UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

2 lines 91.2 kB
/*! For license information please see TinyBasicsEs.min.js.LICENSE.txt */ (()=>{var t={251:(t,e)=>{e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,l=(1<<a)-1,c=l>>1,u=-7,f=r?o-1:0,p=r?-1:1,h=t[e+f];for(f+=p,i=h&(1<<-u)-1,h>>=-u,u+=a;u>0;i=256*i+t[e+f],f+=p,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=n;u>0;s=256*s+t[e+f],f+=p,u-=8);if(0===i)i=1-c;else{if(i===l)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=c}return(h?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,l,c=8*i-o-1,u=(1<<c)-1,f=u>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,m=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+f>=1?p/l:p*Math.pow(2,1-f))*l>=2&&(s++,l/=2),s+f>=u?(a=0,s=u):s+f>=1?(a=(e*l-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+h]=255&a,h+=m,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[r+h]=255&s,h+=m,s/=256,c-=8);t[r+h-m]|=128*d}},287:(t,e,r)=>{"use strict";var n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=l,e.IS=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=a(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(U(t,Uint8Array)){var e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(U(t,ArrayBuffer)||t&&U(t.buffer,ArrayBuffer))return h(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(U(t,SharedArrayBuffer)||t&&U(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return l.from(n,e,r);var o=function(t){if(l.isBuffer(t)){var e=0|m(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||j(t.length)?a(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return u(t),a(t<0?0:0|m(t))}function p(t){for(var e=t.length<0?0:0|m(t.length),r=a(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function h(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,l.prototype),n}function m(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function d(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||U(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:D(t).length;e=(""+e).toLowerCase(),o=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return N(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),j(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){var i,s=1,a=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,l/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var u=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===l)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(r+l>a&&(r=a-l),i=r;i>=0;i--){for(var f=!0,p=0;p<l;p++)if(c(t,i+p)!==c(e,p)){f=!1;break}if(f)return i}return-1}function E(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(j(a))return s;t[r+s]=a}return s}function v(t,e,r,n){return O(D(e,t.length-r),t,r,n)}function T(t,e,r,n){return O(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function A(t,e,r,n){return O(F(e),t,r,n)}function C(t,e,r,n){return O(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,l,c=t[o],u=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(u=c);break;case 2:128==(192&(i=t[o+1]))&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(l=(15&c)<<12|(63&i)<<6|63&s)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(l=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(u=l)}null===u?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),o+=f}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=_));return r}(n)}l.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},l.allocUnsafe=function(t){return f(t)},l.allocUnsafeSlow=function(t){return f(t)},l.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==l.prototype},l.compare=function(t,e){if(U(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),U(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(t)||!l.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},l.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=l.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(U(i,Uint8Array))o+i.length>n.length?l.from(i).copy(n,o):Uint8Array.prototype.set.call(n,i,o);else{if(!l.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},l.byteLength=d,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},l.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},l.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},l.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(l.prototype[i]=l.prototype.inspect),l.prototype.compare=function(t,e,r,n,o){if(U(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),c=this.slice(n,o),u=t.slice(e,r),f=0;f<a;++f)if(c[f]!==u[f]){i=c[f],s=u[f];break}return i<s?-1:s<i?1:0},l.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},l.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},l.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},l.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return v(this,t,e,r);case"ascii":case"latin1":case"binary":return T(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function L(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function N(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function B(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=V[t[i]];return o}function k(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function W(t,e,r,n,o,i){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function M(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||M(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||M(t,0,r,8),o.write(t,e,r,n,52,8),r+8}l.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,l.prototype),n},l.prototype.readUintLE=l.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},l.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},l.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||W(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||W(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);W(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},l.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);W(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},l.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||W(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},l.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},l.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},l.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},l.prototype.copy=function(t,e,r,n){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},l.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=l.isBuffer(t)?t:l.from(t,n),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var H=/[^+/0-9A-Za-z-_]/g;function D(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function U(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function j(t){return t!=t}var V=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()},526:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=a(t),s=i[0],l=i[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,l)),u=0,f=l>0?s-4:s;for(r=0;r<f;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[u++]=e>>16&255,c[u++]=e>>8&255,c[u++]=255&e;return 2===l&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[u++]=255&e),1===l&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],s=16383,a=0,l=n-o;a<l;a+=s)i.push(c(t,a,a+s>l?l:a+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function l(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function c(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),o.push(l(n));return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{addAiMarkerShortcut:()=>xt,areElsCollBottom:()=>v,areElsCollLeft:()=>T,areElsCollPerfBottom:()=>S,areElsCollPerfLeft:()=>x,areElsCollPerfRight:()=>_,areElsCollPerfTop:()=>C,areElsCollRight:()=>A,areElsCollTop:()=>E,areElsColliding:()=>L,areElsPerfColliding:()=>N,areHtmlElsColliding:()=>J,arraySortPositions:()=>e,asyncReplace:()=>o,cloneObjTypeOrder:()=>at,countObj:()=>u,documentIsFullScreen:()=>ut,exitFullScreen:()=>mt,extendObjType:()=>it,fetchJson:()=>y,fetchText:()=>w,formatBytes:()=>Tt,formatCustomTimer:()=>a,formatDayTimer:()=>c,formatTimer:()=>l,genFibonacciSeq:()=>At,getAge:()=>vt,getElsCollDetails:()=>H,getElsCollDirDepth:()=>I,getElsCollOverlap:()=>P,getElsCollOverlapPos:()=>W,getElsColliding:()=>B,getElsPerfColliding:()=>k,getElsRelativeCenterOffset:()=>R,getHtmlElBorders:()=>G,getHtmlElBordersWidth:()=>K,getHtmlElMargin:()=>Q,getHtmlElPadding:()=>Z,getPercentage:()=>Et,getRectCenter:()=>M,getSimplePerc:()=>bt,getTimeDuration:()=>s,installWindowHiddenScript:()=>b,isFullScreenMode:()=>pt,isInViewport:()=>tt,isJsonObject:()=>f,isScreenFilled:()=>ft,isScrolledIntoView:()=>et,objType:()=>ct,offFullScreenChange:()=>yt,onFullScreenChange:()=>gt,readBase64Blob:()=>h,readFileBlob:()=>p,readJsonBlob:()=>m,reorderObjTypeOrder:()=>st,requestFullScreen:()=>ht,ruleOfThree:()=>wt,safeTextTrim:()=>_t,saveJsonFile:()=>d,shuffleArray:()=>i,toTitleCase:()=>Ct,toTitleCaseLowerFirst:()=>St});var t={};function e(t,e=!1){return e?function(e,r){return e[t]>r[t]?-1:e[t]<r[t]?1:0}:function(e,r){return e[t]<r[t]?-1:e[t]>r[t]?1:0}}async function o(t,e,r){const n=[];t.replace(e,(t,...e)=>(n.push(r(t,...e)),t));const o=await Promise.all(n);return t.replace(e,()=>o.shift())}function i(t){let e,r=t.length;for(;0!==r;)e=Math.floor(Math.random()*r),r--,[t[r],t[e]]=[t[e],t[r]];return t}function s(t=new Date,e="asSeconds",r=null){if(t instanceof Date){const n=r instanceof Date?r:new Date,o=t.getTime()-n.getTime();switch(e){case"asMilliseconds":return o;case"asSeconds":default:return o/1e3;case"asMinutes":return o/6e4;case"asHours":return o/36e5;case"asDays":return o/864e5}}return null}function a(t,e="seconds",r="{time}"){t=Math.max(0,Math.floor(t));const n=["seconds","minutes","hours","days","months","years"].indexOf(e),o=n>=5,i=n>=4,s=n>=3,a=n>=2,l=n>=1,c=n>=0,u={years:o?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:c?0:NaN,total:NaN};let f=t;if(o||i||s){const t=new Date(1980,0,1),e=new Date(t.getTime()+1e3*f),r=new Date(t);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=e.getTime();)r.setFullYear(r.getFullYear()+1),u.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=e.getTime();)r.setMonth(r.getMonth()+1),u.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),u.days++;f=Math.floor((e.getTime()-r.getTime())/1e3)}a&&(u.hours=Math.floor(f/3600),f%=3600),l&&(u.minutes=Math.floor(f/60),f%=60),c&&(u.seconds=f);const p={seconds:c?t:NaN,minutes:l?t/60:NaN,hours:a?t/3600:NaN,days:s?t/86400:NaN,months:i?12*u.years+u.months+(u.days||0)/30:NaN,years:o?u.years+(u.months||0)/12+(u.days||0)/365:NaN};u.total=+(p[e]||0).toFixed(2).replace(/\.00$/,"");const h=t=>{const e="string"==typeof t?parseInt(t):t;return Number.isNaN(e)?"NaN":String(e).padStart(2,"0")},m=[a?h(u.hours):null,l?h(u.minutes):null,c?h(u.seconds):null].filter(t=>null!==t).join(":");return r.replace(/\{years\}/g,String(u.years)).replace(/\{months\}/g,String(u.months)).replace(/\{days\}/g,String(u.days)).replace(/\{hours\}/g,h(u.hours)).replace(/\{minutes\}/g,h(u.minutes)).replace(/\{seconds\}/g,h(u.seconds)).replace(/\{time\}/g,m).replace(/\{total\}/g,String(u.total)).trim()}function l(t){return a(t,"hours","{hours}:{minutes}:{seconds}")}function c(t){return a(t,"days","{days}d {hours}:{minutes}:{seconds}")}function u(t){return Array.isArray(t)?t.length:f(t)?Object.keys(t).length:0}function f(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t)}function p(t,e){return new Promise((r,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(t){n(t)}},o.onerror=()=>{n(o.error)},o[e](t)})}function h(t,e=!1){return new Promise((r,n)=>{"string"!=typeof e&&"boolean"!=typeof e&&n(new TypeError("The isDataUrl parameter must be a boolean or a string.")),p(t,"readAsDataURL").then(t=>{if("string"!=typeof t)throw new TypeError("Expected file content to be a string.");const n=t.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,o,i]=n;if(!/^[\w/+]+=*$/.test(i))throw new Error("Base64 content is malformed.");if("boolean"==typeof e)return r(e?t:i);if(!/^[\w-]+\/[\w.+-]+$/.test(e))throw new Error(`Invalid MIME type string: ${e}`);return r(`data:${e};base64,${i}`)}).catch(n)})}function m(t){return new Promise((e,r)=>p(t,"readAsText").then(t=>{if("string"!=typeof t)throw new TypeError("Expected file content to be a string.");const r=t.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");e(n)}).catch(r))}function d(t,e,r=2){const n=JSON.stringify(e,null,r),o=new Blob([n],{type:"application/json"}),i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}async function g(t,{method:e="GET",body:r,timeout:n=0,retries:o=0,headers:i={},signal:s=null}={}){if("string"!=typeof t||!t.startsWith("../")&&!t.startsWith("./")&&!t.startsWith("/")&&!t.startsWith("https://")&&!t.startsWith("http://"))throw new Error("Invalid URL: must be a valid http or https address.");if("string"!=typeof e||!e.trim())throw new Error("Invalid method: must be a non-empty string.");if(!s){if("number"!=typeof n||!Number.isFinite(n)||Number.isNaN(n)||n<0)throw new Error("Invalid timeout: must be a positive number.");if("number"!=typeof o||!Number.isFinite(o)||Number.isNaN(o)||o<0)throw new Error("Invalid retries: must be a positive number.")}const a=s?1:o+1;let l=null;for(let c=0;c<a;c++){const a=s?null:new AbortController,u=s||(a?.signal??null),p=!s&&n&&a?setTimeout(()=>a.abort(),n):null;try{const n=await fetch(t,{method:e.toUpperCase(),headers:{Accept:"application/json",...i},body:void 0!==r?f(r)?JSON.stringify(r):r:void 0,signal:u});if(p&&clearTimeout(p),!n.ok)throw new Error(`HTTP error: ${n.status} ${n.statusText}`);return n}catch(t){if(l=t,s)break;c<o&&await new Promise(t=>setTimeout(t,300*(c+1)))}}throw new Error(`Failed to fetch JSON from "${t}"${l?`: ${l.message}`:"."}`)}async function y(t,e){return new Promise((r,n)=>{g(t,e).then(async t=>{const e=t.headers.get("content-type")||"";if(!e.includes("application/json"))throw new Error(`Unexpected content-type: ${e}`);const n=await t.json();if(!Array.isArray(n)&&!f(n))throw new Error("Received invalid data instead of valid JSON.");return r(n)}).catch(n)})}async function w(t,e,r){return new Promise((n,o)=>{g(t,r).then(async t=>{const r=t.headers.get("content-type")||"";if(Array.isArray(e)&&e.length>0&&!e.some(t=>r.includes(t)))throw new Error(`Blocked MIME type: ${r}`);const o=await t.text();return n(o)}).catch(o)})}function b({element:t=document.body,hiddenClass:e="windowHidden",visibleClass:r="windowVisible",onVisible:n,onHidden:o}={}){if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof e)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof r)throw new TypeError('"visibleClass" must be a string.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==o&&"function"!=typeof o)throw new TypeError('"onHidden" must be a function if provided.');let i="",s="";const a=()=>{t.classList.remove(e),t.classList.remove(r)};let l=null;const c=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],u=["hidden","mozHidden","webkitHidden","msHidden"];for(let t=0;t<u.length;t++)if(u[t]in document){l=u[t];break}const f=function(c){a();const u=c?.type,f=l&&document[l];["focus","focusin","pageshow"].includes(u)?(t.classList.add(r),n?.({type:u,oldClass:s,oldType:i}),s=r):["blur","focusout","pagehide"].includes(u)||f?(t.classList.add(e),o?.({type:u,oldClass:s,oldType:i}),s=e):(t.classList.add(r),n?.({type:u,oldClass:s,oldType:i}),s=r),i=u};let p=()=>{};if(l){const t=c[u.indexOf(l)];document.addEventListener(t,f),window.addEventListener("focus",f),window.addEventListener("blur",f),p=()=>{document.removeEventListener(t,f),window.removeEventListener("focus",f),window.removeEventListener("blur",f),a()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=f,p=()=>{document.onfocusin=document.onfocusout=null,a()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=f,p=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,a()});const h=new Event(l&&document[l]?"blur":"focus");return f(h),p}r.r(t),r.d(t,{areElsCollBottom:()=>v,areElsCollLeft:()=>T,areElsCollPerfBottom:()=>S,areElsCollPerfLeft:()=>x,areElsCollPerfRight:()=>_,areElsCollPerfTop:()=>C,areElsCollRight:()=>A,areElsCollTop:()=>E,areElsColliding:()=>L,areElsPerfColliding:()=>N,getElsCollDetails:()=>H,getElsCollDirDepth:()=>I,getElsCollOverlap:()=>P,getElsCollOverlapPos:()=>W,getElsColliding:()=>B,getElsPerfColliding:()=>k,getElsRelativeCenterOffset:()=>R,getRectCenter:()=>M});const E=(t,e)=>t.bottom<e.top,v=(t,e)=>t.top>e.bottom,T=(t,e)=>t.right<e.left,A=(t,e)=>t.left>e.right,C=(t,e)=>t.bottom<=e.top,S=(t,e)=>t.top>=e.bottom,x=(t,e)=>t.right<=e.left,_=(t,e)=>t.left>=e.right,L=(t,e)=>!(T(t,e)||A(t,e)||E(t,e)||v(t,e)),N=(t,e)=>!(x(t,e)||_(t,e)||C(t,e)||S(t,e)),B=(t,e)=>T(t,e)?"left":A(t,e)?"right":E(t,e)?"top":v(t,e)?"bottom":null,k=(t,e)=>x(t,e)?"left":_(t,e)?"right":C(t,e)?"top":S(t,e)?"bottom":null,P=(t,e)=>({overlapLeft:e.right-t.left,overlapRight:t.right-e.left,overlapTop:e.bottom-t.top,overlapBottom:t.bottom-e.top}),W=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:t<e?"right":"left",dirY:r<n?"bottom":"top"}),M=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function R(t,e){const r=t.left+t.width/2,n=t.top+t.height/2;return{x:e.left+e.width/2-r,y:e.top+e.height/2-n}}function I(t,e){if(!N(t,e))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}=P(t,e),{dirX:s,dirY:a}=W({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}),l=Math.min(r,n),c=Math.min(o,i);let u;return u=l<c?s:a,{inDir:u,dirX:s,dirY:a,depthX:l,depthY:c}}function H(t,e){const r=N(t,e),n={in:null,x:null,y:null},o={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:a,overlapTop:l,overlapBottom:c}=P(e,t);i.top=l,i.bottom=c,i.left=s,i.right=a;const u=Object.entries(i).filter(([,t])=>t>0).sort((t,e)=>t[1]-e[1]),{dirX:f,dirY:p}=W({overlapLeft:a,overlapRight:s,overlapTop:c,overlapBottom:l});return n.y=p,n.x=f,i.bottom<0?o.y="bottom":i.top<0&&(o.y="top"),i.left<0?o.x="left":i.right<0&&(o.x="right"),n.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":u.length?u[0][0]:"top":null,{dirs:n,depth:i,isNeg:o}}const{areElsColliding:D,areElsPerfColliding:F,areElsCollTop:O,areElsCollBottom:U,areElsCollLeft:j,areElsCollRight:V}=t,$=new WeakMap,Y=new WeakMap,z={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class q{static Utils={...t};static async fetchHtmlFile(t,e={method:"GET"}){const r=await fetch(t,e),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const o=await r.text();return q.htmlToJson(o)}static async fetchHtmlNodes(t,e){const r=await q.fetchHtmlFile(t,e);return q.jsonToNodes(r)}static async fetchHtmlTinyElems(t,e){const r=await q.fetchHtmlNodes(t,e);return q.toTinyElm(r)}static templateToJson(t){return q.htmlToJson([...t.content.childNodes].map(t=>t instanceof Element?t.getHTML():t instanceof Text?t.textContent:"").join(""))}static templateToNodes(t){const e=[];return[...t.content.cloneNode(!0).childNodes].map(t=>{if(!(t instanceof Element||t instanceof Text||t instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${t.constructor.name}`);t instanceof Comment||e.push(t)}),e}static templateToTinyElems(t){return q.toTinyElm(q.templateToNodes(t))}static htmlToJson(t){const e=document.createElement("div");e.innerHTML=t.trim();const r=[],n=t=>{if(t instanceof Comment)return null;if(t instanceof Text){const e=t.textContent?.trim();return e||null}if(!(t instanceof Element))return null;const e=t.tagName.toLowerCase(),r={};for(const e of t.attributes)r[q.getPropName(e.name)]=e.value;const o=Array.from(t.childNodes).map(n).filter(Boolean);return o.length>0?[e,r,...o]:[e,r]};for(const t of e.childNodes){const e=n(t);e&&r.push(e)}return e.innerHTML="",r}static jsonToNodes(t){const e=t=>{if("string"==typeof t)return document.createTextNode(t);if(!Array.isArray(t))return document.createTextNode("");const[r,n,...o]=t,i=document.createElement(r);for(const[t,e]of Object.entries(n))i.setAttribute(q.getAttrName(t),e);for(const t of o){const r=e(t);r instanceof Comment||i.appendChild(r)}return i};return t.map(e).filter(t=>!(t instanceof Comment))}static jsonToTinyElems(t){return q.toTinyElm(q.jsonToNodes(t))}static createFrom(t,e){if("string"!=typeof t)throw new TypeError('The "tagName" must be a string.');if(void 0!==e&&"object"!=typeof e)throw new TypeError('The "attrs" must be a object.');const r=q.createElement(t);if("object"==typeof e)for(const t in e)r.setAttr(t,e[t]);return r}static createElement(t,e){if("string"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==e&&"object"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new q(document.createElement(t,e))}static createTextNode(t){if("string"!=typeof t)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new q(document.createTextNode(t))}static createElementFromHTML(t){const e=document.createElement("template");if(!(t=t.trim()).startsWith("<"))return q.createTextNode(t);if(e.innerHTML=t,!(e.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new q(e.content.firstChild)}static query(t,e=document){const r=e.querySelector(t);return r?new q(r):null}querySelector(t){return q.query(t,q._preElem(this,"query"))}static queryAll(t,e=document){return new q(e.querySelectorAll(t))}querySelectorAll(t){return q.queryAll(t,q._preElem(this,"queryAll"))}static getById(t){const e=document.getElementById(t);return e?new q(e):null}static getByClassName(t,e=document){return new q(e.getElementsByClassName(t))}getElementsByClassName(t){return q.getByClassName(t,q._preElem(this,"getByClassName"))}static getByName(t){return new q(document.getElementsByName(t))}static getByTagNameNS(t,e="http://www.w3.org/1999/xhtml",r=document){return new q(r.getElementsByTagNameNS(e,t))}getElementsByTagNameNS(t,e="http://www.w3.org/1999/xhtml"){return q.getByTagNameNS(t,e,q._preElem(this,"getByTagNameNS"))}get(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");if(!this.#t[t])throw new Error(`No element found at index ${t}.`);return this.#t[t]}extract(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");if(!this.#t[t])throw new Error(`Cannot extract: no element exists at index ${t}.`);return new q(this.#t[t])}exists(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");return!!this.#t[t]}getAll(){return[...this.#t]}_getElement(t,e){if(!(this.#t[e]instanceof Element||this.#t[e]instanceof Window||this.#t[e]instanceof Document||this.#t[e]instanceof Text))throw new Error(`[TinyHtml] Invalid Element in ${t}().`);return this.#t[e]}_getElements(t){if(!this.#t.every(t=>t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error(`[TinyHtml] Invalid Element in ${t}().`);return[...this.#t]}static _preElemsTemplate(t,e,r,n){const o=t=>{const o=[];return t.map(t=>(t instanceof q?t._getElements(e):[t]).map(t=>{let i=!1;for(const e of r)if(t instanceof e){i=!0;break}if(!i)throw new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${e}().`);return o.push(t),t})),o};return Array.isArray(t)?o(t):o([t])}static _preElemTemplate(t,e,r,n,o=!1){const i=t=>{const i=t[0],s=i instanceof q?i._getElements(e):[i];if(s.length>1)throw new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${s.length}/1).`);let a=!1;for(const t of r)if(s[0]instanceof t){a=!0;break}if(!o||null!==s[0]&&void 0!==s[0]||(s[0]=null,a=!0),!a)throw new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${e}().`);return s[0]};if(!Array.isArray(t))return i([t]);if(t.length>1)throw new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${t.length}/1).`);return i(t)}static _preElems(t,e){return q._preElemsTemplate(t,e,[Element],["Element"])}static _preElem(t,e){return q._preElemTemplate(t,e,[Element],["Element"])}static _preNodeElems(t,e){return q._preElemsTemplate(t,e,[Node],["Node"])}static _preNodeElem(t,e){return q._preElemTemplate(t,e,[Node],["Node"])}static _preNodeElemWithNull(t,e){return q._preElemTemplate(t,e,[Node],["Node"],!0)}static _preHtmlElems(t,e){return q._preElemsTemplate(t,e,[HTMLElement],["HTMLElement"])}static _preHtmlElem(t,e){return q._preElemTemplate(t,e,[HTMLElement],["HTMLElement"])}static _preInputElems(t,e){return q._preElemsTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preInputElem(t,e){return q._preElemTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preEventTargetElems(t,e){return q._preElemsTemplate(t,e,[EventTarget],["EventTarget"])}static _preEventTargetElem(t,e){return q._preElemTemplate(t,e,[EventTarget],["EventTarget"])}static _preElemsAndWindow(t,e){return q._preElemsTemplate(t,e,[Element,Window],["Element","Window"])}static _preElemAndWindow(t,e){return q._preElemTemplate(t,e,[Element,Window],["Element","Window"])}static _preElemsAndWinAndDoc(t,e){return q._preElemsTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]).map(t=>t instanceof Document?t.documentElement:t)}static _preElemAndWinAndDoc(t,e){const r=q._preElemTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}static _preElemsWithDoc(t,e){return q._preElemsTemplate(t,e,[Element,Document],["Element","Document"])}static _preElemWithDoc(t,e){return q._preElemTemplate(t,e,[Element,Document],["Element","Document"])}static toTinyElm(t){const e=t=>t.map(t=>t instanceof q?t:new q(t));return Array.isArray(t)?e(t):e([t])}static fromTinyElm(t){const e=t=>{const e=[];return t.map(t=>(t instanceof q?t._getElements("fromTinyElm"):[t]).map(t=>e.push(t))),e};return Array.isArray(t)?e(t):e([t])}static winnow(t,e,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof e)return q._preElems(t,r).filter((t,r)=>!!e.call(t,r,t)!==n);if(e instanceof Element)return q._preElems(t,r).filter(t=>t===e!==n);if(Array.isArray(e)||"string"!=typeof e&&null!=e.length)return q._preElems(t,r).filter(t=>e.includes(t)!==n);let o=e;return n&&(o=`:not(${o})`),q._preElems(t,r).filter(t=>1===t.nodeType&&t.matches(o))}static filter(t,e,r=!1){return r&&(e=`:not(${e})`),q._preElems(t,"filter").filter(t=>1===t.nodeType&&t.matches(e))}static filterOnly(t,e){return q.winnow(t,e,"filterOnly",!1)}static not(t,e){return q.winnow(t,e,"not",!0)}not(t){return q.not(this,t)}static find(t,e){const r=[];for(const n of q._preElems(t,"find"))r.push(...n.querySelectorAll(e));return[...new Set(r)]}find(t){return q.find(this,t)}static is(t,e){return q.winnow(t,e,"is",!1).length>0}is(t){return q.is(this,t)}static has(t,e){const r="string"==typeof e?[...document.querySelectorAll(e)]:q._preElems(e,"has");return q._preElems(t,"has").filter(t=>r.some(e=>t&&t.contains(e)))}has(t){return q.has(this,t).length>0}static closest(t,e,r){const n=[];for(const o of q._preElems(t,"closest")){let t=o;for(;t&&t!==r;){if(1===t.nodeType&&("string"==typeof e?t.matches(e):t===e)){n.push(t);break}t=t.parentElement}}return[...new Set(n)]}closest(t,e){return q.closest(this,t,e)}static isSameDom(t,e){return q._preNodeElem(t,"isSameDom")===q._preNodeElem(e,"isSameDom")}isSameDom(t){return q.isSameDom(this,t)}_data={};static _dataSelector={public:(t,e)=>{const r=q._preElem(e,t);let n=Y.get(r);return n||(n={},Y.set(r,n)),n},private:(t,e)=>{if(!(e instanceof q))throw new Error(`Element must be a TinyHtml instance to execute ${t}().`);return e._data}};static data(t,e,r=!1){const n=q._dataSelector[r?"private":"public"]("data",t);if(null==e)return{...n};if("string"!=typeof e)throw new TypeError("The key must be a string.");return n.hasOwnProperty(e)?n[e]:void 0}data(t,e){return q.data(this,t,e)}static setData(t,e,r,n=!1){const o=q._dataSelector[n?"private":"public"]("setData",t);if("string"!=typeof e)throw new TypeError("The key must be a string.");return o[e]=r,t}setData(t,e,r=!1){return q.setData(this,t,e,r)}static _getSibling(t,e,r){let n=q._preNodeElemWithNull(t,r);for(;n&&(n=n[e])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(t,e){let r=t;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==e&&n.push(r);return n}static domDir(t,e,r,n="domDir"){if("string"!=typeof e)throw new TypeError('The "direction" must be a string.');let o=q._preNodeElemWithNull(t,n);const i=[];for(;o&&(o=o[e]);)if(1===o.nodeType){if(r&&("string"==typeof r?o.matches(r):o===r))break;i.push(o)}return i}static parent(t){let e=q._preNodeElemWithNull(t,"parent");const r=e?e.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return q.parent(this)}static parents(t,e){return q.domDir(t,"parentNode",e,"parents")}parents(t){return q.parents(this,t)}static next(t){return q._getSibling(t,"nextSibling","next")}next(){return q.next(this)}static prev(t){return q._getSibling(t,"previousSibling","prev")}prev(){return q.prev(this)}static nextAll(t){return q.domDir(t,"nextSibling",void 0,"nextAll")}nextAll(){return q.nextAll(this)}static prevAll(t){return q.domDir(t,"previousSibling",void 0,"prevAll")}prevAll(){return q.prevAll(this)}static nextUntil(t,e){return q.domDir(t,"nextSibling",e,"nextUtil")}nextUntil(t){return q.nextUntil(this,t)}static prevUntil(t,e){return q.domDir(t,"previousSibling",e,"prevUtil")}prevUntil(t){return q.prevUntil(this,t)}static siblings(t){const e=q._preNodeElemWithNull(t,"siblings");return q._getSiblings(e&&e.parentNode?e.parentNode.firstChild:null,e)}siblings(){return q.siblings(this)}static children(t){const e=q._preNodeElemWithNull(t,"children");return q._getSiblings(e?e.firstChild:null)}children(){return q.children(this)}static contents(t){const e=q._preNodeElemWithNull(t,"contents");return e instanceof HTMLIFrameElement&&null!=e.contentDocument&&Object.getPrototypeOf(e.contentDocument)?[e.contentDocument]:e instanceof HTMLTemplateElement?Array.from((e.content||e).childNodes):e?Array.from(e.childNodes):[]}contents(){return q.contents(this)}static clone(t,e=!0){if("boolean"!=typeof e)throw new TypeError('The "deep" must be a boolean.');return q._preNodeElems(t,"clone").map(t=>t.cloneNode(e))}clone(t){return q.clone(this,t)[0]}static _appendChecker(t,...e){const r=[],n=[...e];for(const e in n)"string"!=typeof n[e]?r.push(q._preNodeElem(n[e],t)):r.push(n[e]);return r}static append(t,...e){return q._preElem(t,"append").append(...q._appendChecker("append",...e)),t}append(...t){return q.append(this,...t)}static prepend(t,...e){return q._preElem(t,"prepend").prepend(...q._appendChecker("prepend",...e)),t}prepend(...t){return q.prepend(this,...t)}static before(t,...e){return q._preElem(t,"before").before(...q._appendChecker("before",...e)),t}before(...t){return q.before(this,...t)}static after(t,...e){return q._preElem(t,"after").after(...q._appendChecker("after",...e)),t}after(...t){return q.after(this,...t)}static replaceWith(t,...e){return q._preElem(t,"replaceWith").replaceWith(...q._appendChecker("replaceWith",...e)),t}replaceWith(...t){return q.replaceWith(this,...t)}static appendTo(t,e){const r=q._preNodeElems(t,"appendTo"),n=q._preNodeElems(e,"appendTo");return n.forEach((t,e)=>{r.forEach(r=>t.appendChild(e===n.length-1?r:r.cloneNode(!0)))}),t}appendTo(t){return q.appendTo(this,t)}static prependTo(t,e){const r=q._preElems(t,"prependTo"),n=q._preElems(e,"prependTo");return n.forEach((t,e)=>{r.slice().reverse().forEach(r=>t.prepend(e===n.length-1?r:r.cloneNode(!0)))}),t}prependTo(t){return q.prependTo(this,t)}static insertBefore(t,e,r=null){const n=q._preNodeElem(t,"insertBefore"),o=q._preNodeElem(e,"insertBefore"),i=q._preNodeElemWithNull(r,"insertBefore");if(!o.parentNode)throw new Error("The target element has no parent node to insert before.");return o.parentNode.insertBefore(n,i||o),t}insertBefore(t,e){return q.insertBefore(this,t,e)}static insertAfter(t,e,r=null){const n=q._preNodeElem(t,"insertAfter"),o=q._preNodeElem(e,"insertBefore"),i=q._preNodeElemWithNull(r,"insertBefore");if(!o.parentNode)throw new Error("The target element has no parent node to insert after.");return o.parentNode.insertBefore(n,i||o.nextSibling),t}insertAfter(t,e){return q.insertAfter(this,t,e)}static replaceAll(t,e){const r=q._preNodeElems(t,"replaceAll"),n=q._preNodeElems(e,"replaceAll");return n.forEach((t,e)=>{const o=t.parentNode;r.forEach(r=>{o&&o.replaceChild(e===n.length-1?r:r.cloneNode(!0),t)})}),t}replaceAll(t){return q.replaceAll(this,t)}#t;get size(){return this.#t.length}constructor(t){if(t instanceof q)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const e=t=>{if(!t.every(t=>t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHt