diff --git "a/assets/index-Sx-YVtQS.js" "b/assets/index-Sx-YVtQS.js" new file mode 100644--- /dev/null +++ "b/assets/index-Sx-YVtQS.js" @@ -0,0 +1,43 @@ +var Sd=Object.defineProperty;var kd=(t,e,n)=>e in t?Sd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ko=(t,e,n)=>kd(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 wd(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Vu={exports:{}},Fi={},Xu={exports:{}},O={};/** + * @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"),xd=Symbol.for("react.portal"),Id=Symbol.for("react.fragment"),_d=Symbol.for("react.strict_mode"),Cd=Symbol.for("react.profiler"),Ed=Symbol.for("react.provider"),Td=Symbol.for("react.context"),Pd=Symbol.for("react.forward_ref"),Ld=Symbol.for("react.suspense"),Md=Symbol.for("react.memo"),Fd=Symbol.for("react.lazy"),wo=Symbol.iterator;function zd(t){return t===null||typeof t!="object"?null:(t=wo&&t[wo]||t["@@iterator"],typeof t=="function"?t:null)}var Qu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ku=Object.assign,Gu={};function Nn(t,e,n){this.props=t,this.context=e,this.refs=Gu,this.updater=n||Qu}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 Yu(){}Yu.prototype=Nn.prototype;function ys(t,e,n){this.props=t,this.context=e,this.refs=Gu,this.updater=n||Qu}var Ss=ys.prototype=new Yu;Ss.constructor=ys;Ku(Ss,Nn.prototype);Ss.isPureReactComponent=!0;var xo=Array.isArray,Zu=Object.prototype.hasOwnProperty,ks={current:null},Ju={key:!0,ref:!0,__self:!0,__source:!0};function qu(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)Zu.call(e,r)&&!Ju.hasOwnProperty(r)&&(i[r]=e[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1>>1,K=T[W];if(0>>1;Wi(Ot,z))Jei(nn,Ot)?(T[W]=nn,T[Je]=z,W=Je):(T[W]=Ot,T[Ie]=z,W=Ie);else if(Jei(nn,z))T[W]=nn,T[Je]=z,W=Je;else break e}}return R}function i(T,R){var z=T.sortIndex-R.sortIndex;return z!==0?z:T.id-R.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=[],c=[],m=1,p=null,f=3,v=!1,S=!1,k=!1,F=typeof setTimeout=="function"?setTimeout:null,d=typeof clearTimeout=="function"?clearTimeout:null,a=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 R=n(c);R!==null;){if(R.callback===null)r(c);else if(R.startTime<=T)r(c),R.sortIndex=R.expirationTime,e(u,R);else break;R=n(c)}}function g(T){if(k=!1,h(T),!S)if(n(u)!==null)S=!0,Dt(x);else{var R=n(c);R!==null&&Pr(g,R.startTime-T)}}function x(T,R){S=!1,k&&(k=!1,d(P),P=-1),v=!0;var z=f;try{for(h(R),p=n(u);p!==null&&(!(p.expirationTime>R)||T&&!ge());){var W=p.callback;if(typeof W=="function"){p.callback=null,f=p.priorityLevel;var K=W(p.expirationTime<=R);R=t.unstable_now(),typeof K=="function"?p.callback=K:p===n(u)&&r(u),h(R)}else r(u);p=n(u)}if(p!==null)var tn=!0;else{var Ie=n(c);Ie!==null&&Pr(g,Ie.startTime-R),tn=!1}return tn}finally{p=null,f=z,v=!1}}var I=!1,E=null,P=-1,B=5,N=-1;function ge(){return!(t.unstable_now()-NT||125W?(T.sortIndex=z,e(c,T),n(u)===null&&T===n(c)&&(k?(d(P),P=-1):k=!0,Pr(g,z-W))):(T.sortIndex=K,e(u,T),S||v||(S=!0,Dt(x))),T},t.unstable_shouldYield=ge,t.unstable_wrapCallback=function(T){var R=f;return function(){var z=f;f=R;try{return T.apply(this,arguments)}finally{f=z}}}})(ra);na.exports=ra;var Vd=na.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 Xd=C,ze=Vd;function w(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"),_l=Object.prototype.hasOwnProperty,Qd=/^[: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={},Co={};function Kd(t){return _l.call(Co,t)?!0:_l.call(_o,t)?!1:Qd.test(t)?Co[t]=!0:(_o[t]=!0,!1)}function Gd(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 Yd(t,e,n,r){if(e===null||typeof e>"u"||Gd(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 xe(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 de={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){de[t]=new xe(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];de[e]=new xe(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){de[t]=new xe(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){de[t]=new xe(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){de[t]=new xe(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){de[t]=new xe(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){de[t]=new xe(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){de[t]=new xe(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){de[t]=new xe(t,5,!1,t.toLowerCase(),null,!1,!1)});var xs=/[\-:]([a-z])/g;function Is(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,Is);de[e]=new xe(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,Is);de[e]=new xe(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,Is);de[e]=new xe(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){de[t]=new xe(t,1,!1,t.toLowerCase(),null,!1,!1)});de.xlinkHref=new xe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){de[t]=new xe(t,1,!1,t.toLowerCase(),null,!0,!0)});function _s(t,e,n,r){var i=de.hasOwnProperty(e)?de[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{qi=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Qn(t):""}function Zd(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=bi(t.type,!1),t;case 11:return t=bi(t.type.render,!1),t;case 1:return t=bi(t.type,!0),t;default:return""}}function Pl(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 Cs:return"StrictMode";case El:return"Suspense";case Tl:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case sa:return(t.displayName||"Context")+".Consumer";case la: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 Ts:return e=t.displayName||null,e!==null?e:Pl(t.type)||"Memo";case vt:e=t._payload,t=t._init;try{return Pl(t(e))}catch{}}return null}function Jd(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 Pl(e);case 8:return e===Cs?"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 Ft(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ua(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function qd(t){var e=ua(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 Nr(t){t._valueTracker||(t._valueTracker=qd(t))}function aa(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=ua(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function si(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 Ll(t,e){var n=e.checked;return J({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function To(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Ft(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 ca(t,e){e=e.checked,e!=null&&_s(t,"checked",e,!1)}function Ml(t,e){ca(t,e);var n=Ft(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")?Fl(t,e.type,n):e.hasOwnProperty("defaultValue")&&Fl(t,e.type,Ft(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Po(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 Fl(t,e,n){(e!=="number"||si(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Kn=Array.isArray;function Sn(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Rr.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function sr(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Zn={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},bd=["Webkit","ms","Moz","O"];Object.keys(Zn).forEach(function(t){bd.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Zn[e]=Zn[t]})});function pa(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Zn.hasOwnProperty(t)&&Zn[t]?(""+e).trim():e+"px"}function ma(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=pa(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var eh=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 Rl(t,e){if(e){if(eh[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(w(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(w(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(w(61))}if(e.style!=null&&typeof e.style!="object")throw Error(w(62))}}function jl(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 Dl=null;function Ps(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=Cr(t)){if(typeof Ol!="function")throw Error(w(280));var e=t.stateNode;e&&(e=Di(e),Ol(t.stateNode,t.type,e))}}function ga(t){kn?wn?wn.push(t):wn=[t]:kn=t}function va(){if(kn){var t=kn,e=wn;if(wn=kn=null,Fo(t),e)for(t=0;t>>=0,t===0?32:31-(dh(t)/hh|0)|0}var jr=64,Dr=4194304;function Gn(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 ci(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=Gn(o):(l&=s,l!==0&&(r=Gn(l)))}else s=n&~i,s!==0?r=Gn(s):l!==0&&(r=Gn(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 Ir(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Ge(e),t[e]=n}function gh(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=qn),Bo=" ",$o=!1;function Oa(t,e){switch(t){case"keyup":return Vh.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Aa(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var on=!1;function Qh(t,e){switch(t){case"compositionend":return Aa(e);case"keypress":return e.which!==32?null:($o=!0,Bo);case"textInput":return t=e.data,t===Bo&&$o?null:t;default:return null}}function Kh(t,e){if(on)return t==="compositionend"||!Ds&&Oa(t,e)?(t=ja(),Jr=Ns=wt=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=Xo(n)}}function Ha(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Ha(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Wa(){for(var t=window,e=si();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=si(t.document)}return e}function Os(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 nf(t){var e=Wa(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Ha(n.ownerDocument.documentElement,n)){if(r!==null&&Os(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,Wl=null,er=null,Vl=!1;function Ko(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vl||un==null||un!==si(r)||(r=un,"selectionStart"in r&&Os(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}),er&&hr(er,r)||(er=r,r=fi(Wl,"onSelect"),0dn||(t.current=Zl[dn],Zl[dn]=null,dn--)}function H(t,e){dn++,Zl[dn]=t.current,t.current=e}var zt={},me=Rt(zt),Ee=Rt(!1),Gt=zt;function Tn(t,e){var n=t.type.contextTypes;if(!n)return zt;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 Te(t){return t=t.childContextTypes,t!=null}function mi(){X(Ee),X(me)}function eu(t,e,n){if(me.current!==zt)throw Error(w(168));H(me,e),H(Ee,n)}function qa(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(w(108,Jd(t)||"Unknown",i));return J({},n,r)}function gi(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||zt,Gt=me.current,H(me,t),H(Ee,Ee.current),!0}function tu(t,e,n){var r=t.stateNode;if(!r)throw Error(w(169));n?(t=qa(t,e,Gt),r.__reactInternalMemoizedMergedChildContext=t,X(Ee),X(me),H(me,t)):X(Ee),H(Ee,n)}var st=null,Oi=!1,fl=!1;function ba(t){st===null?st=[t]:st.push(t)}function mf(t){Oi=!0,ba(t)}function jt(){if(!fl&&st!==null){fl=!0;var t=0,e=U;try{var n=st;for(U=1;t>=s,i-=s,ot=1<<32-Ge(e)+i|n<P?(B=E,E=null):B=E.sibling;var N=f(d,E,h[P],g);if(N===null){E===null&&(E=B);break}t&&E&&N.alternate===null&&e(d,E),a=l(N,a,P),I===null?x=N:I.sibling=N,I=N,E=B}if(P===h.length)return n(d,E),Q&&Ut(d,P),x;if(E===null){for(;PP?(B=E,E=null):B=E.sibling;var ge=f(d,E,N.value,g);if(ge===null){E===null&&(E=B);break}t&&E&&ge.alternate===null&&e(d,E),a=l(ge,a,P),I===null?x=ge:I.sibling=ge,I=ge,E=B}if(N.done)return n(d,E),Q&&Ut(d,P),x;if(E===null){for(;!N.done;P++,N=h.next())N=p(d,N.value,g),N!==null&&(a=l(N,a,P),I===null?x=N:I.sibling=N,I=N);return Q&&Ut(d,P),x}for(E=r(d,E);!N.done;P++,N=h.next())N=v(E,d,P,N.value,g),N!==null&&(t&&N.alternate!==null&&E.delete(N.key===null?P:N.key),a=l(N,a,P),I===null?x=N:I.sibling=N,I=N);return t&&E.forEach(function($){return e(d,$)}),Q&&Ut(d,P),x}function F(d,a,h,g){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 x=h.key,I=a;I!==null;){if(I.key===x){if(x=h.type,x===sn){if(I.tag===7){n(d,I.sibling),a=i(I,h.props.children),a.return=d,d=a;break e}}else if(I.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===vt&&iu(x)===I.type){n(d,I.sibling),a=i(I,h.props),a.ref=Hn(d,I,h),a.return=d,d=a;break e}n(d,I);break}else e(d,I);I=I.sibling}h.type===sn?(a=Kt(h.props.children,d.mode,g,h.key),a.return=d,d=a):(g=li(h.type,h.key,h.props,null,d.mode,g),g.ref=Hn(d,a,h),g.return=d,d=g)}return s(d);case ln:e:{for(I=h.key;a!==null;){if(a.key===I)if(a.tag===4&&a.stateNode.containerInfo===h.containerInfo&&a.stateNode.implementation===h.implementation){n(d,a.sibling),a=i(a,h.children||[]),a.return=d,d=a;break e}else{n(d,a);break}else e(d,a);a=a.sibling}a=wl(h,d.mode,g),a.return=d,d=a}return s(d);case vt:return I=h._init,F(d,a,I(h._payload),g)}if(Kn(h))return S(d,a,h,g);if(On(h))return k(d,a,h,g);Wr(d,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,a!==null&&a.tag===6?(n(d,a.sibling),a=i(a,h),a.return=d,d=a):(n(d,a),a=kl(h,d.mode,g),a.return=d,d=a),s(d)):n(d,a)}return F}var Ln=rc(!0),ic=rc(!1),Si=Rt(null),ki=null,pn=null,$s=null;function Hs(){$s=pn=ki=null}function Ws(t){var e=Si.current;X(Si),t._currentValue=e}function bl(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 In(t,e){ki=t,$s=pn=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Ce=!0),t.firstContext=null)}function Be(t){var e=t._currentValue;if($s!==t)if(t={context:t,memoizedValue:e,next:null},pn===null){if(ki===null)throw Error(w(308));pn=t,ki.dependencies={lanes:0,firstContext:t}}else pn=pn.next=t;return e}var Vt=null;function Vs(t){Vt===null?Vt=[t]:Vt.push(t)}function lc(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,Vs(e)):(n.next=i.next,i.next=n),e.interleaved=n,ht(t,r)}function ht(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 yt=!1;function Xs(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sc(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 at(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Tt(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,A&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,ht(t,n)}return i=r.interleaved,i===null?(e.next=e,Vs(r)):(e.next=i.next,i.next=e),r.interleaved=e,ht(t,n)}function br(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 lu(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 wi(t,e,n,r){var i=t.updateQueue;yt=!1;var l=i.firstBaseUpdate,s=i.lastBaseUpdate,o=i.shared.pending;if(o!==null){i.shared.pending=null;var u=o,c=u.next;u.next=null,s===null?l=c:s.next=c,s=u;var m=t.alternate;m!==null&&(m=m.updateQueue,o=m.lastBaseUpdate,o!==s&&(o===null?m.firstBaseUpdate=c:o.next=c,m.lastBaseUpdate=u))}if(l!==null){var p=i.baseState;s=0,m=c=u=null,o=l;do{var f=o.lane,v=o.eventTime;if((r&f)===f){m!==null&&(m=m.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var S=t,k=o;switch(f=e,v=n,k.tag){case 1:if(S=k.payload,typeof S=="function"){p=S.call(v,p,f);break e}p=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=k.payload,f=typeof S=="function"?S.call(v,p,f):S,f==null)break e;p=J({},p,f);break e;case 2:yt=!0}}o.callback!==null&&o.lane!==0&&(t.flags|=64,f=i.effects,f===null?i.effects=[o]:f.push(o))}else v={eventTime:v,lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},m===null?(c=m=v,u=p):m=m.next=v,s|=f;if(o=o.next,o===null){if(o=i.shared.pending,o===null)break;f=o,o=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);if(m===null&&(u=p),i.baseState=u,i.firstBaseUpdate=c,i.lastBaseUpdate=m,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);Jt|=s,t.lanes=s,t.memoizedState=p}}function su(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=ml.transition;ml.transition={};try{t(!1),e()}finally{U=n,ml.transition=r}}function Ic(){return $e().memoizedState}function Sf(t,e,n){var r=Lt(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},_c(t))Cc(e,n);else if(n=lc(t,e,n,r),n!==null){var i=ke();Ye(n,t,r,i),Ec(n,e,r)}}function kf(t,e,n){var r=Lt(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(_c(t))Cc(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,Ze(o,s)){var u=e.interleaved;u===null?(i.next=i,Vs(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}n=lc(t,e,i,r),n!==null&&(i=ke(),Ye(n,t,r,i),Ec(n,e,r))}}function _c(t){var e=t.alternate;return t===Z||e!==null&&e===Z}function Cc(t,e){tr=Ii=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Ec(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ms(t,n)}}var _i={readContext:Be,useCallback:he,useContext:he,useEffect:he,useImperativeHandle:he,useInsertionEffect:he,useLayoutEffect:he,useMemo:he,useReducer:he,useRef:he,useState:he,useDebugValue:he,useDeferredValue:he,useTransition:he,useMutableSource:he,useSyncExternalStore:he,useId:he,unstable_isNewReconciler:!1},wf={readContext:Be,useCallback:function(t,e){return be().memoizedState=[t,e===void 0?null:e],t},useContext:Be,useEffect:uu,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,ti(4194308,4,yc.bind(null,e,t),n)},useLayoutEffect:function(t,e){return ti(4194308,4,t,e)},useInsertionEffect:function(t,e){return ti(4,2,t,e)},useMemo:function(t,e){var n=be();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=be();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=Sf.bind(null,Z,t),[r.memoizedState,t]},useRef:function(t){var e=be();return t={current:t},e.memoizedState=t},useState:ou,useDebugValue:bs,useDeferredValue:function(t){return be().memoizedState=t},useTransition:function(){var t=ou(!1),e=t[0];return t=yf.bind(null,t[1]),be().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Z,i=be();if(Q){if(n===void 0)throw Error(w(407));n=n()}else{if(n=e(),ue===null)throw Error(w(349));Zt&30||cc(r,e,n)}i.memoizedState=n;var l={value:n,getSnapshot:e};return i.queue=l,uu(hc.bind(null,r,l,t),[t]),r.flags|=2048,kr(9,dc.bind(null,r,l,n,e),void 0,null),n},useId:function(){var t=be(),e=ue.identifierPrefix;if(Q){var n=ut,r=ot;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=yr++,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[et]=e,t[mr]=r,Dc(t,e,!1,!1),e.stateNode=t;e:{switch(s=jl(n,r),n){case"dialog":V("cancel",t),V("close",t),i=r;break;case"iframe":case"object":case"embed":V("load",t),i=r;break;case"video":case"audio":for(i=0;izn&&(e.flags|=128,r=!0,Wn(l,!1),e.lanes=4194304)}else{if(!r)if(t=xi(s),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Wn(l,!0),l.tail===null&&l.tailMode==="hidden"&&!s.alternate&&!Q)return fe(e),null}else 2*ee()-l.renderingStartTime>zn&&n!==1073741824&&(e.flags|=128,r=!0,Wn(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=ee(),e.sibling=null,n=Y.current,H(Y,r?n&1|2:n&1),e):(fe(e),null);case 22:case 23:return lo(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Le&1073741824&&(fe(e),e.subtreeFlags&6&&(e.flags|=8192)):fe(e),null;case 24:return null;case 25:return null}throw Error(w(156,e.tag))}function Lf(t,e){switch(Us(e),e.tag){case 1:return Te(e.type)&&mi(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Mn(),X(Ee),X(me),Gs(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Ks(e),null;case 13:if(X(Y),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(w(340));Pn()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return X(Y),null;case 4:return Mn(),null;case 10:return Ws(e.type._context),null;case 22:case 23:return lo(),null;case 24:return null;default:return null}}var Xr=!1,pe=!1,Mf=typeof WeakSet=="function"?WeakSet:Set,L=null;function mn(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 us(t,e,n){try{n()}catch(r){q(t,e,r)}}var Su=!1;function Ff(t,e){if(Xl=di,t=Wa(),Os(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,c=0,m=0,p=t,f=null;t:for(;;){for(var v;p!==n||i!==0&&p.nodeType!==3||(o=s+i),p!==l||r!==0&&p.nodeType!==3||(u=s+r),p.nodeType===3&&(s+=p.nodeValue.length),(v=p.firstChild)!==null;)f=p,p=v;for(;;){if(p===t)break t;if(f===n&&++c===i&&(o=s),f===l&&++m===r&&(u=s),(v=p.nextSibling)!==null)break;p=f,f=p.parentNode}p=v}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ql={focusedElem:t,selectionRange:n},di=!1,L=e;L!==null;)if(e=L,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,L=t;else for(;L!==null;){e=L;try{var S=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var k=S.memoizedProps,F=S.memoizedState,d=e.stateNode,a=d.getSnapshotBeforeUpdate(e.elementType===e.type?k:Xe(e.type,k),F);d.__reactInternalSnapshotBeforeUpdate=a}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(w(163))}}catch(g){q(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,L=t;break}L=e.return}return S=Su,Su=!1,S}function nr(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&&us(e,n,l)}i=i.next}while(i!==r)}}function Bi(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 as(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 Uc(t){var e=t.alternate;e!==null&&(t.alternate=null,Uc(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[et],delete e[mr],delete e[Yl],delete e[ff],delete e[pf])),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 Bc(t){return t.tag===5||t.tag===3||t.tag===4}function ku(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Bc(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 cs(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=pi));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}function ds(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(ds(t,e,n),t=t.sibling;t!==null;)ds(t,e,n),t=t.sibling}var ae=null,Qe=!1;function gt(t,e,n){for(n=n.child;n!==null;)$c(t,e,n),n=n.sibling}function $c(t,e,n){if(tt&&typeof tt.onCommitFiberUnmount=="function")try{tt.onCommitFiberUnmount(zi,n)}catch{}switch(n.tag){case 5:pe||mn(n,e);case 6:var r=ae,i=Qe;ae=null,gt(t,e,n),ae=r,Qe=i,ae!==null&&(Qe?(t=ae,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):ae.removeChild(n.stateNode));break;case 18:ae!==null&&(Qe?(t=ae,n=n.stateNode,t.nodeType===8?hl(t.parentNode,n):t.nodeType===1&&hl(t,n),cr(t)):hl(ae,n.stateNode));break;case 4:r=ae,i=Qe,ae=n.stateNode.containerInfo,Qe=!0,gt(t,e,n),ae=r,Qe=i;break;case 0:case 11:case 14:case 15:if(!pe&&(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)&&us(n,e,s),i=i.next}while(i!==r)}gt(t,e,n);break;case 1:if(!pe&&(mn(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)}gt(t,e,n);break;case 21:gt(t,e,n);break;case 22:n.mode&1?(pe=(r=pe)||n.memoizedState!==null,gt(t,e,n),pe=r):gt(t,e,n);break;default:gt(t,e,n)}}function wu(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Mf),e.forEach(function(r){var i=Bf.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function We(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~l}if(r=i,r=ee()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Nf(r/1960))-r,10t?16:t,xt===null)var r=!1;else{if(t=xt,xt=null,Ti=0,A&6)throw Error(w(331));var i=A;for(A|=4,L=t.current;L!==null;){var l=L,s=l.child;if(L.flags&16){var o=l.deletions;if(o!==null){for(var u=0;uee()-ro?Qt(t,0):no|=n),Pe(t,e)}function Yc(t,e){e===0&&(t.mode&1?(e=Dr,Dr<<=1,!(Dr&130023424)&&(Dr=4194304)):e=1);var n=ke();t=ht(t,e),t!==null&&(Ir(t,e,n),Pe(t,n))}function Uf(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),Yc(t,n)}function Bf(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(w(314))}r!==null&&r.delete(e),Yc(t,n)}var Zc;Zc=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ee.current)Ce=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Ce=!1,Tf(t,e,n);Ce=!!(t.flags&131072)}else Ce=!1,Q&&e.flags&1048576&&ec(e,yi,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ni(t,e),t=e.pendingProps;var i=Tn(e,me.current);In(e,n),i=Zs(null,e,r,t,i,n);var l=Js();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,Te(r)?(l=!0,gi(e)):l=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Xs(e),i.updater=Ui,e.stateNode=i,i._reactInternals=e,ts(e,r,t,n),e=is(null,e,r,!0,l,n)):(e.tag=0,Q&&l&&As(e),Se(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(ni(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Hf(r),t=Xe(r,t),i){case 0:e=rs(null,e,r,t,n);break e;case 1:e=gu(null,e,r,t,n);break e;case 11:e=pu(null,e,r,t,n);break e;case 14:e=mu(null,e,r,Xe(r.type,t),n);break e}throw Error(w(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Xe(r,i),rs(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Xe(r,i),gu(t,e,r,i,n);case 3:e:{if(Nc(e),t===null)throw Error(w(387));r=e.pendingProps,l=e.memoizedState,i=l.element,sc(t,e),wi(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=Fn(Error(w(423)),e),e=vu(t,e,r,n,i);break e}else if(r!==i){i=Fn(Error(w(424)),e),e=vu(t,e,r,n,i);break e}else for(Me=Et(e.stateNode.containerInfo.firstChild),Fe=e,Q=!0,Ke=null,n=ic(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pn(),r===i){e=ft(t,e,n);break e}Se(t,e,r,n)}e=e.child}return e;case 5:return oc(e),t===null&&ql(e),r=e.type,i=e.pendingProps,l=t!==null?t.memoizedProps:null,s=i.children,Kl(r,i)?s=null:l!==null&&Kl(r,l)&&(e.flags|=32),zc(t,e),Se(t,e,s,n),e.child;case 6:return t===null&&ql(e),null;case 13:return Rc(t,e,n);case 4:return Qs(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ln(e,null,r,n):Se(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Xe(r,i),pu(t,e,r,i,n);case 7:return Se(t,e,e.pendingProps,n),e.child;case 8:return Se(t,e,e.pendingProps.children,n),e.child;case 12:return Se(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(Si,r._currentValue),r._currentValue=s,l!==null)if(Ze(l.value,s)){if(l.children===i.children&&!Ee.current){e=ft(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=at(-1,n&-n),u.tag=2;var c=l.updateQueue;if(c!==null){c=c.shared;var m=c.pending;m===null?u.next=u:(u.next=m.next,m.next=u),c.pending=u}}l.lanes|=n,u=l.alternate,u!==null&&(u.lanes|=n),bl(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(w(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),bl(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}Se(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,In(e,n),i=Be(i),r=r(i),e.flags|=1,Se(t,e,r,n),e.child;case 14:return r=e.type,i=Xe(r,e.pendingProps),i=Xe(r.type,i),mu(t,e,r,i,n);case 15:return Mc(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Xe(r,i),ni(t,e),e.tag=1,Te(r)?(t=!0,gi(e)):t=!1,In(e,n),Tc(e,r,i),ts(e,r,i,n),is(null,e,r,!0,t,n);case 19:return jc(t,e,n);case 22:return Fc(t,e,n)}throw Error(w(156,e.tag))};function Jc(t,e){return _a(t,e)}function $f(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 Ae(t,e,n,r){return new $f(t,e,n,r)}function oo(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Hf(t){if(typeof t=="function")return oo(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Es)return 11;if(t===Ts)return 14}return 2}function Mt(t,e){var n=t.alternate;return n===null?(n=Ae(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 li(t,e,n,r,i,l){var s=2;if(r=t,typeof t=="function")oo(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case sn:return Kt(n.children,i,l,e);case Cs:s=8,i|=8;break;case Cl:return t=Ae(12,n,e,i|2),t.elementType=Cl,t.lanes=l,t;case El:return t=Ae(13,n,e,i),t.elementType=El,t.lanes=l,t;case Tl:return t=Ae(19,n,e,i),t.elementType=Tl,t.lanes=l,t;case oa:return Hi(n,i,l,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case la:s=10;break e;case sa:s=9;break e;case Es:s=11;break e;case Ts:s=14;break e;case vt:s=16,r=null;break e}throw Error(w(130,t==null?t:typeof t,""))}return e=Ae(s,n,e,i),e.elementType=t,e.type=r,e.lanes=l,e}function Kt(t,e,n,r){return t=Ae(7,t,r,e),t.lanes=n,t}function Hi(t,e,n,r){return t=Ae(22,t,r,e),t.elementType=oa,t.lanes=n,t.stateNode={isHidden:!1},t}function kl(t,e,n){return t=Ae(6,t,null,e),t.lanes=n,t}function wl(t,e,n){return e=Ae(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Wf(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=tl(0),this.expirationTimes=tl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function uo(t,e,n,r,i,l,s,o,u){return t=new Wf(t,e,n,o,u),e===1?(e=1,l===!0&&(e|=8)):e=0,l=Ae(3,null,null,e),t.current=l,l.stateNode=t,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xs(l),t}function Vf(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(td)}catch(t){console.error(t)}}td(),ta.exports=Ne;var Yf=ta.exports,Lu=Yf;Il.createRoot=Lu.createRoot,Il.hydrateRoot=Lu.hydrateRoot;class nd{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 rd{constructor(e={}){this.options={sampleRate:16e3,windowSize:1600,minSpeechDuration:.3,silenceThreshold:.8,energyThreshold:.02,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(),c=u!==-1?this.state.recentChunks[u].time:n;this.startSpeech(c,r),this.log("Speech start detected",{detectedAt:n.toFixed(2),actualStart:c.toFixed(2),lookbackDiff:(n-c).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 c=n-this.state.speechStartTime,m=this.state.speechEnergies.reduce((p,f)=>p+f,0)/this.state.speechEnergies.length;this.state.speechStats.push({startTime:this.state.speechStartTime,endTime:n,duration:c,avgEnergy:m,energyIntegral:m*c}),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}setSilenceLength(e){this.options.silenceThreshold=e}createSegment(e,n,r,i){const o=Math.floor(.5*i),u=Math.floor(.3*i),c=Math.floor(e*i),m=Math.floor(n*i),p=Math.max(0,c-o),f=Math.min(r.length,m+u);if(p>=r.length||f<=0)return this.log("Invalid segment boundaries",{start:e,end:n,startSample:p,endSample:f,bufferLength:r.length,lookback:.5,overlap:.3}),null;const v=f-p;if(v<=0)return this.log("Invalid segment length",{length:v,start:e,end:n}),null;const S=new Float32Array(v);S.set(r.slice(p,f));const k=new nd({startTime:e-.5,endTime:n+.3,audioData:S,sampleRate:i,energy:this.state.speechEnergies.reduce((F,d)=>F+d,0)/this.state.speechEnergies.length});return this.log("Created segment",{originalStart:e.toFixed(2),originalEnd:n.toFixed(2),finalStart:k.startTime.toFixed(2),finalEnd:k.endTime.toFixed(2),duration:(k.endTime-k.startTime).toFixed(2),samples:v,lookbackSamples:o,overlapSamples:u}),k}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:.02,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="tr",this._nextSegmentId=0,yn.instance=this}async initialize(e={}){if(!this.initialized)try{this.options=e,this.processor=new rd({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;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:r!u.isPartOfMerged&&u.endTime>=e.startTime-.5&&u.id!==e.id);if(o.length>0){const u={startTime:Math.min(...o.map(c=>c.startTime),e.startTime),endTime:Math.max(...o.map(c=>c.endTime),e.endTime),id:`merged_${Date.now()}`,isMerged:!0,isProcessed:!1,audioData:this.getMergedAudioData([...o,e]),sampleRate:this.audioContext.sampleRate,originalSegments:[...o,e]};[...o,e].forEach(c=>{c.isPartOfMerged=!0,c.mergedId=u.id}),this.segments.push(u),this.sendForTranscription(u)}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)}sendForTranscription(e){!this.worker||!e.audioData||e.isPartOfMerged&&!e.isMerged||this._activeTranscriptions.has(e.id)||(e.isProcessed=!0,this._activeTranscriptions.add(e.id),this.worker.postMessage({type:"transcribe",data:{audioData:e.audioData,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,this.parameters.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 parameters:",this.parameters)}mergeOverlappingSegments(e){if(!e||e.length<2)return e;const n=[];let r=e[0];for(let i=1;i{const d=k>u,a=d?u:k,h=d?k-u:0;S.forEach(g=>{const x=d?g.startTime-h:g.startTime,I=d?g.endTime-h:g.endTime,E=x/a*F.width,P=I/a*F.width;x<=a&&I>=0&&(v.fillStyle=g.isMerged?"rgba(128, 0, 128, 0.2)":g.isPartOfMerged?"rgba(255, 165, 0, 0.1)":g.isProcessed?"rgba(0, 200, 0, 0.1)":"rgba(255, 200, 0, 0.1)",v.fillRect(E,0,P-E,F.height),v.strokeStyle=g.isMerged?"rgba(128, 0, 128, 0.5)":"rgba(0, 100, 200, 0.5)",v.beginPath(),v.moveTo(E,0),v.lineTo(E,F.height),v.moveTo(P,0),v.lineTo(P,F.height),v.stroke(),v.fillStyle="#666",v.font="10px Arial",v.fillText(`${g.startTime.toFixed(1)}s`,E+2,10))})},[]),p=C.useCallback((v,S,k,F)=>{const d=F>u,a=d?Math.min(S.length,u*e.current.sampleRate):S.length,h=d?S.length-a:0,g=k.height/2,x=k.height/2;v.strokeStyle="#c8c8c8",v.lineWidth=1,v.beginPath();for(let I=0;I{const v=Date.now();if(v-l.current{const d=t.reduce((x,I)=>x+I.length,0),a=new Float32Array(d);let h=0;for(const x of t)a.set(x,h),h+=x.length;const g=d/e.current.sampleRate;k.fillStyle="#f5f5f5",k.fillRect(0,0,S.width,S.height),p(k,a,S,g),m(k,n,g,S),f(k,g,S)})().catch(console.error)},[t,n,m,p]);const f=(v,S,k)=>{const F=S>u,d=F?u:S,a=F?S-u:0;v.fillStyle="#666",v.font="10px Arial";for(let h=0;h<=d;h+=5){const g=h/d*k.width,x=a+h;v.fillText(`${x.toFixed(0)}s`,g,k.height-2)}};return y.jsx("canvas",{ref:i,width:720,height:80,className:"w-full border rounded bg-[#f5f5f5]"})}function Jf({chunks:t,audioContextRef:e,segments:n,threshold:r,processor:i}){var u;const l=(i==null?void 0:i.getStats())||{silence:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0},speech:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0}},[s,o]=C.useState(l);return C.useEffect(()=>{const c=setInterval(()=>{i&&o(i.getStats())},100);return()=>clearInterval(c)},[i]),y.jsxs("div",{children:[y.jsx("h3",{className:"text-xs font-semibold mb-2",children:"Audio Stats"}),y.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[y.jsxs("div",{children:[y.jsx("h4",{className:"text-xs font-semibold mb-1",children:"Silence Stats"}),y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{children:["Avg Duration: ",s.silence.avgDuration.toFixed(2),"s"]}),y.jsxs("div",{children:["Avg Energy: ",s.silence.avgEnergy.toFixed(4)]}),y.jsxs("div",{children:["Energy Integral: ",s.silence.avgEnergyIntegral.toFixed(4)]})]})]}),y.jsxs("div",{children:[y.jsx("h4",{className:"text-xs font-semibold mb-1",children:"Speech Stats"}),y.jsxs("div",{className:"text-xs space-y-1",children:[y.jsxs("div",{children:["Avg Duration: ",s.speech.avgDuration.toFixed(2),"s"]}),y.jsxs("div",{children:["Avg Energy: ",s.speech.avgEnergy.toFixed(4)]}),y.jsxs("div",{children:["Energy Integral: ",s.speech.avgEnergyIntegral.toFixed(4)]})]})]})]}),y.jsxs("div",{className:"mt-2 text-xs space-y-1",children:[y.jsxs("div",{children:["Total Segments: ",n.length]}),y.jsxs("div",{children:["Energy Threshold: ",r.toFixed(4)]}),y.jsxs("div",{children:["Buffer Duration: ",(t.length*1600/16e3).toFixed(2),"s"]}),y.jsxs("div",{children:["Sample Rate: ",((u=e.current)==null?void 0:u.sampleRate)||16e3,"Hz"]})]})]})}function qf({className:t,stream:e,threshold:n,onThresholdChange:r,silenceLength:i,onSilenceLengthChange:l,speechHangover:s,onHangoverChange:o,chunks:u=[],audioContextRef:c,segments:m=[],energyScale:p,onEnergyScaleChange:f,hysteresisRatio:v,onHysteresisChange:S,minSpeechDuration:k,onMinSpeechDurationChange:F,processor:d,minEnergyIntegral:a,onMinEnergyIntegralChange:h}){const[g,x]=C.useState(0),[I,E]=C.useState(0),[P,B]=C.useState(0),[N,ge]=C.useState(0);return y.jsxs("div",{className:t,children:[y.jsx("div",{className:"mb-2",children:y.jsx(Zf,{chunks:u,audioContextRef:c,segments:m,onEnergyUpdate:($,rt,mt,Tr)=>{x($),E(rt),B(mt),ge(Tr)}})}),y.jsxs("div",{className:"flex gap-4 h-full",children:[y.jsxs("div",{className:"flex-1 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg",children:[y.jsx("h3",{className:"text-xs font-semibold mb-2",children:"Speech Detection Parameters"}),y.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Energy Threshold: ",n.toFixed(3)]}),y.jsx("input",{type:"range",min:"0.05",max:"1.0",step:"0.01",value:n,onChange:$=>r(parseFloat($.target.value)),className:"w-full h-4"})]}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Energy Scale: ",p.toFixed(1)]}),y.jsx("input",{type:"range",min:"0.1",max:"2.0",step:"0.1",value:p,onChange:$=>f(parseFloat($.target.value)),className:"w-full h-4"})]}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Min Silence (s): ",i.toFixed(2)]}),y.jsx("input",{type:"range",min:"0.1",max:"1.0",step:"0.05",value:i,onChange:$=>l(parseFloat($.target.value)),className:"w-full h-4"})]}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Speech Hangover (s): ",s.toFixed(2)]}),y.jsx("input",{type:"range",min:"0.1",max:"0.5",step:"0.05",value:s,onChange:$=>o(parseFloat($.target.value)),className:"w-full h-4"})]}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Min Speech (s): ",k.toFixed(2)]}),y.jsx("input",{type:"range",min:"0.05",max:"0.5",step:"0.05",value:k,onChange:$=>F(parseFloat($.target.value)),className:"w-full h-4"})]}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Hysteresis: ",v.toFixed(2)]}),y.jsx("input",{type:"range",min:"1.0",max:"2.0",step:"0.1",value:v,onChange:$=>S(parseFloat($.target.value)),className:"w-full h-4"})]}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("label",{className:"text-xs mb-1",children:["Min Energy Integral: ",a.toFixed(3)]}),y.jsx("input",{type:"range",min:"5",max:"50",step:"5",value:a,onChange:$=>h(parseFloat($.target.value)),className:"w-full h-4"})]})]}),y.jsxs("div",{className:"mt-2 text-xs grid grid-cols-4 gap-1",children:[y.jsxs("div",{children:["Current: ",g.toFixed(4)]}),y.jsxs("div",{children:["Avg: ",I.toFixed(4)]}),y.jsxs("div",{children:["Peak: ",P.toFixed(4)]}),y.jsxs("div",{children:["Raw: ",N.toFixed(4)]})]})]}),y.jsx("div",{className:"flex-1 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg",children:y.jsx(Jf,{chunks:u,audioContextRef:c,segments:m,threshold:n,processor:d})})]})]})}function bf(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 ep({text:t,percentage:e,total:n}){return e??(e=0),y.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:y.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${e}%`},children:[t," (",e.toFixed(2),"%",isNaN(n)?"":` of ${bf(n)}`,")"]})})}const vn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function tp(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 np(t){let e=new Uint8Array(256);for(let i=0;i>4,r[l++]=(o&15)<<4|u>>2,r[l++]=(u&3)<<6|c&63}return r}function rp(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=op(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 lp(t,e){return parseInt(t>0?t*e.newMax:t*e.newMin,10)}function sp(t,e){return t>0?t/e.oldMax:t/e.oldMin}function op(t,e){let n=function(r){return r};return t!=e&&(["32f","64"].includes(t)?n=lp:["32f","64"].includes(e)?n=sp:n=ip),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(zu(o,e)),n.push(zu(s,e))}return n}function hp(t){return t>32768?t-65536:t}function vs(t,e){let n=t-e.predicted,r=0;n>=0?r=0:(r=8,n=-n);let i=fo[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),fp(r,l,e),r}function fp(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+=id[t&7],n.index<0?n.index=0:n.index>88&&(n.index=88)}function zu(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),pp(t,e),e.predicted}function pp(t,e){e.index+=id[t],e.index<0?e.index=0:e.index>88&&(e.index=88),e.step=fo[e.index]}function mp(t,e){vs(t,e);let n=[];return n.push(t&255),n.push(t>>8&255),n.push(e.index),n.push(0),n}const gp=[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 vp(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=gp[t>>8&127],i=t>>r+3&15;e=r<<4|i}else e=t>>4;return e^(n^85)}function yp(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+wp,t>Nu&&(t=Nu),n=xp[t>>7&255],r=t>>n+3&15,i=~(e|n<<4|r),i}function Cp(t){let e,n,r,i;return t=~t,e=t&128,n=t>>4&7,r=t&15,i=Ip[n]+(r<=0&&u<=127)r+=String.fromCharCode(u);else{let c=0;u>=194&&u<=223?c=1:u>=224&&u<=239?(c=2,t[i]===224&&(l=160),t[i]===237&&(s=159)):u>=240&&u<=244?(c=3,t[i]===240&&(l=144),t[i]===244&&(s=143)):o=!0,u=u&(1<<8-c-1)-1;for(let m=0;ms)&&(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 sd(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 Mp{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=xl(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 c=e[u+n].toString(2);l+="00000000".substring(c.length)+c}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 p=this.ebits;p>0;p-=1)s[p]=i%2?1:0,i=Math.floor(i/2);let o=s.length;for(let p=this.fbits;p>0;p-=1)s[o+p]=l%2?1:0,l=Math.floor(l/2);let u=s.join(""),c=this.offset+n-1,m=n;for(;c>=n;)e[c]=parseInt(u.substring(0,8),2),u=u.substring(8),c--,m++;return m}}function xl(t){let e=Math.floor(t),n=t-e;return n<.5?e:n>.5||e%2?e+1:e}function Cn(t,e=0,n=t.length){return Lp(t,e,n)}function re(t){let e=[];return sd(t,e),e}function ju(t,e,n=0){return sd(t,e,n)}function od(t,e,n,r=0){e=e||{};let i=ud(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=Cn(e,this.head,this.head+this._PMX.chunkSize))}readZSTR_(e,n=0){for(let r=n;r16&&(e=e.concat(_(this.fmt.cbSize,this.uInt16))),this.fmt.chunkSize>18&&(e=e.concat(_(this.fmt.validBitsPerSample,this.uInt16))),this.fmt.chunkSize>20&&(e=e.concat(_(this.fmt.dwChannelMask,this.uInt32))),this.fmt.chunkSize>24&&(e=e.concat(_(this.fmt.subformat[0],this.uInt32),_(this.fmt.subformat[1],this.uInt32),_(this.fmt.subformat[2],this.uInt32),_(this.fmt.subformat[3],this.uInt32))),e}getLISTBytes_(){let e=[];for(let n=0;n-1){let r=Ve(e.value,e.value.length);n=n.concat(re(e.chunkId),_(r.length+4+1,this.uInt32),_(e.dwName,this.uInt32),r),n.push(0)}else e.chunkId=="ltxt"&&(n=n.concat(this.getLtxtChunkBytes_(e)));return n}getLtxtChunkBytes_(e){return[].concat(re(e.chunkId),_(e.value.length+20,this.uInt32),_(e.dwName,this.uInt32),_(e.dwSampleLength,this.uInt32),_(e.dwPurposeID,this.uInt32),_(e.dwCountry,this.uInt16),_(e.dwLanguage,this.uInt16),_(e.dwDialect,this.uInt16),_(e.dwCodePage,this.uInt16),Ve(e.value,e.value.length))}get_PMXBytes_(){let e=[];if(this._PMX.chunkId){let n=re(this._PMX.value);this._PMX.chunkSize=n.length,e=e.concat(re(this._PMX.chunkId),_(this._PMX.chunkSize,this.uInt32),n)}return this.enforceByteLen_(e),e}getJunkBytes_(){let e=[];return this.junk.chunkId?e.concat(re(this.junk.chunkId),_(this.junk.chunkData.length,this.uInt32),this.junk.chunkData):(this.enforceByteLen_(e),e)}enforceByteLen_(e){e.length%2&&e.push(0)}}function jp(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 ad(t,e,n){let r=t*(e/8)*n;return!(n<1||r>4294967295)}class Ap extends Rp{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?Dp(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 Mi(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");po(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=jp(i),this.updateDataType_();let s=this.dataType.bits/8;this.data.samples=new Uint8Array(i.length*s),od(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=Up(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_(),!Op(this.fmt.numChannels,this.fmt.bitsPerSample))throw new Error("Invalid number of channels.");if(!ad(this.fmt.numChannels,this.fmt.bitsPerSample,this.fmt.sampleRate))throw new Error("Invalid sample rate.")}}function Up(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 Bp extends Ap{getTag(e){let n=this.getTagIndex_(e);return n.TAG!==null?this.LIST[n.LIST].subChunks[n.TAG].value:null}setTag(e,n){e=$p(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||Au[r.LPFType],n,e/2);Zp(t,l,s,u)}else{let u=new o(r.LPForder||Au[r.LPFType],e,n/2);Jp(t,l,s,u)}}else cd(t,l,s);return l}function cd(t,e,n){for(let r=0,i=e.length;r=0;i--)e[i]=r.filter(e[i])}function Jp(t,e,n,r){for(let i=0,l=t.length;i=0;i--)t[i]=r.filter(t[i]);cd(t,e,n)}class qp extends Ou{toRIFF(){let e=new Float64Array(Xn(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(Xn(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(Xn(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",up(e),{container:this.correctContainer_()})}}fromIMAADPCM(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",ap(this.data.samples,this.fmt.blockAlign),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toALaw(){this.assure16Bit_();let e=new Int16Array(Xn(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",Sp(e),{container:this.correctContainer_()})}fromALaw(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",kp(this.data.samples),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toMuLaw(){this.assure16Bit_();let e=new Int16Array(Xn(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",Ep(e),{container:this.correctContainer_()})}fromMuLaw(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",Tp(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);rp(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 Ou;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 Xn(t,e){let n=t/e;return n%2&&n++,n}class Bu extends qp{constructor(e){super(),e&&this.fromBuffer(e)}fromBase64(e){this.fromBuffer(np(e))}toBase64(){return tp(this.toBuffer())}toDataURI(){return"data:audio/wav;base64,"+this.toBase64()}fromDataURI(e){this.fromBase64(e.replace("data:audio/wav;base64,",""))}}function bp({segments:t,worker:e,language:n}){const r=async o=>{if(!o.audioData||o.audioData.length===0){console.error("Invalid segment audio data");return}console.log("Playing segment:",{start:o.startTime.toFixed(2),end:o.endTime.toFixed(2),duration:o.duration.toFixed(2),samples:o.audioData.length,sampleRate:o.sampleRate});try{const u=new Bu;u.fromScratch(1,o.sampleRate,"32f",o.audioData),u.toBitDepth("16");const c=u.toBuffer(),m=new AudioContext,p=await m.decodeAudioData(c.buffer),f=m.createBufferSource();f.buffer=p,f.connect(m.destination),f.start()}catch(u){console.error("Error playing segment:",u)}},i=(o,u)=>{try{const c=new Bu;c.fromScratch(1,o.sampleRate,"32f",o.audioData),c.toBitDepth("16");const m=c.toBuffer(),p=new Blob([m],{type:"audio/wav"}),f=URL.createObjectURL(p),v=document.createElement("a");v.href=f,v.download=`segment_${u}_${o.startTime.toFixed(2)}-${o.endTime.toFixed(2)}.wav`,document.body.appendChild(v),v.click(),document.body.removeChild(v),URL.revokeObjectURL(f)}catch(c){console.error("Error downloading segment:",c)}},l=C.useCallback(o=>{e&&e.postMessage({type:"transcribe",data:{audioData:o.audioData,segmentId:o.id,language:n,isMerged:o.isMerged}})},[e,n]),s=({segment:o,index:u})=>{const c=`${(o.endTime-o.startTime)*100}%`,m=`${o.startTime*100}%`,p=o.isMerged?"bg-purple-500 opacity-60":o.isProcessed?"bg-blue-500 opacity-40":"bg-gray-500 opacity-40";return y.jsxs("div",{className:`absolute h-full ${p} rounded-md transition-all duration-200`,style:{left:m,width:c,zIndex:o.isMerged?2:1},title:`${o.isMerged?"Merged: ":""}${o.startTime.toFixed(2)}s - ${o.endTime.toFixed(2)}s`,children:[o.isMerged&&y.jsxs("div",{className:"absolute -top-5 left-0 text-xs text-purple-600 font-bold",children:["Merged (",o.mergedCount,")"]}),o.transcription&&y.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 o.transcription=="string"?o.transcription:o.transcription.text||o.transcription.toString()})]})};return y.jsxs("div",{className:"mt-4 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg",children:[y.jsxs("h3",{className:"font-semibold mb-2",children:["Detected Speech Segments (",t.length,")"]}),y.jsx("div",{className:"relative h-16 mb-8 bg-gray-200 dark:bg-gray-700 rounded",children:t.map((o,u)=>y.jsx(s,{segment:o,index:u},o.isMerged?o.id:u))}),y.jsx("div",{className:"space-y-2",children:t.map((o,u)=>y.jsxs("div",{className:`flex flex-col p-2 rounded ${o.isMerged?"bg-purple-100 dark:bg-purple-900":"bg-white dark:bg-gray-700"}`,children:[y.jsxs("div",{className:"flex items-center space-x-4",children:[y.jsxs("span",{className:"text-sm",children:[o.isMerged?"🔄 ":"",`Segment ${u+1}: ${o.startTime.toFixed(2)}s - ${o.endTime.toFixed(2)}s (${(o.endTime-o.startTime).toFixed(2)}s)`]}),y.jsx("button",{onClick:()=>r(o),className:"px-2 py-1 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Play"}),y.jsx("button",{onClick:()=>i(o,u+1),className:"px-2 py-1 bg-green-500 text-white rounded hover:bg-green-600",children:"Download"}),y.jsx("button",{onClick:()=>l(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&&y.jsx("div",{className:"mt-2 ml-4 text-sm",children:typeof o.transcription=="string"?o.transcription:o.transcription.text||o.transcription.toString()})]},o.isMerged?o.id:u))})]})}function em(t){return t=t.toLowerCase(),(t.match(/\w+.?/g)||[]).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}const $u={en:"english",zh:"chinese",de:"german",es:"spanish/castilian",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",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 tm({language:t,setLanguage:e,disabled:n}){return y.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($u).map((r,i)=>y.jsx("option",{value:r,children:Object.values($u).map(em)[i]},r))})}const dd={"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 nm({model:t,setModel:e}){return y.jsx("select",{className:"border rounded-lg p-2 mr-2",value:t,onChange:n=>e(n.target.value),children:Object.entries(dd).map(([n,r])=>y.jsx("option",{value:r,children:n},r))})}const $t=16e3,rm=30,Hu=$t*rm,im=100,Wu=2*im;function lm(){const t=C.useRef(null),e=C.useRef(null),n=C.useRef(null),r=C.useRef(null),i=C.useRef(null);C.useRef(null);const l=C.useRef(null),s=C.useRef(null);C.useRef(0),C.useRef(0),C.useRef(null);const o=C.useRef([]),[u,c]=C.useState("initialized"),[m,p]=C.useState(""),[f,v]=C.useState([]),[S,k]=C.useState(!1),[F,d]=C.useState(!1),[a,h]=C.useState(.125),[g,x]=C.useState(.6),[I,E]=C.useState(.2),[P,B]=C.useState(2),[N,ge]=C.useState(1.2),[$,rt]=C.useState(.3),[mt,Tr]=C.useState(.3),[Dt,Pr]=C.useState(.4),[T,R]=C.useState(.6),[z,W]=C.useState([]),[K,tn]=C.useState(null),[Ie,Ot]=C.useState([]);C.useState("");const[Je,nn]=C.useState(null),[Lr,go]=C.useState("tr"),[vo,Ki]=C.useState(""),[yo,hd]=C.useState([]),[Gi,fd]=C.useState(25),[Yi,pd]=C.useState(Object.values(dd)[0]);C.useEffect(()=>(console.log("Initializing AudioManager"),te.initialize({sampleRate:$t,onSegmentDetected:M=>{Ot(j=>[...j,M])}}).catch(M=>{console.error("Failed to initialize AudioManager:",M)}),te.updateParameters({threshold:a,silenceLength:g,speechHangover:I,energyScale:P,hysteresisRatio:N,minSpeechDuration:$}),()=>{te.reset()}),[]);const md=async()=>{try{await te.startAudioContext();const M=await navigator.mediaDevices.getUserMedia({audio:!0});tn(M),await te.audioContext.audioWorklet.addModule("src/audio-processor.js");const j=te.audioContext.createMediaStreamSource(M),b=new AudioWorkletNode(te.audioContext,"audio-processor",{numberOfInputs:1,numberOfOutputs:1,processorOptions:{sampleRate:$t}});b.port.onmessage=D=>{if(D.data.type==="audio_data"){const ve=D.data.audioData,G=D.data.energy;W(se=>[...se,ve]),te.processNewChunk(ve,G)}},j.connect(b),b.connect(te.audioContext.destination),d(!0),n.current=te.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})}};C.useEffect(()=>{if(F){console.log("Setting up process interval");let M=0;const j=setInterval(async()=>{const b=Date.now();if(b-M=0&&se>0;He--){const ye=D[He];if(!(ye instanceof Float32Array))continue;const At=Math.min(se,ye.length),Dn=ye.length-At;G.set(ye.slice(Dn,Dn+At),se-At),se-=At}Math.max(...Array.from(G.slice(0,1e3)).map(Math.abs))>.1&&await te.processNewChunk(G),M=b}catch(ve){console.error("Error in process interval:",ve)}},Wu);return()=>clearInterval(j)}},[F]),C.useEffect(()=>{if(!t.current){t.current=new Worker(new URL("/assets/worker-79PJ2Jf5.js",import.meta.url),{type:"module"}),te.setWorker(t.current);const M=j=>{switch(j.data.status){case"loading":c("loading"),p(j.data.data);break;case"initiate":v(G=>[...G,j.data]);break;case"progress":v(G=>G.map(se=>se.file===j.data.file?{...se,...j.data}:se));break;case"done":v(G=>G.filter(se=>se.file!==j.data.file));break;case"ready":c("ready");break;case"start":k(!0);break;case"update":nn(j.data.tps);break;case"complete":k(!1);const b=j.data.output,D=j.data.segmentId,ve=j.data.segmentId.startsWith("merged_");hd(G=>{var He,ye,At,Dn;const se={id:D,text:b,timestamp:Date.now(),isMerged:ve,containedSegments:ve?(ye=(He=te.segments.find(it=>it.id===D))==null?void 0:He.originalSegments)==null?void 0:ye.map(it=>it.id):[],isPartOfMerged:!ve&&((At=te.segments.find(it=>it.id===D))==null?void 0:At.isPartOfMerged),mergedId:ve?null:(Dn=te.segments.find(it=>it.id===D))==null?void 0:Dn.mergedId};return[...G.filter(it=>{var So;return!((So=se.containedSegments)!=null&&So.includes(it.id))}),se]}),te.handleTranscriptionResult({segmentId:D,output:b,isMerged:ve});break}};return t.current.addEventListener("message",M),()=>{t.current.removeEventListener("message",M),t.current.terminate(),t.current=null}}},[]);const je=C.useCallback((M,j="info")=>{j==="error"?console.error(M):console.log(M)},[]);C.useEffect(()=>{i.current=je},[je]),C.useEffect(()=>{if(!r.current){console.log("Creating AudioSegmentProcessor...");const M=(j,b)=>{var D;console.log("AudioProcessor:",j,b),(D=i.current)==null||D.call(i,j,"info")};r.current=new rd({logger:M,sampleRate:$t,energyThreshold:a,minSpeechDuration:.1,windowSize:256,minSilenceBetween:g,speechHangover:I}),r.current.log("Test message from initialization",{test:"value"}),je("AudioSegmentProcessor initialized",{threshold:a,silenceLength:g,hangover:I})}},[]),C.useEffect(()=>{r.current&&(r.current.options.energyThreshold=a,r.current.options.minSilenceBetween=g,r.current.options.speechHangover=I,je("Updated processor settings",{threshold:a,silenceLength:g,hangover:I}))},[a,g,I]);const gd=C.useCallback(()=>{var M;je("Reset requested"),e.current&&(e.current.state==="recording"&&e.current.stop(),(M=l.current)==null||M.reset(),setTimeout(()=>{if(u==="ready"&&e.current)try{e.current.start(),je("Started new recording after reset")}catch(j){je("Failed to start after reset: "+j.message,"error")}},100))},[u]);C.useEffect(()=>{if(u==="ready"&&F){je("Starting periodic buffer processing");let M=!0,j=0;const b=setInterval(()=>{if(!(!r.current||!s.current||!M))try{const D=s.current;if(D.length===j)return;const ve=15*$t;let G=0;if(Ie.length>0){const Mr=Ie[Ie.length-1];G=Math.floor(Mr.endTime*$t)}const se=D.slice(Math.max(D.length-ve,G),D.length);if(se.length>0){const He=r.current.processAudioData(se,G/$t).map(ye=>new nd(ye));He.length>0&&(je("Created speech segments",{count:He.length,segments:He.map(ye=>({start:ye.startTime.toFixed(2),end:ye.endTime.toFixed(2),duration:ye.getDuration().toFixed(2)}))}),Ot(ye=>[...ye,...He]))}j=D.length}catch(D){je("Error processing buffer: "+D.message,"error"),console.error("Processing error:",D)}},500);return()=>{M=!1,clearInterval(b)}}},[u,F,Ie]),C.useEffect(()=>{e.current&&(e.current.ondataavailable=M=>{M.data.size>0&&W(j=>[...j,M.data])})},[]),C.useEffect(()=>{r.current&&(r.current.options.maxSilenceWithinSpeech=mt,je("Updated max silence within speech",{value:mt}))},[mt]),C.useEffect(()=>{r.current&&(r.current.options.endingSpeechTolerance=Dt,r.current.options.endingEnergyThreshold=T,je("Updated ending speech parameters",{tolerance:Dt,threshold:T}))},[Dt,T]),C.useEffect(()=>{r.current&&(r.current.options={...r.current.options,energyThreshold:a,minSilenceBetween:g,speechHangover:I,energyScale:P,hysteresisRatio:N,minSpeechDuration:$})},[a,g,I,P,N,$]),C.useEffect(()=>{const M=te.subscribe((j,b)=>{switch(j){case"segmentsUpdated":Ot(b.map(D=>({...D,startTime:D.startTime,endTime:D.endTime,isMerged:D.isMerged||!1,isPartOfMerged:D.isPartOfMerged||!1,isProcessed:D.isProcessed||!1,mergedId:D.mergedId,energy:D.energy})));break}});return()=>M()},[]),C.useEffect(()=>()=>{n.current&&n.current.close(),K&&K.getTracks().forEach(M=>M.stop())},[K]),C.useEffect(()=>{const M=yo.filter(j=>j.isMerged||!j.isPartOfMerged).map(j=>j.text);Ki(M.join(` +`))},[yo]),C.useEffect(()=>{te.updateParameters({minEnergyIntegral:Gi})},[Gi]),C.useEffect(()=>{var M;if(e.current&&F&&!S&&u==="ready")if(z.length>0){const j=new Blob(z,{type:e.current.mimeType}),b=new FileReader;b.onloadend=async()=>{const D=b.result;let G=(await n.current.decodeAudioData(D)).getChannelData(0);G.length>Hu&&(G=G.slice(-Hu)),t.current.postMessage({type:"transcribe",data:{audioData:G,language:Lr,segmentId:Date.now().toString()}})},b.readAsArrayBuffer(j)}else(M=e.current)==null||M.requestData()},[u,F,S,z,Lr]);const vd=M=>{var j;go(M),te.updateLanguage(M),W([]),F&&((j=e.current)==null?void 0:j.state)==="recording"&&e.current.requestData()},yd=M=>{pd(M),M.endsWith(".en")&&go("en")};return y.jsx("div",{className:"flex flex-col h-screen w-screen mx-auto justify-start text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:y.jsxs("div",{className:"h-full w-full overflow-auto scrollbar-thin flex justify-start items-center flex-col relative pt-2",children:[y.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[300px] text-center",children:[y.jsx("img",{src:"logo.png",width:"10%",height:"auto",className:"block"}),y.jsx("h1",{className:"text-xl font-bold mb-1",children:"Whisper WebGPU"}),y.jsx("h2",{className:"text-base font-semibold",children:"Real-time in-browser speech recognition"})]}),y.jsxs("div",{className:"flex gap-4 mb-4 items-center",children:[!F&&y.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500",onClick:md,children:"Start Audio Capture"}),u==="initialized"&&y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(nm,{model:Yi,setModel:yd}),y.jsx(tm,{language:Lr,setLanguage:vd,disabled:Yi.endsWith(".en")}),y.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500",onClick:()=>{var M;(M=t.current)==null||M.postMessage({type:"load",data:{modelId:Yi}}),c("loading")},children:"Load Model"})]})]}),y.jsx("div",{className:"flex flex-col items-center w-full px-4",children:y.jsxs("div",{className:"w-full max-w-[90vw] p-1",children:[y.jsx(qf,{className:"w-full rounded-lg",stream:K,threshold:a,onThresholdChange:h,silenceLength:g,onSilenceLengthChange:x,speechHangover:I,onHangoverChange:E,chunks:z,audioContextRef:n,segments:Ie,energyScale:P,onEnergyScaleChange:B,hysteresisRatio:N,onHysteresisChange:ge,minSpeechDuration:$,onMinSpeechDurationChange:rt,processor:te.processor,minEnergyIntegral:Gi,onMinEnergyIntegralChange:fd}),u==="loading"&&y.jsxs("div",{className:"w-full max-w-[500px] text-left mx-auto p-4",children:[y.jsx("p",{className:"text-center",children:m}),f.map(({file:M,progress:j,total:b},D)=>y.jsx(ep,{text:M,percentage:j,total:b},D))]}),u==="ready"&&y.jsxs("div",{className:"relative w-full max-w-[90vw]",children:[y.jsx("textarea",{value:vo,onChange:M=>Ki(M.target.value),className:`w-full h-[240px] overflow-y-auto font-mono text-sm \r + border rounded-lg p-2 bg-white dark:bg-gray-800 \r + focus:ring-2 focus:ring-blue-500 focus:border-blue-500`,placeholder:"Transcriptions will appear here. You can edit the text..."}),y.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-2",children:[Je&&y.jsxs("span",{className:"px-2 py-1 bg-gray-100 dark:bg-gray-700 rounded text-sm",children:[Je.toFixed(2)," tok/s"]}),y.jsx("button",{onClick:()=>Ki(""),className:"px-2 py-1 text-sm bg-red-500 text-white rounded hover:bg-red-600",children:"Clear"}),y.jsx("button",{onClick:()=>{navigator.clipboard.writeText(vo)},className:"px-2 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Copy"}),y.jsx("button",{className:"px-2 py-1 text-sm bg-gray-500 text-white rounded hover:bg-gray-600",onClick:gd,children:"Reset"})]})]})]})}),y.jsx("div",{className:"w-full max-w-[90vw] p-2 mt-auto",children:y.jsx(bp,{segments:Ie,worker:t.current,language:Lr})})]})})}Il.createRoot(document.getElementById("root")).render(y.jsx(Od.StrictMode,{children:y.jsx(lm,{})}));