-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.min.cjs
1 lines (1 loc) · 66.3 KB
/
bundle.min.cjs
1
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("util")):"function"==typeof define&&define.amd?define(["exports","util"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nj={},e.util)}(this,(function(e,t){"use strict";function n(e,t){if(e==t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}return me(e,t,!0)}function r(e){return e instanceof b&&(e=e.valueOf()),e}let l=new class{compare=n;constructor(){this.tasks={},this._onload=[]}onload(e){this._onload.push(e)}add(e,t,n,r=this.compare){return"function"==typeof e&&(e=e.name),(this.tasks[e]??(this.tasks[e]=[])).push({test:t,expected:n,compare:r}),this}run(e){if(null==e){let e=!0;for(let t of Object.keys(this.tasks))e=this.run(t)&&e;let t=(e?"[32m":"[31m")+"%s[0m";return console.log(t,`Status: ${e}, Total: ${Object.keys(this.tasks).length}`),this._onload.forEach((e=>e())),e}let t=this.tasks[e];if(null==t)throw"no such name";let n=1,l=0,i=[];for(let e of t){let t,s,{test:a,expected:o,compare:u}=e,f=!1,h=!1;try{t=a()}catch(e){t=`[Error]: ${e}`,console.log(e),h=!0}try{s=o()}catch(e){s=`[Error]: ${e}`,console.log(e),h=!0}h||(f=u(t,s)),f&&l++;let p=(f?"[32m":"[31m")+"%s[0m";i.push([p,`#${n}: ${f?"passed":"fail"}`,"\nTest=\n",r(t),"\nExpected=\n",r(s)]),n++}let s=(l==t.length?"[32m":"[31m")+"%s[0m";if(console.log(s,`Testing ${e}: ${l} / ${t.length} cases passed`),l!=t.length)for(let e of i)console.log(...e);return l==t.length}};let i=e=>e,s=new WeakMap;class o{#e;constructor(e=i,t=Array,n=`${e}`){this.name=n,this.type=e,this.#e=t,s.set(e,n),s.set(t,n)}new(e,t=null){let n=new this.#e(e);if(null!=t)if(null!=n.set)n.set(t);else for(let e=0;e<t.length;e++)n[e]=t[e];return n}toString(){return`dtype('${this.name}')`}valueOf(){return this.type}}let u={int8:new o(Number,Int8Array,"int8"),uint8:new o(Number,Uint8Array,"uint8"),int16:new o(Number,Int16Array,"int16"),uint16:new o(Number,Uint16Array,"uint16"),int32:new o(Number,Int32Array,"int32"),uint32:new o(Number,Uint32Array,"uint32"),float32:new o(Number,Float32Array,"float32"),float64:new o(Number,Float64Array,"float64"),boolean:new o(Boolean,class extends Array{},"boolean"),number:new o(Number,class extends Array{},"number"),string:new o(String,class extends Array{},"string"),object:new o(i,Array,"object")};function f(e="object",t=void 0,n=void 0){if("string"==typeof e){if(!Object.hasOwn(u,e))throw new Error(`${e} is not supported`);return u[e]}return e instanceof o?e:s.has(e)?u[s.get(e)]:u[n]=new o(e,t,n)}Object.assign(u,{int:u.number,float:u.number});const h=f;class p{static newaxis=null;static ellipsis=new p;static colon=new p;constructor(e,t,n){this.start=e,this.stop=t,this.step=n}indices(e=null){if(this==p.ellipsis)throw new Error("ellipsis does not support .indices()");let t,{start:n,stop:r,step:l}=this;if(l??=1,null==e){if(n??=0,null==r)throw new Error("stop must be non-null")}else{null==n?n=l<0?e-1:0:(n<0&&(n+=e),n<0&&(n=l<0?-1:0),n>=e&&(n=l<0?e-1:e)),null==r?r=l<0?-1:e:(r<0&&(r+=e),r<0&&(r=l<0?-1:0),r>=e&&(r=l<0?e-1:e))}return t=0==l||l<0&&r>=n||l>0&&n>=r?0:l<0?(r-n+1)/l+1|0:(r-n-1)/l+1|0,new d(n,r,l,t)}toString(){if(this==p.ellipsis)return"...";if(this==p.colon)return":";let{start:e,stop:t,step:n}=this,r=`${e??""}:${t??""}`;return null!=n&&(r+=`:${n}`),r}}p.prototype[t?.inspect?.custom]=function(){return this.toString()};class d{#t;#n;#r;constructor(e,t,n,r){this.start=e,this.stop=t,this.step=n,this.slicelength=r}[Symbol.iterator](){return this.reset(),this}reset(){let{start:e,slicelength:t}=this;this.#r=0,this.#n=0==t,this.#t=e}next(){if(this.#n)return{done:!0};let{step:e,slicelength:t}=this,n=this.#t;return this.#t+=e,this.#n=++this.#r>=t,{value:n,done:!1}}}let c=Object.assign(Object.create(null),{None:p.newaxis,"...":p.ellipsis,":":p.colon}),m=e=>0==(e=e.trim()).length?null:+e,g=(e,t)=>{if(null!=e&&!Number.isInteger(e=+e))throw new Error(`${t} must be either null or able to convert to integer`);return e};function y(e=null,t=null,n=null){if("string"==typeof e){if(Object.hasOwn(c,e))return c[e];let r=e.split(":");if(0==r.length||r.length>3)throw new Error(`invalid string slice representation ${e}`);e=m(r[0]),t=r.length>1?m(r[1]):null,n=r.length>2?m(r[2]):null}else e&&"object"==typeof e&&(null!=e[Symbol.iterator]?[e=null,t=null,n=null]=e:null!=e.length?({0:e=null,1:t=null,2:n=null}=e):({start:e=null,stop:t=null,step:n=null}=e));return null==e&&null==t&&null==n?p.colon:(e=g(e,"start"),t=g(t,"stop"),n=g(n,"step"),new p(e,t,n))}function w(e){switch(typeof e){case"boolean":case"function":case"number":case"string":return!0}return!1}y.newaxis=p.newaxis,y.ellipsis=p.ellipsis,y.colon=p.colon;class b{constructor(e,t=null,n=null,r=null,l=null,i=0,s=1){this.ndim=e.length,this.size=_(e),this.shape=e,this.data=t??Array(this.size),this.itemsize=s,this.strides=l??x(e,this.ndim,s),this.offset=i,this.dtype=h(n??t.constructor),this.base=r?.base??r}get length(){let{ndim:e,shape:t}=this;if(0!=e)return t[0]}get flat(){return new Dr(this)}set flat(e){this.flat.set(":",e)}get T(){return Y(this)}set T(e){this.T.set(e)}toString(){return $r(this)}valueOf(){return 0==this.ndim?this.item():vr(this)}*[Symbol.iterator](){for(let e=0;e<this.shape[0];e++)yield this.at(e)}as_strided(e=this.shape,t=this.strides,n=this.offset){let{data:r,dtype:l,base:i,itemsize:s}=this;return new b(e,r,l,i??this,t,n,s)}keys(){let{shape:e,strides:t,offset:n}=this;return Tr(e,t,n)}values(){return this.flat}idx(e){let{shape:t,strides:n,ndim:r,size:l,offset:i}=this;if(0==e)return i;if(null==e){if(1!=l)throw new Error("index cannot be empty if size != 1");return i}let s=function(e,t,n,r){if(Number.isInteger(e)){let l=e;if(l<0&&(l+=r),l<0||l>=r)throw new Error(`index ${e} out of bound for size ${r}`);if(0==n)return[0];let i=Array(n);for(let e=n-1;e>=0;e--)i[e]=l%t[e],l=l/t[e]|0;return i}if(e.length!=n)throw new Error("incorrect number of indices for array");return e}(e,t,r,l);for(let e=0;e<s.length;e++){let r=s[e],l=t[e];if(r<0&&(r+=l),r<0||r>=l)throw new Error(`index ${s[e]} out of bound for dimension ${l}`);i+=r*n[e]}return i}at(...e){return this.get(e)}slice(e=null,t=null){return this.at(y(e,t))}get(e,t=0){return $(e)?v(this,e,t):Rr(this,e,t).get()}set(e,t){return 1==arguments.length?O(this,e):$(e)?O(v(this,e),t):Rr(this,e).set(t),this}item(e){return this.data[this.idx(e)]}itemset(e,t){return this.data[this.idx(e)]=t,this}astype(e,t=!0){if(e=h(e),t||=this.dtype!=e,!t)return this;let{shape:n,size:r}=this,l=e.new(r,[...this.flat]);return new b(n,l,e)}array(){let{ndim:e}=this;if(0==e)return this.data[this.offset];let t,{shape:n,size:r}=this;if(0==r){if(1==e)return[];let r=1,l=0;for(let t;l<e&&(t=n[l]);l++)r*=t;e=l,t=Array.from({length:r},(()=>[]))}else t=[...this.flat];for(let r=e-1;r>0;r--){let e=n[r],l=[];for(let n=0;n<t.length;n+=e)l.push(t.slice(n,n+e));t=l}return t}toarray(){return this.array()}tolist(){return this.array()}reshape(...e){return 1==e.length&&"object"==typeof e[0]&&(e=e[0]),U(this,e)}add(e,t=null){return xe(this,e,t)}sub(e,t=null){return ke(this,e,t)}mul(e,t=null){return Ae(this,e,t)}div(e,t=null){return ze(this,e,t)}mod(e,t=null){return qe(this,e,t)}all(e=null,t=null,n=!1,r=!0,l=!0){return Ce(this,e,t,n,r,l)}any(e=null,t=null,n=!1,r=!1,l=!0){return Ge(this,e,t,n,r,l)}argmax(e=null,t=null,n=!1){return Zr(this,e,t,n)}argmin(e=null,t=null,n=!1){return el(this,e,t,n)}argpartition(e,t=-1,n="introselect",r=null){throw"not implemented"}argsort(e=-1,t=null){return $n(this,e,t)}byteswap(){throw"not implemented"}choose(e,t=null,n="raise"){throw"not implemented"}clip(e,t,n=null){return _n(this,e,t,n)}compress(e,t=null,n=null){return ue(e,this,t,n)}conj(){throw"not implemented"}conjugate(){throw"not implemented"}copy(){return A(this)}cumprod(e,t){return Ur(this,e,t)}cumsum(e,t){return Vr(this,e,t)}diagonal(e=0,t=0,n=1){return Jn(this,e,t,n)}dump(){throw"not implemented"}dumps(){throw"not implemented"}fill(e){let{data:t,shape:n,strides:r,offset:l}=this;for(let i of Tr(n,r,l))t[i]=e;return this}flatten(){let{size:e,flat:t,dtype:n}=this;return new b([e],[...t],n)}getfield(){throw"not implemented"}max(e=null,t=null,n=!1,r=null,l=!0){return Wt(this,e,t,n,r,l)}mean(e=null,t=null,n=!1){return Vn(this,e,t,n)}min(e=null,t=null,n=!1,r=null,l=!0){return Ht(this,e,t,n,r,l)}newbyteorder(){throw"not implemented"}nonzero(){return oe(this)}partition(e,t=-1,n="introselect",r=null){throw"not implemented"}prod(e=null,t=null,n=!1,r=0,l=!0){return At(this,e,t,n,r,l)}ptp(e=null,t=null,n=!1){return Un(this,e,t,n)}put(e,t,n="raise"){return Yn(this,e,t,n),this}ravel(){return fe(this)}repeat(e,t=null){return Hn(this,e,t)}resize(e){if(null!=this.base)throw"cannot resize this array: it does not own its data";if(!Q(this))throw"resize only works on single-segment arrays";let t=_(e);return t<=this.size?this.data=[...this.data.slice(this.offset,t)]:this.data=[...this.data.slice(this.offset,t),...Array(t-this.size).fill(0)],this.shape=e,this.ndim=e.length,this.strides=x(e,this.ndim,this.itemsize),this.offset=0,this}round(e=0,t=null){return wt(this,e,t)}searchsorted(e,t="left"){return Zn(this,e,t)}setfield(){throw"not implemented"}setflags(){throw"not implemented"}sort(e=-1,t=null){return this.set(vn(this,e,t)),this}squeeze(e=null){return ae(this,e)}std(e=null,t=null,n=0,r=!1){return Xn(this,e,t,n,r)}sum(e=null,t=null,n=!1,r=0,l=!0){return zt(this,e,t,n,r,l)}swapaxes(e,t){return R(this,e,t)}take(e,t=null,n=null,r="raise"){return G(this,e,t,n,r)}tobytes(){throw"not implemented"}tofile(){throw"not implemented"}trace(){throw"not implemented"}transpose(e=null){return Y(this,e)}variance(e=null,t=null,n=0,r=!1){return Bn(this,e,t,n,r)}}function x(e,t,n){if(0==t)return[];let r=Array(t);r[t-1]=n;for(let n=t-1;n>0;n--)r[n-1]=r[n]*e[n];return r}function _(e){let t=1;for(let n of e)t*=n;return t}function $(e){for(let t of e)if(null!=t&&"object"==typeof t&&null!=t.length)return!1;return!0}function v(e,t,n=0){let{ndim:r,shape:l,strides:i,offset:s}=e,a=0,o=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n==p.ellipsis||"..."==n){if(-1!=o)throw new Error("can only have a single ellipsis '...'");o=e}else null==n&&a++}let u=0;if(-1!=o&&(u=r-n-(t.length-a-1)),n+(t.length-a-(-1!=o))>r)throw new Error("too many indices");let f=[],h=[];for(let e=0;e<n;e++)f.push(l[e]),h.push(i[e]);for(let e of t)if(null==e)f.push(1),h.push(0);else{if("string"==typeof e)e=y(e);else if(!(e instanceof p)){let t=e;if(e<0&&(e+=l[n]),e<0||e>l[n])throw new Error(`index ${t} out of bound for dimension size ${l[n]}`);s+=i[n]*e,n++;continue}if(e==p.ellipsis){for(let e=0;e<u;e++)f.push(l[n+e]),h.push(i[n+e]);n+=u}else if(e==p.colon)f.push(l[n]),h.push(i[n]),n++;else{let{start:t,step:r,slicelength:a}=e.indices(l[n]);s+=i[n]*t,f.push(a),h.push(i[n]*r),n++}}for(let e=n;e<r;e++)f.push(l[e]),h.push(i[e]);return e.as_strided(f,h,s)}function A(e,t=void 0,n=!0,r=0){if(e instanceof b){let{shape:l,ndim:i}=e;return i<r&&(l=Array(r-i).fill(1).concat(l),e=e.reshape(l)),e.astype(t??e.dtype,n)}let l=j(e),i=[];z(i,e,l,0);let s=l.length;return s<r&&(l=Array(r-s).fill(1).concat(l)),t=h(t??M(i)),new b(l,t.new(i.length,i),t)}function z(e,t,n,r=0){if(r<n.length)for(let l=0;l<n[r];l++)z(e,t.at(l),n,r+1);else"function"==typeof t?.toarray&&(t=t.toarray()),e.push(t)}function M(e){let t;if("object"==typeof e&&e?.[Symbol.iterator]){t=typeof e[0];for(let n of e)if(t!=typeof n){t="object";break}}else t=typeof e;return"number"==t||"string"==t||"boolean"==t?t:"object"}function k(e,t,n=0){for(let r=0;r<e.length&&n<t.length;r++){let l=e[r];if(null==l||"object"!=typeof l||l.length!=t[n]){t.length=n;break}if(l instanceof b){for(let e=n,r=0;e<t.length&&r<l.ndim;e++,r++)if(t[e]!=l.shape[r]){t.length=e;break}}else n+1<t.length&&k(l,t,n+1)}}function E(e){if(null==e||"object"!=typeof e)return[];if(null!=e.shape)return e.shape;let t=[],n=e;for(;;){if(n instanceof b)t.push(...n.shape);else if("object"==typeof n&&null!=n?.length){t.push(n.length),n=n[0];continue}break}return t.length>1&&k(e,t,1),t}b.prototype[t?.inspect?.custom]=function(){return this.valueOf()},l.onload((()=>{}));const N=E,j=E;function S(e,t){e=T(e);let{strides:n,ndim:r}=e;if(r>t.length)throw new Error("broadcast shape has less dimensions than input array");let l=[];for(let r=t.length-1,i=e.shape.length-1;r>=0;r--,i--){if(i>=0&&1!=e.shape[i]&&e.shape[i]!=t[r])throw new Error("operands could not be broadcast together");l[r]=i<0||1==e.shape[i]?0:n[i]}return e.as_strided(t,l)}function q(...e){let t=X(...(e=e.map((e=>T(e)))).map((e=>e.shape)));return e.map((e=>S(e,t)))}function O(e,t){if(1==(t=T(t)).size)e.fill(t.item());else{let n=S(t,e.shape).flat[Symbol.iterator](),{data:r,shape:l,strides:i,offset:s}=e;for(let e of Tr(l,i,s))r[e]=n.next().value}}function I(e){return new F(e)}class F{constructor(e){this.ndim=e.length,this.size=_(e),this.shape=e,this.coords=Array(this.ndim),this.index,this.done,this[Symbol.iterator]()}[Symbol.iterator](){return this.coords.fill(0),this.index=0,this.done=0==this.size,this}next(){if(this.done)return{done:!0};let{coords:e,size:t,index:n}=this;if(0!=n){let{shape:t,ndim:n}=this,r=n-1,l=!0;for(;r>=0;){let n=t[r];if(1==n)r--;else if(n==e[r])e[r--]=0,l=!0;else{if(!l)break;e[r]++,l=!1}}}return this.done=++this.index>=t,{value:e,done:!1}}}function T(e,t=void 0){return e instanceof b?null==t?e:e.astype(t,!1):A(e,t)}function D(e,t=void 0){return e=P(e),t=h(t),new b(e,t.new(_(e)),t)}function L(e,t=void 0){return D((e=T(e)).shape,t??e.dtype)}function P(e){return e?("function"==typeof e.toarray&&(e=e.toarray()),"object"==typeof e&&null!=e.length?e:[e]):[e]}function U(e,t){e=T(e),t=P(t);let n=-1,r=1;for(let e=0;e<t.length;e++)if(-1==t[e]){if(-1!=n)throw new Error("can only specify one unknown dimension");n=e}else r*=t[e];if(-1!=n){if(e.size%r!=0)throw new Error(`cannot reshape array of size ${e.size} into shape [${t.join(", ")}]`);t[n]=0==r?0:e.size/r}if(e.size!=_(t))throw new Error(`cannot reshape array of size ${e.size} into shape [${t.join(", ")}]`);if(null==e.base)return e.as_strided(t,x(t,t.length,e.itemsize));{let n=!0,r=0;for(let l=0;l<t.length;l++)if(1!=t[l]){for(;r<e.shape.length&&1==e.shape[r];r++);if(r>=e.shape.length||t[l]!=e.shape[r]){n=!1;break}r++}if(r!=e.shape.length&&(n=!1),n){let n=[];for(let r=0,l=0;r<t.length;r++){if(1!=t[r])for(;l<e.shape.length&&1==e.shape[l];l++);n.push(l<e.shape.length?e.strides[l++]:1)}return e.as_strided(t,n)}}let l=null;return 1==t.length&&function(e,t,n){let r;for(let t=n-1;t>0;t--)if(e[t]>1){r=t;break}for(let n=r-1;n>=0;n--)if(e[n]>1){if(t[n]!=t[r]*e[r])return!1;r=n}return!0}(e.shape,e.strides,e.ndim)?l=[e.strides[0]]:0!=t.length&&(e=A(e)),e.as_strided(t,l)}function V(e,t,n=void 0){let r=D(e,n??M(t));return O(r,t),r}function B(e,t,n=void 0){return V(E(e),t,n)}function X(...e){let t=0;for(let n of e)t=Math.max(t,n.length);if(0==t)return[];let n=Array(t).fill(1);for(let r of e)for(let e=r.length-1,l=t-1;e>=0;e--,l--){let t=r[e];if(1!=t)if(1==n[l])n[l]=t;else if(n[l]!=t)throw new Error("shape mismatch")}return n}function C(e,t=void 0,n=1){null==t&&(t=e,e=0);let r=Math.max(0,(t-e)/n|0),l=D([r],"number"),{data:i}=l;for(let t=0;t<r;t++)i[t]=e+t*n;return l}function G(e,t,n=null,r=null,l="raise"){if(e=T(e),t=A(t),null==n){t.data=W(t.data,l,e.size);let n=t.shape;if(null==r)r=D(n);else if(!ge(r.shape,n))throw"output array does not match result of ndarray.take";for(let n=0;n<t.size;n++)r.data[n]=e.item(t.data[n]);return r}{n<0&&(n+=e.ndim),t.data=W(t.data,l,e.shape[n]);let i=e.shape.slice();if(i.splice(n,1,...t.shape),null==r)r=D(i);else if(!ge(r.shape,i))throw"output array does not match result of ndarray.take";let s=Array(n).fill(y());for(let n of I(t.shape))r.get(s.concat(n)).set(e.get([...s,t.item(n)]));return r}}function W(e,t,n){let r=[];if("wrap"==t)for(let t of e)t%=n,t=t<0?t+n:t,r.push(t);else if("clip"==t)for(let t of e)s=n-1,t=(l=t)<(i=0)?i:l>s?s:l,r.push(t);else{if("raise"!=t)throw`unexpected mode = ${t}`;for(let t of e){if(t<-n||t>=n)throw`index ${t} is out of bounds for axis 0 with size ${n}`;t=t<0?t+a.size:t,r.push(t)}}var l,i,s;return r}function H(e,t=void 0){return V(e,0,t)}function J(e,t=void 0){return B(e,0,t)}function K(e,t=void 0){return Q(e=T(e,t))?e:A(e)}function Q(e){let{strides:t,shape:n,ndim:r,itemsize:l}=e;if(0==r)return!1;for(let e=r-1;e>=0;e--)if(n[e]>1){if(l!=t[e])return!1;l*=n[e]}return!0}function R(e,t,n){e=T(e);let r=[...Array(e.ndim).keys()];return[r[t],r[n]]=[r[n],r[t]],Y(e,r)}function Y(e,t=null){e=T(e);let n,r,{ndim:l,shape:i,strides:s}=e;if(null==t)n=i.slice().reverse(),r=s.slice().reverse();else{t=function(e,t){if(e.length!=t)throw new Error("axes don't match array");let n=[],r={};for(let l=0;l<t;l++){let i=e[l];if(i<0&&(i+=t),i<0||t<=i)throw new Error(`axis ${i} is out of bounds for array of dimension ${l+1}`);if(r[i])throw new Error("repeated axis in transpose");r[i]=!0,n[l]=i}return n}(t,l),n=Array(l),r=Array(l);for(let e=0;e<l;e++)n[e]=i[t[e]],r[e]=s[t[e]]}return e.as_strided(n,r)}function Z(...e){if(1!=e.length)return e.map((e=>Z(e)));let t=T(e[0]),{ndim:n}=t;return n>=1?t:t.copy().reshape([1])}function ee(...e){if(1!=e.length)return e.map((e=>ee(e)));let t=T(e[0]),{ndim:n,shape:r}=t;return n>=2?t:1==n?t.reshape([1,r[0]]):t.copy().reshape([1,1])}function te(...e){if(1!=e.length)return e.map((e=>te(e)));let t=T(e[0]),{ndim:n,shape:r}=t;return n>=3?t:2==n?t.reshape([r[0],r[1],1]):1==n?t.reshape([1,r[0],1]):t.copy().reshape([1,1,1])}function ne(...e){return new re(e.map((e=>T(e))))}class re{constructor(e){this.shape=X(...e.map((e=>e.shape))),this.arrays=e.map((e=>S(e,this.shape))),this.ndim=this.shape.length,this.size=_(this.shape),this.reset()}[Symbol.iterator](){return 0!=this.index&&this.reset(),this}next(){let e=this.iters.map((e=>e.next().value)),t=this.index>=this.size;return this.index++,{value:e,done:t}}reset(){this.iters=this.arrays.map((e=>e.flat)),this.index=0}}function le(e,t=e,n=0,r="number"){let l=H([e,t],r),{data:i,size:s}=l;for(let e=n+Math.ceil(-n/(t+1))*(t+1);e<s;e+=t+1)i[e]=1;return l}function ie(e){return null==e||"object"!=typeof e?0:null!=e.ndim?e.ndim:E(e).length}const se=ie;function ae(e,t=null){e=T(e),null!=t&&(t=de(t));let{shape:n,ndim:r}=e,l=[];for(let e=0;e<r;e++)(t?t.includes(e):1==n[e])||l.push(n[e]);return e.reshape(l)}function oe(e){e=Z(e);let{ndim:t}=e,n=[];for(let e=0;e<t;e++)n.push([]);for(let[r,l]of Lr(e))if(l)for(let e=0;e<t;e++)n[e].push(r[e]);return n.map((e=>T(e)))}function ue(e,t,n=null,r=null){if(1!=(e=T(e)).ndim)throw"condition must be a 1-d array";return G(t,oe(e)[0],n,r)}function fe(e){e=K(e);let{size:t,base:n,offset:r,itemsize:l}=e;return(e=e.as_strided([t],x([t],1,l),r)).base=n,e}function he(e,t=null,n=!1){return zt(fn(e,0),t,null,n)}function pe(e,t,n=!1){if(Array.isArray(e)||(e=[e]),e=e.map((e=>yr(e,t))),!n&&new Set(e).size!=e.length)throw"repeated axis";return e}const de=pe;class ce{constructor(e,t=null){this.array=T(e);let{ndim:n,shape:r}=e;if(null!=t&&(t=pe(t,n)),this.axis=t,null!=t){let e=[],l=[],i=[];for(let s=0;s<n;s++)(i[s]=!t.includes(s))?(l[s]=0,e.push(r[s])):l[s]=y[":"];this.shape=e,this.indices=l,this.mask=i}else this.shape=[e.size],this.indices=[0],this.mask=null}*[Symbol.iterator](){let{array:e,axis:t}=this;if(null==t)return void(yield*e.flat);let{shape:n,mask:r,indices:l}=this;for(let t of I(n)){for(let n=0,i=0;n<e.ndim;n++)r[n]&&(l[n]=t[i++]);yield[t,e.get(l)]}}}function me(e,t,n=!1){return e=T(e),t=T(t),!!ge(e.shape,t.shape)&&Ce(n?ye(e,t):un(e,t))}function ge(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const ye=ir("nan_equal",((e,t)=>e==t||Number.isNaN(e)&&Number.isNaN(t)));function we(e,t=0,n=void 0){if(0==e.length)throw new Error("need at least one array to concatenate");e=e.map((e=>T(e))),null==t&&(e=e.map((e=>fe(e))),t=0);let{ndim:r,shape:l}=e[0];if(0==r)throw new Error("zero-dimensional arrays cannot be concatenated");for(let n=1;n<e.length;n++){let i=e[n];if(i.ndim!=r)throw new Error(`all the input arrays must have same number of dimensions, but the array at index 0 has ${r} dimension(s) and the array at index ${n} has ${e[n].ndim} dimension(s)`);for(let s=0;s<r;s++)if(s!=t&&i.shape[s]!=l[s])throw new Error(`all the input array dimensions for the concatenation axis must match exactly, but along dimension ${s}, the array at index 0 has size ${l[s]} and the array at index ${n} has size ${e[n].shape[s]}`)}t=yr(t,r);let i=l.slice();if(i[t]=e.reduce(((e,n)=>e+n.shape[t]),0),null==n)n=D(i);else{if(n.ndim!=r)throw new Error("output array has wrong dimensionality");if(!ge(n.shape,i))throw new Error("output array is the wrong shape")}let s=Array(r).fill(y(":")),a=0;for(let r of e)s[t]=y(a,a+=r.shape[t]),n.set(s,r);return n}function be(e,t,n){e=T(e);let{ndim:r}=e;if(t=de(t,r),n=de(n,r),t.length!=n.length)throw new Error("'src' and 'dst' arguments must have the same number of elements");let l=[...Array(r).keys()].filter((e=>!t.includes(e)));for(let e=0;e<t.length;e++)l.splice(n[e],0,t[e]);return Y(e,l)}const xe=ir("add",((e,t)=>e+t)),_e=lr("reciprocal",(e=>1/e)),$e=lr("positive",(e=>+e)),ve=lr("negative",(e=>-e)),Ae=ir("multiply",((e,t)=>e*t)),ze=ir("divide",((e,t)=>e/t)),Me=ir("power",((e,t)=>e**t)),ke=ir("subtract",((e,t)=>e-t)),Ee=ze,Ne=ir("floor_divide",((e,t)=>e/t|0)),je=Me,Se=ir("fmod",((e,t)=>e-(e/t|0)*t)),qe=ir("mod",((e,t)=>(e%t+t)%t));const Oe=e=>e%1,Ie=e=>0|e,Fe=qe;const Te=ir("logical_and",((e,t)=>e&&t),{dtype:"boolean"}),De=Te,Le=ir("logical_or",((e,t)=>e||t),{dtype:"boolean"}),Pe=Le,Ue=lr("logical_not",(e=>!e),{dtype:"boolean"}),Ve=Ue,Be=ir("logical_xor",((e,t)=>!e!=!t),{dtype:"boolean"}),Xe=Be,Ce=sr("all",((e,t)=>e&&!!t),!0),Ge=sr("any",((e,t)=>e||!!t),!1),We=lr("isfinite",Number.isFinite),He=lr("isinf",(e=>e==1/0||e==-1/0)),Je=lr("isnan",Number.isNaN),Ke=lr("isneginf",(e=>e==-1/0)),Qe=lr("isposinf",(e=>e==1/0)),Re=Math.E,Ye=Math.PI,Ze=1/0,et=lr("sin",Math.sin),tt=lr("cos",Math.cos),nt=lr("tan",Math.tan),rt=lr("arcsin",Math.asin),lt=lr("arccos",Math.acos),it=lr("arctan",Math.atan),st=lr("hypot",Math.hypot),at=lr("arctan2",Math.atan2),ot=lr("degrees",(e=>180*e/Ye)),ut=lr("radians",(e=>e/180*Ye));const ft=lr("rad2deg",(e=>180*e/Ye)),ht=lr("deg2rad",(e=>e/180*Ye)),pt=lr("sinh",Math.sinh),dt=lr("cosh",Math.cosh),ct=lr("tanh",Math.tanh),mt=lr("arcsinh",Math.asinh),gt=lr("arccosh",Math.acosh),yt=lr("arctanh",Math.atanh);function wt(e,t=0,n=null){if(e=T(e),null==n)n=D(e.shape);else if(!ge(n.shape,e.shape))throw new Error("shape does not match");let r=0;for(let l of e.flat){let e=10**t,i=l*e,s=Math.round(i),a=i%1;.5!=a&&-.5!=a||(s=s%2?s-1:s),n.itemset(r++,s/e)}return n}const bt=lr("rint",(e=>{let t=e%1,n=Math.round(e);return.5!=t&&-.5!=t||(n=n%2?n-1:n),n})),xt=lr("fix",(e=>Math.sign(e)*Math.floor(Math.abs(e)))),_t=lr("floor",Math.floor),$t=lr("ceil",Math.ceil),vt=lr("trunc",Math.trunc),At=sr("prod",((e,t)=>e*t),1),zt=sr("sum",((e,t)=>e+t),0),Mt=sr("nanprod",((e,t)=>e*(isNaN(t)?1:t)),1),kt=sr("nansum",((e,t)=>e+(isNaN(t)?0:t)),0);function Et(e,t=1,n=-1){e=T(e);let{ndim:r}=e;n=yr(n,r);let l=Array(r).fill(y()),i=Array(r).fill(y());l[n]=y(1,null),i[n]=y(null,-1);for(let n=0;n<t;n++)e=ke(e.get(l),e.get(i));return e}const Nt=lr("exp",Math.exp,1),jt=lr("expm1",(e=>Math.exp(e)-1)),St=lr("exp2",(e=>2**e)),qt=lr("log",Math.log),Ot=lr("log10",Math.log10),It=lr("log2",Math.log2),Ft=lr("log1p",Math.log1p),Tt=ir("logaddexp",((e,t)=>Math.log(Math.exp(e)+Math.exp(t)))),Dt=ir("logaddexp2",((e,t)=>Math.log2(2**e+2**t))),Lt=lr("signbit",(e=>e<0)),Pt=ir("copysign",((e,t)=>t<0?-Math.abs(e):Math.abs(e))),Ut=ir("ldexp",((e,t)=>e*2**t));function Vt(e,t){for(;0!=t;){let n=t;t=e%t,e=n}return e}const Bt=ir("lcm",(function(e,t){return e*t/Vt(e,t)})),Xt=ir("gcd",Vt),Ct=ir("maximum",Math.max),Gt=ir("minimum",Math.min),Wt=sr("amax",Math.max,-1/0),Ht=sr("amin",Math.min,Ze),Jt=lr("sqrt",Math.sqrt),Kt=lr("cbrt",Math.cbrt),Qt=lr("square",(e=>e**2)),Rt=lr("abs",Math.abs),Yt=Rt,Zt=lr("sign",Math.sign),en=lr("nan_to_num",(e=>isNaN(e)?0:e==1/0?Number.MAX_VALUE:e==-1/0?Number.MIN_VALUE:e)),tn=ir("bitwise_and",((e,t)=>e&t)),nn=ir("bitwise_or",((e,t)=>e|t)),rn=ir("bitwise_xor",((e,t)=>e^t)),ln=lr("bitwise_not",(e=>~e)),sn=ln,an=ir("left_shift",((e,t)=>e<<t)),on=ir("right_shift",((e,t)=>e>>t)),un=ir("equal",((e,t)=>e==t),{dtype:"boolean"}),fn=ir("not_equal",((e,t)=>e!=t),{dtype:"boolean"}),hn=ir("less",((e,t)=>e<t),{dtype:"boolean"}),pn=ir("less_equal",((e,t)=>e<=t),{dtype:"boolean"}),dn=ir("greater",((e,t)=>e>t),{dtype:"boolean"}),cn=ir("greater_equal",((e,t)=>e>=t),{dtype:"boolean"}),mn=un,gn=fn,yn=hn,wn=pn,bn=dn,xn=cn;function _n(e,t,n,r=null){if(e=T(e),null==r)r=L(e);else if(!ge(e.shape,r.shape))throw"out shape does not match input shape";if(w(t)&&w(n)){let l=Tr(e.shape,e.strides)[Symbol.iterator]();for(let i of Tr(r.shape,r.strides))r.data[i]=Math.min(Math.max(t,e.data[l.next().value]),n);return r}t=S(t,e.shape),n=S(n,e.shape);let l=Tr(e.shape,e.strides)[Symbol.iterator](),i=Tr(t.shape,t.strides)[Symbol.iterator](),s=Tr(n.shape,n.strides)[Symbol.iterator]();for(let a of Tr(r.shape,r.strides))r.data[a]=Math.min(Math.max(t.data[i.next().value],e.data[l.next().value]),n.data[s.next().value]);return r}function $n(e,t=-1,n=null){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let r=L(e),l=Array(e.shape[t]),i=Array(e.shape[t]),s=(e,t)=>l[e]-l[t],a=e.shape.slice();a[t]=1;for(let o of I(a)){let{offset:u}=e,{offset:f}=r;for(let t=0;t<a.length;t++)u+=o[t]*e.strides[t],f+=o[t]*r.strides[t];for(let r=0;r<e.shape[t];r++){let s=e.data[u+r*e.strides[t]];l[r]=null!=n?n(s):s,i[r]=r}i.sort(s);for(let n=0;n<e.shape[t];n++)r.data[f+n*r.strides[t]]=i[n]}return r}function vn(e,t=-1,n=null){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let r=L(e),l=Array(e.shape[t]),i=(e,t)=>e-t,s=e.shape.slice();s[t]=1;for(let a of I(s)){let{offset:o}=e,{offset:u}=r;for(let t=0;t<s.length;t++)o+=a[t]*e.strides[t],u+=a[t]*r.strides[t];for(let r=0;r<e.shape[t];r++){let i=e.data[o+r*e.strides[t]];l[r]=null!=n?n(i):i}l.sort(i);for(let n=0;n<e.shape[t];n++)r.data[u+n*r.strides[t]]=l[n]}return r}function An(e){let t=Array(e.length),n=t[0]=e[0];for(let r=1;r<e.length;r++)t[r]=n+=e[r];return t}function zn(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function Mn(e,t,n){let r=n()*t,l=e.length-1;for(let t=0;t<l;t++)if(r-=e[t],r<0)return t;return l}function kn(e,t,n){let r=n()*t,l=0,i=e.length-1;for(;l<i;){let t=l+i>>1;r>e[t]?l=t+1:i=t}return l}function En(e){let t=e.length,n=[],r=[],l=t/zn(e);e=e.map((e=>e*l));for(let l=0;l<t;l++)e[l]<1?n.push(l):r.push(l);let i=Array(t),s=Array(t);for(;n.length>0&&r.length>0;){let t=n.pop(),l=r.pop();i[t]=e[t],s[t]=l,e[l]=e[l]+e[t]-1,e[l]<1?n.push(l):r.push(l)}for(;r.length>0;)i[r.pop()]=1;for(;n.length>0;)i[n.pop()]=1;return{n:t,prob:i,alias:s}}function Nn(e,t,n,r){let l=r()*e|0;return r()<t[l]?l:n[l]}function jn(e){let t=e.length,n=Math.ceil(Math.log2(t)),r=1<<n,l=Array(2*r-1),i=r-1;for(let n=0;n<t;n++)l[i+n]=e[n];for(let e=t;e<r;e++)l[i+e]=0;let s=i;for(;r>1;){let e=s;s-=r>>=1;for(let t=0;t<r;t++)l[s+t]=l[e]+l[e+1],e+=2}return{tree:l,level:n,offset:i}}function Sn(e,t,n,r){let l=r-e[n+=t];for(;n>=0;)e[n]+=l,n=n-1>>1}function qn(e,t,n,r){let l=r()*e[0],i=1;for(;--t;)l>e[i]&&(l-=e[i++]),i=2*i+1;return l>e[i]&&i++,i-n}function On(e,t=null,n=!0,r="auto",l=Array(e),i=Math.random){let s=t.length;if(n||=1==e,n)switch("auto"==r&&(r=1==e||e*s<600?"linear":e>(s>100?2*s:50)?"alias":"binary"),r){case"linear":{let n=zn(t);for(let r=0;r<e;r++)l[r]=Mn(t,n,i);break}case"binary":{let n=An(t),r=n.at(-1);for(let t=0;t<e;t++)l[t]=kn(n,r,i);break}case"alias":{let{n:n,prob:r,alias:s}=En(t);for(let t=0;t<e;t++)l[t]=Nn(n,r,s,i);break}case"sumtree":{let{tree:n,level:r,offset:s}=jn(t);for(let t=0;t<e;t++)l[t]=qn(n,r,s,i);break}default:throw`unexpected method '${r}'`}else{if(e>t)throw"size > p is not allowed when replace = true";switch("auto"==r&&(r=s+e<150?"linear":s+e<200?"binary":"sumtree"),r){case"linear":{let n=zn(t);t=t.slice();for(let r=0;r<e;r++){let e=l[r]=Mn(t,n,i);n-=t[e],t[e]=0}break}case"binary":{let n=An(t),r=n.at(-1);for(let s=0;s<e;s++){let e=l[s]=kn(n,r,i),a=t[s];for(let t=e;t<n.length;t++)n[t]-=a;r-=a}break}case"alias":t=t.slice();for(let n=0;n<e;n++){let{n:e,prob:r,alias:s}=En(t);t[l[n]=Nn(e,r,s,i)]=0}break;case"sumtree":{let{tree:n,level:r,offset:s}=jn(t);for(let t=0;t<e;t++){Sn(n,s,l[t]=qn(n,r,s,i),0)}break}default:throw`unexpected method '${r}'`}}return l}function In(e=null){if(null==e)return Math.random();"number"==typeof e&&(e=[e]);let t=function(e){let t=1;for(let n of e)t*=n;return t}(e),n=Array(t);for(let e=0;e<t;e++)n[e]=Math.random();return A(n).reshape(e)}$n(A([[[0,3],[2,2],[2,2]],[[8,5],[4,1],[6,-2]]]),0);const Fn=In,Tn=In;function Dn(e,t=null,n=null,r=!0){if(null!=n){if(!Q(n))throw"output array must be contiguous";null==t&&(t=n.shape)}let l;if(null==t){if(r)return e();l=[],t=1}else"number"==typeof t?l=[t]:(l=t,t=_(l));if(null==n)n=D(l);else if(!ge(l,n.shape))throw"size must match out.shape when used together";let{data:i,offset:s}=n;for(let n=0;n<t;n++)i[s+n]=e();return n}class Ln{constructor(e=Math.random){this.rand=e}integers(e,t=null,n=null,r=!1){null==t&&(t=e,e=0);let l=t-e;return r&&(l+=1),Dn((()=>this.rand()*l+e|0),n)}random(e=null,t=null){return Dn((()=>this.rand()),e,t)}choice(e,t=null,n=!0,r=null,l=0){if("number"==typeof e){if(e<=0)throw"a must be a positive integer unless no samples are taken";e=C(e)}else if(0==(e=T(e)).size)throw"a cannot be empty unless no samples are taken";if(null==r)r=Array(e.shape[l]).fill(1/e.shape[l]);else{if(1!=(r=T(r)).ndim)throw"p must be 1-dimensional";if(r.size!=e.shape[l])throw"a and p must have same size";r=r.toarray()}let i=Array(l).fill(y());if(null==t)return i[l]=On(1,r,void 0,void 0,void 0,this.rand)[0],e._getview(i).copy();let s=t;if("number"==typeof t&&(s=[t]),t=_(s),r.length<t)throw"Cannot take a larger sample than population when replace is false";if(he(r)<t)throw"Fewer non-zero entries in p than size";let a=[...e.shape];a.splice(l,1,...s);let o=Array(l).fill(y()),u=D(a),f=On(t,r,n,void 0,void 0,this.rand),h=0;for(let t of I(s)){for(let e=0;e<t.length;e++)o[l+e]=t[e];i[l]=f[h++],u.set(o,e._getview(i))}return u}shuffle(e,t=0){t=yr(t,(e=T(e)).ndim);let n=Array(t+1).fill(y(":")),{shape:r}=e,l=r[t],i=D([...r.slice(0,t),...r.slice(t+1)]);for(let r=0;r<l-2;r++){let s=this.rand()*(l-r)+r|0;n[t]=r;let a=e._getview(n);n[t]=s;let o=e._getview(n);i.set(a),a.set(o),o.set(i)}}permuted(e,t=null,n=null){t=yr(t,(e=T(e)).ndim);let r=[...e.shape];r[t]=1,null==n&&(n=L(e));for(let l of I(r)){l[t]=y();let r=e._getview(l).flatten();this.shuffle(r),n.set(l,r)}return n}permutation(e,t=0){return e="number"==typeof e?C(e):A(e),this.shuffle(e,t),e}uniform(e=0,t=1,n=null){return Dn((()=>this.rand()*(t-e)+e),n)}normal(e=0,t=1,n=null){return Dn((()=>{let n=this.rand(),r=this.rand(),l=Math.sqrt(-2*Math.log(n))*Math.cos(2*Math.PI*r);return e+t*l}),n)}}const Pn=new Ln;function Un(e,t=null,n=null,r=!1){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let l=[...e.shape.slice(0,t),...r?[1]:[],...e.shape.slice(t+1)];if(null==n)n=D(l);else if(!ge(l,n.shape))throw"out must have the same shape as the expected output";return ke(Wt(e,t,null,r),Ht(e,t,null,r),n),n}function Vn(e,t=null,n=null,r=!1){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let l=[...e.shape.slice(0,t),...r?[1]:[],...e.shape.slice(t+1)];if(null==n)n=D(l);else if(!ge(l,n.shape))throw"out must have the same shape as the expected output";return ze(zt(e,t,null,r),e.shape[t],n),n}function Bn(e,t=null,n=null,r=0,l=!1){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let i=[...e.shape.slice(0,t),...l?[1]:[],...e.shape.slice(t+1)];if(null==n)n=D(i);else if(!ge(i,n.shape))throw"out must have the same shape as the expected output";return Vn(Qt(ke(e,ze(zt(e,t,null,!0),e.shape[t]-r))),t,n,l),n}function Xn(e,t=null,n=null,r=0,l=!1){return n=Bn(e,t,n,r,l),Jt(n,n),n}function Cn(e,t=[],n="big"){if("big"==n)for(let n=7;n>=0;n--)t[n]=e%2,e=e/2|0;else for(let n=0;n<=7;n++)t[n]=e%2,e=e/2|0;return t}function Gn(e,t,n=0){let r,l,i;if(null!=e.shape?(n=yr(n,e.ndim),r=e.shape[n]):r=e.length,"number"==typeof t){if(l=0|t,l<=0)throw"number sections must be larger than 0.";let e=r/l|0,n=r%l;i=A([0,...Array(n).fill(e+1),...Array(l-n).fill(e)]).cumsum().array()}else l=t.length+1,i=[0,...t,r];let s=[],a=R(e,n,0);for(let e=0;e<l;e++){let t=i[e],r=i[e+1];s.push(R(a.at(y(t,r)),n,0))}return s}function Wn(e,t,n=0){if(n=yr(n,(e=T(e)).ndim),null!=t.shape&&(t=t.array()),null==t.length){let r=t;if(e.shape[n]%r)throw"array split does not result in an equal division"}return Gn(e,t,n)}function Hn(e,t,n=null){e=T(e),null==n?(e=fe(e),n=0):n=yr(n,e.ndim);let r=e.shape.slice(),l="number"==typeof t;if(l)r[n]*=t;else if(1==t.length)t=t[0],r[n]*=t,l=!0;else{if(r[n]!=t.length)throw`operands could not be broadcast together with shape (${r[n]},) (${t.length},)`;r[n]=t.reduce(((e,t)=>e+t))}let i=D(r),s=i.strides.slice();s.splice(n,1);let a=e.shape.slice();a.splice(n,1);let o=e.strides.slice();o.splice(n,1);let u=r[n];for(let r of I(a)){let a=0,f=0;for(let e=0;e<r.length;e++)a+=r[e]*o[e],f+=r[e]*s[e];let h=0;for(let r=0;r<u;r++){let s=e.data[a+r*e.strides[n]],o=l?t:t[r];for(let e=0;e<o;e++,h++)i.data[f+h*i.strides[n]]=s}}return i.astype(e.dtype)}function Jn(e,t=0,n=0,r=1){e=T(e);let{ndim:l}=e;if(l<2)throw"array.ndim must be >= 2";n=yr(n,l),r=yr(r,l);let i=Array(l);i[l-2]=n,i[l-1]=r;for(let e=0,t=0;e<l;e++)e!=n&&e!=r&&(i[t++]=e);let s,a,o=(e=Y(e,i)).shape[l-2],u=e.shape[l-1],f=u+1;t<0?(s=-u*t,a=Math.min(u,o+t)*(u+1)-u*t):(s=t,a=Math.min(o,u-t)*(u+1)+t);let h=Math.ceil((a-s)/f);return e.as_strided([...e.shape.slice(0,-2),h],[...e.strides.slice(0,-2),f*e.strides[l-1]],e.offset+s)}let Kn=e=>"number"==typeof e||e instanceof p?e:y(e);const Qn=Symbol("tupleType");function Rn(...e){let t=e.map(Kn);return t[Qn]=!0,t}function Yn(e,t,n,r="raise"){"number"==typeof t&&(t=[t]),"number"==typeof n&&(n=[n]),t=function(e,t,n,r){if("raise"==t)return function(e,t,n){let r=Array(e.length);for(let l=0;l<e.length;l++){let i=e[l];if(i<0&&(i+=t),i<0||i>=t)throw`index ${e[l]} is out of bounds for axis ${n} with size ${t}`;r[l]=i}return r}(e,n,r);if("wrap"==t)return function(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let l=e[r]%t;l<0&&(l+=t),n[r]=l}return n}(e,n);if("clip"==t)return function(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let l=e[r];n[r]=Math.max(0,Math.min(l,t-1))}return n}(e,n);throw`unexpected mode ${t}`}(t,r,e.size,0);let l=e.flat,i=n.length;for(let e=0;e<t.length;e++)l.set(t[e],n[e%i])}function Zn(e,t,n="left"){e instanceof b&&(e=e.array());let r=L(t=T(t)),l=0,i="left"==n?er:tr;for(let n of t.flat)r.data[l++]=i(e,n);return r}function er(e,t){let n=0,r=e.length-1;for(;n<=r;){let l=n+r>>1;e[l]<t?n=l+1:r=l-1}return n}function tr(e,t){let n=0,r=e.length-1;for(;n<=r;){let l=n+r>>1;e[l]>t?r=l-1:n=l+1}return n}class nr{constructor(e){this.length=e.length,this.elements=e.map((e=>Array.from(e))),this.lengths=this.elements.map((e=>e.length)),this.size=this.lengths.reduce(((e,t)=>e*t)),this.coords=Array(this.length),this.done=this.index=void 0,this.reset()}[Symbol.iterator](){return this.reset()}reset(){return this.coords.fill(0),this.index=0,this.done=0==this.size,this}next(){if(this.done)return{done:!0};let{elements:e,coords:t,length:n,lengths:r}=this,l=e.map(((e,n)=>e[t[n]])),i=n-1,s=!0;e:for(;i>=0;)switch(r[i]){case 1:i--;break;case t[i]:t[i--]=0,s=!0;break;default:if(!s)break e;t[i]+=1,s=!1}return this.index++,this.done=this.index>=this.size,{value:l,done:!1}}}function rr(e){let t=Object.create(null);return(...n)=>t[n]??(t[n]=e(...n))}function lr(e,t,n=null){return Object.defineProperty(or.bind(n,t),"name",{value:e})}function ir(e,t,n=null){return Object.defineProperty(ur.bind(n,t),"name",{value:e})}function sr(e,t,n=void 0){return Object.defineProperty(fr.bind({defaultinitial:n},t),"name",{value:e})}function ar(e,t,n=null){return Object.defineProperty(hr.bind(n,t),"name",{value:e})}function or(e,t,n=null,r=this?.dtype){return t=T(t),null==n?n=D(t.shape,r):t=S(t,n.shape),pr(n.ndim)(e,t,n),n}function ur(e,t,n,r=null,l=this?.dtype){let i;return t=T(t),n=T(n),null==r?(i=X(t.shape,n.shape),r=D(i,l)):i=r.shape,t=S(t,i),n=S(n,i),dr(r.ndim)(e,t,n,r),r}function fr(e,t,n=null,r=null,l=!1,i=this?.defaultinitial,s=!0,a=this?.dtype){let o=gr(n,(t=T(t)).ndim),u=[],f=[];for(let e=0;e<o.length;e++)o[e]?f.push(1):(u.push(t.shape[e]),f.push(t.shape[e]));if(null==r)r=D(u,a);else if(!ge(u,r.shape))throw new Error("unmatch shape");let h=r.reshape(f);return l&&(r=h),cr(t.ndim,o)(e,t,h,i),s&&0==r.ndim?r.item():r}function hr(e,t,n=null,r=null,l=this?.dtype){t=T(t),null==n&&(t=fe(t));let i=gr(n,t.ndim);if(null==r)r=D(t.shape,l);else if(!ge(t.shape,r.shape))throw new Error("unmatch shape");return mr(t.ndim,i)(e,t,r),r}function pr(e){if(0==e)return new Function("fn","x","out","\nout.data[out.offset] = fn(x.data[x.offset]);\n");let t=(t,n=", ")=>[...Array(e).keys()].map((e=>t.replaceAll("$",e))).join(n);return new Function("fn","x","out",`\nlet { data, strides, offset, shape } = out;\nlet [${t("d_$")}] = shape;\nlet [${t("s_$")}] = strides;\nlet { data: x_data, strides: x_strides, offset: x_offset } = x;\nlet [${t("x_$")}] = x_strides;\n${t("for (let i_$ = 0; i_$ < d_$; i_$++)"," ")} {\n\tdata[offset + ${t("i_$ * s_$"," + ")}] = fn(x_data[x_offset + ${t("i_$ * x_$"," + ")}]);\n}\n`)}function dr(e){if(0==e)return new Function("fn","x1","x2","out","\nout.data[out.offset] = fn(x1.data[x1.offset], x2.data[x2.offset]);\n");let t=(t,n=", ")=>[...Array(e).keys()].map((e=>t.replaceAll("$",e))).join(n);return new Function("fn","x1","x2","out",`\nlet { data, strides, offset, shape } = out;\nlet [${t("d_$")}] = shape;\nlet [${t("s_$")}] = strides;\nlet { data: x1_data, strides: x1_strides, offset: x1_offset } = x1;\nlet { data: x2_data, strides: x2_strides, offset: x2_offset } = x2;\nlet [${t("x1_$")}] = x1_strides;\nlet [${t("x2_$")}] = x2_strides;\n${t("for (let i_$ = 0; i_$ < d_$; i_$++)"," ")} {\n\tdata[offset + ${t("i_$ * s_$"," + ")}] = fn(\n\t\tx1_data[x1_offset + ${t("i_$ * x1_$"," + ")}],\n\t\tx2_data[x2_offset + ${t("i_$ * x2_$"," + ")}]\n\t);\n}\n`)}function cr(e,t){if(0==e)return new Function("fn","x","out","initial","\nout.data[out.offset] = initial != undefined ? fn(initial, x.data[x.offset]) : x.data[x.offset];\n");let n=(t,n=", ",r=[...Array(e).keys()])=>r.map((e=>t.replaceAll("$",e))).join(n),r=[...Array(e).keys()].filter((e=>!t[e])),l=[...Array(e).keys()].filter((e=>t[e]));return new Function("fn","x","out","initial",`\nlet { data, strides, offset } = out;\nlet [${n("s_$")}] = strides;\nlet { data: x_data, strides: x_strides, offset: x_offset, shape } = x;\nlet [${n("d_$")}] = shape;\nlet [${n("x_$")}] = x_strides;\n\nlet use_initial = initial != undefined;\n${n("for (let i_$ = 0; i_$ < d_$; i_$++)"," ",r)} {\n\tlet startOffset = x_offset${r.length?" + ":""}${n("i_$ * x_$"," + ",r)};\n\tlet first = !use_initial;\n\tlet accum = initial;\n\t${n("for (let i_$ = 0; i_$ < d_$; i_$++)"," ",l)} {\n\t\tif (first) {\n\t\t\tfirst = false;\n\t\t\taccum = x_data[startOffset];\n\t\t} else {\n\t\t\taccum = fn(accum, x_data[startOffset + ${n("i_$ * x_$"," + ",l)}]);\n\t\t}\n\t}\n\tdata[offset${r.length?" + ":""}${n("i_$ * s_$"," + ",r)}] = accum;\n}\n`)}function mr(e,t){if(0==e)return new Function("fn","x","out","initial","\nout.data[out.offset] = initial != undefined ? fn(initial, x.data[x.offset]) : x.data[x.offset];\n");let n=(t,n=", ",r=[...Array(e).keys()])=>r.map((e=>t.replaceAll("$",e))).join(n),r=[...Array(e).keys()].filter((e=>!t[e])),l=[...Array(e).keys()].filter((e=>t[e]));return new Function("fn","x","out","initial",`\nlet { data, strides, offset } = out;\nlet [${n("s_$")}] = strides;\nlet { data: x_data, strides: x_strides, offset: x_offset, shape } = x;\nlet [${n("d_$")}] = shape;\nlet [${n("x_$")}] = x_strides;\n\n${n("for (let i_$ = 0; i_$ < d_$; i_$++)"," ",r)} {\n\tlet first = true;\n\tlet accum = x_data[x_offset${r.length?" + ":""}${n("i_$ * x_$"," + ",r)}];\n\t${n("for (let i_$ = 0; i_$ < d_$; i_$++)"," ",l)} {\n\t\tif (first) {\n\t\t\tfirst = false;\n\t\t} else {\n\t\t\taccum = fn(accum, x_data[x_offset + ${n("i_$ * x_$"," + ")}]);\n\t\t}\n\t\tdata[offset + ${n("i_$ * s_$"," + ")}] = accum;\n\t}\n}\n`)}function gr(e,t,n=!1){if(null==e)return Array(t).fill(!0);"object"!=typeof e&&(e=[+e]);let r=Array(t).fill(!1);for(let l of e){if(l=yr(l,t),!n&&r[l])throw new Error("repeated axis");r[l]=!0}return r}function yr(e,t){let n=e;if(e=+e,!Number.isInteger(e))throw new Error(`${n} cannot be cast to integer`);if(e<0&&(e+=t),e<0||t<=e)throw new Error(`axis ${n} is out of bounds for array of dimension ${t}`);return e}function wr(e,t,n=null){e=T(e),t=T(t),br(e.ndim>0,"x1 does not have enough dimensions"),br(t.ndim>0,"x2 does not have enough dimensions");let r=1==e.ndim,l=1==t.ndim,i=r||l;if(r&&(e=e.at(null,y(":"))),l&&(t=t.at(y(":"),null)),2==e.ndim&&2==t.ndim){br(e.shape[1]==t.shape[0],"input shape mismatch");let s=[e.shape[0],t.shape[1]],a=i?s.slice(r?1:0,l?-1:void 0):s;null==n?n=D(a):br(ge(a,n.shape),"out shape mismatch");let o=i?n.reshape(s):n,u=t.T;for(let[t,n]of I(s))o.set([t,n],xr(e.at(t),u.at(n)));return n}let s=X(e.shape.slice(0,-2),t.shape.slice(0,-2));e=S(e,[...s,...e.shape.slice(-2)]),t=S(t,[...s,...t.shape.slice(-2)]),br(e.shape.at(-1)==t.shape.at(-2),"input shape mismatch");let a=e.shape.at(-2),o=t.shape.at(-1),u=[...s,a,o];null==n?n=D(u):br(ge(u,n.shape),"out shape mismatch");for(let r of I(s))wr(e.get(r),t.get(r),n.get(r));return n}function br(e,t){if(!e)throw new Error(t)}function xr(e,t,n=null){if(e=T(e),t=T(t),1==e.ndim&&1==t.ndim)return zt(Ae(e,t),0,n);if(2==e.ndim&&2==t.ndim)return wr(e,t,n);if(0==e.ndim||0==t.ndim)return Ae(e,t,n);if(1==t.ndim){br(e.shape.at(-1)==t.shape[0],`shapes ${e.shape} and ${t.shape} not aligned`);let r=e.shape.slice(0,-1);null==n?n=D(r):br(ge(r,n.shape),"out shape mismatch");for(let l of I(r))xr(e.get(l),t,n.at(y("..."),...l));return n}}function _r(e,t=null){t=null!=t?Object.assign(Object.create(Ar),t):Ar;let{separator:n,prefix:r}=t;return 0==e.size?"[]":function(e,t=Ar,n=" ",r=""){let l,i=T(e);0==e.ndim&&(e=i);e.size>t.threshold?(l="...",i=zr(i,t.edgeitems)):l="";let s=function(e,t){let n=function(e,t){let n={int:()=>new kr(e).__call__,float:()=>new jr(e,t.precision).__call__,object:()=>Sr},{formatter:r}=t;if(null!=r)for(let e of Object.keys(r))n[e]=qr(r[e]);return n}(e,t),r=e.flat.copy().data,l=M(r),i=h(l)==h("number")?function(e){for(let t of e)if(!Number.isInteger(t))return!1;return!0}(r)?"int":"float":"object";return n[i](t)}(i,t),a=" "+" ".repeat(r.length),o=function(e,t,n,r,l,i,s,a){function o(n,r,u){let f=n.length,h=e.ndim-f;if(0===h)return t(e.item(n));let p,d=r+" ";p=a<=113?u:u-1;let c,m,g=e.shape[f],y=s&&2*i<g;y?(c=i,m=i):(c=0,m=g);let w="";if(1===h){let e,t=l.trimEnd().length;e=a<=113?u-t:u-Math.max(t,1);let i=r;for(let t=0;t<c;t++){let s=o([...n,t],d,p);[w,i]=Ir(w,i,s,e,r,a),i+=l}y&&([w,i]=Or(w,i,s,e,r,a),i+=a<=113?", ":l);for(let t=m;t>1;t--){let s=o([...n,-t],d,p);[w,i]=Ir(w,i,s,e,r,a),i+=l}a<=113&&(e=u);let f=o([...n,-1],d,p);[w,i]=Ir(w,i,f,e,r,a),w+=i}else{w="";let e=l.trimEnd()+"\n".repeat(h-1);for(let t=0;t<c;t++){w+=r+o([...n,t],d,p)+e}y&&(w+=r+s,w+=a<=113?", \n":e);let t=m;for(;t>1;t--){w+=r+o([...n,-t],d,p)+e}w+=r+o([...n,-t],d,p)}return w="["+w.slice(r.length)+"]",w}try{return o([],r,n)}finally{o=null}}(e,s,t.linewidth,a,n,t.edgeitems,l,t.legacy);return o}(e,t,n,r)}function $r(e,t=null,n=null){return t??=Ar.linewidth,n??=Ar.precision,0==e.ndim?`${e.item()}`:_r(e,{linewidth:t,precision:n})}function vr(e,t=null,n=null){if(t??=Ar.linewidth,n??=Ar.precision,0==e.ndim)return`${e.item()}`;let r,l=e instanceof b?"array":typeof e,i=function(e){return["number","boolean"].includes(e.name)}(e.dtype)&&e.size>0,s=l+"(",a=i?")":",";r=e.size>0||ge(e.shape,[0])?_r(e,{linewidth:t,precision:n,separator:", ",prefix:s}):`[], shape=[${e.shape.join(", ")}]`;let o=s+r+a;if(i)return o;let u=`dtype=${e.dtype.name})`,f=" ";return o.length-(o.lastIndexOf("\n")+1)+u.length+1>t&&(f="\n"+" ".repeat((l+"(").length)),o+f+u}pr=rr(pr),dr=rr(dr),cr=rr(cr),mr=rr(mr),l.onload((()=>{D(100).reshape(10,10)}));let Ar={edgeitems:3,threshold:1e3,linewidth:75,precision:void 0,formatter:null,separator:" ",prefix:""};function zr(e,t,n=[]){let r=n.length;if(r==e.ndim)return e.get(n);if(e.shape[r]>2*t){let l=n.concat(Rn([,t])),i=n.concat(Rn([-t]));return we([zr(e,t,l),zr(e,t,i)],r)}return zr(e,t,n.concat(Rn(":")))}class Mr{get __call__(){return this.call.bind(null,this)}}class kr extends Mr{constructor(e){super(),this.padLeft=e.size>0?Math.max(String(e.max()).length,String(e.min()).length):0}call({padLeft:e}=this,t){let n=String(t);return" ".repeat(e-n.length)+n}}function Er(e,t){return e.toExponential(t)}function Nr(e,t){return null!=t?e.toFixed(t):String(e)}class jr extends Mr{constructor(e,t=void 0){super(),this.precision=t;let n=!1;{let t=e.item(0),r=t,l=!1;for(let n of e.flat)Number.isFinite(n)&&0!=n&&(n=Math.abs(n),t=Math.min(t,n),r=Math.max(r,n),l=!0);l&&(r>=1e8||t<1e-4||r/t>1e3)&&(n=!0)}this.exp_format=n;let r=0;if(this.exp_format)for(let n of e.flat)r=Math.max(r,Er(n,t).length);else for(let n of e.flat)r=Math.max(r,Nr(n,t).length);this.padLeft=r}call({padLeft:e,exp_format:t,precision:n}=this,r){let l=t?Er(r,n):Nr(r,n);return" ".repeat(e-l.length)+l}}function Sr(e){return"string"==typeof e?`'${e}'`:`${e}`}let qr=e=>()=>e;function Or(e,t,n,r,l,i){let s=t.length+n.length>r;return i>113&&t.length<=l.length&&(s=!1),s&&(e+=t.trimEnd()+"\n",t=l),[e,t+=n]}function Ir(e,t,n,r,l,i){let s=n.split(/\r?\n/);if(1===s.length||i<=113)return Or(e,t,n,r,l,i);let a,o=Math.max(...s.map((e=>e.length)));t.length+o>r&&t.length>l.length?(e+=t.trimEnd()+"\n",t=l+s[0],a=l):(a=" ".repeat(t.length),t+=s[0]);for(let n=1;n<s.length;n++)e+=t.trimEnd()+"\n",t=a+s[n];let u=o-s.at(-1).length;return[e,t+=" ".repeat(u)]}class Fr{constructor(e,t,n){this.ndim=e.length,this.size=_(e),this.shape=e,this.strides=t;let r=Array(this.ndim);for(let n=0;n<this.ndim;n++)r[n]=e[n]*t[n];this.dim_strides=r,this.initial=n,this.offset,this.coords=Array(this.ndim),this.index,this.done,this[Symbol.iterator]()}[Symbol.iterator](){return this.index=0,this.done=0==this.size,this.coords.fill(0),this.offset=this.initial,this}next(){if(this.done)return{done:!0};let{offset:e,coords:t,size:n,index:r}=this;if(0!=r){let{shape:n,strides:r,ndim:l,dim_strides:i}=this,s=l-1,a=!0;for(;s>=0;){let l=n[s];if(1==l)s--;else if(l==t[s])e-=i[s],t[s--]=0,a=!0;else{if(!a)break;e+=r[s],t[s]++,a=!1}}this.offset=e}return this.done=++this.index>=n,{value:e,done:!1}}}function Tr(e,t,n=0){return new Fr(e,t,n)}class Dr extends Fr{constructor(e){let{shape:t,strides:n,offset:r}=e;super(t,n,r),this.base=e}next(){return this.done?{done:!0}:{value:this.base.data[super.next().value],done:!1}}at(e){return this.get(e)}get(e){let t,n,{base:r}=this;if("number"==typeof e)return A(r.item(e),r.dtype);"string"==typeof e&&(e=y(e)),e instanceof p?(t=e.indices(r.size),n=D([t.slicelength],r.dtype)):(t=T(e).flat,n=L(e));let l=0;for(let e of t)n.data[l++]=r.item(e);return n}set(e,t){let{base:n}=this;if("number"==typeof e)return n.itemset(e,t),this;"string"==typeof e&&(e=y(e)),t=t instanceof Dr?[...t]:T(t).flatten().data;let r=e instanceof p?e.indices(n.size):T(e).flat,l=0;for(let e of r)n.itemset(e,t[l++%t.length]);return this}copy(){return this.base.flatten()}}function Lr(e){return e=T(e),new Pr(e)}class Pr extends Dr{constructor(e){super(e)}next(){if(this.done)return{done:!0};let e=super.next().value;return{value:[this.coords,e],done:!1}}}const Ur=ar("cumprod",((e,t)=>e*t)),Vr=ar("cumsum",((e,t)=>e+t));let Br=e=>Number.isNaN(e)?1:e;const Xr=ar("nancumprod",((e,t)=>Br(e)*Br(t)));let Cr=e=>Number.isNaN(e)?0:e;const Gr=ar("nancumsum",((e,t)=>Cr(e)+Cr(t)));function Wr(e,t,n=1e-5,r=1e-8,l=!1){e=T(e),t=T(t);let i=We(e),s=We(t);if(Ce(i)&&Ce(s))return Hr(e,t,r,n);[e,t]=q(e,t);let a=Te(i,s),o=Ve(a),u=J(a);if(u.set([a],Hr(e.at(a),t.at(a),r,n)),u.set([o],un(e.at(o),t.at(o))),l){let n=Te(Je(e),Je(t));u.set([n],n.at(n))}return u}function Hr(e,t,n,r){return pn(Rt(ke(e,t)),xe(n,Ae(r,Rt(t))))}function Jr(e){let[t,n]=[e.length,e[0].length],[r,l]=Kr(e.flat(),t,n);return r=U(r,[t,n]).array(),[r,l]}function Kr(e,t,n){let r=e.slice(),l=Array(n);for(let e=0;e<n;e++){let i=-1,s=-1;for(let l=e;l<t;l++){let t=Math.abs(r[l*n+e]);t>i&&(s=l,i=t)}if(-1!=s){if(l[e]=s,s!=e)for(let t=0;t<n;t++){let l=e*n+t,i=s*n+t,a=r[l];r[l]=r[i],r[i]=a}for(let l=e+1;l<t;l++){let t=r[l*n+e]/=r[e*n+e];for(let i=e+1;i<n;i++)r[l*n+i]-=t*r[e*n+i]}}else l[e]=e}return[r,l]}function Qr(e,t){let[n,r]=e,l=n.length,i=t.slice();for(let e=0;e<l;e++)r[e]!==e&&([i[e],i[r[e]]]=[i[r[e]],i[e]]);for(let e=0;e<l;e++)for(let t=0;t<e;t++)i[e]-=n[e][t]*i[t];for(let e=l-1;e>=0;e--){for(let t=e+1;t<l;t++)i[e]-=n[e][t]*i[t];i[e]/=n[e][e]}return i}function Rr(e,t,n=0){e=T(e);let r=[],l=[],i=[];for(let e of t)if(null==e)i.push(null),r.push(!1);else if("string"==typeof e)i.push(y(e)),r.push(!1);else if(e instanceof p)i.push(e),r.push(!1);else if(e=T(e),e.dtype==f("boolean"))for(let t of e.nonzero())l.push(t.shape),i.push(t),r.push(!0);else l.push(e.shape),i.push(e),r.push(!0);let s=r.length,a=X(...l);for(let e=0;e<s;e++)r[e]&&(i[e]=S(i[e],a));let o=!0,u=-1;for(let e=0;e<s;e++)if(r[e]){if(-1===u)u=e;else if(e!==u+1){o=!1;break}u=e}let h=[];if(o)for(let t=0;t<s;)if(r[t])n+=t,h.push(...a),t=u+1;else{let n=i[t].indices(e.shape[t]).slicelength;h.push(n),t++}else{h.push(...a);for(let t=0;t<s;t++)if(!r[t])if(null==i[t])h.push(1);else{let n=i[t].indices(e.shape[t]).slicelength;h.push(n)}}for(let t=s;t<e.ndim;t++){let n=e.shape[t];h.push(n)}return new Yr(e,a,i,n,h)}class Yr extends F{constructor(e,t,n,r,l){super(t),this.base=T(e),this.indices=n,this.axis=r,this.outShape=l,this._indices=[...n]}next(){if(this.done)return{done:!0};let{base:e,indices:t,index:n,_indices:r}=this;for(let e=0;e<t.length;e++)t[e]instanceof b&&(r[e]=t[e].item(n));let l=e.get(r);return super.next(),{value:l,done:!1}}get(){let{axis:e,coords:t,outShape:n,base:r}=this,l=D(n,r.dtype);for(let n of this)O(l.get(t,e),n);return l}set(e){let{axis:t,coords:n,outShape:r}=this;e=S(e,r);for(let r of this)O(r,e.get(n,t))}}function Zr(e,t=null,n=null,r=!1){if(0==(e=T(e)).size)throw new Error("attempt to get argmax of an empty sequence");if(null==t){let t,l=Number.MIN_VALUE,i=0;for(let n of e.flat)n>l&&(t=i,l=n),i++;let s=r?Array(e.ndim).fill(1):[];if(null==n)n=D(s,"number");else if(!ge(n.shape,s))throw new Error("out shape does not match");return n.itemset(0,t),n}if(t=yr(t,e.ndim),0==e.ndim)return 0;if(1==e.ndim)return Zr(e,null,n,r);let l=[...e.shape];if(r?l.splice(t,1,1):l.splice(t,1),null==n)n=D(l,"number");else if(!ge(n.shape,l))throw new Error("out shape does not match");let i=n,s=[...e.shape];s.splice(t,1),n=n.reshape(s);for(let r of I(s)){let l=[...r];l.splice(t,0,":"),Zr(e.get(l),null,n.get(r))}return n=i}function el(e,t=null,n=null,r=!1){if(0==(e=T(e)).size)throw new Error("attempt to get argmax of an empty sequence");if(null==t){let t,l=Number.MAX_VALUE,i=0;for(let n of e.flat)n<l&&(t=i,l=n),i++;let s=r?Array(e.ndim).fill(1):[];if(null==n)n=D(s,"number");else if(!ge(n.shape,s))throw new Error("out shape does not match");return n.itemset(0,t),n}if(t=yr(t,e.ndim),0==e.ndim)return 0;if(1==e.ndim)return el(e,null,n,r);let l=[...e.shape];if(r?l.splice(t,1,1):l.splice(t,1),null==n)n=D(l,"number");else if(!ge(n.shape,l))throw new Error("out shape does not match");let i=n,s=[...e.shape];s.splice(t,1),n=n.reshape(s);for(let r of I(s)){let l=[...r];l.splice(t,0,":"),el(e.get(l),null,n.get(r))}return n=i}e.Broadcast=re,e.Dtype=o,e.Flatiter=Dr,e.Generator=Ln,e.NDArray=b,e.NINF=-(1/0),e.NdenumerateIterator=Pr,e.NdindexIterator=F,e.Nditer=ce,e.NdoffsetIterator=Fr,e.Product=nr,e.Slice=p,e._ndim=se,e._shape=N,e.abs=Rt,e.absolute=Yt,e.accumulate_=hr,e.add=xe,e.all=Ce,e.allclose=function(e,t,n=1e-5,r=1e-8,l=!1){return Ce(Wr(e,t,n,r,l))},e.amax=Wt,e.amin=Ht,e.and=De,e.any=Ge,e.arange=C,e.arccos=lt,e.arccosh=gt,e.arcsin=rt,e.arcsinh=mt,e.arctan=it,e.arctan2=at,e.arctanh=yt,e.argmax=Zr,e.argmin=el,e.argsort=$n,e.argwhere=function e(t){return 0==ie(t)?e(t=Z(t)).at(y(),y(null,0)):Y(oe(t))},e.around=wt,e.array=A,e.array2string=_r,e.array_equal=me,e.array_equiv=function(e,t){return e=T(e),t=T(t),!!function(...e){let t=0;for(let n of e)t=Math.max(t,n.length);for(let n=0;n<t;n++){let t=-1;for(let r of e){let e=r.length-n-1;if(!(e<0))if(-1==t)t=r[e];else if(1!=t&&t!=r[e])return!1}}return!0}(e.shape,t.shape)&&Ce(un(e,t))},e.array_repr=vr,e.array_split=Gn,e.array_str=$r,e.asarray=T,e.ascontiguousarray=K,e.assert=br,e.atleast_1d=Z,e.atleast_2d=ee,e.atleast_3d=te,e.average=function(e,t=null,n=null,r=!1,l=!1){let i;if(e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim),null!=n&&(n=T(n)),null!=n){if(i=zt(n),0==i)throw"sum(weights) must not be 0";if(1==n.ndim)n=n.reshape([...Array(t).fill(1),e.shape[t]]);else if(!ge(n.shape,e.shape))throw"weights.shape and a.shape do not match";e=Ae(e,n)}else i=e.shape[t];let s=ze(zt(e,t,null,l),i);return r?[s,i]:s},e.bincount=function(e,t=null,n=0){if(1!=(e=T(e)).ndim)throw"a.dim != 1";if(Ht(e)<0)throw"amin(a) < 0";if(n<0)throw"minlength < 0";if(null!=t){if(!ge((t=T(t)).shape,e.shape))throw"weights.shape != a.shape";t=t.toarray()}let r=Array(Math.max(Wt(e)+1,n)).fill(0),l=0;for(let n of e.flat)r[n]+=null!=t?t[l]:1,l++;return A(r)},e.bitwise_and=tn,e.bitwise_not=ln,e.bitwise_or=nn,e.bitwise_xor=rn,e.broadcast=ne,e.broadcast_arrays=q,e.broadcast_shapes=X,e.broadcast_to=S,e.cbrt=Kt,e.ceil=$t,e.choice=function(e,t=null,n=!0,r=null){if(1!=(e="number"==typeof e?C(e):T(e)).ndim)throw"'p' must be 1-dimensional";if(0==e.size)throw"'a' cannot be empty unless no samples are taken";if(null==r)r=Array(e.size).fill(1/e.size);else{if(1!=(r=T(r)).ndim)throw"'p' must be 1-dimensional";if(r.size!=e.size)throw"'a' and 'p' must have same size";r=r.toarray()}if(e=e.toarray(),null==t)return e[On(1,r)[0]];"number"==typeof t&&(t=[t]);let l=function(e){let t=1;for(let n of e)t*=n;return t}(t);if(he(r)<l)throw"Fewer non-zero entries in p than size";return A(On(l,r,n).map((t=>e[t]))).reshape(t)},e.clip=_n,e.column_stack=function(e){let t=[];for(let n of e)n=T(n),n.ndim<2&&(n=A(n,null,!1,2).T),t.push(n);return we(t,1)},e.compile=function(e,t={}){console.log(e.toString())},e.compress=ue,e.concatenate=we,e.contiguous=Q,e.convolve=function(e,t,n="full"){if(e=Z(e),t=Z(t),0==e.size)throw"a cannot be empty";if(0==t.size)throw"v cannot be empty";if(e.ndim>1||t.ndim>1)throw"object too deep for desired array";if(t.ndim>e.ndim){let n=e;e=t,t=n}let r=e.size;if("valid"==n)r+=1-t.size;else if("full"==n)r+=t.size-1;else if("same"!=n)throw`mode must be one of 'valid', 'same', or 'full' (got '${n}')`;let l=Array(r),i=0;if("valid"!=n)for(let n=0;n<t.size-1;n++){let r=0;for(let l=n+1,i=0;l--;i++)r+=e.item(i)*t.item(l);l[i++]=r}for(let n=0;n<e.size+1-t.size;n++){let r=0;for(let l=0,i=t.size-1;l<t.size;l++,i--)r+=e.item(n+l)*t.item(i);l[i++]=r}if("valid"!=n)for(let n=0;n<t.size-1;n++){let r=0;for(let l=0;l<t.size-1-n;l++)r+=e.item(e.size-t.size+1+n+l)*t.item(t.size-1-l);l[i++]=r}return"same"==n&&(l=l.slice((t.size-1)/2|0,((t.size-1)/2|0)+r)),A(l)},e.copy=function(e){return A(e)},e.copysign=Pt,e.copyto=O,e.cos=tt,e.cosh=dt,e.count_nonzero=he,e.cross=function(e,t,n=-1,r=n,l=n,i=n){e=T(e),t=T(t),r=yr(r,e.ndim),l=yr(l,t.ndim),e=be(e,r,-1),t=be(t,l,-1);let s=e.shape.at(-1),a=t.shape.at(-1);if(2!=s&&3!=s||2!=a&&3!=a)throw"incompatible dimensions for cross product (dimension must be 2 or 3)";let o=X(e.shape.slice(0,-1),t.shape.slice(0,-1));3!=e.shape.at(-1)&&3!=t.shape.at(-1)||(o=[...o,3],i=yr(i,o.length));let u,f,h,p,d,c,m,g,y,w=D(o);if(u=e.at("...",0),f=e.at("...",1),3==e.shape.at(-1)&&(h=e.at("...",2)),p=t.at("...",0),d=t.at("...",1),3==t.shape.at(-1)&&(c=t.at("...",2)),0!=w.ndim&&3==w.shape.at(-1)&&(m=w.at("...",0),g=w.at("...",1),y=w.at("...",2)),2==e.shape.at(-1)){if(2==t.shape.at(-1))return Ae(u,d,w),ke(w,Ae(f,p),w),w;if(3!=t.shape.at(-1))throw"b.shape.at(-1) != 3";Ae(f,c,m),Ae(u,c,g),ve(g,g),Ae(u,d,y),ke(y,Ae(f,p),y)}else{if(3!=e.shape.at(-1))throw"a.shape.at(-1) != 3";if(3==t.shape.at(-1)){Ae(f,c,m);let e=Ae(h,d);ke(m,e,m),Ae(h,p,g),Ae(u,c,e),ke(g,e,g),Ae(u,d,y),Ae(f,p,e),ke(y,e,y)}else{if(2!=t.shape.at(-1))throw"b.shape.at(-1) != 2";Ae(h,d,m),ve(m,m),Ae(h,p,g),Ae(u,d,y),ke(y,Ae(f,p),y)}}return be(w,-1,i)},e.cumprod=Ur,e.cumsum=Vr,e.deg2rad=ht,e.degrees=ot,e.diag=function(e,t=0){let n=(e=T(e)).shape;if(1==n.length){let r=n[0]+Math.abs(t),l=H([r,r]),i=t>=0?t:-t*r,s=l.at(y(null,r-t));for(let t=0;t<e.size;t++,i+=r+1)s.itemset(i,e.item(t));return l}if(2!=n.length)throw"Input must be 1- or 2-d.";return Jn(e,t)},e.diagonal=Jn,e.diff=Et,e.divide=ze,e.divmod=function(e,t,n=[null,null]){return[Ne(e,t,n[0]),qe(e,t,n[1])]},e.dot=xr,e.dsplit=function(e,t){if(ie(e)<3)throw"dsplit only works on arrays of 3 or more dimensions";return Wn(e,t,2)},e.dstack=function(e){return e=te(...e),Array.isArray(e)||(e=[e]),we(e,2)},e.dtype=f,e.dtype_=h,e.e=Re,e.ediff1d=function(e,t=null,n=null){if(e=Et(U(e,-1)),null!=n||null!=t){let r=[];null!=n&&r.push(n),r.push(e),null!=t&&r.push(t),e=we(r,null)}return e},e.empty=D,e.empty_like=L,e.eq=mn,e.equal=un,e.exp=Nt,e.exp2=St,e.expand_dims=function(e,t){"number"==typeof t&&(t=[t]);let n=(e=T(e)).ndim+t.length;t=de(t,n,!1);let r=[];for(let l=0,i=0;l<n;l++)r.push(t.includes(l)?1:e.shape[i++]);return e.reshape(r)},e.expm1=jt,e.extract=function(e,t){return ue(fe(e),fe(t))},e.eye=le,e.fix=xt,e.flatnonzero=function(e){return oe(fe(e))[0]},e.flip=function(e,t=null){let n;if(e=T(e),null==t)n=Array(e.ndim).fill(y("::-1"));else{t=de(t,e.ndim),n=Array(e.ndim).fill(y(":"));for(let e of t)n[e]=y("::-1")}return e.get(n)},e.fliplr=function(e){if((e=T(e)).ndim<2)throw"Input must be >= 2-d.";return e.get(Rn(":","::-1"))},e.flipud=function(e){if((e=T(e)).ndim<1)throw"Input must be >= 1-d.";return e.at(y("::-1"))},e.float_power=je,e.floor=_t,e.floor_divide=Ne,e.fmod=Se,e.fromfunction=function(e,t,n=void 0){let r=[];for(let n of I(t))r.push(e(n));return A(r,n??M(r)).reshape(t)},e.fromiter=function(e,t=-1,n=void 0){let r;if(-1==t)r=[...e];else{r=[];let n=0;if(n<t)for(let l of e)if(r.push(l),n++,n>=t)break}return A(r,n??M(r))},e.full=V,e.full_like=B,e.gcd=Xt,e.get=function(e,t){return Rr(e,t).get()},e.get_size=_,e.get_strides=x,e.gradient=function(e,t,n=null,r=1){throw new Error},e.greater=dn,e.greater_equal=cn,e.gt=bn,e.gte=xn,e.guessType=M,e.hsplit=function(e,t){if(0==ie(e))throw"hsplit only works on arrays of 1 or more dimensions";return Wn(e,t,ie(e)>1?1:0)},e.hstack=function(e){return e=Z(...e),Array.isArray(e)||(e=[e]),e.length>0&&1==e[0].ndim?we(e,0):we(e,1)},e.hypot=st,e.identity=function(e,t="number"){return le(e,e,0,t)},e.in1d=function(e,t,n=!1,r=!1,l="table"){throw new Error},e.index_exp=Rn,e.indices=function(e,t=!1){let n,r=e.length,l=Array(r).fill(1);n=t?[]:D([r,...e]);for(let r=0;r<e.length;r++){let i=e[r],s=C(i).reshape([...l.slice(0,r),i,...l.slice(r+1)]);t?n.push(s):n.set([r],s)}return n},e.inf=Ze,e.interp=function(e,t,n,r=null,l=null,i=null){if([e,t,n]=[e,t,n].map((e=>T(e))),1!=t.ndim||1!=n.ndim)throw"Data points must be 1-D sequences";if(t.shape[0]!=n.shape[0])throw"fp and xp are not of the same length";if(null!=i){e=qe(e,i);let r=$n(t=qe(t,i));t=t.at(r),n=n.at(r),t=we([ke(t.at(y(-1)),i),t,xe(t.at(y(0,1)),i)]),n=we([n.at(y(-1)),n,n.at(y(0,1))])}r??=n.item(0),l??=n.item(-1);let s=Array(e.size),a=0,o=t.item(0),u=t.item(-1);for(let i of e.flat){let e;if(i<o)e=r;else if(i>u)e=l;else{let r=1;for(;r<t.length&&i>t.item(r);r++);let l=t.item(r-1);if(i==l)e=n.item(r-1);else{let s=t.item(r);if(i==s)e=n.item(r);else{let t=n.item(r-1);e=(i-l)*(n.item(r)-t)/(s-l)+t}}}s[a++]=e}return A(s).reshape(e.shape)},e.invert=sn,e.isclose=Wr,e.isfinite=We,e.isinf=He,e.isnan=Je,e.isneginf=Ke,e.isposinf=Qe,e.isscalar=w,e.ix_=function(...e){let t=[],n=e.length;for(let r=0;r<n;r++){let l=e[r];l=T(l),l.ndim,"boolean"==typeof l.item(0)&&([l]=oe(l)),l=l.reshape([...Array(r).fill(1),l.size,...Array(n-r-1).fill(1)]),t.push(l)}return t},e.lcm=Bt,e.ldexp=Ut,e.left_shift=an,e.less=hn,e.less_equal=pn,e.linspace=function(e,t,n=50,r=!0,l=!1){let i=(t-e)/(r?n-1:n),s=[];for(let t=0;t<n;t++)s[t]=e+t*i;let a=A(s);return l?[a,i]:a},e.log=qt,e.log10=Ot,e.log1p=Ft,e.log2=It,e.logaddexp=Tt,e.logaddexp2=Dt,e.logical_and=Te,e.logical_not=Ue,e.logical_or=Le,e.logical_xor=Be,e.lt=yn,e.lte=wn,e.lu=function(e){let t=e.length,n=Array(t).fill().map((()=>Array(t).fill(0)));for(let e=0;e<t;e++)n[e][e]=1;for(let r=0;r<t;r++){let l=0,i=-1;for(let n=r;n<t;n++){let t=Math.abs(e[n][r]);t>l&&(i=n,l=t)}if(i!=r){for(let e=0;e<t;e++)[n[e][r],n[e][i]]=[n[e][i],n[e][r]];[e[r],e[i]]=[e[i],e[r]]}for(let n=r+1;n<t;n++){let l=e[n][r]/=e[r][r];for(let i=r+1;i<t;i++)e[n][i]-=l*e[r][i]}}let r=Array(t).fill().map((()=>Array(t).fill(0))),l=Array(t).fill().map((()=>Array(t).fill(0)));for(let n=0;n<t;n++){r[n][n]=1;for(let i=0;i<t;i++)i<n?r[n][i]=e[n][i]:l[n][i]=e[n][i]}return[n,r,l]},e.lu_factor=Jr,e.lu_factor_=Kr,e.lu_solve=Qr,e.map=function(e,t){return or(t,e)},e.map2_=ur,e.map_=or,e.matmul=wr,e.maximum=Ct,e.mean=Vn,e.minimum=Gt,e.mod=qe,e.modf=function(e,t=[null,null]){return[or(Oe,e,t[0]),or(Ie,e,t[1])]},e.moveaxis=be,e.multiply=Ae,e.nan=NaN,e.nan_to_num=en,e.nancumprod=Xr,e.nancumsum=Gr,e.nanprod=Mt,e.nansum=kt,e.ndenumerate=Lr,e.ndim=ie,e.ndindex=I,e.nditer=function(e,t=null){return new ce(e,t)},e.ndoffset=Tr,e.negative=ve,e.neq=gn,e.nonzero=oe,e.normalize_axes=gr,e.normalize_axis=pe,e.normalize_axis_index=yr,e.normalize_axis_tuple=de,e.not=Ve,e.not_equal=fn,e.ogrid=function(...e){let t=[];for(let n=0;n<e.length;n++){let{start:r,stop:l,step:i,slicelength:s}=e[n].indices(),a=Array(s);for(let e=0;e<s;e++)a[e]=r+e*i;let o=Array(e.length).fill(1);o[n]=s,t.push(A(a).reshape(o))}return t},e.ones=function(e,t=void 0){return V(e,1,t)},e.ones_like=function(e,t=void 0){return B(e,1,t)},e.or=Pe,e.packbits=function(e,t=null,n="big"){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let r=e.shape.slice();r[t]=Math.ceil(r[t]/8);let l=D(r),i=e.shape.slice();i[t]=1;let s=Array(8*r[t]);for(let r of I(i)){let{offset:a}=e,{offset:o}=l;for(let t=0;t<i.length;t++)a+=r[t]*e.strides[t],o+=r[t]*l.strides[t];s.fill(0);for(let n=0;n<e.shape[t];n++){let r=e.data[a+n*e.strides[t]];s[n]=r}let u=0;for(let e=0;e<s.length;e+=8){let r=0;if("big"==n)for(let t=0;t<8;t++)r+=s[e+t]<<7-t;else{if("little"!=n)throw"bitorder can be either big or little";for(let t=0;t<8;t++)r+=s[e+t]<<t}l.data[o+u*l.strides[t]]=r,u++}}return l},e.pi=Ye,e.pick=On,e.positive=$e,e.power=Me,e.prod=At,e.ptp=Un,e.put=Yn,e.rad2deg=ft,e.radians=ut,e.rand=function(...e){return In(e)},e.random=Pn,e.random_sample=In,e.ranf=Fn,e.ravel=fe,e.ravel_multi_index=function(e,t,n="raise"){let r=T(e).T;if(r=ee(r),"raise"==n){if(Ge(hn(r,0))||Ge(dn(r,t)))throw new Error(`index is out of bounds for array with shape ${t}`)}else if("wrap"==n)r=qe(xe(qe(r,t),t),t);else{if("clip"!=n)throw new Error(`unsupported mode '${n}'`);r=_n(r,H(t.length),ke(t,1))}let l=D(j(e).slice(1)),i=we([Ur(t.slice(1).reverse()).at("::-1"),[1]]),s=0;for(let e of r)l.itemset(s++,zt(Ae(e,i)));return l},e.reciprocal=_e,e.reduce=function(e,t){return fr(t,e,axis)},e.reduce_=fr,e.remainder=Fe,e.repeat=Hn,e.reshape=U,e.resize=function(e,t){"number"==typeof t&&(t=[t]),e=fe(e);let n=1;for(let e of t){if(e<0)throw"all elements of 'new_shape' must be non-negative";n*=e}if(0==e.size||0==n)return H(t);let r=Math.ceil(n/e.size);return U(e=we(Array(r).fill(e)).at(y(0,n)),t)},e.right_shift=on,e.rint=bt,e.roll=function e(t,n,r=null){if(t=T(t),null==r)return e(t.ravel(),n,0).reshape(t.shape);{let e=ne(n,r=de(r,t.ndim,!0));if(e.ndim>1)throw new Error("'shift' and 'axis' should be scalars or 1D sequences");let l=Array(t.ndim).fill(0);for(let[t,n]of e)l[n]+=t;let i=Array(t.ndim).fill([[y(null),y(null)]]);for(let[e,n]of l.entries())n%=t.shape[e]||1,n&&(i[e]=[[y(null,-n),y(n,null)],[y(-n,null),y(null,n)]]);let s=L(t);for(let e of new nr(i)){let n=e.map((e=>e[0])),r=e.map((e=>e[1]));s.set(r,t.get(n))}return s}},e.row_stack=function(e){return e=ee(...e),Array.isArray(e)||(e=[e]),we(e,0)},e.s_=function(...e){return 1==e.length?Kn(e[0]):Rn(...e)},e.sample=Tn,e.scatter=Rr,e.searchsorted=Zn,e.set=function(e,t,n){return Rr(e,t).set(n)},e.shallow_array_equal=ge,e.shape=E,e.shape_=j,e.sign=Zt,e.signbit=Lt,e.sin=et,e.sinh=pt,e.slice=y,e.solve=function(e,t){return Qr(Jr(e),t)},e.sort=vn,e.split=Wn,e.sqrt=Jt,e.square=Qt,e.squeeze=ae,e.stack=function(e,t=0,n=null){if(0==(e=e.map((e=>T(e)))).length)throw"need at least one array to stack";for(let t=1;t<e.length;t++)if(!ge(e[0],e[t]))throw"all input arrays must have the same shape";t=yr(t,e[0].ndim+1);let r=[...Array(t).fill(p.colon),p.newaxis];return we(e.map((e=>e.get(r))),t,n)},e.std=Xn,e.subtract=ke,e.sum=zt,e.swapaxes=R,e.take=G,e.tan=nt,e.tanh=ct,e.tester=l,e.tile=function(e,t){"number"==typeof t&&(t=[t]);let n=t.length;if(t.every((e=>1==e))&&e instanceof b)return A(e,e.dtype,!0,n);let r=A(e,e.dtype,!1,n);n<r.ndim&&(t=[...Array(r.ndim-n).fill(1),...t]);let l=r.shape.map(((e,n)=>e*t[n])),i=r.size;if(i>0){let{ndim:e,shape:n}=r;for(let l=0;l<e;l++){let e=n[l],s=t[l];1!=s&&(r=r.reshape(-1,i).repeat(s,0)),i=i/e|0}}return r.reshape(l)},e.timeit=function(e,{name:t="test",setup:n=null,duration:r=1e3,warmup:l=100,cycle:i="auto",cycle_duration:s=100,repeat:a="auto",verbose:o=!1}={}){let u=n?.();if(s>r&&(s=r),"auto"==a&&(a=r/s|0),"auto"==i){let t,n=1;for(;;){let r=Date.now();for(let t=0;t<n;t++)e(u);if(t=Date.now()-r,t>s)break;n*=2}i=Math.max(n/t*(r/a)|0,1)}let f=[];for(let t=0;t<l;t++)e(u);for(let t=0;t<a;t++){let t=Date.now();for(let t=0;t<i;t++)e(u);let n=i/((Date.now()-t)/1e3);f.push(n)}let h=f.length,p=f.reduce(((e,t)=>e+t))/h;if(o){let e=Math.max(...f),n=Math.min(...f),r=Math.max(e-p,p-n);console.log(`#${t} ${0|p} ± ${(r/p*100).toFixed(2)}% ops/sec (${a} runs)`)}return p},e.timeit2=function(e,t=1e3){let n,r=performance.now(),l=0;for(;e(),l++,n=performance.now(),!(n-r>=t););let i=l/((n-r)/t);console.log(`ops: ${i} per sec`,e)},e.toArray=function(e){return e instanceof b?e.array():e},e.transpose=Y,e.trapz=function(e,t=null,n=1,r=-1){e=T(e);let{ndim:l}=e;r=yr(r,l);let i=n;if(null!=t)if(1==(t=T(t)).ndim){i=Et(t);let e=Array(l).fill(1);e[r]=i.shape[0],i=i.reshape(e)}else i=Et(t,null,r);let s,a=Array(l).fill(y()),o=Array(l).fill(y());return a[r]=y(1,null),o[r]=y(null,-1),s=xe(e.get(a),e.get(o)),Ae(i,s,s),ze(s,2,s),zt(s,r)},e.true_divide=Ee,e.trunc=vt,e.tupleType=Qn,e.tuple_=P,e.unique=function(e){return e=T(e),A([...new Set(e.flat)].sort())},e.unpackbits=function(e,t=null,n=null,r="big"){e=T(e),null==t?(e=fe(e),t=0):t=yr(t,e.ndim);let l=0,i=8;null!=n&&(n<0?l=8-n:i=n);let s=e.shape.slice();s[t]=s[t]*(i-l);let a=D(s),o=Array(8);for(let n of I(e.shape)){let{offset:s}=e,{offset:u}=a;for(let t=0;t<e.shape.length;t++)s+=n[t]*e.strides[t],u+=n[t]*a.strides[t];Cn(e.data[s],o,r);for(let e=l,n=0;e<i;e++,n++)a.data[u+n*a.strides[t]]=o[e]}return a},e.unravel_index=function(e,t){e=T(e);let n=t.length,r=_(t),l=D([].concat(e.shape,n)),i=0;for(let s of e.flat){if(s<0||s>=r)throw new Error(`index ${s} is out of bounds for array with size ${r}`);for(let e=n;e--;)l.data[i+e]=s%t[e],s=s/t[e]|0;i+=n}let s=Array(n).fill().map(((e,t)=>t)).map((e=>l.at("...",e)));return s},e.unwrap=function(e,t=2*Ye,n=t/2){if(1!=(e=T(e)).ndim)throw"unwrap currently only supports 1d arrays";let r=[e.data[e.offset]],l=e.data[e.offset],i=!0;for(let s of Tr(e.shape,e.strides)){if(i){i=!1;continue}let a=e.data[e.offset+s]-l;a>n?a-=t:a<-n&&(a+=t);let o=l+a;r.push(o),l=o}return T(r)},e.variance=Bn,e.vsplit=function(e,t){if(ie(e)<2)throw"vsplit only works on arrays of 2 or more dimensions";return Wn(e,t,0)},e.vstack=function(e){return e=ee(...e),Array.isArray(e)||(e=[e]),we(e,0)},e.where=function(e,t=null,n=null){if(null==t&&null==n)return oe(e);let r=ne(e,t,n),l=D(r.shape),i=0;for(let[e,t,n]of r)l.data[i++]=e?t:n;return l},e.wrapper_=function(e,t,...n){return t=t.bind(null,...n),Object.defineProperty(t,"name",{value:e}),t},e.wrapper_accumulate=ar,e.wrapper_map=lr,e.wrapper_map2=ir,e.wrapper_reduce=sr,e.xor=Xe,e.zeros=H,e.zeros_like=J}));