create-opentray 0.22.0 → 0.23.0
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/{bin-Dyfucd3C.mjs → bin-DDNgskyb.mjs} +195 -45
- package/dist/bin-DDNgskyb.mjs.map +1 -0
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +23 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shell/assets/index.css +1 -1
- package/dist/shell/assets/index2.js +2 -0
- package/dist/shell/assets/main.js +19 -18
- package/dist/shell/assets/ort.bundle.min.js +2763 -0
- package/dist/shell/assets/ort.bundle.min.mjs +2817 -0
- package/dist/shell/assets/ort.webgpu.bundle.min.js +2763 -0
- package/dist/shell/assets/ort.webgpu.bundle.min.mjs +2817 -0
- package/dist/webui/assets/index.css +1 -1
- package/dist/webui/assets/index2.js +2 -0
- package/dist/webui/assets/main.js +19 -18
- package/dist/webui/assets/ort.bundle.min.js +2763 -0
- package/dist/webui/assets/ort.bundle.min.mjs +2817 -0
- package/dist/webui/assets/ort.webgpu.bundle.min.js +2763 -0
- package/dist/webui/assets/ort.webgpu.bundle.min.mjs +2817 -0
- package/package.json +6 -6
- package/dist/bin-Dyfucd3C.mjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as vt}from"./terminal-pane.js";import"./index.js";var ar=Object.create,Ct=Object.defineProperty,nr=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyNames,sr=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty,ut=(t,e)=>function(){return e||(0,t[jt(t)[0]])((e={exports:{}}).exports,e),e.exports},or=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of jt(e))!ir.call(t,a)&&a!==r&&Ct(t,a,{get:()=>e[a],enumerable:!(n=nr(e,a))||n.enumerable});return t},Ve=(t,e,r)=>(r=t!=null?ar(sr(t)):{},or(!t||!t.__esModule?Ct(r,"default",{value:t,enumerable:!0}):r,t)),cr=ut({"../../node_modules/.pnpm/iota-array@1.0.0/node_modules/iota-array/iota.js"(t,e){function r(n){for(var a=new Array(n),s=0;s<n;++s)a[s]=s;return a}e.exports=r}}),ur=ut({"../../node_modules/.pnpm/is-buffer@1.1.6/node_modules/is-buffer/index.js"(t,e){e.exports=function(a){return a!=null&&(r(a)||n(a)||!!a._isBuffer)};function r(a){return!!a.constructor&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function n(a){return typeof a.readFloatLE=="function"&&typeof a.slice=="function"&&r(a.slice(0,0))}}}),Le=ut({"../../node_modules/.pnpm/ndarray@1.0.19/node_modules/ndarray/ndarray.js"(t,e){var r=cr(),n=ur(),a=typeof Float64Array<"u";function s(p,v){return p[0]-v[0]}function i(){var p=this.stride,v=new Array(p.length),l;for(l=0;l<v.length;++l)v[l]=[Math.abs(p[l]),l];v.sort(s);var O=new Array(v.length);for(l=0;l<O.length;++l)O[l]=v[l][1];return O}function o(p,v){var l=["View",v,"d",p].join("");v<0&&(l="View_Nil"+p);var O=p==="generic";if(v===-1){var g="function "+l+"(a){this.data=a;};var proto="+l+".prototype;proto.dtype='"+p+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+l+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+l+"(a){return new "+l+"(a);}",ne=new Function(g);return ne()}else if(v===0){var g="function "+l+"(a,d) {this.data = a;this.offset = d};var proto="+l+".prototype;proto.dtype='"+p+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+l+"_copy() {return new "+l+"(this.data,this.offset)};proto.pick=function "+l+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+l+"_get(){return "+(O?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+l+"_set(v){return "+(O?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+l+"(a,b,c,d){return new "+l+"(a,d)}",ne=new Function("TrivialArray",g);return ne(c[p][0])}var g=["'use strict'"],C=r(v),S=C.map(function(w){return"i"+w}),R="this.offset+"+C.map(function(w){return"this.stride["+w+"]*i"+w}).join("+"),N=C.map(function(w){return"b"+w}).join(","),I=C.map(function(w){return"c"+w}).join(",");g.push("function "+l+"(a,"+N+","+I+",d){this.data=a","this.shape=["+N+"]","this.stride=["+I+"]","this.offset=d|0}","var proto="+l+".prototype","proto.dtype='"+p+"'","proto.dimension="+v),g.push("Object.defineProperty(proto,'size',{get:function "+l+"_size(){return "+C.map(function(w){return"this.shape["+w+"]"}).join("*"),"}})"),v===1?g.push("proto.order=[0]"):(g.push("Object.defineProperty(proto,'order',{get:"),v<4?(g.push("function "+l+"_order(){"),v===2?g.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):v===3&&g.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):g.push("ORDER})")),g.push("proto.set=function "+l+"_set("+S.join(",")+",v){"),O?g.push("return this.data.set("+R+",v)}"):g.push("return this.data["+R+"]=v}"),g.push("proto.get=function "+l+"_get("+S.join(",")+"){"),O?g.push("return this.data.get("+R+")}"):g.push("return this.data["+R+"]}"),g.push("proto.index=function "+l+"_index(",S.join(),"){return "+R+"}"),g.push("proto.hi=function "+l+"_hi("+S.join(",")+"){return new "+l+"(this.data,"+C.map(function(w){return["(typeof i",w,"!=='number'||i",w,"<0)?this.shape[",w,"]:i",w,"|0"].join("")}).join(",")+","+C.map(function(w){return"this.stride["+w+"]"}).join(",")+",this.offset)}");var Ge=C.map(function(w){return"a"+w+"=this.shape["+w+"]"}),He=C.map(function(w){return"c"+w+"=this.stride["+w+"]"});g.push("proto.lo=function "+l+"_lo("+S.join(",")+"){var b=this.offset,d=0,"+Ge.join(",")+","+He.join(","));for(var T=0;T<v;++T)g.push("if(typeof i"+T+"==='number'&&i"+T+">=0){d=i"+T+"|0;b+=c"+T+"*d;a"+T+"-=d}");g.push("return new "+l+"(this.data,"+C.map(function(w){return"a"+w}).join(",")+","+C.map(function(w){return"c"+w}).join(",")+",b)}"),g.push("proto.step=function "+l+"_step("+S.join(",")+"){var "+C.map(function(w){return"a"+w+"=this.shape["+w+"]"}).join(",")+","+C.map(function(w){return"b"+w+"=this.stride["+w+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var T=0;T<v;++T)g.push("if(typeof i"+T+"==='number'){d=i"+T+"|0;if(d<0){c+=b"+T+"*(a"+T+"-1);a"+T+"=ceil(-a"+T+"/d)}else{a"+T+"=ceil(a"+T+"/d)}b"+T+"*=d}");g.push("return new "+l+"(this.data,"+C.map(function(w){return"a"+w}).join(",")+","+C.map(function(w){return"b"+w}).join(",")+",c)}");for(var Ae=new Array(v),Se=new Array(v),T=0;T<v;++T)Ae[T]="a[i"+T+"]",Se[T]="b[i"+T+"]";g.push("proto.transpose=function "+l+"_transpose("+S+"){"+S.map(function(w,rr){return w+"=("+w+"===undefined?"+rr+":"+w+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+l+"(this.data,"+Ae.join(",")+","+Se.join(",")+",this.offset)}"),g.push("proto.pick=function "+l+"_pick("+S+"){var a=[],b=[],c=this.offset");for(var T=0;T<v;++T)g.push("if(typeof i"+T+"==='number'&&i"+T+">=0){c=(c+this.stride["+T+"]*i"+T+")|0}else{a.push(this.shape["+T+"]);b.push(this.stride["+T+"])}");g.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),g.push("return function construct_"+l+"(data,shape,stride,offset){return new "+l+"(data,"+C.map(function(w){return"shape["+w+"]"}).join(",")+","+C.map(function(w){return"stride["+w+"]"}).join(",")+",offset)}");var ne=new Function("CTOR_LIST","ORDER",g.join(`
|
|
2
|
+
`));return ne(c[p],i)}function u(p){if(n(p))return"buffer";if(a)switch(Object.prototype.toString.call(p)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(p)?"array":"generic"}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function h(p,v,l,O){if(p===void 0){var I=c.array[0];return I([])}else typeof p=="number"&&(p=[p]);v===void 0&&(v=[p.length]);var g=v.length;if(l===void 0){l=new Array(g);for(var C=g-1,S=1;C>=0;--C)l[C]=S,S*=v[C]}if(O===void 0){O=0;for(var C=0;C<g;++C)l[C]<0&&(O-=(v[C]-1)*l[C])}for(var R=u(p),N=c[R];N.length<=g+1;)N.push(o(R,N.length-1));var I=N[g+1];return I(p,v,l,O)}e.exports=h}}),dr=typeof global=="object"&&global&&global.Object===Object&&global,lr=dr,fr=typeof self=="object"&&self&&self.Object===Object&&self,hr=lr||fr||Function("return this")(),dt=hr,pr=dt.Symbol,Ee=pr,Ot=Object.prototype,mr=Ot.hasOwnProperty,vr=Ot.toString,se=Ee?Ee.toStringTag:void 0;function _r(t){var e=mr.call(t,se),r=t[se];try{t[se]=void 0;var n=!0}catch{}var a=vr.call(t);return n&&(e?t[se]=r:delete t[se]),a}var gr=_r,yr=Object.prototype,br=yr.toString;function wr(t){return br.call(t)}var xr=wr,kr="[object Null]",Tr="[object Undefined]",_t=Ee?Ee.toStringTag:void 0;function Cr(t){return t==null?t===void 0?Tr:kr:_t&&_t in Object(t)?gr(t):xr(t)}var jr=Cr;function Or(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var At=Or,Ar="[object AsyncFunction]",Sr="[object Function]",Zr="[object GeneratorFunction]",Ir="[object Proxy]";function Er(t){if(!At(t))return!1;var e=jr(t);return e==Sr||e==Zr||e==Ar||e==Ir}var Rr=Er,Nr=dt["__core-js_shared__"],Je=Nr,gt=(function(){var t=/[^.]+$/.exec(Je&&Je.keys&&Je.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Pr(t){return!!gt&> in t}var Mr=Pr,$r=Function.prototype,zr=$r.toString;function Dr(t){if(t!=null){try{return zr.call(t)}catch{}try{return t+""}catch{}}return""}var Ur=Dr,Vr=/[\\^$.*+?()[\]{}|]/g,Lr=/^\[object .+?Constructor\]$/,Fr=Function.prototype,Br=Object.prototype,Wr=Fr.toString,qr=Br.hasOwnProperty,Gr=RegExp("^"+Wr.call(qr).replace(Vr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hr(t){if(!At(t)||Mr(t))return!1;var e=Rr(t)?Gr:Lr;return e.test(Ur(t))}var Jr=Hr;function Yr(t,e){return t?.[e]}var Kr=Yr;function Xr(t,e){var r=Kr(t,e);return Jr(r)?r:void 0}var St=Xr,Qr=St(Object,"create"),de=Qr;function ea(){this.__data__=de?de(null):{},this.size=0}var ta=ea;function ra(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var aa=ra,na="__lodash_hash_undefined__",sa=Object.prototype,ia=sa.hasOwnProperty;function oa(t){var e=this.__data__;if(de){var r=e[t];return r===na?void 0:r}return ia.call(e,t)?e[t]:void 0}var ca=oa,ua=Object.prototype,da=ua.hasOwnProperty;function la(t){var e=this.__data__;return de?e[t]!==void 0:da.call(e,t)}var fa=la,ha="__lodash_hash_undefined__";function pa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=de&&e===void 0?ha:e,this}var ma=pa;function te(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}te.prototype.clear=ta;te.prototype.delete=aa;te.prototype.get=ca;te.prototype.has=fa;te.prototype.set=ma;var yt=te;function va(){this.__data__=[],this.size=0}var _a=va;function ga(t,e){return t===e||t!==t&&e!==e}var ya=ga;function ba(t,e){for(var r=t.length;r--;)if(ya(t[r][0],e))return r;return-1}var Fe=ba,wa=Array.prototype,xa=wa.splice;function ka(t){var e=this.__data__,r=Fe(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():xa.call(e,r,1),--this.size,!0}var Ta=ka;function Ca(t){var e=this.__data__,r=Fe(e,t);return r<0?void 0:e[r][1]}var ja=Ca;function Oa(t){return Fe(this.__data__,t)>-1}var Aa=Oa;function Sa(t,e){var r=this.__data__,n=Fe(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Za=Sa;function re(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}re.prototype.clear=_a;re.prototype.delete=Ta;re.prototype.get=ja;re.prototype.has=Aa;re.prototype.set=Za;var Ia=re,Ea=St(dt,"Map"),Ra=Ea;function Na(){this.size=0,this.__data__={hash:new yt,map:new(Ra||Ia),string:new yt}}var Pa=Na;function Ma(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $a=Ma;function za(t,e){var r=t.__data__;return $a(e)?r[typeof e=="string"?"string":"hash"]:r.map}var Be=za;function Da(t){var e=Be(this,t).delete(t);return this.size-=e?1:0,e}var Ua=Da;function Va(t){return Be(this,t).get(t)}var La=Va;function Fa(t){return Be(this,t).has(t)}var Ba=Fa;function Wa(t,e){var r=Be(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var qa=Wa;function ae(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ae.prototype.clear=Pa;ae.prototype.delete=Ua;ae.prototype.get=La;ae.prototype.has=Ba;ae.prototype.set=qa;var Zt=ae,Ga="Expected a function";function lt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Ga);var r=function(){var n=arguments,a=e?e.apply(this,n):n[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,n);return r.cache=s.set(a,i)||s,i};return r.cache=new(lt.Cache||Zt),r}lt.Cache=Zt;var Ha=lt,ft=Ve(Le()),It=class Xe{constructor(e,r){this.type="application/octet-stream",this.params={},this.type=e,this.params=r}toString(){const e=[];for(const r in this.params){const n=this.params[r];e.push(`${r}=${n}`)}return[this.type,...e].join(";")}static create(e,r){return new Xe(e,r)}isIdentical(e){return this.type===e.type&&this.params===e.params}isEqual(e){return this.type===e.type}static fromString(e){const[r,...n]=e.split(";"),a={};for(const s of n){const[i,o]=s.split("=");a[i.trim()]=o.trim()}return new Xe(r,a)}},Ye=Ve(Le());async function Ja(t){const e=It.fromString(t.type);switch(e.type){case"image/x-alpha8":{const r=parseInt(e.params.width),n=parseInt(e.params.height);return(0,Ye.default)(new Uint8Array(await t.arrayBuffer()),[n,r,1])}case"image/x-rgba8":{const r=parseInt(e.params.width),n=parseInt(e.params.height);return(0,Ye.default)(new Uint8Array(await t.arrayBuffer()),[n,r,4])}case"application/octet-stream":case"image/png":case"image/jpeg":case"image/jpg":case"image/webp":{const r=await createImageBitmap(t),n=Xa(r);return(0,Ye.default)(new Uint8Array(n.data),[n.height,n.width,4])}default:throw new Error(`Invalid format: ${e.type} with params: ${e.params}`)}}async function We(t,e=.8,r="image/png"){const[n,a,s]=t.shape;switch(r){case"image/x-alpha8":case"image/x-rgba8":{const u=It.create(r,{width:a.toString(),height:n.toString()});return new Blob([t.data],{type:u.toString()})}case"image/png":case"image/jpeg":case"image/webp":{const u=new ImageData(new Uint8ClampedArray(t.data),a,n);var i=Et(u.width,u.height),o=i.getContext("2d");return o.putImageData(u,0,0),i.convertToBlob({quality:e,type:r})}default:throw new Error(`Invalid format: ${r}`)}}function Ya(t){return new RegExp("^(?:[a-z+]+:)?//","i").test(t)}function Ka(t,e){return Ya(t)?t:new URL(t,e).href}function Xa(t){var e=Et(t.width,t.height),r=e.getContext("2d");return r.drawImage(t,0,0),r.getImageData(0,0,e.width,e.height)}function Qa(t){if(typeof Uint8Array<"u")return new Uint8Array(t);if(typeof Uint8ClampedArray<"u")return new Uint8ClampedArray(t);if(typeof Uint16Array<"u")return new Uint16Array(t);if(typeof Uint32Array<"u")return new Uint32Array(t);if(typeof Float32Array<"u")return new Float32Array(t);if(typeof Float64Array<"u")return new Float64Array(t);throw new Error("TypedArray not supported")}function Qe(t,e,r,n=!1){const[a,s,i]=t.shape;let o=s/e,u=a/r;n&&(o=u=Math.max(o,u)>1?Math.max(o,u):Math.min(o,u));const c=(0,ft.default)(Qa(i*e*r),[r,e,i]);for(let h=0;h<r;h++)for(let p=0;p<e;p++){const v=p*o,l=h*u,O=Math.max(Math.floor(v),0),g=Math.min(Math.ceil(v),s-1),C=Math.max(Math.floor(l),0),S=Math.min(Math.ceil(l),a-1),R=v-O,N=l-C;for(let I=0;I<i;I++){const Ge=t.get(C,O,I),He=t.get(C,g,I),T=t.get(S,O,I),Ae=t.get(S,g,I),Se=(1-R)*(1-N)*Ge+R*(1-N)*He+(1-R)*N*T+R*N*Ae;c.set(h,p,I,Se)}}return c}function en(t,e=[128,128,128],r=[256,256,256]){var n=t.data;const[a,s,i]=t.shape,o=a*s,u=new Float32Array(3*o);for(let c=0,h=0;c<n.length;c+=4,h+=1)u[h]=(n[c]-e[0])/r[0],u[h+o]=(n[c+1]-e[1])/r[1],u[h+o+o]=(n[c+2]-e[2])/r[2];return(0,ft.default)(u,[1,3,a,s])}async function le(t,e){return typeof t=="string"&&(t=Ka(t,e.publicPath),t=new URL(t)),t instanceof URL&&(t=await(await fetch(t,{})).blob()),(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t=new Blob([t])),t instanceof Blob&&(t=await Ja(t)),t}function tn(t){const e=new Uint8Array(t.data.length);for(let r=0;r<t.data.length;r++)e[r]=t.data[r]*255;return(0,ft.default)(e,t.shape)}function Et(t,e){let r;if(typeof OffscreenCanvas<"u"?r=new OffscreenCanvas(t,e):r=document.createElement("canvas"),!r)throw new Error("Canvas nor OffscreenCanvas are available in the current context.");return r}var rn=Ve(Le()),Rt=async()=>navigator.gpu===void 0?!1:await navigator.gpu.requestAdapter()!==null,an=()=>navigator.hardwareConcurrency??4;async function bt(t,e){return URL.createObjectURL(await Nt(t,e))}async function Nt(t,e){const r=new URL("resources.json",e.publicPath),n=await fetch(r);if(!n.ok)throw new Error("Resource metadata not found. Ensure that the config.publicPath is configured correctly.");const s=(await n.json())[t];if(!s)throw new Error(`Resource ${t} not found. Ensure that the config.publicPath is configured correctly.`);const i=s.chunks;let o=0;const u=i.map(async p=>{const v=p.offsets[1]-p.offsets[0],l=e.publicPath?new URL(p.name,e.publicPath).toString():p.name,g=await(await fetch(l,e.fetchArgs)).blob();if(v!==g.size)throw new Error(`Failed to fetch ${t} with size ${v} but got ${g.size}`);return e.progress&&(o+=v,e.progress(`fetch:${t}`,o,s.size)),g}),c=await Promise.all(u),h=new Blob(c,{type:s.mime});if(h.size!==s.size)throw new Error(`Failed to fetch ${t} with size ${s.size} but got ${h.size}`);return h}var ie=null,Pt=async t=>(ie!==null||(t?ie=(await vt(async()=>{const{default:e}=await import("./ort.webgpu.bundle.min.js");return{default:e}},[])).default:ie=(await vt(async()=>{const{default:e}=await import("./ort.bundle.min.js");return{default:e}},[])).default),ie);async function nn(t,e){const r=e.device==="gpu"&&await Rt(),n=r&&e.proxyToWorker,a=[r?"webgpu":"wasm"],s=await Pt(r);e.debug&&(console.debug(" Using WebGPU:",r),console.debug(" Proxy to Worker:",n),s.env.debug=!0,s.env.logLevel="verbose"),s.env.wasm.numThreads=an(),s.env.wasm.proxy=n;const i=r?"/onnxruntime-web/ort-wasm-simd-threaded.jsep":"/onnxruntime-web/ort-wasm-simd-threaded",o=await bt(`${i}.wasm`,e),u=await bt(`${i}.mjs`,e);s.env.wasm.wasmPaths={mjs:u,wasm:o},e.debug&&console.debug("ort.env.wasm:",s.env.wasm);const c={executionProviders:a,graphOptimizationLevel:"all",executionMode:"parallel",enableCpuMemArena:!0};return await s.InferenceSession.create(t,c).catch(p=>{throw new Error(`Failed to create session: "${p}". Please check if the publicPath is set correctly.`)})}async function sn(t,e,r,n){const a=n.device==="gpu"&&await Rt(),s=await Pt(a),i={};for(const[c,h]of e)i[c]=new s.Tensor("float32",new Float32Array(h.data),h.shape);const o=await t.run(i,{}),u=[];for(const c of r){const h=o[c],p=h.dims,v=h.data,l=(0,rn.default)(v,p);u.push(l)}return u}var j;(function(t){t.assertEqual=a=>a;function e(a){}t.assertIs=e;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const s={};for(const i of a)s[i]=i;return s},t.getValidEnumValues=a=>{const s=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of s)i[o]=a[o];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(s){return a[s]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&s.push(i);return s},t.find=(a,s)=>{for(const i of a)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function n(a,s=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(j||(j={}));var et;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(et||(et={}));var m=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),L=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}},d=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),on=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),$=class Mt extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(s){return s.message},n={_errors:[]},a=s=>{for(const i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(r(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return a(this),n}static assert(e){if(!(e instanceof Mt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const a of this.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(e(a))):n.push(e(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};$.create=t=>new $(t);var K=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,j.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${j.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${j.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${j.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:j.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case d.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case d.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=e.defaultError,j.assertNever(t)}return{message:r}},$t=K;function cn(t){$t=t}function Re(){return $t}var Ne=t=>{const{data:e,path:r,errorMaps:n,issueData:a}=t,s=[...r,...a.path||[]],i={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...a,path:s,message:o}},un=[];function f(t,e){const r=Re(),n=Ne({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===K?void 0:K].filter(a=>!!a)});t.common.issues.push(n)}var E=class zt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const a of r){if(a.status==="aborted")return b;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const a of r){const s=await a.key,i=await a.value;n.push({key:s,value:i})}return zt.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const a of r){const{key:s,value:i}=a;if(s.status==="aborted"||i.status==="aborted")return b;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},b=Object.freeze({status:"aborted"}),Y=t=>({status:"dirty",value:t}),Z=t=>({status:"valid",value:t}),tt=t=>t.status==="aborted",rt=t=>t.status==="dirty",G=t=>t.status==="valid",fe=t=>typeof Promise<"u"&&t instanceof Promise;function Pe(t,e,r,n){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function Dt(t,e,r,n,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}var _;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(_||(_={}));var oe,ce,U=class{constructor(t,e,r,n){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},wt=(t,e)=>{if(G(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new $(t.common.issues);return this._error=r,this._error}}};function x(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:a}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{var u,c;const{message:h}=t;return i.code==="invalid_enum_value"?{message:h??o.defaultError}:typeof o.data>"u"?{message:(u=h??n)!==null&&u!==void 0?u:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(c=h??r)!==null&&c!==void 0?c:o.defaultError}},description:a}}var k=class{get description(){return this._def.description}_getType(t){return L(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:L(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new E,ctx:{common:t.parent.common,data:t.data,parsedType:L(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(fe(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;const n={common:{issues:[],async:(r=e?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:L(t)},a=this._parseSync({data:t,path:n.path,parent:n});return wt(n,a)}"~validate"(t){var e,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:L(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return G(a)?{value:a.value}:{issues:n.common.issues}}catch(a){!((r=(e=a?.message)===null||e===void 0?void 0:e.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>G(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:L(t)},n=this._parse({data:t,path:r.path,parent:r}),a=await(fe(n)?n:Promise.resolve(n));return wt(r,a)}refine(t,e){const r=n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e;return this._refinement((n,a)=>{const s=t(n),i=()=>a.addIssue({code:d.custom,...r(n)});return typeof Promise<"u"&&s instanceof Promise?s.then(o=>o?!0:(i(),!1)):s?!0:(i(),!1)})}refinement(t,e){return this._refinement((r,n)=>t(r)?!0:(n.addIssue(typeof e=="function"?e(r,n):e),!1))}_refinement(t){return new z({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return D.create(this,this._def)}nullable(){return W.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.create(this)}promise(){return ee.create(this,this._def)}or(t){return ye.create([this,t],this._def)}and(t){return be.create(this,t,this._def)}transform(t){return new z({...x(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Te({...x(this._def),innerType:this,defaultValue:e,typeName:y.ZodDefault})}brand(){return new ht({typeName:y.ZodBranded,type:this,...x(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new Ce({...x(this._def),innerType:this,catchValue:e,typeName:y.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return pt.create(this,t)}readonly(){return je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},dn=/^c[^\s-]{8,}$/i,ln=/^[0-9a-z]+$/,fn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pn=/^[a-z0-9_-]{21}$/i,mn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,vn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,_n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ke,yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,wn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,xn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ut="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Cn=new RegExp(`^${Ut}$`);function Vt(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function jn(t){return new RegExp(`^${Vt(t)}$`)}function Lt(t){let e=`${Ut}T${Vt(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function On(t,e){return!!((e==="v4"||!e)&&yn.test(t)||(e==="v6"||!e)&&wn.test(t))}function An(t,e){if(!mn.test(t))return!1;try{const[r]=t.split("."),n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||!a.typ||!a.alg||e&&a.alg!==e)}catch{return!1}}function Sn(t,e){return!!((e==="v4"||!e)&&bn.test(t)||(e==="v6"||!e)&&xn.test(t))}var X=class ue extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const s=this._getOrReturnCtx(e);return f(s,{code:d.invalid_type,expected:m.string,received:s.parsedType}),b}const n=new E;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:d.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:d.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,o=e.data.length<s.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?f(a,{code:d.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&f(a,{code:d.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")_n.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ke||(Ke=new RegExp(gn,"u")),Ke.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")hn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")pn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")dn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")ln.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")fn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:d.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:d.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:d.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:d.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:d.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Lt(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:d.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Cn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:d.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?jn(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:d.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?vn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?On(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?An(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Sn(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?kn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?Tn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:d.invalid_string,message:s.message}),n.dirty()):j.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(a=>e.test(a),{validation:r,code:d.invalid_string,..._.errToObj(n)})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!==null&&r!==void 0?r:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,..._.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,..._.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,..._.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,..._.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,..._.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,..._.errToObj(r)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new ue({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ue({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ue({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};X.create=t=>{var e;return new X({checks:[],typeName:y.ZodString,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...x(t)})};function Zn(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=r>n?r:n,s=parseInt(t.toFixed(a).replace(".","")),i=parseInt(e.toFixed(a).replace(".",""));return s%i/Math.pow(10,a)}var he=class at extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){const s=this._getOrReturnCtx(e);return f(s,{code:d.invalid_type,expected:m.number,received:s.parsedType}),b}let n;const a=new E;for(const s of this._def.checks)s.kind==="int"?j.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Zn(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_finite,message:s.message}),a.dirty()):j.assertNever(s);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,n,a){return new at({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:_.toString(a)}]})}_addCheck(e){return new at({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};he.create=t=>new he({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,...x(t)});var pe=class nt extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let n;const a=new E;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):j.assertNever(s);return{status:a.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:m.bigint,received:r.parsedType}),b}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,n,a){return new nt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:_.toString(a)}]})}_addCheck(e){return new nt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};pe.create=t=>{var e;return new pe({checks:[],typeName:y.ZodBigInt,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...x(t)})};var me=class extends k{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==m.boolean){const r=this._getOrReturnCtx(t);return f(r,{code:d.invalid_type,expected:m.boolean,received:r.parsedType}),b}return Z(t.data)}};me.create=t=>new me({typeName:y.ZodBoolean,coerce:t?.coerce||!1,...x(t)});var ve=class Ft extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const s=this._getOrReturnCtx(e);return f(s,{code:d.invalid_type,expected:m.date,received:s.parsedType}),b}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:d.invalid_date}),b}const n=new E;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:d.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:d.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):j.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ft({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ve.create=t=>new ve({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,...x(t)});var Me=class extends k{_parse(t){if(this._getType(t)!==m.symbol){const r=this._getOrReturnCtx(t);return f(r,{code:d.invalid_type,expected:m.symbol,received:r.parsedType}),b}return Z(t.data)}};Me.create=t=>new Me({typeName:y.ZodSymbol,...x(t)});var _e=class extends k{_parse(t){if(this._getType(t)!==m.undefined){const r=this._getOrReturnCtx(t);return f(r,{code:d.invalid_type,expected:m.undefined,received:r.parsedType}),b}return Z(t.data)}};_e.create=t=>new _e({typeName:y.ZodUndefined,...x(t)});var ge=class extends k{_parse(t){if(this._getType(t)!==m.null){const r=this._getOrReturnCtx(t);return f(r,{code:d.invalid_type,expected:m.null,received:r.parsedType}),b}return Z(t.data)}};ge.create=t=>new ge({typeName:y.ZodNull,...x(t)});var Q=class extends k{constructor(){super(...arguments),this._any=!0}_parse(t){return Z(t.data)}};Q.create=t=>new Q({typeName:y.ZodAny,...x(t)});var q=class extends k{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Z(t.data)}};q.create=t=>new q({typeName:y.ZodUnknown,...x(t)});var F=class extends k{_parse(t){const e=this._getOrReturnCtx(t);return f(e,{code:d.invalid_type,expected:m.never,received:e.parsedType}),b}};F.create=t=>new F({typeName:y.ZodNever,...x(t)});var $e=class extends k{_parse(t){if(this._getType(t)!==m.undefined){const r=this._getOrReturnCtx(t);return f(r,{code:d.invalid_type,expected:m.void,received:r.parsedType}),b}return Z(t.data)}};$e.create=t=>new $e({typeName:y.ZodVoid,...x(t)});var H=class Ze extends k{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==m.array)return f(r,{code:d.invalid_type,expected:m.array,received:r.parsedType}),b;if(a.exactLength!==null){const i=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(i||o)&&(f(r,{code:i?d.too_big:d.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(f(r,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(f(r,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>a.type._parseAsync(new U(r,i,r.path,o)))).then(i=>E.mergeArray(n,i));const s=[...r.data].map((i,o)=>a.type._parseSync(new U(r,i,r.path,o)));return E.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new Ze({...this._def,minLength:{value:e,message:_.toString(r)}})}max(e,r){return new Ze({...this._def,maxLength:{value:e,message:_.toString(r)}})}length(e,r){return new Ze({...this._def,exactLength:{value:e,message:_.toString(r)}})}nonempty(e){return this.min(1,e)}};H.create=(t,e)=>new H({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...x(e)});function J(t){if(t instanceof P){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=D.create(J(n))}return new P({...t._def,shape:()=>e})}else return t instanceof H?new H({...t._def,type:J(t.element)}):t instanceof D?D.create(J(t.unwrap())):t instanceof W?W.create(J(t.unwrap())):t instanceof B?B.create(t.items.map(e=>J(e))):t}var P=class M extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=j.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==m.object){const c=this._getOrReturnCtx(e);return f(c,{code:d.invalid_type,expected:m.object,received:c.parsedType}),b}const{status:n,ctx:a}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(const c in a.data)i.includes(c)||o.push(c);const u=[];for(const c of i){const h=s[c],p=a.data[c];u.push({key:{status:"valid",value:c},value:h._parse(new U(a,p,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof F){const c=this._def.unknownKeys;if(c==="passthrough")for(const h of o)u.push({key:{status:"valid",value:h},value:{status:"valid",value:a.data[h]}});else if(c==="strict")o.length>0&&(f(a,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const h of o){const p=a.data[h];u.push({key:{status:"valid",value:h},value:c._parse(new U(a,p,a.path,h)),alwaysSet:h in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const c=[];for(const h of u){const p=await h.key,v=await h.value;c.push({key:p,value:v,alwaysSet:h.alwaysSet})}return c}).then(c=>E.mergeObjectSync(n,c)):E.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new M({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var a,s,i,o;const u=(i=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,r,n).message)!==null&&i!==void 0?i:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new M({...this._def,unknownKeys:"strip"})}passthrough(){return new M({...this._def,unknownKeys:"passthrough"})}extend(e){return new M({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new M({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new M({...this._def,catchall:e})}pick(e){const r={};return j.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new M({...this._def,shape:()=>r})}omit(e){const r={};return j.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new M({...this._def,shape:()=>r})}deepPartial(){return J(this)}partial(e){const r={};return j.objectKeys(this.shape).forEach(n=>{const a=this.shape[n];e&&!e[n]?r[n]=a:r[n]=a.optional()}),new M({...this._def,shape:()=>r})}required(e){const r={};return j.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof D;)s=s._def.innerType;r[n]=s}}),new M({...this._def,shape:()=>r})}keyof(){return Jt(j.objectKeys(this.shape))}};P.create=(t,e)=>new P({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,...x(e)});P.strictCreate=(t,e)=>new P({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:y.ZodObject,...x(e)});P.lazycreate=(t,e)=>new P({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,...x(e)});var ye=class extends k{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function n(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return e.common.issues.push(...i.ctx.common.issues),i.result;const s=a.map(i=>new $(i.ctx.common.issues));return f(e,{code:d.invalid_union,unionErrors:s}),b}if(e.common.async)return Promise.all(r.map(async a=>{const s={...e,common:{...e.common,issues:[]},parent:null};return{result:await a._parseAsync({data:e.data,path:e.path,parent:s}),ctx:s}})).then(n);{let a;const s=[];for(const o of r){const u={...e,common:{...e.common,issues:[]},parent:null},c=o._parseSync({data:e.data,path:e.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:u}),u.common.issues.length&&s.push(u.common.issues)}if(a)return e.common.issues.push(...a.ctx.common.issues),a.result;const i=s.map(o=>new $(o));return f(e,{code:d.invalid_union,unionErrors:i}),b}}get options(){return this._def.options}};ye.create=(t,e)=>new ye({options:t,typeName:y.ZodUnion,...x(e)});var V=t=>t instanceof we?V(t.schema):t instanceof z?V(t.innerType()):t instanceof xe?[t.value]:t instanceof Oe?t.options:t instanceof ke?j.objectValues(t.enum):t instanceof Te?V(t._def.innerType):t instanceof _e?[void 0]:t instanceof ge?[null]:t instanceof D?[void 0,...V(t.unwrap())]:t instanceof W?[null,...V(t.unwrap())]:t instanceof ht||t instanceof je?V(t.unwrap()):t instanceof Ce?V(t._def.innerType):[],Bt=class Wt extends k{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return f(r,{code:d.invalid_type,expected:m.object,received:r.parsedType}),b;const n=this.discriminator,a=r.data[n],s=this.optionsMap.get(a);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(f(r,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const a=new Map;for(const s of r){const i=V(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,s)}}return new Wt({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...x(n)})}};function st(t,e){const r=L(t),n=L(e);if(t===e)return{valid:!0,data:t};if(r===m.object&&n===m.object){const a=j.objectKeys(e),s=j.objectKeys(t).filter(o=>a.indexOf(o)!==-1),i={...t,...e};for(const o of s){const u=st(t[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(r===m.array&&n===m.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<t.length;s++){const i=t[s],o=e[s],u=st(i,o);if(!u.valid)return{valid:!1};a.push(u.data)}return{valid:!0,data:a}}else return r===m.date&&n===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var be=class extends k{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),n=(a,s)=>{if(tt(a)||tt(s))return b;const i=st(a.value,s.value);return i.valid?((rt(a)||rt(s))&&e.dirty(),{status:e.value,value:i.data}):(f(r,{code:d.invalid_intersection_types}),b)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,s])=>n(a,s)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};be.create=(t,e,r)=>new be({left:t,right:e,typeName:y.ZodIntersection,...x(r)});var B=class qt extends k{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.array)return f(n,{code:d.invalid_type,expected:m.array,received:n.parsedType}),b;if(n.data.length<this._def.items.length)return f(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const s=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new U(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>E.mergeArray(r,i)):E.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new qt({...this._def,rest:e})}};B.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new B({items:t,typeName:y.ZodTuple,rest:null,...x(e)})};var Gt=class it extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return f(n,{code:d.invalid_type,expected:m.object,received:n.parsedType}),b;const a=[],s=this._def.keyType,i=this._def.valueType;for(const o in n.data)a.push({key:s._parse(new U(n,o,n.path,o)),value:i._parse(new U(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?E.mergeObjectAsync(r,a):E.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof k?new it({keyType:e,valueType:r,typeName:y.ZodRecord,...x(n)}):new it({keyType:X.create(),valueType:e,typeName:y.ZodRecord,...x(r)})}},ze=class extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==m.map)return f(r,{code:d.invalid_type,expected:m.map,received:r.parsedType}),b;const n=this._def.keyType,a=this._def.valueType,s=[...r.data.entries()].map(([i,o],u)=>({key:n._parse(new U(r,i,r.path,[u,"key"])),value:a._parse(new U(r,o,r.path,[u,"value"]))}));if(r.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const o of s){const u=await o.key,c=await o.value;if(u.status==="aborted"||c.status==="aborted")return b;(u.status==="dirty"||c.status==="dirty")&&e.dirty(),i.set(u.value,c.value)}return{status:e.value,value:i}})}else{const i=new Map;for(const o of s){const u=o.key,c=o.value;if(u.status==="aborted"||c.status==="aborted")return b;(u.status==="dirty"||c.status==="dirty")&&e.dirty(),i.set(u.value,c.value)}return{status:e.value,value:i}}}};ze.create=(t,e,r)=>new ze({valueType:e,keyType:t,typeName:y.ZodMap,...x(r)});var De=class ot extends k{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.set)return f(n,{code:d.invalid_type,expected:m.set,received:n.parsedType}),b;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(f(n,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(f(n,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const s=this._def.valueType;function i(u){const c=new Set;for(const h of u){if(h.status==="aborted")return b;h.status==="dirty"&&r.dirty(),c.add(h.value)}return{status:r.value,value:c}}const o=[...n.data.values()].map((u,c)=>s._parse(new U(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,r){return new ot({...this._def,minSize:{value:e,message:_.toString(r)}})}max(e,r){return new ot({...this._def,maxSize:{value:e,message:_.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};De.create=(t,e)=>new De({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,...x(e)});var Ht=class Ie extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.function)return f(r,{code:d.invalid_type,expected:m.function,received:r.parsedType}),b;function n(o,u){return Ne({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Re(),K].filter(c=>!!c),issueData:{code:d.invalid_arguments,argumentsError:u}})}function a(o,u){return Ne({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Re(),K].filter(c=>!!c),issueData:{code:d.invalid_return_type,returnTypeError:u}})}const s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof ee){const o=this;return Z(async function(...u){const c=new $([]),h=await o._def.args.parseAsync(u,s).catch(l=>{throw c.addIssue(n(u,l)),c}),p=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(p,s).catch(l=>{throw c.addIssue(a(p,l)),c})})}else{const o=this;return Z(function(...u){const c=o._def.args.safeParse(u,s);if(!c.success)throw new $([n(u,c.error)]);const h=Reflect.apply(i,this,c.data),p=o._def.returns.safeParse(h,s);if(!p.success)throw new $([a(h,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ie({...this._def,args:B.create(e).rest(q.create())})}returns(e){return new Ie({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ie({args:e||B.create([]).rest(q.create()),returns:r||q.create(),typeName:y.ZodFunction,...x(n)})}},we=class extends k{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};we.create=(t,e)=>new we({getter:t,typeName:y.ZodLazy,...x(e)});var xe=class extends k{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return f(e,{received:e.data,code:d.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:t.data}}get value(){return this._def.value}};xe.create=(t,e)=>new xe({value:t,typeName:y.ZodLiteral,...x(e)});function Jt(t,e){return new Oe({values:t,typeName:y.ZodEnum,...x(e)})}var Oe=class ct extends k{constructor(){super(...arguments),oe.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{expected:j.joinValues(n),received:r.parsedType,code:d.invalid_type}),b}if(Pe(this,oe)||Dt(this,oe,new Set(this._def.values)),!Pe(this,oe).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{received:r.data,code:d.invalid_enum_value,options:n}),b}return Z(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return ct.create(e,{...this._def,...r})}exclude(e,r=this._def){return ct.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};oe=new WeakMap;Oe.create=Jt;var ke=class extends k{constructor(){super(...arguments),ce.set(this,void 0)}_parse(t){const e=j.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==m.string&&r.parsedType!==m.number){const n=j.objectValues(e);return f(r,{expected:j.joinValues(n),received:r.parsedType,code:d.invalid_type}),b}if(Pe(this,ce)||Dt(this,ce,new Set(j.getValidEnumValues(this._def.values))),!Pe(this,ce).has(t.data)){const n=j.objectValues(e);return f(r,{received:r.data,code:d.invalid_enum_value,options:n}),b}return Z(t.data)}get enum(){return this._def.values}};ce=new WeakMap;ke.create=(t,e)=>new ke({values:t,typeName:y.ZodNativeEnum,...x(e)});var ee=class extends k{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==m.promise&&e.common.async===!1)return f(e,{code:d.invalid_type,expected:m.promise,received:e.parsedType}),b;const r=e.parsedType===m.promise?e.data:Promise.resolve(e.data);return Z(r.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}};ee.create=(t,e)=>new ee({type:t,typeName:y.ZodPromise,...x(e)});var z=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),n=this._def.effect||null,a={addIssue:s=>{f(r,s),s.fatal?e.abort():e.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const s=n.transform(r.data,a);if(r.common.async)return Promise.resolve(s).then(async i=>{if(e.value==="aborted")return b;const o=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return o.status==="aborted"?b:o.status==="dirty"||e.value==="dirty"?Y(o.value):o});{if(e.value==="aborted")return b;const i=this._def.schema._parseSync({data:s,path:r.path,parent:r});return i.status==="aborted"?b:i.status==="dirty"||e.value==="dirty"?Y(i.value):i}}if(n.type==="refinement"){const s=i=>{const o=n.refinement(i,a);if(r.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?b:(i.status==="dirty"&&e.dirty(),s(i.value),{status:e.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?b:(i.status==="dirty"&&e.dirty(),s(i.value).then(()=>({status:e.value,value:i.value}))))}if(n.type==="transform")if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!G(s))return s;const i=n.transform(s.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>G(s)?Promise.resolve(n.transform(s.value,a)).then(i=>({status:e.value,value:i})):s);j.assertNever(n)}};z.create=(t,e,r)=>new z({schema:t,typeName:y.ZodEffects,effect:e,...x(r)});z.createWithPreprocess=(t,e,r)=>new z({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,...x(r)});var D=class extends k{_parse(t){return this._getType(t)===m.undefined?Z(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};D.create=(t,e)=>new D({innerType:t,typeName:y.ZodOptional,...x(e)});var W=class extends k{_parse(t){return this._getType(t)===m.null?Z(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};W.create=(t,e)=>new W({innerType:t,typeName:y.ZodNullable,...x(e)});var Te=class extends k{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};Te.create=(t,e)=>new Te({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});var Ce=class extends k{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return fe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new $(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new $(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ce.create=(t,e)=>new Ce({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});var Ue=class extends k{_parse(t){if(this._getType(t)!==m.nan){const r=this._getOrReturnCtx(t);return f(r,{code:d.invalid_type,expected:m.nan,received:r.parsedType}),b}return{status:"valid",value:t.data}}};Ue.create=t=>new Ue({typeName:y.ZodNaN,...x(t)});var In=Symbol("zod_brand"),ht=class extends k{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}},pt=class Yt extends k{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?b:s.status==="dirty"?(r.dirty(),Y(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?b:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,r){return new Yt({in:e,out:r,typeName:y.ZodPipeline})}},je=class extends k{_parse(t){const e=this._def.innerType._parse(t),r=n=>(G(n)&&(n.value=Object.freeze(n.value)),n);return fe(e)?e.then(n=>r(n)):r(e)}unwrap(){return this._def.innerType}};je.create=(t,e)=>new je({innerType:t,typeName:y.ZodReadonly,...x(e)});function xt(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Kt(t,e={},r){return t?Q.create().superRefine((n,a)=>{var s,i;const o=t(n);if(o instanceof Promise)return o.then(u=>{var c,h;if(!u){const p=xt(e,n),v=(h=(c=p.fatal)!==null&&c!==void 0?c:r)!==null&&h!==void 0?h:!0;a.addIssue({code:"custom",...p,fatal:v})}});if(!o){const u=xt(e,n),c=(i=(s=u.fatal)!==null&&s!==void 0?s:r)!==null&&i!==void 0?i:!0;a.addIssue({code:"custom",...u,fatal:c})}}):Q.create()}var En={object:P.lazycreate},y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));var Rn=(t,e={message:`Input not instance of ${t.name}`})=>Kt(r=>r instanceof t,e),Xt=X.create,Qt=he.create,Nn=Ue.create,Pn=pe.create,er=me.create,Mn=ve.create,$n=Me.create,zn=_e.create,Dn=ge.create,Un=Q.create,Vn=q.create,Ln=F.create,Fn=$e.create,Bn=H.create,Wn=P.create,qn=P.strictCreate,Gn=ye.create,Hn=Bt.create,Jn=be.create,Yn=B.create,Kn=Gt.create,Xn=ze.create,Qn=De.create,es=Ht.create,ts=we.create,rs=xe.create,as=Oe.create,ns=ke.create,ss=ee.create,kt=z.create,is=D.create,os=W.create,cs=z.createWithPreprocess,us=pt.create,ds=()=>Xt().optional(),ls=()=>Qt().optional(),fs=()=>er().optional(),hs={string:t=>X.create({...t,coerce:!0}),number:t=>he.create({...t,coerce:!0}),boolean:t=>me.create({...t,coerce:!0}),bigint:t=>pe.create({...t,coerce:!0}),date:t=>ve.create({...t,coerce:!0})},ps=b,A=Object.freeze({__proto__:null,defaultErrorMap:K,setErrorMap:cn,getErrorMap:Re,makeIssue:Ne,EMPTY_PATH:un,addIssueToContext:f,ParseStatus:E,INVALID:b,DIRTY:Y,OK:Z,isAborted:tt,isDirty:rt,isValid:G,isAsync:fe,get util(){return j},get objectUtil(){return et},ZodParsedType:m,getParsedType:L,ZodType:k,datetimeRegex:Lt,ZodString:X,ZodNumber:he,ZodBigInt:pe,ZodBoolean:me,ZodDate:ve,ZodSymbol:Me,ZodUndefined:_e,ZodNull:ge,ZodAny:Q,ZodUnknown:q,ZodNever:F,ZodVoid:$e,ZodArray:H,ZodObject:P,ZodUnion:ye,ZodDiscriminatedUnion:Bt,ZodIntersection:be,ZodTuple:B,ZodRecord:Gt,ZodMap:ze,ZodSet:De,ZodFunction:Ht,ZodLazy:we,ZodLiteral:xe,ZodEnum:Oe,ZodNativeEnum:ke,ZodPromise:ee,ZodEffects:z,ZodTransformer:z,ZodOptional:D,ZodNullable:W,ZodDefault:Te,ZodCatch:Ce,ZodNaN:Ue,BRAND:In,ZodBranded:ht,ZodPipeline:pt,ZodReadonly:je,custom:Kt,Schema:k,ZodSchema:k,late:En,get ZodFirstPartyTypeKind(){return y},coerce:hs,any:Un,array:Bn,bigint:Pn,boolean:er,date:Mn,discriminatedUnion:Hn,effect:kt,enum:as,function:es,instanceof:Rn,intersection:Jn,lazy:ts,literal:rs,map:Xn,nan:Nn,nativeEnum:ns,never:Ln,null:Dn,nullable:os,number:Qt,object:Wn,oboolean:fs,onumber:ls,optional:is,ostring:ds,pipeline:us,preprocess:cs,promise:ss,record:Kn,set:Qn,strictObject:qn,string:Xt,symbol:$n,transformer:kt,tuple:Yn,undefined:zn,union:Gn,unknown:Vn,void:Fn,NEVER:ps,ZodIssueCode:d,quotelessJson:on,ZodError:$}),Tt={name:"@imgly/background-removal",version:"1.7.0"},ms=A.object({publicPath:A.string().optional().describe("The public path to the wasm files and the onnx model.").default("https://staticimgly.com/@imgly/background-removal-data/${PACKAGE_VERSION}/dist/").transform(t=>t.replace("${PACKAGE_NAME}",Tt.name).replace("${PACKAGE_VERSION}",Tt.version)),debug:A.boolean().default(!1).describe("Whether to enable debug logging."),rescale:A.boolean().default(!0).describe("Whether to rescale the image."),device:A.enum(["cpu","gpu"]).default("cpu").describe("The device to run the model on."),proxyToWorker:A.boolean().default(!1).describe("Whether to proxy inference to a web worker."),fetchArgs:A.any().default({}).describe("Arguments to pass to fetch when loading the model."),progress:A.function().args(A.string(),A.number(),A.number()).returns(A.void()).describe("Progress callback.").optional(),model:A.preprocess(t=>{switch(t){case"large":return"isnet";case"small":return"isnet_quint8";case"medium":return"isnet_fp16";default:return t}},A.enum(["isnet","isnet_fp16","isnet_quint8"])).default("medium"),output:A.object({format:A.enum(["image/png","image/jpeg","image/webp","image/x-rgba8","image/x-alpha8"]).default("image/png"),quality:A.number().default(.8)}).default({})}).default({}).transform(t=>(t.debug&&console.log("Config:",t),t.debug&&!t.progress&&(t.progress=t.progress??((e,r,n)=>{console.debug(`Downloading ${e}: ${r} of ${n}`)}),crossOriginIsolated||t.debug&&console.debug("Cross-Origin-Isolated is not enabled. Performance will be degraded. Please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer.")),t));function tr(t){return ms.parse(t??{})}var vs=Ve(Le());async function _s(t){t.debug&&console.debug("Loading model...",t.model);const e=t.model,n=await(await Nt(`/models/${e}`,t)).arrayBuffer();return await nn(n,t)}async function gs(t){t=tr(t);const e=await _s(t);return{config:t,session:{base:e}}}async function mt(t,e,r){const[a,s,i]=t.shape,o=!1;let u=Qe(t,1024,1024,o);const c=en(u);let h=await sn(r.base,[["input",c]],["output"],e),p=(0,vs.default)(h[0].data,[1024,1024,1]),v=tn(p);return e.rescale?(v=Qe(v,s,a,o),[v,t]):[v,u]}var qe=Ha(gs,t=>JSON.stringify(t));async function xs(t){await qe(t)}async function ks(t,e){const{config:r,session:n}=await qe(e);r.progress&&r.progress("compute:decode",0,4);const a=await le(t,r);r.progress?.("compute:inference",1,4);const[s,i]=await mt(a,r,n);r.progress?.("compute:mask",2,4);const o=i,[u,c]=o.shape,h=u*c;for(let v=0;v<h;v+=1)o.data[4*v+3]=s.data[v];r.progress?.("compute:encode",3,4);const p=await We(o,r.output.quality,r.output.format);return r.progress?.("compute:encode",4,4),p}async function Ts(t,e){const{config:r,session:n}=await qe(e),a=await le(t,r),[s,i]=await mt(a,r,n),o=i,[u,c,h]=o.shape,p=u*c;for(let l=0;l<p;l+=1)o.data[4*l+3]=255-s.data[l];return await We(o,r.output.quality,r.output.format)}var Cs=ys;async function ys(t,e){const{config:r,session:n}=await qe(e),a=await le(t,r);let[s,i,o]=a.shape;const[u,c]=await mt(a,r,n),h=i*s,p=a;for(let l=0;l<h;l+=1){const O=4*l;let g=u.data[l];p.data[O]=255,p.data[O+1]=255,p.data[O+2]=255,p.data[O+3]=g}return await We(p,r.output.quality,r.output.format)}async function js(t,e,r){r=tr(r);const n=await le(t,r),[a,s,i]=n.shape,o=await le(e,r),[u,c,h]=o.shape,p=u!==a||c!==s?Qe(o,s,a):o,v=s*a;for(let O=0;O<v;O+=1){const g=i*O,C=h*O;n.data[g+3]=p.data[C+3]}return await We(n,r.output.quality,r.output.format)}export{Cs as alphamask,js as applySegmentationMask,xs as preload,ks as removeBackground,Ts as removeForeground,ys as segmentForeground};
|