@yuktishaalaa/yuktai 3.0.4 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-KCEUBLHC.mjs +1 -0
- package/dist/index.js +98 -28
- package/dist/index.mjs +2 -2
- package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
- package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
- package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
- package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
- package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
- package/dist/rag-BJOHTAZU.mjs +1 -0
- package/dist/transformers.node-5VXT65S7.mjs +71 -0
- package/package.json +82 -89
- package/dist/rag-HDO3PUIJ.mjs +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import{a as Pe,b as sh,c as LT,d as te,e as ih}from"./chunk-KCEUBLHC.mjs";var So=te(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.resolveBackendAndExecutionProviders=en.registerBackend=void 0;var oi=new Map,La=[],AT=(e,t,r)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let a=oi.get(e);if(a===void 0)oi.set(e,{backend:t,priority:r});else{if(a.priority>r)return;if(a.priority===r&&a.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${r}`)}if(r>=0){let n=La.indexOf(e);n!==-1&&La.splice(n,1);for(let s=0;s<La.length;s++)if(oi.get(La[s]).priority<=r){La.splice(s,0,e);return}La.push(e)}return}throw new TypeError("not a valid backend")};en.registerBackend=AT;var gT=async e=>{let t=oi.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(a){return r||(t.error=`${a}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},TT=async e=>{let t=e.executionProviders||[],r=t.map(o=>typeof o=="string"?o:o.name),a=r.length===0?La:r,n,s=[],i=new Set;for(let o of a){let _=await gT(o);typeof _=="string"?s.push({name:o,err:_}):(n||(n=_),n===_&&i.add(o))}if(!n)throw new Error(`no available backend found. ERR: ${s.map(o=>`[${o.name}] ${o.err}`).join(", ")}`);for(let{name:o,err:_}of s)r.includes(o)&&console.warn(`removing requested execution provider "${o}" from session options because it is not available: ${_}`);let H=t.filter(o=>i.has(typeof o=="string"?o:o.name));return[n,new Proxy(e,{get:(o,_)=>_==="executionProviders"?H:Reflect.get(o,_)})]};en.resolveBackendAndExecutionProviders=TT});var Hh=te(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.registerBackend=void 0;var bT=So();Object.defineProperty(_i,"registerBackend",{enumerable:!0,get:function(){return bT.registerBackend}})});var oh=te(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.version=void 0;ci.version="1.24.3"});var Lo=te(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.env=void 0;var vT=oh(),_h="warning";ns.env={wasm:{},webgl:{},webgpu:{},versions:{common:vT.version},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);_h=e}},get logLevel(){return _h}};Object.defineProperty(ns.env,"logLevel",{enumerable:!0})});var ch=te(li=>{"use strict";Object.defineProperty(li,"__esModule",{value:!0});li.env=void 0;var DT=Lo();li.env=DT.env});var lh=te(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.tensorToImageData=tn.tensorToDataURL=void 0;var CT=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];let a=r.getContext("2d");if(a!=null){let n,s;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(n=e.dims[2],s=e.dims[3]):(n=e.dims[3],s=e.dims[2]);let i=t?.format!==void 0?t.format:"RGB",H=t?.norm,o,_;H===void 0||H.mean===void 0?o=[255,255,255,255]:typeof H.mean=="number"?o=[H.mean,H.mean,H.mean,H.mean]:(o=[H.mean[0],H.mean[1],H.mean[2],0],H.mean[3]!==void 0&&(o[3]=H.mean[3])),H===void 0||H.bias===void 0?_=[0,0,0,0]:typeof H.bias=="number"?_=[H.bias,H.bias,H.bias,H.bias]:(_=[H.bias[0],H.bias[1],H.bias[2],0],H.bias[3]!==void 0&&(_[3]=H.bias[3]));let c=s*n,l=0,d=c,h=c*2,$=-1;i==="RGBA"?(l=0,d=c,h=c*2,$=c*3):i==="RGB"?(l=0,d=c,h=c*2):i==="RBG"&&(l=0,h=c,d=c*2);for(let m=0;m<s;m++)for(let S=0;S<n;S++){let I=(e.data[l++]-_[0])*o[0],T=(e.data[d++]-_[1])*o[1],D=(e.data[h++]-_[2])*o[2],v=$===-1?255:(e.data[$++]-_[3])*o[3];a.fillStyle="rgba("+I+","+T+","+D+","+v+")",a.fillRect(S,m,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")};tn.tensorToDataURL=CT;var xT=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),a;if(r!=null){let n,s,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(n=e.dims[2],s=e.dims[1],i=e.dims[3]):(n=e.dims[3],s=e.dims[2],i=e.dims[1]);let H=t!==void 0&&t.format!==void 0?t.format:"RGB",o=t?.norm,_,c;o===void 0||o.mean===void 0?_=[255,255,255,255]:typeof o.mean=="number"?_=[o.mean,o.mean,o.mean,o.mean]:(_=[o.mean[0],o.mean[1],o.mean[2],255],o.mean[3]!==void 0&&(_[3]=o.mean[3])),o===void 0||o.bias===void 0?c=[0,0,0,0]:typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:(c=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(c[3]=o.bias[3]));let l=s*n;if(t!==void 0&&(t.format!==void 0&&i===4&&t.format!=="RGBA"||i===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,h=0,$=1,m=2,S=3,I=0,T=l,D=l*2,v=-1;H==="RGBA"?(I=0,T=l,D=l*2,v=l*3):H==="RGB"?(I=0,T=l,D=l*2):H==="RBG"&&(I=0,D=l,T=l*2),a=r.createImageData(n,s);for(let C=0;C<s*n;h+=d,$+=d,m+=d,S+=d,C++)a.data[h]=(e.data[I++]-c[0])*_[0],a.data[$]=(e.data[T++]-c[1])*_[1],a.data[m]=(e.data[D++]-c[2])*_[2],a.data[S]=v===-1?255:(e.data[v++]-c[3])*_[3]}else throw new Error("Can not access image data");return a};tn.tensorToImageData=xT});var uh=te($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.tensorFromPinnedBuffer=$t.tensorFromMLTensor=$t.tensorFromGpuBuffer=$t.tensorFromTexture=$t.tensorFromImage=$t.bufferToTensor=void 0;var rn=ui(),NT=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:a}=t,n=t.norm??{mean:255,bias:0},s,i;typeof n.mean=="number"?s=[n.mean,n.mean,n.mean,n.mean]:s=[n.mean[0],n.mean[1],n.mean[2],n.mean[3]??255],typeof n.bias=="number"?i=[n.bias,n.bias,n.bias,n.bias]:i=[n.bias[0],n.bias[1],n.bias[2],n.bias[3]??0];let H=t.format!==void 0?t.format:"RGBA",o=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",_=r*a,c=o==="RGBA"?new Float32Array(_*4):new Float32Array(_*3),l=4,d=0,h=1,$=2,m=3,S=0,I=_,T=_*2,D=-1;H==="RGB"&&(l=3,d=0,h=1,$=2,m=-1),o==="RGBA"?D=_*3:o==="RBG"?(S=0,T=_,I=_*2):o==="BGR"&&(T=0,I=_,S=_*2);for(let C=0;C<_;C++,d+=l,$+=l,h+=l,m+=l)c[S++]=(e[d]+i[0])/s[0],c[I++]=(e[h]+i[1])/s[1],c[T++]=(e[$]+i[2])/s[2],D!==-1&&m!==-1&&(c[D++]=(e[m]+i[3])/s[3]);return o==="RGBA"?new rn.Tensor("float32",c,[1,4,r,a]):new rn.Tensor("float32",c,[1,3,r,a])};$t.bufferToTensor=NT;var wT=async(e,t)=>{let r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,a=typeof ImageData<"u"&&e instanceof ImageData,n=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,s=typeof e=="string",i,H=t??{},o=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},_=c=>typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||c instanceof OffscreenCanvas?c.getContext("2d"):null;if(r){let c=o();c.width=e.width,c.height=e.height;let l=_(c);if(l!=null){let d=e.height,h=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(d=t.resizedHeight,h=t.resizedWidth),t!==void 0){if(H=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");H.tensorFormat="RGBA",H.height=d,H.width=h}else H.tensorFormat="RGBA",H.height=d,H.width=h;l.drawImage(e,0,0),i=l.getImageData(0,0,h,d).data}else throw new Error("Can not access image data")}else if(a){let c,l;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(c=t.resizedHeight,l=t.resizedWidth):(c=e.height,l=e.width),t!==void 0&&(H=t),H.format="RGBA",H.height=c,H.width=l,t!==void 0){let d=o();d.width=l,d.height=c;let h=_(d);if(h!=null)h.putImageData(e,0,0),i=h.getImageData(0,0,l,c).data;else throw new Error("Can not access image data")}else i=e.data}else if(n){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=o();c.width=e.width,c.height=e.height;let l=_(c);if(l!=null){let d=e.height,h=e.width;return l.drawImage(e,0,0,h,d),i=l.getImageData(0,0,h,d).data,H.height=d,H.width=h,(0,$t.bufferToTensor)(i,H)}else throw new Error("Can not access image data")}else{if(s)return new Promise((c,l)=>{let d=o(),h=_(d);if(!e||!h)return l();let $=new Image;$.crossOrigin="Anonymous",$.src=e,$.onload=()=>{d.width=$.width,d.height=$.height,h.drawImage($,0,0,d.width,d.height);let m=h.getImageData(0,0,d.width,d.height);H.height=d.height,H.width=d.width,c((0,$t.bufferToTensor)(m.data,H))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(i!==void 0)return(0,$t.bufferToTensor)(i,H);throw new Error("Input data provided is not supported - aborted tensor creation")};$t.tensorFromImage=wT;var yT=(e,t)=>{let{width:r,height:a,download:n,dispose:s}=t,i=[1,a,r,4];return new rn.Tensor({location:"texture",type:"float32",texture:e,dims:i,download:n,dispose:s})};$t.tensorFromTexture=yT;var BT=(e,t)=>{let{dataType:r,dims:a,download:n,dispose:s}=t;return new rn.Tensor({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:a,download:n,dispose:s})};$t.tensorFromGpuBuffer=BT;var MT=(e,t)=>{let{dataType:r,dims:a,download:n,dispose:s}=t;return new rn.Tensor({location:"ml-tensor",type:r??"float32",mlTensor:e,dims:a,download:n,dispose:s})};$t.tensorFromMLTensor=MT;var PT=(e,t,r)=>new rn.Tensor({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]});$t.tensorFromPinnedBuffer=PT});var ph=te(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.checkTypedArray=yt.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=yt.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=void 0;yt.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]);yt.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);var dh=!1,RT=()=>{if(!dh){dh=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,a=typeof r<"u"&&r.from;e&&(yt.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),yt.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64")),t&&(yt.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),yt.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64")),a?(yt.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("float16",r),yt.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(r,"float16")):yt.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("float16",Uint16Array)}};yt.checkTypedArray=RT});var hh=te(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});an.tensorReshape=an.calculateSize=void 0;var ss=ui(),kT=e=>{let t=1;for(let r=0;r<e.length;r++){let a=e[r];if(typeof a!="number"||!Number.isSafeInteger(a))throw new TypeError(`dims[${r}] must be an integer, got: ${a}`);if(a<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${a}`);t*=a}return t};an.calculateSize=kT;var OT=(e,t)=>{switch(e.location){case"cpu":return new ss.Tensor(e.type,e.data,t);case"cpu-pinned":return new ss.Tensor({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new ss.Tensor({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new ss.Tensor({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case"ml-tensor":return new ss.Tensor({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}};an.tensorReshape=OT});var ui=te(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.Tensor=void 0;var fh=lh(),is=uh(),di=ph(),Eh=hh(),Ao=class{constructor(t,r,a){(0,di.checkTypedArray)();let n,s;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,n=t.type,s=t.dims,t.location){case"cpu-pinned":{let H=di.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(n);if(!H)throw new TypeError(`unsupported type "${n}" to create tensor from pinned buffer`);if(!(t.data instanceof H))throw new TypeError(`buffer should be of type ${H.name}`);this.cpuData=t.data;break}case"texture":{if(n!=="float32")throw new TypeError(`unsupported type "${n}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(n!=="float32"&&n!=="float16"&&n!=="int32"&&n!=="int64"&&n!=="uint32"&&n!=="uint8"&&n!=="bool"&&n!=="uint4"&&n!=="int4")throw new TypeError(`unsupported type "${n}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(n!=="float32"&&n!=="float16"&&n!=="int32"&&n!=="int64"&&n!=="uint32"&&n!=="uint64"&&n!=="int8"&&n!=="uint8"&&n!=="bool"&&n!=="uint4"&&n!=="int4")throw new TypeError(`unsupported type "${n}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let H,o;if(typeof t=="string")if(n=t,o=a,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");H=r}else{let _=di.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(t);if(_===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&_===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${_.name} as data.`);t==="uint64"||t==="int64"?H=_.from(r,BigInt):H=_.from(r)}else if(r instanceof _)H=r;else if(r instanceof Uint8ClampedArray)if(t==="uint8")H=Uint8Array.from(r);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&r instanceof Uint16Array&&_!==Uint16Array)H=new globalThis.Float16Array(r.buffer,r.byteOffset,r.length);else throw new TypeError(`A ${n} tensor's data must be type of ${_}`)}else if(o=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let _=typeof t[0];if(_==="string")n="string",H=t;else if(_==="boolean")n="bool",H=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${_}.`)}else if(t instanceof Uint8ClampedArray)n="uint8",H=Uint8Array.from(t);else{let _=di.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(t.constructor);if(_===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);n=_,H=t}if(o===void 0)o=[H.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");s=o,this.cpuData=H,this.dataLocation="cpu"}let i=(0,Eh.calculateSize)(s);if(this.cpuData&&i!==this.cpuData.length&&!((n==="uint4"||n==="int4")&&Math.ceil(i/2)===this.cpuData.length))throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=n,this.dims=s,this.size=i}static async fromImage(t,r){return(0,is.tensorFromImage)(t,r)}static fromTexture(t,r){return(0,is.tensorFromTexture)(t,r)}static fromGpuBuffer(t,r){return(0,is.tensorFromGpuBuffer)(t,r)}static fromMLTensor(t,r){return(0,is.tensorFromMLTensor)(t,r)}static fromPinnedBuffer(t,r,a){return(0,is.tensorFromPinnedBuffer)(t,r,a)}toDataURL(t){return(0,fh.tensorToDataURL)(this,t)}toImageData(t){return(0,fh.tensorToImageData)(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let r=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=r,t&&this.disposer&&(this.disposer(),this.disposer=void 0),r}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return(0,Eh.tensorReshape)(this,t)}};pi.Tensor=Ao});var go=te(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.Tensor=void 0;var GT=ui();hi.Tensor=GT.Tensor});var To=te(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.TRACE_EVENT_END=Zt.TRACE_EVENT_BEGIN=Zt.TRACE_FUNC_END=Zt.TRACE_FUNC_BEGIN=Zt.TRACE=void 0;var Bt=Lo(),FT=(e,t)=>{(typeof Bt.env.trace>"u"?!Bt.env.wasm.trace:!Bt.env.trace)||console.timeStamp(`${e}::ORT::${t}`)};Zt.TRACE=FT;var $h=(e,t)=>{let r=new Error().stack?.split(/\r\n|\r|\n/g)||[],a=!1;for(let n=0;n<r.length;n++){if(a&&!r[n].includes("TRACE_FUNC")){let s=`FUNC_${e}::${r[n].trim().split(" ")[1]}`;t&&(s+=`::${t}`),(0,Zt.TRACE)("CPU",s);return}r[n].includes("TRACE_FUNC")&&(a=!0)}},ZT=e=>{(typeof Bt.env.trace>"u"?!Bt.env.wasm.trace:!Bt.env.trace)||$h("BEGIN",e)};Zt.TRACE_FUNC_BEGIN=ZT;var UT=e=>{(typeof Bt.env.trace>"u"?!Bt.env.wasm.trace:!Bt.env.trace)||$h("END",e)};Zt.TRACE_FUNC_END=UT;var KT=e=>{(typeof Bt.env.trace>"u"?!Bt.env.wasm.trace:!Bt.env.trace)||console.time(`ORT::${e}`)};Zt.TRACE_EVENT_BEGIN=KT;var WT=e=>{(typeof Bt.env.trace>"u"?!Bt.env.wasm.trace:!Bt.env.trace)||console.timeEnd(`ORT::${e}`)};Zt.TRACE_EVENT_END=WT});var mh=te(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.InferenceSession=void 0;var VT=So(),Hs=go(),aa=To(),bo=class e{constructor(t){this.handler=t}async run(t,r,a){(0,aa.TRACE_FUNC_BEGIN)(),(0,aa.TRACE_EVENT_BEGIN)("InferenceSession.run");let n={},s={};if(typeof t!="object"||t===null||t instanceof Hs.Tensor||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Hs.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(let _ of r){if(typeof _!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(_)===-1)throw new RangeError(`'fetches' contains invalid output name: ${_}.`);n[_]=null}if(typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else{let _=!1,c=Object.getOwnPropertyNames(r);for(let l of this.outputNames)if(c.indexOf(l)!==-1){let d=r[l];(d===null||d instanceof Hs.Tensor)&&(_=!0,i=!1,n[l]=d)}if(_){if(typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else s=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let _ of this.inputNames)if(typeof t[_]>"u")throw new Error(`input '${_}' is missing in 'feeds'.`);if(i)for(let _ of this.outputNames)n[_]=null;let H=await this.handler.run(t,n,s),o={};for(let _ in H)if(Object.hasOwnProperty.call(H,_)){let c=H[_];c instanceof Hs.Tensor?o[_]=c:o[_]=new Hs.Tensor(c.type,c.data,c.dims)}return(0,aa.TRACE_EVENT_END)("InferenceSession.run"),(0,aa.TRACE_FUNC_END)(),o}async release(){return this.handler.dispose()}static async create(t,r,a,n){(0,aa.TRACE_FUNC_BEGIN)(),(0,aa.TRACE_EVENT_BEGIN)("InferenceSession.create");let s,i={};if(typeof t=="string"){if(s=t,typeof r=="object"&&r!==null)i=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(s=t,typeof r=="object"&&r!==null)i=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let c=t,l=0,d=t.byteLength;if(typeof r=="object"&&r!==null)i=r;else if(typeof r=="number"){if(l=r,!Number.isSafeInteger(l))throw new RangeError("'byteOffset' must be an integer.");if(l<0||l>=c.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${c.byteLength}).`);if(d=t.byteLength-l,typeof a=="number"){if(d=a,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||l+d>c.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${c.byteLength-l}].`);if(typeof n=="object"&&n!==null)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(typeof a<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof r<"u")throw new TypeError("'options' must be an object.");s=new Uint8Array(c,l,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[H,o]=await(0,VT.resolveBackendAndExecutionProviders)(i),_=await H.createInferenceSessionHandler(s,o);return(0,aa.TRACE_EVENT_END)("InferenceSession.create"),(0,aa.TRACE_FUNC_END)(),new e(_)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}};fi.InferenceSession=bo});var Ih=te(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.InferenceSession=void 0;var jT=mh();Ei.InferenceSession=jT.InferenceSession});var Lh=te(Sh=>{"use strict";Object.defineProperty(Sh,"__esModule",{value:!0})});var gh=te(Ah=>{"use strict";Object.defineProperty(Ah,"__esModule",{value:!0})});var bh=te(Th=>{"use strict";Object.defineProperty(Th,"__esModule",{value:!0})});var Dh=te(vh=>{"use strict";Object.defineProperty(vh,"__esModule",{value:!0})});var $i=te(Mt=>{"use strict";var qT=Mt&&Mt.__createBinding||(Object.create?(function(e,t,r,a){a===void 0&&(a=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,n)}):(function(e,t,r,a){a===void 0&&(a=r),e[a]=t[r]})),Fr=Mt&&Mt.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&qT(t,e,r)};Object.defineProperty(Mt,"__esModule",{value:!0});Fr(Hh(),Mt);Fr(ch(),Mt);Fr(Ih(),Mt);Fr(go(),Mt);Fr(Lh(),Mt);Fr(gh(),Mt);Fr(To(),Mt);Fr(bh(),Mt);Fr(Dh(),Mt)});var Ch=te((AF,XT)=>{XT.exports="./onnxruntime_binding-EKZT2NRK.node"});var xh=te((gF,zT)=>{zT.exports="./onnxruntime_binding-6Q6HXASN.node"});var Nh=te((TF,JT)=>{JT.exports="./onnxruntime_binding-UN6SPTQK.node"});var wh=te((bF,QT)=>{QT.exports="./onnxruntime_binding-PJNNIIUO.node"});var yh=te((vF,YT)=>{YT.exports="./onnxruntime_binding-P6S7V3CI.node"});var eb,vo=LT(()=>{eb=sh({"../bin/napi-v6/darwin/arm64/onnxruntime_binding.node":()=>Ch(),"../bin/napi-v6/linux/arm64/onnxruntime_binding.node":()=>xh(),"../bin/napi-v6/linux/x64/onnxruntime_binding.node":()=>Nh(),"../bin/napi-v6/win32/arm64/onnxruntime_binding.node":()=>wh(),"../bin/napi-v6/win32/x64/onnxruntime_binding.node":()=>yh()})});var Mh=te(Aa=>{"use strict";vo();Object.defineProperty(Aa,"__esModule",{value:!0});Aa.initOrt=Aa.binding=void 0;var mi=$i();Aa.binding=eb(`../bin/napi-v6/${process.platform}/${process.arch}/onnxruntime_binding.node`);var Bh=!1,tb=()=>{if(!Bh){Bh=!0;let e=2;if(mi.env.logLevel)switch(mi.env.logLevel){case"verbose":e=0;break;case"info":e=1;break;case"warning":e=2;break;case"error":e=3;break;case"fatal":e=4;break;default:throw new Error(`Unsupported log level: ${mi.env.logLevel}`)}Aa.binding.initOrtOnce(e,mi.Tensor)}};Aa.initOrt=tb});var No=te(Ir=>{"use strict";var rb=Ir&&Ir.__classPrivateFieldSet||function(e,t,r,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r},ga=Ir&&Ir.__classPrivateFieldGet||function(e,t,r,a){if(r==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?a:r==="a"?a.call(e):a?a.value:t.get(e)},mr;Object.defineProperty(Ir,"__esModule",{value:!0});Ir.listSupportedBackends=Ir.onnxruntimeBackend=void 0;var Do=Mh(),ab=[void 0,"float32","uint8","int8","uint16","int16","int32","int64","string","bool","float16","float64","uint32","uint64",void 0,void 0,void 0,void 0,void 0,void 0,void 0,"uint4","int4"],Co=class{constructor(t,r){mr.set(this,void 0),(0,Do.initOrt)(),rb(this,mr,new Do.binding.InferenceSession,"f"),typeof t=="string"?ga(this,mr,"f").loadModel(t,r):ga(this,mr,"f").loadModel(t.buffer,t.byteOffset,t.byteLength,r),this.inputNames=[],this.outputNames=[],this.inputMetadata=[],this.outputMetadata=[];let a=n=>{let s=[],i=[];for(let H of n)if(s.push(H.name),!H.isTensor)i.push({name:H.name,isTensor:!1});else{let o=ab[H.type];if(o===void 0)throw new Error(`Unsupported data type: ${H.type}`);let _=[];for(let c=0;c<H.shape.length;++c){let l=H.shape[c];if(l===-1)_.push(H.symbolicDimensions[c]);else if(l>=0)_.push(l);else throw new Error(`Invalid dimension: ${l}`)}i.push({name:H.name,isTensor:H.isTensor,type:o,shape:_})}return[s,i]};[this.inputNames,this.inputMetadata]=a(ga(this,mr,"f").inputMetadata),[this.outputNames,this.outputMetadata]=a(ga(this,mr,"f").outputMetadata)}async dispose(){ga(this,mr,"f").dispose()}startProfiling(){}endProfiling(){ga(this,mr,"f").endProfiling()}async run(t,r,a){return new Promise((n,s)=>{setImmediate(()=>{try{n(ga(this,mr,"f").run(t,r,a))}catch(i){s(i)}})})}};mr=new WeakMap;var xo=class{async init(){return Promise.resolve()}async createInferenceSessionHandler(t,r){return new Promise((a,n)=>{setImmediate(()=>{try{a(new Co(t,r||{}))}catch(s){n(s)}})})}};Ir.onnxruntimeBackend=new xo;Ir.listSupportedBackends=Do.binding.listSupportedBackends});var Ph=te(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.version=void 0;Ii.version="1.24.3"});var Oh=te(Zr=>{"use strict";var nb=Zr&&Zr.__createBinding||(Object.create?(function(e,t,r,a){a===void 0&&(a=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,n)}):(function(e,t,r,a){a===void 0&&(a=r),e[a]=t[r]})),sb=Zr&&Zr.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&nb(t,e,r)};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.listSupportedBackends=void 0;sb($i(),Zr);var ib=No();Object.defineProperty(Zr,"listSupportedBackends",{enumerable:!0,get:function(){return ib.listSupportedBackends}});var Rh=$i(),Hb=Ph(),kh=No(),ob=(0,kh.listSupportedBackends)();for(let e of ob)(0,Rh.registerBackend)(e.name,kh.onnxruntimeBackend,100);Object.defineProperty(Rh.env.versions,"node",{value:Hb.version,enumerable:!0})});var Sr=te((vZ,ef)=>{"use strict";var Yh=e=>typeof e<"u"&&e!==null,_b=e=>typeof e=="object",cb=e=>Object.prototype.toString.call(e)==="[object Object]",lb=e=>typeof e=="function",ub=e=>typeof e=="boolean",db=e=>e instanceof Buffer,pb=e=>{if(Yh(e))switch(e.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},hb=e=>e instanceof ArrayBuffer,fb=e=>typeof e=="string"&&e.length>0,Eb=e=>typeof e=="number"&&!Number.isNaN(e),$b=e=>Number.isInteger(e),mb=(e,t,r)=>e>=t&&e<=r,Ib=(e,t)=>t.includes(e),Sb=(e,t,r)=>new Error(`Expected ${t} for ${e} but received ${r} of type ${typeof r}`),Lb=(e,t)=>(t.message=e.message,t);ef.exports={defined:Yh,object:_b,plainObject:cb,fn:lb,bool:ub,buffer:db,typedArray:pb,arrayBuffer:hb,string:fb,number:Eb,integer:$b,inRange:mb,inArray:Ib,invalidParameterError:Sb,nativeError:Lb}});var af=te((DZ,rf)=>{"use strict";var tf=()=>process.platform==="linux",Si=null,Ab=()=>{if(!Si)if(tf()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,Si=process.report.getReport(),process.report.excludeNetwork=e}else Si={};return Si};rf.exports={isLinux:tf,getReport:Ab}});var sf=te((CZ,nf)=>{"use strict";var nn=Pe("fs"),gb="/usr/bin/ldd",Tb="/proc/self/exe",Li=2048,bb=e=>{let t=nn.openSync(e,"r"),r=Buffer.alloc(Li),a=nn.readSync(t,r,0,Li,0);return nn.close(t,()=>{}),r.subarray(0,a)},vb=e=>new Promise((t,r)=>{nn.open(e,"r",(a,n)=>{if(a)r(a);else{let s=Buffer.alloc(Li);nn.read(n,s,0,Li,0,(i,H)=>{t(s.subarray(0,H)),nn.close(n,()=>{})})}})});nf.exports={LDD_PATH:gb,SELF_PATH:Tb,readFileSync:bb,readFile:vb}});var of=te((xZ,Hf)=>{"use strict";var Db=e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),r=e.readUInt16LE(54),a=e.readUInt16LE(56);for(let n=0;n<a;n++){let s=t+n*r;if(e.readUInt32LE(s)===3){let H=e.readUInt32LE(s+8),o=e.readUInt32LE(s+32);return e.subarray(H,H+o).toString().replace(/\0.*$/g,"")}}return null};Hf.exports={interpreterPath:Db}});var gi=te((NZ,bf)=>{"use strict";var cf=Pe("child_process"),{isLinux:sn,getReport:lf}=af(),{LDD_PATH:Ai,SELF_PATH:uf,readFile:Mo,readFileSync:Po}=sf(),{interpreterPath:df}=of(),Lr,Ar,gr,pf="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",na="",hf=()=>na||new Promise(e=>{cf.exec(pf,(t,r)=>{na=t?" ":r,e(na)})}),ff=()=>{if(!na)try{na=cf.execSync(pf,{encoding:"utf8"})}catch{na=" "}return na},Ur="glibc",Ef=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,ba="musl",Cb=e=>e.includes("libc.musl-")||e.includes("ld-musl-"),$f=()=>{let e=lf();return e.header&&e.header.glibcVersionRuntime?Ur:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(Cb)?ba:null},mf=e=>{let[t,r]=e.split(/[\r\n]+/);return t&&t.includes(Ur)?Ur:r&&r.includes(ba)?ba:null},If=e=>{if(e){if(e.includes("/ld-musl-"))return ba;if(e.includes("/ld-linux-"))return Ur}return null},Sf=e=>(e=e.toString(),e.includes("musl")?ba:e.includes("GNU C Library")?Ur:null),xb=async()=>{if(Ar!==void 0)return Ar;Ar=null;try{let e=await Mo(Ai);Ar=Sf(e)}catch{}return Ar},Nb=()=>{if(Ar!==void 0)return Ar;Ar=null;try{let e=Po(Ai);Ar=Sf(e)}catch{}return Ar},wb=async()=>{if(Lr!==void 0)return Lr;Lr=null;try{let e=await Mo(uf),t=df(e);Lr=If(t)}catch{}return Lr},yb=()=>{if(Lr!==void 0)return Lr;Lr=null;try{let e=Po(uf),t=df(e);Lr=If(t)}catch{}return Lr},Lf=async()=>{let e=null;if(sn()&&(e=await wb(),!e&&(e=await xb(),e||(e=$f()),!e))){let t=await hf();e=mf(t)}return e},Af=()=>{let e=null;if(sn()&&(e=yb(),!e&&(e=Nb(),e||(e=$f()),!e))){let t=ff();e=mf(t)}return e},Bb=async()=>sn()&&await Lf()!==Ur,Mb=()=>sn()&&Af()!==Ur,Pb=async()=>{if(gr!==void 0)return gr;gr=null;try{let t=(await Mo(Ai)).match(Ef);t&&(gr=t[1])}catch{}return gr},Rb=()=>{if(gr!==void 0)return gr;gr=null;try{let t=Po(Ai).match(Ef);t&&(gr=t[1])}catch{}return gr},gf=()=>{let e=lf();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},_f=e=>e.trim().split(/\s+/)[1],Tf=e=>{let[t,r,a]=e.split(/[\r\n]+/);return t&&t.includes(Ur)?_f(t):r&&a&&r.includes(ba)?_f(a):null},kb=async()=>{let e=null;if(sn()&&(e=await Pb(),e||(e=gf()),!e)){let t=await hf();e=Tf(t)}return e},Ob=()=>{let e=null;if(sn()&&(e=Rb(),e||(e=gf()),!e)){let t=ff();e=Tf(t)}return e};bf.exports={GLIBC:Ur,MUSL:ba,family:Lf,familySync:Af,isNonGlibcLinux:Bb,isNonGlibcLinuxSync:Mb,version:kb,versionSync:Ob}});var _s=te((wZ,vf)=>{"use strict";var Gb=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};vf.exports=Gb});var Ti=te((yZ,Df)=>{"use strict";var Fb="2.0.0",Zb=Number.MAX_SAFE_INTEGER||9007199254740991,Ub=16,Kb=250,Wb=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Df.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Ub,MAX_SAFE_BUILD_LENGTH:Kb,MAX_SAFE_INTEGER:Zb,RELEASE_TYPES:Wb,SEMVER_SPEC_VERSION:Fb,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var cs=te((Tr,Cf)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:Ro,MAX_SAFE_BUILD_LENGTH:Vb,MAX_LENGTH:jb}=Ti(),qb=_s();Tr=Cf.exports={};var Xb=Tr.re=[],zb=Tr.safeRe=[],re=Tr.src=[],Jb=Tr.safeSrc=[],ae=Tr.t={},Qb=0,ko="[a-zA-Z0-9-]",Yb=[["\\s",1],["\\d",jb],[ko,Vb]],ev=e=>{for(let[t,r]of Yb)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},Ee=(e,t,r)=>{let a=ev(t),n=Qb++;qb(e,n,t),ae[e]=n,re[n]=t,Jb[n]=a,Xb[n]=new RegExp(t,r?"g":void 0),zb[n]=new RegExp(a,r?"g":void 0)};Ee("NUMERICIDENTIFIER","0|[1-9]\\d*");Ee("NUMERICIDENTIFIERLOOSE","\\d+");Ee("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${ko}*`);Ee("MAINVERSION",`(${re[ae.NUMERICIDENTIFIER]})\\.(${re[ae.NUMERICIDENTIFIER]})\\.(${re[ae.NUMERICIDENTIFIER]})`);Ee("MAINVERSIONLOOSE",`(${re[ae.NUMERICIDENTIFIERLOOSE]})\\.(${re[ae.NUMERICIDENTIFIERLOOSE]})\\.(${re[ae.NUMERICIDENTIFIERLOOSE]})`);Ee("PRERELEASEIDENTIFIER",`(?:${re[ae.NONNUMERICIDENTIFIER]}|${re[ae.NUMERICIDENTIFIER]})`);Ee("PRERELEASEIDENTIFIERLOOSE",`(?:${re[ae.NONNUMERICIDENTIFIER]}|${re[ae.NUMERICIDENTIFIERLOOSE]})`);Ee("PRERELEASE",`(?:-(${re[ae.PRERELEASEIDENTIFIER]}(?:\\.${re[ae.PRERELEASEIDENTIFIER]})*))`);Ee("PRERELEASELOOSE",`(?:-?(${re[ae.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${re[ae.PRERELEASEIDENTIFIERLOOSE]})*))`);Ee("BUILDIDENTIFIER",`${ko}+`);Ee("BUILD",`(?:\\+(${re[ae.BUILDIDENTIFIER]}(?:\\.${re[ae.BUILDIDENTIFIER]})*))`);Ee("FULLPLAIN",`v?${re[ae.MAINVERSION]}${re[ae.PRERELEASE]}?${re[ae.BUILD]}?`);Ee("FULL",`^${re[ae.FULLPLAIN]}$`);Ee("LOOSEPLAIN",`[v=\\s]*${re[ae.MAINVERSIONLOOSE]}${re[ae.PRERELEASELOOSE]}?${re[ae.BUILD]}?`);Ee("LOOSE",`^${re[ae.LOOSEPLAIN]}$`);Ee("GTLT","((?:<|>)?=?)");Ee("XRANGEIDENTIFIERLOOSE",`${re[ae.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);Ee("XRANGEIDENTIFIER",`${re[ae.NUMERICIDENTIFIER]}|x|X|\\*`);Ee("XRANGEPLAIN",`[v=\\s]*(${re[ae.XRANGEIDENTIFIER]})(?:\\.(${re[ae.XRANGEIDENTIFIER]})(?:\\.(${re[ae.XRANGEIDENTIFIER]})(?:${re[ae.PRERELEASE]})?${re[ae.BUILD]}?)?)?`);Ee("XRANGEPLAINLOOSE",`[v=\\s]*(${re[ae.XRANGEIDENTIFIERLOOSE]})(?:\\.(${re[ae.XRANGEIDENTIFIERLOOSE]})(?:\\.(${re[ae.XRANGEIDENTIFIERLOOSE]})(?:${re[ae.PRERELEASELOOSE]})?${re[ae.BUILD]}?)?)?`);Ee("XRANGE",`^${re[ae.GTLT]}\\s*${re[ae.XRANGEPLAIN]}$`);Ee("XRANGELOOSE",`^${re[ae.GTLT]}\\s*${re[ae.XRANGEPLAINLOOSE]}$`);Ee("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Ro}})(?:\\.(\\d{1,${Ro}}))?(?:\\.(\\d{1,${Ro}}))?`);Ee("COERCE",`${re[ae.COERCEPLAIN]}(?:$|[^\\d])`);Ee("COERCEFULL",re[ae.COERCEPLAIN]+`(?:${re[ae.PRERELEASE]})?(?:${re[ae.BUILD]})?(?:$|[^\\d])`);Ee("COERCERTL",re[ae.COERCE],!0);Ee("COERCERTLFULL",re[ae.COERCEFULL],!0);Ee("LONETILDE","(?:~>?)");Ee("TILDETRIM",`(\\s*)${re[ae.LONETILDE]}\\s+`,!0);Tr.tildeTrimReplace="$1~";Ee("TILDE",`^${re[ae.LONETILDE]}${re[ae.XRANGEPLAIN]}$`);Ee("TILDELOOSE",`^${re[ae.LONETILDE]}${re[ae.XRANGEPLAINLOOSE]}$`);Ee("LONECARET","(?:\\^)");Ee("CARETTRIM",`(\\s*)${re[ae.LONECARET]}\\s+`,!0);Tr.caretTrimReplace="$1^";Ee("CARET",`^${re[ae.LONECARET]}${re[ae.XRANGEPLAIN]}$`);Ee("CARETLOOSE",`^${re[ae.LONECARET]}${re[ae.XRANGEPLAINLOOSE]}$`);Ee("COMPARATORLOOSE",`^${re[ae.GTLT]}\\s*(${re[ae.LOOSEPLAIN]})$|^$`);Ee("COMPARATOR",`^${re[ae.GTLT]}\\s*(${re[ae.FULLPLAIN]})$|^$`);Ee("COMPARATORTRIM",`(\\s*)${re[ae.GTLT]}\\s*(${re[ae.LOOSEPLAIN]}|${re[ae.XRANGEPLAIN]})`,!0);Tr.comparatorTrimReplace="$1$2$3";Ee("HYPHENRANGE",`^\\s*(${re[ae.XRANGEPLAIN]})\\s+-\\s+(${re[ae.XRANGEPLAIN]})\\s*$`);Ee("HYPHENRANGELOOSE",`^\\s*(${re[ae.XRANGEPLAINLOOSE]})\\s+-\\s+(${re[ae.XRANGEPLAINLOOSE]})\\s*$`);Ee("STAR","(<|>)?=?\\s*\\*");Ee("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");Ee("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var bi=te((BZ,xf)=>{"use strict";var tv=Object.freeze({loose:!0}),rv=Object.freeze({}),av=e=>e?typeof e!="object"?tv:e:rv;xf.exports=av});var Bf=te((MZ,yf)=>{"use strict";var Nf=/^[0-9]+$/,wf=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;let r=Nf.test(e),a=Nf.test(t);return r&&a&&(e=+e,t=+t),e===t?0:r&&!a?-1:a&&!r?1:e<t?-1:1},nv=(e,t)=>wf(t,e);yf.exports={compareIdentifiers:wf,rcompareIdentifiers:nv}});var Hn=te((PZ,Pf)=>{"use strict";var vi=_s(),{MAX_LENGTH:Mf,MAX_SAFE_INTEGER:Di}=Ti(),{safeRe:Ci,t:xi}=cs(),sv=bi(),{compareIdentifiers:Oo}=Bf(),Go=class e{constructor(t,r){if(r=sv(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>Mf)throw new TypeError(`version is longer than ${Mf} characters`);vi("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let a=t.trim().match(r.loose?Ci[xi.LOOSE]:Ci[xi.FULL]);if(!a)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+a[1],this.minor=+a[2],this.patch=+a[3],this.major>Di||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Di||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Di||this.patch<0)throw new TypeError("Invalid patch version");a[4]?this.prerelease=a[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let s=+n;if(s>=0&&s<Di)return s}return n}):this.prerelease=[],this.build=a[5]?a[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(vi("SemVer.compare",this.version,this.options,t),!(t instanceof e)){if(typeof t=="string"&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let a=this.prerelease[r],n=t.prerelease[r];if(vi("prerelease compare",r,a,n),a===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(a===void 0)return-1;if(a===n)continue;return Oo(a,n)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let a=this.build[r],n=t.build[r];if(vi("build compare",r,a,n),a===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(a===void 0)return-1;if(a===n)continue;return Oo(a,n)}while(++r)}inc(t,r,a){if(t.startsWith("pre")){if(!r&&a===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?Ci[xi.PRERELEASELOOSE]:Ci[xi.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,a);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,a);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,a),this.inc("pre",r,a);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,a),this.inc("pre",r,a);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(a)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(r===this.prerelease.join(".")&&a===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let s=[r,n];a===!1&&(s=[r]),Oo(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Pf.exports=Go});var Of=te((RZ,kf)=>{"use strict";var Rf=Hn(),iv=(e,t,r=!1)=>{if(e instanceof Rf)return e;try{return new Rf(e,t)}catch(a){if(!r)return null;throw a}};kf.exports=iv});var Ff=te((kZ,Gf)=>{"use strict";var Hv=Hn(),ov=Of(),{safeRe:Ni,t:wi}=cs(),_v=(e,t)=>{if(e instanceof Hv)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?Ni[wi.COERCEFULL]:Ni[wi.COERCE]);else{let o=t.includePrerelease?Ni[wi.COERCERTLFULL]:Ni[wi.COERCERTL],_;for(;(_=o.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||_.index+_[0].length!==r.index+r[0].length)&&(r=_),o.lastIndex=_.index+_[1].length+_[2].length;o.lastIndex=-1}if(r===null)return null;let a=r[2],n=r[3]||"0",s=r[4]||"0",i=t.includePrerelease&&r[5]?`-${r[5]}`:"",H=t.includePrerelease&&r[6]?`+${r[6]}`:"";return ov(`${a}.${n}.${s}${i}${H}`,t)};Gf.exports=_v});var va=te((OZ,Uf)=>{"use strict";var Zf=Hn(),cv=(e,t,r)=>new Zf(e,r).compare(new Zf(t,r));Uf.exports=cv});var Fo=te((GZ,Kf)=>{"use strict";var lv=va(),uv=(e,t,r)=>lv(e,t,r)>=0;Kf.exports=uv});var Vf=te((FZ,Wf)=>{"use strict";var Zo=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(t,r)}return this}};Wf.exports=Zo});var qf=te((ZZ,jf)=>{"use strict";var dv=va(),pv=(e,t,r)=>dv(e,t,r)===0;jf.exports=pv});var zf=te((UZ,Xf)=>{"use strict";var hv=va(),fv=(e,t,r)=>hv(e,t,r)!==0;Xf.exports=fv});var Qf=te((KZ,Jf)=>{"use strict";var Ev=va(),$v=(e,t,r)=>Ev(e,t,r)>0;Jf.exports=$v});var eE=te((WZ,Yf)=>{"use strict";var mv=va(),Iv=(e,t,r)=>mv(e,t,r)<0;Yf.exports=Iv});var rE=te((VZ,tE)=>{"use strict";var Sv=va(),Lv=(e,t,r)=>Sv(e,t,r)<=0;tE.exports=Lv});var nE=te((jZ,aE)=>{"use strict";var Av=qf(),gv=zf(),Tv=Qf(),bv=Fo(),vv=eE(),Dv=rE(),Cv=(e,t,r,a)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return Av(e,r,a);case"!=":return gv(e,r,a);case">":return Tv(e,r,a);case">=":return bv(e,r,a);case"<":return vv(e,r,a);case"<=":return Dv(e,r,a);default:throw new TypeError(`Invalid operator: ${t}`)}};aE.exports=Cv});var lE=te((qZ,cE)=>{"use strict";var ls=Symbol("SemVer ANY"),Wo=class e{static get ANY(){return ls}constructor(t,r){if(r=sE(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),Ko("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===ls?this.value="":this.value=this.operator+this.semver.version,Ko("comp",this)}parse(t){let r=this.options.loose?iE[HE.COMPARATORLOOSE]:iE[HE.COMPARATOR],a=t.match(r);if(!a)throw new TypeError(`Invalid comparator: ${t}`);this.operator=a[1]!==void 0?a[1]:"",this.operator==="="&&(this.operator=""),a[2]?this.semver=new oE(a[2],this.options.loose):this.semver=ls}toString(){return this.value}test(t){if(Ko("Comparator.test",t,this.options.loose),this.semver===ls||t===ls)return!0;if(typeof t=="string")try{t=new oE(t,this.options)}catch{return!1}return Uo(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new _E(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new _E(this.value,r).test(t.semver):(r=sE(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||Uo(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||Uo(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};cE.exports=Wo;var sE=bi(),{safeRe:iE,t:HE}=cs(),Uo=nE(),Ko=_s(),oE=Hn(),_E=Vo()});var Vo=te((XZ,hE)=>{"use strict";var xv=/\s+/g,jo=class e{constructor(t,r){if(r=wv(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof qo)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(xv," "),this.set=this.raw.split("||").map(a=>this.parseRange(a.trim())).filter(a=>a.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let a=this.set[0];if(this.set=this.set.filter(n=>!dE(n[0])),this.set.length===0)this.set=[a];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&Ov(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let r=this.set[t];for(let a=0;a<r.length;a++)a>0&&(this.formatted+=" "),this.formatted+=r[a].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let a=((this.options.includePrerelease&&Rv)|(this.options.loose&&kv))+":"+t,n=uE.get(a);if(n)return n;let s=this.options.loose,i=s?Pt[At.HYPHENRANGELOOSE]:Pt[At.HYPHENRANGE];t=t.replace(i,Xv(this.options.includePrerelease)),Ke("hyphen replace",t),t=t.replace(Pt[At.COMPARATORTRIM],Bv),Ke("comparator trim",t),t=t.replace(Pt[At.TILDETRIM],Mv),Ke("tilde trim",t),t=t.replace(Pt[At.CARETTRIM],Pv),Ke("caret trim",t);let H=t.split(" ").map(l=>Gv(l,this.options)).join(" ").split(/\s+/).map(l=>qv(l,this.options));s&&(H=H.filter(l=>(Ke("loose invalid filter",l,this.options),!!l.match(Pt[At.COMPARATORLOOSE])))),Ke("range list",H);let o=new Map,_=H.map(l=>new qo(l,this.options));for(let l of _){if(dE(l))return[l];o.set(l.value,l)}o.size>1&&o.has("")&&o.delete("");let c=[...o.values()];return uE.set(a,c),c}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(a=>pE(a,r)&&t.set.some(n=>pE(n,r)&&a.every(s=>n.every(i=>s.intersects(i,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new yv(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(zv(this.set[r],t,this.options))return!0;return!1}};hE.exports=jo;var Nv=Vf(),uE=new Nv,wv=bi(),qo=lE(),Ke=_s(),yv=Hn(),{safeRe:Pt,t:At,comparatorTrimReplace:Bv,tildeTrimReplace:Mv,caretTrimReplace:Pv}=cs(),{FLAG_INCLUDE_PRERELEASE:Rv,FLAG_LOOSE:kv}=Ti(),dE=e=>e.value==="<0.0.0-0",Ov=e=>e.value==="",pE=(e,t)=>{let r=!0,a=e.slice(),n=a.pop();for(;r&&a.length;)r=a.every(s=>n.intersects(s,t)),n=a.pop();return r},Gv=(e,t)=>(e=e.replace(Pt[At.BUILD],""),Ke("comp",e,t),e=Uv(e,t),Ke("caret",e),e=Fv(e,t),Ke("tildes",e),e=Wv(e,t),Ke("xrange",e),e=jv(e,t),Ke("stars",e),e),Rt=e=>!e||e.toLowerCase()==="x"||e==="*",Fv=(e,t)=>e.trim().split(/\s+/).map(r=>Zv(r,t)).join(" "),Zv=(e,t)=>{let r=t.loose?Pt[At.TILDELOOSE]:Pt[At.TILDE];return e.replace(r,(a,n,s,i,H)=>{Ke("tilde",e,a,n,s,i,H);let o;return Rt(n)?o="":Rt(s)?o=`>=${n}.0.0 <${+n+1}.0.0-0`:Rt(i)?o=`>=${n}.${s}.0 <${n}.${+s+1}.0-0`:H?(Ke("replaceTilde pr",H),o=`>=${n}.${s}.${i}-${H} <${n}.${+s+1}.0-0`):o=`>=${n}.${s}.${i} <${n}.${+s+1}.0-0`,Ke("tilde return",o),o})},Uv=(e,t)=>e.trim().split(/\s+/).map(r=>Kv(r,t)).join(" "),Kv=(e,t)=>{Ke("caret",e,t);let r=t.loose?Pt[At.CARETLOOSE]:Pt[At.CARET],a=t.includePrerelease?"-0":"";return e.replace(r,(n,s,i,H,o)=>{Ke("caret",e,n,s,i,H,o);let _;return Rt(s)?_="":Rt(i)?_=`>=${s}.0.0${a} <${+s+1}.0.0-0`:Rt(H)?s==="0"?_=`>=${s}.${i}.0${a} <${s}.${+i+1}.0-0`:_=`>=${s}.${i}.0${a} <${+s+1}.0.0-0`:o?(Ke("replaceCaret pr",o),s==="0"?i==="0"?_=`>=${s}.${i}.${H}-${o} <${s}.${i}.${+H+1}-0`:_=`>=${s}.${i}.${H}-${o} <${s}.${+i+1}.0-0`:_=`>=${s}.${i}.${H}-${o} <${+s+1}.0.0-0`):(Ke("no pr"),s==="0"?i==="0"?_=`>=${s}.${i}.${H}${a} <${s}.${i}.${+H+1}-0`:_=`>=${s}.${i}.${H}${a} <${s}.${+i+1}.0-0`:_=`>=${s}.${i}.${H} <${+s+1}.0.0-0`),Ke("caret return",_),_})},Wv=(e,t)=>(Ke("replaceXRanges",e,t),e.split(/\s+/).map(r=>Vv(r,t)).join(" ")),Vv=(e,t)=>{e=e.trim();let r=t.loose?Pt[At.XRANGELOOSE]:Pt[At.XRANGE];return e.replace(r,(a,n,s,i,H,o)=>{Ke("xRange",e,a,n,s,i,H,o);let _=Rt(s),c=_||Rt(i),l=c||Rt(H),d=l;return n==="="&&d&&(n=""),o=t.includePrerelease?"-0":"",_?n===">"||n==="<"?a="<0.0.0-0":a="*":n&&d?(c&&(i=0),H=0,n===">"?(n=">=",c?(s=+s+1,i=0,H=0):(i=+i+1,H=0)):n==="<="&&(n="<",c?s=+s+1:i=+i+1),n==="<"&&(o="-0"),a=`${n+s}.${i}.${H}${o}`):c?a=`>=${s}.0.0${o} <${+s+1}.0.0-0`:l&&(a=`>=${s}.${i}.0${o} <${s}.${+i+1}.0-0`),Ke("xRange return",a),a})},jv=(e,t)=>(Ke("replaceStars",e,t),e.trim().replace(Pt[At.STAR],"")),qv=(e,t)=>(Ke("replaceGTE0",e,t),e.trim().replace(Pt[t.includePrerelease?At.GTE0PRE:At.GTE0],"")),Xv=e=>(t,r,a,n,s,i,H,o,_,c,l,d)=>(Rt(a)?r="":Rt(n)?r=`>=${a}.0.0${e?"-0":""}`:Rt(s)?r=`>=${a}.${n}.0${e?"-0":""}`:i?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,Rt(_)?o="":Rt(c)?o=`<${+_+1}.0.0-0`:Rt(l)?o=`<${_}.${+c+1}.0-0`:d?o=`<=${_}.${c}.${l}-${d}`:e?o=`<${_}.${c}.${+l+1}-0`:o=`<=${o}`,`${r} ${o}`.trim()),zv=(e,t,r)=>{for(let a=0;a<e.length;a++)if(!e[a].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let a=0;a<e.length;a++)if(Ke(e[a].semver),e[a].semver!==qo.ANY&&e[a].semver.prerelease.length>0){let n=e[a].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0}});var EE=te((zZ,fE)=>{"use strict";var Jv=Vo(),Qv=(e,t,r)=>{try{t=new Jv(t,r)}catch{return!1}return t.test(e)};fE.exports=Qv});var Xo=te((JZ,Yv)=>{Yv.exports={name:"sharp",description:"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",version:"0.34.5",author:"Lovell Fuller <npm@lovell.info>",homepage:"https://sharp.pixelplumbing.com",contributors:["Pierre Inglebert <pierre.inglebert@gmail.com>","Jonathan Ong <jonathanrichardong@gmail.com>","Chanon Sajjamanochai <chanon.s@gmail.com>","Juliano Julio <julianojulio@gmail.com>","Daniel Gasienica <daniel@gasienica.ch>","Julian Walker <julian@fiftythree.com>","Amit Pitaru <pitaru.amit@gmail.com>","Brandon Aaron <hello.brandon@aaron.sh>","Andreas Lind <andreas@one.com>","Maurus Cuelenaere <mcuelenaere@gmail.com>","Linus Unneb\xE4ck <linus@folkdatorn.se>","Victor Mateevitsi <mvictoras@gmail.com>","Alaric Holloway <alaric.holloway@gmail.com>","Bernhard K. Weisshuhn <bkw@codingforce.com>","Chris Riley <criley@primedia.com>","David Carley <dacarley@gmail.com>","John Tobin <john@limelightmobileinc.com>","Kenton Gray <kentongray@gmail.com>","Felix B\xFCnemann <Felix.Buenemann@gmail.com>","Samy Al Zahrani <samyalzahrany@gmail.com>","Chintan Thakkar <lemnisk8@gmail.com>","F. Orlando Galashan <frulo@gmx.de>","Kleis Auke Wolthuizen <info@kleisauke.nl>","Matt Hirsch <mhirsch@media.mit.edu>","Matthias Thoemmes <thoemmes@gmail.com>","Patrick Paskaris <patrick@paskaris.gr>","J\xE9r\xE9my Lal <kapouer@melix.org>","Rahul Nanwani <r.nanwani@gmail.com>","Alice Monday <alice0meta@gmail.com>","Kristo Jorgenson <kristo.jorgenson@gmail.com>","YvesBos <yves_bos@outlook.com>","Guy Maliar <guy@tailorbrands.com>","Nicolas Coden <nicolas@ncoden.fr>","Matt Parrish <matt.r.parrish@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Matthew McEachen <matthew+github@mceachen.org>","Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>","Kenric D'Souza <kenric.dsouza@gmail.com>","Oleh Aleinyk <oleg.aleynik@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Andrea Bianco <andrea.bianco@unibas.ch>","Rik Heywood <rik@rik.org>","Thomas Parisot <hi@oncletom.io>","Nathan Graves <nathanrgraves+github@gmail.com>","Tom Lokhorst <tom@lokhorst.eu>","Espen Hovlandsdal <espen@hovlandsdal.com>","Sylvain Dumont <sylvain.dumont35@gmail.com>","Alun Davies <alun.owain.davies@googlemail.com>","Aidan Hoolachan <ajhoolachan21@gmail.com>","Axel Eirola <axel.eirola@iki.fi>","Freezy <freezy@xbmc.org>","Daiz <taneli.vatanen@gmail.com>","Julian Aubourg <j@ubourg.net>","Keith Belovay <keith@picthrive.com>","Michael B. Klein <mbklein@gmail.com>","Jordan Prudhomme <jordan@raboland.fr>","Ilya Ovdin <iovdin@gmail.com>","Andargor <andargor@yahoo.com>","Paul Neave <paul.neave@gmail.com>","Brendan Kennedy <brenwken@gmail.com>","Brychan Bennett-Odlum <git@brychan.io>","Edward Silverton <e.silverton@gmail.com>","Roman Malieiev <aromaleev@gmail.com>","Tomas Szabo <tomas.szabo@deftomat.com>","Robert O'Rourke <robert@o-rourke.org>","Guillermo Alfonso Varela Chouci\xF1o <guillevch@gmail.com>","Christian Flintrup <chr@gigahost.dk>","Manan Jadhav <manan@motionden.com>","Leon Radley <leon@radley.se>","alza54 <alza54@thiocod.in>","Jacob Smith <jacob@frende.me>","Michael Nutt <michael@nutt.im>","Brad Parham <baparham@gmail.com>","Taneli Vatanen <taneli.vatanen@gmail.com>","Joris Dugu\xE9 <zaruike10@gmail.com>","Chris Banks <christopher.bradley.banks@gmail.com>","Ompal Singh <ompal.hitm09@gmail.com>","Brodan <christopher.hranj@gmail.com>","Ankur Parihar <ankur.github@gmail.com>","Brahim Ait elhaj <brahima@gmail.com>","Mart Jansink <m.jansink@gmail.com>","Lachlan Newman <lachnewman007@gmail.com>","Dennis Beatty <dennis@dcbeatty.com>","Ingvar Stepanyan <me@rreverser.com>","Don Denton <don@happycollision.com>"],scripts:{build:"node install/build.js",install:"node install/check.js || npm run build",clean:"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",test:"npm run lint && npm run test-unit",lint:"npm run lint-cpp && npm run lint-js && npm run lint-types","lint-cpp":"cpplint --quiet src/*.h src/*.cc","lint-js":"biome lint","lint-types":"tsd --files ./test/types/sharp.test-d.ts","test-leak":"./test/leak/leak.sh","test-unit":"node --experimental-test-coverage test/unit.mjs","package-from-local-build":"node npm/from-local-build.js","package-release-notes":"node npm/release-notes.js","docs-build":"node docs/build.mjs","docs-serve":"cd docs && npm start","docs-publish":"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"},type:"commonjs",main:"lib/index.js",types:"lib/index.d.ts",files:["install","lib","src/*.{cc,h,gyp}"],repository:{type:"git",url:"git://github.com/lovell/sharp.git"},keywords:["jpeg","png","webp","avif","tiff","gif","svg","jp2","dzi","image","resize","thumbnail","crop","embed","libvips","vips"],dependencies:{"@img/colour":"^1.0.0","detect-libc":"^2.1.2",semver:"^7.7.3"},optionalDependencies:{"@img/sharp-darwin-arm64":"0.34.5","@img/sharp-darwin-x64":"0.34.5","@img/sharp-libvips-darwin-arm64":"1.2.4","@img/sharp-libvips-darwin-x64":"1.2.4","@img/sharp-libvips-linux-arm":"1.2.4","@img/sharp-libvips-linux-arm64":"1.2.4","@img/sharp-libvips-linux-ppc64":"1.2.4","@img/sharp-libvips-linux-riscv64":"1.2.4","@img/sharp-libvips-linux-s390x":"1.2.4","@img/sharp-libvips-linux-x64":"1.2.4","@img/sharp-libvips-linuxmusl-arm64":"1.2.4","@img/sharp-libvips-linuxmusl-x64":"1.2.4","@img/sharp-linux-arm":"0.34.5","@img/sharp-linux-arm64":"0.34.5","@img/sharp-linux-ppc64":"0.34.5","@img/sharp-linux-riscv64":"0.34.5","@img/sharp-linux-s390x":"0.34.5","@img/sharp-linux-x64":"0.34.5","@img/sharp-linuxmusl-arm64":"0.34.5","@img/sharp-linuxmusl-x64":"0.34.5","@img/sharp-wasm32":"0.34.5","@img/sharp-win32-arm64":"0.34.5","@img/sharp-win32-ia32":"0.34.5","@img/sharp-win32-x64":"0.34.5"},devDependencies:{"@biomejs/biome":"^2.3.4","@cpplint/cli":"^0.1.0","@emnapi/runtime":"^1.7.0","@img/sharp-libvips-dev":"1.2.4","@img/sharp-libvips-dev-wasm32":"1.2.4","@img/sharp-libvips-win32-arm64":"1.2.4","@img/sharp-libvips-win32-ia32":"1.2.4","@img/sharp-libvips-win32-x64":"1.2.4","@types/node":"*",emnapi:"^1.7.0","exif-reader":"^2.0.2","extract-zip":"^2.0.1",icc:"^3.0.0","jsdoc-to-markdown":"^9.1.3","node-addon-api":"^8.5.0","node-gyp":"^11.5.0","tar-fs":"^3.1.1",tsd:"^0.33.0"},license:"Apache-2.0",engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},config:{libvips:">=8.17.3"},funding:{url:"https://opencollective.com/libvips"}}});var Jo=te((QZ,vE)=>{"use strict";var{spawnSync:yi}=Pe("child_process"),{createHash:eD}=Pe("crypto"),SE=Ff(),tD=Fo(),rD=EE(),$E=gi(),{config:aD,engines:mE,optionalDependencies:nD}=Xo(),sD=process.env.npm_package_config_libvips||aD.libvips,LE=SE(sD).version,iD=["darwin-arm64","darwin-x64","linux-arm","linux-arm64","linux-ppc64","linux-riscv64","linux-s390x","linux-x64","linuxmusl-arm64","linuxmusl-x64","win32-arm64","win32-ia32","win32-x64"],Bi={encoding:"utf8",shell:!0},HD=e=>{e instanceof Error?console.error(`sharp: Installation error: ${e.message}`):console.log(`sharp: ${e}`)},AE=()=>$E.isNonGlibcLinuxSync()?$E.familySync():"",oD=()=>`${process.platform}${AE()}-${process.arch}`,on=()=>{if(gE())return"wasm32";let{npm_config_arch:e,npm_config_platform:t,npm_config_libc:r}=process.env,a=typeof r=="string"?r:AE();return`${t||process.platform}${a}-${e||process.arch}`},_D=()=>{try{return Pe(`@img/sharp-libvips-dev-${on()}/include`)}catch{try{return Pe("@img/sharp-libvips-dev/include")}catch{}}return""},cD=()=>{try{return Pe("@img/sharp-libvips-dev/cplusplus")}catch{}return""},lD=()=>{try{return Pe(`@img/sharp-libvips-dev-${on()}/lib`)}catch{try{return Pe(`@img/sharp-libvips-${on()}/lib`)}catch{}}return""},uD=()=>{if(process.release?.name==="node"&&process.versions&&!rD(process.versions.node,mE.node))return{found:process.versions.node,expected:mE.node}},gE=()=>{let{CC:e}=process.env;return!!e?.endsWith("/emcc")},dD=()=>process.platform==="darwin"&&process.arch==="x64"?(yi("sysctl sysctl.proc_translated",Bi).stdout||"").trim()==="sysctl.proc_translated: 1":!1,IE=e=>eD("sha512").update(e).digest("hex"),pD=()=>{try{let e=IE(`imgsharp-libvips-${on()}`),t=SE(nD[`@img/sharp-libvips-${on()}`],{includePrerelease:!0}).version;return IE(`${e}npm:${t}`).slice(0,10)}catch{}return""},hD=()=>yi(`node-gyp rebuild --directory=src ${gE()?"--nodedir=emscripten":""}`,{...Bi,stdio:"inherit"}).status,TE=()=>process.platform!=="win32"?(yi("pkg-config --modversion vips-cpp",{...Bi,env:{...process.env,PKG_CONFIG_PATH:bE()}}).stdout||"").trim():"",bE=()=>process.platform!=="win32"?[(yi('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',Bi).stdout||"").trim(),process.env.PKG_CONFIG_PATH,"/usr/local/lib/pkgconfig","/usr/lib/pkgconfig","/usr/local/libdata/pkgconfig","/usr/libdata/pkgconfig"].filter(Boolean).join(":"):"",zo=(e,t,r)=>(r&&r(`Detected ${t}, skipping search for globally-installed libvips`),e),fD=e=>{if(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)return zo(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",e);if(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)return zo(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",e);if(dD())return zo(!1,"Rosetta",e);let t=TE();return!!t&&tD(t,LE)};vE.exports={minimumLibvipsVersion:LE,prebuiltPlatforms:iD,buildPlatformArch:on,buildSharpLibvipsIncludeDir:_D,buildSharpLibvipsCPlusPlusDir:cD,buildSharpLibvipsLibDir:lD,isUnsupportedNodeRuntime:uD,runtimePlatformArch:oD,log:HD,yarnLocator:pD,spawnRebuild:hD,globalLibvipsVersion:TE,pkgConfigPath:bE,useGlobalLibvips:fD}});var ds=te((e7,CE)=>{"use strict";var{familySync:ED,versionSync:$D}=gi(),{runtimePlatformArch:mD,isUnsupportedNodeRuntime:DE,prebuiltPlatforms:ID,minimumLibvipsVersion:SD}=Jo(),Da=mD(),LD=[`../src/build/Release/sharp-${Da}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${Da}/sharp.node`,"@img/sharp-wasm32/sharp.node"],Qo,_n,us=[];for(Qo of LD)try{_n=Pe(Qo);break}catch(e){us.push(e)}if(_n&&Qo.startsWith("@img/sharp-linux-x64")&&!_n._isUsingX64V2()){let e=new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");e.code="Unsupported CPU",us.push(e),_n=null}if(_n)CE.exports=_n;else{let[e,t,r]=["linux","darwin","win32"].map(s=>Da.startsWith(s)),a=[`Could not load the "sharp" module using the ${Da} runtime`];us.forEach(s=>{s.code!=="MODULE_NOT_FOUND"&&a.push(`${s.code}: ${s.message}`)});let n=us.map(s=>s.message).join(" ");if(a.push("Possible solutions:"),DE()){let{found:s,expected:i}=DE();a.push("- Please upgrade Node.js:",` Found ${s}`,` Requires ${i}`)}else if(ID.includes(Da)){let[s,i]=Da.split("-"),H=s.endsWith("musl")?" --libc=musl":"";a.push("- Ensure optional dependencies can be installed:"," npm install --include=optional sharp","- Ensure your package manager supports multi-platform installation:"," See https://sharp.pixelplumbing.com/install#cross-platform","- Add platform-specific dependencies:",` npm install --os=${s.replace("musl","")}${H} --cpu=${i} sharp`)}else a.push(`- Manually install libvips >= ${SD}`,"- Add experimental WebAssembly-based dependencies:"," npm install --cpu=wasm32 sharp"," npm install @img/sharp-wasm32");if(e&&/(symbol not found|CXXABI_)/i.test(n))try{let{config:s}=Pe(`@img/sharp-libvips-${Da}/package`),i=`${ED()} ${$D()}`,H=`${s.musl?"musl":"glibc"} ${s.musl||s.glibc}`;a.push("- Update your OS:",` Found ${i}`,` Requires ${H}`)}catch{}throw e&&/\/snap\/core[0-9]{2}/.test(n)&&a.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node"),t&&/Incompatible library version/.test(n)&&a.push("- Update Homebrew:"," brew update && brew upgrade vips"),us.some(s=>s.code==="ERR_DLOPEN_DISABLED")&&a.push("- Run Node.js without using the --no-addons flag"),r&&/The specified procedure could not be found/.test(n)&&a.push("- Using the canvas package on Windows?"," See https://sharp.pixelplumbing.com/install#canvas-and-windows","- Check for outdated versions of sharp in the dependency tree:"," npm ls sharp"),a.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),new Error(a.join(`
|
|
2
|
+
`))}});var NE=te((r7,xE)=>{"use strict";var AD=Pe("util"),Yo=Pe("stream"),gD=Sr();ds();var TD=AD.debuglog("sharp"),bD=e=>{Ca.queue.emit("change",e)},Ca=function(e,t){if(arguments.length===1&&!gD.defined(e))throw new Error("Invalid input");return this instanceof Ca?(Yo.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:r=>{this.emit("warning",r),TD(r)},queueListener:bD},this.options.input=this._createInputDescriptor(e,t,{allowStream:!0}),this):new Ca(e,t)};Object.setPrototypeOf(Ca.prototype,Yo.Duplex.prototype);Object.setPrototypeOf(Ca,Yo.Duplex);function vD(){let e=this.constructor.call(),{debuglog:t,queueListener:r,...a}=this.options;return e.options=structuredClone(a),e.options.debuglog=t,e.options.queueListener=r,this._isStreamInput()&&this.on("finish",()=>{this._flattenBufferIn(),e.options.input.buffer=this.options.input.buffer,e.emit("finish")}),e}Object.assign(Ca.prototype,{clone:vD});xE.exports=Ca});var BE=te((a7,yE)=>{"use strict";var x=Sr(),sa=ds(),DD={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},CD=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function wE(e){let t=CD.filter(r=>x.defined(e[r])).map(r=>[r,e[r]]);return t.length?Object.fromEntries(t):void 0}function xD(e,t,r){let a={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(x.string(e))a.file=e;else if(x.buffer(e)){if(e.length===0)throw Error("Input Buffer is empty");a.buffer=e}else if(x.arrayBuffer(e)){if(e.byteLength===0)throw Error("Input bit Array is empty");a.buffer=Buffer.from(e,0,e.byteLength)}else if(x.typedArray(e)){if(e.length===0)throw Error("Input Bit Array is empty");a.buffer=Buffer.from(e.buffer,e.byteOffset,e.byteLength)}else if(x.plainObject(e)&&!x.defined(t))t=e,wE(t)&&(a.buffer=[]);else if(!x.defined(e)&&!x.defined(t)&&x.object(r)&&r.allowStream)a.buffer=[];else if(Array.isArray(e))if(e.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=e.map(n=>this._createInputDescriptor(n));else throw new Error("Recursive join is unsupported");else throw new Error("Expected at least two images to join");else throw new Error(`Unsupported input '${e}' of type ${typeof e}${x.defined(t)?` when also providing options of type ${typeof t}`:""}`);if(x.object(t)){if(x.defined(t.failOnError))if(x.bool(t.failOnError))a.failOn=t.failOnError?"warning":"none";else throw x.invalidParameterError("failOnError","boolean",t.failOnError);if(x.defined(t.failOn))if(x.string(t.failOn)&&x.inArray(t.failOn,["none","truncated","error","warning"]))a.failOn=t.failOn;else throw x.invalidParameterError("failOn","one of: none, truncated, error, warning",t.failOn);if(x.defined(t.autoOrient))if(x.bool(t.autoOrient))a.autoOrient=t.autoOrient;else throw x.invalidParameterError("autoOrient","boolean",t.autoOrient);if(x.defined(t.density))if(x.inRange(t.density,1,1e5))a.density=t.density;else throw x.invalidParameterError("density","number between 1 and 100000",t.density);if(x.defined(t.ignoreIcc))if(x.bool(t.ignoreIcc))a.ignoreIcc=t.ignoreIcc;else throw x.invalidParameterError("ignoreIcc","boolean",t.ignoreIcc);if(x.defined(t.limitInputPixels))if(x.bool(t.limitInputPixels))a.limitInputPixels=t.limitInputPixels?16383**2:0;else if(x.integer(t.limitInputPixels)&&x.inRange(t.limitInputPixels,0,Number.MAX_SAFE_INTEGER))a.limitInputPixels=t.limitInputPixels;else throw x.invalidParameterError("limitInputPixels","positive integer",t.limitInputPixels);if(x.defined(t.unlimited))if(x.bool(t.unlimited))a.unlimited=t.unlimited;else throw x.invalidParameterError("unlimited","boolean",t.unlimited);if(x.defined(t.sequentialRead))if(x.bool(t.sequentialRead))a.sequentialRead=t.sequentialRead;else throw x.invalidParameterError("sequentialRead","boolean",t.sequentialRead);if(x.defined(t.raw)){if(x.object(t.raw)&&x.integer(t.raw.width)&&t.raw.width>0&&x.integer(t.raw.height)&&t.raw.height>0&&x.integer(t.raw.channels)&&x.inRange(t.raw.channels,1,4))switch(a.rawWidth=t.raw.width,a.rawHeight=t.raw.height,a.rawChannels=t.raw.channels,e.constructor){case Uint8Array:case Uint8ClampedArray:a.rawDepth="uchar";break;case Int8Array:a.rawDepth="char";break;case Uint16Array:a.rawDepth="ushort";break;case Int16Array:a.rawDepth="short";break;case Uint32Array:a.rawDepth="uint";break;case Int32Array:a.rawDepth="int";break;case Float32Array:a.rawDepth="float";break;case Float64Array:a.rawDepth="double";break;default:a.rawDepth="uchar";break}else throw new Error("Expected width, height and channels for raw pixel input");if(a.rawPremultiplied=!1,x.defined(t.raw.premultiplied))if(x.bool(t.raw.premultiplied))a.rawPremultiplied=t.raw.premultiplied;else throw x.invalidParameterError("raw.premultiplied","boolean",t.raw.premultiplied);if(a.rawPageHeight=0,x.defined(t.raw.pageHeight))if(x.integer(t.raw.pageHeight)&&t.raw.pageHeight>0&&t.raw.pageHeight<=t.raw.height){if(t.raw.height%t.raw.pageHeight!==0)throw new Error(`Expected raw.height ${t.raw.height} to be a multiple of raw.pageHeight ${t.raw.pageHeight}`);a.rawPageHeight=t.raw.pageHeight}else throw x.invalidParameterError("raw.pageHeight","positive integer",t.raw.pageHeight)}if(x.defined(t.animated))if(x.bool(t.animated))a.pages=t.animated?-1:1;else throw x.invalidParameterError("animated","boolean",t.animated);if(x.defined(t.pages))if(x.integer(t.pages)&&x.inRange(t.pages,-1,1e5))a.pages=t.pages;else throw x.invalidParameterError("pages","integer between -1 and 100000",t.pages);if(x.defined(t.page))if(x.integer(t.page)&&x.inRange(t.page,0,1e5))a.page=t.page;else throw x.invalidParameterError("page","integer between 0 and 100000",t.page);if(x.object(t.openSlide)&&x.defined(t.openSlide.level))if(x.integer(t.openSlide.level)&&x.inRange(t.openSlide.level,0,256))a.openSlideLevel=t.openSlide.level;else throw x.invalidParameterError("openSlide.level","integer between 0 and 256",t.openSlide.level);else if(x.defined(t.level))if(x.integer(t.level)&&x.inRange(t.level,0,256))a.openSlideLevel=t.level;else throw x.invalidParameterError("level","integer between 0 and 256",t.level);if(x.object(t.tiff)&&x.defined(t.tiff.subifd))if(x.integer(t.tiff.subifd)&&x.inRange(t.tiff.subifd,-1,1e5))a.tiffSubifd=t.tiff.subifd;else throw x.invalidParameterError("tiff.subifd","integer between -1 and 100000",t.tiff.subifd);else if(x.defined(t.subifd))if(x.integer(t.subifd)&&x.inRange(t.subifd,-1,1e5))a.tiffSubifd=t.subifd;else throw x.invalidParameterError("subifd","integer between -1 and 100000",t.subifd);if(x.object(t.svg)){if(x.defined(t.svg.stylesheet))if(x.string(t.svg.stylesheet))a.svgStylesheet=t.svg.stylesheet;else throw x.invalidParameterError("svg.stylesheet","string",t.svg.stylesheet);if(x.defined(t.svg.highBitdepth))if(x.bool(t.svg.highBitdepth))a.svgHighBitdepth=t.svg.highBitdepth;else throw x.invalidParameterError("svg.highBitdepth","boolean",t.svg.highBitdepth)}if(x.object(t.pdf)&&x.defined(t.pdf.background)?a.pdfBackground=this._getBackgroundColourOption(t.pdf.background):x.defined(t.pdfBackground)&&(a.pdfBackground=this._getBackgroundColourOption(t.pdfBackground)),x.object(t.jp2)&&x.defined(t.jp2.oneshot))if(x.bool(t.jp2.oneshot))a.jp2Oneshot=t.jp2.oneshot;else throw x.invalidParameterError("jp2.oneshot","boolean",t.jp2.oneshot);if(x.defined(t.create))if(x.object(t.create)&&x.integer(t.create.width)&&t.create.width>0&&x.integer(t.create.height)&&t.create.height>0&&x.integer(t.create.channels)){if(a.createWidth=t.create.width,a.createHeight=t.create.height,a.createChannels=t.create.channels,a.createPageHeight=0,x.defined(t.create.pageHeight))if(x.integer(t.create.pageHeight)&&t.create.pageHeight>0&&t.create.pageHeight<=t.create.height){if(t.create.height%t.create.pageHeight!==0)throw new Error(`Expected create.height ${t.create.height} to be a multiple of create.pageHeight ${t.create.pageHeight}`);a.createPageHeight=t.create.pageHeight}else throw x.invalidParameterError("create.pageHeight","positive integer",t.create.pageHeight);if(x.defined(t.create.noise)){if(!x.object(t.create.noise))throw new Error("Expected noise to be an object");if(t.create.noise.type!=="gaussian")throw new Error("Only gaussian noise is supported at the moment");if(a.createNoiseType=t.create.noise.type,!x.inRange(t.create.channels,1,4))throw x.invalidParameterError("create.channels","number between 1 and 4",t.create.channels);if(a.createNoiseMean=128,x.defined(t.create.noise.mean))if(x.number(t.create.noise.mean)&&x.inRange(t.create.noise.mean,0,1e4))a.createNoiseMean=t.create.noise.mean;else throw x.invalidParameterError("create.noise.mean","number between 0 and 10000",t.create.noise.mean);if(a.createNoiseSigma=30,x.defined(t.create.noise.sigma))if(x.number(t.create.noise.sigma)&&x.inRange(t.create.noise.sigma,0,1e4))a.createNoiseSigma=t.create.noise.sigma;else throw x.invalidParameterError("create.noise.sigma","number between 0 and 10000",t.create.noise.sigma)}else if(x.defined(t.create.background)){if(!x.inRange(t.create.channels,3,4))throw x.invalidParameterError("create.channels","number between 3 and 4",t.create.channels);a.createBackground=this._getBackgroundColourOption(t.create.background)}else throw new Error("Expected valid noise or background to create a new input image");delete a.buffer}else throw new Error("Expected valid width, height and channels to create a new input image");if(x.defined(t.text))if(x.object(t.text)&&x.string(t.text.text)){if(a.textValue=t.text.text,x.defined(t.text.height)&&x.defined(t.text.dpi))throw new Error("Expected only one of dpi or height");if(x.defined(t.text.font))if(x.string(t.text.font))a.textFont=t.text.font;else throw x.invalidParameterError("text.font","string",t.text.font);if(x.defined(t.text.fontfile))if(x.string(t.text.fontfile))a.textFontfile=t.text.fontfile;else throw x.invalidParameterError("text.fontfile","string",t.text.fontfile);if(x.defined(t.text.width))if(x.integer(t.text.width)&&t.text.width>0)a.textWidth=t.text.width;else throw x.invalidParameterError("text.width","positive integer",t.text.width);if(x.defined(t.text.height))if(x.integer(t.text.height)&&t.text.height>0)a.textHeight=t.text.height;else throw x.invalidParameterError("text.height","positive integer",t.text.height);if(x.defined(t.text.align))if(x.string(t.text.align)&&x.string(this.constructor.align[t.text.align]))a.textAlign=this.constructor.align[t.text.align];else throw x.invalidParameterError("text.align","valid alignment",t.text.align);if(x.defined(t.text.justify))if(x.bool(t.text.justify))a.textJustify=t.text.justify;else throw x.invalidParameterError("text.justify","boolean",t.text.justify);if(x.defined(t.text.dpi))if(x.integer(t.text.dpi)&&x.inRange(t.text.dpi,1,1e6))a.textDpi=t.text.dpi;else throw x.invalidParameterError("text.dpi","integer between 1 and 1000000",t.text.dpi);if(x.defined(t.text.rgba))if(x.bool(t.text.rgba))a.textRgba=t.text.rgba;else throw x.invalidParameterError("text.rgba","bool",t.text.rgba);if(x.defined(t.text.spacing))if(x.integer(t.text.spacing)&&x.inRange(t.text.spacing,-1e6,1e6))a.textSpacing=t.text.spacing;else throw x.invalidParameterError("text.spacing","integer between -1000000 and 1000000",t.text.spacing);if(x.defined(t.text.wrap))if(x.string(t.text.wrap)&&x.inArray(t.text.wrap,["word","char","word-char","none"]))a.textWrap=t.text.wrap;else throw x.invalidParameterError("text.wrap","one of: word, char, word-char, none",t.text.wrap);delete a.buffer}else throw new Error("Expected a valid string to create an image with text.");if(x.defined(t.join))if(x.defined(this.options.join)){if(x.defined(t.join.animated))if(x.bool(t.join.animated))a.joinAnimated=t.join.animated;else throw x.invalidParameterError("join.animated","boolean",t.join.animated);if(x.defined(t.join.across))if(x.integer(t.join.across)&&x.inRange(t.join.across,1,1e6))a.joinAcross=t.join.across;else throw x.invalidParameterError("join.across","integer between 1 and 100000",t.join.across);if(x.defined(t.join.shim))if(x.integer(t.join.shim)&&x.inRange(t.join.shim,0,1e6))a.joinShim=t.join.shim;else throw x.invalidParameterError("join.shim","integer between 0 and 100000",t.join.shim);if(x.defined(t.join.background)&&(a.joinBackground=this._getBackgroundColourOption(t.join.background)),x.defined(t.join.halign))if(x.string(t.join.halign)&&x.string(this.constructor.align[t.join.halign]))a.joinHalign=this.constructor.align[t.join.halign];else throw x.invalidParameterError("join.halign","valid alignment",t.join.halign);if(x.defined(t.join.valign))if(x.string(t.join.valign)&&x.string(this.constructor.align[t.join.valign]))a.joinValign=this.constructor.align[t.join.valign];else throw x.invalidParameterError("join.valign","valid alignment",t.join.valign)}else throw new Error("Expected input to be an array of images to join")}else if(x.defined(t))throw new Error(`Invalid input options ${t}`);return a}function ND(e,t,r){Array.isArray(this.options.input.buffer)?x.buffer(e)?(this.options.input.buffer.length===0&&this.on("finish",()=>{this.streamInFinished=!0}),this.options.input.buffer.push(e),r()):r(new Error("Non-Buffer data on Writable Stream")):r(new Error("Unexpected data on Writable Stream"))}function wD(){this._isStreamInput()&&(this.options.input.buffer=Buffer.concat(this.options.input.buffer))}function yD(){return Array.isArray(this.options.input.buffer)}function BD(e){let t=Error();return x.fn(e)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),sa.metadata(this.options,(r,a)=>{r?e(x.nativeError(r,t)):e(null,a)})}):sa.metadata(this.options,(r,a)=>{r?e(x.nativeError(r,t)):e(null,a)}),this):this._isStreamInput()?new Promise((r,a)=>{let n=()=>{this._flattenBufferIn(),sa.metadata(this.options,(s,i)=>{s?a(x.nativeError(s,t)):r(i)})};this.writableFinished?n():this.once("finish",n)}):new Promise((r,a)=>{sa.metadata(this.options,(n,s)=>{n?a(x.nativeError(n,t)):r(s)})})}function MD(e){let t=Error();return x.fn(e)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),sa.stats(this.options,(r,a)=>{r?e(x.nativeError(r,t)):e(null,a)})}):sa.stats(this.options,(r,a)=>{r?e(x.nativeError(r,t)):e(null,a)}),this):this._isStreamInput()?new Promise((r,a)=>{this.on("finish",function(){this._flattenBufferIn(),sa.stats(this.options,(n,s)=>{n?a(x.nativeError(n,t)):r(s)})})}):new Promise((r,a)=>{sa.stats(this.options,(n,s)=>{n?a(x.nativeError(n,t)):r(s)})})}yE.exports=e=>{Object.assign(e.prototype,{_inputOptionsFromObject:wE,_createInputDescriptor:xD,_write:ND,_flattenBufferIn:wD,_isStreamInput:yD,metadata:BD,stats:MD}),e.align=DD}});var GE=te((n7,OE)=>{"use strict";var ie=Sr(),PE={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},RE={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},ME={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},kE={entropy:16,attention:17},e_={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},PD={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},RD={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function t_(e){return e.angle%360!==0||e.rotationAngle!==0}function Mi(e){return e.width!==-1||e.height!==-1}function kD(e,t,r){if(Mi(this.options)&&this.options.debuglog("ignoring previous resize options"),this.options.widthPost!==-1&&this.options.debuglog("operation order will be: extract, resize, extract"),ie.defined(e))if(ie.object(e)&&!ie.defined(r))r=e;else if(ie.integer(e)&&e>0)this.options.width=e;else throw ie.invalidParameterError("width","positive integer",e);else this.options.width=-1;if(ie.defined(t))if(ie.integer(t)&&t>0)this.options.height=t;else throw ie.invalidParameterError("height","positive integer",t);else this.options.height=-1;if(ie.object(r)){if(ie.defined(r.width))if(ie.integer(r.width)&&r.width>0)this.options.width=r.width;else throw ie.invalidParameterError("width","positive integer",r.width);if(ie.defined(r.height))if(ie.integer(r.height)&&r.height>0)this.options.height=r.height;else throw ie.invalidParameterError("height","positive integer",r.height);if(ie.defined(r.fit)){let a=RD[r.fit];if(ie.string(a))this.options.canvas=a;else throw ie.invalidParameterError("fit","valid fit",r.fit)}if(ie.defined(r.position)){let a=ie.integer(r.position)?r.position:kE[r.position]||RE[r.position]||PE[r.position];if(ie.integer(a)&&(ie.inRange(a,0,8)||ie.inRange(a,16,17)))this.options.position=a;else throw ie.invalidParameterError("position","valid position/gravity/strategy",r.position)}if(this._setBackgroundColourOption("resizeBackground",r.background),ie.defined(r.kernel))if(ie.string(e_[r.kernel]))this.options.kernel=e_[r.kernel];else throw ie.invalidParameterError("kernel","valid kernel name",r.kernel);ie.defined(r.withoutEnlargement)&&this._setBooleanOption("withoutEnlargement",r.withoutEnlargement),ie.defined(r.withoutReduction)&&this._setBooleanOption("withoutReduction",r.withoutReduction),ie.defined(r.fastShrinkOnLoad)&&this._setBooleanOption("fastShrinkOnLoad",r.fastShrinkOnLoad)}return t_(this.options)&&Mi(this.options)&&(this.options.rotateBefore=!0),this}function OD(e){if(ie.integer(e)&&e>0)this.options.extendTop=e,this.options.extendBottom=e,this.options.extendLeft=e,this.options.extendRight=e;else if(ie.object(e)){if(ie.defined(e.top))if(ie.integer(e.top)&&e.top>=0)this.options.extendTop=e.top;else throw ie.invalidParameterError("top","positive integer",e.top);if(ie.defined(e.bottom))if(ie.integer(e.bottom)&&e.bottom>=0)this.options.extendBottom=e.bottom;else throw ie.invalidParameterError("bottom","positive integer",e.bottom);if(ie.defined(e.left))if(ie.integer(e.left)&&e.left>=0)this.options.extendLeft=e.left;else throw ie.invalidParameterError("left","positive integer",e.left);if(ie.defined(e.right))if(ie.integer(e.right)&&e.right>=0)this.options.extendRight=e.right;else throw ie.invalidParameterError("right","positive integer",e.right);if(this._setBackgroundColourOption("extendBackground",e.background),ie.defined(e.extendWith))if(ie.string(ME[e.extendWith]))this.options.extendWith=ME[e.extendWith];else throw ie.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",e.extendWith)}else throw ie.invalidParameterError("extend","integer or object",e);return this}function GD(e){let t=Mi(this.options)||this.options.widthPre!==-1?"Post":"Pre";return this.options[`width${t}`]!==-1&&this.options.debuglog("ignoring previous extract options"),["left","top","width","height"].forEach(function(r){let a=e[r];if(ie.integer(a)&&a>=0)this.options[r+(r==="left"||r==="top"?"Offset":"")+t]=a;else throw ie.invalidParameterError(r,"integer",a)},this),t_(this.options)&&!Mi(this.options)&&(this.options.widthPre===-1||this.options.widthPost===-1)&&(this.options.rotateBefore=!0),this.options.input.autoOrient&&(this.options.orientBefore=!0),this}function FD(e){if(this.options.trimThreshold=10,ie.defined(e))if(ie.object(e)){if(ie.defined(e.background)&&this._setBackgroundColourOption("trimBackground",e.background),ie.defined(e.threshold))if(ie.number(e.threshold)&&e.threshold>=0)this.options.trimThreshold=e.threshold;else throw ie.invalidParameterError("threshold","positive number",e.threshold);ie.defined(e.lineArt)&&this._setBooleanOption("trimLineArt",e.lineArt)}else throw ie.invalidParameterError("trim","object",e);return t_(this.options)&&(this.options.rotateBefore=!0),this}OE.exports=e=>{Object.assign(e.prototype,{resize:kD,extend:OD,extract:GD,trim:FD}),e.gravity=PE,e.strategy=kE,e.kernel=e_,e.fit=PD,e.position=RE}});var ZE=te((s7,FE)=>{"use strict";var Oe=Sr(),r_={clear:"clear",source:"source",over:"over",in:"in",out:"out",atop:"atop",dest:"dest","dest-over":"dest-over","dest-in":"dest-in","dest-out":"dest-out","dest-atop":"dest-atop",xor:"xor",add:"add",saturate:"saturate",multiply:"multiply",screen:"screen",overlay:"overlay",darken:"darken",lighten:"lighten","colour-dodge":"colour-dodge","color-dodge":"colour-dodge","colour-burn":"colour-burn","color-burn":"colour-burn","hard-light":"hard-light","soft-light":"soft-light",difference:"difference",exclusion:"exclusion"};function ZD(e){if(!Array.isArray(e))throw Oe.invalidParameterError("images to composite","array",e);return this.options.composite=e.map(t=>{if(!Oe.object(t))throw Oe.invalidParameterError("image to composite","object",t);let r=this._inputOptionsFromObject(t),a={input:this._createInputDescriptor(t.input,r,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(Oe.defined(t.blend))if(Oe.string(r_[t.blend]))a.blend=r_[t.blend];else throw Oe.invalidParameterError("blend","valid blend name",t.blend);if(Oe.defined(t.tile))if(Oe.bool(t.tile))a.tile=t.tile;else throw Oe.invalidParameterError("tile","boolean",t.tile);if(Oe.defined(t.left))if(Oe.integer(t.left))a.left=t.left;else throw Oe.invalidParameterError("left","integer",t.left);if(Oe.defined(t.top))if(Oe.integer(t.top))a.top=t.top;else throw Oe.invalidParameterError("top","integer",t.top);if(Oe.defined(t.top)!==Oe.defined(t.left))throw new Error("Expected both left and top to be set");if(a.hasOffset=Oe.integer(t.top)&&Oe.integer(t.left),Oe.defined(t.gravity))if(Oe.integer(t.gravity)&&Oe.inRange(t.gravity,0,8))a.gravity=t.gravity;else if(Oe.string(t.gravity)&&Oe.integer(this.constructor.gravity[t.gravity]))a.gravity=this.constructor.gravity[t.gravity];else throw Oe.invalidParameterError("gravity","valid gravity",t.gravity);if(Oe.defined(t.premultiplied))if(Oe.bool(t.premultiplied))a.premultiplied=t.premultiplied;else throw Oe.invalidParameterError("premultiplied","boolean",t.premultiplied);return a}),this}FE.exports=e=>{e.prototype.composite=ZD,e.blend=r_}});var jE=te((i7,VE)=>{"use strict";var B=Sr(),UE={integer:"integer",float:"float",approximate:"approximate"};function UD(e,t){if(!B.defined(e))return this.autoOrient();if((this.options.angle||this.options.rotationAngle)&&(this.options.debuglog("ignoring previous rotate options"),this.options.angle=0,this.options.rotationAngle=0),B.integer(e)&&!(e%90))this.options.angle=e;else if(B.number(e))this.options.rotationAngle=e,B.object(t)&&t.background&&this._setBackgroundColourOption("rotationBackground",t.background);else throw B.invalidParameterError("angle","numeric",e);return this}function KD(){return this.options.input.autoOrient=!0,this}function WD(e){return this.options.flip=B.bool(e)?e:!0,this}function VD(e){return this.options.flop=B.bool(e)?e:!0,this}function jD(e,t){let r=[].concat(...e);if(r.length===4&&r.every(B.number))this.options.affineMatrix=r;else throw B.invalidParameterError("matrix","1x4 or 2x2 array",e);if(B.defined(t))if(B.object(t)){if(this._setBackgroundColourOption("affineBackground",t.background),B.defined(t.idx))if(B.number(t.idx))this.options.affineIdx=t.idx;else throw B.invalidParameterError("options.idx","number",t.idx);if(B.defined(t.idy))if(B.number(t.idy))this.options.affineIdy=t.idy;else throw B.invalidParameterError("options.idy","number",t.idy);if(B.defined(t.odx))if(B.number(t.odx))this.options.affineOdx=t.odx;else throw B.invalidParameterError("options.odx","number",t.odx);if(B.defined(t.ody))if(B.number(t.ody))this.options.affineOdy=t.ody;else throw B.invalidParameterError("options.ody","number",t.ody);if(B.defined(t.interpolator))if(B.inArray(t.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=t.interpolator;else throw B.invalidParameterError("options.interpolator","valid interpolator name",t.interpolator)}else throw B.invalidParameterError("options","object",t);return this}function qD(e,t,r){if(!B.defined(e))this.options.sharpenSigma=-1;else if(B.bool(e))this.options.sharpenSigma=e?-1:0;else if(B.number(e)&&B.inRange(e,.01,1e4)){if(this.options.sharpenSigma=e,B.defined(t))if(B.number(t)&&B.inRange(t,0,1e4))this.options.sharpenM1=t;else throw B.invalidParameterError("flat","number between 0 and 10000",t);if(B.defined(r))if(B.number(r)&&B.inRange(r,0,1e4))this.options.sharpenM2=r;else throw B.invalidParameterError("jagged","number between 0 and 10000",r)}else if(B.plainObject(e)){if(B.number(e.sigma)&&B.inRange(e.sigma,1e-6,10))this.options.sharpenSigma=e.sigma;else throw B.invalidParameterError("options.sigma","number between 0.000001 and 10",e.sigma);if(B.defined(e.m1))if(B.number(e.m1)&&B.inRange(e.m1,0,1e6))this.options.sharpenM1=e.m1;else throw B.invalidParameterError("options.m1","number between 0 and 1000000",e.m1);if(B.defined(e.m2))if(B.number(e.m2)&&B.inRange(e.m2,0,1e6))this.options.sharpenM2=e.m2;else throw B.invalidParameterError("options.m2","number between 0 and 1000000",e.m2);if(B.defined(e.x1))if(B.number(e.x1)&&B.inRange(e.x1,0,1e6))this.options.sharpenX1=e.x1;else throw B.invalidParameterError("options.x1","number between 0 and 1000000",e.x1);if(B.defined(e.y2))if(B.number(e.y2)&&B.inRange(e.y2,0,1e6))this.options.sharpenY2=e.y2;else throw B.invalidParameterError("options.y2","number between 0 and 1000000",e.y2);if(B.defined(e.y3))if(B.number(e.y3)&&B.inRange(e.y3,0,1e6))this.options.sharpenY3=e.y3;else throw B.invalidParameterError("options.y3","number between 0 and 1000000",e.y3)}else throw B.invalidParameterError("sigma","number between 0.01 and 10000",e);return this}function XD(e){if(!B.defined(e))this.options.medianSize=3;else if(B.integer(e)&&B.inRange(e,1,1e3))this.options.medianSize=e;else throw B.invalidParameterError("size","integer between 1 and 1000",e);return this}function zD(e){let t;if(B.number(e))t=e;else if(B.plainObject(e)){if(!B.number(e.sigma))throw B.invalidParameterError("options.sigma","number between 0.3 and 1000",t);if(t=e.sigma,"precision"in e)if(B.string(UE[e.precision]))this.options.precision=UE[e.precision];else throw B.invalidParameterError("precision","one of: integer, float, approximate",e.precision);if("minAmplitude"in e)if(B.number(e.minAmplitude)&&B.inRange(e.minAmplitude,.001,1))this.options.minAmpl=e.minAmplitude;else throw B.invalidParameterError("minAmplitude","number between 0.001 and 1",e.minAmplitude)}if(!B.defined(e))this.options.blurSigma=-1;else if(B.bool(e))this.options.blurSigma=e?-1:0;else if(B.number(t)&&B.inRange(t,.3,1e3))this.options.blurSigma=t;else throw B.invalidParameterError("sigma","number between 0.3 and 1000",t);return this}function KE(e){if(!B.defined(e))this.options.dilateWidth=1;else if(B.integer(e)&&e>0)this.options.dilateWidth=e;else throw B.invalidParameterError("dilate","positive integer",KE);return this}function WE(e){if(!B.defined(e))this.options.erodeWidth=1;else if(B.integer(e)&&e>0)this.options.erodeWidth=e;else throw B.invalidParameterError("erode","positive integer",WE);return this}function JD(e){return this.options.flatten=B.bool(e)?e:!0,B.object(e)&&this._setBackgroundColourOption("flattenBackground",e.background),this}function QD(){return this.options.unflatten=!0,this}function YD(e,t){if(!B.defined(e))this.options.gamma=2.2;else if(B.number(e)&&B.inRange(e,1,3))this.options.gamma=e;else throw B.invalidParameterError("gamma","number between 1.0 and 3.0",e);if(!B.defined(t))this.options.gammaOut=this.options.gamma;else if(B.number(t)&&B.inRange(t,1,3))this.options.gammaOut=t;else throw B.invalidParameterError("gammaOut","number between 1.0 and 3.0",t);return this}function eC(e){if(this.options.negate=B.bool(e)?e:!0,B.plainObject(e)&&"alpha"in e)if(B.bool(e.alpha))this.options.negateAlpha=e.alpha;else throw B.invalidParameterError("alpha","should be boolean value",e.alpha);return this}function tC(e){if(B.plainObject(e)){if(B.defined(e.lower))if(B.number(e.lower)&&B.inRange(e.lower,0,99))this.options.normaliseLower=e.lower;else throw B.invalidParameterError("lower","number between 0 and 99",e.lower);if(B.defined(e.upper))if(B.number(e.upper)&&B.inRange(e.upper,1,100))this.options.normaliseUpper=e.upper;else throw B.invalidParameterError("upper","number between 1 and 100",e.upper)}if(this.options.normaliseLower>=this.options.normaliseUpper)throw B.invalidParameterError("range","lower to be less than upper",`${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);return this.options.normalise=!0,this}function rC(e){return this.normalise(e)}function aC(e){if(B.plainObject(e)){if(B.integer(e.width)&&e.width>0)this.options.claheWidth=e.width;else throw B.invalidParameterError("width","integer greater than zero",e.width);if(B.integer(e.height)&&e.height>0)this.options.claheHeight=e.height;else throw B.invalidParameterError("height","integer greater than zero",e.height);if(B.defined(e.maxSlope))if(B.integer(e.maxSlope)&&B.inRange(e.maxSlope,0,100))this.options.claheMaxSlope=e.maxSlope;else throw B.invalidParameterError("maxSlope","integer between 0 and 100",e.maxSlope)}else throw B.invalidParameterError("options","plain object",e);return this}function nC(e){if(!B.object(e)||!Array.isArray(e.kernel)||!B.integer(e.width)||!B.integer(e.height)||!B.inRange(e.width,3,1001)||!B.inRange(e.height,3,1001)||e.height*e.width!==e.kernel.length)throw new Error("Invalid convolution kernel");return B.integer(e.scale)||(e.scale=e.kernel.reduce((t,r)=>t+r,0)),e.scale<1&&(e.scale=1),B.integer(e.offset)||(e.offset=0),this.options.convKernel=e,this}function sC(e,t){if(!B.defined(e))this.options.threshold=128;else if(B.bool(e))this.options.threshold=e?128:0;else if(B.integer(e)&&B.inRange(e,0,255))this.options.threshold=e;else throw B.invalidParameterError("threshold","integer between 0 and 255",e);return!B.object(t)||t.greyscale===!0||t.grayscale===!0?this.options.thresholdGrayscale=!0:this.options.thresholdGrayscale=!1,this}function iC(e,t,r){if(this.options.boolean=this._createInputDescriptor(e,r),B.string(t)&&B.inArray(t,["and","or","eor"]))this.options.booleanOp=t;else throw B.invalidParameterError("operator","one of: and, or, eor",t);return this}function HC(e,t){if(!B.defined(e)&&B.number(t)?e=1:B.number(e)&&!B.defined(t)&&(t=0),!B.defined(e))this.options.linearA=[];else if(B.number(e))this.options.linearA=[e];else if(Array.isArray(e)&&e.length&&e.every(B.number))this.options.linearA=e;else throw B.invalidParameterError("a","number or array of numbers",e);if(!B.defined(t))this.options.linearB=[];else if(B.number(t))this.options.linearB=[t];else if(Array.isArray(t)&&t.length&&t.every(B.number))this.options.linearB=t;else throw B.invalidParameterError("b","number or array of numbers",t);if(this.options.linearA.length!==this.options.linearB.length)throw new Error("Expected a and b to be arrays of the same length");return this}function oC(e){if(!Array.isArray(e))throw B.invalidParameterError("inputMatrix","array",e);if(e.length!==3&&e.length!==4)throw B.invalidParameterError("inputMatrix","3x3 or 4x4 array",e.length);let t=e.flat().map(Number);if(t.length!==9&&t.length!==16)throw B.invalidParameterError("inputMatrix","cardinality of 9 or 16",t.length);return this.options.recombMatrix=t,this}function _C(e){if(!B.plainObject(e))throw B.invalidParameterError("options","plain object",e);if("brightness"in e)if(B.number(e.brightness)&&e.brightness>=0)this.options.brightness=e.brightness;else throw B.invalidParameterError("brightness","number above zero",e.brightness);if("saturation"in e)if(B.number(e.saturation)&&e.saturation>=0)this.options.saturation=e.saturation;else throw B.invalidParameterError("saturation","number above zero",e.saturation);if("hue"in e)if(B.integer(e.hue))this.options.hue=e.hue%360;else throw B.invalidParameterError("hue","number",e.hue);if("lightness"in e)if(B.number(e.lightness))this.options.lightness=e.lightness;else throw B.invalidParameterError("lightness","number",e.lightness);return this}VE.exports=e=>{Object.assign(e.prototype,{autoOrient:KD,rotate:UD,flip:WD,flop:VD,affine:jD,sharpen:qD,erode:WE,dilate:KE,median:XD,blur:zD,flatten:JD,unflatten:QD,gamma:YD,negate:eC,normalise:tC,normalize:rC,clahe:aC,convolve:nC,threshold:sC,boolean:iC,linear:HC,recomb:oC,modulate:_C})}});var YE=te((H7,QE)=>{"use strict";var H_=Object.defineProperty,cC=Object.getOwnPropertyDescriptor,lC=Object.getOwnPropertyNames,uC=Object.prototype.hasOwnProperty,dC=(e,t)=>{for(var r in t)H_(e,r,{get:t[r],enumerable:!0})},pC=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lC(t))!uC.call(e,n)&&n!==r&&H_(e,n,{get:()=>t[n],enumerable:!(a=cC(t,n))||a.enumerable});return e},hC=e=>pC(H_({},"__esModule",{value:!0}),e),qE={};dC(qE,{default:()=>CC});QE.exports=hC(qE);var a_={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(let e in a_)Object.freeze(a_[e]);var br=Object.freeze(a_),XE=Object.create(null);for(let e in br)Object.hasOwn(br,e)&&(XE[br[e]]=e);var Ot={to:{},get:{}};Ot.get=function(e){let t=e.slice(0,3).toLowerCase(),r,a;switch(t){case"hsl":{r=Ot.get.hsl(e),a="hsl";break}case"hwb":{r=Ot.get.hwb(e),a="hwb";break}default:{r=Ot.get.rgb(e),a="rgb";break}}return r?{model:a,value:r}:null};Ot.get.rgb=function(e){if(!e)return null;let t=/^#([a-f\d]{3,4})$/i,r=/^#([a-f\d]{6})([a-f\d]{2})?$/i,a=/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i,n=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i,s=/^(\w+)$/,i=[0,0,0,1],H,o,_;if(H=e.match(r)){for(_=H[2],H=H[1],o=0;o<3;o++){let c=o*2;i[o]=Number.parseInt(H.slice(c,c+2),16)}_&&(i[3]=Number.parseInt(_,16)/255)}else if(H=e.match(t)){for(H=H[1],_=H[3],o=0;o<3;o++)i[o]=Number.parseInt(H[o]+H[o],16);_&&(i[3]=Number.parseInt(_+_,16)/255)}else if(H=e.match(a)){for(o=0;o<3;o++)i[o]=Number.parseFloat(H[o+1]);H[4]&&(i[3]=H[5]?Number.parseFloat(H[4])*.01:Number.parseFloat(H[4]))}else if(H=e.match(n)){for(o=0;o<3;o++)i[o]=Math.round(Number.parseFloat(H[o+1])*2.55);H[4]&&(i[3]=H[5]?Number.parseFloat(H[4])*.01:Number.parseFloat(H[4]))}else return(H=e.toLowerCase().match(s))?H[1]==="transparent"?[0,0,0,0]:Object.hasOwn(br,H[1])?(i=br[H[1]].slice(),i[3]=1,i):null:null;for(o=0;o<3;o++)i[o]=ia(i[o],0,255);return i[3]=ia(i[3],0,1),i};Ot.get.hsl=function(e){if(!e)return null;let t=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i,r=e.match(t);if(r){let a=Number.parseFloat(r[4]),n=(Number.parseFloat(r[1])%360+360)%360,s=ia(Number.parseFloat(r[2]),0,100),i=ia(Number.parseFloat(r[3]),0,100),H=ia(Number.isNaN(a)?1:a,0,1);return[n,s,i,H]}return null};Ot.get.hwb=function(e){if(!e)return null;let t=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i,r=e.match(t);if(r){let a=Number.parseFloat(r[4]),n=(Number.parseFloat(r[1])%360+360)%360,s=ia(Number.parseFloat(r[2]),0,100),i=ia(Number.parseFloat(r[3]),0,100),H=ia(Number.isNaN(a)?1:a,0,1);return[n,s,i,H]}return null};Ot.to.hex=function(...e){return"#"+Pi(e[0])+Pi(e[1])+Pi(e[2])+(e[3]<1?Pi(Math.round(e[3]*255)):"")};Ot.to.rgb=function(...e){return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};Ot.to.rgb.percent=function(...e){let t=Math.round(e[0]/255*100),r=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+t+"%, "+r+"%, "+a+"%)":"rgba("+t+"%, "+r+"%, "+a+"%, "+e[3]+")"};Ot.to.hsl=function(...e){return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};Ot.to.hwb=function(...e){let t="";return e.length>=4&&e[3]!==1&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"};Ot.to.keyword=function(...e){return XE[e.slice(0,3)]};function ia(e,t,r){return Math.min(Math.max(t,e),r)}function Pi(e){let t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}var cn=Ot,zE={};for(let e of Object.keys(br))zE[br[e]]=e;var ee={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},xa=ee,Kr=(6/29)**3;function un(e){let t=e>.0031308?1.055*e**.4166666666666667-.055:e*12.92;return Math.min(Math.max(0,t),1)}function dn(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(let e of Object.keys(ee)){if(!("channels"in ee[e]))throw new Error("missing channels property: "+e);if(!("labels"in ee[e]))throw new Error("missing channel labels property: "+e);if(ee[e].labels.length!==ee[e].channels)throw new Error("channel and label counts mismatch: "+e);let{channels:t,labels:r}=ee[e];delete ee[e].channels,delete ee[e].labels,Object.defineProperty(ee[e],"channels",{value:t}),Object.defineProperty(ee[e],"labels",{value:r})}ee.rgb.hsl=function(e){let t=e[0]/255,r=e[1]/255,a=e[2]/255,n=Math.min(t,r,a),s=Math.max(t,r,a),i=s-n,H,o;switch(s){case n:{H=0;break}case t:{H=(r-a)/i;break}case r:{H=2+(a-t)/i;break}case a:{H=4+(t-r)/i;break}}H=Math.min(H*60,360),H<0&&(H+=360);let _=(n+s)/2;return s===n?o=0:_<=.5?o=i/(s+n):o=i/(2-s-n),[H,o*100,_*100]};ee.rgb.hsv=function(e){let t,r,a,n,s,i=e[0]/255,H=e[1]/255,o=e[2]/255,_=Math.max(i,H,o),c=_-Math.min(i,H,o),l=function(d){return(_-d)/6/c+1/2};if(c===0)n=0,s=0;else{switch(s=c/_,t=l(i),r=l(H),a=l(o),_){case i:{n=a-r;break}case H:{n=1/3+t-a;break}case o:{n=2/3+r-t;break}}n<0?n+=1:n>1&&(n-=1)}return[n*360,s*100,_*100]};ee.rgb.hwb=function(e){let t=e[0],r=e[1],a=e[2],n=ee.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(r,a));return a=1-1/255*Math.max(t,Math.max(r,a)),[n,s*100,a*100]};ee.rgb.oklab=function(e){let t=dn(e[0]/255),r=dn(e[1]/255),a=dn(e[2]/255),n=Math.cbrt(.4122214708*t+.5363325363*r+.0514459929*a),s=Math.cbrt(.2119034982*t+.6806995451*r+.1073969566*a),i=Math.cbrt(.0883024619*t+.2817188376*r+.6299787005*a),H=.2104542553*n+.793617785*s-.0040720468*i,o=1.9779984951*n-2.428592205*s+.4505937099*i,_=.0259040371*n+.7827717662*s-.808675766*i;return[H*100,o*100,_*100]};ee.rgb.cmyk=function(e){let t=e[0]/255,r=e[1]/255,a=e[2]/255,n=Math.min(1-t,1-r,1-a),s=(1-t-n)/(1-n)||0,i=(1-r-n)/(1-n)||0,H=(1-a-n)/(1-n)||0;return[s*100,i*100,H*100,n*100]};function fC(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}ee.rgb.keyword=function(e){let t=zE[e];if(t)return t;let r=Number.POSITIVE_INFINITY,a;for(let n of Object.keys(br)){let s=br[n],i=fC(e,s);i<r&&(r=i,a=n)}return a};ee.keyword.rgb=function(e){return[...br[e]]};ee.rgb.xyz=function(e){let t=dn(e[0]/255),r=dn(e[1]/255),a=dn(e[2]/255),n=t*.4124564+r*.3575761+a*.1804375,s=t*.2126729+r*.7151522+a*.072175,i=t*.0193339+r*.119192+a*.9503041;return[n*100,s*100,i*100]};ee.rgb.lab=function(e){let t=ee.rgb.xyz(e),r=t[0],a=t[1],n=t[2];r/=95.047,a/=100,n/=108.883,r=r>Kr?r**(1/3):7.787*r+16/116,a=a>Kr?a**(1/3):7.787*a+16/116,n=n>Kr?n**(1/3):7.787*n+16/116;let s=116*a-16,i=500*(r-a),H=200*(a-n);return[s,i,H]};ee.hsl.rgb=function(e){let t=e[0]/360,r=e[1]/100,a=e[2]/100,n,s;if(r===0)return s=a*255,[s,s,s];let i=a<.5?a*(1+r):a+r-a*r,H=2*a-i,o=[0,0,0];for(let _=0;_<3;_++)n=t+1/3*-(_-1),n<0&&n++,n>1&&n--,6*n<1?s=H+(i-H)*6*n:2*n<1?s=i:3*n<2?s=H+(i-H)*(2/3-n)*6:s=H,o[_]=s*255;return o};ee.hsl.hsv=function(e){let t=e[0],r=e[1]/100,a=e[2]/100,n=r,s=Math.max(a,.01);a*=2,r*=a<=1?a:2-a,n*=s<=1?s:2-s;let i=(a+r)/2,H=a===0?2*n/(s+n):2*r/(a+r);return[t,H*100,i*100]};ee.hsv.rgb=function(e){let t=e[0]/60,r=e[1]/100,a=e[2]/100,n=Math.floor(t)%6,s=t-Math.floor(t),i=255*a*(1-r),H=255*a*(1-r*s),o=255*a*(1-r*(1-s));switch(a*=255,n){case 0:return[a,o,i];case 1:return[H,a,i];case 2:return[i,a,o];case 3:return[i,H,a];case 4:return[o,i,a];case 5:return[a,i,H]}};ee.hsv.hsl=function(e){let t=e[0],r=e[1]/100,a=e[2]/100,n=Math.max(a,.01),s,i;i=(2-r)*a;let H=(2-r)*n;return s=r*n,s/=H<=1?H:2-H,s=s||0,i/=2,[t,s*100,i*100]};ee.hwb.rgb=function(e){let t=e[0]/360,r=e[1]/100,a=e[2]/100,n=r+a,s;n>1&&(r/=n,a/=n);let i=Math.floor(6*t),H=1-a;s=6*t-i,(i&1)!==0&&(s=1-s);let o=r+s*(H-r),_,c,l;switch(i){default:case 6:case 0:{_=H,c=o,l=r;break}case 1:{_=o,c=H,l=r;break}case 2:{_=r,c=H,l=o;break}case 3:{_=r,c=o,l=H;break}case 4:{_=o,c=r,l=H;break}case 5:{_=H,c=r,l=o;break}}return[_*255,c*255,l*255]};ee.cmyk.rgb=function(e){let t=e[0]/100,r=e[1]/100,a=e[2]/100,n=e[3]/100,s=1-Math.min(1,t*(1-n)+n),i=1-Math.min(1,r*(1-n)+n),H=1-Math.min(1,a*(1-n)+n);return[s*255,i*255,H*255]};ee.xyz.rgb=function(e){let t=e[0]/100,r=e[1]/100,a=e[2]/100,n,s,i;return n=t*3.2404542+r*-1.5371385+a*-.4985314,s=t*-.969266+r*1.8760108+a*.041556,i=t*.0556434+r*-.2040259+a*1.0572252,n=un(n),s=un(s),i=un(i),[n*255,s*255,i*255]};ee.xyz.lab=function(e){let t=e[0],r=e[1],a=e[2];t/=95.047,r/=100,a/=108.883,t=t>Kr?t**(1/3):7.787*t+16/116,r=r>Kr?r**(1/3):7.787*r+16/116,a=a>Kr?a**(1/3):7.787*a+16/116;let n=116*r-16,s=500*(t-r),i=200*(r-a);return[n,s,i]};ee.xyz.oklab=function(e){let t=e[0]/100,r=e[1]/100,a=e[2]/100,n=Math.cbrt(.8189330101*t+.3618667424*r-.1288597137*a),s=Math.cbrt(.0329845436*t+.9293118715*r+.0361456387*a),i=Math.cbrt(.0482003018*t+.2643662691*r+.633851707*a),H=.2104542553*n+.793617785*s-.0040720468*i,o=1.9779984951*n-2.428592205*s+.4505937099*i,_=.0259040371*n+.7827717662*s-.808675766*i;return[H*100,o*100,_*100]};ee.oklab.oklch=function(e){return ee.lab.lch(e)};ee.oklab.xyz=function(e){let t=e[0]/100,r=e[1]/100,a=e[2]/100,n=(.999999998*t+.396337792*r+.215803758*a)**3,s=(1.000000008*t-.105561342*r-.063854175*a)**3,i=(1.000000055*t-.089484182*r-1.291485538*a)**3,H=1.227013851*n-.55779998*s+.281256149*i,o=-.040580178*n+1.11225687*s-.071676679*i,_=-.076381285*n-.421481978*s+1.58616322*i;return[H*100,o*100,_*100]};ee.oklab.rgb=function(e){let t=e[0]/100,r=e[1]/100,a=e[2]/100,n=(t+.3963377774*r+.2158037573*a)**3,s=(t-.1055613458*r-.0638541728*a)**3,i=(t-.0894841775*r-1.291485548*a)**3,H=un(4.0767416621*n-3.3077115913*s+.2309699292*i),o=un(-1.2684380046*n+2.6097574011*s-.3413193965*i),_=un(-.0041960863*n-.7034186147*s+1.707614701*i);return[H*255,o*255,_*255]};ee.oklch.oklab=function(e){return ee.lch.lab(e)};ee.lab.xyz=function(e){let t=e[0],r=e[1],a=e[2],n,s,i;s=(t+16)/116,n=r/500+s,i=s-a/200;let H=s**3,o=n**3,_=i**3;return s=H>Kr?H:(s-16/116)/7.787,n=o>Kr?o:(n-16/116)/7.787,i=_>Kr?_:(i-16/116)/7.787,n*=95.047,s*=100,i*=108.883,[n,s,i]};ee.lab.lch=function(e){let t=e[0],r=e[1],a=e[2],n;n=Math.atan2(a,r)*360/2/Math.PI,n<0&&(n+=360);let i=Math.sqrt(r*r+a*a);return[t,i,n]};ee.lch.lab=function(e){let t=e[0],r=e[1],n=e[2]/360*2*Math.PI,s=r*Math.cos(n),i=r*Math.sin(n);return[t,s,i]};ee.rgb.ansi16=function(e,t=null){let[r,a,n]=e,s=t===null?ee.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),s===0)return 30;let i=30+(Math.round(n/255)<<2|Math.round(a/255)<<1|Math.round(r/255));return s===2&&(i+=60),i};ee.hsv.ansi16=function(e){return ee.rgb.ansi16(ee.hsv.rgb(e),e[2])};ee.rgb.ansi256=function(e){let t=e[0],r=e[1],a=e[2];return t>>4===r>>4&&r>>4===a>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(a/255*5)};ee.ansi16.rgb=function(e){e=e[0];let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let r=(Math.trunc(e>50)+1)*.5,a=(t&1)*r*255,n=(t>>1&1)*r*255,s=(t>>2&1)*r*255;return[a,n,s]};ee.ansi256.rgb=function(e){if(e=e[0],e>=232){let s=(e-232)*10+8;return[s,s,s]}e-=16;let t,r=Math.floor(e/36)/5*255,a=Math.floor((t=e%36)/6)/5*255,n=t%6/5*255;return[r,a,n]};ee.rgb.hex=function(e){let r=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".slice(r.length)+r};ee.hex.rgb=function(e){let t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let r=t[0];t[0].length===3&&(r=[...r].map(H=>H+H).join(""));let a=Number.parseInt(r,16),n=a>>16&255,s=a>>8&255,i=a&255;return[n,s,i]};ee.rgb.hcg=function(e){let t=e[0]/255,r=e[1]/255,a=e[2]/255,n=Math.max(Math.max(t,r),a),s=Math.min(Math.min(t,r),a),i=n-s,H,o=i<1?s/(1-i):0;return i<=0?H=0:n===t?H=(r-a)/i%6:n===r?H=2+(a-t)/i:H=4+(t-r)/i,H/=6,H%=1,[H*360,i*100,o*100]};ee.hsl.hcg=function(e){let t=e[1]/100,r=e[2]/100,a=r<.5?2*t*r:2*t*(1-r),n=0;return a<1&&(n=(r-.5*a)/(1-a)),[e[0],a*100,n*100]};ee.hsv.hcg=function(e){let t=e[1]/100,r=e[2]/100,a=t*r,n=0;return a<1&&(n=(r-a)/(1-a)),[e[0],a*100,n*100]};ee.hcg.rgb=function(e){let t=e[0]/360,r=e[1]/100,a=e[2]/100;if(r===0)return[a*255,a*255,a*255];let n=[0,0,0],s=t%1*6,i=s%1,H=1-i,o=0;switch(Math.floor(s)){case 0:{n[0]=1,n[1]=i,n[2]=0;break}case 1:{n[0]=H,n[1]=1,n[2]=0;break}case 2:{n[0]=0,n[1]=1,n[2]=i;break}case 3:{n[0]=0,n[1]=H,n[2]=1;break}case 4:{n[0]=i,n[1]=0,n[2]=1;break}default:n[0]=1,n[1]=0,n[2]=H}return o=(1-r)*a,[(r*n[0]+o)*255,(r*n[1]+o)*255,(r*n[2]+o)*255]};ee.hcg.hsv=function(e){let t=e[1]/100,r=e[2]/100,a=t+r*(1-t),n=0;return a>0&&(n=t/a),[e[0],n*100,a*100]};ee.hcg.hsl=function(e){let t=e[1]/100,a=e[2]/100*(1-t)+.5*t,n=0;return a>0&&a<.5?n=t/(2*a):a>=.5&&a<1&&(n=t/(2*(1-a))),[e[0],n*100,a*100]};ee.hcg.hwb=function(e){let t=e[1]/100,r=e[2]/100,a=t+r*(1-t);return[e[0],(a-t)*100,(1-a)*100]};ee.hwb.hcg=function(e){let t=e[1]/100,a=1-e[2]/100,n=a-t,s=0;return n<1&&(s=(a-n)/(1-n)),[e[0],n*100,s*100]};ee.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};ee.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};ee.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};ee.gray.hsl=function(e){return[0,0,e[0]]};ee.gray.hsv=ee.gray.hsl;ee.gray.hwb=function(e){return[0,100,e[0]]};ee.gray.cmyk=function(e){return[0,0,0,e[0]]};ee.gray.lab=function(e){return[e[0],0,0]};ee.gray.hex=function(e){let t=Math.round(e[0]/100*255)&255,a=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(a.length)+a};ee.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};function EC(){let e={},t=Object.keys(xa);for(let{length:r}=t,a=0;a<r;a++)e[t[a]]={distance:-1,parent:null};return e}function $C(e){let t=EC(),r=[e];for(t[e].distance=0;r.length>0;){let a=r.pop(),n=Object.keys(xa[a]);for(let{length:s}=n,i=0;i<s;i++){let H=n[i],o=t[H];o.distance===-1&&(o.distance=t[a].distance+1,o.parent=a,r.unshift(H))}}return t}function mC(e,t){return function(r){return t(e(r))}}function IC(e,t){let r=[t[e].parent,e],a=xa[t[e].parent][e],n=t[e].parent;for(;t[n].parent;)r.unshift(t[n].parent),a=mC(xa[t[n].parent][n],a),n=t[n].parent;return a.conversion=r,a}function SC(e){let t=$C(e),r={},a=Object.keys(t);for(let{length:n}=a,s=0;s<n;s++){let i=a[s];t[i].parent!==null&&(r[i]=IC(i,t))}return r}var LC=SC,ln={},AC=Object.keys(xa);function gC(e){let t=function(...r){let a=r[0];return a==null?a:(a.length>1&&(r=a),e(r))};return"conversion"in e&&(t.conversion=e.conversion),t}function TC(e){let t=function(...r){let a=r[0];if(a==null)return a;a.length>1&&(r=a);let n=e(r);if(typeof n=="object")for(let{length:s}=n,i=0;i<s;i++)n[i]=Math.round(n[i]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}for(let e of AC){ln[e]={},Object.defineProperty(ln[e],"channels",{value:xa[e].channels}),Object.defineProperty(ln[e],"labels",{value:xa[e].labels});let t=LC(e),r=Object.keys(t);for(let a of r){let n=t[a];ln[e][a]=TC(n),ln[e][a].raw=gC(n)}}var Ut=ln,JE=["keyword","gray","hex"],n_={};for(let e of Object.keys(Ut))n_[[...Ut[e].labels].sort().join("")]=e;var s_={};function ut(e,t){if(!(this instanceof ut))return new ut(e,t);if(t&&t in JE&&(t=null),t&&!(t in Ut))throw new Error("Unknown model: "+t);let r,a;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof ut)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if(typeof e=="string"){let n=cn.get(e);if(n===null)throw new Error("Unable to parse color from string: "+e);this.model=n.model,a=Ut[this.model].channels,this.color=n.value.slice(0,a),this.valpha=typeof n.value[a]=="number"?n.value[a]:1}else if(e.length>0){this.model=t||"rgb",a=Ut[this.model].channels;let n=Array.prototype.slice.call(e,0,a);this.color=i_(n,a),this.valpha=typeof e[a]=="number"?e[a]:1}else if(typeof e=="number")this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;let n=Object.keys(e);"alpha"in e&&(n.splice(n.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);let s=n.sort().join("");if(!(s in n_))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=n_[s];let{labels:i}=Ut[this.model],H=[];for(r=0;r<i.length;r++)H.push(e[i[r]]);this.color=i_(H)}if(s_[this.model])for(a=Ut[this.model].channels,r=0;r<a;r++){let n=s_[this.model][r];n&&(this.color[r]=n(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}ut.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(e){let t=this.model in cn.to?this:this.rgb();t=t.round(typeof e=="number"?e:1);let r=t.valpha===1?t.color:[...t.color,this.valpha];return cn.to[t.model](...r)},percentString(e){let t=this.rgb().round(typeof e=="number"?e:1),r=t.valpha===1?t.color:[...t.color,this.valpha];return cn.to.rgb.percent(...r)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let e={},{channels:t}=Ut[this.model],{labels:r}=Ut[this.model];for(let a=0;a<t;a++)e[r[a]]=this.color[a];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray(){let e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject(){let e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round(e){return e=Math.max(e||0,0),new ut([...this.color.map(vC(e)),this.valpha],this.model)},alpha(e){return e!==void 0?new ut([...this.color,Math.max(0,Math.min(1,e))],this.model):this.valpha},red:ze("rgb",0,st(255)),green:ze("rgb",1,st(255)),blue:ze("rgb",2,st(255)),hue:ze(["hsl","hsv","hsl","hwb","hcg"],0,e=>(e%360+360)%360),saturationl:ze("hsl",1,st(100)),lightness:ze("hsl",2,st(100)),saturationv:ze("hsv",1,st(100)),value:ze("hsv",2,st(100)),chroma:ze("hcg",1,st(100)),gray:ze("hcg",2,st(100)),white:ze("hwb",1,st(100)),wblack:ze("hwb",2,st(100)),cyan:ze("cmyk",0,st(100)),magenta:ze("cmyk",1,st(100)),yellow:ze("cmyk",2,st(100)),black:ze("cmyk",3,st(100)),x:ze("xyz",0,st(95.047)),y:ze("xyz",1,st(100)),z:ze("xyz",2,st(108.833)),l:ze("lab",0,st(100)),a:ze("lab",1),b:ze("lab",2),keyword(e){return e!==void 0?new ut(e):Ut[this.model].keyword(this.color)},hex(e){return e!==void 0?new ut(e):cn.to.hex(...this.rgb().round().color)},hexa(e){if(e!==void 0)return new ut(e);let t=this.rgb().round().color,r=Math.round(this.valpha*255).toString(16).toUpperCase();return r.length===1&&(r="0"+r),cn.to.hex(...t)+r},rgbNumber(){let e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity(){let e=this.rgb().color,t=[];for(let[r,a]of e.entries()){let n=a/255;t[r]=n<=.04045?n/12.92:((n+.055)/1.055)**2.4}return .2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){let t=this.luminosity(),r=e.luminosity();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},level(e){let t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){let e=this.rgb().color;return(e[0]*2126+e[1]*7152+e[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){let t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){let t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){let t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){let t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){let t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){let t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){let e=this.rgb().color,t=e[0]*.3+e[1]*.59+e[2]*.11;return ut.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){let t=this.hsl(),r=t.color[0];return r=(r+e)%360,r=r<0?360+r:r,t.color[0]=r,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);let r=e.rgb(),a=this.rgb(),n=t===void 0?.5:t,s=2*n-1,i=r.alpha()-a.alpha(),H=((s*i===-1?s:(s+i)/(1+s*i))+1)/2,o=1-H;return ut.rgb(H*r.red()+o*a.red(),H*r.green()+o*a.green(),H*r.blue()+o*a.blue(),r.alpha()*n+a.alpha()*(1-n))}};for(let e of Object.keys(Ut)){if(JE.includes(e))continue;let{channels:t}=Ut[e];ut.prototype[e]=function(...r){return this.model===e?new ut(this):r.length>0?new ut(r,e):new ut([...DC(Ut[this.model][e].raw(this.color)),this.valpha],e)},ut[e]=function(...r){let a=r[0];return typeof a=="number"&&(a=i_(r,t)),new ut(a,e)}}function bC(e,t){return Number(e.toFixed(t))}function vC(e){return function(t){return bC(t,e)}}function ze(e,t,r){e=Array.isArray(e)?e:[e];for(let a of e)(s_[a]||=[])[t]=r;return e=e[0],function(a){let n;return a!==void 0?(r&&(a=r(a)),n=this[e](),n.color[t]=a,n):(n=this[e]().color[t],r&&(n=r(n)),n)}}function st(e){return function(t){return Math.max(0,Math.min(e,t))}}function DC(e){return Array.isArray(e)?e:[e]}function i_(e,t){for(let r=0;r<t;r++)typeof e[r]!="number"&&(e[r]=0);return e}var CC=ut});var t1=te((o7,e1)=>{"use strict";e1.exports=YE().default});var s1=te((_7,n1)=>{"use strict";var xC=t1(),Wr=Sr(),r1={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function NC(e){return this._setBackgroundColourOption("tint",e),this}function wC(e){return this.options.greyscale=Wr.bool(e)?e:!0,this}function yC(e){return this.greyscale(e)}function BC(e){if(!Wr.string(e))throw Wr.invalidParameterError("colourspace","string",e);return this.options.colourspacePipeline=e,this}function MC(e){return this.pipelineColourspace(e)}function PC(e){if(!Wr.string(e))throw Wr.invalidParameterError("colourspace","string",e);return this.options.colourspace=e,this}function RC(e){return this.toColourspace(e)}function a1(e){if(Wr.object(e)||Wr.string(e)&&e.length>=3&&e.length<=200){let t=xC(e);return[t.red(),t.green(),t.blue(),Math.round(t.alpha()*255)]}else throw Wr.invalidParameterError("background","object or string",e)}function kC(e,t){Wr.defined(t)&&(this.options[e]=a1(t))}n1.exports=e=>{Object.assign(e.prototype,{tint:NC,greyscale:wC,grayscale:yC,pipelineColourspace:BC,pipelineColorspace:MC,toColourspace:PC,toColorspace:RC,_getBackgroundColourOption:a1,_setBackgroundColourOption:kC}),e.colourspace=r1,e.colorspace=r1}});var H1=te((c7,i1)=>{"use strict";var vr=Sr(),OC={and:"and",or:"or",eor:"eor"};function GC(){return this.options.removeAlpha=!0,this}function FC(e){if(vr.defined(e))if(vr.number(e)&&vr.inRange(e,0,1))this.options.ensureAlpha=e;else throw vr.invalidParameterError("alpha","number between 0 and 1",e);else this.options.ensureAlpha=1;return this}function ZC(e){let t={red:0,green:1,blue:2,alpha:3};if(Object.keys(t).includes(e)&&(e=t[e]),vr.integer(e)&&vr.inRange(e,0,4))this.options.extractChannel=e;else throw vr.invalidParameterError("channel","integer or one of: red, green, blue, alpha",e);return this}function UC(e,t){return Array.isArray(e)?e.forEach(function(r){this.options.joinChannelIn.push(this._createInputDescriptor(r,t))},this):this.options.joinChannelIn.push(this._createInputDescriptor(e,t)),this}function KC(e){if(vr.string(e)&&vr.inArray(e,["and","or","eor"]))this.options.bandBoolOp=e;else throw vr.invalidParameterError("boolOp","one of: and, or, eor",e);return this}i1.exports=e=>{Object.assign(e.prototype,{removeAlpha:GC,ensureAlpha:FC,extractChannel:ZC,joinChannel:UC,bandbool:KC}),e.bool=OC}});var u1=te((l7,l1)=>{"use strict";var o_=Pe("path"),g=Sr(),pn=ds(),o1=new Map([["heic","heif"],["heif","heif"],["avif","avif"],["jpeg","jpeg"],["jpg","jpeg"],["jpe","jpeg"],["tile","tile"],["dz","tile"],["png","png"],["raw","raw"],["tiff","tiff"],["tif","tiff"],["webp","webp"],["gif","gif"],["jp2","jp2"],["jpx","jp2"],["j2k","jp2"],["j2c","jp2"],["jxl","jxl"]]),WC=/\.(jp[2x]|j2[kc])$/i,_1=()=>new Error("JP2 output requires libvips with support for OpenJPEG"),c1=e=>1<<31-Math.clz32(Math.ceil(Math.log2(e)));function VC(e,t){let r;if(g.string(e)?g.string(this.options.input.file)&&o_.resolve(this.options.input.file)===o_.resolve(e)?r=new Error("Cannot use same file for input and output"):WC.test(o_.extname(e))&&!this.constructor.format.jp2k.output.file&&(r=_1()):r=new Error("Missing output file path"),r)if(g.fn(t))t(r);else return Promise.reject(r);else{this.options.fileOut=e;let a=Error();return this._pipeline(t,a)}return this}function jC(e,t){g.object(e)?this._setBooleanOption("resolveWithObject",e.resolveWithObject):this.options.resolveWithObject&&(this.options.resolveWithObject=!1),this.options.fileOut="";let r=Error();return this._pipeline(g.fn(e)?e:t,r)}function qC(){return this.options.keepMetadata|=1,this}function XC(e){if(g.object(e))for(let[t,r]of Object.entries(e))if(g.object(r))for(let[a,n]of Object.entries(r))if(g.string(n))this.options.withExif[`exif-${t.toLowerCase()}-${a}`]=n;else throw g.invalidParameterError(`${t}.${a}`,"string",n);else throw g.invalidParameterError(t,"object",r);else throw g.invalidParameterError("exif","object",e);return this.options.withExifMerge=!1,this.keepExif()}function zC(e){return this.withExif(e),this.options.withExifMerge=!0,this}function JC(){return this.options.keepMetadata|=8,this}function QC(e,t){if(g.string(e))this.options.withIccProfile=e;else throw g.invalidParameterError("icc","string",e);if(this.keepIccProfile(),g.object(t)&&g.defined(t.attach))if(g.bool(t.attach))t.attach||(this.options.keepMetadata&=-9);else throw g.invalidParameterError("attach","boolean",t.attach);return this}function YC(){return this.options.keepMetadata|=2,this}function ex(e){if(g.string(e)&&e.length>0)this.options.withXmp=e,this.options.keepMetadata|=2;else throw g.invalidParameterError("xmp","non-empty string",e);return this}function tx(){return this.options.keepMetadata=31,this}function rx(e){if(this.keepMetadata(),this.withIccProfile("srgb"),g.object(e)){if(g.defined(e.orientation))if(g.integer(e.orientation)&&g.inRange(e.orientation,1,8))this.options.withMetadataOrientation=e.orientation;else throw g.invalidParameterError("orientation","integer between 1 and 8",e.orientation);if(g.defined(e.density))if(g.number(e.density)&&e.density>0)this.options.withMetadataDensity=e.density;else throw g.invalidParameterError("density","positive number",e.density);g.defined(e.icc)&&this.withIccProfile(e.icc),g.defined(e.exif)&&this.withExifMerge(e.exif)}return this}function ax(e,t){let r=o1.get((g.object(e)&&g.string(e.id)?e.id:e).toLowerCase());if(!r)throw g.invalidParameterError("format",`one of: ${[...o1.keys()].join(", ")}`,e);return this[r](t)}function nx(e){if(g.object(e)){if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,1,100))this.options.jpegQuality=e.quality;else throw g.invalidParameterError("quality","integer between 1 and 100",e.quality);if(g.defined(e.progressive)&&this._setBooleanOption("jpegProgressive",e.progressive),g.defined(e.chromaSubsampling))if(g.string(e.chromaSubsampling)&&g.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=e.chromaSubsampling;else throw g.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling);let t=g.bool(e.optimizeCoding)?e.optimizeCoding:e.optimiseCoding;if(g.defined(t)&&this._setBooleanOption("jpegOptimiseCoding",t),g.defined(e.mozjpeg))if(g.bool(e.mozjpeg))e.mozjpeg&&(this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3);else throw g.invalidParameterError("mozjpeg","boolean",e.mozjpeg);let r=g.bool(e.trellisQuantization)?e.trellisQuantization:e.trellisQuantisation;g.defined(r)&&this._setBooleanOption("jpegTrellisQuantisation",r),g.defined(e.overshootDeringing)&&this._setBooleanOption("jpegOvershootDeringing",e.overshootDeringing);let a=g.bool(e.optimizeScans)?e.optimizeScans:e.optimiseScans;g.defined(a)&&(this._setBooleanOption("jpegOptimiseScans",a),a&&(this.options.jpegProgressive=!0));let n=g.number(e.quantizationTable)?e.quantizationTable:e.quantisationTable;if(g.defined(n))if(g.integer(n)&&g.inRange(n,0,8))this.options.jpegQuantisationTable=n;else throw g.invalidParameterError("quantisationTable","integer between 0 and 8",n)}return this._updateFormatOut("jpeg",e)}function sx(e){if(g.object(e)){if(g.defined(e.progressive)&&this._setBooleanOption("pngProgressive",e.progressive),g.defined(e.compressionLevel))if(g.integer(e.compressionLevel)&&g.inRange(e.compressionLevel,0,9))this.options.pngCompressionLevel=e.compressionLevel;else throw g.invalidParameterError("compressionLevel","integer between 0 and 9",e.compressionLevel);g.defined(e.adaptiveFiltering)&&this._setBooleanOption("pngAdaptiveFiltering",e.adaptiveFiltering);let t=e.colours||e.colors;if(g.defined(t))if(g.integer(t)&&g.inRange(t,2,256))this.options.pngBitdepth=c1(t);else throw g.invalidParameterError("colours","integer between 2 and 256",t);if(g.defined(e.palette)?this._setBooleanOption("pngPalette",e.palette):[e.quality,e.effort,e.colours,e.colors,e.dither].some(g.defined)&&this._setBooleanOption("pngPalette",!0),this.options.pngPalette){if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,0,100))this.options.pngQuality=e.quality;else throw g.invalidParameterError("quality","integer between 0 and 100",e.quality);if(g.defined(e.effort))if(g.integer(e.effort)&&g.inRange(e.effort,1,10))this.options.pngEffort=e.effort;else throw g.invalidParameterError("effort","integer between 1 and 10",e.effort);if(g.defined(e.dither))if(g.number(e.dither)&&g.inRange(e.dither,0,1))this.options.pngDither=e.dither;else throw g.invalidParameterError("dither","number between 0.0 and 1.0",e.dither)}}return this._updateFormatOut("png",e)}function ix(e){if(g.object(e)){if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,1,100))this.options.webpQuality=e.quality;else throw g.invalidParameterError("quality","integer between 1 and 100",e.quality);if(g.defined(e.alphaQuality))if(g.integer(e.alphaQuality)&&g.inRange(e.alphaQuality,0,100))this.options.webpAlphaQuality=e.alphaQuality;else throw g.invalidParameterError("alphaQuality","integer between 0 and 100",e.alphaQuality);if(g.defined(e.lossless)&&this._setBooleanOption("webpLossless",e.lossless),g.defined(e.nearLossless)&&this._setBooleanOption("webpNearLossless",e.nearLossless),g.defined(e.smartSubsample)&&this._setBooleanOption("webpSmartSubsample",e.smartSubsample),g.defined(e.smartDeblock)&&this._setBooleanOption("webpSmartDeblock",e.smartDeblock),g.defined(e.preset))if(g.string(e.preset)&&g.inArray(e.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=e.preset;else throw g.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",e.preset);if(g.defined(e.effort))if(g.integer(e.effort)&&g.inRange(e.effort,0,6))this.options.webpEffort=e.effort;else throw g.invalidParameterError("effort","integer between 0 and 6",e.effort);g.defined(e.minSize)&&this._setBooleanOption("webpMinSize",e.minSize),g.defined(e.mixed)&&this._setBooleanOption("webpMixed",e.mixed)}return __(e,this.options),this._updateFormatOut("webp",e)}function Hx(e){if(g.object(e)){g.defined(e.reuse)&&this._setBooleanOption("gifReuse",e.reuse),g.defined(e.progressive)&&this._setBooleanOption("gifProgressive",e.progressive);let t=e.colours||e.colors;if(g.defined(t))if(g.integer(t)&&g.inRange(t,2,256))this.options.gifBitdepth=c1(t);else throw g.invalidParameterError("colours","integer between 2 and 256",t);if(g.defined(e.effort))if(g.number(e.effort)&&g.inRange(e.effort,1,10))this.options.gifEffort=e.effort;else throw g.invalidParameterError("effort","integer between 1 and 10",e.effort);if(g.defined(e.dither))if(g.number(e.dither)&&g.inRange(e.dither,0,1))this.options.gifDither=e.dither;else throw g.invalidParameterError("dither","number between 0.0 and 1.0",e.dither);if(g.defined(e.interFrameMaxError))if(g.number(e.interFrameMaxError)&&g.inRange(e.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=e.interFrameMaxError;else throw g.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",e.interFrameMaxError);if(g.defined(e.interPaletteMaxError))if(g.number(e.interPaletteMaxError)&&g.inRange(e.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=e.interPaletteMaxError;else throw g.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",e.interPaletteMaxError);if(g.defined(e.keepDuplicateFrames))if(g.bool(e.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",e.keepDuplicateFrames);else throw g.invalidParameterError("keepDuplicateFrames","boolean",e.keepDuplicateFrames)}return __(e,this.options),this._updateFormatOut("gif",e)}function ox(e){if(!this.constructor.format.jp2k.output.buffer)throw _1();if(g.object(e)){if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,1,100))this.options.jp2Quality=e.quality;else throw g.invalidParameterError("quality","integer between 1 and 100",e.quality);if(g.defined(e.lossless))if(g.bool(e.lossless))this.options.jp2Lossless=e.lossless;else throw g.invalidParameterError("lossless","boolean",e.lossless);if(g.defined(e.tileWidth))if(g.integer(e.tileWidth)&&g.inRange(e.tileWidth,1,32768))this.options.jp2TileWidth=e.tileWidth;else throw g.invalidParameterError("tileWidth","integer between 1 and 32768",e.tileWidth);if(g.defined(e.tileHeight))if(g.integer(e.tileHeight)&&g.inRange(e.tileHeight,1,32768))this.options.jp2TileHeight=e.tileHeight;else throw g.invalidParameterError("tileHeight","integer between 1 and 32768",e.tileHeight);if(g.defined(e.chromaSubsampling))if(g.string(e.chromaSubsampling)&&g.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=e.chromaSubsampling;else throw g.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling)}return this._updateFormatOut("jp2",e)}function __(e,t){if(g.object(e)&&g.defined(e.loop))if(g.integer(e.loop)&&g.inRange(e.loop,0,65535))t.loop=e.loop;else throw g.invalidParameterError("loop","integer between 0 and 65535",e.loop);if(g.object(e)&&g.defined(e.delay))if(g.integer(e.delay)&&g.inRange(e.delay,0,65535))t.delay=[e.delay];else if(Array.isArray(e.delay)&&e.delay.every(g.integer)&&e.delay.every(r=>g.inRange(r,0,65535)))t.delay=e.delay;else throw g.invalidParameterError("delay","integer or an array of integers between 0 and 65535",e.delay)}function _x(e){if(g.object(e)){if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,1,100))this.options.tiffQuality=e.quality;else throw g.invalidParameterError("quality","integer between 1 and 100",e.quality);if(g.defined(e.bitdepth))if(g.integer(e.bitdepth)&&g.inArray(e.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=e.bitdepth;else throw g.invalidParameterError("bitdepth","1, 2, 4 or 8",e.bitdepth);if(g.defined(e.tile)&&this._setBooleanOption("tiffTile",e.tile),g.defined(e.tileWidth))if(g.integer(e.tileWidth)&&e.tileWidth>0)this.options.tiffTileWidth=e.tileWidth;else throw g.invalidParameterError("tileWidth","integer greater than zero",e.tileWidth);if(g.defined(e.tileHeight))if(g.integer(e.tileHeight)&&e.tileHeight>0)this.options.tiffTileHeight=e.tileHeight;else throw g.invalidParameterError("tileHeight","integer greater than zero",e.tileHeight);if(g.defined(e.miniswhite)&&this._setBooleanOption("tiffMiniswhite",e.miniswhite),g.defined(e.pyramid)&&this._setBooleanOption("tiffPyramid",e.pyramid),g.defined(e.xres))if(g.number(e.xres)&&e.xres>0)this.options.tiffXres=e.xres;else throw g.invalidParameterError("xres","number greater than zero",e.xres);if(g.defined(e.yres))if(g.number(e.yres)&&e.yres>0)this.options.tiffYres=e.yres;else throw g.invalidParameterError("yres","number greater than zero",e.yres);if(g.defined(e.compression))if(g.string(e.compression)&&g.inArray(e.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=e.compression;else throw g.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",e.compression);if(g.defined(e.bigtiff)&&this._setBooleanOption("tiffBigtiff",e.bigtiff),g.defined(e.predictor))if(g.string(e.predictor)&&g.inArray(e.predictor,["none","horizontal","float"]))this.options.tiffPredictor=e.predictor;else throw g.invalidParameterError("predictor","one of: none, horizontal, float",e.predictor);if(g.defined(e.resolutionUnit))if(g.string(e.resolutionUnit)&&g.inArray(e.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=e.resolutionUnit;else throw g.invalidParameterError("resolutionUnit","one of: inch, cm",e.resolutionUnit)}return this._updateFormatOut("tiff",e)}function cx(e){return this.heif({...e,compression:"av1"})}function lx(e){if(g.object(e)){if(g.string(e.compression)&&g.inArray(e.compression,["av1","hevc"]))this.options.heifCompression=e.compression;else throw g.invalidParameterError("compression","one of: av1, hevc",e.compression);if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,1,100))this.options.heifQuality=e.quality;else throw g.invalidParameterError("quality","integer between 1 and 100",e.quality);if(g.defined(e.lossless))if(g.bool(e.lossless))this.options.heifLossless=e.lossless;else throw g.invalidParameterError("lossless","boolean",e.lossless);if(g.defined(e.effort))if(g.integer(e.effort)&&g.inRange(e.effort,0,9))this.options.heifEffort=e.effort;else throw g.invalidParameterError("effort","integer between 0 and 9",e.effort);if(g.defined(e.chromaSubsampling))if(g.string(e.chromaSubsampling)&&g.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=e.chromaSubsampling;else throw g.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling);if(g.defined(e.bitdepth))if(g.integer(e.bitdepth)&&g.inArray(e.bitdepth,[8,10,12])){if(e.bitdepth!==8&&this.constructor.versions.heif)throw g.invalidParameterError("bitdepth when using prebuilt binaries",8,e.bitdepth);this.options.heifBitdepth=e.bitdepth}else throw g.invalidParameterError("bitdepth","8, 10 or 12",e.bitdepth)}else throw g.invalidParameterError("options","Object",e);return this._updateFormatOut("heif",e)}function ux(e){if(g.object(e)){if(g.defined(e.quality))if(g.integer(e.quality)&&g.inRange(e.quality,1,100))this.options.jxlDistance=e.quality>=30?.1+(100-e.quality)*.09:53/3e3*e.quality*e.quality-23/20*e.quality+25;else throw g.invalidParameterError("quality","integer between 1 and 100",e.quality);else if(g.defined(e.distance))if(g.number(e.distance)&&g.inRange(e.distance,0,15))this.options.jxlDistance=e.distance;else throw g.invalidParameterError("distance","number between 0.0 and 15.0",e.distance);if(g.defined(e.decodingTier))if(g.integer(e.decodingTier)&&g.inRange(e.decodingTier,0,4))this.options.jxlDecodingTier=e.decodingTier;else throw g.invalidParameterError("decodingTier","integer between 0 and 4",e.decodingTier);if(g.defined(e.lossless))if(g.bool(e.lossless))this.options.jxlLossless=e.lossless;else throw g.invalidParameterError("lossless","boolean",e.lossless);if(g.defined(e.effort))if(g.integer(e.effort)&&g.inRange(e.effort,1,9))this.options.jxlEffort=e.effort;else throw g.invalidParameterError("effort","integer between 1 and 9",e.effort)}return __(e,this.options),this._updateFormatOut("jxl",e)}function dx(e){if(g.object(e)&&g.defined(e.depth))if(g.string(e.depth)&&g.inArray(e.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=e.depth;else throw g.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",e.depth);return this._updateFormatOut("raw")}function px(e){if(g.object(e)){if(g.defined(e.size))if(g.integer(e.size)&&g.inRange(e.size,1,8192))this.options.tileSize=e.size;else throw g.invalidParameterError("size","integer between 1 and 8192",e.size);if(g.defined(e.overlap))if(g.integer(e.overlap)&&g.inRange(e.overlap,0,8192)){if(e.overlap>this.options.tileSize)throw g.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,e.overlap);this.options.tileOverlap=e.overlap}else throw g.invalidParameterError("overlap","integer between 0 and 8192",e.overlap);if(g.defined(e.container))if(g.string(e.container)&&g.inArray(e.container,["fs","zip"]))this.options.tileContainer=e.container;else throw g.invalidParameterError("container","one of: fs, zip",e.container);if(g.defined(e.layout))if(g.string(e.layout)&&g.inArray(e.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=e.layout;else throw g.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",e.layout);if(g.defined(e.angle))if(g.integer(e.angle)&&!(e.angle%90))this.options.tileAngle=e.angle;else throw g.invalidParameterError("angle","positive/negative multiple of 90",e.angle);if(this._setBackgroundColourOption("tileBackground",e.background),g.defined(e.depth))if(g.string(e.depth)&&g.inArray(e.depth,["onepixel","onetile","one"]))this.options.tileDepth=e.depth;else throw g.invalidParameterError("depth","one of: onepixel, onetile, one",e.depth);if(g.defined(e.skipBlanks))if(g.integer(e.skipBlanks)&&g.inRange(e.skipBlanks,-1,65535))this.options.tileSkipBlanks=e.skipBlanks;else throw g.invalidParameterError("skipBlanks","integer between -1 and 255/65535",e.skipBlanks);else g.defined(e.layout)&&e.layout==="google"&&(this.options.tileSkipBlanks=5);let t=g.bool(e.center)?e.center:e.centre;if(g.defined(t)&&this._setBooleanOption("tileCentre",t),g.defined(e.id))if(g.string(e.id))this.options.tileId=e.id;else throw g.invalidParameterError("id","string",e.id);if(g.defined(e.basename))if(g.string(e.basename))this.options.tileBasename=e.basename;else throw g.invalidParameterError("basename","string",e.basename)}if(g.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw g.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function hx(e){if(!g.plainObject(e))throw g.invalidParameterError("options","object",e);if(g.integer(e.seconds)&&g.inRange(e.seconds,0,3600))this.options.timeoutSeconds=e.seconds;else throw g.invalidParameterError("seconds","integer between 0 and 3600",e.seconds);return this}function fx(e,t){return g.object(t)&&t.force===!1||(this.options.formatOut=e),this}function Ex(e,t){if(g.bool(t))this.options[e]=t;else throw g.invalidParameterError(e,"boolean",t)}function $x(){if(!this.options.streamOut){this.options.streamOut=!0;let e=Error();this._pipeline(void 0,e)}}function mx(e,t){return typeof e=="function"?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),pn.pipeline(this.options,(r,a,n)=>{r?e(g.nativeError(r,t)):e(null,a,n)})}):pn.pipeline(this.options,(r,a,n)=>{r?e(g.nativeError(r,t)):e(null,a,n)}),this):this.options.streamOut?(this._isStreamInput()?(this.once("finish",()=>{this._flattenBufferIn(),pn.pipeline(this.options,(r,a,n)=>{r?this.emit("error",g.nativeError(r,t)):(this.emit("info",n),this.push(a)),this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished&&this.emit("finish")):pn.pipeline(this.options,(r,a,n)=>{r?this.emit("error",g.nativeError(r,t)):(this.emit("info",n),this.push(a)),this.push(null),this.on("end",()=>this.emit("close"))}),this):this._isStreamInput()?new Promise((r,a)=>{this.once("finish",()=>{this._flattenBufferIn(),pn.pipeline(this.options,(n,s,i)=>{n?a(g.nativeError(n,t)):this.options.resolveWithObject?r({data:s,info:i}):r(s)})})}):new Promise((r,a)=>{pn.pipeline(this.options,(n,s,i)=>{n?a(g.nativeError(n,t)):this.options.resolveWithObject?r({data:s,info:i}):r(s)})})}l1.exports=e=>{Object.assign(e.prototype,{toFile:VC,toBuffer:jC,keepExif:qC,withExif:XC,withExifMerge:zC,keepIccProfile:JC,withIccProfile:QC,keepXmp:YC,withXmp:ex,keepMetadata:tx,withMetadata:rx,toFormat:ax,jpeg:nx,jp2:ox,png:sx,webp:ix,tiff:_x,avif:cx,heif:lx,jxl:ux,gif:Hx,raw:dx,tile:px,timeout:hx,_updateFormatOut:fx,_setBooleanOption:Ex,_read:$x,_pipeline:mx})}});var f1=te((u7,h1)=>{"use strict";var Ix=Pe("events"),Ri=gi(),Jt=Sr(),{runtimePlatformArch:Sx}=Jo(),kt=ds(),d1=Sx(),c_=kt.libvipsVersion(),Ha=kt.format();Ha.heif.output.alias=["avif","heic"];Ha.jpeg.output.alias=["jpe","jpg"];Ha.tiff.output.alias=["tif"];Ha.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var Lx={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},hn={vips:c_.semver};if(!c_.isGlobal)if(c_.isWasm)try{hn=Pe("@img/sharp-wasm32/versions")}catch{}else try{hn=Pe(`@img/sharp-${d1}/versions`)}catch{try{hn=Pe(`@img/sharp-libvips-${d1}/versions`)}catch{}}hn.sharp=Xo().version;hn.heif&&Ha.heif&&(Ha.heif.input.fileSuffix=[".avif"],Ha.heif.output.alias=["avif"]);function p1(e){return Jt.bool(e)?e?kt.cache(50,20,100):kt.cache(0,0,0):Jt.object(e)?kt.cache(e.memory,e.files,e.items):kt.cache()}p1(!0);function Ax(e){return kt.concurrency(Jt.integer(e)?e:null)}Ri.familySync()===Ri.GLIBC&&!kt._isUsingJemalloc()?kt.concurrency(1):Ri.familySync()===Ri.MUSL&&kt.concurrency()===1024&&kt.concurrency(Pe("os").availableParallelism());var gx=new Ix.EventEmitter;function Tx(){return kt.counters()}function bx(e){return kt.simd(Jt.bool(e)?e:null)}function vx(e){if(Jt.object(e))if(Array.isArray(e.operation)&&e.operation.every(Jt.string))kt.block(e.operation,!0);else throw Jt.invalidParameterError("operation","Array<string>",e.operation);else throw Jt.invalidParameterError("options","object",e)}function Dx(e){if(Jt.object(e))if(Array.isArray(e.operation)&&e.operation.every(Jt.string))kt.block(e.operation,!1);else throw Jt.invalidParameterError("operation","Array<string>",e.operation);else throw Jt.invalidParameterError("options","object",e)}h1.exports=e=>{e.cache=p1,e.concurrency=Ax,e.counters=Tx,e.simd=bx,e.format=Ha,e.interpolators=Lx,e.versions=hn,e.queue=gx,e.block=vx,e.unblock=Dx}});var $1=te((p7,E1)=>{"use strict";var Vr=NE();BE()(Vr);GE()(Vr);ZE()(Vr);jE()(Vr);s1()(Vr);H1()(Vr);u1()(Vr);f1()(Vr);E1.exports=Vr});var bB=ih(Oh(),1);import xx from"fs";import Dn from"path";import Nx from"url";import $n from"fs";import fs from"fs";import ki from"path";var Gh="1.24.3";var Fh="warning",wo={wasm:{},webgl:{},webgpu:{},versions:{common:Gh},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);Fh=e}},get logLevel(){return Fh}};Object.defineProperty(wo,"logLevel",{enumerable:!0});var Zh=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];let a=r.getContext("2d");if(a!=null){let n,s;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(n=e.dims[2],s=e.dims[3]):(n=e.dims[3],s=e.dims[2]);let i=t?.format!==void 0?t.format:"RGB",H=t?.norm,o,_;H===void 0||H.mean===void 0?o=[255,255,255,255]:typeof H.mean=="number"?o=[H.mean,H.mean,H.mean,H.mean]:(o=[H.mean[0],H.mean[1],H.mean[2],0],H.mean[3]!==void 0&&(o[3]=H.mean[3])),H===void 0||H.bias===void 0?_=[0,0,0,0]:typeof H.bias=="number"?_=[H.bias,H.bias,H.bias,H.bias]:(_=[H.bias[0],H.bias[1],H.bias[2],0],H.bias[3]!==void 0&&(_[3]=H.bias[3]));let c=s*n,l=0,d=c,h=c*2,$=-1;i==="RGBA"?(l=0,d=c,h=c*2,$=c*3):i==="RGB"?(l=0,d=c,h=c*2):i==="RBG"&&(l=0,h=c,d=c*2);for(let m=0;m<s;m++)for(let S=0;S<n;S++){let I=(e.data[l++]-_[0])*o[0],T=(e.data[d++]-_[1])*o[1],D=(e.data[h++]-_[2])*o[2],v=$===-1?255:(e.data[$++]-_[3])*o[3];a.fillStyle="rgba("+I+","+T+","+D+","+v+")",a.fillRect(S,m,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},Uh=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),a;if(r!=null){let n,s,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(n=e.dims[2],s=e.dims[1],i=e.dims[3]):(n=e.dims[3],s=e.dims[2],i=e.dims[1]);let H=t!==void 0&&t.format!==void 0?t.format:"RGB",o=t?.norm,_,c;o===void 0||o.mean===void 0?_=[255,255,255,255]:typeof o.mean=="number"?_=[o.mean,o.mean,o.mean,o.mean]:(_=[o.mean[0],o.mean[1],o.mean[2],255],o.mean[3]!==void 0&&(_[3]=o.mean[3])),o===void 0||o.bias===void 0?c=[0,0,0,0]:typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:(c=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(c[3]=o.bias[3]));let l=s*n;if(t!==void 0&&(t.format!==void 0&&i===4&&t.format!=="RGBA"||i===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,h=0,$=1,m=2,S=3,I=0,T=l,D=l*2,v=-1;H==="RGBA"?(I=0,T=l,D=l*2,v=l*3):H==="RGB"?(I=0,T=l,D=l*2):H==="RBG"&&(I=0,D=l,T=l*2),a=r.createImageData(n,s);for(let C=0;C<s*n;h+=d,$+=d,m+=d,S+=d,C++)a.data[h]=(e.data[I++]-c[0])*_[0],a.data[$]=(e.data[T++]-c[1])*_[1],a.data[m]=(e.data[D++]-c[2])*_[2],a.data[S]=v===-1?255:(e.data[v++]-c[3])*_[3]}else throw new Error("Can not access image data");return a};var yo=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:a}=t,n=t.norm??{mean:255,bias:0},s,i;typeof n.mean=="number"?s=[n.mean,n.mean,n.mean,n.mean]:s=[n.mean[0],n.mean[1],n.mean[2],n.mean[3]??255],typeof n.bias=="number"?i=[n.bias,n.bias,n.bias,n.bias]:i=[n.bias[0],n.bias[1],n.bias[2],n.bias[3]??0];let H=t.format!==void 0?t.format:"RGBA",o=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",_=r*a,c=o==="RGBA"?new Float32Array(_*4):new Float32Array(_*3),l=4,d=0,h=1,$=2,m=3,S=0,I=_,T=_*2,D=-1;H==="RGB"&&(l=3,d=0,h=1,$=2,m=-1),o==="RGBA"?D=_*3:o==="RBG"?(S=0,T=_,I=_*2):o==="BGR"&&(T=0,I=_,S=_*2);for(let C=0;C<_;C++,d+=l,$+=l,h+=l,m+=l)c[S++]=(e[d]+i[0])/s[0],c[I++]=(e[h]+i[1])/s[1],c[T++]=(e[$]+i[2])/s[2],D!==-1&&m!==-1&&(c[D++]=(e[m]+i[3])/s[3]);return o==="RGBA"?new mt("float32",c,[1,4,r,a]):new mt("float32",c,[1,3,r,a])},Kh=async(e,t)=>{let r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,a=typeof ImageData<"u"&&e instanceof ImageData,n=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,s=typeof e=="string",i,H=t??{},o=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},_=c=>typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||c instanceof OffscreenCanvas?c.getContext("2d"):null;if(r){let c=o();c.width=e.width,c.height=e.height;let l=_(c);if(l!=null){let d=e.height,h=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(d=t.resizedHeight,h=t.resizedWidth),t!==void 0){if(H=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");H.tensorFormat="RGBA",H.height=d,H.width=h}else H.tensorFormat="RGBA",H.height=d,H.width=h;l.drawImage(e,0,0),i=l.getImageData(0,0,h,d).data}else throw new Error("Can not access image data")}else if(a){let c,l;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(c=t.resizedHeight,l=t.resizedWidth):(c=e.height,l=e.width),t!==void 0&&(H=t),H.format="RGBA",H.height=c,H.width=l,t!==void 0){let d=o();d.width=l,d.height=c;let h=_(d);if(h!=null)h.putImageData(e,0,0),i=h.getImageData(0,0,l,c).data;else throw new Error("Can not access image data")}else i=e.data}else if(n){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=o();c.width=e.width,c.height=e.height;let l=_(c);if(l!=null){let d=e.height,h=e.width;return l.drawImage(e,0,0,h,d),i=l.getImageData(0,0,h,d).data,H.height=d,H.width=h,yo(i,H)}else throw new Error("Can not access image data")}else{if(s)return new Promise((c,l)=>{let d=o(),h=_(d);if(!e||!h)return l();let $=new Image;$.crossOrigin="Anonymous",$.src=e,$.onload=()=>{d.width=$.width,d.height=$.height,h.drawImage($,0,0,d.width,d.height);let m=h.getImageData(0,0,d.width,d.height);H.height=d.height,H.width=d.width,c(yo(m.data,H))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(i!==void 0)return yo(i,H);throw new Error("Input data provided is not supported - aborted tensor creation")},Wh=(e,t)=>{let{width:r,height:a,download:n,dispose:s}=t,i=[1,a,r,4];return new mt({location:"texture",type:"float32",texture:e,dims:i,download:n,dispose:s})},Vh=(e,t)=>{let{dataType:r,dims:a,download:n,dispose:s}=t;return new mt({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:a,download:n,dispose:s})},jh=(e,t)=>{let{dataType:r,dims:a,download:n,dispose:s}=t;return new mt({location:"ml-tensor",type:r??"float32",mlTensor:e,dims:a,download:n,dispose:s})},qh=(e,t,r)=>new mt({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]});var Ta=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),os=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Xh=!1,zh=()=>{if(!Xh){Xh=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,a=typeof r<"u"&&r.from;e&&(Ta.set("int64",BigInt64Array),os.set(BigInt64Array,"int64")),t&&(Ta.set("uint64",BigUint64Array),os.set(BigUint64Array,"uint64")),a?(Ta.set("float16",r),os.set(r,"float16")):Ta.set("float16",Uint16Array)}};var Jh=e=>{let t=1;for(let r=0;r<e.length;r++){let a=e[r];if(typeof a!="number"||!Number.isSafeInteger(a))throw new TypeError(`dims[${r}] must be an integer, got: ${a}`);if(a<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${a}`);t*=a}return t},Qh=(e,t)=>{switch(e.location){case"cpu":return new mt(e.type,e.data,t);case"cpu-pinned":return new mt({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new mt({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new mt({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case"ml-tensor":return new mt({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}};var mt=class{constructor(t,r,a){zh();let n,s;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,n=t.type,s=t.dims,t.location){case"cpu-pinned":{let H=Ta.get(n);if(!H)throw new TypeError(`unsupported type "${n}" to create tensor from pinned buffer`);if(!(t.data instanceof H))throw new TypeError(`buffer should be of type ${H.name}`);this.cpuData=t.data;break}case"texture":{if(n!=="float32")throw new TypeError(`unsupported type "${n}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(n!=="float32"&&n!=="float16"&&n!=="int32"&&n!=="int64"&&n!=="uint32"&&n!=="uint8"&&n!=="bool"&&n!=="uint4"&&n!=="int4")throw new TypeError(`unsupported type "${n}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(n!=="float32"&&n!=="float16"&&n!=="int32"&&n!=="int64"&&n!=="uint32"&&n!=="uint64"&&n!=="int8"&&n!=="uint8"&&n!=="bool"&&n!=="uint4"&&n!=="int4")throw new TypeError(`unsupported type "${n}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let H,o;if(typeof t=="string")if(n=t,o=a,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");H=r}else{let _=Ta.get(t);if(_===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&_===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${_.name} as data.`);t==="uint64"||t==="int64"?H=_.from(r,BigInt):H=_.from(r)}else if(r instanceof _)H=r;else if(r instanceof Uint8ClampedArray)if(t==="uint8")H=Uint8Array.from(r);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&r instanceof Uint16Array&&_!==Uint16Array)H=new globalThis.Float16Array(r.buffer,r.byteOffset,r.length);else throw new TypeError(`A ${n} tensor's data must be type of ${_}`)}else if(o=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let _=typeof t[0];if(_==="string")n="string",H=t;else if(_==="boolean")n="bool",H=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${_}.`)}else if(t instanceof Uint8ClampedArray)n="uint8",H=Uint8Array.from(t);else{let _=os.get(t.constructor);if(_===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);n=_,H=t}if(o===void 0)o=[H.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");s=o,this.cpuData=H,this.dataLocation="cpu"}let i=Jh(s);if(this.cpuData&&i!==this.cpuData.length&&!((n==="uint4"||n==="int4")&&Math.ceil(i/2)===this.cpuData.length))throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=n,this.dims=s,this.size=i}static async fromImage(t,r){return Kh(t,r)}static fromTexture(t,r){return Wh(t,r)}static fromGpuBuffer(t,r){return Vh(t,r)}static fromMLTensor(t,r){return jh(t,r)}static fromPinnedBuffer(t,r,a){return qh(t,r,a)}toDataURL(t){return Zh(this,t)}toImageData(t){return Uh(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let r=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=r,t&&this.disposer&&(this.disposer(),this.disposer=void 0),r}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Qh(this,t)}};var Bo=mt;var dH=ih($1(),1);import fM from"fs";import{Readable as EM}from"stream";import{pipeline as $M}from"stream/promises";var Cx=Object.defineProperty,fn=(e=>typeof Pe<"u"?Pe:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof Pe<"u"?Pe:t)[r]}):e)(function(e){if(typeof Pe<"u")return Pe.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),wn=(e,t)=>{for(var r in t)Cx(e,r,{get:t[r],enumerable:!0})},wx="4.2.0",ic=typeof self<"u",Cn=!Q$(xx),X$=!Q$(Dn),rH=ic&&"caches"in self,yx=typeof globalThis.Deno<"u",$7=typeof globalThis.Bun<"u",EH=yx&&rH&&!Cn,z$=typeof process<"u",J$=z$&&process?.release?.name==="node"&&!EH,Hc=typeof window<"u"&&typeof window.document<"u",oc=ic&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),Bx=Hc||oc||EH,Mx=J$||typeof navigator<"u"&&"gpu"in navigator,Px=typeof navigator<"u"&&"ml"in navigator,Rx=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",kx=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",Ox=typeof ServiceWorkerGlobalScope<"u"&&ic&&self instanceof ServiceWorkerGlobalScope,Gx=()=>{if(typeof navigator>"u")return!1;let e=navigator.userAgent,r=(navigator.vendor||"").indexOf("Apple")>-1,a=!e.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!e.includes("Chrome")&&!e.includes("Android");return r&&a},Fx=Gx(),me=Object.freeze({IS_BROWSER_ENV:Hc,IS_WEBWORKER_ENV:oc,IS_WEB_ENV:Bx,IS_SERVICE_WORKER_ENV:Ox,IS_DENO_WEB_RUNTIME:EH,IS_WEB_CACHE_AVAILABLE:rH,IS_WEBGPU_AVAILABLE:Mx,IS_WEBNN_AVAILABLE:Px,IS_SAFARI:Fx,IS_PROCESS_AVAILABLE:z$,IS_NODE_ENV:J$,IS_FS_AVAILABLE:Cn,IS_PATH_AVAILABLE:X$,IS_CRYPTO_AVAILABLE:Rx,IS_CHROME_AVAILABLE:kx}),_c=Cn&&X$,aH="./";if(_c){let e=Object(import.meta).url;e?aH=Dn.dirname(Dn.dirname(Nx.fileURLToPath(e))):typeof __dirname<"u"&&(aH=Dn.dirname(__dirname))}var Zx=_c?Dn.join(aH,"/.cache/"):null,m1="/models/",Ux=_c?Dn.join(aH,m1):m1,Kx=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,sr=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),I1=sr.WARNING,Te={version:wx,backends:{onnx:{}},get logLevel(){return I1},set logLevel(e){I1=e,Te.backends.onnx?.setLogLevel?.(e)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(Hc||oc||EH),localModelPath:Ux,useFS:Cn,useBrowserCache:rH,useFSCache:Cn,cacheDir:Zx,useCustomCache:!1,customCache:null,useWasmCache:rH||Cn,cacheKey:"transformers-cache",experimental_useCrossOriginStorage:!1,fetch:Kx};function Q$(e){return Object.keys(e).length===0}var Ft=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 pa(e,t){e&&e(t)}var U_=class extends Ft{constructor(e,t){super(),this.callback=e,this.files_loading=t}_call(e){if(e.status==="progress"){this.files_loading[e.file]={loaded:e.loaded,total:e.total};let t=Object.values(this.files_loading).reduce((n,s)=>n+s.loaded,0),r=Object.values(this.files_loading).reduce((n,s)=>n+s.total,0),a=r>0?t/r*100:0;this.callback({status:"progress_total",name:e.name,progress:a,loaded:t,total:r,files:structuredClone(this.files_loading)})}this.callback(e)}};function Wx(e){return Number.isInteger(e)||typeof e=="bigint"}function S1(e){return e==null||e===-1}function L1(e){let t=[],r=e;for(;Array.isArray(r);)t.push(r.length),r=r[0];return t}function ir(...e){return Array.prototype.concat.apply([],e)}function Vx(...e){return e.reduce((t,r)=>t.flatMap(a=>r.map(n=>[a,n])))}function nH(e,t){return Math.abs((e+t)%(2*t)-t)}function ht(e,t){return Object.assign({},...t.map(r=>{if(e[r]!==void 0)return{[r]:e[r]}}))}function jx(e,t){let r=0;for(let a of e)a===t&&++r;return r}var he={error(...e){Te.logLevel<=sr.ERROR&&console.error(...e)},warn(...e){Te.logLevel<=sr.WARNING&&console.warn(...e)},info(...e){Te.logLevel<=sr.INFO&&console.log(...e)},debug(...e){Te.logLevel<=sr.DEBUG&&console.log(...e)},log(...e){this.info(...e)}},qx=class{constructor(e){this.trie=this._build_trie(e)}_build_trie(e){let t=Object.create(null);for(let r of e){let a=t;for(let n=0;n<r.length;++n){let s=r[n];a=a[s]??=Object.create(null)}a.end=r}return t}split(e){let t=[],r=e.length,a=0,n=0;for(;n<r;){let s=this.trie,i=null,H=n;for(;H<r&&(s=s[e[H]]);)s.end&&(i=s.end),++H;i?(n>a&&t.push(e.slice(a,n)),t.push(i),n+=i.length,a=n):++n}return a<r&&t.push(e.slice(a)),t}},A1=qx,Xx=class{constructor(e){this.content=e.content,this.id=e.id,this.single_word=e.single_word??!1,this.lstrip=e.lstrip??!1,this.rstrip=e.rstrip??!1,this.special=e.special??!1,this.normalized=e.normalized??!this.special}},zx=Xx,Y$=(()=>{let e=[...Array.from({length:94},(n,s)=>s+33),...Array.from({length:12},(n,s)=>s+161),...Array.from({length:82},(n,s)=>s+174)],t=e.slice(),r=0;for(let n=0;n<256;++n)e.includes(n)||(e.push(n),t.push(256+r),r+=1);let a=t.map(n=>String.fromCharCode(n));return Object.fromEntries(e.map((n,s)=>[n,a[s]]))})(),Jx=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[r,t])),Qx=Jx(Y$),g1=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",Yx=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"],["(?i:[sdmt]|ll|ve|re)","(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])"],["[^\\r\\n\\p{L}\\p{N}]?+","[^\\r\\n\\p{L}\\p{N}]?"],["[^\\s\\p{L}\\p{N}]++","[^\\s\\p{L}\\p{N}]+"],["(?>\\p{Nd}{510})","(?:\\p{Nd}{510})"],["\\p{Nd}{3}+","(?:\\p{Nd}{3})+"],["\\G",""],[` ?[^(\\s|[${g1}])]+`,` ?[^\\s${g1}]+`]]),sH="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",cc=e=>e.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n't/g,"n't").replace(/ 'm/g,"'m").replace(/ 's/g,"'s").replace(/ 've/g,"'ve").replace(/ 're/g,"'re"),$H=(e,t=!0)=>{if(e.Regex!==void 0){let r=e.Regex.replace(/\\([#&~])/g,"$1");r=r.replace(/\\A/g,"^").replace(/\\z/g,"$").replace(/\\Z/g,"(?=\\r?\\n?$)");for(let[a,n]of Yx)r=r.replaceAll(a,n);try{return new RegExp(r,"gu")}catch(a){if(!(a instanceof SyntaxError)||!a.message.toLowerCase().includes("invalid property name"))throw a;let n=!1,s=r.replace(/(\\[pP])\{([^}=]+)\}/g,(i,H,o)=>{try{return new RegExp(`\\p{${o}}`,"u"),`${H}{${o}}`}catch{return n=!0,`${H}{Script=${o}}`}});if(!n)throw a;try{return new RegExp(s,"gu")}catch{throw a}}}else if(e.String!==void 0){let r=eN(e.String);return new RegExp(t?r:`(${r})`,"gu")}else return console.warn("Unknown pattern type:",e),null},eN=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),tN=(e,t,r)=>{let a=[],n=0;for(;n<e.length;){if(a.push(e[n]),(t.get(e[n])??r)!==r){++n;continue}for(;++n<e.length&&(t.get(e[n])??r)===r;)t.get(a.at(-1))!==r&&(a[a.length-1]+=e[n])}return a},rN=e=>e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,aN=e=>Number.isInteger(e)||typeof e=="bigint",nN=e=>{let t=0;for(let r of e)++t;return t},sN=e=>e0(e.toLowerCase()),Hr=(...e)=>Array.prototype.concat.apply([],e),lc=e=>new Map(Object.entries(e)),iN=(e,t)=>{let r=[],a=0;for(let n of e.matchAll(t)){let s=n[0];a<n.index&&r.push(e.slice(a,n.index)),s.length>0&&r.push(s),a=n.index+s.length}return a<e.length&&r.push(e.slice(a)),r},e0=e=>e.replace(/\p{M}/gu,""),T1=(e,t,r=[])=>{if(!e||Array.isArray(e)||typeof e!="object")return`${t} must be a valid object`;for(let a of r)if(!(a in e))return`${t} must contain a "${a}" property`;return null},HN=e=>e.match(/\S+/g)||[],oN=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}},Bs=oN,_N=class extends Bs{constructor(e){super(),this.config=e}_call(e){return this.normalize(e)}},Qr=_N,cN=class extends Qr{tokenize_chinese_chars(e){let t=[];for(let r=0;r<e.length;++r){let a=e[r],n=a.charCodeAt(0);rN(n)?(t.push(" "),t.push(a),t.push(" ")):t.push(a)}return t.join("")}strip_accents(e){return e.normalize("NFD").replace(/\p{Mn}/gu,"")}is_control(e){switch(e){case" ":case`
|
|
3
|
+
`:case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(e)}}clean_text(e){let t=[];for(let r of e){let a=r.charCodeAt(0);a===0||a===65533||this.is_control(r)||(/^\s$/.test(r)?t.push(" "):t.push(r))}return t.join("")}normalize(e){return this.config.clean_text&&(e=this.clean_text(e)),this.config.handle_chinese_chars&&(e=this.tokenize_chinese_chars(e)),this.config.lowercase?(e=e.toLowerCase(),this.config.strip_accents!==!1&&(e=this.strip_accents(e))):this.config.strip_accents&&(e=this.strip_accents(e)),e}},lN=cN,uN=class extends Qr{constructor(e){super(e),this.charsmap=e.precompiled_charsmap??null}normalize(e){return e=e.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,""),e=e.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm," "),e.includes("\uFF5E")?e=e.split("\uFF5E").map(r=>r.normalize("NFKC")).join("\uFF5E"):e=e.normalize("NFKC"),e}},dN=uN,pN=class extends Qr{constructor(e){super(e),this.normalizers=(e.normalizers??[]).map(t=>t0(t))}normalize(e){return this.normalizers.reduce((t,r)=>r?r.normalize(t):t,e)}},hN=pN,fN=class extends Qr{normalize(e){let t=$H(this.config.pattern??{});return t===null?e:e.replaceAll(t,this.config.content??"")}},EN=fN,$N=class extends Qr{constructor(){super(...arguments),this.form="NFC"}normalize(e){return e=e.normalize(this.form),e}},mH=$N,mN=class extends mH{constructor(){super(...arguments),this.form="NFC"}},IN=mN,SN=class extends mH{constructor(){super(...arguments),this.form="NFD"}},LN=SN,AN=class extends mH{constructor(){super(...arguments),this.form="NFKC"}},gN=AN,TN=class extends mH{constructor(){super(...arguments),this.form="NFKD"}},bN=TN,vN=class extends Qr{normalize(e){return this.config.strip_left&&this.config.strip_right?e=e.trim():(this.config.strip_left&&(e=e.trimStart()),this.config.strip_right&&(e=e.trimEnd())),e}},DN=vN,CN=class extends Qr{normalize(e){return e0(e)}},xN=CN,NN=class extends Qr{normalize(e){return e.toLowerCase()}},wN=NN,yN=class extends Qr{normalize(e){return e=this.config.prepend+e,e}},BN=yN;function MN(e){if(e===null)return null;switch(e.type){case"BertNormalizer":return new lN(e);case"Precompiled":return new dN(e);case"Sequence":return new hN(e);case"Replace":return new EN(e);case"NFC":return new IN(e);case"NFD":return new LN(e);case"NFKC":return new gN(e);case"NFKD":return new bN(e);case"Strip":return new DN(e);case"StripAccents":return new xN(e);case"Lowercase":return new wN(e);case"Prepend":return new BN(e);default:throw new Error(`Unknown Normalizer type: ${e.type}`)}}var t0=MN,PN=class extends Bs{pre_tokenize(e,t){return(Array.isArray(e)?e.map(r=>this.pre_tokenize_text(r,t)):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}},cr=PN,RN=class extends cr{constructor(e){super(),this.config=e,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=Y$,this.text_encoder=new TextEncoder}pre_tokenize_text(e,t){return this.add_prefix_space&&!e.startsWith(" ")&&(e=" "+e),(this.use_regex?e.match(this.pattern)||[]:[e]).map(a=>Array.from(this.text_encoder.encode(a),n=>this.byte_encoder[n]).join(""))}},kN=RN,ON=class extends cr{pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}},GN=ON,FN=class extends cr{constructor(e){super(),this.replacement=e.replacement??"\u2581",this.str_rep=e.str_rep||this.replacement,this.prepend_scheme=e.prepend_scheme??"always"}pre_tokenize_text(e,t){let{section_index:r=void 0}=t??{},a=e.replaceAll(" ",this.str_rep);return!a.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&r===0)&&(a=this.str_rep+a),[a]}},ZN=FN,UN=class extends cr{constructor(e){super(),this.config=e,this.pattern=$H(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(e){return this.pattern===null?[]:this.config.invert?e.match(this.pattern)||[]:this.config.behavior?.toLowerCase()==="removed"?e.split(this.pattern).filter(t=>t):iN(e,this.pattern)}},KN=UN,WN=class extends cr{constructor(e){super(),this.config=e,this.pattern=new RegExp(`[^${sH}]+|[${sH}]+`,"gu")}pre_tokenize_text(e){return e.match(this.pattern)||[]}},VN=WN,jN=class extends cr{constructor(e){super(),this.config=e;let t=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(t,"gu")}pre_tokenize_text(e){return e.match(this.pattern)||[]}},qN=jN,XN=class extends cr{constructor(){super(),this.pattern=new RegExp(`[^\\s${sH}]+|[${sH}]`,"gu")}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}},zN=XN,JN=class extends cr{constructor(e){super(),this.config=e,this.pattern=$H(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(e){return this.pattern===null?[e]:[e.replaceAll(this.pattern,this.config.content??"")]}},QN=JN,YN=class extends cr{constructor(e){super(),this.tokenizers=(e.pretokenizers??[]).map(t=>r0(t))}pre_tokenize_text(e,t){return this.tokenizers.reduce((r,a)=>a?a.pre_tokenize(r,t):r,[e])}},ew=YN,tw=class extends cr{pre_tokenize_text(e){return HN(e)}},rw=tw,aw=class extends cr{constructor(e){super(),this.config=e,this._length=e.length}pre_tokenize_text(e){let t=[];for(let r=0;r<e.length;r+=this._length)t.push(e.slice(r,r+this._length));return t}},nw=aw;function sw(e){if(e===null)return null;switch(e.type){case"BertPreTokenizer":return new zN;case"Sequence":return new ew(e);case"Whitespace":return new GN;case"WhitespaceSplit":return new rw;case"Metaspace":return new ZN(e);case"ByteLevel":return new kN(e);case"Split":return new KN(e);case"Punctuation":return new VN(e);case"Digits":return new qN(e);case"Replace":return new QN(e);case"FixedLength":return new nw(e);default:throw new Error(`Unknown PreTokenizer type: ${e.type}`)}}var r0=sw,iw=class extends Bs{constructor(e){super(),this.config=e,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}_call(e){let t=this.encode(e);return this.fuse_unk&&(t=tN(t,this.tokens_to_ids,this.unk_token_id)),t}},IH=iw,Hw=class extends IH{constructor(e){super(e),this.max_input_chars_per_word=100,this.tokens_to_ids=lc(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.max_input_chars_per_word=e.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(let[t,r]of this.tokens_to_ids)this.vocab[r]=t}encode(e){let t=[];for(let r of e){let a=[...r];if(a.length>this.max_input_chars_per_word){t.push(this.unk_token);continue}let n=!1,s=0,i=[];for(;s<a.length;){let H=a.length,o=null;for(;s<H;){let _=a.slice(s,H).join("");if(s>0&&(_=this.config.continuing_subword_prefix+_),this.tokens_to_ids.has(_)){o=_;break}--H}if(o===null){n=!0;break}i.push(o),s=H}n?t.push(this.unk_token):t.push(...i)}return t}},b1=Hw,v1=class a0{constructor(t,r){this.is_leaf=t,this.children=r}static default(){return new a0(!1,new Map)}},ow=class{constructor(){this.root=v1.default()}extend(e){for(let t of e)this.push(t)}push(e){let t=this.root;for(let r of e){let a=t.children.get(r);a===void 0&&(a=v1.default(),t.children.set(r,a)),t=a}t.is_leaf=!0}*common_prefix_search(e){let t=this.root;if(t===void 0)return;let r="";for(let a of e){if(r+=a,t=t.children.get(a),t===void 0)return;t.is_leaf&&(yield r)}}},_w=ow,l_=class n0{constructor(t,r,a,n,s){this.token_id=t,this.node_id=r,this.pos=a,this.length=n,this.score=s,this.prev=null,this.backtrace_score=0}clone(){let t=new n0(this.token_id,this.node_id,this.pos,this.length,this.score);return t.prev=this.prev,t.backtrace_score=this.backtrace_score,t}},cw=class{constructor(e,t,r){this.chars=Array.from(e),this.len=this.chars.length,this.bos_token_id=t,this.eos_token_id=r,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let a=new l_(this.bos_token_id??0,0,0,0,0),n=new l_(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(a.clone()),this.nodes.push(n.clone()),this.begin_nodes[this.len].push(n),this.end_nodes[0].push(a)}insert(e,t,r,a){let n=this.nodes.length,s=new l_(a,n,e,t,r);this.begin_nodes[e].push(s),this.end_nodes[e+t].push(s),this.nodes.push(s)}viterbi(){let e=this.len,t=0;for(;t<=e;){if(this.begin_nodes[t].length==0)return[];for(let i of this.begin_nodes[t]){i.prev=null;let H=0,o=null;for(let _ of this.end_nodes[t]){let c=_.backtrace_score+i.score;(o===null||c>H)&&(o=_.clone(),H=c)}if(o!==null)i.prev=o,i.backtrace_score=H;else return[]}++t}let r=[],n=this.begin_nodes[e][0].prev;if(n===null)return[];let s=n.clone();for(;s.prev!==null;)r.push(s.clone()),s=s.clone().prev.clone();return r.reverse(),r}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join("")}tokens(){return this.viterbi().map(t=>this.piece(t))}token_ids(){return this.viterbi().map(t=>t.token_id)}},lw=cw;function uw(e){if(e.length===0)throw new Error("Array must not be empty");let t=e[0],r=0;for(let a=1;a<e.length;++a)e[a]<t&&(t=e[a],r=a);return[t,r]}var dw=class extends IH{constructor(e,t){super(e);let r=e.vocab.length;this.vocab=new Array(r),this.scores=new Array(r);for(let a=0;a<r;++a)[this.vocab[a],this.scores[a]]=e.vocab[a];this.unk_token_id=e.unk_id,this.unk_token=this.vocab[e.unk_id],this.tokens_to_ids=new Map(this.vocab.map((a,n)=>[a,n])),this.bos_token=" ",this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=uw(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new _w,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(e){let t=e.chars,r=1,a=0;for(;a<t.length;){let n=!1,s=[],i=t.slice(a).join(""),H=this.trie.common_prefix_search(i);for(let o of H){s.push(o);let _=this.tokens_to_ids.get(o),c=this.scores[_],l=nN(o);e.insert(a,l,c,_),!n&&l===r&&(n=!0)}n||e.insert(a,r,this.unk_score,this.unk_token_id),a+=r}}tokenize(e){let t=new lw(e,this.bos_token_id,this.eos_token_id);return this.populate_nodes(t),t.tokens()}encode(e){let t=[];for(let r of e){let a=this.tokenize(r);t.push(...a)}return t}},D1=dw,pw=class{constructor(e=(r,a)=>r>a,t=1/0){this._heap=[],this._comparator=e,this._max_size=t}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(let t of e)if(this.size<this._max_size)this._heap.push(t),this._sift_up();else{let r=this._smallest();this._comparator(t,this._heap[r])&&(this._heap[r]=t,this._sift_up_from(r))}return this.size}pop(){let e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._sift_down(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._sift_down(),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}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(e){for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_sift_down(){let e=0;for(;this._left(e)<this.size&&this._greater(this._left(e),e)||this._right(e)<this.size&&this._greater(this._right(e),e);){let t=this._right(e)<this.size&&this._greater(this._right(e),this._left(e))?this._right(e):this._left(e);this._swap(e,t),e=t}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},hw=pw,fw=class{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;let t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)&&this.cache.delete(e),this.cache.set(e,t),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},Ew=fw,$w=class extends IH{constructor(e){super(e),this.tokens_to_ids=lc(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(let[r,a]of this.tokens_to_ids)this.vocab[a]=r;let t=Array.isArray(e.merges[0]);this.merges=t?e.merges:e.merges.map(r=>r.split(" ",2)),this.bpe_ranks=new Map(this.merges.map((r,a)=>[JSON.stringify(r),a])),this.end_of_word_suffix=e.end_of_word_suffix,this.continuing_subword_suffix=e.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new Ew(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(e){if(e.length===0)return[];let t=this.cache.get(e);if(t!==void 0)return t;let r=Array.from(e);this.end_of_word_suffix&&(r[r.length-1]+=this.end_of_word_suffix);let a=[];if(r.length>1){let n=new hw((H,o)=>H.score<o.score),s={token:r[0],bias:0,prev:null,next:null},i=s;for(let H=1;H<r.length;++H){let o={bias:H/r.length,token:r[H],prev:i,next:null};i.next=o,this.add_node(n,i),i=o}for(;!n.is_empty();){let H=n.pop();if(H.deleted||!H.next||H.next.deleted)continue;if(H.deleted=!0,H.next.deleted=!0,H.prev){let _={...H.prev};H.prev.deleted=!0,H.prev=_,_.prev?_.prev.next=_:s=_}let o={token:H.token+H.next.token,bias:H.bias,prev:H.prev,next:H.next.next};o.prev?(o.prev.next=o,this.add_node(n,o.prev)):s=o,o.next&&(o.next.prev=o,this.add_node(n,o))}for(let H=s;H!==null;H=H.next)a.push(H.token)}else a=r;if(this.continuing_subword_suffix)for(let n=0;n<a.length-1;++n)a[n]+=this.continuing_subword_suffix;return e.length<this.max_length_to_cache&&this.cache.put(e,a),a}add_node(e,t){let r=this.bpe_ranks.get(JSON.stringify([t.token,t.next.token]));r!==void 0&&(t.score=r+t.bias,e.push(t))}encode(e){let t=[];for(let r of e){if(this.ignore_merges&&this.tokens_to_ids.has(r)){t.push(r);continue}let a=this.bpe(r);for(let n of a)if(this.tokens_to_ids.has(n))t.push(n);else if(this.byte_fallback){let s=Array.from(this.text_encoder.encode(n)).map(i=>`<0x${i.toString(16).toUpperCase().padStart(2,"0")}>`);s.every(i=>this.tokens_to_ids.has(i))?t.push(...s):this.unk_token!=null&&t.push(this.unk_token)}else this.unk_token!=null&&t.push(this.unk_token)}return t}},C1=$w,mw=class extends IH{constructor(e,t){super(e);let r=e.vocab;this.tokens_to_ids=lc(t.target_lang?r[t.target_lang]:r),this.bos_token=t.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=t.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=t.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(let[a,n]of this.tokens_to_ids)this.vocab[n]=a}encode(e){return e}},Iw=mw;function Sw(e,t){switch(e.type){case"WordPiece":return new b1(e);case"Unigram":return new D1(e,t.eos_token);case"BPE":return new C1(e);default:if(e.vocab)return Array.isArray(e.vocab)?new D1(e,t.eos_token):Object.hasOwn(e,"continuing_subword_prefix")&&Object.hasOwn(e,"unk_token")?Object.hasOwn(e,"merges")?new C1(e):new b1(e):new Iw(e,{target_lang:t.target_lang,bos_token:t.bos_token,eos_token:t.eos_token,pad_token:t.pad_token,unk_token:t.unk_token});throw new Error(`Unknown TokenizerModel type: ${e?.type}`)}}var Lw=Sw,Aw=class extends Bs{constructor(e){super(),this.config=e}_call(e,...t){return this.post_process(e,...t)}},Ms=Aw,gw=class extends Ms{post_process(e,t=null,r=!0){let a=t===null?this.config.single:this.config.pair,n=[],s=[];for(let i of a)"SpecialToken"in i?r&&(n.push(i.SpecialToken.id),s.push(i.SpecialToken.type_id)):"Sequence"in i&&(i.Sequence.id==="A"?(n=Hr(n,e),s=Hr(s,new Array(e.length).fill(i.Sequence.type_id))):i.Sequence.id==="B"&&(n=Hr(n,t),s=Hr(s,new Array(t.length).fill(i.Sequence.type_id))));return{tokens:n,token_type_ids:s}}},Tw=gw,bw=class extends Ms{post_process(e,t=null){return{tokens:e,tokens_pair:t}}},vw=bw,Dw=class extends Ms{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t=null,r=!0){r&&(e=Hr([this.cls[0]],e,[this.sep[0]]));let a=new Array(e.length).fill(0);if(t){let n=[],s=r?[this.sep[0]]:[];e=Hr(e,n,t,s),a=Hr(a,new Array(t.length+n.length+s.length).fill(1))}return{tokens:e,token_type_ids:a}}},Cw=Dw,xw=class extends Ms{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t,r=!0){r&&(e=Hr([this.cls[0]],e,[this.sep[0]]));let a=new Array(e.length).fill(0);if(t){let n=r?[this.sep[0]]:[],s=r?[this.sep[0]]:[];e=Hr(e,n,t,s),a=Hr(a,new Array(t.length+n.length+s.length).fill(1))}return{tokens:e,token_type_ids:a}}},Nw=xw,ww=class extends Ms{constructor(e){super(e),this.processors=(e.processors??[]).map(t=>s0(t))}post_process(e,t=null,r=!0){let a={tokens:e,tokens_pair:t};for(let n of this.processors)a=n.post_process(a.tokens,a.tokens_pair,r);return a}},yw=ww;function Bw(e){if(e===null)return null;switch(e.type){case"TemplateProcessing":return new Tw(e);case"ByteLevel":return new vw(e);case"BertProcessing":return new Cw(e);case"RobertaProcessing":return new Nw(e);case"Sequence":return new yw(e);default:throw new Error(`Unknown PostProcessor type: ${e.type}`)}}var s0=Bw,Mw=class extends Bs{constructor(e){super(),this.config=e,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets="trim_offsets"in e?e.trim_offsets:!1}_call(e){return this.decode(e)}decode(e){return this.decode_chain(e).join("")}},lr=Mw,Pw=class extends lr{constructor(e){super(e),this.byte_decoder=Qx,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){let t=e.join(""),r=new Uint8Array([...t].map(a=>this.byte_decoder[a]));return this.text_decoder.decode(r)}decode_chain(e){let t=[],r=[];for(let a of e)this.added_tokens.find(n=>n.content===a)!==void 0?(r.length>0&&(t.push(this.convert_tokens_to_string(r)),r=[]),t.push(a)):r.push(a);return r.length>0&&t.push(this.convert_tokens_to_string(r)),t}},Rw=Pw,kw=class extends lr{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map((t,r)=>{if(r!==0){let a=this.config.prefix;a&&t.startsWith(a)?t=t.replace(a,""):t=" "+t}return this.cleanup&&(t=cc(t)),t})}},Ow=kw,Gw=class extends lr{constructor(e){super(e),this.replacement=e.replacement??"\u2581"}decode_chain(e){let t=[];for(let r=0;r<e.length;++r){let a=e[r].replaceAll(this.replacement," ");r==0&&a.startsWith(" ")&&(a=a.substring(1)),t.push(a)}return t}},Fw=Gw,Zw=class extends lr{constructor(e){super(e),this.suffix=e.suffix??""}decode_chain(e){return e.map((t,r)=>t.replaceAll(this.suffix,r===e.length-1?"":" "))}},Uw=Zw,Kw=class extends lr{constructor(e){super(e),this.pad_token=e.pad_token??"",this.word_delimiter_token=e.word_delimiter_token??"",this.cleanup=e.cleanup}convert_tokens_to_string(e){if(e.length===0)return"";let t=[e[0]];for(let n=1;n<e.length;++n)e[n]!==t.at(-1)&&t.push(e[n]);let a=t.filter(n=>n!==this.pad_token).join("");return this.cleanup&&(a=cc(a).replaceAll(this.word_delimiter_token," ").trim()),a}decode_chain(e){return[this.convert_tokens_to_string(e)]}},Ww=Kw,Vw=class extends lr{constructor(e){super(e),this.decoders=(e.decoders??[]).map(t=>i0(t))}decode_chain(e){return this.decoders.reduce((t,r)=>r.decode_chain(t),e)}},jw=Vw,qw=class extends lr{decode_chain(e){let t=$H(this.config.pattern),r=this.config.content??"";return t===null?e:e.map(a=>a.replaceAll(t,r))}},Xw=qw,zw=class extends lr{decode_chain(e){return[e.join("")]}},Jw=zw,Qw=class extends lr{constructor(e){super(e),this.content=e.content??"",this.start=e.start??0,this.stop=e.stop??0}decode_chain(e){return e.map(t=>{let r=0;for(let n=0;n<this.start&&t[n]===this.content;++n){r=n+1;continue}let a=t.length;for(let n=0;n<this.stop;++n){let s=t.length-n-1;if(t[s]===this.content){a=s;continue}else break}return t.slice(r,a)})}},Yw=Qw,ey=class extends lr{constructor(e){super(e),this.text_decoder=new TextDecoder}decode_chain(e){let t=[],r=[];for(let a of e){let n=null;if(a.length===6&&a.startsWith("<0x")&&a.endsWith(">")){let s=parseInt(a.slice(3,5),16);isNaN(s)||(n=s)}if(n!==null)r.push(n);else{if(r.length>0){let s=this.text_decoder.decode(Uint8Array.from(r));t.push(s),r=[]}t.push(a)}}if(r.length>0){let a=this.text_decoder.decode(Uint8Array.from(r));t.push(a),r=[]}return t}},ty=ey;function ry(e){if(e===null)return null;switch(e.type){case"ByteLevel":return new Rw(e);case"WordPiece":return new Ow(e);case"Metaspace":return new Fw(e);case"BPEDecoder":return new Uw(e);case"CTC":return new Ww(e);case"Sequence":return new jw(e);case"Replace":return new Xw(e);case"Fuse":return new Jw(e);case"Strip":return new Yw(e);case"ByteFallback":return new ty(e);default:throw new Error(`Unknown Decoder type: ${e.type}`)}}var i0=ry,ay=class{constructor(e,t){let r=T1(e,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(r)throw new Error(r);let a=T1(t,"Config");if(a)throw new Error(a);this.tokenizer=e,this.config=t,this.normalizer=t0(this.tokenizer.normalizer),this.pre_tokenizer=r0(this.tokenizer.pre_tokenizer),this.model=Lw(this.tokenizer.model,this.config),this.post_processor=s0(this.tokenizer.post_processor),this.decoder=i0(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let n=[],s=[];this.added_tokens_map=new Map;for(let i of this.tokenizer.added_tokens){let H=new zx(i);if(this.added_tokens.push(H),this.model.tokens_to_ids.set(H.content,H.id),this.model.vocab[H.id]=H.content,H.special&&(this.special_tokens.push(H.content),this.all_special_ids.push(H.id)),this.added_tokens_map.set(H.content,H),H.normalized&&this.normalizer!==null){let o=this.normalizer(H.content);s.push(o),this.added_tokens_map.set(o,H)}else n.push(H.content)}(this.config.additional_special_tokens??[]).forEach(i=>{this.special_tokens.includes(i)||this.special_tokens.push(i)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new A1(n),this.splitter_normalized=new A1(s),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:a=null}={}){let{tokens:n,token_type_ids:s}=this.tokenize_helper(e,{text_pair:t,add_special_tokens:r}),i=n.map(o=>this.added_tokens_map.get(o)?.id??this.model.tokens_to_ids.get(o)??this.model.unk_token_id),H={ids:i,tokens:n,attention_mask:new Array(i.length).fill(1)};return a&&s&&(H.token_type_ids=s),H}decode(e,t={}){if(!Array.isArray(e)||e.length===0||!aN(e[0]))throw Error("token_ids must be a non-empty array of integers.");let r=e.map(n=>this.model.vocab[Number(n)]??this.model.unk_token);t.skip_special_tokens&&(r=r.filter(n=>!this.special_tokens.includes(n)));let a=this.decoder?this.decoder(r):r.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(a=a.replaceAll(this.decoder.end_of_word_suffix," "),t.skip_special_tokens&&(a=a.trim())),(t.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(a=cc(a)),a}tokenize(e,{text_pair:t=null,add_special_tokens:r=!1}={}){return this.tokenize_helper(e,{text_pair:t,add_special_tokens:r}).tokens}encode_text(e){if(e===null)return null;let t=this.splitter_unnormalized.split(e);return t.forEach((r,a)=>{let n=this.added_tokens_map.get(r);n&&(n.lstrip&&a>0&&(t[a-1]=t[a-1].trimEnd()),n.rstrip&&a<t.length-1&&(t[a+1]=t[a+1].trimStart()))}),t.flatMap((r,a)=>{if(r.length===0)return[];if(this.added_tokens_map.has(r))return[r];if(this.remove_space===!0&&(r=r.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(r=sN(r)),this.normalizer!==null&&(r=this.normalizer(r)),r.length===0)return[];let n=this.splitter_normalized.split(r);return n.forEach((s,i)=>{let H=this.added_tokens_map.get(s);H&&(H.lstrip&&i>0&&(n[i-1]=n[i-1].trimEnd()),H.rstrip&&i<n.length-1&&(n[i+1]=n[i+1].trimStart()))}),n.flatMap(s=>{if(s.length===0)return[];if(this.added_tokens_map.has(s))return[s];let i=this.pre_tokenizer!==null?this.pre_tokenizer(s,{section_index:a}):[s];return this.model(i)})})}tokenize_helper(e,{text_pair:t=null,add_special_tokens:r=!0}){let a=this.encode_text(e),n=this.encode_text(t||null);return this.post_processor?this.post_processor(a,n,r):{tokens:Hr(a??[],n??[])}}token_to_id(e){return this.model.tokens_to_ids.get(e)}id_to_token(e){return this.model.vocab[e]}get_added_tokens_decoder(){let e=new Map;for(let t of this.added_tokens)e.set(t.id,t);return e}get_vocab(e=!0){let t=new Map;for(let r=0;r<this.model.vocab.length;++r){let a=this.model.vocab[r];(e||!this.added_tokens_map.has(a))&&t.set(a,r)}return t}},ny=ay,O=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",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",Comment:"Comment"}),Yt=class{constructor(e,t){this.value=e,this.type=t}};function x1(e){return/\w/.test(e)}function ps(e){return/[0-9]/.test(e)}function N1(e){return/\s/.test(e)}var sy=[["{%",O.OpenStatement],["%}",O.CloseStatement],["{{",O.OpenExpression],["}}",O.CloseExpression],["(",O.OpenParen],[")",O.CloseParen],["{",O.OpenCurlyBracket],["}",O.CloseCurlyBracket],["[",O.OpenSquareBracket],["]",O.CloseSquareBracket],[",",O.Comma],[".",O.Dot],[":",O.Colon],["|",O.Pipe],["<=",O.ComparisonBinaryOperator],[">=",O.ComparisonBinaryOperator],["==",O.ComparisonBinaryOperator],["!=",O.ComparisonBinaryOperator],["<",O.ComparisonBinaryOperator],[">",O.ComparisonBinaryOperator],["+",O.AdditiveBinaryOperator],["-",O.AdditiveBinaryOperator],["~",O.AdditiveBinaryOperator],["*",O.MultiplicativeBinaryOperator],["/",O.MultiplicativeBinaryOperator],["%",O.MultiplicativeBinaryOperator],["=",O.Equals]],iy=new Map([["n",`
|
|
4
|
+
`],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function Hy(e,t={}){return e.endsWith(`
|
|
5
|
+
`)&&(e=e.slice(0,-1)),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%-])/gm,"$1")),t.trim_blocks&&(e=e.replace(/([#%-]})\n/g,"$1")),e.replace(/{%\s*(end)?generation\s*%}/gs,"")}function oy(e,t={}){let r=[],a=Hy(e,t),n=0,s=0,i=_=>{let c="";for(;_(a[n]);){if(a[n]==="\\"){if(++n,n>=a.length)throw new SyntaxError("Unexpected end of input");let l=a[n++],d=iy.get(l);if(d===void 0)throw new SyntaxError(`Unexpected escaped character: ${l}`);c+=d;continue}if(c+=a[n++],n>=a.length)throw new SyntaxError("Unexpected end of input")}return c},H=()=>{let _=r.at(-1);_&&_.type===O.Text&&(_.value=_.value.trimEnd(),_.value===""&&r.pop())},o=()=>{for(;n<a.length&&N1(a[n]);)++n};e:for(;n<a.length;){let _=r.at(-1)?.type;if(_===void 0||_===O.CloseStatement||_===O.CloseExpression||_===O.Comment){let l="";for(;n<a.length&&!(a[n]==="{"&&(a[n+1]==="%"||a[n+1]==="{"||a[n+1]==="#"));)l+=a[n++];if(l.length>0){r.push(new Yt(l,O.Text));continue}}if(a[n]==="{"&&a[n+1]==="#"){n+=2;let l=a[n]==="-";l&&++n;let d="";for(;a[n]!=="#"||a[n+1]!=="}";){if(n+2>=a.length)throw new SyntaxError("Missing end of comment tag");d+=a[n++]}let h=d.endsWith("-");h&&(d=d.slice(0,-1)),l&&H(),r.push(new Yt(d,O.Comment)),n+=2,h&&o();continue}if(a.slice(n,n+3)==="{%-"){H(),r.push(new Yt("{%",O.OpenStatement)),n+=3;continue}if(a.slice(n,n+3)==="{{-"){H(),r.push(new Yt("{{",O.OpenExpression)),s=0,n+=3;continue}if(i(N1),a.slice(n,n+3)==="-%}"){r.push(new Yt("%}",O.CloseStatement)),n+=3,o();continue}if(a.slice(n,n+3)==="-}}"){r.push(new Yt("}}",O.CloseExpression)),n+=3,o();continue}let c=a[n];if(c==="-"||c==="+"){let l=r.at(-1)?.type;if(l===O.Text||l===void 0)throw new SyntaxError(`Unexpected character: ${c}`);switch(l){case O.Identifier:case O.NumericLiteral:case O.StringLiteral:case O.CloseParen:case O.CloseSquareBracket:break;default:{++n;let d=i(ps);r.push(new Yt(`${c}${d}`,d.length>0?O.NumericLiteral:O.UnaryOperator));continue}}}for(let[l,d]of sy){if(l==="}}"&&s>0)continue;if(a.slice(n,n+l.length)===l){r.push(new Yt(l,d)),d===O.OpenExpression?s=0:d===O.OpenCurlyBracket?++s:d===O.CloseCurlyBracket&&--s,n+=l.length;continue e}}if(c==="'"||c==='"'){++n;let l=i(d=>d!==c);r.push(new Yt(l,O.StringLiteral)),++n;continue}if(ps(c)){let l=i(ps);if(a[n]==="."&&ps(a[n+1])){++n;let d=i(ps);l=`${l}.${d}`}r.push(new Yt(l,O.NumericLiteral));continue}if(x1(c)){let l=i(x1);r.push(new Yt(l,O.Identifier));continue}throw new SyntaxError(`Unexpected character: ${c}`)}return r}var ur=class{type="Statement"},_y=class extends ur{constructor(e){super(),this.body=e}type="Program"},cy=class extends ur{constructor(e,t,r){super(),this.test=e,this.body=t,this.alternate=r}type="If"},ly=class extends ur{constructor(e,t,r,a){super(),this.loopvar=e,this.iterable=t,this.body=r,this.defaultBlock=a}type="For"},uy=class extends ur{type="Break"},dy=class extends ur{type="Continue"},py=class extends ur{constructor(e,t,r){super(),this.assignee=e,this.value=t,this.body=r}type="Set"},hy=class extends ur{constructor(e,t,r){super(),this.name=e,this.args=t,this.body=r}type="Macro"},fy=class extends ur{constructor(e){super(),this.value=e}type="Comment"},Xt=class extends ur{type="Expression"},Ey=class extends Xt{constructor(e,t,r){super(),this.object=e,this.property=t,this.computed=r}type="MemberExpression"},w1=class extends Xt{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},En=class extends Xt{constructor(e){super(),this.value=e}type="Identifier"},yn=class extends Xt{constructor(e){super(),this.value=e}type="Literal"},$y=class extends yn{type="IntegerLiteral"},my=class extends yn{type="FloatLiteral"},y1=class extends yn{type="StringLiteral"},Iy=class extends yn{type="ArrayLiteral"},B1=class extends yn{type="TupleLiteral"},Sy=class extends yn{type="ObjectLiteral"},hs=class extends Xt{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}type="BinaryExpression"},Ly=class extends Xt{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},Ay=class extends ur{constructor(e,t){super(),this.filter=e,this.body=t}type="FilterStatement"},gy=class extends Xt{constructor(e,t){super(),this.lhs=e,this.test=t}type="SelectExpression"},Ty=class extends Xt{constructor(e,t,r){super(),this.operand=e,this.negate=t,this.test=r}type="TestExpression"},by=class extends Xt{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},vy=class extends Xt{constructor(e=void 0,t=void 0,r=void 0){super(),this.start=e,this.stop=t,this.step=r}type="SliceExpression"},Dy=class extends Xt{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"},Cy=class extends Xt{constructor(e){super(),this.argument=e}type="SpreadExpression"},xy=class extends ur{constructor(e,t,r){super(),this.call=e,this.callerArgs=t,this.body=r}type="CallStatement"},Ny=class extends Xt{constructor(e,t,r){super(),this.condition=e,this.trueExpr=t,this.falseExpr=r}type="Ternary"};function wy(e){let t=new _y([]),r=0;function a(M,k){let F=e[r++];if(!F||F.type!==M)throw new Error(`Parser Error: ${k}. ${F.type} !== ${M}.`);return F}function n(M){if(!o(M))throw new SyntaxError(`Expected ${M}`);++r}function s(){switch(e[r].type){case O.Comment:return new fy(e[r++].value);case O.Text:return _();case O.OpenStatement:return c();case O.OpenExpression:return l();default:throw new SyntaxError(`Unexpected token type: ${e[r].type}`)}}function i(...M){return r+M.length<=e.length&&M.every((k,F)=>k===e[r+F].type)}function H(...M){return e[r]?.type===O.OpenStatement&&e[r+1]?.type===O.Identifier&&M.includes(e[r+1]?.value)}function o(...M){return r+M.length<=e.length&&M.every((k,F)=>e[r+F].type==="Identifier"&&k===e[r+F].value)}function _(){return new y1(a(O.Text,"Expected text token").value)}function c(){if(a(O.OpenStatement,"Expected opening statement token"),e[r].type!==O.Identifier)throw new SyntaxError(`Unknown statement, got ${e[r].type}`);let M=e[r].value,k;switch(M){case"set":++r,k=d();break;case"if":++r,k=h(),a(O.OpenStatement,"Expected {% token"),n("endif"),a(O.CloseStatement,"Expected %} token");break;case"macro":++r,k=$(),a(O.OpenStatement,"Expected {% token"),n("endmacro"),a(O.CloseStatement,"Expected %} token");break;case"for":++r,k=S(),a(O.OpenStatement,"Expected {% token"),n("endfor"),a(O.CloseStatement,"Expected %} token");break;case"call":{++r;let F=null;i(O.OpenParen)&&(F=j());let J=_e();if(J.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");let Ie=j();a(O.CloseStatement,"Expected closing statement token");let Ze=[];for(;!H("endcall");)Ze.push(s());a(O.OpenStatement,"Expected '{%'"),n("endcall"),a(O.CloseStatement,"Expected closing statement token");let oe=new w1(J,Ie);k=new xy(oe,F,Ze);break}case"break":++r,a(O.CloseStatement,"Expected closing statement token"),k=new uy;break;case"continue":++r,a(O.CloseStatement,"Expected closing statement token"),k=new dy;break;case"filter":{++r;let F=_e();F instanceof En&&i(O.OpenParen)&&(F=Z(F)),a(O.CloseStatement,"Expected closing statement token");let J=[];for(;!H("endfilter");)J.push(s());a(O.OpenStatement,"Expected '{%'"),n("endfilter"),a(O.CloseStatement,"Expected '%}'"),k=new Ay(F,J);break}default:throw new SyntaxError(`Unknown statement type: ${M}`)}return k}function l(){a(O.OpenExpression,"Expected opening expression token");let M=I();return a(O.CloseExpression,"Expected closing expression token"),M}function d(){let M=m(),k=null,F=[];if(i(O.Equals))++r,k=m();else{for(a(O.CloseStatement,"Expected %} token");!H("endset");)F.push(s());a(O.OpenStatement,"Expected {% token"),n("endset")}return a(O.CloseStatement,"Expected closing statement token"),new py(M,k,F)}function h(){let M=I();a(O.CloseStatement,"Expected closing statement token");let k=[],F=[];for(;!H("elif","else","endif");)k.push(s());if(H("elif")){++r,++r;let J=h();F.push(J)}else if(H("else"))for(++r,++r,a(O.CloseStatement,"Expected closing statement token");!H("endif");)F.push(s());return new cy(M,k,F)}function $(){let M=_e();if(M.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let k=j();a(O.CloseStatement,"Expected closing statement token");let F=[];for(;!H("endmacro");)F.push(s());return new hy(M,k,F)}function m(M=!1){let k=M?_e:I,F=[k()],J=i(O.Comma);for(;J&&(++r,F.push(k()),!!i(O.Comma)););return J?new B1(F):F[0]}function S(){let M=m(!0);if(!(M instanceof En||M instanceof B1))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${M.type} instead`);if(!o("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++r;let k=I();a(O.CloseStatement,"Expected closing statement token");let F=[];for(;!H("endfor","else");)F.push(s());let J=[];if(H("else"))for(++r,++r,a(O.CloseStatement,"Expected closing statement token");!H("endfor");)J.push(s());return new ly(M,k,F,J)}function I(){return T()}function T(){let M=D();if(o("if")){++r;let k=D();if(o("else")){++r;let F=T();return new Ny(k,M,F)}else return new gy(M,k)}return M}function D(){let M=v();for(;o("or");){let k=e[r];++r;let F=v();M=new hs(k,M,F)}return M}function v(){let M=C();for(;o("and");){let k=e[r];++r;let F=C();M=new hs(k,M,F)}return M}function C(){let M;for(;o("not");){let k=e[r];++r;let F=C();M=new by(k,F)}return M??R()}function R(){let M=A();for(;;){let k;if(o("not","in"))k=new Yt("not in",O.Identifier),r+=2;else if(o("in"))k=e[r++];else if(i(O.ComparisonBinaryOperator))k=e[r++];else break;let F=A();M=new hs(k,M,F)}return M}function A(){let M=G();for(;i(O.AdditiveBinaryOperator);){let k=e[r];++r;let F=G();M=new hs(k,M,F)}return M}function U(){let M=q(_e());return i(O.OpenParen)?Z(M):M}function Z(M){let k=new w1(M,j());return k=q(k),i(O.OpenParen)&&(k=Z(k)),k}function j(){a(O.OpenParen,"Expected opening parenthesis for arguments list");let M=z();return a(O.CloseParen,"Expected closing parenthesis for arguments list"),M}function z(){let M=[];for(;!i(O.CloseParen);){let k;if(e[r].type===O.MultiplicativeBinaryOperator&&e[r].value==="*"){++r;let F=I();k=new Cy(F)}else if(k=I(),i(O.Equals)){if(++r,!(k instanceof En))throw new SyntaxError("Expected identifier for keyword argument");let F=I();k=new Dy(k,F)}M.push(k),i(O.Comma)&&++r}return M}function X(){let M=[],k=!1;for(;!i(O.CloseSquareBracket);)i(O.Colon)?(M.push(void 0),++r,k=!0):(M.push(I()),i(O.Colon)&&(++r,k=!0));if(M.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(k){if(M.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new vy(...M)}return M[0]}function q(M){for(;i(O.Dot)||i(O.OpenSquareBracket);){let k=e[r];++r;let F,J=k.type===O.OpenSquareBracket;if(J)F=X(),a(O.CloseSquareBracket,"Expected closing square bracket");else if(F=_e(),F.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");M=new Ey(M,F,J)}return M}function G(){let M=y();for(;i(O.MultiplicativeBinaryOperator);){let k=e[r++],F=y();M=new hs(k,M,F)}return M}function y(){let M=Q();for(;o("is");){++r;let k=o("not");k&&++r;let F=_e();if(!(F instanceof En))throw new SyntaxError("Expected identifier for the test");M=new Ty(M,k,F)}return M}function Q(){let M=U();for(;i(O.Pipe);){++r;let k=_e();if(!(k instanceof En))throw new SyntaxError("Expected identifier for the filter");i(O.OpenParen)&&(k=Z(k)),M=new Ly(M,k)}return M}function _e(){let M=e[r++];switch(M.type){case O.NumericLiteral:{let k=M.value;return k.includes(".")?new my(Number(k)):new $y(Number(k))}case O.StringLiteral:{let k=M.value;for(;i(O.StringLiteral);)k+=e[r++].value;return new y1(k)}case O.Identifier:return new En(M.value);case O.OpenParen:{let k=m();return a(O.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),k}case O.OpenSquareBracket:{let k=[];for(;!i(O.CloseSquareBracket);)k.push(I()),i(O.Comma)&&++r;return++r,new Iy(k)}case O.OpenCurlyBracket:{let k=new Map;for(;!i(O.CloseCurlyBracket);){let F=I();a(O.Colon,"Expected colon between key and value in object literal");let J=I();k.set(F,J),i(O.Comma)&&++r}return++r,new Sy(k)}default:throw new SyntaxError(`Unexpected token: ${M.type}`)}}for(;r<e.length;)t.body.push(s());return t}function yy(e,t,r=1){if(t===void 0&&(t=e,e=0),r===0)throw new Error("range() step must not be zero");let a=[];if(r>0)for(let n=e;n<t;n+=r)a.push(n);else for(let n=e;n>t;n+=r)a.push(n);return a}function M1(e,t,r,a=1){let n=Math.sign(a);n>=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 s=[];for(let i=t;n*i<n*r;i+=a)s.push(e[i]);return s}function By(e){return e.replace(/\b\w/g,t=>t.toUpperCase())}function My(e){return Py(new Date,e)}function Py(e,t){let r=new Intl.DateTimeFormat(void 0,{month:"long"}),a=new Intl.DateTimeFormat(void 0,{month:"short"}),n=s=>s<10?"0"+s:s.toString();return t.replace(/%[YmdbBHM%]/g,s=>{switch(s){case"%Y":return e.getFullYear().toString();case"%m":return n(e.getMonth()+1);case"%d":return n(e.getDate());case"%b":return a.format(e);case"%B":return r.format(e);case"%H":return n(e.getHours());case"%M":return n(e.getMinutes());case"%%":return"%";default:return s}})}function Ry(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ky(e,t,r,a){if(a===0)return e;let n=a==null||a<0?1/0:a,s=t.length===0?new RegExp("(?=)","gu"):new RegExp(Ry(t),"gu");return e.replaceAll(s,i=>n>0?(--n,r):i)}var P1=class extends Error{},R1=class extends Error{},wr=class{type="RuntimeValue";value;builtins=new Map;constructor(e=void 0){this.value=e}__bool__(){return new de(!!this.value)}toString(){return String(this.value)}},$e=class extends wr{type="IntegerValue"},Qe=class extends wr{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},ne=class extends wr{type="StringValue";builtins=new Map([["upper",new Ve(()=>new ne(this.value.toUpperCase()))],["lower",new Ve(()=>new ne(this.value.toLowerCase()))],["strip",new Ve(()=>new ne(this.value.trim()))],["title",new Ve(()=>new ne(By(this.value)))],["capitalize",new Ve(()=>new ne(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new $e(this.value.length)],["rstrip",new Ve(()=>new ne(this.value.trimEnd()))],["lstrip",new Ve(()=>new ne(this.value.trimStart()))],["startswith",new Ve(e=>{if(e.length===0)throw new Error("startswith() requires at least one argument");let t=e[0];if(t instanceof ne)return new de(this.value.startsWith(t.value));if(t instanceof Le){for(let r of t.value){if(!(r instanceof ne))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(r.value))return new de(!0)}return new de(!1)}throw new Error("startswith() argument must be a string or tuple of strings")})],["endswith",new Ve(e=>{if(e.length===0)throw new Error("endswith() requires at least one argument");let t=e[0];if(t instanceof ne)return new de(this.value.endsWith(t.value));if(t instanceof Le){for(let r of t.value){if(!(r instanceof ne))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(r.value))return new de(!0)}return new de(!1)}throw new Error("endswith() argument must be a string or tuple of strings")})],["split",new Ve(e=>{let t=e[0]??new Xe;if(!(t instanceof ne||t instanceof Xe))throw new Error("sep argument must be a string or null");let r=e[1]??new $e(-1);if(!(r instanceof $e))throw new Error("maxsplit argument must be a number");let a=[];if(t instanceof Xe){let n=this.value.trimStart();for(let{0:s,index:i}of n.matchAll(/\S+/g)){if(r.value!==-1&&a.length>=r.value&&i!==void 0){a.push(s+n.slice(i+s.length));break}a.push(s)}}else{if(t.value==="")throw new Error("empty separator");a=this.value.split(t.value),r.value!==-1&&a.length>r.value&&a.push(a.splice(r.value).join(t.value))}return new Le(a.map(n=>new ne(n)))})],["replace",new Ve(e=>{if(e.length<2)throw new Error("replace() requires at least two arguments");let t=e[0],r=e[1];if(!(t instanceof ne&&r instanceof ne))throw new Error("replace() arguments must be strings");let a;if(e.length>2?e[2].type==="KeywordArgumentsValue"?a=e[2].value.get("count")??new Xe:a=e[2]:a=new Xe,!(a instanceof $e||a instanceof Xe))throw new Error("replace() count argument must be a number or null");return new ne(ky(this.value,t.value,r.value,a.value))})]])},de=class extends wr{type="BooleanValue"},Oy=/[\x7f-\uffff]/g;function k1(e){return e.replace(Oy,t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"))}function Oa(e,t={},r=0,a=!0){let{indent:n=null,ensureAscii:s=!1,separators:i=null,sortKeys:H=!1}=t,o,_;switch(i?[o,_]=i:n?(o=",",_=": "):(o=", ",_=": "),e.type){case"NullValue":return"null";case"UndefinedValue":return a?"null":"undefined";case"IntegerValue":case"FloatValue":case"BooleanValue":return JSON.stringify(e.value);case"StringValue":{let c=JSON.stringify(e.value);return s&&(c=k1(c)),c}case"ArrayValue":case"ObjectValue":{let c=n?" ".repeat(n):"",l=`
|
|
6
|
+
`+c.repeat(r),d=l+c;if(e.type==="ArrayValue"){let h=e.value.map($=>Oa($,t,r+1,a));return n?`[${d}${h.join(`${o}${d}`)}${l}]`:`[${h.join(o)}]`}else{let h=Array.from(e.value.entries());H&&(h=h.sort(([m],[S])=>m.localeCompare(S)));let $=h.map(([m,S])=>{let I=JSON.stringify(m);s&&(I=k1(I));let T=`${I}${_}${Oa(S,t,r+1,a)}`;return n?`${d}${T}`:T});return n?`{${$.join(o)}${l}}`:`{${$.join(o)}}`}}default:throw new Error(`Cannot convert to JSON: ${e.type}`)}}var pt=class extends wr{type="ObjectValue";__bool__(){return new de(this.value.size>0)}builtins=new Map([["get",new Ve(([e,t])=>{if(!(e instanceof ne))throw new Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new Xe})],["items",new Ve(()=>this.items())],["keys",new Ve(()=>this.keys())],["values",new Ve(()=>this.values())],["dictsort",new Ve(e=>{let t=new Map,r=e.filter(H=>H instanceof Ls?(t=H.value,!1):!0),a=r.at(0)??t.get("case_sensitive")??new de(!1);if(!(a instanceof de))throw new Error("case_sensitive must be a boolean");let n=r.at(1)??t.get("by")??new ne("key");if(!(n instanceof ne))throw new Error("by must be a string");if(!["key","value"].includes(n.value))throw new Error("by must be either 'key' or 'value'");let s=r.at(2)??t.get("reverse")??new de(!1);if(!(s instanceof de))throw new Error("reverse must be a boolean");let i=Array.from(this.value.entries()).map(([H,o])=>new Le([new ne(H),o])).sort((H,o)=>{let _=n.value==="key"?0:1,c=H.value[_],l=o.value[_],d=K_(c,l,a.value);return s.value?-d:d});return new Le(i)})]]);items(){return new Le(Array.from(this.value.entries()).map(([e,t])=>new Le([new ne(e),t])))}keys(){return new Le(Array.from(this.value.keys()).map(e=>new ne(e)))}values(){return new Le(Array.from(this.value.values()))}toString(){return Oa(this,{},0,!1)}},Ls=class extends pt{type="KeywordArgumentsValue"},Le=class extends wr{type="ArrayValue";builtins=new Map([["length",new $e(this.value.length)]]);__bool__(){return new de(this.value.length>0)}toString(){return Oa(this,{},0,!1)}},O1=class extends Le{type="TupleValue"},Ve=class extends wr{type="FunctionValue"},Xe=class extends wr{type="NullValue"},We=class extends wr{type="UndefinedValue"},Ba=class{constructor(e){this.parent=e}variables=new Map([["namespace",new Ve(e=>{if(e.length===0)return new pt(new Map);if(e.length!==1||!(e[0]instanceof pt))throw new Error("`namespace` expects either zero arguments or a single object argument");return e[0]})]]);tests=new Map([["boolean",e=>e.type==="BooleanValue"],["callable",e=>e instanceof Ve],["odd",e=>{if(!(e instanceof $e))throw new Error(`cannot odd on ${e.type}`);return e.value%2!==0}],["even",e=>{if(!(e instanceof $e))throw new Error(`cannot even on ${e.type}`);return e.value%2===0}],["false",e=>e.type==="BooleanValue"&&!e.value],["true",e=>e.type==="BooleanValue"&&e.value],["none",e=>e.type==="NullValue"],["string",e=>e.type==="StringValue"],["number",e=>e instanceof $e||e instanceof Qe],["integer",e=>e instanceof $e],["iterable",e=>e.type==="ArrayValue"||e.type==="StringValue"],["mapping",e=>e instanceof pt],["sequence",e=>e instanceof Le||e instanceof pt||e instanceof ne],["lower",e=>{let t=e.value;return e.type==="StringValue"&&t===t.toLowerCase()}],["upper",e=>{let t=e.value;return e.type==="StringValue"&&t===t.toUpperCase()}],["none",e=>e.type==="NullValue"],["defined",e=>e.type!=="UndefinedValue"],["undefined",e=>e.type==="UndefinedValue"],["equalto",(e,t)=>e.value===t.value],["eq",(e,t)=>e.value===t.value]]);set(e,t){return this.declareVariable(e,Yi(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 We}catch{return new We}}};function Gy(e){e.set("false",!1),e.set("true",!0),e.set("none",null),e.set("raise_exception",t=>{throw new Error(t)}),e.set("range",yy),e.set("strftime_now",My),e.set("True",!0),e.set("False",!1),e.set("None",null)}function G1(e,t){let r=t.split("."),a=e;for(let n of r)if(a instanceof pt)a=a.value.get(n)??new We;else if(a instanceof Le){let s=parseInt(n,10);if(!isNaN(s)&&s>=0&&s<a.value.length)a=a.value[s];else return new We}else return new We;return a}function K_(e,t,r=!1){if(e instanceof Xe&&t instanceof Xe)return 0;if(e instanceof Xe||t instanceof Xe)throw new Error(`Cannot compare ${e.type} with ${t.type}`);if(e instanceof We&&t instanceof We)return 0;if(e instanceof We||t instanceof We)throw new Error(`Cannot compare ${e.type} with ${t.type}`);let a=s=>s instanceof $e||s instanceof Qe||s instanceof de,n=s=>s instanceof de?s.value?1:0:s.value;if(a(e)&&a(t)){let s=n(e),i=n(t);return s<i?-1:s>i?1:0}if(e.type!==t.type)throw new Error(`Cannot compare different types: ${e.type} and ${t.type}`);if(e.type==="StringValue"){let s=e.value,i=t.value;return r||(s=s.toLowerCase(),i=i.toLowerCase()),s<i?-1:s>i?1:0}else throw new Error(`Cannot compare type: ${e.type}`)}var Fy=class{global;constructor(e){this.global=e??new Ba}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 a=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new de(r.value==a.value);case"!=":return new de(r.value!=a.value)}if(r instanceof We||a instanceof We){if(a instanceof We&&["in","not in"].includes(e.operator.value))return new de(e.operator.value==="not in");throw new Error(`Cannot perform operation ${e.operator.value} on undefined values`)}else{if(r instanceof Xe||a instanceof Xe)throw new Error("Cannot perform operation on null values");if(e.operator.value==="~")return new ne(r.value.toString()+a.value.toString());if((r instanceof $e||r instanceof Qe)&&(a instanceof $e||a instanceof Qe)){let n=r.value,s=a.value;switch(e.operator.value){case"+":case"-":case"*":{let i=e.operator.value==="+"?n+s:e.operator.value==="-"?n-s:n*s;return r instanceof Qe||a instanceof Qe?new Qe(i):new $e(i)}case"/":return new Qe(n/s);case"%":{let i=n%s;return r instanceof Qe||a instanceof Qe?new Qe(i):new $e(i)}case"<":return new de(n<s);case">":return new de(n>s);case">=":return new de(n>=s);case"<=":return new de(n<=s)}}else if(r instanceof Le&&a instanceof Le){if(e.operator.value==="+")return new Le(r.value.concat(a.value))}else if(a instanceof Le){let n=a.value.find(s=>s.value===r.value)!==void 0;switch(e.operator.value){case"in":return new de(n);case"not in":return new de(!n)}}}if((r instanceof ne||a instanceof ne)&&e.operator.value==="+")return new ne(r.value.toString()+a.value.toString());if(r instanceof ne&&a instanceof ne)switch(e.operator.value){case"in":return new de(a.value.includes(r.value));case"not in":return new de(!a.value.includes(r.value))}if(r instanceof ne&&a instanceof pt)switch(e.operator.value){case"in":return new de(a.value.has(r.value));case"not in":return new de(!a.value.has(r.value))}throw new SyntaxError(`Unknown operator "${e.operator.value}" between ${r.type} and ${a.type}`)}evaluateArguments(e,t){let r=[],a=new Map;for(let n of e)if(n.type==="SpreadExpression"){let s=n,i=this.evaluate(s.argument,t);if(!(i instanceof Le))throw new Error(`Cannot unpack non-iterable type: ${i.type}`);for(let H of i.value)r.push(H)}else if(n.type==="KeywordArgumentExpression"){let s=n;a.set(s.key.value,this.evaluate(s.value,t))}else{if(a.size>0)throw new Error("Positional arguments must come before keyword arguments");r.push(this.evaluate(n,t))}return[r,a]}applyFilter(e,t,r){if(t.type==="Identifier"){let a=t;if(a.value==="safe")return e;if(a.value==="tojson")return new ne(Oa(e,{}));if(e instanceof Le)switch(a.value){case"list":return e;case"first":return e.value[0];case"last":return e.value[e.value.length-1];case"length":return new $e(e.value.length);case"reverse":return new Le(e.value.slice().reverse());case"sort":return new Le(e.value.slice().sort((n,s)=>K_(n,s,!1)));case"join":return new ne(e.value.map(n=>n.value).join(""));case"string":return new ne(Oa(e,{},0,!1));case"unique":{let n=new Set,s=[];for(let i of e.value)n.has(i.value)||(n.add(i.value),s.push(i));return new Le(s)}default:throw new Error(`Unknown ArrayValue filter: ${a.value}`)}else if(e instanceof ne)switch(a.value){case"length":case"upper":case"lower":case"title":case"capitalize":{let n=e.builtins.get(a.value);if(n instanceof Ve)return n.value([],r);if(n instanceof $e)return n;throw new Error(`Unknown StringValue filter: ${a.value}`)}case"trim":return new ne(e.value.trim());case"indent":return new ne(e.value.split(`
|
|
7
|
+
`).map((n,s)=>s===0||n.length===0?n:" "+n).join(`
|
|
8
|
+
`));case"join":case"string":return e;case"int":{let n=parseInt(e.value,10);return new $e(isNaN(n)?0:n)}case"float":{let n=parseFloat(e.value);return new Qe(isNaN(n)?0:n)}default:throw new Error(`Unknown StringValue filter: ${a.value}`)}else if(e instanceof $e||e instanceof Qe)switch(a.value){case"abs":return e instanceof $e?new $e(Math.abs(e.value)):new Qe(Math.abs(e.value));case"int":return new $e(Math.floor(e.value));case"float":return new Qe(e.value);case"string":return new ne(e.toString());default:throw new Error(`Unknown NumericValue filter: ${a.value}`)}else if(e instanceof pt)switch(a.value){case"items":return new Le(Array.from(e.value.entries()).map(([n,s])=>new Le([new ne(n),s])));case"length":return new $e(e.value.size);default:{let n=e.builtins.get(a.value);if(n)return n instanceof Ve?n.value([],r):n;throw new Error(`Unknown ObjectValue filter: ${a.value}`)}}else if(e instanceof de)switch(a.value){case"bool":return new de(e.value);case"int":return new $e(e.value?1:0);case"float":return new Qe(e.value?1:0);case"string":return new ne(e.value?"true":"false");default:throw new Error(`Unknown BooleanValue filter: ${a.value}`)}throw new Error(`Cannot apply filter "${a.value}" to type: ${e.type}`)}else if(t.type==="CallExpression"){let a=t;if(a.callee.type!=="Identifier")throw new Error(`Unknown filter: ${a.callee.type}`);let n=a.callee.value;if(n==="tojson"){let[,s]=this.evaluateArguments(a.args,r),i=s.get("indent")??new Xe;if(!(i instanceof $e||i instanceof Xe))throw new Error("If set, indent must be a number");let H=s.get("ensure_ascii")??new de(!1);if(!(H instanceof de))throw new Error("If set, ensure_ascii must be a boolean");let o=s.get("sort_keys")??new de(!1);if(!(o instanceof de))throw new Error("If set, sort_keys must be a boolean");let _=s.get("separators")??new Xe,c=null;if(_ instanceof Le||_ instanceof O1){if(_.value.length!==2)throw new Error("separators must be a tuple of two strings");let[l,d]=_.value;if(!(l instanceof ne)||!(d instanceof ne))throw new Error("separators must be a tuple of two strings");c=[l.value,d.value]}else if(!(_ instanceof Xe))throw new Error("If set, separators must be a tuple of two strings");return new ne(Oa(e,{indent:i.value,ensureAscii:H.value,sortKeys:o.value,separators:c}))}else if(n==="join"){let s;if(e instanceof ne)s=Array.from(e.value);else if(e instanceof Le)s=e.value.map(_=>_.value);else throw new Error(`Cannot apply filter "${n}" to type: ${e.type}`);let[i,H]=this.evaluateArguments(a.args,r),o=i.at(0)??H.get("separator")??new ne("");if(!(o instanceof ne))throw new Error("separator must be a string");return new ne(s.join(o.value))}else if(n==="int"||n==="float"){let[s,i]=this.evaluateArguments(a.args,r),H=s.at(0)??i.get("default")??(n==="int"?new $e(0):new Qe(0));if(e instanceof ne){let o=n==="int"?parseInt(e.value,10):parseFloat(e.value);return isNaN(o)?H:n==="int"?new $e(o):new Qe(o)}else{if(e instanceof $e||e instanceof Qe)return e;if(e instanceof de)return n==="int"?new $e(e.value?1:0):new Qe(e.value?1:0);throw new Error(`Cannot apply filter "${n}" to type: ${e.type}`)}}else if(n==="default"){let[s,i]=this.evaluateArguments(a.args,r),H=s[0]??new ne(""),o=s[1]??i.get("boolean")??new de(!1);if(!(o instanceof de))throw new Error("`default` filter flag must be a boolean");return e instanceof We||o.value&&!e.__bool__().value?H:e}if(e instanceof Le){switch(n){case"sort":{let[s,i]=this.evaluateArguments(a.args,r),H=s.at(0)??i.get("reverse")??new de(!1);if(!(H instanceof de))throw new Error("reverse must be a boolean");let o=s.at(1)??i.get("case_sensitive")??new de(!1);if(!(o instanceof de))throw new Error("case_sensitive must be a boolean");let _=s.at(2)??i.get("attribute")??new Xe;if(!(_ instanceof ne||_ instanceof $e||_ instanceof Xe))throw new Error("attribute must be a string, integer, or null");let c=l=>{if(_ instanceof Xe)return l;let d=_ instanceof $e?String(_.value):_.value;return G1(l,d)};return new Le(e.value.slice().sort((l,d)=>{let h=c(l),$=c(d),m=K_(h,$,o.value);return H.value?-m:m}))}case"selectattr":case"rejectattr":{let s=n==="selectattr";if(e.value.some(l=>!(l instanceof pt)))throw new Error(`\`${n}\` can only be applied to array of objects`);if(a.args.some(l=>l.type!=="StringLiteral"))throw new Error(`arguments of \`${n}\` must be strings`);let[i,H,o]=a.args.map(l=>this.evaluate(l,r)),_;if(H){let l=r.tests.get(H.value);if(!l)throw new Error(`Unknown test: ${H.value}`);_=l}else _=(...l)=>l[0].__bool__().value;let c=e.value.filter(l=>{let d=l.value.get(i.value),h=d?_(d,o):!1;return s?h:!h});return new Le(c)}case"map":{let[,s]=this.evaluateArguments(a.args,r);if(s.has("attribute")){let i=s.get("attribute");if(!(i instanceof ne))throw new Error("attribute must be a string");let H=s.get("default"),o=e.value.map(_=>{if(!(_ instanceof pt))throw new Error("items in map must be an object");let c=G1(_,i.value);return c instanceof We?H??new We:c});return new Le(o)}else throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${n}`)}else if(e instanceof ne){switch(n){case"indent":{let[s,i]=this.evaluateArguments(a.args,r),H=s.at(0)??i.get("width")??new $e(4);if(!(H instanceof $e))throw new Error("width must be a number");let o=s.at(1)??i.get("first")??new de(!1),_=s.at(2)??i.get("blank")??new de(!1),c=e.value.split(`
|
|
9
|
+
`),l=" ".repeat(H.value),d=c.map((h,$)=>!o.value&&$===0||!_.value&&h.length===0?h:l+h);return new ne(d.join(`
|
|
10
|
+
`))}case"replace":{let s=e.builtins.get("replace");if(!(s instanceof Ve))throw new Error("replace filter not available");let[i,H]=this.evaluateArguments(a.args,r);return s.value([...i,new Ls(H)],r)}}throw new Error(`Unknown StringValue filter: ${n}`)}else if(e instanceof pt){let s=e.builtins.get(n);if(s&&s instanceof Ve){let[i,H]=this.evaluateArguments(a.args,r);return H.size>0&&i.push(new Ls(H)),s.value(i,r)}throw new Error(`Unknown ObjectValue filter: ${n}`)}else throw new Error(`Cannot apply filter "${n}" to type: ${e.type}`)}throw new Error(`Unknown filter: ${t.type}`)}evaluateFilterExpression(e,t){let r=this.evaluate(e.operand,t);return this.applyFilter(r,e.filter,t)}evaluateTestExpression(e,t){let r=this.evaluate(e.operand,t),a=t.tests.get(e.test.value);if(!a)throw new Error(`Unknown test: ${e.test.value}`);let n=a(r);return new de(e.negate?!n:n)}evaluateSelectExpression(e,t){return this.evaluate(e.test,t).__bool__().value?this.evaluate(e.lhs,t):new We}evaluateUnaryExpression(e,t){let r=this.evaluate(e.argument,t);if(e.operator.value==="not")return new de(!r.value);throw new SyntaxError(`Unknown operator: ${e.operator.value}`)}evaluateTernaryExpression(e,t){return this.evaluate(e.condition,t).__bool__().value?this.evaluate(e.trueExpr,t):this.evaluate(e.falseExpr,t)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let r="";for(let a of e){let n=this.evaluate(a,t);n.type!=="NullValue"&&n.type!=="UndefinedValue"&&(r+=n.toString())}return new ne(r)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){let[r,a]=this.evaluateArguments(e.args,t);a.size>0&&r.push(new Ls(a));let n=this.evaluate(e.callee,t);if(n.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${n.type}`);return n.value(r,t)}evaluateSliceExpression(e,t,r){if(!(e instanceof Le||e instanceof ne))throw new Error("Slice object must be an array or string");let a=this.evaluate(t.start,r),n=this.evaluate(t.stop,r),s=this.evaluate(t.step,r);if(!(a instanceof $e||a instanceof We))throw new Error("Slice start must be numeric or undefined");if(!(n instanceof $e||n instanceof We))throw new Error("Slice stop must be numeric or undefined");if(!(s instanceof $e||s instanceof We))throw new Error("Slice step must be numeric or undefined");return e instanceof Le?new Le(M1(e.value,a.value,n.value,s.value)):new ne(M1(Array.from(e.value),a.value,n.value,s.value).join(""))}evaluateMemberExpression(e,t){let r=this.evaluate(e.object,t),a;if(e.computed){if(e.property.type==="SliceExpression")return this.evaluateSliceExpression(r,e.property,t);a=this.evaluate(e.property,t)}else a=new ne(e.property.value);let n;if(r instanceof pt){if(!(a instanceof ne))throw new Error(`Cannot access property with non-string: got ${a.type}`);n=r.value.get(a.value)??r.builtins.get(a.value)}else if(r instanceof Le||r instanceof ne)if(a instanceof $e)n=r.value.at(a.value),r instanceof ne&&(n=new ne(r.value.at(a.value)));else if(a instanceof ne)n=r.builtins.get(a.value);else throw new Error(`Cannot access property with non-string/non-number: got ${a.type}`);else{if(!(a instanceof ne))throw new Error(`Cannot access property with non-string: got ${a.type}`);n=r.builtins.get(a.value)}return n instanceof wr?n:new We}evaluateSet(e,t){let r=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if(e.assignee.type==="Identifier"){let a=e.assignee.value;t.setVariable(a,r)}else if(e.assignee.type==="TupleLiteral"){let a=e.assignee;if(!(r instanceof Le))throw new Error(`Cannot unpack non-iterable type in set: ${r.type}`);let n=r.value;if(n.length!==a.value.length)throw new Error(`Too ${a.value.length>n.length?"few":"many"} items to unpack in set`);for(let s=0;s<a.value.length;++s){let i=a.value[s];if(i.type!=="Identifier")throw new Error(`Cannot unpack to non-identifier in set: ${i.type}`);t.setVariable(i.value,n[s])}}else if(e.assignee.type==="MemberExpression"){let a=e.assignee,n=this.evaluate(a.object,t);if(!(n instanceof pt))throw new Error("Cannot assign to member of non-object");if(a.property.type!=="Identifier")throw new Error("Cannot assign to member with non-identifier property");n.value.set(a.property.value,r)}else throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);return new Xe}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 Ba(t),a,n;if(e.iterable.type==="SelectExpression"){let _=e.iterable;n=this.evaluate(_.lhs,r),a=_.test}else n=this.evaluate(e.iterable,r);if(!(n instanceof Le||n instanceof pt))throw new Error(`Expected iterable or object type in for loop: got ${n.type}`);n instanceof pt&&(n=n.keys());let s=[],i=[];for(let _=0;_<n.value.length;++_){let c=new Ba(r),l=n.value[_],d;if(e.loopvar.type==="Identifier")d=h=>h.setVariable(e.loopvar.value,l);else if(e.loopvar.type==="TupleLiteral"){let h=e.loopvar;if(l.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${l.type}`);let $=l;if(h.value.length!==$.value.length)throw new Error(`Too ${h.value.length>$.value.length?"few":"many"} items to unpack`);d=m=>{for(let S=0;S<h.value.length;++S){if(h.value[S].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${h.value[S].type}`);m.setVariable(h.value[S].value,$.value[S])}}}else throw new Error(`Invalid loop variable(s): ${e.loopvar.type}`);a&&(d(c),!this.evaluate(a,c).__bool__().value)||(s.push(l),i.push(d))}let H="",o=!0;for(let _=0;_<s.length;++_){let c=new Map([["index",new $e(_+1)],["index0",new $e(_)],["revindex",new $e(s.length-_)],["revindex0",new $e(s.length-_-1)],["first",new de(_===0)],["last",new de(_===s.length-1)],["length",new $e(s.length)],["previtem",_>0?s[_-1]:new We],["nextitem",_<s.length-1?s[_+1]:new We]]);r.setVariable("loop",new pt(c)),i[_](r);try{let l=this.evaluateBlock(e.body,r);H+=l.value}catch(l){if(l instanceof R1)continue;if(l instanceof P1)break;throw l}o=!1}if(o){let _=this.evaluateBlock(e.defaultBlock,r);H+=_.value}return new ne(H)}evaluateMacro(e,t){return t.setVariable(e.name.value,new Ve((r,a)=>{let n=new Ba(a);r=r.slice();let s;r.at(-1)?.type==="KeywordArgumentsValue"&&(s=r.pop());for(let i=0;i<e.args.length;++i){let H=e.args[i],o=r[i];if(H.type==="Identifier"){let _=H;if(!o)throw new Error(`Missing positional argument: ${_.value}`);n.setVariable(_.value,o)}else if(H.type==="KeywordArgumentExpression"){let _=H,c=o??s?.value.get(_.key.value)??this.evaluate(_.value,n);n.setVariable(_.key.value,c)}else throw new Error(`Unknown argument type: ${H.type}`)}return this.evaluateBlock(e.body,n)})),new Xe}evaluateCallStatement(e,t){let r=new Ve((H,o)=>{let _=new Ba(o);if(e.callerArgs)for(let c=0;c<e.callerArgs.length;++c){let l=e.callerArgs[c];if(l.type!=="Identifier")throw new Error(`Caller parameter must be an identifier, got ${l.type}`);_.setVariable(l.value,H[c]??new We)}return this.evaluateBlock(e.body,_)}),[a,n]=this.evaluateArguments(e.call.args,t);a.push(new Ls(n));let s=this.evaluate(e.call.callee,t);if(s.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${s.type}`);let i=new Ba(t);return i.setVariable("caller",r),s.value(a,i)}evaluateFilterStatement(e,t){let r=this.evaluateBlock(e.body,t);return this.applyFilter(r,e.filter,t)}evaluate(e,t){if(!e)return new We;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"CallStatement":return this.evaluateCallStatement(e,t);case"Break":throw new P1;case"Continue":throw new R1;case"IntegerLiteral":return new $e(e.value);case"FloatLiteral":return new Qe(e.value);case"StringLiteral":return new ne(e.value);case"ArrayLiteral":return new Le(e.value.map(r=>this.evaluate(r,t)));case"TupleLiteral":return new O1(e.value.map(r=>this.evaluate(r,t)));case"ObjectLiteral":{let r=new Map;for(let[a,n]of e.value){let s=this.evaluate(a,t);if(!(s instanceof ne))throw new Error(`Object keys must be strings: got ${s.type}`);r.set(s.value,this.evaluate(n,t))}return new pt(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"FilterStatement":return this.evaluateFilterStatement(e,t);case"TestExpression":return this.evaluateTestExpression(e,t);case"SelectExpression":return this.evaluateSelectExpression(e,t);case"Ternary":return this.evaluateTernaryExpression(e,t);case"Comment":return new Xe;default:throw new SyntaxError(`Unknown node type: ${e.type}`)}}};function Yi(e){switch(typeof e){case"number":return Number.isInteger(e)?new $e(e):new Qe(e);case"string":return new ne(e);case"boolean":return new de(e);case"undefined":return new We;case"object":return e===null?new Xe:Array.isArray(e)?new Le(e.map(Yi)):new pt(new Map(Object.entries(e).map(([t,r])=>[t,Yi(r)])));case"function":return new Ve((t,r)=>{let a=e(...t.map(n=>n.value))??null;return Yi(a)});default:throw new Error(`Cannot convert to runtime value: ${e}`)}}var Ht=`
|
|
11
|
+
`,Zy="{%- ",Uy=" -%}";function Ky(e){switch(e.operator.type){case"MultiplicativeBinaryOperator":return 4;case"AdditiveBinaryOperator":return 3;case"ComparisonBinaryOperator":return 2;case"Identifier":return e.operator.value==="and"?1:e.operator.value==="in"||e.operator.value==="not in"?2:0}return 0}function Wy(e,t=" "){let r=typeof t=="number"?" ".repeat(t):t;return or(e.body,0,r).replace(/\n$/,"")}function It(...e){return Zy+e.join(" ")+Uy}function or(e,t,r){return e.map(a=>Vy(a,t,r)).join(Ht)}function Vy(e,t,r){let a=r.repeat(t);switch(e.type){case"Program":return or(e.body,t,r);case"If":return jy(e,t,r);case"For":return qy(e,t,r);case"Set":return Xy(e,t,r);case"Macro":return zy(e,t,r);case"Break":return a+It("break");case"Continue":return a+It("continue");case"CallStatement":return Jy(e,t,r);case"FilterStatement":return Qy(e,t,r);case"Comment":return a+"{# "+e.value+" #}";default:return a+"{{- "+ge(e)+" -}}"}}function jy(e,t,r){let a=r.repeat(t),n=[],s=e;for(;s&&(n.push({test:s.test,body:s.body}),s.alternate.length===1&&s.alternate[0].type==="If");)s=s.alternate[0];let i=a+It("if",ge(n[0].test))+Ht+or(n[0].body,t+1,r);for(let H=1;H<n.length;++H)i+=Ht+a+It("elif",ge(n[H].test))+Ht+or(n[H].body,t+1,r);return s&&s.alternate.length>0&&(i+=Ht+a+It("else")+Ht+or(s.alternate,t+1,r)),i+=Ht+a+It("endif"),i}function qy(e,t,r){let a=r.repeat(t),n="";if(e.iterable.type==="SelectExpression"){let i=e.iterable;n=`${ge(i.lhs)} if ${ge(i.test)}`}else n=ge(e.iterable);let s=a+It("for",ge(e.loopvar),"in",n)+Ht+or(e.body,t+1,r);return e.defaultBlock.length>0&&(s+=Ht+a+It("else")+Ht+or(e.defaultBlock,t+1,r)),s+=Ht+a+It("endfor"),s}function Xy(e,t,r){let a=r.repeat(t),n=ge(e.assignee),s=e.value?ge(e.value):"",i=a+It("set",`${n}${e.value?" = "+s:""}`);return e.body.length===0?i:i+Ht+or(e.body,t+1,r)+Ht+a+It("endset")}function zy(e,t,r){let a=r.repeat(t),n=e.args.map(ge).join(", ");return a+It("macro",`${e.name.value}(${n})`)+Ht+or(e.body,t+1,r)+Ht+a+It("endmacro")}function Jy(e,t,r){let a=r.repeat(t),n=e.callerArgs&&e.callerArgs.length>0?`(${e.callerArgs.map(ge).join(", ")})`:"",s=ge(e.call),i=a+It(`call${n}`,s)+Ht;return i+=or(e.body,t+1,r)+Ht,i+=a+It("endcall"),i}function Qy(e,t,r){let a=r.repeat(t),n=e.filter.type==="Identifier"?e.filter.value:ge(e.filter),s=a+It("filter",n)+Ht;return s+=or(e.body,t+1,r)+Ht,s+=a+It("endfilter"),s}function ge(e,t=-1){switch(e.type){case"SpreadExpression":return`*${ge(e.argument)}`;case"Identifier":return e.value;case"IntegerLiteral":return`${e.value}`;case"FloatLiteral":return`${e.value}`;case"StringLiteral":return JSON.stringify(e.value);case"BinaryExpression":{let r=e,a=Ky(r),n=ge(r.left,a),s=ge(r.right,a+1),i=`${n} ${r.operator.value} ${s}`;return a<t?`(${i})`:i}case"UnaryExpression":{let r=e;return r.operator.value+(r.operator.value==="not"?" ":"")+ge(r.argument,1/0)}case"CallExpression":{let r=e,a=r.args.map(ge).join(", ");return`${ge(r.callee)}(${a})`}case"MemberExpression":{let r=e,a=ge(r.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(r.object.type)||(a=`(${a})`);let n=ge(r.property);return!r.computed&&r.property.type!=="Identifier"&&(n=`(${n})`),r.computed?`${a}[${n}]`:`${a}.${n}`}case"FilterExpression":{let r=e,a=ge(r.operand,1/0);return r.filter.type==="CallExpression"?`${a} | ${ge(r.filter)}`:`${a} | ${r.filter.value}`}case"SelectExpression":{let r=e;return`${ge(r.lhs)} if ${ge(r.test)}`}case"TestExpression":{let r=e;return`${ge(r.operand)} is${r.negate?" not":""} ${r.test.value}`}case"ArrayLiteral":case"TupleLiteral":{let r=e.value.map(ge),a=e.type==="ArrayLiteral"?"[]":"()";return`${a[0]}${r.join(", ")}${a[1]}`}case"ObjectLiteral":return`{${Array.from(e.value.entries()).map(([a,n])=>`${ge(a)}: ${ge(n)}`).join(", ")}}`;case"SliceExpression":{let r=e,a=r.start?ge(r.start):"",n=r.stop?ge(r.stop):"",s=r.step?`:${ge(r.step)}`:"";return`${a}:${n}${s}`}case"KeywordArgumentExpression":{let r=e;return`${r.key.value}=${ge(r.value)}`}case"Ternary":{let r=e,a=`${ge(r.trueExpr)} if ${ge(r.condition,0)} else ${ge(r.falseExpr)}`;return t>-1?`(${a})`:a}default:throw new Error(`Unknown expression type: ${e.type}`)}}var Yy=class{parsed;constructor(e){let t=oy(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=wy(t)}render(e){let t=new Ba;if(Gy(t),e)for(let[n,s]of Object.entries(e))t.set(n,s);return new Fy(t).run(this.parsed).value}format(e){return Wy(this.parsed,e?.indent||" ")}},eB={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"},iH=class H0{constructor(t){if(this.filePath=t,this.headers=new Headers,this.exists=$n.existsSync(t),this.exists){this.status=200,this.statusText="OK";let r=$n.statSync(t);this.headers.set("content-length",r.size.toString()),this.updateContentType();let a=$n.createReadStream(t);this.body=new ReadableStream({start(n){a.on("data",s=>n.enqueue(s)),a.on("end",()=>n.close()),a.on("error",s=>n.error(s))},cancel(){a.destroy()}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){let t=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",eB[t]??"application/octet-stream")}clone(){let t=new H0(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=new Headers(this.headers),t}async arrayBuffer(){return(await $n.promises.readFile(this.filePath)).buffer}async blob(){let t=await $n.promises.readFile(this.filePath);return new Blob([t],{type:this.headers.get("content-type")})}async text(){return await $n.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}},SH=class{constructor(e){this._mt=new Uint32Array(624),this._idx=625,this._gauss_next=null,this._random_fn=this.random.bind(this),this.seed(e)}seed(e){if(e==null)if(me.IS_CRYPTO_AVAILABLE){let i=new Uint32Array(1);crypto.getRandomValues(i),e=i[0]}else e=Date.now()>>>0;let t=this._mt,r=(i,H)=>Math.imul(i,H)>>>0,a=[];for(let i=e||0;i>0;i=Math.floor(i/4294967296))a.push(i&4294967295);a.length||a.push(0),t[0]=19650218;for(let i=1;i<624;++i)t[i]=r(1812433253,t[i-1]^t[i-1]>>>30)+i>>>0;let n=1,s=0;for(let i=Math.max(624,a.length);i>0;--i,++n,++s)n>=624&&(t[0]=t[623],n=1),s>=a.length&&(s=0),t[n]=(t[n]^r(t[n-1]^t[n-1]>>>30,1664525))+a[s]+s>>>0;for(let i=623;i>0;--i,++n)n>=624&&(t[0]=t[623],n=1),t[n]=(t[n]^r(t[n-1]^t[n-1]>>>30,1566083941))-n>>>0;t[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let r=0;r<624;++r){let a=e[r]&2147483648|e[(r+1)%624]&2147483647;e[r]=(e[(r+397)%624]^a>>>1^(a&1?2567483615:0))>>>0}this._idx=0}let t=e[this._idx++];return t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,t=1){let r=this._gauss_next;if(this._gauss_next=null,r===null){let a=this.random()*2*Math.PI,n=Math.sqrt(-2*Math.log(1-this.random()));r=Math.cos(a)*n,this._gauss_next=Math.sin(a)*n}return e+r*t}shuffle(e){for(let t=e.length-1;t>0;--t){let r=32-Math.clz32(t+1),a=this._int32()>>>32-r;for(;a>t;)a=this._int32()>>>32-r;let n=e[t];e[t]=e[a],e[a]=n}}choices(e,t){return e[o0(this._random_fn,t)]}};function o0(e,t){let r=0;for(let n=0;n<t.length;++n)r+=t[n];let a=e()*r;for(let n=0;n<t.length;++n)if(a-=t[n],a<0)return n;return t.length-1}var Dr=new SH,LH=Object.freeze({Random:SH,seed:Dr.seed.bind(Dr),random:Dr.random.bind(Dr),gauss:Dr.gauss.bind(Dr),shuffle:Dr.shuffle.bind(Dr),choices:Dr.choices.bind(Dr)}),tB=e=>o0(LH.random,e),rB=new SH,_0=class{constructor(e){this.path=e}async match(e){let t=ki.join(this.path,e),r=new iH(t);if(r.exists)return r}async put(e,t,r=void 0){let a=ki.join(this.path,e),n=me.IS_PROCESS_AVAILABLE?process.pid:Date.now(),s=rB._int32().toString(36),i=a+`.tmp.${n}.${s}`;try{let H=t.headers.get("Content-Length"),o=parseInt(H??"0"),_=0;await fs.promises.mkdir(ki.dirname(a),{recursive:!0});let c=fs.createWriteStream(i),l=t.body.getReader();for(;;){let{done:d,value:h}=await l.read();if(d)break;await new Promise((m,S)=>{c.write(h,I=>{if(I){S(I);return}m()})}),_+=h.length;let $=o?_/o*100:0;r?.({progress:$,loaded:_,total:o})}await new Promise((d,h)=>{c.close($=>$?h($):d())}),await fs.promises.rename(i,a)}catch(H){try{await fs.promises.unlink(i)}catch{}throw H}}async delete(e){let t=ki.join(this.path,e);try{return await fs.promises.unlink(t),!0}catch{return!1}}},aB={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"},F1=100,nB=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function Oi(...e){return e=e.map((t,r)=>(r&&(t=t.replace(new RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(new RegExp("/$"),"")),t)),e.join("/")}function Bn(e,t=null,r=null){let a;try{a=new URL(e)}catch{return!1}return!(t&&!t.includes(a.protocol)||r&&!r.includes(a.hostname))}function sB(e){return!(!nB.test(e)||e.includes("..")||e.includes("--")||e.endsWith(".git")||e.endsWith(".ipynb"))}function iB(e,t,r){if(!r)return null;let a=aB[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${a}: "${t}".`)}async function HB(e,t,r){let a=e.headers.get("Content-Length"),n=a?parseInt(a,10):r??0;a===null&&!r&&he.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let s=new Uint8Array(n),i=0,H=e.body.getReader();async function o(){let{done:_,value:c}=await H.read();if(_)return;let l=i+c.length;if(l>n){n=l;let h=new Uint8Array(n);h.set(s),s=h}s.set(c,i),i=l;let d=i/n*100;return t({progress:d,loaded:i,total:n}),o()}return await o(),s}function Z1(e){return Bn(e,["blob:"])}function U1(e){let t;if(typeof location<"u"&&location.href)t=location.href;else if(typeof import.meta<"u"&&import.meta.url)t=import.meta.url;else return e;return new URL(e,t).href}var c0="SHA-256",oB="experimental_transformers-hash-cache",K1=e=>({algorithm:c0,value:e}),W1=class{#t=null;_getHashCache=()=>(this.#t??=caches.open(oB),this.#t);static isAvailable=()=>typeof navigator<"u"&&"crossOriginStorage"in navigator;match=async e=>{let t=await this._getFileHash(e);if(t)try{let[r]=await navigator.crossOriginStorage.requestFileHandles([K1(t)]),a=await r.getFile();return new Response(a,{headers:{"Content-Length":String(a.size)}})}catch{return}};put=async(e,t)=>{let r=await this._getFileHash(e);if(r){let a=await t.blob();await this._storeBlobInCOS(a,r)}else this._processAndStore(e,t.body)};_storeBlobInCOS=async(e,t)=>{let[r]=await navigator.crossOriginStorage.requestFileHandles([K1(t)],{create:!0}),a=await r.createWritable();await a.write(e),await a.close()};_processAndStore=async(e,t)=>{try{let r=[];for await(let s of t)r.push(s);let a=new Blob(r),n=await this._getBlobHash(a);await this._storeBlobInCOS(a,n);try{await(await this._getHashCache()).put(e,new Response(n))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let t=await this._getHashCache(),r=await t.match(e);if(r)return r.text();let a=await this._getLfsFileHash(e);return a?(await t.put(e,new Response(a)),a):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes("/resolve/"))return null;let t=e.replace("/resolve/","/raw/");try{let a=(await fetch(t).then(n=>n.text())).match(/^oid sha256:([0-9a-f]+)$/m);return a?a[1]:null}catch{return null}};_getBlobHash=async e=>{let t=await e.arrayBuffer(),r=await crypto.subtle.digest(c0,t);return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}};async function Mn(e=null){let t=null;if(Te.useCustomCache){if(!Te.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!Te.customCache.match||!Te.customCache.put)throw new 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");t=Te.customCache}if(!t&&Te.experimental_useCrossOriginStorage&&W1.isAvailable()&&(t=new W1),!t&&Te.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{t=await caches.open(Te.cacheKey)}catch(r){he.warn("An error occurred while opening the browser cache:",r)}}if(!t&&Te.useFSCache){if(!me.IS_FS_AVAILABLE)throw Error("File System Cache is not available in this environment.");t=new _0(e??Te.cacheDir)}return t}async function _B(e,...t){for(let r of t)try{let a=await e.match(r);if(a)return a}catch{continue}}var cB=class{#t;#e;constructor(e){this.#t=e,this.#e=new Map}get(e){if(!this.#e.has(e))return;let t=this.#e.get(e);return this.#e.delete(e),this.#e.set(e,t),t}put(e,t){this.#e.has(e)&&this.#e.delete(e),this.#e.set(e,t),this.#e.size>this.#t&&this.#e.delete(this.#e.keys().next().value)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}},lB=100,u_=new cB(lB);function l0(e,t){let r=u_.get(e);if(r!==void 0)return r;let a=t().then(n=>n,n=>(u_.delete(e),Promise.reject(n)));return u_.put(e,a),a}async function uB(e){if(!Bn(e,["http:","https:"]))return null;let t=u0(e);return t.set("Range","bytes=0-0"),Te.fetch(e,{method:"GET",headers:t,cache:"no-store"})}function Ua(e,t,r={}){let a=JSON.stringify([e,t,r?.revision,r?.cache_dir,r?.local_files_only]);return l0(a,()=>dB(e,t,r))}async function dB(e,t,r){let a=await Mn(r?.cache_dir),{localPath:n,remoteURL:s,proposedCacheKey:i,validModelId:H}=Ps(e,t,r,a),o=await Rs(a,n,i);if(o!==void 0&&typeof o!="string"){let _=o.headers.get("content-length"),c=o.headers.get("content-type");return{exists:!0,size:_?parseInt(_,10):void 0,contentType:c||void 0,fromCache:!0}}if(Te.allowLocalModels&&!Bn(n,["http:","https:"]))try{let c=await Ds(n);if(typeof c!="string"&&c.status!==404){let l=c.headers.get("content-length"),d=c.headers.get("content-type");return{exists:!0,size:l?parseInt(l,10):void 0,contentType:d||void 0,fromCache:!1}}}catch{}if(Te.allowRemoteModels&&!r.local_files_only&&H)try{let _=await uB(s);if(_&&_.status>=200&&_.status<300){let c,l=_.headers.get("content-type");if(_.status===206){let d=_.headers.get("content-range");if(d){let h=d.match(/bytes \d+-\d+\/(\d+)/);h&&(c=parseInt(h[1],10))}}else if(_.status===200)try{await _.body?.cancel()}catch{}if(c===void 0){let d=_.headers.get("content-length");c=d?parseInt(d,10):void 0}return{exists:!0,size:c,contentType:l||void 0,fromCache:!1}}}catch(_){he.warn(`Unable to fetch file metadata for "${s}": ${_}`)}return{exists:!1,fromCache:!1}}async function Ds(e){return Te.useFS&&!Bn(e,["http:","https:","blob:"])?new iH(e instanceof URL?e.protocol==="file:"?e.pathname:e.toString():e):Te.fetch(e,{headers:u0(e)})}function u0(e){let t=typeof process<"u"&&process?.release?.name==="node",r=new Headers;if(t){let a=!!process.env?.TESTING_REMOTELY,n=Te.version;if(r.set("User-Agent",`transformers.js/${n}; is_ci/${a};`),Bn(e,["http:","https:"],["huggingface.co","hf.co"])){let i=process.env?.HF_TOKEN??process.env?.HF_ACCESS_TOKEN;i&&r.set("Authorization",`Bearer ${i}`)}}return r}function Ps(e,t,r={},a=null){let n=r.revision??"main",s=Oi(e,t),i=sB(e),H=i?Oi(Te.localModelPath,s):s,o=Oi(Te.remoteHost,Te.remotePathTemplate.replaceAll("{model}",e).replaceAll("{revision}",encodeURIComponent(n)),t),_=a instanceof _0?n==="main"?s:Oi(e,n,t):o;return{requestURL:s,localPath:H,remoteURL:o,proposedCacheKey:_,validModelId:i}}async function Rs(e,t,r){if(e)return await _B(e,t,r)}async function pB(e,t,r,a,n,s,i={}){if(await r.match(a)===void 0)if(s){if(typeof n!="string"){let H=new Headers(n.headers);H.set("content-length",s.byteLength.toString()),await r.put(a,new Response(s,{headers:H})).catch(o=>{he.warn(`Unable to add response to browser cache: ${o}.`)})}}else{let H=i.progress_callback?o=>pa(i.progress_callback,{status:"progress",name:e,file:t,...o}):void 0;await r.put(a,n,H)}}async function hB(e,t,r=!0,a={},n=!1,s=null){let{requestURL:i,localPath:H,remoteURL:o,proposedCacheKey:_,validModelId:c}=Ps(e,t,a,s),l,d=!1,h;h=await Rs(s,H,_);let $=h!==void 0;if($)l=_;else{if(Te.allowLocalModels)if(Bn(i,["http:","https:"])){if(a.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${i}.`);if(!Te.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${i}.`)}else try{h=await Ds(H),l=H}catch(T){he.warn(`Unable to load from local path "${H}": "${T}"`)}if(h===void 0||typeof h!="string"&&h.status===404){if(a.local_files_only||!Te.allowRemoteModels){if(r)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${H}".`);return null}if(!c)throw Error(`Local file missing at "${H}" and download aborted due to invalid model ID "${e}".`);if(h=await Ds(o),h.status!==200)return iB(h.status,o,r);l=_}d=s&&typeof Response<"u"&&h instanceof Response&&h.status===200}pa(a.progress_callback,{status:"download",name:e,file:t});let m;if(!(me.IS_NODE_ENV&&n)){let I;if(typeof h!="string")if(!a.progress_callback)I=new Uint8Array(await h.arrayBuffer());else if($&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))I=new Uint8Array(await h.arrayBuffer()),pa(a.progress_callback,{status:"progress",name:e,file:t,progress:100,loaded:I.length,total:I.length});else{let T,D=h.headers.get("content-length");if(D)T=parseInt(D,10);else try{let v=await Ua(e,t,a);v.size&&(T=v.size)}catch{}I=await HB(h,v=>{pa(a.progress_callback,{status:"progress",name:e,file:t,...v})},T)}m=I}if(d&&l&&typeof h!="string"&&await pB(e,t,s,l,h,m,a),me.IS_NODE_ENV&&n&&a.progress_callback&&typeof h!="string"){let I=parseInt(h.headers.get("content-length"),10)||0;pa(a.progress_callback,{status:"progress",name:e,file:t,progress:100,loaded:I,total:I})}if(pa(a.progress_callback,{status:"done",name:e,file:t}),m){if(!me.IS_NODE_ENV&&n)throw new Error("Cannot return path in a browser environment.");return m}if(h instanceof iH)return h.filePath;let S=await s?.match(l);if(S instanceof iH)return S.filePath;if(S instanceof Response)return new Uint8Array(await S.arrayBuffer());if(typeof S=="string")return S;throw new Error("Unable to get model file path or buffer.")}var Gi=new Map;async function HH(e,t,r=!0,a={},n=!1){if(!Te.allowLocalModels){if(a.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(!Te.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}pa(a.progress_callback,{status:"initiate",name:e,file:t});let s=`${e}::${t}`,i=Gi.get(s);if(!i){let H=await Mn(a?.cache_dir);i=hB(e,t,r,a,n,H).then(o=>(Gi.delete(s),o),o=>{throw Gi.delete(s),o}),Gi.set(s,i)}return await i}async function uc(e,t,r=!0,a={}){let n=await HH(e,t,r,a,!1);return n===null?null:new TextDecoder("utf-8").decode(n)}async function yr(e,t,r=!0,a={}){let n=await uc(e,t,r,a);return n===null?{}:JSON.parse(n)}function fB(e,[t,r,a],[n,s],i="bilinear",H=!1){let o=s/a,_=n/r,c=new e.constructor(n*s*t),l=r*a,d=n*s;for(let h=0;h<n;++h)for(let $=0;$<s;++$){let m=h*s+$,S=($+.5)/o-.5,I=(h+.5)/_-.5,T=Math.floor(S),D=Math.floor(I),v=Math.min(T+1,a-1),C=Math.min(D+1,r-1);T=Math.max(T,0),D=Math.max(D,0);let R=S-T,A=I-D,U=(1-R)*(1-A),Z=R*(1-A),j=(1-R)*A,z=R*A,X=D*a,q=C*a,G=X+T,y=X+v,Q=q+T,_e=q+v;for(let M=0;M<t;++M){let k=M*l;c[M*d+m]=U*e[k+G]+Z*e[k+y]+j*e[k+Q]+z*e[k+_e]}}return c}function EB(e,t,r){let a=new Array(r.length),n=new Array(r.length);for(let H=r.length-1,o=1;H>=0;--H)n[H]=o,a[H]=t[r[H]],o*=a[H];let s=r.map((H,o)=>n[r.indexOf(o)]),i=new e.constructor(e.length);for(let H=0;H<e.length;++H){let o=0;for(let _=t.length-1,c=H;_>=0;--_)o+=c%t[_]*s[_],c=Math.floor(c/t[_]);i[o]=e[H]}return[i,a]}function St(e){let t=et(e)[0],r=e.map(s=>Math.exp(s-t)),a=r.reduce((s,i)=>s+i,0);return r.map(s=>s/a)}function $B(e){let t=et(e)[0],r=0;for(let s=0;s<e.length;++s)r+=Math.exp(e[s]-t);let a=Math.log(r);return e.map(s=>s-t-a)}function mB(e,t){let r=0;for(let a=0;a<e.length;++a)r+=e[a]*t[a];return r}function L7(e,t){let r=mB(e,t),a=V1(e),n=V1(t);return r/(a*n)}function V1(e){return Math.sqrt(e.reduce((t,r)=>t+r*r,0))}function W_(e){if(e.length===0)throw Error("Array must not be empty");let t=e[0],r=0;for(let a=1;a<e.length;++a)e[a]<t&&(t=e[a],r=a);return[t,r]}function et(e){if(e.length===0)throw Error("Array must not be empty");let t=e[0],r=0;for(let a=1;a<e.length;++a)e[a]>t&&(t=e[a],r=a);return[t,r]}function d0(e){return e>0&&(e&e-1)===0}var p0=class{constructor(e){if(this.size=e|0,this.size<=1||!d0(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=e<<1,this.table=new Float64Array(this.size*2);for(let r=0;r<this.table.length;r+=2){let a=Math.PI*r/this.size;this.table[r]=Math.cos(a),this.table[r+1]=-Math.sin(a)}let t=0;for(let r=1;this.size>r;r<<=1)++t;this._width=t%2===0?t-1:t,this._bitrev=new Int32Array(1<<this._width);for(let r=0;r<this._bitrev.length;++r){this._bitrev[r]=0;for(let a=0;a<this._width;a+=2){let n=this._width-a-2;this._bitrev[r]|=(r>>>a&3)<<n}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,t){let r=t||new Array(e.length>>>1);for(let a=0;a<e.length;a+=2)r[a>>>1]=e[a];return r}toComplexArray(e,t){let r=t||this.createComplexArray();for(let a=0;a<r.length;a+=2)r[a]=e[a>>>1],r[a+1]=0;return r}transform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._transform4(e,t,-1);for(let r=0;r<e.length;++r)e[r]/=this.size}_transform4(e,t,r){let a=this._csize,s=1<<this._width,i=a/s<<1,H,o,_=this._bitrev;if(i===4)for(H=0,o=0;H<a;H+=i,++o){let l=_[o];this._singleTransform2(t,e,H,l,s)}else for(H=0,o=0;H<a;H+=i,++o){let l=_[o];this._singleTransform4(t,e,H,l,s,r)}let c=this.table;for(s>>=2;s>=2;s>>=2){i=a/s<<1;let l=i>>>2;for(H=0;H<a;H+=i){let d=H+l-1;for(let h=H,$=0;h<d;h+=2,$+=s){let m=h,S=m+l,I=S+l,T=I+l,D=e[m],v=e[m+1],C=e[S],R=e[S+1],A=e[I],U=e[I+1],Z=e[T],j=e[T+1],z=c[$],X=r*c[$+1],q=C*z-R*X,G=C*X+R*z,y=c[2*$],Q=r*c[2*$+1],_e=A*y-U*Q,M=A*Q+U*y,k=c[3*$],F=r*c[3*$+1],J=Z*k-j*F,Ie=Z*F+j*k,Ze=D+_e,oe=v+M,Ct=D-_e,Ue=v-M,at=q+J,xt=G+Ie,Ge=r*(q-J),ve=r*(G-Ie);e[m]=Ze+at,e[m+1]=oe+xt,e[S]=Ct+ve,e[S+1]=Ue-Ge,e[I]=Ze-at,e[I+1]=oe-xt,e[T]=Ct-ve,e[T+1]=Ue+Ge}}}}_singleTransform2(e,t,r,a,n){let s=e[a],i=e[a+1],H=e[a+n],o=e[a+n+1];t[r]=s+H,t[r+1]=i+o,t[r+2]=s-H,t[r+3]=i-o}_singleTransform4(e,t,r,a,n,s){let i=n*2,H=n*3,o=e[a],_=e[a+1],c=e[a+n],l=e[a+n+1],d=e[a+i],h=e[a+i+1],$=e[a+H],m=e[a+H+1],S=o+d,I=_+h,T=o-d,D=_-h,v=c+$,C=l+m,R=s*(c-$),A=s*(l-m);t[r]=S+v,t[r+1]=I+C,t[r+2]=T+A,t[r+3]=D-R,t[r+4]=S-v,t[r+5]=I-C,t[r+6]=T-A,t[r+7]=D+R}_realTransform4(e,t,r){let a=this._csize,s=1<<this._width,i=a/s<<1,H,o,_=this._bitrev;if(i===4)for(H=0,o=0;H<a;H+=i,++o){let d=_[o];this._singleRealTransform2(t,e,H,d>>>1,s>>>1)}else for(H=0,o=0;H<a;H+=i,++o){let d=_[o];this._singleRealTransform4(t,e,H,d>>>1,s>>>1,r)}let c=this.table;for(s>>=2;s>=2;s>>=2){i=a/s<<1;let d=i>>>1,h=d>>>1,$=h>>>1;for(H=0;H<a;H+=i)for(let m=0,S=0;m<=$;m+=2,S+=s){let I=H+m,T=I+h,D=T+h,v=D+h,C=e[I],R=e[I+1],A=e[T],U=e[T+1],Z=e[D],j=e[D+1],z=e[v],X=e[v+1],q=C,G=R,y=c[S],Q=r*c[S+1],_e=A*y-U*Q,M=A*Q+U*y,k=c[2*S],F=r*c[2*S+1],J=Z*k-j*F,Ie=Z*F+j*k,Ze=c[3*S],oe=r*c[3*S+1],Ct=z*Ze-X*oe,Ue=z*oe+X*Ze,at=q+J,xt=G+Ie,Ge=q-J,ve=G-Ie,nt=_e+Ct,hr=M+Ue,Ce=r*(_e-Ct),ke=r*(M-Ue);if(e[I]=at+nt,e[I+1]=xt+hr,e[T]=Ge+ke,e[T+1]=ve-Ce,m===0){e[D]=at-nt,e[D+1]=xt-hr;continue}if(m===$)continue;let qa=H+h-m,Qn=H+d-m;e[qa]=Ge-r*ke,e[qa+1]=-ve-r*Ce,e[Qn]=at-r*nt,e[Qn+1]=-xt+r*hr}}let l=a>>>1;for(let d=2;d<l;d+=2)e[a-d]=e[d],e[a-d+1]=-e[d+1]}_singleRealTransform2(e,t,r,a,n){let s=e[a],i=e[a+n];t[r]=s+i,t[r+1]=0,t[r+2]=s-i,t[r+3]=0}_singleRealTransform4(e,t,r,a,n,s){let i=n*2,H=n*3,o=e[a],_=e[a+n],c=e[a+i],l=e[a+H],d=o+c,h=o-c,$=_+l,m=s*(_-l);t[r]=d+$,t[r+1]=0,t[r+2]=h,t[r+3]=-m,t[r+4]=d-$,t[r+5]=0,t[r+6]=h,t[r+7]=m}},IB=class{constructor(e){let t=2*(e-1),r=2*(2*e-1),a=2**Math.ceil(Math.log2(r));this.bufferSize=a,this._a=t;let n=new Float64Array(r),s=new Float64Array(a);this._chirpBuffer=new Float64Array(a),this._buffer1=new Float64Array(a),this._buffer2=new Float64Array(a),this._outBuffer1=new Float64Array(a),this._outBuffer2=new Float64Array(a);let i=-2*Math.PI/e,H=Math.cos(i),o=Math.sin(i);for(let _=0;_<r>>1;++_){let c=(_+1-e)**2/2,l=Math.sqrt(H**2+o**2)**c,d=c*Math.atan2(o,H),h=2*_;n[h]=l*Math.cos(d),n[h+1]=l*Math.sin(d),s[h]=n[h],s[h+1]=-n[h+1]}this._slicedChirpBuffer=n.subarray(t,r),this._f=new p0(a>>1),this._f.transform(this._chirpBuffer,s)}_transform(e,t,r){let a=this._buffer1,n=this._buffer2,s=this._outBuffer1,i=this._outBuffer2,H=this._chirpBuffer,o=this._slicedChirpBuffer,_=this._a;if(r)for(let c=0;c<o.length;c+=2){let l=c+1,d=c>>1,h=t[d];a[c]=h*o[c],a[l]=h*o[l]}else for(let c=0;c<o.length;c+=2){let l=c+1;a[c]=t[c]*o[c]-t[l]*o[l],a[l]=t[c]*o[l]+t[l]*o[c]}this._f.transform(s,a);for(let c=0;c<H.length;c+=2){let l=c+1;n[c]=s[c]*H[c]-s[l]*H[l],n[l]=s[c]*H[l]+s[l]*H[c]}this._f.inverseTransform(i,n);for(let c=0;c<i.length;c+=2){let l=i[c+_],d=i[c+_+1],h=o[c],$=o[c+1];e[c]=l*h-d*$,e[c+1]=l*$+d*h}}transform(e,t){this._transform(e,t,!1)}realTransform(e,t){this._transform(e,t,!0)}},SB=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=d0(e),this.isPowerOfTwo?(this.fft=new p0(e),this.outputBufferSize=2*e):(this.fft=new IB(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,t){this.fft.realTransform(e,t)}transform(e,t){this.fft.transform(e,t)}};function LB(e,t){if(t%2===0||t<=0)throw new Error("Window size must be a positive odd number");let r=new e.constructor(e.length),a=new e.constructor(t),n=Math.floor(t/2);for(let s=0;s<e.length;++s){let i=0;for(let H=-n;H<=n;++H){let o=s+H;o<0?o=Math.abs(o):o>=e.length&&(o=2*(e.length-1)-o),a[i++]=e[o]}a.sort(),r[s]=a[n]}return r}function As(e,t){let r=Math.pow(10,t);return Math.round(e*r)/r}function AB(e){let t=Math.round(e);return Math.abs(e)%1===.5?t%2===0?t:t-1:t}function gB(e){let t=e.length,r=e[0].length,a=[t+1,r+1],n=Array.from({length:a[0]},()=>Array(a[1]).fill(1/0));n[0][0]=0;let s=Array.from({length:a[0]},()=>Array(a[1]).fill(-1));for(let c=1;c<a[1];++c)for(let l=1;l<a[0];++l){let d=n[l-1][c-1],h=n[l-1][c],$=n[l][c-1],m,S;d<h&&d<$?(m=d,S=0):h<d&&h<$?(m=h,S=1):(m=$,S=2),n[l][c]=e[l-1][c-1]+m,s[l][c]=S}for(let c=0;c<a[1];++c)s[0][c]=2;for(let c=0;c<a[0];++c)s[c][0]=1;let i=t,H=r,o=[],_=[];for(;i>0||H>0;)switch(o.push(i-1),_.push(H-1),s[i][H]){case 0:--i,--H;break;case 1:--i;break;case 2:--H;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${i}, ${H}]. Please file a bug report.`)}return o.reverse(),_.reverse(),[o,_]}var TB=(function(){let e=null;return function(t){if(!e){e=new Float32Array(65536);let s=new ArrayBuffer(4),i=new Uint32Array(s),H=new Float32Array(s);for(let o=0;o<e.length;++o){let _=0,c=(o&32768)<<16,l=(o&31744)>>10,d=o&1023;if(l===31)_=c|2139095040|d<<13;else if(l===0)if(d===0)_=c;else{let h=113;for(;(d&1024)===0;)d<<=1,--h;d&=-1025,_=c|h<<23|d<<13}else _=c|l+112<<23|d<<13;i[0]=_,e[o]=H[0]}}let r=t.length,a=e,n=new Float32Array(r);for(let s=0;s<r;++s)n[s]=a[t[s]];return n}})(),h0={};wn(h0,{InferenceSession:()=>hc,TRACE:()=>_H,TRACE_EVENT_BEGIN:()=>ha,TRACE_EVENT_END:()=>fa,TRACE_FUNC_BEGIN:()=>Fa,TRACE_FUNC_END:()=>Za,Tensor:()=>nr,default:()=>t2,env:()=>qe,registerBackend:()=>ka});var dc=Object.defineProperty,vB=Object.getOwnPropertyDescriptor,DB=Object.getOwnPropertyNames,CB=Object.prototype.hasOwnProperty,xB=(e=>typeof fn<"u"?fn:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof fn<"u"?fn:t)[r]}):e)(function(e){if(typeof fn<"u")return fn.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Ae=(e,t)=>()=>(e&&(t=e(e=0)),t),ks=(e,t)=>{for(var r in t)dc(e,r,{get:t[r],enumerable:!0})},NB=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of DB(t))!CB.call(e,n)&&n!==r&&dc(e,n,{get:()=>t[n],enumerable:!(a=vB(t,n))||a.enumerable});return e},oH=e=>NB(dc({},"__esModule",{value:!0}),e),Es,oa,ka,j1,f0,E0=Ae(()=>{"use strict";Es=new Map,oa=[],ka=(e,t,r)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let a=Es.get(e);if(a===void 0)Es.set(e,{backend:t,priority:r});else{if(a.priority>r)return;if(a.priority===r&&a.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${r}`)}if(r>=0){let n=oa.indexOf(e);n!==-1&&oa.splice(n,1);for(let s=0;s<oa.length;s++)if(Es.get(oa[s]).priority<=r){oa.splice(s,0,e);return}oa.push(e)}return}throw new TypeError("not a valid backend")},j1=async e=>{let t=Es.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(a){return r||(t.error=`${a}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},f0=async e=>{let t=e.executionProviders||[],r=t.map(o=>typeof o=="string"?o:o.name),a=r.length===0?oa:r,n,s=[],i=new Set;for(let o of a){let _=await j1(o);typeof _=="string"?s.push({name:o,err:_}):(n||(n=_),n===_&&i.add(o))}if(!n)throw new Error(`no available backend found. ERR: ${s.map(o=>`[${o.name}] ${o.err}`).join(", ")}`);for(let{name:o,err:_}of s)r.includes(o)&&console.warn(`removing requested execution provider "${o}" from session options because it is not available: ${_}`);let H=t.filter(o=>i.has(typeof o=="string"?o:o.name));return[n,new Proxy(e,{get:(o,_)=>_==="executionProviders"?H:Reflect.get(o,_)})]}}),wB=Ae(()=>{"use strict";E0()}),$0,yB=Ae(()=>{"use strict";$0="1.24.0-dev.20251116-b39e144322"}),d_,dt,m0=Ae(()=>{"use strict";yB(),d_="warning",dt={wasm:{},webgl:{},webgpu:{},versions:{common:$0},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);d_=e}},get logLevel(){return d_}},Object.defineProperty(dt,"logLevel",{enumerable:!0})}),qe,BB=Ae(()=>{"use strict";m0(),qe=dt}),I0,S0,MB=Ae(()=>{"use strict";I0=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];let a=r.getContext("2d");if(a!=null){let n,s;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(n=e.dims[2],s=e.dims[3]):(n=e.dims[3],s=e.dims[2]);let i=t?.format!==void 0?t.format:"RGB",H=t?.norm,o,_;H===void 0||H.mean===void 0?o=[255,255,255,255]:typeof H.mean=="number"?o=[H.mean,H.mean,H.mean,H.mean]:(o=[H.mean[0],H.mean[1],H.mean[2],0],H.mean[3]!==void 0&&(o[3]=H.mean[3])),H===void 0||H.bias===void 0?_=[0,0,0,0]:typeof H.bias=="number"?_=[H.bias,H.bias,H.bias,H.bias]:(_=[H.bias[0],H.bias[1],H.bias[2],0],H.bias[3]!==void 0&&(_[3]=H.bias[3]));let c=s*n,l=0,d=c,h=c*2,$=-1;i==="RGBA"?(l=0,d=c,h=c*2,$=c*3):i==="RGB"?(l=0,d=c,h=c*2):i==="RBG"&&(l=0,h=c,d=c*2);for(let m=0;m<s;m++)for(let S=0;S<n;S++){let I=(e.data[l++]-_[0])*o[0],T=(e.data[d++]-_[1])*o[1],D=(e.data[h++]-_[2])*o[2],v=$===-1?255:(e.data[$++]-_[3])*o[3];a.fillStyle="rgba("+I+","+T+","+D+","+v+")",a.fillRect(S,m,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},S0=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),a;if(r!=null){let n,s,i;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(n=e.dims[2],s=e.dims[1],i=e.dims[3]):(n=e.dims[3],s=e.dims[2],i=e.dims[1]);let H=t!==void 0&&t.format!==void 0?t.format:"RGB",o=t?.norm,_,c;o===void 0||o.mean===void 0?_=[255,255,255,255]:typeof o.mean=="number"?_=[o.mean,o.mean,o.mean,o.mean]:(_=[o.mean[0],o.mean[1],o.mean[2],255],o.mean[3]!==void 0&&(_[3]=o.mean[3])),o===void 0||o.bias===void 0?c=[0,0,0,0]:typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:(c=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(c[3]=o.bias[3]));let l=s*n;if(t!==void 0&&(t.format!==void 0&&i===4&&t.format!=="RGBA"||i===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,h=0,$=1,m=2,S=3,I=0,T=l,D=l*2,v=-1;H==="RGBA"?(I=0,T=l,D=l*2,v=l*3):H==="RGB"?(I=0,T=l,D=l*2):H==="RBG"&&(I=0,D=l,T=l*2),a=r.createImageData(n,s);for(let C=0;C<s*n;h+=d,$+=d,m+=d,S+=d,C++)a.data[h]=(e.data[I++]-c[0])*_[0],a.data[$]=(e.data[T++]-c[1])*_[1],a.data[m]=(e.data[D++]-c[2])*_[2],a.data[S]=v===-1?255:(e.data[v++]-c[3])*_[3]}else throw new Error("Can not access image data");return a}}),Fi,L0,A0,g0,T0,b0,PB=Ae(()=>{"use strict";pc(),Fi=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:a}=t,n=t.norm??{mean:255,bias:0},s,i;typeof n.mean=="number"?s=[n.mean,n.mean,n.mean,n.mean]:s=[n.mean[0],n.mean[1],n.mean[2],n.mean[3]??255],typeof n.bias=="number"?i=[n.bias,n.bias,n.bias,n.bias]:i=[n.bias[0],n.bias[1],n.bias[2],n.bias[3]??0];let H=t.format!==void 0?t.format:"RGBA",o=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",_=r*a,c=o==="RGBA"?new Float32Array(_*4):new Float32Array(_*3),l=4,d=0,h=1,$=2,m=3,S=0,I=_,T=_*2,D=-1;H==="RGB"&&(l=3,d=0,h=1,$=2,m=-1),o==="RGBA"?D=_*3:o==="RBG"?(S=0,T=_,I=_*2):o==="BGR"&&(T=0,I=_,S=_*2);for(let v=0;v<_;v++,d+=l,$+=l,h+=l,m+=l)c[S++]=(e[d]+i[0])/s[0],c[I++]=(e[h]+i[1])/s[1],c[T++]=(e[$]+i[2])/s[2],D!==-1&&m!==-1&&(c[D++]=(e[m]+i[3])/s[3]);return o==="RGBA"?new jt("float32",c,[1,4,r,a]):new jt("float32",c,[1,3,r,a])},L0=async(e,t)=>{let r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,a=typeof ImageData<"u"&&e instanceof ImageData,n=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,s=typeof e=="string",i,H=t??{},o=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},_=c=>typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||c instanceof OffscreenCanvas?c.getContext("2d"):null;if(r){let c=o();c.width=e.width,c.height=e.height;let l=_(c);if(l!=null){let d=e.height,h=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(d=t.resizedHeight,h=t.resizedWidth),t!==void 0){if(H=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");H.tensorFormat="RGBA",H.height=d,H.width=h}else H.tensorFormat="RGBA",H.height=d,H.width=h;l.drawImage(e,0,0),i=l.getImageData(0,0,h,d).data}else throw new Error("Can not access image data")}else if(a){let c,l;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(c=t.resizedHeight,l=t.resizedWidth):(c=e.height,l=e.width),t!==void 0&&(H=t),H.format="RGBA",H.height=c,H.width=l,t!==void 0){let d=o();d.width=l,d.height=c;let h=_(d);if(h!=null)h.putImageData(e,0,0),i=h.getImageData(0,0,l,c).data;else throw new Error("Can not access image data")}else i=e.data}else if(n){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=o();c.width=e.width,c.height=e.height;let l=_(c);if(l!=null){let d=e.height,h=e.width;return l.drawImage(e,0,0,h,d),i=l.getImageData(0,0,h,d).data,H.height=d,H.width=h,Fi(i,H)}else throw new Error("Can not access image data")}else{if(s)return new Promise((c,l)=>{let d=o(),h=_(d);if(!e||!h)return l();let $=new Image;$.crossOrigin="Anonymous",$.src=e,$.onload=()=>{d.width=$.width,d.height=$.height,h.drawImage($,0,0,d.width,d.height);let m=h.getImageData(0,0,d.width,d.height);H.height=d.height,H.width=d.width,c(Fi(m.data,H))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(i!==void 0)return Fi(i,H);throw new Error("Input data provided is not supported - aborted tensor creation")},A0=(e,t)=>{let{width:r,height:a,download:n,dispose:s}=t,i=[1,a,r,4];return new jt({location:"texture",type:"float32",texture:e,dims:i,download:n,dispose:s})},g0=(e,t)=>{let{dataType:r,dims:a,download:n,dispose:s}=t;return new jt({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:a,download:n,dispose:s})},T0=(e,t)=>{let{dataType:r,dims:a,download:n,dispose:s}=t;return new jt({location:"ml-tensor",type:r??"float32",mlTensor:e,dims:a,download:n,dispose:s})},b0=(e,t,r)=>new jt({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]})}),Pa,gs,p_,v0,RB=Ae(()=>{"use strict";Pa=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),gs=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),p_=!1,v0=()=>{if(!p_){p_=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,a=typeof r<"u"&&r.from;e&&(Pa.set("int64",BigInt64Array),gs.set(BigInt64Array,"int64")),t&&(Pa.set("uint64",BigUint64Array),gs.set(BigUint64Array,"uint64")),a?(Pa.set("float16",r),gs.set(r,"float16")):Pa.set("float16",Uint16Array)}}}),D0,C0,kB=Ae(()=>{"use strict";pc(),D0=e=>{let t=1;for(let r=0;r<e.length;r++){let a=e[r];if(typeof a!="number"||!Number.isSafeInteger(a))throw new TypeError(`dims[${r}] must be an integer, got: ${a}`);if(a<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${a}`);t*=a}return t},C0=(e,t)=>{switch(e.location){case"cpu":return new jt(e.type,e.data,t);case"cpu-pinned":return new jt({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new jt({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new jt({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case"ml-tensor":return new jt({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),jt,pc=Ae(()=>{"use strict";MB(),PB(),RB(),kB(),jt=class{constructor(e,t,r){v0();let a,n;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,a=e.type,n=e.dims,e.location){case"cpu-pinned":{let i=Pa.get(a);if(!i)throw new TypeError(`unsupported type "${a}" to create tensor from pinned buffer`);if(!(e.data instanceof i))throw new TypeError(`buffer should be of type ${i.name}`);this.cpuData=e.data;break}case"texture":{if(a!=="float32")throw new TypeError(`unsupported type "${a}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break}case"gpu-buffer":{if(a!=="float32"&&a!=="float16"&&a!=="int32"&&a!=="int64"&&a!=="uint32"&&a!=="uint8"&&a!=="bool"&&a!=="uint4"&&a!=="int4")throw new TypeError(`unsupported type "${a}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}case"ml-tensor":{if(a!=="float32"&&a!=="float16"&&a!=="int32"&&a!=="int64"&&a!=="uint32"&&a!=="uint64"&&a!=="int8"&&a!=="uint8"&&a!=="bool"&&a!=="uint4"&&a!=="int4")throw new TypeError(`unsupported type "${a}" 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 i,H;if(typeof e=="string")if(a=e,H=r,e==="string"){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");i=t}else{let o=Pa.get(e);if(o===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e==="float16"&&o===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${o.name} as data.`);e==="uint64"||e==="int64"?i=o.from(t,BigInt):i=o.from(t)}else if(t instanceof o)i=t;else if(t instanceof Uint8ClampedArray)if(e==="uint8")i=Uint8Array.from(t);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(e==="float16"&&t instanceof Uint16Array&&o!==Uint16Array)i=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw new TypeError(`A ${a} tensor's data must be type of ${o}`)}else if(H=t,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let o=typeof e[0];if(o==="string")a="string",i=e;else if(o==="boolean")a="bool",i=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${o}.`)}else if(e instanceof Uint8ClampedArray)a="uint8",i=Uint8Array.from(e);else{let o=gs.get(e.constructor);if(o===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);a=o,i=e}if(H===void 0)H=[i.length];else if(!Array.isArray(H))throw new TypeError("A tensor's dims must be a number array");n=H,this.cpuData=i,this.dataLocation="cpu"}let s=D0(n);if(this.cpuData&&s!==this.cpuData.length&&!((a==="uint4"||a==="int4")&&Math.ceil(s/2)===this.cpuData.length))throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=a,this.dims=n,this.size=s}static async fromImage(e,t){return L0(e,t)}static fromTexture(e,t){return A0(e,t)}static fromGpuBuffer(e,t){return g0(e,t)}static fromMLTensor(e,t){return T0(e,t)}static fromPinnedBuffer(e,t,r){return b0(e,t,r)}toDataURL(e){return I0(this,e)}toImageData(e){return S0(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return C0(this,e)}}}),nr,x0=Ae(()=>{"use strict";pc(),nr=jt}),_H,h_,Fa,Za,ha,fa,N0=Ae(()=>{"use strict";m0(),_H=(e,t)=>{(typeof dt.trace>"u"?!dt.wasm.trace:!dt.trace)||console.timeStamp(`${e}::ORT::${t}`)},h_=(e,t)=>{let r=new Error().stack?.split(/\r\n|\r|\n/g)||[],a=!1;for(let n=0;n<r.length;n++){if(a&&!r[n].includes("TRACE_FUNC")){let s=`FUNC_${e}::${r[n].trim().split(" ")[1]}`;t&&(s+=`::${t}`),_H("CPU",s);return}r[n].includes("TRACE_FUNC")&&(a=!0)}},Fa=e=>{(typeof dt.trace>"u"?!dt.wasm.trace:!dt.trace)||h_("BEGIN",e)},Za=e=>{(typeof dt.trace>"u"?!dt.wasm.trace:!dt.trace)||h_("END",e)},ha=e=>{(typeof dt.trace>"u"?!dt.wasm.trace:!dt.trace)||console.time(`ORT::${e}`)},fa=e=>{(typeof dt.trace>"u"?!dt.wasm.trace:!dt.trace)||console.timeEnd(`ORT::${e}`)}}),w0,OB=Ae(()=>{"use strict";E0(),x0(),N0(),w0=class y0{constructor(t){this.handler=t}async run(t,r,a){Fa(),ha("InferenceSession.run");let n={},s={};if(typeof t!="object"||t===null||t instanceof nr||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof nr)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(let _ of r){if(typeof _!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(_)===-1)throw new RangeError(`'fetches' contains invalid output name: ${_}.`);n[_]=null}if(typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else{let _=!1,c=Object.getOwnPropertyNames(r);for(let l of this.outputNames)if(c.indexOf(l)!==-1){let d=r[l];(d===null||d instanceof nr)&&(_=!0,i=!1,n[l]=d)}if(_){if(typeof a=="object"&&a!==null)s=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else s=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let _ of this.inputNames)if(typeof t[_]>"u")throw new Error(`input '${_}' is missing in 'feeds'.`);if(i)for(let _ of this.outputNames)n[_]=null;let H=await this.handler.run(t,n,s),o={};for(let _ in H)if(Object.hasOwnProperty.call(H,_)){let c=H[_];c instanceof nr?o[_]=c:o[_]=new nr(c.type,c.data,c.dims)}return fa("InferenceSession.run"),Za(),o}async release(){return this.handler.dispose()}static async create(t,r,a,n){Fa(),ha("InferenceSession.create");let s,i={};if(typeof t=="string"){if(s=t,typeof r=="object"&&r!==null)i=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(s=t,typeof r=="object"&&r!==null)i=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let c=t,l=0,d=t.byteLength;if(typeof r=="object"&&r!==null)i=r;else if(typeof r=="number"){if(l=r,!Number.isSafeInteger(l))throw new RangeError("'byteOffset' must be an integer.");if(l<0||l>=c.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${c.byteLength}).`);if(d=t.byteLength-l,typeof a=="number"){if(d=a,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||l+d>c.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${c.byteLength-l}].`);if(typeof n=="object"&&n!==null)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(typeof a<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof r<"u")throw new TypeError("'options' must be an object.");s=new Uint8Array(c,l,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[H,o]=await f0(i),_=await H.createInferenceSessionHandler(s,o);return fa("InferenceSession.create"),Za(),new y0(_)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),hc,GB=Ae(()=>{"use strict";OB(),hc=w0}),FB=Ae(()=>{"use strict"}),ZB=Ae(()=>{"use strict"}),UB=Ae(()=>{"use strict"}),KB=Ae(()=>{"use strict"}),B0={};ks(B0,{InferenceSession:()=>hc,TRACE:()=>_H,TRACE_EVENT_BEGIN:()=>ha,TRACE_EVENT_END:()=>fa,TRACE_FUNC_BEGIN:()=>Fa,TRACE_FUNC_END:()=>Za,Tensor:()=>nr,env:()=>qe,registerBackend:()=>ka});var Ka=Ae(()=>{"use strict";wB(),BB(),GB(),x0(),FB(),ZB(),N0(),UB(),KB()}),fc=Ae(()=>{"use strict"}),M0={};ks(M0,{default:()=>P0});var f_,E_,P0,WB=Ae(()=>{"use strict";J0(),Wa(),Ec(),f_="ort-wasm-proxy-worker",E_=globalThis.self?.name===f_,E_&&(self.onmessage=e=>{let{type:t,in:r}=e.data;try{switch(t){case"init-wasm":$c(r.wasm).then(()=>{Ac(r).then(()=>{postMessage({type:t})},a=>{postMessage({type:t,err:a})})},a=>{postMessage({type:t,err:a})});break;case"init-ep":{let{epName:a,env:n}=r;gc(n,a).then(()=>{postMessage({type:t})},s=>{postMessage({type:t,err:s})});break}case"copy-from":{let{buffer:a}=r,n=uH(a);postMessage({type:t,out:n});break}case"create":{let{model:a,options:n}=r;Tc(a,n).then(s=>{postMessage({type:t,out:s})},s=>{postMessage({type:t,err:s})});break}case"release":bc(r),postMessage({type:t});break;case"run":{let{sessionId:a,inputIndices:n,inputs:s,outputIndices:i,options:H}=r;vc(a,n,s,i,new Array(i.length).fill(null),H).then(o=>{o.some(_=>_[3]!=="cpu")?postMessage({type:t,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:t,out:o},Cc([...s,...o]))},o=>{postMessage({type:t,err:o})});break}case"end-profiling":Dc(r),postMessage({type:t});break;default:}}catch(a){postMessage({type:t,err:a})}}),P0=E_?null:e=>new Worker(e??Wt,{type:"module",name:f_})}),R0={};ks(R0,{default:()=>k0});async function q1(e={}){var t=e,r=!!globalThis.window,a=!!globalThis.WorkerGlobalScope,n=a&&self.name?.startsWith("em-pthread");t.mountExternalData=(u,p)=>{u.startsWith("./")&&(u=u.substring(2)),(t.Uc||(t.Uc=new Map)).set(u,p)},t.unmountExternalData=()=>{delete t.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let s=()=>{let u=p=>(...f)=>{let E=Er;return f=p(...f),Er!=E?new Promise((L,b)=>{ro={resolve:L,reject:b}}):f};(()=>{for(let p of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])t[p]=u(t[p])})(),typeof jsepRunAsync<"u"&&(t._OrtRun=jsepRunAsync(t._OrtRun),t._OrtRunWithBinding=jsepRunAsync(t._OrtRunWithBinding)),s=void 0};t.asyncInit=()=>{s?.()};var i,H,o=(u,p)=>{throw p},_=import.meta.url,c="";if(r||a){try{c=new URL(".",_).href}catch{}a&&(H=u=>{var p=new XMLHttpRequest;return p.open("GET",u,!1),p.responseType="arraybuffer",p.send(null),new Uint8Array(p.response)}),i=async u=>{if(R(u))return new Promise((f,E)=>{var L=new XMLHttpRequest;L.open("GET",u,!0),L.responseType="arraybuffer",L.onload=()=>{L.status==200||L.status==0&&L.response?f(L.response):E(L.status)},L.onerror=E,L.send(null)});var p=await fetch(u,{credentials:"same-origin"});if(p.ok)return p.arrayBuffer();throw Error(p.status+" : "+p.url)}}var l,d,h,$,m,S,I=console.log.bind(console),T=console.error.bind(console),D=I,v=T,C=!1,R=u=>u.startsWith("file://");function A(){ta.buffer!=j.buffer&&Ie()}if(n){let u=function(p){try{var f=p.data,E=f.Oc;if(E==="load"){let L=[];self.onmessage=b=>L.push(b),S=()=>{postMessage({Oc:"loaded"});for(let b of L)u(b);self.onmessage=u};for(let b of f.ce)t[b]&&!t[b].proxy||(t[b]=(...w)=>{postMessage({Oc:"callHandler",be:b,args:w})},b=="print"&&(D=t[b]),b=="printErr"&&(v=t[b]));ta=f.ie,Ie(),d=f.je,Ue(),Hi()}else if(E==="run"){(function(L){var b=(A(),y)[L+52>>>2>>>0];L=(A(),y)[L+56>>>2>>>0],fp(b,b-L),ce(b)})(f.Nc),ho(f.Nc,0,0,1,0,0),ad(),YH(f.Nc),Z||(Qd(),Z=!0);try{LL(f.ge,f.Wc)}catch(L){if(L!="unwind")throw L}}else f.target!=="setimmediate"&&(E==="checkMailbox"?Z&&Ys():E&&(v(`worker: received unknown command ${E}`),v(f)))}catch(L){throw lp(),L}};var U=u,Z=!1;self.onunhandledrejection=p=>{throw p.reason||p},self.onmessage=u}var j,z,X,q,G,y,Q,_e,M,k,F,J=!1;function Ie(){var u=ta.buffer;t.HEAP8=j=new Int8Array(u),X=new Int16Array(u),t.HEAPU8=z=new Uint8Array(u),q=new Uint16Array(u),t.HEAP32=G=new Int32Array(u),t.HEAPU32=y=new Uint32Array(u),Q=new Float32Array(u),_e=new Float64Array(u),M=new BigInt64Array(u),k=new BigUint64Array(u)}function Ze(){J=!0,n?S():Gr._b()}function oe(u){throw v(u="Aborted("+u+")"),C=!0,u=new WebAssembly.RuntimeError(u+". Build with -sASSERTIONS for more info."),m?.(u),u}function Ct(){return{a:{f:AL,J:gL,k:TL,p:bL,l:vL,sa:DL,b:CL,ca:xL,Ja:_d,q:NL,da:dd,Za:pd,Fa:hd,Ha:fd,_a:Ed,Xa:$d,Qa:md,Wa:Id,oa:Sd,Ga:Ld,Xb:Ad,Ya:gd,Yb:Td,db:wL,Da:BL,Sb:ML,Qb:RL,Ca:OL,M:GL,I:FL,Rb:ZL,ja:XL,Tb:zL,Ta:JL,Vb:YL,Ka:eA,Ob:tA,ka:rA,Sa:YH,ab:aA,U:HA,n:uA,c:JH,rb:dA,w:pA,L:hA,z:fA,j:EA,o:yd,sb:$A,G:mA,T:IA,h:SA,u:LA,m:AA,i:gA,Na:TA,Oa:bA,Pa:vA,La:Rd,Ma:kd,Pb:Od,eb:CA,cb:wA,Y:yA,qb:BA,la:MA,bb:xA,fb:PA,$a:RA,Wb:kA,N:DA,gb:OA,X:GA,Ub:FA,nb:zA,C:JA,ra:QA,qa:YA,pb:eg,W:tg,v:rg,mb:ag,lb:ng,kb:sg,ob:ig,jb:Hg,ib:og,hb:_g,Ua:Wd,Va:Vd,Ia:VH,V:jd,na:qd,Ra:Xd,ma:zd,Cb:mT,xa:dT,Db:$T,ya:uT,F:tT,e:Zg,s:Gg,x:Og,B:Qg,Fb:_T,ba:oT,D:Wg,za:cT,$:pT,ga:HT,Gb:iT,Hb:sT,Ba:rT,Aa:nT,Ib:aT,wa:ET,aa:lT,d:Fg,A:Kg,r:Ug,Bb:IT,t:jg,y:Yg,H:Vg,E:qg,K:eT,R:hT,ia:Jg,_:fT,Jb:zg,Kb:Xg,g:lg,a:ta,Nb:qa,Eb:ug,ha:dg,O:pg,pa:hg,Lb:fg,ta:Eg,Q:$g,yb:mg,zb:Ig,ua:Sg,ea:Lg,P:Ag,Ea:gg,va:Tg,Z:bg,wb:vg,Zb:Dg,S:Cg,Ab:xg,tb:Ng,ub:yg,vb:Bg,fa:Mg,xb:Pg,Mb:Rg}}}async function Ue(){function u(E,L){var b=Gr=E.exports;E={};for(let[w,P]of Object.entries(b))typeof P=="function"?(b=nA(P),E[w]=b):E[w]=P;return Gr=E,Gr=(function(){var w=Gr,P=Y=>De=>Y(De)>>>0,W=Y=>()=>Y()>>>0;return(w=Object.assign({},w)).$b=P(w.$b),w.Cc=W(w.Cc),w.Ec=P(w.Ec),w.rd=(Y=>(De,Ne)=>Y(De,Ne)>>>0)(w.rd),w.wd=P(w.wd),w.xd=W(w.xd),w.Bd=P(w.Bd),w})(),td.push(Gr.id),Jd=(E=Gr).$b,Qd=E.ac,t._OrtInit=E.bc,t._OrtGetLastError=E.cc,t._OrtCreateSessionOptions=E.dc,t._OrtAppendExecutionProvider=E.ec,t._OrtAddFreeDimensionOverride=E.fc,t._OrtAddSessionConfigEntry=E.gc,t._OrtReleaseSessionOptions=E.hc,t._OrtCreateSession=E.ic,t._OrtReleaseSession=E.jc,t._OrtGetInputOutputCount=E.kc,t._OrtGetInputOutputMetadata=E.lc,t._OrtFree=E.mc,t._OrtCreateTensor=E.nc,t._OrtGetTensorData=E.oc,t._OrtReleaseTensor=E.pc,t._OrtCreateRunOptions=E.qc,t._OrtAddRunConfigEntry=E.rc,t._OrtReleaseRunOptions=E.sc,t._OrtCreateBinding=E.tc,t._OrtBindInput=E.uc,t._OrtBindOutput=E.vc,t._OrtClearBoundOutputs=E.wc,t._OrtReleaseBinding=E.xc,t._OrtRunWithBinding=E.yc,t._OrtRun=E.zc,t._OrtEndProfiling=E.Ac,oo=t._OrtGetWebGpuDevice=E.Bc,si=E.Cc,ar=t._free=E.Dc,Ya=t._malloc=E.Ec,Yd=t._wgpuBufferRelease=E.Fc,ep=t._wgpuCreateInstance=E.Gc,tp=E.Hc,rp=E.Ic,ap=E.Jc,np=E.Kc,sp=E.Lc,ip=E.Pc,Hp=E.Zc,op=E._c,_p=E.$c,_o=E.bd,co=E.cd,lo=E.dd,uo=E.ed,rs=E.fd,po=E.gd,cp=E.hd,ho=E.kd,lp=E.ld,up=E.md,dp=E.nd,fo=E.od,pp=E.pd,hp=E.qd,Eo=E.rd,Se=E.sd,as=E.td,fp=E.ud,ce=E.vd,ii=E.wd,le=E.xd,Ep=E.yd,$o=E.zd,$p=E.Ad,mp=E.Bd,Ip=E.Cd,mo=E.Dd,Sp=E.Ed,Lp=E.Fd,Ap=E.Gd,gp=E.Hd,Tp=E.Id,bp=E.Jd,vp=E.Kd,Dp=E.Ld,Cp=E.Md,xp=E.Nd,Np=E.Od,wp=E.Pd,yp=E.Qd,Bp=E.Rd,Mp=E.Td,Pp=E.Ud,Rp=E.Vd,kp=E.Wd,Op=E.Yd,Gp=E.Zd,Fp=E._d,Zp=E.$d,Up=E.ae,Kp=E.oe,Wp=E.pe,Vp=E.qe,jp=E.re,qp=E.se,Xp=E.te,zp=E.ue,Jp=E.ve,Qp=E.we,Yp=E.xe,eh=E.ye,th=E.Ye,rh=E.Ze,ah=E._e,nh=E.$e,d=L,Gr}var p,f=Ct();return t.instantiateWasm?new Promise(E=>{t.instantiateWasm(f,(L,b)=>{E(u(L,b))})}):n?u(new WebAssembly.Instance(d,Ct()),d):(F??=t.locateFile?t.locateFile?t.locateFile("ort-wasm-simd-threaded.asyncify.wasm",c):c+"ort-wasm-simd-threaded.asyncify.wasm":new URL("ort-wasm-simd-threaded.asyncify.wasm",import.meta.url).href,p=await(async function(E){var L=F;if(!l&&!R(L))try{var b=fetch(L,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(b,E)}catch(w){v(`wasm streaming compile failed: ${w}`),v("falling back to ArrayBuffer instantiation")}return(async function(w,P){try{var W=await(async function(Y){if(!l)try{var De=await i(Y);return new Uint8Array(De)}catch{}if(Y==F&&l)Y=new Uint8Array(l);else{if(!H)throw"both async and sync fetching of the wasm failed";Y=H(Y)}return Y})(w);return await WebAssembly.instantiate(W,P)}catch(Y){v(`failed to asynchronously prepare wasm: ${Y}`),oe(Y)}})(L,E)})(f),u(p.instance,p.module))}class at{name="ExitStatus";constructor(p){this.message=`Program terminated with exit(${p})`,this.status=p}}var xt=u=>{u.terminate(),u.onmessage=()=>{}},Ge=[],ve=0,nt=null,hr=u=>{ea.length==0&&(sd(),nd(ea[0]));var p=ea.pop();if(!p)return 6;Yn.push(p),ma[u.Nc]=p,p.Nc=u.Nc;var f={Oc:"run",ge:u.fe,Wc:u.Wc,Nc:u.Nc};return p.postMessage(f,u.Yc),0},Ce=0,ke=(u,p,...f)=>{var E,L=16*f.length,b=le(),w=ii(L),P=w>>>3;for(E of f)typeof E=="bigint"?((A(),M)[P++>>>0]=1n,(A(),M)[P++>>>0]=E):((A(),M)[P++>>>0]=0n,(A(),_e)[P++>>>0]=E);return u=up(u,0,L,w,p),ce(b),u};function qa(u){if(n)return ke(0,1,u);if(h=u,!(0<Ce)){for(var p of Yn)xt(p);for(p of ea)xt(p);ea=[],Yn=[],ma={},C=!0}o(0,new at(u))}function Qn(u){if(n)return ke(1,0,u);VH(u)}var VH=u=>{if(h=u,n)throw Qn(u),"unwind";qa(u)},ea=[],Yn=[],td=[],ma={},rd=u=>{var p=u.Nc;delete ma[p],ea.push(u),Yn.splice(Yn.indexOf(u),1),u.Nc=0,dp(p)};function ad(){td.forEach(u=>u())}var nd=u=>new Promise(p=>{u.onmessage=L=>{var b=L.data;if(L=b.Oc,b.Vc&&b.Vc!=si()){var w=ma[b.Vc];w?w.postMessage(b,b.Yc):v(`Internal error! Worker sent a message "${L}" to target pthread ${b.Vc}, but that thread no longer exists!`)}else L==="checkMailbox"?Ys():L==="spawnThread"?hr(b):L==="cleanupThread"?Nt(()=>{rd(ma[b.he])}):L==="loaded"?(u.loaded=!0,p(u)):b.target==="setimmediate"?u.postMessage(b):L==="uncaughtException"?u.onerror(b.error):L==="callHandler"?t[b.be](...b.args):L&&v(`worker sent an unknown command ${L}`)},u.onerror=L=>{throw v(`worker sent an error! ${L.filename}:${L.lineno}: ${L.message}`),L};var f,E=[];for(f of[])t.propertyIsEnumerable(f)&&E.push(f);u.postMessage({Oc:"load",ce:E,ie:ta,je:d})});function sd(){var u=new Worker((()=>{let p=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new p("ort.webgpu.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});ea.push(u)}var ta,LL=(u,p)=>{Ce=0,u=mo(u,p),0<Ce?h=u:fo(u)},Js=[],Qs=0,ft=u=>-9007199254740992>u||9007199254740992<u?NaN:Number(u);function AL(u){var p=new jH(u>>>=0);return(A(),j)[p.Qc+12>>>0]==0&&(id(p,!0),Qs--),Hd(p,!1),Js.push(p),mp(u)}var Xa=0,gL=()=>{Se(0,0);var u=Js.pop();Ep(u.Xc),Xa=0};function id(u,p){p=p?1:0,(A(),j)[u.Qc+12>>>0]=p}function Hd(u,p){p=p?1:0,(A(),j)[u.Qc+13>>>0]=p}class jH{constructor(p){this.Xc=p,this.Qc=p-24}}var qH=u=>{var p=Xa;if(!p)return as(0),0;var f=new jH(p);(A(),y)[f.Qc+16>>>2>>>0]=p;var E=(A(),y)[f.Qc+4>>>2>>>0];if(!E)return as(0),p;for(var L of u){if(L===0||L===E)break;if($p(L,E,f.Qc+16))return as(L),p}return as(E),p};function TL(){return qH([])}function bL(u){return qH([u>>>0])}function vL(u,p,f,E){return qH([u>>>0,p>>>0,f>>>0,E>>>0])}var DL=()=>{var u=Js.pop();u||oe("no exception to throw");var p=u.Xc;throw(A(),j)[u.Qc+13>>>0]==0&&(Js.push(u),Hd(u,!0),id(u,!1),Qs++),$o(p),Xa=p};function CL(u,p,f){var E=new jH(u>>>=0);throw p>>>=0,f>>>=0,(A(),y)[E.Qc+16>>>2>>>0]=0,(A(),y)[E.Qc+4>>>2>>>0]=p,(A(),y)[E.Qc+8>>>2>>>0]=f,$o(u),Qs++,Xa=u}var xL=()=>Qs;function od(u,p,f,E){return n?ke(2,1,u,p,f,E):_d(u,p,f,E)}function _d(u,p,f,E){if(u>>>=0,p>>>=0,f>>>=0,E>>>=0,!globalThis.SharedArrayBuffer)return 6;var L=[];return n&&L.length===0?od(u,p,f,E):(u={fe:f,Nc:u,Wc:E,Yc:L},n?(u.Oc="spawnThread",postMessage(u,L),0):hr(u))}function NL(u){throw Xa||=u>>>0,Xa}var cd=globalThis.TextDecoder&&new TextDecoder,ld=(u,p,f,E)=>{if(f=p+f,E)return f;for(;u[p]&&!(p>=f);)++p;return p},ud=(u,p=0,f,E)=>{if(16<(f=ld(u,p>>>=0,f,E))-p&&u.buffer&&cd)return cd.decode(u.buffer instanceof ArrayBuffer?u.subarray(p,f):u.slice(p,f));for(E="";p<f;){var L=u[p++];if(128&L){var b=63&u[p++];if((224&L)==192)E+=String.fromCharCode((31&L)<<6|b);else{var w=63&u[p++];65536>(L=(240&L)==224?(15&L)<<12|b<<6|w:(7&L)<<18|b<<12|w<<6|63&u[p++])?E+=String.fromCharCode(L):(L-=65536,E+=String.fromCharCode(55296|L>>10,56320|1023&L))}}else E+=String.fromCharCode(L)}return E},za=(u,p,f)=>(u>>>=0)?ud((A(),z),u,p,f):"";function dd(u,p,f){return n?ke(3,1,u,p,f):0}function pd(u,p){if(n)return ke(4,1,u,p)}function hd(u,p){if(n)return ke(5,1,u,p)}function fd(u,p,f){if(n)return ke(6,1,u,p,f)}function Ed(u,p,f){return n?ke(7,1,u,p,f):0}function $d(u,p){if(n)return ke(8,1,u,p)}function md(u,p,f){if(n)return ke(9,1,u,p,f)}function Id(u,p,f,E){if(n)return ke(10,1,u,p,f,E)}function Sd(u,p,f,E){if(n)return ke(11,1,u,p,f,E)}function Ld(u,p,f,E){if(n)return ke(12,1,u,p,f,E)}function Ad(u){if(n)return ke(13,1,u)}function gd(u,p){if(n)return ke(14,1,u,p)}function Td(u,p,f){if(n)return ke(15,1,u,p,f)}var wL=()=>oe(""),fr=u=>{u>>>=0;for(var p="";;){var f=(A(),z)[u++>>>0];if(!f)return p;p+=String.fromCharCode(f)}},XH={},zH={},yL={},Ja=class extends Error{constructor(u){super(u),this.name="BindingError"}};function Mr(u,p,f={}){return(function(E,L,b={}){var w=L.name;if(!E)throw new Ja(`type "${w}" must have a positive integer typeid pointer`);if(zH.hasOwnProperty(E)){if(b.de)return;throw new Ja(`Cannot register type '${w}' twice`)}zH[E]=L,delete yL[E],XH.hasOwnProperty(E)&&(L=XH[E],delete XH[E],L.forEach(P=>P()))})(u,p,f)}var bd=(u,p,f)=>{switch(p){case 1:return f?E=>(A(),j)[E>>>0]:E=>(A(),z)[E>>>0];case 2:return f?E=>(A(),X)[E>>>1>>>0]:E=>(A(),q)[E>>>1>>>0];case 4:return f?E=>(A(),G)[E>>>2>>>0]:E=>(A(),y)[E>>>2>>>0];case 8:return f?E=>(A(),M)[E>>>3>>>0]:E=>(A(),k)[E>>>3>>>0];default:throw new TypeError(`invalid integer width (${p}): ${u}`)}};function BL(u,p,f,E,L){u>>>=0,f>>>=0,p=fr(p>>>0);let b=w=>w;if(E=E===0n){let w=8*f;b=P=>BigInt.asUintN(w,P),L=b(L)}Mr(u,{name:p,Mc:b,Sc:(w,P)=>(typeof P=="number"&&(P=BigInt(P)),P),Rc:bd(p,f,!E),Tc:null})}function ML(u,p,f,E){Mr(u>>>=0,{name:p=fr(p>>>0),Mc:function(L){return!!L},Sc:function(L,b){return b?f:E},Rc:function(L){return this.Mc((A(),z)[L>>>0])},Tc:null})}var vd=[],Ia=[0,1,,1,null,1,!0,1,!1,1];function JH(u){9<(u>>>=0)&&--Ia[u+1]==0&&(Ia[u]=void 0,vd.push(u))}var zt=u=>{if(!u)throw new Ja(`Cannot use deleted val. handle = ${u}`);return Ia[u]},rr=u=>{switch(u){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let p=vd.pop()||Ia.length;return Ia[p]=u,Ia[p+1]=1,p}};function QH(u){return this.Mc((A(),y)[u>>>2>>>0])}var PL={name:"emscripten::val",Mc:u=>{var p=zt(u);return JH(u),p},Sc:(u,p)=>rr(p),Rc:QH,Tc:null};function RL(u){return Mr(u>>>0,PL)}var kL=(u,p)=>{switch(p){case 4:return function(f){return this.Mc((A(),Q)[f>>>2>>>0])};case 8:return function(f){return this.Mc((A(),_e)[f>>>3>>>0])};default:throw new TypeError(`invalid float width (${p}): ${u}`)}};function OL(u,p,f){f>>>=0,Mr(u>>>=0,{name:p=fr(p>>>0),Mc:E=>E,Sc:(E,L)=>L,Rc:kL(p,f),Tc:null})}function GL(u,p,f,E,L){u>>>=0,f>>>=0,p=fr(p>>>0);let b=P=>P;if(E===0){var w=32-8*f;b=P=>P<<w>>>w,L=b(L)}Mr(u,{name:p,Mc:b,Sc:(P,W)=>W,Rc:bd(p,f,E!==0),Tc:null})}function FL(u,p,f){function E(b){var w=(A(),y)[b>>>2>>>0];return b=(A(),y)[b+4>>>2>>>0],new L((A(),j).buffer,b,w)}var L=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][p];Mr(u>>>=0,{name:f=fr(f>>>0),Mc:E,Rc:E},{de:!0})}var Pr=(u,p,f)=>{var E=(A(),z);if(p>>>=0,0<f){var L=p;f=p+f-1;for(var b=0;b<u.length;++b){var w=u.codePointAt(b);if(127>=w){if(p>=f)break;E[p++>>>0]=w}else if(2047>=w){if(p+1>=f)break;E[p++>>>0]=192|w>>6,E[p++>>>0]=128|63&w}else if(65535>=w){if(p+2>=f)break;E[p++>>>0]=224|w>>12,E[p++>>>0]=128|w>>6&63,E[p++>>>0]=128|63&w}else{if(p+3>=f)break;E[p++>>>0]=240|w>>18,E[p++>>>0]=128|w>>12&63,E[p++>>>0]=128|w>>6&63,E[p++>>>0]=128|63&w,b++}}E[p>>>0]=0,u=p-L}else u=0;return u},Rr=u=>{for(var p=0,f=0;f<u.length;++f){var E=u.charCodeAt(f);127>=E?p++:2047>=E?p+=2:55296<=E&&57343>=E?(p+=4,++f):p+=3}return p};function ZL(u,p){Mr(u>>>=0,{name:p=fr(p>>>0),Mc(f){var E=(A(),y)[f>>>2>>>0];return E=za(f+4,E,!0),ar(f),E},Sc(f,E){E instanceof ArrayBuffer&&(E=new Uint8Array(E));var L=typeof E=="string";if(!(L||ArrayBuffer.isView(E)&&E.BYTES_PER_ELEMENT==1))throw new Ja("Cannot pass non-string to std::string");var b=L?Rr(E):E.length,w=Ya(4+b+1),P=w+4;return(A(),y)[w>>>2>>>0]=b,L?Pr(E,P,b+1):(A(),z).set(E,P>>>0),f!==null&&f.push(ar,w),w},Rc:QH,Tc(f){ar(f)}})}var Dd=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,UL=(u,p,f)=>{if(u>>>=1,16<(p=ld((A(),q),u,p/2,f))-u&&Dd)return Dd.decode((A(),q).slice(u,p));for(f="";u<p;++u){var E=(A(),q)[u>>>0];f+=String.fromCharCode(E)}return f},KL=(u,p,f)=>{if(f??=2147483647,2>f)return 0;var E=p;f=(f-=2)<2*u.length?f/2:u.length;for(var L=0;L<f;++L){var b=u.charCodeAt(L);(A(),X)[p>>>1>>>0]=b,p+=2}return(A(),X)[p>>>1>>>0]=0,p-E},WL=u=>2*u.length,VL=(u,p,f)=>{var E="";u>>>=2;for(var L=0;!(L>=p/4);L++){var b=(A(),y)[u+L>>>0];if(!b&&!f)break;E+=String.fromCodePoint(b)}return E},jL=(u,p,f)=>{if(p>>>=0,f??=2147483647,4>f)return 0;var E=p;f=E+f-4;for(var L=0;L<u.length;++L){var b=u.codePointAt(L);if(65535<b&&L++,(A(),G)[p>>>2>>>0]=b,(p+=4)+4>f)break}return(A(),G)[p>>>2>>>0]=0,p-E},qL=u=>{for(var p=0,f=0;f<u.length;++f)65535<u.codePointAt(f)&&f++,p+=4;return p};function XL(u,p,f){if(u>>>=0,p>>>=0,f=fr(f>>>=0),p===2)var E=UL,L=KL,b=WL;else E=VL,L=jL,b=qL;Mr(u,{name:f,Mc:w=>{var P=(A(),y)[w>>>2>>>0];return P=E(w+4,P*p,!0),ar(w),P},Sc:(w,P)=>{if(typeof P!="string")throw new Ja(`Cannot pass non-string to C++ string type ${f}`);var W=b(P),Y=Ya(4+W+p);return(A(),y)[Y>>>2>>>0]=W/p,L(P,Y+4,W+p),w!==null&&w.push(ar,Y),Y},Rc:QH,Tc(w){ar(w)}})}function zL(u,p){Mr(u>>>=0,{ee:!0,name:p=fr(p>>>0),Mc:()=>{},Sc:()=>{}})}function JL(u){ho(u>>>0,!a,1,!r,131072,!1),ad()}var Nt=u=>{if(!C)try{if(u(),!(0<Ce))try{n?si()&&fo(h):VH(h)}catch(p){p instanceof at||p=="unwind"||o(0,p)}}catch(p){p instanceof at||p=="unwind"||o(0,p)}},QL=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function YH(u){u>>>=0,QL||(Atomics.waitAsync((A(),G),u>>>2,u).value.then(Ys),u+=128,Atomics.store((A(),G),u>>>2,1))}var Ys=()=>Nt(()=>{var u=si();u&&(YH(u),hp())});function YL(u,p){(u>>>=0)==p>>>0?setTimeout(Ys):n?postMessage({Vc:u,Oc:"checkMailbox"}):(u=ma[u])&&u.postMessage({Oc:"checkMailbox"})}var eo=[];function eA(u,p,f,E,L){for(p>>>=0,L>>>=0,eo.length=0,f=L>>>3,E=L+E>>>3;f<E;){var b;b=(A(),M)[f++>>>0]?(A(),M)[f++>>>0]:(A(),_e)[f++>>>0],eo.push(b)}return(p?Io[p]:kg[u])(...eo)}var tA=()=>{Ce=0};function rA(u){u>>>=0,n?postMessage({Oc:"cleanupThread",he:u}):rd(ma[u])}function aA(u){}var ei=u=>{try{u()}catch(p){oe(p)}};function nA(u){var p=(...f)=>{ti.push(u);try{return u(...f)}finally{C||(ti.pop(),Er&&ra===1&&ti.length===0&&(ra=0,Ce+=1,ei(rh),typeof Fibers<"u"&&Fibers.Be()))}};return Nd.set(u,p),p}var ra=0,Er=null,Cd=0,ti=[],to=new Map,xd=new Map,Nd=new Map,sA=0,ro=null,iA=[],wd=u=>(function(p){if(!C){if(ra===0){var f=!1,E=!1;p((L=0)=>{if(!C&&(Cd=L,f=!0,E)){ra=2,ei(()=>ah(Er)),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.resume(),L=!1;try{var b=(function(){var W=(A(),G)[Er+8>>>2>>>0];return W=xd.get(W),W=Nd.get(W),--Ce,W()})()}catch(W){b=W,L=!0}var w=!1;if(!Er){var P=ro;P&&(ro=null,(L?P.reject:P.resolve)(b),w=!0)}if(L&&!w)throw b}}),E=!0,f||(ra=1,Er=(function(){var L=Ya(65548),b=L+12;if((A(),y)[L>>>2>>>0]=b,(A(),y)[L+4>>>2>>>0]=b+65536,b=ti[0],!to.has(b)){var w=sA++;to.set(b,w),xd.set(w,b)}return b=to.get(b),(A(),G)[L+8>>>2>>>0]=b,L})(),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.pause(),ei(()=>th(Er)))}else ra===2?(ra=0,ei(nh),ar(Er),Er=null,iA.forEach(Nt)):oe(`invalid state: ${ra}`);return Cd}})(p=>{u().then(p)});function HA(u){return u>>>=0,wd(async()=>{var p=await zt(u);return rr(p)})}var ao=[],oA=u=>{var p=ao.length;return ao.push(u),p},_A=(u,p)=>{for(var f=Array(u),E=0;E<u;++E){var L=E,b=(A(),y)[p+4*E>>>2>>>0],w=zH[b];if(w===void 0)throw u=`parameter ${E}`,b=Jd(b),p=fr(b),ar(b),new Ja(`${u} has unknown type ${p}`);f[L]=w}return f},cA=(u,p,f)=>{var E=[];return u=u(E,f),E.length&&((A(),y)[p>>>2>>>0]=rr(E)),u},lA={},ri=u=>{var p=lA[u];return p===void 0?fr(u):p};function uA(u,p,f){var[E,...L]=_A(u,p>>>0);p=E.Sc.bind(E);var b=L.map(W=>W.Rc.bind(W));u--;var w={toValue:zt};switch(u=b.map((W,Y)=>{var De=`argFromPtr${Y}`;return w[De]=W,`${De}(args${Y?"+"+8*Y:""})`}),f){case 0:var P="toValue(handle)";break;case 2:P="new (toValue(handle))";break;case 3:P="";break;case 1:w.getStringOrSymbol=ri,P="toValue(handle)[getStringOrSymbol(methodName)]"}return P+=`(${u})`,E.ee||(w.toReturnWire=p,w.emval_returnValue=cA,P=`return emval_returnValue(toReturnWire, destructorsRef, ${P})`),P=`return function (handle, methodName, destructorsRef, args) {
|
|
12
|
+
${P}
|
|
13
|
+
}`,f=new Function(Object.keys(w),P)(...Object.values(w)),P=`methodCaller<(${L.map(W=>W.name)}) => ${E.name}>`,oA(Object.defineProperty(f,"name",{value:P}))}function dA(u,p){return p>>>=0,(u=zt(u>>>0))==zt(p)}function pA(u){return(u>>>=0)?(u=ri(u),rr(globalThis[u])):rr(globalThis)}function hA(u){return u=ri(u>>>0),rr(t[u])}function fA(u,p){return p>>>=0,u=zt(u>>>0),p=zt(p),rr(u[p])}function EA(u){9<(u>>>=0)&&(Ia[u+1]+=1)}function yd(u,p,f,E,L){return ao[u>>>0](p>>>0,f>>>0,E>>>0,L>>>0)}function $A(u,p,f,E,L){return yd(u>>>0,p>>>0,f>>>0,E>>>0,L>>>0)}function mA(){return rr([])}function IA(u){u=zt(u>>>0);for(var p=Array(u.length),f=0;f<u.length;f++)p[f]=u[f];return rr(p)}function SA(u){return rr(ri(u>>>0))}function LA(){return rr({})}function AA(u){for(var p=zt(u>>>=0);p.length;){var f=p.pop();p.pop()(f)}JH(u)}function gA(u,p,f){p>>>=0,f>>>=0,u=zt(u>>>0),p=zt(p),f=zt(f),u[p]=f}function TA(u,p){u=ft(u),p>>>=0,u=new Date(1e3*u),(A(),G)[p>>>2>>>0]=u.getUTCSeconds(),(A(),G)[p+4>>>2>>>0]=u.getUTCMinutes(),(A(),G)[p+8>>>2>>>0]=u.getUTCHours(),(A(),G)[p+12>>>2>>>0]=u.getUTCDate(),(A(),G)[p+16>>>2>>>0]=u.getUTCMonth(),(A(),G)[p+20>>>2>>>0]=u.getUTCFullYear()-1900,(A(),G)[p+24>>>2>>>0]=u.getUTCDay(),u=(u.getTime()-Date.UTC(u.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(A(),G)[p+28>>>2>>>0]=u}var Bd=u=>u%4==0&&(u%100!=0||u%400==0),Md=[0,31,60,91,121,152,182,213,244,274,305,335],Pd=[0,31,59,90,120,151,181,212,243,273,304,334];function bA(u,p){u=ft(u),p>>>=0,u=new Date(1e3*u),(A(),G)[p>>>2>>>0]=u.getSeconds(),(A(),G)[p+4>>>2>>>0]=u.getMinutes(),(A(),G)[p+8>>>2>>>0]=u.getHours(),(A(),G)[p+12>>>2>>>0]=u.getDate(),(A(),G)[p+16>>>2>>>0]=u.getMonth(),(A(),G)[p+20>>>2>>>0]=u.getFullYear()-1900,(A(),G)[p+24>>>2>>>0]=u.getDay();var f=(Bd(u.getFullYear())?Md:Pd)[u.getMonth()]+u.getDate()-1|0;(A(),G)[p+28>>>2>>>0]=f,(A(),G)[p+36>>>2>>>0]=-60*u.getTimezoneOffset(),f=new Date(u.getFullYear(),6,1).getTimezoneOffset();var E=new Date(u.getFullYear(),0,1).getTimezoneOffset();u=0|(f!=E&&u.getTimezoneOffset()==Math.min(E,f)),(A(),G)[p+32>>>2>>>0]=u}function vA(u){u>>>=0;var p=new Date((A(),G)[u+20>>>2>>>0]+1900,(A(),G)[u+16>>>2>>>0],(A(),G)[u+12>>>2>>>0],(A(),G)[u+8>>>2>>>0],(A(),G)[u+4>>>2>>>0],(A(),G)[u>>>2>>>0],0),f=(A(),G)[u+32>>>2>>>0],E=p.getTimezoneOffset(),L=new Date(p.getFullYear(),6,1).getTimezoneOffset(),b=new Date(p.getFullYear(),0,1).getTimezoneOffset(),w=Math.min(b,L);return 0>f?(A(),G)[u+32>>>2>>>0]=+(L!=b&&w==E):0<f!=(w==E)&&(L=Math.max(b,L),p.setTime(p.getTime()+6e4*((0<f?w:L)-E))),(A(),G)[u+24>>>2>>>0]=p.getDay(),f=(Bd(p.getFullYear())?Md:Pd)[p.getMonth()]+p.getDate()-1|0,(A(),G)[u+28>>>2>>>0]=f,(A(),G)[u>>>2>>>0]=p.getSeconds(),(A(),G)[u+4>>>2>>>0]=p.getMinutes(),(A(),G)[u+8>>>2>>>0]=p.getHours(),(A(),G)[u+12>>>2>>>0]=p.getDate(),(A(),G)[u+16>>>2>>>0]=p.getMonth(),(A(),G)[u+20>>>2>>>0]=p.getYear(),u=p.getTime(),BigInt(isNaN(u)?-1:u/1e3)}function Rd(u,p,f,E,L,b,w){return n?ke(16,1,u,p,f,E,L,b,w):-52}function kd(u,p,f,E,L,b){if(n)return ke(17,1,u,p,f,E,L,b)}var es={},DA=()=>performance.timeOrigin+performance.now();function Od(u,p){if(n)return ke(18,1,u,p);if(es[u]&&(clearTimeout(es[u].id),delete es[u]),!p)return 0;var f=setTimeout(()=>{delete es[u],Nt(()=>pp(u,performance.timeOrigin+performance.now()))},p);return es[u]={id:f,Ae:p},0}function CA(u,p,f,E){u>>>=0,p>>>=0,f>>>=0,E>>>=0;var L=new Date().getFullYear(),b=new Date(L,0,1).getTimezoneOffset();L=new Date(L,6,1).getTimezoneOffset();var w=Math.max(b,L);(A(),y)[u>>>2>>>0]=60*w,(A(),G)[p>>>2>>>0]=+(b!=L),u=(p=P=>{var W=Math.abs(P);return`UTC${0<=P?"-":"+"}${String(Math.floor(W/60)).padStart(2,"0")}${String(W%60).padStart(2,"0")}`})(b),p=p(L),L<b?(Pr(u,f,17),Pr(p,E,17)):(Pr(u,E,17),Pr(p,f,17))}var xA=()=>Date.now(),NA=1;function wA(u,p,f){if(f>>>=0,!(0<=u&&3>=u))return 28;if(u===0)u=Date.now();else{if(!NA)return 52;u=performance.timeOrigin+performance.now()}return u=Math.round(1e6*u),(A(),M)[f>>>3>>>0]=BigInt(u),0}var no=[],Gd=(u,p)=>{no.length=0;for(var f;f=(A(),z)[u++>>>0];){var E=f!=105;p+=(E&=f!=112)&&p%8?4:0,no.push(f==112?(A(),y)[p>>>2>>>0]:f==106?(A(),M)[p>>>3>>>0]:f==105?(A(),G)[p>>>2>>>0]:(A(),_e)[p>>>3>>>0]),p+=E?8:4}return no};function yA(u,p,f){return u>>>=0,p=Gd(p>>>0,f>>>0),Io[u](...p)}function BA(u,p,f){return u>>>=0,p=Gd(p>>>0,f>>>0),Io[u](...p)}var MA=()=>{};function PA(u,p){return v(za(u>>>0,p>>>0))}var RA=()=>{throw Ce+=1,"unwind"};function kA(){return 4294901760}var OA=()=>1,GA=()=>navigator.hardwareConcurrency;function FA(u){u>>>=0;var p=(A(),z).length;if(u<=p||4294901760<u)return!1;for(var f=1;4>=f;f*=2){var E=p*(1+.2/f);E=Math.min(E,u+100663296);e:{E=(Math.min(4294901760,65536*Math.ceil(Math.max(u,E)/65536))-ta.buffer.byteLength+65535)/65536|0;try{ta.grow(E),Ie();var L=1;break e}catch{}L=void 0}if(L)return!0}return!1}var $r=u=>{var p=Rr(u)+1,f=ii(p);return Pr(u,f,p),f},so=(u,p)=>{(A(),y)[u>>>2>>>0]=p;var f=(A(),y)[u>>>2>>>0];(A(),y)[u+4>>>2>>>0]=(p-f)/4294967296},ts=u=>(A(),y)[u>>>2>>>0]+4294967296*(A(),G)[u+4>>>2>>>0],Et=[],ZA=(u,p)=>{Et[u>>>0]=p},kr=[],ai=[],Qa=(u,p)=>{ai[u]=new Promise(f=>p.finally(()=>f(u)))},se=u=>{if(u)return Et[u>>>0]},UA=(u,p)=>{for(u=(A(),y)[u>>>2>>>0];u;u=(A(),y)[u>>>2>>>0])p[(A(),G)[u+4>>>2>>>0]](u)},ni=(u,p,f)=>{(A(),y)[u>>>2>>>0]=p,(A(),y)[u+4>>>2>>>0]=f},Fd=u=>{var p=(A(),y)[u>>>2>>>0];return u=(A(),y)[u+4>>>2>>>0],za(p,u)},Or=u=>{var p=(A(),y)[u>>>2>>>0];return u=(A(),y)[u+4>>>2>>>0],p?za(p,u):u===0?"":void 0},KA=u=>{var p=Or(u+4),f=(f=(A(),y)[u+12>>>2>>>0])?se(f):"auto";if(u+=16){var E=se((A(),y)[u+4>>>2>>>0]),L=(A(),y)[u+16>>>2>>>0],b=(A(),y)[u+20>>>2>>>0];if(L){for(var w={},P=0;P<L;++P){var W=b+24*P;w[Fd(W+4)]=(A(),_e)[W+16>>>3>>>0]}L=w}else L=void 0;u={module:E,constants:L,entryPoint:Or(u+8)}}else u=void 0;return{label:p,layout:f,compute:u}},Zd=(u,p)=>{function f(E,L){E=u[E],(A(),y)[p+L>>>2>>>0]=E}f("maxTextureDimension1D",4),f("maxTextureDimension2D",8),f("maxTextureDimension3D",12),f("maxTextureArrayLayers",16),f("maxBindGroups",20),f("maxBindGroupsPlusVertexBuffers",24),f("maxBindingsPerBindGroup",28),f("maxDynamicUniformBuffersPerPipelineLayout",32),f("maxDynamicStorageBuffersPerPipelineLayout",36),f("maxSampledTexturesPerShaderStage",40),f("maxSamplersPerShaderStage",44),f("maxStorageBuffersPerShaderStage",48),f("maxStorageTexturesPerShaderStage",52),f("maxUniformBuffersPerShaderStage",56),f("minUniformBufferOffsetAlignment",80),f("minStorageBufferOffsetAlignment",84),so(p+64,u.maxUniformBufferBindingSize),so(p+72,u.maxStorageBufferBindingSize),f("maxVertexBuffers",88),so(p+96,u.maxBufferSize),f("maxVertexAttributes",104),f("maxVertexBufferArrayStride",108),f("maxInterStageShaderVariables",112),f("maxColorAttachments",116),f("maxColorAttachmentBytesPerSample",120),f("maxComputeWorkgroupStorageSize",124),f("maxComputeInvocationsPerWorkgroup",128),f("maxComputeWorkgroupSizeX",132),f("maxComputeWorkgroupSizeY",136),f("maxComputeWorkgroupSizeZ",140),f("maxComputeWorkgroupsPerDimension",144),u.ze!==void 0&&f("maxImmediateSize",148)},WA=[,"validation","out-of-memory","internal"],VA=[,"compatibility","core"],Ud={1:"core-features-and-limits",2:"depth-clip-control",3:"depth32float-stencil8",4:"texture-compression-bc",5:"texture-compression-bc-sliced-3d",6:"texture-compression-etc2",7:"texture-compression-astc",8:"texture-compression-astc-sliced-3d",9:"timestamp-query",10:"indirect-first-instance",11:"shader-f16",12:"rg11b10ufloat-renderable",13:"bgra8unorm-storage",14:"float32-filterable",15:"float32-blendable",16:"clip-distances",17:"dual-source-blending",18:"subgroups",19:"texture-formats-tier1",20:"texture-formats-tier2",21:"primitive-index",22:"texture-component-swizzle",327692:"chromium-experimental-unorm16-texture-formats",327729:"chromium-experimental-multi-draw-indirect"},jA=[,"low-power","high-performance"],qA=[,"occlusion","timestamp"],XA={undefined:1,unknown:1,destroyed:2};function zA(u,p,f,E,L,b){p=ft(p),f=ft(f),E>>>=0,L>>>=0,b>>>=0;var w=se(u>>>0);if(u={},b){var P=(A(),y)[b+12>>>2>>>0];if(P){var W=(A(),y)[b+16>>>2>>>0];u.requiredFeatures=Array.from((A(),y).subarray(W>>>2>>>0,W+4*P>>>2>>>0),He=>Ud[He])}var Y=(A(),y)[b+20>>>2>>>0];if(Y){let He=function(wt,lt,Sa=!1){lt=Y+lt,(lt=(A(),y)[lt>>>2>>>0])==4294967295||Sa&<==0||(Fe[wt]=lt)},ct=function(wt,lt){lt=Y+lt;var Sa=(A(),y)[lt>>>2>>>0],ST=(A(),y)[lt+4>>>2>>>0];Sa==4294967295&&ST==4294967295||(Fe[wt]=ts(lt))};var De=He,Ne=ct,Fe={};He("maxTextureDimension1D",4),He("maxTextureDimension2D",8),He("maxTextureDimension3D",12),He("maxTextureArrayLayers",16),He("maxBindGroups",20),He("maxBindGroupsPlusVertexBuffers",24),He("maxDynamicUniformBuffersPerPipelineLayout",32),He("maxDynamicStorageBuffersPerPipelineLayout",36),He("maxSampledTexturesPerShaderStage",40),He("maxSamplersPerShaderStage",44),He("maxStorageBuffersPerShaderStage",48),He("maxStorageTexturesPerShaderStage",52),He("maxUniformBuffersPerShaderStage",56),He("minUniformBufferOffsetAlignment",80),He("minStorageBufferOffsetAlignment",84),ct("maxUniformBufferBindingSize",64),ct("maxStorageBufferBindingSize",72),He("maxVertexBuffers",88),ct("maxBufferSize",96),He("maxVertexAttributes",104),He("maxVertexBufferArrayStride",108),He("maxInterStageShaderVariables",112),He("maxColorAttachments",116),He("maxColorAttachmentBytesPerSample",120),He("maxComputeWorkgroupStorageSize",124),He("maxComputeInvocationsPerWorkgroup",128),He("maxComputeWorkgroupSizeX",132),He("maxComputeWorkgroupSizeY",136),He("maxComputeWorkgroupSizeZ",140),He("maxComputeWorkgroupsPerDimension",144),He("maxImmediateSize",148,!0),u.requiredLimits=Fe}(P=(A(),y)[b+24>>>2>>>0])&&(P={label:Or(P+4)},u.defaultQueue=P),u.label=Or(b+4)}Ce+=1,Qa(p,w.requestDevice(u).then(He=>{--Ce,Nt(()=>{Et[L>>>0]=He.queue,Et[E>>>0]=He,Ce+=1,Qa(f,He.lost.then(ct=>{Nt(()=>{He.onuncapturederror=()=>{};var wt=le(),lt=$r(ct.message);co(f,XA[ct.reason],lt),ce(wt)}),--Ce})),He.onuncapturederror=ct=>{var wt=5;ct.error instanceof GPUValidationError?wt=2:ct.error instanceof GPUOutOfMemoryError?wt=3:ct.error instanceof GPUInternalError&&(wt=4);var lt=le();ct=$r(ct.error.message),cp(E,wt,ct),ce(lt)},"adapterInfo"in He||(He.adapterInfo=w.info),po(p,1,E,0)})},He=>{--Ce,Nt(()=>{var ct=le(),wt=$r(He.message);po(p,3,E,wt),f&&co(f,4,wt),ce(ct)})}))}function JA(u){var p=se(u>>>=0),f=kr[u];if(f){for(var E=0;E<f.length;++E)f[E]();delete kr[u]}p.destroy()}function QA(u,p,f){f>>>=0;var E=se(u>>>=0);f==4294967295&&(f=void 0);try{var L=E.getMappedRange(p>>>0,f)}catch{return 0}var b=Eo(16,L.byteLength);return(A(),z).set(new Uint8Array(L),b>>>0),kr[u].push(()=>ar(b)),b}function YA(u,p,f){f>>>=0;var E=se(u>>>=0);f==4294967295&&(f=void 0);try{var L=E.getMappedRange(p>>>0,f)}catch{return 0}var b=Eo(16,L.byteLength);return(A(),z).fill(0,b,L.byteLength),kr[u].push(()=>{new Uint8Array(L).set((A(),z).subarray(b>>>0,b+L.byteLength>>>0)),ar(b)}),b}function eg(u,p,f,E,L){u>>>=0,p=ft(p),f=ft(f),L>>>=0;var b=se(u);kr[u]=[],L==4294967295&&(L=void 0),Ce+=1,Qa(p,b.mapAsync(f,E>>>0,L).then(()=>{--Ce,Nt(()=>{lo(p,1,0)})},w=>{--Ce,Nt(()=>{le();var P=$r(w.message);lo(p,w.name==="AbortError"?4:w.name==="OperationError"?3:0,P),delete kr[u]})}))}function tg(u){var p=se(u>>>=0),f=kr[u];if(f){for(var E=0;E<f.length;++E)f[E]();delete kr[u],p.unmap()}}function rg(u){delete Et[u>>>0]}function ag(u,p,f){u>>>=0,p>>>=0,f>>>=0;var E=!!(A(),y)[p+32>>>2>>>0];p={label:Or(p+4),usage:(A(),y)[p+16>>>2>>>0],size:ts(p+24),mappedAtCreation:E},u=se(u);try{var L=u.createBuffer(p)}catch{return!1}return Et[f>>>0]=L,E&&(kr[f]=[]),!0}function ng(u,p,f,E){u>>>=0,p=ft(p),E>>>=0,f=KA(f>>>0),u=se(u),Ce+=1,Qa(p,u.createComputePipelineAsync(f).then(L=>{--Ce,Nt(()=>{Et[E>>>0]=L,_o(p,1,E,0)})},L=>{--Ce,Nt(()=>{var b=le(),w=$r(L.message);_o(p,L.reason==="validation"?3:L.reason==="internal"?4:0,E,w),ce(b)})}))}function sg(u,p,f){u>>>=0,p>>>=0,f>>>=0;var E=(A(),y)[p>>>2>>>0],L=(A(),G)[E+4>>>2>>>0];p={label:Or(p+4),code:""},L===2&&(p.code=Fd(E+8)),u=se(u).createShaderModule(p),Et[f>>>0]=u}var ig=u=>{(u=se(u)).onuncapturederror=null,u.destroy()};function Hg(u,p){p=ft(p),u=se(u>>>0),Ce+=1,Qa(p,u.popErrorScope().then(f=>{--Ce,Nt(()=>{var E=5;f?f instanceof GPUValidationError?E=2:f instanceof GPUOutOfMemoryError?E=3:f instanceof GPUInternalError&&(E=4):E=1;var L=le(),b=f?$r(f.message):0;uo(p,1,E,b),ce(L)})},f=>{--Ce,Nt(()=>{var E=le(),L=$r(f.message);uo(p,1,5,L),ce(E)})}))}function og(u,p,f,E){if(p=ft(p),E>>>=0,f>>>=0){var L={featureLevel:VA[(A(),G)[f+4>>>2>>>0]],powerPreference:jA[(A(),G)[f+8>>>2>>>0]],forceFallbackAdapter:!!(A(),y)[f+12>>>2>>>0]};(u=(A(),y)[f>>>2>>>0])!==0&&(A(),L.De=!!(A(),y)[u+8>>>2>>>0])}"gpu"in navigator?(Ce+=1,Qa(p,navigator.gpu.requestAdapter(L).then(b=>{--Ce,Nt(()=>{if(b)Et[E>>>0]=b,rs(p,1,E,0);else{var w=le(),P=$r("WebGPU not available on this browser (requestAdapter returned null)");rs(p,3,E,P),ce(w)}})},b=>{--Ce,Nt(()=>{var w=le(),P=$r(b.message);rs(p,4,E,P),ce(w)})}))):(L=le(),u=$r("WebGPU not available on this browser (navigator.gpu is not available)"),rs(p,3,E,u),ce(L))}function _g(u,p,f){return u>>>=0,p>>>=0,f>>>=0,wd(async()=>{var E=[];if(f){var L=(A(),G)[f>>>2>>>0];E.length=p+1,E[p]=new Promise(P=>setTimeout(P,L,0))}else E.length=p;for(var b=0;b<p;++b){var w=ts(u+8*b);if(!(w in ai))return w;E[b]=ai[w]}return E=await Promise.race(E),delete ai[E],E})}var io,Ho={},Kd=()=>{if(!io){var u,p={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(u in Ho)Ho[u]===void 0?delete p[u]:p[u]=Ho[u];var f=[];for(u in p)f.push(`${u}=${p[u]}`);io=f}return io};function Wd(u,p){if(n)return ke(19,1,u,p);u>>>=0,p>>>=0;var f,E=0,L=0;for(f of Kd()){var b=p+E;(A(),y)[u+L>>>2>>>0]=b,E+=Pr(f,b,1/0)+1,L+=4}return 0}function Vd(u,p){if(n)return ke(20,1,u,p);u>>>=0,p>>>=0;var f=Kd();for(var E of((A(),y)[u>>>2>>>0]=f.length,u=0,f))u+=Rr(E)+1;return(A(),y)[p>>>2>>>0]=u,0}function jd(u){return n?ke(21,1,u):52}function qd(u,p,f,E){return n?ke(22,1,u,p,f,E):52}function Xd(u,p,f,E){return n?ke(23,1,u,p,f,E):70}var cg=[null,[],[]];function zd(u,p,f,E){if(n)return ke(24,1,u,p,f,E);p>>>=0,f>>>=0,E>>>=0;for(var L=0,b=0;b<f;b++){var w=(A(),y)[p>>>2>>>0],P=(A(),y)[p+4>>>2>>>0];p+=8;for(var W=0;W<P;W++){var Y=u,De=(A(),z)[w+W>>>0],Ne=cg[Y];De===0||De===10?((Y===1?D:v)(ud(Ne)),Ne.length=0):Ne.push(De)}L+=P}return(A(),y)[E>>>2>>>0]=L,0}function lg(u){return u>>>0}function ug(u,p){return Zd(se(u>>>0).limits,p>>>0),1}function dg(u,p){return se(u>>>0).features.has(Ud[p])}function pg(u){return BigInt(se(u>>>0).size)}function hg(u){return BigInt(se(u>>>0).usage)}function fg(u,p){if(u>>>=0,p>>>=0){var f=Or(p+4);f={label:f,timestampWrites:p=(p=(A(),y)[p+12>>>2>>>0])!==0?{querySet:se((A(),y)[p+4>>>2>>>0]),beginningOfPassWriteIndex:(A(),y)[p+8>>>2>>>0],endOfPassWriteIndex:(A(),y)[p+12>>>2>>>0]}:void 0}}return p=se(u),u=sp(0),f=p.beginComputePass(f),Et[u>>>0]=f,u}function Eg(u,p,f,E){f=ft(f),(E=ft(E))==-1&&(E=void 0),(u=se(u>>>0)).clearBuffer(se(p>>>0),f,E)}function $g(u,p,f,E,L,b){f=ft(f),L=ft(L),b=ft(b),se(u>>>0).copyBufferToBuffer(se(p>>>0),f,se(E>>>0),L,b)}function mg(u){var p=se(u>>>0);return u=ap(0),p=p.finish(),Et[u>>>0]=p,u}function Ig(u,p,f,E,L,b){b=ft(b),se(u>>>0).resolveQuerySet(se(p>>>0),f,E,se(L>>>0),b)}function Sg(u,p,f,E){se(u>>>0).dispatchWorkgroups(p,f,E)}function Lg(u,p,f){f=ft(f),se(u>>>0).dispatchWorkgroupsIndirect(se(p>>>0),f)}function Ag(u){se(u>>>0).end()}function gg(u,p,f,E,L){E>>>=0,L>>>=0,u=se(u>>>0),f=se(f>>>0),E==0?u.setBindGroup(p,f):u.setBindGroup(p,f,(A(),y),L>>>2,E)}function Tg(u,p){se(u>>>0).setPipeline(se(p>>>0))}function bg(u,p,f){se(u>>>0).Ce(se(p>>>0),f)}function vg(u,p){var f=se(u>>>0);return u=rp(0),p=f.getBindGroupLayout(p),Et[u>>>0]=p,u}function Dg(u,p){function f(L){var b=(A(),y)[L+8>>>2>>>0],w=(A(),y)[L+32>>>2>>>0],P=(A(),y)[L+36>>>2>>>0],W=0;return UA(L,{327681:Y=>{W=(A(),y)[Y+8>>>2>>>0]}}),b?((w=ts(L+24))==-1&&(w=void 0),b={buffer:se(b),offset:ts(L+16),size:w}):b=se(w||P||W),{binding:(A(),y)[L+4>>>2>>>0],resource:b}}u>>>=0,p={label:Or(4+(p>>>=0)),layout:se((A(),y)[p+12>>>2>>>0]),entries:(function(L,b){for(var w=[],P=0;P<L;++P)w.push(f(b+40*P));return w})((A(),y)[p+16>>>2>>>0],(A(),y)[p+20>>>2>>>0])},u=se(u);var E=tp(0);return ZA(E,u.createBindGroup(p)),E}function Cg(u,p){var f;return u>>>=0,(p>>>=0)&&(f={label:Or(p+4)}),p=se(u),u=np(0),f=p.createCommandEncoder(f),Et[u>>>0]=f,u}function xg(u,p){u>>>=0,p>>>=0,p={type:qA[(A(),G)[p+12>>>2>>>0]],count:(A(),y)[p+16>>>2>>>0]};var f=se(u);return u=ip(0),p=f.createQuerySet(p),Et[u>>>0]=p,u}function Ng(u,p){u=se(u>>>0).adapterInfo,p>>>=0,(A(),y)[p+52>>>2>>>0]=u.subgroupMinSize,(A(),y)[p+56>>>2>>>0]=u.subgroupMaxSize;var f=u.vendor+u.architecture+u.device+u.description,E=Rr(f)+1,L=Ya(E);return L&&Pr(f,L,E),f=L,E=Rr(u.vendor),ni(p+4,f,E),f+=E,E=Rr(u.architecture),ni(p+12,f,E),f+=E,E=Rr(u.device),ni(p+20,f,E),ni(p+28,f+E,Rr(u.description)),(A(),G)[p+36>>>2>>>0]=2,u=u.isFallbackAdapter?3:4,(A(),G)[p+40>>>2>>>0]=u,(A(),y)[p+44>>>2>>>0]=0,(A(),y)[p+48>>>2>>>0]=0,1}var wg={"core-features-and-limits":1,"depth-clip-control":2,"depth32float-stencil8":3,"texture-compression-bc":4,"texture-compression-bc-sliced-3d":5,"texture-compression-etc2":6,"texture-compression-astc":7,"texture-compression-astc-sliced-3d":8,"timestamp-query":9,"indirect-first-instance":10,"shader-f16":11,"rg11b10ufloat-renderable":12,"bgra8unorm-storage":13,"float32-filterable":14,"float32-blendable":15,"clip-distances":16,"dual-source-blending":17,subgroups:18,"texture-formats-tier1":19,"texture-formats-tier2":20,"primitive-index":21,"texture-component-swizzle":22,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729};function yg(u,p){p>>>=0;var f=se(u>>>0);u=Ya(4*f.features.size);var E=0,L=0;for(let b of f.features)0<=(f=wg[b])&&((A(),G)[u+E>>>2>>>0]=f,E+=4,L++);(A(),y)[p+4>>>2>>>0]=u,(A(),y)[p>>>2>>>0]=L}function Bg(u,p){return Zd(se(u>>>0).limits,p>>>0),1}function Mg(u,p){se(u>>>0).pushErrorScope(WA[p])}function Pg(u,p,f){p>>>=0,f>>>=0,u=se(u>>>0),p=Array.from((A(),G).subarray(f>>>2>>>0,f+4*p>>>2>>>0),E=>se(E)),u.submit(p)}function Rg(u,p,f,E,L){f=ft(f),E>>>=0,L>>>=0,u=se(u>>>0),p=se(p>>>0),E=(A(),z).subarray(E>>>0,E+L>>>0),u.writeBuffer(p,f,E,0,L)}n||(function(){for(var u=t.numThreads-1;u--;)sd();Ge.push(async()=>{var p=(async function(){if(!n)return Promise.all(ea.map(nd))})();ve++,await p,--ve==0&&nt&&(p=nt,nt=null,p())})})(),n||(ta=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),Ie()),t.wasmBinary&&(l=t.wasmBinary),t.stackSave=()=>le(),t.stackRestore=u=>ce(u),t.stackAlloc=u=>ii(u),t.setValue=function(u,p,f="i8"){switch(f.endsWith("*")&&(f="*"),f){case"i1":case"i8":(A(),j)[u>>>0]=p;break;case"i16":(A(),X)[u>>>1>>>0]=p;break;case"i32":(A(),G)[u>>>2>>>0]=p;break;case"i64":(A(),M)[u>>>3>>>0]=BigInt(p);break;case"float":(A(),Q)[u>>>2>>>0]=p;break;case"double":(A(),_e)[u>>>3>>>0]=p;break;case"*":(A(),y)[u>>>2>>>0]=p;break;default:oe(`invalid type for setValue: ${f}`)}},t.getValue=function(u,p="i8"){switch(p.endsWith("*")&&(p="*"),p){case"i1":case"i8":return(A(),j)[u>>>0];case"i16":return(A(),X)[u>>>1>>>0];case"i32":return(A(),G)[u>>>2>>>0];case"i64":return(A(),M)[u>>>3>>>0];case"float":return(A(),Q)[u>>>2>>>0];case"double":return(A(),_e)[u>>>3>>>0];case"*":return(A(),y)[u>>>2>>>0];default:oe(`invalid type for getValue: ${p}`)}},t.UTF8ToString=za,t.stringToUTF8=Pr,t.lengthBytesUTF8=Rr;var Jd,Qd,oo,si,ar,Ya,Yd,ep,tp,rp,ap,np,sp,ip,Hp,op,_p,_o,co,lo,uo,rs,po,cp,ho,lp,up,dp,fo,pp,hp,Eo,Se,as,fp,ce,ii,le,Ep,$o,$p,mp,Ip,mo,Sp,Lp,Ap,gp,Tp,bp,vp,Dp,Cp,xp,Np,wp,yp,Bp,Mp,Pp,Rp,kp,Op,Gp,Fp,Zp,Up,Kp,Wp,Vp,jp,qp,Xp,zp,Jp,Qp,Yp,eh,th,rh,ah,nh,Gr,kg=[qa,Qn,od,dd,pd,hd,fd,Ed,$d,md,Id,Sd,Ld,Ad,gd,Td,Rd,kd,Od,Wd,Vd,jd,qd,Xd,zd],Io={970348:(u,p,f,E,L)=>{if(t===void 0||!t.Uc)return 1;if((u=za(Number(u>>>0))).startsWith("./")&&(u=u.substring(2)),!(u=t.Uc.get(u)))return 2;if(p=Number(p>>>0),f=Number(f>>>0),E=Number(E>>>0),p+f>u.byteLength)return 3;try{let b=u.subarray(p,p+f);switch(L){case 0:(A(),z).set(b,E>>>0);break;case 1:t.ad?t.ad(E,b):t.ne(E,b);break;default:return 4}return 0}catch{return 4}},971172:(u,p,f)=>{t.Sd(u,(A(),z).subarray(p>>>0,p+f>>>0))},971236:()=>t.le(),971278:u=>{t.jd(u)},971315:()=>typeof wasmOffsetConverter<"u"};function Og(u,p,f,E){var L=le();try{return Dp(u,p,f,E)}catch(b){if(ce(L),b!==b+0)throw b;Se(1,0)}}function Gg(u,p,f){var E=le();try{return Tp(u,p,f)}catch(L){if(ce(E),L!==L+0)throw L;Se(1,0)}}function Fg(u){var p=le();try{Sp(u)}catch(f){if(ce(p),f!==f+0)throw f;Se(1,0)}}function Zg(u,p){var f=le();try{return mo(u,p)}catch(E){if(ce(f),E!==E+0)throw E;Se(1,0)}}function Ug(u,p,f){var E=le();try{Ip(u,p,f)}catch(L){if(ce(E),L!==L+0)throw L;Se(1,0)}}function Kg(u,p){var f=le();try{Cp(u,p)}catch(E){if(ce(f),E!==E+0)throw E;Se(1,0)}}function Wg(u,p,f,E,L,b,w){var P=le();try{return gp(u,p,f,E,L,b,w)}catch(W){if(ce(P),W!==W+0)throw W;Se(1,0)}}function Vg(u,p,f,E,L,b){var w=le();try{Lp(u,p,f,E,L,b)}catch(P){if(ce(w),P!==P+0)throw P;Se(1,0)}}function jg(u,p,f,E){var L=le();try{vp(u,p,f,E)}catch(b){if(ce(L),b!==b+0)throw b;Se(1,0)}}function qg(u,p,f,E,L,b,w){var P=le();try{Np(u,p,f,E,L,b,w)}catch(W){if(ce(P),W!==W+0)throw W;Se(1,0)}}function Xg(u,p,f,E,L,b,w){var P=le();try{wp(u,p,f,E,L,b,w)}catch(W){if(ce(P),W!==W+0)throw W;Se(1,0)}}function zg(u,p,f,E,L,b,w,P){var W=le();try{Fp(u,p,f,E,L,b,w,P)}catch(Y){if(ce(W),Y!==Y+0)throw Y;Se(1,0)}}function Jg(u,p,f,E,L,b,w,P,W,Y,De,Ne){var Fe=le();try{yp(u,p,f,E,L,b,w,P,W,Y,De,Ne)}catch(He){if(ce(Fe),He!==He+0)throw He;Se(1,0)}}function Qg(u,p,f,E,L){var b=le();try{return xp(u,p,f,E,L)}catch(w){if(ce(b),w!==w+0)throw w;Se(1,0)}}function Yg(u,p,f,E,L){var b=le();try{Ap(u,p,f,E,L)}catch(w){if(ce(b),w!==w+0)throw w;Se(1,0)}}function eT(u,p,f,E,L,b,w,P){var W=le();try{bp(u,p,f,E,L,b,w,P)}catch(Y){if(ce(W),Y!==Y+0)throw Y;Se(1,0)}}function tT(u){var p=le();try{return Zp(u)}catch(f){if(ce(p),f!==f+0)throw f;Se(1,0)}}function rT(u,p,f){var E=le();try{return Up(u,p,f)}catch(L){if(ce(E),L!==L+0)throw L;Se(1,0)}}function aT(u,p){var f=le();try{return eh(u,p)}catch(E){if(ce(f),E!==E+0)throw E;return Se(1,0),0n}}function nT(u){var p=le();try{return Bp(u)}catch(f){if(ce(p),f!==f+0)throw f;return Se(1,0),0n}}function sT(u,p,f,E){var L=le();try{return Kp(u,p,f,E)}catch(b){if(ce(L),b!==b+0)throw b;Se(1,0)}}function iT(u,p,f,E,L){var b=le();try{return Wp(u,p,f,E,L)}catch(w){if(ce(b),w!==w+0)throw w;Se(1,0)}}function HT(u,p,f,E,L,b){var w=le();try{return Vp(u,p,f,E,L,b)}catch(P){if(ce(w),P!==P+0)throw P;Se(1,0)}}function oT(u,p,f,E,L,b){var w=le();try{return Op(u,p,f,E,L,b)}catch(P){if(ce(w),P!==P+0)throw P;Se(1,0)}}function _T(u,p,f,E,L,b){var w=le();try{return jp(u,p,f,E,L,b)}catch(P){if(ce(w),P!==P+0)throw P;Se(1,0)}}function cT(u,p,f,E,L,b,w,P){var W=le();try{return Gp(u,p,f,E,L,b,w,P)}catch(Y){if(ce(W),Y!==Y+0)throw Y;Se(1,0)}}function lT(u,p,f,E,L){var b=le();try{return qp(u,p,f,E,L)}catch(w){if(ce(b),w!==w+0)throw w;return Se(1,0),0n}}function uT(u,p,f,E){var L=le();try{return Xp(u,p,f,E)}catch(b){if(ce(L),b!==b+0)throw b;Se(1,0)}}function dT(u,p,f,E){var L=le();try{return zp(u,p,f,E)}catch(b){if(ce(L),b!==b+0)throw b;Se(1,0)}}function pT(u,p,f,E,L,b,w,P,W,Y,De,Ne){var Fe=le();try{return Jp(u,p,f,E,L,b,w,P,W,Y,De,Ne)}catch(He){if(ce(Fe),He!==He+0)throw He;Se(1,0)}}function hT(u,p,f,E,L,b,w,P,W,Y,De){var Ne=le();try{Qp(u,p,f,E,L,b,w,P,W,Y,De)}catch(Fe){if(ce(Ne),Fe!==Fe+0)throw Fe;Se(1,0)}}function fT(u,p,f,E,L,b,w,P,W,Y,De,Ne,Fe,He,ct,wt){var lt=le();try{Yp(u,p,f,E,L,b,w,P,W,Y,De,Ne,Fe,He,ct,wt)}catch(Sa){if(ce(lt),Sa!==Sa+0)throw Sa;Se(1,0)}}function ET(u,p,f){var E=le();try{return Pp(u,p,f)}catch(L){if(ce(E),L!==L+0)throw L;return Se(1,0),0n}}function $T(u,p,f){var E=le();try{return Mp(u,p,f)}catch(L){if(ce(E),L!==L+0)throw L;Se(1,0)}}function mT(u,p,f){var E=le();try{return Rp(u,p,f)}catch(L){if(ce(E),L!==L+0)throw L;Se(1,0)}}function IT(u,p,f,E){var L=le();try{kp(u,p,f,E)}catch(b){if(ce(L),b!==b+0)throw b;Se(1,0)}}function Hi(){if(0<ve)nt=Hi;else if(n)$?.(t),Ze();else{for(var u=Ge;0<u.length;)u.shift()(t);0<ve?nt=Hi:(t.calledRun=!0,C||(Ze(),$?.(t)))}}return n||(Gr=await Ue(),Hi()),t.PTR_SIZE=4,t.webgpuInit=u=>{let p=new WeakMap,f,E,L=1;t.webgpuRegisterDevice=P=>{if(E!==void 0)throw Error("another WebGPU EP inference session is being created.");if(P){var W=p.get(P);if(!W){let Y=((De,Ne=0)=>{var Fe=_p(Ne);return Ne=op(Ne,Fe),Et[Fe>>>0]=De.queue,Et[Ne>>>0]=De,Ne})(P,W=ep(0));W=[L++,W,Y],p.set(P,W)}return f=P,E=W[0],W}f=void 0,E=0};let b=new Map;t.webgpuOnCreateSession=P=>{if(E!==void 0){var W=E;if(E=void 0,P){let Y=oo(W);b.set(P,Y),W===0&&u(f??se(Y))}f=void 0}},t.webgpuOnReleaseSession=P=>{b.delete(P)};let w=Symbol("gpuBufferMetadata");t.webgpuRegisterBuffer=(P,W,Y)=>{if(Y)return P[w]=[Y,NaN],Y;if(Y=P[w])return Y[1]++,Y[0];if((W=b.get(W))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");return W=((De,Ne=0)=>(De.mapState==="unmapped"||oe(),Ne=Hp(Ne),Et[Ne>>>0]=De,Ne))(P,W),P[w]=[W,1],W},t.webgpuUnregisterBuffer=P=>{let W=P[w];if(!W)throw Error("Buffer is not registered");W[1]--,W[1]===0&&(Yd(W[0]),delete P[w])},t.webgpuGetBuffer=P=>se(P),t.webgpuCreateDownloader=(P,W,Y)=>{if((Y=b.get(Y))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");let De=se(Y),Ne=16*Math.ceil(Number(W)/16);return async()=>{let Fe=De.createBuffer({size:Ne,usage:9});try{let He=De.createCommandEncoder();return He.copyBufferToBuffer(P,0,Fe,0,Ne),De.queue.submit([He.finish()]),await Fe.mapAsync(GPUMapMode.READ),Fe.getMappedRange().slice(0,W)}finally{Fe.destroy()}}},t.ad=(P,W)=>{var Y=W.buffer;let De=W.byteOffset,Ne=W.byteLength;if(W=16*Math.ceil(Number(Ne)/16),P=se(P),!f){var Fe=oo(E);f=se(Fe)}let He=(Fe=f.createBuffer({mappedAtCreation:!0,size:W,usage:6})).getMappedRange();new Uint8Array(He).set(new Uint8Array(Y,De,Ne)),Fe.unmap(),(Y=f.createCommandEncoder()).copyBufferToBuffer(Fe,0,P,0,W),f.queue.submit([Y.finish()]),Fe.destroy()}},t.webnnInit=u=>{let p=u[0];[t.le,t.jd,t.webnnEnsureTensor,t.Sd,t.webnnDownloadTensor,t.ke,t.webnnEnableTraceEvent]=u.slice(1),t.webnnReleaseTensorId=t.jd,t.webnnUploadTensor=t.Sd,t.webnnRegisterMLContext=t.ke,t.webnnOnRunStart=f=>p.onRunStart(f),t.webnnOnRunEnd=p.onRunEnd.bind(p),t.webnnOnReleaseSession=f=>{p.onReleaseSession(f)},t.webnnCreateMLTensorDownloader=(f,E)=>p.createMLTensorDownloader(f,E),t.webnnRegisterMLTensor=(f,E,L,b)=>p.registerMLTensor(f,E,L,b),t.webnnCreateMLContext=f=>p.createMLContext(f),t.webnnRegisterMLConstant=(f,E,L,b,w,P)=>p.registerMLConstant(f,E,L,b,w,t.Uc,P),t.webnnRegisterGraphInput=p.registerGraphInput.bind(p),t.webnnIsGraphInput=p.isGraphInput.bind(p),t.webnnRegisterGraphOutput=p.registerGraphOutput.bind(p),t.webnnIsGraphOutput=p.isGraphOutput.bind(p),t.webnnCreateTemporaryTensor=p.createTemporaryTensor.bind(p),t.webnnIsGraphInputOutputTypeSupported=p.isGraphInputOutputTypeSupported.bind(p)},J?t:new Promise((u,p)=>{$=u,m=p})}var k0,X1,VB=Ae(()=>{"use strict";k0=q1,X1=globalThis.self?.name?.startsWith("em-pthread"),X1&&q1()}),$_,V_,z1,Wt,O0,Zi,J1,Q1,m_,Y1,I_,G0,S_,F0,Ec=Ae(()=>{"use strict";fc(),$_=typeof location>"u"?void 0:location.origin,V_=import.meta.url>"file:"&&import.meta.url<"file;",z1=()=>{if(V_){let e=URL;return new URL(new e("ort.webgpu.bundle.min.mjs",import.meta.url).href,$_).href}return import.meta.url},Wt=z1(),O0=()=>{if(Wt&&!Wt.startsWith("blob:"))return Wt.substring(0,Wt.lastIndexOf("/")+1)},Zi=(e,t)=>{try{let r=t??Wt;return(r?new URL(e,r):new URL(e)).origin===$_}catch{return!1}},J1=(e,t)=>{let r=t??Wt;try{return(r?new URL(e,r):new URL(e)).href}catch{return}},Q1=(e,t)=>`${t??"./"}${e}`,m_=async e=>{let t=await(await fetch(e,{credentials:"same-origin"})).blob();return URL.createObjectURL(t)},Y1=async e=>(await import(e)).default,I_=(WB(),oH(M0)).default,G0=async()=>{if(!Wt)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Zi(Wt))return[void 0,I_()];let e=await m_(Wt);return[e,I_(e)]},S_=(VB(),oH(R0)).default,F0=async(e,t,r,a)=>{let n=S_&&!(e||t);if(n)if(Wt)n=Zi(Wt)||a&&!r;else if(a&&!r)n=!0;else throw new Error("cannot determine the script source URL.");if(n)return[void 0,S_];{let s="ort-wasm-simd-threaded.asyncify.mjs",i=e??J1(s,t),H=r&&i&&!Zi(i,t),o=H?await m_(i):i??Q1(s,t);return[H?o:void 0,await Y1(o)]}}}),L_,Ui,$s,A_,e$,t$,r$,$c,Re,Wa=Ae(()=>{"use strict";Ec(),Ui=!1,$s=!1,A_=!1,e$=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},t$=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},r$=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},$c=async e=>{if(Ui)return Promise.resolve();if($s)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(A_)throw new Error("previous call to 'initializeWebAssembly()' failed.");$s=!0;let t=e.initTimeout,r=e.numThreads;if(e.simd!==!1){if(e.simd==="relaxed"){if(!r$())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!t$())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let a=e$();r>1&&!a&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+r+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),e.numThreads=r=1);let n=e.wasmPaths,s=typeof n=="string"?n:void 0,i=n?.mjs,H=i?.href??i,o=n?.wasm,_=o?.href??o,c=e.wasmBinary,[l,d]=await F0(H,s,r>1,!!c||!!_),h=!1,$=[];if(t>0&&$.push(new Promise(m=>{setTimeout(()=>{h=!0,m()},t)})),$.push(new Promise((m,S)=>{let I={numThreads:r};if(c)I.wasmBinary=c,I.locateFile=T=>T;else if(_||s)I.locateFile=T=>_??s+T;else if(H&&H.indexOf("blob:")!==0)I.locateFile=T=>new URL(T,H).href;else if(l){let T=O0();T&&(I.locateFile=D=>T+D)}d(I).then(T=>{$s=!1,Ui=!0,L_=T,m(),l&&URL.revokeObjectURL(l)},T=>{$s=!1,A_=!0,S(T)})})),await Promise.race($),h)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},Re=()=>{if(Ui&&L_)return L_;throw new Error("WebAssembly is not initialized yet.")}}),Vt,cH,xe,mc=Ae(()=>{"use strict";Wa(),Vt=(e,t)=>{let r=Re(),a=r.lengthBytesUTF8(e)+1,n=r._malloc(a);return r.stringToUTF8(e,n,a),t.push(n),n},cH=(e,t,r,a)=>{if(typeof e=="object"&&e!==null){if(r.has(e))throw new Error("Circular reference in options");r.add(e)}Object.entries(e).forEach(([n,s])=>{let i=t?t+n:n;if(typeof s=="object")cH(s,i+".",r,a);else if(typeof s=="string"||typeof s=="number")a(i,s.toString());else if(typeof s=="boolean")a(i,s?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof s}`)})},xe=e=>{let t=Re(),r=t.stackSave();try{let a=t.PTR_SIZE,n=t.stackAlloc(2*a);t._OrtGetLastError(n,n+a);let s=Number(t.getValue(n,a===4?"i32":"i64")),i=t.getValue(n+a,"*"),H=i?t.UTF8ToString(i):"";throw new Error(`${e} ERROR_CODE: ${s}, ERROR_MESSAGE: ${H}`)}finally{t.stackRestore(r)}}}),Z0,jB=Ae(()=>{"use strict";Wa(),mc(),Z0=e=>{let t=Re(),r=0,a=[],n=e||{};try{if(e?.logSeverityLevel===void 0)n.logSeverityLevel=2;else if(typeof e.logSeverityLevel!="number"||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)n.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!="number"||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(n.terminate=!1);let s=0;return e?.tag!==void 0&&(s=Vt(e.tag,a)),r=t._OrtCreateRunOptions(n.logSeverityLevel,n.logVerbosityLevel,!!n.terminate,s),r===0&&xe("Can't create run options."),e?.extra!==void 0&&cH(e.extra,"",new WeakSet,(i,H)=>{let o=Vt(i,a),_=Vt(H,a);t._OrtAddRunConfigEntry(r,o,_)!==0&&xe(`Can't set a run config entry: ${i} - ${H}.`)}),[r,a]}catch(s){throw r!==0&&t._OrtReleaseRunOptions(r),a.forEach(i=>t._free(i)),s}}}),a$,n$,s$,Ki,_a,i$,U0,qB=Ae(()=>{"use strict";Wa(),mc(),a$=e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}},n$=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},s$=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some(r=>(typeof r=="string"?r:r.name)==="webgpu")&&(e.enableMemPattern=!1)},Ki=(e,t,r,a)=>{let n=Vt(t,a),s=Vt(r,a);Re()._OrtAddSessionConfigEntry(e,n,s)!==0&&xe(`Can't set a session config entry: ${t} - ${r}.`)},_a=(e,t,r,a)=>{let n=Vt(t,a),s=Vt(r,a);e.push([n,s])},i$=async(e,t,r)=>{let a=t.executionProviders;for(let n of a){let s=typeof n=="string"?n:n.name,i=[];switch(s){case"webnn":if(s="WEBNN",typeof n!="string"){let l=n?.deviceType;l&&Ki(e,"deviceType",l,r)}break;case"webgpu":{s="WebGPU";let l;if(typeof n!="string"){let h=n;if(h.device)if(typeof GPUDevice<"u"&&h.device instanceof GPUDevice)l=h.device;else throw new Error("Invalid GPU device set in WebGPU EP options.");let{enableGraphCapture:$}=t;if(typeof $=="boolean"&&$&&_a(i,"enableGraphCapture","1",r),typeof h.preferredLayout=="string"&&_a(i,"preferredLayout",h.preferredLayout,r),h.forceCpuNodeNames){let m=Array.isArray(h.forceCpuNodeNames)?h.forceCpuNodeNames:[h.forceCpuNodeNames];_a(i,"forceCpuNodeNames",m.join(`
|
|
14
|
+
`),r)}h.validationMode&&_a(i,"validationMode",h.validationMode,r)}let d=Re().webgpuRegisterDevice(l);if(d){let[h,$,m]=d;_a(i,"deviceId",h.toString(),r),_a(i,"webgpuInstance",$.toString(),r),_a(i,"webgpuDevice",m.toString(),r)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${s}`)}let H=Vt(s,r),o=i.length,_=0,c=0;if(o>0){_=Re()._malloc(o*Re().PTR_SIZE),r.push(_),c=Re()._malloc(o*Re().PTR_SIZE),r.push(c);for(let l=0;l<o;l++)Re().setValue(_+l*Re().PTR_SIZE,i[l][0],"*"),Re().setValue(c+l*Re().PTR_SIZE,i[l][1],"*")}await Re()._OrtAppendExecutionProvider(e,H,_,c,o)!==0&&xe(`Can't append execution provider: ${s}.`)}},U0=async e=>{let t=Re(),r=0,a=[],n=e||{};s$(n);try{let s=a$(n.graphOptimizationLevel??"all"),i=n$(n.executionMode??"sequential"),H=typeof n.logId=="string"?Vt(n.logId,a):0,o=n.logSeverityLevel??2;if(!Number.isInteger(o)||o<0||o>4)throw new Error(`log severity level is not valid: ${o}`);let _=n.logVerbosityLevel??0;if(!Number.isInteger(_)||_<0||_>4)throw new Error(`log verbosity level is not valid: ${_}`);let c=typeof n.optimizedModelFilePath=="string"?Vt(n.optimizedModelFilePath,a):0;if(r=t._OrtCreateSessionOptions(s,!!n.enableCpuMemArena,!!n.enableMemPattern,i,!!n.enableProfiling,0,H,o,_,c),r===0&&xe("Can't create session options."),n.executionProviders&&await i$(r,n,a),n.enableGraphCapture!==void 0){if(typeof n.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${n.enableGraphCapture}`);Ki(r,"enableGraphCapture",n.enableGraphCapture.toString(),a)}if(n.freeDimensionOverrides)for(let[l,d]of Object.entries(n.freeDimensionOverrides)){if(typeof l!="string")throw new Error(`free dimension override name must be a string: ${l}`);if(typeof d!="number"||!Number.isInteger(d)||d<0)throw new Error(`free dimension override value must be a non-negative integer: ${d}`);let h=Vt(l,a);t._OrtAddFreeDimensionOverride(r,h,d)!==0&&xe(`Can't set a free dimension override: ${l} - ${d}.`)}return n.extra!==void 0&&cH(n.extra,"",new WeakSet,(l,d)=>{Ki(r,l,d,a)}),[r,a]}catch(s){throw r!==0&&t._OrtReleaseSessionOptions(r)!==0&&xe("Can't release session options."),a.forEach(i=>t._free(i)),s}}}),Ra,eH,An,Cs,lH,Ic,Sc,j_,Pn=Ae(()=>{"use strict";Ra=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${e}`)}},eH=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${e}`)}},An=(e,t)=>{let r=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],a=typeof t=="number"?t:t.reduce((n,s)=>n*s,1);return r>0?Math.ceil(a*r):void 0},Cs=e=>{switch(e){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},lH=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}},Ic=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",Sc=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint64"||e==="int8"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",j_=e=>{switch(e){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${e}`)}}}),Lc,K0=Ae(()=>{"use strict";fc(),Lc=async e=>{if(typeof e=="string"){let t=await fetch(e);if(!t.ok)throw new Error(`failed to load external data file: ${e}`);let r=t.headers.get("Content-Length"),a=r?parseInt(r,10):0;if(a<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),s;try{s=new ArrayBuffer(a)}catch(H){if(H instanceof RangeError){let o=Math.ceil(a/65536);s=new WebAssembly.Memory({initial:o,maximum:o}).buffer}else throw H}let i=0;for(;;){let{done:H,value:o}=await n.read();if(H)break;let _=o.byteLength;new Uint8Array(s,i,_).set(o),i+=_}return new Uint8Array(s,0,a)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),W0,XB=Ae(()=>{"use strict";Pn(),W0=(e,t)=>new(Cs(t))(e)}),H$,o$,_$,c$,V0,l$,gt,j0=Ae(()=>{"use strict";Pn(),H$=["V","I","W","E","F"],o$=(e,t)=>{console.log(`[${H$[e]},${new Date().toISOString()}]${t}`)},V0=(e,t)=>{_$=e,c$=t},l$=(e,t)=>{let r=lH(e),a=lH(_$);r>=a&&o$(r,typeof t=="function"?t():t)},gt=(...e)=>{c$&&l$(...e)}}),g_,q_,T_,u$,b_,d$,v_,D_,C_,p$,q0,zB=Ae(()=>{"use strict";Pn(),j0(),g_=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),q_=(e,t)=>{if(t==="int32")return e;let r=g_.get(t);if(!r)throw new Error(`WebNN backend does not support data type: ${t}`);let a=r/8;if(e.byteLength%a!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${a}.`);let n=e.byteLength/a,s=new(Cs(t))(e.buffer,e.byteOffset,n);switch(t){case"int64":case"uint64":{let i=new Int32Array(n);for(let H=0;H<n;H++){let o=s[H];if(o>2147483647n||o<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");i[H]=Number(o)}return new Uint8Array(i.buffer)}case"int8":case"uint8":case"uint32":{if(t==="uint32"&&s.some(H=>H>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let i=Int32Array.from(s,Number);return new Uint8Array(i.buffer)}default:throw new Error(`Unsupported data conversion from ${t} to 'int32'`)}},T_=(e,t)=>{if(t==="int32")return e;if(e.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let r=e.byteLength/4,a=new Int32Array(e.buffer,e.byteOffset,r);switch(t){case"int64":{let n=BigInt64Array.from(a,BigInt);return new Uint8Array(n.buffer)}case"uint64":{if(a.some(s=>s<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let n=BigUint64Array.from(a,BigInt);return new Uint8Array(n.buffer)}case"int8":{if(a.some(s=>s<-128||s>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let n=Int8Array.from(a,Number);return new Uint8Array(n.buffer)}case"uint8":{if(a.some(n=>n<0||n>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(a,Number)}case"uint32":{if(a.some(s=>s<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let n=Uint32Array.from(a,Number);return new Uint8Array(n.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${t}`)}},u$=1,b_=()=>u$++,d$=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),v_=(e,t)=>{let r=g_.get(e);if(!r)throw new Error(`WebNN backend does not support data type: ${e}`);return t.length>0?Math.ceil(t.reduce((a,n)=>a*n)*r/8):0},D_=class{constructor(e){this.isDataConverted=!1;let{sessionId:t,context:r,tensor:a,dataType:n,shape:s,fallbackDataType:i}=e;this.sessionId=t,this.mlContext=r,this.mlTensor=a,this.dataType=n,this.tensorShape=s,this.fallbackDataType=i}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return v_(this.dataType,this.tensorShape)}destroy(){gt("verbose",()=>"[WebNN] TensorWrapper.destroy"),this.mlTensor.destroy()}write(e){this.mlContext.writeTensor(this.mlTensor,e)}async read(e){if(this.fallbackDataType){let t=await this.mlContext.readTensor(this.mlTensor),r=T_(new Uint8Array(t),this.dataType);if(e){(e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).set(r);return}else return r.buffer}else return e?this.mlContext.readTensor(this.mlTensor,e):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(e,t,r){return this.mlContext===e&&this.dataType===t&&this.tensorShape.length===r.length&&this.tensorShape.every((a,n)=>a===r[n])}setIsDataConverted(e){this.isDataConverted=e}},C_=class{constructor(e,t){this.tensorManager=e,this.wrapper=t}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(e,t,r,a){let n=this.tensorManager.getMLContext(e),s=this.tensorManager.getMLOpSupportLimits(e),i;if(!s?.input.dataTypes.includes(t)){if(i=d$.get(t),!i||s?.input.dataTypes.includes(i))throw new Error(`WebNN backend does not support data type: ${t}`);gt("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${t} to ${i}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(n,t,r))return this.wrapper.tensor;if(a){if(this.wrapper.byteLength!==v_(t,r))throw new Error("Unable to copy data to tensor with different size.");this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let H=typeof MLTensorUsage>"u"?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(e,t,r,H,!0,!0,i),a&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(e){let t=e;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType==="int32")t=q_(e,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(e.byteLength===this.wrapper.byteLength){this.wrapper.write(t);return}else gt("verbose",()=>"Data size does not match tensor size. Releasing tensor."),this.releaseTensor()}this.activeUpload?this.activeUpload.set(t):this.activeUpload=new Uint8Array(t)}async download(e){if(this.activeUpload){let t=this.wrapper?.isDataConverted?T_(this.activeUpload,this.wrapper?.type):this.activeUpload;if(e){e instanceof ArrayBuffer?new Uint8Array(e).set(t):new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t);return}else return t.buffer}if(!this.wrapper)throw new Error("Tensor has not been created.");return e?this.wrapper.read(e):this.wrapper.read()}},p$=class{constructor(e){this.backend=e,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(e){let t=this.backend.getMLContext(e);if(!t)throw new Error("MLContext not found for session.");return t}getMLOpSupportLimits(e){return this.backend.getMLOpSupportLimits(e)}reserveTensorId(){let e=b_();return this.tensorTrackersById.set(e,new C_(this)),e}releaseTensorId(e){let t=this.tensorTrackersById.get(e);t&&(this.tensorTrackersById.delete(e),t.tensorWrapper&&this.releaseTensor(t.tensorWrapper))}async ensureTensor(e,t,r,a,n){gt("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${t}, dataType: ${r}, shape: ${a}, copyOld: ${n}}`);let s=this.tensorTrackersById.get(t);if(!s)throw new Error("Tensor not found.");return s.ensureTensor(e,r,a,n)}upload(e,t){let r=this.tensorTrackersById.get(e);if(!r)throw new Error("Tensor not found.");r.upload(t)}async download(e,t){gt("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${e}, dstBuffer: ${t?.byteLength}}`);let r=this.tensorTrackersById.get(e);if(!r)throw new Error("Tensor not found.");return r.download(t)}releaseTensorsForSession(e){for(let t of this.freeTensors)t.sessionId===e&&t.destroy();this.freeTensors=this.freeTensors.filter(t=>t.sessionId!==e)}registerTensor(e,t,r,a){let n=this.getMLContext(e),s=b_(),i=new D_({sessionId:e,context:n,tensor:t,dataType:r,shape:a});return this.tensorTrackersById.set(s,new C_(this,i)),this.externalTensors.add(i),s}async getCachedTensor(e,t,r,a,n,s,i){let H=this.getMLContext(e);for(let[_,c]of this.freeTensors.entries())if(c.canReuseTensor(H,t,r)){gt("verbose",()=>`[WebNN] Reusing tensor {dataType: ${t}, ${i?`fallbackDataType: ${i},`:""} shape: ${r}`);let l=this.freeTensors.splice(_,1)[0];return l.sessionId=e,l}gt("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${t}, ${i?`fallbackDataType: ${i},`:""} shape: ${r}}`);let o=await H.createTensor({dataType:i??t,shape:r,dimensions:r,usage:a,writable:n,readable:s});return new D_({sessionId:e,context:H,tensor:o,dataType:t,shape:r,fallbackDataType:i})}releaseTensor(e){this.externalTensors.has(e)&&this.externalTensors.delete(e),this.freeTensors.push(e)}},q0=(...e)=>new p$(...e)}),X0={};ks(X0,{WebNNBackend:()=>z0});var ms,h$,z0,JB=Ae(()=>{"use strict";Pn(),Wa(),XB(),zB(),j0(),ms=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),h$=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0)return!1;let r=Object.keys(e).sort(),a=Object.keys(t).sort();return r.length===a.length&&r.every((n,s)=>n===a[s]&&e[n]===t[n])},z0=class{constructor(e){this.tensorManager=q0(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,V0(e.logLevel,!!e.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(e){gt("verbose",()=>`[WebNN] onRunStart {sessionId: ${e}}`),this.activeSessionId=e}onRunEnd(e){gt("verbose",()=>`[WebNN] onRunEnd {sessionId: ${e}}`);let t=this.temporarySessionTensorIds.get(e);if(t){for(let r of t)gt("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${r}}`),this.tensorManager.releaseTensorId(r);this.temporarySessionTensorIds.delete(e),this.activeSessionId=void 0}}async createMLContext(e){if(e instanceof GPUDevice){let r=this.mlContextCache.findIndex(a=>a.gpuDevice===e);if(r!==-1)return this.mlContextCache[r].mlContext;{let a=await navigator.ml.createContext(e);return this.mlContextCache.push({gpuDevice:e,mlContext:a}),a}}else if(e===void 0){let r=this.mlContextCache.findIndex(a=>a.options===void 0&&a.gpuDevice===void 0);if(r!==-1)return this.mlContextCache[r].mlContext;{let a=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:a}),a}}let t=this.mlContextCache.findIndex(r=>h$(r.options,e));if(t!==-1)return this.mlContextCache[t].mlContext;{let r=await navigator.ml.createContext(e);return this.mlContextCache.push({options:e,mlContext:r}),r}}registerMLContext(e,t){this.mlContextBySessionId.set(e,t);let r=this.sessionIdsByMLContext.get(t);r||(r=new Set,this.sessionIdsByMLContext.set(t,r)),r.add(e),this.mlOpSupportLimitsBySessionId.has(e)||this.mlOpSupportLimitsBySessionId.set(e,t.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(e,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(e,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(e){this.sessionGraphInputs.delete(e),this.sessionGraphOutputs.delete(e);let t=this.mlContextBySessionId.get(e);if(!t)return;this.tensorManager.releaseTensorsForSession(e),this.mlContextBySessionId.delete(e),this.mlOpSupportLimitsBySessionId.delete(e);let r=this.sessionIdsByMLContext.get(t);if(r.delete(e),r.size===0){this.sessionIdsByMLContext.delete(t);let a=this.mlContextCache.findIndex(n=>n.mlContext===t);a!==-1&&this.mlContextCache.splice(a,1)}}getMLContext(e){return this.mlContextBySessionId.get(e)}getMLOpSupportLimits(e){return this.mlOpSupportLimitsBySessionId.get(e)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(e){gt("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e)}async ensureTensor(e,t,r,a,n){let s=ms.get(r);if(!s)throw new Error(`Unsupported ONNX data type: ${r}`);return this.tensorManager.ensureTensor(e??this.currentSessionId,t,s,a,n)}async createTemporaryTensor(e,t,r){gt("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${t}, shape: ${r}}`);let a=ms.get(t);if(!a)throw new Error(`Unsupported ONNX data type: ${t}`);let n=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(e,n,a,r,!1);let s=this.temporarySessionTensorIds.get(e);return s?s.push(n):this.temporarySessionTensorIds.set(e,[n]),n}uploadTensor(e,t){if(!Re().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");gt("verbose",()=>`[WebNN] uploadTensor {tensorId: ${e}, data: ${t.byteLength}}`),this.tensorManager.upload(e,t)}async downloadTensor(e,t){return this.tensorManager.download(e,t)}createMLTensorDownloader(e,t){return async()=>{let r=await this.tensorManager.download(e);return W0(r,t)}}registerMLTensor(e,t,r,a){let n=ms.get(r);if(!n)throw new Error(`Unsupported ONNX data type: ${r}`);let s=this.tensorManager.registerTensor(e,t,n,a);return gt("verbose",()=>`[WebNN] registerMLTensor {tensor: ${t}, dataType: ${n}, dimensions: ${a}} -> {tensorId: ${s}}`),s}registerMLConstant(e,t,r,a,n,s,i=!1){if(!s)throw new Error("External mounted files are not available.");let H=e;e.startsWith("./")&&(H=e.substring(2));let o=s.get(H);if(!o)throw new Error(`File with name ${H} not found in preloaded files.`);if(t+r>o.byteLength)throw new Error("Out of bounds: data offset and length exceed the external file data size.");let _=o.slice(t,t+r).buffer,c;switch(n.dataType){case"float32":c=new Float32Array(_);break;case"float16":c=typeof Float16Array<"u"&&Float16Array.from?new Float16Array(_):new Uint16Array(_);break;case"int32":c=new Int32Array(_);break;case"uint32":c=new Uint32Array(_);break;case"int64":if(i){let l=q_(new Uint8Array(_),"int64");c=new Int32Array(l.buffer),n.dataType="int32"}else c=new BigInt64Array(_);break;case"uint64":c=new BigUint64Array(_);break;case"int8":c=new Int8Array(_);break;case"int4":case"uint4":case"uint8":c=new Uint8Array(_);break;default:throw new Error(`Unsupported data type: ${n.dataType} in creating WebNN Constant from external data.`)}return gt("verbose",()=>`[WebNN] registerMLConstant {dataType: ${n.dataType}, shape: ${n.shape}}} ${i?"(Note: it was int64 data type and registered to int32 as workaround)":""}`),a.constant(n,c)}registerGraphInput(e){this.temporaryGraphInputs.push(e)}registerGraphOutput(e){this.temporaryGraphOutputs.push(e)}isGraphInput(e,t){let r=this.sessionGraphInputs.get(e);return r?r.includes(t):!1}isGraphOutput(e,t){let r=this.sessionGraphOutputs.get(e);return r?r.includes(t):!1}isGraphInputOutputTypeSupported(e,t,r=!0){let a=ms.get(Ra(t)),n=this.mlOpSupportLimitsBySessionId.get(e);return typeof a>"u"?!1:r?!!n?.input.dataTypes.includes(a):!!n?.output.dataTypes.includes(a)}flush(){}}}),f$,Ac,gc,ca,E$,x_,uH,Tc,bc,N_,vc,Dc,Cc,J0=Ae(()=>{"use strict";Ka(),jB(),qB(),Pn(),Wa(),mc(),K0(),f$=(e,t)=>{Re()._OrtInit(e,t)!==0&&xe("Can't initialize onnxruntime.")},Ac=async e=>{f$(e.wasm.numThreads,lH(e.logLevel))},gc=async(e,t)=>{Re().asyncInit?.();let r=e.webgpu.adapter;if(t==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(r){if(typeof r.limits!="object"||typeof r.features!="object"||typeof r.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let a=e.webgpu.powerPreference;if(a!==void 0&&a!=="low-power"&&a!=="high-performance")throw new Error(`Invalid powerPreference setting: "${a}"`);let n=e.webgpu.forceFallbackAdapter;if(n!==void 0&&typeof n!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${n}"`);if(r=await navigator.gpu.requestAdapter({powerPreference:a,forceFallbackAdapter:n}),!r)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(t==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment");if(t==="webgpu"&&Re().webgpuInit(a=>{e.webgpu.device=a}),t==="webnn"){let a=new(JB(),oH(X0)).WebNNBackend(e);Re().webnnInit([a,()=>a.reserveTensorId(),n=>a.releaseTensorId(n),async(n,s,i,H,o)=>a.ensureTensor(n,s,i,H,o),(n,s)=>{a.uploadTensor(n,s)},async(n,s)=>a.downloadTensor(n,s),(n,s)=>a.registerMLContext(n,s),!!e.trace])}},ca=new Map,E$=e=>{let t=Re(),r=t.stackSave();try{let a=t.PTR_SIZE,n=t.stackAlloc(2*a);t._OrtGetInputOutputCount(e,n,n+a)!==0&&xe("Can't get session input/output count.");let s=a===4?"i32":"i64";return[Number(t.getValue(n,s)),Number(t.getValue(n+a,s))]}finally{t.stackRestore(r)}},x_=(e,t)=>{let r=Re(),a=r.stackSave(),n=0;try{let s=r.PTR_SIZE,i=r.stackAlloc(2*s);r._OrtGetInputOutputMetadata(e,t,i,i+s)!==0&&xe("Can't get session input/output metadata.");let H=Number(r.getValue(i,"*"));n=Number(r.getValue(i+s,"*"));let o=r.HEAP32[n/4];if(o===0)return[H,0];let _=r.HEAPU32[n/4+1],c=[];for(let l=0;l<_;l++){let d=Number(r.getValue(n+8+l*s,"*"));c.push(d!==0?r.UTF8ToString(d):Number(r.getValue(n+8+(l+_)*s,"*")))}return[H,o,c]}finally{r.stackRestore(a),n!==0&&r._OrtFree(n)}},uH=e=>{let t=Re(),r=t._malloc(e.byteLength);if(r===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,r),[r,e.byteLength]},Tc=async(e,t)=>{let r,a,n=Re();Array.isArray(e)?[r,a]=e:e.buffer===n.HEAPU8.buffer?[r,a]=[e.byteOffset,e.byteLength]:[r,a]=uH(e);let s=0,i=0,H=0,o=[],_=[],c=[];try{if([i,o]=await U0(t),t?.externalData&&n.mountExternalData){let v=[];for(let C of t.externalData){let R=typeof C=="string"?C:C.path;v.push(Lc(typeof C=="string"?C:C.data).then(A=>{n.mountExternalData(R,A)}))}await Promise.all(v)}for(let v of t?.executionProviders??[])if((typeof v=="string"?v:v.name)==="webnn"){if(n.shouldTransferToMLTensor=!1,typeof v!="string"){let C=v,R=C?.context,A=C?.gpuDevice,U=C?.deviceType,Z=C?.powerPreference;R?n.currentContext=R:A?n.currentContext=await n.webnnCreateMLContext(A):n.currentContext=await n.webnnCreateMLContext({deviceType:U,powerPreference:Z})}else n.currentContext=await n.webnnCreateMLContext();break}s=await n._OrtCreateSession(r,a,i),n.webgpuOnCreateSession?.(s),s===0&&xe("Can't create a session."),n.jsepOnCreateSession?.(),n.currentContext&&(n.webnnRegisterMLContext(s,n.currentContext),n.currentContext=void 0,n.shouldTransferToMLTensor=!0);let[l,d]=E$(s),h=!!t?.enableGraphCapture,$=[],m=[],S=[],I=[],T=[];for(let v=0;v<l;v++){let[C,R,A]=x_(s,v);C===0&&xe("Can't get an input name."),_.push(C);let U=n.UTF8ToString(C);$.push(U),S.push(R===0?{name:U,isTensor:!1}:{name:U,isTensor:!0,type:eH(R),shape:A})}for(let v=0;v<d;v++){let[C,R,A]=x_(s,v+l);C===0&&xe("Can't get an output name."),c.push(C);let U=n.UTF8ToString(C);m.push(U),I.push(R===0?{name:U,isTensor:!1}:{name:U,isTensor:!0,type:eH(R),shape:A});{if(h&&t?.preferredOutputLocation===void 0){T.push("gpu-buffer");continue}let Z=typeof t?.preferredOutputLocation=="string"?t.preferredOutputLocation:t?.preferredOutputLocation?.[U]??"cpu",j=n.webnnIsGraphOutput;if(Z==="cpu"&&j&&j(s,U)){T.push("ml-tensor-cpu-output");continue}if(Z!=="cpu"&&Z!=="cpu-pinned"&&Z!=="gpu-buffer"&&Z!=="ml-tensor")throw new Error(`Not supported preferred output location: ${Z}.`);if(h&&Z!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${Z}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);T.push(Z)}}let D=null;return T.some(v=>v==="gpu-buffer"||v==="ml-tensor"||v==="ml-tensor-cpu-output")&&(H=n._OrtCreateBinding(s),H===0&&xe("Can't create IO binding."),D={handle:H,outputPreferredLocations:T,outputPreferredLocationsEncoded:T.map(v=>v==="ml-tensor-cpu-output"?"ml-tensor":v).map(v=>j_(v))}),ca.set(s,[s,_,c,D,h,!1]),[s,$,m,S,I]}catch(l){throw _.forEach(d=>n._OrtFree(d)),c.forEach(d=>n._OrtFree(d)),H!==0&&n._OrtReleaseBinding(H)!==0&&xe("Can't release IO binding."),s!==0&&n._OrtReleaseSession(s)!==0&&xe("Can't release session."),l}finally{n._free(r),i!==0&&n._OrtReleaseSessionOptions(i)!==0&&xe("Can't release session options."),o.forEach(l=>n._free(l)),n.unmountExternalData?.()}},bc=e=>{let t=Re(),r=ca.get(e);if(!r)throw new Error(`cannot release session. invalid session id: ${e}`);let[a,n,s,i,H]=r;i&&(H&&t._OrtClearBoundOutputs(i.handle)!==0&&xe("Can't clear bound outputs."),t._OrtReleaseBinding(i.handle)!==0&&xe("Can't release IO binding.")),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),n.forEach(o=>t._OrtFree(o)),s.forEach(o=>t._OrtFree(o)),t._OrtReleaseSession(a)!==0&&xe("Can't release session."),ca.delete(e)},N_=async(e,t,r,a,n,s,i=!1)=>{if(!e){t.push(0);return}let H=Re(),o=H.PTR_SIZE,_=e[0],c=e[1],l=e[3],d=l,h,$;if(_==="string"&&(l==="gpu-buffer"||l==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(i&&l!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${s} when enableGraphCapture is true.`);if(l==="gpu-buffer"){let I=e[2].gpuBuffer;$=An(Ra(_),c);{let T=H.webgpuRegisterBuffer;if(!T)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');h=T(I,a)}}else if(l==="ml-tensor"){let I=e[2].mlTensor;$=An(Ra(_),c);let T=H.webnnRegisterMLTensor;if(!T)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');h=T(a,I,Ra(_),c)}else{let I=e[2];if(Array.isArray(I)){$=o*I.length,h=H._malloc($),r.push(h);for(let T=0;T<I.length;T++){if(typeof I[T]!="string")throw new TypeError(`tensor data at index ${T} is not a string`);H.setValue(h+T*o,Vt(I[T],r),"*")}}else{let T=H.webnnIsGraphInput,D=H.webnnIsGraphOutput;if(_!=="string"&&T&&D){let v=H.UTF8ToString(n);if(T(a,v)||D(a,v)){let C=Ra(_);$=An(C,c),d="ml-tensor";let R=H.webnnCreateTemporaryTensor,A=H.webnnUploadTensor;if(!R||!A)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let U=await R(a,C,c);A(U,new Uint8Array(I.buffer,I.byteOffset,I.byteLength)),h=U}else $=I.byteLength,h=H._malloc($),r.push(h),H.HEAPU8.set(new Uint8Array(I.buffer,I.byteOffset,$),h)}else $=I.byteLength,h=H._malloc($),r.push(h),H.HEAPU8.set(new Uint8Array(I.buffer,I.byteOffset,$),h)}}let m=H.stackSave(),S=H.stackAlloc(4*c.length);try{c.forEach((T,D)=>H.setValue(S+D*o,T,o===4?"i32":"i64"));let I=H._OrtCreateTensor(Ra(_),h,$,S,c.length,j_(d));I===0&&xe(`Can't create tensor for input/output. session=${a}, index=${s}.`),t.push(I)}finally{H.stackRestore(m)}},vc=async(e,t,r,a,n,s)=>{let i=Re(),H=i.PTR_SIZE,o=ca.get(e);if(!o)throw new Error(`cannot run inference. invalid session id: ${e}`);let _=o[0],c=o[1],l=o[2],d=o[3],h=o[4],$=o[5],m=t.length,S=a.length,I=0,T=[],D=[],v=[],C=[],R=[],A=i.stackSave(),U=i.stackAlloc(m*H),Z=i.stackAlloc(m*H),j=i.stackAlloc(S*H),z=i.stackAlloc(S*H);try{[I,T]=Z0(s),ha("wasm prepareInputOutputTensor");for(let y=0;y<m;y++)await N_(r[y],D,C,e,c[t[y]],t[y],h);for(let y=0;y<S;y++)await N_(n[y],v,C,e,l[a[y]],m+a[y],h);fa("wasm prepareInputOutputTensor");for(let y=0;y<m;y++)i.setValue(U+y*H,D[y],"*"),i.setValue(Z+y*H,c[t[y]],"*");for(let y=0;y<S;y++)i.setValue(j+y*H,v[y],"*"),i.setValue(z+y*H,l[a[y]],"*");if(d&&!$){let{handle:y,outputPreferredLocations:Q,outputPreferredLocationsEncoded:_e}=d;if(c.length!==m)throw new Error(`input count from feeds (${m}) is expected to be always equal to model's input count (${c.length}).`);ha("wasm bindInputsOutputs");for(let M=0;M<m;M++){let k=t[M];await i._OrtBindInput(y,c[k],D[M])!==0&&xe(`Can't bind input[${M}] for session=${e}.`)}for(let M=0;M<S;M++){let k=a[M];n[M]?.[3]?(R.push(v[M]),i._OrtBindOutput(y,l[k],v[M],0)!==0&&xe(`Can't bind pre-allocated output[${M}] for session=${e}.`)):i._OrtBindOutput(y,l[k],0,_e[k])!==0&&xe(`Can't bind output[${M}] to ${Q[M]} for session=${e}.`)}fa("wasm bindInputsOutputs"),ca.set(e,[_,c,l,d,h,!0])}i.jsepOnRunStart?.(_),i.webnnOnRunStart?.(_);let X;d?X=await i._OrtRunWithBinding(_,d.handle,S,j,I):X=await i._OrtRun(_,Z,U,m,z,S,j,I),X!==0&&xe("failed to call OrtRun().");let q=[],G=[];ha("wasm ProcessOutputTensor");for(let y=0;y<S;y++){let Q=Number(i.getValue(j+y*H,"*"));if(Q===v[y]||R.includes(v[y])){q.push(n[y]),Q!==v[y]&&i._OrtReleaseTensor(Q)!==0&&xe("Can't release tensor.");continue}let _e=i.stackSave(),M=i.stackAlloc(4*H),k=!1,F,J=0;try{i._OrtGetTensorData(Q,M,M+H,M+2*H,M+3*H)!==0&&xe(`Can't access output tensor data on index ${y}.`);let Ie=H===4?"i32":"i64",Ze=Number(i.getValue(M,Ie));J=i.getValue(M+H,"*");let oe=i.getValue(M+H*2,"*"),Ct=Number(i.getValue(M+H*3,Ie)),Ue=[];for(let Ge=0;Ge<Ct;Ge++)Ue.push(Number(i.getValue(oe+Ge*H,Ie)));i._OrtFree(oe)!==0&&xe("Can't free memory for tensor dims.");let at=Ue.reduce((Ge,ve)=>Ge*ve,1);F=eH(Ze);let xt=d?.outputPreferredLocations[a[y]];if(F==="string"){if(xt==="gpu-buffer"||xt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Ge=[];for(let ve=0;ve<at;ve++){let nt=i.getValue(J+ve*H,"*"),hr=i.getValue(J+(ve+1)*H,"*"),Ce=ve===at-1?void 0:hr-nt;Ge.push(i.UTF8ToString(nt,Ce))}q.push([F,Ue,Ge,"cpu"])}else if(xt==="gpu-buffer"&&at>0){let Ge=i.webgpuGetBuffer;if(!Ge)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let ve=Ge(J),nt=An(Ze,at);if(nt===void 0||!Ic(F))throw new Error(`Unsupported data type: ${F}`);k=!0;{i.webgpuRegisterBuffer(ve,e,J);let hr=i.webgpuCreateDownloader(ve,nt,e);q.push([F,Ue,{gpuBuffer:ve,download:async()=>{let Ce=await hr();return new(Cs(F))(Ce)},dispose:()=>{i._OrtReleaseTensor(Q)!==0&&xe("Can't release tensor.")}},"gpu-buffer"])}}else if(xt==="ml-tensor"&&at>0){let Ge=i.webnnEnsureTensor,ve=i.webnnIsGraphInputOutputTypeSupported;if(!Ge||!ve)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(An(Ze,at)===void 0||!Sc(F))throw new Error(`Unsupported data type: ${F}`);if(!ve(e,F,!1))throw new Error(`preferredLocation "ml-tensor" for ${F} output is not supported by current WebNN Context.`);let nt=await Ge(e,J,Ze,Ue,!1);k=!0,q.push([F,Ue,{mlTensor:nt,download:i.webnnCreateMLTensorDownloader(J,F),dispose:()=>{i.webnnReleaseTensorId(J),i._OrtReleaseTensor(Q)}},"ml-tensor"])}else if(xt==="ml-tensor-cpu-output"&&at>0){let Ge=i.webnnCreateMLTensorDownloader(J,F)(),ve=q.length;k=!0,G.push((async()=>{let nt=[ve,await Ge];return i.webnnReleaseTensorId(J),i._OrtReleaseTensor(Q),nt})()),q.push([F,Ue,[],"cpu"])}else{let Ge=Cs(F),ve=new Ge(at);new Uint8Array(ve.buffer,ve.byteOffset,ve.byteLength).set(i.HEAPU8.subarray(J,J+ve.byteLength)),q.push([F,Ue,ve,"cpu"])}}finally{i.stackRestore(_e),F==="string"&&J&&i._free(J),k||i._OrtReleaseTensor(Q)}}d&&!h&&(i._OrtClearBoundOutputs(d.handle)!==0&&xe("Can't clear bound outputs."),ca.set(e,[_,c,l,d,h,!1]));for(let[y,Q]of await Promise.all(G))q[y][2]=Q;return fa("wasm ProcessOutputTensor"),q}finally{i.webnnOnRunEnd?.(_),i.stackRestore(A),r.forEach(X=>{X&&X[3]==="gpu-buffer"&&i.webgpuUnregisterBuffer(X[2].gpuBuffer)}),n.forEach(X=>{X&&X[3]==="gpu-buffer"&&i.webgpuUnregisterBuffer(X[2].gpuBuffer)}),D.forEach(X=>i._OrtReleaseTensor(X)),v.forEach(X=>i._OrtReleaseTensor(X)),C.forEach(X=>i._free(X)),I!==0&&i._OrtReleaseRunOptions(I),T.forEach(X=>i._free(X))}},Dc=e=>{let t=Re(),r=ca.get(e);if(!r)throw new Error("invalid session id");let a=r[0],n=t._OrtEndProfiling(a);n===0&&xe("Can't get an profile file name."),t._OrtFree(n)},Cc=e=>{let t=[];for(let r of e){let a=r[2];!Array.isArray(a)&&"buffer"in a&&t.push(a.buffer)}return t}}),la,Qt,mn,Is,Ss,Wi,w_,Vi,Na,wa,$$,Q0,Y0,em,tm,rm,am,nm,sm=Ae(()=>{"use strict";Ka(),J0(),Wa(),Ec(),la=()=>!!qe.wasm.proxy&&typeof document<"u",mn=!1,Is=!1,Ss=!1,Vi=new Map,Na=(e,t)=>{let r=Vi.get(e);r?r.push(t):Vi.set(e,[t])},wa=()=>{if(mn||!Is||Ss||!Qt)throw new Error("worker not ready")},$$=e=>{switch(e.data.type){case"init-wasm":mn=!1,e.data.err?(Ss=!0,w_[1](e.data.err)):(Is=!0,w_[0]()),Wi&&(URL.revokeObjectURL(Wi),Wi=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let t=Vi.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}default:}},Q0=async()=>{if(!Is){if(mn)throw new Error("multiple calls to 'initWasm()' detected.");if(Ss)throw new Error("previous call to 'initWasm()' failed.");if(mn=!0,la())return new Promise((e,t)=>{Qt?.terminate(),G0().then(([r,a])=>{try{Qt=a,Qt.onerror=s=>t(s),Qt.onmessage=$$,w_=[e,t];let n={type:"init-wasm",in:qe};!n.in.wasm.wasmPaths&&(r||V_)&&(n.in.wasm.wasmPaths={wasm:new URL("ort-wasm-simd-threaded.asyncify.wasm",import.meta.url).href}),Qt.postMessage(n),Wi=r}catch(n){t(n)}},t)});try{await $c(qe.wasm),await Ac(qe),Is=!0}catch(e){throw Ss=!0,e}finally{mn=!1}}},Y0=async e=>{if(la())return wa(),new Promise((t,r)=>{Na("init-ep",[t,r]);let a={type:"init-ep",in:{epName:e,env:qe}};Qt.postMessage(a)});await gc(qe,e)},em=async e=>la()?(wa(),new Promise((t,r)=>{Na("copy-from",[t,r]);let a={type:"copy-from",in:{buffer:e}};Qt.postMessage(a,[e.buffer])})):uH(e),tm=async(e,t)=>{if(la()){if(t?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return wa(),new Promise((r,a)=>{Na("create",[r,a]);let n={type:"create",in:{model:e,options:{...t}}},s=[];e instanceof Uint8Array&&s.push(e.buffer),Qt.postMessage(n,s)})}else return Tc(e,t)},rm=async e=>{if(la())return wa(),new Promise((t,r)=>{Na("release",[t,r]);let a={type:"release",in:e};Qt.postMessage(a)});bc(e)},am=async(e,t,r,a,n,s)=>{if(la()){if(r.some(i=>i[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(n.some(i=>i))throw new Error("pre-allocated output tensor is not supported for proxy.");return wa(),new Promise((i,H)=>{Na("run",[i,H]);let o=r,_={type:"run",in:{sessionId:e,inputIndices:t,inputs:o,outputIndices:a,options:s}};Qt.postMessage(_,Cc(o))})}else return vc(e,t,r,a,n,s)},nm=async e=>{if(la())return wa(),new Promise((t,r)=>{Na("end-profiling",[t,r]);let a={type:"end-profiling",in:e};Qt.postMessage(a)});Dc(e)}}),y_,m$,im,QB=Ae(()=>{"use strict";Ka(),sm(),Pn(),fc(),K0(),y_=(e,t)=>{switch(e.location){case"cpu":return[e.type,e.dims,e.data,"cpu"];case"gpu-buffer":return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[e.type,e.dims,{mlTensor:e.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${e.location} for ${t()}`)}},m$=e=>{switch(e[3]){case"cpu":return new nr(e[0],e[2],e[1]);case"gpu-buffer":{let t=e[0];if(!Ic(t))throw new Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:r,download:a,dispose:n}=e[2];return nr.fromGpuBuffer(r,{dataType:t,dims:e[1],download:a,dispose:n})}case"ml-tensor":{let t=e[0];if(!Sc(t))throw new Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:r,download:a,dispose:n}=e[2];return nr.fromMLTensor(r,{dataType:t,dims:e[1],download:a,dispose:n})}default:throw new Error(`invalid data location: ${e[3]}`)}},im=class{async fetchModelAndCopyToWasmMemory(e){return em(await Lc(e))}async loadModel(e,t){Fa();let r;typeof e=="string"?r=await this.fetchModelAndCopyToWasmMemory(e):r=e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await tm(r,t),Za()}async dispose(){return rm(this.sessionId)}async run(e,t,r){Fa();let a=[],n=[];Object.entries(e).forEach(l=>{let d=l[0],h=l[1],$=this.inputNames.indexOf(d);if($===-1)throw new Error(`invalid input '${d}'`);a.push(h),n.push($)});let s=[],i=[];Object.entries(t).forEach(l=>{let d=l[0],h=l[1],$=this.outputNames.indexOf(d);if($===-1)throw new Error(`invalid output '${d}'`);s.push(h),i.push($)});let H=a.map((l,d)=>y_(l,()=>`input "${this.inputNames[n[d]]}"`)),o=s.map((l,d)=>l?y_(l,()=>`output "${this.outputNames[i[d]]}"`):null),_=await am(this.sessionId,n,H,i,o,r),c={};for(let l=0;l<_.length;l++)c[this.outputNames[i[l]]]=s[l]??m$(_[l]);return Za(),c}startProfiling(){}endProfiling(){nm(this.sessionId)}}}),Hm={};ks(Hm,{OnnxruntimeWebAssemblyBackend:()=>z_,initializeFlags:()=>X_,wasmBackend:()=>om});var X_,z_,om,YB=Ae(()=>{"use strict";Ka(),sm(),QB(),X_=()=>{(typeof qe.wasm.initTimeout!="number"||qe.wasm.initTimeout<0)&&(qe.wasm.initTimeout=0);let e=qe.wasm.simd;if(typeof e!="boolean"&&e!==void 0&&e!=="fixed"&&e!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),qe.wasm.simd=!1),typeof qe.wasm.proxy!="boolean"&&(qe.wasm.proxy=!1),typeof qe.wasm.trace!="boolean"&&(qe.wasm.trace=!1),typeof qe.wasm.numThreads!="number"||!Number.isInteger(qe.wasm.numThreads)||qe.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)qe.wasm.numThreads=1;else{let t=typeof navigator>"u"?xB("node:os").cpus().length:navigator.hardwareConcurrency;qe.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}},z_=class{async init(e){X_(),await Q0(),await Y0(e)}async createInferenceSessionHandler(e,t){let r=new im;return await r.loadModel(e,t),r}},om=new z_});Ka();Ka();Ka();var e2="1.26.0-dev.20260416-b7804b056c",t2=B0;{let e=(YB(),oH(Hm)).wasmBackend;ka("webgpu",e,5),ka("webnn",e,5),ka("cpu",e,10),ka("wasm",e,10)}Object.defineProperty(qe.versions,"web",{value:e2,enumerable:!0});async function _m(e){let t=e.split("/").pop(),r;try{if(r=await Mn(),r){let n=await r.match(e);if(n)return n}}catch(n){he.warn(`Failed to load ${t} from cache:`,n)}let a=await Te.fetch(e);if(!a.ok)throw new Error(`Failed to fetch ${t}: ${a.status} ${a.statusText}`);if(r)try{await r.put(e,a.clone())}catch(n){he.warn(`Failed to cache ${t}:`,n)}return a}async function r2(e){let t=await _m(e);if(!t||typeof t=="string")return null;try{return await t.arrayBuffer()}catch(r){return he.warn("Failed to read WASM binary:",r),null}}async function a2(e){if(me.IS_SERVICE_WORKER_ENV||me.IS_CHROME_AVAILABLE)return e;let t=await _m(e);if(!t||typeof t=="string")return null;try{let r=await t.text();r=r.replaceAll("globalThis.process?.versions?.node","false");let a=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(a)}catch(r){return he.warn("Failed to read WASM factory:",r),null}}var n2=Object.freeze({auto:null,gpu:null,cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",coreml:"coreml",webnn:{name:"webnn",deviceType:"cpu"},"webnn-npu":{name:"webnn",deviceType:"npu"},"webnn-gpu":{name:"webnn",deviceType:"gpu"},"webnn-cpu":{name:"webnn",deviceType:"cpu"}});function cm(e){return e<=sr.DEBUG?0:e<=sr.INFO?2:e<=sr.WARNING||e<=sr.ERROR?3:4}var s2={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},er=[],J_,xn,I$=Symbol.for("onnxruntime");if(I$ in globalThis)xn=globalThis[I$];else if(me.IS_NODE_ENV){switch(xn=bB,process.platform){case"win32":er.push("dml");break;case"linux":process.arch==="x64"&&er.push("cuda");break;case"darwin":er.push("coreml");break}er.push("webgpu"),er.push("cpu"),J_=["cpu"]}else xn=h0,me.IS_WEBNN_AVAILABLE&&er.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),me.IS_WEBGPU_AVAILABLE&&er.push("webgpu"),er.push("wasm"),J_=["wasm"];var i2=xn.InferenceSession;function H2(e=null){if(!e)return J_;switch(e){case"auto":return er;case"gpu":return er.filter(t=>["webgpu","cuda","dml","webnn-gpu"].includes(t))}if(er.includes(e))return[n2[e]??e];throw new Error(`Unsupported device: "${e}". Should be one of: ${er.join(", ")}.`)}var S$=Promise.resolve(),In=null;async function o2(){if(In)return In;if(!(Te.useWasmCache&&typeof it?.wasm?.wasmPaths=="object"&&it?.wasm?.wasmPaths?.wasm&&it?.wasm?.wasmPaths?.mjs)){if(me.IS_DENO_WEB_RUNTIME)throw new Error("env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.");return In=Promise.resolve(),In}return In=(async()=>{let t=it.wasm.wasmPaths,r=!1;await Promise.all([t.wasm&&!Z1(t.wasm)?(async()=>{try{let a=await r2(U1(t.wasm));a&&(it.wasm.wasmBinary=a,r=!0)}catch(a){he.warn("Failed to pre-load WASM binary:",a)}})():Promise.resolve(),t.mjs&&!Z1(t.mjs)?(async()=>{try{let a=await a2(U1(t.mjs));a&&(it.wasm.wasmPaths.mjs=a)}catch(a){he.warn("Failed to pre-load WASM factory:",a)}})():Promise.resolve()]),r||(it.wasm.wasmPaths.mjs=t.mjs)})(),In}async function lm(e,t,r){await o2();let a=cm(Te.logLevel??sr.WARNING),n=()=>i2.create(e,{logSeverityLevel:a,...t}),s=await(me.IS_WEB_ENV?S$=S$.then(n):n());return s.config=r,s}var L$=Promise.resolve();async function um(e,t){let r=()=>e.run(t);return me.IS_WEB_ENV?L$=L$.then(r):r()}function dm(e){return e instanceof xn.Tensor}var it=xn?.env;function xc(){return it?.wasm?.proxy}if(it){let e=function(t){let r=cm(t);it.logLevel=s2[r]};if(it.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&&it.versions?.web&&!it.wasm.wasmPaths){let t=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${it.versions.web}/dist/`;it.wasm.wasmPaths=me.IS_SAFARI?{mjs:`${t}ort-wasm-simd-threaded.mjs`,wasm:`${t}ort-wasm-simd-threaded.wasm`}:{mjs:`${t}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`${t}ort-wasm-simd-threaded.asyncify.wasm`}}it.wasm.proxy=!1}it.webgpu&&(it.webgpu.powerPreference="high-performance"),e(Te.logLevel??sr.WARNING),Te.backends.onnx={...it,setLogLevel:e}}var ua=async(e,t,r)=>{let a=await lm(new Uint8Array(e),t);return(async n=>{let s=xc(),i=Object.fromEntries(Object.entries(n).map(([o,_])=>[o,(s?_.clone():_).ort_tensor])),H=await um(a,i);return Array.isArray(r)?r.map(o=>new K(H[o])):new K(H[r])})},Ga=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||(this._nearest_interpolate_4d=ua([8,10,18,0,58,129,1,10,41,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,18,10,4,109,111,100,101,34,7,110,101,97,114,101,115,116,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,21],this.session_options,"y")),this._nearest_interpolate_4d}static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||(this._bilinear_interpolate_4d=ua([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||(this._bicubic_interpolate_4d=ua([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||(this._matmul=ua([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,"c")),this._matmul}static get stft(){return this._stft||(this._stft=ua([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,"o")),this._stft}static get rfft(){return this._rfft||(this._rfft=ua([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=ua([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,["v","i"])),this._top_k}static get slice(){return this._slice||(this._slice=ua([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,"y")),this._slice}},_2=Object.freeze({auto:"auto",gpu:"gpu",cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",coreml:"coreml",webnn:"webnn","webnn-npu":"webnn-npu","webnn-gpu":"webnn-gpu","webnn-cpu":"webnn-cpu"}),B_=me.IS_NODE_ENV?"cpu":"wasm";function pm(e,t,{warn:r}={}){return e?typeof e=="string"?e:e.hasOwnProperty(t)?e[t]:(r&&r(`device not specified for "${t}". Using the default device (${B_}).`),B_):B_}var c2=(function(){let e;return async function(){if(e===void 0)if(!me.IS_WEBGPU_AVAILABLE)e=!1;else try{e=(await navigator.gpu.requestAdapter()).features.has("shader-f16")}catch{e=!1}return e}})(),tt=Object.freeze({auto:"auto",fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16",q2:"q2",q2f16:"q2f16",q1:"q1",q1f16:"q1f16"}),A$=tt.fp32,g$=Object.freeze({[_2.wasm]:tt.q8}),xs=Object.freeze({[tt.fp32]:"",[tt.fp16]:"_fp16",[tt.int8]:"_int8",[tt.uint8]:"_uint8",[tt.q8]:"_quantized",[tt.q4]:"_q4",[tt.q2]:"_q2",[tt.q1]:"_q1",[tt.q4f16]:"_q4f16",[tt.q2f16]:"_q2f16",[tt.q1f16]:"_q1f16",[tt.bnb4]:"_bnb4"});function hm(e,t,r,{configDtype:a=null,warn:n}={}){let s,i=!1;e&&typeof e!="string"?e.hasOwnProperty(t)?s=e[t]:(s=null,i=!0):s=e;let H;if(s===tt.auto){if(a){let o=typeof a=="string"?a:a?.[t];if(o&&o!==tt.auto&&tt.hasOwnProperty(o))return o}H=g$[r]??A$}else s&&tt.hasOwnProperty(s)?H=s:H=g$[r]??A$;return i&&n&&n(`dtype not specified for "${t}". Using the default dtype (${H}) for this device (${r}).`),H}var Ns=Object.freeze({float32:Float32Array,float16:typeof Float16Array<"u"?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array}),K=class Je{get dims(){return this.ort_tensor.dims}set dims(t){this.ort_tensor.dims=t}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...t){return dm(t[0])?this.ort_tensor=t[0]:this.ort_tensor=new Bo(t[0],t[1],t[2]),new Proxy(this,{get:(r,a)=>{if(typeof a=="string"){let n=Number(a);if(Number.isInteger(n))return r._getitem(n)}return r[a]},set:(r,a,n)=>r[a]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[t,...r]=this.dims;if(r.length>0){let a=r.reduce((n,s)=>n*s);for(let n=0;n<t;++n)yield this._subarray(n,a,r)}else yield*this.data}_getitem(t){let[r,...a]=this.dims;if(t=xr(t,r),a.length>0){let n=a.reduce((s,i)=>s*i);return this._subarray(t,n,a)}else return new Je(this.type,[this.data[t]],a)}indexOf(t){let r=this.data;for(let a=0;a<r.length;++a)if(r[a]==t)return a;return-1}_subarray(t,r,a){let n=t*r,s=(t+1)*r,i="subarray"in this.data?this.data.subarray(n,s):this.data.slice(n,s);return new Je(this.type,i,a)}item(){let t=this.data;if(t.length!==1)throw new Error(`a Tensor with ${t.length} elements cannot be converted to Scalar`);return t[0]}tolist(){return l2(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let t=this.data;for(let r=0;r<t.length;++r)t[r]=1/(1+Math.exp(-t[r]));return this}map(t){return this.clone().map_(t)}map_(t){let r=this.data;for(let a=0;a<r.length;++a)r[a]=t(r[a],a,r);return this}mul(t){return this.clone().mul_(t)}mul_(t){let r=this.data;for(let a=0;a<r.length;++a)r[a]*=t;return this}div(t){return this.clone().div_(t)}div_(t){let r=this.data;for(let a=0;a<r.length;++a)r[a]/=t;return this}add(t){return this.clone().add_(t)}add_(t){let r=this.data;for(let a=0;a<r.length;++a)r[a]+=t;return this}sub(t){return this.clone().sub_(t)}sub_(t){let r=this.data;for(let a=0;a<r.length;++a)r[a]-=t;return this}clone(){return new Je(this.type,this.data.slice(),this.dims.slice())}slice(...t){let r=[],a=[];for(let c=0;c<this.dims.length;++c){let l=t[c];if(l==null)a.push([0,this.dims[c]]),r.push(this.dims[c]);else if(typeof l=="number")l=xr(l,this.dims[c],c),a.push([l,l+1]);else if(Array.isArray(l)&&l.length===2){let[d,h]=l;if(d=d===null?0:xr(d,this.dims[c],c,!1),h=h===null?this.dims[c]:xr(h,this.dims[c],c,!1),d>h)throw new Error(`Invalid slice: ${l}`);let $=[Math.max(d,0),Math.min(h,this.dims[c])];a.push($),r.push($[1]-$[0])}else throw new Error(`Invalid slice: ${l}`)}let n=a.map(([c,l])=>l-c),s=n.reduce((c,l)=>c*l),i=this.data,H=new i.constructor(s),o=this.stride(),_=!0;for(let c=1;c<n.length;++c)if(a[c][0]!==0||a[c][1]!==this.dims[c]){_=!1;break}if(_){let c=a[0][0]*o[0],l=a[0][1]*o[0];if(ArrayBuffer.isView(i))H.set(i.subarray(c,l));else if(Array.isArray(i)){let d=i.slice(c,l);for(let h=0;h<d.length;++h)H[h]=d[h]}else throw new Error("Unsupported data type for slicing")}else for(let c=0;c<s;++c){let l=0;for(let d=n.length-1,h=c;d>=0;--d){let $=n[d];l+=(h%$+a[d][0])*o[d],h=Math.floor(h/$)}H[c]=i[l]}return new Je(this.type,H,r)}permute(...t){return u2(this,t)}transpose(...t){return this.permute(...t)}sum(t=null,r=!1){return this.norm(1,t,r)}norm(t="fro",r=null,a=!1){if(t==="fro")t=2;else if(typeof t=="string")throw Error(`Unsupported norm: ${t}`);let n=this.data,s=n instanceof BigInt64Array||n instanceof BigUint64Array;if(s&&t!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let i,H;if(s?(i=(l,d)=>l+d,H=0n):(i=(l,d)=>l+d**t,H=0),r===null){let l=n.reduce(i,H);return t!==1&&(l=l**(1/t)),new Je(this.type,[l],[])}let[o,_,c]=bs(i,this,r,a);if(t!==1)for(let l=0;l<_.length;++l)_[l]=_[l]**(1/t);return new Je(o,_,c)}normalize_(t=2,r=1){r=xr(r,this.dims.length);let a=this.norm(t,r,!0),n=this.data,s=a.data;for(let i=0;i<n.length;++i){let H=0;for(let o=this.dims.length-1,_=i,c=1;o>=0;--o){let l=this.dims[o];if(o!==r){let d=_%l;H+=d*c,c*=this.dims[o]}_=Math.floor(_/l)}n[i]/=s[H]}return this}normalize(t=2,r=1){return this.clone().normalize_(t,r)}stride(){return M_(this.dims)}squeeze(t=null){return new Je(this.type,this.data,T$(this.dims,t))}squeeze_(t=null){return this.dims=T$(this.dims,t),this}unsqueeze(t){return new Je(this.type,this.data,b$(this.dims,t))}unsqueeze_(t){return this.dims=b$(this.dims,t),this}flatten_(t=0,r=-1){r=(r+this.dims.length)%this.dims.length;let a=this.dims.slice(0,t),n=this.dims.slice(t,r+1),s=this.dims.slice(r+1);return this.dims=[...a,n.reduce((i,H)=>i*H,1),...s],this}flatten(t=0,r=-1){return this.clone().flatten_(t,r)}view(...t){let r=-1;for(let n=0;n<t.length;++n)if(t[n]===-1){if(r!==-1)throw new Error("Only one dimension can be inferred");r=n}let a=this.data;if(r!==-1){let n=t.reduce((s,i,H)=>H!==r?s*i:s,1);t[r]=a.length/n}return new Je(this.type,a,t)}neg_(){let t=this.data;for(let r=0;r<t.length;++r)t[r]=-t[r];return this}neg(){return this.clone().neg_()}gt(t){let r=new Uint8Array(this.data.length),a=this.data;for(let n=0;n<a.length;++n)r[n]=a[n]>t?1:0;return new Je("bool",r,this.dims)}lt(t){let r=new Uint8Array(this.data.length),a=this.data;for(let n=0;n<a.length;++n)r[n]=a[n]<t?1:0;return new Je("bool",r,this.dims)}clamp_(t,r){let a=this.data;for(let n=0;n<a.length;++n)a[n]=Math.min(Math.max(a[n],t),r);return this}clamp(t,r){return this.clone().clamp_(t,r)}round_(){let t=this.data;for(let r=0;r<t.length;++r)t[r]=Math.round(t[r]);return this}round(){return this.clone().round_()}mean(t=null,r=!1){return Nc(this,t,r)}min(t=null,r=!1){if(t===null){let i=W_(this.data)[0];return new Je(this.type,[i],[])}let[a,n,s]=bs((i,H)=>Math.min(i,H),this,t,r,1/0);return new Je(a,n,s)}max(t=null,r=!1){if(t===null){let i=et(this.data)[0];return new Je(this.type,[i],[])}let[a,n,s]=bs((i,H)=>Math.max(i,H),this,t,r,-1/0);return new Je(a,n,s)}argmin(t=null,r=!1){if(t!==null)throw new Error("`dim !== null` not yet implemented.");let a=W_(this.data)[1];return new Je("int64",[BigInt(a)],[])}argmax(t=null,r=!1){if(t!==null)throw new Error("`dim !== null` not yet implemented.");let a=et(this.data)[1];return new Je("int64",[BigInt(a)],[])}repeat(...t){if(t.length<this.dims.length)throw new Error(`Number of dimensions of repeat dims (${t.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(t.every(c=>c===1)){if(t.length===this.dims.length)return this.clone();let c=t.length-this.dims.length,l=Array(c).fill(1).concat(this.dims);return new Je(this.type,this.data.slice(),l)}let r=t.length-this.dims.length,a=Array(r).fill(1).concat(this.dims),n=a.map((c,l)=>c*t[l]),s=n.reduce((c,l)=>c*l,1),i=this.data,H=new i.constructor(s),o=M_(a),_=M_(n);for(let c=0;c<s;++c){let l=c,d=0;for(let h=0;h<n.length;++h){let $=Math.floor(l/_[h]);l=l%_[h];let m=$%a[h];d+=m*o[h]}H[c]=i[d]}return new Je(this.type,H,n)}tile(...t){if(t.length<this.dims.length){let r=this.dims.length-t.length;t=Array(r).fill(1).concat(t)}return this.repeat(...t)}to(t){if(this.type===t)return this;if(!Ns.hasOwnProperty(t))throw new Error(`Unsupported type: ${t}`);let r,a=["int64","uint64"].includes(this.type),n=["int64","uint64"].includes(t);if(a&&!n)r=Number;else if(!a&&n)["float16","float32","float64"].includes(this.type)?r=s=>BigInt(Math.floor(s)):r=BigInt;else if(this.type==="float16"&&t=="float32"&&this.data instanceof Uint16Array)return new Je(t,TB(this.data),this.dims);return new Je(t,Ns[t].from(this.data,r),this.dims)}};function l2(e,t){let r=e.length,a=t.reduce((s,i)=>s*i);if(r!==a)throw Error(`cannot reshape array of size ${r} into shape (${t})`);let n=e;for(let s=t.length-1;s>=0;s--)n=n.reduce((i,H)=>{let o=i[i.length-1];return o.length<t[s]?o.push(H):i.push([H]),i},[[]]);return n[0]}function u2(e,t){let[r,a]=EB(e.data,e.dims,t);return new K(e.type,r,a)}function fm(e,[t,r],a="bilinear",n=!1){let s=e.dims.at(-3)??1,i=e.dims.at(-2),H=e.dims.at(-1),o=fB(e.data,[s,i,H],[t,r],a,n);return new K(e.type,o,[s,t,r])}async function _r(e,{size:t=null,mode:r="bilinear"}={}){if(e.dims.length!==4)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!t)throw new Error("`interpolate_4d` requires a `size` argument.");let a;if(t.length===2)a=[...e.dims.slice(0,2),...t];else if(t.length===3)a=[e.dims[0],...t];else if(t.length===4)a=t;else throw new Error("`size` must be of length 2, 3, or 4.");let n;if(r==="nearest")n=await Ga.nearest_interpolate_4d;else if(r==="bilinear")n=await Ga.bilinear_interpolate_4d;else if(r==="bicubic")n=await Ga.bicubic_interpolate_4d;else throw new Error(`Unsupported mode: ${r}`);let s=new K("int64",new BigInt64Array(a.map(BigInt)),[a.length]);return await n({x:e,s})}async function d2(e,t){return await(await Ga.matmul)({a:e,b:t})}async function g7(e,t){return await(await Ga.rfft)({x:e,a:t})}async function Rn(e,t){let r=await Ga.top_k;return t==null?t=e.dims.at(-1):t=Math.min(t,e.dims.at(-1)),await r({x:e,k:new K("int64",[BigInt(t)],[1])})}var ji=e=>new K("int64",e,[e.length]);async function Em(e,t,r,a,n){return await(await Ga.slice)({x:e,s:ji(t),e:ji(r),a:ji(a),t:ji(n??new Array(a.length).fill(1))})}function p2(e,t){let r=e.data,a=t.data,n=[e.dims[0],e.dims[2]],s=new r.constructor(n[0]*n[1]),[i,H,o]=e.dims,_=0;for(let c=0;c<i;++c){let l=c*o*H;for(let d=0;d<o;++d){let h=0,$=0,m=c*H,S=l+d;for(let T=0;T<H;++T){let D=Number(a[m+T]);$+=D,h+=r[S+T*o]*D}let I=h/$;s[_++]=I}}return new K(e.type,s,n)}function T7(e,t,{eps:r=1e-5}={}){if(e.dims.length!==2)throw new Error("`layer_norm` currently only supports 2D input.");let[a,n]=e.dims;if(t.length!==1&&t[0]!==n)throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[s,i]=$m(e,1,0,!0),H=s.data,o=i.data,_=e.data,c=new _.constructor(_.length);for(let l=0;l<a;++l){let d=l*n;for(let h=0;h<n;++h){let $=d+h;c[$]=(_[$]-o[l])/(H[l]+r)}}return new K(e.type,c,e.dims)}function T$(e,t){return e=e.slice(),t===null?e=e.filter(r=>r!==1):typeof t=="number"?e[t]===1&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((r,a)=>r!==1||!t.includes(a))),e}function b$(e,t){return t=xr(t,e.length+1),e=e.slice(),e.splice(t,0,1),e}function xr(e,t,r=null,a=!0){if(e<-t||e>=t){if(a)throw new Error(`IndexError: index ${e} is out of bounds for dimension${r===null?"":" "+r} with size ${t}`);return e<-t?0:t}return e<0&&(e=(e%t+t)%t),e}function je(e,t=0){t=xr(t,e[0].dims.length);let r=e[0].dims.slice();r[t]=e.reduce((i,H)=>i+H.dims[t],0);let a=r.reduce((i,H)=>i*H,1),n=new e[0].data.constructor(a),s=e[0].type;if(t===0){let i=0;for(let H of e){let o=H.data;n.set(o,i),i+=o.length}}else{let i=0;for(let H=0;H<e.length;++H){let{data:o,dims:_}=e[H];for(let c=0;c<o.length;++c){let l=0;for(let d=_.length-1,h=c,$=1;d>=0;--d){let m=_[d],S=h%m;d===t&&(S+=i),l+=S*$,$*=r[d],h=Math.floor(h/m)}n[l]=o[c]}i+=_[t]}}return new K(s,n,r)}function Xr(e,t=0){return je(e.map(r=>r.unsqueeze(t)),t)}function bs(e,t,r,a=!1,n=null){let s=t.data,i=t.dims;r=xr(r,i.length);let H=i.slice();H[r]=1;let o=new s.constructor(s.length/i[r]);n!==null&&o.fill(n);for(let _=0;_<s.length;++_){let c=0;for(let l=i.length-1,d=_,h=1;l>=0;--l){let $=i[l];if(l!==r){let m=d%$;c+=m*h,h*=H[l]}d=Math.floor(d/$)}o[c]=e(o[c],s[_],_,c)}return a||H.splice(r,1),[t.type,o,H]}function $m(e,t=null,r=1,a=!1){let n=e.data,s=e.dims;if(t===null){let h=n.reduce((I,T)=>I+T,0)/n.length,$=Math.sqrt(n.reduce((I,T)=>I+(T-h)**2,0)/(n.length-r)),m=new K(e.type,[h],[]);return[new K(e.type,[$],[]),m]}t=xr(t,s.length);let i=Nc(e,t,a),H=i.data,[o,_,c]=bs((d,h,$,m)=>d+(h-H[m])**2,e,t,a);for(let d=0;d<_.length;++d)_[d]=Math.sqrt(_[d]/(s[t]-r));return[new K(o,_,c),i]}function Nc(e,t=null,r=!1){let a=e.dims,n=e.data;if(t===null){let o=n.reduce((_,c)=>_+c,0);return new K(e.type,[o/n.length],[])}t=xr(t,a.length);let[s,i,H]=bs((o,_)=>o+_,e,t,r);if(a[t]!==1)for(let o=0;o<i.length;++o)i[o]/=a[t];return new K(s,i,H)}function M_(e){let t=new Array(e.length);for(let r=e.length-1,a=1;r>=0;--r)t[r]=a,a*=e[r];return t}function wc(e,t,r,a){let n=e.reduce((s,i)=>s*i,1);return new K(r,new a(n).fill(t),e)}function Tt(e,t){let r,a;if(typeof t=="number")r="float32",a=Float32Array;else if(typeof t=="bigint")r="int64",a=BigInt64Array;else if(typeof t=="boolean")r="bool",a=Uint8Array;else throw new Error(`Unsupported data type: ${typeof t}`);return wc(e,t,r,a)}function Q_(e,t){return Tt(e.dims,t)}function Gt(e){return wc(e,1n,"int64",BigInt64Array)}function mm(e){return Gt(e.dims)}function Im(e){return wc(e,0n,"int64",BigInt64Array)}function Sm(e){return Im(e.dims)}function b7(e){let t=e.reduce((r,a)=>r*a,1);return new K("float32",Float32Array.from({length:t},()=>LH.random()),e)}function h2(e){let t=e.reduce((r,a)=>r*a,1);return new K("float32",Float32Array.from({length:t},()=>LH.gauss()),e)}function f2(e,t){if(e.dims.length!==2)throw new Error("The tensor must have 2 dimensions");if(e.dims.at(-1)%8!==0)throw new Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(t))throw new Error("The precision must be either 'binary' or 'ubinary'");let r=t==="binary",a=r?"int8":"uint8",n=r?Int8Array:Uint8Array,s=e.data,i=new n(s.length/8);for(let H=0;H<s.length;++H){let o=s[H]>0?1:0,_=Math.floor(H/8),c=H%8;i[_]|=o<<7-c,r&&c===0&&(i[_]-=128)}return new K(a,i,[e.dims[0],e.dims[1]/8])}async function yc(e){if(!e)throw new Error("modelId is required for get_tokenizer_files");return(await Ua(e,"tokenizer_config.json",{})).exists?["tokenizer.json","tokenizer_config.json"]:[]}async function Lm(e,t){let r=await yc(e);return await Promise.all(r.map(a=>yr(e,a,!0,t)))}function Bc(e){let t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(t[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}var E2=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function $2(e,t,r,a){for(let n of Object.keys(e)){let s=t-e[n].length,i=r(n),H=new Array(s).fill(i);e[n]=a==="right"?ir(e[n],H):ir(H,e[n])}}function m2(e,t){for(let r of Object.keys(e))e[r].length=t}function ya(e,...t){for(let r of t){if(!Object.hasOwn(e,r))continue;let a=e[r];if(a)if(typeof a=="object"){if(a.__type==="AddedToken")return a.content;throw Error(`Unknown token: ${a}`)}else return a}return null}function I2(e){let t=[];for(let r of e.get_added_tokens_decoder().values())r.special&&t.push(r);return t}var pe=class extends Ft{return_token_type_ids=!1;padding_side="right";constructor(e,t){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=t,this._tokenizer=new ny(e,t),this.config=t,this.padding_side=t.padding_side??this.padding_side,this.mask_token=ya(t,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=ya(t,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=ya(t,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=ya(t,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=ya(t,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=ya(t,"eos_token"),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=t.chat_template??null,Array.isArray(this.chat_template)){let a=Object.create(null);for(let{name:n,template:s}of this.chat_template){if(typeof n!="string"||typeof s!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');a[n]=s}this.chat_template=a}this._compiled_template_cache=new Map;let r=I2(this._tokenizer);this.all_special_ids=r.map(a=>a.id),this.all_special_tokens=r.map(a=>a.content)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:a=null,local_files_only:n=!1,revision:s="main"}={}){let i=await Lm(e,{progress_callback:t,config:r,cache_dir:a,local_files_only:n,revision:s});return new this(...i)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e=="string"?this._tokenizer.token_to_id(e):e.map(t=>this._tokenizer.token_to_id(t))}_call(e,t={}){let{text_pair:r=null,add_special_tokens:a=!0,padding:n=!1,return_token_type_ids:s=null}=t,{truncation:i=null,max_length:H=null}=t,o=t.return_tensor??!0,_=Array.isArray(e),c;if(_){if(e.length===0)throw Error("text array must be non-empty");if(r!==null){if(Array.isArray(r)){if(e.length!==r.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");c=e.map((d,h)=>this._encode_plus(d,{text_pair:r[h],add_special_tokens:a,return_token_type_ids:s}))}else c=e.map(d=>this._encode_plus(d,{add_special_tokens:a,return_token_type_ids:s}))}else{if(e==null)throw Error("text may not be null or undefined");if(Array.isArray(r))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");c=[this._encode_plus(e,{text_pair:r,add_special_tokens:a,return_token_type_ids:s})]}if(H===null?H=this.model_max_length:i===null&&(n===!0?(he.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),H=this.model_max_length):n===!1&&(he.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),i=!0)),n===!0&&(H=Math.min(et(c.map(d=>d.input_ids.length))[0],H??1/0)),H=Math.min(H,this.model_max_length??1/0),n||i)for(let d=0;d<c.length;++d)c[d].input_ids.length!==H&&(c[d].input_ids.length>H?i&&m2(c[d],H):n&&$2(c[d],H,h=>h==="input_ids"?this.pad_token_id:0,this.padding_side));let l={};if(o){if(!(n&&i)&&c.some(h=>{for(let $ of Object.keys(h))if(h[$].length!==c[0][$]?.length)return!0;return!1}))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");let d=[c.length,c[0].input_ids.length];for(let h of Object.keys(c[0]))l[h]=new K("int64",BigInt64Array.from(c.flatMap($=>$[h]).map(BigInt)),d)}else{for(let d of Object.keys(c[0]))l[d]=c.map(h=>h[d]);if(!_)for(let d of Object.keys(l))l[d]=l[d][0]}return l}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:a=null}={}){let{ids:n,attention_mask:s,token_type_ids:i}=this._tokenizer.encode(e,{text_pair:t,add_special_tokens:r,return_token_type_ids:a??this.return_token_type_ids});return{input_ids:n,attention_mask:s,...i?{token_type_ids:i}:{}}}tokenize(e,{pair:t=null,add_special_tokens:r=!1}={}){return this._tokenizer.tokenize(e,{text_pair:t,add_special_tokens:r})}encode(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:a=null}={}){return this._tokenizer.encode(e,{text_pair:t,add_special_tokens:r,return_token_type_ids:a}).ids}batch_decode(e,t={}){return e instanceof K&&(e=e.tolist()),e.map(r=>this.decode(r,t))}decode(e,t={}){if(e instanceof K&&(e=Bc(e)),!Array.isArray(e)||e.length===0||!Wx(e[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(e,t)}decode_single(e,{skip_special_tokens:t=!1,clean_up_tokenization_spaces:r=null}){return this._tokenizer.decode(e,{skip_special_tokens:t,clean_up_tokenization_spaces:r})}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&typeof this.chat_template=="object"){let r=this.chat_template;if(e!==null&&Object.hasOwn(r,e))e=r[e];else if(e===null)if(t!==null&&"tool_use"in r)e=r.tool_use;else if("default"in r)e=r.default;else throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(r).sort()}.`)}else if(e===null)if(this.chat_template)e=this.chat_template;else throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");return e}apply_chat_template(e,t={}){let{tools:r=null,documents:a=null,chat_template:n=null,add_generation_prompt:s=!1,tokenize:i=!0,padding:H=!1,truncation:o=!1,max_length:_=null,return_tensor:c=!0,return_dict:l=!0,tokenizer_kwargs:d={},...h}=t;if(n=this.get_chat_template({chat_template:n,tools:r}),typeof n!="string")throw Error(`chat_template must be a string, but got ${typeof n}`);let $=this._compiled_template_cache.get(n);$===void 0&&($=new Yy(n),this._compiled_template_cache.set(n,$));let m=Object.create(null);for(let I of E2){let T=ya(this.config,I);T&&(m[I]=T)}let S=$.render({messages:e,add_generation_prompt:s,tools:r,documents:a,...m,...h});if(i){let I=this._call(S,{add_special_tokens:!1,padding:H,truncation:o,max_length:_,return_tensor:c,...d});return l?I:I.input_ids}return S}};function Mc(e,t,r,a){if(!("language_codes"in e)||!Array.isArray(e.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in e)||!(e.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in e)||typeof e.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let n=a.src_lang,s=a.tgt_lang;if(!e.language_codes.includes(s))throw new Error(`Target language code "${s}" is not valid. Must be one of: {${e.language_codes.join(", ")}}`);if(n!==void 0){if(!e.language_codes.includes(n))throw new Error(`Source language code "${n}" is not valid. Must be one of: {${e.language_codes.join(", ")}}`);for(let i of e._tokenizer.post_processor.config.single)if("SpecialToken"in i&&e.languageRegex.test(i.SpecialToken.id)){i.SpecialToken.id=e.lang_to_token(n);break}}return a.forced_bos_token_id=e._tokenizer.token_to_id(e.lang_to_token(s)),e._call(t,r)}var Am={};wn(Am,{AlbertTokenizer:()=>S2,AutoTokenizer:()=>we,BartTokenizer:()=>L2,BertTokenizer:()=>A2,BlenderbotSmallTokenizer:()=>g2,BlenderbotTokenizer:()=>T2,BloomTokenizer:()=>b2,CLIPTokenizer:()=>D2,CamembertTokenizer:()=>v2,CodeGenTokenizer:()=>x2,CodeLlamaTokenizer:()=>C2,CohereAsrTokenizer:()=>w2,CohereTokenizer:()=>N2,ConvBertTokenizer:()=>y2,DebertaTokenizer:()=>M2,DebertaV2Tokenizer:()=>B2,DistilBertTokenizer:()=>P2,ElectraTokenizer:()=>R2,EsmTokenizer:()=>k2,FalconTokenizer:()=>O2,GPT2Tokenizer:()=>Z2,GPTNeoXTokenizer:()=>F2,GemmaTokenizer:()=>G2,HerbertTokenizer:()=>U2,LlamaTokenizer:()=>K2,M2M100Tokenizer:()=>W2,MBart50Tokenizer:()=>j2,MBartTokenizer:()=>gm,MPNetTokenizer:()=>z2,MarianTokenizer:()=>V2,MgpstrTokenizer:()=>q2,MobileBertTokenizer:()=>X2,NllbTokenizer:()=>J2,NougatTokenizer:()=>Q2,PreTrainedTokenizer:()=>pe,Qwen2Tokenizer:()=>Y2,RoFormerTokenizer:()=>tM,RobertaTokenizer:()=>eM,SiglipTokenizer:()=>rM,SpeechT5Tokenizer:()=>aM,SqueezeBertTokenizer:()=>nM,T5Tokenizer:()=>sM,TokenizersBackend:()=>pe,VitsTokenizer:()=>HM,Wav2Vec2CTCTokenizer:()=>oM,WhisperTokenizer:()=>dM,XLMRobertaTokenizer:()=>pM,XLMTokenizer:()=>hM});var S2=class extends pe{return_token_type_ids=!0},L2=class extends pe{},A2=class extends pe{return_token_type_ids=!0},g2=class extends pe{},T2=class extends pe{},b2=class extends pe{},v2=class extends pe{},D2=class extends pe{},C2=class extends pe{},x2=class extends pe{},N2=class extends pe{},w2=class extends pe{},y2=class extends pe{return_token_type_ids=!0},B2=class extends pe{return_token_type_ids=!0},M2=class extends pe{return_token_type_ids=!0},P2=class extends pe{},R2=class extends pe{return_token_type_ids=!0},k2=class extends pe{},O2=class extends pe{},G2=class extends pe{},F2=class extends pe{},Z2=class extends pe{},U2=class extends pe{return_token_type_ids=!0},K2=class extends pe{padding_side="left"},W2=class extends pe{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r.slice(2,-2)),this.lang_to_token=r=>`__${r}__`}_build_translation_inputs(e,t,r){return Mc(this,e,t,r)}},V2=class extends pe{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(r=>this.languageRegex.test(r)),he.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[t,...r]=e.trim().split(this.languageRegex);if(r.length===0)return super._encode_text(t);if(r.length===2){let[a,n]=r;return this.supported_language_codes.includes(a)||he.warn(`Unsupported language code "${a}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),ir([a],super._encode_text(n))}}},gm=class extends pe{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r),this.lang_to_token=r=>r}_build_translation_inputs(e,t,r){return Mc(this,e,t,r)}},j2=class extends gm{},q2=class extends pe{},X2=class extends pe{return_token_type_ids=!0},z2=class extends pe{},J2=class extends pe{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)),this.lang_to_token=r=>r}_build_translation_inputs(e,t,r){return Mc(this,e,t,r)}},Q2=class extends pe{},Y2=class extends pe{},eM=class extends pe{},tM=class extends pe{return_token_type_ids=!0},rM=class extends pe{},aM=class extends pe{},nM=class extends pe{return_token_type_ids=!0},sM=class extends pe{},iM=class extends lr{decode_chain(e){let t="";for(let r=1;r<e.length;r+=2)t+=e[r];return[t]}},HM=class extends pe{constructor(e,t){super(e,t),this._tokenizer.decoder=new iM({type:"VitsDecoder"})}},oM=class extends pe{},Tm=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["ar","arabic"],["sv","swedish"],["it","italian"],["id","indonesian"],["hi","hindi"],["fi","finnish"],["vi","vietnamese"],["he","hebrew"],["uk","ukrainian"],["el","greek"],["ms","malay"],["cs","czech"],["ro","romanian"],["da","danish"],["hu","hungarian"],["ta","tamil"],["no","norwegian"],["th","thai"],["ur","urdu"],["hr","croatian"],["bg","bulgarian"],["lt","lithuanian"],["la","latin"],["mi","maori"],["ml","malayalam"],["cy","welsh"],["sk","slovak"],["te","telugu"],["fa","persian"],["lv","latvian"],["bn","bengali"],["sr","serbian"],["az","azerbaijani"],["sl","slovenian"],["kn","kannada"],["et","estonian"],["mk","macedonian"],["br","breton"],["eu","basque"],["is","icelandic"],["hy","armenian"],["ne","nepali"],["mn","mongolian"],["bs","bosnian"],["kk","kazakh"],["sq","albanian"],["sw","swahili"],["gl","galician"],["mr","marathi"],["pa","punjabi"],["si","sinhala"],["km","khmer"],["sn","shona"],["yo","yoruba"],["so","somali"],["af","afrikaans"],["oc","occitan"],["ka","georgian"],["be","belarusian"],["tg","tajik"],["sd","sindhi"],["gu","gujarati"],["am","amharic"],["yi","yiddish"],["lo","lao"],["uz","uzbek"],["fo","faroese"],["ht","haitian creole"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],tH=new Map(Tm),_M=new Map([...Tm.map(([e,t])=>[t,e]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);function cM(e){e=e.toLowerCase();let t=_M.get(e);if(t===void 0){let r=e.match(/^<\|([a-z]{2})\|>$/);if(r&&(e=r[1]),tH.has(e))t=e;else{let n=e.length===2?tH.keys():tH.values();throw new Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return t}var lM="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",v$=new RegExp(`^[${lM}]+$`,"gu"),uM=.1,dM=class extends pe{get timestamp_begin(){return this._tokenizer.token_to_id("<|notimestamps|>")+1}_decode_asr(e,{return_timestamps:t=!1,return_language:r=!1,time_precision:a=null,force_full_sequences:n=!0}={}){if(a===null)throw Error("Must specify time_precision");let s=null,i=t==="word";function H(){return{language:s,timestamp:[null,null],text:""}}let o=[],_=H(),c=0,l=this.timestamp_begin,h=l+1500,$=[],m=[],S=!1,I=null,T=new Set(this.all_special_ids);for(let C of e){let R=C.tokens,A=i?C.token_timestamps:null,U=null,Z=l;if("stride"in C){let[X,q,G]=C.stride;if(c-=q,I=X-G,q&&(Z=q/a+l),G)for(let y=R.length-1;y>=0;--y){let Q=Number(R[y]);if(Q>=l){if(U!==null&&(Q-l)*a<I)break;U=Q}}}let j=[],z=[];for(let X=0;X<R.length;++X){let q=Number(R[X]);if(T.has(q)){let G=this.decode([q]),y=tH.get(G.slice(2,-2));if(y!==void 0){if(s!==null&&y!==s&&!t){$.push(j);let Q=this.findLongestCommonSequence($)[0],_e=this.decode(Q);_.text=_e,o.push(_),$=[],j=[],_=H()}s=_.language=y}}else if(q>=l&&q<=h){let G=(q-l)*a+c,y=As(G,2);if(U!==null&&q>=U)S=!0;else if(S||$.length>0&&q<Z)S=!1;else if(_.timestamp[0]===null)_.timestamp[0]=y;else if(y!==_.timestamp[0]){_.timestamp[1]=y,$.push(j),i&&m.push(z);let[Q,_e]=this.findLongestCommonSequence($,m),M=this.decode(Q);if(_.text=M,i&&(_.words=this.collateWordTimestamps(Q,_e,s),_.words.length>0&&_.timestamp[1]!==null))for(let k of _.words)k.timestamp[1]>_.timestamp[1]&&_.timestamp[1]>=k.timestamp[0]&&(k.timestamp[1]=_.timestamp[1]);o.push(_),$=[],j=[],m=[],z=[],_=H()}}else if(j.push(q),i){let G=As(A[X]+c,2),y;if(X+1<A.length){y=As(A[X+1]+c,2);let Q=this.decode([q]);v$.test(Q)&&(y=As(Math.min(G+a,y),2))}else y=null;z.push([G,y])}}if("stride"in C){let[X,q,G]=C.stride;c+=X-G}j.length>0?($.push(j),i&&m.push(z)):$.every(X=>X.length===0)&&(_=H(),$=[],j=[],m=[],z=[])}if($.length>0){if(n&&t)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");let[C,R]=this.findLongestCommonSequence($,m),A=this.decode(C);_.text=A,i&&(_.words=this.collateWordTimestamps(C,R,s)),o.push(_)}let D=Object.create(null),v=o.map(C=>C.text).join("");if(t||r){for(let C=0;C<o.length;++C){let R=o[C];t||delete R.timestamp,r||delete R.language}if(i){let C=[];for(let R of o)for(let A of R.words)C.push(A);D={chunks:C}}else D={chunks:o}}return[v,D]}findLongestCommonSequence(e,t=null){let r=e[0],a=r.length,n=[],s=Array.isArray(t)&&t.length>0,i=s?[]:null,H=s?t[0]:null;for(let o=1;o<e.length;++o){let _=e[o],c=0,l=[a,a,0,0],d=_.length;for(let D=1;D<a+d;++D){let v=Math.max(0,a-D),C=Math.min(a,a+d-D),R=r.slice(v,C),A=Math.max(0,D-a),U=Math.min(d,D),Z=_.slice(A,U);if(R.length!==Z.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let j;s?j=R.filter((q,G)=>q===Z[G]&&H[v+G][0]-uM<=t[o][A+G][0]).length:j=R.filter((q,G)=>q===Z[G]).length;let z=D/1e4,X=j/D+z;j>1&&X>c&&(c=X,l=[v,C,A,U])}let[h,$,m,S]=l,I=Math.floor(($+h)/2),T=Math.floor((S+m)/2);if(s&&c===0&&a>0){let D=H[a-1][0],v=t[o].findIndex(C=>C[0]>=D);T=v===-1?_.length:v}n.push(...r.slice(0,I)),r=_.slice(T),a=r.length,s&&(i.push(...H.slice(0,I)),H=t[o].slice(T))}return n.push(...r),s?(i.push(...H),[n,i]):[n,[]]}collateWordTimestamps(e,t,r){let[a,n,s]=this.combineTokensIntoWords(e,r),i=[];for(let H=0;H<a.length;++H){let o=s[H];i.push({text:a[H],timestamp:[t[o.at(0)][0],t[o.at(-1)][1]]})}return i}combineTokensIntoWords(e,t,r=`"'\u201C\xA1\xBF([{-`,a=`"'.\u3002,\uFF0C!\uFF01?\uFF1F:\uFF1A\u201D)]}\u3001`){t=t??"english";let n,s,i;return["chinese","japanese","thai","lao","myanmar"].includes(t)?[n,s,i]=this.splitTokensOnUnicode(e):[n,s,i]=this.splitTokensOnSpaces(e),this.mergePunctuations(n,s,i,r,a)}decode(e,t){let r;return t?.decode_with_timestamps?(e instanceof K&&(e=Bc(e)),r=this.decodeWithTimestamps(e,t)):r=super.decode(e,t),r}decodeWithTimestamps(e,t){let r=t?.time_precision??.02,a=this.all_special_ids.at(-1)+1,n=[[]];for(let s of e)if(s=Number(s),s>=a){let i=((s-a)*r).toFixed(2);n.push(`<|${i}|>`),n.push([])}else n[n.length-1].push(s);return n=n.map(s=>typeof s=="string"?s:super.decode(s,t)),n.join("")}splitTokensOnUnicode(e){let t=this.decode(e,{decode_with_timestamps:!0}),r="\uFFFD",a=[],n=[],s=[],i=[],H=[],o=0;for(let _=0;_<e.length;++_){let c=e[_];i.push(c),H.push(_);let l=this.decode(i,{decode_with_timestamps:!0});(!l.includes(r)||t[o+l.indexOf(r)]===r)&&(a.push(l),n.push(i),s.push(H),i=[],H=[],o+=l.length)}return[a,n,s]}splitTokensOnSpaces(e){let[t,r,a]=this.splitTokensOnUnicode(e),n=[],s=[],i=[];for(let H=0;H<t.length;++H){let o=t[H],_=r[H],c=a[H],l=_[0]>=this._tokenizer.token_to_id("<|endoftext|>"),d=o.startsWith(" "),h=o.trim(),$=v$.test(h);if(l||d||$||n.length===0)n.push(o),s.push(_),i.push(c);else{let m=n.length-1;n[m]+=o,s[m].push(..._),i[m].push(...c)}}return[n,s,i]}mergePunctuations(e,t,r,a,n){let s=structuredClone(e),i=structuredClone(t),H=structuredClone(r),o=s.length-2,_=s.length-1;for(;o>=0;)s[o].startsWith(" ")&&a.includes(s[o].trim())?(s[_]=s[o]+s[_],i[_]=ir(i[o],i[_]),H[_]=ir(H[o],H[_]),s[o]="",i[o]=[],H[o]=[]):_=o,--o;for(o=0,_=1;_<s.length;)!s[o].endsWith(" ")&&n.includes(s[_])?(s[o]+=s[_],i[o]=ir(i[o],i[_]),H[o]=ir(H[o],H[_]),s[_]="",i[_]=[],H[_]=[]):o=_,++_;return[s.filter(c=>c),i.filter(c=>c.length>0),H.filter(c=>c.length>0)]}},pM=class extends pe{},hM=class extends pe{return_token_type_ids=!0;constructor(e,t){super(e,t),he.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}},we=class{static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:a=null,local_files_only:n=!1,revision:s="main"}={}){let[i,H]=await Lm(e,{progress_callback:t,config:r,cache_dir:a,local_files_only:n,revision:s}),o=H.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",_=Am[o];return _||(he.warn(`Unknown tokenizer class "${o}", attempting to construct from base class.`),_=pe),new _(i,H)}},AH="https://github.com/huggingface/transformers.js/issues/new/choose",Pc="preprocessor_config.json",ws=Pc,bm="processor_config.json",vm="chat_template.jinja",ye=class extends Ft{static classes=["image_processor_class","tokenizer_class","feature_extractor_class"];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,t,r){super(),this.config=e,this.components=t,this.chat_template=r}get image_processor(){return this.components.image_processor}get tokenizer(){return this.components.tokenizer}get feature_extractor(){return this.components.feature_extractor}apply_chat_template(e,t={}){if(!this.tokenizer)throw new Error("Unable to apply chat template without a tokenizer.");return this.tokenizer.apply_chat_template(e,{tokenize:!1,chat_template:this.chat_template??void 0,...t})}batch_decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.decode(...e)}async _call(e,...t){for(let r of[this.image_processor,this.feature_extractor,this.tokenizer])if(r)return r(e,...t);throw new Error("No image processor, feature extractor, or tokenizer found.")}static async from_pretrained(e,t={}){let[r,a,n]=await Promise.all([this.uses_processor_config?yr(e,bm,!0,t):{},Promise.all(this.classes.filter(s=>s in this).map(async s=>{let i=await this[s].from_pretrained(e,t);return[s.replace(/_class$/,""),i]})).then(Object.fromEntries),this.uses_chat_template_file?uc(e,vm,!0,t):null]);return new this(r,a,n)}},Y_={};wn(Y_,{ChatterboxProcessor:()=>WM,CohereAsrProcessor:()=>jM,Florence2Processor:()=>qP,Gemma3Processor:()=>XP,Gemma3nProcessor:()=>zP,Gemma4Processor:()=>JP,Glm46VProcessor:()=>QP,GraniteSpeechProcessor:()=>YP,GroundingDinoProcessor:()=>t3,Idefics3Processor:()=>B$,JinaCLIPProcessor:()=>i3,Lfm2VlProcessor:()=>H3,LlavaProcessor:()=>o3,MgpstrProcessor:()=>_3,MoonshineProcessor:()=>c3,OwlViTProcessor:()=>l3,PaliGemmaProcessor:()=>d3,Phi3VProcessor:()=>h3,PixtralProcessor:()=>f3,Processor:()=>ye,PyAnnoteProcessor:()=>E3,Qwen2VLProcessor:()=>Zc,Qwen2_5_VLProcessor:()=>nI,Qwen3VLProcessor:()=>$3,Sam2Processor:()=>iI,Sam2VideoProcessor:()=>m3,SamProcessor:()=>sI,SmolVLMProcessor:()=>B$,SpeechT5Processor:()=>I3,UltravoxProcessor:()=>S3,VLChatProcessor:()=>s3,VoxtralProcessor:()=>T3,VoxtralRealtimeProcessor:()=>D3,Wav2Vec2Processor:()=>C3,Wav2Vec2ProcessorWithLM:()=>x3,WhisperProcessor:()=>N3});var bt=class extends Ft{constructor(e){super(),this.config=e}static async from_pretrained(e,t={}){let r=await yr(e,Pc,!0,t);return new this(r)}};function Lt(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw new 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.`)}var Rc={};wn(Rc,{ASTFeatureExtractor:()=>NM,ChatterboxFeatureExtractor:()=>wM,ClapFeatureExtractor:()=>yM,CohereAsrFeatureExtractor:()=>MM,DacFeatureExtractor:()=>ym,EncodecFeatureExtractor:()=>Nm,FeatureExtractor:()=>bt,Gemma3nAudioFeatureExtractor:()=>Bm,Gemma4AudioFeatureExtractor:()=>Mm,GraniteSpeechFeatureExtractor:()=>PM,MoonshineFeatureExtractor:()=>RM,ParakeetFeatureExtractor:()=>wm,PyAnnoteFeatureExtractor:()=>Pm,SeamlessM4TFeatureExtractor:()=>kM,SnacFeatureExtractor:()=>OM,SpeechT5FeatureExtractor:()=>GM,VoxtralRealtimeFeatureExtractor:()=>UM,Wav2Vec2FeatureExtractor:()=>FM,WeSpeakerFeatureExtractor:()=>ZM,WhisperFeatureExtractor:()=>KM});async function Dm(e,t){if(me.IS_BROWSER_ENV){if(me.IS_WEBWORKER_ENV)throw new Error("Unable to save a file from a Web Worker.");let r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=e,a.click(),a.remove(),URL.revokeObjectURL(r)}else if(me.IS_FS_AVAILABLE){let r=t.stream(),a=EM.fromWeb(r),n=fM.createWriteStream(e);await $M(a,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function mM(e,t){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let r=await(await Ds(e)).arrayBuffer(),a=new AudioContext({sampleRate:t});typeof t>"u"&&he.warn(`No sampling rate provided, using default of ${a.sampleRate}Hz.`);let n=await a.decodeAudioData(r),s;if(n.numberOfChannels===2){let i=Math.sqrt(2),H=n.getChannelData(0),o=n.getChannelData(1);s=new Float32Array(H.length);for(let _=0;_<n.length;++_)s[_]=i*(H[_]+o[_])/2}else s=n.getChannelData(0);return s}var IM=mM;function Cm(e,t){if(e<1)return new Float64Array;if(e===1)return new Float64Array([1]);let r=1-t,a=2*Math.PI/(e-1),n=new Float64Array(e);for(let s=0;s<e;++s)n[s]=t-r*Math.cos(s*a);return n}function D$(e){return Cm(e,.5)}function SM(e){return Cm(e,.54)}var LM={htk:e=>2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,r=15,a=27/Math.log(6.4))=>e>=t?r+Math.log(e/t)*a:3*e/200};function P_(e,t="htk"){let r=LM[t];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof e=="number"?r(e):e.map(a=>r(a))}var AM={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,r=15,a=Math.log(6.4)/27)=>e>=r?t*Math.exp(a*(e-r)):200*e/3};function gM(e,t="htk"){let r=AM[t];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof e=="number"?r(e):e.map(a=>r(a))}function TM(e,t){let r=Float64Array.from({length:t.length-1},(i,H)=>t[H+1]-t[H]),a=Array.from({length:e.length},()=>new Array(t.length));for(let i=0;i<e.length;++i){let H=a[i];for(let o=0;o<t.length;++o)H[o]=t[o]-e[i]}let n=t.length-2,s=Array.from({length:n},()=>new Array(e.length));for(let i=0;i<e.length;++i){let H=a[i];for(let o=0;o<n;++o){let _=-H[o]/r[o],c=H[o+2]/r[o+1];s[o][i]=Math.max(0,Math.min(_,c))}}return s}function C$(e,t,r){let a=(t-e)/(r-1);return Float64Array.from({length:r},(n,s)=>e+a*s)}function Nr(e,t,r,a,n,s=null,i="htk",H=!1){if(s!==null&&s!=="slaney")throw new Error('norm must be one of null or "slaney"');if(e<2)throw new Error(`Require num_frequency_bins: ${e} >= 2`);if(r>a)throw new Error(`Require min_frequency: ${r} <= max_frequency: ${a}`);let o=P_(r,i),_=P_(a,i),c=C$(o,_,t+2),l=gM(c,i),d;if(H){let $=n/((e-1)*2);d=P_(Float64Array.from({length:e},(m,S)=>S*$),i),l=c}else d=C$(0,Math.floor(n/2),e);let h=TM(d,l);if(s!==null&&s==="slaney")for(let $=0;$<t;++$){let m=h[$],S=2/(l[$+2]-l[$]);for(let I=0;I<e;++I)m[I]*=S}return h}function bM(e,t,r){let a=new e.constructor(e.length+t+r),n=e.length-1;for(let s=0;s<e.length;++s)a[t+s]=e[s];for(let s=1;s<=t;++s)a[t-s]=e[nH(s,n)];for(let s=1;s<=r;++s)a[n+t+s]=e[nH(n-s,n)];return a}function xm(e,t,r,a,n){if(r<=0)throw new Error("reference must be greater than zero");if(a<=0)throw new Error("min_value must be greater than zero");r=Math.max(a,r);let s=Math.log10(r);for(let i=0;i<e.length;++i)e[i]=t*Math.log10(Math.max(a,e[i])-s);if(n!==null){if(n<=0)throw new Error("db_range must be greater than zero");let i=et(e)[0]-n;for(let H=0;H<e.length;++H)e[H]=Math.max(e[H],i)}return e}function vM(e,t=1,r=1e-5,a=null){return xm(e,20,t,r,a)}function DM(e,t=1,r=1e-10,a=null){return xm(e,10,t,r,a)}async function Br(e,t,r,a,{fft_length:n=null,power:s=1,center:i=!0,pad_mode:H="reflect",onesided:o=!0,preemphasis:_=null,preemphasis_htk_flavor:c=!0,mel_filters:l=null,mel_floor:d=1e-10,log_mel:h=null,max_log_mel:$=null,reference:m=1,min_value:S=1e-10,db_range:I=null,remove_dc_offset:T=null,min_num_frames:D=null,max_num_frames:v=null,do_pad:C=!0,transpose:R=!1,mel_offset:A=0,mel_floor_mode:U="clamp"}={}){let Z=t.length;if(n===null&&(n=r),r>n)throw Error(`frame_length (${r}) may not be larger than fft_length (${n})`);if(Z!==r)throw new Error(`Length of the window (${Z}) must equal frame_length (${r})`);if(a<=0)throw new Error("hop_length must be greater than zero");if(s===null&&l!==null)throw new Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!c)throw new Error("`preemphasis_htk_flavor=false` is not currently supported.");if(i){let J=Math.floor(r/2);switch(H){case"reflect":{e=bM(e,J,J);break}case"constant":{let Ie=new e.constructor(e.length+2*J);Ie.set(e,J),e=Ie;break}case"semicausal":{let Ie=new e.constructor(e.length+J);Ie.set(e,J),e=Ie;break}default:throw new Error(`pad_mode="${H}" not implemented yet.`)}}let j=Math.floor(1+Math.floor((e.length-r)/a));D!==null&&j<D&&(j=D);let z=o?Math.floor(n/2)+1:n,X=j,q=j;v!==null&&(v>j?C&&(q=v):q=X=v);let G=new SB(n),y=new Float64Array(n),Q=new Float64Array(G.outputBufferSize),_e=new Float32Array(z*q);for(let J=0;J<X;++J){let Ie=J*a,Ze=Math.min(e.length-Ie,r);Ze!==r&&y.fill(0,0,r);for(let oe=0;oe<Ze;++oe)y[oe]=e[Ie+oe];if(T){let oe=0;for(let Ue=0;Ue<Ze;++Ue)oe+=y[Ue];let Ct=oe/Ze;for(let Ue=0;Ue<Ze;++Ue)y[Ue]-=Ct}if(_!==null){for(let oe=Ze-1;oe>=1;--oe)y[oe]-=_*y[oe-1];y[0]*=1-_}for(let oe=0;oe<t.length;++oe)y[oe]*=t[oe];G.realTransform(Q,y);for(let oe=0;oe<z;++oe){let Ct=oe<<1;_e[oe*q+J]=Q[Ct]**2+Q[Ct+1]**2}}if(s!==null&&s!==2){let J=s/2;for(let Ie=0;Ie<_e.length;++Ie)_e[Ie]**=J}let M=l.length,k=await d2(new K("float32",l.flat(),[M,z]),new K("float32",_e,[z,q]));R&&(k=k.transpose(1,0));let F=k.data;if(U==="add")for(let J=0;J<F.length;++J)F[J]=A+F[J]+d;else for(let J=0;J<F.length;++J)F[J]=A+Math.max(d,F[J]);if(s!==null&&h!==null){let J=Math.min(F.length,X*M);switch(h){case"log":for(let Ie=0;Ie<J;++Ie)F[Ie]=Math.log(F[Ie]);break;case"log10":for(let Ie=0;Ie<J;++Ie)F[Ie]=Math.log10(F[Ie]);break;case"log10_max_norm":{for(let oe=0;oe<J;++oe)F[oe]=Math.log10(F[oe]);let Ze=($??et(F)[0])-8;for(let oe=0;oe<J;++oe)F[oe]=(Math.max(F[oe],Ze)+4)/4;break}case"dB":if(s===1)vM(F,m,S,I);else if(s===2)DM(F,m,S,I);else throw new Error(`Cannot use log_mel option '${h}' with power ${s}`);break;default:throw new Error(`log_mel must be one of null, 'log', 'log10', 'log10_max_norm', or 'dB'. Got '${h}'`)}}return k}function Yr(e,t,{periodic:r=!0,frame_length:a=null,center:n=!0}={}){let s=r?e+1:e,i;switch(t){case"boxcar":i=new Float64Array(s).fill(1);break;case"hann":case"hann_window":i=D$(s);break;case"hamming":i=SM(s);break;case"povey":i=D$(s).map(_=>Math.pow(_,.85));break;default:throw new Error(`Unknown window type ${t}.`)}if(r&&(i=i.subarray(0,e)),a===null||e===a)return i;if(e>a)throw new Error(`Length of the window (${e}) may not be larger than frame_length (${a})`);let H=new Float64Array(a),o=n?Math.floor((a-e)/2):0;return H.set(i,o),H}function CM(e,t){let r=e.reduce((s,i)=>s+i.length,0),a=new ArrayBuffer(44),n=new DataView(a);return qi(n,0,"RIFF"),n.setUint32(4,36+r*4,!0),qi(n,8,"WAVE"),qi(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,3,!0),n.setUint16(22,1,!0),n.setUint32(24,t,!0),n.setUint32(28,t*4,!0),n.setUint16(32,4,!0),n.setUint16(34,32,!0),qi(n,36,"data"),n.setUint32(40,r*4,!0),new Blob([a,...e.map(s=>s.buffer)],{type:"audio/wav"})}function qi(e,t,r){for(let a=0;a<r.length;++a)e.setUint8(t+a,r.charCodeAt(a))}var xM=class{constructor(e,t){this.audio=e,this.sampling_rate=t}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array(0);if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((a,n)=>a+n.length,0),t=new Float32Array(e),r=0;for(let a of this.audio)t.set(a,r),r+=a.length;return t}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),CM(e,this.sampling_rate)}async save(e){return Dm(e,this.toBlob())}},NM=class extends bt{constructor(e){super(e);let t=this.config.sampling_rate,r=Nr(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);this.mel_filters=r,this.window=Yr(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return Br(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){Lt(e,"ASTFeatureExtractor");let t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let r=this.std*2,a=t.data;for(let n=0;n<a.length;++n)a[n]=(a[n]-this.mean)/r}return{input_values:t.unsqueeze_(0)}}},Nm=class extends bt{async _call(e){Lt(e,"EncodecFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=this.config.feature_size;if(e.length%t!==0)throw new Error(`The length of the audio data must be a multiple of the number of channels (${t}).`);let r=[1,t,e.length/t];return{input_values:new K("float32",e,r)}}},wM=class extends bt{async _call(e){Lt(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,e.length];return{input_values:new K("float32",e,t)}}},yM=class extends bt{constructor(e){super(e),this.mel_filters=Nr(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,null,"htk"),this.mel_filters_slaney=Nr(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,"slaney","slaney"),this.window=Yr(this.config.fft_window_size,"hann")}async _get_input_mel(e,t,r,a){let n,s=!1,i=e.length-t;if(i>0)if(r==="rand_trunc"){s=!0;let H=Math.floor(LH.random()*(i+1));e=e.subarray(H,H+t),n=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw new Error(`Truncation strategy "${r}" not implemented`);else{if(i<0){let H=new Float64Array(t);if(H.set(e),a==="repeat")for(let o=e.length;o<t;o+=e.length)H.set(e.subarray(0,Math.min(e.length,t-o)),o);else if(a==="repeatpad")for(let o=e.length;o<-i;o+=e.length)H.set(e,o);e=H}if(r==="fusion")throw new Error(`Truncation strategy "${r}" not implemented`);n=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return n.unsqueeze_(0)}async _extract_fbank_features(e,t,r=null){return Br(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:t,log_mel:"dB",max_num_frames:r,do_pad:!1,transpose:!0})}async _call(e,{max_length:t=null}={}){return Lt(e,"ClapFeatureExtractor"),{input_features:(await this._get_input_mel(e,t??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}},BM=1e-5,wm=class extends bt{constructor(e){super(e),this.config.mel_filters??=Nr(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,this.config.sampling_rate/2,this.config.sampling_rate,"slaney","slaney");let t=Yr(this.config.win_length,"hann",{periodic:!1});this.window=new Float64Array(this.config.n_fft);let r=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(t,r)}async _extract_fbank_features(e){let t=this.config.preemphasis;e=new Float64Array(e);for(let a=e.length-1;a>=1;--a)e[a]-=t*e[a-1];return await Br(e,this.window,this.window.length,this.config.hop_length,{fft_length:this.config.n_fft,power:2,mel_filters:this.config.mel_filters,log_mel:"log",mel_floor:-1/0,pad_mode:"constant",center:!0,transpose:!0,mel_offset:2**-24})}async _call(e){Lt(e,"ParakeetFeatureExtractor");let t=await this._extract_fbank_features(e),r=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),a=t.data;a.fill(0,r*t.dims[1]);let[n,s]=t.dims,i=new Float64Array(s),H=new Float64Array(s);for(let c=0;c<r;++c){let l=c*s;for(let d=0;d<s;++d){let h=a[l+d];i[d]+=h,H[d]+=h*h}}let o=r>1?r-1:1;for(let c=0;c<s;++c){let l=i[c]/r,d=(H[c]-r*l*l)/o,$=1/(Math.sqrt(d)+BM);for(let m=0;m<r;++m){let S=m*s+c;a[S]=(a[S]-l)*$}}let _=new BigInt64Array(n);return _.fill(1n,0,r),{input_features:t.unsqueeze_(0),attention_mask:new K("int64",_,[1,n])}}},MM=class extends wm{_apply_dither(e){let t=this.config.dither??0;if(t<=0)return e;let r=new SH(e.length);for(let a=0;a<e.length;++a)e[a]+=t*r.gauss();return e}split_audio(e){let t=this.config.max_audio_clip_s??35,r=this.config.overlap_chunk_second??5,a=this.config.min_energy_window_samples??1600,n=this.config.sampling_rate,s=Math.max(1,Math.round(t*n)),i=Math.max(1,Math.round(r*n));if(e.length<=s)return[e];let H=[],o=0,_=e.length;for(;o<_;){if(o+s>=_){H.push(e.slice(o,_));break}let c=Math.max(o,o+s-i),l=Math.min(o+s,_),d;l<=c?d=o+s:d=this._find_split_point_energy(e,c,l,a),d=Math.max(o+1,Math.min(d,_)),H.push(e.slice(o,d)),o=d}return H}_find_split_point_energy(e,t,r,a){let n=r-t;if(n<=a)return Math.floor((t+r)/2);let s=1/0,i=t,H=n-a;for(let o=0;o<=H;o+=a){let _=0;for(let c=0;c<a;++c){let l=e[t+o+c];_+=l*l}_=Math.sqrt(_/a),_<s&&(s=_,i=t+o)}return i}async _call(e){Lt(e,"CohereAsrFeatureExtractor");let t=new Float64Array(e);return this._apply_dither(t),super._call(t)}},ym=class extends Nm{},Bm=class extends bt{constructor(e){super(e);let{fft_length:t,feature_size:r,min_frequency:a,max_frequency:n,sampling_rate:s,frame_length:i}=this.config,H=Nr(Math.floor(1+t/2),r,a,n,s,null,"htk",!1);this.mel_filters=H,this.window=Yr(i,"hann")}async _extract_fbank_features(e,t){return Br(e,this.window,this.config.frame_length,this.config.hop_length,{fft_length:this.config.fft_length,center:!1,onesided:!0,preemphasis:this.config.preemphasis,preemphasis_htk_flavor:this.config.preemphasis_htk_flavor,mel_filters:this.mel_filters,log_mel:"log",mel_floor:this.config.mel_floor,remove_dc_offset:!1,transpose:!0})}async _call(e,{max_length:t=48e4,truncation:r=!0,padding:a=!0,pad_to_multiple_of:n=128}={}){if(Lt(e,"Gemma3nAudioFeatureExtractor"),r&&e.length>t&&(e=e.slice(0,t)),a&&e.length%n!==0){let H=n-e.length%n,o=new Float64Array(e.length+H);o.set(e),this.config.padding_value!==0&&o.fill(this.config.padding_value,e.length),e=o}let s=await this._extract_fbank_features(e,this.config.max_length),i=Tt([1,s.dims[0]],!0);return{input_features:s.unsqueeze_(0),input_features_mask:i}}},Mm=class extends Bm{async _extract_fbank_features(e,t){let{frame_length:r,hop_length:a,fft_length:n}=this.config,s=Math.floor(r/2),i=Math.floor((e.length+s-(r+1))/a)+1;return Br(e,this.window,r,a,{fft_length:n,center:!0,pad_mode:"semicausal",onesided:!0,preemphasis:this.config.preemphasis,preemphasis_htk_flavor:this.config.preemphasis_htk_flavor,mel_filters:this.mel_filters,log_mel:"log",mel_floor:this.config.mel_floor,mel_floor_mode:"add",remove_dc_offset:!1,transpose:!0,max_num_frames:i})}async _call(e,t={}){Lt(e,"Gemma4AudioFeatureExtractor");let r=e.length,a=await super._call(e,t),{input_features:n}=a,[,s,i]=n.dims,{frame_length:H,hop_length:o}=this.config,_=Math.floor(H/2),c=H+1,l=new Uint8Array(r+_+(t.pad_to_multiple_of??128));l.fill(1,_,_+r);let d=new Uint8Array(s);for(let $=0;$<s;++$)d[$]=l[$*o+c-1]?1:0;let h=n.data;for(let $=0;$<s;++$)d[$]||h.fill(0,$*i,($+1)*i);return a.input_features_mask=new K("bool",d,[1,s]),a}},PM=class extends bt{constructor(e){super(e);let{n_fft:t,win_length:r,n_mels:a,sample_rate:n}=e.melspec_kwargs;this.mel_filters=Nr(Math.floor(1+t/2),a,0,n/2,n,null,"htk");let s=Yr(r,"hann");this.window=new Float64Array(t);let i=Math.floor((t-r)/2);this.window.set(s,i)}async _call(e){Lt(e,"GraniteSpeechFeatureExtractor");let{n_fft:t,hop_length:r,n_mels:a}=this.config.melspec_kwargs,n=1+Math.floor((e.length-1)/r),s=n-n%2;return{input_features:(await Br(e,this.window,t,r,{power:2,mel_filters:this.mel_filters,log_mel:"log10_max_norm",transpose:!0,max_num_frames:s,do_pad:!1})).view(-1,2*a).unsqueeze_(0)}}},RM=class extends bt{async _call(e){Lt(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,e.length];return{input_values:new K("float32",e,t)}}},Pm=class extends bt{async _call(e){Lt(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,1,e.length];return{input_values:new K("float32",e,t)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,t){let r=t/this.samples_to_frames(t)/this.config.sampling_rate,a=[];for(let n of e.tolist()){let s=[],i=-1;for(let H=0;H<n.length;++H){let o=St(n[H]),[_,c]=et(o),[l,d]=[H,H+1];c!==i?(i=c,s.push({id:c,start:l,end:d,score:_})):(s.at(-1).end=d,s.at(-1).score+=_)}a.push(s.map(({id:H,start:o,end:_,score:c})=>({id:H,start:o*r,end:_*r,confidence:c/(_-o)})))}return a}},kM=class extends bt{constructor(e){super(e);let t=this.config.sampling_rate,r=Nr(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);this.mel_filters=r,this.window=Yr(400,"povey",{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map(r=>r*32768),Br(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:a=!0,return_attention_mask:n=!0}={}){Lt(e,"SeamlessM4TFeatureExtractor");let s=await this._extract_fbank_features(e,this.config.max_length);if(a){let[h,$]=s.dims,m=s.data;for(let S=0;S<$;++S){let I=0;for(let C=0;C<h;++C)I+=m[C*$+S];let T=I/h,D=0;for(let C=0;C<h;++C)D+=(m[C*$+S]-T)**2;D/=h-1;let v=Math.sqrt(D+1e-7);for(let C=0;C<h;++C){let R=C*$+S;m[R]=(m[R]-T)/v}}}let i;if(t){let[h,$]=s.dims,m=s.data,S=h%r;if(S>0){let I=new Float32Array($*(h+S));I.set(m),I.fill(this.config.padding_value,m.length);let T=h+S;s=new K(s.type,I,[T,$]),n&&(i=new K("int64",new BigInt64Array(T),[1,T]),i.data.fill(1n,0,h))}}let[H,o]=s.dims,_=this.config.stride;if(H%_!==0)throw new Error(`The number of frames (${H}) must be a multiple of the stride (${_}).`);let l=s.view(1,Math.floor(H/_),o*_),d={input_features:l};if(n){let h=l.dims[1],$=new BigInt64Array(h);if(i){let m=i.data;for(let S=1,I=0;S<H;S+=_,++I)$[I]=m[S]}else $.fill(1n);d.attention_mask=new K("int64",$,[1,h])}return d}},OM=class extends ym{},GM=class extends bt{},FM=class extends bt{_zero_mean_unit_var_norm(e){let r=e.reduce((n,s)=>n+s,0)/e.length,a=e.reduce((n,s)=>n+(s-r)**2,0)/e.length;return e.map(n=>(n-r)/Math.sqrt(a+1e-7))}async _call(e){Lt(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 K("float32",t,r),attention_mask:new K("int64",new BigInt64Array(t.length).fill(1n),r)}}},ZM=class extends bt{constructor(e){super(e);let t=this.config.sampling_rate,r=Nr(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);this.mel_filters=r,this.window=Yr(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(t=>t*32768),Br(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,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){Lt(e,"WeSpeakerFeatureExtractor");let t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let r=t.mean(1).data,a=t.data,[n,s,i]=t.dims;for(let H=0;H<n;++H){let o=H*s*i,_=H*i;for(let c=0;c<s;++c){let l=o+c*i;for(let d=0;d<i;++d)a[l+d]-=r[_+d]}}}return{input_features:t}}},UM=class extends bt{constructor(e){super(e),this.config.mel_filters??=Nr(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=Yr(this.config.n_fft,"hann")}async _extract_fbank_features(e,{center:t=!0}={}){let{n_fft:r,hop_length:a,mel_filters:n,global_log_mel_max:s}=this.config,i=Math.floor(t?e.length/a:(e.length-r)/a);return await Br(e,this.window,r,a,{power:2,mel_filters:n,log_mel:"log10_max_norm",max_log_mel:s,center:t,max_num_frames:i,do_pad:!1})}async _call(e,{center:t=!0}={}){return Lt(e,"VoxtralRealtimeFeatureExtractor"),{input_features:(await this._extract_fbank_features(e,{center:t})).unsqueeze_(0)}}},KM=class extends bt{constructor(e){super(e),this.config.mel_filters??=Nr(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=Yr(this.config.n_fft,"hann")}async _extract_fbank_features(e){return await Br(e,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10_max_norm",max_num_frames:Math.min(Math.floor(e.length/this.config.hop_length),this.config.nb_max_frames)})}async _call(e,{max_length:t=null}={}){Lt(e,"WhisperFeatureExtractor");let r,a=t??this.config.n_samples;return e.length>a?(e.length>this.config.n_samples&&he.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`."),r=e.slice(0,a)):(r=new Float32Array(a),r.set(e)),{input_features:(await this._extract_fbank_features(r)).unsqueeze_(0)}}},tr=class{static async from_pretrained(e,t={}){let r=await yr(e,Pc,!0,t),a=r.feature_extractor_type,n=Rc[a];if(!n)throw new Error(`Unknown feature_extractor_type: '${a}'. Please report this at ${AH}.`);return new n(r)}},WM=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;async _call(e,t=null){let r=this.tokenizer(e),a=t?await this.feature_extractor(t):{};return{...r,...a}}},VM=new Set(["ja","zh"]),jM=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;static uses_processor_config=!0;get_decoder_prompt_ids(e="en"){let t=["\u2581","<|startofcontext|>","<|startoftranscript|>","<|emo:undefined|>",`<|${e}|>`,`<|${e}|>`,"<|pnc|>","<|noitn|>","<|notimestamp|>","<|nodiarize|>"];return this.tokenizer.convert_tokens_to_ids(t)}static join_chunks(e,t="en"){let r=e.filter(s=>s&&s.trim());if(r.length===0)return"";let a=VM.has(t)?"":" ";return[r[0].trimEnd(),...r.slice(1).map(s=>s.trim())].join(a)}async _call(e){return await this.feature_extractor(e)}},Ma,Rm,da;if(me.IS_WEB_ENV)Ma=(e,t)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this environment.");return new self.OffscreenCanvas(e,t)},da=self.createImageBitmap,Rm=self.ImageData;else if(dH.default)da=async e=>{let r=(await e.metadata()).channels,{data:a,info:n}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),s=new qt(new Uint8ClampedArray(a),n.width,n.height,n.channels);return r!==void 0&&r!==n.channels&&s.convert(r),s};else throw new Error("Unable to load image processing library.");var qM={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},XM=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),qt=class Cr{constructor(t,r,a,n){this.data=t,this.width=r,this.height=a,this.channels=n}get size(){return[this.width,this.height]}static async read(t){if(t instanceof Cr)return t;if(typeof t=="string"||t instanceof URL)return await this.fromURL(t);if(t instanceof Blob)return await this.fromBlob(t);if(typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return this.fromCanvas(t);throw new Error(`Unsupported input type: ${typeof t}`)}static fromCanvas(t){if(!me.IS_WEB_ENV)throw new Error("fromCanvas() is only supported in browser environments.");let a=t.getContext("2d").getImageData(0,0,t.width,t.height).data;return new Cr(a,t.width,t.height,4)}static async fromURL(t){let r=await Ds(t);if(r.status!==200)throw new Error(`Unable to read image from "${t}" (${r.status} ${r.statusText})`);let a=await r.blob();return this.fromBlob(a)}static async fromBlob(t){if(me.IS_WEB_ENV){let r=await da(t),a=Ma(r.width,r.height).getContext("2d");return a.drawImage(r,0,0),new this(a.getImageData(0,0,r.width,r.height).data,r.width,r.height,4)}else{let r=(0,dH.default)(await t.arrayBuffer());return await da(r)}}static fromTensor(t,r="CHW"){if(t.dims.length!==3)throw new Error(`Tensor should have 3 dimensions, but has ${t.dims.length} dimensions.`);if(r==="CHW")t=t.transpose(1,2,0);else if(r!=="HWC")throw new Error(`Unsupported channel format: ${r}`);if(!(t.data instanceof Uint8ClampedArray||t.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${t.type}`);switch(t.dims[2]){case 1:case 2:case 3:case 4:return new Cr(t.data,t.dims[1],t.dims[0],t.dims[2]);default:throw new Error(`Unsupported number of channels: ${t.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let t=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let r=0,a=0;r<this.data.length;r+=this.channels){let n=this.data[r],s=this.data[r+1],i=this.data[r+2];t[a++]=Math.round(.2989*n+.587*s+.114*i)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(t,this.width,this.height,1)}rgb(){if(this.channels===3)return this;let t=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let r=0,a=0;r<this.data.length;++r)t[a++]=this.data[r],t[a++]=this.data[r],t[a++]=this.data[r];break;case 4:for(let r=0,a=0;r<this.data.length;r+=4)t[a++]=this.data[r],t[a++]=this.data[r+1],t[a++]=this.data[r+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(t,this.width,this.height,3)}rgba(){if(this.channels===4)return this;let t=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let r=0,a=0;r<this.data.length;++r)t[a++]=this.data[r],t[a++]=this.data[r],t[a++]=this.data[r],t[a++]=255;break;case 3:for(let r=0,a=0;r<this.data.length;r+=3)t[a++]=this.data[r],t[a++]=this.data[r+1],t[a++]=this.data[r+2],t[a++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(t,this.width,this.height,4)}putAlpha(t){if(t.width!==this.width||t.height!==this.height)throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${t.width}x${t.height}`);if(t.channels!==1)throw new Error(`Expected mask to have 1 channel, but got ${t.channels}`);let r=this.data,a=t.data,n=this.width*this.height;if(this.channels===3){let s=new Uint8ClampedArray(n*4);for(let i=0,H=0,o=0;i<n;++i)s[o++]=r[H++],s[o++]=r[H++],s[o++]=r[H++],s[o++]=a[i];return this._update(s,this.width,this.height,4)}else if(this.channels===4){for(let s=0;s<n;++s)r[4*s+3]=a[s];return this}throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(t,r,{resample:a=2}={}){if(this.width===t&&this.height===r)return this;let n=qM[a]??a,s=S1(t),i=S1(r);if(s&&i)return this;if(s?t=r/this.height*this.width:i&&(r=t/this.width*this.height),me.IS_WEB_ENV){let H=this.channels,o=this.toCanvas(),_=Ma(t,r).getContext("2d");return _.drawImage(o,0,0,t,r),new Cr(_.getImageData(0,0,t,r).data,t,r,4).convert(H)}else{let H=this.toSharp();switch(n){case"box":case"hamming":(n==="box"||n==="hamming")&&(he.warn(`Resampling method ${n} is not yet supported. Using bilinear instead.`),n="bilinear");case"nearest":case"bilinear":case"bicubic":H=H.affine([t/this.width,0,0,r/this.height],{interpolator:n});break;case"lanczos":H=H.resize({width:t,height:r,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${n} is not supported.`)}return await da(H)}}async pad([t,r,a,n]){if(t=Math.max(t,0),r=Math.max(r,0),a=Math.max(a,0),n=Math.max(n,0),t===0&&r===0&&a===0&&n===0)return this;if(me.IS_WEB_ENV){let s=this.channels,i=this.toCanvas(),H=this.width+t+r,o=this.height+a+n,_=Ma(H,o).getContext("2d");return _.drawImage(i,0,0,this.width,this.height,t,a,this.width,this.height),new Cr(_.getImageData(0,0,H,o).data,H,o,4).convert(s)}else{let s=this.toSharp().extend({left:t,right:r,top:a,bottom:n});return await da(s)}}async crop([t,r,a,n]){if(t=Math.max(t,0),r=Math.max(r,0),a=Math.min(a,this.width-1),n=Math.min(n,this.height-1),t===0&&r===0&&a===this.width-1&&n===this.height-1)return this;let s=a-t+1,i=n-r+1;if(me.IS_WEB_ENV){let H=this.channels,o=this.toCanvas(),_=Ma(s,i).getContext("2d");return _.drawImage(o,t,r,s,i,0,0,s,i),new Cr(_.getImageData(0,0,s,i).data,s,i,4).convert(H)}else{let H=this.toSharp().extract({left:t,top:r,width:s,height:i});return await da(H)}}async center_crop(t,r){if(this.width===t&&this.height===r)return this;let a=(this.width-t)/2,n=(this.height-r)/2;if(me.IS_WEB_ENV){let s=this.channels,i=this.toCanvas(),H=Ma(t,r).getContext("2d"),o=0,_=0,c=0,l=0;return a>=0?o=a:c=-a,n>=0?_=n:l=-n,H.drawImage(i,o,_,t,r,c,l,t,r),new Cr(H.getImageData(0,0,t,r).data,t,r,4).convert(s)}else{let s=this.toSharp();if(a>=0&&n>=0)s=s.extract({left:Math.floor(a),top:Math.floor(n),width:t,height:r});else if(a<=0&&n<=0){let i=Math.floor(-n),H=Math.floor(-a);s=s.extend({top:i,left:H,right:t-this.width-H,bottom:r-this.height-i})}else{let i=[0,0],H=0;n<0?(i[0]=Math.floor(-n),i[1]=r-this.height-i[0]):H=Math.floor(n);let o=[0,0],_=0;a<0?(o[0]=Math.floor(-a),o[1]=t-this.width-o[0]):_=Math.floor(a),s=s.extend({top:i[0],bottom:i[1],left:o[0],right:o[1]}).extract({left:_,top:H,width:t,height:r})}return await da(s)}}async toBlob(t="image/png",r=1){if(!me.IS_WEB_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:t,quality:r})}toTensor(t="CHW"){let r=new K("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if(t!=="HWC")if(t==="CHW")r=r.permute(2,0,1);else throw new Error(`Unsupported channel format: ${t}`);return r}toCanvas(){if(!me.IS_WEB_ENV)throw new Error("toCanvas() is only supported in browser environments.");let t=this.clone().rgba(),r=Ma(t.width,t.height),a=new Rm(t.data,t.width,t.height);return r.getContext("2d").putImageData(a,0,0),r}split(){let{data:t,width:r,height:a,channels:n}=this,s=t.constructor,i=t.length/n,H=Array.from({length:n},()=>new s(i));for(let o=0;o<i;++o){let _=n*o;for(let c=0;c<n;++c)H[c][o]=t[_+c]}return H.map(o=>new Cr(o,r,a,1))}_update(t,r,a,n=null){return this.data=t,this.width=r,this.height=a,n!==null&&(this.channels=n),this}clone(){return new Cr(this.data.slice(),this.width,this.height,this.channels)}convert(t){if(this.channels===t)return this;switch(t){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(t){if(me.IS_WEB_ENV){if(me.IS_WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");let r=t.split(".").pop().toLowerCase(),a=XM.get(r)??"image/png",n=await this.toBlob(a);return Dm(t,n)}else if(me.IS_FS_AVAILABLE)await this.toSharp().toFile(t);else throw new Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(me.IS_WEB_ENV)throw new Error("toSharp() is only supported in server-side environments.");return(0,dH.default)(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},x7=qt.read.bind(qt);function x$(e,t,r=0,a=null){let n=e/t,s=AB(n)*t;return a!==null&&s>a&&(s=Math.floor(n)*t),s<r&&(s=Math.ceil(n)*t),s}function N$([e,t],r){return[Math.max(Math.floor(e/r),1)*r,Math.max(Math.floor(t/r),1)*r]}function km([e,t,r,a]){return[e-r/2,t-a/2,e+r/2,t+a/2]}function gH(e,t=.5,r=null,a=!1){let n=e.logits,s=e.pred_boxes,[i,H,o]=n.dims;if(r!==null&&r.length!==i)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let _=[];for(let c=0;c<i;++c){let l=r!==null?r[c]:null,d={boxes:[],classes:[],scores:[]},h=n[c],$=s[c];for(let m=0;m<H;++m){let S=h[m],I=[],T;if(a){T=S.sigmoid().data;for(let D=0;D<T.length;++D)T[D]>t&&I.push(D)}else{let D=et(S.data)[1];if(D===o-1||(T=St(S.data),T[D]<t))continue;I.push(D)}for(let D of I){let v=$[m].data;v=km(v),l!==null&&(v=v.map((C,R)=>C*l[(R+1)%2])),d.boxes.push(v),d.classes.push(D),d.scores.push(T[D])}}_.push(d)}return _}function Om(e,t=null){let r=e.logits,a=r.dims[0];if(t!==null&&t.length!==a)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let n=[];for(let s=0;s<a;++s){let i=t!==null?t[s]:null,H=r[s];i!==null&&(H=fm(H,i,"bilinear",!1));let[o,_]=i??H.dims.slice(-2),c=new K("int32",new Int32Array(o*_),[o,_]),l=H[0].data,d=c.data;for(let m=1;m<H.dims[0];++m){let S=H[m].data;for(let I=0;I<S.length;++I)S[I]>l[I]&&(l[I]=S[I],d[I]=m)}let h=new Array(H.dims[0]);for(let m=0;m<d.length;++m){let S=d[m];h[S]=S}let $=h.filter(m=>m!==void 0);n.push({segmentation:c,labels:$})}return n}function zM(e,t,r,a){let n=[],s=[],i=[];for(let H=0;H<e.dims[0];++H){let o=e[H],_=t[H],c=et(o.data)[1];if(c===a)continue;let d=St(o.data)[c];d>r&&(n.push(_),s.push(d),i.push(c))}return[n,s,i]}function JM(e,t,r,a=.5,n=.8){let s=[],i=0,H=0,o=t[r].data;for(let c=0;c<e.length;++c)e[c]===r&&(s.push(c),++i),o[c]>=a&&++H;let _=i>0&&H>0;return _&&(_=i/H>n),[_,s]}function QM(e,t,r,a,n,s=null,i=null){let[H,o]=i??e[0].dims,_=new K("int32",new Int32Array(H*o),[H,o]),c=[];if(i!==null)for(let m=0;m<e.length;++m)e[m]=fm(e[m],i,"bilinear",!1);let l=new Int32Array(e[0].data.length),d=new Float32Array(e[0].data.length);for(let m=0;m<e.length;++m){let S=t[m],I=e[m].data;for(let T=0;T<I.length;++T)I[T]*=S,I[T]>d[T]&&(l[T]=m,d[T]=I[T])}let h=0,$=_.data;for(let m=0;m<r.length;++m){let S=r[m],[I,T]=JM(l,e,m,a,n);if(I){++h;for(let D of T)$[D]=h;c.push({id:h,label_id:S,score:t[m]})}}return[_,c]}function kc(e,t,r=28,a=3136,n=784*1280,s=1){if(e<r||t<r){let o=Math.max(r/e,r/t);e=Math.round(e*o),t=Math.round(t*o)}if(Math.max(e,t)/Math.min(e,t)>200)throw new Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(e,t)/Math.min(e,t)}`);let i=Math.round(e/r)*r,H=Math.round(t/r)*r;if(s*i*H>n){let o=Math.sqrt(s*e*t/n);i=Math.max(r,Math.floor(e/o/r)*r),H=Math.max(r,Math.floor(t/o/r)*r)}else if(s*i*H<a){let o=Math.sqrt(a/(s*e*t));i=Math.ceil(e*o/r)*r,H=Math.ceil(t*o/r)*r}return[H,i]}function Gm(e,t=.5,r=.5,a=.8,n=null,s=null){n===null&&(he.warn("`label_ids_to_fuse` unset. No instance will be fused."),n=new Set);let i=e.class_queries_logits??e.logits,o=(e.masks_queries_logits??e.pred_masks).sigmoid(),[_,c,l]=i.dims;if(l-=1,s!==null&&s.length!==_)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let d=[];for(let h=0;h<_;++h){let $=s!==null?s[h]:null,m=i[h],S=o[h],[I,T,D]=zM(m,S,t,l);if(D.length===0){let[R,A]=$??S.dims.slice(-2),U=new K("int32",new Int32Array(R*A).fill(-1),[R,A]);d.push({segmentation:U,segments_info:[]});continue}let[v,C]=QM(I,T,D,r,a,n,$);d.push({segmentation:v,segments_info:C})}return d}function Fm(e,t=.5,r=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var fe=class extends Ft{constructor(e){super(),this.image_mean=e.image_mean??e.mean,this.image_std=e.image_std??e.std,this.resample=e.resample??2,this.do_rescale=e.do_rescale??!0,this.rescale_factor=e.rescale_factor??1/255,this.do_normalize=e.do_normalize,this.do_thumbnail=e.do_thumbnail,this.size=e.size??e.image_size,this.do_resize=e.do_resize??this.size!==void 0,this.size_divisibility=e.size_divisibility??e.size_divisor,this.do_center_crop=e.do_center_crop,this.crop_size=e.crop_size,this.do_convert_rgb=e.do_convert_rgb??!0,this.do_crop_margin=e.do_crop_margin,this.pad_size=e.pad_size,this.do_pad=e.do_pad,this.min_pixels=e.min_pixels,this.max_pixels=e.max_pixels,this.do_pad&&!this.pad_size&&!this.size_divisibility&&this.size&&this.size.width!==void 0&&this.size.height!==void 0&&(this.pad_size=this.size),this.do_flip_channel_order=e.do_flip_channel_order??!1,this.config=e}async thumbnail(e,t,r=2){let a=e.height,n=e.width,s=t.height,i=t.width,H=Math.min(a,s),o=Math.min(n,i);return H===a&&o===n?e:(a>n?o=Math.floor(n*H/a):n>a&&(H=Math.floor(a*o/n)),await e.resize(o,H,{resample:r}))}async crop_margin(e,t=200){let r=e.clone().grayscale(),a=W_(r.data)[0],s=et(r.data)[0]-a;if(s===0)return e;let i=t/255,H=r.width,o=r.height,_=0,c=0,l=r.data;for(let d=0;d<r.height;++d){let h=d*r.width;for(let $=0;$<r.width;++$)(l[h+$]-a)/s<i&&(H=Math.min(H,$),o=Math.min(o,d),_=Math.max(_,$),c=Math.max(c,d))}return e=await e.crop([H,o,_,c]),e}pad_image(e,t,r,{mode:a="constant",center:n=!1,constant_values:s=0}={}){let[i,H,o]=t,_,c;if(typeof r=="number"?(_=r,c=r):r==="square"?_=c=Math.max(i,H):(_=r.width,c=r.height),_!==H||c!==i){let l=new Float32Array(_*c*o);if(Array.isArray(s))for(let $=0;$<l.length;++$)l[$]=s[$%o];else s!==0&&l.fill(s);let[d,h]=n?[Math.floor((_-H)/2),Math.floor((c-i)/2)]:[0,0];for(let $=0;$<i;++$){let m=($+h)*_,S=$*H;for(let I=0;I<H;++I){let T=(m+I+d)*o,D=(S+I)*o;for(let v=0;v<o;++v)l[T+v]=e[D+v]}}if(a==="symmetric"){if(n)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let $=i-1,m=H-1;for(let S=0;S<c;++S){let I=S*_,T=nH(S,$)*H;for(let D=0;D<_;++D){if(S<i&&D<H)continue;let v=(I+D)*o,C=(T+nH(D,m))*o;for(let R=0;R<o;++R)l[v+R]=e[C+R]}}}e=l,t=[c,_,o]}return[e,t]}rescale(e){for(let t=0;t<e.length;++t)e[t]=this.rescale_factor*e[t]}get_resize_output_image_size(e,t){let[r,a]=e.size,n,s;if(this.do_thumbnail){let{height:i,width:H}=t;n=Math.min(i,H)}else Number.isInteger(t)?(n=t,s=this.config.max_size??n):t!==void 0&&(n=t.shortest_edge,s=t.longest_edge);if(n!==void 0||s!==void 0){let i=n===void 0?1:Math.max(n/r,n/a),H=r*i,o=a*i,_=s===void 0?1:Math.min(s/H,s/o),c=Math.floor(Number((H*_).toFixed(2))),l=Math.floor(Number((o*_).toFixed(2)));return this.size_divisibility!==void 0&&([c,l]=N$([c,l],this.size_divisibility)),[c,l]}else if(t!==void 0&&t.width!==void 0&&t.height!==void 0){let i=t.width,H=t.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let o=H/a,_=i/r;Math.abs(1-_)<Math.abs(1-o)?o=_:_=o,H=x$(o*a,this.config.ensure_multiple_of),i=x$(_*r,this.config.ensure_multiple_of)}return[i,H]}else{if(this.size_divisibility!==void 0)return N$([r,a],this.size_divisibility);throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(t)}`)}}async resize(e){let[t,r]=this.get_resize_output_image_size(e,this.size);return await e.resize(t,r,{resample:this.resample})}async preprocess(e,{do_normalize:t=null,do_pad:r=null,do_convert_rgb:a=null,do_convert_grayscale:n=null,do_flip_channel_order:s=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[i,H]=e.size;if(a??this.do_convert_rgb?e=e.rgb():n&&(e=e.grayscale()),this.do_resize&&(e=await this.resize(e)),this.do_thumbnail&&(e=await this.thumbnail(e,this.size,this.resample)),this.do_center_crop){let d,h;Number.isInteger(this.crop_size)?(d=this.crop_size,h=this.crop_size):(d=this.crop_size.width,h=this.crop_size.height),e=await e.center_crop(d,h)}let o=[e.height,e.width],_=Float32Array.from(e.data),c=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(_),t??this.do_normalize){let d=this.image_mean;Array.isArray(this.image_mean)||(d=new Array(e.channels).fill(d));let h=this.image_std;if(Array.isArray(this.image_std)||(h=new Array(e.channels).fill(h)),d.length!==e.channels||h.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${d.length}) and \`image_std\` (${h.length}) must match the number of channels in the image (${e.channels}).`);for(let $=0;$<_.length;$+=e.channels)for(let m=0;m<e.channels;++m)_[$+m]=(_[$+m]-d[m])/h[m]}if(r??this.do_pad){if(this.pad_size)[_,c]=this.pad_image(_,[e.height,e.width,e.channels],this.pad_size);else if(this.size_divisibility){let d=Math.ceil(c[1]/this.size_divisibility)*this.size_divisibility,h=Math.ceil(c[0]/this.size_divisibility)*this.size_divisibility;[_,c]=this.pad_image(_,c,{width:d,height:h})}}if(s??this.do_flip_channel_order){if(c[2]!==3)throw new Error("Flipping channel order is only supported for RGB images.");for(let d=0;d<_.length;d+=3){let h=_[d];_[d]=_[d+2],_[d+2]=h}}let l=new K("float32",_,c).permute(2,0,1);return{original_size:[H,i],reshaped_input_size:o,pixel_values:l}}async _call(e,...t){Array.isArray(e)||(e=[e]);let r=await Promise.all(e.map(n=>this.preprocess(n)));return{pixel_values:Xr(r.map(n=>n.pixel_values),0),original_sizes:r.map(n=>n.original_size),reshaped_input_sizes:r.map(n=>n.reshaped_input_size)}}static async from_pretrained(e,t={}){let r=await yr(e,ws,!0,t);return new this(r)}},pH={};wn(pH,{BeitFeatureExtractor:()=>YM,BitImageProcessor:()=>eP,CHMv2ImageProcessor:()=>rP,CLIPFeatureExtractor:()=>aP,CLIPImageProcessor:()=>Zm,ChineseCLIPFeatureExtractor:()=>tP,ConvNextFeatureExtractor:()=>nP,ConvNextImageProcessor:()=>Um,DINOv3ViTImageProcessor:()=>HP,DPTFeatureExtractor:()=>_P,DPTImageProcessor:()=>Vm,DeiTFeatureExtractor:()=>sP,DeiTImageProcessor:()=>Km,DetrFeatureExtractor:()=>iP,DetrImageProcessor:()=>Wm,DonutFeatureExtractor:()=>oP,DonutImageProcessor:()=>Oc,EfficientNetImageProcessor:()=>cP,GLPNFeatureExtractor:()=>hP,Gemma3ImageProcessor:()=>lP,Gemma4ImageProcessor:()=>jm,Glm46VImageProcessor:()=>pP,GroundingDinoImageProcessor:()=>fP,Idefics3ImageProcessor:()=>w$,ImageFeatureExtractor:()=>fe,ImageProcessor:()=>fe,JinaCLIPImageProcessor:()=>$P,Lfm2VlImageProcessor:()=>AP,LlavaOnevisionImageProcessor:()=>gP,Mask2FormerImageProcessor:()=>bP,MaskFormerFeatureExtractor:()=>TP,MaskFormerImageProcessor:()=>Gc,MobileNetV1FeatureExtractor:()=>vP,MobileNetV1ImageProcessor:()=>Xm,MobileNetV2FeatureExtractor:()=>DP,MobileNetV2ImageProcessor:()=>zm,MobileNetV3FeatureExtractor:()=>CP,MobileNetV3ImageProcessor:()=>Jm,MobileNetV4FeatureExtractor:()=>xP,MobileNetV4ImageProcessor:()=>Qm,MobileViTFeatureExtractor:()=>NP,MobileViTImageProcessor:()=>Ym,NougatImageProcessor:()=>wP,OwlViTFeatureExtractor:()=>yP,OwlViTImageProcessor:()=>Fc,Owlv2ImageProcessor:()=>BP,Phi3VImageProcessor:()=>PP,PixtralImageProcessor:()=>RP,PvtImageProcessor:()=>kP,Qwen2VLImageProcessor:()=>qm,RTDetrImageProcessor:()=>OP,Sam2ImageProcessor:()=>O_,Sam3ImageProcessor:()=>O_,SamImageProcessor:()=>O_,SapiensFeatureExtractor:()=>GP,SapiensImageProcessor:()=>eI,SegformerFeatureExtractor:()=>FP,SegformerImageProcessor:()=>tI,SiglipImageProcessor:()=>ZP,SmolVLMImageProcessor:()=>w$,Swin2SRImageProcessor:()=>UP,VLMImageProcessor:()=>EP,ViTFeatureExtractor:()=>KP,ViTImageProcessor:()=>rI,VitMatteImageProcessor:()=>WP,VitPoseImageProcessor:()=>VP,YolosFeatureExtractor:()=>jP,YolosImageProcessor:()=>aI});var YM=class extends fe{},eP=class extends fe{},tP=class extends fe{},rP=class extends fe{},Zm=class extends fe{},aP=class extends Zm{},Um=class extends fe{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let t=this.size?.shortest_edge;if(t===void 0)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(t<384){let r=Math.floor(t/this.crop_pct),[a,n]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(a,n,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}},nP=class extends Um{},Km=class extends fe{},sP=class extends Km{},Wm=class extends fe{async _call(e){let t=await super._call(e),r=[t.pixel_values.dims[0],64,64],a=Tt(r,1n);return{...t,pixel_mask:a}}post_process_object_detection(...e){return gH(...e)}post_process_panoptic_segmentation(...e){return Gm(...e)}post_process_instance_segmentation(...e){return Fm(...e)}},iP=class extends Wm{},HP=class extends fe{},Oc=class extends fe{pad_image(e,t,r,a={}){let[n,s,i]=t,H=this.image_mean;Array.isArray(this.image_mean)||(H=new Array(i).fill(H));let o=this.image_std;Array.isArray(o)||(o=new Array(i).fill(H));let _=H.map((c,l)=>-c/o[l]);return super.pad_image(e,t,r,{center:!0,constant_values:_,...a})}},oP=class extends Oc{},Vm=class extends fe{},_P=class extends Vm{},cP=class extends fe{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(t=>t*t))}},lP=class extends fe{};function uP(e,t,r,a,n){let s=a*r**2,i=Math.sqrt(s/(e*t)),H=n*r,o=Math.floor(i*e/H)*H,_=Math.floor(i*t/H)*H;if(o===0&&_===0)throw new Error(`Attempting to resize to a 0 x 0 image. Resized height should be divisible by \`pooling_kernel_size * patch_size\`=${H}.`);let c=Math.floor(a/n**2)*H;return o===0?(o=H,_=Math.min(Math.floor(t/e)*H,c)):_===0&&(_=H,o=Math.min(Math.floor(e/t)*H,c)),[o,_]}function dP(e,t,r,a,n,s,i){let H=Math.floor(t/n),o=Math.floor(r/n),_=H*o,c=n*n*a,l=new Float32Array(s*c),d=0;for(let m=0;m<H;++m)for(let S=0;S<o;++S)for(let I=0;I<n;++I){let T=(m*n+I)*r*a+S*n*a;for(let D=0;D<n;++D){let v=T+D*a;for(let C=0;C<a;++C)l[d++]=e[v+C]}}let h=new BigInt64Array(s*2).fill(-1n),$=0;for(let m=0;m<H;++m)for(let S=0;S<o;++S)h[$++]=BigInt(S),h[$++]=BigInt(m);return{patches:new K("float32",l,[s,c]),positions:new K("int64",h,[s,2]),num_soft_tokens:Math.floor(_/i**2)}}var jm=class extends Ft{constructor(e){super(),this.config=e,this.patch_size=e.patch_size??16,this.max_soft_tokens=e.max_soft_tokens??280,this.pooling_kernel_size=e.pooling_kernel_size??3,this.resample=e.resample??3,this.rescale_factor=e.rescale_factor??1/255,this.do_rescale=e.do_rescale??!0,this.do_resize=e.do_resize??!0,this.do_convert_rgb=e.do_convert_rgb??!0}async _call(e){Array.isArray(e)||(e=[e]);let{patch_size:t,pooling_kernel_size:r}=this,a=this.max_soft_tokens*r**2,n=[],s=[],i=[];for(let H of e){if(this.do_convert_rgb&&(H=H.rgb()),this.do_resize){let[d,h]=uP(H.height,H.width,t,a,r);(d!==H.height||h!==H.width)&&(H=await H.resize(h,d,{resample:this.resample}))}let o=Float32Array.from(H.data);if(this.do_rescale)for(let d=0;d<o.length;++d)o[d]*=this.rescale_factor;let{patches:_,positions:c,num_soft_tokens:l}=dP(o,H.height,H.width,H.channels,t,a,r);n.push(_),s.push(c),i.push(l)}return{pixel_values:Xr(n,0),image_position_ids:Xr(s,0),num_soft_tokens_per_image:i}}},qm=class extends fe{constructor(e){super(e),this.min_pixels=e.min_pixels??e.size?.shortest_edge,this.max_pixels=e.max_pixels??e.size?.longest_edge,this.patch_size=e.patch_size,this.merge_size=e.merge_size}get_resize_output_image_size(e,t){let r=this.patch_size*this.merge_size;return kc(e.height,e.width,r,this.min_pixels,this.max_pixels)}async _call(e,...t){let{pixel_values:r,original_sizes:a,reshaped_input_sizes:n}=await super._call(e,...t),s=r,{temporal_patch_size:i,merge_size:H,patch_size:o}=this.config;s.dims[0]===1&&(s=je(Array.from({length:i},()=>s),0));let _=s.dims[0]/i,c=s.dims[1],l=Math.floor(s.dims[2]/o),d=Math.floor(s.dims[3]/o),h=s.view(_,i,c,Math.floor(l/H),H,o,Math.floor(d/H),H,o).permute(0,3,6,4,7,2,1,5,8).view(_*l*d,c*i*o*o),$=new K("int64",[_,l,d],[1,3]);return{pixel_values:h,image_grid_thw:$,original_sizes:a,reshaped_input_sizes:n}}},pP=class extends qm{get_resize_output_image_size(e,t){let r=this.patch_size*this.merge_size,a=this.config.temporal_patch_size??2;return kc(e.height,e.width,r,this.min_pixels,this.max_pixels,a)}},hP=class extends fe{},fP=class extends fe{async _call(e){let t=await super._call(e),r=t.pixel_values.dims,a=Gt([r[0],r[2],r[3]]);return{...t,pixel_mask:a}}},w$=class extends fe{constructor(e){super(e),this.do_image_splitting=e.do_image_splitting??!0,this.max_image_size=e.max_image_size}get_resize_for_vision_encoder(e,t){let[r,a]=e.dims.slice(-2),n=a/r;return a>=r?(a=Math.ceil(a/t)*t,r=Math.floor(a/n),r=Math.ceil(r/t)*t):(r=Math.ceil(r/t)*t,a=Math.floor(r*n),a=Math.ceil(a/t)*t),{height:r,width:a}}async _call(e,{do_image_splitting:t=null,return_row_col_info:r=!1}={}){let a;if(!Array.isArray(e))a=[[e]];else{if(e.length===0||!e[0])throw new Error("No images provided.");Array.isArray(e[0])?a=e:a=[e]}let n=[],s=[],i=[],H=[],o=[];for(let S of a){let I=await Promise.all(S.map(v=>this.preprocess(v)));H.push(...I.map(v=>v.original_size)),o.push(...I.map(v=>v.reshaped_input_size)),I.forEach(v=>v.pixel_values.unsqueeze_(0));let{longest_edge:T}=this.max_image_size,D;if(t??this.do_image_splitting){let v=new Array(I.length),C=new Array(I.length);D=await Promise.all(I.map(async(R,A)=>{let U=this.get_resize_for_vision_encoder(R.pixel_values,T),Z=await _r(R.pixel_values,{size:[U.height,U.width]}),{frames:j,num_splits_h:z,num_splits_w:X}=await this.split_image(Z,this.max_image_size);return v[A]=z,C[A]=X,je(j,0)})),s.push(v),i.push(C)}else{let v=[T,T];D=await Promise.all(I.map(C=>_r(C.pixel_values,{size:v}))),s.push(new Array(I.length).fill(0)),i.push(new Array(I.length).fill(0))}n.push(je(D,0))}let _=n.length,[c,l,d,h]=n[0].dims,$,m;if(_===1)$=n[0].unsqueeze_(0),m=Tt([_,c,d,h],!0);else{let S=Math.max(...n.map(D=>D.dims.at(0)));m=Tt([_,S,d,h],!0);let I=m.data,T=S*d*h;for(let D=0;D<_;++D){let v=n[D].dims[0];if(v<S){n[D]=je([n[D],Tt([S-v,l,d,h],0)],0);let C=D*T+v*d*h,R=(D+1)*T;I.fill(!1,C,R)}}$=Xr(n,0)}return{pixel_values:$,pixel_attention_mask:m,original_sizes:H,reshaped_input_sizes:o,...r?{rows:s,cols:i}:{}}}async split_image(e,{longest_edge:t}){let r=t,a=t,n=[],[s,i]=e.dims.slice(-2),H=0,o=0;if(s>r||i>a){H=Math.ceil(s/r),o=Math.ceil(i/a);let _=Math.ceil(s/H),c=Math.ceil(i/o);for(let h=0;h<H;++h)for(let $=0;$<o;++$){let m,S,I,T;h===H-1?(S=s-_,T=s):(S=h*_,T=(h+1)*_),$===o-1?(m=i-c,I=i):(m=$*c,I=($+1)*c);let C=await Em(e,[S,m],[T,I],[2,3]);n.push(C)}let l=r,d=a;(s!==l||i!==d)&&(e=await _r(e,{size:[l,d]}))}return n.push(e),{frames:n,num_splits_h:H,num_splits_w:o}}},EP=class extends fe{constructor(e){super({do_pad:!0,pad_size:{width:e.image_size,height:e.image_size},...e}),this.constant_values=this.config.background_color.map(t=>t*this.rescale_factor)}pad_image(e,t,r,a){return super.pad_image(e,t,r,{constant_values:this.constant_values,center:!0,...a})}},$P=class extends fe{constructor(e){let{resize_mode:t,fill_color:r,interpolation:a,size:n,...s}=e,i=t==="squash"?{width:n,height:n}:t==="shortest"?{shortest_edge:n}:{longest_edge:n},H=a==="bicubic"?3:2;super({...s,size:i,resample:H,do_center_crop:!0,crop_size:n,do_normalize:!0})}};function y$(e,t){return Math.round(e/t)*t}function mP(e,t,r,a,n){let s=1/0,i=[1,1],H=r*a;for(let o of t){let _=Math.abs(e-o[0]/o[1]);_<s?(s=_,i=o):_===s&&H>.5*n*n*o[0]*o[1]&&(i=o)}return i}function IP(e,t){let r=[],a=new Set;for(let n=e;n<=t;++n)for(let s=1;s<=n;++s)for(let i=1;i<=n;++i){let H=s*i;if(H>=e&&H<=t){let o=s<<16|i;a.has(o)||(a.add(o),r.push([s,i]))}}return r.sort((n,s)=>n[0]*n[1]-s[0]*s[1])}function SP(e,t){let[r,a,n,s]=e.dims,i=Math.floor(n/t),H=Math.floor(s/t),o=t*t*a,_=e.data,c=new Float32Array(r*i*H*o),l=n*s;for(let d=0;d<r;++d){let h=d*a*l,$=d*i*H*o;for(let m=0;m<i;++m)for(let S=0;S<H;++S){let I=$+(m*H+S)*o;for(let T=0;T<t;++T){let D=(m*t+T)*s+S*t;for(let v=0;v<t;++v){let C=D+v;for(let R=0;R<a;++R)c[I++]=_[h+R*l+C]}}}}return new K("float32",c,[r,i*H,o])}function LP(e,t){let[,r,a]=e.dims,n=new BigInt64Array(t);n.fill(1n,0,r);let s=e;if(r<t){let i=new Float32Array(t*a);i.set(e.data),s=new K("float32",i,[1,t,a])}return{padded:s,mask:new K("int64",n,[t])}}var AP=class extends fe{constructor(e){super(e),this.downsample_factor=e.downsample_factor??2,this.do_image_splitting=e.do_image_splitting??!0,this.min_tiles=e.min_tiles??2,this.max_tiles=e.max_tiles??10,this.use_thumbnail=e.use_thumbnail??!0,this.min_image_tokens=e.min_image_tokens??64,this.max_image_tokens=e.max_image_tokens??256,this.encoder_patch_size=e.encoder_patch_size??e.patch_size??16,this.tile_size=e.tile_size??512,this.max_pixels_tolerance=e.max_pixels_tolerance??2,this.return_row_col_info=e.return_row_col_info??!1;let t=this.max_image_tokens*this.downsample_factor**2,r=this.do_image_splitting?(this.tile_size/this.encoder_patch_size)**2:0;this.max_num_patches=Math.max(t,r)}_is_image_too_large(e,t){let r=this.encoder_patch_size*this.downsample_factor,a=Math.max(this.encoder_patch_size,y$(e,r)),n=Math.max(this.encoder_patch_size,y$(t,r));return a*n>this.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,t){let r=IP(this.min_tiles,this.max_tiles),[a,n]=mP(t/e,r,t,e,this.tile_size);return{grid_width:a,grid_height:n,target_width:this.tile_size*a,target_height:this.tile_size*n}}async _call(e,{return_row_col_info:t=null}={}){let r;Array.isArray(e)?Array.isArray(e[0])?r=e:r=[e]:r=[[e]];let a=[],n=[],s=[],i=[],H=[],o=[];for(let c of r){let l=await Promise.all(c.map(d=>this.preprocess(d,{do_pad:!1})));for(let{pixel_values:d}of l){let[,h,$]=d.dims,m=d.unsqueeze_(0),S=this.encoder_patch_size*this.downsample_factor,I=S**2,[T,D]=kc(Math.max(S,h),Math.max(S,$),S,this.min_image_tokens*I,this.max_image_tokens*I).map(Z=>Math.max(S,Z)),v,C=1,R=1,A=this._is_image_too_large(h,$),U=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(A&&U){let{grid_width:Z,grid_height:j,target_width:z,target_height:X}=this._get_grid_layout(h,$);C=j,R=Z;let q=await _r(m,{size:[X,z]});v=[];for(let G=0;G<j;++G)for(let y=0;y<Z;++y){let Q=G*this.tile_size,_e=y*this.tile_size;v.push(q.slice(null,null,[Q,Q+this.tile_size],[_e,_e+this.tile_size]))}this.use_thumbnail&&Z*j!==1&&v.push(await _r(m,{size:[D,T]}))}else v=[await _r(m,{size:[D,T]})];for(let Z of v){let[,,j,z]=Z.dims,X=SP(Z,this.encoder_patch_size),{padded:q,mask:G}=LP(X,this.max_num_patches);a.push(q),n.push(G),s.push([Math.floor(j/this.encoder_patch_size),Math.floor(z/this.encoder_patch_size)])}i.push(C),H.push(R),o.push([D,T])}}let _={pixel_values:je(a,0),pixel_attention_mask:Xr(n,0),spatial_shapes:new K("int64",BigInt64Array.from(s.flat(),BigInt),[s.length,2])};return(t??this.return_row_col_info)&&(_.image_rows=i,_.image_cols=H,_.image_sizes=o),_}},gP=class extends fe{},Gc=class extends fe{post_process_panoptic_segmentation(...e){return Gm(...e)}post_process_instance_segmentation(...e){return Fm(...e)}},TP=class extends Gc{},bP=class extends Gc{},Xm=class extends fe{},vP=class extends Xm{},zm=class extends fe{},DP=class extends zm{},Jm=class extends fe{},CP=class extends Jm{},Qm=class extends fe{},xP=class extends Qm{},Ym=class extends fe{},NP=class extends Ym{},wP=class extends Oc{},Fc=class extends fe{post_process_object_detection(...e){return gH(...e)}},yP=class extends Fc{},BP=class extends Fc{},Kt=336,MP=[2,3],{ceil:R_,floor:Sn,sqrt:k_}=Math,PP=class extends fe{constructor(e){super({...e,do_normalize:!0,do_pad:!0,pad_size:"custom",do_convert_rgb:!0,do_resize:!0}),this._num_crops=e.num_crops}calc_num_image_tokens_from_image_size(e,t){let{num_img_tokens:r}=this.config;return Sn((Sn(t/Kt)*Sn(e/Kt)+1)*r+1+(Sn(t/Kt)+1)*k_(r))}get_resize_output_image_size(e,t){let r=this._num_crops,[a,n]=e.size,s=a/n,i=1;for(;i*Math.ceil(i/s)<=r;)i+=1;i-=1;let H=Math.floor(i*336),o=Math.floor(H/s);return[H,o]}pad_image(e,t,r,a={}){let[n,s]=t,i=Kt*R_(n/Kt),H=Kt*R_(s/Kt),o=[1,1,1].map((_,c)=>(_-this.image_mean[c])/this.image_std[c]);return super.pad_image(e,t,{width:H,height:i},{center:!0,constant_values:o,...a})}async _call(e,{num_crops:t=null}={}){if(this._num_crops=t??=this.config.num_crops,t<4||k_(t)%1!==0)throw new Error("num_crops must be a square number >= 4");Array.isArray(e)||(e=[e]);let r=e.length,a=await Promise.all(e.map(l=>this.preprocess(l))),n=a.map(l=>l.original_size),s=a.map(l=>l.reshaped_input_size),i=[];for(let{pixel_values:l}of a){l.unsqueeze_(0);let[d,h]=l.dims.slice(-2),$=await _r(l,{size:[Kt,Kt],mode:"bicubic"});if(t>0){let m=[],S=k_(t),I=Sn(h/S),T=Sn(d/S);for(let v=0;v<S;++v)for(let C=0;C<S;++C){let R,A,U,Z;v===S-1?(A=d-T,Z=d):(A=v*T,Z=(v+1)*T),C===S-1?(R=h-I,U=h):(R=C*I,U=(C+1)*I);let X=await Em(l,[A,R],[Z,U],MP);m.push(X)}let D=await _r(je(m,0),{size:[Kt,Kt],mode:"bicubic"});i.push(je([$,D],0))}else i.push($)}let H=Xr(i,0),o=s.map(l=>l.map(d=>Kt*R_(d/Kt))),_=new K("int64",o.flat(),[r,2]),c=o.map(([l,d])=>this.calc_num_image_tokens_from_image_size(d,l));return{pixel_values:H,original_sizes:n,reshaped_input_sizes:s,image_sizes:_,num_img_tokens:c}}},RP=class extends fe{get_resize_output_image_size(e,t){let{longest_edge:r}=t;if(r===void 0)throw new Error("size must contain 'longest_edge'");let[a,n]=e.size,s=Math.max(a,n)/r,i=a,H=n;s>1&&(i=Math.floor(a/s),H=Math.floor(n/s));let{patch_size:o,spatial_merge_size:_}=this.config;if(!_)throw new Error("config must contain 'spatial_merge_size'");let c=o*_,l=Math.floor((i-1)/c)+1,d=Math.floor((H-1)/c)+1;return[l*c,d*c]}},kP=class extends fe{},OP=class extends fe{post_process_object_detection(...e){return gH(...e)}},O_=class extends fe{reshape_input_points(e,t,r,a=!1){e=structuredClone(e);let n=L1(e);if(n.length===3)a||(n=[1,...n]),e=[e];else if(n.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let s=0;s<e.length;++s){let[i,H]=t[s],[o,_]=r[s],c=[_/H,o/i];for(let l=0;l<e[s].length;++l)for(let d=0;d<e[s][l].length;++d)for(let h=0;h<e[s][l][d].length;++h)e[s][l][d][h]*=c[h%2]}return new K("float32",Float32Array.from(e.flat(1/0)),n)}add_input_labels(e,t){let r=L1(e);if(r.length===2)r=[1,...r],e=[e];else if(r.length!==3)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");if(r.some((a,n)=>a!==t.dims[n]))throw Error(`The first ${r.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new K("int64",e.flat(1/0).map(BigInt),r)}async _call(e,{input_points:t=null,input_labels:r=null,input_boxes:a=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 a&&(n.input_boxes=this.reshape_input_points(a,n.original_sizes,n.reshaped_input_sizes,!0)),n}async post_process_masks(e,t,r,{mask_threshold:a=0,binarize:n=!0,pad_size:s=null}={}){let i=[];s=s??this.pad_size??this.size;let H=[s.height,s.width];for(let o=0;o<t.length;++o){let _=t[o],c=r[o],l=await _r(e[o],{mode:"bilinear",size:H});if(l=l.slice(null,null,[0,c[0]],[0,c[1]]),l=await _r(l,{mode:"bilinear",size:_}),n){let d=l.data,h=new Uint8Array(d.length);for(let $=0;$<d.length;++$)d[$]>a&&(h[$]=1);l=new K("bool",h,l.dims)}i.push(l)}return i}generate_crop_boxes(e,t,{crop_n_layers:r=0,overlap_ratio:a=512/1500,points_per_crop:n=32,crop_n_points_downscale_factor:s=1}={}){}},eI=class extends fe{post_process_semantic_segmentation(...e){return Om(...e)}},GP=class extends eI{},tI=class extends fe{post_process_semantic_segmentation(...e){return Om(...e)}},FP=class extends tI{},ZP=class extends fe{},UP=class extends fe{pad_image(e,t,r,a={}){let[n,s,i]=t;return super.pad_image(e,t,{width:s+(r-s%r)%r,height:n+(r-n%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...a})}},rI=class extends fe{},KP=class extends rI{},WP=class extends fe{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let r=await Promise.all(e.map(s=>this.preprocess(s))),a=await Promise.all(t.map(s=>this.preprocess(s,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:Xr(r.map((s,i)=>je([s.pixel_values,a[i].pixel_values],0)),0),original_sizes:r.map(s=>s.original_size),reshaped_input_sizes:r.map(s=>s.reshaped_input_size)}}},VP=class extends fe{post_process_pose_estimation(e,t,{threshold:r=null}={}){let a=e.tolist(),[n,s,i,H]=e.dims,o=[];for(let _=0;_<n;++_){let c=a[_],l=t[_],d=[];for(let h=0;h<l.length;++h){let $=l[h],m=[],S=[],I=[],T=$.at(-2)/H,D=$.at(-1)/i;for(let v=0;v<c.length;++v){let[C,R]=[0,0],A=0,U=-1/0,Z=c[v];for(let z=0;z<Z.length;++z){let X=Z[z];for(let q=0;q<X.length;++q){let G=X[q];A+=G,U=Math.max(U,G),C+=(q+.5)*G,R+=z*G}}if(r!=null&&U<r)continue;let j=[T*C/A,D*R/A];m.push(j),I.push(v),S.push(U)}d.push({bbox:$,scores:S,labels:I,keypoints:m})}o.push(d)}return o}},aI=class extends fe{post_process_object_detection(...e){return gH(...e)}},jP=class extends aI{},vt=class{static async from_pretrained(e,t={}){let r=await yr(e,ws,!0,t),a=r.image_processor_type??r.feature_extractor_type,n=pH[a?.replace(/Fast$/,"")];return n||(a!==void 0&&he.warn(`Image processor type '${a}' not found, assuming base ImageProcessor. Please report this at ${AH}.`),n=fe),new n(r)}},qP=class extends ye{static tokenizer_class=we;static image_processor_class=vt;constructor(e,t,r){super(e,t,r);let{tasks_answer_post_processing_type:a,task_prompts_without_inputs:n,task_prompts_with_input:s}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(a??{})),this.task_prompts_without_inputs=new Map(Object.entries(n??{})),this.task_prompts_with_input=new Map(Object.entries(s??{})),this.regexes={quad_boxes:/(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm,bboxes:/([^<]+)?<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e=="string"&&(e=[e]);let t=[];for(let r of e)if(this.task_prompts_without_inputs.has(r))t.push(this.task_prompts_without_inputs.get(r));else{for(let[a,n]of this.task_prompts_with_input)if(r.includes(a)){t.push(n.replaceAll("{input}",r).replaceAll(a,""));break}t.length!==e.length&&t.push(r)}return t}post_process_generation(e,t,r){let a=this.tasks_answer_post_processing_type.get(t)??"pure_text";e=e.replaceAll("<s>","").replaceAll("</s>","");let n;switch(a){case"pure_text":n=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":let s=a==="ocr"?"quad_boxes":"bboxes",i=e.matchAll(this.regexes[s]),H=[],o=[];for(let[_,c,...l]of i)H.push(c?c.trim():H.at(-1)??""),o.push(l.map((d,h)=>(Number(d)+.5)/this.size_per_bin*r[h%2]));n={labels:H,[s]:o};break;default:throw new Error(`Task "${t}" (of type "${a}") not yet implemented.`)}return{[t]:n}}async _call(e,t=null,r={}){if(!e&&!t)throw new Error("Either text or images must be provided");let a=await this.image_processor(e,r),n=t?this.tokenizer(this.construct_prompts(t),r):{};return{...a,...n}}},XP=class extends ye{static tokenizer_class=we;static image_processor_class=vt;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,r){super(e,t,r),this.image_seq_length=this.config.image_seq_length;let{boi_token:a,image_token:n,eoi_token:s}=this.tokenizer.config;this.boi_token=a,this.image_token=n,this.eoi_token=s;let i=n.repeat(this.image_seq_length);this.full_image_sequence=`
|
|
15
|
+
|
|
16
|
+
${a}${i}${s}
|
|
17
|
+
|
|
18
|
+
`}async _call(e,t=null,r={}){typeof e=="string"&&(e=[e]);let a;return t&&(a=await this.image_processor(t,r),e=e.map(s=>s.replaceAll(this.boi_token,this.full_image_sequence))),{...this.tokenizer(e,r),...a}}},zP=class extends ye{static image_processor_class=vt;static feature_extractor_class=tr;static tokenizer_class=we;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,r){super(e,t,r),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:a,boa_token:n,audio_token:s,eoa_token:i,image_token_id:H,boi_token:o,image_token:_,eoi_token:c}=this.tokenizer.config;this.audio_token_id=a,this.boa_token=n,this.audio_token=s;let l=s.repeat(this.audio_seq_length);this.full_audio_sequence=`
|
|
19
|
+
|
|
20
|
+
${n}${l}${i}
|
|
21
|
+
|
|
22
|
+
`,this.image_token_id=H,this.boi_token=o,this.image_token=_;let d=_.repeat(this.image_seq_length);this.full_image_sequence=`
|
|
23
|
+
|
|
24
|
+
${o}${d}${c}
|
|
25
|
+
|
|
26
|
+
`}async _call(e,t=null,r=null,a={}){typeof e=="string"&&(e=[e]);let n;r&&(n=await this.feature_extractor(r,a),e=e.map(H=>H.replaceAll(this.audio_token,this.full_audio_sequence)));let s;return t&&(s=await this.image_processor(t,a),e=e.map(H=>H.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,a),...s,...n}}},JP=class extends ye{static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,r){super(e,t,r),this.audio_ms_per_token=this.config.audio_ms_per_token??40,this.audio_seq_length=this.config.audio_seq_length??750,this.image_seq_length=this.config.image_seq_length??280;let{audio_token:a,boa_token:n,eoa_token:s,image_token:i,boi_token:H,eoi_token:o}=this.tokenizer.config;this.audio_token=a,this.boa_token=n,this.eoa_token=s,this.image_token=i,this.boi_token=H,this.eoi_token=o}static async from_pretrained(e,t={}){let[r,a,n]=await Promise.all([yr(e,bm,!0,t),we.from_pretrained(e,t),uc(e,vm,!1,t)]),s={tokenizer:a};return r.image_processor&&(s.image_processor=new jm(r.image_processor)),r.feature_extractor&&(s.feature_extractor=new Mm(r.feature_extractor)),new this(r,s,n)}_compute_audio_num_tokens(e,t){let r=Math.round(t*20/1e3),a=Math.round(t*10/1e3),n=Math.floor(r/2),s=Math.floor((e+n-r-1)/a)+1;if(s<=0)return 0;for(let i=0;i<2;++i)s=Math.floor((s-1)/2)+1;return Math.min(s,this.audio_seq_length)}async _call(e,t=null,r=null,a={}){typeof e=="string"&&(e=[e]);let n;if(t){n=await this.image_processor(t,a);let i=n.num_soft_tokens_per_image,H=0;e=e.map(o=>o.replaceAll(this.image_token,()=>`
|
|
27
|
+
|
|
28
|
+
${this.boi_token}${this.image_token.repeat(i[H++])}${this.eoi_token}
|
|
29
|
+
|
|
30
|
+
`))}let s;if(r){let i=Array.isArray(r)?r:[r];s=await this.feature_extractor(i[0],a);let H=this.feature_extractor.config.sampling_rate??16e3,o=0;e=e.map(_=>_.replaceAll(this.audio_token,()=>`
|
|
31
|
+
|
|
32
|
+
${this.boa_token}${this.audio_token.repeat(this._compute_audio_num_tokens(i[o++].length,H))}${this.eoa_token}
|
|
33
|
+
|
|
34
|
+
`))}return{...this.tokenizer(e,a),...n,...s}}},Zc=class extends ye{static image_processor_class=vt;static tokenizer_class=we;static image_token="<|image_pad|>";async _call(e,t=null,...r){Array.isArray(e)||(e=[e]);let a,n;if(t&&(a=await this.image_processor(t),n=a.image_grid_thw),n){let i=this.image_processor.config.merge_size**2,H=0,o=this.constructor.image_token,_=n.tolist();e=e.map(c=>{for(;c.includes(o);){let l=Number(_[H++].reduce((d,h)=>d*h,1n));c=c.replace(o,"<|placeholder|>".repeat(Math.floor(l/i)))}return c.replaceAll("<|placeholder|>",o)})}return{...this.tokenizer(e),...a}}},QP=class extends Zc{static image_token="<|image|>"},YP=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;static uses_processor_config=!0;_get_num_audio_features(e){let{hop_length:t}=this.feature_extractor.config.melspec_kwargs,{projector_window_size:r,projector_downsample_rate:a}=this.feature_extractor.config,n=Math.floor(r/a),s=Math.floor(e/t)+1,i=Math.floor(s/2);return Math.ceil(i/r)*n}async _call(e,t=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let a={};if(t){let{input_features:s}=await this.feature_extractor(t);a.input_features=s;let i=this._get_num_audio_features(t.length),H=new Uint8Array(i).fill(1);a.input_features_mask=new K("bool",H,[1,i]);let o=this.config.audio_token??"<|audio|>";if(!e.includes(o))throw new Error(`The input text does not contain the audio token ${o}.`);e=e.replaceAll(o,o.repeat(i))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...a}}};function e3(e,t){let a=e.dims.at(-1)-1,n=e.tolist();n.fill(!1,0,1),n.fill(!1,a);let s=t.tolist();return n.map((i,H)=>i?H:null).filter(i=>i!==null).map(i=>s[i])}var t3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;async _call(e,t,r={}){let a=e?await this.image_processor(e,r):{};return{...t?this.tokenizer(t,r):{},...a}}post_process_grounded_object_detection(e,t,{box_threshold:r=.25,text_threshold:a=.25,target_sizes:n=null}={}){let{logits:s,pred_boxes:i}=e,H=s.dims[0];if(n!==null&&n.length!==H)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let o=s.dims.at(1),_=s.sigmoid(),c=_.max(-1).tolist(),l=i.tolist().map(h=>h.map($=>km($))),d=[];for(let h=0;h<H;++h){let $=n!==null?n[h]:null;$!==null&&(l[h]=l[h].map(D=>D.map((v,C)=>v*$[(C+1)%2])));let m=c[h],S=[],I=[],T=[];for(let D=0;D<o;++D){let v=m[D];if(v<=r)continue;let C=l[h][D],R=_[h][D];S.push(v),T.push(C);let A=e3(R.gt(a),t[h]);I.push(A)}d.push({scores:S,boxes:T,labels:this.batch_decode(I)})}return d}};function r3(e,t,r,a,n,s){let i="";for(let H=0;H<t;++H){for(let o=0;o<r;++o)i+=a+`<row_${H+1}_col_${o+1}>`+n.repeat(e);i+=`
|
|
35
|
+
`}return i+=`
|
|
36
|
+
${a}${s}`+n.repeat(e)+`${a}`,i}function a3(e,t,r,a){return`${t}${a}`+r.repeat(e)+`${t}`}function n3(e,t,r,a,n,s){return e===0&&t===0?a3(r,a,n,s):r3(r,e,t,a,n,s)}var B$=class extends ye{static image_processor_class=vt;static tokenizer_class=we;static uses_processor_config=!0;fake_image_token="<fake_token_around_image>";image_token="<image>";global_img_token="<global-img>";async _call(e,t=null,r={}){r.return_row_col_info??=!0;let a;t&&(a=await this.image_processor(t,r)),Array.isArray(e)||(e=[e]);let n=a.rows??[new Array(e.length).fill(0)],s=a.cols??[new Array(e.length).fill(0)],i=this.config.image_seq_len,H=[],o=[];for(let c=0;c<e.length;++c){let l=e[c],d=n[c],h=s[c];H.push(jx(l,this.image_token));let $=d.map((I,T)=>n3(I,h[T],i,this.fake_image_token,this.image_token,this.global_img_token)),m=l.split(this.image_token);if(m.length===0)throw new Error("The image token should be present in the text.");let S=m[0];for(let I=0;I<$.length;++I)S+=$[I]+m[I+1];o.push(S)}return{...this.tokenizer(o),...a}}},s3=class extends ye{static image_processor_class=vt;static tokenizer_class=we;static uses_processor_config=!0;constructor(e,t,r){super(e,t,r),this.image_tag=this.config.image_tag,this.image_start_tag=this.config.image_start_tag,this.image_end_tag=this.config.image_end_tag,this.num_image_tokens=this.config.num_image_tokens}async _call(e,{images:t=null,chat_template:r="default"}={}){t?Array.isArray(t)||(t=[t]):t=await Promise.all(e.filter(m=>m.images).flatMap(m=>m.images).map(m=>qt.read(m)));let a=this.tokenizer,n=a.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:r}),s=m=>a.encode(m,{add_special_tokens:!1}),i=n.split(this.image_tag),H=i.length-1;if(t.length!==H)throw new Error(`Number of images provided (${t.length}) does not match number of "${this.image_tag}" image tags (${H})`);let[o,_,c]=a.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),l=s(i[0]),d=new Array(l.length).fill(!1);for(let m=1;m<i.length;++m){let S=new Array(this.num_image_tokens).fill(o),I=s(i[m]);l=ir(l,[_],S,[c],I);let T=new Array(this.num_image_tokens).fill(!0);d=ir(d,[!1],T,[!1],new Array(I.length).fill(!1))}let h=[1,l.length],$={input_ids:new K("int64",l,h),attention_mask:new K("int64",new Array(l.length).fill(1),h),images_seq_mask:new K("bool",d,h),images_emb_mask:new K("bool",new Array(H*this.num_image_tokens).fill(!0),[1,H,this.num_image_tokens])};if(t&&t.length>0){let m=await this.image_processor(t);return m.pixel_values.unsqueeze_(0),{...$,...m}}return $}},i3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;async _call(e=null,t=null,r={}){if(!e&&!t)throw new Error("Either text or images must be provided");let a=e?this.tokenizer(e,r):{},n=t?await this.image_processor(t,r):{};return{...a,...n}}},H3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;async _call(e,t=null,r={}){let{image_rows:a,image_cols:n,image_sizes:s,...i}=await this.image_processor(e,{...r,return_row_col_info:!0});if(t){let H=this.config.image_token??"<image>",{tile_size:o=512,downsample_factor:_=2,encoder_patch_size:c=16,use_thumbnail:l=!0}=this.image_processor.config,d=T=>Math.ceil(Math.floor(T/c)/_),h=d(o)**2,$=this.config.image_start_token??"<|image_start|>",m=this.config.image_end_token??"<|image_end|>",S=this.config.image_thumbnail??"<|img_thumbnail|>";Array.isArray(t)||(t=[t]);let I=0;t=t.map(T=>{let D=T.split(H);return D[0]+D.slice(1).map(v=>{let C=I++,[R,A]=s[C],U=a[C],Z=n[C],j=d(R)*d(A),z=$;if(U>1||Z>1){let X=H.repeat(h);for(let q=0;q<U;++q)for(let G=0;G<Z;++G)z+=`<|img_row_${q+1}_col_${G+1}|>`+X;l&&(z+=S+H.repeat(j))}else z+=H.repeat(j);return z+m+v}).join("")})}return{...i,...t?this.tokenizer(t,r):{}}}},o3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;static uses_processor_config=!0;async _call(e,t=null,r={}){let a=await this.image_processor(e,r);if(t){let[s,i]=a.pixel_values.dims.slice(-2),{image_token:H,patch_size:o,num_additional_image_tokens:_}=this.config,c=Math.floor(s/o)*Math.floor(i/o)+_;t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let l=0;l<t.length;++l)t[l]=t[l].replace(H,H.repeat(c))}let n=t?this.tokenizer(t,r):{};return{...a,...n}}},M$={char:["char_decode",1],bpe:["bpe_decode",2],wp:["wp_decode",102]},_3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;get char_tokenizer(){return this.components.char_tokenizer}get bpe_tokenizer(){return this.components.bpe_tokenizer}get wp_tokenizer(){return this.components.wp_tokenizer}_decode_helper(e,t){if(!M$.hasOwnProperty(t))throw new Error(`Format ${t} is not supported.`);let[r,a]=M$[t],n=this[r].bind(this),[s,i]=e.dims,H=[],o=[],_=e.tolist();for(let l=0;l<s;++l){let d=_[l],h=[],$=[];for(let S=1;S<i;++S){let[I,T]=et(St(d[S]));if($.push(I),T==a)break;h.push(T)}let m=$.length>0?$.reduce((S,I)=>S*I,1):0;o.push(h),H.push(m)}return[n(o),H]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(t=>t.replaceAll(" ",""))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(t=>t.replaceAll(" ",""))}batch_decode([e,t,r]){let[a,n]=this._decode_helper(e,"char"),[s,i]=this._decode_helper(t,"bpe"),[H,o]=this._decode_helper(r,"wp"),_=[],c=[];for(let l=0;l<a.length;++l){let[d,h]=et([n[l],i[l],o[l]]);_.push([a[l],s[l],H[l]][h]),c.push(d)}return{generated_text:_,scores:c,char_preds:a,bpe_preds:s,wp_preds:H}}static async from_pretrained(...e){let t=await super.from_pretrained(...e),r=await we.from_pretrained("Xenova/gpt2"),a=await we.from_pretrained("Xenova/bert-base-uncased");return t.components={image_processor:t.image_processor,char_tokenizer:t.tokenizer,bpe_tokenizer:r,wp_tokenizer:a},t}async _call(e,t=null){let r=await this.image_processor(e);return t&&(r.labels=this.tokenizer(t).input_ids),r}},c3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;async _call(e){return await this.feature_extractor(e)}},l3=class extends ye{static tokenizer_class=we;static image_processor_class=vt},Ln="<image>";function u3(e,t,r,a,n){return`${a.repeat(r*n)}${t}${e}
|
|
37
|
+
`}var d3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;static uses_processor_config=!1;async _call(e,t=null,r={}){t||(he.warn("You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."),t=""),Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let a=this.tokenizer.bos_token,n=this.image_processor.config.image_seq_length,s;t.some(o=>o.includes(Ln))?s=t.map(o=>{let _=o.replaceAll(Ln,Ln.repeat(n)),c=_.lastIndexOf(Ln),l=c===-1?0:c+Ln.length;return _.slice(0,l)+a+_.slice(l)+`
|
|
38
|
+
`}):(he.warn("You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special image tokens in the text, as many tokens as there are images per each text. It is recommended to add `<image>` tokens in the very beginning of your text. For this call, we will infer how many images each text has and add special tokens."),s=t.map(o=>u3(o,a,n,Ln,e.length)));let i=this.tokenizer(s,r);return{...await this.image_processor(e,r),...i}}},P$="<|image|>",p3=/<\|image_\d+\|>/g,h3=class extends ye{static image_processor_class=vt;static tokenizer_class=we;async _call(e,t=null,{padding:r=!0,truncation:a=!0,num_crops:n=null}={}){Array.isArray(e)||(e=[e]);let s,i;if(t){i=await this.image_processor(t,{num_crops:n});let{num_img_tokens:H}=i,o=e.map((c,l)=>c.split(p3).join(P$.repeat(H[l])));s=this.tokenizer(o,{padding:r,truncation:a});let _=this.tokenizer._tokenizer.token_to_id(P$);s.input_ids.map_(c=>c==_?-c:c)}else s=this.tokenizer(e);return{...s,...i}}},f3=class extends ye{static tokenizer_class=we;static image_processor_class=vt;static uses_processor_config=!0;async _call(e,t=null,r={}){let a=await this.image_processor(e,r);if(t){let[s,i]=a.pixel_values.dims.slice(-2),{image_token:H,image_break_token:o,image_end_token:_,patch_size:c,spatial_merge_size:l}=this.config,d=c*l,h=Math.floor(s/d),$=Math.floor(i/d);t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let m=0;m<t.length;++m){let S=H.repeat($),I=S+o,T=S+_,D=I.repeat(h-1)+T;t[m]=t[m].replace(H,D)}}let n=t?this.tokenizer(t,r):{};return{...a,...n}}},E3=class extends ye{static feature_extractor_class=Pm;async _call(e){return await this.feature_extractor(e)}post_process_speaker_diarization(...e){return this.feature_extractor.post_process_speaker_diarization(...e)}get sampling_rate(){return this.feature_extractor.config.sampling_rate}},nI=class extends Zc{},$3=class extends nI{},sI=class extends ye{static image_processor_class=vt;async _call(...e){return await this.image_processor(...e)}post_process_masks(...e){return this.image_processor.post_process_masks(...e)}reshape_input_points(...e){return this.image_processor.reshape_input_points(...e)}},iI=class extends sI{},m3=class extends iI{},I3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;async _call(e){return await this.feature_extractor(e)}},S3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;static uses_processor_config=!0;async _call(e,t=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let a={};if(t){let s=t.length,{input_features:i}=await this.feature_extractor(t,{...r,max_length:s}),H=Math.round(s/this.config.encoder_ds_factor+1e-4),o=1+Math.ceil(H/this.config.stack_factor);a.audio_token_len=[o],a.audio_values=i;let _=this.config.audio_placeholder;if(!e.includes(_))throw new Error(`The input text does not contain the image token ${_}.`);e=e.replaceAll(_,_.repeat(o))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...a}}},Xi="[AUDIO]",L3="[BEGIN_AUDIO]",A3=375;function g3(e,t){let r=[];for(let a=0;a<e.length;a+=t)r.push(e.subarray(a,Math.min(a+t,e.length)));return r}var T3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;static uses_processor_config=!1;async _call(e,t=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let a={};if(t){if(!e.includes(Xi))throw new Error(`The input text does not contain the audio token ${Xi}.`);Array.isArray(t)||(t=[t]);let s=e.split(Xi),i=s.length-1;if(i!==t.length)throw new Error(`The number of audio inputs (${t.length}) does not match the number of audio tokens in the text (${i}).`);let H=this.feature_extractor.config.n_samples,o=t.map(h=>g3(h,H)),_=o.map(h=>h.length),c=o.flat(),l=(await Promise.all(c.map(h=>this.feature_extractor(h,r)))).map(h=>h.input_features);a.audio_values=l.length>1?je(l,0):l[0];let d=s[0];for(let h=0;h<_.length;++h){d+=L3;for(let $=0;$<_[h];++$)d+=Xi.repeat(A3);d+=s[h+1]}e=d}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...a}}},R$=32,G_=6,zi=8,b3=10,v3=32,D3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(G_+1)*zi}get num_samples_first_audio_chunk(){let{hop_length:e,n_fft:t}=this.feature_extractor.config;return(this.num_mel_frames_first_audio_chunk-1)*e+Math.floor(t/2)}get num_samples_per_audio_chunk(){let{hop_length:e,n_fft:t}=this.feature_extractor.config;return zi*e+t}get num_right_pad_tokens(){return G_+1+b3}get audio_length_per_tok(){return zi}get raw_audio_length_per_tok(){return zi*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:t=!1,is_first_audio_chunk:r=!0}={}){if(Lt(e,"VoxtralRealtimeProcessor"),!t&&!r)throw new Error("In non-streaming mode (`is_streaming=false`), `is_first_audio_chunk` must be `true`.");if(r)if(t){let a=R$*this.raw_audio_length_per_tok,n=new Float32Array(a+e.length);n.set(e,a);let s=await this.feature_extractor(n,{center:!0}),H=1+(R$+G_),o=new BigInt64Array(H).fill(BigInt(v3));return o[0]=1n,{input_ids:new K("int64",o,[1,H]),...s}}else{let a=this.num_right_pad_tokens*this.raw_audio_length_per_tok,n=new Float32Array(e.length+a);return n.set(e),await this.feature_extractor(n,{center:!0})}else return await this.feature_extractor(e,{center:!1})}},C3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;async _call(e){return await this.feature_extractor(e)}},x3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;async _call(e){return await this.feature_extractor(e)}},N3=class extends ye{static tokenizer_class=we;static feature_extractor_class=tr;async _call(e){return await this.feature_extractor(e)}},w3=class{static async from_pretrained(e,t={}){let r=await yr(e,ws,!0,t),{image_processor_type:a,feature_extractor_type:n,processor_class:s}=r;if(s&&Y_[s])return Y_[s].from_pretrained(e,t);if(!a&&!n)throw new Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let i={};if(a){let o=pH[a.replace(/Fast$/,"")];if(!o)throw new Error(`Unknown image_processor_type: '${a}'.`);i.image_processor=new o(r)}if(n){let o=pH[n];if(o)i.image_processor=new o(r);else{let _=Rc[n];if(!_)throw new Error(`Unknown feature_extractor_type: '${n}'.`);i.feature_extractor=new _(r)}}let H={};return new ye(H,i,null)}};async function y3(e,t){return await yr(e,"config.json",!0,t)}function gn(e){let t={},r={};switch(e.model_type){case"llava":case"paligemma":case"gemma3":case"florence2":case"llava_onevision":case"idefics3":case"granite_speech":case"ultravox":case"voxtral":case"voxtral_realtime":case"smolvlm":case"gemma3n":case"gemma4":case"lfm2_vl":case"chatterbox":case"lighton_ocr":case"glm_ocr":case"mistral3":case"qwen2_5_vl":case"qwen3_vl":case"qwen3_vl_moe":r=gn(e.text_config);break;case"moondream1":r=gn(e.phi_config);break;case"musicgen":r=gn(e.decoder);break;case"multi_modality":r=gn(e.language_config);break;case"gpt2":case"gptj":case"jais":case"codegen":case"gpt_bigcode":t.num_heads="n_head",t.num_layers="n_layer",t.hidden_size="n_embd";break;case"gpt_neox":case"stablelm":case"opt":case"falcon":case"modernbert-decoder":t.num_heads="num_attention_heads",t.num_layers="num_hidden_layers",t.hidden_size="hidden_size";break;case"gpt_oss":case"llama":case"llama4_text":case"nanochat":case"apertus":case"arcee":case"afmoe":case"lfm2":case"lfm2_moe":case"smollm3":case"olmo":case"olmo2":case"olmo3":case"mobilellm":case"granite":case"granitemoehybrid":case"cohere":case"cohere2":case"mistral":case"voxtral_realtime_text":case"voxtral_realtime_encoder":case"starcoder2":case"qwen2":case"qwen2_moe":case"qwen2_vl":case"qwen2_vl_text":case"qwen2_5_vl_text":case"qwen3_moe":case"qwen3_vl_text":case"qwen3_vl_moe_text":case"phi":case"phi3":case"phi3_v":case"llava_qwen2":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.hidden_size="hidden_size",t.num_attention_heads="num_attention_heads",t.dim_kv="head_dim";break;case"qwen3":case"solar_open":case"glm_ocr_text":case"gemma":case"gemma2":case"vaultgemma":case"gemma3_text":case"gemma3n_text":case"gemma4_text":case"glm":case"helium":case"ernie4_5":case"hunyuan_v1_dense":case"falcon_h1":case"nemotron_h":case"ministral":case"ministral3":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.dim_kv="head_dim";break;case"openelm":t.num_heads="num_kv_heads",t.num_layers="num_transformer_layers",t.dim_kv="head_dim";break;case"gpt_neo":case"donut-swin":t.num_heads="num_heads",t.num_layers="num_layers",t.hidden_size="hidden_size";break;case"bloom":t.num_heads="n_head",t.num_layers="n_layer",t.hidden_size="hidden_size";break;case"mpt":t.num_heads="n_heads",t.num_layers="n_layers",t.hidden_size="d_model";break;case"exaone":t.num_heads="num_key_value_heads",t.num_layers="num_layers",t.dim_kv="head_dim",t.num_attention_heads="num_attention_heads";break;case"youtu":case"deepseek_v3":case"glm_moe_dsa":case"mistral4":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.dim_kv="qk_head_dim",t.num_attention_heads="num_attention_heads";break;case"t5":case"mt5":case"longt5":t.num_decoder_layers="num_decoder_layers",t.num_decoder_heads="num_heads",t.decoder_dim_kv="d_kv",t.num_encoder_layers="num_layers",t.num_encoder_heads="num_heads",t.encoder_dim_kv="d_kv";break;case"bart":case"mbart":case"marian":case"whisper":case"lite-whisper":case"m2m_100":case"blenderbot":case"blenderbot-small":case"florence2_language":t.num_decoder_layers="decoder_layers",t.num_decoder_heads="decoder_attention_heads",t.decoder_hidden_size="d_model",t.num_encoder_layers="encoder_layers",t.num_encoder_heads="encoder_attention_heads",t.encoder_hidden_size="d_model";break;case"speecht5":t.num_decoder_layers="decoder_layers",t.num_decoder_heads="decoder_attention_heads",t.decoder_hidden_size="hidden_size",t.num_encoder_layers="encoder_layers",t.num_encoder_heads="encoder_attention_heads",t.encoder_hidden_size="hidden_size";break;case"trocr":t.num_encoder_layers=t.num_decoder_layers="decoder_layers",t.num_encoder_heads=t.num_decoder_heads="decoder_attention_heads",t.encoder_hidden_size=t.decoder_hidden_size="d_model";break;case"musicgen_decoder":t.num_encoder_layers=t.num_decoder_layers="num_hidden_layers",t.num_encoder_heads=t.num_decoder_heads="num_attention_heads",t.encoder_hidden_size=t.decoder_hidden_size="hidden_size";break;case"moonshine":t.num_decoder_layers="decoder_num_hidden_layers",t.num_decoder_heads="decoder_num_key_value_heads",t.num_encoder_layers="encoder_num_hidden_layers",t.num_encoder_heads="encoder_num_key_value_heads",t.encoder_hidden_size=t.decoder_hidden_size="hidden_size";break;case"cohere_asr":t.num_decoder_layers="num_hidden_layers",t.num_decoder_heads="num_key_value_heads",t.decoder_hidden_size="hidden_size",t.decoder_dim_kv="head_dim";let{num_hidden_layers:n,num_attention_heads:s,hidden_size:i}=e.encoder_config;r={num_encoder_layers:n,num_encoder_heads:s,encoder_hidden_size:i,encoder_dim_kv:e.head_dim};break;case"vision-encoder-decoder":let H=gn(e.decoder),o="num_decoder_layers"in H,_=ht(e,["model_type","is_encoder_decoder"]);return o?(_.num_decoder_layers=H.num_decoder_layers,_.num_decoder_heads=H.num_decoder_heads,_.decoder_hidden_size=H.decoder_hidden_size,_.num_encoder_layers=H.num_encoder_layers,_.num_encoder_heads=H.num_encoder_heads,_.encoder_hidden_size=H.encoder_hidden_size):(_.num_layers=H.num_layers,_.num_heads=H.num_heads,_.hidden_size=H.hidden_size),_}let a={...r,...ht(e,["model_type","multi_query","is_encoder_decoder"])};for(let n in t)a[n]=e[t[n]];return a}function TH(e,t){e instanceof ec||(e=new ec(e));let r=t?.prefix??"past_key_values",a=r==="present"?"present":"past",n=new Set;if(["lfm2","lfm2_moe"].includes(e.model_type)){let{layer_types:s}=e;for(let i=0;i<s.length;++i)if(s[i]==="full_attention")n.add(`${r}.${i}.key`),n.add(`${r}.${i}.value`);else if(s[i]==="conv")n.add(`${a}_conv.${i}`);else throw new Error(`Unsupported layer type: ${s[i]}`);return n}else if(["granitemoehybrid","falcon_h1","nemotron_h"].includes(e.model_type)){let s=e,i=s.layer_types??s.layers_block_type,H=s.num_hidden_layers??i?.length;for(let o=0;o<H;++o)(!i||i[o]==="mamba")&&(n.add(`${a}_conv.${o}`),n.add(`${a}_ssm.${o}`)),(!i||i[o]==="attention")&&(n.add(`${r}.${o}.key`),n.add(`${r}.${o}.value`));return n}else if(["qwen3_next","qwen3_5_text","qwen3_5_moe_text","olmo_hybrid"].includes(e.model_type)){let{layer_types:s}=e;for(let i=0;i<s.length;++i)if(s[i]==="full_attention")n.add(`${r}.${i}.key`),n.add(`${r}.${i}.value`);else if(s[i]==="linear_attention")e.model_type==="olmo_hybrid"?(n.add(`${a}_conv.${i}.key`),n.add(`${a}_conv.${i}.value`),n.add(`${a}_conv.${i}.query`)):n.add(`${a}_conv.${i}`),n.add(`${a}_recurrent.${i}`);else throw new Error(`Unsupported layer type: ${s[i]}`);return n}else if(["gemma4","gemma4_text"].includes(e.model_type)){let s=e.model_type==="gemma4"?e.text_config:e,i=s.num_hidden_layers,H=s.num_kv_shared_layers??0,o=i-H;for(let _=0;_<o;++_)n.add(`${r}.${_}.key`),n.add(`${r}.${_}.value`);return n}else if(["lfm2_vl","qwen3_5","qwen3_5_moe","voxtral_realtime"].includes(e.model_type)){let s;return e.model_type==="voxtral_realtime"&&t?.session_name==="audio_encoder"?s=e.audio_config:s=e.text_config,TH(s,t)}return B3(e,{prefix:r})}function B3(e,{prefix:t="past_key_values"}={}){let r=new Set,a=e.normalized_config;if(a.is_encoder_decoder&&"num_encoder_heads"in a&&"num_decoder_heads"in a)for(let n=0;n<a.num_decoder_layers;++n)r.add(`${t}.${n}.encoder.key`),r.add(`${t}.${n}.encoder.value`),r.add(`${t}.${n}.decoder.key`),r.add(`${t}.${n}.decoder.value`);else if(a.multi_query)for(let n=0;n<a.num_layers;++n)r.add(`${t}.${n}.key_value`);else for(let n=0;n<a.num_layers;++n)r.add(`${t}.${n}.key`),r.add(`${t}.${n}.value`);return r}var ec=class tc{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(t){Object.assign(this,t),this.normalized_config=gn(this)}static async from_pretrained(t,{progress_callback:r=null,config:a=null,cache_dir:n=null,local_files_only:s=!1,revision:i="main"}={}){a&&!(a instanceof tc)&&(a=new tc(a));let H=a??await y3(t,{progress_callback:r,config:a,cache_dir:n,local_files_only:s,revision:i});return new this(H)}},ys=class{static async from_pretrained(...e){return ec.from_pretrained(...e)}};function HI(e,t,r){return e?typeof e=="object"&&e!==null?e.hasOwnProperty(t)?+e[t]:e.hasOwnProperty(r)?+e[r]:0:+e:0}function oI(e,t){let r=[];for(let a=0;a<t;++a)r.push(`${e}_data${a===0?"":"_"+a}`);return r}async function M3(e,t,r,a){let n=`${t}${a}.onnx`,s=`${r.subfolder??""}/${n}`;return await HH(e,s,!0,r,me.IS_NODE_ENV)}async function P3(e,t,r,a,n,s={}){let i=`${t}${r}.onnx`,H=me.IS_NODE_ENV,o=[],_=HI(n,i,t);if(_>0){if(_>F1)throw new Error(`The number of external data chunks (${_}) exceeds the maximum allowed value (${F1}).`);let c=oI(i,_);for(let l of c){let d=`${a.subfolder??""}/${l}`;o.push(new Promise(async(h,$)=>{let m=await HH(e,d,!0,a,H);h(m instanceof Uint8Array?{path:l,data:m}:l)}))}}else s.externalData!==void 0&&(o=s.externalData.map(async c=>{if(typeof c.data=="string"){let l=await HH(e,c.data,!0,a);return{...c,data:l}}return c}));return Promise.all(o)}async function R3(e,t,r,a=!1,n=void 0){let s=r.config?.["transformers.js_config"]??{},i=pm(r.device??s.device,t,{warn:T=>he.info(T)}),H=H2(i),o=s.device_config??{};o.hasOwnProperty(i)&&(s={...s,...o[i]});let _=hm(r.dtype??s.dtype,t,i,{configDtype:s.dtype,warn:T=>he.info(T)});if(xs.hasOwnProperty(_)){if(i==="webgpu"&&!me.IS_NODE_ENV&&_===tt.fp16&&!await c2())throw new Error(`The device (${i}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${_}. Should be one of: ${Object.keys(tt).join(", ")}`);let c=xs[_],l={...r.session_options};l.executionProviders??=H;let d=s.free_dimension_overrides;d?l.freeDimensionOverrides??=d:i.startsWith("webnn")&&!l.freeDimensionOverrides&&he.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${i}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let h=M3(e,t,r,c),$=r.use_external_data_format??s.use_external_data_format,m=await P3(e,t,c,r,$,l);if(m.length>0&&(!me.IS_NODE_ENV||m.some(T=>typeof T!="string"))&&(l.externalData=m),a&&i==="webgpu"){let T=TH(r.config,{prefix:"present",session_name:n});if(T.size>0&&!xc()){let D={};for(let v of T)D[v]="gpu-buffer";l.preferredOutputLocation=D}}return{buffer_or_path:await h,session_options:l,session_config:{dtype:_,device:i}}}async function k3(e,t,r,a=void 0){return Object.fromEntries(await Promise.all(Object.keys(t).map(async n=>{let s=a?.[n]??!1,{buffer_or_path:i,session_options:H,session_config:o}=await R3(e,t[n],r,s,n),_=await lm(i,H,o);return[n,_]})))}function _I(e){for(let t in e)dm(e[t])?e[t]=new K(e[t]):typeof e[t]=="object"&&_I(e[t]);return e}async function be(e,t){let r=O3(e,t);try{let a=Object.fromEntries(Object.entries(r).map(([s,i])=>{let H=i.ort_tensor;return me.IS_NODE_ENV&&typeof Float16Array<"u"&&H.cpuData instanceof Float16Array&&(H.cpuData=new Uint16Array(H.cpuData.buffer)),[s,H]})),n=await um(e,a);return _I(n)}catch(a){let n=Object.fromEntries(Object.entries(r).map(([s,i])=>{let H={type:i.type,dims:i.dims,location:i.location};return H.location!=="gpu-buffer"&&(H.data=i.data),[s,H]}));throw he.error(`An error occurred during model execution: "${a}".`),he.error("Inputs given to model:",n),a}}function O3(e,t){let r=Object.create(null),a=[];for(let i of e.inputNames){let H=t[i];if(!(H instanceof K)){a.push(i);continue}r[i]=xc()?H.clone():H}if(a.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${a.join(", ")}.`);let n=Object.keys(t).length,s=e.inputNames.length;if(n>s){let i=Object.keys(t).filter(H=>!e.inputNames.includes(H));he.warn(`WARNING: Too many inputs were provided (${n} > ${s}). The following inputs will be ignored: "${i.join(", ")}".`)}return r}var ot=class{},ue=class extends ot{constructor({logits:e,...t}){super(),this.logits=e;let r=Object.values(t);r.length>0&&(this.attentions=r)}},rt=class extends ot{constructor({logits:e}){super(),this.logits=e}},_t=class extends ot{constructor({logits:e}){super(),this.logits=e}},Dt=class extends ot{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}},Va=class extends ot{constructor({logits:e}){super(),this.logits=e}},G3=class extends ot{constructor({alphas:e}){super(),this.alphas=e}},dr=class extends Ft{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},Uc=class extends Ft{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},rc=class extends Ft{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let r=t;for(let a of this.processors)r=a(e,r);return r}[Symbol.iterator](){return this.processors.values()}},F3=class extends dr{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===1){let a=t[r].data;a.fill(-1/0),a[this.bos_token_id]=0}return t}},Z3=class extends dr{constructor(e,t){super(),this.max_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===this.max_length-1){let a=t[r].data;a.fill(-1/0);for(let n of this.eos_token_id)a[n]=0}return t}},U3=class extends dr{constructor(e){super(),this.suppress_tokens=e}_call(e,t){for(let r=0;r<e.length;++r){let a=t[r].data;for(let n of this.suppress_tokens)a[n]=-1/0}return t}},cI=class extends dr{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===this.begin_index){let a=t[r].data;for(let n of this.begin_suppress_tokens)a[n]=-1/0}return t}},K3=class extends dr{constructor(e,t){super(),this.eos_token_id=Array.isArray(e.eos_token_id)?e.eos_token_id[0]: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=t.length,t.at(-1)===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){for(let r=0;r<e.length;++r){let a=t[r].data;if(a[this.no_timestamps_token_id]=-1/0,e[r].length===this.begin_index){a.subarray(0,this.timestamp_begin).fill(-1/0);continue}let n=e[r].slice(this.begin_index),s=n.length>=1&&n[n.length-1]>=this.timestamp_begin,i=n.length<2||n[n.length-2]>=this.timestamp_begin;if(s&&(i?a.subarray(this.timestamp_begin).fill(-1/0):a.subarray(0,this.eos_token_id).fill(-1/0)),e[r].length===this.begin_index&&this.max_initial_timestamp_index!==null){let c=this.timestamp_begin+this.max_initial_timestamp_index;a.subarray(c+1).fill(-1/0)}let H=$B(a),o=Math.log(H.subarray(this.timestamp_begin).map(Math.exp).reduce((c,l)=>c+l)),_=et(H.subarray(0,this.timestamp_begin))[0];o>_&&a.subarray(0,this.timestamp_begin).fill(-1/0)}return t}},W3=class extends dr{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,r=[];for(let n=0;n<t+1-this.no_repeat_ngram_size;++n){let s=[];for(let i=0;i<this.no_repeat_ngram_size;++i)s.push(e[n+i]);r.push(s.map(Number))}let a=new Map;for(let n of r){let s=n.slice(0,n.length-1),i=JSON.stringify(s),H=a.get(i)??[];H.push(n[n.length-1]),a.set(i,H)}return a}getGeneratedNgrams(e,t){let r=t.slice(t.length+1-this.no_repeat_ngram_size,t.length);return e.get(JSON.stringify(r.map(Number)))??[]}calcBannedNgramTokens(e){let t=[];if(e.length+1<this.no_repeat_ngram_size)return t;{let r=this.getNgrams(e);return this.getGeneratedNgrams(r,e)}}_call(e,t){for(let r=0;r<e.length;++r){let a=t[r].data,n=this.calcBannedNgramTokens(e[r]);for(let s of n)a[s]=-1/0}return t}},V3=class extends dr{constructor(e){super(),this.penalty=e}_call(e,t){for(let r=0;r<e.length;++r){let a=t[r].data;for(let n of new Set(e[r])){let s=Number(n);a[s]<0?a[s]*=this.penalty:a[s]/=this.penalty}}return t}},j3=class extends dr{constructor(e,t){super(),this.min_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length<this.min_length){let a=t[r].data;for(let n of this.eos_token_id)a[n]=-1/0}return t}},q3=class extends dr{constructor(e,t,r){super(),this.prompt_length_to_skip=e,this.min_new_tokens=t,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length-this.prompt_length_to_skip<this.min_new_tokens){let n=t[r].data;for(let s of this.eos_token_id)n[s]=-1/0}return t}},X3=class extends dr{constructor(e,t){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r){let a=t[r].data,n=e[r];for(let s of this.bad_words_ids){if(n.length<s.length-1)continue;let i=!0;for(let H=1;H<=s.length-1;++H)if(s.at(-H-1)!=n.at(-H)){i=!1;break}i&&(a[s.at(-1)]=-1/0)}}return t}},z3=class extends dr{constructor(e){if(super(),e<=1)throw new Error(`Require guidance scale >1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw new Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${t.dims[0]} for the logits and ${e.length} for the input ids.`);let r=e.length,a=t.slice([0,r],null),n=t.slice([r,t.dims[0]],null);for(let s=0;s<n.data.length;++s)n.data[s]+=(a.data[s]-n.data[s])*this.guidance_scale;return n}},J3=class extends Uc{constructor(e){if(super(),typeof e!="number"||e<=0){let t=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(t+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,t){let r=t.data;for(let a=0;a<r.length;++a)r[a]/=this.temperature;return t}},N7=class extends Uc{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:r=1}={}){if(super(),e<0||e>1)throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(r)||r<1)throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${r}`);this.top_p=e,this.filter_value=t,this.min_tokens_to_keep=r}},w7=class extends Uc{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:r=1}={}){if(super(),!Number.isInteger(e)||e<0)throw new Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,r),this.filter_value=t}},lI=class{max_length=20;max_new_tokens=null;min_length=0;min_new_tokens=null;early_stopping=!1;max_time=null;do_sample=!1;num_beams=1;num_beam_groups=1;penalty_alpha=null;use_cache=!0;temperature=1;top_k=50;top_p=1;typical_p=1;epsilon_cutoff=0;eta_cutoff=0;diversity_penalty=0;repetition_penalty=1;encoder_repetition_penalty=1;length_penalty=1;no_repeat_ngram_size=0;bad_words_ids=null;force_words_ids=null;renormalize_logits=!1;constraints=null;forced_bos_token_id=null;forced_eos_token_id=null;remove_invalid_values=!1;exponential_decay_length_penalty=null;suppress_tokens=null;streamer=null;begin_suppress_tokens=null;forced_decoder_ids=null;guidance_scale=null;num_return_sequences=1;output_attentions=!1;output_hidden_states=!1;output_scores=!1;return_dict_in_generate=!1;pad_token_id=null;bos_token_id=null;eos_token_id=null;encoder_no_repeat_ngram_size=0;decoder_start_token_id=null;generation_kwargs={};constructor(e){Object.assign(this,ht(e,Object.getOwnPropertyNames(this)))}},Os=class extends Ft{_call(e,t){throw Error("StoppingCriteria needs to be subclassed")}},uI=class dI extends Ft{constructor(){super(),this.criteria=[]}push(t){this.criteria.push(t)}extend(t){t instanceof dI?t=t.criteria:t instanceof Os&&(t=[t]),this.criteria.push(...t)}_call(t,r){let a=new Array(t.length).fill(!1);for(let n of this.criteria){let s=n(t,r);for(let i=0;i<a.length;++i)a[i]||=s[i]}return a}[Symbol.iterator](){return this.criteria.values()}},Q3=class extends Os{constructor(e,t=null){super(),this.max_length=e,this.max_position_embeddings=t}_call(e){return e.map(t=>t.length>=this.max_length)}},Y3=class extends Os{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map(r=>{let a=r.at(-1);return this.eos_token_id.some(n=>a==n)})}},y7=class extends Os{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,t){return new Array(e.length).fill(this.interrupted)}},bH=class extends Ft{constructor(e){super(),this.generation_config=e}async _call(e){return this.sample(e)}async sample(e){throw Error("sample should be implemented in subclasses.")}getLogits(e,t){let r=e.dims.at(-1),a=e.data;if(t===-1)a=a.slice(-r);else{let n=t*r;a=a.slice(n,n+r)}return a}randomSelect(e){return tB(e)}static getSampler(e){if(e.do_sample)return new t5(e);if(e.num_beams>1)return new r5(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 e5(e)}},e5=class extends bH{async sample(e){let t=et(e.data)[1];return[[BigInt(t),0]]}},t5=class extends bH{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[r,a]=await Rn(e,t),n=St(r.data);return Array.from({length:this.generation_config.num_beams},()=>{let s=this.randomSelect(n);return[a.data[s],Math.log(n[s])]})}},r5=class extends bH{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[r,a]=await Rn(e,t),n=St(r.data);return Array.from({length:this.generation_config.num_beams},(s,i)=>[a.data[i],Math.log(n[i])])}},a5=class{constructor(e){if(e)for(let t in e){if(t in this)throw new TypeError(`Key "${t}" conflicts with an existing property on DynamicCache`);let r=e[t];if(!(r instanceof K))throw new TypeError(`Expected a Tensor for key "${t}", got ${typeof r}`);this[t]=r}}get_seq_length(){let e=this;if(Object.keys(e).length===0)return 0;for(let t in e)if(t.startsWith("past_key_values."))return e[t].dims.at(-2);throw new Error("Unable to determine sequence length from the cache.")}update(e){for(let t in e){let r=this[t],a=e[t];r&&r!==a&&r.location==="gpu-buffer"&&r.dispose(),this[t]=a}}async dispose(){let e=[];for(let t of Object.values(this))t.location==="gpu-buffer"&&e.push(t.dispose());await Promise.all(e)}},Kc=a5,V={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,DecoderOnlyWithoutHead:5,MaskGeneration:6,ImageTextToText:7,Musicgen:8,MultiModality:9,Phi3V:10,AudioTextToText:11,AutoEncoder:12,ImageAudioTextToText:13,Supertonic:14,Chatterbox:15,VoxtralRealtime:16},jr={[V.DecoderOnly]:{sessions:(e,t)=>({model:t.model_file_name??"model"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[V.DecoderOnlyWithoutHead]:{sessions:(e,t)=>({model:t.model_file_name??"model"})},[V.Seq2Seq]:{sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[V.Vision2Seq]:{sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[V.Musicgen]:{sessions:()=>({model:"text_encoder",decoder_model_merged:"decoder_model_merged",encodec_decode:"encodec_decode"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[V.EncoderDecoder]:{sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0}},[V.MaskGeneration]:{sessions:()=>({model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"})},[V.ImageTextToText]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{let a={...jr[V.ImageTextToText].text_only_sessions};return r||(a.vision_encoder="vision_encoder"),e.is_encoder_decoder&&(a.model="encoder_model"),a},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[V.AudioTextToText]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{let a={...jr[V.AudioTextToText].text_only_sessions};return r||(a.audio_encoder="audio_encoder"),a},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[V.ImageAudioTextToText]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{let a={...jr[V.ImageAudioTextToText].text_only_sessions};return r||(a.audio_encoder="audio_encoder",a.vision_encoder="vision_encoder"),a},optional_configs:{generation_config:"generation_config.json"}},[V.Phi3V]:{sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"model",vision_encoder:"vision_encoder"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[V.MultiModality]:{sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"language_model",lm_head:"lm_head",gen_head:"gen_head",gen_img_embeds:"gen_img_embeds",image_decode:"image_decode"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[V.AutoEncoder]:{sessions:()=>({encoder_model:"encoder_model",decoder_model:"decoder_model"})},[V.Supertonic]:{sessions:()=>({text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"})},[V.Chatterbox]:{sessions:()=>({embed_tokens:"embed_tokens",speech_encoder:"speech_encoder",model:"language_model",conditional_decoder:"conditional_decoder"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[V.VoxtralRealtime]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{let a={...jr[V.VoxtralRealtime].text_only_sessions};return r||(a.audio_encoder="audio_encoder"),a},cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:"generation_config.json"}},default:{sessions:(e,t)=>({model:t.model_file_name??"model"})}};function n5(e){return jr[e]?.text_only_sessions??null}function pI(e,t,r={}){let a=jr[e]??jr.default;return{sessions:a.sessions(t,r,r.textOnly??!1),cache_sessions:a.cache_sessions,optional_configs:a.optional_configs}}function Wc(e,{warn:t=!0}={}){let r=e.architectures||[];for(let a of r){let n=qr.get(a);if(n!==void 0)return n}if(e.model_type){let a=qr.get(e.model_type);if(a!==void 0)return a;for(let n of Object.values(Tn))if(n.has(e.model_type)){let s=qr.get(n.get(e.model_type));if(s!==void 0)return s}}if(t){let a=r.length>0?r.join(", "):"(none)";he.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${a}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${AH}`)}return V.EncoderOnly}function Vc(e,{config:t=null,cache_dir:r=null,local_files_only:a=!1,revision:n="main"}={}){if(t!==null)return ys.from_pretrained(e,{config:t,cache_dir:r,local_files_only:a,revision:n});let s=JSON.stringify([e,r,a,n]);return l0(s,()=>ys.from_pretrained(e,{config:t,cache_dir:r,local_files_only:a,revision:n}))}async function jc(e,{config:t=null,dtype:r=null,device:a=null,model_file_name:n=null}={}){t=await Vc(e,{config:t});let s=["config.json"],i=t["transformers.js_config"]??{},H=i.use_external_data_format,o="onnx",_=a??i.device,c=r??i.dtype,l=Wc(t),d=(m,S=null)=>{S=S??m;let I=pm(_,m),T=hm(c,m,I),D=xs[T]??"",v=`${S}${D}.onnx`,C=o?`${o}/${v}`:v;s.push(C);let R=HI(H,v,m);for(let A of oI(v,R)){let U=o?`${o}/${A}`:A;s.push(U)}},{sessions:h,optional_configs:$}=pI(l,t,{model_file_name:n});for(let[m,S]of Object.entries(h))d(m,S);if($)for(let m of Object.values($))s.push(m);return s}var Tn=null;function s5(e){Tn=e}function ac(e){if(e instanceof K)return e;if(e.length===0)throw Error("items must be non-empty");if(Array.isArray(e[0])){if(e.some(t=>t.length!==e[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new K("int64",BigInt64Array.from(e.flat().map(t=>BigInt(t))),[e.length,e[0].length])}else return new K("int64",BigInt64Array.from(e.map(t=>BigInt(t))),[1,e.length])}function hI(e){return new K("bool",[e],[1])}var k$={[V.DecoderOnly]:{can_generate:!0,forward:zr,prepare_inputs:vs},[V.DecoderOnlyWithoutHead]:{can_generate:!1,forward:zr,prepare_inputs:vs},[V.Seq2Seq]:{can_generate:!0,forward:Ji,prepare_inputs:hH},[V.Vision2Seq]:{can_generate:!0,forward:Ji,prepare_inputs:hH},[V.Musicgen]:{can_generate:!0,forward:Ji},[V.EncoderDecoder]:{can_generate:!1,forward:Ji},[V.ImageTextToText]:{can_generate:!0,forward:_5,prepare_inputs:Qi},[V.AudioTextToText]:{can_generate:!0,forward:o5,prepare_inputs:Qi},[V.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:Qi},[V.Phi3V]:{can_generate:!0,prepare_inputs:Qi},[V.MultiModality]:{can_generate:!0},[V.AutoEncoder]:{can_generate:!1,forward:i5},[V.Chatterbox]:{can_generate:!0,forward:Ea},[V.VoxtralRealtime]:{can_generate:!0,prepare_inputs:vs},default:{can_generate:!1,forward:Ea}};function O$(e,t){let r=qr.get(e),a=!1,n=t?.architectures?.[0];if(n&&n!==e&&e?.endsWith("ForCausalLM")&&n.endsWith("ForConditionalGeneration")){let H=qr.get(n);H!==void 0&&(r=H,a=!0)}let s=k$[r]??k$.default,i=jr[r]??jr.default;return{typeConfig:{...s,...i},textOnly:a,modelType:r}}var qr=new Map,qc=new Map,Nn=new Map,N=class extends Ft{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];_return_dict_in_generate_keys=null;constructor(e,t,r){super(),this.config=e,this.sessions=t,this.configs=r;let a=Nn.get(this.constructor),{typeConfig:n}=O$(a,e);this.can_generate=n.can_generate,this._forward=n.forward,this._prepare_inputs_for_generation=n.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){let e=[];for(let t of Object.values(this.sessions))e.push(t.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:a=null,local_files_only:n=!1,revision:s="main",model_file_name:i=null,subfolder:H="onnx",device:o=null,dtype:_=null,use_external_data_format:c=null,session_options:l={}}={}){let d={progress_callback:t,config:r,cache_dir:a,local_files_only:n,revision:s,model_file_name:i,subfolder:H,device:o,dtype:_,use_external_data_format:c,session_options:l},h=Nn.get(this);r=d.config=await ys.from_pretrained(e,d);let{typeConfig:$,textOnly:m,modelType:S}=O$(h,r);if(S===void 0){let v=h??r?.model_type;v!=="custom"&&he.warn(`Model type for '${v}' not found, assuming encoder-only architecture. Please report this at ${AH}.`)}if(t&&!(t instanceof U_)){let v={};try{let C=await jc(e,{config:r,dtype:_,device:o,model_file_name:i});(await Promise.all(C.map(A=>Ua(e,A,d)))).forEach((A,U)=>{if(A.exists){let Z=C[U]==="config.json";v[C[U]]={loaded:Z?A.size??0:0,total:A.size??0}}})}catch(C){he.warn(`Unable to fetch model file metadata for total progress tracking: ${C}`)}Object.keys(v).length>0&&(d.progress_callback=new U_(t,v))}let I=$.sessions(r,d,m),T=[k3(e,I,d,$.cache_sessions)];$.optional_configs&&T.push(l5(e,$.optional_configs,d));let D=await Promise.all(T);return new this(r,...D)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}get generation_config(){return this.configs?.generation_config??null}_get_logits_processor(e,t,r=null){let a=new rc;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&a.push(new V3(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&a.push(new W3(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&a.push(new X3(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&a.push(new j3(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&a.push(new q3(t,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&a.push(new F3(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&a.push(new Z3(e.max_length,e.forced_eos_token_id)),e.suppress_tokens!==null&&a.push(new U3(e.suppress_tokens)),e.begin_suppress_tokens!==null){let n=t>1||e.forced_bos_token_id===null?t:t+1;a.push(new cI(e.begin_suppress_tokens,n))}return e.guidance_scale!==null&&e.guidance_scale>1&&a.push(new z3(e.guidance_scale)),e.temperature===0&&e.do_sample&&(he.warn("`do_sample` changed to false because `temperature: 0` implies greedy sampling (always selecting the most likely token), which is incompatible with `do_sample: true`."),e.do_sample=!1),e.do_sample&&e.temperature!==null&&e.temperature!==1&&a.push(new J3(e.temperature)),r!==null&&a.extend(r),a}_prepare_generation_config(e,t,r=lI){let a={...this.config};for(let s of["decoder","generator","text_config"])s in a&&Object.assign(a,a[s]);let n=new r(a);return Object.assign(n,this.generation_config??{}),e&&Object.assign(n,e),t&&Object.assign(n,ht(t,Object.getOwnPropertyNames(n))),n}_get_stopping_criteria(e,t=null){let r=new uI;return e.max_length!==null&&r.push(new Q3(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&r.push(new Y3(e.eos_token_id)),t&&r.extend(t),r}_validate_model_class(){if(!this.can_generate){let e=[Tn.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,Tn.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,Tn.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,Tn.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),t=Nn.get(this.constructor),r=new Set,a=this.config.model_type;for(let s of e){let i=s?.get(a);i&&r.add(i)}let n=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw r.size>0&&(n+=` Please use the following class instead: ${[...r].join(", ")}`),Error(n)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw new Error("prepare_inputs_for_generation is not implemented for this model.");return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:t,model_inputs:r,is_encoder_decoder:a}){return r.past_key_values=nc(t,r.past_key_values),r.input_ids=new K("int64",e.flat(),[e.length,1]),a?"decoder_attention_mask"in r&&(r.decoder_attention_mask=je([r.decoder_attention_mask,Gt([r.decoder_attention_mask.dims[0],1])],1)):r.attention_mask=je([r.attention_mask,Gt([r.attention_mask.dims[0],1])],1),r.position_ids=null,r}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:r}){let a=ht(r,this.forward_params),n=this.main_input_name;if(n in a){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else a[n]=e;return{inputs_tensor:a[n],model_inputs:a,model_input_name:n}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:r,generation_config:a}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!t.inputs_embeds&&"_prepare_inputs_embeds"in this){let{input_ids:s,pixel_values:i,attention_mask:H,...o}=t,_=await this._prepare_inputs_embeds(t);t={...o,...ht(_,["inputs_embeds","attention_mask"])}}let{last_hidden_state:n}=await Ea(this,t);if(a.guidance_scale!==null&&a.guidance_scale>1)n=je([n,Q_(n,0)],0),"attention_mask"in t&&(t.attention_mask=je([t.attention_mask,Sm(t.attention_mask)],0));else if(t.decoder_input_ids){let s=ac(t.decoder_input_ids).dims[0];if(s!==n.dims[0]){if(n.dims[0]!==1)throw new Error(`The encoder outputs have a different batch size (${n.dims[0]}) than the decoder inputs (${s}).`);n=je(Array.from({length:s},()=>n),0)}}return t.encoder_outputs=n,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:r,decoder_start_token_id:a,bos_token_id:n,generation_config:s}){let{decoder_input_ids:i,...H}=r;if(!(i instanceof K)){if(i)Array.isArray(i[0])||(i=Array.from({length:e},()=>i));else if(a??=n,this.config.model_type==="musicgen")i=Array.from({length:e*this.config.decoder.num_codebooks},()=>[a]);else if(Array.isArray(a)){if(a.length!==e)throw new Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${a.length}`);i=a}else i=Array.from({length:e},()=>[a]);i=ac(i)}return H.decoder_attention_mask=mm(i),{input_ids:i,model_inputs:H}}async generate({inputs:e=null,generation_config:t=null,logits_processor:r=null,stopping_criteria:a=null,streamer:n=null,...s}){this._validate_model_class(),t=this._prepare_generation_config(t,s);let{inputs_tensor:i,model_inputs:H,model_input_name:o}=this._prepare_model_inputs({inputs:e,model_kwargs:s}),_=this.config.is_encoder_decoder;_&&("encoder_outputs"in H||(H=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:i,model_inputs:H,model_input_name:o,generation_config:t})));let c;_?{input_ids:c,model_inputs:H}=this._prepare_decoder_input_ids_for_generation({batch_size:H[o].dims.at(0),model_input_name:o,model_kwargs:H,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t}):c=H[o];let l=c.dims.at(-1);t.max_new_tokens!==null&&(t.max_length=l+t.max_new_tokens);let d=this._get_logits_processor(t,l,r),h=this._get_stopping_criteria(t,a),$=H[o].dims.at(0),m=bH.getSampler(t),S=new Array($).fill(0),I=c.tolist();n&&n.put(I);let T,D={},v={};for(;;){if(H=this.prepare_inputs_for_generation(I,H,t),T=await this.forward(H),t.return_dict_in_generate)if(t.output_attentions){let q=H5(T);for(let G in q)G in D||(D[G]=[]),D[G].push(q[G])}else this._return_dict_in_generate_keys&&Object.assign(v,ht(T,this._return_dict_in_generate_keys));let Z=T.logits.slice(null,-1,null).to("float32"),j=d(I,Z),z=[];for(let q=0;q<j.dims.at(0);++q){let G=j[q],y=await m(G);for(let[Q,_e]of y){let M=BigInt(Q);S[q]+=_e,I[q].push(M),z.push([M]);break}}if(n&&n.put(z),h(I).every(q=>q))break;H=this._update_model_kwargs_for_generation({generated_input_ids:z,outputs:T,model_inputs:H,is_encoder_decoder:_})}n&&n.end();let C=new K("int64",I.flat(),[I.length,I[0].length]),R=nc(T,H.past_key_values),A=new Set(Object.values(R));for(let Z of Object.values(T))Z.location==="gpu-buffer"&&!A.has(Z)&&Z.dispose();return"past_key_values"in s||t.return_dict_in_generate||await R.dispose(),t.return_dict_in_generate?{sequences:C,past_key_values:R,...D,...v}:C}async _encode_input(e,t,r){if(!Object.hasOwn(this.sessions,e))throw new Error(`Model does not have a ${e} session.`);let a=this.sessions[e];return(await be(a,ht(t,a.inputNames)))[r]}async encode_image(e){return this._encode_input("vision_encoder",e,"image_features")}async encode_text(e){return this._encode_input("embed_tokens",e,"inputs_embeds")}async encode_audio(e){return this._encode_input("audio_encoder",e,"audio_features")}};async function Ji(e,t){let{encoder_outputs:r,input_ids:a,decoder_input_ids:n,decoder_attention_mask:s,...i}=t;if(!r){let H=ht(t,e.sessions.model.inputNames);r=(await Ea(e,H)).last_hidden_state}return i.input_ids=n,i.encoder_hidden_states=r,e.sessions.decoder_model_merged.inputNames.includes("encoder_attention_mask")&&(i.encoder_attention_mask=t.attention_mask),s&&!i.attention_mask&&(i.attention_mask=s),await zr(e,i,!0)}async function Ea(e,t){let r=e.sessions.model,a=ht(t,r.inputNames);if(r.inputNames.includes("inputs_embeds")&&!a.inputs_embeds){if(!t.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");a.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}if(r.inputNames.includes("token_type_ids")&&!a.token_type_ids){if(!a.input_ids)throw new Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");a.token_type_ids=Sm(a.input_ids)}if(r.inputNames.includes("pixel_mask")&&!a.pixel_mask){if(!a.pixel_values)throw new Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let n=a.pixel_values.dims;a.pixel_mask=Gt([n[0],n[2],n[3]])}return await be(r,a)}async function i5(e,t){let r=await e.encode(t);return await e.decode(r)}function nc(e,t){let r=Object.create(null);for(let a in e)if(a.startsWith("present")){let n=a.replace("present_ssm","past_ssm").replace("present_conv","past_conv").replace("present_recurrent","past_recurrent").replace("present","past_key_values");a.includes("encoder")&&t?r[n]=t[n]:r[n]=e[a]}return t?(t.update(r),t):new Kc(r)}function H5(e){let t={};for(let r of["cross_attentions","encoder_attentions","decoder_attentions"])for(let a in e)a.startsWith(r)&&(r in t||(t[r]=[]),t[r].push(e[a]));return t}function fI(e,t){return e.map(r=>typeof r=="number"?r:t[r]??0)}function Xc(e,t,r){if(r&&Object.keys(r).length>0)return Object.assign(t,r),r;let a=e.sessions.decoder_model_merged??e.sessions.model,n=(t[e.main_input_name]??t.attention_mask)?.dims?.[0]??1,s=TH(e.config),i=e.config?.normalized_config?.num_heads,H={batch_size:n};typeof i=="number"&&(H["batch_size x num_heads"]=n*i);let o=Object.create(null);for(let _ of a.inputMetadata){if(!s.has(_.name))continue;let c=fI(_.shape,H),l=c.reduce(($,m)=>$*m,1),d=Ns[_.type],h=new K(_.type,new d(l),c);t[_.name]=h,o[_.name]=h}return r?(r.update(o),r):new Kc(o)}async function zr(e,t,r=!1){let a=e.sessions[r?"decoder_model_merged":"model"],{past_key_values:n,...s}=t;if(a.inputNames.includes("use_cache_branch")&&(s.use_cache_branch=hI(n!=null&&Object.keys(n).length>0)),a.inputNames.includes("position_ids")&&s.attention_mask&&!s.position_ids){let H=["paligemma","gemma3_text","gemma3"].includes(e.config.model_type)?1:0;s.position_ids=c5(s,n,H)}a.inputNames.includes("num_logits_to_keep")&&!s.num_logits_to_keep&&(s.num_logits_to_keep=new K("int64",[0n],[])),Xc(e,s,n);let i=ht(s,a.inputNames);return await be(a,i)}async function EI(e,{encode_function:t,merge_function:r,modality_input_names:a,modality_output_name:n,input_ids:s=null,attention_mask:i=null,position_ids:H=null,inputs_embeds:o=null,past_key_values:_=null,generation_config:c=null,logits_processor:l=null,...d}){if(!o){o=await e.encode_text({input_ids:s,...d});let $=ht(d,a);if(Object.keys($).length>0){if(s.dims[1]!==1){let m=await t({...$,...d});({inputs_embeds:o,attention_mask:i}=r({[n]:m,inputs_embeds:o,input_ids:s,attention_mask:i}))}else if(_&&s.dims[1]===1){let m=s.dims[1],S=_.get_seq_length();i=je([Gt([s.dims[0],S]),i.slice(null,[i.dims[1]-m,i.dims[1]])],1)}}}if(!H&&["qwen2_vl","qwen2_vl_text","qwen2_5_vl","qwen2_5_vl_text","qwen3_vl","qwen3_vl_text","qwen3_vl_moe","qwen3_vl_moe_text","qwen3_5","qwen3_5_text","qwen3_5_moe","qwen3_5_moe_text","glm_ocr","glm_ocr_text"].includes(e.config.model_type)){let{image_grid_thw:$,video_grid_thw:m}=d;[H]=e.get_rope_index(s,$,m,i)}return await zr(e,{inputs_embeds:o,past_key_values:_,attention_mask:i,position_ids:H,generation_config:c,logits_processor:l},!0)}async function o5(e,t){return await EI(e,{...t,modality_input_names:["audio_values","input_features"],modality_output_name:"audio_features",encode_function:e.encode_audio.bind(e),merge_function:e._merge_input_ids_with_audio_features.bind(e)})}async function _5(e,t){return await EI(e,{...t,modality_input_names:["pixel_values"],modality_output_name:"image_features",encode_function:e.encode_image.bind(e),merge_function:e._merge_input_ids_with_image_features.bind(e)})}function $I(e,t=0){let[r,a]=e.dims,n=e.data,s=new BigInt64Array(n.length);for(let i=0;i<r;++i){let H=i*a,o=BigInt(t);for(let _=0;_<a;++_){let c=H+_;n[c]===0n?s[c]=BigInt(1):(s[c]=o,o+=n[c])}}return{data:s,dims:e.dims}}function c5(e,t=null,r=0){let{input_ids:a,inputs_embeds:n,attention_mask:s}=e,{data:i,dims:H}=$I(s,r),o=new K("int64",i,H);if(t){let _=-(a??n).dims.at(1);o=o.slice(null,[_,null])}return o}function vs(e,t,r,a){let n=r.past_key_values?r.past_key_values.get_seq_length():0;if((e.sessions.decoder_model_merged??e.sessions.model)?.inputNames.includes("num_logits_to_keep")&&!r.num_logits_to_keep&&(r.num_logits_to_keep=new K("int64",[1n],[])),!r.attention_mask){let i;for(let H of["input_ids","inputs_embeds","position_ids"])if(r[H]){i=r[H].dims;break}if(!i)throw new Error("attention_mask is not provided, and unable to infer its shape from model inputs.");r.attention_mask=Gt([i[0],n+i[1]])}if(r.past_key_values){let{input_ids:i,attention_mask:H}=r;H&&H.dims[1]>i.dims[1]||n<i.dims[1]&&(r.input_ids=i.slice(null,[n,null]))}return r}function hH(e,t,r,a){return r.past_key_values&&(t=t.map(n=>[n.at(-1)])),{...r,decoder_input_ids:ac(t)}}function Qi(e,...t){return e.config.is_encoder_decoder?hH(e,...t):vs(e,...t)}function mI({modality_token_id:e,inputs_embeds:t,modality_features:r,input_ids:a,attention_mask:n}){let s=a.tolist().map(_=>_.reduce((c,l,d)=>(l==e&&c.push(d),c),[])),i=s.reduce((_,c)=>_+c.length,0),H=r.dims[0];if(i!==H)throw new Error(`Number of tokens and features do not match: tokens: ${i}, features ${H}`);let o=0;for(let _=0;_<s.length;++_){let c=s[_],l=t[_];for(let d=0;d<c.length;++d)l[c[d]].data.set(r[o++].data)}return{inputs_embeds:t,attention_mask:n}}function zc({image_token_id:e,inputs_embeds:t,image_features:r,input_ids:a,attention_mask:n}){return mI({modality_token_id:e,inputs_embeds:t,modality_features:r,input_ids:a,attention_mask:n})}function II({audio_token_id:e,inputs_embeds:t,audio_features:r,input_ids:a,attention_mask:n}){return mI({modality_token_id:e,inputs_embeds:t,modality_features:r,input_ids:a,attention_mask:n})}async function l5(e,t,r){return Object.fromEntries(await Promise.all(Object.keys(t).map(async a=>{let n=await yr(e,t[a],!1,r);return[a,n]})))}var Jc={};wn(Jc,{ASTForAudioClassification:()=>A5,ASTModel:()=>L5,ASTPreTrainedModel:()=>tl,AfmoeForCausalLM:()=>m5,AfmoeModel:()=>$5,AfmoePreTrainedModel:()=>Yc,AlbertForMaskedLM:()=>h5,AlbertForQuestionAnswering:()=>p5,AlbertForSequenceClassification:()=>d5,AlbertModel:()=>u5,AlbertPreTrainedModel:()=>Gs,ApertusForCausalLM:()=>E5,ApertusModel:()=>f5,ApertusPreTrainedModel:()=>Qc,ArceeForCausalLM:()=>S5,ArceeModel:()=>I5,ArceePreTrainedModel:()=>el,BartForConditionalGeneration:()=>T5,BartForSequenceClassification:()=>b5,BartModel:()=>g5,BartPretrainedModel:()=>vH,BeitForImageClassification:()=>D5,BeitModel:()=>v5,BeitPreTrainedModel:()=>rl,BertForMaskedLM:()=>x5,BertForQuestionAnswering:()=>y5,BertForSequenceClassification:()=>N5,BertForTokenClassification:()=>w5,BertModel:()=>C5,BertPreTrainedModel:()=>kn,BlenderbotForConditionalGeneration:()=>M5,BlenderbotModel:()=>B5,BlenderbotPreTrainedModel:()=>al,BlenderbotSmallForConditionalGeneration:()=>R5,BlenderbotSmallModel:()=>P5,BlenderbotSmallPreTrainedModel:()=>nl,BloomForCausalLM:()=>O5,BloomModel:()=>k5,BloomPreTrainedModel:()=>sl,CHMv2ForDepthEstimation:()=>j5,CHMv2PreTrainedModel:()=>gI,CLIPModel:()=>X5,CLIPPreTrainedModel:()=>ja,CLIPSegForImageSegmentation:()=>eR,CLIPSegModel:()=>Y5,CLIPSegPreTrainedModel:()=>il,CLIPTextModel:()=>z5,CLIPTextModelWithProjection:()=>vI,CLIPVisionModel:()=>J5,CLIPVisionModelWithProjection:()=>Q5,CamembertForMaskedLM:()=>F5,CamembertForQuestionAnswering:()=>K5,CamembertForSequenceClassification:()=>Z5,CamembertForTokenClassification:()=>U5,CamembertModel:()=>G5,CamembertPreTrainedModel:()=>On,ChatterboxModel:()=>LI,ChatterboxPreTrainedModel:()=>SI,ChineseCLIPModel:()=>V5,ChineseCLIPPreTrainedModel:()=>AI,ClapAudioModelWithProjection:()=>bI,ClapModel:()=>q5,ClapPreTrainedModel:()=>DH,ClapTextModelWithProjection:()=>TI,CodeGenForCausalLM:()=>rR,CodeGenModel:()=>tR,CodeGenPreTrainedModel:()=>Hl,Cohere2ForCausalLM:()=>iR,Cohere2Model:()=>sR,Cohere2PreTrainedModel:()=>_l,CohereAsrForConditionalGeneration:()=>oR,CohereAsrModel:()=>HR,CohereAsrPreTrainedModel:()=>cl,CohereForCausalLM:()=>nR,CohereModel:()=>aR,CoherePreTrainedModel:()=>ol,ConvBertForMaskedLM:()=>cR,ConvBertForQuestionAnswering:()=>dR,ConvBertForSequenceClassification:()=>lR,ConvBertForTokenClassification:()=>uR,ConvBertModel:()=>_R,ConvBertPreTrainedModel:()=>Gn,ConvNextForImageClassification:()=>hR,ConvNextModel:()=>pR,ConvNextPreTrainedModel:()=>ll,ConvNextV2ForImageClassification:()=>ER,ConvNextV2Model:()=>fR,ConvNextV2PreTrainedModel:()=>ul,DFineForObjectDetection:()=>SR,DFineModel:()=>IR,DFinePreTrainedModel:()=>pl,DINOv3ConvNextModel:()=>jR,DINOv3ConvNextPreTrainedModel:()=>PI,DINOv3ViTModel:()=>qR,DINOv3ViTPreTrainedModel:()=>RI,DPTForDepthEstimation:()=>rk,DPTModel:()=>tk,DPTPreTrainedModel:()=>Il,DacDecoderModel:()=>NI,DacDecoderOutput:()=>CI,DacEncoderModel:()=>xI,DacEncoderOutput:()=>DI,DacModel:()=>LR,DacPreTrainedModel:()=>CH,DebertaForMaskedLM:()=>gR,DebertaForQuestionAnswering:()=>vR,DebertaForSequenceClassification:()=>TR,DebertaForTokenClassification:()=>bR,DebertaModel:()=>AR,DebertaPreTrainedModel:()=>Fn,DebertaV2ForMaskedLM:()=>NR,DebertaV2ForQuestionAnswering:()=>BR,DebertaV2ForSequenceClassification:()=>wR,DebertaV2ForTokenClassification:()=>yR,DebertaV2Model:()=>xR,DebertaV2PreTrainedModel:()=>Zn,DecisionTransformerModel:()=>MR,DecisionTransformerPreTrainedModel:()=>wI,DeepseekV3ForCausalLM:()=>CR,DeepseekV3Model:()=>DR,DeepseekV3PreTrainedModel:()=>hl,DeiTForImageClassification:()=>RR,DeiTModel:()=>PR,DeiTPreTrainedModel:()=>fl,DepthAnythingForDepthEstimation:()=>kR,DepthAnythingPreTrainedModel:()=>yI,DepthProForDepthEstimation:()=>OR,DepthProPreTrainedModel:()=>BI,DetrForObjectDetection:()=>FR,DetrForSegmentation:()=>ZR,DetrModel:()=>GR,DetrObjectDetectionOutput:()=>El,DetrPreTrainedModel:()=>xH,DetrSegmentationOutput:()=>MI,Dinov2ForImageClassification:()=>KR,Dinov2Model:()=>UR,Dinov2PreTrainedModel:()=>$l,Dinov2WithRegistersForImageClassification:()=>VR,Dinov2WithRegistersModel:()=>WR,Dinov2WithRegistersPreTrainedModel:()=>ml,DistilBertForMaskedLM:()=>YR,DistilBertForQuestionAnswering:()=>QR,DistilBertForSequenceClassification:()=>zR,DistilBertForTokenClassification:()=>JR,DistilBertModel:()=>XR,DistilBertPreTrainedModel:()=>Un,DonutSwinModel:()=>ek,DonutSwinPreTrainedModel:()=>kI,EdgeTamModel:()=>d9,EfficientNetForImageClassification:()=>nk,EfficientNetModel:()=>ak,EfficientNetPreTrainedModel:()=>Sl,ElectraForMaskedLM:()=>ik,ElectraForQuestionAnswering:()=>_k,ElectraForSequenceClassification:()=>Hk,ElectraForTokenClassification:()=>ok,ElectraModel:()=>sk,ElectraPreTrainedModel:()=>Kn,Ernie4_5ForCausalLM:()=>lk,Ernie4_5Model:()=>ck,Ernie4_5PretrainedModel:()=>Ll,EsmForMaskedLM:()=>dk,EsmForSequenceClassification:()=>pk,EsmForTokenClassification:()=>hk,EsmModel:()=>uk,EsmPreTrainedModel:()=>Zs,EuroBertForMaskedLM:()=>Ek,EuroBertForSequenceClassification:()=>$k,EuroBertForTokenClassification:()=>mk,EuroBertModel:()=>fk,EuroBertPreTrainedModel:()=>Us,ExaoneForCausalLM:()=>Sk,ExaoneModel:()=>Ik,ExaonePreTrainedModel:()=>Al,FalconForCausalLM:()=>Ak,FalconH1ForCausalLM:()=>Tk,FalconH1Model:()=>gk,FalconH1PreTrainedModel:()=>Tl,FalconModel:()=>Lk,FalconPreTrainedModel:()=>gl,FastViTForImageClassification:()=>vk,FastViTModel:()=>bk,FastViTPreTrainedModel:()=>bl,Florence2ForConditionalGeneration:()=>Dk,Florence2PreTrainedModel:()=>OI,GLPNForDepthEstimation:()=>Wk,GLPNModel:()=>Kk,GLPNPreTrainedModel:()=>Bl,GPT2LMHeadModel:()=>t4,GPT2Model:()=>e4,GPT2PreTrainedModel:()=>Ol,GPTBigCodeForCausalLM:()=>jk,GPTBigCodeModel:()=>Vk,GPTBigCodePreTrainedModel:()=>Ml,GPTJForCausalLM:()=>a4,GPTJModel:()=>r4,GPTJPreTrainedModel:()=>Gl,GPTNeoForCausalLM:()=>Xk,GPTNeoModel:()=>qk,GPTNeoPreTrainedModel:()=>Pl,GPTNeoXForCausalLM:()=>Jk,GPTNeoXModel:()=>zk,GPTNeoXPreTrainedModel:()=>Rl,Gemma2ForCausalLM:()=>wk,Gemma2Model:()=>Nk,Gemma2PreTrainedModel:()=>Dl,Gemma3ForCausalLM:()=>Pk,Gemma3ForConditionalGeneration:()=>ZI,Gemma3Model:()=>Mk,Gemma3PreTrainedModel:()=>FI,Gemma3nForCausalLM:()=>Rk,Gemma3nForConditionalGeneration:()=>NH,Gemma3nPreTrainedModel:()=>UI,Gemma4ForCausalLM:()=>kk,Gemma4ForConditionalGeneration:()=>Cl,GemmaForCausalLM:()=>xk,GemmaModel:()=>Ck,GemmaPreTrainedModel:()=>vl,GlmForCausalLM:()=>Gk,GlmModel:()=>Ok,GlmMoeDsaForCausalLM:()=>Zk,GlmMoeDsaModel:()=>Fk,GlmMoeDsaPreTrainedModel:()=>Nl,GlmOcrForConditionalGeneration:()=>Uk,GlmPreTrainedModel:()=>xl,GptOssForCausalLM:()=>Yk,GptOssModel:()=>Qk,GptOssPreTrainedModel:()=>kl,GraniteForCausalLM:()=>s4,GraniteModel:()=>n4,GraniteMoeHybridForCausalLM:()=>H4,GraniteMoeHybridModel:()=>i4,GraniteMoeHybridPreTrainedModel:()=>Zl,GranitePreTrainedModel:()=>Fl,GraniteSpeechForConditionalGeneration:()=>o4,GroundingDinoForObjectDetection:()=>_4,GroundingDinoPreTrainedModel:()=>qI,GroupViTModel:()=>c4,GroupViTPreTrainedModel:()=>XI,HeliumForCausalLM:()=>u4,HeliumModel:()=>l4,HeliumPreTrainedModel:()=>Kl,HieraForImageClassification:()=>p4,HieraModel:()=>d4,HieraPreTrainedModel:()=>Wl,HubertForCTC:()=>S4,HubertForSequenceClassification:()=>L4,HubertModel:()=>I4,HubertPreTrainedModel:()=>m4,HunYuanDenseV1ForCausalLM:()=>g4,HunYuanDenseV1Model:()=>A4,HunYuanDenseV1PreTrainedModel:()=>Vl,IJepaForImageClassification:()=>b4,IJepaModel:()=>T4,IJepaPreTrainedModel:()=>jl,Idefics3ForConditionalGeneration:()=>zI,JAISLMHeadModel:()=>D4,JAISModel:()=>v4,JAISPreTrainedModel:()=>ql,JinaCLIPModel:()=>C4,JinaCLIPPreTrainedModel:()=>wH,JinaCLIPTextModel:()=>JI,JinaCLIPVisionModel:()=>x4,Lfm2ForCausalLM:()=>w4,Lfm2Model:()=>N4,Lfm2MoeForCausalLM:()=>M4,Lfm2MoeModel:()=>B4,Lfm2MoePreTrainedModel:()=>zl,Lfm2PreTrainedModel:()=>Xl,Lfm2VlForConditionalGeneration:()=>P4,LightOnOcrForConditionalGeneration:()=>y4,LiteWhisperForConditionalGeneration:()=>BG,Llama4ForCausalLM:()=>O4,Llama4PreTrainedModel:()=>QI,LlamaForCausalLM:()=>k4,LlamaModel:()=>R4,LlamaPreTrainedModel:()=>Jl,LlavaForConditionalGeneration:()=>Jr,LlavaOnevisionForConditionalGeneration:()=>Jr,LlavaPreTrainedModel:()=>GI,LlavaQwen2ForCausalLM:()=>Bk,LongT5ForConditionalGeneration:()=>F4,LongT5Model:()=>G4,LongT5PreTrainedModel:()=>Ql,M2M100ForConditionalGeneration:()=>U4,M2M100Model:()=>Z4,M2M100PreTrainedModel:()=>Yl,MBartForCausalLM:()=>J4,MBartForConditionalGeneration:()=>X4,MBartForSequenceClassification:()=>z4,MBartModel:()=>q4,MBartPreTrainedModel:()=>Ks,MPNetForMaskedLM:()=>RO,MPNetForQuestionAnswering:()=>GO,MPNetForSequenceClassification:()=>kO,MPNetForTokenClassification:()=>OO,MPNetModel:()=>PO,MPNetPreTrainedModel:()=>Wn,MT5ForConditionalGeneration:()=>KO,MT5Model:()=>UO,MT5PreTrainedModel:()=>cu,MarianMTModel:()=>W4,MarianModel:()=>K4,MarianPreTrainedModel:()=>eu,MaskFormerForInstanceSegmentation:()=>j4,MaskFormerModel:()=>V4,MaskFormerPreTrainedModel:()=>tu,Metric3DForDepthEstimation:()=>Q4,Metric3DPreTrainedModel:()=>YI,Metric3Dv2ForDepthEstimation:()=>Y4,Metric3Dv2PreTrainedModel:()=>eS,MgpstrForSceneTextRecognition:()=>eO,MgpstrModelOutput:()=>tS,MgpstrPreTrainedModel:()=>rS,MimiDecoderModel:()=>iS,MimiDecoderOutput:()=>nS,MimiEncoderModel:()=>sS,MimiEncoderOutput:()=>aS,MimiModel:()=>tO,MimiPreTrainedModel:()=>yH,Mistral4ForCausalLM:()=>sO,Mistral4Model:()=>nO,Mistral4PreTrainedModel:()=>au,MistralForCausalLM:()=>aO,MistralModel:()=>rO,MistralPreTrainedModel:()=>ru,MobileBertForMaskedLM:()=>HO,MobileBertForQuestionAnswering:()=>_O,MobileBertForSequenceClassification:()=>oO,MobileBertModel:()=>iO,MobileBertPreTrainedModel:()=>Ws,MobileLLMForCausalLM:()=>lO,MobileLLMModel:()=>cO,MobileLLMPreTrainedModel:()=>nu,MobileNetV1ForImageClassification:()=>dO,MobileNetV1ForSemanticSegmentation:()=>pO,MobileNetV1Model:()=>uO,MobileNetV1PreTrainedModel:()=>BH,MobileNetV2ForImageClassification:()=>fO,MobileNetV2ForSemanticSegmentation:()=>EO,MobileNetV2Model:()=>hO,MobileNetV2PreTrainedModel:()=>MH,MobileNetV3ForImageClassification:()=>mO,MobileNetV3ForSemanticSegmentation:()=>IO,MobileNetV3Model:()=>$O,MobileNetV3PreTrainedModel:()=>PH,MobileNetV4ForImageClassification:()=>LO,MobileNetV4ForSemanticSegmentation:()=>AO,MobileNetV4Model:()=>SO,MobileNetV4PreTrainedModel:()=>RH,MobileViTForImageClassification:()=>TO,MobileViTModel:()=>gO,MobileViTPreTrainedModel:()=>su,MobileViTV2ForImageClassification:()=>vO,MobileViTV2Model:()=>bO,MobileViTV2PreTrainedModel:()=>iu,ModernBertDecoderForCausalLM:()=>yO,ModernBertDecoderModel:()=>wO,ModernBertDecoderPreTrainedModel:()=>Hu,ModernBertForMaskedLM:()=>CO,ModernBertForSequenceClassification:()=>xO,ModernBertForTokenClassification:()=>NO,ModernBertModel:()=>DO,ModernBertPreTrainedModel:()=>Vs,Moondream1ForConditionalGeneration:()=>yk,MoonshineForConditionalGeneration:()=>MO,MoonshineModel:()=>BO,MoonshinePreTrainedModel:()=>ou,MptForCausalLM:()=>ZO,MptModel:()=>FO,MptPreTrainedModel:()=>_u,MultiModalityCausalLM:()=>WO,MultiModalityPreTrainedModel:()=>HS,MusicgenForCausalLM:()=>jO,MusicgenForConditionalGeneration:()=>oS,MusicgenModel:()=>VO,MusicgenPreTrainedModel:()=>lu,NanoChatForCausalLM:()=>XO,NanoChatModel:()=>qO,NanoChatPreTrainedModel:()=>uu,NemotronHForCausalLM:()=>JO,NemotronHModel:()=>zO,NemotronHPreTrainedModel:()=>du,NeoBertForMaskedLM:()=>YO,NeoBertForQuestionAnswering:()=>r8,NeoBertForSequenceClassification:()=>e8,NeoBertForTokenClassification:()=>t8,NeoBertModel:()=>QO,NeoBertPreTrainedModel:()=>Vn,NomicBertModel:()=>a8,NomicBertPreTrainedModel:()=>_S,OPTForCausalLM:()=>E8,OPTModel:()=>f8,OPTPreTrainedModel:()=>Iu,Olmo2ForCausalLM:()=>H8,Olmo2Model:()=>i8,Olmo2PreTrainedModel:()=>hu,Olmo3ForCausalLM:()=>_8,Olmo3Model:()=>o8,Olmo3PreTrainedModel:()=>fu,OlmoForCausalLM:()=>s8,OlmoHybridForCausalLM:()=>l8,OlmoHybridModel:()=>c8,OlmoHybridPreTrainedModel:()=>Eu,OlmoModel:()=>n8,OlmoPreTrainedModel:()=>pu,OpenAIPrivacyFilterForTokenClassification:()=>d8,OpenAIPrivacyFilterModel:()=>u8,OpenAIPrivacyFilterPreTrainedModel:()=>$u,OpenELMForCausalLM:()=>h8,OpenELMModel:()=>p8,OpenELMPreTrainedModel:()=>mu,OwlViTForObjectDetection:()=>S8,OwlViTModel:()=>I8,OwlViTPreTrainedModel:()=>Lu,Owlv2ForObjectDetection:()=>m8,Owlv2Model:()=>$8,Owlv2PreTrainedModel:()=>Su,PaliGemmaForConditionalGeneration:()=>L8,ParakeetForCTC:()=>A8,ParakeetPreTrainedModel:()=>cS,PatchTSMixerForPrediction:()=>T8,PatchTSMixerModel:()=>g8,PatchTSMixerPreTrainedModel:()=>Au,PatchTSTForPrediction:()=>v8,PatchTSTModel:()=>b8,PatchTSTPreTrainedModel:()=>gu,Phi3ForCausalLM:()=>N8,Phi3Model:()=>x8,Phi3PreTrainedModel:()=>bu,Phi3VForCausalLM:()=>uS,Phi3VPreTrainedModel:()=>lS,PhiForCausalLM:()=>C8,PhiModel:()=>D8,PhiPreTrainedModel:()=>Tu,PreTrainedModel:()=>N,PvtForImageClassification:()=>y8,PvtModel:()=>w8,PvtPreTrainedModel:()=>vu,PyAnnoteForAudioFrameClassification:()=>M8,PyAnnoteModel:()=>B8,PyAnnotePreTrainedModel:()=>Du,Qwen2ForCausalLM:()=>R8,Qwen2Model:()=>P8,Qwen2MoeForCausalLM:()=>O8,Qwen2MoeModel:()=>k8,Qwen2MoePreTrainedModel:()=>xu,Qwen2PreTrainedModel:()=>Cu,Qwen2VLForCausalLM:()=>WI,Qwen2VLForConditionalGeneration:()=>wl,Qwen2VLPreTrainedModel:()=>KI,Qwen2_5_VLForCausalLM:()=>VI,Qwen2_5_VLForConditionalGeneration:()=>yl,Qwen3ForCausalLM:()=>F8,Qwen3Model:()=>G8,Qwen3MoeForCausalLM:()=>U8,Qwen3MoeModel:()=>Z8,Qwen3MoePreTrainedModel:()=>wu,Qwen3NextForCausalLM:()=>W8,Qwen3NextModel:()=>K8,Qwen3NextPreTrainedModel:()=>yu,Qwen3PreTrainedModel:()=>Nu,Qwen3VLForCausalLM:()=>dS,Qwen3VLForConditionalGeneration:()=>Bu,Qwen3VLMoeForCausalLM:()=>j8,Qwen3VLMoeForConditionalGeneration:()=>V8,Qwen3_5ForCausalLM:()=>pS,Qwen3_5ForConditionalGeneration:()=>Mu,Qwen3_5MoeForCausalLM:()=>X8,Qwen3_5MoeForConditionalGeneration:()=>q8,RFDetrForObjectDetection:()=>Y8,RFDetrModel:()=>Q8,RFDetrObjectDetectionOutput:()=>hS,RFDetrPreTrainedModel:()=>Ru,RTDetrForObjectDetection:()=>mR,RTDetrModel:()=>$R,RTDetrObjectDetectionOutput:()=>Fs,RTDetrPreTrainedModel:()=>dl,RTDetrV2ForObjectDetection:()=>l9,RTDetrV2Model:()=>c9,RTDetrV2ObjectDetectionOutput:()=>fS,RTDetrV2PreTrainedModel:()=>ku,ResNetForImageClassification:()=>J8,ResNetModel:()=>z8,ResNetPreTrainedModel:()=>Pu,RoFormerForMaskedLM:()=>i9,RoFormerForQuestionAnswering:()=>_9,RoFormerForSequenceClassification:()=>H9,RoFormerForTokenClassification:()=>o9,RoFormerModel:()=>s9,RoFormerPreTrainedModel:()=>qn,RobertaForMaskedLM:()=>t9,RobertaForQuestionAnswering:()=>n9,RobertaForSequenceClassification:()=>r9,RobertaForTokenClassification:()=>a9,RobertaModel:()=>e9,RobertaPreTrainedModel:()=>jn,Sam2ImageSegmentationOutput:()=>mS,Sam2Model:()=>Ou,Sam2PreTrainedModel:()=>IS,Sam3TrackerModel:()=>p9,SamImageSegmentationOutput:()=>ES,SamModel:()=>u9,SamPreTrainedModel:()=>$S,SapiensForDepthEstimation:()=>f9,SapiensForNormalEstimation:()=>E9,SapiensForSemanticSegmentation:()=>h9,SapiensPreTrainedModel:()=>kH,SegformerForImageClassification:()=>m9,SegformerForSemanticSegmentation:()=>I9,SegformerModel:()=>$9,SegformerPreTrainedModel:()=>OH,SiglipModel:()=>S9,SiglipPreTrainedModel:()=>Gu,SiglipTextModel:()=>SS,SiglipVisionModel:()=>L9,SmolLM3ForCausalLM:()=>g9,SmolLM3Model:()=>A9,SmolLM3PreTrainedModel:()=>Fu,SmolVLMForConditionalGeneration:()=>T9,SnacDecoderModel:()=>AS,SnacEncoderModel:()=>LS,SnacModel:()=>b9,SnacPreTrainedModel:()=>GH,SolarOpenForCausalLM:()=>D9,SolarOpenModel:()=>v9,SolarOpenPreTrainedModel:()=>Zu,SpeechT5ForSpeechToText:()=>x9,SpeechT5ForTextToSpeech:()=>N9,SpeechT5HifiGan:()=>w9,SpeechT5Model:()=>C9,SpeechT5PreTrainedModel:()=>FH,SqueezeBertForMaskedLM:()=>B9,SqueezeBertForQuestionAnswering:()=>P9,SqueezeBertForSequenceClassification:()=>M9,SqueezeBertModel:()=>y9,SqueezeBertPreTrainedModel:()=>js,StableLmForCausalLM:()=>k9,StableLmModel:()=>R9,StableLmPreTrainedModel:()=>Uu,Starcoder2ForCausalLM:()=>G9,Starcoder2Model:()=>O9,Starcoder2PreTrainedModel:()=>Ku,StyleTextToSpeech2Model:()=>F9,StyleTextToSpeech2PreTrainedModel:()=>gS,SupertonicForConditionalGeneration:()=>bS,SupertonicPreTrainedModel:()=>TS,Swin2SRForImageSuperResolution:()=>V9,Swin2SRModel:()=>W9,Swin2SRPreTrainedModel:()=>Wu,SwinForImageClassification:()=>U9,SwinForSemanticSegmentation:()=>K9,SwinModel:()=>Z9,SwinPreTrainedModel:()=>ZH,T5ForConditionalGeneration:()=>q9,T5Model:()=>j9,T5PreTrainedModel:()=>Vu,TableTransformerForObjectDetection:()=>z9,TableTransformerModel:()=>X9,TableTransformerObjectDetectionOutput:()=>vS,TableTransformerPreTrainedModel:()=>ju,TrOCRForCausalLM:()=>J9,TrOCRPreTrainedModel:()=>DS,UltravoxModel:()=>Ul,UltravoxPreTrainedModel:()=>jI,UniSpeechForCTC:()=>Y9,UniSpeechForSequenceClassification:()=>eG,UniSpeechModel:()=>Q9,UniSpeechPreTrainedModel:()=>UH,UniSpeechSatForAudioFrameClassification:()=>nG,UniSpeechSatForCTC:()=>rG,UniSpeechSatForSequenceClassification:()=>aG,UniSpeechSatModel:()=>tG,UniSpeechSatPreTrainedModel:()=>qs,VaultGemmaForCausalLM:()=>iG,VaultGemmaModel:()=>sG,VaultGemmaPreTrainedModel:()=>qu,ViTForImageClassification:()=>_G,ViTMAEModel:()=>cG,ViTMAEPreTrainedModel:()=>CS,ViTMSNForImageClassification:()=>uG,ViTMSNModel:()=>lG,ViTMSNPreTrainedModel:()=>zu,ViTModel:()=>oG,ViTPreTrainedModel:()=>Xu,VisionEncoderDecoderModel:()=>HG,VitMatteForImageMatting:()=>dG,VitMattePreTrainedModel:()=>xS,VitPoseForPoseEstimation:()=>pG,VitPosePreTrainedModel:()=>NS,VitsModel:()=>hG,VitsModelOutput:()=>wS,VitsPreTrainedModel:()=>yS,VoxtralForConditionalGeneration:()=>fG,VoxtralRealtimeForConditionalGeneration:()=>MS,VoxtralRealtimePreTrainedModel:()=>BS,Wav2Vec2BertForCTC:()=>gG,Wav2Vec2BertForSequenceClassification:()=>TG,Wav2Vec2BertModel:()=>AG,Wav2Vec2BertPreTrainedModel:()=>KH,Wav2Vec2ForAudioFrameClassification:()=>$4,Wav2Vec2ForCTC:()=>f4,Wav2Vec2ForSequenceClassification:()=>E4,Wav2Vec2Model:()=>h4,Wav2Vec2PreTrainedModel:()=>$a,WavLMForAudioFrameClassification:()=>xG,WavLMForCTC:()=>vG,WavLMForSequenceClassification:()=>DG,WavLMForXVector:()=>CG,WavLMModel:()=>bG,WavLMPreTrainedModel:()=>Xn,WeSpeakerResNetModel:()=>NG,WeSpeakerResNetPreTrainedModel:()=>RS,WhisperForConditionalGeneration:()=>kS,WhisperModel:()=>yG,WhisperPreTrainedModel:()=>Ju,XLMForQuestionAnswering:()=>OG,XLMForSequenceClassification:()=>RG,XLMForTokenClassification:()=>kG,XLMModel:()=>MG,XLMPreTrainedModel:()=>zn,XLMRobertaForMaskedLM:()=>FG,XLMRobertaForQuestionAnswering:()=>KG,XLMRobertaForSequenceClassification:()=>ZG,XLMRobertaForTokenClassification:()=>UG,XLMRobertaModel:()=>GG,XLMRobertaPreTrainedModel:()=>Jn,XLMWithLMHeadModel:()=>PG,XVectorOutput:()=>PS,YolosForObjectDetection:()=>VG,YolosModel:()=>WG,YolosObjectDetectionOutput:()=>OS,YolosPreTrainedModel:()=>Qu,YoutuForCausalLM:()=>qG,YoutuModel:()=>jG,YoutuPreTrainedModel:()=>Yu});var Gs=class extends N{},u5=class extends Gs{},d5=class extends Gs{async _call(e){return new ue(await super._call(e))}},p5=class extends Gs{async _call(e){return new Dt(await super._call(e))}},h5=class extends Gs{async _call(e){return new _t(await super._call(e))}},Qc=class extends N{},f5=class extends Qc{},E5=class extends Qc{},Yc=class extends N{},$5=class extends Yc{},m5=class extends Yc{},el=class extends N{},I5=class extends el{},S5=class extends el{},tl=class extends N{},L5=class extends tl{},A5=class extends tl{},vH=class extends N{},g5=class extends vH{},T5=class extends vH{},b5=class extends vH{async _call(e){return new ue(await super._call(e))}},rl=class extends N{},v5=class extends rl{},D5=class extends rl{async _call(e){return new ue(await super._call(e))}},kn=class extends N{},C5=class extends kn{},x5=class extends kn{async _call(e){return new _t(await super._call(e))}},N5=class extends kn{async _call(e){return new ue(await super._call(e))}},w5=class extends kn{async _call(e){return new rt(await super._call(e))}},y5=class extends kn{async _call(e){return new Dt(await super._call(e))}},al=class extends N{},B5=class extends al{},M5=class extends al{},nl=class extends N{},P5=class extends nl{},R5=class extends nl{},sl=class extends N{},k5=class extends sl{},O5=class extends sl{},On=class extends N{},G5=class extends On{},F5=class extends On{async _call(e){return new _t(await super._call(e))}},Z5=class extends On{async _call(e){return new ue(await super._call(e))}},U5=class extends On{async _call(e){return new rt(await super._call(e))}},K5=class extends On{async _call(e){return new Dt(await super._call(e))}},W5=4299n,G$=6561n,SI=class extends N{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","audio_values","exaggeration","audio_features","audio_tokens","speaker_embeddings","speaker_features","past_key_values"];main_input_name="input_ids";_return_dict_in_generate_keys=["audio_tokens","speaker_embeddings","speaker_features"]},LI=class extends SI{async encode_speech(e){return be(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:t=null,audio_values:r=null,exaggeration:a=null,position_ids:n=null,inputs_embeds:s=null,past_key_values:i=null,generation_config:H=null,logits_processor:o=null,audio_features:_=null,audio_tokens:c=null,speaker_embeddings:l=null,speaker_features:d=null,...h}){let $;if(!s){let S=this.sessions.embed_tokens.inputNames,I={input_ids:e};if(S.includes("exaggeration")){if(!(a instanceof K)){let T=e.dims[0];if(a==null)a=Tt([T],.5);else if(typeof a=="number")a=Tt([T],a);else if(Array.isArray(a))a=new K("float32",a,[T]);else throw new Error("Unsupported type for `exaggeration` input")}I.exaggeration=a}if(S.includes("position_ids")&&(I.position_ids=n),{inputs_embeds:s}=await be(this.sessions.embed_tokens,I),_&&c&&l&&d&&($={audio_features:_,audio_tokens:c,speaker_embeddings:l,speaker_features:d}),$||r)$??=await this.encode_speech(r),s=je([$.audio_features,s],1),t=Gt([s.dims[0],s.dims[1]]);else{let T=s.dims[1];if(!i||T!==1)throw new Error("Incorrect state encountered during generation.");let D=i.get_seq_length();t=Gt([s.dims[0],D+T])}}return{...await zr(this,{inputs_embeds:s,past_key_values:i,attention_mask:t,generation_config:H,logits_processor:o},!1),...$}}prepare_inputs_for_generation(e,t,r){if(!t.position_ids&&this.sessions.embed_tokens.inputNames.includes("position_ids"))if(t.input_ids.dims[1]===1){let a=Array.from({length:e.length},(n,s)=>e[s].length-e[s].findLastIndex(i=>i==G$)-1);t.position_ids=new K("int64",a,[e.length,1])}else{let n=t.input_ids.tolist().map(s=>{let i=0;return s.map(H=>H>=G$?0:i++)});t.position_ids=new K("int64",n.flat(),t.input_ids.dims)}return t.input_ids.dims[1]===1&&(delete t.audio_values,delete t.audio_features,delete t.audio_tokens,delete t.speaker_embeddings,delete t.speaker_features),vs(this,e,t,r)}async generate(e){let{sequences:t,audio_tokens:r,speaker_embeddings:a,speaker_features:n}=await super.generate({...e,return_dict_in_generate:!0}),s=t.slice(null,[e.input_ids.dims[1],-1]),i=Tt([s.dims[0],3],W5),H=je([r,s,i],1),{waveform:o}=await be(this.sessions.conditional_decoder,{speech_tokens:H,speaker_features:n,speaker_embeddings:a});return o}},AI=class extends N{},V5=class extends AI{},gI=class extends N{},j5=class extends gI{},DH=class extends N{},q5=class extends DH{},TI=class extends DH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},bI=class extends DH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"audio_model"})}},ja=class extends N{},X5=class extends ja{},z5=class extends ja{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},vI=class extends ja{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},J5=class extends ja{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},Q5=class extends ja{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},il=class extends N{},Y5=class extends il{},eR=class extends il{},Hl=class extends N{},tR=class extends Hl{},rR=class extends Hl{},ol=class extends N{},aR=class extends ol{},nR=class extends ol{},_l=class extends N{},sR=class extends _l{},iR=class extends _l{},cl=class extends N{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","decoder_input_ids","decoder_attention_mask","past_key_values"]},HR=class extends cl{},oR=class extends cl{},Gn=class extends N{},_R=class extends Gn{},cR=class extends Gn{async _call(e){return new _t(await super._call(e))}},lR=class extends Gn{async _call(e){return new ue(await super._call(e))}},uR=class extends Gn{async _call(e){return new rt(await super._call(e))}},dR=class extends Gn{async _call(e){return new Dt(await super._call(e))}},ll=class extends N{},pR=class extends ll{},hR=class extends ll{async _call(e){return new ue(await super._call(e))}},ul=class extends N{},fR=class extends ul{},ER=class extends ul{async _call(e){return new ue(await super._call(e))}},dl=class extends N{},$R=class extends dl{},mR=class extends dl{async _call(e){return new Fs(await super._call(e))}},Fs=class extends ot{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},pl=class extends N{},IR=class extends pl{},SR=class extends pl{async _call(e){return new Fs(await super._call(e))}},DI=class extends ot{constructor({audio_codes:e}){super(),this.audio_codes=e}},CI=class extends ot{constructor({audio_values:e}){super(),this.audio_values=e}},CH=class extends N{main_input_name="input_values";forward_params=["input_values"]},LR=class extends CH{async encode(e){return new DI(await be(this.sessions.encoder_model,e))}async decode(e){return new CI(await be(this.sessions.decoder_model,e))}},xI=class extends CH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"encoder_model"})}},NI=class extends CH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"decoder_model"})}},Fn=class extends N{},AR=class extends Fn{},gR=class extends Fn{async _call(e){return new _t(await super._call(e))}},TR=class extends Fn{async _call(e){return new ue(await super._call(e))}},bR=class extends Fn{async _call(e){return new rt(await super._call(e))}},vR=class extends Fn{async _call(e){return new Dt(await super._call(e))}},hl=class extends N{},DR=class extends hl{},CR=class extends hl{},Zn=class extends N{},xR=class extends Zn{},NR=class extends Zn{async _call(e){return new _t(await super._call(e))}},wR=class extends Zn{async _call(e){return new ue(await super._call(e))}},yR=class extends Zn{async _call(e){return new rt(await super._call(e))}},BR=class extends Zn{async _call(e){return new Dt(await super._call(e))}},wI=class extends N{},MR=class extends wI{},fl=class extends N{},PR=class extends fl{},RR=class extends fl{async _call(e){return new ue(await super._call(e))}},yI=class extends N{},kR=class extends yI{},BI=class extends N{},OR=class extends BI{},xH=class extends N{},GR=class extends xH{},FR=class extends xH{async _call(e){return new El(await super._call(e))}},ZR=class extends xH{async _call(e){return new MI(await super._call(e))}},El=class extends ot{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},MI=class extends ot{constructor({logits:e,pred_boxes:t,pred_masks:r}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=r}},$l=class extends N{},UR=class extends $l{},KR=class extends $l{async _call(e){return new ue(await super._call(e))}},ml=class extends N{},WR=class extends ml{},VR=class extends ml{async _call(e){return new ue(await super._call(e))}},PI=class extends N{},jR=class extends PI{},RI=class extends N{},qR=class extends RI{},Un=class extends N{},XR=class extends Un{},zR=class extends Un{async _call(e){return new ue(await super._call(e))}},JR=class extends Un{async _call(e){return new rt(await super._call(e))}},QR=class extends Un{async _call(e){return new Dt(await super._call(e))}},YR=class extends Un{async _call(e){return new _t(await super._call(e))}},kI=class extends N{},ek=class extends kI{},Il=class extends N{},tk=class extends Il{},rk=class extends Il{},Sl=class extends N{},ak=class extends Sl{},nk=class extends Sl{async _call(e){return new ue(await super._call(e))}},Kn=class extends N{},sk=class extends Kn{},ik=class extends Kn{async _call(e){return new _t(await super._call(e))}},Hk=class extends Kn{async _call(e){return new ue(await super._call(e))}},ok=class extends Kn{async _call(e){return new rt(await super._call(e))}},_k=class extends Kn{async _call(e){return new Dt(await super._call(e))}},Ll=class extends N{},ck=class extends Ll{},lk=class extends Ll{},Zs=class extends N{},uk=class extends Zs{},dk=class extends Zs{async _call(e){return new _t(await super._call(e))}},pk=class extends Zs{async _call(e){return new ue(await super._call(e))}},hk=class extends Zs{async _call(e){return new rt(await super._call(e))}},Us=class extends N{},fk=class extends Us{},Ek=class extends Us{async _call(e){return new _t(await super._call(e))}},$k=class extends Us{async _call(e){return new ue(await super._call(e))}},mk=class extends Us{async _call(e){return new rt(await super._call(e))}},Al=class extends N{},Ik=class extends Al{},Sk=class extends Al{},gl=class extends N{},Lk=class extends gl{},Ak=class extends gl{},Tl=class extends N{},gk=class extends Tl{},Tk=class extends Tl{},bl=class extends N{},bk=class extends bl{},vk=class extends bl{async _call(e){return new ue(await super._call(e))}},OI=class extends N{forward_params=["input_ids","inputs_embeds","attention_mask","pixel_values","encoder_outputs","decoder_input_ids","decoder_inputs_embeds","decoder_attention_mask","past_key_values"];main_input_name="inputs_embeds"},Dk=class extends OI{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:r,attention_mask:a}){return{inputs_embeds:je([t,e],1),attention_mask:je([Gt(t.dims.slice(0,2)),a],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:r,attention_mask:a}){if(!e&&!t)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let n,s;return e&&(n=await this.encode_text({input_ids:e})),t&&(s=await this.encode_image({pixel_values:t})),n&&s?{inputs_embeds:r,attention_mask:a}=this._merge_input_ids_with_image_features({inputs_embeds:n,image_features:s,input_ids:e,attention_mask:a}):r=n||s,{inputs_embeds:r,attention_mask:a}}async forward({input_ids:e,pixel_values:t,attention_mask:r,decoder_input_ids:a,decoder_attention_mask:n,encoder_outputs:s,past_key_values:i,inputs_embeds:H,decoder_inputs_embeds:o}){if(H||({inputs_embeds:H,attention_mask:r}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:H,attention_mask:r})),!s){let{last_hidden_state:c}=await Ea(this,{inputs_embeds:H,attention_mask:r});s=c}if(!o){if(!a)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");o=await this.encode_text({input_ids:a})}return await zr(this,{inputs_embeds:o,attention_mask:n,encoder_attention_mask:r,encoder_hidden_states:s,past_key_values:i},!0)}},vl=class extends N{},Ck=class extends vl{},xk=class extends vl{},Dl=class extends N{},Nk=class extends Dl{},wk=class extends Dl{},GI=class extends N{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},Jr=class extends GI{_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),r=e.image_features.view(-1,t);return zc({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:r})}},yk=class extends Jr{},Bk=class extends Jr{},FI=class extends N{},Mk=class extends FI{},ZI=class extends Jr{},Pk=class extends ZI{},UI=class extends N{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","input_features","input_features_mask","past_key_values"]},NH=class extends UI{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:r=null,input_features:a=null,input_features_mask:n=null,position_ids:s=null,inputs_embeds:i=null,per_layer_inputs:H=null,past_key_values:o=null,generation_config:_=null,logits_processor:c=null,...l}){if((!i||!H)&&({inputs_embeds:i,per_layer_inputs:H}=await be(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(r){let{image_features:h}=await this._encode_vision({pixel_values:r,...l});({inputs_embeds:i,attention_mask:t}=this._merge_input_ids_with_image_features({image_features:h,inputs_embeds:i,input_ids:e,attention_mask:t}))}if(a){let{audio_features:h}=await be(this.sessions.audio_encoder,{input_features:a,input_features_mask:n});({inputs_embeds:i,attention_mask:t}=this._merge_input_ids_with_audio_features({audio_features:h,inputs_embeds:i,input_ids:e,attention_mask:t}))}}return await zr(this,{inputs_embeds:i,per_layer_inputs:H,past_key_values:o,attention_mask:t,position_ids:s,generation_config:_,logits_processor:c},!0)}_encode_vision(e){return be(this.sessions.vision_encoder,{pixel_values:e.pixel_values})}_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),r=e.image_features.view(-1,t);return zc({image_token_id:this.config.image_token_id,...e,image_features:r})}_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,t);return II({audio_token_id:this.config.audio_token_id,...e,audio_features:r})}},Rk=class extends NH{},Cl=class extends NH{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","image_position_ids","input_features","input_features_mask","past_key_values"];_encode_vision(e){return be(this.sessions.vision_encoder,{pixel_values:e.pixel_values,pixel_position_ids:e.image_position_ids})}},kk=class extends Cl{},xl=class extends N{},Ok=class extends xl{},Gk=class extends xl{},Nl=class extends N{},Fk=class extends Nl{},Zk=class extends Nl{},KI=class extends N{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},wl=class extends KI{image_grid_thw_name="grid_thw";_get_text_only_rope_index(e,t){if(t){let{data:r,dims:a}=$I(t),n=BigInt64Array.from({length:3*r.length},(i,H)=>r[H%r.length]),s=Array.from({length:a[0]},(i,H)=>et(r.subarray(a[1]*H,a[1]*(H+1)))[0]+1n+BigInt(a[1]));return[new K("int64",n,[3,...a]),new K("int64",s,[s.length,1])]}else{let[r,a]=e.dims,n=BigInt64Array.from({length:3*r*a},(s,i)=>BigInt(Math.floor(i%a/r)));return[new K("int64",n,[3,...e.dims]),Im([r,1])]}}_reorder_and_write_positions(e,t,r,a){let n=e.reduce((o,_)=>o+_.length,0),s=new Array(n),i=0;for(let o=0;o<3;++o)for(let _ of e){let c=_.length/3;for(let l=o*c;l<(o+1)*c;++l)s[i++]=_[l]}let H=0;for(let o=0;o<t.length;++o)if(t[o]==1){for(let _=0;_<3;++_)r[_][a][o]=s[_*n/3+H];++H}return s}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:r,spatial_merge_size:a,state:n}){let{image_token_id:s,video_token_id:i,vision_start_token_id:H}=this.config,o=e,c=o.reduce((I,T,D)=>(T==H&&I.push(D),I),[]).map(I=>o[I+1]),l=c.filter(I=>I==s).length,d=c.filter(I=>I==i).length,h=[],$=0,m=l,S=d;for(let I=0;I<c.length;++I){let T=o.findIndex((F,J)=>J>$&&F==s),D=o.findIndex((F,J)=>J>$&&F==i),v=m>0&&T!==-1?T:o.length+1,C=S>0&&D!==-1?D:o.length+1,R,A,U,Z;v<C?([A,U,Z]=t[n.image_index],++n.image_index,--m,R=v):([A,U,Z]=r[n.video_index],++n.video_index,--S,R=C);let[j,z,X]=[Number(A),Math.floor(Number(U)/a),Math.floor(Number(Z)/a)],q=R-$,G=h.length>0?et(h.at(-1))[0]+1:0;h.push(Array.from({length:3*q},(F,J)=>G+J%q));let y=q+G,Q=j*z*X,_e=Array.from({length:Q},(F,J)=>y+Math.floor(J/(z*X))),M=Array.from({length:Q},(F,J)=>y+Math.floor(J/X)%z),k=Array.from({length:Q},(F,J)=>y+J%X);h.push([_e,M,k].flat()),$=R+Q}if($<o.length){let I=h.length>0?et(h.at(-1))[0]+1:0,T=o.length-$;h.push(Array.from({length:3*T},(D,v)=>I+v%T))}return h}get_rope_index(e,t,r,a){let{vision_config:n}=this.config,s=n.spatial_merge_size??2;if(t||r){let i=e.tolist();a||(a=mm(e));let H=a.tolist(),o=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),_=t?t.tolist():[],c=r?r.tolist():[],l={image_index:0,video_index:0},d=[];for(let h=0;h<i.length;++h){let $=i[h].filter((I,T)=>H[h][T]==1),m=this._get_multimodal_rope_positions({filtered_ids:$,image_grid_thw_list:_,video_grid_thw_list:c,spatial_merge_size:s,state:l}),S=this._reorder_and_write_positions(m,H[h],o,h);d.push(et(S)[0]+1-i[h].length)}return[new K("int64",o.flat(1/0),[3,e.dims[0],e.dims[1]]),new K("int64",d,[d.length,1])]}else return this._get_text_only_rope_index(e,a)}async encode_image({pixel_values:e,image_grid_thw:t}){return(await be(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:t})).image_features}_merge_input_ids_with_image_features(e){return zc({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,t,r){if(!t.attention_mask||t.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes("position_ids"))return t;if(!t.past_key_values)[t.position_ids,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);else{t.pixel_values=null;let n=t.past_key_values.get_seq_length();if(n<t.input_ids.dims[1]){let[s,i]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);t.rope_deltas=i,t.position_ids=s.slice(null,null,[n,null]),t.input_ids=t.input_ids.slice(null,[n,null])}else{t.rope_deltas||([,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask));let s=BigInt(n),i=t.rope_deltas.map(H=>s+H);t.position_ids=Xr([i,i,i],0)}}return t}},WI=class extends wl{},yl=class extends wl{image_grid_thw_name="image_grid_thw"},VI=class extends WI{image_grid_thw_name="image_grid_thw"},Uk=class extends yl{get_vision_position_ids(e,t,r,a){let n=Math.floor(t[0]/r),s=Math.floor(t[1]/a),i=Math.floor(t[2]/a),H=s*i*n,o=Array.from({length:H},()=>e),_=Array.from({length:H},(l,d)=>e+Math.floor(d/(i*n))),c=Array.from({length:H},(l,d)=>e+d%i);return[...o,..._,...c]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:r,spatial_merge_size:a,state:n}){let{image_token_id:s}=this.config,i=[],H=0,o=e[0]==s?1:0;for(let l=1;l<=e.length;++l){let d=l<e.length?e[l]==s?1:0:-1;d!==o&&(i.push([o,H,l]),H=l,o=d)}let _=0,c=[];for(let[l,d,h]of i)if(l===0){let $=h-d;c.push(Array.from({length:3*$},(m,S)=>_+S%$)),_+=$}else{let $=t[n.image_index++].map(Number),m=$[0];c.push(this.get_vision_position_ids(_,$,m,a)),_+=Math.max($[1],$[2])/a}return c}},Bl=class extends N{},Kk=class extends Bl{},Wk=class extends Bl{},Ml=class extends N{},Vk=class extends Ml{},jk=class extends Ml{},Pl=class extends N{},qk=class extends Pl{},Xk=class extends Pl{},Rl=class extends N{},zk=class extends Rl{},Jk=class extends Rl{},kl=class extends N{},Qk=class extends kl{},Yk=class extends kl{},Ol=class extends N{},e4=class extends Ol{},t4=class extends Ol{},Gl=class extends N{},r4=class extends Gl{},a4=class extends Gl{},Fl=class extends N{},n4=class extends Fl{},s4=class extends Fl{},Zl=class extends N{},i4=class extends Zl{},H4=class extends Zl{},jI=class extends N{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},Ul=class extends jI{_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,t);return II({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:r})}},o4=class extends Ul{forward_params=["input_ids","attention_mask","input_features","past_key_values"]},qI=class extends N{},_4=class extends qI{},XI=class extends N{},c4=class extends XI{},Kl=class extends N{},l4=class extends Kl{},u4=class extends Kl{},Wl=class extends N{},d4=class extends Wl{},p4=class extends Wl{async _call(e){return new ue(await super._call(e))}},$a=class extends N{},h4=class extends $a{},f4=class extends $a{async _call(e){return new Va(await super._call(e))}},E4=class extends $a{async _call(e){return new ue(await super._call(e))}},$4=class extends $a{async _call(e){return new rt(await super._call(e))}},m4=class extends N{},I4=class extends $a{},S4=class extends $a{async _call(e){return new Va(await super._call(e))}},L4=class extends $a{async _call(e){return new ue(await super._call(e))}},Vl=class extends N{},A4=class extends Vl{},g4=class extends Vl{},zI=class extends Jr{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]},jl=class extends N{},T4=class extends jl{},b4=class extends jl{async _call(e){return new ue(await super._call(e))}},ql=class extends N{},v4=class extends ql{},D4=class extends ql{},wH=class extends N{},C4=class extends wH{async forward(e){let t=!e.input_ids,r=!e.pixel_values;if(t&&r)throw new Error("Either `input_ids` or `pixel_values` should be provided.");if(t&&(e.input_ids=Gt([e.pixel_values.dims[0],1])),r){let{image_size:o}=this.config.vision_config;e.pixel_values=Tt([0,3,o,o],0)}let{text_embeddings:a,image_embeddings:n,l2norm_text_embeddings:s,l2norm_image_embeddings:i}=await super.forward(e),H={};return t||(H.text_embeddings=a,H.l2norm_text_embeddings=s),r||(H.image_embeddings=n,H.l2norm_image_embeddings=i),H}},JI=class extends wH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},x4=class extends wH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},Xl=class extends N{},N4=class extends Xl{},w4=class extends Xl{},y4=class extends Jr{},zl=class extends N{},B4=class extends zl{},M4=class extends zl{},P4=class extends Jr{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","spatial_shapes","position_ids","past_key_values"]},Jl=class extends N{},R4=class extends Jl{},k4=class extends Jl{},QI=class extends N{},O4=class extends QI{},Ql=class extends N{},G4=class extends Ql{},F4=class extends Ql{},Yl=class extends N{},Z4=class extends Yl{},U4=class extends Yl{},eu=class extends N{},K4=class extends eu{},W4=class extends eu{},tu=class extends N{},V4=class extends tu{},j4=class extends tu{},Ks=class extends N{},q4=class extends Ks{},X4=class extends Ks{},z4=class extends Ks{async _call(e){return new ue(await super._call(e))}},J4=class extends Ks{},YI=class extends N{},Q4=class extends YI{},eS=class extends N{},Y4=class extends eS{},tS=class extends ot{constructor({char_logits:e,bpe_logits:t,wp_logits:r}){super(),this.char_logits=e,this.bpe_logits=t,this.wp_logits=r}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},rS=class extends N{},eO=class extends rS{async _call(e){return new tS(await super._call(e))}},aS=class extends ot{constructor({audio_codes:e}){super(),this.audio_codes=e}},nS=class extends ot{constructor({audio_values:e}){super(),this.audio_values=e}},yH=class extends N{main_input_name="input_values";forward_params=["input_values"]},tO=class extends yH{async encode(e){return new aS(await be(this.sessions.encoder_model,e))}async decode(e){return new nS(await be(this.sessions.decoder_model,e))}},sS=class extends yH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"encoder_model"})}},iS=class extends yH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"decoder_model"})}},ru=class extends N{},rO=class extends ru{},aO=class extends ru{},au=class extends N{},nO=class extends au{},sO=class extends au{},Ws=class extends N{},iO=class extends Ws{},HO=class extends Ws{async _call(e){return new _t(await super._call(e))}},oO=class extends Ws{async _call(e){return new ue(await super._call(e))}},_O=class extends Ws{async _call(e){return new Dt(await super._call(e))}},nu=class extends N{},cO=class extends nu{},lO=class extends nu{},BH=class extends N{},uO=class extends BH{},dO=class extends BH{async _call(e){return new ue(await super._call(e))}},pO=class extends BH{},MH=class extends N{},hO=class extends MH{},fO=class extends MH{async _call(e){return new ue(await super._call(e))}},EO=class extends MH{},PH=class extends N{},$O=class extends PH{},mO=class extends PH{async _call(e){return new ue(await super._call(e))}},IO=class extends PH{},RH=class extends N{},SO=class extends RH{},LO=class extends RH{async _call(e){return new ue(await super._call(e))}},AO=class extends RH{},su=class extends N{},gO=class extends su{},TO=class extends su{async _call(e){return new ue(await super._call(e))}},iu=class extends N{},bO=class extends iu{},vO=class extends iu{async _call(e){return new ue(await super._call(e))}},Vs=class extends N{},DO=class extends Vs{},CO=class extends Vs{async _call(e){return new _t(await super._call(e))}},xO=class extends Vs{async _call(e){return new ue(await super._call(e))}},NO=class extends Vs{async _call(e){return new rt(await super._call(e))}},Hu=class extends N{},wO=class extends Hu{},yO=class extends Hu{},ou=class extends N{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},BO=class extends ou{},MO=class extends ou{},Wn=class extends N{},PO=class extends Wn{},RO=class extends Wn{async _call(e){return new _t(await super._call(e))}},kO=class extends Wn{async _call(e){return new ue(await super._call(e))}},OO=class extends Wn{async _call(e){return new rt(await super._call(e))}},GO=class extends Wn{async _call(e){return new Dt(await super._call(e))}},_u=class extends N{},FO=class extends _u{},ZO=class extends _u{},cu=class extends N{},UO=class extends cu{},KO=class extends cu{},HS=class extends N{},WO=class extends HS{forward_params=["input_ids","pixel_values","images_seq_mask","images_emb_mask","attention_mask","position_ids","past_key_values"];constructor(...e){super(...e),this._generation_mode="text"}async forward(e){let t=this._generation_mode??"text",r;if(t==="text"||!e.past_key_values){let H=this.sessions.prepare_inputs_embeds,o=ht(e,H.inputNames);r=await be(H,o)}else{let H=this.sessions.gen_img_embeds,o=ht({image_ids:e.input_ids},H.inputNames);r=await be(H,o)}let a={...e,...r},n=await zr(this,a),s=this.sessions[t==="text"?"lm_head":"gen_head"];if(!s)throw new Error(`Unable to find "${s}" generation head`);let i=await be(s,ht(n,s.inputNames));return{...r,...n,...i}}prepare_inputs_for_generation(e,t,r){let a=!!t.past_key_values;return r.guidance_scale!==null&&r.guidance_scale>1&&(a?t.input_ids=je([t.input_ids,t.input_ids],0):(t.input_ids=je([t.input_ids,Q_(t.input_ids,BigInt(r.pad_token_id))],0),t.attention_mask=je([t.attention_mask,Q_(t.attention_mask,0n)],0))),(a||!t.pixel_values)&&(t.pixel_values=Tt([0,0,3,384,384],1)),a&&(t.images_seq_mask=new K("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),t.images_emb_mask=new K("bool",new Array(0).fill(!1),[1,1,0])),t}async generate(e){return this._generation_mode="text",super.generate(e)}async generate_images(e){this._generation_mode="image";let t=(e.inputs??e[this.main_input_name]).dims[1],a=(await super.generate(e)).slice(null,[t,null]),n=this.sessions.image_decode,{decoded_image:s}=await be(n,{generated_tokens:a}),i=s.add_(1).mul_(255/2).clamp_(0,255).to("uint8"),H=[];for(let o of i){let _=qt.fromTensor(o);H.push(_)}return H}},lu=class extends N{},VO=class extends lu{},jO=class extends lu{},oS=class extends N{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];_apply_and_filter_by_delay_pattern_mask(e){let[t,r]=e.dims,a=this.config.decoder.num_codebooks,n=r-a,s=0;for(let o=0;o<e.size;++o){if(e.data[o]==this.config.decoder.pad_token_id)continue;let _=o%r,c=Math.floor(o/r)%a,l=_-c;l>0&&l<=n&&(e.data[s++]=e.data[o])}let i=Math.floor(t/a),H=s/(i*a);return new K(e.type,e.data.slice(0,s),[i,a,H])}prepare_inputs_for_generation(e,t,r){let a=BigInt(this.config.decoder.pad_token_id),n=structuredClone(e);for(let s=0;s<n.length;++s)for(let i=0;i<n[s].length;++i)s%this.config.decoder.num_codebooks>=i&&(n[s][i]=a);return r.guidance_scale!==null&&r.guidance_scale>1&&(n=n.concat(n)),hH(this,n,t,r)}async generate(e){let t=await super.generate(e),r=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:a}=await be(this.sessions.encodec_decode,{audio_codes:r});return a}},uu=class extends N{},qO=class extends uu{},XO=class extends uu{},du=class extends N{},zO=class extends du{},JO=class extends du{},Vn=class extends N{},QO=class extends Vn{},YO=class extends Vn{async _call(e){return new _t(await super._call(e))}},e8=class extends Vn{async _call(e){return new ue(await super._call(e))}},t8=class extends Vn{async _call(e){return new rt(await super._call(e))}},r8=class extends Vn{async _call(e){return new Dt(await super._call(e))}},_S=class extends N{},a8=class extends _S{},pu=class extends N{},n8=class extends pu{},s8=class extends pu{},hu=class extends N{},i8=class extends hu{},H8=class extends hu{},fu=class extends N{},o8=class extends fu{},_8=class extends fu{},Eu=class extends N{},c8=class extends Eu{},l8=class extends Eu{},$u=class extends N{},u8=class extends $u{},d8=class extends $u{async _call(e){return new ue(await super._call(e))}},mu=class extends N{},p8=class extends mu{},h8=class extends mu{},Iu=class extends N{},f8=class extends Iu{},E8=class extends Iu{},Su=class extends N{},$8=class extends Su{},m8=class extends Su{},Lu=class extends N{},I8=class extends Lu{},S8=class extends Lu{},L8=class extends Jr{},cS=class extends N{},A8=class extends cS{async _call(e){return new Va(await super._call(e))}},Au=class extends N{},g8=class extends Au{},T8=class extends Au{},gu=class extends N{},b8=class extends gu{},v8=class extends gu{},Tu=class extends N{},D8=class extends Tu{},C8=class extends Tu{},bu=class extends N{},x8=class extends bu{},N8=class extends bu{},lS=class extends N{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},uS=class extends lS{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:r=null,image_sizes:a=null,position_ids:n=null,inputs_embeds:s=null,past_key_values:i=null,generation_config:H=null,logits_processor:o=null,..._}){if(!s){let l;if(r&&e.dims[1]!==1){if(!a)throw new Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:l}=await be(this.sessions.vision_encoder,{pixel_values:r,image_sizes:a}))}else{let d=this.config.normalized_config.hidden_size;l=new K("float32",[],[0,d])}({inputs_embeds:s}=await be(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:l}))}return await zr(this,{inputs_embeds:s,past_key_values:i,attention_mask:t,position_ids:n,generation_config:H,logits_processor:o},!1)}},vu=class extends N{},w8=class extends vu{},y8=class extends vu{async _call(e){return new ue(await super._call(e))}},Du=class extends N{},B8=class extends Du{},M8=class extends Du{async _call(e){return new rt(await super._call(e))}},Cu=class extends N{},P8=class extends Cu{},R8=class extends Cu{},xu=class extends N{},k8=class extends xu{},O8=class extends xu{},Nu=class extends N{},G8=class extends Nu{},F8=class extends Nu{},wu=class extends N{},Z8=class extends wu{},U8=class extends wu{},yu=class extends N{},K8=class extends yu{},W8=class extends yu{},Bu=class extends yl{},dS=class extends VI{},V8=class extends Bu{},j8=class extends dS{},Mu=class extends Bu{},pS=class extends Mu{},q8=class extends Mu{},X8=class extends pS{},Pu=class extends N{},z8=class extends Pu{},J8=class extends Pu{async _call(e){return new ue(await super._call(e))}},Ru=class extends N{},Q8=class extends Ru{},Y8=class extends Ru{async _call(e){return new hS(await super._call(e))}},hS=class extends Fs{},jn=class extends N{},e9=class extends jn{},t9=class extends jn{async _call(e){return new _t(await super._call(e))}},r9=class extends jn{async _call(e){return new ue(await super._call(e))}},a9=class extends jn{async _call(e){return new rt(await super._call(e))}},n9=class extends jn{async _call(e){return new Dt(await super._call(e))}},qn=class extends N{},s9=class extends qn{},i9=class extends qn{async _call(e){return new _t(await super._call(e))}},H9=class extends qn{async _call(e){return new ue(await super._call(e))}},o9=class extends qn{async _call(e){return new rt(await super._call(e))}},_9=class extends qn{async _call(e){return new Dt(await super._call(e))}},ku=class extends N{},c9=class extends ku{},l9=class extends ku{async _call(e){return new fS(await super._call(e))}},fS=class extends Fs{},ES=class extends ot{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}},$S=class extends N{},u9=class extends $S{async get_image_embeddings({pixel_values:e}){return await Ea(this,{pixel_values:e})}async forward(e){!e.image_embeddings||!e.image_positional_embeddings?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_labels??=Gt(e.input_points.dims.slice(0,-1));let t={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(t.input_points=e.input_points),e.input_labels&&(t.input_labels=e.input_labels),e.input_boxes&&(t.input_boxes=e.input_boxes),await be(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new ES(await super._call(e))}},mS=class extends ot{constructor({iou_scores:e,pred_masks:t,object_score_logits:r}){super(),this.iou_scores=e,this.pred_masks=t,this.object_score_logits=r}},IS=class extends N{},Ou=class extends IS{async get_image_embeddings({pixel_values:e}){return await Ea(this,{pixel_values:e})}async forward(e){let{num_feature_levels:t}=this.config.vision_config;if(Array.from({length:t},(s,i)=>`image_embeddings.${i}`).some(s=>!e[s])?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw new Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let s=e.input_points.dims;e.input_labels??=Gt(s.slice(0,-1)),e.input_boxes??=Tt([s[0],0,4],0)}else if(e.input_boxes){let s=e.input_boxes.dims;e.input_labels=Tt([s[0],s[1],0],-1n),e.input_points=Tt([s[0],1,0,2],0)}else throw new Error("At least one of `input_points` or `input_boxes` must be provided.");let a=this.sessions.prompt_encoder_mask_decoder,n=ht(e,a.inputNames);return await be(a,n)}async _call(e){return new mS(await super._call(e))}},d9=class extends Ou{},p9=class extends Ou{},kH=class extends N{},h9=class extends kH{},f9=class extends kH{},E9=class extends kH{},OH=class extends N{},$9=class extends OH{},m9=class extends OH{},I9=class extends OH{},Gu=class extends N{},S9=class extends Gu{},SS=class extends Gu{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},L9=class extends ja{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},Fu=class extends N{},A9=class extends Fu{},g9=class extends Fu{},T9=class extends zI{},GH=class extends N{main_input_name="input_values";forward_params=["input_values"]},b9=class extends GH{async encode(e){return await be(this.sessions.encoder_model,e)}async decode(e){return await be(this.sessions.decoder_model,e)}},LS=class extends GH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"encoder_model"})}},AS=class extends GH{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"decoder_model"})}},Zu=class extends N{},v9=class extends Zu{},D9=class extends Zu{},FH=class extends N{},C9=class extends FH{},x9=class extends FH{},N9=class extends FH{async generate_speech(e,t,{threshold:r=.5,minlenratio:a=0,maxlenratio:n=20,vocoder:s=null}={}){let i={input_ids:e},{encoder_outputs:H,encoder_attention_mask:o}=await Ea(this,i),_=H.dims[1]/this.config.reduction_factor,c=Math.floor(_*n),l=Math.floor(_*a),d=this.config.num_mel_bins,h=[],$=null,m=null,S=0;for(;;){++S;let D=hI(!!m),v;m?v=m.output_sequence_out:v=new K("float32",new Float32Array(d),[1,1,d]);let C={use_cache_branch:D,output_sequence:v,encoder_attention_mask:o,speaker_embeddings:t,encoder_hidden_states:H};Xc(this,C,$),m=await be(this.sessions.decoder_model_merged,C),$=nc(m,$);let{prob:R,spectrum:A}=m;if(h.push(A),S>=l&&(Array.from(R.data).filter(U=>U>=r).length>0||S>=c))break}let I=je(h),{waveform:T}=await be(s.sessions.model,{spectrogram:I});return{spectrogram:I,waveform:T}}},w9=class extends N{main_input_name="spectrogram"},js=class extends N{},y9=class extends js{},B9=class extends js{async _call(e){return new _t(await super._call(e))}},M9=class extends js{async _call(e){return new ue(await super._call(e))}},P9=class extends js{async _call(e){return new Dt(await super._call(e))}},Uu=class extends N{},R9=class extends Uu{},k9=class extends Uu{},Ku=class extends N{},O9=class extends Ku{},G9=class extends Ku{},gS=class extends N{},F9=class extends gS{},TS=class extends N{},bS=class extends TS{async generate_speech({input_ids:e,attention_mask:t,style:r,num_inference_steps:a=5,speed:n=1.05}){let{sampling_rate:s,chunk_compress_factor:i,base_chunk_size:H,latent_dim:o}=this.config,{last_hidden_state:_,durations:c}=await be(this.sessions.text_encoder,{input_ids:e,attention_mask:t,style:r}),l=c.div(n).mul_(s),d=H*i,h=l.data,$=Int32Array.from(h,Z=>Math.ceil(Z/d)),m=Math.max(...$),S=e.dims[0],I=new BigInt64Array(S*m);for(let Z=0;Z<S;++Z)I.fill(1n,Z*m,Z*m+$[Z]);let T=new K("int64",I,[S,m]),D=o*i,v=D*m,C=h2([S,D,m]),R=C.data;for(let Z=0;Z<S;++Z)if($[Z]!==m)for(let j=0;j<D;++j)R.fill(0,Z*v+j*m+$[Z],Z*v+(j+1)*m);let A=Tt([S],a);for(let Z=0;Z<a;++Z){let j=Tt([S],Z);({denoised_latents:C}=await be(this.sessions.latent_denoiser,{style:r,noisy_latents:C,latent_mask:T,encoder_outputs:_,attention_mask:t,timestep:j,num_inference_steps:A}))}let{waveform:U}=await be(this.sessions.voice_decoder,{latents:C});return{waveform:U,durations:l}}},ZH=class extends N{},Z9=class extends ZH{},U9=class extends ZH{async _call(e){return new ue(await super._call(e))}},K9=class extends ZH{},Wu=class extends N{},W9=class extends Wu{},V9=class extends Wu{},Vu=class extends N{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},j9=class extends Vu{},q9=class extends Vu{},ju=class extends N{},X9=class extends ju{},z9=class extends ju{async _call(e){return new vS(await super._call(e))}},vS=class extends El{},DS=class extends N{},J9=class extends DS{},UH=class extends N{},Q9=class extends UH{},Y9=class extends UH{async _call(e){return new Va(await super._call(e))}},eG=class extends UH{async _call(e){return new ue(await super._call(e))}},qs=class extends N{},tG=class extends qs{},rG=class extends qs{async _call(e){return new Va(await super._call(e))}},aG=class extends qs{async _call(e){return new ue(await super._call(e))}},nG=class extends qs{async _call(e){return new rt(await super._call(e))}},qu=class extends N{},sG=class extends qu{},iG=class extends qu{},HG=class extends N{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]},Xu=class extends N{},oG=class extends Xu{},_G=class extends Xu{async _call(e){return new ue(await super._call(e))}},CS=class extends N{},cG=class extends CS{},zu=class extends N{},lG=class extends zu{},uG=class extends zu{async _call(e){return new ue(await super._call(e))}},xS=class extends N{},dG=class extends xS{async _call(e){return new G3(await super._call(e))}},NS=class extends N{},pG=class extends NS{},wS=class extends ot{constructor({waveform:e,spectrogram:t}){super(),this.waveform=e,this.spectrogram=t}},yS=class extends N{},hG=class extends yS{async _call(e){return new wS(await super._call(e))}},fG=class extends Ul{},F$=2,EG=1,F_=new WeakMap;function $G(e,t){let{text_config:r,audio_config:a}=e.config,n=e.sessions.audio_encoder,{num_mel_bins:s,hidden_size:i}=a,H=s+i,o=new Kc,_=TH(a),c={batch_size:1},l="float32";for(let m of n.inputMetadata){if(m.name==="past_padding_cache"){l=m.type;continue}if(!_.has(m.name))continue;let S=fI(m.shape,c),I=S.reduce((D,v)=>D*v,1),T=Ns[m.type];o[m.name]=new K(m.type,new T(I),S)}let d=Ns[l],h=new K(l,new d(H*F$),[1,H,F$]),$=t[Symbol.asyncIterator]?.()??t[Symbol.iterator]?.();if(!$)throw new Error("input_features must be iterable or async iterable");return{encoder_session:n,enc_kv_cache:o,enc_padding_cache:h,enc_past_seq_len:0,audio_embed_queue:[],audio_embed_total_tokens:0,audio_queue_offset:0,audio_consumed:0,stream_exhausted:!1,chunks_iter:$,text_hidden_size:r.hidden_size}}async function mG(e,t){let r=t.dims[2],a=Math.floor((EG+r-3)/2)+1,n=new K("int64",BigInt64Array.from({length:a},(c,l)=>BigInt(e.enc_past_seq_len+l)),[1,a]),s=e.enc_past_seq_len+a,i=Gt([1,s]),{audio_embeds:H,present_padding_cache:o,..._}=await be(e.encoder_session,{input_features:t,attention_mask:i,position_ids:n,past_padding_cache:e.enc_padding_cache,...e.enc_kv_cache});e.enc_padding_cache.location==="gpu-buffer"&&e.enc_padding_cache.dispose(),e.enc_padding_cache=o;for(let c in _)if(c.startsWith("present.")){let l=c.replace("present","past_key_values"),d=e.enc_kv_cache[l];d?.location==="gpu-buffer"&&d.dispose(),e.enc_kv_cache[l]=_[c]}return e.enc_past_seq_len=s,H}async function IG(e,t){for(;e.audio_embed_total_tokens<t&&!e.stream_exhausted;){let r=await e.chunks_iter.next();if(r.done){e.stream_exhausted=!0;break}let a=await mG(e,r.value);e.audio_embed_queue.push({data:a.data,tokens:a.dims[1]}),e.audio_embed_total_tokens+=a.dims[1]}}function SG(e,t,r){if(e.audio_embed_queue.length===0)return;let a=t.data,n=0,s=r;for(;s>0&&e.audio_embed_queue.length>0;){let i=e.audio_embed_queue[0],H=i.tokens-e.audio_queue_offset,o=Math.min(s,H),_=e.audio_queue_offset*e.text_hidden_size;for(let c=0;c<o*e.text_hidden_size;++c)a[n*e.text_hidden_size+c]+=i.data[_+c];n+=o,s-=o,e.audio_queue_offset+=o,e.audio_queue_offset>=i.tokens&&(e.audio_embed_queue.shift(),e.audio_queue_offset=0)}e.audio_consumed+=r-s}var LG=class extends Os{constructor(e){super(),this._s=e}_call(e){let t=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>t)}},BS=class extends N{forward_params=["input_ids","attention_mask","position_ids","past_key_values"]},MS=class extends BS{async forward({input_ids:e,past_key_values:t,...r}){let a=e.dims[1],n=F_.get(this);n&&await IG(n,n.audio_consumed+a);let{inputs_embeds:s}=await be(this.sessions.embed_tokens,{input_ids:e});n&&SG(n,s,a);let i={inputs_embeds:s,...r};Xc(this,i,t);let H=this.sessions.decoder_model_merged,o=ht(i,H.inputNames);return await be(H,o)}async generate({input_features:e,stopping_criteria:t,...r}){if(!e)throw new Error("input_features (generator/iterable) must be provided");let a=$G(this,e);F_.set(this,a);let n=new uI;n.push(new LG(a)),t&&n.extend(t);try{return await super.generate({...r,stopping_criteria:n})}finally{a.enc_kv_cache.dispose(),F_.delete(this)}}},KH=class extends N{},AG=class extends KH{},gG=class extends KH{async _call(e){return new Va(await super._call(e))}},TG=class extends KH{async _call(e){return new ue(await super._call(e))}},PS=class extends ot{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}},Xn=class extends N{},bG=class extends Xn{},vG=class extends Xn{async _call(e){return new Va(await super._call(e))}},DG=class extends Xn{async _call(e){return new ue(await super._call(e))}},CG=class extends Xn{async _call(e){return new PS(await super._call(e))}},xG=class extends Xn{async _call(e){return new rt(await super._call(e))}},RS=class extends N{},NG=class extends RS{},wG=class extends lI{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1},Ju=class extends N{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"]},yG=class extends Ju{},kS=class extends Ju{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,wG)}_retrieve_init_tokens(e){let t=[e.decoder_start_token_id],r=e.language,a=e.task;if(e.is_multilingual){r||(he.warn("No language specified - defaulting to English (en)."),r="en");let s=`<|${cM(r)}|>`;t.push(e.lang_to_id[s]),t.push(e.task_to_id[a??"transcribe"])}else if(r||a)throw new Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&t.at(-1)!==e.no_timestamps_token_id?t.push(e.no_timestamps_token_id):e.return_timestamps&&t.at(-1)===e.no_timestamps_token_id&&(he.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter(n=>n!=null)}async generate({inputs:e=null,generation_config:t=null,logits_processor:r=null,stopping_criteria:a=null,...n}){t=this._prepare_generation_config(t,n);let s=n.decoder_input_ids instanceof K?Bc(n.decoder_input_ids):n.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(r??=new rc,r.push(new K3(t,s))),t.begin_suppress_tokens&&(r??=new rc,r.push(new cI(t.begin_suppress_tokens,s.length))),t.return_token_timestamps){if(!t.alignment_heads)throw new Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");t.task==="translate"&&he.warn("Token-level timestamps may not be reliable for task 'translate'."),t.output_attentions=!0,t.return_dict_in_generate=!0}if(t.return_timestamps&&!n.max_new_tokens)return this._generate_with_seek({inputs:e,generation_config:t,logits_processor:r,init_tokens:s,kwargs:n});let i=await super.generate({inputs:e,generation_config:t,logits_processor:r,decoder_input_ids:s,...n});return t.return_token_timestamps&&(i.token_timestamps=this._extract_token_timestamps(i,t.alignment_heads,t.num_frames,.02,s.length)),i}async _generate_with_seek({inputs:e,generation_config:t,logits_processor:r,init_tokens:a,kwargs:n}){let s=t.no_timestamps_token_id+1,i=Array.isArray(t.eos_token_id)?t.eos_token_id[0]:t.eos_token_id,H=t.return_token_timestamps,o=e,_=o.dims[2],c=2,l=this.config.max_source_positions,d=c*l,h=0,$=[],m=[];for(;h<_;){let I=Math.min(h+d,_),T=o.slice(null,null,[h,I]),D,v=T.dims[2];if(v<d){let Q=o.dims[1],_e=new Float32Array(Q*d),M=T.data;for(let k=0;k<Q;++k)_e.set(M.subarray(k*v,(k+1)*v),k*d);D=new K("float32",_e,[1,Q,d])}else D=T;if(r)for(let Q of r)"begin_index"in Q&&(Q.begin_index=a.length);let C=await super.generate({inputs:D,generation_config:t,logits_processor:r,decoder_input_ids:a,...n}),A=(H?C.sequences:C)[0].tolist().map(Number).slice(a.length),U;if(H){C.token_timestamps=this._extract_token_timestamps(C,t.alignment_heads,Math.floor((I-h)/c),.02,a.length);let Q=h/c*.02;U=C.token_timestamps[0].tolist().slice(a.length).map(_e=>_e+Q)}if(A.length>0&&A.at(-1)===i&&A.pop(),A.length===0)break;let Z=A.map(Q=>Q>=s),j=A.length>=2&&Z[A.length-1]&&!Z[A.length-2],z=[];for(let Q=0;Q<A.length-1;++Q)Z[Q]&&Z[Q+1]&&z.push(Q+1);let X,q=A.length;if(z.length>0)if(j)X=I-h;else{let Q=z.at(-1);X=(A[Q-1]-s)*c,q=Q}else X=I-h;let G=Math.floor(h/c),y=s+1500;for(let Q=0;Q<q;++Q)A[Q]>=s&&(A[Q]=Math.min(A[Q]+G,y));$.push(...A.slice(0,q)),U&&m.push(...U.slice(0,q)),h+=X}$.push(i);let S=[...a,...$];if(H){let I=new K("int64",S.map(BigInt),[1,S.length]),T=[...new Array(a.length).fill(0),...m,0],D=new K("float32",new Float32Array(T),[1,T.length]);return{sequences:I,token_timestamps:D}}return new K("int64",S.map(BigInt),[1,S.length])}_extract_token_timestamps(e,t,r=null,a=.02,n=0){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");r==null&&he.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let s=this.config.median_filter_width;s===void 0&&(he.warn("Model config has no `median_filter_width`, using default value of 7."),s=7);let i=e.cross_attentions,H=Array.from({length:this.config.decoder_layers},(S,I)=>je(i.map(T=>T[I]),2)),o=Xr(t.map(([S,I])=>{if(S>=H.length)throw new Error(`Layer index ${S} is out of bounds for cross attentions (length ${H.length}).`);return r?H[S].slice(null,I,null,[0,r]):H[S].slice(null,I)})).transpose(1,0,2,3),[_,c]=$m(o,-2,0,!0),l=o.clone();for(let S=0;S<l.dims[0];++S){let I=l[S];for(let T=0;T<I.dims[0];++T){let D=I[T],v=_[S][T][0].data,C=c[S][T][0].data;for(let R=0;R<D.dims[0];++R){let A=D[R].data;for(let U=0;U<A.length;++U)A[U]=(A[U]-C[U])/v[U];A.set(LB(A,s))}}}let d=n>0?l.slice(null,null,[n,l.dims[2]],null):l,h=[Nc(d,1)],$=e.sequences.dims,m=new K("float32",new Float32Array($[0]*$[1]),$);for(let S=0;S<$[0];++S){let I=h[S].neg().squeeze_(0),[T,D]=gB(I.tolist()),v=Array.from({length:T.length-1},(U,Z)=>T[Z+1]-T[Z]),C=ir([1],v).map(U=>!!U),R=[];for(let U=0;U<C.length;++U)C[U]&&R.push(D[U]*a);let A=new Array(n).fill(0);A.push(...R),R.length>0&&A.push(R.at(-1)),m[S].data.set(A)}return m}},BG=class extends kS{},zn=class extends N{},MG=class extends zn{},PG=class extends zn{async _call(e){return new _t(await super._call(e))}},RG=class extends zn{async _call(e){return new ue(await super._call(e))}},kG=class extends zn{async _call(e){return new rt(await super._call(e))}},OG=class extends zn{async _call(e){return new Dt(await super._call(e))}},Jn=class extends N{},GG=class extends Jn{},FG=class extends Jn{async _call(e){return new _t(await super._call(e))}},ZG=class extends Jn{async _call(e){return new ue(await super._call(e))}},UG=class extends Jn{async _call(e){return new rt(await super._call(e))}},KG=class extends Jn{async _call(e){return new Dt(await super._call(e))}},Qu=class extends N{},WG=class extends Qu{},VG=class extends Qu{async _call(e){return new OS(await super._call(e))}},OS=class extends ot{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},Yu=class extends N{},jG=class extends Yu{},qG=class extends Yu{},XG=new Map([["bert","BertModel"],["eurobert","EuroBertModel"],["neobert","NeoBertModel"],["modernbert","ModernBertModel"],["nomic_bert","NomicBertModel"],["roformer","RoFormerModel"],["electra","ElectraModel"],["esm","EsmModel"],["convbert","ConvBertModel"],["camembert","CamembertModel"],["deberta","DebertaModel"],["deberta-v2","DebertaV2Model"],["mpnet","MPNetModel"],["albert","AlbertModel"],["distilbert","DistilBertModel"],["roberta","RobertaModel"],["xlm","XLMModel"],["xlm-roberta","XLMRobertaModel"],["clap","ClapModel"],["clip","CLIPModel"],["clipseg","CLIPSegModel"],["chinese_clip","ChineseCLIPModel"],["siglip","SiglipModel"],["jina_clip","JinaCLIPModel"],["mobilebert","MobileBertModel"],["squeezebert","SqueezeBertModel"],["wav2vec2","Wav2Vec2Model"],["wav2vec2-bert","Wav2Vec2BertModel"],["unispeech","UniSpeechModel"],["unispeech-sat","UniSpeechSatModel"],["hubert","HubertModel"],["wavlm","WavLMModel"],["audio-spectrogram-transformer","ASTModel"],["vits","VitsModel"],["pyannote","PyAnnoteModel"],["wespeaker-resnet","WeSpeakerResNetModel"],["detr","DetrModel"],["rt_detr","RTDetrModel"],["rt_detr_v2","RTDetrV2Model"],["rf_detr","RFDetrModel"],["d_fine","DFineModel"],["table-transformer","TableTransformerModel"],["vit","ViTModel"],["ijepa","IJepaModel"],["pvt","PvtModel"],["vit_msn","ViTMSNModel"],["vit_mae","ViTMAEModel"],["groupvit","GroupViTModel"],["fastvit","FastViTModel"],["mobilevit","MobileViTModel"],["mobilevitv2","MobileViTV2Model"],["owlvit","OwlViTModel"],["owlv2","Owlv2Model"],["beit","BeitModel"],["deit","DeiTModel"],["hiera","HieraModel"],["convnext","ConvNextModel"],["convnextv2","ConvNextV2Model"],["dinov2","Dinov2Model"],["dinov2_with_registers","Dinov2WithRegistersModel"],["dinov3_vit","DINOv3ViTModel"],["dinov3_convnext","DINOv3ConvNextModel"],["resnet","ResNetModel"],["swin","SwinModel"],["swin2sr","Swin2SRModel"],["donut-swin","DonutSwinModel"],["yolos","YolosModel"],["dpt","DPTModel"],["glpn","GLPNModel"],["hifigan","SpeechT5HifiGan"],["efficientnet","EfficientNetModel"],["decision_transformer","DecisionTransformerModel"],["patchtst","PatchTSTModel"],["patchtsmixer","PatchTSMixerModel"],["mobilenet_v1","MobileNetV1Model"],["mobilenet_v2","MobileNetV2Model"],["mobilenet_v3","MobileNetV3Model"],["mobilenet_v4","MobileNetV4Model"],["maskformer","MaskFormerModel"],["mgp-str","MgpstrForSceneTextRecognition"],["style_text_to_speech_2","StyleTextToSpeech2Model"],["openai_privacy_filter","OpenAIPrivacyFilterModel"]]),zG=new Map([["t5","T5Model"],["longt5","LongT5Model"],["mt5","MT5Model"],["bart","BartModel"],["mbart","MBartModel"],["marian","MarianModel"],["whisper","WhisperModel"],["cohere_asr","CohereAsrModel"],["m2m_100","M2M100Model"],["blenderbot","BlenderbotModel"],["blenderbot-small","BlenderbotSmallModel"]]),JG=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),QG=new Map([["bloom","BloomModel"],["jais","JAISModel"],["gpt2","GPT2Model"],["gpt_oss","GptOssModel"],["gptj","GPTJModel"],["gpt_bigcode","GPTBigCodeModel"],["gpt_neo","GPTNeoModel"],["gpt_neox","GPTNeoXModel"],["codegen","CodeGenModel"],["llama","LlamaModel"],["apertus","ApertusModel"],["nanochat","NanoChatModel"],["arcee","ArceeModel"],["afmoe","AfmoeModel"],["lfm2","Lfm2Model"],["lfm2_moe","Lfm2MoeModel"],["smollm3","SmolLM3Model"],["exaone","ExaoneModel"],["olmo","OlmoModel"],["olmo2","Olmo2Model"],["olmo3","Olmo3Model"],["olmo_hybrid","OlmoHybridModel"],["mobilellm","MobileLLMModel"],["granite","GraniteModel"],["granitemoehybrid","GraniteMoeHybridModel"],["cohere","CohereModel"],["cohere2","Cohere2Model"],["gemma","GemmaModel"],["gemma2","Gemma2Model"],["vaultgemma","VaultGemmaModel"],["gemma3_text","Gemma3Model"],["helium","HeliumModel"],["glm","GlmModel"],["glm_moe_dsa","GlmMoeDsaModel"],["openelm","OpenELMModel"],["qwen2","Qwen2Model"],["qwen2_moe","Qwen2MoeModel"],["qwen3","Qwen3Model"],["qwen3_moe","Qwen3MoeModel"],["qwen3_next","Qwen3NextModel"],["phi","PhiModel"],["phi3","Phi3Model"],["mpt","MptModel"],["opt","OPTModel"],["mistral","MistralModel"],["mistral4","Mistral4Model"],["ministral","MinistralModel"],["ministral3","Ministral3Model"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2Model"],["deepseek_v3","DeepseekV3Model"],["falcon","FalconModel"],["falcon_h1","FalconH1Model"],["nemotron_h","NemotronHModel"],["solar_open","SolarOpenModel"],["stablelm","StableLmModel"],["modernbert-decoder","ModernBertDecoderModel"],["hunyuan_v1_dense","HunYuanDenseV1Model"],["youtu","YoutuModel"]]),GS=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"],["cohere_asr","CohereAsrForConditionalGeneration"]]),FS=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),ZS=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),US=new Map([["bert","BertForSequenceClassification"],["eurobert","EuroBertForSequenceClassification"],["neobert","NeoBertForSequenceClassification"],["modernbert","ModernBertForSequenceClassification"],["roformer","RoFormerForSequenceClassification"],["electra","ElectraForSequenceClassification"],["esm","EsmForSequenceClassification"],["convbert","ConvBertForSequenceClassification"],["camembert","CamembertForSequenceClassification"],["deberta","DebertaForSequenceClassification"],["deberta-v2","DebertaV2ForSequenceClassification"],["mpnet","MPNetForSequenceClassification"],["albert","AlbertForSequenceClassification"],["distilbert","DistilBertForSequenceClassification"],["roberta","RobertaForSequenceClassification"],["xlm","XLMForSequenceClassification"],["xlm-roberta","XLMRobertaForSequenceClassification"],["bart","BartForSequenceClassification"],["mbart","MBartForSequenceClassification"],["mobilebert","MobileBertForSequenceClassification"],["squeezebert","SqueezeBertForSequenceClassification"]]),KS=new Map([["bert","BertForTokenClassification"],["eurobert","EuroBertForTokenClassification"],["neobert","NeoBertForTokenClassification"],["modernbert","ModernBertForTokenClassification"],["roformer","RoFormerForTokenClassification"],["electra","ElectraForTokenClassification"],["esm","EsmForTokenClassification"],["convbert","ConvBertForTokenClassification"],["camembert","CamembertForTokenClassification"],["deberta","DebertaForTokenClassification"],["deberta-v2","DebertaV2ForTokenClassification"],["mpnet","MPNetForTokenClassification"],["distilbert","DistilBertForTokenClassification"],["roberta","RobertaForTokenClassification"],["xlm","XLMForTokenClassification"],["xlm-roberta","XLMRobertaForTokenClassification"],["openai_privacy_filter","OpenAIPrivacyFilterForTokenClassification"]]),WS=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),VS=new Map([["bloom","BloomForCausalLM"],["gpt2","GPT2LMHeadModel"],["gpt_oss","GptOssForCausalLM"],["jais","JAISLMHeadModel"],["gptj","GPTJForCausalLM"],["gpt_bigcode","GPTBigCodeForCausalLM"],["gpt_neo","GPTNeoForCausalLM"],["gpt_neox","GPTNeoXForCausalLM"],["codegen","CodeGenForCausalLM"],["llama","LlamaForCausalLM"],["nanochat","NanoChatForCausalLM"],["apertus","ApertusForCausalLM"],["llama4_text","Llama4ForCausalLM"],["arcee","ArceeForCausalLM"],["afmoe","AfmoeForCausalLM"],["lfm2","Lfm2ForCausalLM"],["lfm2_moe","Lfm2MoeForCausalLM"],["smollm3","SmolLM3ForCausalLM"],["exaone","ExaoneForCausalLM"],["olmo","OlmoForCausalLM"],["olmo2","Olmo2ForCausalLM"],["olmo3","Olmo3ForCausalLM"],["olmo_hybrid","OlmoHybridForCausalLM"],["mobilellm","MobileLLMForCausalLM"],["granite","GraniteForCausalLM"],["granitemoehybrid","GraniteMoeHybridForCausalLM"],["cohere","CohereForCausalLM"],["cohere2","Cohere2ForCausalLM"],["gemma","GemmaForCausalLM"],["gemma2","Gemma2ForCausalLM"],["vaultgemma","VaultGemmaForCausalLM"],["gemma3_text","Gemma3ForCausalLM"],["gemma3","Gemma3ForCausalLM"],["helium","HeliumForCausalLM"],["glm","GlmForCausalLM"],["glm_moe_dsa","GlmMoeDsaForCausalLM"],["openelm","OpenELMForCausalLM"],["qwen2","Qwen2ForCausalLM"],["qwen2_moe","Qwen2MoeForCausalLM"],["qwen3","Qwen3ForCausalLM"],["qwen3_moe","Qwen3MoeForCausalLM"],["qwen3_next","Qwen3NextForCausalLM"],["qwen2_vl","Qwen2VLForCausalLM"],["qwen2_5_vl","Qwen2_5_VLForCausalLM"],["qwen3_vl","Qwen3VLForCausalLM"],["qwen3_vl_moe","Qwen3VLMoeForCausalLM"],["qwen3_5","Qwen3_5ForCausalLM"],["qwen3_5_text","Qwen3_5ForCausalLM"],["qwen3_5_moe","Qwen3_5MoeForCausalLM"],["gemma3n","Gemma3nForCausalLM"],["gemma4","Gemma4ForCausalLM"],["phi","PhiForCausalLM"],["phi3","Phi3ForCausalLM"],["mpt","MptForCausalLM"],["opt","OPTForCausalLM"],["mbart","MBartForCausalLM"],["mistral","MistralForCausalLM"],["mistral4","Mistral4ForCausalLM"],["ministral","MinistralForCausalLM"],["ministral3","Ministral3ForCausalLM"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2ForCausalLM"],["deepseek_v3","DeepseekV3ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["nemotron_h","NemotronHForCausalLM"],["trocr","TrOCRForCausalLM"],["solar_open","SolarOpenForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),YG=new Map([["multi_modality","MultiModalityCausalLM"]]),jS=new Map([["bert","BertForMaskedLM"],["eurobert","EuroBertForMaskedLM"],["neobert","NeoBertForMaskedLM"],["modernbert","ModernBertForMaskedLM"],["roformer","RoFormerForMaskedLM"],["electra","ElectraForMaskedLM"],["esm","EsmForMaskedLM"],["convbert","ConvBertForMaskedLM"],["camembert","CamembertForMaskedLM"],["deberta","DebertaForMaskedLM"],["deberta-v2","DebertaV2ForMaskedLM"],["mpnet","MPNetForMaskedLM"],["albert","AlbertForMaskedLM"],["distilbert","DistilBertForMaskedLM"],["roberta","RobertaForMaskedLM"],["xlm","XLMWithLMHeadModel"],["xlm-roberta","XLMRobertaForMaskedLM"],["mobilebert","MobileBertForMaskedLM"],["squeezebert","SqueezeBertForMaskedLM"]]),qS=new Map([["bert","BertForQuestionAnswering"],["neobert","NeoBertForQuestionAnswering"],["roformer","RoFormerForQuestionAnswering"],["electra","ElectraForQuestionAnswering"],["convbert","ConvBertForQuestionAnswering"],["camembert","CamembertForQuestionAnswering"],["deberta","DebertaForQuestionAnswering"],["deberta-v2","DebertaV2ForQuestionAnswering"],["mpnet","MPNetForQuestionAnswering"],["albert","AlbertForQuestionAnswering"],["distilbert","DistilBertForQuestionAnswering"],["roberta","RobertaForQuestionAnswering"],["xlm","XLMForQuestionAnswering"],["xlm-roberta","XLMRobertaForQuestionAnswering"],["mobilebert","MobileBertForQuestionAnswering"],["squeezebert","SqueezeBertForQuestionAnswering"]]),XS=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),zS=new Map([["llava","LlavaForConditionalGeneration"],["llava_onevision","LlavaOnevisionForConditionalGeneration"],["moondream1","Moondream1ForConditionalGeneration"],["florence2","Florence2ForConditionalGeneration"],["qwen2_vl","Qwen2VLForConditionalGeneration"],["qwen2_5_vl","Qwen2_5_VLForConditionalGeneration"],["qwen3_vl","Qwen3VLForConditionalGeneration"],["qwen3_vl_moe","Qwen3VLMoeForConditionalGeneration"],["qwen3_5","Qwen3_5ForConditionalGeneration"],["qwen3_5_moe","Qwen3_5MoeForConditionalGeneration"],["lfm2_vl","Lfm2VlForConditionalGeneration"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"],["paligemma","PaliGemmaForConditionalGeneration"],["llava_qwen2","LlavaQwen2ForCausalLM"],["gemma3","Gemma3ForConditionalGeneration"],["gemma3n","Gemma3nForConditionalGeneration"],["gemma4","Gemma4ForConditionalGeneration"],["mistral3","Mistral3ForConditionalGeneration"],["lighton_ocr","LightOnOcrForConditionalGeneration"],["glm_ocr","GlmOcrForConditionalGeneration"]]),JS=new Map([["granite_speech","GraniteSpeechForConditionalGeneration"],["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"],["voxtral_realtime","VoxtralRealtimeForConditionalGeneration"]]),e6=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),QS=new Map([["vit","ViTForImageClassification"],["ijepa","IJepaForImageClassification"],["pvt","PvtForImageClassification"],["vit_msn","ViTMSNForImageClassification"],["fastvit","FastViTForImageClassification"],["mobilevit","MobileViTForImageClassification"],["mobilevitv2","MobileViTV2ForImageClassification"],["beit","BeitForImageClassification"],["deit","DeiTForImageClassification"],["hiera","HieraForImageClassification"],["convnext","ConvNextForImageClassification"],["convnextv2","ConvNextV2ForImageClassification"],["dinov2","Dinov2ForImageClassification"],["dinov2_with_registers","Dinov2WithRegistersForImageClassification"],["resnet","ResNetForImageClassification"],["swin","SwinForImageClassification"],["segformer","SegformerForImageClassification"],["efficientnet","EfficientNetForImageClassification"],["mobilenet_v1","MobileNetV1ForImageClassification"],["mobilenet_v2","MobileNetV2ForImageClassification"],["mobilenet_v3","MobileNetV3ForImageClassification"],["mobilenet_v4","MobileNetV4ForImageClassification"]]),YS=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),eL=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),bn=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),tL=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),rL=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),aL=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),nL=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),sL=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),iL=new Map([["wavlm","WavLMForXVector"]]),HL=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),oL=new Map([["vitmatte","VitMatteForImageMatting"]]),t6=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),_L=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),cL=new Map([["chmv2","CHMv2ForDepthEstimation"],["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),lL=new Map([["sapiens","SapiensForNormalEstimation"]]),uL=new Map([["vitpose","VitPoseForPoseEstimation"]]),dL=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),pL=[[XG,V.EncoderOnly],[zG,V.EncoderDecoder],[QG,V.DecoderOnlyWithoutHead],[JG,V.AutoEncoder],[US,V.EncoderOnly],[KS,V.EncoderOnly],[WS,V.Seq2Seq],[GS,V.Seq2Seq],[VS,V.DecoderOnly],[YG,V.MultiModality],[jS,V.EncoderOnly],[qS,V.EncoderOnly],[XS,V.Vision2Seq],[zS,V.ImageTextToText],[JS,V.AudioTextToText],[QS,V.EncoderOnly],[bn,V.EncoderOnly],[rL,V.EncoderOnly],[tL,V.EncoderOnly],[oL,V.EncoderOnly],[t6,V.EncoderOnly],[_L,V.EncoderOnly],[cL,V.EncoderOnly],[lL,V.EncoderOnly],[uL,V.EncoderOnly],[YS,V.EncoderOnly],[eL,V.EncoderOnly],[aL,V.MaskGeneration],[nL,V.EncoderOnly],[sL,V.EncoderOnly],[FS,V.Seq2Seq],[ZS,V.EncoderOnly],[iL,V.EncoderOnly],[HL,V.EncoderOnly],[dL,V.EncoderOnly]];for(let[e,t]of pL)for(let r of e.values()){qr.set(r,t);let a=Jc[r];Nn.set(a,r),qc.set(r,a)}var r6=[["MusicgenForConditionalGeneration",oS,V.Musicgen],["Phi3VForCausalLM",uS,V.Phi3V],["CLIPTextModelWithProjection",vI,V.EncoderOnly],["SiglipTextModel",SS,V.EncoderOnly],["JinaCLIPTextModel",JI,V.EncoderOnly],["ClapTextModelWithProjection",TI,V.EncoderOnly],["ClapAudioModelWithProjection",bI,V.EncoderOnly],["DacEncoderModel",xI,V.EncoderOnly],["DacDecoderModel",NI,V.EncoderOnly],["MimiEncoderModel",sS,V.EncoderOnly],["MimiDecoderModel",iS,V.EncoderOnly],["SnacEncoderModel",LS,V.EncoderOnly],["SnacDecoderModel",AS,V.EncoderOnly],["Gemma3nForConditionalGeneration",NH,V.ImageAudioTextToText],["Gemma4ForConditionalGeneration",Cl,V.ImageAudioTextToText],["SupertonicForConditionalGeneration",bS,V.Supertonic],["ChatterboxModel",LI,V.Chatterbox],["VoxtralRealtimeForConditionalGeneration",MS,V.VoxtralRealtime]];for(let[e,t,r]of r6)qr.set(e,r),Nn.set(t,e),qc.set(e,t);var hL=new Map([["modnet",bn],["birefnet",bn],["isnet",bn],["ben",bn]]);for(let[e,t]of hL.entries())t.set(e,"PreTrainedModel"),qr.set(e,V.EncoderOnly),qc.set(e,N);var a6=new Set(hL.keys());qr.set("PreTrainedModel",V.EncoderOnly);Nn.set(N,"PreTrainedModel");var Be={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:US,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:KS,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:FS,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:ZS,MODEL_FOR_MASKED_LM_MAPPING_NAMES:jS,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:qS,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:QS,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:bn,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:tL,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:rL,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:YS,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:eL,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:aL,MODEL_FOR_CTC_MAPPING_NAMES:nL,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:sL,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:iL,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:HL,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:e6,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:oL,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:_L,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:cL,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:lL,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:uL,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:dL,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:zS,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:JS,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:WS,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:GS,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:VS,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:XS};s5(Be);var Me=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let t of this.MODEL_CLASS_MAPPINGS)if(t.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:a=null,local_files_only:n=!1,revision:s="main",model_file_name:i=null,subfolder:H="onnx",device:o=null,dtype:_=null,use_external_data_format:c=null,session_options:l={}}={}){let d={progress_callback:t,config:r,cache_dir:a,local_files_only:n,revision:s,model_file_name:i,subfolder:H,device:o,dtype:_,use_external_data_format:c,session_options:l};if(d.config=await ys.from_pretrained(e,d),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:h}=d.config;for(let $ of this.MODEL_CLASS_MAPPINGS){let m=$.get(h);if(!m){for(let S of $.values())if(S[0]===h){m=S;break}if(!m)continue}return await Jc[m].from_pretrained(e,d)}if(this.BASE_IF_FAIL)return a6.has(h)||he.warn(`Unknown model class "${h}", attempting to construct from base class.`),await N.from_pretrained(e,d);throw Error(`Unsupported model type: ${h}`)}},Ts=class extends Me{static MODEL_CLASS_MAPPINGS=pL.map(e=>e[0]);static BASE_IF_FAIL=!0},Z$=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},n6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},Z_=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},s6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},i6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},H6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},o6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},_6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},c6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},l6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},u6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},U$=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},K$=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},W$=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},d6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},p6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},B7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},h6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_CTC_MAPPING_NAMES]},f6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},M7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},P7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},E6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},R7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},$6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},m6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},k7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},O7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},I6=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},G7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},F7=class extends Me{static MODEL_CLASS_MAPPINGS=[Be.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function pr(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(t=>qt.read(t)))}async function vn(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(r=>typeof r=="string"||r instanceof URL?IM(r,t):r instanceof Float64Array?new Float32Array(r):r))}function sc(e,t){t&&(e=e.map(i=>i|0));let[r,a,n,s]=e;return{xmin:r,ymin:a,xmax:n,ymax:s}}var Ye=class extends Ft{constructor({task:e,model:t,tokenizer:r=null,processor:a=null}){super(),this.task=e,this.model=t,this.tokenizer=r,this.processor=a}async dispose(){await this.model.dispose()}},S6=class extends Ye{async _call(e,{top_k:t=1}={}){let r=this.tokenizer(e,{padding:!0,truncation:!0}),a=await this.model(r),{problem_type:n,id2label:s}=this.model.config,i=n==="multi_label_classification"?o=>o.sigmoid():o=>new K("float32",St(o.data),o.dims),H=[];for(let o of a.logits){let _=i(o),c=await Rn(_,t),l=c[0].tolist(),h=c[1].tolist().map(($,m)=>({label:s?s[$]:`LABEL_${$}`,score:l[m]}));t===1?H.push(...h):H.push(h)}return Array.isArray(e)||t===1?H:H[0]}},L6=class extends Ye{async _call(e,{ignore_labels:t=["O"],aggregation_strategy:r="none"}={}){if(r!=="none"&&r!=="simple")throw new Error(`Invalid aggregation_strategy: "${r}". Must be one of "none" or "simple".`);let a=Array.isArray(e),n=this.tokenizer(a?e:[e],{padding:!0,truncation:!0}),i=(await this.model(n)).logits,H=this.model.config.id2label,o=[];for(let _=0;_<i.dims[0];++_){let c=n.input_ids[_].tolist(),l=i[_],d=[];for(let h=0;h<l.dims[0];++h){let $=l[h],m=et($.data)[1],S=H?H[m]:`LABEL_${m}`;if(t.includes(S))continue;let I=this.tokenizer.decode([c[h]],{skip_special_tokens:!0});if(I==="")continue;let T=St($.data);d.push({entity:S,score:T[m],index:h,word:I})}o.push(r==="simple"?g6(d,c,this.tokenizer):d)}return a?o:o[0]}};function A6(e){let t=e[0];return e[1]==="-"&&(t==="B"||t==="I"||t==="E"||t==="S")?[t,e.slice(2)]:["I",e]}function g6(e,t,r){let a=[],n=null;for(let s=0;s<e.length;++s){let[i,H]=A6(e[s].entity);n===H&&i!=="B"&&i!=="S"?(a[a.length-1].end=s+1,i==="E"&&(n=null)):(a.push({tag:H,start:s,end:s+1}),n=i==="S"?null:H)}return a.map(({tag:s,start:i,end:H})=>{let o=0,_=[];for(let c=i;c<H;++c)o+=e[c].score,_.push(t[e[c].index]);return{entity_group:s,score:o/(H-i),word:r.decode(_,{skip_special_tokens:!0})}})}var T6=class extends Ye{async _call(e,t,{top_k:r=1}={}){let a=this.tokenizer(e,{text_pair:t,padding:!0,truncation:!0}),n=Array.isArray(e),{start_logits:s,end_logits:i}=await this.model(a),H=a.input_ids.tolist(),o=a.attention_mask.tolist(),{all_special_ids:_,sep_token_id:c}=this.tokenizer,l=[];for(let d=0;d<s.dims[0];++d){let h=H[d],$=h.findIndex(C=>C==c),m=s[d].tolist(),S=i[d].tolist();for(let C=1;C<m.length;++C)(o[d]==0||C<=$||_.findIndex(R=>R==h[C])!==-1)&&(m[C]=-1/0,S[C]=-1/0);let I=St(m).map((C,R)=>[C,R]),T=St(S).map((C,R)=>[C,R]);I[0][0]=0,T[0][0]=0;let D=Vx(I,T).filter(C=>C[0][1]<=C[1][1]).map(C=>[C[0][1],C[1][1],C[0][0]*C[1][0]]).sort((C,R)=>R[2]-C[2]),v=[];for(let C=0;C<Math.min(D.length,r);++C){let[R,A,U]=D[C],Z=h.slice(R,A+1),j=this.tokenizer.decode(Z,{skip_special_tokens:!0});v.push({answer:j,score:U})}r===1?l.push(...v):l.push(v)}return n?l:l[0]}},b6=class extends Ye{async _call(e,{top_k:t=5}={}){let{mask_token_id:r,mask_token:a}=this.tokenizer,n=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:s}=await this.model(n),i=[],H=n.input_ids.tolist();for(let o=0;o<H.length;++o){let _=H[o],c=_.findIndex(m=>m==r);if(c===-1)throw Error(`Mask token (${a}) not found in text.`);let l=s[o][c],d=await Rn(new K("float32",St(l.data),l.dims),t),h=d[0].tolist(),$=d[1].tolist();i.push($.map((m,S)=>{let I=_.slice();return I[c]=m,{score:h[S],token:Number(m),token_str:this.tokenizer.decode([m]),sequence:this.tokenizer.decode(I,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}},ed=class extends Ye{_default_generation_config={max_new_tokens:256};_key="generated_text";async _call(e,t={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(H=>this.model.config.prefix+H));let r=this.model.config.task_specific_params;r&&r[this.task]&&r[this.task].prefix&&(e=e.map(H=>r[this.task].prefix+H));let a=this.tokenizer,n={padding:!0,truncation:!0},s;this.task==="translation"&&"_build_translation_inputs"in a?s=a._build_translation_inputs(e,n,t):s=a(e,n);let i=await this.model.generate({...s,...this._default_generation_config,...t});return a.batch_decode(i,{skip_special_tokens:!0}).map(H=>({[this._key]:H}))}},v6=class extends ed{_key="summary_text"},D6=class extends ed{_key="translation_text"};function V$(e){return Array.isArray(e)&&e.every(t=>"role"in t&&"content"in t)}var C6=class extends Ye{_default_generation_config={max_new_tokens:256};async _call(e,t={}){let{add_special_tokens:r,return_full_text:a,tools:n,documents:s,chat_template:i,tokenizer_encode_kwargs:H,...o}=t,_=!1,c=!1,l=r??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,d=H,h;if(typeof e=="string")h=e=[e];else if(Array.isArray(e)&&e.every(v=>typeof v=="string"))_=!0,h=e;else{if(V$(e))e=[e];else if(Array.isArray(e)&&e.every(V$))_=!0;else throw new Error("Input must be a string, an array of strings, a Chat, or an array of Chats");c=!0;let v={tokenize:!1,add_generation_prompt:!0,...ht({tools:n,documents:s,chat_template:i},["tools","documents","chat_template"]),...d};h=e.map(C=>this.tokenizer.apply_chat_template(C,v)),l=!1,d=void 0}let $=c?!1:a??!0;this.tokenizer.padding_side="left";let m=this.tokenizer(h,{add_special_tokens:l,padding:!0,truncation:!0,...d}),S=await this.model.generate({...m,...this._default_generation_config,...o}),I=this.tokenizer.batch_decode(S,{skip_special_tokens:!0}),T;!$&&m.input_ids.dims.at(-1)>0&&(T=this.tokenizer.batch_decode(m.input_ids,{skip_special_tokens:!0}).map(v=>v.length));let D=Array.from({length:e.length},v=>[]);for(let v=0;v<I.length;++v){let C=Math.floor(v/S.dims[0]*e.length);T&&(I[v]=I[v].slice(T[C])),D[C].push({generated_text:c?[...e[C],{role:"assistant",content:I[v]}]:I[v]})}return!_&&D.length===1?D[0]:D}},x6=class extends Ye{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([t,r])=>[t.toLowerCase(),r])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(he.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(he.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:a=!1}={}){let n=Array.isArray(e);n||(e=[e]),Array.isArray(t)||(t=[t]);let s=t.map(o=>r.replace("{}",o)),i=a||t.length===1,H=[];for(let o of e){let _=[];for(let d of s){let h=this.tokenizer(o,{text_pair:d,padding:!0,truncation:!0}),$=await this.model(h);i?_.push([$.logits.data[this.contradiction_id],$.logits.data[this.entailment_id]]):_.push($.logits.data[this.entailment_id])}let l=(i?_.map(d=>St(d)[1]):St(_)).map((d,h)=>[d,h]).sort((d,h)=>h[0]-d[0]);H.push({sequence:o,labels:l.map(d=>t[d[1]]),scores:l.map(d=>d[0])})}return n?H:H[0]}},N6=class extends Ye{async _call(e,{top_k:t=5}={}){let r=this.processor.feature_extractor.config.sampling_rate,a=await vn(e,r),n=this.model.config.id2label,s=[];for(let i of a){let H=await this.processor(i),_=(await this.model(H)).logits[0],c=await Rn(new K("float32",St(_.data),_.dims),t),l=c[0].tolist(),h=c[1].tolist().map(($,m)=>({label:n?n[$]:`LABEL_${$}`,score:l[m]}));s.push(h)}return Array.isArray(e)?s:s[0]}},w6=class extends Ye{async _call(e,t,{hypothesis_template:r="This is a sound of {}."}={}){let a=!Array.isArray(e);a&&(e=[e]);let n=t.map(_=>r.replace("{}",_)),s=this.tokenizer(n,{padding:!0,truncation:!0}),i=this.processor.feature_extractor.config.sampling_rate,H=await vn(e,i),o=[];for(let _ of H){let c=await this.processor(_),l=await this.model({...s,...c}),d=St(l.logits_per_audio.data);o.push([...d].map((h,$)=>({score:h,label:t[$]})))}return a?o[0]:o}},y6=class extends Ye{_default_generation_config={};async _call(e,t={}){switch(t={...this._default_generation_config,...t},this.model.config.model_type){case"whisper":case"lite-whisper":return this._call_whisper(e,t);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":case"parakeet_ctc":return this._call_wav2vec2(e,t);case"moonshine":return this._call_moonshine(e,t);case"cohere_asr":return this._call_cohere_asr(e,t);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t){t.language&&he.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&he.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let r=!Array.isArray(e),a=r?[e]:e,n=this.processor.feature_extractor.config.sampling_rate,s=await vn(a,n),i=[];for(let H of s){let o=await this.processor(H),c=(await this.model(o)).logits[0],l=[];for(let h of c)l.push(et(h.data)[1]);let d=this.tokenizer.decode(l,{skip_special_tokens:!0}).trim();i.push({text:d})}return r?i[0]:i}async _call_whisper(e,t){let r=t.return_timestamps??!1,a=t.chunk_length_s??0,n=t.force_full_sequences??!1,s=t.stride_length_s??null,i={...t};r==="word"&&(i.return_token_timestamps=!0,i.return_timestamps=!0);let H=!Array.isArray(e),o=H?[e]:e,_=this.processor.feature_extractor.config,c=_.chunk_length/this.model.config.max_source_positions,l=_.hop_length,d=_.sampling_rate,h=await vn(o,d),$=[];for(let m of h){let S=[];if(a>0){if(s===null)s=a/6;else if(a<=s)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let D=d*a,v=d*s,C=D-2*v,R=0;for(;;){let A=R+D,U=m.subarray(R,A),Z=await this.processor(U),j=R===0,z=A>=m.length;if(S.push({stride:[U.length,j?0:v,z?0:v],input_features:Z.input_features,is_last:z}),z)break;R+=C}}else S=[{stride:[m.length,0,0],input_features:(await this.processor(m)).input_features,is_last:!0}];for(let D of S){i.num_frames=Math.floor(D.stride[0]/l);let v=await this.model.generate({inputs:D.input_features,...i});if(r==="word"){let C=v.sequences.tolist()[0],R=v.token_timestamps.tolist()[0],A=this.tokenizer.timestamp_begin,U=Math.max(C.findIndex(Z=>Number(Z)>=A),0);D.tokens=C.slice(U),D.token_timestamps=R.slice(U).map(Z=>As(Z,2))}else D.tokens=v[0].tolist();D.stride=D.stride.map(C=>C/d)}let[I,T]=this.tokenizer._decode_asr(S,{time_precision:c,return_timestamps:r,force_full_sequences:n});$.push({text:I,...T})}return H?$[0]:$}async _call_moonshine(e,t){let r=!Array.isArray(e),a=r?[e]:e,n=this.processor.feature_extractor.config.sampling_rate,s=await vn(a,n),i=[];for(let H of s){let o=await this.processor(H),_=Math.floor(H.length/n)*6,c=await this.model.generate({max_new_tokens:_,...t,...o}),l=this.processor.batch_decode(c,{skip_special_tokens:!0})[0];i.push({text:l})}return r?i[0]:i}async _call_cohere_asr(e,t){let r=!Array.isArray(e),a=r?[e]:e,n=this.processor.feature_extractor,s=n.config.sampling_rate,i=await vn(a,s),H=t.language??"en",o=this.processor.get_decoder_prompt_ids(H),_=[];for(let c of i){let l=n.split_audio(c),d=[];for(let $ of l){let m=await this.processor($),S=await this.model.generate({...m,decoder_input_ids:o,...t}),I=this.tokenizer.decode(S[0].tolist(),{skip_special_tokens:!0}).trim();d.push(I)}let h=this.processor.constructor.join_chunks(d,H);_.push({text:h})}return r?_[0]:_}},B6=class extends Ye{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,t){if((typeof e=="string"||e instanceof URL)&&(e=new Float32Array(await(await Te.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new K("float32",e,[e.length]);else if(!(e instanceof K))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(t>1){if(e.dims[0]===1)e=e.repeat(t,1);else if(e.dims[0]!==t)throw new Error(`Expected speaker embeddings batch size to be 1 or ${t}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,t,r,a=null){let n=t.data,[s,i]=t.dims,H=a?a.data:null,o=[];for(let _=0;_<s;++_){let c=H?Math.min(Math.ceil(H[_]),i):i,l=_*i;o.push(new xM(n.slice(l,l+c),r))}return Array.isArray(e)?o:o[0]}async _call(e,t){return this.processor?this._call_text_to_spectrogram(e,t):this.model.config.model_type==="supertonic"?this._call_supertonic(e,t):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:t,num_inference_steps:r,speed:a}){if(!t)throw new Error("Speaker embeddings must be provided for Supertonic models.");let{sampling_rate:n,style_dim:s}=this.model.config,i=this.tokenizer(e,{padding:!0,truncation:!0}),H=i.input_ids.dims[0];t=await this._prepare_speaker_embeddings(t,H),t=t.view(H,-1,s);let{waveform:o,durations:_}=await this.model.generate_speech({...i,style:t,num_inference_steps:r,speed:a});return this._postprocess_waveform(e,o,n,_)}async _call_text_to_waveform(e){let t=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:r}=await this.model(t),a=this.model.config.sampling_rate;return this._postprocess_waveform(e,r,a)}async _call_text_to_spectrogram(e,{speaker_embeddings:t}){this.vocoder||(he.info("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await Ts.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:"fp32"}));let{input_ids:r}=this.tokenizer(e,{padding:!0,truncation:!0}),a=r.dims[0];t=await this._prepare_speaker_embeddings(t,a),t=t.view(a,-1);let{waveform:n}=await this.model.generate_speech(r,t,{vocoder:this.vocoder}),s=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,n,s)}},M6=class extends Ye{async _call(e,t={}){let r=Array.isArray(e),a=await pr(e),{pixel_values:n}=await this.processor(a),s=[];for(let i of n){i.dims=[1,...i.dims];let H=await this.model.generate({inputs:i,...t}),o=this.tokenizer.batch_decode(H,{skip_special_tokens:!0}).map(_=>({generated_text:_.trim()}));s.push(o)}return r?s:s[0]}},P6=class extends Ye{async _call(e,{top_k:t=5}={}){let r=await pr(e),{pixel_values:a}=await this.processor(r),n=await this.model({pixel_values:a}),{id2label:s}=this.model.config,i=[];for(let H of n.logits){let o=await Rn(new K("float32",St(H.data),H.dims),t),_=o[0].tolist(),l=o[1].tolist().map((d,h)=>({label:s?s[d]:`LABEL_${d}`,score:_[h]}));i.push(l)}return Array.isArray(e)?i:i[0]}},j$={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},fL=class extends Ye{async _call(e,{threshold:t=.5,mask_threshold:r=.5,overlap_mask_area_threshold:a=.8,label_ids_to_fuse:n=null,target_sizes:s=null,subtask:i=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let o=await pr(e),_=o.map(I=>[I.height,I.width]),c=await this.processor(o),{inputNames:l,outputNames:d}=this.model.sessions.model;if(!l.includes("pixel_values")){if(l.length!==1)throw Error(`Expected a single input name, but got ${l.length} inputs: ${l}.`);let I=l[0];if(I in c)throw Error(`Input name ${I} already exists in the inputs.`);c[I]=c.pixel_values}let h=await this.model(c),$=null;if(i!==null)$=j$[i];else if(this.processor.image_processor){for(let[I,T]of Object.entries(j$))if(T in this.processor.image_processor){$=this.processor.image_processor[T].bind(this.processor.image_processor),i=I;break}}let m=this.model.config.id2label,S=[];if(i)if(i==="panoptic"||i==="instance"){let I=$(h,t,r,a,n,s??_)[0],T=I.segmentation;for(let D of I.segments_info){let v=new Uint8ClampedArray(T.data.length);for(let R=0;R<T.data.length;++R)T.data[R]===D.id&&(v[R]=255);let C=new qt(v,T.dims[1],T.dims[0],1);S.push({score:D.score,label:m[D.label_id],mask:C})}}else if(i==="semantic"){let{segmentation:I,labels:T}=$(h,s??_)[0];for(let D of T){let v=new Uint8ClampedArray(I.data.length);for(let R=0;R<I.data.length;++R)I.data[R]===D&&(v[R]=255);let C=new qt(v,I.dims[1],I.dims[0],1);S.push({score:null,label:m[D],mask:C})}}else throw Error(`Subtask ${i} not supported.`);else{let T=h[d[0]];for(let D=0;D<_.length;++D){let v=_[D],C=T[D];C.data.some(A=>A<-1e-5||A>1+1e-5)&&C.sigmoid_();let R=await qt.fromTensor(C.mul_(255).to("uint8")).resize(v[1],v[0]);S.push({label:null,score:null,mask:R})}}return S}},R6=class extends fL{async _call(e,t={}){let r=await pr(e),a=await super._call(e,t),n=r.map((s,i)=>{let H=s.clone();return H.putAlpha(a[i].mask),H});return Array.isArray(e)?n:n[0]}},k6=class extends Ye{async _call(e,t,{hypothesis_template:r="This is a photo of {}"}={}){let a=Array.isArray(e),n=await pr(e),s=t.map(l=>r.replace("{}",l)),i=this.tokenizer(s,{padding:this.model.config.model_type==="siglip"?"max_length":!0,truncation:!0}),{pixel_values:H}=await this.processor(n),o=await this.model({...i,pixel_values:H}),_=this.model.config.model_type==="siglip"?l=>l.sigmoid().data:l=>St(l.data),c=[];for(let l of o.logits_per_image){let h=[..._(l)].map(($,m)=>({score:$,label:t[m]}));h.sort(($,m)=>m.score-$.score),c.push(h)}return a?c:c[0]}},O6=class extends Ye{async _call(e,{threshold:t=.9,percentage:r=!1}={}){let a=Array.isArray(e);if(a&&e.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");let n=await pr(e),s=r?null:n.map(d=>[d.height,d.width]),{pixel_values:i,pixel_mask:H}=await this.processor(n),o=await this.model({pixel_values:i,pixel_mask:H}),_=this.processor.image_processor.post_process_object_detection(o,t,s),{id2label:c}=this.model.config,l=_.map(d=>d.boxes.map((h,$)=>({score:d.scores[$],label:c[d.classes[$]],box:sc(h,!r)})));return a?l:l[0]}},G6=class extends Ye{async _call(e,t,{threshold:r=.1,top_k:a=null,percentage:n=!1}={}){let s=Array.isArray(e),i=await pr(e),H=this.tokenizer(t,{padding:!0,truncation:!0}),o=await this.processor(i),_=[];for(let c=0;c<i.length;++c){let l=i[c],d=n?null:[[l.height,l.width]],h=o.pixel_values[c].unsqueeze_(0),$=await this.model({...H,pixel_values:h}),m;if("post_process_grounded_object_detection"in this.processor){let S=this.processor.post_process_grounded_object_detection($,H.input_ids,{box_threshold:r,text_threshold:r,target_sizes:d})[0];m=S.boxes.map((I,T)=>({score:S.scores[T],label:S.labels[T],box:sc(I,!n)}))}else{let S=this.processor.image_processor.post_process_object_detection($,r,d,!0)[0];m=S.boxes.map((I,T)=>({score:S.scores[T],label:t[S.classes[T]],box:sc(I,!n)}))}m.sort((S,I)=>I.score-S.score),a!==null&&(m=m.slice(0,a)),_.push(m)}return s?_:_[0]}},F6=class extends Ye{_default_generation_config={max_new_tokens:256};async _call(e,t,r={}){if(Array.isArray(e)){if(e.length!==1)throw Error("Document Question Answering pipeline currently only supports a batch size of 1.");e=e[0]}let a=(await pr(e))[0],{pixel_values:n}=await this.processor(a),s=`<s_docvqa><s_question>${t}</s_question><s_answer>`,i=this.tokenizer(s,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,H=await this.model.generate({inputs:n,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:i,...this._default_generation_config,...r}),_=this.tokenizer.batch_decode(H)[0].match(/<s_answer>(.*?)<\/s_answer>/),c=null;return _&&_.length>=2&&(c=_[1].trim()),[{answer:c}]}},Z6=class extends Ye{async _call(e){let t=await pr(e),r=await this.processor(t),a=await this.model(r),n=[];for(let s of a.reconstruction){let i=s.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");n.push(qt.fromTensor(i))}return Array.isArray(e)?n:n[0]}},U6=class extends Ye{async _call(e){let t=await pr(e),r=await this.processor(t),{predicted_depth:a}=await this.model(r),n=[];for(let s=0;s<t.length;++s){let i=a[s],[H,o]=i.dims.slice(-2),[_,c]=t[s].size,l=(await _r(i.view(1,1,H,o),{size:[c,_],mode:"bilinear"})).view(c,_),d=l.min().item(),h=l.max().item(),$=l.sub(d).div_(h-d).mul_(255).to("uint8").unsqueeze(0),m=qt.fromTensor($);n.push({predicted_depth:l,depth:m})}return Array.isArray(e)?n:n[0]}},K6=class extends Ye{async _call(e,{pooling:t="none",normalize:r=!1,quantize:a=!1,precision:n="binary"}={}){let s=this.tokenizer(e,{padding:!0,truncation:!0}),i=await this.model(s),H=i.last_hidden_state??i.logits??i.token_embeddings;switch(t){case"none":break;case"mean":H=p2(H,s.attention_mask);break;case"first_token":case"cls":H=H.slice(null,0);break;case"last_token":case"eos":H=H.slice(null,-1);break;default:throw Error(`Pooling method '${t}' not supported.`)}return r&&(H=H.normalize(2,-1)),a&&(H=f2(H,n)),H}},W6=class extends Ye{async _call(e,{pool:t=null}={}){let r=await pr(e),{pixel_values:a}=await this.processor(r),n=await this.model({pixel_values:a}),s;if(t){if(!("pooler_output"in n))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");s=n.pooler_output}else s=n.last_hidden_state??n.logits??n.image_embeds;return s}},fH=Object.freeze({"text-classification":{pipeline:S6,model:Z$,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{pipeline:L6,model:n6,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{pipeline:T6,model:c6,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{pipeline:b6,model:_6,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{pipeline:v6,model:Z_,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{pipeline:D6,model:Z_,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{pipeline:ed,model:Z_,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{pipeline:C6,model:o6,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{pipeline:x6,model:Z$,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:N6,model:f6,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{pipeline:w6,model:Ts,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{pipeline:y6,model:[s6,h6],default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{pipeline:B6,model:[H6,i6],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{pipeline:M6,model:l6,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:P6,model:u6,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:fL,model:[U$,K$,W$],default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:R6,model:[U$,K$,W$],default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{pipeline:k6,model:Ts,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:O6,model:d6,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{pipeline:G6,model:p6,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{pipeline:F6,model:E6,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:Z6,model:$6,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:U6,model:m6,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{pipeline:K6,model:Ts,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{pipeline:W6,model:[I6,Ts],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),EL=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});async function $L(e){if(!e)throw new Error("modelId is required");return(await Ua(e,ws,{})).exists?[ws]:[]}async function Xs(e,{config:t=null,dtype:r=null,device:a=null,model_file_name:n=null,include_tokenizer:s=!0,include_processor:i=!0}={}){let H=await jc(e,{config:t,dtype:r,device:a,model_file_name:n});if(s){let o=await yc(e);H.push(...o)}if(i){let o=await $L(e);H.push(...o)}return H}async function zs(e,t,r={}){e=EL[e]??e;let a=fH[e];if(!a)throw new Error(`Unsupported pipeline task: ${e}. Must be one of [${Object.keys(fH).join(", ")}]`);let{type:n}=a,H=await Xs(t,{...r,include_tokenizer:n!=="audio"&&n!=="image",include_processor:n!=="text"});if(e==="text-generation"){let o=await Vc(t,r),_=Wc(o),c=n5(_);if(c){let l=Object.values(c).map(d=>`onnx/${d}`);return H.filter(d=>!d.startsWith("onnx/")||l.some(h=>d.startsWith(h)))}}return H}async function Z7(e,t=null,{progress_callback:r=null,config:a=null,cache_dir:n=null,local_files_only:s=!1,revision:i="main",device:H=null,dtype:o=null,subfolder:_="onnx",use_external_data_format:c=null,model_file_name:l=null,session_options:d={}}={}){e=EL[e]??e;let h=fH[e.split("_",1)[0]];if(!h)throw Error(`Unsupported pipeline: ${e}. Must be one of [${Object.keys(fH)}]`);t||(t=h.default.model,he.info(`No model specified. Using default model: "${t}".`),!o&&h.default.dtype&&(o=h.default.dtype));let $=await zs(e,t,{device:H,dtype:o}),m={};r&&(await Promise.all($.map(async z=>Ua(t,z)))).forEach((z,X)=>{z.exists&&(m[$[X]]={loaded:0,total:z.size??0})});let S={progress_callback:r?new U_(r,m):void 0,config:a,cache_dir:n,local_files_only:s,revision:i,device:H,dtype:o,subfolder:_,use_external_data_format:c,model_file_name:l,session_options:d},I=$.includes("tokenizer.json"),T=$.includes("preprocessor_config.json"),D=h.model,v;if(Array.isArray(D)){let j=a??await ys.from_pretrained(t,S),{model_type:z}=j,X=D.find(q=>q.supports(z));if(!X)throw Error(`Unsupported model type "${z}" for task "${e}". None of the candidate model classes support this type.`);v=X.from_pretrained(t,{...S,config:j})}else v=D.from_pretrained(t,S);let[C,R,A]=await Promise.all([I?we.from_pretrained(t,S):null,T?w3.from_pretrained(t,S):null,v]),U={task:e,model:A};C&&(U.tokenizer=C),R&&(U.processor=R),pa(r,{status:"ready",task:e,model:t});let Z=h.pipeline;return new Z(U)}var V6=e=>e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,j6=class{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}},q$=me.IS_PROCESS_AVAILABLE?e=>process.stdout.write(e):e=>console.log(e),q6=class extends j6{constructor(e,{skip_prompt:t=!1,callback_function:r=null,token_callback_function:a=null,skip_special_tokens:n=!0,decode_kwargs:s={},...i}={}){super(),this.tokenizer=e,this.skip_prompt=t,this.callback_function=r??q$,this.token_callback_function=a,this.decode_kwargs={skip_special_tokens:n,...s,...i},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0,this.special_ids=new Set(this.tokenizer.all_special_ids.map(BigInt))}put(e){if(e.length>1)throw Error("TextStreamer only supports batch size of 1");let t=this.next_tokens_are_prompt;if(t&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let r=e[0];if(this.token_callback_function?.(r),r.length===1&&this.special_ids.has(r[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let H=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(H,!1),this.token_cache=[],this.print_len=0}let s=this.tokenizer.decode(r,this.decode_kwargs);this.on_finalized_text(s,!1);return}this.token_cache=ir(this.token_cache,r);let a=this.tokenizer.decode(this.token_cache,this.decode_kwargs),n;t||a.endsWith(`
|
|
39
|
+
`)?(n=a.slice(this.print_len),this.token_cache=[],this.print_len=0):a.length>0&&V6(a.charCodeAt(a.length-1))?(n=a.slice(this.print_len),this.print_len+=n.length):(n=a.slice(this.print_len,a.lastIndexOf(" ")+1),this.print_len+=n.length),this.on_finalized_text(n,!1)}end(){let e;this.token_cache.length>0?(e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len),this.token_cache=[],this.print_len=0):e="",this.next_tokens_are_prompt=!0,this.on_finalized_text(e,!0)}on_finalized_text(e,t){e.length>0&&this.callback_function?.(e),t&&this.callback_function===q$&&me.IS_PROCESS_AVAILABLE&&this.callback_function?.(`
|
|
40
|
+
`)}},U7=class extends q6{constructor(e,{skip_prompt:t=!1,callback_function:r=null,token_callback_function:a=null,on_chunk_start:n=null,on_chunk_end:s=null,on_finalize:i=null,time_precision:H=.02,skip_special_tokens:o=!0,decode_kwargs:_={}}={}){super(e,{skip_prompt:t,skip_special_tokens:o,callback_function:r,token_callback_function:a,decode_kwargs:_}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=n,this.on_chunk_end=s,this.on_finalize=i,this.time_precision=H,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error("WhisperTextStreamer only supports batch size of 1");let t=e[0];if(t.length===1){let r=Number(t[0])-this.timestamp_begin;if(r>=0){let a=r*this.time_precision;this.waiting_for_timestamp?this.on_chunk_end?.(a):this.on_chunk_start?.(a),this.waiting_for_timestamp=!this.waiting_for_timestamp,this.token_callback_function?.(t);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}},mL=class{constructor(e,t){this.image=e,this.timestamp=t}},X6=class{constructor(e,t){e.length>0&&e[0]instanceof qt&&(e=e.map((r,a)=>new mL(r,(a+1)/(e.length+1)*t))),this.frames=e,this.duration=t}get width(){return this.frames[0].image.width}get height(){return this.frames[0].image.height}get fps(){return this.frames.length/this.duration}};async function K7(e,{num_frames:t=null,fps:r=null}={}){if(!me.IS_BROWSER_ENV)throw new Error("`load_video` is currently only supported in browser environments.");if(t==null&&r==null)throw new Error("Either num_frames or fps must be provided.");let a=[],n=document.createElement("video");if(n.crossOrigin="anonymous",n.muted=!0,typeof e=="string")n.src=e;else if(e instanceof Blob)n.src=URL.createObjectURL(e);else if(e instanceof HTMLVideoElement)n.src=e.src;else throw new Error("Invalid URL or video element provided.");if(await new Promise(l=>n.onloadedmetadata=l),n.seekable.start(0)===n.seekable.end(0)){let d=await(await Te.fetch(n.src)).blob();n.src=URL.createObjectURL(d),await new Promise(h=>n.onloadedmetadata=h)}let s=n.duration,i,H;t!=null?(i=t,H=t===1?0:s/(t-1)):(H=1/r,i=Math.floor(s/H));let o=[];for(let l=0;l<i;++l)o.push(t===1?s/2:l*H);let _=document.createElement("canvas");_.width=n.videoWidth,_.height=n.videoHeight;let c=_.getContext("2d",{willReadFrequently:!0});for(let l of o){n.currentTime=l,await new Promise(m=>{n.onseeked=m}),c.drawImage(n,0,0,_.width,_.height);let d=c.getImageData(0,0,_.width,_.height),h=new qt(d.data,_.width,_.height,4),$=new mL(h,l);a.push($)}return n.remove(),new X6(a,s)}async function WH(e,t,r={}){let a=await Mn(r?.cache_dir);if(!a)return{allCached:!1,files:t.map(i=>({file:i,cached:!1}))};let n=await Promise.all(t.map(async s=>{let{localPath:i,proposedCacheKey:H}=Ps(e,s,r,a),o=await Rs(a,i,H);return{file:s,cached:!!o}}));return{allCached:n.every(s=>s.cached),files:n}}async function IL(e,t,r={}){let a=await Mn(r?.cache_dir);if(!a)return!1;let{localPath:n,proposedCacheKey:s}=Ps(e,t,r,a);return!!await Rs(a,n,s)}async function z6(e,t={}){if(!e)throw new Error("modelId is required");if(!await IL(e,"config.json",t))return!1;let r=await Xs(e,t);return(await WH(e,r,t)).allCached}async function J6(e,t={}){if(!e)throw new Error("modelId is required");let r=await Xs(e,t);return await WH(e,r,t)}async function Q6(e,t,r={}){if(!e)throw new Error("task is required");if(!t)throw new Error("modelId is required");if(!await IL(t,"config.json",r))return!1;let a=await zs(e,t,r);return(await WH(t,a,r)).allCached}async function Y6(e,t,r={}){if(!e)throw new Error("task is required");if(!t)throw new Error("modelId is required");let a=await zs(e,t,r);return await WH(t,a,r)}async function SL(e,t,r={}){let a=await Mn(r?.cache_dir);if(!a)return{filesDeleted:0,filesCached:0,files:t.map(s=>({file:s,deleted:!1,wasCached:!1}))};if(!a.delete)throw new Error("Cache does not support delete operation");let n=await Promise.all(t.map(async s=>{let{localPath:i,proposedCacheKey:H}=Ps(e,s,r,a),_=!!await Rs(a,i,H),c=!1;if(_){let l=await a.delete(H),d=!l&&H!==i?await a.delete(i):!1;c=l||d}return{file:s,deleted:c,wasCached:_}}));return{filesDeleted:n.filter(s=>s.deleted).length,filesCached:n.filter(s=>s.wasCached).length,files:n}}async function eF(e,t={}){if(!e)throw new Error("modelId is required");let r=await Xs(e,t);return await SL(e,r,t)}async function tF(e,t,r={}){if(!e)throw new Error("task is required");if(!t)throw new Error("modelId is required");let a=await zs(e,t,r);return await SL(t,a,r)}var rF=Object.keys(xs);async function aF(e,{config:t=null,model_file_name:r=null,revision:a="main",cache_dir:n=null,local_files_only:s=!1}={}){t=await Vc(e,{config:t,cache_dir:n,local_files_only:s,revision:a});let i="onnx",H=Wc(t),{sessions:o}=pI(H,t,{model_file_name:r}),_=Object.values(o),c={revision:a,cache_dir:n,local_files_only:s};return(await Promise.all(rF.map(async d=>{let h=xs[d]??"",$=await Promise.all(_.map(async m=>{let S=`${i}/${m}${h}.onnx`;return(await Ua(e,S,c)).exists}));return{dtype:d,available:$.every(Boolean)}}))).filter(d=>d.available).map(d=>d.dtype)}var W7=class{static async get_files(e,t={}){return Xs(e,t)}static async get_pipeline_files(e,t,r={}){return zs(e,t,r)}static async get_model_files(e,t={}){return jc(e,t)}static async get_tokenizer_files(e){return yc(e)}static async get_processor_files(e){return $L(e)}static async get_available_dtypes(e,t={}){return aF(e,t)}static async is_cached(e,t={}){return z6(e,t)}static async is_cached_files(e,t={}){return J6(e,t)}static async is_pipeline_cached(e,t,r={}){return Q6(e,t,r)}static async is_pipeline_cached_files(e,t,r={}){return Y6(e,t,r)}static async get_file_metadata(e,t,r={}){return Ua(e,t,r)}static async clear_cache(e,t={}){return eF(e,t)}static async clear_pipeline_cache(e,t,r={}){return tF(e,t,r)}};export{NM as ASTFeatureExtractor,A5 as ASTForAudioClassification,L5 as ASTModel,tl as ASTPreTrainedModel,m5 as AfmoeForCausalLM,$5 as AfmoeModel,Yc as AfmoePreTrainedModel,h5 as AlbertForMaskedLM,p5 as AlbertForQuestionAnswering,d5 as AlbertForSequenceClassification,u5 as AlbertModel,Gs as AlbertPreTrainedModel,S2 as AlbertTokenizer,E5 as ApertusForCausalLM,f5 as ApertusModel,Qc as ApertusPreTrainedModel,S5 as ArceeForCausalLM,I5 as ArceeModel,el as ArceePreTrainedModel,N6 as AudioClassificationPipeline,ys as AutoConfig,tr as AutoFeatureExtractor,vt as AutoImageProcessor,Ts as AutoModel,f6 as AutoModelForAudioClassification,P7 as AutoModelForAudioFrameClassification,F7 as AutoModelForAudioTextToText,h6 as AutoModelForCTC,o6 as AutoModelForCausalLM,m6 as AutoModelForDepthEstimation,E6 as AutoModelForDocumentQuestionAnswering,u6 as AutoModelForImageClassification,I6 as AutoModelForImageFeatureExtraction,R7 as AutoModelForImageMatting,U$ as AutoModelForImageSegmentation,G7 as AutoModelForImageTextToText,$6 as AutoModelForImageToImage,B7 as AutoModelForMaskGeneration,_6 as AutoModelForMaskedLM,k7 as AutoModelForNormalEstimation,d6 as AutoModelForObjectDetection,O7 as AutoModelForPoseEstimation,c6 as AutoModelForQuestionAnswering,K$ as AutoModelForSemanticSegmentation,Z_ as AutoModelForSeq2SeqLM,Z$ as AutoModelForSequenceClassification,s6 as AutoModelForSpeechSeq2Seq,i6 as AutoModelForTextToSpectrogram,H6 as AutoModelForTextToWaveform,n6 as AutoModelForTokenClassification,W$ as AutoModelForUniversalSegmentation,l6 as AutoModelForVision2Seq,M7 as AutoModelForXVector,p6 as AutoModelForZeroShotObjectDetection,w3 as AutoProcessor,we as AutoTokenizer,y6 as AutomaticSpeechRecognitionPipeline,R6 as BackgroundRemovalPipeline,T5 as BartForConditionalGeneration,b5 as BartForSequenceClassification,g5 as BartModel,vH as BartPretrainedModel,L2 as BartTokenizer,j6 as BaseStreamer,YM as BeitFeatureExtractor,D5 as BeitForImageClassification,v5 as BeitModel,rl as BeitPreTrainedModel,x5 as BertForMaskedLM,y5 as BertForQuestionAnswering,N5 as BertForSequenceClassification,w5 as BertForTokenClassification,C5 as BertModel,kn as BertPreTrainedModel,A2 as BertTokenizer,eP as BitImageProcessor,M5 as BlenderbotForConditionalGeneration,B5 as BlenderbotModel,al as BlenderbotPreTrainedModel,R5 as BlenderbotSmallForConditionalGeneration,P5 as BlenderbotSmallModel,nl as BlenderbotSmallPreTrainedModel,g2 as BlenderbotSmallTokenizer,T2 as BlenderbotTokenizer,O5 as BloomForCausalLM,k5 as BloomModel,sl as BloomPreTrainedModel,b2 as BloomTokenizer,j5 as CHMv2ForDepthEstimation,rP as CHMv2ImageProcessor,gI as CHMv2PreTrainedModel,aP as CLIPFeatureExtractor,Zm as CLIPImageProcessor,X5 as CLIPModel,ja as CLIPPreTrainedModel,eR as CLIPSegForImageSegmentation,Y5 as CLIPSegModel,il as CLIPSegPreTrainedModel,z5 as CLIPTextModel,vI as CLIPTextModelWithProjection,D2 as CLIPTokenizer,J5 as CLIPVisionModel,Q5 as CLIPVisionModelWithProjection,F5 as CamembertForMaskedLM,K5 as CamembertForQuestionAnswering,Z5 as CamembertForSequenceClassification,U5 as CamembertForTokenClassification,G5 as CamembertModel,On as CamembertPreTrainedModel,v2 as CamembertTokenizer,wM as ChatterboxFeatureExtractor,LI as ChatterboxModel,SI as ChatterboxPreTrainedModel,WM as ChatterboxProcessor,tP as ChineseCLIPFeatureExtractor,V5 as ChineseCLIPModel,AI as ChineseCLIPPreTrainedModel,bI as ClapAudioModelWithProjection,yM as ClapFeatureExtractor,q5 as ClapModel,DH as ClapPreTrainedModel,TI as ClapTextModelWithProjection,z3 as ClassifierFreeGuidanceLogitsProcessor,rR as CodeGenForCausalLM,tR as CodeGenModel,Hl as CodeGenPreTrainedModel,x2 as CodeGenTokenizer,C2 as CodeLlamaTokenizer,iR as Cohere2ForCausalLM,sR as Cohere2Model,_l as Cohere2PreTrainedModel,MM as CohereAsrFeatureExtractor,oR as CohereAsrForConditionalGeneration,HR as CohereAsrModel,cl as CohereAsrPreTrainedModel,jM as CohereAsrProcessor,w2 as CohereAsrTokenizer,nR as CohereForCausalLM,aR as CohereModel,ol as CoherePreTrainedModel,N2 as CohereTokenizer,cR as ConvBertForMaskedLM,dR as ConvBertForQuestionAnswering,lR as ConvBertForSequenceClassification,uR as ConvBertForTokenClassification,_R as ConvBertModel,Gn as ConvBertPreTrainedModel,y2 as ConvBertTokenizer,nP as ConvNextFeatureExtractor,hR as ConvNextForImageClassification,Um as ConvNextImageProcessor,pR as ConvNextModel,ll as ConvNextPreTrainedModel,ER as ConvNextV2ForImageClassification,fR as ConvNextV2Model,ul as ConvNextV2PreTrainedModel,SR as DFineForObjectDetection,IR as DFineModel,pl as DFinePreTrainedModel,jR as DINOv3ConvNextModel,PI as DINOv3ConvNextPreTrainedModel,HP as DINOv3ViTImageProcessor,qR as DINOv3ViTModel,RI as DINOv3ViTPreTrainedModel,_P as DPTFeatureExtractor,rk as DPTForDepthEstimation,Vm as DPTImageProcessor,tk as DPTModel,Il as DPTPreTrainedModel,NI as DacDecoderModel,CI as DacDecoderOutput,xI as DacEncoderModel,DI as DacEncoderOutput,ym as DacFeatureExtractor,LR as DacModel,CH as DacPreTrainedModel,gR as DebertaForMaskedLM,vR as DebertaForQuestionAnswering,TR as DebertaForSequenceClassification,bR as DebertaForTokenClassification,AR as DebertaModel,Fn as DebertaPreTrainedModel,M2 as DebertaTokenizer,NR as DebertaV2ForMaskedLM,BR as DebertaV2ForQuestionAnswering,wR as DebertaV2ForSequenceClassification,yR as DebertaV2ForTokenClassification,xR as DebertaV2Model,Zn as DebertaV2PreTrainedModel,B2 as DebertaV2Tokenizer,MR as DecisionTransformerModel,wI as DecisionTransformerPreTrainedModel,CR as DeepseekV3ForCausalLM,DR as DeepseekV3Model,hl as DeepseekV3PreTrainedModel,sP as DeiTFeatureExtractor,RR as DeiTForImageClassification,Km as DeiTImageProcessor,PR as DeiTModel,fl as DeiTPreTrainedModel,kR as DepthAnythingForDepthEstimation,yI as DepthAnythingPreTrainedModel,U6 as DepthEstimationPipeline,OR as DepthProForDepthEstimation,BI as DepthProPreTrainedModel,iP as DetrFeatureExtractor,FR as DetrForObjectDetection,ZR as DetrForSegmentation,Wm as DetrImageProcessor,GR as DetrModel,El as DetrObjectDetectionOutput,xH as DetrPreTrainedModel,MI as DetrSegmentationOutput,KR as Dinov2ForImageClassification,UR as Dinov2Model,$l as Dinov2PreTrainedModel,VR as Dinov2WithRegistersForImageClassification,WR as Dinov2WithRegistersModel,ml as Dinov2WithRegistersPreTrainedModel,YR as DistilBertForMaskedLM,QR as DistilBertForQuestionAnswering,zR as DistilBertForSequenceClassification,JR as DistilBertForTokenClassification,XR as DistilBertModel,Un as DistilBertPreTrainedModel,P2 as DistilBertTokenizer,F6 as DocumentQuestionAnsweringPipeline,oP as DonutFeatureExtractor,Oc as DonutImageProcessor,ek as DonutSwinModel,kI as DonutSwinPreTrainedModel,Kc as DynamicCache,d9 as EdgeTamModel,nk as EfficientNetForImageClassification,cP as EfficientNetImageProcessor,ak as EfficientNetModel,Sl as EfficientNetPreTrainedModel,ik as ElectraForMaskedLM,_k as ElectraForQuestionAnswering,Hk as ElectraForSequenceClassification,ok as ElectraForTokenClassification,sk as ElectraModel,Kn as ElectraPreTrainedModel,R2 as ElectraTokenizer,Nm as EncodecFeatureExtractor,Y3 as EosTokenCriteria,lk as Ernie4_5ForCausalLM,ck as Ernie4_5Model,Ll as Ernie4_5PretrainedModel,dk as EsmForMaskedLM,pk as EsmForSequenceClassification,hk as EsmForTokenClassification,uk as EsmModel,Zs as EsmPreTrainedModel,k2 as EsmTokenizer,Ek as EuroBertForMaskedLM,$k as EuroBertForSequenceClassification,mk as EuroBertForTokenClassification,fk as EuroBertModel,Us as EuroBertPreTrainedModel,Sk as ExaoneForCausalLM,Ik as ExaoneModel,Al as ExaonePreTrainedModel,Ak as FalconForCausalLM,Tk as FalconH1ForCausalLM,gk as FalconH1Model,Tl as FalconH1PreTrainedModel,Lk as FalconModel,gl as FalconPreTrainedModel,O2 as FalconTokenizer,vk as FastViTForImageClassification,bk as FastViTModel,bl as FastViTPreTrainedModel,K6 as FeatureExtractionPipeline,bt as FeatureExtractor,b6 as FillMaskPipeline,Dk as Florence2ForConditionalGeneration,OI as Florence2PreTrainedModel,qP as Florence2Processor,F3 as ForcedBOSTokenLogitsProcessor,Z3 as ForcedEOSTokenLogitsProcessor,hP as GLPNFeatureExtractor,Wk as GLPNForDepthEstimation,Kk as GLPNModel,Bl as GLPNPreTrainedModel,t4 as GPT2LMHeadModel,e4 as GPT2Model,Ol as GPT2PreTrainedModel,Z2 as GPT2Tokenizer,jk as GPTBigCodeForCausalLM,Vk as GPTBigCodeModel,Ml as GPTBigCodePreTrainedModel,a4 as GPTJForCausalLM,r4 as GPTJModel,Gl as GPTJPreTrainedModel,Xk as GPTNeoForCausalLM,qk as GPTNeoModel,Pl as GPTNeoPreTrainedModel,Jk as GPTNeoXForCausalLM,zk as GPTNeoXModel,Rl as GPTNeoXPreTrainedModel,F2 as GPTNeoXTokenizer,wk as Gemma2ForCausalLM,Nk as Gemma2Model,Dl as Gemma2PreTrainedModel,Pk as Gemma3ForCausalLM,ZI as Gemma3ForConditionalGeneration,lP as Gemma3ImageProcessor,Mk as Gemma3Model,FI as Gemma3PreTrainedModel,XP as Gemma3Processor,Bm as Gemma3nAudioFeatureExtractor,Rk as Gemma3nForCausalLM,NH as Gemma3nForConditionalGeneration,UI as Gemma3nPreTrainedModel,zP as Gemma3nProcessor,Mm as Gemma4AudioFeatureExtractor,kk as Gemma4ForCausalLM,Cl as Gemma4ForConditionalGeneration,jm as Gemma4ImageProcessor,JP as Gemma4Processor,xk as GemmaForCausalLM,Ck as GemmaModel,vl as GemmaPreTrainedModel,G2 as GemmaTokenizer,pP as Glm46VImageProcessor,QP as Glm46VProcessor,Gk as GlmForCausalLM,Ok as GlmModel,Zk as GlmMoeDsaForCausalLM,Fk as GlmMoeDsaModel,Nl as GlmMoeDsaPreTrainedModel,Uk as GlmOcrForConditionalGeneration,xl as GlmPreTrainedModel,Yk as GptOssForCausalLM,Qk as GptOssModel,kl as GptOssPreTrainedModel,s4 as GraniteForCausalLM,n4 as GraniteModel,H4 as GraniteMoeHybridForCausalLM,i4 as GraniteMoeHybridModel,Zl as GraniteMoeHybridPreTrainedModel,Fl as GranitePreTrainedModel,PM as GraniteSpeechFeatureExtractor,o4 as GraniteSpeechForConditionalGeneration,YP as GraniteSpeechProcessor,_4 as GroundingDinoForObjectDetection,fP as GroundingDinoImageProcessor,qI as GroundingDinoPreTrainedModel,t3 as GroundingDinoProcessor,c4 as GroupViTModel,XI as GroupViTPreTrainedModel,u4 as HeliumForCausalLM,l4 as HeliumModel,Kl as HeliumPreTrainedModel,U2 as HerbertTokenizer,p4 as HieraForImageClassification,d4 as HieraModel,Wl as HieraPreTrainedModel,S4 as HubertForCTC,L4 as HubertForSequenceClassification,I4 as HubertModel,m4 as HubertPreTrainedModel,g4 as HunYuanDenseV1ForCausalLM,A4 as HunYuanDenseV1Model,Vl as HunYuanDenseV1PreTrainedModel,b4 as IJepaForImageClassification,T4 as IJepaModel,jl as IJepaPreTrainedModel,zI as Idefics3ForConditionalGeneration,w$ as Idefics3ImageProcessor,B$ as Idefics3Processor,P6 as ImageClassificationPipeline,W6 as ImageFeatureExtractionPipeline,fe as ImageFeatureExtractor,fe as ImageProcessor,fL as ImageSegmentationPipeline,Z6 as ImageToImagePipeline,M6 as ImageToTextPipeline,y7 as InterruptableStoppingCriteria,D4 as JAISLMHeadModel,v4 as JAISModel,ql as JAISPreTrainedModel,$P as JinaCLIPImageProcessor,C4 as JinaCLIPModel,wH as JinaCLIPPreTrainedModel,i3 as JinaCLIPProcessor,JI as JinaCLIPTextModel,x4 as JinaCLIPVisionModel,w4 as Lfm2ForCausalLM,N4 as Lfm2Model,M4 as Lfm2MoeForCausalLM,B4 as Lfm2MoeModel,zl as Lfm2MoePreTrainedModel,Xl as Lfm2PreTrainedModel,P4 as Lfm2VlForConditionalGeneration,AP as Lfm2VlImageProcessor,H3 as Lfm2VlProcessor,y4 as LightOnOcrForConditionalGeneration,BG as LiteWhisperForConditionalGeneration,O4 as Llama4ForCausalLM,QI as Llama4PreTrainedModel,k4 as LlamaForCausalLM,R4 as LlamaModel,Jl as LlamaPreTrainedModel,K2 as LlamaTokenizer,Jr as LlavaForConditionalGeneration,Jr as LlavaOnevisionForConditionalGeneration,gP as LlavaOnevisionImageProcessor,GI as LlavaPreTrainedModel,o3 as LlavaProcessor,Bk as LlavaQwen2ForCausalLM,sr as LogLevel,dr as LogitsProcessor,rc as LogitsProcessorList,Uc as LogitsWarper,F4 as LongT5ForConditionalGeneration,G4 as LongT5Model,Ql as LongT5PreTrainedModel,U4 as M2M100ForConditionalGeneration,Z4 as M2M100Model,Yl as M2M100PreTrainedModel,W2 as M2M100Tokenizer,j2 as MBart50Tokenizer,J4 as MBartForCausalLM,X4 as MBartForConditionalGeneration,z4 as MBartForSequenceClassification,q4 as MBartModel,Ks as MBartPreTrainedModel,gm as MBartTokenizer,RO as MPNetForMaskedLM,GO as MPNetForQuestionAnswering,kO as MPNetForSequenceClassification,OO as MPNetForTokenClassification,PO as MPNetModel,Wn as MPNetPreTrainedModel,z2 as MPNetTokenizer,KO as MT5ForConditionalGeneration,UO as MT5Model,cu as MT5PreTrainedModel,W4 as MarianMTModel,K4 as MarianModel,eu as MarianPreTrainedModel,V2 as MarianTokenizer,bP as Mask2FormerImageProcessor,TP as MaskFormerFeatureExtractor,j4 as MaskFormerForInstanceSegmentation,Gc as MaskFormerImageProcessor,V4 as MaskFormerModel,tu as MaskFormerPreTrainedModel,Q3 as MaxLengthCriteria,Q4 as Metric3DForDepthEstimation,YI as Metric3DPreTrainedModel,Y4 as Metric3Dv2ForDepthEstimation,eS as Metric3Dv2PreTrainedModel,eO as MgpstrForSceneTextRecognition,tS as MgpstrModelOutput,rS as MgpstrPreTrainedModel,_3 as MgpstrProcessor,q2 as MgpstrTokenizer,iS as MimiDecoderModel,nS as MimiDecoderOutput,sS as MimiEncoderModel,aS as MimiEncoderOutput,tO as MimiModel,yH as MimiPreTrainedModel,j3 as MinLengthLogitsProcessor,q3 as MinNewTokensLengthLogitsProcessor,sO as Mistral4ForCausalLM,nO as Mistral4Model,au as Mistral4PreTrainedModel,aO as MistralForCausalLM,rO as MistralModel,ru as MistralPreTrainedModel,HO as MobileBertForMaskedLM,_O as MobileBertForQuestionAnswering,oO as MobileBertForSequenceClassification,iO as MobileBertModel,Ws as MobileBertPreTrainedModel,X2 as MobileBertTokenizer,lO as MobileLLMForCausalLM,cO as MobileLLMModel,nu as MobileLLMPreTrainedModel,vP as MobileNetV1FeatureExtractor,dO as MobileNetV1ForImageClassification,pO as MobileNetV1ForSemanticSegmentation,Xm as MobileNetV1ImageProcessor,uO as MobileNetV1Model,BH as MobileNetV1PreTrainedModel,DP as MobileNetV2FeatureExtractor,fO as MobileNetV2ForImageClassification,EO as MobileNetV2ForSemanticSegmentation,zm as MobileNetV2ImageProcessor,hO as MobileNetV2Model,MH as MobileNetV2PreTrainedModel,CP as MobileNetV3FeatureExtractor,mO as MobileNetV3ForImageClassification,IO as MobileNetV3ForSemanticSegmentation,Jm as MobileNetV3ImageProcessor,$O as MobileNetV3Model,PH as MobileNetV3PreTrainedModel,xP as MobileNetV4FeatureExtractor,LO as MobileNetV4ForImageClassification,AO as MobileNetV4ForSemanticSegmentation,Qm as MobileNetV4ImageProcessor,SO as MobileNetV4Model,RH as MobileNetV4PreTrainedModel,NP as MobileViTFeatureExtractor,TO as MobileViTForImageClassification,Ym as MobileViTImageProcessor,gO as MobileViTModel,su as MobileViTPreTrainedModel,vO as MobileViTV2ForImageClassification,bO as MobileViTV2Model,iu as MobileViTV2PreTrainedModel,W7 as ModelRegistry,yO as ModernBertDecoderForCausalLM,wO as ModernBertDecoderModel,Hu as ModernBertDecoderPreTrainedModel,CO as ModernBertForMaskedLM,xO as ModernBertForSequenceClassification,NO as ModernBertForTokenClassification,DO as ModernBertModel,Vs as ModernBertPreTrainedModel,yk as Moondream1ForConditionalGeneration,RM as MoonshineFeatureExtractor,MO as MoonshineForConditionalGeneration,BO as MoonshineModel,ou as MoonshinePreTrainedModel,c3 as MoonshineProcessor,ZO as MptForCausalLM,FO as MptModel,_u as MptPreTrainedModel,WO as MultiModalityCausalLM,HS as MultiModalityPreTrainedModel,jO as MusicgenForCausalLM,oS as MusicgenForConditionalGeneration,VO as MusicgenModel,lu as MusicgenPreTrainedModel,XO as NanoChatForCausalLM,qO as NanoChatModel,uu as NanoChatPreTrainedModel,JO as NemotronHForCausalLM,zO as NemotronHModel,du as NemotronHPreTrainedModel,YO as NeoBertForMaskedLM,r8 as NeoBertForQuestionAnswering,e8 as NeoBertForSequenceClassification,t8 as NeoBertForTokenClassification,QO as NeoBertModel,Vn as NeoBertPreTrainedModel,J2 as NllbTokenizer,X3 as NoBadWordsLogitsProcessor,W3 as NoRepeatNGramLogitsProcessor,a8 as NomicBertModel,_S as NomicBertPreTrainedModel,wP as NougatImageProcessor,Q2 as NougatTokenizer,E8 as OPTForCausalLM,f8 as OPTModel,Iu as OPTPreTrainedModel,O6 as ObjectDetectionPipeline,H8 as Olmo2ForCausalLM,i8 as Olmo2Model,hu as Olmo2PreTrainedModel,_8 as Olmo3ForCausalLM,o8 as Olmo3Model,fu as Olmo3PreTrainedModel,s8 as OlmoForCausalLM,l8 as OlmoHybridForCausalLM,c8 as OlmoHybridModel,Eu as OlmoHybridPreTrainedModel,n8 as OlmoModel,pu as OlmoPreTrainedModel,d8 as OpenAIPrivacyFilterForTokenClassification,u8 as OpenAIPrivacyFilterModel,$u as OpenAIPrivacyFilterPreTrainedModel,h8 as OpenELMForCausalLM,p8 as OpenELMModel,mu as OpenELMPreTrainedModel,yP as OwlViTFeatureExtractor,S8 as OwlViTForObjectDetection,Fc as OwlViTImageProcessor,I8 as OwlViTModel,Lu as OwlViTPreTrainedModel,l3 as OwlViTProcessor,m8 as Owlv2ForObjectDetection,BP as Owlv2ImageProcessor,$8 as Owlv2Model,Su as Owlv2PreTrainedModel,L8 as PaliGemmaForConditionalGeneration,d3 as PaliGemmaProcessor,wm as ParakeetFeatureExtractor,A8 as ParakeetForCTC,cS as ParakeetPreTrainedModel,T8 as PatchTSMixerForPrediction,g8 as PatchTSMixerModel,Au as PatchTSMixerPreTrainedModel,v8 as PatchTSTForPrediction,b8 as PatchTSTModel,gu as PatchTSTPreTrainedModel,N8 as Phi3ForCausalLM,x8 as Phi3Model,bu as Phi3PreTrainedModel,uS as Phi3VForCausalLM,PP as Phi3VImageProcessor,lS as Phi3VPreTrainedModel,h3 as Phi3VProcessor,C8 as PhiForCausalLM,D8 as PhiModel,Tu as PhiPreTrainedModel,RP as PixtralImageProcessor,f3 as PixtralProcessor,N as PreTrainedModel,pe as PreTrainedTokenizer,ec as PretrainedConfig,ye as Processor,y8 as PvtForImageClassification,kP as PvtImageProcessor,w8 as PvtModel,vu as PvtPreTrainedModel,Pm as PyAnnoteFeatureExtractor,M8 as PyAnnoteForAudioFrameClassification,B8 as PyAnnoteModel,Du as PyAnnotePreTrainedModel,E3 as PyAnnoteProcessor,T6 as QuestionAnsweringPipeline,R8 as Qwen2ForCausalLM,P8 as Qwen2Model,O8 as Qwen2MoeForCausalLM,k8 as Qwen2MoeModel,xu as Qwen2MoePreTrainedModel,Cu as Qwen2PreTrainedModel,Y2 as Qwen2Tokenizer,WI as Qwen2VLForCausalLM,wl as Qwen2VLForConditionalGeneration,qm as Qwen2VLImageProcessor,KI as Qwen2VLPreTrainedModel,Zc as Qwen2VLProcessor,VI as Qwen2_5_VLForCausalLM,yl as Qwen2_5_VLForConditionalGeneration,nI as Qwen2_5_VLProcessor,F8 as Qwen3ForCausalLM,G8 as Qwen3Model,U8 as Qwen3MoeForCausalLM,Z8 as Qwen3MoeModel,wu as Qwen3MoePreTrainedModel,W8 as Qwen3NextForCausalLM,K8 as Qwen3NextModel,yu as Qwen3NextPreTrainedModel,Nu as Qwen3PreTrainedModel,dS as Qwen3VLForCausalLM,Bu as Qwen3VLForConditionalGeneration,j8 as Qwen3VLMoeForCausalLM,V8 as Qwen3VLMoeForConditionalGeneration,$3 as Qwen3VLProcessor,pS as Qwen3_5ForCausalLM,Mu as Qwen3_5ForConditionalGeneration,X8 as Qwen3_5MoeForCausalLM,q8 as Qwen3_5MoeForConditionalGeneration,Y8 as RFDetrForObjectDetection,Q8 as RFDetrModel,hS as RFDetrObjectDetectionOutput,Ru as RFDetrPreTrainedModel,mR as RTDetrForObjectDetection,OP as RTDetrImageProcessor,$R as RTDetrModel,Fs as RTDetrObjectDetectionOutput,dl as RTDetrPreTrainedModel,l9 as RTDetrV2ForObjectDetection,c9 as RTDetrV2Model,fS as RTDetrV2ObjectDetectionOutput,ku as RTDetrV2PreTrainedModel,xM as RawAudio,qt as RawImage,X6 as RawVideo,mL as RawVideoFrame,V3 as RepetitionPenaltyLogitsProcessor,J8 as ResNetForImageClassification,z8 as ResNetModel,Pu as ResNetPreTrainedModel,i9 as RoFormerForMaskedLM,_9 as RoFormerForQuestionAnswering,H9 as RoFormerForSequenceClassification,o9 as RoFormerForTokenClassification,s9 as RoFormerModel,qn as RoFormerPreTrainedModel,tM as RoFormerTokenizer,t9 as RobertaForMaskedLM,n9 as RobertaForQuestionAnswering,r9 as RobertaForSequenceClassification,a9 as RobertaForTokenClassification,e9 as RobertaModel,jn as RobertaPreTrainedModel,eM as RobertaTokenizer,O_ as Sam2ImageProcessor,mS as Sam2ImageSegmentationOutput,Ou as Sam2Model,IS as Sam2PreTrainedModel,iI as Sam2Processor,m3 as Sam2VideoProcessor,O_ as Sam3ImageProcessor,p9 as Sam3TrackerModel,O_ as SamImageProcessor,ES as SamImageSegmentationOutput,u9 as SamModel,$S as SamPreTrainedModel,sI as SamProcessor,GP as SapiensFeatureExtractor,f9 as SapiensForDepthEstimation,E9 as SapiensForNormalEstimation,h9 as SapiensForSemanticSegmentation,eI as SapiensImageProcessor,kH as SapiensPreTrainedModel,kM as SeamlessM4TFeatureExtractor,FP as SegformerFeatureExtractor,m9 as SegformerForImageClassification,I9 as SegformerForSemanticSegmentation,tI as SegformerImageProcessor,$9 as SegformerModel,OH as SegformerPreTrainedModel,ZP as SiglipImageProcessor,S9 as SiglipModel,Gu as SiglipPreTrainedModel,SS as SiglipTextModel,rM as SiglipTokenizer,L9 as SiglipVisionModel,g9 as SmolLM3ForCausalLM,A9 as SmolLM3Model,Fu as SmolLM3PreTrainedModel,T9 as SmolVLMForConditionalGeneration,w$ as SmolVLMImageProcessor,B$ as SmolVLMProcessor,AS as SnacDecoderModel,LS as SnacEncoderModel,OM as SnacFeatureExtractor,b9 as SnacModel,GH as SnacPreTrainedModel,D9 as SolarOpenForCausalLM,v9 as SolarOpenModel,Zu as SolarOpenPreTrainedModel,GM as SpeechT5FeatureExtractor,x9 as SpeechT5ForSpeechToText,N9 as SpeechT5ForTextToSpeech,w9 as SpeechT5HifiGan,C9 as SpeechT5Model,FH as SpeechT5PreTrainedModel,I3 as SpeechT5Processor,aM as SpeechT5Tokenizer,B9 as SqueezeBertForMaskedLM,P9 as SqueezeBertForQuestionAnswering,M9 as SqueezeBertForSequenceClassification,y9 as SqueezeBertModel,js as SqueezeBertPreTrainedModel,nM as SqueezeBertTokenizer,k9 as StableLmForCausalLM,R9 as StableLmModel,Uu as StableLmPreTrainedModel,G9 as Starcoder2ForCausalLM,O9 as Starcoder2Model,Ku as Starcoder2PreTrainedModel,Os as StoppingCriteria,uI as StoppingCriteriaList,F9 as StyleTextToSpeech2Model,gS as StyleTextToSpeech2PreTrainedModel,v6 as SummarizationPipeline,bS as SupertonicForConditionalGeneration,TS as SupertonicPreTrainedModel,cI as SuppressTokensAtBeginLogitsProcessor,U3 as SuppressTokensLogitsProcessor,V9 as Swin2SRForImageSuperResolution,UP as Swin2SRImageProcessor,W9 as Swin2SRModel,Wu as Swin2SRPreTrainedModel,U9 as SwinForImageClassification,K9 as SwinForSemanticSegmentation,Z9 as SwinModel,ZH as SwinPreTrainedModel,q9 as T5ForConditionalGeneration,j9 as T5Model,Vu as T5PreTrainedModel,sM as T5Tokenizer,z9 as TableTransformerForObjectDetection,X9 as TableTransformerModel,vS as TableTransformerObjectDetectionOutput,ju as TableTransformerPreTrainedModel,J3 as TemperatureLogitsWarper,K as Tensor,ed as Text2TextGenerationPipeline,S6 as TextClassificationPipeline,C6 as TextGenerationPipeline,q6 as TextStreamer,B6 as TextToAudioPipeline,L6 as TokenClassificationPipeline,pe as TokenizersBackend,w7 as TopKLogitsWarper,N7 as TopPLogitsWarper,J9 as TrOCRForCausalLM,DS as TrOCRPreTrainedModel,D6 as TranslationPipeline,Ul as UltravoxModel,jI as UltravoxPreTrainedModel,S3 as UltravoxProcessor,Y9 as UniSpeechForCTC,eG as UniSpeechForSequenceClassification,Q9 as UniSpeechModel,UH as UniSpeechPreTrainedModel,nG as UniSpeechSatForAudioFrameClassification,rG as UniSpeechSatForCTC,aG as UniSpeechSatForSequenceClassification,tG as UniSpeechSatModel,qs as UniSpeechSatPreTrainedModel,s3 as VLChatProcessor,EP as VLMImageProcessor,iG as VaultGemmaForCausalLM,sG as VaultGemmaModel,qu as VaultGemmaPreTrainedModel,KP as ViTFeatureExtractor,_G as ViTForImageClassification,rI as ViTImageProcessor,cG as ViTMAEModel,CS as ViTMAEPreTrainedModel,uG as ViTMSNForImageClassification,lG as ViTMSNModel,zu as ViTMSNPreTrainedModel,oG as ViTModel,Xu as ViTPreTrainedModel,HG as VisionEncoderDecoderModel,dG as VitMatteForImageMatting,WP as VitMatteImageProcessor,xS as VitMattePreTrainedModel,pG as VitPoseForPoseEstimation,VP as VitPoseImageProcessor,NS as VitPosePreTrainedModel,hG as VitsModel,wS as VitsModelOutput,yS as VitsPreTrainedModel,HM as VitsTokenizer,fG as VoxtralForConditionalGeneration,T3 as VoxtralProcessor,UM as VoxtralRealtimeFeatureExtractor,MS as VoxtralRealtimeForConditionalGeneration,BS as VoxtralRealtimePreTrainedModel,D3 as VoxtralRealtimeProcessor,gG as Wav2Vec2BertForCTC,TG as Wav2Vec2BertForSequenceClassification,AG as Wav2Vec2BertModel,KH as Wav2Vec2BertPreTrainedModel,oM as Wav2Vec2CTCTokenizer,FM as Wav2Vec2FeatureExtractor,$4 as Wav2Vec2ForAudioFrameClassification,f4 as Wav2Vec2ForCTC,E4 as Wav2Vec2ForSequenceClassification,h4 as Wav2Vec2Model,$a as Wav2Vec2PreTrainedModel,C3 as Wav2Vec2Processor,x3 as Wav2Vec2ProcessorWithLM,xG as WavLMForAudioFrameClassification,vG as WavLMForCTC,DG as WavLMForSequenceClassification,CG as WavLMForXVector,bG as WavLMModel,Xn as WavLMPreTrainedModel,ZM as WeSpeakerFeatureExtractor,NG as WeSpeakerResNetModel,RS as WeSpeakerResNetPreTrainedModel,KM as WhisperFeatureExtractor,kS as WhisperForConditionalGeneration,yG as WhisperModel,Ju as WhisperPreTrainedModel,N3 as WhisperProcessor,U7 as WhisperTextStreamer,K3 as WhisperTimeStampLogitsProcessor,dM as WhisperTokenizer,OG as XLMForQuestionAnswering,RG as XLMForSequenceClassification,kG as XLMForTokenClassification,MG as XLMModel,zn as XLMPreTrainedModel,FG as XLMRobertaForMaskedLM,KG as XLMRobertaForQuestionAnswering,ZG as XLMRobertaForSequenceClassification,UG as XLMRobertaForTokenClassification,GG as XLMRobertaModel,Jn as XLMRobertaPreTrainedModel,pM as XLMRobertaTokenizer,hM as XLMTokenizer,PG as XLMWithLMHeadModel,PS as XVectorOutput,jP as YolosFeatureExtractor,VG as YolosForObjectDetection,aI as YolosImageProcessor,WG as YolosModel,OS as YolosObjectDetectionOutput,Qu as YolosPreTrainedModel,qG as YoutuForCausalLM,jG as YoutuModel,Yu as YoutuPreTrainedModel,w6 as ZeroShotAudioClassificationPipeline,x6 as ZeroShotClassificationPipeline,k6 as ZeroShotImageClassificationPipeline,G6 as ZeroShotObjectDetectionPipeline,je as cat,L7 as cos_sim,mB as dot,Te as env,Tt as full,Q_ as full_like,fm as interpolate,_r as interpolate_4d,T7 as layer_norm,mM as load_audio,x7 as load_image,K7 as load_video,$B as log_softmax,d2 as matmul,Nc as mean,p2 as mean_pooling,Gt as ones,mm as ones_like,u2 as permute,Z7 as pipeline,f2 as quantize_embeddings,b7 as rand,h2 as randn,LH as random,IM as read_audio,g7 as rfft,Em as slice,St as softmax,Xr as stack,$m as std_mean,Rn as topk,Im as zeros,Sm as zeros_like};
|
|
41
|
+
/*! Bundled license information:
|
|
42
|
+
|
|
43
|
+
sharp/lib/is.js:
|
|
44
|
+
sharp/lib/libvips.js:
|
|
45
|
+
sharp/lib/sharp.js:
|
|
46
|
+
sharp/lib/constructor.js:
|
|
47
|
+
sharp/lib/input.js:
|
|
48
|
+
sharp/lib/resize.js:
|
|
49
|
+
sharp/lib/composite.js:
|
|
50
|
+
sharp/lib/operation.js:
|
|
51
|
+
sharp/lib/colour.js:
|
|
52
|
+
sharp/lib/channel.js:
|
|
53
|
+
sharp/lib/output.js:
|
|
54
|
+
sharp/lib/utility.js:
|
|
55
|
+
sharp/lib/index.js:
|
|
56
|
+
(*!
|
|
57
|
+
Copyright 2013 Lovell Fuller and others.
|
|
58
|
+
SPDX-License-Identifier: Apache-2.0
|
|
59
|
+
*)
|
|
60
|
+
|
|
61
|
+
@huggingface/transformers/dist/transformers.node.mjs:
|
|
62
|
+
(*! Bundled license information:
|
|
63
|
+
|
|
64
|
+
onnxruntime-web/dist/ort.webgpu.bundle.min.mjs:
|
|
65
|
+
(*!
|
|
66
|
+
* ONNX Runtime Web v1.26.0-dev.20260416-b7804b056c
|
|
67
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
68
|
+
* Licensed under the MIT License.
|
|
69
|
+
*)
|
|
70
|
+
*)
|
|
71
|
+
*/
|