raiutils 8.7.3 → 8.7.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raiutils",
3
- "version": "8.7.3",
3
+ "version": "8.7.5",
4
4
  "type": "module",
5
5
  "description": "The ultimate JavaScript companion library. You'll never need jQuery again!",
6
6
  "repository": "https://github.com/Pecacheu/Utils.js",
package/router.js CHANGED
@@ -1,4 +1,4 @@
1
- //Node Webserver v3.4.1, Pecacheu 2025. GNU GPL v3
1
+ //Node Webserver v3.4.2, Pecacheu 2025. GNU GPL v3
2
2
 
3
3
  import path from 'path';
4
4
  import fs from 'fs/promises';
@@ -19,17 +19,15 @@ const types = {
19
19
  '.webm': "video/webm"
20
20
  };
21
21
 
22
- let MAX_ETAG=1048576, //1MB
23
- FAST_ETAG=true;
24
-
25
- async function handle(dir, req, res, virtualDirs) {
22
+ //etag: If number, max file size to calc hash, else if true, use fast etag mode (modified date)
23
+ async function handle(dir, req, res, virtualDirs, etag=true) {
26
24
  let f;
27
25
  try {
28
26
  let fn=await resolve(dir, new URL(req.url,'http://a').pathname, virtualDirs),
29
27
  hdr={}, stat=200, ext=path.extname(fn), ct=types[ext], rng=req.headers.range, str;
30
28
  if(ct) hdr["content-type"] = ct;
31
29
  f=await fs.open(fn);
32
- let dl=(await f.stat()).size;
30
+ let st=await f.stat(), dl=st.size;
33
31
  if(rng) { //Range
34
32
  if(!rng.startsWith('bytes=') || (rng=rng.slice(6).split('-'))
35
33
  .length !== 2 || !rng[0]) return await rngErr(f,dl,rng,res);
@@ -40,12 +38,12 @@ async function handle(dir, req, res, virtualDirs) {
40
38
  hdr["accept-ranges"] = 'bytes';
41
39
  hdr["content-range"] = `bytes ${rs}-${re}/${dl}`;
42
40
  stat=206;
43
- } else if(!FAST_ETAG && dl <= MAX_ETAG) {
41
+ } else if(typeof etag==='number') {if(dl <= MAX_ETAG) {
44
42
  str=await f.readFile();
45
43
  let h=crypto.createHash('sha1');
46
44
  h.update(str);
47
45
  hdr.etag=h.digest('base64url');
48
- } else if(FAST_ETAG) hdr.etag=dl.toString();
46
+ }} else if(etag) hdr.etag=st.mtime.toISOString();
49
47
 
50
48
  if(hdr.etag && hdr.etag === req.headers['if-none-match'])
51
49
  return res.writeHead(304,''),res.end(),f.close();
@@ -63,6 +61,11 @@ async function handle(dir, req, res, virtualDirs) {
63
61
  }
64
62
  }
65
63
 
64
+ async function serve(fn, req, res, etag=true) {
65
+ let u=req.url; req.url='/';
66
+ return handle(fn, req, res, null, etag).finally(() => req.url=u);
67
+ }
68
+
66
69
  async function rngErr(f,fl,rng,res) {
67
70
  if(debug) err("-- Bad Range",rng);
68
71
  let h={"content-range": 'bytes */'+fl};
@@ -80,6 +83,7 @@ function log(name, ct) {console.log(chalk.dim("-- Served "+name+(ct?" with type
80
83
  async function resolve(dir, uri, vDir) {
81
84
  if(uri.indexOf('..') !== -1) throw "Bad path";
82
85
  let fn = parseUri(dir, uri, vDir);
86
+ if(fn.endsWith('/')) fn=fn.slice(0,-1);
83
87
  try {
84
88
  let stat = await fs.stat(fn);
85
89
  if(stat.isDirectory()) return path.join(fn,'/index.html'); //Try index
@@ -100,6 +104,6 @@ function parseUri(root, uri, vDir) {
100
104
  return root+uri;
101
105
  }
102
106
 
103
- const ex={handle, types};
107
+ const ex={handle, serve, types};
104
108
  Object.defineProperty(ex, 'debug', {set:d => debug=d});
105
109
  export default ex;
package/schema.js CHANGED
@@ -1,4 +1,4 @@
1
- //ChuSchema v1.2, Pecacheu 2025. GNU GPL v3
1
+ //ChuSchema v1.2.1, Pecacheu 2025. GNU GPL v3
2
2
 
3
3
  function errAt(k,e,l) {
4
4
  let es=e.message||e;
@@ -7,7 +7,7 @@ function errAt(k,e,l) {
7
7
  return e;
8
8
  }
9
9
 
10
- function isDict(d) {return typeof d==='object' && !Array.isArray(d)}
10
+ function isDict(d) {return typeof d==='object' && d!==null && !Array.isArray(d)}
11
11
  function oobStr(s) {return ` out-of-bounds (${s.min||'*'}-${s.max||'*'})`}
12
12
  function checkType(d,sr) {
13
13
  if(typeof sr.t!=='string') throw "Missing type";
@@ -24,7 +24,7 @@ function checkType(d,sr) {
24
24
  if(typeof d!=='string') throw -1;
25
25
  l=d.length;
26
26
  if(l<s.min || l>s.max) throw "Str len "+l+oobStr(s);
27
- if(typeof s.f==='string') s.f=new RegExp(`^(?:${f})$`);
27
+ if(typeof s.f==='string') s.f=new RegExp(`^(?:${s.f})$`);
28
28
  if(s.f instanceof RegExp && !s.f.test(d)) throw `Str '${d}' does not match format`;
29
29
  break; case 'int': case 'float':
30
30
  if(typeof d!=='number' || !(t==='int'?Number.isSafeInteger(d):Number.isFinite(d))) throw -1;
@@ -39,6 +39,7 @@ function checkType(d,sr) {
39
39
  if(typeof s.c==='string') s.c={t:s.c};
40
40
  n=0, dt=isDict(s.f)?2:isDict(s.c)?1:0;
41
41
  if(!dt) throw "List schema lacks format or childType";
42
+ if(dt===2 && s.c) throw "Cannot require both format and childType";
42
43
  for(; n<l; ++n) try {dt===2?checkSchema(d[n],s.f):checkType(d[n],s.c)}
43
44
  catch(e) {throw errAt(n,e,1)}
44
45
  break; case 'dict':
@@ -46,8 +47,11 @@ function checkType(d,sr) {
46
47
  k=Object.keys(d), l=k.length; if(!l) throw "Empty dict";
47
48
  if(s.f) throw "Dict schema does not support format (use childType instead)";
48
49
  if(typeof s.c==='string') s.c={t:s.c};
49
- if(!isDict(s.c)) throw "Dict schema lacks childType";
50
- for(n of k) try {checkType(d[n],s.c)} catch(e) {throw errAt(n,e,1)}
50
+ dt=isDict(s.f)?2:isDict(s.c)?1:0;
51
+ if(!dt) throw "Dict schema lacks format or childType";
52
+ if(dt===2 && s.c) throw "Cannot require both format and childType";
53
+ for(n of k) try {dt===2?checkSchema(d[n],s.f):checkType(d[n],s.c)}
54
+ catch(e) {throw errAt(n,e,1)}
51
55
  break; default:
52
56
  throw `Unknown type ${s.t} in schema`;
53
57
  }} catch(e) {el.push(e)}
@@ -61,7 +65,7 @@ function checkType(d,sr) {
61
65
 
62
66
  const R_FN=/\W+|(\w+)/g;
63
67
 
64
- function checkSchema(data, schema) {
68
+ function checkSchema(data, schema, ignoreReq) {
65
69
  if(!isDict(data)) throw "Data must be dict";
66
70
  if(!isDict(schema)) throw "Schema must be dict";
67
71
  let k,d,s,r,n,m;
@@ -71,6 +75,7 @@ function checkSchema(data, schema) {
71
75
  if(k.startsWith('$')) throw "Key cannot start with $";
72
76
  checkType(d,s);
73
77
  } catch(e) {throw errAt(k,e)}
78
+ if(ignoreReq) return;
74
79
  for(k in schema) if(!(k in data)) { //Check missing
75
80
  s=schema[k], r=typeof s.req==='string';
76
81
  if(r) { //Conditional req
package/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  //https://github.com/Pecacheu/Utils.js; GNU GPL v3
2
2
 
3
3
  'use strict';
4
- const utils = {VER:'v8.7.3'},
4
+ const utils = {VER:'v8.7.5'},
5
5
  _uNJS = typeof global!='undefined';
6
6
 
7
7
  //Node.js compat
@@ -27,33 +27,45 @@ utils.proto = (obj, name, val, st) => {
27
27
  else Object.defineProperty(obj,name,t);
28
28
  }
29
29
 
30
- //Cookie Parsing
31
- utils.setCookie = (name,value,exp,secure) => {
32
- let c=encodeURIComponent(name)+'='+(value==null?'':encodeURIComponent(value))+';path=/';
30
+ //Cookies! (Yum)
31
+ utils.setCookie = (key,value,exp,secure) => {
32
+ let c=`${encodeURIComponent(key)}=${value==null?'':encodeURIComponent(value)};path=/`;
33
33
  if(exp != null) {
34
- if(!(exp instanceof Date)) exp = new Date(exp);
35
- c+=';expires='+exp.toUTCString();
34
+ if(exp === -1) exp=new Date(Number.MAX_SAFE_INTEGER/10);
35
+ if(exp instanceof Date) c+=';expires='+exp.toUTCString();
36
+ else c+=';max-age='+exp;
36
37
  }
37
38
  if(secure) c+=';secure';
38
39
  if(_uNJS) return c;
39
40
  document.cookie=c;
40
41
  }
41
- utils.remCookie = name => {
42
- document.cookie = encodeURIComponent(name)+'=;expires='+new Date(0).toUTCString();
42
+ utils.remCookie = key => {
43
+ let c=encodeURIComponent(key)+'=;max-age=0';
44
+ if(_uNJS) return c;
45
+ document.cookie=c;
43
46
  }
44
- utils.getCookie = (name, cookies) => {
45
- if(cookies == null) cookies = document.cookie;
46
- const n1 = encodeURIComponent(name), n2 = ' '+n1, cl = cookies.split(';');
47
- for(let i=0,l=cl.length,c,eq,sub; i<l; ++i) {
48
- c = cl[i]; eq = c.indexOf('='); sub = c.substr(0,eq);
49
- if(sub == n1 || sub == n2) return decodeURIComponent(c.substr(eq+1));
47
+ utils.getCookies = ckStr => {
48
+ if(ckStr == null) ckStr=document.cookie;
49
+ if(!ckStr) return {};
50
+ let l=ckStr.split('; '),c,e,d={};
51
+ for(c of l) {
52
+ e=c.indexOf('=');
53
+ d[decodeURIComponent(c.slice(0,e))]=decodeURIComponent(c.slice(e+1));
50
54
  }
55
+ return d;
56
+ }
57
+ utils.getCookie = (key, ckStr) => {
58
+ if(ckStr == null) ckStr=document.cookie;
59
+ key=encodeURIComponent(key)+'=';
60
+ let l=ckStr.split('; '),c;
61
+ for(c of l) if(c.startsWith(key))
62
+ return decodeURIComponent(c.slice(key.length));
51
63
  }
52
64
 
53
65
  //Wrap a function so that it always has a preset argument list when called
54
66
  //In the called function, 'this' is set to the caller's arguments, granting access to both
55
67
  utils.proto(Function, 'wrap', function(/*...*/) {
56
- const f=this, a=arguments; return function() {f.apply(arguments,a)}
68
+ const f=this, a=arguments; return function() {return f.apply(arguments,a)}
57
69
  })
58
70
 
59
71
  //Deep (recursive) Object.create
@@ -71,29 +83,29 @@ utils.copy = (o, sub) => {
71
83
  utils.deviceInfo = ua => {
72
84
  const d={}; if(!ua) ua=navigator.userAgent;
73
85
  if(!ua.startsWith("Mozilla/5.0 ")) return d;
74
- let o=ua.indexOf(')'), os=d.rawOS=ua.substring(13,o), o2,o3;
86
+ let o=ua.indexOf(')'), os=d.rawOS=ua.slice(13,o), o2,o3;
75
87
  if(os.startsWith("Windows")) {
76
88
  o2=os.split('; '), d.os = "Windows";
77
89
  d.type = o2.indexOf('WOW64')!=-1?'x64 PC; x86 Browser':o2.indexOf('x64')!=-1?'x64 PC':'x86 PC';
78
- o2=os.indexOf("Windows NT "), d.version = os.substring(o2+11,os.indexOf(';',o2+12));
90
+ o2=os.indexOf("Windows NT "), d.version = os.slice(o2+11,os.indexOf(';',o2+12));
79
91
  } else if(os.startsWith("iP")) {
80
- o2=os.indexOf("OS"), d.os = "iOS", d.type = os.substr(0,os.indexOf(';'));
81
- d.version = os.substring(o2+3, os.indexOf(' ',o2+4)).replace(/_/g,'.');
92
+ o2=os.indexOf("OS"), d.os = "iOS", d.type = os.slice(0,os.indexOf(';'));
93
+ d.version = os.slice(o2+3, os.indexOf(' ',o2+4)).replace(/_/g,'.');
82
94
  } else if(os.startsWith("Macintosh;")) {
83
- o2=os.indexOf(" Mac OS X"), d.os = "MacOS", d.type = os.substring(11,o2)+" Mac";
84
- d.version = os.substr(o2+10).replace(/_/g,'.');
95
+ o2=os.indexOf(" Mac OS X"), d.os = "MacOS", d.type = os.slice(11,o2)+" Mac";
96
+ d.version = os.slice(o2+10).replace(/_/g,'.');
85
97
  } else if((o2=os.indexOf("Android"))!=-1) {
86
- d.os = "Android", d.version = os.substring(o2+8, os.indexOf(';',o2+9));
98
+ d.os = "Android", d.version = os.slice(o2+8, os.indexOf(';',o2+9));
87
99
  o2=os.lastIndexOf(';'), o3=os.indexOf(" Build",o2+2);
88
- d.type = os.substring(o2+2, o3==-1?undefined:o3);
100
+ d.type = os.slice(o2+2, o3==-1?undefined:o3);
89
101
  } else if(os.startsWith("X11;")) {
90
- os=os.substr(5).split(/[;\s]+/), o2=os.length;
102
+ os=os.slice(5).split(/[;\s]+/), o2=os.length;
91
103
  d.os = (os[0]=="Linux"?'':"Linux ")+os[0];
92
104
  d.type = os[o2-2], d.version = os[o2-1];
93
105
  }
94
106
  if(o2=Number(d.version)) d.version=o2;
95
107
  o2=ua.indexOf(' ',o+2), o3=ua.indexOf(')',o2+1), o3=o3==-1?o2+1:o3+2;
96
- d.engine = ua.substring(o+2,o2), d.browser = ua.substring(o3);
108
+ d.engine = ua.slice(o+2,o2), d.browser = ua.slice(o3);
97
109
  d.mobile = !!ua.match(/Mobi/i); return d;
98
110
  }
99
111
 
@@ -287,7 +299,7 @@ utils.formatDate = (d,opt={}) => {
287
299
  if(opt.time==null||opt.time) {
288
300
  let h=d.getHours(),pm=''; if(!opt.h24) {pm=' AM'; if(h>=12) pm=' PM',h-=12; if(!h) h=12}
289
301
  t=h+':'+fixed2(d.getMinutes())+(opt.sec?':'+fixed2(d.getSeconds())
290
- +(opt.ms?(d.getMilliseconds()/1000).toFixed(Number.isFinite(opt.ms)?opt.ms:3).substr(1):''):'');
302
+ +(opt.ms?(d.getMilliseconds()/1000).toFixed(Number.isFinite(opt.ms)?opt.ms:3).slice(1):''):'');
291
303
  t+=pm; if(opt.time) return t;
292
304
  }
293
305
  dd=d.getDate();
@@ -575,15 +587,15 @@ utils.cutStr = (s, rem) => {
575
587
  //index: Optional object. index.s and index.t will be set to start and end indexes
576
588
  utils.dCut = (d, ss, es, sd, st) => {
577
589
  let is = d.indexOf(ss,st?st:undefined)+ss.length, it = d.indexOf(es,is);
578
- if(sd) sd.s=is,sd.t=it; return (is < ss.length || it <= is)?'':d.substring(is,it);
590
+ if(sd) sd.s=is,sd.t=it; return (is < ss.length || it <= is)?'':d.slice(is,it);
579
591
  }
580
592
  utils.dCutToLast = (d, ss, es, sd, st) => {
581
593
  let is = d.indexOf(ss,st?st:undefined)+ss.length, it = d.lastIndexOf(es);
582
- if(sd) sd.s=is,sd.t=it; return (is < ss.length || it <= is)?'':d.substring(is,it);
594
+ if(sd) sd.s=is,sd.t=it; return (is < ss.length || it <= is)?'':d.slice(is,it);
583
595
  }
584
596
  utils.dCutLast = (d, ss, es, sd, st) => {
585
597
  let is = d.lastIndexOf(ss,st?st:undefined)+ss.length, it = d.indexOf(es,is);
586
- if(sd) sd.s=is,sd.t=it; return (is < ss.length || it <= is)?'':d.substring(is,it);
598
+ if(sd) sd.s=is,sd.t=it; return (is < ss.length || it <= is)?'':d.slice(is,it);
587
599
  }
588
600
 
589
601
  //Given CSS property value 'prop', returns object with
@@ -600,16 +612,14 @@ utils.parseCSS = prop => {
600
612
  }
601
613
  while(prop.length > 0) {
602
614
  if(prop[0] == '(' && prop.indexOf(')') !== -1 && pKey) {
603
- let end=prop.indexOf(')'), pStr=prop.substring(1, end);
615
+ let end=prop.indexOf(')'), pStr=prop.slice(1,end);
604
616
  pArr[pKey] = parseInner(pStr);
605
- pKey = ""; prop = prop.substring(end+1);
617
+ pKey = ""; prop = prop.slice(end+1);
606
618
  } else if(prop.search(/[#!\w]/) == 0) {
607
619
  if(pKey) pArr[keyNum++] = pKey;
608
620
  let end=prop.search(/[^#!\w-%]/); if(end==-1) end=prop.length;
609
- pKey = prop.substring(0, end); prop = prop.substring(end);
610
- } else {
611
- prop = prop.substring(1);
612
- }
621
+ pKey = prop.slice(0,end); prop = prop.slice(end);
622
+ } else prop = prop.slice(1);
613
623
  }
614
624
  if(pKey) pArr[keyNum] = pKey; return pArr;
615
625
  }
@@ -621,7 +631,7 @@ utils.buildCSS = propArr => {
621
631
  const k=keyArr[i], v=propArr[keyArr[i]]; ++i;
622
632
  if(0<=Number(k)) pStr+=v+' '; else pStr+=`${k}(${v}) `;
623
633
  }
624
- return pStr.substring(0, pStr.length-1);
634
+ return pStr.slice(0,-1);
625
635
  }
626
636
 
627
637
  function defaultStyle() {
@@ -664,10 +674,28 @@ utils.removeSelector = name => {
664
674
 
665
675
  //Converts HEX color to 24-bit RGB
666
676
  utils.hexToRgb = hex => {
667
- const c = parseInt(hex.substr(1), 16);
677
+ const c = parseInt(hex.slice(1),16);
668
678
  return [(c >> 16) & 255, (c >> 8) & 255, c & 255];
669
679
  }
670
680
 
681
+ //By mjackson @ GitHub
682
+ utils.rgbToHsl = (r,g,b) => {
683
+ r /= 255, g /= 255, b /= 255;
684
+ let max=Math.max(r,g,b), min=Math.min(r,g,b), h,s,l=(max+min)/2;
685
+ if(max===min) h=s=0; //Achromatic
686
+ else {
687
+ let d=max-min;
688
+ s=l>.5 ? d/(2-max-min) : d/(max+min);
689
+ switch(max) {
690
+ case r: h=(g-b)/d + (g<b?6:0); break;
691
+ case g: h=(b-r)/d + 2; break;
692
+ case b: h=(r-g)/d + 4;
693
+ }
694
+ h /= 6;
695
+ }
696
+ return [h*360, s*100, l*100];
697
+ }
698
+
671
699
  //Generates random integer from min to max
672
700
  utils.rand = (min, max, res, ease) => {
673
701
  res=res||1; max*=res,min*=res; let r=Math.random();
@@ -676,54 +704,51 @@ utils.rand = (min, max, res, ease) => {
676
704
 
677
705
  //Parses a url query string into an Object
678
706
  utils.fromQuery = str => {
679
- if(str.startsWith('?')) str = str.substr(1);
680
- function parse(params, pairs) {
681
- const pair = pairs[0], spl = pair.indexOf('='),
682
- key = decodeURIComponent(pair.substr(0,spl)),
683
- value = decodeURIComponent(pair.substr(spl+1));
684
- //Handle multiple parameters of the same name
685
- if(params[key] == null) params[key] = value;
686
- else if(typeof params[key] == 'array') params[key].push(value);
687
- else params[key] = [params[key],value];
688
- return pairs.length == 1 ? params : parse(params, pairs.slice(1));
689
- } return str.length == 0 ? {} : parse({}, str.split('&'));
707
+ if(str.startsWith('?')) str=str.slice(1);
708
+ function parse(pl, pairs) {
709
+ const pair=pairs[0], spl=pair.indexOf('='),
710
+ key=decodeURIComponent(pair.slice(0,spl)),
711
+ val=decodeURIComponent(pair.slice(spl+1));
712
+ //Handle multiple params of the same name
713
+ if(pl[key] == null) pl[key] = val;
714
+ else if(Array.isArray(pl[key])) pl[key].push(val);
715
+ else pl[key] = [pl[key],val];
716
+ return pairs.length===1 ? pl : parse(pl, pairs.slice(1));
717
+ }
718
+ return str ? parse({}, str.split('&')) : {};
690
719
  }
691
720
 
692
721
  //Converts an object into a url query string
693
722
  utils.toQuery = obj => {
694
- let str = ''; if(typeof obj != 'object') return encodeURIComponent(obj);
695
- for(let key in obj) {
696
- let val = obj[key]; if(typeof val == 'object') val = JSON.stringify(val);
723
+ let str='',key,val;
724
+ if(typeof obj !== 'object') return encodeURIComponent(obj);
725
+ for(key in obj) {
726
+ val = obj[key];
727
+ if(typeof val === 'object' && val != null) val = JSON.stringify(val);
697
728
  str += '&'+key+'='+encodeURIComponent(val);
698
- } return str.slice(1);
729
+ }
730
+ return str.slice(1);
699
731
  }
700
732
 
701
733
  //Various methods of centering objects using JavaScript
702
734
  //obj: Object to center
703
735
  //only: 'x' for only x axis centering, 'y' for only y axis, null for both
704
- //type: 'calc', 'trans', 'move', or null, modes explained below
736
+ //type: 'trans' or null, modes explained below
705
737
  utils.center = (obj, only, type) => {
706
738
  let os=obj.style;
707
- if(!os.position) os.position="absolute";
708
- if(type == 'calc') { //Responsive, but only if object size is static
709
- if(!only || only == "x") os.left=`calc(50% - ${obj.clientWidth/2}px)`;
710
- if(!only || only == "y") os.top=`calc(50% - ${obj.clientHeight/2}px)`;
711
- } else if(type == 'move') { //Not responsive
712
- if(!only || only == "x") os.left=`${utils.w/2 - obj.clientWidth/2}px`;
713
- if(!only || only == "y") os.top=`${utils.h/2 - obj.clientHeight/2}px`;
714
- } else if(type == 'trans') { //Responsive, doesn't create container
715
- let trans = utils.cutStr(os.transform, "translateX(-50%)");
716
- trans = utils.cutStr(trans, "translateY(-50%)");
717
- if(!only || only == "x") os.left="50%", trans+="translateX(-50%)";
718
- if(!only || only == "y") os.top="50%", trans+="translateY(-50%)";
739
+ if(type == 'trans') { //Responsive, doesn't create container
740
+ if(!os.position) os.position='absolute';
741
+ let trans=utils.cutStr(os.transform, 'translateX(-50%)');
742
+ trans=utils.cutStr(trans, 'translateY(-50%)');
743
+ if(!only || only == 'x') os.left='50%', trans+='translateX(-50%)';
744
+ if(!only || only == 'y') os.top='50%', trans+='translateY(-50%)';
719
745
  if(trans) os.transform=trans;
720
- } else { //Responsive, largest browser support
721
- let cont=utils.mkEl("div", obj.parentNode, null, {display:'table',
722
- position:'absolute', top:0, left:0, width:'100%', height:'100%'});
723
- cont.appendChild(obj); os.display="table-cell";
724
- if(!only || only == "x") os.textAlign="center";
725
- if(!only || only == "y") os.verticalAlign="middle";
726
- os.position="relative";
746
+ } else { //New flexbox method
747
+ let cont=utils.mkDiv(obj.parentNode, null, {display:'flex',
748
+ top:0, left:0, width:'100%', height:'100%'});
749
+ cont.appendChild(obj), cont=cont.style;
750
+ if(!only || only == 'x') cont.justifyContent='center';
751
+ if(!only || only == 'y') cont.alignItems='center', cont.position='absolute';
727
752
  }
728
753
  }
729
754
 
package/utils.min.js CHANGED
@@ -1,2 +1,2 @@
1
1
  //https://github.com/Pecacheu/Utils.js GNU GPL v3
2
- "use strict";const utils={VER:"v8.7.3"},_uNJS="undefined"!=typeof global;let UtilRect,P="undefined"==typeof window?[{},{back(){},forward(){}},class{},class{},class{},class{},()=>{}]:[window,history,DOMRect,HTMLCollection,Element,NodeList,addEventListener];(()=>{let[t,e,i,n,l,s,r]=P;function o(){switch(this.type){case"datetime-local":this.siT.textContent=utils.formatDate(utils.fromDateTimeBox(this));break;case"select-one":this.siT.textContent=u(this);break;case"select-multiple":this.siT.textContent=a(this)}}function u(t){let e=t.options;return -1!=e.selectedIndex?e[e.selectedIndex].label:"No Options Selected"}function a(t){let e=t.options,i="";for(let n=0,l=e.length;n<l;++n)e[n].selected&&(i+=(i?", ":"")+e[n].label);return i||"No Options Selected"}function d(t){return t<=9?"0"+t:t}utils.define=(t,e,i,n)=>{let l={};if(i&&(l.get=i),n&&(l.set=n),Array.isArray(e))for(let s of e)Object.defineProperty(t,s,l);else Object.defineProperty(t,e,l)},utils.proto=(t,e,i,n)=>{let l={value:i};if(n||(t=t.prototype),Array.isArray(e))for(let s of e)Object.defineProperty(t,s,l);else Object.defineProperty(t,e,l)},utils.setCookie=(t,e,i,n)=>{let l=encodeURIComponent(t)+"="+(null==e?"":encodeURIComponent(e))+";path=/";if(null!=i&&(i instanceof Date||(i=new Date(i)),l+=";expires="+i.toUTCString()),n&&(l+=";secure"),_uNJS)return l;document.cookie=l},utils.remCookie=t=>{document.cookie=encodeURIComponent(t)+"=;expires="+new Date(0).toUTCString()},utils.getCookie=(t,e)=>{null==e&&(e=document.cookie);let i=encodeURIComponent(t),n=" "+i,l=e.split(";");for(let s=0,r=l.length,o,u,a;s<r;++s)if(u=(o=l[s]).indexOf("="),(a=o.substr(0,u))==i||a==n)return decodeURIComponent(o.substr(u+1))},utils.proto(Function,"wrap",function(){let t=this,e=arguments;return function(){t.apply(arguments,e)}}),utils.copy=(t,e)=>{if(0===e||"object"!=typeof t)return t;e=e>0?e-1:null;let i;if(Array.isArray(t))i=Array(t.length),t.forEach((t,n)=>{i[n]=utils.copy(t,e)});else for(let n in i={},t)i[n]=utils.copy(t[n],e);return i},utils.deviceInfo=t=>{let e={};if(t||(t=navigator.userAgent),!t.startsWith("Mozilla/5.0 "))return e;let i=t.indexOf(")"),n=e.rawOS=t.substring(13,i),l,s;return n.startsWith("Windows")?(l=n.split("; "),e.os="Windows",e.type=-1!=l.indexOf("WOW64")?"x64 PC; x86 Browser":-1!=l.indexOf("x64")?"x64 PC":"x86 PC",l=n.indexOf("Windows NT "),e.version=n.substring(l+11,n.indexOf(";",l+12))):n.startsWith("iP")?(l=n.indexOf("OS"),e.os="iOS",e.type=n.substr(0,n.indexOf(";")),e.version=n.substring(l+3,n.indexOf(" ",l+4)).replace(/_/g,".")):n.startsWith("Macintosh;")?(l=n.indexOf(" Mac OS X"),e.os="MacOS",e.type=n.substring(11,l)+" Mac",e.version=n.substr(l+10).replace(/_/g,".")):-1!=(l=n.indexOf("Android"))?(e.os="Android",e.version=n.substring(l+8,n.indexOf(";",l+9)),l=n.lastIndexOf(";"),s=n.indexOf(" Build",l+2),e.type=n.substring(l+2,-1==s?void 0:s)):n.startsWith("X11;")&&(l=(n=n.substr(5).split(/[;\s]+/)).length,e.os=("Linux"==n[0]?"":"Linux ")+n[0],e.type=n[l-2],e.version=n[l-1]),(l=Number(e.version))&&(e.version=l),l=t.indexOf(" ",i+2),s=-1==(s=t.indexOf(")",l+1))?l+1:s+2,e.engine=t.substring(i+2,l),e.browser=t.substring(s),e.mobile=!!t.match(/Mobi/i),e},_uNJS||(utils.device=utils.deviceInfo(),utils.mobile=utils.device.mobile),t.TouchList&&utils.proto(TouchList,"get",function(t){for(let e in this)if(this[e].identifier==t)return this[e];return 0}),utils.skinnedInput=t=>{let e=utils.mkDiv(null,t.className),i=t.style,n=t.type;if(t.className+=" isSub","datetime-local"==n||"select-one"==n||"select-multiple"==n){i.opacity=0,i.top="-100%",t.siT=utils.mkEl("span",e,"isText"),utils.mkEl("span",e,"isArrow",{borderTopColor:getComputedStyle(t).color});let l=o.bind(t);t.addEventListener("change",l),t.forceUpdate=l,l()}t.replaceWith(e),e.appendChild(t),document.isStyles||(document.isStyles=!0,utils.mkEl("style",document.body,null,null,".isSub {width:100% !important; height:100% !important; border:none !important; display:inline-block !important;position:relative !important; box-shadow:none !important; margin:0 !important; padding:initial !important;} .isText {display:inline-block; height:100%; max-width:95%;overflow:hidden; text-overflow:ellipsis; white-space:nowrap;} .isArrow {width:0; height:0; display:inline-block; float:right; top:38%; position:relative;border-left:3px solid transparent; border-right:3px solid transparent;border-top:6px solid #000; vertical-align:middle;}"))},utils.numField=(t,e,i,n,l)=>{let s=RegExp(`[,${l?RegExp.escape(l):""}]`,"g");return t.type=utils.mobile||n||l?"tel":"number",t.setAttribute("pattern","\\d*"),null==e&&(e=Number.MIN_SAFE_INTEGER),null==i&&(i=Number.MAX_SAFE_INTEGER),null==n&&(n=l?2:0),t.step||(t.step=1),t.num=Math.max(0,e),t.ns="",t.value=l?utils.formatCost(t.num,l):t.num.toString(),t.addEventListener("keydown",s=>{if(s.ctrlKey)return;let r=s.key,o=1==r.length&&Number.isFinite(Number(r)),u=t.ns,a=u.length,d=u.indexOf(".");if("Tab"!=r&&"Enter"!=r){if(o?(-1==d||a-d<n+1)&&(u+=r):"."==r||"*"==r?n&&-1==d&&t.num!=i&&(e>=0||t.num!=e)&&(!a&&e>0?u=Math.floor(e)+".":u+="."):"Backspace"==r||"Delete"==r?u=e>0&&t.num==e&&u.endsWith(".")?"":u.slice(0,-1):"-"==r||"#"==r?e<0&&!a&&(u="-"):"ArrowUp"==r?(u=null,t.set(t.num+Number(t.step))):"ArrowDown"==r&&(u=null,t.set(t.num-Number(t.step))),null!==u&&u!==t.ns){let f="-"==u||"-."==u,c=Number(f?"0":u+(u.endsWith(".")?"0":"")),h=Math.min(i,Math.max(e,c));(!o||t.num!==h||c===e)&&(t.ns=u,t.num=h,t.value=l?f?l+"-0.00":utils.formatCost(h,l):(f?"-":"")+h+(u.endsWith(".")&&(e<=0||h!=e)?".0":""),t.onnuminput&&t.onnuminput.call(t))}s.preventDefault()}}),t.set=r=>{"string"==typeof r&&(r=r.replace(s,"")),r=Math.min(i,Math.max(e,Number(r)||0)),t.num=n?Number(r.toFixed(n)):Math.round(r),t.ns=t.num.toString(),t.value=l?utils.formatCost(t.num,l):t.ns,t.ns=t.ns.replace(/^(-?)0+/,"$1"),t.onnuminput&&t.onnuminput.call(t)},t.setRange=(t,l,s)=>{e=t,i=l,n=s},t.addEventListener("input",()=>t.set(t.value)),t.addEventListener("paste",e=>{t.set(e.clipboardData.getData("text")),e.preventDefault()}),t},utils.autosize=(t,e=5,i=1)=>{t.set=e=>{t.value=e,l()};let n=t.style;function l(){if(0===t.scrollHeight)return setTimeout(l,1);t.setAttribute("rows",1);let s=getComputedStyle(t);n.setProperty("overflow","hidden","important"),n.width=t.innerRect.w+"px",n.boxSizing="content-box",n.borderWidth=n.paddingInline=0;let r=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom),o="normal"===s.lineHeight?parseFloat(s.height):parseFloat(s.lineHeight),u=Math.round((Math.round(t.scrollHeight)-r)/o);n.overflow=n.width=n.boxSizing=n.borderWidth=n.paddingInline="",t.setAttribute("rows",utils.bounds(u,i,e))}n.maxHeight=n.resize="none",n.minHeight=0,n.height="auto",t.setAttribute("rows",i),t.addEventListener("input",l)},utils.formatCost=(t,e="$")=>{if(!t)return e+"0.00";let i=t.toFixed(2).split(".");return e+i[0].split("").reverse().reduce((t,e,i)=>"-"==e?e+t:e+(i&&!(i%3)?",":"")+t,"")+"."+i[1]},utils.fromDateTimeBox=t=>{let e=t.value;return e?new Date(e.replace(/-/g,"/").replace(/T/g," ")):new Date},utils.fixedNum=function(t,e,i=10){let n=Math.abs(t).toString(i).toUpperCase();return(t<0?"-":"")+(16==i?"0x":2==i?"0b":"")+"0".repeat(Math.max(e-n.length,0))+n},utils.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],utils.toDateTimeBox=(t,e)=>t.getFullYear()+"-"+d(t.getMonth()+1)+"-"+d(t.getDate())+"T"+d(t.getHours())+":"+d(t.getMinutes())+(e?":"+d(t.getSeconds()):""),utils.formatDate=(t,e={})=>{let i="",n,l;if(null==t||!t.getDate||!((n=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let s=t.getHours(),r="";if(e.h24||(r=" AM",s>=12&&(r=" PM",s-=12),s||(s=12)),i=s+":"+d(t.getMinutes())+(e.sec?":"+d(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).substr(1):""):""),i+=r,e.time)return i}return l=t.getDate(),l=utils.months[t.getMonth()]+" "+(null==e.suf||e.suf?utils.suffix(l):l),(null==e.year||e.year)&&e.year!==n&&(l=l+", "+n),e.df?l+(i&&" "+i):(i&&i+" ")+l},utils.suffix=t=>{let e=t%10,i=t%100;return 1==e&&11!=i?t+"st":2==e&&12!=i?t+"nd":3==e&&13!=i?t+"rd":t+"th"};let f=e;function c(t){utils.onNav&&utils.onNav.call(null,t)}function h(t,e,i){let l=this.length,s=Math.max(e<0?l+e:e||0,0),r;for(null!=i&&(l=Math.min(i<0?l+i:i,l));s<l;++s)if("!"===(r=t(this[s],s,l)))this instanceof n?this[s].remove():this.splice(s,1),--s,--l;else if(null!=r)return r}async function p(t,e,i,l=!0){let s=this.length,r=e=Math.max(e<0?s+e:e||0,0),o,u=[];for(null!=i&&(s=Math.min(i<0?s+i:i,s));r<s;++r){if(o=t(this[r],r,s),!l&&"!"!==(o=await o)&&null!=o)return o;u.push(o)}for(l&&(u=await Promise.all(u)),r=e,o=0;r<s;++r,++o)if("!"===u[o])this instanceof n?this[r].remove():this.splice(r,1),--r,--s;else if(null!=u[o])return u[o]}utils.goBack=f.back.bind(f),utils.goForward=f.forward.bind(f),utils.go=(t,e)=>{f.pushState(e,"",t||location.pathname),c(e)},r("popstate",t=>c(t.state)),r("load",()=>setTimeout(c.wrap(f.state),1)),utils.mkEl=(t,e,i,n,l)=>{let s=document.createElement(t);if(null!=i&&(s.className=i),null!=l&&(s.innerHTML=l),n&&"object"==typeof n)for(let r in n)r in s.style?s.style[r]=n[r]:s.style.setProperty(r,n[r]);return null!=e&&e.appendChild(s),s},utils.mkDiv=(t,e,i,n)=>utils.mkEl("div",t,e,i,n),utils.addText=(t,e)=>t.appendChild(document.createTextNode(e)),utils.textWidth=(e,i)=>{let n=t.TWCanvas||(t.TWCanvas=utils.mkEl("canvas")),l=n.getContext("2d");return l.font=i,l.measureText(e).width},utils.define(utils,"w",()=>innerWidth),utils.define(utils,"h",()=>innerHeight),utils.setPropSafe=(t,e,i,n=!1)=>{"string"==typeof e&&(e=e.split("."));let l=e.length-1;return(e.each(e=>{t="object"==typeof t[e]?t[e]:t[e]={}},0,l),l=e[l],n&&null!=t[l])?t[l]:t[l]=i},utils.getPropSafe=(t,e)=>{"string"==typeof e&&(e=e.split("."));try{for(let i of e)t=t[i];return t}catch(n){}},utils.proto(Array,"clean",function(t){for(let e=0,i,n=this.length;e<n;++e)i=this[e],(utils.isBlank(i)||!1===i||!t&&0===i)&&(this.splice(e--,1),n--);return this}),utils.proto(Array,"remove",function(t){let e=this.indexOf(t);return -1!=e&&(this.splice(e,1),!0)}),[Array,n,s].forEach(t=>{utils.proto(t,"each",h),utils.proto(t,"eachAsync",p)});let $="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=$.replace("+/","-_"),g={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 m(t,e){if(null==(t=g[t.charCodeAt(e)]))throw"Bad char at "+e;return t}"toBase64"in Uint8Array.prototype||utils.proto(Uint8Array,"toBase64",function(t){let e=this.byteLength,i=e%3,n=t&&"base64url"===t.alphabet?_:$,l=0,s="",r;for(e-=i;l<e;l+=3)s+=n[(16515072&(r=this[l]<<16|this[l+1]<<8|this[l+2]))>>18]+n[(258048&r)>>12]+n[(4032&r)>>6]+n[63&r];return 1==i?(s+=n[(252&(r=this[e]))>>2]+n[(3&r)<<4],t&&t.omitPadding||(s+="=")):2!=i||(s+=n[(64512&(r=this[e]<<8|this[e+1]))>>10]+n[(1008&r)>>4]+n[(15&r)<<2],t&&t.omitPadding||(s+="==")),s}),"fromBase64"in Uint8Array||utils.proto(Uint8Array,"fromBase64",t=>{let e=t.length,i=e-1;for(;i>=0&&61===t.charCodeAt(i);--i);e=i+1,i=0;let n=e%4;if(e-=n,1==n)throw"Bad b64 len";let l=new Uint8Array(3*e/4+(n?n-1:0)),s=-1,r;for(;i<e;i+=4)r=m(t,i)<<18|m(t,i+1)<<12|m(t,i+2)<<6|m(t,i+3),l[++s]=r>>16,l[++s]=r>>8,l[++s]=r;return 2==n?l[++s]=m(t,i)<<2|m(t,i+1)>>4:3==n&&(r=m(t,i)<<10|m(t,i+1)<<4|m(t,i+2)>>2,l[++s]=r>>8,l[++s]=r),l},1);let y=/[|\\{}()[\]^$+*?.]/g,x=/-/g;function b(t,e){for(;t>=e;)t-=e;return t}function v(){let t=document.styleSheets;for(let e=0,i=t.length;e<i;++e)try{return t[e].cssRules,t[e]}catch(n){}let l=utils.mkEl("style",document.head);return utils.addText(l,""),l.sheet}function w(t){return t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}"escape"in RegExp||utils.proto(RegExp,"escape",t=>t.replace(y,"\\$&").replace(x,"\\x2d"),1),utils.define(l.prototype,"index",function(){let t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),utils.proto(l,"insertChildAt",function(t,e){e<0&&(e=0),e>=this.children.length?this.appendChild(t):this.insertBefore(t,this.children[e])}),utils.boundingRect=t=>new UtilRect(t.getBoundingClientRect()),utils.innerRect=t=>{let e=t.getBoundingClientRect(),i=getComputedStyle(t);return new UtilRect(e.top+parseFloat(i.paddingTop)+parseFloat(i.borderTopWidth),e.bottom-parseFloat(i.paddingBottom)-parseFloat(i.borderBottomWidth),e.left+parseFloat(i.paddingLeft)+parseFloat(i.borderLeftWidth),e.right-parseFloat(i.paddingRight)-parseFloat(i.borderRightWidth))},utils.define(l.prototype,"boundingRect",function(){return utils.boundingRect(this)}),utils.define(l.prototype,"innerRect",function(){return utils.innerRect(this)}),Math.cot=t=>1/Math.tan(t),utils.isBlank=t=>null==t||("string"==typeof t?!/\S/.test(t):"object"==typeof t&&("number"==typeof t.length?0===t.length:0===Object.keys(t).length)),utils.firstEmpty=t=>{let e=t.length;for(let i=0;i<e;++i)if(null==t[i])return i;return e},utils.firstEmptyChar=t=>{let e=Object.keys(t),i=e.length;for(let n=0;n<i;++n)if(null==t[e[n]])return e[n];return utils.numToChar(i)},utils.numToChar=t=>{if(t<=25)return String.fromCharCode(t+97);if(t>=26&&t<=51)return String.fromCharCode(t+39);let e,i;if(t<2756)e=b(Math.floor(t/52)-1,52),i=b(t,52);else if(t<143364)e=b(Math.floor((t-52)/2704)-1,52),i=b(t-52,2704)+52;else{if(!(t<7454980))return!1;e=b(Math.floor((t-2756)/140608)-1,52),i=b(t-2756,140608)+2756}return utils.numToChar(e)+utils.numToChar(i)},utils.merge=function(t){for(let e=1,i=arguments.length,n,l,s;e<i;++e)for(let r in n=arguments[e]){if(l=t[r],s=n[r],l&&s){if(l.length>=0&&s.length>=0){for(let o=0,u=s.length,a=l.length;o<u;++o)l[o+a]=s[o];continue}if("object"==typeof l&&"object"==typeof s){for(let d in s)l[d]=s[d];continue}}t[r]=s}return t},utils.bounds=(t,e=0,i=1)=>t>=e?t<=i?t:i:e,utils.norm=utils.normalize=(t,e=0,i=1)=>{let n=Math.abs(i-e);if(t<e)for(;t<e;)t+=n;else for(;t>=i;)t-=n;return t},utils.cutStr=(t,e)=>{let i;for(;-1!=(i=t.indexOf(e));)t=t.slice(0,i)+t.slice(i+e.length);return t},utils.dCut=(t,e,i,n,l)=>{let s=t.indexOf(e,l||void 0)+e.length,r=t.indexOf(i,s);return n&&(n.s=s,n.t=r),s<e.length||r<=s?"":t.substring(s,r)},utils.dCutToLast=(t,e,i,n,l)=>{let s=t.indexOf(e,l||void 0)+e.length,r=t.lastIndexOf(i);return n&&(n.s=s,n.t=r),s<e.length||r<=s?"":t.substring(s,r)},utils.dCutLast=(t,e,i,n,l)=>{let s=t.lastIndexOf(e,l||void 0)+e.length,r=t.indexOf(i,s);return n&&(n.s=s,n.t=r),s<e.length||r<=s?"":t.substring(s,r)},utils.parseCSS=t=>{let e={},i="",n=0;function l(t){if(-1!==t.indexOf(",")){let e=utils.clean(t.split(","));for(let i=0,n=e.length;i<n;++i)e[i]=e[i].trim();return e}return t.trim()}for(t=t.trim();t.length>0;)if("("==t[0]&&-1!==t.indexOf(")")&&i){let s=t.indexOf(")"),r=t.substring(1,s);e[i]=l(r),i="",t=t.substring(s+1)}else if(0==t.search(/[#!\w]/)){i&&(e[n++]=i);let o=t.search(/[^#!\w-%]/);-1==o&&(o=t.length),i=t.substring(0,o),t=t.substring(o)}else t=t.substring(1);return i&&(e[n]=i),e},utils.buildCSS=t=>{let e=Object.keys(t),i=e.length,n="",l=0;for(;l<i;){let s=e[l],r=t[e[l]];++l,0<=Number(s)?n+=r+" ":n+=`${s}(${r}) `}return n.substring(0,n.length-1)},utils.addClass=(t,e)=>{let i=v(),n=Object.keys(e),l="";for(let s=0,r=n.length;s<r;++s)l+=w(n[s])+":"+e[n[s]]+";";i.addRule("."+t,l)},utils.addId=(t,e)=>{let i=v(),n=Object.keys(e),l="";for(let s=0,r=n.length;s<r;++s)l+=w(n[s])+":"+e[n[s]]+";";i.addRule("#"+t,l)},utils.addKeyframe=(t,e)=>{v().addRule("@keyframes "+t,e)},utils.removeSelector=t=>{for(let e=0,i,n,l=document.styleSheets.length;e<l;++e){i=document.styleSheets[e];try{n=i.cssRules}catch(s){continue}for(let r in n)"CSSStyleRule"==n[r].constructor.name&&n[r].selectorText==t&&i.deleteRule(r)}},utils.hexToRgb=t=>{let e=parseInt(t.substr(1),16);return[e>>16&255,e>>8&255,255&e]},utils.rand=(t,e,i,n)=>{e*=i=i||1,t*=i;let l=Math.random();return Math.round((n?n(l):l)*(e-t)+t)/i},utils.fromQuery=t=>{function e(t,i){let n=i[0],l=n.indexOf("="),s=decodeURIComponent(n.substr(0,l)),r=decodeURIComponent(n.substr(l+1));return null==t[s]?t[s]=r:"array"==typeof t[s]?t[s].push(r):t[s]=[t[s],r],1==i.length?t:e(t,i.slice(1))}return t.startsWith("?")&&(t=t.substr(1)),0==t.length?{}:e({},t.split("&"))},utils.toQuery=t=>{let e="";if("object"!=typeof t)return encodeURIComponent(t);for(let i in t){let n=t[i];"object"==typeof n&&(n=JSON.stringify(n)),e+="&"+i+"="+encodeURIComponent(n)}return e.slice(1)},utils.center=(t,e,i)=>{let n=t.style;if(n.position||(n.position="absolute"),"calc"==i)e&&"x"!=e||(n.left=`calc(50% - ${t.clientWidth/2}px)`),e&&"y"!=e||(n.top=`calc(50% - ${t.clientHeight/2}px)`);else if("move"==i)e&&"x"!=e||(n.left=`${utils.w/2-t.clientWidth/2}px`),e&&"y"!=e||(n.top=`${utils.h/2-t.clientHeight/2}px`);else if("trans"==i){let l=utils.cutStr(n.transform,"translateX(-50%)");l=utils.cutStr(l,"translateY(-50%)"),e&&"x"!=e||(n.left="50%",l+="translateX(-50%)"),e&&"y"!=e||(n.top="50%",l+="translateY(-50%)"),l&&(n.transform=l)}else utils.mkEl("div",t.parentNode,null,{display:"table",position:"absolute",top:0,left:0,width:"100%",height:"100%"}).appendChild(t),n.display="table-cell",e&&"x"!=e||(n.textAlign="center"),e&&"y"!=e||(n.verticalAlign="middle"),n.position="relative"},utils.loadAjax=(t,e,i,n,l)=>{let s;try{s=new XMLHttpRequest}catch(r){return e(r)}if(l)for(let o in l)s.setRequestHeader(o,l[o]);s.open(i||"GET",t),s.onreadystatechange=()=>{let t=s.status||-1;s.readyState==s.DONE&&e(200==t?0:t,s.response,s)},s.send(n||void 0)},utils.loadFile=(t,e,i)=>{let n=utils.mkEl("object",document.body,null,{position:"fixed",opacity:0});n.data=t;let l=setTimeout(()=>{n.remove(),l=null,e(!1)},i||4e3);n.onload=()=>{l&&(clearTimeout(l),e(n.contentDocument.documentElement.outerHTML),n.remove())}},utils.loadJSONP=(t,e,i)=>{let n=utils.mkEl("script",document.head),l=utils.firstEmptyChar(utils.lJSONCall);n.type="application/javascript",n.src=t+(-1==t.indexOf("?")?"?":"&")+"callback=utils.lJSONCall."+l;let s=setTimeout(()=>{delete utils.lJSONCall[l],e(!1)},i||4e3);utils.lJSONCall[l]=t=>{s&&clearTimeout(s),delete utils.lJSONCall[l],e(t)},document.head.removeChild(n)},utils.lJSONCall=[],utils.dlFile=(t,e)=>fetch(e).then(t=>{if(200!=t.status)throw"Code "+t.status;return t.blob()}).then(e=>{utils.dlData(t,e)}),utils.dlData=(t,e)=>{let i,n=utils.mkEl("a",document.body,null,{display:"none"});"string"==typeof e?i=e:(e instanceof Blob||(e=Blob(e)),i=URL.createObjectURL(e)),n.href=i,n.download=t,n.click(),n.remove(),URL.revokeObjectURL(i)},utils.deg=t=>180*t/Math.PI,utils.rad=t=>t*Math.PI/180,utils.map=(t,e,i,n,l,s)=>{let r=(t-e)/(i-e);return(s?s(r):r)*(l-n)+n},utils.delay=t=>new Promise(e=>setTimeout(e,t)),UtilRect=function(t,e,n,l){if(!(this instanceof UtilRect))return new UtilRect(t,e,n,l);let s=Number.isFinite,r=0,o=0,u=0,a=0;utils.define(this,"x",()=>u,t=>{s(t)&&(a+=t-u,u=t)}),utils.define(this,"y",()=>r,t=>{s(t)&&(o+=t-r,r=t)}),utils.define(this,"top",()=>r,t=>{r=s(t)?t:0}),utils.define(this,["bottom","y2"],()=>o,t=>{o=s(t)?t:0}),utils.define(this,"left",()=>u,t=>{u=s(t)?t:0}),utils.define(this,["right","x2"],()=>a,t=>{a=s(t)?t:0}),utils.define(this,["width","w"],()=>a-u,t=>{a=t>=0?u+t:0}),utils.define(this,["height","h"],()=>o-r,t=>{o=t>=0?r+t:0}),utils.define(this,"centerX",()=>u/2+a/2),utils.define(this,"centerY",()=>r/2+o/2),t instanceof i||t instanceof UtilRect?(r=t.top,o=t.bottom,u=t.left,a=t.right):(r=t,o=e,u=n,a=l)},utils.proto(UtilRect,"contains",function(t,e){return t instanceof l?this.contains(t.boundingRect):t instanceof UtilRect?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}),utils.proto(UtilRect,"overlaps",function(t){if(t instanceof l)return this.overlaps(t.boundingRect);if(!(t instanceof UtilRect))return 0;let e,i;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,i=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&&i}),utils.proto(UtilRect,"dist",function(t,e){if(t instanceof l)return this.dist(t.boundingRect);let i=t instanceof UtilRect;return e=Math.abs((i?t.centerY:e)-this.centerY),Math.sqrt((t=Math.abs((i?t.centerX:t)-this.centerX))*t+e*e)}),utils.proto(UtilRect,"expand",function(t){return this.top-=t,this.left-=t,this.bottom+=t,this.right+=t,this})})();const Easing={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,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};if(_uNJS&&!global.utils){let t=import("os").then(e=>t=e);utils.getIPs=()=>{let e=[],i=t.networkInterfaces();for(let n in i)i[n].forEach(t=>{!t.internal&&"IPv4"==t.family&&"00:00:00:00:00:00"!=t.mac&&t.address&&e.push(t.address)});return e.length?e:0},utils.getOS=()=>{let e,i,n;switch(t.platform()){case"win32":e="Windows";break;case"darwin":e="MacOS";break;case"linux":e="Linux";break;default:e=t.platform()}switch(t.arch()){case"ia32":i="32-bit";break;case"x64":i="64-bit";break;case"arm":i="ARM";break;default:i=t.arch()}return[e,i,n=t.cpus()[0].model]},global.utils=utils,global.UtilRect=UtilRect,global.Easing=Easing}
2
+ "use strict";const utils={VER:"v8.7.5"},_uNJS="undefined"!=typeof global;let UtilRect,P="undefined"==typeof window?[{},{back(){},forward(){}},class{},class{},class{},class{},()=>{}]:[window,history,DOMRect,HTMLCollection,Element,NodeList,addEventListener];(()=>{let[t,e,i,l,n,s,r]=P;function o(){switch(this.type){case"datetime-local":this.siT.textContent=utils.formatDate(utils.fromDateTimeBox(this));break;case"select-one":this.siT.textContent=u(this);break;case"select-multiple":this.siT.textContent=a(this)}}function u(t){let e=t.options;return -1!=e.selectedIndex?e[e.selectedIndex].label:"No Options Selected"}function a(t){let e=t.options,i="";for(let l=0,n=e.length;l<n;++l)e[l].selected&&(i+=(i?", ":"")+e[l].label);return i||"No Options Selected"}function c(t){return t<=9?"0"+t:t}utils.define=(t,e,i,l)=>{let n={};if(i&&(n.get=i),l&&(n.set=l),Array.isArray(e))for(let s of e)Object.defineProperty(t,s,n);else Object.defineProperty(t,e,n)},utils.proto=(t,e,i,l)=>{let n={value:i};if(l||(t=t.prototype),Array.isArray(e))for(let s of e)Object.defineProperty(t,s,n);else Object.defineProperty(t,e,n)},utils.setCookie=(t,e,i,l)=>{let n=`${encodeURIComponent(t)}=${null==e?"":encodeURIComponent(e)};path=/`;if(null!=i&&(-1===i&&(i=new Date(Number.MAX_SAFE_INTEGER/10)),i instanceof Date?n+=";expires="+i.toUTCString():n+=";max-age="+i),l&&(n+=";secure"),_uNJS)return n;document.cookie=n},utils.remCookie=t=>{let e=encodeURIComponent(t)+"=;max-age=0";if(_uNJS)return e;document.cookie=e},utils.getCookies=t=>{if(null==t&&(t=document.cookie),!t)return{};let e=t.split("; "),i,l,n={};for(i of e)l=i.indexOf("="),n[decodeURIComponent(i.slice(0,l))]=decodeURIComponent(i.slice(l+1));return n},utils.getCookie=(t,e)=>{null==e&&(e=document.cookie),t=encodeURIComponent(t)+"=";let i=e.split("; "),l;for(l of i)if(l.startsWith(t))return decodeURIComponent(l.slice(t.length))},utils.proto(Function,"wrap",function(){let t=this,e=arguments;return function(){return t.apply(arguments,e)}}),utils.copy=(t,e)=>{if(0===e||"object"!=typeof t)return t;e=e>0?e-1:null;let i;if(Array.isArray(t))i=Array(t.length),t.forEach((t,l)=>{i[l]=utils.copy(t,e)});else for(let l in i={},t)i[l]=utils.copy(t[l],e);return i},utils.deviceInfo=t=>{let e={};if(t||(t=navigator.userAgent),!t.startsWith("Mozilla/5.0 "))return e;let i=t.indexOf(")"),l=e.rawOS=t.slice(13,i),n,s;return l.startsWith("Windows")?(n=l.split("; "),e.os="Windows",e.type=-1!=n.indexOf("WOW64")?"x64 PC; x86 Browser":-1!=n.indexOf("x64")?"x64 PC":"x86 PC",n=l.indexOf("Windows NT "),e.version=l.slice(n+11,l.indexOf(";",n+12))):l.startsWith("iP")?(n=l.indexOf("OS"),e.os="iOS",e.type=l.slice(0,l.indexOf(";")),e.version=l.slice(n+3,l.indexOf(" ",n+4)).replace(/_/g,".")):l.startsWith("Macintosh;")?(n=l.indexOf(" Mac OS X"),e.os="MacOS",e.type=l.slice(11,n)+" Mac",e.version=l.slice(n+10).replace(/_/g,".")):-1!=(n=l.indexOf("Android"))?(e.os="Android",e.version=l.slice(n+8,l.indexOf(";",n+9)),n=l.lastIndexOf(";"),s=l.indexOf(" Build",n+2),e.type=l.slice(n+2,-1==s?void 0:s)):l.startsWith("X11;")&&(n=(l=l.slice(5).split(/[;\s]+/)).length,e.os=("Linux"==l[0]?"":"Linux ")+l[0],e.type=l[n-2],e.version=l[n-1]),(n=Number(e.version))&&(e.version=n),n=t.indexOf(" ",i+2),s=-1==(s=t.indexOf(")",n+1))?n+1:s+2,e.engine=t.slice(i+2,n),e.browser=t.slice(s),e.mobile=!!t.match(/Mobi/i),e},_uNJS||(utils.device=utils.deviceInfo(),utils.mobile=utils.device.mobile),t.TouchList&&utils.proto(TouchList,"get",function(t){for(let e in this)if(this[e].identifier==t)return this[e];return 0}),utils.skinnedInput=t=>{let e=utils.mkDiv(null,t.className),i=t.style,l=t.type;if(t.className+=" isSub","datetime-local"==l||"select-one"==l||"select-multiple"==l){i.opacity=0,i.top="-100%",t.siT=utils.mkEl("span",e,"isText"),utils.mkEl("span",e,"isArrow",{borderTopColor:getComputedStyle(t).color});let n=o.bind(t);t.addEventListener("change",n),t.forceUpdate=n,n()}t.replaceWith(e),e.appendChild(t),document.isStyles||(document.isStyles=!0,utils.mkEl("style",document.body,null,null,".isSub {width:100% !important; height:100% !important; border:none !important; display:inline-block !important;position:relative !important; box-shadow:none !important; margin:0 !important; padding:initial !important;} .isText {display:inline-block; height:100%; max-width:95%;overflow:hidden; text-overflow:ellipsis; white-space:nowrap;} .isArrow {width:0; height:0; display:inline-block; float:right; top:38%; position:relative;border-left:3px solid transparent; border-right:3px solid transparent;border-top:6px solid #000; vertical-align:middle;}"))},utils.numField=(t,e,i,l,n)=>{let s=RegExp(`[,${n?RegExp.escape(n):""}]`,"g");return t.type=utils.mobile||l||n?"tel":"number",t.setAttribute("pattern","\\d*"),null==e&&(e=Number.MIN_SAFE_INTEGER),null==i&&(i=Number.MAX_SAFE_INTEGER),null==l&&(l=n?2:0),t.step||(t.step=1),t.num=Math.max(0,e),t.ns="",t.value=n?utils.formatCost(t.num,n):t.num.toString(),t.addEventListener("keydown",s=>{if(s.ctrlKey)return;let r=s.key,o=1==r.length&&Number.isFinite(Number(r)),u=t.ns,a=u.length,c=u.indexOf(".");if("Tab"!=r&&"Enter"!=r){if(o?(-1==c||a-c<l+1)&&(u+=r):"."==r||"*"==r?l&&-1==c&&t.num!=i&&(e>=0||t.num!=e)&&(!a&&e>0?u=Math.floor(e)+".":u+="."):"Backspace"==r||"Delete"==r?u=e>0&&t.num==e&&u.endsWith(".")?"":u.slice(0,-1):"-"==r||"#"==r?e<0&&!a&&(u="-"):"ArrowUp"==r?(u=null,t.set(t.num+Number(t.step))):"ArrowDown"==r&&(u=null,t.set(t.num-Number(t.step))),null!==u&&u!==t.ns){let d="-"==u||"-."==u,f=Number(d?"0":u+(u.endsWith(".")?"0":"")),h=Math.min(i,Math.max(e,f));(!o||t.num!==h||f===e)&&(t.ns=u,t.num=h,t.value=n?d?n+"-0.00":utils.formatCost(h,n):(d?"-":"")+h+(u.endsWith(".")&&(e<=0||h!=e)?".0":""),t.onnuminput&&t.onnuminput.call(t))}s.preventDefault()}}),t.set=r=>{"string"==typeof r&&(r=r.replace(s,"")),r=Math.min(i,Math.max(e,Number(r)||0)),t.num=l?Number(r.toFixed(l)):Math.round(r),t.ns=t.num.toString(),t.value=n?utils.formatCost(t.num,n):t.ns,t.ns=t.ns.replace(/^(-?)0+/,"$1"),t.onnuminput&&t.onnuminput.call(t)},t.setRange=(t,n,s)=>{e=t,i=n,l=s},t.addEventListener("input",()=>t.set(t.value)),t.addEventListener("paste",e=>{t.set(e.clipboardData.getData("text")),e.preventDefault()}),t},utils.autosize=(t,e=5,i=1)=>{t.set=e=>{t.value=e,n()};let l=t.style;function n(){if(0===t.scrollHeight)return setTimeout(n,1);t.setAttribute("rows",1);let s=getComputedStyle(t);l.setProperty("overflow","hidden","important"),l.width=t.innerRect.w+"px",l.boxSizing="content-box",l.borderWidth=l.paddingInline=0;let r=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom),o="normal"===s.lineHeight?parseFloat(s.height):parseFloat(s.lineHeight),u=Math.round((Math.round(t.scrollHeight)-r)/o);l.overflow=l.width=l.boxSizing=l.borderWidth=l.paddingInline="",t.setAttribute("rows",utils.bounds(u,i,e))}l.maxHeight=l.resize="none",l.minHeight=0,l.height="auto",t.setAttribute("rows",i),t.addEventListener("input",n)},utils.formatCost=(t,e="$")=>{if(!t)return e+"0.00";let i=t.toFixed(2).split(".");return e+i[0].split("").reverse().reduce((t,e,i)=>"-"==e?e+t:e+(i&&!(i%3)?",":"")+t,"")+"."+i[1]},utils.fromDateTimeBox=t=>{let e=t.value;return e?new Date(e.replace(/-/g,"/").replace(/T/g," ")):new Date},utils.fixedNum=function(t,e,i=10){let l=Math.abs(t).toString(i).toUpperCase();return(t<0?"-":"")+(16==i?"0x":2==i?"0b":"")+"0".repeat(Math.max(e-l.length,0))+l},utils.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],utils.toDateTimeBox=(t,e)=>t.getFullYear()+"-"+c(t.getMonth()+1)+"-"+c(t.getDate())+"T"+c(t.getHours())+":"+c(t.getMinutes())+(e?":"+c(t.getSeconds()):""),utils.formatDate=(t,e={})=>{let i="",l,n;if(null==t||!t.getDate||!((l=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let s=t.getHours(),r="";if(e.h24||(r=" AM",s>=12&&(r=" PM",s-=12),s||(s=12)),i=s+":"+c(t.getMinutes())+(e.sec?":"+c(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).slice(1):""):""),i+=r,e.time)return i}return n=t.getDate(),n=utils.months[t.getMonth()]+" "+(null==e.suf||e.suf?utils.suffix(n):n),(null==e.year||e.year)&&e.year!==l&&(n=n+", "+l),e.df?n+(i&&" "+i):(i&&i+" ")+n},utils.suffix=t=>{let e=t%10,i=t%100;return 1==e&&11!=i?t+"st":2==e&&12!=i?t+"nd":3==e&&13!=i?t+"rd":t+"th"};let d=e;function f(t){utils.onNav&&utils.onNav.call(null,t)}function h(t,e,i){let n=this.length,s=Math.max(e<0?n+e:e||0,0),r;for(null!=i&&(n=Math.min(i<0?n+i:i,n));s<n;++s)if("!"===(r=t(this[s],s,n)))this instanceof l?this[s].remove():this.splice(s,1),--s,--n;else if(null!=r)return r}async function p(t,e,i,n=!0){let s=this.length,r=e=Math.max(e<0?s+e:e||0,0),o,u=[];for(null!=i&&(s=Math.min(i<0?s+i:i,s));r<s;++r){if(o=t(this[r],r,s),!n&&"!"!==(o=await o)&&null!=o)return o;u.push(o)}for(n&&(u=await Promise.all(u)),r=e,o=0;r<s;++r,++o)if("!"===u[o])this instanceof l?this[r].remove():this.splice(r,1),--r,--s;else if(null!=u[o])return u[o]}utils.goBack=d.back.bind(d),utils.goForward=d.forward.bind(d),utils.go=(t,e)=>{d.pushState(e,"",t||location.pathname),f(e)},r("popstate",t=>f(t.state)),r("load",()=>setTimeout(f.wrap(d.state),1)),utils.mkEl=(t,e,i,l,n)=>{let s=document.createElement(t);if(null!=i&&(s.className=i),null!=n&&(s.innerHTML=n),l&&"object"==typeof l)for(let r in l)r in s.style?s.style[r]=l[r]:s.style.setProperty(r,l[r]);return null!=e&&e.appendChild(s),s},utils.mkDiv=(t,e,i,l)=>utils.mkEl("div",t,e,i,l),utils.addText=(t,e)=>t.appendChild(document.createTextNode(e)),utils.textWidth=(e,i)=>{let l=t.TWCanvas||(t.TWCanvas=utils.mkEl("canvas")),n=l.getContext("2d");return n.font=i,n.measureText(e).width},utils.define(utils,"w",()=>innerWidth),utils.define(utils,"h",()=>innerHeight),utils.setPropSafe=(t,e,i,l=!1)=>{"string"==typeof e&&(e=e.split("."));let n=e.length-1;return(e.each(e=>{t="object"==typeof t[e]?t[e]:t[e]={}},0,n),n=e[n],l&&null!=t[n])?t[n]:t[n]=i},utils.getPropSafe=(t,e)=>{"string"==typeof e&&(e=e.split("."));try{for(let i of e)t=t[i];return t}catch(l){}},utils.proto(Array,"clean",function(t){for(let e=0,i,l=this.length;e<l;++e)i=this[e],(utils.isBlank(i)||!1===i||!t&&0===i)&&(this.splice(e--,1),l--);return this}),utils.proto(Array,"remove",function(t){let e=this.indexOf(t);return -1!=e&&(this.splice(e,1),!0)}),[Array,l,s].forEach(t=>{utils.proto(t,"each",h),utils.proto(t,"eachAsync",p)});let $="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=$.replace("+/","-_"),m={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 g(t,e){if(null==(t=m[t.charCodeAt(e)]))throw"Bad char at "+e;return t}"toBase64"in Uint8Array.prototype||utils.proto(Uint8Array,"toBase64",function(t){let e=this.byteLength,i=e%3,l=t&&"base64url"===t.alphabet?_:$,n=0,s="",r;for(e-=i;n<e;n+=3)s+=l[(16515072&(r=this[n]<<16|this[n+1]<<8|this[n+2]))>>18]+l[(258048&r)>>12]+l[(4032&r)>>6]+l[63&r];return 1==i?(s+=l[(252&(r=this[e]))>>2]+l[(3&r)<<4],t&&t.omitPadding||(s+="=")):2!=i||(s+=l[(64512&(r=this[e]<<8|this[e+1]))>>10]+l[(1008&r)>>4]+l[(15&r)<<2],t&&t.omitPadding||(s+="==")),s}),"fromBase64"in Uint8Array||utils.proto(Uint8Array,"fromBase64",t=>{let e=t.length,i=e-1;for(;i>=0&&61===t.charCodeAt(i);--i);e=i+1,i=0;let l=e%4;if(e-=l,1==l)throw"Bad b64 len";let n=new Uint8Array(3*e/4+(l?l-1:0)),s=-1,r;for(;i<e;i+=4)r=g(t,i)<<18|g(t,i+1)<<12|g(t,i+2)<<6|g(t,i+3),n[++s]=r>>16,n[++s]=r>>8,n[++s]=r;return 2==l?n[++s]=g(t,i)<<2|g(t,i+1)>>4:3==l&&(r=g(t,i)<<10|g(t,i+1)<<4|g(t,i+2)>>2,n[++s]=r>>8,n[++s]=r),n},1);let y=/[|\\{}()[\]^$+*?.]/g,x=/-/g;function b(t,e){for(;t>=e;)t-=e;return t}function w(){let t=document.styleSheets;for(let e=0,i=t.length;e<i;++e)try{return t[e].cssRules,t[e]}catch(l){}let n=utils.mkEl("style",document.head);return utils.addText(n,""),n.sheet}function v(t){return t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}"escape"in RegExp||utils.proto(RegExp,"escape",t=>t.replace(y,"\\$&").replace(x,"\\x2d"),1),utils.define(n.prototype,"index",function(){let t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),utils.proto(n,"insertChildAt",function(t,e){e<0&&(e=0),e>=this.children.length?this.appendChild(t):this.insertBefore(t,this.children[e])}),utils.boundingRect=t=>new UtilRect(t.getBoundingClientRect()),utils.innerRect=t=>{let e=t.getBoundingClientRect(),i=getComputedStyle(t);return new UtilRect(e.top+parseFloat(i.paddingTop)+parseFloat(i.borderTopWidth),e.bottom-parseFloat(i.paddingBottom)-parseFloat(i.borderBottomWidth),e.left+parseFloat(i.paddingLeft)+parseFloat(i.borderLeftWidth),e.right-parseFloat(i.paddingRight)-parseFloat(i.borderRightWidth))},utils.define(n.prototype,"boundingRect",function(){return utils.boundingRect(this)}),utils.define(n.prototype,"innerRect",function(){return utils.innerRect(this)}),Math.cot=t=>1/Math.tan(t),utils.isBlank=t=>null==t||("string"==typeof t?!/\S/.test(t):"object"==typeof t&&("number"==typeof t.length?0===t.length:0===Object.keys(t).length)),utils.firstEmpty=t=>{let e=t.length;for(let i=0;i<e;++i)if(null==t[i])return i;return e},utils.firstEmptyChar=t=>{let e=Object.keys(t),i=e.length;for(let l=0;l<i;++l)if(null==t[e[l]])return e[l];return utils.numToChar(i)},utils.numToChar=t=>{if(t<=25)return String.fromCharCode(t+97);if(t>=26&&t<=51)return String.fromCharCode(t+39);let e,i;if(t<2756)e=b(Math.floor(t/52)-1,52),i=b(t,52);else if(t<143364)e=b(Math.floor((t-52)/2704)-1,52),i=b(t-52,2704)+52;else{if(!(t<7454980))return!1;e=b(Math.floor((t-2756)/140608)-1,52),i=b(t-2756,140608)+2756}return utils.numToChar(e)+utils.numToChar(i)},utils.merge=function(t){for(let e=1,i=arguments.length,l,n,s;e<i;++e)for(let r in l=arguments[e]){if(n=t[r],s=l[r],n&&s){if(n.length>=0&&s.length>=0){for(let o=0,u=s.length,a=n.length;o<u;++o)n[o+a]=s[o];continue}if("object"==typeof n&&"object"==typeof s){for(let c in s)n[c]=s[c];continue}}t[r]=s}return t},utils.bounds=(t,e=0,i=1)=>t>=e?t<=i?t:i:e,utils.norm=utils.normalize=(t,e=0,i=1)=>{let l=Math.abs(i-e);if(t<e)for(;t<e;)t+=l;else for(;t>=i;)t-=l;return t},utils.cutStr=(t,e)=>{let i;for(;-1!=(i=t.indexOf(e));)t=t.slice(0,i)+t.slice(i+e.length);return t},utils.dCut=(t,e,i,l,n)=>{let s=t.indexOf(e,n||void 0)+e.length,r=t.indexOf(i,s);return l&&(l.s=s,l.t=r),s<e.length||r<=s?"":t.slice(s,r)},utils.dCutToLast=(t,e,i,l,n)=>{let s=t.indexOf(e,n||void 0)+e.length,r=t.lastIndexOf(i);return l&&(l.s=s,l.t=r),s<e.length||r<=s?"":t.slice(s,r)},utils.dCutLast=(t,e,i,l,n)=>{let s=t.lastIndexOf(e,n||void 0)+e.length,r=t.indexOf(i,s);return l&&(l.s=s,l.t=r),s<e.length||r<=s?"":t.slice(s,r)},utils.parseCSS=t=>{let e={},i="",l=0;function n(t){if(-1!==t.indexOf(",")){let e=utils.clean(t.split(","));for(let i=0,l=e.length;i<l;++i)e[i]=e[i].trim();return e}return t.trim()}for(t=t.trim();t.length>0;)if("("==t[0]&&-1!==t.indexOf(")")&&i){let s=t.indexOf(")"),r=t.slice(1,s);e[i]=n(r),i="",t=t.slice(s+1)}else if(0==t.search(/[#!\w]/)){i&&(e[l++]=i);let o=t.search(/[^#!\w-%]/);-1==o&&(o=t.length),i=t.slice(0,o),t=t.slice(o)}else t=t.slice(1);return i&&(e[l]=i),e},utils.buildCSS=t=>{let e=Object.keys(t),i=e.length,l="",n=0;for(;n<i;){let s=e[n],r=t[e[n]];++n,0<=Number(s)?l+=r+" ":l+=`${s}(${r}) `}return l.slice(0,-1)},utils.addClass=(t,e)=>{let i=w(),l=Object.keys(e),n="";for(let s=0,r=l.length;s<r;++s)n+=v(l[s])+":"+e[l[s]]+";";i.addRule("."+t,n)},utils.addId=(t,e)=>{let i=w(),l=Object.keys(e),n="";for(let s=0,r=l.length;s<r;++s)n+=v(l[s])+":"+e[l[s]]+";";i.addRule("#"+t,n)},utils.addKeyframe=(t,e)=>{w().addRule("@keyframes "+t,e)},utils.removeSelector=t=>{for(let e=0,i,l,n=document.styleSheets.length;e<n;++e){i=document.styleSheets[e];try{l=i.cssRules}catch(s){continue}for(let r in l)"CSSStyleRule"==l[r].constructor.name&&l[r].selectorText==t&&i.deleteRule(r)}},utils.hexToRgb=t=>{let e=parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,255&e]},utils.rgbToHsl=(t,e,i)=>{t/=255;let l=Math.max(t,e/=255,i/=255),n=Math.min(t,e,i),s,r,o=(l+n)/2;if(l===n)s=r=0;else{let u=l-n;switch(r=o>.5?u/(2-l-n):u/(l+n),l){case t:s=(e-i)/u+(e<i?6:0);break;case e:s=(i-t)/u+2;break;case i:s=(t-e)/u+4}s/=6}return[360*s,100*r,100*o]},utils.rand=(t,e,i,l)=>{e*=i=i||1,t*=i;let n=Math.random();return Math.round((l?l(n):n)*(e-t)+t)/i},utils.fromQuery=t=>{function e(t,i){let l=i[0],n=l.indexOf("="),s=decodeURIComponent(l.slice(0,n)),r=decodeURIComponent(l.slice(n+1));return null==t[s]?t[s]=r:Array.isArray(t[s])?t[s].push(r):t[s]=[t[s],r],1===i.length?t:e(t,i.slice(1))}return t.startsWith("?")&&(t=t.slice(1)),t?e({},t.split("&")):{}},utils.toQuery=t=>{let e="",i,l;if("object"!=typeof t)return encodeURIComponent(t);for(i in t)"object"==typeof(l=t[i])&&null!=l&&(l=JSON.stringify(l)),e+="&"+i+"="+encodeURIComponent(l);return e.slice(1)},utils.center=(t,e,i)=>{let l=t.style;if("trans"==i){l.position||(l.position="absolute");let n=utils.cutStr(l.transform,"translateX(-50%)");n=utils.cutStr(n,"translateY(-50%)"),e&&"x"!=e||(l.left="50%",n+="translateX(-50%)"),e&&"y"!=e||(l.top="50%",n+="translateY(-50%)"),n&&(l.transform=n)}else{let s=utils.mkDiv(t.parentNode,null,{display:"flex",top:0,left:0,width:"100%",height:"100%"});s.appendChild(t),s=s.style,e&&"x"!=e||(s.justifyContent="center"),e&&"y"!=e||(s.alignItems="center",s.position="absolute")}},utils.loadAjax=(t,e,i,l,n)=>{let s;try{s=new XMLHttpRequest}catch(r){return e(r)}if(n)for(let o in n)s.setRequestHeader(o,n[o]);s.open(i||"GET",t),s.onreadystatechange=()=>{let t=s.status||-1;s.readyState==s.DONE&&e(200==t?0:t,s.response,s)},s.send(l||void 0)},utils.loadFile=(t,e,i)=>{let l=utils.mkEl("object",document.body,null,{position:"fixed",opacity:0});l.data=t;let n=setTimeout(()=>{l.remove(),n=null,e(!1)},i||4e3);l.onload=()=>{n&&(clearTimeout(n),e(l.contentDocument.documentElement.outerHTML),l.remove())}},utils.loadJSONP=(t,e,i)=>{let l=utils.mkEl("script",document.head),n=utils.firstEmptyChar(utils.lJSONCall);l.type="application/javascript",l.src=t+(-1==t.indexOf("?")?"?":"&")+"callback=utils.lJSONCall."+n;let s=setTimeout(()=>{delete utils.lJSONCall[n],e(!1)},i||4e3);utils.lJSONCall[n]=t=>{s&&clearTimeout(s),delete utils.lJSONCall[n],e(t)},document.head.removeChild(l)},utils.lJSONCall=[],utils.dlFile=(t,e)=>fetch(e).then(t=>{if(200!=t.status)throw"Code "+t.status;return t.blob()}).then(e=>{utils.dlData(t,e)}),utils.dlData=(t,e)=>{let i,l=utils.mkEl("a",document.body,null,{display:"none"});"string"==typeof e?i=e:(e instanceof Blob||(e=Blob(e)),i=URL.createObjectURL(e)),l.href=i,l.download=t,l.click(),l.remove(),URL.revokeObjectURL(i)},utils.deg=t=>180*t/Math.PI,utils.rad=t=>t*Math.PI/180,utils.map=(t,e,i,l,n,s)=>{let r=(t-e)/(i-e);return(s?s(r):r)*(n-l)+l},utils.delay=t=>new Promise(e=>setTimeout(e,t)),UtilRect=function(t,e,l,n){if(!(this instanceof UtilRect))return new UtilRect(t,e,l,n);let s=Number.isFinite,r=0,o=0,u=0,a=0;utils.define(this,"x",()=>u,t=>{s(t)&&(a+=t-u,u=t)}),utils.define(this,"y",()=>r,t=>{s(t)&&(o+=t-r,r=t)}),utils.define(this,"top",()=>r,t=>{r=s(t)?t:0}),utils.define(this,["bottom","y2"],()=>o,t=>{o=s(t)?t:0}),utils.define(this,"left",()=>u,t=>{u=s(t)?t:0}),utils.define(this,["right","x2"],()=>a,t=>{a=s(t)?t:0}),utils.define(this,["width","w"],()=>a-u,t=>{a=t>=0?u+t:0}),utils.define(this,["height","h"],()=>o-r,t=>{o=t>=0?r+t:0}),utils.define(this,"centerX",()=>u/2+a/2),utils.define(this,"centerY",()=>r/2+o/2),t instanceof i||t instanceof UtilRect?(r=t.top,o=t.bottom,u=t.left,a=t.right):(r=t,o=e,u=l,a=n)},utils.proto(UtilRect,"contains",function(t,e){return t instanceof n?this.contains(t.boundingRect):t instanceof UtilRect?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}),utils.proto(UtilRect,"overlaps",function(t){if(t instanceof n)return this.overlaps(t.boundingRect);if(!(t instanceof UtilRect))return 0;let e,i;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,i=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&&i}),utils.proto(UtilRect,"dist",function(t,e){if(t instanceof n)return this.dist(t.boundingRect);let i=t instanceof UtilRect;return e=Math.abs((i?t.centerY:e)-this.centerY),Math.sqrt((t=Math.abs((i?t.centerX:t)-this.centerX))*t+e*e)}),utils.proto(UtilRect,"expand",function(t){return this.top-=t,this.left-=t,this.bottom+=t,this.right+=t,this})})();const Easing={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,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};if(_uNJS&&!global.utils){let t=import("os").then(e=>t=e);utils.getIPs=()=>{let e=[],i=t.networkInterfaces();for(let l in i)i[l].forEach(t=>{!t.internal&&"IPv4"==t.family&&"00:00:00:00:00:00"!=t.mac&&t.address&&e.push(t.address)});return e.length?e:0},utils.getOS=()=>{let e,i,l;switch(t.platform()){case"win32":e="Windows";break;case"darwin":e="MacOS";break;case"linux":e="Linux";break;default:e=t.platform()}switch(t.arch()){case"ia32":i="32-bit";break;case"x64":i="64-bit";break;case"arm":i="ARM";break;default:i=t.arch()}return[e,i,l=t.cpus()[0].model]},global.utils=utils,global.UtilRect=UtilRect,global.Easing=Easing}