raiutils 9.0.1 → 9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.d.ts CHANGED
@@ -80,7 +80,7 @@ export interface QueryMap {
80
80
  }
81
81
  export declare namespace utils {
82
82
  /** Current library version */
83
- export const VER = "v9.0.1";
83
+ export const VER = "v9.0.3";
84
84
  /** Whether the environment is Node.js or Browser */
85
85
  export const isNode: boolean;
86
86
  /** Add getter and/or setter for `name` to `obj` */
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- const t="undefined"==typeof window,e=t?[{},{back:()=>{},forward:()=>{}},class{},class{},class{},class{},()=>{}]:[window,history,DOMRect,HTMLCollection,Element,NodeList,addEventListener];export var utils;!function(n){const[i,o,r,s,a,l,u]=e;function c(t,e,n,i){const o={get:n||void 0,set:i||void 0};if(Array.isArray(e))for(const n of e)Object.defineProperty(t,n,o);else Object.defineProperty(t,e,o)}function f(t,e,n,i,o){const r={value:n,writable:!!o};if(i||(t=t.prototype),Array.isArray(e))for(const n of e)Object.defineProperty(t,n,r);else Object.defineProperty(t,e,r)}function d(t,e,n){let i,o=this.length,r=Math.max(e<0?o+e:e||0,0);for(null!=n&&(o=Math.min(n<0?o+n:n,o));r<o;++r)if("!"===(i=t(this[r],r,o)))this instanceof s?this[r].remove():this.splice(r,1),--r,--o;else if(null!=i)return i}async function h(t,e,n,i=!0){let o,r=this.length,a=e=Math.max(e<0?r+e:e||0,0),l=[];for(null!=n&&(r=Math.min(n<0?r+n:n,r));a<r;++a){if(o=t(this[a],a,r),!i&&(o=await o,"!"!==o&&null!=o))return o;l.push(o)}for(i&&(l=await Promise.all(l)),a=e,o=0;a<r;++a,++o)if("!"===l[o])this instanceof s?this[a].remove():this.splice(a,1),--a,--r;else if(null!=l[o])return l[o]}n.VER="v9.0.1",n.isNode=t,n.define=c,n.proto=f,n.copy=function t(e,n){if(0===n||"object"!=typeof e)return e;let i;if(n=n>0?n-1:void 0,Array.isArray(e))i=Array(e.length),e.forEach((e,o)=>i[o]=t(e,n));else{i={};for(let o in e)i[o]=t(e[o],n)}return i},n.merge=function t(e,...n){let i,o;for(const r of n)for(const n in r){if(i=e[n],o=r[n],i&&o){if(i.length>=0&&o.length>=0){Array.prototype.push.apply(i,o);continue}if("object"==typeof i&&"object"==typeof o){t(i,o);continue}}e[n]=o}return e},n.setProp=function(t,e,n,i=!1){"string"==typeof e&&(e=e.split("."));let o=0,r=e.length-1,s=t;for(;o<r;++o)if(s=s[e[o]],!s||"object"!=typeof s){if(i)return!1;s=t[e[o]]={}}const a=e.at(-1);return!(i&&null!=s[a]||(s[a]=n,0))},n.getProp=function(t,e){"string"==typeof e&&(e=e.split("."));try{for(const n of e)t=t[n];return t}catch(t){}},f(Array,"clean",function(t){for(let e,n=0,i=this.length;n<i;++n)e=this[n],(L(e)||!1===e||!t&&0===e)&&(this.splice(n--,1),--i);return this}),f(Array,"remove",function(t){const e=this.indexOf(t);return-1!==e&&(this.splice(e,1),!0)}),f(Array,"firstEmpty",function(){const t=this.length;for(let e=0;e<t;++e)if(null==this[e])return e;return t}),[Array,s,l].forEach(t=>{f(t,"each",d),f(t,"eachAsync",h)});const p=("undefined"==typeof BigInt?t=>t:BigInt)(0);function m(t,e="$"){if(!t)return e+"0.00";const n=t.toFixed(2).split(".");return e+n[0].split("").reverse().reduce((t,e,n)=>"-"==e?e+t:e+(!n||n%3?"":",")+t,"")+"."+n[1]}n.abs=t=>"bigint"==typeof t?t<p?-t:t:Math.abs(t),n.min=(...t)=>{let e,n;for(e of t)e>n||(n=e);return n},n.max=(...t)=>{let e,n;for(e of t)e<n||(n=e);return n},n.deg=t=>180*t/Math.PI,n.rad=t=>t*Math.PI/180,Math.cot=t=>1/Math.tan(t),n.fixedNum=function(t,e,i=10){"bigint"==typeof e&&(e=Number(e));let o=n.abs(t).toString(i).toUpperCase();return(t<0?"-":"")+(16==i?"0x":2==i?"0b":"")+"0".repeat(Math.max(e-o.length,0))+o},n.bounds=(t,e=0,n=1)=>t>=e?t<=n?t:n:e,n.norm=function(t,e=0,i=1){let o=i-e;return((t+n.abs(e))%o+o)%o+e},n.map=function(t,e,n,i,o,r){let s=(t-e)/(n-e);return(r?r(s):s)*(o-i)+i},n.hexToRgb=function(t){const e=parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,255&e]},n.rgbToHsl=function(t,e,n){let i,o,r=Math.max(t/=255,e/=255,n/=255),s=Math.min(t,e,n),a=(r+s)/2;if(r===s)i=o=0;else{let l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case t:i=(e-n)/l+(e<n?6:0);break;case e:i=(n-t)/l+2;break;default:i=(t-e)/l+4}i/=6}return[360*i,100*o,100*a]},n.rand=function(t,e,n=1,i){e*=n,t*=n;let o=Math.random();return Math.round((i?i(o):o)*(e-t)+t)/n},n.formatCost=m,n.Easing={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1- --t*t*t*t,easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>1+--t*t*t*t*t,easeInOutQuint:t=>t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t};const y=/[|\\{}()[\]^$+*?.]/g,g=/-/g;"escape"in RegExp||f(RegExp,"escape",t=>t.replace(y,"\\$&").replace(g,"\\x2d"),!0);const b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=b.replace("+/","-_"),v={43:62,47:63,48:52,49:53,50:54,51:55,52:56,53:57,54:58,55:59,56:60,57:61,65:0,66:1,67:2,68:3,69:4,70:5,71:6,72:7,73:8,74:9,75:10,76:11,77:12,78:13,79:14,80:15,81:16,82:17,83:18,84:19,85:20,86:21,87:22,88:23,89:24,90:25,97:26,98:27,99:28,100:29,101:30,102:31,103:32,104:33,105:34,106:35,107:36,108:37,109:38,110:39,111:40,112:41,113:42,114:43,115:44,116:45,117:46,118:47,119:48,120:49,121:50,122:51,45:62,95:63};function w(t,e){const n=v[t.charCodeAt(e)];if(null==n)throw"Bad char at "+e;return n}function O(t){let e=t.getBoundingClientRect(),n=getComputedStyle(t);return new R(e.top+parseFloat(n.paddingTop)+parseFloat(n.borderTopWidth),e.bottom-parseFloat(n.paddingBottom)-parseFloat(n.borderBottomWidth),e.left+parseFloat(n.paddingLeft)+parseFloat(n.borderLeftWidth),e.right-parseFloat(n.paddingRight)-parseFloat(n.borderRightWidth))}"toBase64"in Uint8Array.prototype||f(Uint8Array,"toBase64",function(t){let e,n=this.byteLength,i=n%3,o=t&&"base64url"===t.alphabet?x:b,r=0,s="";for(n-=i;r<n;r+=3)e=this[r]<<16|this[r+1]<<8|this[r+2],s+=o[(16515072&e)>>18]+o[(258048&e)>>12]+o[(4032&e)>>6]+o[63&e];return 1===i?(e=this[n],s+=o[(252&e)>>2]+o[(3&e)<<4],t&&t.omitPadding||(s+="=")):2===i&&(e=this[n]<<8|this[n+1],s+=o[(64512&e)>>10]+o[(1008&e)>>4]+o[(15&e)<<2],t&&t.omitPadding||(s+="==")),s}),"fromBase64"in Uint8Array||f(Uint8Array,"fromBase64",t=>{let e=t.length,n=e-1;for(;n>=0&&61===t.charCodeAt(n);--n);e=n+1,n=0;let i=e%4;if(e-=i,1==i)throw"Bad b64 len";let o,r=new Uint8Array(3*e/4+(i?i-1:0)),s=-1;for(;n<e;n+=4)o=w(t,n)<<18|w(t,n+1)<<12|w(t,n+2)<<6|w(t,n+3),r[++s]=o>>16,r[++s]=o>>8,r[++s]=o;return 2==i?r[++s]=w(t,n)<<2|w(t,n+1)>>4:3==i&&(o=w(t,n)<<10|w(t,n+1)<<4|w(t,n+2)>>2,r[++s]=o>>8,r[++s]=o),r},!0),"at"in Array.prototype||f(Array,"at",function(t){const e=this.length,n=t<0?e+t:t;if(n>=0&&n<e)return this[n]}),f(Function,"wrap",function(...t){const e=this;return function(){return e.apply(arguments,t)}},!1,!0),i.TouchList&&f(TouchList,"get",function(t){for(const e of this)if(e.identifier===t)return e}),c(a.prototype,"index",function(){const t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),f(a,"insertChildAt",function(t,e){e<0&&(e=0),e>=this.children.length?this.appendChild(t):this.insertBefore(t,this.children[e])}),n.boundingRect=t=>new R(t.getBoundingClientRect()),n.innerRect=O,c(a.prototype,"boundingRect",function(){return n.boundingRect(this)}),c(a.prototype,"innerRect",function(){return O(this)});class R{constructor(t,e,n,i){const o=Number.isFinite;let s=0,a=0,l=0,u=0;c(this,"x",()=>l,t=>{o(t)&&(u+=t-l,l=t)}),c(this,"y",()=>s,t=>{o(t)&&(a+=t-s,s=t)}),c(this,"top",()=>s,t=>{s=o(t)?t:0}),c(this,["bottom","y2"],()=>a,t=>{a=o(t)?t:0}),c(this,"left",()=>l,t=>{l=o(t)?t:0}),c(this,["right","x2"],()=>u,t=>{u=o(t)?t:0}),c(this,["width","w"],()=>u-l,t=>{u=t>=0?l+t:0}),c(this,["height","h"],()=>a-s,t=>{a=t>=0?s+t:0}),c(this,"centerX",()=>l/2+u/2),c(this,"centerY",()=>s/2+a/2),t instanceof r||t instanceof R?(s=t.top,a=t.bottom,l=t.left,u=t.right):(s=t,a=e,l=n,u=i)}contains(t,e){return t instanceof a?this.contains(t.boundingRect):t instanceof R?t.x>=this.x&&t.x2<=this.x2&&t.y>=this.y&&t.y2<=this.y2:t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}overlaps(t){if(t instanceof a)return this.overlaps(t.boundingRect);if(!(t instanceof R))return!1;let e,n;return e=t.x2-t.x>=this.x2-this.x?this.x>=t.x&&this.x<=t.x2||this.x2>=t.x&&this.x2<=t.x2:t.x>=this.x&&t.x<=this.x2||t.x2>=this.x&&t.x2<=this.x2,n=t.y2-t.y>=this.y2-this.y?this.y>=t.y&&this.y<=t.y2||this.y2>=t.y&&this.y2<=t.y2:t.y>=this.y&&t.y<=this.y2||t.y2>=this.y&&t.y2<=this.y2,e&&n}dist(t,e){if(t instanceof a)return this.dist(t.boundingRect);const n=t instanceof R;return e=Math.abs((n?t.centerY:e)-this.centerY),t=Math.abs((n?t.centerX:t)-this.centerX),Math.sqrt(t*t+e*e)}expand(t){return this.top-=t,this.left-=t,this.bottom+=t,this.right+=t,this}}function A(t){t||(t=navigator.userAgent);const e={};if(!t.startsWith("Mozilla/5.0 "))return e;let n,i,o=t.indexOf(")"),r=e.rawOS=t.slice(13,o);return r.startsWith("Windows")?(n=r.split("; "),e.os="Windows",e.type=-1!==n.indexOf("WOW64")?"x64 PC; x86 Browser":-1!==n.indexOf("x64")?"x64 PC":"x86 PC",n=r.indexOf("Windows NT "),e.version=r.slice(n+11,r.indexOf(";",n+12))):r.startsWith("iP")?(n=r.indexOf("OS"),e.os="iOS",e.type=r.slice(0,r.indexOf(";")),e.version=r.slice(n+3,r.indexOf(" ",n+4)).replace(/_/g,".")):r.startsWith("Macintosh;")?(n=r.indexOf(" Mac OS X"),e.os="MacOS",e.type=r.slice(11,n)+" Mac",e.version=r.slice(n+10).replace(/_/g,".")):-1!==(n=r.indexOf("Android"))?(e.os="Android",e.version=r.slice(n+8,r.indexOf(";",n+9)),n=r.lastIndexOf(";"),i=r.indexOf(" Build",n+2),e.type=r.slice(n+2,-1===i?void 0:i)):r.startsWith("X11;")&&(r=r.slice(5).split(/[;\s]+/),n=r.length,e.os=("Linux"===r[0]?"":"Linux ")+r[0],e.type=r[n-2],e.version=r[n-1]),(n=Number(e.version))&&(e.version=n),n=t.indexOf(" ",o+2),i=t.indexOf(")",n+1),i=-1===i?n+1:i+2,e.engine=t.slice(o+2,n),e.browser=t.slice(i),e.mobile=!!t.match(/Mobi/i),e}n.UtilRect=R,n.deviceInfo=A,n.device=t?null:A(),n.mobile=null===n.device||void 0===n.device?void 0:n.device.mobile;const M=/translate(?:x|y)?\(.+?\)/gi;function C(t){n.onNav&&n.onNav.call(null,t)}function I(t,e,n,i,o){const r=document.createElement(t);if(null!=n&&(r.className=n),null!=o&&(r.innerHTML=o),i&&"object"==typeof i)for(const t in i)t in r.style?r.style[t]=i[t]:r.style.setProperty(t,i[t]);return null!=e&&e.appendChild(r),r}let S;n.center=function(t,e,i){const o=t.style;if("trans"==i){o.position||(o.position="absolute");let t=o.transform.replace(M,"").trim();e&&"x"!==e||(o.left="50%",t+=" translateX(-50%)"),e&&"y"!==e||(o.top="50%",t+=" translateY(-50%)"),o.transform=t}else{const i=n.mkDiv(t.parentNode,null,{display:"flex",top:0,left:0}),o=i.style;i.appendChild(t),e&&"x"!==e||(o.justifyContent="center",o.width="100%"),e&&"y"!==e||(o.alignItems="center",o.height="100%",o.position="absolute")}},n.go=function(t,e){o.pushState(e,"",t),C(e)},u("popstate",t=>C(t.state)),u("load",()=>setTimeout(()=>C(o.state),1)),n.mkEl=I,n.mkDiv=(t,e,n,i)=>I("div",t,e,n,i),n.addText=(t,e)=>t.appendChild(document.createTextNode(e)),n.textWidth=function(t,e){const n=(S||(S=I("canvas"))).getContext("2d");return n.font=e,n.measureText(t).width};const k=/[A-Z]/g,N=t=>"-"+t.toLowerCase();function E(t,e){return!0===e?t:("string"!=typeof e&&(e=JSON.stringify(e)),`${t}=${encodeURIComponent(e)}`)}n.addCSS=function(t,e,n){n||(n=function(){for(const t of document.styleSheets)try{return t.cssRules,t}catch(t){}return I("style",document.head).sheet}());let i,o=[];for(i in e)o.push(`${i.replace(k,N)}:${e[i]}`);n.insertRule(`${t}{${o.join(";")}}`)},n.remCSS=function(t){let e,n;for(e of document.styleSheets){try{n=e.cssRules}catch(t){continue}for(let i=0,o=n.length;i<o;++i)n[i]instanceof CSSStyleRule&&n[i].selectorText===t&&e.deleteRule(i)}},n.setCookie=function(e,n,i,o){let r=`${encodeURIComponent(e)}=${null==n?"":encodeURIComponent(n)};path=/`;return null!=i&&(-1===i&&(i=new Date(9e14)),r+=i instanceof Date?";expires="+i.toUTCString():";max-age="+i),o&&(r+=";secure"),t||(document.cookie=r),r},n.getCookie=function(t,e){null==e&&(e=document.cookie),t=encodeURIComponent(t)+"=";let n,i=e.split("; ");for(n of i)if(n.startsWith(t))return decodeURIComponent(n.slice(t.length))},n.remCookie=function(e){let n=encodeURIComponent(e)+"=;max-age=0";return t||(document.cookie=n),n},n.getCookies=function(t){if(null==t&&(t=document.cookie),!t)return{};let e,n;const i={};for(e of t.split("; "))n=e.indexOf("="),i[decodeURIComponent(e.slice(0,n))]=decodeURIComponent(e.slice(n+1));return i},n.fromQuery=function(t,e="&"){t.startsWith("?")&&(t=t.slice(1));let n,i,o,r,s={};for(n of t.split(e))i=n.indexOf("="),-1===i?(o=n,r=!0):(o=decodeURIComponent(n.slice(0,i)),r=decodeURIComponent(n.slice(i+1))),o in s?(i=s[o],Array.isArray(i)?i.push(r):s[o]=[i,r]):s[o]=r;return s},n.toQuery=function(t,e="&"){let n,i,o=[];for(n in t)if(i=t[n],n=encodeURIComponent(n),Array.isArray(i))for(const t of i)o.push(E(n,t));else o.push(E(n,i));return o.join(e)};const T=/\.0*$/;function U(t){return t<=9?"0"+t:t}function F(t){let e=t%10,n=t%100;return 1==e&&11!=n?t+"st":2==e&&12!=n?t+"nd":3==e&&13!=n?t+"rd":t+"th"}n.numField=function(t,e,i,o,r){const s=t,a=RegExp(`[,${r?RegExp.escape(r):""}]`,"g");function l(t){return"string"==typeof t&&(t=t.replace(a,"")),t=n.bounds(Number(t)||0,e,i),o?Number(t.toFixed(o)):Math.round(t)}return s.type=n.mobile||o||r?"tel":"number",s.setAttribute("pattern","\\d*"),s.step||(s.step=1),s.addEventListener("keydown",t=>{if(t.ctrlKey)return;let a=t.key,l=1===a.length&&Number.isFinite(Number(a)),u=s.ns,c=u.length,f=u.indexOf(".");if("Tab"!==a&&"Enter"!==a){if(l?(-1===f||c-f<o+1)&&(u+=a):"."===a||"*"===a?o&&-1==f&&s.num!=i&&(e>=0||s.num!=e)&&(!c&&e>0?u=Math.floor(e)+".":u+="."):"Backspace"===a||"Delete"===a?u=e>0&&s.num===e&&u.endsWith(".")?"":u.slice(0,-1):"-"===a||"#"===a?e<0&&!c&&(u="-"):"ArrowUp"===a?(u=null,s.set(s.num+Number(s.step))):"ArrowDown"===a&&(u=null,s.set(s.num-Number(s.step))),null!==u&&u!==s.ns){c=u.length,f=u.indexOf(".");let a="-"===u||"-."===u,d=a?"0":u+(u.endsWith(".")?"0":""),h=Number(d),p=n.bounds(h,e,i);(!l||!u||s.num!==p||-1!==f&&c-f<o+1)&&(s.ns=u,s.num=p,s.value=r?a?r+"-0.00":m(p,r):("-"===u[0]?"-":"")+Math.floor(Math.abs(p))+(-1!==f?u.slice(f)+(T.test(u)?"0":""):""),s.onnuminput&&s.onnuminput.call(s,t))}t.preventDefault()}}),s.set=t=>{s.num=l(t),s.ns=s.num.toString(),s.value=r?m(s.num,r):s.ns,s.ns=s.ns.replace(/^(-?)0+/,"$1"),s.onnuminput&&s.onnuminput.call(s)},s.setRange=(t,n,a)=>{e=null==t?Number.MIN_SAFE_INTEGER:t,i=null==n?Number.MAX_SAFE_INTEGER:n,o=null==a?r?2:0:a,l(s.num)!==s.num&&s.set(s.num)},s.addEventListener("input",()=>s.set(s.value)),s.addEventListener("paste",t=>{s.set(t.clipboardData.getData("text")),t.preventDefault()}),s.setRange(e,i,o),s},n.autosize=function(t,e=5,i=1){const o=t;o.set=t=>{o.value=t,s()};let r=o.style;function s(){if(0===o.scrollHeight)return setTimeout(s,1);o.setAttribute("rows",1);let t=getComputedStyle(o);r.setProperty("overflow","hidden","important"),r.width=o.innerRect.w+"px",r.boxSizing="content-box",r.borderWidth=r.paddingInline="0";let a=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),l="normal"===t.lineHeight?parseFloat(t.height):parseFloat(t.lineHeight),u=Math.round((Math.round(o.scrollHeight)-a)/l);r.overflow=r.width=r.boxSizing=r.borderWidth=r.paddingInline="",o.setAttribute("rows",n.bounds(u,i,e))}r.maxHeight=r.resize="none",r.minHeight="0",r.height="auto",o.setAttribute("rows",i),o.addEventListener("input",s)},n.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n.formatDate=function(t,e={}){let i,o,r="";if(!(null!=t&&t.getDate&&(i=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let n=t.getHours(),i="";if(e.h24||(i=" AM",n>=12&&(i=" PM",n-=12),n||(n=12)),r=n+":"+U(t.getMinutes())+(e.sec?":"+U(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).slice(1):""):""),r+=i,e.time)return r}return o=t.getDate(),o=n.months[t.getMonth()]+" "+(null==e.suf||e.suf?F(o):o),null!=e.year&&!e.year||e.year===i||(o=o+", "+i),e.df?o+(r&&" "+r):(r&&r+" ")+o},n.suffix=F,n.setDateTime=function(t,e){e instanceof Date||(e=new Date(e)),t.value=new Date(e.getTime()-6e4*e.getTimezoneOffset()).toISOString().slice(0,"date"===t.type?10:19)},n.getDateTime=t=>new Date(t.value+("date"===t.type?"T00:00":""));const D=/\S/;function L(t){return null==t||("string"==typeof t?!D.test(t):"object"==typeof t&&("number"==typeof t.length?0===t.length:0===Object.keys(t).length))}let W;async function P(){W||(W=await import("os"))}n.isBlank=L,n.download=async function(t,e){const n=I("a");if("string"==typeof t||t instanceof URL)n.href=t.toString(),n.download=e||n.href.split("/").at(-1),n.click();else{t instanceof Blob||(t=new Blob([t]));const i=URL.createObjectURL(t);n.href=i,n.download=e||"file",n.click(),URL.revokeObjectURL(i)}},n.delay=t=>new Promise(e=>setTimeout(e,t)),n.getIPs=async function(){await P();const t=[],e=W.networkInterfaces();for(let n in e)e[n].forEach(e=>{!e.internal&&"IPv4"==e.family&&"00:00:00:00:00:00"!=e.mac&&e.address&&t.push(e.address)});return t},n.getOS=async function(){var t;let e,n;switch(await P(),W.platform()){case"win32":e="Windows";break;case"darwin":e="MacOS";break;case"linux":e="Linux";break;default:e=W.platform()}switch(W.arch()){case"ia32":n="32-bit";break;case"x64":n="64-bit";break;case"arm":n="ARM";break;default:n=W.arch()}return[e,n,(null===(t=W.cpus()[0])||void 0===t?void 0:t.model)||""]}}(utils||(utils={}));export default utils//# sourceMappingURL=utils.js.map
1
+ const t="undefined"==typeof window,e=t?[{},{back:()=>{},forward:()=>{}},class{},class{},class{},class{},()=>{}]:[window,history,DOMRect,HTMLCollection,Element,NodeList,addEventListener];export var utils;!function(n){const[i,o,r,s,a,l,u]=e;function c(t,e,n,i){const o={get:n||void 0,set:i||void 0};if(Array.isArray(e))for(const n of e)Object.defineProperty(t,n,o);else Object.defineProperty(t,e,o)}function f(t,e,n,i,o){const r={value:n,writable:!!o};if(i||(t=t.prototype),Array.isArray(e))for(const n of e)Object.defineProperty(t,n,r);else Object.defineProperty(t,e,r)}function d(t,e,n){let i,o=this.length,r=Math.max(e<0?o+e:e||0,0);for(null!=n&&(o=Math.min(n<0?o+n:n,o));r<o;++r)if("!"===(i=t(this[r],r,o)))this instanceof s?this[r].remove():this.splice(r,1),--r,--o;else if(null!=i)return i}async function h(t,e,n,i=!0){let o,r=this.length,a=e=Math.max(e<0?r+e:e||0,0),l=[];for(null!=n&&(r=Math.min(n<0?r+n:n,r));a<r;++a){if(o=t(this[a],a,r),!i&&(o=await o,"!"!==o&&null!=o))return o;l.push(o)}for(i&&(l=await Promise.all(l)),a=e,o=0;a<r;++a,++o)if("!"===l[o])this instanceof s?this[a].remove():this.splice(a,1),--a,--r;else if(null!=l[o])return l[o]}n.VER="v9.0.3",n.isNode=t,n.define=c,n.proto=f,n.copy=function t(e,n){if(0===n||"object"!=typeof e)return e;let i;if(n=n>0?n-1:void 0,Array.isArray(e))i=Array(e.length),e.forEach((e,o)=>i[o]=t(e,n));else{i={};for(let o in e)i[o]=t(e[o],n)}return i},n.merge=function t(e,...n){let i,o;for(const r of n)for(const n in r){if(i=e[n],o=r[n],i&&o){if(i.length>=0&&o.length>=0){Array.prototype.push.apply(i,o);continue}if("object"==typeof i&&"object"==typeof o){t(i,o);continue}}e[n]=o}return e},n.setProp=function(t,e,n,i=!1){"string"==typeof e&&(e=e.split("."));let o=0,r=e.length-1,s=t;for(;o<r;++o)if(s=s[e[o]],!s||"object"!=typeof s){if(i)return!1;s=t[e[o]]={}}const a=e.at(-1);return!(i&&null!=s[a]||(s[a]=n,0))},n.getProp=function(t,e){"string"==typeof e&&(e=e.split("."));try{for(const n of e)t=t[n];return t}catch(t){}},f(Array,"clean",function(t){for(let e,n=0,i=this.length;n<i;++n)e=this[n],(L(e)||!1===e||!t&&0===e)&&(this.splice(n--,1),--i);return this}),f(Array,"remove",function(t){const e=this.indexOf(t);return-1!==e&&(this.splice(e,1),!0)}),f(Array,"firstEmpty",function(){const t=this.length;for(let e=0;e<t;++e)if(null==this[e])return e;return t}),[Array,s,l].forEach(t=>{f(t,"each",d),f(t,"eachAsync",h)});const p=("undefined"==typeof BigInt?t=>t:BigInt)(0);function m(t,e="$"){if(!t)return e+"0.00";const n=t.toFixed(2).split(".");return e+n[0].split("").reverse().reduce((t,e,n)=>"-"==e?e+t:e+(!n||n%3?"":",")+t,"")+"."+n[1]}n.abs=t=>"bigint"==typeof t?t<p?-t:t:Math.abs(t),n.min=(...t)=>{let e,n;for(e of t)e>n||(n=e);return n},n.max=(...t)=>{let e,n;for(e of t)e<n||(n=e);return n},n.deg=t=>180*t/Math.PI,n.rad=t=>t*Math.PI/180,Math.cot=t=>1/Math.tan(t),n.fixedNum=function(t,e,i=10){"bigint"==typeof e&&(e=Number(e));let o=n.abs(t).toString(i).toUpperCase();return(t<0?"-":"")+(16==i?"0x":2==i?"0b":"")+"0".repeat(Math.max(e-o.length,0))+o},n.bounds=(t,e=0,n=1)=>t>=e?t<=n?t:n:e,n.norm=function(t,e=0,i=1){let o=i-e;return((t+n.abs(e))%o+o)%o+e},n.map=function(t,e,n,i,o,r){let s=(t-e)/(n-e);return(r?r(s):s)*(o-i)+i},n.hexToRgb=function(t){const e=parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,255&e]},n.rgbToHsl=function(t,e,n){let i,o,r=Math.max(t/=255,e/=255,n/=255),s=Math.min(t,e,n),a=(r+s)/2;if(r===s)i=o=0;else{let l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case t:i=(e-n)/l+(e<n?6:0);break;case e:i=(n-t)/l+2;break;default:i=(t-e)/l+4}i/=6}return[360*i,100*o,100*a]},n.rand=function(t,e,n=1,i){e*=n,t*=n;let o=Math.random();return Math.round((i?i(o):o)*(e-t)+t)/n},n.formatCost=m,n.Easing={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1- --t*t*t*t,easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>1+--t*t*t*t*t,easeInOutQuint:t=>t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t};const y=/[|\\{}()[\]^$+*?.]/g,g=/-/g;"escape"in RegExp||f(RegExp,"escape",t=>t.replace(y,"\\$&").replace(g,"\\x2d"),!0);const b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=b.replace("+/","-_"),v={43:62,47:63,48:52,49:53,50:54,51:55,52:56,53:57,54:58,55:59,56:60,57:61,65:0,66:1,67:2,68:3,69:4,70:5,71:6,72:7,73:8,74:9,75:10,76:11,77:12,78:13,79:14,80:15,81:16,82:17,83:18,84:19,85:20,86:21,87:22,88:23,89:24,90:25,97:26,98:27,99:28,100:29,101:30,102:31,103:32,104:33,105:34,106:35,107:36,108:37,109:38,110:39,111:40,112:41,113:42,114:43,115:44,116:45,117:46,118:47,119:48,120:49,121:50,122:51,45:62,95:63};function w(t,e){const n=v[t.charCodeAt(e)];if(null==n)throw"Bad char at "+e;return n}function O(t){let e=t.getBoundingClientRect(),n=getComputedStyle(t);return new R(e.top+parseFloat(n.paddingTop)+parseFloat(n.borderTopWidth),e.bottom-parseFloat(n.paddingBottom)-parseFloat(n.borderBottomWidth),e.left+parseFloat(n.paddingLeft)+parseFloat(n.borderLeftWidth),e.right-parseFloat(n.paddingRight)-parseFloat(n.borderRightWidth))}"toBase64"in Uint8Array.prototype||f(Uint8Array,"toBase64",function(t){let e,n=this.byteLength,i=n%3,o=t&&"base64url"===t.alphabet?x:b,r=0,s="";for(n-=i;r<n;r+=3)e=this[r]<<16|this[r+1]<<8|this[r+2],s+=o[(16515072&e)>>18]+o[(258048&e)>>12]+o[(4032&e)>>6]+o[63&e];return 1===i?(e=this[n],s+=o[(252&e)>>2]+o[(3&e)<<4],t&&t.omitPadding||(s+="=")):2===i&&(e=this[n]<<8|this[n+1],s+=o[(64512&e)>>10]+o[(1008&e)>>4]+o[(15&e)<<2],t&&t.omitPadding||(s+="==")),s}),"fromBase64"in Uint8Array||f(Uint8Array,"fromBase64",t=>{let e=t.length,n=e-1;for(;n>=0&&61===t.charCodeAt(n);--n);e=n+1,n=0;let i=e%4;if(e-=i,1==i)throw"Bad b64 len";let o,r=new Uint8Array(3*e/4+(i?i-1:0)),s=-1;for(;n<e;n+=4)o=w(t,n)<<18|w(t,n+1)<<12|w(t,n+2)<<6|w(t,n+3),r[++s]=o>>16,r[++s]=o>>8,r[++s]=o;return 2==i?r[++s]=w(t,n)<<2|w(t,n+1)>>4:3==i&&(o=w(t,n)<<10|w(t,n+1)<<4|w(t,n+2)>>2,r[++s]=o>>8,r[++s]=o),r},!0),"at"in Array.prototype||f(Array,"at",function(t){const e=this.length,n=t<0?e+t:t;if(n>=0&&n<e)return this[n]}),f(Function,"wrap",function(...t){const e=this;return function(){return e.apply(arguments,t)}},!1,!0),i.TouchList&&f(TouchList,"get",function(t){for(const e of this)if(e.identifier===t)return e}),c(a.prototype,"index",function(){const t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),f(a,"insertChildAt",function(t,e){e<0&&(e=0),e>=this.children.length?this.appendChild(t):this.insertBefore(t,this.children[e])}),n.boundingRect=t=>new R(t.getBoundingClientRect()),n.innerRect=O,c(a.prototype,"boundingRect",function(){return n.boundingRect(this)}),c(a.prototype,"innerRect",function(){return O(this)});class R{constructor(t,e,n,i){const o=Number.isFinite;let s=0,a=0,l=0,u=0;c(this,"x",()=>l,t=>{o(t)&&(u+=t-l,l=t)}),c(this,"y",()=>s,t=>{o(t)&&(a+=t-s,s=t)}),c(this,"top",()=>s,t=>{s=o(t)?t:0}),c(this,["bottom","y2"],()=>a,t=>{a=o(t)?t:0}),c(this,"left",()=>l,t=>{l=o(t)?t:0}),c(this,["right","x2"],()=>u,t=>{u=o(t)?t:0}),c(this,["width","w"],()=>u-l,t=>{u=t>=0?l+t:0}),c(this,["height","h"],()=>a-s,t=>{a=t>=0?s+t:0}),c(this,"centerX",()=>l/2+u/2),c(this,"centerY",()=>s/2+a/2),t instanceof r||t instanceof R?(s=t.top,a=t.bottom,l=t.left,u=t.right):(s=t,a=e,l=n,u=i)}contains(t,e){return t instanceof a?this.contains(t.boundingRect):t instanceof R?t.x>=this.x&&t.x2<=this.x2&&t.y>=this.y&&t.y2<=this.y2:t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}overlaps(t){if(t instanceof a)return this.overlaps(t.boundingRect);if(!(t instanceof R))return!1;let e,n;return e=t.x2-t.x>=this.x2-this.x?this.x>=t.x&&this.x<=t.x2||this.x2>=t.x&&this.x2<=t.x2:t.x>=this.x&&t.x<=this.x2||t.x2>=this.x&&t.x2<=this.x2,n=t.y2-t.y>=this.y2-this.y?this.y>=t.y&&this.y<=t.y2||this.y2>=t.y&&this.y2<=t.y2:t.y>=this.y&&t.y<=this.y2||t.y2>=this.y&&t.y2<=this.y2,e&&n}dist(t,e){if(t instanceof a)return this.dist(t.boundingRect);const n=t instanceof R;return e=Math.abs((n?t.centerY:e)-this.centerY),t=Math.abs((n?t.centerX:t)-this.centerX),Math.sqrt(t*t+e*e)}expand(t){return this.top-=t,this.left-=t,this.bottom+=t,this.right+=t,this}}function A(t){t||(t=navigator.userAgent);const e={};if(!t.startsWith("Mozilla/5.0 "))return e;let n,i,o=t.indexOf(")"),r=e.rawOS=t.slice(13,o);return r.startsWith("Windows")?(n=r.split("; "),e.os="Windows",e.type=-1!==n.indexOf("WOW64")?"x64 PC; x86 Browser":-1!==n.indexOf("x64")?"x64 PC":"x86 PC",n=r.indexOf("Windows NT "),e.version=r.slice(n+11,r.indexOf(";",n+12))):r.startsWith("iP")?(n=r.indexOf("OS"),e.os="iOS",e.type=r.slice(0,r.indexOf(";")),e.version=r.slice(n+3,r.indexOf(" ",n+4)).replace(/_/g,".")):r.startsWith("Macintosh;")?(n=r.indexOf(" Mac OS X"),e.os="MacOS",e.type=r.slice(11,n)+" Mac",e.version=r.slice(n+10).replace(/_/g,".")):-1!==(n=r.indexOf("Android"))?(e.os="Android",e.version=r.slice(n+8,r.indexOf(";",n+9)),n=r.lastIndexOf(";"),i=r.indexOf(" Build",n+2),e.type=r.slice(n+2,-1===i?void 0:i)):r.startsWith("X11;")&&(r=r.slice(5).split(/[;\s]+/),n=r.length,e.os=("Linux"===r[0]?"":"Linux ")+r[0],e.type=r[n-2],e.version=r[n-1]),(n=Number(e.version))&&(e.version=n),n=t.indexOf(" ",o+2),i=t.indexOf(")",n+1),i=-1===i?n+1:i+2,e.engine=t.slice(o+2,n),e.browser=t.slice(i),e.mobile=!!t.match(/Mobi/i),e}n.UtilRect=R,n.deviceInfo=A,n.device=t?null:A(),n.mobile=null===n.device||void 0===n.device?void 0:n.device.mobile;const M=/translate(?:x|y)?\(.+?\)/gi;function C(t){n.onNav&&n.onNav.call(null,t)}function I(t,e,n,i,o){const r=document.createElement(t);if(null!=n&&(r.className=n),null!=o&&(r.innerHTML=o),i&&"object"==typeof i)for(const t in i)t in r.style?r.style[t]=i[t]:r.style.setProperty(t,i[t]);return null!=e&&e.appendChild(r),r}let S;n.center=function(t,e,i){const o=t.style;if("trans"==i){o.position||(o.position="absolute");let t=o.transform.replace(M,"").trim();e&&"x"!==e||(o.left="50%",t+=" translateX(-50%)"),e&&"y"!==e||(o.top="50%",t+=" translateY(-50%)"),o.transform=t}else{const i=n.mkDiv(t.parentNode,null,{display:"flex",top:0,left:0}),o=i.style;i.appendChild(t),e&&"x"!==e||(o.justifyContent="center",o.width="100%"),e&&"y"!==e||(o.alignItems="center",o.height="100%",o.position="absolute")}},n.go=function(t,e){o.pushState(e,"",t),C(e)},u("popstate",t=>C(t.state)),u("load",()=>setTimeout(()=>C(o.state),1)),n.mkEl=I,n.mkDiv=(t,e,n,i)=>I("div",t,e,n,i),n.addText=(t,e)=>t.appendChild(document.createTextNode(e)),n.textWidth=function(t,e){const n=(S||(S=I("canvas"))).getContext("2d");return n.font=e,n.measureText(t).width};const k=/[A-Z]/g,N=t=>"-"+t.toLowerCase();function E(t,e){return!0===e?t:("string"!=typeof e&&(e=JSON.stringify(e)),`${t}=${encodeURIComponent(e)}`)}n.addCSS=function(t,e,n){n||(n=function(){for(const t of document.styleSheets)try{return t.cssRules,t}catch(t){}return I("style",document.head).sheet}());let i,o=[];for(i in e)o.push(`${i.replace(k,N)}:${e[i]}`);n.insertRule(`${t}{${o.join(";")}}`)},n.remCSS=function(t){let e,n;for(e of document.styleSheets){try{n=e.cssRules}catch(t){continue}for(let i=0,o=n.length;i<o;++i)n[i]instanceof CSSStyleRule&&n[i].selectorText===t&&e.deleteRule(i)}},n.setCookie=function(e,n,i,o){let r=`${encodeURIComponent(e)}=${null==n?"":encodeURIComponent(n)};path=/`;return null!=i&&(-1===i&&(i=new Date(9e14)),r+=i instanceof Date?";expires="+i.toUTCString():";max-age="+i),o&&(r+=";secure"),t||(document.cookie=r),r},n.getCookie=function(t,e){null==e&&(e=document.cookie),t=encodeURIComponent(t)+"=";let n,i=e.split("; ");for(n of i)if(n.startsWith(t))return decodeURIComponent(n.slice(t.length))},n.remCookie=function(e){let n=encodeURIComponent(e)+"=;max-age=0";return t||(document.cookie=n),n},n.getCookies=function(t){if(null==t&&(t=document.cookie),!t)return{};let e,n;const i={};for(e of t.split("; "))n=e.indexOf("="),i[decodeURIComponent(e.slice(0,n))]=decodeURIComponent(e.slice(n+1));return i},n.fromQuery=function(t,e="&"){t.startsWith("?")&&(t=t.slice(1));let n,i,o,r,s={};for(n of t.split(e))i=n.indexOf("="),-1===i?(o=n,r=!0):(o=decodeURIComponent(n.slice(0,i)),r=decodeURIComponent(n.slice(i+1))),o in s?(i=s[o],Array.isArray(i)?i.push(r):s[o]=[i,r]):s[o]=r;return s},n.toQuery=function(t,e="&"){let n,i,o=[];for(n in t)if(i=t[n],n=encodeURIComponent(n),Array.isArray(i))for(const t of i)o.push(E(n,t));else o.push(E(n,i));return o.join(e)};const T=/\.0*$/;function U(t){return t<=9?"0"+t:t}function F(t){let e=t%10,n=t%100;return 1==e&&11!=n?t+"st":2==e&&12!=n?t+"nd":3==e&&13!=n?t+"rd":t+"th"}n.numField=function(t,e,i,o,r){const s=t,a=RegExp(`[,${r?RegExp.escape(r):""}]`,"g");function l(t){return"string"==typeof t&&(t=t.replace(a,"")),t=n.bounds(Number(t)||0,e,i),o?Number(t.toFixed(o)):Math.round(t)}return s.type=n.mobile||o||r?"tel":"number",s.setAttribute("pattern","\\d*"),s.step||(s.step=1),s.addEventListener("keydown",t=>{if(t.ctrlKey)return;let a=t.key,l=1===a.length&&Number.isFinite(Number(a)),u=s.ns,c=u.length,f=u.indexOf(".");if("Tab"!==a&&"Enter"!==a){if(l?(-1===f||c-f<o+1)&&(u+=a):"."===a||"*"===a?o&&-1==f&&s.num!=i&&(e>=0||s.num!=e)&&(!c&&e>0?u=Math.floor(e)+".":u+="."):"Backspace"===a||"Delete"===a?u=e>0&&s.num===e&&u.endsWith(".")?"":u.slice(0,-1):"-"===a||"#"===a?e<0&&!c&&(u="-"):"ArrowUp"===a?(u=null,s.set(s.num+Number(s.step))):"ArrowDown"===a&&(u=null,s.set(s.num-Number(s.step))),null!==u&&u!==s.ns){c=u.length,f=u.indexOf(".");let a="-"===u||"-."===u,d=a?"0":u+(u.endsWith(".")?"0":""),h=Number(d),p=n.bounds(h,e,i);(!l||!u||s.num!==p||-1!==f&&c-f<o+1)&&(s.ns=u,s.num=p,s.value=r?a?r+"-0.00":m(p,r):("-"===u[0]?"-":"")+Math.floor(Math.abs(p))+(-1!==f?u.slice(f)+(T.test(u)?"0":""):""),s.onnuminput&&s.onnuminput.call(s,t))}t.preventDefault()}}),s.set=t=>{s.num=l(t),s.ns=s.num.toString(),s.value=r?m(s.num,r):s.ns,s.ns=s.ns.replace(/^(-?)0+/,"$1"),s.onnuminput&&s.onnuminput.call(s)},s.setRange=(t,n,a)=>{e=null==t?Number.MIN_SAFE_INTEGER:t,i=null==n?Number.MAX_SAFE_INTEGER:n,o=null==a?r?2:0:a,l(s.num)!==s.num&&s.set(s.num)},s.addEventListener("input",()=>s.set(s.value)),s.addEventListener("paste",t=>{s.set(t.clipboardData.getData("text")),t.preventDefault()}),s.setRange(e,i,o),s},n.autosize=function(t,e=5,i=1){const o=t;o.set=t=>{o.value=t,s()};let r=o.style;function s(){if(0===o.scrollHeight)return setTimeout(s,1);o.setAttribute("rows",1);let t=getComputedStyle(o);r.setProperty("overflow","hidden","important"),r.width=o.innerRect.w+"px",r.boxSizing="content-box",r.borderWidth=r.paddingInline="0";let a=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),l="normal"===t.lineHeight?parseFloat(t.height):parseFloat(t.lineHeight),u=Math.round((Math.round(o.scrollHeight)-a)/l);r.overflow=r.width=r.boxSizing=r.borderWidth=r.paddingInline="",o.setAttribute("rows",n.bounds(u,i,e))}r.maxHeight=r.resize="none",r.minHeight="0",r.height="auto",o.setAttribute("rows",i),o.addEventListener("input",s)},n.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n.formatDate=function(t,e={}){let i,o,r="";if(!(null!=t&&t.getDate&&(i=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let n=t.getHours(),i="";if(e.h24||(i=" AM",n>=12&&(i=" PM",n-=12),n||(n=12)),r=n+":"+U(t.getMinutes())+(e.sec?":"+U(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).slice(1):""):""),r+=i,e.time)return r}return o=t.getDate(),o=n.months[t.getMonth()]+" "+(null==e.suf||e.suf?F(o):o),null!=e.year&&!e.year||e.year===i||(o=o+", "+i),e.df?o+(r&&" "+r):(r&&r+" ")+o},n.suffix=F,n.setDateTime=function(t,e){e instanceof Date||(e=new Date(e)),t.value=new Date(e.getTime()-6e4*e.getTimezoneOffset()).toISOString().slice(0,"date"===t.type?10:19)},n.getDateTime=t=>new Date(t.value+("date"===t.type?"T00:00":""));const D=/\S/;function L(t){return null==t||("string"==typeof t?!D.test(t):"object"==typeof t&&("number"==typeof t.length?0===t.length:0===Object.keys(t).length))}let W;async function P(){W||(W=await import("os"))}n.isBlank=L,n.download=async function(t,e){const n=I("a");if("string"==typeof t||t instanceof URL)n.href=t.toString(),n.download=e||n.href.split("/").at(-1),n.click();else{t instanceof Blob||(t=new Blob([t]));const i=URL.createObjectURL(t);n.href=i,n.download=e||"file",n.click(),URL.revokeObjectURL(i)}},n.delay=t=>new Promise(e=>setTimeout(e,t)),n.getIPs=async function(){await P();const t=[],e=W.networkInterfaces();for(let n in e)e[n].forEach(e=>{!e.internal&&"IPv4"==e.family&&"00:00:00:00:00:00"!=e.mac&&e.address&&t.push(e.address)});return t},n.getOS=async function(){var t;let e,n;switch(await P(),W.platform()){case"win32":e="Windows";break;case"darwin":e="MacOS";break;case"linux":e="Linux";break;default:e=W.platform()}switch(W.arch()){case"ia32":n="32-bit";break;case"x64":n="64-bit";break;case"arm":n="ARM";break;default:n=W.arch()}return[e,n,(null===(t=W.cpus()[0])||void 0===t?void 0:t.model)||""]}}(utils||(utils={}));export default utils//# sourceMappingURL=utils.js.map
package/dist/uuid.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Buffer } from 'buffer';
2
+ declare let Long: any;
2
3
  interface Long {
3
4
  unsigned: boolean;
4
5
  toString(r: number): string;
@@ -9,9 +10,10 @@ export default class UUID {
9
10
  /** Delay before writing ID file to disk */
10
11
  static ID_Delay: number;
11
12
  id: Buffer;
12
- constructor(id: string | Buffer | Uint8Array | Long);
13
+ constructor(id: string | Buffer | Uint8Array | bigint | Long);
13
14
  toString(f?: BufferEncoding): string;
14
15
  toHexLE(): string;
16
+ toBigInt(): bigint;
15
17
  toLong(): any;
16
18
  getMagic(): number;
17
19
  getDate(): Date;
@@ -1 +1 @@
1
- {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAiBhC,UAAU,IAAI;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC;AAoB/D,MAAM,CAAC,OAAO,OAAO,IAAI;IACxB,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM;IACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,QAAQ,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;gBAEC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI;IAWnD,QAAQ,CAAC,CAAC,CAAC,EAAE,cAAc;IAI3B,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;IAKP,uDAAuD;IACvD,MAAM,CAAC,SAAS,GAAU,MAAM,MAAM,oDACc;IAEpD;;;MAGE;IACF,MAAM,CAAC,OAAO,GAAU,OAAO,IAAI,GAAG,MAAM,EAAE,QAAQ,MAAM,mBA+B3D;CACD"}
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC,QAAA,IAAI,IAAI,EAAE,GAAG,CAAC;AAGd,UAAU,IAAI;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC;AA2B/D,MAAM,CAAC,OAAO,OAAO,IAAI;IACxB,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM;IACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,QAAQ,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;gBAEC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI;IAc5D,QAAQ,CAAC,CAAC,CAAC,EAAE,cAAc;IAI3B,OAAO;IACP,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,OAAO;IAKP,uDAAuD;IACvD,MAAM,CAAC,SAAS,GAAU,MAAM,MAAM,oDACc;IAEpD;;;MAGE;IACF,MAAM,CAAC,OAAO,GAAU,OAAO,IAAI,GAAG,MAAM,EAAE,QAAQ,MAAM,mBA+B3D;CACD"}
package/dist/uuid.js CHANGED
@@ -1 +1 @@
1
- var t;import{Buffer as e}from"buffer";import r from"raiutils";const[i,n,a]=r.isNode?[await import("os"),await import("fs/promises"),(await import("util")).promisify((await import("crypto")).randomBytes)]:[];let o;try{o=await import("mongodb")}catch(t){}const s=import.meta.dirname+"/uuid";let l,f,d,m,u;class c{constructor(i){if(i instanceof Uint8Array&&i.length===t.BYTES);else if("string"==typeof i&&i.length===t.LEN)i=r.isNode?e.from(i,"base64"):Uint8Array.fromBase64(i,{alphabet:"base64url"});else{if(!(o&&i instanceof o.Long))throw"Unknown UUID format "+i;i.unsigned=!0,i=e.from(i.toString(16),"hex")}this.id=i instanceof e?i:e.from(i.buffer)}toString(t){return r.isNode||t?this.id.toString(t||"base64url"):this.id.toBase64({alphabet:"base64url",omitPadding:!0})}toHexLE(){return this.id.toString("hex").match(/.{2}/g).reverse().join("")}toLong(){return o.Long.fromString(this.id.toString("hex"),16)}getMagic(){return this.id.readUInt8(1)}getDate(){let t=1e4*this.id.readUInt32LE(4);return new Date(t<16215438e5?0:t)}}t=c,c.LEN=11,c.BYTES=8,c.ID_Delay=1e4,c.randBytes=async t=>a?a(t):crypto.getRandomValues(e.allocUnsafe(t)),c.genUUID=async(a,o)=>{let c=255&(i?10*i.uptime():performance.now()/100);const g=(a instanceof Date?a.getTime():a||Date.now())/1e4,w=await t.randBytes(null!=o?1:2),h=e.allocUnsafe(8);null==l&&await async function(){if(!n)return l=r.rand(0,255);if(!0!==u){u=!0;try{l=Number(await n.readFile(s,{encoding:"utf8"}))}catch(t){}l>=0&&l<=255||(console.error("[ChuID] IDCount error, resetting"),l=0),u=!1}else for(;!0===u;)await r.delay(10)}();const U=l;return++l>255&&(l=0),d===c&&m===g?f===U&&(await r.delay(50),d=c=c+1&255):(d=c,m=g,f=U),h.writeUInt8(c),null!=o?(h.writeUInt8(255&o,1),h.writeUInt8(w.readUInt8(),2)):h.writeUInt16LE(w.readUInt16LE(),1),h.writeUInt8(U,3),h.writeUInt32LE(g,4),n&&!u&&(u=setTimeout(()=>{u=!1,n.writeFile(s,l.toString())},t.ID_Delay)),new t(h)};export default c//# sourceMappingURL=uuid.js.map
1
+ var t;import{Buffer as e}from"buffer";import i from"raiutils";const[r,n,a]=i.isNode?[await import("os"),await import("fs/promises"),(await import("util")).promisify((await import("crypto")).randomBytes)]:[];let o;try{o=(await import("mongodb")).Long}catch(t){}const s=import.meta.dirname+"/uuid";let l,f,d,c,u;const g=BigInt(0),m=BigInt("18446744073709551615");class w{constructor(r){if(r instanceof Uint8Array&&r.length===t.BYTES);else if("string"==typeof r&&r.length===t.LEN)r=i.isNode?e.from(r,"base64"):Uint8Array.fromBase64(r,{alphabet:"base64url"});else if("bigint"==typeof r&&r>g&&r<=m){const t=r;(r=e.allocUnsafe(8)).writeBigUInt64LE(t)}else{if(!(o&&r instanceof o))throw"Unknown UUID format "+r;r.unsigned=!0,r=e.from(r.toString(16),"hex")}this.id=r instanceof e?r:e.from(r.buffer)}toString(t){return i.isNode||t?this.id.toString(t||"base64url"):this.id.toBase64({alphabet:"base64url",omitPadding:!0})}toHexLE(){return this.id.toString("hex").match(/.{2}/g).reverse().join("")}toBigInt(){return this.id.readBigUInt64LE()}toLong(){return o.fromString(this.id.toString("hex"),16)}getMagic(){return this.id.readUInt8(1)}getDate(){let t=1e4*this.id.readUInt32LE(4);return new Date(t<16215438e5?0:t)}}t=w,w.LEN=11,w.BYTES=8,w.ID_Delay=1e4,w.randBytes=async t=>a?a(t):crypto.getRandomValues(e.allocUnsafe(t)),w.genUUID=async(a,o)=>{let g=255&(r?10*r.uptime():performance.now()/100);const m=(a instanceof Date?a.getTime():a||Date.now())/1e4,w=await t.randBytes(null!=o?1:2),U=e.allocUnsafe(8);null==l&&await async function(){if(!n)return l=i.rand(0,255);if(!0!==u){u=!0;try{l=Number(await n.readFile(s,{encoding:"utf8"}))}catch(t){}l>=0&&l<=255||(console.error("[ChuID] IDCount error, resetting"),l=0),u=!1}else for(;!0===u;)await i.delay(10)}();const I=l;return++l>255&&(l=0),d===g&&c===m?f===I&&(await i.delay(50),d=g=g+1&255):(d=g,c=m,f=I),U.writeUInt8(g),null!=o?(U.writeUInt8(255&o,1),U.writeUInt8(w.readUInt8(),2)):U.writeUInt16LE(w.readUInt16LE(),1),U.writeUInt8(I,3),U.writeUInt32LE(m,4),n&&!u&&(u=setTimeout(()=>{u=!1,n.writeFile(s,l.toString())},t.ID_Delay)),new t(U)};export default w//# sourceMappingURL=uuid.js.map
package/dist/uuid.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Buffer","utils","os","fs","cRand","isNode","import","promisify","randomBytes","mdb","e","ID_FN","dirname","Cnt","CLT","LT","LD","UT","UUID","constructor","id","Uint8Array","length","_a","BYTES","LEN","from","fromBase64","alphabet","Long","unsigned","toString","this","buffer","f","toBase64","omitPadding","toHexLE","match","reverse","join","toLong","fromString","getMagic","readUInt8","getDate","d","readUInt32LE","Date","ID_Delay","randBytes","async","size","crypto","getRandomValues","allocUnsafe","genUUID","date","magic","ts","uptime","performance","now","ds","getTime","rb","u","rand","Number","readFile","encoding","console","error","delay","loadId","ct","writeUInt8","writeUInt16LE","readUInt16LE","writeUInt32LE","setTimeout","writeFile"],"sources":["../src/uuid.ts"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"names":["Buffer","utils","os","fs","cRand","isNode","import","promisify","randomBytes","Long","e","ID_FN","dirname","Cnt","CLT","LT","LD","UT","B0","BigInt","B64","UUID","constructor","id","Uint8Array","length","_a","BYTES","LEN","from","fromBase64","alphabet","n","allocUnsafe","writeBigUInt64LE","unsigned","toString","this","buffer","f","toBase64","omitPadding","toHexLE","match","reverse","join","toBigInt","readBigUInt64LE","toLong","fromString","getMagic","readUInt8","getDate","d","readUInt32LE","Date","ID_Delay","randBytes","async","size","crypto","getRandomValues","genUUID","date","magic","ts","uptime","performance","now","ds","getTime","rb","u","rand","Number","readFile","encoding","console","error","delay","loadId","ct","writeUInt8","writeUInt16LE","readUInt16LE","writeUInt32LE","setTimeout","writeFile"],"sources":["../src/uuid.ts"],"mappings":"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","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raiutils",
3
- "version": "9.0.1",
3
+ "version": "9.0.3",
4
4
  "type": "module",
5
5
  "description": "The ultimate JavaScript & TypeScript companion library. You'll never need jQuery again!",
6
6
  "repository": {
package/src/utils.ts CHANGED
@@ -108,7 +108,7 @@ const [window, history, DOMRect, HTMLCollection,
108
108
  Element, NodeList, addEventListener] = P;
109
109
 
110
110
  /** Current library version */
111
- export const VER = "v9.0.1";
111
+ export const VER = "v9.0.3";
112
112
 
113
113
  /** Whether the environment is Node.js or Browser */
114
114
  export const isNode = IsNode;
package/src/uuid.ts CHANGED
@@ -1,4 +1,4 @@
1
- //Chu ID v1.5.2, Pecacheu 2026. GNU GPL v3
1
+ //Chu ID v1.5.3, Pecacheu 2026. GNU GPL v3
2
2
 
3
3
  import { Buffer } from 'buffer';
4
4
  import utils from 'raiutils';
@@ -9,16 +9,15 @@ const [os, fs, cRand] = utils.isNode ? [
9
9
  (await import('util')).promisify((await import('crypto')).randomBytes)
10
10
  ] : [];
11
11
 
12
- let mdb: any;
12
+ let Long: any;
13
13
  //@ts-expect-error
14
- try {mdb = await import('mongodb')} catch(e) {}
14
+ try {Long = (await import('mongodb')).Long} catch(e) {}
15
+ interface Long {unsigned: boolean; toString(r: number): string}
15
16
 
16
17
  const ID_FN = import.meta.dirname+'/uuid';
17
18
  let Cnt: number, CLT: number, LT: number,
18
19
  LD: number, UT: NodeJS.Timeout | boolean;
19
20
 
20
- interface Long {unsigned: boolean; toString(r: number): string}
21
-
22
21
  //64-bit UUID Format
23
22
  //<U8 Uptime><U8 Magic><U8 CryptoRand><U8 Counter><U32 Date>
24
23
 
@@ -37,6 +36,9 @@ async function loadId() {
37
36
  UT=false;
38
37
  }
39
38
 
39
+ const B0 = BigInt(0),
40
+ B64 = BigInt('18446744073709551615');
41
+
40
42
  export default class UUID {
41
43
  static readonly LEN = 11;
42
44
  static readonly BYTES = 8;
@@ -44,12 +46,15 @@ export default class UUID {
44
46
  static ID_Delay = 10000;
45
47
  id: Buffer;
46
48
 
47
- constructor(id: string | Buffer | Uint8Array | Long) {
49
+ constructor(id: string | Buffer | Uint8Array | bigint | Long) {
48
50
  if(id instanceof Uint8Array && id.length === UUID.BYTES) {}
49
51
  else if(typeof id === 'string' && id.length === UUID.LEN) {
50
52
  if(utils.isNode) id=Buffer.from(id, 'base64');
51
53
  else id=Uint8Array.fromBase64(id, {alphabet:'base64url'});
52
- } else if(mdb && id instanceof mdb.Long) {
54
+ } else if(typeof id === 'bigint' && id > B0 && id <= B64) {
55
+ const n=id;
56
+ (id=Buffer.allocUnsafe(8)).writeBigUInt64LE(n);
57
+ } else if(Long && id instanceof Long) {
53
58
  (id as Long).unsigned=true;
54
59
  id=Buffer.from((id as Long).toString(16),'hex');
55
60
  } else throw `Unknown UUID format ${id}`;
@@ -60,7 +65,8 @@ export default class UUID {
60
65
  return this.id.toBase64({alphabet:'base64url', omitPadding:true});
61
66
  }
62
67
  toHexLE() {return swapHex(this.id.toString('hex'))}
63
- toLong() {return mdb.Long.fromString(this.id.toString('hex'),16)}
68
+ toBigInt() {return this.id.readBigUInt64LE()}
69
+ toLong() {return Long.fromString(this.id.toString('hex'),16)}
64
70
  getMagic() {return this.id.readUInt8(1)}
65
71
  getDate() {
66
72
  let d=this.id.readUInt32LE(4)*10000;