@huggingface/transformers
Version:
State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
1 lines • 843 kB
JavaScript
var e,t,n={"./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.jsep.wasm":(e,t,n)=>{e.exports=n.p+"ort-wasm-simd-threaded.jsep.wasm"},"./node_modules/onnxruntime-web/dist/ort.bundle.min.mjs?46eb":(e,t,n)=>{e.exports=n.p+"ort.bundle.min.mjs"},"?2ce3":()=>{},"?7a2c":()=>{},"?a42a":()=>{},"?2b25":()=>{},"?569f":()=>{},"?3f59":()=>{},"?154a":()=>{},"./node_modules/@huggingface/jinja/dist/index.js":(e,t,n)=>{n.r(t),n.d(t,{Environment:()=>J,Interpreter:()=>Y,Template:()=>te,parse:()=>O,tokenize:()=>u});var r=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",BooleanLiteral:"BooleanLiteral",NullLiteral:"NullLiteral",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",EndSet:"EndSet",EndIf:"EndIf",ElseIf:"ElseIf",EndFor:"EndFor",And:"And",Or:"Or",Not:"UnaryOperator",Macro:"Macro",EndMacro:"EndMacro"}),s=Object.freeze({set:r.Set,for:r.For,in:r.In,is:r.Is,if:r.If,else:r.Else,endset:r.EndSet,endif:r.EndIf,elif:r.ElseIf,endfor:r.EndFor,and:r.And,or:r.Or,not:r.Not,"not in":r.NotIn,macro:r.Macro,endmacro:r.EndMacro,true:r.BooleanLiteral,false:r.BooleanLiteral,none:r.NullLiteral,True:r.BooleanLiteral,False:r.BooleanLiteral,None:r.NullLiteral}),i=class{constructor(e,t){this.value=e,this.type=t}};function o(e){return/\w/.test(e)}function a(e){return/[0-9]/.test(e)}var l=[["{%",r.OpenStatement],["%}",r.CloseStatement],["{{",r.OpenExpression],["}}",r.CloseExpression],["(",r.OpenParen],[")",r.CloseParen],["{",r.OpenCurlyBracket],["}",r.CloseCurlyBracket],["[",r.OpenSquareBracket],["]",r.CloseSquareBracket],[",",r.Comma],[".",r.Dot],[":",r.Colon],["|",r.Pipe],["<=",r.ComparisonBinaryOperator],[">=",r.ComparisonBinaryOperator],["==",r.ComparisonBinaryOperator],["!=",r.ComparisonBinaryOperator],["<",r.ComparisonBinaryOperator],[">",r.ComparisonBinaryOperator],["+",r.AdditiveBinaryOperator],["-",r.AdditiveBinaryOperator],["*",r.MultiplicativeBinaryOperator],["/",r.MultiplicativeBinaryOperator],["%",r.MultiplicativeBinaryOperator],["=",r.Equals]],d=new Map([["n","\n"],["t","\t"],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function u(e,t={}){const n=[],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);let c=0;const p=e=>{let t="";for(;e(u[c]);)if("\\"!==u[c]){if(t+=u[c++],c>=u.length)throw new SyntaxError("Unexpected end of input")}else{if(++c,c>=u.length)throw new SyntaxError("Unexpected end of input");const e=u[c++],n=d.get(e);if(void 0===n)throw new SyntaxError(`Unexpected escaped character: ${e}`);t+=n}return t};e:for(;c<u.length;){const e=n.at(-1)?.type;if(void 0===e||e===r.CloseStatement||e===r.CloseExpression){let e="";for(;c<u.length&&("{"!==u[c]||"%"!==u[c+1]&&"{"!==u[c+1]);)e+=u[c++];if(e.length>0){n.push(new i(e,r.Text));continue}}p((e=>/\s/.test(e)));const t=u[c];if("-"===t||"+"===t){const e=n.at(-1)?.type;if(e===r.Text||void 0===e)throw new SyntaxError(`Unexpected character: ${t}`);switch(e){case r.Identifier:case r.NumericLiteral:case r.BooleanLiteral:case r.NullLiteral:case r.StringLiteral:case r.CloseParen:case r.CloseSquareBracket:break;default:{++c;const e=p(a);n.push(new i(`${t}${e}`,e.length>0?r.NumericLiteral:r.UnaryOperator));continue}}}for(const[e,t]of l){if(u.slice(c,c+e.length)===e){n.push(new i(e,t)),c+=e.length;continue e}}if("'"!==t&&'"'!==t)if(a(t)){const e=p(a);n.push(new i(e,r.NumericLiteral))}else{if(!o(t))throw new SyntaxError(`Unexpected character: ${t}`);{const e=p(o),t=Object.hasOwn(s,e)?s[e]:r.Identifier;t===r.In&&n.at(-1)?.type===r.Not?(n.pop(),n.push(new i("not in",r.NotIn))):n.push(new i(e,t))}}else{++c;const e=p((e=>e!==t));n.push(new i(e,r.StringLiteral)),++c}}return n}var c=class{type="Statement"},p=class extends c{constructor(e){super(),this.body=e}type="Program"},m=class extends c{constructor(e,t,n){super(),this.test=e,this.body=t,this.alternate=n}type="If"},h=class extends c{constructor(e,t,n,r){super(),this.loopvar=e,this.iterable=t,this.body=n,this.defaultBlock=r}type="For"},f=class extends c{constructor(e,t,n){super(),this.assignee=e,this.value=t,this.body=n}type="Set"},_=class extends c{constructor(e,t,n){super(),this.name=e,this.args=t,this.body=n}type="Macro"},g=class extends c{type="Expression"},w=class extends g{constructor(e,t,n){super(),this.object=e,this.property=t,this.computed=n}type="MemberExpression"},b=class extends g{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},y=class extends g{constructor(e){super(),this.value=e}type="Identifier"},x=class extends g{constructor(e){super(),this.value=e}type="Literal"},M=class extends x{type="NumericLiteral"},v=class extends x{type="StringLiteral"},T=class extends x{type="BooleanLiteral"},k=class extends x{type="NullLiteral"},$=class extends x{type="ArrayLiteral"},P=class extends x{type="TupleLiteral"},S=class extends x{type="ObjectLiteral"},C=class extends g{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}type="BinaryExpression"},E=class extends g{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},F=class extends g{constructor(e,t){super(),this.iterable=e,this.test=t}type="SelectExpression"},I=class extends g{constructor(e,t,n){super(),this.operand=e,this.negate=t,this.test=n}type="TestExpression"},A=class extends g{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},z=class extends g{constructor(e=void 0,t=void 0,n=void 0){super(),this.start=e,this.stop=t,this.step=n}type="SliceExpression"},L=class extends g{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"};function O(e){const t=new p([]);let n=0;function s(t,r){const s=e[n++];if(!s||s.type!==t)throw new Error(`Parser Error: ${r}. ${s.type} !== ${t}.`);return s}function i(){switch(e[n].type){case r.Text:return new v(s(r.Text,"Expected text token").value);case r.OpenStatement:return function(){let t;switch(s(r.OpenStatement,"Expected opening statement token"),e[n].type){case r.Set:++n,t=function(){const t=u();if(a(r.Equals)){++n;const e=u();return new f(t,e,[])}{const o=[];for(s(r.CloseStatement,"Expected %} token");e[n]?.type!==r.OpenStatement||e[n+1]?.type!==r.EndSet;){const e=i();o.push(e)}return s(r.OpenStatement,"Expected {% token"),s(r.EndSet,"Expected endset token"),new f(t,null,o)}}(),s(r.CloseStatement,"Expected closing statement token");break;case r.If:++n,t=l(),s(r.OpenStatement,"Expected {% token"),s(r.EndIf,"Expected endif token"),s(r.CloseStatement,"Expected %} token");break;case r.Macro:++n,t=function(){const e=G();if("Identifier"!==e.type)throw new SyntaxError("Expected identifier following macro statement");const t=B();s(r.CloseStatement,"Expected closing statement token");const n=[];for(;o(r.OpenStatement,r.EndMacro);)n.push(i());return new _(e,t,n)}(),s(r.OpenStatement,"Expected {% token"),s(r.EndMacro,"Expected endmacro token"),s(r.CloseStatement,"Expected %} token");break;case r.For:++n,t=function(){const e=d(!0);if(!(e instanceof y||e instanceof P))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${e.type} instead`);s(r.In,"Expected `in` keyword following loop variable");const t=u();s(r.CloseStatement,"Expected closing statement token");const l=[];for(;o(r.OpenStatement,r.EndFor)&&o(r.OpenStatement,r.Else);)l.push(i());const c=[];if(a(r.OpenStatement,r.Else))for(++n,++n,s(r.CloseStatement,"Expected closing statement token");o(r.OpenStatement,r.EndFor);)c.push(i());return new h(e,t,l,c)}(),s(r.OpenStatement,"Expected {% token"),s(r.EndFor,"Expected endfor token"),s(r.CloseStatement,"Expected %} token");break;default:throw new SyntaxError(`Unknown statement type: ${e[n].type}`)}return t}();case r.OpenExpression:return function(){s(r.OpenExpression,"Expected opening expression token");const e=u();return s(r.CloseExpression,"Expected closing expression token"),e}();default:throw new SyntaxError(`Unexpected token type: ${e[n].type}`)}}function o(...t){return n+t.length<=e.length&&t.some(((t,r)=>t!==e[n+r].type))}function a(...t){return n+t.length<=e.length&&t.every(((t,r)=>t===e[n+r].type))}function l(){const t=u();s(r.CloseStatement,"Expected closing statement token");const o=[],d=[];for(;e[n]?.type!==r.OpenStatement||e[n+1]?.type!==r.ElseIf&&e[n+1]?.type!==r.Else&&e[n+1]?.type!==r.EndIf;)o.push(i());if(e[n]?.type===r.OpenStatement&&e[n+1]?.type!==r.EndIf)if(++n,a(r.ElseIf))s(r.ElseIf,"Expected elseif token"),d.push(l());else for(s(r.Else,"Expected else token"),s(r.CloseStatement,"Expected closing statement token");e[n]?.type!==r.OpenStatement||e[n+1]?.type!==r.EndIf;)d.push(i());return new m(t,o,d)}function d(e=!1){const t=e?G:u,s=[t()],i=a(r.Comma);for(;i&&(++n,s.push(t()),a(r.Comma)););return i?new P(s):s[0]}function u(){return function(){const e=c();if(a(r.If)){++n;const t=c();if(a(r.Else)){++n;const r=c();return new m(t,[e],[r])}return new F(e,t)}return e}()}function c(){let t=g();for(;a(r.Or);){const r=e[n];++n;const s=g();t=new C(r,t,s)}return t}function g(){let t=x();for(;a(r.And);){const r=e[n];++n;const s=x();t=new C(r,t,s)}return t}function x(){let t;for(;a(r.Not);){const r=e[n];++n;const s=x();t=new A(r,s)}return t??function(){let t=O();for(;a(r.ComparisonBinaryOperator)||a(r.In)||a(r.NotIn);){const r=e[n];++n;const s=O();t=new C(r,t,s)}return t}()}function O(){let t=j();for(;a(r.AdditiveBinaryOperator);){const r=e[n];++n;const s=j();t=new C(r,t,s)}return t}function D(e){let t=new b(e,B());return t=R(t),a(r.OpenParen)&&(t=D(t)),t}function B(){s(r.OpenParen,"Expected opening parenthesis for arguments list");const e=function(){const e=[];for(;!a(r.CloseParen);){let t=u();if(a(r.Equals)){if(++n,!(t instanceof y))throw new SyntaxError("Expected identifier for keyword argument");const e=u();t=new L(t,e)}e.push(t),a(r.Comma)&&++n}return e}();return s(r.CloseParen,"Expected closing parenthesis for arguments list"),e}function N(){const e=[];let t=!1;for(;!a(r.CloseSquareBracket);)a(r.Colon)?(e.push(void 0),++n,t=!0):(e.push(u()),a(r.Colon)&&(++n,t=!0));if(0===e.length)throw new SyntaxError("Expected at least one argument for member/slice expression");if(t){if(e.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new z(...e)}return e[0]}function R(t){for(;a(r.Dot)||a(r.OpenSquareBracket);){const i=e[n];let o;++n;const a=i.type!==r.Dot;if(a)o=N(),s(r.CloseSquareBracket,"Expected closing square bracket");else if(o=G(),"Identifier"!==o.type)throw new SyntaxError("Expected identifier following dot operator");t=new w(t,o,a)}return t}function j(){let t=V();for(;a(r.MultiplicativeBinaryOperator);){const r=e[n];++n;const s=V();t=new C(r,t,s)}return t}function V(){let e=function(){let e=function(){const e=R(G());return a(r.OpenParen)?D(e):e}();for(;a(r.Pipe);){++n;let t=G();if(!(t instanceof y))throw new SyntaxError("Expected identifier for the filter");a(r.OpenParen)&&(t=D(t)),e=new E(e,t)}return e}();for(;a(r.Is);){++n;const t=a(r.Not);t&&++n;let s=G();if(s instanceof T?s=new y(s.value.toString()):s instanceof k&&(s=new y("none")),!(s instanceof y))throw new SyntaxError("Expected identifier for the test");e=new I(e,t,s)}return e}function G(){const t=e[n];switch(t.type){case r.NumericLiteral:return++n,new M(Number(t.value));case r.StringLiteral:return++n,new v(t.value);case r.BooleanLiteral:return++n,new T("true"===t.value.toLowerCase());case r.NullLiteral:return++n,new k(null);case r.Identifier:return++n,new y(t.value);case r.OpenParen:{++n;const t=d();if(e[n].type!==r.CloseParen)throw new SyntaxError(`Expected closing parenthesis, got ${e[n].type} instead`);return++n,t}case r.OpenSquareBracket:{++n;const e=[];for(;!a(r.CloseSquareBracket);)e.push(u()),a(r.Comma)&&++n;return++n,new $(e)}case r.OpenCurlyBracket:{++n;const e=new Map;for(;!a(r.CloseCurlyBracket);){const t=u();s(r.Colon,"Expected colon between key and value in object literal");const i=u();e.set(t,i),a(r.Comma)&&++n}return++n,new S(e)}default:throw new SyntaxError(`Unexpected token: ${t.type}`)}}for(;n<e.length;)t.body.push(i());return t}function D(e,t,n=1){void 0===t&&(t=e,e=0);const r=[];for(let s=e;s<t;s+=n)r.push(s);return r}function B(e,t,n,r=1){const s=Math.sign(r);s>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),n=(n??=e.length)<0?Math.max(e.length+n,0):Math.min(n,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),n=(n??=-1)<-1?Math.max(e.length+n,-1):Math.min(n,e.length-1));const i=[];for(let o=t;s*o<s*n;o+=r)i.push(e[o]);return i}function N(e){return e.replace(/\b\w/g,(e=>e.toUpperCase()))}var R=class{type="RuntimeValue";value;builtins=new Map;constructor(e=void 0){this.value=e}__bool__(){return new G(!!this.value)}},j=class extends R{type="NumericValue"},V=class extends R{type="StringValue";builtins=new Map([["upper",new K((()=>new V(this.value.toUpperCase())))],["lower",new K((()=>new V(this.value.toLowerCase())))],["strip",new K((()=>new V(this.value.trim())))],["title",new K((()=>new V(N(this.value))))],["length",new j(this.value.length)],["rstrip",new K((()=>new V(this.value.trimEnd())))],["lstrip",new K((()=>new V(this.value.trimStart())))],["split",new K((e=>{const t=e[0]??new Q;if(!(t instanceof V||t instanceof Q))throw new Error("sep argument must be a string or null");const n=e[1]??new j(-1);if(!(n instanceof j))throw new Error("maxsplit argument must be a number");let r=[];if(t instanceof Q){const e=this.value.trimStart();for(const{0:t,index:s}of e.matchAll(/\S+/g)){if(-1!==n.value&&r.length>=n.value&&void 0!==s){r.push(t+e.slice(s+t.length));break}r.push(t)}}else{if(""===t.value)throw new Error("empty separator");r=this.value.split(t.value),-1!==n.value&&r.length>n.value&&r.push(r.splice(n.value).join(t.value))}return new W(r.map((e=>new V(e))))}))]])},G=class extends R{type="BooleanValue"},q=class extends R{type="ObjectValue";__bool__(){return new G(this.value.size>0)}builtins=new Map([["get",new K((([e,t])=>{if(!(e instanceof V))throw new Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new Q}))],["items",new K((()=>new W(Array.from(this.value.entries()).map((([e,t])=>new W([new V(e),t]))))))]])},U=class extends q{type="KeywordArgumentsValue"},W=class extends R{type="ArrayValue";builtins=new Map([["length",new j(this.value.length)]]);__bool__(){return new G(this.value.length>0)}},H=class extends W{type="TupleValue"},K=class extends R{type="FunctionValue"},Q=class extends R{type="NullValue"},X=class extends R{type="UndefinedValue"},J=class{constructor(e){this.parent=e}variables=new Map([["namespace",new K((e=>{if(0===e.length)return new q(new Map);if(1!==e.length||!(e[0]instanceof q))throw new 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 K],["odd",e=>{if("NumericValue"!==e.type)throw new Error(`Cannot apply test "odd" to type: ${e.type}`);return e.value%2!=0}],["even",e=>{if("NumericValue"!==e.type)throw new 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],["none",e=>"NullValue"===e.type],["string",e=>"StringValue"===e.type],["number",e=>"NumericValue"===e.type],["integer",e=>"NumericValue"===e.type&&Number.isInteger(e.value)],["iterable",e=>"ArrayValue"===e.type||"StringValue"===e.type],["mapping",e=>"ObjectValue"===e.type],["lower",e=>{const t=e.value;return"StringValue"===e.type&&t===t.toLowerCase()}],["upper",e=>{const 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],["eq",(e,t)=>e.value===t.value]]);set(e,t){return this.declareVariable(e,Z(t))}declareVariable(e,t){if(this.variables.has(e))throw new 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 new Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new X}catch{return new X}}},Y=class{global;constructor(e){this.global=e??new J}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){const n=this.evaluate(e.left,t);switch(e.operator.value){case"and":return n.__bool__().value?this.evaluate(e.right,t):n;case"or":return n.__bool__().value?n:this.evaluate(e.right,t)}const r=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new G(n.value==r.value);case"!=":return new G(n.value!=r.value)}if(n instanceof X||r instanceof X)throw new Error("Cannot perform operation on undefined values");if(n instanceof Q||r instanceof Q)throw new Error("Cannot perform operation on null values");if(n instanceof j&&r instanceof j)switch(e.operator.value){case"+":return new j(n.value+r.value);case"-":return new j(n.value-r.value);case"*":return new j(n.value*r.value);case"/":return new j(n.value/r.value);case"%":return new j(n.value%r.value);case"<":return new G(n.value<r.value);case">":return new G(n.value>r.value);case">=":return new G(n.value>=r.value);case"<=":return new G(n.value<=r.value)}else if(n instanceof W&&r instanceof W){if("+"===e.operator.value)return new W(n.value.concat(r.value))}else if(r instanceof W){const t=void 0!==r.value.find((e=>e.value===n.value));switch(e.operator.value){case"in":return new G(t);case"not in":return new G(!t)}}if((n instanceof V||r instanceof V)&&"+"===e.operator.value)return new V(n.value.toString()+r.value.toString());if(n instanceof V&&r instanceof V)switch(e.operator.value){case"in":return new G(r.value.includes(n.value));case"not in":return new G(!r.value.includes(n.value))}if(n instanceof V&&r instanceof q)switch(e.operator.value){case"in":return new G(r.value.has(n.value));case"not in":return new G(!r.value.has(n.value))}throw new SyntaxError(`Unknown operator "${e.operator.value}" between ${n.type} and ${r.type}`)}evaluateArguments(e,t){const n=[],r=new Map;for(const s of e)if("KeywordArgumentExpression"===s.type){const e=s;r.set(e.key.value,this.evaluate(e.value,t))}else{if(r.size>0)throw new Error("Positional arguments must come before keyword arguments");n.push(this.evaluate(s,t))}return[n,r]}evaluateFilterExpression(e,t){const n=this.evaluate(e.operand,t);if("Identifier"===e.filter.type){const t=e.filter;if("tojson"===t.value)return new V(ee(n));if(n instanceof W)switch(t.value){case"list":return n;case"first":return n.value[0];case"last":return n.value[n.value.length-1];case"length":return new j(n.value.length);case"reverse":return new W(n.value.reverse());case"sort":return new W(n.value.sort(((e,t)=>{if(e.type!==t.type)throw new 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 new Error(`Cannot compare type: ${e.type}`)}})));case"join":return new V(n.value.map((e=>e.value)).join(""));case"string":return new V(ee(n));default:throw new Error(`Unknown ArrayValue filter: ${t.value}`)}else if(n instanceof V)switch(t.value){case"length":return new j(n.value.length);case"upper":return new V(n.value.toUpperCase());case"lower":return new V(n.value.toLowerCase());case"title":return new V(N(n.value));case"capitalize":return new V(n.value.charAt(0).toUpperCase()+n.value.slice(1));case"trim":return new V(n.value.trim());case"indent":return new V(n.value.split("\n").map(((e,t)=>0===t||0===e.length?e:" "+e)).join("\n"));case"join":case"string":return n;default:throw new Error(`Unknown StringValue filter: ${t.value}`)}else{if(n instanceof j){if("abs"===t.value)return new j(Math.abs(n.value));throw new Error(`Unknown NumericValue filter: ${t.value}`)}if(n instanceof q)switch(t.value){case"items":return new W(Array.from(n.value.entries()).map((([e,t])=>new W([new V(e),t]))));case"length":return new j(n.value.size);default:throw new Error(`Unknown ObjectValue filter: ${t.value}`)}}throw new Error(`Cannot apply filter "${t.value}" to type: ${n.type}`)}if("CallExpression"===e.filter.type){const r=e.filter;if("Identifier"!==r.callee.type)throw new Error(`Unknown filter: ${r.callee.type}`);const s=r.callee.value;if("tojson"===s){const[,e]=this.evaluateArguments(r.args,t),s=e.get("indent")??new Q;if(!(s instanceof j||s instanceof Q))throw new Error("If set, indent must be a number");return new V(ee(n,s.value))}if("join"===s){let e;if(n instanceof V)e=Array.from(n.value);else{if(!(n instanceof W))throw new Error(`Cannot apply filter "${s}" to type: ${n.type}`);e=n.value.map((e=>e.value))}const[i,o]=this.evaluateArguments(r.args,t),a=i.at(0)??o.get("separator")??new V("");if(!(a instanceof V))throw new Error("separator must be a string");return new V(e.join(a.value))}if(n instanceof W){switch(s){case"selectattr":case"rejectattr":{const e="selectattr"===s;if(n.value.some((e=>!(e instanceof q))))throw new Error(`\`${s}\` can only be applied to array of objects`);if(r.args.some((e=>"StringLiteral"!==e.type)))throw new Error(`arguments of \`${s}\` must be strings`);const[i,o,a]=r.args.map((e=>this.evaluate(e,t)));let l;if(o){const e=t.tests.get(o.value);if(!e)throw new Error(`Unknown test: ${o.value}`);l=e}else l=(...e)=>e[0].__bool__().value;const d=n.value.filter((t=>{const n=t.value.get(i.value),r=!!n&&l(n,a);return e?r:!r}));return new W(d)}case"map":{const[,e]=this.evaluateArguments(r.args,t);if(e.has("attribute")){const t=e.get("attribute");if(!(t instanceof V))throw new Error("attribute must be a string");const r=e.get("default"),s=n.value.map((e=>{if(!(e instanceof q))throw new Error("items in map must be an object");return e.value.get(t.value)??r??new X}));return new W(s)}throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${s}`)}if(n instanceof V){if("indent"===s){const[e,s]=this.evaluateArguments(r.args,t),i=e.at(0)??s.get("width")??new j(4);if(!(i instanceof j))throw new Error("width must be a number");const o=e.at(1)??s.get("first")??new G(!1),a=e.at(2)??s.get("blank")??new G(!1),l=n.value.split("\n"),d=" ".repeat(i.value),u=l.map(((e,t)=>!o.value&&0===t||!a.value&&0===e.length?e:d+e));return new V(u.join("\n"))}throw new Error(`Unknown StringValue filter: ${s}`)}throw new Error(`Cannot apply filter "${s}" to type: ${n.type}`)}throw new Error(`Unknown filter: ${e.filter.type}`)}evaluateTestExpression(e,t){const n=this.evaluate(e.operand,t),r=t.tests.get(e.test.value);if(!r)throw new Error(`Unknown test: ${e.test.value}`);const s=r(n);return new G(e.negate?!s:s)}evaluateUnaryExpression(e,t){const n=this.evaluate(e.argument,t);if("not"===e.operator.value)return new G(!n.value);throw new SyntaxError(`Unknown operator: ${e.operator.value}`)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let n="";for(const r of e){const e=this.evaluate(r,t);"NullValue"!==e.type&&"UndefinedValue"!==e.type&&(n+=e.value)}return new V(n)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){const[n,r]=this.evaluateArguments(e.args,t);r.size>0&&n.push(new U(r));const s=this.evaluate(e.callee,t);if("FunctionValue"!==s.type)throw new Error(`Cannot call something that is not a function: got ${s.type}`);return s.value(n,t)}evaluateSliceExpression(e,t,n){if(!(e instanceof W||e instanceof V))throw new Error("Slice object must be an array or string");const r=this.evaluate(t.start,n),s=this.evaluate(t.stop,n),i=this.evaluate(t.step,n);if(!(r instanceof j||r instanceof X))throw new Error("Slice start must be numeric or undefined");if(!(s instanceof j||s instanceof X))throw new Error("Slice stop must be numeric or undefined");if(!(i instanceof j||i instanceof X))throw new Error("Slice step must be numeric or undefined");return e instanceof W?new W(B(e.value,r.value,s.value,i.value)):new V(B(Array.from(e.value),r.value,s.value,i.value).join(""))}evaluateMemberExpression(e,t){const n=this.evaluate(e.object,t);let r,s;if(e.computed){if("SliceExpression"===e.property.type)return this.evaluateSliceExpression(n,e.property,t);r=this.evaluate(e.property,t)}else r=new V(e.property.value);if(n instanceof q){if(!(r instanceof V))throw new Error(`Cannot access property with non-string: got ${r.type}`);s=n.value.get(r.value)??n.builtins.get(r.value)}else if(n instanceof W||n instanceof V)if(r instanceof j)s=n.value.at(r.value),n instanceof V&&(s=new V(n.value.at(r.value)));else{if(!(r instanceof V))throw new Error(`Cannot access property with non-string/non-number: got ${r.type}`);s=n.builtins.get(r.value)}else{if(!(r instanceof V))throw new Error(`Cannot access property with non-string: got ${r.type}`);s=n.builtins.get(r.value)}return s instanceof R?s:new X}evaluateSet(e,t){const n=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if("Identifier"===e.assignee.type){const r=e.assignee.value;t.setVariable(r,n)}else{if("MemberExpression"!==e.assignee.type)throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);{const r=e.assignee,s=this.evaluate(r.object,t);if(!(s instanceof q))throw new Error("Cannot assign to member of non-object");if("Identifier"!==r.property.type)throw new Error("Cannot assign to member with non-identifier property");s.value.set(r.property.value,n)}}return new Q}evaluateIf(e,t){const n=this.evaluate(e.test,t);return this.evaluateBlock(n.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){const n=new J(t);let r,s;if("SelectExpression"===e.iterable.type){const t=e.iterable;s=this.evaluate(t.iterable,n),r=t.test}else s=this.evaluate(e.iterable,n);if(!(s instanceof W))throw new Error(`Expected iterable type in for loop: got ${s.type}`);const i=[],o=[];for(let t=0;t<s.value.length;++t){const a=new J(n),l=s.value[t];let d;if("Identifier"===e.loopvar.type)d=t=>t.setVariable(e.loopvar.value,l);else{if("TupleLiteral"!==e.loopvar.type)throw new Error(`Invalid loop variable(s): ${e.loopvar.type}`);{const t=e.loopvar;if("ArrayValue"!==l.type)throw new Error(`Cannot unpack non-iterable type: ${l.type}`);const n=l;if(t.value.length!==n.value.length)throw new Error(`Too ${t.value.length>n.value.length?"few":"many"} items to unpack`);d=e=>{for(let r=0;r<t.value.length;++r){if("Identifier"!==t.value[r].type)throw new Error(`Cannot unpack non-identifier type: ${t.value[r].type}`);e.setVariable(t.value[r].value,n.value[r])}}}}if(r){d(a);if(!this.evaluate(r,a).__bool__().value)continue}i.push(l),o.push(d)}let a="",l=!0;for(let t=0;t<i.length;++t){const r=new Map([["index",new j(t+1)],["index0",new j(t)],["revindex",new j(i.length-t)],["revindex0",new j(i.length-t-1)],["first",new G(0===t)],["last",new G(t===i.length-1)],["length",new j(i.length)],["previtem",t>0?i[t-1]:new X],["nextitem",t<i.length-1?i[t+1]:new X]]);n.setVariable("loop",new q(r)),o[t](n);a+=this.evaluateBlock(e.body,n).value,l=!1}if(l){a+=this.evaluateBlock(e.defaultBlock,n).value}return new V(a)}evaluateMacro(e,t){return t.setVariable(e.name.value,new K(((t,n)=>{const r=new J(n);let s;t=t.slice(),"KeywordArgumentsValue"===t.at(-1)?.type&&(s=t.pop());for(let n=0;n<e.args.length;++n){const i=e.args[n],o=t[n];if("Identifier"===i.type){const e=i;if(!o)throw new Error(`Missing positional argument: ${e.value}`);r.setVariable(e.value,o)}else{if("KeywordArgumentExpression"!==i.type)throw new Error(`Unknown argument type: ${i.type}`);{const e=i,t=o??s?.value.get(e.key.value)??this.evaluate(e.value,r);r.setVariable(e.key.value,t)}}}return this.evaluateBlock(e.body,r)}))),new Q}evaluate(e,t){if(void 0===e)return new X;switch(e.type){case"Program":return this.evalProgram(e,t);case"Set":return this.evaluateSet(e,t);case"If":return this.evaluateIf(e,t);case"For":return this.evaluateFor(e,t);case"Macro":return this.evaluateMacro(e,t);case"NumericLiteral":return new j(Number(e.value));case"StringLiteral":return new V(e.value);case"BooleanLiteral":return new G(e.value);case"NullLiteral":return new Q(e.value);case"ArrayLiteral":return new W(e.value.map((e=>this.evaluate(e,t))));case"TupleLiteral":return new H(e.value.map((e=>this.evaluate(e,t))));case"ObjectLiteral":{const n=new Map;for(const[r,s]of e.value){const e=this.evaluate(r,t);if(!(e instanceof V))throw new Error(`Object keys must be strings: got ${e.type}`);n.set(e.value,this.evaluate(s,t))}return new q(n)}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 new SyntaxError(`Unknown node type: ${e.type}`)}}};function Z(e){switch(typeof e){case"number":return new j(e);case"string":return new V(e);case"boolean":return new G(e);case"undefined":return new X;case"object":return null===e?new Q:Array.isArray(e)?new W(e.map(Z)):new q(new Map(Object.entries(e).map((([e,t])=>[e,Z(t)]))));case"function":return new K(((t,n)=>Z(e(...t.map((e=>e.value)))??null)));default:throw new Error(`Cannot convert to runtime value: ${e}`)}}function ee(e,t,n){const r=n??0;switch(e.type){case"NullValue":case"UndefinedValue":return"null";case"NumericValue":case"StringValue":case"BooleanValue":return JSON.stringify(e.value);case"ArrayValue":case"ObjectValue":{const n=t?" ".repeat(t):"",s="\n"+n.repeat(r),i=s+n;if("ArrayValue"===e.type){const n=e.value.map((e=>ee(e,t,r+1)));return t?`[${i}${n.join(`,${i}`)}${s}]`:`[${n.join(", ")}]`}{const n=Array.from(e.value.entries()).map((([e,n])=>{const s=`"${e}": ${ee(n,t,r+1)}`;return t?`${i}${s}`:s}));return t?`{${n.join(",")}${s}}`:`{${n.join(", ")}}`}}default:throw new Error(`Cannot convert to JSON: ${e.type}`)}}var te=class{parsed;constructor(e){const t=u(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=O(t)}render(e){const t=new J;if(t.set("false",!1),t.set("true",!0),t.set("raise_exception",(e=>{throw new Error(e)})),t.set("range",D),e)for(const[n,r]of Object.entries(e))t.set(n,r);return new Y(t).run(this.parsed).value}}},"./node_modules/onnxruntime-common/dist/esm/backend-impl.js":(e,t,n)=>{n.r(t),n.d(t,{registerBackend:()=>i,resolveBackendAndExecutionProviders:()=>a});const r=new Map,s=[],i=(e,t,n)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createInferenceSessionHandler)throw new TypeError("not a valid backend");{const i=r.get(e);if(void 0===i)r.set(e,{backend:t,priority:n});else{if(i.priority>n)return;if(i.priority===n&&i.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){const t=s.indexOf(e);-1!==t&&s.splice(t,1);for(let t=0;t<s.length;t++)if(r.get(s[t]).priority<=n)return void s.splice(t,0,e);s.push(e)}}},o=async e=>{const t=r.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{const n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},a=async e=>{const t=e.executionProviders||[],n=t.map((e=>"string"==typeof e?e:e.name)),r=0===n.length?s:n;let i;const a=[],l=new Set;for(const e of r){const t=await o(e);"string"==typeof t?a.push({name:e,err:t}):(i||(i=t),i===t&&l.add(e))}if(!i)throw new Error(`no available backend found. ERR: ${a.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`);for(const{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);const d=t.filter((e=>l.has("string"==typeof e?e:e.name)));return[i,new Proxy(e,{get:(e,t)=>"executionProviders"===t?d:Reflect.get(e,t)})]}},"./node_modules/onnxruntime-common/dist/esm/backend.js":(e,t,n)=>{n.r(t),n.d(t,{registerBackend:()=>r.registerBackend});var r=n("./node_modules/onnxruntime-common/dist/esm/backend-impl.js")},"./node_modules/onnxruntime-common/dist/esm/env-impl.js":(e,t,n)=>{n.r(t),n.d(t,{env:()=>i});var r=n("./node_modules/onnxruntime-common/dist/esm/version.js");let s="warning";const i={wasm:{},webgl:{},webgpu:{},versions:{common:r.version},set logLevel(e){if(void 0!==e){if("string"!=typeof e||-1===["verbose","info","warning","error","fatal"].indexOf(e))throw new Error(`Unsupported logging level: ${e}`);s=e}},get logLevel(){return s}};Object.defineProperty(i,"logLevel",{enumerable:!0})},"./node_modules/onnxruntime-common/dist/esm/env.js":(e,t,n)=>{n.r(t),n.d(t,{env:()=>r});const r=n("./node_modules/onnxruntime-common/dist/esm/env-impl.js").env},"./node_modules/onnxruntime-common/dist/esm/index.js":(e,t,n)=>{n.r(t),n.d(t,{InferenceSession:()=>i.InferenceSession,TRACE:()=>a.TRACE,TRACE_FUNC_BEGIN:()=>a.TRACE_FUNC_BEGIN,TRACE_FUNC_END:()=>a.TRACE_FUNC_END,Tensor:()=>o.Tensor,env:()=>s.env,registerBackend:()=>r.registerBackend});var r=n("./node_modules/onnxruntime-common/dist/esm/backend.js"),s=n("./node_modules/onnxruntime-common/dist/esm/env.js"),i=n("./node_modules/onnxruntime-common/dist/esm/inference-session.js"),o=n("./node_modules/onnxruntime-common/dist/esm/tensor.js"),a=(n("./node_modules/onnxruntime-common/dist/esm/tensor-conversion.js"),n("./node_modules/onnxruntime-common/dist/esm/tensor-factory.js"),n("./node_modules/onnxruntime-common/dist/esm/trace.js"));n("./node_modules/onnxruntime-common/dist/esm/onnx-model.js"),n("./node_modules/onnxruntime-common/dist/esm/onnx-value.js")},"./node_modules/onnxruntime-common/dist/esm/inference-session-impl.js":(e,t,n)=>{n.r(t),n.d(t,{InferenceSession:()=>o});var r=n("./node_modules/onnxruntime-common/dist/esm/backend-impl.js"),s=n("./node_modules/onnxruntime-common/dist/esm/tensor.js"),i=n("./node_modules/onnxruntime-common/dist/esm/trace.js");class o{constructor(e){this.handler=e}async run(e,t,n){(0,i.TRACE_FUNC_BEGIN)();const r={};let o={};if("object"!=typeof e||null===e||e instanceof s.Tensor||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if("object"==typeof t){if(null===t)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof s.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(0===t.length)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(const e of t){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if("object"==typeof n&&null!==n)o=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else{let e=!1;const i=Object.getOwnPropertyNames(t);for(const n of this.outputNames)if(-1!==i.indexOf(n)){const i=t[n];(null===i||i instanceof s.Tensor)&&(e=!0,a=!1,r[n]=i)}if(e){if("object"==typeof n&&null!==n)o=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else o=t}}else if(void 0!==t)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const t of this.inputNames)if(void 0===e[t])throw new Error(`input '${t}' is missing in 'feeds'.`);if(a)for(const e of this.outputNames)r[e]=null;const l=await this.handler.run(e,r,o),d={};for(const e in l)if(Object.hasOwnProperty.call(l,e)){const t=l[e];t instanceof s.Tensor?d[e]=t:d[e]=new s.Tensor(t.type,t.data,t.dims)}return(0,i.TRACE_FUNC_END)(),d}async release(){return this.handler.dispose()}static async create(e,t,n,s){let a;(0,i.TRACE_FUNC_BEGIN)();let l={};if("string"==typeof e){if(a=e,"object"==typeof t&&null!==t)l=t;else if(void 0!==t)throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(a=e,"object"==typeof t&&null!==t)l=t;else if(void 0!==t)throw new TypeError("'options' must be an object.")}else{if(!(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{const r=e;let i=0,o=e.byteLength;if("object"==typeof t&&null!==t)l=t;else if("number"==typeof t){if(i=t,!Number.isSafeInteger(i))throw new RangeError("'byteOffset' must be an integer.");if(i<0||i>=r.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${r.byteLength}).`);if(o=e.byteLength-i,"number"==typeof n){if(o=n,!Number.isSafeInteger(o))throw new RangeError("'byteLength' must be an integer.");if(o<=0||i+o>r.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${r.byteLength-i}].`);if("object"==typeof s&&null!==s)l=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else if(void 0!==n)throw new TypeError("'byteLength' must be a number.")}else if(void 0!==t)throw new TypeError("'options' must be an object.");a=new Uint8Array(r,i,o)}}const[d,u]=await(0,r.resolveBackendAndExecutionProviders)(l),c=await d.createInferenceSessionHandler(a,u);return(0,i.TRACE_FUNC_END)(),new o(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}},"./node_modules/onnxruntime-common/dist/esm/inference-session.js":(e,t,n)=>{n.r(t),n.d(t,{InferenceSession:()=>r});const r=n("./node_modules/onnxruntime-common/dist/esm/inference-session-impl.js").InferenceSession},"./node_modules/onnxruntime-common/dist/esm/onnx-model.js":(e,t,n)=>{n.r(t)},"./node_modules/onnxruntime-common/dist/esm/onnx-value.js":(e,t,n)=>{n.r(t)},"./node_modules/onnxruntime-common/dist/esm/tensor-conversion-impl.js":(e,t,n)=>{n.r(t),n.d(t,{tensorToDataURL:()=>r,tensorToImageData:()=>s});const r=(e,t)=>{const n="undefined"!=typeof document?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];const r=n.getContext("2d");if(null!=r){let s,i;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(s=e.dims[2],i=e.dims[3]):(s=e.dims[3],i=e.dims[2]);const o=void 0!==t?.format?t.format:"RGB",a=t?.norm;let l,d;void 0===a||void 0===a.mean?l=[255,255,255,255]:"number"==typeof a.mean?l=[a.mean,a.mean,a.mean,a.mean]:(l=[a.mean[0],a.mean[1],a.mean[2],0],void 0!==a.mean[3]&&(l[3]=a.mean[3])),void 0===a||void 0===a.bias?d=[0,0,0,0]:"number"==typeof a.bias?d=[a.bias,a.bias,a.bias,a.bias]:(d=[a.bias[0],a.bias[1],a.bias[2],0],void 0!==a.bias[3]&&(d[3]=a.bias[3]));const u=i*s;let c=0,p=u,m=2*u,h=-1;"RGBA"===o?(c=0,p=u,m=2*u,h=3*u):"RGB"===o?(c=0,p=u,m=2*u):"RBG"===o&&(c=0,m=u,p=2*u);for(let t=0;t<i;t++)for(let n=0;n<s;n++){const s=(e.data[c++]-d[0])*l[0],i=(e.data[p++]-d[1])*l[1],o=(e.data[m++]-d[2])*l[2],a=-1===h?255:(e.data[h++]-d[3])*l[3];r.fillStyle="rgba("+s+","+i+","+o+","+a+")",r.fillRect(n,t,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},s=(e,t)=>{const n="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");let r;if(null==n)throw new Error("Can not access image data");{let s,i,o;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(s=e.dims[2],i=e.dims[1],o=e.dims[3]):(s=e.dims[3],i=e.dims[2],o=e.dims[1]);const a=void 0!==t&&void 0!==t.format?t.format:"RGB",l=t?.norm;let d,u;void 0===l||void 0===l.mean?d=[255,255,255,255]:"number"==typeof l.mean?d=[l.mean,l.mean,l.mean,l.mean]:(d=[l.mean[0],l.mean[1],l.mean[2],255],void 0!==l.mean[3]&&(d[3]=l.mean[3])),void 0===l||void 0===l.bias?u=[0,0,0,0]:"number"==typeof l.bias?u=[l.bias,l.bias,l.bias,l.bias]:(u=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(u[3]=l.bias[3]));const c=i*s;if(void 0!==t&&(void 0!==t.format&&4===o&&"RGBA"!==t.format||3===o&&"RGB"!==t.format&&"BGR"!==t.format))throw new Error("Tensor format doesn't match input tensor dims");const p=4;let m=0,h=1,f=2,_=3,g=0,w=c,b=2*c,y=-1;"RGBA"===a?(g=0,w=c,b=2*c,y=3*c):"RGB"===a?(g=0,w=c,b=2*c):"RBG"===a&&(g=0,b=c,w=2*c),r=n.createImageData(s,i);for(let t=0;t<i*s;m+=p,h+=p,f+=p,_+=p,t++)r.data[m]=(e.data[g++]-u[0])*d[0],r.data[h]=(e.data[w++]-u[1])*d[1],r.data[f]=(e.data[b++]-u[2])*d[2],r.data[_]=-1===y?255:(e.data[y++]-u[3])*d[3]}return r}},"./node_modules/onnxruntime-common/dist/esm/tensor-conversion.js":(e,t,n)=>{n.r(t)},"./node_modules/onnxruntime-common/dist/esm/tensor-factory-impl.js":(e,t,n)=>{n.r(t),n.d(t,{bufferToTensor:()=>s,tensorFromGpuBuffer:()=>a,tensorFromImage:()=>i,tensorFromMLTensor:()=>l,tensorFromPinnedBuffer:()=>d,tensorFromTexture:()=>o});var r=n("./node_modules/onnxruntime-common/dist/esm/tensor-impl.js");const s=(e,t)=>{if(void 0===e)throw new Error("Image buffer must be defined");if(void 0===t.height||void 0===t.width)throw new Error("Image height and width must be defined");if("NHWC"===t.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");const{height:n,width:s}=t,i=t.norm??{mean:255,bias:0};let o,a;o="number"==typeof i.mean?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],a="number"==typeof i.bias?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];const l=void 0!==t.format?t.format:"RGBA",d=void 0!==t.tensorFormat&&void 0!==t.tensorFormat?t.tensorFormat:"RGB",u=n*s,c="RGBA"===d?new Float32Array(4*u):new Float32Array(3*u);let p=4,m=0,h=1,f=2,_=3,g=0,w=u,b=2*u,y=-1;"RGB"===l&&(p=3,m=0,h=1,f=2,_=-1),"RGBA"===d?y=3*u:"RBG"===d?(g=0,b=u,w=2*u):"BGR"===d&&(b=0,w=u,g=2*u);for(let t=0;t<u;t++,m+=p,f+=p,h+=p,_+=p)c[g++]=(e[m]+a[0])/o[0],c[w++]=(e[h]+a[1])/o[1],c[b++]=(e[f]+a[2])/o[2],-1!==y&&-1!==_&&(c[y++]=(e[_]+a[3])/o[3]);return"RGBA"===d?new r.Tensor("float32",c,[1,4,n,s]):new r.Tensor("float32",c,[1,3,n,s])},i=async(e,t)=>{const n="undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement,r="undefined"!=typeof ImageData&&e instanceof ImageData,i="undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap,o="string"==typeof e;let a,l=t??{};const d=()=>{if("undefined"!=typeof document)return document.createElement("canvas");if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},u=e=>"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext("2d"):null;if(n){const n=d();n.width=e.width,n.height=e.height;const r=u(n);if(null==r)throw new Error("Can not access image data");{let n=e.height,s=e.width;if(void 0!==t&&void 0!==t.resizedHeight&&void 0!==t.resizedWidth&&(n=t.resizedHeight,s=t.resizedWidth),void 0!==t){if(l=t,void 0!==t.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");l.tensorFormat="RGBA",l.height=n,l.width=s}else l.tensorFormat="RGBA",l.height=n,l.width=s;r.drawImage(e,0,0),a=r.getImageData(0,0,s,n).data}}else{if(!r){if(i){if(void 0===t)throw new Error("Please provide image config with format for Imagebitmap");const n=d();n.width=e.width,n.height=e.height;const r=u(n);if(null!=r){const t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),a=r.getImageData(0,0,n,t).data,l.height=t,l.width=n,s(a,l)}throw new Error("Can not access image data")}if(o)return new Promise(((t,n)=>{const r=d(),i=u(r);if(!e||!i)return n();const o=new Image;o.crossOrigin="Anonymous",o.src=e,o.onload=()=>{r.width=o.width,r.height=o.height,i.drawImage(o,0,0,r.width,r.height);const e=i.getImageData(0,0,r.width,r.height);l.height=r.height,l.width=r.width,t(s(e.data,l))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let n,r;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),void 0!==t&&(l=t),l.format="RGBA",l.height=n,l.width=r,void 0!==t){const t=d();t.width=r,t.height=n;const s=u(t);if(null==s)throw new Error("Can not access image data");s.putImageData(e,0,0),a=s.getImageData(0,0,r,n).data}else a=e.data}}if(void 0!==a)return s(a,l);throw new Error("Input data provided is not supported - aborted tensor creation")},o=(e,t)=>{const{width:n,height:s,download:i,dispose:o}=t,a=[1,s,n,4];return new r.Tensor({location:"texture",type:"float32",texture:e,dims:a,download:i,dispose:o})},a=(e,t)=>{const{dataType:n,dims:s,download:i,dispose:o}=t;return new r.Tensor({location:"gpu-buffer",type:n??"float32",gpuBuffer:e,dims:s,download:i,dispose:o})},l=(e,t)=>{const{dataType:n,dims:s,download:i,dispose:o}=t;return new r.Tensor({location:"ml-tensor",type:n??"float32",mlTensor:e,dims:s,download:i,dispose:o})},d=(e,t,n)=>new r.Tensor({location:"cpu-pinned",type:e,data:t,dims:n??[t.length]})},"./node_modules/onnxruntime-common/dist/esm/tensor-factory.js":(e,t,n)=>{n.r(t)},"./node_modules/onnxruntime-common/dist/esm/tensor-impl-type-mapping.js":(e,t,n)=>{n.r(t),n.d(t,{NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP:()=>s,NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP:()=>r,checkTypedArray:()=>o});const r=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),s=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let i=!1;const o=()=>{if(!i){i=!0;const e="undefined"!=typeof BigInt64Array&&BigInt64Array.from,t="undefined"!=typeof BigUint64Array&&BigUint64Array.from,n=globalThis.Float16Array,o=void 0!==n&&n.from;e&&(r.set("int64",BigInt64Array),s.set(BigInt64Array,"int64")),t&&(r.set("uint64",BigUint64Array),s.set(BigUint64Array,"uint64")),o?(r.set("float16",n),s.set(n,"float16")):r.set("float16",Uint16Array)}}},"./node_modules/onnxruntime-common/dist/esm/tensor-impl.js":(e,t,n)=>{n.r(t),n.d(t,{Tensor:()=>a});var r=n("./node_modules/onnxruntime-common/dist/esm/tensor-conversion-impl.js"),s=n("./node_modules/onnxruntime-common/dist/esm/tensor-factory-impl.js"),i=n("./node_modules/onnxruntime-common/dist/esm/tensor-impl-type-mapping.js"),o=n("./node_modules/onnxruntime-common/dist/esm/tensor-utils-impl.js");class a{constructor(e,t,n){let r,s;if((0,i.checkTypedArray)(),"object"==typeof e&&"location"in e)switch(this.dataLocation=e.location,r=e.type,s=e.dims,e.location){case"cpu-pinned":{const t=i.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(r);if(!t)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw new TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case"texture":if("float32"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case"gpu-buffer":if("float32"!==r&&"float16"!==r&&"int32"!==r&&"int64"!==r&&"uint32"!==r&&"uint8"!==r&&"bool"!==r&&"uint4"!==r&&"int4"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case"ml-tensor":if("float32"!==r&&"float16"!==r&&"int32"!==r&&"int64"!==r&&"uint32"!==r&&"uint64"!==r&&"int8"!==r&&"uint8"!==r&&"bool"!==r&&"uint4"!==r&&"int4"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let o,a;if("string"==typeof e)if(r=e,a=n,"string"===e){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");o=t}else{const n=i.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(e);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if("float16"===e&&n===Uint16Array||"uint4"===e||"int4"===e)throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);o="uint64"===e||"int64"===e?n.from(t,BigInt):n.from(t)}else if(t instanceof n)o=t;else if(t instanceof Uint8ClampedArray){if("uint8"!==e)throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");o=Uint8Array.from(t)}else{if(!("float16"===e&&t instanceof Uint16Array&&n!==Uint16Array))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);o=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length)}}else if(a=t,Array.isArray(e)){if(0===e.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");const t=typeof e[0];if("string"===t)r="string",o=e;else{if("boolean"!==t)throw new TypeError(`Invalid element type of data array: ${t}.`);r="bool",o=Uint8Array.from(e)}}else if(e instanceof Uint8ClampedArray)r="uint8",o=Uint8Array.from(e);else{const t=i.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(e.constructor);if(void 0===t)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,o=e}if(void 0===a)a=[o.length];else if(!Array.isArray(a))throw new TypeError("A tensor's dims must be a number array");s=a,this.cpuData=o,this.dataLocation="cpu"}const a=(0,o.calculateS