diff --git a/assets/index-e5ae303f.js b/assets/index-e5ae303f.js new file mode 100644 index 0000000000000000000000000000000000000000..fdaa4f172c559b6b6acc549f3f0740d85e895555 --- /dev/null +++ b/assets/index-e5ae303f.js @@ -0,0 +1,47 @@ +var op=Object.defineProperty;var ip=(e,t,n)=>t in e?op(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qn=(e,t,n)=>(ip(e,typeof t!="symbol"?t+"":t,n),n);function lp(e,t){for(var n=0;nr[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function up(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ic={exports:{}},ui={},lc={exports:{}},D={};/** + * @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 zr=Symbol.for("react.element"),sp=Symbol.for("react.portal"),ap=Symbol.for("react.fragment"),cp=Symbol.for("react.strict_mode"),dp=Symbol.for("react.profiler"),fp=Symbol.for("react.provider"),pp=Symbol.for("react.context"),mp=Symbol.for("react.forward_ref"),hp=Symbol.for("react.suspense"),yp=Symbol.for("react.memo"),gp=Symbol.for("react.lazy"),Os=Symbol.iterator;function vp(e){return e===null||typeof e!="object"?null:(e=Os&&e[Os]||e["@@iterator"],typeof e=="function"?e:null)}var uc={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},sc=Object.assign,ac={};function Hn(e,t,n){this.props=e,this.context=t,this.refs=ac,this.updater=n||uc}Hn.prototype.isReactComponent={};Hn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};Hn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function cc(){}cc.prototype=Hn.prototype;function Tu(e,t,n){this.props=e,this.context=t,this.refs=ac,this.updater=n||uc}var Nu=Tu.prototype=new cc;Nu.constructor=Tu;sc(Nu,Hn.prototype);Nu.isPureReactComponent=!0;var Fs=Array.isArray,dc=Object.prototype.hasOwnProperty,Pu={current:null},fc={key:!0,ref:!0,__self:!0,__source:!0};function pc(e,t,n){var r,o={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)dc.call(t,r)&&!fc.hasOwnProperty(r)&&(o[r]=t[r]);var u=arguments.length-2;if(u===1)o.children=n;else if(1>>1,ee=R[B];if(0>>1;Bo(Q,F))teo(G,Q)?(R[B]=G,R[te]=F,B=te):(R[B]=Q,R[at]=F,B=at);else if(teo(G,F))R[B]=G,R[te]=F,B=te;else break e}}return O}function o(R,O){var F=R.sortIndex-O.sortIndex;return F!==0?F:R.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var s=[],a=[],d=1,p=null,m=3,v=!1,h=!1,g=!1,T=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(R){for(var O=n(a);O!==null;){if(O.callback===null)r(a);else if(O.startTime<=R)r(a),O.sortIndex=O.expirationTime,t(s,O);else break;O=n(a)}}function k(R){if(g=!1,y(R),!h)if(n(s)!==null)h=!0,st(N);else{var O=n(a);O!==null&&Kt(k,O.startTime-R)}}function N(R,O){h=!1,g&&(g=!1,f(L),L=-1),v=!0;var F=m;try{for(y(O),p=n(s);p!==null&&(!(p.expirationTime>O)||R&&!j());){var B=p.callback;if(typeof B=="function"){p.callback=null,m=p.priorityLevel;var ee=B(p.expirationTime<=O);O=e.unstable_now(),typeof ee=="function"?p.callback=ee:p===n(s)&&r(s),y(O)}else r(s);p=n(s)}if(p!==null)var Gt=!0;else{var at=n(a);at!==null&&Kt(k,at.startTime-O),Gt=!1}return Gt}finally{p=null,m=F,v=!1}}var P=!1,x=null,L=-1,A=5,U=-1;function j(){return!(e.unstable_now()-UR||125B?(R.sortIndex=F,t(a,R),n(s)===null&&R===n(a)&&(g?(f(L),L=-1):g=!0,Kt(k,F-B))):(R.sortIndex=ee,t(s,R),h||v||(h=!0,st(N))),R},e.unstable_shouldYield=j,e.unstable_wrapCallback=function(R){var O=m;return function(){var F=m;m=O;try{return R.apply(this,arguments)}finally{m=F}}}})(gc);yc.exports=gc;var Lp=yc.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 vc=w,_e=Lp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),El=Object.prototype.hasOwnProperty,_p=/^[: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]*$/,As={},Ms={};function Up(e){return El.call(Ms,e)?!0:El.call(As,e)?!1:_p.test(e)?Ms[e]=!0:(As[e]=!0,!1)}function Op(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Fp(e,t,n,r){if(t===null||typeof t>"u"||Op(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Se(e,t,n,r,o,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var de={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){de[e]=new Se(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];de[t]=new Se(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){de[e]=new Se(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){de[e]=new Se(e,2,!1,e,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(e){de[e]=new Se(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){de[e]=new Se(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){de[e]=new Se(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){de[e]=new Se(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){de[e]=new Se(e,5,!1,e.toLowerCase(),null,!1,!1)});var _u=/[\-:]([a-z])/g;function Uu(e){return e[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(e){var t=e.replace(_u,Uu);de[t]=new Se(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(_u,Uu);de[t]=new Se(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(_u,Uu);de[t]=new Se(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){de[e]=new Se(e,1,!1,e.toLowerCase(),null,!1,!1)});de.xlinkHref=new Se("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){de[e]=new Se(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ou(e,t,n,r){var o=de.hasOwnProperty(t)?de[t]:null;(o!==null?o.type!==0:r||!(2u||o[l]!==i[u]){var s=` +`+o[l].replace(" at new "," at ");return e.displayName&&s.includes("")&&(s=s.replace("",e.displayName)),s}while(1<=l&&0<=u);break}}}finally{Mi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ur(e):""}function Dp(e){switch(e.tag){case 5:return ur(e.type);case 16:return ur("Lazy");case 13:return ur("Suspense");case 19:return ur("SuspenseList");case 0:case 2:case 15:return e=$i(e.type,!1),e;case 11:return e=$i(e.type.render,!1),e;case 1:return e=$i(e.type,!0),e;default:return""}}function Nl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case gn:return"Fragment";case yn:return"Portal";case Cl:return"Profiler";case Fu:return"StrictMode";case xl:return"Suspense";case Tl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case kc:return(e.displayName||"Context")+".Consumer";case Sc:return(e._context.displayName||"Context")+".Provider";case Du:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Au:return t=e.displayName||null,t!==null?t:Nl(e.type)||"Memo";case Pt:t=e._payload,e=e._init;try{return Nl(e(t))}catch{}}return null}function Ap(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Nl(t);case 8:return t===Fu?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Ht(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Cc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Mp(e){var t=Cc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Jr(e){e._valueTracker||(e._valueTracker=Mp(e))}function xc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Cc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Oo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Pl(e,t){var n=t.checked;return Y({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Is(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ht(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Tc(e,t){t=t.checked,t!=null&&Ou(e,"checked",t,!1)}function Rl(e,t){Tc(e,t);var n=Ht(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ll(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ll(e,t.type,Ht(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function zs(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ll(e,t,n){(t!=="number"||Oo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var sr=Array.isArray;function Rn(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=Zr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Er(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var fr={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},$p=["Webkit","ms","Moz","O"];Object.keys(fr).forEach(function(e){$p.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),fr[t]=fr[e]})});function Lc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||fr.hasOwnProperty(e)&&fr[e]?(""+t).trim():t+"px"}function _c(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=Lc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var Ip=Y({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 Ol(e,t){if(t){if(Ip[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 Mu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Al=null,Ln=null,_n=null;function Hs(e){if(e=Hr(e)){if(typeof Al!="function")throw Error(E(280));var t=e.stateNode;t&&(t=fi(t),Al(e.stateNode,e.type,t))}}function Uc(e){Ln?_n?_n.push(e):_n=[e]:Ln=e}function Oc(){if(Ln){var e=Ln,t=_n;if(_n=Ln=null,Hs(e),t)for(e=0;e>>=0,e===0?32:31-(qp(e)/Xp|0)|0}var eo=64,to=4194304;function ar(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var u=l&~o;u!==0?r=ar(u):(i&=l,i!==0&&(r=ar(i)))}else l=n&~o,l!==0?r=ar(l):i!==0&&(r=ar(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Br(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ge(t),e[t]=n}function em(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=mr),Ys=String.fromCharCode(32),Js=!1;function Jc(e,t){switch(e){case"keyup":return Rm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vn=!1;function _m(e,t){switch(e){case"compositionend":return Zc(t);case"keypress":return t.which!==32?null:(Js=!0,Ys);case"textInput":return e=t.data,e===Ys&&Js?null:e;default:return null}}function Um(e,t){if(vn)return e==="compositionend"||!bu&&Jc(e,t)?(e=Xc(),vo=ju=Ot=null,vn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=na(n)}}function rd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?rd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function od(){for(var e=window,t=Oo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Oo(e.document)}return t}function Wu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Bm(e){var t=od(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&rd(n.ownerDocument.documentElement,n)){if(r!==null&&Wu(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=ra(n,i);var l=ra(n,r);o&&l&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,wn=null,jl=null,yr=null,Hl=!1;function oa(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hl||wn==null||wn!==Oo(r)||(r=wn,"selectionStart"in r&&Wu(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}),yr&&Rr(yr,r)||(yr=r,r=zo(jl,"onSelect"),0En||(e.current=Gl[En],Gl[En]=null,En--)}function V(e,t){En++,Gl[En]=e.current,e.current=t}var Vt={},ye=Wt(Vt),Ce=Wt(!1),un=Vt;function An(e,t){var n=e.type.contextTypes;if(!n)return Vt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function xe(e){return e=e.childContextTypes,e!=null}function jo(){W(Ce),W(ye)}function da(e,t,n){if(ye.current!==Vt)throw Error(E(168));V(ye,t),V(Ce,n)}function pd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(E(108,Ap(e)||"Unknown",o));return Y({},n,r)}function Ho(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Vt,un=ye.current,V(ye,e),V(Ce,Ce.current),!0}function fa(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=pd(e,t,un),r.__reactInternalMemoizedMergedChildContext=e,W(Ce),W(ye),V(ye,e)):W(Ce),V(Ce,n)}var dt=null,pi=!1,Yi=!1;function md(e){dt===null?dt=[e]:dt.push(e)}function Jm(e){pi=!0,md(e)}function Qt(){if(!Yi&&dt!==null){Yi=!0;var e=0,t=H;try{var n=dt;for(H=1;e>=l,o-=l,pt=1<<32-Ge(t)+o|n<L?(A=x,x=null):A=x.sibling;var U=m(f,x,y[L],k);if(U===null){x===null&&(x=A);break}e&&x&&U.alternate===null&&t(f,x),c=i(U,c,L),P===null?N=U:P.sibling=U,P=U,x=A}if(L===y.length)return n(f,x),K&&Xt(f,L),N;if(x===null){for(;LL?(A=x,x=null):A=x.sibling;var j=m(f,x,U.value,k);if(j===null){x===null&&(x=A);break}e&&x&&j.alternate===null&&t(f,x),c=i(j,c,L),P===null?N=j:P.sibling=j,P=j,x=A}if(U.done)return n(f,x),K&&Xt(f,L),N;if(x===null){for(;!U.done;L++,U=y.next())U=p(f,U.value,k),U!==null&&(c=i(U,c,L),P===null?N=U:P.sibling=U,P=U);return K&&Xt(f,L),N}for(x=r(f,x);!U.done;L++,U=y.next())U=v(x,f,L,U.value,k),U!==null&&(e&&U.alternate!==null&&x.delete(U.key===null?L:U.key),c=i(U,c,L),P===null?N=U:P.sibling=U,P=U);return e&&x.forEach(function(He){return t(f,He)}),K&&Xt(f,L),N}function T(f,c,y,k){if(typeof y=="object"&&y!==null&&y.type===gn&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Yr:e:{for(var N=y.key,P=c;P!==null;){if(P.key===N){if(N=y.type,N===gn){if(P.tag===7){n(f,P.sibling),c=o(P,y.props.children),c.return=f,f=c;break e}}else if(P.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Pt&&wa(N)===P.type){n(f,P.sibling),c=o(P,y.props),c.ref=tr(f,P,y),c.return=f,f=c;break e}n(f,P);break}else t(f,P);P=P.sibling}y.type===gn?(c=on(y.props.children,f.mode,k,y.key),c.return=f,f=c):(k=No(y.type,y.key,y.props,null,f.mode,k),k.ref=tr(f,c,y),k.return=f,f=k)}return l(f);case yn:e:{for(P=y.key;c!==null;){if(c.key===P)if(c.tag===4&&c.stateNode.containerInfo===y.containerInfo&&c.stateNode.implementation===y.implementation){n(f,c.sibling),c=o(c,y.children||[]),c.return=f,f=c;break e}else{n(f,c);break}else t(f,c);c=c.sibling}c=il(y,f.mode,k),c.return=f,f=c}return l(f);case Pt:return P=y._init,T(f,c,P(y._payload),k)}if(sr(y))return h(f,c,y,k);if(Xn(y))return g(f,c,y,k);so(f,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,c!==null&&c.tag===6?(n(f,c.sibling),c=o(c,y),c.return=f,f=c):(n(f,c),c=ol(y,f.mode,k),c.return=f,f=c),l(f)):n(f,c)}return T}var $n=Ed(!0),Cd=Ed(!1),Vr={},ot=Wt(Vr),Or=Wt(Vr),Fr=Wt(Vr);function tn(e){if(e===Vr)throw Error(E(174));return e}function es(e,t){switch(V(Fr,t),V(Or,e),V(ot,Vr),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ul(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ul(t,e)}W(ot),V(ot,t)}function In(){W(ot),W(Or),W(Fr)}function xd(e){tn(Fr.current);var t=tn(ot.current),n=Ul(t,e.type);t!==n&&(V(Or,e),V(ot,n))}function ts(e){Or.current===e&&(W(ot),W(Or))}var q=Wt(0);function Go(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ji=[];function ns(){for(var e=0;en?n:4,e(!0);var r=Zi.transition;Zi.transition={};try{e(!1),t()}finally{H=n,Zi.transition=r}}function Bd(){return Be().memoizedState}function nh(e,t,n){var r=Bt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},jd(e))Hd(t,n);else if(n=vd(e,t,n,r),n!==null){var o=ve();qe(n,e,r,o),Vd(n,t,r)}}function rh(e,t,n){var r=Bt(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(jd(e))Hd(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,u=i(l,n);if(o.hasEagerState=!0,o.eagerState=u,Xe(u,l)){var s=t.interleaved;s===null?(o.next=o,Ju(t)):(o.next=s.next,s.next=o),t.interleaved=o;return}}catch{}finally{}n=vd(e,t,o,r),n!==null&&(o=ve(),qe(n,e,r,o),Vd(n,t,r))}}function jd(e){var t=e.alternate;return e===X||t!==null&&t===X}function Hd(e,t){gr=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Vd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Iu(e,n)}}var Xo={readContext:ze,useCallback:fe,useContext:fe,useEffect:fe,useImperativeHandle:fe,useInsertionEffect:fe,useLayoutEffect:fe,useMemo:fe,useReducer:fe,useRef:fe,useState:fe,useDebugValue:fe,useDeferredValue:fe,useTransition:fe,useMutableSource:fe,useSyncExternalStore:fe,useId:fe,unstable_isNewReconciler:!1},oh={readContext:ze,useCallback:function(e,t){return Ze().memoizedState=[e,t===void 0?null:t],e},useContext:ze,useEffect:ka,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Eo(4194308,4,Ad.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Eo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Eo(4,2,e,t)},useMemo:function(e,t){var n=Ze();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ze();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=nh.bind(null,X,e),[r.memoizedState,e]},useRef:function(e){var t=Ze();return e={current:e},t.memoizedState=e},useState:Sa,useDebugValue:us,useDeferredValue:function(e){return Ze().memoizedState=e},useTransition:function(){var e=Sa(!1),t=e[0];return e=th.bind(null,e[1]),Ze().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=X,o=Ze();if(K){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),se===null)throw Error(E(349));an&30||Pd(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,ka(Ld.bind(null,r,i,e),[e]),r.flags|=2048,Mr(9,Rd.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ze(),t=se.identifierPrefix;if(K){var n=mt,r=pt;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Dr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[et]=t,e[Ur]=r,Jd(e,t,!1,!1),t.stateNode=e;e:{switch(l=Fl(n,r),n){case"dialog":b("cancel",e),b("close",e),o=r;break;case"iframe":case"object":case"embed":b("load",e),o=r;break;case"video":case"audio":for(o=0;oBn&&(t.flags|=128,r=!0,nr(i,!1),t.lanes=4194304)}else{if(!r)if(e=Go(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),nr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!K)return pe(t),null}else 2*Z()-i.renderingStartTime>Bn&&n!==1073741824&&(t.flags|=128,r=!0,nr(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Z(),t.sibling=null,n=q.current,V(q,r?n&1|2:n&1),t):(pe(t),null);case 22:case 23:return ps(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ne&1073741824&&(pe(t),t.subtreeFlags&6&&(t.flags|=8192)):pe(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function fh(e,t){switch(Ku(t),t.tag){case 1:return xe(t.type)&&jo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return In(),W(Ce),W(ye),ns(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return ts(t),null;case 13:if(W(q),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Mn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return W(q),null;case 4:return In(),null;case 10:return Yu(t.type._context),null;case 22:case 23:return ps(),null;case 24:return null;default:return null}}var co=!1,me=!1,ph=typeof WeakSet=="function"?WeakSet:Set,_=null;function Nn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){J(e,t,r)}else n.current=null}function lu(e,t,n){try{n()}catch(r){J(e,t,r)}}var _a=!1;function mh(e,t){if(Vl=$o,e=od(),Wu(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,u=-1,s=-1,a=0,d=0,p=e,m=null;t:for(;;){for(var v;p!==n||o!==0&&p.nodeType!==3||(u=l+o),p!==i||r!==0&&p.nodeType!==3||(s=l+r),p.nodeType===3&&(l+=p.nodeValue.length),(v=p.firstChild)!==null;)m=p,p=v;for(;;){if(p===e)break t;if(m===n&&++a===o&&(u=l),m===i&&++d===r&&(s=l),(v=p.nextSibling)!==null)break;p=m,m=p.parentNode}p=v}n=u===-1||s===-1?null:{start:u,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(bl={focusedElem:e,selectionRange:n},$o=!1,_=t;_!==null;)if(t=_,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,_=e;else for(;_!==null;){t=_;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,T=h.memoizedState,f=t.stateNode,c=f.getSnapshotBeforeUpdate(t.elementType===t.type?g:We(t.type,g),T);f.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(k){J(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,_=e;break}_=t.return}return h=_a,_a=!1,h}function vr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&lu(t,n,i)}o=o.next}while(o!==r)}}function yi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function uu(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function tf(e){var t=e.alternate;t!==null&&(e.alternate=null,tf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[et],delete t[Ur],delete t[Kl],delete t[Xm],delete t[Ym])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function nf(e){return e.tag===5||e.tag===3||e.tag===4}function Ua(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||nf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function su(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Bo));else if(r!==4&&(e=e.child,e!==null))for(su(e,t,n),e=e.sibling;e!==null;)su(e,t,n),e=e.sibling}function au(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(au(e,t,n),e=e.sibling;e!==null;)au(e,t,n),e=e.sibling}var ae=null,Qe=!1;function Tt(e,t,n){for(n=n.child;n!==null;)rf(e,t,n),n=n.sibling}function rf(e,t,n){if(rt&&typeof rt.onCommitFiberUnmount=="function")try{rt.onCommitFiberUnmount(si,n)}catch{}switch(n.tag){case 5:me||Nn(n,t);case 6:var r=ae,o=Qe;ae=null,Tt(e,t,n),ae=r,Qe=o,ae!==null&&(Qe?(e=ae,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ae.removeChild(n.stateNode));break;case 18:ae!==null&&(Qe?(e=ae,n=n.stateNode,e.nodeType===8?Xi(e.parentNode,n):e.nodeType===1&&Xi(e,n),Nr(e)):Xi(ae,n.stateNode));break;case 4:r=ae,o=Qe,ae=n.stateNode.containerInfo,Qe=!0,Tt(e,t,n),ae=r,Qe=o;break;case 0:case 11:case 14:case 15:if(!me&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&lu(n,t,l),o=o.next}while(o!==r)}Tt(e,t,n);break;case 1:if(!me&&(Nn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){J(n,t,u)}Tt(e,t,n);break;case 21:Tt(e,t,n);break;case 22:n.mode&1?(me=(r=me)||n.memoizedState!==null,Tt(e,t,n),me=r):Tt(e,t,n);break;default:Tt(e,t,n)}}function Oa(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ph),t.forEach(function(r){var o=Ch.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function be(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=l),r&=~i}if(r=o,r=Z()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yh(r/1960))-r,10e?16:e,Ft===null)var r=!1;else{if(e=Ft,Ft=null,Zo=0,z&6)throw Error(E(331));var o=z;for(z|=4,_=e.current;_!==null;){var i=_,l=i.child;if(_.flags&16){var u=i.deletions;if(u!==null){for(var s=0;sZ()-ds?rn(e,0):cs|=n),Te(e,t)}function ff(e,t){t===0&&(e.mode&1?(t=to,to<<=1,!(to&130023424)&&(to=4194304)):t=1);var n=ve();e=Et(e,t),e!==null&&(Br(e,t,n),Te(e,n))}function Eh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ff(e,n)}function Ch(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),ff(e,n)}var pf;pf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ce.current)Ee=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ee=!1,ch(e,t,n);Ee=!!(e.flags&131072)}else Ee=!1,K&&t.flags&1048576&&hd(t,bo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Co(e,t),e=t.pendingProps;var o=An(t,ye.current);On(t,n),o=os(null,t,r,e,o,n);var i=is();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,xe(r)?(i=!0,Ho(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,Zu(t),o.updater=mi,t.stateNode=o,o._reactInternals=t,Zl(t,r,e,n),t=nu(null,t,r,!0,i,n)):(t.tag=0,K&&i&&Qu(t),ge(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Co(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Th(r),e=We(r,e),o){case 0:t=tu(null,t,r,e,n);break e;case 1:t=Pa(null,t,r,e,n);break e;case 11:t=Ta(null,t,r,e,n);break e;case 14:t=Na(null,t,r,We(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:We(r,o),tu(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:We(r,o),Pa(e,t,r,o,n);case 3:e:{if(qd(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,o=i.element,wd(e,t),Ko(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=zn(Error(E(423)),t),t=Ra(e,t,r,n,o);break e}else if(r!==o){o=zn(Error(E(424)),t),t=Ra(e,t,r,n,o);break e}else for(Re=$t(t.stateNode.containerInfo.firstChild),Le=t,K=!0,Ke=null,n=Cd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Mn(),r===o){t=Ct(e,t,n);break e}ge(e,t,r,n)}t=t.child}return t;case 5:return xd(t),e===null&&Xl(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,l=o.children,Wl(r,o)?l=null:i!==null&&Wl(r,i)&&(t.flags|=32),Gd(e,t),ge(e,t,l,n),t.child;case 6:return e===null&&Xl(t),null;case 13:return Xd(e,t,n);case 4:return es(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$n(t,null,r,n):ge(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:We(r,o),Ta(e,t,r,o,n);case 7:return ge(e,t,t.pendingProps,n),t.child;case 8:return ge(e,t,t.pendingProps.children,n),t.child;case 12:return ge(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,l=o.value,V(Wo,r._currentValue),r._currentValue=l,i!==null)if(Xe(i.value,l)){if(i.children===o.children&&!Ce.current){t=Ct(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){l=i.child;for(var s=u.firstContext;s!==null;){if(s.context===r){if(i.tag===1){s=yt(-1,n&-n),s.tag=2;var a=i.updateQueue;if(a!==null){a=a.shared;var d=a.pending;d===null?s.next=s:(s.next=d.next,d.next=s),a.pending=s}}i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),Yl(i.return,n,t),u.lanes|=n;break}s=s.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,u=l.alternate,u!==null&&(u.lanes|=n),Yl(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}ge(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,On(t,n),o=ze(o),r=r(o),t.flags|=1,ge(e,t,r,n),t.child;case 14:return r=t.type,o=We(r,t.pendingProps),o=We(r.type,o),Na(e,t,r,o,n);case 15:return Qd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:We(r,o),Co(e,t),t.tag=1,xe(r)?(e=!0,Ho(t)):e=!1,On(t,n),kd(t,r,o),Zl(t,r,o,n),nu(null,t,r,!0,e,n);case 19:return Yd(e,t,n);case 22:return Kd(e,t,n)}throw Error(E(156,t.tag))};function mf(e,t){return zc(e,t)}function xh(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 Me(e,t,n,r){return new xh(e,t,n,r)}function hs(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Th(e){if(typeof e=="function")return hs(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Du)return 11;if(e===Au)return 14}return 2}function jt(e,t){var n=e.alternate;return n===null?(n=Me(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function No(e,t,n,r,o,i){var l=2;if(r=e,typeof e=="function")hs(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case gn:return on(n.children,o,i,t);case Fu:l=8,o|=8;break;case Cl:return e=Me(12,n,t,o|2),e.elementType=Cl,e.lanes=i,e;case xl:return e=Me(13,n,t,o),e.elementType=xl,e.lanes=i,e;case Tl:return e=Me(19,n,t,o),e.elementType=Tl,e.lanes=i,e;case Ec:return vi(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Sc:l=10;break e;case kc:l=9;break e;case Du:l=11;break e;case Au:l=14;break e;case Pt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=Me(l,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function on(e,t,n,r){return e=Me(7,e,r,t),e.lanes=n,e}function vi(e,t,n,r){return e=Me(22,e,r,t),e.elementType=Ec,e.lanes=n,e.stateNode={isHidden:!1},e}function ol(e,t,n){return e=Me(6,e,null,t),e.lanes=n,e}function il(e,t,n){return t=Me(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Nh(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zi(0),this.expirationTimes=zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zi(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function ys(e,t,n,r,o,i,l,u,s){return e=new Nh(e,t,n,u,s),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Me(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zu(i),e}function Ph(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(vf)}catch(e){console.error(e)}}vf(),hc.exports=Ue;var wf=hc.exports,Ba=wf;kl.createRoot=Ba.createRoot,kl.hydrateRoot=Ba.hydrateRoot;function Sf(e,t){return function(){return e.apply(t,arguments)}}const{toString:Oh}=Object.prototype,{getPrototypeOf:Ss}=Object,Ci=(e=>t=>{const n=Oh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),it=e=>(e=e.toLowerCase(),t=>Ci(t)===e),xi=e=>t=>typeof t===e,{isArray:Wn}=Array,Ir=xi("undefined");function Fh(e){return e!==null&&!Ir(e)&&e.constructor!==null&&!Ir(e.constructor)&&Ie(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const kf=it("ArrayBuffer");function Dh(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&kf(e.buffer),t}const Ah=xi("string"),Ie=xi("function"),Ef=xi("number"),Ti=e=>e!==null&&typeof e=="object",Mh=e=>e===!0||e===!1,Po=e=>{if(Ci(e)!=="object")return!1;const t=Ss(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},$h=it("Date"),Ih=it("File"),zh=it("Blob"),Bh=it("FileList"),jh=e=>Ti(e)&&Ie(e.pipe),Hh=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ie(e.append)&&((t=Ci(e))==="formdata"||t==="object"&&Ie(e.toString)&&e.toString()==="[object FormData]"))},Vh=it("URLSearchParams"),bh=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function br(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Wn(e))for(r=0,o=e.length;r0;)if(o=n[r],t===o.toLowerCase())return o;return null}const xf=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Tf=e=>!Ir(e)&&e!==xf;function mu(){const{caseless:e}=Tf(this)&&this||{},t={},n=(r,o)=>{const i=e&&Cf(t,o)||o;Po(t[i])&&Po(r)?t[i]=mu(t[i],r):Po(r)?t[i]=mu({},r):Wn(r)?t[i]=r.slice():t[i]=r};for(let r=0,o=arguments.length;r(br(t,(o,i)=>{n&&Ie(o)?e[i]=Sf(o,n):e[i]=o},{allOwnKeys:r}),e),Qh=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kh=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Gh=(e,t,n,r)=>{let o,i,l;const u={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)l=o[i],(!r||r(l,e,t))&&!u[l]&&(t[l]=e[l],u[l]=!0);e=n!==!1&&Ss(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},qh=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Xh=e=>{if(!e)return null;if(Wn(e))return e;let t=e.length;if(!Ef(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Yh=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ss(Uint8Array)),Jh=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let o;for(;(o=r.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},Zh=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},e0=it("HTMLFormElement"),t0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ja=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),n0=it("RegExp"),Nf=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};br(n,(o,i)=>{t(o,i,e)!==!1&&(r[i]=o)}),Object.defineProperties(e,r)},r0=e=>{Nf(e,(t,n)=>{if(Ie(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ie(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},o0=(e,t)=>{const n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Wn(e)?r(e):r(String(e).split(t)),n},i0=()=>{},l0=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ll="abcdefghijklmnopqrstuvwxyz",Ha="0123456789",Pf={DIGIT:Ha,ALPHA:ll,ALPHA_DIGIT:ll+ll.toUpperCase()+Ha},u0=(e=16,t=Pf.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function s0(e){return!!(e&&Ie(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const a0=e=>{const t=new Array(10),n=(r,o)=>{if(Ti(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[o]=r;const i=Wn(r)?[]:{};return br(r,(l,u)=>{const s=n(l,o+1);!Ir(s)&&(i[u]=s)}),t[o]=void 0,i}}return r};return n(e,0)},c0=it("AsyncFunction"),d0=e=>e&&(Ti(e)||Ie(e))&&Ie(e.then)&&Ie(e.catch),S={isArray:Wn,isArrayBuffer:kf,isBuffer:Fh,isFormData:Hh,isArrayBufferView:Dh,isString:Ah,isNumber:Ef,isBoolean:Mh,isObject:Ti,isPlainObject:Po,isUndefined:Ir,isDate:$h,isFile:Ih,isBlob:zh,isRegExp:n0,isFunction:Ie,isStream:jh,isURLSearchParams:Vh,isTypedArray:Yh,isFileList:Bh,forEach:br,merge:mu,extend:Wh,trim:bh,stripBOM:Qh,inherits:Kh,toFlatObject:Gh,kindOf:Ci,kindOfTest:it,endsWith:qh,toArray:Xh,forEachEntry:Jh,matchAll:Zh,isHTMLForm:e0,hasOwnProperty:ja,hasOwnProp:ja,reduceDescriptors:Nf,freezeMethods:r0,toObjectSet:o0,toCamelCase:t0,noop:i0,toFiniteNumber:l0,findKey:Cf,global:xf,isContextDefined:Tf,ALPHABET:Pf,generateString:u0,isSpecCompliantForm:s0,toJSONObject:a0,isAsyncFn:c0,isThenable:d0};function $(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}S.inherits($,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Rf=$.prototype,Lf={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Lf[e]={value:e}});Object.defineProperties($,Lf);Object.defineProperty(Rf,"isAxiosError",{value:!0});$.from=(e,t,n,r,o,i)=>{const l=Object.create(Rf);return S.toFlatObject(e,l,function(s){return s!==Error.prototype},u=>u!=="isAxiosError"),$.call(l,e.message,t,n,r,o),l.cause=e,l.name=e.name,i&&Object.assign(l,i),l};const f0=null;function hu(e){return S.isPlainObject(e)||S.isArray(e)}function _f(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function Va(e,t,n){return e?e.concat(t).map(function(o,i){return o=_f(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function p0(e){return S.isArray(e)&&!e.some(hu)}const m0=S.toFlatObject(S,{},null,function(t){return/^is[A-Z]/.test(t)});function Ni(e,t,n){if(!S.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=S.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,T){return!S.isUndefined(T[g])});const r=n.metaTokens,o=n.visitor||d,i=n.dots,l=n.indexes,s=(n.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(t);if(!S.isFunction(o))throw new TypeError("visitor must be a function");function a(h){if(h===null)return"";if(S.isDate(h))return h.toISOString();if(!s&&S.isBlob(h))throw new $("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(h)||S.isTypedArray(h)?s&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function d(h,g,T){let f=h;if(h&&!T&&typeof h=="object"){if(S.endsWith(g,"{}"))g=r?g:g.slice(0,-2),h=JSON.stringify(h);else if(S.isArray(h)&&p0(h)||(S.isFileList(h)||S.endsWith(g,"[]"))&&(f=S.toArray(h)))return g=_f(g),f.forEach(function(y,k){!(S.isUndefined(y)||y===null)&&t.append(l===!0?Va([g],k,i):l===null?g:g+"[]",a(y))}),!1}return hu(h)?!0:(t.append(Va(T,g,i),a(h)),!1)}const p=[],m=Object.assign(m0,{defaultVisitor:d,convertValue:a,isVisitable:hu});function v(h,g){if(!S.isUndefined(h)){if(p.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(h),S.forEach(h,function(f,c){(!(S.isUndefined(f)||f===null)&&o.call(t,f,S.isString(c)?c.trim():c,g,m))===!0&&v(f,g?g.concat(c):[c])}),p.pop()}}if(!S.isObject(e))throw new TypeError("data must be an object");return v(e),t}function ba(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ks(e,t){this._pairs=[],e&&Ni(e,this,t)}const Uf=ks.prototype;Uf.append=function(t,n){this._pairs.push([t,n])};Uf.toString=function(t){const n=t?function(r){return t.call(this,r,ba)}:ba;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function h0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Of(e,t,n){if(!t)return e;const r=n&&n.encode||h0,o=n&&n.serialize;let i;if(o?i=o(t,n):i=S.isURLSearchParams(t)?t.toString():new ks(t,n).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class y0{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){S.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Wa=y0,Ff={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},g0=typeof URLSearchParams<"u"?URLSearchParams:ks,v0=typeof FormData<"u"?FormData:null,w0=typeof Blob<"u"?Blob:null,S0=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),k0=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),tt={isBrowser:!0,classes:{URLSearchParams:g0,FormData:v0,Blob:w0},isStandardBrowserEnv:S0,isStandardBrowserWebWorkerEnv:k0,protocols:["http","https","file","blob","url","data"]};function E0(e,t){return Ni(e,new tt.classes.URLSearchParams,Object.assign({visitor:function(n,r,o,i){return tt.isNode&&S.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function C0(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function x0(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r=n.length;return l=!l&&S.isArray(o)?o.length:l,s?(S.hasOwnProp(o,l)?o[l]=[o[l],r]:o[l]=r,!u):((!o[l]||!S.isObject(o[l]))&&(o[l]=[]),t(n,r,o[l],i)&&S.isArray(o[l])&&(o[l]=x0(o[l])),!u)}if(S.isFormData(e)&&S.isFunction(e.entries)){const n={};return S.forEachEntry(e,(r,o)=>{t(C0(r),o,n,0)}),n}return null}const T0={"Content-Type":void 0};function N0(e,t,n){if(S.isString(e))try{return(t||JSON.parse)(e),S.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Pi={transitional:Ff,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=S.isObject(t);if(i&&S.isHTMLForm(t)&&(t=new FormData(t)),S.isFormData(t))return o&&o?JSON.stringify(Df(t)):t;if(S.isArrayBuffer(t)||S.isBuffer(t)||S.isStream(t)||S.isFile(t)||S.isBlob(t))return t;if(S.isArrayBufferView(t))return t.buffer;if(S.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return E0(t,this.formSerializer).toString();if((u=S.isFileList(t))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return Ni(u?{"files[]":t}:t,s&&new s,this.formSerializer)}}return i||o?(n.setContentType("application/json",!1),N0(t)):t}],transformResponse:[function(t){const n=this.transitional||Pi.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(t&&S.isString(t)&&(r&&!this.responseType||o)){const l=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(u){if(l)throw u.name==="SyntaxError"?$.from(u,$.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:tt.classes.FormData,Blob:tt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};S.forEach(["delete","get","head"],function(t){Pi.headers[t]={}});S.forEach(["post","put","patch"],function(t){Pi.headers[t]=S.merge(T0)});const Es=Pi,P0=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),R0=e=>{const t={};let n,r,o;return e&&e.split(` +`).forEach(function(l){o=l.indexOf(":"),n=l.substring(0,o).trim().toLowerCase(),r=l.substring(o+1).trim(),!(!n||t[n]&&P0[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Qa=Symbol("internals");function or(e){return e&&String(e).trim().toLowerCase()}function Ro(e){return e===!1||e==null?e:S.isArray(e)?e.map(Ro):String(e)}function L0(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const _0=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ul(e,t,n,r,o){if(S.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!S.isString(t)){if(S.isString(r))return t.indexOf(r)!==-1;if(S.isRegExp(r))return r.test(t)}}function U0(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function O0(e,t){const n=S.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,i,l){return this[r].call(this,t,o,i,l)},configurable:!0})})}class Ri{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function i(u,s,a){const d=or(s);if(!d)throw new Error("header name must be a non-empty string");const p=S.findKey(o,d);(!p||o[p]===void 0||a===!0||a===void 0&&o[p]!==!1)&&(o[p||s]=Ro(u))}const l=(u,s)=>S.forEach(u,(a,d)=>i(a,d,s));return S.isPlainObject(t)||t instanceof this.constructor?l(t,n):S.isString(t)&&(t=t.trim())&&!_0(t)?l(R0(t),n):t!=null&&i(n,t,r),this}get(t,n){if(t=or(t),t){const r=S.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return L0(o);if(S.isFunction(n))return n.call(this,o,r);if(S.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=or(t),t){const r=S.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ul(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function i(l){if(l=or(l),l){const u=S.findKey(r,l);u&&(!n||ul(r,r[u],u,n))&&(delete r[u],o=!0)}}return S.isArray(t)?t.forEach(i):i(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const i=n[r];(!t||ul(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){const n=this,r={};return S.forEach(this,(o,i)=>{const l=S.findKey(r,i);if(l){n[l]=Ro(o),delete n[i];return}const u=t?U0(i):String(i).trim();u!==i&&delete n[i],n[u]=Ro(o),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return S.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&S.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Qa]=this[Qa]={accessors:{}}).accessors,o=this.prototype;function i(l){const u=or(l);r[u]||(O0(o,l),r[u]=!0)}return S.isArray(t)?t.forEach(i):i(t),this}}Ri.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);S.freezeMethods(Ri.prototype);S.freezeMethods(Ri);const gt=Ri;function sl(e,t){const n=this||Es,r=t||n,o=gt.from(r.headers);let i=r.data;return S.forEach(e,function(u){i=u.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Af(e){return!!(e&&e.__CANCEL__)}function Wr(e,t,n){$.call(this,e??"canceled",$.ERR_CANCELED,t,n),this.name="CanceledError"}S.inherits(Wr,$,{__CANCEL__:!0});function F0(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new $("Request failed with status code "+n.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const D0=tt.isStandardBrowserEnv?function(){return{write:function(n,r,o,i,l,u){const s=[];s.push(n+"="+encodeURIComponent(r)),S.isNumber(o)&&s.push("expires="+new Date(o).toGMTString()),S.isString(i)&&s.push("path="+i),S.isString(l)&&s.push("domain="+l),u===!0&&s.push("secure"),document.cookie=s.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function A0(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function M0(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function Mf(e,t){return e&&!A0(t)?M0(e,t):t}const $0=tt.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function o(i){let l=i;return t&&(n.setAttribute("href",l),l=n.href),n.setAttribute("href",l),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=o(window.location.href),function(l){const u=S.isString(l)?o(l):l;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function I0(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function z0(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,i=0,l;return t=t!==void 0?t:1e3,function(s){const a=Date.now(),d=r[i];l||(l=a),n[o]=s,r[o]=a;let p=i,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),a-l{const i=o.loaded,l=o.lengthComputable?o.total:void 0,u=i-n,s=r(u),a=i<=l;n=i;const d={loaded:i,total:l,progress:l?i/l:void 0,bytes:u,rate:s||void 0,estimated:s&&l&&a?(l-i)/s:void 0,event:o};d[t?"download":"upload"]=!0,e(d)}}const B0=typeof XMLHttpRequest<"u",j0=B0&&function(e){return new Promise(function(n,r){let o=e.data;const i=gt.from(e.headers).normalize(),l=e.responseType;let u;function s(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}S.isFormData(o)&&(tt.isStandardBrowserEnv||tt.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let a=new XMLHttpRequest;if(e.auth){const v=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(v+":"+h))}const d=Mf(e.baseURL,e.url);a.open(e.method.toUpperCase(),Of(d,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function p(){if(!a)return;const v=gt.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),g={data:!l||l==="text"||l==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:v,config:e,request:a};F0(function(f){n(f),s()},function(f){r(f),s()},g),a=null}if("onloadend"in a?a.onloadend=p:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(p)},a.onabort=function(){a&&(r(new $("Request aborted",$.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new $("Network Error",$.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const g=e.transitional||Ff;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new $(h,g.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,e,a)),a=null},tt.isStandardBrowserEnv){const v=(e.withCredentials||$0(d))&&e.xsrfCookieName&&D0.read(e.xsrfCookieName);v&&i.set(e.xsrfHeaderName,v)}o===void 0&&i.setContentType(null),"setRequestHeader"in a&&S.forEach(i.toJSON(),function(h,g){a.setRequestHeader(g,h)}),S.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),l&&l!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",Ka(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",Ka(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=v=>{a&&(r(!v||v.type?new Wr(null,e,a):v),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const m=I0(d);if(m&&tt.protocols.indexOf(m)===-1){r(new $("Unsupported protocol "+m+":",$.ERR_BAD_REQUEST,e));return}a.send(o||null)})},Lo={http:f0,xhr:j0};S.forEach(Lo,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const H0={getAdapter:e=>{e=S.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let o=0;oe instanceof gt?e.toJSON():e;function jn(e,t){t=t||{};const n={};function r(a,d,p){return S.isPlainObject(a)&&S.isPlainObject(d)?S.merge.call({caseless:p},a,d):S.isPlainObject(d)?S.merge({},d):S.isArray(d)?d.slice():d}function o(a,d,p){if(S.isUndefined(d)){if(!S.isUndefined(a))return r(void 0,a,p)}else return r(a,d,p)}function i(a,d){if(!S.isUndefined(d))return r(void 0,d)}function l(a,d){if(S.isUndefined(d)){if(!S.isUndefined(a))return r(void 0,a)}else return r(void 0,d)}function u(a,d,p){if(p in t)return r(a,d);if(p in e)return r(void 0,a)}const s={url:i,method:i,data:i,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:u,headers:(a,d)=>o(qa(a),qa(d),!0)};return S.forEach(Object.keys(Object.assign({},e,t)),function(d){const p=s[d]||o,m=p(e[d],t[d],d);S.isUndefined(m)&&p!==u||(n[d]=m)}),n}const $f="1.4.0",Cs={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Cs[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Xa={};Cs.transitional=function(t,n,r){function o(i,l){return"[Axios v"+$f+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,u)=>{if(t===!1)throw new $(o(l," has been removed"+(n?" in "+n:"")),$.ERR_DEPRECATED);return n&&!Xa[l]&&(Xa[l]=!0,console.warn(o(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,u):!0}};function V0(e,t,n){if(typeof e!="object")throw new $("options must be an object",$.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],l=t[i];if(l){const u=e[i],s=u===void 0||l(u,i,e);if(s!==!0)throw new $("option "+i+" must be "+s,$.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new $("Unknown option "+i,$.ERR_BAD_OPTION)}}const yu={assertOptions:V0,validators:Cs},Nt=yu.validators;class ni{constructor(t){this.defaults=t,this.interceptors={request:new Wa,response:new Wa}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&yu.assertOptions(r,{silentJSONParsing:Nt.transitional(Nt.boolean),forcedJSONParsing:Nt.transitional(Nt.boolean),clarifyTimeoutError:Nt.transitional(Nt.boolean)},!1),o!=null&&(S.isFunction(o)?n.paramsSerializer={serialize:o}:yu.assertOptions(o,{encode:Nt.function,serialize:Nt.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l;l=i&&S.merge(i.common,i[n.method]),l&&S.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),n.headers=gt.concat(l,i);const u=[];let s=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(s=s&&g.synchronous,u.unshift(g.fulfilled,g.rejected))});const a=[];this.interceptors.response.forEach(function(g){a.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!s){const h=[Ga.bind(this),void 0];for(h.unshift.apply(h,u),h.push.apply(h,a),m=h.length,d=Promise.resolve(n);p{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const l=new Promise(u=>{r.subscribe(u),i=u}).then(o);return l.cancel=function(){r.unsubscribe(i)},l},t(function(i,l,u){r.reason||(r.reason=new Wr(i,l,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new xs(function(o){t=o}),cancel:t}}}const b0=xs;function W0(e){return function(n){return e.apply(null,n)}}function Q0(e){return S.isObject(e)&&e.isAxiosError===!0}const gu={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(gu).forEach(([e,t])=>{gu[t]=e});const K0=gu;function If(e){const t=new _o(e),n=Sf(_o.prototype.request,t);return S.extend(n,_o.prototype,t,{allOwnKeys:!0}),S.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return If(jn(e,o))},n}const ie=If(Es);ie.Axios=_o;ie.CanceledError=Wr;ie.CancelToken=b0;ie.isCancel=Af;ie.VERSION=$f;ie.toFormData=Ni;ie.AxiosError=$;ie.Cancel=ie.CanceledError;ie.all=function(t){return Promise.all(t)};ie.spread=W0;ie.isAxiosError=Q0;ie.mergeConfig=jn;ie.AxiosHeaders=gt;ie.formToJSON=e=>Df(S.isHTMLForm(e)?new FormData(e):e);ie.HttpStatusCode=K0;ie.default=ie;const G0=ie;var q0=Object.defineProperty,X0=(e,t,n)=>t in e?q0(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cl=(e,t,n)=>(X0(e,typeof t!="symbol"?t+"":t,n),n);let Y0=class{constructor(){cl(this,"current",this.detect()),cl(this,"handoffState","pending"),cl(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},vt=new Y0,lt=(e,t)=>{vt.isServer?w.useEffect(e,t):w.useLayoutEffect(e,t)};function wt(e){let t=w.useRef(e);return lt(()=>{t.current=e},[e]),t}function Qr(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function Qn(){let e=[],t={addEventListener(n,r,o,i){return n.addEventListener(r,o,i),t.add(()=>n.removeEventListener(r,o,i))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return Qr(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,o){let i=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:o}),this.add(()=>{Object.assign(n.style,{[r]:i})})},group(n){let r=Qn();return n(r),this.add(()=>r.dispose())},add(n){return e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let n of e.splice(0))n()}};return t}function Ts(){let[e]=w.useState(Qn);return w.useEffect(()=>()=>e.dispose(),[e]),e}let ue=function(e){let t=wt(e);return M.useCallback((...n)=>t.current(...n),[t])};function Kn(){let[e,t]=w.useState(vt.isHandoffComplete);return e&&vt.isHandoffComplete===!1&&t(!1),w.useEffect(()=>{e!==!0&&t(!0)},[e]),w.useEffect(()=>vt.handoff(),[]),e}var Ya;let Gn=(Ya=M.useId)!=null?Ya:function(){let e=Kn(),[t,n]=M.useState(e?()=>vt.nextId():null);return lt(()=>{t===null&&n(vt.nextId())},[t]),t!=null?""+t:void 0};function he(e,t,...n){if(e in t){let o=t[e];return typeof o=="function"?o(...n):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,he),r}function zf(e){return vt.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}let vu=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var Jt=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e))(Jt||{}),Bf=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Bf||{}),J0=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(J0||{});function Z0(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(vu)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var jf=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(jf||{});function ey(e,t=0){var n;return e===((n=zf(e))==null?void 0:n.body)?!1:he(t,{[0](){return e.matches(vu)},[1](){let r=e;for(;r!==null;){if(r.matches(vu))return!0;r=r.parentElement}return!1}})}var ty=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(ty||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function ln(e){e==null||e.focus({preventScroll:!0})}let ny=["textarea","input"].join(",");function ry(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,ny))!=null?n:!1}function oy(e,t=n=>n){return e.slice().sort((n,r)=>{let o=t(n),i=t(r);if(o===null||i===null)return 0;let l=o.compareDocumentPosition(i);return l&Node.DOCUMENT_POSITION_FOLLOWING?-1:l&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function Uo(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,l=Array.isArray(e)?n?oy(e):e:Z0(e);o.length>0&&l.length>1&&(l=l.filter(v=>!o.includes(v))),r=r??i.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,l.indexOf(r))-1;if(t&4)return Math.max(0,l.indexOf(r))+1;if(t&8)return l.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),a=t&32?{preventScroll:!0}:{},d=0,p=l.length,m;do{if(d>=p||d+p<=0)return 0;let v=s+d;if(t&16)v=(v+p)%p;else{if(v<0)return 3;if(v>=p)return 1}m=l[v],m==null||m.focus(a),d+=u}while(m!==i.activeElement);return t&6&&ry(m)&&m.select(),2}function dl(e,t,n){let r=wt(t);w.useEffect(()=>{function o(i){r.current(i)}return document.addEventListener(e,o,n),()=>document.removeEventListener(e,o,n)},[e,n])}function iy(e,t,n=!0){let r=w.useRef(!1);w.useEffect(()=>{requestAnimationFrame(()=>{r.current=n})},[n]);function o(l,u){if(!r.current||l.defaultPrevented)return;let s=function d(p){return typeof p=="function"?d(p()):Array.isArray(p)||p instanceof Set?p:[p]}(e),a=u(l);if(a!==null&&a.getRootNode().contains(a)){for(let d of s){if(d===null)continue;let p=d instanceof HTMLElement?d:d.current;if(p!=null&&p.contains(a)||l.composed&&l.composedPath().includes(p))return}return!ey(a,jf.Loose)&&a.tabIndex!==-1&&l.preventDefault(),t(l,a)}}let i=w.useRef(null);dl("mousedown",l=>{var u,s;r.current&&(i.current=((s=(u=l.composedPath)==null?void 0:u.call(l))==null?void 0:s[0])||l.target)},!0),dl("click",l=>{i.current&&(o(l,()=>i.current),i.current=null)},!0),dl("blur",l=>o(l,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}let Hf=Symbol();function ly(e,t=!0){return Object.assign(e,{[Hf]:t})}function Ye(...e){let t=w.useRef(e);w.useEffect(()=>{t.current=e},[e]);let n=ue(r=>{for(let o of t.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[Hf]))?void 0:n}function wu(...e){return e.filter(Boolean).join(" ")}var ri=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(ri||{}),ht=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(ht||{});function je({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:o,visible:i=!0,name:l}){let u=Vf(t,e);if(i)return mo(u,n,r,l);let s=o??0;if(s&2){let{static:a=!1,...d}=u;if(a)return mo(d,n,r,l)}if(s&1){let{unmount:a=!0,...d}=u;return he(a?0:1,{[0](){return null},[1](){return mo({...d,hidden:!0,style:{display:"none"}},n,r,l)}})}return mo(u,n,r,l)}function mo(e,t={},n,r){let{as:o=n,children:i,refName:l="ref",...u}=fl(e,["unmount","static"]),s=e.ref!==void 0?{[l]:e.ref}:{},a=typeof i=="function"?i(t):i;"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(t));let d={};if(t){let p=!1,m=[];for(let[v,h]of Object.entries(t))typeof h=="boolean"&&(p=!0),h===!0&&m.push(v);p&&(d["data-headlessui-state"]=m.join(" "))}if(o===w.Fragment&&Object.keys(Ja(u)).length>0){if(!w.isValidElement(a)||Array.isArray(a)&&a.length>1)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(u).map(h=>` - ${h}`).join(` +`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(h=>` - ${h}`).join(` +`)].join(` +`));let p=a.props,m=typeof(p==null?void 0:p.className)=="function"?(...h)=>wu(p==null?void 0:p.className(...h),u.className):wu(p==null?void 0:p.className,u.className),v=m?{className:m}:{};return w.cloneElement(a,Object.assign({},Vf(a.props,Ja(fl(u,["ref"]))),d,s,uy(a.ref,s.ref),v))}return w.createElement(o,Object.assign({},fl(u,["ref"]),o!==w.Fragment&&s,o!==w.Fragment&&d),a)}function uy(...e){return{ref:e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}}function Vf(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];if(t.disabled||t["aria-disabled"])return Object.assign(t,Object.fromEntries(Object.keys(n).map(r=>[r,void 0])));for(let r in n)Object.assign(t,{[r](o,...i){let l=n[r];for(let u of l){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;u(o,...i)}}});return t}function Fe(e){var t;return Object.assign(w.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function Ja(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function fl(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function sy(e){let t=e.parentElement,n=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(n=t),t=t.parentElement;let r=(t==null?void 0:t.getAttribute("disabled"))==="";return r&&ay(n)?!1:r}function ay(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}let cy="div";var oi=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(oi||{});function dy(e,t){let{features:n=1,...r}=e,o={ref:t,"aria-hidden":(n&2)===2?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(n&4)===4&&(n&2)!==2&&{display:"none"}}};return je({ourProps:o,theirProps:r,slot:{},defaultTag:cy,name:"Hidden"})}let Su=Fe(dy),Ns=w.createContext(null);Ns.displayName="OpenClosedContext";var Pe=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Pe||{});function Ps(){return w.useContext(Ns)}function fy({value:e,children:t}){return M.createElement(Ns.Provider,{value:e},t)}var bf=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(bf||{});function Rs(e,t){let n=w.useRef([]),r=ue(e);w.useEffect(()=>{let o=[...n.current];for(let[i,l]of t.entries())if(n.current[i]!==l){let u=r(t,o);return n.current=t,u}},[r,...t])}function py(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function my(e,t,n){let r=wt(t);w.useEffect(()=>{function o(i){r.current(i)}return window.addEventListener(e,o,n),()=>window.removeEventListener(e,o,n)},[e,n])}var dr=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(dr||{});function hy(){let e=w.useRef(0);return my("keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function Kr(){let e=w.useRef(!1);return lt(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Li(...e){return w.useMemo(()=>zf(...e),[...e])}function Wf(e,t,n,r){let o=wt(n);w.useEffect(()=>{e=e??window;function i(l){o.current(l)}return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},[e,t,r])}function yy(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}function Qf(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)n.current instanceof HTMLElement&&t.add(n.current);return t}let gy="div";var Kf=(e=>(e[e.None=1]="None",e[e.InitialFocus=2]="InitialFocus",e[e.TabLock=4]="TabLock",e[e.FocusLock=8]="FocusLock",e[e.RestoreFocus=16]="RestoreFocus",e[e.All=30]="All",e))(Kf||{});function vy(e,t){let n=w.useRef(null),r=Ye(n,t),{initialFocus:o,containers:i,features:l=30,...u}=e;Kn()||(l=1);let s=Li(n);ky({ownerDocument:s},!!(l&16));let a=Ey({ownerDocument:s,container:n,initialFocus:o},!!(l&2));Cy({ownerDocument:s,container:n,containers:i,previousActiveElement:a},!!(l&8));let d=hy(),p=ue(g=>{let T=n.current;T&&(f=>f())(()=>{he(d.current,{[dr.Forwards]:()=>{Uo(T,Jt.First,{skipElements:[g.relatedTarget]})},[dr.Backwards]:()=>{Uo(T,Jt.Last,{skipElements:[g.relatedTarget]})}})})}),m=Ts(),v=w.useRef(!1),h={ref:r,onKeyDown(g){g.key=="Tab"&&(v.current=!0,m.requestAnimationFrame(()=>{v.current=!1}))},onBlur(g){let T=Qf(i);n.current instanceof HTMLElement&&T.add(n.current);let f=g.relatedTarget;f instanceof HTMLElement&&f.dataset.headlessuiFocusGuard!=="true"&&(Gf(T,f)||(v.current?Uo(n.current,he(d.current,{[dr.Forwards]:()=>Jt.Next,[dr.Backwards]:()=>Jt.Previous})|Jt.WrapAround,{relativeTo:g.target}):g.target instanceof HTMLElement&&ln(g.target)))}};return M.createElement(M.Fragment,null,!!(l&4)&&M.createElement(Su,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:p,features:oi.Focusable}),je({ourProps:h,theirProps:u,defaultTag:gy,name:"FocusTrap"}),!!(l&4)&&M.createElement(Su,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:p,features:oi.Focusable}))}let wy=Fe(vy),ir=Object.assign(wy,{features:Kf}),Ut=[];yy(()=>{function e(t){t.target instanceof HTMLElement&&t.target!==document.body&&Ut[0]!==t.target&&(Ut.unshift(t.target),Ut=Ut.filter(n=>n!=null&&n.isConnected),Ut.splice(10))}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function Sy(e=!0){let t=w.useRef(Ut.slice());return Rs(([n],[r])=>{r===!0&&n===!1&&Qr(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=Ut.slice())},[e,Ut,t]),ue(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function ky({ownerDocument:e},t){let n=Sy(t);Rs(()=>{t||(e==null?void 0:e.activeElement)===(e==null?void 0:e.body)&&ln(n())},[t]);let r=w.useRef(!1);w.useEffect(()=>(r.current=!1,()=>{r.current=!0,Qr(()=>{r.current&&ln(n())})}),[])}function Ey({ownerDocument:e,container:t,initialFocus:n},r){let o=w.useRef(null),i=Kr();return Rs(()=>{if(!r)return;let l=t.current;l&&Qr(()=>{if(!i.current)return;let u=e==null?void 0:e.activeElement;if(n!=null&&n.current){if((n==null?void 0:n.current)===u){o.current=u;return}}else if(l.contains(u)){o.current=u;return}n!=null&&n.current?ln(n.current):Uo(l,Jt.First)===Bf.Error&&console.warn("There are no focusable elements inside the "),o.current=e==null?void 0:e.activeElement})},[r]),o}function Cy({ownerDocument:e,container:t,containers:n,previousActiveElement:r},o){let i=Kr();Wf(e==null?void 0:e.defaultView,"focus",l=>{if(!o||!i.current)return;let u=Qf(n);t.current instanceof HTMLElement&&u.add(t.current);let s=r.current;if(!s)return;let a=l.target;a&&a instanceof HTMLElement?Gf(u,a)?(r.current=a,ln(a)):(l.preventDefault(),l.stopPropagation(),ln(s)):ln(r.current)},!0)}function Gf(e,t){for(let n of e)if(n.contains(t))return!0;return!1}let qf=w.createContext(!1);function xy(){return w.useContext(qf)}function ku(e){return M.createElement(qf.Provider,{value:e.force},e.children)}function Ty(e){let t=xy(),n=w.useContext(Xf),r=Li(e),[o,i]=w.useState(()=>{if(!t&&n!==null||vt.isServer)return null;let l=r==null?void 0:r.getElementById("headlessui-portal-root");if(l)return l;if(r===null)return null;let u=r.createElement("div");return u.setAttribute("id","headlessui-portal-root"),r.body.appendChild(u)});return w.useEffect(()=>{o!==null&&(r!=null&&r.body.contains(o)||r==null||r.body.appendChild(o))},[o,r]),w.useEffect(()=>{t||n!==null&&i(n.current)},[n,i,t]),o}let Ny=w.Fragment;function Py(e,t){let n=e,r=w.useRef(null),o=Ye(ly(d=>{r.current=d}),t),i=Li(r),l=Ty(r),[u]=w.useState(()=>{var d;return vt.isServer?null:(d=i==null?void 0:i.createElement("div"))!=null?d:null}),s=Kn(),a=w.useRef(!1);return lt(()=>{if(a.current=!1,!(!l||!u))return l.contains(u)||(u.setAttribute("data-headlessui-portal",""),l.appendChild(u)),()=>{a.current=!0,Qr(()=>{var d;a.current&&(!l||!u||(u instanceof Node&&l.contains(u)&&l.removeChild(u),l.childNodes.length<=0&&((d=l.parentElement)==null||d.removeChild(l))))})}},[l,u]),s?!l||!u?null:wf.createPortal(je({ourProps:{ref:o},theirProps:n,defaultTag:Ny,name:"Portal"}),u):null}let Ry=w.Fragment,Xf=w.createContext(null);function Ly(e,t){let{target:n,...r}=e,o={ref:Ye(t)};return M.createElement(Xf.Provider,{value:n},je({ourProps:o,theirProps:r,defaultTag:Ry,name:"Popover.Group"}))}let _y=Fe(Py),Uy=Fe(Ly),Eu=Object.assign(_y,{Group:Uy}),Yf=w.createContext(null);function Jf(){let e=w.useContext(Yf);if(e===null){let t=new Error("You used a component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Jf),t}return e}function Oy(){let[e,t]=w.useState([]);return[e.length>0?e.join(" "):void 0,w.useMemo(()=>function(n){let r=ue(i=>(t(l=>[...l,i]),()=>t(l=>{let u=l.slice(),s=u.indexOf(i);return s!==-1&&u.splice(s,1),u}))),o=w.useMemo(()=>({register:r,slot:n.slot,name:n.name,props:n.props}),[r,n.slot,n.name,n.props]);return M.createElement(Yf.Provider,{value:o},n.children)},[t])]}let Fy="p";function Dy(e,t){let n=Gn(),{id:r=`headlessui-description-${n}`,...o}=e,i=Jf(),l=Ye(t);lt(()=>i.register(r),[r,i.register]);let u={ref:l,...i.props,id:r};return je({ourProps:u,theirProps:o,slot:i.slot||{},defaultTag:Fy,name:i.name||"Description"})}let Ay=Fe(Dy),My=Object.assign(Ay,{}),Ls=w.createContext(()=>{});Ls.displayName="StackContext";var Cu=(e=>(e[e.Add=0]="Add",e[e.Remove=1]="Remove",e))(Cu||{});function $y(){return w.useContext(Ls)}function Iy({children:e,onUpdate:t,type:n,element:r,enabled:o}){let i=$y(),l=ue((...u)=>{t==null||t(...u),i(...u)});return lt(()=>{let u=o===void 0||o===!0;return u&&l(0,n,r),()=>{u&&l(1,n,r)}},[l,n,r,o]),M.createElement(Ls.Provider,{value:l},e)}function zy(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}const By=typeof Object.is=="function"?Object.is:zy,{useState:jy,useEffect:Hy,useLayoutEffect:Vy,useDebugValue:by}=Sl;function Wy(e,t,n){const r=t(),[{inst:o},i]=jy({inst:{value:r,getSnapshot:t}});return Vy(()=>{o.value=r,o.getSnapshot=t,pl(o)&&i({inst:o})},[e,r,t]),Hy(()=>(pl(o)&&i({inst:o}),e(()=>{pl(o)&&i({inst:o})})),[e]),by(r),r}function pl(e){const t=e.getSnapshot,n=e.value;try{const r=t();return!By(n,r)}catch{return!0}}function Qy(e,t,n){return t()}const Ky=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Gy=!Ky,qy=Gy?Qy:Wy,Xy="useSyncExternalStore"in Sl?(e=>e.useSyncExternalStore)(Sl):qy;function Yy(e){return Xy(e.subscribe,e.getSnapshot,e.getSnapshot)}function Jy(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...i){let l=t[o].call(n,...i);l&&(n=l,r.forEach(u=>u()))}}}function Zy(){let e;return{before({doc:t}){var n;let r=t.documentElement;e=((n=t.defaultView)!=null?n:window).innerWidth-r.clientWidth},after({doc:t,d:n}){let r=t.documentElement,o=r.clientWidth-r.offsetWidth,i=e-o;n.style(r,"paddingRight",`${i}px`)}}}function e1(){if(!py())return{};let e;return{before(){e=window.pageYOffset},after({doc:t,d:n,meta:r}){function o(l){return r.containers.flatMap(u=>u()).some(u=>u.contains(l))}n.style(t.body,"marginTop",`-${e}px`),window.scrollTo(0,0);let i=null;n.addEventListener(t,"click",l=>{if(l.target instanceof HTMLElement)try{let u=l.target.closest("a");if(!u)return;let{hash:s}=new URL(u.href),a=t.querySelector(s);a&&!o(a)&&(i=a)}catch{}},!0),n.addEventListener(t,"touchmove",l=>{l.target instanceof HTMLElement&&!o(l.target)&&l.preventDefault()},{passive:!1}),n.add(()=>{window.scrollTo(0,window.pageYOffset+e),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})}}}function t1(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function n1(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let nn=Jy(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:Qn(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:n1(n)},o=[e1(),Zy(),t1()];o.forEach(({before:i})=>i==null?void 0:i(r)),o.forEach(({after:i})=>i==null?void 0:i(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});nn.subscribe(()=>{let e=nn.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",o=n.count!==0;(o&&!r||!o&&r)&&nn.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&nn.dispatch("TEARDOWN",n)}});function r1(e,t,n){let r=Yy(nn),o=e?r.get(e):void 0,i=o?o.count>0:!1;return lt(()=>{if(!(!e||!t))return nn.dispatch("PUSH",e,n),()=>nn.dispatch("POP",e,n)},[t,e]),i}let ml=new Map,lr=new Map;function Za(e,t=!0){lt(()=>{var n;if(!t)return;let r=typeof e=="function"?e():e.current;if(!r)return;function o(){var l;if(!r)return;let u=(l=lr.get(r))!=null?l:1;if(u===1?lr.delete(r):lr.set(r,u-1),u!==1)return;let s=ml.get(r);s&&(s["aria-hidden"]===null?r.removeAttribute("aria-hidden"):r.setAttribute("aria-hidden",s["aria-hidden"]),r.inert=s.inert,ml.delete(r))}let i=(n=lr.get(r))!=null?n:0;return lr.set(r,i+1),i!==0||(ml.set(r,{"aria-hidden":r.getAttribute("aria-hidden"),inert:r.inert}),r.setAttribute("aria-hidden","true"),r.inert=!0),o},[e,t])}var o1=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(o1||{}),i1=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(i1||{});let l1={[0](e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},ii=w.createContext(null);ii.displayName="DialogContext";function Gr(e){let t=w.useContext(ii);if(t===null){let n=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Gr),n}return t}function u1(e,t,n=()=>[document.body]){r1(e,t,r=>{var o;return{containers:[...(o=r.containers)!=null?o:[],n]}})}function s1(e,t){return he(t.type,l1,e,t)}let a1="div",c1=ri.RenderStrategy|ri.Static;function d1(e,t){let n=Gn(),{id:r=`headlessui-dialog-${n}`,open:o,onClose:i,initialFocus:l,__demoMode:u=!1,...s}=e,[a,d]=w.useState(0),p=Ps();o===void 0&&p!==null&&(o=(p&Pe.Open)===Pe.Open);let m=w.useRef(null),v=Ye(m,t),h=w.useRef(null),g=Li(m),T=e.hasOwnProperty("open")||p!==null,f=e.hasOwnProperty("onClose");if(!T&&!f)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!T)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!f)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(typeof o!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${o}`);if(typeof i!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${i}`);let c=o?0:1,[y,k]=w.useReducer(s1,{titleId:null,descriptionId:null,panelRef:w.createRef()}),N=ue(()=>i(!1)),P=ue(Q=>k({type:0,id:Q})),x=Kn()?u?!1:c===0:!1,L=a>1,A=w.useContext(ii)!==null,U=L?"parent":"leaf",j=p!==null?(p&Pe.Closing)===Pe.Closing:!1,He=(()=>A||j?!1:x)(),Ve=w.useCallback(()=>{var Q,te;return(te=Array.from((Q=g==null?void 0:g.querySelectorAll("body > *"))!=null?Q:[]).find(G=>G.id==="headlessui-portal-root"?!1:G.contains(h.current)&&G instanceof HTMLElement))!=null?te:null},[h]);Za(Ve,He);let mn=(()=>L?!0:x)(),ut=w.useCallback(()=>{var Q,te;return(te=Array.from((Q=g==null?void 0:g.querySelectorAll("[data-headlessui-portal]"))!=null?Q:[]).find(G=>G.contains(h.current)&&G instanceof HTMLElement))!=null?te:null},[h]);Za(ut,mn);let st=ue(()=>{var Q,te;return[...Array.from((Q=g==null?void 0:g.querySelectorAll("html > *, body > *, [data-headlessui-portal]"))!=null?Q:[]).filter(G=>!(G===document.body||G===document.head||!(G instanceof HTMLElement)||G.contains(h.current)||y.panelRef.current&&G.contains(y.panelRef.current))),(te=y.panelRef.current)!=null?te:m.current]}),Kt=(()=>!(!x||L))();iy(()=>st(),N,Kt);let R=(()=>!(L||c!==0))();Wf(g==null?void 0:g.defaultView,"keydown",Q=>{R&&(Q.defaultPrevented||Q.key===bf.Escape&&(Q.preventDefault(),Q.stopPropagation(),N()))});let O=(()=>!(j||c!==0||A))();u1(g,O,st),w.useEffect(()=>{if(c!==0||!m.current)return;let Q=new ResizeObserver(te=>{for(let G of te){let qr=G.target.getBoundingClientRect();qr.x===0&&qr.y===0&&qr.width===0&&qr.height===0&&N()}});return Q.observe(m.current),()=>Q.disconnect()},[c,m,N]);let[F,B]=Oy(),ee=w.useMemo(()=>[{dialogState:c,close:N,setTitleId:P},y],[c,y,N,P]),Gt=w.useMemo(()=>({open:c===0}),[c]),at={ref:v,id:r,role:"dialog","aria-modal":c===0?!0:void 0,"aria-labelledby":y.titleId,"aria-describedby":F};return M.createElement(Iy,{type:"Dialog",enabled:c===0,element:m,onUpdate:ue((Q,te)=>{te==="Dialog"&&he(Q,{[Cu.Add]:()=>d(G=>G+1),[Cu.Remove]:()=>d(G=>G-1)})})},M.createElement(ku,{force:!0},M.createElement(Eu,null,M.createElement(ii.Provider,{value:ee},M.createElement(Eu.Group,{target:m},M.createElement(ku,{force:!1},M.createElement(B,{slot:Gt,name:"Dialog.Description"},M.createElement(ir,{initialFocus:l,containers:st,features:x?he(U,{parent:ir.features.RestoreFocus,leaf:ir.features.All&~ir.features.FocusLock}):ir.features.None},je({ourProps:at,theirProps:s,slot:Gt,defaultTag:a1,features:c1,visible:c===0,name:"Dialog"})))))))),M.createElement(Su,{features:oi.Hidden,ref:h}))}let f1="div";function p1(e,t){let n=Gn(),{id:r=`headlessui-dialog-overlay-${n}`,...o}=e,[{dialogState:i,close:l}]=Gr("Dialog.Overlay"),u=Ye(t),s=ue(d=>{if(d.target===d.currentTarget){if(sy(d.currentTarget))return d.preventDefault();d.preventDefault(),d.stopPropagation(),l()}}),a=w.useMemo(()=>({open:i===0}),[i]);return je({ourProps:{ref:u,id:r,"aria-hidden":!0,onClick:s},theirProps:o,slot:a,defaultTag:f1,name:"Dialog.Overlay"})}let m1="div";function h1(e,t){let n=Gn(),{id:r=`headlessui-dialog-backdrop-${n}`,...o}=e,[{dialogState:i},l]=Gr("Dialog.Backdrop"),u=Ye(t);w.useEffect(()=>{if(l.panelRef.current===null)throw new Error("A component is being used, but a component is missing.")},[l.panelRef]);let s=w.useMemo(()=>({open:i===0}),[i]);return M.createElement(ku,{force:!0},M.createElement(Eu,null,je({ourProps:{ref:u,id:r,"aria-hidden":!0},theirProps:o,slot:s,defaultTag:m1,name:"Dialog.Backdrop"})))}let y1="div";function g1(e,t){let n=Gn(),{id:r=`headlessui-dialog-panel-${n}`,...o}=e,[{dialogState:i},l]=Gr("Dialog.Panel"),u=Ye(t,l.panelRef),s=w.useMemo(()=>({open:i===0}),[i]),a=ue(d=>{d.stopPropagation()});return je({ourProps:{ref:u,id:r,onClick:a},theirProps:o,slot:s,defaultTag:y1,name:"Dialog.Panel"})}let v1="h2";function w1(e,t){let n=Gn(),{id:r=`headlessui-dialog-title-${n}`,...o}=e,[{dialogState:i,setTitleId:l}]=Gr("Dialog.Title"),u=Ye(t);w.useEffect(()=>(l(r),()=>l(null)),[r,l]);let s=w.useMemo(()=>({open:i===0}),[i]);return je({ourProps:{ref:u,id:r},theirProps:o,slot:s,defaultTag:v1,name:"Dialog.Title"})}let S1=Fe(d1),k1=Fe(h1),E1=Fe(g1),C1=Fe(p1),x1=Fe(w1),hl=Object.assign(S1,{Backdrop:k1,Panel:E1,Overlay:C1,Title:x1,Description:My});function T1(e=0){let[t,n]=w.useState(e),r=Kr(),o=w.useCallback(s=>{r.current&&n(a=>a|s)},[t,r]),i=w.useCallback(s=>!!(t&s),[t]),l=w.useCallback(s=>{r.current&&n(a=>a&~s)},[n,r]),u=w.useCallback(s=>{r.current&&n(a=>a^s)},[n]);return{flags:t,addFlag:o,hasFlag:i,removeFlag:l,toggleFlag:u}}function N1(e){let t={called:!1};return(...n)=>{if(!t.called)return t.called=!0,e(...n)}}function yl(e,...t){e&&t.length>0&&e.classList.add(...t)}function gl(e,...t){e&&t.length>0&&e.classList.remove(...t)}function P1(e,t){let n=Qn();if(!e)return n.dispose;let{transitionDuration:r,transitionDelay:o}=getComputedStyle(e),[i,l]=[r,o].map(s=>{let[a=0]=s.split(",").filter(Boolean).map(d=>d.includes("ms")?parseFloat(d):parseFloat(d)*1e3).sort((d,p)=>p-d);return a}),u=i+l;if(u!==0){n.group(a=>{a.setTimeout(()=>{t(),a.dispose()},u),a.addEventListener(e,"transitionrun",d=>{d.target===d.currentTarget&&a.dispose()})});let s=n.addEventListener(e,"transitionend",a=>{a.target===a.currentTarget&&(t(),s())})}else t();return n.add(()=>t()),n.dispose}function R1(e,t,n,r){let o=n?"enter":"leave",i=Qn(),l=r!==void 0?N1(r):()=>{};o==="enter"&&(e.removeAttribute("hidden"),e.style.display="");let u=he(o,{enter:()=>t.enter,leave:()=>t.leave}),s=he(o,{enter:()=>t.enterTo,leave:()=>t.leaveTo}),a=he(o,{enter:()=>t.enterFrom,leave:()=>t.leaveFrom});return gl(e,...t.enter,...t.enterTo,...t.enterFrom,...t.leave,...t.leaveFrom,...t.leaveTo,...t.entered),yl(e,...u,...a),i.nextFrame(()=>{gl(e,...a),yl(e,...s),P1(e,()=>(gl(e,...u),yl(e,...t.entered),l()))}),i.dispose}function L1({container:e,direction:t,classes:n,onStart:r,onStop:o}){let i=Kr(),l=Ts(),u=wt(t);lt(()=>{let s=Qn();l.add(s.dispose);let a=e.current;if(a&&u.current!=="idle"&&i.current)return s.dispose(),r.current(u.current),s.add(R1(a,n.current,u.current==="enter",()=>{s.dispose(),o.current(u.current)})),s.dispose},[t])}function qt(e=""){return e.split(" ").filter(t=>t.trim().length>1)}let _i=w.createContext(null);_i.displayName="TransitionContext";var _1=(e=>(e.Visible="visible",e.Hidden="hidden",e))(_1||{});function U1(){let e=w.useContext(_i);if(e===null)throw new Error("A is used but it is missing a parent or .");return e}function O1(){let e=w.useContext(Ui);if(e===null)throw new Error("A is used but it is missing a parent or .");return e}let Ui=w.createContext(null);Ui.displayName="NestingContext";function Oi(e){return"children"in e?Oi(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function Zf(e,t){let n=wt(e),r=w.useRef([]),o=Kr(),i=Ts(),l=ue((v,h=ht.Hidden)=>{let g=r.current.findIndex(({el:T})=>T===v);g!==-1&&(he(h,{[ht.Unmount](){r.current.splice(g,1)},[ht.Hidden](){r.current[g].state="hidden"}}),i.microTask(()=>{var T;!Oi(r)&&o.current&&((T=n.current)==null||T.call(n))}))}),u=ue(v=>{let h=r.current.find(({el:g})=>g===v);return h?h.state!=="visible"&&(h.state="visible"):r.current.push({el:v,state:"visible"}),()=>l(v,ht.Unmount)}),s=w.useRef([]),a=w.useRef(Promise.resolve()),d=w.useRef({enter:[],leave:[],idle:[]}),p=ue((v,h,g)=>{s.current.splice(0),t&&(t.chains.current[h]=t.chains.current[h].filter(([T])=>T!==v)),t==null||t.chains.current[h].push([v,new Promise(T=>{s.current.push(T)})]),t==null||t.chains.current[h].push([v,new Promise(T=>{Promise.all(d.current[h].map(([f,c])=>c)).then(()=>T())})]),h==="enter"?a.current=a.current.then(()=>t==null?void 0:t.wait.current).then(()=>g(h)):g(h)}),m=ue((v,h,g)=>{Promise.all(d.current[h].splice(0).map(([T,f])=>f)).then(()=>{var T;(T=s.current.shift())==null||T()}).then(()=>g(h))});return w.useMemo(()=>({children:r,register:u,unregister:l,onStart:p,onStop:m,wait:a,chains:d}),[u,l,r,p,m,d,a])}function F1(){}let D1=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function ec(e){var t;let n={};for(let r of D1)n[r]=(t=e[r])!=null?t:F1;return n}function A1(e){let t=w.useRef(ec(e));return w.useEffect(()=>{t.current=ec(e)},[e]),t}let M1="div",ep=ri.RenderStrategy;function $1(e,t){let{beforeEnter:n,afterEnter:r,beforeLeave:o,afterLeave:i,enter:l,enterFrom:u,enterTo:s,entered:a,leave:d,leaveFrom:p,leaveTo:m,...v}=e,h=w.useRef(null),g=Ye(h,t),T=v.unmount?ht.Unmount:ht.Hidden,{show:f,appear:c,initial:y}=U1(),[k,N]=w.useState(f?"visible":"hidden"),P=O1(),{register:x,unregister:L}=P,A=w.useRef(null);w.useEffect(()=>x(h),[x,h]),w.useEffect(()=>{if(T===ht.Hidden&&h.current){if(f&&k!=="visible"){N("visible");return}return he(k,{hidden:()=>L(h),visible:()=>x(h)})}},[k,h,x,L,f,T]);let U=wt({enter:qt(l),enterFrom:qt(u),enterTo:qt(s),entered:qt(a),leave:qt(d),leaveFrom:qt(p),leaveTo:qt(m)}),j=A1({beforeEnter:n,afterEnter:r,beforeLeave:o,afterLeave:i}),He=Kn();w.useEffect(()=>{if(He&&k==="visible"&&h.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[h,k,He]);let Ve=y&&!c,mn=(()=>!He||Ve||A.current===f?"idle":f?"enter":"leave")(),ut=T1(0),st=ue(B=>he(B,{enter:()=>{ut.addFlag(Pe.Opening),j.current.beforeEnter()},leave:()=>{ut.addFlag(Pe.Closing),j.current.beforeLeave()},idle:()=>{}})),Kt=ue(B=>he(B,{enter:()=>{ut.removeFlag(Pe.Opening),j.current.afterEnter()},leave:()=>{ut.removeFlag(Pe.Closing),j.current.afterLeave()},idle:()=>{}})),R=Zf(()=>{N("hidden"),L(h)},P);L1({container:h,classes:U,direction:mn,onStart:wt(B=>{R.onStart(h,B,st)}),onStop:wt(B=>{R.onStop(h,B,Kt),B==="leave"&&!Oi(R)&&(N("hidden"),L(h))})}),w.useEffect(()=>{Ve&&(T===ht.Hidden?A.current=null:A.current=f)},[f,Ve,k]);let O=v,F={ref:g};return c&&f&&(O={...O,className:wu(v.className,...U.current.enter,...U.current.enterFrom)}),M.createElement(Ui.Provider,{value:R},M.createElement(fy,{value:he(k,{visible:Pe.Open,hidden:Pe.Closed})|ut.flags},je({ourProps:F,theirProps:O,defaultTag:M1,features:ep,visible:k==="visible",name:"Transition.Child"})))}function I1(e,t){let{show:n,appear:r=!1,unmount:o,...i}=e,l=w.useRef(null),u=Ye(l,t);Kn();let s=Ps();if(n===void 0&&s!==null&&(n=(s&Pe.Open)===Pe.Open),![!0,!1].includes(n))throw new Error("A is used but it is missing a `show={true | false}` prop.");let[a,d]=w.useState(n?"visible":"hidden"),p=Zf(()=>{d("hidden")}),[m,v]=w.useState(!0),h=w.useRef([n]);lt(()=>{m!==!1&&h.current[h.current.length-1]!==n&&(h.current.push(n),v(!1))},[h,n]);let g=w.useMemo(()=>({show:n,appear:r,initial:m}),[n,r,m]);w.useEffect(()=>{if(n)d("visible");else if(!Oi(p))d("hidden");else{let f=l.current;if(!f)return;let c=f.getBoundingClientRect();c.x===0&&c.y===0&&c.width===0&&c.height===0&&d("hidden")}},[n,p]);let T={unmount:o};return M.createElement(Ui.Provider,{value:p},M.createElement(_i.Provider,{value:g},je({ourProps:{...T,as:w.Fragment,children:M.createElement(tp,{ref:u,...T,...i})},theirProps:{},defaultTag:w.Fragment,features:ep,visible:a==="visible",name:"Transition"})))}function z1(e,t){let n=w.useContext(_i)!==null,r=Ps()!==null;return M.createElement(M.Fragment,null,!n&&r?M.createElement(xu,{ref:t,...e}):M.createElement(tp,{ref:t,...e}))}let xu=Fe(I1),tp=Fe($1),B1=Fe(z1),vl=Object.assign(xu,{Child:B1,Root:xu});function _s({show:e,onClose:t,onSubmit:n,title:r,content:o,submitText:i,submitEnabled:l=!0}){return C(vl,{appear:!0,show:e,as:w.Fragment,children:I(hl,{as:"div",className:"relative z-10",onClose:t,children:[C(vl.Child,{as:w.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:C("div",{className:"fixed inset-0 bg-black bg-opacity-25"})}),C("div",{className:"fixed inset-0 overflow-y-auto",children:C("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:C(vl.Child,{as:w.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:I(hl.Panel,{className:"w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all",children:[C(hl.Title,{as:"h3",className:"text-lg font-medium leading-6 text-gray-900",children:r}),C("div",{className:"mt-3 text-sm text-gray-500",children:o}),I("div",{className:"mt-4 flex flex-row-reverse",children:[i&&C("button",{type:"button",disabled:!l,className:`inline-flex ml-4 justify-center rounded-md border border-transparent ${l?"bg-indigo-600":"bg-grey-300"} px-4 py-2 text-sm font-medium text-indigo-100 ${l?"hover:bg-indigo-500 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2":""} transition-all duration-300`,onClick:n,children:i}),C("button",{type:"button",className:"inline-flex justify-center rounded-md border border-transparent bg-indigo-100 px-4 py-2 text-sm font-medium text-indigo-900 hover:bg-indigo-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 transition-all duration-300",onClick:t,children:"Close"})]})]})})})})]})})}function j1(e){return C("div",{children:C("input",{...e,type:"url",className:"my-2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",placeholder:"www.example.com",required:!0})})}function H1(e){const t=w.useRef(null),n=w.useRef(null);return w.useEffect(()=>{t.current&&n.current&&(n.current.src=e.audioUrl,t.current.load())},[e.audioUrl]),C("div",{className:"flex relative z-10 p-4 w-full",children:C("audio",{ref:t,controls:!0,className:"w-full h-14 rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10",children:C("source",{ref:n,type:e.mimeType})})})}function V1(e){const{isModelLoading:t,isTranscribing:n,onClick:r,...o}=e;return C("button",{...o,onClick:i=>{r&&!n&&!t&&r(i)},disabled:n,className:"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 inline-flex items-center",children:t?C(tc,{text:"Loading model..."}):n?C(tc,{text:"Transcribing..."}):"Transcribe Audio"})}function tc(e){return I("div",{role:"status",children:[I("svg",{"aria-hidden":"true",role:"status",className:"inline w-4 h-4 mr-3 text-white animate-spin",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"#E5E7EB"}),C("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentColor"})]}),e.text]})}function b1(){let e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||("opera"in window&&typeof window.opera=="string"?window.opera:"")),e}const W1=b1(),ft={SAMPLING_RATE:16e3,DEFAULT_AUDIO_URL:`https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/${W1?"jfk":"ted_60_16k"}.wav`,DEFAULT_MODEL:"distil-whisper/distil-small.en",DEFAULT_SUBTASK:"transcribe",DEFAULT_LANGUAGE:"english",DEFAULT_QUANTIZED:!0,DEFAULT_MULTILINGUAL:!1};function Q1({text:e,percentage:t}){return t=t??0,C("div",{className:"mt-0.5 w-full relative text-sm text-white background-bg-cyan-400 bg-gray-200 border-1 border-gray-400 rounded-lg text-left overflow-hidden",children:I("div",{className:"top-0 h-full bg-blue-500 whitespace-nowrap px-2",style:{width:`${t}%`},children:[e," (",`${t.toFixed(2)}%`,")"]})})}function wl(e){return String(e).padStart(2,"0")}function np(e){const t=e/3600|0;e-=t*(60*60);const n=e/60|0;e-=n*60;const r=e|0;return`${t?wl(t)+":":""}${wl(n)}:${wl(r)}`}const K1={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}};class li{constructor(t="Unknown",n="Unknown"){qn(this,"source");qn(this,"data");this.name=t,this.type=n}updateBySource(){}setSource(t){this.source=t,this.updateBySource()}updateByData(){}setData(t){this.data=t,this.updateByData()}}class G1 extends li{constructor(t,n){super(t,n||"Uint")}updateBySource(){this.data="";for(let t=0;t=i&&o<8;o++,i*=128);if(!r){let l=i+n;for(let u=o-1;u>=0;u--){const s=l%256;this.source[this.offset+u]=s,l=(l-s)/256}}this.offset+=o}writeSections(n=!1){this.offset=0;for(let r=0;rnew Promise((r,o)=>{try{const i=new FileReader;i.addEventListener("loadend",()=>{try{const l=i.result,u=new q1(new Uint8Array(l));u.fixDuration(t)?r(u.toBlob(n)):r(e)}catch(l){o(l)}}),i.addEventListener("error",()=>o()),i.readAsArrayBuffer(e)}catch(i){o(i)}});function Y1(){const e=["audio/webm","audio/mp4","audio/ogg","audio/wav","audio/aac"];for(let t=0;t{l(null);let h=Date.now();try{u.current||(u.current=await navigator.mediaDevices.getUserMedia({audio:!0}));const g=Y1(),T=new MediaRecorder(u.current,{mimeType:g});s.current=T,T.addEventListener("dataavailable",async f=>{if(f.data.size>0&&a.current.push(f.data),T.state==="inactive"){const c=Date.now()-h;let y=new Blob(a.current,{type:g});g==="audio/webm"&&(y=await X1(y,c,y.type)),l(y),e.onRecordingComplete(y),a.current=[]}}),T.start(),n(!0)}catch(g){console.error("Error accessing microphone:",g)}},m=()=>{s.current&&s.current.state==="recording"&&(s.current.stop(),o(0),n(!1))};return w.useEffect(()=>{if(t){const h=setInterval(()=>{o(g=>g+1)},1e3);return()=>{clearInterval(h)}}return()=>{}},[t]),I("div",{className:"flex flex-col justify-center items-center",children:[C("button",{type:"button",className:`m-2 inline-flex justify-center rounded-md border border-transparent px-4 py-2 text-sm font-medium text-white focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 transition-all duration-200 ${t?"bg-red-500 hover:bg-red-600":"bg-green-500 hover:bg-green-600"}`,onClick:()=>{t?m():p()},children:t?`Stop Recording (${np(r)})`:"Start Recording"}),i&&C("audio",{className:"w-full",ref:d,controls:!0,children:C("source",{src:URL.createObjectURL(i),type:i.type})})]})}function Z1(e){return e=e.toLowerCase(),(e.match(/\w+.?/g)||[]).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}const rc={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 eg(e){const[t,n]=w.useState(void 0),[r,o]=w.useState(void 0),[i,l]=w.useState(void 0),u=t!==void 0,s=()=>{o(void 0),l(void 0)},a=async(m,v)=>{const h=new AudioContext({sampleRate:ft.SAMPLING_RATE}),g=URL.createObjectURL(new Blob([m],{type:"audio/*"})),T=await h.decodeAudioData(m);o({buffer:T,url:g,source:"URL",mimeType:v})},d=async m=>{s(),n(0);const v=URL.createObjectURL(m),h=new FileReader;h.onprogress=g=>{n(g.loaded/g.total||0)},h.onloadend=async()=>{const g=new AudioContext({sampleRate:ft.SAMPLING_RATE}),T=h.result,f=await g.decodeAudioData(T);n(void 0),o({buffer:f,url:v,source:"RECORDING",mimeType:m.type})},h.readAsArrayBuffer(m)},p=async m=>{if(i)try{o(void 0),n(0);const{data:v,headers:h}=await G0.get(i,{signal:m.signal,responseType:"arraybuffer",onDownloadProgress(T){n(T.progress||0)}});let g=h["content-type"];(!g||g==="audio/wave")&&(g="audio/wav"),a(v,g)}catch(v){console.log("Request failed or aborted",v)}finally{n(void 0)}};return w.useEffect(()=>{if(i){const m=new AbortController;return p(m),()=>{m.abort()}}},[i]),I(nt,{children:[I("div",{className:"flex flex-col justify-center items-center rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10",children:[I("div",{className:"flex flex-row space-x-2 py-2 w-full px-2",children:[C(ig,{icon:C(cg,{}),text:"From URL",onUrlUpdate:m=>{e.transcriber.onInputChange(),l(m)}}),C(oc,{}),C(ug,{icon:C(dg,{}),text:"From file",onFileUpdate:(m,v,h)=>{e.transcriber.onInputChange(),o({buffer:m,url:v,source:"FILE",mimeType:h})}}),navigator.mediaDevices&&I(nt,{children:[C(oc,{}),C(sg,{icon:C(pg,{}),text:"Record",setAudioData:m=>{e.transcriber.onInputChange(),d(m)}})]})]}),C(rg,{progress:u?t:+!!r})]}),r&&I(nt,{children:[C(H1,{audioUrl:r.url,mimeType:r.mimeType}),I("div",{className:"relative w-full flex justify-center items-center",children:[C(V1,{onClick:()=>{e.transcriber.start(r.buffer)},isModelLoading:e.transcriber.isModelLoading,isTranscribing:e.transcriber.isBusy}),C(tg,{className:"absolute right-4",transcriber:e.transcriber,icon:C(fg,{})})]}),e.transcriber.progressItems.length>0&&I("div",{className:"relative z-10 p-4 w-full",children:[C("label",{children:"Loading model files... (only run once)"}),e.transcriber.progressItems.map(m=>C("div",{children:C(Q1,{text:m.file,percentage:m.progress})},m.file))]})]})]})}function tg(e){const[t,n]=w.useState(!1),r=()=>{n(!0)},o=()=>{n(!1)},i=l=>{o()};return I("div",{className:e.className,children:[C(Fi,{icon:e.icon,onClick:r}),C(ng,{show:t,onSubmit:i,onClose:o,transcriber:e.transcriber})]})}function ng(e){const t=Object.values(rc).map(Z1),n={"distil-whisper/distil-small.en":[172],"distil-whisper/distil-medium.en":[402],"distil-whisper/distil-large-v2":[767]};return C(_s,{show:e.show,title:"Settings",content:I(nt,{children:[C("label",{children:"Select the model to use."}),C("select",{className:"mt-1 mb-1 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",defaultValue:e.transcriber.model,onChange:r=>{e.transcriber.setModel(r.target.value)},children:Object.keys(n).map(r=>C("option",{value:r,children:`${r} (${n[r][0]}MB)`},r))}),I("div",{className:"flex justify-between items-center mb-3 px-1",children:[I("div",{className:"flex",children:[C("input",{id:"multilingual",type:"checkbox",disabled:!0,checked:e.transcriber.multilingual,onChange:r=>{e.transcriber.setMultilingual(r.target.checked)}}),C("label",{htmlFor:"multilingual",className:"ms-1",children:"Multilingual (coming soon)"})]}),I("div",{className:"flex",children:[C("input",{id:"quantize",type:"checkbox",disabled:!0,checked:e.transcriber.quantized,onChange:r=>{e.transcriber.setQuantized(r.target.checked)}}),C("label",{htmlFor:"quantize",className:"ms-1",children:"Quantized"})]})]}),e.transcriber.multilingual&&I(nt,{children:[C("label",{children:"Select the source language."}),C("select",{className:"mt-1 mb-3 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",defaultValue:e.transcriber.language,onChange:r=>{e.transcriber.setLanguage(r.target.value)},children:Object.keys(rc).map((r,o)=>C("option",{value:r,children:t[o]},r))}),C("label",{children:"Select the task to perform."}),I("select",{className:"mt-1 mb-3 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",defaultValue:e.transcriber.subtask,onChange:r=>{e.transcriber.setSubtask(r.target.value)},children:[C("option",{value:"transcribe",children:"Transcribe"}),C("option",{value:"translate",children:"Translate (to English)"})]})]})]}),onClose:e.onClose,onSubmit:()=>{}})}function oc(){return C("div",{className:"w-[1px] bg-slate-200"})}function rg(e){return C(og,{progress:`${Math.round(e.progress*100)}%`})}function og(e){return C("div",{className:"w-full bg-gray-200 rounded-full h-1 dark:bg-gray-700",children:C("div",{className:"bg-blue-600 h-1 rounded-full transition-all duration-100",style:{width:e.progress}})})}function ig(e){const[t,n]=w.useState(!1),r=()=>{n(!0)},o=()=>{n(!1)},i=l=>{e.onUrlUpdate(l),o()};return I(nt,{children:[C(Fi,{icon:e.icon,text:e.text,onClick:r}),C(lg,{show:t,onSubmit:i,onClose:o})]})}function lg(e){const[t,n]=w.useState(ft.DEFAULT_AUDIO_URL),r=i=>{n(i.target.value)},o=()=>{e.onSubmit(t)};return C(_s,{show:e.show,title:"From URL",content:I(nt,{children:["Enter the URL of the audio file you want to load.",C(j1,{onChange:r,value:t})]}),onClose:e.onClose,submitText:"Load",onSubmit:o})}function ug(e){let t=document.createElement("input");return t.type="file",t.oninput=n=>{let r=n.target.files;if(!r)return;const o=URL.createObjectURL(r[0]),i=r[0].type,l=new FileReader;l.addEventListener("load",async u=>{var p;const s=(p=u.target)==null?void 0:p.result;if(!s)return;const d=await new AudioContext({sampleRate:ft.SAMPLING_RATE}).decodeAudioData(s);e.onFileUpdate(d,o,i)}),l.readAsArrayBuffer(r[0]),t.value=""},C(nt,{children:C(Fi,{icon:e.icon,text:e.text,onClick:()=>t.click()})})}function sg(e){const[t,n]=w.useState(!1),r=()=>{n(!0)},o=()=>{n(!1)},i=l=>{l&&(e.setAudioData(l),o())};return I(nt,{children:[C(Fi,{icon:e.icon,text:e.text,onClick:r}),C(ag,{show:t,onSubmit:i,onClose:o})]})}function ag(e){const[t,n]=w.useState(),r=l=>{n(l)},o=()=>{e.onSubmit(t),n(void 0)},i=()=>{e.onClose(),n(void 0)};return C(_s,{show:e.show,title:"From Recording",content:I(nt,{children:["Record audio using your microphone",C(J1,{onRecordingComplete:r})]}),onClose:i,submitText:"Load",submitEnabled:t!==void 0,onSubmit:o})}function Fi(e){return I("button",{onClick:e.onClick,className:"flex items-center justify-center rounded-lg p-2 bg-blue text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-all duration-200",children:[C("div",{className:"w-7 h-7",children:e.icon}),e.text&&C("div",{className:"ml-2 break-text text-center text-md w-30",children:e.text})]})}function cg(){return C("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:C("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"})})}function dg(){return C("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:C("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})})}function fg(){return I("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.25",stroke:"currentColor",children:[C("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z"}),C("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function pg(){return C("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:C("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z"})})}function mg({transcribedData:e}){const t=w.useRef(null),n=(i,l)=>{const u=URL.createObjectURL(i),s=document.createElement("a");s.href=u,s.download=l,s.click(),URL.revokeObjectURL(u)},r=()=>{let l=((e==null?void 0:e.chunks)??[]).map(s=>s.text).join("").trim();const u=new Blob([l],{type:"text/plain"});n(u,"transcript.txt")},o=()=>{let i=JSON.stringify((e==null?void 0:e.chunks)??[],null,2);const l=/( "timestamp": )\[\s+(\S+)\s+(\S+)\s+\]/gm;i=i.replace(l,"$1[$2 $3]");const u=new Blob([i],{type:"application/json"});n(u,"transcript.json")};return w.useEffect(()=>{t.current&&Math.abs(t.current.offsetHeight+t.current.scrollTop-t.current.scrollHeight)<=64&&(t.current.scrollTop=t.current.scrollHeight)}),I("div",{ref:t,className:"w-full flex flex-col my-2 p-4 max-h-[20rem] overflow-y-auto",children:[(e==null?void 0:e.chunks)&&e.chunks.map((i,l)=>I("div",{className:"w-full flex flex-row mb-2 bg-white rounded-lg p-4 shadow-xl shadow-black/5 ring-1 ring-slate-700/10",children:[C("div",{className:"mr-5",children:np(i.timestamp[0])}),i.text]},`${l}-${i.text}`)),e&&!e.isBusy&&I("div",{className:"w-full text-right",children:[C("button",{onClick:r,className:"text-white bg-green-500 hover:bg-green-600 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-4 py-2 text-center mr-2 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800 inline-flex items-center",children:"Export TXT"}),C("button",{onClick:o,className:"text-white bg-green-500 hover:bg-green-600 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-4 py-2 text-center mr-2 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800 inline-flex items-center",children:"Export JSON"})]})]})}function hg(e){const[t]=w.useState(()=>yg(e));return t}function yg(e){const t=new Worker(new URL("/assets/worker-ec0b2923.js",self.location),{type:"module"});return t.addEventListener("message",e),t}function gg(){const[e,t]=w.useState(void 0),[n,r]=w.useState(!1),[o,i]=w.useState(!1),[l,u]=w.useState([]),s=hg(P=>{const x=P.data;switch(x.status){case"progress":u(U=>U.map(j=>j.file===x.file?{...j,progress:x.progress}:j));break;case"update":const L=x;t({isBusy:!0,text:L.data[0],chunks:L.data[1].chunks});break;case"complete":const A=x;t({isBusy:!1,text:A.data.text,chunks:A.data.chunks}),r(!1);break;case"initiate":i(!0),u(U=>[...U,x]);break;case"ready":i(!1);break;case"error":r(!1),alert(`${x.data.message} This is most likely because you are using Safari on an M1/M2 Mac. Please try again from Chrome, Firefox, or Edge. + +If this is not the case, please file a bug report.`);break;case"done":u(U=>U.filter(j=>j.file!==x.file));break}}),[a,d]=w.useState(ft.DEFAULT_MODEL),[p,m]=w.useState(ft.DEFAULT_SUBTASK),[v,h]=w.useState(ft.DEFAULT_QUANTIZED),[g,T]=w.useState(ft.DEFAULT_MULTILINGUAL),[f,c]=w.useState(ft.DEFAULT_LANGUAGE),y=w.useCallback(()=>{t(void 0)},[]),k=w.useCallback(async P=>{if(P){t(void 0),r(!0);let x;if(P.numberOfChannels===2){const L=Math.sqrt(2);let A=P.getChannelData(0),U=P.getChannelData(1);x=new Float32Array(A.length);for(let j=0;j({onInputChange:y,isBusy:n,isModelLoading:o,progressItems:l,start:k,output:e,model:a,setModel:d,multilingual:g,setMultilingual:T,quantized:v,setQuantized:h,subtask:p,setSubtask:m,language:f,setLanguage:c}),[n,o,l,k,e,a,g,v,p,f])}function vg(){const e=gg();return I("div",{className:"flex justify-center items-center min-h-screen",children:[I("div",{className:"container flex flex-col justify-center items-center",children:[C("h1",{className:"text-5xl font-extrabold tracking-tight text-slate-900 sm:text-6xl text-center",children:"Distil-Whisper Web"}),C("h2",{className:"mt-3 mb-5 px-4 text-center text-1xl font-semibold tracking-tight text-slate-900 sm:text-2xl",children:"ML-powered speech recognition directly in your browser"}),C(eg,{transcriber:e}),C(mg,{transcribedData:e.output})]}),I("div",{className:"absolute bottom-4",children:["Made with"," ",C("a",{className:"underline",href:"https://github.com/xenova/transformers.js",children:"🤗 Transformers.js"})]})]})}kl.createRoot(document.getElementById("root")).render(C(M.StrictMode,{children:C(vg,{})})); diff --git a/assets/worker-ec0b2923.js b/assets/worker-ec0b2923.js new file mode 100644 index 0000000000000000000000000000000000000000..7e1530f8d5d951133fa5fbb3c9de0bdb0c202ed7 --- /dev/null +++ b/assets/worker-ec0b2923.js @@ -0,0 +1,1790 @@ +var fn=Object.defineProperty;var gn=(nt,m,t)=>m in nt?fn(nt,m,{enumerable:!0,configurable:!0,writable:!0,value:t}):nt[m]=t;var le=(nt,m,t)=>(gn(nt,typeof m!="symbol"?m+"":m,t),t);(function(){var nt;"use strict";function _mergeNamespaces(m,t){return t.forEach(function(i){i&&typeof i!="string"&&!Array.isArray(i)&&Object.keys(i).forEach(function(s){if(s!=="default"&&!(s in m)){var u=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(m,s,u.get?u:{enumerable:!0,get:function(){return i[s]}})}})}),Object.freeze(m)}function dispatchCallback(m,t){m&&m(t)}function reverseDictionary(m){return Object.fromEntries(Object.entries(m).map(([t,i])=>[i,t]))}function escapeRegExp(m){return m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Callable=class{constructor(){let m=function(...t){return m._call(...t)};return Object.setPrototypeOf(m,new.target.prototype)}_call(...m){throw Error("Must implement _call method in subclass")}};function isString(m){return typeof m=="string"||m instanceof String}function isTypedArray(m){var t,i,s;return((s=(i=(t=m==null?void 0:m.prototype)==null?void 0:t.__proto__)==null?void 0:i.constructor)==null?void 0:s.name)==="TypedArray"}function isIntegralNumber(m){return Number.isInteger(m)||typeof m=="bigint"}function exists(m){return m!=null}function calculateDimensions(m){const t=[];let i=m;for(;Array.isArray(i);)t.push(i.length),i=i[0];return t}function pop(m,t,i=void 0){const s=m[t];if(s!==void 0)return delete m[t],s;if(i===void 0)throw Error(`Key ${t} does not exist in object.`);return i}function mergeArrays(...m){return Array.prototype.concat.apply([],m)}function product(...m){return m.reduce((t,i)=>t.flatMap(s=>i.map(u=>[s,u])))}function calculateReflectOffset(m,t){return Math.abs((m+t)%(2*t)-t)}function get_bounding_box(m,t){t&&(m=m.map(a=>a|0));const[i,s,u,d]=m;return{xmin:i,ymin:s,xmax:u,ymax:d}}var sharp={},ONNX_NODE=Object.freeze({__proto__:null,default:sharp});function getDefaultExportFromCjs(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}function getAugmentedNamespace(m){if(m.__esModule)return m;var t=m.default;if(typeof t=="function"){var i=function s(){if(this instanceof s){var u=[null];u.push.apply(u,arguments);var d=Function.bind.apply(t,u);return new d}return t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(m).forEach(function(s){var u=Object.getOwnPropertyDescriptor(m,s);Object.defineProperty(i,s,u.get?u:{enumerable:!0,get:function(){return m[s]}})}),i}var ortWeb_min$1={exports:{}};const backends={},backendsSortedByPriority=[],registerBackend=(m,t,i)=>{if(t&&typeof t.init=="function"&&typeof t.createSessionHandler=="function"){const s=backends[m];if(s===void 0)backends[m]={backend:t,priority:i};else{if(s.priority>i)return;if(s.priority===i&&s.backend!==t)throw new Error(`cannot register backend "${m}" using priority ${i}`)}if(i>=0){const u=backendsSortedByPriority.indexOf(m);u!==-1&&backendsSortedByPriority.splice(u,1);for(let d=0;d{const t=m.length===0?backendsSortedByPriority:m,i=[];for(const s of t){const u=backends[s];if(u){if(u.initialized)return u.backend;if(u.aborted)continue;const d=!!u.initPromise;try{return d||(u.initPromise=u.backend.init()),await u.initPromise,u.initialized=!0,u.backend}catch(a){d||i.push({name:s,err:a}),u.aborted=!0}finally{delete u.initPromise}}}throw new Error(`no available backend found. ERR: ${i.map(s=>`[${s.name}] ${s.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);this.logLevelInternal=t}}get logLevel(){return this.logLevelInternal}}const env$2=new EnvImpl,isBigInt64ArrayAvailable=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",isBigUint64ArrayAvailable=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function",NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);isBigInt64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64")),isBigUint64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64"));const calculateSize=m=>{let t=1;for(let i=0;i{const n=document.createElement("canvas"),e=n.getContext("2d");if(!t||!e)return l();const r=new Image;r.crossOrigin="Anonymous",r.src=t,r.onload=()=>{n.width=r.width,n.height=r.height,e.drawImage(r,0,0,n.width,n.height);const o=e.getImageData(0,0,n.width,n.height);if(i!==void 0){if(i.height!==void 0&&i.height!==n.height)throw new Error("Image input config height doesn't match ImageBitmap height");if(f.height=n.height,i.width!==void 0&&i.width!==n.width)throw new Error("Image input config width doesn't match ImageBitmap width");f.width=n.width}else f.height=n.height,f.width=n.width;c(lt.bufferToTensor(o.data,f))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(h!==void 0)return lt.bufferToTensor(h,f);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(t){var i,s;const u=document.createElement("canvas").getContext("2d");let d;if(u!=null){const a=this.dims[3],h=this.dims[2],f=this.dims[1],c=t!==void 0&&t.format!==void 0?t.format:"RGB",l=t!==void 0&&((i=t.norm)===null||i===void 0?void 0:i.mean)!==void 0?t.norm.mean:255,n=t!==void 0&&((s=t.norm)===null||s===void 0?void 0:s.bias)!==void 0?t.norm.bias:0,e=h*a;if(t!==void 0){if(t.height!==void 0&&t.height!==h)throw new Error("Image output config height doesn't match tensor height");if(t.width!==void 0&&t.width!==a)throw new Error("Image output config width doesn't match tensor width");if(t.format!==void 0&&f===4&&t.format!=="RGBA"||f===3&&t.format!=="RGB"&&t.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const r=4;let o=0,p=1,g=2,_=3,b=0,y=e,w=e*2,T=-1;c==="RGBA"?(b=0,y=e,w=e*2,T=e*3):c==="RGB"?(b=0,y=e,w=e*2):c==="RBG"&&(b=0,w=e,y=e*2),d=u.createImageData(a,h);for(let S=0;S"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(const c of this.outputNames)u[c]=null;const h=await this.handler.run(t,u,d),f={};for(const c in h)Object.hasOwnProperty.call(h,c)&&(f[c]=new Tensor$1(h[c].type,h[c].data,h[c].dims));return f}static async create(t,i,s,u){let d,a={};if(typeof t=="string"){if(d=t,typeof i=="object"&&i!==null)a=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(d=t,typeof i=="object"&&i!==null)a=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){const n=t;let e=0,r=t.byteLength;if(typeof i=="object"&&i!==null)a=i;else if(typeof i=="number"){if(e=i,!Number.isSafeInteger(e))throw new RangeError("'byteOffset' must be an integer.");if(e<0||e>=n.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${n.byteLength}).`);if(r=t.byteLength-e,typeof s=="number"){if(r=s,!Number.isSafeInteger(r))throw new RangeError("'byteLength' must be an integer.");if(r<=0||e+r>n.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${n.byteLength-e}].`);if(typeof u=="object"&&u!==null)a=u;else if(typeof u<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof i<"u")throw new TypeError("'options' must be an object.");d=new Uint8Array(n,e,r)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const f=(a.executionProviders||[]).map(n=>typeof n=="string"?n:n.name),l=await(await resolveBackend(f)).createSessionHandler(d,a);return new dn(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const InferenceSession$1=InferenceSession$2;var lib=Object.freeze({__proto__:null,InferenceSession:InferenceSession$1,Tensor:Tensor$1,env:env$2,registerBackend}),require$$0=getAugmentedNamespace(lib);/*! +* ONNX Runtime Web v1.14.0 +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. +*/(function(module,exports){(function(m,t){module.exports=t(require$$0)})(self,__WEBPACK_EXTERNAL_MODULE__1670__=>(()=>{var __webpack_modules__={3474:(m,t,i)=>{var s,u=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(d){function a(){return V.buffer!=Z&&Me(V.buffer),ue}function h(){return V.buffer!=Z&&Me(V.buffer),Ae}function f(){return V.buffer!=Z&&Me(V.buffer),xe}function c(){return V.buffer!=Z&&Me(V.buffer),se}function l(){return V.buffer!=Z&&Me(V.buffer),we}var n,e,r;d=d||{},n||(n=d!==void 0?d:{}),n.ready=new Promise(function(v,O){e=v,r=O});var o,p,g,_,b,y,w=Object.assign({},n),T="./this.program",S=(v,O)=>{throw O},A=typeof window=="object",P=typeof importScripts=="function",x=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",M=n.ENVIRONMENT_IS_PTHREAD||!1,N="";function z(v){return n.locateFile?n.locateFile(v,N):N+v}if(x){let v;N=P?i(908).dirname(N)+"/":"//",y=()=>{b||(_=i(1384),b=i(908))},o=function(O,k){return y(),O=b.normalize(O),_.readFileSync(O,k?void 0:"utf8")},g=O=>((O=o(O,!0)).buffer||(O=new Uint8Array(O)),O),p=(O,k,F)=>{y(),O=b.normalize(O),_.readFile(O,function(B,q){B?F(B):k(q.buffer)})},1{if(qe())throw process.exitCode=O,k;k instanceof Ze||R("exiting due to exception: "+k),process.exit(O)},n.inspect=function(){return"[Emscripten Module object]"};try{v=i(9925)}catch(O){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),O}i.g.Worker=v.Worker}else(A||P)&&(P?N=self.location.href:typeof document<"u"&&document.currentScript&&(N=document.currentScript.src),s&&(N=s),N=N.indexOf("blob:")!==0?N.substr(0,N.replace(/[?#].*/,"").lastIndexOf("/")+1):"",x||(o=v=>{var O=new XMLHttpRequest;return O.open("GET",v,!1),O.send(null),O.responseText},P&&(g=v=>{var O=new XMLHttpRequest;return O.open("GET",v,!1),O.responseType="arraybuffer",O.send(null),new Uint8Array(O.response)}),p=(v,O,k)=>{var F=new XMLHttpRequest;F.open("GET",v,!0),F.responseType="arraybuffer",F.onload=()=>{F.status==200||F.status==0&&F.response?O(F.response):k()},F.onerror=k,F.send(null)}));x&&typeof performance>"u"&&(i.g.performance=i(6953).performance);var $=console.log.bind(console),C=console.warn.bind(console);x&&(y(),$=v=>_.writeSync(1,v+` +`),C=v=>_.writeSync(2,v+` +`));var G,D=n.print||$,R=n.printErr||C;Object.assign(n,w),w=null,n.thisProgram&&(T=n.thisProgram),n.quit&&(S=n.quit),n.wasmBinary&&(G=n.wasmBinary);var Y=n.noExitRuntime||!1;typeof WebAssembly!="object"&&ge("no native wasm support detected");var V,J,Z,ue,Ae,xe,se,we,be=!1,Ie=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Le(v,O,k){var F=(O>>>=0)+k;for(k=O;v[k]&&!(k>=F);)++k;if(16(B=(240&B)==224?(15&B)<<12|q<<6|Q:(7&B)<<18|q<<12|Q<<6|63&v[O++])?F+=String.fromCharCode(B):(B-=65536,F+=String.fromCharCode(55296|B>>10,56320|1023&B))}}else F+=String.fromCharCode(B)}return F}function ve(v,O){return(v>>>=0)?Le(h(),v,O):""}function $e(v,O,k,F){if(!(0>>=0;F=k+F-1;for(var q=0;q=Q&&(Q=65536+((1023&Q)<<10)|1023&v.charCodeAt(++q)),127>=Q){if(k>=F)break;O[k++>>>0]=Q}else{if(2047>=Q){if(k+1>=F)break;O[k++>>>0]=192|Q>>6}else{if(65535>=Q){if(k+2>=F)break;O[k++>>>0]=224|Q>>12}else{if(k+3>=F)break;O[k++>>>0]=240|Q>>18,O[k++>>>0]=128|Q>>12&63}O[k++>>>0]=128|Q>>6&63}O[k++>>>0]=128|63&Q}}return O[k>>>0]=0,k-B}function Fe(v){for(var O=0,k=0;k=F?O++:2047>=F?O+=2:55296<=F&&57343>=F?(O+=4,++k):O+=3}return O}function Me(v){Z=v,n.HEAP8=ue=new Int8Array(v),n.HEAP16=new Int16Array(v),n.HEAP32=xe=new Int32Array(v),n.HEAPU8=Ae=new Uint8Array(v),n.HEAPU16=new Uint16Array(v),n.HEAPU32=se=new Uint32Array(v),n.HEAPF32=new Float32Array(v),n.HEAPF64=we=new Float64Array(v)}M&&(Z=n.buffer);var Pe=n.INITIAL_MEMORY||16777216;if(M)V=n.wasmMemory,Z=n.buffer;else if(n.wasmMemory)V=n.wasmMemory;else if(!((V=new WebAssembly.Memory({initial:Pe/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw R("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),x&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");V&&(Z=V.buffer),Pe=Z.byteLength,Me(Z);var Be,Ge=[],Ve=[],Xe=[],Qe=[];function qe(){return Y||!1}function Ue(){var v=n.preRun.shift();Ge.unshift(v)}var Ee,ze=0,Ye=null;function ge(v){throw M?postMessage({cmd:"onAbort",arg:v}):n.onAbort&&n.onAbort(v),R(v="Aborted("+v+")"),be=!0,v=new WebAssembly.RuntimeError(v+". Build with -sASSERTIONS for more info."),r(v),v}function pt(){return Ee.startsWith("data:application/octet-stream;base64,")}function ut(){var v=Ee;try{if(v==Ee&&G)return new Uint8Array(G);if(g)return g(v);throw"both async and sync fetching of the wasm failed"}catch(O){ge(O)}}Ee="ort-wasm-threaded.wasm",pt()||(Ee=z(Ee));var Et={};function Ze(v){this.name="ExitStatus",this.message="Program terminated with exit("+v+")",this.status=v}function ct(v){(v=re.Vb[v])||ge(),re.mc(v)}function dt(v){var O=re.Cc();if(!O)return 6;re.ac.push(O),re.Vb[v.Ub]=O,O.Ub=v.Ub;var k={cmd:"run",start_routine:v.Ic,arg:v.zc,pthread_ptr:v.Ub};return O.$b=()=>{k.time=performance.now(),O.postMessage(k,v.Nc)},O.loaded&&(O.$b(),delete O.$b),0}function Re(v){if(M)return ee(1,1,v);qe()||(re.oc(),n.onExit&&n.onExit(v),be=!0),S(v,new Ze(v))}function it(v,O){if(!O&&M)throw kt(v),"unwind";qe()||M||(Wt(),rt(Xe),qt(0),Nt[1].length&&Lt(1,10),Nt[2].length&&Lt(2,10),re.oc()),Re(v)}var re={Yb:[],ac:[],qc:[],Vb:{},fc:function(){M&&re.Ec()},Pc:function(){},Ec:function(){re.receiveObjectTransfer=re.Gc,re.threadInitTLS=re.pc,re.setExitStatus=re.nc,Y=!1},nc:function(){},oc:function(){for(var v of Object.values(re.Vb))re.mc(v);for(v of re.Yb)v.terminate();re.Yb=[]},mc:function(v){var O=v.Ub;delete re.Vb[O],re.Yb.push(v),re.ac.splice(re.ac.indexOf(v),1),v.Ub=0,Rt(O)},Gc:function(){},pc:function(){re.qc.forEach(v=>v())},Fc:function(v,O){v.onmessage=k=>{var F=(k=k.data).cmd;if(v.Ub&&(re.Bc=v.Ub),k.targetThread&&k.targetThread!=Dt()){var B=re.Vb[k.Qc];B?B.postMessage(k,k.transferList):R('Internal error! Worker sent a message "'+F+'" to target pthread '+k.targetThread+", but that thread no longer exists!")}else F==="processProxyingQueue"?L(k.queue):F==="spawnThread"?dt(k):F==="cleanupThread"?ct(k.thread):F==="killThread"?(k=k.thread,F=re.Vb[k],delete re.Vb[k],F.terminate(),Rt(k),re.ac.splice(re.ac.indexOf(F),1),F.Ub=0):F==="cancelThread"?re.Vb[k.thread].postMessage({cmd:"cancel"}):F==="loaded"?(v.loaded=!0,O&&O(v),v.$b&&(v.$b(),delete v.$b)):F==="print"?D("Thread "+k.threadId+": "+k.text):F==="printErr"?R("Thread "+k.threadId+": "+k.text):F==="alert"?alert("Thread "+k.threadId+": "+k.text):k.target==="setimmediate"?v.postMessage(k):F==="onAbort"?n.onAbort&&n.onAbort(k.arg):F&&R("worker sent an unknown command "+F);re.Bc=void 0},v.onerror=k=>{throw R("worker sent an error! "+k.filename+":"+k.lineno+": "+k.message),k},x&&(v.on("message",function(k){v.onmessage({data:k})}),v.on("error",function(k){v.onerror(k)}),v.on("detachedExit",function(){})),v.postMessage({cmd:"load",urlOrBlob:n.mainScriptUrlOrBlob||s,wasmMemory:V,wasmModule:J})},yc:function(){var v=z("ort-wasm-threaded.worker.js");re.Yb.push(new Worker(v))},Cc:function(){return re.Yb.length==0&&(re.yc(),re.Fc(re.Yb[0])),re.Yb.pop()}};function rt(v){for(;0>2>>>0];v=f()[v+48>>2>>>0],Qt(O,O-v),de(O)};var Je=[];function Te(v){var O=Je[v];return O||(v>=Je.length&&(Je.length=v+1),Je[v]=O=Be.get(v)),O}n.invokeEntryPoint=function(v,O){v=Te(v)(O),qe()?re.nc(v):Kt(v)};var ot,ft,st=[],ae=0,ie=0;function oe(v){this.Zb=v,this.Sb=v-24,this.xc=function(O){c()[this.Sb+4>>2>>>0]=O},this.bc=function(){return c()[this.Sb+4>>2>>>0]},this.wc=function(O){c()[this.Sb+8>>2>>>0]=O},this.Dc=function(){return c()[this.Sb+8>>2>>>0]},this.rc=function(){f()[this.Sb>>2>>>0]=0},this.hc=function(O){O=O?1:0,a()[this.Sb+12>>0>>>0]=O},this.uc=function(){return a()[this.Sb+12>>0>>>0]!=0},this.ic=function(O){O=O?1:0,a()[this.Sb+13>>0>>>0]=O},this.kc=function(){return a()[this.Sb+13>>0>>>0]!=0},this.fc=function(O,k){this.cc(0),this.xc(O),this.wc(k),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(f(),this.Sb>>2,1)},this.Hc=function(){return Atomics.sub(f(),this.Sb>>2,1)===1},this.cc=function(O){c()[this.Sb+16>>2>>>0]=O},this.tc=function(){return c()[this.Sb+16>>2>>>0]},this.vc=function(){if(Zt(this.bc()))return c()[this.Zb>>2>>>0];var O=this.tc();return O!==0?O:this.Zb}}function gt(v){return Vt(new oe(v).Sb)}function at(v,O,k,F){return M?ee(3,1,v,O,k,F):mt(v,O,k,F)}function mt(v,O,k,F){if(typeof SharedArrayBuffer>"u")return R("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var B=[];return M&&B.length===0?at(v,O,k,F):(v={Ic:k,Ub:v,zc:F,Nc:B},M?(v.Oc="spawnThread",postMessage(v,B),0):dt(v))}function _t(v,O,k){return M?ee(4,1,v,O,k):0}function bt(v,O){if(M)return ee(5,1,v,O)}function yt(v,O){if(M)return ee(6,1,v,O)}function wt(v,O,k){if(M)return ee(7,1,v,O,k)}function Tt(v,O,k){return M?ee(8,1,v,O,k):0}function xt(v,O){if(M)return ee(9,1,v,O)}function vt(v,O,k){if(M)return ee(10,1,v,O,k)}function St(v,O,k,F){if(M)return ee(11,1,v,O,k,F)}function At(v,O,k,F){if(M)return ee(12,1,v,O,k,F)}function Pt(v,O,k,F){if(M)return ee(13,1,v,O,k,F)}function Ot(v){if(M)return ee(14,1,v)}function E(v,O){if(M)return ee(15,1,v,O)}function I(v,O,k){if(M)return ee(16,1,v,O,k)}function L(v){Atomics.store(f(),v>>2,1),Dt()&&Yt(v),Atomics.compareExchange(f(),v>>2,1,0)}function j(v){return c()[v>>>2]+4294967296*f()[v+4>>>2]}function U(v,O,k,F,B,q){return M?ee(17,1,v,O,k,F,B,q):-52}function X(v,O,k,F,B,q){if(M)return ee(18,1,v,O,k,F,B,q)}function K(v){var O=Fe(v)+1,k=$t(O);return k&&$e(v,a(),k,O),k}function te(v,O,k){function F(me){return(me=me.toTimeString().match(/\(([A-Za-z ]+)\)$/))?me[1]:"GMT"}if(M)return ee(19,1,v,O,k);var B=new Date().getFullYear(),q=new Date(B,0,1),Q=new Date(B,6,1);B=q.getTimezoneOffset();var ne=Q.getTimezoneOffset(),fe=Math.max(B,ne);f()[v>>2>>>0]=60*fe,f()[O>>2>>>0]=+(B!=ne),v=F(q),O=F(Q),v=K(v),O=K(O),ne>2>>>0]=v,c()[k+4>>2>>>0]=O):(c()[k>>2>>>0]=O,c()[k+4>>2>>>0]=v)}function ee(v,O){var k=arguments.length-2,F=arguments;return Mt(()=>{for(var B=zt(8*k),q=B>>3,Q=0;Q>>0]=ne}return Xt(v,k,B,O)})}n.executeNotifiedProxyingQueue=L,ft=x?()=>{var v=process.hrtime();return 1e3*v[0]+v[1]/1e6}:M?()=>performance.now()-n.__performance_now_clock_drift:()=>performance.now();var ce,Se=[],Ne={};function Ce(){if(!ce){var v,O={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:T||"./this.program"};for(v in Ne)Ne[v]===void 0?delete O[v]:O[v]=Ne[v];var k=[];for(v in O)k.push(v+"="+O[v]);ce=k}return ce}function W(v,O){if(M)return ee(20,1,v,O);var k=0;return Ce().forEach(function(F,B){var q=O+k;for(B=c()[v+4*B>>2>>>0]=q,q=0;q>0>>>0]=F.charCodeAt(q);a()[B>>0>>>0]=0,k+=F.length+1}),0}function _e(v,O){if(M)return ee(21,1,v,O);var k=Ce();c()[v>>2>>>0]=k.length;var F=0;return k.forEach(function(B){F+=B.length+1}),c()[O>>2>>>0]=F,0}function Oe(v){return M?ee(22,1,v):52}function We(v,O,k,F){return M?ee(23,1,v,O,k,F):52}function et(v,O,k,F,B){return M?ee(24,1,v,O,k,F,B):70}var Nt=[null,[],[]];function Lt(v,O){var k=Nt[v];O===0||O===10?((v===1?D:R)(Le(k,0)),k.length=0):k.push(O)}function jt(v,O,k,F){if(M)return ee(25,1,v,O,k,F);for(var B=0,q=0;q>2>>>0],ne=c()[O+4>>2>>>0];O+=8;for(var fe=0;fe>>0]);B+=ne}return c()[F>>2>>>0]=B,0}var je=0;function It(v){return v%4==0&&(v%100!=0||v%400==0)}var Bt=[31,29,31,30,31,30,31,31,30,31,30,31],Ut=[31,28,31,30,31,30,31,31,30,31,30,31];function Gt(v,O,k,F){function B(H,ye,ke){for(H=typeof H=="number"?H.toString():H||"";H.lengthht?-1:0tt-H.getDate())){H.setDate(H.getDate()+ye);break}ye-=tt-H.getDate()+1,H.setDate(1),11>ke?H.setMonth(ke+1):(H.setMonth(0),H.setFullYear(H.getFullYear()+1))}return ke=new Date(H.getFullYear()+1,0,4),ye=ne(new Date(H.getFullYear(),0,4)),ke=ne(ke),0>=Q(ye,H)?0>=Q(ke,H)?H.getFullYear()+1:H.getFullYear():H.getFullYear()-1}var me=f()[F+40>>2>>>0];for(var De in F={Lc:f()[F>>2>>>0],Kc:f()[F+4>>2>>>0],dc:f()[F+8>>2>>>0],jc:f()[F+12>>2>>>0],ec:f()[F+16>>2>>>0],Xb:f()[F+20>>2>>>0],Tb:f()[F+24>>2>>>0],Wb:f()[F+28>>2>>>0],Rc:f()[F+32>>2>>>0],Jc:f()[F+36>>2>>>0],Mc:me?ve(me):""},k=ve(k),me={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})k=k.replace(new RegExp(De,"g"),me[De]);var Ke="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),He="January February March April May June July August September October November December".split(" ");for(De in me={"%a":function(H){return Ke[H.Tb].substring(0,3)},"%A":function(H){return Ke[H.Tb]},"%b":function(H){return He[H.ec].substring(0,3)},"%B":function(H){return He[H.ec]},"%C":function(H){return q((H.Xb+1900)/100|0,2)},"%d":function(H){return q(H.jc,2)},"%e":function(H){return B(H.jc,2," ")},"%g":function(H){return fe(H).toString().substring(2)},"%G":function(H){return fe(H)},"%H":function(H){return q(H.dc,2)},"%I":function(H){return(H=H.dc)==0?H=12:12H.dc?"AM":"PM"},"%S":function(H){return q(H.Lc,2)},"%t":function(){return" "},"%u":function(H){return H.Tb||7},"%U":function(H){return q(Math.floor((H.Wb+7-H.Tb)/7),2)},"%V":function(H){var ye=Math.floor((H.Wb+7-(H.Tb+6)%7)/7);if(2>=(H.Tb+371-H.Wb-2)%7&&ye++,ye)ye==53&&((ke=(H.Tb+371-H.Wb)%7)==4||ke==3&&It(H.Xb)||(ye=1));else{ye=52;var ke=(H.Tb+7-H.Wb-1)%7;(ke==4||ke==5&&It(H.Xb%400-1))&&ye++}return q(ye,2)},"%w":function(H){return H.Tb},"%W":function(H){return q(Math.floor((H.Wb+7-(H.Tb+6)%7)/7),2)},"%y":function(H){return(H.Xb+1900).toString().substring(2)},"%Y":function(H){return H.Xb+1900},"%z":function(H){var ye=0<=(H=H.Jc);return H=Math.abs(H)/60,(ye?"+":"-")+("0000"+(H/60*100+H%60)).slice(-4)},"%Z":function(H){return H.Mc},"%%":function(){return"%"}},k=k.replace(/%%/g,"\0\0"),me)k.includes(De)&&(k=k.replace(new RegExp(De,"g"),me[De](F)));return De=function(H){var ye=Array(Fe(H)+1);return $e(H,ye,0,ye.length),ye}(k=k.replace(/\0\0/g,"%")),De.length>O?0:(function(H,ye){a().set(H,ye>>>0)}(De,v),De.length-1)}re.fc();var hn=[null,Re,kt,at,_t,bt,yt,wt,Tt,xt,vt,St,At,Pt,Ot,E,I,U,X,te,W,_e,Oe,We,et,jt],pn={b:function(v){return $t(v+24)+24},n:function(v){return(v=new oe(v)).uc()||(v.hc(!0),ae--),v.ic(!1),st.push(v),v.sc(),v.vc()},ma:function(v){throw R("Unexpected exception thrown, this is not properly supported - aborting"),be=!0,v},x:function(){pe(0);var v=st.pop();if(v.Hc()&&!v.kc()){var O=v.Dc();O&&Te(O)(v.Zb),gt(v.Zb)}ie=0},e:function(){var v=ie;if(!v)return je=0;var O=new oe(v);O.cc(v);var k=O.bc();if(!k)return je=0,v;for(var F=Array.prototype.slice.call(arguments),B=0;BL(F));else if(M)postMessage({targetThread:v,cmd:"processProxyingQueue",queue:F});else{if(!(v=re.Vb[v]))return;v.postMessage({cmd:"processProxyingQueue",queue:F})}return 1},Ea:function(){return-1},Pa:function(v,O){v=new Date(1e3*j(v)),f()[O>>2>>>0]=v.getUTCSeconds(),f()[O+4>>2>>>0]=v.getUTCMinutes(),f()[O+8>>2>>>0]=v.getUTCHours(),f()[O+12>>2>>>0]=v.getUTCDate(),f()[O+16>>2>>>0]=v.getUTCMonth(),f()[O+20>>2>>>0]=v.getUTCFullYear()-1900,f()[O+24>>2>>>0]=v.getUTCDay(),v=(v.getTime()-Date.UTC(v.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,f()[O+28>>2>>>0]=v},Qa:function(v,O){v=new Date(1e3*j(v)),f()[O>>2>>>0]=v.getSeconds(),f()[O+4>>2>>>0]=v.getMinutes(),f()[O+8>>2>>>0]=v.getHours(),f()[O+12>>2>>>0]=v.getDate(),f()[O+16>>2>>>0]=v.getMonth(),f()[O+20>>2>>>0]=v.getFullYear()-1900,f()[O+24>>2>>>0]=v.getDay();var k=new Date(v.getFullYear(),0,1),F=(v.getTime()-k.getTime())/864e5|0;f()[O+28>>2>>>0]=F,f()[O+36>>2>>>0]=-60*v.getTimezoneOffset(),F=new Date(v.getFullYear(),6,1).getTimezoneOffset(),v=0|(F!=(k=k.getTimezoneOffset())&&v.getTimezoneOffset()==Math.min(k,F)),f()[O+32>>2>>>0]=v},Ra:function(v){var O=new Date(f()[v+20>>2>>>0]+1900,f()[v+16>>2>>>0],f()[v+12>>2>>>0],f()[v+8>>2>>>0],f()[v+4>>2>>>0],f()[v>>2>>>0],0),k=f()[v+32>>2>>>0],F=O.getTimezoneOffset(),B=new Date(O.getFullYear(),0,1),q=new Date(O.getFullYear(),6,1).getTimezoneOffset(),Q=B.getTimezoneOffset(),ne=Math.min(Q,q);return 0>k?f()[v+32>>2>>>0]=+(q!=Q&&ne==F):0>2>>>0]=O.getDay(),k=(O.getTime()-B.getTime())/864e5|0,f()[v+28>>2>>>0]=k,f()[v>>2>>>0]=O.getSeconds(),f()[v+4>>2>>>0]=O.getMinutes(),f()[v+8>>2>>>0]=O.getHours(),f()[v+12>>2>>>0]=O.getDate(),f()[v+16>>2>>>0]=O.getMonth(),O.getTime()/1e3|0},Aa:U,Ba:X,Sa:function v(O,k,F){v.Ac||(v.Ac=!0,te(O,k,F))},y:function(){ge("")},U:function(){if(!x&&!P){var v="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";ot||(ot={}),ot[v]||(ot[v]=1,x&&(v="warning: "+v),R(v))}},ra:function(){return 4294901760},B:ft,Ia:function(v,O,k){h().copyWithin(v>>>0,O>>>0,O+k>>>0)},F:function(){return x?i(3993).cpus().length:navigator.hardwareConcurrency},Da:function(v,O,k){Se.length=O,k>>=3;for(var F=0;F>>0];return(0>v?Et[-v-1]:hn[v]).apply(null,Se)},qa:function(v){var O=h().length;if((v>>>=0)<=O||4294901760=k;k*=2){var F=O*(1+.2/k);F=Math.min(F,v+100663296);var B=Math;F=Math.max(v,F),B=B.min.call(B,4294901760,F+(65536-F%65536)%65536);e:{try{V.grow(B-Z.byteLength+65535>>>16),Me(V.buffer);var q=1;break e}catch{}q=void 0}if(q)return!0}return!1},Na:function(){throw"unwind"},Ga:W,Ha:_e,J:it,I:Oe,S:We,ga:et,R:jt,d:function(){return je},na:function v(O,k){v.lc||(v.lc=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var B=new Uint8Array(1);return()=>(crypto.getRandomValues(B),B[0])}if(x)try{var q=i(Object(function(){var Q=new Error("Cannot find module 'crypto'");throw Q.code="MODULE_NOT_FOUND",Q}()));return()=>q.randomBytes(1)[0]}catch{}return()=>ge("randomDevice")}());for(var F=0;F>0>>>0]=v.lc();return 0},ia:function(v,O,k){var F=he();try{return Te(v)(O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},ja:function(v,O,k){var F=he();try{return Te(v)(O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},K:function(v){var O=he();try{return Te(v)()}catch(k){if(de(O),k!==k+0)throw k;pe(1,0)}},f:function(v,O){var k=he();try{return Te(v)(O)}catch(F){if(de(k),F!==F+0)throw F;pe(1,0)}},P:function(v,O,k){var F=he();try{return Te(v)(O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},Q:function(v,O,k){var F=he();try{return Te(v)(O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},k:function(v,O,k){var F=he();try{return Te(v)(O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},p:function(v,O,k,F){var B=he();try{return Te(v)(O,k,F)}catch(q){if(de(B),q!==q+0)throw q;pe(1,0)}},q:function(v,O,k,F,B){var q=he();try{return Te(v)(O,k,F,B)}catch(Q){if(de(q),Q!==Q+0)throw Q;pe(1,0)}},N:function(v,O,k,F,B,q){var Q=he();try{return Te(v)(O,k,F,B,q)}catch(ne){if(de(Q),ne!==ne+0)throw ne;pe(1,0)}},s:function(v,O,k,F,B,q){var Q=he();try{return Te(v)(O,k,F,B,q)}catch(ne){if(de(Q),ne!==ne+0)throw ne;pe(1,0)}},w:function(v,O,k,F,B,q,Q){var ne=he();try{return Te(v)(O,k,F,B,q,Q)}catch(fe){if(de(ne),fe!==fe+0)throw fe;pe(1,0)}},L:function(v,O,k,F,B,q,Q,ne){var fe=he();try{return Te(v)(O,k,F,B,q,Q,ne)}catch(me){if(de(fe),me!==me+0)throw me;pe(1,0)}},E:function(v,O,k,F,B,q,Q,ne,fe,me,De,Ke){var He=he();try{return Te(v)(O,k,F,B,q,Q,ne,fe,me,De,Ke)}catch(H){if(de(He),H!==H+0)throw H;pe(1,0)}},aa:function(v,O,k,F,B,q,Q,ne){var fe=he();try{return ln(v,O,k,F,B,q,Q,ne)}catch(me){if(de(fe),me!==me+0)throw me;pe(1,0)}},_:function(v,O,k,F,B,q,Q){var ne=he();try{return en(v,O,k,F,B,q,Q)}catch(fe){if(de(ne),fe!==fe+0)throw fe;pe(1,0)}},Z:function(v,O,k,F,B){var q=he();try{return un(v,O,k,F,B)}catch(Q){if(de(q),Q!==Q+0)throw Q;pe(1,0)}},ca:function(v,O,k,F){var B=he();try{return sn(v,O,k,F)}catch(q){if(de(B),q!==q+0)throw q;pe(1,0)}},$:function(v){var O=he();try{return Jt(v)}catch(k){if(de(O),k!==k+0)throw k;pe(1,0)}},ba:function(v,O){var k=he();try{return an(v,O)}catch(F){if(de(k),F!==F+0)throw F;pe(1,0)}},Y:function(v,O,k){var F=he();try{return tn(v,O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},g:function(v){var O=he();try{Te(v)()}catch(k){if(de(O),k!==k+0)throw k;pe(1,0)}},r:function(v,O){var k=he();try{Te(v)(O)}catch(F){if(de(k),F!==F+0)throw F;pe(1,0)}},i:function(v,O,k){var F=he();try{Te(v)(O,k)}catch(B){if(de(F),B!==B+0)throw B;pe(1,0)}},ha:function(v,O,k,F){var B=he();try{Te(v)(O,k,F)}catch(q){if(de(B),q!==q+0)throw q;pe(1,0)}},m:function(v,O,k,F){var B=he();try{Te(v)(O,k,F)}catch(q){if(de(B),q!==q+0)throw q;pe(1,0)}},v:function(v,O,k,F,B){var q=he();try{Te(v)(O,k,F,B)}catch(Q){if(de(q),Q!==Q+0)throw Q;pe(1,0)}},u:function(v,O,k,F,B,q){var Q=he();try{Te(v)(O,k,F,B,q)}catch(ne){if(de(Q),ne!==ne+0)throw ne;pe(1,0)}},O:function(v,O,k,F,B,q,Q){var ne=he();try{Te(v)(O,k,F,B,q,Q)}catch(fe){if(de(ne),fe!==fe+0)throw fe;pe(1,0)}},A:function(v,O,k,F,B,q,Q,ne){var fe=he();try{Te(v)(O,k,F,B,q,Q,ne)}catch(me){if(de(fe),me!==me+0)throw me;pe(1,0)}},ka:function(v,O,k,F,B,q,Q,ne,fe){var me=he();try{Te(v)(O,k,F,B,q,Q,ne,fe)}catch(De){if(de(me),De!==De+0)throw De;pe(1,0)}},C:function(v,O,k,F,B,q,Q,ne,fe,me,De){var Ke=he();try{Te(v)(O,k,F,B,q,Q,ne,fe,me,De)}catch(He){if(de(Ke),He!==He+0)throw He;pe(1,0)}},D:function(v,O,k,F,B,q,Q,ne,fe,me,De,Ke,He,H,ye,ke){var tt=he();try{Te(v)(O,k,F,B,q,Q,ne,fe,me,De,Ke,He,H,ye,ke)}catch(ht){if(de(tt),ht!==ht+0)throw ht;pe(1,0)}},fa:function(v,O,k,F,B,q,Q,ne){var fe=he();try{nn(v,O,k,F,B,q,Q,ne)}catch(me){if(de(fe),me!==me+0)throw me;pe(1,0)}},da:function(v,O,k,F,B,q,Q,ne,fe,me,De,Ke){var He=he();try{on(v,O,k,F,B,q,Q,ne,fe,me,De,Ke)}catch(H){if(de(He),H!==H+0)throw H;pe(1,0)}},ea:function(v,O,k,F,B,q){var Q=he();try{rn(v,O,k,F,B,q)}catch(ne){if(de(Q),ne!==ne+0)throw ne;pe(1,0)}},o:function(v){return v},a:V||n.wasmMemory,G:function(v){je=v},la:Gt,z:function(v,O,k,F){return Gt(v,O,k,F)}};(function(){function v(B,q){n.asm=B.exports,re.qc.push(n.asm.sb),Be=n.asm.ub,Ve.unshift(n.asm.Va),J=q,M||(ze--,n.monitorRunDependencies&&n.monitorRunDependencies(ze),ze==0&&Ye&&(B=Ye,Ye=null,B()))}function O(B){v(B.instance,B.module)}function k(B){return function(){if(!G&&(A||P)){if(typeof fetch=="function"&&!Ee.startsWith("file://"))return fetch(Ee,{credentials:"same-origin"}).then(function(q){if(!q.ok)throw"failed to load wasm binary file at '"+Ee+"'";return q.arrayBuffer()}).catch(function(){return ut()});if(p)return new Promise(function(q,Q){p(Ee,function(ne){q(new Uint8Array(ne))},Q)})}return Promise.resolve().then(function(){return ut()})}().then(function(q){return WebAssembly.instantiate(q,F)}).then(function(q){return q}).then(B,function(q){R("failed to asynchronously prepare wasm: "+q),ge(q)})}var F={a:pn};if(M||(ze++,n.monitorRunDependencies&&n.monitorRunDependencies(ze)),n.instantiateWasm)try{return n.instantiateWasm(F,v)}catch(B){return R("Module.instantiateWasm callback failed with error: "+B),!1}(G||typeof WebAssembly.instantiateStreaming!="function"||pt()||Ee.startsWith("file://")||x||typeof fetch!="function"?k(O):fetch(Ee,{credentials:"same-origin"}).then(function(B){return WebAssembly.instantiateStreaming(B,F).then(O,function(q){return R("wasm streaming compile failed: "+q),R("falling back to ArrayBuffer instantiation"),k(O)})})).catch(r)})(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.Va).apply(null,arguments)},n._OrtInit=function(){return(n._OrtInit=n.asm.Wa).apply(null,arguments)},n._OrtCreateSessionOptions=function(){return(n._OrtCreateSessionOptions=n.asm.Xa).apply(null,arguments)},n._OrtAppendExecutionProvider=function(){return(n._OrtAppendExecutionProvider=n.asm.Ya).apply(null,arguments)},n._OrtAddSessionConfigEntry=function(){return(n._OrtAddSessionConfigEntry=n.asm.Za).apply(null,arguments)},n._OrtReleaseSessionOptions=function(){return(n._OrtReleaseSessionOptions=n.asm._a).apply(null,arguments)},n._OrtCreateSession=function(){return(n._OrtCreateSession=n.asm.$a).apply(null,arguments)},n._OrtReleaseSession=function(){return(n._OrtReleaseSession=n.asm.ab).apply(null,arguments)},n._OrtGetInputCount=function(){return(n._OrtGetInputCount=n.asm.bb).apply(null,arguments)},n._OrtGetOutputCount=function(){return(n._OrtGetOutputCount=n.asm.cb).apply(null,arguments)},n._OrtGetInputName=function(){return(n._OrtGetInputName=n.asm.db).apply(null,arguments)},n._OrtGetOutputName=function(){return(n._OrtGetOutputName=n.asm.eb).apply(null,arguments)},n._OrtFree=function(){return(n._OrtFree=n.asm.fb).apply(null,arguments)},n._OrtCreateTensor=function(){return(n._OrtCreateTensor=n.asm.gb).apply(null,arguments)},n._OrtGetTensorData=function(){return(n._OrtGetTensorData=n.asm.hb).apply(null,arguments)},n._OrtReleaseTensor=function(){return(n._OrtReleaseTensor=n.asm.ib).apply(null,arguments)},n._OrtCreateRunOptions=function(){return(n._OrtCreateRunOptions=n.asm.jb).apply(null,arguments)},n._OrtAddRunConfigEntry=function(){return(n._OrtAddRunConfigEntry=n.asm.kb).apply(null,arguments)},n._OrtReleaseRunOptions=function(){return(n._OrtReleaseRunOptions=n.asm.lb).apply(null,arguments)},n._OrtRun=function(){return(n._OrtRun=n.asm.mb).apply(null,arguments)},n._OrtEndProfiling=function(){return(n._OrtEndProfiling=n.asm.nb).apply(null,arguments)};var Dt=n._pthread_self=function(){return(Dt=n._pthread_self=n.asm.ob).apply(null,arguments)},$t=n._malloc=function(){return($t=n._malloc=n.asm.pb).apply(null,arguments)},Vt=n._free=function(){return(Vt=n._free=n.asm.qb).apply(null,arguments)},qt=n._fflush=function(){return(qt=n._fflush=n.asm.rb).apply(null,arguments)};n.__emscripten_tls_init=function(){return(n.__emscripten_tls_init=n.asm.sb).apply(null,arguments)};var Wt=n.___funcs_on_exit=function(){return(Wt=n.___funcs_on_exit=n.asm.tb).apply(null,arguments)},Ht=n.__emscripten_thread_init=function(){return(Ht=n.__emscripten_thread_init=n.asm.vb).apply(null,arguments)};n.__emscripten_thread_crashed=function(){return(n.__emscripten_thread_crashed=n.asm.wb).apply(null,arguments)};var Ct,Xt=n._emscripten_run_in_main_runtime_thread_js=function(){return(Xt=n._emscripten_run_in_main_runtime_thread_js=n.asm.xb).apply(null,arguments)},Yt=n.__emscripten_proxy_execute_task_queue=function(){return(Yt=n.__emscripten_proxy_execute_task_queue=n.asm.yb).apply(null,arguments)},Rt=n.__emscripten_thread_free_data=function(){return(Rt=n.__emscripten_thread_free_data=n.asm.zb).apply(null,arguments)},Kt=n.__emscripten_thread_exit=function(){return(Kt=n.__emscripten_thread_exit=n.asm.Ab).apply(null,arguments)},pe=n._setThrew=function(){return(pe=n._setThrew=n.asm.Bb).apply(null,arguments)},Qt=n._emscripten_stack_set_limits=function(){return(Qt=n._emscripten_stack_set_limits=n.asm.Cb).apply(null,arguments)},he=n.stackSave=function(){return(he=n.stackSave=n.asm.Db).apply(null,arguments)},de=n.stackRestore=function(){return(de=n.stackRestore=n.asm.Eb).apply(null,arguments)},zt=n.stackAlloc=function(){return(zt=n.stackAlloc=n.asm.Fb).apply(null,arguments)},Ft=n.___cxa_can_catch=function(){return(Ft=n.___cxa_can_catch=n.asm.Gb).apply(null,arguments)},Zt=n.___cxa_is_pointer_type=function(){return(Zt=n.___cxa_is_pointer_type=n.asm.Hb).apply(null,arguments)},Jt=n.dynCall_j=function(){return(Jt=n.dynCall_j=n.asm.Ib).apply(null,arguments)},en=n.dynCall_iiiiij=function(){return(en=n.dynCall_iiiiij=n.asm.Jb).apply(null,arguments)},tn=n.dynCall_jii=function(){return(tn=n.dynCall_jii=n.asm.Kb).apply(null,arguments)},nn=n.dynCall_viiiiij=function(){return(nn=n.dynCall_viiiiij=n.asm.Lb).apply(null,arguments)},rn=n.dynCall_vjji=function(){return(rn=n.dynCall_vjji=n.asm.Mb).apply(null,arguments)},on=n.dynCall_viiijjjii=function(){return(on=n.dynCall_viiijjjii=n.asm.Nb).apply(null,arguments)},sn=n.dynCall_iij=function(){return(sn=n.dynCall_iij=n.asm.Ob).apply(null,arguments)},an=n.dynCall_ji=function(){return(an=n.dynCall_ji=n.asm.Pb).apply(null,arguments)},ln=n.dynCall_iiiiiij=function(){return(ln=n.dynCall_iiiiiij=n.asm.Qb).apply(null,arguments)},un=n.dynCall_iiij=function(){return(un=n.dynCall_iiij=n.asm.Rb).apply(null,arguments)};function cn(){function v(){if(!Ct&&(Ct=!0,n.calledRun=!0,!be)&&(M||rt(Ve),e(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),!M)){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;){var O=n.postRun.shift();Qe.unshift(O)}rt(Qe)}}if(!(0{var s,u=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(d){var a,h,f;d=d||{},a||(a=d!==void 0?d:{}),a.ready=new Promise(function(E,I){h=E,f=I});var c,l,n,e,r,o,p=Object.assign({},a),g="./this.program",_=(E,I)=>{throw I},b=typeof window=="object",y=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T="";w?(T=y?i(908).dirname(T)+"/":"//",o=()=>{r||(e=i(1384),r=i(908))},c=function(E,I){return o(),E=r.normalize(E),e.readFileSync(E,I?void 0:"utf8")},n=E=>((E=c(E,!0)).buffer||(E=new Uint8Array(E)),E),l=(E,I,L)=>{o(),E=r.normalize(E),e.readFile(E,function(j,U){j?L(j):I(U.buffer)})},1{if(x||0{var I=new XMLHttpRequest;return I.open("GET",E,!1),I.send(null),I.responseText},y&&(n=E=>{var I=new XMLHttpRequest;return I.open("GET",E,!1),I.responseType="arraybuffer",I.send(null),new Uint8Array(I.response)}),l=(E,I,L)=>{var j=new XMLHttpRequest;j.open("GET",E,!0),j.responseType="arraybuffer",j.onload=()=>{j.status==200||j.status==0&&j.response?I(j.response):L()},j.onerror=L,j.send(null)});var S,A=a.print||console.log.bind(console),P=a.printErr||console.warn.bind(console);Object.assign(a,p),p=null,a.thisProgram&&(g=a.thisProgram),a.quit&&(_=a.quit),a.wasmBinary&&(S=a.wasmBinary);var x=a.noExitRuntime||!1;typeof WebAssembly!="object"&&Me("no native wasm support detected");var M,N,z,$,C,G,D=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Y(E,I,L){var j=(I>>>=0)+L;for(L=I;E[L]&&!(L>=j);)++L;if(16(U=(240&U)==224?(15&U)<<12|X<<6|K:(7&U)<<18|X<<12|K<<6|63&E[I++])?j+=String.fromCharCode(U):(U-=65536,j+=String.fromCharCode(55296|U>>10,56320|1023&U))}}else j+=String.fromCharCode(U)}return j}function V(E,I){return(E>>>=0)?Y($,E,I):""}function J(E,I,L,j){if(!(0>>=0;j=L+j-1;for(var X=0;X=K&&(K=65536+((1023&K)<<10)|1023&E.charCodeAt(++X)),127>=K){if(L>=j)break;I[L++>>>0]=K}else{if(2047>=K){if(L+1>=j)break;I[L++>>>0]=192|K>>6}else{if(65535>=K){if(L+2>=j)break;I[L++>>>0]=224|K>>12}else{if(L+3>=j)break;I[L++>>>0]=240|K>>18,I[L++>>>0]=128|K>>12&63}I[L++>>>0]=128|K>>6&63}I[L++>>>0]=128|63&K}}return I[L>>>0]=0,L-U}function Z(E){for(var I=0,L=0;L=j?I++:2047>=j?I+=2:55296<=j&&57343>=j?(I+=4,++L):I+=3}return I}function ue(){var E=M.buffer;N=E,a.HEAP8=z=new Int8Array(E),a.HEAP16=new Int16Array(E),a.HEAP32=C=new Int32Array(E),a.HEAPU8=$=new Uint8Array(E),a.HEAPU16=new Uint16Array(E),a.HEAPU32=G=new Uint32Array(E),a.HEAPF32=new Float32Array(E),a.HEAPF64=new Float64Array(E)}var Ae,xe=[],se=[],we=[],be=[],Ie=0;function Le(){var E=a.preRun.shift();xe.unshift(E)}var ve,$e=0,Fe=null;function Me(E){throw a.onAbort&&a.onAbort(E),P(E="Aborted("+E+")"),D=!0,E=new WebAssembly.RuntimeError(E+". Build with -sASSERTIONS for more info."),f(E),E}function Pe(){return ve.startsWith("data:application/octet-stream;base64,")}if(ve="ort-wasm.wasm",!Pe()){var Be=ve;ve=a.locateFile?a.locateFile(Be,T):T+Be}function Ge(){var E=ve;try{if(E==ve&&S)return new Uint8Array(S);if(n)return n(E);throw"both async and sync fetching of the wasm failed"}catch(I){Me(I)}}function Ve(E){this.name="ExitStatus",this.message="Program terminated with exit("+E+")",this.status=E}function Xe(E){for(;0>2>>>0]=I},this.Eb=function(){return G[this.zb+4>>2>>>0]},this.Sb=function(I){G[this.zb+8>>2>>>0]=I},this.Wb=function(){return G[this.zb+8>>2>>>0]},this.Tb=function(){C[this.zb>>2>>>0]=0},this.Ib=function(I){z[this.zb+12>>0>>>0]=I?1:0},this.Pb=function(){return z[this.zb+12>>0>>>0]!=0},this.Jb=function(I){z[this.zb+13>>0>>>0]=I?1:0},this.Lb=function(){return z[this.zb+13>>0>>>0]!=0},this.Rb=function(I,L){this.Fb(0),this.Ub(I),this.Sb(L),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){C[this.zb>>2>>>0]+=1},this.Xb=function(){var I=C[this.zb>>2>>>0];return C[this.zb>>2>>>0]=I-1,I===1},this.Fb=function(I){G[this.zb+16>>2>>>0]=I},this.Ob=function(){return G[this.zb+16>>2>>>0]},this.Qb=function(){if(mt(this.Eb()))return G[this.Db>>2>>>0];var I=this.Ob();return I!==0?I:this.Db}}function ze(E){return ot(new Ee(E).zb)}var Ye=[];function ge(E){var I=Ye[E];return I||(E>=Ye.length&&(Ye.length=E+1),Ye[E]=I=Ae.get(E)),I}function pt(E){var I=Z(E)+1,L=Te(I);return L&&J(E,z,L,I),L}var ut={};function Et(){if(!Ze){var E,I={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"};for(E in ut)ut[E]===void 0?delete I[E]:I[E]=ut[E];var L=[];for(E in I)L.push(E+"="+I[E]);Ze=L}return Ze}var Ze,ct=[null,[],[]];function dt(E,I){var L=ct[E];I===0||I===10?((E===1?A:P)(Y(L,0)),L.length=0):L.push(I)}var Re=0;function it(E){return E%4==0&&(E%100!=0||E%400==0)}var re=[31,29,31,30,31,30,31,31,30,31,30,31],rt=[31,28,31,30,31,30,31,31,30,31,30,31];function Mt(E,I,L,j){function U(W,_e,Oe){for(W=typeof W=="number"?W.toString():W||"";W.length<_e;)W=Oe[0]+W;return W}function X(W,_e){return U(W,_e,"0")}function K(W,_e){function Oe(et){return 0>et?-1:0We-W.getDate())){W.setDate(W.getDate()+_e);break}_e-=We-W.getDate()+1,W.setDate(1),11>Oe?W.setMonth(Oe+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return Oe=new Date(W.getFullYear()+1,0,4),_e=te(new Date(W.getFullYear(),0,4)),Oe=te(Oe),0>=K(_e,W)?0>=K(Oe,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}var ce=C[j+40>>2>>>0];for(var Se in j={$b:C[j>>2>>>0],Zb:C[j+4>>2>>>0],Gb:C[j+8>>2>>>0],Kb:C[j+12>>2>>>0],Hb:C[j+16>>2>>>0],Cb:C[j+20>>2>>>0],Ab:C[j+24>>2>>>0],Bb:C[j+28>>2>>>0],bc:C[j+32>>2>>>0],Yb:C[j+36>>2>>>0],ac:ce?V(ce):""},L=V(L),ce={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})L=L.replace(new RegExp(Se,"g"),ce[Se]);var Ne="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ce="January February March April May June July August September October November December".split(" ");for(Se in ce={"%a":function(W){return Ne[W.Ab].substring(0,3)},"%A":function(W){return Ne[W.Ab]},"%b":function(W){return Ce[W.Hb].substring(0,3)},"%B":function(W){return Ce[W.Hb]},"%C":function(W){return X((W.Cb+1900)/100|0,2)},"%d":function(W){return X(W.Kb,2)},"%e":function(W){return U(W.Kb,2," ")},"%g":function(W){return ee(W).toString().substring(2)},"%G":function(W){return ee(W)},"%H":function(W){return X(W.Gb,2)},"%I":function(W){return(W=W.Gb)==0?W=12:12W.Gb?"AM":"PM"},"%S":function(W){return X(W.$b,2)},"%t":function(){return" "},"%u":function(W){return W.Ab||7},"%U":function(W){return X(Math.floor((W.Bb+7-W.Ab)/7),2)},"%V":function(W){var _e=Math.floor((W.Bb+7-(W.Ab+6)%7)/7);if(2>=(W.Ab+371-W.Bb-2)%7&&_e++,_e)_e==53&&((Oe=(W.Ab+371-W.Bb)%7)==4||Oe==3&&it(W.Cb)||(_e=1));else{_e=52;var Oe=(W.Ab+7-W.Bb-1)%7;(Oe==4||Oe==5&&it(W.Cb%400-1))&&_e++}return X(_e,2)},"%w":function(W){return W.Ab},"%W":function(W){return X(Math.floor((W.Bb+7-(W.Ab+6)%7)/7),2)},"%y":function(W){return(W.Cb+1900).toString().substring(2)},"%Y":function(W){return W.Cb+1900},"%z":function(W){var _e=0<=(W=W.Yb);return W=Math.abs(W)/60,(_e?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":function(W){return W.ac},"%%":function(){return"%"}},L=L.replace(/%%/g,"\0\0"),ce)L.includes(Se)&&(L=L.replace(new RegExp(Se,"g"),ce[Se](j)));return Se=function(W){var _e=Array(Z(W)+1);return J(W,_e,0,_e.length),_e}(L=L.replace(/\0\0/g,"%")),Se.length>I?0:(z.set(Se,E>>>0),Se.length-1)}var kt={a:function(E){return Te(E+24)+24},m:function(E){return(E=new Ee(E)).Pb()||(E.Ib(!0),qe--),E.Jb(!1),Qe.push(E),E.Nb(),E.Qb()},ia:function(E){throw P("Unexpected exception thrown, this is not properly supported - aborting"),D=!0,E},w:function(){ae(0);var E=Qe.pop();if(E.Xb()&&!E.Lb()){var I=E.Wb();I&&ge(I)(E.Db),ze(E.Db)}Ue=0},d:function(){var E=Ue;if(!E)return Re=0;var I=new Ee(E);I.Fb(E);var L=I.Eb();if(!L)return Re=0,E;for(var j=Array.prototype.slice.call(arguments),U=0;U>>2]+4294967296*C[E+4>>>2])),C[I>>2>>>0]=E.getUTCSeconds(),C[I+4>>2>>>0]=E.getUTCMinutes(),C[I+8>>2>>>0]=E.getUTCHours(),C[I+12>>2>>>0]=E.getUTCDate(),C[I+16>>2>>>0]=E.getUTCMonth(),C[I+20>>2>>>0]=E.getUTCFullYear()-1900,C[I+24>>2>>>0]=E.getUTCDay(),C[I+28>>2>>>0]=(E.getTime()-Date.UTC(E.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(E,I){E=new Date(1e3*(G[E>>>2]+4294967296*C[E+4>>>2])),C[I>>2>>>0]=E.getSeconds(),C[I+4>>2>>>0]=E.getMinutes(),C[I+8>>2>>>0]=E.getHours(),C[I+12>>2>>>0]=E.getDate(),C[I+16>>2>>>0]=E.getMonth(),C[I+20>>2>>>0]=E.getFullYear()-1900,C[I+24>>2>>>0]=E.getDay();var L=new Date(E.getFullYear(),0,1);C[I+28>>2>>>0]=(E.getTime()-L.getTime())/864e5|0,C[I+36>>2>>>0]=-60*E.getTimezoneOffset();var j=new Date(E.getFullYear(),6,1).getTimezoneOffset();L=L.getTimezoneOffset(),C[I+32>>2>>>0]=0|(j!=L&&E.getTimezoneOffset()==Math.min(L,j))},Fa:function(E){var I=new Date(C[E+20>>2>>>0]+1900,C[E+16>>2>>>0],C[E+12>>2>>>0],C[E+8>>2>>>0],C[E+4>>2>>>0],C[E>>2>>>0],0),L=C[E+32>>2>>>0],j=I.getTimezoneOffset(),U=new Date(I.getFullYear(),0,1),X=new Date(I.getFullYear(),6,1).getTimezoneOffset(),K=U.getTimezoneOffset(),te=Math.min(K,X);return 0>L?C[E+32>>2>>>0]=+(X!=K&&te==j):0>2>>>0]=I.getDay(),C[E+28>>2>>>0]=(I.getTime()-U.getTime())/864e5|0,C[E>>2>>>0]=I.getSeconds(),C[E+4>>2>>>0]=I.getMinutes(),C[E+8>>2>>>0]=I.getHours(),C[E+12>>2>>>0]=I.getDate(),C[E+16>>2>>>0]=I.getMonth(),I.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function E(I,L,j){E.Vb||(E.Vb=!0,function(U,X,K){function te(Ce){return(Ce=Ce.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ce[1]:"GMT"}var ee=new Date().getFullYear(),ce=new Date(ee,0,1),Se=new Date(ee,6,1);ee=ce.getTimezoneOffset();var Ne=Se.getTimezoneOffset();C[U>>2>>>0]=60*Math.max(ee,Ne),C[X>>2>>>0]=+(ee!=Ne),U=te(ce),X=te(Se),U=pt(U),X=pt(X),Ne>2>>>0]=U,G[K+4>>2>>>0]=X):(G[K>>2>>>0]=X,G[K+4>>2>>>0]=U)}(I,L,j))},B:function(){Me("")},ma:function(){return 4294901760},I:w?()=>{var E=process.hrtime();return 1e3*E[0]+E[1]/1e6}:()=>performance.now(),xa:function(E,I,L){$.copyWithin(E>>>0,I>>>0,I+L>>>0)},G:function(E){var I=$.length;if(4294901760<(E>>>=0))return!1;for(var L=1;4>=L;L*=2){var j=I*(1+.2/L);j=Math.min(j,E+100663296);var U=Math;j=Math.max(E,j),U=U.min.call(U,4294901760,j+(65536-j%65536)%65536);e:{try{M.grow(U-N.byteLength+65535>>>16),ue();var X=1;break e}catch{}X=void 0}if(X)return!0}return!1},va:function(E,I){var L=0;return Et().forEach(function(j,U){var X=I+L;for(U=G[E+4*U>>2>>>0]=X,X=0;X>0>>>0]=j.charCodeAt(X);z[U>>0>>>0]=0,L+=j.length+1}),0},wa:function(E,I){var L=Et();G[E>>2>>>0]=L.length;var j=0;return L.forEach(function(U){j+=U.length+1}),G[I>>2>>>0]=j,0},ba:function(E){x||0>2>>>0],te=G[I+4>>2>>>0];I+=8;for(var ee=0;ee>>0]);U+=te}return G[j>>2>>>0]=U,0},c:function(){return Re},ja:function E(I,L){E.Mb||(E.Mb=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var U=new Uint8Array(1);return()=>(crypto.getRandomValues(U),U[0])}if(w)try{var X=i(Object(function(){var K=new Error("Cannot find module 'crypto'");throw K.code="MODULE_NOT_FOUND",K}()));return()=>X.randomBytes(1)[0]}catch{}return()=>Me("randomDevice")}());for(var j=0;j>0>>>0]=E.Mb();return 0},ea:function(E,I,L){var j=ie();try{return ge(E)(I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},fa:function(E,I,L){var j=ie();try{return ge(E)(I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},J:function(E){var I=ie();try{return ge(E)()}catch(L){if(oe(I),L!==L+0)throw L;ae(1,0)}},e:function(E,I){var L=ie();try{return ge(E)(I)}catch(j){if(oe(L),j!==j+0)throw j;ae(1,0)}},N:function(E,I,L){var j=ie();try{return ge(E)(I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},O:function(E,I,L){var j=ie();try{return ge(E)(I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},j:function(E,I,L){var j=ie();try{return ge(E)(I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},o:function(E,I,L,j){var U=ie();try{return ge(E)(I,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},p:function(E,I,L,j,U){var X=ie();try{return ge(E)(I,L,j,U)}catch(K){if(oe(X),K!==K+0)throw K;ae(1,0)}},M:function(E,I,L,j,U,X){var K=ie();try{return ge(E)(I,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},r:function(E,I,L,j,U,X){var K=ie();try{return ge(E)(I,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},v:function(E,I,L,j,U,X,K){var te=ie();try{return ge(E)(I,L,j,U,X,K)}catch(ee){if(oe(te),ee!==ee+0)throw ee;ae(1,0)}},K:function(E,I,L,j,U,X,K,te){var ee=ie();try{return ge(E)(I,L,j,U,X,K,te)}catch(ce){if(oe(ee),ce!==ce+0)throw ce;ae(1,0)}},D:function(E,I,L,j,U,X,K,te,ee,ce,Se,Ne){var Ce=ie();try{return ge(E)(I,L,j,U,X,K,te,ee,ce,Se,Ne)}catch(W){if(oe(Ce),W!==W+0)throw W;ae(1,0)}},X:function(E,I,L,j,U,X,K,te){var ee=ie();try{return At(E,I,L,j,U,X,K,te)}catch(ce){if(oe(ee),ce!==ce+0)throw ce;ae(1,0)}},V:function(E,I,L,j,U,X,K){var te=ie();try{return bt(E,I,L,j,U,X,K)}catch(ee){if(oe(te),ee!==ee+0)throw ee;ae(1,0)}},U:function(E,I,L,j,U){var X=ie();try{return Pt(E,I,L,j,U)}catch(K){if(oe(X),K!==K+0)throw K;ae(1,0)}},Z:function(E,I,L,j){var U=ie();try{return vt(E,I,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},W:function(E){var I=ie();try{return _t(E)}catch(L){if(oe(I),L!==L+0)throw L;ae(1,0)}},Y:function(E,I){var L=ie();try{return St(E,I)}catch(j){if(oe(L),j!==j+0)throw j;ae(1,0)}},T:function(E,I,L){var j=ie();try{return yt(E,I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},f:function(E){var I=ie();try{ge(E)()}catch(L){if(oe(I),L!==L+0)throw L;ae(1,0)}},q:function(E,I){var L=ie();try{ge(E)(I)}catch(j){if(oe(L),j!==j+0)throw j;ae(1,0)}},h:function(E,I,L){var j=ie();try{ge(E)(I,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},da:function(E,I,L,j){var U=ie();try{ge(E)(I,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},l:function(E,I,L,j){var U=ie();try{ge(E)(I,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},t:function(E,I,L,j,U){var X=ie();try{ge(E)(I,L,j,U)}catch(K){if(oe(X),K!==K+0)throw K;ae(1,0)}},u:function(E,I,L,j,U,X){var K=ie();try{ge(E)(I,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},x:function(E,I,L,j,U,X,K){var te=ie();try{ge(E)(I,L,j,U,X,K)}catch(ee){if(oe(te),ee!==ee+0)throw ee;ae(1,0)}},z:function(E,I,L,j,U,X,K,te){var ee=ie();try{ge(E)(I,L,j,U,X,K,te)}catch(ce){if(oe(ee),ce!==ce+0)throw ce;ae(1,0)}},ga:function(E,I,L,j,U,X,K,te,ee){var ce=ie();try{ge(E)(I,L,j,U,X,K,te,ee)}catch(Se){if(oe(ce),Se!==Se+0)throw Se;ae(1,0)}},A:function(E,I,L,j,U,X,K,te,ee,ce,Se){var Ne=ie();try{ge(E)(I,L,j,U,X,K,te,ee,ce,Se)}catch(Ce){if(oe(Ne),Ce!==Ce+0)throw Ce;ae(1,0)}},C:function(E,I,L,j,U,X,K,te,ee,ce,Se,Ne,Ce,W,_e,Oe){var We=ie();try{ge(E)(I,L,j,U,X,K,te,ee,ce,Se,Ne,Ce,W,_e,Oe)}catch(et){if(oe(We),et!==et+0)throw et;ae(1,0)}},aa:function(E,I,L,j,U,X,K,te){var ee=ie();try{wt(E,I,L,j,U,X,K,te)}catch(ce){if(oe(ee),ce!==ce+0)throw ce;ae(1,0)}},_:function(E,I,L,j,U,X,K,te,ee,ce,Se,Ne){var Ce=ie();try{xt(E,I,L,j,U,X,K,te,ee,ce,Se,Ne)}catch(W){if(oe(Ce),W!==W+0)throw W;ae(1,0)}},$:function(E,I,L,j,U,X){var K=ie();try{Tt(E,I,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},n:function(E){return E},F:function(E){Re=E},ha:Mt,y:function(E,I,L,j){return Mt(E,I,L,j)}};(function(){function E(U){a.asm=U.exports,M=a.asm.Ka,ue(),Ae=a.asm.ib,se.unshift(a.asm.La),$e--,a.monitorRunDependencies&&a.monitorRunDependencies($e),$e==0&&Fe&&(U=Fe,Fe=null,U())}function I(U){E(U.instance)}function L(U){return function(){if(!S&&(b||y)){if(typeof fetch=="function"&&!ve.startsWith("file://"))return fetch(ve,{credentials:"same-origin"}).then(function(X){if(!X.ok)throw"failed to load wasm binary file at '"+ve+"'";return X.arrayBuffer()}).catch(function(){return Ge()});if(l)return new Promise(function(X,K){l(ve,function(te){X(new Uint8Array(te))},K)})}return Promise.resolve().then(function(){return Ge()})}().then(function(X){return WebAssembly.instantiate(X,j)}).then(function(X){return X}).then(U,function(X){P("failed to asynchronously prepare wasm: "+X),Me(X)})}var j={a:kt};if($e++,a.monitorRunDependencies&&a.monitorRunDependencies($e),a.instantiateWasm)try{return a.instantiateWasm(j,E)}catch(U){return P("Module.instantiateWasm callback failed with error: "+U),!1}(S||typeof WebAssembly.instantiateStreaming!="function"||Pe()||ve.startsWith("file://")||w||typeof fetch!="function"?L(I):fetch(ve,{credentials:"same-origin"}).then(function(U){return WebAssembly.instantiateStreaming(U,j).then(I,function(X){return P("wasm streaming compile failed: "+X),P("falling back to ArrayBuffer instantiation"),L(I)})})).catch(f)})(),a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.La).apply(null,arguments)},a._OrtInit=function(){return(a._OrtInit=a.asm.Ma).apply(null,arguments)},a._OrtCreateSessionOptions=function(){return(a._OrtCreateSessionOptions=a.asm.Na).apply(null,arguments)},a._OrtAppendExecutionProvider=function(){return(a._OrtAppendExecutionProvider=a.asm.Oa).apply(null,arguments)},a._OrtAddSessionConfigEntry=function(){return(a._OrtAddSessionConfigEntry=a.asm.Pa).apply(null,arguments)},a._OrtReleaseSessionOptions=function(){return(a._OrtReleaseSessionOptions=a.asm.Qa).apply(null,arguments)},a._OrtCreateSession=function(){return(a._OrtCreateSession=a.asm.Ra).apply(null,arguments)},a._OrtReleaseSession=function(){return(a._OrtReleaseSession=a.asm.Sa).apply(null,arguments)},a._OrtGetInputCount=function(){return(a._OrtGetInputCount=a.asm.Ta).apply(null,arguments)},a._OrtGetOutputCount=function(){return(a._OrtGetOutputCount=a.asm.Ua).apply(null,arguments)},a._OrtGetInputName=function(){return(a._OrtGetInputName=a.asm.Va).apply(null,arguments)},a._OrtGetOutputName=function(){return(a._OrtGetOutputName=a.asm.Wa).apply(null,arguments)},a._OrtFree=function(){return(a._OrtFree=a.asm.Xa).apply(null,arguments)},a._OrtCreateTensor=function(){return(a._OrtCreateTensor=a.asm.Ya).apply(null,arguments)},a._OrtGetTensorData=function(){return(a._OrtGetTensorData=a.asm.Za).apply(null,arguments)},a._OrtReleaseTensor=function(){return(a._OrtReleaseTensor=a.asm._a).apply(null,arguments)},a._OrtCreateRunOptions=function(){return(a._OrtCreateRunOptions=a.asm.$a).apply(null,arguments)},a._OrtAddRunConfigEntry=function(){return(a._OrtAddRunConfigEntry=a.asm.ab).apply(null,arguments)},a._OrtReleaseRunOptions=function(){return(a._OrtReleaseRunOptions=a.asm.bb).apply(null,arguments)},a._OrtRun=function(){return(a._OrtRun=a.asm.cb).apply(null,arguments)},a._OrtEndProfiling=function(){return(a._OrtEndProfiling=a.asm.db).apply(null,arguments)};var Je,Te=a._malloc=function(){return(Te=a._malloc=a.asm.eb).apply(null,arguments)},ot=a._free=function(){return(ot=a._free=a.asm.fb).apply(null,arguments)},ft=a._fflush=function(){return(ft=a._fflush=a.asm.gb).apply(null,arguments)},st=a.___funcs_on_exit=function(){return(st=a.___funcs_on_exit=a.asm.hb).apply(null,arguments)},ae=a._setThrew=function(){return(ae=a._setThrew=a.asm.jb).apply(null,arguments)},ie=a.stackSave=function(){return(ie=a.stackSave=a.asm.kb).apply(null,arguments)},oe=a.stackRestore=function(){return(oe=a.stackRestore=a.asm.lb).apply(null,arguments)},gt=a.stackAlloc=function(){return(gt=a.stackAlloc=a.asm.mb).apply(null,arguments)},at=a.___cxa_can_catch=function(){return(at=a.___cxa_can_catch=a.asm.nb).apply(null,arguments)},mt=a.___cxa_is_pointer_type=function(){return(mt=a.___cxa_is_pointer_type=a.asm.ob).apply(null,arguments)},_t=a.dynCall_j=function(){return(_t=a.dynCall_j=a.asm.pb).apply(null,arguments)},bt=a.dynCall_iiiiij=function(){return(bt=a.dynCall_iiiiij=a.asm.qb).apply(null,arguments)},yt=a.dynCall_jii=function(){return(yt=a.dynCall_jii=a.asm.rb).apply(null,arguments)},wt=a.dynCall_viiiiij=function(){return(wt=a.dynCall_viiiiij=a.asm.sb).apply(null,arguments)},Tt=a.dynCall_vjji=function(){return(Tt=a.dynCall_vjji=a.asm.tb).apply(null,arguments)},xt=a.dynCall_viiijjjii=function(){return(xt=a.dynCall_viiijjjii=a.asm.ub).apply(null,arguments)},vt=a.dynCall_iij=function(){return(vt=a.dynCall_iij=a.asm.vb).apply(null,arguments)},St=a.dynCall_ji=function(){return(St=a.dynCall_ji=a.asm.wb).apply(null,arguments)},At=a.dynCall_iiiiiij=function(){return(At=a.dynCall_iiiiiij=a.asm.xb).apply(null,arguments)},Pt=a.dynCall_iiij=function(){return(Pt=a.dynCall_iiij=a.asm.yb).apply(null,arguments)};function Ot(){function E(){if(!Je&&(Je=!0,a.calledRun=!0,!D)){if(Xe(se),h(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;){var I=a.postRun.shift();be.unshift(I)}Xe(be)}}if(!(0<$e)){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)Le();Xe(xe),0<$e||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),E()},1)):E())}}if(a.UTF8ToString=V,a.stringToUTF8=function(E,I,L){return J(E,$,I,L)},a.lengthBytesUTF8=Z,a.stackSave=ie,a.stackRestore=oe,a.stackAlloc=gt,Fe=function E(){Je||Ot(),Je||(Fe=E)},a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0{m.exports=function(t,i){for(var s=new Array(arguments.length-1),u=0,d=2,a=!0;d{var i=t;i.length=function(h){var f=h.length;if(!f)return 0;for(var c=0;--f%4>1&&h.charAt(f)==="=";)++c;return Math.ceil(3*h.length)/4-c};for(var s=new Array(64),u=new Array(123),d=0;d<64;)u[s[d]=d<26?d+65:d<52?d+71:d<62?d-4:d-59|43]=d++;i.encode=function(h,f,c){for(var l,n=null,e=[],r=0,o=0;f>2],l=(3&p)<<4,o=1;break;case 1:e[r++]=s[l|p>>4],l=(15&p)<<2,o=2;break;case 2:e[r++]=s[l|p>>6],e[r++]=s[63&p],o=0}r>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,e)),r=0)}return o&&(e[r++]=s[l],e[r++]=61,o===1&&(e[r++]=61)),n?(r&&n.push(String.fromCharCode.apply(String,e.slice(0,r))),n.join("")):String.fromCharCode.apply(String,e.slice(0,r))};var a="invalid encoding";i.decode=function(h,f,c){for(var l,n=c,e=0,r=0;r1)break;if((o=u[o])===void 0)throw Error(a);switch(e){case 0:l=o,e=1;break;case 1:f[c++]=l<<2|(48&o)>>4,l=o,e=2;break;case 2:f[c++]=(15&l)<<4|(60&o)>>2,l=o,e=3;break;case 3:f[c++]=(3&l)<<6|o,e=0}}if(e===1)throw Error(a);return c-n},i.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9211:m=>{function t(){this._listeners={}}m.exports=t,t.prototype.on=function(i,s,u){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:s,ctx:u||this}),this},t.prototype.off=function(i,s){if(i===void 0)this._listeners={};else if(s===void 0)this._listeners[i]=[];else for(var u=this._listeners[i],d=0;d{function t(a){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),f=new Uint8Array(h.buffer),c=f[3]===128;function l(o,p,g){h[0]=o,p[g]=f[0],p[g+1]=f[1],p[g+2]=f[2],p[g+3]=f[3]}function n(o,p,g){h[0]=o,p[g]=f[3],p[g+1]=f[2],p[g+2]=f[1],p[g+3]=f[0]}function e(o,p){return f[0]=o[p],f[1]=o[p+1],f[2]=o[p+2],f[3]=o[p+3],h[0]}function r(o,p){return f[3]=o[p],f[2]=o[p+1],f[1]=o[p+2],f[0]=o[p+3],h[0]}a.writeFloatLE=c?l:n,a.writeFloatBE=c?n:l,a.readFloatLE=c?e:r,a.readFloatBE=c?r:e}():function(){function h(c,l,n,e){var r=l<0?1:0;if(r&&(l=-l),l===0)c(1/l>0?0:2147483648,n,e);else if(isNaN(l))c(2143289344,n,e);else if(l>34028234663852886e22)c((r<<31|2139095040)>>>0,n,e);else if(l<11754943508222875e-54)c((r<<31|Math.round(l/1401298464324817e-60))>>>0,n,e);else{var o=Math.floor(Math.log(l)/Math.LN2);c((r<<31|o+127<<23|8388607&Math.round(l*Math.pow(2,-o)*8388608))>>>0,n,e)}}function f(c,l,n){var e=c(l,n),r=2*(e>>31)+1,o=e>>>23&255,p=8388607&e;return o===255?p?NaN:r*(1/0):o===0?1401298464324817e-60*r*p:r*Math.pow(2,o-150)*(p+8388608)}a.writeFloatLE=h.bind(null,i),a.writeFloatBE=h.bind(null,s),a.readFloatLE=f.bind(null,u),a.readFloatBE=f.bind(null,d)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),f=new Uint8Array(h.buffer),c=f[7]===128;function l(o,p,g){h[0]=o,p[g]=f[0],p[g+1]=f[1],p[g+2]=f[2],p[g+3]=f[3],p[g+4]=f[4],p[g+5]=f[5],p[g+6]=f[6],p[g+7]=f[7]}function n(o,p,g){h[0]=o,p[g]=f[7],p[g+1]=f[6],p[g+2]=f[5],p[g+3]=f[4],p[g+4]=f[3],p[g+5]=f[2],p[g+6]=f[1],p[g+7]=f[0]}function e(o,p){return f[0]=o[p],f[1]=o[p+1],f[2]=o[p+2],f[3]=o[p+3],f[4]=o[p+4],f[5]=o[p+5],f[6]=o[p+6],f[7]=o[p+7],h[0]}function r(o,p){return f[7]=o[p],f[6]=o[p+1],f[5]=o[p+2],f[4]=o[p+3],f[3]=o[p+4],f[2]=o[p+5],f[1]=o[p+6],f[0]=o[p+7],h[0]}a.writeDoubleLE=c?l:n,a.writeDoubleBE=c?n:l,a.readDoubleLE=c?e:r,a.readDoubleBE=c?r:e}():function(){function h(c,l,n,e,r,o){var p=e<0?1:0;if(p&&(e=-e),e===0)c(0,r,o+l),c(1/e>0?0:2147483648,r,o+n);else if(isNaN(e))c(0,r,o+l),c(2146959360,r,o+n);else if(e>17976931348623157e292)c(0,r,o+l),c((p<<31|2146435072)>>>0,r,o+n);else{var g;if(e<22250738585072014e-324)c((g=e/5e-324)>>>0,r,o+l),c((p<<31|g/4294967296)>>>0,r,o+n);else{var _=Math.floor(Math.log(e)/Math.LN2);_===1024&&(_=1023),c(4503599627370496*(g=e*Math.pow(2,-_))>>>0,r,o+l),c((p<<31|_+1023<<20|1048576*g&1048575)>>>0,r,o+n)}}}function f(c,l,n,e,r){var o=c(e,r+l),p=c(e,r+n),g=2*(p>>31)+1,_=p>>>20&2047,b=4294967296*(1048575&p)+o;return _===2047?b?NaN:g*(1/0):_===0?5e-324*g*b:g*Math.pow(2,_-1075)*(b+4503599627370496)}a.writeDoubleLE=h.bind(null,i,0,4),a.writeDoubleBE=h.bind(null,s,4,0),a.readDoubleLE=f.bind(null,u,0,4),a.readDoubleBE=f.bind(null,d,4,0)}(),a}function i(a,h,f){h[f]=255&a,h[f+1]=a>>>8&255,h[f+2]=a>>>16&255,h[f+3]=a>>>24}function s(a,h,f){h[f]=a>>>24,h[f+1]=a>>>16&255,h[f+2]=a>>>8&255,h[f+3]=255&a}function u(a,h){return(a[h]|a[h+1]<<8|a[h+2]<<16|a[h+3]<<24)>>>0}function d(a,h){return(a[h]<<24|a[h+1]<<16|a[h+2]<<8|a[h+3])>>>0}m.exports=t(t)},7199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(m){}return null}module.exports=inquire},6662:m=>{m.exports=function(t,i,s){var u=s||8192,d=u>>>1,a=null,h=u;return function(f){if(f<1||f>d)return t(f);h+f>u&&(a=t(u),h=0);var c=i.call(a,h,h+=f);return 7&h&&(h=1+(7|h)),c}}},4997:(m,t)=>{var i=t;i.length=function(s){for(var u=0,d=0,a=0;a191&&a<224?f[c++]=(31&a)<<6|63&s[u++]:a>239&&a<365?(a=((7&a)<<18|(63&s[u++])<<12|(63&s[u++])<<6|63&s[u++])-65536,f[c++]=55296+(a>>10),f[c++]=56320+(1023&a)):f[c++]=(15&a)<<12|(63&s[u++])<<6|63&s[u++],c>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,f)),c=0);return h?(c&&h.push(String.fromCharCode.apply(String,f.slice(0,c))),h.join("")):String.fromCharCode.apply(String,f.slice(0,c))},i.write=function(s,u,d){for(var a,h,f=d,c=0;c>6|192,u[d++]=63&a|128):(64512&a)==55296&&(64512&(h=s.charCodeAt(c+1)))==56320?(a=65536+((1023&a)<<10)+(1023&h),++c,u[d++]=a>>18|240,u[d++]=a>>12&63|128,u[d++]=a>>6&63|128,u[d++]=63&a|128):(u[d++]=a>>12|224,u[d++]=a>>6&63|128,u[d++]=63&a|128);return d-f}},3442:(m,t)=>{t.__esModule=!0;var i=function(){function s(u){if(!u)throw new TypeError("Invalid argument; `value` has no value.");this.value=s.EMPTY,u&&s.isGuid(u)&&(this.value=u)}return s.isGuid=function(u){var d=u.toString();return u&&(u instanceof s||s.validator.test(d))},s.create=function(){return new s([s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-"))},s.createEmpty=function(){return new s("emptyguid")},s.parse=function(u){return new s(u)},s.raw=function(){return[s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-")},s.gen=function(u){for(var d="",a=0;a{m.exports=i;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function i(x,M,N){this.low=0|x,this.high=0|M,this.unsigned=!!N}function s(x){return(x&&x.__isLong__)===!0}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0}),i.isLong=s;var u={},d={};function a(x,M){var N,z,$;return M?($=0<=(x>>>=0)&&x<256)&&(z=d[x])?z:(N=f(x,(0|x)<0?-1:0,!0),$&&(d[x]=N),N):($=-128<=(x|=0)&&x<128)&&(z=u[x])?z:(N=f(x,x<0?-1:0,!1),$&&(u[x]=N),N)}function h(x,M){if(isNaN(x))return M?_:g;if(M){if(x<0)return _;if(x>=r)return S}else{if(x<=-o)return A;if(x+1>=o)return T}return x<0?h(-x,M).neg():f(x%e|0,x/e|0,M)}function f(x,M,N){return new i(x,M,N)}i.fromInt=a,i.fromNumber=h,i.fromBits=f;var c=Math.pow;function l(x,M,N){if(x.length===0)throw Error("empty string");if(x==="NaN"||x==="Infinity"||x==="+Infinity"||x==="-Infinity")return g;if(typeof M=="number"?(N=M,M=!1):M=!!M,(N=N||10)<2||360)throw Error("interior hyphen");if(z===0)return l(x.substring(1),M,N).neg();for(var $=h(c(N,8)),C=g,G=0;G>>0:this.low},P.toNumber=function(){return this.unsigned?(this.high>>>0)*e+(this.low>>>0):this.high*e+(this.low>>>0)},P.toString=function(x){if((x=x||10)<2||36>>0).toString(x);if((C=D).isZero())return R+G;for(;R.length<6;)R="0"+R;G=""+R+G}},P.getHighBits=function(){return this.high},P.getHighBitsUnsigned=function(){return this.high>>>0},P.getLowBits=function(){return this.low},P.getLowBitsUnsigned=function(){return this.low>>>0},P.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,M=31;M>0&&!(x&1<=0},P.isOdd=function(){return(1&this.low)==1},P.isEven=function(){return(1&this.low)==0},P.equals=function(x){return s(x)||(x=n(x)),(this.unsigned===x.unsigned||this.high>>>31!=1||x.high>>>31!=1)&&this.high===x.high&&this.low===x.low},P.eq=P.equals,P.notEquals=function(x){return!this.eq(x)},P.neq=P.notEquals,P.ne=P.notEquals,P.lessThan=function(x){return this.comp(x)<0},P.lt=P.lessThan,P.lessThanOrEqual=function(x){return this.comp(x)<=0},P.lte=P.lessThanOrEqual,P.le=P.lessThanOrEqual,P.greaterThan=function(x){return this.comp(x)>0},P.gt=P.greaterThan,P.greaterThanOrEqual=function(x){return this.comp(x)>=0},P.gte=P.greaterThanOrEqual,P.ge=P.greaterThanOrEqual,P.compare=function(x){if(s(x)||(x=n(x)),this.eq(x))return 0;var M=this.isNegative(),N=x.isNegative();return M&&!N?-1:!M&&N?1:this.unsigned?x.high>>>0>this.high>>>0||x.high===this.high&&x.low>>>0>this.low>>>0?-1:1:this.sub(x).isNegative()?-1:1},P.comp=P.compare,P.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(b)},P.neg=P.negate,P.add=function(x){s(x)||(x=n(x));var M=this.high>>>16,N=65535&this.high,z=this.low>>>16,$=65535&this.low,C=x.high>>>16,G=65535&x.high,D=x.low>>>16,R=0,Y=0,V=0,J=0;return V+=(J+=$+(65535&x.low))>>>16,Y+=(V+=z+D)>>>16,R+=(Y+=N+G)>>>16,R+=M+C,f((V&=65535)<<16|(J&=65535),(R&=65535)<<16|(Y&=65535),this.unsigned)},P.subtract=function(x){return s(x)||(x=n(x)),this.add(x.neg())},P.sub=P.subtract,P.multiply=function(x){if(this.isZero())return g;if(s(x)||(x=n(x)),t)return f(t.mul(this.low,this.high,x.low,x.high),t.get_high(),this.unsigned);if(x.isZero())return g;if(this.eq(A))return x.isOdd()?A:g;if(x.eq(A))return this.isOdd()?A:g;if(this.isNegative())return x.isNegative()?this.neg().mul(x.neg()):this.neg().mul(x).neg();if(x.isNegative())return this.mul(x.neg()).neg();if(this.lt(p)&&x.lt(p))return h(this.toNumber()*x.toNumber(),this.unsigned);var M=this.high>>>16,N=65535&this.high,z=this.low>>>16,$=65535&this.low,C=x.high>>>16,G=65535&x.high,D=x.low>>>16,R=65535&x.low,Y=0,V=0,J=0,Z=0;return J+=(Z+=$*R)>>>16,V+=(J+=z*R)>>>16,J&=65535,V+=(J+=$*D)>>>16,Y+=(V+=N*R)>>>16,V&=65535,Y+=(V+=z*D)>>>16,V&=65535,Y+=(V+=$*G)>>>16,Y+=M*R+N*D+z*G+$*C,f((J&=65535)<<16|(Z&=65535),(Y&=65535)<<16|(V&=65535),this.unsigned)},P.mul=P.multiply,P.divide=function(x){if(s(x)||(x=n(x)),x.isZero())throw Error("division by zero");var M,N,z;if(t)return this.unsigned||this.high!==-2147483648||x.low!==-1||x.high!==-1?f((this.unsigned?t.div_u:t.div_s)(this.low,this.high,x.low,x.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?_:g;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return _;if(x.gt(this.shru(1)))return y;z=_}else{if(this.eq(A))return x.eq(b)||x.eq(w)?A:x.eq(A)?b:(M=this.shr(1).div(x).shl(1)).eq(g)?x.isNegative()?b:w:(N=this.sub(x.mul(M)),z=M.add(N.div(x)));if(x.eq(A))return this.unsigned?_:g;if(this.isNegative())return x.isNegative()?this.neg().div(x.neg()):this.neg().div(x).neg();if(x.isNegative())return this.div(x.neg()).neg();z=g}for(N=this;N.gte(x);){M=Math.max(1,Math.floor(N.toNumber()/x.toNumber()));for(var $=Math.ceil(Math.log(M)/Math.LN2),C=$<=48?1:c(2,$-48),G=h(M),D=G.mul(x);D.isNegative()||D.gt(N);)D=(G=h(M-=C,this.unsigned)).mul(x);G.isZero()&&(G=b),z=z.add(G),N=N.sub(D)}return z},P.div=P.divide,P.modulo=function(x){return s(x)||(x=n(x)),t?f((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,x.low,x.high),t.get_high(),this.unsigned):this.sub(this.div(x).mul(x))},P.mod=P.modulo,P.rem=P.modulo,P.not=function(){return f(~this.low,~this.high,this.unsigned)},P.and=function(x){return s(x)||(x=n(x)),f(this.low&x.low,this.high&x.high,this.unsigned)},P.or=function(x){return s(x)||(x=n(x)),f(this.low|x.low,this.high|x.high,this.unsigned)},P.xor=function(x){return s(x)||(x=n(x)),f(this.low^x.low,this.high^x.high,this.unsigned)},P.shiftLeft=function(x){return s(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?f(this.low<>>32-x,this.unsigned):f(0,this.low<>>x|this.high<<32-x,this.high>>x,this.unsigned):f(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},P.shr=P.shiftRight,P.shiftRightUnsigned=function(x){if(s(x)&&(x=x.toInt()),(x&=63)==0)return this;var M=this.high;return x<32?f(this.low>>>x|M<<32-x,M>>>x,this.unsigned):f(x===32?M:M>>>x-32,0,this.unsigned)},P.shru=P.shiftRightUnsigned,P.shr_u=P.shiftRightUnsigned,P.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},P.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},P.toBytes=function(x){return x?this.toBytesLE():this.toBytesBE()},P.toBytesLE=function(){var x=this.high,M=this.low;return[255&M,M>>>8&255,M>>>16&255,M>>>24,255&x,x>>>8&255,x>>>16&255,x>>>24]},P.toBytesBE=function(){var x=this.high,M=this.low;return[x>>>24,x>>>16&255,x>>>8&255,255&x,M>>>24,M>>>16&255,M>>>8&255,255&M]},i.fromBytes=function(x,M,N){return N?i.fromBytesLE(x,M):i.fromBytesBE(x,M)},i.fromBytesLE=function(x,M){return new i(x[0]|x[1]<<8|x[2]<<16|x[3]<<24,x[4]|x[5]<<8|x[6]<<16|x[7]<<24,M)},i.fromBytesBE=function(x,M){return new i(x[4]<<24|x[5]<<16|x[6]<<8|x[7],x[0]<<24|x[1]<<16|x[2]<<8|x[3],M)}},1446:(m,t,i)=>{var s,u,d,a=i(2100),h=a.Reader,f=a.Writer,c=a.util,l=a.roots.default||(a.roots.default={});l.onnx=((d={}).Version=(s={},(u=Object.create(s))[s[0]="_START_VERSION"]=0,u[s[1]="IR_VERSION_2017_10_10"]=1,u[s[2]="IR_VERSION_2017_10_30"]=2,u[s[3]="IR_VERSION_2017_11_3"]=3,u[s[4]="IR_VERSION_2019_1_22"]=4,u[s[5]="IR_VERSION"]=5,u),d.AttributeProto=function(){function n(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],e)for(var r=Object.keys(e),o=0;o>>3){case 1:p.name=e.string();break;case 21:p.refAttrName=e.string();break;case 13:p.docString=e.string();break;case 20:p.type=e.int32();break;case 2:p.f=e.float();break;case 3:p.i=e.int64();break;case 4:p.s=e.bytes();break;case 5:p.t=l.onnx.TensorProto.decode(e,e.uint32());break;case 6:p.g=l.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(p.floats&&p.floats.length||(p.floats=[]),(7&g)==2)for(var _=e.uint32()+e.pos;e.pos<_;)p.floats.push(e.float());else p.floats.push(e.float());break;case 8:if(p.ints&&p.ints.length||(p.ints=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.ints.push(e.int64());else p.ints.push(e.int64());break;case 9:p.strings&&p.strings.length||(p.strings=[]),p.strings.push(e.bytes());break;case 10:p.tensors&&p.tensors.length||(p.tensors=[]),p.tensors.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 11:p.graphs&&p.graphs.length||(p.graphs=[]),p.graphs.push(l.onnx.GraphProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!c.isString(e.name))return"name: string expected";if(e.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&!c.isString(e.refAttrName))return"refAttrName: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString))return"docString: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:}if(e.f!=null&&e.hasOwnProperty("f")&&typeof e.f!="number")return"f: number expected";if(e.i!=null&&e.hasOwnProperty("i")&&!(c.isInteger(e.i)||e.i&&c.isInteger(e.i.low)&&c.isInteger(e.i.high)))return"i: integer|Long expected";if(e.s!=null&&e.hasOwnProperty("s")&&!(e.s&&typeof e.s.length=="number"||c.isString(e.s)))return"s: buffer expected";if(e.t!=null&&e.hasOwnProperty("t")&&(o=l.onnx.TensorProto.verify(e.t)))return"t."+o;if(e.g!=null&&e.hasOwnProperty("g")&&(o=l.onnx.GraphProto.verify(e.g)))return"g."+o;if(e.floats!=null&&e.hasOwnProperty("floats")){if(!Array.isArray(e.floats))return"floats: array expected";for(var r=0;r>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?c.base64.decode(e.s,r.s=c.newBuffer(c.base64.length(e.s)),0):e.s.length&&(r.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");r.t=l.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");r.g=l.onnx.GraphProto.fromObject(e.g)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");r.floats=[];for(var o=0;o>>0,e.ints[o].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(r.strings=[],o=0;o>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(o.s=r.bytes===String?c.base64.encode(e.s,0,e.s.length):r.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(o.t=l.onnx.TensorProto.toObject(e.t,r)),e.g!=null&&e.hasOwnProperty("g")&&(o.g=l.onnx.GraphProto.toObject(e.g,r)),e.floats&&e.floats.length){o.floats=[];for(var g=0;g>>0,e.ints[g].high>>>0).toNumber():e.ints[g];if(e.strings&&e.strings.length)for(o.strings=[],g=0;g>>3){case 1:p.name=e.string();break;case 2:p.type=l.onnx.TypeProto.decode(e,e.uint32());break;case 3:p.docString=e.string();break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!c.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var r=l.onnx.TypeProto.verify(e.type);if(r)return"type."+r}return e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString)?"docString: string expected":null},n.fromObject=function(e){if(e instanceof l.onnx.ValueInfoProto)return e;var r=new l.onnx.ValueInfoProto;if(e.name!=null&&(r.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");r.type=l.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(r.docString=String(e.docString)),r},n.toObject=function(e,r){r||(r={});var o={};return r.defaults&&(o.name="",o.type=null,o.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(o.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(o.type=l.onnx.TypeProto.toObject(e.type,r)),e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),o},n.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},n}(),d.NodeProto=function(){function n(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var r=Object.keys(e),o=0;o>>3){case 1:p.input&&p.input.length||(p.input=[]),p.input.push(e.string());break;case 2:p.output&&p.output.length||(p.output=[]),p.output.push(e.string());break;case 3:p.name=e.string();break;case 4:p.opType=e.string();break;case 7:p.domain=e.string();break;case 5:p.attribute&&p.attribute.length||(p.attribute=[]),p.attribute.push(l.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:p.docString=e.string();break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var r=0;r>>3){case 1:p.irVersion=e.int64();break;case 8:p.opsetImport&&p.opsetImport.length||(p.opsetImport=[]),p.opsetImport.push(l.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:p.producerName=e.string();break;case 3:p.producerVersion=e.string();break;case 4:p.domain=e.string();break;case 5:p.modelVersion=e.int64();break;case 6:p.docString=e.string();break;case 7:p.graph=l.onnx.GraphProto.decode(e,e.uint32());break;case 14:p.metadataProps&&p.metadataProps.length||(p.metadataProps=[]),p.metadataProps.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!(c.isInteger(e.irVersion)||e.irVersion&&c.isInteger(e.irVersion.low)&&c.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(e.opsetImport!=null&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var r=0;r>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");r.opsetImport=[];for(var o=0;o>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(r.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");r.graph=l.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(r.metadataProps=[],o=0;o>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(o.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(o.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(o.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?o.modelVersion=r.longs===String?String(e.modelVersion):e.modelVersion:o.modelVersion=r.longs===String?c.Long.prototype.toString.call(e.modelVersion):r.longs===Number?new c.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(o.graph=l.onnx.GraphProto.toObject(e.graph,r)),e.opsetImport&&e.opsetImport.length){o.opsetImport=[];for(var g=0;g>>3){case 1:p.key=e.string();break;case 2:p.value=e.string();break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!c.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!c.isString(e.value)?"value: string expected":null},n.fromObject=function(e){if(e instanceof l.onnx.StringStringEntryProto)return e;var r=new l.onnx.StringStringEntryProto;return e.key!=null&&(r.key=String(e.key)),e.value!=null&&(r.value=String(e.value)),r},n.toObject=function(e,r){r||(r={});var o={};return r.defaults&&(o.key="",o.value=""),e.key!=null&&e.hasOwnProperty("key")&&(o.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(o.value=e.value),o},n.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},n}(),d.TensorAnnotation=function(){function n(e){if(this.quantParameterTensorNames=[],e)for(var r=Object.keys(e),o=0;o>>3){case 1:p.tensorName=e.string();break;case 2:p.quantParameterTensorNames&&p.quantParameterTensorNames.length||(p.quantParameterTensorNames=[]),p.quantParameterTensorNames.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!c.isString(e.tensorName))return"tensorName: string expected";if(e.quantParameterTensorNames!=null&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var r=0;r>>3){case 1:p.node&&p.node.length||(p.node=[]),p.node.push(l.onnx.NodeProto.decode(e,e.uint32()));break;case 2:p.name=e.string();break;case 5:p.initializer&&p.initializer.length||(p.initializer=[]),p.initializer.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 10:p.docString=e.string();break;case 11:p.input&&p.input.length||(p.input=[]),p.input.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:p.output&&p.output.length||(p.output=[]),p.output.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:p.valueInfo&&p.valueInfo.length||(p.valueInfo=[]),p.valueInfo.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:p.quantizationAnnotation&&p.quantizationAnnotation.length||(p.quantizationAnnotation=[]),p.quantizationAnnotation.push(l.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var r=0;r>>3){case 1:if(p.dims&&p.dims.length||(p.dims=[]),(7&g)==2)for(var _=e.uint32()+e.pos;e.pos<_;)p.dims.push(e.int64());else p.dims.push(e.int64());break;case 2:p.dataType=e.int32();break;case 3:p.segment=l.onnx.TensorProto.Segment.decode(e,e.uint32());break;case 4:if(p.floatData&&p.floatData.length||(p.floatData=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.floatData.push(e.float());else p.floatData.push(e.float());break;case 5:if(p.int32Data&&p.int32Data.length||(p.int32Data=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.int32Data.push(e.int32());else p.int32Data.push(e.int32());break;case 6:p.stringData&&p.stringData.length||(p.stringData=[]),p.stringData.push(e.bytes());break;case 7:if(p.int64Data&&p.int64Data.length||(p.int64Data=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.int64Data.push(e.int64());else p.int64Data.push(e.int64());break;case 8:p.name=e.string();break;case 12:p.docString=e.string();break;case 9:p.rawData=e.bytes();break;case 13:p.externalData&&p.externalData.length||(p.externalData=[]),p.externalData.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;case 14:p.dataLocation=e.int32();break;case 10:if(p.doubleData&&p.doubleData.length||(p.doubleData=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.doubleData.push(e.double());else p.doubleData.push(e.double());break;case 11:if(p.uint64Data&&p.uint64Data.length||(p.uint64Data=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.uint64Data.push(e.uint64());else p.uint64Data.push(e.uint64());break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dims!=null&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var r=0;r>>0,e.dims[o].high>>>0).toNumber())}if(e.dataType!=null&&(r.dataType=0|e.dataType),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");r.segment=l.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(r.floatData=[],o=0;o>>0,e.int64Data[o].high>>>0).toNumber())}if(e.name!=null&&(r.name=String(e.name)),e.docString!=null&&(r.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?c.base64.decode(e.rawData,r.rawData=c.newBuffer(c.base64.length(e.rawData)),0):e.rawData.length&&(r.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(r.externalData=[],o=0;o>>0,e.uint64Data[o].high>>>0).toNumber(!0))}return r},n.toObject=function(e,r){r||(r={});var o={};if((r.arrays||r.defaults)&&(o.dims=[],o.floatData=[],o.int32Data=[],o.stringData=[],o.int64Data=[],o.doubleData=[],o.uint64Data=[],o.externalData=[]),r.defaults&&(o.dataType=0,o.segment=null,o.name="",r.bytes===String?o.rawData="":(o.rawData=[],r.bytes!==Array&&(o.rawData=c.newBuffer(o.rawData))),o.docString="",o.dataLocation=r.enums===String?"DEFAULT":0),e.dims&&e.dims.length){o.dims=[];for(var p=0;p>>0,e.dims[p].high>>>0).toNumber():e.dims[p]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(o.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(o.segment=l.onnx.TensorProto.Segment.toObject(e.segment,r)),e.floatData&&e.floatData.length)for(o.floatData=[],p=0;p>>0,e.int64Data[p].high>>>0).toNumber():e.int64Data[p];if(e.name!=null&&e.hasOwnProperty("name")&&(o.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(o.rawData=r.bytes===String?c.base64.encode(e.rawData,0,e.rawData.length):r.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(o.doubleData=[],p=0;p>>0,e.uint64Data[p].high>>>0).toNumber(!0):e.uint64Data[p];if(e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),e.externalData&&e.externalData.length)for(o.externalData=[],p=0;p>>3){case 1:g.begin=r.int64();break;case 2:g.end=r.int64();break;default:r.skipType(7&_)}}return g},e.decodeDelimited=function(r){return r instanceof h||(r=new h(r)),this.decode(r,r.uint32())},e.verify=function(r){return typeof r!="object"||r===null?"object expected":r.begin!=null&&r.hasOwnProperty("begin")&&!(c.isInteger(r.begin)||r.begin&&c.isInteger(r.begin.low)&&c.isInteger(r.begin.high))?"begin: integer|Long expected":r.end!=null&&r.hasOwnProperty("end")&&!(c.isInteger(r.end)||r.end&&c.isInteger(r.end.low)&&c.isInteger(r.end.high))?"end: integer|Long expected":null},e.fromObject=function(r){if(r instanceof l.onnx.TensorProto.Segment)return r;var o=new l.onnx.TensorProto.Segment;return r.begin!=null&&(c.Long?(o.begin=c.Long.fromValue(r.begin)).unsigned=!1:typeof r.begin=="string"?o.begin=parseInt(r.begin,10):typeof r.begin=="number"?o.begin=r.begin:typeof r.begin=="object"&&(o.begin=new c.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber())),r.end!=null&&(c.Long?(o.end=c.Long.fromValue(r.end)).unsigned=!1:typeof r.end=="string"?o.end=parseInt(r.end,10):typeof r.end=="number"?o.end=r.end:typeof r.end=="object"&&(o.end=new c.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber())),o},e.toObject=function(r,o){o||(o={});var p={};if(o.defaults){if(c.Long){var g=new c.Long(0,0,!1);p.begin=o.longs===String?g.toString():o.longs===Number?g.toNumber():g}else p.begin=o.longs===String?"0":0;c.Long?(g=new c.Long(0,0,!1),p.end=o.longs===String?g.toString():o.longs===Number?g.toNumber():g):p.end=o.longs===String?"0":0}return r.begin!=null&&r.hasOwnProperty("begin")&&(typeof r.begin=="number"?p.begin=o.longs===String?String(r.begin):r.begin:p.begin=o.longs===String?c.Long.prototype.toString.call(r.begin):o.longs===Number?new c.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber():r.begin),r.end!=null&&r.hasOwnProperty("end")&&(typeof r.end=="number"?p.end=o.longs===String?String(r.end):r.end:p.end=o.longs===String?c.Long.prototype.toString.call(r.end):o.longs===Number?new c.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber():r.end),p},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),n.DataLocation=function(){var e={},r=Object.create(e);return r[e[0]="DEFAULT"]=0,r[e[1]="EXTERNAL"]=1,r}(),n}(),d.TensorShapeProto=function(){function n(e){if(this.dim=[],e)for(var r=Object.keys(e),o=0;o>>3==1?(p.dim&&p.dim.length||(p.dim=[]),p.dim.push(l.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&g)}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dim!=null&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var r=0;r>>3){case 1:_.dimValue=o.int64();break;case 2:_.dimParam=o.string();break;case 3:_.denotation=o.string();break;default:o.skipType(7&b)}}return _},e.decodeDelimited=function(o){return o instanceof h||(o=new h(o)),this.decode(o,o.uint32())},e.verify=function(o){if(typeof o!="object"||o===null)return"object expected";var p={};if(o.dimValue!=null&&o.hasOwnProperty("dimValue")&&(p.value=1,!(c.isInteger(o.dimValue)||o.dimValue&&c.isInteger(o.dimValue.low)&&c.isInteger(o.dimValue.high))))return"dimValue: integer|Long expected";if(o.dimParam!=null&&o.hasOwnProperty("dimParam")){if(p.value===1)return"value: multiple values";if(p.value=1,!c.isString(o.dimParam))return"dimParam: string expected"}return o.denotation!=null&&o.hasOwnProperty("denotation")&&!c.isString(o.denotation)?"denotation: string expected":null},e.fromObject=function(o){if(o instanceof l.onnx.TensorShapeProto.Dimension)return o;var p=new l.onnx.TensorShapeProto.Dimension;return o.dimValue!=null&&(c.Long?(p.dimValue=c.Long.fromValue(o.dimValue)).unsigned=!1:typeof o.dimValue=="string"?p.dimValue=parseInt(o.dimValue,10):typeof o.dimValue=="number"?p.dimValue=o.dimValue:typeof o.dimValue=="object"&&(p.dimValue=new c.LongBits(o.dimValue.low>>>0,o.dimValue.high>>>0).toNumber())),o.dimParam!=null&&(p.dimParam=String(o.dimParam)),o.denotation!=null&&(p.denotation=String(o.denotation)),p},e.toObject=function(o,p){p||(p={});var g={};return p.defaults&&(g.denotation=""),o.dimValue!=null&&o.hasOwnProperty("dimValue")&&(typeof o.dimValue=="number"?g.dimValue=p.longs===String?String(o.dimValue):o.dimValue:g.dimValue=p.longs===String?c.Long.prototype.toString.call(o.dimValue):p.longs===Number?new c.LongBits(o.dimValue.low>>>0,o.dimValue.high>>>0).toNumber():o.dimValue,p.oneofs&&(g.value="dimValue")),o.dimParam!=null&&o.hasOwnProperty("dimParam")&&(g.dimParam=o.dimParam,p.oneofs&&(g.value="dimParam")),o.denotation!=null&&o.hasOwnProperty("denotation")&&(g.denotation=o.denotation),g},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),n}(),d.TypeProto=function(){function n(r){if(r)for(var o=Object.keys(r),p=0;p>>3){case 1:g.tensorType=l.onnx.TypeProto.Tensor.decode(r,r.uint32());break;case 6:g.denotation=r.string();break;default:r.skipType(7&_)}}return g},n.decodeDelimited=function(r){return r instanceof h||(r=new h(r)),this.decode(r,r.uint32())},n.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.tensorType!=null&&r.hasOwnProperty("tensorType")){var o=l.onnx.TypeProto.Tensor.verify(r.tensorType);if(o)return"tensorType."+o}return r.denotation!=null&&r.hasOwnProperty("denotation")&&!c.isString(r.denotation)?"denotation: string expected":null},n.fromObject=function(r){if(r instanceof l.onnx.TypeProto)return r;var o=new l.onnx.TypeProto;if(r.tensorType!=null){if(typeof r.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");o.tensorType=l.onnx.TypeProto.Tensor.fromObject(r.tensorType)}return r.denotation!=null&&(o.denotation=String(r.denotation)),o},n.toObject=function(r,o){o||(o={});var p={};return o.defaults&&(p.denotation=""),r.tensorType!=null&&r.hasOwnProperty("tensorType")&&(p.tensorType=l.onnx.TypeProto.Tensor.toObject(r.tensorType,o),o.oneofs&&(p.value="tensorType")),r.denotation!=null&&r.hasOwnProperty("denotation")&&(p.denotation=r.denotation),p},n.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},n.Tensor=function(){function r(o){if(o)for(var p=Object.keys(o),g=0;g>>3){case 1:_.elemType=o.int32();break;case 2:_.shape=l.onnx.TensorShapeProto.decode(o,o.uint32());break;default:o.skipType(7&b)}}return _},r.decodeDelimited=function(o){return o instanceof h||(o=new h(o)),this.decode(o,o.uint32())},r.verify=function(o){if(typeof o!="object"||o===null)return"object expected";if(o.elemType!=null&&o.hasOwnProperty("elemType")&&!c.isInteger(o.elemType))return"elemType: integer expected";if(o.shape!=null&&o.hasOwnProperty("shape")){var p=l.onnx.TensorShapeProto.verify(o.shape);if(p)return"shape."+p}return null},r.fromObject=function(o){if(o instanceof l.onnx.TypeProto.Tensor)return o;var p=new l.onnx.TypeProto.Tensor;if(o.elemType!=null&&(p.elemType=0|o.elemType),o.shape!=null){if(typeof o.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");p.shape=l.onnx.TensorShapeProto.fromObject(o.shape)}return p},r.toObject=function(o,p){p||(p={});var g={};return p.defaults&&(g.elemType=0,g.shape=null),o.elemType!=null&&o.hasOwnProperty("elemType")&&(g.elemType=o.elemType),o.shape!=null&&o.hasOwnProperty("shape")&&(g.shape=l.onnx.TensorShapeProto.toObject(o.shape,p)),g},r.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},r}(),n}(),d.OperatorSetIdProto=function(){function n(e){if(e)for(var r=Object.keys(e),o=0;o>>3){case 1:p.domain=e.string();break;case 2:p.version=e.int64();break;default:e.skipType(7&g)}}return p},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!c.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!(c.isInteger(e.version)||e.version&&c.isInteger(e.version.low)&&c.isInteger(e.version.high))?"version: integer|Long expected":null},n.fromObject=function(e){if(e instanceof l.onnx.OperatorSetIdProto)return e;var r=new l.onnx.OperatorSetIdProto;return e.domain!=null&&(r.domain=String(e.domain)),e.version!=null&&(c.Long?(r.version=c.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?r.version=parseInt(e.version,10):typeof e.version=="number"?r.version=e.version:typeof e.version=="object"&&(r.version=new c.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),r},n.toObject=function(e,r){r||(r={});var o={};if(r.defaults)if(o.domain="",c.Long){var p=new c.Long(0,0,!1);o.version=r.longs===String?p.toString():r.longs===Number?p.toNumber():p}else o.version=r.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(o.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?o.version=r.longs===String?String(e.version):e.version:o.version=r.longs===String?c.Long.prototype.toString.call(e.version):r.longs===Number?new c.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),o},n.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},n}(),d),m.exports=l},2100:(m,t,i)=>{m.exports=i(9482)},9482:(m,t,i)=>{var s=t;function u(){s.util._configure(),s.Writer._configure(s.BufferWriter),s.Reader._configure(s.BufferReader)}s.build="minimal",s.Writer=i(1173),s.BufferWriter=i(3155),s.Reader=i(1408),s.BufferReader=i(593),s.util=i(9693),s.rpc=i(5994),s.roots=i(5054),s.configure=u,u()},1408:(m,t,i)=>{m.exports=f;var s,u=i(9693),d=u.LongBits,a=u.utf8;function h(p,g){return RangeError("index out of range: "+p.pos+" + "+(g||1)+" > "+p.len)}function f(p){this.buf=p,this.pos=0,this.len=p.length}var c,l=typeof Uint8Array<"u"?function(p){if(p instanceof Uint8Array||Array.isArray(p))return new f(p);throw Error("illegal buffer")}:function(p){if(Array.isArray(p))return new f(p);throw Error("illegal buffer")},n=function(){return u.Buffer?function(p){return(f.create=function(g){return u.Buffer.isBuffer(g)?new s(g):l(g)})(p)}:l};function e(){var p=new d(0,0),g=0;if(!(this.len-this.pos>4)){for(;g<3;++g){if(this.pos>=this.len)throw h(this);if(p.lo=(p.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return p}return p.lo=(p.lo|(127&this.buf[this.pos++])<<7*g)>>>0,p}for(;g<4;++g)if(p.lo=(p.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return p;if(p.lo=(p.lo|(127&this.buf[this.pos])<<28)>>>0,p.hi=(p.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return p;if(g=0,this.len-this.pos>4){for(;g<5;++g)if(p.hi=(p.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return p}else for(;g<5;++g){if(this.pos>=this.len)throw h(this);if(p.hi=(p.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return p}throw Error("invalid varint encoding")}function r(p,g){return(p[g-4]|p[g-3]<<8|p[g-2]<<16|p[g-1]<<24)>>>0}function o(){if(this.pos+8>this.len)throw h(this,8);return new d(r(this.buf,this.pos+=4),r(this.buf,this.pos+=4))}f.create=n(),f.prototype._slice=u.Array.prototype.subarray||u.Array.prototype.slice,f.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return c;if((this.pos+=5)>this.len)throw this.pos=this.len,h(this,10);return c}),f.prototype.int32=function(){return 0|this.uint32()},f.prototype.sint32=function(){var p=this.uint32();return p>>>1^-(1&p)|0},f.prototype.bool=function(){return this.uint32()!==0},f.prototype.fixed32=function(){if(this.pos+4>this.len)throw h(this,4);return r(this.buf,this.pos+=4)},f.prototype.sfixed32=function(){if(this.pos+4>this.len)throw h(this,4);return 0|r(this.buf,this.pos+=4)},f.prototype.float=function(){if(this.pos+4>this.len)throw h(this,4);var p=u.float.readFloatLE(this.buf,this.pos);return this.pos+=4,p},f.prototype.double=function(){if(this.pos+8>this.len)throw h(this,4);var p=u.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,p},f.prototype.bytes=function(){var p=this.uint32(),g=this.pos,_=this.pos+p;if(_>this.len)throw h(this,p);return this.pos+=p,Array.isArray(this.buf)?this.buf.slice(g,_):g===_?new this.buf.constructor(0):this._slice.call(this.buf,g,_)},f.prototype.string=function(){var p=this.bytes();return a.read(p,0,p.length)},f.prototype.skip=function(p){if(typeof p=="number"){if(this.pos+p>this.len)throw h(this,p);this.pos+=p}else do if(this.pos>=this.len)throw h(this);while(128&this.buf[this.pos++]);return this},f.prototype.skipType=function(p){switch(p){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(p=7&this.uint32())!=4;)this.skipType(p);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+p+" at offset "+this.pos)}return this},f._configure=function(p){s=p,f.create=n(),s._configure();var g=u.Long?"toLong":"toNumber";u.merge(f.prototype,{int64:function(){return e.call(this)[g](!1)},uint64:function(){return e.call(this)[g](!0)},sint64:function(){return e.call(this).zzDecode()[g](!1)},fixed64:function(){return o.call(this)[g](!0)},sfixed64:function(){return o.call(this)[g](!1)}})}},593:(m,t,i)=>{m.exports=d;var s=i(1408);(d.prototype=Object.create(s.prototype)).constructor=d;var u=i(9693);function d(a){s.call(this,a)}d._configure=function(){u.Buffer&&(d.prototype._slice=u.Buffer.prototype.slice)},d.prototype.string=function(){var a=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+a,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+a,this.len))},d._configure()},5054:m=>{m.exports={}},5994:(m,t,i)=>{t.Service=i(7948)},7948:(m,t,i)=>{m.exports=u;var s=i(9693);function u(d,a,h){if(typeof d!="function")throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=d,this.requestDelimited=!!a,this.responseDelimited=!!h}(u.prototype=Object.create(s.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function d(a,h,f,c,l){if(!c)throw TypeError("request must be specified");var n=this;if(!l)return s.asPromise(d,n,a,h,f,c);if(n.rpcImpl)try{return n.rpcImpl(a,h[n.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(e,r){if(e)return n.emit("error",e,a),l(e);if(r!==null){if(!(r instanceof f))try{r=f[n.responseDelimited?"decodeDelimited":"decode"](r)}catch(o){return n.emit("error",o,a),l(o)}return n.emit("data",r,a),l(null,r)}n.end(!0)})}catch(e){return n.emit("error",e,a),void setTimeout(function(){l(e)},0)}else setTimeout(function(){l(Error("already ended"))},0)},u.prototype.end=function(d){return this.rpcImpl&&(d||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(m,t,i)=>{m.exports=u;var s=i(9693);function u(f,c){this.lo=f>>>0,this.hi=c>>>0}var d=u.zero=new u(0,0);d.toNumber=function(){return 0},d.zzEncode=d.zzDecode=function(){return this},d.length=function(){return 1};var a=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(f){if(f===0)return d;var c=f<0;c&&(f=-f);var l=f>>>0,n=(f-l)/4294967296>>>0;return c&&(n=~n>>>0,l=~l>>>0,++l>4294967295&&(l=0,++n>4294967295&&(n=0))),new u(l,n)},u.from=function(f){if(typeof f=="number")return u.fromNumber(f);if(s.isString(f)){if(!s.Long)return u.fromNumber(parseInt(f,10));f=s.Long.fromString(f)}return f.low||f.high?new u(f.low>>>0,f.high>>>0):d},u.prototype.toNumber=function(f){if(!f&&this.hi>>>31){var c=1+~this.lo>>>0,l=~this.hi>>>0;return c||(l=l+1>>>0),-(c+4294967296*l)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(f){return s.Long?new s.Long(0|this.lo,0|this.hi,!!f):{low:0|this.lo,high:0|this.hi,unsigned:!!f}};var h=String.prototype.charCodeAt;u.fromHash=function(f){return f===a?d:new u((h.call(f,0)|h.call(f,1)<<8|h.call(f,2)<<16|h.call(f,3)<<24)>>>0,(h.call(f,4)|h.call(f,5)<<8|h.call(f,6)<<16|h.call(f,7)<<24)>>>0)},u.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},u.prototype.zzEncode=function(){var f=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^f)>>>0,this.lo=(this.lo<<1^f)>>>0,this},u.prototype.zzDecode=function(){var f=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^f)>>>0,this.hi=(this.hi>>>1^f)>>>0,this},u.prototype.length=function(){var f=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,l=this.hi>>>24;return l===0?c===0?f<16384?f<128?1:2:f<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:l<128?9:10}},9693:function(m,t,i){var s=t;function u(a,h,f){for(var c=Object.keys(h),l=0;l0)},s.Buffer=function(){try{var a=s.inquire("buffer").Buffer;return a.prototype.utf8Write?a:null}catch{return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(a){return typeof a=="number"?s.Buffer?s._Buffer_allocUnsafe(a):new s.Array(a):s.Buffer?s._Buffer_from(a):typeof Uint8Array>"u"?a:new Uint8Array(a)},s.Array=typeof Uint8Array<"u"?Uint8Array:Array,s.Long=s.global.dcodeIO&&s.global.dcodeIO.Long||s.global.Long||s.inquire("long"),s.key2Re=/^true|false|0|1$/,s.key32Re=/^-?(?:0|[1-9][0-9]*)$/,s.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,s.longToHash=function(a){return a?s.LongBits.from(a).toHash():s.LongBits.zeroHash},s.longFromHash=function(a,h){var f=s.LongBits.fromHash(a);return s.Long?s.Long.fromBits(f.lo,f.hi,h):f.toNumber(!!h)},s.merge=u,s.lcFirst=function(a){return a.charAt(0).toLowerCase()+a.substring(1)},s.newError=d,s.ProtocolError=d("ProtocolError"),s.oneOfGetter=function(a){for(var h={},f=0;f-1;--l)if(h[c[l]]===1&&this[c[l]]!==void 0&&this[c[l]]!==null)return c[l]}},s.oneOfSetter=function(a){return function(h){for(var f=0;f{m.exports=n;var s,u=i(9693),d=u.LongBits,a=u.base64,h=u.utf8;function f(b,y,w){this.fn=b,this.len=y,this.next=void 0,this.val=w}function c(){}function l(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function n(){this.len=0,this.head=new f(c,0,0),this.tail=this.head,this.states=null}var e=function(){return u.Buffer?function(){return(n.create=function(){return new s})()}:function(){return new n}};function r(b,y,w){y[w]=255&b}function o(b,y){this.len=b,this.next=void 0,this.val=y}function p(b,y,w){for(;b.hi;)y[w++]=127&b.lo|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)y[w++]=127&b.lo|128,b.lo=b.lo>>>7;y[w++]=b.lo}function g(b,y,w){y[w]=255&b,y[w+1]=b>>>8&255,y[w+2]=b>>>16&255,y[w+3]=b>>>24}n.create=e(),n.alloc=function(b){return new u.Array(b)},u.Array!==Array&&(n.alloc=u.pool(n.alloc,u.Array.prototype.subarray)),n.prototype._push=function(b,y,w){return this.tail=this.tail.next=new f(b,y,w),this.len+=y,this},o.prototype=Object.create(f.prototype),o.prototype.fn=function(b,y,w){for(;b>127;)y[w++]=127&b|128,b>>>=7;y[w]=b},n.prototype.uint32=function(b){return this.len+=(this.tail=this.tail.next=new o((b>>>=0)<128?1:b<16384?2:b<2097152?3:b<268435456?4:5,b)).len,this},n.prototype.int32=function(b){return b<0?this._push(p,10,d.fromNumber(b)):this.uint32(b)},n.prototype.sint32=function(b){return this.uint32((b<<1^b>>31)>>>0)},n.prototype.uint64=function(b){var y=d.from(b);return this._push(p,y.length(),y)},n.prototype.int64=n.prototype.uint64,n.prototype.sint64=function(b){var y=d.from(b).zzEncode();return this._push(p,y.length(),y)},n.prototype.bool=function(b){return this._push(r,1,b?1:0)},n.prototype.fixed32=function(b){return this._push(g,4,b>>>0)},n.prototype.sfixed32=n.prototype.fixed32,n.prototype.fixed64=function(b){var y=d.from(b);return this._push(g,4,y.lo)._push(g,4,y.hi)},n.prototype.sfixed64=n.prototype.fixed64,n.prototype.float=function(b){return this._push(u.float.writeFloatLE,4,b)},n.prototype.double=function(b){return this._push(u.float.writeDoubleLE,8,b)};var _=u.Array.prototype.set?function(b,y,w){y.set(b,w)}:function(b,y,w){for(var T=0;T>>0;if(!y)return this._push(r,1,0);if(u.isString(b)){var w=n.alloc(y=a.length(b));a.decode(b,w,0),b=w}return this.uint32(y)._push(_,y,b)},n.prototype.string=function(b){var y=h.length(b);return y?this.uint32(y)._push(h.write,y,b):this._push(r,1,0)},n.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new f(c,0,0),this.len=0,this},n.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new f(c,0,0),this.len=0),this},n.prototype.ldelim=function(){var b=this.head,y=this.tail,w=this.len;return this.reset().uint32(w),w&&(this.tail.next=b.next,this.tail=y,this.len+=w),this},n.prototype.finish=function(){for(var b=this.head.next,y=this.constructor.alloc(this.len),w=0;b;)b.fn(b.val,y,w),w+=b.len,b=b.next;return y},n._configure=function(b){s=b,n.create=e(),s._configure()}},3155:(m,t,i)=>{m.exports=d;var s=i(1173);(d.prototype=Object.create(s.prototype)).constructor=d;var u=i(9693);function d(){s.call(this)}function a(h,f,c){h.length<40?u.utf8.write(h,f,c):f.utf8Write?f.utf8Write(h,c):f.write(h,c)}d._configure=function(){d.alloc=u._Buffer_allocUnsafe,d.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&u.Buffer.prototype.set.name==="set"?function(h,f,c){f.set(h,c)}:function(h,f,c){if(h.copy)h.copy(f,c,0,h.length);else for(var l=0;l>>0;return this.uint32(f),f&&this._push(d.writeBytesBuffer,f,h),this},d.prototype.string=function(h){var f=u.Buffer.byteLength(h);return this.uint32(f),f&&this._push(a,f,h),this},d._configure()},7714:(m,t,i)=>{t.R=void 0;const s=i(6919),u=i(7448);t.R=new class{async init(){}async createSessionHandler(d,a){const h=new s.Session(a);return await h.loadModel(d),new u.OnnxjsSessionHandler(h)}}},4200:(m,t,i)=>{t.c8=t.rX=void 0;const s=i(1670),u=i(5381),d=i(2157),a=i(2306);t.rX=()=>{if((typeof s.env.wasm.initTimeout!="number"||s.env.wasm.initTimeout<0)&&(s.env.wasm.initTimeout=0),typeof s.env.wasm.simd!="boolean"&&(s.env.wasm.simd=!0),typeof s.env.wasm.proxy!="boolean"&&(s.env.wasm.proxy=!1),typeof s.env.wasm.numThreads!="number"||!Number.isInteger(s.env.wasm.numThreads)||s.env.wasm.numThreads<=0){const h=typeof navigator>"u"?(0,u.cpus)().length:navigator.hardwareConcurrency;s.env.wasm.numThreads=Math.min(4,Math.ceil((h||1)/2))}},t.c8=new class{async init(){(0,t.rX)(),await(0,d.initWasm)()}async createSessionHandler(h,f){const c=new a.OnnxruntimeWebAssemblySessionHandler;return await c.loadModel(h,f),Promise.resolve(c)}}},6018:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(a,h,f,c){c===void 0&&(c=f);var l=Object.getOwnPropertyDescriptor(h,f);l&&!("get"in l?!h.__esModule:l.writable||l.configurable)||(l={enumerable:!0,get:function(){return h[f]}}),Object.defineProperty(a,c,l)}:function(a,h,f,c){c===void 0&&(c=f),a[c]=h[f]}),u=this&&this.__exportStar||function(a,h){for(var f in a)f==="default"||Object.prototype.hasOwnProperty.call(h,f)||s(h,a,f)};Object.defineProperty(t,"__esModule",{value:!0}),u(i(1670),t);const d=i(1670);{const a=i(7714).R;(0,d.registerBackend)("webgl",a,-10)}{const a=i(4200).c8;(0,d.registerBackend)("cpu",a,10),(0,d.registerBackend)("wasm",a,10),(0,d.registerBackend)("xnnpack",a,9)}},246:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createAttributeWithCacheKey=void 0;class i{constructor(u){Object.assign(this,u)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(u=>`${this[u]}`).join(";")),this._cacheKey}}t.createAttributeWithCacheKey=s=>new i(s)},7778:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Attribute=void 0;const s=i(1446),u=i(9395),d=i(9162),a=i(2517);var h=u.onnxruntime.experimental.fbs;class f{constructor(l){if(this._attributes=new Map,l!=null){for(const n of l)n instanceof s.onnx.AttributeProto?this._attributes.set(n.name,[f.getValue(n),f.getType(n)]):n instanceof h.Attribute&&this._attributes.set(n.name(),[f.getValue(n),f.getType(n)]);if(this._attributes.sized.Tensor.fromProto(r));if(l instanceof h.Attribute)return e.map(r=>d.Tensor.fromOrtTensor(r))}if(n===s.onnx.AttributeProto.AttributeType.STRING&&l instanceof s.onnx.AttributeProto){const r=e;return(0,a.decodeUtf8String)(r)}return n===s.onnx.AttributeProto.AttributeType.STRINGS&&l instanceof s.onnx.AttributeProto?e.map(a.decodeUtf8String):e}static getValueNoCheck(l){return l instanceof s.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(l):this.getValueNoCheckFromOrtFormat(l)}static getValueNoCheckFromOnnxFormat(l){switch(l.type){case s.onnx.AttributeProto.AttributeType.FLOAT:return l.f;case s.onnx.AttributeProto.AttributeType.INT:return l.i;case s.onnx.AttributeProto.AttributeType.STRING:return l.s;case s.onnx.AttributeProto.AttributeType.TENSOR:return l.t;case s.onnx.AttributeProto.AttributeType.GRAPH:return l.g;case s.onnx.AttributeProto.AttributeType.FLOATS:return l.floats;case s.onnx.AttributeProto.AttributeType.INTS:return l.ints;case s.onnx.AttributeProto.AttributeType.STRINGS:return l.strings;case s.onnx.AttributeProto.AttributeType.TENSORS:return l.tensors;case s.onnx.AttributeProto.AttributeType.GRAPHS:return l.graphs;default:throw new Error(`unsupported attribute type: ${s.onnx.AttributeProto.AttributeType[l.type]}`)}}static getValueNoCheckFromOrtFormat(l){switch(l.type()){case h.AttributeType.FLOAT:return l.f();case h.AttributeType.INT:return l.i();case h.AttributeType.STRING:return l.s();case h.AttributeType.TENSOR:return l.t();case h.AttributeType.GRAPH:return l.g();case h.AttributeType.FLOATS:return l.floatsArray();case h.AttributeType.INTS:{const n=[];for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.resolveBackend=t.backend=void 0;const s=i(5038),u=new Map;async function d(a){const h=t.backend;if(h[a]!==void 0&&function(f){const c=f;return"initialize"in c&&typeof c.initialize=="function"&&"createSessionHandler"in c&&typeof c.createSessionHandler=="function"&&"dispose"in c&&typeof c.dispose=="function"}(h[a])){const f=h[a];let c=f.initialize();if(typeof c=="object"&&"then"in c&&(c=await c),c)return u.set(a,f),f}}t.backend={webgl:new s.WebGLBackend},t.resolveBackend=async function a(h){if(!h)return a(["webgl"]);{const f=typeof h=="string"?[h]:h;for(const c of f){const l=u.get(c);if(l)return l;const n=await d(c);if(n)return n}}throw new Error("no available backend to use")}},5038:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLBackend=void 0;const s=i(1670),u=i(6231),d=i(6416),a=i(7305);t.WebGLBackend=class{get contextId(){return s.env.webgl.contextId}set contextId(h){s.env.webgl.contextId=h}get matmulMaxBatchSize(){return s.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(h){s.env.webgl.matmulMaxBatchSize=h}get textureCacheMode(){return s.env.webgl.textureCacheMode}set textureCacheMode(h){s.env.webgl.textureCacheMode=h}get pack(){return s.env.webgl.pack}set pack(h){s.env.webgl.pack=h}get async(){return s.env.webgl.async}set async(h){s.env.webgl.async=h}initialize(){try{return this.glContext=(0,a.createWebGLContext)(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),u.Logger.setWithEnv(s.env),u.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(h){return u.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${h}`),!1}}createSessionHandler(h){return new d.WebGLSessionHandler(this,h)}dispose(){this.glContext.dispose()}}},5107:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsGlslLib=void 0;const s=i(2517),u=i(8520),d=i(5060),a=i(7859),h=i(9390);class f extends u.GlslLib{constructor(l){super(l)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new u.GlslLibRoutine(` + vec2 offsetToCoords(int offset, int width, int height) { + int t = offset / width; + int s = offset - t*width; + vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height); + return coords; + } + `)}}coordsToOffset(){return{coordsToOffset:new u.GlslLibRoutine(` + int coordsToOffset(vec2 coords, int width, int height) { + float s = coords.s * float(width); + float t = coords.t * float(height); + int offset = int(t) * width + int(s); + return offset; + } + `)}}getOutputSamplingSnippet(){const l=this.context.outputTextureLayout;return l.isPacked?this.getPackedOutputSamplingSnippet(l):this.getUnpackedOutputSamplingSnippet(l)}getPackedOutputSamplingSnippet(l){const n=l.unpackedShape,e=[l.width,l.height],r={},o="getOutputCoords";switch(n.length){case 0:r[o]=this.getOutputScalarCoords();break;case 1:r[o]=this.getOutputPacked1DCoords(n,e);break;case 2:r[o]=this.getOutputPacked2DCoords(n,e);break;case 3:r[o]=this.getOutputPacked3DCoords(n,e);break;default:r[o]=this.getOutputPackedNDCoords(n,e)}const p=` + void setOutput(vec4 val) { + ${(0,d.getGlsl)(this.context.glContext.version).output} = val; + } + `;return r.floatTextureSetRGBA=new u.GlslLibRoutine(p),r}getUnpackedOutputSamplingSnippet(l){const n=l.unpackedShape,e=[l.width,l.height],r={},o="getOutputCoords";switch(n.length){case 0:r[o]=this.getOutputScalarCoords();break;case 1:r[o]=this.getOutputUnpacked1DCoords(n,e);break;case 2:r[o]=this.getOutputUnpacked2DCoords(n,e);break;case 3:r[o]=this.getOutputUnpacked3DCoords(n,e);break;case 4:r[o]=this.getOutputUnpacked4DCoords(n,e);break;case 5:r[o]=this.getOutputUnpacked5DCoords(n,e);break;case 6:r[o]=this.getOutputUnpacked6DCoords(n,e);break;default:throw new Error(`Unsupported output dimensionality: ${n.length}`)}const p=` + void setOutput(float val) { + ${(0,d.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0); + } + `;return r.floatTextureSetR=new u.GlslLibRoutine(p),r}getOutputScalarCoords(){return new u.GlslLibRoutine(` + int getOutputCoords() { + return 0; + } + `)}getOutputPacked1DCoords(l,n){const e=n;let r="";return e[0]===1?(r=` + int getOutputCoords() { + return 2 * int(TexCoords.y * ${e[1]}.0); + } + `,new u.GlslLibRoutine(r)):e[1]===1?(r=` + int getOutputCoords() { + return 2 * int(TexCoords.x * ${e[0]}.0); + } + `,new u.GlslLibRoutine(r)):(r=` + int getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); + } + `,new u.GlslLibRoutine(r))}getOutputPacked2DCoords(l,n){let e="";if(s.ArrayUtil.arraysEqual(l,n))return e=` + ivec2 getOutputCoords() { + return 2 * ivec2(TexCoords.xy * vec2(${n[0]}, ${n[1]})); + } + `,new u.GlslLibRoutine(e);const r=n,o=Math.ceil(l[1]/2);return e=` + ivec2 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${r[0]}, ${r[1]})); + + int index = resTexRC.y * ${r[0]} + resTexRC.x; + + // reverse r and c order for packed texture + int r = imod(index, ${o}) * 2; + int c = 2 * (index / ${o}); + + return ivec2(r, c); + } + `,new u.GlslLibRoutine(e)}getOutputPacked3DCoords(l,n){const e=[n[0],n[1]],r=Math.ceil(l[2]/2),o=r*Math.ceil(l[1]/2),p=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + int index = resTexRC.y * ${e[0]} + resTexRC.x; + + int b = index / ${o}; + index -= b * ${o}; + + // reverse r and c order for packed texture + int r = imod(index, ${r}) * 2; + int c = 2 * (index / ${r}); + + return ivec3(b, r, c); + } + `;return new u.GlslLibRoutine(p)}getOutputPackedNDCoords(l,n){const e=[n[0],n[1]],r=Math.ceil(l[l.length-1]/2),o=r*Math.ceil(l[l.length-2]/2);let p=o,g="",_="b, r, c";for(let y=2;y=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[b]} * ${_}`};`).join("");return e=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${g} + return ivec3(r, c, d); + } + `,new u.GlslLibRoutine(e)}getOutputUnpacked4DCoords(l,n){let e="";const r=l.length;let o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=l[r-1];for(let _=r-3;_>=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d","d2"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[b]} * ${_}`};`).join("");return e=` + ivec4 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${g} + return ivec4(r, c, d, d2); + } + `,new u.GlslLibRoutine(e)}getOutputUnpacked5DCoords(l,n){let e="";const r=l.length;let o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=l[r-1];for(let _=r-3;_>=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d","d2","d3"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[b]} * ${_}`};`).join("");return e=` + ivec5 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${g} + return ivec5(r, c, d, d2, d3); + } + `,new u.GlslLibRoutine(e)}getOutputUnpacked6DCoords(l,n){let e="";const r=l.length;let o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=l[r-1];for(let _=r-3;_>=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d","d2","d3","d4"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[b]} * ${_}`};`).join("");return e=` + ivec6 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + int index = resTexRC.y * ${n[0]} + resTexRC.x; + ${g} + return ivec6(r, c, d, d2, d3, d4); + } + `,new u.GlslLibRoutine(e)}getCommonUtilFuncs(){const l={};let n="uvFromFlat";l[n]=new u.GlslLibRoutine(` + vec2 uvFromFlat(int texNumR, int texNumC, int index) { + int texC = index / texNumR; + int texR = index - texC * texNumR; + // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to + // v. + return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC); + } + `),n="packedUVfrom1D",l[n]=new u.GlslLibRoutine(` + vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { + int texelIndex = index / 2; + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),n="packedUVfrom2D",l[n]=new u.GlslLibRoutine(` + vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) { + int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),n="packedUVfrom3D",l[n]=new u.GlslLibRoutine(` + vec2 packedUVfrom3D(int texNumR, int texNumC, + int texelsInBatch, int texelsInLogicalRow, int b, + int row, int col) { + int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); + int texR = index / texNumC; + int texC = index - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),n="sampleTexture";const e=(0,d.getGlsl)(this.context.glContext.version);return l[n]=new u.GlslLibRoutine(` + float sampleTexture(sampler2D textureSampler, vec2 uv) { + return ${e.texture2D}(textureSampler, uv).r; + }`),l}getInputsSamplingSnippets(){const l={},n=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((e,r)=>{const o=this.context.inputTextureLayouts[r],p=(0,h.generateShaderFuncNameFromInputSamplerName)(e);o.isPacked?l[p]=this.getPackedSamplerFromInput(p,e,o):l[p]=this.getUnpackedSamplerFromInput(p,e,o);const g=(0,h.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(e);o.unpackedShape.length<=n.unpackedShape.length&&(o.isPacked?l[g]=this.getPackedSamplerAtOutputCoords(g,o,n,e):l[g]=this.getUnpackedSamplerAtOutputCoords(g,o,n,e))}),l}getPackedSamplerAtOutputCoords(l,n,e,r){const o=n.unpackedShape,p=e.unpackedShape,g=r,_=(0,h.generateShaderFuncNameFromInputSamplerName)(g),b=o.length,y=p.length,w=s.BroadcastUtil.getBroadcastDims(o,p),T=(0,h.getCoordsDataType)(y),S=y-b;let A;const P=(0,h.getGlChannels)();A=b===0?"":y<2&&w.length>=1?"coords = 0;":w.map(C=>`coords.${P[C+S]} = 0;`).join(` +`);let x="";x=y<2&&b>0?"coords":o.map((C,G)=>`coords.${P[G+S]}`).join(", ");let M="return outputValue;";const N=s.ShapeUtil.size(o)===1,z=s.ShapeUtil.size(p)===1;if(b!==1||N||z){if(N&&!z)M=y===1?` + return vec4(outputValue.x, outputValue.x, 0., 0.); + `:` + return vec4(outputValue.x); + `;else if(w.length){const C=b-2,G=b-1;w.indexOf(C)>-1&&w.indexOf(G)>-1?M="return vec4(outputValue.x);":w.indexOf(C)>-1?M="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":w.indexOf(G)>-1&&(M="return vec4(outputValue.xx, outputValue.zz);")}}else M=` + return vec4(outputValue.xy, outputValue.xy); + `;const $=` + vec4 ${l}() { + ${T} coords = getOutputCoords(); + + int lastDim = coords.${P[y-1]}; + coords.${P[y-1]} = coords.${P[y-2]}; + coords.${P[y-2]} = lastDim; + + ${A} + vec4 outputValue = ${_}(${x}); + ${M} + } + `;return new u.GlslLibRoutine($,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(l,n,e,r){const o=[e.width,e.height],p=[n.width,n.height],g=n.unpackedShape.length,_=e.unpackedShape.length,b=n.unpackedShape,y=e.unpackedShape,w=(0,h.generateShaderFuncNameFromInputSamplerName)(r);if(g===_&&s.ArrayUtil.arraysEqual(p,o)){const z=` + float ${l}() { + return sampleTexture(${r}, TexCoords); + } + `;return new u.GlslLibRoutine(z,["coordinates.sampleTexture"])}const T=(0,h.getCoordsDataType)(_),S=s.BroadcastUtil.getBroadcastDims(b,y),A=_-g;let P;const x=(0,h.getGlChannels)();P=g===0?"":_<2&&S.length>=1?"coords = 0;":S.map(z=>`coords.${x[z+A]} = 0;`).join(` +`);let M="";M=_<2&&g>0?"coords":n.unpackedShape.map((z,$)=>`coords.${x[$+A]}`).join(", ");const N=` + float ${l}() { + ${T} coords = getOutputCoords(); + ${P} + return ${w}(${M}); + } + `;return new u.GlslLibRoutine(N,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(l,n,e){switch(e.unpackedShape.length){case 0:return this.getPackedSamplerScalar(l,n);case 1:return this.getPackedSampler1D(l,n,e);case 2:return this.getPackedSampler2D(l,n,e);case 3:return this.getPackedSampler3D(l,n,e);default:return this.getPackedSamplerND(l,n,e)}}getUnpackedSamplerFromInput(l,n,e){const r=e.unpackedShape;switch(r.length){case 0:return this.getUnpackedSamplerScalar(l,n,e);case 1:return this.getUnpackedSampler1D(l,n,e);case 2:return this.getUnpackedSampler2D(l,n,e);case 3:return this.getUnpackedSampler3D(l,n,e);case 4:return this.getUnpackedSampler4D(l,n,e);case 5:return this.getUnpackedSampler5D(l,n,e);case 6:return this.getUnpackedSampler6D(l,n,e);default:throw new Error(`Unsupported dimension ${r.length}-D`)}}getPackedSamplerScalar(l,n){const e=` + vec4 ${l}() { + return ${(0,d.getGlsl)(this.context.glContext.version).texture2D}(${n}, halfCR); + } + `;return new u.GlslLibRoutine(e)}getPackedSampler1D(l,n,e){const r=[e.width,e.height],o=[r[1],r[0]],p=(0,d.getGlsl)(this.context.glContext.version),g=`vec4 ${l}(int index) { + vec2 uv = packedUVfrom1D( + ${o[0]}, ${o[1]}, index); + return ${p.texture2D}(${n}, uv); + }`;return new u.GlslLibRoutine(g,["coordinates.packedUVfrom1D"])}getPackedSampler2D(l,n,e){const r=e.unpackedShape,o=[e.width,e.height],p=(0,d.getGlsl)(this.context.glContext.version),g=o[0],_=o[1];if(o!=null&&s.ArrayUtil.arraysEqual(r,o)){const T=`vec4 ${l}(int row, int col) { + vec2 uv = (vec2(col, row) + halfCR) / vec2(${_}.0, ${g}.0); + return ${p.texture2D}(${n}, uv); + }`;return new u.GlslLibRoutine(T)}const b=o,y=Math.ceil(r[1]/2),w=`vec4 ${l}(int row, int col) { + vec2 uv = packedUVfrom2D(${b[1]}, ${b[0]}, ${y}, row, col); + return ${p.texture2D}(${n}, uv); + }`;return new u.GlslLibRoutine(w,["coordinates.packedUVfrom2D"])}getPackedSampler3D(l,n,e){const r=e.unpackedShape,o=[e.width,e.height],p=[o[0],o[1]],g=(0,d.getGlsl)(this.context.glContext.version);if(r[0]===1){const T=r.slice(1),S=[1,2],A=(0,h.squeezeInputShape)(r,T),P=["b","row","col"],x=JSON.parse(JSON.stringify(e));x.unpackedShape=A;const M=this.getPackedSamplerFromInput(l,n,x),N=`${M.routineBody} + vec4 ${l}(int b, int row, int col) { + return ${l}(${(0,h.getSqueezedParams)(P,S)}); + } `;return new u.GlslLibRoutine(N,M.dependencies)}const _=p[0],b=p[1],y=Math.ceil(r[2]/2),w=`vec4 ${l}(int b, int row, int col) { + vec2 uv = packedUVfrom3D( + ${b}, ${_}, ${y*Math.ceil(r[1]/2)}, ${y}, b, row, col); + return ${g.texture2D}(${n}, uv);}`;return new u.GlslLibRoutine(w,["coordinates.packedUVfrom3D"])}getPackedSamplerND(l,n,e){const r=e.unpackedShape,o=r.length,p=[e.width,e.height],g=(0,d.getGlsl)(this.context.glContext.version),_=[p[0],p[1]],b=_[1],y=_[0],w=Math.ceil(r[o-1]/2);let T=w*Math.ceil(r[o-2]/2),S="int b, int row, int col",A=`b * ${T} + (row / 2) * ${w} + (col / 2)`;for(let x=2;x{const r=this.context.inputTextureLayouts[e],o=(r.unpackedShape.length>0?r.unpackedShape:r.shape).length;let p=`_${n}`;l[p]=new u.GlslLibRoutine(this.getValueFromSingle(n,o,r.width,r.height,!1),[`shapeUtils.indicesToOffset${p}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),p+="_T",l[p]=new u.GlslLibRoutine(this.getValueFromSingle(n,o,r.width,r.height,!0),[`shapeUtils.indicesToOffset${p}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),l}getValueFromSingle(l,n,e,r,o){let p=`_${l}`;return o&&(p+="_T"),` + float ${p}(int m[${n}]) { + int offset = indicesToOffset${p}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${r}); + float value = getColorAsFloat(${(0,d.getGlsl)(this.context.glContext.version).texture2D}(${l}, coords)); + return value; + } + `}getPackedValueFrom(l,n,e,r,o){let p=`_${l}_Pack`;return o&&(p+="_T"),` + vec4 ${p}(int m[${n}]) { + int offset = indicesToOffset_${l}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${r}); + return ${(0,d.getGlsl)(this.context.glContext.version).texture2D}(${l}, coords); + } + `}}t.CoordsGlslLib=f},8520:(m,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.TopologicalSortGlslRoutines=t.GlslLibRoutineNode=t.GlslLibRoutine=t.GlslLib=t.GlslContext=t.FunctionType=void 0,(i=t.FunctionType||(t.FunctionType={}))[i.ValueBased=0]="ValueBased",i[i.Positional=1]="Positional",t.GlslContext=class{constructor(s,u,d,a){this.glContext=s,this.programInfo=u,this.inputTextureLayouts=d,this.outputTextureLayout=a}},t.GlslLib=class{constructor(s){this.context=s}},t.GlslLibRoutine=class{constructor(s,u){this.routineBody=s,this.dependencies=u}},t.GlslLibRoutineNode=class{constructor(s,u,d){this.name=s,this.dependencies=d||[],u&&(this.routineBody=u)}addDependency(s){s&&this.dependencies.push(s)}},t.TopologicalSortGlslRoutines=class{static returnOrderedNodes(s){if(!s||s.length===0)return[];if(s.length===1)return s;const u=new Set,d=new Set,a=new Array;return this.createOrderedNodes(s,u,d,a),a}static createOrderedNodes(s,u,d,a){for(let h=0;h0)for(let f=0;f{Object.defineProperty(t,"__esModule",{value:!0}),t.EncodingGlslLib=void 0;const s=i(8520);class u extends s.GlslLib{constructor(a){super(a)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new s.GlslLibRoutine(`highp vec4 encode(highp float f) { + return vec4(f, 0.0, 0.0, 0.0); + } + `)}}decodeFloat32(){return{decode:new s.GlslLibRoutine(`highp float decode(highp vec4 rgba) { + return rgba.r; + } + `)}}encodeUint8(){const a=u.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new s.GlslLibRoutine(` + highp vec4 encode(highp float f) { + highp float F = abs(f); + highp float Sign = step(0.0,-f); + highp float Exponent = floor(log2(F)); + highp float Mantissa = (exp2(- Exponent) * F); + Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa)); + highp vec4 rgba; + rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0)); + rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0); + rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0))); + rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0))); + ${a} + rgba = rgba / 255.0; // values need to be normalized to [0,1] + return rgba; + } + `)}}decodeUint8(){const a=u.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new s.GlslLibRoutine(` + highp float decode(highp vec4 rgba) { + rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] + ${a} + highp float Sign = 1.0 - step(128.0,rgba[0])*2.0; + highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0; + highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000); + highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 )); + return Result; + } + `)}}static isLittleEndian(){const a=new ArrayBuffer(4),h=new Uint32Array(a),f=new Uint8Array(a);if(h[0]=3735928559,f[0]===239)return!0;if(f[0]===222)return!1;throw new Error("unknown endianness")}}t.EncodingGlslLib=u},9894:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragColorGlslLib=void 0;const s=i(8520),u=i(5060);class d extends s.GlslLib{constructor(h){super(h)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const h=(0,u.getGlsl)(this.context.glContext.version);return{setFragColor:new s.GlslLibRoutine(` + void setFragColor(float value) { + ${h.output} = encode(value); + } + `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new s.GlslLibRoutine(` + float getColorAsFloat(vec4 color) { + return decode(color); + } + `,["encoding.decode"])}}}t.FragColorGlslLib=d},2848:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.replaceInlines=void 0;const i=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;t.replaceInlines=function(s){const u={};let d;for(;(d=i.exec(s))!==null;){const a=d[3].split(",").map(h=>{const f=h.trim().split(" ");return f&&f.length===2?{type:f[0],name:f[1]}:null}).filter(h=>h!==null);u[d[2]]={params:a,body:d[4]}}for(const a in u){const h="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",a),f=new RegExp(h,"gm");for(;(d=f.exec(s))!==null;){const c=d[1],l=d[2],n=d[3].split(","),e=c?`${c} ${l};`:"";let r=u[a].body,o="";u[a].params.forEach((g,_)=>{g&&(o+=`${g.type} ${g.name} = ${n[_]}; +`)}),r=`${o} + ${r}`,r=r.replace("return",`${l} = `);const p=` + ${e} + { + ${r} + } + `;s=s.replace(d[0],p)}}return s.replace(i,"")}},8879:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GlslPreprocessor=void 0;const s=i(8520),u=i(2848),d=i(5483),a=i(5060);t.GlslPreprocessor=class{constructor(h,f,c,l){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new s.GlslContext(h,f,c,l),Object.keys(d.glslRegistry).forEach(e=>{const r=new d.glslRegistry[e](this.context);this.libs[e]=r});const n=this.glslLibRoutineDependencyGraph;for(const e in this.libs){const r=this.libs[e].getFunctions();for(const o in r){const p=e+"."+o;let g;n[p]?(g=n[p],g.routineBody=r[o].routineBody):(g=new s.GlslLibRoutineNode(p,r[o].routineBody),n[p]=g);const _=r[o].dependencies;if(_)for(let b=0;b<_.length;++b)if(n[_[b]])g.addDependency(n[_[b]]);else{const y=new s.GlslLibRoutineNode(_[b]);n[_[b]]=y,g.addDependency(y)}}}}preprocess(){const h=this.context.programInfo;let f=h.shaderSource;return this.context.programInfo.hasMain||(f=`${f} + ${(0,a.getDefaultFragShaderMain)(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),f=(0,u.replaceInlines)(f),`${(0,a.getFragShaderPreamble)(this.context.glContext.version)} + ${this.getUniforms(h.inputNames,h.variables)} + ${this.getImports(f)} + ${f}`}getImports(h){const f=this.selectGlslLibRoutinesToBeIncluded(h);if(f.length===0)return"";let c="";for(let l=0;l{const l=c.split(".")[1];h.indexOf(l)!==-1&&f.push(this.glslLibRoutineDependencyGraph[c])}),s.TopologicalSortGlslRoutines.returnOrderedNodes(f)}getUniforms(h,f){const c=[];if(h)for(const l of h)c.push(`uniform sampler2D ${l};`);if(f)for(const l of f)c.push(`uniform ${l.type} ${l.name}${l.arrayLength?`[${l.arrayLength}]`:""};`);return c.join(` +`)}}},5483:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.glslRegistry=void 0;const s=i(5107),u=i(7341),d=i(9894),a=i(2655),h=i(3891);t.glslRegistry={encoding:u.EncodingGlslLib,fragcolor:d.FragColorGlslLib,vec:h.VecGlslLib,shapeUtils:a.ShapeUtilsGlslLib,coordinates:s.CoordsGlslLib}},2655:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShapeUtilsGlslLib=void 0;const s=i(8520);class u extends s.GlslLib{constructor(a){super(a)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const a=this.context.outputTextureLayout.shape.length,h={};return this.context.programInfo.inputNames.forEach((f,c)=>{const l=this.context.inputTextureLayouts[c].unpackedShape;if(l.length<=a){const n=l.length,e=a-n,r=`bcastIndices_${f}`;let o="";for(let g=0;g{const l=this.context.inputTextureLayouts[c].shape;if(!(l.length<2||l.length>a)){const n=l.length,e=a-n,r=`bcastMatmulIndices_${f}`;let o="";for(let g=0;g{const c=this.context.inputTextureLayouts[f].shape,l=this.context.inputTextureLayouts[f].strides,n=c.length;let e=`indicesToOffset_${h}`;a[e]=new s.GlslLibRoutine(u.indexToOffsetSingle(e,n,l)),e=`indicesToOffset_${h}_T`,a[e]=new s.GlslLibRoutine(u.indexToOffsetSingle(e,n,l.slice().reverse()))}),a}static indexToOffsetSingle(a,h,f){let c="";for(let l=h-1;l>=0;--l)c+=` + offset += indices[${l}] * ${f[l]}; + `;return` + int ${a}(int indices[${h}]) { + int offset = 0; + ${c} + return offset; + } + `}offsetToIndices(){const a={};return this.context.programInfo.inputNames.forEach((h,f)=>{const c=this.context.inputTextureLayouts[f].shape,l=this.context.inputTextureLayouts[f].strides,n=c.length;let e=`offsetToIndices_${h}`;a[e]=new s.GlslLibRoutine(u.offsetToIndicesSingle(e,n,l)),e=`offsetToIndices_${h}_T`,a[e]=new s.GlslLibRoutine(u.offsetToIndicesSingle(e,n,l.slice().reverse()))}),a}static offsetToIndicesSingle(a,h,f){const c=[];for(let l=0;l{const c=this.context.inputTextureLayouts[f].shape,l=c.length,n=`incrementIndices_${h}`;let e="";for(let o=0;o= 0; --i) { + if(i > axis) continue; + indices[i] += 1; + if(indices[i] < shape[i]) { + break; + } + indices[i] = 0; + } + } + `;a[n]=new s.GlslLibRoutine(r)}),a}}t.ShapeUtilsGlslLib=u},5060:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultFragShaderMain=t.getFragShaderPreamble=t.getVertexShaderSource=t.getGlsl=void 0;const i={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},s={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function u(d){return d===1?i:s}t.getGlsl=u,t.getVertexShaderSource=function(d){const a=u(d);return`${a.version} + precision highp float; + ${a.attribute} vec3 position; + ${a.attribute} vec2 textureCoord; + + ${a.varyingVertex} vec2 TexCoords; + + void main() + { + gl_Position = vec4(position, 1.0); + TexCoords = textureCoord; + }`},t.getFragShaderPreamble=function(d){const a=u(d);return`${a.version} + precision highp float; + precision highp int; + precision highp sampler2D; + ${a.varyingFrag} vec2 TexCoords; + ${a.outputDeclaration} + const vec2 halfCR = vec2(0.5, 0.5); + + // Custom vector types to handle higher dimenalities. + struct ivec5 + { + int x; + int y; + int z; + int w; + int u; + }; + + struct ivec6 + { + int x; + int y; + int z; + int w; + int u; + int v; + }; + + int imod(int x, int y) { + return x - y * (x / y); + } + + `},t.getDefaultFragShaderMain=function(d,a){return` + void main() { + int indices[${a}]; + toVec(TexCoords, indices); + vec4 result = vec4(process(indices)); + ${u(d).output} = result; + } + `}},3891:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VecGlslLib=void 0;const s=i(8520);class u extends s.GlslLib{constructor(a){super(a)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const a=this.context.outputTextureLayout.shape.length,h={add:"+=",sub:"-=",mul:"*=",div:"/="},f={};for(const c in h){const l=`${c}Vec`;let n="";for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLInferenceHandler=void 0;const s=i(6231),u=i(9162),d=i(2517),a=i(2403),h=i(7019),f=i(8710),c=i(5611),l=i(4057),n=i(2039);t.WebGLInferenceHandler=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,r){return(0,l.calculateTextureWidthAndHeight)(this.session.layoutStrategy,e,r)}executeProgram(e,r){if(r.length{const S=T.map(P=>`${P.unpackedShape.join(",")};${P.width}x${P.height}`).join("_");let A=w.name;return w.cacheHint&&(A+="["+w.cacheHint+"]"),A+=":"+S,A})(e,o);let g=this.session.programManager.getArtifact(p);const _=g?g.programInfo:typeof e.get=="function"?e.get():e,b=(0,l.createTextureLayoutFromTextureType)(this.session.layoutStrategy,_.output.dims,_.output.textureType),y=this.createTextureData(b,_.output.type);return g||(g=this.session.programManager.build(_,o,y),this.session.programManager.setArtifact(p,g)),this.runProgram(g,o,y),y}run(e,r){return this.executeProgram(e,r).tensor}runProgram(e,r,o){for(let p=0;pthis.readTexture(_),async b=>this.readTextureAsync(_),void 0,g),texture:o});return this.setTextureData(_.tensor.dataId,_,e.isPacked),_}getTextureData(e,r=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,r):r?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,r,o=!1){this.session.isInitializer(e)?this.session.setTextureData(e,r,o):(o?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,r)}isTextureLayoutCached(e,r=!1){return!!this.getTextureData(e.dataId,r)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,f.encodeAsUint8)(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,f.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,a.createPackProgramInfoLoader)(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram((0,c.createUnpackProgramInfoLoader)(this,e.tensor),[e.tensor])}}},1640:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(V,J,Z,ue){ue===void 0&&(ue=Z);var Ae=Object.getOwnPropertyDescriptor(J,Z);Ae&&!("get"in Ae?!J.__esModule:Ae.writable||Ae.configurable)||(Ae={enumerable:!0,get:function(){return J[Z]}}),Object.defineProperty(V,ue,Ae)}:function(V,J,Z,ue){ue===void 0&&(ue=Z),V[ue]=J[Z]}),u=this&&this.__setModuleDefault||(Object.create?function(V,J){Object.defineProperty(V,"default",{enumerable:!0,value:J})}:function(V,J){V.default=J}),d=this&&this.__importStar||function(V){if(V&&V.__esModule)return V;var J={};if(V!=null)for(var Z in V)Z!=="default"&&Object.prototype.hasOwnProperty.call(V,Z)&&s(J,V,Z);return u(J,V),J};Object.defineProperty(t,"__esModule",{value:!0}),t.WEBGL_OP_RESOLVE_RULES=void 0;const a=i(2898),h=d(i(7839)),f=i(4196),c=i(2069),l=i(8138),n=i(9663),e=i(5193),r=i(7992),o=i(1253),p=i(4776),g=i(6572),_=i(3346),b=i(5623),y=i(2870),w=i(2143),T=i(4939),S=i(718),A=i(2268),P=i(8117),x=i(2278),M=i(5524),N=i(5975),z=i(3933),$=i(6558),C=i(5723),G=i(3738),D=d(i(4909)),R=i(8428),Y=i(9793);t.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",D.abs],["Acos","","7+",D.acos],["Add","","7+",h.add],["And","","7+",h.and],["Asin","","7+",D.asin],["Atan","","7+",D.atan],["AveragePool","","7+",w.averagePool,w.parseAveragePoolAttributes],["BatchNormalization","","7+",a.batchNormalization,a.parseBatchNormalizationAttributes],["Cast","","6+",f.cast,f.parseCastAttributes],["Ceil","","6+",D.ceil],["Clip","","6-10",D.clip,D.parseClipAttributes],["Clip","","11+",D.clipV11],["Concat","","4+",c.concat,c.parseConcatAttributes],["Conv","","1+",l.conv,l.parseConvAttributes],["ConvTranspose","","1+",n.convTranspose,n.parseConvTransposeAttributes],["Cos","","7+",D.cos],["Div","","7+",h.div],["Dropout","","7+",D.identity],["DepthToSpace","","1+",e.depthToSpace,e.parseDepthToSpaceAttributes],["Equal","","7+",h.equal],["Elu","","6+",D.elu,D.parseEluAttributes],["Exp","","6+",D.exp],["Flatten","","1+",r.flatten,r.parseFlattenAttributes],["Floor","","6+",D.floor],["FusedConv","com.microsoft","1+",l.conv,l.parseConvAttributes],["Gather","","1+",o.gather,o.parseGatherAttributes],["Gemm","","7-10",p.gemm,p.parseGemmAttributesV7],["Gemm","","11+",p.gemm,p.parseGemmAttributesV11],["GlobalAveragePool","","1+",w.globalAveragePool,w.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",w.globalMaxPool],["Greater","","7+",h.greater],["Identity","","1+",D.identity],["ImageScaler","","1+",g.imageScaler,g.parseImageScalerAttributes],["InstanceNormalization","","6+",_.instanceNormalization,_.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",D.leakyRelu,D.parseLeakyReluAttributes],["Less","","7+",h.less],["Log","","6+",D.log],["MatMul","","1+",b.matMul,b.parseMatMulAttributes],["MaxPool","","1+",w.maxPool,w.parseMaxPoolAttributes],["Mul","","7+",h.mul],["Neg","","6+",D.neg],["Not","","1+",D.not],["Or","","7+",h.or],["Pad","","2-10",y.padV2,y.parsePadAttributesV2],["Pad","","11+",y.padV11,y.parsePadAttributesV11],["Pow","","7+",h.pow],["PRelu","","7+",h.pRelu],["ReduceLogSum","","1+",T.reduceLogSum,T.parseReduceAttributes],["ReduceMax","","1+",T.reduceMax,T.parseReduceAttributes],["ReduceMean","","1+",T.reduceMean,T.parseReduceAttributes],["ReduceMin","","1+",T.reduceMin,T.parseReduceAttributes],["ReduceProd","","1+",T.reduceProd,T.parseReduceAttributes],["ReduceSum","","1-12",T.reduceSum,T.parseReduceAttributes],["ReduceSumSquare","","1+",T.reduceLogSumSquare,T.parseReduceAttributes],["Relu","","6+",D.relu],["Reshape","","5+",S.reshape],["Resize","","10",A.resize,A.parseResizeAttributesV10],["Resize","","11+",A.resize,A.parseResizeAttributesV11],["Shape","","1+",P.shape],["Sigmoid","","6+",D.sigmoid],["Sin","","7+",D.sin],["Slice","","10+",x.sliceV10],["Slice","","1-9",x.slice,x.parseSliceAttributes],["Softmax","","1-12",M.softmax,M.parseSoftmaxAttributes],["Softmax","","13+",M.softmaxV13,M.parseSoftmaxAttributesV13],["Split","","2-12",N.split,N.parseSplitAttributes],["Sqrt","","6+",D.sqrt],["Squeeze","","1-12",z.squeeze,z.parseSqueezeAttributes],["Squeeze","","13+",z.squeezeV13],["Sub","","7+",h.sub],["Sum","","6+",$.sum],["Tan","","7+",D.tan],["Tanh","","6+",D.tanh],["Tile","","6+",C.tile],["Transpose","","1+",G.transpose,G.parseTransposeAttributes],["Upsample","","7-8",Y.upsample,Y.parseUpsampleAttributesV7],["Upsample","","9",Y.upsample,Y.parseUpsampleAttributesV9],["Unsqueeze","","1-12",R.unsqueeze,R.parseUnsqueezeAttributes],["Unsqueeze","","13+",R.unsqueezeV13],["Xor","","7+",h.xor]]},2898:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseBatchNormalizationAttributes=t.batchNormalization=void 0;const s=i(246),u=i(5060),d=i(2039),a={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]};t.batchNormalization=(c,l,n)=>(f(l),[c.run(Object.assign(Object.assign({},a),{cacheHint:n.cacheKey,get:()=>h(c,l,n)}),l)]),t.parseBatchNormalizationAttributes=c=>{const l=c.attributes.getFloat("epsilon",1e-5),n=c.attributes.getFloat("momentum",.9),e=c.attributes.getInt("spatial",1);return(0,s.createAttributeWithCacheKey)({epsilon:l,momentum:n,spatial:e})};const h=(c,l,n)=>{const e=(0,u.getGlsl)(c.session.backend.glContext.version),r=l[0].dims.length,[o,p]=c.calculateTextureWidthAndHeight(l[1].dims,d.TextureType.unpacked),g=` + float process(int[${r}] indices) { + vec2 position = offsetToCoords(indices[1], ${o}, ${p}); + float scale = getColorAsFloat(${e.texture2D}(Scale, position)); + float mean = getColorAsFloat(${e.texture2D}(Mean, position)); + float variance = getColorAsFloat(${e.texture2D}(Variance, position)); + float b = getColorAsFloat(${e.texture2D}(B, position)); + + return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b; + }`;return Object.assign(Object.assign({},a),{output:{dims:l[0].dims,type:l[0].type,textureType:d.TextureType.unpacked},shaderSource:g})},f=c=>{if(!c||c.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const l=c[0],n=c[1],e=c[2],r=c[3],o=c[4];if(l.dims.length<3||n.dims.length!==1||e.dims.length!==1||r.dims.length!==1||o.dims.length!==1)throw new Error("invalid input shape.");if(n.dims[0]!==l.dims[1]||e.dims[0]!==l.dims[1]||r.dims[0]!==l.dims[1]||o.dims[0]!==l.dims[1])throw new Error("invalid input shape.");if(l.type!=="float32"&&l.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64"||o.type!=="float32"&&o.type!=="float64")throw new Error("invalid input tensor types.")}},7839:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xor=t.sub=t.pRelu=t.pow=t.or=t.mul=t.less=t.greater=t.equal=t.div=t.and=t.add=t.glslPRelu=t.glslPow=t.glslXor=t.glslOr=t.glslAnd=t.glslLess=t.glslGreater=t.glslEqual=t.glslSub=t.glslMul=t.glslDiv=t.glslAdd=void 0;const s=i(2517),u=i(8520),d=i(5060),a=i(2039);function h(){const T="add_";return{body:` + float ${T}(float a, float b) { + return a + b; + } + vec4 ${T}(vec4 v1, vec4 v2) { + return v1 + v2; + } + `,name:T,type:u.FunctionType.ValueBased}}function f(){const T="div_";return{body:` + float ${T}(float a, float b) { + return a / b; + } + vec4 ${T}(vec4 v1, vec4 v2) { + return v1 / v2; + } + `,name:T,type:u.FunctionType.ValueBased}}function c(){const T="mul_";return{body:` + float ${T}(float a, float b) { + return a * b; + } + vec4 ${T}(vec4 v1, vec4 v2) { + return v1 * v2; + } + `,name:T,type:u.FunctionType.ValueBased}}function l(){const T="sub_";return{body:` + float ${T}(float a, float b) { + return a - b; + } + vec4 ${T}(vec4 v1, vec4 v2) { + return v1 - v2; + } + `,name:T,type:u.FunctionType.ValueBased}}function n(){const T="equal_";return{body:` + float ${T}(float a, float b) { + return float(a == b); + } + vec4 ${T}(vec4 v1, vec4 v2) { + return vec4(equal(v1, v2)); + } + `,name:T,type:u.FunctionType.ValueBased}}function e(){const T="greater_";return{body:` + float ${T}(float a, float b) { + return float(a > b); + } + vec4 ${T}(vec4 v1, vec4 v2) { + return vec4( v1.r > v2.r , + v1.g > v2.g, + v1.b > v2.b, + v1.a > v2.a ); + } + `,name:T,type:u.FunctionType.ValueBased}}function r(){const T="less_";return{body:` + float ${T}(float a, float b) { + return float(a < b); + } + vec4 ${T}(vec4 v1, vec4 v2) { + return vec4( v1.r < v2.r , + v1.g < v2.g, + v1.b < v2.b, + v1.a < v2.a ); + } + `,name:T,type:u.FunctionType.ValueBased}}function o(){const T="and_";return{body:` + float ${T}(float a, float b) { + return float( bool(a) && bool(b) ); + } + vec4 ${T}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r && b2.r , + b1.g && b2.g, + b1.b && b2.b, + b1.a && b2.a ); + } + `,name:T,type:u.FunctionType.ValueBased}}function p(){const T="or_";return{body:` + float ${T}(float a, float b) { + return float( bool(a) || bool(b) ); + } + vec4 ${T}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r || b2.r , + b1.g || b2.g, + b1.b || b2.b, + b1.a || b2.a ); + } + `,name:T,type:u.FunctionType.ValueBased}}function g(){const T="xor_";return{body:` + float ${T}(float a, float b) { + return float( bool(a) ^^ bool(b) ); + } + vec4 ${T}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r ^^ b2.r , + b1.g ^^ b2.g, + b1.b ^^ b2.b, + b1.a ^^ b2.a ); + } + `,name:T,type:u.FunctionType.ValueBased}}function _(){return function(T){const S=`${T}_`;return{body:` + float ${S}(float a, float b) { + return ${T}(a, b); + } + vec4 ${S}(vec4 v1, vec4 v2) { + return ${T}(v1, v2); + } + `,name:S,type:u.FunctionType.ValueBased}}("pow")}function b(){const T="prelu_";return{body:` + float ${T}(float a, float b) { + return a < 0.0 ? a * b: a; + } + vec4 ${T}(vec4 v1, vec4 v2) { + return vec4( + v1.r < 0.0 ? v1.r * v2.r: v1.r, + v1.g < 0.0 ? v1.g * v2.g: v1.g, + v1.b < 0.0 ? v1.b * v2.b: v1.b, + v1.a < 0.0 ? v1.a * v2.a: v1.a + ); + } + `,name:T,type:u.FunctionType.ValueBased}}t.glslAdd=h,t.glslDiv=f,t.glslMul=c,t.glslSub=l,t.glslEqual=n,t.glslGreater=e,t.glslLess=r,t.glslAnd=o,t.glslOr=p,t.glslXor=g,t.glslPow=_,t.glslPRelu=b;const y=(T,S,A,P=S[0].type,x)=>{const M=T.session.pack?a.TextureType.packed:a.TextureType.unpacked;return{name:A.name,inputNames:["A","B"],inputTypes:[M,M],cacheHint:x,get:()=>w(T,S,A,P)}},w=(T,S,A,P=S[0].type)=>{const x=T.session.pack?a.TextureType.packed:a.TextureType.unpacked,M=!s.ShapeUtil.areEqual(S[0].dims,S[1].dims);let N=S[0].dims;const z=T.session.pack;if(M){const G=s.BroadcastUtil.calcShape(S[0].dims,S[1].dims,!1);if(!G)throw new Error("Can't perform binary op on the given tensors");N=G;const D=N.length,R=S[0].dims.length!==0?S[0].dims.length:1,Y=S[1].dims.length!==0?S[1].dims.length:1,V=S[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",J=S[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",Z=(0,d.getGlsl)(T.session.backend.glContext.version),ue=z?` + ${A.body} + void main() { + vec4 a = getAAtOutCoords(); + vec4 b = getBAtOutCoords(); + vec4 result = ${A.name}(a, b); + ${Z.output} = result; + }`:` + ${A.body} + float process(int indices[${D}]) { + int aindices[${R}]; + int bindices[${Y}]; + ${V} + ${J} + return ${A.name}(_A(aindices), _B(bindices)); + }`;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:N,type:P,textureType:x},shaderSource:ue,hasMain:z}}const $=(0,d.getGlsl)(T.session.backend.glContext.version),C=` + ${A.body} + void main() { + vec4 v1 = ${$.texture2D}(A, TexCoords); + vec4 v2 = ${$.texture2D}(B, TexCoords); + vec4 result = ${A.name}(v1, v2); + ${$.output} = result; + } + `;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:S[0].dims,type:P,textureType:x},shaderSource:C,hasMain:!0}};t.add=(T,S)=>[T.run(y(T,S,h()),S)],t.and=(T,S)=>[T.run(y(T,S,o(),"bool"),S)],t.div=(T,S)=>[T.run(y(T,S,f()),S)],t.equal=(T,S)=>[T.run(y(T,S,n(),"bool"),S)],t.greater=(T,S)=>[T.run(y(T,S,e(),"bool"),S)],t.less=(T,S)=>[T.run(y(T,S,r(),"bool"),S)],t.mul=(T,S)=>[T.run(y(T,S,c()),S)],t.or=(T,S)=>[T.run(y(T,S,p(),"bool"),S)],t.pow=(T,S)=>[T.run(y(T,S,_()),S)],t.pRelu=(T,S)=>[T.run(y(T,S,b()),S)],t.sub=(T,S)=>[T.run(y(T,S,l()),S)],t.xor=(T,S)=>[T.run(y(T,S,g(),"bool"),S)]},4196:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseCastAttributes=t.cast=void 0;const s=i(2517);t.cast=(d,a,h)=>(u(a),[d.cast(a[0],h)]),t.parseCastAttributes=d=>s.ProtoUtil.tensorDataTypeFromProto(d.attributes.getInt("to"));const u=d=>{if(!d||d.length!==1)throw new Error("Cast requires 1 input.");if(d[0].type==="string")throw new Error("Invalid input type.")}},1163:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedConcatProgramInfoLoader=void 0;const s=i(5060),u=i(2039),d=i(9390),a=i(2827);t.createPackedConcatProgramInfoLoader=(f,c,l)=>{const n=(e=c.length,r=l.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:e},(o,p)=>`X${p}`),inputTypes:Array(e).fill(u.TextureType.packed),cacheHint:r});var e,r;return Object.assign(Object.assign({},n),{get:()=>((o,p,g,_)=>{const b=g[0].dims.slice();if(_>=b.length||_<-1*b.length)throw new Error("axis specified for concat doesn't match input dimensionality");_<0&&(_=b.length+_);const y=b.slice(0);for(let V=1;VV.dims),x=(0,d.getGlChannels)(w),M=new Array(P.length-1);M[0]=P[0][_];for(let V=1;V= ${M[V-1]}) { + return getChannel( + getX${V}(${h(x,N,J)}), + vec2(${h(z,N,J)})); + }`}const G=M.length,D=M[M.length-1];C+=` + return getChannel( + getX${G}(${h(x,N,D)}), + vec2(${h(z,N,D)}));`;const R=(0,s.getGlsl)(o.session.backend.glContext.version),Y=` + ${A} + float getValue(${x.map(V=>"int "+V)}) { + ${C} + } + + void main() { + ${S} coords = getOutputCoords(); + int lastDim = coords.${x[w-1]}; + coords.${x[w-1]} = coords.${x[w-2]}; + coords.${x[w-2]} = lastDim; + + vec4 result = vec4(getValue(${T}), 0., 0., 0.); + + ${T[w-1]} = ${T[w-1]} + 1; + if (${T[w-1]} < ${y[w-1]}) { + result.g = getValue(${T}); + } + + ${T[w-2]} = ${T[w-2]} + 1; + if (${T[w-2]} < ${y[w-2]}) { + result.a = getValue(${T}); + } + + ${T[w-1]} = ${T[w-1]} - 1; + if (${T[w-2]} < ${y[w-2]} && + ${T[w-1]} < ${y[w-1]}) { + result.b = getValue(${T}); + } + ${R.output} = result; + } + `;return Object.assign(Object.assign({},p),{output:{dims:y,type:g[0].type,textureType:u.TextureType.packed},shaderSource:Y,hasMain:!0})})(f,n,c,l.axis)})};const h=(f,c,l)=>{const n=f.indexOf(c);return f.map((e,r)=>r===n?`${e} - ${l}`:e).join()}},2069:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConcatAttributes=t.concat=void 0;const s=i(246),u=i(2039),d=i(1163);t.concat=(e,r,o)=>(n(r),e.session.pack&&r[0].dims.length>1?[e.run((0,d.createPackedConcatProgramInfoLoader)(e,r,o),r)]:[e.run(a(e,r,o),r)]);const a=(e,r,o)=>{const p=(g=r.length,_=o.cacheKey,{name:"Concat",inputNames:Array.from({length:g},(b,y)=>`X${y}`),inputTypes:Array(g).fill(u.TextureType.unpacked),cacheHint:_});var g,_;return Object.assign(Object.assign({},p),{get:()=>((b,y,w,T)=>{const S=w[0].dims.slice();if(T>=S.length||T<-1*S.length)throw new Error("axis specified for concat doesn't match input dimensionality");T<0&&(T=S.length+T);const A=S.slice(0);for(let $=1;$`int getTextureWhereDataResides(int index) { + ${e.map((r,o)=>`if(index<${r}) {return ${o};} +`).join("")} + }`,f=e=>h(e),c=(e,r)=>{const o=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let p=0;p{const r=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let o=0;o(0,s.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis")});const n=e=>{if(!e||e.length<1)throw new Error("too few inputs");const r=e[0].type,o=e[0].dims.length;if(r==="string")throw new Error("string tensor is not supported yet");for(const p of e){if(p.type!==r)throw new Error("input tensors should be one type");if(p.dims.length!==o)throw new Error("input tensors should have the same shape")}}},4770:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackedGroupedConvProgramInfoLoader=void 0;const s=i(6231),u=i(5060),d=i(2039),a=i(8138),h=i(2823);t.createUnpackedGroupedConvProgramInfoLoader=(f,c,l)=>{const n=(e=c.length>2,r=l.cacheKey,{name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.unpacked],cacheHint:r});var e,r;return Object.assign(Object.assign({},n),{get:()=>((o,p,g,_)=>{const b=p.length>2?"value += getBias(output_channel);":"",y=p[0].dims.slice(),w=p[1].dims.slice(),T=w[0]/_.group;s.Logger.verbose("GroupedConv",`autpPad:${_.autoPad}, dilations:${_.dilations}, group:${_.group}, kernelShape:${_.kernelShape}, pads:${_.pads}, strides:${_.strides}`);const S=(0,a.calculateOutputShape)(y,w,_.dilations,_.pads,_.strides),A=(0,u.getGlsl)(o.session.backend.glContext.version),{activationFunction:P,applyActivation:x}=(0,h.getActivationSnippet)(_),M=` + const ivec2 strides = ivec2(${_.strides[0]}, ${_.strides[1]}); + const ivec2 pads = ivec2(${_.pads[0]}, ${_.pads[1]}); + ${P} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + ivec2 xRCCorner = coords.zw * strides - pads; + int group_id = output_channel / ${T}; + + float value = 0.0; + for (int wInChannel = 0; wInChannel < ${w[1]}; wInChannel++) { + int input_channel = group_id * ${w[1]} + wInChannel; + for (int wHeight = 0; wHeight < ${w[2]}; wHeight++) { + int xHeight = xRCCorner.x + wHeight * ${_.dilations[0]}; + + if (xHeight < 0 || xHeight >= ${y[2]}) { + continue; + } + + for (int wWidth = 0; wWidth < ${w[3]}; wWidth++) { + int xWidth = xRCCorner.y + wWidth * ${_.dilations[1]}; + if (xWidth < 0 || xWidth >= ${y[3]}) { + continue; + } + + float xVal = getX(batch, input_channel, xWidth, xHeight); + float wVal = getW(output_channel, wInChannel, wWidth, wHeight); + value += xVal*wVal; + } + } + } + ${b} + ${x} + ${A.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},g),{output:{dims:S,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:M,hasMain:!0})})(f,c,n,l)})}},1386:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.conv2DPacked=t.conv2DPackedPointwise=void 0;const s=i(8138),u=i(8555),d=i(708);t.conv2DPackedPointwise=(a,h,f)=>{const c=h[0].dims,l=h[1].dims,n=(0,s.calculateOutputShape)(c,l,f.dilations,f.pads,f.strides),e=a.reshapePacked(h[0],[c[1],c[2]*c[3]]),r=a.reshapePacked(h[1],[l[0],l[1]]),o=h.length>2?[r,e,h[2]]:[r,e],p=a.run((0,d.createPackedMatmulProgramInfoLoader)(a,o,f),o);return a.reshapePacked(p,n)},t.conv2DPacked=(a,h,f)=>{const c=h[0].dims,l=h[1].dims,n=(0,s.calculateOutputShape)(c,l,f.dilations,f.pads,f.strides),e=a.run((0,u.createPackedIm2ColProgramInfoLoader)(a,h[0],h[1],n,f),[h[0]]),r=a.reshapePacked(h[1],[l[0],l[1]*l[2]*l[3]]),o=h.length===3?[r,e,h[2]]:[r,e],p=a.run((0,d.createPackedMatmulProgramInfoLoader)(a,o,f),o);return a.reshapePacked(p,n)}},9663:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvTransposeAttributes=t.convTranspose=void 0;const s=i(246),u=i(5060),d=i(2039),a=i(2823),h=(r,o,p,g,_,b)=>(r-1)*o+p+(g-1)*_+1-b,f=(r,o,p,g,_)=>{const b=Math.floor(r/2);o==="SAME_UPPER"?(p[g]=b,p[_]=r-b):o==="SAME_LOWER"&&(p[g]=r-b,p[_]=b)};t.convTranspose=(r,o,p)=>(e(o,p),c(r,o,p));const c=(r,o,p)=>{const g=n(p,o);return[l(r,o,g)]},l=(r,o,p)=>r.run(((g,_,b)=>{const y=(w=_.length>2,T=b.cacheKey,{name:"ConvTranspose",inputNames:w?["X","W","B"]:["X","W"],inputTypes:w?[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.unpacked],cacheHint:T});var w,T;return Object.assign(Object.assign({},y),{get:()=>((S,A,P,x)=>{const M=A.length>2?"getB(output_channel)":"0.0",N=A[0].dims,z=A[1].dims,$=z[1],C=z[0]/x.group,G=[A[0].dims[0],A[1].dims[1]*x.group,...x.outputShape],D=(0,u.getGlsl)(S.session.backend.glContext.version),{activationFunction:R,applyActivation:Y}=(0,a.getActivationSnippet)(x),V=` + const ivec2 strides = ivec2(${x.strides[0]}, ${x.strides[1]}); + const ivec2 pads = ivec2(${x.pads[0]}, ${x.pads[1]}); + ${R} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + + ivec2 loc = coords.zw + pads; + + int group_id = output_channel / ${$}; + int wOutChannel = output_channel - group_id * ${$}; + + float value = ${M}; + for (int inChannelOffset = 0; inChannelOffset < ${C}; inChannelOffset++) { + int input_channel = group_id * ${C} + inChannelOffset; + for (int wWOff = 0; wWOff < ${z[2]}; wWOff++) { + for (int wHOff = 0; wHOff < ${z[3]}; wHOff++) { + ivec2 wOff = ivec2(wWOff * ${x.dilations[0]}, wHOff * ${x.dilations[1]}); + ivec2 wLoc = loc - wOff; + ivec2 wLocIn = wLoc / strides; + if ( + wLocIn * strides == wLoc && + wLocIn.x >= 0 && wLocIn.x < ${N[2]} && + wLocIn.y >= 0 && wLocIn.y < ${N[3]} + ) { + float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); + float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); + value += xVal * wVal; + } + } + } + } + ${Y} + ${D.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},P),{output:{dims:G,type:A[0].type,textureType:d.TextureType.unpacked},shaderSource:V,hasMain:!0})})(g,_,y,b)})})(r,o,p),o),n=(r,o)=>{const p=r.kernelShape.slice();if(r.kernelShape.length===0)for(let y=2;y{const N=y.length-2,z=M.length===0;for(let $=0;${const o=r.attributes,p=(0,a.parseInternalActivationAttributes)(o),g=o.getString("auto_pad","NOTSET"),_=o.getInts("dilations",[1,1]),b=o.getInt("group",1),y=o.getInts("kernel_shape",[]),w=o.getInts("output_padding",[0,0]),T=o.getInts("output_shape",[]),S=o.getInts("pads",[0,0,0,0]),A=o.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:g,dilations:_,group:b,kernelShape:y,outputPadding:w,outputShape:T,pads:S,strides:A},p))};const e=(r,o)=>{if(!r||r.length!==2&&r.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(r[0].dims.length!==4||r[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(r[0].dims[1]!==r[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const p=r[1].dims[1]*o.group;if(r.length===3&&(r[2].dims.length!==1||r[2].dims[0]!==p))throw new Error("invalid bias");const g=r[0].dims.length-2;if(o.dilations.length!==g)throw new Error(`dilations should be ${g}D`);if(o.strides.length!==g)throw new Error(`strides should be ${g}D`);if(o.pads.length!==2*g)throw new Error(`pads should be ${2*g}D`);if(o.outputPadding.length!==g)throw new Error(`output_padding should be ${g}D`);if(o.kernelShape.length!==0&&o.kernelShape.length!==r[1].dims.length-2)throw new Error("invalid kernel shape");if(o.outputShape.length!==0&&o.outputShape.length!==r[0].dims.length-2)throw new Error("invalid output shape");if(r[0].type!=="float32"||r[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(r.length===3&&r[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},8138:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvAttributes=t.conv=t.calculateOutputShape=void 0;const s=i(246),u=i(2517),d=i(4770),a=i(1386),h=i(9828),f=i(2823),c=i(3248),l=i(5623);t.calculateOutputShape=(g,_,b,y,w)=>{const T=g[0],S=g.slice(2),A=S.length,P=_[0],x=_.slice(2).map((N,z)=>N+(N-1)*(b[z]-1)),M=S.map((N,z)=>N+y[z]+y[z+A]).map((N,z)=>Math.floor((N-x[z]+w[z])/w[z]));return[T,P].concat(...M)},t.conv=(g,_,b)=>(p(_,b),n(g,_,b));const n=(g,_,b)=>{const y=o(b,_),w=g.session.pack,T=y.kernelShape[0]===1&&y.kernelShape[1]===1;return y.group>1?[g.run((0,d.createUnpackedGroupedConvProgramInfoLoader)(g,_,y),_)]:T&&w?[e(g,_,y)]:w&&_[0].dims.length===4&&_[0].dims[0]===1&&!T?[(0,a.conv2DPacked)(g,_,y)]:[r(g,_,y)]},e=(g,_,b)=>{const y=_[0].dims,w=_[1].dims,T=(0,t.calculateOutputShape)(y,w,b.dilations,b.pads,b.strides),S=g.reshapeUnpacked(_[0],[y[1],y[2]*y[3]]),A=g.reshapeUnpacked(_[1],[w[0],w[1]]),P=_.length>2?[A,S,_[2]]:[A,S],x=g.run((0,l.createMatmulProgramInfoLoader)(P,b),P);return g.reshapeUnpacked(x,T)},r=(g,_,b)=>{const y=_[0].dims,w=_[1].dims,T=(0,t.calculateOutputShape)(y,w,b.dilations,b.pads,b.strides),S=g.run((0,c.createIm2ColProgramInfoLoader)(g,_[0],_[1],T,b),[_[0]]),A=_.length===3?[S,_[1],_[2]]:[S,_[1]];return g.run((0,h.createDotProductProgramInfoLoader)(g,_,T,b),A)},o=(g,_)=>{const b=g.kernelShape.slice();if(g.kernelShape.length===0)for(let T=2;T<_[1].dims.length;++T)b.push(_[1].dims[T]);const y=g.pads.slice();u.PoolConvUtil.adjustPadsBasedOnAutoPad(_[0].dims,g.strides,g.dilations,b,y,g.autoPad);const w=Object.assign({},g);return Object.assign(w,{kernelShape:b,pads:y,cacheKey:g.cacheKey}),w};t.parseConvAttributes=g=>{const _=g.attributes,b=(0,f.parseInternalActivationAttributes)(_),y=_.getString("auto_pad","NOTSET"),w=_.getInts("dilations",[1,1]),T=_.getInt("group",1),S=_.getInts("kernel_shape",[]),A=_.getInts("pads",[0,0,0,0]),P=_.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:y,dilations:w,group:T,kernelShape:S,pads:A,strides:P},b))};const p=(g,_)=>{if(!g||g.length!==2&&g.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(g[0].dims.length!==4||g[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(g[0].dims[1]!==g[1].dims[1]*_.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(g.length===3&&(g[2].dims.length!==1||g[1].dims[0]!==g[2].dims[0]))throw new Error("invalid bias");const b=g[0].dims.length-2;if(_.dilations.length!==b)throw new Error(`dilations should be ${b}D`);if(_.strides.length!==b)throw new Error(`strides should be ${b}D`);if(_.pads.length!==2*b)throw new Error(`pads should be ${2*b}D`);if(_.kernelShape.length!==0&&_.kernelShape.length!==g[1].dims.length-2)throw new Error("invalid kernel shape");if(g[0].type!=="float32"||g[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(g.length===3&&g[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},5193:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseDepthToSpaceAttributes=t.depthToSpace=void 0;const s=i(3738);t.depthToSpace=(d,a,h)=>{u(a);const f=h.blocksize,c=f*f,l=h.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],n=h.mode==="DCR"?[a[0].dims[0],f,f,a[0].dims[1]/c,a[0].dims[2],a[0].dims[3]]:[a[0].dims[0],a[0].dims[1]/c,f,f,a[0].dims[2],a[0].dims[3]],e=d.reshapeUnpacked(a[0],n),r={perm:l,cacheKey:`${l}`},[o]=(0,s.transpose)(d,[e],r),p=[a[0].dims[0],a[0].dims[1]/c,a[0].dims[2]*f,a[0].dims[3]*f];return[d.reshapeUnpacked(o,p)]},t.parseDepthToSpaceAttributes=d=>{const a=d.attributes.getInt("blocksize");if(a<1)throw new Error(`blocksize must be >= 1, but got : ${a} for DepthToSpace`);const h=d.attributes.getString("mode","DCR");if(h!=="DCR"&&h!=="CRD")throw new Error(`unrecognized mode: ${h} for DepthToSpace`);return{mode:h,blocksize:a}};const u=d=>{if(d.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${d.length}`);if(d[0].type==="string"||d[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},9828:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createDotProductProgramInfoLoader=void 0;const s=i(2517),u=i(5060),d=i(2039),a=i(2823),h=i(3248);t.createDotProductProgramInfoLoader=(f,c,l,n)=>{const e=((r,o)=>({name:"ConvDotProduct",inputNames:r?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:r?[d.TextureType.unpacked,d.TextureType.packedLastDimension,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.packedLastDimension],cacheKey:o.activationCacheKey}))(c.length>2,n);return Object.assign(Object.assign({},e),{get:()=>((r,o,p,g,_)=>{const b=p[0].dims,y=p[1].dims,w=[y[0],Math.ceil(b[1]*y[2]*y[3]/4)],T=(0,h.calculateIm2ColDims)(b,y,g),[S,A]=r.calculateTextureWidthAndHeight(w,d.TextureType.packedLastDimension),P=s.ShapeUtil.computeStrides(T),[x,M]=r.calculateTextureWidthAndHeight(T,d.TextureType.packedLastDimension),N=g.length,z=p.length<3?"0.0":"_B(b)",$=Math.ceil(b[1]*y[2]*y[3]/4),{activationFunction:C,applyActivation:G}=(0,a.getActivationSnippet)(_),D=(0,u.getGlsl)(r.session.backend.glContext.version),R=` +${C} +float process(int indices[${N}]) { + int b[1]; + b[0] = indices[1]; + int im2col[4]; + im2col[0] = indices[0]; + im2col[1] = indices[2]; + im2col[2] = indices[3]; + int im2colOffset = im2col[0] * ${P[0]} + im2col[1] * ${P[1]} + im2col[2] * ${P[2]}; + int kernelOffset = indices[1] * ${w[1]}; + float value = ${z}; + for (int i = 0; i < ${$}; ++i) { + vec2 im2colCoords = offsetToCoords(im2colOffset, ${x}, ${M}); + vec2 kernelCoords = offsetToCoords(kernelOffset, ${S}, ${A}); + value += dot(${D.texture2D}(Im2Col, im2colCoords), ${D.texture2D}(K, kernelCoords)); + ++im2colOffset; + ++kernelOffset; + } + ${G} + return value; +}`;return Object.assign(Object.assign({},o),{output:{dims:g,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:R})})(f,e,c,l,n)})}},7992:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseFlattenAttributes=t.flatten=void 0;const s=i(2517);t.flatten=(d,a,h)=>{u(a,h);const f=s.ShapeUtil.flattenShape(a[0].dims,h);return[d.reshapeUnpacked(a[0],f)]},t.parseFlattenAttributes=d=>d.attributes.getInt("axis",1);const u=(d,a)=>{if(!d||d.length!==1)throw new Error("Flatten requires 1 input.");const h=d[0].dims.length;if(h===0)throw new Error("scalar tensor is not supported.");if(a<-h||a>h)throw new Error("Invalid axis");if(d[0].type==="string")throw new Error("string tensor is not supported.")}},2823:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseInternalActivationAttributes=t.getActivationSnippet=void 0;const s=i(2517),u=i(4909);t.getActivationSnippet=function(d){let a;switch(d.activation){case"Relu":a=(0,u.glslRelu)();break;case"Sigmoid":a=(0,u.glslSigmoid)();break;case"Clip":a=(0,u.glslClip)(d.clipMin,d.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const h=a.name;return{activationFunction:a.body,applyActivation:`value = ${h}_(value);`}},t.parseInternalActivationAttributes=d=>{const a=d.getString("activation","");if(a==="Clip"){const[h,f]=d.getFloats("activation_params",[s.MIN_CLIP,s.MAX_CLIP]);return{activation:a,clipMax:f,clipMin:h,activationCacheKey:`${a}:${h},${f}`}}return{activation:a,activationCacheKey:a}}},1253:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGatherAttributes=t.gather=void 0;const s=i(246),u=i(782),d=i(2517),a=i(2039);t.gather=(l,n,e)=>(c(n,e.axis),[l.run(f(l,n,e),n)]),t.parseGatherAttributes=l=>(0,s.createAttributeWithCacheKey)({axis:l.attributes.getInt("axis",0)});const h={name:"Gather",inputNames:["A","B"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},f=(l,n,e)=>{const r=Object.assign(Object.assign({},h),{cacheHint:e.cacheKey});return Object.assign(Object.assign({},r),{get:()=>((o,p,g,_)=>{const b=g[0].dims.slice(),y=g[1].dims.slice(),w=new Array(b.length+y.length-1);_=d.ShapeUtil.normalizeAxis(_,b.length);const T=[];for(let A=0;A{if(!l||l.length!==2)throw new Error("Gather requires 2 inputs.");const e=l[0].dims.length;if(e<1)throw new Error("Invalid input shape.");if(n<-e||n>e-1)throw new Error("Invalid axis.");if(u.NUMBER_TYPES.indexOf(l[0].type)===-1)throw new Error("Invaid input type.");if(l[1].type!=="int32"&&l[1].type!=="int16")throw new Error("Invaid input type.")}},4776:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGemmAttributesV11=t.parseGemmAttributesV7=t.gemm=void 0;const s=i(246),u=i(2517),d=i(2039);t.gemm=(l,n,e)=>(c(n,e),[l.run(h(n,e),n)]);const a=(l,n)=>{const e=l.attributes.getInt("transA",0)!==0,r=l.attributes.getInt("transB",0)!==0,o=l.attributes.getFloat("alpha",1),p=l.attributes.getFloat("beta",1);return(0,s.createAttributeWithCacheKey)({transA:e,transB:r,alpha:o,beta:p,isOptionalC:n})};t.parseGemmAttributesV7=l=>a(l,!1),t.parseGemmAttributesV11=l=>a(l,!0);const h=(l,n)=>{const e={name:"Gemm",inputNames:l.length===3?["A","B","C"]:["A","B"],inputTypes:l.length===3?[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.unpacked],key:n.cacheKey};return Object.assign(Object.assign({},e),{get:()=>f(e,l,n)})},f=(l,n,e)=>{const r=n[0].dims.slice(),o=n[1].dims.slice(),[p,g]=u.GemmUtil.getShapeOfGemmResult(r,e.transA,o,e.transB,n.length===3?n[2].dims:void 0),_=[p,g];if(!_)throw new Error("Can't use gemm on the given tensors");let b=r[r.length-1],y="";e.transA&&(b=r[0]),e.transA&&e.transB?y="value += _A_T(a) * _B_T(b);":e.transA&&!e.transB?y="value += _A_T(a) * _B(b);":!e.transA&&e.transB?y="value += _A(a) * _B_T(b);":e.transA||e.transB||(y="value += _A(a) * _B(b);");const w=_.length,T=` + float process(int indices[${w}]) { + int a[${w}]; + int b[${w}]; + ${n.length===3?`int c[${n[2].dims.length}];`:""} + + copyVec(indices, a); + copyVec(indices, b); + ${n.length===3?"bcastIndices_C(indices, c);":""} + + float value = 0.0; + for (int k=0; k<${b}; ++k) { + a[${w-1}] = k; + b[${w-2}] = k; + ${y} + } + + value = value * alpha; + ${n.length===3?"value += beta * _C(c);":""} + return value; + }`;return Object.assign(Object.assign({},l),{output:{dims:_,type:n[0].type,textureType:d.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:e.alpha},{name:"beta",type:"float",data:e.beta}],shaderSource:T})},c=(l,n)=>{if(!l)throw new Error("Input is missing");if(n.isOptionalC&&(l.length<2||l.length>3))throw new Error("Invaid input shape.");if(!n.isOptionalC&&l.length!==3)throw new Error("Gemm requires 3 inputs");if(l.length===3&&l[2].dims.length!==1&&l[2].dims.length!==2)throw new Error("Invalid input shape of C");if(l[0].type!=="float32"&&l[0].type!=="float64"||l[1].type!=="float32"&&l[1].type!=="float64"||l.length===3&&l[2].type!=="float32"&&l[2].type!=="float64")throw new Error("Invalid input type.");if(l[0].type!==l[1].type||l.length===3&&l[0].type!==l[2].type)throw new Error("Input types are mismatched")}},8555:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedIm2ColProgramInfoLoader=void 0;const s=i(5060),u=i(2039),d=i(2827);t.createPackedIm2ColProgramInfoLoader=(a,h,f,c,l)=>{const n=(e=l.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[u.TextureType.packed],cacheHint:e});var e;return Object.assign(Object.assign({},n),{get:()=>((r,o,p,g,_,b)=>{const y=p.dims,w=g.dims,T=_.length,S=[w[1]*w[2]*w[3],_[2]*_[3]],A=w[2]*w[3],P=(0,d.unpackFromChannel)(),x=(0,s.getGlsl)(r.session.backend.glContext.version);let M="";for(let z=0;z<=1;z++)for(let $=0;$<=1;$++)M+=` + blockIndex = rc.x + ${$}; + pos = rc.y + ${z}; + + if(blockIndex < ${S[1]} && pos < ${S[0]}) { + offsetY = int(blockIndex / (${_[T-1]})) * ${b.strides[0]} - + ${b.pads[0]}; + d0 = offsetY + ${b.dilations[0]} * (imod(pos, ${A}) / ${w[2]}); + + if(d0 < ${y[2]} && d0 >= 0) { + offsetX = imod(blockIndex, ${_[T-1]}) * ${b.strides[1]} - + ${b.pads[1]}; + d1 = offsetX + ${b.dilations[1]} * imod(imod(pos, ${A}), ${w[2]}); + + if(d1 < ${y[3]} && d1 >= 0) { + + ch = int(float(pos)/ ${A}.); + innerDims = vec2(d0, d1); + result[${2*z+$}] = getChannel( + getA(0, ch, int(innerDims.x), + int(innerDims.y)), innerDims); + } + } + } + + `;const N=` + ${P} + + void main() { + ivec2 rc = getOutputCoords(); + vec4 result = vec4(0.0); + int blockIndex, pos, offsetY, d0, offsetX, d1, ch; + vec2 innerDims; + ${M} + ${x.output} = result; + } + `;return Object.assign(Object.assign({},o),{output:{dims:S,type:p.type,textureType:u.TextureType.packed},shaderSource:N,hasMain:!0})})(a,n,h,f,c,l)})}},3248:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.calculateIm2ColDims=t.createIm2ColProgramInfoLoader=void 0;const s=i(2039);t.createIm2ColProgramInfoLoader=(u,d,a,h,f)=>{const c=(l=f.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[s.TextureType.unpacked],cacheHint:l});var l;return Object.assign(Object.assign({},c),{get:()=>((n,e,r,o,p,g)=>{const _=r.dims,b=o.dims,y=p.length,w=(0,t.calculateIm2ColDims)(_,b,p,4),T=` + const int XC = ${_[1]}; + const int XH = ${_[2]}; + const int XW = ${_[3]}; + const int KH = ${g.kernelShape[0]}; + const int KW = ${g.kernelShape[1]}; + const int dilationH = ${g.dilations[0]}; + const int dilationW = ${g.dilations[1]}; + const int strideH = ${g.strides[0]}; + const int strideW = ${g.strides[1]}; + const int padH = ${g.pads[0]}; + const int padW = ${g.pads[1]}; + const int KHKW = KH*KW; + const int XCKHKW = XC * KHKW; + const int outputChannels = 4; + vec4 process(int indices[${y}]) { + int b = indices[0]; // batch size + int oh = indices[1] * strideH - padH; //output height + int ow = indices[2] * strideW - padW; //output width + int p = indices[3] * outputChannels; //patch + vec4 value = vec4(0.0); + for(int i=0; i < outputChannels; ++i) { + if(p < XCKHKW) { + int patchC = p / KHKW; + int patchH = (p - patchC*KHKW) / KW; + int patchW = (p - patchC*KHKW) - patchH * KW; + int xh2 = oh + patchH * dilationH; + int xw2 = ow + patchW * dilationW; + int x[${_.length}]; + x[0] = b; + x[1] = patchC; + x[2] = xh2; + x[3] = xw2; + if(xh2 >= 0 && + xh2 < XH && + xw2 >= 0 && + xw2 < XW) { + value[i] = _X(x); + } + } + ++p; + } + return value; + } + `;return Object.assign(Object.assign({},e),{output:{dims:w,type:r.type,textureType:s.TextureType.packedLastDimension},shaderSource:T})})(0,c,d,a,h,f)})},t.calculateIm2ColDims=(u,d,a,h=4)=>[a[0],a[2],a[3],Math.ceil(u[1]*d[2]*d[3]/h)]},6572:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseImageScalerAttributes=t.imageScaler=void 0;const s=i(246),u=i(2039);t.imageScaler=(c,l,n)=>(f(l),[c.run(a(c,l,n),l)]),t.parseImageScalerAttributes=c=>{const l=c.attributes.getFloat("scale"),n=c.attributes.getFloats("bias");return(0,s.createAttributeWithCacheKey)({scale:l,bias:n})};const d={name:"ImageScaler",inputNames:["X"],inputTypes:[u.TextureType.unpacked]},a=(c,l,n)=>{const e=Object.assign(Object.assign({},d),{cacheHint:n.cacheKey});return Object.assign(Object.assign({},e),{get:()=>((r,o,p,g)=>{const _=p[0].dims.slice(),b=_.length,y=` + ${h(g.bias.length)} + float process(int indices[${b}]) { + return _X(indices) * scale + getBias(bias, indices[1]); + }`;return Object.assign(Object.assign({},o),{output:{dims:_,type:p[0].type,textureType:u.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:g.bias.length,data:g.bias},{name:"scale",type:"float",data:g.scale}],shaderSource:y})})(0,e,l,n)})},h=c=>{const l=[`float getBias(float bias[${c}], int channel) {`];for(let n=0;n{if(!c||c.length!==1)throw new Error("ImageScaler requires 1 input.");if(c[0].dims.length!==4)throw new Error("Invalid input shape.");if(c[0].type!=="float32"&&c[0].type!=="float64")throw new Error("Invalid input type.")}},3346:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseInstanceNormalizationAttributes=t.instanceNormalization=void 0;const s=i(5060),u=i(2039);t.instanceNormalization=(l,n,e)=>{c(n);const r=l.run(a(n[0]),n);return[l.run(f(l,n[0],e,r.dims),[n[0],r,n[1],n[2]])]},t.parseInstanceNormalizationAttributes=l=>l.attributes.getFloat("epsilon",1e-5);const d={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[u.TextureType.unpacked]},a=l=>Object.assign(Object.assign({},d),{get:()=>((n,e)=>{const r=e.dims.slice(),o=r[1],p=r[2]*r[3],g=[r[0],o],_=` + vec4 process(int[2] indices) { + vec4 v = vec4(0.0); + int a[4]; + a[0] = indices[0]; + a[1] = indices[1]; + float temp = 0.0; + for(int a2=0; a2<${r[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${r[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += x; + } + } + float mean = temp / float(${p}); + temp = 0.0; + for(int a2=0; a2<${r[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${r[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += (x - mean) * (x - mean); + } + } + v.r = mean; + v.g = temp / float(${p}); + + return v; + }`;return Object.assign(Object.assign({},n),{output:{dims:g,type:e.type,textureType:u.TextureType.packedLastDimension},shaderSource:_})})(d,l)}),h={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[u.TextureType.unpacked,u.TextureType.packedLastDimension,u.TextureType.unpacked,u.TextureType.unpacked]},f=(l,n,e,r)=>{const o=Object.assign(Object.assign({},h),{cacheHint:`${e}`});return Object.assign(Object.assign({},o),{get:()=>((p,g,_,b,y)=>{const w=(0,s.getGlsl)(p.session.backend.glContext.version),[T,S]=p.calculateTextureWidthAndHeight(y,u.TextureType.packedLastDimension),[A,P]=[T/4,S],x=` + vec4 get_MeanAndVariance(int[2] mv) { + int offset = indicesToOffset_MeanAndVariance(mv); + vec2 coords = offsetToCoords(offset, ${A}, ${P}); + return ${w.texture2D}(MeanAndVariance, coords); + } + + float process(int[4] indices) { + int mv[2]; + mv[0] = indices[0]; + mv[1] = indices[1]; + vec4 mean_and_variance = get_MeanAndVariance(mv); + float mean = mean_and_variance.r; + float variance = mean_and_variance.g; + + int sb[1]; + sb[0] = indices[1]; + float scale = _Scale(sb); + float b = _B(sb); + + return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b; + }`;return Object.assign(Object.assign({},g),{output:{dims:_.dims,type:_.type,textureType:u.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:b}],shaderSource:x})})(l,o,n,e,r)})},c=l=>{if(!l||l.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const n=l[0],e=l[1],r=l[2];if(n.dims.length<3||e.dims.length!==1||r.dims.length!==1)throw new Error("Invalid input shape.");if(e.dims[0]!==n.dims[1]||r.dims[0]!==n.dims[1])throw new Error("Input shapes are mismatched.");if(n.type!=="float32"&&n.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64")throw new Error("Invalid input type.");if(l[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},708:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedMatmulProgramInfoLoader=void 0;const s=i(2517),u=i(5060),d=i(2039),a=i(9390),h=i(2823),f=i(5623);t.createPackedMatmulProgramInfoLoader=(c,l,n)=>{const e=(r=l.length>2,o=n.activationCacheKey,{name:"MatMul (packed)",inputNames:r?["A","B","Bias"]:["A","B"],inputTypes:r?[d.TextureType.packed,d.TextureType.packed,d.TextureType.packed]:[d.TextureType.packed,d.TextureType.packed],cacheHint:o});var r,o;return Object.assign(Object.assign({},e),{get:()=>((p,g,_,b)=>{const y=_.length>2,w=y?"value += getBiasForMatmul();":"",T=_[0].dims,S=_[1].dims,A=s.BroadcastUtil.calcShape(T,S,!0),P=!s.ShapeUtil.areEqual(_[0].dims,_[1].dims);if(!A)throw new Error("Can't use matmul on the given tensors");const x=T[T.length-1],M=Math.ceil(x/2),N=T.length,z=S.length,$=(0,u.getGlsl)(p.session.backend.glContext.version),C=(0,a.getCoordsDataType)(A.length),G=A.length,D=(0,a.getGlChannels)(),{activationFunction:R,applyActivation:Y}=(0,h.getActivationSnippet)(b),V=y?`${(0,f.getBiasForMatmul)(C,D,_[2].dims,A,!0)}`:"",J=P?`${function(xe,se,we,be){let Ie=[],Le=[];const ve=we[0].dims,$e=we[1].dims,Fe=ve.length,Me=$e.length,Pe=be.length,Be=Pe-Fe,Ge=Pe-Me;Ie=ve.map((Ee,ze)=>`coords.${se[ze+Be]}`),Ie[Fe-1]="i*2",Ie.join(", "),Le=$e.map((Ee,ze)=>`coords.${se[ze+Ge]}`),Le[Me-2]="i*2",Le.join(", ");const Ve=s.BroadcastUtil.getBroadcastDims(ve,be),Xe=s.BroadcastUtil.getBroadcastDims($e,be),Qe=Ve.map(Ee=>`coords.${se[Ee+Be]} = 0;`).join(` +`),qe=Xe.map(Ee=>`coords.${se[Ee+Ge]} = 0;`).join(` +`),Ue=`int lastDim = coords.${se[Pe-1]}; + coords.${se[Pe-1]} = coords.${se[Pe-2]}; + coords.${se[Pe-2]} = lastDim;`;return` +vec4 getAAtOutCoordsMatmul(int i) { + ${xe} coords = getOutputCoords(); + ${Ue} + ${Qe} + vec4 outputValue = getA(${Ie}); + return outputValue; +} + +vec4 getBAtOutCoordsMatmul(int i) { + ${xe} coords = getOutputCoords(); + ${Ue} + ${qe} + vec4 outputValue = getB(${Le}); + return outputValue; +}`}(C,D,_,A)}`:"",Z=P?"getAAtOutCoordsMatmul(i)":`getA(${function(xe,se){let we="";for(let be=0;be{Object.defineProperty(t,"__esModule",{value:!0}),t.getBiasForMatmul=t.createMatmulProgramInfoLoader=t.parseMatMulAttributes=t.matMul=void 0;const s=i(2517),u=i(2039),d=i(9390),a=i(2823),h=i(708);function f(n,e){const r=(o=n.length>2,p=e.activationCacheKey,{name:"MatMul",inputNames:o?["A","B","Bias"]:["A","B"],inputTypes:o?[u.TextureType.unpacked,u.TextureType.unpacked,u.TextureType.unpacked]:[u.TextureType.unpacked,u.TextureType.unpacked],cacheHint:p});var o,p;return Object.assign(Object.assign({},r),{get:()=>function(g,_,b){const y=_[0].dims,w=_[1].dims,T=s.BroadcastUtil.calcShape(y,w,!0);if(!T)throw new Error("Can't use matmul on the given tensors");const S=(0,d.getCoordsDataType)(T.length),A=(0,d.getGlChannels)(),{activationFunction:P,applyActivation:x}=(0,a.getActivationSnippet)(b),M=_.length>2,N=M?"value += getBiasForMatmul();":"",z=M?`${l(S,A,_[2].dims,T,!1)}`:"",$=T.length,C=y.length,G=w.length,D=` + ${P} + ${z} + float process(int indices[${$}]) { + int a[${C}]; + int b[${G}]; + bcastMatmulIndices_A(indices, a); + bcastMatmulIndices_B(indices, b); + + float value; + for (int k=0; k<${y[y.length-1]}; ++k) { + a[${C-1}] = k; + b[${G-2}] = k; + value += _A(a) * _B(b); + } + ${N} + ${x} + return value; + }`;return Object.assign(Object.assign({},g),{output:{dims:T,type:_[0].type,textureType:u.TextureType.unpacked},shaderSource:D})}(r,n,e)})}t.matMul=(n,e,r)=>(c(e),n.session.pack?[n.run((0,h.createPackedMatmulProgramInfoLoader)(n,e,r),e)]:[n.run(f(e,r),e)]),t.parseMatMulAttributes=n=>(0,a.parseInternalActivationAttributes)(n.attributes),t.createMatmulProgramInfoLoader=f;const c=n=>{if(!n||n.length!==2)throw new Error("MatMul requires 2 inputs.");if(n[0].dims[n[0].dims.length-1]!==n[1].dims[n[1].dims.length-2])throw new Error("shared dimension does not match.");if(n[0].type!=="float32"&&n[0].type!=="float64"||n[1].type!=="float32"&&n[1].type!=="float64")throw new Error("inputs should be float type");if(n[0].type!==n[1].type)throw new Error("inputs types should match")};function l(n,e,r,o,p){let g="";const _=r.length,b=o.length,y=b-_;g=b<2&&_>0?"coords":r.map((S,A)=>`coords.${e[A+y]}`).join(", ");const w=s.BroadcastUtil.getBroadcastDims(r,o).map(S=>`coords.${e[S+y]} = 0;`).join(` +`);let T="vec4(outputValue.xx, outputValue.yy)";return s.ShapeUtil.size(r)===1&&(T="vec4(outputValue.x)"),p?` +vec4 getBiasForMatmul() { + ${n} coords = getOutputCoords(); + ${w} + vec4 outputValue = getBias(${g}); + return ${T}; +}`:` +float getBiasForMatmul() { + ${n} coords = getOutputCoords(); + ${w} + return getBias(coords.x); +}`}t.getBiasForMatmul=l},2403:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackProgramInfoLoader=void 0;const s=i(5060),u=i(2039),d=i(9390),a=i(2827),h={name:"pack",inputNames:["A"],inputTypes:[u.TextureType.unpackedReversed]};t.createPackProgramInfoLoader=(f,c)=>Object.assign(Object.assign({},h),{get:()=>((l,n)=>{const e=(0,s.getGlsl)(l.session.backend.glContext.version),r=n.dims,o=r.length,p=n.dims.length,g=(0,d.getCoordsDataType)(p),_=(0,a.getChannels)("rc",p),b=(y=p,w=_,T=r[r.length-2],S=r[r.length-1],y===0||y===1?"":` + int r = ${w[y-2]}; + int c = ${w[y-1]}; + int rp1 = ${w[y-2]} + 1; + int cp1 = ${w[y-1]} + 1; + bool rEdge = rp1 >= ${S}; + bool cEdge = cp1 >= ${T}; + `);var y,w,T,S;let A;A=o===0?[1,1]:o===1?[r[0],1]:[r[p-1],r[p-2]];const P=function(N,z,$){if(N===0)return"false";if(N===1)return`rc > ${z[0]}`;let C="";for(let G=N-2;G= ${z[G-N+2]}`,G= ${N[0]} ? 0. : getA(rc + 1), + 0, 0`;let C="";if($>2)for(let G=0;G<$-2;++G)C+=`${z[G]},`;return`getA(${C}r, c), + rEdge ? 0. : getA(${C}rp1, c), + cEdge ? 0. : getA(${C}r, cp1), + rEdge || cEdge ? 0. : getA(${C}rp1, cp1)`}(r,_),M=` + void main() { + ${g} rc = getOutputCoords(); + + if(${P}) { + ${e.output} = vec4(0); + } else { + ${b} + + ${e.output} = vec4(${x}); + } + } + `;return Object.assign(Object.assign({},h),{hasMain:!0,output:{dims:n.dims,type:n.type,textureType:u.TextureType.packed},shaderSource:M})})(f,c)})},2827:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unpackFromChannel=t.getChannels=t.getVecChannels=void 0;const s=i(9390);function u(d,a){return(0,s.getGlChannels)(a).map(h=>`${d}.${h}`)}t.getVecChannels=u,t.getChannels=function(d,a){return a===1?[d]:u(d,a)},t.unpackFromChannel=function(){return` + float getChannel(vec4 frag, int dim) { + int modCoord = imod(dim, 2); + return modCoord == 0 ? frag.r : frag.g; + } + + float getChannel(vec4 frag, vec2 innerDims) { + vec2 modCoord = mod(innerDims, 2.); + return modCoord.x == 0. ? + (modCoord.y == 0. ? frag.r : frag.g) : + (modCoord.y == 0. ? frag.b : frag.a); + } + `}},2870:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parsePadAttributesV11=t.padV11=t.parsePadAttributesV2=t.padV2=void 0;const s=i(246),u=i(2517),d=i(5060),a=i(2039),h={name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};t.padV2=(g,_,b)=>(l(_),[g.run(Object.assign(Object.assign({},h),{cacheHint:b.cacheKey,get:()=>c(g,_[0],b)}),_)]),t.parsePadAttributesV2=g=>{const _=g.attributes.getString("mode","constant"),b=g.attributes.getFloat("value",0),y=g.attributes.getInts("pads");return(0,s.createAttributeWithCacheKey)({mode:_,value:b,pads:y})},t.padV11=(g,_,b)=>{n(_);const y=f(g,_,b);return(0,t.padV2)(g,[_[0]],y)},t.parsePadAttributesV11=g=>g.attributes.getString("mode","constant");const f=(g,_,b)=>{if(!g.session.isInitializer(_[1].dataId)||_.length>=3&&!g.session.isInitializer(_[2].dataId))throw new Error("dynamic pad attributes are not allowed");const y=Array.from(_[1].integerData),w=_.length>=3?_[2].floatData[0]:0;return(0,s.createAttributeWithCacheKey)({mode:b,pads:y,value:w})},c=(g,_,b)=>{const y=u.ShapeUtil.padShape(_.dims.slice(),b.pads),w=y.length,T=` + ${e(g,_,b)} + float process(int[${w}] indices) { + return padA(indices); + }`;return{name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked],output:{dims:y,type:_.type,textureType:a.TextureType.unpacked},shaderSource:T}},l=g=>{if(!g||g.length!==1)throw new Error("Pad requires 1 input");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type.")},n=g=>{if(!g||g.length!==2&&g.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(g[1].type!=="int32")throw new Error("Invalid input type.");if(g.length>=3&&g[2].type==="string")throw new Error("Invalid input type.")},e=(g,_,b)=>{const y=(0,d.getGlsl)(g.session.backend.glContext.version),[w,T]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),S=u.ShapeUtil.computeStrides(_.dims);switch(b.mode){case"constant":return r(y,_.dims,S,w,T,b.pads,b.value);case"reflect":return o(y,_.dims,S,w,T,b.pads);case"edge":return p(y,_.dims,S,w,T,b.pads);default:throw new Error("Invalid mode")}},r=(g,_,b,y,w,T,S)=>{const A=_.length;let P="";for(let x=A-1;x>=0;--x)P+=` + k = m[${x}] - ${T[x]}; + if (k < 0) return constant; + if (k >= ${_[x]}) return constant; + offset += k * ${b[x]}; + `;return` + float padA(int m[${A}]) { + const float constant = float(${S}); + int offset = 0; + int k = 0; + ${P} + vec2 coords = offsetToCoords(offset, ${y}, ${w}); + float value = getColorAsFloat(${g.texture2D}(A, coords)); + return value; + } + `},o=(g,_,b,y,w,T)=>{const S=_.length;let A="";for(let P=S-1;P>=0;--P)A+=` + k = m[${P}] - ${T[P]}; + if (k < 0) { k = -k; } + { + const int _2n_1 = ${2*(_[P]-1)}; + k = int( mod( float(k), float(_2n_1) ) ) ; + if(k >= ${_[P]}) { k = _2n_1 - k; } + } + offset += k * ${b[P]}; + `;return` + float padA(int m[${S}]) { + int offset = 0; + int k = 0; + ${A} + vec2 coords = offsetToCoords(offset, ${y}, ${w}); + float value = getColorAsFloat(${g.texture2D}(A, coords)); + return value; + } + `},p=(g,_,b,y,w,T)=>{const S=_.length;let A="";for(let P=S-1;P>=0;--P)A+=` + k = m[${P}] - ${T[P]}; + if (k < 0) k = 0; + if (k >= ${_[P]}) k = ${_[P]-1}; + offset += k * ${b[P]}; + `;return` + float padA(int m[${S}]) { + int offset = 0; + int k = 0; + ${A} + vec2 coords = offsetToCoords(offset, ${y}, ${w}); + float value = getColorAsFloat(${g.texture2D}(A, coords)); + return value; + } + `}},2143:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.globalMaxPool=t.parseMaxPoolAttributes=t.maxPool=t.parseGlobalAveragePoolAttributes=t.globalAveragePool=t.parseAveragePoolAttributes=t.averagePool=void 0;const s=i(246),u=i(2517),d=i(2039);t.averagePool=(p,g,_)=>{n(g);const b={name:"AveragePool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:_.cacheKey};return[p.run(Object.assign(Object.assign({},b),{get:()=>a(g,b,!1,_)}),g)]},t.parseAveragePoolAttributes=p=>{const g=p.attributes.getString("auto_pad","NOTSET"),_=p.attributes.getInt("ceil_mode",0),b=p.attributes.getInt("count_include_pad",0)!==0,y=p.attributes.getInts("kernel_shape"),w=p.attributes.getInts("strides",[]),T=p.attributes.getInts("pads",[]);if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,s.createAttributeWithCacheKey)({autoPad:g,ceilMode:_,countIncludePad:b,kernelShape:y,strides:w,pads:T})};const a=(p,g,_,b)=>{const[y,w]=f(p,b,_),T=u.ShapeUtil.size(y.kernelShape);let S="";y.countIncludePad?S+=`value /= float(${T});`:S+=`value /= float(${T} - pad);`;const A=` + ${e(p[0].dims,y,"value += _X(x);",S,"0.0")} + `;return Object.assign(Object.assign({},g),{output:{dims:w,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:A})};t.globalAveragePool=(p,g,_)=>{n(g);const b={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:`${_.countIncludePad}`};return[p.run(Object.assign(Object.assign({},b),{get:()=>a(g,b,!0,_)}),g)]},t.parseGlobalAveragePoolAttributes=p=>{const g=p.attributes.getInt("count_include_pad",0)!==0;return(0,s.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:g,kernelShape:[],strides:[],pads:[]})},t.maxPool=(p,g,_)=>{n(g);const b={name:"MaxPool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:_.cacheKey};return[p.run(Object.assign(Object.assign({},b),{get:()=>h(g,b,!1,_)}),g)]},t.parseMaxPoolAttributes=p=>{const g=p.attributes.getString("auto_pad","NOTSET"),_=p.attributes.getInt("ceil_mode",0),b=p.attributes.getInts("kernel_shape"),y=p.attributes.getInts("strides",[]),w=p.attributes.getInts("pads",[]),T=p.attributes.getInt("storage_order",0),S=p.attributes.getInts("dilations",[]);if(T!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,s.createAttributeWithCacheKey)({autoPad:g,ceilMode:_,countIncludePad:!1,kernelShape:b,strides:y,pads:w,storageOrder:T,dilations:S})};const h=(p,g,_,b)=>{const[y,w]=f(p,b,_),T=` + ${e(p[0].dims,y,` + value = max(_X(x), value); + `,"","-1e5")} + `;return Object.assign(Object.assign({},g),{output:{dims:w,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:T})},f=(p,g,_)=>{const b=p[0].dims.slice(),y=Object.hasOwnProperty.call(g,"dilations"),w=g.kernelShape.slice(),T=g.strides.slice(),S=y?g.dilations.slice():[],A=g.pads.slice();u.PoolConvUtil.adjustPoolAttributes(_,b,w,T,S,A);const P=u.PoolConvUtil.computePoolOutputShape(_,b,T,S,w,A,g.autoPad),x=Object.assign({},g);return y?Object.assign(x,{kernelShape:w,strides:T,pads:A,dilations:S,cacheKey:g.cacheKey}):Object.assign(x,{kernelShape:w,strides:T,pads:A,cacheKey:g.cacheKey}),[x,P]},c={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},l={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[d.TextureType.unpacked]};t.globalMaxPool=(p,g)=>(n(g),[p.run(Object.assign(Object.assign({},l),{get:()=>h(g,l,!0,c)}),g)]);const n=p=>{if(!p||p.length!==1)throw new Error("Pool ops requires 1 input.");if(p[0].type!=="float32"&&p[0].type!=="float64")throw new Error("Invalid input type.")},e=(p,g,_,b,y)=>{const w=p.length;if(g.kernelShape.length<=2){const T=g.kernelShape[g.kernelShape.length-1],S=g.strides[g.strides.length-1],A=g.pads[g.pads.length/2-1],P=g.pads[g.pads.length-1],x=p[w-1];let M="",N="",z="";if(M=A+P!==0?` + for (int i = 0; i < ${T}; i++) { + x[${w} - 1] = indices[${w} - 1] * ${S} - ${A} + i; + if (x[${w} - 1] < 0 || x[${w} - 1] >= ${x}) { + pad++; + continue; + } + ${_} + }`:` + for (int i = 0; i < ${T}; i++) { + x[${w} - 1] = indices[${w} - 1] * ${S} - ${A} + i; + ${_} + }`,g.kernelShape.length===2){const $=g.kernelShape[g.kernelShape.length-2],C=g.strides[g.strides.length-2],G=g.pads[g.pads.length/2-2],D=g.pads[g.pads.length-2],R=p[w-2];N=G+D!==0?` + for (int j = 0; j < ${$}; j++) { + x[${w} - 2] = indices[${w} - 2] * ${C} - ${G} + j; + if (x[${w} - 2] < 0 || x[${w} - 2] >= ${R}) { + pad+= ${T}; + continue; + } + `:` + for (int j = 0; j < ${$}; j++) { + x[${w} - 2] = indices[${w} - 2] * ${C} - ${G} + j; + `,z=` + } + `}return` + float process(int indices[${w}]) { + int x[${w}]; + copyVec(indices, x); + + float value = ${y}; + int pad = 0; + ${N} + ${M} + ${z} + ${b} + return value; + } + `}{const T=u.ShapeUtil.size(g.kernelShape),S=u.ShapeUtil.computeStrides(g.kernelShape),A=S.length,P=g.pads.length,x=o(A),M=r(p,"inputDims"),N=r(g.pads,"pads"),z=r(S,"kernelStrides"),$=r(g.strides,"strides");let C="";return C=g.pads.reduce((G,D)=>G+D)?` + if (x[j] >= inputDims[j] || x[j] < 0) { + pad++; + isPad = true; + break; + } + } + if (!isPad) { + ${_} + }`:` + } + ${_} + `,` + ${x} + float process(int indices[${w}]) { + int x[${w}]; + copyVec(indices, x); + int offset[${A}]; + int pads[${P}]; + int inputDims[${w}]; + int kernelStrides[${A}]; + int strides[${A}]; + ${N} + ${M} + ${$} + ${z} + + float value = ${y}; + int pad = 0; + bool isPad = false; + for (int i = 0; i < ${T}; i++) { + offsetToIndices(i, kernelStrides, offset); + isPad = false; + for (int j = ${w} - ${A}; j < ${w}; j++) { + x[j] = indices[j] * strides[j - ${w} + ${A}] + + offset[j - ${w} + ${A}] - pads[j - 2]; + ${C} + } + ${b} + + return value; + } + `}},r=(p,g)=>{let _="";for(let b=0;b` + void offsetToIndices(int offset, int[${p}] strides, out int[${p}] indices) { + if (${p} == 0) { + return; + } + for (int i = 0; i < ${p} - 1; ++i) { + indices[i] = offset / strides[i]; + offset -= indices[i] * strides[i]; + } + indices[${p} - 1] = offset; + }`},4939:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reduceLogSumSquare=t.reduceLogSum=t.reduceProd=t.reduceMin=t.reduceMax=t.reduceMean=t.reduceSum=t.parseReduceAttributes=void 0;const s=i(246),u=i(782),d=i(2517),a=i(2039),h=(l,n,e,r,o)=>{c(n);const p={name:r,inputNames:["A"],inputTypes:[a.TextureType.unpacked]};return[l.run(Object.assign(Object.assign({},p),{cacheHint:e.cacheKey,get:()=>f(l,n,e,r,o,p)}),n)]};t.parseReduceAttributes=l=>{const n=l.attributes.getInts("axes",[]),e=l.attributes.getInt("keepdims",1)===1;return(0,s.createAttributeWithCacheKey)({axes:n,keepDims:e})};const f=(l,n,e,r,o,p)=>{const g=[],_=n[0].dims.length||1,b=[],y=d.ShapeUtil.normalizeAxes(e.axes,n[0].dims.length),w=o(n,y);let T=w[1];for(let A=0;A=0||y.length===0?(e.keepDims&&g.push(1),T=` + for(int j${A} = 0; j${A} < ${n[0].dims[A]}; j${A}++) { + inputIdx[${A}] = j${A}; + ${T} + }`):(b.push(`inputIdx[${A}] = outputIdx[${g.length}];`),g.push(n[0].dims[A]));const S=` + float process(int outputIdx[${g.length||1}]) { + float value; // final result + int inputIdx[${_}]; // addressing input data + ${b.join(` +`)} + ${w[0]} // init ops for reduce max/min + ${T} + ${w[2]} // final computation for reduce mean + return value; + }`;return Object.assign(Object.assign({},p),{output:{dims:g,type:n[0].type,textureType:a.TextureType.unpacked},shaderSource:S})},c=l=>{if(!l||l.length!==1)throw new Error("Reduce op requires 1 input.");if(u.NUMBER_TYPES.indexOf(l[0].type)===-1)throw new Error("Invalid input type.")};t.reduceSum=(l,n,e)=>h(l,n,e,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),t.reduceMean=(l,n,e)=>h(l,n,e,"ReduceMean",(r,o)=>{let p=1;for(let g=0;g=0||o.length===0)&&(p*=r[0].dims[g]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${p}.;`]}),t.reduceMax=(l,n,e)=>h(l,n,e,"ReduceMax",(r,o)=>{const p=[];for(let g=0;g=0||o.length===0)&&p.push(`inputIdx[${g}] = 0;`);return[`${p.join(` +`)} +value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),t.reduceMin=(l,n,e)=>h(l,n,e,"ReduceMin",(r,o)=>{const p=[];for(let g=0;g=0||o.length===0)&&p.push(`inputIdx[${g}] = 0;`);return[`${p.join(` +`)} +value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),t.reduceProd=(l,n,e)=>h(l,n,e,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),t.reduceLogSum=(l,n,e)=>h(l,n,e,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),t.reduceLogSumSquare=(l,n,e)=>h(l,n,e,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7019:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isReshapeCheap=t.processDims3D=t.createPackedReshape3DProgramInfoLoader=void 0;const s=i(2517),u=i(5060),d=i(2039),a=i(2827);t.createPackedReshape3DProgramInfoLoader=(h,f,c)=>{const l=(n=>({name:"Reshape (packed)",inputTypes:[d.TextureType.packed],inputNames:["A"],cacheHint:`${n}`}))(c);return Object.assign(Object.assign({},l),{get:()=>((n,e,r,o)=>{const p=e.dims,g=o;let _="";for(let w=0;w<4;w++){let T="";switch(w){case 0:T="outputCoords = rc;";break;case 1:T="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:T="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:T="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}_+=` + ${T} + ${w>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""} + int flattenedIndex = getFlattenedIndex(outputCoords); + + ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex); + vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z)); + + result[${w}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); + + ${w>0?"}":""} + `}const b=(0,u.getGlsl)(n.session.backend.glContext.version),y=` + ${function(w){const T=s.ShapeUtil.computeStrides(w),S=["b","r","c"],A="index";return` + ivec3 inputCoordsFromReshapedOutCoords(int index) { + ${T.map((P,x)=>`int ${S[x]} = ${A} / ${P}; ${x===T.length-1?`int ${S[x+1]} = ${A} - ${S[x]} * ${P}`:`index -= ${S[x]} * ${P}`};`).join("")} + return ivec3(b, r, c); + } + `}(p)} + ${function(w){const T=s.ShapeUtil.computeStrides(w);return` + int getFlattenedIndex(ivec3 coords) { + // reverse y, z order + return coords.x * ${T[0]} + coords.z * ${T[1]} + coords.y; + } +`}(g)} + ${(0,a.unpackFromChannel)()} + + void main() { + ivec3 rc = getOutputCoords(); + + vec4 result = vec4(0.0); + + ivec3 outputCoords; + int rows = ${g[2]}; + int cols = ${g[1]}; + + ${_} + ${b.output} = result; + } + `;return Object.assign(Object.assign({},r),{output:{dims:g,type:e.type,textureType:d.TextureType.packed},shaderSource:y,hasMain:!0})})(h,f,l,c)})},t.processDims3D=function(h){if(h.length===0)return[1,1,1];let f=1;for(let c=0;c1?h[h.length-2]:1,h[h.length-1]]},t.isReshapeCheap=function(h,f){let c=!1;return c=h.length===0||f.length===0||(h.length<2||f.length<2?h[h.length-1]===f[f.length-1]:h[h.length-1]===f[f.length-1]&&h[h.length-2]===f[f.length-2]),c}},718:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=void 0;const s=i(2517);t.reshape=(u,d)=>{const a=s.ShapeUtil.calculateReshapedDims(d[0].dims,d[1].integerData);return u.session.pack?[u.reshapePacked(d[0],a)]:[u.reshapeUnpacked(d[0],a)]}},2268:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseResizeAttributesV11=t.parseResizeAttributesV10=t.resize=void 0;const s=i(5060),u=i(2039),d=i(9390),a=i(2827),h=i(9793),f={name:"Resize",inputNames:["A"],inputTypes:[u.TextureType.packed]};t.resize=(r,o,p)=>((0,h.validateInputs)(o,p),[r.run(Object.assign(Object.assign({},f),{cacheHint:p.cacheKey,get:()=>c(r,o,p)}),o)]),t.parseResizeAttributesV10=r=>(0,h.parseUpsampleAttributes)(r,10),t.parseResizeAttributesV11=r=>(0,h.parseUpsampleAttributes)(r,11);const c=(r,o,p)=>{const g=(0,s.getGlsl)(r.session.backend.glContext.version),[_,b]=l(o,p);if(_.every(C=>C===1)&&p.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},f),{output:{dims:b,type:o[0].type,textureType:u.TextureType.packed},hasMain:!0,shaderSource:`void main() { + vec4 v = ${g.texture2D}(X, TexCoords); + ${g.output} = v; + }`});const y=b.length;if(y<2)throw new Error(`output dimension should be at least 2, but got ${y}`);const w=b[y-2],T=b[y-1],S=o[0].dims;if(y!==S.length)throw new Error(`output dimension should match input ${S.length}, but got ${y}`);const A=S[y-2],P=S[y-1],x=_[y-2],M=_[y-1];let N="";if(p.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${p.mode}'`);switch(p.coordinateTransformMode){case"asymmetric":N=` + vec4 getSourceFracIndex(ivec4 coords) { + return vec4(coords) / scaleWHWH; + } + `;break;case"half_pixel":N=` + vec4 getSourceFracIndex(ivec4 coords) { + return (vec4(coords) + 0.5) / scaleWHWH - 0.5; + } + `;break;case"pytorch_half_pixel":N=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 fcoords = vec4(coords); + return vec4( + ${T}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, + ${w}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, + ${T}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, + ${w}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 + ); + } + `;break;case"align_corners":N=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 resized = vec4(${T}.0 - 1.0, ${w}.0 - 1.0, ${T}.0 - 1.0, + ${w}.0 - 1.0); + vec4 original = vec4(${P}.0 - 1.0, ${A}.0 - 1.0, ${P}.0 - 1.0, + ${A}.0 - 1.0); + vec4 new_scale = original / resized; + return vec4(coords) * new_scale; + } + `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${p.coordinateTransformMode}'`)}const z=(0,d.getCoordsDataType)(y),$=` + const vec2 inputWH = vec2(${A}.0, ${P}.0); + const vec4 scaleWHWH = vec4(float(${x}), float(${M}), float(${x}), float(${M})); + ${(0,a.unpackFromChannel)()} + ${N} + float getAValue(int x10, int r, int c, int d) { + return getChannel(getA(x10, r, c, d), vec2(c, d)); + } + void main() { + ${z} rc = getOutputCoords(); + + int batch = rc[0]; + int depth = rc[1]; + + // retrieve the 4 coordinates that is used in the 4 packed output values. + ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1); + + // calculate the source index in fraction + vec4 sourceFrac = getSourceFracIndex(coords); + + // get the lower and upper bound of the 4 values that will be packed into one texel. + ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy))); + ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw))); + ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy))); + ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw))); + + bool hasNextRow = rc.w < ${w-1}; + bool hasNextCol = rc.z < ${T-1}; + + // pack x00, x01, x10, x11's top-left corner into one vec4 structure + vec4 topLeft = vec4( + getAValue(batch, depth, x00.x, x00.y), + hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0); + + // pack x00, x01, x10, x11's top-right corner into one vec4 structure + vec4 topRight = vec4( + getAValue(batch, depth, x00.x, x00.w), + hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0); + + // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure + vec4 bottomLeft = vec4( + getAValue(batch, depth, x00.z, x00.y), + hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0); + + // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure + vec4 bottomRight = vec4( + getAValue(batch, depth, x00.z, x00.w), + hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0); + + // calculate the interpolation fraction on u and v direction + vec4 frac = vec4(sourceFrac) - floor(sourceFrac); + vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0)); + + vec4 top = mix(topLeft, topRight, clampFrac.ywyw); + vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw); + vec4 newValue = mix(top, bottom, clampFrac.xxzz); + + ${g.output} = vec4(newValue); + } + `;return Object.assign(Object.assign({},f),{output:{dims:b,type:o[0].type,textureType:u.TextureType.packed},hasMain:!0,shaderSource:$})},l=(r,o)=>{const p=r[0].dims;let g,_=o.scales;if(_.length===0){const y=r[o.scalesInputIdx];if(y&&y.size!==0){if(r[o.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");_=n(y,o.mode,o.isResize)}else{const w=r[o.sizesInputIdx];if(!w||w.size===0)throw new Error("Either scales or sizes MUST be provided as input.");g=Array.from(w.integerData),_=e(g,p,o.mode,o.isResize)}}else if(r[o.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const b=g||p.map((y,w)=>Math.floor(y*_[w]));return[_,b]},n=(r,o,p)=>{const g=Array.from(r.floatData);return(0,h.scalesValidation)(g,o,p),g},e=(r,o,p,g)=>{const _=o.length,b=new Array(_);for(let y=0,w=_;y{Object.defineProperty(t,"__esModule",{value:!0}),t.shape=void 0;const s=i(9162);t.shape=(d,a)=>(u(a),[new s.Tensor([a[0].dims.length],"int32",void 0,void 0,new Int32Array(a[0].dims))]);const u=d=>{if(!d||d.length!==1)throw new Error("Shape requires 1 input.")}},2278:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sliceV10=t.parseSliceAttributes=t.slice=void 0;const s=i(246),u=i(782),d=i(2517),a=i(2039),h={name:"Slice",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};t.slice=(e,r,o)=>(c(r),[e.run(Object.assign(Object.assign({},h),{cacheHint:o.cacheKey,get:()=>f(e,r[0],o)}),r)]),t.parseSliceAttributes=e=>{const r=e.attributes.getInts("starts"),o=e.attributes.getInts("ends"),p=e.attributes.getInts("axes",[]);return(0,s.createAttributeWithCacheKey)({starts:r,ends:o,axes:p})};const f=(e,r,o)=>{const p=o.axes.length===0?r.dims.slice(0).map((S,A)=>A):o.axes,g=d.ShapeUtil.normalizeAxes(p,r.dims.length),_=o.starts.map((S,A)=>S>r.dims[g[A]]-1?r.dims[g[A]]:d.ShapeUtil.normalizeAxis(S,r.dims[g[A]])),b=o.ends.map((S,A)=>S>r.dims[g[A]]-1?r.dims[g[A]]:d.ShapeUtil.normalizeAxis(S,r.dims[g[A]])),y=r.dims.slice(),w=[];for(let S=0;S0&&w.push(`outputIdx[${g[S]}] += ${_[S]};`);const T=` + float process(int outputIdx[${y.length}]) { + ${w.join(` + `)} + return _A(outputIdx); + }`;return Object.assign(Object.assign({},h),{output:{dims:y,type:r.type,textureType:a.TextureType.unpacked},shaderSource:T})},c=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(u.NUMBER_TYPES.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")};t.sliceV10=(e,r)=>{n(r);const o=l(e,r);return[e.run(Object.assign(Object.assign({},h),{cacheHint:o.cacheKey,get:()=>f(e,r[0],o)}),[r[0]])]};const l=(e,r)=>{if(!e.session.isInitializer(r[1].dataId)||!e.session.isInitializer(r[2].dataId)||r.length>=4&&!e.session.isInitializer(r[3].dataId)||r.length>=5&&!e.session.isInitializer(r[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(r.length>=5&&r[4].integerData.some(_=>_!==1))throw new Error("currently non-1 steps is not supported for Slice");const o=Array.from(r[1].integerData),p=Array.from(r[2].integerData),g=r.length>=4?Array.from(r[3].integerData):[];return{starts:o,ends:p,axes:g,cacheKey:`${g};${o};${p}`}},n=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}},5524:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.softmaxV13=t.parseSoftmaxAttributesV13=t.parseSoftmaxAttributes=t.softmax=void 0;const s=i(246),u=i(2517),d=i(5060),a=i(2039),h=i(3738),f={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[a.TextureType.unpacked]},c={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},l={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked,a.TextureType.unpacked]};t.softmax=(g,_,b)=>{p(_);const y=_[0].dims.slice(),w=u.ShapeUtil.normalizeAxis(b.axis,y.length),T=u.ShapeUtil.sizeToDimension(y,w),S=u.ShapeUtil.sizeFromDimension(y,w);return n(g,_,b,T,S)},t.parseSoftmaxAttributes=g=>(0,s.createAttributeWithCacheKey)({axis:g.attributes.getInt("axis",1)}),t.parseSoftmaxAttributesV13=g=>(0,s.createAttributeWithCacheKey)({axis:g.attributes.getInt("axis",-1)}),t.softmaxV13=(g,_,b)=>{p(_);const y=_[0].dims.slice(),w=u.ShapeUtil.normalizeAxis(b.axis,y.length),T=y.length,S=w!==T-1,A=[];let P,x=[],M=[];S&&(x=Array.from({length:T}).map((C,G)=>G),x[w]=T-1,x[T-1]=w,x.map(C=>A.push(y[C])),P=(0,s.createAttributeWithCacheKey)({perm:x}),M=(0,h.transpose)(g,_,P));const N=S?u.ShapeUtil.sizeToDimension(A,T-1):u.ShapeUtil.sizeToDimension(y,T-1),z=S?u.ShapeUtil.sizeFromDimension(A,T-1):u.ShapeUtil.sizeFromDimension(y,T-1),$=n(g,S?M:_,b,N,z);return S?(0,h.transpose)(g,$,P):$};const n=(g,_,b,y,w)=>{const T=e(g,_[0],y,w,[y]),S=g.run(Object.assign(Object.assign({},f),{cacheHint:b.cacheKey,get:()=>T}),_),A=r(g,_[0],y,w,T.output.dims,[y]),P=g.run(Object.assign(Object.assign({},c),{cacheHint:b.cacheKey,get:()=>A}),[_[0],S]),x=o(g,_[0],y,w,T.output.dims,A.output.dims);return[g.run(Object.assign(Object.assign({},l),{cacheHint:b.cacheKey,get:()=>x}),[_[0],S,P])]},e=(g,_,b,y,w)=>{const[T,S]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),A=w.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(w.length!==1)throw new Error("Dimensionality of the output should be 1");if(w[0]!==b)throw new Error("Shape of the output should be equal to logical row count");const P=(0,d.getGlsl)(g.session.backend.glContext.version),x=` + float process(int[${A}] indices) { + int logical_row_start_offset = indices[0] * ${y}; + + float max = getColorAsFloat(${P.texture2D}(A, offsetToCoords(logical_row_start_offset, ${T}, + ${S} ))); + for(int i=1; i<${y}; ++i) + { + float current = getColorAsFloat(${P.texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${T}, ${S}))); + if(current > max) + max = current; + } + + return max; + }`;return Object.assign(Object.assign({},f),{output:{dims:w,type:_.type,textureType:a.TextureType.unpacked},shaderSource:x})},r=(g,_,b,y,w,T)=>{const[S,A]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),P=T.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1)throw new Error("Dimensionality of the output should be 1");if(T[0]!==b)throw new Error("Shape of the output should be equal to logical row count");if(w.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(w[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` + float process(int[${P}] indices) { + int logical_row_start_offset = indices[0] * ${y}; + + float norm_factor = 0.0; + float max = _Max(indices); + for(int i=0; i<${y}; ++i) + { + norm_factor += exp(getColorAsFloat(${(0,d.getGlsl)(g.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${S}, ${A}))) - max); + } + + return norm_factor; + }`;return Object.assign(Object.assign({},c),{output:{dims:T,type:_.type,textureType:a.TextureType.unpacked},shaderSource:x})},o=(g,_,b,y,w,T)=>{const[S,A]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),P=_.dims.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(w.length!==1||T.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(w[0]!==b||T[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` + float process(int[${P}] indices) { + + // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) + int offset = coordsToOffset(TexCoords, ${S}, ${A}); + + //determine the logical row for this index + int logical_row_index[1]; + logical_row_index[0] = offset / ${y}; + + float norm_factor = _Norm(logical_row_index); + + // avoid possible division by 0 + // if norm_facor is 0, all elements are zero + // if so, return 0 + if(norm_factor == 0.0) + return 0.0; + + return exp(_A(indices) - _Max(logical_row_index)) / norm_factor; + }`;return Object.assign(Object.assign({},l),{output:{dims:_.dims,type:_.type,textureType:a.TextureType.unpacked},shaderSource:x})},p=g=>{if(!g||g.length!==1)throw new Error("Softmax requires 1 input.");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type")}},5975:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseSplitAttributes=t.split=void 0;const s=i(246),u=i(2517),d=i(2039),a={name:"Split",inputNames:["A"],inputTypes:[d.TextureType.unpacked]};t.split=(l,n,e)=>{c(n);const r=u.ShapeUtil.normalizeAxis(e.axis,n[0].dims.length),o=h(l,n,r,e),p=[];for(let g=0;gf(l,n[0],e,r,g)}),n));return p},t.parseSplitAttributes=l=>{const n=l.attributes.getInt("axis",0),e=l.attributes.getInts("split",[]),r=l.outputs.length;return(0,s.createAttributeWithCacheKey)({axis:n,split:e,numOutputs:r})};const h=(l,n,e,r)=>{const[,o]=u.SplitUtil.splitShape(n[0].dims,e,r.split,r.numOutputs);return o.length},f=(l,n,e,r,o)=>{const[p,g]=u.SplitUtil.splitShape(n.dims,r,e.split,e.numOutputs),_=g[o],b=p[o],y=` + float process(int indices[${b.length}]) { + indices[${r}] += ${_}; + return _A(indices); + } + `;return Object.assign(Object.assign({},a),{cacheHint:`${e.cacheKey}:${o}`,output:{dims:b,type:n.type,textureType:d.TextureType.unpacked},shaderSource:y})},c=l=>{if(!l||l.length!==1)throw new Error("Split requires one input.");if(l[0].type!=="int8"&&l[0].type!=="uint8"&&l[0].type!=="int16"&&l[0].type!=="uint16"&&l[0].type!=="int32"&&l[0].type!=="uint32"&&l[0].type!=="float32"&&l[0].type!=="float64"&&l[0].type!=="bool")throw new Error("Invalid input type.")}},3933:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseSqueezeAttributes=t.squeezeV13=t.squeeze=void 0;const s=i(2517);t.squeeze=(a,h,f)=>{u(h);const c=s.ShapeUtil.squeezeShape(h[0].dims,f);return[a.reshapeUnpacked(h[0],c)]},t.squeezeV13=(a,h)=>(d(h),(0,t.squeeze)(a,[h[0]],Array.from(h[1].integerData))),t.parseSqueezeAttributes=a=>a.attributes.getInts("axes");const u=a=>{if(!a||a.length!==1)throw new Error("Squeeze requires 1 input.");if(a[0].type==="string")throw new Error("invalid input tensor types.")},d=a=>{if(!a||a.length!==2)throw new Error("Squeeze requires 2 inputs.");if(a[1].type!=="int32")throw new Error("Invalid input type.")}},6558:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sum=void 0;const s=i(5060),u=i(2039);t.sum=(h,f)=>{a(f);const c={name:"Sum",inputNames:f.map((l,n)=>`X${n}`),inputTypes:new Array(f.length).fill(u.TextureType.unpacked)};return[h.run(Object.assign(Object.assign({},c),{get:()=>d(h,f,c)}),f)]};const d=(h,f,c)=>{const l=(0,s.getGlsl)(h.session.backend.glContext.version),n=f[0].dims.slice(),e=` + void main() { + vec4 result = ${f.map((r,o)=>`${l.texture2D}(X${o},TexCoords)`).join(" + ")}; + ${l.output} = result; + } + `;return Object.assign(Object.assign({},c),{output:{dims:n,type:f[0].type,textureType:u.TextureType.unpacked},hasMain:!0,shaderSource:e})},a=h=>{if(!h||h.length===0)throw new Error("Sum requires inputs.");const f=h[0].dims.length;for(let c=1;c{Object.defineProperty(t,"__esModule",{value:!0}),t.tile=void 0;const s=i(782),u=i(2039);t.tile=(h,f)=>{a(f);const c={name:"Tile",inputNames:["A"],inputTypes:[u.TextureType.unpacked]};return[h.run(Object.assign(Object.assign({},c),{get:()=>d(h,f,c)}),f)]};const d=(h,f,c)=>{const l=f[0].dims.slice(),n=new Array(l.length),e=[];for(let p=0;p{if(!h||h.length!==2)throw new Error("Tile requires 2 input.");if(h[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(h[1].dims[0]!==h[0].dims.length)throw new Error("Invalid input shape.");if(s.NUMBER_TYPES.indexOf(h[0].type)===-1)throw new Error("Invalid input type.");if(h[1].type!=="int32"&&h[1].type!=="int16")throw new Error("Invalid repeat type.")}},3738:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseTransposeAttributes=t.transpose=void 0;const s=i(246),u=i(2517),d=i(2039),a={name:"Transpose",inputNames:["A"],inputTypes:[d.TextureType.unpacked]};t.transpose=(e,r,o)=>(n(r),[e.run(Object.assign(Object.assign({},a),{cacheHint:o.cacheKey,get:()=>h(e,r[0],o.perm)}),r)]),t.parseTransposeAttributes=e=>(0,s.createAttributeWithCacheKey)({perm:e.attributes.getInts("perm",[])});const h=(e,r,o)=>{const p=r.dims;o=f(p,o);const g=c(p,o),_=p.length,b=` + ${l("perm",o,_)} + float process(int indices[${_}]) { + int a[${_}]; + perm(a, indices); + return _A(a); + }`;return Object.assign(Object.assign({},a),{output:{dims:g,type:r.type,textureType:d.TextureType.unpacked},shaderSource:b})},f=(e,r)=>(r&&r.length!==e.length&&(r=[...e.keys()].reverse()),r),c=(e,r)=>(r=f(e,r),u.ShapeUtil.sortBasedOnPerm(e,r)),l=(e,r,o)=>{const p=[];p.push(`void ${e}(out int a[${o}], int src[${o}]) {`);for(let g=0;g{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}},8710:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeAsUint8=void 0;const s=i(5060),u=i(2039);t.encodeAsUint8=(d,a)=>{const h=a.shape,f=(0,s.getGlsl)(d.session.backend.glContext.version),c=` + const float FLOAT_MAX = 1.70141184e38; + const float FLOAT_MIN = 1.17549435e-38; + + bool isNaN(float val) { + return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true; + } + + highp vec4 encodeAsUint8(highp float v) { + if (isNaN(v)) { + return vec4(255, 255, 255, 255); + } + + highp float av = abs(v); + + if(av < FLOAT_MIN) { + return vec4(0.0, 0.0, 0.0, 0.0); + } else if(v > FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; + } else if(v < -FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; + } + + highp vec4 c = vec4(0,0,0,0); + + highp float e = floor(log2(av)); + highp float m = exp2(fract(log2(av))) - 1.0; + + c[2] = floor(128.0 * m); + m -= c[2] / 128.0; + c[1] = floor(32768.0 * m); + m -= c[1] / 32768.0; + c[0] = floor(8388608.0 * m); + + highp float ebias = e + 127.0; + c[3] = floor(ebias / 2.0); + ebias -= c[3] * 2.0; + c[2] += floor(ebias) * 128.0; + + c[3] += 128.0 * step(0.0, -v); + + return c / 255.0; + } + + void main() { + float value = ${f.texture2D}(X,TexCoords).r; + ${f.output} = encodeAsUint8(value); + }`,l={name:"Uint8Encode",inputTypes:[u.TextureType.unpacked],inputNames:["X"],output:{dims:h,type:a.tensor.type,textureType:u.TextureType.downloadUint8AsFloat},shaderSource:c,hasMain:!0};return d.executeProgram(l,[a.tensor])}},4909:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tanh=t.tan=t.sqrt=t.sin=t.sigmoid=t.relu=t.not=t.neg=t.log=t.parseLeakyReluAttributes=t.leakyRelu=t.identity=t.floor=t.exp=t.parseEluAttributes=t.elu=t.cos=t.ceil=t.clipV11=t.parseClipAttributes=t.clip=t.atan=t.asin=t.acos=t.abs=t.glslTanh=t.glslTan=t.glslSqrt=t.glslSigmoid=t.glslRelu=t.glslSin=t.glslNot=t.glslNeg=t.glslLog=t.glslLeakyRelu=t.glslIdentity=t.glslClip=t.glslFloor=t.glslExp=t.glslElu=t.glslCos=t.glslCeil=t.glslAtan=t.glslAsin=t.glslAcos=t.glslAbs=void 0;const s=i(246),u=i(2517),d=i(8520),a=i(5060),h=i(2039);function f(){return $("abs")}function c(){return $("acos")}function l(){return $("asin")}function n(){return $("atan")}function e(){return $("ceil")}function r(){return $("cos")}function o(D){const R="elu";return{body:` + const float alpha = float(${D}); + + float ${R}_(float a) { + return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; + } + vec4 ${R}_(vec4 v) { + return vec4(${R}_(v.x), ${R}_(v.y), ${R}_(v.z), ${R}_(v.w)); + } + `,name:R,type:d.FunctionType.ValueBased}}function p(){return $("exp")}function g(){return $("floor")}function _(D,R){const Y="clip";return{body:` + const float min = float(${D}); + const float max = float(${R}); + + float ${Y}_(float a) { + return clamp(a, min, max); + } + vec4 ${Y}_(vec4 v) { + return clamp(v, min, max); + } + `,name:Y,type:d.FunctionType.ValueBased}}function b(){const D="indentity";return{body:` + float ${D}_(float a) { + return a; + } + vec4 ${D}_(vec4 v) { + return v; + } + `,name:D,type:d.FunctionType.ValueBased}}function y(D){const R="leakyRelu";return{body:` + const float alpha = float(${D}); + + float ${R}_(float a) { + return a < 0.0 ? a * alpha : a; + } + vec4 ${R}_(vec4 v) { + return vec4(${R}_(v.x), ${R}_(v.y), ${R}_(v.z), ${R}_(v.w)); + } + `,name:R,type:d.FunctionType.ValueBased}}function w(){return $("log")}function T(){const D="neg";return{body:` + float ${D}_(float a) { + return -a; + } + vec4 ${D}_(vec4 v) { + return -v; + } + `,name:D,type:d.FunctionType.ValueBased}}function S(){const D="not";return{body:` + float ${D}_(float a) { + return float( ! bool(a) ); + } + bool ${D}_(bool a) { + return !a; + } + vec4 ${D}_(vec4 v) { + return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w)); + } + bvec4 ${D}_(bvec4 v) { + return bvec4(!v.x, !v.y, !v.z, !v.w); + } + `,name:D,type:d.FunctionType.ValueBased}}function A(){return $("sin")}function P(){const D="relu";return{body:` + float ${D}_(float a) { + return max( a, 0.0 ); + } + vec4 ${D}_(vec4 v) { + return max( v, 0.0 ); + } + `,name:D,type:d.FunctionType.ValueBased}}function x(){const D="sigmoid";return{body:` + float ${D}_(float a) { + return 1.0 / (1.0 + exp(-a)); + } + vec4 ${D}_(vec4 v) { + return 1.0 / (1.0 + exp(-v)); + } + `,name:D,type:d.FunctionType.ValueBased}}function M(){return $("sqrt")}function N(){return $("tan")}function z(){const D="tanh";return{body:` + float ${D}_(float a) { + a = clamp(a, -10., 10.); + a = exp(2.*a); + return (a - 1.) / (a + 1.); + } + vec4 ${D}_(vec4 v) { + v = clamp(v, -10., 10.); + v = exp(2.*v); + return (v - 1.) / (v + 1.); + } + `,name:D,type:d.FunctionType.ValueBased}}function $(D){return{body:` + float ${D}_(float a) { + return ${D}(a); + } + vec4 ${D}_(vec4 v) { + return ${D}(v); + } + `,name:D,type:d.FunctionType.ValueBased}}t.glslAbs=f,t.glslAcos=c,t.glslAsin=l,t.glslAtan=n,t.glslCeil=e,t.glslCos=r,t.glslElu=o,t.glslExp=p,t.glslFloor=g,t.glslClip=_,t.glslIdentity=b,t.glslLeakyRelu=y,t.glslLog=w,t.glslNeg=T,t.glslNot=S,t.glslSin=A,t.glslRelu=P,t.glslSigmoid=x,t.glslSqrt=M,t.glslTan=N,t.glslTanh=z;const C=(D,R,Y,V)=>{const J=D.session.pack?h.TextureType.packed:h.TextureType.unpacked,Z={name:Y.name,inputTypes:[J],inputNames:["A"],cacheHint:V};return Object.assign(Object.assign({},Z),{get:()=>((ue,Ae,xe,se)=>{const we=ue.session.pack?h.TextureType.packed:h.TextureType.unpacked,be=(0,a.getGlsl)(ue.session.backend.glContext.version);return Object.assign(Object.assign({},Ae),{output:{dims:xe.dims,type:xe.type,textureType:we},shaderSource:` + ${se.body} + void main() { + vec4 v = ${be.texture2D}(A, TexCoords); + v = ${se.name}_(v); + ${be.output} = v; + } + `,hasMain:!0})})(D,Z,R,Y)})};t.abs=(D,R)=>[D.run(C(D,R[0],f()),R)],t.acos=(D,R)=>[D.run(C(D,R[0],c()),R)],t.asin=(D,R)=>[D.run(C(D,R[0],l()),R)],t.atan=(D,R)=>[D.run(C(D,R[0],n()),R)],t.clip=(D,R,Y)=>[D.run(C(D,R[0],_(Y.min,Y.max),Y.cacheKey),R)],t.parseClipAttributes=D=>(0,s.createAttributeWithCacheKey)({min:D.attributes.getFloat("min",u.MIN_CLIP),max:D.attributes.getFloat("max",u.MAX_CLIP)}),t.clipV11=(D,R)=>{const Y=G(D,R);return(0,t.clip)(D,[R[0]],Y)};const G=(D,R)=>{if(R.length>=3&&(!D.session.isInitializer(R[1].dataId)||!D.session.isInitializer(R[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const Y=R.length>=3?R[1].numberData[0]:u.MIN_CLIP,V=R.length>=3?R[2].numberData[0]:u.MAX_CLIP;return(0,s.createAttributeWithCacheKey)({min:Y,max:V})};t.ceil=(D,R)=>[D.run(C(D,R[0],e()),R)],t.cos=(D,R)=>[D.run(C(D,R[0],r()),R)],t.elu=(D,R,Y)=>[D.run(C(D,R[0],o(Y.alpha),Y.cacheKey),R)],t.parseEluAttributes=D=>(0,s.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",1)}),t.exp=(D,R)=>[D.run(C(D,R[0],p()),R)],t.floor=(D,R)=>[D.run(C(D,R[0],g()),R)],t.identity=(D,R)=>[D.run(C(D,R[0],b()),R)],t.leakyRelu=(D,R,Y)=>[D.run(C(D,R[0],y(Y.alpha),Y.cacheKey),R)],t.parseLeakyReluAttributes=D=>(0,s.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",.01)}),t.log=(D,R)=>[D.run(C(D,R[0],w()),R)],t.neg=(D,R)=>[D.run(C(D,R[0],T()),R)],t.not=(D,R)=>[D.run(C(D,R[0],S()),R)],t.relu=(D,R)=>[D.run(C(D,R[0],P()),R)],t.sigmoid=(D,R)=>[D.run(C(D,R[0],x()),R)],t.sin=(D,R)=>[D.run(C(D,R[0],A()),R)],t.sqrt=(D,R)=>[D.run(C(D,R[0],M()),R)],t.tan=(D,R)=>[D.run(C(D,R[0],N()),R)],t.tanh=(D,R)=>[D.run(C(D,R[0],z()),R)]},5611:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackProgramInfoLoader=t.createUnpackProgramInfo=void 0;const s=i(5060),u=i(2039),d=i(9390),a=i(2827),h={name:"unpack",inputNames:["A"],inputTypes:[u.TextureType.packed]};t.createUnpackProgramInfo=(f,c)=>{const l=c.dims.length,n=(0,a.getChannels)("rc",l),e=n.slice(-2),r=(0,d.getCoordsDataType)(l),o=(0,a.unpackFromChannel)(),p=c.dims.length===0?"":function(b,y){if(b===1)return"rc";let w="";for(let T=0;TObject.assign(Object.assign({},h),{get:()=>(0,t.createUnpackProgramInfo)(f,c)})},8428:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnsqueezeAttributes=t.unsqueezeV13=t.unsqueeze=void 0;const s=i(2517);t.unsqueeze=(a,h,f)=>{u(h);const c=s.ShapeUtil.unsqueezeShape(h[0].dims,f);return[a.reshapeUnpacked(h[0],c)]},t.unsqueezeV13=(a,h)=>(d(h),(0,t.unsqueeze)(a,[h[0]],Array.from(h[1].integerData))),t.parseUnsqueezeAttributes=a=>a.attributes.getInts("axes");const u=a=>{if(!a||a.length!==1)throw new Error("Unsqueeze requires 1 input.");if(a[0].type==="string")throw new Error("invalid input tensor types.")},d=a=>{if(!a||a.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(a[1].type!=="int32")throw new Error("Invalid input type.")}},9793:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scalesValidation=t.validateInputs=t.parseUpsampleAttributes=t.parseUpsampleAttributesV9=t.parseUpsampleAttributesV7=t.upsample=void 0;const s=i(246),u=i(5060),d=i(2039),a={name:"Upsample",inputNames:["X"],inputTypes:[d.TextureType.unpacked]};t.upsample=(f,c,l)=>((0,t.validateInputs)(c,l),[f.run(Object.assign(Object.assign({},a),{cacheHint:l.cacheKey,get:()=>h(f,c,l)}),c)]),t.parseUpsampleAttributesV7=f=>(0,t.parseUpsampleAttributes)(f,7),t.parseUpsampleAttributesV9=f=>(0,t.parseUpsampleAttributes)(f,9),t.parseUpsampleAttributes=(f,c)=>{const l=c>=10,n=f.attributes.getString("mode","nearest");if(n!=="nearest"&&n!=="linear"&&(c<11||n!=="cubic"))throw new Error(`unrecognized mode: ${n}`);let e=[];c<9&&(e=f.attributes.getFloats("scales"),(0,t.scalesValidation)(e,n,l));const r=f.attributes.getFloat("extrapolation_value",0),o=c>10?f.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(o)===-1)throw new Error(`coordinate_transform_mode '${o}' is not supported`);const p=o==="tf_crop_and_resize",g=p,_=n==="nearest"&&c>=11?f.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(_)===-1)throw new Error(`nearest_mode '${_}' is not supported`);const b=f.attributes.getFloat("cubic_coeff_a",-.75),y=f.attributes.getInt("exclude_outside",0)!==0;if(y&&n!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const w=c<11||n==="nearest"&&o==="asymmetric"&&_==="floor";let T=0,S=0,A=0;return c>10?f.inputs.length>2?(T=1,S=2,A=3):(S=1,A=2):c===9&&(S=1),(0,s.createAttributeWithCacheKey)({opset:c,isResize:l,mode:n,scales:e,extrapolationValue:r,coordinateTransformMode:o,useExtrapolation:g,needRoiInput:p,nearestMode:_,cubicCoefficientA:b,excludeOutside:y,useNearest2xOptimization:w,roiInputIdx:T,scalesInputIdx:S,sizesInputIdx:A})};const h=(f,c,l)=>{const n=(0,u.getGlsl)(f.session.backend.glContext.version),[e,r]=f.calculateTextureWidthAndHeight(c[0].dims,d.TextureType.unpacked),o=c[0].dims.map((A,P)=>Math.floor(A*l.scales[P])),[p,g]=f.calculateTextureWidthAndHeight(o,d.TextureType.unpacked),_=o.length,b=new Array(_),y=new Array(_);let w=` + int output_pitches[${_}]; + int input_pitches[${_}]; + `;for(let A=_-1;A>=0;A--)b[A]=A===_-1?1:b[A+1]*o[A+1],y[A]=A===_-1?1:y[A+1]*c[0].dims[A+1],w+=` + output_pitches[${A}] = ${b[A]}; + input_pitches[${A}] = ${y[A]}; + `;const T=` + float getInputFloat(int index) { + vec2 coords = offsetToCoords(index, ${e}, ${r}); + float value = getColorAsFloat(${n.texture2D}(X, coords)); + return value; + } + `,S=l.mode==="nearest"?` + ${T} + float process(int indices[${_}]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${p}, ${g}); + + ${w} + + int d, m; + for (int dim = 0; dim < ${_}; ++dim) { + d = output_index / output_pitches[dim]; + m = output_index - d * output_pitches[dim]; + output_index = m; + + if (scales[dim] != 1 && d > 0) { + int d2 = d / scales[dim]; + m = d - d2 * scales[dim]; + d = d2; + } + input_index += input_pitches[dim] * d; + } + + return getInputFloat(input_index); + }`:_===4?` + ${T} + float process(int indices[4]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${p}, ${g}); + + ${w} + + int m; + int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m / output_pitches[1]; + m = m - index_of_dim1 * output_pitches[1]; + index_of_dim2 = m / output_pitches[2]; + m = m - index_of_dim2 * output_pitches[2]; + index_of_dim3 = m; + + int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset; + index_of_input_dim2 = index_of_dim2 / scales[2]; + y_offset = index_of_dim2 - index_of_input_dim2 * scales[2]; + index_of_input_dim3 = index_of_dim3 / scales[3]; + x_offset = index_of_dim3 - index_of_input_dim3 * scales[3]; + + input_index = index_of_dim0 * input_pitches[0] + + index_of_dim1 * input_pitches[1] + + index_of_input_dim2 * input_pitches[2] + + index_of_input_dim3; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim2 = false; + if (index_of_input_dim2 == (${c[0].dims[2]} - 1)) { + // It's the end in dimension 2 + x01 = x00; + end_of_dim2 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[2]); + } + + if (index_of_input_dim3 == (input_pitches[2] - 1)) { + // It's the end in dimension 3 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[3]); + }`:` + ${T} + float process(int indices[2]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${p}, ${g}); + + ${w} + + int m; + int index_of_dim0, index_of_dim1; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m; + + int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset; + index_of_input_dim0 = index_of_dim0 / scales[0]; + y_offset = index_of_dim0 - index_of_input_dim0 * scales[0]; + index_of_input_dim1 = index_of_dim1 / scales[1]; + x_offset = index_of_dim1 - index_of_input_dim1 * scales[1]; + + input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim0 = false; + if (index_of_input_dim0 == (${c[0].dims[0]} - 1)) { + // It's the end in dimension 0 + x01 = x00; + end_of_dim0 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[0]); + } + + if (index_of_input_dim1 == (input_pitches[0] - 1)) { + // It's the end in dimension 1 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[1]); + }`;return Object.assign(Object.assign({},a),{output:{dims:o,type:c[0].type,textureType:d.TextureType.unpacked},shaderSource:S,variables:[{name:"scales",type:"int",arrayLength:l.scales.length,data:l.scales.map(A=>Math.ceil(A))}]})};t.validateInputs=(f,c)=>{if(!f||c.opset<9&&f.length!==1||c.opset>=9&&c.opset<11&&f.length!==2||c.opset>=11&&f.length<2)throw new Error("invalid inputs.");if(c.scales.length>0&&f[0].dims.length!==c.scales.length)throw new Error("Invalid input shape.");if(f[0].type==="string")throw new Error("Invalid input tensor types.")},t.scalesValidation=(f,c,l)=>{if(l){for(const n of f)if(n<=0)throw new Error("Scale value should be greater than 0.")}else for(const n of f)if(n<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(c!=="linear"&&c!=="cubic"||f.length===2||f.length===4&&f[0]===1&&f[1]===1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic') or 4-D inputs with the corresponding outermost 2 scale values being 1 in the ${l?"Resize":"Upsample"} opeartor.`)}},1958:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProgramManager=void 0;const s=i(1670),u=i(6231),d=i(8879),a=i(5060);t.ProgramManager=class{constructor(h,f,c){this.profiler=h,this.glContext=f,this.textureLayoutStrategy=c,this.repo=new Map,this.attributesBound=!1}getArtifact(h){return this.repo.get(h)}setArtifact(h,f){this.repo.set(h,f)}run(h,f,c){var l;this.profiler.event("op",`ProgramManager.run ${(l=h.programInfo.name)!==null&&l!==void 0?l:"unknown kernel"}`,()=>{var n;const e=this.glContext.gl,r=h.program;e.useProgram(r);try{this.bindOutput(c),this.attributesBound||this.bindAttributes(h.attribLocations),this.bindUniforms(h.uniformLocations,(n=h.programInfo.variables)!==null&&n!==void 0?n:[],f)}catch(o){throw u.Logger.error("ProgramManager",h.programInfo.shaderSource),o}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(h=>this.glContext.deleteProgram(h.program))}build(h,f,c){return this.profiler.event("backend","ProgramManager.build",()=>{const l=new d.GlslPreprocessor(this.glContext,h,f,c),n=l.preprocess(),e=this.compile(n);return{programInfo:h,program:e,uniformLocations:this.getUniformLocations(e,l.context.programInfo.inputNames,l.context.programInfo.variables),attribLocations:this.getAttribLocations(e)}})}compile(h){if(!this.vertexShader){u.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const l=(0,a.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(l,this.glContext.gl.VERTEX_SHADER)}s.env.debug&&u.Logger.verbose("ProrgramManager",`FragShader: +${h} +`);const f=this.glContext.compileShader(h,this.glContext.gl.FRAGMENT_SHADER),c=this.glContext.createProgram(this.vertexShader,f);return this.glContext.deleteShader(f),c}bindOutput(h){const f=h.width,c=h.height;u.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${f}/${c}, shape=${h.shape}, type=${h.tensor.type}`),this.glContext.attachFramebuffer(h.texture,f,c)}bindAttributes(h){const f=h.position,c=h.textureCoord;this.glContext.setVertexAttributes(f,c),this.attributesBound=!0}bindUniforms(h,f,c){var l;const n=this.glContext.gl;let e=0;for(const{name:r,type:o,location:p,arrayLength:g}of h){const _=(l=f.find(b=>b.name===r))===null||l===void 0?void 0:l.data;if(o!=="sampler2D"&&!_)throw new Error(`variable '${r}' does not have data defined in program info`);switch(o){case"sampler2D":this.bindTexture(c[e],p,e),e++;break;case"float":g?n.uniform1fv(p,_):n.uniform1f(p,_);break;case"int":g?n.uniform1iv(p,_):n.uniform1i(p,_);break;default:throw new Error(`Uniform not implemented: ${o}`)}}}bindTexture(h,f,c){this.glContext.bindTextureToUniform(h.texture,c,f)}getAttribLocations(h){return{position:this.getAttribLocation(h,"position"),textureCoord:this.getAttribLocation(h,"textureCoord")}}getUniformLocations(h,f,c){const l=[];if(f)for(const n of f)l.push({name:n,type:"sampler2D",location:this.getUniformLocation(h,n)});if(c)for(const n of c)l.push(Object.assign(Object.assign({},n),{location:this.getUniformLocation(h,n.name)}));return l}getUniformLocation(h,f){const c=this.glContext.gl.getUniformLocation(h,f);if(c===null)throw new Error(`Uniform ${f} not found.`);return c}getAttribLocation(h,f){return this.glContext.gl.getAttribLocation(h,f)}}},6416:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLSessionHandler=void 0;const s=i(6231),u=i(1047),d=i(8316),a=i(1640),h=i(1958),f=i(7859),c=i(5702);t.WebGLSessionHandler=class{constructor(l,n){this.backend=l,this.context=n,this.layoutStrategy=new f.PreferLogicalStrategy(l.glContext.maxTextureSize),this.programManager=new h.ProgramManager(this.context.profiler,l.glContext,this.layoutStrategy),this.textureManager=new c.TextureManager(l.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:l.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=l.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new d.WebGLInferenceHandler(this)}onGraphInitialized(l){const n=l.getValues().filter(e=>e.from===-1&&e.tensor).map(e=>e.tensor.dataId);this.initializers=new Set(n)}isInitializer(l){return!!this.initializers&&this.initializers.has(l)}addInitializer(l){this.initializers.add(l)}getTextureData(l,n){return n?this.packedTextureDataCache.get(l):this.unpackedTextureDataCache.get(l)}setTextureData(l,n,e=!1){s.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),e?this.packedTextureDataCache.set(l,n):this.unpackedTextureDataCache.set(l,n)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(l=>this.textureManager.releaseTexture(l,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(l=>this.textureManager.releaseTexture(l,!0)),this.unpackedTextureDataCache=new Map}resolve(l,n,e){const r=(0,u.resolveOperator)(l,n,a.WEBGL_OP_RESOLVE_RULES);return{impl:r.opImpl,context:r.opInit?r.opInit(l,e):l}}}},7769:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Uint8DataEncoder=t.RGBAFloatDataEncoder=t.RedFloat32DataEncoder=void 0;const s=i(6231);t.RedFloat32DataEncoder=class{constructor(u,d=1){if(d===1)this.internalFormat=u.R32F,this.format=u.RED,this.textureType=u.FLOAT,this.channelSize=d;else{if(d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=u.RGBA32F,this.format=u.RGBA,this.textureType=u.FLOAT,this.channelSize=d}}encode(u,d){let a,h;return u.constructor!==Float32Array&&(s.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),h=new Float32Array(u)),d*this.channelSize>u.length?(s.Logger.warning("Encoder","Source data too small. Allocating larger array"),h=u,a=this.allocate(d*this.channelSize),h.forEach((f,c)=>a[c]=f)):(h=u,a=h),a}allocate(u){return new Float32Array(4*u)}decode(u,d){return this.channelSize===1?u.filter((a,h)=>h%4==0).subarray(0,d):u.subarray(0,d)}},t.RGBAFloatDataEncoder=class{constructor(u,d=1,a){if(d!==1&&d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=u.RGBA,this.format=u.RGBA,this.channelSize=d,this.textureType=a||u.FLOAT}encode(u,d){let a=u;return this.channelSize===1&&(s.Logger.verbose("Encoder","Exploding into a larger array"),a=this.allocate(d),u.forEach((h,f)=>a[4*f]=h)),a}allocate(u){return new Float32Array(4*u)}decode(u,d){return this.channelSize===1?u.filter((a,h)=>h%4==0).subarray(0,d):u.subarray(0,d)}},t.Uint8DataEncoder=class{constructor(u,d=1){if(this.channelSize=4,d===1)this.internalFormat=u.ALPHA,this.format=u.ALPHA,this.textureType=u.UNSIGNED_BYTE,this.channelSize=d;else{if(d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=u.RGBA,this.format=u.RGBA,this.textureType=u.UNSIGNED_BYTE,this.channelSize=d}}encode(u,d){return new Uint8Array(u.buffer,u.byteOffset,u.byteLength)}allocate(u){return new Uint8Array(u*this.channelSize)}decode(u,d){if(u instanceof Uint8Array)return u.subarray(0,d);throw new Error(`Invalid array type: ${u.constructor}`)}}},7859:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getBatchDim=t.sizeToSquarishShape=t.getRowsCols=t.sizeFromShape=t.isInt=t.parseAxisParam=t.squeezeShape=t.PreferLogicalStrategy=t.AlwaysKeepOriginalSizeStrategy=void 0;const s=i(6231),u=i(2517);function d(l,n){const e=[],r=[],o=n!=null&&Array.isArray(n)&&n.length===0,p=n==null||o?null:a(n,l).sort();let g=0;for(let _=0;__)&&l[_]===1&&(e.push(l[_]),r.push(_)),p[g]<=_&&g++}l[_]!==1&&(e.push(l[_]),r.push(_))}return{newShape:e,keptDims:r}}function a(l,n){const e=n.length;return l=l==null?n.map((r,o)=>o):[].concat(l),(0,u.assert)(l.every(r=>r>=-e&&r`All values in axis param must be in range [-${e}, ${e}) but got axis ${l}`),(0,u.assert)(l.every(h),()=>`All values in axis param must be integers but got axis ${l}`),l.map(r=>r<0?e+r:r)}function h(l){return l%1==0}function f(l){if(l.length===0)return 1;let n=l[0];for(let e=1;e=l.length?1:l.slice(n.breakAxis).reduce((_,b)=>_*b),g=n.breakAxis<=0?1:l.slice(0,n.breakAxis).reduce((_,b)=>_*b);if(!(p>e||g>e))return[p,g];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${l}, breakAxis:${n.breakAxis}`)}const r=l.reduce((p,g)=>p*g);let o=Math.floor(Math.sqrt(r));for(;o=e||r%o!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${l}`);return[o,r/o]}},t.PreferLogicalStrategy=class{constructor(l){this.maxTextureSize=l}computeTextureWH(l,n){const e=this.computeTexture(l,n);return n&&n.isPacked&&(e[0]/=2,e[1]/=2),n&&n.reverseWH?[e[1],e[0]]:e}computeTexture(l,n){const e=n&&n.isPacked;if(l.length===0)return e?[2,2]:[1,1];let r=this.maxTextureSize;if(n&&n.breakAxis!==void 0){const g=n.breakAxis>=l.length?1:l.slice(n.breakAxis).reduce((b,y)=>b*y),_=n.breakAxis<=0?1:l.slice(0,n.breakAxis).reduce((b,y)=>b*y);if(!(g>r||_>r))return[g,_];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${l}, breakAxis:${n.breakAxis}`)}let o=l.slice(0);e&&(r*=2,o=o.map((g,_)=>_>=o.length-2?o[_]%2==0?o[_]:o[_]+1:o[_]),o.length===1&&(o=[2,o[0]])),o.length!==2&&(o=d(o).newShape);const p=f(o);return o.length<=1&&p<=r?[1,p]:o.length===2&&o[0]<=r&&o[1]<=r?o:o.length===3&&o[0]*o[1]<=r&&o[2]<=r?[o[0]*o[1],o[2]]:o.length===3&&o[0]<=r&&o[1]*o[2]<=r?[o[0],o[1]*o[2]]:o.length===4&&o[0]*o[1]*o[2]<=r&&o[3]<=r?[o[0]*o[1]*o[2],o[3]]:o.length===4&&o[0]<=r&&o[1]*o[2]*o[3]<=r?[o[0],o[1]*o[2]*o[3]]:e?c(p/4).map(g=>2*g):c(p)}},t.squeezeShape=d,t.parseAxisParam=a,t.isInt=h,t.sizeFromShape=f,t.getRowsCols=function(l){if(l.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[l.length>1?l[l.length-2]:1,l[l.length-1]]},t.sizeToSquarishShape=c,t.getBatchDim=function(l,n=2){return f(l.slice(0,l.length-n))}},4057:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createTextureLayoutFromShape=t.calculateTextureWidthAndHeight=t.createTextureLayoutFromTextureType=void 0;const s=i(2517),u=i(2039);t.createTextureLayoutFromTextureType=(d,a,h)=>{const f=h===u.TextureType.unpacked||h===u.TextureType.unpackedReversed?1:4,c=h===u.TextureType.packed,l=h===u.TextureType.unpackedReversed||h===u.TextureType.packed,n=h===u.TextureType.packedLastDimension?a.length-1:void 0,e=h===u.TextureType.packedLastDimension?a.map((r,o)=>o===a.length-1?4*r:r):void 0;return(0,t.createTextureLayoutFromShape)(d,a,f,e,{isPacked:c,reverseWH:l,breakAxis:n})},t.calculateTextureWidthAndHeight=(d,a,h)=>{const f=(0,t.createTextureLayoutFromTextureType)(d,a,h);return[f.width,f.height]},t.createTextureLayoutFromShape=(d,a,h=1,f,c)=>{const l=!(!c||!c.isPacked),[n,e]=d.computeTextureWH(l&&f||a,c),r=a.length;let o=a.slice(0);if(r===0&&(o=[1]),h===1)f=a;else if(l){if(h!==4)throw new Error("a packed texture must be 4-channel");f=a,r>0&&(o[r-1]=Math.ceil(o[r-1]/2)),r>1&&(o[r-2]=Math.ceil(o[r-2]/2))}else if(!f)throw new Error("Unpacked shape is needed when using channels > 1");return{width:n,height:e,channels:h,isPacked:l,shape:o,strides:s.ShapeUtil.computeStrides(o),unpackedShape:f,reversedWH:c&&c.reverseWH}}},5702:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextureManager=void 0;const s=i(6231);t.TextureManager=class{constructor(u,d,a,h){this.glContext=u,this.layoutStrategy=d,this.profiler=a,this.config=h,this.pendingRead=new Map,h.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(u,d,a,h){const f=this.toEncoderType(u),c=this.glContext.getEncoder(f,d.channels||1,h);if(d.isPacked&&h===1)throw new Error("not implemented");const l=d.width,n=d.height;let e,r;if(this.config.reuseTextures){e=`${l}x${n}_${c.format}_${c.internalFormat}_${c.textureType}`,r=this.inUseTextures.get(e),r||(r=[],this.inUseTextures.set(e,r));const p=this.idleTextures.get(e);if(p&&p.length>0){const g=p.pop();return r.push(g),h===1&&this.glContext.updateTexture(g,l,n,c,this.toTextureData(u,a)),g}}s.Logger.verbose("TextureManager",`Creating new texture of size ${d.width}x${d.height}`);const o=this.glContext.allocateTexture(l,n,c,this.toTextureData(u,a));return this.config.reuseTextures&&(r.push(o),this.textureLookup.set(o,e)),o}readTexture(u,d,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const h=u.shape.reduce((c,l)=>c*l)*a,f=this.glContext.readTexture(u.texture,u.width,u.height,h,this.toEncoderType(d),a);return this.toTensorData(d,f)})}async readTextureAsync(u,d,a){const h=u.tensor.dataId;if(a||(a=1),this.pendingRead.has(h)){const f=this.pendingRead.get(h);return new Promise(c=>f==null?void 0:f.push(c))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(h,[]);const f=u.shape.reduce((e,r)=>e*r)*a;await this.glContext.createAndWaitForFence();const c=this.glContext.readTexture(u.texture,u.width,u.height,f,this.toEncoderType(d),a),l=this.toTensorData(d,c),n=this.pendingRead.get(h);return this.pendingRead.delete(h),n==null||n.forEach(e=>e(l)),l})}readUint8TextureAsFloat(u){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const d=u.shape.reduce((h,f)=>h*f),a=this.glContext.readTexture(u.texture,u.width,u.height,4*d,"byte",4);return new Float32Array(a.buffer,a.byteOffset,d)})}releaseTexture(u,d){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(u.texture),a)){d&&this.textureLookup.delete(a);const h=this.inUseTextures.get(a);if(h){const f=h.indexOf(u.texture);if(f!==-1){h.splice(f,1);let c=this.idleTextures.get(a);c||(c=[],this.idleTextures.set(a,c)),c.push(u.texture)}}}a&&!d||(s.Logger.verbose("TextureManager",`Deleting texture of size ${u.width}x${u.height}`),this.glContext.deleteTexture(u.texture))}toTensorData(u,d){switch(u){case"int16":return d instanceof Int16Array?d:Int16Array.from(d);case"int32":return d instanceof Int32Array?d:Int32Array.from(d);case"int8":return d instanceof Int8Array?d:Int8Array.from(d);case"uint16":return d instanceof Uint16Array?d:Uint16Array.from(d);case"uint32":return d instanceof Uint32Array?d:Uint32Array.from(d);case"uint8":case"bool":return d instanceof Uint8Array?d:Uint8Array.from(d);case"float32":return d instanceof Float32Array?d:Float32Array.from(d);case"float64":return d instanceof Float64Array?d:Float64Array.from(d);default:throw new Error(`TensorData type ${u} is not supported`)}}toTextureData(u,d){if(d)return d instanceof Float32Array?d:new Float32Array(d)}toEncoderType(u){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},2039:(m,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.TextureType=void 0,(i=t.TextureType||(t.TextureType={}))[i.unpacked=0]="unpacked",i[i.unpackedReversed=1]="unpackedReversed",i[i.packed=2]="packed",i[i.downloadUint8AsFloat=3]="downloadUint8AsFloat",i[i.packedLastDimension=4]="packedLastDimension"},9390:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getGlChannels=t.getCoordsDataType=t.getSqueezedParams=t.squeezeInputShape=t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=t.generateShaderFuncNameFromInputSamplerName=t.repeatedTry=t.getPackedShape=void 0;const s=i(2517);t.getPackedShape=function(u){const d=u.length;return u.slice(0,d-1).concat(u[d-1]/4)},t.repeatedTry=async function(u,d=h=>0,a){return new Promise((h,f)=>{let c=0;const l=()=>{if(u())return void h();c++;const n=d(c);a!=null&&c>=a?f():setTimeout(l,n)};l()})},t.generateShaderFuncNameFromInputSamplerName=function(u){return(0,s.assert)(u!==void 0&&u.length!==0,()=>"empty string found for sampler name"),"get"+u.charAt(0).toUpperCase()+u.slice(1)},t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(u){return(0,s.assert)(u!==void 0&&u.length!==0,()=>"empty string found for sampler name"),"get"+u.charAt(0).toUpperCase()+u.slice(1)+"AtOutCoords"},t.squeezeInputShape=function(u,d){let a=JSON.parse(JSON.stringify(u));return a=d,a},t.getSqueezedParams=function(u,d){return d.map(a=>u[a]).join(", ")},t.getCoordsDataType=function(u){if(u<=1)return"int";if(u===2)return"ivec2";if(u===3)return"ivec3";if(u===4)return"ivec4";if(u===5)return"ivec5";if(u===6)return"ivec6";throw Error(`GPU for rank ${u} is not yet supported`)},t.getGlChannels=function(u=6){return["x","y","z","w","u","v"].slice(0,u)}},7305:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createNewWebGLContext=t.createWebGLContext=void 0;const s=i(6231),u=i(1713),d={};function a(h){const f=function(){if(typeof document>"u"){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}const n=document.createElement("canvas");return n.width=1,n.height=1,n}();let c;const l={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!h||h==="webgl2")&&(c=f.getContext("webgl2",l),c))try{return new u.WebGLContext(c,2)}catch(n){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${n}`)}if((!h||h==="webgl")&&(c=f.getContext("webgl",l)||f.getContext("experimental-webgl",l),c))try{return new u.WebGLContext(c,1)}catch(n){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${n}`)}throw new Error("WebGL is not supported")}t.createWebGLContext=function h(f){let c;f&&f!=="webgl2"||!("webgl2"in d)?f&&f!=="webgl"||!("webgl"in d)||(c=d.webgl):c=d.webgl2,c=c||a(f),f=f||c.version===1?"webgl":"webgl2";const l=c.gl;return d[f]=c,l.isContextLost()?(delete d[f],h(f)):(l.disable(l.DEPTH_TEST),l.disable(l.STENCIL_TEST),l.disable(l.BLEND),l.disable(l.DITHER),l.disable(l.POLYGON_OFFSET_FILL),l.disable(l.SAMPLE_COVERAGE),l.enable(l.SCISSOR_TEST),l.enable(l.CULL_FACE),l.cullFace(l.BACK),c)},t.createNewWebGLContext=a},1713:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(l,n,e,r){r===void 0&&(r=e);var o=Object.getOwnPropertyDescriptor(n,e);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[e]}}),Object.defineProperty(l,r,o)}:function(l,n,e,r){r===void 0&&(r=e),l[r]=n[e]}),u=this&&this.__setModuleDefault||(Object.create?function(l,n){Object.defineProperty(l,"default",{enumerable:!0,value:n})}:function(l,n){l.default=n}),d=this&&this.__importStar||function(l){if(l&&l.__esModule)return l;var n={};if(l!=null)for(var e in l)e!=="default"&&Object.prototype.hasOwnProperty.call(l,e)&&s(n,l,e);return u(n,l),n};Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLContext=t.linearSearchLastTrue=void 0;const a=i(1670),h=d(i(7769)),f=i(9390);function c(l){let n=0;for(;nthis.isTimerResultAvailable(l)),this.getTimerResult(l)}async createAndWaitForFence(){const l=this.createFence(this.gl);return this.pollFence(l)}createFence(l){let n;const e=l,r=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return l.flush(),n=r===null?()=>!0:()=>{const o=e.clientWaitSync(r,0,0);return o===e.ALREADY_SIGNALED||o===e.CONDITION_SATISFIED},{query:r,isFencePassed:n}}async pollFence(l){return new Promise(n=>{this.addItemToPoll(()=>l.isFencePassed(),()=>n())})}pollItems(){const l=c(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=l;++n){const{resolveFn:e}=this.itemsToPoll[n];e()}this.itemsToPoll=this.itemsToPoll.slice(l+1)}async addItemToPoll(l,n){this.itemsToPoll.push({isDoneFn:l,resolveFn:n}),this.itemsToPoll.length>1||await(0,f.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},1036:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExecutionPlan=void 0;const s=i(6231);class u{constructor(a,h){this.op=a,this.node=h}}t.ExecutionPlan=class{constructor(d,a,h){this.graph=d,this.profiler=h,this.initialize(a)}initialize(d){this.profiler.event("session","ExecutionPlan.initialize",()=>{const a=this.graph.getNodes();if(a.length!==d.length)throw new Error("The size of nodes and OPs do not match.");this._ops=d.map((h,f)=>new u(h,a[f])),this.reset(),this._starter=[],this._ops.forEach((h,f)=>{let c=!0;for(const l of h.node.inputs)if(!this._values[l]&&this.graph.getInputIndices().indexOf(l)===-1){c=!1;break}c&&this._starter.push(f)})})}reset(){this._values=this.graph.getValues().map(d=>d.tensor)}async execute(d,a){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const h=d.createInferenceHandler(),f=this.graph.getInputIndices();if(a.length!==f.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${a.length} expected: ${f.length}`);a.forEach((o,p)=>{const g=f[p];this._values[g]=o});const c=this._starter.slice(0),l=this.graph.getValues(),n=this.graph.getNodes();let e=0;for(;ethis._values[w]);if(g.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${p.node}`);const _=g;s.Logger.verbose("ExecPlan",`Runing op:${p.node.name} (${_.map((w,T)=>`'${p.node.inputs[T]}': ${w.type}[${w.dims.join(",")}]`).join(", ")})`);const b=await this.profiler.event("node",p.node.name,async()=>p.op.impl(h,_,p.op.context));if(b.length!==p.node.outputs.length)throw new Error("the size of output does not match model definition.");b.forEach((w,T)=>{const S=p.node.outputs[T];if(this._values[S])throw new Error(`output [${S}] already has value: op:${p.node.name}`);this._values[S]=w});const y=new Set;b.forEach((w,T)=>{const S=p.node.outputs[T];for(const A of l[S].to){const P=n[A];let x=!0;for(const M of P.inputs)if(!this._values[M]){x=!1;break}x&&y.add(A)}}),c.push(...y)}const r=[];for(let o=0;o{Object.defineProperty(t,"__esModule",{value:!0}),t.Graph=void 0;const s=i(1446),u=i(7778),d=i(9395),a=i(9162),h=i(2517);var f=d.onnxruntime.experimental.fbs;t.Graph={from:(e,r)=>new n(e,r)};class c{constructor(r){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,r&&(this.type=h.ProtoUtil.tensorValueTypeFromProto(r.type.tensorType))}get from(){return this._from}get to(){return this._to}}class l{constructor(r,o){r instanceof s.onnx.NodeProto?(this.name=r.name,this.opType=r.opType,this.attributes=new u.Attribute(r.attribute)):r instanceof f.Node&&(this.name=o??r.name(),this.opType=r.opType(),this.attributes=new u.Attribute(h.ProtoUtil.tensorAttributesFromORTFormat(r))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class n{constructor(r,o){if(!r)throw new TypeError("graph is empty");this.buildGraph(r),this.transformGraph(o),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(r){if(r instanceof s.onnx.GraphProto)this.buildGraphFromOnnxFormat(r);else{if(!(r instanceof f.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(r)}}buildGraphFromOnnxFormat(r){const o=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const p=new Map;if(!r.input)throw new Error("missing information in graph: input");const g=[];for(const _ of r.input){if(o.has(_.name))throw new Error(`duplicated input name: ${_.name}`);const b=this._allData.push(new c(_))-1;o.set(_.name,b),g.push(_.name)}if(!r.initializer)throw new Error("missing information in graph: initializer");for(const _ of r.initializer){let b=o.get(_.name);if(b===void 0){const y=new c;y.type={shape:{dims:h.ProtoUtil.tensorDimsFromProto(_.dims)},tensorType:h.ProtoUtil.tensorDataTypeFromProto(_.dataType)},b=this._allData.push(y)-1,o.set(_.name,b)}this._allData[b]._from=-1,this._allData[b].tensor=a.Tensor.fromProto(_)}for(let _=0;_{this._allData[g]._to.forEach(_=>{r.add(_)})});const o=Array.from(r),p=new Array(this._nodes.length).fill("white");for(;o.length>0;){const g=o.pop();p[g]==="gray"?p[g]="black":(o.push(g),p[g]="gray",this._nodes[g].outputs.forEach(_=>{const b=this._allData[_];if(b.tensor!==void 0)throw new Error("node outputs should not be initialized");if(b._from!==g)throw new Error("from property of the Value object doesn't match index of Node being processed");b._to.forEach(y=>{if(p[y]==="gray")throw new Error("model graph is cyclic");p[y]==="white"&&o.push(y)})}))}}transformGraph(r){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),r&&r.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let r=0;for(let o=0;o0&&(this._nodes[o].inputs.forEach(p=>{const g=this._allData[p]._to.indexOf(o+r);g!==-1&&(this._allData[p]._to[g]=o)}),this._nodes[o].outputs.forEach(p=>{this._allData[p]._from&&this._allData[p]._from===o+r&&(this._allData[p]._from=o)})):(r++,this._nodes[o].outputs.forEach(p=>{this._allData[p]._from=-2}),this._nodes.splice(o,1),o--);r=0;for(let o=0;o0){let p=-1;this._allData[o].from!==void 0&&this._allData[o].from!==-1?(p=this._nodes[this._allData[o].from].outputs.indexOf(o+r),p!==-1&&(this._nodes[this._allData[o].from].outputs[p]=o)):(p=this._allInputIndices.indexOf(o+r),p!==-1&&(this._allInputIndices[p]=o)),this._allData[o].to.forEach(g=>{p=this._nodes[g].inputs.indexOf(o+r),p!==-1&&(this._nodes[g].inputs[p]=o)}),this._allData[o].to.length===0&&(p=this._allOutputIndices.indexOf(o+r),p!==-1&&(this._allOutputIndices[p]=o))}}else r++,this._allData.splice(o,1),o--}deleteNode(r){const o=this._nodes[r];if(o.outputs.length>1){for(let w=1;w0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}o.executeNode=!1;const p=o.inputs[0],g=o.outputs[0],_=this._allData[g].to,b=this._allData[p].to.indexOf(r);if(b===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[p].to.splice(b,1),this._allData[g]._to=[];const y=this._allOutputIndices.indexOf(g);if(y!==-1&&(this._allOutputIndices[y]=p),_&&_.length>0)for(const w of _){const T=this._nodes[w].inputs.indexOf(g);if(T===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[w].inputs[T]=p,this._allData[p].to.push(w)}}removeAllDropoutNodes(){let r=0;for(const o of this._nodes){if(o.opType==="Dropout"){if(o.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(o.outputs.length!==1&&o.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(o.outputs.length===2&&this._allData[o.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(r)}r++}}removeAllIdentityNodes(){let r=0;for(const o of this._nodes)o.opType==="Identity"&&this.deleteNode(r),r++}isActivation(r){switch(r.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const r of this._nodes)if(r.opType==="Conv"){const o=this._allData[r.outputs[0]]._to;if(o.length===1&&this.isActivation(this._nodes[o[0]])){const p=this._nodes[o[0]];if(p.opType==="Clip")if(p.inputs.length===1)try{r.attributes.set("activation_params","floats",[p.attributes.getFloat("min"),p.attributes.getFloat("max")])}catch{r.attributes.set("activation_params","floats",[h.MIN_CLIP,h.MAX_CLIP])}else{if(!(p.inputs.length>=3&&this._allData[p.inputs[1]].tensor!==void 0&&this._allData[p.inputs[2]].tensor!==void 0))continue;r.attributes.set("activation_params","floats",[this._allData[p.inputs[1]].tensor.floatData[0],this._allData[p.inputs[2]].tensor.floatData[0]])}r.attributes.set("activation","string",p.opType),this.deleteNode(o[0])}}}}},6231:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.now=t.Profiler=t.Logger=void 0;const i={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},s={none:new class{log(l,n,e){}},console:new class{log(l,n,e){console.log(`${this.color(l)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${n}`)}color(l){switch(l){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${l}`)}}}},u={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let d={"":u};function a(l,n,e,r){if(n===void 0)return o=l,{verbose:a.verbose.bind(null,o),info:a.info.bind(null,o),warning:a.warning.bind(null,o),error:a.error.bind(null,o),fatal:a.fatal.bind(null,o)};if(e===void 0)h(l,n);else if(typeof e=="number"&&r===void 0)h(l,n);else if(typeof e=="string"&&r===void 0)h(l,e,0,n);else{if(typeof e!="string"||typeof r!="number")throw new TypeError("input is valid");h(l,e,0,n)}var o}function h(l,n,e,r){const o=d[r||""]||d[""];i[l]{g.then(async y=>{o&&await o.end(),_(y)},async y=>{o&&await o.end(),b(y)})});if(!p&&o){const _=o.end();if(_&&typeof _.then=="function")return new Promise((b,y)=>{_.then(()=>{b(g)},w=>{y(w)})})}return g}begin(l,n,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){const r=(0,t.now)();return this.flush(r),new f(l,n,r,o=>this.endSync(o))}{const r=e.beginTimer();return new f(l,n,0,async o=>this.end(o),r,e)}}async end(l){const n=await l.checkTimer();this._timingEvents.length=this._flushBatchSize||l-this._flushTime>=this._flushIntervalInMilliseconds){for(const n=this._flushPointer;this._flushPointerperformance.now():Date.now},2644:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(5686),u=i(1446),d=i(7070),a=i(9395),h=i(2517);var f=a.onnxruntime.experimental.fbs;t.Model=class{constructor(){}load(c,l,n){if(!n)try{return void this.loadFromOnnxFormat(c,l)}catch(e){if(n!==void 0)throw e}this.loadFromOrtFormat(c,l)}loadFromOnnxFormat(c,l){const n=u.onnx.ModelProto.decode(c);if(h.LongUtil.longToNumber(n.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=n.opsetImport.map(e=>({domain:e.domain,version:h.LongUtil.longToNumber(e.version)})),this._graph=d.Graph.from(n.graph,l)}loadFromOrtFormat(c,l){const n=new s.flatbuffers.ByteBuffer(c),e=f.InferenceSession.getRootAsInferenceSession(n).model();if(h.LongUtil.longToNumber(e.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.FLOAT_TYPES=t.INT_TYPES=t.NUMBER_TYPES=void 0,t.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],t.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],t.FLOAT_TYPES=["float32","float64"]},1047:(m,t)=>{function i(s,u){if(u.endsWith("+")){const d=Number.parseInt(u.substring(0,u.length-1),10);return!isNaN(d)&&d<=s}if(u.split("-").length===2){const d=u.split("-"),a=Number.parseInt(d[0],10),h=Number.parseInt(d[1],10);return!isNaN(a)&&!isNaN(h)&&a<=s&&s<=h}return Number.parseInt(u,10)===s}Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOperator=void 0,t.resolveOperator=function(s,u,d){for(const a of d){const h=a[0],f=a[1],c=a[2],l=a[3],n=a[4];if(s.opType===h){for(const e of u)if((e.domain===f||e.domain==="ai.onnx"&&f==="")&&i(e.version,c))return{opImpl:l,opInit:n}}}throw new TypeError(`cannot resolve operator '${s.opType}' with opsets: ${u.map(a=>`${a.domain||"ai.onnx"} v${a.version}`).join(", ")}`)}},9395:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onnxruntime=void 0;const s=i(5686);var u,d;u=t.onnxruntime||(t.onnxruntime={}),function(a){(function(h){h[h.UNDEFINED=0]="UNDEFINED",h[h.FLOAT=1]="FLOAT",h[h.INT=2]="INT",h[h.STRING=3]="STRING",h[h.TENSOR=4]="TENSOR",h[h.GRAPH=5]="GRAPH",h[h.FLOATS=6]="FLOATS",h[h.INTS=7]="INTS",h[h.STRINGS=8]="STRINGS",h[h.TENSORS=9]="TENSORS",h[h.GRAPHS=10]="GRAPHS",h[h.SPARSE_TENSOR=11]="SPARSE_TENSOR",h[h.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(a.AttributeType||(a.AttributeType={}))}((d=u.experimental||(u.experimental={})).fbs||(d.fbs={})),function(a){(function(h){(function(f){(function(c){c[c.UNKNOWN=0]="UNKNOWN",c[c.VALUE=1]="VALUE",c[c.PARAM=2]="PARAM"})(f.DimensionValueType||(f.DimensionValueType={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){(function(c){c[c.UNDEFINED=0]="UNDEFINED",c[c.FLOAT=1]="FLOAT",c[c.UINT8=2]="UINT8",c[c.INT8=3]="INT8",c[c.UINT16=4]="UINT16",c[c.INT16=5]="INT16",c[c.INT32=6]="INT32",c[c.INT64=7]="INT64",c[c.STRING=8]="STRING",c[c.BOOL=9]="BOOL",c[c.FLOAT16=10]="FLOAT16",c[c.DOUBLE=11]="DOUBLE",c[c.UINT32=12]="UINT32",c[c.UINT64=13]="UINT64",c[c.COMPLEX64=14]="COMPLEX64",c[c.COMPLEX128=15]="COMPLEX128",c[c.BFLOAT16=16]="BFLOAT16"})(f.TensorDataType||(f.TensorDataType={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){(function(c){c[c.Primitive=0]="Primitive",c[c.Fused=1]="Fused"})(f.NodeType||(f.NodeType={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){(function(c){c[c.NONE=0]="NONE",c[c.tensor_type=1]="tensor_type",c[c.sequence_type=2]="sequence_type",c[c.map_type=3]="map_type"})(f.TypeInfoValue||(f.TypeInfoValue={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsShape(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsShape(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}dim(n,e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new a.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}dimLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}static startShape(n){n.startObject(1)}static addDim(n,e){n.addFieldOffset(0,e,0)}static createDimVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startDimVector(n,e){n.startVector(4,e,4)}static endShape(n){return n.endObject()}static createShape(n,e){return c.startShape(n),c.addDim(n,e),c.endShape(n)}}f.Shape=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsDimension(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimension(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}value(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new a.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}denotation(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}static startDimension(n){n.startObject(2)}static addValue(n,e){n.addFieldOffset(0,e,0)}static addDenotation(n,e){n.addFieldOffset(1,e,0)}static endDimension(n){return n.endObject()}static createDimension(n,e,r){return c.startDimension(n),c.addValue(n,e),c.addDenotation(n,r),c.endDimension(n)}}f.Dimension=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsDimensionValue(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimensionValue(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}dimType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt8(this.bb_pos+n):a.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}dimParam(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,n):null}static startDimensionValue(n){n.startObject(3)}static addDimType(n,e){n.addFieldInt8(0,e,a.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(n,e){n.addFieldInt64(1,e,n.createLong(0,0))}static addDimParam(n,e){n.addFieldOffset(2,e,0)}static endDimensionValue(n){return n.endObject()}static createDimensionValue(n,e,r,o){return c.startDimensionValue(n),c.addDimType(n,e),c.addDimValue(n,r),c.addDimParam(n,o),c.endDimensionValue(n)}}f.DimensionValue=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsTensorTypeAndShape(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensorTypeAndShape(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}elemType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt32(this.bb_pos+n):a.experimental.fbs.TensorDataType.UNDEFINED}shape(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startTensorTypeAndShape(n){n.startObject(2)}static addElemType(n,e){n.addFieldInt32(0,e,a.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(n,e){n.addFieldOffset(1,e,0)}static endTensorTypeAndShape(n){return n.endObject()}static createTensorTypeAndShape(n,e,r){return c.startTensorTypeAndShape(n),c.addElemType(n,e),c.addShape(n,r),c.endTensorTypeAndShape(n)}}f.TensorTypeAndShape=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsMapType(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsMapType(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}keyType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt32(this.bb_pos+n):a.experimental.fbs.TensorDataType.UNDEFINED}valueType(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startMapType(n){n.startObject(2)}static addKeyType(n,e){n.addFieldInt32(0,e,a.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(n,e){n.addFieldOffset(1,e,0)}static endMapType(n){return n.endObject()}static createMapType(n,e,r){return c.startMapType(n),c.addKeyType(n,e),c.addValueType(n,r),c.endMapType(n)}}f.MapType=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSequenceType(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSequenceType(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}elemType(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSequenceType(n){n.startObject(1)}static addElemType(n,e){n.addFieldOffset(0,e,0)}static endSequenceType(n){return n.endObject()}static createSequenceType(n,e){return c.startSequenceType(n),c.addElemType(n,e),c.endSequenceType(n)}}f.SequenceType=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(h.fbs||(h.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(f,c){return this.bb_pos=f,this.bb=c,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(f,c,l,n){return f.prep(4,12),f.writeInt32(n),f.writeInt32(l),f.writeInt32(c),f.offset()}}})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsNodeEdge(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNodeEdge(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}nodeIndex(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readUint32(this.bb_pos+n):0}inputEdges(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new a.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*n,this.bb):null}inputEdgesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}outputEdges(n,e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new a.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*n,this.bb):null}outputEdgesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNodeEdge(n){n.startObject(3)}static addNodeIndex(n,e){n.addFieldInt32(0,e,0)}static addInputEdges(n,e){n.addFieldOffset(1,e,0)}static startInputEdgesVector(n,e){n.startVector(12,e,4)}static addOutputEdges(n,e){n.addFieldOffset(2,e,0)}static startOutputEdgesVector(n,e){n.startVector(12,e,4)}static endNodeEdge(n){return n.endObject()}static createNodeEdge(n,e,r,o){return c.startNodeEdge(n),c.addNodeIndex(n,e),c.addInputEdges(n,r),c.addOutputEdges(n,o),c.endNodeEdge(n)}}f.NodeEdge=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsNode(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNode(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}domain(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,n):null}sinceVersion(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt32(this.bb_pos+n):0}index(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readUint32(this.bb_pos+n):0}opType(n){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,n):null}type(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.readInt32(this.bb_pos+n):a.experimental.fbs.NodeType.Primitive}executionProviderType(n){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,n):null}inputs(n,e){let r=this.bb.__offset(this.bb_pos,20);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,e){let r=this.bb.__offset(this.bb_pos,22);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}attributes(n,e){let r=this.bb.__offset(this.bb_pos,24);return r?(e||new a.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}attributesLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCounts(n){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*n):0}inputArgCountsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCountsArray(){let n=this.bb.__offset(this.bb_pos,26);return n?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}implicitInputs(n,e){let r=this.bb.__offset(this.bb_pos,28);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}implicitInputsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNode(n){n.startObject(13)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addDomain(n,e){n.addFieldOffset(2,e,0)}static addSinceVersion(n,e){n.addFieldInt32(3,e,0)}static addIndex(n,e){n.addFieldInt32(4,e,0)}static addOpType(n,e){n.addFieldOffset(5,e,0)}static addType(n,e){n.addFieldInt32(6,e,a.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(n,e){n.addFieldOffset(7,e,0)}static addInputs(n,e){n.addFieldOffset(8,e,0)}static createInputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startInputsVector(n,e){n.startVector(4,e,4)}static addOutputs(n,e){n.addFieldOffset(9,e,0)}static createOutputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startOutputsVector(n,e){n.startVector(4,e,4)}static addAttributes(n,e){n.addFieldOffset(10,e,0)}static createAttributesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startAttributesVector(n,e){n.startVector(4,e,4)}static addInputArgCounts(n,e){n.addFieldOffset(11,e,0)}static createInputArgCountsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addInt32(e[r]);return n.endVector()}static startInputArgCountsVector(n,e){n.startVector(4,e,4)}static addImplicitInputs(n,e){n.addFieldOffset(12,e,0)}static createImplicitInputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startImplicitInputsVector(n,e){n.startVector(4,e,4)}static endNode(n){return n.endObject()}static createNode(n,e,r,o,p,g,_,b,y,w,T,S,A,P){return c.startNode(n),c.addName(n,e),c.addDocString(n,r),c.addDomain(n,o),c.addSinceVersion(n,p),c.addIndex(n,g),c.addOpType(n,_),c.addType(n,b),c.addExecutionProviderType(n,y),c.addInputs(n,w),c.addOutputs(n,T),c.addAttributes(n,S),c.addInputArgCounts(n,A),c.addImplicitInputs(n,P),c.endNode(n)}}f.Node=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsValueInfo(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsValueInfo(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}type(n){let e=this.bb.__offset(this.bb_pos,8);return e?(n||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startValueInfo(n){n.startObject(3)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addType(n,e){n.addFieldOffset(2,e,0)}static endValueInfo(n){return n.endObject()}static createValueInfo(n,e,r,o){return c.startValueInfo(n),c.addName(n,e),c.addDocString(n,r),c.addType(n,o),c.endValueInfo(n)}}f.ValueInfo=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsTypeInfo(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTypeInfo(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}denotation(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}valueType(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readUint8(this.bb_pos+n):a.experimental.fbs.TypeInfoValue.NONE}value(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(n,this.bb_pos+e):null}static startTypeInfo(n){n.startObject(3)}static addDenotation(n,e){n.addFieldOffset(0,e,0)}static addValueType(n,e){n.addFieldInt8(1,e,a.experimental.fbs.TypeInfoValue.NONE)}static addValue(n,e){n.addFieldOffset(2,e,0)}static endTypeInfo(n){return n.endObject()}static createTypeInfo(n,e,r,o){return c.startTypeInfo(n),c.addDenotation(n,e),c.addValueType(n,r),c.addValue(n,o),c.endTypeInfo(n)}}f.TypeInfo=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsOperatorSetId(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsOperatorSetId(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}domain(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}version(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}static startOperatorSetId(n){n.startObject(2)}static addDomain(n,e){n.addFieldOffset(0,e,0)}static addVersion(n,e){n.addFieldInt64(1,e,n.createLong(0,0))}static endOperatorSetId(n){return n.endObject()}static createOperatorSetId(n,e,r){return c.startOperatorSetId(n),c.addDomain(n,e),c.addVersion(n,r),c.endOperatorSetId(n)}}f.OperatorSetId=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsTensor(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensor(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}dims(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}dimsLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}dataType(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt32(this.bb_pos+n):a.experimental.fbs.TensorDataType.UNDEFINED}rawData(n){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+n):0}rawDataLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}rawDataArray(){let n=this.bb.__offset(this.bb_pos,12);return n?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}stringData(n,e){let r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}stringDataLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}static startTensor(n){n.startObject(6)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addDims(n,e){n.addFieldOffset(2,e,0)}static createDimsVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startDimsVector(n,e){n.startVector(8,e,8)}static addDataType(n,e){n.addFieldInt32(3,e,a.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(n,e){n.addFieldOffset(4,e,0)}static createRawDataVector(n,e){n.startVector(1,e.length,1);for(let r=e.length-1;r>=0;r--)n.addInt8(e[r]);return n.endVector()}static startRawDataVector(n,e){n.startVector(1,e,1)}static addStringData(n,e){n.addFieldOffset(5,e,0)}static createStringDataVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startStringDataVector(n,e){n.startVector(4,e,4)}static endTensor(n){return n.endObject()}static createTensor(n,e,r,o,p,g,_){return c.startTensor(n),c.addName(n,e),c.addDocString(n,r),c.addDims(n,o),c.addDataType(n,p),c.addRawData(n,g),c.addStringData(n,_),c.endTensor(n)}}f.Tensor=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSparseTensor(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSparseTensor(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}values(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}indices(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dims(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}dimsLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSparseTensor(n){n.startObject(3)}static addValues(n,e){n.addFieldOffset(0,e,0)}static addIndices(n,e){n.addFieldOffset(1,e,0)}static addDims(n,e){n.addFieldOffset(2,e,0)}static createDimsVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startDimsVector(n,e){n.startVector(8,e,8)}static endSparseTensor(n){return n.endObject()}static createSparseTensor(n,e,r,o){return c.startSparseTensor(n),c.addValues(n,e),c.addIndices(n,r),c.addDims(n,o),c.endSparseTensor(n)}}f.SparseTensor=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsAttribute(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsAttribute(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}type(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.readInt32(this.bb_pos+n):a.experimental.fbs.AttributeType.UNDEFINED}f(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readFloat32(this.bb_pos+n):0}i(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}s(n){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,n):null}t(n){let e=this.bb.__offset(this.bb_pos,16);return e?(n||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}g(n){let e=this.bb.__offset(this.bb_pos,18);return e?(n||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}floats(n){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*n):0}floatsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}floatsArray(){let n=this.bb.__offset(this.bb_pos,20);return n?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}ints(n){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}intsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}strings(n,e){let r=this.bb.__offset(this.bb_pos,24);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}stringsLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}tensors(n,e){let r=this.bb.__offset(this.bb_pos,26);return r?(e||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}tensorsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}graphs(n,e){let r=this.bb.__offset(this.bb_pos,28);return r?(e||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}graphsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startAttribute(n){n.startObject(13)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addType(n,e){n.addFieldInt32(2,e,a.experimental.fbs.AttributeType.UNDEFINED)}static addF(n,e){n.addFieldFloat32(3,e,0)}static addI(n,e){n.addFieldInt64(4,e,n.createLong(0,0))}static addS(n,e){n.addFieldOffset(5,e,0)}static addT(n,e){n.addFieldOffset(6,e,0)}static addG(n,e){n.addFieldOffset(7,e,0)}static addFloats(n,e){n.addFieldOffset(8,e,0)}static createFloatsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addFloat32(e[r]);return n.endVector()}static startFloatsVector(n,e){n.startVector(4,e,4)}static addInts(n,e){n.addFieldOffset(9,e,0)}static createIntsVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startIntsVector(n,e){n.startVector(8,e,8)}static addStrings(n,e){n.addFieldOffset(10,e,0)}static createStringsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startStringsVector(n,e){n.startVector(4,e,4)}static addTensors(n,e){n.addFieldOffset(11,e,0)}static createTensorsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startTensorsVector(n,e){n.startVector(4,e,4)}static addGraphs(n,e){n.addFieldOffset(12,e,0)}static createGraphsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startGraphsVector(n,e){n.startVector(4,e,4)}static endAttribute(n){return n.endObject()}static createAttribute(n,e,r,o,p,g,_,b,y,w,T,S,A,P){return c.startAttribute(n),c.addName(n,e),c.addDocString(n,r),c.addType(n,o),c.addF(n,p),c.addI(n,g),c.addS(n,_),c.addT(n,b),c.addG(n,y),c.addFloats(n,w),c.addInts(n,T),c.addStrings(n,S),c.addTensors(n,A),c.addGraphs(n,P),c.endAttribute(n)}}f.Attribute=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsGraph(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsGraph(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}initializers(n,e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}initializersLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeArgs(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new a.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}nodeArgsLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}nodes(n,e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new a.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}nodesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}maxNodeIndex(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readUint32(this.bb_pos+n):0}nodeEdges(n,e){let r=this.bb.__offset(this.bb_pos,12);return r?(e||new a.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}nodeEdgesLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}inputs(n,e){let r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,e){let r=this.bb.__offset(this.bb_pos,16);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__vector_len(this.bb_pos+n):0}sparseInitializers(n,e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new a.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}sparseInitializersLength(){let n=this.bb.__offset(this.bb_pos,18);return n?this.bb.__vector_len(this.bb_pos+n):0}static startGraph(n){n.startObject(8)}static addInitializers(n,e){n.addFieldOffset(0,e,0)}static createInitializersVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startInitializersVector(n,e){n.startVector(4,e,4)}static addNodeArgs(n,e){n.addFieldOffset(1,e,0)}static createNodeArgsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startNodeArgsVector(n,e){n.startVector(4,e,4)}static addNodes(n,e){n.addFieldOffset(2,e,0)}static createNodesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startNodesVector(n,e){n.startVector(4,e,4)}static addMaxNodeIndex(n,e){n.addFieldInt32(3,e,0)}static addNodeEdges(n,e){n.addFieldOffset(4,e,0)}static createNodeEdgesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startNodeEdgesVector(n,e){n.startVector(4,e,4)}static addInputs(n,e){n.addFieldOffset(5,e,0)}static createInputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startInputsVector(n,e){n.startVector(4,e,4)}static addOutputs(n,e){n.addFieldOffset(6,e,0)}static createOutputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startOutputsVector(n,e){n.startVector(4,e,4)}static addSparseInitializers(n,e){n.addFieldOffset(7,e,0)}static createSparseInitializersVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startSparseInitializersVector(n,e){n.startVector(4,e,4)}static endGraph(n){return n.endObject()}static createGraph(n,e,r,o,p,g,_,b,y){return c.startGraph(n),c.addInitializers(n,e),c.addNodeArgs(n,r),c.addNodes(n,o),c.addMaxNodeIndex(n,p),c.addNodeEdges(n,g),c.addInputs(n,_),c.addOutputs(n,b),c.addSparseInitializers(n,y),c.endGraph(n)}}f.Graph=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsModel(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsModel(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}irVersion(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}opsetImport(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new a.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}opsetImportLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}producerName(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,n):null}producerVersion(n){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,n):null}domain(n){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,n):null}modelVersion(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}docString(n){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,n):null}graph(n){let e=this.bb.__offset(this.bb_pos,18);return e?(n||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}graphDocString(n){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,n):null}static startModel(n){n.startObject(9)}static addIrVersion(n,e){n.addFieldInt64(0,e,n.createLong(0,0))}static addOpsetImport(n,e){n.addFieldOffset(1,e,0)}static createOpsetImportVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startOpsetImportVector(n,e){n.startVector(4,e,4)}static addProducerName(n,e){n.addFieldOffset(2,e,0)}static addProducerVersion(n,e){n.addFieldOffset(3,e,0)}static addDomain(n,e){n.addFieldOffset(4,e,0)}static addModelVersion(n,e){n.addFieldInt64(5,e,n.createLong(0,0))}static addDocString(n,e){n.addFieldOffset(6,e,0)}static addGraph(n,e){n.addFieldOffset(7,e,0)}static addGraphDocString(n,e){n.addFieldOffset(8,e,0)}static endModel(n){return n.endObject()}static createModel(n,e,r,o,p,g,_,b,y,w){return c.startModel(n),c.addIrVersion(n,e),c.addOpsetImport(n,r),c.addProducerName(n,o),c.addProducerVersion(n,p),c.addDomain(n,g),c.addModelVersion(n,_),c.addDocString(n,b),c.addGraph(n,y),c.addGraphDocString(n,w),c.endModel(n)}}f.Model=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsKernelCreateInfos(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsKernelCreateInfos(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}nodeIndices(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*n):0}nodeIndicesLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeIndicesArray(){let n=this.bb.__offset(this.bb_pos,4);return n?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}kernelDefHashes(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}kernelDefHashesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startKernelCreateInfos(n){n.startObject(2)}static addNodeIndices(n,e){n.addFieldOffset(0,e,0)}static createNodeIndicesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addInt32(e[r]);return n.endVector()}static startNodeIndicesVector(n,e){n.startVector(4,e,4)}static addKernelDefHashes(n,e){n.addFieldOffset(1,e,0)}static createKernelDefHashesVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startKernelDefHashesVector(n,e){n.startVector(8,e,8)}static endKernelCreateInfos(n){return n.endObject()}static createKernelCreateInfos(n,e,r){return c.startKernelCreateInfos(n),c.addNodeIndices(n,e),c.addKernelDefHashes(n,r),c.endKernelCreateInfos(n)}}f.KernelCreateInfos=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSubGraphSessionState(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSubGraphSessionState(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}graphId(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}sessionState(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSubGraphSessionState(n){n.startObject(2)}static addGraphId(n,e){n.addFieldOffset(0,e,0)}static addSessionState(n,e){n.addFieldOffset(1,e,0)}static endSubGraphSessionState(n){let e=n.endObject();return n.requiredField(e,4),e}static createSubGraphSessionState(n,e,r){return c.startSubGraphSessionState(n),c.addGraphId(n,e),c.addSessionState(n,r),c.endSubGraphSessionState(n)}}f.SubGraphSessionState=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSessionState(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSessionState(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}kernels(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new a.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}subGraphSessionStates(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new a.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}subGraphSessionStatesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSessionState(n){n.startObject(2)}static addKernels(n,e){n.addFieldOffset(0,e,0)}static addSubGraphSessionStates(n,e){n.addFieldOffset(1,e,0)}static createSubGraphSessionStatesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startSubGraphSessionStatesVector(n,e){n.startVector(4,e,4)}static endSessionState(n){return n.endObject()}static createSessionState(n,e,r){return c.startSessionState(n),c.addKernels(n,e),c.addSubGraphSessionStates(n,r),c.endSessionState(n)}}f.SessionState=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsInferenceSession(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsInferenceSession(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static bufferHasIdentifier(n){return n.__has_identifier("ORTM")}ortVersion(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}model(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}sessionState(n){let e=this.bb.__offset(this.bb_pos,8);return e?(n||new a.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startInferenceSession(n){n.startObject(3)}static addOrtVersion(n,e){n.addFieldOffset(0,e,0)}static addModel(n,e){n.addFieldOffset(1,e,0)}static addSessionState(n,e){n.addFieldOffset(2,e,0)}static endInferenceSession(n){return n.endObject()}static finishInferenceSessionBuffer(n,e){n.finish(e,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(n,e){n.finish(e,"ORTM",!0)}static createInferenceSession(n,e,r,o){return c.startInferenceSession(n),c.addOrtVersion(n,e),c.addModel(n,r),c.addSessionState(n,o),c.endInferenceSession(n)}}f.InferenceSession=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={}))},7448:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxjsSessionHandler=void 0;const s=i(1670),u=i(9162);t.OnnxjsSessionHandler=class{constructor(d){this.session=d,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(d,a,h){const f=new Map;for(const n in d)if(Object.hasOwnProperty.call(d,n)){const e=d[n];f.set(n,new u.Tensor(e.dims,e.type,void 0,void 0,e.data))}const c=await this.session.run(f),l={};return c.forEach((n,e)=>{l[e]=new s.Tensor(n.type,n.data,n.dims)}),l}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6919:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Session=void 0;const s=i(7067),u=i(1296),d=i(7091),a=i(1036),h=i(6231),f=i(2644);t.Session=class{constructor(c={}){this._initialized=!1,this.backendHint=c.backendHint,this.profiler=h.Profiler.create(c.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(c,l,n){await this.profiler.event("session","Session.loadModel",async()=>{const e=await(0,d.resolveBackend)(this.backendHint);if(this.sessionHandler=e.createSessionHandler(this.context),this._model=new f.Model,typeof c=="string"){const r=c.endsWith(".ort");if(typeof fetch>"u"){const o=await(0,u.promisify)(s.readFile)(c);this.initialize(o,r)}else{const o=await fetch(c),p=await o.arrayBuffer();this.initialize(new Uint8Array(p),r)}}else if(ArrayBuffer.isView(c))this.initialize(c);else{const r=new Uint8Array(c,l||0,n||c.byteLength);this.initialize(r)}})}initialize(c,l){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const n=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(c,n,l),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new a.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(c){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const l=this.normalizeAndValidateInputs(c),n=await this._executionPlan.execute(this.sessionHandler,l);return this.createOutput(n)})}normalizeAndValidateInputs(c){const l=this._model.graph.getInputNames();if(Array.isArray(c)){if(c.length!==l.length)throw new Error(`incorrect input array length: expected ${l.length} but got ${c.length}`)}else{if(c.size!==l.length)throw new Error(`incorrect input map size: expected ${l.length} but got ${c.size}`);const n=new Array(c.size);let e=0;for(let r=0;rtypeof P=="string")))throw new TypeError("cache should be a string array");A&&(this.cache=new Array(S))}else{if(w!==void 0){const P=e(_);if(!(w instanceof P))throw new TypeError(`cache should be type ${P.name}`)}if(A){const P=new ArrayBuffer(S*function(x){switch(x){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${x}`)}}(_));this.cache=function(x,M){return new(e(M))(x)}(P,_)}}}static fromProto(g){if(!g)throw new Error("cannot construct Value from an empty tensor");const _=f.ProtoUtil.tensorDataTypeFromProto(g.dataType),b=f.ProtoUtil.tensorDimsFromProto(g.dims),y=new l(b,_);if(_==="string")g.stringData.forEach((w,T)=>{y.data[T]=(0,f.decodeUtf8String)(w)});else if(g.rawData&&typeof g.rawData.byteLength=="number"&&g.rawData.byteLength>0){const w=y.data,T=new DataView(g.rawData.buffer,g.rawData.byteOffset,g.rawData.byteLength),S=n(g.dataType),A=g.rawData.byteLength/S;if(g.rawData.byteLength%S!=0)throw new Error("invalid buffer length");if(w.length!==A)throw new Error("buffer length mismatch");for(let P=0;P0){const w=y.data,T=new DataView(g.rawDataArray().buffer,g.rawDataArray().byteOffset,g.rawDataLength()),S=n(g.dataType()),A=g.rawDataLength()/S;if(g.rawDataLength()%S!=0)throw new Error("invalid buffer length");if(w.length!==A)throw new Error("buffer length mismatch");for(let P=0;P1&&M>1)return;A[S-P]=Math.max(x,M)}return A}static index(_,b){const y=new Array(b.length);return c.fillIndex(_,b,y),y}static fillIndex(_,b,y){const w=_.length-b.length;for(let T=0;T=0;Y--)x[Y]=z%S[Y],z=Math.floor(z/S[Y]);G||(c.fillIndex(x,_.dims,M),$=_.get(M)),D||(c.fillIndex(x,b.dims,N),C=b.get(N)),P.set(x,y($,C))}}return P}}static isValidBroadcast(_,b){const y=_.length,w=b.length;if(y>w)return!1;for(let T=1;T<=y;T++)if(_[y-T]!==1&&_[y-T]!==b[w-T])return!1;return!0}static getBroadcastDims(_,b){const y=_.length,w=[];for(let T=0;T1&&A===1&&w.unshift(S)}return w}}t.BroadcastUtil=c,t.arrayCopyHelper=function(g,_,b,y,w){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let T=0;Td.default.isLong(b)?b.toNumber():b)}static tensorValueTypeFromProto(_){return{tensorType:l.tensorDataTypeFromProto(_.elemType),shape:{dims:l.tensorDimsFromProto(_.shape.dim.map(b=>b.dimValue))}}}static tensorDimsFromORTFormat(_){const b=[];for(let y=0;y<_.dimsLength();y++)b.push(n.longToNumber(_.dims(y)));return b}static tensorAttributesFromORTFormat(_){const b=[];for(let y=0;y<_.attributesLength();y++)b.push(_.attributes(y));return b}}t.ProtoUtil=l;class n{static longToNumber(_,b){return d.default.isLong(_)?_.toNumber():_ instanceof u.flatbuffers.Long?d.default.fromValue({low:_.low,high:_.high,unsigned:b!=null&&b}).toNumber():_}static isLong(_){return d.default.isLong(_)||_ instanceof u.flatbuffers.Long}}t.LongUtil=n;class e{static size(_){return e.getSizeFromDimensionRange(_,0,_.length)}static sizeFromDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeFromDimension as Tensor has ${_.length} dimensions.`);return e.getSizeFromDimensionRange(_,b,_.length)}static sizeToDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeToDimension as Tensor has ${_.length} dimensions.`);return e.getSizeFromDimensionRange(_,0,b)}static getSizeFromDimensionRange(_,b,y){let w=1;for(let T=b;T=0;--w)y[w]=y[w+1]*_[w+1];return y}static transpose(_){return _.slice().reverse()}static indicesToOffset(_,b,y){y===void 0&&(y=_.length);let w=0;for(let T=0;T=b)throw new Error("unsupported axis for this operation.");return _<0?_+b:_}static normalizeAxes(_,b){return _.map(y=>this.normalizeAxis(y,b))}static incrementIndex(_,b,y){if(b.length===0||_.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(y===void 0)y=b.length;else if(y<=0||y>b.length)throw new Error("Incorrect axis to increment on");for(let w=y-1;w>=0&&(_[w]++,!(_[w]=_.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");w[P]=_[P]}else w[P]=b[P];S*=w[P]}}const A=e.size(_);if(T!==-1){if(A%S!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${_}] Output shape: [${b}]`);w[T]=A/S}else if(S!==A)throw new Error("reshapedDims and originalDims don't have matching sizes");return w}static sortBasedOnPerm(_,b){return b?b.map(y=>_[y]):_.slice().reverse()}static padShape(_,b){const y=_.length;return _.map((w,T)=>w+b[T]+b[T+y])}static areEqual(_,b){return _.length===b.length&&_.every((y,w)=>y===b[w])}static validateDimsAndCalcSize(_){if(_.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let b=1;for(const y of _){if(!Number.isInteger(y))throw new TypeError(`Invalid shape: ${y} is not an integer`);if(y<0||y>2147483647)throw new TypeError(`Invalid shape: length ${y} is not allowed`);b*=y}return b}static flattenShape(_,b){b<0&&(b+=_.length);const y=_.reduce((T,S)=>T*S,1),w=_.slice(b).reduce((T,S)=>T*S,1);return[y/w,w]}static squeezeShape(_,b){const y=new Array;b=e.normalizeAxes(b,_.length);for(let w=0;w<_.length;w++){const T=b.indexOf(w)>=0;if(T&&_[w]!==1)throw new Error("squeeze an axis of size different than 1");(b.length===0&&_[w]>1||b.length>0&&!T)&&y.push(_[w])}return y}static unsqueezeShape(_,b){const y=new Array(_.length+b.length);y.fill(0);for(let T=0;T=y.length)throw new Error("'axes' has an out of range axis");if(y[S]!==0)throw new Error("'axes' has a duplicate axis");y[S]=1}let w=0;for(let T=0;T=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let T=0;T=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let S=0;S=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let S=0;S=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let T=0;Tb.push(C));const A=o.calcReduceShape(S,b,!0),P=e.size(A),x=new h.Tensor(A,_.type),M=e.computeStrides(A),N=e.computeStrides(S),z=new Array(S.length);for(let $=0;$=b.length)return S(_[T]);const x=b[w],M=x>=y.length?1:e.size(y.slice(x+1));for(let N=0;NT!==0)}}t.ReduceUtil=o;class p{static adjustPoolAttributes(_,b,y,w,T,S){if(!_&&y.length!==b.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(_)for(let A=0;A=y.length?y.push(b[A+2]):y[A]=b[A+2];for(let A=0;A=y[A]||S[A+y.length]>=y[A])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(_,b,y,w,T,S){if(S){if(T.length!==2*(_.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(b.length!==_.length-2)throw new Error("length of strides should be the length of data dimensions");if(w.length!==_.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let A=0;A<_.length-2;A++)p.adjustPadAndReturnShape(_[A+2],b[A],y[A],w[A],T,A,A+_.length-2,S)}}static computePoolOutputShape(_,b,y,w,T,S,A){if(b.length<=0)throw new Error("input shape must be of size greater than 0");const P=[b[0],b[1]];return p.computeShapeHelper(_,b,P,y,w,T,S,A),P}static computeConvOutputShape(_,b,y,w,T,S,A){if(_.length<=0||b.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const P=[_[0],b[0]];return p.computeShapeHelper(!1,_,P,y,w,T,S,A),P}static computeShapeHelper(_,b,y,w,T,S,A,P){if(_)for(let x=0;x{Object.defineProperty(t,"__esModule",{value:!0}),t.iterateExtraOptions=void 0,t.iterateExtraOptions=(i,s,u,d)=>{if(typeof i=="object"&&i!==null){if(u.has(i))throw new Error("Circular reference in options");u.add(i)}Object.entries(i).forEach(([a,h])=>{const f=s?s+a:a;if(typeof h=="object")(0,t.iterateExtraOptions)(h,f+".",u,d);else if(typeof h=="string"||typeof h=="number")d(f,h.toString());else{if(typeof h!="boolean")throw new Error("Can't handle extra config type: "+typeof h);d(f,h?"1":"0")}})}},2157:function(m,t,i){var s,u=this&&this.__createBinding||(Object.create?function(M,N,z,$){$===void 0&&($=z);var C=Object.getOwnPropertyDescriptor(N,z);C&&!("get"in C?!N.__esModule:C.writable||C.configurable)||(C={enumerable:!0,get:function(){return N[z]}}),Object.defineProperty(M,$,C)}:function(M,N,z,$){$===void 0&&($=z),M[$]=N[z]}),d=this&&this.__setModuleDefault||(Object.create?function(M,N){Object.defineProperty(M,"default",{enumerable:!0,value:N})}:function(M,N){M.default=N}),a=this&&this.__importStar||function(M){if(M&&M.__esModule)return M;var N={};if(M!=null)for(var z in M)z!=="default"&&Object.prototype.hasOwnProperty.call(M,z)&&u(N,M,z);return d(N,M),N};Object.defineProperty(t,"__esModule",{value:!0}),t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=t.initWasm=void 0;const h=i(1670),f=a(i(349)),c=i(6361),l=()=>!!h.env.wasm.proxy&&typeof document<"u";let n,e,r,o=!1,p=!1,g=!1;const _=[],b=[],y=[],w=[],T=[],S=[],A=()=>{if(o||!p||g||!n)throw new Error("worker not ready")},P=M=>{switch(M.data.type){case"init-wasm":o=!1,M.data.err?(g=!0,e[1](M.data.err)):(p=!0,e[0]());break;case"init-ort":M.data.err?r[1](M.data.err):r[0]();break;case"create_allocate":M.data.err?_.shift()[1](M.data.err):_.shift()[0](M.data.out);break;case"create_finalize":M.data.err?b.shift()[1](M.data.err):b.shift()[0](M.data.out);break;case"create":M.data.err?y.shift()[1](M.data.err):y.shift()[0](M.data.out);break;case"release":M.data.err?w.shift()[1](M.data.err):w.shift()[0]();break;case"run":M.data.err?T.shift()[1](M.data.err):T.shift()[0](M.data.out);break;case"end-profiling":M.data.err?S.shift()[1](M.data.err):S.shift()[0]()}},x=typeof document<"u"?(s=document==null?void 0:document.currentScript)===null||s===void 0?void 0:s.src:void 0;t.initWasm=async()=>{if(l()){if(p)return;if(o)throw new Error("multiple calls to 'initWasm()' detected.");if(g)throw new Error("previous call to 'initWasm()' failed.");return o=!0,h.env.wasm.wasmPaths===void 0&&x&&x.indexOf("blob:")!==0&&(h.env.wasm.wasmPaths=x.substr(0,+x.lastIndexOf("/")+1)),new Promise((M,N)=>{n==null||n.terminate(),n=i(9710).Z(),n.onmessage=P,e=[M,N];const z={type:"init-wasm",in:h.env.wasm};n.postMessage(z)})}return(0,c.initializeWebAssembly)(h.env.wasm)},t.initOrt=async(M,N)=>{if(l())return A(),new Promise((z,$)=>{r=[z,$];const C={type:"init-ort",in:{numThreads:M,loggingLevel:N}};n.postMessage(C)});f.initOrt(M,N)},t.createSessionAllocate=async M=>l()?(A(),new Promise((N,z)=>{_.push([N,z]);const $={type:"create_allocate",in:{model:M}};n.postMessage($,[M.buffer])})):f.createSessionAllocate(M),t.createSessionFinalize=async(M,N)=>l()?(A(),new Promise((z,$)=>{b.push([z,$]);const C={type:"create_finalize",in:{modeldata:M,options:N}};n.postMessage(C)})):f.createSessionFinalize(M,N),t.createSession=async(M,N)=>l()?(A(),new Promise((z,$)=>{y.push([z,$]);const C={type:"create",in:{model:M,options:N}};n.postMessage(C,[M.buffer])})):f.createSession(M,N),t.releaseSession=async M=>{if(l())return A(),new Promise((N,z)=>{w.push([N,z]);const $={type:"release",in:M};n.postMessage($)});f.releaseSession(M)},t.run=async(M,N,z,$,C)=>l()?(A(),new Promise((G,D)=>{T.push([G,D]);const R={type:"run",in:{sessionId:M,inputIndices:N,inputs:z,outputIndices:$,options:C}};n.postMessage(R,f.extractTransferableBuffers(z))})):f.run(M,N,z,$,C),t.endProfiling=async M=>{if(l())return A(),new Promise((N,z)=>{S.push([N,z]);const $={type:"end-profiling",in:M};n.postMessage($)});f.endProfiling(M)}},586:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const s=i(7967),u=i(4983),d=i(6361);t.setRunOptions=a=>{const h=(0,d.getInstance)();let f=0;const c=[],l=a||{};try{if((a==null?void 0:a.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof a.logSeverityLevel!="number"||!Number.isInteger(a.logSeverityLevel)||a.logSeverityLevel<0||a.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${a.logSeverityLevel}`);if((a==null?void 0:a.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof a.logVerbosityLevel!="number"||!Number.isInteger(a.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${a.logVerbosityLevel}`);(a==null?void 0:a.terminate)===void 0&&(l.terminate=!1);let n=0;if((a==null?void 0:a.tag)!==void 0&&(n=(0,u.allocWasmString)(a.tag,c)),f=h._OrtCreateRunOptions(l.logSeverityLevel,l.logVerbosityLevel,!!l.terminate,n),f===0)throw new Error("Can't create run options");return(a==null?void 0:a.extra)!==void 0&&(0,s.iterateExtraOptions)(a.extra,"",new WeakSet,(e,r)=>{const o=(0,u.allocWasmString)(e,c),p=(0,u.allocWasmString)(r,c);if(h._OrtAddRunConfigEntry(f,o,p)!==0)throw new Error(`Can't set a run config entry: ${e} - ${r}`)}),[f,c]}catch(n){throw f!==0&&h._OrtReleaseRunOptions(f),c.forEach(h._free),n}}},2306:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxruntimeWebAssemblySessionHandler=void 0;const s=i(2806),u=i(1670),d=i(2850),a=i(2157);let h;t.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(f){const c=await fetch(f),l=await c.arrayBuffer();return(0,a.createSessionAllocate)(new Uint8Array(l))}async loadModel(f,c){if(h||(await(0,a.initOrt)(u.env.wasm.numThreads,(l=>{switch(l){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${l}`)}})(u.env.logLevel)),h=!0),typeof f=="string")if(typeof fetch>"u"){const l=await(0,d.promisify)(s.readFile)(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(l,c)}else{const l=await this.createSessionAllocate(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSessionFinalize)(l,c)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(f,c)}async dispose(){return(0,a.releaseSession)(this.sessionId)}async run(f,c,l){const n=[],e=[];Object.entries(f).forEach(g=>{const _=g[0],b=g[1],y=this.inputNames.indexOf(_);if(y===-1)throw new Error(`invalid input '${_}'`);n.push(b),e.push(y)});const r=[];Object.entries(c).forEach(g=>{const _=g[0],b=this.outputNames.indexOf(_);if(b===-1)throw new Error(`invalid output '${_}'`);r.push(b)});const o=await(0,a.run)(this.sessionId,e,n.map(g=>[g.type,g.dims,g.data]),r,l),p={};for(let g=0;g{Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const s=i(7967),u=i(4983),d=i(6361);t.setSessionOptions=a=>{const h=(0,d.getInstance)();let f=0;const c=[],l=a||{};(n=>{n.extra||(n.extra={}),n.extra.session||(n.extra.session={});const e=n.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(l);try{(a==null?void 0:a.graphOptimizationLevel)===void 0&&(l.graphOptimizationLevel="all");const n=(o=>{switch(o){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${o}`)}})(l.graphOptimizationLevel);(a==null?void 0:a.enableCpuMemArena)===void 0&&(l.enableCpuMemArena=!0),(a==null?void 0:a.enableMemPattern)===void 0&&(l.enableMemPattern=!0),(a==null?void 0:a.executionMode)===void 0&&(l.executionMode="sequential");const e=(o=>{switch(o){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${o}`)}})(l.executionMode);let r=0;if((a==null?void 0:a.logId)!==void 0&&(r=(0,u.allocWasmString)(a.logId,c)),(a==null?void 0:a.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof a.logSeverityLevel!="number"||!Number.isInteger(a.logSeverityLevel)||a.logSeverityLevel<0||a.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${a.logSeverityLevel}`);if((a==null?void 0:a.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof a.logVerbosityLevel!="number"||!Number.isInteger(a.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${a.logVerbosityLevel}`);if((a==null?void 0:a.enableProfiling)===void 0&&(l.enableProfiling=!1),f=h._OrtCreateSessionOptions(n,!!l.enableCpuMemArena,!!l.enableMemPattern,e,!!l.enableProfiling,0,r,l.logSeverityLevel,l.logVerbosityLevel),f===0)throw new Error("Can't create session options");return a!=null&&a.executionProviders&&((o,p,g)=>{for(const _ of p){let b=typeof _=="string"?_:_.name;switch(b){case"xnnpack":b="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${b}`)}const y=(0,u.allocWasmString)(b,g);if((0,d.getInstance)()._OrtAppendExecutionProvider(o,y)!==0)throw new Error(`Can't append execution provider: ${b}`)}})(f,a.executionProviders,c),(a==null?void 0:a.extra)!==void 0&&(0,s.iterateExtraOptions)(a.extra,"",new WeakSet,(o,p)=>{const g=(0,u.allocWasmString)(o,c),_=(0,u.allocWasmString)(p,c);if(h._OrtAddSessionConfigEntry(f,g,_)!==0)throw new Error(`Can't set a session config entry: ${o} - ${p}`)}),[f,c]}catch(n){throw f!==0&&h._OrtReleaseSessionOptions(f),c.forEach(h._free),n}}},4983:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.allocWasmString=void 0;const s=i(6361);t.allocWasmString=(u,d)=>{const a=(0,s.getInstance)(),h=a.lengthBytesUTF8(u)+1,f=a._malloc(h);return a.stringToUTF8(u,f,h),d.push(f),f}},349:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractTransferableBuffers=t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=void 0;const s=i(586),u=i(4919),d=i(4983),a=i(6361);t.initOrt=(n,e)=>{const r=(0,a.getInstance)()._OrtInit(n,e);if(r!==0)throw new Error(`Can't initialize onnxruntime. error code = ${r}`)};const h=new Map;t.createSessionAllocate=n=>{const e=(0,a.getInstance)(),r=e._malloc(n.byteLength);return e.HEAPU8.set(n,r),[r,n.byteLength]},t.createSessionFinalize=(n,e)=>{const r=(0,a.getInstance)();let o=0,p=0,g=[];try{if([p,g]=(0,u.setSessionOptions)(e),o=r._OrtCreateSession(n[0],n[1],p),o===0)throw new Error("Can't create a session")}finally{r._free(n[0]),r._OrtReleaseSessionOptions(p),g.forEach(r._free)}const _=r._OrtGetInputCount(o),b=r._OrtGetOutputCount(o),y=[],w=[],T=[],S=[];for(let A=0;A<_;A++){const P=r._OrtGetInputName(o,A);if(P===0)throw new Error("Can't get an input name");w.push(P),y.push(r.UTF8ToString(P))}for(let A=0;A{const r=(0,t.createSessionAllocate)(n);return(0,t.createSessionFinalize)(r,e)},t.releaseSession=n=>{const e=(0,a.getInstance)(),r=h.get(n);if(!r)throw new Error("invalid session id");const o=r[0],p=r[1],g=r[2];p.forEach(e._OrtFree),g.forEach(e._OrtFree),e._OrtReleaseSession(o),h.delete(n)};const f=n=>{switch(n){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${n}`)}},c=n=>{switch(n){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${n}`)}},l=n=>{switch(n){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}};t.run=(n,e,r,o,p)=>{const g=(0,a.getInstance)(),_=h.get(n);if(!_)throw new Error("invalid session id");const b=_[0],y=_[1],w=_[2],T=e.length,S=o.length;let A=0,P=[];const x=[],M=[];try{[A,P]=(0,s.setRunOptions)(p);for(let D=0;Dg.HEAP32[xe++]=we);const se=g._OrtCreateTensor(f(R),J,Z,Ae,Y.length);if(se===0)throw new Error("Can't create a tensor");x.push(se)}finally{g.stackRestore(ue)}}const N=g.stackSave(),z=g.stackAlloc(4*T),$=g.stackAlloc(4*T),C=g.stackAlloc(4*S),G=g.stackAlloc(4*S);try{let D=z/4,R=$/4,Y=C/4,V=G/4;for(let ue=0;uePe*Be);if(we=c(Le),we==="string"){const Pe=[];let Be=be/4;for(let Ge=0;Ge{const e=(0,a.getInstance)(),r=h.get(n);if(!r)throw new Error("invalid session id");const o=r[0],p=e._OrtEndProfiling(o);if(p===0)throw new Error("Can't get an profile file name");e._OrtFree(p)},t.extractTransferableBuffers=n=>{const e=[];for(const r of n){const o=r[2];!Array.isArray(o)&&o.buffer&&e.push(o.buffer)}return e}},6361:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(p,g,_,b){b===void 0&&(b=_);var y=Object.getOwnPropertyDescriptor(g,_);y&&!("get"in y?!g.__esModule:y.writable||y.configurable)||(y={enumerable:!0,get:function(){return g[_]}}),Object.defineProperty(p,b,y)}:function(p,g,_,b){b===void 0&&(b=_),p[b]=g[_]}),u=this&&this.__setModuleDefault||(Object.create?function(p,g){Object.defineProperty(p,"default",{enumerable:!0,value:g})}:function(p,g){p.default=g}),d=this&&this.__importStar||function(p){if(p&&p.__esModule)return p;var g={};if(p!=null)for(var _ in p)_!=="default"&&Object.prototype.hasOwnProperty.call(p,_)&&s(g,p,_);return u(g,p),g},a=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const h=d(i(6449)),f=a(i(932)),c=i(3474);let l,n=!1,e=!1,r=!1;const o=(p,g)=>g?p?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":p?"ort-wasm-simd.wasm":"ort-wasm.wasm";t.initializeWebAssembly=async p=>{if(n)return Promise.resolve();if(e)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(r)throw new Error("previous call to 'initializeWebAssembly()' failed.");e=!0;const g=p.initTimeout,_=p.numThreads,b=p.simd,y=_>1&&(()=>{try{return typeof SharedArrayBuffer<"u"&&(typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch{return!1}})(),w=b&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}})(),T=typeof p.wasmPaths=="string"?p.wasmPaths:void 0,S=o(!1,y),A=o(w,y),P=typeof p.wasmPaths=="object"?p.wasmPaths[A]:void 0;let x=!1;const M=[];if(g>0&&M.push(new Promise(N=>{setTimeout(()=>{x=!0,N()},g)})),M.push(new Promise((N,z)=>{const $=y?c:f.default,C={locateFile:(G,D)=>y&&G.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([i(4154)],{type:"text/javascript"})):G===S?P??(T??D)+A:D+G};if(y)if(typeof Blob>"u")C.mainScriptUrlOrBlob=h.join("/","ort-wasm-threaded.js");else{const G=`var ortWasmThreaded=(function(){var _scriptDir;return ${$.toString()}})();`;C.mainScriptUrlOrBlob=new Blob([G],{type:"text/javascript"})}$(C).then(G=>{e=!1,n=!0,l=G,N()},G=>{e=!1,r=!0,z(G)})})),await Promise.race(M),x)throw new Error(`WebAssembly backend initializing failed due to timeout: ${g}ms`)},t.getInstance=()=>{if(n&&l)return l;throw new Error("WebAssembly is not initialized yet.")},t.dispose=()=>{var p;!n||e||r||(e=!0,(p=l.PThread)===null||p===void 0||p.terminateAllThreads(),l=void 0,e=!1,n=!1,r=!0)}},9710:(m,t,i)=>{i.d(t,{Z:()=>d});var s=i(477),u=i.n(s);function d(){return u()('/*!\n* ONNX Runtime Web v1.14.0\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var t={474:(t,e,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){function e(){return j.buffer!=D&&N(j.buffer),P}function r(){return j.buffer!=D&&N(j.buffer),U}function a(){return j.buffer!=D&&N(j.buffer),F}function i(){return j.buffer!=D&&N(j.buffer),I}function o(){return j.buffer!=D&&N(j.buffer),W}var u,c,s;t=t||{},u||(u=void 0!==t?t:{}),u.ready=new Promise((function(t,e){c=t,s=e}));var l,f,p,h,d,y,b=Object.assign({},u),m="./this.program",g=(t,e)=>{throw e},v="object"==typeof window,w="function"==typeof importScripts,_="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,O=u.ENVIRONMENT_IS_PTHREAD||!1,A="";function S(t){return u.locateFile?u.locateFile(t,A):A+t}if(_){let e;A=w?n(908).dirname(A)+"/":"//",y=()=>{d||(h=n(384),d=n(908))},l=function(t,e){return y(),t=d.normalize(t),h.readFileSync(t,e?void 0:"utf8")},p=t=>((t=l(t,!0)).buffer||(t=new Uint8Array(t)),t),f=(t,e,n)=>{y(),t=d.normalize(t),h.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1{if(Q())throw process.exitCode=t,e;e instanceof ct||x("exiting due to exception: "+e),process.exit(t)},u.inspect=function(){return"[Emscripten Module object]"};try{e=n(925)}catch(t){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),t}n.g.Worker=e.Worker}else(v||w)&&(w?A=self.location.href:"undefined"!=typeof document&&document.currentScript&&(A=document.currentScript.src),_scriptDir&&(A=_scriptDir),A=0!==A.indexOf("blob:")?A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):"",_||(l=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},w&&(p=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),f=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)}));_&&"undefined"==typeof performance&&(n.g.performance=n(953).performance);var T=console.log.bind(console),E=console.warn.bind(console);_&&(y(),T=t=>h.writeSync(1,t+"\\n"),E=t=>h.writeSync(2,t+"\\n"));var M,C=u.print||T,x=u.printErr||E;Object.assign(u,b),b=null,u.thisProgram&&(m=u.thisProgram),u.quit&&(g=u.quit),u.wasmBinary&&(M=u.wasmBinary);var R=u.noExitRuntime||!1;"object"!=typeof WebAssembly&&at("no native wasm support detected");var j,k,D,P,U,F,I,W,H=!1,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function Y(t,e){return(t>>>=0)?z(r(),t,e):""}function B(t,e,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function G(t){for(var e=0,n=0;n=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function N(t){D=t,u.HEAP8=P=new Int8Array(t),u.HEAP16=new Int16Array(t),u.HEAP32=F=new Int32Array(t),u.HEAPU8=U=new Uint8Array(t),u.HEAPU16=new Uint16Array(t),u.HEAPU32=I=new Uint32Array(t),u.HEAPF32=new Float32Array(t),u.HEAPF64=W=new Float64Array(t)}O&&(D=u.buffer);var V=u.INITIAL_MEMORY||16777216;if(O)j=u.wasmMemory,D=u.buffer;else if(u.wasmMemory)j=u.wasmMemory;else if(!((j=new WebAssembly.Memory({initial:V/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw x("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),_&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");j&&(D=j.buffer),V=D.byteLength,N(D);var $,q=[],X=[],J=[],Z=[];function Q(){return R||!1}function K(){var t=u.preRun.shift();q.unshift(t)}var tt,et=0,nt=null,rt=null;function at(t){throw O?postMessage({cmd:"onAbort",arg:t}):u.onAbort&&u.onAbort(t),x(t="Aborted("+t+")"),H=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),s(t),t}function it(){return tt.startsWith("data:application/octet-stream;base64,")}function ot(){var t=tt;try{if(t==tt&&M)return new Uint8Array(M);if(p)return p(t);throw"both async and sync fetching of the wasm failed"}catch(t){at(t)}}tt="ort-wasm-threaded.wasm",it()||(tt=S(tt));var ut={};function ct(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function st(t){(t=ht.Vb[t])||at(),ht.mc(t)}function lt(t){var e=ht.Cc();if(!e)return 6;ht.ac.push(e),ht.Vb[t.Ub]=e,e.Ub=t.Ub;var n={cmd:"run",start_routine:t.Ic,arg:t.zc,pthread_ptr:t.Ub};return e.$b=()=>{n.time=performance.now(),e.postMessage(n,t.Nc)},e.loaded&&(e.$b(),delete e.$b),0}function ft(t){if(O)return $t(1,1,t);Q()||(ht.oc(),u.onExit&&u.onExit(t),H=!0),g(t,new ct(t))}function pt(t,e){if(!e&&O)throw bt(t),"unwind";Q()||O||(me(),dt(J),be(0),re[1].length&&ae(1,10),re[2].length&&ae(2,10),ht.oc()),ft(t)}var ht={Yb:[],ac:[],qc:[],Vb:{},fc:function(){O&&ht.Ec()},Pc:function(){},Ec:function(){ht.receiveObjectTransfer=ht.Gc,ht.threadInitTLS=ht.pc,ht.setExitStatus=ht.nc,R=!1},nc:function(){},oc:function(){for(var t of Object.values(ht.Vb))ht.mc(t);for(t of ht.Yb)t.terminate();ht.Yb=[]},mc:function(t){var e=t.Ub;delete ht.Vb[e],ht.Yb.push(t),ht.ac.splice(ht.ac.indexOf(t),1),t.Ub=0,Oe(e)},Gc:function(){},pc:function(){ht.qc.forEach((t=>t()))},Fc:function(t,e){t.onmessage=n=>{var r=(n=n.data).cmd;if(t.Ub&&(ht.Bc=t.Ub),n.targetThread&&n.targetThread!=he()){var a=ht.Vb[n.Qc];a?a.postMessage(n,n.transferList):x(\'Internal error! Worker sent a message "\'+r+\'" to target pthread \'+n.targetThread+", but that thread no longer exists!")}else"processProxyingQueue"===r?zt(n.queue):"spawnThread"===r?lt(n):"cleanupThread"===r?st(n.thread):"killThread"===r?(n=n.thread,r=ht.Vb[n],delete ht.Vb[n],r.terminate(),Oe(n),ht.ac.splice(ht.ac.indexOf(r),1),r.Ub=0):"cancelThread"===r?ht.Vb[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(t.loaded=!0,e&&e(t),t.$b&&(t.$b(),delete t.$b)):"print"===r?C("Thread "+n.threadId+": "+n.text):"printErr"===r?x("Thread "+n.threadId+": "+n.text):"alert"===r?alert("Thread "+n.threadId+": "+n.text):"setimmediate"===n.target?t.postMessage(n):"onAbort"===r?u.onAbort&&u.onAbort(n.arg):r&&x("worker sent an unknown command "+r);ht.Bc=void 0},t.onerror=t=>{throw x("worker sent an error! "+t.filename+":"+t.lineno+": "+t.message),t},_&&(t.on("message",(function(e){t.onmessage({data:e})})),t.on("error",(function(e){t.onerror(e)})),t.on("detachedExit",(function(){}))),t.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||_scriptDir,wasmMemory:j,wasmModule:k})},yc:function(){var t=S("ort-wasm-threaded.worker.js");ht.Yb.push(new Worker(t))},Cc:function(){return 0==ht.Yb.length&&(ht.yc(),ht.Fc(ht.Yb[0])),ht.Yb.pop()}};function dt(t){for(;0>2>>>0];t=a()[t+48>>2>>>0],Te(e,e-t),Me(e)};var mt=[];function gt(t){var e=mt[t];return e||(t>=mt.length&&(mt.length=t+1),mt[t]=e=$.get(t)),e}u.invokeEntryPoint=function(t,e){t=gt(t)(e),Q()?ht.nc(t):Ae(t)};var vt,wt,_t=[],Ot=0,At=0;function St(t){this.Zb=t,this.Sb=t-24,this.xc=function(t){i()[this.Sb+4>>2>>>0]=t},this.bc=function(){return i()[this.Sb+4>>2>>>0]},this.wc=function(t){i()[this.Sb+8>>2>>>0]=t},this.Dc=function(){return i()[this.Sb+8>>2>>>0]},this.rc=function(){a()[this.Sb>>2>>>0]=0},this.hc=function(t){t=t?1:0,e()[this.Sb+12>>0>>>0]=t},this.uc=function(){return 0!=e()[this.Sb+12>>0>>>0]},this.ic=function(t){t=t?1:0,e()[this.Sb+13>>0>>>0]=t},this.kc=function(){return 0!=e()[this.Sb+13>>0>>>0]},this.fc=function(t,e){this.cc(0),this.xc(t),this.wc(e),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(a(),this.Sb>>2,1)},this.Hc=function(){return 1===Atomics.sub(a(),this.Sb>>2,1)},this.cc=function(t){i()[this.Sb+16>>2>>>0]=t},this.tc=function(){return i()[this.Sb+16>>2>>>0]},this.vc=function(){if(Re(this.bc()))return i()[this.Zb>>2>>>0];var t=this.tc();return 0!==t?t:this.Zb}}function Tt(t){return ye(new St(t).Sb)}function Et(t,e,n,r){return O?$t(3,1,t,e,n,r):Mt(t,e,n,r)}function Mt(t,e,n,r){if("undefined"==typeof SharedArrayBuffer)return x("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return O&&0===a.length?Et(t,e,n,r):(t={Ic:n,Ub:t,zc:r,Nc:a},O?(t.Oc="spawnThread",postMessage(t,a),0):lt(t))}function Ct(t,e,n){return O?$t(4,1,t,e,n):0}function xt(t,e){if(O)return $t(5,1,t,e)}function Rt(t,e){if(O)return $t(6,1,t,e)}function jt(t,e,n){if(O)return $t(7,1,t,e,n)}function kt(t,e,n){return O?$t(8,1,t,e,n):0}function Dt(t,e){if(O)return $t(9,1,t,e)}function Pt(t,e,n){if(O)return $t(10,1,t,e,n)}function Ut(t,e,n,r){if(O)return $t(11,1,t,e,n,r)}function Ft(t,e,n,r){if(O)return $t(12,1,t,e,n,r)}function It(t,e,n,r){if(O)return $t(13,1,t,e,n,r)}function Wt(t){if(O)return $t(14,1,t)}function Ht(t,e){if(O)return $t(15,1,t,e)}function Lt(t,e,n){if(O)return $t(16,1,t,e,n)}function zt(t){Atomics.store(a(),t>>2,1),he()&&_e(t),Atomics.compareExchange(a(),t>>2,1,0)}function Yt(t){return i()[t>>>2]+4294967296*a()[t+4>>>2]}function Bt(t,e,n,r,a,i){return O?$t(17,1,t,e,n,r,a,i):-52}function Gt(t,e,n,r,a,i){if(O)return $t(18,1,t,e,n,r,a,i)}function Nt(t){var n=G(t)+1,r=de(n);return r&&B(t,e(),r,n),r}function Vt(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}if(O)return $t(19,1,t,e,n);var o=(new Date).getFullYear(),u=new Date(o,0,1),c=new Date(o,6,1);o=u.getTimezoneOffset();var s=c.getTimezoneOffset(),l=Math.max(o,s);a()[t>>2>>>0]=60*l,a()[e>>2>>>0]=Number(o!=s),t=r(u),e=r(c),t=Nt(t),e=Nt(e),s>2>>>0]=t,i()[n+4>>2>>>0]=e):(i()[n>>2>>>0]=e,i()[n+4>>2>>>0]=t)}function $t(t,e){var n=arguments.length-2,r=arguments;return yt((()=>{for(var a=Ce(8*n),i=a>>3,u=0;u>>0]=c}return we(t,n,a,e)}))}u.executeNotifiedProxyingQueue=zt,wt=_?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:O?()=>performance.now()-u.__performance_now_clock_drift:()=>performance.now();var qt,Xt=[],Jt={};function Zt(){if(!qt){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"};for(t in Jt)void 0===Jt[t]?delete e[t]:e[t]=Jt[t];var n=[];for(t in e)n.push(t+"="+e[t]);qt=n}return qt}function Qt(t,n){if(O)return $t(20,1,t,n);var r=0;return Zt().forEach((function(a,o){var u=n+r;for(o=i()[t+4*o>>2>>>0]=u,u=0;u>0>>>0]=a.charCodeAt(u);e()[o>>0>>>0]=0,r+=a.length+1})),0}function Kt(t,e){if(O)return $t(21,1,t,e);var n=Zt();i()[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),i()[e>>2>>>0]=r,0}function te(t){return O?$t(22,1,t):52}function ee(t,e,n,r){return O?$t(23,1,t,e,n,r):52}function ne(t,e,n,r,a){return O?$t(24,1,t,e,n,r,a):70}var re=[null,[],[]];function ae(t,e){var n=re[t];0===e||10===e?((1===t?C:x)(z(n,0)),n.length=0):n.push(e)}function ie(t,e,n,a){if(O)return $t(25,1,t,e,n,a);for(var o=0,u=0;u>2>>>0],s=i()[e+4>>2>>>0];e+=8;for(var l=0;l>>0]);o+=s}return i()[a>>2>>>0]=o,0}var oe=0;function ue(t){return 0==t%4&&(0!=t%100||0==t%400)}var ce=[31,29,31,30,31,30,31,31,30,31,30,31],se=[31,28,31,30,31,30,31,31,30,31,30,31];function le(t,n,r,i){function o(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.lengtht?-1:0r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=s(new Date(t.getFullYear(),0,4)),n=s(n),0>=c(e,t)?0>=c(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var f=a()[i+40>>2>>>0];for(var p in i={Lc:a()[i>>2>>>0],Kc:a()[i+4>>2>>>0],dc:a()[i+8>>2>>>0],jc:a()[i+12>>2>>>0],ec:a()[i+16>>2>>>0],Xb:a()[i+20>>2>>>0],Tb:a()[i+24>>2>>>0],Wb:a()[i+28>>2>>>0],Rc:a()[i+32>>2>>>0],Jc:a()[i+36>>2>>>0],Mc:f?Y(f):""},r=Y(r),f={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(p,"g"),f[p]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(p in f={"%a":function(t){return h[t.Tb].substring(0,3)},"%A":function(t){return h[t.Tb]},"%b":function(t){return d[t.ec].substring(0,3)},"%B":function(t){return d[t.ec]},"%C":function(t){return u((t.Xb+1900)/100|0,2)},"%d":function(t){return u(t.jc,2)},"%e":function(t){return o(t.jc,2," ")},"%g":function(t){return l(t).toString().substring(2)},"%G":function(t){return l(t)},"%H":function(t){return u(t.dc,2)},"%I":function(t){return 0==(t=t.dc)?t=12:12t.dc?"AM":"PM"},"%S":function(t){return u(t.Lc,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Tb||7},"%U":function(t){return u(Math.floor((t.Wb+7-t.Tb)/7),2)},"%V":function(t){var e=Math.floor((t.Wb+7-(t.Tb+6)%7)/7);if(2>=(t.Tb+371-t.Wb-2)%7&&e++,e)53==e&&(4==(n=(t.Tb+371-t.Wb)%7)||3==n&&ue(t.Xb)||(e=1));else{e=52;var n=(t.Tb+7-t.Wb-1)%7;(4==n||5==n&&ue(t.Xb%400-1))&&e++}return u(e,2)},"%w":function(t){return t.Tb},"%W":function(t){return u(Math.floor((t.Wb+7-(t.Tb+6)%7)/7),2)},"%y":function(t){return(t.Xb+1900).toString().substring(2)},"%Y":function(t){return t.Xb+1900},"%z":function(t){var e=0<=(t=t.Jc);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.Mc},"%%":function(){return"%"}},r=r.replace(/%%/g,"\\0\\0"),f)r.includes(p)&&(r=r.replace(new RegExp(p,"g"),f[p](i)));return p=function(t){var e=Array(G(t)+1);return B(t,e,0,e.length),e}(r=r.replace(/\\0\\0/g,"%")),p.length>n?0:(function(t,n){e().set(t,n>>>0)}(p,t),p.length-1)}ht.fc();var fe=[null,ft,bt,Et,Ct,xt,Rt,jt,kt,Dt,Pt,Ut,Ft,It,Wt,Ht,Lt,Bt,Gt,Vt,Qt,Kt,te,ee,ne,ie],pe={b:function(t){return de(t+24)+24},n:function(t){return(t=new St(t)).uc()||(t.hc(!0),Ot--),t.ic(!1),_t.push(t),t.sc(),t.vc()},ma:function(t){throw x("Unexpected exception thrown, this is not properly supported - aborting"),H=!0,t},x:function(){Se(0);var t=_t.pop();if(t.Hc()&&!t.kc()){var e=t.Dc();e&>(e)(t.Zb),Tt(t.Zb)}At=0},e:function(){var t=At;if(!t)return oe=0;var e=new St(t);e.cc(t);var n=e.bc();if(!n)return oe=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;azt(r)));else if(O)postMessage({targetThread:t,cmd:"processProxyingQueue",queue:r});else{if(!(t=ht.Vb[t]))return;t.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},Ea:function(){return-1},Pa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getUTCSeconds(),a()[e+4>>2>>>0]=t.getUTCMinutes(),a()[e+8>>2>>>0]=t.getUTCHours(),a()[e+12>>2>>>0]=t.getUTCDate(),a()[e+16>>2>>>0]=t.getUTCMonth(),a()[e+20>>2>>>0]=t.getUTCFullYear()-1900,a()[e+24>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[e+28>>2>>>0]=t},Qa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),a()[e+20>>2>>>0]=t.getFullYear()-1900,a()[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1),r=(t.getTime()-n.getTime())/864e5|0;a()[e+28>>2>>>0]=r,a()[e+36>>2>>>0]=-60*t.getTimezoneOffset(),r=new Date(t.getFullYear(),6,1).getTimezoneOffset(),t=0|(r!=(n=n.getTimezoneOffset())&&t.getTimezoneOffset()==Math.min(n,r)),a()[e+32>>2>>>0]=t},Ra:function(t){var e=new Date(a()[t+20>>2>>>0]+1900,a()[t+16>>2>>>0],a()[t+12>>2>>>0],a()[t+8>>2>>>0],a()[t+4>>2>>>0],a()[t>>2>>>0],0),n=a()[t+32>>2>>>0],r=e.getTimezoneOffset(),i=new Date(e.getFullYear(),0,1),o=new Date(e.getFullYear(),6,1).getTimezoneOffset(),u=i.getTimezoneOffset(),c=Math.min(u,o);return 0>n?a()[t+32>>2>>>0]=Number(o!=u&&c==r):0>2>>>0]=e.getDay(),n=(e.getTime()-i.getTime())/864e5|0,a()[t+28>>2>>>0]=n,a()[t>>2>>>0]=e.getSeconds(),a()[t+4>>2>>>0]=e.getMinutes(),a()[t+8>>2>>>0]=e.getHours(),a()[t+12>>2>>>0]=e.getDate(),a()[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},Aa:Bt,Ba:Gt,Sa:function t(e,n,r){t.Ac||(t.Ac=!0,Vt(e,n,r))},y:function(){at("")},U:function(){if(!_&&!w){var t="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";vt||(vt={}),vt[t]||(vt[t]=1,_&&(t="warning: "+t),x(t))}},ra:function(){return 4294901760},B:wt,Ia:function(t,e,n){r().copyWithin(t>>>0,e>>>0,e+n>>>0)},F:function(){return _?n(993).cpus().length:navigator.hardwareConcurrency},Da:function(t,e,n){Xt.length=e,n>>=3;for(var r=0;r>>0];return(0>t?ut[-t-1]:fe[t]).apply(null,Xt)},qa:function(t){var e=r().length;if((t>>>=0)<=e||4294901760=n;n*=2){var a=e*(1+.2/n);a=Math.min(a,t+100663296);var i=Math;a=Math.max(t,a),i=i.min.call(i,4294901760,a+(65536-a%65536)%65536);t:{try{j.grow(i-D.byteLength+65535>>>16),N(j.buffer);var o=1;break t}catch(t){}o=void 0}if(o)return!0}return!1},Na:function(){throw"unwind"},Ga:Qt,Ha:Kt,J:pt,I:te,S:ee,ga:ne,R:ie,d:function(){return oe},na:function t(r,a){t.lc||(t.lc=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(_)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>at("randomDevice")}());for(var i=0;i>0>>>0]=t.lc();return 0},ia:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ja:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},K:function(t){var e=Ee();try{return gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},f:function(t,e){var n=Ee();try{return gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},P:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},Q:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},k:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},p:function(t,e,n,r){var a=Ee();try{return gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},q:function(t,e,n,r,a){var i=Ee();try{return gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},N:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},s:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},w:function(t,e,n,r,a,i,o){var u=Ee();try{return gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},L:function(t,e,n,r,a,i,o,u){var c=Ee();try{return gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},E:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{return gt(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=Ee();try{return He(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},_:function(t,e,n,r,a,i,o){var u=Ee();try{return ke(t,e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},Z:function(t,e,n,r,a){var i=Ee();try{return Le(t,e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},ca:function(t,e,n,r){var a=Ee();try{return Ie(t,e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},$:function(t){var e=Ee();try{return je(t)}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},ba:function(t,e){var n=Ee();try{return We(t,e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},Y:function(t,e,n){var r=Ee();try{return De(t,e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},g:function(t){var e=Ee();try{gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},r:function(t,e){var n=Ee();try{gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},i:function(t,e,n){var r=Ee();try{gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ha:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},m:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},v:function(t,e,n,r,a){var i=Ee();try{gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},u:function(t,e,n,r,a,i){var o=Ee();try{gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},O:function(t,e,n,r,a,i,o){var u=Ee();try{gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},A:function(t,e,n,r,a,i,o,u){var c=Ee();try{gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},ka:function(t,e,n,r,a,i,o,u,c){var s=Ee();try{gt(t)(e,n,r,a,i,o,u,c)}catch(t){if(Me(s),t!==t+0)throw t;Se(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l){var f=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(Me(f),t!==t+0)throw t;Se(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(Me(b),t!==t+0)throw t;Se(1,0)}},fa:function(t,e,n,r,a,i,o,u){var c=Ee();try{Pe(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},da:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{Fe(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},ea:function(t,e,n,r,a,i){var o=Ee();try{Ue(t,e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},o:function(t){return t},a:j||u.wasmMemory,G:function(t){oe=t},la:le,z:function(t,e,n,r){return le(t,e,n,r)}};!function(){function t(t,e){u.asm=t.exports,ht.qc.push(u.asm.sb),$=u.asm.ub,X.unshift(u.asm.Va),k=e,O||(et--,u.monitorRunDependencies&&u.monitorRunDependencies(et),0==et&&(null!==nt&&(clearInterval(nt),nt=null),rt&&(t=rt,rt=null,t())))}function e(e){t(e.instance,e.module)}function n(t){return function(){if(!M&&(v||w)){if("function"==typeof fetch&&!tt.startsWith("file://"))return fetch(tt,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+tt+"\'";return t.arrayBuffer()})).catch((function(){return ot()}));if(f)return new Promise((function(t,e){f(tt,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return ot()}))}().then((function(t){return WebAssembly.instantiate(t,r)})).then((function(t){return t})).then(t,(function(t){x("failed to asynchronously prepare wasm: "+t),at(t)}))}var r={a:pe};if(O||(et++,u.monitorRunDependencies&&u.monitorRunDependencies(et)),u.instantiateWasm)try{return u.instantiateWasm(r,t)}catch(t){return x("Module.instantiateWasm callback failed with error: "+t),!1}(M||"function"!=typeof WebAssembly.instantiateStreaming||it()||tt.startsWith("file://")||_||"function"!=typeof fetch?n(e):fetch(tt,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,r).then(e,(function(t){return x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation"),n(e)}))}))).catch(s)}(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.Va).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.Wa).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.Xa).apply(null,arguments)},u._OrtAppendExecutionProvider=function(){return(u._OrtAppendExecutionProvider=u.asm.Ya).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.Za).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm._a).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.$a).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.ab).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.bb).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.cb).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.db).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.eb).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.fb).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.gb).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.hb).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm.ib).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.jb).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.kb).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.lb).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.mb).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.nb).apply(null,arguments)};var he=u._pthread_self=function(){return(he=u._pthread_self=u.asm.ob).apply(null,arguments)},de=u._malloc=function(){return(de=u._malloc=u.asm.pb).apply(null,arguments)},ye=u._free=function(){return(ye=u._free=u.asm.qb).apply(null,arguments)},be=u._fflush=function(){return(be=u._fflush=u.asm.rb).apply(null,arguments)};u.__emscripten_tls_init=function(){return(u.__emscripten_tls_init=u.asm.sb).apply(null,arguments)};var me=u.___funcs_on_exit=function(){return(me=u.___funcs_on_exit=u.asm.tb).apply(null,arguments)},ge=u.__emscripten_thread_init=function(){return(ge=u.__emscripten_thread_init=u.asm.vb).apply(null,arguments)};u.__emscripten_thread_crashed=function(){return(u.__emscripten_thread_crashed=u.asm.wb).apply(null,arguments)};var ve,we=u._emscripten_run_in_main_runtime_thread_js=function(){return(we=u._emscripten_run_in_main_runtime_thread_js=u.asm.xb).apply(null,arguments)},_e=u.__emscripten_proxy_execute_task_queue=function(){return(_e=u.__emscripten_proxy_execute_task_queue=u.asm.yb).apply(null,arguments)},Oe=u.__emscripten_thread_free_data=function(){return(Oe=u.__emscripten_thread_free_data=u.asm.zb).apply(null,arguments)},Ae=u.__emscripten_thread_exit=function(){return(Ae=u.__emscripten_thread_exit=u.asm.Ab).apply(null,arguments)},Se=u._setThrew=function(){return(Se=u._setThrew=u.asm.Bb).apply(null,arguments)},Te=u._emscripten_stack_set_limits=function(){return(Te=u._emscripten_stack_set_limits=u.asm.Cb).apply(null,arguments)},Ee=u.stackSave=function(){return(Ee=u.stackSave=u.asm.Db).apply(null,arguments)},Me=u.stackRestore=function(){return(Me=u.stackRestore=u.asm.Eb).apply(null,arguments)},Ce=u.stackAlloc=function(){return(Ce=u.stackAlloc=u.asm.Fb).apply(null,arguments)},xe=u.___cxa_can_catch=function(){return(xe=u.___cxa_can_catch=u.asm.Gb).apply(null,arguments)},Re=u.___cxa_is_pointer_type=function(){return(Re=u.___cxa_is_pointer_type=u.asm.Hb).apply(null,arguments)},je=u.dynCall_j=function(){return(je=u.dynCall_j=u.asm.Ib).apply(null,arguments)},ke=u.dynCall_iiiiij=function(){return(ke=u.dynCall_iiiiij=u.asm.Jb).apply(null,arguments)},De=u.dynCall_jii=function(){return(De=u.dynCall_jii=u.asm.Kb).apply(null,arguments)},Pe=u.dynCall_viiiiij=function(){return(Pe=u.dynCall_viiiiij=u.asm.Lb).apply(null,arguments)},Ue=u.dynCall_vjji=function(){return(Ue=u.dynCall_vjji=u.asm.Mb).apply(null,arguments)},Fe=u.dynCall_viiijjjii=function(){return(Fe=u.dynCall_viiijjjii=u.asm.Nb).apply(null,arguments)},Ie=u.dynCall_iij=function(){return(Ie=u.dynCall_iij=u.asm.Ob).apply(null,arguments)},We=u.dynCall_ji=function(){return(We=u.dynCall_ji=u.asm.Pb).apply(null,arguments)},He=u.dynCall_iiiiiij=function(){return(He=u.dynCall_iiiiiij=u.asm.Qb).apply(null,arguments)},Le=u.dynCall_iiij=function(){return(Le=u.dynCall_iiij=u.asm.Rb).apply(null,arguments)};function ze(){function t(){if(!ve&&(ve=!0,u.calledRun=!0,!H)&&(O||dt(X),c(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),!O)){if(u.postRun)for("function"==typeof u.postRun&&(u.postRun=[u.postRun]);u.postRun.length;){var t=u.postRun.shift();Z.unshift(t)}dt(Z)}}if(!(0{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){var e,r,a;t=t||{},e||(e=void 0!==t?t:{}),e.ready=new Promise((function(t,e){r=t,a=e}));var i,o,u,c,s,l,f=Object.assign({},e),p="./this.program",h=(t,e)=>{throw e},d="object"==typeof window,y="function"==typeof importScripts,b="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,m="";b?(m=y?n(908).dirname(m)+"/":"//",l=()=>{s||(c=n(384),s=n(908))},i=function(t,e){return l(),t=s.normalize(t),c.readFileSync(t,e?void 0:"utf8")},u=t=>((t=i(t,!0)).buffer||(t=new Uint8Array(t)),t),o=(t,e,n)=>{l(),t=s.normalize(t),c.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1{if(_||0{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},y&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),o=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var g,v=e.print||console.log.bind(console),w=e.printErr||console.warn.bind(console);Object.assign(e,f),f=null,e.thisProgram&&(p=e.thisProgram),e.quit&&(h=e.quit),e.wasmBinary&&(g=e.wasmBinary);var _=e.noExitRuntime||!1;"object"!=typeof WebAssembly&&V("no native wasm support detected");var O,A,S,T,E,M,C=!1,x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function R(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function j(t,e){return(t>>>=0)?R(T,t,e):""}function k(t,e,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function D(t){for(var e=0,n=0;n=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function P(){var t=O.buffer;A=t,e.HEAP8=S=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=E=new Int32Array(t),e.HEAPU8=T=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=M=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}var U,F=[],I=[],W=[],H=[],L=0;function z(){var t=e.preRun.shift();F.unshift(t)}var Y,B=0,G=null,N=null;function V(t){throw e.onAbort&&e.onAbort(t),w(t="Aborted("+t+")"),C=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),a(t),t}function $(){return Y.startsWith("data:application/octet-stream;base64,")}if(Y="ort-wasm.wasm",!$()){var q=Y;Y=e.locateFile?e.locateFile(q,m):m+q}function X(){var t=Y;try{if(t==Y&&g)return new Uint8Array(g);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){V(t)}}function J(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Z(t){for(;0>2>>>0]=t},this.Eb=function(){return M[this.zb+4>>2>>>0]},this.Sb=function(t){M[this.zb+8>>2>>>0]=t},this.Wb=function(){return M[this.zb+8>>2>>>0]},this.Tb=function(){E[this.zb>>2>>>0]=0},this.Ib=function(t){S[this.zb+12>>0>>>0]=t?1:0},this.Pb=function(){return 0!=S[this.zb+12>>0>>>0]},this.Jb=function(t){S[this.zb+13>>0>>>0]=t?1:0},this.Lb=function(){return 0!=S[this.zb+13>>0>>>0]},this.Rb=function(t,e){this.Fb(0),this.Ub(t),this.Sb(e),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){E[this.zb>>2>>>0]+=1},this.Xb=function(){var t=E[this.zb>>2>>>0];return E[this.zb>>2>>>0]=t-1,1===t},this.Fb=function(t){M[this.zb+16>>2>>>0]=t},this.Ob=function(){return M[this.zb+16>>2>>>0]},this.Qb=function(){if(Mt(this.Eb()))return M[this.Db>>2>>>0];var t=this.Ob();return 0!==t?t:this.Db}}function nt(t){return vt(new et(t).zb)}var rt=[];function at(t){var e=rt[t];return e||(t>=rt.length&&(rt.length=t+1),rt[t]=e=U.get(t)),e}function it(t){var e=D(t)+1,n=gt(e);return n&&k(t,S,n,e),n}var ot={};function ut(){if(!ct){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:p||"./this.program"};for(t in ot)void 0===ot[t]?delete e[t]:e[t]=ot[t];var n=[];for(t in e)n.push(t+"="+e[t]);ct=n}return ct}var ct,st=[null,[],[]];function lt(t,e){var n=st[t];0===e||10===e?((1===t?v:w)(R(n,0)),n.length=0):n.push(e)}var ft=0;function pt(t){return 0==t%4&&(0!=t%100||0==t%400)}var ht=[31,29,31,30,31,30,31,31,30,31,30,31],dt=[31,28,31,30,31,30,31,31,30,31,30,31];function yt(t,e,n,r){function a(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.lengtht?-1:0r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=u(new Date(t.getFullYear(),0,4)),n=u(n),0>=o(e,t)?0>=o(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var s=E[r+40>>2>>>0];for(var l in r={$b:E[r>>2>>>0],Zb:E[r+4>>2>>>0],Gb:E[r+8>>2>>>0],Kb:E[r+12>>2>>>0],Hb:E[r+16>>2>>>0],Cb:E[r+20>>2>>>0],Ab:E[r+24>>2>>>0],Bb:E[r+28>>2>>>0],bc:E[r+32>>2>>>0],Yb:E[r+36>>2>>>0],ac:s?j(s):""},n=j(n),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(l,"g"),s[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(l in s={"%a":function(t){return f[t.Ab].substring(0,3)},"%A":function(t){return f[t.Ab]},"%b":function(t){return p[t.Hb].substring(0,3)},"%B":function(t){return p[t.Hb]},"%C":function(t){return i((t.Cb+1900)/100|0,2)},"%d":function(t){return i(t.Kb,2)},"%e":function(t){return a(t.Kb,2," ")},"%g":function(t){return c(t).toString().substring(2)},"%G":function(t){return c(t)},"%H":function(t){return i(t.Gb,2)},"%I":function(t){return 0==(t=t.Gb)?t=12:12t.Gb?"AM":"PM"},"%S":function(t){return i(t.$b,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Ab||7},"%U":function(t){return i(Math.floor((t.Bb+7-t.Ab)/7),2)},"%V":function(t){var e=Math.floor((t.Bb+7-(t.Ab+6)%7)/7);if(2>=(t.Ab+371-t.Bb-2)%7&&e++,e)53==e&&(4==(n=(t.Ab+371-t.Bb)%7)||3==n&&pt(t.Cb)||(e=1));else{e=52;var n=(t.Ab+7-t.Bb-1)%7;(4==n||5==n&&pt(t.Cb%400-1))&&e++}return i(e,2)},"%w":function(t){return t.Ab},"%W":function(t){return i(Math.floor((t.Bb+7-(t.Ab+6)%7)/7),2)},"%y":function(t){return(t.Cb+1900).toString().substring(2)},"%Y":function(t){return t.Cb+1900},"%z":function(t){var e=0<=(t=t.Yb);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.ac},"%%":function(){return"%"}},n=n.replace(/%%/g,"\\0\\0"),s)n.includes(l)&&(n=n.replace(new RegExp(l,"g"),s[l](r)));return l=function(t){var e=Array(D(t)+1);return k(t,e,0,e.length),e}(n=n.replace(/\\0\\0/g,"%")),l.length>e?0:(S.set(l,t>>>0),l.length-1)}var bt={a:function(t){return gt(t+24)+24},m:function(t){return(t=new et(t)).Pb()||(t.Ib(!0),K--),t.Jb(!1),Q.push(t),t.Nb(),t.Qb()},ia:function(t){throw w("Unexpected exception thrown, this is not properly supported - aborting"),C=!0,t},w:function(){Ot(0);var t=Q.pop();if(t.Xb()&&!t.Lb()){var e=t.Wb();e&&at(e)(t.Db),nt(t.Db)}tt=0},d:function(){var t=tt;if(!t)return ft=0;var e=new et(t);e.Fb(t);var n=e.Eb();if(!n)return ft=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getUTCSeconds(),E[e+4>>2>>>0]=t.getUTCMinutes(),E[e+8>>2>>>0]=t.getUTCHours(),E[e+12>>2>>>0]=t.getUTCDate(),E[e+16>>2>>>0]=t.getUTCMonth(),E[e+20>>2>>>0]=t.getUTCFullYear()-1900,E[e+24>>2>>>0]=t.getUTCDay(),E[e+28>>2>>>0]=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(t,e){t=new Date(1e3*(M[t>>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getSeconds(),E[e+4>>2>>>0]=t.getMinutes(),E[e+8>>2>>>0]=t.getHours(),E[e+12>>2>>>0]=t.getDate(),E[e+16>>2>>>0]=t.getMonth(),E[e+20>>2>>>0]=t.getFullYear()-1900,E[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1);E[e+28>>2>>>0]=(t.getTime()-n.getTime())/864e5|0,E[e+36>>2>>>0]=-60*t.getTimezoneOffset();var r=new Date(t.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),E[e+32>>2>>>0]=0|(r!=n&&t.getTimezoneOffset()==Math.min(n,r))},Fa:function(t){var e=new Date(E[t+20>>2>>>0]+1900,E[t+16>>2>>>0],E[t+12>>2>>>0],E[t+8>>2>>>0],E[t+4>>2>>>0],E[t>>2>>>0],0),n=E[t+32>>2>>>0],r=e.getTimezoneOffset(),a=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear(),6,1).getTimezoneOffset(),o=a.getTimezoneOffset(),u=Math.min(o,i);return 0>n?E[t+32>>2>>>0]=Number(i!=o&&u==r):0>2>>>0]=e.getDay(),E[t+28>>2>>>0]=(e.getTime()-a.getTime())/864e5|0,E[t>>2>>>0]=e.getSeconds(),E[t+4>>2>>>0]=e.getMinutes(),E[t+8>>2>>>0]=e.getHours(),E[t+12>>2>>>0]=e.getDate(),E[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function t(e,n,r){t.Vb||(t.Vb=!0,function(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}var a=(new Date).getFullYear(),i=new Date(a,0,1),o=new Date(a,6,1);a=i.getTimezoneOffset();var u=o.getTimezoneOffset();E[t>>2>>>0]=60*Math.max(a,u),E[e>>2>>>0]=Number(a!=u),t=r(i),e=r(o),t=it(t),e=it(e),u>2>>>0]=t,M[n+4>>2>>>0]=e):(M[n>>2>>>0]=e,M[n+4>>2>>>0]=t)}(e,n,r))},B:function(){V("")},ma:function(){return 4294901760},I:b?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:()=>performance.now(),xa:function(t,e,n){T.copyWithin(t>>>0,e>>>0,e+n>>>0)},G:function(t){var e=T.length;if(4294901760<(t>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=e*(1+.2/n);r=Math.min(r,t+100663296);var a=Math;r=Math.max(t,r),a=a.min.call(a,4294901760,r+(65536-r%65536)%65536);t:{try{O.grow(a-A.byteLength+65535>>>16),P();var i=1;break t}catch(t){}i=void 0}if(i)return!0}return!1},va:function(t,e){var n=0;return ut().forEach((function(r,a){var i=e+n;for(a=M[t+4*a>>2>>>0]=i,i=0;i>0>>>0]=r.charCodeAt(i);S[a>>0>>>0]=0,n+=r.length+1})),0},wa:function(t,e){var n=ut();M[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),M[e>>2>>>0]=r,0},ba:function(t){_||0>2>>>0],u=M[e+4>>2>>>0];e+=8;for(var c=0;c>>0]);a+=u}return M[r>>2>>>0]=a,0},c:function(){return ft},ja:function t(e,r){t.Mb||(t.Mb=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(b)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>V("randomDevice")}());for(var a=0;a>0>>>0]=t.Mb();return 0},ea:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},fa:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},J:function(t){var e=At();try{return at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},e:function(t,e){var n=At();try{return at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},N:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},O:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},j:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},o:function(t,e,n,r){var a=At();try{return at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},p:function(t,e,n,r,a){var i=At();try{return at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},M:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},r:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},v:function(t,e,n,r,a,i,o){var u=At();try{return at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},K:function(t,e,n,r,a,i,o,u){var c=At();try{return at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{return at(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},X:function(t,e,n,r,a,i,o,u){var c=At();try{return Ft(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},V:function(t,e,n,r,a,i,o){var u=At();try{return xt(t,e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},U:function(t,e,n,r,a){var i=At();try{return It(t,e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},Z:function(t,e,n,r){var a=At();try{return Pt(t,e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},W:function(t){var e=At();try{return Ct(t)}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},Y:function(t,e){var n=At();try{return Ut(t,e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},T:function(t,e,n){var r=At();try{return Rt(t,e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},f:function(t){var e=At();try{at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},q:function(t,e){var n=At();try{at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},h:function(t,e,n){var r=At();try{at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},da:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},l:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},t:function(t,e,n,r,a){var i=At();try{at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},u:function(t,e,n,r,a,i){var o=At();try{at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},x:function(t,e,n,r,a,i,o){var u=At();try{at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},z:function(t,e,n,r,a,i,o,u){var c=At();try{at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},ga:function(t,e,n,r,a,i,o,u,c){var s=At();try{at(t)(e,n,r,a,i,o,u,c)}catch(t){if(St(s),t!==t+0)throw t;Ot(1,0)}},A:function(t,e,n,r,a,i,o,u,c,s,l){var f=At();try{at(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(St(f),t!==t+0)throw t;Ot(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=At();try{at(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(St(b),t!==t+0)throw t;Ot(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=At();try{jt(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},_:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{Dt(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},$:function(t,e,n,r,a,i){var o=At();try{kt(t,e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},n:function(t){return t},F:function(t){ft=t},ha:yt,y:function(t,e,n,r){return yt(t,e,n,r)}};!function(){function t(t){e.asm=t.exports,O=e.asm.Ka,P(),U=e.asm.ib,I.unshift(e.asm.La),B--,e.monitorRunDependencies&&e.monitorRunDependencies(B),0==B&&(null!==G&&(clearInterval(G),G=null),N&&(t=N,N=null,t()))}function n(e){t(e.instance)}function r(t){return function(){if(!g&&(d||y)){if("function"==typeof fetch&&!Y.startsWith("file://"))return fetch(Y,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+Y+"\'";return t.arrayBuffer()})).catch((function(){return X()}));if(o)return new Promise((function(t,e){o(Y,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return X()}))}().then((function(t){return WebAssembly.instantiate(t,i)})).then((function(t){return t})).then(t,(function(t){w("failed to asynchronously prepare wasm: "+t),V(t)}))}var i={a:bt};if(B++,e.monitorRunDependencies&&e.monitorRunDependencies(B),e.instantiateWasm)try{return e.instantiateWasm(i,t)}catch(t){return w("Module.instantiateWasm callback failed with error: "+t),!1}(g||"function"!=typeof WebAssembly.instantiateStreaming||$()||Y.startsWith("file://")||b||"function"!=typeof fetch?r(n):fetch(Y,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(n,(function(t){return w("wasm streaming compile failed: "+t),w("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a)}(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.La).apply(null,arguments)},e._OrtInit=function(){return(e._OrtInit=e.asm.Ma).apply(null,arguments)},e._OrtCreateSessionOptions=function(){return(e._OrtCreateSessionOptions=e.asm.Na).apply(null,arguments)},e._OrtAppendExecutionProvider=function(){return(e._OrtAppendExecutionProvider=e.asm.Oa).apply(null,arguments)},e._OrtAddSessionConfigEntry=function(){return(e._OrtAddSessionConfigEntry=e.asm.Pa).apply(null,arguments)},e._OrtReleaseSessionOptions=function(){return(e._OrtReleaseSessionOptions=e.asm.Qa).apply(null,arguments)},e._OrtCreateSession=function(){return(e._OrtCreateSession=e.asm.Ra).apply(null,arguments)},e._OrtReleaseSession=function(){return(e._OrtReleaseSession=e.asm.Sa).apply(null,arguments)},e._OrtGetInputCount=function(){return(e._OrtGetInputCount=e.asm.Ta).apply(null,arguments)},e._OrtGetOutputCount=function(){return(e._OrtGetOutputCount=e.asm.Ua).apply(null,arguments)},e._OrtGetInputName=function(){return(e._OrtGetInputName=e.asm.Va).apply(null,arguments)},e._OrtGetOutputName=function(){return(e._OrtGetOutputName=e.asm.Wa).apply(null,arguments)},e._OrtFree=function(){return(e._OrtFree=e.asm.Xa).apply(null,arguments)},e._OrtCreateTensor=function(){return(e._OrtCreateTensor=e.asm.Ya).apply(null,arguments)},e._OrtGetTensorData=function(){return(e._OrtGetTensorData=e.asm.Za).apply(null,arguments)},e._OrtReleaseTensor=function(){return(e._OrtReleaseTensor=e.asm._a).apply(null,arguments)},e._OrtCreateRunOptions=function(){return(e._OrtCreateRunOptions=e.asm.$a).apply(null,arguments)},e._OrtAddRunConfigEntry=function(){return(e._OrtAddRunConfigEntry=e.asm.ab).apply(null,arguments)},e._OrtReleaseRunOptions=function(){return(e._OrtReleaseRunOptions=e.asm.bb).apply(null,arguments)},e._OrtRun=function(){return(e._OrtRun=e.asm.cb).apply(null,arguments)},e._OrtEndProfiling=function(){return(e._OrtEndProfiling=e.asm.db).apply(null,arguments)};var mt,gt=e._malloc=function(){return(gt=e._malloc=e.asm.eb).apply(null,arguments)},vt=e._free=function(){return(vt=e._free=e.asm.fb).apply(null,arguments)},wt=e._fflush=function(){return(wt=e._fflush=e.asm.gb).apply(null,arguments)},_t=e.___funcs_on_exit=function(){return(_t=e.___funcs_on_exit=e.asm.hb).apply(null,arguments)},Ot=e._setThrew=function(){return(Ot=e._setThrew=e.asm.jb).apply(null,arguments)},At=e.stackSave=function(){return(At=e.stackSave=e.asm.kb).apply(null,arguments)},St=e.stackRestore=function(){return(St=e.stackRestore=e.asm.lb).apply(null,arguments)},Tt=e.stackAlloc=function(){return(Tt=e.stackAlloc=e.asm.mb).apply(null,arguments)},Et=e.___cxa_can_catch=function(){return(Et=e.___cxa_can_catch=e.asm.nb).apply(null,arguments)},Mt=e.___cxa_is_pointer_type=function(){return(Mt=e.___cxa_is_pointer_type=e.asm.ob).apply(null,arguments)},Ct=e.dynCall_j=function(){return(Ct=e.dynCall_j=e.asm.pb).apply(null,arguments)},xt=e.dynCall_iiiiij=function(){return(xt=e.dynCall_iiiiij=e.asm.qb).apply(null,arguments)},Rt=e.dynCall_jii=function(){return(Rt=e.dynCall_jii=e.asm.rb).apply(null,arguments)},jt=e.dynCall_viiiiij=function(){return(jt=e.dynCall_viiiiij=e.asm.sb).apply(null,arguments)},kt=e.dynCall_vjji=function(){return(kt=e.dynCall_vjji=e.asm.tb).apply(null,arguments)},Dt=e.dynCall_viiijjjii=function(){return(Dt=e.dynCall_viiijjjii=e.asm.ub).apply(null,arguments)},Pt=e.dynCall_iij=function(){return(Pt=e.dynCall_iij=e.asm.vb).apply(null,arguments)},Ut=e.dynCall_ji=function(){return(Ut=e.dynCall_ji=e.asm.wb).apply(null,arguments)},Ft=e.dynCall_iiiiiij=function(){return(Ft=e.dynCall_iiiiiij=e.asm.xb).apply(null,arguments)},It=e.dynCall_iiij=function(){return(It=e.dynCall_iiij=e.asm.yb).apply(null,arguments)};function Wt(){function t(){if(!mt&&(mt=!0,e.calledRun=!0,!C)){if(Z(I),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var t=e.postRun.shift();H.unshift(t)}Z(H)}}if(!(0{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iterateExtraOptions=void 0,e.iterateExtraOptions=(t,n,r,a)=>{if("object"==typeof t&&null!==t){if(r.has(t))throw new Error("Circular reference in options");r.add(t)}Object.entries(t).forEach((([t,i])=>{const o=n?n+t:t;if("object"==typeof i)(0,e.iterateExtraOptions)(i,o+".",r,a);else if("string"==typeof i||"number"==typeof i)a(o,i.toString());else{if("boolean"!=typeof i)throw new Error("Can\'t handle extra config type: "+typeof i);a(o,i?"1":"0")}}))}},586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setRunOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};try{if(void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);void 0===(null==t?void 0:t.terminate)&&(u.terminate=!1);let i=0;if(void 0!==(null==t?void 0:t.tag)&&(i=(0,a.allocWasmString)(t.tag,o)),n=e._OrtCreateRunOptions(u.logSeverityLevel,u.logVerbosityLevel,!!u.terminate,i),0===n)throw new Error("Can\'t create run options");return void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddRunConfigEntry(n,i,u))throw new Error(`Can\'t set a run config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseRunOptions(n),o.forEach(e._free),t}}},919:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setSessionOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};(t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});const e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(u);try{void 0===(null==t?void 0:t.graphOptimizationLevel)&&(u.graphOptimizationLevel="all");const c=(t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}})(u.graphOptimizationLevel);void 0===(null==t?void 0:t.enableCpuMemArena)&&(u.enableCpuMemArena=!0),void 0===(null==t?void 0:t.enableMemPattern)&&(u.enableMemPattern=!0),void 0===(null==t?void 0:t.executionMode)&&(u.executionMode="sequential");const s=(t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}})(u.executionMode);let l=0;if(void 0!==(null==t?void 0:t.logId)&&(l=(0,a.allocWasmString)(t.logId,o)),void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);if(void 0===(null==t?void 0:t.enableProfiling)&&(u.enableProfiling=!1),n=e._OrtCreateSessionOptions(c,!!u.enableCpuMemArena,!!u.enableMemPattern,s,!!u.enableProfiling,0,l,u.logSeverityLevel,u.logVerbosityLevel),0===n)throw new Error("Can\'t create session options");return(null==t?void 0:t.executionProviders)&&((t,e,n)=>{for(const r of e){let e="string"==typeof r?r:r.name;switch(e){case"xnnpack":e="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${e}`)}const o=(0,a.allocWasmString)(e,n);if(0!==(0,i.getInstance)()._OrtAppendExecutionProvider(t,o))throw new Error(`Can\'t append execution provider: ${e}`)}})(n,t.executionProviders,o),void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddSessionConfigEntry(n,i,u))throw new Error(`Can\'t set a session config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseSessionOptions(n),o.forEach(e._free),t}}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.allocWasmString=void 0;const r=n(361);e.allocWasmString=(t,e)=>{const n=(0,r.getInstance)(),a=n.lengthBytesUTF8(t)+1,i=n._malloc(a);return n.stringToUTF8(t,i,a),e.push(i),i}},349:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initOrt=void 0;const r=n(586),a=n(919),i=n(983),o=n(361);e.initOrt=(t,e)=>{const n=(0,o.getInstance)()._OrtInit(t,e);if(0!==n)throw new Error(`Can\'t initialize onnxruntime. error code = ${n}`)};const u=new Map;e.createSessionAllocate=t=>{const e=(0,o.getInstance)(),n=e._malloc(t.byteLength);return e.HEAPU8.set(t,n),[n,t.byteLength]},e.createSessionFinalize=(t,e)=>{const n=(0,o.getInstance)();let r=0,i=0,c=[];try{if([i,c]=(0,a.setSessionOptions)(e),r=n._OrtCreateSession(t[0],t[1],i),0===r)throw new Error("Can\'t create a session")}finally{n._free(t[0]),n._OrtReleaseSessionOptions(i),c.forEach(n._free)}const s=n._OrtGetInputCount(r),l=n._OrtGetOutputCount(r),f=[],p=[],h=[],d=[];for(let t=0;t{const r=(0,e.createSessionAllocate)(t);return(0,e.createSessionFinalize)(r,n)},e.releaseSession=t=>{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=n[1],i=n[2];a.forEach(e._OrtFree),i.forEach(e._OrtFree),e._OrtReleaseSession(r),u.delete(t)};const c=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${t}`)}},s=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${t}`)}},l=t=>{switch(t){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}};e.run=(t,e,n,a,f)=>{const p=(0,o.getInstance)(),h=u.get(t);if(!h)throw new Error("invalid session id");const d=h[0],y=h[1],b=h[2],m=e.length,g=a.length;let v=0,w=[];const _=[],O=[];try{[v,w]=(0,r.setRunOptions)(f);for(let t=0;tp.HEAP32[t++]=e));const n=p._OrtCreateTensor(c(e),o,u,l,r.length);if(0===n)throw new Error("Can\'t create a tensor");_.push(n)}finally{p.stackRestore(s)}}const t=p.stackSave(),o=p.stackAlloc(4*m),u=p.stackAlloc(4*m),h=p.stackAlloc(4*g),A=p.stackAlloc(4*g);try{let n=o/4,r=u/4,i=h/4,c=A/4;for(let t=0;tt*e));if(a=s(o),"string"===a){const t=[];let e=i/4;for(let n=0;n{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=e._OrtEndProfiling(r);if(0===a)throw new Error("Can\'t get an profile file name");e._OrtFree(a)},e.extractTransferableBuffers=t=>{const e=[];for(const n of t){const t=n[2];!Array.isArray(t)&&t.buffer&&e.push(t.buffer)}return e}},361:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return a(e,t),e},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const u=i(n(449)),c=o(n(932)),s=n(474);let l,f=!1,p=!1,h=!1;const d=(t,e)=>e?t?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":t?"ort-wasm-simd.wasm":"ort-wasm.wasm";e.initializeWebAssembly=async t=>{if(f)return Promise.resolve();if(p)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(h)throw new Error("previous call to \'initializeWebAssembly()\' failed.");p=!0;const e=t.initTimeout,r=t.numThreads,a=t.simd,i=r>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(t){return!1}})(),o=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(t){return!1}})(),y="string"==typeof t.wasmPaths?t.wasmPaths:void 0,b=d(!1,i),m=d(o,i),g="object"==typeof t.wasmPaths?t.wasmPaths[m]:void 0;let v=!1;const w=[];if(e>0&&w.push(new Promise((t=>{setTimeout((()=>{v=!0,t()}),e)}))),w.push(new Promise(((t,e)=>{const r=i?s:c.default,a={locateFile:(t,e)=>i&&t.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([n(154)],{type:"text/javascript"})):t===b?null!=g?g:(null!=y?y:e)+m:e+t};if(i)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=u.join("/","ort-wasm-threaded.js");else{const t=`var ortWasmThreaded=(function(){var _scriptDir;return ${r.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([t],{type:"text/javascript"})}r(a).then((e=>{p=!1,f=!0,l=e,t()}),(t=>{p=!1,h=!0,e(t)}))}))),await Promise.race(w),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},e.getInstance=()=>{if(f&&l)return l;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var t;!f||p||h||(p=!0,null===(t=l.PThread)||void 0===t||t.terminateAllThreads(),l=void 0,p=!1,f=!1,h=!0)}},154:t=>{"use strict";t.exports=\'"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};\\n\'},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{"use strict";const t=n(349),e=n(361);self.onmessage=n=>{switch(n.data.type){case"init-wasm":(0,e.initializeWebAssembly)(n.data.in).then((()=>postMessage({type:"init-wasm"})),(t=>postMessage({type:"init-wasm",err:t})));break;case"init-ort":try{const{numThreads:e,loggingLevel:r}=n.data.in;(0,t.initOrt)(e,r),postMessage({type:"init-ort"})}catch(t){postMessage({type:"init-ort",err:t})}break;case"create_allocate":try{const{model:e}=n.data.in,r=(0,t.createSessionAllocate)(e);postMessage({type:"create_allocate",out:r})}catch(t){postMessage({type:"create_allocate",err:t})}break;case"create_finalize":try{const{modeldata:e,options:r}=n.data.in,a=(0,t.createSessionFinalize)(e,r);postMessage({type:"create_finalize",out:a})}catch(t){postMessage({type:"create_finalize",err:t})}break;case"create":try{const{model:e,options:r}=n.data.in,a=(0,t.createSession)(e,r);postMessage({type:"create",out:a})}catch(t){postMessage({type:"create",err:t})}break;case"release":try{const e=n.data.in;(0,t.releaseSession)(e),postMessage({type:"release"})}catch(t){postMessage({type:"release",err:t})}break;case"run":try{const{sessionId:e,inputIndices:r,inputs:a,outputIndices:i,options:o}=n.data.in,u=(0,t.run)(e,r,a,i,o);postMessage({type:"run",out:u},(0,t.extractTransferableBuffers)(u))}catch(t){postMessage({type:"run",err:t})}break;case"end-profiling":try{const e=n.data.in;(0,t.endProfiling)(e),postMessage({type:"end-profiling"})}catch(t){postMessage({type:"end-profiling",err:t})}}}})()})();\n',"Worker",void 0,void 0)}},477:m=>{m.exports=function(t,i,s,u){var d=self||window;try{try{var a;try{a=new d.Blob([t])}catch{(a=new(d.BlobBuilder||d.WebKitBlobBuilder||d.MozBlobBuilder||d.MSBlobBuilder)).append(t),a=a.getBlob()}var h=d.URL||d.webkitURL,f=h.createObjectURL(a),c=new d[i](f,s);return h.revokeObjectURL(f),c}catch{return new d[i]("data:application/javascript,".concat(encodeURIComponent(t)),s)}}catch{if(!u)throw Error("Inline worker is not supported");return new d[i](u,s)}}},4154:m=>{m.exports=`"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}}; +`},1670:m=>{m.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(m,t,i)=>{i.r(t),i.d(t,{flatbuffers:()=>s});var s={};s.Offset,s.Table,s.SIZEOF_SHORT=2,s.SIZEOF_INT=4,s.FILE_IDENTIFIER_LENGTH=4,s.SIZE_PREFIX_LENGTH=4,s.Encoding={UTF8_BYTES:1,UTF16_STRING:2},s.int32=new Int32Array(2),s.float32=new Float32Array(s.int32.buffer),s.float64=new Float64Array(s.int32.buffer),s.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,s.Long=function(u,d){this.low=0|u,this.high=0|d},s.Long.create=function(u,d){return u==0&&d==0?s.Long.ZERO:new s.Long(u,d)},s.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},s.Long.prototype.equals=function(u){return this.low==u.low&&this.high==u.high},s.Long.ZERO=new s.Long(0,0),s.Builder=function(u){if(u)d=u;else var d=1024;this.bb=s.ByteBuffer.allocate(d),this.space=d,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},s.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},s.Builder.prototype.forceDefaults=function(u){this.force_defaults=u},s.Builder.prototype.dataBuffer=function(){return this.bb},s.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},s.Builder.prototype.prep=function(u,d){u>this.minalign&&(this.minalign=u);for(var a=1+~(this.bb.capacity()-this.space+d)&u-1;this.space=0&&this.vtable[d]==0;d--);for(var a=d+1;d>=0;d--)this.addInt16(this.vtable[d]!=0?u-this.vtable[d]:0);this.addInt16(u-this.object_start);var h=(a+2)*s.SIZEOF_SHORT;this.addInt16(h);var f=0,c=this.space;e:for(d=0;d=0;c--)this.writeInt8(f.charCodeAt(c))}this.prep(this.minalign,s.SIZEOF_INT+h),this.addOffset(u),h&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},s.Builder.prototype.finishSizePrefixed=function(u,d){this.finish(u,d,!0)},s.Builder.prototype.requiredField=function(u,d){var a=this.bb.capacity()-u,h=a-this.bb.readInt32(a);if(this.bb.readInt16(h+d)==0)throw new Error("FlatBuffers: field "+d+" must be set")},s.Builder.prototype.startVector=function(u,d,a){this.notNested(),this.vector_num_elems=d,this.prep(s.SIZEOF_INT,u*d),this.prep(a,u*d)},s.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},s.Builder.prototype.createString=function(u){if(u instanceof Uint8Array)var d=u;else{d=[];for(var a=0;a=56320?f:(f<<10)+u.charCodeAt(a++)+-56613888)<128?d.push(h):(h<2048?d.push(h>>6&31|192):(h<65536?d.push(h>>12&15|224):d.push(h>>18&7|240,h>>12&63|128),d.push(h>>6&63|128)),d.push(63&h|128))}}this.addInt8(0),this.startVector(1,d.length,1),this.bb.setPosition(this.space-=d.length),a=0;for(var c=this.space,l=this.bb.bytes();a>24},s.ByteBuffer.prototype.readUint8=function(u){return this.bytes_[u]},s.ByteBuffer.prototype.readInt16=function(u){return this.readUint16(u)<<16>>16},s.ByteBuffer.prototype.readUint16=function(u){return this.bytes_[u]|this.bytes_[u+1]<<8},s.ByteBuffer.prototype.readInt32=function(u){return this.bytes_[u]|this.bytes_[u+1]<<8|this.bytes_[u+2]<<16|this.bytes_[u+3]<<24},s.ByteBuffer.prototype.readUint32=function(u){return this.readInt32(u)>>>0},s.ByteBuffer.prototype.readInt64=function(u){return new s.Long(this.readInt32(u),this.readInt32(u+4))},s.ByteBuffer.prototype.readUint64=function(u){return new s.Long(this.readUint32(u),this.readUint32(u+4))},s.ByteBuffer.prototype.readFloat32=function(u){return s.int32[0]=this.readInt32(u),s.float32[0]},s.ByteBuffer.prototype.readFloat64=function(u){return s.int32[s.isLittleEndian?0:1]=this.readInt32(u),s.int32[s.isLittleEndian?1:0]=this.readInt32(u+4),s.float64[0]},s.ByteBuffer.prototype.writeInt8=function(u,d){this.bytes_[u]=d},s.ByteBuffer.prototype.writeUint8=function(u,d){this.bytes_[u]=d},s.ByteBuffer.prototype.writeInt16=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8},s.ByteBuffer.prototype.writeUint16=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8},s.ByteBuffer.prototype.writeInt32=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8,this.bytes_[u+2]=d>>16,this.bytes_[u+3]=d>>24},s.ByteBuffer.prototype.writeUint32=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8,this.bytes_[u+2]=d>>16,this.bytes_[u+3]=d>>24},s.ByteBuffer.prototype.writeInt64=function(u,d){this.writeInt32(u,d.low),this.writeInt32(u+4,d.high)},s.ByteBuffer.prototype.writeUint64=function(u,d){this.writeUint32(u,d.low),this.writeUint32(u+4,d.high)},s.ByteBuffer.prototype.writeFloat32=function(u,d){s.float32[0]=d,this.writeInt32(u,s.int32[0])},s.ByteBuffer.prototype.writeFloat64=function(u,d){s.float64[0]=d,this.writeInt32(u,s.int32[s.isLittleEndian?0:1]),this.writeInt32(u+4,s.int32[s.isLittleEndian?1:0])},s.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&c)))}return h},s.ByteBuffer.prototype.__indirect=function(u){return u+this.readInt32(u)},s.ByteBuffer.prototype.__vector=function(u){return u+this.readInt32(u)+s.SIZEOF_INT},s.ByteBuffer.prototype.__vector_len=function(u){return this.readInt32(u+this.readInt32(u))},s.ByteBuffer.prototype.__has_identifier=function(u){if(u.length!=s.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+s.FILE_IDENTIFIER_LENGTH);for(var d=0;d{var t=m&&m.__esModule?()=>m.default:()=>m;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(m,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(m,i)&&Object.defineProperty(m,i,{enumerable:!0,get:t[i]})},__webpack_require__.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),__webpack_require__.o=(m,t)=>Object.prototype.hasOwnProperty.call(m,t),__webpack_require__.r=m=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(m,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(m,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())})(ortWeb_min$1);var ortWeb_minExports=ortWeb_min$1.exports,ortWeb_min=getDefaultExportFromCjs(ortWeb_minExports),ONNX_WEB=_mergeNamespaces({__proto__:null,default:ortWeb_min},[ortWeb_minExports]);let ONNX;const executionProviders=["wasm"];typeof process<"u"&&((nt=process==null?void 0:process.release)==null?void 0:nt.name)==="node"?(ONNX=sharp??ONNX_NODE,executionProviders.unshift("cpu")):(ONNX=ortWeb_min??ONNX_WEB,typeof navigator<"u"&&/iP(hone|od|ad).+16_4.+AppleWebKit/.test(navigator.userAgent)&&(ONNX.env.wasm.simd=!1));const{env:onnx_env}=ONNX,VERSION="2.10.1",WEB_CACHE_AVAILABLE=typeof self<"u"&&"caches"in self,FS_AVAILABLE=!isEmpty(sharp),PATH_AVAILABLE=!isEmpty(sharp),RUNNING_LOCALLY=FS_AVAILABLE&&PATH_AVAILABLE,__dirname=RUNNING_LOCALLY?sharp.dirname(sharp.dirname(sharp.fileURLToPath(self.location.href))):"./",DEFAULT_CACHE_DIR=RUNNING_LOCALLY?sharp.join(__dirname,"/.cache/"):null,DEFAULT_LOCAL_MODEL_PATH="/models/",localModelPath=RUNNING_LOCALLY?sharp.join(__dirname,DEFAULT_LOCAL_MODEL_PATH):DEFAULT_LOCAL_MODEL_PATH;onnx_env.wasm.wasmPaths=RUNNING_LOCALLY?sharp.join(__dirname,"/dist/"):`https://cdn.jsdelivr.net/npm/@xenova/transformers@${VERSION}/dist/`;const env$1={backends:{onnx:onnx_env,tfjs:{}},__dirname,version:VERSION,allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!0,localModelPath,useFS:FS_AVAILABLE,useBrowserCache:WEB_CACHE_AVAILABLE,useFSCache:FS_AVAILABLE,cacheDir:DEFAULT_CACHE_DIR,useCustomCache:!1,customCache:null};function isEmpty(m){return Object.keys(m).length===0}globalThis.ReadableStream||(globalThis.ReadableStream=sharp.ReadableStream);class FileResponse{constructor(t){le(this,"_CONTENT_TYPE_MAP",{txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif"});if(this.filePath=t,this.headers=new Headers,this.exists=sharp.existsSync(t),this.exists){this.status=200,this.statusText="OK";let i=sharp.statSync(t);this.headers.set("content-length",i.size.toString()),this.updateContentType();let s=this;this.body=new ReadableStream({start(u){s.arrayBuffer().then(d=>{u.enqueue(new Uint8Array(d)),u.close()})}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){const t=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",this._CONTENT_TYPE_MAP[t]??"application/octet-stream")}clone(){let t=new FileResponse(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=new Headers(this.headers),t}async arrayBuffer(){return(await sharp.promises.readFile(this.filePath)).buffer}async blob(){const t=await sharp.promises.readFile(this.filePath);return new Blob([t],{type:this.headers.get("content-type")})}async text(){return await sharp.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}}function isValidHttpUrl(m,t=null){let i;try{i=new URL(m)}catch{return!1}return t&&!t.includes(i.hostname)?!1:i.protocol==="http:"||i.protocol==="https:"}async function getFile(m){var t,i,s,u;if(env$1.useFS&&!isValidHttpUrl(m))return new FileResponse(m);if(typeof process<"u"&&((t=process==null?void 0:process.release)==null?void 0:t.name)==="node"){const d=!!((i=process.env)!=null&&i.TESTING_REMOTELY),a=env$1.version,h=new Headers;if(h.set("User-Agent",`transformers.js/${a}; is_ci/${d};`),isValidHttpUrl(m,["huggingface.co","hf.co"])){const c=((s=process.env)==null?void 0:s.HF_TOKEN)??((u=process.env)==null?void 0:u.HF_ACCESS_TOKEN);c&&h.set("Authorization",`Bearer ${c}`)}return fetch(m,{headers:h})}else return fetch(m)}const ERROR_MAPPING={400:"Bad request error occurred while trying to load file",401:"Unauthorized access to file",403:"Forbidden access to file",404:"Could not locate file",408:"Request timeout error occurred while trying to load file",500:"Internal server error error occurred while trying to load file",502:"Bad gateway error occurred while trying to load file",503:"Service unavailable error occurred while trying to load file",504:"Gateway timeout error occurred while trying to load file"};function handleError(m,t,i){if(!i)return null;const s=ERROR_MAPPING[m]??`Error (${m}) occurred while trying to load file`;throw Error(`${s}: "${t}".`)}class FileCache{constructor(t){this.path=t}async match(t){let i=sharp.join(this.path,t),s=new FileResponse(i);if(s.exists)return s}async put(t,i){const s=Buffer.from(await i.arrayBuffer());let u=sharp.join(this.path,t);try{await sharp.promises.mkdir(sharp.dirname(u),{recursive:!0}),await sharp.promises.writeFile(u,s)}catch(d){console.warn("An error occurred while writing the file to cache:",d)}}}async function tryCache(m,...t){for(let i of t)try{let s=await m.match(i);if(s)return s}catch{continue}}async function getModelFile(m,t,i=!0,s={}){if(!env$1.allowLocalModels&&s.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");dispatchCallback(s.progress_callback,{status:"initiate",name:m,file:t});let u;if(!u&&env$1.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{u=await caches.open("transformers-cache")}catch(_){console.warn("An error occurred while opening the browser cache:",_)}}if(!u&&env$1.useFSCache&&(u=new FileCache(s.cache_dir??env$1.cacheDir)),!u&&env$1.useCustomCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");const d=s.revision??"main";let a=pathJoin(m,t),h=pathJoin(env$1.localModelPath,a),f=pathJoin(env$1.remoteHost,env$1.remotePathTemplate.replaceAll("{model}",m).replaceAll("{revision}",d),t),c=d==="main"?a:pathJoin(m,d,t),l,n=u instanceof FileCache?c:f,e=!1,r;u&&(r=await tryCache(u,h,n));const o=r!==void 0;if(r===void 0){if(env$1.allowLocalModels)if(isValidHttpUrl(a)){if(s.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${a}.`)}else try{r=await getFile(h),l=h}catch(b){console.warn(`Unable to load from local path "${h}": "${b}"`)}if(r===void 0||r.status===404){if(s.local_files_only||!env$1.allowRemoteModels){if(i)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${h}".`);return null}if(r=await getFile(f),r.status!==200)return handleError(r.status,f,i);l=n}e=u&&typeof Response<"u"&&r instanceof Response&&r.status===200}dispatchCallback(s.progress_callback,{status:"download",name:m,file:t});const p={status:"progress",name:m,file:t};let g;return s.progress_callback?o&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent)?(g=new Uint8Array(await r.arrayBuffer()),dispatchCallback(s.progress_callback,{...p,progress:100,loaded:g.length,total:g.length})):g=await readResponse(r,_=>{dispatchCallback(s.progress_callback,{...p,..._})}):g=new Uint8Array(await r.arrayBuffer()),e&&l&&await u.match(l)===void 0&&await u.put(l,new Response(g,{headers:r.headers})).catch(_=>{console.warn(`Unable to add response to browser cache: ${_}.`)}),dispatchCallback(s.progress_callback,{status:"done",name:m,file:t}),g}async function getModelJSON(m,t,i=!0,s={}){let u=await getModelFile(m,t,i,s);if(u===null)return{};let a=new TextDecoder("utf-8").decode(u);return JSON.parse(a)}async function readResponse(m,t){const i=m.headers.get("Content-Length");i===null&&console.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let s=parseInt(i??"0"),u=new Uint8Array(s),d=0;const a=m.body.getReader();async function h(){const{done:f,value:c}=await a.read();if(f)return;let l=d+c.length;if(l>s){s=l;let e=new Uint8Array(s);e.set(u),u=e}u.set(c,d),d=l;const n=d/s*100;return t({progress:n,loaded:d,total:s}),h()}return await h(),u}function pathJoin(...m){return m=m.map((t,i)=>(i&&(t=t.replace(new RegExp("^/"),"")),i!==m.length-1&&(t=t.replace(new RegExp("/$"),"")),t)),m.join("/")}function interpolate_data(m,[t,i,s],[u,d],a="bilinear",h=!1){const f=d/s,c=u/i,l=new m.constructor(u*d*t),n=i*s,e=u*d;for(let r=0;r=0;--h)u[h]=f,s[h]=t[i[h]],f*=s[h];const d=i.map((h,f)=>u[i.indexOf(f)]),a=new m.constructor(m.length);for(let h=0;h=0;--c)f+=l%t[c]*d[c],l=Math.floor(l/t[c]);a[f]=m[h]}return[a,s]}function softmax(m){const t=max(m)[0],i=m.map(d=>Math.exp(d-t)),s=i.reduce((d,a)=>d+a,0);return i.map(d=>d/s)}function log_softmax(m){return softmax(m).map(s=>Math.log(s))}function getTopItems(m,t=0){return m=Array.from(m).map((i,s)=>[s,i]).sort((i,s)=>s[1]-i[1]),t>0&&(m=m.slice(0,t)),m}function min(m){if(m.length===0)throw Error("Array must not be empty");let t=m[0],i=0;for(let s=1;st&&(t=m[s],i=s);return[t,i]}function isPowerOfTwo(m){return m>0&&(m&m-1)===0}class P2FFT{constructor(t){if(this.size=t|0,this.size<=1||!isPowerOfTwo(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=t<<1,this.table=new Float64Array(this.size*2);for(let s=0;ss;s<<=1)++i;this._width=i%2===0?i-1:i,this._bitrev=new Int32Array(1<>>u&3)<>>1);for(let u=0;u>>1]=t[u];return s}toComplexArray(t,i){const s=i||this.createComplexArray();for(let u=0;u>>1],s[u+1]=0;return s}completeSpectrum(t){const i=this._csize,s=i>>>1;for(let u=2;u>=2;a>=2;a>>=2){h=u/a<<1;const n=h>>>2;for(f=0;f>>1,a>>>1)}else for(f=0,c=0;f>>1,a>>>1,s)}for(a>>=2;a>=2;a>>=2){h=u/a<<1;const n=h>>>2;for(f=0;f>1;++l){const n=(l+1-t)**2/2,e=Math.sqrt(f**2+c**2)**n,r=n*Math.atan2(c,f),o=2*l;d[o]=e*Math.cos(r),d[o+1]=e*Math.sin(r),a[o]=d[o],a[o+1]=-d[o+1]}this._slicedChirpBuffer=d.subarray(i,s),this._f=new P2FFT(u>>1),this._f.transform(this._chirpBuffer,a)}_transform(t,i,s){const u=this._buffer1,d=this._buffer2,a=this._outBuffer1,h=this._outBuffer2,f=this._chirpBuffer,c=this._slicedChirpBuffer,l=this._a;if(s)for(let n=0;n>1,o=i[r];u[n]=o*c[n],u[e]=o*c[e]}else for(let n=0;n=m.length&&(f=2*(m.length-1)-f),s[a++]=m[f]}s.sort(),i[d]=s[u]}return i}function round(m,t){const i=Math.pow(10,t);return Math.round(m*i)/i}const DataTypeMap=new Map([["bool",Uint8Array],["float32",Float32Array],["float64",Float64Array],["string",Array],["int8",Int8Array],["uint8",Uint8Array],["int16",Int16Array],["uint16",Uint16Array],["int32",Int32Array],["uint32",Uint32Array],["int64",BigInt64Array]]),ONNXTensor$1=ONNX.Tensor;class Tensor extends ONNXTensor$1{constructor(...t){return t[0]instanceof ONNX.Tensor?super(t[0].type,t[0].data,t[0].dims):super(...t),new Proxy(this,{get:(i,s)=>{if(typeof s=="string"){let u=Number(s);if(Number.isInteger(u))return i._getitem(u)}return i[s]},set:(i,s,u)=>i[s]=u})}*[Symbol.iterator](){const[t,...i]=this.dims;if(i.length>0){const s=i.reduce((u,d)=>u*d);for(let u=0;u0){const u=s.reduce((d,a)=>d*a);return this._subarray(t,u,s)}else return new Tensor(this.type,[this.data[t]],s)}indexOf(t){for(let i=0;ic[1])throw new Error(`Invalid slice: ${c}`);let l=[Math.max(c[0],0),Math.min(c[1],this.dims[f])];s.push(l),i.push(l[1]-l[0])}else throw new Error(`Invalid slice: ${c}`)}let u=s.map(([f,c])=>c-f),d=u.reduce((f,c)=>f*c),a=new this.data.constructor(d);const h=this.stride();for(let f=0;f=0;--l){const e=u[l];c+=(n%e+s[l][0])*h[l],n=Math.floor(n/e)}a[f]=this.data[c]}return new Tensor(this.type,a,i)}transpose(...t){return transpose(this,t)}sum(t=null,i=!1){return this.norm(1,t,i)}norm(t="fro",i=null,s=!1){if(t==="fro")t=2;else if(typeof t=="string")throw Error(`Unsupported norm: ${t}`);if(i===null){let a=this.data.reduce((h,f)=>h+f**t,0)**(1/t);return new Tensor(this.type,[a],[])}i=safeIndex(i,this.dims.length);const u=this.dims.slice();u[i]=1;const d=new this.data.constructor(this.data.length/this.dims[i]);for(let a=0;a=0;--f){const n=this.dims[f];if(f!==i){const e=c%n;h+=e*l,l*=u[f]}c=Math.floor(c/n)}d[h]+=this.data[a]**t}if(t!==1)for(let a=0;a=0;--a){const c=this.dims[a];if(a!==i){const l=h%c;d+=l*f,f*=this.dims[a]}h=Math.floor(h/c)}this.data[u]/=s.data[d]}return this}normalize(t=2,i=1){return this.clone().normalize_(t,i)}stride(){return dimsToStride(this.dims)}squeeze(t=null){return new Tensor(this.type,this.data,calc_squeeze_dims(this.dims,t))}squeeze_(t=null){return this.dims=calc_squeeze_dims(this.dims,t),this}unsqueeze(t=null){return new Tensor(this.type,this.data,calc_unsqueeze_dims(this.dims,t))}unsqueeze_(t=null){return this.dims=calc_unsqueeze_dims(this.dims,t),this}flatten_(t=0,i=-1){i=(i+this.dims.length)%this.dims.length;let s=this.dims.slice(0,t),u=this.dims.slice(t,i+1),d=this.dims.slice(i+1);return this.dims=[...s,u.reduce((a,h)=>a*h,1),...d],this}flatten(t=0,i=-1){return this.clone().flatten_(t,i)}view(...t){let i=-1;for(let s=0;sa!==i?u*d:u,1);t[i]=this.data.length/s}return new Tensor(this.type,this.data,t)}neg_(){for(let t=0;td*a);if(i!==s)throw Error(`cannot reshape array of size ${i} into shape (${t})`);let u=m;for(let d=t.length-1;d>=0;d--)u=u.reduce((a,h)=>{let f=a[a.length-1];return f.lengthi!==1):typeof t=="number"?m[t]===1&&m.splice(t,1):Array.isArray(t)&&(m=m.filter((i,s)=>i!==1||!t.includes(s))),m}function calc_unsqueeze_dims(m,t){return t=safeIndex(t,m.length+1),m=m.slice(),m.splice(t,0,1),m}function safeIndex(m,t,i=null){if(m<-t||m>=t)throw new Error(`IndexError: index ${m} is out of bounds for dimension${i===null?"":" "+i} with size ${t}`);return m<0&&(m=(m%t+t)%t),m}function cat(m,t=0){t=safeIndex(t,m[0].dims.length);const i=m[0].dims.slice();i[t]=m.reduce((a,h)=>a+h.dims[t],0);const s=i.reduce((a,h)=>a*h,1),u=new m[0].data.constructor(s),d=m[0].type;if(t===0){let a=0;for(let h of m)u.set(h.data,a),a+=h.data.length}else{let a=0;for(let h=0;h=0;--n){const o=f.dims[n];let p=e%o;n===t&&(p+=a),l+=p*r,r*=i[n],e=Math.floor(e/o)}u[l]=f.data[c]}a+=f.dims[t]}}return new Tensor(d,u,i)}function stack(m,t=0){return cat(m.map(i=>i.unsqueeze(t)),t)}function std_mean(m,t=null,i=1,s=!1){if(t===null){const c=m.data.reduce((r,o)=>r+o,0)/m.data.length,l=Math.sqrt(m.data.reduce((r,o)=>r+(o-c)**2,0)/(m.data.length-i)),n=new Tensor(m.type,[c],[]);return[new Tensor(m.type,[l],[]),n]}t=safeIndex(t,m.dims.length);const u=mean(m,t,s),d=m.dims.slice();d[t]=1;const a=new m.data.constructor(m.data.length/m.dims[t]);for(let f=0;f=0;--l){const r=m.dims[l];if(l!==t){const o=n%r;c+=o*e,e*=d[l]}n=Math.floor(n/r)}a[c]+=(m.data[f]-u.data[c])**2}for(let f=0;fa+h,0);return new Tensor(m.type,[d/m.data.length],[])}t=safeIndex(t,m.dims.length);const s=m.dims.slice();s[t]=1;const u=new m.data.constructor(m.data.length/m.dims[t]);for(let d=0;d=0;--h){const l=m.dims[h];if(h!==t){const n=f%l;a+=n*c,c*=s[h]}f=Math.floor(f/l)}u[a]+=m.data[d]}if(m.dims[t]!==1)for(let d=0;d0||h>0;)switch(f.push(a-1),c.push(h-1),d[a][h].item()){case 0:--a,--h;break;case 1:--a;break;case 2:--h;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${a}, ${h}]. Please file a bug report.`)}return f.reverse(),c.reverse(),[f,c]}function dimsToStride(m){const t=new Array(m.length);for(let i=m.length-1,s=1;i>=0;--i)t[i]=s,s*=m[i];return t}function ones(m){const t=m.reduce((i,s)=>i*s,1);return new Tensor("int64",new BigInt64Array(t).fill(1n),m)}function ones_like(m){return ones(m.dims)}class PriorityQueue{constructor(t=(i,s)=>i>s){this._heap=[],this._comparator=t}get size(){return this._heap.length}isEmpty(){return this.size===0}peek(){return this._heap[0]}push(...t){return this.extend(t)}extend(t){for(const i of t)this._heap.push(i),this._siftUp();return this.size}pop(){const t=this.peek(),i=this.size-1;return i>0&&this._swap(0,i),this._heap.pop(),this._siftDown(),t}replace(t){const i=this.peek();return this._heap[0]=t,this._siftDown(),i}_parent(t){return(t+1>>>1)-1}_left(t){return(t<<1)+1}_right(t){return t+1<<1}_greater(t,i){return this._comparator(this._heap[t],this._heap[i])}_swap(t,i){const s=this._heap[t];this._heap[t]=this._heap[i],this._heap[i]=s}_siftUp(){let t=this.size-1;for(;t>0&&this._greater(t,this._parent(t));)this._swap(t,this._parent(t)),t=this._parent(t)}_siftDown(){let t=0;for(;this._left(t)[]),this.endNodes=Array.from({length:this.len+1},()=>[]);const u=new TokenLatticeNode(this.bosTokenId,0,0,0,0),d=new TokenLatticeNode(this.eosTokenId,1,this.len,0,0);this.nodes.push(u.clone()),this.nodes.push(d.clone()),this.beginNodes[this.len].push(d),this.endNodes[0].push(u)}insert(t,i,s,u){const d=this.nodes.length,a=new TokenLatticeNode(u,d,t,i,s);this.beginNodes[t].push(a),this.endNodes[t+i].push(a),this.nodes.push(a)}viterbi(){const t=this.len;let i=0;for(;i<=t;){if(this.beginNodes[i].length==0)return[];for(let h of this.beginNodes[i]){h.prev=null;let f=0,c=null;for(let l of this.endNodes[i]){const n=l.backtraceScore+h.score;(c===null||n>f)&&(c=l.clone(),f=n)}if(c!==null)h.prev=c,h.backtraceScore=f;else return[]}++i}const s=[],d=this.beginNodes[t][0].prev;if(d===null)return[];let a=d.clone();for(;a.prev!==null;)s.push(a.clone()),a=a.clone().prev.clone();return s.reverse(),s}piece(t){return this.sentence.slice(t.pos,t.pos+t.length)}tokens(){return this.viterbi().map(i=>this.piece(i))}tokenIds(){return this.viterbi().map(i=>i.tokenId)}}class TokenLatticeNode{constructor(t,i,s,u,d){this.tokenId=t,this.nodeId=i,this.pos=s,this.length=u,this.score=d,this.prev=null,this.backtraceScore=0}clone(){const t=new TokenLatticeNode(this.tokenId,this.nodeId,this.pos,this.length,this.score);return t.prev=this.prev,t.backtraceScore=this.backtraceScore,t}}async function loadTokenizer(m,t){return await Promise.all([getModelJSON(m,"tokenizer.json",!0,t),getModelJSON(m,"tokenizer_config.json",!0,t)])}function regexSplit(m,t){const i=[];let s=0;for(const u of m.matchAll(t)){const d=u[0];s0&&i.push(d),s=u.index+d.length}return sthis.tokens_to_ids.get(s)??this.unk_token_id);return this.fuse_unk&&(i=fuse(i,this.unk_token_id)),i}convert_ids_to_tokens(t){return t.map(i=>this.vocab[i]??this.unk_token)}}class WordPieceTokenizer extends TokenizerModel{constructor(t){super(t),this.tokens_to_ids=objectToMap(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.max_input_chars_per_word=t.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(const[i,s]of this.tokens_to_ids)this.vocab[s]=i}encode(t){let i=[];for(let s of t){let u=[...s];if(u.length>this.max_input_chars_per_word){i.push(this.unk_token);continue}let d=!1,a=0,h=[];for(;a0&&(l=this.config.continuing_subword_prefix+l),this.tokens_to_ids.has(l)){c=l;break}--f}if(c===null){d=!0;break}h.push(c),a=f}d?i.push(this.unk_token):i.push(...h)}return i}}class Unigram extends TokenizerModel{constructor(t,i){super(t);const s=t.vocab.length;this.vocab=new Array(s),this.scores=new Array(s);for(let u=0;u[u,d])),this.bosToken=" ",this.bosTokenId=this.tokens_to_ids.get(this.bosToken),this.eosToken=i.eos_token,this.eosTokenId=this.tokens_to_ids.get(this.eosToken),this.unkToken=this.vocab[this.unk_token_id],this.minScore=min(this.scores)[0],this.unkScore=this.minScore-10,this.scores[this.unk_token_id]=this.unkScore,this.trie=new CharTrie,this.trie.extend(this.vocab),this.fuse_unk=!0}populateNodes(t){const i=t.sentence,s=i.length;let u=0;for(;u{const m=[...Array.from({length:"~".charCodeAt(0)-"!".charCodeAt(0)+1},(u,d)=>d+"!".charCodeAt(0)),...Array.from({length:"¬".charCodeAt(0)-"¡".charCodeAt(0)+1},(u,d)=>d+"¡".charCodeAt(0)),...Array.from({length:"ÿ".charCodeAt(0)-"®".charCodeAt(0)+1},(u,d)=>d+"®".charCodeAt(0))];let t=m.slice(),i=0;for(let u=0;u<256;++u)m.includes(u)||(m.push(u),t.push(256+i),i+=1);let s=t.map(u=>String.fromCharCode(u));return Object.fromEntries(m.map((u,d)=>[u,s[d]]))})(),UNICODE_TO_BYTES=reverseDictionary(BYTES_TO_UNICODE);class BPE extends TokenizerModel{constructor(t){super(t),this.BPE_SPLIT_TOKEN=" ",this.tokens_to_ids=objectToMap(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(const[i,s]of this.tokens_to_ids)this.vocab[s]=i;this.bpe_ranks=new Map(t.merges.map((i,s)=>[i,s])),this.merges=t.merges.map(i=>i.split(this.BPE_SPLIT_TOKEN)),this.end_of_word_suffix=t.end_of_word_suffix,this.continuing_subword_suffix=t.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.cache=new Map}bpe(t){if(t.length===0)return[];const i=this.cache.get(t);if(i!==void 0)return i;const s=Array.from(t);this.end_of_word_suffix&&(s[s.length-1]+=this.end_of_word_suffix);let u=[];if(s.length>1){const d=new PriorityQueue((f,c)=>f.score`<0x${a.toString(16).toUpperCase().padStart(2,"0")}>`)):i.push(this.unk_token)}return i}}class LegacyTokenizerModel extends TokenizerModel{constructor(t,i){super(t),this.tokens_to_ids=objectToMap(i.target_lang?t.vocab[i.target_lang]:t.vocab),this.bos_token=i.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=i.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=i.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=i.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(const[s,u]of this.tokens_to_ids)this.vocab[u]=s}encode(t){return t}}class Normalizer extends Callable{constructor(t){super(),this.config=t}static fromConfig(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new BertNormalizer(t);case"Precompiled":return new Precompiled(t);case"Sequence":return new NormalizerSequence(t);case"Replace":return new Replace(t);case"NFC":return new NFC(t);case"NFKC":return new NFKC(t);case"NFKD":return new NFKD(t);case"Strip":return new StripNormalizer(t);case"StripAccents":return new StripAccents(t);case"Lowercase":return new Lowercase(t);case"Prepend":return new Prepend(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}normalize(t){throw Error("normalize should be implemented in subclass.")}_call(t){return this.normalize(t)}}class Replace extends Normalizer{normalize(t){let i=createPattern(this.config.pattern);return i===null||(t=t.replaceAll(i,this.config.content)),t}}class NFC extends Normalizer{normalize(t){return t=t.normalize("NFC"),t}}class NFKC extends Normalizer{normalize(t){return t=t.normalize("NFKC"),t}}class NFKD extends Normalizer{normalize(t){return t=t.normalize("NFKD"),t}}class StripNormalizer extends Normalizer{normalize(t){return this.config.strip_left&&this.config.strip_right?t=t.trim():(this.config.strip_left&&(t=t.trimStart()),this.config.strip_right&&(t=t.trimEnd())),t}}class StripAccents extends Normalizer{normalize(t){return t=remove_accents(t),t}}class Lowercase extends Normalizer{normalize(t){return t=t.toLowerCase(),t}}class Prepend extends Normalizer{normalize(t){return t=this.config.prepend+t,t}}class NormalizerSequence extends Normalizer{constructor(t){super(t),this.normalizers=t.normalizers.map(i=>Normalizer.fromConfig(i))}normalize(t){return this.normalizers.reduce((i,s)=>s.normalize(i),t)}}class BertNormalizer extends Normalizer{_tokenize_chinese_chars(t){let i=[];for(let s=0;s=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103}stripAccents(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}normalize(t){return this.config.handle_chinese_chars&&(t=this._tokenize_chinese_chars(t)),this.config.lowercase?(t=t.toLowerCase(),this.config.strip_accents!==!1&&(t=this.stripAccents(t))):this.config.strip_accents&&(t=this.stripAccents(t)),t}}class PreTokenizer extends Callable{static fromConfig(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new BertPreTokenizer(t);case"Sequence":return new PreTokenizerSequence(t);case"WhitespaceSplit":return new WhitespaceSplit(t);case"Metaspace":return new MetaspacePreTokenizer(t);case"ByteLevel":return new ByteLevelPreTokenizer(t);case"Split":return new SplitPreTokenizer(t);case"Punctuation":return new PunctuationPreTokenizer(t);case"Digits":return new DigitsPreTokenizer(t);case"Replace":return new ReplacePreTokenizer(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}pre_tokenize_text(t){throw Error("pre_tokenize_text should be implemented in subclass.")}pre_tokenize(t){let i=[];return Array.isArray(t)?i=t.map(s=>this.pre_tokenize_text(s)):i=this.pre_tokenize_text(t),i.flat()}_call(t){return this.pre_tokenize(t)}}class BertPreTokenizer extends PreTokenizer{constructor(t){super(),this.pattern=new RegExp(`[^\\s${PUNCTUATION_REGEX}]+|[${PUNCTUATION_REGEX}]`,"gu")}pre_tokenize_text(t){return t.trim().match(this.pattern)||[]}}class ByteLevelPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.add_prefix_space=this.config.add_prefix_space,this.trim_offsets=this.config.trim_offsets,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=BYTES_TO_UNICODE,this.text_encoder=new TextEncoder}pre_tokenize_text(t){return this.add_prefix_space&&!t.startsWith(" ")&&(t=" "+t),(this.use_regex?t.match(this.pattern)||[]:[t]).map(s=>Array.from(this.text_encoder.encode(s),u=>this.byte_encoder[u]).join(""))}}class SplitPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.pattern=createPattern(this.config.pattern,this.config.invert)}pre_tokenize_text(t){return this.pattern===null?[]:this.config.invert?t.match(this.pattern)||[]:regexSplit(t,this.pattern)}}class PunctuationPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${PUNCTUATION_REGEX}]+|[${PUNCTUATION_REGEX}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}}class DigitsPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t;const i=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(i,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}}class PostProcessor extends Callable{constructor(t){super(),this.config=t}static fromConfig(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new TemplateProcessing(t);case"ByteLevel":return new ByteLevelPostProcessor(t);case"RobertaProcessing":return new RobertaProcessing(t);case"BertProcessing":return new BertProcessing(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}post_process(t,...i){throw Error("post_process should be implemented in subclass.")}_call(t,...i){return this.post_process(t,...i)}}class BertProcessing extends PostProcessor{constructor(t){super(t),this.cls=t.cls[0],this.sep=t.sep[0]}post_process(t,i=null){return t=mergeArrays([this.cls],t,[this.sep]),i!==null&&(t=mergeArrays(t,[this.sep],i,[this.sep])),t}}class RobertaProcessing extends BertProcessing{}class TemplateProcessing extends PostProcessor{constructor(t){super(t),this.single=t.single,this.pair=t.pair}post_process(t,i=null){let s=i===null?this.single:this.pair,u=[];for(let d of s)"SpecialToken"in d?u.push(d.SpecialToken.id):"Sequence"in d&&(d.Sequence.id==="A"?u=mergeArrays(u,t):d.Sequence.id==="B"&&(u=mergeArrays(u,i)));return u}}class ByteLevelPostProcessor extends PostProcessor{post_process(t){return t}}class Decoder extends Callable{constructor(t){super(),this.config=t,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=t.trim_offsets}static fromConfig(t){switch(t.type){case"WordPiece":return new WordPieceDecoder(t);case"Metaspace":return new MetaspaceDecoder(t);case"ByteLevel":return new ByteLevelDecoder(t);case"Replace":return new ReplaceDecoder(t);case"ByteFallback":return new ByteFallback(t);case"Fuse":return new FuseDecoder(t);case"Strip":return new StripDecoder(t);case"Sequence":return new DecoderSequence(t);case"CTC":return new CTCDecoder(t);case"BPEDecoder":return new BPEDecoder(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}_call(t){return this.decode(t)}decode(t){return this.decode_chain(t).join("")}decode_chain(t){throw Error("`decode_chain` should be implemented in subclass.")}}class ReplaceDecoder extends Decoder{decode_chain(t){let i=createPattern(this.config.pattern);return i===null?t:t.map(s=>s.replaceAll(i,this.config.content))}}class ByteFallback extends Decoder{constructor(t){super(t),this.text_decoder=new TextDecoder}decode_chain(t){let i=[],s=[];for(let u of t){let d=null;if(u.length===6&&u.startsWith("<0x")&&u.endsWith(">")){let a=parseInt(u.slice(3,5),16);isNaN(a)||(d=a)}if(d!==null)s.push(d);else{if(s.length>0){let a=this.text_decoder.decode(Uint8Array.from(s));i.push(a),s=[]}i.push(u)}}if(s.length>0){let u=this.text_decoder.decode(Uint8Array.from(s));i.push(u),s=[]}return i}}class FuseDecoder extends Decoder{decode_chain(t){return[t.join("")]}}class StripDecoder extends Decoder{constructor(t){super(t),this.content=this.config.content,this.start=this.config.start,this.stop=this.config.stop}decode_chain(t){return t.map(i=>{let s=0;for(let d=0;d(s!==0&&(i.startsWith(this.config.prefix)?i=i.replace(this.config.prefix,""):i=" "+i),this.cleanup&&(i=clean_up_tokenization(i)),i))}}class ByteLevelDecoder extends Decoder{constructor(t){super(t),this.byte_decoder=UNICODE_TO_BYTES,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(t){let i=t.join(""),s=new Uint8Array([...i].map(d=>this.byte_decoder[d]));return this.text_decoder.decode(s)}decode_chain(t){let i=[],s=[];for(let u of t)this.added_tokens.includes(u)?(s.length>0&&(i.push(this.convert_tokens_to_string(s)),s=[]),i.push(u)):s.push(u);return s.length>0&&i.push(this.convert_tokens_to_string(s)),i}}class CTCDecoder extends Decoder{constructor(t){super(t),this.pad_token=this.config.pad_token,this.word_delimiter_token=this.config.word_delimiter_token,this.cleanup=this.config.cleanup}convert_tokens_to_string(t){if(t.length===0)return"";let i=[t[0]];for(let d=1;dd!==this.pad_token).join("");return this.cleanup&&(u=clean_up_tokenization(u).replaceAll(this.word_delimiter_token," ").trim()),u}decode_chain(t){return[this.convert_tokens_to_string(t)]}}class DecoderSequence extends Decoder{constructor(t){super(t),this.decoders=t.decoders.map(i=>Decoder.fromConfig(i))}decode_chain(t){return this.decoders.reduce((i,s)=>s.decode_chain(i),t)}}class BPEDecoder extends Decoder{constructor(t){super(t),this.suffix=this.config.suffix}decode_chain(t){return t.map((i,s)=>i.replaceAll(this.suffix,s===t.length-1?"":" "))}}class MetaspacePreTokenizer extends PreTokenizer{constructor(t){super(),this.addPrefixSpace=t.add_prefix_space,this.replacement=t.replacement,this.strRep=t.str_rep||this.replacement}pre_tokenize(t){typeof t=="string"&&(t=t.trimStart().split(/\s+/));const i=[];for(let s of t){let u=s.replaceAll(" ",this.strRep);this.addPrefixSpace&&!u.startsWith(this.replacement)&&(u=this.strRep+u),i.push(u)}return i}}class MetaspaceDecoder extends Decoder{constructor(t){super(t),this.addPrefixSpace=t.add_prefix_space,this.replacement=t.replacement}decode_chain(t){let i=[];for(let s=0;ss.normalize("NFKC")).join("~"):t=t.normalize("NFKC"),t}}class PreTokenizerSequence extends PreTokenizer{constructor(t){super(),this.tokenizers=t.pretokenizers.map(i=>PreTokenizer.fromConfig(i))}pre_tokenize_text(t){return typeof t=="string"&&(t=[t]),this.tokenizers.reduce((i,s)=>s.pre_tokenize(i),t)}}class WhitespaceSplit extends PreTokenizer{constructor(t){super()}pre_tokenize_text(t){return whitespace_split(t)}}class ReplacePreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.pattern=createPattern(this.config.pattern),this.content=this.config.content}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content)]}}class PreTrainedTokenizer extends Callable{constructor(t,i){super(),this.normalizer=Normalizer.fromConfig(t.normalizer),this.pre_tokenizer=PreTokenizer.fromConfig(t.pre_tokenizer),this.model=TokenizerModel.fromConfig(t.model,i),this.post_processor=PostProcessor.fromConfig(t.post_processor),this.decoder=Decoder.fromConfig(t.decoder),this.decoder.end_of_word_suffix=this.model.end_of_word_suffix,this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];for(let s of t.added_tokens){let u=s.id,d=s.content;this.added_tokens.push(d),this.model.tokens_to_ids.set(d,u),this.model.vocab[u]=d,s.special&&(this.special_tokens.push(d),this.all_special_ids.push(u))}this.special_tokens.push(...i.additional_special_tokens??[]),this.special_tokens=[...new Set(this.special_tokens)],this.decoder.added_tokens=this.added_tokens,this.added_tokens_regex=this.added_tokens.length>0?new RegExp("("+this.added_tokens.map(escapeRegExp).join("|")+")"):null,this.mask_token=this.getToken(i,"mask_token"),this.mask_token_id=this.model.tokens_to_ids.get(this.mask_token),this.pad_token=this.getToken(i,"pad_token","eos_token"),this.pad_token_id=this.model.tokens_to_ids.get(this.pad_token),this.sep_token=this.getToken(i,"sep_token"),this.sep_token_id=this.model.tokens_to_ids.get(this.sep_token),this.unk_token=this.getToken(i,"unk_token"),this.unk_token_id=this.model.tokens_to_ids.get(this.unk_token),this.model_max_length=i.model_max_length,this.remove_space=i.remove_space,this.clean_up_tokenization_spaces=i.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=i.do_lowercase_and_remove_accent??!1,this.padding_side="right"}getToken(t,...i){for(let s of i){let u=t[s];if(u)if(typeof u=="object"){if(u.__type==="AddedToken")return u.content;throw Error(`Unknown token: ${u}`)}else return u}return null}static async from_pretrained(t,{progress_callback:i=null,config:s=null,cache_dir:u=null,local_files_only:d=!1,revision:a="main"}={}){let h=await loadTokenizer(t,{progress_callback:i,config:s,cache_dir:u,local_files_only:d,revision:a});return new this(...h)}prepare_model_inputs(t){return t}_call(t,{text_pair:i=null,add_special_tokens:s=!0,padding:u=!1,truncation:d=null,max_length:a=null,return_tensor:h=!0}={}){let f;if(Array.isArray(t)){if(t.length===0)throw Error("text array must be non-empty");if(i!==null){if(Array.isArray(i)){if(t.length!==i.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");f=t.map((e,r)=>this.encode(e,i[r],{add_special_tokens:s}))}else f=t.map(e=>this.encode(e,null,{add_special_tokens:s}))}else{if(t===null)throw Error("text may not be null");if(Array.isArray(i))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");f=[this.encode(t,i,{add_special_tokens:s})]}let c=max(f.map(e=>e.length))[0];a===null&&(a=c),a=Math.min(a,this.model_max_length);let l=[];if(u||d)for(let e=0;ea)d&&(f[e]=f[e].slice(0,a)),l.push(new Array(f[e].length).fill(1));else if(u){let r=a-f[e].length;this.padding_side==="right"?(l.push(new Array(f[e].length).fill(1).concat(new Array(r).fill(0))),f[e].push(...new Array(r).fill(this.pad_token_id))):(l.push(new Array(r).fill(0).concat(new Array(f[e].length).fill(1))),f[e].unshift(...new Array(r).fill(this.pad_token_id)))}else l.push(new Array(f[e].length).fill(1));else l=f.map(e=>new Array(e.length).fill(1));if(h){if(!(u&&d)&&f.some(r=>r.length!==f[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");let e=[f.length,f[0].length];f=new Tensor("int64",BigInt64Array.from(f.flat().map(BigInt)),e),l=new Tensor("int64",BigInt64Array.from(l.flat().map(BigInt)),e)}else Array.isArray(t)||(f=f[0],l=l[0]);let n={input_ids:f,attention_mask:l};return n=this.prepare_model_inputs(n),n}_encode_text(t){return t===null?null:(this.added_tokens_regex?t.split(this.added_tokens_regex).filter(u=>u):[t]).map(u=>{if(this.added_tokens.includes(u))return u;{this.remove_space===!0&&(u=u.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(u=lowercase_and_remove_accent(u)),this.normalizer!==null&&(u=this.normalizer(u));let d=this.pre_tokenizer!==null?this.pre_tokenizer(u):[u];return this.model(d)}}).flat()}encode(t,i=null,{add_special_tokens:s=!0}={}){let u=this._encode_text(t),d=this._encode_text(i),a=this.post_processor!==null&&s?this.post_processor(u,d):mergeArrays(u??[],d??[]);return this.model.convert_tokens_to_ids(a)}batch_decode(t,i={}){return t instanceof Tensor&&(t=t.tolist()),t.map(s=>this.decode(s,i))}decode(t,i={}){if(t instanceof Tensor&&(t=prepareTensorForDecode(t)),!Array.isArray(t)||t.length===0||!isIntegralNumber(t[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(t,i)}decode_single(t,{skip_special_tokens:i=!1,clean_up_tokenization_spaces:s=null}){let u=this.model.convert_ids_to_tokens(t);i&&(u=u.filter(a=>!this.special_tokens.includes(a)));let d=this.decoder(u);return this.decoder.end_of_word_suffix&&(d=d.replaceAll(this.decoder.end_of_word_suffix," "),i&&(d=d.trim())),(s??this.clean_up_tokenization_spaces)&&(d=clean_up_tokenization(d)),d}}function add_token_types(m){if(m.input_ids instanceof Tensor)m.token_type_ids=new Tensor("int64",new BigInt64Array(m.input_ids.data.length),m.input_ids.dims);else if(Array.isArray(m.input_ids))Array.isArray(m.input_ids[0])?m.token_type_ids=m.input_ids.map(t=>new Array(t.length).fill(0)):m.token_type_ids=new Array(m.input_ids.length).fill(0);else throw new Error("Input ids must be a Tensor or an Array");return m}class BertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class AlbertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class MobileBertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class SqueezeBertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class DebertaTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class DebertaV2Tokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class HerbertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class DistilBertTokenizer extends PreTrainedTokenizer{}class CamembertTokenizer extends PreTrainedTokenizer{}class XLMTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),console.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}prepare_model_inputs(t){return add_token_types(t)}}class T5Tokenizer extends PreTrainedTokenizer{}class GPT2Tokenizer extends PreTrainedTokenizer{}class BartTokenizer extends PreTrainedTokenizer{}class MBartTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(t,i,s){return _build_translation_inputs(this,t,i,s)}}class MBart50Tokenizer extends MBartTokenizer{}class RobertaTokenizer extends PreTrainedTokenizer{}class BloomTokenizer extends PreTrainedTokenizer{constructor(t,i){var d,a;const s=".,!?…。,、।۔،",u=(a=(d=t.pre_tokenizer)==null?void 0:d.pretokenizers[0])==null?void 0:a.pattern;u&&u.Regex===` ?[^(\\s|[${s}])]+`&&(u.Regex=` ?[^\\s${s}]+`),super(t,i)}}class LlamaTokenizer extends PreTrainedTokenizer{}class CodeLlamaTokenizer extends PreTrainedTokenizer{}class XLMRobertaTokenizer extends PreTrainedTokenizer{}class MPNetTokenizer extends PreTrainedTokenizer{}class FalconTokenizer extends PreTrainedTokenizer{}class GPTNeoXTokenizer extends PreTrainedTokenizer{}function _build_translation_inputs(m,t,i,s){if(!("language_codes"in m)||!Array.isArray(m.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in m)||!(m.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in m)||typeof m.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");const u=s.src_lang,d=s.tgt_lang;if(!m.language_codes.includes(d))throw new Error(`Target language code "${d}" is not valid. Must be one of: {${m.language_codes.join(", ")}}`);if(u!==void 0){if(!m.language_codes.includes(u))throw new Error(`Source language code "${u}" is not valid. Must be one of: {${m.language_codes.join(", ")}}`);for(let a of m.post_processor.config.single)if("SpecialToken"in a&&m.languageRegex.test(a.SpecialToken.id)){a.SpecialToken.id=m.lang_to_token(u);break}}return s.forced_bos_token_id=m.model.convert_tokens_to_ids([m.lang_to_token(d)])[0],m._call(t,i)}class NllbTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(t,i,s){return _build_translation_inputs(this,t,i,s)}}class M2M100Tokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s.slice(2,-2)),this.lang_to_token=s=>`__${s}__`}_build_translation_inputs(t,i,s){return _build_translation_inputs(this,t,i,s)}}const WHISPER_LANGUAGES=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["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"],["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"],["si","sinhala"],["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"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],WHISPER_LANGUAGE_MAPPING=new Map(WHISPER_LANGUAGES),WHISPER_TO_LANGUAGE_CODE_MAPPING=new Map([...WHISPER_LANGUAGES.map(([m,t])=>[t,m]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);class WhisperTokenizer extends PreTrainedTokenizer{_decode_asr(t,{return_timestamps:i=!1,return_language:s=!1,time_precision:u=null,force_full_sequences:d=!0}={}){if(u===null)throw Error("Must specify time_precision");let a=null;const h=i==="word";function f(){return{language:a,timestamp:[null,null],text:""}}const c=[];let l=f(),n=0;const e=this.model.convert_tokens_to_ids(["<|notimestamps|>"])[0]+1;let r=[],o=[],p=!1,g=null;const _=new Set(this.all_special_ids);for(let w of t){const T=w.tokens,S=h?w.token_timestamps:null;let A=null,P=e;if("stride"in w){const[N,z,$]=w.stride;if(n-=z,g=N-$,z&&(P=z/u+e),$)for(let C=T.length-1;C>=0;--C){const G=T[C];if(G>=e){if(A!==null&&(G-e)*u=e){const $=(z-e)*u+n,C=round($,2);if(A!==null&&z>=A)p=!0;else if(p||r.length>0&&z0?(r.push(x),h&&o.push(M)):r.every(N=>N.length===0)&&(l=f(),r=[],x=[],o=[],M=[])}if(r.length>0){if(d&&i)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");const[w,T]=this.findLongestCommonSequence(r,o),S=this.decode(w);l.text=S,h&&(l.words=this.collateWordTimestamps(w,T,a)),c.push(l)}let b=Object.create(null);const y=c.map(w=>w.text).join("");if(i||s){for(let w=0;w0;let h=a?[]:null,f=a?i[0]:null;for(let c=1;cC===N[G]).length,$=z/w+T;z>1&&$>n&&(n=$,e=[S,A,x,M])}const[o,p,g,_]=e,b=Math.floor((p+o)/2),y=Math.floor((_+g)/2);d.push(...s.slice(0,b)),s=l.slice(y),u=s.length,a&&(h.push(...f.slice(0,b)),f=i[c].slice(y))}return d.push(...s),a?(h.push(...f),[d,h]):[d,[]]}collateWordTimestamps(t,i,s){let[u,d,a]=this.combineTokensIntoWords(t,s),h=[];for(let f=0;f=u){let h=(a-u)*s;h=round(h,2),d.push(`<|${h}|>`),d.push([])}else d[d.length-1].push(a);return d=d.map(a=>typeof a=="string"?a:super.decode(a,i)),d.join("")}splitTokensOnUnicode(t){const i=this.decode(t,{decode_with_timestamps:!0}),s="�";let u=[],d=[],a=[],h=[],f=[],c=0;for(let l=0;l=this.model.tokens_to_ids.get("<|endoftext|>"),o=l.startsWith(" "),p=l.trim(),g=f.test(p);if(r||o||g||d.length===0)d.push(l),a.push(n),h.push(e);else{const _=d.length-1;d[_]+=l,a[_].push(...n),h[_].push(...e)}}return[d,a,h]}mergePunctuations(t,i,s,u,d){let a=structuredClone(t),h=structuredClone(i),f=structuredClone(s),c=a.length-2,l=a.length-1;for(;c>=0;)a[c].startsWith(" ")&&u.includes(a[c].trim())?(a[l]=a[c]+a[l],h[l]=mergeArrays(h[c],h[l]),f[l]=mergeArrays(f[c],f[l]),a[c]="",h[c]=[],f[c]=[]):l=c,--c;for(c=0,l=1;ln),h.filter(n=>n.length>0),f.filter(n=>n.length>0)]}get_decoder_prompt_ids({language:t=null,task:i=null,no_timestamps:s=!0}={}){let u=[];if(t){t=t.toLowerCase();let d=WHISPER_TO_LANGUAGE_CODE_MAPPING.get(t);if(d===void 0)if(WHISPER_LANGUAGE_MAPPING.has(t))d=t;else{const f=t.length===2?WHISPER_LANGUAGE_MAPPING.keys():WHISPER_LANGUAGE_MAPPING.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(f)}`)}let a=this.model.tokens_to_ids.get(`<|${d}|>`);if(a===void 0)throw new Error(`Unable to find language "${d}" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.`);u.push(a)}else u.push(null);if(i){if(i=i.toLowerCase(),i!=="transcribe"&&i!=="translate")throw new Error(`Task "${i}" is not supported. Must be one of: ["transcribe", "translate"]`);let d=this.model.tokens_to_ids.get(`<|${i}|>`);if(d===void 0)throw new Error(`Unable to find task "${i}" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.`);u.push(d)}else u.push(null);if(s){let d=this.model.tokens_to_ids.get("<|notimestamps|>");if(d===void 0)throw new Error('Unable to find "<|notimestamps|>" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.');u.push(d)}return u.map((d,a)=>[a+1,d]).filter(d=>d[1]!==null)}}class CodeGenTokenizer extends PreTrainedTokenizer{}class CLIPTokenizer extends PreTrainedTokenizer{}class MarianTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=this.model.vocab.filter(s=>this.languageRegex.test(s)),console.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(t){if(t===null)return null;let[i,...s]=t.trim().split(this.languageRegex);if(s.length===0)return super._encode_text(i);if(s.length===2){let[u,d]=s;return this.supported_language_codes.includes(u)||console.warn(`Unsupported language code "${u}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),mergeArrays([u],super._encode_text(d))}}}class Wav2Vec2CTCTokenizer extends PreTrainedTokenizer{}class BlenderbotTokenizer extends PreTrainedTokenizer{}class BlenderbotSmallTokenizer extends PreTrainedTokenizer{}class SpeechT5Tokenizer extends PreTrainedTokenizer{}class NougatTokenizer extends PreTrainedTokenizer{}class AutoTokenizer{static async from_pretrained(t,{quantized:i=!0,progress_callback:s=null,config:u=null,cache_dir:d=null,local_files_only:a=!1,revision:h="main"}={}){let[f,c]=await loadTokenizer(t,{quantized:i,progress_callback:s,config:u,cache_dir:d,local_files_only:a,revision:h}),l=c.tokenizer_class.replace(/Fast$/,""),n=this.TOKENIZER_CLASS_MAPPING[l];return n||(console.warn(`Unknown tokenizer class "${l}", attempting to construct from base class.`),n=PreTrainedTokenizer),new n(f,c)}}le(AutoTokenizer,"TOKENIZER_CLASS_MAPPING",{T5Tokenizer,DistilBertTokenizer,CamembertTokenizer,DebertaTokenizer,DebertaV2Tokenizer,BertTokenizer,HerbertTokenizer,XLMTokenizer,MobileBertTokenizer,SqueezeBertTokenizer,AlbertTokenizer,GPT2Tokenizer,BartTokenizer,MBartTokenizer,MBart50Tokenizer,RobertaTokenizer,WhisperTokenizer,CodeGenTokenizer,CLIPTokenizer,MarianTokenizer,BloomTokenizer,NllbTokenizer,M2M100Tokenizer,LlamaTokenizer,CodeLlamaTokenizer,XLMRobertaTokenizer,MPNetTokenizer,FalconTokenizer,GPTNeoXTokenizer,Wav2Vec2CTCTokenizer,BlenderbotTokenizer,BlenderbotSmallTokenizer,SpeechT5Tokenizer,NougatTokenizer,PreTrainedTokenizer});async function loadConfig(m,t){return await getModelJSON(m,"config.json",!0,t)}class PretrainedConfig{constructor(t){this.model_type=null,this.is_encoder_decoder=!1,Object.assign(this,t)}static async from_pretrained(t,{progress_callback:i=null,config:s=null,cache_dir:u=null,local_files_only:d=!1,revision:a="main"}={}){let h=s??await loadConfig(t,{progress_callback:i,config:s,cache_dir:u,local_files_only:d,revision:a});return new this(h)}}class AutoConfig{static async from_pretrained(...t){return PretrainedConfig.from_pretrained(...t)}}class LogitsProcessorList extends Callable{constructor(){super(),this.processors=[]}push(t){this.processors.push(t)}extend(t){this.processors.push(...t)}_call(t,i){for(let s of i)this.processors.forEach(u=>u(t,s))}[Symbol.iterator](){return this.processors.values()}}class LogitsProcessor extends Callable{_call(t,i){throw Error("`_call` should be implemented in a subclass")}}class ForceTokensLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.force_token_map=Object.fromEntries(t??[])}_call(t,i){let s=this.force_token_map[t.length];return exists(s)&&(i.data.fill(-1/0),i.data[s]=0),i}}class ForcedBOSTokenLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.bos_token_id=t}_call(t,i){return t.length===1&&(i.data.fill(-1/0),i.data[this.bos_token_id]=0),i}}class ForcedEOSTokenLogitsProcessor extends LogitsProcessor{constructor(t,i){super(),this.max_length=t,this.forced_eos_token_id=i}_call(t,i){}}class SuppressTokensAtBeginLogitsProcessor extends LogitsProcessor{constructor(t,i){super(),this.begin_suppress_tokens=t,this.begin_index=i}_call(t,i){if(t.length===this.begin_index)for(let s of this.begin_suppress_tokens)i.data[s]=-1/0;return i}}class WhisperTimeStampLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.eos_token_id=t.eos_token_id,this.no_timestamps_token_id=t.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=(t.forced_decoder_ids||[]).length+2,t.forced_decoder_ids.slice(-1)[0][1]===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=t.max_initial_timestamp_index}_call(t,i){if(i.data[this.no_timestamps_token_id]=-1/0,t.length===this.begin_index-1)return i.data.fill(-1/0),i.data[this.timestamp_begin]=0,i;const s=t.slice(this.begin_index),u=s.length>=1&&s[s.length-1]>=this.timestamp_begin,d=s.length<2||s[s.length-2]>=this.timestamp_begin;if(u&&(d?i.data.subarray(this.timestamp_begin).fill(-1/0):i.data.subarray(0,this.eos_token_id).fill(-1/0)),t.length===this.begin_index&&this.max_initial_timestamp_index!==null){const c=this.timestamp_begin+this.max_initial_timestamp_index;i.data.subarray(c+1).fill(-1/0)}const a=log_softmax(i.data),h=Math.log(a.subarray(this.timestamp_begin).map(Math.exp).reduce((c,l)=>c+l)),f=max(a.subarray(0,this.timestamp_begin))[0];return h>f&&i.data.subarray(0,this.timestamp_begin).fill(-1/0),i}}class NoRepeatNGramLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.no_repeat_ngram_size=t}getNgrams(t){const i=t.length,s=[];for(let d=0;d0&&(u=u.map(d=>d/this.generation_config.temperature)),u}randomSelect(t){let i=t.reduce((u,d)=>u+d,0),s=Math.random()*i;for(let u=0;u1)return new BeamSearchSampler(t);if(t.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${t.num_return_sequences}.`);return new GreedySampler(t)}}class GreedySampler extends Sampler{sample(t,i=-1){let s=this.getLogits(t,i);return[[max(s)[1],0]]}}class MultinomialSampler extends Sampler{sample(t,i=-1){let s=t.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));const u=this.getLogits(t,i),d=getTopItems(u,s),a=softmax(d.map(h=>h[1]));return Array.from({length:this.generation_config.num_beams},()=>{const h=this.randomSelect(a);return[d[h][0],Math.log(a[h])]})}}class BeamSearchSampler extends Sampler{sample(t,i=-1){let s=t.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));const u=this.getLogits(t,i),d=getTopItems(u,s),a=softmax(d.map(h=>h[1]));return Array.from({length:this.generation_config.num_beams},(h,f)=>[d[f][0],Math.log(a[f])])}}const{InferenceSession,Tensor:ONNXTensor,env}=ONNX,MODEL_TYPES={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4},MODEL_TYPE_MAPPING=new Map,MODEL_NAME_TO_CLASS_MAPPING=new Map,MODEL_CLASS_TO_NAME_MAPPING=new Map;async function constructSession(m,t,i){let s=`onnx/${t}${i.quantized?"_quantized":""}.onnx`,u=await getModelFile(m,s,!0,i);try{return await InferenceSession.create(u,{executionProviders})}catch(d){if(executionProviders.length===1&&executionProviders[0]==="wasm")throw d;return console.warn(d),console.warn("Something went wrong during model construction (most likely a missing operation). Using `wasm` as a fallback. "),await InferenceSession.create(u,{executionProviders:["wasm"]})}}function validateInputs(m,t){const i=Object.create(null),s=[];for(const a of m.inputNames){const h=t[a];if(!(h instanceof Tensor)){s.push(a);continue}i[a]=env.wasm.proxy?h.clone():h}if(s.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);const u=Object.keys(t).length,d=m.inputNames.length;if(u>d){let a=Object.keys(t).filter(h=>!m.inputNames.includes(h));console.warn(`WARNING: Too many inputs were provided (${u} > ${d}). The following inputs will be ignored: "${a.join(", ")}".`)}return i}async function sessionRun(m,t){const i=validateInputs(m,t);try{let s=await m.run(i);return s=replaceTensors(s),s}catch(s){throw console.error(`An error occurred during model execution: "${s}".`),console.error("Inputs given to model:",i),s}}function replaceTensors(m){for(let t in m)m[t]instanceof ONNXTensor?m[t]=new Tensor(m[t]):typeof m[t]=="object"&&replaceTensors(m[t]);return m}function toI64Tensor(m){if(m instanceof Tensor)return m;if(m.length===0)throw Error("items must be non-empty");if(Array.isArray(m[0])){if(m.some(t=>t.length!==m[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new Tensor("int64",BigInt64Array.from(m.flat().map(t=>BigInt(t))),[m.length,m[0].length])}else return new Tensor("int64",BigInt64Array.from(m.map(t=>BigInt(t))),[1,m.length])}function prepareAttentionMask(m,t){let i=m.config.pad_token_id??null,s=m.config.eos_token_id??null;isIntegralNumber(s)&&(s=[s]);let u=t.indexOf(i)!==-1,d=s===null||!s.includes(i);if(u&&d){let a=BigInt64Array.from(t.data.map(h=>h!=i));return new Tensor("int64",a,t.dims)}else return ones_like(t)}function preparePositionIds(m,t,i){if(!m.inputNames.includes("position_ids"))return;const s=new BigInt64Array(t.attention_mask.data.length);for(let u=0;u0&&d.push(new NoRepeatNGramLogitsProcessor(i.no_repeat_ngram_size)),i.bad_words_ids!==null&&d.push(new NoBadWordsLogitsProcessor(i.bad_words_ids,i.eos_token_id)),i.min_length!==null&&i.eos_token_id!==null&&i.min_length>0&&d.push(new MinLengthLogitsProcessor(i.min_length,i.eos_token_id)),i.min_new_tokens!==null&&i.eos_token_id!==null&&i.min_new_tokens>0&&d.push(new MinNewTokensLengthLogitsProcessor(s,i.min_new_tokens,i.eos_token_id)),i.forced_bos_token_id!==null&&d.push(new ForcedBOSTokenLogitsProcessor(i.forced_bos_token_id)),i.forced_eos_token_id!==null&&d.push(new ForcedEOSTokenLogitsProcessor(i.max_length,i.forced_eos_token_id)),i.begin_suppress_tokens!==null){let a=s>1||i.forced_bos_token_id===null?s:s+1;i.forced_decoder_ids!==null&&(a+=i.forced_decoder_ids[i.forced_decoder_ids.length-1][0]),d.push(new SuppressTokensAtBeginLogitsProcessor(i.begin_suppress_tokens,a))}return i.forced_decoder_ids!==null&&d.push(new ForceTokensLogitsProcessor(i.forced_decoder_ids)),u!==null&&d.extend(u),d}_get_generation_config(i){let s=new GenerationConfig(this.config);return"generation_config"in this&&Object.assign(s,this.generation_config),i!==null&&Object.assign(s,i),s}async generate(i,s=null,u=null,{inputs_attention_mask:d=null}={}){if(!this.can_generate){let _=`The current model class (${MODEL_CLASS_TO_NAME_MAPPING.get(this.constructor)}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;const b=this.config.model_type,y=MODEL_WITH_LM_HEAD_MAPPING_NAMES.get(b)??MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES.get(b)??MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES.get(b)??MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES.get(b);throw y&&(_+=` Please use the following class instead: '${y[0]}'`),Error(_)}if(!(i instanceof Tensor)&&!isTypedArray(i)&&!Array.isArray(i))throw Error(`\`inputs\` must be a Tensor, TypedArray, or Array, but is "${i.constructor.name}".`);let a;if(this.config.is_encoder_decoder)a=0;else if(a=i instanceof Tensor?i.dims.at(-1):i.length,a===0)throw Error("Must supply a non-empty array of input token ids.");s=this._get_generation_config(s),u=u??new LogitsProcessorList,u=this._get_logits_processor(s,a,u);let h=s.eos_token_id;h!==null&&!Array.isArray(h)&&(h=[h]);let f=1;const c=f+(s.max_new_tokens??1/0),l=Number.isInteger(s.max_length)&&(s.max_new_tokens??null)===null;let n=Sampler.getSampler(s),e=this.getStartBeams(i,s,f,d);for(;e.some(g=>!g.done)&&f=s.max_length){_.done=!0,g.push(_);continue}let b=await this.runBeam(_);s.output_attentions&&this.addAttentionsToBeam(_,b),s.output_scores;let y=b.logits.slice(null,-1,null);u(_.output_token_ids,y);let w=n(y);for(let[T,S]of w){let A={..._};this.updateBeam(A,T),A.score+=S,h&&h.includes(T)&&(A.done=!0),g.push(A)}}++f,g=this.groupBeams(g).map(_=>_.sort((b,y)=>y.score-b.score).slice(0,s.num_beams)),e=g.flat(),s.callback_function&&s.callback_function(e)}const r=this.groupBeams(e),o=g=>r.map(_=>s.num_return_sequences>1?_.slice(0,s.num_return_sequences).map(b=>b[g]):[_[0][g]]).flat(),p=o("output_token_ids");if(s.return_dict_in_generate){const g=o("decoder_attentions"),_=o("cross_attentions");return{sequences:p,decoder_attentions:g,cross_attentions:_}}else return p}addAttentionsToBeam(i,s){if(this.config.is_encoder_decoder){if(!s.cross_attentions||s.cross_attentions.length===0)throw Error("`output_attentions` is true, but the model did not produce cross-attentions. This is most likely because the model was not exported with `output_attentions=True`.");i.cross_attentions||(i.cross_attentions=[]),i.cross_attentions.push(s.cross_attentions)}if(!s.decoder_attentions||s.decoder_attentions.length===0)throw Error("`output_attentions` is true, but the model did not produce decoder-attentions. This is most likely because the model was not exported with `output_attentions=True`.");i.decoder_attentions||(i.decoder_attentions=[]),i.decoder_attentions.push(s.decoder_attentions)}groupBeams(i){const s=Object.create(null);for(const u of i)s[u.id]===void 0?s[u.id]=[u]:s[u.id].push(u);return Object.values(s)}getPastKeyValues(i,s){const u=Object.create(null);for(const d in i)if(d.startsWith("present")){let a=d.replace("present","past_key_values");s&&d.includes("encoder")?u[a]=s[a]:u[a]=i[d]}return u}getAttentions(i){const s=Object.create(null);for(const u of["cross_attentions","decoder_attentions"]){const d=[];for(const a in i)if(a.startsWith(u)){const h=a.split(".").pop();d[h]=i[a]}s[u]=d}return s}addPastKeyValues(i,s){if(s)Object.assign(i,s);else if(this.config.is_encoder_decoder&&(this.add_encoder_pkv??!0)){let d=[1,this.num_encoder_heads,0,this.encoder_dim_kv],a=[1,this.num_decoder_heads,0,this.decoder_dim_kv];for(let h=0;h{let n=Array.from({length:this.config.decoder_layers},(_,b)=>cat(l.map(y=>y[b]),2)),e=stack(s.map(([_,b])=>u?n[_].slice(null,b,null,[0,u]):n[_].slice(null,b)));e=e.transpose(1,0,2,3);let[r,o]=std_mean(e,-2,0,!0),p=e.clone();for(let _=0;_e[b+1]-e[b]),p=mergeArrays([1],o).map(_=>!!_),g=[];for(let _=0;_=e&&(Array.from(A.data).filter(x=>x>=s).length>0||_>=n))break}const b=cat(o),{waveform:y}=await sessionRun(a.session,{spectrogram:b});return{spectrogram:b,waveform:y}}}class SpeechT5HifiGan extends PreTrainedModel{constructor(){super(...arguments);le(this,"main_input_name","spectrogram")}}class TrOCRPreTrainedModel extends PreTrainedModel{constructor(t,i,s){super(t,i),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_encoder_layers=this.num_decoder_layers=this.config.decoder_layers,this.num_encoder_heads=this.num_decoder_heads=this.config.decoder_attention_heads,this.encoder_dim_kv=this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads}}class TrOCRForCausalLM extends TrOCRPreTrainedModel{}class MistralPreTrainedModel extends PreTrainedModel{constructor(t,i,s){super(t,i),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_key_value_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class MistralModel extends MistralPreTrainedModel{}class MistralForCausalLM extends MistralPreTrainedModel{}class FalconPreTrainedModel extends PreTrainedModel{constructor(t,i,s){super(t,i),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class FalconModel extends FalconPreTrainedModel{}class FalconForCausalLM extends FalconPreTrainedModel{}class ClapPreTrainedModel extends PreTrainedModel{}class ClapModel extends ClapPreTrainedModel{}class ClapTextModelWithProjection extends ClapPreTrainedModel{static async from_pretrained(t,i={}){return i.model_file_name??(i.model_file_name="text_model"),super.from_pretrained(t,i)}}class ClapAudioModelWithProjection extends ClapPreTrainedModel{static async from_pretrained(t,i={}){return i.model_file_name??(i.model_file_name="audio_model"),super.from_pretrained(t,i)}}class PretrainedMixin{static async from_pretrained(t,{quantized:i=!0,progress_callback:s=null,config:u=null,cache_dir:d=null,local_files_only:a=!1,revision:h="main",model_file_name:f=null}={}){let c={quantized:i,progress_callback:s,config:u,cache_dir:d,local_files_only:a,revision:h,model_file_name:f};if(u=await AutoConfig.from_pretrained(t,c),c.config||(c.config=u),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);for(let l of this.MODEL_CLASS_MAPPINGS){const n=l.get(u.model_type);if(n)return await n[1].from_pretrained(t,c)}if(this.BASE_IF_FAIL)return console.warn(`Unknown model class "${u.model_type}", attempting to construct from base class.`),await PreTrainedModel.from_pretrained(t,c);throw Error(`Unsupported model type: ${u.model_type}`)}}le(PretrainedMixin,"MODEL_CLASS_MAPPINGS",null),le(PretrainedMixin,"BASE_IF_FAIL",!1);const MODEL_MAPPING_NAMES_ENCODER_ONLY=new Map([["bert",["BertModel",BertModel]],["camembert",["CamembertModel",CamembertModel]],["deberta",["DebertaModel",DebertaModel]],["deberta-v2",["DebertaV2Model",DebertaV2Model]],["mpnet",["MPNetModel",MPNetModel]],["albert",["AlbertModel",AlbertModel]],["distilbert",["DistilBertModel",DistilBertModel]],["roberta",["RobertaModel",RobertaModel]],["xlm",["XLMModel",XLMModel]],["xlm-roberta",["XLMRobertaModel",XLMRobertaModel]],["clap",["ClapModel",ClapModel]],["clip",["CLIPModel",CLIPModel]],["mobilebert",["MobileBertModel",MobileBertModel]],["squeezebert",["SqueezeBertModel",SqueezeBertModel]],["wav2vec2",["Wav2Vec2Model",Wav2Vec2Model]],["wavlm",["WavLMModel",WavLMModel]],["audio-spectrogram-transformer",["ASTModel",ASTModel]],["detr",["DetrModel",DetrModel]],["vit",["ViTModel",ViTModel]],["mobilevit",["MobileViTModel",MobileViTModel]],["owlvit",["OwlViTModel",OwlViTModel]],["beit",["BeitModel",BeitModel]],["deit",["DeiTModel",DeiTModel]],["convnext",["ConvNextModel",ConvNextModel]],["convnextv2",["ConvNextV2Model",ConvNextV2Model]],["resnet",["ResNetModel",ResNetModel]],["swin",["SwinModel",SwinModel]],["swin2sr",["Swin2SRModel",Swin2SRModel]],["donut-swin",["DonutSwinModel",DonutSwinModel]],["yolos",["YolosModel",YolosModel]],["dpt",["DPTModel",DPTModel]],["glpn",["GLPNModel",GLPNModel]],["hifigan",["SpeechT5HifiGan",SpeechT5HifiGan]],["sam",["SamModel",SamModel]]]),MODEL_MAPPING_NAMES_ENCODER_DECODER=new Map([["t5",["T5Model",T5Model]],["longt5",["LongT5Model",LongT5Model]],["mt5",["MT5Model",MT5Model]],["bart",["BartModel",BartModel]],["mbart",["MBartModel",MBartModel]],["marian",["MarianModel",MarianModel]],["whisper",["WhisperModel",WhisperModel]],["m2m_100",["M2M100Model",M2M100Model]],["blenderbot",["BlenderbotModel",BlenderbotModel]],["blenderbot-small",["BlenderbotSmallModel",BlenderbotSmallModel]]]),MODEL_MAPPING_NAMES_DECODER_ONLY=new Map([["bloom",["BloomModel",BloomModel]],["gpt2",["GPT2Model",GPT2Model]],["gptj",["GPTJModel",GPTJModel]],["gpt_bigcode",["GPTBigCodeModel",GPTBigCodeModel]],["gpt_neo",["GPTNeoModel",GPTNeoModel]],["gpt_neox",["GPTNeoXModel",GPTNeoXModel]],["codegen",["CodeGenModel",CodeGenModel]],["llama",["LlamaModel",LlamaModel]],["mpt",["MptModel",MptModel]],["opt",["OPTModel",OPTModel]],["mistral",["MistralModel",MistralModel]],["falcon",["FalconModel",FalconModel]]]),MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES=new Map([["speecht5",["SpeechT5ForSpeechToText",SpeechT5ForSpeechToText]],["whisper",["WhisperForConditionalGeneration",WhisperForConditionalGeneration]]]),MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES=new Map([["speecht5",["SpeechT5ForTextToSpeech",SpeechT5ForTextToSpeech]]]),MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES=new Map([["bert",["BertForSequenceClassification",BertForSequenceClassification]],["camembert",["CamembertForSequenceClassification",CamembertForSequenceClassification]],["deberta",["DebertaForSequenceClassification",DebertaForSequenceClassification]],["deberta-v2",["DebertaV2ForSequenceClassification",DebertaV2ForSequenceClassification]],["mpnet",["MPNetForSequenceClassification",MPNetForSequenceClassification]],["albert",["AlbertForSequenceClassification",AlbertForSequenceClassification]],["distilbert",["DistilBertForSequenceClassification",DistilBertForSequenceClassification]],["roberta",["RobertaForSequenceClassification",RobertaForSequenceClassification]],["xlm",["XLMForSequenceClassification",XLMForSequenceClassification]],["xlm-roberta",["XLMRobertaForSequenceClassification",XLMRobertaForSequenceClassification]],["bart",["BartForSequenceClassification",BartForSequenceClassification]],["mbart",["MBartForSequenceClassification",MBartForSequenceClassification]],["mobilebert",["MobileBertForSequenceClassification",MobileBertForSequenceClassification]],["squeezebert",["SqueezeBertForSequenceClassification",SqueezeBertForSequenceClassification]]]),MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES=new Map([["bert",["BertForTokenClassification",BertForTokenClassification]],["camembert",["CamembertForTokenClassification",CamembertForTokenClassification]],["deberta",["DebertaForTokenClassification",DebertaForTokenClassification]],["deberta-v2",["DebertaV2ForTokenClassification",DebertaV2ForTokenClassification]],["mpnet",["MPNetForTokenClassification",MPNetForTokenClassification]],["distilbert",["DistilBertForTokenClassification",DistilBertForTokenClassification]],["roberta",["RobertaForTokenClassification",RobertaForTokenClassification]],["xlm",["XLMForTokenClassification",XLMForTokenClassification]],["xlm-roberta",["XLMRobertaForTokenClassification",XLMRobertaForTokenClassification]]]),MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES=new Map([["t5",["T5ForConditionalGeneration",T5ForConditionalGeneration]],["longt5",["LongT5ForConditionalGeneration",LongT5ForConditionalGeneration]],["mt5",["MT5ForConditionalGeneration",MT5ForConditionalGeneration]],["bart",["BartForConditionalGeneration",BartForConditionalGeneration]],["mbart",["MBartForConditionalGeneration",MBartForConditionalGeneration]],["marian",["MarianMTModel",MarianMTModel]],["m2m_100",["M2M100ForConditionalGeneration",M2M100ForConditionalGeneration]],["blenderbot",["BlenderbotForConditionalGeneration",BlenderbotForConditionalGeneration]],["blenderbot-small",["BlenderbotSmallForConditionalGeneration",BlenderbotSmallForConditionalGeneration]]]),MODEL_WITH_LM_HEAD_MAPPING_NAMES=new Map([["bloom",["BloomForCausalLM",BloomForCausalLM]],["gpt2",["GPT2LMHeadModel",GPT2LMHeadModel]],["gptj",["GPTJForCausalLM",GPTJForCausalLM]],["gpt_bigcode",["GPTBigCodeForCausalLM",GPTBigCodeForCausalLM]],["gpt_neo",["GPTNeoForCausalLM",GPTNeoForCausalLM]],["gpt_neox",["GPTNeoXForCausalLM",GPTNeoXForCausalLM]],["codegen",["CodeGenForCausalLM",CodeGenForCausalLM]],["llama",["LlamaForCausalLM",LlamaForCausalLM]],["mpt",["MptForCausalLM",MptForCausalLM]],["opt",["OPTForCausalLM",OPTForCausalLM]],["mbart",["MBartForCausalLM",MBartForCausalLM]],["mistral",["MistralForCausalLM",MistralForCausalLM]],["falcon",["FalconForCausalLM",FalconForCausalLM]],["trocr",["TrOCRForCausalLM",TrOCRForCausalLM]]]),MODEL_FOR_MASKED_LM_MAPPING_NAMES=new Map([["bert",["BertForMaskedLM",BertForMaskedLM]],["camembert",["CamembertForMaskedLM",CamembertForMaskedLM]],["deberta",["DebertaForMaskedLM",DebertaForMaskedLM]],["deberta-v2",["DebertaV2ForMaskedLM",DebertaV2ForMaskedLM]],["mpnet",["MPNetForMaskedLM",MPNetForMaskedLM]],["albert",["AlbertForMaskedLM",AlbertForMaskedLM]],["distilbert",["DistilBertForMaskedLM",DistilBertForMaskedLM]],["roberta",["RobertaForMaskedLM",RobertaForMaskedLM]],["xlm",["XLMWithLMHeadModel",XLMWithLMHeadModel]],["xlm-roberta",["XLMRobertaForMaskedLM",XLMRobertaForMaskedLM]],["mobilebert",["MobileBertForMaskedLM",MobileBertForMaskedLM]],["squeezebert",["SqueezeBertForMaskedLM",SqueezeBertForMaskedLM]]]),MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES=new Map([["bert",["BertForQuestionAnswering",BertForQuestionAnswering]],["camembert",["CamembertForQuestionAnswering",CamembertForQuestionAnswering]],["deberta",["DebertaForQuestionAnswering",DebertaForQuestionAnswering]],["deberta-v2",["DebertaV2ForQuestionAnswering",DebertaV2ForQuestionAnswering]],["mpnet",["MPNetForQuestionAnswering",MPNetForQuestionAnswering]],["albert",["AlbertForQuestionAnswering",AlbertForQuestionAnswering]],["distilbert",["DistilBertForQuestionAnswering",DistilBertForQuestionAnswering]],["roberta",["RobertaForQuestionAnswering",RobertaForQuestionAnswering]],["xlm",["XLMForQuestionAnswering",XLMForQuestionAnswering]],["xlm-roberta",["XLMRobertaForQuestionAnswering",XLMRobertaForQuestionAnswering]],["mobilebert",["MobileBertForQuestionAnswering",MobileBertForQuestionAnswering]],["squeezebert",["SqueezeBertForQuestionAnswering",SqueezeBertForQuestionAnswering]]]),MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES=new Map([["vit",["ViTForImageClassification",ViTForImageClassification]],["mobilevit",["MobileViTForImageClassification",MobileViTForImageClassification]],["beit",["BeitForImageClassification",BeitForImageClassification]],["deit",["DeiTForImageClassification",DeiTForImageClassification]],["convnext",["ConvNextForImageClassification",ConvNextForImageClassification]],["convnextv2",["ConvNextV2ForImageClassification",ConvNextV2ForImageClassification]],["resnet",["ResNetForImageClassification",ResNetForImageClassification]],["swin",["SwinForImageClassification",SwinForImageClassification]]]),MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES=new Map([["detr",["DetrForObjectDetection",DetrForObjectDetection]],["yolos",["YolosForObjectDetection",YolosForObjectDetection]]]),MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES=new Map([["owlvit",["OwlViTForObjectDetection",OwlViTForObjectDetection]]]),MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES=new Map([["detr",["DetrForSegmentation",DetrForSegmentation]]]),MODEL_FOR_MASK_GENERATION_MAPPING_NAMES=new Map([["sam",["SamModel",SamModel]]]),MODEL_FOR_CTC_MAPPING_NAMES=new Map([["wav2vec2",["Wav2Vec2ForCTC",Wav2Vec2ForCTC]],["wavlm",["WavLMForCTC",WavLMForCTC]]]),MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES=new Map([["wav2vec2",["Wav2Vec2ForSequenceClassification",Wav2Vec2ForSequenceClassification]],["wavlm",["WavLMForSequenceClassification",WavLMForSequenceClassification]],["audio-spectrogram-transformer",["ASTForAudioClassification",ASTForAudioClassification]]]),MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES=new Map([["swin2sr",["Swin2SRForImageSuperResolution",Swin2SRForImageSuperResolution]]]),MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES=new Map([["dpt",["DPTForDepthEstimation",DPTForDepthEstimation]],["glpn",["GLPNForDepthEstimation",GLPNForDepthEstimation]]]),MODEL_CLASS_TYPE_MAPPING=[[MODEL_MAPPING_NAMES_ENCODER_ONLY,MODEL_TYPES.EncoderOnly],[MODEL_MAPPING_NAMES_ENCODER_DECODER,MODEL_TYPES.EncoderDecoder],[MODEL_MAPPING_NAMES_DECODER_ONLY,MODEL_TYPES.DecoderOnly],[MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_WITH_LM_HEAD_MAPPING_NAMES,MODEL_TYPES.DecoderOnly],[MODEL_FOR_MASKED_LM_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,MODEL_TYPES.Vision2Seq],[MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_MASK_GENERATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_CTC_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES,MODEL_TYPES.Seq2Seq]];for(const[m,t]of MODEL_CLASS_TYPE_MAPPING)for(const[i,s]of m.values())MODEL_TYPE_MAPPING.set(i,t),MODEL_CLASS_TO_NAME_MAPPING.set(s,i),MODEL_NAME_TO_CLASS_MAPPING.set(i,s);const CUSTOM_MAPPING=[["CLIPTextModelWithProjection",CLIPTextModelWithProjection,MODEL_TYPES.EncoderOnly],["CLIPVisionModelWithProjection",CLIPVisionModelWithProjection,MODEL_TYPES.EncoderOnly],["ClapTextModelWithProjection",ClapTextModelWithProjection,MODEL_TYPES.EncoderOnly],["ClapAudioModelWithProjection",ClapAudioModelWithProjection,MODEL_TYPES.EncoderOnly]];for(const[m,t,i]of CUSTOM_MAPPING)MODEL_TYPE_MAPPING.set(m,i),MODEL_CLASS_TO_NAME_MAPPING.set(t,m),MODEL_NAME_TO_CLASS_MAPPING.set(m,t);class AutoModel extends PretrainedMixin{}le(AutoModel,"MODEL_CLASS_MAPPINGS",[MODEL_MAPPING_NAMES_ENCODER_ONLY,MODEL_MAPPING_NAMES_ENCODER_DECODER,MODEL_MAPPING_NAMES_DECODER_ONLY]),le(AutoModel,"BASE_IF_FAIL",!0);class AutoModelForSequenceClassification extends PretrainedMixin{}le(AutoModelForSequenceClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForTokenClassification extends PretrainedMixin{}le(AutoModelForTokenClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForSeq2SeqLM extends PretrainedMixin{}le(AutoModelForSeq2SeqLM,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]);class AutoModelForSpeechSeq2Seq extends PretrainedMixin{}le(AutoModelForSpeechSeq2Seq,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]);class AutoModelForTextToSpectrogram extends PretrainedMixin{}le(AutoModelForTextToSpectrogram,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]);class AutoModelForCausalLM extends PretrainedMixin{}le(AutoModelForCausalLM,"MODEL_CLASS_MAPPINGS",[MODEL_WITH_LM_HEAD_MAPPING_NAMES]);class AutoModelForMaskedLM extends PretrainedMixin{}le(AutoModelForMaskedLM,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_MASKED_LM_MAPPING_NAMES]);class AutoModelForQuestionAnswering extends PretrainedMixin{}le(AutoModelForQuestionAnswering,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]);class AutoModelForVision2Seq extends PretrainedMixin{}le(AutoModelForVision2Seq,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]);class AutoModelForImageClassification extends PretrainedMixin{}le(AutoModelForImageClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForImageSegmentation extends PretrainedMixin{}le(AutoModelForImageSegmentation,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]);class AutoModelForObjectDetection extends PretrainedMixin{}le(AutoModelForObjectDetection,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]);class AutoModelForZeroShotObjectDetection extends PretrainedMixin{}le(AutoModelForZeroShotObjectDetection,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]);class AutoModelForCTC extends PretrainedMixin{}le(AutoModelForCTC,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_CTC_MAPPING_NAMES]);class AutoModelForAudioClassification extends PretrainedMixin{}le(AutoModelForAudioClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForDocumentQuestionAnswering extends PretrainedMixin{}le(AutoModelForDocumentQuestionAnswering,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]);class AutoModelForImageToImage extends PretrainedMixin{}le(AutoModelForImageToImage,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]);class AutoModelForDepthEstimation extends PretrainedMixin{}le(AutoModelForDepthEstimation,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]);class Seq2SeqLMOutput extends ModelOutput{constructor({logits:t,past_key_values:i,encoder_outputs:s,decoder_attentions:u=null,cross_attentions:d=null}){super(),this.logits=t,this.past_key_values=i,this.encoder_outputs=s,this.decoder_attentions=u,this.cross_attentions=d}}class SequenceClassifierOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}class TokenClassifierOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}class MaskedLMOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}class QuestionAnsweringModelOutput extends ModelOutput{constructor({start_logits:t,end_logits:i}){super(),this.start_logits=t,this.end_logits=i}}class CausalLMOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}const BROWSER_ENV=typeof self<"u",WEBWORKER_ENV=BROWSER_ENV&&self.constructor.name==="DedicatedWorkerGlobalScope";let createCanvasFunction,ImageDataClass,loadImageFunction;if(BROWSER_ENV)createCanvasFunction=(m,t)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this browser.");return new self.OffscreenCanvas(m,t)},loadImageFunction=self.createImageBitmap,ImageDataClass=self.ImageData;else if(sharp)loadImageFunction=async m=>{const i=(await m.metadata()).channels;let{data:s,info:u}=await m.raw().toBuffer({resolveWithObject:!0});const d=new RawImage(new Uint8ClampedArray(s),u.width,u.height,u.channels);return i!==void 0&&i!==u.channels&&d.convert(i),d};else throw new Error("Unable to load image processing library.");const RESAMPLING_MAPPING={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},CONTENT_TYPE_MAP=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]);class RawImage{constructor(t,i,s,u){this.data=t,this.width=i,this.height=s,this.channels=u}get size(){return[this.width,this.height]}static async read(t){if(t instanceof RawImage)return t;if(isString(t)||t instanceof URL)return await this.fromURL(t);throw new Error(`Unsupported input type: ${typeof t}`)}static async fromURL(t){let i=await getFile(t);if(i.status!==200)throw new Error(`Unable to read image from "${t}" (${i.status} ${i.statusText})`);let s=await i.blob();return this.fromBlob(s)}static async fromBlob(t){if(BROWSER_ENV){let i=await loadImageFunction(t);const s=createCanvasFunction(i.width,i.height).getContext("2d");return s.drawImage(i,0,0),new this(s.getImageData(0,0,i.width,i.height).data,i.width,i.height,4)}else{let i=sharp(await t.arrayBuffer());return await loadImageFunction(i)}}static fromTensor(t,i="CHW"){if(i==="CHW")t=t.transpose(1,2,0);else if(i!=="HWC")throw new Error(`Unsupported channel format: ${i}`);return new RawImage(t.data,t.dims[1],t.dims[0],t.dims[2])}grayscale(){if(this.channels===1)return this;let t=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let i=0,s=0;i=0?f=s:l=-s,u>=0?c=u:n=-u,h.drawImage(a,f,c,t,i,l,n,t,i),new RawImage(h.getImageData(0,0,t,i).data,t,i,4).convert(d)}else{let d=this.toSharp();if(s>=0&&u>=0)d=d.extract({left:Math.floor(s),top:Math.floor(u),width:t,height:i});else if(s<=0&&u<=0){let a=Math.floor(-u),h=Math.floor(-s);d=d.extend({top:a,left:h,right:t-this.width-h,bottom:i-this.height-a})}else{let a=[0,0],h=0;u<0?(a[0]=Math.floor(-u),a[1]=i-this.height-a[0]):h=Math.floor(u);let f=[0,0],c=0;s<0?(f[0]=Math.floor(-s),f[1]=t-this.width-f[0]):c=Math.floor(s),d=d.extend({top:a[0],bottom:a[1],left:f[0],right:f[1]}).extract({left:c,top:h,width:t,height:i})}return await loadImageFunction(d)}}async toBlob(t="image/png",i=1){if(!BROWSER_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:t,quality:i})}toCanvas(){if(!BROWSER_ENV)throw new Error("toCanvas() is only supported in browser environments.");let t=this.clone().rgba(),i=createCanvasFunction(t.width,t.height),s=new ImageDataClass(t.data,t.width,t.height);return i.getContext("2d").putImageData(s,0,0),i}_update(t,i,s,u=null){return this.data=t,this.width=i,this.height=s,u!==null&&(this.channels=u),this}clone(){return new RawImage(this.data.slice(),this.width,this.height,this.channels)}convert(t){if(this.channels===t)return this;switch(t){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(t){if(BROWSER_ENV){if(WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");const i=t.split(".").pop().toLowerCase(),s=CONTENT_TYPE_MAP.get(i)??"image/png",u=await this.toBlob(s),d=URL.createObjectURL(u),a=document.createElement("a");a.href=d,a.download=t,a.click(),a.remove()}else{if(env$1.useFS)return await this.toSharp().toFile(t);throw new Error("Unable to save the image because filesystem is disabled in this environment.")}}toSharp(){if(BROWSER_ENV)throw new Error("toSharp() is only supported in server-side environments.");return sharp(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}}async function read_audio(m,t){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");const i=await(await getFile(m)).arrayBuffer(),s=new AudioContext({sampleRate:t});typeof t>"u"&&console.warn(`No sampling rate provided, using default of ${s.sampleRate}Hz.`);const u=await s.decodeAudioData(i);let d;if(u.numberOfChannels===2){const a=Math.sqrt(2),h=u.getChannelData(0),f=u.getChannelData(1);d=new Float32Array(h.length);for(let c=0;c2595*Math.log10(1+m/700),kaldi:m=>1127*Math.log(1+m/700),slaney:(m,t=1e3,i=15,s=27/Math.log(6.4))=>m>=t?i+Math.log(m/t)*s:3*m/200};function hertz_to_mel(m,t="htk"){const i=HERTZ_TO_MEL_MAPPING[t];if(!i)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof m=="number"?i(m):m.map(s=>i(s))}const MEL_TO_HERTZ_MAPPING={htk:m=>700*(10**(m/2595)-1),kaldi:m=>700*(Math.exp(m/1127)-1),slaney:(m,t=1e3,i=15,s=Math.log(6.4)/27)=>m>=i?t*Math.exp(s*(m-i)):200*m/3};function mel_to_hertz(m,t="htk"){const i=MEL_TO_HERTZ_MAPPING[t];if(!i)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof m=="number"?i(m):m.map(s=>i(s))}function _create_triangular_filter_bank(m,t){const i=Float64Array.from({length:t.length-1},(a,h)=>t[h+1]-t[h]),s=Array.from({length:m.length},()=>new Array(t.length));for(let a=0;anew Array(m.length));for(let a=0;am+s*d)}function mel_filter_bank(m,t,i,s,u,d=null,a="htk",h=!1){if(d!==null&&d!=="slaney")throw new Error('norm must be one of null or "slaney"');const f=hertz_to_mel(i,a),c=hertz_to_mel(s,a),l=linspace(f,c,t+2);let n=mel_to_hertz(l,a),e;if(h){const o=u/(m*2);e=hertz_to_mel(Float64Array.from({length:m},(p,g)=>g*o),a),n=l}else e=linspace(0,Math.floor(u/2),m);const r=_create_triangular_filter_bank(e,n);if(d!==null&&d==="slaney")for(let o=0;ou)throw Error(`frame_length (${i}) may not be larger than fft_length (${u})`);if(w!==i)throw new Error(`Length of the window (${w}) must equal frame_length (${i})`);if(s<=0)throw new Error("hop_length must be greater than zero");if(a){if(h!=="reflect")throw new Error(`pad_mode="${h}" not implemented yet.`);const D=Math.floor((u-1)/2)+1;m=padReflect(m,D,D)}const T=Math.floor(1+Math.floor((m.length-i)/s)),S=f?Math.floor(u/2)+1:u;let A=T,P=T;_!==null&&(_>T?b&&(P=_):P=A=_);const x=new FFT(u),M=new Float64Array(u),N=new Float64Array(x.outputBufferSize),z=new Array(A);for(let D=0;D=1;--V)M[V]-=c*M[V-1];M[0]*=1-c}for(let V=0;Vs)throw new Error(`Length of the window (${m}) may not be larger than frame_length (${s})`);return a}function center_to_corners_format([m,t,i,s]){return[m-i/2,t-s/2,m+i/2,t+s/2]}function post_process_object_detection(m,t=.5,i=null,s=!1){const u=m.logits,d=m.pred_boxes,[a,h,f]=u.dims;if(i!==null&&i.length!==a)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=[];for(let l=0;lt&&_.push(y)}else{let y=max(g.data)[1];if(y===f-1)continue;_.push(y),b=softmax(g.data)}for(const y of _){let w=o[p].data;w=center_to_corners_format(w),n!==null&&(w=w.map((T,S)=>T*n[(S+1)%2])),e.boxes.push(w),e.classes.push(y),e.scores.push(b[y])}}c.push(e)}return c}function validate_audio_inputs(m,t){var i;if(!(m instanceof Float32Array||m instanceof Float64Array))throw new Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${((i=m==null?void 0:m.constructor)==null?void 0:i.name)??typeof m} instead.If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}class FeatureExtractor extends Callable{constructor(t){super(),this.config=t}}class ImageFeatureExtractor extends FeatureExtractor{constructor(t){super(t),this.image_mean=this.config.image_mean,this.image_std=this.config.image_std,this.resample=this.config.resample??2,this.do_rescale=this.config.do_rescale??!0,this.rescale_factor=this.config.rescale_factor??1/255,this.do_normalize=this.config.do_normalize,this.do_resize=this.config.do_resize,this.do_thumbnail=this.config.do_thumbnail,this.size=this.config.size,this.size_divisor=this.config.size_divisor,this.do_center_crop=this.config.do_center_crop,this.crop_size=this.config.crop_size,this.do_convert_rgb=this.config.do_convert_rgb??!0,this.do_crop_margin=this.config.do_crop_margin,this.pad_size=this.config.pad_size,this.do_pad=this.config.do_pad,this.do_pad&&!this.pad_size&&this.size.width!==void 0&&this.size.height!==void 0&&(this.pad_size=this.size)}async thumbnail(t,i,s=2){const u=t.height,d=t.width,a=i.height,h=i.width;let f=Math.min(u,a),c=Math.min(d,h);return f===u&&c===d?t:(u>d?c=Math.floor(d*f/u):d>u&&(f=Math.floor(u*c/d)),await t.resize(c,f,{resample:s}))}async crop_margin(t,i=200){const s=t.clone().grayscale(),u=min(s.data)[0],a=max(s.data)[0]-u;if(a===0)return t;const h=i/255;let f=s.width,c=s.height,l=0,n=0;for(let e=0;ethis.preprocess(d)));return s.forEach(d=>d.pixel_values.dims=[1,...d.pixel_values.dims]),{pixel_values:cat(s.map(d=>d.pixel_values)),original_sizes:s.map(d=>d.original_size),reshaped_input_sizes:s.map(d=>d.reshaped_input_size)}}}class DPTFeatureExtractor extends ImageFeatureExtractor{}class GLPNFeatureExtractor extends ImageFeatureExtractor{}class CLIPFeatureExtractor extends ImageFeatureExtractor{}class ConvNextFeatureExtractor extends ImageFeatureExtractor{}class ConvNextImageProcessor extends ConvNextFeatureExtractor{}class ViTFeatureExtractor extends ImageFeatureExtractor{}class MobileViTFeatureExtractor extends ImageFeatureExtractor{}class OwlViTFeatureExtractor extends ImageFeatureExtractor{post_process_object_detection(...t){return post_process_object_detection(...t)}}class DeiTFeatureExtractor extends ImageFeatureExtractor{}class BeitFeatureExtractor extends ImageFeatureExtractor{}class DonutFeatureExtractor extends ImageFeatureExtractor{pad_image(t,i,s,u={}){const[d,a,h]=i;let f=this.image_mean;Array.isArray(this.image_mean)||(f=new Array(h).fill(f)),this.image_std,Array.isArray(this.image_std)||new Array(h).fill(f);const c=f.map((l,n)=>-l/this.image_std[n]);return super.pad_image(t,i,s,{center:!0,constant_values:c,...u})}}class NougatImageProcessor extends DonutFeatureExtractor{}class DetrFeatureExtractor extends ImageFeatureExtractor{async _call(t){const i=await super._call(t),s=[i.pixel_values.dims[0],64,64],u=new Tensor("int64",new BigInt64Array(s.reduce((d,a)=>d*a)).fill(1n),s);return{...i,pixel_mask:u}}post_process_object_detection(...t){return post_process_object_detection(...t)}remove_low_and_no_objects(t,i,s,u){let d=[],a=[],h=[];for(let f=0;fs&&(d.push(l),a.push(r),h.push(n))}return[d,a,h]}check_segment_validity(t,i,s,u=.5,d=.8){let a=[],h=0,f=0;for(let l=0;l=u&&++f;let c=h>0&&f>0;return c&&(c=h/f>d),[c,a]}compute_segments(t,i,s,u,d,a=null,h=null){let[f,c]=h??t[0].dims,l=new Tensor("int32",new Int32Array(f*c),[f,c]),n=[];if(h!==null)for(let p=0;pr[_]&&(e[_]=p,r[_]=t[p].data[_])}let o=0;for(let p=0;pBigInt(Math.round(f)))),a);return{pixel_values:s,original_sizes:u,reshaped_input_sizes:d,input_points:h}}post_process_masks(t,i,s,{mask_threshold:u=0,binarize:d=!0,pad_size:a=null}={}){let h=[];a=a??this.pad_size;let f=[a.height,a.width];for(let c=0;cb>u),_.dims)),_.dims=[1,..._.dims],r.push(_)}let o=cat(r);h.push(o)}return h}}class Swin2SRImageProcessor extends ImageFeatureExtractor{pad_image(t,i,s,u={}){const[d,a,h]=i;return super.pad_image(t,i,{width:d+(s-d%s)%s,height:a+(s-a%s)%s},{mode:"symmetric",center:!1,constant_values:-1,...u})}}class WhisperFeatureExtractor extends FeatureExtractor{constructor(t){var i;super(t),(i=this.config).mel_filters??(i.mel_filters=mel_filter_bank(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney")),this.window=window_function(this.config.n_fft,"hann")}_extract_fbank_features(t){const{data:i,dims:s}=spectrogram(t,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10",max_num_frames:this.config.nb_max_frames}),u=max(i)[0];for(let d=0;dthis.config.n_samples?(console.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),i=t.slice(0,this.config.n_samples)):(i=new Float32Array(this.config.n_samples),i.set(t));const{data:s,dims:u}=this._extract_fbank_features(i);return{input_features:new Tensor("float32",s,[1,...u])}}}class Wav2Vec2FeatureExtractor extends FeatureExtractor{_zero_mean_unit_var_norm(t){const s=t.reduce((d,a)=>d+a,0)/t.length,u=t.reduce((d,a)=>d+(a-s)**2,0)/t.length;return t.map(d=>(d-s)/Math.sqrt(u+1e-7))}async _call(t){validate_audio_inputs(t,"Wav2Vec2FeatureExtractor"),t instanceof Float64Array&&(t=new Float32Array(t));let i=t;this.config.do_normalize&&(i=this._zero_mean_unit_var_norm(i));const s=[1,i.length];return{input_values:new Tensor("float32",i,s),attention_mask:new Tensor("int64",new BigInt64Array(i.length).fill(1n),s)}}}class ASTFeatureExtractor extends FeatureExtractor{constructor(t){super(t);const i=this.config.sampling_rate,s=mel_filter_bank(256,this.config.num_mel_bins,20,Math.floor(i/2),i,null,"kaldi",!0);for(let u=0;u0)if(s==="rand_trunc"){a=!0;const f=Math.floor(Math.random()*(h+1));t=t.subarray(f,f+i),d=this._extract_fbank_features(t,this.mel_filters_slaney,this.config.nb_max_samples),d.dims=[1,...d.dims]}else throw new Error(`Truncation strategy "${s}" not implemented`);else{if(h<0){let f=new Float64Array(i);if(f.set(t),u==="repeat")for(let c=t.length;cRawImage.read(t))),m}class Pipeline extends Callable{constructor({task:t,model:i,tokenizer:s=null,processor:u=null}){super(),this.task=t,this.model=i,this.tokenizer=s,this.processor=u}async dispose(){await this.model.dispose()}async _call(t,...i){let s=this.tokenizer(t,{padding:!0,truncation:!0}),u=await this.model(s);return[s,u]}}class TextClassificationPipeline extends Pipeline{async _call(t,{topk:i=1}={}){let s=this.model.config.problem_type==="multi_label_classification"?f=>f.sigmoid().data:f=>softmax(f.data),[u,d]=await super._call(t),a=this.model.config.id2label,h=[];for(let f of d.logits){let c=s(f),n=getTopItems(c,i).map(function(e){return{label:a[e[0]],score:e[1]}});i===1?h.push(...n):h.push(n)}return Array.isArray(t)||i===1?h:h[0]}}class TokenClassificationPipeline extends Pipeline{async _call(t,{ignore_labels:i=["O"]}={}){let s=Array.isArray(t);s||(t=[t]);let u=this.tokenizer,[d,a]=await super._call(t),h=a.logits,f=this.model.config.id2label,c=[];for(let l=0;l[r,o]).filter(r=>r[1]>c),n=Array.from(softmax(d.end_logits[h].data)).map((r,o)=>[r,o]).filter(r=>r[1]>c),e=product(l,n).filter(r=>r[0][1]<=r[1][1]).map(r=>[r[0][1],r[1][1],r[0][0]*r[1][0]]).sort((r,o)=>o[2]-r[2]);for(let r=0;r{let o=[...f];return o[c]=r[0],{score:r[1],token:r[0],token_str:d.model.vocab[r[0]],sequence:d.decode(o,{skip_special_tokens:!0})}}))}return Array.isArray(t)?a:a[0]}}class Text2TextGenerationPipeline extends Pipeline{constructor(){super(...arguments);le(this,"_key","generated_text")}async _call(i,s={}){Array.isArray(i)||(i=[i]),this.model.config.prefix&&(i=i.map(c=>this.model.config.prefix+c));let u=this.model.config.task_specific_params;u&&u[this.task]&&u[this.task].prefix&&(i=i.map(c=>u[this.task].prefix+c));let d={padding:!0,truncation:!0},a;this instanceof TranslationPipeline&&"_build_translation_inputs"in this.tokenizer?a=this.tokenizer._build_translation_inputs(i,d,s).input_ids:a=this.tokenizer(i,d).input_ids;let h=await this.model.generate(a,s),f=this.tokenizer.batch_decode(h,{skip_special_tokens:!0});return this._key!==null&&(f=f.map(c=>this._key===null?c:{[this._key]:c})),f}}class SummarizationPipeline extends Text2TextGenerationPipeline{constructor(){super(...arguments);le(this,"_key","summary_text")}}class TranslationPipeline extends Text2TextGenerationPipeline{constructor(){super(...arguments);le(this,"_key","translation_text")}}class TextGenerationPipeline extends Pipeline{async _call(t,i={}){let s=typeof t=="string"||t instanceof String;s&&(t=[t]);const u=i.add_special_tokens??!1;this.tokenizer.padding_side="left";let d=this.tokenizer(t,{add_special_tokens:u,padding:!0,truncation:!0}),a=d.input_ids,h=d.attention_mask,f=await this.model.generate(a,i,null,{inputs_attention_mask:h});const c=this.tokenizer.batch_decode(f,{skip_special_tokens:!0}),l=Array.from({length:t.length},n=>[]);for(let n=0;n[i.toLowerCase(),s])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(console.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(console.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(t,i,{hypothesis_template:s="This example is {}.",multi_label:u=!1}={}){let d=Array.isArray(t);d||(t=[t]),Array.isArray(i)||(i=[i]);let a=i.map(c=>s.replace("{}",c)),h=u||i.length===1,f=[];for(let c of t){let l=[];for(let r of a){let o=this.tokenizer(c,{text_pair:r,padding:!0,truncation:!0}),p=await this.model(o);h?l.push([p.logits.data[this.contradiction_id],p.logits.data[this.entailment_id]]):l.push(p.logits.data[this.entailment_id])}let n;h?n=l.map(r=>softmax(r)[1]):n=softmax(l);let e=n.map((r,o)=>[r,o]).sort((r,o)=>o[0]-r[0]);f.push({sequence:c,labels:e.map(r=>i[r[1]]),scores:e.map(r=>r[0])})}return d?f:f[0]}}class FeatureExtractionPipeline extends Pipeline{async _call(t,{pooling:i="none",normalize:s=!1}={}){let[u,d]=await super._call(t),a=d.last_hidden_state??d.logits;if(i!=="none")if(i==="mean")a=mean_pooling(a,u.attention_mask);else throw Error(`Pooling method '${i}' not supported.`);return s&&(a=a.normalize(2,-1)),a}}class AudioClassificationPipeline extends Pipeline{constructor(t){super(t)}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,{topk:i=5}={}){let s=!Array.isArray(t);s&&(t=[t]);const u=this.model.config.id2label,d=this.processor.feature_extractor.config.sampling_rate;let a=[];for(let h of t){h=await this._preprocess(h,d);const f=await this.processor(h),l=(await this.model(f)).logits[0];let e=getTopItems(softmax(l.data),i).map(function(r){return{label:u[r[0]],score:r[1]}});i===1?a.push(...e):a.push(e)}return!s||i===1?a:a[0]}}class ZeroShotAudioClassificationPipeline extends Pipeline{constructor(t){super(t)}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,i,{hypothesis_template:s="This is a sound of {}."}={}){const u=!Array.isArray(t);u&&(t=[t]);const d=i.map(c=>s.replace("{}",c)),a=this.tokenizer(d,{padding:!0,truncation:!0}),h=this.processor.feature_extractor.config.sampling_rate,f=[];for(let c of t){c=await this._preprocess(c,h);const l=await this.processor(c),n=await this.model({...a,...l}),e=softmax(n.logits_per_audio.data);f.push([...e].map((r,o)=>({score:r,label:i[o]})))}return u?f[0]:f}}class AutomaticSpeechRecognitionPipeline extends Pipeline{constructor(t){super(t)}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,i={}){switch(this.model.config.model_type){case"whisper":return this._call_whisper(t,i);case"wav2vec2":return this._call_wav2vec2(t,i);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(t,i={}){i.language&&console.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),i.task&&console.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let s=!Array.isArray(t);s&&(t=[t]);const u=this.processor.feature_extractor.config.sampling_rate;let d=[];for(let a of t){a=await this._preprocess(a,u);const h=await this.processor(a),c=(await this.model(h)).logits[0],l=[];for(let e of c)l.push(max(e.data)[1]);const n=this.tokenizer.decode(l);d.push({text:n})}return s?d[0]:d}async _call_whisper(t,i={}){let s=i.return_timestamps??!1,u=i.chunk_length_s??0,d=i.stride_length_s??null,a=i.chunk_callback??null,h=i.force_full_sequences??!1;s==="word"&&(i.return_token_timestamps=!0);let f=pop(i,"language",null),c=pop(i,"task",null);if(f||c||s){if(i.forced_decoder_ids)throw new Error("Cannot specify `language`/`task`/`return_timestamps` and `forced_decoder_ids` at the same time.");let p=this.tokenizer.get_decoder_prompt_ids({language:f,task:c,no_timestamps:!s});p.length>0&&(i.forced_decoder_ids=p)}let l=!Array.isArray(t);l&&(t=[t]);const n=this.processor.feature_extractor.config.sampling_rate,e=this.processor.feature_extractor.config.chunk_length/this.model.config.max_source_positions,r=this.processor.feature_extractor.config.hop_length;let o=[];for(let p of t){p=await this._preprocess(p,n);let g=[];if(u>0){if(d===null)d=u/6;else if(u<=d)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");const y=n*u,w=n*d,T=y-2*w;let S=0;for(;S=p.length;g.push({stride:[A.length,x?0:w,M?0:w],input_features:P.input_features,is_last:M}),S+=T}}else g=[{stride:[p.length,0,0],input_features:(await this.processor(p)).input_features,is_last:!0}];for(let y of g){i.num_frames=Math.floor(y.stride[0]/r);let w=await this.model.generate(y.input_features,i);s==="word"?(y.tokens=w.sequences[0],y.token_timestamps=w.token_timestamps.tolist()[0].map(T=>round(T,2))):y.tokens=w[0],y.stride=y.stride.map(T=>T/n),a!==null&&a(y)}let[_,b]=this.tokenizer._decode_asr(g,{time_precision:e,return_timestamps:s,force_full_sequences:h});o.push({text:_,...b})}return l?o[0]:o}}class ImageToTextPipeline extends Pipeline{constructor(t){super(t)}async _call(t,i={}){let s=Array.isArray(t);t=await prepareImages(t);let{pixel_values:u}=await this.processor(t),d=[];for(let a of u){a.dims=[1,...a.dims];let h=await this.model.generate(a,i),f=this.tokenizer.batch_decode(h,{skip_special_tokens:!0}).map(c=>({generated_text:c.trim()}));d.push(f)}return s?d:d[0]}}class ImageClassificationPipeline extends Pipeline{constructor(t){super(t)}async _call(t,{topk:i=1}={}){let s=Array.isArray(t);t=await prepareImages(t);let{pixel_values:u}=await this.processor(t),d=await this.model({pixel_values:u}),a=this.model.config.id2label,h=[];for(let f of d.logits){let l=getTopItems(softmax(f.data),i).map(function(n){return{label:a[n[0]],score:n[1]}});i===1?h.push(...l):h.push(l)}return s||i===1?h:h[0]}}class ImageSegmentationPipeline extends Pipeline{constructor(t){super(t),this.subtasks_mapping={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"}}async _call(t,{threshold:i=.5,mask_threshold:s=.5,overlap_mask_area_threshold:u=.8,label_ids_to_fuse:d=null,target_sizes:a=null,subtask:h=null}={}){if(Array.isArray(t)&&t.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");t=await prepareImages(t);let c=t.map(p=>[p.height,p.width]),{pixel_values:l,pixel_mask:n}=await this.processor(t),e=await this.model({pixel_values:l,pixel_mask:n}),r=null;if(h!==null)r=this.subtasks_mapping[h];else for(let[p,g]of Object.entries(this.subtasks_mapping))if(g in this.processor.feature_extractor){r=this.processor.feature_extractor[g].bind(this.processor.feature_extractor),h=p;break}let o=[];if(h==="panoptic"||h==="instance"){let p=r(e,i,s,u,d,a??c)[0],g=p.segmentation,_=this.model.config.id2label;for(let b of p.segments_info){let y=new Uint8ClampedArray(g.data.length);for(let T=0;Ts.replace("{}",l)),a=this.tokenizer(d,{padding:!0,truncation:!0}),{pixel_values:h}=await this.processor(t),f=await this.model({...a,pixel_values:h}),c=[];for(let l of f.logits_per_image){let n=softmax(l.data);c.push([...n].map((e,r)=>({score:e,label:i[r]})))}return u?c:c[0]}}class ObjectDetectionPipeline extends Pipeline{constructor(t){super(t)}async _call(t,{threshold:i=.9,percentage:s=!1}={}){let u=Array.isArray(t);if(u&&t.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");t=await prepareImages(t);let d=s?null:t.map(e=>[e.height,e.width]),{pixel_values:a,pixel_mask:h}=await this.processor(t),f=await this.model({pixel_values:a,pixel_mask:h}),c=this.processor.feature_extractor.post_process_object_detection(f,i,d),l=this.model.config.id2label;const n=c.map(e=>e.boxes.map((r,o)=>({score:e.scores[o],label:l[e.classes[o]],box:get_bounding_box(r,!s)})));return u?n:n[0]}}class ZeroShotObjectDetectionPipeline extends Pipeline{constructor(t){super(t)}async _call(t,i,{threshold:s=.1,topk:u=null,percentage:d=!1}={}){const a=Array.isArray(t);t=await prepareImages(t);const h=this.tokenizer(i,{padding:!0,truncation:!0}),f=await this.processor(t),c=[];for(let l=0;l({score:p.scores[b],label:i[p.classes[b]],box:get_bounding_box(_,!d)})).sort((_,b)=>b.score-_.score);u!==null&&(g=g.slice(0,u)),c.push(g)}return a?c:c[0]}}class DocumentQuestionAnsweringPipeline extends Pipeline{constructor(t){super(t)}async _call(t,i,s={}){t=(await prepareImages(t))[0];const{pixel_values:u}=await this.processor(t),d=`${i}`,a=this.tokenizer(d,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,h=await this.model.generate(u,{...s,decoder_input_ids:a,max_length:this.model.config.decoder.max_position_embeddings}),c=this.tokenizer.batch_decode(h)[0].match(/(.*?)<\/s_answer>/);let l=null;return c&&c.length>=2&&(l=c[1].trim()),[{answer:l}]}}class TextToAudioPipeline extends Pipeline{constructor(i){super(i);le(this,"DEFAULT_VOCODER_ID","Xenova/speecht5_hifigan");this.vocoder=i.vocoder??null}async _call(i,{speaker_embeddings:s=null}={}){if(this.vocoder||(console.log("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await AutoModel.from_pretrained(this.DEFAULT_VOCODER_ID,{quantized:!1})),(typeof s=="string"||s instanceof URL)&&(s=new Float32Array(await(await fetch(s)).arrayBuffer())),s instanceof Float32Array)s=new Tensor("float32",s,[1,s.length]);else if(!(s instanceof Tensor))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");const{input_ids:u}=this.tokenizer(i,{padding:!0,truncation:!0}),{waveform:d}=await this.model.generate_speech(u,s,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return{audio:d.data,sampling_rate:a}}}class ImageToImagePipeline extends Pipeline{async _call(t){t=await prepareImages(t);let i=await this.processor(t),s=await this.model(i),u=[];for(let d of s.reconstruction){const a=d.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");u.push(RawImage.fromTensor(a))}return u.length>1?u:u[0]}}class DepthEstimationPipeline extends Pipeline{async _call(t){t=await prepareImages(t);const i=await this.processor(t),{predicted_depth:s}=await this.model(i),u=[];for(let d=0;d1?u:u[0]}}const SUPPORTED_TASKS={"text-classification":{tokenizer:AutoTokenizer,pipeline:TextClassificationPipeline,model:AutoModelForSequenceClassification,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{tokenizer:AutoTokenizer,pipeline:TokenClassificationPipeline,model:AutoModelForTokenClassification,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{tokenizer:AutoTokenizer,pipeline:QuestionAnsweringPipeline,model:AutoModelForQuestionAnswering,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{tokenizer:AutoTokenizer,pipeline:FillMaskPipeline,model:AutoModelForMaskedLM,default:{model:"Xenova/bert-base-uncased"},type:"text"},summarization:{tokenizer:AutoTokenizer,pipeline:SummarizationPipeline,model:AutoModelForSeq2SeqLM,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{tokenizer:AutoTokenizer,pipeline:TranslationPipeline,model:AutoModelForSeq2SeqLM,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{tokenizer:AutoTokenizer,pipeline:Text2TextGenerationPipeline,model:AutoModelForSeq2SeqLM,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{tokenizer:AutoTokenizer,pipeline:TextGenerationPipeline,model:AutoModelForCausalLM,default:{model:"Xenova/gpt2"},type:"text"},"zero-shot-classification":{tokenizer:AutoTokenizer,pipeline:ZeroShotClassificationPipeline,model:AutoModelForSequenceClassification,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:AudioClassificationPipeline,model:AutoModelForAudioClassification,processor:AutoProcessor,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{tokenizer:AutoTokenizer,pipeline:ZeroShotAudioClassificationPipeline,model:AutoModel,processor:AutoProcessor,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{tokenizer:AutoTokenizer,pipeline:AutomaticSpeechRecognitionPipeline,model:[AutoModelForSpeechSeq2Seq,AutoModelForCTC],processor:AutoProcessor,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{tokenizer:AutoTokenizer,pipeline:TextToAudioPipeline,model:[AutoModelForTextToSpectrogram],processor:AutoProcessor,default:{model:"Xenova/speecht5_tts"},type:"text"},"image-to-text":{tokenizer:AutoTokenizer,pipeline:ImageToTextPipeline,model:AutoModelForVision2Seq,processor:AutoProcessor,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:ImageClassificationPipeline,model:AutoModelForImageClassification,processor:AutoProcessor,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:ImageSegmentationPipeline,model:AutoModelForImageSegmentation,processor:AutoProcessor,default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"zero-shot-image-classification":{tokenizer:AutoTokenizer,pipeline:ZeroShotImageClassificationPipeline,model:AutoModel,processor:AutoProcessor,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:ObjectDetectionPipeline,model:AutoModelForObjectDetection,processor:AutoProcessor,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{tokenizer:AutoTokenizer,pipeline:ZeroShotObjectDetectionPipeline,model:AutoModelForZeroShotObjectDetection,processor:AutoProcessor,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{tokenizer:AutoTokenizer,pipeline:DocumentQuestionAnsweringPipeline,model:AutoModelForDocumentQuestionAnswering,processor:AutoProcessor,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:ImageToImagePipeline,model:AutoModelForImageToImage,processor:AutoProcessor,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:DepthEstimationPipeline,model:AutoModelForDepthEstimation,processor:AutoProcessor,default:{model:"Xenova/dpt-large"},type:"image"},"feature-extraction":{tokenizer:AutoTokenizer,pipeline:FeatureExtractionPipeline,model:AutoModel,default:{model:"Xenova/all-MiniLM-L6-v2"},type:"text"}},TASK_ALIASES={"sentiment-analysis":"text-classification",ner:"token-classification",vqa:"visual-question-answering",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"};async function pipeline(m,t=null,{quantized:i=!0,progress_callback:s=null,config:u=null,cache_dir:d=null,local_files_only:a=!1,revision:h="main"}={}){m=TASK_ALIASES[m]??m;let f=SUPPORTED_TASKS[m.split("_",1)[0]];if(!f)throw Error(`Unsupported pipeline: ${m}. Must be one of [${Object.keys(SUPPORTED_TASKS)}]`);t||(t=f.default.model,console.log(`No model specified. Using default model: "${t}".`));let c={quantized:i,progress_callback:s,config:u,cache_dir:d,local_files_only:a,revision:h};const l=new Map([["tokenizer",f.tokenizer],["model",f.model],["processor",f.processor]]);let n=await loadItems(l,t,c);n.task=m,dispatchCallback(s,{status:"ready",task:m,model:t});let e=f.pipeline;return new e(n)}async function loadItems(m,t,i){const s=Object.create(null),u=[];for(let[d,a]of m.entries()){if(!a)continue;let h;Array.isArray(a)?h=new Promise(async(f,c)=>{let l;for(let n of a)try{f(await n.from_pretrained(t,i));return}catch(e){l=e}c(l)}):h=a.from_pretrained(t,i),s[d]=h,u.push(h)}await Promise.all(u);for(let[d,a]of Object.entries(s))s[d]=await a;return s}env$1.allowLocalModels=!1;class PipelineFactory{constructor(t,i,s){this.tokenizer=t,this.model=i,this.quantized=s}static async getInstance(t=null){return this.instance===null&&(this.instance=pipeline(this.task,this.model,{quantized:this.quantized,progress_callback:t})),this.instance}}le(PipelineFactory,"task",null),le(PipelineFactory,"model",null),le(PipelineFactory,"quantized",null),le(PipelineFactory,"instance",null),self.addEventListener("message",async m=>{const t=m.data;let i=await transcribe(t.audio,t.model,t.multilingual,t.quantized,t.subtask,t.language);i!==null&&self.postMessage({status:"complete",task:"automatic-speech-recognition",data:i})});class AutomaticSpeechRecognitionPipelineFactory extends PipelineFactory{}le(AutomaticSpeechRecognitionPipelineFactory,"task","automatic-speech-recognition"),le(AutomaticSpeechRecognitionPipelineFactory,"model",null),le(AutomaticSpeechRecognitionPipelineFactory,"quantized",null);const transcribe=async(m,t,i,s,u,d)=>{const a=t.startsWith("distil-whisper/");let h=t;!a&&!i&&(h+=".en");const f=AutomaticSpeechRecognitionPipelineFactory;(f.model!==h||f.quantized!==s)&&(f.model=h,f.quantized=s,f.instance!==null&&((await f.getInstance()).dispose(),f.instance=null));let c=await f.getInstance(p=>{self.postMessage(p)});const l=c.processor.feature_extractor.config.chunk_length/c.model.config.max_source_positions;let n=[{tokens:[],finalised:!1}];function e(p){let g=n[n.length-1];Object.assign(g,p),g.finalised=!0,p.is_last||n.push({tokens:[],finalised:!1})}function r(p){let g=n[n.length-1];g.tokens=[...p[0].output_token_ids];let _=c.tokenizer._decode_asr(n,{time_precision:l,return_timestamps:!0,force_full_sequences:!1});self.postMessage({status:"update",task:"automatic-speech-recognition",data:_})}return await c(m,{top_k:0,do_sample:!1,chunk_length_s:a?20:30,stride_length_s:a?3:5,language:d,task:u,return_timestamps:!0,force_full_sequences:!1,callback_function:r,chunk_callback:e}).catch(p=>(self.postMessage({status:"error",task:"automatic-speech-recognition",data:p}),null))}})(); diff --git a/index.html b/index.html index 4f1255e4a79608155ce2fe3950259b78eb1f3971..e193d7c235dcffc50073dd465c83dd164ff2fae8 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Whisper Web - +