diff --git "a/_next/static/chunks/413.b409a6760c36dc81.js" "b/_next/static/chunks/413.b409a6760c36dc81.js" new file mode 100644--- /dev/null +++ "b/_next/static/chunks/413.b409a6760c36dc81.js" @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[413],{357:function(e,t,r){"use strict";var n,i;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(i=r.g.process)?void 0:i.env)?r.g.process:r(8081)},8464:function(e,t,r){!function(){var t={452:function(e){"use strict";e.exports=r(6405)}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}},s=!0;try{t[e](a,a.exports,i),s=!1}finally{s&&delete n[e]}return a.exports}i.ab="//";var a={};!function(){var e,t=(e=i(452))&&"object"==typeof e&&"default"in e?e.default:e,r=/https?|ftp|gopher|file/;function n(e){"string"==typeof e&&(e=_(e));var n,i,a,s,o,l,h,u,c,f=(i=(n=e).auth,a=n.hostname,s=n.protocol||"",o=n.pathname||"",l=n.hash||"",h=n.query||"",u=!1,i=i?encodeURIComponent(i).replace(/%3A/i,":")+"@":"",n.host?u=i+n.host:a&&(u=i+(~a.indexOf(":")?"["+a+"]":a),n.port&&(u+=":"+n.port)),h&&"object"==typeof h&&(h=t.encode(h)),c=n.search||h&&"?"+h||"",s&&":"!==s.substr(-1)&&(s+=":"),n.slashes||(!s||r.test(s))&&!1!==u?(u="//"+(u||""),o&&"/"!==o[0]&&(o="/"+o)):u||(u=""),l&&"#"!==l[0]&&(l="#"+l),c&&"?"!==c[0]&&(c="?"+c),{protocol:s,host:u,pathname:o=o.replace(/[?#]/g,encodeURIComponent),search:c=c.replace("#","%23"),hash:l});return""+f.protocol+f.host+f.pathname+f.search+f.hash}var s="http://",o=s+"w.w",l=/^([a-z0-9.+-]*:\/\/\/)([a-z0-9.+-]:\/*)?/i,h=/https?|ftp|gopher|file/;function u(e,t){var r="string"==typeof e?_(e):e;e="object"==typeof e?n(e):e;var i=_(t),a="";r.protocol&&!r.slashes&&(a=r.protocol,e=e.replace(r.protocol,""),a+="/"===t[0]||"/"===e[0]?"/":""),a&&i.protocol&&(a="",i.slashes||(a=i.protocol,t=t.replace(i.protocol,"")));var u=e.match(l);u&&!i.protocol&&(e=e.substr((a=u[1]+(u[2]||"")).length),/^\/\/[^/]/.test(t)&&(a=a.slice(0,-1)));var c=new URL(e,o+"/"),f=new URL(t,c).toString().replace(o,""),d=i.protocol||r.protocol;return d+=r.slashes||i.slashes?"//":"",!a&&d?f=f.replace(s,d):a&&(f=f.replace(s,"")),h.test(f)||~t.indexOf(".")||"/"===e.slice(-1)||"/"===t.slice(-1)||"/"!==f.slice(-1)||(f=f.slice(0,-1)),a&&(f=a+("/"===f[0]?f.substr(1):f)),f}function c(){}c.prototype.parse=_,c.prototype.format=n,c.prototype.resolve=u,c.prototype.resolveObject=u;var f=/^https?|ftp|gopher|file/,d=/^(.*?)([#?].*)/,p=/^([a-z0-9.+-]*:)(\/{0,3})(.*)/i,m=/^([a-z0-9.+-]*:)?\/\/\/*/i,g=/^([a-z0-9.+-]*:)(\/{0,2})\[(.*)\]$/i;function _(e,r,i){if(void 0===r&&(r=!1),void 0===i&&(i=!1),e&&"object"==typeof e&&e instanceof c)return e;var a=(e=e.trim()).match(d);e=a?a[1].replace(/\\/g,"/")+a[2]:e.replace(/\\/g,"/"),g.test(e)&&"/"!==e.slice(-1)&&(e+="/");var s=!/(^javascript)/.test(e)&&e.match(p),l=m.test(e),h="";s&&(f.test(s[1])||(h=s[1].toLowerCase(),e=""+s[2]+s[3]),s[2]||(l=!1,f.test(s[1])?(h=s[1],e=""+s[3]):e="//"+s[3]),3!==s[2].length&&1!==s[2].length||(h=s[1],e="/"+s[3]));var u,_=(a?a[1]:e).match(/^https?:\/\/[^/]+(:[0-9]+)(?=\/|$)/),w=_&&_[1],y=new c,b="",v="";try{u=new URL(e)}catch(t){b=t,h||i||!/^\/\//.test(e)||/^\/\/.+[@.]/.test(e)||(v="/",e=e.substr(1));try{u=new URL(e,o)}catch(e){return y.protocol=h,y.href=h,y}}y.slashes=l&&!v,y.host="w.w"===u.host?"":u.host,y.hostname="w.w"===u.hostname?"":u.hostname.replace(/(\[|\])/g,""),y.protocol=b?h||null:u.protocol,y.search=u.search.replace(/\\/g,"%5C"),y.hash=u.hash.replace(/\\/g,"%5C");var x=e.split("#");!y.search&&~x[0].indexOf("?")&&(y.search="?"),y.hash||""!==x[1]||(y.hash="#"),y.query=r?t.decode(u.search.substr(1)):y.search.substr(1),y.pathname=v+(s?u.pathname.replace(/['^|`]/g,function(e){return"%"+e.charCodeAt().toString(16).toUpperCase()}).replace(/((?:%[0-9A-F]{2})+)/g,function(e,t){try{return decodeURIComponent(t).split("").map(function(e){var t=e.charCodeAt();return t>256||/^[a-z0-9]$/i.test(e)?e:"%"+t.toString(16).toUpperCase()}).join("")}catch(e){return t}}):u.pathname),"about:"===y.protocol&&"blank"===y.pathname&&(y.protocol="",y.pathname=""),b&&"/"!==e[0]&&(y.pathname=y.pathname.substr(1)),h&&!f.test(h)&&"/"!==e.slice(-1)&&"/"===y.pathname&&(y.pathname=""),y.path=y.pathname+y.search,y.auth=[u.username,u.password].map(decodeURIComponent).filter(Boolean).join(":"),y.port=u.port,w&&!y.host.endsWith(w)&&(y.host+=w,y.port=w.slice(1)),y.href=v?""+y.pathname+y.search+y.hash:n(y);var E=/^(file)/.test(y.href)?["host","hostname"]:[];return Object.keys(y).forEach(function(e){~E.indexOf(e)||(y[e]=y[e]||null)}),y}a.parse=_,a.format=n,a.resolve=u,a.resolveObject=function(e,t){return _(u(e,t))},a.Url=c}(),e.exports=a}()},8081:function(e){!function(){var t={229:function(e){var t,r,n,i=e.exports={};function a(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var l=[],h=!1,u=-1;function c(){h&&n&&(h=!1,n.length?l=n.concat(l):u=-1,l.length&&f())}function f(){if(!h){var e=o(c);h=!0;for(var t=l.length;t;){for(n=l,l=[];++u1)for(var r=1;r0&&l>o&&(l=o);for(var h=0;h=0?(u=p.substr(0,m),c=p.substr(m+1)):(u=p,c=""),f=decodeURIComponent(u),d=decodeURIComponent(c),Object.prototype.hasOwnProperty.call(a,f))?t(a[f])?a[f].push(d):a[f]=[a[f],d]:a[f]=d}return a};var t=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},577:function(e){var t=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,a,s,o){return(a=a||"&",s=s||"=",null===e&&(e=void 0),"object"==typeof e)?n(i(e),function(i){var o=encodeURIComponent(t(i))+s;return r(e[i])?n(e[i],function(e){return o+encodeURIComponent(t(e))}).join(a):o+encodeURIComponent(t(e[i]))}).join(a):o?encodeURIComponent(t(o))+s+encodeURIComponent(t(e)):""};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n{if(t&&"function"==typeof t.init&&"function"==typeof t.createSessionHandler){let a=n[e];if(void 0===a)n[e]={backend:t,priority:r};else if(a.priority>r)return;else if(a.priority===r&&a.backend!==t)throw Error(`cannot register backend "${e}" using priority ${r}`);if(r>=0){let t=i.indexOf(e);-1!==t&&i.splice(t,1);for(let t=0;t{let t=0===e.length?i:e,r=[];for(let e of t){let t=n[e];if(t){if(t.initialized)return t.backend;if(t.aborted)continue;let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init()),await t.initPromise,t.initialized=!0,t.backend}catch(i){n||r.push({name:e,err:i}),t.aborted=!0}finally{delete t.initPromise}}}throw Error(`no available backend found. ERR: ${r.map(e=>`[${e.name}] ${e.err}`).join(", ")}`)};class o{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(e){if(void 0!==e){if("string"!=typeof e||-1===["verbose","info","warning","error","fatal"].indexOf(e))throw Error(`Unsupported logging level: ${e}`);this.logLevelInternal=e}}get logLevel(){return this.logLevelInternal}}let l=new o,h="undefined"!=typeof BigInt64Array&&"function"==typeof BigInt64Array.from,u="undefined"!=typeof BigUint64Array&&"function"==typeof BigUint64Array.from,c=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),f=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);h&&(c.set("int64",BigInt64Array),f.set(BigInt64Array,"int64")),u&&(c.set("uint64",BigUint64Array),f.set(BigUint64Array,"uint64"));let d=e=>{let t=1;for(let r=0;r{let i=document.createElement("canvas"),a=i.getContext("2d");if(!e||!a)return n();let s=new Image;s.crossOrigin="Anonymous",s.src=e,s.onload=()=>{i.width=s.width,i.height=s.height,a.drawImage(s,0,0,i.width,i.height);let e=a.getImageData(0,0,i.width,i.height);if(void 0!==t){if(void 0!==t.height&&t.height!==i.height)throw Error("Image input config height doesn't match ImageBitmap height");if(o.height=i.height,void 0!==t.width&&t.width!==i.width)throw Error("Image input config width doesn't match ImageBitmap width");o.width=i.width}else o.height=i.height,o.width=i.width;r(p.bufferToTensor(e.data,o))}});else throw Error("Input data provided is not supported - aborted tensor creation");if(void 0!==r)return p.bufferToTensor(r,o);throw Error("Input data provided is not supported - aborted tensor creation")}toImageData(e){var t,r;let n;let i=document.createElement("canvas").getContext("2d");if(null!=i){let a=this.dims[3],s=this.dims[2],o=this.dims[1],l=void 0!==e&&void 0!==e.format?e.format:"RGB",h=void 0!==e&&(null===(t=e.norm)||void 0===t?void 0:t.mean)!==void 0?e.norm.mean:255,u=void 0!==e&&(null===(r=e.norm)||void 0===r?void 0:r.bias)!==void 0?e.norm.bias:0,c=s*a;if(void 0!==e){if(void 0!==e.height&&e.height!==s)throw Error("Image output config height doesn't match tensor height");if(void 0!==e.width&&e.width!==a)throw Error("Image output config width doesn't match tensor width");if(void 0!==e.format&&4===o&&"RGBA"!==e.format||3===o&&"RGB"!==e.format&&"BGR"!==e.format)throw Error("Tensor format doesn't match input tensor dims")}let f=0,d=1,p=2,m=3,g=0,_=c,w=2*c,y=-1;"RGBA"===l?(g=0,_=c,w=2*c,y=3*c):"RGB"===l?(g=0,_=c,w=2*c):"RBG"===l&&(g=0,w=c,_=2*c),n=i.createImageData(a,s);for(let e=0;e=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(o=e.byteLength-s,"number"==typeof r){if(!Number.isSafeInteger(o=r))throw RangeError("'byteLength' must be an integer.");if(o<=0||s+o>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if("object"==typeof n&&null!==n)a=n;else if(void 0!==n)throw TypeError("'options' must be an object.")}else if(void 0!==r)throw TypeError("'byteLength' must be a number.")}else if(void 0!==t)throw TypeError("'options' must be an object.");i=new Uint8Array(e,s,o)}else throw TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let o=(a.executionProviders||[]).map(e=>"string"==typeof e?e:e.name),l=await s(o);return new g(await l.createSessionHandler(i,a))}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}let _=g},4087:function(e,t,r){"use strict";r.d(t,{YS:function(){return H}});var n=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",BooleanLiteral:"BooleanLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Set:"Set",If:"If",For:"For",In:"In",Is:"Is",NotIn:"NotIn",Else:"Else",EndIf:"EndIf",ElseIf:"ElseIf",EndFor:"EndFor",And:"And",Or:"Or",Not:"UnaryOperator"}),i=Object.freeze({set:n.Set,for:n.For,in:n.In,is:n.Is,if:n.If,else:n.Else,endif:n.EndIf,elif:n.ElseIf,endfor:n.EndFor,and:n.And,or:n.Or,not:n.Not,"not in":n.NotIn,true:n.BooleanLiteral,false:n.BooleanLiteral}),a=class{constructor(e,t){this.value=e,this.type=t}};function s(e){return/\w/.test(e)}function o(e){return/[0-9]/.test(e)}var l=[["{%",n.OpenStatement],["%}",n.CloseStatement],["{{",n.OpenExpression],["}}",n.CloseExpression],["(",n.OpenParen],[")",n.CloseParen],["{",n.OpenCurlyBracket],["}",n.CloseCurlyBracket],["[",n.OpenSquareBracket],["]",n.CloseSquareBracket],[",",n.Comma],[".",n.Dot],[":",n.Colon],["|",n.Pipe],["<=",n.ComparisonBinaryOperator],[">=",n.ComparisonBinaryOperator],["==",n.ComparisonBinaryOperator],["!=",n.ComparisonBinaryOperator],["<",n.ComparisonBinaryOperator],[">",n.ComparisonBinaryOperator],["+",n.AdditiveBinaryOperator],["-",n.AdditiveBinaryOperator],["*",n.MultiplicativeBinaryOperator],["/",n.MultiplicativeBinaryOperator],["%",n.MultiplicativeBinaryOperator],["=",n.Equals]],h=new Map([["n","\n"],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]),u=class{type="Statement"},c=class extends u{constructor(e){super(),this.body=e}type="Program"},f=class extends u{constructor(e,t,r){super(),this.test=e,this.body=t,this.alternate=r}type="If"},d=class extends u{constructor(e,t,r){super(),this.loopvar=e,this.iterable=t,this.body=r}type="For"},p=class extends u{constructor(e,t){super(),this.assignee=e,this.value=t}type="Set"},m=class extends u{type="Expression"},g=class extends m{constructor(e,t,r){super(),this.object=e,this.property=t,this.computed=r}type="MemberExpression"},_=class extends m{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},w=class extends m{constructor(e){super(),this.value=e}type="Identifier"},y=class extends m{constructor(e){super(),this.value=e}type="Literal"},b=class extends y{type="NumericLiteral"},v=class extends y{type="StringLiteral"},x=class extends y{type="BooleanLiteral"},E=class extends y{type="ArrayLiteral"},k=class extends y{type="TupleLiteral"},A=class extends y{type="ObjectLiteral"},z=class extends m{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}type="BinaryExpression"},C=class extends m{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},M=class extends m{constructor(e,t,r){super(),this.operand=e,this.negate=t,this.test=r}type="TestExpression"},I=class extends m{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},O=class extends m{constructor(e,t,r){super(),this.start=e,this.stop=t,this.step=r}type="SliceExpression"},S=class extends m{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"};function $(e,t,r=1){void 0===t&&(t=e,e=0);let n=[];for(let i=e;i=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),r=(r??=e.length)<0?Math.max(e.length+r,0):Math.min(r,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),r=(r??=-1)<-1?Math.max(e.length+r,-1):Math.min(r,e.length-1));let a=[];for(let s=t;i*se.toUpperCase())}var U=class{type="RuntimeValue";value;builtins=new Map;constructor(e){this.value=e}__bool__(){return new L(!!this.value)}},F=class extends U{type="NumericValue"},j=class extends U{type="StringValue";builtins=new Map([["upper",new q(()=>new j(this.value.toUpperCase()))],["lower",new q(()=>new j(this.value.toLowerCase()))],["strip",new q(()=>new j(this.value.trim()))],["title",new q(()=>new j(B(this.value)))],["length",new F(this.value.length)]])},L=class extends U{type="BooleanValue"},N=class extends U{type="ObjectValue";__bool__(){return new L(this.value.size>0)}builtins=new Map([["get",new q(([e,t])=>{if(!(e instanceof j))throw Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new X})],["items",new q(()=>new R(Array.from(this.value.entries()).map(([e,t])=>new R([new j(e),t]))))]])},R=class extends U{type="ArrayValue";builtins=new Map([["length",new F(this.value.length)]]);__bool__(){return new L(this.value.length>0)}},P=class extends R{type="TupleValue"},q=class extends U{type="FunctionValue"},X=class extends U{type="NullValue"},V=class extends U{type="UndefinedValue"},D=class{constructor(e){this.parent=e}variables=new Map([["namespace",new q(e=>{if(0===e.length)return new N(new Map);if(1!==e.length||!(e[0]instanceof N))throw Error("`namespace` expects either zero arguments or a single object argument");return e[0]})]]);tests=new Map([["boolean",e=>"BooleanValue"===e.type],["callable",e=>e instanceof q],["odd",e=>{if("NumericValue"!==e.type)throw Error(`Cannot apply test "odd" to type: ${e.type}`);return e.value%2!=0}],["even",e=>{if("NumericValue"!==e.type)throw Error(`Cannot apply test "even" to type: ${e.type}`);return e.value%2==0}],["false",e=>"BooleanValue"===e.type&&!e.value],["true",e=>"BooleanValue"===e.type&&e.value],["number",e=>"NumericValue"===e.type],["integer",e=>"NumericValue"===e.type&&Number.isInteger(e.value)],["iterable",e=>e instanceof R||e instanceof j],["lower",e=>{let t=e.value;return"StringValue"===e.type&&t===t.toLowerCase()}],["upper",e=>{let t=e.value;return"StringValue"===e.type&&t===t.toUpperCase()}],["none",e=>"NullValue"===e.type],["defined",e=>"UndefinedValue"!==e.type],["undefined",e=>"UndefinedValue"===e.type],["equalto",(e,t)=>e.value===t.value]]);set(e,t){return this.declareVariable(e,function e(t){switch(typeof t){case"number":return new F(t);case"string":return new j(t);case"boolean":return new L(t);case"object":if(null===t)return new X;if(Array.isArray(t))return new R(t.map(e));return new N(new Map(Object.entries(t).map(([t,r])=>[t,e(r)])));case"function":return new q((r,n)=>e(t(...r.map(e=>e.value))??null));default:throw Error(`Cannot convert to runtime value: ${t}`)}}(t))}declareVariable(e,t){if(this.variables.has(e))throw SyntaxError(`Variable already declared: ${e}`);return this.variables.set(e,t),t}setVariable(e,t){return this.variables.set(e,t),t}resolve(e){if(this.variables.has(e))return this;if(this.parent)return this.parent.resolve(e);throw Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new V}catch{return new V}}},G=class{global;constructor(e){this.global=e??new D}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){let r=this.evaluate(e.left,t);switch(e.operator.value){case"and":return r.__bool__().value?this.evaluate(e.right,t):r;case"or":return r.__bool__().value?r:this.evaluate(e.right,t)}let n=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new L(r.value==n.value);case"!=":return new L(r.value!=n.value)}if(r instanceof V||n instanceof V)throw Error("Cannot perform operation on undefined values");if(r instanceof X||n instanceof X)throw Error("Cannot perform operation on null values");if(r instanceof F&&n instanceof F)switch(e.operator.value){case"+":return new F(r.value+n.value);case"-":return new F(r.value-n.value);case"*":return new F(r.value*n.value);case"/":return new F(r.value/n.value);case"%":return new F(r.value%n.value);case"<":return new L(r.value":return new L(r.value>n.value);case">=":return new L(r.value>=n.value);case"<=":return new L(r.value<=n.value)}else if(r instanceof R&&n instanceof R){if("+"===e.operator.value)return new R(r.value.concat(n.value))}else if(n instanceof R){let t=void 0!==n.value.find(e=>e.value===r.value);switch(e.operator.value){case"in":return new L(t);case"not in":return new L(!t)}}if((r instanceof j||n instanceof j)&&"+"===e.operator.value)return new j(r.value.toString()+n.value.toString());if(r instanceof j&&n instanceof j)switch(e.operator.value){case"in":return new L(n.value.includes(r.value));case"not in":return new L(!n.value.includes(r.value))}if(r instanceof j&&n instanceof N)switch(e.operator.value){case"in":return new L(n.value.has(r.value));case"not in":return new L(!n.value.has(r.value))}throw SyntaxError(`Unknown operator "${e.operator.value}" between ${r.type} and ${n.type}`)}evaluateFilterExpression(e,t){let r=this.evaluate(e.operand,t);if("Identifier"===e.filter.type){let t=e.filter;if(r instanceof R)switch(t.value){case"list":return r;case"first":return r.value[0];case"last":return r.value[r.value.length-1];case"length":return new F(r.value.length);case"reverse":return new R(r.value.reverse());case"sort":return new R(r.value.sort((e,t)=>{if(e.type!==t.type)throw Error(`Cannot compare different types: ${e.type} and ${t.type}`);switch(e.type){case"NumericValue":return e.value-t.value;case"StringValue":return e.value.localeCompare(t.value);default:throw Error(`Cannot compare type: ${e.type}`)}}));default:throw Error(`Unknown ArrayValue filter: ${t.value}`)}else if(r instanceof j)switch(t.value){case"length":return new F(r.value.length);case"upper":return new j(r.value.toUpperCase());case"lower":return new j(r.value.toLowerCase());case"title":return new j(B(r.value));case"capitalize":return new j(r.value.charAt(0).toUpperCase()+r.value.slice(1));case"trim":return new j(r.value.trim());default:throw Error(`Unknown StringValue filter: ${t.value}`)}else if(r instanceof F){if("abs"===t.value)return new F(Math.abs(r.value));throw Error(`Unknown NumericValue filter: ${t.value}`)}else if(r instanceof N)switch(t.value){case"items":return new R(Array.from(r.value.entries()).map(([e,t])=>new R([new j(e),t])));case"length":return new F(r.value.size);default:throw Error(`Unknown ObjectValue filter: ${t.value}`)}throw Error(`Cannot apply filter "${t.value}" to type: ${r.type}`)}if("CallExpression"===e.filter.type){let n=e.filter;if("Identifier"!==n.callee.type)throw Error(`Unknown filter: ${n.callee.type}`);let i=n.callee.value;if(r instanceof R){if("selectattr"===i){let e;if(r.value.some(e=>!(e instanceof N)))throw Error("`selectattr` can only be applied to array of objects");if(n.args.some(e=>"StringLiteral"!==e.type))throw Error("arguments of `selectattr` must be strings");let[i,a,s]=n.args.map(e=>this.evaluate(e,t));if(a){let r=t.tests.get(a.value);if(!r)throw Error(`Unknown test: ${a.value}`);e=r}else e=(...e)=>e[0].__bool__().value;return new R(r.value.filter(t=>{let r=t.value.get(i.value);return!!r&&e(r,s)}))}throw Error(`Unknown ArrayValue filter: ${i}`)}throw Error(`Cannot apply filter "${i}" to type: ${r.type}`)}throw Error(`Unknown filter: ${e.filter.type}`)}evaluateTestExpression(e,t){let r=this.evaluate(e.operand,t),n=t.tests.get(e.test.value);if(!n)throw Error(`Unknown test: ${e.test.value}`);let i=n(r);return new L(e.negate?!i:i)}evaluateUnaryExpression(e,t){let r=this.evaluate(e.argument,t);if("not"===e.operator.value)return new L(!r.value);throw SyntaxError(`Unknown operator: ${e.operator.value}`)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let r="";for(let n of e){let e=this.evaluate(n,t);"NullValue"!==e.type&&"UndefinedValue"!==e.type&&(r+=e.value)}return new j(r)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){let r=[],n=new Map;for(let i of e.args)"KeywordArgumentExpression"===i.type?n.set(i.key.value,this.evaluate(i.value,t)):r.push(this.evaluate(i,t));n.size>0&&r.push(new N(n));let i=this.evaluate(e.callee,t);if("FunctionValue"!==i.type)throw Error(`Cannot call something that is not a function: got ${i.type}`);return i.value(r,t)}evaluateSliceExpression(e,t,r){if(!(e instanceof R||e instanceof j))throw Error("Slice object must be an array or string");let n=this.evaluate(t.start,r),i=this.evaluate(t.stop,r),a=this.evaluate(t.step,r);if(!(n instanceof F||n instanceof V))throw Error("Slice start must be numeric or undefined");if(!(i instanceof F||i instanceof V))throw Error("Slice stop must be numeric or undefined");if(!(a instanceof F||a instanceof V))throw Error("Slice step must be numeric or undefined");return e instanceof R?new R(T(e.value,n.value,i.value,a.value)):new j(T(Array.from(e.value),n.value,i.value,a.value).join(""))}evaluateMemberExpression(e,t){let r,n;let i=this.evaluate(e.object,t);if(e.computed){if("SliceExpression"===e.property.type)return this.evaluateSliceExpression(i,e.property,t);r=this.evaluate(e.property,t)}else r=new j(e.property.value);if(i instanceof N){if(!(r instanceof j))throw Error(`Cannot access property with non-string: got ${r.type}`);n=i.value.get(r.value)??i.builtins.get(r.value)}else if(i instanceof R||i instanceof j){if(r instanceof F)n=i.value.at(r.value),i instanceof j&&(n=new j(i.value.at(r.value)));else if(r instanceof j)n=i.builtins.get(r.value);else throw Error(`Cannot access property with non-string/non-number: got ${r.type}`)}else{if(!(r instanceof j))throw Error(`Cannot access property with non-string: got ${r.type}`);n=i.builtins.get(r.value)}return n instanceof U?n:new V}evaluateSet(e,t){let r=this.evaluate(e.value,t);if("Identifier"===e.assignee.type){let n=e.assignee.value;t.setVariable(n,r)}else if("MemberExpression"===e.assignee.type){let n=e.assignee,i=this.evaluate(n.object,t);if(!(i instanceof N))throw Error("Cannot assign to member of non-object");if("Identifier"!==n.property.type)throw Error("Cannot assign to member with non-identifier property");i.value.set(n.property.value,r)}else throw Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);return new X}evaluateIf(e,t){let r=this.evaluate(e.test,t);return this.evaluateBlock(r.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){let r=new D(t),n=this.evaluate(e.iterable,r);if(!(n instanceof R))throw Error(`Expected iterable type in for loop: got ${n.type}`);let i="";for(let t=0;t0?n.value[t-1]:new V],["nextitem",ts.value.length?"few":"many"} items to unpack`);for(let e=0;ethis.evaluate(e,t)));case"TupleLiteral":return new P(e.value.map(e=>this.evaluate(e,t)));case"ObjectLiteral":{let r=new Map;for(let[n,i]of e.value){let e=this.evaluate(n,t);if(!(e instanceof j))throw Error(`Object keys must be strings: got ${e.type}`);r.set(e.value,this.evaluate(i,t))}return new N(r)}case"Identifier":return this.evaluateIdentifier(e,t);case"CallExpression":return this.evaluateCallExpression(e,t);case"MemberExpression":return this.evaluateMemberExpression(e,t);case"UnaryExpression":return this.evaluateUnaryExpression(e,t);case"BinaryExpression":return this.evaluateBinaryExpression(e,t);case"FilterExpression":return this.evaluateFilterExpression(e,t);case"TestExpression":return this.evaluateTestExpression(e,t);default:throw SyntaxError(`Unknown node type: ${e.type}`)}}},H=class{parsed;constructor(e){let t=function(e,t={}){let r=[],u=function(e,t={}){return e.endsWith("\n")&&(e=e.slice(0,-1)),e=e.replace(/{#.*?#}/gs,"{##}"),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%])/gm,"$1")),t.trim_blocks&&(e=e.replace(/([#%]})\n/g,"$1")),e.replace(/{##}/g,"").replace(/-%}\s*/g,"%}").replace(/\s*{%-/g,"{%").replace(/-}}\s*/g,"}}").replace(/\s*{{-/g,"{{")}(e,t),c=0,f=e=>{let t="";for(;e(u[c]);){if("\\"===u[c]){if(++c>=u.length)throw SyntaxError("Unexpected end of input");let e=u[c++],r=h.get(e);if(void 0===r)throw SyntaxError(`Unexpected escaped character: ${e}`);t+=r;continue}if(t+=u[c++],c>=u.length)throw SyntaxError("Unexpected end of input")}return t};e:for(;c0){r.push(new a(e,n.Text));continue}}f(e=>/\s/.test(e));let t=u[c];if("-"===t||"+"===t){let e=r.at(-1)?.type;if(e===n.Text||void 0===e)throw SyntaxError(`Unexpected character: ${t}`);switch(e){case n.Identifier:case n.NumericLiteral:case n.BooleanLiteral:case n.StringLiteral:case n.CloseParen:case n.CloseSquareBracket:break;default:{++c;let e=f(o);r.push(new a(`${t}${e}`,e.length>0?n.NumericLiteral:n.UnaryOperator));continue}}}for(let[e,t]of l)if(u.slice(c,c+e.length)===e){r.push(new a(e,t)),c+=e.length;continue e}if("'"===t||'"'===t){++c;let e=f(e=>e!==t);r.push(new a(e,n.StringLiteral)),++c;continue}if(o(t)){let e=f(o);r.push(new a(e,n.NumericLiteral));continue}if(s(t)){let e=f(s),t=Object.hasOwn(i,e)?i[e]:n.Identifier;t===n.In&&r.at(-1)?.type===n.Not?(r.pop(),r.push(new a("not in",n.NotIn))):r.push(new a(e,t));continue}throw SyntaxError(`Unexpected character: ${t}`)}return r}(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=function(e){let t=new c([]),r=0;function i(t,n){let i=e[r++];if(!i||i.type!==t)throw Error(`Parser Error: ${n}. ${i.type} !== ${t}.`);return i}function a(...t){return r+t.length<=e.length&&t.every((t,n)=>t===e[r+n].type)}function s(e=!1){let t=e?B:o,i=[t()],s=a(n.Comma);for(;s&&(++r,i.push(t()),a(n.Comma)););return s?new k(i):i[0]}function o(){return function(){let e=l();if(a(n.If)){++r;let t=l();return i(n.Else,"Expected else token"),new f(t,[e],[l()])}return e}()}function l(){let t=h();for(;a(n.Or);){let n=e[r];++r,t=new z(n,t,h())}return t}function h(){let t=u();for(;a(n.And);){let n=e[r];++r,t=new z(n,t,u())}return t}function u(){let t;for(;a(n.Not);){let n=e[r];++r,t=new I(n,u())}return t??function(){let t=m();for(;a(n.ComparisonBinaryOperator)||a(n.In)||a(n.NotIn);){let n=e[r];++r,t=new z(n,t,m())}return t}()}function m(){let t=$();for(;a(n.AdditiveBinaryOperator);){let n=e[r];++r,t=new z(n,t,$())}return t}function y(e){let t=new _(e,function(){i(n.OpenParen,"Expected opening parenthesis for arguments list");let e=function(){let e=[];for(;!a(n.CloseParen);){let t=o();if(a(n.Equals)){if(++r,!(t instanceof w))throw SyntaxError("Expected identifier for keyword argument");t=new S(t,o())}e.push(t),a(n.Comma)&&++r}return e}();return i(n.CloseParen,"Expected closing parenthesis for arguments list"),e}());return a(n.OpenParen)&&(t=y(t)),t}function $(){let t=T();for(;a(n.MultiplicativeBinaryOperator);){let n=e[r];++r,t=new z(n,t,T())}return t}function T(){let t=function(){let t=function(){let t=function(){let t=B();for(;a(n.Dot)||a(n.OpenSquareBracket);){let s;let l=e[r];++r;let h=l.type!==n.Dot;if(h)s=function(){let e=[],t=!1;for(;!a(n.CloseSquareBracket);)a(n.Colon)?(e.push(void 0),++r,t=!0):(e.push(o()),a(n.Colon)&&(++r,t=!0));if(0===e.length)throw SyntaxError("Expected at least one argument for member/slice expression");if(t){if(e.length>3)throw SyntaxError("Expected 0-3 arguments for slice expression");return new O(...e)}return e[0]}(),i(n.CloseSquareBracket,"Expected closing square bracket");else if("Identifier"!==(s=B()).type)throw SyntaxError("Expected identifier following dot operator");t=new g(t,s,h)}return t}();return a(n.OpenParen)?y(t):t}();for(;a(n.Pipe);){++r;let e=B();if(!(e instanceof w))throw SyntaxError("Expected identifier for the filter");a(n.OpenParen)&&(e=y(e)),t=new C(t,e)}return t}();for(;a(n.Is);){++r;let e=a(n.Not);e&&++r;let i=B();if(i instanceof x&&(i=new w(i.value.toString())),!(i instanceof w))throw SyntaxError("Expected identifier for the test");t=new M(t,e,i)}return t}function B(){let t=e[r];switch(t.type){case n.NumericLiteral:return++r,new b(Number(t.value));case n.StringLiteral:return++r,new v(t.value);case n.BooleanLiteral:return++r,new x("true"===t.value);case n.Identifier:return++r,new w(t.value);case n.OpenParen:{++r;let t=s();if(e[r].type!==n.CloseParen)throw SyntaxError(`Expected closing parenthesis, got ${e[r].type} instead`);return++r,t}case n.OpenSquareBracket:{++r;let e=[];for(;!a(n.CloseSquareBracket);)e.push(o()),a(n.Comma)&&++r;return++r,new E(e)}case n.OpenCurlyBracket:{++r;let e=new Map;for(;!a(n.CloseCurlyBracket);){let t=o();i(n.Colon,"Expected colon between key and value in object literal");let s=o();e.set(t,s),a(n.Comma)&&++r}return++r,new A(e)}default:throw SyntaxError(`Unexpected token: ${t.type}`)}}for(;rt!==e[r+n].type)}(n.OpenStatement,n.EndFor);)h.push(t());return new d(a,l,h)}(),i(n.OpenStatement,"Expected {% token"),i(n.EndFor,"Expected endfor token"),i(n.CloseStatement,"Expected %} token");break;default:throw SyntaxError(`Unknown statement type: ${e[r].type}`)}return l}();case n.OpenExpression:return function(){i(n.OpenExpression,"Expected opening expression token");let e=o();return i(n.CloseExpression,"Expected closing expression token"),e}();default:throw SyntaxError(`Unexpected token type: ${e[r].type}`)}}());return t}(t)}render(e){let t=new D;for(let[r,n]of(t.set("false",!1),t.set("true",!0),t.set("raise_exception",e=>{throw Error(e)}),t.set("range",$),Object.entries(e)))t.set(r,n);return new G(t).run(this.parsed).value}}},1542:function(e,t,r){"use strict";let n;r.d(t,{ONNX:function(){return n},p:function(){return h}});var i,a,s=r(495),o=r(7004),l=r(357);let h=["wasm"];void 0!==l&&l?.release?.name==="node"?(n=s??(i||(i=r.t(s,2))),h.unshift("cpu")):(n=o??(a||(a=r.t(o,2))),"undefined"!=typeof navigator&&/iP(hone|od|ad).+16_4.+AppleWebKit/.test(navigator.userAgent)&&(n.env.wasm.simd=!1))},16:function(e,t,r){"use strict";r.d(t,{z:function(){return s}});var n=r(911);async function i(e,t){return await (0,n.yM)(e,"config.json",!0,t)}class a{constructor(e){this.model_type=null,this.is_encoder_decoder=!1,Object.assign(this,e)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:a=!1,revision:s="main"}={}){return new this(r??await i(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:a,revision:s}))}}class s{static async from_pretrained(...e){return a.from_pretrained(...e)}}},851:function(e,t,r){"use strict";r.d(t,{O:function(){return g}});var n=r(8386),i=r(3342),a=r(8464);let{env:s}=r(1542).ONNX,o="2.17.0",l="undefined"!=typeof self&&"caches"in self,h=!_(n),u=!_(i),c=h&&u,f=c?i.dirname(i.dirname(a.fileURLToPath("file:///workspace/PhoWhisper-next/node_modules/@xenova/transformers/src/env.js"))):"./",d=c?i.join(f,"/.cache/"):null,p="/models/",m=c?i.join(f,p):p;s?.wasm&&(s.wasm.wasmPaths=c?i.join(f,"/dist/"):`https://cdn.jsdelivr.net/npm/@xenova/transformers@${o}/dist/`);let g={backends:{onnx:s,tfjs:{}},__dirname:f,version:o,allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!0,localModelPath:m,useFS:h,useBrowserCache:l,useFSCache:h,cacheDir:d,useCustomCache:!1,customCache:null};function _(e){return 0===Object.keys(e).length}},9078:function(e,t,r){"use strict";let n,i,a;r.d(t,{OBj:function(){return f.O},qCb:function(){return u.qC},EUT:function(){return eJ}});var s=r(9046),o=r(9454),l=r(761),h=r(911),u=r(8709),c=r(2414),f=r(851),d=r(8741);let p="undefined"!=typeof self,m=p&&"DedicatedWorkerGlobalScope"===self.constructor.name;if(p)n=(e,t)=>{if(!self.OffscreenCanvas)throw Error("OffscreenCanvas not supported by this browser.");return new self.OffscreenCanvas(e,t)},a=self.createImageBitmap,i=self.ImageData;else if(d)a=async e=>{let t=(await e.metadata()).channels,{data:r,info:n}=await e.raw().toBuffer({resolveWithObject:!0}),i=new w(new Uint8ClampedArray(r),n.width,n.height,n.channels);return void 0!==t&&t!==n.channels&&i.convert(t),i};else throw Error("Unable to load image processing library.");let g={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},_=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]);class w{constructor(e,t,r,n){this.data=e,this.width=t,this.height=r,this.channels=n}get size(){return[this.width,this.height]}static async read(e){if(e instanceof w)return e;if("string"==typeof e||e instanceof URL)return await this.fromURL(e);throw Error(`Unsupported input type: ${typeof e}`)}static async fromURL(e){let t=await (0,h.hn)(e);if(200!==t.status)throw Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);let r=await t.blob();return this.fromBlob(r)}static async fromBlob(e){if(p){let t=await a(e),r=n(t.width,t.height).getContext("2d");return r.drawImage(t,0,0),new this(r.getImageData(0,0,t.width,t.height).data,t.width,t.height,4)}{let t=d(await e.arrayBuffer());return await a(t)}}static fromTensor(e,t="CHW"){if(3!==e.dims.length)throw Error(`Tensor should have 3 dimensions, but has ${e.dims.length} dimensions.`);if("CHW"===t)e=e.transpose(1,2,0);else if("HWC"===t);else throw Error(`Unsupported channel format: ${t}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new w(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(1===this.channels)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let t=0,r=0;t=0?l=r:u=-r,i>=0?h=i:c=-i,o.drawImage(s,l,h,e,t,u,c,e,t),new w(o.getImageData(0,0,e,t).data,e,t,4).convert(a)}{let n=this.toSharp();if(r>=0&&i>=0)n=n.extract({left:Math.floor(r),top:Math.floor(i),width:e,height:t});else if(r<=0&&i<=0){let a=Math.floor(-i),s=Math.floor(-r);n=n.extend({top:a,left:s,right:e-this.width-s,bottom:t-this.height-a})}else{let a=[0,0],s=0;i<0?(a[0]=Math.floor(-i),a[1]=t-this.height-a[0]):s=Math.floor(i);let o=[0,0],l=0;r<0?(o[0]=Math.floor(-r),o[1]=e-this.width-o[0]):l=Math.floor(r),n=n.extend({top:a[0],bottom:a[1],left:o[0],right:o[1]}).extract({left:l,top:s,width:e,height:t})}return await a(n)}}async toBlob(e="image/png",t=1){if(!p)throw Error("toBlob() is only supported in browser environments.");let r=this.toCanvas();return await r.convertToBlob({type:e,quality:t})}toTensor(e="CHW"){let t=new c.es("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if("HWC"===e);else if("CHW"===e)t=t.permute(2,0,1);else throw Error(`Unsupported channel format: ${e}`);return t}toCanvas(){if(!p)throw Error("toCanvas() is only supported in browser environments.");let e=this.clone().rgba(),t=n(e.width,e.height),r=new i(e.data,e.width,e.height);return t.getContext("2d").putImageData(r,0,0),t}_update(e,t,r,n=null){return this.data=e,this.width=t,this.height=r,null!==n&&(this.channels=n),this}clone(){return new w(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(p){if(m)throw Error("Unable to save an image from a Web Worker.");let t=e.split(".").pop().toLowerCase(),r=_.get(t)??"image/png",n=await this.toBlob(r),i=URL.createObjectURL(n),a=document.createElement("a");a.href=i,a.download=e,a.click(),a.remove()}else if(f.O.useFS){let t=this.toSharp();return await t.toFile(e)}else throw Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(p)throw Error("toSharp() is only supported in server-side environments.");return d(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}}async function y(e,t){let r;if("undefined"==typeof AudioContext)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.");let n=await (await (0,h.hn)(e)).arrayBuffer(),i=new AudioContext({sampleRate:t});void 0===t&&console.warn(`No sampling rate provided, using default of ${i.sampleRate}Hz.`);let a=await i.decodeAudioData(n);if(2===a.numberOfChannels){let e=Math.sqrt(2),t=a.getChannelData(0),n=a.getChannelData(1);r=new Float32Array(t.length);for(let i=0;i2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,r=15,n=27/Math.log(6.4))=>e>=t?r+Math.log(e/t)*n:3*e/200};function x(e,t="htk"){let r=v[t];if(!r)throw Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return"number"==typeof e?r(e):e.map(e=>r(e))}let E={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,r=15,n=Math.log(6.4)/27)=>e>=r?t*Math.exp(n*(e-r)):200*e/3};function k(e,t,r){let n=(t-e)/(r-1);return Float64Array.from({length:r},(t,r)=>e+n*r)}function A(e,t,r,n,i,a=null,s="htk",o=!1){let l;if(null!==a&&"slaney"!==a)throw Error('norm must be one of null or "slaney"');let h=k(x(r,s),x(n,s),t+2),u=function(e,t="htk"){let r=E[t];if(!r)throw Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return"number"==typeof e?r(e):e.map(e=>r(e))}(h,s);if(o){let t=i/(2*e);l=x(Float64Array.from({length:e},(e,r)=>r*t),s),u=h}else l=k(0,Math.floor(i/2),e);let c=function(e,t){let r=Float64Array.from({length:t.length-1},(e,r)=>t[r+1]-t[r]),n=Array.from({length:e.length},()=>Array(t.length));for(let r=0;rArray(e.length));for(let t=0;ti)throw Error(`frame_length (${r}) may not be larger than fft_length (${i})`);if(x!==r)throw Error(`Length of the window (${x}) must equal frame_length (${r})`);if(n<=0)throw Error("hop_length must be greater than zero");if(s){if("reflect"!==o)throw Error(`pad_mode="${o}" not implemented yet.`);let t=Math.floor((i-1)/2)+1;e=function(e,t,r){let n=new e.constructor(e.length+t+r),i=e.length-1;for(let r=0;rE?b&&(C=y):C=A=y);let M=new u.vw(i),I=new Float64Array(i),O=new Float64Array(M.outputBufferSize),S=Array(A);for(let i=0;i=1;--e)I[e]-=c*I[e-1];I[0]*=1-c}for(let e=0;eMath.pow(e,.85));break;default:throw Error(`Unknown window type ${t}.`)}if(r&&(a=a.subarray(0,e)),null===n)return a;if(e>n)throw Error(`Length of the window (${e}) may not be larger than frame_length (${n})`);return a}function I(e,t=.5,r=null,n=!1){let i=e.logits,a=e.pred_boxes,[s,o,l]=i.dims;if(null!==r&&r.length!==s)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let h=[];for(let e=0;et&&a.push(e)}else{let e=(0,u.Fp)(i.data)[1];if(e===l-1)continue;a.push(e),r=(0,u.XA)(i.data)}for(let t of a){let n=d[e].data;n=function([e,t,r,n]){return[e-r/2,t-n/2,e+r/2,t+n/2]}(n),null!==s&&(n=n.map((e,t)=>e*s[(t+1)%2])),c.boxes.push(n),c.classes.push(t),c.scores.push(r[t])}}h.push(c)}return h}function O(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${e?.constructor?.name??typeof e} 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.`)}function S(e,t,r=0,n=null){let i=e/t,a=(0,u.eT)(i)*t;return null!==n&&a>n&&(a=Math.floor(i)*t),ai?l=Math.floor(i*o/n):i>n&&(o=Math.floor(n*l/i)),await e.resize(l,o,{resample:r}))}async crop_margin(e,t=200){let r=e.clone().grayscale(),n=(0,u.VV)(r.data)[0],i=(0,u.Fp)(r.data)[0]-n;if(0===i)return e;let a=t/255,s=r.width,o=r.height,l=0,h=0;for(let e=0;ethis.preprocess(e)));return{pixel_values:(0,c.kn)(r.map(e=>e.pixel_values),0),original_sizes:r.map(e=>e.original_size),reshaped_input_sizes:r.map(e=>e.reshaped_input_size)}}}class U extends B{post_process_semantic_segmentation(e,t=null){let r=e.logits,n=r.dims[0];if(null!==t&&t.length!==n)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let i=[];for(let e=0;eh[r]&&(h[r]=t[r],l.data[r]=e)}let u=Array(a.dims[0]),f=l.data;for(let e=0;evoid 0!==e);i.push({segmentation:l,labels:d})}return i}}class F extends B{}class j extends F{}class L extends B{}class N extends B{}class R extends B{}class P extends B{}class q extends B{}class X extends B{constructor(e){super(e),this.crop_pct=this.config.crop_pct??.875}async resize(e){let t=this.size?.shortest_edge;if(void 0===t)throw Error("Size dictionary must contain 'shortest_edge' key.");if(t<384){let r=Math.floor(t/this.crop_pct),[n,i]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(n,i,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}}class V extends X{}class D extends B{}class G extends B{}class H extends B{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(e=>e*e))}}class W extends B{}class K extends B{post_process_object_detection(...e){return I(...e)}}class J extends K{}class Y extends B{}class Z extends B{}class Q extends B{pad_image(e,t,r,n={}){let[i,a,s]=t,o=this.image_mean;Array.isArray(this.image_mean)||(o=Array(s).fill(o));let l=this.image_std;Array.isArray(l)||(l=Array(s).fill(o));let h=o.map((e,t)=>-e/l[t]);return super.pad_image(e,t,r,{center:!0,constant_values:h,...n})}}class ee extends Q{}class et extends B{async _call(e){let t=await super._call(e),r=[t.pixel_values.dims[0],64,64],n=new c.es("int64",new BigInt64Array(r.reduce((e,t)=>e*t)).fill(1n),r);return{...t,pixel_mask:n}}post_process_object_detection(...e){return I(...e)}remove_low_and_no_objects(e,t,r,n){let i=[],a=[],s=[];for(let o=0;or&&(i.push(h),a.push(f),s.push(c))}return[i,a,s]}check_segment_validity(e,t,r,n=.5,i=.8){let a=[],s=0,o=0;for(let i=0;i=n&&++o;let l=s>0&&o>0;return l&&(l=s/o>i),[l,a]}compute_segments(e,t,r,n,i,a=null,s=null){let[o,l]=s??e[0].dims,h=new c.es("int32",new Int32Array(o*l),[o,l]),u=[];if(null!==s)for(let t=0;td[t]&&(f[t]=r,d[t]=e[r].data[t])}let p=0;for(let a=0;ae!==t.dims[r]))throw Error(`The first ${r.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new c.es("int64",e.flat(1/0).map(BigInt),r)}async _call(e,t=null,r=null){let n=await super._call(e);if(t&&(n.input_points=this.reshape_input_points(t,n.original_sizes,n.reshaped_input_sizes)),r){if(!n.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");n.input_labels=this.add_input_labels(r,n.input_points)}return n}post_process_masks(e,t,r,{mask_threshold:n=0,binarize:i=!0,pad_size:a=null}={}){let s=[],o=[(a=a??this.pad_size).height,a.width];for(let a=0;an&&(e[t]=1);r=new c.es("bool",e,r.dims)}f.push(r)}s.push((0,c.kn)(f))}return s}}class ei extends B{pad_image(e,t,r,n={}){let[i,a,s]=t;return super.pad_image(e,t,{width:a+(r-a%r)%r,height:i+(r-i%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...n})}}class ea extends B{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let r=await Promise.all(e.map(e=>this.preprocess(e))),n=await Promise.all(t.map(e=>this.preprocess(e,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:(0,c.kn)(r.map((e,t)=>(0,c.d3)([e.pixel_values,n[t].pixel_values],0)),0),original_sizes:r.map(e=>e.original_size),reshaped_input_sizes:r.map(e=>e.reshaped_input_size)}}}class es extends T{constructor(e){super(e),this.config.mel_filters??=A(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=M(this.config.n_fft,"hann")}_extract_fbank_features(e){let{data:t,dims:r}=C(e,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}),n=(0,u.Fp)(t)[0];for(let e=0;ethis.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`."),t=e.slice(0,this.config.n_samples)):(t=new Float32Array(this.config.n_samples)).set(e);let{data:r,dims:n}=this._extract_fbank_features(t);return{input_features:new c.es("float32",r,[1,...n])}}}class eo extends T{_zero_mean_unit_var_norm(e){let t=e.reduce((e,t)=>e+t,0)/e.length,r=e.reduce((e,r)=>e+(r-t)**2,0)/e.length;return e.map(e=>(e-t)/Math.sqrt(r+1e-7))}async _call(e){O(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));let r=[1,t.length];return{input_values:new c.es("float32",t,r),attention_mask:new c.es("int64",new BigInt64Array(t.length).fill(1n),r)}}}class el extends T{constructor(e){super(e);let t=this.config.sampling_rate,r=A(256,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);for(let e=0;e32768*e),this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:r=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:i=!0}={}){let a;O(e,"SeamlessM4TFeatureExtractor");let s=this._extract_fbank_features(e,this.config.max_length);if(n){let[e,t]=s.dims;for(let r=0;r0){let r=new Float32Array(t*(e+n));r.set(s.data),r.fill(this.config.padding_value,s.data.length);let o=e+n;s={data:r,dims:[o,t]},i&&(a=new c.es("int64",new BigInt64Array(o),[1,o])).data.fill(1n,0,e)}}let[o,l]=s.dims,h=this.config.stride;if(0!=o%h)throw Error(`The number of frames (${o}) must be a multiple of the stride (${h}).`);let u=new c.es("float32",s.data,s.dims).view(1,Math.floor(o/h),l*h),f={input_features:u};if(i){let e=u.dims[1],t=new c.es("int64",new BigInt64Array(e),[1,e]);if(a)for(let e=1,r=0;e0){if("rand_trunc"===r){a=!0;let r=Math.floor(Math.random()*(s+1));e=e.subarray(r,r+t),(i=this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)).dims=[1,...i.dims]}else throw Error(`Truncation strategy "${r}" not implemented`)}else{if(s<0){let r=new Float64Array(t);if(r.set(e),"repeat"===n)for(let n=e.length;nw.read(e)))}async function eb(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>"string"==typeof e||e instanceof URL?y(e,t):e instanceof Float64Array?new Float32Array(e):e))}function ev(e,t){t&&(e=e.map(e=>0|e));let[r,n,i,a]=e;return{xmin:r,ymin:n,xmax:i,ymax:a}}class ex extends l.Ag{constructor({task:e,model:t,tokenizer:r=null,processor:n=null}){super(),this.task=e,this.model=t,this.tokenizer=r,this.processor=n}async dispose(){await this.model.dispose()}}class eE extends ex{constructor(e){super(e)}async _call(e,{topk:t=1}={}){let r=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(r),i="multi_label_classification"===this.model.config.problem_type?e=>e.sigmoid().data:e=>(0,u.XA)(e.data),a=this.model.config.id2label,s=[];for(let e of n.logits){let r=i(e),n=(0,u.em)(r,t).map(e=>({label:a[e[0]],score:e[1]}));1===t?s.push(...n):s.push(n)}return Array.isArray(e)||1===t?s:s[0]}}class ek extends ex{constructor(e){super(e)}async _call(e,{ignore_labels:t=["O"]}={}){let r=Array.isArray(e),n=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),i=(await this.model(n)).logits,a=this.model.config.id2label,s=[];for(let e=0;e[e,t]).filter(e=>e[1]>s),h=Array.from((0,u.XA)(i.end_logits[e].data)).map((e,t)=>[e,t]).filter(e=>e[1]>s),c=(0,l.O7)(o,h).filter(e=>e[0][1]<=e[1][1]).map(e=>[e[0][1],e[1][1],e[0][0]*e[1][0]]).sort((e,t)=>t[2]-e[2]);for(let e=0;e{let t=[...a];return t[s]=e[0],{score:e[1],token:e[0],token_str:this.tokenizer.model.vocab[e[0]],sequence:this.tokenizer.decode(t,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}}class eC extends ex{_key="generated_text";constructor(e){super(e)}async _call(e,t={}){let r;Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(e=>this.model.config.prefix+e));let n=this.model.config.task_specific_params;n&&n[this.task]&&n[this.task].prefix&&(e=e.map(e=>n[this.task].prefix+e));let i=this.tokenizer,a={padding:!0,truncation:!0};r=this instanceof eI&&"_build_translation_inputs"in i?i._build_translation_inputs(e,a,t).input_ids:i(e,a).input_ids;let s=await this.model.generate(r,t);return i.batch_decode(s,{skip_special_tokens:!0}).map(e=>({[this._key]:e}))}}class eM extends eC{_key="summary_text";constructor(e){super(e)}}class eI extends eC{_key="translation_text";constructor(e){super(e)}}function eO(e){return Array.isArray(e)&&e.every(e=>"role"in e&&"content"in e)}class eS extends ex{constructor(e){super(e)}async _call(e,t={}){let r,n,i=!1,a=!1;if("string"==typeof e)r=e=[e];else if(Array.isArray(e)&&e.every(e=>"string"==typeof e))i=!0,r=e;else{if(eO(e))e=[e];else if(Array.isArray(e)&&e.every(eO))i=!0;else throw Error("Input must be a string, an array of strings, a Chat, or an array of Chats");a=!0,r=e.map(e=>this.tokenizer.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0}))}let s=t.add_special_tokens??!1,o=!a&&(t.return_full_text??!0);this.tokenizer.padding_side="left";let{input_ids:l,attention_mask:h}=this.tokenizer(r,{add_special_tokens:s,padding:!0,truncation:!0}),u=await this.model.generate(l,t,null,{inputs_attention_mask:h}),c=this.tokenizer.batch_decode(u,{skip_special_tokens:!0});!o&&l.dims.at(-1)>0&&(n=this.tokenizer.batch_decode(l,{skip_special_tokens:!0}).map(e=>e.length));let f=Array.from({length:e.length},e=>[]);for(let t=0;t[e.toLowerCase(),t])),this.entailment_id=this.label2id.entailment,void 0===this.entailment_id&&(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,void 0===this.contradiction_id&&(console.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(e,t,{hypothesis_template:r="This example is {}.",multi_label:n=!1}={}){let i=Array.isArray(e);i||(e=[e]),Array.isArray(t)||(t=[t]);let a=t.map(e=>r.replace("{}",e)),s=n||1===t.length,o=[];for(let r of e){let e=[];for(let t of a){let n=this.tokenizer(r,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(n);s?e.push([i.logits.data[this.contradiction_id],i.logits.data[this.entailment_id]]):e.push(i.logits.data[this.entailment_id])}let n=(s?e.map(e=>(0,u.XA)(e)[1]):(0,u.XA)(e)).map((e,t)=>[e,t]).sort((e,t)=>t[0]-e[0]);o.push({sequence:r,labels:n.map(e=>t[e[1]]),scores:n.map(e=>e[0])})}return i?o:o[0]}}class eT extends ex{constructor(e){super(e)}async _call(e,{pooling:t="none",normalize:r=!1,quantize:n=!1,precision:i="binary"}={}){let a=this.tokenizer(e,{padding:!0,truncation:!0}),s=await this.model(a),o=s.last_hidden_state??s.logits;if("none"===t);else if("mean"===t)o=(0,c.v6)(o,a.attention_mask);else if("cls"===t)o=o.slice(null,0);else throw Error(`Pooling method '${t}' not supported.`);return r&&(o=o.normalize(2,-1)),n&&(o=(0,c.e)(o,i)),o}}class eB extends ex{constructor(e){super(e)}async _call(e,{pool:t=null}={}){let r;let n=await ey(e),{pixel_values:i}=await this.processor(n),a=await this.model({pixel_values:i});if(t){if(!("pooler_output"in a))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");r=a.pooler_output}else r=a.last_hidden_state??a.logits??a.image_embeds;return r}}class eU extends ex{constructor(e){super(e)}async _call(e,{topk:t=null}={}){let r=!Array.isArray(e),n=this.processor.feature_extractor.config.sampling_rate,i=await eb(e,n),a=this.model.config.id2label,s=[];for(let e of i){let r=await this.processor(e),n=(await this.model(r)).logits[0],i=(0,u.em)((0,u.XA)(n.data),t).map(e=>({label:a[e[0]],score:e[1]}));1===t?s.push(...i):s.push(i)}return r&&1!==t?s[0]:s}}class eF extends ex{constructor(e){super(e)}async _call(e,t,{hypothesis_template:r="This is a sound of {}."}={}){let n=!Array.isArray(e);n&&(e=[e]);let i=t.map(e=>r.replace("{}",e)),a=this.tokenizer(i,{padding:!0,truncation:!0}),s=this.processor.feature_extractor.config.sampling_rate,o=await eb(e,s),l=[];for(let e of o){let r=await this.processor(e),n=await this.model({...a,...r}),i=(0,u.XA)(n.logits_per_audio.data);l.push([...i].map((e,r)=>({score:e,label:t[r]})))}return n?l[0]:l}}class ej extends ex{constructor(e){super(e)}async _call(e,t={}){switch(this.model.config.model_type){case"whisper":return this._call_whisper(e,t);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":return this._call_wav2vec2(e,t);default:throw Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t={}){t.language&&console.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&console.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let r=!Array.isArray(e);r&&(e=[e]);let n=this.processor.feature_extractor.config.sampling_rate,i=await eb(e,n),a=[];for(let e of i){let t=await this.processor(e),r=(await this.model(t)).logits[0],n=[];for(let e of r)n.push((0,u.Fp)(e.data)[1]);let i=this.tokenizer.decode(n);a.push({text:i})}return r?a[0]:a}async _call_whisper(e,t={}){let r=t.return_timestamps??!1,n=t.chunk_length_s??0,i=t.chunk_callback??null,a=t.force_full_sequences??!1,s=t.stride_length_s??null;"word"===r&&(t.return_token_timestamps=!0);let o=(0,l.Sw)(t,"language",null),h=(0,l.Sw)(t,"task",null);if(o||h||r){if(t.forced_decoder_ids)throw Error("Cannot specify `language`/`task`/`return_timestamps` and `forced_decoder_ids` at the same time.");let e=this.tokenizer.get_decoder_prompt_ids({language:o,task:h,no_timestamps:!r});e.length>0&&(t.forced_decoder_ids=e)}let c=!Array.isArray(e);c&&(e=[e]);let f=this.processor.feature_extractor.config.chunk_length/this.model.config.max_source_positions,d=this.processor.feature_extractor.config.hop_length,p=this.processor.feature_extractor.config.sampling_rate,m=await eb(e,p),g=[];for(let e of m){let o=[];if(n>0){if(null===s)s=n/6;else if(n<=s)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let t=p*n,r=p*s,i=t-2*r,a=0;for(;a=e.length;o.push({stride:[n.length,l?0:r,h?0:r],input_features:s.input_features,is_last:h}),a+=i}}else o=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(let e of o){t.num_frames=Math.floor(e.stride[0]/d);let n=await this.model.generate(e.input_features,t);"word"===r?(e.tokens=n.sequences[0],e.token_timestamps=n.token_timestamps.tolist()[0].map(e=>(0,u.NM)(e,2))):e.tokens=n[0],e.stride=e.stride.map(e=>e/p),null!==i&&i(e)}let[l,h]=this.tokenizer._decode_asr(o,{time_precision:f,return_timestamps:r,force_full_sequences:a});g.push({text:l,...h})}return c?g[0]:g}}class eL extends ex{constructor(e){super(e)}async _call(e,t={}){let r=Array.isArray(e),n=await ey(e),{pixel_values:i}=await this.processor(n),a=[];for(let e of i){e.dims=[1,...e.dims];let r=await this.model.generate(e,t),n=this.tokenizer.batch_decode(r,{skip_special_tokens:!0}).map(e=>({generated_text:e.trim()}));a.push(n)}return r?a:a[0]}}class eN extends ex{constructor(e){super(e)}async _call(e,{topk:t=1}={}){let r=Array.isArray(e),n=await ey(e),{pixel_values:i}=await this.processor(n),a=await this.model({pixel_values:i}),s=this.model.config.id2label,o=[];for(let e of a.logits){let r=(0,u.em)((0,u.XA)(e.data),t).map(e=>({label:s[e[0]],score:e[1]}));1===t?o.push(...r):o.push(r)}return r||1===t?o:o[0]}}class eR extends ex{constructor(e){super(e),this.subtasks_mapping={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"}}async _call(e,{threshold:t=.5,mask_threshold:r=.5,overlap_mask_area_threshold:n=.8,label_ids_to_fuse:i=null,target_sizes:a=null,subtask:s=null}={}){if(Array.isArray(e)&&1!==e.length)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let o=await ey(e),l=o.map(e=>[e.height,e.width]),{pixel_values:h,pixel_mask:u}=await this.processor(o),c=await this.model({pixel_values:h,pixel_mask:u}),f=null;if(null!==s)f=this.subtasks_mapping[s];else for(let[e,t]of Object.entries(this.subtasks_mapping))if(t in this.processor.feature_extractor){f=this.processor.feature_extractor[t].bind(this.processor.feature_extractor),s=e;break}let d=this.model.config.id2label,p=[];if("panoptic"===s||"instance"===s){let e=f(c,t,r,n,i,a??l)[0],s=e.segmentation;for(let t of e.segments_info){let e=new Uint8ClampedArray(s.data.length);for(let r=0;rr.replace("{}",e)),s=this.tokenizer(a,{padding:"siglip"!==this.model.config.model_type||"max_length",truncation:!0}),{pixel_values:o}=await this.processor(i),l=await this.model({...s,pixel_values:o}),h="siglip"===this.model.config.model_type?e=>e.sigmoid().data:e=>(0,u.XA)(e.data),c=[];for(let e of l.logits_per_image){let r=[...h(e)].map((e,r)=>({score:e,label:t[r]}));r.sort((e,t)=>t.score-e.score),c.push(r)}return n?c:c[0]}}class eq extends ex{constructor(e){super(e)}async _call(e,{threshold:t=.9,percentage:r=!1}={}){let n=Array.isArray(e);if(n&&1!==e.length)throw Error("Object detection pipeline currently only supports a batch size of 1.");let i=await ey(e),a=r?null:i.map(e=>[e.height,e.width]),{pixel_values:s,pixel_mask:o}=await this.processor(i),l=await this.model({pixel_values:s,pixel_mask:o}),h=this.processor.feature_extractor.post_process_object_detection(l,t,a),u=this.model.config.id2label,c=h.map(e=>e.boxes.map((t,n)=>({score:e.scores[n],label:u[e.classes[n]],box:ev(t,!r)})));return n?c:c[0]}}class eX extends ex{constructor(e){super(e)}async _call(e,t,{threshold:r=.1,topk:n=null,percentage:i=!1}={}){let a=Array.isArray(e),s=await ey(e),o=this.tokenizer(t,{padding:!0,truncation:!0}),l=await this.processor(s),h=[];for(let e=0;e({score:d.scores[r],label:t[d.classes[r]],box:ev(e,!i)})).sort((e,t)=>t.score-e.score);null!==n&&(p=p.slice(0,n)),h.push(p)}return a?h:h[0]}}class eV extends ex{constructor(e){super(e)}async _call(e,t,r={}){let n=(await ey(e))[0],{pixel_values:i}=await this.processor(n),a=`${t}`,s=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,o=await this.model.generate(i,{...r,decoder_input_ids:s,max_length:this.model.config.decoder.max_position_embeddings}),l=this.tokenizer.batch_decode(o)[0].match(/(.*?)<\/s_answer>/),h=null;return l&&l.length>=2&&(h=l[1].trim()),[{answer:h}]}}class eD extends ex{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _call(e,{speaker_embeddings:t=null}={}){return this.processor?this._call_text_to_spectrogram(e,{speaker_embeddings:t}):this._call_text_to_waveform(e)}async _call_text_to_waveform(e){let t=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:r}=await this.model(t),n=this.model.config.sampling_rate;return{audio:r.data,sampling_rate:n}}async _call_text_to_spectrogram(e,{speaker_embeddings:t}){if(this.vocoder||(console.log("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await o.$Sz.from_pretrained(this.DEFAULT_VOCODER_ID,{quantized:!1})),("string"==typeof t||t instanceof URL)&&(t=new Float32Array(await (await fetch(t)).arrayBuffer())),t instanceof Float32Array)t=new c.es("float32",t,[1,t.length]);else if(!(t instanceof c.es))throw Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");let{input_ids:r}=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:n}=await this.model.generate_speech(r,t,{vocoder:this.vocoder}),i=this.processor.feature_extractor.config.sampling_rate;return{audio:n.data,sampling_rate:i}}}class eG extends ex{constructor(e){super(e)}async _call(e){let t=await ey(e),r=await this.processor(t),n=await this.model(r),i=[];for(let e of n.reconstruction){let t=e.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");i.push(w.fromTensor(t))}return i.length>1?i:i[0]}}class eH extends ex{constructor(e){super(e)}async _call(e){let t=await ey(e),r=await this.processor(t),{predicted_depth:n}=await this.model(r),i=[];for(let e=0;e1?i:i[0]}}let eW=Object.freeze({"text-classification":{tokenizer:s.t2,pipeline:eE,model:o.o$X,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{tokenizer:s.t2,pipeline:ek,model:o.OjJ,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{tokenizer:s.t2,pipeline:eA,model:o.wiU,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{tokenizer:s.t2,pipeline:ez,model:o.t78,default:{model:"Xenova/bert-base-uncased"},type:"text"},summarization:{tokenizer:s.t2,pipeline:eM,model:o.Kf0,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{tokenizer:s.t2,pipeline:eI,model:o.Kf0,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{tokenizer:s.t2,pipeline:eC,model:o.Kf0,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{tokenizer:s.t2,pipeline:eS,model:o.Hqk,default:{model:"Xenova/gpt2"},type:"text"},"zero-shot-classification":{tokenizer:s.t2,pipeline:e$,model:o.o$X,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:eU,model:o.K2m,processor:ew,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{tokenizer:s.t2,pipeline:eF,model:o.$Sz,processor:ew,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{tokenizer:s.t2,pipeline:ej,model:[o.hZO,o.ENH],processor:ew,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{tokenizer:s.t2,pipeline:eD,model:[o.z6E,o.lbf],processor:[ew,null],default:{model:"Xenova/speecht5_tts"},type:"text"},"image-to-text":{tokenizer:s.t2,pipeline:eL,model:o.tLj,processor:ew,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:eN,model:o.En$,processor:ew,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:eR,model:[o.U$$,o.$Bv],processor:ew,default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"zero-shot-image-classification":{tokenizer:s.t2,pipeline:eP,model:o.$Sz,processor:ew,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:eq,model:o.Zn,processor:ew,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{tokenizer:s.t2,pipeline:eX,model:o.LdW,processor:ew,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{tokenizer:s.t2,pipeline:eV,model:o.DcG,processor:ew,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:eG,model:o.S2d,processor:ew,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:eH,model:o.hY6,processor:ew,default:{model:"Xenova/dpt-large"},type:"image"},"feature-extraction":{tokenizer:s.t2,pipeline:eT,model:o.$Sz,default:{model:"Xenova/all-MiniLM-L6-v2"},type:"text"},"image-feature-extraction":{processor:ew,pipeline:eB,model:[o.IFL,o.$Sz],default:{model:"Xenova/vit-base-patch16-224-in21k"},type:"image"}}),eK=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});async function eJ(e,t=null,{quantized:r=!0,progress_callback:n=null,config:i=null,cache_dir:a=null,local_files_only:s=!1,revision:o="main"}={}){let h=eW[(e=eK[e]??e).split("_",1)[0]];if(!h)throw Error(`Unsupported pipeline: ${e}. Must be one of [${Object.keys(eW)}]`);t||(t=h.default.model,console.log(`No model specified. Using default model: "${t}".`));let u=new Map([["tokenizer",h.tokenizer],["model",h.model],["processor",h.processor]]),c=await eY(u,t,{quantized:r,progress_callback:n,config:i,cache_dir:a,local_files_only:s,revision:o});return c.task=e,(0,l.T2)(n,{status:"ready",task:e,model:t}),new h.pipeline(c)}async function eY(e,t,r){let n=Object.create(null),i=[];for(let[a,s]of e.entries()){let e;s&&(e=Array.isArray(s)?new Promise(async(e,n)=>{let i;for(let n of s){if(null===n){e(null);return}try{e(await n.from_pretrained(t,r));return}catch(e){i=e}}n(i)}):s.from_pretrained(t,r),n[a]=e,i.push(e))}for(let[e,t]of(await Promise.all(i),Object.entries(n)))n[e]=await t;return n}r(16)},761:function(e,t,r){"use strict";function n(e,t){e&&e(t)}function i(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))}function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}r.d(t,{$2:function(){return i},Ag:function(){return s},Gg:function(){return h},O7:function(){return d},Sw:function(){return c},T2:function(){return n},Wy:function(){return l},eG:function(){return f},fU:function(){return o},hr:function(){return a},hs:function(){return p},jg:function(){return u}});let s=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}_call(...e){throw Error("Must implement _call method in subclass")}};function o(e){return e?.prototype?.__proto__?.constructor?.name==="TypedArray"}function l(e){return Number.isInteger(e)||"bigint"==typeof e}function h(e){return null!=e}function u(e){let t=[],r=e;for(;Array.isArray(r);)t.push(r.length),r=r[0];return t}function c(e,t,r){let n=e[t];if(void 0!==n)return delete e[t],n;if(void 0===r)throw Error(`Key ${t} does not exist in object.`);return r}function f(...e){return Array.prototype.concat.apply([],e)}function d(...e){return e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[e,t])))}function p(e,t){return Math.abs((e+t)%(2*t)-t)}},1510:function(e,t,r){"use strict";r.d(t,{GA:function(){return i},Z3:function(){return n},pQ:function(){return s}});class n{constructor(e=(e,t)=>e>t){this._heap=[],this._comparator=e}get size(){return this._heap.length}isEmpty(){return 0===this.size}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(let t of e)this._heap.push(t),this._siftUp();return this.size}pop(){let e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._siftDown(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._siftDown(),t}_parent(e){return(e+1>>>1)-1}_left(e){return(e<<1)+1}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){let r=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=r}_siftUp(){let e=this.size-1;for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_siftDown(){let e=0;for(;this._left(e)[]),this.endNodes=Array.from({length:this.len+1},()=>[]);let n=new o(this.bosTokenId,0,0,0,0),i=new o(this.eosTokenId,1,this.len,0,0);this.nodes.push(n.clone()),this.nodes.push(i.clone()),this.beginNodes[this.len].push(i),this.endNodes[0].push(n)}insert(e,t,r,n){let i=new o(n,this.nodes.length,e,t,r);this.beginNodes[e].push(i),this.endNodes[e+t].push(i),this.nodes.push(i)}viterbi(){let e=this.len,t=0;for(;t<=e;){if(0==this.beginNodes[t].length)return[];for(let e of this.beginNodes[t]){e.prev=null;let r=0,n=null;for(let i of this.endNodes[t]){let t=i.backtraceScore+e.score;(null===n||t>r)&&(n=i.clone(),r=t)}if(null===n)return[];e.prev=n,e.backtraceScore=r}++t}let r=[],n=this.beginNodes[e][0].prev;if(null===n)return[];let i=n.clone();for(;null!==i.prev;)r.push(i.clone()),i=i.clone().prev.clone();return r.reverse(),r}piece(e){return this.sentence.slice(e.pos,e.pos+e.length)}tokens(){return this.viterbi().map(e=>this.piece(e))}tokenIds(){return this.viterbi().map(e=>e.tokenId)}}class o{constructor(e,t,r,n,i){this.tokenId=e,this.nodeId=t,this.pos=r,this.length=n,this.score=i,this.prev=null,this.backtraceScore=0}clone(){let e=new o(this.tokenId,this.nodeId,this.pos,this.length,this.score);return e.prev=this.prev,e.backtraceScore=this.backtraceScore,e}}},5774:function(e,t,r){"use strict";r.d(t,{AE:function(){return g},C9:function(){return l},CJ:function(){return m},E:function(){return o},GU:function(){return u},Jj:function(){return d},Jm:function(){return a},Pg:function(){return c},Z4:function(){return w},aP:function(){return _},dZ:function(){return h},ez:function(){return p},jF:function(){return f}}),r(2414);var n=r(761),i=r(8709);class a extends n.Ag{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){for(let r of t)this.processors.forEach(t=>t(e,r))}[Symbol.iterator](){return this.processors.values()}}class s extends n.Ag{_call(e,t){throw Error("`_call` should be implemented in a subclass")}}class o extends s{constructor(e){super(),this.force_token_map=Object.fromEntries(e??[])}_call(e,t){let r=this.force_token_map[e.length];return(0,n.Gg)(r)&&(t.data.fill(-1/0),t.data[r]=0),t}}class l extends s{constructor(e){super(),this.bos_token_id=e}_call(e,t){return 1===e.length&&(t.data.fill(-1/0),t.data[this.bos_token_id]=0),t}}class h extends s{constructor(e,t){super(),this.max_length=e,this.forced_eos_token_id=t}_call(e,t){}}class u extends s{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){if(e.length===this.begin_index)for(let e of this.begin_suppress_tokens)t.data[e]=-1/0;return t}}class c extends s{constructor(e){super(),this.eos_token_id=e.eos_token_id,this.no_timestamps_token_id=e.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=(e.forced_decoder_ids||[]).length+2,e.forced_decoder_ids.slice(-1)[0][1]===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){let r=t.data;if(r[this.no_timestamps_token_id]=-1/0,e.length===this.begin_index-1)return r.fill(-1/0),r[this.timestamp_begin]=0,t;let n=e.slice(this.begin_index),a=n.length>=1&&n[n.length-1]>=this.timestamp_begin,s=n.length<2||n[n.length-2]>=this.timestamp_begin;if(a&&(s?r.subarray(this.timestamp_begin).fill(-1/0):r.subarray(0,this.eos_token_id).fill(-1/0)),e.length===this.begin_index&&null!==this.max_initial_timestamp_index){let e=this.timestamp_begin+this.max_initial_timestamp_index;r.subarray(e+1).fill(-1/0)}let o=(0,i.CI)(r);return Math.log(o.subarray(this.timestamp_begin).map(Math.exp).reduce((e,t)=>e+t))>(0,i.Fp)(o.subarray(0,this.timestamp_begin))[0]&&r.subarray(0,this.timestamp_begin).fill(-1/0),t}}class f extends s{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,r=[];for(let n=0;n0&&(n=n.map(e=>e/this.generation_config.temperature)),n}randomSelect(e){let t=Math.random()*e.reduce((e,t)=>e+t,0);for(let r=0;r1)return new v(e);if(e.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${e.num_return_sequences}.`);return new y(e)}}class y extends w{sample(e,t=-1){let r=this.getLogits(e,t);return[[(0,i.Fp)(r)[1],0]]}}class b extends w{sample(e,t=-1){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let n=this.getLogits(e,t),a=(0,i.em)(n,r),s=(0,i.XA)(a.map(e=>e[1]));return Array.from({length:this.generation_config.num_beams},()=>{let e=this.randomSelect(s);return[a[e][0],Math.log(s[e])]})}}class v extends w{sample(e,t=-1){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let n=this.getLogits(e,t),a=(0,i.em)(n,r),s=(0,i.XA)(a.map(e=>e[1]));return Array.from({length:this.generation_config.num_beams},(e,t)=>[a[t][0],Math.log(s[t])])}}},911:function(e,t,r){"use strict";r.d(t,{hn:function(){return f},st:function(){return g},yM:function(){return _}});var n=r(7147),i=r(1418),a=r(319),s=r(851),o=r(761),l=r(357),h=r(9109).lW;globalThis.ReadableStream||(globalThis.ReadableStream=a.ReadableStream);class u{_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"};constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=n.existsSync(e),this.exists){this.status=200,this.statusText="OK";let t=n.statSync(e);this.headers.set("content-length",t.size.toString()),this.updateContentType();let r=this;this.body=new ReadableStream({start(e){r.arrayBuffer().then(t=>{e.enqueue(new Uint8Array(t)),e.close()})}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){let e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",this._CONTENT_TYPE_MAP[e]??"application/octet-stream")}clone(){let e=new u(this.filePath);return e.exists=this.exists,e.status=this.status,e.statusText=this.statusText,e.headers=new Headers(this.headers),e}async arrayBuffer(){return(await n.promises.readFile(this.filePath)).buffer}async blob(){return new Blob([await n.promises.readFile(this.filePath)],{type:this.headers.get("content-type")})}async text(){return await n.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}}function c(e,t=null){let r;try{r=new URL(e)}catch(e){return!1}return(!t||!!t.includes(r.hostname))&&("http:"===r.protocol||"https:"===r.protocol)}async function f(e){if(s.O.useFS&&!c(e))return new u(e);if(void 0===l||l?.release?.name!=="node")return fetch(e);{let t=!!l.env?.TESTING_REMOTELY,r=s.O.version,n=new Headers;if(n.set("User-Agent",`transformers.js/${r}; is_ci/${t};`),c(e,["huggingface.co","hf.co"])){let e=l.env?.HF_TOKEN??l.env?.HF_ACCESS_TOKEN;e&&n.set("Authorization",`Bearer ${e}`)}return fetch(e,{headers:n})}}let d={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"};class p{constructor(e){this.path=e}async match(e){let t=new u(i.join(this.path,e));return t.exists?t:void 0}async put(e,t){let r=h.from(await t.arrayBuffer()),a=i.join(this.path,e);try{await n.promises.mkdir(i.dirname(a),{recursive:!0}),await n.promises.writeFile(a,r)}catch(e){console.warn("An error occurred while writing the file to cache:",e)}}}async function m(e,...t){for(let r of t)try{let t=await e.match(r);if(t)return t}catch(e){continue}}async function g(e,t,r=!0,n={}){let i,a,l,h;if(!s.O.allowLocalModels){if(n.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`).");if(!s.O.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}if((0,o.T2)(n.progress_callback,{status:"initiate",name:e,file:t}),!i&&s.O.useBrowserCache){if("undefined"==typeof caches)throw Error("Browser cache is not available in this environment.");try{i=await caches.open("transformers-cache")}catch(e){console.warn("An error occurred while opening the browser cache:",e)}}if(!i&&s.O.useFSCache&&(i=new p(n.cache_dir??s.O.cacheDir)),!i&&s.O.useCustomCache){if(!s.O.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!s.O.customCache.match||!s.O.customCache.put)throw Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");i=s.O.customCache}let u=n.revision??"main",g=y(e,t),_=y(s.O.localModelPath,g),b=y(s.O.remoteHost,s.O.remotePathTemplate.replaceAll("{model}",e).replaceAll("{revision}",encodeURIComponent(u)),t),v="main"===u?g:y(e,u,t),x=i instanceof p?v:b,E=!1;i&&(l=await m(i,_,x));let k=void 0!==l;if(void 0===l){if(s.O.allowLocalModels){if(c(g)){if(n.local_files_only)throw Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${g}.`);if(!s.O.allowRemoteModels)throw Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${g}.`)}else try{l=await f(_),a=_}catch(e){console.warn(`Unable to load from local path "${_}": "${e}"`)}}if(void 0===l||404===l.status){if(n.local_files_only||!s.O.allowRemoteModels){if(!r)return null;throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${_}".`)}if(200!==(l=await f(b)).status)return function(e,t,r){if(!r)return null;let n=d[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${n}: "${t}".`)}(l.status,b,r);a=x}E=i&&"undefined"!=typeof Response&&l instanceof Response&&200===l.status}(0,o.T2)(n.progress_callback,{status:"download",name:e,file:t});let A={status:"progress",name:e,file:t};return n.progress_callback?k&&"undefined"!=typeof navigator&&/firefox/i.test(navigator.userAgent)?(h=new Uint8Array(await l.arrayBuffer()),(0,o.T2)(n.progress_callback,{...A,progress:100,loaded:h.length,total:h.length})):h=await w(l,e=>{(0,o.T2)(n.progress_callback,{...A,...e})}):h=new Uint8Array(await l.arrayBuffer()),E&&a&&await i.match(a)===void 0&&await i.put(a,new Response(h,{headers:l.headers})).catch(e=>{console.warn(`Unable to add response to browser cache: ${e}.`)}),(0,o.T2)(n.progress_callback,{status:"done",name:e,file:t}),h}async function _(e,t,r=!0,n={}){let i=await g(e,t,r,n);return null===i?{}:JSON.parse(new TextDecoder("utf-8").decode(i))}async function w(e,t){let r=e.headers.get("Content-Length");null===r&&console.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let n=parseInt(r??"0"),i=new Uint8Array(n),a=0,s=e.body.getReader();async function o(){let{done:e,value:r}=await s.read();if(e)return;let l=a+r.length;if(l>n){let e=new Uint8Array(n=l);e.set(i),i=e}return i.set(r,a),t({progress:(a=l)/n*100,loaded:a,total:n}),o()}return await o(),i}function y(...e){return(e=e.map((t,r)=>(r&&(t=t.replace(RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(RegExp("/$"),"")),t))).join("/")}},8709:function(e,t,r){"use strict";function n(e,[t,r,n],[i,a],s="bilinear",o=!1){let l=a/n,h=i/r,u=new e.constructor(i*a*t),c=r*n,f=i*a;for(let s=0;s=0;--e)i[e]=a,n[e]=t[r[e]],a*=n[e];let a=r.map((e,t)=>i[r.indexOf(t)]),s=new e.constructor(e.length);for(let r=0;r=0;--e)n+=i%t[e]*a[e],i=Math.floor(i/t[e]);s[n]=e[r]}return[s,n]}function a(e){let t=h(e)[0],r=e.map(e=>Math.exp(e-t)),n=r.reduce((e,t)=>e+t,0);return r.map(e=>e/n)}function s(e){return a(e).map(e=>Math.log(e))}function o(e,t=0){return e=Array.from(e).map((e,t)=>[t,e]).sort((e,t)=>t[1]-e[1]),null!==t&&t>0&&(e=e.slice(0,t)),e}function l(e){if(0===e.length)throw Error("Array must not be empty");let t=e[0],r=0;for(let n=1;nt&&(t=e[n],r=n);return[Number(t),r]}function u(e){return e>0&&(e&e-1)==0}r.d(t,{CI:function(){return s},Fp:function(){return h},NM:function(){return m},Nq:function(){return n},VV:function(){return l},XA:function(){return a},eT:function(){return g},em:function(){return o},nu:function(){return i},qC:function(){return p},vw:function(){return d}});class c{constructor(e){if(this.size=0|e,this.size<=1||!u(this.size))throw Error("FFT size must be a power of two larger than 1");this._csize=e<<1,this.table=new Float64Array(2*this.size);for(let e=0;ee;e<<=1)++t;this._width=t%2==0?t-1:t,this._bitrev=new Int32Array(1<>>t&3)<>>1);for(let t=0;t>>1]=e[t];return r}toComplexArray(e,t){let r=t||this.createComplexArray();for(let t=0;t>>1],r[t+1]=0;return r}completeSpectrum(e){let t=this._csize,r=t>>>1;for(let n=2;n>=2;s>=2;s>>=2){let t=(o=a/s<<1)>>>2;for(n=0;n>>1,s>>>1)}else for(n=0,i=0;n>>1,s>>>1,r)}for(s>>=2;s>=2;s>>=2){let t=(o=a/s<<1)>>>2;for(n=0;n>1;++t){let r=(t+1-e)**2/2,n=Math.sqrt(o**2+l**2)**r,s=r*Math.atan2(l,o),h=2*t;i[h]=n*Math.cos(s),i[h+1]=n*Math.sin(s),a[h]=i[h],a[h+1]=-i[h+1]}this._slicedChirpBuffer=i.subarray(t,r),this._f=new c(n>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,t,r){let n=this._buffer1,i=this._buffer2,a=this._outBuffer1,s=this._outBuffer2,o=this._chirpBuffer,l=this._slicedChirpBuffer,h=this._a;if(r)for(let e=0;e>1];n[e]=i*l[e],n[r]=i*l[r]}else for(let e=0;e=e.length&&(i=2*(e.length-1)-i),n[a++]=e[i]}n.sort(),r[t]=n[i]}return r}function m(e,t){let r=Math.pow(10,t);return Math.round(e*r)/r}function g(e){let t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}},2414:function(e,t,r){"use strict";r.d(t,{J6:function(){return g},Ks:function(){return _},d3:function(){return d},e:function(){return y},es:function(){return o},f3:function(){return m},kn:function(){return p},r6:function(){return w},sX:function(){return l},v6:function(){return h}});var n=r(1542),i=r(8709);let a=Object.freeze({float32:Float32Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array}),s=n.ONNX.Tensor;class o{dims;type;data;size;constructor(...e){return e[0]instanceof s?Object.assign(this,e[0]):Object.assign(this,new s(e[0],e[1],e[2])),new Proxy(this,{get:(e,t)=>{if("string"==typeof t){let r=Number(t);if(Number.isInteger(r))return e._getitem(r)}return e[t]},set:(e,t,r)=>e[t]=r})}*[Symbol.iterator](){let[e,...t]=this.dims;if(t.length>0){let r=t.reduce((e,t)=>e*t);for(let n=0;n0))return new o(this.type,[this.data[e]],r);{let t=r.reduce((e,t)=>e*t);return this._subarray(e,t,r)}}indexOf(e){for(let t=0;te*t))throw Error(`cannot reshape array of size ${r} into shape (${t})`);let n=e;for(let e=t.length-1;e>=0;e--)n=n.reduce((r,n)=>{let i=r[r.length-1];return i.lengthi[1])throw Error(`Invalid slice: ${i}`);let e=[Math.max(i[0],0),Math.min(i[1],this.dims[n])];r.push(e),t.push(e[1]-e[0])}else throw Error(`Invalid slice: ${i}`)}let n=r.map(([e,t])=>t-e),i=n.reduce((e,t)=>e*t),a=new this.data.constructor(i),s=this.stride();for(let e=0;e=0;--i){let e=n[i];t+=(a%e+r[i][0])*s[i],a=Math.floor(a/e)}a[e]=this.data[t]}return new o(this.type,a,t)}permute(...e){return function(e,t){let[r,n]=(0,i.nu)(e.data,e.dims,t);return new o(e.type,r,n)}(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,t=!1){return this.norm(1,e,t)}norm(e="fro",t=null,r=!1){if("fro"===e)e=2;else if("string"==typeof e)throw Error(`Unsupported norm: ${e}`);if(null===t){let t=this.data.reduce((t,r)=>t+r**e,0)**(1/e);return new o(this.type,[t],[])}t=f(t,this.dims.length);let n=this.dims.slice();n[t]=1;let i=new this.data.constructor(this.data.length/this.dims[t]);for(let r=0;r=0;--e){let r=this.dims[e];e!==t&&(a+=i%r*s,s*=n[e]),i=Math.floor(i/r)}i[a]+=this.data[r]**e}if(1!==e)for(let t=0;t=0;--r){let e=this.dims[r];r!==t&&(n+=i%e*a,a*=this.dims[r]),i=Math.floor(i/e)}this.data[e]/=r.data[n]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return function(e){let t=Array(e.length);for(let r=e.length-1,n=1;r>=0;--r)t[r]=n,n*=e[r];return t}(this.dims)}squeeze(e=null){return new o(this.type,this.data,u(this.dims,e))}squeeze_(e=null){return this.dims=u(this.dims,e),this}unsqueeze(e=null){return new o(this.type,this.data,c(this.dims,e))}unsqueeze_(e=null){return this.dims=c(this.dims,e),this}flatten_(e=0,t=-1){t=(t+this.dims.length)%this.dims.length;let r=this.dims.slice(0,e),n=this.dims.slice(e,t+1),i=this.dims.slice(t+1);return this.dims=[...r,n.reduce((e,t)=>e*t,1),...i],this}flatten(e=0,t=-1){return this.clone().flatten_(e,t)}view(...e){let t=-1;for(let r=0;rn!==t?e*r:e,1);e[t]=this.data.length/r}return new o(this.type,this.data,e)}neg_(){for(let e=0;e1!==e):"number"==typeof t?1===e[t]&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((e,r)=>1!==e||!t.includes(r))),e}function c(e,t){return t=f(t,e.length+1),(e=e.slice()).splice(t,0,1),e}function f(e,t,r=null){if(e<-t||e>=t)throw Error(`IndexError: index ${e} is out of bounds for dimension${null===r?"":" "+r} with size ${t}`);return e<0&&(e=(e%t+t)%t),e}function d(e,t=0){t=f(t,e[0].dims.length);let r=e[0].dims.slice();r[t]=e.reduce((e,r)=>e+r.dims[t],0);let n=r.reduce((e,t)=>e*t,1),i=new e[0].data.constructor(n),a=e[0].type;if(0===t){let t=0;for(let r of e)i.set(r.data,t),t+=r.data.length}else{let n=0;for(let a=0;a=0;--i){let e=s.dims[i],h=o%e;i===t&&(h+=n),a+=h*l,l*=r[i],o=Math.floor(o/e)}i[a]=s.data[e]}n+=s.dims[t]}}return new o(a,i,r)}function p(e,t=0){return d(e.map(e=>e.unsqueeze(t)),t)}function m(e,t=null,r=1,n=!1){if(null===t){let t=e.data.reduce((e,t)=>e+t,0)/e.data.length,n=Math.sqrt(e.data.reduce((e,r)=>e+(r-t)**2,0)/(e.data.length-r)),i=new o(e.type,[t],[]);return[new o(e.type,[n],[]),i]}t=f(t,e.dims.length);let i=g(e,t,n),a=e.dims.slice();a[t]=1;let s=new e.data.constructor(e.data.length/e.dims[t]);for(let r=0;r=0;--i){let r=e.dims[i];i!==t&&(n+=s%r*o,o*=a[i]),s=Math.floor(s/r)}s[n]+=(e.data[r]-i.data[n])**2}for(let n=0;ne+t,0);return new o(e.type,[t/e.data.length],[])}t=f(t,e.dims.length);let n=e.dims.slice();n[t]=1;let i=new e.data.constructor(e.data.length/e.dims[t]);for(let r=0;r=0;--i){let r=e.dims[i];i!==t&&(a+=s%r*o,o*=n[i]),s=Math.floor(s/r)}i[a]+=e.data[r]}if(1!==e.dims[t])for(let r=0;r0||l>0;)switch(h.push(s-1),u.push(l-1),a[s][l].item()){case 0:--s,--l;break;case 1:--s;break;case 2:--l;break;default:throw Error(`Internal error in dynamic time warping. Unexpected trace[${s}, ${l}]. Please file a bug report.`)}return h.reverse(),u.reverse(),[h,u]}function w(e){var t;return new o("int64",new BigInt64Array((t=e.dims).reduce((e,t)=>e*t,1)).fill(1n),t)}function y(e,t){if(2!==e.dims.length)throw Error("The tensor must have 2 dimensions");if(e.dims.at(-1)%8!=0)throw Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(t))throw Error("The precision must be either 'binary' or 'ubinary'");let r="binary"===t,n=r?Int8Array:Uint8Array,i=e.data,a=new n(i.length/8);for(let e=0;e0?1:0,n=Math.floor(e/8),s=e%8;a[n]|=t<<7-s,r&&0===s&&(a[n]-=128)}return new o(r?"int8":"uint8",a,[e.dims[0],e.dims[1]/8])}}}]); \ No newline at end of file