-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.js
4 lines (4 loc) · 57 KB
/
mod.js
1
2
3
4
// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
/// <reference types="./mod.d.ts" />
var r="function"==typeof Object.defineProperty?Object.defineProperty:null;var e=Object.defineProperty;function t(r){return"number"==typeof r}function n(r){var e,t="";for(e=0;e<r;e++)t+="0";return t}function i(r,e,t){var i=!1,o=e-r.length;return o<0||(function(r){return"-"===r[0]}(r)&&(i=!0,r=r.substr(1)),r=t?r+n(o):n(o)+r,i&&(r="-"+r)),r}var o=String.prototype.toLowerCase,a=String.prototype.toUpperCase;function u(r){var e,n,u;switch(r.specifier){case"b":e=2;break;case"o":e=8;break;case"x":case"X":e=16;break;default:e=10}if(n=r.arg,u=parseInt(n,10),!isFinite(u)){if(!t(n))throw new Error("invalid integer. Value: "+n);u=0}return u<0&&("u"===r.specifier||10!==e)&&(u=4294967295+u+1),u<0?(n=(-u).toString(e),r.precision&&(n=i(n,r.precision,r.padRight)),n="-"+n):(n=u.toString(e),u||r.precision?r.precision&&(n=i(n,r.precision,r.padRight)):n="",r.sign&&(n=r.sign+n)),16===e&&(r.alternate&&(n="0x"+n),n=r.specifier===a.call(r.specifier)?a.call(n):o.call(n)),8===e&&r.alternate&&"0"!==n.charAt(0)&&(n="0"+n),n}var f=Math.abs,l=String.prototype.toLowerCase,s=String.prototype.toUpperCase,h=String.prototype.replace,c=/e\+(\d)$/,p=/e-(\d)$/,m=/^(\d+)$/,y=/^(\d+)e/,g=/\.0$/,w=/\.0*e/,v=/(\..*[^0])0*e/;function b(r){var e,n,i=parseFloat(r.arg);if(!isFinite(i)){if(!t(r.arg))throw new Error("invalid floating-point number. Value: "+n);i=r.arg}switch(r.specifier){case"e":case"E":n=i.toExponential(r.precision);break;case"f":case"F":n=i.toFixed(r.precision);break;case"g":case"G":f(i)<1e-4?((e=r.precision)>0&&(e-=1),n=i.toExponential(e)):n=i.toPrecision(r.precision),r.alternate||(n=h.call(n,v,"$1e"),n=h.call(n,w,"e"),n=h.call(n,g,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return n=h.call(n,c,"e+0$1"),n=h.call(n,p,"e-0$1"),r.alternate&&(n=h.call(n,m,"$1."),n=h.call(n,y,"$1.e")),i>=0&&r.sign&&(n=r.sign+n),n=r.specifier===s.call(r.specifier)?s.call(n):l.call(n)}function d(r){var e,t="";for(e=0;e<r;e++)t+=" ";return t}var E=String.fromCharCode,_=Array.isArray;function T(r){return r!=r}function x(r){var e={};return e.specifier=r.specifier,e.precision=void 0===r.precision?1:r.precision,e.width=r.width,e.flags=r.flags||"",e.mapping=r.mapping,e}function A(r){var e,t,n,o,a,f,l,s,h,c,p,m,y;if(!_(r))throw new TypeError("invalid argument. First argument must be an array. Value: `"+r+"`.");for(f="",l=1,s=0;s<r.length;s++)if(n=r[s],"string"==typeof n)f+=n;else{if(e=void 0!==n.precision,!(n=x(n)).specifier)throw new TypeError("invalid argument. Token is missing `specifier` property. Index: `"+s+"`. Value: `"+n+"`.");for(n.mapping&&(l=n.mapping),t=n.flags,h=0;h<t.length;h++)switch(o=t.charAt(h)){case" ":n.sign=" ";break;case"+":n.sign="+";break;case"-":n.padRight=!0,n.padZeros=!1;break;case"0":n.padZeros=t.indexOf("-")<0;break;case"#":n.alternate=!0;break;default:throw new Error("invalid flag: "+o)}if("*"===n.width){if(n.width=parseInt(arguments[l],10),l+=1,T(n.width))throw new TypeError("the argument for * width at position "+l+" is not a number. Value: `"+n.width+"`.");n.width<0&&(n.padRight=!0,n.width=-n.width)}if(e&&"*"===n.precision){if(n.precision=parseInt(arguments[l],10),l+=1,T(n.precision))throw new TypeError("the argument for * precision at position "+l+" is not a number. Value: `"+n.precision+"`.");n.precision<0&&(n.precision=1,e=!1)}switch(n.arg=arguments[l],n.specifier){case"b":case"o":case"x":case"X":case"d":case"i":case"u":e&&(n.padZeros=!1),n.arg=u(n);break;case"s":n.maxWidth=e?n.precision:-1,n.arg=String(n.arg);break;case"c":if(!T(n.arg)){if((a=parseInt(n.arg,10))<0||a>127)throw new Error("invalid character code. Value: "+n.arg);n.arg=T(a)?String(n.arg):E(a)}break;case"e":case"E":case"f":case"F":case"g":case"G":e||(n.precision=6),n.arg=b(n);break;default:throw new Error("invalid specifier: "+n.specifier)}n.maxWidth>=0&&n.arg.length>n.maxWidth&&(n.arg=n.arg.substring(0,n.maxWidth)),n.padZeros?n.arg=i(n.arg,n.width||n.precision,n.padRight):n.width&&(n.arg=(c=n.arg,p=n.width,m=n.padRight,y=void 0,(y=p-c.length)<0?c:c=m?c+d(y):d(y)+c)),f+=n.arg||"",l+=1}return f}var V=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function j(r){var e={mapping:r[1]?parseInt(r[1],10):void 0,flags:r[2],width:r[3],precision:r[5],specifier:r[6]};return"."===r[4]&&void 0===r[5]&&(e.precision="1"),e}function S(r){var e,t,n,i;for(t=[],i=0,n=V.exec(r);n;)(e=r.slice(i,V.lastIndex-n[0].length)).length&&t.push(e),t.push(j(n)),i=V.lastIndex,n=V.exec(r);return(e=r.slice(i)).length&&t.push(e),t}function F(r){var e,t;if("string"!=typeof r)throw new TypeError(F("invalid argument. First argument must be a string. Value: `%s`.",r));for(e=[S(r)],t=1;t<arguments.length;t++)e.push(arguments[t]);return A.apply(null,e)}var k,R=Object.prototype,L=R.toString,I=R.__defineGetter__,B=R.__defineSetter__,O=R.__lookupGetter__,C=R.__lookupSetter__;k=function(){try{return r({},"x",{}),!0}catch(r){return!1}}()?e:function(r,e,t){var n,i,o,a;if("object"!=typeof r||null===r||"[object Array]"===L.call(r))throw new TypeError(F("invalid argument. First argument must be an object. Value: `%s`.",r));if("object"!=typeof t||null===t||"[object Array]"===L.call(t))throw new TypeError(F("invalid argument. Property descriptor must be an object. Value: `%s`.",t));if((i="value"in t)&&(O.call(r,e)||C.call(r,e)?(n=r.__proto__,r.__proto__=R,delete r[e],r[e]=t.value,r.__proto__=n):r[e]=t.value),o="get"in t,a="set"in t,i&&(o||a))throw new Error("invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.");return o&&I&&I.call(r,e,t.get),a&&B&&B.call(r,e,t.set),r};var M=k;function U(r,e,t){M(r,e,{configurable:!1,enumerable:!1,writable:!1,value:t})}function N(r,e){return r<0?0:r>e?e:r}function P(r,e){var t=e+1;return r<0?((r+=t)<0&&0!==(r%=t)&&(r+=t),r):r>e?((r-=t)>e&&(r%=t),r):r}function Y(r,e){return r<0?(r+=e+1)<0?-1:r:r>e?-1:r}var W="function";function $(r){return typeof r.get===W&&typeof r.set===W}var G={complex128:function(r,e){return r.get(e)},complex64:function(r,e){return r.get(e)},default:function(r,e){return r.get(e)}};function z(r){var e=G[r];return"function"==typeof e?e:G.default}var Z={float64:function(r,e){return r[e]},float32:function(r,e){return r[e]},int32:function(r,e){return r[e]},int16:function(r,e){return r[e]},int8:function(r,e){return r[e]},uint32:function(r,e){return r[e]},uint16:function(r,e){return r[e]},uint8:function(r,e){return r[e]},uint8c:function(r,e){return r[e]},generic:function(r,e){return r[e]},default:function(r,e){return r[e]}};function J(r){var e=Z[r];return"function"==typeof e?e:Z.default}var X="function"==typeof Symbol&&"symbol"==typeof Symbol("foo");function q(){return X&&"symbol"==typeof Symbol.toStringTag}var D=Object.prototype.toString;var H=Object.prototype.hasOwnProperty;function K(r,e){return null!=r&&H.call(r,e)}var Q="function"==typeof Symbol?Symbol:void 0,rr="function"==typeof Q?Q.toStringTag:"";var er=q()?function(r){var e,t,n;if(null==r)return D.call(r);t=r[rr],e=K(r,rr);try{r[rr]=void 0}catch(e){return D.call(r)}return n=D.call(r),e?r[rr]=t:delete r[rr],n}:function(r){return D.call(r)};var tr=Array.isArray?Array.isArray:function(r){return"[object Array]"===er(r)};function nr(r){return null!==r&&"object"==typeof r}function ir(r){return nr(r)&&(r._isBuffer||r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r))}function or(){return/^\s*function\s*([^(]*)/i}U(nr,"isObjectLikeArray",function(r){if("function"!=typeof r)throw new TypeError(F("invalid argument. Must provide a function. Value: `%s`.",r));return function(e){var t,n;if(!tr(e))return!1;if(0===(t=e.length))return!1;for(n=0;n<t;n++)if(!1===r(e[n]))return!1;return!0}}(nr));var ar=/^\s*function\s*([^(]*)/i;function ur(r){var e,t,n;if(("Object"===(t=er(r).slice(8,-1))||"Error"===t)&&r.constructor){if("string"==typeof(n=r.constructor).name)return n.name;if(e=ar.exec(n.toString()))return e[1]}return ir(r)?"Buffer":t}U(or,"REGEXP",ar);var fr={Float32Array:"float32",Float64Array:"float64",Array:"generic",Int16Array:"int16",Int32Array:"int32",Int8Array:"int8",Uint16Array:"uint16",Uint32Array:"uint32",Uint8Array:"uint8",Uint8ClampedArray:"uint8c",Complex64Array:"complex64",Complex128Array:"complex128"},lr="function"==typeof Float64Array;var sr="function"==typeof Float64Array?Float64Array:null;var hr="function"==typeof Float64Array?Float64Array:void 0;var cr=function(){var r,e,t;if("function"!=typeof sr)return!1;try{e=new sr([1,3.14,-3.14,NaN]),t=e,r=(lr&&t instanceof Float64Array||"[object Float64Array]"===er(t))&&1===e[0]&&3.14===e[1]&&-3.14===e[2]&&e[3]!=e[3]}catch(e){r=!1}return r}()?hr:function(){throw new Error("not implemented")},pr="function"==typeof Float32Array;var mr=Number.POSITIVE_INFINITY,yr="function"==typeof Float32Array?Float32Array:null;var gr="function"==typeof Float32Array?Float32Array:void 0;var wr=function(){var r,e,t;if("function"!=typeof yr)return!1;try{e=new yr([1,3.14,-3.14,5e40]),t=e,r=(pr&&t instanceof Float32Array||"[object Float32Array]"===er(t))&&1===e[0]&&3.140000104904175===e[1]&&-3.140000104904175===e[2]&&e[3]===mr}catch(e){r=!1}return r}()?gr:function(){throw new Error("not implemented")},vr="function"==typeof Uint32Array;var br="function"==typeof Uint32Array?Uint32Array:null;var dr="function"==typeof Uint32Array?Uint32Array:void 0;var Er=function(){var r,e,t;if("function"!=typeof br)return!1;try{e=new br(e=[1,3.14,-3.14,4294967296,4294967297]),t=e,r=(vr&&t instanceof Uint32Array||"[object Uint32Array]"===er(t))&&1===e[0]&&3===e[1]&&4294967293===e[2]&&0===e[3]&&1===e[4]}catch(e){r=!1}return r}()?dr:function(){throw new Error("not implemented")},_r="function"==typeof Int32Array;var Tr="function"==typeof Int32Array?Int32Array:null;var xr="function"==typeof Int32Array?Int32Array:void 0;var Ar=function(){var r,e,t;if("function"!=typeof Tr)return!1;try{e=new Tr([1,3.14,-3.14,2147483648]),t=e,r=(_r&&t instanceof Int32Array||"[object Int32Array]"===er(t))&&1===e[0]&&3===e[1]&&-3===e[2]&&-2147483648===e[3]}catch(e){r=!1}return r}()?xr:function(){throw new Error("not implemented")},Vr="function"==typeof Uint16Array;var jr="function"==typeof Uint16Array?Uint16Array:null;var Sr="function"==typeof Uint16Array?Uint16Array:void 0;var Fr=function(){var r,e,t;if("function"!=typeof jr)return!1;try{e=new jr(e=[1,3.14,-3.14,65536,65537]),t=e,r=(Vr&&t instanceof Uint16Array||"[object Uint16Array]"===er(t))&&1===e[0]&&3===e[1]&&65533===e[2]&&0===e[3]&&1===e[4]}catch(e){r=!1}return r}()?Sr:function(){throw new Error("not implemented")},kr="function"==typeof Int16Array;var Rr="function"==typeof Int16Array?Int16Array:null;var Lr="function"==typeof Int16Array?Int16Array:void 0;var Ir=function(){var r,e,t;if("function"!=typeof Rr)return!1;try{e=new Rr([1,3.14,-3.14,32768]),t=e,r=(kr&&t instanceof Int16Array||"[object Int16Array]"===er(t))&&1===e[0]&&3===e[1]&&-3===e[2]&&-32768===e[3]}catch(e){r=!1}return r}()?Lr:function(){throw new Error("not implemented")},Br="function"==typeof Uint8Array;var Or="function"==typeof Uint8Array?Uint8Array:null;var Cr="function"==typeof Uint8Array?Uint8Array:void 0;var Mr=function(){var r,e,t;if("function"!=typeof Or)return!1;try{e=new Or(e=[1,3.14,-3.14,256,257]),t=e,r=(Br&&t instanceof Uint8Array||"[object Uint8Array]"===er(t))&&1===e[0]&&3===e[1]&&253===e[2]&&0===e[3]&&1===e[4]}catch(e){r=!1}return r}()?Cr:function(){throw new Error("not implemented")},Ur="function"==typeof Uint8ClampedArray;var Nr="function"==typeof Uint8ClampedArray?Uint8ClampedArray:null;var Pr="function"==typeof Uint8ClampedArray?Uint8ClampedArray:void 0;var Yr=function(){var r,e,t;if("function"!=typeof Nr)return!1;try{e=new Nr([-1,0,1,3.14,4.99,255,256]),t=e,r=(Ur&&t instanceof Uint8ClampedArray||"[object Uint8ClampedArray]"===er(t))&&0===e[0]&&0===e[1]&&1===e[2]&&3===e[3]&&5===e[4]&&255===e[5]&&255===e[6]}catch(e){r=!1}return r}()?Pr:function(){throw new Error("not implemented")},Wr="function"==typeof Int8Array;var $r="function"==typeof Int8Array?Int8Array:null;var Gr="function"==typeof Int8Array?Int8Array:void 0;var zr=function(){var r,e,t;if("function"!=typeof $r)return!1;try{e=new $r([1,3.14,-3.14,128]),t=e,r=(Wr&&t instanceof Int8Array||"[object Int8Array]"===er(t))&&1===e[0]&&3===e[1]&&-3===e[2]&&-128===e[3]}catch(e){r=!1}return r}()?Gr:function(){throw new Error("not implemented")};function Zr(r){return"number"==typeof r}var Jr=Number,Xr=Jr.prototype.toString;var qr=q();function Dr(r){return"object"==typeof r&&(r instanceof Jr||(qr?function(r){try{return Xr.call(r),!0}catch(r){return!1}}(r):"[object Number]"===er(r)))}function Hr(r){return Zr(r)||Dr(r)}U(Hr,"isPrimitive",Zr),U(Hr,"isObject",Dr);var Kr=Jr.NEGATIVE_INFINITY,Qr=Math.floor;function re(r){return Qr(r)===r}function ee(r){return r<mr&&r>Kr&&re(r)}function te(r){return Zr(r)&&ee(r)}function ne(r){return Dr(r)&&ee(r.valueOf())}function ie(r){return te(r)||ne(r)}function oe(r){return te(r)&&r>=0}function ae(r){return ne(r)&&r.valueOf()>=0}function ue(r){return oe(r)||ae(r)}U(ie,"isPrimitive",te),U(ie,"isObject",ne),U(ue,"isPrimitive",oe),U(ue,"isObject",ae);var fe=4294967295;function le(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&re(r.length)&&r.length>=0&&r.length<=fe}var se=9007199254740991;function he(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&re(r.length)&&r.length>=0&&r.length<=se}var ce="function"==typeof ArrayBuffer;function pe(r){return ce&&r instanceof ArrayBuffer||"[object ArrayBuffer]"===er(r)}function me(r){return"object"==typeof r&&null!==r&&!tr(r)}function ye(r){return"string"==typeof r}var ge=String.prototype.valueOf;var we=q();function ve(r){return"object"==typeof r&&(r instanceof String||(we?function(r){try{return ge.call(r),!0}catch(r){return!1}}(r):"[object String]"===er(r)))}function be(r){return ye(r)||ve(r)}U(be,"isPrimitive",ye),U(be,"isObject",ve);var de=/./;function Ee(r){return"boolean"==typeof r}var _e=Boolean,Te=Boolean.prototype.toString;var xe=q();function Ae(r){return"object"==typeof r&&(r instanceof _e||(xe?function(r){try{return Te.call(r),!0}catch(r){return!1}}(r):"[object Boolean]"===er(r)))}function Ve(r){return Ee(r)||Ae(r)}U(Ve,"isPrimitive",Ee),U(Ve,"isObject",Ae);var je="object"==typeof self?self:null,Se="object"==typeof window?window:null,Fe="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ke="object"==typeof Fe?Fe:null,Re="object"==typeof globalThis?globalThis:null;var Le=function(r){if(arguments.length){if(!Ee(r))throw new TypeError(F("invalid argument. Must provide a boolean. Value: `%s`.",r));if(r)return new Function("return this;")()}if(Re)return Re;if(je)return je;if(Se)return Se;if(ke)return ke;throw new Error("unexpected error. Unable to resolve global object.")}(),Ie=Le.document&&Le.document.childNodes,Be=Int8Array;var Oe="function"==typeof de||"object"==typeof Be||"function"==typeof Ie?function(r){return ur(r).toLowerCase()}:function(r){var e;return null===r?"null":"object"===(e=typeof r)?ur(r).toLowerCase():e};function Ce(r){return"function"===Oe(r)}function Me(r,e){if(!(this instanceof Me))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Zr(r))throw new TypeError(F("invalid argument. Real component must be a number. Value: `%s`.",r));if(!Zr(e))throw new TypeError(F("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return M(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),M(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:e}),this}U(Me,"BYTES_PER_ELEMENT",8),U(Me.prototype,"BYTES_PER_ELEMENT",8),U(Me.prototype,"byteLength",16),U(Me.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),U(Me.prototype,"toJSON",(function(){var r={type:"Complex128"};return r.re=this.re,r.im=this.im,r}));var Ue="function"==typeof Math.fround?Math.fround:null,Ne=new wr(1);var Pe="function"==typeof Ue?Ue:function(r){return Ne[0]=r,Ne[0]};function Ye(r,e){if(!(this instanceof Ye))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Zr(r))throw new TypeError(F("invalid argument. Real component must be a number. Value: `%s`.",r));if(!Zr(e))throw new TypeError(F("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return M(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:Pe(r)}),M(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:Pe(e)}),this}function We(r){return r instanceof Me||r instanceof Ye||"object"==typeof r&&null!==r&&"number"==typeof r.re&&"number"==typeof r.im}function $e(r){return re(r/2)}U(Ye,"BYTES_PER_ELEMENT",4),U(Ye.prototype,"BYTES_PER_ELEMENT",4),U(Ye.prototype,"byteLength",8),U(Ye.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),U(Ye.prototype,"toJSON",(function(){var r={type:"Complex64"};return r.re=this.re,r.im=this.im,r}));var Ge=8;function ze(r){return"object"==typeof r&&null!==r&&"Complex64Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===Ge}var Ze=16;function Je(r){return"object"==typeof r&&null!==r&&"Complex128Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===Ze}function Xe(){return"function"==typeof Q&&"symbol"==typeof Q("foo")&&K(Q,"iterator")&&"symbol"==typeof Q.iterator}var qe=Xe()?Symbol.iterator:null;function De(r,e,t){M(r,e,{configurable:!1,enumerable:!1,get:t})}function He(r,e){if(!(this instanceof He))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Zr(r))throw new TypeError(F("invalid argument. Real component must be a number. Value: `%s`.",r));if(!Zr(e))throw new TypeError(F("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return M(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:Pe(r)}),M(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:Pe(e)}),this}function Ke(r){return r.re}function Qe(r){return r.im}function rt(r,e){return new wr(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*e,2*(r.length-e))}function et(r,e){return new cr(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*e,2*(r.length-e))}function tt(r){var e,t,n;for(e=[];!(t=r.next()).done;)if(le(n=t.value)&&n.length>=2)e.push(n[0],n[1]);else{if(!We(n))return new TypeError(F("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));e.push(Ke(n),Qe(n))}return e}U(He,"BYTES_PER_ELEMENT",4),U(He.prototype,"BYTES_PER_ELEMENT",4),U(He.prototype,"byteLength",8),U(He.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),U(He.prototype,"toJSON",(function(){var r={type:"Complex64"};return r.re=this.re,r.im=this.im,r}));var nt=2*wr.BYTES_PER_ELEMENT,it=Xe();function ot(r){return r instanceof ft||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function at(r){return r===ft||"Complex128Array"===r.name}function ut(r,e){return new He(r[e*=2],r[e+1])}function ft(){var r,e,t,n;if(e=arguments.length,!(this instanceof ft))return 0===e?new ft:1===e?new ft(arguments[0]):2===e?new ft(arguments[0],arguments[1]):new ft(arguments[0],arguments[1],arguments[2]);if(0===e)t=new wr(0);else if(1===e)if(oe(arguments[0]))t=new wr(2*arguments[0]);else if(he(arguments[0]))if((n=(t=arguments[0]).length)&&tr(t)&&We(t[0])){if(t=function(r,e){var t,n,i,o;for(t=e.length,o=0,i=0;i<t;i++){if(!We(n=e[i]))return null;r[o]=Ke(n),r[o+1]=Qe(n),o+=2}return r}(new wr(2*n),t),null===t){if(!$e(n))throw new RangeError(F("invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.",n));t=new wr(arguments[0])}}else{if(ze(t))t=rt(t,0);else if(Je(t))t=et(t,0);else if(!$e(n))throw new RangeError(F("invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.",n));t=new wr(t)}else if(pe(arguments[0])){if(!re((t=arguments[0]).byteLength/nt))throw new RangeError(F("invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.",nt,t.byteLength));t=new wr(t)}else{if(!me(arguments[0]))throw new TypeError(F("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.",arguments[0]));if(t=arguments[0],!1===it)throw new TypeError(F("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.",t));if(!Ce(t[qe]))throw new TypeError(F("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.",t));if(!Ce((t=t[qe]()).next))throw new TypeError(F("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.",t));if((t=tt(t))instanceof Error)throw t;t=new wr(t)}else{if(!pe(t=arguments[0]))throw new TypeError(F("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",t));if(!oe(r=arguments[1]))throw new TypeError(F("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",r));if(!re(r/nt))throw new RangeError(F("invalid argument. Byte offset must be a multiple of %u. Value: `%u`.",nt,r));if(2===e){if(!re((n=t.byteLength-r)/nt))throw new RangeError(F("invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.",nt,n));t=new wr(t,r)}else{if(!oe(n=arguments[2]))throw new TypeError(F("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));if(n*nt>t.byteLength-r)throw new RangeError(F("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*nt));t=new wr(t,r,2*n)}}return U(this,"_buffer",t),U(this,"_length",t.length/2),this}function lt(r,e){if(!(this instanceof lt))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Zr(r))throw new TypeError(F("invalid argument. Real component must be a number. Value: `%s`.",r));if(!Zr(e))throw new TypeError(F("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return M(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),M(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:e}),this}function st(r){return r.re}function ht(r){return r.im}function ct(r){var e,t,n;for(e=[];!(t=r.next()).done;)if(le(n=t.value)&&n.length>=2)e.push(n[0],n[1]);else{if(!We(n))return new TypeError(F("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));e.push(st(n),ht(n))}return e}U(ft,"BYTES_PER_ELEMENT",nt),U(ft,"name","Complex64Array"),U(ft,"from",(function(r){var e,t,n,i,o,a,u,f,l,s,h,c;if(!Ce(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!at(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((t=arguments.length)>1){if(!Ce(n=arguments[1]))throw new TypeError(F("invalid argument. Second argument must be a function. Value: `%s`.",n));t>2&&(e=arguments[2])}if(ot(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,c=0,h=0;h<f;h++){if(We(s=n.call(e,r.get(h),h)))o[c]=Ke(s),o[c+1]=Qe(s);else{if(!(le(s)&&s.length>=2))throw new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[c]=s[0],o[c+1]=s[1]}c+=2}return i}return new this(r)}if(he(r)){if(n){for(f=r.length,u=r.get&&r.set?z("default"):J("default"),h=0;h<f;h++)if(!We(u(r,h))){l=!0;break}if(l){if(!$e(f))throw new RangeError(F("invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.",2,f));for(o=(i=new this(f/2))._buffer,h=0;h<f;h++)o[h]=n.call(e,u(r,h),h);return i}for(o=(i=new this(f))._buffer,c=0,h=0;h<f;h++){if(We(s=n.call(e,u(r,h),h)))o[c]=Ke(s),o[c+1]=Qe(s);else{if(!(le(s)&&s.length>=2))throw new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[c]=s[0],o[c+1]=s[1]}c+=2}return i}return new this(r)}if(me(r)&&it&&Ce(r[qe])){if(!Ce((o=r[qe]()).next))throw new TypeError(F("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,e,t){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,le(o=e.call(t,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!We(o))return new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Ke(o),Qe(o))}return n}(o,n,e):tt(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,h=0;h<f;h++)o[h]=a[h];return i}throw new TypeError(F("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r))})),U(ft,"of",(function(){var r,e;if(!Ce(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!at(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(r=[],e=0;e<arguments.length;e++)r.push(arguments[e]);return new this(r)})),U(ft.prototype,"at",(function(r){if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!re(r))throw new TypeError(F("invalid argument. Must provide an integer. Value: `%s`.",r));if(r<0&&(r+=this._length),!(r<0||r>=this._length))return ut(this._buffer,r)})),De(ft.prototype,"buffer",(function(){return this._buffer.buffer})),De(ft.prototype,"byteLength",(function(){return this._buffer.byteLength})),De(ft.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(ft.prototype,"BYTES_PER_ELEMENT",ft.BYTES_PER_ELEMENT),U(ft.prototype,"copyWithin",(function(r,e){if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*e):this._buffer.copyWithin(2*r,2*e,2*arguments[2]),this})),U(ft.prototype,"entries",(function(){var r,e,t,n,i,o,a;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return e=this,r=this._buffer,n=this._length,o=-1,a=-2,U(t={},"next",(function(){var e;if(o+=1,i||o>=n)return{done:!0};return e=new He(r[a+=2],r[a+1]),{value:[o,e],done:!1}})),U(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),qe&&U(t,qe,(function(){return e.entries()})),t})),U(ft.prototype,"every",(function(r,e){var t,n;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(!r.call(e,ut(t,n),n,this))return!1;return!0})),U(ft.prototype,"fill",(function(r,e,t){var n,i,o,a,u,f;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(n=this._buffer,i=this._length,arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));if(e<0&&(e+=i)<0&&(e=0),arguments.length>2){if(!re(t))throw new TypeError(F("invalid argument. Third argument must be an integer. Value: `%s`.",t));t<0&&(t+=i)<0&&(t=0),t>i&&(t=i)}else t=i}else e=0,t=i;for(a=Ke(r),u=Qe(r),f=e;f<t;f++)n[o=2*f]=a,n[o+1]=u;return this})),U(ft.prototype,"filter",(function(r,e){var t,n,i,o;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=[],i=0;i<this._length;i++)o=ut(t,i),r.call(e,o,i,this)&&n.push(o);return new this.constructor(n)})),U(ft.prototype,"find",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(i=ut(t,n),r.call(e,i,n,this))return i})),U(ft.prototype,"findIndex",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(i=ut(t,n),r.call(e,i,n,this))return n;return-1})),U(ft.prototype,"findLast",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=this._length-1;n>=0;n--)if(i=ut(t,n),r.call(e,i,n,this))return i})),U(ft.prototype,"findLastIndex",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=this._length-1;n>=0;n--)if(i=ut(t,n),r.call(e,i,n,this))return n;return-1})),U(ft.prototype,"forEach",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)i=ut(t,n),r.call(e,i,n,this)})),U(ft.prototype,"get",(function(r){if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!oe(r))throw new TypeError(F("invalid argument. Must provide a nonnegative integer. Value: `%s`.",r));if(!(r>=this._length))return ut(this._buffer,r)})),U(ft.prototype,"includes",(function(r,e){var t,n,i,o,a;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(i=Ke(r),o=Qe(r),t=this._buffer,a=e;a<this._length;a++)if(i===t[n=2*a]&&o===t[n+1])return!0;return!1})),U(ft.prototype,"indexOf",(function(r,e){var t,n,i,o,a;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(i=Ke(r),o=Qe(r),t=this._buffer,a=e;a<this._length;a++)if(i===t[n=2*a]&&o===t[n+1])return a;return-1})),U(ft.prototype,"join",(function(r){var e,t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=",";else{if(!ye(r))throw new TypeError(F("invalid argument. First argument must be a string. Value: `%s`.",r));n=r}for(e=[],t=this._buffer,i=0;i<this._length;i++)e.push(ut(t,i).toString());return e.join(n)})),U(ft.prototype,"lastIndexOf",(function(r,e){var t,n,i,o,a;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e>=this._length?e=this._length-1:e<0&&(e+=this._length)}else e=this._length-1;for(i=Ke(r),o=Qe(r),t=this._buffer,a=e;a>=0;a--)if(i===t[n=2*a]&&o===t[n+1])return a;return-1})),De(ft.prototype,"length",(function(){return this._length})),U(ft.prototype,"map",(function(r,e){var t,n,i,o,a;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,t=(i=new this.constructor(this._length))._buffer,o=0;o<this._length;o++)if(We(a=r.call(e,ut(n,o),o,this)))t[2*o]=Ke(a),t[2*o+1]=Qe(a);else{if(!le(a)||2!==a.length)throw new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",a));t[2*o]=a[0],t[2*o+1]=a[1]}return i})),U(ft.prototype,"reduce",(function(r,e){var t,n,i,o;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));if(t=this._buffer,i=this._length,arguments.length>1)n=e,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=ut(t,0),o=1}for(;o<i;o++)n=r(n,ut(t,o),o,this);return n})),U(ft.prototype,"reverse",(function(){var r,e,t,n,i,o;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(t=this._length,r=this._buffer,n=Qr(t/2),i=0;i<n;i++)o=t-i-1,e=r[2*i],r[2*i]=r[2*o],r[2*o]=e,e=r[2*i+1],r[2*i+1]=r[2*o+1],r[2*o+1]=e;return this})),U(ft.prototype,"set",(function(r){var e,t,n,i,o,a,u,f,l;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(n=this._buffer,arguments.length>1){if(!oe(t=arguments[1]))throw new TypeError(F("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",t))}else t=0;if(We(r)){if(t>=this._length)throw new RangeError(F("invalid argument. Index argument is out-of-bounds. Value: `%u`.",t));return n[t*=2]=Ke(r),void(n[t+1]=Qe(r))}if(ot(r)){if(t+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r._buffer,l=n.byteOffset+t*nt,e.buffer===n.buffer&&e.byteOffset<l&&e.byteOffset+e.byteLength>l){for(i=new wr(e.length),f=0;f<e.length;f++)i[f]=e[f];e=i}for(t*=2,l=0,f=0;f<a;f++)n[t]=e[l],n[t+1]=e[l+1],t+=2,l+=2}else{if(!he(r))throw new TypeError(F("invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.",r));for(a=r.length,f=0;f<a;f++)if(!We(r[f])){o=!0;break}if(o){if(!$e(a))throw new RangeError(F("invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.",a));if(t+a/2>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r,l=n.byteOffset+t*nt,e.buffer===n.buffer&&e.byteOffset<l&&e.byteOffset+e.byteLength>l){for(i=new wr(a),f=0;f<a;f++)i[f]=e[f];e=i}for(t*=2,a/=2,l=0,f=0;f<a;f++)n[t]=e[l],n[t+1]=e[l+1],t+=2,l+=2;return}if(t+a>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(t*=2,f=0;f<a;f++)u=r[f],n[t]=Ke(u),n[t+1]=Qe(u),t+=2}})),U(ft.prototype,"slice",(function(r,e){var t,n,i,o,a,u,f;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(a=this._buffer,u=this._length,0===arguments.length)r=0,e=u;else{if(!re(r))throw new TypeError(F("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=u)<0&&(r=0),1===arguments.length)e=u;else{if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0?(e+=u)<0&&(e=0):e>u&&(e=u)}}for(t=r<e?e-r:0,n=(i=new this.constructor(t))._buffer,f=0;f<t;f++)o=2*(f+r),n[2*f]=a[o],n[2*f+1]=a[o+1];return i})),U(ft.prototype,"some",(function(r,e){var t,n;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(r.call(e,ut(t,n),n,this))return!0;return!1})),U(ft.prototype,"subarray",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(n=this._buffer,i=this._length,0===arguments.length)r=0,e=i;else{if(!re(r))throw new TypeError(F("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=i)<0&&(r=0),1===arguments.length)e=i;else{if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0?(e+=i)<0&&(e=0):e>i&&(e=i)}}return r>=i?(i=0,t=n.byteLength):r>=e?(i=0,t=n.byteOffset+r*nt):(i=e-r,t=n.byteOffset+r*nt),new this.constructor(n.buffer,t,i<0?0:i)})),U(ft.prototype,"toReversed",(function(){var r,e,t,n,i,o;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(t=this._length,e=new this.constructor(t),n=this._buffer,r=e._buffer,i=0;i<t;i++)o=t-i-1,r[2*i]=n[2*o],r[2*i+1]=n[2*o+1];return e})),U(ft.prototype,"toString",(function(){var r,e,t;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(r=[],e=this._buffer,t=0;t<this._length;t++)r.push(ut(e,t).toString());return r.join(",")})),U(ft.prototype,"with",(function(r,e){var t,n,i;if(!ot(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!re(r))throw new TypeError(F("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(F("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!We(e))throw new TypeError(F("invalid argument. Second argument must be a complex number. Value: `%s`.",e));return(t=(n=new this.constructor(this._buffer))._buffer)[2*r]=Ke(e),t[2*r+1]=Qe(e),n})),U(lt,"BYTES_PER_ELEMENT",8),U(lt.prototype,"BYTES_PER_ELEMENT",8),U(lt.prototype,"byteLength",16),U(lt.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),U(lt.prototype,"toJSON",(function(){var r={type:"Complex128"};return r.re=this.re,r.im=this.im,r}));var pt=2*cr.BYTES_PER_ELEMENT,mt=Xe();function yt(r){return r instanceof vt||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function gt(r){return r===vt||"Complex64Array"===r.name}function wt(r,e){return new lt(r[e*=2],r[e+1])}function vt(){var r,e,t,n;if(e=arguments.length,!(this instanceof vt))return 0===e?new vt:1===e?new vt(arguments[0]):2===e?new vt(arguments[0],arguments[1]):new vt(arguments[0],arguments[1],arguments[2]);if(0===e)t=new cr(0);else if(1===e)if(oe(arguments[0]))t=new cr(2*arguments[0]);else if(he(arguments[0]))if((n=(t=arguments[0]).length)&&tr(t)&&We(t[0])){if(t=function(r,e){var t,n,i,o;for(t=e.length,o=0,i=0;i<t;i++){if(!We(n=e[i]))return null;r[o]=st(n),r[o+1]=ht(n),o+=2}return r}(new cr(2*n),t),null===t){if(!$e(n))throw new RangeError(F("invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.",n));t=new cr(arguments[0])}}else{if(ze(t))t=rt(t,0);else if(Je(t))t=et(t,0);else if(!$e(n))throw new RangeError(F("invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.",n));t=new cr(t)}else if(pe(arguments[0])){if(!re((t=arguments[0]).byteLength/pt))throw new RangeError(F("invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.",pt,t.byteLength));t=new cr(t)}else{if(!me(arguments[0]))throw new TypeError(F("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.",arguments[0]));if(t=arguments[0],!1===mt)throw new TypeError(F("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.",t));if(!Ce(t[qe]))throw new TypeError(F("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.",t));if(!Ce((t=t[qe]()).next))throw new TypeError(F("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.",t));if((t=ct(t))instanceof Error)throw t;t=new cr(t)}else{if(!pe(t=arguments[0]))throw new TypeError(F("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",t));if(!oe(r=arguments[1]))throw new TypeError(F("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",r));if(!re(r/pt))throw new RangeError(F("invalid argument. Byte offset must be a multiple of %u. Value: `%u`.",pt,r));if(2===e){if(!re((n=t.byteLength-r)/pt))throw new RangeError(F("invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.",pt,n));t=new cr(t,r)}else{if(!oe(n=arguments[2]))throw new TypeError(F("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));if(n*pt>t.byteLength-r)throw new RangeError(F("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*pt));t=new cr(t,r,2*n)}}return U(this,"_buffer",t),U(this,"_length",t.length/2),this}U(vt,"BYTES_PER_ELEMENT",pt),U(vt,"name","Complex128Array"),U(vt,"from",(function(r){var e,t,n,i,o,a,u,f,l,s,h,c;if(!Ce(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!gt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((t=arguments.length)>1){if(!Ce(n=arguments[1]))throw new TypeError(F("invalid argument. Second argument must be a function. Value: `%s`.",n));t>2&&(e=arguments[2])}if(yt(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,c=0,h=0;h<f;h++){if(We(s=n.call(e,r.get(h),h)))o[c]=st(s),o[c+1]=ht(s);else{if(!(le(s)&&s.length>=2))throw new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[c]=s[0],o[c+1]=s[1]}c+=2}return i}return new this(r)}if(he(r)){if(n){for(f=r.length,u=r.get&&r.set?z("default"):J("default"),h=0;h<f;h++)if(!We(u(r,h))){l=!0;break}if(l){if(!$e(f))throw new RangeError(F("invalid argument. First argument must have a length which is a multiple of two. Length: `%u`.",f));for(o=(i=new this(f/2))._buffer,h=0;h<f;h++)o[h]=n.call(e,u(r,h),h);return i}for(o=(i=new this(f))._buffer,c=0,h=0;h<f;h++){if(We(s=n.call(e,u(r,h),h)))o[c]=st(s),o[c+1]=ht(s);else{if(!(le(s)&&s.length>=2))throw new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[c]=s[0],o[c+1]=s[1]}c+=2}return i}return new this(r)}if(me(r)&&mt&&Ce(r[qe])){if(!Ce((o=r[qe]()).next))throw new TypeError(F("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,e,t){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,le(o=e.call(t,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!We(o))return new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(st(o),ht(o))}return n}(o,n,e):ct(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,h=0;h<f;h++)o[h]=a[h];return i}throw new TypeError(F("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r))})),U(vt,"of",(function(){var r,e;if(!Ce(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!gt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(r=[],e=0;e<arguments.length;e++)r.push(arguments[e]);return new this(r)})),U(vt.prototype,"at",(function(r){if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!re(r))throw new TypeError(F("invalid argument. Must provide an integer. Value: `%s`.",r));if(r<0&&(r+=this._length),!(r<0||r>=this._length))return wt(this._buffer,r)})),De(vt.prototype,"buffer",(function(){return this._buffer.buffer})),De(vt.prototype,"byteLength",(function(){return this._buffer.byteLength})),De(vt.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(vt.prototype,"BYTES_PER_ELEMENT",vt.BYTES_PER_ELEMENT),U(vt.prototype,"copyWithin",(function(r,e){if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*e):this._buffer.copyWithin(2*r,2*e,2*arguments[2]),this})),U(vt.prototype,"entries",(function(){var r,e,t,n,i,o,a;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return e=this,r=this._buffer,n=this._length,o=-1,a=-2,U(t={},"next",(function(){var e;if(o+=1,i||o>=n)return{done:!0};return e=new lt(r[a+=2],r[a+1]),{value:[o,e],done:!1}})),U(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),qe&&U(t,qe,(function(){return e.entries()})),t})),U(vt.prototype,"every",(function(r,e){var t,n;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(!r.call(e,wt(t,n),n,this))return!1;return!0})),U(vt.prototype,"fill",(function(r,e,t){var n,i,o,a,u,f;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(n=this._buffer,i=this._length,arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));if(e<0&&(e+=i)<0&&(e=0),arguments.length>2){if(!re(t))throw new TypeError(F("invalid argument. Third argument must be an integer. Value: `%s`.",t));t<0&&(t+=i)<0&&(t=0),t>i&&(t=i)}else t=i}else e=0,t=i;for(a=st(r),u=ht(r),f=e;f<t;f++)n[o=2*f]=a,n[o+1]=u;return this})),U(vt.prototype,"filter",(function(r,e){var t,n,i,o;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=[],i=0;i<this._length;i++)o=wt(t,i),r.call(e,o,i,this)&&n.push(o);return new this.constructor(n)})),U(vt.prototype,"find",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(i=wt(t,n),r.call(e,i,n,this))return i})),U(vt.prototype,"findIndex",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(i=wt(t,n),r.call(e,i,n,this))return n;return-1})),U(vt.prototype,"findLast",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=this._length-1;n>=0;n--)if(i=wt(t,n),r.call(e,i,n,this))return i})),U(vt.prototype,"findLastIndex",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=this._length-1;n>=0;n--)if(i=wt(t,n),r.call(e,i,n,this))return n;return-1})),U(vt.prototype,"forEach",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)i=wt(t,n),r.call(e,i,n,this)})),U(vt.prototype,"get",(function(r){if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!oe(r))throw new TypeError(F("invalid argument. Must provide a nonnegative integer. Value: `%s`.",r));if(!(r>=this._length))return wt(this._buffer,r)})),De(vt.prototype,"length",(function(){return this._length})),U(vt.prototype,"includes",(function(r,e){var t,n,i,o,a;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(i=st(r),o=ht(r),t=this._buffer,a=e;a<this._length;a++)if(i===t[n=2*a]&&o===t[n+1])return!0;return!1})),U(vt.prototype,"indexOf",(function(r,e){var t,n,i,o,a;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(i=st(r),o=ht(r),t=this._buffer,a=e;a<this._length;a++)if(i===t[n=2*a]&&o===t[n+1])return a;return-1})),U(vt.prototype,"join",(function(r){var e,t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=",";else{if(!be(r))throw new TypeError(F("invalid argument. First argument must be a string. Value: `%s`.",r));n=r}for(e=[],t=this._buffer,i=0;i<this._length;i++)e.push(wt(t,i).toString());return e.join(n)})),U(vt.prototype,"lastIndexOf",(function(r,e){var t,n,i,o,a;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!We(r))throw new TypeError(F("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e>=this._length?e=this._length-1:e<0&&(e+=this._length)}else e=this._length-1;for(i=st(r),o=ht(r),t=this._buffer,a=e;a>=0;a--)if(i===t[n=2*a]&&o===t[n+1])return a;return-1})),U(vt.prototype,"map",(function(r,e){var t,n,i,o,a;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,t=(i=new this.constructor(this._length))._buffer,o=0;o<this._length;o++)if(We(a=r.call(e,wt(n,o),o,this)))t[2*o]=st(a),t[2*o+1]=ht(a);else{if(!le(a)||2!==a.length)throw new TypeError(F("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",a));t[2*o]=a[0],t[2*o+1]=a[1]}return i})),U(vt.prototype,"reduce",(function(r,e){var t,n,i,o;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));if(t=this._buffer,i=this._length,arguments.length>1)n=e,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=wt(t,0),o=1}for(;o<i;o++)n=r(n,wt(t,o),o,this);return n})),U(vt.prototype,"reverse",(function(){var r,e,t,n,i,o;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(t=this._length,r=this._buffer,n=Qr(t/2),i=0;i<n;i++)o=t-i-1,e=r[2*i],r[2*i]=r[2*o],r[2*o]=e,e=r[2*i+1],r[2*i+1]=r[2*o+1],r[2*o+1]=e;return this})),U(vt.prototype,"set",(function(r){var e,t,n,i,o,a,u,f,l;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(n=this._buffer,arguments.length>1){if(!oe(t=arguments[1]))throw new TypeError(F("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",t))}else t=0;if(We(r)){if(t>=this._length)throw new RangeError(F("invalid argument. Index argument is out-of-bounds. Value: `%u`.",t));return n[t*=2]=st(r),void(n[t+1]=ht(r))}if(yt(r)){if(t+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r._buffer,l=n.byteOffset+t*pt,e.buffer===n.buffer&&e.byteOffset<l&&e.byteOffset+e.byteLength>l){for(i=new cr(e.length),f=0;f<e.length;f++)i[f]=e[f];e=i}for(t*=2,l=0,f=0;f<a;f++)n[t]=e[l],n[t+1]=e[l+1],t+=2,l+=2}else{if(!he(r))throw new TypeError(F("invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.",r));for(a=r.length,f=0;f<a;f++)if(!We(r[f])){o=!0;break}if(o){if(!$e(a))throw new RangeError(F("invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.",a));if(t+a/2>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r,l=n.byteOffset+t*pt,e.buffer===n.buffer&&e.byteOffset<l&&e.byteOffset+e.byteLength>l){for(i=new cr(a),f=0;f<a;f++)i[f]=e[f];e=i}for(t*=2,a/=2,l=0,f=0;f<a;f++)n[t]=e[l],n[t+1]=e[l+1],t+=2,l+=2;return}if(t+a>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(t*=2,f=0;f<a;f++)u=r[f],n[t]=st(u),n[t+1]=ht(u),t+=2}})),U(vt.prototype,"slice",(function(r,e){var t,n,i,o,a,u,f;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(a=this._buffer,u=this._length,0===arguments.length)r=0,e=u;else{if(!re(r))throw new TypeError(F("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=u)<0&&(r=0),1===arguments.length)e=u;else{if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0?(e+=u)<0&&(e=0):e>u&&(e=u)}}for(t=r<e?e-r:0,n=(i=new this.constructor(t))._buffer,f=0;f<t;f++)o=2*(f+r),n[2*f]=a[o],n[2*f+1]=a[o+1];return i})),U(vt.prototype,"some",(function(r,e){var t,n;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Ce(r))throw new TypeError(F("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n<this._length;n++)if(r.call(e,wt(t,n),n,this))return!0;return!1})),U(vt.prototype,"subarray",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(n=this._buffer,i=this._length,0===arguments.length)r=0,e=i;else{if(!re(r))throw new TypeError(F("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=i)<0&&(r=0),1===arguments.length)e=i;else{if(!re(e))throw new TypeError(F("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0?(e+=i)<0&&(e=0):e>i&&(e=i)}}return r>=i?(i=0,t=n.byteLength):r>=e?(i=0,t=n.byteOffset+r*pt):(i=e-r,t=n.byteOffset+r*pt),new this.constructor(n.buffer,t,i<0?0:i)})),U(vt.prototype,"toReversed",(function(){var r,e,t,n,i,o;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(t=this._length,e=new this.constructor(t),n=this._buffer,r=e._buffer,i=0;i<t;i++)o=t-i-1,r[2*i]=n[2*o],r[2*i+1]=n[2*o+1];return e})),U(vt.prototype,"toString",(function(){var r,e,t;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(r=[],e=this._buffer,t=0;t<this._length;t++)r.push(wt(e,t).toString());return r.join(",")})),U(vt.prototype,"with",(function(r,e){var t,n,i;if(!yt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!re(r))throw new TypeError(F("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(F("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!We(e))throw new TypeError(F("invalid argument. Second argument must be a complex number. Value: `%s`.",e));return(t=(n=new this.constructor(this._buffer))._buffer)[2*r]=st(e),t[2*r+1]=ht(e),n}));var bt=[cr,wr,Ar,Er,Ir,Fr,zr,Mr,Yr,ft,vt],dt=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128"],Et=dt.length;function _t(r){var e;if(tr(r))return"generic";if(ir(r))return null;for(e=0;e<Et;e++)if(r instanceof bt[e])return dt[e];return fr[ur(r)]||null}function Tt(r){var e,t,n;if(!he(r))throw new TypeError(F("invalid argument. Must provide an array-like object. Value: `%s`.",r));return n=_t(r),$(r)&&(e=z(n)),t=r.length,void 0===e?function(e){var n;for(n=0;n<t;n++)if(r[n]===e)return!0;return!1}:function(n){var i;for(i=0;i<t;i++)if(e(r,i)===n)return!0;return!1}}U((function(r,e){var t,n,i,o;for(i=_t(r),n=$(r)?z(i):J(i),t=r.length,o=0;o<t;o++)if(n(r,o)===e)return!0;return!1}),"factory",Tt);var xt=["throw","normalize","clamp","wrap"];function At(){return xt.slice()}U(At,"enum",(function(){return{throw:1,clamp:2,wrap:3,normalize:4}}));var Vt=Tt(At());function jt(){var r,e=arguments,t="https://stdlib.io/e/"+e[0]+"?";for(r=1;r<e.length;r++)t+="&arg[]="+encodeURIComponent(e[r]);return t}var St={wrap:P,clamp:N,normalize:function(r,e){var t=Y(r,e);if(t<0||t>e)throw new RangeError(jt("0ilFB",e,r));return t},throw:function(r,e){if(r<0||r>e)throw new RangeError(jt("0ilFB",e,r));return r}};function Ft(r){if(!Vt(r))throw new TypeError(jt("0ilFC",r));return St[r]}function kt(r,e,t){var n;if("clamp"===t)return N(r,e);if("wrap"===t)return P(r,e);if(n=r,"normalize"===t&&(n=Y(n,e)),n<0||n>e)throw new RangeError(jt("0ilFB",e,r));return n}U(kt,"factory",Ft);export{kt as default,Ft as factory};
//# sourceMappingURL=mod.js.map