var Cd=Object.defineProperty;var _d=(t,e,n)=>e in t?Cd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var wo=(t,e,n)=>_d(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function Td(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ku={exports:{}},Li={},Yu={exports:{}},R={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var xr=Symbol.for("react.element"),Ed=Symbol.for("react.portal"),Pd=Symbol.for("react.fragment"),Ld=Symbol.for("react.strict_mode"),zd=Symbol.for("react.profiler"),Md=Symbol.for("react.provider"),Fd=Symbol.for("react.context"),Nd=Symbol.for("react.forward_ref"),Ad=Symbol.for("react.suspense"),Rd=Symbol.for("react.memo"),Od=Symbol.for("react.lazy"),Io=Symbol.iterator;function Dd(t){return t===null||typeof t!="object"?null:(t=Io&&t[Io]||t["@@iterator"],typeof t=="function"?t:null)}var Ju={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qu=Object.assign,bu={};function Nn(t,e,n){this.props=t,this.context=e,this.refs=bu,this.updater=n||Ju}Nn.prototype.isReactComponent={};Nn.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Nn.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function ea(){}ea.prototype=Nn.prototype;function Ss(t,e,n){this.props=t,this.context=e,this.refs=bu,this.updater=n||Ju}var ks=Ss.prototype=new ea;ks.constructor=Ss;qu(ks,Nn.prototype);ks.isPureReactComponent=!0;var xo=Array.isArray,ta=Object.prototype.hasOwnProperty,ws={current:null},na={key:!0,ref:!0,__self:!0,__source:!0};function ra(t,e,n){var r,i={},l=null,s=null;if(e!=null)for(r in e.ref!==void 0&&(s=e.ref),e.key!==void 0&&(l=""+e.key),e)ta.call(e,r)&&!na.hasOwnProperty(r)&&(i[r]=e[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1>>1,G=T[W];if(0>>1;Wi(mt,F))Gei(vt,mt)?(T[W]=vt,T[Ge]=F,W=Ge):(T[W]=mt,T[te]=F,W=te);else if(Gei(vt,F))T[W]=vt,T[Ge]=F,W=Ge;else break e}}return A}function i(T,A){var F=T.sortIndex-A.sortIndex;return F!==0?F:T.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var u=[],a=[],p=1,m=null,g=3,k=!1,y=!1,f=!1,S=typeof setTimeout=="function"?setTimeout:null,d=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(T){for(var A=n(a);A!==null;){if(A.callback===null)r(a);else if(A.startTime<=T)r(a),A.sortIndex=A.expirationTime,e(u,A);else break;A=n(a)}}function v(T){if(f=!1,h(T),!y)if(n(u)!==null)y=!0,tt(w);else{var A=n(a);A!==null&&Bt(v,A.startTime-T)}}function w(T,A){y=!1,f&&(f=!1,d(L),L=-1),k=!0;var F=g;try{for(h(A),m=n(u);m!==null&&(!(m.expirationTime>A)||T&&!le());){var W=m.callback;if(typeof W=="function"){m.callback=null,g=m.priorityLevel;var G=W(m.expirationTime<=A);A=t.unstable_now(),typeof G=="function"?m.callback=G:m===n(u)&&r(u),h(A)}else r(u);m=n(u)}if(m!==null)var nt=!0;else{var te=n(a);te!==null&&Bt(v,te.startTime-A),nt=!1}return nt}finally{m=null,g=F,k=!1}}var C=!1,_=null,L=-1,O=5,N=-1;function le(){return!(t.unstable_now()-NT||125W?(T.sortIndex=F,e(a,T),n(u)===null&&T===n(a)&&(f?(d(L),L=-1):f=!0,Bt(v,F-W))):(T.sortIndex=G,e(u,T),y||k||(y=!0,tt(w))),T},t.unstable_shouldYield=le,t.unstable_wrapCallback=function(T){var A=g;return function(){var F=g;g=A;try{return T.apply(this,arguments)}finally{g=F}}}})(ua);oa.exports=ua;var Kd=oa.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Yd=E,Le=Kd;function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xl=Object.prototype.hasOwnProperty,Jd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,_o={},To={};function qd(t){return xl.call(To,t)?!0:xl.call(_o,t)?!1:Jd.test(t)?To[t]=!0:(_o[t]=!0,!1)}function bd(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function eh(t,e,n,r){if(e===null||typeof e>"u"||bd(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ye(t,e,n,r,i,l,s){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=l,this.removeEmptyString=s}var ce={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ce[t]=new ye(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];ce[e]=new ye(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ce[t]=new ye(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ce[t]=new ye(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ce[t]=new ye(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ce[t]=new ye(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ce[t]=new ye(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ce[t]=new ye(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ce[t]=new ye(t,5,!1,t.toLowerCase(),null,!1,!1)});var xs=/[\-:]([a-z])/g;function Cs(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(xs,Cs);ce[e]=new ye(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(xs,Cs);ce[e]=new ye(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(xs,Cs);ce[e]=new ye(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ce[t]=new ye(t,1,!1,t.toLowerCase(),null,!1,!1)});ce.xlinkHref=new ye("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ce[t]=new ye(t,1,!1,t.toLowerCase(),null,!0,!0)});function _s(t,e,n,r){var i=ce.hasOwnProperty(e)?ce[e]:null;(i!==null?i.type!==0:r||!(2o||i[s]!==l[o]){var u=` `+i[s].replace(" at new "," at ");return t.displayName&&u.includes("")&&(u=u.replace("",t.displayName)),u}while(1<=s&&0<=o);break}}}finally{Ki=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Qn(t):""}function th(t){switch(t.tag){case 5:return Qn(t.type);case 16:return Qn("Lazy");case 13:return Qn("Suspense");case 19:return Qn("SuspenseList");case 0:case 2:case 15:return t=Yi(t.type,!1),t;case 11:return t=Yi(t.type.render,!1),t;case 1:return t=Yi(t.type,!0),t;default:return""}}function El(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case sn:return"Fragment";case ln:return"Portal";case Cl:return"Profiler";case Ts:return"StrictMode";case _l:return"Suspense";case Tl:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case da:return(t.displayName||"Context")+".Consumer";case ca:return(t._context.displayName||"Context")+".Provider";case Es:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ps:return e=t.displayName||null,e!==null?e:El(t.type)||"Memo";case kt:e=t._payload,t=t._init;try{return El(t(e))}catch{}}return null}function nh(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return El(e);case 8:return e===Ts?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function At(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function fa(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function rh(t){var e=fa(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,l=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,l.call(this,s)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Mr(t){t._valueTracker||(t._valueTracker=rh(t))}function pa(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=fa(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function ii(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Pl(t,e){var n=e.checked;return J({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Po(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=At(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function ga(t,e){e=e.checked,e!=null&&_s(t,"checked",e,!1)}function Ll(t,e){ga(t,e);var n=At(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?zl(t,e.type,n):e.hasOwnProperty("defaultValue")&&zl(t,e.type,At(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Lo(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function zl(t,e,n){(e!=="number"||ii(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Gn=Array.isArray;function Sn(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Fr.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function or(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Jn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ih=["Webkit","ms","Moz","O"];Object.keys(Jn).forEach(function(t){ih.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Jn[e]=Jn[t]})});function Sa(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Jn.hasOwnProperty(t)&&Jn[t]?(""+e).trim():e+"px"}function ka(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Sa(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var lh=J({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Nl(t,e){if(e){if(lh[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(x(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(x(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(x(61))}if(e.style!=null&&typeof e.style!="object")throw Error(x(62))}}function Al(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rl=null;function Ls(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Ol=null,kn=null,wn=null;function Fo(t){if(t=Tr(t)){if(typeof Ol!="function")throw Error(x(280));var e=t.stateNode;e&&(e=Ai(e),Ol(t.stateNode,t.type,e))}}function wa(t){kn?wn?wn.push(t):wn=[t]:kn=t}function Ia(){if(kn){var t=kn,e=wn;if(wn=kn=null,Fo(t),e)for(t=0;t>>=0,t===0?32:31-(mh(t)/vh|0)|0}var Nr=64,Ar=4194304;function Kn(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ui(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,l=t.pingedLanes,s=n&268435455;if(s!==0){var o=s&~i;o!==0?r=Kn(o):(l&=s,l!==0&&(r=Kn(l)))}else s=n&~i,s!==0?r=Kn(s):l!==0&&(r=Kn(l));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,l=e&-e,i>=l||i===16&&(l&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Cr(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Xe(e),t[e]=n}function wh(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=bn),Wo=" ",Vo=!1;function Va(t,e){switch(t){case"keyup":return Kh.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ha(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var on=!1;function Jh(t,e){switch(t){case"compositionend":return Ha(e);case"keypress":return e.which!==32?null:(Vo=!0,Wo);case"textInput":return t=e.data,t===Wo&&Vo?null:t;default:return null}}function qh(t,e){if(on)return t==="compositionend"||!Ds&&Va(t,e)?(t=Ua(),Kr=As=Ct=null,on=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Zo(n)}}function Qa(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Qa(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ga(){for(var t=window,e=ii();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=ii(t.document)}return e}function js(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function uf(t){var e=Ga(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Qa(n.ownerDocument.documentElement,n)){if(r!==null&&js(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,l=Math.min(r.start,i);r=r.end===void 0?l:Math.min(r.end,i),!t.extend&&l>r&&(i=r,r=l,l=i),i=Qo(n,l);var s=Qo(n,r);i&&s&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),l>r?(t.addRange(e),t.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,un=null,Vl=null,tr=null,Hl=!1;function Go(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hl||un==null||un!==ii(r)||(r=un,"selectionStart"in r&&js(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),tr&&fr(tr,r)||(tr=r,r=di(Vl,"onSelect"),0dn||(t.current=Kl[dn],Kl[dn]=null,dn--)}function H(t,e){dn++,Kl[dn]=t.current,t.current=e}var Rt={},pe=Dt(Rt),Ie=Dt(!1),Kt=Rt;function En(t,e){var n=t.type.contextTypes;if(!n)return Rt;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},l;for(l in n)i[l]=e[l];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function xe(t){return t=t.childContextTypes,t!=null}function fi(){X(Ie),X(pe)}function tu(t,e,n){if(pe.current!==Rt)throw Error(x(168));H(pe,e),H(Ie,n)}function rc(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,nh(t)||"Unknown",i));return J({},n,r)}function pi(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Rt,Kt=pe.current,H(pe,t),H(Ie,Ie.current),!0}function nu(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=rc(t,e,Kt),r.__reactInternalMemoizedMergedChildContext=t,X(Ie),X(pe),H(pe,t)):X(Ie),H(Ie,n)}var lt=null,Ri=!1,cl=!1;function ic(t){lt===null?lt=[t]:lt.push(t)}function kf(t){Ri=!0,ic(t)}function jt(){if(!cl&<!==null){cl=!0;var t=0,e=B;try{var n=lt;for(B=1;t>=s,i-=s,st=1<<32-Xe(e)+i|n<L?(O=_,_=null):O=_.sibling;var N=g(d,_,h[L],v);if(N===null){_===null&&(_=O);break}t&&_&&N.alternate===null&&e(d,_),c=l(N,c,L),C===null?w=N:C.sibling=N,C=N,_=O}if(L===h.length)return n(d,_),Q&&Wt(d,L),w;if(_===null){for(;LL?(O=_,_=null):O=_.sibling;var le=g(d,_,N.value,v);if(le===null){_===null&&(_=O);break}t&&_&&le.alternate===null&&e(d,_),c=l(le,c,L),C===null?w=le:C.sibling=le,C=le,_=O}if(N.done)return n(d,_),Q&&Wt(d,L),w;if(_===null){for(;!N.done;L++,N=h.next())N=m(d,N.value,v),N!==null&&(c=l(N,c,L),C===null?w=N:C.sibling=N,C=N);return Q&&Wt(d,L),w}for(_=r(d,_);!N.done;L++,N=h.next())N=k(_,d,L,N.value,v),N!==null&&(t&&N.alternate!==null&&_.delete(N.key===null?L:N.key),c=l(N,c,L),C===null?w=N:C.sibling=N,C=N);return t&&_.forEach(function(Be){return e(d,Be)}),Q&&Wt(d,L),w}function S(d,c,h,v){if(typeof h=="object"&&h!==null&&h.type===sn&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case zr:e:{for(var w=h.key,C=c;C!==null;){if(C.key===w){if(w=h.type,w===sn){if(C.tag===7){n(d,C.sibling),c=i(C,h.props.children),c.return=d,d=c;break e}}else if(C.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===kt&&lu(w)===C.type){n(d,C.sibling),c=i(C,h.props),c.ref=Hn(d,C,h),c.return=d,d=c;break e}n(d,C);break}else e(d,C);C=C.sibling}h.type===sn?(c=Gt(h.props.children,d.mode,v,h.key),c.return=d,d=c):(v=ri(h.type,h.key,h.props,null,d.mode,v),v.ref=Hn(d,c,h),v.return=d,d=v)}return s(d);case ln:e:{for(C=h.key;c!==null;){if(c.key===C)if(c.tag===4&&c.stateNode.containerInfo===h.containerInfo&&c.stateNode.implementation===h.implementation){n(d,c.sibling),c=i(c,h.children||[]),c.return=d,d=c;break e}else{n(d,c);break}else e(d,c);c=c.sibling}c=yl(h,d.mode,v),c.return=d,d=c}return s(d);case kt:return C=h._init,S(d,c,C(h._payload),v)}if(Gn(h))return y(d,c,h,v);if(jn(h))return f(d,c,h,v);Wr(d,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,c!==null&&c.tag===6?(n(d,c.sibling),c=i(c,h),c.return=d,d=c):(n(d,c),c=vl(h,d.mode,v),c.return=d,d=c),s(d)):n(d,c)}return S}var Ln=uc(!0),ac=uc(!1),vi=Dt(null),yi=null,pn=null,Vs=null;function Hs(){Vs=pn=yi=null}function $s(t){var e=vi.current;X(vi),t._currentValue=e}function ql(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function xn(t,e){yi=t,Vs=pn=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(we=!0),t.firstContext=null)}function De(t){var e=t._currentValue;if(Vs!==t)if(t={context:t,memoizedValue:e,next:null},pn===null){if(yi===null)throw Error(x(308));pn=t,yi.dependencies={lanes:0,firstContext:t}}else pn=pn.next=t;return e}var Xt=null;function Xs(t){Xt===null?Xt=[t]:Xt.push(t)}function cc(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,Xs(e)):(n.next=i.next,i.next=n),e.interleaved=n,dt(t,r)}function dt(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var wt=!1;function Zs(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ut(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function zt(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,D&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,dt(t,n)}return i=r.interleaved,i===null?(e.next=e,Xs(r)):(e.next=i.next,i.next=e),r.interleaved=e,dt(t,n)}function Jr(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ms(t,n)}}function su(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?i=l=s:l=l.next=s,n=n.next}while(n!==null);l===null?i=l=e:l=l.next=e}else i=l=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:l,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Si(t,e,n,r){var i=t.updateQueue;wt=!1;var l=i.firstBaseUpdate,s=i.lastBaseUpdate,o=i.shared.pending;if(o!==null){i.shared.pending=null;var u=o,a=u.next;u.next=null,s===null?l=a:s.next=a,s=u;var p=t.alternate;p!==null&&(p=p.updateQueue,o=p.lastBaseUpdate,o!==s&&(o===null?p.firstBaseUpdate=a:o.next=a,p.lastBaseUpdate=u))}if(l!==null){var m=i.baseState;s=0,p=a=u=null,o=l;do{var g=o.lane,k=o.eventTime;if((r&g)===g){p!==null&&(p=p.next={eventTime:k,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var y=t,f=o;switch(g=e,k=n,f.tag){case 1:if(y=f.payload,typeof y=="function"){m=y.call(k,m,g);break e}m=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=f.payload,g=typeof y=="function"?y.call(k,m,g):y,g==null)break e;m=J({},m,g);break e;case 2:wt=!0}}o.callback!==null&&o.lane!==0&&(t.flags|=64,g=i.effects,g===null?i.effects=[o]:g.push(o))}else k={eventTime:k,lane:g,tag:o.tag,payload:o.payload,callback:o.callback,next:null},p===null?(a=p=k,u=m):p=p.next=k,s|=g;if(o=o.next,o===null){if(o=i.shared.pending,o===null)break;g=o,o=g.next,g.next=null,i.lastBaseUpdate=g,i.shared.pending=null}}while(!0);if(p===null&&(u=m),i.baseState=u,i.firstBaseUpdate=a,i.lastBaseUpdate=p,e=i.shared.interleaved,e!==null){i=e;do s|=i.lane,i=i.next;while(i!==e)}else l===null&&(i.shared.lanes=0);qt|=s,t.lanes=s,t.memoizedState=m}}function ou(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=hl.transition;hl.transition={};try{t(!1),e()}finally{B=n,hl.transition=r}}function Pc(){return je().memoizedState}function Cf(t,e,n){var r=Ft(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Lc(t))zc(e,n);else if(n=cc(t,e,n,r),n!==null){var i=me();Ze(n,t,r,i),Mc(n,e,r)}}function _f(t,e,n){var r=Ft(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Lc(t))zc(e,i);else{var l=t.alternate;if(t.lanes===0&&(l===null||l.lanes===0)&&(l=e.lastRenderedReducer,l!==null))try{var s=e.lastRenderedState,o=l(s,n);if(i.hasEagerState=!0,i.eagerState=o,Qe(o,s)){var u=e.interleaved;u===null?(i.next=i,Xs(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}n=cc(t,e,i,r),n!==null&&(i=me(),Ze(n,t,r,i),Mc(n,e,r))}}function Lc(t){var e=t.alternate;return t===Y||e!==null&&e===Y}function zc(t,e){nr=wi=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Mc(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ms(t,n)}}var Ii={readContext:De,useCallback:de,useContext:de,useEffect:de,useImperativeHandle:de,useInsertionEffect:de,useLayoutEffect:de,useMemo:de,useReducer:de,useRef:de,useState:de,useDebugValue:de,useDeferredValue:de,useTransition:de,useMutableSource:de,useSyncExternalStore:de,useId:de,unstable_isNewReconciler:!1},Tf={readContext:De,useCallback:function(t,e){return Je().memoizedState=[t,e===void 0?null:e],t},useContext:De,useEffect:au,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,br(4194308,4,xc.bind(null,e,t),n)},useLayoutEffect:function(t,e){return br(4194308,4,t,e)},useInsertionEffect:function(t,e){return br(4,2,t,e)},useMemo:function(t,e){var n=Je();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Je();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=Cf.bind(null,Y,t),[r.memoizedState,t]},useRef:function(t){var e=Je();return t={current:t},e.memoizedState=t},useState:uu,useDebugValue:eo,useDeferredValue:function(t){return Je().memoizedState=t},useTransition:function(){var t=uu(!1),e=t[0];return t=xf.bind(null,t[1]),Je().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Y,i=Je();if(Q){if(n===void 0)throw Error(x(407));n=n()}else{if(n=e(),oe===null)throw Error(x(349));Jt&30||gc(r,e,n)}i.memoizedState=n;var l={value:n,getSnapshot:e};return i.queue=l,au(vc.bind(null,r,l,t),[t]),r.flags|=2048,wr(9,mc.bind(null,r,l,n,e),void 0,null),n},useId:function(){var t=Je(),e=oe.identifierPrefix;if(Q){var n=ot,r=st;n=(r&~(1<<32-Xe(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Sr++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=s.createElement(n,{is:r.is}):(t=s.createElement(n),n==="select"&&(s=t,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):t=s.createElementNS(t,n),t[qe]=e,t[mr]=r,Wc(t,e,!1,!1),e.stateNode=t;e:{switch(s=Al(n,r),n){case"dialog":$("cancel",t),$("close",t),i=r;break;case"iframe":case"object":case"embed":$("load",t),i=r;break;case"video":case"audio":for(i=0;iFn&&(e.flags|=128,r=!0,$n(l,!1),e.lanes=4194304)}else{if(!r)if(t=ki(s),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),$n(l,!0),l.tail===null&&l.tailMode==="hidden"&&!s.alternate&&!Q)return he(e),null}else 2*b()-l.renderingStartTime>Fn&&n!==1073741824&&(e.flags|=128,r=!0,$n(l,!1),e.lanes=4194304);l.isBackwards?(s.sibling=e.child,e.child=s):(n=l.last,n!==null?n.sibling=s:e.child=s,l.last=s)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=b(),e.sibling=null,n=K.current,H(K,r?n&1|2:n&1),e):(he(e),null);case 22:case 23:return so(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Te&1073741824&&(he(e),e.subtreeFlags&6&&(e.flags|=8192)):he(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function Af(t,e){switch(Us(e),e.tag){case 1:return xe(e.type)&&fi(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return zn(),X(Ie),X(pe),Ks(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Gs(e),null;case 13:if(X(K),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Pn()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return X(K),null;case 4:return zn(),null;case 10:return $s(e.type._context),null;case 22:case 23:return so(),null;case 24:return null;default:return null}}var Hr=!1,fe=!1,Rf=typeof WeakSet=="function"?WeakSet:Set,z=null;function gn(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){q(t,e,r)}else n.current=null}function os(t,e,n){try{n()}catch(r){q(t,e,r)}}var ku=!1;function Of(t,e){if($l=ai,t=Ga(),js(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var s=0,o=-1,u=-1,a=0,p=0,m=t,g=null;t:for(;;){for(var k;m!==n||i!==0&&m.nodeType!==3||(o=s+i),m!==l||r!==0&&m.nodeType!==3||(u=s+r),m.nodeType===3&&(s+=m.nodeValue.length),(k=m.firstChild)!==null;)g=m,m=k;for(;;){if(m===t)break t;if(g===n&&++a===i&&(o=s),g===l&&++p===r&&(u=s),(k=m.nextSibling)!==null)break;m=g,g=m.parentNode}m=k}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Xl={focusedElem:t,selectionRange:n},ai=!1,z=e;z!==null;)if(e=z,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,z=t;else for(;z!==null;){e=z;try{var y=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var f=y.memoizedProps,S=y.memoizedState,d=e.stateNode,c=d.getSnapshotBeforeUpdate(e.elementType===e.type?f:Ve(e.type,f),S);d.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var h=e.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(v){q(e,e.return,v)}if(t=e.sibling,t!==null){t.return=e.return,z=t;break}z=e.return}return y=ku,ku=!1,y}function rr(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var l=i.destroy;i.destroy=void 0,l!==void 0&&os(e,n,l)}i=i.next}while(i!==r)}}function ji(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function us(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function $c(t){var e=t.alternate;e!==null&&(t.alternate=null,$c(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[qe],delete e[mr],delete e[Gl],delete e[yf],delete e[Sf])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Xc(t){return t.tag===5||t.tag===3||t.tag===4}function wu(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Xc(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function as(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=hi));else if(r!==4&&(t=t.child,t!==null))for(as(t,e,n),t=t.sibling;t!==null;)as(t,e,n),t=t.sibling}function cs(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(cs(t,e,n),t=t.sibling;t!==null;)cs(t,e,n),t=t.sibling}var ue=null,He=!1;function yt(t,e,n){for(n=n.child;n!==null;)Zc(t,e,n),n=n.sibling}function Zc(t,e,n){if(be&&typeof be.onCommitFiberUnmount=="function")try{be.onCommitFiberUnmount(zi,n)}catch{}switch(n.tag){case 5:fe||gn(n,e);case 6:var r=ue,i=He;ue=null,yt(t,e,n),ue=r,He=i,ue!==null&&(He?(t=ue,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):ue.removeChild(n.stateNode));break;case 18:ue!==null&&(He?(t=ue,n=n.stateNode,t.nodeType===8?al(t.parentNode,n):t.nodeType===1&&al(t,n),dr(t)):al(ue,n.stateNode));break;case 4:r=ue,i=He,ue=n.stateNode.containerInfo,He=!0,yt(t,e,n),ue=r,He=i;break;case 0:case 11:case 14:case 15:if(!fe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var l=i,s=l.destroy;l=l.tag,s!==void 0&&(l&2||l&4)&&os(n,e,s),i=i.next}while(i!==r)}yt(t,e,n);break;case 1:if(!fe&&(gn(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){q(n,e,o)}yt(t,e,n);break;case 21:yt(t,e,n);break;case 22:n.mode&1?(fe=(r=fe)||n.memoizedState!==null,yt(t,e,n),fe=r):yt(t,e,n);break;default:yt(t,e,n)}}function Iu(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Rf),e.forEach(function(r){var i=Xf.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Ue(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~l}if(r=i,r=b()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*jf(r/1960))-r,10t?16:t,_t===null)var r=!1;else{if(t=_t,_t=null,_i=0,D&6)throw Error(x(331));var i=D;for(D|=4,z=t.current;z!==null;){var l=z,s=l.child;if(z.flags&16){var o=l.deletions;if(o!==null){for(var u=0;ub()-io?Qt(t,0):ro|=n),Ce(t,e)}function ed(t,e){e===0&&(t.mode&1?(e=Ar,Ar<<=1,!(Ar&130023424)&&(Ar=4194304)):e=1);var n=me();t=dt(t,e),t!==null&&(Cr(t,e,n),Ce(t,n))}function $f(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),ed(t,n)}function Xf(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),ed(t,n)}var td;td=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ie.current)we=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return we=!1,Ff(t,e,n);we=!!(t.flags&131072)}else we=!1,Q&&e.flags&1048576&&lc(e,mi,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ei(t,e),t=e.pendingProps;var i=En(e,pe.current);xn(e,n),i=Js(null,e,r,t,i,n);var l=qs();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,xe(r)?(l=!0,pi(e)):l=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Zs(e),i.updater=Di,e.stateNode=i,i._reactInternals=e,es(e,r,t,n),e=rs(null,e,r,!0,l,n)):(e.tag=0,Q&&l&&Bs(e),ge(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(ei(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Qf(r),t=Ve(r,t),i){case 0:e=ns(null,e,r,t,n);break e;case 1:e=vu(null,e,r,t,n);break e;case 11:e=gu(null,e,r,t,n);break e;case 14:e=mu(null,e,r,Ve(r.type,t),n);break e}throw Error(x(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ve(r,i),ns(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ve(r,i),vu(t,e,r,i,n);case 3:e:{if(jc(e),t===null)throw Error(x(387));r=e.pendingProps,l=e.memoizedState,i=l.element,dc(t,e),Si(e,r,null,n);var s=e.memoizedState;if(r=s.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=l,e.memoizedState=l,e.flags&256){i=Mn(Error(x(423)),e),e=yu(t,e,r,n,i);break e}else if(r!==i){i=Mn(Error(x(424)),e),e=yu(t,e,r,n,i);break e}else for(Ee=Lt(e.stateNode.containerInfo.firstChild),Pe=e,Q=!0,$e=null,n=ac(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pn(),r===i){e=ht(t,e,n);break e}ge(t,e,r,n)}e=e.child}return e;case 5:return hc(e),t===null&&Jl(e),r=e.type,i=e.pendingProps,l=t!==null?t.memoizedProps:null,s=i.children,Zl(r,i)?s=null:l!==null&&Zl(r,l)&&(e.flags|=32),Dc(t,e),ge(t,e,s,n),e.child;case 6:return t===null&&Jl(e),null;case 13:return Bc(t,e,n);case 4:return Qs(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ln(e,null,r,n):ge(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ve(r,i),gu(t,e,r,i,n);case 7:return ge(t,e,e.pendingProps,n),e.child;case 8:return ge(t,e,e.pendingProps.children,n),e.child;case 12:return ge(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,l=e.memoizedProps,s=i.value,H(vi,r._currentValue),r._currentValue=s,l!==null)if(Qe(l.value,s)){if(l.children===i.children&&!Ie.current){e=ht(t,e,n);break e}}else for(l=e.child,l!==null&&(l.return=e);l!==null;){var o=l.dependencies;if(o!==null){s=l.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(l.tag===1){u=ut(-1,n&-n),u.tag=2;var a=l.updateQueue;if(a!==null){a=a.shared;var p=a.pending;p===null?u.next=u:(u.next=p.next,p.next=u),a.pending=u}}l.lanes|=n,u=l.alternate,u!==null&&(u.lanes|=n),ql(l.return,n,e),o.lanes|=n;break}u=u.next}}else if(l.tag===10)s=l.type===e.type?null:l.child;else if(l.tag===18){if(s=l.return,s===null)throw Error(x(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ql(s,n,e),s=l.sibling}else s=l.child;if(s!==null)s.return=l;else for(s=l;s!==null;){if(s===e){s=null;break}if(l=s.sibling,l!==null){l.return=s.return,s=l;break}s=s.return}l=s}ge(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,xn(e,n),i=De(i),r=r(i),e.flags|=1,ge(t,e,r,n),e.child;case 14:return r=e.type,i=Ve(r,e.pendingProps),i=Ve(r.type,i),mu(t,e,r,i,n);case 15:return Rc(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ve(r,i),ei(t,e),e.tag=1,xe(r)?(t=!0,pi(e)):t=!1,xn(e,n),Fc(e,r,i),es(e,r,i,n),rs(null,e,r,!0,t,n);case 19:return Uc(t,e,n);case 22:return Oc(t,e,n)}throw Error(x(156,e.tag))};function nd(t,e){return La(t,e)}function Zf(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Re(t,e,n,r){return new Zf(t,e,n,r)}function uo(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Qf(t){if(typeof t=="function")return uo(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Es)return 11;if(t===Ps)return 14}return 2}function Nt(t,e){var n=t.alternate;return n===null?(n=Re(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function ri(t,e,n,r,i,l){var s=2;if(r=t,typeof t=="function")uo(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case sn:return Gt(n.children,i,l,e);case Ts:s=8,i|=8;break;case Cl:return t=Re(12,n,e,i|2),t.elementType=Cl,t.lanes=l,t;case _l:return t=Re(13,n,e,i),t.elementType=_l,t.lanes=l,t;case Tl:return t=Re(19,n,e,i),t.elementType=Tl,t.lanes=l,t;case ha:return Ui(n,i,l,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ca:s=10;break e;case da:s=9;break e;case Es:s=11;break e;case Ps:s=14;break e;case kt:s=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=Re(s,n,e,i),e.elementType=t,e.type=r,e.lanes=l,e}function Gt(t,e,n,r){return t=Re(7,t,r,e),t.lanes=n,t}function Ui(t,e,n,r){return t=Re(22,t,r,e),t.elementType=ha,t.lanes=n,t.stateNode={isHidden:!1},t}function vl(t,e,n){return t=Re(6,t,null,e),t.lanes=n,t}function yl(t,e,n){return e=Re(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Gf(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qi(0),this.expirationTimes=qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qi(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ao(t,e,n,r,i,l,s,o,u){return t=new Gf(t,e,n,o,u),e===1?(e=1,l===!0&&(e|=8)):e=0,l=Re(3,null,null,e),t.current=l,l.stateNode=t,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zs(l),t}function Kf(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sd)}catch(t){console.error(t)}}sd(),sa.exports=ze;var ep=sa.exports,zu=ep;Il.createRoot=zu.createRoot,Il.hydrateRoot=zu.hydrateRoot;class od{constructor({startTime:e,endTime:n,energy:r,audioData:i}){this.startTime=e,this.endTime=n,this.energy=r,this.audioData=i,this.isProcessed=!1,this.transcription=""}getDuration(){return this.endTime-this.startTime}isSilence(){return!1}}class ud{constructor(e={}){this.options={sampleRate:16e3,windowSize:1600,minSpeechDuration:.3,silenceThreshold:.8,energyThreshold:.125,smaLength:6,lookbackChunks:3,overlapDuration:.2,maxHistoryLength:10,logger:console.log,...e},this.reset()}log(e,n=null){typeof this.options.logger=="function"&&this.options.logger(e,n)}processAudioData(e,n,r,i,l){if(!e||!e.length)return[];const s=[],o=r>this.options.energyThreshold;if(this.state.recentChunks.push({time:n,energy:r,isSpeech:o}),this.state.recentChunks.length>10&&this.state.recentChunks.shift(),!this.state.inSpeech&&o){let u=this.findSpeechStart(),a=u!==-1?this.state.recentChunks[u].time:n;this.startSpeech(a,r),this.log("Speech start detected",{detectedAt:n.toFixed(2),actualStart:a.toFixed(2),lookbackDiff:(n-a).toFixed(2)})}else if(this.state.inSpeech&&!o){if(this.state.silenceCounter++,this.state.silenceCounter>=this.options.silenceThreshold*10){if(this.state.speechStartTime!==null){const a=n-this.state.speechStartTime,p=this.state.speechEnergies.reduce((m,g)=>m+g,0)/this.state.speechEnergies.length;this.state.speechStats.push({startTime:this.state.speechStartTime,endTime:n,duration:a,avgEnergy:p,energyIntegral:p*a}),this.state.speechStats.length>this.options.maxHistoryLength&&this.state.speechStats.shift()}const u=this.createSegment(this.state.speechStartTime,n,i,this.options.sampleRate);u&&s.push(u),this.startSilence(n)}}else this.state.inSpeech?this.state.speechEnergies.push(r):this.state.silenceEnergies.push(r);return this.updateStats(),s}startSpeech(e,n){this.state.inSpeech=!0,this.state.speechStartTime=e,this.state.silenceCounter=0,this.state.speechEnergies=[n],this.state.silenceStartTime=null}startSilence(e){this.state.inSpeech=!1,this.state.silenceStartTime=e,this.state.speechStartTime=null,this.state.silenceCounter=0,this.state.silenceEnergies=[]}updateStats(){const e={silence:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0},speech:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0}};this.state.silenceStats.length>0&&(e.silence={avgDuration:this.average(this.state.silenceStats.map(n=>n.duration)),avgEnergy:this.average(this.state.silenceStats.map(n=>n.avgEnergy)),avgEnergyIntegral:this.average(this.state.silenceStats.map(n=>n.energyIntegral))}),this.state.speechStats.length>0&&(e.speech={avgDuration:this.average(this.state.speechStats.map(n=>n.duration)),avgEnergy:this.average(this.state.speechStats.map(n=>n.avgEnergy)),avgEnergyIntegral:this.average(this.state.speechStats.map(n=>n.energyIntegral))}),this.state.currentStats=e}average(e){return e.reduce((n,r)=>n+r,0)/e.length}getStats(){return this.state.currentStats}reset(){this.state={inSpeech:!1,speechStartTime:null,silenceStartTime:null,silenceCounter:0,recentChunks:[],speechEnergies:[],silenceEnergies:[],speechStats:[],silenceStats:[],currentStats:{silence:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0},speech:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0}}}}setThreshold(e){this.options.energyThreshold=e,this.log("Updated energy threshold:",e)}setSilenceLength(e){this.options.silenceThreshold=e}createSegment(e,n,r,i){const o=Math.floor(.5*i),u=Math.floor(.3*i),a=Math.floor(e*i),p=Math.floor(n*i),m=Math.max(0,a-o),g=Math.min(r.length,p+u);if(m>=r.length||g<=0)return this.log("Invalid segment boundaries",{start:e,end:n,startSample:m,endSample:g,bufferLength:r.length,lookback:.5,overlap:.3}),null;const k=g-m;if(k<=0)return this.log("Invalid segment length",{length:k,start:e,end:n}),null;const y=new Float32Array(k);y.set(r.slice(m,g));const f=new od({startTime:e-.5,endTime:n+.3,audioData:y,sampleRate:i,energy:this.state.speechEnergies.reduce((S,d)=>S+d,0)/this.state.speechEnergies.length});return this.log("Created segment",{originalStart:e.toFixed(2),originalEnd:n.toFixed(2),finalStart:f.startTime.toFixed(2),finalEnd:f.endTime.toFixed(2),duration:(f.endTime-f.startTime).toFixed(2),samples:k,lookbackSamples:o,overlapSamples:u}),f}findSpeechStart(){const e=this.state.recentChunks;let n=e.length-1;for(;n>=0;){if(!e[n].isSpeech){let r=0;for(;n>=0&&!e[n].isSpeech;)r++,n--;if(r>=3)return n+1}n--}return 0}}const yn=class yn{constructor(){if(yn.instance)return yn.instance;this.audioContext=null,this.processor=null,this.listeners=new Set,this.initialized=!1,this.parameters={threshold:.125,silenceLength:.8,minSpeechDuration:.3},this.segments=[],this.recordedChunks=[],this.audioBuffer=new Float32Array(0),this.lastProcessedTime=0,this._activeTranscriptions=new Set,this.worker=null,this.language="en",this._nextSegmentId=0,this._metrics={currentEnergy:0,averageEnergy:0,peakEnergy:0,rawPeakValue:0,bufferDuration:0,recentAudioData:new Float32Array(48e3)},this._visualizationBuffer=new Float32Array(16e3*30),this._visualizationBufferPosition=0,yn.instance=this}async initialize(e={}){if(!this.initialized)try{this.options=e,this.processor=new ud({sampleRate:e.sampleRate||16e3,onSegmentDetected:this.handleNewSegment.bind(this)}),this.initialized=!0,this.notifyListeners("initialized")}catch(n){throw console.error("Failed to initialize AudioManager:",n),n}}async startAudioContext(){var e;this.audioContext||(this.audioContext=new AudioContext({sampleRate:((e=this.options)==null?void 0:e.sampleRate)||16e3})),this.audioContext.state!=="running"&&await this.audioContext.resume(),this.notifyListeners("audioContextStarted")}processNewChunk(e,n){if(!e||!e.length)return;this.updateVisualizationBuffer(e),this._metrics.currentEnergy=n,this._metrics.averageEnergy=this._metrics.averageEnergy*.95+n*.05,this._metrics.peakEnergy=Math.max(this._metrics.peakEnergy*.99,n),this._metrics.rawPeakValue=Math.max(...Array.from(e).map(Math.abs)),this._metrics.bufferDuration=this.audioBuffer.length/this.options.sampleRate;const r=new Float32Array(this.audioBuffer.length+e.length);r.set(this.audioBuffer),r.set(e,this.audioBuffer.length),this.audioBuffer=r;const i=this.getCurrentTime(),l=this.processor.processAudioData(e,i,n,this.audioBuffer,this.lastProcessedTime);l.length>0&&l.forEach(s=>this.handleNewSegment(s)),this.lastProcessedTime=i}getCurrentTime(){return this.audioContext?this.audioContext.currentTime:0}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(e,n){this.listeners.forEach(r=>r(e,n))}handleNewSegment(e){const n=this.calculateSegmentEnergyIntegral(e),r=e.endTime-e.startTime;if(console.log("Candidate segment detected:",{startTime:e.startTime.toFixed(2),endTime:e.endTime.toFixed(2),duration:r.toFixed(2),energyIntegral:n.toFixed(4),isValidSpeech:r>=this.parameters.minSpeechDuration&&n>=this.parameters.minEnergyIntegral,minDurationRequired:this.parameters.minSpeechDuration,minEnergyIntegralRequired:this.parameters.minEnergyIntegral}),!(r>=this.parameters.minSpeechDuration&&n>=this.parameters.minEnergyIntegral)){console.log("🚫 Filtered out noise segment:",{reason:ro&&(this.segments=this.segments.slice(-o));const u=this.segments.filter(a=>!a.isPartOfMerged&&a.endTime>=e.startTime-.5&&a.id!==e.id);if(u.length>0){const a={startTime:Math.min(...u.map(p=>p.startTime),e.startTime),endTime:Math.max(...u.map(p=>p.endTime),e.endTime),id:`merged_${Date.now()}`,isMerged:!0,isProcessed:!1,audioData:this.getMergedAudioData([...u,e]),sampleRate:this.audioContext.sampleRate,originalSegments:[...u,e]};[...u,e].forEach(p=>{p.isPartOfMerged=!0,p.mergedId=a.id}),this.segments.push(a),this.sendForTranscription(a)}else this.sendForTranscription(e);this.notifyListeners("segmentsUpdated",this.segments)}calculateSegmentEnergyIntegral(e){const n=Math.floor(e.startTime*this.audioContext.sampleRate),r=Math.ceil(e.endTime*this.audioContext.sampleRate),i=this.audioBuffer.slice(n,r);let l=0;for(let o=0;os.startTime)),r=Math.max(...e.map(s=>s.endTime)),i=Math.floor(n*this.audioContext.sampleRate),l=Math.ceil(r*this.audioContext.sampleRate);return this.audioBuffer.slice(i,l)}trimSilence(e,n,r=null,i=.5,l=.3){if(!e||e.length===0)return e;const s=i/2,o=l/2,u=Math.floor(s*n),a=Math.floor(o*n),p=Math.floor(.02*n);let m=u,g=e.length-a-1;const k=r??this.parameters.threshold;for(let y=u;yk){m=Math.max(u,y-p);break}}for(let y=e.length-a-p;y>=u;y-=p){let f=0;for(let S=0;Sk){g=Math.min(e.length-a,y+p*2);break}}return e.slice(m,g)}sendForTranscription(e){if(!this.worker||!e.audioData||e.isPartOfMerged&&!e.isMerged||this._activeTranscriptions.has(e.id))return;e.isProcessed=!0,this._activeTranscriptions.add(e.id);const n=.5,r=.3,i=this.trimSilence(e.audioData,this.audioContext.sampleRate,this.parameters.threshold/2,n,r),l=e.audioData.length/this.audioContext.sampleRate,s=i.length/this.audioContext.sampleRate;console.log("Audio trimming results:",{segmentId:e.id,originalDuration:l.toFixed(2)+"s",trimmedDuration:s.toFixed(2)+"s",reduction:((1-s/l)*100).toFixed(1)+"%",lookbackDuration:n.toFixed(2)+"s",overlapDuration:r.toFixed(2)+"s"}),console.log("Sending for transcription with language:",this.language),this.worker.postMessage({type:"transcribe",data:{audioData:i,language:this.language,segmentId:e.id,isMerged:e.isMerged}})}handleTranscriptionResult({segmentId:e,output:n,isMerged:r}){const i=this.segments.find(l=>l.id===e);if(!i){console.warn("Segment not found:",e);return}i.transcription=n,i.isProcessed=!0,this.notifyListeners("segmentsUpdated",this.segments),console.log("Received transcription result:",{segmentId:e,output:n,isMerged:r})}reset(){this.segments=[],this.recordedChunks=[],this.processor&&this.processor.reset(),this.notifyListeners("reset")}updateParameters(e){var n,r,i,l;Object.assign(this.parameters,e),this.processor&&(e.threshold!==void 0&&((r=(n=this.processor).setThreshold)==null||r.call(n,e.threshold),this.processor.options&&(this.processor.options.energyThreshold=e.threshold)),e.silenceLength!==void 0&&((l=(i=this.processor).setSilenceLength)==null||l.call(i,this.parameters.silenceLength)),this.processor.options&&Object.assign(this.processor.options,{minSpeechDuration:this.parameters.minSpeechDuration,energyScale:this.parameters.energyScale,hysteresisRatio:this.parameters.hysteresisRatio,minEnergyIntegral:this.parameters.minEnergyIntegral})),console.log("Updated threshold:",this.parameters.threshold)}mergeOverlappingSegments(e){if(!e||e.length<2)return e;const n=[];let r=e[0];for(let i=1;ii)this._visualizationBuffer.set(e,i);else{const s=n-i;this._visualizationBuffer.set(e.slice(0,s),i),this._visualizationBuffer.set(e.slice(s),0)}this._visualizationBufferPosition=l}getVisualizationData(){const e=new Float32Array(this._visualizationBuffer.length),n=this._visualizationBufferPosition;return e.set(this._visualizationBuffer.slice(n),0),e.set(this._visualizationBuffer.slice(0,n),this._visualizationBuffer.length-n),e}getMetrics(){return{...this._metrics}}};wo(yn,"instance",null);let gs=yn;const U=new gs;function tp({threshold:t=.02,segments:e=[]}){const n=E.useRef(null),r=E.useRef(null),i=E.useRef(0);E.useRef(0);const l=E.useCallback((o,u)=>{const a=o.getContext("2d",{alpha:!1,desynchronized:!0});if(a.fillStyle="#f5f5f5",a.fillRect(0,0,o.width,o.height),!(u!=null&&u.length))return;const p=o.height/2,m=o.height/2;a.strokeStyle="#c8c8c8",a.lineWidth=1,a.beginPath();const g=16;for(let S=0;S{const d=S.startTime-f,c=S.endTime-f;if(c>0&&d{if(!o||!u||typeof a!="number")return;o.fillStyle="#f5f5f5",o.fillRect(0,0,u.width,u.height);const m=p*u.width;o.strokeStyle="#ff6b6b",o.lineWidth=2,o.beginPath(),o.moveTo(m,0),o.lineTo(m,u.height),o.stroke();const g=Math.min(a*u.width,u.width);o.fillStyle=a>p?"#4CAF50":"#2196F3",o.fillRect(0,0,g,u.height),o.fillStyle="#666",o.font="12px Arial",o.fillText(`${a.toFixed(3)}`,5,u.height-5)},[]);return E.useEffect(()=>{if(!n.current)return;const o=setInterval(()=>{const u=performance.now();if(u-i.current<50)return;const a=U.getVisualizationData(),p=U.getMetrics();l(n.current,a),r.current&&s(r.current.getContext("2d"),r.current,p.currentEnergy,t),i.current=u},100);return()=>clearInterval(o)},[t,l,s]),I.jsxs("div",{className:"flex flex-col gap-2",children:[I.jsx("canvas",{ref:r,width:480,height:24,className:"w-full border rounded bg-[#f5f5f5]"}),I.jsx("canvas",{ref:n,width:480,height:80,className:"w-full border rounded bg-[#f5f5f5]"})]})}function np(){const[t,e]=E.useState(U.getMetrics());return E.useEffect(()=>{const n=setInterval(()=>{e(U.getMetrics())},100);return()=>clearInterval(n)},[]),I.jsxs("div",{children:[I.jsx("h3",{className:"text-xs font-semibold mb-2",children:"Audio Stats"}),I.jsxs("div",{className:"text-xs space-y-1",children:[I.jsxs("div",{children:["Current Energy: ",t.currentEnergy.toFixed(4)]}),I.jsxs("div",{children:["Average Energy: ",t.averageEnergy.toFixed(4)]}),I.jsxs("div",{children:["Peak Energy: ",t.peakEnergy.toFixed(4)]}),I.jsxs("div",{children:["Buffer Duration: ",t.bufferDuration.toFixed(2),"s"]})]})]})}function rp({className:t,stream:e,threshold:n,onThresholdChange:r,silenceLength:i,onSilenceLengthChange:l,speechHangover:s,onHangoverChange:o,audioContextRef:u,segments:a=[],energyScale:p,onEnergyScaleChange:m,hysteresisRatio:g,onHysteresisChange:k,minSpeechDuration:y,onMinSpeechDurationChange:f,processor:S,minEnergyIntegral:d,onMinEnergyIntegralChange:c}){return I.jsxs("div",{className:t,children:[I.jsx("div",{className:"mb-2",children:I.jsx(tp,{threshold:n,segments:a})}),I.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[I.jsxs("div",{className:"p-3 bg-gray-100 dark:bg-gray-800 rounded-lg",children:[I.jsx("h3",{className:"text-xs font-semibold mb-2",children:"Speech Detection Parameters"}),I.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Energy Threshold: ",n.toFixed(3)]}),I.jsx("input",{type:"range",min:"0.01",max:"0.5",step:"0.01",value:n,onChange:h=>r(parseFloat(h.target.value)),className:"w-full h-4"})]}),I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Energy Scale: ",p.toFixed(1)]}),I.jsx("input",{type:"range",min:"0.1",max:"2.0",step:"0.1",value:p,onChange:h=>m(parseFloat(h.target.value)),className:"w-full h-4"})]}),I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Min Silence (s): ",i.toFixed(2)]}),I.jsx("input",{type:"range",min:"0.1",max:"1.0",step:"0.05",value:i,onChange:h=>l(parseFloat(h.target.value)),className:"w-full h-4"})]}),I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Speech Hangover (s): ",s.toFixed(2)]}),I.jsx("input",{type:"range",min:"0.1",max:"0.5",step:"0.05",value:s,onChange:h=>o(parseFloat(h.target.value)),className:"w-full h-4"})]}),I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Min Speech (s): ",y.toFixed(2)]}),I.jsx("input",{type:"range",min:"0.05",max:"0.5",step:"0.05",value:y,onChange:h=>f(parseFloat(h.target.value)),className:"w-full h-4"})]}),I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Hysteresis: ",g.toFixed(2)]}),I.jsx("input",{type:"range",min:"1.0",max:"2.0",step:"0.1",value:g,onChange:h=>k(parseFloat(h.target.value)),className:"w-full h-4"})]}),I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("label",{className:"text-xs mb-1",children:["Min Energy Integral: ",d.toFixed(3)]}),I.jsx("input",{type:"range",min:"5",max:"50",step:"5",value:d,onChange:h=>c(parseFloat(h.target.value)),className:"w-full h-4"})]})]})]}),I.jsx("div",{className:"p-3 bg-gray-100 dark:bg-gray-800 rounded-lg",children:I.jsx(np,{})})]})]})}function ip(t){const e=t==0?0:Math.floor(Math.log(t)/Math.log(1024));return+(t/Math.pow(1024,e)).toFixed(2)*1+["B","kB","MB","GB","TB"][e]}function lp({text:t,percentage:e,total:n}){return e??(e=0),I.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:I.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${e}%`},children:[t," (",e.toFixed(2),"%",isNaN(n)?"":` of ${ip(n)}`,")"]})})}const vn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function sp(t){let e="";for(let n=0;n>2],e+=vn[(t[n]&3)<<4|t[n+1]>>4],e+=vn[(t[n+1]&15)<<2|t[n+2]>>6],e+=vn[t[n+2]&63];return t.length%3===2?e=e.substring(0,e.length-1)+"=":t.length%3===1&&(e=e.substring(0,e.length-2)+"=="),e}function op(t){let e=new Uint8Array(256);for(let i=0;i>4,r[l++]=(o&15)<<4|u>>2,r[l++]=(u&3)<<6|a&63}return r}function up(t,e,n,r){if(["32f","64"].indexOf(e)>-1&&["32f","64"].indexOf(r)>-1){n.set(t);return}Mu(e),Mu(r);let i=hp(e,r),l={oldMin:Math.pow(2,parseInt(e,10))/2,newMin:Math.pow(2,parseInt(r,10))/2,oldMax:Math.pow(2,parseInt(e,10))/2-1,newMax:Math.pow(2,parseInt(r,10))/2-1};Fu(e,t,!0);for(let s=0,o=t.length;s0?t=parseInt(t/e.oldMax*e.newMax,10):t=parseInt(t/e.oldMin*e.newMin,10),t}function cp(t,e){return parseInt(t>0?t*e.newMax:t*e.newMin,10)}function dp(t,e){return t>0?t/e.oldMax:t/e.oldMin}function hp(t,e){let n=function(r){return r};return t!=e&&(["32f","64"].includes(t)?n=cp:["32f","64"].includes(e)?n=dp:n=ap),n}function Mu(t){if(t!="32f"&&t!="64"&&(parseInt(t,10)<"8"||parseInt(t,10)>"53"))throw new Error("Invalid bit depth.")}function Fu(t,e,n){if(t=="8"){let r=n?-128:128;for(let i=0,l=e.length;i>4,o=s<<4^l;n.push(Nu(o,e)),n.push(Nu(s,e))}return n}function vp(t){return t>32768?t-65536:t}function ms(t,e){let n=t-e.predicted,r=0;n>=0?r=0:(r=8,n=-n);let i=po[e.index],l=i>>3;return n>i&&(r|=4,n-=i,l+=i),i>>=1,n>i&&(r|=2,n-=i,l+=i),i>>=1,n>i&&(r|=1,l+=i),yp(r,l,e),r}function yp(t,e,n){t&8?n.predicted-=e:n.predicted+=e,n.predicted<-32768?n.predicted=-32768:n.predicted>32767&&(n.predicted=32767),n.index+=ad[t&7],n.index<0?n.index=0:n.index>88&&(n.index=88)}function Nu(t,e){let n=0;return t&4&&(n+=e.step),t&2&&(n+=e.step>>1),t&1&&(n+=e.step>>2),n+=e.step>>3,t&8&&(n=-n),e.predicted+=n,e.predicted>32767?e.predicted=32767:e.predicted<-32767&&(e.predicted=-32767),Sp(t,e),e.predicted}function Sp(t,e){e.index+=ad[t],e.index<0?e.index=0:e.index>88&&(e.index=88),e.step=po[e.index]}function kp(t,e){ms(t,e);let n=[];return n.push(t&255),n.push(t>>8&255),n.push(e.index),n.push(0),n}const wp=[1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];function Ip(t){let e;t=t==-32768?-32767:t;let n=~t>>8&128;if(n||(t=t*-1),t>32635&&(t=32635),t>=256){let r=wp[t>>8&127],i=t>>r+3&15;e=r<<4|i}else e=t>>4;return e^(n^85)}function xp(t){let e=0;t^=85,t&128&&(t&=-129,e=-1);let n=((t&240)>>4)+4,r=0;return n!=4?r=1<>8&128,e!=0&&(t=-t),t=t+Tp,t>Au&&(t=Au),n=Ep[t>>7&255],r=t>>n+3&15,i=~(e|n<<4|r),i}function zp(t){let e,n,r,i;return t=~t,e=t&128,n=t>>4&7,r=t&15,i=Pp[n]+(r<=0&&u<=127)r+=String.fromCharCode(u);else{let a=0;u>=194&&u<=223?a=1:u>=224&&u<=239?(a=2,t[i]===224&&(l=160),t[i]===237&&(s=159)):u>=240&&u<=244?(a=3,t[i]===240&&(l=144),t[i]===244&&(s=143)):o=!0,u=u&(1<<8-a-1)-1;for(let p=0;ps)&&(o=!0),u=u<<6|t[i]&63,i++;o?r+="�":u<=65535?r+=String.fromCharCode(u):(u-=65536,r+=String.fromCharCode((u>>10&1023)+55296,(u&1023)+56320))}}return r}function dd(t,e,n=0){let r=0,i=t.length;for(;r>6*s)+o,n++;s>0;)e[n]=128|l>>6*(s-1)&63,n++,s--}r++}return n}class Rp{constructor(e,n=!1){this.bits=e,this.offset=Math.ceil(e/8),this.max=Math.pow(2,e)-1,this.min=0,this.unpack=this.unpack_,n&&(this.max=Math.pow(2,e)/2-1,this.min=-this.max-1,this.unpack=this.unpackSigned_)}pack(e,n,r=0){n=this.clamp_(Math.round(n));for(let i=0,l=this.offset;ithis.max?this.max:ethis.max&&(e-=this.max*2+2),e}}class Ru{constructor(e,n){this.offset=Math.ceil((e+n)/8),this.ebits=e,this.fbits=n,this.bias=(1<this.biasP2-this.ebitsFbits*2&&(n=n<0?-1/0:1/0);let i=((n=+n)||1/n)<0||n<0?1:0;n=Math.abs(n);let l=Math.min(Math.floor(Math.log(n)/Math.LN2),1023),s=Sl(n/Math.pow(2,l)*Math.pow(2,this.fbits));return n!==n?(s=Math.pow(2,this.fbits-1),l=(1<=Math.pow(2,1-this.bias)?(s/Math.pow(2,this.fbits)>=2&&(l=l+1,s=1),l>this.bias?(l=(1<=0;u--){let a=e[u+n].toString(2);l+="00000000".substring(a.length)+a}let s=l.charAt(0)=="1"?-1:1;l=l.substring(1);let o=parseInt(l.substring(0,this.ebits),2);return l=l.substring(this.ebits),o==r?parseInt(l,2)!==0?NaN:s*(1/0):(o===0?(o+=1,i=parseInt(l,2)):i=parseInt("1"+l,2),s*i*this.fbias*Math.pow(2,o-this.bias))}packFloatBits_(e,n,r,i,l){let s=[];s.push(r);for(let m=this.ebits;m>0;m-=1)s[m]=i%2?1:0,i=Math.floor(i/2);let o=s.length;for(let m=this.fbits;m>0;m-=1)s[o+m]=l%2?1:0,l=Math.floor(l/2);let u=s.join(""),a=this.offset+n-1,p=n;for(;a>=n;)e[a]=parseInt(u.substring(0,8),2),u=u.substring(8),a--,p++;return p}}function Sl(t){let e=Math.floor(t),n=t-e;return n<.5?e:n>.5||e%2?e+1:e}function _n(t,e=0,n=t.length){return Ap(t,e,n)}function ne(t){let e=[];return dd(t,e),e}function Ou(t,e,n=0){return dd(t,e,n)}function hd(t,e,n,r=0){e=e||{};let i=fd(e.bits,e.fp,e.signed),l=Math.ceil(e.bits/8),s=0,o=r;for(let u=t.length;s16&&(this.fmt.cbSize=this.readUInt16_(e),this.fmt.chunkSize>18&&(this.fmt.validBitsPerSample=this.readUInt16_(e),this.fmt.chunkSize>20&&(this.fmt.dwChannelMask=this.readUInt32(e),this.fmt.subformat=[this.readUInt32(e),this.readUInt32(e),this.readUInt32(e),this.readUInt32(e)])))}readFactChunk_(e){let n=this.findChunk("fact");n&&(this.head=n.chunkData.start,this.fact.chunkId=n.chunkId,this.fact.chunkSize=n.chunkSize,this.fact.dwSampleLength=this.readUInt32(e))}readCueChunk_(e){let n=this.findChunk("cue ");if(n){this.head=n.chunkData.start,this.cue.chunkId=n.chunkId,this.cue.chunkSize=n.chunkSize,this.cue.dwCuePoints=this.readUInt32(e);for(let r=0;r-1&&this.readLISTadtlSubChunks_(r,e):n=="INFO"&&this.readLISTINFOSubChunks_(r,e)}readLISTadtlSubChunks_(e,n){this.head=n.chunkData.start;let r={chunkId:n.chunkId,chunkSize:n.chunkSize,dwName:this.readUInt32(e)};n.chunkId=="ltxt"?(r.dwSampleLength=this.readUInt32(e),r.dwPurposeID=this.readUInt32(e),r.dwCountry=this.readUInt16_(e),r.dwLanguage=this.readUInt16_(e),r.dwDialect=this.readUInt16_(e),r.dwCodePage=this.readUInt16_(e),r.value=""):r.value=this.readZSTR_(e,this.head),this.LIST[this.LIST.length-1].subChunks.push(r)}readLISTINFOSubChunks_(e,n){this.head=n.chunkData.start,this.LIST[this.LIST.length-1].subChunks.push({chunkId:n.chunkId,chunkSize:n.chunkSize,value:this.readZSTR_(e,this.head)})}readJunkChunk_(e){let n=this.findChunk("junk");n&&(this.junk={chunkId:n.chunkId,chunkSize:n.chunkSize,chunkData:[].slice.call(e.slice(n.chunkData.start,n.chunkData.end))})}read_PMXChunk_(e){let n=this.findChunk("_PMX");n&&(this.head=n.chunkData.start,this._PMX.chunkId=n.chunkId,this._PMX.chunkSize=n.chunkSize,this._PMX.value=_n(e,this.head,this.head+this._PMX.chunkSize))}readZSTR_(e,n=0){for(let r=n;r16&&(e=e.concat(P(this.fmt.cbSize,this.uInt16))),this.fmt.chunkSize>18&&(e=e.concat(P(this.fmt.validBitsPerSample,this.uInt16))),this.fmt.chunkSize>20&&(e=e.concat(P(this.fmt.dwChannelMask,this.uInt32))),this.fmt.chunkSize>24&&(e=e.concat(P(this.fmt.subformat[0],this.uInt32),P(this.fmt.subformat[1],this.uInt32),P(this.fmt.subformat[2],this.uInt32),P(this.fmt.subformat[3],this.uInt32))),e}getLISTBytes_(){let e=[];for(let n=0;n-1){let r=We(e.value,e.value.length);n=n.concat(ne(e.chunkId),P(r.length+4+1,this.uInt32),P(e.dwName,this.uInt32),r),n.push(0)}else e.chunkId=="ltxt"&&(n=n.concat(this.getLtxtChunkBytes_(e)));return n}getLtxtChunkBytes_(e){return[].concat(ne(e.chunkId),P(e.value.length+20,this.uInt32),P(e.dwName,this.uInt32),P(e.dwSampleLength,this.uInt32),P(e.dwPurposeID,this.uInt32),P(e.dwCountry,this.uInt16),P(e.dwLanguage,this.uInt16),P(e.dwDialect,this.uInt16),P(e.dwCodePage,this.uInt16),We(e.value,e.value.length))}get_PMXBytes_(){let e=[];if(this._PMX.chunkId){let n=ne(this._PMX.value);this._PMX.chunkSize=n.length,e=e.concat(ne(this._PMX.chunkId),P(this._PMX.chunkSize,this.uInt32),n)}return this.enforceByteLen_(e),e}getJunkBytes_(){let e=[];return this.junk.chunkId?e.concat(ne(this.junk.chunkId),P(this.junk.chunkData.length,this.uInt32),this.junk.chunkData):(this.enforceByteLen_(e),e)}enforceByteLen_(e){e.length%2&&e.push(0)}}function Up(t){let e=[];if(t.length>0)if(t[0].constructor!==Number){e=new Float64Array(t[0].length*t.length);for(let n=0,r=t[0].length,i=0;n65535)}function pd(t,e,n){let r=t*(e/8)*n;return!(n<1||r>4294967295)}class Hp extends Bp{constructor(){super(),this.bitDepth="0",this.dataType={bits:0,be:!1},this.WAV_AUDIO_FORMATS={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3}}fromScratch(e,n,r,i,l){l=l||{},this.clearHeaders(),this.newWavFile_(e,n,r,i,l)}fromBuffer(e,n=!0){super.fromBuffer(e,n),this.bitDepthFromFmt_(),this.updateDataType_()}toBuffer(){return this.validateWavHeader_(),super.toBuffer()}getSamples(e=!1,n=Float64Array){let r=new n(this.data.samples.length/(this.dataType.bits/8));return Ht(this.data.samples,this.dataType,r,0,this.data.samples.length),!e&&this.fmt.numChannels>1?Wp(r,this.fmt.numChannels,n):r}getSample(e){if(e=e*(this.dataType.bits/8),e+this.dataType.bits/8>this.data.samples.length)throw new Error("Range error");return Pi(this.data.samples.slice(e,e+this.dataType.bits/8),this.dataType)}setSample(e,n){if(e=e*(this.dataType.bits/8),e+this.dataType.bits/8>this.data.samples.length)throw new Error("Range error");go(n,this.dataType,this.data.samples,e)}getiXML(){return this.iXML.value}setiXML(e){if(typeof e!="string")throw new TypeError("iXML value must be a string.");this.iXML.value=e,this.iXML.chunkId="iXML"}get_PMX(){return this._PMX.value}set_PMX(e){if(typeof e!="string")throw new TypeError("_PMX value must be a string.");this._PMX.value=e,this._PMX.chunkId="_PMX"}newWavFile_(e,n,r,i,l){l.container||(l.container="RIFF"),this.container=l.container,this.bitDepth=r,i=Up(i),this.updateDataType_();let s=this.dataType.bits/8;this.data.samples=new Uint8Array(i.length*s),hd(i,this.dataType,this.data.samples,0),this.makeWavHeader_(r,e,n,s,this.data.samples.length,l),this.data.chunkId="data",this.data.chunkSize=this.data.samples.length,this.validateWavHeader_()}makeWavHeader_(e,n,r,i,l,s){e=="4"?this.createADPCMHeader_(e,n,r,i,l,s):e=="8a"||e=="8m"?this.createALawMulawHeader_(e,n,r,i,l,s):Object.keys(this.WAV_AUDIO_FORMATS).indexOf(e)==-1||n>2?this.createExtensibleHeader_(e,n,r,i,l,s):this.createPCMHeader_(e,n,r,i,l,s)}createPCMHeader_(e,n,r,i,l,s){this.container=s.container,this.chunkSize=36+l,this.format="WAVE",this.bitDepth=e,this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.WAV_AUDIO_FORMATS[e]||65534,numChannels:n,sampleRate:r,byteRate:n*i*r,blockAlign:n*i,bitsPerSample:parseInt(e,10),cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]}}createADPCMHeader_(e,n,r,i,l,s){this.createPCMHeader_(e,n,r,i,l,s),this.chunkSize=40+l,this.fmt.chunkSize=20,this.fmt.byteRate=4055,this.fmt.blockAlign=256,this.fmt.bitsPerSample=4,this.fmt.cbSize=2,this.fmt.validBitsPerSample=505,this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:l*2}}createExtensibleHeader_(e,n,r,i,l,s){this.createPCMHeader_(e,n,r,i,l,s),this.chunkSize=60+l,this.fmt.chunkSize=40,this.fmt.bitsPerSample=(parseInt(e,10)-1|7)+1,this.fmt.cbSize=22,this.fmt.validBitsPerSample=parseInt(e,10),this.fmt.dwChannelMask=$p(n),this.fmt.subformat=[1,1048576,2852126848,1905997824]}createALawMulawHeader_(e,n,r,i,l,s){this.createPCMHeader_(e,n,r,i,l,s),this.chunkSize=40+l,this.fmt.chunkSize=20,this.fmt.cbSize=2,this.fmt.validBitsPerSample=8,this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:l}}bitDepthFromFmt_(){this.fmt.audioFormat===3&&this.fmt.bitsPerSample===32?this.bitDepth="32f":this.fmt.audioFormat===6?this.bitDepth="8a":this.fmt.audioFormat===7?this.bitDepth="8m":this.bitDepth=this.fmt.bitsPerSample.toString()}validateBitDepth_(){if(!this.WAV_AUDIO_FORMATS[this.bitDepth]){if(parseInt(this.bitDepth,10)>8&&parseInt(this.bitDepth,10)<54)return!0;throw new Error("Invalid bit depth.")}return!0}updateDataType_(){this.dataType={bits:(parseInt(this.bitDepth,10)-1|7)+1,fp:this.bitDepth=="32f"||this.bitDepth=="64",signed:this.bitDepth!="8",be:this.container=="RIFX"},["4","8a","8m"].indexOf(this.bitDepth)>-1&&(this.dataType.bits=8,this.dataType.signed=!1)}validateWavHeader_(){if(this.validateBitDepth_(),!Vp(this.fmt.numChannels,this.fmt.bitsPerSample))throw new Error("Invalid number of channels.");if(!pd(this.fmt.numChannels,this.fmt.bitsPerSample,this.fmt.sampleRate))throw new Error("Invalid sample rate.")}}function $p(t){let e=0;return t===1?e=4:t===2?e=3:t===4?e=51:t===6?e=63:t===8&&(e=1599),e}class Xp extends Hp{getTag(e){let n=this.getTagIndex_(e);return n.TAG!==null?this.LIST[n.LIST].subChunks[n.TAG].value:null}setTag(e,n){e=Zp(e);let r=this.getTagIndex_(e);r.TAG!==null?(this.LIST[r.LIST].subChunks[r.TAG].chunkSize=n.length+1,this.LIST[r.LIST].subChunks[r.TAG].value=n):r.LIST!==null?this.LIST[r.LIST].subChunks.push({chunkId:e,chunkSize:n.length+1,value:n}):(this.LIST.push({chunkId:"LIST",chunkSize:8+n.length+1,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:e,chunkSize:n.length+1,value:n}))}deleteTag(e){let n=this.getTagIndex_(e);return n.TAG!==null?(this.LIST[n.LIST].subChunks.splice(n.TAG,1),!0):!1}listTags(){let e=this.getLISTIndex("INFO"),n={};if(e!==null)for(let r=0,i=this.LIST[e].subChunks.length;rn.dwSampleOffset&&!r?(this.setCuePoint_(n,i+1),this.setCuePoint_(e[i],i+2),r=!0):this.setCuePoint_(e[i],r?i+2:i+1);r||this.setCuePoint_(n,this.cue.points.length+1)}clearLISTadtl_(){for(let e=0,n=this.LIST.length;ee){let u=new o(r.LPForder||Bu[r.LPFType],n,e/2);tg(t,l,s,u)}else{let u=new o(r.LPForder||Bu[r.LPFType],e,n/2);ng(t,l,s,u)}}else gd(t,l,s);return l}function gd(t,e,n){for(let r=0,i=e.length;r=0;i--)e[i]=r.filter(e[i])}function ng(t,e,n,r){for(let i=0,l=t.length;i=0;i--)t[i]=r.filter(t[i]);gd(t,e,n)}class rg extends ju{toRIFF(){let e=new Float64Array(Zn(this.data.samples.length,this.dataType.bits/8));Ht(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,e,{container:"RIFF"})}toRIFX(){let e=new Float64Array(Zn(this.data.samples.length,this.dataType.bits/8));Ht(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,e,{container:"RIFX"})}toIMAADPCM(){if(this.fmt.sampleRate!==8e3)throw new Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");if(this.fmt.numChannels!==1)throw new Error("Only mono files can be compressed as IMA-ADPCM.");{this.assure16Bit_();let e=new Int16Array(Zn(this.data.samples.length,2));Ht(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"4",fp(e),{container:this.correctContainer_()})}}fromIMAADPCM(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",pp(this.data.samples,this.fmt.blockAlign),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toALaw(){this.assure16Bit_();let e=new Int16Array(Zn(this.data.samples.length,2));Ht(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8a",Cp(e),{container:this.correctContainer_()})}fromALaw(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",_p(this.data.samples),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toMuLaw(){this.assure16Bit_();let e=new Int16Array(Zn(this.data.samples.length,2));Ht(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8m",Mp(e),{container:this.correctContainer_()})}fromMuLaw(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",Fp(this.data.samples),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toBitDepth(e,n=!0){let r=e,i=this.bitDepth;n||(e!="32f"&&(r=this.dataType.bits.toString()),i=""+this.dataType.bits),this.assureUncompressed_();let l=this.getSamples(!0),s=new Float64Array(l.length);up(l,i,s,r),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,e,s,{container:this.correctContainer_()})}toSampleRate(e,n){this.validateResample_(e);let r=this.getSamples(),i=[];if(r.constructor===Float64Array)i=Uu(r,this.fmt.sampleRate,e,n);else for(let l=0;l-1)throw new Error("wavefile can't change the sample rate of compressed files.")}else throw new Error("Invalid sample rate.")}assure16Bit_(){this.assureUncompressed_(),this.bitDepth!="16"&&this.toBitDepth("16")}assureUncompressed_(){this.bitDepth=="8a"?this.fromALaw():this.bitDepth=="8m"?this.fromMuLaw():this.bitDepth=="4"&&this.fromIMAADPCM()}correctContainer_(){return this.container=="RF64"?"RIFF":this.container}fromExisting_(e,n,r,i,l){let s=new ju;Object.assign(this.fmt,s.fmt),Object.assign(this.fact,s.fact),Object.assign(this.ds64,s.ds64),Object.assign(this.data,s.data),this.newWavFile_(e,n,r,i,l)}}function Zn(t,e){let n=t/e;return n%2&&n++,n}class Wu extends rg{constructor(e){super(),e&&this.fromBuffer(e)}fromBase64(e){this.fromBuffer(op(e))}toBase64(){return sp(this.toBuffer())}toDataURI(){return"data:audio/wav;base64,"+this.toBase64()}fromDataURI(e){this.fromBase64(e.replace("data:audio/wav;base64,",""))}}function vs(){return vs=Object.assign?Object.assign.bind():function(t){for(var e=1;e=e?t.call(null):i.id=requestAnimationFrame(r)}var i={id:requestAnimationFrame(r)};return i}var wl=-1;function Zu(t){if(t===void 0&&(t=!1),wl===-1||t){var e=document.createElement("div"),n=e.style;n.width="50px",n.height="50px",n.overflow="scroll",document.body.appendChild(e),wl=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return wl}var rn=null;function Qu(t){if(t===void 0&&(t=!1),rn===null||t){var e=document.createElement("div"),n=e.style;n.width="50px",n.height="50px",n.overflow="scroll",n.direction="rtl";var r=document.createElement("div"),i=r.style;return i.width="100px",i.height="100px",e.appendChild(r),document.body.appendChild(e),e.scrollLeft>0?rn="positive-descending":(e.scrollLeft=1,e.scrollLeft===0?rn="negative":rn="positive-ascending"),document.body.removeChild(e),rn}return rn}var ag=150,cg=function(e,n){return e};function dg(t){var e,n=t.getItemOffset,r=t.getEstimatedTotalSize,i=t.getItemSize,l=t.getOffsetForIndexAndAlignment,s=t.getStartIndexForOffset,o=t.getStopIndexForStartIndex,u=t.initInstanceProps,a=t.shouldResetStyleCacheOnItemSizeChange,p=t.validateProps;return e=function(m){ig(g,m);function g(y){var f;return f=m.call(this,y)||this,f._instanceProps=u(f.props,Vu(f)),f._outerRef=void 0,f._resetIsScrollingTimeoutId=null,f.state={instance:Vu(f),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof f.props.initialScrollOffset=="number"?f.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},f._callOnItemsRendered=void 0,f._callOnItemsRendered=kl(function(S,d,c,h){return f.props.onItemsRendered({overscanStartIndex:S,overscanStopIndex:d,visibleStartIndex:c,visibleStopIndex:h})}),f._callOnScroll=void 0,f._callOnScroll=kl(function(S,d,c){return f.props.onScroll({scrollDirection:S,scrollOffset:d,scrollUpdateWasRequested:c})}),f._getItemStyle=void 0,f._getItemStyle=function(S){var d=f.props,c=d.direction,h=d.itemSize,v=d.layout,w=f._getItemStyleCache(a&&h,a&&v,a&&c),C;if(w.hasOwnProperty(S))C=w[S];else{var _=n(f.props,S,f._instanceProps),L=i(f.props,S,f._instanceProps),O=c==="horizontal"||v==="horizontal",N=c==="rtl",le=O?_:0;w[S]=C={position:"absolute",left:N?void 0:le,right:N?le:void 0,top:O?0:_,height:O?"100%":L,width:O?L:"100%"}}return C},f._getItemStyleCache=void 0,f._getItemStyleCache=kl(function(S,d,c){return{}}),f._onScrollHorizontal=function(S){var d=S.currentTarget,c=d.clientWidth,h=d.scrollLeft,v=d.scrollWidth;f.setState(function(w){if(w.scrollOffset===h)return null;var C=f.props.direction,_=h;if(C==="rtl")switch(Qu()){case"negative":_=-h;break;case"positive-descending":_=v-c-h;break}return _=Math.max(0,Math.min(_,v-c)),{isScrolling:!0,scrollDirection:w.scrollOffset<_?"forward":"backward",scrollOffset:_,scrollUpdateWasRequested:!1}},f._resetIsScrollingDebounced)},f._onScrollVertical=function(S){var d=S.currentTarget,c=d.clientHeight,h=d.scrollHeight,v=d.scrollTop;f.setState(function(w){if(w.scrollOffset===v)return null;var C=Math.max(0,Math.min(v,h-c));return{isScrolling:!0,scrollDirection:w.scrollOffsetC.clientWidth?Zu():0:w=C.scrollHeight>C.clientHeight?Zu():0}this.scrollTo(l(this.props,f,S,v,this._instanceProps,w))},k.componentDidMount=function(){var f=this.props,S=f.direction,d=f.initialScrollOffset,c=f.layout;if(typeof d=="number"&&this._outerRef!=null){var h=this._outerRef;S==="horizontal"||c==="horizontal"?h.scrollLeft=d:h.scrollTop=d}this._callPropsCallbacks()},k.componentDidUpdate=function(){var f=this.props,S=f.direction,d=f.layout,c=this.state,h=c.scrollOffset,v=c.scrollUpdateWasRequested;if(v&&this._outerRef!=null){var w=this._outerRef;if(S==="horizontal"||d==="horizontal")if(S==="rtl")switch(Qu()){case"negative":w.scrollLeft=-h;break;case"positive-ascending":w.scrollLeft=h;break;default:var C=w.clientWidth,_=w.scrollWidth;w.scrollLeft=_-C-h;break}else w.scrollLeft=h;else w.scrollTop=h}this._callPropsCallbacks()},k.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&Xu(this._resetIsScrollingTimeoutId)},k.render=function(){var f=this.props,S=f.children,d=f.className,c=f.direction,h=f.height,v=f.innerRef,w=f.innerElementType,C=f.innerTagName,_=f.itemCount,L=f.itemData,O=f.itemKey,N=O===void 0?cg:O,le=f.layout,Be=f.outerElementType,pt=f.outerTagName,gt=f.style,Pr=f.useIsScrolling,tt=f.width,Bt=this.state.isScrolling,T=c==="horizontal"||le==="horizontal",A=T?this._onScrollHorizontal:this._onScrollVertical,F=this._getRangeToRender(),W=F[0],G=F[1],nt=[];if(_>0)for(var te=W;te<=G;te++)nt.push(E.createElement(S,{data:L,key:N(te,L),index:te,isScrolling:Pr?Bt:void 0,style:this._getItemStyle(te)}));var mt=r(this.props,this._instanceProps);return E.createElement(Be||pt||"div",{className:d,onScroll:A,ref:this._outerRefSetter,style:vs({position:"relative",height:h,width:tt,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:c},gt)},E.createElement(w||C||"div",{children:nt,ref:v,style:{height:T?"100%":mt,pointerEvents:Bt?"none":void 0,width:T?mt:"100%"}}))},k._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var f=this.props.itemCount;if(f>0){var S=this._getRangeToRender(),d=S[0],c=S[1],h=S[2],v=S[3];this._callOnItemsRendered(d,c,h,v)}}if(typeof this.props.onScroll=="function"){var w=this.state,C=w.scrollDirection,_=w.scrollOffset,L=w.scrollUpdateWasRequested;this._callOnScroll(C,_,L)}},k._getRangeToRender=function(){var f=this.props,S=f.itemCount,d=f.overscanCount,c=this.state,h=c.isScrolling,v=c.scrollDirection,w=c.scrollOffset;if(S===0)return[0,0,0,0];var C=s(this.props,w,this._instanceProps),_=o(this.props,C,w,this._instanceProps),L=!h||v==="backward"?Math.max(1,d):1,O=!h||v==="forward"?Math.max(1,d):1;return[Math.max(0,C-L),Math.max(0,Math.min(S-1,_+O)),C,_]},g}(E.PureComponent),e.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},e}var hg=function(e,n){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,n.instance},fg=dg({getItemOffset:function(e,n){var r=e.itemSize;return n*r},getItemSize:function(e,n){var r=e.itemSize;return r},getEstimatedTotalSize:function(e){var n=e.itemCount,r=e.itemSize;return r*n},getOffsetForIndexAndAlignment:function(e,n,r,i,l,s){var o=e.direction,u=e.height,a=e.itemCount,p=e.itemSize,m=e.layout,g=e.width,k=o==="horizontal"||m==="horizontal",y=k?g:u,f=Math.max(0,a*p-y),S=Math.min(f,n*p),d=Math.max(0,n*p-y+p+s);switch(r==="smart"&&(i>=d-y&&i<=S+y?r="auto":r="center"),r){case"start":return S;case"end":return d;case"center":{var c=Math.round(d+(S-d)/2);return cf+Math.floor(y/2)?f:c}case"auto":default:return i>=d&&i<=S?i:i{const l=`${(t.endTime-t.startTime)*100}%`,s=`${t.startTime*100}%`,o=t.isMerged?"bg-purple-500 opacity-60":t.isProcessed?"bg-blue-500 opacity-40":"bg-gray-500 opacity-40";return I.jsxs("div",{className:`absolute h-full ${o} rounded-md transition-all duration-200`,style:{left:s,width:l,zIndex:t.isMerged?2:1},title:`${t.isMerged?"Merged: ":""}${t.startTime.toFixed(2)}s - ${t.endTime.toFixed(2)}s`,children:[t.isMerged&&I.jsxs("div",{className:"absolute -top-5 left-0 text-xs text-purple-600 font-bold",children:["Merged (",t.mergedCount,")"]}),t.transcription&&I.jsx("div",{className:"absolute -bottom-6 left-0 text-xs text-gray-600 dark:text-gray-300 whitespace-nowrap overflow-hidden max-w-full",children:typeof t.transcription=="string"?t.transcription:t.transcription.text||t.transcription.toString()})]})});const pg=E.memo(({index:t,style:e,data:n})=>{const{segments:r,onPlay:i,onDownload:l,onTranscribe:s}=n,o=r[t];return I.jsxs("div",{style:e,className:`flex flex-col p-2 rounded ${o.isMerged?"bg-purple-100 dark:bg-purple-900":"bg-white dark:bg-gray-700"}`,children:[I.jsxs("div",{className:"flex items-center space-x-4",children:[I.jsxs("span",{className:"text-sm",children:[o.isMerged?"🔄 ":"",`Segment ${t+1}: ${o.startTime.toFixed(2)}s - ${o.endTime.toFixed(2)}s (${(o.endTime-o.startTime).toFixed(2)}s)`]}),I.jsx("button",{onClick:()=>i(o),className:"px-2 py-1 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Play"}),I.jsx("button",{onClick:()=>l(o,t+1),className:"px-2 py-1 bg-green-500 text-white rounded hover:bg-green-600",children:"Download"}),I.jsx("button",{onClick:()=>s(o),className:"px-2 py-1 bg-purple-500 text-white rounded hover:bg-purple-600",disabled:o.isProcessed,children:o.isProcessed?"Transcribed":"Transcribe"})]}),o.transcription&&I.jsx("div",{className:"mt-2 ml-4 text-sm",children:typeof o.transcription=="string"?o.transcription:o.transcription.text||o.transcription.toString()})]})}),md=E.memo(({segments:t,worker:e,language:n})=>{E.useRef([]);const r=E.useCallback(async o=>{if(!o.audioData||o.audioData.length===0){console.error("Invalid segment audio data");return}try{const u=new Wu;u.fromScratch(1,o.sampleRate,"32f",o.audioData),u.toBitDepth("16");const a=u.toBuffer(),p=new AudioContext,m=await p.decodeAudioData(a.buffer),g=p.createBufferSource();g.buffer=m,g.connect(p.destination),g.start()}catch(u){console.error("Error playing segment:",u)}},[]),i=E.useCallback((o,u)=>{try{const a=new Wu;a.fromScratch(1,o.sampleRate,"32f",o.audioData),a.toBitDepth("16");const p=a.toBuffer(),m=new Blob([p],{type:"audio/wav"}),g=URL.createObjectURL(m),k=document.createElement("a");k.href=g,k.download=`segment_${u}_${o.startTime.toFixed(2)}-${o.endTime.toFixed(2)}.wav`,document.body.appendChild(k),k.click(),document.body.removeChild(k),URL.revokeObjectURL(g)}catch(a){console.error("Error downloading segment:",a)}},[]),l=E.useCallback(o=>{e&&e.postMessage({type:"transcribe",data:{audioData:o.audioData,segmentId:o.id,language:n,isMerged:o.isMerged}})},[e,n]),s=E.useMemo(()=>({segments:t,onPlay:r,onDownload:i,onTranscribe:l}),[t,r,i,l]);return I.jsxs("div",{className:"mt-4 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg",children:[I.jsxs("h3",{className:"font-semibold mb-2",children:["Detected Speech Segments (",t.length,")"]}),I.jsx(fg,{height:400,itemCount:t.length,itemSize:80,width:"100%",itemData:s,children:pg})]})});md.displayName="AudioSegmentsWidget";function gg(t){return t=t.toLowerCase(),(t.match(/\w+.?/g)||[]).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}const Gu={en:"english",tr:"turkish",zh:"chinese",de:"german",es:"spanish/castilian",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",pl:"polish",ca:"catalan/valencian",nl:"dutch/flemish",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian/moldavian/moldovan",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi/panjabi",si:"sinhala/sinhalese",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole/haitian",ps:"pashto/pushto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish/letzeburgesch",my:"myanmar/burmese",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese"};function mg({language:t,setLanguage:e,disabled:n}){return I.jsx("select",{className:`border rounded-lg p-2 ${n?"opacity-50 cursor-not-allowed":""}`,value:t,onChange:r=>e(r.target.value),disabled:n,title:n?"Language locked to English for this model":"Select language",children:Object.keys(Gu).map((r,i)=>I.jsx("option",{value:r,children:Object.values(Gu).map(gg)[i]},r))})}const vd={"Whisper Small":"onnx-community/whisper-small","Whisper Base":"onnx-community/whisper-base","Whisper Tiny":"onnx-community/whisper-tiny","Whisper Small En":"onnx-community/whisper-small.en","Whisper Base En":"onnx-community/whisper-base.en","Whisper Tiny En":"onnx-community/whisper-tiny.en","Whisper Base Tr":"ysdede/whisper-base-dsntt1-tr-onnx","Whisper Small Tr":"ysdede/whisper-small-dsntt1-tr-onnx"};function vg({model:t,setModel:e}){return I.jsx("select",{className:"border rounded-lg p-2 mr-2",value:t,onChange:n=>e(n.target.value),children:Object.entries(vd).map(([n,r])=>I.jsx("option",{value:r,children:n},r))})}const yg="data:text/javascript;base64,Y2xhc3MgQXVkaW9Qcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgc3VwZXIoKTsKICAgICAgICB0aGlzLmJ1ZmZlclNpemUgPSAxNjAwOwogICAgICAgIHRoaXMuYnVmZmVyID0gbmV3IEZsb2F0MzJBcnJheSh0aGlzLmJ1ZmZlclNpemUpOwogICAgICAgIHRoaXMuYnVmZmVySW5kZXggPSAwOwogICAgICAgIAogICAgICAgIHRoaXMubWF4VmFsdWVzID0gW107CiAgICAgICAgdGhpcy5zbWFMZW5ndGggPSA2OwogICAgICAgIHRoaXMuc2lsZW5jZUNvdW50ZXIgPSAwOwogICAgICAgIHRoaXMuc2lsZW5jZVRocmVzaG9sZCA9IDg7CiAgICB9CgogICAgY2FsY3VsYXRlTWF4RW5lcmd5KGJ1ZmZlcikgewogICAgICAgIGNvbnN0IG1heEFic1ZhbHVlID0gTWF0aC5tYXgoLi4uQXJyYXkuZnJvbShidWZmZXIpLm1hcChNYXRoLmFicykpOwogICAgICAgIHRoaXMubWF4VmFsdWVzLnB1c2gobWF4QWJzVmFsdWUpOwogICAgICAgIAogICAgICAgIGlmICh0aGlzLm1heFZhbHVlcy5sZW5ndGggPiB0aGlzLnNtYUxlbmd0aCkgewogICAgICAgICAgICB0aGlzLm1heFZhbHVlcy5zaGlmdCgpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBjb25zdCBzdW0gPSB0aGlzLm1heFZhbHVlcy5yZWR1Y2UoKGFjYywgdmFsKSA9PiBhY2MgKyB2YWwsIDApOwogICAgICAgIHJldHVybiAoc3VtIC8gdGhpcy5tYXhWYWx1ZXMubGVuZ3RoKTsKICAgIH0KCiAgICBwcm9jZXNzKGlucHV0cywgb3V0cHV0cykgewogICAgICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgICAgIGNvbnN0IGNoYW5uZWwgPSBpbnB1dFswXTsKCiAgICAgICAgaWYgKCFjaGFubmVsKSByZXR1cm4gdHJ1ZTsKCiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjaGFubmVsLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIHRoaXMuYnVmZmVyW3RoaXMuYnVmZmVySW5kZXgrK10gPSBjaGFubmVsW2ldOwoKICAgICAgICAgICAgaWYgKHRoaXMuYnVmZmVySW5kZXggPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgICAgICAgICAgICBjb25zdCBlbmVyZ3kgPSB0aGlzLmNhbGN1bGF0ZU1heEVuZXJneSh0aGlzLmJ1ZmZlcik7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2F1ZGlvX2RhdGEnLAogICAgICAgICAgICAgICAgICAgIGF1ZGlvRGF0YTogdGhpcy5idWZmZXIuc2xpY2UoKSwKICAgICAgICAgICAgICAgICAgICBlbmVyZ3k6IGVuZXJneQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVySW5kZXggPSAwOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2F1ZGlvLXByb2Nlc3NvcicsIEF1ZGlvUHJvY2Vzc29yKTsg",St=16e3,Sg=100,kg=2*Sg,wg=async t=>{try{const e=t.getAudioTracks()[0];if(!e){console.warn("No audio track found");return}const n=e.getConstraints();console.log("Current constraints:",n);const r={autoGainControl:!1,echoCancellation:!1,noiseSuppression:!1,channelCount:1,sampleRate:St};await e.applyConstraints({advanced:[r]});const i=e.getConstraints();console.log("Automatically unsetting gain!",{audio:!0,initial:n,applied:r,final:i});const l=e.getSettings();console.log("Track settings after constraints:",l)}catch(e){console.warn("Failed to disable auto gain:",e)}};function Ig(){const t=E.useRef(null),e=E.useRef(null),n=E.useRef(null),r=E.useRef(null),i=E.useRef(null);E.useRef(null),E.useRef(null);const l=E.useRef(null);E.useRef(0),E.useRef(0),E.useRef(null);const[s,o]=E.useState("initialized"),[u,a]=E.useState(""),[p,m]=E.useState([]),[g,k]=E.useState(!1),[y,f]=E.useState(!1),[S,d]=E.useState(.125),[c,h]=E.useState(.6),[v,w]=E.useState(.2),[C,_]=E.useState(2),[L,O]=E.useState(1.2),[N,le]=E.useState(.3),[Be,pt]=E.useState(.3),[gt,Pr]=E.useState(.4),[tt,Bt]=E.useState(.6),[T,A]=E.useState(null),[F,W]=E.useState([]);E.useState("");const[G,nt]=E.useState(null),[te,mt]=E.useState("en"),[Ge,vt]=E.useState(""),[vo,yd]=E.useState([]),[Xi,Sd]=E.useState(25),[Zi,kd]=E.useState(Object.values(vd)[0]);E.useEffect(()=>(console.log("Initializing AudioManager"),U.initialize({sampleRate:St,onSegmentDetected:M=>{W(Z=>[...Z,M])}}).catch(M=>{console.error("Failed to initialize AudioManager:",M)}),U.updateParameters({threshold:S,silenceLength:c,speechHangover:v,energyScale:C,hysteresisRatio:L,minSpeechDuration:N}),()=>{U.reset()}),[]);const wd=async()=>{try{await U.startAudioContext();const M=await navigator.mediaDevices.getUserMedia({audio:{autoGainControl:!1,echoCancellation:!1,noiseSuppression:!1,channelCount:1,sampleRate:St}});await wg(M),A(M),await U.audioContext.audioWorklet.addModule(yg);const Z=U.audioContext.createMediaStreamSource(M),V=U.audioContext.createGain();V.gain.value=1;const j=new AudioWorkletNode(U.audioContext,"audio-processor",{numberOfInputs:1,numberOfOutputs:1,processorOptions:{sampleRate:St}});Z.connect(V),V.connect(j),j.port.onmessage=_e=>{if(_e.data.type==="audio_data"){const Se=_e.data.audioData,On=_e.data.energy;U.processNewChunk(Se,On)}},j.connect(U.audioContext.destination),f(!0),n.current=U.audioContext}catch(M){console.error("Failed to start audio:",M),M.name==="NotAllowedError"?console.error("Microphone permission denied"):M.name==="NotFoundError"?console.error("No microphone found"):console.error("Error details:",{name:M.name,message:M.message,stack:M.stack})}},Id=E.useCallback(()=>{Fe("Reset requested"),e.current&&(e.current.state==="recording"&&e.current.stop(),U.reset(),setTimeout(()=>{if(s==="ready"&&e.current)try{e.current.start(),Fe("Started new recording after reset")}catch(M){Fe("Failed to start after reset: "+M.message,"error")}},100))},[s]);E.useEffect(()=>()=>{n.current&&n.current.close(),T&&T.getTracks().forEach(M=>M.stop()),U.reset()},[T]);const Fe=E.useCallback((M,Z="info")=>{Z==="error"?console.error(M):console.log(M)},[]);E.useEffect(()=>{i.current=Fe},[Fe]),E.useEffect(()=>{if(!r.current){console.log("Creating AudioSegmentProcessor...");const M=(Z,V)=>{var j;console.log("AudioProcessor:",Z,V),(j=i.current)==null||j.call(i,Z,"info")};r.current=new ud({logger:M,sampleRate:St,energyThreshold:S,minSpeechDuration:.1,windowSize:256,minSilenceBetween:c,speechHangover:v}),r.current.log("Test message from initialization",{test:"value"}),Fe("AudioSegmentProcessor initialized",{threshold:S,silenceLength:c,hangover:v})}},[]),E.useEffect(()=>{r.current&&(r.current.options.energyThreshold=S,r.current.options.minSilenceBetween=c,r.current.options.speechHangover=v,Fe("Updated processor settings",{threshold:S,silenceLength:c,hangover:v}))},[S,c,v]),E.useEffect(()=>{if(s==="ready"&&y){Fe("Starting periodic buffer processing");let M=!0,Z=0;const V=setInterval(()=>{if(!(!r.current||!l.current||!M))try{const j=l.current;if(j.length===Z)return;const _e=15*St;let Se=0;if(F.length>0){const Dn=F[F.length-1];Se=Math.floor(Dn.endTime*St)}const On=j.slice(Math.max(j.length-_e,Se),j.length);if(On.length>0){const Ut=r.current.processAudioData(On,Se/St).map(Ke=>new od(Ke));Ut.length>0&&(Fe("Created speech segments",{count:Ut.length,segments:Ut.map(Ke=>({start:Ke.startTime.toFixed(2),end:Ke.endTime.toFixed(2),duration:Ke.getDuration().toFixed(2)}))}),W(Ke=>[...Ke,...Ut]))}Z=j.length}catch(j){Fe("Error processing buffer: "+j.message,"error"),console.error("Processing error:",j)}},500);return()=>{M=!1,clearInterval(V)}}},[s,y,F]),E.useEffect(()=>{r.current&&(r.current.options.maxSilenceWithinSpeech=Be,Fe("Updated max silence within speech",{value:Be}))},[Be]),E.useEffect(()=>{r.current&&(r.current.options.endingSpeechTolerance=gt,r.current.options.endingEnergyThreshold=tt,Fe("Updated ending speech parameters",{tolerance:gt,threshold:tt}))},[gt,tt]),E.useEffect(()=>{r.current&&(r.current.options={...r.current.options,energyThreshold:S,minSilenceBetween:c,speechHangover:v,energyScale:C,hysteresisRatio:L,minSpeechDuration:N})},[S,c,v,C,L,N]),E.useEffect(()=>{const M=U.subscribe((Z,V)=>{switch(Z){case"segmentsUpdated":W(V.map(j=>({...j,startTime:j.startTime,endTime:j.endTime,isMerged:j.isMerged||!1,isPartOfMerged:j.isPartOfMerged||!1,isProcessed:j.isProcessed||!1,mergedId:j.mergedId,energy:j.energy})));break}});return()=>M()},[]),E.useEffect(()=>()=>{n.current&&n.current.close(),T&&T.getTracks().forEach(M=>M.stop())},[T]),E.useEffect(()=>{const M=vo.filter(Z=>Z.isMerged||!Z.isPartOfMerged).map(Z=>Z.text);vt(M.join(` `))},[vo]),E.useEffect(()=>{U.updateParameters({minEnergyIntegral:Xi})},[Xi]),E.useEffect(()=>{if(!t.current||!y||g||s!=="ready")return;const M=setInterval(()=>{U.segments.filter(V=>!V.isProcessed&&!V.isPartOfMerged).forEach(V=>{if(!V.audioData){console.warn("Segment has no audio data:",V);return}V.isProcessed=!0,t.current.postMessage({type:"transcribe",data:{audioData:V.audioData,language:te,segmentId:V.id,isMerged:V.isMerged}})})},500);return()=>clearInterval(M)},[s,y,g,te]);const yo=M=>{console.log("Changing language from",te,"to:",M),mt(M),U.updateLanguage(M)},xd=M=>{kd(M),M.endsWith(".en")&&yo("en")};return E.useEffect(()=>{let M=null;return y&&(M=setInterval(async()=>{},kg)),()=>{M&&clearInterval(M)}},[y]),E.useEffect(()=>{if(!t.current)return t.current=new Worker(new URL("/assets/worker-D60LmNTA.js",import.meta.url),{type:"module"}),U.setWorker(t.current),t.current.addEventListener("message",M=>{switch(M.data.status){case"loading":o("loading"),a(M.data.data);break;case"initiate":m(_e=>[..._e,M.data]);break;case"progress":m(_e=>_e.map(Se=>Se.file===M.data.file?{...Se,...M.data}:Se));break;case"done":m(_e=>_e.filter(Se=>Se.file!==M.data.file));break;case"ready":o("ready");break;case"start":k(!0);break;case"update":nt(M.data.tps);break;case"complete":k(!1);const Z=M.data.output,V=M.data.segmentId,j=M.data.segmentId.startsWith("merged_");yd(_e=>{var Dn,Ut,Ke,So;const Se={id:V,text:Z,timestamp:Date.now(),isMerged:j,containedSegments:j?(Ut=(Dn=U.segments.find(rt=>rt.id===V))==null?void 0:Dn.originalSegments)==null?void 0:Ut.map(rt=>rt.id):[],isPartOfMerged:!j&&((Ke=U.segments.find(rt=>rt.id===V))==null?void 0:Ke.isPartOfMerged),mergedId:j?null:(So=U.segments.find(rt=>rt.id===V))==null?void 0:So.mergedId};return[..._e.filter(rt=>{var ko;return!((ko=Se.containedSegments)!=null&&ko.includes(rt.id))}),Se]}),U.handleTranscriptionResult({segmentId:V,output:Z,isMerged:j});break}}),()=>{t.current.terminate(),t.current=null}},[]),I.jsxs("div",{className:"flex flex-col min-h-screen max-h-screen w-screen mx-auto text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:[I.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-gray-800 border-b",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("img",{src:"logo.png",width:"32",height:"32",className:"block"}),I.jsxs("div",{children:[I.jsx("h1",{className:"text-lg font-bold",children:"Whisper WebGPU"}),I.jsx("h2",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Real-time speech recognition"})]})]}),I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx(mg,{language:te,setLanguage:yo,disabled:Zi.endsWith(".en")}),s==="initialized"&&I.jsxs(I.Fragment,{children:[I.jsx(vg,{model:Zi,setModel:xd}),I.jsx("button",{className:"px-3 py-1 text-sm bg-blue-500 text-white rounded-lg hover:bg-blue-600",onClick:()=>{var M;(M=t.current)==null||M.postMessage({type:"load",data:{modelId:Zi}}),o("loading")},children:"Load Model"})]}),!y&&I.jsx("button",{className:"px-3 py-1 text-sm bg-green-500 text-white rounded-lg hover:bg-green-600",onClick:wd,children:"Start Recording"})]})]}),I.jsxs("div",{className:"flex-1 grid grid-cols-12 gap-4 p-4 overflow-hidden",children:[I.jsx("div",{className:"col-span-3 flex flex-col gap-4 overflow-y-auto",children:I.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4",children:I.jsx(rp,{className:"w-full",stream:T,threshold:S,onThresholdChange:d,silenceLength:c,onSilenceLengthChange:h,speechHangover:v,onHangoverChange:w,audioContextRef:n,segments:F,energyScale:C,onEnergyScaleChange:_,hysteresisRatio:L,onHysteresisChange:O,minSpeechDuration:N,onMinSpeechDurationChange:le,processor:U.processor,minEnergyIntegral:Xi,onMinEnergyIntegralChange:Sd})})}),I.jsxs("div",{className:"col-span-5 flex flex-col gap-4 overflow-hidden",children:[s==="loading"&&I.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4",children:[I.jsx("p",{className:"text-center mb-2",children:u}),p.map(({file:M,progress:Z,total:V},j)=>I.jsx(lp,{text:M,percentage:Z,total:V},j))]}),s==="ready"&&I.jsxs("div",{className:"flex-1 flex flex-col bg-gray-50 dark:bg-gray-800 rounded-lg overflow-hidden",children:[I.jsx("div",{className:"flex-1 relative",children:I.jsx("textarea",{value:Ge,onChange:M=>vt(M.target.value),className:`absolute inset-0 w-full h-full resize-none p-4 font-mono text-sm bg-white dark:bg-gray-800 border rounded-lg focus:ring-2 focus:ring-blue-500`,placeholder:"Transcriptions will appear here..."})}),I.jsxs("div",{className:"flex justify-end gap-2 p-2 bg-gray-100 dark:bg-gray-700",children:[G&&I.jsxs("span",{className:"px-2 py-1 text-sm bg-gray-200 dark:bg-gray-600 rounded",children:[G.toFixed(2)," tok/s"]}),I.jsx("button",{onClick:()=>vt(""),className:"px-3 py-1 text-sm bg-red-500 text-white rounded hover:bg-red-600",children:"Clear"}),I.jsx("button",{onClick:()=>navigator.clipboard.writeText(Ge),className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Copy"}),I.jsx("button",{onClick:Id,className:"px-3 py-1 text-sm bg-gray-500 text-white rounded hover:bg-gray-600",children:"Reset"})]})]})]}),I.jsx("div",{className:"col-span-4 overflow-y-auto",children:I.jsx(md,{segments:F,worker:t.current,language:te})})]})]})}Il.createRoot(document.getElementById("root")).render(I.jsx(Vd.StrictMode,{children:I.jsx(Ig,{})}));