numpy-ts 0.11.0 → 0.12.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,4 +1,4 @@
1
- "use strict";var pe=Object.defineProperty;var Gm=Object.getOwnPropertyDescriptor;var Zm=Object.getOwnPropertyNames;var Ym=Object.prototype.hasOwnProperty;var W=(r,t)=>()=>(r&&(t=r(r=0)),t);var ye=(r,t)=>{for(var e in t)pe(r,e,{get:t[e],enumerable:!0})},Hm=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zm(t))!Ym.call(r,o)&&o!==e&&pe(r,o,{get:()=>t[o],enumerable:!(n=Gm(t,o))||n.enumerable});return r};var de=r=>Hm(pe({},"__esModule",{value:!0}),r);function Jn(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 Xn(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 Qn=W(()=>{"use strict"});function j(r){switch(r){case"float64":return Float64Array;case"float32":return Float32Array;case"complex128":return Float64Array;case"complex64":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 Mt(r){switch(r){case"complex128":return 16;case"float64":case"int64":case"uint64":case"complex64":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 ro(r){return r==="int64"||r==="int32"||r==="int16"||r==="int8"||r==="uint64"||r==="uint32"||r==="uint16"||r==="uint8"}function Kn(r){return r==="float64"||r==="float32"}function B(r){return r==="int64"||r==="uint64"}function M(r){return r==="complex64"||r==="complex128"}function q(r,t,e){if(M(r)){let n=e?` ${e}`:"";throw new TypeError(`ufunc '${t}' not supported for complex dtype '${r}'.${n}`)}}function nt(r){if(r==="complex128")return"float64";if(r==="complex64")return"float32";throw new Error(`${r} is not a complex dtype`)}function to(r){return typeof r=="object"&&r!==null&&"re"in r&&"im"in r}function Z(r,t){if(r===t)return r;if(r==="bool")return t;if(t==="bool")return r;if(M(r)||M(t)){if(M(r)&&M(t))return r==="complex128"||t==="complex128"?"complex128":"complex64";let c=M(r)?r:t,l=M(r)?t:r;return c==="complex128"||l==="float64"||l==="int64"||l==="uint64"||l==="int32"||l==="uint32"?"complex128":"complex64"}if(Kn(r)||Kn(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 tr,J=W(()=>{"use strict";tr="float64"});var O,xr=W(()=>{"use strict";O=class r{constructor(t,e=0){this.re=t,this.im=e}abs(){return Math.sqrt(this.re*this.re+this.im*this.im)}angle(){return Math.atan2(this.im,this.re)}conj(){return new r(this.re,-this.im)}add(t){return typeof t=="number"?new r(this.re+t,this.im):new r(this.re+t.re,this.im+t.im)}sub(t){return typeof t=="number"?new r(this.re-t,this.im):new r(this.re-t.re,this.im-t.im)}mul(t){return typeof t=="number"?new r(this.re*t,this.im*t):new r(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)}div(t){if(typeof t=="number")return new r(this.re/t,this.im/t);let e=t.re*t.re+t.im*t.im;return new r((this.re*t.re+this.im*t.im)/e,(this.im*t.re-this.re*t.im)/e)}neg(){return new r(-this.re,-this.im)}equals(t){return this.re===t.re&&this.im===t.im}toString(){return this.im===0?`(${this.re}+0j)`:this.im<0?`(${this.re}${this.im}j)`:`(${this.re}+${this.im}j)`}static from(t){if(t instanceof r)return t;if(typeof t=="number")return new r(t,0);if(Array.isArray(t))return new r(t[0]??0,t[1]??0);if(typeof t=="object"&&t!==null&&"re"in t)return new r(t.re??0,t.im??0);throw new Error(`Cannot convert ${t} to Complex`)}static isComplex(t){return t instanceof r||typeof t=="object"&&t!==null&&"re"in t&&"im"in t}}});function ur(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,X=W(()=>{"use strict";J();xr();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,a=M(this._dtype),u;if(o===0)u=this._offset;else{let s=t;u=this._offset;for(let i=0;i<o;i++){let c=1;for(let m=i+1;m<o;m++)c*=e[m];let l=Math.floor(s/c);s=s%c,u+=l*n[i]}}if(a){let s=u*2,i=this._data[s],c=this._data[s+1];return new O(i,c)}return this._data[u]}iset(t,e){let n=this._shape,o=this._strides,a=n.length,u=M(this._dtype),s;if(a===0)s=this._offset;else{let i=t;s=this._offset;for(let c=0;c<a;c++){let l=1;for(let y=c+1;y<a;y++)l*=n[y];let m=Math.floor(i/l);i=i%l,s+=m*o[c]}}if(u){let i=s*2,c,l;e instanceof O?(c=e.re,l=e.im):typeof e=="object"&&e!==null&&"re"in e?(c=e.re,l=e.im??0):(c=Number(e),l=0),this._data[i]=c,this._data[i+1]=l}else 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];if(M(this._dtype)){let o=n*2,a=this._data[o],u=this._data[o+1];return new O(a,u)}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];if(M(this._dtype)){let a=o*2,u,s;e instanceof O?(u=e.re,s=e.im):typeof e=="object"&&e!==null&&"re"in e?(u=e.re,s=e.im??0):(u=Number(e),s=0),this._data[a]=u,this._data[a+1]=s}else this._data[o]=e}copy(){let t=Array.from(this._shape),e=this._dtype,n=this.size,o=M(e),a=j(e);if(!a)throw new Error(`Cannot copy array with dtype ${e}`);let u=o?n*2:n,s=new a(u);if(this.isCContiguous&&this._offset===0)if(B(e)){let i=this._data,c=s;for(let l=0;l<u;l++)c[l]=i[l]}else s.set(this._data.subarray(0,u));else if(B(e)){let i=s;for(let c=0;c<n;c++)i[c]=this.iget(c)}else if(o){let i=s;for(let c=0;c<n;c++){let l=this.iget(c);i[c*2]=l.re,i[c*2+1]=l.im}}else for(let i=0;i<n;i++)s[i]=this.iget(i);return new r(s,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=tr){let n=t.reduce((i,c)=>i*c,1),o=M(e),a=j(e);if(!a)throw new Error(`Cannot create array with dtype ${e}`);let u=o?n*2:n,s=new a(u);return new r(s,t,r._computeStrides(t),0,e)}static ones(t,e=tr){let n=t.reduce((i,c)=>i*c,1),o=M(e),a=j(e);if(!a)throw new Error(`Cannot create array with dtype ${e}`);let u=o?n*2:n,s=new a(u);if(B(e))s.fill(BigInt(1));else if(o){let i=s;for(let c=0;c<n;c++)i[c*2]=1,i[c*2+1]=0}else s.fill(1);return new r(s,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 gr(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 Jm(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 pr(r,t){let e=Jm(r.shape,r.strides,t);return D.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function ge(...r){let t=gr(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 Bt=W(()=>{"use strict";X()});function Er(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 Xm(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 vt(r,t){let e=Xm(r.shape,r.strides,t);return D.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function K(r,t,e,n){let o=Er(r.shape,t.shape),a=vt(r,o),u=vt(t,o),s=Z(r.dtype,t.dtype),i=D.zeros(o,s),c=i.data,l=i.size;if(B(s)){let m=c;for(let y=0;y<l;y++){let d=a.iget(y),f=u.iget(y),p=d instanceof O?d.re:d,g=f instanceof O?f.re:f,h=typeof p=="bigint"?p:BigInt(Math.round(p)),b=typeof g=="bigint"?g:BigInt(Math.round(g));n==="add"?m[y]=h+b:n==="subtract"?m[y]=h-b:n==="multiply"?m[y]=h*b:n==="divide"?m[y]=h/b:m[y]=BigInt(Math.round(e(Number(h),Number(b))))}}else{let m=B(r.dtype)||B(t.dtype);for(let y=0;y<l;y++){let d=a.iget(y),f=u.iget(y),p=Number(d),g=Number(f);c[y]=e(p,g)}}return i}function yr(r,t,e){let n=Er(r.shape,t.shape),o=vt(r,n),a=vt(t,n),u=n.reduce((c,l)=>c*l,1),s=new Uint8Array(u),i=B(r.dtype)||B(t.dtype);for(let c=0;c<u;c++){let l=o.iget(c),m=a.iget(c),y=Number(l),d=Number(m);s[c]=e(y,d)?1:0}return D.fromData(s,n,"bool")}function H(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,l=r.data;if(B(n))if(B(s)){let m=c;for(let y=0;y<a;y++){let d=Number(l[y]);m[y]=BigInt(Math.round(t(d)))}}else for(let m=0;m<a;m++)c[m]=t(Number(l[m]));else for(let m=0;m<a;m++)c[m]=t(Number(l[m]));return i}var Mr=W(()=>{"use strict";X();J();xr()});function Ae(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function fr(r,t){return[r[t*2],r[t*2+1]]}function Br(r,t,e,n){r[t*2]=e,r[t*2+1]=n}function eo(r,t){return typeof t=="number"?tp(r,t):Ae(r,t)?Qm(r,t):K(r,t,(e,n)=>e+n,"add")}function Qm(r,t){let e=Z(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(M(e)){let i=s,c=M(r.dtype),l=M(t.dtype);for(let m=0;m<o;m++){let[y,d]=c?fr(a,m):[Number(a[m]),0],[f,p]=l?fr(u,m):[Number(u[m]),0];Br(i,m,y+f,d+p)}return n}if(B(e)){let i=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),y=typeof u[l]=="bigint"?u[l]:BigInt(Math.round(Number(u[l])));i[l]=m+y}else{let l=a,m=u;for(let y=0;y<o;y++)i[y]=l[y]+m[y]}}else if(B(r.dtype)||B(t.dtype))for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?Number(a[c]):a[c],m=typeof u[c]=="bigint"?Number(u[c]):u[c];s[c]=l+m}else for(let c=0;c<o;c++)s[c]=a[c]+u[c];return n}function no(r,t){return typeof t=="number"?ep(r,t):Ae(r,t)?Km(r,t):K(r,t,(e,n)=>e-n,"subtract")}function Km(r,t){let e=Z(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(M(e)){let i=s,c=M(r.dtype),l=M(t.dtype);for(let m=0;m<o;m++){let[y,d]=c?fr(a,m):[Number(a[m]),0],[f,p]=l?fr(u,m):[Number(u[m]),0];Br(i,m,y-f,d-p)}return n}if(B(e)){let i=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),y=typeof u[l]=="bigint"?u[l]:BigInt(Math.round(Number(u[l])));i[l]=m-y}else{let l=a,m=u;for(let y=0;y<o;y++)i[y]=l[y]-m[y]}}else if(B(r.dtype)||B(t.dtype))for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?Number(a[c]):a[c],m=typeof u[c]=="bigint"?Number(u[c]):u[c];s[c]=l-m}else for(let c=0;c<o;c++)s[c]=a[c]-u[c];return n}function oo(r,t){return typeof t=="number"?np(r,t):Ae(r,t)?rp(r,t):K(r,t,(e,n)=>e*n,"multiply")}function rp(r,t){let e=Z(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(M(e)){let i=s,c=M(r.dtype),l=M(t.dtype);for(let m=0;m<o;m++){let[y,d]=c?fr(a,m):[Number(a[m]),0],[f,p]=l?fr(u,m):[Number(u[m]),0],g=y*f-d*p,h=y*p+d*f;Br(i,m,g,h)}return n}if(B(e)){let i=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),y=typeof u[l]=="bigint"?u[l]:BigInt(Math.round(Number(u[l])));i[l]=m*y}else{let l=a,m=u;for(let y=0;y<o;y++)i[y]=l[y]*m[y]}}else if(B(r.dtype)||B(t.dtype))for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?Number(a[c]):a[c],m=typeof u[c]=="bigint"?Number(u[c]):u[c];s[c]=l*m}else for(let c=0;c<o;c++)s[c]=a[c]*u[c];return n}function ao(r,t){if(typeof t=="number")return op(r,t);let e=M(r.dtype),n=M(t.dtype);if(e||n){let l=Z(r.dtype,t.dtype),m=D.zeros(Array.from(r.shape),l),y=m.data,d=r.size,f=r.data,p=t.data;for(let g=0;g<d;g++){let[h,b]=e?fr(f,g):[Number(f[g]),0],[A,S]=n?fr(p,g):[Number(p[g]),0],x=A*A+S*S,w=(h*A+b*S)/x,N=(b*A-h*S)/x;Br(y,g,w,N)}return m}let o=r.dtype==="float64",a=t.dtype==="float64",u=r.dtype==="float32",s=t.dtype==="float32";if(o||a){let l=o?r:Lr(r,"float64"),m=a?t:Lr(t,"float64");return K(l,m,(y,d)=>y/d,"divide")}if(u||s){let l=u?r:Lr(r,"float32"),m=s?t:Lr(t,"float32");return K(l,m,(y,d)=>y/d,"divide")}let i=Lr(r,"float64"),c=Lr(t,"float64");return K(i,c,(l,m)=>l/m,"divide")}function Lr(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 tp(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(M(e)){let i=o,c=s;for(let l=0;l<a;l++){let[m,y]=fr(i,l);Br(c,l,m+t,y)}}else if(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]+l}else for(let i=0;i<a;i++)s[i]=Number(o[i])+t;return u}function ep(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(M(e)){let i=o,c=s;for(let l=0;l<a;l++){let[m,y]=fr(i,l);Br(c,l,m-t,y)}}else if(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]-l}else for(let i=0;i<a;i++)s[i]=Number(o[i])-t;return u}function np(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(M(e)){let i=o,c=s;for(let l=0;l<a;l++){let[m,y]=fr(i,l);Br(c,l,m*t,y*t)}}else if(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]*l}else for(let i=0;i<a;i++)s[i]=Number(o[i])*t;return u}function op(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size;if(M(e)){let l=D.zeros(n,e),m=o,y=l.data;for(let d=0;d<a;d++){let[f,p]=fr(m,d);Br(y,d,f/t,p/t)}return l}let s=e!=="float32"&&e!=="float64"?"float64":e,i=D.zeros(n,s),c=i.data;if(B(e))for(let l=0;l<a;l++)c[l]=Number(o[l])/t;else for(let l=0;l<a;l++)c[l]=Number(o[l])/t;return i}function so(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size;if(M(t)){let s=nt(t),i=D.zeros(e,s),c=i.data,l=n;for(let m=0;m<o;m++){let y=l[m*2],d=l[m*2+1];c[m]=Math.sqrt(y*y+d*d)}return i}let a=D.zeros(e,t),u=a.data;if(B(t)){let s=n,i=u;for(let c=0;c<o;c++){let l=s[c];i[c]=l<0n?-l:l}}else for(let s=0;s<o;s++)u[s]=Math.abs(Number(n[s]));return a}function io(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(M(t)){let s=n,i=u;for(let c=0;c<o;c++){let[l,m]=fr(s,c);Br(i,c,-l,-m)}}else if(B(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 uo(r){q(r.dtype,"sign","Sign is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=D.zeros(e,t),u=a.data;if(B(t)){let s=n,i=u;for(let c=0;c<o;c++){let l=s[c];i[c]=l>0n?1n:l<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 Tt(r,t){return q(r.dtype,"mod","Modulo is not defined for complex numbers."),typeof t!="number"&&q(t.dtype,"mod","Modulo is not defined for complex numbers."),typeof t=="number"?ap(r,t):K(r,t,(e,n)=>(e%n+n)%n,"mod")}function ap(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++){let y=i[m];c[m]=(y%l+l)%l}}else for(let i=0;i<a;i++){let c=Number(o[i]);s[i]=(c%t+t)%t}return u}function be(r,t){return q(r.dtype,"floor_divide","Floor division is not defined for complex numbers."),typeof t!="number"&&q(t.dtype,"floor_divide","Floor division is not defined for complex numbers."),typeof t=="number"?sp(r,t):K(r,t,(e,n)=>Math.floor(e/n),"floor_divide")}function sp(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]/l}else for(let i=0;i<a;i++)s[i]=Math.floor(Number(o[i])/t);return u}function co(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(M(t)){let s=n,i=u;for(let c=0;c<o;c++)i[c*2]=s[c*2],i[c*2+1]=s[c*2+1]}else for(let s=0;s<o;s++)u[s]=n[s];return a}function lo(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size;if(M(t)){let c=D.zeros(e,t),l=n,m=c.data;for(let y=0;y<o;y++){let d=l[y*2],f=l[y*2+1],p=d*d+f*f;m[y*2]=d/p,m[y*2+1]=-f/p}return c}let u=t!=="float32"&&t!=="float64"?"float64":t,s=D.zeros(e,u),i=s.data;if(B(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 fo(r){let t=r.dtype;q(t,"cbrt","cbrt is not supported for complex numbers.");let 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 mo(r){let t=r.dtype;q(t,"fabs","fabs is only for real numbers. Use absolute() for complex.");let 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 po(r,t){let e=be(r,t),n=Tt(r,t);return[e,n]}function yo(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(M(t)){let s=n,i=u;for(let c=0;c<o;c++){let l=s[c*2],m=s[c*2+1];i[c*2]=l*l-m*m,i[c*2+1]=2*l*m}}else if(B(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 go(r,t){return Tt(r,t)}function Ao(r,t){q(r.dtype,"heaviside","Heaviside step function is not defined for complex numbers."),typeof t!="number"&&q(t.dtype,"heaviside","Heaviside step function is not defined for complex numbers.");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((l,m)=>l===c[m]))for(let l=0;l<o;l++){let m=Number(r.data[l]);m<0?s[l]=0:m===0?s[l]=Number(i[l]):s[l]=1}else for(let l=0;l<o;l++){let m=Number(r.data[l]),y=l%t.size;m<0?s[l]=0:m===0?s[l]=Number(i[y]):s[l]=1}}return u}function bo(r,t){let e=r.dtype;if(M(e)){let n=r.data,o=r.size,a=D.zeros(Array.from(r.shape),e),u=a.data;if(typeof t=="number")for(let s=0;s<o;s++){let i=n[s*2],c=n[s*2+1],l=Math.hypot(i,c),m=Math.atan2(c,i),y=Math.pow(l,t),d=m*t;u[s*2]=y*Math.cos(d),u[s*2+1]=y*Math.sin(d)}else{let s=t.data,i=M(t.dtype);for(let c=0;c<o;c++){let l=n[c*2],m=n[c*2+1],y,d;i?(y=s[c*2],d=s[c*2+1]):(y=Number(s[c]),d=0);let f=Math.hypot(l,m),p=Math.atan2(m,l),g=Math.log(f),h=p,b=y*g-d*h,A=y*h+d*g,S=Math.exp(b);u[c*2]=S*Math.cos(A),u[c*2+1]=S*Math.sin(A)}}return a}if(typeof t=="number"){let n=D.zeros(Array.from(r.shape),"float64"),o=n.data,a=r.data,u=r.size;for(let s=0;s<u;s++)o[s]=Math.pow(Number(a[s]),t);return n}return K(r,t,(n,o)=>Math.pow(n,o),"float_power")}function ho(r,t){if(q(r.dtype,"fmod","fmod is not defined for complex numbers."),typeof t!="number"&&q(t.dtype,"fmod","fmod is not defined for complex numbers."),typeof t=="number"){let e=r.copy(),n=e.data,o=r.size;for(let a=0;a<o;a++){let u=Number(n[a]);n[a]=u-Math.trunc(u/t)*t}return e}return K(r,t,(e,n)=>e-Math.trunc(e/n)*n,"fmod")}function So(r){q(r.dtype,"frexp","frexp is not defined for complex numbers.");let t=D.zeros(Array.from(r.shape),"float64"),e=D.zeros(Array.from(r.shape),"int32"),n=t.data,o=e.data,a=r.data,u=r.size;for(let s=0;s<u;s++){let i=Number(a[s]);if(i===0||!isFinite(i))n[s]=i,o[s]=0;else{let c=Math.floor(Math.log2(Math.abs(i)))+1,l=i/Math.pow(2,c);n[s]=l,o[s]=c}}return[t,e]}function xo(r,t){q(r.dtype,"gcd","GCD is only defined for integers."),typeof t!="number"&&q(t.dtype,"gcd","GCD is only defined for integers.");let e=(i,c)=>{for(i=Math.abs(Math.trunc(i)),c=Math.abs(Math.trunc(c));c!==0;){let l=c;c=i%c,i=l}return i};if(typeof t=="number"){let i=D.zeros(Array.from(r.shape),"int32"),c=i.data,l=r.data,m=r.size,y=Math.abs(Math.trunc(t));for(let d=0;d<m;d++)c[d]=e(Number(l[d]),y);return i}let n=K(r,t,e,"gcd"),o=D.zeros(Array.from(n.shape),"int32"),a=o.data,u=n.data,s=n.size;for(let i=0;i<s;i++)a[i]=Math.round(Number(u[i]));return o}function Do(r,t){q(r.dtype,"lcm","LCM is only defined for integers."),typeof t!="number"&&q(t.dtype,"lcm","LCM is only defined for integers.");let e=(c,l)=>{for(c=Math.abs(Math.trunc(c)),l=Math.abs(Math.trunc(l));l!==0;){let m=l;l=c%l,c=m}return c},n=(c,l)=>(c=Math.abs(Math.trunc(c)),l=Math.abs(Math.trunc(l)),c===0||l===0?0:c*l/e(c,l));if(typeof t=="number"){let c=D.zeros(Array.from(r.shape),"int32"),l=c.data,m=r.data,y=r.size,d=Math.abs(Math.trunc(t));for(let f=0;f<y;f++)l[f]=n(Number(m[f]),d);return c}let o=K(r,t,n,"lcm"),a=D.zeros(Array.from(o.shape),"int32"),u=a.data,s=o.data,i=o.size;for(let c=0;c<i;c++)u[c]=Math.round(Number(s[c]));return a}function No(r,t){if(q(r.dtype,"ldexp","ldexp is not defined for complex numbers."),typeof t!="number"&&q(t.dtype,"ldexp","ldexp is not defined for complex numbers."),typeof t=="number"){let e=D.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.data,a=r.size,u=Math.pow(2,t);for(let s=0;s<a;s++)n[s]=Number(o[s])*u;return e}return K(r,t,(e,n)=>e*Math.pow(2,n),"ldexp")}function wo(r){q(r.dtype,"modf","modf is not defined for complex numbers.");let t=D.zeros(Array.from(r.shape),"float64"),e=D.zeros(Array.from(r.shape),"float64"),n=t.data,o=e.data,a=r.data,u=r.size;for(let s=0;s<u;s++){let i=Number(a[s]),c=Math.trunc(i);o[s]=c,n[s]=i-c}return[t,e]}var Io=W(()=>{"use strict";X();J();Mr()});function $r(r,t){return[r[t*2],r[t*2+1]]}function zo(r,t){if(M(r.dtype))return $r(r.data,t);let e=r.iget(t);return e instanceof O?[e.re,e.im]:[Number(e),0]}function Wr(r,t,e){let n=gr([Array.from(r.shape),Array.from(t.shape)]);if(!n)throw new Error("Cannot broadcast arrays together");let o=pr(r,n),a=pr(t,n),u=n.reduce((i,c)=>i*c,1),s=new Uint8Array(u);for(let i=0;i<u;i++){let[c,l]=zo(o,i),[m,y]=zo(a,i);s[i]=e(c,l,m,y)?1:0}return D.fromData(s,n,"bool")}function _o(r,t){return typeof t=="number"?up(r,t):M(r.dtype)||M(t.dtype)?Wr(r,t,(e,n,o,a)=>e!==o?e>o:n>a):yr(r,t,(e,n)=>e>n)}function Fo(r,t){return typeof t=="number"?cp(r,t):M(r.dtype)||M(t.dtype)?Wr(r,t,(e,n,o,a)=>e!==o?e>=o:n>=a):yr(r,t,(e,n)=>e>=n)}function Mo(r,t){return typeof t=="number"?lp(r,t):M(r.dtype)||M(t.dtype)?Wr(r,t,(e,n,o,a)=>e!==o?e<o:n<a):yr(r,t,(e,n)=>e<n)}function Bo(r,t){return typeof t=="number"?fp(r,t):M(r.dtype)||M(t.dtype)?Wr(r,t,(e,n,o,a)=>e!==o?e<=o:n<=a):yr(r,t,(e,n)=>e<=n)}function vo(r,t){return typeof t=="number"?mp(r,t):M(r.dtype)||M(t.dtype)?Wr(r,t,(e,n,o,a)=>e===o&&n===a):yr(r,t,(e,n)=>e===n)}function To(r,t){return typeof t=="number"?pp(r,t):M(r.dtype)||M(t.dtype)?Wr(r,t,(e,n,o,a)=>e!==o||n!==a):yr(r,t,(e,n)=>e!==n)}function he(r,t,e=1e-5,n=1e-8){return typeof t=="number"?yp(r,t,e,n):yr(r,t,(o,a)=>{let u=Math.abs(o-a),s=n+e*Math.abs(a);return u<=s})}function Eo(r,t,e=1e-5,n=1e-8){let o=he(r,t,e,n),a=o.data;for(let u=0;u<o.size;u++)if(a[u]===0)return!1;return!0}function Oo(r,t){let e=[Array.from(r.shape),Array.from(t.shape)],n=gr(e);if(n===null)return!1;let o=pr(r,n),a=pr(t,n),u=n.length,s=n.reduce((l,m)=>l*m,1),i=B(o.dtype),c=B(a.dtype);for(let l=0;l<s;l++){let m=l,y=new Array(u);for(let p=u-1;p>=0;p--)y[p]=m%n[p],m=Math.floor(m/n[p]);let d=o.get(...y),f=a.get(...y);if(i||c){let p=typeof d=="bigint"?d:BigInt(Number(d)),g=typeof f=="bigint"?f:BigInt(Number(f));if(p!==g)return!1}else if(d!==f)return!1}return!0}function up(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[u,s]=$r(o,a);e[a]=(u!==t?u>t:s>0)?1:0}}else 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 cp(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[u,s]=$r(o,a);e[a]=(u!==t?u>=t:s>=0)?1:0}}else 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 lp(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[u,s]=$r(o,a);e[a]=(u!==t?u<t:s<0)?1:0}}else 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 fp(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[u,s]=$r(o,a);e[a]=(u!==t?u<=t:s<=0)?1:0}}else 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 mp(r,t){let e=new Uint8Array(r.size),n=r.data,o=r.dtype;if(M(o)){let a=n;for(let u=0;u<r.size;u++){let[s,i]=$r(a,u);e[u]=s===t&&i===0?1:0}}else if(B(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 pp(r,t){let e=new Uint8Array(r.size),n=r.data,o=r.dtype;if(M(o)){let a=n;for(let u=0;u<r.size;u++){let[s,i]=$r(a,u);e[u]=s!==t||i!==0?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 yp(r,t,e,n){let o=new Uint8Array(r.size),a=r.data,u=r.dtype;if(B(u)){let s=a;for(let i=0;i<r.size;i++){let c=Number(s[i]),l=Math.abs(c-t),m=n+e*Math.abs(t);o[i]=l<=m?1:0}}else for(let s=0;s<r.size;s++){let i=Number(a[s]),c=Math.abs(i-t),l=n+e*Math.abs(t);o[s]=c<=l?1:0}return D.fromData(o,Array.from(r.shape),"bool")}var Co=W(()=>{"use strict";X();J();Mr();Bt();xr()});function U(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 Se=W(()=>{"use strict"});function ot(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(M(n)){let f=s,p=0,g=0;for(let h=0;h<u;h++)p+=f[h*2],g+=f[h*2+1];return new O(p,g)}else if(B(n)){let f=s,p=BigInt(0);for(let g=0;g<u;g++)p+=f[g];return Number(p)}else{let f=0;for(let p=0;p<u;p++)f+=Number(s[p]);return f}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((f,p)=>p!==i);if(c.length===0)return ot(r);let l=D.zeros(c,n),m=l.data,y=o[i],d=c.reduce((f,p)=>f*p,1);if(M(n)){let f=s,p=m;for(let g=0;g<d;g++){let h=0,b=0;for(let A=0;A<y;A++){let S=$(g,i,A,o),x=U(S,o);h+=f[x*2],b+=f[x*2+1]}p[g*2]=h,p[g*2+1]=b}}else if(B(n)){let f=s,p=m;for(let g=0;g<d;g++){let h=BigInt(0);for(let b=0;b<y;b++){let A=$(g,i,b,o),S=U(A,o);h+=f[S]}p[g]=h}}else for(let f=0;f<d;f++){let p=0;for(let g=0;g<y;g++){let h=$(f,i,g,o),b=U(h,o);p+=Number(s[b])}m[f]=p}if(e){let f=[...o];return f[i]=1,D.fromData(m,f,n)}return l}function Et(r,t,e=!1){let n=r.dtype,o=r.shape;if(t===void 0){let y=ot(r);return y instanceof O?new O(y.re/r.size,y.im/r.size):y/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=ot(r,t,e);if(typeof u=="number")return u/o[a];if(u instanceof O)return new O(u.re/o[a],u.im/o[a]);let s=o[a],i=n;M(n)?i=n:(B(n)||n.startsWith("int")||n.startsWith("uint"))&&(i="float64");let c=D.zeros(Array.from(u.shape),i),l=c.data,m=u.data;if(M(n)){let y=m,d=l,f=u.size;for(let p=0;p<f;p++)d[p*2]=y[p*2]/s,d[p*2+1]=y[p*2+1]/s}else if(B(n)){let y=m;for(let d=0;d<l.length;d++)l[d]=Number(y[d])/s}else for(let y=0;y<l.length;y++)l[y]=Number(m[y])/s;return c}function Gr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.size,s=r.data;if(M(n)){let f=s;if(t===void 0){if(u===0)throw new Error("max of empty array");let x=f[0],w=f[1];for(let N=1;N<u;N++){let I=f[N*2],z=f[N*2+1];if(isNaN(I)||isNaN(z))return new O(NaN,NaN);(I>x||I===x&&z>w)&&(x=I,w=z)}return isNaN(x)||isNaN(w)?new O(NaN,NaN):new O(x,w)}let p=t;if(p<0&&(p=a+p),p<0||p>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let g=Array.from(o).filter((x,w)=>w!==p);if(g.length===0)return Gr(r);let h=D.zeros(g,n),b=h.data,A=o[p],S=g.reduce((x,w)=>x*w,1);for(let x=0;x<S;x++){let w=$(x,p,0,o),N=U(w,o),I=f[N*2],z=f[N*2+1];for(let F=1;F<A;F++){let _=$(x,p,F,o),T=U(_,o),E=f[T*2],C=f[T*2+1];if(isNaN(E)||isNaN(C)){I=NaN,z=NaN;break}(E>I||E===I&&C>z)&&(I=E,z=C)}b[x*2]=I,b[x*2+1]=z}if(e){let x=[...o];return x[p]=1,D.fromData(b,x,n)}return h}if(t===void 0){if(u===0)throw new Error("max of empty array");let f=s[0];for(let p=1;p<u;p++)s[p]>f&&(f=s[p]);return Number(f)}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((f,p)=>p!==i);if(c.length===0)return Gr(r);let l=D.zeros(c,n),m=l.data,y=o[i],d=c.reduce((f,p)=>f*p,1);if(B(n)){let f=s,p=m;for(let g=0;g<d;g++){let h=$(g,i,0,o),b=U(h,o),A=f[b];for(let S=1;S<y;S++){let x=$(g,i,S,o),w=U(x,o),N=f[w];N>A&&(A=N)}p[g]=A}}else for(let f=0;f<d;f++){let p=-1/0;for(let g=0;g<y;g++){let h=$(f,i,g,o),b=U(h,o),A=Number(s[b]);A>p&&(p=A)}m[f]=p}if(e){let f=[...o];return f[i]=1,D.fromData(m,f,n)}return l}function xe(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(M(n)){let f=s,p=1,g=0;for(let h=0;h<u;h++){let b=f[h*2],A=f[h*2+1],S=p*b-g*A,x=p*A+g*b;p=S,g=x}return new O(p,g)}else if(B(n)){let f=s,p=BigInt(1);for(let g=0;g<u;g++)p*=f[g];return Number(p)}else{let f=1;for(let p=0;p<u;p++)f*=Number(s[p]);return f}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((f,p)=>p!==i);if(c.length===0)return xe(r);let l=D.zeros(c,n),m=l.data,y=o[i],d=c.reduce((f,p)=>f*p,1);if(M(n)){let f=s,p=m;for(let g=0;g<d;g++){let h=1,b=0;for(let A=0;A<y;A++){let S=$(g,i,A,o),x=U(S,o),w=f[x*2],N=f[x*2+1],I=h*w-b*N,z=h*N+b*w;h=I,b=z}p[g*2]=h,p[g*2+1]=b}}else if(B(n)){let f=s,p=m;for(let g=0;g<d;g++){let h=BigInt(1);for(let b=0;b<y;b++){let A=$(g,i,b,o),S=U(A,o);h*=f[S]}p[g]=h}}else for(let f=0;f<d;f++){let p=1;for(let g=0;g<y;g++){let h=$(f,i,g,o),b=U(h,o);p*=Number(s[b])}m[f]=p}if(e){let f=[...o];return f[i]=1,D.fromData(m,f,n)}return l}function Zr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.size,s=r.data;if(M(n)){let f=s;if(t===void 0){if(u===0)throw new Error("min of empty array");let x=f[0],w=f[1];for(let N=1;N<u;N++){let I=f[N*2],z=f[N*2+1];if(isNaN(I)||isNaN(z))return new O(NaN,NaN);(I<x||I===x&&z<w)&&(x=I,w=z)}return isNaN(x)||isNaN(w)?new O(NaN,NaN):new O(x,w)}let p=t;if(p<0&&(p=a+p),p<0||p>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let g=Array.from(o).filter((x,w)=>w!==p);if(g.length===0)return Zr(r);let h=D.zeros(g,n),b=h.data,A=o[p],S=g.reduce((x,w)=>x*w,1);for(let x=0;x<S;x++){let w=$(x,p,0,o),N=U(w,o),I=f[N*2],z=f[N*2+1];for(let F=1;F<A;F++){let _=$(x,p,F,o),T=U(_,o),E=f[T*2],C=f[T*2+1];if(isNaN(E)||isNaN(C)){I=NaN,z=NaN;break}(E<I||E===I&&C<z)&&(I=E,z=C)}b[x*2]=I,b[x*2+1]=z}if(e){let x=[...o];return x[p]=1,D.fromData(b,x,n)}return h}if(t===void 0){if(u===0)throw new Error("min of empty array");let f=s[0];for(let p=1;p<u;p++)s[p]<f&&(f=s[p]);return Number(f)}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((f,p)=>p!==i);if(c.length===0)return Zr(r);let l=D.zeros(c,n),m=l.data,y=o[i],d=c.reduce((f,p)=>f*p,1);if(B(n)){let f=s,p=m;for(let g=0;g<d;g++){let h=$(g,i,0,o),b=U(h,o),A=f[b];for(let S=1;S<y;S++){let x=$(g,i,S,o),w=U(x,o),N=f[w];N<A&&(A=N)}p[g]=A}}else for(let f=0;f<d;f++){let p=1/0;for(let g=0;g<y;g++){let h=$(f,i,g,o),b=U(h,o),A=Number(s[b]);A<p&&(p=A)}m[f]=p}if(e){let f=[...o];return f[i]=1,D.fromData(m,f,n)}return l}function Or(r,t,e,n){return r<e?-1:r>e?1:t<n?-1:t>n?1:0}function De(r,t){let e=r.dtype,n=M(e),o=r.shape,a=o.length,u=r.size,s=r.data;if(t===void 0){if(u===0)throw new Error("argmin of empty array");if(n){let g=s,h=g[0],b=g[1],A=0;for(let S=1;S<u;S++){let x=g[S*2],w=g[S*2+1];Or(x,w,h,b)<0&&(h=x,b=w,A=S)}return A}let f=s[0],p=0;for(let g=1;g<u;g++)s[g]<f&&(f=s[g],p=g);return p}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((f,p)=>p!==i);if(c.length===0)return De(r);let l=D.zeros(c,"int32"),m=l.data,y=o[i],d=c.reduce((f,p)=>f*p,1);if(n){let f=s;for(let p=0;p<d;p++){let g=$(p,i,0,o),h=U(g,o),b=f[h*2],A=f[h*2+1],S=0;for(let x=1;x<y;x++){let w=$(p,i,x,o),N=U(w,o),I=f[N*2],z=f[N*2+1];Or(I,z,b,A)<0&&(b=I,A=z,S=x)}m[p]=S}}else if(B(e)){let f=s;for(let p=0;p<d;p++){let g=$(p,i,0,o),h=U(g,o),b=f[h],A=0;for(let S=1;S<y;S++){let x=$(p,i,S,o),w=U(x,o),N=f[w];N<b&&(b=N,A=S)}m[p]=A}}else for(let f=0;f<d;f++){let p=1/0,g=0;for(let h=0;h<y;h++){let b=$(f,i,h,o),A=U(b,o),S=Number(s[A]);S<p&&(p=S,g=h)}m[f]=g}return l}function Ne(r,t){let e=r.dtype,n=M(e),o=r.shape,a=o.length,u=r.size,s=r.data;if(t===void 0){if(u===0)throw new Error("argmax of empty array");if(n){let g=s,h=g[0],b=g[1],A=0;for(let S=1;S<u;S++){let x=g[S*2],w=g[S*2+1];Or(x,w,h,b)>0&&(h=x,b=w,A=S)}return A}let f=s[0],p=0;for(let g=1;g<u;g++)s[g]>f&&(f=s[g],p=g);return p}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((f,p)=>p!==i);if(c.length===0)return Ne(r);let l=D.zeros(c,"int32"),m=l.data,y=o[i],d=c.reduce((f,p)=>f*p,1);if(n){let f=s;for(let p=0;p<d;p++){let g=$(p,i,0,o),h=U(g,o),b=f[h*2],A=f[h*2+1],S=0;for(let x=1;x<y;x++){let w=$(p,i,x,o),N=U(w,o),I=f[N*2],z=f[N*2+1];Or(I,z,b,A)>0&&(b=I,A=z,S=x)}m[p]=S}}else if(B(e)){let f=s;for(let p=0;p<d;p++){let g=$(p,i,0,o),h=U(g,o),b=f[h],A=0;for(let S=1;S<y;S++){let x=$(p,i,S,o),w=U(x,o),N=f[w];N>b&&(b=N,A=S)}m[p]=A}}else for(let f=0;f<d;f++){let p=-1/0,g=0;for(let h=0;h<y;h++){let b=$(f,i,h,o),A=U(b,o),S=Number(s[A]);S>p&&(p=S,g=h)}m[f]=g}return l}function we(r,t,e=0,n=!1){let o=r.dtype,a=r.shape,u=a.length,s=r.size,i=r.data,c=Et(r,t,n);if(t===void 0){if(M(o)){let S=i,x=c,w=0;for(let N=0;N<s;N++){let I=S[N*2],z=S[N*2+1],F=I-x.re,_=z-x.im;w+=F*F+_*_}return w/(s-e)}let b=c,A=0;for(let S=0;S<s;S++){let x=Number(i[S])-b;A+=x*x}return A/(s-e)}let l=t;if(l<0&&(l=u+l),l<0||l>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let m=a[l],y=c,d=y.data,f=n?y.shape:Array.from(a).filter((b,A)=>A!==l),p=D.zeros(Array.from(f),"float64"),g=p.data,h=f.reduce((b,A)=>b*A,1);if(M(o)){let b=i,A=d;for(let S=0;S<h;S++){let x=0,w=A[S*2],N=A[S*2+1];for(let I=0;I<m;I++){let z=$(S,l,I,a),F=U(z,a),_=b[F*2],T=b[F*2+1],E=_-w,C=T-N;x+=E*E+C*C}g[S]=x/(m-e)}}else for(let b=0;b<h;b++){let A=0,S=Number(d[b]);for(let x=0;x<m;x++){let w=$(b,l,x,a),N=U(w,a),I=Number(i[N])-S;A+=I*I}g[b]=A/(m-e)}return p}function Uo(r,t,e=0,n=!1){let o=we(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 Ie(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,u=r.data;if(t===void 0){for(let d=0;d<a;d++)if(!u[d])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((d,f)=>f!==s);if(i.length===0)return Ie(r);let c=D.zeros(i,"bool"),l=c.data,m=n[s],y=i.reduce((d,f)=>d*f,1);for(let d=0;d<y;d++){let f=!0;for(let p=0;p<m;p++){let g=$(d,s,p,n),h=U(g,n);if(!u[h]){f=!1;break}}l[d]=f?1:0}if(e){let d=[...n];return d[s]=1,D.fromData(l,d,"bool")}return c}function ze(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,u=r.data;if(t===void 0){for(let d=0;d<a;d++)if(u[d])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((d,f)=>f!==s);if(i.length===0)return ze(r);let c=D.zeros(i,"bool"),l=c.data,m=n[s],y=i.reduce((d,f)=>d*f,1);for(let d=0;d<y;d++){let f=!1;for(let p=0;p<m;p++){let g=$(d,s,p,n),h=U(g,n);if(u[h]){f=!0;break}}l[d]=f?1:0}if(e){let d=[...n];return d[s]=1,D.fromData(l,d,"bool")}return c}function _e(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let d=a,f=r.size;if(t===void 0){let N=D.zeros([f],e),I=N.data,z=0,F=0;for(let _=0;_<f;_++)z+=d[_*2],F+=d[_*2+1],I[_*2]=z,I[_*2+1]=F;return N}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=D.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let N=o-1;N>=0;N--)A.unshift(S),S*=n[N];let x=r.size,w=A[p];for(let N=0;N<x;N++)Math.floor(N/w)%b===0?(h[N*2]=d[N*2],h[N*2+1]=d[N*2+1]):(h[N*2]=h[(N-w)*2]+d[N*2],h[N*2+1]=h[(N-w)*2+1]+d[N*2+1]);return g}if(t===void 0){let d=r.size,f=new Float64Array(d),p=0;for(let g=0;g<d;g++)p+=Number(a[g]),f[g]=p;return D.fromData(f,[d],"float64")}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=new Float64Array(r.size),i=n[u],c=[],l=1;for(let d=o-1;d>=0;d--)c.unshift(l),l*=n[d];let m=r.size,y=c[u];for(let d=0;d<m;d++)Math.floor(d/y)%i===0?s[d]=Number(a[d]):s[d]=s[d-y]+Number(a[d]);return D.fromData(s,[...n],"float64")}function Fe(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let d=a,f=r.size;if(t===void 0){let N=D.zeros([f],e),I=N.data,z=1,F=0;for(let _=0;_<f;_++){let T=d[_*2],E=d[_*2+1],C=z*T-F*E,k=z*E+F*T;z=C,F=k,I[_*2]=z,I[_*2+1]=F}return N}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=D.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let N=o-1;N>=0;N--)A.unshift(S),S*=n[N];let x=r.size,w=A[p];for(let N=0;N<x;N++)if(Math.floor(N/w)%b===0)h[N*2]=d[N*2],h[N*2+1]=d[N*2+1];else{let z=h[(N-w)*2],F=h[(N-w)*2+1],_=d[N*2],T=d[N*2+1];h[N*2]=z*_-F*T,h[N*2+1]=z*T+F*_}return g}if(t===void 0){let d=r.size,f=new Float64Array(d),p=1;for(let g=0;g<d;g++)p*=Number(a[g]),f[g]=p;return D.fromData(f,[d],"float64")}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=new Float64Array(r.size),i=n[u],c=[],l=1;for(let d=o-1;d>=0;d--)c.unshift(l),l*=n[d];let m=r.size,y=c[u];for(let d=0;d<m;d++)Math.floor(d/y)%i===0?s[d]=Number(a[d]):s[d]=s[d-y]*Number(a[d]);return D.fromData(s,[...n],"float64")}function Me(r,t,e=!1){let n=r.dtype;if(M(n)){let m=Gr(r,t,e),y=Zr(r,t,e);if(m instanceof O&&y instanceof O)return new O(m.re-y.re,m.im-y.im);let d=m,f=y,p=d.data,g=f.data,h=new Float64Array(d.size*2);for(let b=0;b<d.size;b++)h[b*2]=p[b*2]-g[b*2],h[b*2+1]=p[b*2+1]-g[b*2+1];return D.fromData(h,[...d.shape],n)}let o=Gr(r,t,e),a=Zr(r,t,e);if(typeof o=="number"&&typeof a=="number")return o-a;let u=o,s=a,i=u.data,c=s.data,l=new Float64Array(u.size);for(let m=0;m<u.size;m++)l[m]=Number(i[m])-Number(c[m]);return D.fromData(l,[...u.shape],"float64")}function Be(r,t,e=!1){return Hr(r,.5,t,e)}function ve(r,t,e,n=!1){return Hr(r,t/100,e,n)}function Hr(r,t,e,n=!1){if(q(r.dtype,"quantile","Complex numbers are not orderable."),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 d=[];for(let A=0;A<r.size;A++)d.push(Number(u[A]));d.sort((A,S)=>A-S);let f=d.length,p=t*(f-1),g=Math.floor(p),h=Math.ceil(p);if(g===h)return d[g];let b=p-g;return d[g]*(1-b)+d[h]*b}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((d,f)=>f!==s);if(i.length===0)return Hr(r,t);let c=i.reduce((d,f)=>d*f,1),l=o[s],m=new Float64Array(c);for(let d=0;d<c;d++){let f=[];for(let A=0;A<l;A++){let S=$(d,s,A,o),x=U(S,o);f.push(Number(u[x]))}f.sort((A,S)=>A-S);let p=f.length,g=t*(p-1),h=Math.floor(g),b=Math.ceil(g);if(h===b)m[d]=f[h];else{let A=g-h;m[d]=f[h]*(1-A)+f[b]*A}}let y=D.fromData(m,i,"float64");if(n){let d=[...o];return d[s]=1,D.fromData(m,d,"float64")}return y}function at(r,t,e,n=!1){let o=r.dtype,a=r.shape,u=a.length,s=r.data;if(e===void 0)return Et(r,t,n);if(M(o)){let p=s,g=e.data;if(t===void 0){let N=0,I=0,z=0;for(let F=0;F<r.size;F++){let _=Number(g[F%e.size]),T=p[F*2],E=p[F*2+1];N+=T*_,I+=E*_,z+=_}return z===0?new O(NaN,NaN):new O(N/z,I/z)}let h=t;if(h<0&&(h=u+h),h<0||h>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let b=Array.from(a).filter((N,I)=>I!==h);if(b.length===0)return at(r,void 0,e);let A=b.reduce((N,I)=>N*I,1),S=a[h],x=D.zeros(b,o),w=x.data;for(let N=0;N<A;N++){let I=0,z=0,F=0;for(let _=0;_<S;_++){let T=$(N,h,_,a),E=U(T,a),C=Number(g[_%e.size]),k=p[E*2],V=p[E*2+1];I+=k*C,z+=V*C,F+=C}F===0?(w[N*2]=NaN,w[N*2+1]=NaN):(w[N*2]=I/F,w[N*2+1]=z/F)}if(n){let N=[...a];return N[h]=1,D.fromData(w,N,o)}return x}if(t===void 0){let p=0,g=0,h=e.data;for(let b=0;b<r.size;b++){let A=Number(h[b%e.size]);p+=Number(s[b])*A,g+=A}return g===0?NaN:p/g}let i=t;if(i<0&&(i=u+i),i<0||i>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let c=Array.from(a).filter((p,g)=>g!==i);if(c.length===0)return at(r,void 0,e);let l=c.reduce((p,g)=>p*g,1),m=a[i],y=e.data,d=new Float64Array(l);for(let p=0;p<l;p++){let g=0,h=0;for(let b=0;b<m;b++){let A=$(p,i,b,a),S=U(A,a),x=Number(y[b%e.size]);g+=Number(s[S])*x,h+=x}d[p]=h===0?NaN:g/h}let f=D.fromData(d,c,"float64");if(n){let p=[...a];return p[i]=1,D.fromData(d,p,"float64")}return f}function nr(r,t){return isNaN(r)||isNaN(t)}function Ot(r,t,e=!1){let n=r.dtype,o=M(n),a=r.shape,u=a.length,s=r.data;if(t===void 0){if(o){let p=s,g=0,h=0;for(let b=0;b<r.size;b++){let A=p[b*2],S=p[b*2+1];nr(A,S)||(g+=A,h+=S)}return new O(g,h)}let f=0;for(let p=0;p<r.size;p++){let g=Number(s[p]);isNaN(g)||(f+=g)}return f}let i=t;if(i<0&&(i=u+i),i<0||i>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let c=Array.from(a).filter((f,p)=>p!==i);if(c.length===0)return Ot(r);let l=c.reduce((f,p)=>f*p,1),m=a[i];if(o){let f=s,p=new Float64Array(l*2);for(let g=0;g<l;g++){let h=0,b=0;for(let A=0;A<m;A++){let S=$(g,i,A,a),x=U(S,a),w=f[x*2],N=f[x*2+1];nr(w,N)||(h+=w,b+=N)}p[g*2]=h,p[g*2+1]=b}if(e){let g=[...a];return g[i]=1,D.fromData(p,g,n)}return D.fromData(p,c,n)}let y=new Float64Array(l);for(let f=0;f<l;f++){let p=0;for(let g=0;g<m;g++){let h=$(f,i,g,a),b=U(h,a),A=Number(s[b]);isNaN(A)||(p+=A)}y[f]=p}let d=D.fromData(y,c,"float64");if(e){let f=[...a];return f[i]=1,D.fromData(y,f,"float64")}return d}function Ct(r,t,e=!1){let n=r.dtype,o=M(n),a=r.shape,u=a.length,s=r.data;if(t===void 0){if(o){let p=s,g=1,h=0;for(let b=0;b<r.size;b++){let A=p[b*2],S=p[b*2+1];if(!nr(A,S)){let x=g*A-h*S,w=g*S+h*A;g=x,h=w}}return new O(g,h)}let f=1;for(let p=0;p<r.size;p++){let g=Number(s[p]);isNaN(g)||(f*=g)}return f}let i=t;if(i<0&&(i=u+i),i<0||i>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let c=Array.from(a).filter((f,p)=>p!==i);if(c.length===0)return Ct(r);let l=c.reduce((f,p)=>f*p,1),m=a[i];if(o){let f=s,p=new Float64Array(l*2);for(let g=0;g<l;g++){let h=1,b=0;for(let A=0;A<m;A++){let S=$(g,i,A,a),x=U(S,a),w=f[x*2],N=f[x*2+1];if(!nr(w,N)){let I=h*w-b*N,z=h*N+b*w;h=I,b=z}}p[g*2]=h,p[g*2+1]=b}if(e){let g=[...a];return g[i]=1,D.fromData(p,g,n)}return D.fromData(p,c,n)}let y=new Float64Array(l);for(let f=0;f<l;f++){let p=1;for(let g=0;g<m;g++){let h=$(f,i,g,a),b=U(h,a),A=Number(s[b]);isNaN(A)||(p*=A)}y[f]=p}let d=D.fromData(y,c,"float64");if(e){let f=[...a];return f[i]=1,D.fromData(y,f,"float64")}return d}function Ut(r,t,e=!1){let n=r.dtype,o=M(n),a=r.shape,u=a.length,s=r.data;if(t===void 0){if(o){let g=s,h=0,b=0,A=0;for(let S=0;S<r.size;S++){let x=g[S*2],w=g[S*2+1];nr(x,w)||(h+=x,b+=w,A++)}return A===0?new O(NaN,NaN):new O(h/A,b/A)}let f=0,p=0;for(let g=0;g<r.size;g++){let h=Number(s[g]);isNaN(h)||(f+=h,p++)}return p===0?NaN:f/p}let i=t;if(i<0&&(i=u+i),i<0||i>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let c=Array.from(a).filter((f,p)=>p!==i);if(c.length===0)return Ut(r);let l=c.reduce((f,p)=>f*p,1),m=a[i];if(o){let f=s,p=new Float64Array(l*2);for(let g=0;g<l;g++){let h=0,b=0,A=0;for(let S=0;S<m;S++){let x=$(g,i,S,a),w=U(x,a),N=f[w*2],I=f[w*2+1];nr(N,I)||(h+=N,b+=I,A++)}A===0?(p[g*2]=NaN,p[g*2+1]=NaN):(p[g*2]=h/A,p[g*2+1]=b/A)}if(e){let g=[...a];return g[i]=1,D.fromData(p,g,n)}return D.fromData(p,c,n)}let y=new Float64Array(l);for(let f=0;f<l;f++){let p=0,g=0;for(let h=0;h<m;h++){let b=$(f,i,h,a),A=U(b,a),S=Number(s[A]);isNaN(S)||(p+=S,g++)}y[f]=g===0?NaN:p/g}let d=D.fromData(y,c,"float64");if(e){let f=[...a];return f[i]=1,D.fromData(y,f,"float64")}return d}function Yr(r,t,e=0,n=!1){let o=r.dtype,a=r.shape,u=a.length,s=r.data;if(M(o)){let f=s;if(t===void 0){let x=0,w=0,N=0;for(let _=0;_<r.size;_++){let T=f[_*2],E=f[_*2+1];nr(T,E)||(x+=T,w+=E,N++)}if(N-e<=0)return NaN;let I=x/N,z=w/N,F=0;for(let _=0;_<r.size;_++){let T=f[_*2],E=f[_*2+1];if(!nr(T,E)){let C=T-I,k=E-z;F+=C*C+k*k}}return F/(N-e)}let p=t;if(p<0&&(p=u+p),p<0||p>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let g=Array.from(a).filter((x,w)=>w!==p);if(g.length===0)return Yr(r,void 0,e);let h=g.reduce((x,w)=>x*w,1),b=a[p],A=new Float64Array(h);for(let x=0;x<h;x++){let w=0,N=0,I=0;for(let T=0;T<b;T++){let E=$(x,p,T,a),C=U(E,a),k=f[C*2],V=f[C*2+1];nr(k,V)||(w+=k,N+=V,I++)}if(I-e<=0){A[x]=NaN;continue}let z=w/I,F=N/I,_=0;for(let T=0;T<b;T++){let E=$(x,p,T,a),C=U(E,a),k=f[C*2],V=f[C*2+1];if(!nr(k,V)){let R=k-z,L=V-F;_+=R*R+L*L}}A[x]=_/(I-e)}let S=D.fromData(A,g,"float64");if(n){let x=[...a];return x[p]=1,D.fromData(A,x,"float64")}return S}if(t===void 0){let f=0,p=0;for(let b=0;b<r.size;b++){let A=Number(s[b]);isNaN(A)||(f+=A,p++)}if(p-e<=0)return NaN;let g=f/p,h=0;for(let b=0;b<r.size;b++){let A=Number(s[b]);isNaN(A)||(h+=(A-g)**2)}return h/(p-e)}let i=t;if(i<0&&(i=u+i),i<0||i>=u)throw new Error(`axis ${t} is out of bounds for array of dimension ${u}`);let c=Array.from(a).filter((f,p)=>p!==i);if(c.length===0)return Yr(r,void 0,e);let l=c.reduce((f,p)=>f*p,1),m=a[i],y=new Float64Array(l);for(let f=0;f<l;f++){let p=0,g=0;for(let A=0;A<m;A++){let S=$(f,i,A,a),x=U(S,a),w=Number(s[x]);isNaN(w)||(p+=w,g++)}if(g-e<=0){y[f]=NaN;continue}let h=p/g,b=0;for(let A=0;A<m;A++){let S=$(f,i,A,a),x=U(S,a),w=Number(s[x]);isNaN(w)||(b+=(w-h)**2)}y[f]=b/(g-e)}let d=D.fromData(y,c,"float64");if(n){let f=[...a];return f[i]=1,D.fromData(y,f,"float64")}return d}function Te(r,t,e=0,n=!1){let o=Yr(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 st(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.data;if(M(n)){let d=u;if(t===void 0){let S=1/0,x=1/0,w=!1;for(let N=0;N<r.size;N++){let I=d[N*2],z=d[N*2+1];isNaN(I)||isNaN(z)||(w?(I<S||I===S&&z<x)&&(S=I,x=z):(S=I,x=z,w=!0))}return w?new O(S,x):new O(NaN,NaN)}let f=t;if(f<0&&(f=a+f),f<0||f>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let p=Array.from(o).filter((S,x)=>x!==f);if(p.length===0)return st(r);let g=p.reduce((S,x)=>S*x,1),h=o[f],b=new Float64Array(g*2);for(let S=0;S<g;S++){let x=1/0,w=1/0,N=!1;for(let I=0;I<h;I++){let z=$(S,f,I,o),F=U(z,o),_=d[F*2],T=d[F*2+1];isNaN(_)||isNaN(T)||(N?(_<x||_===x&&T<w)&&(x=_,w=T):(x=_,w=T,N=!0))}b[S*2]=N?x:NaN,b[S*2+1]=N?w:NaN}let A=D.fromData(b,p,n);if(e){let S=[...o];return S[f]=1,D.fromData(b,S,n)}return A}if(t===void 0){let d=1/0;for(let f=0;f<r.size;f++){let p=Number(u[f]);!isNaN(p)&&p<d&&(d=p)}return d===1/0?NaN: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((d,f)=>f!==s);if(i.length===0)return st(r);let c=i.reduce((d,f)=>d*f,1),l=o[s],m=new Float64Array(c);for(let d=0;d<c;d++){let f=1/0;for(let p=0;p<l;p++){let g=$(d,s,p,o),h=U(g,o),b=Number(u[h]);!isNaN(b)&&b<f&&(f=b)}m[d]=f===1/0?NaN:f}let y=D.fromData(m,i,"float64");if(e){let d=[...o];return d[s]=1,D.fromData(m,d,"float64")}return y}function it(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,u=r.data;if(M(n)){let d=u;if(t===void 0){let S=-1/0,x=-1/0,w=!1;for(let N=0;N<r.size;N++){let I=d[N*2],z=d[N*2+1];isNaN(I)||isNaN(z)||(w?(I>S||I===S&&z>x)&&(S=I,x=z):(S=I,x=z,w=!0))}return w?new O(S,x):new O(NaN,NaN)}let f=t;if(f<0&&(f=a+f),f<0||f>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let p=Array.from(o).filter((S,x)=>x!==f);if(p.length===0)return it(r);let g=p.reduce((S,x)=>S*x,1),h=o[f],b=new Float64Array(g*2);for(let S=0;S<g;S++){let x=-1/0,w=-1/0,N=!1;for(let I=0;I<h;I++){let z=$(S,f,I,o),F=U(z,o),_=d[F*2],T=d[F*2+1];isNaN(_)||isNaN(T)||(N?(_>x||_===x&&T>w)&&(x=_,w=T):(x=_,w=T,N=!0))}b[S*2]=N?x:NaN,b[S*2+1]=N?w:NaN}let A=D.fromData(b,p,n);if(e){let S=[...o];return S[f]=1,D.fromData(b,S,n)}return A}if(t===void 0){let d=-1/0;for(let f=0;f<r.size;f++){let p=Number(u[f]);!isNaN(p)&&p>d&&(d=p)}return d===-1/0?NaN: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((d,f)=>f!==s);if(i.length===0)return it(r);let c=i.reduce((d,f)=>d*f,1),l=o[s],m=new Float64Array(c);for(let d=0;d<c;d++){let f=-1/0;for(let p=0;p<l;p++){let g=$(d,s,p,o),h=U(g,o),b=Number(u[h]);!isNaN(b)&&b>f&&(f=b)}m[d]=f===-1/0?NaN:f}let y=D.fromData(m,i,"float64");if(e){let d=[...o];return d[s]=1,D.fromData(m,d,"float64")}return y}function ut(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let m=a;if(t===void 0){let h=1/0,b=1/0,A=-1;for(let S=0;S<r.size;S++){let x=m[S*2],w=m[S*2+1];!nr(x,w)&&Or(x,w,h,b)<0&&(h=x,b=w,A=S)}return A}let y=t;if(y<0&&(y=o+y),y<0||y>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let d=Array.from(n).filter((h,b)=>b!==y);if(d.length===0)return ut(r);let f=d.reduce((h,b)=>h*b,1),p=n[y],g=new Int32Array(f);for(let h=0;h<f;h++){let b=1/0,A=1/0,S=0;for(let x=0;x<p;x++){let w=$(h,y,x,n),N=U(w,n),I=m[N*2],z=m[N*2+1];!nr(I,z)&&Or(I,z,b,A)<0&&(b=I,A=z,S=x)}g[h]=S}return D.fromData(g,d,"int32")}if(t===void 0){let m=1/0,y=-1;for(let d=0;d<r.size;d++){let f=Number(a[d]);!isNaN(f)&&f<m&&(m=f,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 ut(r);let i=s.reduce((m,y)=>m*y,1),c=n[u],l=new Int32Array(i);for(let m=0;m<i;m++){let y=1/0,d=0;for(let f=0;f<c;f++){let p=$(m,u,f,n),g=U(p,n),h=Number(a[g]);!isNaN(h)&&h<y&&(y=h,d=f)}l[m]=d}return D.fromData(l,s,"int32")}function ct(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let m=a;if(t===void 0){let h=-1/0,b=-1/0,A=-1;for(let S=0;S<r.size;S++){let x=m[S*2],w=m[S*2+1];!nr(x,w)&&Or(x,w,h,b)>0&&(h=x,b=w,A=S)}return A}let y=t;if(y<0&&(y=o+y),y<0||y>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let d=Array.from(n).filter((h,b)=>b!==y);if(d.length===0)return ct(r);let f=d.reduce((h,b)=>h*b,1),p=n[y],g=new Int32Array(f);for(let h=0;h<f;h++){let b=-1/0,A=-1/0,S=0;for(let x=0;x<p;x++){let w=$(h,y,x,n),N=U(w,n),I=m[N*2],z=m[N*2+1];!nr(I,z)&&Or(I,z,b,A)>0&&(b=I,A=z,S=x)}g[h]=S}return D.fromData(g,d,"int32")}if(t===void 0){let m=-1/0,y=-1;for(let d=0;d<r.size;d++){let f=Number(a[d]);!isNaN(f)&&f>m&&(m=f,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 ct(r);let i=s.reduce((m,y)=>m*y,1),c=n[u],l=new Int32Array(i);for(let m=0;m<i;m++){let y=-1/0,d=0;for(let f=0;f<c;f++){let p=$(m,u,f,n),g=U(p,n),h=Number(a[g]);!isNaN(h)&&h>y&&(y=h,d=f)}l[m]=d}return D.fromData(l,s,"int32")}function Ee(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let d=a,f=r.size;if(t===void 0){let N=D.zeros([f],e),I=N.data,z=0,F=0;for(let _=0;_<f;_++){let T=d[_*2],E=d[_*2+1];nr(T,E)||(z+=T,F+=E),I[_*2]=z,I[_*2+1]=F}return N}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=D.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let N=o-1;N>=0;N--)A.unshift(S),S*=n[N];let x=r.size,w=A[p];for(let N=0;N<x;N++){let I=d[N*2],z=d[N*2+1],F=Math.floor(N/w)%b,_=nr(I,z);F===0?(h[N*2]=_?0:I,h[N*2+1]=_?0:z):(h[N*2]=h[(N-w)*2]+(_?0:I),h[N*2+1]=h[(N-w)*2+1]+(_?0:z))}return g}if(t===void 0){let d=r.size,f=new Float64Array(d),p=0;for(let g=0;g<d;g++){let h=Number(a[g]);isNaN(h)||(p+=h),f[g]=p}return D.fromData(f,[d],"float64")}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=new Float64Array(r.size),i=n[u],c=[],l=1;for(let d=o-1;d>=0;d--)c.unshift(l),l*=n[d];let m=r.size,y=c[u];for(let d=0;d<m;d++){let f=Number(a[d]);Math.floor(d/y)%i===0?s[d]=isNaN(f)?0:f:s[d]=s[d-y]+(isNaN(f)?0:f)}return D.fromData(s,[...n],"float64")}function Oe(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let d=a,f=r.size;if(t===void 0){let N=D.zeros([f],e),I=N.data,z=1,F=0;for(let _=0;_<f;_++){let T=d[_*2],E=d[_*2+1];if(!nr(T,E)){let C=z*T-F*E,k=z*E+F*T;z=C,F=k}I[_*2]=z,I[_*2+1]=F}return N}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=D.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let N=o-1;N>=0;N--)A.unshift(S),S*=n[N];let x=r.size,w=A[p];for(let N=0;N<x;N++){let I=d[N*2],z=d[N*2+1],F=Math.floor(N/w)%b,_=nr(I,z);if(F===0)h[N*2]=_?1:I,h[N*2+1]=_?0:z;else{let T=h[(N-w)*2],E=h[(N-w)*2+1];_?(h[N*2]=T,h[N*2+1]=E):(h[N*2]=T*I-E*z,h[N*2+1]=T*z+E*I)}}return g}if(t===void 0){let d=r.size,f=new Float64Array(d),p=1;for(let g=0;g<d;g++){let h=Number(a[g]);isNaN(h)||(p*=h),f[g]=p}return D.fromData(f,[d],"float64")}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=new Float64Array(r.size),i=n[u],c=[],l=1;for(let d=o-1;d>=0;d--)c.unshift(l),l*=n[d];let m=r.size,y=c[u];for(let d=0;d<m;d++){let f=Number(a[d]);Math.floor(d/y)%i===0?s[d]=isNaN(f)?1:f:s[d]=s[d-y]*(isNaN(f)?1:f)}return D.fromData(s,[...n],"float64")}function $t(r,t,e=!1){q(r.dtype,"nanmedian","Complex numbers are not orderable.");let n=r.shape,o=n.length,a=r.data;if(t===void 0){let y=[];for(let p=0;p<r.size;p++){let g=Number(a[p]);isNaN(g)||y.push(g)}if(y.length===0)return NaN;y.sort((p,g)=>p-g);let d=y.length,f=Math.floor(d/2);return d%2===0?(y[f-1]+y[f])/2:y[f]}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((y,d)=>d!==u);if(s.length===0)return $t(r);let i=s.reduce((y,d)=>y*d,1),c=n[u],l=new Float64Array(i);for(let y=0;y<i;y++){let d=[];for(let g=0;g<c;g++){let h=$(y,u,g,n),b=U(h,n),A=Number(a[b]);isNaN(A)||d.push(A)}if(d.length===0){l[y]=NaN;continue}d.sort((g,h)=>g-h);let f=d.length,p=Math.floor(f/2);f%2===0?l[y]=(d[p-1]+d[p])/2:l[y]=d[p]}let m=D.fromData(l,s,"float64");if(e){let y=[...n];return y[u]=1,D.fromData(l,y,"float64")}return m}var $o=W(()=>{"use strict";X();J();Se();xr()});function ir(r,t){let e=r.size,n=r.dtype,o=t.indexOf(-1),a;if(o!==-1){let c=t.reduce((m,y,d)=>d===o?m:m*y,1),l=e/c;if(!Number.isInteger(l))throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(t)}`);a=t.map((m,y)=>y===o?l:m)}else a=t;if(a.reduce((c,l)=>c*l,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,ur(a),0)}let i=r.copy().data;return D.fromData(i,a,n,ur(a),0)}function Rt(r){let t=r.size,e=r.dtype,n=j(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=B(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 Jr(r){let t=r.size,e=r.dtype;if(r.isCContiguous){let n=r.data;return D.fromData(n,[t],e,[1],0)}return Rt(r)}function ft(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},(m,y)=>n-1-y);else{if(t.length!==n)throw new Error(`axes must have length ${n}, got ${t.length}`);let m=new Set;for(let y of t){let d=y<0?n+y:y;if(d<0||d>=n)throw new Error(`axis ${y} is out of bounds for array of dimension ${n}`);if(m.has(d))throw new Error("repeated axis in transpose");m.add(d)}s=t.map(y=>y<0?n+y:y)}let i=s.map(m=>e[m]),c=Array.from(o),l=s.map(m=>c[m]);return D.fromData(a,i,u,l,r.offset)}function Ro(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 l=0;l<n;l++)l!==s&&(i.push(e[l]),c.push(o[l]));return D.fromData(a,i,u,c,r.offset)}}function lt(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)],l=s<n?o[s]*(e[s]||1):1;return c.splice(s,0,l),D.fromData(a,i,u,c,r.offset)}function ko(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 l=Array.from(n),m=Array.from(a);return[l[i],l[c]]=[l[c],l[i]],[m[i],m[c]]=[m[c],m[i]],D.fromData(u,l,s,m,r.offset)}function Ce(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 l=c<0?n+c:c;if(l<0||l>=n)throw new Error(`source axis ${c} is out of bounds for array of dimension ${n}`);return l}),s=a.map(c=>{let l=c<0?n+c:c;if(l<0||l>=n)throw new Error(`destination axis ${c} is out of bounds for array of dimension ${n}`);return l});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 l=s[c];i.splice(l,0,u[c])}return ft(r,i)}function Rr(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 d=1;d<r.length;d++){let f=r[d];if(f.ndim!==n)throw new Error("all the input arrays must have same number of dimensions");for(let p=0;p<n;p++)if(p!==a&&f.shape[p]!==e.shape[p])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 d=1;d<r.length;d++)s+=r[d].shape[a];u[a]=s;let i=u.reduce((d,f)=>d*f,1),c=j(o);if(!c)throw new Error(`Cannot concatenate arrays with dtype ${o}`);let l=new c(i),m=ur(u),y=0;for(let d of r){let f=d.shape[a];Ap(d,l,u,m,a,y,o),y+=f}return D.fromData(l,u,o)}function Ap(r,t,e,n,o,a,u){let s=r.shape,i=s.length,c=r.size,l=u==="int64"||u==="uint64";if(o===0&&r.isCContiguous&&i>0){let d=a*n[0],f=r.data,p=r.offset,g=p+c;t.set(f.subarray(p,g),d);return}if(o===1&&i===2&&r.isCContiguous){let d=s[0],f=s[1],p=e[1],g=r.data,h=r.offset;for(let b=0;b<d;b++){let A=h+b*f,S=b*p+a;t.set(g.subarray(A,A+f),S)}return}let m=new Array(i).fill(0),y=a*n[o];for(let d=0;d<c;d++){let f=r.iget(d),p=y;for(let g=0;g<i;g++)p+=m[g]*n[g];t[p]=f;for(let g=i-1;g>=0&&(m[g]++,!(m[g]<s[g]));g--)m[g]=0}}function qo(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=>lt(s,a));return Rr(u,a)}function Vo(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?ir(e,[1,e.shape[0]]):e);return Rr(t,0)}function Ue(r){if(r.length===0)throw new Error("need at least one array to stack");return r.every(e=>e.ndim===1)?Rr(r,0):Rr(r,1)}function Po(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?ir(lt(ir(e,[1,e.shape[0]]),2),[1,e.shape[0],1]):e.ndim===2?lt(e,2):e);return Rr(t,2)}function jo(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 Lo(r,s,a)}function mt(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),l=u%i;s=[];let m=0;for(let y=0;y<i-1;y++)m+=c+(y<l?1:0),s.push(m)}else s=t;return Lo(r,s,a)}function Lo(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 l=Array.from(n);l[e]=c-i;let m=r.offset+i*r.strides[e];u.push(D.fromData(r.data,l,r.dtype,Array.from(r.strides),m))}return u}function Wo(r,t){if(r.ndim<2)throw new Error("vsplit only works on arrays of 2 or more dimensions");return mt(r,t,0)}function Go(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 mt(r,t,e)}function Zo(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 b=0;b<n;b++)s[u-n+b]=e[b];for(let b=0;b<a.length;b++)i[u-a.length+b]=a[b];let c=s.map((b,A)=>b*i[A]),l=c.reduce((b,A)=>b*A,1),m=j(o);if(!m)throw new Error(`Cannot tile array with dtype ${o}`);let y=new m(l),d=ur(c),f=r;n<u&&(f=ir(r,s));let p=o==="int64"||o==="uint64",g=f.strides,h=new Array(u).fill(0);for(let b=0;b<l;b++){let A=f.offset;for(let w=0;w<u;w++){let N=h[w]%s[w];A+=N*g[w]}let S=f.data[A],x=0;for(let w=0;w<u;w++)x+=h[w]*d[w];y[x]=S;for(let w=u-1;w>=0&&(h[w]++,!(h[w]<c[w]));w--)h[w]=0}return D.fromData(y,c,o)}function Yo(r,t,e){let n=r.shape,o=n.length,a=r.dtype,u=r.size;if(e===void 0){let b=u,A=Array.isArray(t)?t:new Array(b).fill(t);if(A.length!==b)throw new Error(`operands could not be broadcast together with shape (${b},) (${A.length},)`);let S=A.reduce((I,z)=>I+z,0),x=j(a);if(!x)throw new Error(`Cannot repeat array with dtype ${a}`);let w=new x(S),N=0;for(let I=0;I<b;I++){let z=r.iget(I),F=A[I];for(let _=0;_<F;_++)w[N++]=z}return D.fromData(w,[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 l=Array.from(n);l[s]=c.reduce((b,A)=>b+A,0);let m=l.reduce((b,A)=>b*A,1),y=j(a);if(!y)throw new Error(`Cannot repeat array with dtype ${a}`);let d=new y(m),f=ur(l),p=new Array(o).fill(0),g=a==="int64"||a==="uint64",h=[0];for(let b=0;b<i;b++)h.push(h[b]+c[b]);for(let b=0;b<u;b++){let A=r.iget(b),S=p[s],x=c[S],w=0;for(let z=0;z<o;z++)z!==s&&(w+=p[z]*f[z]);let N=f[s],I=h[S];for(let z=0;z<x;z++){let F=w+(I+z)*N;d[F]=A}for(let z=o-1;z>=0&&(p[z]++,!(p[z]<n[z]));z--)p[z]=0}return D.fromData(d,l,a)}function Ho(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},(y,d)=>d));else if(typeof t=="number"){let y=t<0?n+t:t;if(y<0||y>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);u=new Set([y])}else u=new Set(t.map(y=>{let d=y<0?n+y:y;if(d<0||d>=n)throw new Error(`axis ${y} is out of bounds for array of dimension ${n}`);return d}));let s=j(o);if(!s)throw new Error(`Cannot flip array with dtype ${o}`);let i=new s(a),c=B(o);if(n===1&&r.isCContiguous){let y=r.data,d=r.offset;for(let f=0;f<a;f++)i[f]=y[d+a-1-f];return D.fromData(i,[...e],o)}if(n===2&&r.isCContiguous){let y=e[0],d=e[1],f=r.data,p=r.offset;if(u.size===2){for(let g=0;g<a;g++)i[g]=f[p+a-1-g];return D.fromData(i,[...e],o)}if(u.size===1){if(u.has(0)){for(let g=0;g<y;g++){let h=p+(y-1-g)*d,b=g*d;for(let A=0;A<d;A++)i[b+A]=f[h+A]}return D.fromData(i,[...e],o)}else if(u.has(1)){for(let g=0;g<y;g++){let h=p+g*d,b=g*d;for(let A=0;A<d;A++)i[b+A]=f[h+d-1-A]}return D.fromData(i,[...e],o)}}}let l=new Array(n),m=new Array(n).fill(0);for(let y=0;y<a;y++){for(let p=0;p<n;p++)l[p]=u.has(p)?e[p]-1-m[p]:m[p];let d=r.offset;for(let p=0;p<n;p++)d+=l[p]*r.strides[p];let f=r.data[d];i[y]=f;for(let p=n-1;p>=0&&(m[p]++,!(m[p]<e[p]));p--)m[p]=0}return D.fromData(i,[...e],o)}function Jo(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=j(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 l=c.reduce((g,h)=>g*h,1),m=new i(l),y=ur(c),d=B(a),f=new Array(o).fill(0),p=new Array(o);for(let g=0;g<r.size;g++){for(let x=0;x<o;x++)p[x]=f[x];let h,b;t===1?(h=n[s]-1-f[s],b=f[u]):t===2?(h=n[u]-1-f[u],b=n[s]-1-f[s],p[u]=h,p[s]=b):(h=f[s],b=n[u]-1-f[u]),t!==2&&(p[u]=h,p[s]=b);let A=0;for(let x=0;x<o;x++)A+=p[x]*y[x];let S=r.iget(g);m[A]=S;for(let x=o-1;x>=0&&(f[x]++,!(f[x]<n[x]));x--)f[x]=0}return D.fromData(m,c,a)}function Xo(r,t,e){let n=r.shape,o=n.length,a=r.dtype,u=r.size;if(e===void 0){let f=Array.isArray(t)?t.reduce((A,S)=>A+S,0):t,p=Rt(r),g=j(a);if(!g)throw new Error(`Cannot roll array with dtype ${a}`);let h=new g(u),b=B(a);for(let A=0;A<u;A++){let S=((A-f)%u+u)%u,x=p.iget(S);h[A]=x}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(f=>{let p=f<0?o+f:f;if(p<0||p>=o)throw new Error(`axis ${f} is out of bounds for array of dimension ${o}`);return p}),l=j(a);if(!l)throw new Error(`Cannot roll array with dtype ${a}`);let m=new l(u),y=B(a),d=new Array(o).fill(0);for(let f=0;f<u;f++){let p=[...d];for(let b=0;b<c.length;b++){let A=c[b],S=n[A],x=s[b];p[A]=((p[A]-x)%S+S)%S}let g=r.offset;for(let b=0;b<o;b++)g+=p[b]*r.strides[b];let h=r.data[g];m[f]=h;for(let b=o-1;b>=0&&(d[b]++,!(d[b]<n[b]));b--)d[b]=0}return D.fromData(m,[...n],a)}function Qo(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):Ce(r,o,a)}function Ko(r,t){if(r.ndim<3)throw new Error("dsplit only works on arrays of 3 or more dimensions");return mt(r,t,2)}function ra(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?ir(e,[e.shape[0],1]):e);return Ue(t)}function ta(r,t){let e=r.dtype,n=t.reduce((i,c)=>i*c,1),o=r.size,a=j(e);if(!a)throw new Error(`Cannot resize array with dtype ${e}`);let u=new a(n),s=B(e);for(let i=0;i<n;i++){let c=i%o,l=r.iget(c);u[i]=l}return D.fromData(u,t,e)}function ea(r){return r.map(t=>t.ndim===0?ir(t,[1]):t)}function na(r){return r.map(t=>t.ndim===0?ir(t,[1,1]):t.ndim===1?ir(t,[1,t.shape[0]]):t)}function oa(r){return r.map(t=>t.ndim===0?ir(t,[1,1,1]):t.ndim===1?ir(t,[1,t.shape[0],1]):t.ndim===2?ir(t,[t.shape[0],t.shape[1],1]):t)}var $e=W(()=>{"use strict";X();J()});function Xr(r,t){if(r instanceof O||t instanceof O){let e=r instanceof O?r:new O(Number(r),0),n=t instanceof O?t:new O(Number(t),0);return e.mul(n)}return typeof r=="bigint"&&typeof t=="bigint"?Number(r*t):Number(r)*Number(t)}function bp(r,t,e,n,o,a,u,s,i,c,l,m,y,d){if(m===0)for(let h=0;h<n*o;h++)y[h]=0;else if(m!==1)for(let h=0;h<n*o;h++)y[h]=(y[h]??0)*m;let f=r==="row-major",p=t==="transpose",g=e==="transpose";if(f&&!p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*i+S]??0)*(c[S*l+b]??0);y[h*d+b]=(y[h*d+b]??0)+u*A}else if(f&&p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*i+h]??0)*(c[S*l+b]??0);y[h*d+b]=(y[h*d+b]??0)+u*A}else if(f&&!p&&g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*i+S]??0)*(c[b*l+S]??0);y[h*d+b]=(y[h*d+b]??0)+u*A}else if(f&&p&&g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*i+h]??0)*(c[b*l+S]??0);y[h*d+b]=(y[h*d+b]??0)+u*A}else if(!f&&!p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*i+h]??0)*(c[b*l+S]??0);y[b*d+h]=(y[b*d+h]??0)+u*A}else if(!f&&p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*i+S]??0)*(c[b*l+S]??0);y[b*d+h]=(y[b*d+h]??0)+u*A}else if(!f&&!p&&g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*i+h]??0)*(c[S*l+b]??0);y[b*d+h]=(y[b*d+h]??0)+u*A}else for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*i+S]??0)*(c[S*l+b]??0);y[b*d+h]=(y[b*d+h]??0)+u*A}}function ke(r,t){let e=r.ndim,n=t.ndim,o=M(r.dtype)||M(t.dtype);if(e===0||n===0){let a=e===0?r.get():null,u=n===0?t.get():null;if(e===0&&n===0)return Xr(a,u);if(e===0){let s=Z(r.dtype,t.dtype),i=D.zeros([...t.shape],s),c=(l,m)=>{let y=new Array(m.length),d=l;for(let f=m.length-1;f>=0;f--)y[f]=d%m[f],d=Math.floor(d/m[f]);return y};for(let l=0;l<t.size;l++){let m=c(l,t.shape),y=t.get(...m);i.set(m,Xr(a,y))}return i}else{let s=Z(r.dtype,t.dtype),i=D.zeros([...r.shape],s),c=(l,m)=>{let y=new Array(m.length),d=l;for(let f=m.length-1;f>=0;f--)y[f]=d%m[f],d=Math.floor(d/m[f]);return y};for(let l=0;l<r.size;l++){let m=c(l,r.shape),y=r.get(...m);i.set(m,Xr(y,u))}return i}}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 a=r.shape[0];if(o){let s=0,i=0;for(let c=0;c<a;c++){let l=r.get(c),m=t.get(c),y=Xr(l,m);y instanceof O?(s+=y.re,i+=y.im):s+=y}return new O(s,i)}let u=0;for(let s=0;s<a;s++){let i=r.get(s),c=t.get(s);typeof i=="bigint"&&typeof c=="bigint"?u=Number(u)+Number(i*c):u+=Number(i)*Number(c)}return u}if(e===2&&n===2)return Ar(r,t);if(e===2&&n===1){let[a,u]=r.shape,s=t.shape[0];if(u!==s)throw new Error(`dot: incompatible shapes (${a},${u}) and (${s},)`);let i=Z(r.dtype,t.dtype),c=D.zeros([a],i);if(o)for(let l=0;l<a;l++){let m=0,y=0;for(let d=0;d<u;d++){let f=r.get(l,d),p=t.get(d),g=f instanceof O?f:new O(Number(f),0),h=p instanceof O?p:new O(Number(p),0);m+=g.re*h.re-g.im*h.im,y+=g.re*h.im+g.im*h.re}c.set([l],new O(m,y))}else for(let l=0;l<a;l++){let m=0;for(let y=0;y<u;y++){let d=r.get(l,y),f=t.get(y);typeof d=="bigint"&&typeof f=="bigint"?m=Number(m)+Number(d*f):m+=Number(d)*Number(f)}c.set([l],m)}return c}if(e===1&&n===2){let a=r.shape[0],[u,s]=t.shape;if(a!==u)throw new Error(`dot: incompatible shapes (${a},) and (${u},${s})`);let i=Z(r.dtype,t.dtype),c=D.zeros([s],i);if(o)for(let l=0;l<s;l++){let m=0,y=0;for(let d=0;d<a;d++){let f=r.get(d),p=t.get(d,l),g=f instanceof O?f:new O(Number(f),0),h=p instanceof O?p:new O(Number(p),0);m+=g.re*h.re-g.im*h.im,y+=g.re*h.im+g.im*h.re}c.set([l],new O(m,y))}else for(let l=0;l<s;l++){let m=0;for(let y=0;y<a;y++){let d=r.get(y),f=t.get(y,l);typeof d=="bigint"&&typeof f=="bigint"?m=Number(m)+Number(d*f):m+=Number(d)*Number(f)}c.set([l],m)}return c}if(e>2&&n===1){let a=r.shape[e-1],u=t.shape[0];if(a!==u)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and (${u},)`);let s=[...r.shape.slice(0,-1)],i=Z(r.dtype,t.dtype),c=D.zeros(s,i),l=s.reduce((m,y)=>m*y,1);if(o)for(let m=0;m<l;m++){let y=0,d=0,f=m,p=[];for(let g=s.length-1;g>=0;g--)p[g]=f%s[g],f=Math.floor(f/s[g]);for(let g=0;g<a;g++){let h=[...p,g],b=r.get(...h),A=t.get(g),S=b instanceof O?b:new O(Number(b),0),x=A instanceof O?A:new O(Number(A),0);y+=S.re*x.re-S.im*x.im,d+=S.re*x.im+S.im*x.re}c.set(p,new O(y,d))}else for(let m=0;m<l;m++){let y=0,d=m,f=[];for(let p=s.length-1;p>=0;p--)f[p]=d%s[p],d=Math.floor(d/s[p]);for(let p=0;p<a;p++){let g=[...f,p],h=r.get(...g),b=t.get(p);typeof h=="bigint"&&typeof b=="bigint"?y=Number(y)+Number(h*b):y+=Number(h)*Number(b)}c.set(f,y)}return c}if(e===1&&n>2){let a=r.shape[0],u=1,s=t.shape[u];if(a!==s)throw new Error(`dot: incompatible shapes (${a},) and ${JSON.stringify(t.shape)}`);let i=[...t.shape.slice(0,u),...t.shape.slice(u+1)],c=Z(r.dtype,t.dtype),l=D.zeros(i,c),m=i.reduce((y,d)=>y*d,1);if(o)for(let y=0;y<m;y++){let d=y,f=[];for(let A=i.length-1;A>=0;A--)f[A]=d%i[A],d=Math.floor(d/i[A]);let p=f.slice(0,u),g=f.slice(u),h=0,b=0;for(let A=0;A<a;A++){let S=r.get(A),x=[...p,A,...g],w=t.get(...x),N=S instanceof O?S:new O(Number(S),0),I=w instanceof O?w:new O(Number(w),0);h+=N.re*I.re-N.im*I.im,b+=N.re*I.im+N.im*I.re}l.set(f,new O(h,b))}else for(let y=0;y<m;y++){let d=y,f=[];for(let b=i.length-1;b>=0;b--)f[b]=d%i[b],d=Math.floor(d/i[b]);let p=f.slice(0,u),g=f.slice(u),h=0;for(let b=0;b<a;b++){let A=r.get(b),S=[...p,b,...g],x=t.get(...S);typeof A=="bigint"&&typeof x=="bigint"?h=Number(h)+Number(A*x):h+=Number(A)*Number(x)}l.set(f,h)}return l}if(e>=2&&n>=2&&!(e===2&&n===2)){let a=r.shape[e-1],u=t.shape[n-2];if(a!==u)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and ${JSON.stringify(t.shape)}`);let s=[...r.shape.slice(0,-1),...t.shape.slice(0,-2),t.shape[n-1]],i=Z(r.dtype,t.dtype),c=D.zeros(s,i),l=r.shape.slice(0,-1).reduce((f,p)=>f*p,1),m=t.shape.slice(0,-2).reduce((f,p)=>f*p,1),y=t.shape[n-1],d=a;if(o)for(let f=0;f<l;f++)for(let p=0;p<m;p++)for(let g=0;g<y;g++){let h=0,b=0;for(let x=0;x<d;x++){let w=[],N=f;for(let C=r.shape.length-2;C>=0;C--)w.unshift(N%r.shape[C]),N=Math.floor(N/r.shape[C]);w.push(x);let I=r.get(...w),z=[],F=p;for(let C=t.shape.length-3;C>=0;C--)z.unshift(F%t.shape[C]),F=Math.floor(F/t.shape[C]);z.push(x,g);let _=t.get(...z),T=I instanceof O?I:new O(Number(I),0),E=_ instanceof O?_:new O(Number(_),0);h+=T.re*E.re-T.im*E.im,b+=T.re*E.im+T.im*E.re}let A=f*m*y+p*y+g,S=c.data;S[A*2]=h,S[A*2+1]=b}else for(let f=0;f<l;f++)for(let p=0;p<m;p++)for(let g=0;g<y;g++){let h=0;for(let A=0;A<d;A++){let S=f*d+A,x=p*d*y+A*y+g,w=r.data[S+r.offset],N=t.data[x+t.offset];typeof w=="bigint"&&typeof N=="bigint"?h=Number(h)+Number(w*N):h+=Number(w)*Number(N)}let b=f*m*y+p*y+g;c.data[b]=h}return c}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=Z(r.dtype,t.dtype);if(M(u)){let x=D.zeros([e,a],u),w=x.data,N=r.data,I=t.data;for(let z=0;z<e;z++)for(let F=0;F<a;F++){let _=0,T=0;for(let C=0;C<n;C++){let k=(z*n+C)*2,V=(C*a+F)*2,R=N[k],L=N[k+1],P=I[V],Q=I[V+1];_+=R*P-L*Q,T+=R*Q+L*P}let E=z*a+F;w[E*2]=_,w[E*2+1]=T}return x}let 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[l=0,m=0]=r.strides,[y=0,d=0]=t.strides,f=m>l,p=d>y,g=f?"transpose":"no-transpose",h=p?"transpose":"no-transpose",b,A;f?b=m:b=l,p?A=d:A=y;let S=D.zeros([e,a],"float64");return bp("row-major",g,h,e,a,n,1,i,b,c,A,0,S.data,a),S}function ua(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);if(M(r.dtype)){let a=0,u=0;for(let s=0;s<n;s++){let i=r.get(s,s);a+=i.re,u+=i.im}return new O(a,u)}let 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 sa(r,t){return ft(r,t)}function ca(r,t){let e=r.ndim,n=t.ndim,o=M(r.dtype)||M(t.dtype),a=r.shape[e-1],u=t.shape[n-1];if(a!==u)throw new Error(`inner: incompatible shapes - last dimensions ${a} and ${u} don't match`);if(e===1&&n===1)return ke(r,t);let s=[...r.shape.slice(0,-1),...t.shape.slice(0,-1)],i=Z(r.dtype,t.dtype),c=D.zeros(s,i),l=e===1?1:r.shape.slice(0,-1).reduce((d,f)=>d*f,1),m=n===1?1:t.shape.slice(0,-1).reduce((d,f)=>d*f,1),y=a;if(o)for(let d=0;d<l;d++)for(let f=0;f<m;f++){let p=0,g=0;for(let A=0;A<y;A++){let S,x;if(e===1)S=r.get(A);else{let I=[],z=d,F=r.shape.slice(0,-1);for(let _=F.length-1;_>=0;_--)I.unshift(z%F[_]),z=Math.floor(z/F[_]);I.push(A),S=r.get(...I)}if(n===1)x=t.get(A);else{let I=[],z=f,F=t.shape.slice(0,-1);for(let _=F.length-1;_>=0;_--)I.unshift(z%F[_]),z=Math.floor(z/F[_]);I.push(A),x=t.get(...I)}let w=S instanceof O?S:new O(Number(S),0),N=x instanceof O?x:new O(Number(x),0);p+=w.re*N.re-w.im*N.im,g+=w.re*N.im+w.im*N.re}if(s.length===0)return new O(p,g);let h=l===1?f:d*m+f,b=c.data;b[h*2]=p,b[h*2+1]=g}else for(let d=0;d<l;d++)for(let f=0;f<m;f++){let p=0;for(let h=0;h<y;h++){let b=e===1?h:d*y+h,A=n===1?h:f*y+h,S=r.data[b+r.offset],x=t.data[A+t.offset];typeof S=="bigint"&&typeof x=="bigint"?p=Number(p)+Number(S*x):p+=Number(S)*Number(x)}if(s.length===0)return p;let g=l===1?f:d*m+f;c.data[g]=p}return c}function qe(r,t){let e=r.ndim===1?r:Jr(r),n=t.ndim===1?t:Jr(t),o=e.size,a=n.size,u=Z(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 l=e.get(i),m=n.get(c),y=Xr(l,m);s.set([i,c],y)}return s}function la(r,t,e){let n,o;if(typeof e=="number"){let f=e;if(f<0)throw new Error("tensordot: axes must be non-negative");if(f>r.ndim||f>t.ndim)throw new Error("tensordot: axes exceeds array dimensions");n=Array.from({length:f},(p,g)=>r.ndim-f+g),o=Array.from({length:f},(p,g)=>g)}else if([n,o]=e,n.length!==o.length)throw new Error("tensordot: axes lists must have same length");for(let f=0;f<n.length;f++){let p=n[f],g=o[f];if(p<0||p>=r.ndim||g<0||g>=t.ndim)throw new Error("tensordot: axis out of bounds");if(r.shape[p]!==t.shape[g])throw new Error(`tensordot: shape mismatch on axes ${p} and ${g}: ${r.shape[p]} != ${t.shape[g]}`)}let a=[],u=[];for(let f=0;f<r.ndim;f++)n.includes(f)||a.push(f);for(let f=0;f<t.ndim;f++)o.includes(f)||u.push(f);let s=[...a.map(f=>r.shape[f]),...u.map(f=>t.shape[f])],i=Z(r.dtype,t.dtype),c=M(i),l=f=>f instanceof O?{re:f.re,im:f.im}:{re:Number(f),im:0};if(s.length===0){let f=0,p=0,g=n.map(h=>r.shape[h]).reduce((h,b)=>h*b,1);for(let h=0;h<g;h++){let b=h,A=new Array(n.length);for(let I=n.length-1;I>=0;I--){let z=n[I];A[I]=b%r.shape[z],b=Math.floor(b/r.shape[z])}let S=new Array(r.ndim),x=new Array(t.ndim);for(let I=0;I<n.length;I++)S[n[I]]=A[I];for(let I=0;I<o.length;I++)x[o[I]]=A[I];let w=r.get(...S),N=t.get(...x);if(c){let I=l(w),z=l(N);f+=I.re*z.re-I.im*z.im,p+=I.re*z.im+I.im*z.re}else typeof w=="bigint"&&typeof N=="bigint"?f+=Number(w*N):f+=Number(w)*Number(N)}return c?new O(f,p):f}let m=D.zeros(s,i),y=s.reduce((f,p)=>f*p,1),d=n.map(f=>r.shape[f]).reduce((f,p)=>f*p,1);for(let f=0;f<y;f++){let p=f,g=[];for(let x=s.length-1;x>=0;x--)g[x]=p%s[x],p=Math.floor(p/s[x]);let h=g.slice(0,a.length),b=g.slice(a.length),A=0,S=0;for(let x=0;x<d;x++){p=x;let w=[];for(let _=n.length-1;_>=0;_--){let T=n[_];w[_]=p%r.shape[T],p=Math.floor(p/r.shape[T])}let N=new Array(r.ndim),I=new Array(t.ndim);for(let _=0;_<a.length;_++)N[a[_]]=h[_];for(let _=0;_<u.length;_++)I[u[_]]=b[_];for(let _=0;_<n.length;_++)N[n[_]]=w[_],I[o[_]]=w[_];let z=r.get(...N),F=t.get(...I);if(c){let _=l(z),T=l(F);A+=_.re*T.re-_.im*T.im,S+=_.re*T.im+_.im*T.re}else typeof z=="bigint"&&typeof F=="bigint"?A+=Number(z*F):A+=Number(z)*Number(F)}c?m.set(g,new O(A,S)):m.set(g,A)}return m}function fa(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],l;t>=0?l=Math.max(0,Math.min(i,c-t)):l=Math.max(0,Math.min(i+t,c));let m=[];for(let p=0;p<a;p++)p!==u&&p!==s&&m.push(o[p]);m.push(l);let y=D.zeros(m,r.dtype),d=o.filter((p,g)=>g!==u&&g!==s),f=d.reduce((p,g)=>p*g,1);for(let p=0;p<f;p++){let g=p,h=[];for(let b=d.length-1;b>=0;b--)h.unshift(g%d[b]),g=Math.floor(g/d[b]);for(let b=0;b<l;b++){let A=new Array(a),S=0;for(let N=0;N<a;N++)N===u?A[N]=t>=0?b:b-t:N===s?A[N]=t>=0?b+t:b:A[N]=h[S++];let x=[...h,b],w=r.get(...A);y.set(x,w)}}return y}function ma(r,...t){let e=r.indexOf("->"),n,o;e===-1?(n=r,o=hp(n)):(n=r.slice(0,e),o=r.slice(e+2));let a=n.split(",").map(p=>p.trim());if(a.length!==t.length)throw new Error(`einsum: expected ${a.length} operands, got ${t.length}`);let u=new Map;for(let p=0;p<t.length;p++){let g=a[p],h=t[p];if(g.length!==h.ndim)throw new Error(`einsum: operand ${p} has ${h.ndim} dimensions but subscript '${g}' has ${g.length} indices`);for(let b=0;b<g.length;b++){let A=g[b],S=h.shape[b];if(u.has(A)){if(u.get(A)!==S)throw new Error(`einsum: size mismatch for index '${A}': ${u.get(A)} vs ${S}`)}else u.set(A,S)}}for(let p of o)if(!u.has(p))throw new Error(`einsum: output subscript contains unknown index '${p}'`);let s=new Set(o),i=new Set;for(let p of a)for(let g of p)i.add(g);let c=[];for(let p of i)s.has(p)||c.push(p);if(t.length===2&&a.length===2){let[p,g]=a,[h,b]=t;if(p.length===2&&g.length===2&&o.length===2&&h.ndim===2&&b.ndim===2){let[A,S]=[p[0],p[1]],[x,w]=[g[0],g[1]],[N,I]=[o[0],o[1]];if(A===N&&w===I&&S===x&&c.length===1&&c[0]===S||A===N&&w===I&&S===x&&c.length===1&&c[0]===S)return Ar(h,b);if(S===N&&w===I&&A===x&&c.length===1&&c[0]===A){let z=sa(h);return Ar(z,b)}if(A===N&&x===I&&S===w&&c.length===1&&c[0]===S){let z=sa(b);return Ar(h,z)}}if(p.length===1&&g.length===1&&p===g&&o.length===0&&h.ndim===1&&b.ndim===1)return Re(t,a,c,u);if(p&&g&&p.length===1&&g.length===1&&o.length===2&&o===p+g&&c.length===0&&h.ndim===1&&b.ndim===1)return qe(h,b)}if(t.length===1&&a[0].length===2&&o.length===0){let p=a[0];if(p[0]===p[1]&&t[0].ndim===2)return Re(t,a,c,u)}let l=Array.from(o).map(p=>u.get(p));if(l.length===0)return Re(t,a,c,u);let m=t[0].dtype;for(let p=1;p<t.length;p++)m=Z(m,t[p].dtype);let y=D.zeros(l,m),d=l.reduce((p,g)=>p*g,1),f=1;for(let p of c)f*=u.get(p);for(let p=0;p<d;p++){let g=Sp(p,l),h=new Map;for(let A=0;A<o.length;A++)h.set(o[A],g[A]);let b=0;for(let A=0;A<f;A++){let S=A;for(let w=c.length-1;w>=0;w--){let N=c[w],I=u.get(N);h.set(N,S%I),S=Math.floor(S/I)}let x=1;for(let w=0;w<t.length;w++){let N=t[w],I=a[w],z=[];for(let _ of I)z.push(h.get(_));let F=N.get(...z);x*=Number(F)}b+=x}y.set(g,b)}return y}function hp(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 Re(r,t,e,n){let o=!1;for(let c of r)if(M(c.dtype)){o=!0;break}let a=c=>c instanceof O?{re:c.re,im:c.im}:{re:Number(c),im:0},u=1;for(let c of e)u*=n.get(c);let s=0,i=0;for(let c=0;c<u;c++){let l=new Map,m=c;for(let f=e.length-1;f>=0;f--){let p=e[f],g=n.get(p);l.set(p,m%g),m=Math.floor(m/g)}let y=1,d=0;for(let f=0;f<r.length;f++){let p=r[f],g=t[f],h=[];for(let A of g)h.push(l.get(A));let b=p.get(...h);if(o){let A=a(b),S=y*A.re-d*A.im,x=y*A.im+d*A.re;y=S,d=x}else y*=Number(b)}s+=y,i+=d}return o?new O(s,i):s}function Sp(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 pa(r,t){let e=r.shape,n=t.shape,o=e.length,a=n.length,u=Z(r.dtype,t.dtype),s=Math.max(o,a),i=new Array(s),c=new Array(s).fill(1),l=new Array(s).fill(1);for(let f=0;f<o;f++)c[s-o+f]=e[f];for(let f=0;f<a;f++)l[s-a+f]=n[f];for(let f=0;f<s;f++)i[f]=c[f]*l[f];let m=D.zeros(i,u),y=e.reduce((f,p)=>f*p,1),d=n.reduce((f,p)=>f*p,1);for(let f=0;f<y;f++){let p=f,g=new Array(o);for(let A=o-1;A>=0;A--)g[A]=p%e[A],p=Math.floor(p/e[A]);let h=new Array(s).fill(0);for(let A=0;A<o;A++)h[s-o+A]=g[A];let b=r.get(...g);for(let A=0;A<d;A++){let S=A,x=new Array(a);for(let F=a-1;F>=0;F--)x[F]=S%n[F],S=Math.floor(S/n[F]);let w=new Array(s).fill(0);for(let F=0;F<a;F++)w[s-a+F]=x[F];let N=t.get(...x),I=new Array(s);for(let F=0;F<s;F++)I[F]=h[F]*l[F]+w[F];let z=Xr(b,N);m.set(I,z)}}return m}function ya(r,t,e=-1,n=-1,o=-1,a){a!==void 0&&(e=a,n=a,o=a);let u=(A,S)=>A<0?S+A:A,s=u(e,r.ndim),i=u(n,t.ndim);if(r.ndim===1&&t.ndim===1){let A=r.shape[0],S=t.shape[0];if(A===3&&S===3){let x=Number(r.get(0)),w=Number(r.get(1)),N=Number(r.get(2)),I=Number(t.get(0)),z=Number(t.get(1)),F=Number(t.get(2)),_=D.zeros([3],"float64");return _.set([0],w*F-N*z),_.set([1],N*I-x*F),_.set([2],x*z-w*I),_}else if(A===2&&S===2){let x=Number(r.get(0)),w=Number(r.get(1)),N=Number(t.get(0)),I=Number(t.get(1));return x*I-w*N}else if(A===2&&S===3||A===3&&S===2){let x=Number(r.get(0)),w=Number(r.get(1)),N=A===3?Number(r.get(2)):0,I=Number(t.get(0)),z=Number(t.get(1)),F=S===3?Number(t.get(2)):0,_=D.zeros([3],"float64");return _.set([0],w*F-N*z),_.set([1],N*I-x*F),_.set([2],x*z-w*I),_}else throw new Error(`cross: incompatible dimensions for cross product: ${A} and ${S}`)}let c=r.shape[s],l=t.shape[i];if(c!==2&&c!==3||l!==2&&l!==3)throw new Error(`cross: incompatible dimensions for cross product: ${c} and ${l}`);let m=c===2&&l===2?0:3,y=[...r.shape.slice(0,s),...r.shape.slice(s+1)],d=[...t.shape.slice(0,i),...t.shape.slice(i+1)];if(y.length!==d.length)throw new Error("cross: incompatible shapes for cross product");for(let A=0;A<y.length;A++)if(y[A]!==d[A])throw new Error("cross: incompatible shapes for cross product");let f=y,p=o<0?f.length+1+o:o,g;if(m===0?g=f:g=[...f.slice(0,p),m,...f.slice(p)],g.length===0)throw new Error("cross: unexpected scalar result from higher-dimensional input");let h=D.zeros(g,"float64"),b=f.reduce((A,S)=>A*S,1);for(let A=0;A<b;A++){let S=A,x=[];for(let V=f.length-1;V>=0;V--)x[V]=S%f[V],S=Math.floor(S/f[V]);let w=[...x.slice(0,s),0,...x.slice(s)],N=[...x.slice(0,i),0,...x.slice(i)],I=V=>(w[s]=V,Number(r.get(...w))),z=V=>(N[i]=V,Number(t.get(...N))),F=I(0),_=I(1),T=c===3?I(2):0,E=z(0),C=z(1),k=l===3?z(2):0;if(m===0)h.set(x,F*C-_*E);else{let V=_*k-T*C,R=T*E-F*k,L=F*C-_*E,P=(Q,er)=>{let G=[...x.slice(0,p),Q,...x.slice(p)];h.set(G,er)};P(0,V),P(1,R),P(2,L)}}return h}function Qr(r,t=2,e,n=!1){if(typeof t!="number")throw new Error("vector_norm: ord must be a number");if(e==null){let c=r.ndim===1?r:Jr(r),l=c.size,m;if(t===1/0){m=0;for(let y=0;y<l;y++)m=Math.max(m,Math.abs(Number(c.get(y))))}else if(t===-1/0){m=1/0;for(let y=0;y<l;y++)m=Math.min(m,Math.abs(Number(c.get(y))))}else if(t===0){m=0;for(let y=0;y<l;y++)Number(c.get(y))!==0&&m++}else if(t===1){m=0;for(let y=0;y<l;y++)m+=Math.abs(Number(c.get(y)))}else if(t===2){m=0;for(let y=0;y<l;y++){let d=Number(c.get(y));m+=d*d}m=Math.sqrt(m)}else{m=0;for(let y=0;y<l;y++)m+=Math.pow(Math.abs(Number(c.get(y))),t);m=Math.pow(m,1/t)}if(n){let y=new Array(r.ndim).fill(1),d=D.zeros(y,"float64");return d.set(new Array(r.ndim).fill(0),m),d}return m}let o=e<0?r.ndim+e:e;if(o<0||o>=r.ndim)throw new Error(`vector_norm: axis ${e} out of bounds for array with ${r.ndim} dimensions`);let a=n?[...r.shape.slice(0,o),1,...r.shape.slice(o+1)]:[...r.shape.slice(0,o),...r.shape.slice(o+1)];if(a.length===0)return Qr(r,t,null,!1);let u=D.zeros(a,"float64"),s=r.shape[o],i=a.reduce((c,l)=>c*l,1);for(let c=0;c<i;c++){let l=c,m=[];for(let f=a.length-1;f>=0;f--)m[f]=l%a[f],l=Math.floor(l/a[f]);let y=n?[...m.slice(0,o),0,...m.slice(o+1)]:[...m.slice(0,o),0,...m.slice(o)],d;if(t===1/0){d=0;for(let f=0;f<s;f++)y[o]=f,d=Math.max(d,Math.abs(Number(r.get(...y))))}else if(t===-1/0){d=1/0;for(let f=0;f<s;f++)y[o]=f,d=Math.min(d,Math.abs(Number(r.get(...y))))}else if(t===0){d=0;for(let f=0;f<s;f++)y[o]=f,Number(r.get(...y))!==0&&d++}else if(t===1){d=0;for(let f=0;f<s;f++)y[o]=f,d+=Math.abs(Number(r.get(...y)))}else if(t===2){d=0;for(let f=0;f<s;f++){y[o]=f;let p=Number(r.get(...y));d+=p*p}d=Math.sqrt(d)}else{d=0;for(let f=0;f<s;f++)y[o]=f,d+=Math.pow(Math.abs(Number(r.get(...y))),t);d=Math.pow(d,1/t)}u.set(m,d)}return u}function kr(r,t="fro",e=!1){if(r.ndim!==2)throw new Error(`matrix_norm: input must be 2D, got ${r.ndim}D`);let[n,o]=r.shape,a;if(t==="fro"){a=0;for(let u=0;u<n;u++)for(let s=0;s<o;s++){let i=Number(r.get(u,s));a+=i*i}a=Math.sqrt(a)}else if(t==="nuc"){let{s:u}=Cr(r);a=0;for(let s=0;s<u.size;s++)a+=Number(u.get(s))}else if(t===1){a=0;for(let u=0;u<o;u++){let s=0;for(let i=0;i<n;i++)s+=Math.abs(Number(r.get(i,u)));a=Math.max(a,s)}}else if(t===-1){a=1/0;for(let u=0;u<o;u++){let s=0;for(let i=0;i<n;i++)s+=Math.abs(Number(r.get(i,u)));a=Math.min(a,s)}}else if(t===1/0){a=0;for(let u=0;u<n;u++){let s=0;for(let i=0;i<o;i++)s+=Math.abs(Number(r.get(u,i)));a=Math.max(a,s)}}else if(t===-1/0){a=1/0;for(let u=0;u<n;u++){let s=0;for(let i=0;i<o;i++)s+=Math.abs(Number(r.get(u,i)));a=Math.min(a,s)}}else if(t===2){let{s:u}=Cr(r);a=Number(u.get(0))}else if(t===-2){let{s:u}=Cr(r);a=Number(u.get(u.size-1))}else throw new Error(`matrix_norm: invalid ord value: ${t}`);if(e){let u=D.zeros([1,1],"float64");return u.set([0,0],a),u}return a}function da(r,t=null,e=null,n=!1){if(t===null)return e===null?Qr(r,2,null,n):typeof e=="number"?Qr(r,2,e,n):kr(r,"fro",n);if(Array.isArray(e)){if(e.length!==2)throw new Error("norm: axis must be a 2-tuple for matrix norms");let o=e[0]<0?r.ndim+e[0]:e[0],a=e[1]<0?r.ndim+e[1]:e[1];if(r.ndim!==2||o!==0&&o!==1||a!==0&&a!==1||o===a)throw new Error("norm: complex axis specification not yet supported");return kr(r,t,n)}if(r.ndim===2&&e===null&&(t==="fro"||t==="nuc"))return kr(r,t,n);if(typeof t!="number"&&t!==null)throw new Error(`norm: ord '${t}' not valid for vector norm`);return Qr(r,t??2,e,n)}function Ve(r,t="reduced"){if(r.ndim!==2)throw new Error(`qr: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape,o=Math.min(e,n),a=D.zeros([e,n],"float64");for(let d=0;d<e;d++)for(let f=0;f<n;f++)a.set([d,f],Number(r.get(d,f)));let u=[],s=[];for(let d=0;d<o;d++){let f=e-d,p=[];for(let x=d;x<e;x++)p.push(Number(a.get(x,d)));let g=0;for(let x=0;x<f;x++)g+=p[x]*p[x];if(g=Math.sqrt(g),g<1e-15){u.push(p),s.push(0);continue}let h=p[0]>=0?1:-1,b=p[0]+h*g,A=[1];for(let x=1;x<f;x++)A.push(p[x]/b);let S=h*b/g;s.push(S),u.push(A);for(let x=d;x<n;x++){let w=0;for(let N=0;N<f;N++)w+=A[N]*Number(a.get(d+N,x));for(let N=0;N<f;N++)a.set([d+N,x],Number(a.get(d+N,x))-S*A[N]*w)}}if(t==="raw"){let d=D.zeros([e,n],"float64");for(let p=0;p<e;p++)for(let g=0;g<n;g++)d.set([p,g],Number(a.get(p,g)));let f=D.zeros([o],"float64");for(let p=0;p<o;p++)f.set([p],s[p]);return{h:d,tau:f}}if(t==="r"){let d=D.zeros([o,n],"float64");for(let f=0;f<o;f++)for(let p=f;p<n;p++)d.set([f,p],Number(a.get(f,p)));return d}let i=t==="complete"?e:o,c=D.zeros([e,i],"float64");for(let d=0;d<Math.min(e,i);d++)c.set([d,d],1);for(let d=o-1;d>=0;d--){let f=u[d],p=s[d],g=e-d;for(let h=d;h<i;h++){let b=0;for(let A=0;A<g;A++)b+=f[A]*Number(c.get(d+A,h));for(let A=0;A<g;A++)c.set([d+A,h],Number(c.get(d+A,h))-p*f[A]*b)}}let l=D.zeros([e,i],"float64");for(let d=0;d<e;d++)for(let f=0;f<i;f++)l.set([d,f],Number(c.get(d,f)));let m=t==="complete"?e:o,y=D.zeros([m,n],"float64");for(let d=0;d<m;d++)for(let f=0;f<n;f++)f>=d&&y.set([d,f],Number(a.get(d,f)));return{q:l,r:y}}function ga(r,t=!1){if(r.ndim!==2)throw new Error(`cholesky: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`cholesky: matrix must be square, got ${e}x${n}`);let o=e,a=D.zeros([o,o],"float64");for(let u=0;u<o;u++)for(let s=0;s<=u;s++){let i=0;if(u===s){for(let l=0;l<s;l++)i+=Number(a.get(s,l))**2;let c=Number(r.get(s,s))-i;if(c<0)throw new Error("cholesky: matrix is not positive definite");a.set([s,s],Math.sqrt(c))}else{for(let l=0;l<s;l++)i+=Number(a.get(u,l))*Number(a.get(s,l));let c=Number(a.get(s,s));if(Math.abs(c)<1e-15)throw new Error("cholesky: matrix is not positive definite");a.set([u,s],(Number(r.get(u,s))-i)/c)}}if(t){let u=D.zeros([o,o],"float64");for(let s=0;s<o;s++)for(let i=s;i<o;i++)u.set([s,i],Number(a.get(i,s)));return u}return a}function Cr(r){if(r.ndim!==2)throw new Error(`svd: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape,n=Math.min(t,e),o=D.zeros([e,e],"float64");for(let m=0;m<e;m++)for(let y=0;y<e;y++){let d=0;for(let f=0;f<t;f++)d+=Number(r.get(f,m))*Number(r.get(f,y));o.set([m,y],d)}let{values:a,vectors:u}=Pe(o),s=Array.from({length:e},(m,y)=>y);s.sort((m,y)=>a[y]-a[m]);let i=D.zeros([n],"float64");for(let m=0;m<n;m++){let y=a[s[m]];i.set([m],Math.sqrt(Math.max(0,y)))}let c=D.zeros([e,e],"float64");for(let m=0;m<e;m++)for(let y=0;y<e;y++)c.set([m,y],u[y][s[m]]);let l=D.zeros([t,t],"float64");for(let m=0;m<t;m++)for(let y=0;y<n;y++){let d=Number(i.get(y));if(d>1e-10){let f=0;for(let p=0;p<e;p++)f+=Number(r.get(m,p))*Number(c.get(y,p));l.set([m,y],f/d)}}if(t>n)for(let m=n;m<t;m++){let y=new Array(t).fill(0);y[m]=1;for(let f=0;f<m;f++){let p=0;for(let g=0;g<t;g++)p+=y[g]*Number(l.get(g,f));for(let g=0;g<t;g++)y[g]=y[g]-p*Number(l.get(g,f))}let d=0;for(let f=0;f<t;f++)d+=y[f]*y[f];if(d=Math.sqrt(d),d>1e-10)for(let f=0;f<t;f++)l.set([f,m],y[f]/d)}return{u:l,s:i,vt:c}}function Pe(r){let t=r.shape[0],e=100*t*t,n=1e-10,o=[];for(let s=0;s<t;s++){o.push([]);for(let i=0;i<t;i++)o[s].push(Number(r.get(s,i)))}let a=[];for(let s=0;s<t;s++){a.push([]);for(let i=0;i<t;i++)a[s].push(s===i?1:0)}for(let s=0;s<e;s++){let i=0,c=0,l=1;for(let A=0;A<t;A++)for(let S=A+1;S<t;S++)Math.abs(o[A][S])>i&&(i=Math.abs(o[A][S]),c=A,l=S);if(i<n)break;let m=o[c][c],y=o[l][l],d=o[c][l],f;Math.abs(m-y)<1e-15?f=Math.PI/4:f=.5*Math.atan2(2*d,y-m);let p=Math.cos(f),g=Math.sin(f),h=p*p*m+g*g*y-2*g*p*d,b=g*g*m+p*p*y+2*g*p*d;o[c][c]=h,o[l][l]=b,o[c][l]=0,o[l][c]=0;for(let A=0;A<t;A++)if(A!==c&&A!==l){let S=o[A][c],x=o[A][l];o[A][c]=p*S-g*x,o[c][A]=o[A][c],o[A][l]=g*S+p*x,o[l][A]=o[A][l]}for(let A=0;A<t;A++){let S=a[A][c],x=a[A][l];a[A][c]=p*S-g*x,a[A][l]=g*S+p*x}}let u=[];for(let s=0;s<t;s++)u.push(o[s][s]);return{values:u,vectors:a}}function Aa(r,t=!0,e=!0){let n=Cr(r);if(!e)return n.s;if(!t){let[o,a]=r.shape,u=Math.min(o,a),s=D.zeros([o,u],"float64");for(let c=0;c<o;c++)for(let l=0;l<u;l++)s.set([c,l],Number(n.u.get(c,l)));let i=D.zeros([u,a],"float64");for(let c=0;c<u;c++)for(let l=0;l<a;l++)i.set([c,l],Number(n.vt.get(c,l)));return{u:s,s:n.s,vt:i}}return n}function ba(r){if(r.ndim!==2)throw new Error(`det: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`det: matrix must be square, got ${t}x${e}`);let n=t;if(n===0)return 1;let o=r.data;if(n===1)return Number(o[0]);if(n===2)return Number(o[0])*Number(o[3])-Number(o[1])*Number(o[2]);let{lu:a,sign:u}=je(r),s=a.data,i=u;for(let c=0;c<n;c++)i*=s[c*n+c];return i}function je(r){let[t,e]=r.shape,n=t,o=e,a=D.zeros([n,o],"float64"),u=a.data,s=r.data;for(let l=0;l<n*o;l++)u[l]=Number(s[l]);let i=Array.from({length:n},(l,m)=>m),c=1;for(let l=0;l<Math.min(n,o);l++){let m=Math.abs(u[l*o+l]),y=l;for(let f=l+1;f<n;f++){let p=Math.abs(u[f*o+l]);p>m&&(m=p,y=f)}if(y!==l){for(let p=0;p<o;p++){let g=u[l*o+p];u[l*o+p]=u[y*o+p],u[y*o+p]=g}let f=i[l];i[l]=i[y],i[y]=f,c=-c}let d=u[l*o+l];if(Math.abs(d)>1e-15)for(let f=l+1;f<n;f++){let p=u[f*o+l]/d;u[f*o+l]=p;for(let g=l+1;g<o;g++)u[f*o+g]=u[f*o+g]-p*u[l*o+g]}}return{lu:a,piv:i,sign:c}}function kt(r){if(r.ndim!==2)throw new Error(`inv: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`inv: matrix must be square, got ${t}x${e}`);let n=t,{lu:o,piv:a}=je(r),u=o.data,s=D.zeros([n,n],"float64"),i=s.data;for(let c=0;c<n;c++){let l=new Float64Array(n);for(let m=0;m<n;m++){let y=a[m]===c?1:0;for(let d=0;d<m;d++)y-=u[m*n+d]*l[d];l[m]=y}for(let m=n-1;m>=0;m--){let y=l[m];for(let f=m+1;f<n;f++)y-=u[m*n+f]*i[f*n+c];let d=u[m*n+m];if(Math.abs(d)<1e-15)throw new Error("inv: singular matrix");i[m*n+c]=y/d}}return s}function ia(r,t){let[e]=r.shape,n=e,{lu:o,piv:a}=je(r),u=o.data,s=t.data,i=new Float64Array(n);for(let y=0;y<n;y++)i[y]=Number(s[a[y]]);let c=new Float64Array(n);for(let y=0;y<n;y++){let d=i[y];for(let f=0;f<y;f++)d-=u[y*n+f]*c[f];c[y]=d}let l=D.zeros([n],"float64"),m=l.data;for(let y=n-1;y>=0;y--){let d=c[y];for(let p=y+1;p<n;p++)d-=u[y*n+p]*m[p];let f=u[y*n+y];if(Math.abs(f)<1e-15)throw new Error("solve: singular matrix");m[y]=d/f}return l}function ha(r,t){if(r.ndim!==2)throw new Error(`solve: coefficient matrix must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`solve: coefficient matrix must be square, got ${e}x${n}`);let o=e;if(t.ndim===1){if(t.shape[0]!==o)throw new Error(`solve: incompatible shapes (${e},${n}) and (${t.shape[0]},)`);return ia(r,t)}if(t.ndim===2){if(t.shape[0]!==o)throw new Error(`solve: incompatible shapes (${e},${n}) and (${t.shape[0]},${t.shape[1]})`);let a=t.shape[1],u=D.zeros([o,a],"float64");for(let s=0;s<a;s++){let i=D.zeros([o],"float64");for(let l=0;l<o;l++)i.set([l],Number(t.get(l,s)));let c=ia(r,i);for(let l=0;l<o;l++)u.set([l,s],Number(c.get(l)))}return u}throw new Error(`solve: b must be 1D or 2D, got ${t.ndim}D`)}function Sa(r,t,e=null){if(r.ndim!==2)throw new Error(`lstsq: coefficient matrix must be 2D, got ${r.ndim}D`);let[n,o]=r.shape,{u:a,s:u,vt:s}=Cr(r),i=Math.min(n,o),c=e??Math.max(n,o)*Number.EPSILON,m=Number(u.get(0))*c,y=0;for(let b=0;b<i;b++)Number(u.get(b))>m&&y++;let d=t.ndim===1?ir(t,[t.size,1]):t,f=d.shape[1];if(d.shape[0]!==n)throw new Error(`lstsq: incompatible shapes (${n},${o}) and (${t.shape.join(",")})`);let p=D.zeros([o,f],"float64");for(let b=0;b<f;b++){let A=new Array(n).fill(0);for(let S=0;S<n;S++)for(let x=0;x<n;x++)A[S]+=Number(a.get(x,S))*Number(d.get(x,b));for(let S=0;S<o;S++){let x=0;for(let w=0;w<i;w++){let N=Number(u.get(w));N>m&&(x+=Number(s.get(w,S))*A[w]/N)}p.set([S,b],x)}}let g;if(n>o){g=D.zeros([f],"float64");for(let b=0;b<f;b++){let A=0;for(let S=0;S<n;S++){let x=0;for(let N=0;N<o;N++)x+=Number(r.get(S,N))*Number(p.get(N,b));let w=x-Number(d.get(S,b));A+=w*w}g.set([b],A)}}else g=D.zeros([0],"float64");return{x:t.ndim===1?ir(p,[o]):p,residuals:g,rank:y,s:u}}function xa(r,t=2){if(r.ndim!==2)throw new Error(`cond: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(t===2||t===-2){let{s}=Cr(r),i=Math.min(e,n),c=Number(s.get(0)),l=Number(s.get(i-1));return t===2?l>0?c/l:1/0:c>0?l/c:0}if(e!==n)throw new Error(`cond: matrix must be square for p=${t}`);let o=kr(r,t),a=kt(r),u=kr(a,t);return o*u}function Da(r,t){if(r.ndim===0)return Number(r.get())!==0?1:0;if(r.ndim===1){for(let u=0;u<r.size;u++)if(Number(r.get(u))!==0)return 1;return 0}if(r.ndim!==2)throw new Error(`matrix_rank: input must be at most 2D, got ${r.ndim}D`);let{s:e}=Cr(r),n=Number(e.get(0)),o=t??n*Math.max(r.shape[0],r.shape[1])*Number.EPSILON,a=0;for(let u=0;u<e.size;u++)Number(e.get(u))>o&&a++;return a}function Na(r,t){if(r.ndim!==2)throw new Error(`matrix_power: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`matrix_power: matrix must be square, got ${e}x${n}`);let o=e;if(!Number.isInteger(t))throw new Error("matrix_power: exponent must be an integer");if(t===0){let c=D.zeros([o,o],"float64");for(let l=0;l<o;l++)c.set([l,l],1);return c}let a=r,u=t;t<0&&(a=kt(r),u=-t);let s=D.zeros([o,o],"float64");for(let c=0;c<o;c++)s.set([c,c],1);let i=D.zeros([o,o],"float64");for(let c=0;c<o;c++)for(let l=0;l<o;l++)i.set([c,l],Number(a.get(c,l)));for(;u>0;)u&1&&(s=Ar(s,i)),i=Ar(i,i),u>>=1;return s}function wa(r,t=1e-15){if(r.ndim!==2)throw new Error(`pinv: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape,{u:o,s:a,vt:u}=Cr(r),s=Math.min(e,n),c=Number(a.get(0))*t,l=D.zeros([n,e],"float64");for(let m=0;m<n;m++)for(let y=0;y<e;y++){let d=0;for(let f=0;f<s;f++){let p=Number(a.get(f));p>c&&(d+=Number(u.get(f,m))*Number(o.get(y,f))/p)}l.set([m,y],d)}return l}function Le(r){if(r.ndim!==2)throw new Error(`eig: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`eig: matrix must be square, got ${t}x${e}`);let n=t,o=!0;r:for(let c=0;c<n;c++)for(let l=c+1;l<n;l++)if(Math.abs(Number(r.get(c,l))-Number(r.get(l,c)))>1e-10){o=!1;break r}if(o){let{values:c,vectors:l}=Pe(r),m=D.zeros([n],"float64"),y=D.zeros([n,n],"float64");for(let d=0;d<n;d++){m.set([d],c[d]);for(let f=0;f<n;f++)y.set([f,d],l[f][d])}return{w:m,v:y}}console.warn("numpy-ts: eig() called on non-symmetric matrix. Complex eigenvalues are not supported; results may be inaccurate. For symmetric matrices, use eigh() instead.");let{values:a,vectors:u}=xp(r),s=D.zeros([n],"float64"),i=D.zeros([n,n],"float64");for(let c=0;c<n;c++){s.set([c],a[c]);for(let l=0;l<n;l++)i.set([l,c],u[l][c])}return{w:s,v:i}}function xp(r){let t=r.shape[0],e=1e3,n=1e-10,o=D.zeros([t,t],"float64");for(let i=0;i<t;i++)for(let c=0;c<t;c++)o.set([i,c],Number(r.get(i,c)));let a=D.zeros([t,t],"float64");for(let i=0;i<t;i++)a.set([i,i],1);for(let i=0;i<e;i++){let c=0;for(let d=0;d<t;d++)for(let f=0;f<t;f++)d!==f&&(c+=Number(o.get(d,f))**2);if(Math.sqrt(c)<n*t)break;let l=Ve(o,"reduced"),m=l.q,y=l.r;o=Ar(y,m),a=Ar(a,m)}let u=[];for(let i=0;i<t;i++)u.push(Number(o.get(i,i)));let s=[];for(let i=0;i<t;i++){s.push([]);for(let c=0;c<t;c++)s[i].push(Number(a.get(i,c)))}return{values:u,vectors:s}}function We(r,t="L"){if(r.ndim!==2)throw new Error(`eigh: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`eigh: matrix must be square, got ${e}x${n}`);let o=e,a=D.zeros([o,o],"float64");for(let m=0;m<o;m++)for(let y=0;y<o;y++)t==="L"?m>=y&&(a.set([m,y],Number(r.get(m,y))),a.set([y,m],Number(r.get(m,y)))):y>=m&&(a.set([m,y],Number(r.get(m,y))),a.set([y,m],Number(r.get(m,y))));let{values:u,vectors:s}=Pe(a),i=Array.from({length:o},(m,y)=>y);i.sort((m,y)=>u[m]-u[y]);let c=D.zeros([o],"float64"),l=D.zeros([o,o],"float64");for(let m=0;m<o;m++){c.set([m],u[i[m]]);for(let y=0;y<o;y++)l.set([y,m],s[y][i[m]])}return{w:c,v:l}}function Ia(r){let{w:t}=Le(r);return t}function za(r,t="L"){let{w:e}=We(r,t);return e}var _a=W(()=>{"use strict";X();J();xr();$e()});function Fa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=Math.sqrt(i*i+c*c),m=Math.sqrt((l+i)/2),y=(c>=0?1:-1)*Math.sqrt((l-i)/2);u[s*2]=m,u[s*2+1]=y}return a}return H(r,Math.sqrt,!1)}function Ma(r,t){if(typeof t=="number")return wp(r,t);let e=M(r.dtype),n=M(t.dtype);return e||n?Np(r,t):K(r,t,Math.pow,"power")}function Np(r,t){let e=M(r.dtype),n=M(t.dtype),o=r.dtype==="complex128"||t.dtype==="complex128"||t.dtype==="float64"?"complex128":"complex64",a=Array.from(r.shape),u=r.size,s=D.zeros(a,o),i=s.data;for(let c=0;c<u;c++){let l,m;if(e){let S=r.data;l=S[c*2],m=S[c*2+1]}else l=Number(r.iget(c)),m=0;let y,d;if(n){let S=t.data;y=S[c*2],d=S[c*2+1]}else y=Number(t.iget(c)),d=0;let f=Math.sqrt(l*l+m*m),p=Math.atan2(m,l),g=Math.log(f),h=y*g-d*p,b=y*p+d*g,A=Math.exp(h);i[c*2]=A*Math.cos(b),i[c*2+1]=A*Math.sin(b)}return s}function wp(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size;if(M(e)){let m=D.zeros(n,e),y=o,d=m.data;for(let f=0;f<a;f++){let p=y[f*2],g=y[f*2+1],h=Math.sqrt(p*p+g*g),b=Math.atan2(g,p),A=Math.pow(h,t),S=b*t;d[f*2]=A*Math.cos(S),d[f*2+1]=A*Math.sin(S)}return m}let i=e!=="float32"&&e!=="float64"&&(t<0||!Number.isInteger(t))?"float64":e,c=D.zeros(n,i),l=c.data;if(B(e))if(B(i)&&Number.isInteger(t)&&t>=0){let m=o,y=l;for(let d=0;d<a;d++)y[d]=m[d]**BigInt(t)}else for(let m=0;m<a;m++)l[m]=Math.pow(Number(o[m]),t);else for(let m=0;m<a;m++)l[m]=Math.pow(Number(o[m]),t);return c}function Ba(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=Math.exp(i);u[s*2]=l*Math.cos(c),u[s*2+1]=l*Math.sin(c)}return a}return H(r,Math.exp,!1)}function va(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=Math.LN2,u=D.zeros(e,t),s=u.data;for(let i=0;i<n;i++){let c=o[i*2],l=o[i*2+1],m=Math.exp(c*a),y=l*a;s[i*2]=m*Math.cos(y),s[i*2+1]=m*Math.sin(y)}return u}return H(r,e=>Math.pow(2,e),!1)}function Ta(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=Math.exp(i);u[s*2]=l*Math.cos(c)-1,u[s*2+1]=l*Math.sin(c)}return a}return H(r,Math.expm1,!1)}function Ea(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=Math.sqrt(i*i+c*c),m=Math.atan2(c,i);u[s*2]=Math.log(l),u[s*2+1]=m}return a}return H(r,Math.log,!1)}function Oa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=1/Math.LN2,u=D.zeros(e,t),s=u.data;for(let i=0;i<n;i++){let c=o[i*2],l=o[i*2+1],m=Math.sqrt(c*c+l*l),y=Math.atan2(l,c);s[i*2]=Math.log(m)*a,s[i*2+1]=y*a}return u}return H(r,Math.log2,!1)}function Ca(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=1/Math.LN10,u=D.zeros(e,t),s=u.data;for(let i=0;i<n;i++){let c=o[i*2],l=o[i*2+1],m=Math.sqrt(c*c+l*l),y=Math.atan2(l,c);s[i*2]=Math.log(m)*a,s[i*2+1]=y*a}return u}return H(r,Math.log10,!1)}function Ua(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=1+i,m=Math.sqrt(l*l+c*c),y=Math.atan2(c,l);u[s*2]=Math.log(m),u[s*2+1]=y}return a}return H(r,Math.log1p,!1)}function $a(r,t){return q(r.dtype,"logaddexp","logaddexp is not supported for complex numbers."),typeof t!="number"&&q(t.dtype,"logaddexp","logaddexp is not supported for complex numbers."),typeof t=="number"?zp(r,t):Ip(r,t)}function Ip(r,t){let e=Er(r.shape,t.shape),n=e.reduce((c,l)=>c*l,1),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 l=(B(o),Number(r.iget(c))),m=(B(a),Number(t.iget(c))),y=Math.max(l,m),d=Math.min(l,m);i[c]=y+Math.log1p(Math.exp(d-y))}return s}function zp(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;for(let i=0;i<o;i++){let c=(B(e),Number(r.data[i])),l=Math.max(c,t),m=Math.min(c,t);s[i]=l+Math.log1p(Math.exp(m-l))}return u}function Ra(r,t){return q(r.dtype,"logaddexp2","logaddexp2 is not supported for complex numbers."),typeof t!="number"&&q(t.dtype,"logaddexp2","logaddexp2 is not supported for complex numbers."),typeof t=="number"?Fp(r,t):_p(r,t)}function _p(r,t){let e=Er(r.shape,t.shape),n=e.reduce((l,m)=>l*m,1),o=r.dtype,a=t.dtype,u=o==="float32"&&a==="float32"?"float32":"float64",s=D.zeros(e,u),i=s.data,c=Math.LOG2E;for(let l=0;l<n;l++){let m=(B(o),Number(r.iget(l))),y=(B(a),Number(t.iget(l))),d=Math.max(m,y),f=Math.min(m,y);i[l]=d+Math.log1p(Math.pow(2,f-d))*c}return s}function Fp(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,i=Math.LOG2E;for(let c=0;c<o;c++){let l=(B(e),Number(r.data[c])),m=Math.max(l,t),y=Math.min(l,t);s[c]=m+Math.log1p(Math.pow(2,y-m))*i}return u}var ka=W(()=>{"use strict";X();Mr();J()});function qa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1];u[s*2]=Math.sin(i)*Math.cosh(c),u[s*2+1]=Math.cos(i)*Math.sinh(c)}return a}return H(r,Math.sin,!1)}function Va(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1];u[s*2]=Math.cos(i)*Math.cosh(c),u[s*2+1]=-Math.sin(i)*Math.sinh(c)}return a}return H(r,Math.cos,!1)}function Pa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=Math.cos(2*i)+Math.cosh(2*c);u[s*2]=Math.sin(2*i)/l,u[s*2+1]=Math.sinh(2*c)/l}return a}return H(r,Math.tan,!1)}function ja(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=-c,m=i,y=i*i-c*c,d=2*i*c,f=1-y,p=-d,g=Math.sqrt(f*f+p*p),h=Math.sqrt((g+f)/2),b=(p>=0?1:-1)*Math.sqrt((g-f)/2),A=l+h,S=m+b,x=Math.sqrt(A*A+S*S),w=Math.log(x),I=Math.atan2(S,A),z=-w;Math.abs(c)<1e-15&&i>1&&(z=-z),u[s*2]=I,u[s*2+1]=z}return a}return H(r,Math.asin,!1)}function La(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=i*i-c*c,m=2*i*c,y=1-l,d=-m,f=Math.sqrt(y*y+d*d),p=Math.sqrt((f+y)/2),h=-((d>=0?1:-1)*Math.sqrt((f-y)/2)),b=p,A=i+h,S=c+b,x=Math.sqrt(A*A+S*S),w=Math.log(x),I=Math.atan2(S,A),z=-w;Math.abs(c)<1e-15&&i>1&&(z=-z),u[s*2]=I,u[s*2+1]=z}return a}return H(r,Math.acos,!1)}function Wa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],l=-o[s*2+1],m=i,y=1-l,d=-m,f=1+l,p=m,g=f*f+p*p,h=(y*f+d*p)/g,b=(d*f-y*p)/g,A=Math.sqrt(h*h+b*b),S=Math.log(A),x=Math.atan2(b,h);u[s*2]=-x/2,u[s*2+1]=S/2}return a}return H(r,Math.atan,!1)}function Ga(r,t){return q(r.dtype,"arctan2","arctan2 is only defined for real numbers."),typeof t!="number"&&q(t.dtype,"arctan2","arctan2 is only defined for real numbers."),typeof t=="number"?vp(r,t):Bp(r,t)}function Bp(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 l=(B(o),Number(r.data[c])),m=(B(a),Number(t.data[c]));i[c]=Math.atan2(l,m)}return s}function vp(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(B(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 Za(r,t){return q(r.dtype,"hypot","hypot is only defined for real numbers."),typeof t!="number"&&q(t.dtype,"hypot","hypot is only defined for real numbers."),typeof t=="number"?Ep(r,t):Tp(r,t)}function Tp(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 l=(B(o),Number(r.data[c])),m=(B(a),Number(t.data[c]));i[c]=Math.hypot(l,m)}return s}function Ep(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(B(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 Ya(r){q(r.dtype,"degrees","degrees is only defined for real numbers.");let t=180/Math.PI;return H(r,e=>e*t,!1)}function Ha(r){q(r.dtype,"radians","radians is only defined for real numbers.");let t=Math.PI/180;return H(r,e=>e*t,!1)}var Ja=W(()=>{"use strict";X();Mr();J()});function Xa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1];u[s*2]=Math.sinh(i)*Math.cos(c),u[s*2+1]=Math.cosh(i)*Math.sin(c)}return a}return H(r,Math.sinh,!1)}function Qa(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1];u[s*2]=Math.cosh(i)*Math.cos(c),u[s*2+1]=Math.sinh(i)*Math.sin(c)}return a}return H(r,Math.cosh,!1)}function Ka(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=Math.cosh(2*i)+Math.cos(2*c);u[s*2]=Math.sinh(2*i)/l,u[s*2+1]=Math.sin(2*c)/l}return a}return H(r,Math.tanh,!1)}function rs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=i*i-c*c,m=2*i*c,y=l+1,d=m,f=Math.sqrt(y*y+d*d),p=Math.sqrt((f+y)/2),g=(d>=0?1:-1)*Math.sqrt((f-y)/2),h=i+p,b=c+g,A=Math.sqrt(h*h+b*b);u[s*2]=Math.log(A),u[s*2+1]=Math.atan2(b,h)}return a}return H(r,Math.asinh,!1)}function ts(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=i*i-c*c,m=2*i*c,y=l-1,d=m,f=Math.sqrt(y*y+d*d),p=Math.sqrt((f+y)/2),g=(d>=0?1:-1)*Math.sqrt((f-y)/2),h=i+p,b=c+g,A=Math.sqrt(h*h+b*b),S=Math.log(A),x=Math.atan2(b,h);Math.abs(c)<1e-15&&i<1&&(x=-x),u[s*2]=S,u[s*2+1]=x}return a}return H(r,Math.acosh,!1)}function es(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=D.zeros(e,t),u=a.data;for(let s=0;s<n;s++){let i=o[s*2],c=o[s*2+1],l=1+i,m=c,y=1-i,d=-c,f=y*y+d*d,p=(l*y+m*d)/f,g=(m*y-l*d)/f,h=Math.sqrt(p*p+g*g),b=Math.log(h),A=Math.atan2(g,p);u[s*2]=b/2,u[s*2+1]=A/2}return a}return H(r,Math.atanh,!1)}var ns=W(()=>{"use strict";X();Mr();J()});function qt(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=gr([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 pr(r,t)}function os(r){if(r.length===0)return[];if(r.length===1)return[r[0]];let t=r.map(n=>Array.from(n.shape)),e=gr(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=>pr(n,e))}function as(r,t,e){let n=r.shape,o=n.length,a=r.dtype;if(e===void 0){let f=r.size;for(let b of t){let A=b<0?f+b:b;if(A<0||A>=f)throw new Error(`index ${b} is out of bounds for axis 0 with size ${f}`)}let p=t.length,g=j(a);if(!g)throw new Error(`Cannot take from array with dtype ${a}`);let h=new g(p);for(let b=0;b<p;b++){let A=t[b];A<0&&(A=f+A);let S=r.iget(A);B(a),h[b]=S}return D.fromData(h,[p],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 f of t){let p=f<0?s+f:f;if(p<0||p>=s)throw new Error(`index ${f} is out of bounds for axis ${u} with size ${s}`)}let i=Array.from(n);i[u]=t.length;let c=i.reduce((f,p)=>f*p,1),l=j(a);if(!l)throw new Error(`Cannot take from array with dtype ${a}`);let m=new l(c),y=ur(i),d=new Array(o).fill(0);for(let f=0;f<c;f++){let p=[...d],g=d[u],h=t[g];h<0&&(h=s+h),p[u]=h;let b=r.get(...p),A=0;for(let S=0;S<o;S++)A+=d[S]*y[S];B(a),m[A]=b;for(let S=o-1;S>=0&&(d[S]++,!(d[S]<i[S]));S--)d[S]=0}return D.fromData(m,i,a)}function ss(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++){let s=e.iget(u);a.push(s instanceof O?s.re:s)}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];B(o)?typeof i!="bigint"&&(i=BigInt(Math.round(Number(i)))):typeof i=="bigint"&&(i=Number(i)),r.iset(s,i)}}function is(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(y=>Array.from(y.shape));a.unshift(Array.from(e));let u=gr(a);if(u===null)throw new Error("operands could not be broadcast together");let s=pr(r,u),i=t.map(y=>pr(y,u)),c=u.reduce((y,d)=>y*d,1),l=j(o);if(!l)throw new Error(`Cannot choose with dtype ${o}`);let m=new l(c);for(let y=0;y<c;y++){let d=Number(s.iget(y));if(d<0||d>=n)throw new Error(`index ${d} is out of bounds for axis 0 with size ${n}`);let f=i[d].iget(y);B(o),m[y]=f}return D.fromData(m,u,o)}function us(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 cs(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 p=0;p<o;p++)if(p!==u&&s[p]!==n[p]&&s[p]!==1&&n[p]!==1)throw new Error(`index ${s[p]} is out of bounds for size ${n[p]} in dimension ${p}`);let i=Array.from(s),c=i.reduce((p,g)=>p*g,1),l=j(a);if(!l)throw new Error(`Cannot take_along_axis with dtype ${a}`);let m=new l(c),y=ur(n),d=ur(s),f=n[u];for(let p=0;p<c;p++){let g=new Array(o),h=p;for(let N=o-1;N>=0;N--)g[N]=h%i[N],h=Math.floor(h/i[N]);let b=0;for(let N=0;N<o;N++){let I=s[N]===1?0:g[N];b+=I*d[N]}let A=Number(t.iget(b));if(A<0&&(A=f+A),A<0||A>=f)throw new Error(`index ${A} is out of bounds for axis ${u} with size ${f}`);let S=[...g];S[u]=A;let x=0;for(let N=0;N<o;N++){let I=n[N]===1?0:S[N];x+=I*y[N]}let w=r.iget(x);B(a),m[p]=w}return D.fromData(m,i,a)}function ls(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 l=o[s],m=ur(o),y=ur(i),d=ur(c),f=i.reduce((p,g)=>p*g,1);for(let p=0;p<f;p++){let g=new Array(a),h=p;for(let I=a-1;I>=0;I--)g[I]=h%i[I],h=Math.floor(h/i[I]);let b=0;for(let I=0;I<a;I++)b+=g[I]*y[I];let A=Number(t.iget(b));if(A<0&&(A=l+A),A<0||A>=l)throw new Error(`index ${A} is out of bounds for axis ${s} with size ${l}`);let S=0;for(let I=0;I<a;I++){let z=c[I]===1?0:g[I];S+=z*d[I]}let x=e.iget(S),w=[...g];w[s]=A;let N=0;for(let I=0;I<a;I++)N+=w[I]*m[I];B(u)?typeof x!="bigint"&&(x=BigInt(Math.round(Number(x)))):typeof x=="bigint"&&(x=Number(x)),r.iset(N,x)}}function fs(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++){let i=e.iget(s);a.push(i instanceof O?i.re:i)}}let u=0;for(let s=0;s<n;s++)if(t.iget(s)){let c=a[u%a.length];B(o)?typeof c!="bigint"&&(c=BigInt(Math.round(Number(c)))):typeof c=="bigint"&&(c=Number(c)),r.iset(s,c),u++}}function Ge(r,t,e){let n=t.shape,o=n.length,a=t.dtype,u=t.data,s=B(a);if(e===void 0){let b=0,A=Math.min(r.size,t.size);for(let N=0;N<A;N++)r.iget(N)&&b++;let S=j(a);if(!S)throw new Error(`Cannot compress with dtype ${a}`);let x=new S(b),w=0;for(let N=0;N<A;N++)r.iget(N)&&(x[w]=u[N],w++);return D.fromData(x,[b],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],l=Math.min(r.size,c),m=[];for(let b=0;b<l;b++)r.iget(b)&&m.push(b);let y=m.length,d=[...n];d[i]=y;let f=d.reduce((b,A)=>b*A,1),p=j(a);if(!p)throw new Error(`Cannot compress with dtype ${a}`);let g=new p(f),h=ur(n);if(i===0){let b=h[0],A=n.slice(1).reduce((x,w)=>x*w,1),S=0;for(let x=0;x<y;x++){let N=m[x]*b;if(s){let I=u,z=g;for(let F=0;F<A;F++)z[S++]=I[N+F]}else{let I=u,z=g;for(let F=0;F<A;F++)z[S++]=I[N+F]}}}else{let b=n.slice(0,i).reduce((x,w)=>x*w,1),A=n.slice(i+1).reduce((x,w)=>x*w,1),S=0;for(let x=0;x<b;x++)for(let w=0;w<y;w++){let N=m[w],I=0,z=x;for(let F=i-1;F>=0;F--){let _=z%n[F];z=Math.floor(z/n[F]),I+=_*h[F]}if(I+=N*h[i],s){let F=u,_=g;for(let T=0;T<A;T++)_[S++]=F[I+T]}else{let F=u,_=g;for(let T=0;T<A;T++)_[S++]=F[I+T]}}}return D.fromData(g,d,a)}function ms(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(y=>Array.from(y.shape)),...t.map(y=>Array.from(y.shape))],o=gr(n);if(o===null)throw new Error("condlist and choicelist arrays could not be broadcast together");let a=t[0].dtype,u=o.reduce((y,d)=>y*d,1),s=j(a);if(!s)throw new Error(`Cannot select with dtype ${a}`);let i=e;B(a)?i=typeof e=="bigint"?e:BigInt(e):i=typeof e=="bigint"?Number(e):e;let c=new s(u);for(let y=0;y<u;y++)B(a),c[y]=i;let l=r.map(y=>pr(y,o)),m=t.map(y=>pr(y,o));for(let y=0;y<u;y++)for(let d=0;d<r.length;d++)if(l[d].iget(y)){let f=m[d].iget(y);B(a),c[y]=f;break}return D.fromData(c,o,a)}function ps(r,t,e){let n=r.size,o=r.dtype,a=[];for(let s=0;s<e.size;s++){let i=e.iget(s);a.push(i instanceof O?i.re:i)}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];B(o)?typeof c!="bigint"&&(c=BigInt(Math.round(Number(c)))):typeof c=="bigint"&&(c=Number(c)),r.iset(s,c),u++}}function Ze(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 ys(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 Ze(n,e)}function Ye(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 ds(r,t=0){let e=r.shape;if(e.length!==2)throw new Error("array must be 2-D");return Ye(e[0],t,e[1])}function He(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 gs(r,t=0){let e=r.shape;if(e.length!==2)throw new Error("array must be 2-D");return He(e[0],t,e[1])}function As(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 bs(r,t="int32"){let e=r.length,n=[e,...r],o=n.reduce((i,c)=>i*c,1),a=j(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 l=0;l<s;l++){let m=new Array(e),y=l;for(let f=e-1;f>=0;f--)m[f]=y%r[f],y=Math.floor(y/r[f]);let d=m[i];t==="int64"?u[c+l]=BigInt(d):u[c+l]=d}}return D.fromData(u,n,t)}function hs(...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=j(u);if(!i)throw new Error(`Cannot create ix_ with dtype ${u}`);let c=new i(a);for(let l=0;l<a;l++){let m=o.iget(l);B(u),c[l]=m}e.push(D.fromData(c,s,u))}return e}function Ss(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 l=0;l<o;l++){let m=Number(r[l].iget(i)),y=t[l];if(e==="wrap")m=(m%y+y)%y;else if(e==="clip")m=Math.max(0,Math.min(m,y-1));else if(m<0||m>=y)throw new Error(`index ${m} is out of bounds for axis ${l} with size ${y}`);c+=m*u[l]}a[i]=c}return D.fromData(a,[n],"int32")}function xs(r,t,e="C"){let n=t.length,o,a;if(typeof r=="number")o=[r],a=[];else{o=[];for(let l=0;l<r.size;l++)o.push(Number(r.iget(l)));a=Array.from(r.shape)}let u=o.length,s=t.reduce((l,m)=>l*m,1),i=new Array(n);if(e==="C"){let l=1;for(let m=n-1;m>=0;m--)i[m]=l,l*=t[m]}else{let l=1;for(let m=0;m<n;m++)i[m]=l,l*=t[m]}let c=[];for(let l=0;l<n;l++){let m=new Int32Array(u);c.push(D.fromData(m,a.length?a:[1],"int32"))}for(let l=0;l<u;l++){let m=o[l];if(m<0||m>=s)throw new Error(`index ${m} is out of bounds for array with size ${s}`);if(e==="C")for(let y=0;y<n;y++){let d=Math.floor(m/i[y]);m=m%i[y],c[y].data[l]=d%t[y]}else for(let y=n-1;y>=0;y--){let d=Math.floor(m/i[y]);m=m%i[y],c[y].data[l]=d%t[y]}}return typeof r=="number"?c.map(l=>{let m=l.iget(0);return D.fromData(new Int32Array([Number(m)]),[],"int32")}):c}function Ds(r,t,e=!1){let n=r.shape,o=n.length;if(o<2)throw new Error("array must be at least 2-d");let a;if(o===2)a=n[1]+1;else{a=1;for(let c=1;c<o;c++){let l=1;for(let m=c;m<o;m++)l*=n[m];a+=l}}let u=r.data,s=r.size,i=Math.min(...n);if(e&&o===2&&(i=Math.max(n[0],n[1])),typeof t=="number")for(let c=0;c<i&&c*a<s;c++){let l=c*a;if(l<s)u[l]=t;else break}else{let c=t.data,l=t.size;for(let m=0;m<i&&m*a<s;m++){let y=m*a;if(y<s)u[y]=c[m%l];else break}}}var Ns=W(()=>{"use strict";X();J();Bt();xr()});function br(r,t){if(!ro(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 pt(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function zs(r,t){return br(r.dtype,"bitwise_and"),typeof t=="number"?Rp(r,t):(br(t.dtype,"bitwise_and"),pt(r,t)?$p(r,t):K(r,t,(e,n)=>e&n,"bitwise_and"))}function $p(r,t){let e=Z(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(B(e)){let i=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),y=typeof u[l]=="bigint"?u[l]:BigInt(Math.round(Number(u[l])));i[l]=m&y}else{let l=a,m=u;for(let y=0;y<o;y++)i[y]=l[y]&m[y]}}else for(let i=0;i<o;i++)s[i]=a[i]&u[i];return n}function Rp(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]&l}else for(let i=0;i<a;i++)s[i]=o[i]&t;return u}function _s(r,t){return br(r.dtype,"bitwise_or"),typeof t=="number"?qp(r,t):(br(t.dtype,"bitwise_or"),pt(r,t)?kp(r,t):K(r,t,(e,n)=>e|n,"bitwise_or"))}function kp(r,t){let e=Z(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(B(e)){let i=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),y=typeof u[l]=="bigint"?u[l]:BigInt(Math.round(Number(u[l])));i[l]=m|y}else{let l=a,m=u;for(let y=0;y<o;y++)i[y]=l[y]|m[y]}}else for(let i=0;i<o;i++)s[i]=a[i]|u[i];return n}function qp(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]|l}else for(let i=0;i<a;i++)s[i]=o[i]|t;return u}function Fs(r,t){return br(r.dtype,"bitwise_xor"),typeof t=="number"?Pp(r,t):(br(t.dtype,"bitwise_xor"),pt(r,t)?Vp(r,t):K(r,t,(e,n)=>e^n,"bitwise_xor"))}function Vp(r,t){let e=Z(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(B(e)){let i=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),y=typeof u[l]=="bigint"?u[l]:BigInt(Math.round(Number(u[l])));i[l]=m^y}else{let l=a,m=u;for(let y=0;y<o;y++)i[y]=l[y]^m[y]}}else for(let i=0;i<o;i++)s[i]=a[i]^u[i];return n}function Pp(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]^l}else for(let i=0;i<a;i++)s[i]=o[i]^t;return u}function Je(r){br(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(B(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 Ms(r){return Je(r)}function Bs(r,t){if(br(r.dtype,"left_shift"),typeof t=="number")return ws(r,t);if(br(t.dtype,"left_shift"),t.size===1||t.ndim===1&&t.shape[0]===1){let e=B(t.dtype)?Number(t.data[0]):t.data[0];return ws(r,e)}return pt(r,t)?jp(r,t):K(r,t,(e,n)=>e<<n,"left_shift")}function jp(r,t){let e=Z(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(B(e)){let i=s;for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?a[c]:BigInt(Math.round(Number(a[c]))),m=typeof u[c]=="bigint"?u[c]:BigInt(Math.round(Number(u[c])));i[c]=l<<m}}else for(let i=0;i<o;i++)s[i]=a[i]<<u[i];return n}function ws(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]<<l}else for(let i=0;i<a;i++)s[i]=o[i]<<t;return u}function vs(r,t){if(br(r.dtype,"right_shift"),typeof t=="number")return Is(r,t);if(br(t.dtype,"right_shift"),t.size===1||t.ndim===1&&t.shape[0]===1){let e=B(t.dtype)?Number(t.data[0]):t.data[0];return Is(r,e)}return pt(r,t)?Lp(r,t):K(r,t,(e,n)=>e>>n,"right_shift")}function Lp(r,t){let e=Z(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(B(e)){let i=s;for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?a[c]:BigInt(Math.round(Number(a[c]))),m=typeof u[c]=="bigint"?u[c]:BigInt(Math.round(Number(u[c])));i[c]=l>>m}}else for(let i=0;i<o;i++)s[i]=a[i]>>u[i];return n}function Is(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(B(e)){let i=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=i[m]>>l}else for(let i=0;i<a;i++)s[i]=o[i]>>t;return u}function Ts(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 b=0;b<8;b++){let A=g*8+b;if(A<a){let S=Number(r.data[A])!==0?1:0;e==="big"?h|=S<<7-b:h|=S<<b}}c[g]=h}return i}let l=n.slice(0,t),m=n.slice(t+1),y=l.reduce((g,h)=>g*h,1),d=m.reduce((g,h)=>g*h,1),f=Vt(n),p=Vt(s);for(let g=0;g<y;g++)for(let h=0;h<d;h++)for(let b=0;b<u;b++){let A=0;for(let N=0;N<8;N++){let I=b*8+N;if(I<a){let z=0,F=g;for(let E=0;E<t;E++){let C=E<t-1?l.slice(E+1).reduce((V,R)=>V*R,1):1,k=Math.floor(F/C);F%=C,z+=k*f[E]}z+=I*f[t];let _=h;for(let E=t+1;E<o;E++){let C=E<o-1?m.slice(E-t).reduce((V,R)=>V*R,1):1,k=Math.floor(_/C);_%=C,z+=k*f[E]}let T=Number(r.data[z])!==0?1:0;e==="big"?A|=T<<7-N:A|=T<<N}}let S=0,x=g;for(let N=0;N<t;N++){let I=N<t-1?l.slice(N+1).reduce((F,_)=>F*_,1):1,z=Math.floor(x/I);x%=I,S+=z*p[N]}S+=b*p[t];let w=h;for(let N=t+1;N<o;N++){let I=N<o-1?m.slice(N-t).reduce((F,_)=>F*_,1):1,z=Math.floor(w/I);w%=I,S+=z*p[N]}c[S]=A}return i}function Es(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"),l=c.data;if(a===1){for(let h=0;h<u;h++){let b=Number(r.data[h]);for(let A=0;A<8;A++){let S=h*8+A;if(S>=s)break;n==="big"?l[S]=b>>7-A&1:l[S]=b>>A&1}}return c}let m=o.slice(0,t),y=o.slice(t+1),d=m.reduce((h,b)=>h*b,1),f=y.reduce((h,b)=>h*b,1),p=Vt(o),g=Vt(i);for(let h=0;h<d;h++)for(let b=0;b<f;b++)for(let A=0;A<u;A++){let S=0,x=h;for(let I=0;I<t;I++){let z=I<t-1?m.slice(I+1).reduce((_,T)=>_*T,1):1,F=Math.floor(x/z);x%=z,S+=F*p[I]}S+=A*p[t];let w=b;for(let I=t+1;I<a;I++){let z=I<a-1?y.slice(I-t).reduce((_,T)=>_*T,1):1,F=Math.floor(w/z);w%=z,S+=F*p[I]}let N=Number(r.data[S]);for(let I=0;I<8;I++){let z=A*8+I;if(z>=s)break;let F=0;x=h;for(let _=0;_<t;_++){let T=_<t-1?m.slice(_+1).reduce((C,k)=>C*k,1):1,E=Math.floor(x/T);x%=T,F+=E*g[_]}F+=z*g[t],w=b;for(let _=t+1;_<a;_++){let T=_<a-1?y.slice(_-t).reduce((C,k)=>C*k,1):1,E=Math.floor(w/T);w%=T,F+=E*g[_]}n==="big"?l[F]=N>>7-I&1:l[F]=N>>I&1}}return c}function Vt(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 Os=W(()=>{"use strict";X();J();Mr()});function Kr(r){return r!==0&&r!==0n}function Dr(r,t){let e=r[t*2],n=r[t*2+1];return e!==0||n!==0}function dt(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function Us(r,t){return typeof t=="number"?Zp(r,t):dt(r,t)?Gp(r,t):yr(r,t,(e,n)=>Kr(e)&&Kr(n))}function Gp(r,t){let e=new Uint8Array(r.size),n=r.data,o=t.data,a=r.size,u=B(r.dtype),s=B(t.dtype),i=M(r.dtype),c=M(t.dtype);if(i||c)for(let l=0;l<a;l++){let m=i?Dr(n,l):n[l]!==0,y=c?Dr(o,l):o[l]!==0;e[l]=m&&y?1:0}else if(u||s)for(let l=0;l<a;l++){let m=u?n[l]!==0n:n[l]!==0,y=s?o[l]!==0n:o[l]!==0;e[l]=m&&y?1:0}else for(let l=0;l<a;l++)e[l]=n[l]!==0&&o[l]!==0?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Zp(r,t){let e=new Uint8Array(r.size),n=r.data,o=t!==0,a=r.size;if(M(r.dtype)){let u=n;for(let s=0;s<a;s++)e[s]=Dr(u,s)&&o?1:0}else if(B(r.dtype)){let u=n;for(let s=0;s<a;s++)e[s]=u[s]!==0n&&o?1:0}else for(let u=0;u<a;u++)e[u]=n[u]!==0&&o?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function $s(r,t){return typeof t=="number"?Hp(r,t):dt(r,t)?Yp(r,t):yr(r,t,(e,n)=>Kr(e)||Kr(n))}function Yp(r,t){let e=new Uint8Array(r.size),n=r.data,o=t.data,a=r.size,u=B(r.dtype),s=B(t.dtype),i=M(r.dtype),c=M(t.dtype);if(i||c)for(let l=0;l<a;l++){let m=i?Dr(n,l):n[l]!==0,y=c?Dr(o,l):o[l]!==0;e[l]=m||y?1:0}else if(u||s)for(let l=0;l<a;l++){let m=u?n[l]!==0n:n[l]!==0,y=s?o[l]!==0n:o[l]!==0;e[l]=m||y?1:0}else for(let l=0;l<a;l++)e[l]=n[l]!==0||o[l]!==0?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Hp(r,t){let e=new Uint8Array(r.size),n=r.data,o=t!==0,a=r.size;if(M(r.dtype)){let u=n;for(let s=0;s<a;s++)e[s]=Dr(u,s)||o?1:0}else if(B(r.dtype)){let u=n;for(let s=0;s<a;s++)e[s]=u[s]!==0n||o?1:0}else for(let u=0;u<a;u++)e[u]=n[u]!==0||o?1:0;return D.fromData(e,Array.from(r.shape),"bool")}function Rs(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++)t[a]=Dr(o,a)?0:1}else if(B(r.dtype)){let o=e;for(let a=0;a<n;a++)t[a]=o[a]===0n?1:0}else for(let o=0;o<n;o++)t[o]=e[o]===0?1:0;return D.fromData(t,Array.from(r.shape),"bool")}function ks(r,t){return typeof t=="number"?Xp(r,t):dt(r,t)?Jp(r,t):yr(r,t,(e,n)=>Kr(e)!==Kr(n))}function Jp(r,t){let e=new Uint8Array(r.size),n=r.data,o=t.data,a=r.size,u=B(r.dtype),s=B(t.dtype),i=M(r.dtype),c=M(t.dtype);if(i||c)for(let l=0;l<a;l++){let m=i?Dr(n,l):n[l]!==0,y=c?Dr(o,l):o[l]!==0;e[l]=m!==y?1:0}else if(u||s)for(let l=0;l<a;l++){let m=u?n[l]!==0n:n[l]!==0,y=s?o[l]!==0n:o[l]!==0;e[l]=m!==y?1:0}else for(let l=0;l<a;l++){let m=n[l]!==0,y=o[l]!==0;e[l]=m!==y?1:0}return D.fromData(e,Array.from(r.shape),"bool")}function Xp(r,t){let e=new Uint8Array(r.size),n=r.data,o=t!==0,a=r.size;if(M(r.dtype)){let u=n;for(let s=0;s<a;s++){let i=Dr(u,s);e[s]=i!==o?1:0}}else if(B(r.dtype)){let u=n;for(let s=0;s<a;s++){let i=u[s]!==0n;e[s]=i!==o?1:0}}else for(let u=0;u<a;u++){let s=n[u]!==0;e[u]=s!==o?1:0}return D.fromData(e,Array.from(r.shape),"bool")}function qs(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++){let u=o[a*2],s=o[a*2+1];t[a]=Number.isFinite(u)&&Number.isFinite(s)?1:0}}else if(B(r.dtype))for(let o=0;o<n;o++)t[o]=1;else for(let o=0;o<n;o++){let a=e[o];t[o]=Number.isFinite(a)?1:0}return D.fromData(t,Array.from(r.shape),"bool")}function Vs(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++){let u=o[a*2],s=o[a*2+1],i=!Number.isFinite(u)&&!Number.isNaN(u),c=!Number.isFinite(s)&&!Number.isNaN(s);t[a]=i||c?1:0}}else if(B(r.dtype))for(let o=0;o<n;o++)t[o]=0;else for(let o=0;o<n;o++){let a=e[o];t[o]=!Number.isFinite(a)&&!Number.isNaN(a)?1:0}return D.fromData(t,Array.from(r.shape),"bool")}function Ps(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++){let u=o[a*2],s=o[a*2+1];t[a]=Number.isNaN(u)||Number.isNaN(s)?1:0}}else if(B(r.dtype))for(let o=0;o<n;o++)t[o]=0;else for(let o=0;o<n;o++)t[o]=Number.isNaN(e[o])?1:0;return D.fromData(t,Array.from(r.shape),"bool")}function js(r){let t=new Uint8Array(r.size);return D.fromData(t,Array.from(r.shape),"bool")}function Ls(r,t){if(q(r.dtype,"copysign","copysign is only defined for real numbers."),typeof t!="number"&&q(t.dtype,"copysign","copysign is only defined for real numbers."),typeof t=="number")return Kp(r,t);if(dt(r,t))return Qp(r,t);let e=Er(r.shape,t.shape),n=e.reduce((i,c)=>i*c,1),o=D.zeros(e,"float64"),a=o.data,u=Pt(r,e),s=Pt(t,e);for(let i=0;i<n;i++){let c=Number(u.iget(i)),l=Number(s.iget(i));a[i]=Math.sign(l)*Math.abs(c)}return o}function Qp(r,t){let e=D.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.size,a=r.data,u=t.data,s=B(r.dtype),i=B(t.dtype);for(let c=0;c<o;c++){let l=s?Number(a[c]):a[c],m=i?Number(u[c]):u[c];n[c]=Math.sign(m)*Math.abs(l)}return e}function Kp(r,t){let e=D.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.data,a=r.size,u=Math.sign(t);if(B(r.dtype)){let s=o;for(let i=0;i<a;i++)n[i]=u*Math.abs(Number(s[i]))}else for(let s=0;s<a;s++)n[s]=u*Math.abs(o[s]);return e}function Ws(r){q(r.dtype,"signbit","signbit is only defined for real numbers.");let t=new Uint8Array(r.size),e=r.data,n=r.size;if(B(r.dtype)){let o=e;for(let a=0;a<n;a++)t[a]=o[a]<0n?1:0}else for(let o=0;o<n;o++){let a=e[o];t[o]=a<0||Object.is(a,-0)?1:0}return D.fromData(t,Array.from(r.shape),"bool")}function Gs(r,t){if(q(r.dtype,"nextafter","nextafter is only defined for real numbers."),typeof t!="number"&&q(t.dtype,"nextafter","nextafter is only defined for real numbers."),typeof t=="number")return ty(r,t);if(dt(r,t))return ry(r,t);let e=Er(r.shape,t.shape),n=e.reduce((i,c)=>i*c,1),o=D.zeros(e,"float64"),a=o.data,u=Pt(r,e),s=Pt(t,e);for(let i=0;i<n;i++){let c=Number(u.iget(i)),l=Number(s.iget(i));a[i]=yt(c,l)}return o}function ry(r,t){let e=D.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.size,a=r.data,u=t.data,s=B(r.dtype),i=B(t.dtype);for(let c=0;c<o;c++){let l=s?Number(a[c]):a[c],m=i?Number(u[c]):u[c];n[c]=yt(l,m)}return e}function ty(r,t){let e=D.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.data,a=r.size;if(B(r.dtype)){let u=o;for(let s=0;s<a;s++)n[s]=yt(Number(u[s]),t)}else for(let u=0;u<a;u++)n[u]=yt(o[u],t);return e}function yt(r,t){if(Number.isNaN(r)||Number.isNaN(t))return NaN;if(r===t)return t;if(r===0)return t>0?Number.MIN_VALUE:-Number.MIN_VALUE;let e=new ArrayBuffer(8),n=new Float64Array(e),o=new BigInt64Array(e);n[0]=r;let a=o[0];return r>0&&t>r||r<0&&t>r?a=a+1n:a=a-1n,o[0]=a,n[0]}function Zs(r){q(r.dtype,"spacing","spacing is only defined for real numbers.");let t=D.zeros(Array.from(r.shape),"float64"),e=t.data,n=r.data,o=r.size;if(B(r.dtype)){let a=n;for(let u=0;u<o;u++)e[u]=Cs(Number(a[u]))}else for(let a=0;a<o;a++)e[a]=Cs(n[a]);return t}function Cs(r){if(Number.isNaN(r))return NaN;if(!Number.isFinite(r))return NaN;if(Math.abs(r)===0)return Number.MIN_VALUE;let e=yt(r,1/0);return Math.abs(e-r)}function Pt(r,t){let e=r.shape.length,n=t.length,o=new Array(n).fill(0);for(let a=0;a<e;a++){let u=n-e+a,s=r.shape[a],i=t[u];if(s===i)o[u]=r.strides[a];else if(s===1)o[u]=0;else throw new Error("Invalid broadcast")}return D.fromData(r.data,Array.from(t),r.dtype,o,r.offset)}function Ys(r){let t=r.dtype,e=r.size,n=new Uint8Array(e);if(M(t)){let o=r.data;for(let a=0;a<e;a++)n[a]=o[a*2+1]!==0?1:0}return D.fromData(n,Array.from(r.shape),"bool")}function Hs(r){return M(r.dtype)}function Js(r){let t=r.dtype,e=r.size,n=new Uint8Array(e);if(M(t)){let o=r.data;for(let a=0;a<e;a++)n[a]=o[a*2+1]===0?1:0}else n.fill(1);return D.fromData(n,Array.from(r.shape),"bool")}function Xs(r){return!M(r.dtype)}function Qs(r){q(r.dtype,"isneginf","This operation is not supported for complex values because it would be ambiguous.");let t=new Uint8Array(r.size),e=r.data,n=r.size;if(!B(r.dtype))for(let o=0;o<n;o++){let a=e[o];t[o]=a===-1/0?1:0}return D.fromData(t,Array.from(r.shape),"bool")}function Ks(r){q(r.dtype,"isposinf","This operation is not supported for complex values because it would be ambiguous.");let t=new Uint8Array(r.size),e=r.data,n=r.size;if(!B(r.dtype))for(let o=0;o<n;o++){let a=e[o];t[o]=a===1/0?1:0}return D.fromData(t,Array.from(r.shape),"bool")}function ri(r){return r.isFContiguous}function ti(r,t=100){let e=r.dtype;if(M(e)){let n=r.data,o=r.size,u=t*(e==="complex64"?11920929e-14:2220446049250313e-31),s=!0;for(let i=0;i<o;i++){let c=n[i*2+1];if(Math.abs(c)>u){s=!1;break}}if(s){let i=e==="complex64"?"float32":"float64",c=D.zeros(Array.from(r.shape),i),l=c.data;for(let m=0;m<o;m++)l[m]=n[m*2];return c}return r.copy()}return r.copy()}function ei(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="boolean"||typeof r=="string"}function ni(r){return r==null?!1:typeof r[Symbol.iterator]=="function"}function oi(r,t){let n={b:["bool"],i:["int8","int16","int32","int64"],u:["uint8","uint16","uint32","uint64"],f:["float32","float64"]}[t];return n?n.includes(r):!1}function ai(r,t){let e=["float64","float32","int64","int32","int16","int8","uint64","uint32","uint16","uint8","bool"],n=e.indexOf(r),o=e.indexOf(t);return n<=o?r:t}var si=W(()=>{"use strict";X();J();Mr();Mr()});function ii(r){let t=r.dtype,e=Array.from(r.shape),n=r.size;if(M(t)){let o=nt(t),a=D.zeros(e,o),u=a.data,s=r.data;for(let i=0;i<n;i++)u[i]=s[i*2];return a}return r.copy()}function ui(r){let t=r.dtype,e=Array.from(r.shape),n=r.size;if(M(t)){let a=nt(t),u=D.zeros(e,a),s=u.data,i=r.data;for(let c=0;c<n;c++)s[c]=i[c*2+1];return u}let o=t==="float32"?"float32":"float64";return D.zeros(e,o)}function ci(r){let t=r.dtype,e=Array.from(r.shape),n=r.size;if(M(t)){let o=j(t),a=n*2,u=new o(a),s=r.data;for(let i=0;i<n;i++)u[i*2]=s[i*2],u[i*2+1]=-s[i*2+1];return D.fromData(u,e,t)}return r.copy()}function li(r,t=!1){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=D.zeros(n,"float64"),u=a.data;if(M(e)){let s=r.data;for(let i=0;i<o;i++){let c=s[i*2],l=s[i*2+1],m=Math.atan2(l,c);t&&(m=m*180/Math.PI),u[i]=m}}else for(let s=0;s<o;s++){let i=r.iget(s),l=(i instanceof O?i.re:Number(i))>=0?0:Math.PI;t&&(l=l*180/Math.PI),u[s]=l}return a}var fi=W(()=>{"use strict";X();J();xr()});function Nr(r,t,e){if(e){let n=r[t*2],o=r[t*2+1];return n!==0||o!==0}return!!r[t]}function gt(r,t,e,n){let o=isNaN(r)||isNaN(t),a=isNaN(e)||isNaN(n);return o&&a?0:o?1:a||r<e?-1:r>e?1:t<n?-1:t>n?1:0}function Xe(r,t=-1){let e=r.shape,n=e.length,o=r.dtype,a=r.data;if(n===0)return r.copy();let u=t;if(u<0&&(u=n+u),u<0||u>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let s=r.copy(),i=s.data,c=e[u],l=Array.from(e).filter((y,d)=>d!==u),m=l.length===0?1:l.reduce((y,d)=>y*d,1);if(M(o)){let y=a,d=i;for(let f=0;f<m;f++){let p=[];for(let g=0;g<c;g++){let h=$(f,u,g,e),b=U(h,e);p.push({re:y[b*2],im:y[b*2+1],idx:g})}p.sort((g,h)=>gt(g.re,g.im,h.re,h.im));for(let g=0;g<c;g++){let h=$(f,u,g,e),b=U(h,e);d[b*2]=p[g].re,d[b*2+1]=p[g].im}}}else if(B(o)){let y=a,d=i;for(let f=0;f<m;f++){let p=[];for(let g=0;g<c;g++){let h=$(f,u,g,e),b=U(h,e);p.push({value:y[b],idx:g})}p.sort((g,h)=>g.value<h.value?-1:g.value>h.value?1:0);for(let g=0;g<c;g++){let h=$(f,u,g,e),b=U(h,e);d[b]=p[g].value}}}else for(let y=0;y<m;y++){let d=[];for(let f=0;f<c;f++){let p=$(y,u,f,e),g=U(p,e);d.push(Number(a[g]))}d.sort((f,p)=>isNaN(f)&&isNaN(p)?0:isNaN(f)?1:isNaN(p)?-1:f-p);for(let f=0;f<c;f++){let p=$(y,u,f,e),g=U(p,e);i[g]=d[f]}}return s}function Qe(r,t=-1){let e=r.shape,n=e.length,o=r.dtype,a=r.data;if(n===0)return D.zeros([0],"int32");let u=t;if(u<0&&(u=n+u),u<0||u>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let s=D.zeros(Array.from(e),"int32"),i=s.data,c=e[u],l=Array.from(e).filter((y,d)=>d!==u),m=l.length===0?1:l.reduce((y,d)=>y*d,1);if(M(o)){let y=a;for(let d=0;d<m;d++){let f=[];for(let p=0;p<c;p++){let g=$(d,u,p,e),h=U(g,e);f.push({re:y[h*2],im:y[h*2+1],idx:p})}f.sort((p,g)=>gt(p.re,p.im,g.re,g.im));for(let p=0;p<c;p++){let g=$(d,u,p,e),h=U(g,e);i[h]=f[p].idx}}}else if(B(o)){let y=a;for(let d=0;d<m;d++){let f=[];for(let p=0;p<c;p++){let g=$(d,u,p,e),h=U(g,e);f.push({value:y[h],idx:p})}f.sort((p,g)=>p.value<g.value?-1:p.value>g.value?1:0);for(let p=0;p<c;p++){let g=$(d,u,p,e),h=U(g,e);i[h]=f[p].idx}}}else for(let y=0;y<m;y++){let d=[];for(let f=0;f<c;f++){let p=$(y,u,f,e),g=U(p,e);d.push({value:Number(a[g]),idx:f})}d.sort((f,p)=>isNaN(f.value)&&isNaN(p.value)?0:isNaN(f.value)?1:isNaN(p.value)?-1:f.value-p.value);for(let f=0;f<c;f++){let p=$(y,u,f,e),g=U(p,e);i[g]=d[f].idx}}return s}function mi(r){if(r.length===0)return D.zeros([0],"int32");let e=r[0].size;for(let u of r){if(u.ndim!==1)throw new Error("keys must be 1D arrays");if(u.size!==e)throw new Error("all keys must have the same length")}let n=[];for(let u=0;u<e;u++)n.push(u);n.sort((u,s)=>{for(let i=r.length-1;i>=0;i--){let l=r[i].data,m=Number(l[u]),y=Number(l[s]);if(!(isNaN(m)&&isNaN(y))){if(isNaN(m))return 1;if(isNaN(y)||m<y)return-1;if(m>y)return 1}}return 0});let o=D.zeros([e],"int32"),a=o.data;for(let u=0;u<e;u++)a[u]=n[u];return o}function oy(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e],u=r[o],s=r[n],i;a<=u&&u<=s||s<=u&&u<=a?i=o:u<=a&&a<=s||s<=a&&a<=u?i=e:i=n;let c=r[i];[r[i],r[n]]=[r[n],r[i]];let l=e;for(let m=e;m<n;m++){let y=r[m],d=isNaN(y),f=isNaN(c);!d&&(f||y<=c)&&([r[l],r[m]]=[r[m],r[l]],l++)}if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function ay(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e],u=r[o],s=r[n],i;a<=u&&u<=s||s<=u&&u<=a?i=o:u<=a&&a<=s||s<=a&&a<=u?i=e:i=n;let c=r[i];[r[i],r[n]]=[r[n],r[i]];let l=e;for(let m=e;m<n;m++)r[m]<=c&&([r[l],r[m]]=[r[m],r[l]],l++);if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function sy(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e].value,u=r[o].value,s=r[n].value,i;a<=u&&u<=s||s<=u&&u<=a?i=o:u<=a&&a<=s||s<=a&&a<=u?i=e:i=n;let c=r[i].value;[r[i],r[n]]=[r[n],r[i]];let l=e;for(let m=e;m<n;m++){let y=r[m].value,d=isNaN(y),f=isNaN(c);!d&&(f||y<=c)&&([r[l],r[m]]=[r[m],r[l]],l++)}if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function iy(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e].value,u=r[o].value,s=r[n].value,i;a<=u&&u<=s||s<=u&&u<=a?i=o:u<=a&&a<=s||s<=a&&a<=u?i=e:i=n;let c=r[i].value;[r[i],r[n]]=[r[n],r[i]];let l=e;for(let m=e;m<n;m++)r[m].value<=c&&([r[l],r[m]]=[r[m],r[l]],l++);if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function Ke(r,t,e=-1){let n=r.shape,o=n.length,a=r.dtype;if(o===0)return r.copy();let u=e;if(u<0&&(u=o+u),u<0||u>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let s=n[u],i=t;if(i<0&&(i=s+i),i<0||i>=s)throw new Error(`kth(=${t}) out of bounds (${s})`);let c=r.copy(),l=c.data,m=Array.from(n).filter((d,f)=>f!==u),y=m.length===0?1:m.reduce((d,f)=>d*f,1);if(B(a)){let d=l;for(let f=0;f<y;f++){let p=[];for(let g=0;g<s;g++){let h=$(f,u,g,n),b=U(h,n);p.push(d[b])}ay(p,i);for(let g=0;g<s;g++){let h=$(f,u,g,n),b=U(h,n);d[b]=p[g]}}}else for(let d=0;d<y;d++){let f=[];for(let p=0;p<s;p++){let g=$(d,u,p,n),h=U(g,n);f.push(Number(l[h]))}oy(f,i);for(let p=0;p<s;p++){let g=$(d,u,p,n),h=U(g,n);l[h]=f[p]}}return c}function rn(r,t,e=-1){let n=r.shape,o=n.length,a=r.dtype,u=r.data;if(o===0)return D.zeros([0],"int32");let s=e;if(s<0&&(s=o+s),s<0||s>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let i=n[s],c=t;if(c<0&&(c=i+c),c<0||c>=i)throw new Error(`kth(=${t}) out of bounds (${i})`);let l=D.zeros(Array.from(n),"int32"),m=l.data,y=Array.from(n).filter((f,p)=>p!==s),d=y.length===0?1:y.reduce((f,p)=>f*p,1);if(B(a)){let f=u;for(let p=0;p<d;p++){let g=[];for(let h=0;h<i;h++){let b=$(p,s,h,n),A=U(b,n);g.push({value:f[A],idx:h})}iy(g,c);for(let h=0;h<i;h++){let b=$(p,s,h,n),A=U(b,n);m[A]=g[h].idx}}}else for(let f=0;f<d;f++){let p=[];for(let g=0;g<i;g++){let h=$(f,s,g,n),b=U(h,n);p.push({value:Number(u[b]),idx:g})}sy(p,c);for(let g=0;g<i;g++){let h=$(f,s,g,n),b=U(h,n);m[b]=p[g].idx}}return l}function pi(r){let t=r.dtype,e=r.size,n=r.data;if(M(t)){let o=n,a=[];for(let i=0;i<e;i++)a.push({re:o[i*2],im:o[i*2+1]});a.sort((i,c)=>gt(i.re,i.im,c.re,c.im));let u=D.zeros([e],"complex128"),s=u.data;for(let i=0;i<e;i++)s[i*2]=a[i].re,s[i*2+1]=a[i].im;return u}else{let o=[];for(let s=0;s<e;s++)o.push(Number(n[s]));o.sort((s,i)=>isNaN(s)&&isNaN(i)?0:isNaN(s)?1:isNaN(i)?-1:s-i);let a=D.zeros([e],"complex128"),u=a.data;for(let s=0;s<e;s++)u[s*2]=o[s],u[s*2+1]=0;return a}}function jt(r){let t=r.shape,e=t.length,n=r.data,o=r.size,a=M(r.dtype),u=[];for(let m=0;m<e;m++)u.push([]);let s=[],i=1;for(let m=e-1;m>=0;m--)s.unshift(i),i*=t[m];for(let m=0;m<o;m++)if(Nr(n,m,a)){let y=m;for(let d=0;d<e;d++){let f=Math.floor(y/s[d]);y=y%s[d],u[d].push(f)}}let c=u[0]?.length??0,l=[];for(let m=0;m<e;m++){let y=D.zeros([c],"int32"),d=y.data;for(let f=0;f<c;f++)d[f]=u[m][f];l.push(y)}return l}function tn(r){let t=r.shape,e=t.length,n=r.data,o=r.size,a=M(r.dtype),u=[],s=[],i=1;for(let d=e-1;d>=0;d--)s.unshift(i),i*=t[d];for(let d=0;d<o;d++)if(Nr(n,d,a)){let f=[],p=d;for(let g=0;g<e;g++){let h=Math.floor(p/s[g]);p=p%s[g],f.push(h)}u.push(f)}let c=u.length,l=e===0?[c,1]:[c,e],m=D.zeros(l,"int32"),y=m.data;for(let d=0;d<c;d++){let f=u[d];for(let p=0;p<(e===0?1:e);p++)y[d*(e===0?1:e)+p]=f[p]??0}return m}function yi(r){let t=r.data,e=r.size,n=M(r.dtype),o=[];for(let s=0;s<e;s++)Nr(t,s,n)&&o.push(s);let a=D.zeros([o.length],"int32"),u=a.data;for(let s=0;s<o.length;s++)u[s]=o[s];return a}function di(r,t,e){if(t===void 0&&e===void 0)return jt(r);if(t===void 0||e===void 0)throw new Error("either both or neither of x and y should be given");let n=r.shape,o=t.shape,a=e.shape,u=Math.max(n.length,o.length,a.length),s=_=>{let T=Array(u).fill(1);for(let E=0;E<_.length;E++)T[u-_.length+E]=_[E];return T},i=s(n),c=s(o),l=s(a),m=[];for(let _=0;_<u;_++){let T=[i[_],c[_],l[_]],E=Math.max(...T);for(let C of T)if(C!==1&&C!==E)throw new Error("operands could not be broadcast together");m.push(E)}let y=t.dtype,d=D.zeros(m,y),f=d.data,p=r.data,g=t.data,h=e.data,b=(_,T)=>{let E=[],C=1;for(let k=_.length-1;k>=0;k--)E.unshift(C),C*=_[k];for(;E.length<T.length;)E.unshift(0);for(let k=0;k<T.length;k++)T[k]===1&&m[k]!==1&&(E[k]=0);return E},A=b(n,i),S=b(o,c),x=b(a,l),w=[],N=1;for(let _=m.length-1;_>=0;_--)w.unshift(N),N*=m[_];let I=m.reduce((_,T)=>_*T,1),z=M(r.dtype),F=M(y);for(let _=0;_<I;_++){let T=_,E=0,C=0,k=0;for(let V=0;V<u;V++){let R=Math.floor(T/w[V]);T=T%w[V],E+=R*A[V],C+=R*S[V],k+=R*x[V]}Nr(p,E,z)?F?(f[_*2]=g[C*2],f[_*2+1]=g[C*2+1]):f[_]=g[C]:F?(f[_*2]=h[k*2],f[_*2+1]=h[k*2+1]):f[_]=h[k]}return d}function en(r,t,e="left"){if(r.ndim!==1)throw new Error("storage must be 1D");let n=r.data,o=r.size,a=t.data,u=t.size,s=M(r.dtype),i=D.zeros([u],"int32"),c=i.data;if(s){let l=n,m=a;for(let y=0;y<u;y++){let d=m[y*2],f=m[y*2+1],p=0,g=o;if(e==="left")for(;p<g;){let h=Math.floor((p+g)/2),b=l[h*2],A=l[h*2+1];gt(b,A,d,f)<0?p=h+1:g=h}else for(;p<g;){let h=Math.floor((p+g)/2),b=l[h*2],A=l[h*2+1];gt(b,A,d,f)<=0?p=h+1:g=h}c[y]=p}}else for(let l=0;l<u;l++){let m=Number(a[l]),y=0,d=o;if(e==="left")for(;y<d;){let f=Math.floor((y+d)/2);Number(n[f])<m?y=f+1:d=f}else for(;y<d;){let f=Math.floor((y+d)/2);Number(n[f])<=m?y=f+1:d=f}c[l]=y}return i}function gi(r,t){let e=r.data,n=t.data,o=t.dtype,a=M(r.dtype),u=M(o),s=Math.min(r.size,t.size),i=0;for(let y=0;y<s;y++)Nr(e,y,a)&&i++;let c=D.zeros([i],o),l=c.data,m=0;if(B(o)){let y=n,d=l;for(let f=0;f<s;f++)Nr(e,f,a)&&(d[m++]=y[f])}else if(u){let y=n,d=l;for(let f=0;f<s;f++)Nr(e,f,a)&&(d[m*2]=y[f*2],d[m*2+1]=y[f*2+1],m++)}else for(let y=0;y<s;y++)Nr(e,y,a)&&(l[m++]=n[y]);return c}function nn(r,t){let e=r.shape,n=e.length,o=r.data,a=r.size,u=M(r.dtype);if(t===void 0){let d=0;for(let f=0;f<a;f++)Nr(o,f,u)&&d++;return d}let s=t;if(s<0&&(s=n+s),s<0||s>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let i=Array.from(e).filter((d,f)=>f!==s);if(i.length===0)return nn(r);let c=D.zeros(i,"int32"),l=c.data,m=e[s],y=i.reduce((d,f)=>d*f,1);for(let d=0;d<y;d++){let f=0;for(let p=0;p<m;p++){let g=$(d,s,p,e),h=U(g,e);Nr(o,h,u)&&f++}l[d]=f}return c}var Ai=W(()=>{"use strict";X();J();Se()});function bi(r){if(!isFinite(r))return r;let t=Math.floor(r),e=r-t;return Math.abs(e-.5)<1e-10?t%2===0?t:t+1:Math.round(r)}function on(r,t=0){q(r.dtype,"around","Rounding is not defined for complex numbers.");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,c=Math.pow(10,t);for(let l=0;l<a;l++){let m=Number(o[l]);i[l]=bi(m*c)/c}return s}function an(r){q(r.dtype,"ceil","Rounding is not defined for complex numbers.");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.ceil(Number(n[i]));return u}function sn(r){q(r.dtype,"fix","Rounding is not defined for complex numbers.");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.trunc(Number(n[i]));return u}function un(r){q(r.dtype,"floor","Rounding is not defined for complex numbers.");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.floor(Number(n[i]));return u}function cn(r){q(r.dtype,"rint","Rounding is not defined for complex numbers.");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]=bi(Number(n[i]));return u}function ln(r){q(r.dtype,"trunc","Rounding is not defined for complex numbers.");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.trunc(Number(n[i]));return u}var hi=W(()=>{"use strict";X();J()});function fn(r,t,e,n){let o=isNaN(r)||isNaN(t),a=isNaN(e)||isNaN(n);return o&&a?0:o?1:a||r<e?-1:r>e?1:t<n?-1:t>n?1:0}function ly(r,t,e,n){let o=isNaN(r)||isNaN(t),a=isNaN(e)||isNaN(n);return o&&a?!0:o||a?!1:r===e&&t===n}function vr(r,t=!1,e=!1,n=!1){let o=r.dtype,a=r.size,u=r.data;if(M(o)){let A=u,S=[];for(let R=0;R<a;R++)S.push({re:A[R*2],im:A[R*2+1],index:R});S.sort((R,L)=>fn(R.re,R.im,L.re,L.im));let x=[],w=[],N=new Array(a),I=[],z,F,_=0;for(let R=0;R<S.length;R++){let{re:L,im:P,index:Q}=S[R];z===void 0||!ly(L,P,z,F)?(z!==void 0&&I.push(_),x.push({re:L,im:P}),w.push(Q),_=1,z=L,F=P):_++}_>0&&I.push(_);let T=new Map,E=-1;for(let R=0;R<x.length;R++){let{re:L,im:P}=x[R];isNaN(L)||isNaN(P)?E=R:T.set(`${L},${P}`,R)}for(let R=0;R<a;R++){let L=A[R*2],P=A[R*2+1];isNaN(L)||isNaN(P)?N[R]=E:N[R]=T.get(`${L},${P}`)}let C=D.zeros([x.length],o),k=C.data;for(let R=0;R<x.length;R++)k[R*2]=x[R].re,k[R*2+1]=x[R].im;if(!t&&!e&&!n)return C;let V={values:C};if(t){let R=D.zeros([w.length],"int32"),L=R.data;for(let P=0;P<w.length;P++)L[P]=w[P];V.indices=R}if(e){let R=D.zeros([N.length],"int32"),L=R.data;for(let P=0;P<N.length;P++)L[P]=N[P];V.inverse=R}if(n){let R=D.zeros([I.length],"int32"),L=R.data;for(let P=0;P<I.length;P++)L[P]=I[P];V.counts=R}return V}let s=[];for(let A=0;A<a;A++)s.push({value:Number(u[A]),index:A});s.sort((A,S)=>isNaN(A.value)&&isNaN(S.value)?0:isNaN(A.value)?1:isNaN(S.value)?-1:A.value-S.value);let i=[],c=[],l=new Array(a),m=[],y,d=0;for(let A=0;A<s.length;A++){let{value:S,index:x}=s[A];y===void 0||isNaN(S)&&!isNaN(y)||!isNaN(S)&&isNaN(y)||!isNaN(S)&&!isNaN(y)&&S!==y?(y!==void 0&&m.push(d),i.push(S),c.push(x),d=1,y=S):d++}d>0&&m.push(d);let f=new Map,p=-1;for(let A=0;A<i.length;A++){let S=i[A];isNaN(S)?p=A:f.set(S,A)}for(let A=0;A<a;A++){let S=Number(u[A]);isNaN(S)?l[A]=p:l[A]=f.get(S)}let g=D.zeros([i.length],o),h=g.data;for(let A=0;A<i.length;A++)h[A]=i[A];if(!t&&!e&&!n)return g;let b={values:g};if(t){let A=D.zeros([c.length],"int32"),S=A.data;for(let x=0;x<c.length;x++)S[x]=c[x];b.indices=A}if(e){let A=D.zeros([l.length],"int32"),S=A.data;for(let x=0;x<l.length;x++)S[x]=l[x];b.inverse=A}if(n){let A=D.zeros([m.length],"int32"),S=A.data;for(let x=0;x<m.length;x++)S[x]=m[x];b.counts=A}return b}function wr(r,t,e){if(e){let n=Number(r[t*2]),o=Number(r[t*2+1]);return`${n},${o}`}return String(Number(r[t]))}function Si(r,t){return mn(r,t)}function xi(r,t){let e=r.dtype,n=M(e),o=vr(r),a=vr(t),u=new Set;for(let l=0;l<a.size;l++)u.add(wr(a.data,l,n));let s=[];for(let l=0;l<o.size;l++){let m=wr(o.data,l,n);u.has(m)&&s.push(l)}if(n){let l=D.zeros([s.length],e),m=l.data,y=o.data;for(let d=0;d<s.length;d++){let f=s[d];m[d*2]=y[f*2],m[d*2+1]=y[f*2+1]}return l}let i=D.zeros([s.length],e),c=i.data;for(let l=0;l<s.length;l++)c[l]=o.data[s[l]];return i}function mn(r,t){let e=Array.from(r.shape),n=r.size,o=M(r.dtype),a=new Set;for(let i=0;i<t.size;i++)a.add(wr(t.data,i,o));let u=D.zeros(e,"bool"),s=u.data;for(let i=0;i<n;i++){let c=wr(r.data,i,o);s[i]=a.has(c)?1:0}return u}function Di(r,t){let e=r.dtype,n=M(e),o=vr(r),a=new Set;for(let c=0;c<t.size;c++)a.add(wr(t.data,c,n));let u=[];for(let c=0;c<o.size;c++){let l=wr(o.data,c,n);a.has(l)||u.push(c)}if(n){let c=D.zeros([u.length],e),l=c.data,m=o.data;for(let y=0;y<u.length;y++){let d=u[y];l[y*2]=m[d*2],l[y*2+1]=m[d*2+1]}return c}let s=D.zeros([u.length],e),i=s.data;for(let c=0;c<u.length;c++)i[c]=o.data[u[c]];return s}function Ni(r,t){let e=r.dtype,n=M(e),o=vr(r),a=vr(t),u=new Set,s=new Set;for(let d=0;d<o.size;d++)u.add(wr(o.data,d,n));for(let d=0;d<a.size;d++)s.add(wr(a.data,d,n));let i=[],c=[];for(let d=0;d<o.size;d++){let f=wr(o.data,d,n);s.has(f)||i.push(d)}for(let d=0;d<a.size;d++){let f=wr(a.data,d,n);u.has(f)||c.push(d)}if(n){let d=[],f=o.data,p=a.data;for(let b of i)d.push({re:f[b*2],im:f[b*2+1]});for(let b of c)d.push({re:p[b*2],im:p[b*2+1]});d.sort((b,A)=>fn(b.re,b.im,A.re,A.im));let g=D.zeros([d.length],e),h=g.data;for(let b=0;b<d.length;b++)h[b*2]=d[b].re,h[b*2+1]=d[b].im;return g}let l=[];for(let d of i)l.push(Number(o.data[d]));for(let d of c)l.push(Number(a.data[d]));l.sort((d,f)=>isNaN(d)&&isNaN(f)?0:isNaN(d)?1:isNaN(f)?-1:d-f);let m=D.zeros([l.length],e),y=m.data;for(let d=0;d<l.length;d++)y[d]=l[d];return m}function wi(r,t){let e=r.dtype,n=M(e),o=vr(r),a=vr(t),u=new Set,s=[];if(n){let m=o.data,y=a.data;for(let p=0;p<o.size;p++){let g=m[p*2],h=m[p*2+1],b=`${g},${h}`;u.has(b)||(u.add(b),s.push({re:g,im:h}))}for(let p=0;p<a.size;p++){let g=y[p*2],h=y[p*2+1],b=`${g},${h}`;u.has(b)||(u.add(b),s.push({re:g,im:h}))}s.sort((p,g)=>fn(p.re,p.im,g.re,g.im));let d=D.zeros([s.length],e),f=d.data;for(let p=0;p<s.length;p++)f[p*2]=s[p].re,f[p*2+1]=s[p].im;return d}let i=[];for(let m=0;m<o.size;m++){let y=Number(o.data[m]),d=String(y);u.has(d)||(u.add(d),i.push(y))}for(let m=0;m<a.size;m++){let y=Number(a.data[m]),d=String(y);u.has(d)||(u.add(d),i.push(y))}i.sort((m,y)=>isNaN(m)&&isNaN(y)?0:isNaN(m)?1:isNaN(y)?-1:m-y);let c=D.zeros([i.length],e),l=c.data;for(let m=0;m<i.length;m++)l[m]=i[m];return c}var Ii=W(()=>{"use strict";X();J()});function pn(r,t=1,e=-1){if(t<0)throw new Error(`order must be non-negative but got ${t}`);if(t===0)return r.copy();let n=Array.from(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}`);if(n[a]<t+1)throw new Error(`diff requires at least ${t+1} elements along axis ${e}, but got ${n[a]}`);let u=r;for(let s=0;s<t;s++)u=my(u,a);return u}function my(r,t){let e=Array.from(r.shape),n=e.length,o=e[t],a=[...e];a[t]=o-1;let u=r.dtype,s=M(u),i=B(u)?"float64":u,c=D.zeros(a,i),l=c.data,m=r.strides,y=c.size;for(let d=0;d<y;d++){let f=d,p=new Array(n);for(let S=n-1;S>=0;S--)p[S]=f%a[S],f=Math.floor(f/a[S]);let g=[...p],h=[...p];h[t]=g[t]+1;let b=0,A=0;for(let S=0;S<n;S++)b+=g[S]*m[S],A+=h[S]*m[S];if(s){let S=r.data,x=S[b*2],w=S[b*2+1],N=S[A*2],I=S[A*2+1];l[d*2]=N-x,l[d*2+1]=I-w}else{let S=(B(u),Number(r.data[b])),x=(B(u),Number(r.data[A]));l[d]=x-S}}return c}function zi(r,t=null,e=null){let n=r.size,o=r.dtype,a=M(o),u=B(o)?"float64":o,s=Math.max(0,n-1),i=e?e.length:0,c=t?t.length:0,l=i+s+c,m=D.zeros([l],u),y=m.data,d=0;if(e)if(a)for(let f of e)y[d*2]=f,y[d*2+1]=0,d++;else for(let f of e)y[d++]=f;if(a){let f=r.data;for(let p=0;p<s;p++){let g=f[p*2],h=f[p*2+1],b=f[(p+1)*2],A=f[(p+1)*2+1];y[d*2]=b-g,y[d*2+1]=A-h,d++}}else for(let f=0;f<s;f++){let p=(B(o),Number(r.iget(f))),g=(B(o),Number(r.iget(f+1)));y[d++]=g-p}if(t)if(a)for(let f of t)y[d*2]=f,y[d*2+1]=0,d++;else for(let f of t)y[d++]=f;return m}function _i(r,t=1,e=null){let o=Array.from(r.shape).length,a;if(e===null)a=Array.from({length:o},(i,c)=>c);else if(typeof e=="number"){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}`);a=[i]}else a=e.map(i=>{let c=i<0?o+i:i;if(c<0||c>=o)throw new Error(`axis ${i} is out of bounds for array of dimension ${o}`);return c});let u;if(typeof t=="number")u=a.map(()=>t);else{if(t.length!==a.length)throw new Error("Number of spacings must match number of axes");u=t}let s=[];for(let i=0;i<a.length;i++)s.push(py(r,a[i],u[i]));return s.length===1?s[0]:s}function py(r,t,e){let n=Array.from(r.shape),o=n.length,a=n[t];if(a<2)throw new Error(`Shape of array along axis ${t} must be at least 2, but got ${a}`);let u=r.dtype,s=M(u),i=B(u)?"float64":u==="float32"?"float32":s?u:"float64",c=D.zeros(n,i),l=c.data,m=r.strides,y=e,d=2*y,f=r.size;for(let p=0;p<f;p++){let g=p,h=new Array(o);for(let A=o-1;A>=0;A--)h[A]=g%n[A],g=Math.floor(g/n[A]);let b=h[t];if(s){let A=r.data,S=l,x,w;if(b===0){let N=[...h];N[t]=1;let I=0;for(let E=0;E<o;E++)I+=N[E]*m[E];let z=A[p*2],F=A[p*2+1],_=A[I*2],T=A[I*2+1];x=(_-z)/y,w=(T-F)/y}else if(b===a-1){let N=[...h];N[t]=a-2;let I=0;for(let E=0;E<o;E++)I+=N[E]*m[E];let z=A[p*2],F=A[p*2+1],_=A[I*2],T=A[I*2+1];x=(z-_)/y,w=(F-T)/y}else{let N=[...h],I=[...h];N[t]=b+1,I[t]=b-1;let z=0,F=0;for(let k=0;k<o;k++)z+=N[k]*m[k],F+=I[k]*m[k];let _=A[z*2],T=A[z*2+1],E=A[F*2],C=A[F*2+1];x=(_-E)/d,w=(T-C)/d}S[p*2]=x,S[p*2+1]=w}else{let A;if(b===0){let S=[...h];S[t]=1;let x=0;for(let I=0;I<o;I++)x+=S[I]*m[I];let w=(B(u),Number(r.data[p]));A=((B(u),Number(r.data[x]))-w)/y}else if(b===a-1){let S=[...h];S[t]=a-2;let x=0;for(let I=0;I<o;I++)x+=S[I]*m[I];let w=(B(u),Number(r.data[p])),N=(B(u),Number(r.data[x]));A=(w-N)/y}else{let S=[...h],x=[...h];S[t]=b+1,x[t]=b-1;let w=0,N=0;for(let F=0;F<o;F++)w+=S[F]*m[F],N+=x[F]*m[F];let I=(B(u),Number(r.data[w])),z=(B(u),Number(r.data[N]));A=(I-z)/d}l[p]=A}}return c}function Fi(r,t,e=-1,n=-1,o=-1){let a=Array.from(r.shape),u=Array.from(t.shape),s=a.length,i=u.length,c=e<0?s+e:e,l=n<0?i+n:n;if(c<0||c>=s)throw new Error(`axisa ${e} is out of bounds for array of dimension ${s}`);if(l<0||l>=i)throw new Error(`axisb ${n} is out of bounds for array of dimension ${i}`);let m=a[c],y=u[l];if(m!==2&&m!==3)throw new Error(`incompatible dimensions for cross product (dimension must be 2 or 3, got ${m})`);if(y!==2&&y!==3)throw new Error(`incompatible dimensions for cross product (dimension must be 2 or 3, got ${y})`);let d=Z(r.dtype,t.dtype),f=M(d),p=(b,A)=>{if(M(b.dtype)){let S=b.data;return[S[A*2],S[A*2+1]]}return[Number(b.iget(A)),0]},g=(b,A,S,x)=>[b*S-A*x,b*x+A*S],h=(b,A,S,x)=>[b-S,A-x];if(s===1&&i===1&&m===3&&y===3){let b=D.zeros([3],d);if(f){let A=b.data,[S,x]=p(r,0),[w,N]=p(r,1),[I,z]=p(r,2),[F,_]=p(t,0),[T,E]=p(t,1),[C,k]=p(t,2),[V,R]=g(w,N,C,k),[L,P]=g(I,z,T,E),[Q,er]=h(V,R,L,P),[G,or]=g(I,z,F,_),[ar,sr]=g(S,x,C,k),[mr,se]=h(G,or,ar,sr),[ie,ue]=g(S,x,T,E),[ce,le]=g(w,N,F,_),[fe,me]=h(ie,ue,ce,le);A[0]=Q,A[1]=er,A[2]=mr,A[3]=se,A[4]=fe,A[5]=me}else{let A=b.data,S=Number(r.iget(0)),x=Number(r.iget(1)),w=Number(r.iget(2)),N=Number(t.iget(0)),I=Number(t.iget(1)),z=Number(t.iget(2));A[0]=x*z-w*I,A[1]=w*N-S*z,A[2]=S*I-x*N}return b}if(s===1&&i===1&&m===2&&y===2){let b=D.zeros([],d);if(f){let A=b.data,[S,x]=p(r,0),[w,N]=p(r,1),[I,z]=p(t,0),[F,_]=p(t,1),[T,E]=g(S,x,F,_),[C,k]=g(w,N,I,z),[V,R]=h(T,E,C,k);A[0]=V,A[1]=R}else{let A=Number(r.iget(0)),S=Number(r.iget(1)),x=Number(t.iget(0)),w=Number(t.iget(1));b.data[0]=A*w-S*x}return b}if(s===1&&i===1){if(m===2&&y===3){let b=D.zeros([3],d);if(f){let A=b.data,[S,x]=p(r,0),[w,N]=p(r,1),[I,z]=p(t,0),[F,_]=p(t,1),[T,E]=p(t,2),[C,k]=g(w,N,T,E),[V,R]=g(S,x,T,E),L=-V,P=-R,[Q,er]=g(S,x,F,_),[G,or]=g(w,N,I,z),[ar,sr]=h(Q,er,G,or);A[0]=C,A[1]=k,A[2]=L,A[3]=P,A[4]=ar,A[5]=sr}else{let A=b.data,S=Number(r.iget(0)),x=Number(r.iget(1)),w=Number(t.iget(0)),N=Number(t.iget(1)),I=Number(t.iget(2));A[0]=x*I,A[1]=-S*I,A[2]=S*N-x*w}return b}else if(m===3&&y===2){let b=D.zeros([3],d);if(f){let A=b.data,[S,x]=p(r,0),[w,N]=p(r,1),[I,z]=p(r,2),[F,_]=p(t,0),[T,E]=p(t,1),[C,k]=g(I,z,T,E),V=-C,R=-k,[L,P]=g(I,z,F,_),[Q,er]=g(S,x,T,E),[G,or]=g(w,N,F,_),[ar,sr]=h(Q,er,G,or);A[0]=V,A[1]=R,A[2]=L,A[3]=P,A[4]=ar,A[5]=sr}else{let A=b.data,S=Number(r.iget(0)),x=Number(r.iget(1)),w=Number(r.iget(2)),N=Number(t.iget(0)),I=Number(t.iget(1));A[0]=-w*I,A[1]=w*N,A[2]=S*I-x*N}return b}}if(s===2&&i===2&&c===1&&l===1){let b=a[0];if(u[0]!==b)throw new Error(`Shape mismatch: a has ${b} vectors, b has ${u[0]} vectors`);if(m===3&&y===3){let A=D.zeros([b,3],d);if(f){let S=A.data;for(let x=0;x<b;x++){let[w,N]=p(r,x*3),[I,z]=p(r,x*3+1),[F,_]=p(r,x*3+2),[T,E]=p(t,x*3),[C,k]=p(t,x*3+1),[V,R]=p(t,x*3+2),[L,P]=g(I,z,V,R),[Q,er]=g(F,_,C,k),[G,or]=h(L,P,Q,er),[ar,sr]=g(F,_,T,E),[mr,se]=g(w,N,V,R),[ie,ue]=h(ar,sr,mr,se),[ce,le]=g(w,N,C,k),[fe,me]=g(I,z,T,E),[Lm,Wm]=h(ce,le,fe,me);S[x*3*2]=G,S[x*3*2+1]=or,S[(x*3+1)*2]=ie,S[(x*3+1)*2+1]=ue,S[(x*3+2)*2]=Lm,S[(x*3+2)*2+1]=Wm}}else{let S=A.data;for(let x=0;x<b;x++){let w=Number(r.iget(x*3)),N=Number(r.iget(x*3+1)),I=Number(r.iget(x*3+2)),z=Number(t.iget(x*3)),F=Number(t.iget(x*3+1)),_=Number(t.iget(x*3+2));S[x*3]=N*_-I*F,S[x*3+1]=I*z-w*_,S[x*3+2]=w*F-N*z}}return A}if(m===2&&y===2){let A=D.zeros([b],d);if(f){let S=A.data;for(let x=0;x<b;x++){let[w,N]=p(r,x*2),[I,z]=p(r,x*2+1),[F,_]=p(t,x*2),[T,E]=p(t,x*2+1),[C,k]=g(w,N,T,E),[V,R]=g(I,z,F,_),[L,P]=h(C,k,V,R);S[x*2]=L,S[x*2+1]=P}}else{let S=A.data;for(let x=0;x<b;x++){let w=Number(r.iget(x*2)),N=Number(r.iget(x*2+1)),I=Number(t.iget(x*2)),z=Number(t.iget(x*2+1));S[x]=w*z-N*I}}return A}}throw new Error(`cross product not implemented for arrays with shapes ${JSON.stringify(a)} and ${JSON.stringify(u)}`)}var Mi=W(()=>{"use strict";X();J()});function Bi(r,t,e=0){q(r.dtype,"bincount","bincount requires integer input.");let n=r.data,o=r.size,a=0;for(let s=0;s<o;s++){let i=Number(n[s]);if(i<0||!Number.isInteger(i))throw new Error("'x' argument must contain non-negative integers");i>a&&(a=i)}let u=Math.max(a+1,e);if(t!==void 0){if(t.size!==o)throw new Error("weights array must have same length as x");let s=t.data,i=new Float64Array(u);for(let c=0;c<o;c++){let l=Number(n[c]);i[l]+=Number(s[c])}return D.fromData(i,[u],"float64")}else{let s=new Float64Array(u);for(let i=0;i<o;i++){let c=Number(n[i]);s[c]++}return D.fromData(s,[u],"float64")}}function vi(r,t,e=!1){q(r.dtype,"digitize","digitize requires real numbers."),q(t.dtype,"digitize","digitize requires real numbers.");let n=r.data,o=t.data,a=r.size,u=t.size,s=new Float64Array(a),i=!0;u>1&&(i=Number(o[1])>=Number(o[0]));for(let c=0;c<a;c++){let l=Number(n[c]),m;if(i)e?m=dy(o,u,l):m=At(o,u,l);else if(e)for(m=0;m<u&&Number(o[m])>=l;)m++;else for(m=0;m<u&&Number(o[m])>l;)m++;s[c]=m}return D.fromData(s,[...r.shape],"float64")}function dy(r,t,e){let n=0,o=t;for(;n<o;){let a=n+o>>>1;Number(r[a])<e?n=a+1:o=a}return n}function At(r,t,e){let n=0,o=t;for(;n<o;){let a=n+o>>>1;Number(r[a])<=e?n=a+1:o=a}return n}function Ti(r,t=10,e,n=!1,o){q(r.dtype,"histogram","histogram requires real numbers."),typeof t!="number"&&q(t.dtype,"histogram","histogram requires real numbers.");let a=r.data,u=r.size,s;if(typeof t=="number"){let m,y;if(e)[m,y]=e;else{m=1/0,y=-1/0;for(let f=0;f<u;f++){let p=Number(a[f]);p<m&&(m=p),p>y&&(y=p)}m===y&&(m=m-.5,y=y+.5)}s=[];let d=(y-m)/t;for(let f=0;f<=t;f++)s.push(m+f*d)}else{let m=t.data;s=[];for(let y=0;y<t.size;y++)s.push(Number(m[y]))}let i=s.length-1,c=new Float64Array(i),l=o?.data;for(let m=0;m<u;m++){let y=Number(a[m]),d=l?Number(l[m]):1,f=At(s,s.length,y)-1;if(!(f<0)){if(f>=i)if(y===s[i])f=i-1;else continue;c[f]+=d}}if(n){let m=0;for(let y=0;y<i;y++)m+=c[y];for(let y=0;y<i;y++){let d=s[y+1]-s[y];c[y]=c[y]/(m*d)}}return{hist:D.fromData(c,[i],"float64"),bin_edges:D.fromData(new Float64Array(s),[s.length],"float64")}}function Ei(r,t,e=10,n,o=!1,a){q(r.dtype,"histogram2d","histogram2d requires real numbers."),q(t.dtype,"histogram2d","histogram2d requires real numbers.");let u=r.data,s=t.data,i=r.size;if(t.size!==i)throw new Error("x and y must have the same length");let c,l,m,y;if(typeof e=="number"?(m=e,y=e):Array.isArray(e)&&e.length===2?(e[0],m=e[0],y=e[1]):(m=10,y=10),typeof m=="number"){let h,b;if(n)[h,b]=n[0];else{h=1/0,b=-1/0;for(let S=0;S<i;S++){let x=Number(u[S]);x<h&&(h=x),x>b&&(b=x)}h===b&&(h-=.5,b+=.5)}c=[];let A=(b-h)/m;for(let S=0;S<=m;S++)c.push(h+S*A)}else{let h=m.data;c=[];for(let b=0;b<m.size;b++)c.push(Number(h[b]))}if(typeof y=="number"){let h,b;if(n)[h,b]=n[1];else{h=1/0,b=-1/0;for(let S=0;S<i;S++){let x=Number(s[S]);x<h&&(h=x),x>b&&(b=x)}h===b&&(h-=.5,b+=.5)}l=[];let A=(b-h)/y;for(let S=0;S<=y;S++)l.push(h+S*A)}else{let h=y.data;l=[];for(let b=0;b<y.size;b++)l.push(Number(h[b]))}let d=c.length-1,f=l.length-1,p=new Float64Array(d*f),g=a?.data;for(let h=0;h<i;h++){let b=Number(u[h]),A=Number(s[h]),S=g?Number(g[h]):1,x=At(c,c.length,b)-1,w=At(l,l.length,A)-1;if(x<0||x>=d)if(b===c[d]&&x===d)x=d-1;else continue;if(w<0||w>=f)if(A===l[f]&&w===f)w=f-1;else continue;p[x*f+w]+=S}if(o){let h=0;for(let b=0;b<p.length;b++)h+=p[b];for(let b=0;b<d;b++)for(let A=0;A<f;A++){let S=c[b+1]-c[b],x=l[A+1]-l[A],w=S*x;p[b*f+A]=p[b*f+A]/(h*w)}}return{hist:D.fromData(p,[d,f],"float64"),x_edges:D.fromData(new Float64Array(c),[c.length],"float64"),y_edges:D.fromData(new Float64Array(l),[l.length],"float64")}}function Oi(r,t=10,e,n=!1,o){q(r.dtype,"histogramdd","histogramdd requires real numbers.");let a=r.shape,u=r.data,s,i;if(a.length===1)s=a[0],i=1;else if(a.length===2)s=a[0],i=a[1];else throw new Error("sample must be 1D or 2D array");let c;if(typeof t=="number")c=new Array(i).fill(t);else if(c=t,c.length!==i)throw new Error("bins array length must match number of dimensions");let l=[];for(let h=0;h<i;h++){let b,A;if(e&&e[h])[b,A]=e[h];else{b=1/0,A=-1/0;for(let N=0;N<s;N++){let I=Number(i===1?u[N]:u[N*i+h]);I<b&&(b=I),I>A&&(A=I)}b===A&&(b-=.5,A+=.5)}let S=c[h],x=[],w=(A-b)/S;for(let N=0;N<=S;N++)x.push(b+N*w);l.push(x)}let m=c.slice(),y=m.reduce((h,b)=>h*b,1),d=new Float64Array(y),f=new Array(i);f[i-1]=1;for(let h=i-2;h>=0;h--)f[h]=f[h+1]*c[h+1];let p=o?.data;for(let h=0;h<s;h++){let b=p?Number(p[h]):1,A=0,S=!1;for(let x=0;x<i;x++){let w=Number(i===1?u[h]:u[h*i+x]),N=l[x],I=c[x],z=At(N,N.length,w)-1;if(z<0||z>=I)if(w===N[I]&&z===I)z=I-1;else{S=!0;break}A+=z*f[x]}S||(d[A]+=b)}if(n){let h=0;for(let A=0;A<y;A++)h+=d[A];let b=new Float64Array(y);for(let A=0;A<y;A++){let S=1,x=A;for(let w=0;w<i;w++){let N=Math.floor(x/f[w])%c[w],I=l[w];S*=I[N+1]-I[N]}b[A]=S}for(let A=0;A<y;A++)d[A]=d[A]/(h*b[A])}let g=l.map(h=>D.fromData(new Float64Array(h),[h.length],"float64"));return{hist:D.fromData(d,m,"float64"),edges:g}}function yn(r,t,e="full"){let n=r.data,o=t.data,a=r.size,u=t.size,s=M(r.dtype)||M(t.dtype),i=a+u-1;if(s){let l=new Float64Array(i),m=new Float64Array(i),y=M(r.dtype),d=M(t.dtype);for(let p=0;p<i;p++){let g=0,h=0,b=p-u+1;for(let A=0;A<a;A++){let S=A-b;if(S>=0&&S<u){let x,w,N,I;y?(x=n[A*2],w=n[A*2+1]):(x=Number(n[A]),w=0),d?(N=o[S*2],I=o[S*2+1]):(N=Number(o[S]),I=0),g+=x*N+w*I,h+=w*N-x*I}}l[p]=g,m[p]=h}let f=(p,g,h,b=0)=>{let A=new Float64Array(h*2);for(let S=0;S<h;S++)A[S*2]=p[b+S],A[S*2+1]=g[b+S];return D.fromData(A,[h],"complex128")};if(e==="full")return f(l,m,i);if(e==="same"){let p=Math.floor((i-a)/2);return f(l,m,a,p)}else{let p=Math.max(a,u)-Math.min(a,u)+1,g=Math.min(a,u)-1;return f(l,m,p,g)}}let c=new Float64Array(i);for(let l=0;l<i;l++){let m=0,y=l-u+1;for(let d=0;d<a;d++){let f=d-y;f>=0&&f<u&&(m+=Number(n[d])*Number(o[f]))}c[l]=m}if(e==="full")return D.fromData(c,[i],"float64");if(e==="same"){let l=Math.floor((i-a)/2),m=new Float64Array(a);for(let y=0;y<a;y++)m[y]=c[l+y];return D.fromData(m,[a],"float64")}else{let l=Math.max(a,u)-Math.min(a,u)+1,m=Math.min(a,u)-1,y=new Float64Array(l);for(let d=0;d<l;d++)y[d]=c[m+d];return D.fromData(y,[l],"float64")}}function Ci(r,t,e="full"){let n=t.data,o=t.size,a=M(t.dtype),u;if(a){let s=new Float64Array(o*2);for(let i=0;i<o;i++){let c=o-1-i;s[i*2]=n[c*2],s[i*2+1]=n[c*2+1]}u=D.fromData(s,[o],t.dtype)}else{let s=new Float64Array(o);for(let i=0;i<o;i++)s[i]=Number(n[o-1-i]);u=D.fromData(s,[o],"float64")}if(a){let s=u.data;for(let i=0;i<o;i++)s[i*2+1]=-s[i*2+1]}return yn(r,u,e)}function dn(r,t,e=!0,n=!1,o){let a=r.shape,u=r.data,s=M(r.dtype)||t!==void 0&&M(t.dtype),i;if(o!==void 0?i=o:i=n?0:1,a.length===1)if(t!==void 0){let f=t.data,p=r.size,g=M(r.dtype),h=M(t.dtype);if(t.size!==p)throw new Error("m and y must have same length");if(s){let I=0,z=0,F=0,_=0;for(let G=0;G<p;G++)g?(I+=u[G*2],z+=u[G*2+1]):I+=Number(u[G]),h?(F+=f[G*2],_+=f[G*2+1]):F+=Number(f[G]);I/=p,z/=p,F/=p,_/=p;let T=0,E=0,C=0,k=0,V=0,R=0,L=0,P=0;for(let G=0;G<p;G++){let or,ar,sr,mr;g?(or=u[G*2]-I,ar=u[G*2+1]-z):(or=Number(u[G])-I,ar=0),h?(sr=f[G*2]-F,mr=f[G*2+1]-_):(sr=Number(f[G])-F,mr=0),T+=or*or+ar*ar,C+=sr*sr+mr*mr,V+=or*sr+ar*mr,R+=ar*sr-or*mr,L+=sr*or+mr*ar,P+=mr*or-sr*ar}let Q=p-i;if(Q<=0){let G=new Float64Array(8);return G.fill(NaN),D.fromData(G,[2,2],"complex128")}T/=Q,C/=Q,V/=Q,R/=Q,L/=Q,P/=Q;let er=new Float64Array(8);return er[0]=T,er[1]=E,er[2]=V,er[3]=R,er[4]=L,er[5]=P,er[6]=C,er[7]=k,D.fromData(er,[2,2],"complex128")}let b=0,A=0;for(let I=0;I<p;I++)b+=Number(u[I]),A+=Number(f[I]);b/=p,A/=p;let S=0,x=0,w=0;for(let I=0;I<p;I++){let z=Number(u[I])-b,F=Number(f[I])-A;S+=z*z,x+=F*F,w+=z*F}let N=p-i;return N<=0?D.fromData(new Float64Array([NaN,NaN,NaN,NaN]),[2,2],"float64"):(S/=N,x/=N,w/=N,D.fromData(new Float64Array([S,w,w,x]),[2,2],"float64"))}else{let f=r.size;if(s){let b=0,A=0;for(let w=0;w<f;w++)b+=u[w*2],A+=u[w*2+1];b/=f,A/=f;let S=0;for(let w=0;w<f;w++){let N=u[w*2]-b,I=u[w*2+1]-A;S+=N*N+I*I}let x=f-i;return x<=0?D.fromData(new Float64Array([NaN,0]),[],"complex128"):(S/=x,D.fromData(new Float64Array([S,0]),[],"complex128"))}let p=0;for(let b=0;b<f;b++)p+=Number(u[b]);p/=f;let g=0;for(let b=0;b<f;b++){let A=Number(u[b])-p;g+=A*A}let h=f-i;return h<=0?D.fromData(new Float64Array([NaN]),[],"float64"):(g/=h,D.fromData(new Float64Array([g]),[],"float64"))}let c,l;e?(c=a[0],l=a[1]):(c=a[1],l=a[0]);let m=l-i;if(s){let f=new Float64Array(c),p=new Float64Array(c);for(let h=0;h<c;h++){let b=0,A=0;for(let S=0;S<l;S++){let x=e?h*l+S:S*c+h;b+=u[x*2],A+=u[x*2+1]}f[h]=b/l,p[h]=A/l}let g=new Float64Array(c*c*2);if(m<=0)return g.fill(NaN),D.fromData(g,[c,c],"complex128");for(let h=0;h<c;h++)for(let b=0;b<c;b++){let A=0,S=0;for(let w=0;w<l;w++){let N=e?h*l+w:w*c+h,I=e?b*l+w:w*c+b,z=u[N*2]-f[h],F=u[N*2+1]-p[h],_=u[I*2]-f[b],T=u[I*2+1]-p[b];A+=z*_+F*T,S+=F*_-z*T}let x=(h*c+b)*2;g[x]=A/m,g[x+1]=S/m}return D.fromData(g,[c,c],"complex128")}let y=new Float64Array(c);for(let f=0;f<c;f++){let p=0;for(let g=0;g<l;g++){let h=e?f*l+g:g*c+f;p+=Number(u[h])}y[f]=p/l}let d=new Float64Array(c*c);if(m<=0)return d.fill(NaN),D.fromData(d,[c,c],"float64");for(let f=0;f<c;f++)for(let p=f;p<c;p++){let g=0;for(let b=0;b<l;b++){let A=e?f*l+b:b*c+f,S=e?p*l+b:b*c+p,x=Number(u[A])-y[f],w=Number(u[S])-y[p];g+=x*w}let h=g/m;d[f*c+p]=h,d[p*c+f]=h}return D.fromData(d,[c,c],"float64")}function Ui(r,t,e=!0){let n=M(r.dtype)||t!==void 0&&M(t.dtype);if(r.shape.length===1&&t===void 0)return n?D.fromData(new Float64Array([1,0]),[],"complex128"):D.fromData(new Float64Array([1]),[],"float64");let o=dn(r,t,e,!1),a=o.data,s=o.shape[0];if(n){let c=new Float64Array(s*s*2);for(let l=0;l<s;l++)for(let m=0;m<s;m++){let y=a[(l*s+m)*2],d=a[(l*s+m)*2+1],f=a[(l*s+l)*2],p=a[(m*s+m)*2],g=(l*s+m)*2;if(f<=0||p<=0)c[g]=NaN,c[g+1]=NaN;else{let h=Math.sqrt(f*p);c[g]=y/h,c[g+1]=d/h}}return D.fromData(c,[s,s],"complex128")}let i=new Float64Array(s*s);for(let c=0;c<s;c++)for(let l=0;l<s;l++){let m=Number(a[c*s+l]),y=Number(a[c*s+c]),d=Number(a[l*s+l]);y<=0||d<=0?i[c*s+l]=NaN:i[c*s+l]=m/Math.sqrt(y*d)}return D.fromData(i,[s,s],"float64")}var $i=W(()=>{"use strict";X();J()});function Ir(r,t=tr){let e=D.zeros(r,t);return new v(e)}function gn(r,t=tr){let e=D.ones(r,t);return new v(e)}function Ay(r){let t=[],e=r;for(;Array.isArray(e);)t.push(e.length),e=e[0];return t}function Ri(r){return typeof r=="bigint"?!0:Array.isArray(r)?r.some(t=>Ri(t)):!1}function ki(r){return to(r)?!0:Array.isArray(r)?r.some(t=>ki(t)):!1}function by(r){let t=[];function e(n){Array.isArray(n)?n.forEach(o=>e(o)):t.push(n)}return e(r),t}function rr(r,t){if(r instanceof v)return!t||r.dtype===t?r.copy():r.astype(t);let e=Ri(r),n=ki(r),o=Ay(r),a=o.reduce((d,f)=>d*f,1),u=t;u||(n?u="complex128":e?u="int64":u=tr);let s=M(u),i=j(u);if(!i)throw new Error(`Cannot create array with dtype ${u}`);let c=s?a*2:a,l=new i(c),m=by(r);if(B(u)){let d=l;for(let f=0;f<a;f++){let p=m[f];d[f]=typeof p=="bigint"?p:BigInt(Math.round(Number(p)))}}else if(u==="bool"){let d=l;for(let f=0;f<a;f++)d[f]=m[f]?1:0}else if(s){let d=l;for(let f=0;f<a;f++){let p=m[f],g,h;p instanceof O?(g=p.re,h=p.im):typeof p=="object"&&p!==null&&"re"in p?(g=p.re,h=p.im??0):(g=Number(p),h=0),d[f*2]=g,d[f*2+1]=h}}else{let d=l;for(let f=0;f<a;f++){let p=m[f];d[f]=Number(p)}}let y=D.fromData(l,o,u);return new v(y)}function qi(r,t,e=1,n=tr){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=j(n);if(!s)throw new Error(`Cannot create arange array with dtype ${n}`);let i=new s(u);if(B(n))for(let l=0;l<u;l++)i[l]=BigInt(Math.round(o+l*e));else if(n==="bool")for(let l=0;l<u;l++)i[l]=o+l*e!==0?1:0;else for(let l=0;l<u;l++)i[l]=o+l*e;let c=D.fromData(i,[u],n);return new v(c)}function Vi(r,t,e=50,n=tr){if(e<0)throw new Error("num must be non-negative");if(e===0)return rr([],n);if(e===1)return rr([r],n);let o=j(n);if(!o)throw new Error(`Cannot create linspace array with dtype ${n}`);let a=new o(e),u=(t-r)/(e-1);if(B(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 v(s)}function Pi(r,t,e=50,n=10,o=tr){if(e<0)throw new Error("num must be non-negative");if(e===0)return rr([],o);if(e===1)return rr([Math.pow(n,r)],o);let a=j(o);if(!a)throw new Error(`Cannot create logspace array with dtype ${o}`);let u=new a(e),s=(t-r)/(e-1);if(B(o))for(let c=0;c<e;c++){let l=r+c*s;u[c]=BigInt(Math.round(Math.pow(n,l)))}else if(o==="bool")for(let c=0;c<e;c++){let l=r+c*s;u[c]=Math.pow(n,l)!==0?1:0}else for(let c=0;c<e;c++){let l=r+c*s;u[c]=Math.pow(n,l)}let i=D.fromData(u,[e],o);return new v(i)}function ji(r,t,e=50,n=tr){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 rr([],n);if(e===1)return rr([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=j(n);if(!u)throw new Error(`Cannot create geomspace array with dtype ${n}`);let s=new u(e),i=Math.log(Math.abs(r)),l=(Math.log(Math.abs(t))-i)/(e-1);if(B(n))for(let y=0;y<e;y++){let d=o*Math.exp(i+y*l);s[y]=BigInt(Math.round(d))}else if(n==="bool")for(let y=0;y<e;y++){let d=o*Math.exp(i+y*l);s[y]=d!==0?1:0}else for(let y=0;y<e;y++){let d=o*Math.exp(i+y*l);s[y]=d}let m=D.fromData(s,[e],n);return new v(m)}function An(r,t,e=0,n=tr){let o=t??r,a=Ir([r,o],n),u=a.data;if(B(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 bn(r,t=tr){return Ir(r,t)}function hn(r,t,e){let n=e;n||(typeof t=="bigint"?n="int64":typeof t=="boolean"?n="bool":Number.isInteger(t)?n="int32":n=tr);let o=j(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(B(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 v(s)}function Li(r,t=tr){return An(r,r,0,t)}function bt(r,t){return r instanceof v?!t||r.dtype===t?r:r.astype(t):rr(r,t)}function Wi(r){return r.copy()}function Gi(r,t){return Ir(Array.from(r.shape),t??r.dtype)}function Zi(r,t){return gn(Array.from(r.shape),t??r.dtype)}function Yi(r,t){return bn(Array.from(r.shape),t??r.dtype)}function Hi(r,t,e){return hn(Array.from(r.shape),t,e??r.dtype)}function Ji(r,t){return bt(r,t)}function Xi(r,t){let e=bt(r,t);return e.flags.C_CONTIGUOUS?e:e.copy()}function Qi(r,t){return bt(r,t).copy()}function Sn(r,t=0){if(r.ndim===1){let e=r.size,n=e+Math.abs(t),o=Ir([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 Ir([0],r.dtype);let s=j(r.dtype),i=new s(u);for(let l=0;l<u;l++){let m=r.get([o+l,a+l]);B(r.dtype)?i[l]=typeof m=="bigint"?m:BigInt(m):i[l]=m}let c=D.fromData(i,[u],r.dtype);return new v(c)}else throw new Error("Input must be 1-D or 2-D")}function Ki(r,t=0){let e=r.flatten();return Sn(e,t)}function ru(r,t,e=tr){let n=t.reduce((c,l)=>c*l,1),o=j(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 l=r(...s);B(e)?a[c]=typeof l=="bigint"?l:BigInt(Number(l)):e==="bool"?a[c]=l?1:0:a[c]=Number(l);for(let m=u-1;m>=0&&(s[m]++,!(s[m]<t[m]));m--)s[m]=0}let i=D.fromData(a,t,e);return new v(i)}function tu(...r){let t=[],e="xy";for(let s of r)s instanceof v?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,l=new Array(a).fill(1);l[s]=c;let m=i.reshape(...l),y=qt(m.storage,o),d=v._fromStorage(y.copy());u.push(d)}return e==="xy"&&u.length>=2&&([u[0],u[1]]=[u[1],u[0]]),u}function eu(r,t,e=0,n=tr){let o=t??r,a=Ir([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 nu(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 l=[],m=s;for(let y=n.length-3;y>=0;y--)l.unshift(m%n[y]),m=Math.floor(m/n[y]);l.push(i,c),e.set(l,0)}return e}function ou(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 l=[],m=s;for(let y=n.length-3;y>=0;y--)l.unshift(m%n[y]),m=Math.floor(m/n[y]);l.push(i,c),e.set(l,0)}return e}function au(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=Ir([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 su(r,t=tr,e=-1,n=0){let o,a=n;r instanceof ArrayBuffer?o=r:(o=r.buffer,a+=r.byteOffset);let u=hy(t),s=o.byteLength-a,i=Math.floor(s/u),c=e<0?i:Math.min(e,i);if(c<=0)return rr([],t);let l=j(t);if(!l)throw new Error(`Unsupported dtype: ${t}`);let m=new l(o,a,c),y=D.fromData(m,[c],t);return new v(y)}function iu(r,t=tr,e=-1){let n=[],o=0;for(let a of r){if(e>=0&&o>=e)break;n.push(a),o++}return rr(n,t)}function uu(r,t=tr,e=-1){let n=[],o=0;for(let a of r){if(e>=0&&o>=e)break;n.push(a),o++}return rr(n,t)}function cu(r,t=tr,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!==""&&(B(t)?a.push(BigInt(i)):a.push(parseFloat(i)),u++)}return rr(a,t)}function hy(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 lu(r){return r.sqrt()}function xn(r,t){return r.power(t)}function fu(r){return r.exp()}function mu(r){return r.exp2()}function pu(r){return r.expm1()}function yu(r){return r.log()}function du(r){return r.log2()}function gu(r){return r.log10()}function Au(r){return r.log1p()}function bu(r,t){return r.logaddexp(t)}function hu(r,t){return r.logaddexp2(t)}function Dn(r){return r.absolute()}function Su(r){return r.negative()}function xu(r){return r.sign()}function Du(r,t){return r.mod(t)}function Nn(r,t){return r.divide(t)}function Nu(r,t){return r.floor_divide(t)}function wu(r){return r.positive()}function Iu(r){return r.reciprocal()}function zu(r,t){return r.dot(t)}function _u(r){return r.trace()}function Fu(r,t=0,e=0,n=1){let o=fa(r.storage,t,e,n);return v._fromStorage(o)}function Mu(r,t){let e=pa(r.storage,t.storage);return v._fromStorage(e)}function Bu(r,t){return r.transpose(t)}function vu(r,t){return r.inner(t)}function Tu(r,t){return r.outer(t)}function Eu(r,t,e=2){return r.tensordot(t,e)}function Ou(r){return r.sin()}function Cu(r){return r.cos()}function Uu(r){return r.tan()}function wn(r){return r.arcsin()}function In(r){return r.arccos()}function zn(r){return r.arctan()}function _n(r,t){return r.arctan2(t)}function $u(r,t){return r.hypot(t)}function Ru(r){return r.degrees()}function ku(r){return r.radians()}function qu(r){return r.radians()}function Vu(r){return r.degrees()}function Pu(r){return r.sinh()}function ju(r){return r.cosh()}function Lu(r){return r.tanh()}function Fn(r){return r.arcsinh()}function Mn(r){return r.arccosh()}function Bn(r){return r.arctanh()}function Wu(r,t,e){return r.swapaxes(t,e)}function Gu(r,t,e){return r.moveaxis(t,e)}function qr(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=Rr(e,t);return v._fromStorage(n)}function Zu(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=qo(e,t);return v._fromStorage(n)}function vn(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Vo(t);return v._fromStorage(e)}function Yu(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Ue(t);return v._fromStorage(e)}function Hu(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Po(t);return v._fromStorage(e)}function Ju(r,t,e=0){return jo(r.storage,t,e).map(o=>v._fromStorage(o,r.base??r))}function Xu(r,t,e=0){return mt(r.storage,t,e).map(o=>v._fromStorage(o,r.base??r))}function Qu(r,t){return Wo(r.storage,t).map(n=>v._fromStorage(n,r.base??r))}function Ku(r,t){return Go(r.storage,t).map(n=>v._fromStorage(n,r.base??r))}function rc(r,t){let e=Zo(r.storage,t);return v._fromStorage(e)}function tc(r,t,e){return r.repeat(t,e)}function ec(r){return r.ravel()}function nc(r,t){return r.reshape(...t)}function oc(r,t){return r.squeeze(t)}function ac(r,t){return r.expand_dims(t)}function Lt(r,t){let e=Ho(r.storage,t);return v._fromStorage(e)}function sc(r){if(r.ndim<2)throw new Error("Input must be at least 2-D");return Lt(r,1)}function ic(r){if(r.ndim<2)throw new Error("Input must be at least 2-D");return Lt(r,0)}function uc(r,t=1,e=[0,1]){let n=Jo(r.storage,t,e);return v._fromStorage(n)}function cc(r,t,e){let n=Xo(r.storage,t,e);return v._fromStorage(n)}function lc(r,t,e=0){let n=Qo(r.storage,t,e);return v._fromStorage(n,r.base??r)}function fc(...r){let t=r.map(o=>o.storage),n=ea(t).map((o,a)=>o===t[a]?r[a]:v._fromStorage(o));return n.length===1?n[0]:n}function mc(...r){let t=r.map(o=>o.storage),n=na(t).map((o,a)=>o===t[a]?r[a]:v._fromStorage(o));return n.length===1?n[0]:n}function pc(...r){let t=r.map(o=>o.storage),n=oa(t).map((o,a)=>o===t[a]?r[a]:v._fromStorage(o));return n.length===1?n[0]:n}function yc(r,t){return Ko(r.storage,t).map(n=>v._fromStorage(n,r.base??r))}function dc(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=ra(t);return v._fromStorage(e)}function gc(r){return vn(r)}function Ac(r,t){let e=ta(r.storage,t);return v._fromStorage(e)}function bc(r,t,e){let n=t instanceof v?t:rr(t,r.dtype);if(e===void 0){let o=r.flatten(),a=n.flatten();return qr([o,a])}return qr([r,n],e)}function hc(r,t,e){let n=r.dtype;if(e===void 0){let d=r.flatten(),p=(Array.isArray(t)?t:[t]).map(S=>S<0?d.size+S:S),g=[];for(let S=0;S<d.size;S++)p.includes(S)||g.push(S);let h=j(n),b=new h(g.length);for(let S=0;S<g.length;S++){let x=d.get([g[S]]);B(n)?b[S]=typeof x=="bigint"?x:BigInt(x):b[S]=x}let A=D.fromData(b,[g.length],n);return new v(A)}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(d=>d<0?s+d:d)),l=[],m=0;for(let d=0;d<=s;d++)(c.has(d)||d===s)&&(d>m&&l.push([m,d]),m=d+1);if(l.length===0){let d=[...o];return d[u]=0,Ir(d,n)}let y=[];for(let[d,f]of l){let p=o.map(()=>":");p[u]=`${d}:${f}`,y.push(r.slice(...p))}return qr(y,u)}function Sc(r,t,e,n){let o=e instanceof v?e:rr(e,r.dtype);if(n===void 0){let m=r.flatten(),y=o.flatten(),d=t<0?m.size+t:t;if(d<0||d>m.size)throw new Error(`index ${t} is out of bounds for array of size ${m.size}`);let f=d>0?m.slice(`0:${d}`):null,p=d<m.size?m.slice(`${d}:`):null,g=[];return f&&g.push(f),g.push(y),p&&g.push(p),qr(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 l=[];if(c>0){let m=a.map(()=>":");m[s]=`0:${c}`,l.push(r.slice(...m))}if(l.push(o),c<i){let m=a.map(()=>":");m[s]=`${c}:`,l.push(r.slice(...m))}return qr(l,s)}function xc(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((p,g)=>p+s[g][0]+s[g][1]),c=i.reduce((p,g)=>p*g,1),l=j(u),m=new l(c),y=B(u);e==="constant"&&(y?m.fill(BigInt(n)):m.fill(n));let d=new Array(a).fill(0);for(let p=0;p<c;p++){let g=!0,h=[];for(let A=0;A<a;A++){let[S]=s[A],x=d[A]-S;if(x<0||x>=o[A]){g=!1;break}h.push(x)}let b;if(g)b=r.get(h);else if(e==="constant"){for(let A=a-1;A>=0&&(d[A]++,!(d[A]<i[A]));A--)d[A]=0;continue}else{let A=[];for(let S=0;S<a;S++){let[x]=s[S],w=d[S]-x,N=o[S];w<0?e==="edge"?w=0:e==="reflect"?(w=-w,w>=N&&(w=N-1)):e==="symmetric"?(w=-w-1,w>=N&&(w=N-1),w<0&&(w=0)):e==="wrap"&&(w=(w%N+N)%N):w>=N&&(e==="edge"?w=N-1:e==="reflect"?(w=2*N-w-2,w<0&&(w=0)):e==="symmetric"?(w=2*N-w-1,w<0&&(w=0)):e==="wrap"&&(w=w%N)),A.push(Math.max(0,Math.min(N-1,w)))}b=r.get(A)}y?m[p]=typeof b=="bigint"?b:BigInt(Number(b)):m[p]=Number(b);for(let A=a-1;A>=0&&(d[A]++,!(d[A]<i[A]));A--)d[A]=0}let f=D.fromData(m,i,u);return new v(f)}function Dc(r,t){let e=qt(r.storage,t);return v._fromStorage(e,r.base??r)}function Nc(...r){let t=r.map(n=>n.storage);return os(t).map((n,o)=>v._fromStorage(n,r[o].base??r[o]))}function wc(...r){return ge(...r)}function Ic(r,t,e){return r.take(t,e)}function zc(r,t,e){r.put(t,e)}function _c(r,t,e=0){return r.iindex(t,e)}function Fc(r,t,e){return r.bindex(t,e)}function Mc(r,t,e){if(e!==void 0)throw new Error("copyto with where parameter is not yet implemented");let n=r.storage,o=r.shape,a=r.size,u=r.dtype;if(typeof t=="number"||typeof t=="bigint"){r.fill(t);return}let s=t.storage,i=t.shape,c=gr([i,o]);if(!c)throw new Error(`could not broadcast input array from shape (${i.join(",")}) into shape (${o.join(",")})`);if(c.length!==o.length||!c.every((m,y)=>m===o[y]))throw new Error(`could not broadcast input array from shape (${i.join(",")}) into shape (${o.join(",")})`);let l=qt(s,o);if(B(u))for(let m=0;m<a;m++){let y=l.iget(m),d=typeof y=="bigint"?y:BigInt(Math.round(Number(y)));n.iset(m,d)}else if(u==="bool")for(let m=0;m<a;m++){let y=l.iget(m);n.iset(m,y?1:0)}else for(let m=0;m<a;m++){let y=l.iget(m);n.iset(m,Number(y))}}function Bc(r,t){let e=t.map(o=>o.storage),n=is(r.storage,e);return v._fromStorage(n)}function vc(r,t,e=!1){return us(r.storage,t.storage,e)}function Tc(r,t){return Oo(r.storage,t.storage)}function Tn(r,t){return v._fromStorage(_e(r.storage,t))}function En(r,t){return v._fromStorage(Fe(r.storage,t))}function On(r,t,e=!1){return r.max(t,e)}function Cn(r,t,e=!1){return r.min(t,e)}function Ec(r,t,e=!1){let n=Me(r.storage,t,e);return typeof n=="number"||n instanceof O?n:v._fromStorage(n)}function Oc(r,t,e=!1){let n=Be(r.storage,t,e);return typeof n=="number"?n:v._fromStorage(n)}function Cc(r,t,e,n=!1){let o=ve(r.storage,t,e,n);return typeof o=="number"?o:v._fromStorage(o)}function Uc(r,t,e,n=!1){let o=Hr(r.storage,t,e,n);return typeof o=="number"?o:v._fromStorage(o)}function $c(r,t,e,n=!1){let o=e?e.storage:void 0,a=at(r.storage,t,o,n);return typeof a=="number"||a instanceof O?a:v._fromStorage(a)}function Rc(r,t,e=!1){let n=Ot(r.storage,t,e);return typeof n=="number"||n instanceof O?n:v._fromStorage(n)}function kc(r,t,e=!1){let n=Ct(r.storage,t,e);return typeof n=="number"||n instanceof O?n:v._fromStorage(n)}function qc(r,t,e=!1){let n=Ut(r.storage,t,e);return typeof n=="number"||n instanceof O?n:v._fromStorage(n)}function Vc(r,t,e=0,n=!1){let o=Yr(r.storage,t,e,n);return typeof o=="number"?o:v._fromStorage(o)}function Pc(r,t,e=0,n=!1){let o=Te(r.storage,t,e,n);return typeof o=="number"?o:v._fromStorage(o)}function jc(r,t,e=!1){let n=st(r.storage,t,e);return typeof n=="number"||n instanceof O?n:v._fromStorage(n)}function Lc(r,t,e=!1){let n=it(r.storage,t,e);return typeof n=="number"||n instanceof O?n:v._fromStorage(n)}function Wc(r,t){let e=ut(r.storage,t);return typeof e=="number"?e:v._fromStorage(e)}function Gc(r,t){let e=ct(r.storage,t);return typeof e=="number"?e:v._fromStorage(e)}function Zc(r,t){return v._fromStorage(Ee(r.storage,t))}function Yc(r,t){return v._fromStorage(Oe(r.storage,t))}function Hc(r,t,e=!1){let n=$t(r.storage,t,e);return typeof n=="number"?n:v._fromStorage(n)}function Jc(r){return r.cbrt()}function Xc(r){return r.fabs()}function Qc(r,t){return r.divmod(t)}function Kc(r){return r.square()}function rl(r,t){return r.remainder(t)}function tl(r,t){return r.heaviside(t)}function el(r,t){let e=typeof t=="number"?t:t.storage;return v._fromStorage(bo(r.storage,e))}function nl(r,t){let e=typeof t=="number"?t:t.storage;return v._fromStorage(ho(r.storage,e))}function ol(r){let[t,e]=So(r.storage);return[v._fromStorage(t),v._fromStorage(e)]}function al(r,t){let e=typeof t=="number"?t:t.storage;return v._fromStorage(xo(r.storage,e))}function sl(r,t){let e=typeof t=="number"?t:t.storage;return v._fromStorage(Do(r.storage,e))}function il(r,t){let e=typeof t=="number"?t:t.storage;return v._fromStorage(No(r.storage,e))}function ul(r){let[t,e]=wo(r.storage);return[v._fromStorage(t),v._fromStorage(e)]}function cl(r,t){return r.bitwise_and(t)}function ll(r,t){return r.bitwise_or(t)}function fl(r,t){return r.bitwise_xor(t)}function ml(r){return r.bitwise_not()}function pl(r){return r.invert()}function yl(r,t){return r.left_shift(t)}function dl(r,t){return r.right_shift(t)}function gl(r,t=-1,e="big"){let n=Ts(r.storage,t,e);return v._fromStorage(n)}function Al(r,t=-1,e=-1,n="big"){let o=Es(r.storage,t,e,n);return v._fromStorage(o)}function bl(r,t){return r.logical_and(t)}function hl(r,t){return r.logical_or(t)}function Sl(r){return r.logical_not()}function xl(r,t){return r.logical_xor(t)}function Dl(r){return r.isfinite()}function Nl(r){return r.isinf()}function wl(r){return r.isnan()}function Il(r){return r.isnat()}function zl(r,t){return r.copysign(t)}function _l(r){return r.signbit()}function Fl(r,t){return r.nextafter(t)}function Ml(r){return r.spacing()}function Bl(r){return v._fromStorage(Ys(r.storage))}function vl(r){return Hs(r.storage)}function Tl(r){return v._fromStorage(Js(r.storage))}function El(r){return Xs(r.storage)}function Ol(r){return v._fromStorage(ii(r.storage))}function Cl(r){return v._fromStorage(ui(r.storage))}function Un(r){return v._fromStorage(ci(r.storage))}function $l(r,t=!1){return v._fromStorage(li(r.storage,t))}function Rl(r){return v._fromStorage(Qs(r.storage))}function kl(r){return v._fromStorage(Ks(r.storage))}function ql(r){return ri(r.storage)}function Vl(r,t=100){return v._fromStorage(ti(r.storage,t))}function Pl(r){return ei(r)}function jl(r){return ni(r)}function Ll(r,t){return oi(r,t)}function Wl(r,t){return ai(r,t)}function Gl(r,...t){let e=t.map(o=>o.storage),n=ma(r,...e);return typeof n=="number"||typeof n=="bigint"||n instanceof O?n:v._fromStorage(n)}function Yl(r,t,e){return v._fromStorage(cs(r.storage,t.storage,e))}function Hl(r,t,e,n){ls(r.storage,t.storage,e.storage,n)}function Jl(r,t,e){let n=e instanceof v?e.storage:e;fs(r.storage,t.storage,n)}function Xl(r,t,e){return v._fromStorage(Ge(r.storage,t.storage,e))}function Ql(r,t,e=0){let n=r.map(a=>a.storage),o=t.map(a=>a.storage);return v._fromStorage(ms(n,o,e))}function Kl(r,t,e){ps(r.storage,t.storage,e.storage)}function rf(r,t,e=!1){let n=typeof t=="number"?t:t.storage;Ds(r.storage,n,e)}function tf(r,t=2){return Ze(r,t).map(n=>v._fromStorage(n))}function ef(r){return ys(r.storage).map(e=>v._fromStorage(e))}function nf(r,t=0,e){return Ye(r,t,e).map(o=>v._fromStorage(o))}function of(r,t=0){return ds(r.storage,t).map(n=>v._fromStorage(n))}function af(r,t=0,e){return He(r,t,e).map(o=>v._fromStorage(o))}function sf(r,t=0){return gs(r.storage,t).map(n=>v._fromStorage(n))}function uf(r,t,e=0){return As(r,(a,u)=>t(a,u).storage,e).map(a=>v._fromStorage(a))}function cf(r,t="int32"){return v._fromStorage(bs(r,t))}function lf(...r){return hs(...r.map(e=>e.storage)).map(e=>v._fromStorage(e))}function ff(r,t,e="raise"){let n=r.map(o=>o.storage);return v._fromStorage(Ss(n,t,e))}function mf(r,t,e="C"){let n=r instanceof v?r.storage:r;return xs(n,t,e).map(a=>v._fromStorage(a))}function pf(r,t=-1){return v._fromStorage(Xe(r.storage,t))}function yf(r,t=-1){return v._fromStorage(Qe(r.storage,t))}function df(r){let t=r.map(e=>e.storage);return v._fromStorage(mi(t))}function gf(r,t,e=-1){return v._fromStorage(Ke(r.storage,t,e))}function Af(r,t,e=-1){return v._fromStorage(rn(r.storage,t,e))}function bf(r){return v._fromStorage(pi(r.storage))}function hf(r){return jt(r.storage).map(e=>v._fromStorage(e))}function Sf(r){return v._fromStorage(tn(r.storage))}function xf(r){return v._fromStorage(yi(r.storage))}function Df(r,t,e){let n=di(r.storage,t?.storage,e?.storage);return Array.isArray(n)?n.map(o=>v._fromStorage(o)):v._fromStorage(n)}function Nf(r,t,e="left"){return v._fromStorage(en(r.storage,t.storage,e))}function wf(r,t){return v._fromStorage(gi(r.storage,t.storage))}function If(r,t){let e=nn(r.storage,t);return typeof e=="number"?e:v._fromStorage(e)}function Wt(r,t=0){return v._fromStorage(on(r.storage,t))}function zf(r){return v._fromStorage(an(r.storage))}function _f(r){return v._fromStorage(sn(r.storage))}function Ff(r){return v._fromStorage(un(r.storage))}function Mf(r){return v._fromStorage(cn(r.storage))}function Bf(r){return v._fromStorage(ln(r.storage))}function vf(r,t=!1,e=!1,n=!1){let o=vr(r.storage,t,e,n);if(o instanceof D)return v._fromStorage(o);let a={values:v._fromStorage(o.values)};return o.indices&&(a.indices=v._fromStorage(o.indices)),o.inverse&&(a.inverse=v._fromStorage(o.inverse)),o.counts&&(a.counts=v._fromStorage(o.counts)),a}function Tf(r,t){return v._fromStorage(Si(r.storage,t.storage))}function Ef(r,t){return v._fromStorage(xi(r.storage,t.storage))}function Of(r,t){return v._fromStorage(mn(r.storage,t.storage))}function Cf(r,t){return v._fromStorage(Di(r.storage,t.storage))}function Uf(r,t){return v._fromStorage(Ni(r.storage,t.storage))}function $f(r,t){return v._fromStorage(wi(r.storage,t.storage))}function Rf(r,t=1,e=-1){return v._fromStorage(pn(r.storage,t,e))}function kf(r,t=null,e=null){return v._fromStorage(zi(r.storage,t,e))}function qf(r,t=1,e=null){let n=_i(r.storage,t,e);return Array.isArray(n)?n.map(o=>v._fromStorage(o)):v._fromStorage(n)}function Vf(r,t,e=-1,n=-1,o=-1){return v._fromStorage(Fi(r.storage,t.storage,e,n,o))}function Pf(r,t,e=0){return v._fromStorage(Bi(r.storage,t?.storage,e))}function jf(r,t,e=!1){return v._fromStorage(vi(r.storage,t.storage,e))}function Lf(r,t=10,e,n=!1,o){let a=Ti(r.storage,typeof t=="number"?t:t.storage,e,n,o?.storage);return[v._fromStorage(a.hist),v._fromStorage(a.bin_edges)]}function Wf(r,t,e=10,n,o=!1,a){let u;typeof e=="number"?u=e:Array.isArray(e)&&e.length===2?typeof e[0]=="number"?u=e:u=[e[0].storage,e[1].storage]:u=10;let s=Ei(r.storage,t.storage,u,n,o,a?.storage);return[v._fromStorage(s.hist),v._fromStorage(s.x_edges),v._fromStorage(s.y_edges)]}function Gf(r,t=10,e,n=!1,o){let a=Oi(r.storage,t,e,n,o?.storage);return[v._fromStorage(a.hist),a.edges.map(u=>v._fromStorage(u))]}function Zf(r,t,e="full"){return v._fromStorage(yn(r.storage,t.storage,e))}function Yf(r,t,e="full"){return v._fromStorage(Ci(r.storage,t.storage,e))}function Hf(r,t,e=!0,n=!1,o){return v._fromStorage(dn(r.storage,t?.storage,e,n,o))}function Jf(r,t,e=!0){return v._fromStorage(Ui(r.storage,t?.storage,e))}var v,Ul,Zl,ht=W(()=>{"use strict";Qn();J();xr();X();Bt();Io();Co();$o();$e();_a();ka();Ja();ns();Ns();Os();si();fi();Ai();hi();Ii();Mi();$i();v=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(){return this.transpose()}get itemsize(){return Mt(this._storage.dtype)}get nbytes(){return this.size*this.itemsize}fill(t){let e=this._storage.dtype,n=this.size;if(B(e)){let o=typeof t=="bigint"?t:BigInt(Math.round(Number(t)));for(let a=0;a<n;a++)this._storage.iset(a,o)}else if(e==="bool"){let o=t?1:0;for(let a=0;a<n;a++)this._storage.iset(a,o)}else{let o=Number(t);for(let a=0;a<n;a++)this._storage.iset(a,o)}}*[Symbol.iterator](){if(this.ndim===0)yield this._storage.iget(0);else if(this.ndim===1)for(let t=0;t<this.shape[0];t++)yield this._storage.iget(t);else for(let t=0;t<this.shape[0];t++)yield this.slice(String(t))}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((a,u)=>{let s=a;if(s<0&&(s=this.shape[u]+s),s<0||s>=this.shape[u])throw new Error(`Index ${a} is out of bounds for axis ${u} with size ${this.shape[u]}`);return s}),o=this.dtype;if(M(o))this._storage.set(n,e);else if(B(o)){let a=e instanceof O?e.re:Number(e),u=typeof e=="bigint"?e:BigInt(Math.round(a));this._storage.set(n,u)}else if(o==="bool"){let u=(e instanceof O?e.re:Number(e))?1:0;this._storage.set(n,u)}else{let a=e instanceof O?e.re: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=j(t);if(!u)throw new Error(`Cannot convert to dtype ${t}`);let s=new u(a),i=this.data;if(B(n)&&!B(t)){let l=i;if(t==="bool")for(let m=0;m<a;m++)s[m]=l[m]!==BigInt(0)?1:0;else for(let m=0;m<a;m++)s[m]=Number(l[m])}else if(!B(n)&&B(t)){let l=i;for(let m=0;m<a;m++)s[m]=BigInt(Math.round(Number(l[m])))}else if(t==="bool"){let l=i;for(let m=0;m<a;m++)s[m]=l[m]!==0?1:0}else if(n==="bool"&&!B(t)){let l=i;for(let m=0;m<a;m++)s[m]=l[m]}else if(!B(n)&&!B(t)){let l=i;for(let m=0;m<a;m++)s[m]=l[m]}else{let l=i;for(let m=0;m<a;m++)s[m]=l[m]}let c=D.fromData(s,o,t);return new r(c)}add(t){let e=typeof t=="number"?t:t._storage,n=eo(this._storage,e);return r._fromStorage(n)}subtract(t){let e=typeof t=="number"?t:t._storage,n=no(this._storage,e);return r._fromStorage(n)}multiply(t){let e=typeof t=="number"?t:t._storage,n=oo(this._storage,e);return r._fromStorage(n)}divide(t){let e=typeof t=="number"?t:t._storage,n=ao(this._storage,e);return r._fromStorage(n)}mod(t){let e=typeof t=="number"?t:t._storage,n=Tt(this._storage,e);return r._fromStorage(n)}floor_divide(t){let e=typeof t=="number"?t:t._storage,n=be(this._storage,e);return r._fromStorage(n)}positive(){let t=co(this._storage);return r._fromStorage(t)}reciprocal(){let t=lo(this._storage);return r._fromStorage(t)}sqrt(){let t=Fa(this._storage);return r._fromStorage(t)}power(t){let e=typeof t=="number"?t:t._storage,n=Ma(this._storage,e);return r._fromStorage(n)}exp(){let t=Ba(this._storage);return r._fromStorage(t)}exp2(){let t=va(this._storage);return r._fromStorage(t)}expm1(){let t=Ta(this._storage);return r._fromStorage(t)}log(){let t=Ea(this._storage);return r._fromStorage(t)}log2(){let t=Oa(this._storage);return r._fromStorage(t)}log10(){let t=Ca(this._storage);return r._fromStorage(t)}log1p(){let t=Ua(this._storage);return r._fromStorage(t)}logaddexp(t){let e=typeof t=="number"?t:t._storage,n=$a(this._storage,e);return r._fromStorage(n)}logaddexp2(t){let e=typeof t=="number"?t:t._storage,n=Ra(this._storage,e);return r._fromStorage(n)}absolute(){let t=so(this._storage);return r._fromStorage(t)}negative(){let t=io(this._storage);return r._fromStorage(t)}sign(){let t=uo(this._storage);return r._fromStorage(t)}around(t=0){let e=on(this._storage,t);return r._fromStorage(e)}round(t=0){return this.around(t)}ceil(){let t=an(this._storage);return r._fromStorage(t)}fix(){let t=sn(this._storage);return r._fromStorage(t)}floor(){let t=un(this._storage);return r._fromStorage(t)}rint(){let t=cn(this._storage);return r._fromStorage(t)}trunc(){let t=ln(this._storage);return r._fromStorage(t)}sin(){let t=qa(this._storage);return r._fromStorage(t)}cos(){let t=Va(this._storage);return r._fromStorage(t)}tan(){let t=Pa(this._storage);return r._fromStorage(t)}arcsin(){let t=ja(this._storage);return r._fromStorage(t)}arccos(){let t=La(this._storage);return r._fromStorage(t)}arctan(){let t=Wa(this._storage);return r._fromStorage(t)}arctan2(t){let e=typeof t=="number"?t:t._storage,n=Ga(this._storage,e);return r._fromStorage(n)}hypot(t){let e=typeof t=="number"?t:t._storage,n=Za(this._storage,e);return r._fromStorage(n)}degrees(){let t=Ya(this._storage);return r._fromStorage(t)}radians(){let t=Ha(this._storage);return r._fromStorage(t)}sinh(){let t=Xa(this._storage);return r._fromStorage(t)}cosh(){let t=Qa(this._storage);return r._fromStorage(t)}tanh(){let t=Ka(this._storage);return r._fromStorage(t)}arcsinh(){let t=rs(this._storage);return r._fromStorage(t)}arccosh(){let t=ts(this._storage);return r._fromStorage(t)}arctanh(){let t=es(this._storage);return r._fromStorage(t)}greater(t){let e=typeof t=="number"?t:t._storage,n=_o(this._storage,e);return r._fromStorage(n)}greater_equal(t){let e=typeof t=="number"?t:t._storage,n=Fo(this._storage,e);return r._fromStorage(n)}less(t){let e=typeof t=="number"?t:t._storage,n=Mo(this._storage,e);return r._fromStorage(n)}less_equal(t){let e=typeof t=="number"?t:t._storage,n=Bo(this._storage,e);return r._fromStorage(n)}equal(t){let e=typeof t=="number"?t:t._storage,n=vo(this._storage,e);return r._fromStorage(n)}not_equal(t){let e=typeof t=="number"?t:t._storage,n=To(this._storage,e);return r._fromStorage(n)}isclose(t,e=1e-5,n=1e-8){let o=typeof t=="number"?t:t._storage,a=he(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 Eo(this._storage,o,e,n)}bitwise_and(t){let e=typeof t=="number"?t:t._storage,n=zs(this._storage,e);return r._fromStorage(n)}bitwise_or(t){let e=typeof t=="number"?t:t._storage,n=_s(this._storage,e);return r._fromStorage(n)}bitwise_xor(t){let e=typeof t=="number"?t:t._storage,n=Fs(this._storage,e);return r._fromStorage(n)}bitwise_not(){let t=Je(this._storage);return r._fromStorage(t)}invert(){let t=Ms(this._storage);return r._fromStorage(t)}left_shift(t){let e=typeof t=="number"?t:t._storage,n=Bs(this._storage,e);return r._fromStorage(n)}right_shift(t){let e=typeof t=="number"?t:t._storage,n=vs(this._storage,e);return r._fromStorage(n)}logical_and(t){let e=typeof t=="number"?t:t._storage,n=Us(this._storage,e);return r._fromStorage(n)}logical_or(t){let e=typeof t=="number"?t:t._storage,n=$s(this._storage,e);return r._fromStorage(n)}logical_not(){let t=Rs(this._storage);return r._fromStorage(t)}logical_xor(t){let e=typeof t=="number"?t:t._storage,n=ks(this._storage,e);return r._fromStorage(n)}isfinite(){let t=qs(this._storage);return r._fromStorage(t)}isinf(){let t=Vs(this._storage);return r._fromStorage(t)}isnan(){let t=Ps(this._storage);return r._fromStorage(t)}isnat(){let t=js(this._storage);return r._fromStorage(t)}copysign(t){let e=typeof t=="number"?t:t._storage,n=Ls(this._storage,e);return r._fromStorage(n)}signbit(){let t=Ws(this._storage);return r._fromStorage(t)}nextafter(t){let e=typeof t=="number"?t:t._storage,n=Gs(this._storage,e);return r._fromStorage(n)}spacing(){let t=Zs(this._storage);return r._fromStorage(t)}sum(t,e=!1){let n=ot(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}mean(t,e=!1){let n=Et(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}max(t,e=!1){let n=Gr(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}min(t,e=!1){let n=Zr(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}prod(t,e=!1){let n=xe(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}argmin(t){let e=De(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}argmax(t){let e=Ne(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}var(t,e=0,n=!1){let o=we(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}std(t,e=0,n=!1){let o=Uo(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}all(t,e=!1){let n=Ie(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}any(t,e=!1){let n=ze(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}cumsum(t){return r._fromStorage(_e(this._storage,t))}cumprod(t){return r._fromStorage(Fe(this._storage,t))}ptp(t,e=!1){let n=Me(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}median(t,e=!1){let n=Be(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}percentile(t,e,n=!1){let o=ve(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}quantile(t,e,n=!1){let o=Hr(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}average(t,e){let n=at(this._storage,e,t?.storage);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}nansum(t,e=!1){let n=Ot(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}nanprod(t,e=!1){let n=Ct(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}nanmean(t,e=!1){let n=Ut(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}nanvar(t,e=0,n=!1){let o=Yr(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanstd(t,e=0,n=!1){let o=Te(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanmin(t,e=!1){let n=st(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}nanmax(t,e=!1){let n=it(this._storage,t,e);return typeof n=="number"||n instanceof O?n:r._fromStorage(n)}nanargmin(t){let e=ut(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}nanargmax(t){let e=ct(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}nancumsum(t){return r._fromStorage(Ee(this._storage,t))}nancumprod(t){return r._fromStorage(Oe(this._storage,t))}nanmedian(t,e=!1){let n=$t(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}sort(t=-1){return r._fromStorage(Xe(this._storage,t))}argsort(t=-1){return r._fromStorage(Qe(this._storage,t))}partition(t,e=-1){return r._fromStorage(Ke(this._storage,t,e))}argpartition(t,e=-1){return r._fromStorage(rn(this._storage,t,e))}nonzero(){return jt(this._storage).map(e=>r._fromStorage(e))}argwhere(){return r._fromStorage(tn(this._storage))}searchsorted(t,e="left"){return r._fromStorage(en(this._storage,t._storage,e))}diff(t=1,e=-1){return r._fromStorage(pn(this._storage,t,e))}reshape(...t){let e=t.length===1&&Array.isArray(t[0])?t[0]:t,n=ir(this._storage,e),a=n.data===this.data?this._base??this:void 0;return r._fromStorage(n,a)}flatten(){let t=Rt(this._storage);return r._fromStorage(t)}ravel(){let t=Jr(this._storage),n=t.data===this.data?this._base??this:void 0;return r._fromStorage(t,n)}transpose(t){let e=ft(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}squeeze(t){let e=Ro(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}expand_dims(t){let e=lt(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}swapaxes(t,e){let n=ko(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}moveaxis(t,e){let n=Ce(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}repeat(t,e){let n=Yo(this._storage,t,e);return r._fromStorage(n)}take(t,e){let n=as(this._storage,t,e);return r._fromStorage(n)}put(t,e){let n=e instanceof r?e._storage:e;ss(this._storage,t,n)}iindex(t,e=0){let n;if(t instanceof r){n=[];for(let o=0;o<t.size;o++){let a=t.storage.iget(o),u=typeof a=="bigint"?Number(a):a instanceof O?a.re:a;n.push(u)}}else Array.isArray(t)&&t.length>0&&Array.isArray(t[0])?n=t.flat():n=t;return this.take(n,e)}bindex(t,e){return r._fromStorage(Ge(t._storage,this._storage,e))}matmul(t){let e=Ar(this._storage,t._storage);return r._fromStorage(e)}dot(t){let e=ke(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"||e instanceof O?e:r._fromStorage(e)}trace(){return ua(this._storage)}inner(t){let e=ca(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"||e instanceof O?e:r._fromStorage(e)}outer(t){let e=qe(this._storage,t._storage);return r._fromStorage(e)}tensordot(t,e=2){let n=la(this._storage,t._storage,e);return typeof n=="number"||typeof n=="bigint"||n instanceof O?n:r._fromStorage(n)}cbrt(){let t=fo(this._storage);return r._fromStorage(t)}fabs(){let t=mo(this._storage);return r._fromStorage(t)}divmod(t){let e=typeof t=="number"?t:t._storage,[n,o]=po(this._storage,e);return[r._fromStorage(n),r._fromStorage(o)]}square(){let t=yo(this._storage);return r._fromStorage(t)}remainder(t){let e=typeof t=="number"?t:t._storage,n=go(this._storage,e);return r._fromStorage(n)}heaviside(t){let e=typeof t=="number"?t:t._storage,n=Ao(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 l=Jn(i);return Xn(l,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],l=this._storage.strides[i];if(a+=c.start*l,!c.isIndex){let m;c.step>0?m=Math.max(0,Math.ceil((c.stop-c.start)/c.step)):m=Math.max(0,Math.ceil((c.start-c.stop)/Math.abs(c.step))),n.push(m),o.push(l*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)}};Ul=Un;Zl={cross:(r,t,e=-1,n=-1,o=-1,a)=>{let u=ya(r.storage,t.storage,e,n,o,a);return typeof u=="number"?u:v._fromStorage(u)},norm:(r,t=null,e=null,n=!1)=>{let o=da(r.storage,t,e,n);return typeof o=="number"?o:v._fromStorage(o)},vector_norm:(r,t=2,e,n=!1)=>{let o=Qr(r.storage,t,e,n);return typeof o=="number"?o:v._fromStorage(o)},matrix_norm:(r,t="fro",e=!1)=>{let n=kr(r.storage,t,e);return typeof n=="number"?n:v._fromStorage(n)},qr:(r,t="reduced")=>{let e=Ve(r.storage,t);return e instanceof D?v._fromStorage(e):"q"in e&&"r"in e?{q:v._fromStorage(e.q),r:v._fromStorage(e.r)}:{h:v._fromStorage(e.h),tau:v._fromStorage(e.tau)}},cholesky:(r,t=!1)=>v._fromStorage(ga(r.storage,t)),svd:(r,t=!0,e=!0)=>{let n=Aa(r.storage,t,e);return"u"in n?{u:v._fromStorage(n.u),s:v._fromStorage(n.s),vt:v._fromStorage(n.vt)}:v._fromStorage(n)},det:r=>ba(r.storage),inv:r=>v._fromStorage(kt(r.storage)),solve:(r,t)=>v._fromStorage(ha(r.storage,t.storage)),lstsq:(r,t,e=null)=>{let n=Sa(r.storage,t.storage,e);return{x:v._fromStorage(n.x),residuals:v._fromStorage(n.residuals),rank:n.rank,s:v._fromStorage(n.s)}},cond:(r,t=2)=>xa(r.storage,t),matrix_rank:(r,t)=>Da(r.storage,t),matrix_power:(r,t)=>v._fromStorage(Na(r.storage,t)),pinv:(r,t=1e-15)=>v._fromStorage(wa(r.storage,t)),eig:r=>{let t=Le(r.storage);return{w:v._fromStorage(t.w),v:v._fromStorage(t.v)}},eigh:(r,t="L")=>{let e=We(r.storage,t);return{w:v._fromStorage(e.w),v:v._fromStorage(e.v)}},eigvals:r=>v._fromStorage(Ia(r.storage)),eigvalsh:(r,t="L")=>v._fromStorage(za(r.storage,t))}});function $n(){let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256}function Qf(r){if(r.startsWith("[")||r.startsWith("("))throw new zr(`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 Xf)throw new zr(`Unsupported dtype: ${Xf[n]} (${r}). Use the 'force' parameter to skip arrays with unsupported dtypes.`);let o=Sy[e];if(!o)throw new zr(`Unknown or unsupported dtype descriptor: ${r}. Supported types: ${Gt.join(", ")}. Use the 'force' parameter to skip arrays with unsupported dtypes.`);let a=$n(),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 St,Gt,Sy,xt,Xf,zr,cr,Dt=W(()=>{"use strict";St=new Uint8Array([147,78,85,77,80,89]),Gt=["float64","float32","complex128","complex64","int64","int32","int16","int8","uint64","uint32","uint16","uint8","bool"];Sy={f8:"float64",f4:"float32",c16:"complex128",c8:"complex64",i8:"int64",i4:"int32",i2:"int16",i1:"int8",u8:"uint64",u4:"uint32",u2:"uint16",u1:"uint8",b1:"bool"},xt={float64:"<f8",float32:"<f4",complex128:"<c16",complex64:"<c8",int64:"<i8",int32:"<i4",int16:"<i2",int8:"|i1",uint64:"<u8",uint32:"<u4",uint16:"<u2",uint8:"|u1",bool:"|b1"},Xf={S:"byte strings",U:"Unicode strings",O:"Python objects",V:"structured arrays (void)",M:"datetime64",m:"timedelta64"};zr=class extends Error{constructor(t){super(t),this.name="UnsupportedDTypeError"}},cr=class extends Error{constructor(t){super(t),this.name="InvalidNpyError"}}});function Ur(r){let t=r instanceof ArrayBuffer?new Uint8Array(r):r,e=Zt(t);return Yt(t,e)}function Zt(r){if(r.length<10)throw new cr("File too small to be a valid NPY file");for(let c=0;c<St.length;c++)if(r[c]!==St[c])throw new cr("Invalid NPY magic number");let t=r[6],e=r[7];if(t!==1&&t!==2&&t!==3)throw new cr(`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 cr("File truncated: header extends beyond file");let u=r.slice(o,a),s=new TextDecoder("utf-8").decode(u).trim(),i=xy(s);return{version:{major:t,minor:e},header:i,dataOffset:a}}function Yt(r,t){let{header:e,dataOffset:n}=t,{dtype:o,needsByteSwap:a,itemsize:u}=Qf(e.descr),s=e.shape.reduce((p,g)=>p*g,1),i=s*u,c=r.length-n;if(c<i)throw new cr(`File truncated: expected ${i} bytes of data, got ${c}`);let l=new ArrayBuffer(i);new Uint8Array(l).set(r.subarray(n,n+i));let y=Dy(l,o,s,a,u),d=e.shape,f;if(e.fortran_order&&d.length>1){let p=[...d].reverse(),g=D.fromData(y,p,o);f=Ny(g,p),d=e.shape}else f=D.fromData(y,[...d],o);return new v(f)}function xy(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 cr(`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 cr(`Invalid shape value: ${i}`);return c}),{descr:o,fortran_order:a,shape:s}}function Dy(r,t,e,n,o){let a=j(t);if(!a)throw new cr(`Cannot create array for dtype: ${t}`);let u=M(t),s=u?e*2:e;if(!n)return new a(r,0,s);let i=new Uint8Array(r),c=new Uint8Array(r.byteLength);if(u){let l=o/2;for(let m=0;m<e*2;m++){let y=m*l;for(let d=0;d<l;d++)c[y+d]=i[y+l-1-d]}}else for(let l=0;l<e;l++){let m=l*o;for(let y=0;y<o;y++)c[m+y]=i[m+o-1-y]}return new a(c.buffer,0,s)}function Ny(r,t){let e=t.length,n=r.size,o=r.dtype,a=j(o);if(!a)throw new cr(`Cannot create array for dtype: ${o}`);let u=new a(n),s=[...t].reverse(),i=Kf(t),c=Kf(s),l=new Array(e).fill(0);for(let m=0;m<n;m++){let y=m;for(let f=0;f<e;f++){let p=i[f];l[f]=Math.floor(y/p),y=y%p}let d=0;for(let f=0;f<e;f++)d+=l[e-1-f]*c[f];B(o),u[d]=r.iget(m)}return D.fromData(u,s,o)}function Kf(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 Ht=W(()=>{"use strict";ht();X();J();Dt()});function Tr(r){let t=r.shape,e=r.dtype,n=xt[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),l=c.length,m=r.size,y=Mt(e),d=m*y,f=u+l+d,p=new Uint8Array(f);p.set(St,0),p[6]=3,p[7]=0,p[8]=l&255,p[9]=l>>8&255,p[10]=l>>16&255,p[11]=l>>24&255,p.set(c,u);let g=u+l;return wy(r,p.subarray(g),y),p}function wy(r,t,e){let n=r.dtype,o=r.size,a=$n(),u=B(n),s=M(n),i=r._storage;if(i.isCContiguous&&i.offset===0&&a){let l=i.data,m=new Uint8Array(l.buffer,l.byteOffset,o*e);t.set(m)}else{let l=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let m=0;m<o;m++){let y=i.iget(m),d=m*e;u?Iy(l,d,y,n==="uint64"):s?zy(l,d,y,n):_y(l,d,y,n)}}}function Iy(r,t,e,n){n?r.setBigUint64(t,e,!0):r.setBigInt64(t,e,!0)}function zy(r,t,e,n){n==="complex128"?(r.setFloat64(t,e.re,!0),r.setFloat64(t+8,e.im,!0)):(r.setFloat32(t,e.re,!0),r.setFloat32(t+4,e.im,!0))}function _y(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 Jt=W(()=>{"use strict";J();Dt()});function Rn(r){let t=4294967295;for(let e=0;e<r.length;e++)t=Fy[(t^r[e])&255]^t>>>8;return(t^4294967295)>>>0}var Fy,kn=W(()=>{"use strict";Fy=(()=>{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 rm(r){let t=em(r),e=new Map;for(let n of t){let o=await My(n);e.set(n.name,o)}return e}function tm(r){let t=em(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 em(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 m=e.getUint16(i+10,!0),y=e.getUint32(i+16,!0),d=e.getUint32(i+20,!0),f=e.getUint32(i+24,!0),p=e.getUint16(i+28,!0),g=e.getUint16(i+30,!0),h=e.getUint16(i+32,!0),b=e.getUint32(i+42,!0),A=t.slice(i+46,i+46+p),S=new TextDecoder("utf-8").decode(A);s.push({name:S,compressionMethod:m,crc32:y,compressedSize:d,uncompressedSize:f,localHeaderOffset:b}),i=i+46+p+g+h}for(let c of s){let l=c.localHeaderOffset;if(e.getUint32(l,!0)!==67324752)throw new Error(`Invalid local file header at offset ${l}`);let y=e.getUint16(l+26,!0),d=e.getUint16(l+28,!0),f=l+30+y+d,p=t.slice(f,f+c.compressedSize);n.push({name:c.name,compressedData:p,compressionMethod:c.compressionMethod,crc32:c.crc32,compressedSize:c.compressedSize,uncompressedSize:c.uncompressedSize})}return n}async function My(r){if(r.compressionMethod===0)return r.compressedData;if(r.compressionMethod===8)return await By(r.compressedData);throw new Error(`Unsupported compression method: ${r.compressionMethod}`)}async function By(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:l}=await o.read();if(c)break;a.push(l)}let u=a.reduce((c,l)=>c+l.length,0),s=new Uint8Array(u),i=0;for(let c of a)s.set(c,i),i+=c.length;return s}var nm=W(()=>{"use strict";kn()});var am={};ye(am,{loadNpz:()=>Xt,loadNpzSync:()=>Qt,parseNpz:()=>Vr,parseNpzSync:()=>wt});async function Vr(r,t={}){let e=t.force??!1,n=await rm(r);return om(n,e)}function wt(r,t={}){let e=t.force??!1,n=tm(r);return om(n,e)}function om(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=Ur(u);e.set(s,i)}catch(i){if(i instanceof zr&&t)n.push(s),o.set(s,i.message);else throw i}}return{arrays:e,skipped:n,errors:o}}async function Xt(r,t={}){let e=await Vr(r,t);return Object.fromEntries(e.arrays)}function Qt(r,t={}){let e=wt(r,t);return Object.fromEntries(e.arrays)}var Kt=W(()=>{"use strict";Ht();Dt();nm()});async function sm(r,t={}){let e=t.compress??!1,n=[];for(let[y,d]of r){let f=Rn(d),p,g;e?(p=await Ty(d),p.length<d.length?g=8:(p=d,g=0)):(p=d,g=0),n.push({name:y,data:d,compressedData:p,crc:f,compressionMethod:g,offset:0})}let o=0;for(let y of n){let d=new TextEncoder().encode(y.name);o+=30+d.length+y.compressedData.length}let a=0;for(let y of n){let d=new TextEncoder().encode(y.name);a+=46+d.length}let s=o+a+22,i=new Uint8Array(s),c=new DataView(i.buffer),l=0;for(let y of n)y.offset=l,l=um(i,c,l,y);let m=l;for(let y of n)l=cm(i,c,l,y);return lm(c,l,n.length,a,m),i}function im(r){let t=[];for(let[l,m]of r){let y=Rn(m);t.push({name:l,data:m,compressedData:m,crc:y,compressionMethod:0,offset:0})}let e=0;for(let l of t){let m=new TextEncoder().encode(l.name);e+=30+m.length+l.compressedData.length}let n=0;for(let l of t){let m=new TextEncoder().encode(l.name);n+=46+m.length}let a=e+n+22,u=new Uint8Array(a),s=new DataView(u.buffer),i=0;for(let l of t)l.offset=i,i=um(u,s,i,l);let c=i;for(let l of t)i=cm(u,s,i,l);return lm(s,i,t.length,n,c),u}function um(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 cm(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 lm(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 Ty(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:l}=await o.read();if(c)break;a.push(l)}let u=a.reduce((c,l)=>c+l.length,0),s=new Uint8Array(u),i=0;for(let c of a)s.set(c,i),i+=c.length;return s}var fm=W(()=>{"use strict";kn()});var pm={};ye(pm,{serializeNpz:()=>tt,serializeNpzSync:()=>re});async function tt(r,t={}){let e=mm(r);return sm(e,{compress:t.compress??!1})}function re(r){let t=mm(r);return im(t)}function mm(r){let t=new Map;if(Array.isArray(r)){for(let n=0;n<r.length;n++){let o=r[n],a=Tr(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=Tr(o),u=n.endsWith(".npy")?n:`${n}.npy`;t.set(u,a)}return t}var te=W(()=>{"use strict";Jt();fm()});var pd={};ye(pd,{Complex:()=>O,DTYPE_TO_DESCR:()=>xt,InvalidNpyError:()=>cr,NDArray:()=>v,SUPPORTED_DTYPES:()=>Gt,UnsupportedDTypeError:()=>zr,__version__:()=>Xy,abs:()=>Dn,absolute:()=>Dn,acos:()=>In,acosh:()=>Mn,amax:()=>On,amin:()=>Cn,angle:()=>$l,append:()=>bc,arange:()=>qi,arccos:()=>In,arccosh:()=>Mn,arcsin:()=>wn,arcsinh:()=>Fn,arctan:()=>zn,arctan2:()=>_n,arctanh:()=>Bn,argpartition:()=>Af,argsort:()=>yf,argwhere:()=>Sf,around:()=>Wt,array:()=>rr,array_equal:()=>vc,array_equiv:()=>Tc,array_split:()=>Xu,asanyarray:()=>Ji,asarray:()=>bt,ascontiguousarray:()=>Xi,asfortranarray:()=>Qi,asin:()=>wn,asinh:()=>Fn,atan:()=>zn,atan2:()=>_n,atanh:()=>Bn,atleast_1d:()=>fc,atleast_2d:()=>mc,atleast_3d:()=>pc,average:()=>$c,bincount:()=>Pf,bindex:()=>Fc,bitwise_and:()=>cl,bitwise_not:()=>ml,bitwise_or:()=>ll,bitwise_xor:()=>fl,broadcast_arrays:()=>Nc,broadcast_shapes:()=>wc,broadcast_to:()=>Dc,cbrt:()=>Jc,ceil:()=>zf,choose:()=>Bc,column_stack:()=>dc,compress:()=>Xl,concatenate:()=>qr,conj:()=>Un,conjugate:()=>Ul,convolve:()=>Yf,copy:()=>Wi,copysign:()=>zl,copyto:()=>Mc,corrcoef:()=>Jf,correlate:()=>Zf,cos:()=>Cu,cosh:()=>ju,count_nonzero:()=>If,cov:()=>Hf,cross:()=>Vf,cumprod:()=>En,cumsum:()=>Tn,cumulative_prod:()=>En,cumulative_sum:()=>Tn,deg2rad:()=>qu,degrees:()=>Ru,delete:()=>hc,diag:()=>Sn,diag_indices:()=>tf,diag_indices_from:()=>ef,diagflat:()=>Ki,diagonal:()=>Fu,diff:()=>Rf,digitize:()=>jf,divide:()=>Nn,divmod:()=>Qc,dot:()=>zu,dsplit:()=>yc,dstack:()=>Hu,ediff1d:()=>kf,einsum:()=>Gl,empty:()=>bn,empty_like:()=>Yi,exp:()=>fu,exp2:()=>mu,expand_dims:()=>ac,expm1:()=>pu,extract:()=>wf,eye:()=>An,fabs:()=>Xc,fill_diagonal:()=>rf,fix:()=>_f,flatnonzero:()=>xf,flip:()=>Lt,fliplr:()=>sc,flipud:()=>ic,float_power:()=>el,floor:()=>Ff,floor_divide:()=>Nu,fmod:()=>nl,frexp:()=>ol,frombuffer:()=>su,fromfile:()=>iu,fromfunction:()=>ru,fromiter:()=>uu,fromregex:()=>fd,fromregexSync:()=>md,fromstring:()=>cu,full:()=>hn,full_like:()=>Hi,gcd:()=>al,genfromtxt:()=>cd,genfromtxtSync:()=>ld,geomspace:()=>ji,gradient:()=>qf,heaviside:()=>tl,histogram:()=>Lf,histogram2d:()=>Wf,histogramdd:()=>Gf,hsplit:()=>Ku,hstack:()=>Yu,hypot:()=>$u,identity:()=>Li,iindex:()=>_c,imag:()=>Cl,in1d:()=>Tf,indices:()=>cf,inner:()=>vu,insert:()=>Sc,intersect1d:()=>Ef,invert:()=>pl,iscomplex:()=>Bl,iscomplexobj:()=>vl,isdtype:()=>Ll,isfinite:()=>Dl,isfortran:()=>ql,isin:()=>Of,isinf:()=>Nl,isnan:()=>wl,isnat:()=>Il,isneginf:()=>Rl,isposinf:()=>kl,isreal:()=>Tl,isrealobj:()=>El,isscalar:()=>Pl,iterable:()=>jl,ix_:()=>lf,kron:()=>Mu,lcm:()=>sl,ldexp:()=>il,left_shift:()=>yl,lexsort:()=>df,linalg:()=>Zl,linspace:()=>Vi,load:()=>Ky,loadNpy:()=>Rm,loadNpySync:()=>km,loadNpz:()=>Xt,loadNpzFile:()=>Pm,loadNpzFileSync:()=>jm,loadNpzSync:()=>Qt,loadSync:()=>rd,loadtxt:()=>ad,loadtxtSync:()=>sd,log:()=>yu,log10:()=>gu,log1p:()=>Au,log2:()=>du,logaddexp:()=>bu,logaddexp2:()=>hu,logical_and:()=>bl,logical_not:()=>Sl,logical_or:()=>hl,logical_xor:()=>xl,logspace:()=>Pi,mask_indices:()=>uf,max:()=>On,median:()=>Oc,meshgrid:()=>tu,min:()=>Cn,mod:()=>Du,modf:()=>ul,moveaxis:()=>Gu,nanargmax:()=>Gc,nanargmin:()=>Wc,nancumprod:()=>Yc,nancumsum:()=>Zc,nanmax:()=>Lc,nanmean:()=>qc,nanmedian:()=>Hc,nanmin:()=>jc,nanprod:()=>kc,nanstd:()=>Pc,nansum:()=>Rc,nanvar:()=>Vc,negative:()=>Su,nextafter:()=>Fl,nonzero:()=>hf,ones:()=>gn,ones_like:()=>Zi,outer:()=>Tu,packbits:()=>gl,pad:()=>xc,parseNpy:()=>Ur,parseNpyData:()=>Yt,parseNpyHeader:()=>Zt,parseNpz:()=>Vr,parseNpzSync:()=>wt,parseTxt:()=>Pr,partition:()=>gf,percentile:()=>Cc,place:()=>Kl,positive:()=>wu,pow:()=>xn,power:()=>xn,promote_types:()=>Wl,ptp:()=>Ec,put:()=>zc,put_along_axis:()=>Hl,putmask:()=>Jl,quantile:()=>Uc,rad2deg:()=>Vu,radians:()=>ku,random:()=>Jy,ravel:()=>ec,ravel_multi_index:()=>ff,real:()=>Ol,real_if_close:()=>Vl,reciprocal:()=>Iu,remainder:()=>rl,repeat:()=>tc,reshape:()=>nc,resize:()=>Ac,right_shift:()=>dl,rint:()=>Mf,roll:()=>cc,rollaxis:()=>lc,rot90:()=>uc,round:()=>Wt,round_:()=>Wt,row_stack:()=>gc,save:()=>td,saveNpy:()=>qm,saveNpySync:()=>Vm,saveNpz:()=>Hn,saveNpzSync:()=>Qy,saveSync:()=>ed,savetxt:()=>id,savetxtSync:()=>ud,savez:()=>nd,savez_compressed:()=>od,searchsorted:()=>Nf,select:()=>Ql,serializeNpy:()=>Tr,serializeNpz:()=>tt,serializeNpzSync:()=>re,serializeTxt:()=>et,setdiff1d:()=>Cf,setxor1d:()=>Uf,sign:()=>xu,signbit:()=>_l,sin:()=>Ou,sinh:()=>Pu,sort:()=>pf,sort_complex:()=>bf,spacing:()=>Ml,split:()=>Ju,sqrt:()=>lu,square:()=>Kc,squeeze:()=>oc,stack:()=>Zu,swapaxes:()=>Wu,take:()=>Ic,take_along_axis:()=>Yl,tan:()=>Uu,tanh:()=>Lu,tensordot:()=>Eu,tile:()=>rc,trace:()=>_u,transpose:()=>Bu,tri:()=>eu,tril:()=>nu,tril_indices:()=>nf,tril_indices_from:()=>of,triu:()=>ou,triu_indices:()=>af,triu_indices_from:()=>sf,true_divide:()=>Nn,trunc:()=>Bf,union1d:()=>$f,unique:()=>vf,unpackbits:()=>Al,unravel_index:()=>mf,vander:()=>au,vsplit:()=>Qu,vstack:()=>vn,where:()=>Df,zeros:()=>Ir,zeros_like:()=>Gi});module.exports=de(pd);var _r=require("node:fs"),Fr=require("node:fs/promises");Ht();Jt();Kt();te();ht();function Pr(r,t={}){let{delimiter:e,comments:n="#",skiprows:o=0,usecols:a,max_rows:u,dtype:s="float64",missing_values:i,filling_values:c}=t,l=r.split(/\r?\n/);if(o>0&&(l=l.slice(o)),l=l.filter(p=>{let g=p.trim();return!(g===""||n&&g.startsWith(n))}),u!==void 0&&u>0&&(l=l.slice(0,u)),l.length===0)return rr([],s);let m=[],y=new Set(i?Array.isArray(i)?i:[i]:[]),d=c!==void 0?c:s.includes("int")||s==="bool"?0:NaN;for(let p of l){let g;e===void 0?g=p.trim().split(/\s+/):g=p.split(e),a!==void 0&&(g=(Array.isArray(a)?a:[a]).map(A=>(A<0&&(A=g.length+A),g[A]??"")));let h=g.map(b=>{let A=b.trim();if(y.has(A)||A==="")return d;let S=parseFloat(A);return isNaN(S)?d:S});m.push(h)}let f=m[0]?.length??0;for(let p=1;p<m.length;p++)if(m[p].length!==f)throw new Error(`Inconsistent number of columns: row 0 has ${f} columns, row ${p} has ${m[p].length} columns`);return f===1?rr(m.map(p=>p[0]),s):rr(m,s)}function It(r,t={}){let e={...t,missing_values:t.missing_values??["","nan","NaN","NA","N/A","-"],filling_values:t.filling_values??NaN};return Pr(r,e)}function zt(r,t,e="float64"){let n=typeof t=="string"?new RegExp(t,"gm"):new RegExp(t.source,"gm"),o=[],a;for(;(a=n.exec(r))!==null;)if(a.length>1){let u=a.slice(1).map(s=>{let i=parseFloat(s);return isNaN(i)?0:i});o.push(u)}return o.length===0?rr([],e):o[0].length===1?rr(o.map(u=>u[0]),e):rr(o,e)}function ym(r,t){let e=typeof r=="bigint"?Number(r):r,n=t.match(/^%([+-]?)(\d*)(?:\.(\d+))?([dfeEgGs])$/);if(!n)return String(e);let[,o,a,u,s]=n,i=u!==void 0?parseInt(u,10):void 0,c;switch(s){case"d":c=Math.round(e).toString();break;case"f":c=e.toFixed(i??6);break;case"e":c=e.toExponential(i??6).replace(/e([+-])(\d)$/,"e$10$2");break;case"E":c=e.toExponential(i??6).toUpperCase().replace(/E([+-])(\d)$/,"E$10$2");break;case"g":case"G":{let l=i??6,m=Math.floor(Math.log10(Math.abs(e)));m>=-4&&m<l?(c=e.toPrecision(l),c.includes(".")&&(c=c.replace(/\.?0+$/,""))):c=e.toExponential(l-1),s==="G"&&(c=c.toUpperCase());break}case"s":c=String(e);break;default:c=String(e)}if(a){let l=parseInt(a,10);if(c.length<l){let m=" ".repeat(l-c.length);o==="-"?c=c+m:c=m+c}}return o==="+"&&e>=0&&!c.startsWith("-")&&(c="+"+c),c}function et(r,t={}){let{fmt:e="%.18e",delimiter:n=" ",newline:o=`
3
- `,header:a,footer:u,comments:s="# "}=t;if(r.ndim>2)throw new Error("savetxt: array must be 1D or 2D");let i=[];if(a!==void 0){let l=a.split(/\r?\n/);for(let m of l)m.startsWith(s.trimEnd())?i.push(m):i.push(s+m)}let c=r.toArray();if(r.ndim===1)for(let l of c)i.push(ym(l,e));else for(let l of c){let m=l.map(y=>ym(y,e));i.push(m.join(n))}if(u!==void 0){let l=u.split(/\r?\n/);for(let m of l)m.startsWith(s.trimEnd())?i.push(m):i.push(s+m)}return i.join(o)+o}xr();ht();Ht();Jt();Dt();Kt();te();X();J();var hr=624,ee=397,Ey=2567483615,Pn=2147483648,jn=2147483647,Sr={mt:new Uint32Array(hr),mti:hr+1};function Am(r){let t=Sr.mt;t[0]=r>>>0;for(let e=1;e<hr;e++){let n=t[e-1]^t[e-1]>>>30;t[e]=Math.imul(1812433253,n)+e>>>0}Sr.mti=hr}function dm(){let r=Sr.mt,t,e=[0,Ey];if(Sr.mti>=hr){let n;for(Sr.mti===hr+1&&Am(5489),n=0;n<hr-ee;n++)t=r[n]&Pn|r[n+1]&jn,r[n]=r[n+ee]^t>>>1^e[t&1];for(;n<hr-1;n++)t=r[n]&Pn|r[n+1]&jn,r[n]=r[n+(ee-hr)]^t>>>1^e[t&1];t=r[hr-1]&Pn|r[0]&jn,r[hr-1]=r[ee-1]^t>>>1^e[t&1],Sr.mti=0}return t=r[Sr.mti++],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}function Y(){let r=dm()>>>5,t=dm()>>>6;return(r*67108864+t)/9007199254740992}var Oy=2468251765,Cy=1492356589,Uy=1135663077,$y=2337405405,Ry=3389127133,ky=1232336661,Yn=16,ne=4;function lr(r){return r>>>0}function Ln(r,t){return r=lr(lr(r)^t.val),t.val=lr(Math.imul(t.val,Oy)),r=lr(Math.imul(r,t.val)),r=lr(r^r>>>Yn),r}function qy(r,t){let e=lr(lr(Math.imul(Ry,lr(r)))-lr(Math.imul(ky,lr(t))));return e=lr(e^e>>>Yn),e}function Vy(r){let t=[0,0,0,0],e=[r>>>0],n={val:Uy};for(let o=0;o<ne;o++)o<e.length?t[o]=Ln(e[o],n):t[o]=Ln(0,n);for(let o=0;o<ne;o++)for(let a=0;a<ne;a++)if(o!==a){let u=Ln(t[o],n);t[a]=qy(t[a],u)}return t}function Py(r,t){let e=[],n=$y;for(let o=0;o<t;o++){let a=r[o%ne],u=lr(a^n);n=lr(Math.imul(n,Cy)),u=lr(Math.imul(u,n)),u=lr(u^u>>>Yn),e.push(u)}return e}var jy=BigInt("4865540595714422341"),Ly=BigInt("2549297995355413924"),Wy=Ly<<BigInt(64)|jy,Wn=BigInt("0xffffffffffffffff"),Gn=(BigInt(1)<<BigInt(128))-BigInt(1);function Gy(r){let t=r>>BigInt(64),e=r&Wn,n=(t^e)&Wn,o=Number(r>>BigInt(122));return(n>>BigInt(o)|n<<BigInt(64-o))&Wn}function Zn(r,t){return r*Wy+t&Gn}function gm(r){let t=Vy(r),e=Py(t,8),n=BigInt(e[0])|BigInt(e[1])<<BigInt(32),o=BigInt(e[2])|BigInt(e[3])<<BigInt(32),a=BigInt(e[4])|BigInt(e[5])<<BigInt(32),u=BigInt(e[6])|BigInt(e[7])<<BigInt(32),s=n<<BigInt(64)|o,i=(a<<BigInt(64)|u)<<BigInt(1);i=(i|BigInt(1))&Gn;let c=BigInt(0);return c=Zn(c,i),c=c+s&Gn,c=Zn(c,i),{state:c,inc:i}}function Zy(r){return r.state=Zn(r.state,r.inc),Gy(r.state)}function Yy(r){let e=Zy(r)>>BigInt(11);return Number(e)/9007199254740992}var _t=class{constructor(t){if(t!==void 0)this._pcgState=gm(t);else{let e=Math.floor(Math.random()*4294967296);this._pcgState=gm(e)}}_randomFloat(){return Yy(this._pcgState)}random(t){if(t===void 0)return this._randomFloat();let e=Array.isArray(t)?t:[t],n=e.reduce((u,s)=>u*s,1),o=D.zeros(e,"float64"),a=o.data;for(let u=0;u<n;u++)a[u]=this._randomFloat();return o}integers(t,e,n){if(e===void 0&&(e=t,t=0),n===void 0)return Math.floor(this._randomFloat()*(e-t))+t;let o=Array.isArray(n)?n:[n],a=o.reduce((c,l)=>c*l,1),u=D.zeros(o,"int64"),s=u.data,i=e-t;for(let c=0;c<a;c++)s[c]=BigInt(Math.floor(this._randomFloat()*i)+t);return u}standard_normal(t){if(t===void 0)return jr(this._randomFloat.bind(this));let e=Array.isArray(t)?t:[t],n=e.reduce((u,s)=>u*s,1),o=D.zeros(e,"float64"),a=o.data;for(let u=0;u<n;u+=2){let[s,i]=Ft(this._randomFloat.bind(this));a[u]=s,u+1<n&&(a[u+1]=i)}return o}normal(t=0,e=1,n){if(n===void 0)return jr(this._randomFloat.bind(this))*e+t;let o=Array.isArray(n)?n:[n],a=o.reduce((i,c)=>i*c,1),u=D.zeros(o,"float64"),s=u.data;for(let i=0;i<a;i+=2){let[c,l]=Ft(this._randomFloat.bind(this));s[i]=c*e+t,i+1<a&&(s[i+1]=l*e+t)}return u}uniform(t=0,e=1,n){if(n===void 0)return this._randomFloat()*(e-t)+t;let o=Array.isArray(n)?n:[n],a=o.reduce((c,l)=>c*l,1),u=D.zeros(o,"float64"),s=u.data,i=e-t;for(let c=0;c<a;c++)s[c]=this._randomFloat()*i+t;return u}choice(t,e,n=!0,o){return Tm(t,e,n,o,this._randomFloat.bind(this))}permutation(t){return Om(t,this._randomFloat.bind(this))}shuffle(t){Um(t,this._randomFloat.bind(this))}exponential(t=1,e){if(e===void 0)return-Math.log(1-this._randomFloat())*t;let n=Array.isArray(e)?e:[e],o=n.reduce((s,i)=>s*i,1),a=D.zeros(n,"float64"),u=a.data;for(let s=0;s<o;s++)u[s]=-Math.log(1-this._randomFloat())*t;return a}poisson(t=1,e){if(e===void 0)return oe(t,this._randomFloat.bind(this));let n=Array.isArray(e)?e:[e],o=n.reduce((s,i)=>s*i,1),a=D.zeros(n,"int64"),u=a.data;for(let s=0;s<o;s++)u[s]=BigInt(oe(t,this._randomFloat.bind(this)));return a}binomial(t,e,n){if(n===void 0)return ae(t,e,this._randomFloat.bind(this));let o=Array.isArray(n)?n:[n],a=o.reduce((i,c)=>i*c,1),u=D.zeros(o,"int64"),s=u.data;for(let i=0;i<a;i++)s[i]=BigInt(ae(t,e,this._randomFloat.bind(this)));return u}};function bm(r){return new _t(r)}function hm(r){r==null&&(r=Math.floor(Date.now()^Math.random()*4294967296)),Am(r>>>0)}function Sm(){return{mt:Array.from(Sr.mt),mti:Sr.mti}}function xm(r){Sr.mt=new Uint32Array(r.mt),Sr.mti=r.mti}function jr(r){let t,e;do t=r(),e=r();while(t===0);return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e)}function Ft(r){let t,e;do t=r(),e=r();while(t===0);let n=Math.sqrt(-2*Math.log(t)),o=2*Math.PI*e;return[n*Math.cos(o),n*Math.sin(o)]}function oe(r,t){if(r<30){let e=Math.exp(-r),n=0,o=1;do n++,o*=t();while(o>e);return n-1}else{let e=jr(t);return Math.max(0,Math.round(r+Math.sqrt(r)*e))}}function ae(r,t,e){if(r*t<10&&r*(1-t)<10){let n=0;for(let o=0;o<r;o++)e()<t&&n++;return n}else{let n=r*t,o=Math.sqrt(r*t*(1-t)),a=jr(e);return Math.max(0,Math.min(r,Math.round(n+o*a)))}}function Dm(r){if(r===void 0)return Y();let t=Array.isArray(r)?r:[r],e=t.reduce((a,u)=>a*u,1),n=D.zeros(t,"float64"),o=n.data;for(let a=0;a<e;a++)o[a]=Y();return n}function Nm(...r){if(r.length===0)return Y();let t=r.reduce((o,a)=>o*a,1),e=D.zeros(r,"float64"),n=e.data;for(let o=0;o<t;o++)n[o]=Y();return e}function wm(...r){if(r.length===0)return jr(Y);let t=r.reduce((o,a)=>o*a,1),e=D.zeros(r,"float64"),n=e.data;for(let o=0;o<t;o+=2){let[a,u]=Ft(Y);n[o]=a,o+1<t&&(n[o+1]=u)}return e}function Im(r,t,e,n="int64"){t==null&&(t=r,r=0);let o=t-r;if(e===void 0)return Math.floor(Y()*o)+r;let a=Array.isArray(e)?e:[e],u=a.reduce((c,l)=>c*l,1),s=D.zeros(a,n),i=s.data;if(B(n)){let c=i;for(let l=0;l<u;l++)c[l]=BigInt(Math.floor(Y()*o)+r)}else{let c=i;for(let l=0;l<u;l++)c[l]=Math.floor(Y()*o)+r}return s}function zm(r=0,t=1,e){if(e===void 0)return Y()*(t-r)+r;let n=Array.isArray(e)?e:[e],o=n.reduce((i,c)=>i*c,1),a=D.zeros(n,"float64"),u=a.data,s=t-r;for(let i=0;i<o;i++)u[i]=Y()*s+r;return a}function _m(r=0,t=1,e){if(e===void 0)return jr(Y)*t+r;let n=Array.isArray(e)?e:[e],o=n.reduce((s,i)=>s*i,1),a=D.zeros(n,"float64"),u=a.data;for(let s=0;s<o;s+=2){let[i,c]=Ft(Y);u[s]=i*t+r,s+1<o&&(u[s+1]=c*t+r)}return a}function Fm(r){if(r===void 0)return jr(Y);let t=Array.isArray(r)?r:[r],e=t.reduce((a,u)=>a*u,1),n=D.zeros(t,"float64"),o=n.data;for(let a=0;a<e;a+=2){let[u,s]=Ft(Y);o[a]=u,a+1<e&&(o[a+1]=s)}return n}function Mm(r=1,t){if(t===void 0)return-Math.log(1-Y())*r;let e=Array.isArray(t)?t:[t],n=e.reduce((u,s)=>u*s,1),o=D.zeros(e,"float64"),a=o.data;for(let u=0;u<n;u++)a[u]=-Math.log(1-Y())*r;return o}function Bm(r=1,t){if(t===void 0)return oe(r,Y);let e=Array.isArray(t)?t:[t],n=e.reduce((u,s)=>u*s,1),o=D.zeros(e,"int64"),a=o.data;for(let u=0;u<n;u++)a[u]=BigInt(oe(r,Y));return o}function vm(r,t,e){if(e===void 0)return ae(r,t,Y);let n=Array.isArray(e)?e:[e],o=n.reduce((s,i)=>s*i,1),a=D.zeros(n,"int64"),u=a.data;for(let s=0;s<o;s++)u[s]=BigInt(ae(r,t,Y));return a}function Tm(r,t,e=!0,n,o=Y){let a;if(typeof r=="number")a=Array.from({length:r},(y,d)=>d);else{let y=r.size;a=[];for(let d=0;d<y;d++)a.push(Number(r.iget(d)))}let u=a.length;if(u===0)throw new Error("cannot take a sample from an empty sequence");let s;if(n!==void 0){if(Array.isArray(n))s=n;else{let d=n.size;s=[];for(let f=0;f<d;f++)s.push(Number(n.iget(f)))}if(s.length!==u)throw new Error("p and a must have the same size");let y=s.reduce((d,f)=>d+f,0);Math.abs(y-1)>1e-10&&(s=s.map(d=>d/y))}if(t===void 0){if(s){let y=o(),d=0;for(let f=0;f<u;f++)if(d+=s[f],y<d)return a[f];return a[u-1]}return a[Math.floor(o()*u)]}let i=Array.isArray(t)?t:[t],c=i.reduce((y,d)=>y*d,1);if(!e&&c>u)throw new Error("cannot take a larger sample than population when replace=false");let l=D.zeros(i,"float64"),m=l.data;if(e)if(s){let y=new Array(u);y[0]=s[0];for(let d=1;d<u;d++)y[d]=y[d-1]+s[d];for(let d=0;d<c;d++){let f=o(),p=0;for(;p<u-1&&f>=y[p];)p++;m[d]=a[p]}}else for(let y=0;y<c;y++)m[y]=a[Math.floor(o()*u)];else{let y=[...a],d=s?[...s]:void 0;for(let f=0;f<c;f++){let p;if(d){let g=d.reduce((A,S)=>A+S,0),h=o()*g,b=0;p=0;for(let A=0;A<y.length;A++)if(b+=d[A],h<b){p=A;break}p===0&&h>=b&&(p=y.length-1)}else p=Math.floor(o()*y.length);m[f]=y[p],y.splice(p,1),d&&d.splice(p,1)}}return l}function Em(r,t,e=!0,n){return Tm(r,t,e,n,Y)}function Om(r,t=Y){let e;if(typeof r=="number"){let o=new Float64Array(r);for(let a=0;a<r;a++)o[a]=a;e=D.fromData(o,[r],"float64")}else e=r.copy();let n=e.size;for(let o=n-1;o>0;o--){let a=Math.floor(t()*(o+1)),u=e.iget(o);e.iset(o,e.iget(a)),e.iset(a,u)}return e}function Cm(r){return Om(r,Y)}function Um(r,t=Y){let e=r.size;for(let n=e-1;n>0;n--){let o=Math.floor(t()*(n+1)),a=r.iget(n);r.iset(n,r.iget(o)),r.iset(o,a)}}function $m(r){Um(r,Y)}ht();function dr(r){return r&&typeof r=="object"&&"_data"in r&&"_shape"in r?v._fromStorage(r):r}var Jy={seed:hm,random:r=>dr(Dm(r)),rand:(...r)=>dr(Nm(...r)),randn:(...r)=>dr(wm(...r)),randint:(r,t,e,n)=>dr(Im(r,t,e,n)),uniform:(r,t,e)=>dr(zm(r,t,e)),normal:(r,t,e)=>dr(_m(r,t,e)),standard_normal:r=>dr(Fm(r)),exponential:(r,t)=>dr(Mm(r,t)),poisson:(r,t)=>dr(Bm(r,t)),binomial:(r,t,e)=>dr(vm(r,t,e)),choice:(r,t,e,n)=>dr(Em(r,t,e,n)),permutation:r=>dr(Cm(r)),shuffle:$m,get_state:Sm,set_state:xm,default_rng:bm,Generator:_t},Xy="0.11.0";async function Rm(r){let t=await(0,Fr.readFile)(r);return Ur(t)}function km(r){let t=(0,_r.readFileSync)(r);return Ur(t)}async function qm(r,t){let e=Tr(t);await(0,Fr.writeFile)(r,e)}function Vm(r,t){let e=Tr(t);(0,_r.writeFileSync)(r,e)}async function Pm(r,t={}){let e=await(0,Fr.readFile)(r);return Vr(e,t)}function jm(r,t={}){let e=(0,_r.readFileSync)(r),{parseNpzSync:n}=(Kt(),de(am));return n(e,t)}async function Hn(r,t,e={}){let n=await tt(t,e);await(0,Fr.writeFile)(r,n)}function Qy(r,t){let{serializeNpzSync:e}=(te(),de(pm)),n=e(t);(0,_r.writeFileSync)(r,n)}async function Ky(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return Rm(r)}else{if(r.endsWith(".npz"))return Pm(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}function rd(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return km(r)}else{if(r.endsWith(".npz"))return jm(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}async function td(r,t){if(!r.endsWith(".npy"))throw new Error(`save() is for .npy files. Use saveNpz() for .npz files. Got: ${r}`);return qm(r,t)}function ed(r,t){if(!r.endsWith(".npy"))throw new Error(`saveSync() is for .npy files. Use saveNpzSync() for .npz files. Got: ${r}`);return Vm(r,t)}async function nd(r,t){return r.endsWith(".npz")||(r=r+".npz"),Hn(r,t,{compress:!1})}async function od(r,t){return r.endsWith(".npz")||(r=r+".npz"),Hn(r,t,{compress:!0})}async function ad(r,t={}){let e=await(0,Fr.readFile)(r,{encoding:t.encoding??"utf-8"});return Pr(e,t)}function sd(r,t={}){let e=(0,_r.readFileSync)(r,{encoding:t.encoding??"utf-8"});return Pr(e,t)}async function id(r,t,e={}){let n=et(t,e);await(0,Fr.writeFile)(r,n,"utf-8")}function ud(r,t,e={}){let n=et(t,e);(0,_r.writeFileSync)(r,n,"utf-8")}async function cd(r,t={}){let e=await(0,Fr.readFile)(r,{encoding:t.encoding??"utf-8"});return It(e,t)}function ld(r,t={}){let e=(0,_r.readFileSync)(r,{encoding:t.encoding??"utf-8"});return It(e,t)}async function fd(r,t,e="float64"){let n=await(0,Fr.readFile)(r,{encoding:"utf-8"});return zt(n,t,e)}function md(r,t,e="float64"){let n=(0,_r.readFileSync)(r,{encoding:"utf-8"});return zt(n,t,e)}0&&(module.exports={Complex,DTYPE_TO_DESCR,InvalidNpyError,NDArray,SUPPORTED_DTYPES,UnsupportedDTypeError,__version__,abs,absolute,acos,acosh,amax,amin,angle,append,arange,arccos,arccosh,arcsin,arcsinh,arctan,arctan2,arctanh,argpartition,argsort,argwhere,around,array,array_equal,array_equiv,array_split,asanyarray,asarray,ascontiguousarray,asfortranarray,asin,asinh,atan,atan2,atanh,atleast_1d,atleast_2d,atleast_3d,average,bincount,bindex,bitwise_and,bitwise_not,bitwise_or,bitwise_xor,broadcast_arrays,broadcast_shapes,broadcast_to,cbrt,ceil,choose,column_stack,compress,concatenate,conj,conjugate,convolve,copy,copysign,copyto,corrcoef,correlate,cos,cosh,count_nonzero,cov,cross,cumprod,cumsum,cumulative_prod,cumulative_sum,deg2rad,degrees,delete:null,diag,diag_indices,diag_indices_from,diagflat,diagonal,diff,digitize,divide,divmod,dot,dsplit,dstack,ediff1d,einsum,empty,empty_like,exp,exp2,expand_dims,expm1,extract,eye,fabs,fill_diagonal,fix,flatnonzero,flip,fliplr,flipud,float_power,floor,floor_divide,fmod,frexp,frombuffer,fromfile,fromfunction,fromiter,fromregex,fromregexSync,fromstring,full,full_like,gcd,genfromtxt,genfromtxtSync,geomspace,gradient,heaviside,histogram,histogram2d,histogramdd,hsplit,hstack,hypot,identity,iindex,imag,in1d,indices,inner,insert,intersect1d,invert,iscomplex,iscomplexobj,isdtype,isfinite,isfortran,isin,isinf,isnan,isnat,isneginf,isposinf,isreal,isrealobj,isscalar,iterable,ix_,kron,lcm,ldexp,left_shift,lexsort,linalg,linspace,load,loadNpy,loadNpySync,loadNpz,loadNpzFile,loadNpzFileSync,loadNpzSync,loadSync,loadtxt,loadtxtSync,log,log10,log1p,log2,logaddexp,logaddexp2,logical_and,logical_not,logical_or,logical_xor,logspace,mask_indices,max,median,meshgrid,min,mod,modf,moveaxis,nanargmax,nanargmin,nancumprod,nancumsum,nanmax,nanmean,nanmedian,nanmin,nanprod,nanstd,nansum,nanvar,negative,nextafter,nonzero,ones,ones_like,outer,packbits,pad,parseNpy,parseNpyData,parseNpyHeader,parseNpz,parseNpzSync,parseTxt,partition,percentile,place,positive,pow,power,promote_types,ptp,put,put_along_axis,putmask,quantile,rad2deg,radians,random,ravel,ravel_multi_index,real,real_if_close,reciprocal,remainder,repeat,reshape,resize,right_shift,rint,roll,rollaxis,rot90,round,round_,row_stack,save,saveNpy,saveNpySync,saveNpz,saveNpzSync,saveSync,savetxt,savetxtSync,savez,savez_compressed,searchsorted,select,serializeNpy,serializeNpz,serializeNpzSync,serializeTxt,setdiff1d,setxor1d,sign,signbit,sin,sinh,sort,sort_complex,spacing,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,true_divide,trunc,union1d,unique,unpackbits,unravel_index,vander,vsplit,vstack,where,zeros,zeros_like});
1
+ "use strict";var xe=Object.defineProperty;var Qy=Object.getOwnPropertyDescriptor;var Ky=Object.getOwnPropertyNames;var rd=Object.prototype.hasOwnProperty;var G=(r,t)=>()=>(r&&(t=r(r=0)),t);var we=(r,t)=>{for(var e in t)xe(r,e,{get:t[e],enumerable:!0})},td=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ky(t))!rd.call(r,o)&&o!==e&&xe(r,o,{get:()=>t[o],enumerable:!(n=Qy(t,o))||n.enumerable});return r};var Ie=r=>td(xe({},"__esModule",{value:!0}),r);function ho(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 So(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 i=e<0?t+e:e;if(i<0||i>=t)throw new Error(`Index ${e} is out of bounds for size ${t}`);return{start:i,stop:i+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 Do=G(()=>{"use strict"});function j(r){switch(r){case"float64":return Float64Array;case"float32":return Float32Array;case"complex128":return Float64Array;case"complex64":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 Hr(r){switch(r){case"complex128":return 16;case"float64":case"int64":case"uint64":case"complex64":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 xo(r){return r==="int64"||r==="int32"||r==="int16"||r==="int8"||r==="uint64"||r==="uint32"||r==="uint16"||r==="uint8"}function No(r){return r==="float64"||r==="float32"}function B(r){return r==="int64"||r==="uint64"}function M(r){return r==="complex64"||r==="complex128"}function U(r,t,e){if(M(r)){let n=e?` ${e}`:"";throw new TypeError(`ufunc '${t}' not supported for complex dtype '${r}'.${n}`)}}function lt(r){if(r==="complex128")return"float64";if(r==="complex64")return"float32";throw new Error(`${r} is not a complex dtype`)}function wo(r){return typeof r=="object"&&r!==null&&"re"in r&&"im"in r}function Z(r,t){if(r===t)return r;if(r==="bool")return t;if(t==="bool")return r;if(M(r)||M(t)){if(M(r)&&M(t))return r==="complex128"||t==="complex128"?"complex128":"complex64";let c=M(r)?r:t,l=M(r)?t:r;return c==="complex128"||l==="float64"||l==="int64"||l==="uint64"||l==="int32"||l==="uint32"?"complex128":"complex64"}if(No(r)||No(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"),i=c=>c.includes("64")?64:c.includes("32")?32:c.includes("16")?16:c.includes("8")?8:0,s=i(r),u=i(t);if(r==="int64"&&t==="uint64"||r==="uint64"&&t==="int64")return"float64";if(e&&a&&s===u){if(s===8)return"int16";if(s===16)return"int32";if(s===32)return"int64"}if(o&&n&&s===u){if(u===8)return"int16";if(u===16)return"int32";if(u===32)return"int64"}if(e&&n||o&&a){let c=Math.max(s,u);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>u?r:u===8?"int16":u===16?"int32":u===32?"int64":"float64":o&&n?u>s?t:s===8?"int16":s===16?"int32":s===32?"int64":"float64":"float64"}var tr,Q=G(()=>{"use strict";tr="float64"});var E,xr=G(()=>{"use strict";E=class r{constructor(t,e=0){this.re=t,this.im=e}abs(){return Math.sqrt(this.re*this.re+this.im*this.im)}angle(){return Math.atan2(this.im,this.re)}conj(){return new r(this.re,-this.im)}add(t){return typeof t=="number"?new r(this.re+t,this.im):new r(this.re+t.re,this.im+t.im)}sub(t){return typeof t=="number"?new r(this.re-t,this.im):new r(this.re-t.re,this.im-t.im)}mul(t){return typeof t=="number"?new r(this.re*t,this.im*t):new r(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)}div(t){if(typeof t=="number")return new r(this.re/t,this.im/t);let e=t.re*t.re+t.im*t.im;return new r((this.re*t.re+this.im*t.im)/e,(this.im*t.re-this.re*t.im)/e)}neg(){return new r(-this.re,-this.im)}equals(t){return this.re===t.re&&this.im===t.im}toString(){return this.im===0?`(${this.re}+0j)`:this.im<0?`(${this.re}${this.im}j)`:`(${this.re}+${this.im}j)`}static from(t){if(t instanceof r)return t;if(typeof t=="number")return new r(t,0);if(Array.isArray(t))return new r(t[0]??0,t[1]??0);if(typeof t=="object"&&t!==null&&"re"in t)return new r(t.re??0,t.im??0);throw new Error(`Cannot convert ${t} to Complex`)}static isComplex(t){return t instanceof r||typeof t=="object"&&t!==null&&"re"in t&&"im"in t}}});function ur(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 N,K=G(()=>{"use strict";Q();xr();N=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,a=M(this._dtype),i;if(o===0)i=this._offset;else{let s=t;i=this._offset;for(let u=0;u<o;u++){let c=1;for(let m=u+1;m<o;m++)c*=e[m];let l=Math.floor(s/c);s=s%c,i+=l*n[u]}}if(a){let s=i*2,u=this._data[s],c=this._data[s+1];return new E(u,c)}return this._data[i]}iset(t,e){let n=this._shape,o=this._strides,a=n.length,i=M(this._dtype),s;if(a===0)s=this._offset;else{let u=t;s=this._offset;for(let c=0;c<a;c++){let l=1;for(let d=c+1;d<a;d++)l*=n[d];let m=Math.floor(u/l);u=u%l,s+=m*o[c]}}if(i){let u=s*2,c,l;e instanceof E?(c=e.re,l=e.im):typeof e=="object"&&e!==null&&"re"in e?(c=e.re,l=e.im??0):(c=Number(e),l=0),this._data[u]=c,this._data[u+1]=l}else 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];if(M(this._dtype)){let o=n*2,a=this._data[o],i=this._data[o+1];return new E(a,i)}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];if(M(this._dtype)){let a=o*2,i,s;e instanceof E?(i=e.re,s=e.im):typeof e=="object"&&e!==null&&"re"in e?(i=e.re,s=e.im??0):(i=Number(e),s=0),this._data[a]=i,this._data[a+1]=s}else this._data[o]=e}copy(){let t=Array.from(this._shape),e=this._dtype,n=this.size,o=M(e),a=j(e);if(!a)throw new Error(`Cannot copy array with dtype ${e}`);let i=o?n*2:n,s=new a(i);if(this.isCContiguous&&this._offset===0)if(B(e)){let u=this._data,c=s;for(let l=0;l<i;l++)c[l]=u[l]}else s.set(this._data.subarray(0,i));else if(B(e)){let u=s;for(let c=0;c<n;c++)u[c]=this.iget(c)}else if(o){let u=s;for(let c=0;c<n;c++){let l=this.iget(c);u[c*2]=l.re,u[c*2+1]=l.im}}else for(let u=0;u<n;u++)s[u]=this.iget(u);return new r(s,t,r._computeStrides(t),0,e)}static fromData(t,e,n,o,a){let i=o??r._computeStrides(e),s=a??0;return new r(t,e,i,s,n)}static zeros(t,e=tr){let n=t.reduce((u,c)=>u*c,1),o=M(e),a=j(e);if(!a)throw new Error(`Cannot create array with dtype ${e}`);let i=o?n*2:n,s=new a(i);return new r(s,t,r._computeStrides(t),0,e)}static ones(t,e=tr){let n=t.reduce((u,c)=>u*c,1),o=M(e),a=j(e);if(!a)throw new Error(`Cannot create array with dtype ${e}`);let i=o?n*2:n,s=new a(i);if(B(e))s.fill(BigInt(1));else if(o){let u=s;for(let c=0;c<n;c++)u[c*2]=1,u[c*2+1]=0}else s.fill(1);return new r(s,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 Sr(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 i=a.length-t+n,s=i<0?1:a[i];if(s!==1){if(o===1)o=s;else if(o!==s)return null}}e[n]=o}return e}function ed(r,t,e){let n=r.length,o=e.length,a=new Array(o).fill(0);for(let i=0;i<n;i++){let s=o-n+i,u=r[i],c=e[s];if(u===c)a[s]=t[i];else if(u===1)a[s]=0;else throw new Error("Invalid broadcast")}return a}function gr(r,t){let e=ed(r.shape,r.strides,t);return N.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function ze(...r){let t=Sr(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 Rt=G(()=>{"use strict";K()});function Ur(r,t){let e=r.length,n=t.length,o=Math.max(e,n),a=new Array(o);for(let i=0;i<o;i++){let s=i<o-e?1:r[i-(o-e)],u=i<o-n?1:t[i-(o-n)];if(s===u)a[i]=s;else if(s===1)a[i]=u;else if(u===1)a[i]=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 nd(r,t,e){let n=r.length,o=e.length,a=new Array(o).fill(0);for(let i=0;i<n;i++){let s=o-n+i,u=r[i],c=e[s];if(u===c)a[s]=t[i];else if(u===1)a[s]=0;else throw new Error("Invalid broadcast")}return a}function kt(r,t){let e=nd(r.shape,r.strides,t);return N.fromData(r.data,Array.from(t),r.dtype,e,r.offset)}function X(r,t,e,n){let o=Z(r.dtype,t.dtype),a=r.shape,i=t.shape;if(a.length===i.length&&a.every((f,p)=>f===i[p])&&r.isCContiguous&&t.isCContiguous&&!B(r.dtype)&&!B(t.dtype)&&!B(o)){let f=r.size,p=N.zeros(Array.from(a),o),g=p.data,h=r.data,b=t.data;for(let A=0;A<f;A++)g[A]=e(h[A],b[A]);return p}let u=Ur(r.shape,t.shape),c=kt(r,u),l=kt(t,u),m=N.zeros(u,o),d=m.data,y=m.size;if(B(o)){let f=d;for(let p=0;p<y;p++){let g=c.iget(p),h=l.iget(p),b=g instanceof E?g.re:g,A=h instanceof E?h.re:h,S=typeof b=="bigint"?b:BigInt(Math.round(b)),D=typeof A=="bigint"?A:BigInt(Math.round(A));n==="add"?f[p]=S+D:n==="subtract"?f[p]=S-D:n==="multiply"?f[p]=S*D:n==="divide"?f[p]=S/D:f[p]=BigInt(Math.round(e(Number(S),Number(D))))}}else{let f=B(r.dtype)||B(t.dtype);for(let p=0;p<y;p++){let g=c.iget(p),h=l.iget(p),b=Number(g),A=Number(h);d[p]=e(b,A)}}return m}function Ar(r,t,e){let n=Ur(r.shape,t.shape),o=kt(r,n),a=kt(t,n),i=n.reduce((c,l)=>c*l,1),s=new Uint8Array(i),u=B(r.dtype)||B(t.dtype);for(let c=0;c<i;c++){let l=o.iget(c),m=a.iget(c),d=Number(l),y=Number(m);s[c]=e(d,y)?1:0}return N.fromData(s,n,"bool")}function J(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,u=N.zeros(o,s),c=u.data,l=r.data;if(B(n))if(B(s)){let m=c;for(let d=0;d<a;d++){let y=Number(l[d]);m[d]=BigInt(Math.round(t(y)))}}else for(let m=0;m<a;m++)c[m]=t(Number(l[m]));else for(let m=0;m<a;m++)c[m]=t(Number(l[m]));return u}var Er=G(()=>{"use strict";K();Q();xr()});function _e(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function pr(r,t){return[r[t*2],r[t*2+1]]}function Tr(r,t,e,n){r[t*2]=e,r[t*2+1]=n}function Io(r,t){return typeof t=="number"?id(r,t):_e(r,t)?od(r,t):X(r,t,(e,n)=>e+n,"add")}function od(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(M(e)){let u=s,c=M(r.dtype),l=M(t.dtype);for(let m=0;m<o;m++){let[d,y]=c?pr(a,m):[Number(a[m]),0],[f,p]=l?pr(i,m):[Number(i[m]),0];Tr(u,m,d+f,y+p)}return n}if(B(e)){let u=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),d=typeof i[l]=="bigint"?i[l]:BigInt(Math.round(Number(i[l])));u[l]=m+d}else{let l=a,m=i;for(let d=0;d<o;d++)u[d]=l[d]+m[d]}}else if(B(r.dtype)||B(t.dtype))for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?Number(a[c]):a[c],m=typeof i[c]=="bigint"?Number(i[c]):i[c];s[c]=l+m}else for(let c=0;c<o;c++)s[c]=a[c]+i[c];return n}function zo(r,t){return typeof t=="number"?ud(r,t):_e(r,t)?ad(r,t):X(r,t,(e,n)=>e-n,"subtract")}function ad(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(M(e)){let u=s,c=M(r.dtype),l=M(t.dtype);for(let m=0;m<o;m++){let[d,y]=c?pr(a,m):[Number(a[m]),0],[f,p]=l?pr(i,m):[Number(i[m]),0];Tr(u,m,d-f,y-p)}return n}if(B(e)){let u=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),d=typeof i[l]=="bigint"?i[l]:BigInt(Math.round(Number(i[l])));u[l]=m-d}else{let l=a,m=i;for(let d=0;d<o;d++)u[d]=l[d]-m[d]}}else if(B(r.dtype)||B(t.dtype))for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?Number(a[c]):a[c],m=typeof i[c]=="bigint"?Number(i[c]):i[c];s[c]=l-m}else for(let c=0;c<o;c++)s[c]=a[c]-i[c];return n}function _o(r,t){return typeof t=="number"?cd(r,t):_e(r,t)?sd(r,t):X(r,t,(e,n)=>e*n,"multiply")}function sd(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(M(e)){let u=s,c=M(r.dtype),l=M(t.dtype);for(let m=0;m<o;m++){let[d,y]=c?pr(a,m):[Number(a[m]),0],[f,p]=l?pr(i,m):[Number(i[m]),0],g=d*f-y*p,h=d*p+y*f;Tr(u,m,g,h)}return n}if(B(e)){let u=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),d=typeof i[l]=="bigint"?i[l]:BigInt(Math.round(Number(i[l])));u[l]=m*d}else{let l=a,m=i;for(let d=0;d<o;d++)u[d]=l[d]*m[d]}}else if(B(r.dtype)||B(t.dtype))for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?Number(a[c]):a[c],m=typeof i[c]=="bigint"?Number(i[c]):i[c];s[c]=l*m}else for(let c=0;c<o;c++)s[c]=a[c]*i[c];return n}function vo(r,t){if(typeof t=="number")return ld(r,t);let e=M(r.dtype),n=M(t.dtype);if(e||n){let l=Z(r.dtype,t.dtype),m=N.zeros(Array.from(r.shape),l),d=m.data,y=r.size,f=r.data,p=t.data;for(let g=0;g<y;g++){let[h,b]=e?pr(f,g):[Number(f[g]),0],[A,S]=n?pr(p,g):[Number(p[g]),0],D=A*A+S*S,w=(h*A+b*S)/D,x=(b*A-h*S)/D;Tr(d,g,w,x)}return m}let o=r.dtype==="float64",a=t.dtype==="float64",i=r.dtype==="float32",s=t.dtype==="float32";if(o||a){let l=o?r:Xr(r,"float64"),m=a?t:Xr(t,"float64");return X(l,m,(d,y)=>d/y,"divide")}if(i||s){let l=i?r:Xr(r,"float32"),m=s?t:Xr(t,"float32");return X(l,m,(d,y)=>d/y,"divide")}let u=Xr(r,"float64"),c=Xr(t,"float64");return X(u,c,(l,m)=>l/m,"divide")}function Xr(r,t){let e=N.zeros(Array.from(r.shape),t),n=r.size,o=r.data,a=e.data;for(let i=0;i<n;i++)a[i]=Number(o[i]);return e}function id(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(M(e)){let u=o,c=s;for(let l=0;l<a;l++){let[m,d]=pr(u,l);Tr(c,l,m+t,d)}}else if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]+l}else for(let u=0;u<a;u++)s[u]=Number(o[u])+t;return i}function ud(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(M(e)){let u=o,c=s;for(let l=0;l<a;l++){let[m,d]=pr(u,l);Tr(c,l,m-t,d)}}else if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]-l}else for(let u=0;u<a;u++)s[u]=Number(o[u])-t;return i}function cd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(M(e)){let u=o,c=s;for(let l=0;l<a;l++){let[m,d]=pr(u,l);Tr(c,l,m*t,d*t)}}else if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]*l}else for(let u=0;u<a;u++)s[u]=Number(o[u])*t;return i}function ld(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size;if(M(e)){let l=N.zeros(n,e),m=o,d=l.data;for(let y=0;y<a;y++){let[f,p]=pr(m,y);Tr(d,y,f/t,p/t)}return l}let s=e!=="float32"&&e!=="float64"?"float64":e,u=N.zeros(n,s),c=u.data;if(B(e))for(let l=0;l<a;l++)c[l]=Number(o[l])/t;else for(let l=0;l<a;l++)c[l]=Number(o[l])/t;return u}function Fo(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size;if(M(t)){let s=lt(t),u=N.zeros(e,s),c=u.data,l=n;for(let m=0;m<o;m++){let d=l[m*2],y=l[m*2+1];c[m]=Math.sqrt(d*d+y*y)}return u}let a=N.zeros(e,t),i=a.data;if(B(t)){let s=n,u=i;for(let c=0;c<o;c++){let l=s[c];u[c]=l<0n?-l:l}}else for(let s=0;s<o;s++)i[s]=Math.abs(Number(n[s]));return a}function Mo(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=N.zeros(e,t),i=a.data;if(M(t)){let s=n,u=i;for(let c=0;c<o;c++){let[l,m]=pr(s,c);Tr(u,c,-l,-m)}}else if(B(t)){let s=n,u=i;for(let c=0;c<o;c++)u[c]=-s[c]}else for(let s=0;s<o;s++)i[s]=-Number(n[s]);return a}function Bo(r){U(r.dtype,"sign","Sign is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=N.zeros(e,t),i=a.data;if(B(t)){let s=n,u=i;for(let c=0;c<o;c++){let l=s[c];u[c]=l>0n?1n:l<0n?-1n:0n}}else for(let s=0;s<o;s++){let u=Number(n[s]);i[s]=u>0?1:u<0?-1:0}return a}function qt(r,t){return U(r.dtype,"mod","Modulo is not defined for complex numbers."),typeof t!="number"&&U(t.dtype,"mod","Modulo is not defined for complex numbers."),typeof t=="number"?fd(r,t):X(r,t,(e,n)=>(e%n+n)%n,"mod")}function fd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++){let d=u[m];c[m]=(d%l+l)%l}}else for(let u=0;u<a;u++){let c=Number(o[u]);s[u]=(c%t+t)%t}return i}function ve(r,t){return U(r.dtype,"floor_divide","Floor division is not defined for complex numbers."),typeof t!="number"&&U(t.dtype,"floor_divide","Floor division is not defined for complex numbers."),typeof t=="number"?md(r,t):X(r,t,(e,n)=>Math.floor(e/n),"floor_divide")}function md(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]/l}else for(let u=0;u<a;u++)s[u]=Math.floor(Number(o[u])/t);return i}function Eo(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=N.zeros(e,t),i=a.data;if(M(t)){let s=n,u=i;for(let c=0;c<o;c++)u[c*2]=s[c*2],u[c*2+1]=s[c*2+1]}else for(let s=0;s<o;s++)i[s]=n[s];return a}function To(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size;if(M(t)){let c=N.zeros(e,t),l=n,m=c.data;for(let d=0;d<o;d++){let y=l[d*2],f=l[d*2+1],p=y*y+f*f;m[d*2]=y/p,m[d*2+1]=-f/p}return c}let i=t!=="float32"&&t!=="float64"?"float64":t,s=N.zeros(e,i),u=s.data;if(B(t))for(let c=0;c<o;c++)u[c]=1/Number(n[c]);else for(let c=0;c<o;c++)u[c]=1/Number(n[c]);return s}function Oo(r){let t=r.dtype;U(t,"cbrt","cbrt is not supported for complex numbers.");let e=Array.from(r.shape),n=r.data,o=r.size,i=t!=="float32"&&t!=="float64"?"float64":t,s=N.zeros(e,i),u=s.data;for(let c=0;c<o;c++)u[c]=Math.cbrt(Number(n[c]));return s}function Co(r){let t=r.dtype;U(t,"fabs","fabs is only for real numbers. Use absolute() for complex.");let e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",i=N.zeros(e,a),s=i.data;for(let u=0;u<o;u++)s[u]=Math.abs(Number(n[u]));return i}function Uo(r,t){let e=ve(r,t),n=qt(r,t);return[e,n]}function $o(r){let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=N.zeros(e,t),i=a.data;if(M(t)){let s=n,u=i;for(let c=0;c<o;c++){let l=s[c*2],m=s[c*2+1];u[c*2]=l*l-m*m,u[c*2+1]=2*l*m}}else if(B(t)){let s=n,u=i;for(let c=0;c<o;c++)u[c]=s[c]*s[c]}else for(let s=0;s<o;s++){let u=Number(n[s]);i[s]=u*u}return a}function Ro(r,t){return qt(r,t)}function ko(r,t){U(r.dtype,"heaviside","Heaviside step function is not defined for complex numbers."),typeof t!="number"&&U(t.dtype,"heaviside","Heaviside step function is not defined for complex numbers.");let e=r.dtype,n=Array.from(r.shape),o=r.size,a=e==="float32"?"float32":"float64",i=N.zeros(n,a),s=i.data;if(typeof t=="number")for(let u=0;u<o;u++){let c=Number(r.data[u]);c<0?s[u]=0:c===0?s[u]=t:s[u]=1}else{let u=t.data,c=t.shape;if(n.every((l,m)=>l===c[m]))for(let l=0;l<o;l++){let m=Number(r.data[l]);m<0?s[l]=0:m===0?s[l]=Number(u[l]):s[l]=1}else for(let l=0;l<o;l++){let m=Number(r.data[l]),d=l%t.size;m<0?s[l]=0:m===0?s[l]=Number(u[d]):s[l]=1}}return i}function qo(r,t){let e=r.dtype;if(M(e)){let n=r.data,o=r.size,a=N.zeros(Array.from(r.shape),e),i=a.data;if(typeof t=="number")for(let s=0;s<o;s++){let u=n[s*2],c=n[s*2+1],l=Math.hypot(u,c),m=Math.atan2(c,u),d=Math.pow(l,t),y=m*t;i[s*2]=d*Math.cos(y),i[s*2+1]=d*Math.sin(y)}else{let s=t.data,u=M(t.dtype);for(let c=0;c<o;c++){let l=n[c*2],m=n[c*2+1],d,y;u?(d=s[c*2],y=s[c*2+1]):(d=Number(s[c]),y=0);let f=Math.hypot(l,m),p=Math.atan2(m,l),g=Math.log(f),h=p,b=d*g-y*h,A=d*h+y*g,S=Math.exp(b);i[c*2]=S*Math.cos(A),i[c*2+1]=S*Math.sin(A)}}return a}if(typeof t=="number"){let n=N.zeros(Array.from(r.shape),"float64"),o=n.data,a=r.data,i=r.size;for(let s=0;s<i;s++)o[s]=Math.pow(Number(a[s]),t);return n}return X(r,t,(n,o)=>Math.pow(n,o),"float_power")}function Vo(r,t){if(U(r.dtype,"fmod","fmod is not defined for complex numbers."),typeof t!="number"&&U(t.dtype,"fmod","fmod is not defined for complex numbers."),typeof t=="number"){let e=r.copy(),n=e.data,o=r.size;for(let a=0;a<o;a++){let i=Number(n[a]);n[a]=i-Math.trunc(i/t)*t}return e}return X(r,t,(e,n)=>e-Math.trunc(e/n)*n,"fmod")}function Po(r){U(r.dtype,"frexp","frexp is not defined for complex numbers.");let t=N.zeros(Array.from(r.shape),"float64"),e=N.zeros(Array.from(r.shape),"int32"),n=t.data,o=e.data,a=r.data,i=r.size;for(let s=0;s<i;s++){let u=Number(a[s]);if(u===0||!isFinite(u))n[s]=u,o[s]=0;else{let c=Math.floor(Math.log2(Math.abs(u)))+1,l=u/Math.pow(2,c);n[s]=l,o[s]=c}}return[t,e]}function jo(r,t){U(r.dtype,"gcd","GCD is only defined for integers."),typeof t!="number"&&U(t.dtype,"gcd","GCD is only defined for integers.");let e=(u,c)=>{for(u=Math.abs(Math.trunc(u)),c=Math.abs(Math.trunc(c));c!==0;){let l=c;c=u%c,u=l}return u};if(typeof t=="number"){let u=N.zeros(Array.from(r.shape),"int32"),c=u.data,l=r.data,m=r.size,d=Math.abs(Math.trunc(t));for(let y=0;y<m;y++)c[y]=e(Number(l[y]),d);return u}let n=X(r,t,e,"gcd"),o=N.zeros(Array.from(n.shape),"int32"),a=o.data,i=n.data,s=n.size;for(let u=0;u<s;u++)a[u]=Math.round(Number(i[u]));return o}function Lo(r,t){U(r.dtype,"lcm","LCM is only defined for integers."),typeof t!="number"&&U(t.dtype,"lcm","LCM is only defined for integers.");let e=(c,l)=>{for(c=Math.abs(Math.trunc(c)),l=Math.abs(Math.trunc(l));l!==0;){let m=l;l=c%l,c=m}return c},n=(c,l)=>(c=Math.abs(Math.trunc(c)),l=Math.abs(Math.trunc(l)),c===0||l===0?0:c*l/e(c,l));if(typeof t=="number"){let c=N.zeros(Array.from(r.shape),"int32"),l=c.data,m=r.data,d=r.size,y=Math.abs(Math.trunc(t));for(let f=0;f<d;f++)l[f]=n(Number(m[f]),y);return c}let o=X(r,t,n,"lcm"),a=N.zeros(Array.from(o.shape),"int32"),i=a.data,s=o.data,u=o.size;for(let c=0;c<u;c++)i[c]=Math.round(Number(s[c]));return a}function Wo(r,t){if(U(r.dtype,"ldexp","ldexp is not defined for complex numbers."),typeof t!="number"&&U(t.dtype,"ldexp","ldexp is not defined for complex numbers."),typeof t=="number"){let e=N.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.data,a=r.size,i=Math.pow(2,t);for(let s=0;s<a;s++)n[s]=Number(o[s])*i;return e}return X(r,t,(e,n)=>e*Math.pow(2,n),"ldexp")}function Go(r){U(r.dtype,"modf","modf is not defined for complex numbers.");let t=N.zeros(Array.from(r.shape),"float64"),e=N.zeros(Array.from(r.shape),"float64"),n=t.data,o=e.data,a=r.data,i=r.size;for(let s=0;s<i;s++){let u=Number(a[s]),c=Math.trunc(u);o[s]=c,n[s]=u-c}return[t,e]}function Zo(r,t,e){U(r.dtype,"clip","clip is not supported for complex numbers.");let n=r.dtype,o=Array.from(r.shape),a=r.size,i=N.zeros(o,n),s=i.data,u=r.data,c=t===null||typeof t=="number",l=e===null||typeof e=="number",m=t===null?-1/0:typeof t=="number"?t:null,d=e===null?1/0:typeof e=="number"?e:null;if(B(n)){let y=s,f=u;for(let p=0;p<a;p++){let g=f[p],h=c?m===-1/0?g:BigInt(Math.round(m)):t.data[p%t.size],b=l?d===1/0?g:BigInt(Math.round(d)):e.data[p%e.size];g<h&&(g=h),g>b&&(g=b),y[p]=g}}else for(let y=0;y<a;y++){let f=Number(u[y]),p=c?m:Number(t.data[y%t.size]),g=l?d:Number(e.data[y%e.size]);f<p&&(f=p),f>g&&(f=g),s[y]=f}return i}function Yo(r,t){if(U(r.dtype,"maximum","maximum is not supported for complex numbers."),typeof t!="number"&&U(t.dtype,"maximum","maximum is not supported for complex numbers."),typeof t=="number"){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=N.zeros(n,e),i=a.data,s=r.data;if(B(e)){let u=i,c=s,l=BigInt(Math.round(t));for(let m=0;m<o;m++)u[m]=c[m]>l?c[m]:l}else for(let u=0;u<o;u++){let c=Number(s[u]);i[u]=isNaN(c)||isNaN(t)?NaN:Math.max(c,t)}return a}return X(r,t,(e,n)=>isNaN(e)||isNaN(n)?NaN:Math.max(e,n),"maximum")}function Ho(r,t){if(U(r.dtype,"minimum","minimum is not supported for complex numbers."),typeof t!="number"&&U(t.dtype,"minimum","minimum is not supported for complex numbers."),typeof t=="number"){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=N.zeros(n,e),i=a.data,s=r.data;if(B(e)){let u=i,c=s,l=BigInt(Math.round(t));for(let m=0;m<o;m++)u[m]=c[m]<l?c[m]:l}else for(let u=0;u<o;u++){let c=Number(s[u]);i[u]=isNaN(c)||isNaN(t)?NaN:Math.min(c,t)}return a}return X(r,t,(e,n)=>isNaN(e)||isNaN(n)?NaN:Math.min(e,n),"minimum")}function Xo(r,t){if(U(r.dtype,"fmax","fmax is not supported for complex numbers."),typeof t!="number"&&U(t.dtype,"fmax","fmax is not supported for complex numbers."),typeof t=="number"){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=N.zeros(n,e),i=a.data,s=r.data;if(B(e)){let u=i,c=s,l=BigInt(Math.round(t));for(let m=0;m<o;m++)u[m]=c[m]>l?c[m]:l}else for(let u=0;u<o;u++){let c=Number(s[u]);isNaN(c)?i[u]=t:isNaN(t)?i[u]=c:i[u]=Math.max(c,t)}return a}return X(r,t,(e,n)=>isNaN(e)?n:isNaN(n)?e:Math.max(e,n),"fmax")}function Jo(r,t){if(U(r.dtype,"fmin","fmin is not supported for complex numbers."),typeof t!="number"&&U(t.dtype,"fmin","fmin is not supported for complex numbers."),typeof t=="number"){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=N.zeros(n,e),i=a.data,s=r.data;if(B(e)){let u=i,c=s,l=BigInt(Math.round(t));for(let m=0;m<o;m++)u[m]=c[m]<l?c[m]:l}else for(let u=0;u<o;u++){let c=Number(s[u]);isNaN(c)?i[u]=t:isNaN(t)?i[u]=c:i[u]=Math.min(c,t)}return a}return X(r,t,(e,n)=>isNaN(e)?n:isNaN(n)?e:Math.min(e,n),"fmin")}function Qo(r,t=0,e,n){U(r.dtype,"nan_to_num","nan_to_num is not supported for complex numbers.");let o=r.dtype,a=Array.from(r.shape),i=r.size,s=e!==void 0?e:Number.MAX_VALUE,u=n!==void 0?n:-Number.MAX_VALUE,c=N.zeros(a,o),l=c.data,m=r.data;if(B(o)){let d=l,y=m;for(let f=0;f<i;f++)d[f]=y[f]}else for(let d=0;d<i;d++){let y=Number(m[d]);isNaN(y)?l[d]=t:y===1/0?l[d]=s:y===-1/0?l[d]=u:l[d]=y}return c}function Ko(r,t,e,n,o){U(r.dtype,"interp","interp is not supported for complex numbers."),U(t.dtype,"interp","interp is not supported for complex numbers."),U(e.dtype,"interp","interp is not supported for complex numbers.");let a=Array.from(r.shape),i=r.size,s=N.zeros(a,"float64"),u=s.data,c=r.data,l=t.data,m=e.data,d=t.size,y=n!==void 0?n:Number(m[0]),f=o!==void 0?o:Number(m[d-1]);for(let p=0;p<i;p++){let g=Number(c[p]);if(g<=Number(l[0])){u[p]=y;continue}if(g>=Number(l[d-1])){u[p]=f;continue}let h=0,b=d-1;for(;b-h>1;){let I=Math.floor((h+b)/2);Number(l[I])<=g?h=I:b=I}let A=Number(l[h]),S=Number(l[b]),D=Number(m[h]),w=Number(m[b]),x=(g-A)/(S-A);u[p]=D+x*(w-D)}return s}function ra(r,t=Math.PI,e=-1,n=2*Math.PI){U(r.dtype,"unwrap","unwrap is not supported for complex numbers.");let o=Array.from(r.shape),a=o.length;if(e<0&&(e+=a),e<0||e>=a)throw new Error(`axis ${e} is out of bounds for array of dimension ${a}`);if(a===1){let c=r.size,l=N.zeros(o,"float64"),m=l.data,d=r.data;if(c===0)return l;m[0]=Number(d[0]);let y=0;for(let f=1;f<c;f++){let p=Number(d[f-1]),g=Number(d[f]),h=g-p;h=(h+n/2)%n-n/2,h===-n/2&&g-p>0&&(h=n/2),Math.abs(h)>t&&(y-=Math.round((g-p-h)/n)*n),m[f]=g+y}return l}let i=N.zeros(o,"float64"),s=i.data,u=r.data;for(let c=0;c<r.size;c++)s[c]=Number(u[c]);if(a===2){let[c,l]=o;if(e===0)for(let m=0;m<l;m++){let d=0;for(let y=1;y<c;y++){let f=(y-1)*l+m,p=y*l+m,g=s[f],h=s[p],b=h-g;b=(b+n/2)%n-n/2,b===-n/2&&h-g>0&&(b=n/2),Math.abs(b)>t&&(d-=Math.round((h-g-b)/n)*n),s[p]=h+d}}else for(let m=0;m<c;m++){let d=0;for(let y=1;y<l;y++){let f=m*l+(y-1),p=m*l+y,g=s[f],h=s[p],b=h-g;b=(b+n/2)%n-n/2,b===-n/2&&h-g>0&&(b=n/2),Math.abs(b)>t&&(d-=Math.round((h-g-b)/n)*n),s[p]=h+d}}}return i}function ta(r){U(r.dtype,"sinc","sinc is not supported for complex numbers.");let t=Array.from(r.shape),e=r.size,n=N.zeros(t,"float64"),o=n.data,a=r.data;for(let i=0;i<e;i++){let s=Number(a[i]);if(s===0)o[i]=1;else{let u=Math.PI*s;o[i]=Math.sin(u)/u}}return n}function ea(r){U(r.dtype,"i0","i0 is not supported for complex numbers.");let t=Array.from(r.shape),e=r.size,n=N.zeros(t,"float64"),o=n.data,a=r.data;for(let i=0;i<e;i++){let s=Math.abs(Number(a[i]));o[i]=pd(s)}return n}function pd(r){let t=Math.abs(r);if(t<3.75){let e=r/3.75,n=e*e;return 1+n*(3.5156229+n*(3.0899424+n*(1.2067492+n*(.2659732+n*(.0360768+n*.0045813)))))}else{let e=3.75/t;return Math.exp(t)/Math.sqrt(t)*(.39894228+e*(.01328592+e*(.00225319+e*(-.00157565+e*(.00916281+e*(-.02057706+e*(.02635537+e*(-.01647633+e*.00392377))))))))}}var na=G(()=>{"use strict";K();Q();Er()});function jr(r,t){return[r[t*2],r[t*2+1]]}function oa(r,t){if(M(r.dtype))return jr(r.data,t);let e=r.iget(t);return e instanceof E?[e.re,e.im]:[Number(e),0]}function Jr(r,t,e){let n=Sr([Array.from(r.shape),Array.from(t.shape)]);if(!n)throw new Error("Cannot broadcast arrays together");let o=gr(r,n),a=gr(t,n),i=n.reduce((u,c)=>u*c,1),s=new Uint8Array(i);for(let u=0;u<i;u++){let[c,l]=oa(o,u),[m,d]=oa(a,u);s[u]=e(c,l,m,d)?1:0}return N.fromData(s,n,"bool")}function aa(r,t){return typeof t=="number"?dd(r,t):M(r.dtype)||M(t.dtype)?Jr(r,t,(e,n,o,a)=>e!==o?e>o:n>a):Ar(r,t,(e,n)=>e>n)}function sa(r,t){return typeof t=="number"?gd(r,t):M(r.dtype)||M(t.dtype)?Jr(r,t,(e,n,o,a)=>e!==o?e>=o:n>=a):Ar(r,t,(e,n)=>e>=n)}function ia(r,t){return typeof t=="number"?Ad(r,t):M(r.dtype)||M(t.dtype)?Jr(r,t,(e,n,o,a)=>e!==o?e<o:n<a):Ar(r,t,(e,n)=>e<n)}function ua(r,t){return typeof t=="number"?bd(r,t):M(r.dtype)||M(t.dtype)?Jr(r,t,(e,n,o,a)=>e!==o?e<=o:n<=a):Ar(r,t,(e,n)=>e<=n)}function ca(r,t){return typeof t=="number"?hd(r,t):M(r.dtype)||M(t.dtype)?Jr(r,t,(e,n,o,a)=>e===o&&n===a):Ar(r,t,(e,n)=>e===n)}function la(r,t){return typeof t=="number"?Sd(r,t):M(r.dtype)||M(t.dtype)?Jr(r,t,(e,n,o,a)=>e!==o||n!==a):Ar(r,t,(e,n)=>e!==n)}function Fe(r,t,e=1e-5,n=1e-8){return typeof t=="number"?Dd(r,t,e,n):Ar(r,t,(o,a)=>{let i=Math.abs(o-a),s=n+e*Math.abs(a);return i<=s})}function fa(r,t,e=1e-5,n=1e-8){let o=Fe(r,t,e,n),a=o.data;for(let i=0;i<o.size;i++)if(a[i]===0)return!1;return!0}function ma(r,t){let e=[Array.from(r.shape),Array.from(t.shape)],n=Sr(e);if(n===null)return!1;let o=gr(r,n),a=gr(t,n),i=n.length,s=n.reduce((l,m)=>l*m,1),u=B(o.dtype),c=B(a.dtype);for(let l=0;l<s;l++){let m=l,d=new Array(i);for(let p=i-1;p>=0;p--)d[p]=m%n[p],m=Math.floor(m/n[p]);let y=o.get(...d),f=a.get(...d);if(u||c){let p=typeof y=="bigint"?y:BigInt(Number(y)),g=typeof f=="bigint"?f:BigInt(Number(f));if(p!==g)return!1}else if(y!==f)return!1}return!0}function dd(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[i,s]=jr(o,a);e[a]=(i!==t?i>t:s>0)?1:0}}else for(let o=0;o<r.size;o++)e[o]=n[o]>t?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function gd(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[i,s]=jr(o,a);e[a]=(i!==t?i>=t:s>=0)?1:0}}else for(let o=0;o<r.size;o++)e[o]=n[o]>=t?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function Ad(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[i,s]=jr(o,a);e[a]=(i!==t?i<t:s<0)?1:0}}else for(let o=0;o<r.size;o++)e[o]=n[o]<t?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function bd(r,t){let e=new Uint8Array(r.size),n=r.data;if(M(r.dtype)){let o=n;for(let a=0;a<r.size;a++){let[i,s]=jr(o,a);e[a]=(i!==t?i<=t:s<=0)?1:0}}else for(let o=0;o<r.size;o++)e[o]=n[o]<=t?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function hd(r,t){let e=new Uint8Array(r.size),n=r.data,o=r.dtype;if(M(o)){let a=n;for(let i=0;i<r.size;i++){let[s,u]=jr(a,i);e[i]=s===t&&u===0?1:0}}else if(B(o)){let a=BigInt(Math.round(t)),i=n;for(let s=0;s<r.size;s++)e[s]=i[s]===a?1:0}else for(let a=0;a<r.size;a++)e[a]=n[a]===t?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function Sd(r,t){let e=new Uint8Array(r.size),n=r.data,o=r.dtype;if(M(o)){let a=n;for(let i=0;i<r.size;i++){let[s,u]=jr(a,i);e[i]=s!==t||u!==0?1:0}}else for(let a=0;a<r.size;a++)e[a]=n[a]!==t?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function Dd(r,t,e,n){let o=new Uint8Array(r.size),a=r.data,i=r.dtype;if(B(i)){let s=a;for(let u=0;u<r.size;u++){let c=Number(s[u]),l=Math.abs(c-t),m=n+e*Math.abs(t);o[u]=l<=m?1:0}}else for(let s=0;s<r.size;s++){let u=Number(a[s]),c=Math.abs(u-t),l=n+e*Math.abs(t);o[s]=c<=l?1:0}return N.fromData(o,Array.from(r.shape),"bool")}var pa=G(()=>{"use strict";K();Q();Er();Rt();xr()});function $(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(r,t,e,n){let o=n.length,a=new Array(o),i=Array.from(n).filter((u,c)=>c!==t),s=r;for(let u=i.length-1;u>=0;u--)a[u>=t?u+1:u]=s%i[u],s=Math.floor(s/i[u]);return a[t]=e,a}var Me=G(()=>{"use strict"});function ft(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,i=r.size,s=r.data;if(t===void 0)if(M(n)){let f=s,p=0,g=0;for(let h=0;h<i;h++)p+=f[h*2],g+=f[h*2+1];return new E(p,g)}else if(B(n)){let f=s,p=BigInt(0);for(let g=0;g<i;g++)p+=f[g];return Number(p)}else{let f=0;for(let p=0;p<i;p++)f+=Number(s[p]);return f}let u=t;if(u<0&&(u=a+u),u<0||u>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((f,p)=>p!==u);if(c.length===0)return ft(r);let l=N.zeros(c,n),m=l.data,d=o[u],y=c.reduce((f,p)=>f*p,1);if(M(n)){let f=s,p=m;for(let g=0;g<y;g++){let h=0,b=0;for(let A=0;A<d;A++){let S=R(g,u,A,o),D=$(S,o);h+=f[D*2],b+=f[D*2+1]}p[g*2]=h,p[g*2+1]=b}}else if(B(n)){let f=s,p=m;for(let g=0;g<y;g++){let h=BigInt(0);for(let b=0;b<d;b++){let A=R(g,u,b,o),S=$(A,o);h+=f[S]}p[g]=h}}else for(let f=0;f<y;f++){let p=0;for(let g=0;g<d;g++){let h=R(f,u,g,o),b=$(h,o);p+=Number(s[b])}m[f]=p}if(e){let f=[...o];return f[u]=1,N.fromData(m,f,n)}return l}function Vt(r,t,e=!1){let n=r.dtype,o=r.shape;if(t===void 0){let d=ft(r);return d instanceof E?new E(d.re/r.size,d.im/r.size):d/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 i=ft(r,t,e);if(typeof i=="number")return i/o[a];if(i instanceof E)return new E(i.re/o[a],i.im/o[a]);let s=o[a],u=n;M(n)?u=n:(B(n)||n.startsWith("int")||n.startsWith("uint"))&&(u="float64");let c=N.zeros(Array.from(i.shape),u),l=c.data,m=i.data;if(M(n)){let d=m,y=l,f=i.size;for(let p=0;p<f;p++)y[p*2]=d[p*2]/s,y[p*2+1]=d[p*2+1]/s}else if(B(n)){let d=m;for(let y=0;y<l.length;y++)l[y]=Number(d[y])/s}else for(let d=0;d<l.length;d++)l[d]=Number(m[d])/s;return c}function Qr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,i=r.size,s=r.data;if(M(n)){let f=s;if(t===void 0){if(i===0)throw new Error("max of empty array");let D=f[0],w=f[1];for(let x=1;x<i;x++){let I=f[x*2],z=f[x*2+1];if(isNaN(I)||isNaN(z))return new E(NaN,NaN);(I>D||I===D&&z>w)&&(D=I,w=z)}return isNaN(D)||isNaN(w)?new E(NaN,NaN):new E(D,w)}let p=t;if(p<0&&(p=a+p),p<0||p>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let g=Array.from(o).filter((D,w)=>w!==p);if(g.length===0)return Qr(r);let h=N.zeros(g,n),b=h.data,A=o[p],S=g.reduce((D,w)=>D*w,1);for(let D=0;D<S;D++){let w=R(D,p,0,o),x=$(w,o),I=f[x*2],z=f[x*2+1];for(let F=1;F<A;F++){let v=R(D,p,F,o),T=$(v,o),O=f[T*2],C=f[T*2+1];if(isNaN(O)||isNaN(C)){I=NaN,z=NaN;break}(O>I||O===I&&C>z)&&(I=O,z=C)}b[D*2]=I,b[D*2+1]=z}if(e){let D=[...o];return D[p]=1,N.fromData(b,D,n)}return h}if(t===void 0){if(i===0)throw new Error("max of empty array");let f=s[0];for(let p=1;p<i;p++)s[p]>f&&(f=s[p]);return Number(f)}let u=t;if(u<0&&(u=a+u),u<0||u>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((f,p)=>p!==u);if(c.length===0)return Qr(r);let l=N.zeros(c,n),m=l.data,d=o[u],y=c.reduce((f,p)=>f*p,1);if(B(n)){let f=s,p=m;for(let g=0;g<y;g++){let h=R(g,u,0,o),b=$(h,o),A=f[b];for(let S=1;S<d;S++){let D=R(g,u,S,o),w=$(D,o),x=f[w];x>A&&(A=x)}p[g]=A}}else for(let f=0;f<y;f++){let p=-1/0;for(let g=0;g<d;g++){let h=R(f,u,g,o),b=$(h,o),A=Number(s[b]);A>p&&(p=A)}m[f]=p}if(e){let f=[...o];return f[u]=1,N.fromData(m,f,n)}return l}function Be(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,i=r.size,s=r.data;if(t===void 0)if(M(n)){let f=s,p=1,g=0;for(let h=0;h<i;h++){let b=f[h*2],A=f[h*2+1],S=p*b-g*A,D=p*A+g*b;p=S,g=D}return new E(p,g)}else if(B(n)){let f=s,p=BigInt(1);for(let g=0;g<i;g++)p*=f[g];return Number(p)}else{let f=1;for(let p=0;p<i;p++)f*=Number(s[p]);return f}let u=t;if(u<0&&(u=a+u),u<0||u>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((f,p)=>p!==u);if(c.length===0)return Be(r);let l=N.zeros(c,n),m=l.data,d=o[u],y=c.reduce((f,p)=>f*p,1);if(M(n)){let f=s,p=m;for(let g=0;g<y;g++){let h=1,b=0;for(let A=0;A<d;A++){let S=R(g,u,A,o),D=$(S,o),w=f[D*2],x=f[D*2+1],I=h*w-b*x,z=h*x+b*w;h=I,b=z}p[g*2]=h,p[g*2+1]=b}}else if(B(n)){let f=s,p=m;for(let g=0;g<y;g++){let h=BigInt(1);for(let b=0;b<d;b++){let A=R(g,u,b,o),S=$(A,o);h*=f[S]}p[g]=h}}else for(let f=0;f<y;f++){let p=1;for(let g=0;g<d;g++){let h=R(f,u,g,o),b=$(h,o);p*=Number(s[b])}m[f]=p}if(e){let f=[...o];return f[u]=1,N.fromData(m,f,n)}return l}function Kr(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,i=r.size,s=r.data;if(M(n)){let f=s;if(t===void 0){if(i===0)throw new Error("min of empty array");let D=f[0],w=f[1];for(let x=1;x<i;x++){let I=f[x*2],z=f[x*2+1];if(isNaN(I)||isNaN(z))return new E(NaN,NaN);(I<D||I===D&&z<w)&&(D=I,w=z)}return isNaN(D)||isNaN(w)?new E(NaN,NaN):new E(D,w)}let p=t;if(p<0&&(p=a+p),p<0||p>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let g=Array.from(o).filter((D,w)=>w!==p);if(g.length===0)return Kr(r);let h=N.zeros(g,n),b=h.data,A=o[p],S=g.reduce((D,w)=>D*w,1);for(let D=0;D<S;D++){let w=R(D,p,0,o),x=$(w,o),I=f[x*2],z=f[x*2+1];for(let F=1;F<A;F++){let v=R(D,p,F,o),T=$(v,o),O=f[T*2],C=f[T*2+1];if(isNaN(O)||isNaN(C)){I=NaN,z=NaN;break}(O<I||O===I&&C<z)&&(I=O,z=C)}b[D*2]=I,b[D*2+1]=z}if(e){let D=[...o];return D[p]=1,N.fromData(b,D,n)}return h}if(t===void 0){if(i===0)throw new Error("min of empty array");let f=s[0];for(let p=1;p<i;p++)s[p]<f&&(f=s[p]);return Number(f)}let u=t;if(u<0&&(u=a+u),u<0||u>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((f,p)=>p!==u);if(c.length===0)return Kr(r);let l=N.zeros(c,n),m=l.data,d=o[u],y=c.reduce((f,p)=>f*p,1);if(B(n)){let f=s,p=m;for(let g=0;g<y;g++){let h=R(g,u,0,o),b=$(h,o),A=f[b];for(let S=1;S<d;S++){let D=R(g,u,S,o),w=$(D,o),x=f[w];x<A&&(A=x)}p[g]=A}}else for(let f=0;f<y;f++){let p=1/0;for(let g=0;g<d;g++){let h=R(f,u,g,o),b=$(h,o),A=Number(s[b]);A<p&&(p=A)}m[f]=p}if(e){let f=[...o];return f[u]=1,N.fromData(m,f,n)}return l}function $r(r,t,e,n){return r<e?-1:r>e?1:t<n?-1:t>n?1:0}function Ee(r,t){let e=r.dtype,n=M(e),o=r.shape,a=o.length,i=r.size,s=r.data;if(t===void 0){if(i===0)throw new Error("argmin of empty array");if(n){let g=s,h=g[0],b=g[1],A=0;for(let S=1;S<i;S++){let D=g[S*2],w=g[S*2+1];$r(D,w,h,b)<0&&(h=D,b=w,A=S)}return A}let f=s[0],p=0;for(let g=1;g<i;g++)s[g]<f&&(f=s[g],p=g);return p}let u=t;if(u<0&&(u=a+u),u<0||u>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((f,p)=>p!==u);if(c.length===0)return Ee(r);let l=N.zeros(c,"int32"),m=l.data,d=o[u],y=c.reduce((f,p)=>f*p,1);if(n){let f=s;for(let p=0;p<y;p++){let g=R(p,u,0,o),h=$(g,o),b=f[h*2],A=f[h*2+1],S=0;for(let D=1;D<d;D++){let w=R(p,u,D,o),x=$(w,o),I=f[x*2],z=f[x*2+1];$r(I,z,b,A)<0&&(b=I,A=z,S=D)}m[p]=S}}else if(B(e)){let f=s;for(let p=0;p<y;p++){let g=R(p,u,0,o),h=$(g,o),b=f[h],A=0;for(let S=1;S<d;S++){let D=R(p,u,S,o),w=$(D,o),x=f[w];x<b&&(b=x,A=S)}m[p]=A}}else for(let f=0;f<y;f++){let p=1/0,g=0;for(let h=0;h<d;h++){let b=R(f,u,h,o),A=$(b,o),S=Number(s[A]);S<p&&(p=S,g=h)}m[f]=g}return l}function Te(r,t){let e=r.dtype,n=M(e),o=r.shape,a=o.length,i=r.size,s=r.data;if(t===void 0){if(i===0)throw new Error("argmax of empty array");if(n){let g=s,h=g[0],b=g[1],A=0;for(let S=1;S<i;S++){let D=g[S*2],w=g[S*2+1];$r(D,w,h,b)>0&&(h=D,b=w,A=S)}return A}let f=s[0],p=0;for(let g=1;g<i;g++)s[g]>f&&(f=s[g],p=g);return p}let u=t;if(u<0&&(u=a+u),u<0||u>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let c=Array.from(o).filter((f,p)=>p!==u);if(c.length===0)return Te(r);let l=N.zeros(c,"int32"),m=l.data,d=o[u],y=c.reduce((f,p)=>f*p,1);if(n){let f=s;for(let p=0;p<y;p++){let g=R(p,u,0,o),h=$(g,o),b=f[h*2],A=f[h*2+1],S=0;for(let D=1;D<d;D++){let w=R(p,u,D,o),x=$(w,o),I=f[x*2],z=f[x*2+1];$r(I,z,b,A)>0&&(b=I,A=z,S=D)}m[p]=S}}else if(B(e)){let f=s;for(let p=0;p<y;p++){let g=R(p,u,0,o),h=$(g,o),b=f[h],A=0;for(let S=1;S<d;S++){let D=R(p,u,S,o),w=$(D,o),x=f[w];x>b&&(b=x,A=S)}m[p]=A}}else for(let f=0;f<y;f++){let p=-1/0,g=0;for(let h=0;h<d;h++){let b=R(f,u,h,o),A=$(b,o),S=Number(s[A]);S>p&&(p=S,g=h)}m[f]=g}return l}function Oe(r,t,e=0,n=!1){let o=r.dtype,a=r.shape,i=a.length,s=r.size,u=r.data,c=Vt(r,t,n);if(t===void 0){if(M(o)){let S=u,D=c,w=0;for(let x=0;x<s;x++){let I=S[x*2],z=S[x*2+1],F=I-D.re,v=z-D.im;w+=F*F+v*v}return w/(s-e)}let b=c,A=0;for(let S=0;S<s;S++){let D=Number(u[S])-b;A+=D*D}return A/(s-e)}let l=t;if(l<0&&(l=i+l),l<0||l>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let m=a[l],d=c,y=d.data,f=n?d.shape:Array.from(a).filter((b,A)=>A!==l),p=N.zeros(Array.from(f),"float64"),g=p.data,h=f.reduce((b,A)=>b*A,1);if(M(o)){let b=u,A=y;for(let S=0;S<h;S++){let D=0,w=A[S*2],x=A[S*2+1];for(let I=0;I<m;I++){let z=R(S,l,I,a),F=$(z,a),v=b[F*2],T=b[F*2+1],O=v-w,C=T-x;D+=O*O+C*C}g[S]=D/(m-e)}}else for(let b=0;b<h;b++){let A=0,S=Number(y[b]);for(let D=0;D<m;D++){let w=R(b,l,D,a),x=$(w,a),I=Number(u[x])-S;A+=I*I}g[b]=A/(m-e)}return p}function ya(r,t,e=0,n=!1){let o=Oe(r,t,e,n);if(typeof o=="number")return Math.sqrt(o);let a=N.zeros(Array.from(o.shape),"float64"),i=o.data,s=a.data;for(let u=0;u<i.length;u++)s[u]=Math.sqrt(Number(i[u]));return a}function Ce(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,i=r.data;if(t===void 0){for(let y=0;y<a;y++)if(!i[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 u=Array.from(n).filter((y,f)=>f!==s);if(u.length===0)return Ce(r);let c=N.zeros(u,"bool"),l=c.data,m=n[s],d=u.reduce((y,f)=>y*f,1);for(let y=0;y<d;y++){let f=!0;for(let p=0;p<m;p++){let g=R(y,s,p,n),h=$(g,n);if(!i[h]){f=!1;break}}l[y]=f?1:0}if(e){let y=[...n];return y[s]=1,N.fromData(l,y,"bool")}return c}function Ue(r,t,e=!1){let n=r.shape,o=n.length,a=r.size,i=r.data;if(t===void 0){for(let y=0;y<a;y++)if(i[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 u=Array.from(n).filter((y,f)=>f!==s);if(u.length===0)return Ue(r);let c=N.zeros(u,"bool"),l=c.data,m=n[s],d=u.reduce((y,f)=>y*f,1);for(let y=0;y<d;y++){let f=!1;for(let p=0;p<m;p++){let g=R(y,s,p,n),h=$(g,n);if(i[h]){f=!0;break}}l[y]=f?1:0}if(e){let y=[...n];return y[s]=1,N.fromData(l,y,"bool")}return c}function $e(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let y=a,f=r.size;if(t===void 0){let x=N.zeros([f],e),I=x.data,z=0,F=0;for(let v=0;v<f;v++)z+=y[v*2],F+=y[v*2+1],I[v*2]=z,I[v*2+1]=F;return x}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=N.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let x=o-1;x>=0;x--)A.unshift(S),S*=n[x];let D=r.size,w=A[p];for(let x=0;x<D;x++)Math.floor(x/w)%b===0?(h[x*2]=y[x*2],h[x*2+1]=y[x*2+1]):(h[x*2]=h[(x-w)*2]+y[x*2],h[x*2+1]=h[(x-w)*2+1]+y[x*2+1]);return g}if(t===void 0){let y=r.size,f=new Float64Array(y),p=0;for(let g=0;g<y;g++)p+=Number(a[g]),f[g]=p;return N.fromData(f,[y],"float64")}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=new Float64Array(r.size),u=n[i],c=[],l=1;for(let y=o-1;y>=0;y--)c.unshift(l),l*=n[y];let m=r.size,d=c[i];for(let y=0;y<m;y++)Math.floor(y/d)%u===0?s[y]=Number(a[y]):s[y]=s[y-d]+Number(a[y]);return N.fromData(s,[...n],"float64")}function Re(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let y=a,f=r.size;if(t===void 0){let x=N.zeros([f],e),I=x.data,z=1,F=0;for(let v=0;v<f;v++){let T=y[v*2],O=y[v*2+1],C=z*T-F*O,q=z*O+F*T;z=C,F=q,I[v*2]=z,I[v*2+1]=F}return x}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=N.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let x=o-1;x>=0;x--)A.unshift(S),S*=n[x];let D=r.size,w=A[p];for(let x=0;x<D;x++)if(Math.floor(x/w)%b===0)h[x*2]=y[x*2],h[x*2+1]=y[x*2+1];else{let z=h[(x-w)*2],F=h[(x-w)*2+1],v=y[x*2],T=y[x*2+1];h[x*2]=z*v-F*T,h[x*2+1]=z*T+F*v}return g}if(t===void 0){let y=r.size,f=new Float64Array(y),p=1;for(let g=0;g<y;g++)p*=Number(a[g]),f[g]=p;return N.fromData(f,[y],"float64")}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=new Float64Array(r.size),u=n[i],c=[],l=1;for(let y=o-1;y>=0;y--)c.unshift(l),l*=n[y];let m=r.size,d=c[i];for(let y=0;y<m;y++)Math.floor(y/d)%u===0?s[y]=Number(a[y]):s[y]=s[y-d]*Number(a[y]);return N.fromData(s,[...n],"float64")}function ke(r,t,e=!1){let n=r.dtype;if(M(n)){let m=Qr(r,t,e),d=Kr(r,t,e);if(m instanceof E&&d instanceof E)return new E(m.re-d.re,m.im-d.im);let y=m,f=d,p=y.data,g=f.data,h=new Float64Array(y.size*2);for(let b=0;b<y.size;b++)h[b*2]=p[b*2]-g[b*2],h[b*2+1]=p[b*2+1]-g[b*2+1];return N.fromData(h,[...y.shape],n)}let o=Qr(r,t,e),a=Kr(r,t,e);if(typeof o=="number"&&typeof a=="number")return o-a;let i=o,s=a,u=i.data,c=s.data,l=new Float64Array(i.size);for(let m=0;m<i.size;m++)l[m]=Number(u[m])-Number(c[m]);return N.fromData(l,[...i.shape],"float64")}function qe(r,t,e=!1){return tt(r,.5,t,e)}function Ve(r,t,e,n=!1){return tt(r,t/100,e,n)}function tt(r,t,e,n=!1){if(U(r.dtype,"quantile","Complex numbers are not orderable."),t<0||t>1)throw new Error("Quantile must be between 0 and 1");let o=r.shape,a=o.length,i=r.data;if(e===void 0){let y=[];for(let A=0;A<r.size;A++)y.push(Number(i[A]));y.sort((A,S)=>A-S);let f=y.length,p=t*(f-1),g=Math.floor(p),h=Math.ceil(p);if(g===h)return y[g];let b=p-g;return y[g]*(1-b)+y[h]*b}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 u=Array.from(o).filter((y,f)=>f!==s);if(u.length===0)return tt(r,t);let c=u.reduce((y,f)=>y*f,1),l=o[s],m=new Float64Array(c);for(let y=0;y<c;y++){let f=[];for(let A=0;A<l;A++){let S=R(y,s,A,o),D=$(S,o);f.push(Number(i[D]))}f.sort((A,S)=>A-S);let p=f.length,g=t*(p-1),h=Math.floor(g),b=Math.ceil(g);if(h===b)m[y]=f[h];else{let A=g-h;m[y]=f[h]*(1-A)+f[b]*A}}let d=N.fromData(m,u,"float64");if(n){let y=[...o];return y[s]=1,N.fromData(m,y,"float64")}return d}function mt(r,t,e,n=!1){let o=r.dtype,a=r.shape,i=a.length,s=r.data;if(e===void 0)return Vt(r,t,n);if(M(o)){let p=s,g=e.data;if(t===void 0){let x=0,I=0,z=0;for(let F=0;F<r.size;F++){let v=Number(g[F%e.size]),T=p[F*2],O=p[F*2+1];x+=T*v,I+=O*v,z+=v}return z===0?new E(NaN,NaN):new E(x/z,I/z)}let h=t;if(h<0&&(h=i+h),h<0||h>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let b=Array.from(a).filter((x,I)=>I!==h);if(b.length===0)return mt(r,void 0,e);let A=b.reduce((x,I)=>x*I,1),S=a[h],D=N.zeros(b,o),w=D.data;for(let x=0;x<A;x++){let I=0,z=0,F=0;for(let v=0;v<S;v++){let T=R(x,h,v,a),O=$(T,a),C=Number(g[v%e.size]),q=p[O*2],V=p[O*2+1];I+=q*C,z+=V*C,F+=C}F===0?(w[x*2]=NaN,w[x*2+1]=NaN):(w[x*2]=I/F,w[x*2+1]=z/F)}if(n){let x=[...a];return x[h]=1,N.fromData(w,x,o)}return D}if(t===void 0){let p=0,g=0,h=e.data;for(let b=0;b<r.size;b++){let A=Number(h[b%e.size]);p+=Number(s[b])*A,g+=A}return g===0?NaN:p/g}let u=t;if(u<0&&(u=i+u),u<0||u>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let c=Array.from(a).filter((p,g)=>g!==u);if(c.length===0)return mt(r,void 0,e);let l=c.reduce((p,g)=>p*g,1),m=a[u],d=e.data,y=new Float64Array(l);for(let p=0;p<l;p++){let g=0,h=0;for(let b=0;b<m;b++){let A=R(p,u,b,a),S=$(A,a),D=Number(d[b%e.size]);g+=Number(s[S])*D,h+=D}y[p]=h===0?NaN:g/h}let f=N.fromData(y,c,"float64");if(n){let p=[...a];return p[u]=1,N.fromData(y,p,"float64")}return f}function or(r,t){return isNaN(r)||isNaN(t)}function Pt(r,t,e=!1){let n=r.dtype,o=M(n),a=r.shape,i=a.length,s=r.data;if(t===void 0){if(o){let p=s,g=0,h=0;for(let b=0;b<r.size;b++){let A=p[b*2],S=p[b*2+1];or(A,S)||(g+=A,h+=S)}return new E(g,h)}let f=0;for(let p=0;p<r.size;p++){let g=Number(s[p]);isNaN(g)||(f+=g)}return f}let u=t;if(u<0&&(u=i+u),u<0||u>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let c=Array.from(a).filter((f,p)=>p!==u);if(c.length===0)return Pt(r);let l=c.reduce((f,p)=>f*p,1),m=a[u];if(o){let f=s,p=new Float64Array(l*2);for(let g=0;g<l;g++){let h=0,b=0;for(let A=0;A<m;A++){let S=R(g,u,A,a),D=$(S,a),w=f[D*2],x=f[D*2+1];or(w,x)||(h+=w,b+=x)}p[g*2]=h,p[g*2+1]=b}if(e){let g=[...a];return g[u]=1,N.fromData(p,g,n)}return N.fromData(p,c,n)}let d=new Float64Array(l);for(let f=0;f<l;f++){let p=0;for(let g=0;g<m;g++){let h=R(f,u,g,a),b=$(h,a),A=Number(s[b]);isNaN(A)||(p+=A)}d[f]=p}let y=N.fromData(d,c,"float64");if(e){let f=[...a];return f[u]=1,N.fromData(d,f,"float64")}return y}function jt(r,t,e=!1){let n=r.dtype,o=M(n),a=r.shape,i=a.length,s=r.data;if(t===void 0){if(o){let p=s,g=1,h=0;for(let b=0;b<r.size;b++){let A=p[b*2],S=p[b*2+1];if(!or(A,S)){let D=g*A-h*S,w=g*S+h*A;g=D,h=w}}return new E(g,h)}let f=1;for(let p=0;p<r.size;p++){let g=Number(s[p]);isNaN(g)||(f*=g)}return f}let u=t;if(u<0&&(u=i+u),u<0||u>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let c=Array.from(a).filter((f,p)=>p!==u);if(c.length===0)return jt(r);let l=c.reduce((f,p)=>f*p,1),m=a[u];if(o){let f=s,p=new Float64Array(l*2);for(let g=0;g<l;g++){let h=1,b=0;for(let A=0;A<m;A++){let S=R(g,u,A,a),D=$(S,a),w=f[D*2],x=f[D*2+1];if(!or(w,x)){let I=h*w-b*x,z=h*x+b*w;h=I,b=z}}p[g*2]=h,p[g*2+1]=b}if(e){let g=[...a];return g[u]=1,N.fromData(p,g,n)}return N.fromData(p,c,n)}let d=new Float64Array(l);for(let f=0;f<l;f++){let p=1;for(let g=0;g<m;g++){let h=R(f,u,g,a),b=$(h,a),A=Number(s[b]);isNaN(A)||(p*=A)}d[f]=p}let y=N.fromData(d,c,"float64");if(e){let f=[...a];return f[u]=1,N.fromData(d,f,"float64")}return y}function Lt(r,t,e=!1){let n=r.dtype,o=M(n),a=r.shape,i=a.length,s=r.data;if(t===void 0){if(o){let g=s,h=0,b=0,A=0;for(let S=0;S<r.size;S++){let D=g[S*2],w=g[S*2+1];or(D,w)||(h+=D,b+=w,A++)}return A===0?new E(NaN,NaN):new E(h/A,b/A)}let f=0,p=0;for(let g=0;g<r.size;g++){let h=Number(s[g]);isNaN(h)||(f+=h,p++)}return p===0?NaN:f/p}let u=t;if(u<0&&(u=i+u),u<0||u>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let c=Array.from(a).filter((f,p)=>p!==u);if(c.length===0)return Lt(r);let l=c.reduce((f,p)=>f*p,1),m=a[u];if(o){let f=s,p=new Float64Array(l*2);for(let g=0;g<l;g++){let h=0,b=0,A=0;for(let S=0;S<m;S++){let D=R(g,u,S,a),w=$(D,a),x=f[w*2],I=f[w*2+1];or(x,I)||(h+=x,b+=I,A++)}A===0?(p[g*2]=NaN,p[g*2+1]=NaN):(p[g*2]=h/A,p[g*2+1]=b/A)}if(e){let g=[...a];return g[u]=1,N.fromData(p,g,n)}return N.fromData(p,c,n)}let d=new Float64Array(l);for(let f=0;f<l;f++){let p=0,g=0;for(let h=0;h<m;h++){let b=R(f,u,h,a),A=$(b,a),S=Number(s[A]);isNaN(S)||(p+=S,g++)}d[f]=g===0?NaN:p/g}let y=N.fromData(d,c,"float64");if(e){let f=[...a];return f[u]=1,N.fromData(d,f,"float64")}return y}function rt(r,t,e=0,n=!1){let o=r.dtype,a=r.shape,i=a.length,s=r.data;if(M(o)){let f=s;if(t===void 0){let D=0,w=0,x=0;for(let v=0;v<r.size;v++){let T=f[v*2],O=f[v*2+1];or(T,O)||(D+=T,w+=O,x++)}if(x-e<=0)return NaN;let I=D/x,z=w/x,F=0;for(let v=0;v<r.size;v++){let T=f[v*2],O=f[v*2+1];if(!or(T,O)){let C=T-I,q=O-z;F+=C*C+q*q}}return F/(x-e)}let p=t;if(p<0&&(p=i+p),p<0||p>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let g=Array.from(a).filter((D,w)=>w!==p);if(g.length===0)return rt(r,void 0,e);let h=g.reduce((D,w)=>D*w,1),b=a[p],A=new Float64Array(h);for(let D=0;D<h;D++){let w=0,x=0,I=0;for(let T=0;T<b;T++){let O=R(D,p,T,a),C=$(O,a),q=f[C*2],V=f[C*2+1];or(q,V)||(w+=q,x+=V,I++)}if(I-e<=0){A[D]=NaN;continue}let z=w/I,F=x/I,v=0;for(let T=0;T<b;T++){let O=R(D,p,T,a),C=$(O,a),q=f[C*2],V=f[C*2+1];if(!or(q,V)){let k=q-z,W=V-F;v+=k*k+W*W}}A[D]=v/(I-e)}let S=N.fromData(A,g,"float64");if(n){let D=[...a];return D[p]=1,N.fromData(A,D,"float64")}return S}if(t===void 0){let f=0,p=0;for(let b=0;b<r.size;b++){let A=Number(s[b]);isNaN(A)||(f+=A,p++)}if(p-e<=0)return NaN;let g=f/p,h=0;for(let b=0;b<r.size;b++){let A=Number(s[b]);isNaN(A)||(h+=(A-g)**2)}return h/(p-e)}let u=t;if(u<0&&(u=i+u),u<0||u>=i)throw new Error(`axis ${t} is out of bounds for array of dimension ${i}`);let c=Array.from(a).filter((f,p)=>p!==u);if(c.length===0)return rt(r,void 0,e);let l=c.reduce((f,p)=>f*p,1),m=a[u],d=new Float64Array(l);for(let f=0;f<l;f++){let p=0,g=0;for(let A=0;A<m;A++){let S=R(f,u,A,a),D=$(S,a),w=Number(s[D]);isNaN(w)||(p+=w,g++)}if(g-e<=0){d[f]=NaN;continue}let h=p/g,b=0;for(let A=0;A<m;A++){let S=R(f,u,A,a),D=$(S,a),w=Number(s[D]);isNaN(w)||(b+=(w-h)**2)}d[f]=b/(g-e)}let y=N.fromData(d,c,"float64");if(n){let f=[...a];return f[u]=1,N.fromData(d,f,"float64")}return y}function Pe(r,t,e=0,n=!1){let o=rt(r,t,e,n);if(typeof o=="number")return Math.sqrt(o);let a=o,i=new Float64Array(a.size);for(let s=0;s<a.size;s++)i[s]=Math.sqrt(Number(a.data[s]));return N.fromData(i,[...a.shape],"float64")}function pt(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,i=r.data;if(M(n)){let y=i;if(t===void 0){let S=1/0,D=1/0,w=!1;for(let x=0;x<r.size;x++){let I=y[x*2],z=y[x*2+1];isNaN(I)||isNaN(z)||(w?(I<S||I===S&&z<D)&&(S=I,D=z):(S=I,D=z,w=!0))}return w?new E(S,D):new E(NaN,NaN)}let f=t;if(f<0&&(f=a+f),f<0||f>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let p=Array.from(o).filter((S,D)=>D!==f);if(p.length===0)return pt(r);let g=p.reduce((S,D)=>S*D,1),h=o[f],b=new Float64Array(g*2);for(let S=0;S<g;S++){let D=1/0,w=1/0,x=!1;for(let I=0;I<h;I++){let z=R(S,f,I,o),F=$(z,o),v=y[F*2],T=y[F*2+1];isNaN(v)||isNaN(T)||(x?(v<D||v===D&&T<w)&&(D=v,w=T):(D=v,w=T,x=!0))}b[S*2]=x?D:NaN,b[S*2+1]=x?w:NaN}let A=N.fromData(b,p,n);if(e){let S=[...o];return S[f]=1,N.fromData(b,S,n)}return A}if(t===void 0){let y=1/0;for(let f=0;f<r.size;f++){let p=Number(i[f]);!isNaN(p)&&p<y&&(y=p)}return y===1/0?NaN: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 u=Array.from(o).filter((y,f)=>f!==s);if(u.length===0)return pt(r);let c=u.reduce((y,f)=>y*f,1),l=o[s],m=new Float64Array(c);for(let y=0;y<c;y++){let f=1/0;for(let p=0;p<l;p++){let g=R(y,s,p,o),h=$(g,o),b=Number(i[h]);!isNaN(b)&&b<f&&(f=b)}m[y]=f===1/0?NaN:f}let d=N.fromData(m,u,"float64");if(e){let y=[...o];return y[s]=1,N.fromData(m,y,"float64")}return d}function yt(r,t,e=!1){let n=r.dtype,o=r.shape,a=o.length,i=r.data;if(M(n)){let y=i;if(t===void 0){let S=-1/0,D=-1/0,w=!1;for(let x=0;x<r.size;x++){let I=y[x*2],z=y[x*2+1];isNaN(I)||isNaN(z)||(w?(I>S||I===S&&z>D)&&(S=I,D=z):(S=I,D=z,w=!0))}return w?new E(S,D):new E(NaN,NaN)}let f=t;if(f<0&&(f=a+f),f<0||f>=a)throw new Error(`axis ${t} is out of bounds for array of dimension ${a}`);let p=Array.from(o).filter((S,D)=>D!==f);if(p.length===0)return yt(r);let g=p.reduce((S,D)=>S*D,1),h=o[f],b=new Float64Array(g*2);for(let S=0;S<g;S++){let D=-1/0,w=-1/0,x=!1;for(let I=0;I<h;I++){let z=R(S,f,I,o),F=$(z,o),v=y[F*2],T=y[F*2+1];isNaN(v)||isNaN(T)||(x?(v>D||v===D&&T>w)&&(D=v,w=T):(D=v,w=T,x=!0))}b[S*2]=x?D:NaN,b[S*2+1]=x?w:NaN}let A=N.fromData(b,p,n);if(e){let S=[...o];return S[f]=1,N.fromData(b,S,n)}return A}if(t===void 0){let y=-1/0;for(let f=0;f<r.size;f++){let p=Number(i[f]);!isNaN(p)&&p>y&&(y=p)}return y===-1/0?NaN: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 u=Array.from(o).filter((y,f)=>f!==s);if(u.length===0)return yt(r);let c=u.reduce((y,f)=>y*f,1),l=o[s],m=new Float64Array(c);for(let y=0;y<c;y++){let f=-1/0;for(let p=0;p<l;p++){let g=R(y,s,p,o),h=$(g,o),b=Number(i[h]);!isNaN(b)&&b>f&&(f=b)}m[y]=f===-1/0?NaN:f}let d=N.fromData(m,u,"float64");if(e){let y=[...o];return y[s]=1,N.fromData(m,y,"float64")}return d}function dt(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let m=a;if(t===void 0){let h=1/0,b=1/0,A=-1;for(let S=0;S<r.size;S++){let D=m[S*2],w=m[S*2+1];!or(D,w)&&$r(D,w,h,b)<0&&(h=D,b=w,A=S)}return A}let d=t;if(d<0&&(d=o+d),d<0||d>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let y=Array.from(n).filter((h,b)=>b!==d);if(y.length===0)return dt(r);let f=y.reduce((h,b)=>h*b,1),p=n[d],g=new Int32Array(f);for(let h=0;h<f;h++){let b=1/0,A=1/0,S=0;for(let D=0;D<p;D++){let w=R(h,d,D,n),x=$(w,n),I=m[x*2],z=m[x*2+1];!or(I,z)&&$r(I,z,b,A)<0&&(b=I,A=z,S=D)}g[h]=S}return N.fromData(g,y,"int32")}if(t===void 0){let m=1/0,d=-1;for(let y=0;y<r.size;y++){let f=Number(a[y]);!isNaN(f)&&f<m&&(m=f,d=y)}return d}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((m,d)=>d!==i);if(s.length===0)return dt(r);let u=s.reduce((m,d)=>m*d,1),c=n[i],l=new Int32Array(u);for(let m=0;m<u;m++){let d=1/0,y=0;for(let f=0;f<c;f++){let p=R(m,i,f,n),g=$(p,n),h=Number(a[g]);!isNaN(h)&&h<d&&(d=h,y=f)}l[m]=y}return N.fromData(l,s,"int32")}function gt(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let m=a;if(t===void 0){let h=-1/0,b=-1/0,A=-1;for(let S=0;S<r.size;S++){let D=m[S*2],w=m[S*2+1];!or(D,w)&&$r(D,w,h,b)>0&&(h=D,b=w,A=S)}return A}let d=t;if(d<0&&(d=o+d),d<0||d>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let y=Array.from(n).filter((h,b)=>b!==d);if(y.length===0)return gt(r);let f=y.reduce((h,b)=>h*b,1),p=n[d],g=new Int32Array(f);for(let h=0;h<f;h++){let b=-1/0,A=-1/0,S=0;for(let D=0;D<p;D++){let w=R(h,d,D,n),x=$(w,n),I=m[x*2],z=m[x*2+1];!or(I,z)&&$r(I,z,b,A)>0&&(b=I,A=z,S=D)}g[h]=S}return N.fromData(g,y,"int32")}if(t===void 0){let m=-1/0,d=-1;for(let y=0;y<r.size;y++){let f=Number(a[y]);!isNaN(f)&&f>m&&(m=f,d=y)}return d}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((m,d)=>d!==i);if(s.length===0)return gt(r);let u=s.reduce((m,d)=>m*d,1),c=n[i],l=new Int32Array(u);for(let m=0;m<u;m++){let d=-1/0,y=0;for(let f=0;f<c;f++){let p=R(m,i,f,n),g=$(p,n),h=Number(a[g]);!isNaN(h)&&h>d&&(d=h,y=f)}l[m]=y}return N.fromData(l,s,"int32")}function je(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let y=a,f=r.size;if(t===void 0){let x=N.zeros([f],e),I=x.data,z=0,F=0;for(let v=0;v<f;v++){let T=y[v*2],O=y[v*2+1];or(T,O)||(z+=T,F+=O),I[v*2]=z,I[v*2+1]=F}return x}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=N.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let x=o-1;x>=0;x--)A.unshift(S),S*=n[x];let D=r.size,w=A[p];for(let x=0;x<D;x++){let I=y[x*2],z=y[x*2+1],F=Math.floor(x/w)%b,v=or(I,z);F===0?(h[x*2]=v?0:I,h[x*2+1]=v?0:z):(h[x*2]=h[(x-w)*2]+(v?0:I),h[x*2+1]=h[(x-w)*2+1]+(v?0:z))}return g}if(t===void 0){let y=r.size,f=new Float64Array(y),p=0;for(let g=0;g<y;g++){let h=Number(a[g]);isNaN(h)||(p+=h),f[g]=p}return N.fromData(f,[y],"float64")}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=new Float64Array(r.size),u=n[i],c=[],l=1;for(let y=o-1;y>=0;y--)c.unshift(l),l*=n[y];let m=r.size,d=c[i];for(let y=0;y<m;y++){let f=Number(a[y]);Math.floor(y/d)%u===0?s[y]=isNaN(f)?0:f:s[y]=s[y-d]+(isNaN(f)?0:f)}return N.fromData(s,[...n],"float64")}function Le(r,t){let e=r.dtype,n=r.shape,o=n.length,a=r.data;if(M(e)){let y=a,f=r.size;if(t===void 0){let x=N.zeros([f],e),I=x.data,z=1,F=0;for(let v=0;v<f;v++){let T=y[v*2],O=y[v*2+1];if(!or(T,O)){let C=z*T-F*O,q=z*O+F*T;z=C,F=q}I[v*2]=z,I[v*2+1]=F}return x}let p=t;if(p<0&&(p=o+p),p<0||p>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let g=N.zeros([...n],e),h=g.data,b=n[p],A=[],S=1;for(let x=o-1;x>=0;x--)A.unshift(S),S*=n[x];let D=r.size,w=A[p];for(let x=0;x<D;x++){let I=y[x*2],z=y[x*2+1],F=Math.floor(x/w)%b,v=or(I,z);if(F===0)h[x*2]=v?1:I,h[x*2+1]=v?0:z;else{let T=h[(x-w)*2],O=h[(x-w)*2+1];v?(h[x*2]=T,h[x*2+1]=O):(h[x*2]=T*I-O*z,h[x*2+1]=T*z+O*I)}}return g}if(t===void 0){let y=r.size,f=new Float64Array(y),p=1;for(let g=0;g<y;g++){let h=Number(a[g]);isNaN(h)||(p*=h),f[g]=p}return N.fromData(f,[y],"float64")}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=new Float64Array(r.size),u=n[i],c=[],l=1;for(let y=o-1;y>=0;y--)c.unshift(l),l*=n[y];let m=r.size,d=c[i];for(let y=0;y<m;y++){let f=Number(a[y]);Math.floor(y/d)%u===0?s[y]=isNaN(f)?1:f:s[y]=s[y-d]*(isNaN(f)?1:f)}return N.fromData(s,[...n],"float64")}function Wt(r,t,e=!1){U(r.dtype,"nanmedian","Complex numbers are not orderable.");let n=r.shape,o=n.length,a=r.data;if(t===void 0){let d=[];for(let p=0;p<r.size;p++){let g=Number(a[p]);isNaN(g)||d.push(g)}if(d.length===0)return NaN;d.sort((p,g)=>p-g);let y=d.length,f=Math.floor(y/2);return y%2===0?(d[f-1]+d[f])/2:d[f]}let i=t;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let s=Array.from(n).filter((d,y)=>y!==i);if(s.length===0)return Wt(r);let u=s.reduce((d,y)=>d*y,1),c=n[i],l=new Float64Array(u);for(let d=0;d<u;d++){let y=[];for(let g=0;g<c;g++){let h=R(d,i,g,n),b=$(h,n),A=Number(a[b]);isNaN(A)||y.push(A)}if(y.length===0){l[d]=NaN;continue}y.sort((g,h)=>g-h);let f=y.length,p=Math.floor(f/2);f%2===0?l[d]=(y[p-1]+y[p])/2:l[d]=y[p]}let m=N.fromData(l,s,"float64");if(e){let d=[...n];return d[i]=1,N.fromData(l,d,"float64")}return m}function At(r,t,e,n=!1){if(U(r.dtype,"nanquantile","Complex numbers are not orderable."),t<0||t>1)throw new Error("Quantile must be between 0 and 1");let o=r.shape,a=o.length,i=r.data;if(e===void 0){let y=[];for(let A=0;A<r.size;A++){let S=Number(i[A]);isNaN(S)||y.push(S)}if(y.length===0)return NaN;y.sort((A,S)=>A-S);let f=y.length,p=t*(f-1),g=Math.floor(p),h=Math.ceil(p);if(g===h)return y[g];let b=p-g;return y[g]*(1-b)+y[h]*b}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 u=Array.from(o).filter((y,f)=>f!==s);if(u.length===0)return At(r,t);let c=u.reduce((y,f)=>y*f,1),l=o[s],m=new Float64Array(c);for(let y=0;y<c;y++){let f=[];for(let A=0;A<l;A++){let S=R(y,s,A,o),D=$(S,o),w=Number(i[D]);isNaN(w)||f.push(w)}if(f.length===0){m[y]=NaN;continue}f.sort((A,S)=>A-S);let p=f.length,g=t*(p-1),h=Math.floor(g),b=Math.ceil(g);if(h===b)m[y]=f[h];else{let A=g-h;m[y]=f[h]*(1-A)+f[b]*A}}let d=N.fromData(m,u,"float64");if(n){let y=[...o];return y[s]=1,N.fromData(m,y,"float64")}return d}function We(r,t,e,n=!1){return At(r,t/100,e,n)}var da=G(()=>{"use strict";K();Q();Me();xr()});function er(r,t){let e=r.size,n=r.dtype,o=t.indexOf(-1),a;if(o!==-1){let c=t.reduce((m,d,y)=>y===o?m:m*d,1),l=e/c;if(!Number.isInteger(l))throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(t)}`);a=t.map((m,d)=>d===o?l:m)}else a=t;if(a.reduce((c,l)=>c*l,1)!==e)throw new Error(`cannot reshape array of size ${e} into shape ${JSON.stringify(a)}`);if(r.isCContiguous){let c=r.data;return N.fromData(c,a,n,ur(a),0)}let u=r.copy().data;return N.fromData(u,a,n,ur(a),0)}function Lr(r){let t=r.size,e=r.dtype,n=j(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 N.fromData(s,[t],e,[1],0)}let o=new n(t),a=B(e);for(let i=0;i<t;i++){let s=r.iget(i);o[i]=s}return N.fromData(o,[t],e,[1],0)}function et(r){let t=r.size,e=r.dtype;if(r.isCContiguous){let n=r.data;return N.fromData(n,[t],e,[1],0)}return Lr(r)}function ht(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,i=r.dtype,s;if(t===void 0)s=Array.from({length:n},(m,d)=>n-1-d);else{if(t.length!==n)throw new Error(`axes must have length ${n}, got ${t.length}`);let m=new Set;for(let d of t){let y=d<0?n+d:d;if(y<0||y>=n)throw new Error(`axis ${d} is out of bounds for array of dimension ${n}`);if(m.has(y))throw new Error("repeated axis in transpose");m.add(y)}s=t.map(d=>d<0?n+d:d)}let u=s.map(m=>e[m]),c=Array.from(o),l=s.map(m=>c[m]);return N.fromData(a,u,i,l,r.offset)}function Ge(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,i=r.dtype;if(t===void 0){let s=[],u=[];for(let c=0;c<n;c++)e[c]!==1&&(s.push(e[c]),u.push(o[c]));return s.length===0&&(s.push(1),u.push(1)),N.fromData(a,s,i,u,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 u=[],c=[];for(let l=0;l<n;l++)l!==s&&(u.push(e[l]),c.push(o[l]));return N.fromData(a,u,i,c,r.offset)}}function bt(r,t){let e=r.shape,n=e.length,o=r.strides,a=r.data,i=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 u=[...Array.from(e)];u.splice(s,0,1);let c=[...Array.from(o)],l=s<n?o[s]*(e[s]||1):1;return c.splice(s,0,l),N.fromData(a,u,i,c,r.offset)}function ga(r,t,e){let n=r.shape,o=n.length,a=r.strides,i=r.data,s=r.dtype,u=t<0?o+t:t,c=e<0?o+e:e;if(u<0||u>=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(u===c)return N.fromData(i,Array.from(n),s,Array.from(a),r.offset);let l=Array.from(n),m=Array.from(a);return[l[u],l[c]]=[l[c],l[u]],[m[u],m[c]]=[m[c],m[u]],N.fromData(i,l,s,m,r.offset)}function Ze(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 i=o.map(c=>{let l=c<0?n+c:c;if(l<0||l>=n)throw new Error(`source axis ${c} is out of bounds for array of dimension ${n}`);return l}),s=a.map(c=>{let l=c<0?n+c:c;if(l<0||l>=n)throw new Error(`destination axis ${c} is out of bounds for array of dimension ${n}`);return l});if(new Set(i).size!==i.length)throw new Error("repeated axis in source");if(new Set(s).size!==s.length)throw new Error("repeated axis in destination");let u=[];for(let c=0;c<n;c++)i.includes(c)||u.push(c);for(let c=0;c<i.length;c++){let l=s[c];u.splice(l,0,i[c])}return ht(r,u)}function Rr(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 f=r[y];if(f.ndim!==n)throw new Error("all the input arrays must have same number of dimensions");for(let p=0;p<n;p++)if(p!==a&&f.shape[p]!==e.shape[p])throw new Error("all the input array dimensions except for the concatenation axis must match exactly")}let i=Array.from(e.shape),s=e.shape[a];for(let y=1;y<r.length;y++)s+=r[y].shape[a];i[a]=s;let u=i.reduce((y,f)=>y*f,1),c=j(o);if(!c)throw new Error(`Cannot concatenate arrays with dtype ${o}`);let l=new c(u),m=ur(i),d=0;for(let y of r){let f=y.shape[a];wd(y,l,i,m,a,d,o),d+=f}return N.fromData(l,i,o)}function wd(r,t,e,n,o,a,i){let s=r.shape,u=s.length,c=r.size,l=i==="int64"||i==="uint64";if(o===0&&r.isCContiguous&&u>0){let y=a*n[0],f=r.data,p=r.offset,g=p+c;t.set(f.subarray(p,g),y);return}if(o===1&&u===2&&r.isCContiguous){let y=s[0],f=s[1],p=e[1],g=r.data,h=r.offset;for(let b=0;b<y;b++){let A=h+b*f,S=b*p+a;t.set(g.subarray(A,A+f),S)}return}let m=new Array(u).fill(0),d=a*n[o];for(let y=0;y<c;y++){let f=r.iget(y),p=d;for(let g=0;g<u;g++)p+=m[g]*n[g];t[p]=f;for(let g=u-1;g>=0&&(m[g]++,!(m[g]<s[g]));g--)m[g]=0}}function Aa(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 u=r[s];if(u.ndim!==o)throw new Error("all input arrays must have the same shape");for(let c=0;c<o;c++)if(u.shape[c]!==n[c])throw new Error("all input arrays must have the same shape")}let i=r.map(s=>bt(s,a));return Rr(i,a)}function ba(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?er(e,[1,e.shape[0]]):e);return Rr(t,0)}function Ye(r){if(r.length===0)throw new Error("need at least one array to stack");return r.every(e=>e.ndim===1)?Rr(r,0):Rr(r,1)}function ha(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?er(bt(er(e,[1,e.shape[0]]),2),[1,e.shape[0],1]):e.ndim===2?bt(e,2):e);return Rr(t,2)}function Sa(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 i=n[a],s;if(typeof t=="number"){if(i%t!==0)throw new Error("array split does not result in an equal division");let u=i/t;s=[];for(let c=1;c<t;c++)s.push(c*u)}else s=t;return Da(r,s,a)}function St(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 i=n[a],s;if(typeof t=="number"){let u=t,c=Math.floor(i/u),l=i%u;s=[];let m=0;for(let d=0;d<u-1;d++)m+=c+(d<l?1:0),s.push(m)}else s=t;return Da(r,s,a)}function Da(r,t,e){let n=r.shape,o=n[e],a=[0,...t,o],i=[];for(let s=0;s<a.length-1;s++){let u=a[s],c=a[s+1];if(u>c)throw new Error("split indices must be in ascending order");let l=Array.from(n);l[e]=c-u;let m=r.offset+u*r.strides[e];i.push(N.fromData(r.data,l,r.dtype,Array.from(r.strides),m))}return i}function Na(r,t){if(r.ndim<2)throw new Error("vsplit only works on arrays of 2 or more dimensions");return St(r,t,0)}function xa(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 St(r,t,e)}function wa(r,t){let e=r.shape,n=e.length,o=r.dtype,a=Array.isArray(t)?t:[t],i=Math.max(n,a.length),s=new Array(i).fill(1),u=new Array(i).fill(1);for(let b=0;b<n;b++)s[i-n+b]=e[b];for(let b=0;b<a.length;b++)u[i-a.length+b]=a[b];let c=s.map((b,A)=>b*u[A]),l=c.reduce((b,A)=>b*A,1),m=j(o);if(!m)throw new Error(`Cannot tile array with dtype ${o}`);let d=new m(l),y=ur(c),f=r;n<i&&(f=er(r,s));let p=o==="int64"||o==="uint64",g=f.strides,h=new Array(i).fill(0);for(let b=0;b<l;b++){let A=f.offset;for(let w=0;w<i;w++){let x=h[w]%s[w];A+=x*g[w]}let S=f.data[A],D=0;for(let w=0;w<i;w++)D+=h[w]*y[w];d[D]=S;for(let w=i-1;w>=0&&(h[w]++,!(h[w]<c[w]));w--)h[w]=0}return N.fromData(d,c,o)}function Ia(r,t,e){let n=r.shape,o=n.length,a=r.dtype,i=r.size;if(e===void 0){let b=i,A=Array.isArray(t)?t:new Array(b).fill(t);if(A.length!==b)throw new Error(`operands could not be broadcast together with shape (${b},) (${A.length},)`);let S=A.reduce((I,z)=>I+z,0),D=j(a);if(!D)throw new Error(`Cannot repeat array with dtype ${a}`);let w=new D(S),x=0;for(let I=0;I<b;I++){let z=r.iget(I),F=A[I];for(let v=0;v<F;v++)w[x++]=z}return N.fromData(w,[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 u=n[s],c=Array.isArray(t)?t:new Array(u).fill(t);if(c.length!==u)throw new Error(`operands could not be broadcast together with shape (${u},) (${c.length},)`);let l=Array.from(n);l[s]=c.reduce((b,A)=>b+A,0);let m=l.reduce((b,A)=>b*A,1),d=j(a);if(!d)throw new Error(`Cannot repeat array with dtype ${a}`);let y=new d(m),f=ur(l),p=new Array(o).fill(0),g=a==="int64"||a==="uint64",h=[0];for(let b=0;b<u;b++)h.push(h[b]+c[b]);for(let b=0;b<i;b++){let A=r.iget(b),S=p[s],D=c[S],w=0;for(let z=0;z<o;z++)z!==s&&(w+=p[z]*f[z]);let x=f[s],I=h[S];for(let z=0;z<D;z++){let F=w+(I+z)*x;y[F]=A}for(let z=o-1;z>=0&&(p[z]++,!(p[z]<n[z]));z--)p[z]=0}return N.fromData(y,l,a)}function za(r,t){let e=r.shape,n=e.length,o=r.dtype,a=r.size,i;if(t===void 0)i=new Set(Array.from({length:n},(d,y)=>y));else if(typeof t=="number"){let d=t<0?n+t:t;if(d<0||d>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);i=new Set([d])}else i=new Set(t.map(d=>{let y=d<0?n+d:d;if(y<0||y>=n)throw new Error(`axis ${d} is out of bounds for array of dimension ${n}`);return y}));let s=j(o);if(!s)throw new Error(`Cannot flip array with dtype ${o}`);let u=new s(a),c=B(o);if(n===1&&r.isCContiguous){let d=r.data,y=r.offset;for(let f=0;f<a;f++)u[f]=d[y+a-1-f];return N.fromData(u,[...e],o)}if(n===2&&r.isCContiguous){let d=e[0],y=e[1],f=r.data,p=r.offset;if(i.size===2){for(let g=0;g<a;g++)u[g]=f[p+a-1-g];return N.fromData(u,[...e],o)}if(i.size===1){if(i.has(0)){for(let g=0;g<d;g++){let h=p+(d-1-g)*y,b=g*y;for(let A=0;A<y;A++)u[b+A]=f[h+A]}return N.fromData(u,[...e],o)}else if(i.has(1)){for(let g=0;g<d;g++){let h=p+g*y,b=g*y;for(let A=0;A<y;A++)u[b+A]=f[h+y-1-A]}return N.fromData(u,[...e],o)}}}let l=new Array(n),m=new Array(n).fill(0);for(let d=0;d<a;d++){for(let p=0;p<n;p++)l[p]=i.has(p)?e[p]-1-m[p]:m[p];let y=r.offset;for(let p=0;p<n;p++)y+=l[p]*r.strides[p];let f=r.data[y];u[d]=f;for(let p=n-1;p>=0&&(m[p]++,!(m[p]<e[p]));p--)m[p]=0}return N.fromData(u,[...e],o)}function _a(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 i=e[0]<0?o+e[0]:e[0],s=e[1]<0?o+e[1]:e[1];if(i<0||i>=o||s<0||s>=o)throw new Error(`Axes are out of bounds for array of dimension ${o}`);if(i===s)throw new Error("Axes must be different");if(t=(t%4+4)%4,t===0)return r.copy();let u=j(a);if(!u)throw new Error(`Cannot rotate array with dtype ${a}`);let c=[...n];(t===1||t===3)&&([c[i],c[s]]=[c[s],c[i]]);let l=c.reduce((g,h)=>g*h,1),m=new u(l),d=ur(c),y=B(a),f=new Array(o).fill(0),p=new Array(o);for(let g=0;g<r.size;g++){for(let D=0;D<o;D++)p[D]=f[D];let h,b;t===1?(h=n[s]-1-f[s],b=f[i]):t===2?(h=n[i]-1-f[i],b=n[s]-1-f[s],p[i]=h,p[s]=b):(h=f[s],b=n[i]-1-f[i]),t!==2&&(p[i]=h,p[s]=b);let A=0;for(let D=0;D<o;D++)A+=p[D]*d[D];let S=r.iget(g);m[A]=S;for(let D=o-1;D>=0&&(f[D]++,!(f[D]<n[D]));D--)f[D]=0}return N.fromData(m,c,a)}function va(r,t,e){let n=r.shape,o=n.length,a=r.dtype,i=r.size;if(e===void 0){let f=Array.isArray(t)?t.reduce((A,S)=>A+S,0):t,p=Lr(r),g=j(a);if(!g)throw new Error(`Cannot roll array with dtype ${a}`);let h=new g(i),b=B(a);for(let A=0;A<i;A++){let S=((A-f)%i+i)%i,D=p.iget(S);h[A]=D}return N.fromData(h,[...n],a)}let s=Array.isArray(t)?t:[t],u=Array.isArray(e)?e:[e];if(s.length!==u.length)throw new Error("shift and axis must have the same length");let c=u.map(f=>{let p=f<0?o+f:f;if(p<0||p>=o)throw new Error(`axis ${f} is out of bounds for array of dimension ${o}`);return p}),l=j(a);if(!l)throw new Error(`Cannot roll array with dtype ${a}`);let m=new l(i),d=B(a),y=new Array(o).fill(0);for(let f=0;f<i;f++){let p=[...y];for(let b=0;b<c.length;b++){let A=c[b],S=n[A],D=s[b];p[A]=((p[A]-D)%S+S)%S}let g=r.offset;for(let b=0;b<o;b++)g+=p[b]*r.strides[b];let h=r.data[g];m[f]=h;for(let b=o-1;b>=0&&(y[b]++,!(y[b]<n[b]));b--)y[b]=0}return N.fromData(m,[...n],a)}function Fa(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?N.fromData(r.data,Array.from(r.shape),r.dtype,Array.from(r.strides),r.offset):Ze(r,o,a)}function Ma(r,t){if(r.ndim<3)throw new Error("dsplit only works on arrays of 3 or more dimensions");return St(r,t,2)}function Ba(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(e=>e.ndim===1?er(e,[e.shape[0],1]):e);return Ye(t)}function Ea(r,t){let e=r.dtype,n=t.reduce((u,c)=>u*c,1),o=r.size,a=j(e);if(!a)throw new Error(`Cannot resize array with dtype ${e}`);let i=new a(n),s=B(e);for(let u=0;u<n;u++){let c=u%o,l=r.iget(c);i[u]=l}return N.fromData(i,t,e)}function Ta(r){return r.map(t=>t.ndim===0?er(t,[1]):t)}function Oa(r){return r.map(t=>t.ndim===0?er(t,[1,1]):t.ndim===1?er(t,[1,t.shape[0]]):t)}function Ca(r){return r.map(t=>t.ndim===0?er(t,[1,1,1]):t.ndim===1?er(t,[1,t.shape[0],1]):t.ndim===2?er(t,[t.shape[0],t.shape[1],1]):t)}function Ua(r,t=0){let e=r.shape,n=e.length,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[o],i=[];for(let s=0;s<a;s++){let u=[];for(let m=0;m<n;m++)m===o?u.push({start:s,stop:s+1,step:1}):u.push({start:0,stop:e[m],step:1});let c=Id(r,u),l=Ge(c,o);i.push(l)}return i}function $a(r,t=1){if(r.length===0)throw new Error("need at least one array to block");return r.length===1?r[0].copy():Rr(r,-1)}function Id(r,t){let e=r.shape,n=r.strides,o=r.offset,a=r.dtype,i=r.data,s=[],u=[];for(let c=0;c<e.length;c++){let l=t[c],{start:m,stop:d,step:y}=l,f=Math.ceil((d-m)/y);s.push(f),u.push(n[c]*y),o+=m*n[c]}return N.fromData(i,s,a,u,o)}var He=G(()=>{"use strict";K();Q()});function wr(r,t){if(r instanceof E||t instanceof E){let e=r instanceof E?r:new E(Number(r),0),n=t instanceof E?t:new E(Number(t),0);return e.mul(n)}return typeof r=="bigint"&&typeof t=="bigint"?Number(r*t):Number(r)*Number(t)}function zd(r,t,e,n,o,a,i,s,u,c,l,m,d,y){if(m===0)for(let h=0;h<n*o;h++)d[h]=0;else if(m!==1)for(let h=0;h<n*o;h++)d[h]=(d[h]??0)*m;let f=r==="row-major",p=t==="transpose",g=e==="transpose";if(f&&!p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*u+S]??0)*(c[S*l+b]??0);d[h*y+b]=(d[h*y+b]??0)+i*A}else if(f&&p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*u+h]??0)*(c[S*l+b]??0);d[h*y+b]=(d[h*y+b]??0)+i*A}else if(f&&!p&&g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*u+S]??0)*(c[b*l+S]??0);d[h*y+b]=(d[h*y+b]??0)+i*A}else if(f&&p&&g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*u+h]??0)*(c[b*l+S]??0);d[h*y+b]=(d[h*y+b]??0)+i*A}else if(!f&&!p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*u+h]??0)*(c[b*l+S]??0);d[b*y+h]=(d[b*y+h]??0)+i*A}else if(!f&&p&&!g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*u+S]??0)*(c[b*l+S]??0);d[b*y+h]=(d[b*y+h]??0)+i*A}else if(!f&&!p&&g)for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[S*u+h]??0)*(c[S*l+b]??0);d[b*y+h]=(d[b*y+h]??0)+i*A}else for(let h=0;h<n;h++)for(let b=0;b<o;b++){let A=0;for(let S=0;S<a;S++)A+=(s[h*u+S]??0)*(c[S*l+b]??0);d[b*y+h]=(d[b*y+h]??0)+i*A}}function ot(r,t){let e=r.ndim,n=t.ndim,o=M(r.dtype)||M(t.dtype);if(e===0||n===0){let a=e===0?r.get():null,i=n===0?t.get():null;if(e===0&&n===0)return wr(a,i);if(e===0){let s=Z(r.dtype,t.dtype),u=N.zeros([...t.shape],s),c=(l,m)=>{let d=new Array(m.length),y=l;for(let f=m.length-1;f>=0;f--)d[f]=y%m[f],y=Math.floor(y/m[f]);return d};for(let l=0;l<t.size;l++){let m=c(l,t.shape),d=t.get(...m);u.set(m,wr(a,d))}return u}else{let s=Z(r.dtype,t.dtype),u=N.zeros([...r.shape],s),c=(l,m)=>{let d=new Array(m.length),y=l;for(let f=m.length-1;f>=0;f--)d[f]=y%m[f],y=Math.floor(y/m[f]);return d};for(let l=0;l<r.size;l++){let m=c(l,r.shape),d=r.get(...m);u.set(m,wr(d,i))}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 a=r.shape[0];if(o){let s=0,u=0;for(let c=0;c<a;c++){let l=r.get(c),m=t.get(c),d=wr(l,m);d instanceof E?(s+=d.re,u+=d.im):s+=d}return new E(s,u)}let i=0;for(let s=0;s<a;s++){let u=r.get(s),c=t.get(s);typeof u=="bigint"&&typeof c=="bigint"?i=Number(i)+Number(u*c):i+=Number(u)*Number(c)}return i}if(e===2&&n===2)return mr(r,t);if(e===2&&n===1){let[a,i]=r.shape,s=t.shape[0];if(i!==s)throw new Error(`dot: incompatible shapes (${a},${i}) and (${s},)`);let u=Z(r.dtype,t.dtype),c=N.zeros([a],u);if(o)for(let l=0;l<a;l++){let m=0,d=0;for(let y=0;y<i;y++){let f=r.get(l,y),p=t.get(y),g=f instanceof E?f:new E(Number(f),0),h=p instanceof E?p:new E(Number(p),0);m+=g.re*h.re-g.im*h.im,d+=g.re*h.im+g.im*h.re}c.set([l],new E(m,d))}else for(let l=0;l<a;l++){let m=0;for(let d=0;d<i;d++){let y=r.get(l,d),f=t.get(d);typeof y=="bigint"&&typeof f=="bigint"?m=Number(m)+Number(y*f):m+=Number(y)*Number(f)}c.set([l],m)}return c}if(e===1&&n===2){let a=r.shape[0],[i,s]=t.shape;if(a!==i)throw new Error(`dot: incompatible shapes (${a},) and (${i},${s})`);let u=Z(r.dtype,t.dtype),c=N.zeros([s],u);if(o)for(let l=0;l<s;l++){let m=0,d=0;for(let y=0;y<a;y++){let f=r.get(y),p=t.get(y,l),g=f instanceof E?f:new E(Number(f),0),h=p instanceof E?p:new E(Number(p),0);m+=g.re*h.re-g.im*h.im,d+=g.re*h.im+g.im*h.re}c.set([l],new E(m,d))}else for(let l=0;l<s;l++){let m=0;for(let d=0;d<a;d++){let y=r.get(d),f=t.get(d,l);typeof y=="bigint"&&typeof f=="bigint"?m=Number(m)+Number(y*f):m+=Number(y)*Number(f)}c.set([l],m)}return c}if(e>2&&n===1){let a=r.shape[e-1],i=t.shape[0];if(a!==i)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and (${i},)`);let s=[...r.shape.slice(0,-1)],u=Z(r.dtype,t.dtype),c=N.zeros(s,u),l=s.reduce((m,d)=>m*d,1);if(o)for(let m=0;m<l;m++){let d=0,y=0,f=m,p=[];for(let g=s.length-1;g>=0;g--)p[g]=f%s[g],f=Math.floor(f/s[g]);for(let g=0;g<a;g++){let h=[...p,g],b=r.get(...h),A=t.get(g),S=b instanceof E?b:new E(Number(b),0),D=A instanceof E?A:new E(Number(A),0);d+=S.re*D.re-S.im*D.im,y+=S.re*D.im+S.im*D.re}c.set(p,new E(d,y))}else for(let m=0;m<l;m++){let d=0,y=m,f=[];for(let p=s.length-1;p>=0;p--)f[p]=y%s[p],y=Math.floor(y/s[p]);for(let p=0;p<a;p++){let g=[...f,p],h=r.get(...g),b=t.get(p);typeof h=="bigint"&&typeof b=="bigint"?d=Number(d)+Number(h*b):d+=Number(h)*Number(b)}c.set(f,d)}return c}if(e===1&&n>2){let a=r.shape[0],i=1,s=t.shape[i];if(a!==s)throw new Error(`dot: incompatible shapes (${a},) and ${JSON.stringify(t.shape)}`);let u=[...t.shape.slice(0,i),...t.shape.slice(i+1)],c=Z(r.dtype,t.dtype),l=N.zeros(u,c),m=u.reduce((d,y)=>d*y,1);if(o)for(let d=0;d<m;d++){let y=d,f=[];for(let A=u.length-1;A>=0;A--)f[A]=y%u[A],y=Math.floor(y/u[A]);let p=f.slice(0,i),g=f.slice(i),h=0,b=0;for(let A=0;A<a;A++){let S=r.get(A),D=[...p,A,...g],w=t.get(...D),x=S instanceof E?S:new E(Number(S),0),I=w instanceof E?w:new E(Number(w),0);h+=x.re*I.re-x.im*I.im,b+=x.re*I.im+x.im*I.re}l.set(f,new E(h,b))}else for(let d=0;d<m;d++){let y=d,f=[];for(let b=u.length-1;b>=0;b--)f[b]=y%u[b],y=Math.floor(y/u[b]);let p=f.slice(0,i),g=f.slice(i),h=0;for(let b=0;b<a;b++){let A=r.get(b),S=[...p,b,...g],D=t.get(...S);typeof A=="bigint"&&typeof D=="bigint"?h=Number(h)+Number(A*D):h+=Number(A)*Number(D)}l.set(f,h)}return l}if(e>=2&&n>=2&&!(e===2&&n===2)){let a=r.shape[e-1],i=t.shape[n-2];if(a!==i)throw new Error(`dot: incompatible shapes ${JSON.stringify(r.shape)} and ${JSON.stringify(t.shape)}`);let s=[...r.shape.slice(0,-1),...t.shape.slice(0,-2),t.shape[n-1]],u=Z(r.dtype,t.dtype),c=N.zeros(s,u),l=r.shape.slice(0,-1).reduce((f,p)=>f*p,1),m=t.shape.slice(0,-2).reduce((f,p)=>f*p,1),d=t.shape[n-1],y=a;if(o)for(let f=0;f<l;f++)for(let p=0;p<m;p++)for(let g=0;g<d;g++){let h=0,b=0;for(let D=0;D<y;D++){let w=[],x=f;for(let C=r.shape.length-2;C>=0;C--)w.unshift(x%r.shape[C]),x=Math.floor(x/r.shape[C]);w.push(D);let I=r.get(...w),z=[],F=p;for(let C=t.shape.length-3;C>=0;C--)z.unshift(F%t.shape[C]),F=Math.floor(F/t.shape[C]);z.push(D,g);let v=t.get(...z),T=I instanceof E?I:new E(Number(I),0),O=v instanceof E?v:new E(Number(v),0);h+=T.re*O.re-T.im*O.im,b+=T.re*O.im+T.im*O.re}let A=f*m*d+p*d+g,S=c.data;S[A*2]=h,S[A*2+1]=b}else for(let f=0;f<l;f++)for(let p=0;p<m;p++)for(let g=0;g<d;g++){let h=0;for(let A=0;A<y;A++){let S=f*y+A,D=p*y*d+A*d+g,w=r.data[S+r.offset],x=t.data[D+t.offset];typeof w=="bigint"&&typeof x=="bigint"?h=Number(h)+Number(w*x):h+=Number(w)*Number(x)}let b=f*m*d+p*d+g;c.data[b]=h}return c}throw new Error(`dot: unexpected combination of dimensions ${e}D \xB7 ${n}D`)}function mr(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 i=Z(r.dtype,t.dtype);if(M(i)){let D=N.zeros([e,a],i),w=D.data,x=r.data,I=t.data;for(let z=0;z<e;z++)for(let F=0;F<a;F++){let v=0,T=0;for(let C=0;C<n;C++){let q=(z*n+C)*2,V=(C*a+F)*2,k=x[q],W=x[q+1],P=I[V],rr=I[V+1];v+=k*P-W*rr,T+=k*rr+W*P}let O=z*a+F;w[O*2]=v,w[O*2+1]=T}return D}let s=i.startsWith("int")||i.startsWith("uint")||i==="bool"?"float64":i;if(s!=="float64")throw new Error(`matmul currently only supports float64, got ${s}`);let u=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&&(u=u.subarray(r.offset)),t.offset>0&&(c=c.subarray(t.offset));let[l=0,m=0]=r.strides,[d=0,y=0]=t.strides,f=m>l,p=y>d,g=f?"transpose":"no-transpose",h=p?"transpose":"no-transpose",b,A;f?b=m:b=l,p?A=y:A=d;let S=N.zeros([e,a],"float64");return zd("row-major",g,h,e,a,n,1,u,b,c,A,0,S.data,a),S}function Je(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);if(M(r.dtype)){let a=0,i=0;for(let s=0;s<n;s++){let u=r.get(s,s);a+=u.re,i+=u.im}return new E(a,i)}let o=0;for(let a=0;a<n;a++){let i=r.get(a,a);typeof i=="bigint"?o=(typeof o=="bigint"?o:BigInt(o))+i:o=(typeof o=="bigint"?Number(o):o)+i}return o}function Dt(r,t){return ht(r,t)}function qa(r,t){let e=r.ndim,n=t.ndim,o=M(r.dtype)||M(t.dtype),a=r.shape[e-1],i=t.shape[n-1];if(a!==i)throw new Error(`inner: incompatible shapes - last dimensions ${a} and ${i} don't match`);if(e===1&&n===1)return ot(r,t);let s=[...r.shape.slice(0,-1),...t.shape.slice(0,-1)],u=Z(r.dtype,t.dtype),c=N.zeros(s,u),l=e===1?1:r.shape.slice(0,-1).reduce((y,f)=>y*f,1),m=n===1?1:t.shape.slice(0,-1).reduce((y,f)=>y*f,1),d=a;if(o)for(let y=0;y<l;y++)for(let f=0;f<m;f++){let p=0,g=0;for(let A=0;A<d;A++){let S,D;if(e===1)S=r.get(A);else{let I=[],z=y,F=r.shape.slice(0,-1);for(let v=F.length-1;v>=0;v--)I.unshift(z%F[v]),z=Math.floor(z/F[v]);I.push(A),S=r.get(...I)}if(n===1)D=t.get(A);else{let I=[],z=f,F=t.shape.slice(0,-1);for(let v=F.length-1;v>=0;v--)I.unshift(z%F[v]),z=Math.floor(z/F[v]);I.push(A),D=t.get(...I)}let w=S instanceof E?S:new E(Number(S),0),x=D instanceof E?D:new E(Number(D),0);p+=w.re*x.re-w.im*x.im,g+=w.re*x.im+w.im*x.re}if(s.length===0)return new E(p,g);let h=l===1?f:y*m+f,b=c.data;b[h*2]=p,b[h*2+1]=g}else for(let y=0;y<l;y++)for(let f=0;f<m;f++){let p=0;for(let h=0;h<d;h++){let b=e===1?h:y*d+h,A=n===1?h:f*d+h,S=r.data[b+r.offset],D=t.data[A+t.offset];typeof S=="bigint"&&typeof D=="bigint"?p=Number(p)+Number(S*D):p+=Number(S)*Number(D)}if(s.length===0)return p;let g=l===1?f:y*m+f;c.data[g]=p}return c}function Gt(r,t){let e=r.ndim===1?r:et(r),n=t.ndim===1?t:et(t),o=e.size,a=n.size,i=Z(r.dtype,t.dtype),s=N.zeros([o,a],i);for(let u=0;u<o;u++)for(let c=0;c<a;c++){let l=e.get(u),m=n.get(c),d=wr(l,m);s.set([u,c],d)}return s}function Qe(r,t,e){let n,o;if(typeof e=="number"){let f=e;if(f<0)throw new Error("tensordot: axes must be non-negative");if(f>r.ndim||f>t.ndim)throw new Error("tensordot: axes exceeds array dimensions");n=Array.from({length:f},(p,g)=>r.ndim-f+g),o=Array.from({length:f},(p,g)=>g)}else if([n,o]=e,n.length!==o.length)throw new Error("tensordot: axes lists must have same length");for(let f=0;f<n.length;f++){let p=n[f],g=o[f];if(p<0||p>=r.ndim||g<0||g>=t.ndim)throw new Error("tensordot: axis out of bounds");if(r.shape[p]!==t.shape[g])throw new Error(`tensordot: shape mismatch on axes ${p} and ${g}: ${r.shape[p]} != ${t.shape[g]}`)}let a=[],i=[];for(let f=0;f<r.ndim;f++)n.includes(f)||a.push(f);for(let f=0;f<t.ndim;f++)o.includes(f)||i.push(f);let s=[...a.map(f=>r.shape[f]),...i.map(f=>t.shape[f])],u=Z(r.dtype,t.dtype),c=M(u),l=f=>f instanceof E?{re:f.re,im:f.im}:{re:Number(f),im:0};if(s.length===0){let f=0,p=0,g=n.map(h=>r.shape[h]).reduce((h,b)=>h*b,1);for(let h=0;h<g;h++){let b=h,A=new Array(n.length);for(let I=n.length-1;I>=0;I--){let z=n[I];A[I]=b%r.shape[z],b=Math.floor(b/r.shape[z])}let S=new Array(r.ndim),D=new Array(t.ndim);for(let I=0;I<n.length;I++)S[n[I]]=A[I];for(let I=0;I<o.length;I++)D[o[I]]=A[I];let w=r.get(...S),x=t.get(...D);if(c){let I=l(w),z=l(x);f+=I.re*z.re-I.im*z.im,p+=I.re*z.im+I.im*z.re}else typeof w=="bigint"&&typeof x=="bigint"?f+=Number(w*x):f+=Number(w)*Number(x)}return c?new E(f,p):f}let m=N.zeros(s,u),d=s.reduce((f,p)=>f*p,1),y=n.map(f=>r.shape[f]).reduce((f,p)=>f*p,1);for(let f=0;f<d;f++){let p=f,g=[];for(let D=s.length-1;D>=0;D--)g[D]=p%s[D],p=Math.floor(p/s[D]);let h=g.slice(0,a.length),b=g.slice(a.length),A=0,S=0;for(let D=0;D<y;D++){p=D;let w=[];for(let v=n.length-1;v>=0;v--){let T=n[v];w[v]=p%r.shape[T],p=Math.floor(p/r.shape[T])}let x=new Array(r.ndim),I=new Array(t.ndim);for(let v=0;v<a.length;v++)x[a[v]]=h[v];for(let v=0;v<i.length;v++)I[i[v]]=b[v];for(let v=0;v<n.length;v++)x[n[v]]=w[v],I[o[v]]=w[v];let z=r.get(...x),F=t.get(...I);if(c){let v=l(z),T=l(F);A+=v.re*T.re-v.im*T.im,S+=v.re*T.im+v.im*T.re}else typeof z=="bigint"&&typeof F=="bigint"?A+=Number(z*F):A+=Number(z)*Number(F)}c?m.set(g,new E(A,S)):m.set(g,A)}return m}function Ke(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 i=e<0?a+e:e,s=n<0?a+n:n;if(i<0||i>=a||s<0||s>=a)throw new Error("axis out of bounds");if(i===s)throw new Error("axis1 and axis2 cannot be the same");let u=o[i],c=o[s],l;t>=0?l=Math.max(0,Math.min(u,c-t)):l=Math.max(0,Math.min(u+t,c));let m=[];for(let p=0;p<a;p++)p!==i&&p!==s&&m.push(o[p]);m.push(l);let d=N.zeros(m,r.dtype),y=o.filter((p,g)=>g!==i&&g!==s),f=y.reduce((p,g)=>p*g,1);for(let p=0;p<f;p++){let g=p,h=[];for(let b=y.length-1;b>=0;b--)h.unshift(g%y[b]),g=Math.floor(g/y[b]);for(let b=0;b<l;b++){let A=new Array(a),S=0;for(let x=0;x<a;x++)x===i?A[x]=t>=0?b:b-t:x===s?A[x]=t>=0?b+t:b:A[x]=h[S++];let D=[...h,b],w=r.get(...A);d.set(D,w)}}return d}function Va(r,...t){let e=r.indexOf("->"),n,o;e===-1?(n=r,o=_d(n)):(n=r.slice(0,e),o=r.slice(e+2));let a=n.split(",").map(p=>p.trim());if(a.length!==t.length)throw new Error(`einsum: expected ${a.length} operands, got ${t.length}`);let i=new Map;for(let p=0;p<t.length;p++){let g=a[p],h=t[p];if(g.length!==h.ndim)throw new Error(`einsum: operand ${p} has ${h.ndim} dimensions but subscript '${g}' has ${g.length} indices`);for(let b=0;b<g.length;b++){let A=g[b],S=h.shape[b];if(i.has(A)){if(i.get(A)!==S)throw new Error(`einsum: size mismatch for index '${A}': ${i.get(A)} vs ${S}`)}else i.set(A,S)}}for(let p of o)if(!i.has(p))throw new Error(`einsum: output subscript contains unknown index '${p}'`);let s=new Set(o),u=new Set;for(let p of a)for(let g of p)u.add(g);let c=[];for(let p of u)s.has(p)||c.push(p);if(t.length===2&&a.length===2){let[p,g]=a,[h,b]=t;if(p.length===2&&g.length===2&&o.length===2&&h.ndim===2&&b.ndim===2){let[A,S]=[p[0],p[1]],[D,w]=[g[0],g[1]],[x,I]=[o[0],o[1]];if(A===x&&w===I&&S===D&&c.length===1&&c[0]===S||A===x&&w===I&&S===D&&c.length===1&&c[0]===S)return mr(h,b);if(S===x&&w===I&&A===D&&c.length===1&&c[0]===A){let z=Dt(h);return mr(z,b)}if(A===x&&D===I&&S===w&&c.length===1&&c[0]===S){let z=Dt(b);return mr(h,z)}}if(p.length===1&&g.length===1&&p===g&&o.length===0&&h.ndim===1&&b.ndim===1)return Xe(t,a,c,i);if(p&&g&&p.length===1&&g.length===1&&o.length===2&&o===p+g&&c.length===0&&h.ndim===1&&b.ndim===1)return Gt(h,b)}if(t.length===1&&a[0].length===2&&o.length===0){let p=a[0];if(p[0]===p[1]&&t[0].ndim===2)return Xe(t,a,c,i)}let l=Array.from(o).map(p=>i.get(p));if(l.length===0)return Xe(t,a,c,i);let m=t[0].dtype;for(let p=1;p<t.length;p++)m=Z(m,t[p].dtype);let d=N.zeros(l,m),y=l.reduce((p,g)=>p*g,1),f=1;for(let p of c)f*=i.get(p);for(let p=0;p<y;p++){let g=vd(p,l),h=new Map;for(let A=0;A<o.length;A++)h.set(o[A],g[A]);let b=0;for(let A=0;A<f;A++){let S=A;for(let w=c.length-1;w>=0;w--){let x=c[w],I=i.get(x);h.set(x,S%I),S=Math.floor(S/I)}let D=1;for(let w=0;w<t.length;w++){let x=t[w],I=a[w],z=[];for(let v of I)z.push(h.get(v));let F=x.get(...z);D*=Number(F)}b+=D}d.set(g,b)}return d}function _d(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 Xe(r,t,e,n){let o=!1;for(let c of r)if(M(c.dtype)){o=!0;break}let a=c=>c instanceof E?{re:c.re,im:c.im}:{re:Number(c),im:0},i=1;for(let c of e)i*=n.get(c);let s=0,u=0;for(let c=0;c<i;c++){let l=new Map,m=c;for(let f=e.length-1;f>=0;f--){let p=e[f],g=n.get(p);l.set(p,m%g),m=Math.floor(m/g)}let d=1,y=0;for(let f=0;f<r.length;f++){let p=r[f],g=t[f],h=[];for(let A of g)h.push(l.get(A));let b=p.get(...h);if(o){let A=a(b),S=d*A.re-y*A.im,D=d*A.im+y*A.re;d=S,y=D}else d*=Number(b)}s+=d,u+=y}return o?new E(s,u):s}function vd(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 Pa(r,t){let e=r.shape,n=t.shape,o=e.length,a=n.length,i=Z(r.dtype,t.dtype),s=Math.max(o,a),u=new Array(s),c=new Array(s).fill(1),l=new Array(s).fill(1);for(let f=0;f<o;f++)c[s-o+f]=e[f];for(let f=0;f<a;f++)l[s-a+f]=n[f];for(let f=0;f<s;f++)u[f]=c[f]*l[f];let m=N.zeros(u,i),d=e.reduce((f,p)=>f*p,1),y=n.reduce((f,p)=>f*p,1);for(let f=0;f<d;f++){let p=f,g=new Array(o);for(let A=o-1;A>=0;A--)g[A]=p%e[A],p=Math.floor(p/e[A]);let h=new Array(s).fill(0);for(let A=0;A<o;A++)h[s-o+A]=g[A];let b=r.get(...g);for(let A=0;A<y;A++){let S=A,D=new Array(a);for(let F=a-1;F>=0;F--)D[F]=S%n[F],S=Math.floor(S/n[F]);let w=new Array(s).fill(0);for(let F=0;F<a;F++)w[s-a+F]=D[F];let x=t.get(...D),I=new Array(s);for(let F=0;F<s;F++)I[F]=h[F]*l[F]+w[F];let z=wr(b,x);m.set(I,z)}}return m}function ja(r,t,e=-1,n=-1,o=-1,a){a!==void 0&&(e=a,n=a,o=a);let i=(A,S)=>A<0?S+A:A,s=i(e,r.ndim),u=i(n,t.ndim);if(r.ndim===1&&t.ndim===1){let A=r.shape[0],S=t.shape[0];if(A===3&&S===3){let D=Number(r.get(0)),w=Number(r.get(1)),x=Number(r.get(2)),I=Number(t.get(0)),z=Number(t.get(1)),F=Number(t.get(2)),v=N.zeros([3],"float64");return v.set([0],w*F-x*z),v.set([1],x*I-D*F),v.set([2],D*z-w*I),v}else if(A===2&&S===2){let D=Number(r.get(0)),w=Number(r.get(1)),x=Number(t.get(0)),I=Number(t.get(1));return D*I-w*x}else if(A===2&&S===3||A===3&&S===2){let D=Number(r.get(0)),w=Number(r.get(1)),x=A===3?Number(r.get(2)):0,I=Number(t.get(0)),z=Number(t.get(1)),F=S===3?Number(t.get(2)):0,v=N.zeros([3],"float64");return v.set([0],w*F-x*z),v.set([1],x*I-D*F),v.set([2],D*z-w*I),v}else throw new Error(`cross: incompatible dimensions for cross product: ${A} and ${S}`)}let c=r.shape[s],l=t.shape[u];if(c!==2&&c!==3||l!==2&&l!==3)throw new Error(`cross: incompatible dimensions for cross product: ${c} and ${l}`);let m=c===2&&l===2?0:3,d=[...r.shape.slice(0,s),...r.shape.slice(s+1)],y=[...t.shape.slice(0,u),...t.shape.slice(u+1)];if(d.length!==y.length)throw new Error("cross: incompatible shapes for cross product");for(let A=0;A<d.length;A++)if(d[A]!==y[A])throw new Error("cross: incompatible shapes for cross product");let f=d,p=o<0?f.length+1+o:o,g;if(m===0?g=f:g=[...f.slice(0,p),m,...f.slice(p)],g.length===0)throw new Error("cross: unexpected scalar result from higher-dimensional input");let h=N.zeros(g,"float64"),b=f.reduce((A,S)=>A*S,1);for(let A=0;A<b;A++){let S=A,D=[];for(let V=f.length-1;V>=0;V--)D[V]=S%f[V],S=Math.floor(S/f[V]);let w=[...D.slice(0,s),0,...D.slice(s)],x=[...D.slice(0,u),0,...D.slice(u)],I=V=>(w[s]=V,Number(r.get(...w))),z=V=>(x[u]=V,Number(t.get(...x))),F=I(0),v=I(1),T=c===3?I(2):0,O=z(0),C=z(1),q=l===3?z(2):0;if(m===0)h.set(D,F*C-v*O);else{let V=v*q-T*C,k=T*O-F*q,W=F*C-v*O,P=(rr,nr)=>{let Y=[...D.slice(0,p),rr,...D.slice(p)];h.set(Y,nr)};P(0,V),P(1,k),P(2,W)}}return h}function nt(r,t=2,e,n=!1){if(typeof t!="number")throw new Error("vector_norm: ord must be a number");if(e==null){let c=r.ndim===1?r:et(r),l=c.size,m;if(t===1/0){m=0;for(let d=0;d<l;d++)m=Math.max(m,Math.abs(Number(c.get(d))))}else if(t===-1/0){m=1/0;for(let d=0;d<l;d++)m=Math.min(m,Math.abs(Number(c.get(d))))}else if(t===0){m=0;for(let d=0;d<l;d++)Number(c.get(d))!==0&&m++}else if(t===1){m=0;for(let d=0;d<l;d++)m+=Math.abs(Number(c.get(d)))}else if(t===2){m=0;for(let d=0;d<l;d++){let y=Number(c.get(d));m+=y*y}m=Math.sqrt(m)}else{m=0;for(let d=0;d<l;d++)m+=Math.pow(Math.abs(Number(c.get(d))),t);m=Math.pow(m,1/t)}if(n){let d=new Array(r.ndim).fill(1),y=N.zeros(d,"float64");return y.set(new Array(r.ndim).fill(0),m),y}return m}let o=e<0?r.ndim+e:e;if(o<0||o>=r.ndim)throw new Error(`vector_norm: axis ${e} out of bounds for array with ${r.ndim} dimensions`);let a=n?[...r.shape.slice(0,o),1,...r.shape.slice(o+1)]:[...r.shape.slice(0,o),...r.shape.slice(o+1)];if(a.length===0)return nt(r,t,null,!1);let i=N.zeros(a,"float64"),s=r.shape[o],u=a.reduce((c,l)=>c*l,1);for(let c=0;c<u;c++){let l=c,m=[];for(let f=a.length-1;f>=0;f--)m[f]=l%a[f],l=Math.floor(l/a[f]);let d=n?[...m.slice(0,o),0,...m.slice(o+1)]:[...m.slice(0,o),0,...m.slice(o)],y;if(t===1/0){y=0;for(let f=0;f<s;f++)d[o]=f,y=Math.max(y,Math.abs(Number(r.get(...d))))}else if(t===-1/0){y=1/0;for(let f=0;f<s;f++)d[o]=f,y=Math.min(y,Math.abs(Number(r.get(...d))))}else if(t===0){y=0;for(let f=0;f<s;f++)d[o]=f,Number(r.get(...d))!==0&&y++}else if(t===1){y=0;for(let f=0;f<s;f++)d[o]=f,y+=Math.abs(Number(r.get(...d)))}else if(t===2){y=0;for(let f=0;f<s;f++){d[o]=f;let p=Number(r.get(...d));y+=p*p}y=Math.sqrt(y)}else{y=0;for(let f=0;f<s;f++)d[o]=f,y+=Math.pow(Math.abs(Number(r.get(...d))),t);y=Math.pow(y,1/t)}i.set(m,y)}return i}function Wr(r,t="fro",e=!1){if(r.ndim!==2)throw new Error(`matrix_norm: input must be 2D, got ${r.ndim}D`);let[n,o]=r.shape,a;if(t==="fro"){a=0;for(let i=0;i<n;i++)for(let s=0;s<o;s++){let u=Number(r.get(i,s));a+=u*u}a=Math.sqrt(a)}else if(t==="nuc"){let{s:i}=kr(r);a=0;for(let s=0;s<i.size;s++)a+=Number(i.get(s))}else if(t===1){a=0;for(let i=0;i<o;i++){let s=0;for(let u=0;u<n;u++)s+=Math.abs(Number(r.get(u,i)));a=Math.max(a,s)}}else if(t===-1){a=1/0;for(let i=0;i<o;i++){let s=0;for(let u=0;u<n;u++)s+=Math.abs(Number(r.get(u,i)));a=Math.min(a,s)}}else if(t===1/0){a=0;for(let i=0;i<n;i++){let s=0;for(let u=0;u<o;u++)s+=Math.abs(Number(r.get(i,u)));a=Math.max(a,s)}}else if(t===-1/0){a=1/0;for(let i=0;i<n;i++){let s=0;for(let u=0;u<o;u++)s+=Math.abs(Number(r.get(i,u)));a=Math.min(a,s)}}else if(t===2){let{s:i}=kr(r);a=Number(i.get(0))}else if(t===-2){let{s:i}=kr(r);a=Number(i.get(i.size-1))}else throw new Error(`matrix_norm: invalid ord value: ${t}`);if(e){let i=N.zeros([1,1],"float64");return i.set([0,0],a),i}return a}function La(r,t=null,e=null,n=!1){if(t===null)return e===null?nt(r,2,null,n):typeof e=="number"?nt(r,2,e,n):Wr(r,"fro",n);if(Array.isArray(e)){if(e.length!==2)throw new Error("norm: axis must be a 2-tuple for matrix norms");let o=e[0]<0?r.ndim+e[0]:e[0],a=e[1]<0?r.ndim+e[1]:e[1];if(r.ndim!==2||o!==0&&o!==1||a!==0&&a!==1||o===a)throw new Error("norm: complex axis specification not yet supported");return Wr(r,t,n)}if(r.ndim===2&&e===null&&(t==="fro"||t==="nuc"))return Wr(r,t,n);if(typeof t!="number"&&t!==null)throw new Error(`norm: ord '${t}' not valid for vector norm`);return nt(r,t??2,e,n)}function rn(r,t="reduced"){if(r.ndim!==2)throw new Error(`qr: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape,o=Math.min(e,n),a=N.zeros([e,n],"float64");for(let y=0;y<e;y++)for(let f=0;f<n;f++)a.set([y,f],Number(r.get(y,f)));let i=[],s=[];for(let y=0;y<o;y++){let f=e-y,p=[];for(let D=y;D<e;D++)p.push(Number(a.get(D,y)));let g=0;for(let D=0;D<f;D++)g+=p[D]*p[D];if(g=Math.sqrt(g),g<1e-15){i.push(p),s.push(0);continue}let h=p[0]>=0?1:-1,b=p[0]+h*g,A=[1];for(let D=1;D<f;D++)A.push(p[D]/b);let S=h*b/g;s.push(S),i.push(A);for(let D=y;D<n;D++){let w=0;for(let x=0;x<f;x++)w+=A[x]*Number(a.get(y+x,D));for(let x=0;x<f;x++)a.set([y+x,D],Number(a.get(y+x,D))-S*A[x]*w)}}if(t==="raw"){let y=N.zeros([e,n],"float64");for(let p=0;p<e;p++)for(let g=0;g<n;g++)y.set([p,g],Number(a.get(p,g)));let f=N.zeros([o],"float64");for(let p=0;p<o;p++)f.set([p],s[p]);return{h:y,tau:f}}if(t==="r"){let y=N.zeros([o,n],"float64");for(let f=0;f<o;f++)for(let p=f;p<n;p++)y.set([f,p],Number(a.get(f,p)));return y}let u=t==="complete"?e:o,c=N.zeros([e,u],"float64");for(let y=0;y<Math.min(e,u);y++)c.set([y,y],1);for(let y=o-1;y>=0;y--){let f=i[y],p=s[y],g=e-y;for(let h=y;h<u;h++){let b=0;for(let A=0;A<g;A++)b+=f[A]*Number(c.get(y+A,h));for(let A=0;A<g;A++)c.set([y+A,h],Number(c.get(y+A,h))-p*f[A]*b)}}let l=N.zeros([e,u],"float64");for(let y=0;y<e;y++)for(let f=0;f<u;f++)l.set([y,f],Number(c.get(y,f)));let m=t==="complete"?e:o,d=N.zeros([m,n],"float64");for(let y=0;y<m;y++)for(let f=0;f<n;f++)f>=y&&d.set([y,f],Number(a.get(y,f)));return{q:l,r:d}}function Wa(r,t=!1){if(r.ndim!==2)throw new Error(`cholesky: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`cholesky: matrix must be square, got ${e}x${n}`);let o=e,a=N.zeros([o,o],"float64");for(let i=0;i<o;i++)for(let s=0;s<=i;s++){let u=0;if(i===s){for(let l=0;l<s;l++)u+=Number(a.get(s,l))**2;let c=Number(r.get(s,s))-u;if(c<0)throw new Error("cholesky: matrix is not positive definite");a.set([s,s],Math.sqrt(c))}else{for(let l=0;l<s;l++)u+=Number(a.get(i,l))*Number(a.get(s,l));let c=Number(a.get(s,s));if(Math.abs(c)<1e-15)throw new Error("cholesky: matrix is not positive definite");a.set([i,s],(Number(r.get(i,s))-u)/c)}}if(t){let i=N.zeros([o,o],"float64");for(let s=0;s<o;s++)for(let u=s;u<o;u++)i.set([s,u],Number(a.get(u,s)));return i}return a}function kr(r){if(r.ndim!==2)throw new Error(`svd: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape,n=Math.min(t,e),o=N.zeros([e,e],"float64");for(let m=0;m<e;m++)for(let d=0;d<e;d++){let y=0;for(let f=0;f<t;f++)y+=Number(r.get(f,m))*Number(r.get(f,d));o.set([m,d],y)}let{values:a,vectors:i}=tn(o),s=Array.from({length:e},(m,d)=>d);s.sort((m,d)=>a[d]-a[m]);let u=N.zeros([n],"float64");for(let m=0;m<n;m++){let d=a[s[m]];u.set([m],Math.sqrt(Math.max(0,d)))}let c=N.zeros([e,e],"float64");for(let m=0;m<e;m++)for(let d=0;d<e;d++)c.set([m,d],i[d][s[m]]);let l=N.zeros([t,t],"float64");for(let m=0;m<t;m++)for(let d=0;d<n;d++){let y=Number(u.get(d));if(y>1e-10){let f=0;for(let p=0;p<e;p++)f+=Number(r.get(m,p))*Number(c.get(d,p));l.set([m,d],f/y)}}if(t>n)for(let m=n;m<t;m++){let d=new Array(t).fill(0);d[m]=1;for(let f=0;f<m;f++){let p=0;for(let g=0;g<t;g++)p+=d[g]*Number(l.get(g,f));for(let g=0;g<t;g++)d[g]=d[g]-p*Number(l.get(g,f))}let y=0;for(let f=0;f<t;f++)y+=d[f]*d[f];if(y=Math.sqrt(y),y>1e-10)for(let f=0;f<t;f++)l.set([f,m],d[f]/y)}return{u:l,s:u,vt:c}}function tn(r){let t=r.shape[0],e=100*t*t,n=1e-10,o=[];for(let s=0;s<t;s++){o.push([]);for(let u=0;u<t;u++)o[s].push(Number(r.get(s,u)))}let a=[];for(let s=0;s<t;s++){a.push([]);for(let u=0;u<t;u++)a[s].push(s===u?1:0)}for(let s=0;s<e;s++){let u=0,c=0,l=1;for(let A=0;A<t;A++)for(let S=A+1;S<t;S++)Math.abs(o[A][S])>u&&(u=Math.abs(o[A][S]),c=A,l=S);if(u<n)break;let m=o[c][c],d=o[l][l],y=o[c][l],f;Math.abs(m-d)<1e-15?f=Math.PI/4:f=.5*Math.atan2(2*y,d-m);let p=Math.cos(f),g=Math.sin(f),h=p*p*m+g*g*d-2*g*p*y,b=g*g*m+p*p*d+2*g*p*y;o[c][c]=h,o[l][l]=b,o[c][l]=0,o[l][c]=0;for(let A=0;A<t;A++)if(A!==c&&A!==l){let S=o[A][c],D=o[A][l];o[A][c]=p*S-g*D,o[c][A]=o[A][c],o[A][l]=g*S+p*D,o[l][A]=o[A][l]}for(let A=0;A<t;A++){let S=a[A][c],D=a[A][l];a[A][c]=p*S-g*D,a[A][l]=g*S+p*D}}let i=[];for(let s=0;s<t;s++)i.push(o[s][s]);return{values:i,vectors:a}}function en(r,t=!0,e=!0){let n=kr(r);if(!e)return n.s;if(!t){let[o,a]=r.shape,i=Math.min(o,a),s=N.zeros([o,i],"float64");for(let c=0;c<o;c++)for(let l=0;l<i;l++)s.set([c,l],Number(n.u.get(c,l)));let u=N.zeros([i,a],"float64");for(let c=0;c<i;c++)for(let l=0;l<a;l++)u.set([c,l],Number(n.vt.get(c,l)));return{u:s,s:n.s,vt:u}}return n}function Ga(r){if(r.ndim!==2)throw new Error(`det: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`det: matrix must be square, got ${t}x${e}`);let n=t;if(n===0)return 1;let o=r.data;if(n===1)return Number(o[0]);if(n===2)return Number(o[0])*Number(o[3])-Number(o[1])*Number(o[2]);let{lu:a,sign:i}=Zt(r),s=a.data,u=i;for(let c=0;c<n;c++)u*=s[c*n+c];return u}function Zt(r){let[t,e]=r.shape,n=t,o=e,a=N.zeros([n,o],"float64"),i=a.data,s=r.data;for(let l=0;l<n*o;l++)i[l]=Number(s[l]);let u=Array.from({length:n},(l,m)=>m),c=1;for(let l=0;l<Math.min(n,o);l++){let m=Math.abs(i[l*o+l]),d=l;for(let f=l+1;f<n;f++){let p=Math.abs(i[f*o+l]);p>m&&(m=p,d=f)}if(d!==l){for(let p=0;p<o;p++){let g=i[l*o+p];i[l*o+p]=i[d*o+p],i[d*o+p]=g}let f=u[l];u[l]=u[d],u[d]=f,c=-c}let y=i[l*o+l];if(Math.abs(y)>1e-15)for(let f=l+1;f<n;f++){let p=i[f*o+l]/y;i[f*o+l]=p;for(let g=l+1;g<o;g++)i[f*o+g]=i[f*o+g]-p*i[l*o+g]}}return{lu:a,piv:u,sign:c}}function Nt(r){if(r.ndim!==2)throw new Error(`inv: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`inv: matrix must be square, got ${t}x${e}`);let n=t,{lu:o,piv:a}=Zt(r),i=o.data,s=N.zeros([n,n],"float64"),u=s.data;for(let c=0;c<n;c++){let l=new Float64Array(n);for(let m=0;m<n;m++){let d=a[m]===c?1:0;for(let y=0;y<m;y++)d-=i[m*n+y]*l[y];l[m]=d}for(let m=n-1;m>=0;m--){let d=l[m];for(let f=m+1;f<n;f++)d-=i[m*n+f]*u[f*n+c];let y=i[m*n+m];if(Math.abs(y)<1e-15)throw new Error("inv: singular matrix");u[m*n+c]=d/y}}return s}function ka(r,t){let[e]=r.shape,n=e,{lu:o,piv:a}=Zt(r),i=o.data,s=t.data,u=new Float64Array(n);for(let d=0;d<n;d++)u[d]=Number(s[a[d]]);let c=new Float64Array(n);for(let d=0;d<n;d++){let y=u[d];for(let f=0;f<d;f++)y-=i[d*n+f]*c[f];c[d]=y}let l=N.zeros([n],"float64"),m=l.data;for(let d=n-1;d>=0;d--){let y=c[d];for(let p=d+1;p<n;p++)y-=i[d*n+p]*m[p];let f=i[d*n+d];if(Math.abs(f)<1e-15)throw new Error("solve: singular matrix");m[d]=y/f}return l}function nn(r,t){if(r.ndim!==2)throw new Error(`solve: coefficient matrix must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`solve: coefficient matrix must be square, got ${e}x${n}`);let o=e;if(t.ndim===1){if(t.shape[0]!==o)throw new Error(`solve: incompatible shapes (${e},${n}) and (${t.shape[0]},)`);return ka(r,t)}if(t.ndim===2){if(t.shape[0]!==o)throw new Error(`solve: incompatible shapes (${e},${n}) and (${t.shape[0]},${t.shape[1]})`);let a=t.shape[1],i=N.zeros([o,a],"float64");for(let s=0;s<a;s++){let u=N.zeros([o],"float64");for(let l=0;l<o;l++)u.set([l],Number(t.get(l,s)));let c=ka(r,u);for(let l=0;l<o;l++)i.set([l,s],Number(c.get(l)))}return i}throw new Error(`solve: b must be 1D or 2D, got ${t.ndim}D`)}function Za(r,t,e=null){if(r.ndim!==2)throw new Error(`lstsq: coefficient matrix must be 2D, got ${r.ndim}D`);let[n,o]=r.shape,{u:a,s:i,vt:s}=kr(r),u=Math.min(n,o),c=e??Math.max(n,o)*Number.EPSILON,m=Number(i.get(0))*c,d=0;for(let b=0;b<u;b++)Number(i.get(b))>m&&d++;let y=t.ndim===1?er(t,[t.size,1]):t,f=y.shape[1];if(y.shape[0]!==n)throw new Error(`lstsq: incompatible shapes (${n},${o}) and (${t.shape.join(",")})`);let p=N.zeros([o,f],"float64");for(let b=0;b<f;b++){let A=new Array(n).fill(0);for(let S=0;S<n;S++)for(let D=0;D<n;D++)A[S]+=Number(a.get(D,S))*Number(y.get(D,b));for(let S=0;S<o;S++){let D=0;for(let w=0;w<u;w++){let x=Number(i.get(w));x>m&&(D+=Number(s.get(w,S))*A[w]/x)}p.set([S,b],D)}}let g;if(n>o){g=N.zeros([f],"float64");for(let b=0;b<f;b++){let A=0;for(let S=0;S<n;S++){let D=0;for(let x=0;x<o;x++)D+=Number(r.get(S,x))*Number(p.get(x,b));let w=D-Number(y.get(S,b));A+=w*w}g.set([b],A)}}else g=N.zeros([0],"float64");return{x:t.ndim===1?er(p,[o]):p,residuals:g,rank:d,s:i}}function Ya(r,t=2){if(r.ndim!==2)throw new Error(`cond: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(t===2||t===-2){let{s}=kr(r),u=Math.min(e,n),c=Number(s.get(0)),l=Number(s.get(u-1));return t===2?l>0?c/l:1/0:c>0?l/c:0}if(e!==n)throw new Error(`cond: matrix must be square for p=${t}`);let o=Wr(r,t),a=Nt(r),i=Wr(a,t);return o*i}function Ha(r,t){if(r.ndim===0)return Number(r.get())!==0?1:0;if(r.ndim===1){for(let i=0;i<r.size;i++)if(Number(r.get(i))!==0)return 1;return 0}if(r.ndim!==2)throw new Error(`matrix_rank: input must be at most 2D, got ${r.ndim}D`);let{s:e}=kr(r),n=Number(e.get(0)),o=t??n*Math.max(r.shape[0],r.shape[1])*Number.EPSILON,a=0;for(let i=0;i<e.size;i++)Number(e.get(i))>o&&a++;return a}function Xa(r,t){if(r.ndim!==2)throw new Error(`matrix_power: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`matrix_power: matrix must be square, got ${e}x${n}`);let o=e;if(!Number.isInteger(t))throw new Error("matrix_power: exponent must be an integer");if(t===0){let c=N.zeros([o,o],"float64");for(let l=0;l<o;l++)c.set([l,l],1);return c}let a=r,i=t;t<0&&(a=Nt(r),i=-t);let s=N.zeros([o,o],"float64");for(let c=0;c<o;c++)s.set([c,c],1);let u=N.zeros([o,o],"float64");for(let c=0;c<o;c++)for(let l=0;l<o;l++)u.set([c,l],Number(a.get(c,l)));for(;i>0;)i&1&&(s=mr(s,u)),u=mr(u,u),i>>=1;return s}function Ja(r,t=1e-15){if(r.ndim!==2)throw new Error(`pinv: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape,{u:o,s:a,vt:i}=kr(r),s=Math.min(e,n),c=Number(a.get(0))*t,l=N.zeros([n,e],"float64");for(let m=0;m<n;m++)for(let d=0;d<e;d++){let y=0;for(let f=0;f<s;f++){let p=Number(a.get(f));p>c&&(y+=Number(i.get(f,m))*Number(o.get(d,f))/p)}l.set([m,d],y)}return l}function on(r){if(r.ndim!==2)throw new Error(`eig: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`eig: matrix must be square, got ${t}x${e}`);let n=t,o=!0;r:for(let c=0;c<n;c++)for(let l=c+1;l<n;l++)if(Math.abs(Number(r.get(c,l))-Number(r.get(l,c)))>1e-10){o=!1;break r}if(o){let{values:c,vectors:l}=tn(r),m=N.zeros([n],"float64"),d=N.zeros([n,n],"float64");for(let y=0;y<n;y++){m.set([y],c[y]);for(let f=0;f<n;f++)d.set([f,y],l[f][y])}return{w:m,v:d}}console.warn("numpy-ts: eig() called on non-symmetric matrix. Complex eigenvalues are not supported; results may be inaccurate. For symmetric matrices, use eigh() instead.");let{values:a,vectors:i}=Fd(r),s=N.zeros([n],"float64"),u=N.zeros([n,n],"float64");for(let c=0;c<n;c++){s.set([c],a[c]);for(let l=0;l<n;l++)u.set([l,c],i[l][c])}return{w:s,v:u}}function Fd(r){let t=r.shape[0],e=1e3,n=1e-10,o=N.zeros([t,t],"float64");for(let u=0;u<t;u++)for(let c=0;c<t;c++)o.set([u,c],Number(r.get(u,c)));let a=N.zeros([t,t],"float64");for(let u=0;u<t;u++)a.set([u,u],1);for(let u=0;u<e;u++){let c=0;for(let y=0;y<t;y++)for(let f=0;f<t;f++)y!==f&&(c+=Number(o.get(y,f))**2);if(Math.sqrt(c)<n*t)break;let l=rn(o,"reduced"),m=l.q,d=l.r;o=mr(d,m),a=mr(a,m)}let i=[];for(let u=0;u<t;u++)i.push(Number(o.get(u,u)));let s=[];for(let u=0;u<t;u++){s.push([]);for(let c=0;c<t;c++)s[u].push(Number(a.get(u,c)))}return{values:i,vectors:s}}function an(r,t="L"){if(r.ndim!==2)throw new Error(`eigh: input must be 2D, got ${r.ndim}D`);let[e,n]=r.shape;if(e!==n)throw new Error(`eigh: matrix must be square, got ${e}x${n}`);let o=e,a=N.zeros([o,o],"float64");for(let m=0;m<o;m++)for(let d=0;d<o;d++)t==="L"?m>=d&&(a.set([m,d],Number(r.get(m,d))),a.set([d,m],Number(r.get(m,d)))):d>=m&&(a.set([m,d],Number(r.get(m,d))),a.set([d,m],Number(r.get(m,d))));let{values:i,vectors:s}=tn(a),u=Array.from({length:o},(m,d)=>d);u.sort((m,d)=>i[m]-i[d]);let c=N.zeros([o],"float64"),l=N.zeros([o,o],"float64");for(let m=0;m<o;m++){c.set([m],i[u[m]]);for(let d=0;d<o;d++)l.set([d,m],s[d][u[m]])}return{w:c,v:l}}function Qa(r){let{w:t}=on(r);return t}function Ka(r,t="L"){let{w:e}=an(r,t);return e}function rs(r,t){let e=Lr(r),n=Lr(t),o=e.shape[0],a=n.shape[0];if(o!==a)throw new Error(`vdot: arrays must have same number of elements, got ${o} and ${a}`);if(M(r.dtype)||M(t.dtype)){let u=0,c=0;for(let l=0;l<o;l++){let m=e.get(l),d=n.get(l),y=m instanceof E?m.re:Number(m),f=m instanceof E?-m.im:0,p=d instanceof E?d.re:Number(d),g=d instanceof E?d.im:0;u+=y*p+f*g,c+=y*g-f*p}return Math.abs(c)<1e-15?u:new E(u,c)}let s=0;for(let u=0;u<o;u++){let c=e.get(u),l=n.get(u);typeof c=="bigint"&&typeof l=="bigint"?s=(typeof s=="bigint"?s:BigInt(s))+c*l:s=(typeof s=="bigint"?Number(s):s)+Number(c)*Number(l)}return s}function sn(r,t,e=-1){let n=r.ndim,o=t.ndim,a=e<0?n+e:e,i=e<0?o+e:e;if(a<0||a>=n)throw new Error(`vecdot: axis ${e} out of bounds for array with ${n} dimensions`);if(i<0||i>=o)throw new Error(`vecdot: axis ${e} out of bounds for array with ${o} dimensions`);let s=r.shape[a],u=t.shape[i];if(s!==u)throw new Error(`vecdot: axis dimensions must match, got ${s} and ${u}`);if(n===1&&o===1)return ot(r,t);let c=[...r.shape.slice(0,a),...r.shape.slice(a+1)],l=[...t.shape.slice(0,i),...t.shape.slice(i+1)],m=s,d=M(r.dtype)||M(t.dtype),y=Z(r.dtype,t.dtype),f=c.length>l.length?c:l;if(f.length===0){let h=d?new E(0,0):0;for(let b=0;b<m;b++){let A=r.get(b),S=t.get(b),D=wr(A,S);if(h instanceof E||D instanceof E){let w=h instanceof E?h:new E(Number(h),0),x=D instanceof E?D:new E(Number(D),0);h=w.add(x)}else typeof h=="bigint"||typeof D=="bigint"?h=BigInt(h)+BigInt(D):h=h+D}return h}let p=N.zeros(f,y),g=f.reduce((h,b)=>h*b,1);for(let h=0;h<g;h++){let b=[],A=h;for(let x=f.length-1;x>=0;x--)b.unshift(A%f[x]),A=Math.floor(A/f[x]);let S=[...b.slice(0,a),0,...b.slice(a)],D=[...b.slice(0,i),0,...b.slice(i)],w=d?new E(0,0):0;for(let x=0;x<m;x++){S[a]=x,D[i]=x;let I=r.get(...S),z=t.get(...D),F=wr(I,z);if(w instanceof E||F instanceof E){let v=w instanceof E?w:new E(Number(w),0),T=F instanceof E?F:new E(Number(F),0);w=v.add(T)}else typeof w=="bigint"||typeof F=="bigint"?w=BigInt(w)+BigInt(F):w=w+F}p.set(b,w)}return p}function un(r){if(r.ndim<2)throw new Error(`matrix_transpose: input must have at least 2 dimensions, got ${r.ndim}D`);let t=Array.from({length:r.ndim},(n,o)=>o),e=t.length-1;return t[e]=e-1,t[e-1]=e,Dt(r,t)}function ts(r,t){return Dt(r,t)}function es(r,t){if(r.ndim<2)throw new Error(`matvec: x1 must have at least 2 dimensions, got ${r.ndim}D`);if(t.ndim<1)throw new Error(`matvec: x2 must have at least 1 dimension, got ${t.ndim}D`);let e=r.shape[r.ndim-2],n=r.shape[r.ndim-1],o=t.shape[t.ndim-1];if(n!==o)throw new Error(`matvec: last axis of x1 (${n}) must match last axis of x2 (${o})`);if(r.ndim===2&&t.ndim===1)return ot(r,t);let a=r.shape.slice(0,-2),i=t.shape.slice(0,-1),s=Math.max(a.length,i.length),u=[...Array(s-a.length).fill(1),...a],c=[...Array(s-i.length).fill(1),...i],l=[];for(let g=0;g<s;g++){let h=u[g],b=c[g];if(h!==1&&b!==1&&h!==b)throw new Error(`matvec: batch dimensions not broadcastable: ${a} vs ${i}`);l.push(Math.max(h,b))}let m=[...l,e],d=Z(r.dtype,t.dtype),y=N.zeros(m,d),f=M(d),p=l.reduce((g,h)=>g*h,1);for(let g=0;g<p;g++){let h=[],b=g;for(let D=l.length-1;D>=0;D--)h.unshift(b%l[D]),b=Math.floor(b/l[D]);let A=h.slice(-(a.length||1)).map((D,w)=>(a[w]??1)===1?0:D),S=h.slice(-(i.length||1)).map((D,w)=>(i[w]??1)===1?0:D);for(let D=0;D<e;D++){let w=f?new E(0,0):0;for(let I=0;I<n;I++){let z=[...A,D,I],F=[...S,I],v=r.get(...z),T=t.get(...F),O=wr(v,T);if(w instanceof E||O instanceof E){let C=w instanceof E?w:new E(Number(w),0),q=O instanceof E?O:new E(Number(O),0);w=C.add(q)}else typeof w=="bigint"||typeof O=="bigint"?w=BigInt(w)+BigInt(O):w=w+O}let x=[...h,D];y.set(x,w)}}return y}function ns(r,t){if(r.ndim<1)throw new Error(`vecmat: x1 must have at least 1 dimension, got ${r.ndim}D`);if(t.ndim<2)throw new Error(`vecmat: x2 must have at least 2 dimensions, got ${t.ndim}D`);let e=r.shape[r.ndim-1],n=t.shape[t.ndim-2],o=t.shape[t.ndim-1];if(e!==n)throw new Error(`vecmat: last axis of x1 (${e}) must match second-to-last axis of x2 (${n})`);if(r.ndim===1&&t.ndim===2)return ot(r,t);let a=r.shape.slice(0,-1),i=t.shape.slice(0,-2),s=Math.max(a.length,i.length),u=[...Array(s-a.length).fill(1),...a],c=[...Array(s-i.length).fill(1),...i],l=[];for(let g=0;g<s;g++){let h=u[g],b=c[g];if(h!==1&&b!==1&&h!==b)throw new Error(`vecmat: batch dimensions not broadcastable: ${a} vs ${i}`);l.push(Math.max(h,b))}let m=[...l,o],d=Z(r.dtype,t.dtype),y=N.zeros(m,d),f=M(d),p=l.reduce((g,h)=>g*h,1);for(let g=0;g<p;g++){let h=[],b=g;for(let D=l.length-1;D>=0;D--)h.unshift(b%l[D]),b=Math.floor(b/l[D]);let A=h.slice(-(a.length||1)).map((D,w)=>(a[w]??1)===1?0:D),S=h.slice(-(i.length||1)).map((D,w)=>(i[w]??1)===1?0:D);for(let D=0;D<o;D++){let w=f?new E(0,0):0;for(let I=0;I<e;I++){let z=[...A,I],F=[...S,I,D],v=r.get(...z),T=t.get(...F),O=wr(v,T);if(w instanceof E||O instanceof E){let C=w instanceof E?w:new E(Number(w),0),q=O instanceof E?O:new E(Number(O),0);w=C.add(q)}else typeof w=="bigint"||typeof O=="bigint"?w=BigInt(w)+BigInt(O):w=w+O}let x=[...h,D];y.set(x,w)}}return y}function os(r){if(r.ndim!==2)throw new Error(`slogdet: input must be 2D, got ${r.ndim}D`);let[t,e]=r.shape;if(t!==e)throw new Error(`slogdet: matrix must be square, got ${t}x${e}`);let n=t;if(n===0)return{sign:1,logabsdet:0};let{lu:o,sign:a}=Zt(r),i=o.data,s=0,u=a;for(let c=0;c<n;c++){let l=i[c*n+c];if(l===0)return{sign:0,logabsdet:-1/0};l<0&&(u=-u),s+=Math.log(Math.abs(l))}return{sign:u,logabsdet:s}}function as(r){return en(r,!0,!1)}function ss(r){if(r.length<2)throw new Error("multi_dot: need at least 2 arrays");if(r.length===2)return mr(r[0],r[1]);let t=r[0];for(let e=1;e<r.length;e++)t=mr(t,r[e]);return t}function is(r,t=2){if(t<=0)throw new Error(`tensorinv: ind must be positive, got ${t}`);let e=r.shape,n=r.ndim;if(n<t)throw new Error(`tensorinv: array has ${n} dimensions, ind=${t} is too large`);let o=1;for(let c=0;c<t;c++)o*=e[c];let a=1;for(let c=t;c<n;c++)a*=e[c];if(o!==a)throw new Error(`tensorinv: product of first ${t} dimensions (${o}) must equal product of remaining dimensions (${a})`);let i=er(r,[o,a]),s=Nt(i),u=[...e.slice(t),...e.slice(0,t)];return er(s,u)}function us(r,t,e){let n=r.shape,o=t.shape,a=r.ndim,i=t.ndim,s;e==null?s=Array.from({length:i},(A,S)=>a-i+S):s=e.map(A=>A<0?a+A:A);let u=[];for(let A=0;A<a;A++)s.includes(A)||u.push(A);let c=[...u,...s],l=Dt(r,c),d=s.map(A=>n[A]).reduce((A,S)=>A*S,1),f=u.map(A=>n[A]).reduce((A,S)=>A*S,1),p=o.reduce((A,S)=>A*S,1);if(d!==p)throw new Error(`tensorsolve: dimensions don't match - sum dimensions product (${d}) != b total elements (${p})`);if(f!==d)throw new Error(`tensorsolve: non-square problem - other dimensions product (${f}) != sum dimensions product (${d})`);let g=er(l,[f,d]),h=er(t,[d]),b=nn(g,h);return er(b,[...o])}var cs=G(()=>{"use strict";K();Q();xr();He()});function ls(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=Math.sqrt(u*u+c*c),m=Math.sqrt((l+u)/2),d=(c>=0?1:-1)*Math.sqrt((l-u)/2);i[s*2]=m,i[s*2+1]=d}return a}return J(r,Math.sqrt,!1)}function fs(r,t){if(typeof t=="number")return Ed(r,t);let e=M(r.dtype),n=M(t.dtype);return e||n?Bd(r,t):X(r,t,Math.pow,"power")}function Bd(r,t){let e=M(r.dtype),n=M(t.dtype),o=r.dtype==="complex128"||t.dtype==="complex128"||t.dtype==="float64"?"complex128":"complex64",a=Array.from(r.shape),i=r.size,s=N.zeros(a,o),u=s.data;for(let c=0;c<i;c++){let l,m;if(e){let S=r.data;l=S[c*2],m=S[c*2+1]}else l=Number(r.iget(c)),m=0;let d,y;if(n){let S=t.data;d=S[c*2],y=S[c*2+1]}else d=Number(t.iget(c)),y=0;let f=Math.sqrt(l*l+m*m),p=Math.atan2(m,l),g=Math.log(f),h=d*g-y*p,b=d*p+y*g,A=Math.exp(h);u[c*2]=A*Math.cos(b),u[c*2+1]=A*Math.sin(b)}return s}function Ed(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size;if(M(e)){let m=N.zeros(n,e),d=o,y=m.data;for(let f=0;f<a;f++){let p=d[f*2],g=d[f*2+1],h=Math.sqrt(p*p+g*g),b=Math.atan2(g,p),A=Math.pow(h,t),S=b*t;y[f*2]=A*Math.cos(S),y[f*2+1]=A*Math.sin(S)}return m}let u=e!=="float32"&&e!=="float64"&&(t<0||!Number.isInteger(t))?"float64":e,c=N.zeros(n,u),l=c.data;if(B(e))if(B(u)&&Number.isInteger(t)&&t>=0){let m=o,d=l;for(let y=0;y<a;y++)d[y]=m[y]**BigInt(t)}else for(let m=0;m<a;m++)l[m]=Math.pow(Number(o[m]),t);else for(let m=0;m<a;m++)l[m]=Math.pow(Number(o[m]),t);return c}function ms(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=Math.exp(u);i[s*2]=l*Math.cos(c),i[s*2+1]=l*Math.sin(c)}return a}return J(r,Math.exp,!1)}function ps(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=Math.LN2,i=N.zeros(e,t),s=i.data;for(let u=0;u<n;u++){let c=o[u*2],l=o[u*2+1],m=Math.exp(c*a),d=l*a;s[u*2]=m*Math.cos(d),s[u*2+1]=m*Math.sin(d)}return i}return J(r,e=>Math.pow(2,e),!1)}function ys(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=Math.exp(u);i[s*2]=l*Math.cos(c)-1,i[s*2+1]=l*Math.sin(c)}return a}return J(r,Math.expm1,!1)}function ds(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=Math.sqrt(u*u+c*c),m=Math.atan2(c,u);i[s*2]=Math.log(l),i[s*2+1]=m}return a}return J(r,Math.log,!1)}function gs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=1/Math.LN2,i=N.zeros(e,t),s=i.data;for(let u=0;u<n;u++){let c=o[u*2],l=o[u*2+1],m=Math.sqrt(c*c+l*l),d=Math.atan2(l,c);s[u*2]=Math.log(m)*a,s[u*2+1]=d*a}return i}return J(r,Math.log2,!1)}function As(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=1/Math.LN10,i=N.zeros(e,t),s=i.data;for(let u=0;u<n;u++){let c=o[u*2],l=o[u*2+1],m=Math.sqrt(c*c+l*l),d=Math.atan2(l,c);s[u*2]=Math.log(m)*a,s[u*2+1]=d*a}return i}return J(r,Math.log10,!1)}function bs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=1+u,m=Math.sqrt(l*l+c*c),d=Math.atan2(c,l);i[s*2]=Math.log(m),i[s*2+1]=d}return a}return J(r,Math.log1p,!1)}function hs(r,t){return U(r.dtype,"logaddexp","logaddexp is not supported for complex numbers."),typeof t!="number"&&U(t.dtype,"logaddexp","logaddexp is not supported for complex numbers."),typeof t=="number"?Od(r,t):Td(r,t)}function Td(r,t){let e=Ur(r.shape,t.shape),n=e.reduce((c,l)=>c*l,1),o=r.dtype,a=t.dtype,i=o==="float32"&&a==="float32"?"float32":"float64",s=N.zeros(e,i),u=s.data;for(let c=0;c<n;c++){let l=(B(o),Number(r.iget(c))),m=(B(a),Number(t.iget(c))),d=Math.max(l,m),y=Math.min(l,m);u[c]=d+Math.log1p(Math.exp(y-d))}return s}function Od(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=e==="float32"?"float32":"float64",i=N.zeros(n,a),s=i.data;for(let u=0;u<o;u++){let c=(B(e),Number(r.data[u])),l=Math.max(c,t),m=Math.min(c,t);s[u]=l+Math.log1p(Math.exp(m-l))}return i}function Ss(r,t){return U(r.dtype,"logaddexp2","logaddexp2 is not supported for complex numbers."),typeof t!="number"&&U(t.dtype,"logaddexp2","logaddexp2 is not supported for complex numbers."),typeof t=="number"?Ud(r,t):Cd(r,t)}function Cd(r,t){let e=Ur(r.shape,t.shape),n=e.reduce((l,m)=>l*m,1),o=r.dtype,a=t.dtype,i=o==="float32"&&a==="float32"?"float32":"float64",s=N.zeros(e,i),u=s.data,c=Math.LOG2E;for(let l=0;l<n;l++){let m=(B(o),Number(r.iget(l))),d=(B(a),Number(t.iget(l))),y=Math.max(m,d),f=Math.min(m,d);u[l]=y+Math.log1p(Math.pow(2,f-y))*c}return s}function Ud(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=e==="float32"?"float32":"float64",i=N.zeros(n,a),s=i.data,u=Math.LOG2E;for(let c=0;c<o;c++){let l=(B(e),Number(r.data[c])),m=Math.max(l,t),d=Math.min(l,t);s[c]=m+Math.log1p(Math.pow(2,d-m))*u}return i}var Ds=G(()=>{"use strict";K();Er();Q()});function Ns(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1];i[s*2]=Math.sin(u)*Math.cosh(c),i[s*2+1]=Math.cos(u)*Math.sinh(c)}return a}return J(r,Math.sin,!1)}function xs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1];i[s*2]=Math.cos(u)*Math.cosh(c),i[s*2+1]=-Math.sin(u)*Math.sinh(c)}return a}return J(r,Math.cos,!1)}function ws(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=Math.cos(2*u)+Math.cosh(2*c);i[s*2]=Math.sin(2*u)/l,i[s*2+1]=Math.sinh(2*c)/l}return a}return J(r,Math.tan,!1)}function Is(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=-c,m=u,d=u*u-c*c,y=2*u*c,f=1-d,p=-y,g=Math.sqrt(f*f+p*p),h=Math.sqrt((g+f)/2),b=(p>=0?1:-1)*Math.sqrt((g-f)/2),A=l+h,S=m+b,D=Math.sqrt(A*A+S*S),w=Math.log(D),I=Math.atan2(S,A),z=-w;Math.abs(c)<1e-15&&u>1&&(z=-z),i[s*2]=I,i[s*2+1]=z}return a}return J(r,Math.asin,!1)}function zs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=u*u-c*c,m=2*u*c,d=1-l,y=-m,f=Math.sqrt(d*d+y*y),p=Math.sqrt((f+d)/2),h=-((y>=0?1:-1)*Math.sqrt((f-d)/2)),b=p,A=u+h,S=c+b,D=Math.sqrt(A*A+S*S),w=Math.log(D),I=Math.atan2(S,A),z=-w;Math.abs(c)<1e-15&&u>1&&(z=-z),i[s*2]=I,i[s*2+1]=z}return a}return J(r,Math.acos,!1)}function _s(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],l=-o[s*2+1],m=u,d=1-l,y=-m,f=1+l,p=m,g=f*f+p*p,h=(d*f+y*p)/g,b=(y*f-d*p)/g,A=Math.sqrt(h*h+b*b),S=Math.log(A),D=Math.atan2(b,h);i[s*2]=-D/2,i[s*2+1]=S/2}return a}return J(r,Math.atan,!1)}function vs(r,t){return U(r.dtype,"arctan2","arctan2 is only defined for real numbers."),typeof t!="number"&&U(t.dtype,"arctan2","arctan2 is only defined for real numbers."),typeof t=="number"?kd(r,t):Rd(r,t)}function Rd(r,t){let e=Array.from(r.shape),n=r.size,o=r.dtype,a=t.dtype,i=o==="float32"&&a==="float32"?"float32":"float64",s=N.zeros(e,i),u=s.data;for(let c=0;c<n;c++){let l=(B(o),Number(r.data[c])),m=(B(a),Number(t.data[c]));u[c]=Math.atan2(l,m)}return s}function kd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=e==="float32"?"float32":"float64",s=N.zeros(n,i),u=s.data;if(B(e))for(let c=0;c<a;c++)u[c]=Math.atan2(Number(o[c]),t);else for(let c=0;c<a;c++)u[c]=Math.atan2(Number(o[c]),t);return s}function Fs(r,t){return U(r.dtype,"hypot","hypot is only defined for real numbers."),typeof t!="number"&&U(t.dtype,"hypot","hypot is only defined for real numbers."),typeof t=="number"?Vd(r,t):qd(r,t)}function qd(r,t){let e=Array.from(r.shape),n=r.size,o=r.dtype,a=t.dtype,i=o==="float32"&&a==="float32"?"float32":"float64",s=N.zeros(e,i),u=s.data;for(let c=0;c<n;c++){let l=(B(o),Number(r.data[c])),m=(B(a),Number(t.data[c]));u[c]=Math.hypot(l,m)}return s}function Vd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=e==="float32"?"float32":"float64",s=N.zeros(n,i),u=s.data;if(B(e))for(let c=0;c<a;c++)u[c]=Math.hypot(Number(o[c]),t);else for(let c=0;c<a;c++)u[c]=Math.hypot(Number(o[c]),t);return s}function Ms(r){U(r.dtype,"degrees","degrees is only defined for real numbers.");let t=180/Math.PI;return J(r,e=>e*t,!1)}function Bs(r){U(r.dtype,"radians","radians is only defined for real numbers.");let t=Math.PI/180;return J(r,e=>e*t,!1)}var Es=G(()=>{"use strict";K();Er();Q()});function Ts(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1];i[s*2]=Math.sinh(u)*Math.cos(c),i[s*2+1]=Math.cosh(u)*Math.sin(c)}return a}return J(r,Math.sinh,!1)}function Os(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1];i[s*2]=Math.cosh(u)*Math.cos(c),i[s*2+1]=Math.sinh(u)*Math.sin(c)}return a}return J(r,Math.cosh,!1)}function Cs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=Math.cosh(2*u)+Math.cos(2*c);i[s*2]=Math.sinh(2*u)/l,i[s*2+1]=Math.sin(2*c)/l}return a}return J(r,Math.tanh,!1)}function Us(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=u*u-c*c,m=2*u*c,d=l+1,y=m,f=Math.sqrt(d*d+y*y),p=Math.sqrt((f+d)/2),g=(y>=0?1:-1)*Math.sqrt((f-d)/2),h=u+p,b=c+g,A=Math.sqrt(h*h+b*b);i[s*2]=Math.log(A),i[s*2+1]=Math.atan2(b,h)}return a}return J(r,Math.asinh,!1)}function $s(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=u*u-c*c,m=2*u*c,d=l-1,y=m,f=Math.sqrt(d*d+y*y),p=Math.sqrt((f+d)/2),g=(y>=0?1:-1)*Math.sqrt((f-d)/2),h=u+p,b=c+g,A=Math.sqrt(h*h+b*b),S=Math.log(A),D=Math.atan2(b,h);Math.abs(c)<1e-15&&u<1&&(D=-D),i[s*2]=S,i[s*2+1]=D}return a}return J(r,Math.acosh,!1)}function Rs(r){let t=r.dtype;if(M(t)){let e=Array.from(r.shape),n=r.size,o=r.data,a=N.zeros(e,t),i=a.data;for(let s=0;s<n;s++){let u=o[s*2],c=o[s*2+1],l=1+u,m=c,d=1-u,y=-c,f=d*d+y*y,p=(l*d+m*y)/f,g=(m*d-l*y)/f,h=Math.sqrt(p*p+g*g),b=Math.log(h),A=Math.atan2(g,p);i[s*2]=b/2,i[s*2+1]=A/2}return a}return J(r,Math.atanh,!1)}var ks=G(()=>{"use strict";K();Er();Q()});function Yt(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=Sr([Array.from(e),t]);if(a===null)throw new Error(`operands could not be broadcast together with shape (${e.join(",")}) (${t.join(",")})`);for(let i=0;i<o;i++)if(a[i]!==t[i])throw new Error(`operands could not be broadcast together with shape (${e.join(",")}) (${t.join(",")})`);return gr(r,t)}function qs(r){if(r.length===0)return[];if(r.length===1)return[r[0]];let t=r.map(n=>Array.from(n.shape)),e=Sr(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=>gr(n,e))}function Vs(r,t,e){let n=r.shape,o=n.length,a=r.dtype;if(e===void 0){let f=r.size;for(let b of t){let A=b<0?f+b:b;if(A<0||A>=f)throw new Error(`index ${b} is out of bounds for axis 0 with size ${f}`)}let p=t.length,g=j(a);if(!g)throw new Error(`Cannot take from array with dtype ${a}`);let h=new g(p);for(let b=0;b<p;b++){let A=t[b];A<0&&(A=f+A);let S=r.iget(A);B(a),h[b]=S}return N.fromData(h,[p],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 s=n[i];for(let f of t){let p=f<0?s+f:f;if(p<0||p>=s)throw new Error(`index ${f} is out of bounds for axis ${i} with size ${s}`)}let u=Array.from(n);u[i]=t.length;let c=u.reduce((f,p)=>f*p,1),l=j(a);if(!l)throw new Error(`Cannot take from array with dtype ${a}`);let m=new l(c),d=ur(u),y=new Array(o).fill(0);for(let f=0;f<c;f++){let p=[...y],g=y[i],h=t[g];h<0&&(h=s+h),p[i]=h;let b=r.get(...p),A=0;for(let S=0;S<o;S++)A+=y[S]*d[S];B(a),m[A]=b;for(let S=o-1;S>=0&&(y[S]++,!(y[S]<u[S]));S--)y[S]=0}return N.fromData(m,u,a)}function Ps(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 i=0;i<e.size;i++){let s=e.iget(i);a.push(s instanceof E?s.re:s)}if(a.length===1)a=new Array(t.length).fill(a[0]);else if(a.length!==t.length){let i=[...a];a=[];for(let s=0;s<t.length;s++)a.push(i[s%i.length])}}for(let i=0;i<t.length;i++){let s=t[i];if(s<0&&(s=n+s),s<0||s>=n)throw new Error(`index ${t[i]} is out of bounds for axis 0 with size ${n}`);let u=a[i];B(o)?typeof u!="bigint"&&(u=BigInt(Math.round(Number(u)))):typeof u=="bigint"&&(u=Number(u)),r.iset(s,u)}}function js(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(d=>Array.from(d.shape));a.unshift(Array.from(e));let i=Sr(a);if(i===null)throw new Error("operands could not be broadcast together");let s=gr(r,i),u=t.map(d=>gr(d,i)),c=i.reduce((d,y)=>d*y,1),l=j(o);if(!l)throw new Error(`Cannot choose with dtype ${o}`);let m=new l(c);for(let d=0;d<c;d++){let y=Number(s.iget(d));if(y<0||y>=n)throw new Error(`index ${y} is out of bounds for axis 0 with size ${n}`);let f=u[y].iget(d);B(o),m[d]=f}return N.fromData(m,i,o)}function Ls(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),i=t.iget(o);if(e){let s=typeof a=="number"&&Number.isNaN(a),u=typeof i=="number"&&Number.isNaN(i);if(s&&u)continue}if(a!==i)return!1}return!0}function Ws(r,t,e){let n=r.shape,o=n.length,a=r.dtype,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 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 p=0;p<o;p++)if(p!==i&&s[p]!==n[p]&&s[p]!==1&&n[p]!==1)throw new Error(`index ${s[p]} is out of bounds for size ${n[p]} in dimension ${p}`);let u=Array.from(s),c=u.reduce((p,g)=>p*g,1),l=j(a);if(!l)throw new Error(`Cannot take_along_axis with dtype ${a}`);let m=new l(c),d=ur(n),y=ur(s),f=n[i];for(let p=0;p<c;p++){let g=new Array(o),h=p;for(let x=o-1;x>=0;x--)g[x]=h%u[x],h=Math.floor(h/u[x]);let b=0;for(let x=0;x<o;x++){let I=s[x]===1?0:g[x];b+=I*y[x]}let A=Number(t.iget(b));if(A<0&&(A=f+A),A<0||A>=f)throw new Error(`index ${A} is out of bounds for axis ${i} with size ${f}`);let S=[...g];S[i]=A;let D=0;for(let x=0;x<o;x++){let I=n[x]===1?0:S[x];D+=I*d[x]}let w=r.iget(D);B(a),m[p]=w}return N.fromData(m,u,a)}function Gs(r,t,e,n){let o=r.shape,a=o.length,i=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 u=t.shape,c=e.shape;if(u.length!==a||c.length!==a)throw new Error("indices, arr, and values must have same ndim");let l=o[s],m=ur(o),d=ur(u),y=ur(c),f=u.reduce((p,g)=>p*g,1);for(let p=0;p<f;p++){let g=new Array(a),h=p;for(let I=a-1;I>=0;I--)g[I]=h%u[I],h=Math.floor(h/u[I]);let b=0;for(let I=0;I<a;I++)b+=g[I]*d[I];let A=Number(t.iget(b));if(A<0&&(A=l+A),A<0||A>=l)throw new Error(`index ${A} is out of bounds for axis ${s} with size ${l}`);let S=0;for(let I=0;I<a;I++){let z=c[I]===1?0:g[I];S+=z*y[I]}let D=e.iget(S),w=[...g];w[s]=A;let x=0;for(let I=0;I<a;I++)x+=w[I]*m[I];B(i)?typeof D!="bigint"&&(D=BigInt(Math.round(Number(D)))):typeof D=="bigint"&&(D=Number(D)),r.iset(x,D)}}function Zs(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++){let u=e.iget(s);a.push(u instanceof E?u.re:u)}}let i=0;for(let s=0;s<n;s++)if(t.iget(s)){let c=a[i%a.length];B(o)?typeof c!="bigint"&&(c=BigInt(Math.round(Number(c)))):typeof c=="bigint"&&(c=Number(c)),r.iset(s,c),i++}}function cn(r,t,e){let n=t.shape,o=n.length,a=t.dtype,i=t.data,s=B(a);if(e===void 0){let b=0,A=Math.min(r.size,t.size);for(let x=0;x<A;x++)r.iget(x)&&b++;let S=j(a);if(!S)throw new Error(`Cannot compress with dtype ${a}`);let D=new S(b),w=0;for(let x=0;x<A;x++)r.iget(x)&&(D[w]=i[x],w++);return N.fromData(D,[b],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 c=n[u],l=Math.min(r.size,c),m=[];for(let b=0;b<l;b++)r.iget(b)&&m.push(b);let d=m.length,y=[...n];y[u]=d;let f=y.reduce((b,A)=>b*A,1),p=j(a);if(!p)throw new Error(`Cannot compress with dtype ${a}`);let g=new p(f),h=ur(n);if(u===0){let b=h[0],A=n.slice(1).reduce((D,w)=>D*w,1),S=0;for(let D=0;D<d;D++){let x=m[D]*b;if(s){let I=i,z=g;for(let F=0;F<A;F++)z[S++]=I[x+F]}else{let I=i,z=g;for(let F=0;F<A;F++)z[S++]=I[x+F]}}}else{let b=n.slice(0,u).reduce((D,w)=>D*w,1),A=n.slice(u+1).reduce((D,w)=>D*w,1),S=0;for(let D=0;D<b;D++)for(let w=0;w<d;w++){let x=m[w],I=0,z=D;for(let F=u-1;F>=0;F--){let v=z%n[F];z=Math.floor(z/n[F]),I+=v*h[F]}if(I+=x*h[u],s){let F=i,v=g;for(let T=0;T<A;T++)v[S++]=F[I+T]}else{let F=i,v=g;for(let T=0;T<A;T++)v[S++]=F[I+T]}}}return N.fromData(g,y,a)}function Ys(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(d=>Array.from(d.shape)),...t.map(d=>Array.from(d.shape))],o=Sr(n);if(o===null)throw new Error("condlist and choicelist arrays could not be broadcast together");let a=t[0].dtype,i=o.reduce((d,y)=>d*y,1),s=j(a);if(!s)throw new Error(`Cannot select with dtype ${a}`);let u=e;B(a)?u=typeof e=="bigint"?e:BigInt(e):u=typeof e=="bigint"?Number(e):e;let c=new s(i);for(let d=0;d<i;d++)B(a),c[d]=u;let l=r.map(d=>gr(d,o)),m=t.map(d=>gr(d,o));for(let d=0;d<i;d++)for(let y=0;y<r.length;y++)if(l[y].iget(d)){let f=m[y].iget(d);B(a),c[d]=f;break}return N.fromData(c,o,a)}function Hs(r,t,e){let n=r.size,o=r.dtype,a=[];for(let s=0;s<e.size;s++){let u=e.iget(s);a.push(u instanceof E?u.re:u)}if(a.length===0)return;let i=0;for(let s=0;s<n;s++)if(t.iget(s)){let c=a[i%a.length];B(o)?typeof c!="bigint"&&(c=BigInt(Math.round(Number(c)))):typeof c=="bigint"&&(c=Number(c)),r.iset(s,c),i++}}function ln(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(N.fromData(new Int32Array(e),[r],"int32"));return n}function Xs(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 ln(n,e)}function fn(r,t=0,e){let n=e??r,o=[],a=[];for(let i=0;i<r;i++)for(let s=0;s<=Math.min(i+t,n-1);s++)s>=0&&(o.push(i),a.push(s));return[N.fromData(new Int32Array(o),[o.length],"int32"),N.fromData(new Int32Array(a),[a.length],"int32")]}function Js(r,t=0){let e=r.shape;if(e.length!==2)throw new Error("array must be 2-D");return fn(e[0],t,e[1])}function mn(r,t=0,e){let n=e??r,o=[],a=[];for(let i=0;i<r;i++)for(let s=Math.max(i+t,0);s<n;s++)o.push(i),a.push(s);return[N.fromData(new Int32Array(o),[o.length],"int32"),N.fromData(new Int32Array(a),[a.length],"int32")]}function Qs(r,t=0){let e=r.shape;if(e.length!==2)throw new Error("array must be 2-D");return mn(e[0],t,e[1])}function Ks(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=[],i=[];for(let s=0;s<r;s++)for(let u=0;u<r;u++)n.get(s,u)&&(a.push(s),i.push(u));return[N.fromData(new Int32Array(a),[a.length],"int32"),N.fromData(new Int32Array(i),[i.length],"int32")]}function ri(r,t="int32"){let e=r.length,n=[e,...r],o=n.reduce((u,c)=>u*c,1),a=j(t);if(!a)throw new Error(`Cannot create indices with dtype ${t}`);let i=new a(o),s=r.reduce((u,c)=>u*c,1);for(let u=0;u<e;u++){let c=u*s;for(let l=0;l<s;l++){let m=new Array(e),d=l;for(let f=e-1;f>=0;f--)m[f]=d%r[f],d=Math.floor(d/r[f]);let y=m[u];t==="int64"?i[c+l]=BigInt(y):i[c+l]=y}}return N.fromData(i,n,t)}function ti(...r){let t=r.length,e=[];for(let n=0;n<t;n++){let o=r[n],a=o.size,i=o.dtype,s=new Array(t).fill(1);s[n]=a;let u=j(i);if(!u)throw new Error(`Cannot create ix_ with dtype ${i}`);let c=new u(a);for(let l=0;l<a;l++){let m=o.iget(l);B(i),c[l]=m}e.push(N.fromData(c,s,i))}return e}function ei(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),i=new Array(o),s=1;for(let u=o-1;u>=0;u--)i[u]=s,s*=t[u];for(let u=0;u<n;u++){let c=0;for(let l=0;l<o;l++){let m=Number(r[l].iget(u)),d=t[l];if(e==="wrap")m=(m%d+d)%d;else if(e==="clip")m=Math.max(0,Math.min(m,d-1));else if(m<0||m>=d)throw new Error(`index ${m} is out of bounds for axis ${l} with size ${d}`);c+=m*i[l]}a[u]=c}return N.fromData(a,[n],"int32")}function ni(r,t,e="C"){let n=t.length,o,a;if(typeof r=="number")o=[r],a=[];else{o=[];for(let l=0;l<r.size;l++)o.push(Number(r.iget(l)));a=Array.from(r.shape)}let i=o.length,s=t.reduce((l,m)=>l*m,1),u=new Array(n);if(e==="C"){let l=1;for(let m=n-1;m>=0;m--)u[m]=l,l*=t[m]}else{let l=1;for(let m=0;m<n;m++)u[m]=l,l*=t[m]}let c=[];for(let l=0;l<n;l++){let m=new Int32Array(i);c.push(N.fromData(m,a.length?a:[1],"int32"))}for(let l=0;l<i;l++){let m=o[l];if(m<0||m>=s)throw new Error(`index ${m} is out of bounds for array with size ${s}`);if(e==="C")for(let d=0;d<n;d++){let y=Math.floor(m/u[d]);m=m%u[d],c[d].data[l]=y%t[d]}else for(let d=n-1;d>=0;d--){let y=Math.floor(m/u[d]);m=m%u[d],c[d].data[l]=y%t[d]}}return typeof r=="number"?c.map(l=>{let m=l.iget(0);return N.fromData(new Int32Array([Number(m)]),[],"int32")}):c}function oi(r,t,e=!1){let n=r.shape,o=n.length;if(o<2)throw new Error("array must be at least 2-d");let a;if(o===2)a=n[1]+1;else{a=1;for(let c=1;c<o;c++){let l=1;for(let m=c;m<o;m++)l*=n[m];a+=l}}let i=r.data,s=r.size,u=Math.min(...n);if(e&&o===2&&(u=Math.max(n[0],n[1])),typeof t=="number")for(let c=0;c<u&&c*a<s;c++){let l=c*a;if(l<s)i[l]=t;else break}else{let c=t.data,l=t.size;for(let m=0;m<u&&m*a<s;m++){let d=m*a;if(d<s)i[d]=c[m%l];else break}}}function ai(r,t,e){let n=Array.from(r.shape),o=n.length;if(t<0&&(t+=o),t<0||t>=o)throw new Error(`axis ${t} is out of bounds for array of dimension ${o}`);let a=[];for(let i=0;i<o;i++)i!==t&&a.push(n[i]);if(a.length===0){let i=e(r);if(typeof i=="number"){let s=N.zeros([1],r.dtype);return s.data[0]=i,s}return i}if(o===2){let[i,s]=n;if(t===0){let u=[];for(let l=0;l<s;l++){let m=new Float64Array(i);for(let y=0;y<i;y++)m[y]=Number(r.data[y*s+l]);let d=N.fromData(m,[i],"float64");u.push(e(d))}let c=u[0];if(c===void 0)return N.zeros([0],"float64");if(typeof c=="number"){let l=N.zeros([s],"float64");for(let m=0;m<s;m++)l.data[m]=u[m];return l}else{let l=[c.size,s],m=N.zeros(l,"float64");for(let d=0;d<s;d++){let y=u[d];for(let f=0;f<y.size;f++)m.data[f*s+d]=Number(y.data[f])}return m}}else{let u=[];for(let l=0;l<i;l++){let m=new Float64Array(s);for(let y=0;y<s;y++)m[y]=Number(r.data[l*s+y]);let d=N.fromData(m,[s],"float64");u.push(e(d))}let c=u[0];if(c===void 0)return N.zeros([0],"float64");if(typeof c=="number"){let l=N.zeros([i],"float64");for(let m=0;m<i;m++)l.data[m]=u[m];return l}else{let l=[i,c.size],m=N.zeros(l,"float64");for(let d=0;d<i;d++){let y=u[d];for(let f=0;f<y.size;f++)m.data[d*y.size+f]=Number(y.data[f])}return m}}}if(o===1){let i=e(r);if(typeof i=="number"){let s=N.zeros([1],"float64");return s.data[0]=i,s}return i}throw new Error(`apply_along_axis not fully implemented for ${o}D arrays. Only 1D and 2D arrays are supported.`)}function si(r,t,e){let n=r,o=r.shape.length;for(let a of e){let i=a<0?a+o:a;if(i<0||i>=o)throw new Error(`axis ${a} is out of bounds for array of dimension ${o}`);if(n=t(n,i),n.shape.length<o){let s=Array.from(n.shape);s.splice(i,0,1);let u=ur(s);n=new N(n.data,s,u,0,n.dtype)}}return n}function pn(r,t){return r.data.buffer===t.data.buffer}function ii(r,t){return pn(r,t)}function Ht(){return{...Or}}function yn(r,t,e,n,o){let a=Ht();return r!==void 0&&(Or.divide=r,Or.over=r,Or.under=r,Or.invalid=r),t!==void 0&&(Or.divide=t),e!==void 0&&(Or.over=e),n!==void 0&&(Or.under=n),o!==void 0&&(Or.invalid=o),a}var Or,dn=G(()=>{"use strict";K();Q();Rt();xr();Or={divide:"warn",over:"warn",under:"ignore",invalid:"warn"}});function br(r,t){if(!xo(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 xt(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function li(r,t){return br(r.dtype,"bitwise_and"),typeof t=="number"?Gd(r,t):(br(t.dtype,"bitwise_and"),xt(r,t)?Wd(r,t):X(r,t,(e,n)=>e&n,"bitwise_and"))}function Wd(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(B(e)){let u=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),d=typeof i[l]=="bigint"?i[l]:BigInt(Math.round(Number(i[l])));u[l]=m&d}else{let l=a,m=i;for(let d=0;d<o;d++)u[d]=l[d]&m[d]}}else for(let u=0;u<o;u++)s[u]=a[u]&i[u];return n}function Gd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]&l}else for(let u=0;u<a;u++)s[u]=o[u]&t;return i}function fi(r,t){return br(r.dtype,"bitwise_or"),typeof t=="number"?Yd(r,t):(br(t.dtype,"bitwise_or"),xt(r,t)?Zd(r,t):X(r,t,(e,n)=>e|n,"bitwise_or"))}function Zd(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(B(e)){let u=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),d=typeof i[l]=="bigint"?i[l]:BigInt(Math.round(Number(i[l])));u[l]=m|d}else{let l=a,m=i;for(let d=0;d<o;d++)u[d]=l[d]|m[d]}}else for(let u=0;u<o;u++)s[u]=a[u]|i[u];return n}function Yd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]|l}else for(let u=0;u<a;u++)s[u]=o[u]|t;return i}function mi(r,t){return br(r.dtype,"bitwise_xor"),typeof t=="number"?Xd(r,t):(br(t.dtype,"bitwise_xor"),xt(r,t)?Hd(r,t):X(r,t,(e,n)=>e^n,"bitwise_xor"))}function Hd(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(B(e)){let u=s;if(!B(r.dtype)||!B(t.dtype))for(let l=0;l<o;l++){let m=typeof a[l]=="bigint"?a[l]:BigInt(Math.round(Number(a[l]))),d=typeof i[l]=="bigint"?i[l]:BigInt(Math.round(Number(i[l])));u[l]=m^d}else{let l=a,m=i;for(let d=0;d<o;d++)u[d]=l[d]^m[d]}}else for(let u=0;u<o;u++)s[u]=a[u]^i[u];return n}function Xd(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]^l}else for(let u=0;u<a;u++)s[u]=o[u]^t;return i}function Jt(r){br(r.dtype,"bitwise_not");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=N.zeros(e,t),i=a.data;if(B(t)){let s=n,u=i;for(let c=0;c<o;c++)u[c]=~s[c]}else for(let s=0;s<o;s++)i[s]=~n[s];return a}function pi(r){return Jt(r)}function gn(r,t){if(br(r.dtype,"left_shift"),typeof t=="number")return ui(r,t);if(br(t.dtype,"left_shift"),t.size===1||t.ndim===1&&t.shape[0]===1){let e=B(t.dtype)?Number(t.data[0]):t.data[0];return ui(r,e)}return xt(r,t)?Jd(r,t):X(r,t,(e,n)=>e<<n,"left_shift")}function Jd(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(B(e)){let u=s;for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?a[c]:BigInt(Math.round(Number(a[c]))),m=typeof i[c]=="bigint"?i[c]:BigInt(Math.round(Number(i[c])));u[c]=l<<m}}else for(let u=0;u<o;u++)s[u]=a[u]<<i[u];return n}function ui(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]<<l}else for(let u=0;u<a;u++)s[u]=o[u]<<t;return i}function An(r,t){if(br(r.dtype,"right_shift"),typeof t=="number")return ci(r,t);if(br(t.dtype,"right_shift"),t.size===1||t.ndim===1&&t.shape[0]===1){let e=B(t.dtype)?Number(t.data[0]):t.data[0];return ci(r,e)}return xt(r,t)?Qd(r,t):X(r,t,(e,n)=>e>>n,"right_shift")}function Qd(r,t){let e=Z(r.dtype,t.dtype),n=N.zeros(Array.from(r.shape),e),o=r.size,a=r.data,i=t.data,s=n.data;if(B(e)){let u=s;for(let c=0;c<o;c++){let l=typeof a[c]=="bigint"?a[c]:BigInt(Math.round(Number(a[c]))),m=typeof i[c]=="bigint"?i[c]:BigInt(Math.round(Number(i[c])));u[c]=l>>m}}else for(let u=0;u<o;u++)s[u]=a[u]>>i[u];return n}function ci(r,t){let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=N.zeros(n,e),s=i.data;if(B(e)){let u=o,c=s,l=BigInt(Math.round(t));for(let m=0;m<a;m++)c[m]=u[m]>>l}else for(let u=0;u<a;u++)s[u]=o[u]>>t;return i}function yi(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],i=Math.ceil(a/8),s=[...n];s[t]=i;let u=N.zeros(s,"uint8"),c=u.data;if(o===1){for(let g=0;g<i;g++){let h=0;for(let b=0;b<8;b++){let A=g*8+b;if(A<a){let S=Number(r.data[A])!==0?1:0;e==="big"?h|=S<<7-b:h|=S<<b}}c[g]=h}return u}let l=n.slice(0,t),m=n.slice(t+1),d=l.reduce((g,h)=>g*h,1),y=m.reduce((g,h)=>g*h,1),f=Xt(n),p=Xt(s);for(let g=0;g<d;g++)for(let h=0;h<y;h++)for(let b=0;b<i;b++){let A=0;for(let x=0;x<8;x++){let I=b*8+x;if(I<a){let z=0,F=g;for(let O=0;O<t;O++){let C=O<t-1?l.slice(O+1).reduce((V,k)=>V*k,1):1,q=Math.floor(F/C);F%=C,z+=q*f[O]}z+=I*f[t];let v=h;for(let O=t+1;O<o;O++){let C=O<o-1?m.slice(O-t).reduce((V,k)=>V*k,1):1,q=Math.floor(v/C);v%=C,z+=q*f[O]}let T=Number(r.data[z])!==0?1:0;e==="big"?A|=T<<7-x:A|=T<<x}}let S=0,D=g;for(let x=0;x<t;x++){let I=x<t-1?l.slice(x+1).reduce((F,v)=>F*v,1):1,z=Math.floor(D/I);D%=I,S+=z*p[x]}S+=b*p[t];let w=h;for(let x=t+1;x<o;x++){let I=x<o-1?m.slice(x-t).reduce((F,v)=>F*v,1):1,z=Math.floor(w/I);w%=I,S+=z*p[x]}c[S]=A}return u}function di(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 i=o[t],s=i*8;e>=0&&(s=e);let u=[...o];u[t]=s;let c=N.zeros(u,"uint8"),l=c.data;if(a===1){for(let h=0;h<i;h++){let b=Number(r.data[h]);for(let A=0;A<8;A++){let S=h*8+A;if(S>=s)break;n==="big"?l[S]=b>>7-A&1:l[S]=b>>A&1}}return c}let m=o.slice(0,t),d=o.slice(t+1),y=m.reduce((h,b)=>h*b,1),f=d.reduce((h,b)=>h*b,1),p=Xt(o),g=Xt(u);for(let h=0;h<y;h++)for(let b=0;b<f;b++)for(let A=0;A<i;A++){let S=0,D=h;for(let I=0;I<t;I++){let z=I<t-1?m.slice(I+1).reduce((v,T)=>v*T,1):1,F=Math.floor(D/z);D%=z,S+=F*p[I]}S+=A*p[t];let w=b;for(let I=t+1;I<a;I++){let z=I<a-1?d.slice(I-t).reduce((v,T)=>v*T,1):1,F=Math.floor(w/z);w%=z,S+=F*p[I]}let x=Number(r.data[S]);for(let I=0;I<8;I++){let z=A*8+I;if(z>=s)break;let F=0;D=h;for(let v=0;v<t;v++){let T=v<t-1?m.slice(v+1).reduce((C,q)=>C*q,1):1,O=Math.floor(D/T);D%=T,F+=O*g[v]}F+=z*g[t],w=b;for(let v=t+1;v<a;v++){let T=v<a-1?d.slice(v-t).reduce((C,q)=>C*q,1):1,O=Math.floor(w/T);w%=T,F+=O*g[v]}n==="big"?l[F]=x>>7-I&1:l[F]=x>>I&1}}return c}function Xt(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}function gi(r){let t=r.dtype;br(t,"bitwise_count");let e=Array.from(r.shape),n=r.data,o=r.size,a=N.zeros(e,"uint8"),i=a.data;if(B(t)){let s=n;for(let u=0;u<o;u++)i[u]=rg(s[u])}else for(let s=0;s<o;s++){let u=n[s];i[s]=Kd(u)}return a}function Kd(r){r=r>>>0;let t=0;for(;r!==0;)r=r&r-1,t++;return t}function rg(r){r<0n&&(r=BigInt.asUintN(64,r));let t=0;for(;r!==0n;)r=r&r-1n,t++;return t}function Ai(r){return Jt(r)}function bi(r,t){return gn(r,t)}function hi(r,t){return An(r,t)}var Si=G(()=>{"use strict";K();Q();Er()});function at(r){return r!==0&&r!==0n}function Ir(r,t){let e=r[t*2],n=r[t*2+1];return e!==0||n!==0}function It(r,t){return r.isCContiguous&&t.isCContiguous&&r.shape.length===t.shape.length&&r.shape.every((e,n)=>e===t.shape[n])}function Ni(r,t){return typeof t=="number"?ng(r,t):It(r,t)?eg(r,t):Ar(r,t,(e,n)=>at(e)&&at(n))}function eg(r,t){let e=new Uint8Array(r.size),n=r.data,o=t.data,a=r.size,i=B(r.dtype),s=B(t.dtype),u=M(r.dtype),c=M(t.dtype);if(u||c)for(let l=0;l<a;l++){let m=u?Ir(n,l):n[l]!==0,d=c?Ir(o,l):o[l]!==0;e[l]=m&&d?1:0}else if(i||s)for(let l=0;l<a;l++){let m=i?n[l]!==0n:n[l]!==0,d=s?o[l]!==0n:o[l]!==0;e[l]=m&&d?1:0}else for(let l=0;l<a;l++)e[l]=n[l]!==0&&o[l]!==0?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function ng(r,t){let e=new Uint8Array(r.size),n=r.data,o=t!==0,a=r.size;if(M(r.dtype)){let i=n;for(let s=0;s<a;s++)e[s]=Ir(i,s)&&o?1:0}else if(B(r.dtype)){let i=n;for(let s=0;s<a;s++)e[s]=i[s]!==0n&&o?1:0}else for(let i=0;i<a;i++)e[i]=n[i]!==0&&o?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function xi(r,t){return typeof t=="number"?ag(r,t):It(r,t)?og(r,t):Ar(r,t,(e,n)=>at(e)||at(n))}function og(r,t){let e=new Uint8Array(r.size),n=r.data,o=t.data,a=r.size,i=B(r.dtype),s=B(t.dtype),u=M(r.dtype),c=M(t.dtype);if(u||c)for(let l=0;l<a;l++){let m=u?Ir(n,l):n[l]!==0,d=c?Ir(o,l):o[l]!==0;e[l]=m||d?1:0}else if(i||s)for(let l=0;l<a;l++){let m=i?n[l]!==0n:n[l]!==0,d=s?o[l]!==0n:o[l]!==0;e[l]=m||d?1:0}else for(let l=0;l<a;l++)e[l]=n[l]!==0||o[l]!==0?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function ag(r,t){let e=new Uint8Array(r.size),n=r.data,o=t!==0,a=r.size;if(M(r.dtype)){let i=n;for(let s=0;s<a;s++)e[s]=Ir(i,s)||o?1:0}else if(B(r.dtype)){let i=n;for(let s=0;s<a;s++)e[s]=i[s]!==0n||o?1:0}else for(let i=0;i<a;i++)e[i]=n[i]!==0||o?1:0;return N.fromData(e,Array.from(r.shape),"bool")}function wi(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++)t[a]=Ir(o,a)?0:1}else if(B(r.dtype)){let o=e;for(let a=0;a<n;a++)t[a]=o[a]===0n?1:0}else for(let o=0;o<n;o++)t[o]=e[o]===0?1:0;return N.fromData(t,Array.from(r.shape),"bool")}function Ii(r,t){return typeof t=="number"?ig(r,t):It(r,t)?sg(r,t):Ar(r,t,(e,n)=>at(e)!==at(n))}function sg(r,t){let e=new Uint8Array(r.size),n=r.data,o=t.data,a=r.size,i=B(r.dtype),s=B(t.dtype),u=M(r.dtype),c=M(t.dtype);if(u||c)for(let l=0;l<a;l++){let m=u?Ir(n,l):n[l]!==0,d=c?Ir(o,l):o[l]!==0;e[l]=m!==d?1:0}else if(i||s)for(let l=0;l<a;l++){let m=i?n[l]!==0n:n[l]!==0,d=s?o[l]!==0n:o[l]!==0;e[l]=m!==d?1:0}else for(let l=0;l<a;l++){let m=n[l]!==0,d=o[l]!==0;e[l]=m!==d?1:0}return N.fromData(e,Array.from(r.shape),"bool")}function ig(r,t){let e=new Uint8Array(r.size),n=r.data,o=t!==0,a=r.size;if(M(r.dtype)){let i=n;for(let s=0;s<a;s++){let u=Ir(i,s);e[s]=u!==o?1:0}}else if(B(r.dtype)){let i=n;for(let s=0;s<a;s++){let u=i[s]!==0n;e[s]=u!==o?1:0}}else for(let i=0;i<a;i++){let s=n[i]!==0;e[i]=s!==o?1:0}return N.fromData(e,Array.from(r.shape),"bool")}function zi(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++){let i=o[a*2],s=o[a*2+1];t[a]=Number.isFinite(i)&&Number.isFinite(s)?1:0}}else if(B(r.dtype))for(let o=0;o<n;o++)t[o]=1;else for(let o=0;o<n;o++){let a=e[o];t[o]=Number.isFinite(a)?1:0}return N.fromData(t,Array.from(r.shape),"bool")}function _i(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++){let i=o[a*2],s=o[a*2+1],u=!Number.isFinite(i)&&!Number.isNaN(i),c=!Number.isFinite(s)&&!Number.isNaN(s);t[a]=u||c?1:0}}else if(B(r.dtype))for(let o=0;o<n;o++)t[o]=0;else for(let o=0;o<n;o++){let a=e[o];t[o]=!Number.isFinite(a)&&!Number.isNaN(a)?1:0}return N.fromData(t,Array.from(r.shape),"bool")}function vi(r){let t=new Uint8Array(r.size),e=r.data,n=r.size;if(M(r.dtype)){let o=e;for(let a=0;a<n;a++){let i=o[a*2],s=o[a*2+1];t[a]=Number.isNaN(i)||Number.isNaN(s)?1:0}}else if(B(r.dtype))for(let o=0;o<n;o++)t[o]=0;else for(let o=0;o<n;o++)t[o]=Number.isNaN(e[o])?1:0;return N.fromData(t,Array.from(r.shape),"bool")}function Fi(r){let t=new Uint8Array(r.size);return N.fromData(t,Array.from(r.shape),"bool")}function Mi(r,t){if(U(r.dtype,"copysign","copysign is only defined for real numbers."),typeof t!="number"&&U(t.dtype,"copysign","copysign is only defined for real numbers."),typeof t=="number")return cg(r,t);if(It(r,t))return ug(r,t);let e=Ur(r.shape,t.shape),n=e.reduce((u,c)=>u*c,1),o=N.zeros(e,"float64"),a=o.data,i=Qt(r,e),s=Qt(t,e);for(let u=0;u<n;u++){let c=Number(i.iget(u)),l=Number(s.iget(u));a[u]=Math.sign(l)*Math.abs(c)}return o}function ug(r,t){let e=N.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.size,a=r.data,i=t.data,s=B(r.dtype),u=B(t.dtype);for(let c=0;c<o;c++){let l=s?Number(a[c]):a[c],m=u?Number(i[c]):i[c];n[c]=Math.sign(m)*Math.abs(l)}return e}function cg(r,t){let e=N.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.data,a=r.size,i=Math.sign(t);if(B(r.dtype)){let s=o;for(let u=0;u<a;u++)n[u]=i*Math.abs(Number(s[u]))}else for(let s=0;s<a;s++)n[s]=i*Math.abs(o[s]);return e}function Bi(r){U(r.dtype,"signbit","signbit is only defined for real numbers.");let t=new Uint8Array(r.size),e=r.data,n=r.size;if(B(r.dtype)){let o=e;for(let a=0;a<n;a++)t[a]=o[a]<0n?1:0}else for(let o=0;o<n;o++){let a=e[o];t[o]=a<0||Object.is(a,-0)?1:0}return N.fromData(t,Array.from(r.shape),"bool")}function Ei(r,t){if(U(r.dtype,"nextafter","nextafter is only defined for real numbers."),typeof t!="number"&&U(t.dtype,"nextafter","nextafter is only defined for real numbers."),typeof t=="number")return fg(r,t);if(It(r,t))return lg(r,t);let e=Ur(r.shape,t.shape),n=e.reduce((u,c)=>u*c,1),o=N.zeros(e,"float64"),a=o.data,i=Qt(r,e),s=Qt(t,e);for(let u=0;u<n;u++){let c=Number(i.iget(u)),l=Number(s.iget(u));a[u]=wt(c,l)}return o}function lg(r,t){let e=N.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.size,a=r.data,i=t.data,s=B(r.dtype),u=B(t.dtype);for(let c=0;c<o;c++){let l=s?Number(a[c]):a[c],m=u?Number(i[c]):i[c];n[c]=wt(l,m)}return e}function fg(r,t){let e=N.zeros(Array.from(r.shape),"float64"),n=e.data,o=r.data,a=r.size;if(B(r.dtype)){let i=o;for(let s=0;s<a;s++)n[s]=wt(Number(i[s]),t)}else for(let i=0;i<a;i++)n[i]=wt(o[i],t);return e}function wt(r,t){if(Number.isNaN(r)||Number.isNaN(t))return NaN;if(r===t)return t;if(r===0)return t>0?Number.MIN_VALUE:-Number.MIN_VALUE;let e=new ArrayBuffer(8),n=new Float64Array(e),o=new BigInt64Array(e);n[0]=r;let a=o[0];return r>0&&t>r||r<0&&t>r?a=a+1n:a=a-1n,o[0]=a,n[0]}function Ti(r){U(r.dtype,"spacing","spacing is only defined for real numbers.");let t=N.zeros(Array.from(r.shape),"float64"),e=t.data,n=r.data,o=r.size;if(B(r.dtype)){let a=n;for(let i=0;i<o;i++)e[i]=Di(Number(a[i]))}else for(let a=0;a<o;a++)e[a]=Di(n[a]);return t}function Di(r){if(Number.isNaN(r))return NaN;if(!Number.isFinite(r))return NaN;if(Math.abs(r)===0)return Number.MIN_VALUE;let e=wt(r,1/0);return Math.abs(e-r)}function Qt(r,t){let e=r.shape.length,n=t.length,o=new Array(n).fill(0);for(let a=0;a<e;a++){let i=n-e+a,s=r.shape[a],u=t[i];if(s===u)o[i]=r.strides[a];else if(s===1)o[i]=0;else throw new Error("Invalid broadcast")}return N.fromData(r.data,Array.from(t),r.dtype,o,r.offset)}function Oi(r){let t=r.dtype,e=r.size,n=new Uint8Array(e);if(M(t)){let o=r.data;for(let a=0;a<e;a++)n[a]=o[a*2+1]!==0?1:0}return N.fromData(n,Array.from(r.shape),"bool")}function Ci(r){return M(r.dtype)}function Ui(r){let t=r.dtype,e=r.size,n=new Uint8Array(e);if(M(t)){let o=r.data;for(let a=0;a<e;a++)n[a]=o[a*2+1]===0?1:0}else n.fill(1);return N.fromData(n,Array.from(r.shape),"bool")}function $i(r){return!M(r.dtype)}function Ri(r){U(r.dtype,"isneginf","This operation is not supported for complex values because it would be ambiguous.");let t=new Uint8Array(r.size),e=r.data,n=r.size;if(!B(r.dtype))for(let o=0;o<n;o++){let a=e[o];t[o]=a===-1/0?1:0}return N.fromData(t,Array.from(r.shape),"bool")}function ki(r){U(r.dtype,"isposinf","This operation is not supported for complex values because it would be ambiguous.");let t=new Uint8Array(r.size),e=r.data,n=r.size;if(!B(r.dtype))for(let o=0;o<n;o++){let a=e[o];t[o]=a===1/0?1:0}return N.fromData(t,Array.from(r.shape),"bool")}function qi(r){return r.isFContiguous}function Vi(r,t=100){let e=r.dtype;if(M(e)){let n=r.data,o=r.size,i=t*(e==="complex64"?11920929e-14:2220446049250313e-31),s=!0;for(let u=0;u<o;u++){let c=n[u*2+1];if(Math.abs(c)>i){s=!1;break}}if(s){let u=e==="complex64"?"float32":"float64",c=N.zeros(Array.from(r.shape),u),l=c.data;for(let m=0;m<o;m++)l[m]=n[m*2];return c}return r.copy()}return r.copy()}function Pi(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="boolean"||typeof r=="string"}function ji(r){return r==null?!1:typeof r[Symbol.iterator]=="function"}function Li(r,t){let n={b:["bool"],i:["int8","int16","int32","int64"],u:["uint8","uint16","uint32","uint64"],f:["float32","float64"]}[t];return n?n.includes(r):!1}function Wi(r,t){let e=["float64","float32","int64","int32","int16","int8","uint64","uint32","uint16","uint8","bool"],n=e.indexOf(r),o=e.indexOf(t);return n<=o?r:t}var Gi=G(()=>{"use strict";K();Q();Er();Er()});function Zi(r){let t=r.dtype,e=Array.from(r.shape),n=r.size;if(M(t)){let o=lt(t),a=N.zeros(e,o),i=a.data,s=r.data;for(let u=0;u<n;u++)i[u]=s[u*2];return a}return r.copy()}function Yi(r){let t=r.dtype,e=Array.from(r.shape),n=r.size;if(M(t)){let a=lt(t),i=N.zeros(e,a),s=i.data,u=r.data;for(let c=0;c<n;c++)s[c]=u[c*2+1];return i}let o=t==="float32"?"float32":"float64";return N.zeros(e,o)}function Hi(r){let t=r.dtype,e=Array.from(r.shape),n=r.size;if(M(t)){let o=j(t),a=n*2,i=new o(a),s=r.data;for(let u=0;u<n;u++)i[u*2]=s[u*2],i[u*2+1]=-s[u*2+1];return N.fromData(i,e,t)}return r.copy()}function Xi(r,t=!1){let e=r.dtype,n=Array.from(r.shape),o=r.size,a=N.zeros(n,"float64"),i=a.data;if(M(e)){let s=r.data;for(let u=0;u<o;u++){let c=s[u*2],l=s[u*2+1],m=Math.atan2(l,c);t&&(m=m*180/Math.PI),i[u]=m}}else for(let s=0;s<o;s++){let u=r.iget(s),l=(u instanceof E?u.re:Number(u))>=0?0:Math.PI;t&&(l=l*180/Math.PI),i[s]=l}return a}var Ji=G(()=>{"use strict";K();Q();xr()});function zr(r,t,e){if(e){let n=r[t*2],o=r[t*2+1];return n!==0||o!==0}return!!r[t]}function zt(r,t,e,n){let o=isNaN(r)||isNaN(t),a=isNaN(e)||isNaN(n);return o&&a?0:o?1:a||r<e?-1:r>e?1:t<n?-1:t>n?1:0}function bn(r,t=-1){let e=r.shape,n=e.length,o=r.dtype,a=r.data;if(n===0)return r.copy();let i=t;if(i<0&&(i=n+i),i<0||i>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let s=r.copy(),u=s.data,c=e[i],l=Array.from(e).filter((d,y)=>y!==i),m=l.length===0?1:l.reduce((d,y)=>d*y,1);if(M(o)){let d=a,y=u;for(let f=0;f<m;f++){let p=[];for(let g=0;g<c;g++){let h=R(f,i,g,e),b=$(h,e);p.push({re:d[b*2],im:d[b*2+1],idx:g})}p.sort((g,h)=>zt(g.re,g.im,h.re,h.im));for(let g=0;g<c;g++){let h=R(f,i,g,e),b=$(h,e);y[b*2]=p[g].re,y[b*2+1]=p[g].im}}}else if(B(o)){let d=a,y=u;for(let f=0;f<m;f++){let p=[];for(let g=0;g<c;g++){let h=R(f,i,g,e),b=$(h,e);p.push({value:d[b],idx:g})}p.sort((g,h)=>g.value<h.value?-1:g.value>h.value?1:0);for(let g=0;g<c;g++){let h=R(f,i,g,e),b=$(h,e);y[b]=p[g].value}}}else for(let d=0;d<m;d++){let y=[];for(let f=0;f<c;f++){let p=R(d,i,f,e),g=$(p,e);y.push(Number(a[g]))}y.sort((f,p)=>isNaN(f)&&isNaN(p)?0:isNaN(f)?1:isNaN(p)?-1:f-p);for(let f=0;f<c;f++){let p=R(d,i,f,e),g=$(p,e);u[g]=y[f]}}return s}function hn(r,t=-1){let e=r.shape,n=e.length,o=r.dtype,a=r.data;if(n===0)return N.zeros([0],"int32");let i=t;if(i<0&&(i=n+i),i<0||i>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let s=N.zeros(Array.from(e),"int32"),u=s.data,c=e[i],l=Array.from(e).filter((d,y)=>y!==i),m=l.length===0?1:l.reduce((d,y)=>d*y,1);if(M(o)){let d=a;for(let y=0;y<m;y++){let f=[];for(let p=0;p<c;p++){let g=R(y,i,p,e),h=$(g,e);f.push({re:d[h*2],im:d[h*2+1],idx:p})}f.sort((p,g)=>zt(p.re,p.im,g.re,g.im));for(let p=0;p<c;p++){let g=R(y,i,p,e),h=$(g,e);u[h]=f[p].idx}}}else if(B(o)){let d=a;for(let y=0;y<m;y++){let f=[];for(let p=0;p<c;p++){let g=R(y,i,p,e),h=$(g,e);f.push({value:d[h],idx:p})}f.sort((p,g)=>p.value<g.value?-1:p.value>g.value?1:0);for(let p=0;p<c;p++){let g=R(y,i,p,e),h=$(g,e);u[h]=f[p].idx}}}else for(let d=0;d<m;d++){let y=[];for(let f=0;f<c;f++){let p=R(d,i,f,e),g=$(p,e);y.push({value:Number(a[g]),idx:f})}y.sort((f,p)=>isNaN(f.value)&&isNaN(p.value)?0:isNaN(f.value)?1:isNaN(p.value)?-1:f.value-p.value);for(let f=0;f<c;f++){let p=R(d,i,f,e),g=$(p,e);u[g]=y[f].idx}}return s}function Qi(r){if(r.length===0)return N.zeros([0],"int32");let e=r[0].size;for(let i of r){if(i.ndim!==1)throw new Error("keys must be 1D arrays");if(i.size!==e)throw new Error("all keys must have the same length")}let n=[];for(let i=0;i<e;i++)n.push(i);n.sort((i,s)=>{for(let u=r.length-1;u>=0;u--){let l=r[u].data,m=Number(l[i]),d=Number(l[s]);if(!(isNaN(m)&&isNaN(d))){if(isNaN(m))return 1;if(isNaN(d)||m<d)return-1;if(m>d)return 1}}return 0});let o=N.zeros([e],"int32"),a=o.data;for(let i=0;i<e;i++)a[i]=n[i];return o}function yg(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e],i=r[o],s=r[n],u;a<=i&&i<=s||s<=i&&i<=a?u=o:i<=a&&a<=s||s<=a&&a<=i?u=e:u=n;let c=r[u];[r[u],r[n]]=[r[n],r[u]];let l=e;for(let m=e;m<n;m++){let d=r[m],y=isNaN(d),f=isNaN(c);!y&&(f||d<=c)&&([r[l],r[m]]=[r[m],r[l]],l++)}if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function dg(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e],i=r[o],s=r[n],u;a<=i&&i<=s||s<=i&&i<=a?u=o:i<=a&&a<=s||s<=a&&a<=i?u=e:u=n;let c=r[u];[r[u],r[n]]=[r[n],r[u]];let l=e;for(let m=e;m<n;m++)r[m]<=c&&([r[l],r[m]]=[r[m],r[l]],l++);if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function gg(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e].value,i=r[o].value,s=r[n].value,u;a<=i&&i<=s||s<=i&&i<=a?u=o:i<=a&&a<=s||s<=a&&a<=i?u=e:u=n;let c=r[u].value;[r[u],r[n]]=[r[n],r[u]];let l=e;for(let m=e;m<n;m++){let d=r[m].value,y=isNaN(d),f=isNaN(c);!y&&(f||d<=c)&&([r[l],r[m]]=[r[m],r[l]],l++)}if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function Ag(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.floor((e+n)/2),a=r[e].value,i=r[o].value,s=r[n].value,u;a<=i&&i<=s||s<=i&&i<=a?u=o:i<=a&&a<=s||s<=a&&a<=i?u=e:u=n;let c=r[u].value;[r[u],r[n]]=[r[n],r[u]];let l=e;for(let m=e;m<n;m++)r[m].value<=c&&([r[l],r[m]]=[r[m],r[l]],l++);if([r[l],r[n]]=[r[n],r[l]],l===t)return;l<t?e=l+1:n=l-1}}function Sn(r,t,e=-1){let n=r.shape,o=n.length,a=r.dtype;if(o===0)return r.copy();let i=e;if(i<0&&(i=o+i),i<0||i>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let s=n[i],u=t;if(u<0&&(u=s+u),u<0||u>=s)throw new Error(`kth(=${t}) out of bounds (${s})`);let c=r.copy(),l=c.data,m=Array.from(n).filter((y,f)=>f!==i),d=m.length===0?1:m.reduce((y,f)=>y*f,1);if(B(a)){let y=l;for(let f=0;f<d;f++){let p=[];for(let g=0;g<s;g++){let h=R(f,i,g,n),b=$(h,n);p.push(y[b])}dg(p,u);for(let g=0;g<s;g++){let h=R(f,i,g,n),b=$(h,n);y[b]=p[g]}}}else for(let y=0;y<d;y++){let f=[];for(let p=0;p<s;p++){let g=R(y,i,p,n),h=$(g,n);f.push(Number(l[h]))}yg(f,u);for(let p=0;p<s;p++){let g=R(y,i,p,n),h=$(g,n);l[h]=f[p]}}return c}function Dn(r,t,e=-1){let n=r.shape,o=n.length,a=r.dtype,i=r.data;if(o===0)return N.zeros([0],"int32");let s=e;if(s<0&&(s=o+s),s<0||s>=o)throw new Error(`axis ${e} is out of bounds for array of dimension ${o}`);let u=n[s],c=t;if(c<0&&(c=u+c),c<0||c>=u)throw new Error(`kth(=${t}) out of bounds (${u})`);let l=N.zeros(Array.from(n),"int32"),m=l.data,d=Array.from(n).filter((f,p)=>p!==s),y=d.length===0?1:d.reduce((f,p)=>f*p,1);if(B(a)){let f=i;for(let p=0;p<y;p++){let g=[];for(let h=0;h<u;h++){let b=R(p,s,h,n),A=$(b,n);g.push({value:f[A],idx:h})}Ag(g,c);for(let h=0;h<u;h++){let b=R(p,s,h,n),A=$(b,n);m[A]=g[h].idx}}}else for(let f=0;f<y;f++){let p=[];for(let g=0;g<u;g++){let h=R(f,s,g,n),b=$(h,n);p.push({value:Number(i[b]),idx:g})}gg(p,c);for(let g=0;g<u;g++){let h=R(f,s,g,n),b=$(h,n);m[b]=p[g].idx}}return l}function Ki(r){let t=r.dtype,e=r.size,n=r.data;if(M(t)){let o=n,a=[];for(let u=0;u<e;u++)a.push({re:o[u*2],im:o[u*2+1]});a.sort((u,c)=>zt(u.re,u.im,c.re,c.im));let i=N.zeros([e],"complex128"),s=i.data;for(let u=0;u<e;u++)s[u*2]=a[u].re,s[u*2+1]=a[u].im;return i}else{let o=[];for(let s=0;s<e;s++)o.push(Number(n[s]));o.sort((s,u)=>isNaN(s)&&isNaN(u)?0:isNaN(s)?1:isNaN(u)?-1:s-u);let a=N.zeros([e],"complex128"),i=a.data;for(let s=0;s<e;s++)i[s*2]=o[s],i[s*2+1]=0;return a}}function Kt(r){let t=r.shape,e=t.length,n=r.data,o=r.size,a=M(r.dtype),i=[];for(let m=0;m<e;m++)i.push([]);let s=[],u=1;for(let m=e-1;m>=0;m--)s.unshift(u),u*=t[m];for(let m=0;m<o;m++)if(zr(n,m,a)){let d=m;for(let y=0;y<e;y++){let f=Math.floor(d/s[y]);d=d%s[y],i[y].push(f)}}let c=i[0]?.length??0,l=[];for(let m=0;m<e;m++){let d=N.zeros([c],"int32"),y=d.data;for(let f=0;f<c;f++)y[f]=i[m][f];l.push(d)}return l}function Nn(r){let t=r.shape,e=t.length,n=r.data,o=r.size,a=M(r.dtype),i=[],s=[],u=1;for(let y=e-1;y>=0;y--)s.unshift(u),u*=t[y];for(let y=0;y<o;y++)if(zr(n,y,a)){let f=[],p=y;for(let g=0;g<e;g++){let h=Math.floor(p/s[g]);p=p%s[g],f.push(h)}i.push(f)}let c=i.length,l=e===0?[c,1]:[c,e],m=N.zeros(l,"int32"),d=m.data;for(let y=0;y<c;y++){let f=i[y];for(let p=0;p<(e===0?1:e);p++)d[y*(e===0?1:e)+p]=f[p]??0}return m}function ru(r){let t=r.data,e=r.size,n=M(r.dtype),o=[];for(let s=0;s<e;s++)zr(t,s,n)&&o.push(s);let a=N.zeros([o.length],"int32"),i=a.data;for(let s=0;s<o.length;s++)i[s]=o[s];return a}function tu(r,t,e){if(t===void 0&&e===void 0)return Kt(r);if(t===void 0||e===void 0)throw new Error("either both or neither of x and y should be given");let n=r.shape,o=t.shape,a=e.shape,i=Math.max(n.length,o.length,a.length),s=v=>{let T=Array(i).fill(1);for(let O=0;O<v.length;O++)T[i-v.length+O]=v[O];return T},u=s(n),c=s(o),l=s(a),m=[];for(let v=0;v<i;v++){let T=[u[v],c[v],l[v]],O=Math.max(...T);for(let C of T)if(C!==1&&C!==O)throw new Error("operands could not be broadcast together");m.push(O)}let d=t.dtype,y=N.zeros(m,d),f=y.data,p=r.data,g=t.data,h=e.data,b=(v,T)=>{let O=[],C=1;for(let q=v.length-1;q>=0;q--)O.unshift(C),C*=v[q];for(;O.length<T.length;)O.unshift(0);for(let q=0;q<T.length;q++)T[q]===1&&m[q]!==1&&(O[q]=0);return O},A=b(n,u),S=b(o,c),D=b(a,l),w=[],x=1;for(let v=m.length-1;v>=0;v--)w.unshift(x),x*=m[v];let I=m.reduce((v,T)=>v*T,1),z=M(r.dtype),F=M(d);for(let v=0;v<I;v++){let T=v,O=0,C=0,q=0;for(let V=0;V<i;V++){let k=Math.floor(T/w[V]);T=T%w[V],O+=k*A[V],C+=k*S[V],q+=k*D[V]}zr(p,O,z)?F?(f[v*2]=g[C*2],f[v*2+1]=g[C*2+1]):f[v]=g[C]:F?(f[v*2]=h[q*2],f[v*2+1]=h[q*2+1]):f[v]=h[q]}return y}function xn(r,t,e="left"){if(r.ndim!==1)throw new Error("storage must be 1D");let n=r.data,o=r.size,a=t.data,i=t.size,s=M(r.dtype),u=N.zeros([i],"int32"),c=u.data;if(s){let l=n,m=a;for(let d=0;d<i;d++){let y=m[d*2],f=m[d*2+1],p=0,g=o;if(e==="left")for(;p<g;){let h=Math.floor((p+g)/2),b=l[h*2],A=l[h*2+1];zt(b,A,y,f)<0?p=h+1:g=h}else for(;p<g;){let h=Math.floor((p+g)/2),b=l[h*2],A=l[h*2+1];zt(b,A,y,f)<=0?p=h+1:g=h}c[d]=p}}else for(let l=0;l<i;l++){let m=Number(a[l]),d=0,y=o;if(e==="left")for(;d<y;){let f=Math.floor((d+y)/2);Number(n[f])<m?d=f+1:y=f}else for(;d<y;){let f=Math.floor((d+y)/2);Number(n[f])<=m?d=f+1:y=f}c[l]=d}return u}function eu(r,t){let e=r.data,n=t.data,o=t.dtype,a=M(r.dtype),i=M(o),s=Math.min(r.size,t.size),u=0;for(let d=0;d<s;d++)zr(e,d,a)&&u++;let c=N.zeros([u],o),l=c.data,m=0;if(B(o)){let d=n,y=l;for(let f=0;f<s;f++)zr(e,f,a)&&(y[m++]=d[f])}else if(i){let d=n,y=l;for(let f=0;f<s;f++)zr(e,f,a)&&(y[m*2]=d[f*2],y[m*2+1]=d[f*2+1],m++)}else for(let d=0;d<s;d++)zr(e,d,a)&&(l[m++]=n[d]);return c}function wn(r,t){let e=r.shape,n=e.length,o=r.data,a=r.size,i=M(r.dtype);if(t===void 0){let y=0;for(let f=0;f<a;f++)zr(o,f,i)&&y++;return y}let s=t;if(s<0&&(s=n+s),s<0||s>=n)throw new Error(`axis ${t} is out of bounds for array of dimension ${n}`);let u=Array.from(e).filter((y,f)=>f!==s);if(u.length===0)return wn(r);let c=N.zeros(u,"int32"),l=c.data,m=e[s],d=u.reduce((y,f)=>y*f,1);for(let y=0;y<d;y++){let f=0;for(let p=0;p<m;p++){let g=R(y,s,p,e),h=$(g,e);zr(o,h,i)&&f++}l[y]=f}return c}var nu=G(()=>{"use strict";K();Q();Me()});function ou(r){if(!isFinite(r))return r;let t=Math.floor(r),e=r-t;return Math.abs(e-.5)<1e-10?t%2===0?t:t+1:Math.round(r)}function In(r,t=0){U(r.dtype,"around","Rounding is not defined for complex numbers.");let e=r.dtype,n=Array.from(r.shape),o=r.data,a=r.size,i=e==="float32"?"float32":"float64",s=N.zeros(n,i),u=s.data,c=Math.pow(10,t);for(let l=0;l<a;l++){let m=Number(o[l]);u[l]=ou(m*c)/c}return s}function zn(r){U(r.dtype,"ceil","Rounding is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",i=N.zeros(e,a),s=i.data;for(let u=0;u<o;u++)s[u]=Math.ceil(Number(n[u]));return i}function _n(r){U(r.dtype,"fix","Rounding is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",i=N.zeros(e,a),s=i.data;for(let u=0;u<o;u++)s[u]=Math.trunc(Number(n[u]));return i}function vn(r){U(r.dtype,"floor","Rounding is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",i=N.zeros(e,a),s=i.data;for(let u=0;u<o;u++)s[u]=Math.floor(Number(n[u]));return i}function Fn(r){U(r.dtype,"rint","Rounding is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",i=N.zeros(e,a),s=i.data;for(let u=0;u<o;u++)s[u]=ou(Number(n[u]));return i}function Mn(r){U(r.dtype,"trunc","Rounding is not defined for complex numbers.");let t=r.dtype,e=Array.from(r.shape),n=r.data,o=r.size,a=t==="float32"?"float32":"float64",i=N.zeros(e,a),s=i.data;for(let u=0;u<o;u++)s[u]=Math.trunc(Number(n[u]));return i}var au=G(()=>{"use strict";K();Q()});function Bn(r,t,e,n){let o=isNaN(r)||isNaN(t),a=isNaN(e)||isNaN(n);return o&&a?0:o?1:a||r<e?-1:r>e?1:t<n?-1:t>n?1:0}function Sg(r,t,e,n){let o=isNaN(r)||isNaN(t),a=isNaN(e)||isNaN(n);return o&&a?!0:o||a?!1:r===e&&t===n}function yr(r,t=!1,e=!1,n=!1){let o=r.dtype,a=r.size,i=r.data;if(M(o)){let A=i,S=[];for(let k=0;k<a;k++)S.push({re:A[k*2],im:A[k*2+1],index:k});S.sort((k,W)=>Bn(k.re,k.im,W.re,W.im));let D=[],w=[],x=new Array(a),I=[],z,F,v=0;for(let k=0;k<S.length;k++){let{re:W,im:P,index:rr}=S[k];z===void 0||!Sg(W,P,z,F)?(z!==void 0&&I.push(v),D.push({re:W,im:P}),w.push(rr),v=1,z=W,F=P):v++}v>0&&I.push(v);let T=new Map,O=-1;for(let k=0;k<D.length;k++){let{re:W,im:P}=D[k];isNaN(W)||isNaN(P)?O=k:T.set(`${W},${P}`,k)}for(let k=0;k<a;k++){let W=A[k*2],P=A[k*2+1];isNaN(W)||isNaN(P)?x[k]=O:x[k]=T.get(`${W},${P}`)}let C=N.zeros([D.length],o),q=C.data;for(let k=0;k<D.length;k++)q[k*2]=D[k].re,q[k*2+1]=D[k].im;if(!t&&!e&&!n)return C;let V={values:C};if(t){let k=N.zeros([w.length],"int32"),W=k.data;for(let P=0;P<w.length;P++)W[P]=w[P];V.indices=k}if(e){let k=N.zeros([x.length],"int32"),W=k.data;for(let P=0;P<x.length;P++)W[P]=x[P];V.inverse=k}if(n){let k=N.zeros([I.length],"int32"),W=k.data;for(let P=0;P<I.length;P++)W[P]=I[P];V.counts=k}return V}let s=[];for(let A=0;A<a;A++)s.push({value:Number(i[A]),index:A});s.sort((A,S)=>isNaN(A.value)&&isNaN(S.value)?0:isNaN(A.value)?1:isNaN(S.value)?-1:A.value-S.value);let u=[],c=[],l=new Array(a),m=[],d,y=0;for(let A=0;A<s.length;A++){let{value:S,index:D}=s[A];d===void 0||isNaN(S)&&!isNaN(d)||!isNaN(S)&&isNaN(d)||!isNaN(S)&&!isNaN(d)&&S!==d?(d!==void 0&&m.push(y),u.push(S),c.push(D),y=1,d=S):y++}y>0&&m.push(y);let f=new Map,p=-1;for(let A=0;A<u.length;A++){let S=u[A];isNaN(S)?p=A:f.set(S,A)}for(let A=0;A<a;A++){let S=Number(i[A]);isNaN(S)?l[A]=p:l[A]=f.get(S)}let g=N.zeros([u.length],o),h=g.data;for(let A=0;A<u.length;A++)h[A]=u[A];if(!t&&!e&&!n)return g;let b={values:g};if(t){let A=N.zeros([c.length],"int32"),S=A.data;for(let D=0;D<c.length;D++)S[D]=c[D];b.indices=A}if(e){let A=N.zeros([l.length],"int32"),S=A.data;for(let D=0;D<l.length;D++)S[D]=l[D];b.inverse=A}if(n){let A=N.zeros([m.length],"int32"),S=A.data;for(let D=0;D<m.length;D++)S[D]=m[D];b.counts=A}return b}function _r(r,t,e){if(e){let n=Number(r[t*2]),o=Number(r[t*2+1]);return`${n},${o}`}return String(Number(r[t]))}function su(r,t){return En(r,t)}function iu(r,t){let e=r.dtype,n=M(e),o=yr(r),a=yr(t),i=new Set;for(let l=0;l<a.size;l++)i.add(_r(a.data,l,n));let s=[];for(let l=0;l<o.size;l++){let m=_r(o.data,l,n);i.has(m)&&s.push(l)}if(n){let l=N.zeros([s.length],e),m=l.data,d=o.data;for(let y=0;y<s.length;y++){let f=s[y];m[y*2]=d[f*2],m[y*2+1]=d[f*2+1]}return l}let u=N.zeros([s.length],e),c=u.data;for(let l=0;l<s.length;l++)c[l]=o.data[s[l]];return u}function En(r,t){let e=Array.from(r.shape),n=r.size,o=M(r.dtype),a=new Set;for(let u=0;u<t.size;u++)a.add(_r(t.data,u,o));let i=N.zeros(e,"bool"),s=i.data;for(let u=0;u<n;u++){let c=_r(r.data,u,o);s[u]=a.has(c)?1:0}return i}function uu(r,t){let e=r.dtype,n=M(e),o=yr(r),a=new Set;for(let c=0;c<t.size;c++)a.add(_r(t.data,c,n));let i=[];for(let c=0;c<o.size;c++){let l=_r(o.data,c,n);a.has(l)||i.push(c)}if(n){let c=N.zeros([i.length],e),l=c.data,m=o.data;for(let d=0;d<i.length;d++){let y=i[d];l[d*2]=m[y*2],l[d*2+1]=m[y*2+1]}return c}let s=N.zeros([i.length],e),u=s.data;for(let c=0;c<i.length;c++)u[c]=o.data[i[c]];return s}function cu(r,t){let e=r.dtype,n=M(e),o=yr(r),a=yr(t),i=new Set,s=new Set;for(let y=0;y<o.size;y++)i.add(_r(o.data,y,n));for(let y=0;y<a.size;y++)s.add(_r(a.data,y,n));let u=[],c=[];for(let y=0;y<o.size;y++){let f=_r(o.data,y,n);s.has(f)||u.push(y)}for(let y=0;y<a.size;y++){let f=_r(a.data,y,n);i.has(f)||c.push(y)}if(n){let y=[],f=o.data,p=a.data;for(let b of u)y.push({re:f[b*2],im:f[b*2+1]});for(let b of c)y.push({re:p[b*2],im:p[b*2+1]});y.sort((b,A)=>Bn(b.re,b.im,A.re,A.im));let g=N.zeros([y.length],e),h=g.data;for(let b=0;b<y.length;b++)h[b*2]=y[b].re,h[b*2+1]=y[b].im;return g}let l=[];for(let y of u)l.push(Number(o.data[y]));for(let y of c)l.push(Number(a.data[y]));l.sort((y,f)=>isNaN(y)&&isNaN(f)?0:isNaN(y)?1:isNaN(f)?-1:y-f);let m=N.zeros([l.length],e),d=m.data;for(let y=0;y<l.length;y++)d[y]=l[y];return m}function lu(r,t){let e=r.dtype,n=M(e),o=yr(r),a=yr(t),i=new Set,s=[];if(n){let m=o.data,d=a.data;for(let p=0;p<o.size;p++){let g=m[p*2],h=m[p*2+1],b=`${g},${h}`;i.has(b)||(i.add(b),s.push({re:g,im:h}))}for(let p=0;p<a.size;p++){let g=d[p*2],h=d[p*2+1],b=`${g},${h}`;i.has(b)||(i.add(b),s.push({re:g,im:h}))}s.sort((p,g)=>Bn(p.re,p.im,g.re,g.im));let y=N.zeros([s.length],e),f=y.data;for(let p=0;p<s.length;p++)f[p*2]=s[p].re,f[p*2+1]=s[p].im;return y}let u=[];for(let m=0;m<o.size;m++){let d=Number(o.data[m]),y=String(d);i.has(y)||(i.add(y),u.push(d))}for(let m=0;m<a.size;m++){let d=Number(a.data[m]),y=String(d);i.has(y)||(i.add(y),u.push(d))}u.sort((m,d)=>isNaN(m)&&isNaN(d)?0:isNaN(m)?1:isNaN(d)?-1:m-d);let c=N.zeros([u.length],e),l=c.data;for(let m=0;m<u.length;m++)l[m]=u[m];return c}function fu(r,t="fb"){let e=r.dtype,n=r.data,o=r.size,a=M(e);if(o===0)return N.zeros([0],e);let i=d=>{if(a){let y=n[d*2],f=n[d*2+1];return y===0&&f===0}return Number(n[d])===0},s=0;if(t==="f"||t==="fb")for(;s<o&&i(s);)s++;let u=o-1;if(t==="b"||t==="fb")for(;u>=s&&i(u);)u--;if(s>u)return N.zeros([0],e);let c=u-s+1;if(a){let d=N.zeros([c],e),y=d.data;for(let f=0;f<c;f++)y[f*2]=n[(s+f)*2],y[f*2+1]=n[(s+f)*2+1];return d}let l=N.zeros([c],e),m=l.data;for(let d=0;d<c;d++)m[d]=n[s+d];return l}function mu(r){let e=yr(r,!0,!0,!0);return{values:e.values,indices:e.indices,inverse_indices:e.inverse,counts:e.counts}}function pu(r){let e=yr(r,!1,!1,!0);return{values:e.values,counts:e.counts}}function yu(r){let e=yr(r,!1,!0,!1);return{values:e.values,inverse_indices:e.inverse}}function du(r){return yr(r)}var gu=G(()=>{"use strict";K();Q()});function Tn(r,t=1,e=-1){if(t<0)throw new Error(`order must be non-negative but got ${t}`);if(t===0)return r.copy();let n=Array.from(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}`);if(n[a]<t+1)throw new Error(`diff requires at least ${t+1} elements along axis ${e}, but got ${n[a]}`);let i=r;for(let s=0;s<t;s++)i=Ng(i,a);return i}function Ng(r,t){let e=Array.from(r.shape),n=e.length,o=e[t],a=[...e];a[t]=o-1;let i=r.dtype,s=M(i),u=B(i)?"float64":i,c=N.zeros(a,u),l=c.data,m=r.strides,d=c.size;for(let y=0;y<d;y++){let f=y,p=new Array(n);for(let S=n-1;S>=0;S--)p[S]=f%a[S],f=Math.floor(f/a[S]);let g=[...p],h=[...p];h[t]=g[t]+1;let b=0,A=0;for(let S=0;S<n;S++)b+=g[S]*m[S],A+=h[S]*m[S];if(s){let S=r.data,D=S[b*2],w=S[b*2+1],x=S[A*2],I=S[A*2+1];l[y*2]=x-D,l[y*2+1]=I-w}else{let S=(B(i),Number(r.data[b])),D=(B(i),Number(r.data[A]));l[y]=D-S}}return c}function Au(r,t=null,e=null){let n=r.size,o=r.dtype,a=M(o),i=B(o)?"float64":o,s=Math.max(0,n-1),u=e?e.length:0,c=t?t.length:0,l=u+s+c,m=N.zeros([l],i),d=m.data,y=0;if(e)if(a)for(let f of e)d[y*2]=f,d[y*2+1]=0,y++;else for(let f of e)d[y++]=f;if(a){let f=r.data;for(let p=0;p<s;p++){let g=f[p*2],h=f[p*2+1],b=f[(p+1)*2],A=f[(p+1)*2+1];d[y*2]=b-g,d[y*2+1]=A-h,y++}}else for(let f=0;f<s;f++){let p=(B(o),Number(r.iget(f))),g=(B(o),Number(r.iget(f+1)));d[y++]=g-p}if(t)if(a)for(let f of t)d[y*2]=f,d[y*2+1]=0,y++;else for(let f of t)d[y++]=f;return m}function bu(r,t=1,e=null){let o=Array.from(r.shape).length,a;if(e===null)a=Array.from({length:o},(u,c)=>c);else if(typeof e=="number"){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}`);a=[u]}else a=e.map(u=>{let c=u<0?o+u:u;if(c<0||c>=o)throw new Error(`axis ${u} is out of bounds for array of dimension ${o}`);return c});let i;if(typeof t=="number")i=a.map(()=>t);else{if(t.length!==a.length)throw new Error("Number of spacings must match number of axes");i=t}let s=[];for(let u=0;u<a.length;u++)s.push(xg(r,a[u],i[u]));return s.length===1?s[0]:s}function xg(r,t,e){let n=Array.from(r.shape),o=n.length,a=n[t];if(a<2)throw new Error(`Shape of array along axis ${t} must be at least 2, but got ${a}`);let i=r.dtype,s=M(i),u=B(i)?"float64":i==="float32"?"float32":s?i:"float64",c=N.zeros(n,u),l=c.data,m=r.strides,d=e,y=2*d,f=r.size;for(let p=0;p<f;p++){let g=p,h=new Array(o);for(let A=o-1;A>=0;A--)h[A]=g%n[A],g=Math.floor(g/n[A]);let b=h[t];if(s){let A=r.data,S=l,D,w;if(b===0){let x=[...h];x[t]=1;let I=0;for(let O=0;O<o;O++)I+=x[O]*m[O];let z=A[p*2],F=A[p*2+1],v=A[I*2],T=A[I*2+1];D=(v-z)/d,w=(T-F)/d}else if(b===a-1){let x=[...h];x[t]=a-2;let I=0;for(let O=0;O<o;O++)I+=x[O]*m[O];let z=A[p*2],F=A[p*2+1],v=A[I*2],T=A[I*2+1];D=(z-v)/d,w=(F-T)/d}else{let x=[...h],I=[...h];x[t]=b+1,I[t]=b-1;let z=0,F=0;for(let q=0;q<o;q++)z+=x[q]*m[q],F+=I[q]*m[q];let v=A[z*2],T=A[z*2+1],O=A[F*2],C=A[F*2+1];D=(v-O)/y,w=(T-C)/y}S[p*2]=D,S[p*2+1]=w}else{let A;if(b===0){let S=[...h];S[t]=1;let D=0;for(let I=0;I<o;I++)D+=S[I]*m[I];let w=(B(i),Number(r.data[p]));A=((B(i),Number(r.data[D]))-w)/d}else if(b===a-1){let S=[...h];S[t]=a-2;let D=0;for(let I=0;I<o;I++)D+=S[I]*m[I];let w=(B(i),Number(r.data[p])),x=(B(i),Number(r.data[D]));A=(w-x)/d}else{let S=[...h],D=[...h];S[t]=b+1,D[t]=b-1;let w=0,x=0;for(let F=0;F<o;F++)w+=S[F]*m[F],x+=D[F]*m[F];let I=(B(i),Number(r.data[w])),z=(B(i),Number(r.data[x]));A=(I-z)/y}l[p]=A}}return c}function hu(r,t,e=-1,n=-1,o=-1){let a=Array.from(r.shape),i=Array.from(t.shape),s=a.length,u=i.length,c=e<0?s+e:e,l=n<0?u+n:n;if(c<0||c>=s)throw new Error(`axisa ${e} is out of bounds for array of dimension ${s}`);if(l<0||l>=u)throw new Error(`axisb ${n} is out of bounds for array of dimension ${u}`);let m=a[c],d=i[l];if(m!==2&&m!==3)throw new Error(`incompatible dimensions for cross product (dimension must be 2 or 3, got ${m})`);if(d!==2&&d!==3)throw new Error(`incompatible dimensions for cross product (dimension must be 2 or 3, got ${d})`);let y=Z(r.dtype,t.dtype),f=M(y),p=(b,A)=>{if(M(b.dtype)){let S=b.data;return[S[A*2],S[A*2+1]]}return[Number(b.iget(A)),0]},g=(b,A,S,D)=>[b*S-A*D,b*D+A*S],h=(b,A,S,D)=>[b-S,A-D];if(s===1&&u===1&&m===3&&d===3){let b=N.zeros([3],y);if(f){let A=b.data,[S,D]=p(r,0),[w,x]=p(r,1),[I,z]=p(r,2),[F,v]=p(t,0),[T,O]=p(t,1),[C,q]=p(t,2),[V,k]=g(w,x,C,q),[W,P]=g(I,z,T,O),[rr,nr]=h(V,k,W,P),[Y,ar]=g(I,z,F,v),[sr,ir]=g(S,D,C,q),[dr,ge]=h(Y,ar,sr,ir),[Ae,be]=g(S,D,T,O),[he,Se]=g(w,x,F,v),[De,Ne]=h(Ae,be,he,Se);A[0]=rr,A[1]=nr,A[2]=dr,A[3]=ge,A[4]=De,A[5]=Ne}else{let A=b.data,S=Number(r.iget(0)),D=Number(r.iget(1)),w=Number(r.iget(2)),x=Number(t.iget(0)),I=Number(t.iget(1)),z=Number(t.iget(2));A[0]=D*z-w*I,A[1]=w*x-S*z,A[2]=S*I-D*x}return b}if(s===1&&u===1&&m===2&&d===2){let b=N.zeros([],y);if(f){let A=b.data,[S,D]=p(r,0),[w,x]=p(r,1),[I,z]=p(t,0),[F,v]=p(t,1),[T,O]=g(S,D,F,v),[C,q]=g(w,x,I,z),[V,k]=h(T,O,C,q);A[0]=V,A[1]=k}else{let A=Number(r.iget(0)),S=Number(r.iget(1)),D=Number(t.iget(0)),w=Number(t.iget(1));b.data[0]=A*w-S*D}return b}if(s===1&&u===1){if(m===2&&d===3){let b=N.zeros([3],y);if(f){let A=b.data,[S,D]=p(r,0),[w,x]=p(r,1),[I,z]=p(t,0),[F,v]=p(t,1),[T,O]=p(t,2),[C,q]=g(w,x,T,O),[V,k]=g(S,D,T,O),W=-V,P=-k,[rr,nr]=g(S,D,F,v),[Y,ar]=g(w,x,I,z),[sr,ir]=h(rr,nr,Y,ar);A[0]=C,A[1]=q,A[2]=W,A[3]=P,A[4]=sr,A[5]=ir}else{let A=b.data,S=Number(r.iget(0)),D=Number(r.iget(1)),w=Number(t.iget(0)),x=Number(t.iget(1)),I=Number(t.iget(2));A[0]=D*I,A[1]=-S*I,A[2]=S*x-D*w}return b}else if(m===3&&d===2){let b=N.zeros([3],y);if(f){let A=b.data,[S,D]=p(r,0),[w,x]=p(r,1),[I,z]=p(r,2),[F,v]=p(t,0),[T,O]=p(t,1),[C,q]=g(I,z,T,O),V=-C,k=-q,[W,P]=g(I,z,F,v),[rr,nr]=g(S,D,T,O),[Y,ar]=g(w,x,F,v),[sr,ir]=h(rr,nr,Y,ar);A[0]=V,A[1]=k,A[2]=W,A[3]=P,A[4]=sr,A[5]=ir}else{let A=b.data,S=Number(r.iget(0)),D=Number(r.iget(1)),w=Number(r.iget(2)),x=Number(t.iget(0)),I=Number(t.iget(1));A[0]=-w*I,A[1]=w*x,A[2]=S*I-D*x}return b}}if(s===2&&u===2&&c===1&&l===1){let b=a[0];if(i[0]!==b)throw new Error(`Shape mismatch: a has ${b} vectors, b has ${i[0]} vectors`);if(m===3&&d===3){let A=N.zeros([b,3],y);if(f){let S=A.data;for(let D=0;D<b;D++){let[w,x]=p(r,D*3),[I,z]=p(r,D*3+1),[F,v]=p(r,D*3+2),[T,O]=p(t,D*3),[C,q]=p(t,D*3+1),[V,k]=p(t,D*3+2),[W,P]=g(I,z,V,k),[rr,nr]=g(F,v,C,q),[Y,ar]=h(W,P,rr,nr),[sr,ir]=g(F,v,T,O),[dr,ge]=g(w,x,V,k),[Ae,be]=h(sr,ir,dr,ge),[he,Se]=g(w,x,C,q),[De,Ne]=g(I,z,T,O),[Xy,Jy]=h(he,Se,De,Ne);S[D*3*2]=Y,S[D*3*2+1]=ar,S[(D*3+1)*2]=Ae,S[(D*3+1)*2+1]=be,S[(D*3+2)*2]=Xy,S[(D*3+2)*2+1]=Jy}}else{let S=A.data;for(let D=0;D<b;D++){let w=Number(r.iget(D*3)),x=Number(r.iget(D*3+1)),I=Number(r.iget(D*3+2)),z=Number(t.iget(D*3)),F=Number(t.iget(D*3+1)),v=Number(t.iget(D*3+2));S[D*3]=x*v-I*F,S[D*3+1]=I*z-w*v,S[D*3+2]=w*F-x*z}}return A}if(m===2&&d===2){let A=N.zeros([b],y);if(f){let S=A.data;for(let D=0;D<b;D++){let[w,x]=p(r,D*2),[I,z]=p(r,D*2+1),[F,v]=p(t,D*2),[T,O]=p(t,D*2+1),[C,q]=g(w,x,T,O),[V,k]=g(I,z,F,v),[W,P]=h(C,q,V,k);S[D*2]=W,S[D*2+1]=P}}else{let S=A.data;for(let D=0;D<b;D++){let w=Number(r.iget(D*2)),x=Number(r.iget(D*2+1)),I=Number(t.iget(D*2)),z=Number(t.iget(D*2+1));S[D]=w*z-x*I}}return A}}throw new Error(`cross product not implemented for arrays with shapes ${JSON.stringify(a)} and ${JSON.stringify(i)}`)}var Su=G(()=>{"use strict";K();Q()});function Du(r,t,e=0){U(r.dtype,"bincount","bincount requires integer input.");let n=r.data,o=r.size,a=0;for(let s=0;s<o;s++){let u=Number(n[s]);if(u<0||!Number.isInteger(u))throw new Error("'x' argument must contain non-negative integers");u>a&&(a=u)}let i=Math.max(a+1,e);if(t!==void 0){if(t.size!==o)throw new Error("weights array must have same length as x");let s=t.data,u=new Float64Array(i);for(let c=0;c<o;c++){let l=Number(n[c]);u[l]+=Number(s[c])}return N.fromData(u,[i],"float64")}else{let s=new Float64Array(i);for(let u=0;u<o;u++){let c=Number(n[u]);s[c]++}return N.fromData(s,[i],"float64")}}function Nu(r,t,e=!1){U(r.dtype,"digitize","digitize requires real numbers."),U(t.dtype,"digitize","digitize requires real numbers.");let n=r.data,o=t.data,a=r.size,i=t.size,s=new Float64Array(a),u=!0;i>1&&(u=Number(o[1])>=Number(o[0]));for(let c=0;c<a;c++){let l=Number(n[c]),m;if(u)e?m=Ig(o,i,l):m=_t(o,i,l);else if(e)for(m=0;m<i&&Number(o[m])>=l;)m++;else for(m=0;m<i&&Number(o[m])>l;)m++;s[c]=m}return N.fromData(s,[...r.shape],"float64")}function Ig(r,t,e){let n=0,o=t;for(;n<o;){let a=n+o>>>1;Number(r[a])<e?n=a+1:o=a}return n}function _t(r,t,e){let n=0,o=t;for(;n<o;){let a=n+o>>>1;Number(r[a])<=e?n=a+1:o=a}return n}function xu(r,t=10,e,n=!1,o){U(r.dtype,"histogram","histogram requires real numbers."),typeof t!="number"&&U(t.dtype,"histogram","histogram requires real numbers.");let a=r.data,i=r.size,s;if(typeof t=="number"){let m,d;if(e)[m,d]=e;else{m=1/0,d=-1/0;for(let f=0;f<i;f++){let p=Number(a[f]);p<m&&(m=p),p>d&&(d=p)}m===d&&(m=m-.5,d=d+.5)}s=[];let y=(d-m)/t;for(let f=0;f<=t;f++)s.push(m+f*y)}else{let m=t.data;s=[];for(let d=0;d<t.size;d++)s.push(Number(m[d]))}let u=s.length-1,c=new Float64Array(u),l=o?.data;for(let m=0;m<i;m++){let d=Number(a[m]),y=l?Number(l[m]):1,f=_t(s,s.length,d)-1;if(!(f<0)){if(f>=u)if(d===s[u])f=u-1;else continue;c[f]+=y}}if(n){let m=0;for(let d=0;d<u;d++)m+=c[d];for(let d=0;d<u;d++){let y=s[d+1]-s[d];c[d]=c[d]/(m*y)}}return{hist:N.fromData(c,[u],"float64"),bin_edges:N.fromData(new Float64Array(s),[s.length],"float64")}}function wu(r,t,e=10,n,o=!1,a){U(r.dtype,"histogram2d","histogram2d requires real numbers."),U(t.dtype,"histogram2d","histogram2d requires real numbers.");let i=r.data,s=t.data,u=r.size;if(t.size!==u)throw new Error("x and y must have the same length");let c,l,m,d;if(typeof e=="number"?(m=e,d=e):Array.isArray(e)&&e.length===2?(e[0],m=e[0],d=e[1]):(m=10,d=10),typeof m=="number"){let h,b;if(n)[h,b]=n[0];else{h=1/0,b=-1/0;for(let S=0;S<u;S++){let D=Number(i[S]);D<h&&(h=D),D>b&&(b=D)}h===b&&(h-=.5,b+=.5)}c=[];let A=(b-h)/m;for(let S=0;S<=m;S++)c.push(h+S*A)}else{let h=m.data;c=[];for(let b=0;b<m.size;b++)c.push(Number(h[b]))}if(typeof d=="number"){let h,b;if(n)[h,b]=n[1];else{h=1/0,b=-1/0;for(let S=0;S<u;S++){let D=Number(s[S]);D<h&&(h=D),D>b&&(b=D)}h===b&&(h-=.5,b+=.5)}l=[];let A=(b-h)/d;for(let S=0;S<=d;S++)l.push(h+S*A)}else{let h=d.data;l=[];for(let b=0;b<d.size;b++)l.push(Number(h[b]))}let y=c.length-1,f=l.length-1,p=new Float64Array(y*f),g=a?.data;for(let h=0;h<u;h++){let b=Number(i[h]),A=Number(s[h]),S=g?Number(g[h]):1,D=_t(c,c.length,b)-1,w=_t(l,l.length,A)-1;if(D<0||D>=y)if(b===c[y]&&D===y)D=y-1;else continue;if(w<0||w>=f)if(A===l[f]&&w===f)w=f-1;else continue;p[D*f+w]+=S}if(o){let h=0;for(let b=0;b<p.length;b++)h+=p[b];for(let b=0;b<y;b++)for(let A=0;A<f;A++){let S=c[b+1]-c[b],D=l[A+1]-l[A],w=S*D;p[b*f+A]=p[b*f+A]/(h*w)}}return{hist:N.fromData(p,[y,f],"float64"),x_edges:N.fromData(new Float64Array(c),[c.length],"float64"),y_edges:N.fromData(new Float64Array(l),[l.length],"float64")}}function Iu(r,t=10,e,n=!1,o){U(r.dtype,"histogramdd","histogramdd requires real numbers.");let a=r.shape,i=r.data,s,u;if(a.length===1)s=a[0],u=1;else if(a.length===2)s=a[0],u=a[1];else throw new Error("sample must be 1D or 2D array");let c;if(typeof t=="number")c=new Array(u).fill(t);else if(c=t,c.length!==u)throw new Error("bins array length must match number of dimensions");let l=[];for(let h=0;h<u;h++){let b,A;if(e&&e[h])[b,A]=e[h];else{b=1/0,A=-1/0;for(let x=0;x<s;x++){let I=Number(u===1?i[x]:i[x*u+h]);I<b&&(b=I),I>A&&(A=I)}b===A&&(b-=.5,A+=.5)}let S=c[h],D=[],w=(A-b)/S;for(let x=0;x<=S;x++)D.push(b+x*w);l.push(D)}let m=c.slice(),d=m.reduce((h,b)=>h*b,1),y=new Float64Array(d),f=new Array(u);f[u-1]=1;for(let h=u-2;h>=0;h--)f[h]=f[h+1]*c[h+1];let p=o?.data;for(let h=0;h<s;h++){let b=p?Number(p[h]):1,A=0,S=!1;for(let D=0;D<u;D++){let w=Number(u===1?i[h]:i[h*u+D]),x=l[D],I=c[D],z=_t(x,x.length,w)-1;if(z<0||z>=I)if(w===x[I]&&z===I)z=I-1;else{S=!0;break}A+=z*f[D]}S||(y[A]+=b)}if(n){let h=0;for(let A=0;A<d;A++)h+=y[A];let b=new Float64Array(d);for(let A=0;A<d;A++){let S=1,D=A;for(let w=0;w<u;w++){let x=Math.floor(D/f[w])%c[w],I=l[w];S*=I[x+1]-I[x]}b[A]=S}for(let A=0;A<d;A++)y[A]=y[A]/(h*b[A])}let g=l.map(h=>N.fromData(new Float64Array(h),[h.length],"float64"));return{hist:N.fromData(y,m,"float64"),edges:g}}function Cn(r,t,e="full"){let n=r.data,o=t.data,a=r.size,i=t.size,s=M(r.dtype)||M(t.dtype),u=a+i-1;if(s){let l=new Float64Array(u),m=new Float64Array(u),d=M(r.dtype),y=M(t.dtype);for(let p=0;p<u;p++){let g=0,h=0,b=p-i+1;for(let A=0;A<a;A++){let S=A-b;if(S>=0&&S<i){let D,w,x,I;d?(D=n[A*2],w=n[A*2+1]):(D=Number(n[A]),w=0),y?(x=o[S*2],I=o[S*2+1]):(x=Number(o[S]),I=0),g+=D*x+w*I,h+=w*x-D*I}}l[p]=g,m[p]=h}let f=(p,g,h,b=0)=>{let A=new Float64Array(h*2);for(let S=0;S<h;S++)A[S*2]=p[b+S],A[S*2+1]=g[b+S];return N.fromData(A,[h],"complex128")};if(e==="full")return f(l,m,u);if(e==="same"){let p=Math.floor((u-a)/2);return f(l,m,a,p)}else{let p=Math.max(a,i)-Math.min(a,i)+1,g=Math.min(a,i)-1;return f(l,m,p,g)}}let c=new Float64Array(u);for(let l=0;l<u;l++){let m=0,d=l-i+1;for(let y=0;y<a;y++){let f=y-d;f>=0&&f<i&&(m+=Number(n[y])*Number(o[f]))}c[l]=m}if(e==="full")return N.fromData(c,[u],"float64");if(e==="same"){let l=Math.floor((u-a)/2),m=new Float64Array(a);for(let d=0;d<a;d++)m[d]=c[l+d];return N.fromData(m,[a],"float64")}else{let l=Math.max(a,i)-Math.min(a,i)+1,m=Math.min(a,i)-1,d=new Float64Array(l);for(let y=0;y<l;y++)d[y]=c[m+y];return N.fromData(d,[l],"float64")}}function zu(r,t,e="full"){let n=t.data,o=t.size,a=M(t.dtype),i;if(a){let s=new Float64Array(o*2);for(let u=0;u<o;u++){let c=o-1-u;s[u*2]=n[c*2],s[u*2+1]=n[c*2+1]}i=N.fromData(s,[o],t.dtype)}else{let s=new Float64Array(o);for(let u=0;u<o;u++)s[u]=Number(n[o-1-u]);i=N.fromData(s,[o],"float64")}if(a){let s=i.data;for(let u=0;u<o;u++)s[u*2+1]=-s[u*2+1]}return Cn(r,i,e)}function Un(r,t,e=!0,n=!1,o){let a=r.shape,i=r.data,s=M(r.dtype)||t!==void 0&&M(t.dtype),u;if(o!==void 0?u=o:u=n?0:1,a.length===1)if(t!==void 0){let f=t.data,p=r.size,g=M(r.dtype),h=M(t.dtype);if(t.size!==p)throw new Error("m and y must have same length");if(s){let I=0,z=0,F=0,v=0;for(let Y=0;Y<p;Y++)g?(I+=i[Y*2],z+=i[Y*2+1]):I+=Number(i[Y]),h?(F+=f[Y*2],v+=f[Y*2+1]):F+=Number(f[Y]);I/=p,z/=p,F/=p,v/=p;let T=0,O=0,C=0,q=0,V=0,k=0,W=0,P=0;for(let Y=0;Y<p;Y++){let ar,sr,ir,dr;g?(ar=i[Y*2]-I,sr=i[Y*2+1]-z):(ar=Number(i[Y])-I,sr=0),h?(ir=f[Y*2]-F,dr=f[Y*2+1]-v):(ir=Number(f[Y])-F,dr=0),T+=ar*ar+sr*sr,C+=ir*ir+dr*dr,V+=ar*ir+sr*dr,k+=sr*ir-ar*dr,W+=ir*ar+dr*sr,P+=dr*ar-ir*sr}let rr=p-u;if(rr<=0){let Y=new Float64Array(8);return Y.fill(NaN),N.fromData(Y,[2,2],"complex128")}T/=rr,C/=rr,V/=rr,k/=rr,W/=rr,P/=rr;let nr=new Float64Array(8);return nr[0]=T,nr[1]=O,nr[2]=V,nr[3]=k,nr[4]=W,nr[5]=P,nr[6]=C,nr[7]=q,N.fromData(nr,[2,2],"complex128")}let b=0,A=0;for(let I=0;I<p;I++)b+=Number(i[I]),A+=Number(f[I]);b/=p,A/=p;let S=0,D=0,w=0;for(let I=0;I<p;I++){let z=Number(i[I])-b,F=Number(f[I])-A;S+=z*z,D+=F*F,w+=z*F}let x=p-u;return x<=0?N.fromData(new Float64Array([NaN,NaN,NaN,NaN]),[2,2],"float64"):(S/=x,D/=x,w/=x,N.fromData(new Float64Array([S,w,w,D]),[2,2],"float64"))}else{let f=r.size;if(s){let b=0,A=0;for(let w=0;w<f;w++)b+=i[w*2],A+=i[w*2+1];b/=f,A/=f;let S=0;for(let w=0;w<f;w++){let x=i[w*2]-b,I=i[w*2+1]-A;S+=x*x+I*I}let D=f-u;return D<=0?N.fromData(new Float64Array([NaN,0]),[],"complex128"):(S/=D,N.fromData(new Float64Array([S,0]),[],"complex128"))}let p=0;for(let b=0;b<f;b++)p+=Number(i[b]);p/=f;let g=0;for(let b=0;b<f;b++){let A=Number(i[b])-p;g+=A*A}let h=f-u;return h<=0?N.fromData(new Float64Array([NaN]),[],"float64"):(g/=h,N.fromData(new Float64Array([g]),[],"float64"))}let c,l;e?(c=a[0],l=a[1]):(c=a[1],l=a[0]);let m=l-u;if(s){let f=new Float64Array(c),p=new Float64Array(c);for(let h=0;h<c;h++){let b=0,A=0;for(let S=0;S<l;S++){let D=e?h*l+S:S*c+h;b+=i[D*2],A+=i[D*2+1]}f[h]=b/l,p[h]=A/l}let g=new Float64Array(c*c*2);if(m<=0)return g.fill(NaN),N.fromData(g,[c,c],"complex128");for(let h=0;h<c;h++)for(let b=0;b<c;b++){let A=0,S=0;for(let w=0;w<l;w++){let x=e?h*l+w:w*c+h,I=e?b*l+w:w*c+b,z=i[x*2]-f[h],F=i[x*2+1]-p[h],v=i[I*2]-f[b],T=i[I*2+1]-p[b];A+=z*v+F*T,S+=F*v-z*T}let D=(h*c+b)*2;g[D]=A/m,g[D+1]=S/m}return N.fromData(g,[c,c],"complex128")}let d=new Float64Array(c);for(let f=0;f<c;f++){let p=0;for(let g=0;g<l;g++){let h=e?f*l+g:g*c+f;p+=Number(i[h])}d[f]=p/l}let y=new Float64Array(c*c);if(m<=0)return y.fill(NaN),N.fromData(y,[c,c],"float64");for(let f=0;f<c;f++)for(let p=f;p<c;p++){let g=0;for(let b=0;b<l;b++){let A=e?f*l+b:b*c+f,S=e?p*l+b:b*c+p,D=Number(i[A])-d[f],w=Number(i[S])-d[p];g+=D*w}let h=g/m;y[f*c+p]=h,y[p*c+f]=h}return N.fromData(y,[c,c],"float64")}function _u(r,t,e=!0){let n=M(r.dtype)||t!==void 0&&M(t.dtype);if(r.shape.length===1&&t===void 0)return n?N.fromData(new Float64Array([1,0]),[],"complex128"):N.fromData(new Float64Array([1]),[],"float64");let o=Un(r,t,e,!1),a=o.data,s=o.shape[0];if(n){let c=new Float64Array(s*s*2);for(let l=0;l<s;l++)for(let m=0;m<s;m++){let d=a[(l*s+m)*2],y=a[(l*s+m)*2+1],f=a[(l*s+l)*2],p=a[(m*s+m)*2],g=(l*s+m)*2;if(f<=0||p<=0)c[g]=NaN,c[g+1]=NaN;else{let h=Math.sqrt(f*p);c[g]=d/h,c[g+1]=y/h}}return N.fromData(c,[s,s],"complex128")}let u=new Float64Array(s*s);for(let c=0;c<s;c++)for(let l=0;l<s;l++){let m=Number(a[c*s+l]),d=Number(a[c*s+c]),y=Number(a[l*s+l]);d<=0||y<=0?u[c*s+l]=NaN:u[c*s+l]=m/Math.sqrt(d*y)}return N.fromData(u,[s,s],"float64")}function vu(r,t=10,e,n){U(r.dtype,"histogram_bin_edges","histogram_bin_edges requires real numbers.");let o=r.data,a=r.size,i,s;if(e)[i,s]=e;else{i=1/0,s=-1/0;for(let m=0;m<a;m++){let d=Number(o[m]);isNaN(d)||(d<i&&(i=d),d>s&&(s=d))}!isFinite(i)||!isFinite(s)?(i=0,s=1):i===s&&(i=i-.5,s=s+.5)}let u;typeof t=="number"?u=t:u=On(o,a,i,s,t),u=Math.max(1,Math.round(u));let c=new Float64Array(u+1),l=(s-i)/u;for(let m=0;m<=u;m++)c[m]=i+m*l;return N.fromData(c,[u+1],"float64")}function On(r,t,e,n,o){if(t===0)return 1;let a=n-e;if(a===0)return 1;let i=[],s=0;for(let p=0;p<t;p++){let g=Number(r[p]);isNaN(g)||(i.push(g),s+=g)}let u=i.length;if(u===0)return 1;let c=s/u,l=0;for(let p=0;p<u;p++){let g=i[p]-c;l+=g*g}let m=Math.sqrt(l/u);i.sort((p,g)=>p-g);let d=i[Math.floor(u*.25)]??0,f=(i[Math.floor(u*.75)]??0)-d;switch(o){case"sqrt":return Math.ceil(Math.sqrt(u));case"sturges":return Math.ceil(Math.log2(u)+1);case"rice":return Math.ceil(2*Math.pow(u,1/3));case"scott":{if(m===0)return 1;let p=3.5*m/Math.pow(u,1/3);return Math.ceil(a/p)}case"fd":{if(f===0)return On(r,t,e,n,"sturges");let p=2*f/Math.pow(u,1/3);return Math.ceil(a/p)}case"doane":{let p=zg(i,c,m),g=Math.sqrt(6*(u-2)/((u+1)*(u+3)));return Math.ceil(1+Math.log2(u)+Math.log2(1+Math.abs(p)/g))}case"stone":return On(r,t,e,n,"sturges");default:{let p=Math.ceil(Math.log2(u)+1),g=f===0?p:Math.ceil(a/(2*f/Math.pow(u,1/3)));return Math.max(p,g)}}}function zg(r,t,e){if(e===0)return 0;let n=r.length,o=0;for(let a=0;a<n;a++)o+=Math.pow((r[a]-t)/e,3);return o/n}function Fu(r,t,e=1,n=-1){U(r.dtype,"trapezoid","trapezoid requires real numbers."),t!==void 0&&U(t.dtype,"trapezoid","trapezoid requires real numbers.");let o=Array.from(r.shape),a=o.length;if(n<0&&(n=a+n),n<0||n>=a)throw new Error(`axis ${n} is out of bounds for array of dimension ${a}`);let i=o[n];if(i<2)throw new Error("trapezoid requires at least 2 samples along axis");let s;if(t!==void 0){if(t.size!==i)throw new Error(`x array size (${t.size}) must match y axis size (${i})`);let p=t.data;s=new Float64Array(i);for(let g=0;g<i;g++)s[g]=Number(p[g])}else{s=new Float64Array(i);for(let p=0;p<i;p++)s[p]=p*e}let u=[...o];if(u.splice(n,1),a===1){let p=r.data,g=0;for(let h=0;h<i-1;h++){let b=Number(p[h]),A=Number(p[h+1]),S=s[h+1]-s[h];g+=.5*(b+A)*S}return g}let c=u.reduce((p,g)=>p*g,1),l=new Float64Array(c),m=new Array(a),d=1;for(let p=a-1;p>=0;p--)m[p]=d,d*=o[p];let y=new Array(u.length);d=1;for(let p=u.length-1;p>=0;p--)y[p]=d,d*=u[p];let f=r.data;for(let p=0;p<c;p++){let g=[],h=p;for(let D=0;D<u.length;D++){let w=Math.floor(h/y[D]);h%=y[D],g.push(w)}let b=[],A=0;for(let D=0;D<a;D++)D===n?b.push(0):(b.push(g[A]),A++);let S=0;for(let D=0;D<i-1;D++){b[n]=D;let w=0;for(let v=0;v<a;v++)w+=b[v]*m[v];b[n]=D+1;let x=0;for(let v=0;v<a;v++)x+=b[v]*m[v];let I=Number(f[w]),z=Number(f[x]),F=s[D+1]-s[D];S+=.5*(I+z)*F}l[p]=S}return u.length===0?l[0]:N.fromData(l,u,"float64")}var Mu=G(()=>{"use strict";K();Q()});function vr(r,t=tr){let e=N.zeros(r,t);return new _(e)}function $n(r,t=tr){let e=N.ones(r,t);return new _(e)}function vg(r){let t=[],e=r;for(;Array.isArray(e);)t.push(e.length),e=e[0];return t}function Bu(r){return typeof r=="bigint"?!0:Array.isArray(r)?r.some(t=>Bu(t)):!1}function Eu(r){return wo(r)?!0:Array.isArray(r)?r.some(t=>Eu(t)):!1}function Fg(r){let t=[];function e(n){Array.isArray(n)?n.forEach(o=>e(o)):t.push(n)}return e(r),t}function L(r,t){if(r instanceof _)return!t||r.dtype===t?r.copy():r.astype(t);let e=Bu(r),n=Eu(r),o=vg(r),a=o.reduce((y,f)=>y*f,1),i=t;i||(n?i="complex128":e?i="int64":i=tr);let s=M(i),u=j(i);if(!u)throw new Error(`Cannot create array with dtype ${i}`);let c=s?a*2:a,l=new u(c),m=Fg(r);if(B(i)){let y=l;for(let f=0;f<a;f++){let p=m[f];y[f]=typeof p=="bigint"?p:BigInt(Math.round(Number(p)))}}else if(i==="bool"){let y=l;for(let f=0;f<a;f++)y[f]=m[f]?1:0}else if(s){let y=l;for(let f=0;f<a;f++){let p=m[f],g,h;p instanceof E?(g=p.re,h=p.im):typeof p=="object"&&p!==null&&"re"in p?(g=p.re,h=p.im??0):(g=Number(p),h=0),y[f*2]=g,y[f*2+1]=h}}else{let y=l;for(let f=0;f<a;f++){let p=m[f];y[f]=Number(p)}}let d=N.fromData(l,o,i);return new _(d)}function Tu(r,t,e=1,n=tr){let o=r,a=t;if(t===void 0&&(o=0,a=r),a===void 0)throw new Error("stop is required");let i=Math.max(0,Math.ceil((a-o)/e)),s=j(n);if(!s)throw new Error(`Cannot create arange array with dtype ${n}`);let u=new s(i);if(B(n))for(let l=0;l<i;l++)u[l]=BigInt(Math.round(o+l*e));else if(n==="bool")for(let l=0;l<i;l++)u[l]=o+l*e!==0?1:0;else for(let l=0;l<i;l++)u[l]=o+l*e;let c=N.fromData(u,[i],n);return new _(c)}function Ou(r,t,e=50,n=tr){if(e<0)throw new Error("num must be non-negative");if(e===0)return L([],n);if(e===1)return L([r],n);let o=j(n);if(!o)throw new Error(`Cannot create linspace array with dtype ${n}`);let a=new o(e),i=(t-r)/(e-1);if(B(n))for(let u=0;u<e;u++)a[u]=BigInt(Math.round(r+u*i));else if(n==="bool")for(let u=0;u<e;u++)a[u]=r+u*i!==0?1:0;else for(let u=0;u<e;u++)a[u]=r+u*i;let s=N.fromData(a,[e],n);return new _(s)}function Cu(r,t,e=50,n=10,o=tr){if(e<0)throw new Error("num must be non-negative");if(e===0)return L([],o);if(e===1)return L([Math.pow(n,r)],o);let a=j(o);if(!a)throw new Error(`Cannot create logspace array with dtype ${o}`);let i=new a(e),s=(t-r)/(e-1);if(B(o))for(let c=0;c<e;c++){let l=r+c*s;i[c]=BigInt(Math.round(Math.pow(n,l)))}else if(o==="bool")for(let c=0;c<e;c++){let l=r+c*s;i[c]=Math.pow(n,l)!==0?1:0}else for(let c=0;c<e;c++){let l=r+c*s;i[c]=Math.pow(n,l)}let u=N.fromData(i,[e],o);return new _(u)}function Uu(r,t,e=50,n=tr){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 L([],n);if(e===1)return L([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 i=j(n);if(!i)throw new Error(`Cannot create geomspace array with dtype ${n}`);let s=new i(e),u=Math.log(Math.abs(r)),l=(Math.log(Math.abs(t))-u)/(e-1);if(B(n))for(let d=0;d<e;d++){let y=o*Math.exp(u+d*l);s[d]=BigInt(Math.round(y))}else if(n==="bool")for(let d=0;d<e;d++){let y=o*Math.exp(u+d*l);s[d]=y!==0?1:0}else for(let d=0;d<e;d++){let y=o*Math.exp(u+d*l);s[d]=y}let m=N.fromData(s,[e],n);return new _(m)}function Rn(r,t,e=0,n=tr){let o=t??r,a=vr([r,o],n),i=a.data;if(B(n)){let s=i;for(let u=0;u<r;u++){let c=u+e;c>=0&&c<o&&(s[u*o+c]=BigInt(1))}}else{let s=i;for(let u=0;u<r;u++){let c=u+e;c>=0&&c<o&&(s[u*o+c]=1)}}return a}function kn(r,t=tr){return vr(r,t)}function qn(r,t,e){let n=e;n||(typeof t=="bigint"?n="int64":typeof t=="boolean"?n="bool":Number.isInteger(t)?n="int32":n=tr);let o=j(n);if(!o)throw new Error(`Cannot create full array with dtype ${n}`);let a=r.reduce((u,c)=>u*c,1),i=new o(a);if(B(n)){let u=typeof t=="bigint"?t:BigInt(Math.round(Number(t)));i.fill(u)}else n==="bool"?i.fill(t?1:0):i.fill(Number(t));let s=N.fromData(i,r,n);return new _(s)}function $u(r,t=tr){return Rn(r,r,0,t)}function st(r,t){return r instanceof _?!t||r.dtype===t?r:r.astype(t):L(r,t)}function Ru(r,t){let e=st(r,t);for(let n=0;n<e.size;n++)if(!isFinite(Number(e.data[n])))throw new Error("array must not contain infs or NaNs");return e}function ku(r,t,e){let n=Array.isArray(e)?e:e?[e]:[],o=new Set(n.map(i=>{let s=i.toUpperCase();return s==="C_CONTIGUOUS"||s==="CONTIGUOUS"?"C":s==="F_CONTIGUOUS"||s==="FORTRAN"?"F":s==="WRITEABLE"?"W":s==="ENSUREARRAY"?"E":s==="OWNDATA"?"O":s})),a=r;return t&&r.dtype!==t&&(a=r.astype(t)),(o.has("C")||o.has("W")||o.has("O"))&&a===r&&(a=r.copy()),a}function qu(r){return r.copy()}function Vu(r,t){return vr(Array.from(r.shape),t??r.dtype)}function Pu(r,t){return $n(Array.from(r.shape),t??r.dtype)}function ju(r,t){return kn(Array.from(r.shape),t??r.dtype)}function Lu(r,t,e){return qn(Array.from(r.shape),t,e??r.dtype)}function Wu(r,t){return st(r,t)}function Gu(r,t){let e=st(r,t);return e.flags.C_CONTIGUOUS?e:e.copy()}function Zu(r,t){return st(r,t).copy()}function Vn(r,t=0){if(r.ndim===1){let e=r.size,n=e+Math.abs(t),o=vr([n,n],r.dtype);for(let a=0;a<e;a++){let i=t>=0?a:a-t,s=t>=0?a+t:a;o.set([i,s],r.get([a]))}return o}else if(r.ndim===2){let[e,n]=r.shape,o,a,i;if(t>=0?(o=0,a=t,i=Math.min(e,n-t)):(o=-t,a=0,i=Math.min(e+t,n)),i<=0)return vr([0],r.dtype);let s=j(r.dtype),u=new s(i);for(let l=0;l<i;l++){let m=r.get([o+l,a+l]);B(r.dtype)?u[l]=typeof m=="bigint"?m:BigInt(m):u[l]=m}let c=N.fromData(u,[i],r.dtype);return new _(c)}else throw new Error("Input must be 1-D or 2-D")}function Yu(r,t=0){let e=r.flatten();return Vn(e,t)}function Hu(r,t,e=tr){let n=t.reduce((c,l)=>c*l,1),o=j(e);if(!o)throw new Error(`Cannot create array with dtype ${e}`);let a=new o(n),i=t.length,s=new Array(i).fill(0);for(let c=0;c<n;c++){let l=r(...s);B(e)?a[c]=typeof l=="bigint"?l:BigInt(Number(l)):e==="bool"?a[c]=l?1:0:a[c]=Number(l);for(let m=i-1;m>=0&&(s[m]++,!(s[m]<t[m]));m--)s[m]=0}let u=N.fromData(a,t,e);return new _(u)}function Xu(...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,i=[];for(let s=0;s<t.length;s++){let u=t[s],c=u.size,l=new Array(a).fill(1);l[s]=c;let m=u.reshape(...l),d=Yt(m.storage,o),y=_._fromStorage(d.copy());i.push(y)}return e==="xy"&&i.length>=2&&([i[0],i[1]]=[i[1],i[0]]),i}function Ju(r,t,e=0,n=tr){let o=t??r,a=vr([r,o],n);for(let i=0;i<r;i++)for(let s=0;s<=i+e&&s<o;s++)s>=0&&a.set([i,s],1);return a}function Qu(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],i=n.slice(0,-2).reduce((s,u)=>s*u,1);for(let s=0;s<i;s++)for(let u=0;u<o;u++)for(let c=0;c<a;c++)if(c>u+t){let l=[],m=s;for(let d=n.length-3;d>=0;d--)l.unshift(m%n[d]),m=Math.floor(m/n[d]);l.push(u,c),e.set(l,0)}return e}function Ku(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],i=n.slice(0,-2).reduce((s,u)=>s*u,1);for(let s=0;s<i;s++)for(let u=0;u<o;u++)for(let c=0;c<a;c++)if(c<u+t){let l=[],m=s;for(let d=n.length-3;d>=0;d--)l.unshift(m%n[d]),m=Math.floor(m/n[d]);l.push(u,c),e.set(l,0)}return e}function rc(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=vr([n,o],r.dtype);for(let i=0;i<n;i++){let s=r.get([i]);for(let u=0;u<o;u++){let c=e?u:o-1-u;a.set([i,u],Math.pow(s,c))}}return a}function tc(r,t=tr,e=-1,n=0){let o,a=n;r instanceof ArrayBuffer?o=r:(o=r.buffer,a+=r.byteOffset);let i=Mg(t),s=o.byteLength-a,u=Math.floor(s/i),c=e<0?u:Math.min(e,u);if(c<=0)return L([],t);let l=j(t);if(!l)throw new Error(`Unsupported dtype: ${t}`);let m=new l(o,a,c),d=N.fromData(m,[c],t);return new _(d)}function ec(r,t=tr,e=-1){let n=[],o=0;for(let a of r){if(e>=0&&o>=e)break;n.push(a),o++}return L(n,t)}function nc(r,t=tr,e=-1){let n=[],o=0;for(let a of r){if(e>=0&&o>=e)break;n.push(a),o++}return L(n,t)}function oc(r,t=tr,e=-1,n=""){let o;n===""?o=r.trim().split(/\s+/):o=r.split(n);let a=[],i=0;for(let s of o){if(e>=0&&i>=e)break;let u=s.trim();u!==""&&(B(t)?a.push(BigInt(u)):a.push(parseFloat(u)),i++)}return L(a,t)}function Mg(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 ac(r){return r.sqrt()}function Pn(r,t){return r.power(t)}function sc(r){return r.exp()}function ic(r){return r.exp2()}function uc(r){return r.expm1()}function cc(r){return r.log()}function lc(r){return r.log2()}function fc(r){return r.log10()}function mc(r){return r.log1p()}function pc(r,t){return r.logaddexp(t)}function yc(r,t){return r.logaddexp2(t)}function jn(r){return r.absolute()}function dc(r){return r.negative()}function gc(r){return r.sign()}function Ac(r,t){return r.mod(t)}function Ln(r,t){return r.divide(t)}function bc(r,t){return r.floor_divide(t)}function hc(r){return r.positive()}function Sc(r){return r.reciprocal()}function Dc(r,t){return r.dot(t)}function Nc(r){return r.trace()}function xc(r,t=0,e=0,n=1){let o=Ke(r.storage,t,e,n);return _._fromStorage(o)}function wc(r,t){let e=Pa(r.storage,t.storage);return _._fromStorage(e)}function Ic(r,t){return r.transpose(t)}function zc(r,t){return r.inner(t)}function _c(r,t){return r.outer(t)}function vc(r,t,e=2){return r.tensordot(t,e)}function Fc(r){return r.sin()}function Mc(r){return r.cos()}function Bc(r){return r.tan()}function Wn(r){return r.arcsin()}function Gn(r){return r.arccos()}function Zn(r){return r.arctan()}function Yn(r,t){return r.arctan2(t)}function Ec(r,t){return r.hypot(t)}function Tc(r){return r.degrees()}function Oc(r){return r.radians()}function Cc(r){return r.radians()}function Uc(r){return r.degrees()}function $c(r){return r.sinh()}function Rc(r){return r.cosh()}function kc(r){return r.tanh()}function Hn(r){return r.arcsinh()}function Xn(r){return r.arccosh()}function Jn(r){return r.arctanh()}function qc(r,t,e){return r.swapaxes(t,e)}function Vc(r,t,e){return r.moveaxis(t,e)}function Vr(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=Rr(e,t);return _._fromStorage(n)}function Pc(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=Aa(e,t);return _._fromStorage(n)}function Qn(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=ba(t);return _._fromStorage(e)}function jc(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Ye(t);return _._fromStorage(e)}function Lc(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=ha(t);return _._fromStorage(e)}function Wc(r,t=0){return Vr(r,t)}function Gc(r,t=0){return Ua(r.storage,t).map(n=>_._fromStorage(n))}function Zc(r){let t=r.map(n=>n.storage),e=$a(t);return _._fromStorage(e)}function Yc(r,t,e=0){return Sa(r.storage,t,e).map(o=>_._fromStorage(o,r.base??r))}function Hc(r,t,e=0){return St(r.storage,t,e).map(o=>_._fromStorage(o,r.base??r))}function Xc(r,t){return Na(r.storage,t).map(n=>_._fromStorage(n,r.base??r))}function Jc(r,t){return xa(r.storage,t).map(n=>_._fromStorage(n,r.base??r))}function Qc(r,t){let e=wa(r.storage,t);return _._fromStorage(e)}function Kc(r,t,e){return r.repeat(t,e)}function rl(r){return r.ravel()}function tl(r){return r.flatten()}function el(r,t){r.fill(t)}function nl(r,...t){return r.item(...t)}function ol(r){return r.tolist()}function al(r){return r.tobytes()}function sl(r,t=!1){return r.byteswap(t)}function il(r,t){return r.view(t)}function ul(r,t,e="",n=""){r.tofile(t,e,n)}function cl(r,t){return r.reshape(...t)}function ll(r,t){return r.squeeze(t)}function fl(r,t){return r.expand_dims(t)}function re(r,t){let e=za(r.storage,t);return _._fromStorage(e)}function ml(r){if(r.ndim<2)throw new Error("Input must be at least 2-D");return re(r,1)}function pl(r){if(r.ndim<2)throw new Error("Input must be at least 2-D");return re(r,0)}function yl(r,t=1,e=[0,1]){let n=_a(r.storage,t,e);return _._fromStorage(n)}function dl(r,t,e){let n=va(r.storage,t,e);return _._fromStorage(n)}function gl(r,t,e=0){let n=Fa(r.storage,t,e);return _._fromStorage(n,r.base??r)}function Al(...r){let t=r.map(o=>o.storage),n=Ta(t).map((o,a)=>o===t[a]?r[a]:_._fromStorage(o));return n.length===1?n[0]:n}function bl(...r){let t=r.map(o=>o.storage),n=Oa(t).map((o,a)=>o===t[a]?r[a]:_._fromStorage(o));return n.length===1?n[0]:n}function hl(...r){let t=r.map(o=>o.storage),n=Ca(t).map((o,a)=>o===t[a]?r[a]:_._fromStorage(o));return n.length===1?n[0]:n}function Sl(r,t){return Ma(r.storage,t).map(n=>_._fromStorage(n,r.base??r))}function Dl(r){if(r.length===0)throw new Error("need at least one array to stack");let t=r.map(n=>n.storage),e=Ba(t);return _._fromStorage(e)}function Nl(r){return Qn(r)}function xl(r,t){let e=Ea(r.storage,t);return _._fromStorage(e)}function wl(r,t,e){let n=t instanceof _?t:L(t,r.dtype);if(e===void 0){let o=r.flatten(),a=n.flatten();return Vr([o,a])}return Vr([r,n],e)}function Il(r,t,e){let n=r.dtype;if(e===void 0){let y=r.flatten(),p=(Array.isArray(t)?t:[t]).map(S=>S<0?y.size+S:S),g=[];for(let S=0;S<y.size;S++)p.includes(S)||g.push(S);let h=j(n),b=new h(g.length);for(let S=0;S<g.length;S++){let D=y.get([g[S]]);B(n)?b[S]=typeof D=="bigint"?D:BigInt(D):b[S]=D}let A=N.fromData(b,[g.length],n);return new _(A)}let o=r.shape,a=o.length,i=e<0?a+e:e;if(i<0||i>=a)throw new Error(`axis ${e} is out of bounds for array of dimension ${a}`);let s=o[i],u=Array.isArray(t)?t:[t],c=new Set(u.map(y=>y<0?s+y:y)),l=[],m=0;for(let y=0;y<=s;y++)(c.has(y)||y===s)&&(y>m&&l.push([m,y]),m=y+1);if(l.length===0){let y=[...o];return y[i]=0,vr(y,n)}let d=[];for(let[y,f]of l){let p=o.map(()=>":");p[i]=`${y}:${f}`,d.push(r.slice(...p))}return Vr(d,i)}function zl(r,t,e,n){let o=e instanceof _?e:L(e,r.dtype);if(n===void 0){let m=r.flatten(),d=o.flatten(),y=t<0?m.size+t:t;if(y<0||y>m.size)throw new Error(`index ${t} is out of bounds for array of size ${m.size}`);let f=y>0?m.slice(`0:${y}`):null,p=y<m.size?m.slice(`${y}:`):null,g=[];return f&&g.push(f),g.push(d),p&&g.push(p),Vr(g)}let a=r.shape,i=a.length,s=n<0?i+n:n;if(s<0||s>=i)throw new Error(`axis ${n} is out of bounds for array of dimension ${i}`);let u=a[s],c=t<0?u+t:t;if(c<0||c>u)throw new Error(`index ${t} is out of bounds for axis ${n} with size ${u}`);let l=[];if(c>0){let m=a.map(()=>":");m[s]=`0:${c}`,l.push(r.slice(...m))}if(l.push(o),c<u){let m=a.map(()=>":");m[s]=`${c}:`,l.push(r.slice(...m))}return Vr(l,s)}function _l(r,t,e="constant",n=0){let o=r.shape,a=o.length,i=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 u=o.map((p,g)=>p+s[g][0]+s[g][1]),c=u.reduce((p,g)=>p*g,1),l=j(i),m=new l(c),d=B(i);e==="constant"&&(d?m.fill(BigInt(n)):m.fill(n));let y=new Array(a).fill(0);for(let p=0;p<c;p++){let g=!0,h=[];for(let A=0;A<a;A++){let[S]=s[A],D=y[A]-S;if(D<0||D>=o[A]){g=!1;break}h.push(D)}let b;if(g)b=r.get(h);else if(e==="constant"){for(let A=a-1;A>=0&&(y[A]++,!(y[A]<u[A]));A--)y[A]=0;continue}else{let A=[];for(let S=0;S<a;S++){let[D]=s[S],w=y[S]-D,x=o[S];w<0?e==="edge"?w=0:e==="reflect"?(w=-w,w>=x&&(w=x-1)):e==="symmetric"?(w=-w-1,w>=x&&(w=x-1),w<0&&(w=0)):e==="wrap"&&(w=(w%x+x)%x):w>=x&&(e==="edge"?w=x-1:e==="reflect"?(w=2*x-w-2,w<0&&(w=0)):e==="symmetric"?(w=2*x-w-1,w<0&&(w=0)):e==="wrap"&&(w=w%x)),A.push(Math.max(0,Math.min(x-1,w)))}b=r.get(A)}d?m[p]=typeof b=="bigint"?b:BigInt(Number(b)):m[p]=Number(b);for(let A=a-1;A>=0&&(y[A]++,!(y[A]<u[A]));A--)y[A]=0}let f=N.fromData(m,u,i);return new _(f)}function vl(r,t){let e=Yt(r.storage,t);return _._fromStorage(e,r.base??r)}function Fl(...r){let t=r.map(n=>n.storage);return qs(t).map((n,o)=>_._fromStorage(n,r[o].base??r[o]))}function Ml(...r){return ze(...r)}function Bl(r,t,e){return r.take(t,e)}function El(r,t,e){r.put(t,e)}function Tl(r,t,e=0){return r.iindex(t,e)}function Ol(r,t,e){return r.bindex(t,e)}function Cl(r,t,e){if(e!==void 0)throw new Error("copyto with where parameter is not yet implemented");let n=r.storage,o=r.shape,a=r.size,i=r.dtype;if(typeof t=="number"||typeof t=="bigint"){r.fill(t);return}let s=t.storage,u=t.shape,c=Sr([u,o]);if(!c)throw new Error(`could not broadcast input array from shape (${u.join(",")}) into shape (${o.join(",")})`);if(c.length!==o.length||!c.every((m,d)=>m===o[d]))throw new Error(`could not broadcast input array from shape (${u.join(",")}) into shape (${o.join(",")})`);let l=Yt(s,o);if(B(i))for(let m=0;m<a;m++){let d=l.iget(m),y=typeof d=="bigint"?d:BigInt(Math.round(Number(d)));n.iset(m,y)}else if(i==="bool")for(let m=0;m<a;m++){let d=l.iget(m);n.iset(m,d?1:0)}else for(let m=0;m<a;m++){let d=l.iget(m);n.iset(m,Number(d))}}function Ul(r,t){let e=t.map(o=>o.storage),n=js(r.storage,e);return _._fromStorage(n)}function $l(r,t,e=!1){return Ls(r.storage,t.storage,e)}function Rl(r,t){return ma(r.storage,t.storage)}function Kn(r,t){return _._fromStorage($e(r.storage,t))}function ro(r,t){return _._fromStorage(Re(r.storage,t))}function to(r,t,e=!1){return r.max(t,e)}function eo(r,t,e=!1){return r.min(t,e)}function kl(r,t,e=!1){let n=ke(r.storage,t,e);return typeof n=="number"||n instanceof E?n:_._fromStorage(n)}function ql(r,t,e=!1){let n=qe(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function Vl(r,t,e,n=!1){let o=Ve(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function Pl(r,t,e,n=!1){let o=tt(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function jl(r,t,e,n=!1){let o=e?e.storage:void 0,a=mt(r.storage,t,o,n);return typeof a=="number"||a instanceof E?a:_._fromStorage(a)}function Ll(r,t,e=!1){let n=Pt(r.storage,t,e);return typeof n=="number"||n instanceof E?n:_._fromStorage(n)}function Wl(r,t,e=!1){let n=jt(r.storage,t,e);return typeof n=="number"||n instanceof E?n:_._fromStorage(n)}function Gl(r,t,e=!1){let n=Lt(r.storage,t,e);return typeof n=="number"||n instanceof E?n:_._fromStorage(n)}function Zl(r,t,e=0,n=!1){let o=rt(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function Yl(r,t,e=0,n=!1){let o=Pe(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function Hl(r,t,e=!1){let n=pt(r.storage,t,e);return typeof n=="number"||n instanceof E?n:_._fromStorage(n)}function Xl(r,t,e=!1){let n=yt(r.storage,t,e);return typeof n=="number"||n instanceof E?n:_._fromStorage(n)}function Jl(r,t){let e=dt(r.storage,t);return typeof e=="number"?e:_._fromStorage(e)}function Ql(r,t){let e=gt(r.storage,t);return typeof e=="number"?e:_._fromStorage(e)}function Kl(r,t){return _._fromStorage(je(r.storage,t))}function rf(r,t){return _._fromStorage(Le(r.storage,t))}function tf(r,t,e=!1){let n=Wt(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)}function ef(r,t,e,n=!1){let o=At(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function nf(r,t,e,n=!1){let o=We(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)}function of(r){return r.cbrt()}function af(r){return r.fabs()}function sf(r,t){return r.divmod(t)}function uf(r){return r.square()}function cf(r,t){return r.remainder(t)}function lf(r,t){return r.heaviside(t)}function ff(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(qo(r.storage,e))}function mf(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(Vo(r.storage,e))}function pf(r){let[t,e]=Po(r.storage);return[_._fromStorage(t),_._fromStorage(e)]}function yf(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(jo(r.storage,e))}function df(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(Lo(r.storage,e))}function gf(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(Wo(r.storage,e))}function Af(r){let[t,e]=Go(r.storage);return[_._fromStorage(t),_._fromStorage(e)]}function bf(r,t,e){let n=t instanceof _?t.storage:t,o=e instanceof _?e.storage:e;return _._fromStorage(Zo(r.storage,n,o))}function hf(r,t){let e=t instanceof _?t.storage:t;return _._fromStorage(Yo(r.storage,e))}function Sf(r,t){let e=t instanceof _?t.storage:t;return _._fromStorage(Ho(r.storage,e))}function Df(r,t){let e=t instanceof _?t.storage:t;return _._fromStorage(Xo(r.storage,e))}function Nf(r,t){let e=t instanceof _?t.storage:t;return _._fromStorage(Jo(r.storage,e))}function xf(r,t=0,e,n){return _._fromStorage(Qo(r.storage,t,e,n))}function wf(r,t,e,n,o){return _._fromStorage(Ko(r.storage,t.storage,e.storage,n,o))}function If(r,t=Math.PI,e=-1,n=2*Math.PI){return _._fromStorage(ra(r.storage,t,e,n))}function zf(r){return _._fromStorage(ta(r.storage))}function _f(r){return _._fromStorage(ea(r.storage))}function vf(r,t){return r.bitwise_and(t)}function Ff(r,t){return r.bitwise_or(t)}function Mf(r,t){return r.bitwise_xor(t)}function Bf(r){return r.bitwise_not()}function Ef(r){return r.invert()}function Tf(r,t){return r.left_shift(t)}function Of(r,t){return r.right_shift(t)}function Cf(r,t=-1,e="big"){let n=yi(r.storage,t,e);return _._fromStorage(n)}function Uf(r,t=-1,e=-1,n="big"){let o=di(r.storage,t,e,n);return _._fromStorage(o)}function $f(r){return _._fromStorage(gi(r.storage))}function Rf(r){return _._fromStorage(Ai(r.storage))}function kf(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(bi(r.storage,e))}function qf(r,t){let e=typeof t=="number"?t:t.storage;return _._fromStorage(hi(r.storage,e))}function Vf(r,t){return r.logical_and(t)}function Pf(r,t){return r.logical_or(t)}function jf(r){return r.logical_not()}function Lf(r,t){return r.logical_xor(t)}function Wf(r){return r.isfinite()}function Gf(r){return r.isinf()}function Zf(r){return r.isnan()}function Yf(r){return r.isnat()}function Hf(r,t){return r.copysign(t)}function Xf(r){return r.signbit()}function Jf(r,t){return r.nextafter(t)}function Qf(r){return r.spacing()}function Kf(r){return _._fromStorage(Oi(r.storage))}function rm(r){return Ci(r.storage)}function tm(r){return _._fromStorage(Ui(r.storage))}function em(r){return $i(r.storage)}function nm(r){return _._fromStorage(Zi(r.storage))}function om(r){return _._fromStorage(Yi(r.storage))}function no(r){return _._fromStorage(Hi(r.storage))}function sm(r,t=!1){return _._fromStorage(Xi(r.storage,t))}function im(r){return _._fromStorage(Ri(r.storage))}function um(r){return _._fromStorage(ki(r.storage))}function cm(r){return qi(r.storage)}function lm(r,t=100){return _._fromStorage(Vi(r.storage,t))}function fm(r){return Pi(r)}function mm(r){return ji(r)}function pm(r,t){return Li(r,t)}function ym(r,t){return Wi(r,t)}function dm(r,...t){let e=t.map(o=>o.storage),n=Va(r,...e);return typeof n=="number"||typeof n=="bigint"||n instanceof E?n:_._fromStorage(n)}function gm(r,t){return rs(r.storage,t.storage)}function Am(r,t,e=-1){let n=sn(r.storage,t.storage,e);return typeof n=="number"||typeof n=="bigint"||n instanceof E?n:_._fromStorage(n)}function bm(r){return _._fromStorage(un(r.storage))}function hm(r,t){return _._fromStorage(ts(r.storage,t))}function Sm(r,t){return _._fromStorage(es(r.storage,t.storage))}function Dm(r,t){return _._fromStorage(ns(r.storage,t.storage))}function xm(r,t,e){return _._fromStorage(Ws(r.storage,t.storage,e))}function wm(r,t,e,n){Gs(r.storage,t.storage,e.storage,n)}function Im(r,t,e){let n=e instanceof _?e.storage:e;Zs(r.storage,t.storage,n)}function zm(r,t,e){return _._fromStorage(cn(r.storage,t.storage,e))}function _m(r,t,e=0){let n=r.map(a=>a.storage),o=t.map(a=>a.storage);return _._fromStorage(Ys(n,o,e))}function vm(r,t,e){Hs(r.storage,t.storage,e.storage)}function Fm(r,t,e=!1){let n=typeof t=="number"?t:t.storage;oi(r.storage,n,e)}function Mm(r,t=2){return ln(r,t).map(n=>_._fromStorage(n))}function Bm(r){return Xs(r.storage).map(e=>_._fromStorage(e))}function Em(r,t=0,e){return fn(r,t,e).map(o=>_._fromStorage(o))}function Tm(r,t=0){return Js(r.storage,t).map(n=>_._fromStorage(n))}function Om(r,t=0,e){return mn(r,t,e).map(o=>_._fromStorage(o))}function Cm(r,t=0){return Qs(r.storage,t).map(n=>_._fromStorage(n))}function Um(r,t,e=0){return Ks(r,(a,i)=>t(a,i).storage,e).map(a=>_._fromStorage(a))}function $m(r,t="int32"){return _._fromStorage(ri(r,t))}function Rm(...r){return ti(...r.map(e=>e.storage)).map(e=>_._fromStorage(e))}function km(r,t,e="raise"){let n=r.map(o=>o.storage);return _._fromStorage(ei(n,t,e))}function qm(r,t,e="C"){let n=r instanceof _?r.storage:r;return ni(n,t,e).map(a=>_._fromStorage(a))}function Vm(r,t=-1){return _._fromStorage(bn(r.storage,t))}function Pm(r,t=-1){return _._fromStorage(hn(r.storage,t))}function jm(r){let t=r.map(e=>e.storage);return _._fromStorage(Qi(t))}function Lm(r,t,e=-1){return _._fromStorage(Sn(r.storage,t,e))}function Wm(r,t,e=-1){return _._fromStorage(Dn(r.storage,t,e))}function Gm(r){return _._fromStorage(Ki(r.storage))}function Zm(r){return Kt(r.storage).map(e=>_._fromStorage(e))}function Ym(r){return _._fromStorage(Nn(r.storage))}function Hm(r){return _._fromStorage(ru(r.storage))}function Xm(r,t,e){let n=tu(r.storage,t?.storage,e?.storage);return Array.isArray(n)?n.map(o=>_._fromStorage(o)):_._fromStorage(n)}function Jm(r,t,e="left"){return _._fromStorage(xn(r.storage,t.storage,e))}function Qm(r,t){return _._fromStorage(eu(r.storage,t.storage))}function Km(r,t){let e=wn(r.storage,t);return typeof e=="number"?e:_._fromStorage(e)}function te(r,t=0){return _._fromStorage(In(r.storage,t))}function rp(r){return _._fromStorage(zn(r.storage))}function tp(r){return _._fromStorage(_n(r.storage))}function ep(r){return _._fromStorage(vn(r.storage))}function np(r){return _._fromStorage(Fn(r.storage))}function op(r){return _._fromStorage(Mn(r.storage))}function ap(r,t=!1,e=!1,n=!1){let o=yr(r.storage,t,e,n);if(o instanceof N)return _._fromStorage(o);let a={values:_._fromStorage(o.values)};return o.indices&&(a.indices=_._fromStorage(o.indices)),o.inverse&&(a.inverse=_._fromStorage(o.inverse)),o.counts&&(a.counts=_._fromStorage(o.counts)),a}function sp(r,t){return _._fromStorage(su(r.storage,t.storage))}function ip(r,t){return _._fromStorage(iu(r.storage,t.storage))}function up(r,t){return _._fromStorage(En(r.storage,t.storage))}function cp(r,t){return _._fromStorage(uu(r.storage,t.storage))}function lp(r,t){return _._fromStorage(cu(r.storage,t.storage))}function fp(r,t){return _._fromStorage(lu(r.storage,t.storage))}function mp(r,t="fb"){return _._fromStorage(fu(r.storage,t))}function pp(r){let t=mu(r.storage);return{values:_._fromStorage(t.values),indices:_._fromStorage(t.indices),inverse_indices:_._fromStorage(t.inverse_indices),counts:_._fromStorage(t.counts)}}function yp(r){let t=pu(r.storage);return{values:_._fromStorage(t.values),counts:_._fromStorage(t.counts)}}function dp(r){let t=yu(r.storage);return{values:_._fromStorage(t.values),inverse_indices:_._fromStorage(t.inverse_indices)}}function gp(r){return _._fromStorage(du(r.storage))}function Ap(r,t=1,e=-1){return _._fromStorage(Tn(r.storage,t,e))}function bp(r,t=null,e=null){return _._fromStorage(Au(r.storage,t,e))}function hp(r,t=1,e=null){let n=bu(r.storage,t,e);return Array.isArray(n)?n.map(o=>_._fromStorage(o)):_._fromStorage(n)}function Sp(r,t,e=-1,n=-1,o=-1){return _._fromStorage(hu(r.storage,t.storage,e,n,o))}function Dp(r,t,e=0){return _._fromStorage(Du(r.storage,t?.storage,e))}function Np(r,t,e=!1){return _._fromStorage(Nu(r.storage,t.storage,e))}function xp(r,t=10,e,n=!1,o){let a=xu(r.storage,typeof t=="number"?t:t.storage,e,n,o?.storage);return[_._fromStorage(a.hist),_._fromStorage(a.bin_edges)]}function wp(r,t,e=10,n,o=!1,a){let i;typeof e=="number"?i=e:Array.isArray(e)&&e.length===2?typeof e[0]=="number"?i=e:i=[e[0].storage,e[1].storage]:i=10;let s=wu(r.storage,t.storage,i,n,o,a?.storage);return[_._fromStorage(s.hist),_._fromStorage(s.x_edges),_._fromStorage(s.y_edges)]}function Ip(r,t=10,e,n=!1,o){let a=Iu(r.storage,t,e,n,o?.storage);return[_._fromStorage(a.hist),a.edges.map(i=>_._fromStorage(i))]}function zp(r,t,e="full"){return _._fromStorage(Cn(r.storage,t.storage,e))}function _p(r,t,e="full"){return _._fromStorage(zu(r.storage,t.storage,e))}function vp(r,t,e=!0,n=!1,o){return _._fromStorage(Un(r.storage,t?.storage,e,n,o))}function Fp(r,t,e=!0){return _._fromStorage(_u(r.storage,t?.storage,e))}function Mp(r,t=10,e,n){return _._fromStorage(vu(r.storage,t,e,n?.storage))}function Bp(r,t,e=1,n=-1){let o=Fu(r.storage,t?.storage,e,n);return typeof o=="number"?o:_._fromStorage(o)}function Ep(r,t,e){let n=o=>{let a=r(_._fromStorage(o));return a instanceof _?a.storage:a};return _._fromStorage(ai(e.storage,t,n))}function Tp(r,t,e){let n=(o,a)=>r(_._fromStorage(o),a).storage;return _._fromStorage(si(t.storage,n,e))}function Op(r,t){return pn(r.storage,t.storage)}function Cp(r,t){return ii(r.storage,t.storage)}function Up(r){if(typeof r=="number")return 0;if(r instanceof _)return r.ndim;let t=0,e=r;for(;Array.isArray(e);)t++,e=e[0];return t}function oo(r){if(typeof r=="number")return[];if(r instanceof _)return Array.from(r.shape);let t=[],e=r;for(;Array.isArray(e);)t.push(e.length),e=e[0];return t}function $p(r){return typeof r=="number"?1:r instanceof _?r.size:oo(r).reduce((e,n)=>e*n,1)}function Rp(r,t,e="safe"){let n=r instanceof _?r.dtype:r;if(n===t)return!0;switch(e){case"no":return!1;case"equiv":return n===t;case"safe":return n==="bool"?!0:M(n)?M(t)?qr[n]<=qr[t]:!1:M(t)?!0:(cr[n]==="i"||cr[n]==="u")&&cr[t]==="f"?t==="float32"?["int8","int16","uint8","uint16"].includes(n):t==="float64":cr[n]==="f"&&cr[t]==="f"||(cr[n]==="i"||cr[n]==="u")&&(cr[t]==="i"||cr[t]==="u")?qr[n]<=qr[t]:!1;case"same_kind":{let o=cr[n],a=cr[t];return n==="bool"&&(a==="i"||a==="u"||a==="b")||o===a||(o==="i"||o==="u")&&(a==="i"||a==="u")||o==="f"&&a==="c"}case"unsafe":return!0;default:return!1}}function kp(...r){if(r.length===0)return"float64";let t=!1,e=32;for(let n of r){let o=n.dtype;M(o)?(t=!0,o==="complex128"&&(e=64)):(o==="float64"||o==="int64"||o==="uint64")&&(e=64)}return t?e===64?"complex128":"complex64":e===64?"float64":"float32"}function qp(...r){if(r.length===0)return"float64";let t=r.map(n=>n instanceof _?n.dtype:n),e=t[0];for(let n=1;n<t.length;n++)e=Vp(e,t[n]);return e}function Vp(r,t){if(r===t)return r;if(r==="bool")return t;if(t==="bool")return r;if(M(r)||M(t)){if(M(r)&&M(t))return r==="complex128"||t==="complex128"?"complex128":"complex64";let i=M(r)?r:t,s=M(r)?t:r;return i==="complex128"||s==="float64"||s==="int64"||s==="uint64"?"complex128":"complex64"}let e=cr[r]==="f",n=cr[t]==="f";if(e||n){if(r==="float64"||t==="float64")return"float64";if(r==="float32"||t==="float32"){let i=e?t:r;return["int32","int64","uint32","uint64"].includes(i)?"float64":"float32"}}let o=cr[r],a=cr[t];if(o==="i"&&a==="u"||o==="u"&&a==="i"){let i=o==="u"?r:t;if(i==="uint64")return"float64";if(i==="uint32")return"int64";if(i==="uint16")return"int32";if(i==="uint8")return"int16"}return qr[r]>=qr[t]?r:t}function Pp(r){return typeof r=="boolean"?"bool":typeof r=="bigint"?r>=0n?r<=255n?"uint8":r<=65535n?"uint16":r<=4294967295n?"uint32":"uint64":r>=-128n&&r<=127n?"int8":r>=-32768n&&r<=32767n?"int16":r>=-2147483648n&&r<=2147483647n?"int32":"int64":!Number.isFinite(r)||!Number.isInteger(r)?"float64":r>=0?r<=255?"uint8":r<=65535?"uint16":r<=4294967295?"uint32":"float64":r>=-128&&r<=127?"int8":r>=-32768&&r<=32767?"int16":r>=-2147483648&&r<=2147483647?"int32":"float64"}function jp(r,t){let e=r instanceof _?r.dtype:r;return t==="integer"?["int8","int16","int32","int64","uint8","uint16","uint32","uint64"].includes(e):t==="signedinteger"?["int8","int16","int32","int64"].includes(e):t==="unsignedinteger"?["uint8","uint16","uint32","uint64"].includes(e):t==="floating"?["float32","float64"].includes(e):t==="complexfloating"?["complex64","complex128"].includes(e):t==="number"||t==="numeric"?!["bool"].includes(e):t==="inexact"?["float32","float64","complex64","complex128"].includes(e):e===t}function Lp(r){return{bool:"bool",uint8:"uint8",uint16:"uint16",uint32:"uint32",uint64:"uint64",int8:"int8",int16:"int16",int32:"int32",int64:"int64",float32:"float32",float64:"float64",complex64:"complex64",complex128:"complex128"}[r]||r}function Wp(r,t="GDFgdf",e="d"){let n={b:"int8",B:"uint8",h:"int16",H:"uint16",i:"int32",I:"uint32",l:"int64",L:"uint64",f:"float32",d:"float64",F:"complex64",D:"complex128",g:"float64",G:"complex128","?":"bool"},o={int8:"b",uint8:"B",int16:"h",uint16:"H",int32:"i",uint32:"I",int64:"l",uint64:"L",float32:"f",float64:"d",complex64:"F",complex128:"D",bool:"?"},a=[];for(let l of r)n[l]&&a.push(n[l]);if(a.length===0)return e;let i=a[0];for(let l=1;l<a.length;l++)i=Vp(i,a[l]);let s=new Set(t),u=o[i]||e;if(s.has(u)||s.size===0)return u;let c="gfdGFD";for(let l of c)if(s.has(l))return l;return e}function Gp(r){let t=r instanceof _?r.toArray().flat():r;if(t.length===0)return L([1]);let e=[1];for(let n of t){let o=new Array(e.length+1).fill(0);for(let a=0;a<e.length;a++)o[a]+=e[a],o[a+1]-=e[a]*n;e=o}return L(e)}function Zp(r,t){let e=r instanceof _?r.toArray().flat():r,n=t instanceof _?t.toArray().flat():t,o=Math.max(e.length,n.length),a=new Array(o).fill(0);for(let i=0;i<e.length;i++)a[o-e.length+i]+=e[i];for(let i=0;i<n.length;i++)a[o-n.length+i]+=n[i];return L(a)}function Yp(r,t=1){let e=r instanceof _?r.toArray().flat():[...r];for(let n=0;n<t;n++){if(e.length<=1)return L([0]);let o=new Array(e.length-1),a=e.length-1;for(let i=0;i<a;i++)o[i]=e[i]*(a-i);e=o}return L(e)}function Hp(r,t){let e=r instanceof _?r.toArray().flat():[...r],n=t instanceof _?t.toArray().flat():[...t];if(n.length===0||n.length===1&&n[0]===0)throw new Error("Division by zero polynomial");for(;e.length>1&&e[0]===0;)e.shift();for(;n.length>1&&n[0]===0;)n.shift();if(e.length<n.length)return[L([0]),L(e)];let o=[],a=[...e];for(;a.length>=n.length;){let i=a[0]/n[0];o.push(i);for(let s=0;s<n.length;s++)a[s]=a[s]-i*n[s];a.shift()}return a.length===0||a.every(i=>Math.abs(i)<1e-14)?[L(o.length>0?o:[0]),L([0])]:[L(o.length>0?o:[0]),L(a)]}function Xp(r,t,e){let n=r.toArray().flat(),o=t.toArray().flat(),a=n.length;if(a!==o.length)throw new Error("x and y must have the same length");if(e<0)throw new Error("Degree must be non-negative");if(a<=e)throw new Error("Need more data points than degree");let i=[];for(let m=0;m<a;m++){let d=[];for(let y=e;y>=0;y--)d.push(Math.pow(n[m],y));i.push(d)}let s=Bg(i),u=Jp(s,i),c=Eg(s,o),l=Tg(u,c);return L(l)}function Bg(r){let t=r.length,e=r[0].length,n=[];for(let o=0;o<e;o++){let a=[];for(let i=0;i<t;i++)a.push(r[i][o]);n.push(a)}return n}function Jp(r,t){let e=r.length,n=r[0].length,o=t[0].length,a=[];for(let i=0;i<e;i++){let s=[];for(let u=0;u<o;u++){let c=0;for(let l=0;l<n;l++)c+=r[i][l]*t[l][u];s.push(c)}a.push(s)}return a}function Eg(r,t){let e=[];for(let n=0;n<r.length;n++){let o=0;for(let a=0;a<r[n].length;a++)o+=r[n][a]*t[a];e.push(o)}return e}function Tg(r,t){let e=r.length,n=r.map((a,i)=>[...a,t[i]]);for(let a=0;a<e;a++){let i=a;for(let s=a+1;s<e;s++)Math.abs(n[s][a])>Math.abs(n[i][a])&&(i=s);[n[a],n[i]]=[n[i],n[a]];for(let s=a+1;s<e;s++){let u=n[s][a]/n[a][a];for(let c=a;c<=e;c++)n[s][c]=n[s][c]-u*n[a][c]}}let o=new Array(e).fill(0);for(let a=e-1;a>=0;a--){o[a]=n[a][e];for(let i=a+1;i<e;i++)o[a]-=n[a][i]*o[i];o[a]/=n[a][a]}return o}function Qp(r,t=1,e=0){let n=r instanceof _?r.toArray().flat():[...r],o=Array.isArray(e)?e:[e];for(let a=0;a<t;a++){let i=n.length,s=new Array(i+1);for(let u=0;u<i;u++)s[u]=n[u]/(i-u);s[i]=o[a]!==void 0?o[a]:0,n=s}return L(n)}function Kp(r,t){let e=r instanceof _?r.toArray().flat():r,n=t instanceof _?t.toArray().flat():t,o=e.length+n.length-1,a=new Array(o).fill(0);for(let i=0;i<e.length;i++)for(let s=0;s<n.length;s++)a[i+s]+=e[i]*n[s];return L(a)}function ry(r,t){let e=r instanceof _?r.toArray().flat():r,n=t instanceof _?t.toArray().flat():t,o=Math.max(e.length,n.length),a=new Array(o).fill(0);for(let i=0;i<e.length;i++)a[o-e.length+i]+=e[i];for(let i=0;i<n.length;i++)a[o-n.length+i]-=n[i];return L(a)}function ty(r,t){let e=r instanceof _?r.toArray().flat():r,n=i=>{let s=0;for(let u of e)s=s*i+u;return s};if(typeof t=="number")return n(t);let a=(t instanceof _?t.toArray().flat():t).map(n);return L(a)}function ey(r){let t=r instanceof _?r.toArray().flat():[...r];for(;t.length>1&&t[0]===0;)t.shift();let e=t.length-1;if(e<=0)return L([]);let n=t[0],o=t.map(u=>u/n);if(e===1)return L([-o[1]]);if(e===2){let c=o[1],l=o[2],m=c*c-4*l;if(m>=0){let d=Math.sqrt(m);return L([(-c+d)/2,(-c-d)/2])}else{let d=-c/2;return L([d,d])}}let a=e,i=[];for(let u=0;u<a;u++){let c=new Array(a).fill(0);u<a-1&&(c[u+1]=1),i.push(c)}for(let u=0;u<a;u++)i[a-1][u]=-o[a-u];let s=Og(i);return L(s)}function Og(r){let t=r.length,e=[...r.map(i=>[...i])],n=100,o=1e-10;for(let i=0;i<n;i++){let{Q:s,R:u}=Cg(e);e=Jp(u,s);let c=0;for(let l=1;l<t;l++)c=Math.max(c,Math.abs(e[l][l-1]));if(c<o)break}let a=[];for(let i=0;i<t;i++)a.push(e[i][i]);return a}function Cg(r){let t=r.length,e=r.map(o=>[...o]),n=Array.from({length:t},()=>new Array(t).fill(0));for(let o=0;o<t;o++){for(let i=0;i<o;i++){let s=0;for(let u=0;u<t;u++)s+=e[u][i]*r[u][o];n[i][o]=s;for(let u=0;u<t;u++)e[u][o]=e[u][o]-s*e[u][i]}let a=0;for(let i=0;i<t;i++)a+=e[i][o]*e[i][o];if(a=Math.sqrt(a),n[o][o]=a,a>1e-14)for(let i=0;i<t;i++)e[i][o]=e[i][o]/a}return{Q:e,R:n}}var _,am,Nm,qr,cr,vt=G(()=>{"use strict";Do();Q();xr();K();Rt();na();pa();da();He();cs();Ds();Es();ks();dn();Si();Gi();Ji();nu();au();gu();Su();Mu();dn();_=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(){return this.transpose()}get itemsize(){return Hr(this._storage.dtype)}get nbytes(){return this.size*this.itemsize}fill(t){let e=this._storage.dtype,n=this.size;if(B(e)){let o=typeof t=="bigint"?t:BigInt(Math.round(Number(t)));for(let a=0;a<n;a++)this._storage.iset(a,o)}else if(e==="bool"){let o=t?1:0;for(let a=0;a<n;a++)this._storage.iset(a,o)}else{let o=Number(t);for(let a=0;a<n;a++)this._storage.iset(a,o)}}*[Symbol.iterator](){if(this.ndim===0)yield this._storage.iget(0);else if(this.ndim===1)for(let t=0;t<this.shape[0];t++)yield this._storage.iget(t);else for(let t=0;t<this.shape[0];t++)yield this.slice(String(t))}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((a,i)=>{let s=a;if(s<0&&(s=this.shape[i]+s),s<0||s>=this.shape[i])throw new Error(`Index ${a} is out of bounds for axis ${i} with size ${this.shape[i]}`);return s}),o=this.dtype;if(M(o))this._storage.set(n,e);else if(B(o)){let a=e instanceof E?e.re:Number(e),i=typeof e=="bigint"?e:BigInt(Math.round(a));this._storage.set(n,i)}else if(o==="bool"){let i=(e instanceof E?e.re:Number(e))?1:0;this._storage.set(n,i)}else{let a=e instanceof E?e.re: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,i=j(t);if(!i)throw new Error(`Cannot convert to dtype ${t}`);let s=new i(a),u=this.data;if(B(n)&&!B(t)){let l=u;if(t==="bool")for(let m=0;m<a;m++)s[m]=l[m]!==BigInt(0)?1:0;else for(let m=0;m<a;m++)s[m]=Number(l[m])}else if(!B(n)&&B(t)){let l=u;for(let m=0;m<a;m++)s[m]=BigInt(Math.round(Number(l[m])))}else if(t==="bool"){let l=u;for(let m=0;m<a;m++)s[m]=l[m]!==0?1:0}else if(n==="bool"&&!B(t)){let l=u;for(let m=0;m<a;m++)s[m]=l[m]}else if(!B(n)&&!B(t)){let l=u;for(let m=0;m<a;m++)s[m]=l[m]}else{let l=u;for(let m=0;m<a;m++)s[m]=l[m]}let c=N.fromData(s,o,t);return new r(c)}add(t){let e=typeof t=="number"?t:t._storage,n=Io(this._storage,e);return r._fromStorage(n)}subtract(t){let e=typeof t=="number"?t:t._storage,n=zo(this._storage,e);return r._fromStorage(n)}multiply(t){let e=typeof t=="number"?t:t._storage,n=_o(this._storage,e);return r._fromStorage(n)}divide(t){let e=typeof t=="number"?t:t._storage,n=vo(this._storage,e);return r._fromStorage(n)}mod(t){let e=typeof t=="number"?t:t._storage,n=qt(this._storage,e);return r._fromStorage(n)}floor_divide(t){let e=typeof t=="number"?t:t._storage,n=ve(this._storage,e);return r._fromStorage(n)}positive(){let t=Eo(this._storage);return r._fromStorage(t)}reciprocal(){let t=To(this._storage);return r._fromStorage(t)}sqrt(){let t=ls(this._storage);return r._fromStorage(t)}power(t){let e=typeof t=="number"?t:t._storage,n=fs(this._storage,e);return r._fromStorage(n)}exp(){let t=ms(this._storage);return r._fromStorage(t)}exp2(){let t=ps(this._storage);return r._fromStorage(t)}expm1(){let t=ys(this._storage);return r._fromStorage(t)}log(){let t=ds(this._storage);return r._fromStorage(t)}log2(){let t=gs(this._storage);return r._fromStorage(t)}log10(){let t=As(this._storage);return r._fromStorage(t)}log1p(){let t=bs(this._storage);return r._fromStorage(t)}logaddexp(t){let e=typeof t=="number"?t:t._storage,n=hs(this._storage,e);return r._fromStorage(n)}logaddexp2(t){let e=typeof t=="number"?t:t._storage,n=Ss(this._storage,e);return r._fromStorage(n)}absolute(){let t=Fo(this._storage);return r._fromStorage(t)}negative(){let t=Mo(this._storage);return r._fromStorage(t)}sign(){let t=Bo(this._storage);return r._fromStorage(t)}around(t=0){let e=In(this._storage,t);return r._fromStorage(e)}round(t=0){return this.around(t)}ceil(){let t=zn(this._storage);return r._fromStorage(t)}fix(){let t=_n(this._storage);return r._fromStorage(t)}floor(){let t=vn(this._storage);return r._fromStorage(t)}rint(){let t=Fn(this._storage);return r._fromStorage(t)}trunc(){let t=Mn(this._storage);return r._fromStorage(t)}sin(){let t=Ns(this._storage);return r._fromStorage(t)}cos(){let t=xs(this._storage);return r._fromStorage(t)}tan(){let t=ws(this._storage);return r._fromStorage(t)}arcsin(){let t=Is(this._storage);return r._fromStorage(t)}arccos(){let t=zs(this._storage);return r._fromStorage(t)}arctan(){let t=_s(this._storage);return r._fromStorage(t)}arctan2(t){let e=typeof t=="number"?t:t._storage,n=vs(this._storage,e);return r._fromStorage(n)}hypot(t){let e=typeof t=="number"?t:t._storage,n=Fs(this._storage,e);return r._fromStorage(n)}degrees(){let t=Ms(this._storage);return r._fromStorage(t)}radians(){let t=Bs(this._storage);return r._fromStorage(t)}sinh(){let t=Ts(this._storage);return r._fromStorage(t)}cosh(){let t=Os(this._storage);return r._fromStorage(t)}tanh(){let t=Cs(this._storage);return r._fromStorage(t)}arcsinh(){let t=Us(this._storage);return r._fromStorage(t)}arccosh(){let t=$s(this._storage);return r._fromStorage(t)}arctanh(){let t=Rs(this._storage);return r._fromStorage(t)}greater(t){let e=typeof t=="number"?t:t._storage,n=aa(this._storage,e);return r._fromStorage(n)}greater_equal(t){let e=typeof t=="number"?t:t._storage,n=sa(this._storage,e);return r._fromStorage(n)}less(t){let e=typeof t=="number"?t:t._storage,n=ia(this._storage,e);return r._fromStorage(n)}less_equal(t){let e=typeof t=="number"?t:t._storage,n=ua(this._storage,e);return r._fromStorage(n)}equal(t){let e=typeof t=="number"?t:t._storage,n=ca(this._storage,e);return r._fromStorage(n)}not_equal(t){let e=typeof t=="number"?t:t._storage,n=la(this._storage,e);return r._fromStorage(n)}isclose(t,e=1e-5,n=1e-8){let o=typeof t=="number"?t:t._storage,a=Fe(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 fa(this._storage,o,e,n)}bitwise_and(t){let e=typeof t=="number"?t:t._storage,n=li(this._storage,e);return r._fromStorage(n)}bitwise_or(t){let e=typeof t=="number"?t:t._storage,n=fi(this._storage,e);return r._fromStorage(n)}bitwise_xor(t){let e=typeof t=="number"?t:t._storage,n=mi(this._storage,e);return r._fromStorage(n)}bitwise_not(){let t=Jt(this._storage);return r._fromStorage(t)}invert(){let t=pi(this._storage);return r._fromStorage(t)}left_shift(t){let e=typeof t=="number"?t:t._storage,n=gn(this._storage,e);return r._fromStorage(n)}right_shift(t){let e=typeof t=="number"?t:t._storage,n=An(this._storage,e);return r._fromStorage(n)}logical_and(t){let e=typeof t=="number"?t:t._storage,n=Ni(this._storage,e);return r._fromStorage(n)}logical_or(t){let e=typeof t=="number"?t:t._storage,n=xi(this._storage,e);return r._fromStorage(n)}logical_not(){let t=wi(this._storage);return r._fromStorage(t)}logical_xor(t){let e=typeof t=="number"?t:t._storage,n=Ii(this._storage,e);return r._fromStorage(n)}isfinite(){let t=zi(this._storage);return r._fromStorage(t)}isinf(){let t=_i(this._storage);return r._fromStorage(t)}isnan(){let t=vi(this._storage);return r._fromStorage(t)}isnat(){let t=Fi(this._storage);return r._fromStorage(t)}copysign(t){let e=typeof t=="number"?t:t._storage,n=Mi(this._storage,e);return r._fromStorage(n)}signbit(){let t=Bi(this._storage);return r._fromStorage(t)}nextafter(t){let e=typeof t=="number"?t:t._storage,n=Ei(this._storage,e);return r._fromStorage(n)}spacing(){let t=Ti(this._storage);return r._fromStorage(t)}sum(t,e=!1){let n=ft(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}mean(t,e=!1){let n=Vt(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}max(t,e=!1){let n=Qr(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}min(t,e=!1){let n=Kr(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}prod(t,e=!1){let n=Be(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}argmin(t){let e=Ee(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}argmax(t){let e=Te(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}var(t,e=0,n=!1){let o=Oe(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}std(t,e=0,n=!1){let o=ya(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}all(t,e=!1){let n=Ce(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}any(t,e=!1){let n=Ue(this._storage,t,e);return typeof n=="boolean"?n:r._fromStorage(n)}cumsum(t){return r._fromStorage($e(this._storage,t))}cumprod(t){return r._fromStorage(Re(this._storage,t))}ptp(t,e=!1){let n=ke(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}median(t,e=!1){let n=qe(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}percentile(t,e,n=!1){let o=Ve(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}quantile(t,e,n=!1){let o=tt(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}average(t,e){let n=mt(this._storage,e,t?.storage);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}nansum(t,e=!1){let n=Pt(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}nanprod(t,e=!1){let n=jt(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}nanmean(t,e=!1){let n=Lt(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}nanvar(t,e=0,n=!1){let o=rt(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanstd(t,e=0,n=!1){let o=Pe(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanmin(t,e=!1){let n=pt(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}nanmax(t,e=!1){let n=yt(this._storage,t,e);return typeof n=="number"||n instanceof E?n:r._fromStorage(n)}nanquantile(t,e,n=!1){let o=At(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanpercentile(t,e,n=!1){let o=We(this._storage,t,e,n);return typeof o=="number"?o:r._fromStorage(o)}nanargmin(t){let e=dt(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}nanargmax(t){let e=gt(this._storage,t);return typeof e=="number"?e:r._fromStorage(e)}nancumsum(t){return r._fromStorage(je(this._storage,t))}nancumprod(t){return r._fromStorage(Le(this._storage,t))}nanmedian(t,e=!1){let n=Wt(this._storage,t,e);return typeof n=="number"?n:r._fromStorage(n)}sort(t=-1){return r._fromStorage(bn(this._storage,t))}argsort(t=-1){return r._fromStorage(hn(this._storage,t))}partition(t,e=-1){return r._fromStorage(Sn(this._storage,t,e))}argpartition(t,e=-1){return r._fromStorage(Dn(this._storage,t,e))}nonzero(){return Kt(this._storage).map(e=>r._fromStorage(e))}argwhere(){return r._fromStorage(Nn(this._storage))}searchsorted(t,e="left"){return r._fromStorage(xn(this._storage,t._storage,e))}diff(t=1,e=-1){return r._fromStorage(Tn(this._storage,t,e))}reshape(...t){let e=t.length===1&&Array.isArray(t[0])?t[0]:t,n=er(this._storage,e),a=n.data===this.data?this._base??this:void 0;return r._fromStorage(n,a)}flatten(){let t=Lr(this._storage);return r._fromStorage(t)}ravel(){let t=et(this._storage),n=t.data===this.data?this._base??this:void 0;return r._fromStorage(t,n)}transpose(t){let e=ht(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}squeeze(t){let e=Ge(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}expand_dims(t){let e=bt(this._storage,t),n=this._base??this;return r._fromStorage(e,n)}swapaxes(t,e){let n=ga(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}moveaxis(t,e){let n=Ze(this._storage,t,e),o=this._base??this;return r._fromStorage(n,o)}repeat(t,e){let n=Ia(this._storage,t,e);return r._fromStorage(n)}take(t,e){let n=Vs(this._storage,t,e);return r._fromStorage(n)}put(t,e){let n=e instanceof r?e._storage:e;Ps(this._storage,t,n)}iindex(t,e=0){let n;if(t instanceof r){n=[];for(let o=0;o<t.size;o++){let a=t.storage.iget(o),i=typeof a=="bigint"?Number(a):a instanceof E?a.re:a;n.push(i)}}else Array.isArray(t)&&t.length>0&&Array.isArray(t[0])?n=t.flat():n=t;return this.take(n,e)}bindex(t,e){return r._fromStorage(cn(t._storage,this._storage,e))}matmul(t){let e=mr(this._storage,t._storage);return r._fromStorage(e)}dot(t){let e=ot(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"||e instanceof E?e:r._fromStorage(e)}trace(){return Je(this._storage)}inner(t){let e=qa(this._storage,t._storage);return typeof e=="number"||typeof e=="bigint"||e instanceof E?e:r._fromStorage(e)}outer(t){let e=Gt(this._storage,t._storage);return r._fromStorage(e)}tensordot(t,e=2){let n=Qe(this._storage,t._storage,e);return typeof n=="number"||typeof n=="bigint"||n instanceof E?n:r._fromStorage(n)}cbrt(){let t=Oo(this._storage);return r._fromStorage(t)}fabs(){let t=Co(this._storage);return r._fromStorage(t)}divmod(t){let e=typeof t=="number"?t:t._storage,[n,o]=Uo(this._storage,e);return[r._fromStorage(n),r._fromStorage(o)]}square(){let t=$o(this._storage);return r._fromStorage(t)}remainder(t){let e=typeof t=="number"?t:t._storage,n=Ro(this._storage,e);return r._fromStorage(n)}heaviside(t){let e=typeof t=="number"?t:t._storage,n=ko(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((u,c)=>{let l=ho(u);return So(l,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 u=0;u<e.length;u++){let c=e[u],l=this._storage.strides[u];if(a+=c.start*l,!c.isIndex){let m;c.step>0?m=Math.max(0,Math.ceil((c.stop-c.start)/c.step)):m=Math.max(0,Math.ceil((c.start-c.stop)/Math.abs(c.step))),n.push(m),o.push(l*c.step)}}let i=N.fromData(this._storage.data,n,this._storage.dtype,o,a),s=this._base??this;return new r(i,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 i=[];for(let s=0;s<t[a];s++)o[a]=s,i.push(n(o,a+1));return i};return n(new Array(e),0)}tolist(){return this.toArray()}tobytes(){if(this._storage.isCContiguous){let n=this._storage.data,o=n.BYTES_PER_ELEMENT,a=this._storage.offset*o,i=this.size*o;return n.buffer.slice(a,a+i)}let e=this.copy()._storage.data;return e.buffer.slice(0,this.size*e.BYTES_PER_ELEMENT)}item(...t){if(t.length===0){if(this.size!==1)throw new Error("can only convert an array of size 1 to a Python scalar");return this._storage.iget(0)}if(t.length===1){let e=t[0];if(e<0||e>=this.size)throw new Error(`index ${e} is out of bounds for size ${this.size}`);return this._storage.iget(e)}return this.get(t)}byteswap(t=!1){let e=t?this:this.copy(),n=e._storage.data,o=n.BYTES_PER_ELEMENT;if(o===1)return e;let a=n.buffer,i=new DataView(a);for(let s=0;s<n.length;s++){let u=s*o;if(o===2){let c=i.getUint8(u),l=i.getUint8(u+1);i.setUint8(u,l),i.setUint8(u+1,c)}else if(o===4){let c=i.getUint8(u),l=i.getUint8(u+1),m=i.getUint8(u+2),d=i.getUint8(u+3);i.setUint8(u,d),i.setUint8(u+1,m),i.setUint8(u+2,l),i.setUint8(u+3,c)}else if(o===8){let c=i.getUint8(u),l=i.getUint8(u+1),m=i.getUint8(u+2),d=i.getUint8(u+3),y=i.getUint8(u+4),f=i.getUint8(u+5),p=i.getUint8(u+6),g=i.getUint8(u+7);i.setUint8(u,g),i.setUint8(u+1,p),i.setUint8(u+2,f),i.setUint8(u+3,y),i.setUint8(u+4,d),i.setUint8(u+5,m),i.setUint8(u+6,l),i.setUint8(u+7,c)}}return e}view(t){if(!t||t===this.dtype)return r._fromStorage(this._storage,this._base??this);let e=Hr(this.dtype),n=Hr(t);if(e!==n)throw new Error("When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.");let o=j(t);if(!o)throw new Error(`Unsupported dtype: ${t}`);let a=this._storage.data,i=a.byteOffset+this._storage.offset*e,s=new o(a.buffer,i,this.size),u=N.fromData(s,[...this.shape],t,[...this._storage.strides],0);return r._fromStorage(u,this._base??this)}tofile(t,e="",n=""){throw new Error('tofile() requires file system access. Use the node module: import { save } from "numpy-ts/node"')}};am=no;Nm={cross:(r,t,e=-1,n=-1,o=-1,a)=>{let i=ja(r.storage,t.storage,e,n,o,a);return typeof i=="number"?i:_._fromStorage(i)},norm:(r,t=null,e=null,n=!1)=>{let o=La(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)},vector_norm:(r,t=2,e,n=!1)=>{let o=nt(r.storage,t,e,n);return typeof o=="number"?o:_._fromStorage(o)},matrix_norm:(r,t="fro",e=!1)=>{let n=Wr(r.storage,t,e);return typeof n=="number"?n:_._fromStorage(n)},qr:(r,t="reduced")=>{let e=rn(r.storage,t);return e instanceof N?_._fromStorage(e):"q"in e&&"r"in e?{q:_._fromStorage(e.q),r:_._fromStorage(e.r)}:{h:_._fromStorage(e.h),tau:_._fromStorage(e.tau)}},cholesky:(r,t=!1)=>_._fromStorage(Wa(r.storage,t)),svd:(r,t=!0,e=!0)=>{let n=en(r.storage,t,e);return"u"in n?{u:_._fromStorage(n.u),s:_._fromStorage(n.s),vt:_._fromStorage(n.vt)}:_._fromStorage(n)},det:r=>Ga(r.storage),inv:r=>_._fromStorage(Nt(r.storage)),solve:(r,t)=>_._fromStorage(nn(r.storage,t.storage)),lstsq:(r,t,e=null)=>{let n=Za(r.storage,t.storage,e);return{x:_._fromStorage(n.x),residuals:_._fromStorage(n.residuals),rank:n.rank,s:_._fromStorage(n.s)}},cond:(r,t=2)=>Ya(r.storage,t),matrix_rank:(r,t)=>Ha(r.storage,t),matrix_power:(r,t)=>_._fromStorage(Xa(r.storage,t)),pinv:(r,t=1e-15)=>_._fromStorage(Ja(r.storage,t)),eig:r=>{let t=on(r.storage);return{w:_._fromStorage(t.w),v:_._fromStorage(t.v)}},eigh:(r,t="L")=>{let e=an(r.storage,t);return{w:_._fromStorage(e.w),v:_._fromStorage(e.v)}},eigvals:r=>_._fromStorage(Qa(r.storage)),eigvalsh:(r,t="L")=>_._fromStorage(Ka(r.storage,t)),diagonal:(r,t=0,e=0,n=1)=>_._fromStorage(Ke(r.storage,t,e,n)),matmul:(r,t)=>_._fromStorage(mr(r.storage,t.storage)),matrix_transpose:r=>_._fromStorage(un(r.storage)),multi_dot:r=>{let t=r.map(e=>e.storage);return _._fromStorage(ss(t))},outer:(r,t)=>_._fromStorage(Gt(r.storage,t.storage)),slogdet:r=>os(r.storage),svdvals:r=>_._fromStorage(as(r.storage)),tensordot:(r,t,e=2)=>{let n=Qe(r.storage,t.storage,e);return typeof n=="number"||typeof n=="bigint"||n instanceof E?n:_._fromStorage(n)},tensorinv:(r,t=2)=>_._fromStorage(is(r.storage,t)),tensorsolve:(r,t,e)=>_._fromStorage(us(r.storage,t.storage,e)),trace:r=>Je(r.storage),vecdot:(r,t,e=-1)=>{let n=sn(r.storage,t.storage,e);return typeof n=="number"||typeof n=="bigint"||n instanceof E?n:_._fromStorage(n)}};qr={bool:0,uint8:1,int8:2,uint16:3,int16:4,uint32:5,int32:6,uint64:7,int64:8,float32:9,float64:10,complex64:11,complex128:12},cr={bool:"b",uint8:"u",uint16:"u",uint32:"u",uint64:"u",int8:"i",int16:"i",int32:"i",int64:"i",float32:"f",float64:"f",complex64:"c",complex128:"c"}});function ao(){let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256}function oy(r){if(r.startsWith("[")||r.startsWith("("))throw new Fr(`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 ny)throw new Fr(`Unsupported dtype: ${ny[n]} (${r}). Use the 'force' parameter to skip arrays with unsupported dtypes.`);let o=Ug[e];if(!o)throw new Fr(`Unknown or unsupported dtype descriptor: ${r}. Supported types: ${ee.join(", ")}. Use the 'force' parameter to skip arrays with unsupported dtypes.`);let a=ao(),i=t==="<"||t==="|"||t==="="&&a,s=t===">"||t==="="&&!a,u=parseInt(e.slice(1),10),c=u>1&&(s&&a||i&&!a);return{dtype:o,needsByteSwap:c,itemsize:u}}var Ft,ee,Ug,Mt,ny,Fr,lr,Bt=G(()=>{"use strict";Ft=new Uint8Array([147,78,85,77,80,89]),ee=["float64","float32","complex128","complex64","int64","int32","int16","int8","uint64","uint32","uint16","uint8","bool"];Ug={f8:"float64",f4:"float32",c16:"complex128",c8:"complex64",i8:"int64",i4:"int32",i2:"int16",i1:"int8",u8:"uint64",u4:"uint32",u2:"uint16",u1:"uint8",b1:"bool"},Mt={float64:"<f8",float32:"<f4",complex128:"<c16",complex64:"<c8",int64:"<i8",int32:"<i4",int16:"<i2",int8:"|i1",uint64:"<u8",uint32:"<u4",uint16:"<u2",uint8:"|u1",bool:"|b1"},ny={S:"byte strings",U:"Unicode strings",O:"Python objects",V:"structured arrays (void)",M:"datetime64",m:"timedelta64"};Fr=class extends Error{constructor(t){super(t),this.name="UnsupportedDTypeError"}},lr=class extends Error{constructor(t){super(t),this.name="InvalidNpyError"}}});function Pr(r){let t=r instanceof ArrayBuffer?new Uint8Array(r):r,e=ne(t);return oe(t,e)}function ne(r){if(r.length<10)throw new lr("File too small to be a valid NPY file");for(let c=0;c<Ft.length;c++)if(r[c]!==Ft[c])throw new lr("Invalid NPY magic number");let t=r[6],e=r[7];if(t!==1&&t!==2&&t!==3)throw new lr(`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 lr("File truncated: header extends beyond file");let i=r.slice(o,a),s=new TextDecoder("utf-8").decode(i).trim(),u=$g(s);return{version:{major:t,minor:e},header:u,dataOffset:a}}function oe(r,t){let{header:e,dataOffset:n}=t,{dtype:o,needsByteSwap:a,itemsize:i}=oy(e.descr),s=e.shape.reduce((p,g)=>p*g,1),u=s*i,c=r.length-n;if(c<u)throw new lr(`File truncated: expected ${u} bytes of data, got ${c}`);let l=new ArrayBuffer(u);new Uint8Array(l).set(r.subarray(n,n+u));let d=Rg(l,o,s,a,i),y=e.shape,f;if(e.fortran_order&&y.length>1){let p=[...y].reverse(),g=N.fromData(d,p,o);f=kg(g,p),y=e.shape}else f=N.fromData(d,[...y],o);return new _(f)}function $g(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 lr(`Failed to parse NPY header: ${r}`);let o=t[1],a=e[1]==="True",i=n[1].trim(),s;return i===""?s=[]:s=i.split(",").map(u=>u.trim()).filter(u=>u!=="").map(u=>{let c=parseInt(u,10);if(isNaN(c))throw new lr(`Invalid shape value: ${u}`);return c}),{descr:o,fortran_order:a,shape:s}}function Rg(r,t,e,n,o){let a=j(t);if(!a)throw new lr(`Cannot create array for dtype: ${t}`);let i=M(t),s=i?e*2:e;if(!n)return new a(r,0,s);let u=new Uint8Array(r),c=new Uint8Array(r.byteLength);if(i){let l=o/2;for(let m=0;m<e*2;m++){let d=m*l;for(let y=0;y<l;y++)c[d+y]=u[d+l-1-y]}}else for(let l=0;l<e;l++){let m=l*o;for(let d=0;d<o;d++)c[m+d]=u[m+o-1-d]}return new a(c.buffer,0,s)}function kg(r,t){let e=t.length,n=r.size,o=r.dtype,a=j(o);if(!a)throw new lr(`Cannot create array for dtype: ${o}`);let i=new a(n),s=[...t].reverse(),u=ay(t),c=ay(s),l=new Array(e).fill(0);for(let m=0;m<n;m++){let d=m;for(let f=0;f<e;f++){let p=u[f];l[f]=Math.floor(d/p),d=d%p}let y=0;for(let f=0;f<e;f++)y+=l[e-1-f]*c[f];B(o),i[y]=r.iget(m)}return N.fromData(i,s,o)}function ay(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 ae=G(()=>{"use strict";vt();K();Q();Bt()});function Cr(r){let t=r.shape,e=r.dtype,n=Mt[e],o=t.length===0?"()":t.length===1?`(${t[0]},)`:`(${t.join(", ")})`,a=`{'descr': '${n}', 'fortran_order': False, 'shape': ${o}, }`,i=12,u=(64-(i+a.length+1)%64)%64;a=a+" ".repeat(u)+`
2
+ `;let c=new TextEncoder().encode(a),l=c.length,m=r.size,d=Hr(e),y=m*d,f=i+l+y,p=new Uint8Array(f);p.set(Ft,0),p[6]=3,p[7]=0,p[8]=l&255,p[9]=l>>8&255,p[10]=l>>16&255,p[11]=l>>24&255,p.set(c,i);let g=i+l;return qg(r,p.subarray(g),d),p}function qg(r,t,e){let n=r.dtype,o=r.size,a=ao(),i=B(n),s=M(n),u=r._storage;if(u.isCContiguous&&u.offset===0&&a){let l=u.data,m=new Uint8Array(l.buffer,l.byteOffset,o*e);t.set(m)}else{let l=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let m=0;m<o;m++){let d=u.iget(m),y=m*e;i?Vg(l,y,d,n==="uint64"):s?Pg(l,y,d,n):jg(l,y,d,n)}}}function Vg(r,t,e,n){n?r.setBigUint64(t,e,!0):r.setBigInt64(t,e,!0)}function Pg(r,t,e,n){n==="complex128"?(r.setFloat64(t,e.re,!0),r.setFloat64(t+8,e.im,!0)):(r.setFloat32(t,e.re,!0),r.setFloat32(t+4,e.im,!0))}function jg(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 se=G(()=>{"use strict";Q();Bt()});function so(r){let t=4294967295;for(let e=0;e<r.length;e++)t=Lg[(t^r[e])&255]^t>>>8;return(t^4294967295)>>>0}var Lg,io=G(()=>{"use strict";Lg=(()=>{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 sy(r){let t=uy(r),e=new Map;for(let n of t){let o=await Wg(n);e.set(n.name,o)}return e}function iy(r){let t=uy(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 uy(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),i=e.getUint16(o+10,!0),s=[],u=a;for(let c=0;c<i&&e.getUint32(u,!0)===33639248;c++){let m=e.getUint16(u+10,!0),d=e.getUint32(u+16,!0),y=e.getUint32(u+20,!0),f=e.getUint32(u+24,!0),p=e.getUint16(u+28,!0),g=e.getUint16(u+30,!0),h=e.getUint16(u+32,!0),b=e.getUint32(u+42,!0),A=t.slice(u+46,u+46+p),S=new TextDecoder("utf-8").decode(A);s.push({name:S,compressionMethod:m,crc32:d,compressedSize:y,uncompressedSize:f,localHeaderOffset:b}),u=u+46+p+g+h}for(let c of s){let l=c.localHeaderOffset;if(e.getUint32(l,!0)!==67324752)throw new Error(`Invalid local file header at offset ${l}`);let d=e.getUint16(l+26,!0),y=e.getUint16(l+28,!0),f=l+30+d+y,p=t.slice(f,f+c.compressedSize);n.push({name:c.name,compressedData:p,compressionMethod:c.compressionMethod,crc32:c.crc32,compressedSize:c.compressedSize,uncompressedSize:c.uncompressedSize})}return n}async function Wg(r){if(r.compressionMethod===0)return r.compressedData;if(r.compressionMethod===8)return await Gg(r.compressedData);throw new Error(`Unsupported compression method: ${r.compressionMethod}`)}async function Gg(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:l}=await o.read();if(c)break;a.push(l)}let i=a.reduce((c,l)=>c+l.length,0),s=new Uint8Array(i),u=0;for(let c of a)s.set(c,u),u+=c.length;return s}var cy=G(()=>{"use strict";io()});var fy={};we(fy,{loadNpz:()=>ie,loadNpzSync:()=>ue,parseNpz:()=>Gr,parseNpzSync:()=>Tt});async function Gr(r,t={}){let e=t.force??!1,n=await sy(r);return ly(n,e)}function Tt(r,t={}){let e=t.force??!1,n=iy(r);return ly(n,e)}function ly(r,t){let e=new Map,n=[],o=new Map;for(let[a,i]of r){if(!a.endsWith(".npy"))continue;let s=a.slice(0,-4);try{let u=Pr(i);e.set(s,u)}catch(u){if(u instanceof Fr&&t)n.push(s),o.set(s,u.message);else throw u}}return{arrays:e,skipped:n,errors:o}}async function ie(r,t={}){let e=await Gr(r,t);return Object.fromEntries(e.arrays)}function ue(r,t={}){let e=Tt(r,t);return Object.fromEntries(e.arrays)}var ce=G(()=>{"use strict";ae();Bt();cy()});async function my(r,t={}){let e=t.compress??!1,n=[];for(let[d,y]of r){let f=so(y),p,g;e?(p=await Yg(y),p.length<y.length?g=8:(p=y,g=0)):(p=y,g=0),n.push({name:d,data:y,compressedData:p,crc:f,compressionMethod:g,offset:0})}let o=0;for(let d of n){let y=new TextEncoder().encode(d.name);o+=30+y.length+d.compressedData.length}let a=0;for(let d of n){let y=new TextEncoder().encode(d.name);a+=46+y.length}let s=o+a+22,u=new Uint8Array(s),c=new DataView(u.buffer),l=0;for(let d of n)d.offset=l,l=yy(u,c,l,d);let m=l;for(let d of n)l=dy(u,c,l,d);return gy(c,l,n.length,a,m),u}function py(r){let t=[];for(let[l,m]of r){let d=so(m);t.push({name:l,data:m,compressedData:m,crc:d,compressionMethod:0,offset:0})}let e=0;for(let l of t){let m=new TextEncoder().encode(l.name);e+=30+m.length+l.compressedData.length}let n=0;for(let l of t){let m=new TextEncoder().encode(l.name);n+=46+m.length}let a=e+n+22,i=new Uint8Array(a),s=new DataView(i.buffer),u=0;for(let l of t)l.offset=u,u=yy(i,s,u,l);let c=u;for(let l of t)u=dy(i,s,u,l);return gy(s,u,t.length,n,c),i}function yy(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 dy(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 gy(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 Yg(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:l}=await o.read();if(c)break;a.push(l)}let i=a.reduce((c,l)=>c+l.length,0),s=new Uint8Array(i),u=0;for(let c of a)s.set(c,u),u+=c.length;return s}var Ay=G(()=>{"use strict";io()});var hy={};we(hy,{serializeNpz:()=>ut,serializeNpzSync:()=>le});async function ut(r,t={}){let e=by(r);return my(e,{compress:t.compress??!1})}function le(r){let t=by(r);return py(t)}function by(r){let t=new Map;if(Array.isArray(r)){for(let n=0;n<r.length;n++){let o=r[n],a=Cr(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=Cr(o),i=n.endsWith(".npy")?n:`${n}.npy`;t.set(i,a)}return t}var fe=G(()=>{"use strict";se();Ay()});var FA={};we(FA,{Complex:()=>E,DTYPE_TO_DESCR:()=>Mt,InvalidNpyError:()=>lr,NDArray:()=>_,SUPPORTED_DTYPES:()=>ee,UnsupportedDTypeError:()=>Fr,__version__:()=>pA,abs:()=>jn,absolute:()=>jn,acos:()=>Gn,acosh:()=>Xn,amax:()=>to,amin:()=>eo,angle:()=>sm,append:()=>wl,apply_along_axis:()=>Ep,apply_over_axes:()=>Tp,arange:()=>Tu,arccos:()=>Gn,arccosh:()=>Xn,arcsin:()=>Wn,arcsinh:()=>Hn,arctan:()=>Zn,arctan2:()=>Yn,arctanh:()=>Jn,argpartition:()=>Wm,argsort:()=>Pm,argwhere:()=>Ym,around:()=>te,array:()=>L,array_equal:()=>$l,array_equiv:()=>Rl,array_split:()=>Hc,asanyarray:()=>Wu,asarray:()=>st,asarray_chkfinite:()=>Ru,ascontiguousarray:()=>Gu,asfortranarray:()=>Zu,asin:()=>Wn,asinh:()=>Hn,atan:()=>Zn,atan2:()=>Yn,atanh:()=>Jn,atleast_1d:()=>Al,atleast_2d:()=>bl,atleast_3d:()=>hl,average:()=>jl,bincount:()=>Dp,bindex:()=>Ol,bitwise_and:()=>vf,bitwise_count:()=>$f,bitwise_invert:()=>Rf,bitwise_left_shift:()=>kf,bitwise_not:()=>Bf,bitwise_or:()=>Ff,bitwise_right_shift:()=>qf,bitwise_xor:()=>Mf,block:()=>Zc,broadcast_arrays:()=>Fl,broadcast_shapes:()=>Ml,broadcast_to:()=>vl,byteswap:()=>sl,can_cast:()=>Rp,cbrt:()=>of,ceil:()=>rp,choose:()=>Ul,clip:()=>bf,column_stack:()=>Dl,common_type:()=>kp,compress:()=>zm,concat:()=>Wc,concatenate:()=>Vr,conj:()=>no,conjugate:()=>am,convolve:()=>_p,copy:()=>qu,copysign:()=>Hf,copyto:()=>Cl,corrcoef:()=>Fp,correlate:()=>zp,cos:()=>Mc,cosh:()=>Rc,count_nonzero:()=>Km,cov:()=>vp,cross:()=>Sp,cumprod:()=>ro,cumsum:()=>Kn,cumulative_prod:()=>ro,cumulative_sum:()=>Kn,deg2rad:()=>Cc,degrees:()=>Tc,delete:()=>Il,diag:()=>Vn,diag_indices:()=>Mm,diag_indices_from:()=>Bm,diagflat:()=>Yu,diagonal:()=>xc,diff:()=>Ap,digitize:()=>Np,divide:()=>Ln,divmod:()=>sf,dot:()=>Dc,dsplit:()=>Sl,dstack:()=>Lc,ediff1d:()=>bp,einsum:()=>dm,empty:()=>kn,empty_like:()=>ju,exp:()=>sc,exp2:()=>ic,expand_dims:()=>fl,expm1:()=>uc,extract:()=>Qm,eye:()=>Rn,fabs:()=>af,fill:()=>el,fill_diagonal:()=>Fm,fix:()=>tp,flatnonzero:()=>Hm,flatten:()=>tl,flip:()=>re,fliplr:()=>ml,flipud:()=>pl,float_power:()=>ff,floor:()=>ep,floor_divide:()=>bc,fmax:()=>Df,fmin:()=>Nf,fmod:()=>mf,frexp:()=>pf,frombuffer:()=>tc,fromfile:()=>ec,fromfunction:()=>Hu,fromiter:()=>nc,fromregex:()=>_A,fromregexSync:()=>vA,fromstring:()=>oc,full:()=>qn,full_like:()=>Lu,gcd:()=>yf,genfromtxt:()=>IA,genfromtxtSync:()=>zA,geomspace:()=>Uu,geterr:()=>Ht,gradient:()=>hp,heaviside:()=>lf,histogram:()=>xp,histogram2d:()=>wp,histogram_bin_edges:()=>Mp,histogramdd:()=>Ip,hsplit:()=>Jc,hstack:()=>jc,hypot:()=>Ec,i0:()=>_f,identity:()=>$u,iindex:()=>Tl,imag:()=>om,in1d:()=>sp,indices:()=>$m,inner:()=>zc,insert:()=>zl,interp:()=>wf,intersect1d:()=>ip,invert:()=>Ef,iscomplex:()=>Kf,iscomplexobj:()=>rm,isdtype:()=>pm,isfinite:()=>Wf,isfortran:()=>cm,isin:()=>up,isinf:()=>Gf,isnan:()=>Zf,isnat:()=>Yf,isneginf:()=>im,isposinf:()=>um,isreal:()=>tm,isrealobj:()=>em,isscalar:()=>fm,issubdtype:()=>jp,item:()=>nl,iterable:()=>mm,ix_:()=>Rm,kron:()=>wc,lcm:()=>df,ldexp:()=>gf,left_shift:()=>Tf,lexsort:()=>jm,linalg:()=>Nm,linspace:()=>Ou,load:()=>dA,loadNpy:()=>Ly,loadNpySync:()=>Wy,loadNpz:()=>ie,loadNpzFile:()=>Yy,loadNpzFileSync:()=>Hy,loadNpzSync:()=>ue,loadSync:()=>gA,loadtxt:()=>DA,loadtxtSync:()=>NA,log:()=>cc,log10:()=>fc,log1p:()=>mc,log2:()=>lc,logaddexp:()=>pc,logaddexp2:()=>yc,logical_and:()=>Vf,logical_not:()=>jf,logical_or:()=>Pf,logical_xor:()=>Lf,logspace:()=>Cu,mask_indices:()=>Um,matrix_transpose:()=>bm,matvec:()=>Sm,max:()=>to,maximum:()=>hf,may_share_memory:()=>Op,median:()=>ql,meshgrid:()=>Xu,min:()=>eo,min_scalar_type:()=>Pp,minimum:()=>Sf,mintypecode:()=>Wp,mod:()=>Ac,modf:()=>Af,moveaxis:()=>Vc,nan_to_num:()=>xf,nanargmax:()=>Ql,nanargmin:()=>Jl,nancumprod:()=>rf,nancumsum:()=>Kl,nanmax:()=>Xl,nanmean:()=>Gl,nanmedian:()=>tf,nanmin:()=>Hl,nanpercentile:()=>nf,nanprod:()=>Wl,nanquantile:()=>ef,nanstd:()=>Yl,nansum:()=>Ll,nanvar:()=>Zl,ndim:()=>Up,negative:()=>dc,nextafter:()=>Jf,nonzero:()=>Zm,ones:()=>$n,ones_like:()=>Pu,outer:()=>_c,packbits:()=>Cf,pad:()=>_l,parseNpy:()=>Pr,parseNpyData:()=>oe,parseNpyHeader:()=>ne,parseNpz:()=>Gr,parseNpzSync:()=>Tt,parseTxt:()=>Zr,partition:()=>Lm,percentile:()=>Vl,permute_dims:()=>hm,place:()=>vm,poly:()=>Gp,polyadd:()=>Zp,polyder:()=>Yp,polydiv:()=>Hp,polyfit:()=>Xp,polyint:()=>Qp,polymul:()=>Kp,polysub:()=>ry,polyval:()=>ty,positive:()=>hc,pow:()=>Pn,power:()=>Pn,promote_types:()=>ym,ptp:()=>kl,put:()=>El,put_along_axis:()=>wm,putmask:()=>Im,quantile:()=>Pl,rad2deg:()=>Uc,radians:()=>Oc,random:()=>mA,ravel:()=>rl,ravel_multi_index:()=>km,real:()=>nm,real_if_close:()=>lm,reciprocal:()=>Sc,remainder:()=>cf,repeat:()=>Kc,require:()=>ku,reshape:()=>cl,resize:()=>xl,result_type:()=>qp,right_shift:()=>Of,rint:()=>np,roll:()=>dl,rollaxis:()=>gl,roots:()=>ey,rot90:()=>yl,round:()=>te,round_:()=>te,row_stack:()=>Nl,save:()=>AA,saveNpy:()=>Gy,saveNpySync:()=>Zy,saveNpz:()=>bo,saveNpzSync:()=>yA,saveSync:()=>bA,savetxt:()=>xA,savetxtSync:()=>wA,savez:()=>hA,savez_compressed:()=>SA,searchsorted:()=>Jm,select:()=>_m,serializeNpy:()=>Cr,serializeNpz:()=>ut,serializeNpzSync:()=>le,serializeTxt:()=>ct,setdiff1d:()=>cp,seterr:()=>yn,setxor1d:()=>lp,shape:()=>oo,shares_memory:()=>Cp,sign:()=>gc,signbit:()=>Xf,sin:()=>Fc,sinc:()=>zf,sinh:()=>$c,size:()=>$p,sort:()=>Vm,sort_complex:()=>Gm,spacing:()=>Qf,split:()=>Yc,sqrt:()=>ac,square:()=>uf,squeeze:()=>ll,stack:()=>Pc,swapaxes:()=>qc,take:()=>Bl,take_along_axis:()=>xm,tan:()=>Bc,tanh:()=>kc,tensordot:()=>vc,tile:()=>Qc,tobytes:()=>al,tofile:()=>ul,tolist:()=>ol,trace:()=>Nc,transpose:()=>Ic,trapezoid:()=>Bp,tri:()=>Ju,tril:()=>Qu,tril_indices:()=>Em,tril_indices_from:()=>Tm,trim_zeros:()=>mp,triu:()=>Ku,triu_indices:()=>Om,triu_indices_from:()=>Cm,true_divide:()=>Ln,trunc:()=>op,typename:()=>Lp,union1d:()=>fp,unique:()=>ap,unique_all:()=>pp,unique_counts:()=>yp,unique_inverse:()=>dp,unique_values:()=>gp,unpackbits:()=>Uf,unravel_index:()=>qm,unstack:()=>Gc,unwrap:()=>If,vander:()=>rc,vdot:()=>gm,vecdot:()=>Am,vecmat:()=>Dm,view:()=>il,vsplit:()=>Xc,vstack:()=>Qn,where:()=>Xm,zeros:()=>vr,zeros_like:()=>Vu});module.exports=Ie(FA);var Mr=require("node:fs"),Br=require("node:fs/promises");ae();se();ce();fe();vt();function Zr(r,t={}){let{delimiter:e,comments:n="#",skiprows:o=0,usecols:a,max_rows:i,dtype:s="float64",missing_values:u,filling_values:c}=t,l=r.split(/\r?\n/);if(o>0&&(l=l.slice(o)),l=l.filter(p=>{let g=p.trim();return!(g===""||n&&g.startsWith(n))}),i!==void 0&&i>0&&(l=l.slice(0,i)),l.length===0)return L([],s);let m=[],d=new Set(u?Array.isArray(u)?u:[u]:[]),y=c!==void 0?c:s.includes("int")||s==="bool"?0:NaN;for(let p of l){let g;e===void 0?g=p.trim().split(/\s+/):g=p.split(e),a!==void 0&&(g=(Array.isArray(a)?a:[a]).map(A=>(A<0&&(A=g.length+A),g[A]??"")));let h=g.map(b=>{let A=b.trim();if(d.has(A)||A==="")return y;let S=parseFloat(A);return isNaN(S)?y:S});m.push(h)}let f=m[0]?.length??0;for(let p=1;p<m.length;p++)if(m[p].length!==f)throw new Error(`Inconsistent number of columns: row 0 has ${f} columns, row ${p} has ${m[p].length} columns`);return f===1?L(m.map(p=>p[0]),s):L(m,s)}function Ot(r,t={}){let e={...t,missing_values:t.missing_values??["","nan","NaN","NA","N/A","-"],filling_values:t.filling_values??NaN};return Zr(r,e)}function Ct(r,t,e="float64"){let n=typeof t=="string"?new RegExp(t,"gm"):new RegExp(t.source,"gm"),o=[],a;for(;(a=n.exec(r))!==null;)if(a.length>1){let i=a.slice(1).map(s=>{let u=parseFloat(s);return isNaN(u)?0:u});o.push(i)}return o.length===0?L([],e):o[0].length===1?L(o.map(i=>i[0]),e):L(o,e)}function Sy(r,t){let e=typeof r=="bigint"?Number(r):r,n=t.match(/^%([+-]?)(\d*)(?:\.(\d+))?([dfeEgGs])$/);if(!n)return String(e);let[,o,a,i,s]=n,u=i!==void 0?parseInt(i,10):void 0,c;switch(s){case"d":c=Math.round(e).toString();break;case"f":c=e.toFixed(u??6);break;case"e":c=e.toExponential(u??6).replace(/e([+-])(\d)$/,"e$10$2");break;case"E":c=e.toExponential(u??6).toUpperCase().replace(/E([+-])(\d)$/,"E$10$2");break;case"g":case"G":{let l=u??6,m=Math.floor(Math.log10(Math.abs(e)));m>=-4&&m<l?(c=e.toPrecision(l),c.includes(".")&&(c=c.replace(/\.?0+$/,""))):c=e.toExponential(l-1),s==="G"&&(c=c.toUpperCase());break}case"s":c=String(e);break;default:c=String(e)}if(a){let l=parseInt(a,10);if(c.length<l){let m=" ".repeat(l-c.length);o==="-"?c=c+m:c=m+c}}return o==="+"&&e>=0&&!c.startsWith("-")&&(c="+"+c),c}function ct(r,t={}){let{fmt:e="%.18e",delimiter:n=" ",newline:o=`
3
+ `,header:a,footer:i,comments:s="# "}=t;if(r.ndim>2)throw new Error("savetxt: array must be 1D or 2D");let u=[];if(a!==void 0){let l=a.split(/\r?\n/);for(let m of l)m.startsWith(s.trimEnd())?u.push(m):u.push(s+m)}let c=r.toArray();if(r.ndim===1)for(let l of c)u.push(Sy(l,e));else for(let l of c){let m=l.map(d=>Sy(d,e));u.push(m.join(n))}if(i!==void 0){let l=i.split(/\r?\n/);for(let m of l)m.startsWith(s.trimEnd())?u.push(m):u.push(s+m)}return u.join(o)+o}xr();vt();ae();se();Bt();ce();fe();K();Q();var Dr=624,me=397,Hg=2567483615,lo=2147483648,fo=2147483647,Nr={mt:new Uint32Array(Dr),mti:Dr+1};function xy(r){let t=Nr.mt;t[0]=r>>>0;for(let e=1;e<Dr;e++){let n=t[e-1]^t[e-1]>>>30;t[e]=Math.imul(1812433253,n)+e>>>0}Nr.mti=Dr}function Dy(){let r=Nr.mt,t,e=[0,Hg];if(Nr.mti>=Dr){let n;for(Nr.mti===Dr+1&&xy(5489),n=0;n<Dr-me;n++)t=r[n]&lo|r[n+1]&fo,r[n]=r[n+me]^t>>>1^e[t&1];for(;n<Dr-1;n++)t=r[n]&lo|r[n+1]&fo,r[n]=r[n+(me-Dr)]^t>>>1^e[t&1];t=r[Dr-1]&lo|r[0]&fo,r[Dr-1]=r[me-1]^t>>>1^e[t&1],Nr.mti=0}return t=r[Nr.mti++],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}function H(){let r=Dy()>>>5,t=Dy()>>>6;return(r*67108864+t)/9007199254740992}var Xg=2468251765,Jg=1492356589,Qg=1135663077,Kg=2337405405,rA=3389127133,tA=1232336661,Ao=16,pe=4;function fr(r){return r>>>0}function mo(r,t){return r=fr(fr(r)^t.val),t.val=fr(Math.imul(t.val,Xg)),r=fr(Math.imul(r,t.val)),r=fr(r^r>>>Ao),r}function eA(r,t){let e=fr(fr(Math.imul(rA,fr(r)))-fr(Math.imul(tA,fr(t))));return e=fr(e^e>>>Ao),e}function nA(r){let t=[0,0,0,0],e=[r>>>0],n={val:Qg};for(let o=0;o<pe;o++)o<e.length?t[o]=mo(e[o],n):t[o]=mo(0,n);for(let o=0;o<pe;o++)for(let a=0;a<pe;a++)if(o!==a){let i=mo(t[o],n);t[a]=eA(t[a],i)}return t}function oA(r,t){let e=[],n=Kg;for(let o=0;o<t;o++){let a=r[o%pe],i=fr(a^n);n=fr(Math.imul(n,Jg)),i=fr(Math.imul(i,n)),i=fr(i^i>>>Ao),e.push(i)}return e}var aA=BigInt("4865540595714422341"),sA=BigInt("2549297995355413924"),iA=sA<<BigInt(64)|aA,po=BigInt("0xffffffffffffffff"),yo=(BigInt(1)<<BigInt(128))-BigInt(1);function uA(r){let t=r>>BigInt(64),e=r&po,n=(t^e)&po,o=Number(r>>BigInt(122));return(n>>BigInt(o)|n<<BigInt(64-o))&po}function go(r,t){return r*iA+t&yo}function Ny(r){let t=nA(r),e=oA(t,8),n=BigInt(e[0])|BigInt(e[1])<<BigInt(32),o=BigInt(e[2])|BigInt(e[3])<<BigInt(32),a=BigInt(e[4])|BigInt(e[5])<<BigInt(32),i=BigInt(e[6])|BigInt(e[7])<<BigInt(32),s=n<<BigInt(64)|o,u=(a<<BigInt(64)|i)<<BigInt(1);u=(u|BigInt(1))&yo;let c=BigInt(0);return c=go(c,u),c=c+s&yo,c=go(c,u),{state:c,inc:u}}function cA(r){return r.state=go(r.state,r.inc),uA(r.state)}function lA(r){let e=cA(r)>>BigInt(11);return Number(e)/9007199254740992}var Ut=class{constructor(t){if(t!==void 0)this._pcgState=Ny(t);else{let e=Math.floor(Math.random()*4294967296);this._pcgState=Ny(e)}}_randomFloat(){return lA(this._pcgState)}random(t){if(t===void 0)return this._randomFloat();let e=Array.isArray(t)?t:[t],n=e.reduce((i,s)=>i*s,1),o=N.zeros(e,"float64"),a=o.data;for(let i=0;i<n;i++)a[i]=this._randomFloat();return o}integers(t,e,n){if(e===void 0&&(e=t,t=0),n===void 0)return Math.floor(this._randomFloat()*(e-t))+t;let o=Array.isArray(n)?n:[n],a=o.reduce((c,l)=>c*l,1),i=N.zeros(o,"int64"),s=i.data,u=e-t;for(let c=0;c<a;c++)s[c]=BigInt(Math.floor(this._randomFloat()*u)+t);return i}standard_normal(t){if(t===void 0)return Yr(this._randomFloat.bind(this));let e=Array.isArray(t)?t:[t],n=e.reduce((i,s)=>i*s,1),o=N.zeros(e,"float64"),a=o.data;for(let i=0;i<n;i+=2){let[s,u]=$t(this._randomFloat.bind(this));a[i]=s,i+1<n&&(a[i+1]=u)}return o}normal(t=0,e=1,n){if(n===void 0)return Yr(this._randomFloat.bind(this))*e+t;let o=Array.isArray(n)?n:[n],a=o.reduce((u,c)=>u*c,1),i=N.zeros(o,"float64"),s=i.data;for(let u=0;u<a;u+=2){let[c,l]=$t(this._randomFloat.bind(this));s[u]=c*e+t,u+1<a&&(s[u+1]=l*e+t)}return i}uniform(t=0,e=1,n){if(n===void 0)return this._randomFloat()*(e-t)+t;let o=Array.isArray(n)?n:[n],a=o.reduce((c,l)=>c*l,1),i=N.zeros(o,"float64"),s=i.data,u=e-t;for(let c=0;c<a;c++)s[c]=this._randomFloat()*u+t;return i}choice(t,e,n=!0,o){return Ry(t,e,n,o,this._randomFloat.bind(this))}permutation(t){return qy(t,this._randomFloat.bind(this))}shuffle(t){Py(t,this._randomFloat.bind(this))}exponential(t=1,e){if(e===void 0)return-Math.log(1-this._randomFloat())*t;let n=Array.isArray(e)?e:[e],o=n.reduce((s,u)=>s*u,1),a=N.zeros(n,"float64"),i=a.data;for(let s=0;s<o;s++)i[s]=-Math.log(1-this._randomFloat())*t;return a}poisson(t=1,e){if(e===void 0)return ye(t,this._randomFloat.bind(this));let n=Array.isArray(e)?e:[e],o=n.reduce((s,u)=>s*u,1),a=N.zeros(n,"int64"),i=a.data;for(let s=0;s<o;s++)i[s]=BigInt(ye(t,this._randomFloat.bind(this)));return a}binomial(t,e,n){if(n===void 0)return de(t,e,this._randomFloat.bind(this));let o=Array.isArray(n)?n:[n],a=o.reduce((u,c)=>u*c,1),i=N.zeros(o,"int64"),s=i.data;for(let u=0;u<a;u++)s[u]=BigInt(de(t,e,this._randomFloat.bind(this)));return i}};function wy(r){return new Ut(r)}function Iy(r){r==null&&(r=Math.floor(Date.now()^Math.random()*4294967296)),xy(r>>>0)}function zy(){return{mt:Array.from(Nr.mt),mti:Nr.mti}}function _y(r){Nr.mt=new Uint32Array(r.mt),Nr.mti=r.mti}function Yr(r){let t,e;do t=r(),e=r();while(t===0);return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e)}function $t(r){let t,e;do t=r(),e=r();while(t===0);let n=Math.sqrt(-2*Math.log(t)),o=2*Math.PI*e;return[n*Math.cos(o),n*Math.sin(o)]}function ye(r,t){if(r<30){let e=Math.exp(-r),n=0,o=1;do n++,o*=t();while(o>e);return n-1}else{let e=Yr(t);return Math.max(0,Math.round(r+Math.sqrt(r)*e))}}function de(r,t,e){if(r*t<10&&r*(1-t)<10){let n=0;for(let o=0;o<r;o++)e()<t&&n++;return n}else{let n=r*t,o=Math.sqrt(r*t*(1-t)),a=Yr(e);return Math.max(0,Math.min(r,Math.round(n+o*a)))}}function vy(r){if(r===void 0)return H();let t=Array.isArray(r)?r:[r],e=t.reduce((a,i)=>a*i,1),n=N.zeros(t,"float64"),o=n.data;for(let a=0;a<e;a++)o[a]=H();return n}function Fy(...r){if(r.length===0)return H();let t=r.reduce((o,a)=>o*a,1),e=N.zeros(r,"float64"),n=e.data;for(let o=0;o<t;o++)n[o]=H();return e}function My(...r){if(r.length===0)return Yr(H);let t=r.reduce((o,a)=>o*a,1),e=N.zeros(r,"float64"),n=e.data;for(let o=0;o<t;o+=2){let[a,i]=$t(H);n[o]=a,o+1<t&&(n[o+1]=i)}return e}function By(r,t,e,n="int64"){t==null&&(t=r,r=0);let o=t-r;if(e===void 0)return Math.floor(H()*o)+r;let a=Array.isArray(e)?e:[e],i=a.reduce((c,l)=>c*l,1),s=N.zeros(a,n),u=s.data;if(B(n)){let c=u;for(let l=0;l<i;l++)c[l]=BigInt(Math.floor(H()*o)+r)}else{let c=u;for(let l=0;l<i;l++)c[l]=Math.floor(H()*o)+r}return s}function Ey(r=0,t=1,e){if(e===void 0)return H()*(t-r)+r;let n=Array.isArray(e)?e:[e],o=n.reduce((u,c)=>u*c,1),a=N.zeros(n,"float64"),i=a.data,s=t-r;for(let u=0;u<o;u++)i[u]=H()*s+r;return a}function Ty(r=0,t=1,e){if(e===void 0)return Yr(H)*t+r;let n=Array.isArray(e)?e:[e],o=n.reduce((s,u)=>s*u,1),a=N.zeros(n,"float64"),i=a.data;for(let s=0;s<o;s+=2){let[u,c]=$t(H);i[s]=u*t+r,s+1<o&&(i[s+1]=c*t+r)}return a}function Oy(r){if(r===void 0)return Yr(H);let t=Array.isArray(r)?r:[r],e=t.reduce((a,i)=>a*i,1),n=N.zeros(t,"float64"),o=n.data;for(let a=0;a<e;a+=2){let[i,s]=$t(H);o[a]=i,a+1<e&&(o[a+1]=s)}return n}function Cy(r=1,t){if(t===void 0)return-Math.log(1-H())*r;let e=Array.isArray(t)?t:[t],n=e.reduce((i,s)=>i*s,1),o=N.zeros(e,"float64"),a=o.data;for(let i=0;i<n;i++)a[i]=-Math.log(1-H())*r;return o}function Uy(r=1,t){if(t===void 0)return ye(r,H);let e=Array.isArray(t)?t:[t],n=e.reduce((i,s)=>i*s,1),o=N.zeros(e,"int64"),a=o.data;for(let i=0;i<n;i++)a[i]=BigInt(ye(r,H));return o}function $y(r,t,e){if(e===void 0)return de(r,t,H);let n=Array.isArray(e)?e:[e],o=n.reduce((s,u)=>s*u,1),a=N.zeros(n,"int64"),i=a.data;for(let s=0;s<o;s++)i[s]=BigInt(de(r,t,H));return a}function Ry(r,t,e=!0,n,o=H){let a;if(typeof r=="number")a=Array.from({length:r},(d,y)=>y);else{let d=r.size;a=[];for(let y=0;y<d;y++)a.push(Number(r.iget(y)))}let i=a.length;if(i===0)throw new Error("cannot take a sample from an empty sequence");let s;if(n!==void 0){if(Array.isArray(n))s=n;else{let y=n.size;s=[];for(let f=0;f<y;f++)s.push(Number(n.iget(f)))}if(s.length!==i)throw new Error("p and a must have the same size");let d=s.reduce((y,f)=>y+f,0);Math.abs(d-1)>1e-10&&(s=s.map(y=>y/d))}if(t===void 0){if(s){let d=o(),y=0;for(let f=0;f<i;f++)if(y+=s[f],d<y)return a[f];return a[i-1]}return a[Math.floor(o()*i)]}let u=Array.isArray(t)?t:[t],c=u.reduce((d,y)=>d*y,1);if(!e&&c>i)throw new Error("cannot take a larger sample than population when replace=false");let l=N.zeros(u,"float64"),m=l.data;if(e)if(s){let d=new Array(i);d[0]=s[0];for(let y=1;y<i;y++)d[y]=d[y-1]+s[y];for(let y=0;y<c;y++){let f=o(),p=0;for(;p<i-1&&f>=d[p];)p++;m[y]=a[p]}}else for(let d=0;d<c;d++)m[d]=a[Math.floor(o()*i)];else{let d=[...a],y=s?[...s]:void 0;for(let f=0;f<c;f++){let p;if(y){let g=y.reduce((A,S)=>A+S,0),h=o()*g,b=0;p=0;for(let A=0;A<d.length;A++)if(b+=y[A],h<b){p=A;break}p===0&&h>=b&&(p=d.length-1)}else p=Math.floor(o()*d.length);m[f]=d[p],d.splice(p,1),y&&y.splice(p,1)}}return l}function ky(r,t,e=!0,n){return Ry(r,t,e,n,H)}function qy(r,t=H){let e;if(typeof r=="number"){let o=new Float64Array(r);for(let a=0;a<r;a++)o[a]=a;e=N.fromData(o,[r],"float64")}else e=r.copy();let n=e.size;for(let o=n-1;o>0;o--){let a=Math.floor(t()*(o+1)),i=e.iget(o);e.iset(o,e.iget(a)),e.iset(a,i)}return e}function Vy(r){return qy(r,H)}function Py(r,t=H){let e=r.size;for(let n=e-1;n>0;n--){let o=Math.floor(t()*(n+1)),a=r.iget(n);r.iset(n,r.iget(o)),r.iset(o,a)}}function jy(r){Py(r,H)}vt();function hr(r){return r&&typeof r=="object"&&"_data"in r&&"_shape"in r?_._fromStorage(r):r}var mA={seed:Iy,random:r=>hr(vy(r)),rand:(...r)=>hr(Fy(...r)),randn:(...r)=>hr(My(...r)),randint:(r,t,e,n)=>hr(By(r,t,e,n)),uniform:(r,t,e)=>hr(Ey(r,t,e)),normal:(r,t,e)=>hr(Ty(r,t,e)),standard_normal:r=>hr(Oy(r)),exponential:(r,t)=>hr(Cy(r,t)),poisson:(r,t)=>hr(Uy(r,t)),binomial:(r,t,e)=>hr($y(r,t,e)),choice:(r,t,e,n)=>hr(ky(r,t,e,n)),permutation:r=>hr(Vy(r)),shuffle:jy,get_state:zy,set_state:_y,default_rng:wy,Generator:Ut},pA="0.12.0";async function Ly(r){let t=await(0,Br.readFile)(r);return Pr(t)}function Wy(r){let t=(0,Mr.readFileSync)(r);return Pr(t)}async function Gy(r,t){let e=Cr(t);await(0,Br.writeFile)(r,e)}function Zy(r,t){let e=Cr(t);(0,Mr.writeFileSync)(r,e)}async function Yy(r,t={}){let e=await(0,Br.readFile)(r);return Gr(e,t)}function Hy(r,t={}){let e=(0,Mr.readFileSync)(r),{parseNpzSync:n}=(ce(),Ie(fy));return n(e,t)}async function bo(r,t,e={}){let n=await ut(t,e);await(0,Br.writeFile)(r,n)}function yA(r,t){let{serializeNpzSync:e}=(fe(),Ie(hy)),n=e(t);(0,Mr.writeFileSync)(r,n)}async function dA(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return Ly(r)}else{if(r.endsWith(".npz"))return Yy(r,t);throw new Error(`Unknown file extension. Expected .npy or .npz, got: ${r}`)}}function gA(r,t={}){if(r.endsWith(".npy")){if(t.allowNpy===!1)throw new Error("Loading .npy files is disabled (allowNpy: false)");return Wy(r)}else{if(r.endsWith(".npz"))return Hy(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 Gy(r,t)}function bA(r,t){if(!r.endsWith(".npy"))throw new Error(`saveSync() is for .npy files. Use saveNpzSync() for .npz files. Got: ${r}`);return Zy(r,t)}async function hA(r,t){return r.endsWith(".npz")||(r=r+".npz"),bo(r,t,{compress:!1})}async function SA(r,t){return r.endsWith(".npz")||(r=r+".npz"),bo(r,t,{compress:!0})}async function DA(r,t={}){let e=await(0,Br.readFile)(r,{encoding:t.encoding??"utf-8"});return Zr(e,t)}function NA(r,t={}){let e=(0,Mr.readFileSync)(r,{encoding:t.encoding??"utf-8"});return Zr(e,t)}async function xA(r,t,e={}){let n=ct(t,e);await(0,Br.writeFile)(r,n,"utf-8")}function wA(r,t,e={}){let n=ct(t,e);(0,Mr.writeFileSync)(r,n,"utf-8")}async function IA(r,t={}){let e=await(0,Br.readFile)(r,{encoding:t.encoding??"utf-8"});return Ot(e,t)}function zA(r,t={}){let e=(0,Mr.readFileSync)(r,{encoding:t.encoding??"utf-8"});return Ot(e,t)}async function _A(r,t,e="float64"){let n=await(0,Br.readFile)(r,{encoding:"utf-8"});return Ct(n,t,e)}function vA(r,t,e="float64"){let n=(0,Mr.readFileSync)(r,{encoding:"utf-8"});return Ct(n,t,e)}0&&(module.exports={Complex,DTYPE_TO_DESCR,InvalidNpyError,NDArray,SUPPORTED_DTYPES,UnsupportedDTypeError,__version__,abs,absolute,acos,acosh,amax,amin,angle,append,apply_along_axis,apply_over_axes,arange,arccos,arccosh,arcsin,arcsinh,arctan,arctan2,arctanh,argpartition,argsort,argwhere,around,array,array_equal,array_equiv,array_split,asanyarray,asarray,asarray_chkfinite,ascontiguousarray,asfortranarray,asin,asinh,atan,atan2,atanh,atleast_1d,atleast_2d,atleast_3d,average,bincount,bindex,bitwise_and,bitwise_count,bitwise_invert,bitwise_left_shift,bitwise_not,bitwise_or,bitwise_right_shift,bitwise_xor,block,broadcast_arrays,broadcast_shapes,broadcast_to,byteswap,can_cast,cbrt,ceil,choose,clip,column_stack,common_type,compress,concat,concatenate,conj,conjugate,convolve,copy,copysign,copyto,corrcoef,correlate,cos,cosh,count_nonzero,cov,cross,cumprod,cumsum,cumulative_prod,cumulative_sum,deg2rad,degrees,delete:null,diag,diag_indices,diag_indices_from,diagflat,diagonal,diff,digitize,divide,divmod,dot,dsplit,dstack,ediff1d,einsum,empty,empty_like,exp,exp2,expand_dims,expm1,extract,eye,fabs,fill,fill_diagonal,fix,flatnonzero,flatten,flip,fliplr,flipud,float_power,floor,floor_divide,fmax,fmin,fmod,frexp,frombuffer,fromfile,fromfunction,fromiter,fromregex,fromregexSync,fromstring,full,full_like,gcd,genfromtxt,genfromtxtSync,geomspace,geterr,gradient,heaviside,histogram,histogram2d,histogram_bin_edges,histogramdd,hsplit,hstack,hypot,i0,identity,iindex,imag,in1d,indices,inner,insert,interp,intersect1d,invert,iscomplex,iscomplexobj,isdtype,isfinite,isfortran,isin,isinf,isnan,isnat,isneginf,isposinf,isreal,isrealobj,isscalar,issubdtype,item,iterable,ix_,kron,lcm,ldexp,left_shift,lexsort,linalg,linspace,load,loadNpy,loadNpySync,loadNpz,loadNpzFile,loadNpzFileSync,loadNpzSync,loadSync,loadtxt,loadtxtSync,log,log10,log1p,log2,logaddexp,logaddexp2,logical_and,logical_not,logical_or,logical_xor,logspace,mask_indices,matrix_transpose,matvec,max,maximum,may_share_memory,median,meshgrid,min,min_scalar_type,minimum,mintypecode,mod,modf,moveaxis,nan_to_num,nanargmax,nanargmin,nancumprod,nancumsum,nanmax,nanmean,nanmedian,nanmin,nanpercentile,nanprod,nanquantile,nanstd,nansum,nanvar,ndim,negative,nextafter,nonzero,ones,ones_like,outer,packbits,pad,parseNpy,parseNpyData,parseNpyHeader,parseNpz,parseNpzSync,parseTxt,partition,percentile,permute_dims,place,poly,polyadd,polyder,polydiv,polyfit,polyint,polymul,polysub,polyval,positive,pow,power,promote_types,ptp,put,put_along_axis,putmask,quantile,rad2deg,radians,random,ravel,ravel_multi_index,real,real_if_close,reciprocal,remainder,repeat,require,reshape,resize,result_type,right_shift,rint,roll,rollaxis,roots,rot90,round,round_,row_stack,save,saveNpy,saveNpySync,saveNpz,saveNpzSync,saveSync,savetxt,savetxtSync,savez,savez_compressed,searchsorted,select,serializeNpy,serializeNpz,serializeNpzSync,serializeTxt,setdiff1d,seterr,setxor1d,shape,shares_memory,sign,signbit,sin,sinc,sinh,size,sort,sort_complex,spacing,split,sqrt,square,squeeze,stack,swapaxes,take,take_along_axis,tan,tanh,tensordot,tile,tobytes,tofile,tolist,trace,transpose,trapezoid,tri,tril,tril_indices,tril_indices_from,trim_zeros,triu,triu_indices,triu_indices_from,true_divide,trunc,typename,union1d,unique,unique_all,unique_counts,unique_inverse,unique_values,unpackbits,unravel_index,unstack,unwrap,vander,vdot,vecdot,vecmat,view,vsplit,vstack,where,zeros,zeros_like});
4
4
  //# sourceMappingURL=numpy-ts.node-io.cjs.map