numpy-ts 0.5.0 → 0.7.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.
@@ -1,3 +1,3 @@
1
- "use strict";var zr=Object.defineProperty;var no=Object.getOwnPropertyDescriptor;var oo=Object.getOwnPropertyNames;var ao=Object.prototype.hasOwnProperty;var _=(r,t)=>()=>(r&&(t=r(r=0)),t);var Br=(r,t)=>{for(var e in t)zr(r,e,{get:t[e],enumerable:!0})},so=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oo(t))!ao.call(r,o)&&o!==e&&zr(r,o,{get:()=>t[o],enumerable:!(n=no(t,o))||n.enumerable});return r};var Ur=r=>so(zr({},"__esModule",{value:!0}),r);function et(r){if(!r.includes(":")){if(r.includes("."))throw new Error(`Invalid slice index: "${r}" (must be integer)`);let a=parseInt(r,10);if(isNaN(a))throw new Error(`Invalid slice index: "${r}"`);return{start:a,stop:null,step:1,isIndex:!0}}let t=r.split(":");if(t.length>3)throw new Error(`Invalid slice notation: "${r}" (too many colons)`);let e=t[0]===""?null:parseInt(t[0],10),n=t[1]===""||t[1]===void 0?null:parseInt(t[1],10),o=t[2]===""||t[2]===void 0?1:parseInt(t[2],10);if(e!==null&&isNaN(e))throw new Error(`Invalid start index in slice: "${r}"`);if(n!==null&&isNaN(n))throw new Error(`Invalid stop index in slice: "${r}"`);if(isNaN(o))throw new Error(`Invalid step in slice: "${r}"`);if(o===0)throw new Error("Slice step cannot be zero");return{start:e,stop:n,step:o,isIndex:!1}}function nt(r,t){let{start:e,stop:n}=r,{step:o,isIndex:a}=r;if(a){if(e===null)throw new Error("Index cannot be null");let c=e<0?t+e:e;if(c<0||c>=t)throw new Error(`Index ${e} is out of bounds for size ${t}`);return{start:c,stop:c+1,step:1,isIndex:!0}}return o>0?(e===null&&(e=0),n===null&&(n=t)):(e===null&&(e=t-1),n===null&&(n=-t-1)),e<0&&(e=t+e),n<0&&(n=t+n),e=Math.max(0,Math.min(e,t)),n=Math.max(-1,Math.min(n,t)),{start:e,stop:n,step:o,isIndex:!1}}var ot=_(()=>{"use strict"});function B(r){switch(r){case"float64":return Float64Array;case"float32":return Float32Array;case"int64":return BigInt64Array;case"int32":return Int32Array;case"int16":return Int16Array;case"int8":return Int8Array;case"uint64":return BigUint64Array;case"uint32":return Uint32Array;case"uint16":return Uint16Array;case"uint8":return Uint8Array;case"bool":return Uint8Array;default:throw new Error(`Unknown dtype: ${r}`)}}function st(r){switch(r){case"float64":case"int64":case"uint64":return 8;case"float32":case"int32":case"uint32":return 4;case"int16":case"uint16":return 2;case"int8":case"uint8":case"bool":return 1;default:throw new Error(`Unknown dtype: ${r}`)}}function at(r){return r==="float64"||r==="float32"}function w(r){return r==="int64"||r==="uint64"}function $(r,t){if(r===t)return r;if(r==="bool")return t;if(t==="bool")return r;if(at(r)||at(t)){if(r==="float64"||t==="float64")return"float64";if(r==="float32"){let i=t;return i==="int32"||i==="int64"||i==="uint32"||i==="uint64"?"float64":"float32"}if(t==="float32"){let i=r;return i==="int32"||i==="int64"||i==="uint32"||i==="uint64"?"float64":"float32"}return"float32"}let e=r.startsWith("int"),n=t.startsWith("int"),o=r.startsWith("uint"),a=t.startsWith("uint"),c=i=>i.includes("64")?64:i.includes("32")?32:i.includes("16")?16:i.includes("8")?8:0,u=c(r),s=c(t);if(r==="int64"&&t==="uint64"||r==="uint64"&&t==="int64")return"float64";if(e&&a&&u===s){if(u===8)return"int16";if(u===16)return"int32";if(u===32)return"int64"}if(o&&n&&u===s){if(s===8)return"int16";if(s===16)return"int32";if(s===32)return"int64"}if(e&&n||o&&a){let i=Math.max(u,s);return e?i===64?"int64":i===32?"int32":i===16?"int16":"int8":i===64?"uint64":i===32?"uint32":i===16?"uint16":"uint8"}return e&&a?u>s?r:s===8?"int16":s===16?"int32":s===32?"int64":"float64":o&&n?s>u?t:u===8?"int16":u===16?"int32":u===32?"int64":"float64":"float64"}var v,k=_(()=>{"use strict";v="float64"});function q(r){let t=new Array(r.length),e=1;for(let n=r.length-1;n>=0;n--)t[n]=e,e*=r[n];return t}var D,P=_(()=>{"use strict";k();D=class r{constructor(t,e,n,o,a){this._data=t,this._shape=e,this._strides=n,this._offset=o,this._dtype=a}get shape(){return this._shape}get ndim(){return this._shape.length}get size(){return this._shape.reduce((t,e)=>t*e,1)}get dtype(){return this._dtype}get data(){return this._data}get strides(){return this._strides}get offset(){return this._offset}get isCContiguous(){let t=this._shape,e=this._strides,n=t.length;if(n===0)return!0;if(n===1)return e[0]===1;let o=1;for(let a=n-1;a>=0;a--){if(e[a]!==o)return!1;o*=t[a]}return!0}get isFContiguous(){let t=this._shape,e=this._strides,n=t.length;if(n===0)return!0;if(n===1)return e[0]===1;let o=1;for(let a=0;a<n;a++){if(e[a]!==o)return!1;o*=t[a]}return!0}iget(t){let e=this._shape,n=this._strides,o=e.length;if(o===0)return this._data[this._offset];let a=t,c=this._offset;for(let u=0;u<o;u++){let s=1;for(let l=u+1;l<o;l++)s*=e[l];let i=Math.floor(a/s);a=a%s,c+=i*n[u]}return this._data[c]}iset(t,e){let n=this._shape,o=this._strides,a=n.length;if(a===0){this._data[this._offset]=e;return}let c=t,u=this._offset;for(let s=0;s<a;s++){let i=1;for(let f=s+1;f<a;f++)i*=n[f];let l=Math.floor(c/i);c=c%i,u+=l*o[s]}this._data[u]=e}get(...t){let e=this._strides,n=this._offset;for(let o=0;o<t.length;o++)n+=t[o]*e[o];return this._data[n]}set(t,e){let n=this._strides,o=this._offset;for(let a=0;a<t.length;a++)o+=t[a]*n[a];this._data[o]=e}copy(){let t=Array.from(this._shape),e=this._dtype,n=this.size,o=B(e);if(!o)throw new Error(`Cannot copy array with dtype ${e}`);let a=new o(n);if(this.isCContiguous&&this._offset===0)if(w(e)){let c=this._data,u=a;for(let s=0;s<n;s++)u[s]=c[s]}else a.set(this._data);else if(w(e)){let c=a;for(let u=0;u<n;u++)c[u]=this.iget(u)}else for(let c=0;c<n;c++)a[c]=this.iget(c);return new r(a,t,r._computeStrides(t),0,e)}static fromData(t,e,n,o,a){let c=o??r._computeStrides(e),u=a??0;return new r(t,e,c,u,n)}static zeros(t,e=v){let n=t.reduce((c,u)=>c*u,1),o=B(e);if(!o)throw new Error(`Cannot create array with dtype ${e}`);let a=new o(n);return new r(a,t,r._computeStrides(t),0,e)}static ones(t,e=v){let n=t.reduce((c,u)=>c*u,1),o=B(e);if(!o)throw new Error(`Cannot create array with dtype ${e}`);let a=new o(n);return w(e)?a.fill(BigInt(1)):a.fill(1),new r(a,t,r._computeStrides(t),0,e)}static _computeStrides(t){let e=new Array(t.length),n=1;for(let o=t.length-1;o>=0;o--)e[o]=n,n*=t[o];return e}}});function it(r,t){let e=r.length,n=t.length,o=Math.max(e,n),a=new Array(o);for(let c=0;c<o;c++){let u=c<o-e?1:r[c-(o-e)],s=c<o-n?1:t[c-(o-n)];if(u===s)a[c]=u;else if(u===1)a[c]=s;else if(s===1)a[c]=u;else throw new Error(`operands could not be broadcast together with shapes ${JSON.stringify(Array.from(r))} ${JSON.stringify(Array.from(t))}`)}return a}function io(r,t,e){let n=r.length,o=e.length,a=new Array(o).fill(0);for(let c=0;c<n;c++){let u=o-n+c,s=r[c],i=e[u];if(s===i)a[u]=t[c];else if(s===1)a[u]=0;else throw new Error("Invalid broadcast")}return a}function pr(r,t){let e=io(r.shape,r.strides,t);return D.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function V(r,t,e,n){let o=it(r.shape,t.shape),a=pr(r,o),c=pr(t,o),u=$(r.dtype,t.dtype),s=D.zeros(o,u),i=s.data,l=s.size;if(w(u)){let f=i;for(let p=0;p<l;p++){let m=a.iget(p),y=c.iget(p),d=typeof m=="bigint"?m:BigInt(Math.round(m)),A=typeof y=="bigint"?y:BigInt(Math.round(y));n==="add"?f[p]=d+A:n==="subtract"?f[p]=d-A:n==="multiply"?f[p]=d*A:n==="divide"?f[p]=d/A:f[p]=BigInt(Math.round(e(Number(d),Number(A))))}}else{let f=w(r.dtype)||w(t.dtype);for(let p=0;p<l;p++){let m=a.iget(p),y=c.iget(p),d=Number(m),A=Number(y);i[p]=e(d,A)}}return s}function j(r,t,e){let n=it(r.shape,t.shape),o=pr(r,n),a=pr(t,n),c=n.reduce((i,l)=>i*l,1),u=new Uint8Array(c),s=w(r.dtype)||w(t.dtype);for(let i=0;i<c;i++){let l=o.iget(i),f=a.iget(i),p=Number(l),m=Number(f);u[i]=e(p,m)?1:0}return D.fromData(u,n,"bool")}function M(r,t,e=!0){let n=r.dtype,o=Array.from(r.shape),a=r.size,u=e?n:n!=="float32"&&n!=="float64"?"float64":n,s=D.zeros(o,u),i=s.data,l=r.data;if(w(n))if(w(u)){let f=i;for(let p=0;p<a;p++){let m=Number(l[p]);f[p]=BigInt(Math.round(t(m)))}}else for(let f=0;f<a;f++)i[f]=t(Number(l[f]));else for(let f=0;f<a;f++)i[f]=t(Number(l[f]));return s}var G=_(()=>{"use strict";P();k()});function _r(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function ut(r,t){return typeof t=="number"?fo(r,t):_r(r,t)?uo(r,t):V(r,t,(e,n)=>e+n,"add")}function uo(r,t){let e=$(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,c=t.data,u=n.data;if(w(e)){let s=u;if(!w(r.dtype)||!w(t.dtype))for(let l=0;l<o;l++){let f=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),p=typeof c[l]=="bigint"?c[l]:BigInt(Math.round(Number(c[l])));s[l]=f+p}else{let l=a,f=c;for(let p=0;p<o;p++)s[p]=l[p]+f[p]}}else if(w(r.dtype)||w(t.dtype))for(let i=0;i<o;i++){let l=typeof a[i]=="bigint"?Number(a[i]):a[i],f=typeof c[i]=="bigint"?Number(c[i]):c[i];u[i]=l+f}else for(let i=0;i<o;i++)u[i]=a[i]+c[i];return n}function ct(r,t){return typeof t=="number"?po(r,t):_r(r,t)?co(r,t):V(r,t,(e,n)=>e-n,"subtract")}function co(r,t){let e=$(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,c=t.data,u=n.data;if(w(e)){let s=u;if(!w(r.dtype)||!w(t.dtype))for(let l=0;l<o;l++){let f=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),p=typeof c[l]=="bigint"?c[l]:BigInt(Math.round(Number(c[l])));s[l]=f-p}else{let l=a,f=c;for(let p=0;p<o;p++)s[p]=l[p]-f[p]}}else if(w(r.dtype)||w(t.dtype))for(let i=0;i<o;i++){let l=typeof a[i]=="bigint"?Number(a[i]):a[i],f=typeof c[i]=="bigint"?Number(c[i]):c[i];u[i]=l-f}else for(let i=0;i<o;i++)u[i]=a[i]-c[i];return n}function lt(r,t){return typeof t=="number"?yo(r,t):_r(r,t)?lo(r,t):V(r,t,(e,n)=>e*n,"multiply")}function lo(r,t){let e=$(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,c=t.data,u=n.data;if(w(e)){let s=u;if(!w(r.dtype)||!w(t.dtype))for(let l=0;l<o;l++){let f=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),p=typeof c[l]=="bigint"?c[l]:BigInt(Math.round(Number(c[l])));s[l]=f*p}else{let l=a,f=c;for(let p=0;p<o;p++)s[p]=l[p]*f[p]}}else if(w(r.dtype)||w(t.dtype))for(let i=0;i<o;i++){let l=typeof a[i]=="bigint"?Number(a[i]):a[i],f=typeof c[i]=="bigint"?Number(c[i]):c[i];u[i]=l*f}else for(let i=0;i<o;i++)u[i]=a[i]*c[i];return n}function ft(r,t){if(typeof t=="number")return mo(r,t);let e=r.dtype==="float64",n=t.dtype==="float64",o=r.dtype==="float32",a=t.dtype==="float32";if(e||n){let s=e?r:Y(r,"float64"),i=n?t:Y(t,"float64");return V(s,i,(l,f)=>l/f,"divide")}if(o||a){let s=o?r:Y(r,"float32"),i=a?t:Y(t,"float32");return V(s,i,(l,f)=>l/f,"divide")}let c=Y(r,"float64"),u=Y(t,"float64");return V(c,u,(s,i)=>s/i,"divide")}function Y(r,t){let e=D.zeros(Array.from(r.shape),t),n=r.size,o=r.data,a=e.data;for(let c=0;c<n;c++)a[c]=Number(o[c]);return e}function fo(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=D.zeros(n,e),u=c.data;if(w(e)){let s=o,i=u,l=BigInt(Math.round(t));for(let f=0;f<a;f++)i[f]=s[f]+l}else for(let s=0;s<a;s++)u[s]=Number(o[s])+t;return c}function po(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=D.zeros(n,e),u=c.data;if(w(e)){let s=o,i=u,l=BigInt(Math.round(t));for(let f=0;f<a;f++)i[f]=s[f]-l}else for(let s=0;s<a;s++)u[s]=Number(o[s])-t;return c}function yo(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=D.zeros(n,e),u=c.data;if(w(e)){let s=o,i=u,l=BigInt(Math.round(t));for(let f=0;f<a;f++)i[f]=s[f]*l}else for(let s=0;s<a;s++)u[s]=Number(o[s])*t;return c}function mo(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=e!=="float32"&&e!=="float64"?"float64":e,s=D.zeros(n,u),i=s.data;if(w(e))for(let l=0;l<a;l++)i[l]=Number(o[l])/t;else for(let l=0;l<a;l++)i[l]=Number(o[l])/t;return s}function pt(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),c=a.data;if(w(t)){let u=n,s=c;for(let i=0;i<o;i++){let l=u[i];s[i]=l<0n?-l:l}}else for(let u=0;u<o;u++)c[u]=Math.abs(Number(n[u]));return a}function yt(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),c=a.data;if(w(t)){let u=n,s=c;for(let i=0;i<o;i++)s[i]=-u[i]}else for(let u=0;u<o;u++)c[u]=-Number(n[u]);return a}function mt(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),c=a.data;if(w(t)){let u=n,s=c;for(let i=0;i<o;i++){let l=u[i];s[i]=l>0n?1n:l<0n?-1n:0n}}else for(let u=0;u<o;u++){let s=Number(n[u]);c[u]=s>0?1:s<0?-1:0}return a}function dt(r,t){return typeof t=="number"?go(r,t):V(r,t,(e,n)=>(e%n+n)%n,"mod")}function go(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=D.zeros(n,e),u=c.data;if(w(e)){let s=o,i=u,l=BigInt(Math.round(t));for(let f=0;f<a;f++){let p=s[f];i[f]=(p%l+l)%l}}else for(let s=0;s<a;s++){let i=Number(o[s]);u[s]=(i%t+t)%t}return c}function gt(r,t){return typeof t=="number"?ho(r,t):V(r,t,(e,n)=>Math.floor(e/n),"floor_divide")}function ho(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=D.zeros(n,e),u=c.data;if(w(e)){let s=o,i=u,l=BigInt(Math.round(t));for(let f=0;f<a;f++)i[f]=s[f]/l}else for(let s=0;s<a;s++)u[s]=Math.floor(Number(o[s])/t);return c}function ht(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),c=a.data;for(let u=0;u<o;u++)c[u]=n[u];return a}function At(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,c=t!=="float32"&&t!=="float64"?"float64":t,u=D.zeros(e,c),s=u.data;if(w(t))for(let i=0;i<o;i++)s[i]=1/Number(n[i]);else for(let i=0;i<o;i++)s[i]=1/Number(n[i]);return u}var bt=_(()=>{"use strict";P();k();G()});function St(r,t){return typeof t=="number"?bo(r,t):j(r,t,(e,n)=>e>n)}function Dt(r,t){return typeof t=="number"?So(r,t):j(r,t,(e,n)=>e>=n)}function wt(r,t){return typeof t=="number"?Do(r,t):j(r,t,(e,n)=>e<n)}function Nt(r,t){return typeof t=="number"?wo(r,t):j(r,t,(e,n)=>e<=n)}function xt(r,t){return typeof t=="number"?No(r,t):j(r,t,(e,n)=>e===n)}function It(r,t){return typeof t=="number"?xo(r,t):j(r,t,(e,n)=>e!==n)}function Er(r,t,e=1e-5,n=1e-8){return typeof t=="number"?Io(r,t,e,n):j(r,t,(o,a)=>{let c=Math.abs(o-a),u=n+e*Math.abs(a);return c<=u})}function zt(r,t,e=1e-5,n=1e-8){let o=Er(r,t,e,n),a=o.data;for(let c=0;c<o.size;c++)if(a[c]===0)return!1;return!0}function bo(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]>t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function So(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]>=t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Do(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]<t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function wo(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]<=t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function No(r,t){let e=new Uint8Array(r.size),n=r.data,o=r.dtype;if(w(o)){let a=BigInt(Math.round(t)),c=n;for(let u=0;u<r.size;u++)e[u]=c[u]===a?1:0}else for(let a=0;a<r.size;a++)e[a]=n[a]===t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function xo(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]!==t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Io(r,t,e,n){let o=new Uint8Array(r.size),a=r.data,c=r.dtype;if(w(c)){let u=a;for(let s=0;s<r.size;s++){let i=Number(u[s]),l=Math.abs(i-t),f=n+e*Math.abs(t);o[s]=l<=f?1:0}}else for(let u=0;u<r.size;u++){let s=Number(a[u]),i=Math.abs(s-t),l=n+e*Math.abs(t);o[u]=i<=l?1:0}return D.fromData(o,Array.from(r.shape),"bool")}var Bt=_(()=>{"use strict";P();k();G()});function E(r,t){let e=0,n=1;for(let o=r.length-1;o>=0;o--)e+=r[o]*n,n*=t[o];return e}function T(r,t,e,n){let o=n.length,a=new Array(o),c=Array.from(n).filter((s,i)=>i!==t),u=r;for(let s=c.length-1;s>=0;s--)a[s>=t?s+1:s]=u%c[s],u=Math.floor(u/c[s]);return a[t]=e,a}var Ut=_(()=>{"use strict"});function tr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,c=r.size,u=r.data;if(t===void 0)if(w(n)){let y=u,d=BigInt(0);for(let A=0;A<c;A++)d+=y[A];return Number(d)}else{let y=0;for(let d=0;d<c;d++)y+=Number(u[d]);return y}let s=t;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((y,d)=>d!==s);if(i.length===0)return tr(r);let l=D.zeros(i,n),f=l.data,p=o[s],m=i.reduce((y,d)=>y*d,1);if(w(n)){let y=u,d=f;for(let A=0;A<m;A++){let h=BigInt(0);for(let g=0;g<p;g++){let b=T(A,s,g,o),S=E(b,o);h+=y[S]}d[A]=h}}else for(let y=0;y<m;y++){let d=0;for(let A=0;A<p;A++){let h=T(y,s,A,o),g=E(h,o);d+=Number(u[g])}f[y]=d}if(e){let y=[...o];return y[s]=1,D.fromData(f,y,n)}return l}function Tr(r,t,e=!1){let n=r.dtype,o=r.shape;if(t===void 0)return tr(r)/r.size;let a=t;if(a<0&&(a=o.length+a),a<0||a>=o.length)throw new Error(`axis ${t} is out of bounds for array of dimension ${o.length}`);let c=tr(r,t,e);if(typeof c=="number")return c/o[a];let u=o[a],s=n;(w(n)||n.startsWith("int")||n.startsWith("uint"))&&(s="float64");let i=D.zeros(Array.from(c.shape),s),l=i.data,f=c.data;if(w(n)){let p=f;for(let m=0;m<l.length;m++)l[m]=Number(p[m])/u}else for(let p=0;p<l.length;p++)l[p]=Number(f[p])/u;return i}function Or(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,c=r.size,u=r.data;if(t===void 0){if(c===0)throw new Error("max of empty array");let y=u[0];for(let d=1;d<c;d++)u[d]>y&&(y=u[d]);return Number(y)}let s=t;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((y,d)=>d!==s);if(i.length===0)return Or(r);let l=D.zeros(i,n),f=l.data,p=o[s],m=i.reduce((y,d)=>y*d,1);if(w(n)){let y=u,d=f;for(let A=0;A<m;A++){let h=T(A,s,0,o),g=E(h,o),b=y[g];for(let S=1;S<p;S++){let x=T(A,s,S,o),N=E(x,o),O=y[N];O>b&&(b=O)}d[A]=b}}else for(let y=0;y<m;y++){let d=-1/0;for(let A=0;A<p;A++){let h=T(y,s,A,o),g=E(h,o),b=Number(u[g]);b>d&&(d=b)}f[y]=d}if(e){let y=[...o];return y[s]=1,D.fromData(f,y,n)}return l}function $r(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,c=r.size,u=r.data;if(t===void 0)if(w(n)){let y=u,d=BigInt(1);for(let A=0;A<c;A++)d*=y[A];return Number(d)}else{let y=1;for(let d=0;d<c;d++)y*=Number(u[d]);return y}let s=t;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((y,d)=>d!==s);if(i.length===0)return $r(r);let l=D.zeros(i,n),f=l.data,p=o[s],m=i.reduce((y,d)=>y*d,1);if(w(n)){let y=u,d=f;for(let A=0;A<m;A++){let h=BigInt(1);for(let g=0;g<p;g++){let b=T(A,s,g,o),S=E(b,o);h*=y[S]}d[A]=h}}else for(let y=0;y<m;y++){let d=1;for(let A=0;A<p;A++){let h=T(y,s,A,o),g=E(h,o);d*=Number(u[g])}f[y]=d}if(e){let y=[...o];return y[s]=1,D.fromData(f,y,n)}return l}function Mr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,c=r.size,u=r.data;if(t===void 0){if(c===0)throw new Error("min of empty array");let y=u[0];for(let d=1;d<c;d++)u[d]<y&&(y=u[d]);return Number(y)}let s=t;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((y,d)=>d!==s);if(i.length===0)return Mr(r);let l=D.zeros(i,n),f=l.data,p=o[s],m=i.reduce((y,d)=>y*d,1);if(w(n)){let y=u,d=f;for(let A=0;A<m;A++){let h=T(A,s,0,o),g=E(h,o),b=y[g];for(let S=1;S<p;S++){let x=T(A,s,S,o),N=E(x,o),O=y[N];O<b&&(b=O)}d[A]=b}}else for(let y=0;y<m;y++){let d=1/0;for(let A=0;A<p;A++){let h=T(y,s,A,o),g=E(h,o),b=Number(u[g]);b<d&&(d=b)}f[y]=d}if(e){let y=[...o];return y[s]=1,D.fromData(f,y,n)}return l}function vr(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.size,c=r.data;if(t===void 0){if(a===0)throw new Error("argmin of empty array");let m=c[0],y=0;for(let d=1;d<a;d++)c[d]<m&&(m=c[d],y=d);return y}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((m,y)=>y!==u);if(s.length===0)return vr(r);let i=D.zeros(s,"int32"),l=i.data,f=n[u],p=s.reduce((m,y)=>m*y,1);if(w(e)){let m=c;for(let y=0;y<p;y++){let d=T(y,u,0,n),A=E(d,n),h=m[A],g=0;for(let b=1;b<f;b++){let S=T(y,u,b,n),x=E(S,n),N=m[x];N<h&&(h=N,g=b)}l[y]=g}}else for(let m=0;m<p;m++){let y=1/0,d=0;for(let A=0;A<f;A++){let h=T(m,u,A,n),g=E(h,n),b=Number(c[g]);b<y&&(y=b,d=A)}l[m]=d}return i}function Cr(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.size,c=r.data;if(t===void 0){if(a===0)throw new Error("argmax of empty array");let m=c[0],y=0;for(let d=1;d<a;d++)c[d]>m&&(m=c[d],y=d);return y}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((m,y)=>y!==u);if(s.length===0)return Cr(r);let i=D.zeros(s,"int32"),l=i.data,f=n[u],p=s.reduce((m,y)=>m*y,1);if(w(e)){let m=c;for(let y=0;y<p;y++){let d=T(y,u,0,n),A=E(d,n),h=m[A],g=0;for(let b=1;b<f;b++){let S=T(y,u,b,n),x=E(S,n),N=m[x];N>h&&(h=N,g=b)}l[y]=g}}else for(let m=0;m<p;m++){let y=-1/0,d=0;for(let A=0;A<f;A++){let h=T(m,u,A,n),g=E(h,n),b=Number(c[g]);b>y&&(y=b,d=A)}l[m]=d}return i}function kr(r,t,e=0,n=!1){let o=r.shape,a=o.length,c=r.size,u=r.data,s=Tr(r,t,n);if(t===void 0){let h=s,g=0;for(let b=0;b<c;b++){let S=Number(u[b])-h;g+=S*S}return g/(c-e)}let i=t;if(i<0&&(i=a+i),i<0||i>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let l=o[i],f=s,p=f.data,m=n?f.shape:Array.from(o).filter((h,g)=>g!==i),y=D.zeros(Array.from(m),"float64"),d=y.data,A=m.reduce((h,g)=>h*g,1);for(let h=0;h<A;h++){let g=0,b=Number(p[h]);for(let S=0;S<l;S++){let x=T(h,i,S,o),N=E(x,o),O=Number(u[N])-b;g+=O*O}d[h]=g/(l-e)}return y}function _t(r,t,e=0,n=!1){let o=kr(r,t,e,n);if(typeof o=="number")return Math.sqrt(o);let a=D.zeros(Array.from(o.shape),"float64"),c=o.data,u=a.data;for(let s=0;s<c.length;s++)u[s]=Math.sqrt(Number(c[s]));return a}function Pr(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,c=r.data;if(t===void 0){for(let m=0;m<a;m++)if(!c[m])return!1;return!0}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((m,y)=>y!==u);if(s.length===0)return Pr(r);let i=D.zeros(s,"bool"),l=i.data,f=n[u],p=s.reduce((m,y)=>m*y,1);for(let m=0;m<p;m++){let y=!0;for(let d=0;d<f;d++){let A=T(m,u,d,n),h=E(A,n);if(!c[h]){y=!1;break}}l[m]=y?1:0}if(e){let m=[...n];return m[u]=1,D.fromData(l,m,"bool")}return i}function Vr(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,c=r.data;if(t===void 0){for(let m=0;m<a;m++)if(c[m])return!0;return!1}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((m,y)=>y!==u);if(s.length===0)return Vr(r);let i=D.zeros(s,"bool"),l=i.data,f=n[u],p=s.reduce((m,y)=>m*y,1);for(let m=0;m<p;m++){let y=!1;for(let d=0;d<f;d++){let A=T(m,u,d,n),h=E(A,n);if(c[h]){y=!0;break}}l[m]=y?1:0}if(e){let m=[...n];return m[u]=1,D.fromData(l,m,"bool")}return i}var Et=_(()=>{"use strict";P();k();Ut()});function J(r,t){let e=r.size,n=r.dtype,o=t.indexOf(-1),a;if(o!==-1){let i=t.reduce((f,p,m)=>m===o?f:f*p,1),l=e/i;if(!Number.isInteger(l))throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(t)}`);a=t.map((f,p)=>p===o?l:f)}else a=t;if(a.reduce((i,l)=>i*l,1)!==e)throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(a)}`);if(r.isCContiguous){let i=r.data;return D.fromData(i,a,n,q(a),0)}let s=r.copy().data;return D.fromData(s,a,n,q(a),0)}function Fr(r){let t=r.size,e=r.dtype,n=B(e);if(!n)throw new Error(`Cannot flatten array with dtype ${e}`);if(r.isCContiguous){let u=r.data.slice(r.offset,r.offset+t);return D.fromData(u,[t],e,[1],0)}let o=new n(t),a=w(e);for(let c=0;c<t;c++){let u=r.iget(c);o[c]=u}return D.fromData(o,[t],e,[1],0)}function nr(r){let t=r.size,e=r.dtype;if(r.isCContiguous){let n=r.data;return D.fromData(n,[t],e,[1],0)}return Fr(r)}function yr(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,c=r.dtype,u;if(t===void 0)u=Array.from({length:n},(f,p)=>n-1-p);else{if(t.length!==n)throw new Error(`axes must have length ${n}, got ${t.length}`);let f=new Set;for(let p of t){let m=p<0?n+p:p;if(m<0||m>=n)throw new Error(`axis ${p} is out of bounds for array of dimension ${n}`);if(f.has(m))throw new Error("repeated axis in transpose");f.add(m)}u=t.map(p=>p<0?n+p:p)}let s=u.map(f=>e[f]),i=Array.from(o),l=u.map(f=>i[f]);return D.fromData(a,s,c,l,r.offset)}function Tt(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,c=r.dtype;if(t===void 0){let u=[],s=[];for(let i=0;i<n;i++)e[i]!==1&&(u.push(e[i]),s.push(o[i]));return u.length===0&&(u.push(1),s.push(1)),D.fromData(a,u,c,s,r.offset)}else{let u=t<0?n+t:t;if(u<0||u>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);if(e[u]!==1)throw new Error(`cannot select an axis which has size not equal to one (axis ${t} has size ${e[u]})`);let s=[],i=[];for(let l=0;l<n;l++)l!==u&&(s.push(e[l]),i.push(o[l]));return D.fromData(a,s,c,i,r.offset)}}function er(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,c=r.dtype,u=t;if(u<0&&(u=n+t+1),u<0||u>n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n+1}`);let s=[...Array.from(e)];s.splice(u,0,1);let i=[...Array.from(o)],l=u<n?o[u]*(e[u]||1):1;return i.splice(u,0,l),D.fromData(a,s,c,i,r.offset)}function Ot(r,t,e){let n=r.shape,o=n.length,a=r.strides,c=r.data,u=r.dtype,s=t<0?o+t:t,i=e<0?o+e:e;if(s<0||s>=o)throw new Error(`axis1 ${t} is out of bounds for array of dimension ${o}`);if(i<0||i>=o)throw new Error(`axis2 ${e} is out of bounds for array of dimension ${o}`);if(s===i)return D.fromData(c,Array.from(n),u,Array.from(a),r.offset);let l=Array.from(n),f=Array.from(a);return[l[s],l[i]]=[l[i],l[s]],[f[s],f[i]]=[f[i],f[s]],D.fromData(c,l,u,f,r.offset)}function $t(r,t,e){let n=r.ndim,o=Array.isArray(t)?t:[t],a=Array.isArray(e)?e:[e];if(o.length!==a.length)throw new Error("source and destination must have the same number of elements");let c=o.map(i=>{let l=i<0?n+i:i;if(l<0||l>=n)throw new Error(`source axis ${i} is out of bounds for array of dimension ${n}`);return l}),u=a.map(i=>{let l=i<0?n+i:i;if(l<0||l>=n)throw new Error(`destination axis ${i} is out of bounds for array of dimension ${n}`);return l});if(new Set(c).size!==c.length)throw new Error("repeated axis in source");if(new Set(u).size!==u.length)throw new Error("repeated axis in destination");let s=[];for(let i=0;i<n;i++)c.includes(i)||s.push(i);for(let i=0;i<c.length;i++){let l=u[i];s.splice(l,0,c[i])}return yr(r,s)}function W(r,t=0){if(r.length===0)throw new Error("need at least one array to concatenate");if(r.length===1)return r[0].copy();let e=r[0],n=e.ndim,o=e.dtype,a=t<0?n+t:t;if(a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);for(let m=1;m<r.length;m++){let y=r[m];if(y.ndim!==n)throw new Error("all the input arrays must have same number of dimensions");for(let d=0;d<n;d++)if(d!==a&&y.shape[d]!==e.shape[d])throw new Error("all the input array dimensions except for the concatenation axis must match exactly")}let c=Array.from(e.shape),u=e.shape[a];for(let m=1;m<r.length;m++)u+=r[m].shape[a];c[a]=u;let s=c.reduce((m,y)=>m*y,1),i=B(o);if(!i)throw new Error(`Cannot concatenate arrays with dtype ${o}`);let l=new i(s),f=q(c),p=0;for(let m of r){let y=m.shape[a];Uo(m,l,c,f,a,p,o),p+=y}return D.fromData(l,c,o)}function Uo(r,t,e,n,o,a,c){let u=r.shape,s=u.length,i=r.size,l=c==="int64"||c==="uint64";if(o===0&&r.isCContiguous&&s>0){let p=a*n[0],m=r.data,y=r.offset,d=y+i;t.set(m.subarray(y,d),p);return}let f=new Array(s).fill(0);for(let p=0;p<i;p++){let m=r.iget(p),y=[...f];y[o]+=a;let d=0;for(let A=0;A<s;A++)d+=y[A]*n[A];t[d]=m;for(let A=s-1;A>=0&&(f[A]++,!(f[A]<u[A]));A--)f[A]=0}}function Mt(r,t=0){if(r.length===0)throw new Error("need at least one array to stack");let e=r[0],n=e.shape,o=e.ndim,a=t<0?o+1+t:t;if(a<0||a>o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o+1}`);for(let u=1;u<r.length;u++){let s=r[u];if(s.ndim!==o)throw new Error("all input arrays must have the same shape");for(let i=0;i<o;i++)if(s.shape[i]!==n[i])throw new Error("all input arrays must have the same shape")}let c=r.map(u=>er(u,a));return W(c,a)}function vt(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?J(e,[1,e.shape[0]]):e);return W(t,0)}function Ct(r){if(r.length===0)throw new Error("need at least one array to stack");return r.every(e=>e.ndim===1)?W(r,0):W(r,1)}function kt(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?J(er(J(e,[1,e.shape[0]]),2),[1,e.shape[0],1]):e.ndim===2?er(e,2):e);return W(t,2)}function Pt(r,t,e=0){let n=r.shape,o=n.length,a=e<0?o+e:e;if(a<0||a>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let c=n[a],u;if(typeof t=="number"){if(c%t!==0)throw new Error("array split does not result in an equal division");let s=c/t;u=[];for(let i=1;i<t;i++)u.push(i*s)}else u=t;return Vt(r,u,a)}function mr(r,t,e=0){let n=r.shape,o=n.length,a=e<0?o+e:e;if(a<0||a>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let c=n[a],u;if(typeof t=="number"){let s=t,i=Math.floor(c/s),l=c%s;u=[];let f=0;for(let p=0;p<s-1;p++)f+=i+(p<l?1:0),u.push(f)}else u=t;return Vt(r,u,a)}function Vt(r,t,e){let n=r.shape,o=n[e],a=[0,...t,o],c=[];for(let u=0;u<a.length-1;u++){let s=a[u],i=a[u+1];if(s>i)throw new Error("split indices must be in ascending order");let l=Array.from(n);l[e]=i-s;let f=r.offset+s*r.strides[e];c.push(D.fromData(r.data,l,r.dtype,Array.from(r.strides),f))}return c}function Ft(r,t){if(r.ndim<2)throw new Error("vsplit only works on arrays of 2 or more dimensions");return mr(r,t,0)}function Rt(r,t){if(r.ndim<1)throw new Error("hsplit only works on arrays of 1 or more dimensions");let e=r.ndim===1?0:1;return mr(r,t,e)}function Lt(r,t){let e=r.shape,n=e.length,o=r.dtype,a=Array.isArray(t)?t:[t],c=Math.max(n,a.length),u=new Array(c).fill(1),s=new Array(c).fill(1);for(let g=0;g<n;g++)u[c-n+g]=e[g];for(let g=0;g<a.length;g++)s[c-a.length+g]=a[g];let i=u.map((g,b)=>g*s[b]),l=i.reduce((g,b)=>g*b,1),f=B(o);if(!f)throw new Error(`Cannot tile array with dtype ${o}`);let p=new f(l),m=q(i),y=r;n<c&&(y=J(r,u));let d=o==="int64"||o==="uint64",A=y.strides,h=new Array(c).fill(0);for(let g=0;g<l;g++){let b=y.offset;for(let N=0;N<c;N++){let O=h[N]%u[N];b+=O*A[N]}let S=y.data[b],x=0;for(let N=0;N<c;N++)x+=h[N]*m[N];p[x]=S;for(let N=c-1;N>=0&&(h[N]++,!(h[N]<i[N]));N--)h[N]=0}return D.fromData(p,i,o)}function qt(r,t,e){let n=r.shape,o=n.length,a=r.dtype,c=r.size;if(e===void 0){let g=c,b=Array.isArray(t)?t:new Array(g).fill(t);if(b.length!==g)throw new Error(`operands could not be broadcast together with shape (${g},) (${b.length},)`);let S=b.reduce((I,U)=>I+U,0),x=B(a);if(!x)throw new Error(`Cannot repeat array with dtype ${a}`);let N=new x(S),O=0;for(let I=0;I<g;I++){let U=r.iget(I),fr=b[I];for(let tt=0;tt<fr;tt++)N[O++]=U}return D.fromData(N,[S],a)}let u=e<0?o+e:e;if(u<0||u>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let s=n[u],i=Array.isArray(t)?t:new Array(s).fill(t);if(i.length!==s)throw new Error(`operands could not be broadcast together with shape (${s},) (${i.length},)`);let l=Array.from(n);l[u]=i.reduce((g,b)=>g+b,0);let f=l.reduce((g,b)=>g*b,1),p=B(a);if(!p)throw new Error(`Cannot repeat array with dtype ${a}`);let m=new p(f),y=q(l),d=new Array(o).fill(0),A=a==="int64"||a==="uint64",h=[0];for(let g=0;g<s;g++)h.push(h[g]+i[g]);for(let g=0;g<c;g++){let b=r.iget(g),S=d[u],x=i[S],N=0;for(let U=0;U<o;U++)U!==u&&(N+=d[U]*y[U]);let O=y[u],I=h[S];for(let U=0;U<x;U++){let fr=N+(I+U)*O;m[fr]=b}for(let U=o-1;U>=0&&(d[U]++,!(d[U]<n[U]));U--)d[U]=0}return D.fromData(m,l,a)}var Rr=_(()=>{"use strict";P();k()});function _o(r,t,e,n,o,a,c,u,s,i,l,f,p,m){if(f===0)for(let h=0;h<n*o;h++)p[h]=0;else if(f!==1)for(let h=0;h<n*o;h++)p[h]=(p[h]??0)*f;let y=r==="row-major",d=t==="transpose",A=e==="transpose";if(y&&!d&&!A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[h*s+S]??0)*(i[S*l+g]??0);p[h*m+g]=(p[h*m+g]??0)+c*b}else if(y&&d&&!A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[S*s+h]??0)*(i[S*l+g]??0);p[h*m+g]=(p[h*m+g]??0)+c*b}else if(y&&!d&&A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[h*s+S]??0)*(i[g*l+S]??0);p[h*m+g]=(p[h*m+g]??0)+c*b}else if(y&&d&&A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[S*s+h]??0)*(i[g*l+S]??0);p[h*m+g]=(p[h*m+g]??0)+c*b}else if(!y&&!d&&!A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[S*s+h]??0)*(i[g*l+S]??0);p[g*m+h]=(p[g*m+h]??0)+c*b}else if(!y&&d&&!A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[h*s+S]??0)*(i[g*l+S]??0);p[g*m+h]=(p[g*m+h]??0)+c*b}else if(!y&&!d&&A)for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[S*s+h]??0)*(i[S*l+g]??0);p[g*m+h]=(p[g*m+h]??0)+c*b}else for(let h=0;h<n;h++)for(let g=0;g<o;g++){let b=0;for(let S=0;S<a;S++)b+=(u[h*s+S]??0)*(i[S*l+g]??0);p[g*m+h]=(p[g*m+h]??0)+c*b}}function Lr(r,t){let e=r.ndim,n=t.ndim;if(e===0||n===0){let o=e===0?r.get():null,a=n===0?t.get():null;if(e===0&&n===0)return typeof o=="bigint"&&typeof a=="bigint"?o*a:Number(o)*Number(a);if(e===0){let c=$(r.dtype,t.dtype),u=D.zeros([...t.shape],c);for(let s=0;s<t.size;s++){let i=t.data[s+t.offset];typeof o=="bigint"&&typeof i=="bigint"?u.data[s]=o*i:u.data[s]=Number(o)*Number(i)}return u}else{let c=$(r.dtype,t.dtype),u=D.zeros([...r.shape],c);for(let s=0;s<r.size;s++){let i=r.data[s+r.offset];typeof i=="bigint"&&typeof a=="bigint"?u.data[s]=i*a:u.data[s]=Number(i)*Number(a)}return u}}if(e===1&&n===1){if(r.shape[0]!==t.shape[0])throw new Error(`dot: incompatible shapes (${r.shape[0]},) and (${t.shape[0]},)`);let o=r.shape[0],a=0;for(let c=0;c<o;c++){let u=r.get(c),s=t.get(c);typeof u=="bigint"&&typeof s=="bigint"?a=Number(a)+Number(u*s):a+=Number(u)*Number(s)}return a}if(e===2&&n===2)return qr(r,t);if(e===2&&n===1){let[o,a]=r.shape,c=t.shape[0];if(a!==c)throw new Error(`dot: incompatible shapes (${o},${a}) and (${c},)`);let u=$(r.dtype,t.dtype),s=D.zeros([o],u);for(let i=0;i<o;i++){let l=0;for(let f=0;f<a;f++){let p=r.get(i,f),m=t.get(f);typeof p=="bigint"&&typeof m=="bigint"?l=Number(l)+Number(p*m):l+=Number(p)*Number(m)}s.set([i],l)}return s}if(e===1&&n===2){let o=r.shape[0],[a,c]=t.shape;if(o!==a)throw new Error(`dot: incompatible shapes (${o},) and (${a},${c})`);let u=$(r.dtype,t.dtype),s=D.zeros([c],u);for(let i=0;i<c;i++){let l=0;for(let f=0;f<o;f++){let p=r.get(f),m=t.get(f,i);typeof p=="bigint"&&typeof m=="bigint"?l=Number(l)+Number(p*m):l+=Number(p)*Number(m)}s.set([i],l)}return s}if(e>2&&n===1){let o=r.shape[e-1],a=t.shape[0];if(o!==a)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and (${a},)`);let c=[...r.shape.slice(0,-1)],u=$(r.dtype,t.dtype),s=D.zeros(c,u),i=c.reduce((l,f)=>l*f,1);for(let l=0;l<i;l++){let f=0,p=l,m=[];for(let y=c.length-1;y>=0;y--)m[y]=p%c[y],p=Math.floor(p/c[y]);for(let y=0;y<o;y++){let d=[...m,y],A=r.get(...d),h=t.get(y);typeof A=="bigint"&&typeof h=="bigint"?f=Number(f)+Number(A*h):f+=Number(A)*Number(h)}s.set(m,f)}return s}if(e===1&&n>2){let o=r.shape[0],a=1,c=t.shape[a];if(o!==c)throw new Error(`dot: incompatible shapes (${o},) and ${JSON.stringify(t.shape)}`);let u=[...t.shape.slice(0,a),...t.shape.slice(a+1)],s=$(r.dtype,t.dtype),i=D.zeros(u,s),l=u.reduce((f,p)=>f*p,1);for(let f=0;f<l;f++){let p=f,m=[];for(let h=u.length-1;h>=0;h--)m[h]=p%u[h],p=Math.floor(p/u[h]);let y=m.slice(0,a),d=m.slice(a),A=0;for(let h=0;h<o;h++){let g=r.get(h),b=[...y,h,...d],S=t.get(...b);typeof g=="bigint"&&typeof S=="bigint"?A=Number(A)+Number(g*S):A+=Number(g)*Number(S)}i.set(m,A)}return i}if(e>=2&&n>=2&&!(e===2&&n===2)){let o=r.shape[e-1],a=t.shape[n-2];if(o!==a)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and ${JSON.stringify(t.shape)}`);let c=[...r.shape.slice(0,-1),...t.shape.slice(0,-2),t.shape[n-1]],u=$(r.dtype,t.dtype),s=D.zeros(c,u),i=r.shape.slice(0,-1).reduce((m,y)=>m*y,1),l=t.shape.slice(0,-2).reduce((m,y)=>m*y,1),f=t.shape[n-1],p=o;for(let m=0;m<i;m++)for(let y=0;y<l;y++)for(let d=0;d<f;d++){let A=0;for(let g=0;g<p;g++){let b=m*p+g,S=r.data[b+r.offset],x=y*p*f+g*f+d,N=t.data[x+t.offset];typeof S=="bigint"&&typeof N=="bigint"?A=Number(A)+Number(S*N):A+=Number(S)*Number(N)}let h=m*l*f+y*f+d;s.data[h]=A}return s}throw new Error(`dot: unexpected combination of dimensions ${e}D \xB7 ${n}D`)}function qr(r,t){if(r.ndim!==2||t.ndim!==2)throw new Error("matmul requires 2D arrays");let[e=0,n=0]=r.shape,[o=0,a=0]=t.shape;if(n!==o)throw new Error(`matmul shape mismatch: (${e},${n}) @ (${o},${a})`);let c=$(r.dtype,t.dtype),u=c.startsWith("int")||c.startsWith("uint")||c==="bool"?"float64":c;if(u!=="float64")throw new Error(`matmul currently only supports float64, got ${u}`);let s=r.dtype==="float64"?r.data:Float64Array.from(Array.from(r.data).map(Number)),i=t.dtype==="float64"?t.data:Float64Array.from(Array.from(t.data).map(Number));r.offset>0&&(s=s.subarray(r.offset)),t.offset>0&&(i=i.subarray(t.offset));let[l=0,f=0]=r.strides,[p=0,m=0]=t.strides,y=f>l,d=m>p,A=y?"transpose":"no-transpose",h=d?"transpose":"no-transpose",g,b;y?g=f:g=l,d?b=m:b=p;let S=D.zeros([e,a],"float64");return _o("row-major",A,h,e,a,n,1,s,g,i,b,0,S.data,a),S}function Zt(r){if(r.ndim!==2)throw new Error(`trace requires 2D array, got ${r.ndim}D`);let[t=0,e=0]=r.shape,n=Math.min(t,e),o=0;for(let a=0;a<n;a++){let c=r.get(a,a);typeof c=="bigint"?o=(typeof o=="bigint"?o:BigInt(o))+c:o=(typeof o=="bigint"?Number(o):o)+c}return o}function Wt(r,t){let e=r.ndim,n=t.ndim,o=r.shape[e-1],a=t.shape[n-1];if(o!==a)throw new Error(`inner: incompatible shapes - last dimensions ${o} and ${a} don't match`);if(e===1&&n===1)return Lr(r,t);let c=[...r.shape.slice(0,-1),...t.shape.slice(0,-1)],u=$(r.dtype,t.dtype),s=D.zeros(c,u),i=e===1?1:r.shape.slice(0,-1).reduce((p,m)=>p*m,1),l=n===1?1:t.shape.slice(0,-1).reduce((p,m)=>p*m,1),f=o;for(let p=0;p<i;p++)for(let m=0;m<l;m++){let y=0;for(let A=0;A<f;A++){let h=e===1?A:p*f+A,g=n===1?A:m*f+A,b=r.data[h+r.offset],S=t.data[g+t.offset];typeof b=="bigint"&&typeof S=="bigint"?y=Number(y)+Number(b*S):y+=Number(b)*Number(S)}if(c.length===0)return y;let d=i===1?m:p*l+m;s.data[d]=y}return s}function Ht(r,t){let e=r.ndim===1?r:nr(r),n=t.ndim===1?t:nr(t),o=e.size,a=n.size,c=$(r.dtype,t.dtype),u=D.zeros([o,a],c);for(let s=0;s<o;s++)for(let i=0;i<a;i++){let l=e.get(s),f=n.get(i),p;typeof l=="bigint"&&typeof f=="bigint"?p=l*f:p=Number(l)*Number(f),u.set([s,i],p)}return u}function Gt(r,t,e){let n,o;if(typeof e=="number"){let p=e;if(p<0)throw new Error("tensordot: axes must be non-negative");if(p>r.ndim||p>t.ndim)throw new Error("tensordot: axes exceeds array dimensions");n=Array.from({length:p},(m,y)=>r.ndim-p+y),o=Array.from({length:p},(m,y)=>y)}else if([n,o]=e,n.length!==o.length)throw new Error("tensordot: axes lists must have same length");for(let p=0;p<n.length;p++){let m=n[p],y=o[p];if(m<0||m>=r.ndim||y<0||y>=t.ndim)throw new Error("tensordot: axis out of bounds");if(r.shape[m]!==t.shape[y])throw new Error(`tensordot: shape mismatch on axes ${m} and ${y}: ${r.shape[m]} != ${t.shape[y]}`)}let a=[],c=[];for(let p=0;p<r.ndim;p++)n.includes(p)||a.push(p);for(let p=0;p<t.ndim;p++)o.includes(p)||c.push(p);let u=[...a.map(p=>r.shape[p]),...c.map(p=>t.shape[p])];if(u.length===0){let p=0,m=n.map(y=>r.shape[y]).reduce((y,d)=>y*d,1);for(let y=0;y<m;y++){let d=y,A=new Array(n.length);for(let x=n.length-1;x>=0;x--){let N=n[x];A[x]=d%r.shape[N],d=Math.floor(d/r.shape[N])}let h=new Array(r.ndim),g=new Array(t.ndim);for(let x=0;x<n.length;x++)h[n[x]]=A[x];for(let x=0;x<o.length;x++)g[o[x]]=A[x];let b=r.get(...h),S=t.get(...g);typeof b=="bigint"&&typeof S=="bigint"?p=Number(p)+Number(b*S):p+=Number(b)*Number(S)}return p}let s=$(r.dtype,t.dtype),i=D.zeros(u,s),l=u.reduce((p,m)=>p*m,1),f=n.map(p=>r.shape[p]).reduce((p,m)=>p*m,1);for(let p=0;p<l;p++){let m=p,y=[];for(let g=u.length-1;g>=0;g--)y[g]=m%u[g],m=Math.floor(m/u[g]);let d=y.slice(0,a.length),A=y.slice(a.length),h=0;for(let g=0;g<f;g++){m=g;let b=[];for(let I=n.length-1;I>=0;I--){let U=n[I];b[I]=m%r.shape[U],m=Math.floor(m/r.shape[U])}let S=new Array(r.ndim),x=new Array(t.ndim);for(let I=0;I<a.length;I++)S[a[I]]=d[I];for(let I=0;I<c.length;I++)x[c[I]]=A[I];for(let I=0;I<n.length;I++)S[n[I]]=b[I],x[o[I]]=b[I];let N=r.get(...S),O=t.get(...x);typeof N=="bigint"&&typeof O=="bigint"?h=Number(h)+Number(N*O):h+=Number(N)*Number(O)}i.set(y,h)}return i}var Yt=_(()=>{"use strict";P();k();Rr()});function Jt(r){return M(r,Math.sqrt,!1)}function Xt(r,t){return typeof t=="number"?To(r,t):V(r,t,Math.pow,"power")}function To(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,s=e!=="float32"&&e!=="float64"&&(t<0||!Number.isInteger(t))?"float64":e,i=D.zeros(n,s),l=i.data;if(w(e))if(w(s)&&Number.isInteger(t)&&t>=0){let f=o,p=l;for(let m=0;m<a;m++)p[m]=f[m]**BigInt(t)}else for(let f=0;f<a;f++)l[f]=Math.pow(Number(o[f]),t);else for(let f=0;f<a;f++)l[f]=Math.pow(Number(o[f]),t);return i}var Qt=_(()=>{"use strict";P();G();k()});function Kt(r){return M(r,Math.sin,!1)}function re(r){return M(r,Math.cos,!1)}function te(r){return M(r,Math.tan,!1)}function ee(r){return M(r,Math.asin,!1)}function ne(r){return M(r,Math.acos,!1)}function oe(r){return M(r,Math.atan,!1)}function ae(r,t){return typeof t=="number"?Mo(r,t):$o(r,t)}function $o(r,t){let e=Array.from(r.shape),n=r.size,o=r.dtype,a=t.dtype,c=o==="float32"&&a==="float32"?"float32":"float64",u=D.zeros(e,c),s=u.data;for(let i=0;i<n;i++){let l=(w(o),Number(r.data[i])),f=(w(a),Number(t.data[i]));s[i]=Math.atan2(l,f)}return u}function Mo(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=e==="float32"?"float32":"float64",u=D.zeros(n,c),s=u.data;if(w(e))for(let i=0;i<a;i++)s[i]=Math.atan2(Number(o[i]),t);else for(let i=0;i<a;i++)s[i]=Math.atan2(Number(o[i]),t);return u}function se(r,t){return typeof t=="number"?Co(r,t):vo(r,t)}function vo(r,t){let e=Array.from(r.shape),n=r.size,o=r.dtype,a=t.dtype,c=o==="float32"&&a==="float32"?"float32":"float64",u=D.zeros(e,c),s=u.data;for(let i=0;i<n;i++){let l=(w(o),Number(r.data[i])),f=(w(a),Number(t.data[i]));s[i]=Math.hypot(l,f)}return u}function Co(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,c=e==="float32"?"float32":"float64",u=D.zeros(n,c),s=u.data;if(w(e))for(let i=0;i<a;i++)s[i]=Math.hypot(Number(o[i]),t);else for(let i=0;i<a;i++)s[i]=Math.hypot(Number(o[i]),t);return u}function ie(r){let t=180/Math.PI;return M(r,e=>e*t,!1)}function ue(r){let t=Math.PI/180;return M(r,e=>e*t,!1)}var ce=_(()=>{"use strict";P();G();k()});function le(r){return M(r,Math.sinh,!1)}function fe(r){return M(r,Math.cosh,!1)}function pe(r){return M(r,Math.tanh,!1)}function ye(r){return M(r,Math.asinh,!1)}function me(r){return M(r,Math.acosh,!1)}function de(r){return M(r,Math.atanh,!1)}var ge=_(()=>{"use strict";G()});function dr(r){if(r.length===0)return[];if(r.length===1)return Array.from(r[0]);let t=Math.max(...r.map(n=>n.length)),e=new Array(t);for(let n=0;n<t;n++){let o=1;for(let a of r){let c=a.length-t+n,u=c<0?1:a[c];if(u!==1){if(o===1)o=u;else if(o!==u)return null}}e[n]=o}return e}function Vo(r,t,e){let n=r.length,o=e.length,a=new Array(o).fill(0);for(let c=0;c<n;c++){let u=o-n+c,s=r[c],i=e[u];if(s===i)a[u]=t[c];else if(s===1)a[u]=0;else throw new Error("Invalid broadcast")}return a}function or(r,t){let e=Vo(r.shape,r.strides,t);return D.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}var he=_(()=>{"use strict";P()});function Ae(r,t){let e=r.shape,n=e.length,o=t.length;if(o<n)throw new Error("input operand has more dimensions than allowed by the axis remapping");let a=dr([Array.from(e),t]);if(a===null)throw new Error(`operands could not be broadcast together with shape (${e.join(",")}) (${t.join(",")})`);for(let c=0;c<o;c++)if(a[c]!==t[c])throw new Error(`operands could not be broadcast together with shape (${e.join(",")}) (${t.join(",")})`);return or(r,t)}function be(r){if(r.length===0)return[];if(r.length===1)return[r[0]];let t=r.map(n=>Array.from(n.shape)),e=dr(t);if(e===null)throw new Error(`operands could not be broadcast together with shapes ${t.map(n=>`(${n.join(",")})`).join(" ")}`);return r.map(n=>or(n,e))}function Se(r,t,e){let n=r.shape,o=n.length,a=r.dtype;if(e===void 0){let y=r.size;for(let g of t){let b=g<0?y+g:g;if(b<0||b>=y)throw new Error(`index ${g} is out of bounds for axis 0 with size ${y}`)}let d=t.length,A=B(a);if(!A)throw new Error(`Cannot take from array with dtype ${a}`);let h=new A(d);for(let g=0;g<d;g++){let b=t[g];b<0&&(b=y+b);let S=r.iget(b);w(a),h[g]=S}return D.fromData(h,[d],a)}let c=e<0?o+e:e;if(c<0||c>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let u=n[c];for(let y of t){let d=y<0?u+y:y;if(d<0||d>=u)throw new Error(`index ${y} is out of bounds for axis ${c} with size ${u}`)}let s=Array.from(n);s[c]=t.length;let i=s.reduce((y,d)=>y*d,1),l=B(a);if(!l)throw new Error(`Cannot take from array with dtype ${a}`);let f=new l(i),p=q(s),m=new Array(o).fill(0);for(let y=0;y<i;y++){let d=[...m],A=m[c],h=t[A];h<0&&(h=u+h),d[c]=h;let g=r.get(...d),b=0;for(let S=0;S<o;S++)b+=m[S]*p[S];w(a),f[b]=g;for(let S=o-1;S>=0&&(m[S]++,!(m[S]<s[S]));S--)m[S]=0}return D.fromData(f,s,a)}function De(r,t,e){let n=r.size,o=r.dtype,a;if(typeof e=="number"||typeof e=="bigint")a=new Array(t.length).fill(e);else{a=[];for(let c=0;c<e.size;c++)a.push(e.iget(c));if(a.length===1)a=new Array(t.length).fill(a[0]);else if(a.length!==t.length){let c=[...a];a=[];for(let u=0;u<t.length;u++)a.push(c[u%c.length])}}for(let c=0;c<t.length;c++){let u=t[c];if(u<0&&(u=n+u),u<0||u>=n)throw new Error(`index ${t[c]} is out of bounds for axis 0 with size ${n}`);let s=a[c];w(o)?typeof s!="bigint"&&(s=BigInt(Math.round(Number(s)))):typeof s=="bigint"&&(s=Number(s)),r.iset(u,s)}}function we(r,t){if(t.length===0)throw new Error("choices cannot be empty");let e=r.shape,n=t.length,o=t[0].dtype,a=t.map(p=>Array.from(p.shape));a.unshift(Array.from(e));let c=dr(a);if(c===null)throw new Error("operands could not be broadcast together");let u=or(r,c),s=t.map(p=>or(p,c)),i=c.reduce((p,m)=>p*m,1),l=B(o);if(!l)throw new Error(`Cannot choose with dtype ${o}`);let f=new l(i);for(let p=0;p<i;p++){let m=Number(u.iget(p));if(m<0||m>=n)throw new Error(`index ${m} is out of bounds for axis 0 with size ${n}`);let y=s[m].iget(p);w(o),f[p]=y}return D.fromData(f,c,o)}function Ne(r,t,e=!1){if(r.ndim!==t.ndim)return!1;for(let o=0;o<r.ndim;o++)if(r.shape[o]!==t.shape[o])return!1;let n=r.size;for(let o=0;o<n;o++){let a=r.iget(o),c=t.iget(o);if(e){let u=typeof a=="number"&&Number.isNaN(a),s=typeof c=="number"&&Number.isNaN(c);if(u&&s)continue}if(a!==c)return!1}return!0}var xe=_(()=>{"use strict";P();k();he()});function ar(r,t=v){let e=D.zeros(r,t);return new z(e)}function jr(r,t=v){let e=D.ones(r,t);return new z(e)}function Ro(r){let t=[],e=r;for(;Array.isArray(e);)t.push(e.length),e=e[0];return t}function Ie(r){return typeof r=="bigint"?!0:Array.isArray(r)?r.some(t=>Ie(t)):!1}function Lo(r){let t=[];function e(n){Array.isArray(n)?n.forEach(o=>e(o)):t.push(n)}return e(r),t}function R(r,t){if(r instanceof z)return!t||r.dtype===t?r.copy():r.astype(t);let e=Ie(r),n=Ro(r),o=n.reduce((l,f)=>l*f,1),a=t;a||(e?a="int64":a=v);let c=B(a);if(!c)throw new Error(`Cannot create array with dtype ${a}`);let u=new c(o),s=Lo(r);if(w(a)){let l=u;for(let f=0;f<o;f++){let p=s[f];l[f]=typeof p=="bigint"?p:BigInt(Math.round(Number(p)))}}else if(a==="bool"){let l=u;for(let f=0;f<o;f++)l[f]=s[f]?1:0}else{let l=u;for(let f=0;f<o;f++){let p=s[f];l[f]=Number(p)}}let i=D.fromData(u,n,a);return new z(i)}function ze(r,t,e=1,n=v){let o=r,a=t;if(t===void 0&&(o=0,a=r),a===void 0)throw new Error("stop is required");let c=Math.max(0,Math.ceil((a-o)/e)),u=B(n);if(!u)throw new Error(`Cannot create arange array with dtype ${n}`);let s=new u(c);if(w(n))for(let l=0;l<c;l++)s[l]=BigInt(Math.round(o+l*e));else if(n==="bool")for(let l=0;l<c;l++)s[l]=o+l*e!==0?1:0;else for(let l=0;l<c;l++)s[l]=o+l*e;let i=D.fromData(s,[c],n);return new z(i)}function Be(r,t,e=50,n=v){if(e<0)throw new Error("num must be non-negative");if(e===0)return R([],n);if(e===1)return R([r],n);let o=B(n);if(!o)throw new Error(`Cannot create linspace array with dtype ${n}`);let a=new o(e),c=(t-r)/(e-1);if(w(n))for(let s=0;s<e;s++)a[s]=BigInt(Math.round(r+s*c));else if(n==="bool")for(let s=0;s<e;s++)a[s]=r+s*c!==0?1:0;else for(let s=0;s<e;s++)a[s]=r+s*c;let u=D.fromData(a,[e],n);return new z(u)}function Ue(r,t,e=50,n=10,o=v){if(e<0)throw new Error("num must be non-negative");if(e===0)return R([],o);if(e===1)return R([Math.pow(n,r)],o);let a=B(o);if(!a)throw new Error(`Cannot create logspace array with dtype ${o}`);let c=new a(e),u=(t-r)/(e-1);if(w(o))for(let i=0;i<e;i++){let l=r+i*u;c[i]=BigInt(Math.round(Math.pow(n,l)))}else if(o==="bool")for(let i=0;i<e;i++){let l=r+i*u;c[i]=Math.pow(n,l)!==0?1:0}else for(let i=0;i<e;i++){let l=r+i*u;c[i]=Math.pow(n,l)}let s=D.fromData(c,[e],o);return new z(s)}function _e(r,t,e=50,n=v){if(e<0)throw new Error("num must be non-negative");if(r===0||t===0)throw new Error("Geometric sequence cannot include zero");if(e===0)return R([],n);if(e===1)return R([r],n);let o=Math.sign(r),a=Math.sign(t);if(o!==a)throw new Error("Geometric sequence cannot contain both positive and negative values");let c=B(n);if(!c)throw new Error(`Cannot create geomspace array with dtype ${n}`);let u=new c(e),s=Math.log(Math.abs(r)),l=(Math.log(Math.abs(t))-s)/(e-1);if(w(n))for(let p=0;p<e;p++){let m=o*Math.exp(s+p*l);u[p]=BigInt(Math.round(m))}else if(n==="bool")for(let p=0;p<e;p++){let m=o*Math.exp(s+p*l);u[p]=m!==0?1:0}else for(let p=0;p<e;p++){let m=o*Math.exp(s+p*l);u[p]=m}let f=D.fromData(u,[e],n);return new z(f)}function Zr(r,t,e=0,n=v){let o=t??r,a=ar([r,o],n),c=a.data;if(w(n)){let u=c;for(let s=0;s<r;s++){let i=s+e;i>=0&&i<o&&(u[s*o+i]=BigInt(1))}}else{let u=c;for(let s=0;s<r;s++){let i=s+e;i>=0&&i<o&&(u[s*o+i]=1)}}return a}function Wr(r,t=v){return ar(r,t)}function Hr(r,t,e){let n=e;n||(typeof t=="bigint"?n="int64":typeof t=="boolean"?n="bool":Number.isInteger(t)?n="int32":n=v);let o=B(n);if(!o)throw new Error(`Cannot create full array with dtype ${n}`);let a=r.reduce((s,i)=>s*i,1),c=new o(a);if(w(n)){let s=typeof t=="bigint"?t:BigInt(Math.round(Number(t)));c.fill(s)}else n==="bool"?c.fill(t?1:0):c.fill(Number(t));let u=D.fromData(c,r,n);return new z(u)}function Ee(r,t=v){return Zr(r,r,0,t)}function Te(r,t){return r instanceof z?!t||r.dtype===t?r:r.astype(t):R(r,t)}function Oe(r){return r.copy()}function $e(r,t){return ar(Array.from(r.shape),t??r.dtype)}function Me(r,t){return jr(Array.from(r.shape),t??r.dtype)}function ve(r,t){return Wr(Array.from(r.shape),t??r.dtype)}function Ce(r,t,e){return Hr(Array.from(r.shape),t,e??r.dtype)}function ke(r){return r.sqrt()}function Pe(r,t){return r.power(t)}function Ve(r){return r.absolute()}function Fe(r){return r.negative()}function Re(r){return r.sign()}function Le(r,t){return r.mod(t)}function qe(r,t){return r.floor_divide(t)}function je(r){return r.positive()}function Ze(r){return r.reciprocal()}function We(r,t){return r.dot(t)}function He(r){return r.trace()}function Ge(r,t){return r.transpose(t)}function Ye(r,t){return r.inner(t)}function Je(r,t){return r.outer(t)}function Xe(r,t,e=2){return r.tensordot(t,e)}function Qe(r){return r.sin()}function Ke(r){return r.cos()}function rn(r){return r.tan()}function tn(r){return r.arcsin()}function en(r){return r.arccos()}function nn(r){return r.arctan()}function on(r,t){return r.arctan2(t)}function an(r,t){return r.hypot(t)}function sn(r){return r.degrees()}function un(r){return r.radians()}function cn(r){return r.sinh()}function ln(r){return r.cosh()}function fn(r){return r.tanh()}function pn(r){return r.arcsinh()}function yn(r){return r.arccosh()}function mn(r){return r.arctanh()}function dn(r,t,e){return r.swapaxes(t,e)}function gn(r,t,e){return r.moveaxis(t,e)}function hn(r,t=0){if(r.length===0)throw new Error("need at least one array to concatenate");let e=r.map(o=>o.storage),n=W(e,t);return z._fromStorage(n)}function An(r,t=0){if(r.length===0)throw new Error("need at least one array to stack");let e=r.map(o=>o.storage),n=Mt(e,t);return z._fromStorage(n)}function bn(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=vt(t);return z._fromStorage(e)}function Sn(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Ct(t);return z._fromStorage(e)}function Dn(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=kt(t);return z._fromStorage(e)}function wn(r,t,e=0){return Pt(r.storage,t,e).map(o=>z._fromStorage(o,r.base??r))}function Nn(r,t,e=0){return mr(r.storage,t,e).map(o=>z._fromStorage(o,r.base??r))}function xn(r,t){return Ft(r.storage,t).map(n=>z._fromStorage(n,r.base??r))}function In(r,t){return Rt(r.storage,t).map(n=>z._fromStorage(n,r.base??r))}function zn(r,t){let e=Lt(r.storage,t);return z._fromStorage(e)}function Bn(r,t,e){return r.repeat(t,e)}function Un(r,t){let e=Ae(r.storage,t);return z._fromStorage(e,r.base??r)}function _n(...r){let t=r.map(n=>n.storage);return be(t).map((n,o)=>z._fromStorage(n,r[o].base??r[o]))}function En(r,t,e){return r.take(t,e)}function Tn(r,t,e){r.put(t,e)}function On(r,t){let e=t.map(o=>o.storage),n=we(r.storage,e);return z._fromStorage(n)}function $n(r,t,e=!1){return Ne(r.storage,t.storage,e)}var z,Gr=_(()=>{"use strict";ot();k();P();bt();Bt();Et();Rr();Yt();Qt();ce();ge();xe();z=class r{constructor(t,e){this._storage=t,this._base=e}get storage(){return this._storage}static _fromStorage(t,e){return new r(t,e)}get shape(){return this._storage.shape}get ndim(){return this._storage.ndim}get size(){return this._storage.size}get dtype(){return this._storage.dtype}get data(){return this._storage.data}get strides(){return this._storage.strides}get flags(){return{C_CONTIGUOUS:this._storage.isCContiguous,F_CONTIGUOUS:this._storage.isFContiguous,OWNDATA:this._base===void 0}}get base(){return this._base??null}get(t){if(t.length!==this.ndim)throw new Error(`Index has ${t.length} dimensions, but array has ${this.ndim} dimensions`);let e=t.map((n,o)=>{let a=n;if(a<0&&(a=this.shape[o]+a),a<0||a>=this.shape[o])throw new Error(`Index ${n} is out of bounds for axis ${o} with size ${this.shape[o]}`);return a});return this._storage.get(...e)}set(t,e){if(t.length!==this.ndim)throw new Error(`Index has ${t.length} dimensions, but array has ${this.ndim} dimensions`);let n=t.map((c,u)=>{let s=c;if(s<0&&(s=this.shape[u]+s),s<0||s>=this.shape[u])throw new Error(`Index ${c} is out of bounds for axis ${u} with size ${this.shape[u]}`);return s}),o=this.dtype,a;w(o)?a=typeof e=="bigint"?e:BigInt(Math.round(e)):o==="bool"?a=e?1:0:a=Number(e),this._storage.set(n,a)}copy(){return new r(this._storage.copy())}astype(t,e=!0){let n=this.dtype;if(n===t&&!e)return this;if(n===t&&e)return this.copy();let o=Array.from(this.shape),a=this.size,c=B(t);if(!c)throw new Error(`Cannot convert to dtype ${t}`);let u=new c(a),s=this.data;if(w(n)&&!w(t)){let l=s;if(t==="bool")for(let f=0;f<a;f++)u[f]=l[f]!==BigInt(0)?1:0;else for(let f=0;f<a;f++)u[f]=Number(l[f])}else if(!w(n)&&w(t)){let l=s;for(let f=0;f<a;f++)u[f]=BigInt(Math.round(Number(l[f])))}else if(t==="bool"){let l=s;for(let f=0;f<a;f++)u[f]=l[f]!==0?1:0}else if(n==="bool"&&!w(t)){let l=s;for(let f=0;f<a;f++)u[f]=l[f]}else if(!w(n)&&!w(t)){let l=s;for(let f=0;f<a;f++)u[f]=l[f]}else{let l=s;for(let f=0;f<a;f++)u[f]=l[f]}let i=D.fromData(u,o,t);return new r(i)}add(t){let e=typeof t=="number"?t:t._storage,n=ut(this._storage,e);return r._fromStorage(n)}subtract(t){let e=typeof t=="number"?t:t._storage,n=ct(this._storage,e);return r._fromStorage(n)}multiply(t){let e=typeof t=="number"?t:t._storage,n=lt(this._storage,e);return r._fromStorage(n)}divide(t){let e=typeof t=="number"?t:t._storage,n=ft(this._storage,e);return r._fromStorage(n)}mod(t){let e=typeof t=="number"?t:t._storage,n=dt(this._storage,e);return r._fromStorage(n)}floor_divide(t){let e=typeof t=="number"?t:t._storage,n=gt(this._storage,e);return r._fromStorage(n)}positive(){let t=ht(this._storage);return r._fromStorage(t)}reciprocal(){let t=At(this._storage);return r._fromStorage(t)}sqrt(){let t=Jt(this._storage);return r._fromStorage(t)}power(t){let e=typeof t=="number"?t:t._storage,n=Xt(this._storage,e);return r._fromStorage(n)}absolute(){let t=pt(this._storage);return r._fromStorage(t)}negative(){let t=yt(this._storage);return r._fromStorage(t)}sign(){let t=mt(this._storage);return r._fromStorage(t)}sin(){let t=Kt(this._storage);return r._fromStorage(t)}cos(){let t=re(this._storage);return r._fromStorage(t)}tan(){let t=te(this._storage);return r._fromStorage(t)}arcsin(){let t=ee(this._storage);return r._fromStorage(t)}arccos(){let t=ne(this._storage);return r._fromStorage(t)}arctan(){let t=oe(this._storage);return r._fromStorage(t)}arctan2(t){let e=typeof t=="number"?t:t._storage,n=ae(this._storage,e);return r._fromStorage(n)}hypot(t){let e=typeof t=="number"?t:t._storage,n=se(this._storage,e);return r._fromStorage(n)}degrees(){let t=ie(this._storage);return r._fromStorage(t)}radians(){let t=ue(this._storage);return r._fromStorage(t)}sinh(){let t=le(this._storage);return r._fromStorage(t)}cosh(){let t=fe(this._storage);return r._fromStorage(t)}tanh(){let t=pe(this._storage);return r._fromStorage(t)}arcsinh(){let t=ye(this._storage);return r._fromStorage(t)}arccosh(){let t=me(this._storage);return r._fromStorage(t)}arctanh(){let t=de(this._storage);return r._fromStorage(t)}greater(t){let e=typeof t=="number"?t:t._storage,n=St(this._storage,e);return r._fromStorage(n)}greater_equal(t){let e=typeof t=="number"?t:t._storage,n=Dt(this._storage,e);return r._fromStorage(n)}less(t){let e=typeof t=="number"?t:t._storage,n=wt(this._storage,e);return r._fromStorage(n)}less_equal(t){let e=typeof t=="number"?t:t._storage,n=Nt(this._storage,e);return r._fromStorage(n)}equal(t){let e=typeof t=="number"?t:t._storage,n=xt(this._storage,e);return r._fromStorage(n)}not_equal(t){let e=typeof t=="number"?t:t._storage,n=It(this._storage,e);return r._fromStorage(n)}isclose(t,e=1e-5,n=1e-8){let o=typeof t=="number"?t:t._storage,a=Er(this._storage,o,e,n);return r._fromStorage(a)}allclose(t,e=1e-5,n=1e-8){let o=typeof t=="number"?t:t._storage;return zt(this._storage,o,e,n)}sum(t,e=!1){let n=tr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}mean(t,e=!1){let n=Tr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}max(t,e=!1){let n=Or(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}min(t,e=!1){let n=Mr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}prod(t,e=!1){let n=$r(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}argmin(t){let e=vr(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}argmax(t){let e=Cr(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}var(t,e=0,n=!1){let o=kr(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}std(t,e=0,n=!1){let o=_t(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}all(t,e=!1){let n=Pr(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}any(t,e=!1){let n=Vr(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}reshape(...t){let e=t.length===1&&Array.isArray(t[0])?t[0]:t,n=J(this._storage,e),a=n.data===this.data?this._base??this:void 0;return r._fromStorage(n,a)}flatten(){let t=Fr(this._storage);return r._fromStorage(t)}ravel(){let t=nr(this._storage),n=t.data===this.data?this._base??this:void 0;return r._fromStorage(t,n)}transpose(t){let e=yr(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}squeeze(t){let e=Tt(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}expand_dims(t){let e=er(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}swapaxes(t,e){let n=Ot(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}moveaxis(t,e){let n=$t(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}repeat(t,e){let n=qt(this._storage,t,e);return r._fromStorage(n)}take(t,e){let n=Se(this._storage,t,e);return r._fromStorage(n)}put(t,e){let n=e instanceof r?e._storage:e;De(this._storage,t,n)}matmul(t){let e=qr(this._storage,t._storage);return r._fromStorage(e)}dot(t){let e=Lr(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"?e:r._fromStorage(e)}trace(){return Zt(this._storage)}inner(t){let e=Wt(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"?e:r._fromStorage(e)}outer(t){let e=Ht(this._storage,t._storage);return r._fromStorage(e)}tensordot(t,e=2){let n=Gt(this._storage,t._storage,e);return typeof n=="number"||typeof n=="bigint"?n:r._fromStorage(n)}slice(...t){if(t.length===0)return this;if(t.length>this.ndim)throw new Error(`Too many indices for array: array is ${this.ndim}-dimensional, but ${t.length} were indexed`);let e=t.map((s,i)=>{let l=et(s);return nt(l,this.shape[i])});for(;e.length<this.ndim;)e.push({start:0,stop:this.shape[e.length],step:1,isIndex:!1});let n=[],o=[],a=this._storage.offset;for(let s=0;s<e.length;s++){let i=e[s],l=this._storage.strides[s];if(a+=i.start*l,!i.isIndex){let f;i.step>0?f=Math.max(0,Math.ceil((i.stop-i.start)/i.step)):f=Math.max(0,Math.ceil((i.start-i.stop)/Math.abs(i.step))),n.push(f),o.push(l*i.step)}}let c=D.fromData(this._storage.data,n,this._storage.dtype,o,a),u=this._base??this;return new r(c,u)}row(t){if(this.ndim<2)throw new Error("row() requires at least 2 dimensions");return this.slice(String(t),":")}col(t){if(this.ndim<2)throw new Error("col() requires at least 2 dimensions");return this.slice(":",String(t))}rows(t,e){if(this.ndim<2)throw new Error("rows() requires at least 2 dimensions");return this.slice(`${t}:${e}`,":")}cols(t,e){if(this.ndim<2)throw new Error("cols() requires at least 2 dimensions");return this.slice(":",`${t}:${e}`)}toString(){return`NDArray(shape=${JSON.stringify(this.shape)}, dtype=${this.dtype})`}toArray(){if(this.ndim===0)return this._storage.iget(0);let t=this.shape,e=t.length,n=(o,a)=>{if(a===e)return this._storage.get(...o);let c=[];for(let u=0;u<t[a];u++)o[a]=u,c.push(n(o,a+1));return c};return n(new Array(e),0)}}});function Yr(){let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256}function vn(r){if(r.startsWith("[")||r.startsWith("("))throw new F(`Structured/compound dtypes are not supported: ${r}`);let t="",e=r;(r[0]==="<"||r[0]===">"||r[0]==="="||r[0]==="|")&&(t=r[0],e=r.slice(1));let n=e[0];if(n&&n in Mn)throw new F(`Unsupported dtype: ${Mn[n]} (${r}). Use the 'force' parameter to skip arrays with unsupported dtypes.`);let o=qo[e];if(!o)throw new F(`Unknown or unsupported dtype descriptor: ${r}. Supported types: ${gr.join(", ")}. Use the 'force' parameter to skip arrays with unsupported dtypes.`);let a=Yr(),c=t==="<"||t==="|"||t==="="&&a,u=t===">"||t==="="&&!a,s=parseInt(e.slice(1),10),i=s>1&&(u&&a||c&&!a);return{dtype:o,needsByteSwap:i,itemsize:s}}var sr,gr,qo,ir,Mn,F,C,ur=_(()=>{"use strict";sr=new Uint8Array([147,78,85,77,80,89]),gr=["float64","float32","int64","int32","int16","int8","uint64","uint32","uint16","uint8","bool"];qo={f8:"float64",f4:"float32",i8:"int64",i4:"int32",i2:"int16",i1:"int8",u8:"uint64",u4:"uint32",u2:"uint16",u1:"uint8",b1:"bool"},ir={float64:"<f8",float32:"<f4",int64:"<i8",int32:"<i4",int16:"<i2",int8:"|i1",uint64:"<u8",uint32:"<u4",uint16:"<u2",uint8:"|u1",bool:"|b1"},Mn={c:"complex numbers",S:"byte strings",U:"Unicode strings",O:"Python objects",V:"structured arrays (void)",M:"datetime64",m:"timedelta64"};F=class extends Error{constructor(t){super(t),this.name="UnsupportedDTypeError"}},C=class extends Error{constructor(t){super(t),this.name="InvalidNpyError"}}});function Z(r){let t=r instanceof ArrayBuffer?new Uint8Array(r):r,e=hr(t);return Ar(t,e)}function hr(r){if(r.length<10)throw new C("File too small to be a valid NPY file");for(let i=0;i<sr.length;i++)if(r[i]!==sr[i])throw new C("Invalid NPY magic number");let t=r[6],e=r[7];if(t!==1&&t!==2&&t!==3)throw new C(`Unsupported NPY version: ${t}.${e}`);let n,o;t===1?(n=r[8]|r[9]<<8,o=10):(n=r[8]|r[9]<<8|r[10]<<16|r[11]<<24,o=12);let a=o+n;if(r.length<a)throw new C("File truncated: header extends beyond file");let c=r.slice(o,a),u=new TextDecoder("utf-8").decode(c).trim(),s=jo(u);return{version:{major:t,minor:e},header:s,dataOffset:a}}function Ar(r,t){let{header:e,dataOffset:n}=t,{dtype:o,needsByteSwap:a,itemsize:c}=vn(e.descr),u=e.shape.reduce((d,A)=>d*A,1),s=u*c,i=r.length-n;if(i<s)throw new C(`File truncated: expected ${s} bytes of data, got ${i}`);let l=new ArrayBuffer(s);new Uint8Array(l).set(r.subarray(n,n+s));let p=Zo(l,o,u,a,c),m=e.shape,y;if(e.fortran_order&&m.length>1){let d=[...m].reverse(),A=D.fromData(p,d,o);y=Wo(A,d),m=e.shape}else y=D.fromData(p,[...m],o);return new z(y)}function jo(r){let t=r.match(/'descr'\s*:\s*'([^']+)'/),e=r.match(/'fortran_order'\s*:\s*(True|False)/),n=r.match(/'shape'\s*:\s*\(([^)]*)\)/);if(!t||!e||!n)throw new C(`Failed to parse NPY header: ${r}`);let o=t[1],a=e[1]==="True",c=n[1].trim(),u;return c===""?u=[]:u=c.split(",").map(s=>s.trim()).filter(s=>s!=="").map(s=>{let i=parseInt(s,10);if(isNaN(i))throw new C(`Invalid shape value: ${s}`);return i}),{descr:o,fortran_order:a,shape:u}}function Zo(r,t,e,n,o){let a=B(t);if(!a)throw new C(`Cannot create array for dtype: ${t}`);if(!n)return new a(r,0,e);let c=new Uint8Array(r),u=new Uint8Array(r.byteLength);for(let s=0;s<e;s++){let i=s*o;for(let l=0;l<o;l++)u[i+l]=c[i+o-1-l]}return new a(u.buffer,0,e)}function Wo(r,t){let e=t.length,n=r.size,o=r.dtype,a=B(o);if(!a)throw new C(`Cannot create array for dtype: ${o}`);let c=new a(n),u=[...t].reverse(),s=Cn(t),i=Cn(u),l=new Array(e).fill(0);for(let f=0;f<n;f++){let p=f;for(let y=0;y<e;y++){let d=s[y];l[y]=Math.floor(p/d),p=p%d}let m=0;for(let y=0;y<e;y++)m+=l[e-1-y]*i[y];w(o),c[m]=r.iget(f)}return D.fromData(c,u,o)}function Cn(r){let t=new Array(r.length),e=1;for(let n=r.length-1;n>=0;n--)t[n]=e,e*=r[n];return t}var br=_(()=>{"use strict";Gr();P();k();ur()});function L(r){let t=r.shape,e=r.dtype,n=ir[e],o=t.length===0?"()":t.length===1?`(${t[0]},)`:`(${t.join(", ")})`,a=`{'descr': '${n}', 'fortran_order': False, 'shape': ${o}, }`,c=12,s=(64-(c+a.length+1)%64)%64;a=a+" ".repeat(s)+`
2
- `;let i=new TextEncoder().encode(a),l=i.length,f=r.size,p=st(e),m=f*p,y=c+l+m,d=new Uint8Array(y);d.set(sr,0),d[6]=3,d[7]=0,d[8]=l&255,d[9]=l>>8&255,d[10]=l>>16&255,d[11]=l>>24&255,d.set(i,c);let A=c+l;return Ho(r,d.subarray(A),p),d}function Ho(r,t,e){let n=r.dtype,o=r.size,a=Yr(),c=w(n),u=r._storage;if(u.isCContiguous&&u.offset===0&&a){let i=u.data,l=new Uint8Array(i.buffer,i.byteOffset,o*e);t.set(l)}else{let i=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let l=0;l<o;l++){let f=u.iget(l),p=l*e;c?Go(i,p,f,n==="uint64"):Yo(i,p,f,n)}}}function Go(r,t,e,n){n?r.setBigUint64(t,e,!0):r.setBigInt64(t,e,!0)}function Yo(r,t,e,n){switch(n){case"float64":r.setFloat64(t,e,!0);break;case"float32":r.setFloat32(t,e,!0);break;case"int32":r.setInt32(t,e,!0);break;case"int16":r.setInt16(t,e,!0);break;case"int8":r.setInt8(t,e);break;case"uint32":r.setUint32(t,e,!0);break;case"uint16":r.setUint16(t,e,!0);break;case"uint8":case"bool":r.setUint8(t,e);break;default:throw new Error(`Unsupported dtype for serialization: ${n}`)}}var Sr=_(()=>{"use strict";k();ur()});function Jr(r){let t=4294967295;for(let e=0;e<r.length;e++)t=Jo[(t^r[e])&255]^t>>>8;return(t^4294967295)>>>0}var Jo,Xr=_(()=>{"use strict";Jo=(()=>{let r=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;r[t]=e}return r})()});async function kn(r){let t=Vn(r),e=new Map;for(let n of t){let o=await Xo(n);e.set(n.name,o)}return e}function Pn(r){let t=Vn(r),e=new Map;for(let n of t){if(n.compressionMethod!==0)throw new Error(`Cannot read compressed entry synchronously: ${n.name}. Use readZip() (async) for DEFLATE-compressed files.`);e.set(n.name,n.compressedData)}return e}function Vn(r){let t=r instanceof ArrayBuffer?new Uint8Array(r):r,e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=[],o=-1;for(let i=t.length-22;i>=0;i--)if(e.getUint32(i,!0)===101010256){o=i;break}if(o===-1)throw new Error("Invalid ZIP file: end of central directory not found");let a=e.getUint32(o+16,!0),c=e.getUint16(o+10,!0),u=[],s=a;for(let i=0;i<c&&e.getUint32(s,!0)===33639248;i++){let f=e.getUint16(s+10,!0),p=e.getUint32(s+16,!0),m=e.getUint32(s+20,!0),y=e.getUint32(s+24,!0),d=e.getUint16(s+28,!0),A=e.getUint16(s+30,!0),h=e.getUint16(s+32,!0),g=e.getUint32(s+42,!0),b=t.slice(s+46,s+46+d),S=new TextDecoder("utf-8").decode(b);u.push({name:S,compressionMethod:f,crc32:p,compressedSize:m,uncompressedSize:y,localHeaderOffset:g}),s=s+46+d+A+h}for(let i of u){let l=i.localHeaderOffset;if(e.getUint32(l,!0)!==67324752)throw new Error(`Invalid local file header at offset ${l}`);let p=e.getUint16(l+26,!0),m=e.getUint16(l+28,!0),y=l+30+p+m,d=t.slice(y,y+i.compressedSize);n.push({name:i.name,compressedData:d,compressionMethod:i.compressionMethod,crc32:i.crc32,compressedSize:i.compressedSize,uncompressedSize:i.uncompressedSize})}return n}async function Xo(r){if(r.compressionMethod===0)return r.compressedData;if(r.compressionMethod===8)return await Qo(r.compressedData);throw new Error(`Unsupported compression method: ${r.compressionMethod}`)}async function Qo(r){if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available. This environment does not support the Compression Streams API. Please use a modern browser or Node.js 18+.");let t=new DecompressionStream("deflate-raw"),e=new Uint8Array(r.length);e.set(r);let n=t.writable.getWriter();n.write(e),n.close();let o=t.readable.getReader(),a=[];for(;;){let{done:i,value:l}=await o.read();if(i)break;a.push(l)}let c=a.reduce((i,l)=>i+l.length,0),u=new Uint8Array(c),s=0;for(let i of a)u.set(i,s),s+=i.length;return u}var Fn=_(()=>{"use strict";Xr()});var Ln={};Br(Ln,{loadNpz:()=>Dr,loadNpzSync:()=>wr,parseNpz:()=>H,parseNpzSync:()=>lr});async function H(r,t={}){let e=t.force??!1,n=await kn(r);return Rn(n,e)}function lr(r,t={}){let e=t.force??!1,n=Pn(r);return Rn(n,e)}function Rn(r,t){let e=new Map,n=[],o=new Map;for(let[a,c]of r){if(!a.endsWith(".npy"))continue;let u=a.slice(0,-4);try{let s=Z(c);e.set(u,s)}catch(s){if(s instanceof F&&t)n.push(u),o.set(u,s.message);else throw s}}return{arrays:e,skipped:n,errors:o}}async function Dr(r,t={}){let e=await H(r,t);return Object.fromEntries(e.arrays)}function wr(r,t={}){let e=lr(r,t);return Object.fromEntries(e.arrays)}var Nr=_(()=>{"use strict";br();ur();Fn()});async function qn(r,t={}){let e=t.compress??!1,n=[];for(let[p,m]of r){let y=Jr(m),d,A;e?(d=await ra(m),d.length<m.length?A=8:(d=m,A=0)):(d=m,A=0),n.push({name:p,data:m,compressedData:d,crc:y,compressionMethod:A,offset:0})}let o=0;for(let p of n){let m=new TextEncoder().encode(p.name);o+=30+m.length+p.compressedData.length}let a=0;for(let p of n){let m=new TextEncoder().encode(p.name);a+=46+m.length}let u=o+a+22,s=new Uint8Array(u),i=new DataView(s.buffer),l=0;for(let p of n)p.offset=l,l=Zn(s,i,l,p);let f=l;for(let p of n)l=Wn(s,i,l,p);return Hn(i,l,n.length,a,f),s}function jn(r){let t=[];for(let[l,f]of r){let p=Jr(f);t.push({name:l,data:f,compressedData:f,crc:p,compressionMethod:0,offset:0})}let e=0;for(let l of t){let f=new TextEncoder().encode(l.name);e+=30+f.length+l.compressedData.length}let n=0;for(let l of t){let f=new TextEncoder().encode(l.name);n+=46+f.length}let a=e+n+22,c=new Uint8Array(a),u=new DataView(c.buffer),s=0;for(let l of t)l.offset=s,s=Zn(c,u,s,l);let i=s;for(let l of t)s=Wn(c,u,s,l);return Hn(u,s,t.length,n,i),c}function Zn(r,t,e,n){let o=new TextEncoder().encode(n.name);return t.setUint32(e,67324752,!0),e+=4,t.setUint16(e,n.compressionMethod===8?20:10,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,n.compressionMethod,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,33,!0),e+=2,t.setUint32(e,n.crc,!0),e+=4,t.setUint32(e,n.compressedData.length,!0),e+=4,t.setUint32(e,n.data.length,!0),e+=4,t.setUint16(e,o.length,!0),e+=2,t.setUint16(e,0,!0),e+=2,r.set(o,e),e+=o.length,r.set(n.compressedData,e),e+=n.compressedData.length,e}function Wn(r,t,e,n){let o=new TextEncoder().encode(n.name);return t.setUint32(e,33639248,!0),e+=4,t.setUint16(e,20,!0),e+=2,t.setUint16(e,n.compressionMethod===8?20:10,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,n.compressionMethod,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,33,!0),e+=2,t.setUint32(e,n.crc,!0),e+=4,t.setUint32(e,n.compressedData.length,!0),e+=4,t.setUint32(e,n.data.length,!0),e+=4,t.setUint16(e,o.length,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint32(e,0,!0),e+=4,t.setUint32(e,n.offset,!0),e+=4,r.set(o,e),e+=o.length,e}function Hn(r,t,e,n,o){r.setUint32(t,101010256,!0),t+=4,r.setUint16(t,0,!0),t+=2,r.setUint16(t,0,!0),t+=2,r.setUint16(t,e,!0),t+=2,r.setUint16(t,e,!0),t+=2,r.setUint32(t,n,!0),t+=4,r.setUint32(t,o,!0),t+=4,r.setUint16(t,0,!0)}async function ra(r){if(typeof CompressionStream>"u")throw new Error("CompressionStream is not available. This environment does not support the Compression Streams API. Please use a modern browser or Node.js 18+.");let t=new CompressionStream("deflate-raw"),e=new Uint8Array(r.length);e.set(r);let n=t.writable.getWriter();n.write(e),n.close();let o=t.readable.getReader(),a=[];for(;;){let{done:i,value:l}=await o.read();if(i)break;a.push(l)}let c=a.reduce((i,l)=>i+l.length,0),u=new Uint8Array(c),s=0;for(let i of a)u.set(i,s),s+=i.length;return u}var Gn=_(()=>{"use strict";Xr()});var Jn={};Br(Jn,{serializeNpz:()=>Q,serializeNpzSync:()=>xr});async function Q(r,t={}){let e=Yn(r);return qn(e,{compress:t.compress??!1})}function xr(r){let t=Yn(r);return jn(t)}function Yn(r){let t=new Map;if(Array.isArray(r)){for(let n=0;n<r.length;n++){let o=r[n],a=L(o);t.set(`arr_${n}.npy`,a)}return t}let e=r instanceof Map?r.entries():Object.entries(r);for(let[n,o]of e){if(typeof n!="string"||n.length===0)throw new Error("Array names must be non-empty strings");let a=L(o),c=n.endsWith(".npy")?n:`${n}.npy`;t.set(c,a)}return t}var Ir=_(()=>{"use strict";Sr();Gn()});var ca={};Br(ca,{DTYPE_TO_DESCR:()=>ir,InvalidNpyError:()=>C,NDArray:()=>z,SUPPORTED_DTYPES:()=>gr,UnsupportedDTypeError:()=>F,__version__:()=>ta,absolute:()=>Ve,arange:()=>ze,arccos:()=>en,arccosh:()=>yn,arcsin:()=>tn,arcsinh:()=>pn,arctan:()=>nn,arctan2:()=>on,arctanh:()=>mn,array:()=>R,array_equal:()=>$n,array_split:()=>Nn,asarray:()=>Te,broadcast_arrays:()=>_n,broadcast_to:()=>Un,choose:()=>On,concatenate:()=>hn,copy:()=>Oe,cos:()=>Ke,cosh:()=>ln,degrees:()=>sn,dot:()=>We,dstack:()=>Dn,empty:()=>Wr,empty_like:()=>ve,eye:()=>Zr,floor_divide:()=>qe,full:()=>Hr,full_like:()=>Ce,geomspace:()=>_e,hsplit:()=>In,hstack:()=>Sn,hypot:()=>an,identity:()=>Ee,inner:()=>Ye,linspace:()=>Be,load:()=>na,loadNpy:()=>Xn,loadNpySync:()=>Qn,loadNpz:()=>Dr,loadNpzFile:()=>to,loadNpzFileSync:()=>eo,loadNpzSync:()=>wr,loadSync:()=>oa,logspace:()=>Ue,mod:()=>Le,moveaxis:()=>gn,negative:()=>Fe,ones:()=>jr,ones_like:()=>Me,outer:()=>Je,parseNpy:()=>Z,parseNpyData:()=>Ar,parseNpyHeader:()=>hr,parseNpz:()=>H,parseNpzSync:()=>lr,positive:()=>je,power:()=>Pe,put:()=>Tn,radians:()=>un,reciprocal:()=>Ze,repeat:()=>Bn,save:()=>aa,saveNpy:()=>Kn,saveNpySync:()=>ro,saveNpz:()=>rt,saveNpzSync:()=>ea,saveSync:()=>sa,savez:()=>ia,savez_compressed:()=>ua,serializeNpy:()=>L,serializeNpz:()=>Q,serializeNpzSync:()=>xr,sign:()=>Re,sin:()=>Qe,sinh:()=>cn,split:()=>wn,sqrt:()=>ke,stack:()=>An,swapaxes:()=>dn,take:()=>En,tan:()=>rn,tanh:()=>fn,tensordot:()=>Xe,tile:()=>zn,trace:()=>He,transpose:()=>Ge,vsplit:()=>xn,vstack:()=>bn,zeros:()=>ar,zeros_like:()=>$e});module.exports=Ur(ca);var K=require("node:fs"),rr=require("node:fs/promises");br();Sr();Nr();Ir();Gr();br();Sr();ur();Nr();Ir();var ta="0.5.0";async function Xn(r){let t=await(0,rr.readFile)(r);return Z(t)}function Qn(r){let t=(0,K.readFileSync)(r);return Z(t)}async function Kn(r,t){let e=L(t);await(0,rr.writeFile)(r,e)}function ro(r,t){let e=L(t);(0,K.writeFileSync)(r,e)}async function to(r,t={}){let e=await(0,rr.readFile)(r);return H(e,t)}function eo(r,t={}){let e=(0,K.readFileSync)(r),{parseNpzSync:n}=(Nr(),Ur(Ln));return n(e,t)}async function rt(r,t,e={}){let n=await Q(t,e);await(0,rr.writeFile)(r,n)}function ea(r,t){let{serializeNpzSync:e}=(Ir(),Ur(Jn)),n=e(t);(0,K.writeFileSync)(r,n)}async function na(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return Xn(r)}else{if(r.endsWith(".npz"))return to(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}function oa(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return Qn(r)}else{if(r.endsWith(".npz"))return eo(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}async function aa(r,t){if(!r.endsWith(".npy"))throw new Error(`save() is for .npy files. Use saveNpz() for .npz files. Got: ${r}`);return Kn(r,t)}function sa(r,t){if(!r.endsWith(".npy"))throw new Error(`saveSync() is for .npy files. Use saveNpzSync() for .npz files. Got: ${r}`);return ro(r,t)}async function ia(r,t){return r.endsWith(".npz")||(r=r+".npz"),rt(r,t,{compress:!1})}async function ua(r,t){return r.endsWith(".npz")||(r=r+".npz"),rt(r,t,{compress:!0})}0&&(module.exports={DTYPE_TO_DESCR,InvalidNpyError,NDArray,SUPPORTED_DTYPES,UnsupportedDTypeError,__version__,absolute,arange,arccos,arccosh,arcsin,arcsinh,arctan,arctan2,arctanh,array,array_equal,array_split,asarray,broadcast_arrays,broadcast_to,choose,concatenate,copy,cos,cosh,degrees,dot,dstack,empty,empty_like,eye,floor_divide,full,full_like,geomspace,hsplit,hstack,hypot,identity,inner,linspace,load,loadNpy,loadNpySync,loadNpz,loadNpzFile,loadNpzFileSync,loadNpzSync,loadSync,logspace,mod,moveaxis,negative,ones,ones_like,outer,parseNpy,parseNpyData,parseNpyHeader,parseNpz,parseNpzSync,positive,power,put,radians,reciprocal,repeat,save,saveNpy,saveNpySync,saveNpz,saveNpzSync,saveSync,savez,savez_compressed,serializeNpy,serializeNpz,serializeNpzSync,sign,sin,sinh,split,sqrt,stack,swapaxes,take,tan,tanh,tensordot,tile,trace,transpose,vsplit,vstack,zeros,zeros_like});
1
+ "use strict";var et=Object.defineProperty;var Ai=Object.getOwnPropertyDescriptor;var hi=Object.getOwnPropertyNames;var bi=Object.prototype.hasOwnProperty;var M=(r,t)=>()=>(r&&(t=r(r=0)),t);var nt=(r,t)=>{for(var e in t)et(r,e,{get:t[e],enumerable:!0})},Si=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of hi(t))!bi.call(r,o)&&o!==e&&et(r,o,{get:()=>t[o],enumerable:!(n=Ai(t,o))||n.enumerable});return r};var ot=r=>Si(et({},"__esModule",{value:!0}),r);function Ht(r){if(!r.includes(":")){if(r.includes("."))throw new Error(`Invalid slice index: "${r}" (must be integer)`);let a=parseInt(r,10);if(isNaN(a))throw new Error(`Invalid slice index: "${r}"`);return{start:a,stop:null,step:1,isIndex:!0}}let t=r.split(":");if(t.length>3)throw new Error(`Invalid slice notation: "${r}" (too many colons)`);let e=t[0]===""?null:parseInt(t[0],10),n=t[1]===""||t[1]===void 0?null:parseInt(t[1],10),o=t[2]===""||t[2]===void 0?1:parseInt(t[2],10);if(e!==null&&isNaN(e))throw new Error(`Invalid start index in slice: "${r}"`);if(n!==null&&isNaN(n))throw new Error(`Invalid stop index in slice: "${r}"`);if(isNaN(o))throw new Error(`Invalid step in slice: "${r}"`);if(o===0)throw new Error("Slice step cannot be zero");return{start:e,stop:n,step:o,isIndex:!1}}function Yt(r,t){let{start:e,stop:n}=r,{step:o,isIndex:a}=r;if(a){if(e===null)throw new Error("Index cannot be null");let u=e<0?t+e:e;if(u<0||u>=t)throw new Error(`Index ${e} is out of bounds for size ${t}`);return{start:u,stop:u+1,step:1,isIndex:!0}}return o>0?(e===null&&(e=0),n===null&&(n=t)):(e===null&&(e=t-1),n===null&&(n=-t-1)),e<0&&(e=t+e),n<0&&(n=t+n),e=Math.max(0,Math.min(e,t)),n=Math.max(-1,Math.min(n,t)),{start:e,stop:n,step:o,isIndex:!1}}var Jt=M(()=>{"use strict"});function U(r){switch(r){case"float64":return Float64Array;case"float32":return Float32Array;case"int64":return BigInt64Array;case"int32":return Int32Array;case"int16":return Int16Array;case"int8":return Int8Array;case"uint64":return BigUint64Array;case"uint32":return Uint32Array;case"uint16":return Uint16Array;case"uint8":return Uint8Array;case"bool":return Uint8Array;default:throw new Error(`Unknown dtype: ${r}`)}}function Qt(r){switch(r){case"float64":case"int64":case"uint64":return 8;case"float32":case"int32":case"uint32":return 4;case"int16":case"uint16":return 2;case"int8":case"uint8":case"bool":return 1;default:throw new Error(`Unknown dtype: ${r}`)}}function Kt(r){return r==="int64"||r==="int32"||r==="int16"||r==="int8"||r==="uint64"||r==="uint32"||r==="uint16"||r==="uint8"}function Xt(r){return r==="float64"||r==="float32"}function w(r){return r==="int64"||r==="uint64"}function v(r,t){if(r===t)return r;if(r==="bool")return t;if(t==="bool")return r;if(Xt(r)||Xt(t)){if(r==="float64"||t==="float64")return"float64";if(r==="float32"){let c=t;return c==="int32"||c==="int64"||c==="uint32"||c==="uint64"?"float64":"float32"}if(t==="float32"){let c=r;return c==="int32"||c==="int64"||c==="uint32"||c==="uint64"?"float64":"float32"}return"float32"}let e=r.startsWith("int"),n=t.startsWith("int"),o=r.startsWith("uint"),a=t.startsWith("uint"),u=c=>c.includes("64")?64:c.includes("32")?32:c.includes("16")?16:c.includes("8")?8:0,s=u(r),i=u(t);if(r==="int64"&&t==="uint64"||r==="uint64"&&t==="int64")return"float64";if(e&&a&&s===i){if(s===8)return"int16";if(s===16)return"int32";if(s===32)return"int64"}if(o&&n&&s===i){if(i===8)return"int16";if(i===16)return"int32";if(i===32)return"int64"}if(e&&n||o&&a){let c=Math.max(s,i);return e?c===64?"int64":c===32?"int32":c===16?"int16":"int8":c===64?"uint64":c===32?"uint32":c===16?"uint16":"uint8"}return e&&a?s>i?r:i===8?"int16":i===16?"int32":i===32?"int64":"float64":o&&n?i>s?t:s===8?"int16":s===16?"int32":s===32?"int64":"float64":"float64"}var C,R=M(()=>{"use strict";C="float64"});function L(r){let t=new Array(r.length),e=1;for(let n=r.length-1;n>=0;n--)t[n]=e,e*=r[n];return t}var D,Z=M(()=>{"use strict";R();D=class r{constructor(t,e,n,o,a){this._data=t,this._shape=e,this._strides=n,this._offset=o,this._dtype=a}get shape(){return this._shape}get ndim(){return this._shape.length}get size(){return this._shape.reduce((t,e)=>t*e,1)}get dtype(){return this._dtype}get data(){return this._data}get strides(){return this._strides}get offset(){return this._offset}get isCContiguous(){let t=this._shape,e=this._strides,n=t.length;if(n===0)return!0;if(n===1)return e[0]===1;let o=1;for(let a=n-1;a>=0;a--){if(e[a]!==o)return!1;o*=t[a]}return!0}get isFContiguous(){let t=this._shape,e=this._strides,n=t.length;if(n===0)return!0;if(n===1)return e[0]===1;let o=1;for(let a=0;a<n;a++){if(e[a]!==o)return!1;o*=t[a]}return!0}iget(t){let e=this._shape,n=this._strides,o=e.length;if(o===0)return this._data[this._offset];let a=t,u=this._offset;for(let s=0;s<o;s++){let i=1;for(let f=s+1;f<o;f++)i*=e[f];let c=Math.floor(a/i);a=a%i,u+=c*n[s]}return this._data[u]}iset(t,e){let n=this._shape,o=this._strides,a=n.length;if(a===0){this._data[this._offset]=e;return}let u=t,s=this._offset;for(let i=0;i<a;i++){let c=1;for(let p=i+1;p<a;p++)c*=n[p];let f=Math.floor(u/c);u=u%c,s+=f*o[i]}this._data[s]=e}get(...t){let e=this._strides,n=this._offset;for(let o=0;o<t.length;o++)n+=t[o]*e[o];return this._data[n]}set(t,e){let n=this._strides,o=this._offset;for(let a=0;a<t.length;a++)o+=t[a]*n[a];this._data[o]=e}copy(){let t=Array.from(this._shape),e=this._dtype,n=this.size,o=U(e);if(!o)throw new Error(`Cannot copy array with dtype ${e}`);let a=new o(n);if(this.isCContiguous&&this._offset===0)if(w(e)){let u=this._data,s=a;for(let i=0;i<n;i++)s[i]=u[i]}else a.set(this._data);else if(w(e)){let u=a;for(let s=0;s<n;s++)u[s]=this.iget(s)}else for(let u=0;u<n;u++)a[u]=this.iget(u);return new r(a,t,r._computeStrides(t),0,e)}static fromData(t,e,n,o,a){let u=o??r._computeStrides(e),s=a??0;return new r(t,e,u,s,n)}static zeros(t,e=C){let n=t.reduce((u,s)=>u*s,1),o=U(e);if(!o)throw new Error(`Cannot create array with dtype ${e}`);let a=new o(n);return new r(a,t,r._computeStrides(t),0,e)}static ones(t,e=C){let n=t.reduce((u,s)=>u*s,1),o=U(e);if(!o)throw new Error(`Cannot create array with dtype ${e}`);let a=new o(n);return w(e)?a.fill(BigInt(1)):a.fill(1),new r(a,t,r._computeStrides(t),0,e)}static _computeStrides(t){let e=new Array(t.length),n=1;for(let o=t.length-1;o>=0;o--)e[o]=n,n*=t[o];return e}}});function re(r,t){let e=r.length,n=t.length,o=Math.max(e,n),a=new Array(o);for(let u=0;u<o;u++){let s=u<o-e?1:r[u-(o-e)],i=u<o-n?1:t[u-(o-n)];if(s===i)a[u]=s;else if(s===1)a[u]=i;else if(i===1)a[u]=s;else throw new Error(`operands could not be broadcast together with shapes ${JSON.stringify(Array.from(r))} ${JSON.stringify(Array.from(t))}`)}return a}function Di(r,t,e){let n=r.length,o=e.length,a=new Array(o).fill(0);for(let u=0;u<n;u++){let s=o-n+u,i=r[u],c=e[s];if(i===c)a[s]=t[u];else if(i===1)a[s]=0;else throw new Error("Invalid broadcast")}return a}function _r(r,t){let e=Di(r.shape,r.strides,t);return D.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function P(r,t,e,n){let o=re(r.shape,t.shape),a=_r(r,o),u=_r(t,o),s=v(r.dtype,t.dtype),i=D.zeros(o,s),c=i.data,f=i.size;if(w(s)){let p=c;for(let l=0;l<f;l++){let y=a.iget(l),m=u.iget(l),d=typeof y=="bigint"?y:BigInt(Math.round(y)),g=typeof m=="bigint"?m:BigInt(Math.round(m));n==="add"?p[l]=d+g:n==="subtract"?p[l]=d-g:n==="multiply"?p[l]=d*g:n==="divide"?p[l]=d/g:p[l]=BigInt(Math.round(e(Number(d),Number(g))))}}else{let p=w(r.dtype)||w(t.dtype);for(let l=0;l<f;l++){let y=a.iget(l),m=u.iget(l),d=Number(y),g=Number(m);c[l]=e(d,g)}}return i}function K(r,t,e){let n=re(r.shape,t.shape),o=_r(r,n),a=_r(t,n),u=n.reduce((c,f)=>c*f,1),s=new Uint8Array(u),i=w(r.dtype)||w(t.dtype);for(let c=0;c<u;c++){let f=o.iget(c),p=a.iget(c),l=Number(f),y=Number(p);s[c]=e(l,y)?1:0}return D.fromData(s,n,"bool")}function V(r,t,e=!0){let n=r.dtype,o=Array.from(r.shape),a=r.size,s=e?n:n!=="float32"&&n!=="float64"?"float64":n,i=D.zeros(o,s),c=i.data,f=r.data;if(w(n))if(w(s)){let p=c;for(let l=0;l<a;l++){let y=Number(f[l]);p[l]=BigInt(Math.round(t(y)))}}else for(let p=0;p<a;p++)c[p]=t(Number(f[p]));else for(let p=0;p<a;p++)c[p]=t(Number(f[p]));return i}var nr=M(()=>{"use strict";Z();R()});function at(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function te(r,t){return typeof t=="number"?Ii(r,t):at(r,t)?Ni(r,t):P(r,t,(e,n)=>e+n,"add")}function Ni(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;if(!w(r.dtype)||!w(t.dtype))for(let f=0;f<o;f++){let p=typeof a[f]=="bigint"?a[f]:BigInt(Math.round(Number(a[f]))),l=typeof u[f]=="bigint"?u[f]:BigInt(Math.round(Number(u[f])));i[f]=p+l}else{let f=a,p=u;for(let l=0;l<o;l++)i[l]=f[l]+p[l]}}else if(w(r.dtype)||w(t.dtype))for(let c=0;c<o;c++){let f=typeof a[c]=="bigint"?Number(a[c]):a[c],p=typeof u[c]=="bigint"?Number(u[c]):u[c];s[c]=f+p}else for(let c=0;c<o;c++)s[c]=a[c]+u[c];return n}function ee(r,t){return typeof t=="number"?zi(r,t):at(r,t)?wi(r,t):P(r,t,(e,n)=>e-n,"subtract")}function wi(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;if(!w(r.dtype)||!w(t.dtype))for(let f=0;f<o;f++){let p=typeof a[f]=="bigint"?a[f]:BigInt(Math.round(Number(a[f]))),l=typeof u[f]=="bigint"?u[f]:BigInt(Math.round(Number(u[f])));i[f]=p-l}else{let f=a,p=u;for(let l=0;l<o;l++)i[l]=f[l]-p[l]}}else if(w(r.dtype)||w(t.dtype))for(let c=0;c<o;c++){let f=typeof a[c]=="bigint"?Number(a[c]):a[c],p=typeof u[c]=="bigint"?Number(u[c]):u[c];s[c]=f-p}else for(let c=0;c<o;c++)s[c]=a[c]-u[c];return n}function ne(r,t){return typeof t=="number"?_i(r,t):at(r,t)?xi(r,t):P(r,t,(e,n)=>e*n,"multiply")}function xi(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;if(!w(r.dtype)||!w(t.dtype))for(let f=0;f<o;f++){let p=typeof a[f]=="bigint"?a[f]:BigInt(Math.round(Number(a[f]))),l=typeof u[f]=="bigint"?u[f]:BigInt(Math.round(Number(u[f])));i[f]=p*l}else{let f=a,p=u;for(let l=0;l<o;l++)i[l]=f[l]*p[l]}}else if(w(r.dtype)||w(t.dtype))for(let c=0;c<o;c++){let f=typeof a[c]=="bigint"?Number(a[c]):a[c],p=typeof u[c]=="bigint"?Number(u[c]):u[c];s[c]=f*p}else for(let c=0;c<o;c++)s[c]=a[c]*u[c];return n}function oe(r,t){if(typeof t=="number")return Bi(r,t);let e=r.dtype==="float64",n=t.dtype==="float64",o=r.dtype==="float32",a=t.dtype==="float32";if(e||n){let i=e?r:ur(r,"float64"),c=n?t:ur(t,"float64");return P(i,c,(f,p)=>f/p,"divide")}if(o||a){let i=o?r:ur(r,"float32"),c=a?t:ur(t,"float32");return P(i,c,(f,p)=>f/p,"divide")}let u=ur(r,"float64"),s=ur(t,"float64");return P(u,s,(i,c)=>i/c,"divide")}function ur(r,t){let e=D.zeros(Array.from(r.shape),t),n=r.size,o=r.data,a=e.data;for(let u=0;u<n;u++)a[u]=Number(o[u]);return e}function Ii(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]+f}else for(let i=0;i<a;i++)s[i]=Number(o[i])+t;return u}function zi(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]-f}else for(let i=0;i<a;i++)s[i]=Number(o[i])-t;return u}function _i(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]*f}else for(let i=0;i<a;i++)s[i]=Number(o[i])*t;return u}function Bi(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,s=e!=="float32"&&e!=="float64"?"float64":e,i=D.zeros(n,s),c=i.data;if(w(e))for(let f=0;f<a;f++)c[f]=Number(o[f])/t;else for(let f=0;f<a;f++)c[f]=Number(o[f])/t;return i}function ae(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;if(w(t)){let s=n,i=u;for(let c=0;c<o;c++){let f=s[c];i[c]=f<0n?-f:f}}else for(let s=0;s<o;s++)u[s]=Math.abs(Number(n[s]));return a}function se(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;if(w(t)){let s=n,i=u;for(let c=0;c<o;c++)i[c]=-s[c]}else for(let s=0;s<o;s++)u[s]=-Number(n[s]);return a}function ie(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;if(w(t)){let s=n,i=u;for(let c=0;c<o;c++){let f=s[c];i[c]=f>0n?1n:f<0n?-1n:0n}}else for(let s=0;s<o;s++){let i=Number(n[s]);u[s]=i>0?1:i<0?-1:0}return a}function Br(r,t){return typeof t=="number"?Ei(r,t):P(r,t,(e,n)=>(e%n+n)%n,"mod")}function Ei(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++){let l=i[p];c[p]=(l%f+f)%f}}else for(let i=0;i<a;i++){let c=Number(o[i]);s[i]=(c%t+t)%t}return u}function st(r,t){return typeof t=="number"?Ui(r,t):P(r,t,(e,n)=>Math.floor(e/n),"floor_divide")}function Ui(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]/f}else for(let i=0;i<a;i++)s[i]=Math.floor(Number(o[i])/t);return u}function ue(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;for(let s=0;s<o;s++)u[s]=n[s];return a}function ce(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,u=t!=="float32"&&t!=="float64"?"float64":t,s=D.zeros(e,u),i=s.data;if(w(t))for(let c=0;c<o;c++)i[c]=1/Number(n[c]);else for(let c=0;c<o;c++)i[c]=1/Number(n[c]);return s}function fe(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,u=t!=="float32"&&t!=="float64"?"float64":t,s=D.zeros(e,u),i=s.data;for(let c=0;c<o;c++)i[c]=Math.cbrt(Number(n[c]));return s}function le(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",u=D.zeros(e,a),s=u.data;for(let i=0;i<o;i++)s[i]=Math.abs(Number(n[i]));return u}function pe(r,t){let e=st(r,t),n=Br(r,t);return[e,n]}function ye(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;if(w(t)){let s=n,i=u;for(let c=0;c<o;c++)i[c]=s[c]*s[c]}else for(let s=0;s<o;s++){let i=Number(n[s]);u[s]=i*i}return a}function me(r,t){return Br(r,t)}function de(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=e==="float32"?"float32":"float64",u=D.zeros(n,a),s=u.data;if(typeof t=="number")for(let i=0;i<o;i++){let c=Number(r.data[i]);c<0?s[i]=0:c===0?s[i]=t:s[i]=1}else{let i=t.data,c=t.shape;if(n.every((f,p)=>f===c[p]))for(let f=0;f<o;f++){let p=Number(r.data[f]);p<0?s[f]=0:p===0?s[f]=Number(i[f]):s[f]=1}else for(let f=0;f<o;f++){let p=Number(r.data[f]),l=f%t.size;p<0?s[f]=0:p===0?s[f]=Number(i[l]):s[f]=1}}return u}var ge=M(()=>{"use strict";Z();R();nr()});function rr(r){if(r.length===0)return[];if(r.length===1)return Array.from(r[0]);let t=Math.max(...r.map(n=>n.length)),e=new Array(t);for(let n=0;n<t;n++){let o=1;for(let a of r){let u=a.length-t+n,s=u<0?1:a[u];if(s!==1){if(o===1)o=s;else if(o!==s)return null}}e[n]=o}return e}function Oi(r,t,e){let n=r.length,o=e.length,a=new Array(o).fill(0);for(let u=0;u<n;u++){let s=o-n+u,i=r[u],c=e[s];if(i===c)a[s]=t[u];else if(i===1)a[s]=0;else throw new Error("Invalid broadcast")}return a}function H(r,t){let e=Oi(r.shape,r.strides,t);return D.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function it(...r){let t=rr(r);if(t===null){let e=r.map(n=>`(${n.join(",")})`).join(" ");throw new Error(`shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between ${e}`)}return t}var ut=M(()=>{"use strict";Z()});function Ae(r,t){return typeof t=="number"?$i(r,t):K(r,t,(e,n)=>e>n)}function he(r,t){return typeof t=="number"?vi(r,t):K(r,t,(e,n)=>e>=n)}function be(r,t){return typeof t=="number"?Mi(r,t):K(r,t,(e,n)=>e<n)}function Se(r,t){return typeof t=="number"?Ci(r,t):K(r,t,(e,n)=>e<=n)}function De(r,t){return typeof t=="number"?ki(r,t):K(r,t,(e,n)=>e===n)}function Ne(r,t){return typeof t=="number"?Vi(r,t):K(r,t,(e,n)=>e!==n)}function ct(r,t,e=1e-5,n=1e-8){return typeof t=="number"?Pi(r,t,e,n):K(r,t,(o,a)=>{let u=Math.abs(o-a),s=n+e*Math.abs(a);return u<=s})}function we(r,t,e=1e-5,n=1e-8){let o=ct(r,t,e,n),a=o.data;for(let u=0;u<o.size;u++)if(a[u]===0)return!1;return!0}function xe(r,t){let e=[Array.from(r.shape),Array.from(t.shape)],n=rr(e);if(n===null)return!1;let o=H(r,n),a=H(t,n),u=n.length,s=n.reduce((f,p)=>f*p,1),i=w(o.dtype),c=w(a.dtype);for(let f=0;f<s;f++){let p=f,l=new Array(u);for(let d=u-1;d>=0;d--)l[d]=p%n[d],p=Math.floor(p/n[d]);let y=o.get(...l),m=a.get(...l);if(i||c){let d=typeof y=="bigint"?y:BigInt(Number(y)),g=typeof m=="bigint"?m:BigInt(Number(m));if(d!==g)return!1}else if(y!==m)return!1}return!0}function $i(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]>t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function vi(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]>=t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Mi(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]<t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Ci(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]<=t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function ki(r,t){let e=new Uint8Array(r.size),n=r.data,o=r.dtype;if(w(o)){let a=BigInt(Math.round(t)),u=n;for(let s=0;s<r.size;s++)e[s]=u[s]===a?1:0}else for(let a=0;a<r.size;a++)e[a]=n[a]===t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Vi(r,t){let e=new Uint8Array(r.size),n=r.data;for(let o=0;o<r.size;o++)e[o]=n[o]!==t?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Pi(r,t,e,n){let o=new Uint8Array(r.size),a=r.data,u=r.dtype;if(w(u)){let s=a;for(let i=0;i<r.size;i++){let c=Number(s[i]),f=Math.abs(c-t),p=n+e*Math.abs(t);o[i]=f<=p?1:0}}else for(let s=0;s<r.size;s++){let i=Number(a[s]),c=Math.abs(i-t),f=n+e*Math.abs(t);o[s]=c<=f?1:0}return D.fromData(o,Array.from(r.shape),"bool")}var Ie=M(()=>{"use strict";Z();R();nr();ut()});function O(r,t){let e=0,n=1;for(let o=r.length-1;o>=0;o--)e+=r[o]*n,n*=t[o];return e}function $(r,t,e,n){let o=n.length,a=new Array(o),u=Array.from(n).filter((i,c)=>c!==t),s=r;for(let i=u.length-1;i>=0;i--)a[i>=t?i+1:i]=s%u[i],s=Math.floor(s/u[i]);return a[t]=e,a}var ze=M(()=>{"use strict"});function mr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.size,s=r.data;if(t===void 0)if(w(n)){let m=s,d=BigInt(0);for(let g=0;g<u;g++)d+=m[g];return Number(d)}else{let m=0;for(let d=0;d<u;d++)m+=Number(s[d]);return m}let i=t;if(i<0&&(i=a+i),i<0||i>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((m,d)=>d!==i);if(c.length===0)return mr(r);let f=D.zeros(c,n),p=f.data,l=o[i],y=c.reduce((m,d)=>m*d,1);if(w(n)){let m=s,d=p;for(let g=0;g<y;g++){let h=BigInt(0);for(let A=0;A<l;A++){let b=$(g,i,A,o),S=O(b,o);h+=m[S]}d[g]=h}}else for(let m=0;m<y;m++){let d=0;for(let g=0;g<l;g++){let h=$(m,i,g,o),A=O(h,o);d+=Number(s[A])}p[m]=d}if(e){let m=[...o];return m[i]=1,D.fromData(p,m,n)}return f}function Er(r,t,e=!1){let n=r.dtype,o=r.shape;if(t===void 0)return mr(r)/r.size;let a=t;if(a<0&&(a=o.length+a),a<0||a>=o.length)throw new Error(`axis ${t} is out of bounds for array of dimension ${o.length}`);let u=mr(r,t,e);if(typeof u=="number")return u/o[a];let s=o[a],i=n;(w(n)||n.startsWith("int")||n.startsWith("uint"))&&(i="float64");let c=D.zeros(Array.from(u.shape),i),f=c.data,p=u.data;if(w(n)){let l=p;for(let y=0;y<f.length;y++)f[y]=Number(l[y])/s}else for(let l=0;l<f.length;l++)f[l]=Number(p[l])/s;return c}function Ur(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.size,s=r.data;if(t===void 0){if(u===0)throw new Error("max of empty array");let m=s[0];for(let d=1;d<u;d++)s[d]>m&&(m=s[d]);return Number(m)}let i=t;if(i<0&&(i=a+i),i<0||i>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((m,d)=>d!==i);if(c.length===0)return Ur(r);let f=D.zeros(c,n),p=f.data,l=o[i],y=c.reduce((m,d)=>m*d,1);if(w(n)){let m=s,d=p;for(let g=0;g<y;g++){let h=$(g,i,0,o),A=O(h,o),b=m[A];for(let S=1;S<l;S++){let N=$(g,i,S,o),x=O(N,o),I=m[x];I>b&&(b=I)}d[g]=b}}else for(let m=0;m<y;m++){let d=-1/0;for(let g=0;g<l;g++){let h=$(m,i,g,o),A=O(h,o),b=Number(s[A]);b>d&&(d=b)}p[m]=d}if(e){let m=[...o];return m[i]=1,D.fromData(p,m,n)}return f}function ft(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.size,s=r.data;if(t===void 0)if(w(n)){let m=s,d=BigInt(1);for(let g=0;g<u;g++)d*=m[g];return Number(d)}else{let m=1;for(let d=0;d<u;d++)m*=Number(s[d]);return m}let i=t;if(i<0&&(i=a+i),i<0||i>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((m,d)=>d!==i);if(c.length===0)return ft(r);let f=D.zeros(c,n),p=f.data,l=o[i],y=c.reduce((m,d)=>m*d,1);if(w(n)){let m=s,d=p;for(let g=0;g<y;g++){let h=BigInt(1);for(let A=0;A<l;A++){let b=$(g,i,A,o),S=O(b,o);h*=m[S]}d[g]=h}}else for(let m=0;m<y;m++){let d=1;for(let g=0;g<l;g++){let h=$(m,i,g,o),A=O(h,o);d*=Number(s[A])}p[m]=d}if(e){let m=[...o];return m[i]=1,D.fromData(p,m,n)}return f}function Tr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.size,s=r.data;if(t===void 0){if(u===0)throw new Error("min of empty array");let m=s[0];for(let d=1;d<u;d++)s[d]<m&&(m=s[d]);return Number(m)}let i=t;if(i<0&&(i=a+i),i<0||i>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((m,d)=>d!==i);if(c.length===0)return Tr(r);let f=D.zeros(c,n),p=f.data,l=o[i],y=c.reduce((m,d)=>m*d,1);if(w(n)){let m=s,d=p;for(let g=0;g<y;g++){let h=$(g,i,0,o),A=O(h,o),b=m[A];for(let S=1;S<l;S++){let N=$(g,i,S,o),x=O(N,o),I=m[x];I<b&&(b=I)}d[g]=b}}else for(let m=0;m<y;m++){let d=1/0;for(let g=0;g<l;g++){let h=$(m,i,g,o),A=O(h,o),b=Number(s[A]);b<d&&(d=b)}p[m]=d}if(e){let m=[...o];return m[i]=1,D.fromData(p,m,n)}return f}function lt(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.size,u=r.data;if(t===void 0){if(a===0)throw new Error("argmin of empty array");let y=u[0],m=0;for(let d=1;d<a;d++)u[d]<y&&(y=u[d],m=d);return m}let s=t;if(s<0&&(s=o+s),s<0||s>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let i=Array.from(n).filter((y,m)=>m!==s);if(i.length===0)return lt(r);let c=D.zeros(i,"int32"),f=c.data,p=n[s],l=i.reduce((y,m)=>y*m,1);if(w(e)){let y=u;for(let m=0;m<l;m++){let d=$(m,s,0,n),g=O(d,n),h=y[g],A=0;for(let b=1;b<p;b++){let S=$(m,s,b,n),N=O(S,n),x=y[N];x<h&&(h=x,A=b)}f[m]=A}}else for(let y=0;y<l;y++){let m=1/0,d=0;for(let g=0;g<p;g++){let h=$(y,s,g,n),A=O(h,n),b=Number(u[A]);b<m&&(m=b,d=g)}f[y]=d}return c}function pt(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.size,u=r.data;if(t===void 0){if(a===0)throw new Error("argmax of empty array");let y=u[0],m=0;for(let d=1;d<a;d++)u[d]>y&&(y=u[d],m=d);return m}let s=t;if(s<0&&(s=o+s),s<0||s>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let i=Array.from(n).filter((y,m)=>m!==s);if(i.length===0)return pt(r);let c=D.zeros(i,"int32"),f=c.data,p=n[s],l=i.reduce((y,m)=>y*m,1);if(w(e)){let y=u;for(let m=0;m<l;m++){let d=$(m,s,0,n),g=O(d,n),h=y[g],A=0;for(let b=1;b<p;b++){let S=$(m,s,b,n),N=O(S,n),x=y[N];x>h&&(h=x,A=b)}f[m]=A}}else for(let y=0;y<l;y++){let m=-1/0,d=0;for(let g=0;g<p;g++){let h=$(y,s,g,n),A=O(h,n),b=Number(u[A]);b>m&&(m=b,d=g)}f[y]=d}return c}function yt(r,t,e=0,n=!1){let o=r.shape,a=o.length,u=r.size,s=r.data,i=Er(r,t,n);if(t===void 0){let h=i,A=0;for(let b=0;b<u;b++){let S=Number(s[b])-h;A+=S*S}return A/(u-e)}let c=t;if(c<0&&(c=a+c),c<0||c>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let f=o[c],p=i,l=p.data,y=n?p.shape:Array.from(o).filter((h,A)=>A!==c),m=D.zeros(Array.from(y),"float64"),d=m.data,g=y.reduce((h,A)=>h*A,1);for(let h=0;h<g;h++){let A=0,b=Number(l[h]);for(let S=0;S<f;S++){let N=$(h,c,S,o),x=O(N,o),I=Number(s[x])-b;A+=I*I}d[h]=A/(f-e)}return m}function _e(r,t,e=0,n=!1){let o=yt(r,t,e,n);if(typeof o=="number")return Math.sqrt(o);let a=D.zeros(Array.from(o.shape),"float64"),u=o.data,s=a.data;for(let i=0;i<u.length;i++)s[i]=Math.sqrt(Number(u[i]));return a}function mt(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,u=r.data;if(t===void 0){for(let y=0;y<a;y++)if(!u[y])return!1;return!0}let s=t;if(s<0&&(s=o+s),s<0||s>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let i=Array.from(n).filter((y,m)=>m!==s);if(i.length===0)return mt(r);let c=D.zeros(i,"bool"),f=c.data,p=n[s],l=i.reduce((y,m)=>y*m,1);for(let y=0;y<l;y++){let m=!0;for(let d=0;d<p;d++){let g=$(y,s,d,n),h=O(g,n);if(!u[h]){m=!1;break}}f[y]=m?1:0}if(e){let y=[...n];return y[s]=1,D.fromData(f,y,"bool")}return c}function dt(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,u=r.data;if(t===void 0){for(let y=0;y<a;y++)if(u[y])return!0;return!1}let s=t;if(s<0&&(s=o+s),s<0||s>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let i=Array.from(n).filter((y,m)=>m!==s);if(i.length===0)return dt(r);let c=D.zeros(i,"bool"),f=c.data,p=n[s],l=i.reduce((y,m)=>y*m,1);for(let y=0;y<l;y++){let m=!1;for(let d=0;d<p;d++){let g=$(y,s,d,n),h=O(g,n);if(u[h]){m=!0;break}}f[y]=m?1:0}if(e){let y=[...n];return y[s]=1,D.fromData(f,y,"bool")}return c}function gt(r,t){let e=r.shape,n=e.length,o=r.data;if(t===void 0){let l=r.size,y=new Float64Array(l),m=0;for(let d=0;d<l;d++)m+=Number(o[d]),y[d]=m;return D.fromData(y,[l],"float64")}let a=t;if(a<0&&(a=n+a),a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=new Float64Array(r.size),s=e[a],i=[],c=1;for(let l=n-1;l>=0;l--)i.unshift(c),c*=e[l];let f=r.size,p=i[a];for(let l=0;l<f;l++)Math.floor(l/p)%s===0?u[l]=Number(o[l]):u[l]=u[l-p]+Number(o[l]);return D.fromData(u,[...e],"float64")}function At(r,t){let e=r.shape,n=e.length,o=r.data;if(t===void 0){let l=r.size,y=new Float64Array(l),m=1;for(let d=0;d<l;d++)m*=Number(o[d]),y[d]=m;return D.fromData(y,[l],"float64")}let a=t;if(a<0&&(a=n+a),a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=new Float64Array(r.size),s=e[a],i=[],c=1;for(let l=n-1;l>=0;l--)i.unshift(c),c*=e[l];let f=r.size,p=i[a];for(let l=0;l<f;l++)Math.floor(l/p)%s===0?u[l]=Number(o[l]):u[l]=u[l-p]*Number(o[l]);return D.fromData(u,[...e],"float64")}function ht(r,t,e=!1){let n=Ur(r,t,e),o=Tr(r,t,e);if(typeof n=="number"&&typeof o=="number")return n-o;let a=n,u=o,s=a.data,i=u.data,c=new Float64Array(a.size);for(let f=0;f<a.size;f++)c[f]=Number(s[f])-Number(i[f]);return D.fromData(c,[...a.shape],"float64")}function bt(r,t,e=!1){return cr(r,.5,t,e)}function St(r,t,e,n=!1){return cr(r,t/100,e,n)}function cr(r,t,e,n=!1){if(t<0||t>1)throw new Error("Quantile must be between 0 and 1");let o=r.shape,a=o.length,u=r.data;if(e===void 0){let y=[];for(let b=0;b<r.size;b++)y.push(Number(u[b]));y.sort((b,S)=>b-S);let m=y.length,d=t*(m-1),g=Math.floor(d),h=Math.ceil(d);if(g===h)return y[g];let A=d-g;return y[g]*(1-A)+y[h]*A}let s=e;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${e} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((y,m)=>m!==s);if(i.length===0)return cr(r,t);let c=i.reduce((y,m)=>y*m,1),f=o[s],p=new Float64Array(c);for(let y=0;y<c;y++){let m=[];for(let b=0;b<f;b++){let S=$(y,s,b,o),N=O(S,o);m.push(Number(u[N]))}m.sort((b,S)=>b-S);let d=m.length,g=t*(d-1),h=Math.floor(g),A=Math.ceil(g);if(h===A)p[y]=m[h];else{let b=g-h;p[y]=m[h]*(1-b)+m[A]*b}}let l=D.fromData(p,i,"float64");if(n){let y=[...o];return y[s]=1,D.fromData(p,y,"float64")}return l}function Or(r,t,e,n=!1){let o=r.shape,a=o.length,u=r.data;if(e===void 0)return Er(r,t,n);if(t===void 0){let m=0,d=0,g=e.data;for(let h=0;h<r.size;h++){let A=Number(g[h%e.size]);m+=Number(u[h])*A,d+=A}return d===0?NaN:m/d}let s=t;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((m,d)=>d!==s);if(i.length===0)return Or(r,void 0,e);let c=i.reduce((m,d)=>m*d,1),f=o[s],p=e.data,l=new Float64Array(c);for(let m=0;m<c;m++){let d=0,g=0;for(let h=0;h<f;h++){let A=$(m,s,h,o),b=O(A,o),S=Number(p[h%e.size]);d+=Number(u[b])*S,g+=S}l[m]=g===0?NaN:d/g}let y=D.fromData(l,i,"float64");if(n){let m=[...o];return m[s]=1,D.fromData(l,m,"float64")}return y}function $r(r,t,e=!1){let n=r.shape,o=n.length,a=r.data;if(t===void 0){let l=0;for(let y=0;y<r.size;y++){let m=Number(a[y]);isNaN(m)||(l+=m)}return l}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((l,y)=>y!==u);if(s.length===0)return $r(r);let i=s.reduce((l,y)=>l*y,1),c=n[u],f=new Float64Array(i);for(let l=0;l<i;l++){let y=0;for(let m=0;m<c;m++){let d=$(l,u,m,n),g=O(d,n),h=Number(a[g]);isNaN(h)||(y+=h)}f[l]=y}let p=D.fromData(f,s,"float64");if(e){let l=[...n];return l[u]=1,D.fromData(f,l,"float64")}return p}function vr(r,t,e=!1){let n=r.shape,o=n.length,a=r.data;if(t===void 0){let l=1;for(let y=0;y<r.size;y++){let m=Number(a[y]);isNaN(m)||(l*=m)}return l}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((l,y)=>y!==u);if(s.length===0)return vr(r);let i=s.reduce((l,y)=>l*y,1),c=n[u],f=new Float64Array(i);for(let l=0;l<i;l++){let y=1;for(let m=0;m<c;m++){let d=$(l,u,m,n),g=O(d,n),h=Number(a[g]);isNaN(h)||(y*=h)}f[l]=y}let p=D.fromData(f,s,"float64");if(e){let l=[...n];return l[u]=1,D.fromData(f,l,"float64")}return p}function Mr(r,t,e=!1){let n=r.shape,o=n.length,a=r.data;if(t===void 0){let l=0,y=0;for(let m=0;m<r.size;m++){let d=Number(a[m]);isNaN(d)||(l+=d,y++)}return y===0?NaN:l/y}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((l,y)=>y!==u);if(s.length===0)return Mr(r);let i=s.reduce((l,y)=>l*y,1),c=n[u],f=new Float64Array(i);for(let l=0;l<i;l++){let y=0,m=0;for(let d=0;d<c;d++){let g=$(l,u,d,n),h=O(g,n),A=Number(a[h]);isNaN(A)||(y+=A,m++)}f[l]=m===0?NaN:y/m}let p=D.fromData(f,s,"float64");if(e){let l=[...n];return l[u]=1,D.fromData(f,l,"float64")}return p}function dr(r,t,e=0,n=!1){let o=r.shape,a=o.length,u=r.data;if(t===void 0){let y=0,m=0;for(let h=0;h<r.size;h++){let A=Number(u[h]);isNaN(A)||(y+=A,m++)}if(m-e<=0)return NaN;let d=y/m,g=0;for(let h=0;h<r.size;h++){let A=Number(u[h]);isNaN(A)||(g+=(A-d)**2)}return g/(m-e)}let s=t;if(s<0&&(s=a+s),s<0||s>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let i=Array.from(o).filter((y,m)=>m!==s);if(i.length===0)return dr(r,void 0,e);let c=i.reduce((y,m)=>y*m,1),f=o[s],p=new Float64Array(c);for(let y=0;y<c;y++){let m=0,d=0;for(let A=0;A<f;A++){let b=$(y,s,A,o),S=O(b,o),N=Number(u[S]);isNaN(N)||(m+=N,d++)}if(d-e<=0){p[y]=NaN;continue}let g=m/d,h=0;for(let A=0;A<f;A++){let b=$(y,s,A,o),S=O(b,o),N=Number(u[S]);isNaN(N)||(h+=(N-g)**2)}p[y]=h/(d-e)}let l=D.fromData(p,i,"float64");if(n){let y=[...o];return y[s]=1,D.fromData(p,y,"float64")}return l}function Dt(r,t,e=0,n=!1){let o=dr(r,t,e,n);if(typeof o=="number")return Math.sqrt(o);let a=o,u=new Float64Array(a.size);for(let s=0;s<a.size;s++)u[s]=Math.sqrt(Number(a.data[s]));return D.fromData(u,[...a.shape],"float64")}function Cr(r,t,e=!1){let n=r.shape,o=n.length,a=r.data;if(t===void 0){let l=1/0;for(let y=0;y<r.size;y++){let m=Number(a[y]);!isNaN(m)&&m<l&&(l=m)}return l===1/0?NaN:l}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((l,y)=>y!==u);if(s.length===0)return Cr(r);let i=s.reduce((l,y)=>l*y,1),c=n[u],f=new Float64Array(i);for(let l=0;l<i;l++){let y=1/0;for(let m=0;m<c;m++){let d=$(l,u,m,n),g=O(d,n),h=Number(a[g]);!isNaN(h)&&h<y&&(y=h)}f[l]=y===1/0?NaN:y}let p=D.fromData(f,s,"float64");if(e){let l=[...n];return l[u]=1,D.fromData(f,l,"float64")}return p}function kr(r,t,e=!1){let n=r.shape,o=n.length,a=r.data;if(t===void 0){let l=-1/0;for(let y=0;y<r.size;y++){let m=Number(a[y]);!isNaN(m)&&m>l&&(l=m)}return l===-1/0?NaN:l}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((l,y)=>y!==u);if(s.length===0)return kr(r);let i=s.reduce((l,y)=>l*y,1),c=n[u],f=new Float64Array(i);for(let l=0;l<i;l++){let y=-1/0;for(let m=0;m<c;m++){let d=$(l,u,m,n),g=O(d,n),h=Number(a[g]);!isNaN(h)&&h>y&&(y=h)}f[l]=y===-1/0?NaN:y}let p=D.fromData(f,s,"float64");if(e){let l=[...n];return l[u]=1,D.fromData(f,l,"float64")}return p}function Vr(r,t){let e=r.shape,n=e.length,o=r.data;if(t===void 0){let f=1/0,p=-1;for(let l=0;l<r.size;l++){let y=Number(o[l]);!isNaN(y)&&y<f&&(f=y,p=l)}return p}let a=t;if(a<0&&(a=n+a),a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=Array.from(e).filter((f,p)=>p!==a);if(u.length===0)return Vr(r);let s=u.reduce((f,p)=>f*p,1),i=e[a],c=new Int32Array(s);for(let f=0;f<s;f++){let p=1/0,l=0;for(let y=0;y<i;y++){let m=$(f,a,y,e),d=O(m,e),g=Number(o[d]);!isNaN(g)&&g<p&&(p=g,l=y)}c[f]=l}return D.fromData(c,u,"int32")}function Pr(r,t){let e=r.shape,n=e.length,o=r.data;if(t===void 0){let f=-1/0,p=-1;for(let l=0;l<r.size;l++){let y=Number(o[l]);!isNaN(y)&&y>f&&(f=y,p=l)}return p}let a=t;if(a<0&&(a=n+a),a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=Array.from(e).filter((f,p)=>p!==a);if(u.length===0)return Pr(r);let s=u.reduce((f,p)=>f*p,1),i=e[a],c=new Int32Array(s);for(let f=0;f<s;f++){let p=-1/0,l=0;for(let y=0;y<i;y++){let m=$(f,a,y,e),d=O(m,e),g=Number(o[d]);!isNaN(g)&&g>p&&(p=g,l=y)}c[f]=l}return D.fromData(c,u,"int32")}function Nt(r,t){let e=r.shape,n=e.length,o=r.data;if(t===void 0){let l=r.size,y=new Float64Array(l),m=0;for(let d=0;d<l;d++){let g=Number(o[d]);isNaN(g)||(m+=g),y[d]=m}return D.fromData(y,[l],"float64")}let a=t;if(a<0&&(a=n+a),a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=new Float64Array(r.size),s=e[a],i=[],c=1;for(let l=n-1;l>=0;l--)i.unshift(c),c*=e[l];let f=r.size,p=i[a];for(let l=0;l<f;l++){let y=Number(o[l]);Math.floor(l/p)%s===0?u[l]=isNaN(y)?0:y:u[l]=u[l-p]+(isNaN(y)?0:y)}return D.fromData(u,[...e],"float64")}function wt(r,t){let e=r.shape,n=e.length,o=r.data;if(t===void 0){let l=r.size,y=new Float64Array(l),m=1;for(let d=0;d<l;d++){let g=Number(o[d]);isNaN(g)||(m*=g),y[d]=m}return D.fromData(y,[l],"float64")}let a=t;if(a<0&&(a=n+a),a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=new Float64Array(r.size),s=e[a],i=[],c=1;for(let l=n-1;l>=0;l--)i.unshift(c),c*=e[l];let f=r.size,p=i[a];for(let l=0;l<f;l++){let y=Number(o[l]);Math.floor(l/p)%s===0?u[l]=isNaN(y)?1:y:u[l]=u[l-p]*(isNaN(y)?1:y)}return D.fromData(u,[...e],"float64")}function Fr(r,t,e=!1){let n=r.shape,o=n.length,a=r.data;if(t===void 0){let l=[];for(let d=0;d<r.size;d++){let g=Number(a[d]);isNaN(g)||l.push(g)}if(l.length===0)return NaN;l.sort((d,g)=>d-g);let y=l.length,m=Math.floor(y/2);return y%2===0?(l[m-1]+l[m])/2:l[m]}let u=t;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((l,y)=>y!==u);if(s.length===0)return Fr(r);let i=s.reduce((l,y)=>l*y,1),c=n[u],f=new Float64Array(i);for(let l=0;l<i;l++){let y=[];for(let g=0;g<c;g++){let h=$(l,u,g,n),A=O(h,n),b=Number(a[A]);isNaN(b)||y.push(b)}if(y.length===0){f[l]=NaN;continue}y.sort((g,h)=>g-h);let m=y.length,d=Math.floor(m/2);m%2===0?f[l]=(y[d-1]+y[d])/2:f[l]=y[d]}let p=D.fromData(f,s,"float64");if(e){let l=[...n];return l[u]=1,D.fromData(f,l,"float64")}return p}var Be=M(()=>{"use strict";Z();R();ze()});function W(r,t){let e=r.size,n=r.dtype,o=t.indexOf(-1),a;if(o!==-1){let c=t.reduce((p,l,y)=>y===o?p:p*l,1),f=e/c;if(!Number.isInteger(f))throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(t)}`);a=t.map((p,l)=>l===o?f:p)}else a=t;if(a.reduce((c,f)=>c*f,1)!==e)throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(a)}`);if(r.isCContiguous){let c=r.data;return D.fromData(c,a,n,L(a),0)}let i=r.copy().data;return D.fromData(i,a,n,L(a),0)}function Rr(r){let t=r.size,e=r.dtype,n=U(e);if(!n)throw new Error(`Cannot flatten array with dtype ${e}`);if(r.isCContiguous){let s=r.data.slice(r.offset,r.offset+t);return D.fromData(s,[t],e,[1],0)}let o=new n(t),a=w(e);for(let u=0;u<t;u++){let s=r.iget(u);o[u]=s}return D.fromData(o,[t],e,[1],0)}function Ar(r){let t=r.size,e=r.dtype;if(r.isCContiguous){let n=r.data;return D.fromData(n,[t],e,[1],0)}return Rr(r)}function hr(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,u=r.dtype,s;if(t===void 0)s=Array.from({length:n},(p,l)=>n-1-l);else{if(t.length!==n)throw new Error(`axes must have length ${n}, got ${t.length}`);let p=new Set;for(let l of t){let y=l<0?n+l:l;if(y<0||y>=n)throw new Error(`axis ${l} is out of bounds for array of dimension ${n}`);if(p.has(y))throw new Error("repeated axis in transpose");p.add(y)}s=t.map(l=>l<0?n+l:l)}let i=s.map(p=>e[p]),c=Array.from(o),f=s.map(p=>c[p]);return D.fromData(a,i,u,f,r.offset)}function Ee(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,u=r.dtype;if(t===void 0){let s=[],i=[];for(let c=0;c<n;c++)e[c]!==1&&(s.push(e[c]),i.push(o[c]));return s.length===0&&(s.push(1),i.push(1)),D.fromData(a,s,u,i,r.offset)}else{let s=t<0?n+t:t;if(s<0||s>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);if(e[s]!==1)throw new Error(`cannot select an axis which has size not equal to one (axis ${t} has size ${e[s]})`);let i=[],c=[];for(let f=0;f<n;f++)f!==s&&(i.push(e[f]),c.push(o[f]));return D.fromData(a,i,u,c,r.offset)}}function gr(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,u=r.dtype,s=t;if(s<0&&(s=n+t+1),s<0||s>n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n+1}`);let i=[...Array.from(e)];i.splice(s,0,1);let c=[...Array.from(o)],f=s<n?o[s]*(e[s]||1):1;return c.splice(s,0,f),D.fromData(a,i,u,c,r.offset)}function Ue(r,t,e){let n=r.shape,o=n.length,a=r.strides,u=r.data,s=r.dtype,i=t<0?o+t:t,c=e<0?o+e:e;if(i<0||i>=o)throw new Error(`axis1 ${t} is out of bounds for array of dimension ${o}`);if(c<0||c>=o)throw new Error(`axis2 ${e} is out of bounds for array of dimension ${o}`);if(i===c)return D.fromData(u,Array.from(n),s,Array.from(a),r.offset);let f=Array.from(n),p=Array.from(a);return[f[i],f[c]]=[f[c],f[i]],[p[i],p[c]]=[p[c],p[i]],D.fromData(u,f,s,p,r.offset)}function xt(r,t,e){let n=r.ndim,o=Array.isArray(t)?t:[t],a=Array.isArray(e)?e:[e];if(o.length!==a.length)throw new Error("source and destination must have the same number of elements");let u=o.map(c=>{let f=c<0?n+c:c;if(f<0||f>=n)throw new Error(`source axis ${c} is out of bounds for array of dimension ${n}`);return f}),s=a.map(c=>{let f=c<0?n+c:c;if(f<0||f>=n)throw new Error(`destination axis ${c} is out of bounds for array of dimension ${n}`);return f});if(new Set(u).size!==u.length)throw new Error("repeated axis in source");if(new Set(s).size!==s.length)throw new Error("repeated axis in destination");let i=[];for(let c=0;c<n;c++)u.includes(c)||i.push(c);for(let c=0;c<u.length;c++){let f=s[c];i.splice(f,0,u[c])}return hr(r,i)}function or(r,t=0){if(r.length===0)throw new Error("need at least one array to concatenate");if(r.length===1)return r[0].copy();let e=r[0],n=e.ndim,o=e.dtype,a=t<0?n+t:t;if(a<0||a>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);for(let y=1;y<r.length;y++){let m=r[y];if(m.ndim!==n)throw new Error("all the input arrays must have same number of dimensions");for(let d=0;d<n;d++)if(d!==a&&m.shape[d]!==e.shape[d])throw new Error("all the input array dimensions except for the concatenation axis must match exactly")}let u=Array.from(e.shape),s=e.shape[a];for(let y=1;y<r.length;y++)s+=r[y].shape[a];u[a]=s;let i=u.reduce((y,m)=>y*m,1),c=U(o);if(!c)throw new Error(`Cannot concatenate arrays with dtype ${o}`);let f=new c(i),p=L(u),l=0;for(let y of r){let m=y.shape[a];Li(y,f,u,p,a,l,o),l+=m}return D.fromData(f,u,o)}function Li(r,t,e,n,o,a,u){let s=r.shape,i=s.length,c=r.size,f=u==="int64"||u==="uint64";if(o===0&&r.isCContiguous&&i>0){let y=a*n[0],m=r.data,d=r.offset,g=d+c;t.set(m.subarray(d,g),y);return}if(o===1&&i===2&&r.isCContiguous){let y=s[0],m=s[1],d=e[1],g=r.data,h=r.offset;for(let A=0;A<y;A++){let b=h+A*m,S=A*d+a;t.set(g.subarray(b,b+m),S)}return}let p=new Array(i).fill(0),l=a*n[o];for(let y=0;y<c;y++){let m=r.iget(y),d=l;for(let g=0;g<i;g++)d+=p[g]*n[g];t[d]=m;for(let g=i-1;g>=0&&(p[g]++,!(p[g]<s[g]));g--)p[g]=0}}function Te(r,t=0){if(r.length===0)throw new Error("need at least one array to stack");let e=r[0],n=e.shape,o=e.ndim,a=t<0?o+1+t:t;if(a<0||a>o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o+1}`);for(let s=1;s<r.length;s++){let i=r[s];if(i.ndim!==o)throw new Error("all input arrays must have the same shape");for(let c=0;c<o;c++)if(i.shape[c]!==n[c])throw new Error("all input arrays must have the same shape")}let u=r.map(s=>gr(s,a));return or(u,a)}function Oe(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?W(e,[1,e.shape[0]]):e);return or(t,0)}function It(r){if(r.length===0)throw new Error("need at least one array to stack");return r.every(e=>e.ndim===1)?or(r,0):or(r,1)}function $e(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?W(gr(W(e,[1,e.shape[0]]),2),[1,e.shape[0],1]):e.ndim===2?gr(e,2):e);return or(t,2)}function ve(r,t,e=0){let n=r.shape,o=n.length,a=e<0?o+e:e;if(a<0||a>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let u=n[a],s;if(typeof t=="number"){if(u%t!==0)throw new Error("array split does not result in an equal division");let i=u/t;s=[];for(let c=1;c<t;c++)s.push(c*i)}else s=t;return Me(r,s,a)}function br(r,t,e=0){let n=r.shape,o=n.length,a=e<0?o+e:e;if(a<0||a>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let u=n[a],s;if(typeof t=="number"){let i=t,c=Math.floor(u/i),f=u%i;s=[];let p=0;for(let l=0;l<i-1;l++)p+=c+(l<f?1:0),s.push(p)}else s=t;return Me(r,s,a)}function Me(r,t,e){let n=r.shape,o=n[e],a=[0,...t,o],u=[];for(let s=0;s<a.length-1;s++){let i=a[s],c=a[s+1];if(i>c)throw new Error("split indices must be in ascending order");let f=Array.from(n);f[e]=c-i;let p=r.offset+i*r.strides[e];u.push(D.fromData(r.data,f,r.dtype,Array.from(r.strides),p))}return u}function Ce(r,t){if(r.ndim<2)throw new Error("vsplit only works on arrays of 2 or more dimensions");return br(r,t,0)}function ke(r,t){if(r.ndim<1)throw new Error("hsplit only works on arrays of 1 or more dimensions");let e=r.ndim===1?0:1;return br(r,t,e)}function Ve(r,t){let e=r.shape,n=e.length,o=r.dtype,a=Array.isArray(t)?t:[t],u=Math.max(n,a.length),s=new Array(u).fill(1),i=new Array(u).fill(1);for(let A=0;A<n;A++)s[u-n+A]=e[A];for(let A=0;A<a.length;A++)i[u-a.length+A]=a[A];let c=s.map((A,b)=>A*i[b]),f=c.reduce((A,b)=>A*b,1),p=U(o);if(!p)throw new Error(`Cannot tile array with dtype ${o}`);let l=new p(f),y=L(c),m=r;n<u&&(m=W(r,s));let d=o==="int64"||o==="uint64",g=m.strides,h=new Array(u).fill(0);for(let A=0;A<f;A++){let b=m.offset;for(let x=0;x<u;x++){let I=h[x]%s[x];b+=I*g[x]}let S=m.data[b],N=0;for(let x=0;x<u;x++)N+=h[x]*y[x];l[N]=S;for(let x=u-1;x>=0&&(h[x]++,!(h[x]<c[x]));x--)h[x]=0}return D.fromData(l,c,o)}function Pe(r,t,e){let n=r.shape,o=n.length,a=r.dtype,u=r.size;if(e===void 0){let A=u,b=Array.isArray(t)?t:new Array(A).fill(t);if(b.length!==A)throw new Error(`operands could not be broadcast together with shape (${A},) (${b.length},)`);let S=b.reduce((z,B)=>z+B,0),N=U(a);if(!N)throw new Error(`Cannot repeat array with dtype ${a}`);let x=new N(S),I=0;for(let z=0;z<A;z++){let B=r.iget(z),E=b[z];for(let T=0;T<E;T++)x[I++]=B}return D.fromData(x,[S],a)}let s=e<0?o+e:e;if(s<0||s>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let i=n[s],c=Array.isArray(t)?t:new Array(i).fill(t);if(c.length!==i)throw new Error(`operands could not be broadcast together with shape (${i},) (${c.length},)`);let f=Array.from(n);f[s]=c.reduce((A,b)=>A+b,0);let p=f.reduce((A,b)=>A*b,1),l=U(a);if(!l)throw new Error(`Cannot repeat array with dtype ${a}`);let y=new l(p),m=L(f),d=new Array(o).fill(0),g=a==="int64"||a==="uint64",h=[0];for(let A=0;A<i;A++)h.push(h[A]+c[A]);for(let A=0;A<u;A++){let b=r.iget(A),S=d[s],N=c[S],x=0;for(let B=0;B<o;B++)B!==s&&(x+=d[B]*m[B]);let I=m[s],z=h[S];for(let B=0;B<N;B++){let E=x+(z+B)*I;y[E]=b}for(let B=o-1;B>=0&&(d[B]++,!(d[B]<n[B]));B--)d[B]=0}return D.fromData(y,f,a)}function Fe(r,t){let e=r.shape,n=e.length,o=r.dtype,a=r.size,u;if(t===void 0)u=new Set(Array.from({length:n},(l,y)=>y));else if(typeof t=="number"){let l=t<0?n+t:t;if(l<0||l>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);u=new Set([l])}else u=new Set(t.map(l=>{let y=l<0?n+l:l;if(y<0||y>=n)throw new Error(`axis ${l} is out of bounds for array of dimension ${n}`);return y}));let s=U(o);if(!s)throw new Error(`Cannot flip array with dtype ${o}`);let i=new s(a),c=w(o);if(n===1&&r.isCContiguous){let l=r.data,y=r.offset;for(let m=0;m<a;m++)i[m]=l[y+a-1-m];return D.fromData(i,[...e],o)}if(n===2&&r.isCContiguous){let l=e[0],y=e[1],m=r.data,d=r.offset;if(u.size===2){for(let g=0;g<a;g++)i[g]=m[d+a-1-g];return D.fromData(i,[...e],o)}if(u.size===1){if(u.has(0)){for(let g=0;g<l;g++){let h=d+(l-1-g)*y,A=g*y;for(let b=0;b<y;b++)i[A+b]=m[h+b]}return D.fromData(i,[...e],o)}else if(u.has(1)){for(let g=0;g<l;g++){let h=d+g*y,A=g*y;for(let b=0;b<y;b++)i[A+b]=m[h+y-1-b]}return D.fromData(i,[...e],o)}}}let f=new Array(n),p=new Array(n).fill(0);for(let l=0;l<a;l++){for(let d=0;d<n;d++)f[d]=u.has(d)?e[d]-1-p[d]:p[d];let y=r.offset;for(let d=0;d<n;d++)y+=f[d]*r.strides[d];let m=r.data[y];i[l]=m;for(let d=n-1;d>=0&&(p[d]++,!(p[d]<e[d]));d--)p[d]=0}return D.fromData(i,[...e],o)}function Re(r,t=1,e=[0,1]){let n=r.shape,o=n.length,a=r.dtype;if(o<2)throw new Error("Input must be at least 2-D");let u=e[0]<0?o+e[0]:e[0],s=e[1]<0?o+e[1]:e[1];if(u<0||u>=o||s<0||s>=o)throw new Error(`Axes are out of bounds for array of dimension ${o}`);if(u===s)throw new Error("Axes must be different");if(t=(t%4+4)%4,t===0)return r.copy();let i=U(a);if(!i)throw new Error(`Cannot rotate array with dtype ${a}`);let c=[...n];(t===1||t===3)&&([c[u],c[s]]=[c[s],c[u]]);let f=c.reduce((g,h)=>g*h,1),p=new i(f),l=L(c),y=w(a),m=new Array(o).fill(0),d=new Array(o);for(let g=0;g<r.size;g++){for(let N=0;N<o;N++)d[N]=m[N];let h,A;t===1?(h=n[s]-1-m[s],A=m[u]):t===2?(h=n[u]-1-m[u],A=n[s]-1-m[s],d[u]=h,d[s]=A):(h=m[s],A=n[u]-1-m[u]),t!==2&&(d[u]=h,d[s]=A);let b=0;for(let N=0;N<o;N++)b+=d[N]*l[N];let S=r.iget(g);p[b]=S;for(let N=o-1;N>=0&&(m[N]++,!(m[N]<n[N]));N--)m[N]=0}return D.fromData(p,c,a)}function Le(r,t,e){let n=r.shape,o=n.length,a=r.dtype,u=r.size;if(e===void 0){let m=Array.isArray(t)?t.reduce((b,S)=>b+S,0):t,d=Rr(r),g=U(a);if(!g)throw new Error(`Cannot roll array with dtype ${a}`);let h=new g(u),A=w(a);for(let b=0;b<u;b++){let S=((b-m)%u+u)%u,N=d.iget(S);h[b]=N}return D.fromData(h,[...n],a)}let s=Array.isArray(t)?t:[t],i=Array.isArray(e)?e:[e];if(s.length!==i.length)throw new Error("shift and axis must have the same length");let c=i.map(m=>{let d=m<0?o+m:m;if(d<0||d>=o)throw new Error(`axis ${m} is out of bounds for array of dimension ${o}`);return d}),f=U(a);if(!f)throw new Error(`Cannot roll array with dtype ${a}`);let p=new f(u),l=w(a),y=new Array(o).fill(0);for(let m=0;m<u;m++){let d=[...y];for(let A=0;A<c.length;A++){let b=c[A],S=n[b],N=s[A];d[b]=((d[b]-N)%S+S)%S}let g=r.offset;for(let A=0;A<o;A++)g+=d[A]*r.strides[A];let h=r.data[g];p[m]=h;for(let A=o-1;A>=0&&(y[A]++,!(y[A]<n[A]));A--)y[A]=0}return D.fromData(p,[...n],a)}function qe(r,t,e=0){let n=r.ndim,o=t<0?n+t:t;if(o<0||o>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let a=e<0?n+e:e;if(a<0||a>n)throw new Error(`start ${e} is out of bounds`);return o<a&&a--,o===a?D.fromData(r.data,Array.from(r.shape),r.dtype,Array.from(r.strides),r.offset):xt(r,o,a)}function je(r,t){if(r.ndim<3)throw new Error("dsplit only works on arrays of 3 or more dimensions");return br(r,t,2)}function Ze(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?W(e,[e.shape[0],1]):e);return It(t)}function We(r,t){let e=r.dtype,n=t.reduce((i,c)=>i*c,1),o=r.size,a=U(e);if(!a)throw new Error(`Cannot resize array with dtype ${e}`);let u=new a(n),s=w(e);for(let i=0;i<n;i++){let c=i%o,f=r.iget(c);u[i]=f}return D.fromData(u,t,e)}function Ge(r){return r.map(t=>t.ndim===0?W(t,[1]):t)}function He(r){return r.map(t=>t.ndim===0?W(t,[1,1]):t.ndim===1?W(t,[1,t.shape[0]]):t)}function Ye(r){return r.map(t=>t.ndim===0?W(t,[1,1,1]):t.ndim===1?W(t,[1,t.shape[0],1]):t.ndim===2?W(t,[t.shape[0],t.shape[1],1]):t)}var zt=M(()=>{"use strict";Z();R()});function qi(r,t,e,n,o,a,u,s,i,c,f,p,l,y){if(p===0)for(let h=0;h<n*o;h++)l[h]=0;else if(p!==1)for(let h=0;h<n*o;h++)l[h]=(l[h]??0)*p;let m=r==="row-major",d=t==="transpose",g=e==="transpose";if(m&&!d&&!g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[h*i+S]??0)*(c[S*f+A]??0);l[h*y+A]=(l[h*y+A]??0)+u*b}else if(m&&d&&!g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[S*i+h]??0)*(c[S*f+A]??0);l[h*y+A]=(l[h*y+A]??0)+u*b}else if(m&&!d&&g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[h*i+S]??0)*(c[A*f+S]??0);l[h*y+A]=(l[h*y+A]??0)+u*b}else if(m&&d&&g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[S*i+h]??0)*(c[A*f+S]??0);l[h*y+A]=(l[h*y+A]??0)+u*b}else if(!m&&!d&&!g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[S*i+h]??0)*(c[A*f+S]??0);l[A*y+h]=(l[A*y+h]??0)+u*b}else if(!m&&d&&!g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[h*i+S]??0)*(c[A*f+S]??0);l[A*y+h]=(l[A*y+h]??0)+u*b}else if(!m&&!d&&g)for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[S*i+h]??0)*(c[S*f+A]??0);l[A*y+h]=(l[A*y+h]??0)+u*b}else for(let h=0;h<n;h++)for(let A=0;A<o;A++){let b=0;for(let S=0;S<a;S++)b+=(s[h*i+S]??0)*(c[S*f+A]??0);l[A*y+h]=(l[A*y+h]??0)+u*b}}function Bt(r,t){let e=r.ndim,n=t.ndim;if(e===0||n===0){let o=e===0?r.get():null,a=n===0?t.get():null;if(e===0&&n===0)return typeof o=="bigint"&&typeof a=="bigint"?o*a:Number(o)*Number(a);if(e===0){let u=v(r.dtype,t.dtype),s=D.zeros([...t.shape],u);for(let i=0;i<t.size;i++){let c=t.data[i+t.offset];typeof o=="bigint"&&typeof c=="bigint"?s.data[i]=o*c:s.data[i]=Number(o)*Number(c)}return s}else{let u=v(r.dtype,t.dtype),s=D.zeros([...r.shape],u);for(let i=0;i<r.size;i++){let c=r.data[i+r.offset];typeof c=="bigint"&&typeof a=="bigint"?s.data[i]=c*a:s.data[i]=Number(c)*Number(a)}return s}}if(e===1&&n===1){if(r.shape[0]!==t.shape[0])throw new Error(`dot: incompatible shapes (${r.shape[0]},) and (${t.shape[0]},)`);let o=r.shape[0],a=0;for(let u=0;u<o;u++){let s=r.get(u),i=t.get(u);typeof s=="bigint"&&typeof i=="bigint"?a=Number(a)+Number(s*i):a+=Number(s)*Number(i)}return a}if(e===2&&n===2)return ar(r,t);if(e===2&&n===1){let[o,a]=r.shape,u=t.shape[0];if(a!==u)throw new Error(`dot: incompatible shapes (${o},${a}) and (${u},)`);let s=v(r.dtype,t.dtype),i=D.zeros([o],s);for(let c=0;c<o;c++){let f=0;for(let p=0;p<a;p++){let l=r.get(c,p),y=t.get(p);typeof l=="bigint"&&typeof y=="bigint"?f=Number(f)+Number(l*y):f+=Number(l)*Number(y)}i.set([c],f)}return i}if(e===1&&n===2){let o=r.shape[0],[a,u]=t.shape;if(o!==a)throw new Error(`dot: incompatible shapes (${o},) and (${a},${u})`);let s=v(r.dtype,t.dtype),i=D.zeros([u],s);for(let c=0;c<u;c++){let f=0;for(let p=0;p<o;p++){let l=r.get(p),y=t.get(p,c);typeof l=="bigint"&&typeof y=="bigint"?f=Number(f)+Number(l*y):f+=Number(l)*Number(y)}i.set([c],f)}return i}if(e>2&&n===1){let o=r.shape[e-1],a=t.shape[0];if(o!==a)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and (${a},)`);let u=[...r.shape.slice(0,-1)],s=v(r.dtype,t.dtype),i=D.zeros(u,s),c=u.reduce((f,p)=>f*p,1);for(let f=0;f<c;f++){let p=0,l=f,y=[];for(let m=u.length-1;m>=0;m--)y[m]=l%u[m],l=Math.floor(l/u[m]);for(let m=0;m<o;m++){let d=[...y,m],g=r.get(...d),h=t.get(m);typeof g=="bigint"&&typeof h=="bigint"?p=Number(p)+Number(g*h):p+=Number(g)*Number(h)}i.set(y,p)}return i}if(e===1&&n>2){let o=r.shape[0],a=1,u=t.shape[a];if(o!==u)throw new Error(`dot: incompatible shapes (${o},) and ${JSON.stringify(t.shape)}`);let s=[...t.shape.slice(0,a),...t.shape.slice(a+1)],i=v(r.dtype,t.dtype),c=D.zeros(s,i),f=s.reduce((p,l)=>p*l,1);for(let p=0;p<f;p++){let l=p,y=[];for(let h=s.length-1;h>=0;h--)y[h]=l%s[h],l=Math.floor(l/s[h]);let m=y.slice(0,a),d=y.slice(a),g=0;for(let h=0;h<o;h++){let A=r.get(h),b=[...m,h,...d],S=t.get(...b);typeof A=="bigint"&&typeof S=="bigint"?g=Number(g)+Number(A*S):g+=Number(A)*Number(S)}c.set(y,g)}return c}if(e>=2&&n>=2&&!(e===2&&n===2)){let o=r.shape[e-1],a=t.shape[n-2];if(o!==a)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and ${JSON.stringify(t.shape)}`);let u=[...r.shape.slice(0,-1),...t.shape.slice(0,-2),t.shape[n-1]],s=v(r.dtype,t.dtype),i=D.zeros(u,s),c=r.shape.slice(0,-1).reduce((y,m)=>y*m,1),f=t.shape.slice(0,-2).reduce((y,m)=>y*m,1),p=t.shape[n-1],l=o;for(let y=0;y<c;y++)for(let m=0;m<f;m++)for(let d=0;d<p;d++){let g=0;for(let A=0;A<l;A++){let b=y*l+A,S=r.data[b+r.offset],N=m*l*p+A*p+d,x=t.data[N+t.offset];typeof S=="bigint"&&typeof x=="bigint"?g=Number(g)+Number(S*x):g+=Number(S)*Number(x)}let h=y*f*p+m*p+d;i.data[h]=g}return i}throw new Error(`dot: unexpected combination of dimensions ${e}D \xB7 ${n}D`)}function ar(r,t){if(r.ndim!==2||t.ndim!==2)throw new Error("matmul requires 2D arrays");let[e=0,n=0]=r.shape,[o=0,a=0]=t.shape;if(n!==o)throw new Error(`matmul shape mismatch: (${e},${n}) @ (${o},${a})`);let u=v(r.dtype,t.dtype),s=u.startsWith("int")||u.startsWith("uint")||u==="bool"?"float64":u;if(s!=="float64")throw new Error(`matmul currently only supports float64, got ${s}`);let i=r.dtype==="float64"?r.data:Float64Array.from(Array.from(r.data).map(Number)),c=t.dtype==="float64"?t.data:Float64Array.from(Array.from(t.data).map(Number));r.offset>0&&(i=i.subarray(r.offset)),t.offset>0&&(c=c.subarray(t.offset));let[f=0,p=0]=r.strides,[l=0,y=0]=t.strides,m=p>f,d=y>l,g=m?"transpose":"no-transpose",h=d?"transpose":"no-transpose",A,b;m?A=p:A=f,d?b=y:b=l;let S=D.zeros([e,a],"float64");return qi("row-major",g,h,e,a,n,1,i,A,c,b,0,S.data,a),S}function Qe(r){if(r.ndim!==2)throw new Error(`trace requires 2D array, got ${r.ndim}D`);let[t=0,e=0]=r.shape,n=Math.min(t,e),o=0;for(let a=0;a<n;a++){let u=r.get(a,a);typeof u=="bigint"?o=(typeof o=="bigint"?o:BigInt(o))+u:o=(typeof o=="bigint"?Number(o):o)+u}return o}function Xe(r,t){return hr(r,t)}function Ke(r,t){let e=r.ndim,n=t.ndim,o=r.shape[e-1],a=t.shape[n-1];if(o!==a)throw new Error(`inner: incompatible shapes - last dimensions ${o} and ${a} don't match`);if(e===1&&n===1)return Bt(r,t);let u=[...r.shape.slice(0,-1),...t.shape.slice(0,-1)],s=v(r.dtype,t.dtype),i=D.zeros(u,s),c=e===1?1:r.shape.slice(0,-1).reduce((l,y)=>l*y,1),f=n===1?1:t.shape.slice(0,-1).reduce((l,y)=>l*y,1),p=o;for(let l=0;l<c;l++)for(let y=0;y<f;y++){let m=0;for(let g=0;g<p;g++){let h=e===1?g:l*p+g,A=n===1?g:y*p+g,b=r.data[h+r.offset],S=t.data[A+t.offset];typeof b=="bigint"&&typeof S=="bigint"?m=Number(m)+Number(b*S):m+=Number(b)*Number(S)}if(u.length===0)return m;let d=c===1?y:l*f+y;i.data[d]=m}return i}function Et(r,t){let e=r.ndim===1?r:Ar(r),n=t.ndim===1?t:Ar(t),o=e.size,a=n.size,u=v(r.dtype,t.dtype),s=D.zeros([o,a],u);for(let i=0;i<o;i++)for(let c=0;c<a;c++){let f=e.get(i),p=n.get(c),l;typeof f=="bigint"&&typeof p=="bigint"?l=f*p:l=Number(f)*Number(p),s.set([i,c],l)}return s}function rn(r,t,e){let n,o;if(typeof e=="number"){let l=e;if(l<0)throw new Error("tensordot: axes must be non-negative");if(l>r.ndim||l>t.ndim)throw new Error("tensordot: axes exceeds array dimensions");n=Array.from({length:l},(y,m)=>r.ndim-l+m),o=Array.from({length:l},(y,m)=>m)}else if([n,o]=e,n.length!==o.length)throw new Error("tensordot: axes lists must have same length");for(let l=0;l<n.length;l++){let y=n[l],m=o[l];if(y<0||y>=r.ndim||m<0||m>=t.ndim)throw new Error("tensordot: axis out of bounds");if(r.shape[y]!==t.shape[m])throw new Error(`tensordot: shape mismatch on axes ${y} and ${m}: ${r.shape[y]} != ${t.shape[m]}`)}let a=[],u=[];for(let l=0;l<r.ndim;l++)n.includes(l)||a.push(l);for(let l=0;l<t.ndim;l++)o.includes(l)||u.push(l);let s=[...a.map(l=>r.shape[l]),...u.map(l=>t.shape[l])];if(s.length===0){let l=0,y=n.map(m=>r.shape[m]).reduce((m,d)=>m*d,1);for(let m=0;m<y;m++){let d=m,g=new Array(n.length);for(let N=n.length-1;N>=0;N--){let x=n[N];g[N]=d%r.shape[x],d=Math.floor(d/r.shape[x])}let h=new Array(r.ndim),A=new Array(t.ndim);for(let N=0;N<n.length;N++)h[n[N]]=g[N];for(let N=0;N<o.length;N++)A[o[N]]=g[N];let b=r.get(...h),S=t.get(...A);typeof b=="bigint"&&typeof S=="bigint"?l=Number(l)+Number(b*S):l+=Number(b)*Number(S)}return l}let i=v(r.dtype,t.dtype),c=D.zeros(s,i),f=s.reduce((l,y)=>l*y,1),p=n.map(l=>r.shape[l]).reduce((l,y)=>l*y,1);for(let l=0;l<f;l++){let y=l,m=[];for(let A=s.length-1;A>=0;A--)m[A]=y%s[A],y=Math.floor(y/s[A]);let d=m.slice(0,a.length),g=m.slice(a.length),h=0;for(let A=0;A<p;A++){y=A;let b=[];for(let z=n.length-1;z>=0;z--){let B=n[z];b[z]=y%r.shape[B],y=Math.floor(y/r.shape[B])}let S=new Array(r.ndim),N=new Array(t.ndim);for(let z=0;z<a.length;z++)S[a[z]]=d[z];for(let z=0;z<u.length;z++)N[u[z]]=g[z];for(let z=0;z<n.length;z++)S[n[z]]=b[z],N[o[z]]=b[z];let x=r.get(...S),I=t.get(...N);typeof x=="bigint"&&typeof I=="bigint"?h=Number(h)+Number(x*I):h+=Number(x)*Number(I)}c.set(m,h)}return c}function tn(r,t=0,e=0,n=1){let o=r.shape,a=o.length;if(a<2)throw new Error("diagonal requires an array of at least two dimensions");let u=e<0?a+e:e,s=n<0?a+n:n;if(u<0||u>=a||s<0||s>=a)throw new Error("axis out of bounds");if(u===s)throw new Error("axis1 and axis2 cannot be the same");let i=o[u],c=o[s],f;t>=0?f=Math.max(0,Math.min(i,c-t)):f=Math.max(0,Math.min(i+t,c));let p=[];for(let d=0;d<a;d++)d!==u&&d!==s&&p.push(o[d]);p.push(f);let l=D.zeros(p,r.dtype),y=o.filter((d,g)=>g!==u&&g!==s),m=y.reduce((d,g)=>d*g,1);for(let d=0;d<m;d++){let g=d,h=[];for(let A=y.length-1;A>=0;A--)h.unshift(g%y[A]),g=Math.floor(g/y[A]);for(let A=0;A<f;A++){let b=new Array(a),S=0;for(let I=0;I<a;I++)I===u?b[I]=t>=0?A:A-t:I===s?b[I]=t>=0?A+t:A:b[I]=h[S++];let N=[...h,A],x=r.get(...b);l.set(N,x)}}return l}function en(r,...t){let e=r.indexOf("->"),n,o;e===-1?(n=r,o=ji(n)):(n=r.slice(0,e),o=r.slice(e+2));let a=n.split(",").map(d=>d.trim());if(a.length!==t.length)throw new Error(`einsum: expected ${a.length} operands, got ${t.length}`);let u=new Map;for(let d=0;d<t.length;d++){let g=a[d],h=t[d];if(g.length!==h.ndim)throw new Error(`einsum: operand ${d} has ${h.ndim} dimensions but subscript '${g}' has ${g.length} indices`);for(let A=0;A<g.length;A++){let b=g[A],S=h.shape[A];if(u.has(b)){if(u.get(b)!==S)throw new Error(`einsum: size mismatch for index '${b}': ${u.get(b)} vs ${S}`)}else u.set(b,S)}}for(let d of o)if(!u.has(d))throw new Error(`einsum: output subscript contains unknown index '${d}'`);let s=new Set(o),i=new Set;for(let d of a)for(let g of d)i.add(g);let c=[];for(let d of i)s.has(d)||c.push(d);if(t.length===2&&a.length===2){let[d,g]=a,[h,A]=t;if(d.length===2&&g.length===2&&o.length===2&&h.ndim===2&&A.ndim===2){let[b,S]=[d[0],d[1]],[N,x]=[g[0],g[1]],[I,z]=[o[0],o[1]];if(b===I&&x===z&&S===N&&c.length===1&&c[0]===S||b===I&&x===z&&S===N&&c.length===1&&c[0]===S)return ar(h,A);if(S===I&&x===z&&b===N&&c.length===1&&c[0]===b){let B=Xe(h);return ar(B,A)}if(b===I&&N===z&&S===x&&c.length===1&&c[0]===S){let B=Xe(A);return ar(h,B)}}if(d.length===1&&g.length===1&&d===g&&o.length===0&&h.ndim===1&&A.ndim===1)return _t(t,a,c,u);if(d&&g&&d.length===1&&g.length===1&&o.length===2&&o===d+g&&c.length===0&&h.ndim===1&&A.ndim===1)return Et(h,A)}if(t.length===1&&a[0].length===2&&o.length===0){let d=a[0];if(d[0]===d[1]&&t[0].ndim===2)return _t(t,a,c,u)}let f=Array.from(o).map(d=>u.get(d));if(f.length===0)return _t(t,a,c,u);let p=t[0].dtype;for(let d=1;d<t.length;d++)p=v(p,t[d].dtype);let l=D.zeros(f,p),y=f.reduce((d,g)=>d*g,1),m=1;for(let d of c)m*=u.get(d);for(let d=0;d<y;d++){let g=Zi(d,f),h=new Map;for(let b=0;b<o.length;b++)h.set(o[b],g[b]);let A=0;for(let b=0;b<m;b++){let S=b;for(let x=c.length-1;x>=0;x--){let I=c[x],z=u.get(I);h.set(I,S%z),S=Math.floor(S/z)}let N=1;for(let x=0;x<t.length;x++){let I=t[x],z=a[x],B=[];for(let T of z)B.push(h.get(T));let E=I.get(...B);N*=Number(E)}A+=N}l.set(g,A)}return l}function ji(r){let t=new Map,e=r.split(",");for(let o of e)for(let a of o.trim())t.set(a,(t.get(a)||0)+1);let n=[];for(let[o,a]of t)a===1&&n.push(o);return n.sort().join("")}function _t(r,t,e,n){let o=1;for(let u of e)o*=n.get(u);let a=0;for(let u=0;u<o;u++){let s=new Map,i=u;for(let f=e.length-1;f>=0;f--){let p=e[f],l=n.get(p);s.set(p,i%l),i=Math.floor(i/l)}let c=1;for(let f=0;f<r.length;f++){let p=r[f],l=t[f],y=[];for(let d of l)y.push(s.get(d));let m=p.get(...y);c*=Number(m)}a+=c}return a}function Zi(r,t){let e=new Array(t.length),n=r;for(let o=t.length-1;o>=0;o--)e[o]=n%t[o],n=Math.floor(n/t[o]);return e}function nn(r,t){let e=r.shape,n=t.shape,o=e.length,a=n.length,u=v(r.dtype,t.dtype),s=Math.max(o,a),i=new Array(s),c=new Array(s).fill(1),f=new Array(s).fill(1);for(let m=0;m<o;m++)c[s-o+m]=e[m];for(let m=0;m<a;m++)f[s-a+m]=n[m];for(let m=0;m<s;m++)i[m]=c[m]*f[m];let p=D.zeros(i,u),l=e.reduce((m,d)=>m*d,1),y=n.reduce((m,d)=>m*d,1);for(let m=0;m<l;m++){let d=m,g=new Array(o);for(let b=o-1;b>=0;b--)g[b]=d%e[b],d=Math.floor(d/e[b]);let h=new Array(s).fill(0);for(let b=0;b<o;b++)h[s-o+b]=g[b];let A=r.get(...g);for(let b=0;b<y;b++){let S=b,N=new Array(a);for(let E=a-1;E>=0;E--)N[E]=S%n[E],S=Math.floor(S/n[E]);let x=new Array(s).fill(0);for(let E=0;E<a;E++)x[s-a+E]=N[E];let I=t.get(...N),z=new Array(s);for(let E=0;E<s;E++)z[E]=h[E]*f[E]+x[E];let B=typeof A=="bigint"||typeof I=="bigint"?BigInt(Number(A))*BigInt(Number(I)):Number(A)*Number(I);p.set(z,B)}}return p}var on=M(()=>{"use strict";Z();R();zt()});function an(r){return V(r,Math.sqrt,!1)}function sn(r,t){return typeof t=="number"?Gi(r,t):P(r,t,Math.pow,"power")}function Gi(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=e!=="float32"&&e!=="float64"&&(t<0||!Number.isInteger(t))?"float64":e,c=D.zeros(n,i),f=c.data;if(w(e))if(w(i)&&Number.isInteger(t)&&t>=0){let p=o,l=f;for(let y=0;y<a;y++)l[y]=p[y]**BigInt(t)}else for(let p=0;p<a;p++)f[p]=Math.pow(Number(o[p]),t);else for(let p=0;p<a;p++)f[p]=Math.pow(Number(o[p]),t);return c}var un=M(()=>{"use strict";Z();nr();R()});function cn(r){return V(r,Math.sin,!1)}function fn(r){return V(r,Math.cos,!1)}function ln(r){return V(r,Math.tan,!1)}function pn(r){return V(r,Math.asin,!1)}function yn(r){return V(r,Math.acos,!1)}function mn(r){return V(r,Math.atan,!1)}function dn(r,t){return typeof t=="number"?Ji(r,t):Yi(r,t)}function Yi(r,t){let e=Array.from(r.shape),n=r.size,o=r.dtype,a=t.dtype,u=o==="float32"&&a==="float32"?"float32":"float64",s=D.zeros(e,u),i=s.data;for(let c=0;c<n;c++){let f=(w(o),Number(r.data[c])),p=(w(a),Number(t.data[c]));i[c]=Math.atan2(f,p)}return s}function Ji(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=e==="float32"?"float32":"float64",s=D.zeros(n,u),i=s.data;if(w(e))for(let c=0;c<a;c++)i[c]=Math.atan2(Number(o[c]),t);else for(let c=0;c<a;c++)i[c]=Math.atan2(Number(o[c]),t);return s}function gn(r,t){return typeof t=="number"?Qi(r,t):Xi(r,t)}function Xi(r,t){let e=Array.from(r.shape),n=r.size,o=r.dtype,a=t.dtype,u=o==="float32"&&a==="float32"?"float32":"float64",s=D.zeros(e,u),i=s.data;for(let c=0;c<n;c++){let f=(w(o),Number(r.data[c])),p=(w(a),Number(t.data[c]));i[c]=Math.hypot(f,p)}return s}function Qi(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=e==="float32"?"float32":"float64",s=D.zeros(n,u),i=s.data;if(w(e))for(let c=0;c<a;c++)i[c]=Math.hypot(Number(o[c]),t);else for(let c=0;c<a;c++)i[c]=Math.hypot(Number(o[c]),t);return s}function An(r){let t=180/Math.PI;return V(r,e=>e*t,!1)}function hn(r){let t=Math.PI/180;return V(r,e=>e*t,!1)}var bn=M(()=>{"use strict";Z();nr();R()});function Sn(r){return V(r,Math.sinh,!1)}function Dn(r){return V(r,Math.cosh,!1)}function Nn(r){return V(r,Math.tanh,!1)}function wn(r){return V(r,Math.asinh,!1)}function xn(r){return V(r,Math.acosh,!1)}function In(r){return V(r,Math.atanh,!1)}var zn=M(()=>{"use strict";nr()});function Ut(r,t){let e=r.shape,n=e.length,o=t.length;if(o<n)throw new Error("input operand has more dimensions than allowed by the axis remapping");let a=rr([Array.from(e),t]);if(a===null)throw new Error(`operands could not be broadcast together with shape (${e.join(",")}) (${t.join(",")})`);for(let u=0;u<o;u++)if(a[u]!==t[u])throw new Error(`operands could not be broadcast together with shape (${e.join(",")}) (${t.join(",")})`);return H(r,t)}function _n(r){if(r.length===0)return[];if(r.length===1)return[r[0]];let t=r.map(n=>Array.from(n.shape)),e=rr(t);if(e===null)throw new Error(`operands could not be broadcast together with shapes ${t.map(n=>`(${n.join(",")})`).join(" ")}`);return r.map(n=>H(n,e))}function Bn(r,t,e){let n=r.shape,o=n.length,a=r.dtype;if(e===void 0){let m=r.size;for(let A of t){let b=A<0?m+A:A;if(b<0||b>=m)throw new Error(`index ${A} is out of bounds for axis 0 with size ${m}`)}let d=t.length,g=U(a);if(!g)throw new Error(`Cannot take from array with dtype ${a}`);let h=new g(d);for(let A=0;A<d;A++){let b=t[A];b<0&&(b=m+b);let S=r.iget(b);w(a),h[A]=S}return D.fromData(h,[d],a)}let u=e<0?o+e:e;if(u<0||u>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let s=n[u];for(let m of t){let d=m<0?s+m:m;if(d<0||d>=s)throw new Error(`index ${m} is out of bounds for axis ${u} with size ${s}`)}let i=Array.from(n);i[u]=t.length;let c=i.reduce((m,d)=>m*d,1),f=U(a);if(!f)throw new Error(`Cannot take from array with dtype ${a}`);let p=new f(c),l=L(i),y=new Array(o).fill(0);for(let m=0;m<c;m++){let d=[...y],g=y[u],h=t[g];h<0&&(h=s+h),d[u]=h;let A=r.get(...d),b=0;for(let S=0;S<o;S++)b+=y[S]*l[S];w(a),p[b]=A;for(let S=o-1;S>=0&&(y[S]++,!(y[S]<i[S]));S--)y[S]=0}return D.fromData(p,i,a)}function En(r,t,e){let n=r.size,o=r.dtype,a;if(typeof e=="number"||typeof e=="bigint")a=new Array(t.length).fill(e);else{a=[];for(let u=0;u<e.size;u++)a.push(e.iget(u));if(a.length===1)a=new Array(t.length).fill(a[0]);else if(a.length!==t.length){let u=[...a];a=[];for(let s=0;s<t.length;s++)a.push(u[s%u.length])}}for(let u=0;u<t.length;u++){let s=t[u];if(s<0&&(s=n+s),s<0||s>=n)throw new Error(`index ${t[u]} is out of bounds for axis 0 with size ${n}`);let i=a[u];w(o)?typeof i!="bigint"&&(i=BigInt(Math.round(Number(i)))):typeof i=="bigint"&&(i=Number(i)),r.iset(s,i)}}function Un(r,t){if(t.length===0)throw new Error("choices cannot be empty");let e=r.shape,n=t.length,o=t[0].dtype,a=t.map(l=>Array.from(l.shape));a.unshift(Array.from(e));let u=rr(a);if(u===null)throw new Error("operands could not be broadcast together");let s=H(r,u),i=t.map(l=>H(l,u)),c=u.reduce((l,y)=>l*y,1),f=U(o);if(!f)throw new Error(`Cannot choose with dtype ${o}`);let p=new f(c);for(let l=0;l<c;l++){let y=Number(s.iget(l));if(y<0||y>=n)throw new Error(`index ${y} is out of bounds for axis 0 with size ${n}`);let m=i[y].iget(l);w(o),p[l]=m}return D.fromData(p,u,o)}function Tn(r,t,e=!1){if(r.ndim!==t.ndim)return!1;for(let o=0;o<r.ndim;o++)if(r.shape[o]!==t.shape[o])return!1;let n=r.size;for(let o=0;o<n;o++){let a=r.iget(o),u=t.iget(o);if(e){let s=typeof a=="number"&&Number.isNaN(a),i=typeof u=="number"&&Number.isNaN(u);if(s&&i)continue}if(a!==u)return!1}return!0}function On(r,t,e){let n=r.shape,o=n.length,a=r.dtype,u=e<0?o+e:e;if(u<0||u>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let s=t.shape;if(s.length!==o)throw new Error(`indices and arr must have the same number of dimensions, got ${s.length} vs ${o}`);for(let d=0;d<o;d++)if(d!==u&&s[d]!==n[d]&&s[d]!==1&&n[d]!==1)throw new Error(`index ${s[d]} is out of bounds for size ${n[d]} in dimension ${d}`);let i=Array.from(s),c=i.reduce((d,g)=>d*g,1),f=U(a);if(!f)throw new Error(`Cannot take_along_axis with dtype ${a}`);let p=new f(c),l=L(n),y=L(s),m=n[u];for(let d=0;d<c;d++){let g=new Array(o),h=d;for(let I=o-1;I>=0;I--)g[I]=h%i[I],h=Math.floor(h/i[I]);let A=0;for(let I=0;I<o;I++){let z=s[I]===1?0:g[I];A+=z*y[I]}let b=Number(t.iget(A));if(b<0&&(b=m+b),b<0||b>=m)throw new Error(`index ${b} is out of bounds for axis ${u} with size ${m}`);let S=[...g];S[u]=b;let N=0;for(let I=0;I<o;I++){let z=n[I]===1?0:S[I];N+=z*l[I]}let x=r.iget(N);w(a),p[d]=x}return D.fromData(p,i,a)}function $n(r,t,e,n){let o=r.shape,a=o.length,u=r.dtype,s=n<0?a+n:n;if(s<0||s>=a)throw new Error(`axis ${n} is out of bounds for array of dimension ${a}`);let i=t.shape,c=e.shape;if(i.length!==a||c.length!==a)throw new Error("indices, arr, and values must have same ndim");let f=o[s],p=L(o),l=L(i),y=L(c),m=i.reduce((d,g)=>d*g,1);for(let d=0;d<m;d++){let g=new Array(a),h=d;for(let z=a-1;z>=0;z--)g[z]=h%i[z],h=Math.floor(h/i[z]);let A=0;for(let z=0;z<a;z++)A+=g[z]*l[z];let b=Number(t.iget(A));if(b<0&&(b=f+b),b<0||b>=f)throw new Error(`index ${b} is out of bounds for axis ${s} with size ${f}`);let S=0;for(let z=0;z<a;z++){let B=c[z]===1?0:g[z];S+=B*y[z]}let N=e.iget(S),x=[...g];x[s]=b;let I=0;for(let z=0;z<a;z++)I+=x[z]*p[z];w(u)?typeof N!="bigint"&&(N=BigInt(Math.round(Number(N)))):typeof N=="bigint"&&(N=Number(N)),r.iset(I,N)}}function vn(r,t,e){let n=r.size,o=r.dtype,a;if(typeof e=="number"||typeof e=="bigint")a=[e];else{a=[];for(let s=0;s<e.size;s++)a.push(e.iget(s))}let u=0;for(let s=0;s<n;s++)if(t.iget(s)){let c=a[u%a.length];w(o)?typeof c!="bigint"&&(c=BigInt(Math.round(Number(c)))):typeof c=="bigint"&&(c=Number(c)),r.iset(s,c),u++}}function Mn(r,t,e){let n=t.shape,o=n.length,a=t.dtype,u=t.data,s=w(a);if(e===void 0){let A=0,b=Math.min(r.size,t.size);for(let I=0;I<b;I++)r.iget(I)&&A++;let S=U(a);if(!S)throw new Error(`Cannot compress with dtype ${a}`);let N=new S(A),x=0;for(let I=0;I<b;I++)r.iget(I)&&(N[x]=u[I],x++);return D.fromData(N,[A],a)}let i=e<0?o+e:e;if(i<0||i>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let c=n[i],f=Math.min(r.size,c),p=[];for(let A=0;A<f;A++)r.iget(A)&&p.push(A);let l=p.length,y=[...n];y[i]=l;let m=y.reduce((A,b)=>A*b,1),d=U(a);if(!d)throw new Error(`Cannot compress with dtype ${a}`);let g=new d(m),h=L(n);if(i===0){let A=h[0],b=n.slice(1).reduce((N,x)=>N*x,1),S=0;for(let N=0;N<l;N++){let I=p[N]*A;if(s){let z=u,B=g;for(let E=0;E<b;E++)B[S++]=z[I+E]}else{let z=u,B=g;for(let E=0;E<b;E++)B[S++]=z[I+E]}}}else{let A=n.slice(0,i).reduce((N,x)=>N*x,1),b=n.slice(i+1).reduce((N,x)=>N*x,1),S=0;for(let N=0;N<A;N++)for(let x=0;x<l;x++){let I=p[x],z=0,B=N;for(let E=i-1;E>=0;E--){let T=B%n[E];B=Math.floor(B/n[E]),z+=T*h[E]}if(z+=I*h[i],s){let E=u,T=g;for(let k=0;k<b;k++)T[S++]=E[z+k]}else{let E=u,T=g;for(let k=0;k<b;k++)T[S++]=E[z+k]}}}return D.fromData(g,y,a)}function Cn(r,t,e=0){if(r.length!==t.length)throw new Error("condlist and choicelist must have same length");if(r.length===0)throw new Error("condlist and choicelist cannot be empty");let n=[...r.map(l=>Array.from(l.shape)),...t.map(l=>Array.from(l.shape))],o=rr(n);if(o===null)throw new Error("condlist and choicelist arrays could not be broadcast together");let a=t[0].dtype,u=o.reduce((l,y)=>l*y,1),s=U(a);if(!s)throw new Error(`Cannot select with dtype ${a}`);let i=e;w(a)?i=typeof e=="bigint"?e:BigInt(e):i=typeof e=="bigint"?Number(e):e;let c=new s(u);for(let l=0;l<u;l++)w(a),c[l]=i;let f=r.map(l=>H(l,o)),p=t.map(l=>H(l,o));for(let l=0;l<u;l++)for(let y=0;y<r.length;y++)if(f[y].iget(l)){let m=p[y].iget(l);w(a),c[l]=m;break}return D.fromData(c,o,a)}function kn(r,t,e){let n=r.size,o=r.dtype,a=[];for(let s=0;s<e.size;s++)a.push(e.iget(s));if(a.length===0)return;let u=0;for(let s=0;s<n;s++)if(t.iget(s)){let c=a[u%a.length];w(o)?typeof c!="bigint"&&(c=BigInt(Math.round(Number(c)))):typeof c=="bigint"&&(c=Number(c)),r.iset(s,c),u++}}function Tt(r,t=2){if(t<1)throw new Error("ndim must be at least 1");let e=new Int32Array(r);for(let o=0;o<r;o++)e[o]=o;let n=[];for(let o=0;o<t;o++)n.push(D.fromData(new Int32Array(e),[r],"int32"));return n}function Vn(r){let t=r.shape,e=t.length;if(e<2)throw new Error("array must be at least 2-D");let n=t[0];for(let o=1;o<e;o++)if(t[o]!==n)throw new Error("All dimensions of input must be equal");return Tt(n,e)}function Ot(r,t=0,e){let n=e??r,o=[],a=[];for(let u=0;u<r;u++)for(let s=0;s<=Math.min(u+t,n-1);s++)s>=0&&(o.push(u),a.push(s));return[D.fromData(new Int32Array(o),[o.length],"int32"),D.fromData(new Int32Array(a),[a.length],"int32")]}function Pn(r,t=0){let e=r.shape;if(e.length!==2)throw new Error("array must be 2-D");return Ot(e[0],t,e[1])}function $t(r,t=0,e){let n=e??r,o=[],a=[];for(let u=0;u<r;u++)for(let s=Math.max(u+t,0);s<n;s++)o.push(u),a.push(s);return[D.fromData(new Int32Array(o),[o.length],"int32"),D.fromData(new Int32Array(a),[a.length],"int32")]}function Fn(r,t=0){let e=r.shape;if(e.length!==2)throw new Error("array must be 2-D");return $t(e[0],t,e[1])}function Rn(r,t,e=0){let n=t(r,e),o=n.shape;if(o.length!==2||o[0]!==r||o[1]!==r)throw new Error("mask_func must return n x n array");let a=[],u=[];for(let s=0;s<r;s++)for(let i=0;i<r;i++)n.get(s,i)&&(a.push(s),u.push(i));return[D.fromData(new Int32Array(a),[a.length],"int32"),D.fromData(new Int32Array(u),[u.length],"int32")]}function Ln(r,t="int32"){let e=r.length,n=[e,...r],o=n.reduce((i,c)=>i*c,1),a=U(t);if(!a)throw new Error(`Cannot create indices with dtype ${t}`);let u=new a(o),s=r.reduce((i,c)=>i*c,1);for(let i=0;i<e;i++){let c=i*s;for(let f=0;f<s;f++){let p=new Array(e),l=f;for(let m=e-1;m>=0;m--)p[m]=l%r[m],l=Math.floor(l/r[m]);let y=p[i];t==="int64"?u[c+f]=BigInt(y):u[c+f]=y}}return D.fromData(u,n,t)}function qn(...r){let t=r.length,e=[];for(let n=0;n<t;n++){let o=r[n],a=o.size,u=o.dtype,s=new Array(t).fill(1);s[n]=a;let i=U(u);if(!i)throw new Error(`Cannot create ix_ with dtype ${u}`);let c=new i(a);for(let f=0;f<a;f++){let p=o.iget(f);w(u),c[f]=p}e.push(D.fromData(c,s,u))}return e}function jn(r,t,e="raise"){if(r.length!==t.length)throw new Error("multi_index length must equal dims length");if(r.length===0)throw new Error("multi_index cannot be empty");let n=r[0].size,o=t.length,a=new Int32Array(n),u=new Array(o),s=1;for(let i=o-1;i>=0;i--)u[i]=s,s*=t[i];for(let i=0;i<n;i++){let c=0;for(let f=0;f<o;f++){let p=Number(r[f].iget(i)),l=t[f];if(e==="wrap")p=(p%l+l)%l;else if(e==="clip")p=Math.max(0,Math.min(p,l-1));else if(p<0||p>=l)throw new Error(`index ${p} is out of bounds for axis ${f} with size ${l}`);c+=p*u[f]}a[i]=c}return D.fromData(a,[n],"int32")}function Zn(r,t,e="C"){let n=t.length,o,a;if(typeof r=="number")o=[r],a=[];else{o=[];for(let f=0;f<r.size;f++)o.push(Number(r.iget(f)));a=Array.from(r.shape)}let u=o.length,s=t.reduce((f,p)=>f*p,1),i=new Array(n);if(e==="C"){let f=1;for(let p=n-1;p>=0;p--)i[p]=f,f*=t[p]}else{let f=1;for(let p=0;p<n;p++)i[p]=f,f*=t[p]}let c=[];for(let f=0;f<n;f++){let p=new Int32Array(u);c.push(D.fromData(p,a.length?a:[1],"int32"))}for(let f=0;f<u;f++){let p=o[f];if(p<0||p>=s)throw new Error(`index ${p} is out of bounds for array with size ${s}`);if(e==="C")for(let l=0;l<n;l++){let y=Math.floor(p/i[l]);p=p%i[l],c[l].data[f]=y%t[l]}else for(let l=n-1;l>=0;l--){let y=Math.floor(p/i[l]);p=p%i[l],c[l].data[f]=y%t[l]}}return typeof r=="number"?c.map(f=>{let p=f.iget(0);return D.fromData(new Int32Array([Number(p)]),[],"int32")}):c}var Wn=M(()=>{"use strict";Z();R();ut()});function G(r,t){if(!Kt(r)&&r!=="bool")throw new TypeError(`ufunc '${t}' not supported for the input types, and the inputs could not be safely coerced to any supported types`)}function Sr(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function Yn(r,t){return G(r.dtype,"bitwise_and"),typeof t=="number"?nu(r,t):(G(t.dtype,"bitwise_and"),Sr(r,t)?eu(r,t):P(r,t,(e,n)=>e&n,"bitwise_and"))}function eu(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;if(!w(r.dtype)||!w(t.dtype))for(let f=0;f<o;f++){let p=typeof a[f]=="bigint"?a[f]:BigInt(Math.round(Number(a[f]))),l=typeof u[f]=="bigint"?u[f]:BigInt(Math.round(Number(u[f])));i[f]=p&l}else{let f=a,p=u;for(let l=0;l<o;l++)i[l]=f[l]&p[l]}}else for(let i=0;i<o;i++)s[i]=a[i]&u[i];return n}function nu(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]&f}else for(let i=0;i<a;i++)s[i]=o[i]&t;return u}function Jn(r,t){return G(r.dtype,"bitwise_or"),typeof t=="number"?au(r,t):(G(t.dtype,"bitwise_or"),Sr(r,t)?ou(r,t):P(r,t,(e,n)=>e|n,"bitwise_or"))}function ou(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;if(!w(r.dtype)||!w(t.dtype))for(let f=0;f<o;f++){let p=typeof a[f]=="bigint"?a[f]:BigInt(Math.round(Number(a[f]))),l=typeof u[f]=="bigint"?u[f]:BigInt(Math.round(Number(u[f])));i[f]=p|l}else{let f=a,p=u;for(let l=0;l<o;l++)i[l]=f[l]|p[l]}}else for(let i=0;i<o;i++)s[i]=a[i]|u[i];return n}function au(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]|f}else for(let i=0;i<a;i++)s[i]=o[i]|t;return u}function Xn(r,t){return G(r.dtype,"bitwise_xor"),typeof t=="number"?iu(r,t):(G(t.dtype,"bitwise_xor"),Sr(r,t)?su(r,t):P(r,t,(e,n)=>e^n,"bitwise_xor"))}function su(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;if(!w(r.dtype)||!w(t.dtype))for(let f=0;f<o;f++){let p=typeof a[f]=="bigint"?a[f]:BigInt(Math.round(Number(a[f]))),l=typeof u[f]=="bigint"?u[f]:BigInt(Math.round(Number(u[f])));i[f]=p^l}else{let f=a,p=u;for(let l=0;l<o;l++)i[l]=f[l]^p[l]}}else for(let i=0;i<o;i++)s[i]=a[i]^u[i];return n}function iu(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]^f}else for(let i=0;i<a;i++)s[i]=o[i]^t;return u}function vt(r){G(r.dtype,"bitwise_not");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;if(w(t)){let s=n,i=u;for(let c=0;c<o;c++)i[c]=~s[c]}else for(let s=0;s<o;s++)u[s]=~n[s];return a}function Qn(r){return vt(r)}function Kn(r,t){if(G(r.dtype,"left_shift"),typeof t=="number")return Gn(r,t);if(G(t.dtype,"left_shift"),t.size===1||t.ndim===1&&t.shape[0]===1){let e=w(t.dtype)?Number(t.data[0]):t.data[0];return Gn(r,e)}return Sr(r,t)?uu(r,t):P(r,t,(e,n)=>e<<n,"left_shift")}function uu(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;for(let c=0;c<o;c++){let f=typeof a[c]=="bigint"?a[c]:BigInt(Math.round(Number(a[c]))),p=typeof u[c]=="bigint"?u[c]:BigInt(Math.round(Number(u[c])));i[c]=f<<p}}else for(let i=0;i<o;i++)s[i]=a[i]<<u[i];return n}function Gn(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]<<f}else for(let i=0;i<a;i++)s[i]=o[i]<<t;return u}function ro(r,t){if(G(r.dtype,"right_shift"),typeof t=="number")return Hn(r,t);if(G(t.dtype,"right_shift"),t.size===1||t.ndim===1&&t.shape[0]===1){let e=w(t.dtype)?Number(t.data[0]):t.data[0];return Hn(r,e)}return Sr(r,t)?cu(r,t):P(r,t,(e,n)=>e>>n,"right_shift")}function cu(r,t){let e=v(r.dtype,t.dtype),n=D.zeros(Array.from(r.shape),e),o=r.size,a=r.data,u=t.data,s=n.data;if(w(e)){let i=s;for(let c=0;c<o;c++){let f=typeof a[c]=="bigint"?a[c]:BigInt(Math.round(Number(a[c]))),p=typeof u[c]=="bigint"?u[c]:BigInt(Math.round(Number(u[c])));i[c]=f>>p}}else for(let i=0;i<o;i++)s[i]=a[i]>>u[i];return n}function Hn(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,u=D.zeros(n,e),s=u.data;if(w(e)){let i=o,c=s,f=BigInt(Math.round(t));for(let p=0;p<a;p++)c[p]=i[p]>>f}else for(let i=0;i<a;i++)s[i]=o[i]>>t;return u}function to(r,t=-1,e="big"){let n=Array.from(r.shape),o=n.length;if(t<0&&(t=o+t),t<0||t>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let a=n[t],u=Math.ceil(a/8),s=[...n];s[t]=u;let i=D.zeros(s,"uint8"),c=i.data;if(o===1){for(let g=0;g<u;g++){let h=0;for(let A=0;A<8;A++){let b=g*8+A;if(b<a){let S=Number(r.data[b])!==0?1:0;e==="big"?h|=S<<7-A:h|=S<<A}}c[g]=h}return i}let f=n.slice(0,t),p=n.slice(t+1),l=f.reduce((g,h)=>g*h,1),y=p.reduce((g,h)=>g*h,1),m=Lr(n),d=Lr(s);for(let g=0;g<l;g++)for(let h=0;h<y;h++)for(let A=0;A<u;A++){let b=0;for(let I=0;I<8;I++){let z=A*8+I;if(z<a){let B=0,E=g;for(let F=0;F<t;F++){let X=F<t-1?f.slice(F+1).reduce((rt,tt)=>rt*tt,1):1,er=Math.floor(E/X);E%=X,B+=er*m[F]}B+=z*m[t];let T=h;for(let F=t+1;F<o;F++){let X=F<o-1?p.slice(F-t).reduce((rt,tt)=>rt*tt,1):1,er=Math.floor(T/X);T%=X,B+=er*m[F]}let k=Number(r.data[B])!==0?1:0;e==="big"?b|=k<<7-I:b|=k<<I}}let S=0,N=g;for(let I=0;I<t;I++){let z=I<t-1?f.slice(I+1).reduce((E,T)=>E*T,1):1,B=Math.floor(N/z);N%=z,S+=B*d[I]}S+=A*d[t];let x=h;for(let I=t+1;I<o;I++){let z=I<o-1?p.slice(I-t).reduce((E,T)=>E*T,1):1,B=Math.floor(x/z);x%=z,S+=B*d[I]}c[S]=b}return i}function eo(r,t=-1,e=-1,n="big"){if(r.dtype!=="uint8")throw new TypeError("Expected an input array of unsigned byte data type");let o=Array.from(r.shape),a=o.length;if(t<0&&(t=a+t),t<0||t>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let u=o[t],s=u*8;e>=0&&(s=e);let i=[...o];i[t]=s;let c=D.zeros(i,"uint8"),f=c.data;if(a===1){for(let h=0;h<u;h++){let A=Number(r.data[h]);for(let b=0;b<8;b++){let S=h*8+b;if(S>=s)break;n==="big"?f[S]=A>>7-b&1:f[S]=A>>b&1}}return c}let p=o.slice(0,t),l=o.slice(t+1),y=p.reduce((h,A)=>h*A,1),m=l.reduce((h,A)=>h*A,1),d=Lr(o),g=Lr(i);for(let h=0;h<y;h++)for(let A=0;A<m;A++)for(let b=0;b<u;b++){let S=0,N=h;for(let z=0;z<t;z++){let B=z<t-1?p.slice(z+1).reduce((T,k)=>T*k,1):1,E=Math.floor(N/B);N%=B,S+=E*d[z]}S+=b*d[t];let x=A;for(let z=t+1;z<a;z++){let B=z<a-1?l.slice(z-t).reduce((T,k)=>T*k,1):1,E=Math.floor(x/B);x%=B,S+=E*d[z]}let I=Number(r.data[S]);for(let z=0;z<8;z++){let B=b*8+z;if(B>=s)break;let E=0;N=h;for(let T=0;T<t;T++){let k=T<t-1?p.slice(T+1).reduce((X,er)=>X*er,1):1,F=Math.floor(N/k);N%=k,E+=F*g[T]}E+=B*g[t],x=A;for(let T=t+1;T<a;T++){let k=T<a-1?l.slice(T-t).reduce((X,er)=>X*er,1):1,F=Math.floor(x/k);x%=k,E+=F*g[T]}n==="big"?f[E]=I>>7-z&1:f[E]=I>>z&1}}return c}function Lr(r){let t=r.length,e=new Array(t),n=1;for(let o=t-1;o>=0;o--)e[o]=n,n*=r[o];return e}var no=M(()=>{"use strict";Z();R();nr()});function Y(r,t=C){let e=D.zeros(r,t);return new _(e)}function Mt(r,t=C){let e=D.ones(r,t);return new _(e)}function lu(r){let t=[],e=r;for(;Array.isArray(e);)t.push(e.length),e=e[0];return t}function oo(r){return typeof r=="bigint"?!0:Array.isArray(r)?r.some(t=>oo(t)):!1}function pu(r){let t=[];function e(n){Array.isArray(n)?n.forEach(o=>e(o)):t.push(n)}return e(r),t}function q(r,t){if(r instanceof _)return!t||r.dtype===t?r.copy():r.astype(t);let e=oo(r),n=lu(r),o=n.reduce((f,p)=>f*p,1),a=t;a||(e?a="int64":a=C);let u=U(a);if(!u)throw new Error(`Cannot create array with dtype ${a}`);let s=new u(o),i=pu(r);if(w(a)){let f=s;for(let p=0;p<o;p++){let l=i[p];f[p]=typeof l=="bigint"?l:BigInt(Math.round(Number(l)))}}else if(a==="bool"){let f=s;for(let p=0;p<o;p++)f[p]=i[p]?1:0}else{let f=s;for(let p=0;p<o;p++){let l=i[p];f[p]=Number(l)}}let c=D.fromData(s,n,a);return new _(c)}function ao(r,t,e=1,n=C){let o=r,a=t;if(t===void 0&&(o=0,a=r),a===void 0)throw new Error("stop is required");let u=Math.max(0,Math.ceil((a-o)/e)),s=U(n);if(!s)throw new Error(`Cannot create arange array with dtype ${n}`);let i=new s(u);if(w(n))for(let f=0;f<u;f++)i[f]=BigInt(Math.round(o+f*e));else if(n==="bool")for(let f=0;f<u;f++)i[f]=o+f*e!==0?1:0;else for(let f=0;f<u;f++)i[f]=o+f*e;let c=D.fromData(i,[u],n);return new _(c)}function so(r,t,e=50,n=C){if(e<0)throw new Error("num must be non-negative");if(e===0)return q([],n);if(e===1)return q([r],n);let o=U(n);if(!o)throw new Error(`Cannot create linspace array with dtype ${n}`);let a=new o(e),u=(t-r)/(e-1);if(w(n))for(let i=0;i<e;i++)a[i]=BigInt(Math.round(r+i*u));else if(n==="bool")for(let i=0;i<e;i++)a[i]=r+i*u!==0?1:0;else for(let i=0;i<e;i++)a[i]=r+i*u;let s=D.fromData(a,[e],n);return new _(s)}function io(r,t,e=50,n=10,o=C){if(e<0)throw new Error("num must be non-negative");if(e===0)return q([],o);if(e===1)return q([Math.pow(n,r)],o);let a=U(o);if(!a)throw new Error(`Cannot create logspace array with dtype ${o}`);let u=new a(e),s=(t-r)/(e-1);if(w(o))for(let c=0;c<e;c++){let f=r+c*s;u[c]=BigInt(Math.round(Math.pow(n,f)))}else if(o==="bool")for(let c=0;c<e;c++){let f=r+c*s;u[c]=Math.pow(n,f)!==0?1:0}else for(let c=0;c<e;c++){let f=r+c*s;u[c]=Math.pow(n,f)}let i=D.fromData(u,[e],o);return new _(i)}function uo(r,t,e=50,n=C){if(e<0)throw new Error("num must be non-negative");if(r===0||t===0)throw new Error("Geometric sequence cannot include zero");if(e===0)return q([],n);if(e===1)return q([r],n);let o=Math.sign(r),a=Math.sign(t);if(o!==a)throw new Error("Geometric sequence cannot contain both positive and negative values");let u=U(n);if(!u)throw new Error(`Cannot create geomspace array with dtype ${n}`);let s=new u(e),i=Math.log(Math.abs(r)),f=(Math.log(Math.abs(t))-i)/(e-1);if(w(n))for(let l=0;l<e;l++){let y=o*Math.exp(i+l*f);s[l]=BigInt(Math.round(y))}else if(n==="bool")for(let l=0;l<e;l++){let y=o*Math.exp(i+l*f);s[l]=y!==0?1:0}else for(let l=0;l<e;l++){let y=o*Math.exp(i+l*f);s[l]=y}let p=D.fromData(s,[e],n);return new _(p)}function Ct(r,t,e=0,n=C){let o=t??r,a=Y([r,o],n),u=a.data;if(w(n)){let s=u;for(let i=0;i<r;i++){let c=i+e;c>=0&&c<o&&(s[i*o+c]=BigInt(1))}}else{let s=u;for(let i=0;i<r;i++){let c=i+e;c>=0&&c<o&&(s[i*o+c]=1)}}return a}function kt(r,t=C){return Y(r,t)}function Vt(r,t,e){let n=e;n||(typeof t=="bigint"?n="int64":typeof t=="boolean"?n="bool":Number.isInteger(t)?n="int32":n=C);let o=U(n);if(!o)throw new Error(`Cannot create full array with dtype ${n}`);let a=r.reduce((i,c)=>i*c,1),u=new o(a);if(w(n)){let i=typeof t=="bigint"?t:BigInt(Math.round(Number(t)));u.fill(i)}else n==="bool"?u.fill(t?1:0):u.fill(Number(t));let s=D.fromData(u,r,n);return new _(s)}function co(r,t=C){return Ct(r,r,0,t)}function Dr(r,t){return r instanceof _?!t||r.dtype===t?r:r.astype(t):q(r,t)}function fo(r){return r.copy()}function lo(r,t){return Y(Array.from(r.shape),t??r.dtype)}function po(r,t){return Mt(Array.from(r.shape),t??r.dtype)}function yo(r,t){return kt(Array.from(r.shape),t??r.dtype)}function mo(r,t,e){return Vt(Array.from(r.shape),t,e??r.dtype)}function go(r,t){return Dr(r,t)}function Ao(r,t){let e=Dr(r,t);return e.flags.C_CONTIGUOUS?e:e.copy()}function ho(r,t){return Dr(r,t).copy()}function Pt(r,t=0){if(r.ndim===1){let e=r.size,n=e+Math.abs(t),o=Y([n,n],r.dtype);for(let a=0;a<e;a++){let u=t>=0?a:a-t,s=t>=0?a+t:a;o.set([u,s],r.get([a]))}return o}else if(r.ndim===2){let[e,n]=r.shape,o,a,u;if(t>=0?(o=0,a=t,u=Math.min(e,n-t)):(o=-t,a=0,u=Math.min(e+t,n)),u<=0)return Y([0],r.dtype);let s=U(r.dtype),i=new s(u);for(let f=0;f<u;f++){let p=r.get([o+f,a+f]);w(r.dtype)?i[f]=typeof p=="bigint"?p:BigInt(p):i[f]=p}let c=D.fromData(i,[u],r.dtype);return new _(c)}else throw new Error("Input must be 1-D or 2-D")}function bo(r,t=0){let e=r.flatten();return Pt(e,t)}function So(r,t,e=C){let n=t.reduce((c,f)=>c*f,1),o=U(e);if(!o)throw new Error(`Cannot create array with dtype ${e}`);let a=new o(n),u=t.length,s=new Array(u).fill(0);for(let c=0;c<n;c++){let f=r(...s);w(e)?a[c]=typeof f=="bigint"?f:BigInt(Number(f)):e==="bool"?a[c]=f?1:0:a[c]=Number(f);for(let p=u-1;p>=0&&(s[p]++,!(s[p]<t[p]));p--)s[p]=0}let i=D.fromData(a,t,e);return new _(i)}function Do(...r){let t=[],e="xy";for(let s of r)s instanceof _?t.push(s):typeof s=="object"&&"indexing"in s&&(e=s.indexing||"xy");if(t.length===0)return[];if(t.length===1)return[t[0].copy()];let n=t.map(s=>s.size);e==="xy"&&t.length>=2&&(t=[t[1],t[0],...t.slice(2)],[n[0],n[1]]=[n[1],n[0]]);let o=n,a=o.length,u=[];for(let s=0;s<t.length;s++){let i=t[s],c=i.size,f=new Array(a).fill(1);f[s]=c;let p=i.reshape(...f),l=Ut(p.storage,o),y=_._fromStorage(l.copy());u.push(y)}return e==="xy"&&u.length>=2&&([u[0],u[1]]=[u[1],u[0]]),u}function No(r,t,e=0,n=C){let o=t??r,a=Y([r,o],n);for(let u=0;u<r;u++)for(let s=0;s<=u+e&&s<o;s++)s>=0&&a.set([u,s],1);return a}function wo(r,t=0){if(r.ndim<2)throw new Error("Input must have at least 2 dimensions");let e=r.copy(),n=e.shape,o=n[n.length-2],a=n[n.length-1],u=n.slice(0,-2).reduce((s,i)=>s*i,1);for(let s=0;s<u;s++)for(let i=0;i<o;i++)for(let c=0;c<a;c++)if(c>i+t){let f=[],p=s;for(let l=n.length-3;l>=0;l--)f.unshift(p%n[l]),p=Math.floor(p/n[l]);f.push(i,c),e.set(f,0)}return e}function xo(r,t=0){if(r.ndim<2)throw new Error("Input must have at least 2 dimensions");let e=r.copy(),n=e.shape,o=n[n.length-2],a=n[n.length-1],u=n.slice(0,-2).reduce((s,i)=>s*i,1);for(let s=0;s<u;s++)for(let i=0;i<o;i++)for(let c=0;c<a;c++)if(c<i+t){let f=[],p=s;for(let l=n.length-3;l>=0;l--)f.unshift(p%n[l]),p=Math.floor(p/n[l]);f.push(i,c),e.set(f,0)}return e}function Io(r,t,e=!1){if(r.ndim!==1)throw new Error("Input must be 1-D");let n=r.size,o=t??n;if(o<0)throw new Error("N must be non-negative");let a=Y([n,o],r.dtype);for(let u=0;u<n;u++){let s=r.get([u]);for(let i=0;i<o;i++){let c=e?i:o-1-i;a.set([u,i],Math.pow(s,c))}}return a}function zo(r,t=C,e=-1,n=0){let o,a=n;r instanceof ArrayBuffer?o=r:(o=r.buffer,a+=r.byteOffset);let u=yu(t),s=o.byteLength-a,i=Math.floor(s/u),c=e<0?i:Math.min(e,i);if(c<=0)return q([],t);let f=U(t);if(!f)throw new Error(`Unsupported dtype: ${t}`);let p=new f(o,a,c),l=D.fromData(p,[c],t);return new _(l)}function _o(r,t=C,e=-1){let n=[],o=0;for(let a of r){if(e>=0&&o>=e)break;n.push(a),o++}return q(n,t)}function Bo(r,t=C,e=-1){let n=[],o=0;for(let a of r){if(e>=0&&o>=e)break;n.push(a),o++}return q(n,t)}function Eo(r,t=C,e=-1,n=""){let o;n===""?o=r.trim().split(/\s+/):o=r.split(n);let a=[],u=0;for(let s of o){if(e>=0&&u>=e)break;let i=s.trim();i!==""&&(w(t)?a.push(BigInt(i)):a.push(parseFloat(i)),u++)}return q(a,t)}function yu(r){switch(r){case"int8":case"uint8":case"bool":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"int64":case"uint64":case"float64":return 8;default:return 8}}function Uo(r){return r.sqrt()}function To(r,t){return r.power(t)}function Oo(r){return r.absolute()}function $o(r){return r.negative()}function vo(r){return r.sign()}function Mo(r,t){return r.mod(t)}function Co(r,t){return r.floor_divide(t)}function ko(r){return r.positive()}function Vo(r){return r.reciprocal()}function Po(r,t){return r.dot(t)}function Fo(r){return r.trace()}function Ro(r,t=0,e=0,n=1){let o=tn(r.storage,t,e,n);return _._fromStorage(o)}function Lo(r,t){let e=nn(r.storage,t.storage);return _._fromStorage(e)}function qo(r,t){return r.transpose(t)}function jo(r,t){return r.inner(t)}function Zo(r,t){return r.outer(t)}function Wo(r,t,e=2){return r.tensordot(t,e)}function Go(r){return r.sin()}function Ho(r){return r.cos()}function Yo(r){return r.tan()}function Jo(r){return r.arcsin()}function Xo(r){return r.arccos()}function Qo(r){return r.arctan()}function Ko(r,t){return r.arctan2(t)}function ra(r,t){return r.hypot(t)}function ta(r){return r.degrees()}function ea(r){return r.radians()}function na(r){return r.radians()}function oa(r){return r.degrees()}function aa(r){return r.sinh()}function sa(r){return r.cosh()}function ia(r){return r.tanh()}function ua(r){return r.arcsinh()}function ca(r){return r.arccosh()}function fa(r){return r.arctanh()}function la(r,t,e){return r.swapaxes(t,e)}function pa(r,t,e){return r.moveaxis(t,e)}function sr(r,t=0){if(r.length===0)throw new Error("need at least one array to concatenate");let e=r.map(o=>o.storage),n=or(e,t);return _._fromStorage(n)}function ya(r,t=0){if(r.length===0)throw new Error("need at least one array to stack");let e=r.map(o=>o.storage),n=Te(e,t);return _._fromStorage(n)}function Ft(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Oe(t);return _._fromStorage(e)}function ma(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=It(t);return _._fromStorage(e)}function da(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=$e(t);return _._fromStorage(e)}function ga(r,t,e=0){return ve(r.storage,t,e).map(o=>_._fromStorage(o,r.base??r))}function Aa(r,t,e=0){return br(r.storage,t,e).map(o=>_._fromStorage(o,r.base??r))}function ha(r,t){return Ce(r.storage,t).map(n=>_._fromStorage(n,r.base??r))}function ba(r,t){return ke(r.storage,t).map(n=>_._fromStorage(n,r.base??r))}function Sa(r,t){let e=Ve(r.storage,t);return _._fromStorage(e)}function Da(r,t,e){return r.repeat(t,e)}function Na(r){return r.ravel()}function wa(r,t){return r.reshape(...t)}function xa(r,t){return r.squeeze(t)}function Ia(r,t){return r.expand_dims(t)}function qr(r,t){let e=Fe(r.storage,t);return _._fromStorage(e)}function za(r){if(r.ndim<2)throw new Error("Input must be at least 2-D");return qr(r,1)}function _a(r){if(r.ndim<2)throw new Error("Input must be at least 2-D");return qr(r,0)}function Ba(r,t=1,e=[0,1]){let n=Re(r.storage,t,e);return _._fromStorage(n)}function Ea(r,t,e){let n=Le(r.storage,t,e);return _._fromStorage(n)}function Ua(r,t,e=0){let n=qe(r.storage,t,e);return _._fromStorage(n,r.base??r)}function Ta(...r){let t=r.map(o=>o.storage),n=Ge(t).map((o,a)=>o===t[a]?r[a]:_._fromStorage(o));return n.length===1?n[0]:n}function Oa(...r){let t=r.map(o=>o.storage),n=He(t).map((o,a)=>o===t[a]?r[a]:_._fromStorage(o));return n.length===1?n[0]:n}function $a(...r){let t=r.map(o=>o.storage),n=Ye(t).map((o,a)=>o===t[a]?r[a]:_._fromStorage(o));return n.length===1?n[0]:n}function va(r,t){return je(r.storage,t).map(n=>_._fromStorage(n,r.base??r))}function Ma(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Ze(t);return _._fromStorage(e)}function Ca(r){return Ft(r)}function ka(r,t){let e=We(r.storage,t);return _._fromStorage(e)}function Va(r,t,e){let n=t instanceof _?t:q(t,r.dtype);if(e===void 0){let o=r.flatten(),a=n.flatten();return sr([o,a])}return sr([r,n],e)}function Pa(r,t,e){let n=r.dtype;if(e===void 0){let y=r.flatten(),d=(Array.isArray(t)?t:[t]).map(S=>S<0?y.size+S:S),g=[];for(let S=0;S<y.size;S++)d.includes(S)||g.push(S);let h=U(n),A=new h(g.length);for(let S=0;S<g.length;S++){let N=y.get([g[S]]);w(n)?A[S]=typeof N=="bigint"?N:BigInt(N):A[S]=N}let b=D.fromData(A,[g.length],n);return new _(b)}let o=r.shape,a=o.length,u=e<0?a+e:e;if(u<0||u>=a)throw new Error(`axis ${e} is out of bounds for array of dimension ${a}`);let s=o[u],i=Array.isArray(t)?t:[t],c=new Set(i.map(y=>y<0?s+y:y)),f=[],p=0;for(let y=0;y<=s;y++)(c.has(y)||y===s)&&(y>p&&f.push([p,y]),p=y+1);if(f.length===0){let y=[...o];return y[u]=0,Y(y,n)}let l=[];for(let[y,m]of f){let d=o.map(()=>":");d[u]=`${y}:${m}`,l.push(r.slice(...d))}return sr(l,u)}function Fa(r,t,e,n){let o=e instanceof _?e:q(e,r.dtype);if(n===void 0){let p=r.flatten(),l=o.flatten(),y=t<0?p.size+t:t;if(y<0||y>p.size)throw new Error(`index ${t} is out of bounds for array of size ${p.size}`);let m=y>0?p.slice(`0:${y}`):null,d=y<p.size?p.slice(`${y}:`):null,g=[];return m&&g.push(m),g.push(l),d&&g.push(d),sr(g)}let a=r.shape,u=a.length,s=n<0?u+n:n;if(s<0||s>=u)throw new Error(`axis ${n} is out of bounds for array of dimension ${u}`);let i=a[s],c=t<0?i+t:t;if(c<0||c>i)throw new Error(`index ${t} is out of bounds for axis ${n} with size ${i}`);let f=[];if(c>0){let p=a.map(()=>":");p[s]=`0:${c}`,f.push(r.slice(...p))}if(f.push(o),c<i){let p=a.map(()=>":");p[s]=`${c}:`,f.push(r.slice(...p))}return sr(f,s)}function Ra(r,t,e="constant",n=0){let o=r.shape,a=o.length,u=r.dtype,s;if(typeof t=="number"?s=o.map(()=>[t,t]):Array.isArray(t)&&typeof t[0]=="number"?s=o.map(()=>t):s=t,s.length!==a)throw new Error(`pad_width must have ${a} elements`);let i=o.map((d,g)=>d+s[g][0]+s[g][1]),c=i.reduce((d,g)=>d*g,1),f=U(u),p=new f(c),l=w(u);e==="constant"&&(l?p.fill(BigInt(n)):p.fill(n));let y=new Array(a).fill(0);for(let d=0;d<c;d++){let g=!0,h=[];for(let b=0;b<a;b++){let[S]=s[b],N=y[b]-S;if(N<0||N>=o[b]){g=!1;break}h.push(N)}let A;if(g)A=r.get(h);else if(e==="constant"){for(let b=a-1;b>=0&&(y[b]++,!(y[b]<i[b]));b--)y[b]=0;continue}else{let b=[];for(let S=0;S<a;S++){let[N]=s[S],x=y[S]-N,I=o[S];x<0?e==="edge"?x=0:e==="reflect"?(x=-x,x>=I&&(x=I-1)):e==="symmetric"?(x=-x-1,x>=I&&(x=I-1),x<0&&(x=0)):e==="wrap"&&(x=(x%I+I)%I):x>=I&&(e==="edge"?x=I-1:e==="reflect"?(x=2*I-x-2,x<0&&(x=0)):e==="symmetric"?(x=2*I-x-1,x<0&&(x=0)):e==="wrap"&&(x=x%I)),b.push(Math.max(0,Math.min(I-1,x)))}A=r.get(b)}l?p[d]=typeof A=="bigint"?A:BigInt(Number(A)):p[d]=Number(A);for(let b=a-1;b>=0&&(y[b]++,!(y[b]<i[b]));b--)y[b]=0}let m=D.fromData(p,i,u);return new _(m)}function La(r,t){let e=Ut(r.storage,t);return _._fromStorage(e,r.base??r)}function qa(...r){let t=r.map(n=>n.storage);return _n(t).map((n,o)=>_._fromStorage(n,r[o].base??r[o]))}function ja(...r){return it(...r)}function Za(r,t,e){return r.take(t,e)}function Wa(r,t,e){r.put(t,e)}function Ga(r,t){let e=t.map(o=>o.storage),n=Un(r.storage,e);return _._fromStorage(n)}function Ha(r,t,e=!1){return Tn(r.storage,t.storage,e)}function Ya(r,t){return xe(r.storage,t.storage)}function Ja(r,t){return _._fromStorage(gt(r.storage,t))}function Xa(r,t){return _._fromStorage(At(r.storage,t))}function Qa(r,t,e=!1){let n=ht(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function Ka(r,t,e=!1){let n=bt(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function rs(r,t,e,n=!1){let o=St(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function ts(r,t,e,n=!1){let o=cr(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function es(r,t,e,n=!1){let o=e?e.storage:void 0,a=Or(r.storage,t,o,n);return typeof a=="number"?a:_._fromStorage(a)}function ns(r,t,e=!1){let n=$r(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function os(r,t,e=!1){let n=vr(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function as(r,t,e=!1){let n=Mr(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function ss(r,t,e=0,n=!1){let o=dr(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function is(r,t,e=0,n=!1){let o=Dt(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function us(r,t,e=!1){let n=Cr(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function cs(r,t,e=!1){let n=kr(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function fs(r,t){let e=Vr(r.storage,t);return typeof e=="number"?e:_._fromStorage(e)}function ls(r,t){let e=Pr(r.storage,t);return typeof e=="number"?e:_._fromStorage(e)}function ps(r,t){return _._fromStorage(Nt(r.storage,t))}function ys(r,t){return _._fromStorage(wt(r.storage,t))}function ms(r,t,e=!1){let n=Fr(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function ds(r){return r.cbrt()}function gs(r){return r.fabs()}function As(r,t){return r.divmod(t)}function hs(r){return r.square()}function bs(r,t){return r.remainder(t)}function Ss(r,t){return r.heaviside(t)}function Ds(r,t){return r.bitwise_and(t)}function Ns(r,t){return r.bitwise_or(t)}function ws(r,t){return r.bitwise_xor(t)}function xs(r){return r.bitwise_not()}function Is(r){return r.invert()}function zs(r,t){return r.left_shift(t)}function _s(r,t){return r.right_shift(t)}function Bs(r,t=-1,e="big"){let n=to(r.storage,t,e);return _._fromStorage(n)}function Es(r,t=-1,e=-1,n="big"){let o=eo(r.storage,t,e,n);return _._fromStorage(o)}function Us(r,...t){let e=t.map(o=>o.storage),n=en(r,...e);return typeof n=="number"||typeof n=="bigint"?n:_._fromStorage(n)}function Ts(r,t,e){return _._fromStorage(On(r.storage,t.storage,e))}function Os(r,t,e,n){$n(r.storage,t.storage,e.storage,n)}function $s(r,t,e){let n=e instanceof _?e.storage:e;vn(r.storage,t.storage,n)}function vs(r,t,e){return _._fromStorage(Mn(r.storage,t.storage,e))}function Ms(r,t,e=0){let n=r.map(a=>a.storage),o=t.map(a=>a.storage);return _._fromStorage(Cn(n,o,e))}function Cs(r,t,e){kn(r.storage,t.storage,e.storage)}function ks(r,t=2){return Tt(r,t).map(n=>_._fromStorage(n))}function Vs(r){return Vn(r.storage).map(e=>_._fromStorage(e))}function Ps(r,t=0,e){return Ot(r,t,e).map(o=>_._fromStorage(o))}function Fs(r,t=0){return Pn(r.storage,t).map(n=>_._fromStorage(n))}function Rs(r,t=0,e){return $t(r,t,e).map(o=>_._fromStorage(o))}function Ls(r,t=0){return Fn(r.storage,t).map(n=>_._fromStorage(n))}function qs(r,t,e=0){return Rn(r,(a,u)=>t(a,u).storage,e).map(a=>_._fromStorage(a))}function js(r,t="int32"){return _._fromStorage(Ln(r,t))}function Zs(...r){return qn(...r.map(e=>e.storage)).map(e=>_._fromStorage(e))}function Ws(r,t,e="raise"){let n=r.map(o=>o.storage);return _._fromStorage(jn(n,t,e))}function Gs(r,t,e="C"){let n=r instanceof _?r.storage:r;return Zn(n,t,e).map(a=>_._fromStorage(a))}var _,Rt=M(()=>{"use strict";Jt();R();Z();ge();Ie();Be();zt();on();un();bn();zn();Wn();no();_=class r{constructor(t,e){this._storage=t,this._base=e}get storage(){return this._storage}static _fromStorage(t,e){return new r(t,e)}get shape(){return this._storage.shape}get ndim(){return this._storage.ndim}get size(){return this._storage.size}get dtype(){return this._storage.dtype}get data(){return this._storage.data}get strides(){return this._storage.strides}get flags(){return{C_CONTIGUOUS:this._storage.isCContiguous,F_CONTIGUOUS:this._storage.isFContiguous,OWNDATA:this._base===void 0}}get base(){return this._base??null}get(t){if(t.length!==this.ndim)throw new Error(`Index has ${t.length} dimensions, but array has ${this.ndim} dimensions`);let e=t.map((n,o)=>{let a=n;if(a<0&&(a=this.shape[o]+a),a<0||a>=this.shape[o])throw new Error(`Index ${n} is out of bounds for axis ${o} with size ${this.shape[o]}`);return a});return this._storage.get(...e)}set(t,e){if(t.length!==this.ndim)throw new Error(`Index has ${t.length} dimensions, but array has ${this.ndim} dimensions`);let n=t.map((u,s)=>{let i=u;if(i<0&&(i=this.shape[s]+i),i<0||i>=this.shape[s])throw new Error(`Index ${u} is out of bounds for axis ${s} with size ${this.shape[s]}`);return i}),o=this.dtype,a;w(o)?a=typeof e=="bigint"?e:BigInt(Math.round(e)):o==="bool"?a=e?1:0:a=Number(e),this._storage.set(n,a)}copy(){return new r(this._storage.copy())}astype(t,e=!0){let n=this.dtype;if(n===t&&!e)return this;if(n===t&&e)return this.copy();let o=Array.from(this.shape),a=this.size,u=U(t);if(!u)throw new Error(`Cannot convert to dtype ${t}`);let s=new u(a),i=this.data;if(w(n)&&!w(t)){let f=i;if(t==="bool")for(let p=0;p<a;p++)s[p]=f[p]!==BigInt(0)?1:0;else for(let p=0;p<a;p++)s[p]=Number(f[p])}else if(!w(n)&&w(t)){let f=i;for(let p=0;p<a;p++)s[p]=BigInt(Math.round(Number(f[p])))}else if(t==="bool"){let f=i;for(let p=0;p<a;p++)s[p]=f[p]!==0?1:0}else if(n==="bool"&&!w(t)){let f=i;for(let p=0;p<a;p++)s[p]=f[p]}else if(!w(n)&&!w(t)){let f=i;for(let p=0;p<a;p++)s[p]=f[p]}else{let f=i;for(let p=0;p<a;p++)s[p]=f[p]}let c=D.fromData(s,o,t);return new r(c)}add(t){let e=typeof t=="number"?t:t._storage,n=te(this._storage,e);return r._fromStorage(n)}subtract(t){let e=typeof t=="number"?t:t._storage,n=ee(this._storage,e);return r._fromStorage(n)}multiply(t){let e=typeof t=="number"?t:t._storage,n=ne(this._storage,e);return r._fromStorage(n)}divide(t){let e=typeof t=="number"?t:t._storage,n=oe(this._storage,e);return r._fromStorage(n)}mod(t){let e=typeof t=="number"?t:t._storage,n=Br(this._storage,e);return r._fromStorage(n)}floor_divide(t){let e=typeof t=="number"?t:t._storage,n=st(this._storage,e);return r._fromStorage(n)}positive(){let t=ue(this._storage);return r._fromStorage(t)}reciprocal(){let t=ce(this._storage);return r._fromStorage(t)}sqrt(){let t=an(this._storage);return r._fromStorage(t)}power(t){let e=typeof t=="number"?t:t._storage,n=sn(this._storage,e);return r._fromStorage(n)}absolute(){let t=ae(this._storage);return r._fromStorage(t)}negative(){let t=se(this._storage);return r._fromStorage(t)}sign(){let t=ie(this._storage);return r._fromStorage(t)}sin(){let t=cn(this._storage);return r._fromStorage(t)}cos(){let t=fn(this._storage);return r._fromStorage(t)}tan(){let t=ln(this._storage);return r._fromStorage(t)}arcsin(){let t=pn(this._storage);return r._fromStorage(t)}arccos(){let t=yn(this._storage);return r._fromStorage(t)}arctan(){let t=mn(this._storage);return r._fromStorage(t)}arctan2(t){let e=typeof t=="number"?t:t._storage,n=dn(this._storage,e);return r._fromStorage(n)}hypot(t){let e=typeof t=="number"?t:t._storage,n=gn(this._storage,e);return r._fromStorage(n)}degrees(){let t=An(this._storage);return r._fromStorage(t)}radians(){let t=hn(this._storage);return r._fromStorage(t)}sinh(){let t=Sn(this._storage);return r._fromStorage(t)}cosh(){let t=Dn(this._storage);return r._fromStorage(t)}tanh(){let t=Nn(this._storage);return r._fromStorage(t)}arcsinh(){let t=wn(this._storage);return r._fromStorage(t)}arccosh(){let t=xn(this._storage);return r._fromStorage(t)}arctanh(){let t=In(this._storage);return r._fromStorage(t)}greater(t){let e=typeof t=="number"?t:t._storage,n=Ae(this._storage,e);return r._fromStorage(n)}greater_equal(t){let e=typeof t=="number"?t:t._storage,n=he(this._storage,e);return r._fromStorage(n)}less(t){let e=typeof t=="number"?t:t._storage,n=be(this._storage,e);return r._fromStorage(n)}less_equal(t){let e=typeof t=="number"?t:t._storage,n=Se(this._storage,e);return r._fromStorage(n)}equal(t){let e=typeof t=="number"?t:t._storage,n=De(this._storage,e);return r._fromStorage(n)}not_equal(t){let e=typeof t=="number"?t:t._storage,n=Ne(this._storage,e);return r._fromStorage(n)}isclose(t,e=1e-5,n=1e-8){let o=typeof t=="number"?t:t._storage,a=ct(this._storage,o,e,n);return r._fromStorage(a)}allclose(t,e=1e-5,n=1e-8){let o=typeof t=="number"?t:t._storage;return we(this._storage,o,e,n)}bitwise_and(t){let e=typeof t=="number"?t:t._storage,n=Yn(this._storage,e);return r._fromStorage(n)}bitwise_or(t){let e=typeof t=="number"?t:t._storage,n=Jn(this._storage,e);return r._fromStorage(n)}bitwise_xor(t){let e=typeof t=="number"?t:t._storage,n=Xn(this._storage,e);return r._fromStorage(n)}bitwise_not(){let t=vt(this._storage);return r._fromStorage(t)}invert(){let t=Qn(this._storage);return r._fromStorage(t)}left_shift(t){let e=typeof t=="number"?t:t._storage,n=Kn(this._storage,e);return r._fromStorage(n)}right_shift(t){let e=typeof t=="number"?t:t._storage,n=ro(this._storage,e);return r._fromStorage(n)}sum(t,e=!1){let n=mr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}mean(t,e=!1){let n=Er(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}max(t,e=!1){let n=Ur(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}min(t,e=!1){let n=Tr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}prod(t,e=!1){let n=ft(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}argmin(t){let e=lt(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}argmax(t){let e=pt(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}var(t,e=0,n=!1){let o=yt(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}std(t,e=0,n=!1){let o=_e(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}all(t,e=!1){let n=mt(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}any(t,e=!1){let n=dt(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}cumsum(t){return r._fromStorage(gt(this._storage,t))}cumprod(t){return r._fromStorage(At(this._storage,t))}ptp(t,e=!1){let n=ht(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}median(t,e=!1){let n=bt(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}percentile(t,e,n=!1){let o=St(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}quantile(t,e,n=!1){let o=cr(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}average(t,e){let n=Or(this._storage,e,t?.storage);return typeof n=="number"?n:r._fromStorage(n)}nansum(t,e=!1){let n=$r(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}nanprod(t,e=!1){let n=vr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}nanmean(t,e=!1){let n=Mr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}nanvar(t,e=0,n=!1){let o=dr(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanstd(t,e=0,n=!1){let o=Dt(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanmin(t,e=!1){let n=Cr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}nanmax(t,e=!1){let n=kr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}nanargmin(t){let e=Vr(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}nanargmax(t){let e=Pr(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}nancumsum(t){return r._fromStorage(Nt(this._storage,t))}nancumprod(t){return r._fromStorage(wt(this._storage,t))}nanmedian(t,e=!1){let n=Fr(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}reshape(...t){let e=t.length===1&&Array.isArray(t[0])?t[0]:t,n=W(this._storage,e),a=n.data===this.data?this._base??this:void 0;return r._fromStorage(n,a)}flatten(){let t=Rr(this._storage);return r._fromStorage(t)}ravel(){let t=Ar(this._storage),n=t.data===this.data?this._base??this:void 0;return r._fromStorage(t,n)}transpose(t){let e=hr(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}squeeze(t){let e=Ee(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}expand_dims(t){let e=gr(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}swapaxes(t,e){let n=Ue(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}moveaxis(t,e){let n=xt(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}repeat(t,e){let n=Pe(this._storage,t,e);return r._fromStorage(n)}take(t,e){let n=Bn(this._storage,t,e);return r._fromStorage(n)}put(t,e){let n=e instanceof r?e._storage:e;En(this._storage,t,n)}matmul(t){let e=ar(this._storage,t._storage);return r._fromStorage(e)}dot(t){let e=Bt(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"?e:r._fromStorage(e)}trace(){return Qe(this._storage)}inner(t){let e=Ke(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"?e:r._fromStorage(e)}outer(t){let e=Et(this._storage,t._storage);return r._fromStorage(e)}tensordot(t,e=2){let n=rn(this._storage,t._storage,e);return typeof n=="number"||typeof n=="bigint"?n:r._fromStorage(n)}cbrt(){let t=fe(this._storage);return r._fromStorage(t)}fabs(){let t=le(this._storage);return r._fromStorage(t)}divmod(t){let e=typeof t=="number"?t:t._storage,[n,o]=pe(this._storage,e);return[r._fromStorage(n),r._fromStorage(o)]}square(){let t=ye(this._storage);return r._fromStorage(t)}remainder(t){let e=typeof t=="number"?t:t._storage,n=me(this._storage,e);return r._fromStorage(n)}heaviside(t){let e=typeof t=="number"?t:t._storage,n=de(this._storage,e);return r._fromStorage(n)}slice(...t){if(t.length===0)return this;if(t.length>this.ndim)throw new Error(`Too many indices for array: array is ${this.ndim}-dimensional, but ${t.length} were indexed`);let e=t.map((i,c)=>{let f=Ht(i);return Yt(f,this.shape[c])});for(;e.length<this.ndim;)e.push({start:0,stop:this.shape[e.length],step:1,isIndex:!1});let n=[],o=[],a=this._storage.offset;for(let i=0;i<e.length;i++){let c=e[i],f=this._storage.strides[i];if(a+=c.start*f,!c.isIndex){let p;c.step>0?p=Math.max(0,Math.ceil((c.stop-c.start)/c.step)):p=Math.max(0,Math.ceil((c.start-c.stop)/Math.abs(c.step))),n.push(p),o.push(f*c.step)}}let u=D.fromData(this._storage.data,n,this._storage.dtype,o,a),s=this._base??this;return new r(u,s)}row(t){if(this.ndim<2)throw new Error("row() requires at least 2 dimensions");return this.slice(String(t),":")}col(t){if(this.ndim<2)throw new Error("col() requires at least 2 dimensions");return this.slice(":",String(t))}rows(t,e){if(this.ndim<2)throw new Error("rows() requires at least 2 dimensions");return this.slice(`${t}:${e}`,":")}cols(t,e){if(this.ndim<2)throw new Error("cols() requires at least 2 dimensions");return this.slice(":",`${t}:${e}`)}toString(){return`NDArray(shape=${JSON.stringify(this.shape)}, dtype=${this.dtype})`}toArray(){if(this.ndim===0)return this._storage.iget(0);let t=this.shape,e=t.length,n=(o,a)=>{if(a===e)return this._storage.get(...o);let u=[];for(let s=0;s<t[a];s++)o[a]=s,u.push(n(o,a+1));return u};return n(new Array(e),0)}}});function Lt(){let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256}function Ys(r){if(r.startsWith("[")||r.startsWith("("))throw new J(`Structured/compound dtypes are not supported: ${r}`);let t="",e=r;(r[0]==="<"||r[0]===">"||r[0]==="="||r[0]==="|")&&(t=r[0],e=r.slice(1));let n=e[0];if(n&&n in Hs)throw new J(`Unsupported dtype: ${Hs[n]} (${r}). Use the 'force' parameter to skip arrays with unsupported dtypes.`);let o=mu[e];if(!o)throw new J(`Unknown or unsupported dtype descriptor: ${r}. Supported types: ${jr.join(", ")}. Use the 'force' parameter to skip arrays with unsupported dtypes.`);let a=Lt(),u=t==="<"||t==="|"||t==="="&&a,s=t===">"||t==="="&&!a,i=parseInt(e.slice(1),10),c=i>1&&(s&&a||u&&!a);return{dtype:o,needsByteSwap:c,itemsize:i}}var Nr,jr,mu,wr,Hs,J,j,xr=M(()=>{"use strict";Nr=new Uint8Array([147,78,85,77,80,89]),jr=["float64","float32","int64","int32","int16","int8","uint64","uint32","uint16","uint8","bool"];mu={f8:"float64",f4:"float32",i8:"int64",i4:"int32",i2:"int16",i1:"int8",u8:"uint64",u4:"uint32",u2:"uint16",u1:"uint8",b1:"bool"},wr={float64:"<f8",float32:"<f4",int64:"<i8",int32:"<i4",int16:"<i2",int8:"|i1",uint64:"<u8",uint32:"<u4",uint16:"<u2",uint8:"|u1",bool:"|b1"},Hs={c:"complex numbers",S:"byte strings",U:"Unicode strings",O:"Python objects",V:"structured arrays (void)",M:"datetime64",m:"timedelta64"};J=class extends Error{constructor(t){super(t),this.name="UnsupportedDTypeError"}},j=class extends Error{constructor(t){super(t),this.name="InvalidNpyError"}}});function tr(r){let t=r instanceof ArrayBuffer?new Uint8Array(r):r,e=Zr(t);return Wr(t,e)}function Zr(r){if(r.length<10)throw new j("File too small to be a valid NPY file");for(let c=0;c<Nr.length;c++)if(r[c]!==Nr[c])throw new j("Invalid NPY magic number");let t=r[6],e=r[7];if(t!==1&&t!==2&&t!==3)throw new j(`Unsupported NPY version: ${t}.${e}`);let n,o;t===1?(n=r[8]|r[9]<<8,o=10):(n=r[8]|r[9]<<8|r[10]<<16|r[11]<<24,o=12);let a=o+n;if(r.length<a)throw new j("File truncated: header extends beyond file");let u=r.slice(o,a),s=new TextDecoder("utf-8").decode(u).trim(),i=du(s);return{version:{major:t,minor:e},header:i,dataOffset:a}}function Wr(r,t){let{header:e,dataOffset:n}=t,{dtype:o,needsByteSwap:a,itemsize:u}=Ys(e.descr),s=e.shape.reduce((d,g)=>d*g,1),i=s*u,c=r.length-n;if(c<i)throw new j(`File truncated: expected ${i} bytes of data, got ${c}`);let f=new ArrayBuffer(i);new Uint8Array(f).set(r.subarray(n,n+i));let l=gu(f,o,s,a,u),y=e.shape,m;if(e.fortran_order&&y.length>1){let d=[...y].reverse(),g=D.fromData(l,d,o);m=Au(g,d),y=e.shape}else m=D.fromData(l,[...y],o);return new _(m)}function du(r){let t=r.match(/'descr'\s*:\s*'([^']+)'/),e=r.match(/'fortran_order'\s*:\s*(True|False)/),n=r.match(/'shape'\s*:\s*\(([^)]*)\)/);if(!t||!e||!n)throw new j(`Failed to parse NPY header: ${r}`);let o=t[1],a=e[1]==="True",u=n[1].trim(),s;return u===""?s=[]:s=u.split(",").map(i=>i.trim()).filter(i=>i!=="").map(i=>{let c=parseInt(i,10);if(isNaN(c))throw new j(`Invalid shape value: ${i}`);return c}),{descr:o,fortran_order:a,shape:s}}function gu(r,t,e,n,o){let a=U(t);if(!a)throw new j(`Cannot create array for dtype: ${t}`);if(!n)return new a(r,0,e);let u=new Uint8Array(r),s=new Uint8Array(r.byteLength);for(let i=0;i<e;i++){let c=i*o;for(let f=0;f<o;f++)s[c+f]=u[c+o-1-f]}return new a(s.buffer,0,e)}function Au(r,t){let e=t.length,n=r.size,o=r.dtype,a=U(o);if(!a)throw new j(`Cannot create array for dtype: ${o}`);let u=new a(n),s=[...t].reverse(),i=Js(t),c=Js(s),f=new Array(e).fill(0);for(let p=0;p<n;p++){let l=p;for(let m=0;m<e;m++){let d=i[m];f[m]=Math.floor(l/d),l=l%d}let y=0;for(let m=0;m<e;m++)y+=f[e-1-m]*c[m];w(o),u[y]=r.iget(p)}return D.fromData(u,s,o)}function Js(r){let t=new Array(r.length),e=1;for(let n=r.length-1;n>=0;n--)t[n]=e,e*=r[n];return t}var Gr=M(()=>{"use strict";Rt();Z();R();xr()});function Q(r){let t=r.shape,e=r.dtype,n=wr[e],o=t.length===0?"()":t.length===1?`(${t[0]},)`:`(${t.join(", ")})`,a=`{'descr': '${n}', 'fortran_order': False, 'shape': ${o}, }`,u=12,i=(64-(u+a.length+1)%64)%64;a=a+" ".repeat(i)+`
2
+ `;let c=new TextEncoder().encode(a),f=c.length,p=r.size,l=Qt(e),y=p*l,m=u+f+y,d=new Uint8Array(m);d.set(Nr,0),d[6]=3,d[7]=0,d[8]=f&255,d[9]=f>>8&255,d[10]=f>>16&255,d[11]=f>>24&255,d.set(c,u);let g=u+f;return hu(r,d.subarray(g),l),d}function hu(r,t,e){let n=r.dtype,o=r.size,a=Lt(),u=w(n),s=r._storage;if(s.isCContiguous&&s.offset===0&&a){let c=s.data,f=new Uint8Array(c.buffer,c.byteOffset,o*e);t.set(f)}else{let c=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let f=0;f<o;f++){let p=s.iget(f),l=f*e;u?bu(c,l,p,n==="uint64"):Su(c,l,p,n)}}}function bu(r,t,e,n){n?r.setBigUint64(t,e,!0):r.setBigInt64(t,e,!0)}function Su(r,t,e,n){switch(n){case"float64":r.setFloat64(t,e,!0);break;case"float32":r.setFloat32(t,e,!0);break;case"int32":r.setInt32(t,e,!0);break;case"int16":r.setInt16(t,e,!0);break;case"int8":r.setInt8(t,e);break;case"uint32":r.setUint32(t,e,!0);break;case"uint16":r.setUint16(t,e,!0);break;case"uint8":case"bool":r.setUint8(t,e);break;default:throw new Error(`Unsupported dtype for serialization: ${n}`)}}var Hr=M(()=>{"use strict";R();xr()});function qt(r){let t=4294967295;for(let e=0;e<r.length;e++)t=Du[(t^r[e])&255]^t>>>8;return(t^4294967295)>>>0}var Du,jt=M(()=>{"use strict";Du=(()=>{let r=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;r[t]=e}return r})()});async function Xs(r){let t=Ks(r),e=new Map;for(let n of t){let o=await Nu(n);e.set(n.name,o)}return e}function Qs(r){let t=Ks(r),e=new Map;for(let n of t){if(n.compressionMethod!==0)throw new Error(`Cannot read compressed entry synchronously: ${n.name}. Use readZip() (async) for DEFLATE-compressed files.`);e.set(n.name,n.compressedData)}return e}function Ks(r){let t=r instanceof ArrayBuffer?new Uint8Array(r):r,e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=[],o=-1;for(let c=t.length-22;c>=0;c--)if(e.getUint32(c,!0)===101010256){o=c;break}if(o===-1)throw new Error("Invalid ZIP file: end of central directory not found");let a=e.getUint32(o+16,!0),u=e.getUint16(o+10,!0),s=[],i=a;for(let c=0;c<u&&e.getUint32(i,!0)===33639248;c++){let p=e.getUint16(i+10,!0),l=e.getUint32(i+16,!0),y=e.getUint32(i+20,!0),m=e.getUint32(i+24,!0),d=e.getUint16(i+28,!0),g=e.getUint16(i+30,!0),h=e.getUint16(i+32,!0),A=e.getUint32(i+42,!0),b=t.slice(i+46,i+46+d),S=new TextDecoder("utf-8").decode(b);s.push({name:S,compressionMethod:p,crc32:l,compressedSize:y,uncompressedSize:m,localHeaderOffset:A}),i=i+46+d+g+h}for(let c of s){let f=c.localHeaderOffset;if(e.getUint32(f,!0)!==67324752)throw new Error(`Invalid local file header at offset ${f}`);let l=e.getUint16(f+26,!0),y=e.getUint16(f+28,!0),m=f+30+l+y,d=t.slice(m,m+c.compressedSize);n.push({name:c.name,compressedData:d,compressionMethod:c.compressionMethod,crc32:c.crc32,compressedSize:c.compressedSize,uncompressedSize:c.uncompressedSize})}return n}async function Nu(r){if(r.compressionMethod===0)return r.compressedData;if(r.compressionMethod===8)return await wu(r.compressedData);throw new Error(`Unsupported compression method: ${r.compressionMethod}`)}async function wu(r){if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available. This environment does not support the Compression Streams API. Please use a modern browser or Node.js 18+.");let t=new DecompressionStream("deflate-raw"),e=new Uint8Array(r.length);e.set(r);let n=t.writable.getWriter();n.write(e),n.close();let o=t.readable.getReader(),a=[];for(;;){let{done:c,value:f}=await o.read();if(c)break;a.push(f)}let u=a.reduce((c,f)=>c+f.length,0),s=new Uint8Array(u),i=0;for(let c of a)s.set(c,i),i+=c.length;return s}var ri=M(()=>{"use strict";jt()});var ei={};nt(ei,{loadNpz:()=>Yr,loadNpzSync:()=>Jr,parseNpz:()=>ir,parseNpzSync:()=>zr});async function ir(r,t={}){let e=t.force??!1,n=await Xs(r);return ti(n,e)}function zr(r,t={}){let e=t.force??!1,n=Qs(r);return ti(n,e)}function ti(r,t){let e=new Map,n=[],o=new Map;for(let[a,u]of r){if(!a.endsWith(".npy"))continue;let s=a.slice(0,-4);try{let i=tr(u);e.set(s,i)}catch(i){if(i instanceof J&&t)n.push(s),o.set(s,i.message);else throw i}}return{arrays:e,skipped:n,errors:o}}async function Yr(r,t={}){let e=await ir(r,t);return Object.fromEntries(e.arrays)}function Jr(r,t={}){let e=zr(r,t);return Object.fromEntries(e.arrays)}var Xr=M(()=>{"use strict";Gr();xr();ri()});async function ni(r,t={}){let e=t.compress??!1,n=[];for(let[l,y]of r){let m=qt(y),d,g;e?(d=await Iu(y),d.length<y.length?g=8:(d=y,g=0)):(d=y,g=0),n.push({name:l,data:y,compressedData:d,crc:m,compressionMethod:g,offset:0})}let o=0;for(let l of n){let y=new TextEncoder().encode(l.name);o+=30+y.length+l.compressedData.length}let a=0;for(let l of n){let y=new TextEncoder().encode(l.name);a+=46+y.length}let s=o+a+22,i=new Uint8Array(s),c=new DataView(i.buffer),f=0;for(let l of n)l.offset=f,f=ai(i,c,f,l);let p=f;for(let l of n)f=si(i,c,f,l);return ii(c,f,n.length,a,p),i}function oi(r){let t=[];for(let[f,p]of r){let l=qt(p);t.push({name:f,data:p,compressedData:p,crc:l,compressionMethod:0,offset:0})}let e=0;for(let f of t){let p=new TextEncoder().encode(f.name);e+=30+p.length+f.compressedData.length}let n=0;for(let f of t){let p=new TextEncoder().encode(f.name);n+=46+p.length}let a=e+n+22,u=new Uint8Array(a),s=new DataView(u.buffer),i=0;for(let f of t)f.offset=i,i=ai(u,s,i,f);let c=i;for(let f of t)i=si(u,s,i,f);return ii(s,i,t.length,n,c),u}function ai(r,t,e,n){let o=new TextEncoder().encode(n.name);return t.setUint32(e,67324752,!0),e+=4,t.setUint16(e,n.compressionMethod===8?20:10,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,n.compressionMethod,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,33,!0),e+=2,t.setUint32(e,n.crc,!0),e+=4,t.setUint32(e,n.compressedData.length,!0),e+=4,t.setUint32(e,n.data.length,!0),e+=4,t.setUint16(e,o.length,!0),e+=2,t.setUint16(e,0,!0),e+=2,r.set(o,e),e+=o.length,r.set(n.compressedData,e),e+=n.compressedData.length,e}function si(r,t,e,n){let o=new TextEncoder().encode(n.name);return t.setUint32(e,33639248,!0),e+=4,t.setUint16(e,20,!0),e+=2,t.setUint16(e,n.compressionMethod===8?20:10,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,n.compressionMethod,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,33,!0),e+=2,t.setUint32(e,n.crc,!0),e+=4,t.setUint32(e,n.compressedData.length,!0),e+=4,t.setUint32(e,n.data.length,!0),e+=4,t.setUint16(e,o.length,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint16(e,0,!0),e+=2,t.setUint32(e,0,!0),e+=4,t.setUint32(e,n.offset,!0),e+=4,r.set(o,e),e+=o.length,e}function ii(r,t,e,n,o){r.setUint32(t,101010256,!0),t+=4,r.setUint16(t,0,!0),t+=2,r.setUint16(t,0,!0),t+=2,r.setUint16(t,e,!0),t+=2,r.setUint16(t,e,!0),t+=2,r.setUint32(t,n,!0),t+=4,r.setUint32(t,o,!0),t+=4,r.setUint16(t,0,!0)}async function Iu(r){if(typeof CompressionStream>"u")throw new Error("CompressionStream is not available. This environment does not support the Compression Streams API. Please use a modern browser or Node.js 18+.");let t=new CompressionStream("deflate-raw"),e=new Uint8Array(r.length);e.set(r);let n=t.writable.getWriter();n.write(e),n.close();let o=t.readable.getReader(),a=[];for(;;){let{done:c,value:f}=await o.read();if(c)break;a.push(f)}let u=a.reduce((c,f)=>c+f.length,0),s=new Uint8Array(u),i=0;for(let c of a)s.set(c,i),i+=c.length;return s}var ui=M(()=>{"use strict";jt()});var fi={};nt(fi,{serializeNpz:()=>lr,serializeNpzSync:()=>Qr});async function lr(r,t={}){let e=ci(r);return ni(e,{compress:t.compress??!1})}function Qr(r){let t=ci(r);return oi(t)}function ci(r){let t=new Map;if(Array.isArray(r)){for(let n=0;n<r.length;n++){let o=r[n],a=Q(o);t.set(`arr_${n}.npy`,a)}return t}let e=r instanceof Map?r.entries():Object.entries(r);for(let[n,o]of e){if(typeof n!="string"||n.length===0)throw new Error("Array names must be non-empty strings");let a=Q(o),u=n.endsWith(".npy")?n:`${n}.npy`;t.set(u,a)}return t}var Kr=M(()=>{"use strict";Hr();ui()});var vu={};nt(vu,{DTYPE_TO_DESCR:()=>wr,InvalidNpyError:()=>j,NDArray:()=>_,SUPPORTED_DTYPES:()=>jr,UnsupportedDTypeError:()=>J,__version__:()=>zu,absolute:()=>Oo,append:()=>Va,arange:()=>ao,arccos:()=>Xo,arccosh:()=>ca,arcsin:()=>Jo,arcsinh:()=>ua,arctan:()=>Qo,arctan2:()=>Ko,arctanh:()=>fa,array:()=>q,array_equal:()=>Ha,array_equiv:()=>Ya,array_split:()=>Aa,asanyarray:()=>go,asarray:()=>Dr,ascontiguousarray:()=>Ao,asfortranarray:()=>ho,atleast_1d:()=>Ta,atleast_2d:()=>Oa,atleast_3d:()=>$a,average:()=>es,bitwise_and:()=>Ds,bitwise_not:()=>xs,bitwise_or:()=>Ns,bitwise_xor:()=>ws,broadcast_arrays:()=>qa,broadcast_shapes:()=>ja,broadcast_to:()=>La,cbrt:()=>ds,choose:()=>Ga,column_stack:()=>Ma,compress:()=>vs,concatenate:()=>sr,copy:()=>fo,cos:()=>Ho,cosh:()=>sa,cumprod:()=>Xa,cumsum:()=>Ja,deg2rad:()=>na,degrees:()=>ta,delete:()=>Pa,diag:()=>Pt,diag_indices:()=>ks,diag_indices_from:()=>Vs,diagflat:()=>bo,diagonal:()=>Ro,divmod:()=>As,dot:()=>Po,dsplit:()=>va,dstack:()=>da,einsum:()=>Us,empty:()=>kt,empty_like:()=>yo,expand_dims:()=>Ia,eye:()=>Ct,fabs:()=>gs,flip:()=>qr,fliplr:()=>za,flipud:()=>_a,floor_divide:()=>Co,frombuffer:()=>zo,fromfile:()=>_o,fromfunction:()=>So,fromiter:()=>Bo,fromstring:()=>Eo,full:()=>Vt,full_like:()=>mo,geomspace:()=>uo,heaviside:()=>Ss,hsplit:()=>ba,hstack:()=>ma,hypot:()=>ra,identity:()=>co,indices:()=>js,inner:()=>jo,insert:()=>Fa,invert:()=>Is,ix_:()=>Zs,kron:()=>Lo,left_shift:()=>zs,linspace:()=>so,load:()=>Bu,loadNpy:()=>li,loadNpySync:()=>pi,loadNpz:()=>Yr,loadNpzFile:()=>di,loadNpzFileSync:()=>gi,loadNpzSync:()=>Jr,loadSync:()=>Eu,logspace:()=>io,mask_indices:()=>qs,median:()=>Ka,meshgrid:()=>Do,mod:()=>Mo,moveaxis:()=>pa,nanargmax:()=>ls,nanargmin:()=>fs,nancumprod:()=>ys,nancumsum:()=>ps,nanmax:()=>cs,nanmean:()=>as,nanmedian:()=>ms,nanmin:()=>us,nanprod:()=>os,nanstd:()=>is,nansum:()=>ns,nanvar:()=>ss,negative:()=>$o,ones:()=>Mt,ones_like:()=>po,outer:()=>Zo,packbits:()=>Bs,pad:()=>Ra,parseNpy:()=>tr,parseNpyData:()=>Wr,parseNpyHeader:()=>Zr,parseNpz:()=>ir,parseNpzSync:()=>zr,percentile:()=>rs,place:()=>Cs,positive:()=>ko,power:()=>To,ptp:()=>Qa,put:()=>Wa,put_along_axis:()=>Os,putmask:()=>$s,quantile:()=>ts,rad2deg:()=>oa,radians:()=>ea,ravel:()=>Na,ravel_multi_index:()=>Ws,reciprocal:()=>Vo,remainder:()=>bs,repeat:()=>Da,reshape:()=>wa,resize:()=>ka,right_shift:()=>_s,roll:()=>Ea,rollaxis:()=>Ua,rot90:()=>Ba,row_stack:()=>Ca,save:()=>Uu,saveNpy:()=>yi,saveNpySync:()=>mi,saveNpz:()=>Gt,saveNpzSync:()=>_u,saveSync:()=>Tu,savez:()=>Ou,savez_compressed:()=>$u,select:()=>Ms,serializeNpy:()=>Q,serializeNpz:()=>lr,serializeNpzSync:()=>Qr,sign:()=>vo,sin:()=>Go,sinh:()=>aa,split:()=>ga,sqrt:()=>Uo,square:()=>hs,squeeze:()=>xa,stack:()=>ya,swapaxes:()=>la,take:()=>Za,take_along_axis:()=>Ts,tan:()=>Yo,tanh:()=>ia,tensordot:()=>Wo,tile:()=>Sa,trace:()=>Fo,transpose:()=>qo,tri:()=>No,tril:()=>wo,tril_indices:()=>Ps,tril_indices_from:()=>Fs,triu:()=>xo,triu_indices:()=>Rs,triu_indices_from:()=>Ls,unpackbits:()=>Es,unravel_index:()=>Gs,vander:()=>Io,vsplit:()=>ha,vstack:()=>Ft,zeros:()=>Y,zeros_like:()=>lo});module.exports=ot(vu);var pr=require("node:fs"),yr=require("node:fs/promises");Gr();Hr();Xr();Kr();Rt();Gr();Hr();xr();Xr();Kr();var zu="0.7.0";async function li(r){let t=await(0,yr.readFile)(r);return tr(t)}function pi(r){let t=(0,pr.readFileSync)(r);return tr(t)}async function yi(r,t){let e=Q(t);await(0,yr.writeFile)(r,e)}function mi(r,t){let e=Q(t);(0,pr.writeFileSync)(r,e)}async function di(r,t={}){let e=await(0,yr.readFile)(r);return ir(e,t)}function gi(r,t={}){let e=(0,pr.readFileSync)(r),{parseNpzSync:n}=(Xr(),ot(ei));return n(e,t)}async function Gt(r,t,e={}){let n=await lr(t,e);await(0,yr.writeFile)(r,n)}function _u(r,t){let{serializeNpzSync:e}=(Kr(),ot(fi)),n=e(t);(0,pr.writeFileSync)(r,n)}async function Bu(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return li(r)}else{if(r.endsWith(".npz"))return di(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}function Eu(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return pi(r)}else{if(r.endsWith(".npz"))return gi(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}async function Uu(r,t){if(!r.endsWith(".npy"))throw new Error(`save() is for .npy files. Use saveNpz() for .npz files. Got: ${r}`);return yi(r,t)}function Tu(r,t){if(!r.endsWith(".npy"))throw new Error(`saveSync() is for .npy files. Use saveNpzSync() for .npz files. Got: ${r}`);return mi(r,t)}async function Ou(r,t){return r.endsWith(".npz")||(r=r+".npz"),Gt(r,t,{compress:!1})}async function $u(r,t){return r.endsWith(".npz")||(r=r+".npz"),Gt(r,t,{compress:!0})}0&&(module.exports={DTYPE_TO_DESCR,InvalidNpyError,NDArray,SUPPORTED_DTYPES,UnsupportedDTypeError,__version__,absolute,append,arange,arccos,arccosh,arcsin,arcsinh,arctan,arctan2,arctanh,array,array_equal,array_equiv,array_split,asanyarray,asarray,ascontiguousarray,asfortranarray,atleast_1d,atleast_2d,atleast_3d,average,bitwise_and,bitwise_not,bitwise_or,bitwise_xor,broadcast_arrays,broadcast_shapes,broadcast_to,cbrt,choose,column_stack,compress,concatenate,copy,cos,cosh,cumprod,cumsum,deg2rad,degrees,delete:null,diag,diag_indices,diag_indices_from,diagflat,diagonal,divmod,dot,dsplit,dstack,einsum,empty,empty_like,expand_dims,eye,fabs,flip,fliplr,flipud,floor_divide,frombuffer,fromfile,fromfunction,fromiter,fromstring,full,full_like,geomspace,heaviside,hsplit,hstack,hypot,identity,indices,inner,insert,invert,ix_,kron,left_shift,linspace,load,loadNpy,loadNpySync,loadNpz,loadNpzFile,loadNpzFileSync,loadNpzSync,loadSync,logspace,mask_indices,median,meshgrid,mod,moveaxis,nanargmax,nanargmin,nancumprod,nancumsum,nanmax,nanmean,nanmedian,nanmin,nanprod,nanstd,nansum,nanvar,negative,ones,ones_like,outer,packbits,pad,parseNpy,parseNpyData,parseNpyHeader,parseNpz,parseNpzSync,percentile,place,positive,power,ptp,put,put_along_axis,putmask,quantile,rad2deg,radians,ravel,ravel_multi_index,reciprocal,remainder,repeat,reshape,resize,right_shift,roll,rollaxis,rot90,row_stack,save,saveNpy,saveNpySync,saveNpz,saveNpzSync,saveSync,savez,savez_compressed,select,serializeNpy,serializeNpz,serializeNpzSync,sign,sin,sinh,split,sqrt,square,squeeze,stack,swapaxes,take,take_along_axis,tan,tanh,tensordot,tile,trace,transpose,tri,tril,tril_indices,tril_indices_from,triu,triu_indices,triu_indices_from,unpackbits,unravel_index,vander,vsplit,vstack,zeros,zeros_like});
3
3
  //# sourceMappingURL=numpy-ts.node-io.cjs.map