-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.min.js
2 lines (2 loc) · 20.6 KB
/
utils.min.js
1
2
//https://github.com/Pecacheu/Utils.js MIT -- Minified with https://javascript-minifier.com
"use strict";const utils={VER:"v8.6.2"};(()=>{function t(){switch(this.type){case"datetime-local":this.siT.textContent=utils.formatDate(utils.fromDateTimeBox(this));break;case"select-one":this.siT.textContent=e(this);break;case"select-multiple":this.siT.textContent=i(this)}}function e(t){let e=t.options;return -1!=e.selectedIndex?e[e.selectedIndex].label:"No Options Selected"}function i(t){let e=t.options,i="";for(let n=0,s=e.length;n<s;++n)e[n].selected&&(i+=(i?", ":"")+e[n].label);return i||"No Options Selected"}function n(t){return t<=9?"0"+t:t}utils.define=(t,e,i,n)=>{let s={};i&&(s.get=i),n&&(s.set=n),Array.isArray(e)?e.each(e=>Object.defineProperty(t,e,s)):Object.defineProperty(t,e,s)},utils.proto=(t,e,i,n)=>{let s={value:i};n||(t=t.prototype),Array.isArray(e)?e.each(e=>Object.defineProperty(t,e,s)):Object.defineProperty(t,e,s)},utils.setCookie=(t,e,i,n)=>{let s=encodeURIComponent(t)+"="+(null==e?"":encodeURIComponent(e))+";path=/";null!=i&&(i instanceof Date||(i=new Date(i)),s+=";expires="+i.toUTCString()),n&&(s+=";secure"),document.cookie=s},utils.remCookie=t=>{document.cookie=encodeURIComponent(t)+"=;expires="+new Date(0).toUTCString()},utils.getCookie=t=>{let e=encodeURIComponent(t),i=" "+e,n=document.cookie.split(";");for(let s=0,l=n.length,r,u,o;s<l;++s)if(u=(r=n[s]).indexOf("="),(o=r.substr(0,u))==e||o==i)return decodeURIComponent(r.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),s,l;return n.startsWith("Windows")?(s=n.split("; "),e.os="Windows",e.type=-1!=s.indexOf("WOW64")?"x64 PC; x86 Browser":-1!=s.indexOf("x64")?"x64 PC":"x86 PC",s=n.indexOf("Windows NT "),e.version=n.substring(s+11,n.indexOf(";",s+12))):n.startsWith("iP")?(s=n.indexOf("OS"),e.os="iOS",e.type=n.substr(0,n.indexOf(";")),e.version=n.substring(s+3,n.indexOf(" ",s+4)).replace(/_/g,".")):n.startsWith("Macintosh;")?(s=n.indexOf(" Mac OS X"),e.os="MacOS",e.type=n.substring(11,s)+" Mac",e.version=n.substr(s+10).replace(/_/g,".")):-1!=(s=n.indexOf("Android"))?(e.os="Android",e.version=n.substring(s+8,n.indexOf(";",s+9)),s=n.lastIndexOf(";"),l=n.indexOf(" Build",s+2),e.type=n.substring(s+2,-1==l?void 0:l)):n.startsWith("X11;")&&(s=(n=n.substr(5).split(/[;\s]+/)).length,e.os=("Linux"==n[0]?"":"Linux ")+n[0],e.type=n[s-2],e.version=n[s-1]),(s=Number(e.version))&&(e.version=s),s=t.indexOf(" ",i+2),l=-1==(l=t.indexOf(")",s+1))?s+1:l+2,e.engine=t.substring(i+2,s),e.browser=t.substring(l),e.mobile=!!t.match(/Mobi/i),e},utils.device=utils.deviceInfo(),utils.mobile=utils.device.mobile,window.TouchList&&utils.proto(TouchList,"get",function(t){for(let e in this)if(this[e].identifier==t)return this[e];return 0}),utils.skinnedInput=e=>{let i=utils.mkDiv(null,e.className),n=e.style,s=e.type;if(e.className+=" isSub","datetime-local"==s||"select-one"==s||"select-multiple"==s){n.opacity=0,n.top="-100%",e.siT=utils.mkEl("span",i,"isText"),utils.mkEl("span",i,"isArrow",{borderTopColor:getComputedStyle(e).color});let l=t.bind(e);e.addEventListener("change",l),e.forceUpdate=l,l()}e.replaceWith(i),i.appendChild(e),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)=>(null==e&&(e=-2147483648),null==i&&(i=2147483647),t.setAttribute("pattern","\\d*"),t.type=utils.mobile||n?"tel":"number",t.ns=t.value=(t.num=Number(t.value)||Math.max(0,e)).toString(),t.addEventListener("keydown",s=>{if(s.ctrlKey)return;let l=s.key,r=1==l.length?Number(l):null,u=t.ns.startsWith("-")?t.num!=e:t.num!=i,o=t.ns,a=t.ns.length,d=t.ns.indexOf(".");r||0==r?(-1==d||a-d<n+1)&&(t.ns+=l):n&&u&&("."==l||"*"==l)&&-1==d?t.ns+=".":"Backspace"==l||"Delete"==l?t.ns=t.ns.substr(0,a-1):e<0&&("-"==l||"#"==l)&&!a?t.ns="-":"ArrowUp"==l?t.ns=(t.num+(t.step||1)).toString():"ArrowDown"==l&&(t.ns=(t.num-(t.step||1)).toString()),a=t.ns.length,-1!=(d=t.ns.indexOf("."))&&a-d>n+1&&(a=(t.ns=t.ns.substr(0,d+n+1)).length);let h=Number(t.ns)||0;h>i?(h=i,t.ns=h.toString()):h<e&&(h=e,t.ns=h.toString());let f=t.num,c=t.ns.startsWith("-");t.num=h,t.onnuminput&&!1===t.onnuminput(h)?(t.ns=o,t.num=f):t.value=(c&&!h?"-":"")+h+(-1!=d&&h%1==0?".0":""),s.preventDefault()}),t.addEventListener("input",()=>t.set(t.value)),t.addEventListener("paste",e=>{t.set(e.clipboardData.getData("text")),e.preventDefault()}),t.set=s=>{let l,r;"string"==typeof s&&(l=s.endsWith(".")&&n,r="0-"==s&&e<0),s=Number(s)||0,n||(s=Math.floor(s)),s>i&&(s=i),s<e&&(s=e),t.value=r?"-0":(t.num=s)+(l?".0":""),t.ns=r?"-":s+(l?".":""),t.onnuminput&&t.onnuminput(s)},t),utils.costField=(t,e)=>(e||(e="$"),t.setAttribute("pattern","\\d*"),t.type="tel",t.value=utils.formatCost(t.num=Number(t.value)||0,e),t.ns=t.num.toString(),t.addEventListener("keydown",i=>{let n=i.key,s=1==n.length?Number(n):null,l=t.ns.length,r=t.ns,u=t.ns.indexOf(".");s||0==s?(-1==u||l-u<3)&&(t.ns+=n):("."==n||"*"==n)&&-1==u?(t.ns+=".",u=l):"Backspace"==n||"Delete"==n?t.ns=t.ns.substr(0,l-1):"ArrowUp"==n?t.ns=(t.num+1).toString():"ArrowDown"==n&&t.num>=1&&(t.ns=(t.num-1).toString());let o=Number(t.ns)||0;o||-1!=u||(t.ns="");let a=t.num;t.num=o,t.onnuminput&&!1===t.onnuminput(o)?(t.ns=r,t.num=a):t.value=utils.formatCost(o,e),i.preventDefault()}),t.addEventListener("input",()=>t.set(t.value)),t.addEventListener("paste",e=>{t.set(e.clipboardData.getData("text")),e.preventDefault()}),t.set=i=>{let n;"string"==typeof i&&((n=i.endsWith("."))&&(i=i.substr(0,i.length-1)),i.startsWith(e)&&(i=i.substr(e.length))),t.num=i=Math.floor(100*(Number(i)||0))/100,t.value=utils.formatCost(i,e),t.ns=i+(n?".":""),t.onnuminput&&t.onnuminput(i)},t),utils.formatCost=(t,e)=>{if(e||(e="$"),!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()+"-"+n(t.getMonth()+1)+"-"+n(t.getDate())+"T"+n(t.getHours())+":"+n(t.getMinutes())+(e?":"+n(t.getSeconds()):""),utils.formatDate=(t,e={})=>{let i="",s,l;if(null==t||!t.getDate||!((s=t.getFullYear())>1969))return"[Invalid Date]";if(null==e.time||e.time){let r=t.getHours(),u="";if(e.h24||(u=" AM",r>=12&&(u=" PM",r-=12),r||(r=12)),i=r+":"+n(t.getMinutes())+(e.sec?":"+n(t.getSeconds())+(e.ms?(t.getMilliseconds()/1e3).toFixed(Number.isFinite(e.ms)?e.ms:3).substr(1):""):""),i+=u,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!==s&&(l=l+", "+s),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 s=history;function l(t){utils.onNav&&utils.onNav.call(null,t)}function r(t,e,i){let n=this.length,s=Math.max(e<0?n+e:e||0,0),l;for(null!=i&&(n=Math.min(i<0?n+i:i,n));s<n;++s)if("!"===(l=t(this[s],s,n)))this instanceof HTMLCollection?this[s].remove():this.splice(s,1),--s,--n;else if(null!=l)return l}async function u(t,e,i,n=!0){let s=this.length,l=e=Math.max(e<0?s+e:e||0,0),r,u=[];for(null!=i&&(s=Math.min(i<0?s+i:i,s));l<s;++l){if(r=t(this[l],l,s),!n&&"!"!==(r=await r)&&null!=r)return r;u.push(r)}for(n&&(u=await Promise.all(u)),l=e,r=0;l<s;++l,++r)if("!"===u[r])this instanceof HTMLCollection?this[l].remove():this.splice(l,1),--l,--s;else if(null!=u[r])return u[r]}utils.goBack=s.back.bind(s),utils.goForward=s.forward.bind(s),utils.go=(t,e)=>{s.pushState(e,"",t||location.pathname),l(e)},addEventListener("popstate",t=>l(t.state)),addEventListener("load",()=>setTimeout(l.wrap(s.state),1)),utils.mkEl=(t,e,i,n,s)=>{let l=document.createElement(t);if(null!=i&&(l.className=i),null!=s&&(l.innerHTML=s),n&&"object"==typeof n)for(let r in n)r in l.style?l.style[r]=n[r]:l.style.setProperty(r,n[r]);return null!=e&&e.appendChild(l),l},utils.mkDiv=(t,e,i,n)=>utils.mkEl("div",t,e,i,n),utils.addText=(t,e)=>t.appendChild(document.createTextNode(e)),utils.textWidth=(t,e)=>{let i=window.TWCanvas||(window.TWCanvas=utils.mkEl("canvas")),n=i.getContext("2d");return n.font=e,n.measureText(t).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 s=e.length-1;return(e.each(e=>{t="object"==typeof t[e]?t[e]:t[e]={}},0,s),s=e[s],n&&null!=t[s])?t[s]:t[s]=i},utils.getPropSafe=(t,e)=>{"string"==typeof e&&(e=e.split("."));try{return e.each(e=>{t=t[e]}),t}catch(i){}},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,HTMLCollection,NodeList].forEach(t=>{utils.proto(t,"each",r),utils.proto(t,"eachAsync",u)});let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=o.replace("+/","-_"),d={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 h(t,e){if(null==(t=d[t.charCodeAt(e)]))throw"Bad char at "+e;return t}function f(t,e){for(;t>=e;)t-=e;return t}function c(){let t=document.styleSheets;for(let e=0,i=t.length;e<i;++e)try{return t[e].cssRules,t[e]}catch(n){}let s=utils.mkEl("style",document.head);return utils.addText(s,""),s.sheet}function p(t){return t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}"toBase64"in Uint8Array.prototype||utils.proto(Uint8Array,"toBase64",function(t){let e=this.byteLength,i=e%3,n=t&&"base64url"===t.alphabet?a:o,s=0,l="",r;for(e-=i;s<e;s+=3)l+=n[(16515072&(r=this[s]<<16|this[s+1]<<8|this[s+2]))>>18]+n[(258048&r)>>12]+n[(4032&r)>>6]+n[63&r];return 1==i?(l+=n[(252&(r=this[e]))>>2]+n[(3&r)<<4],t&&t.omitPadding||(l+="=")):2!=i||(l+=n[(64512&(r=this[e]<<8|this[e+1]))>>10]+n[(1008&r)>>4]+n[(15&r)<<2],t&&t.omitPadding||(l+="==")),l}),"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 s=new Uint8Array(3*e/4+(n?n-1:0)),l=-1,r;for(;i<e;i+=4)r=h(t,i)<<18|h(t,i+1)<<12|h(t,i+2)<<6|h(t,i+3),s[++l]=r>>16,s[++l]=r>>8,s[++l]=r;return 2==n?s[++l]=h(t,i)<<2|h(t,i+1)>>4:3==n&&(r=h(t,i)<<10|h(t,i+1)<<4|h(t,i+2)>>2,s[++l]=r>>8,s[++l]=r),s},1),utils.define(Element.prototype,"index",function(){let t=this.parentElement;return t?Array.prototype.indexOf.call(t.children,this):-1}),utils.proto(Element,"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(Element.prototype,"boundingRect",function(){return utils.boundingRect(this)}),utils.define(Element.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=f(Math.floor(t/52)-1,52),i=f(t,52);else if(t<143364)e=f(Math.floor((t-52)/2704)-1,52),i=f(t-52,2704)+52;else{if(!(t<7454980))return!1;e=f(Math.floor((t-2756)/140608)-1,52),i=f(t-2756,140608)+2756}return utils.numToChar(e)+utils.numToChar(i)},utils.merge=function(t){for(let e=1,i=arguments.length,n,s,l;e<i;++e)for(let r in n=arguments[e]){if(s=t[r],l=n[r],s&&l){if(s.length>=0&&l.length>=0){for(let u=0,o=l.length,a=s.length;u<o;++u)s[u+a]=l[u];continue}if("object"==typeof s&&"object"==typeof l){for(let d in l)s[d]=l[d];continue}}t[r]=l}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,s)=>{let l=t.indexOf(e,s||void 0)+e.length,r=t.indexOf(i,l);return n&&(n.s=l,n.t=r),l<e.length||r<=l?"":t.substring(l,r)},utils.dCutToLast=(t,e,i,n,s)=>{let l=t.indexOf(e,s||void 0)+e.length,r=t.lastIndexOf(i);return n&&(n.s=l,n.t=r),l<e.length||r<=l?"":t.substring(l,r)},utils.dCutLast=(t,e,i,n,s)=>{let l=t.lastIndexOf(e,s||void 0)+e.length,r=t.indexOf(i,l);return n&&(n.s=l,n.t=r),l<e.length||r<=l?"":t.substring(l,r)},utils.parseCSS=t=>{let e={},i="",n=0;function s(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 l=t.indexOf(")"),r=t.substring(1,l);e[i]=s(r),i="",t=t.substring(l+1)}else if(0==t.search(/[#!\w]/)){i&&(e[n++]=i);let u=t.search(/[^#!\w-%]/);-1==u&&(u=t.length),i=t.substring(0,u),t=t.substring(u)}else t=t.substring(1);return i&&(e[n]=i),e},utils.buildCSS=t=>{let e=Object.keys(t),i=e.length,n="",s=0;for(;s<i;){let l=e[s],r=t[e[s]];++s,0<=Number(l)?n+=r+" ":n+=`${l}(${r}) `}return n.substring(0,n.length-1)},utils.addClass=(t,e)=>{let i=c(),n=Object.keys(e),s="";for(let l=0,r=n.length;l<r;++l)s+=p(n[l])+":"+e[n[l]]+";";i.addRule("."+t,s)},utils.addId=(t,e)=>{let i=c(),n=Object.keys(e),s="";for(let l=0,r=n.length;l<r;++l)s+=p(n[l])+":"+e[n[l]]+";";i.addRule("#"+t,s)},utils.addKeyframe=(t,e)=>{c().addRule("@keyframes "+t,e)},utils.removeSelector=t=>{for(let e=0,i,n,s=document.styleSheets.length;e<s;++e){i=document.styleSheets[e];try{n=i.cssRules}catch(l){continue}for(let r in n)"CSSStyleRule"==n[r].constructor.name&&n[r].selectorText==t&&i.deleteRule(r)}},utils.getId=(t,e)=>(e||document).getElementById(t),utils.getClassList=(t,e)=>(e||document).getElementsByClassName(t),utils.getClassFirst=(t,e)=>(t=utils.getClassList(t,e)).length>0?t[0]:0,utils.getClassOnly=(t,e)=>1==(t=utils.getClassList(t,e)).length?t[0]:0,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 s=Math.random();return Math.round((n?n(s):s)*(e-t)+t)/i},utils.fromQuery=t=>{function e(t,i){let n=i[0],s=n.indexOf("="),l=decodeURIComponent(n.substr(0,s)),r=decodeURIComponent(n.substr(s+1));return null==t[l]?t[l]=r:"array"==typeof t[l]?t[l].push(r):t[l]=[t[l],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 s=utils.cutStr(n.transform,"translateX(-50%)");s=utils.cutStr(s,"translateY(-50%)"),e&&"x"!=e||(n.left="50%",s+="translateX(-50%)"),e&&"y"!=e||(n.top="50%",s+="translateY(-50%)"),s&&(n.transform=s)}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,s)=>{let l;try{l=new XMLHttpRequest}catch(r){return e(r)}if(s)for(let u in s)l.setRequestHeader(u,s[u]);l.open(i||"GET",t),l.onreadystatechange=()=>{let t=l.status||-1;l.readyState==l.DONE&&e(200==t?0:t,l.response,l)},l.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 s=setTimeout(()=>{n.remove(),s=null,e(!1)},i||4e3);n.onload=()=>{s&&(clearTimeout(s),e(n.contentDocument.documentElement.outerHTML),n.remove())}},utils.loadJSONP=(t,e,i)=>{let n=utils.mkEl("script",document.head),s=utils.firstEmptyChar(utils.lJSONCall);n.type="application/javascript",n.src=t+(-1==t.indexOf("?")?"?":"&")+"callback=utils.lJSONCall."+s;let l=setTimeout(()=>{delete utils.lJSONCall[s],e(!1)},i||4e3);utils.lJSONCall[s]=t=>{l&&clearTimeout(l),delete utils.lJSONCall[s],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,s,l)=>{let r=(t-e)/(i-e);return(l?l(r):r)*(s-n)+n},utils.delay=t=>new Promise(e=>setTimeout(e,t))})();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};function UtilRect(t,e,i,n){if(!(this instanceof UtilRect))return new UtilRect(t,e,i,n);let s=Number.isFinite,l=0,r=0,u=0,o=0;utils.define(this,"x",()=>u,t=>{s(t)&&(o+=t-u,u=t)}),utils.define(this,"y",()=>l,t=>{s(t)&&(r+=t-l,l=t)}),utils.define(this,"top",()=>l,t=>{l=s(t)?t:0}),utils.define(this,["bottom","y2"],()=>r,t=>{r=s(t)?t:0}),utils.define(this,"left",()=>u,t=>{u=s(t)?t:0}),utils.define(this,["right","x2"],()=>o,t=>{o=s(t)?t:0}),utils.define(this,["width","w"],()=>o-u,t=>{o=t>=0?u+t:0}),utils.define(this,["height","h"],()=>r-l,t=>{r=t>=0?l+t:0}),utils.define(this,"centerX",()=>u/2+o/2),utils.define(this,"centerY",()=>l/2+r/2),t instanceof DOMRect||t instanceof UtilRect?(l=t.top,r=t.bottom,u=t.left,o=t.right):(l=t,r=e,u=i,o=n)}utils.proto(UtilRect,"contains",function(t,e){return t instanceof Element?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 Element)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 Element)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});