jmini 0.0.123 → 0.0.124

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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var P=Object.defineProperty,ne=Object.defineProperties,ie=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var j=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var O=Math.pow,G=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&G(e,r,t[r]);if(L)for(var r of L(t))Q.call(t,r)&&G(e,r,t[r]);return e},_=(e,t)=>ne(e,se(t));var B=(e,t)=>{var r={};for(var i in e)U.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&L)for(var i of L(e))t.indexOf(i)<0&&Q.call(e,i)&&(r[i]=e[i]);return r};var oe=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ae(t))!U.call(e,n)&&n!==r&&P(e,n,{get:()=>t[n],enumerable:!(i=ie(t,n))||i.enumerable});return e};var ue=e=>le(P({},"__esModule",{value:!0}),e);var C=(e,t,r)=>new Promise((i,n)=>{var a=u=>{try{l(r.next(u))}catch(h){n(h)}},o=u=>{try{l(r.throw(u))}catch(h){n(h)}},l=u=>u.done?i(u.value):Promise.resolve(u.value).then(a,o);l((r=r.apply(e,t)).next())}),$=function(e,t){this[0]=e,this[1]=t},Z=(e,t,r)=>{var i=(o,l,u,h)=>{try{var d=r[o](l),p=(l=d.value)instanceof $,g=d.done;Promise.resolve(p?l[0]:l).then(m=>p?i(o==="return"?o:"next",l[1]?{done:m.done,value:m.value}:m,u,h):u({value:m,done:g})).catch(m=>i("throw",m,u,h))}catch(m){h(m)}},n=o=>a[o]=l=>new Promise((u,h)=>i(o,l,u,h)),a={};return r=r.apply(e,t),a[j("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a};var ee=(e,t,r)=>(t=e[j("asyncIterator")])?t.call(e):(e=e[j("iterator")](),t={},r=(i,n)=>(n=e[i])&&(t[i]=a=>new Promise((o,l,u)=>(a=n.call(e,a),u=a.done,Promise.resolve(a.value).then(h=>o({value:h,done:u}),l)))),r("next"),r("return"),t);var ve={};oe(ve,{Fetcher:()=>c,Filer:()=>E,Server:()=>N,Time:()=>f,UUID:()=>x,default:()=>Ee,useStore:()=>M});module.exports=ue(ve);typeof HTMLElement!="undefined"&&(HTMLElement.prototype.position=function(){return this.getBoundingClientRect()});typeof String!="undefined"&&(String.prototype.compress=function(){return this.trim().replace(/(\s|\n|\t)/ig,"")},String.prototype.encode=function(){return encodeURIComponent(this)},String.prototype.decode=function(){return decodeURIComponent(this)},String.prototype.toUpper=function(){return this.toLocaleUpperCase()},String.prototype.toLower=function(){return this.toLocaleLowerCase()},String.prototype.toCapital=function(){let e=this;return e&&(e=e.replace(/^./,this[0].toUpper()).replace(/(\s|_|-)[a-z]{1}/ig,t=>t[1].toUpper())),e},String.prototype.clip=function(e,t){return this.slice(e,t)},String.prototype.partReplace=function(...e){let t="";if(e.length==2){let[r,i]=e;t=[this.slice(0,r),i,this.slice(r+i.length)].join("")}if(e.length==3){let[r,i,n]=e;t=[this.slice(0,r),n,this.slice(r+i)].join("")}return t},String.prototype.toBlob=function(e){let t=atob(this.replace(/^.*,/,"")),r=new Uint8Array(t.length);for(var i=0;i<t.length;i++)r[i]=t.charCodeAt(i);try{var n=new Blob([r.buffer],{type:e})}catch(a){return!1}return n},String.prototype.toNumber=function(){let e=this.replace(/[^\d.-]/g,"").replace(/(-)(?=.*\d)/g,"").replace(/(\d+)\.(\d+)\.(\d+)/g,"$1.$2$3");return Number(e)||0},String.prototype.removeLetters=function(){return this.replace(/[\D]/ig,"")},String.prototype.removeSpecifics=function(){return this.replace(/[^\w\s\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]|_/uig,"")},String.prototype.removeJP=function(){return this.replace(/[\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]+/uig,"")},String.prototype.zen2hanNumber=function(){return this.replace(/[0-9]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)}).replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,"-").replace(/¥/,"\xA5").replace(/、/,",").replace(/(/,"(").replace(/)/,")").replace(/+/,"+")},String.prototype.escapeRegExChar=function(){return this.replace(/\\/g,"\\\\").replace(/(\?|\^|\$|\.|\||\*|\+|\(|\)|\{|\}|\[|\])/g,"\\$1")});typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){let t=Number(this)<0,r=Math.abs(Number(this));return isNaN(r)?"":(t?"-":"")+String(r).padStart(e||2,"0")},Number.prototype.toRate=function(e,t){let r=O(10,t!=null?t:2);return Math.round(this/e*r*100)/r},Number.prototype.toRatio=function(e,t){let r=O(10,t!=null?t:2);return Math.round(this/e*r)/r},Number.prototype.rank=function(e){let t=O(10,e!=null?e:1),r=Number(this);if(r<1e3)return String(this);let i=r.toLocaleString().replace(/\d/ig,"").length;return Math.round(r/O(1e3,i)*t)/t+("KMGTPEZY"[i-1]||"")},Number.prototype.rankJp=function(){let e=Number(this),t="";return e>=1e12?t=`${e/1e12}\u5146`:e>=1e8?t=`${e/1e8}\u5104`:e>=1e4?t=`${e/1e4}\u4E07`:e>=1e3?t=`${e/1e3}\u5343`:t=`${e.toLocaleString()}`,t},Number.prototype.toDate=function(e="/"){let t=String(this),r=t.slice(0,4),i=t.slice(4,6),n=t.slice(6,8),a=[];return r.length!=4||a.push(r),i.length!=2||a.push(i),n.length!=2||a.push(n),a.join(e)});if(typeof Array!="undefined"){let e=(r,...i)=>{var a;let n=r;for(let o of i){if(o!==(o!=null?o:!o))break;n=(a=(n||{})[o!=null?o:""])!=null?a:null}return n},t=r=>typeof Number(r)=="number"&&!isNaN(r);Array.prototype.sortBy=function(r,i,n,a){let l=(Array.isArray(i)?i:i?[i]:[""]).map(d=>String(d).match(/([^\.\[\]"]+)/g)||[]),u=l.map((d,p)=>1);return this.map(d=>({origin:d,sortVal:l.map((p,g)=>{let m=e(d,...p);if(t(m))return Number(m);let y=String(m).replace(/¥|,/g,"");return t(y)?Number(y):(u[g]=0,y.replace(/(\d+)/g,b=>b.padStart(10,"0")))})})).sort((d,p)=>{for(let g=0;g<l.length;g++){let m=d.sortVal[g],y=p.sortVal[g];if(u[g]){if(m>y)return 1*r;if(m<y)return-1*r;continue}let b=String(m).localeCompare(String(y),n,a);if(b!=0)return b*r}return 0}).map((d,p)=>(this[p]=d.origin,d.origin))},Array.prototype.toASC=function(...r){return this.sortBy(1,...r)},Array.prototype.toDESC=function(...r){return this.sortBy(-1,...r)},Array.prototype.getSum=function(...r){return this.reduce((i,n)=>i+(r?e(n,...r):Number(n)||0),0)},Array.prototype.getAve=function(...r){return this.getSum(...r)/this.length},Array.prototype.getMedian=function(...r){let i=this.map(a=>r?e(a,...r):Number(a)||0);i.sort((a,o)=>a-o);let n=Math.floor(i.length/2);return i.length%2===0?(i[n-1]+i[n])/2:i[n]},Array.prototype.getMin=function(...r){let i=this.map(n=>r?e(n,...r):Number(n)||0);return Math.min(...i)},Array.prototype.getMax=function(...r){let i=this.map(n=>r?e(n,...r):Number(n)||0);return Math.max(...i)},Array.prototype.chunk=function(r){let i=[];for(let n=0;n<this.length;n+=r)i.push(this.slice(n,n+r));return i},Array.prototype.forEachChunk=function(r,i,n){return C(this,null,function*(){let a=[],o=this.chunk(r);if(n)yield Promise.all(o.map((l,u)=>C(this,null,function*(){a[u]=v({ok:!0},yield i(l,u))})));else for(let l=0;l<o.length;l++)a.push(v({ok:!0},yield i(o[l],l)));return[a.every(l=>l.ok),a]})}}typeof File!="undefined"&&(File.prototype.convert=function(e){e=e||"dataURL";let t="readAs"+(e==null?void 0:e.toCapital());return new Promise((r,i)=>{let n=new FileReader;n.onload=a=>{r(n.result)},n.onerror=a=>i(n.error||a),n[t](this)})},File.prototype.clone=function(){return new File([this.slice(0,this.size,this.type)],this.name,{type:this.type,lastModified:this.lastModified})});var he=(e=24)=>Array.from({length:e}).map((t,r)=>{let i=r==0?25:35,n=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*i)][n?"toUpper":"toLower"]()}).join(""),x=he;x.get128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");x.get32Hex=(e="Formatted",t="-")=>{let r=Array.from({length:32}).map((i,n)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(r=[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20,32)].join(t)),r};x.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();var me=e=>new s.prototype.jmini(e),s=me;s.prototype={};s.extend=function(e,t=s){for(var[r,i]of Object.entries(e))t.prototype[r]=i};s.expando="__jmini_"+x();s.__classAlias="jmini";var R=(e,t)=>(e.queue.push(t),q(e),e),q=e=>C(void 0,null,function*(){if(e.queueProcess||!e.queue.length)return;e.queueProcess=!0;let t=e.queue.shift();t&&(yield t()),e.queueProcess=!1,q(e)}),k=(e,t)=>{for(let r=0;r<e.length;r++)e[r]=null;for(let[r,i]of Object.entries(t))r.match(/queue/)||(e[r]=i);return e},fe=(e,t)=>{if(t.length){for(var r=0;r<t.length;r++){let i=t[r];i&&(i[s.expando]||(s.isElement(i)||s.isShadowRoot(i))&&(i[s.expando]={events:{}})),e[r]=i}e.length=t.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,q(e),e};s.extend({constructor:s,__classAlias:s.__classAlias,jmini:function(e){return this.src=e,this.srcType=s.isWhat(e),this.queueProcess=!0,this.queue=[],fe(this,s.isJmini(e)?e.get():s.isElement(e)?[e]:s.isElements(e)?e:s.isShadowRoot(e)?[e]:s.isString(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}});s.prototype[String(Symbol.iterator)]=[][Symbol.iterator];s.prototype.jmini.prototype=s.prototype;{let e=function(n,a,o){let l=[];for(let u=0;u<(n.length||0);u++)l.push(a(n[u],u));return o&&(l=l.filter(u=>u!=null)),l},t=n=>(n.for((a,o)=>{if(!(s.isElement(a)||s.isShadowRoot(a)))return;let l=a.cloneNode(),u=a.parentNode;u&&u.replaceChild(l,a),n[o]=l}),n),r=(n,a)=>(s(a).for(o=>{if(n&&(s.isElement(o)||s.isShadowRoot(o)))if(s.isString(n)||s.isNumber(n))n=String(n),o.insertAdjacentHTML("beforeend",String(n));else if(s.isElement(n))o.appendChild(n);else{s.isJmini(n)?n=n.get():s.isElement(n)?n=[n]:s.isRecord(n)&&(n=[s(n)]);for(var l=0;l<n.length;l++)r(n[l],o)}}),a),i=(n,a,...o)=>{let{p:l,s:u}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[a]||{p:"",s:""};return n.for(h=>{if(s.isString(o[0]))h.insertAdjacentHTML(l,o[0]);else{if(!h.parentNode)return;s(o[0]).for(p=>{o[1]&&(p=p.cloneNode(!0)),h.parentNode.insertBefore(p,h[u]||h)})}}),n};s.extend({get:function(n){return n?this[0]:e(this,a=>a)},for:function(n,a=1){let o=e(this,(l,u)=>n(l,u),1);return a?o:[]},await:function(n){return R(this,()=>new Promise((a,o)=>{setTimeout(()=>{a(this)},n)}))},abort:function(){return R(this,()=>C(this,null,function*(){return this.queue=[],this}))},callback:function(n){return R(this,()=>C(this,null,function*(){return yield n(this),this}))},click:function(){return R(this,()=>{for(var n=0;n<this.length;n++){let a=this[n];s.isElement(a)&&a.click()}return this})},focus:function(){return R(this,()=>{for(var n=0;n<this.length;n++){let a=this[n];s.isElement(a)&&a.focus()}return this})},onEvent:function(n,a,o){return R(this,()=>{let d=o||{},{target:l,eventID:u=x()}=d,h=B(d,["target","eventID"]);return h=v({passive:!0,capture:!1},h),this.for(p=>{if(!(s.isElement(p)||s.isShadowRoot(p)))return;let{events:g}=p[s.expando];if(l){let m=a;a=y=>{if(y.target){if(s.isString(l)){let T=y.target.closest(l);T&&(!T||m.call(T,y))}else if(s.isElements(l)){for(let b of l)if(y.target==b)return m.call(b,y)}}}}if(g[u]){let m=g[u];p.removeEventListener(m.eventType,m.callback,m.options)}g[u]={eventType:n,callback:a,options:h},p.addEventListener(n,a,h)}),this})},addEvent:function(n){return R(this,()=>{let{eventType:a,eventID:o=x(),target:l,callback:u,options:h}=n;return h=v({passive:!0,capture:!1},h),this.for(d=>{if(!(s.isElement(d)||s.isShadowRoot(d)))return;let{events:p}=d[s.expando];if(l){let g=u;u=m=>{if(m.target){if(s.isString(l)){let b=m.target.closest(l);b&&(!b||g.call(b,m))}else if(s.isElements(l)){for(let y of l)if(m.target==y)return g.call(y,m)}}}}if(p[o]){let g=p[o];d.removeEventListener(g.eventType,g.callback,g.options)}p[o]={eventType:a,callback:u,options:h},d.addEventListener(a,u,h)}),this})},removeEvent:function(n){return R(this,()=>{let a=s.isArray(n)?n:[n];return this.for(o=>{let{events:l}=o[s.expando];for(let u of a){let h=l[u];h&&o.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(n){return R(this,()=>k(this,r(n,t(this))))},empty:function(){return R(this,()=>k(this,t(this)))},append:function(n){return R(this,()=>{r(n,this)})},remove:function(){return R(this,()=>(this.for((n,a)=>{n&&s.isElement(n)&&(n.remove(),delete this[a])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...n){return R(this,()=>k(this,i(this,"before",...n)))},after:function(...n){return R(this,()=>k(this,i(this,"after",...n)))},find:function(n){return R(this,()=>{let a=[],o=this[0];o||k(this,s()),(s.isElement(o)||s.isShadowRoot(o))&&(s.isString(n)?a=o.querySelectorAll(n):s.isElement(o)&&s(n).for(l=>{let u=o.childNodes;for(let h of u)if(h===l){a.push(h);break}else h.childNodes.length&&(a=[...a,...s(h).find(l).for(d=>d)])})),k(this,s(a))})},parent:function(n){return R(this,()=>{var o,l;let a=s(n?(o=this[0])==null?void 0:o.closest(n):(l=this[0])==null?void 0:l.parentNode);k(this,a)})},children:function(n){return R(this,()=>{let a=this[0].children;s.isExist(n)&&(n=String(n).replace(/^ : /,""),a=n=="first"?a[0]:n=="last"?a[a.length-1]:a[Number(n)]);let o=s(a);return k(this,o)})},addClass:function(...n){return R(this,()=>{let a=n.join(" ").split(/\s+/).filter(o=>o.trim()!=="");return a.length&&this.for(o=>{o&&s.isElement(o)&&o.classList.add(...a)}),this})},removeClass:function(...n){return R(this,()=>{let a=n.join(" ").split(/\s+/).filter(o=>o.trim()!=="");return a.length&&this.for(o=>{o&&s.isElement(o)&&o.classList.remove(...a)}),this})},toggleClass:function(n){return R(this,()=>(n&&this.for(a=>{a.classList.toggle(n)}),this))},hasClass:function(n=""){return this[0]?this[0].classList.contains(n.replace(/^\./,"")):!1},findClass:function(n){let a=[];return s.scope(()=>{this[0]&&(a=[...this[0].classList||[]].filter(o=>o.match(n)))}),a},css:function(n){return R(this,()=>(this.for(a=>{if(s.isElement(a))for(let[o,l]of Object.entries(n)){if(s.isNumber(l)&&o.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){a.style[o]=l+"px";continue}a.style[o]=String(l)}}),this))},getAttribute:function(n){return this[0].getAttribute(String(n))||""},setAttribute:function(n,a){return R(this,()=>(this.for(o=>o.setAttribute(n,a)),this))},getStyleProperty:function(n){let a=this[0];return a&&s.isElement(a)?getComputedStyle(a).getPropertyValue(n):""},setStyleProperty:function(n,a){let o=this[0];return o&&s.isElement(o)&&o.style.setProperty(n,a),this},val:function(){var a;let n=this[0];return(n==null?void 0:n.value)||((a=n==null?void 0:n.dataset)==null?void 0:a.value)},position:function(){return s.isElement(this[0])?this[0].getBoundingClientRect():{x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON:()=>{}}}})}s.uniqueArray=(e,t)=>t?Array.from(new Map(e.map(r=>[s.getRecord(r,t||"0"),r])).values()):Array.from(new Set(e));s.getRecord=(e,t)=>{let r={},i=e;return t.split(".").forEach(n=>{i=i==null?void 0:i[n],r=i}),r};s.Arrayify=s.flatArray=(e,t)=>{if(!s.isArray(e))return[e];let r=[];for(let i of e)r.push(...t=="-R"?s.Arrayify(i,"-R"):[i]);return r};s.Stringify=(...e)=>{let[t,r,i]=e;return JSON.stringify(t,r!=null?r:(()=>{let n=new WeakSet;return(a,o)=>{if(typeof o=="object"&&o!==null){if(n.has(o))return"[Circular Reference]";n.add(o)}return o}})(),i)};s.Objectify=(e,t)=>{try{return JSON.parse(e)}catch(r){return t!=null?t:null}};s.SortifyObject=(e,t)=>{let r={};return!e||!s.isArray(e)&&!s.isRecord(e)?null:(Object.keys(e).sort().forEach(i=>{let n=e[i];if(t){if(s.isRecord(n)){r[i]=s.SortifyObject(n,t);return}if(s.isArray(n)){r[i]=n.map(a=>s.isRecord(a)||s.isArray(a)?s.SortifyObject(a,t):a);return}}r[i]=n}),r)};s.randomNumber=(e=0,t=100,r)=>{if(e>t)return NaN;let i=Math.round(Math.random()*(t-e))+e;return r&&r.length&&r.includes(i)?s.randomNumber(e,t,r):i};s.try=e=>{try{return[e(),!0]}catch(t){return[t,!1]}};s.trySync=e=>C(void 0,null,function*(){try{return[yield e(),!0]}catch(t){return[t,!1]}});s.scope=e=>e();s.scopeSync=e=>C(void 0,null,function*(){return yield e()});s.createElement=function(e){var p;let{tag:t,className:r="",id:i,html:n,attr:a,style:o,parent:l}=e,u=document.createElement(t||"div");if(r&&u.classList.add(...r.split(" ")),i&&(u.id=i),a)for(let g of Object.entries(a)){let m=g[0],y=(p=g[1])!=null?p:"";if(m=="data"&&s.isRecord(y))for(let[b,T]of Object.entries(y))u.dataset[b]=T;else m=="for"?m="htmlFor":m=="tabindex"?m="tabIndex":m=="aria-label"&&(m="ariaLabel"),u[m]=y}if(n&&s(u).append(n),o)for(var[h,d]of Object.entries(o))u.style[h]=d;return l&&s(l).append(u),u};s.setCookie=e=>{let{hostname:t}=new URL(location.toString()),{name:r,value:i="",age:n=60*60*24*365,path:a="/",domain:o=t,secure:l=!1}=e,u=`${r}=${i}max-age=${n}path=${a}domain=${o}`;l&&(u+=" Secure"),document.cookie=u};s.getCookie=e=>{let t=document.cookie.match(new RegExp(e+"=[^]*"));return t?t[0].replace(new RegExp(e+"="),""):""};s.localStorage={set:(e,t)=>{localStorage.setItem(e,s.Stringify(t))},get:e=>{let t=localStorage.getItem(e);return s.Objectify(t,t)}};s.deleteCookie=e=>{document.cookie=e+"=max-age=0"};s.getScreenSize=()=>{let{innerHeight:e,innerWidth:t,scrollY:r,scrollX:i,pageXOffset:n,pageYOffset:a}=window,o=Number(s(document.body).getStyleProperty("--sat").removeLetters()),l=Number(s(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:t,pageHeight:e-o-l,scrollY:r,scrollX:i,pageXOffset:n,pageYOffset:a,safeAreaTop:o,safeAreaBottom:l}};s.getCursor=e=>{var i,n,a,o,l,u,h,d;let t=(o=e.pageX)!=null?o:(a=(i=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:i.pageX)!=null?a:(((n=e==null?void 0:e.originalEvent)==null?void 0:n.touches)||[])[0].pageX,r=(d=e.pageY)!=null?d:(h=(l=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:l.pageY)!=null?h:(((u=e==null?void 0:e.originalEvent)==null?void 0:u.touches)||[])[0].pageY;return{x:t,y:r}};s.pending=(e,t)=>{var i;let r=(i=t||Number(e))!=null?i:-1;return new Promise((n,a)=>{s.isFunction(e)&&e(n),!(r<0)&&setTimeout(()=>{n(!0)},r)})};s.deepMerge=(e,...t)=>{if(!t.length)return e;let r=t.shift();if(s.isRecord(e)&&s.isRecord(r))for(let i in r)s.isRecord(r[i])?(e[i]||Object.assign(e,{[i]:{}}),s.deepMerge(e[i],r[i])):Object.assign(e,{[i]:r[i]});return s.deepMerge(e,...t)};s.deepCopy=e=>{let t=(r,i)=>{if(s.isArray(r))return i.has(r)?r:(i.add(r),r.map(n=>t(n,i)));if(s.isRecord(r)){if(i.has(r))return r;i.add(r);let n={};return Object.entries(r).forEach(([a,o])=>{n[a]=t(o,i)}),n}return r};return t(e,new WeakSet)};s.url={path:{get:e=>{let r=new URL(e||location.href).pathname||"";return r=r.replace(/^\//,"").replace(/\/$/,""),r.split("/")},set:(e,t)=>{let r=new URL(t||location.href);if(s.isString(e))r.pathname=e;else{let i=s.url.path.get();Object.entries(e).forEach(([n,a])=>{i[Number(n)]=a}),r.pathname="/"+i.filter(n=>n!=null).join("/")}return t||history.replaceState({},"",r.pathname+r.search),r.toString()}},search:{get:e=>{let t=new URL(e||location.href),r={};return t.searchParams.forEach((i,n)=>r[n]=i),r},set:(e,t)=>{let r=new URL(t||location.href);return Object.entries(e).forEach(([i,n])=>{r.searchParams.set(i,String(n))}),t||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,t)=>{let r=new URL(t||location.href);return e.forEach(i=>{r.searchParams.delete(i)}),t||history.replaceState({},"",r.pathname+r.search),r.toString()}}};s.queryParams={get:e=>{let t=new URL(e||location.href),r={};return t.searchParams.forEach((i,n)=>r[n]=i),r},set:(e,t)=>{let r=new URL(t||location.href);return Object.entries(e).forEach(([i,n])=>{r.searchParams.set(i,String(n))}),t||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,t)=>{let r=new URL(t||location.href);return e.forEach(i=>{r.searchParams.delete(i)}),t||history.replaceState({},"",r.pathname+r.search),r.toString()}};s.ellipsisText=(e,t)=>{let r=String(e);return r.length>t&&(r=r.slice(0,t)+" ..."),r};s.isEqual=(e,t,r)=>r==null||r?s.Stringify(e)===s.Stringify(t):e===t,s.isExist=e=>e===(e!=null?e:!e),s.isNullish=e=>!s.isExist(e),s.isVoid=e=>e===void 0,s.isNull=e=>e===null,s.isJmini=e=>{var t,r;return((t=e||{})==null?void 0:t.constructor)===s||((r=e||{})==null?void 0:r.__classAlias)===s.__classAlias},s.isString=e=>typeof e=="string",s.isBoolean=e=>typeof e=="boolean",s.isNumber=e=>!isNaN(e)&&typeof e=="number",s.isArray=e=>{let t={}.toString.call(e);return Array.isArray(e)||e instanceof Array||t=="[object NodeList]"||t=="[object HTMLCollection]"},s.isFunction=e=>typeof e=="function",s.isRecord=e=>({}).toString.call(e)==="[object Object]"&&!s.isJmini(e),s.isElement=e=>e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e)),s.isElements=e=>{let t={}.toString.call(e),r=Number(!!e&&!s.isString(e)&&s.isArray(e)&&t!=="[object Text]");if(r&&s.isArray(e)&&t!=="[object NodeList]")for(var i of e)r&=Number(s.isElement(i));return!!r},s.isShadowRoot=e=>e instanceof ShadowRoot,s.isDate=e=>s.isNumber(new Date(e).getTime()),s.isInRange=(e,t,r,i=!0)=>i?t<=e&&e<=r:t<e&&e<r,s.isOneOf=(e,...t)=>{if(!(t!=null&&t.length))return!1;let r=s.isArray(e),i=s.isRecord(e);return r||i?t==null?void 0:t.some(n=>s.isEqual(e,n)):t==null?void 0:t.includes(e)},s.isWhat=e=>{let t="other";return s.isJmini(e)?t="jmini":s.isElement(e)?t="element":s.isElements(e)?t="elements":s.isShadowRoot(e)?t="shadowRoot":s.isString(e)?t="string":s.isNumber(e)?t="number":s.isArray(e)?t="array":s.isFunction(e)?t="function":s.isDate(e)?t="date":typeof e=="undefined"?t="undefined":s.isRecord(e)?t="record":e==null?t="null":isNaN(e)&&(t="NaN"),t};s.is={equal:s.isEqual,exist:s.isExist,nullish:s.isNullish,jmini:s.isJmini,string:s.isString,boolean:s.isBoolean,number:s.isNumber,array:s.isArray,function:s.isFunction,record:s.isRecord,element:s.isElement,elements:s.isElements,shadowRoot:s.isShadowRoot,date:s.isDate,inRange:s.isInRange,oneOf:s.isOneOf,what:s.isWhat};var A={},M={set:(e,t)=>{let r=!0;return Object.entries(e).forEach(([i,n])=>{let a=A[i]||{};a&&a.privateKey&&a.privateKey!=t&&(r=!1),A[i]={privateKey:t,value:n}}),r},update:(e,t)=>{let r=!0;return Object.entries(e).forEach(([i,n])=>{var o;let a=A[i]||{};a&&a.privateKey&&a.privateKey!=t&&(r=!1),A[i]=_(v({},A[i]),{value:v(v({},(o=A[i])==null?void 0:o.value),n)})}),r},get:(e,t)=>{let r=A[e];if(!(r&&r.privateKey&&r.privateKey!=t))return r==null?void 0:r.value},delete:(e,t)=>{let r=A[e];return r&&r.privateKey&&r.privateKey!=t?!1:(delete A[e],!0)}};var te=-new Date().getTimezoneOffset(),ce=(e,t)=>new f.prototype.Time(e,t),f=ce;f.prototype={};f.__classAlias="jmini.Time";var de=function(e,t){if(t&&(this.localTimezoneOffset=t),f.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0?e=new Date:e===0&&(e=new Date(0))),e&&(s.isNumber(e)&&(e=new Date(e)),s.isString(e)&&(e=String(e).trim().replace(/\//g,"-").replace(/ +|\s+/g," ").replace(/\-+/g,"-"),e=e.replace(/^(\d{4}-\d{2}-\d{2})$/,"$1T00:00:00").replace(/^(\d{4}-\d{2}-\d{2})\s+/,"$1T").replace(/^(\d{4}-\d{2}-\d{2}T\d{2})(:?|:+)$/,"$1:00").replace(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(:?|:+)$/,"$1:00"),e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d{1,3})?$/)))){let i=this.getLocalTimezoneOffset(),n=Math.floor(i/60),a=i%60;n>=0&&(e+="+"),e+=n.zeroEmbed(2),e+=":"+a.zeroEmbed(2)}let r=new Date(String(e));return this.set(r)};s.extend({constructor:f,Time:de,__classAlias:f.__classAlias,value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,warekiYear:-1,wareki:"",warekiLabel:"",year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,localTimezoneOffset:void 0,getLocalTimezoneOffset:function(){var e,t;return(t=(e=this.localTimezoneOffset)!=null?e:M.get("jmini/time/env/localTimezoneOffset"))!=null?t:te},setLocalTimezoneOffset:function(e,t){return this.localTimezoneOffset=e,t&&M.set({"jmini/time/env/localTimezoneOffset":e}),this.set(this.value)},clone:function(){return f(this,this.localTimezoneOffset)},set:function(e){var n;this.value=e;let t=s.isDate(e);if(this.validate=t,s.isNullish(this.localTimezoneOffset)&&(this.localTimezoneOffset=(n=M.get("jmini/time/env/localTimezoneOffset"))!=null?n:te),!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;let r=e.getTime()+e.getTimezoneOffset()*6e4,i=new Date(r+this.getLocalTimezoneOffset()*60*1e3);this.ms=e.getTime(),this.year=i.getFullYear(),this.month=i.getMonth()+1,this.date=i.getDate(),this.weekday=i.getDay(),this.hours=i.getHours(),this.minutes=i.getMinutes(),this.seconds=i.getSeconds();{let a=this.year||0,o=this.month||0,l=this.date||0,u=Number(a+o.zeroEmbed(2)+l.zeroEmbed(2));u>=20190501?(this.warekiYear=a-2018,this.wareki="REIWA",this.warekiLabel="\u4EE4\u548C"):u>=19890108?(this.warekiYear=a-1988,this.wareki="HEISEI",this.warekiLabel="\u5E73\u6210"):u>=19261225?(this.warekiYear=a-1925,this.wareki="SHOUWA",this.warekiLabel="\u662D\u548C"):u>=19120730?(this.warekiYear=a-1911,this.wareki="TAISHO",this.warekiLabel="\u5927\u6B63"):u>=19680125?(this.warekiYear=a-1867,this.wareki="MEIJI",this.warekiLabel="\u660E\u6CBB"):(this.warekiYear=0,this.wareki="",this.warekiLabel="")}{let a=new Date(this.year,0,1),o=new Date(a.valueOf());o.setDate(o.getDate()-(a.getDay()+1));let l=this.ms-o.getTime(),u=Math.ceil(l/(1e3*60*60*24));this.weekInYear=Math.ceil(u/7)}{let a=new Date(this.year,this.month-1,1),o=new Date(a.valueOf());o.setDate(o.getDate()-(a.getDay()+1));let l=this.ms-o.getTime(),u=Math.ceil(l/(1e3*60*60*24)),h=Math.ceil(u/7);this.weekInMonth=h}{let a=new Date(this.year,this.month,0),o=a.getDay(),l=new Date(new Date(a).setDate(a.getDate()-o));this.isLastWeekInMonth=this.date>=l.getDate()}return this},isPast:function(){let e=f();return this.value.valueOf()<e.value.valueOf()},isSameYear:function(e){let t=f(e);return this.year==t.year},isSameMonth:function(e){let t=f(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=f(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=f(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},isInRange:function(e,t){return!this.validate||!e.validate||!t.validate?!1:this.value>=e.value&&this.value<=t.value},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf()),r=t.getDate();t.setDate(1),t.setMonth(e-1);let i=f(t).getLastDayOfMonth();return t.setDate(Math.min(r,i.date)),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+e)},addMonth:function(e){return this.setMonth(this.month+e)},addWeek:function(e){return this.addDate(7*e)},addDate:function(e){return this.setDate(this.date+e)},addHours:function(e){return this.setHours(this.hours+e)},addMinutes:function(e){return this.setMinutes(this.minutes+e)},addSeconds:function(e){return this.setSeconds(this.seconds+e)},toFormat:function(e,t){if(!this.validate)return"";let r=this;return s.isExist(t)&&(r=r.clone(),r.setLocalTimezoneOffset(t||0)),e.replace(/\%y/ig,r.year.zeroEmbed(4)).replace(/\%m/ig,r.month.zeroEmbed(2)).replace(/\%d/ig,r.date.zeroEmbed(2)).replace(/\%w/ig,r.weekInYear.zeroEmbed(2)).replace(/\%h/ig,r.hours.zeroEmbed(2)).replace(/\%i/ig,r.minutes.zeroEmbed(2)).replace(/\%s/ig,r.seconds.zeroEmbed(2))},toFormatISO:function(){return this.value.toISOString()},toFormatabbrYMD:function(e,t){if(!this.validate)return"";let r=this.isSameYear(f()),i="%Y/%M/%D";return r&&(i="%M/%D"),e=="JP"&&(i="%Y\u5E74%M\u6708%D\u65E5",r&&(i="%M\u6708%D\u65E5")),this.toFormat(i,t)},toFormatYMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t):""},toFormatYM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708",t):this.toFormat("%Y/%M",t):""},toFormatMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):""},toFormatHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206",t):this.toFormat("%h:%i",t):""},toFormatHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206%s\u79D2",t):this.toFormat("%h:%i:%s",t):""},toFormatYMDHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%i\u5206",t):this.toFormat("%Y/%M/%D %h:%i",t):""},toFormatYMDHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2",t):this.toFormat("%Y/%M/%D %h:%i:%s",t):""},toLangYMD:function(e,t){if(!this.validate)return"";let r=f(),i=r.diff(this);return i.dates==0?"\u4ECA\u65E5":i.dates==1?"\u6628\u65E5":i.dates>=-7&&i.dates<0?-1*i.dates+"\u65E5\u5F8C":i.dates<=7&&i.dates>0?i.dates+"\u65E5\u524D":this.isSameYear(r)?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t)},setFirstOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},setFromFormatHHMM:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})/,"$1:$2"),[r,i]=t.split(":"),n=new Date(this.value.valueOf());return n.setHours(Number(r)),n.setMinutes(Number(i)),this.set(n)},setFromFormatHHMMSS:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(6).replace(/(\d{2})(\d{2})(\d{2})/,"$1:$2:$3"),[r,i,n]=t.split(":"),a=new Date(this.value.valueOf());return a.setHours(Number(r)),a.setMinutes(Number(i)),a.setSeconds(Number(n)),this.set(a)},getFirstDayOfYear:function(){return f(new Date(this.value.getFullYear(),0,1))},getLastDayOfYear:function(){return f(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfMonth:function(){return f(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfMonth:function(){return f(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfWeek:function(){let e=f(this.value);return e.addDate(-e.weekday)},getLastDayOfWeek:function(){let e=f(this.value);return e.addDate(6-e.weekday)},diff:function(e){return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:s.scope(()=>{let t=864e5,r=this.clone().setFirstOfDay(),i=e.clone().setFirstOfDay();return Math.floor((r.ms-i.ms)/t)}),hours:s.scope(()=>{let t=36e5,r=this.clone().setMinutes(0).setSeconds(0).setMilliseconds(0),i=e.clone().setMinutes(0).setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-i.ms)/t)}),minutes:s.scope(()=>{let t=6e4,r=this.clone().setSeconds(0).setMilliseconds(0),i=e.clone().setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-i.ms)/t)}),seconds:s.scope(()=>{let t=this.clone().setMilliseconds(0),r=e.clone().setMilliseconds(0);return Math.floor((t.ms-r.ms)/1e3)}),ms:this.ms-e.ms}},getAge:function(e){let t=e||f(),r=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&r--,r}},f);f.isTimeObject=e=>{var t,r;return((t=e||{})==null?void 0:t.constructor)===f||((r=e||{})==null?void 0:r.__classAlias)===f.__classAlias};f.getFromNumberYYYYMMDD=e=>{let t=Number(e).zeroEmbed(8).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return f(t+" 00:00:00")};f.getShortYMDs=(e,t)=>{let r="",i="";return e.year==t.year&&e.year==f().year?r=e.toFormatMD():r=e.toFormatYMD(),e.year!=t.year?i=t.toFormatYMD():i=t.toFormatMD(),[r,i]};f.getPeriodArray=(e,t,r)=>{let i=[],n=t;if(!t.validate||!r.validate)return i;for(e=="year"?n=f(n).setMonth(1).setDate(1).setFirstOfDay():e=="month"?n=f(n).setDate(1):e=="week"?n=f(n).getFirstDayOfWeek():e=="day"?n=f(n).setFirstOfDay():e=="hours"?n=f(n).setMinutes(0).setSeconds(0).setMilliseconds(0):e=="minutes"?n=f(n).setSeconds(0).setMilliseconds(0):e=="seconds"&&(n=f(n).setMilliseconds(0));n.toFormatYMDHMS().toNumber()<=r.toFormatYMDHMS().toNumber();)i.push(n),e=="year"?n=f(n).addYear(1):e=="month"?n=f(n).addMonth(1):e=="week"?n=f(n).addWeek(1):e=="day"?n=f(n).addDate(1):e=="hours"?n=f(n).addHours(1):e=="minutes"?n=f(n).addMinutes(1):e=="seconds"&&(n=f(n).addSeconds(1));return i};f.prototype.Time.prototype=f.prototype;var pe=(...[e,t,r])=>new S.prototype.Interval(e,t,r),S=pe;S.prototype={};var ye=function(...[e,t,r]){return this.fn=e,this.ms=t,this.key=r,this.isFinished=!1,S.abort(this.key),this.store(),this};s.extend({key:"",ms:0,timeoutIndex:-1,fn:null,isFinished:!1,Interval:ye,store:function(){M.set({["Interval_"+this.key]:this})},once:function(){if(this.fn){let e=()=>{this.fn&&this.fn(),this.isFinished=!0,this.store()};this.timeoutIndex=setTimeout(e,this.ms)}return this.store(),this},start:function(){return this.fn&&(this.timeoutIndex=setInterval(this.fn,this.ms)),this.store(),this},abort:function(){return S.abort(this.timeoutIndex),this},setState:function(e){return Object.entries(e).forEach(([t,r])=>{this.hasOwnProperty(t)&&(this[t]=r)}),this.store(),this}},S);S.abort=e=>{if(s.isNumber(e))return clearInterval(e);let t=M.get("Interval_"+e);t&&(t&&clearInterval(t.timeoutIndex),t.setState({isFinished:!0}))};S.get=e=>M.get("Interval_"+e);S.once=(e,t,r)=>S(e,t,r).once();S.series=(e,t)=>C(void 0,null,function*(){return new Promise(r=>{let i=S.get(e);if(i&&!i.isFinished)return r(null);let n=()=>{S.abort(e)};r(n),t&&S(n,t,e).once()})});S.start=(e,t,r)=>S(e,t,r).start();S.prototype.Interval.prototype=S.prototype;var ge=(e,t)=>new c.prototype.Fetcher(e,t),c=ge;c.prototype={};c.waitList=[];c.setDefaultTrafficControl=0;c.setDefaultTimeout=1e3*60*10;c.abort=e=>{let t="fetcher.abortController."+e,r=M.get(t);console.log(r),r&&r.abort()};c.safetyRecords=e=>{let t={};return Object.entries(e).forEach(([r,i])=>{if(s.isArray(i)){t[r]=i.join(",");return}else if(s.isRecord(i)){Object.entries(c.safetyRecords(i)).forEach(([n,a])=>{t[`${r}.${n}`]=a});return}t[r]=i}),t};c.isReadableStream=e=>e instanceof ReadableStream;c.isReadableStreamReader=e=>e instanceof ReadableStreamDefaultReader;c.streamToContext=(e,t)=>C(void 0,null,function*(){try{let r=(t==null?void 0:t.reader)||e.getReader();if(!c.isReadableStreamReader(r))return{ok:!1,done:!0,data:null};if(!r)return{ok:!1,done:!0,data:null};let i=(t==null?void 0:t.decoder)||new TextDecoder("utf-8"),n=yield r.read();return{ok:!0,done:n.done,data:i.decode(n.value)}}catch(r){return{ok:!1,done:!0,data:r}}});var be=function(e,t){var n;t=t||{};let r=t.body;t.body&&!s.isString(t.body)&&((n=t.bodyStringify)==null||n)&&(r=s.Stringify(t.body||{}));let i=e;return s.isString(e)&&!e.match(/https?:/)&&(i=location.origin+"/"+e.replace(/^\//,"")),this.url=i,this.method=t.method||"get",this.streamStatus="open",this.params=_(v({key:x(),response_format:"json",timeout:c.setDefaultTimeout,trafficControl:c.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:v(v({"Content-Type":"application/json"},c.setDefaultHeaders&&c.setDefaultHeaders()),t.headers),body:r}),this};s.extend({Fetcher:be,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:void 0,onKeyDuplicateCB:void 0,onCompleteCB:void 0,onRetryCB:void 0,isRetry:!1,extraBody:{},abortController:null,setExtraBody:function(e){return this.extraBody=v(v({},this.extraBody),e),this},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(e){return this.onStartCB=e,this},onKeyDuplicate:function(e){return this.onKeyDuplicateCB=e,this},onStream:function(e){return this.onStreamCB=e,this},onResult:function(e){return this.onResultCB=e,this},onComplete:function(e){return this.onCompleteCB=e,this},onRetry:function(e){return this.onRetryCB=e,this},onError:function(e){return this.onErrorCB=e,this},onStreamProcess:function(e){return C(this,null,function*(){let{response:t,errorCB:r,streamCB:i,reader:n,decoder:a}=e,o=t.body,l=this,u=function(){return Z(this,null,function*(){if(!t.ok){s.scope(()=>C(this,null,function*(){let{ok:y,done:b,data:T}=yield c.streamToContext(o,{reader:n,decoder:a});y&&r(T)}));return}let m=!1;for(;!m;){let{ok:y,done:b,data:T}=yield new $(c.streamToContext(o,{reader:n,decoder:a}));l.streamStatus=="abort"?(l.streamStatus="closed",n.cancel(),b=!0):l.streamStatus=="closed"&&(b=!0),b&&(m=b,n.releaseLock()),i(T,b)}})};try{for(var h=ee(u()),d,p,g;d=!(p=yield h.next()).done;d=!1){let m=p.value;;}}catch(p){g=[p]}finally{try{d&&(p=h.return)&&(yield p.call(h))}finally{if(g)throw g[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return C(this,null,function*(){var X;let e=this.params,t=performance.now(),V=e,{key:r,response_format:i,trafficControl:n=0,preventMultiRequest:a,timeout:o,queries:l}=V,u=B(V,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);u.method=this.method;let h=[this.method,r].join("."),d=c.waitList.includes(h);c.waitList=[...c.waitList,h];let p=!1,g=!1,m=!1,y=500,b="InternalServerError",T={},J=null,z=null;n>0&&(z=s.pending(n));let I=new AbortController,re=setTimeout(()=>{I.abort(),console.log("timeout",o)},e.timeout);u.signal=I.signal,this.abortController=I;let W="fetcher.abortController."+this.params.key;M.set({[W]:I});let H=()=>{p=!0},K=()=>(I.abort(),c.waitList=c.waitList.filter(w=>w!=h),{isCancelled:p,isAborted:g,ok:!1,status:0,statusText:"CANCELLED",body:T,requestTime:0,rawData:null});try{if(c.setDefaultOnStart&&(yield c.setDefaultOnStart(e,H)),this.onStartCB&&(yield this.onStartCB(e,H)),p)return K();if(d){if(this.onKeyDuplicateCB&&(yield this.onKeyDuplicateCB(H)),p)return K();if(a)throw y=429,new Error("TooManyRequests")}let w=s.url.search.set(v({},c.safetyRecords(l||{})),String(this.url)),Y=yield fetch(w,u).then(F=>C(this,null,function*(){return m=F.ok,y=F.status,b=F.statusText,J=F,i=="none"||i=="stream"?F:F[i]()})).catch(F=>{throw new Error(F)});M.delete(W),T=Y}catch(w){y==200&&(y=500,m=!1),y==429&&(b="TooManyRequests"),I.signal.aborted&&(y=408,b="Timeout",g=!0),y==500&&(b=String(w)||b),T={errorCode:String(w)}}finally{clearTimeout(re)}let D={isCancelled:p,isAborted:g,ok:m,status:y,statusText:b,body:T,additionalBody:this.extraBody,requestTime:performance.now()-t,rawData:J};if(!m){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let w=yield this.onRetryCB(D.body,this.params,this);if(w)return c.waitList=c.waitList.filter(Y=>Y!=h),this.params=w,this.send()}this.onErrorCB&&this.onErrorCB(D.body)}if(m&&this.onStreamCB&&e.response_format=="stream"){let w=(X=J.body)==null?void 0:X.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:D,reader:w,decoder:new TextDecoder("utf-8")})}return yield z,D.requestTime=performance.now()-t,m&&this.onCompleteCB&&this.onCompleteCB(D.body),this.onResultCB&&this.onResultCB(D,e),c.setDefaultOnEnd&&c.setDefaultOnEnd(D,e),c.waitList=c.waitList.filter(w=>w!=h),D})},abortStream:function(){this.streamStatus="abort"}},c);c.prototype.Fetcher.prototype=c.prototype;var Ce=e=>new E.prototype.Filer(e),E=Ce;E.prototype={};var Re=function(e){this.ok=!0;try{let[t,r]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=r,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this};s.extend({ok:!1,extension:"",type:"",file:{},fileName:"",Filer:Re,isValid:function(){return this.ok},toBlob:function(){return C(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return C(this,null,function*(){return yield this.file.convert("dataURL")})},toAarrayBuffer:function(){return C(this,null,function*(){return yield this.file.convert("arrayBuffer")})},toObjectURL:function(){return C(this,null,function*(){return URL.createObjectURL(this.file)})},updateFileName:function(e){let t=new File([this.file],e+"."+this.extension);return this.file=t,this.fileName=e,this},updateMimeType:function(e){return this.file=new File([this.file],this.fileName+"."+this.extension,{type:e}),this.type=e,this},updateExtension:function(e){let t=new File([this.file],this.fileName+"."+e);return this.file=t,this.extension=e,this}},E);E.fromFile=e=>E(e);E.fromBlob=(e,t)=>{let r=(t==null?void 0:t.fileName)||"file",i=(t==null?void 0:t.extension)||"",n=new File([e],r+"."+i,{type:t==null?void 0:t.mimeType});return E(n)};E.fromArrayBuffer=(e,t)=>E.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t);E.fromObjectURL=(e,t)=>C(void 0,null,function*(){let r=yield c(e,{response_format:"blob"}).get();return r.ok?E.fromBlob(r.body,t):E({})});E.fromDataURL=(e,t)=>{let r=e.toBlob((t==null?void 0:t.mimeType)||"");return r?E.fromBlob(r,t):E({})};E.prototype.Filer.prototype=E.prototype;var Se=function(e){let t=e,r=null;return t.use((i,n,a)=>{let o=n;o.return=l=>{let{ok:u,status:h,body:d={},bodyStringify:p=!0}=l||{};h=h!=null?h:(u!=null?u:!0)&&200||403;let g=d;return p&&!s.isString(d)&&(g=s.Stringify(d)),n.status(h).end(g)},a()}),t.onPathRouter=function(i){return r=i,this},t.pathRouter=function(i){if(!r)return;let n=r(i);return n.route(i),t.use(i,n),n},t.exception=function(i){return t.use(i),this},t},N=Se;N.getLocalIP=e=>{let t="";return s.scope(()=>{if(!e)return;let r=e.networkInterfaces();for(let[i,n]of Object.entries(r))n.forEach(a=>{!a.internal&&a.family==="IPv4"&&!a.address.match(/^(169|127)/)&&(t=a.address)})}),t};N.getIP=function(e){var i;return(((e==null?void 0:e.headers["x-forwarded-for"])||((i=e==null?void 0:e.socket)==null?void 0:i.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};s.copyToClipboard=e=>C(void 0,null,function*(){let t="";s.isString(e)?t=e:s.isFunction(e)&&(t=e());let r={ok:!1,body:"NotSupported"};return yield C(void 0,null,function*(){let i;if(navigator.clipboard){if(i=yield navigator.clipboard.writeText(t).then(()=>!0,()=>!1),!i)return}else{let n=document.createElement("input");if(s(document.body).append(n),n.value=t,n.select(),i=document.execCommand("copy"),document.body.removeChild(n),!i)return}r={ok:!0,body:""}}),r});s.ImageLoader=(e,t)=>{let r;return new Promise((i,n)=>{r=t||new Image,r.onload=()=>i(r),r.onerror=a=>n(a),r.crossOrigin="anonymous",r.src=e})};s.formatCharacter={postal:{JP:e=>{let t="";return e=String(e).replace(/\D/ig,""),e.length==7&&(t=e.replace(/^(\d{3})(.*)/,"$1-$2")),t}},tel:{_:e=>{let t=e;return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t},mobile:e=>{let t="";return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),t},fixed:e=>{let t="";return e=String(e).removeLetters(),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t}}};s.transformer={weekday:{ENG:e=>["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur"][e]+"day",JP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]+"\u66DC\u65E5",shortJP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]},wareki:e=>{let t=[],r=[],i=!1;return[{From:1868,To:1912,name:"\u660E\u6CBB"},{From:1912,To:1926,name:"\u5927\u6B63"},{From:1926,To:1989,name:"\u662D\u548C"},{From:1989,To:2019,name:"\u5E73\u6210"},{From:2019,To:1e5,name:"\u4EE4\u548C"}].forEach(a=>{let{From:o,To:l,name:u}=a;if(o<=e&&e<=l){let h=e-o+1;h==1&&(i=!0,h="\u5143"),r.push(u+h+"\u5E74"),t.push(u)}}),{era:t,value:r,gap:i}}};s.interval=S;c.setDefaultHeaders=()=>({});var Ee=s;0&&(module.exports={Fetcher,Filer,Server,Time,UUID,useStore});
1
+ "use strict";var N=Object.defineProperty,ne=Object.defineProperties,ie=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var j=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var L=Math.pow,G=(e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&G(e,r,t[r]);if(P)for(var r of P(t))Q.call(t,r)&&G(e,r,t[r]);return e},_=(e,t)=>ne(e,se(t));var O=(e,t)=>{var r={};for(var i in e)U.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&P)for(var i of P(e))t.indexOf(i)<0&&Q.call(e,i)&&(r[i]=e[i]);return r};var oe=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ae(t))!U.call(e,n)&&n!==r&&N(e,n,{get:()=>t[n],enumerable:!(i=ie(t,n))||i.enumerable});return e};var ue=e=>le(N({},"__esModule",{value:!0}),e);var C=(e,t,r)=>new Promise((i,n)=>{var a=u=>{try{l(r.next(u))}catch(h){n(h)}},o=u=>{try{l(r.throw(u))}catch(h){n(h)}},l=u=>u.done?i(u.value):Promise.resolve(u.value).then(a,o);l((r=r.apply(e,t)).next())}),$=function(e,t){this[0]=e,this[1]=t},Z=(e,t,r)=>{var i=(o,l,u,h)=>{try{var d=r[o](l),y=(l=d.value)instanceof $,g=d.done;Promise.resolve(y?l[0]:l).then(m=>y?i(o==="return"?o:"next",l[1]?{done:m.done,value:m.value}:m,u,h):u({value:m,done:g})).catch(m=>i("throw",m,u,h))}catch(m){h(m)}},n=o=>a[o]=l=>new Promise((u,h)=>i(o,l,u,h)),a={};return r=r.apply(e,t),a[j("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a};var ee=(e,t,r)=>(t=e[j("asyncIterator")])?t.call(e):(e=e[j("iterator")](),t={},r=(i,n)=>(n=e[i])&&(t[i]=a=>new Promise((o,l,u)=>(a=n.call(e,a),u=a.done,Promise.resolve(a.value).then(h=>o({value:h,done:u}),l)))),r("next"),r("return"),t);var ve={};oe(ve,{Fetcher:()=>c,Filer:()=>E,Server:()=>B,Time:()=>f,UUID:()=>x,default:()=>Ee,useStore:()=>M});module.exports=ue(ve);typeof HTMLElement!="undefined"&&(HTMLElement.prototype.position=function(){return this.getBoundingClientRect()});typeof String!="undefined"&&(String.prototype.compress=function(){return this.trim().replace(/(\s|\n|\t)/ig,"")},String.prototype.encode=function(){return encodeURIComponent(this)},String.prototype.decode=function(){return decodeURIComponent(this)},String.prototype.toUpper=function(){return this.toLocaleUpperCase()},String.prototype.toLower=function(){return this.toLocaleLowerCase()},String.prototype.toCapital=function(){let e=this;return e&&(e=e.replace(/^./,this[0].toUpper()).replace(/(\s|_|-)[a-z]{1}/ig,t=>t[1].toUpper())),e},String.prototype.clip=function(e,t){return this.slice(e,t)},String.prototype.partReplace=function(...e){let t="";if(e.length==2){let[r,i]=e;t=[this.slice(0,r),i,this.slice(r+i.length)].join("")}if(e.length==3){let[r,i,n]=e;t=[this.slice(0,r),n,this.slice(r+i)].join("")}return t},String.prototype.toBlob=function(e){let t=atob(this.replace(/^.*,/,"")),r=new Uint8Array(t.length);for(var i=0;i<t.length;i++)r[i]=t.charCodeAt(i);try{var n=new Blob([r.buffer],{type:e})}catch(a){return!1}return n},String.prototype.toNumber=function(){let e=this.replace(/[^\d.-]/g,"").replace(/(-)(?=.*\d)/g,"").replace(/(\d+)\.(\d+)\.(\d+)/g,"$1.$2$3");return Number(e)||0},String.prototype.removeLetters=function(){return this.replace(/[\D]/ig,"")},String.prototype.removeSpecifics=function(){return this.replace(/[^\w\s\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]|_/uig,"")},String.prototype.removeJP=function(){return this.replace(/[\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]+/uig,"")},String.prototype.zen2hanNumber=function(){return this.replace(/[0-9]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)}).replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,"-").replace(/¥/,"\xA5").replace(/、/,",").replace(/(/,"(").replace(/)/,")").replace(/+/,"+")},String.prototype.escapeRegExChar=function(){return this.replace(/\\/g,"\\\\").replace(/(\?|\^|\$|\.|\||\*|\+|\(|\)|\{|\}|\[|\])/g,"\\$1")});typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){let t=Number(this)<0,r=Math.abs(Number(this));return isNaN(r)?"":(t?"-":"")+String(r).padStart(e||2,"0")},Number.prototype.toRate=function(e,t){let r=L(10,t!=null?t:2);return Math.round(this/e*r*100)/r},Number.prototype.toRatio=function(e,t){let r=L(10,t!=null?t:2);return Math.round(this/e*r)/r},Number.prototype.rank=function(e){let t=L(10,e!=null?e:1),r=Number(this);if(r<1e3)return String(this);let i=r.toLocaleString().replace(/\d/ig,"").length;return Math.round(r/L(1e3,i)*t)/t+("KMGTPEZY"[i-1]||"")},Number.prototype.rankJp=function(){let e=Number(this),t="";return e>=1e12?t=`${e/1e12}\u5146`:e>=1e8?t=`${e/1e8}\u5104`:e>=1e4?t=`${e/1e4}\u4E07`:e>=1e3?t=`${e/1e3}\u5343`:t=`${e.toLocaleString()}`,t},Number.prototype.toDate=function(e="/"){let t=String(this),r=t.slice(0,4),i=t.slice(4,6),n=t.slice(6,8),a=[];return r.length!=4||a.push(r),i.length!=2||a.push(i),n.length!=2||a.push(n),a.join(e)});if(typeof Array!="undefined"){let e=(r,...i)=>{var a;let n=r;for(let o of i){if(o!==(o!=null?o:!o))break;n=(a=(n||{})[o!=null?o:""])!=null?a:null}return n},t=r=>typeof Number(r)=="number"&&!isNaN(r);Array.prototype.sortBy=function(r,i,n,a){let l=(Array.isArray(i)?i:i?[i]:[""]).map(d=>String(d).match(/([^\.\[\]"]+)/g)||[]),u=l.map((d,y)=>1);return this.map(d=>({origin:d,sortVal:l.map((y,g)=>{let m=e(d,...y);if(t(m))return Number(m);let p=String(m).replace(/¥|,/g,"");return t(p)?Number(p):(u[g]=0,p.replace(/(\d+)/g,b=>b.padStart(10,"0")))})})).sort((d,y)=>{for(let g=0;g<l.length;g++){let m=d.sortVal[g],p=y.sortVal[g];if(u[g]){if(m>p)return 1*r;if(m<p)return-1*r;continue}let b=String(m).localeCompare(String(p),n,a);if(b!=0)return b*r}return 0}).map((d,y)=>(this[y]=d.origin,d.origin))},Array.prototype.toASC=function(...r){return this.sortBy(1,...r)},Array.prototype.toDESC=function(...r){return this.sortBy(-1,...r)},Array.prototype.getSum=function(...r){return this.reduce((i,n)=>i+(r?e(n,...r):Number(n)||0),0)},Array.prototype.getAve=function(...r){return this.getSum(...r)/this.length},Array.prototype.getMedian=function(...r){let i=this.map(a=>r?e(a,...r):Number(a)||0);i.sort((a,o)=>a-o);let n=Math.floor(i.length/2);return i.length%2===0?(i[n-1]+i[n])/2:i[n]},Array.prototype.getMin=function(...r){let i=this.map(n=>r?e(n,...r):Number(n)||0);return Math.min(...i)},Array.prototype.getMax=function(...r){let i=this.map(n=>r?e(n,...r):Number(n)||0);return Math.max(...i)},Array.prototype.chunk=function(r){let i=[];for(let n=0;n<this.length;n+=r)i.push(this.slice(n,n+r));return i},Array.prototype.forEachChunk=function(r,i,n){return C(this,null,function*(){let a=[],o=this.chunk(r);if(n)yield Promise.all(o.map((l,u)=>C(this,null,function*(){a[u]=v({ok:!0},yield i(l,u))})));else for(let l=0;l<o.length;l++)a.push(v({ok:!0},yield i(o[l],l)));return[a.every(l=>l.ok),a]})}}typeof File!="undefined"&&(File.prototype.convert=function(e){e=e||"dataURL";let t="readAs"+(e==null?void 0:e.toCapital());return new Promise((r,i)=>{let n=new FileReader;n.onload=a=>{r(n.result)},n.onerror=a=>i(n.error||a),n[t](this)})},File.prototype.clone=function(){return new File([this.slice(0,this.size,this.type)],this.name,{type:this.type,lastModified:this.lastModified})});var he=(e=24)=>Array.from({length:e}).map((t,r)=>{let i=r==0?25:35,n=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*i)][n?"toUpper":"toLower"]()}).join(""),x=he;x.get128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");x.get32Hex=(e="Formatted",t="-")=>{let r=Array.from({length:32}).map((i,n)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(r=[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20,32)].join(t)),r};x.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();var me=e=>new s.prototype.jmini(e),s=me;s.prototype={};s.extend=function(e,t=s){for(var[r,i]of Object.entries(e))t.prototype[r]=i};s.expando="__jmini_"+x();s.__classAlias="jmini";var R=(e,t)=>(e.queue.push(t),q(e),e),q=e=>C(void 0,null,function*(){if(e.queueProcess||!e.queue.length)return;e.queueProcess=!0;let t=e.queue.shift();t&&(yield t()),e.queueProcess=!1,q(e)}),k=(e,t)=>{for(let r=0;r<e.length;r++)e[r]=null;for(let[r,i]of Object.entries(t))r.match(/queue/)||(e[r]=i);return e},fe=(e,t)=>{if(t.length){for(var r=0;r<t.length;r++){let i=t[r];i&&(i[s.expando]||(s.isElement(i)||s.isShadowRoot(i))&&(i[s.expando]={events:{}})),e[r]=i}e.length=t.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,q(e),e};s.extend({constructor:s,__classAlias:s.__classAlias,jmini:function(e){return this.src=e,this.srcType=s.isWhat(e),this.queueProcess=!0,this.queue=[],fe(this,s.isJmini(e)?e.get():s.isElement(e)?[e]:s.isElements(e)?e:s.isShadowRoot(e)?[e]:s.isString(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}});s.prototype[String(Symbol.iterator)]=[][Symbol.iterator];s.prototype.jmini.prototype=s.prototype;{let e=function(n,a,o){let l=[];for(let u=0;u<(n.length||0);u++)l.push(a(n[u],u));return o&&(l=l.filter(u=>u!=null)),l},t=n=>(n.for((a,o)=>{if(!(s.isElement(a)||s.isShadowRoot(a)))return;let l=a.cloneNode(),u=a.parentNode;u&&u.replaceChild(l,a),n[o]=l}),n),r=(n,a)=>(s(a).for(o=>{if(n&&(s.isElement(o)||s.isShadowRoot(o)))if(s.isString(n)||s.isNumber(n))n=String(n),o.insertAdjacentHTML("beforeend",String(n));else if(s.isElement(n))o.appendChild(n);else{s.isJmini(n)?n=n.get():s.isElement(n)?n=[n]:s.isRecord(n)&&(n=[s(n)]);for(var l=0;l<n.length;l++)r(n[l],o)}}),a),i=(n,a,...o)=>{let{p:l,s:u}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[a]||{p:"",s:""};return n.for(h=>{if(s.isString(o[0]))h.insertAdjacentHTML(l,o[0]);else{if(!h.parentNode)return;s(o[0]).for(y=>{o[1]&&(y=y.cloneNode(!0)),h.parentNode.insertBefore(y,h[u]||h)})}}),n};s.extend({get:function(n){return n?this[0]:e(this,a=>a)},for:function(n,a=1){let o=e(this,(l,u)=>n(l,u),1);return a?o:[]},await:function(n){return R(this,()=>new Promise((a,o)=>{setTimeout(()=>{a(this)},n)}))},abort:function(){return R(this,()=>C(this,null,function*(){return this.queue=[],this}))},callback:function(n){return R(this,()=>C(this,null,function*(){return yield n(this),this}))},click:function(){return R(this,()=>{for(var n=0;n<this.length;n++){let a=this[n];s.isElement(a)&&a.click()}return this})},focus:function(){return R(this,()=>{for(var n=0;n<this.length;n++){let a=this[n];s.isElement(a)&&a.focus()}return this})},onEvent:function(n,a,o){return R(this,()=>{let d=o||{},{target:l,eventID:u=x()}=d,h=O(d,["target","eventID"]);return h=v({passive:!0,capture:!1},h),this.for(y=>{if(!(s.isElement(y)||s.isShadowRoot(y)))return;let{events:g}=y[s.expando];if(l){let m=a;a=p=>{if(p.target){if(s.isString(l)){let T=p.target.closest(l);T&&(!T||m.call(T,p))}else if(s.isElements(l)){for(let b of l)if(p.target==b)return m.call(b,p)}}}}if(g[u]){let m=g[u];y.removeEventListener(m.eventType,m.callback,m.options)}g[u]={eventType:n,callback:a,options:h},y.addEventListener(n,a,h)}),this})},addEvent:function(n){return R(this,()=>{let{eventType:a,eventID:o=x(),target:l,callback:u,options:h}=n;return h=v({passive:!0,capture:!1},h),this.for(d=>{if(!(s.isElement(d)||s.isShadowRoot(d)))return;let{events:y}=d[s.expando];if(l){let g=u;u=m=>{if(m.target){if(s.isString(l)){let b=m.target.closest(l);b&&(!b||g.call(b,m))}else if(s.isElements(l)){for(let p of l)if(m.target==p)return g.call(p,m)}}}}if(y[o]){let g=y[o];d.removeEventListener(g.eventType,g.callback,g.options)}y[o]={eventType:a,callback:u,options:h},d.addEventListener(a,u,h)}),this})},removeEvent:function(n){return R(this,()=>{let a=s.isArray(n)?n:[n];return this.for(o=>{let{events:l}=o[s.expando];for(let u of a){let h=l[u];h&&o.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(n){return R(this,()=>k(this,r(n,t(this))))},empty:function(){return R(this,()=>k(this,t(this)))},append:function(n){return R(this,()=>{r(n,this)})},remove:function(){return R(this,()=>(this.for((n,a)=>{n&&s.isElement(n)&&(n.remove(),delete this[a])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...n){return R(this,()=>k(this,i(this,"before",...n)))},after:function(...n){return R(this,()=>k(this,i(this,"after",...n)))},find:function(n){return R(this,()=>{let a=[],o=this[0];o||k(this,s()),(s.isElement(o)||s.isShadowRoot(o))&&(s.isString(n)?a=o.querySelectorAll(n):s.isElement(o)&&s(n).for(l=>{let u=o.childNodes;for(let h of u)if(h===l){a.push(h);break}else h.childNodes.length&&(a=[...a,...s(h).find(l).for(d=>d)])})),k(this,s(a))})},parent:function(n){return R(this,()=>{var o,l;let a=s(n?(o=this[0])==null?void 0:o.closest(n):(l=this[0])==null?void 0:l.parentNode);k(this,a)})},children:function(n){return R(this,()=>{let a=this[0].children;s.isExist(n)&&(n=String(n).replace(/^ : /,""),a=n=="first"?a[0]:n=="last"?a[a.length-1]:a[Number(n)]);let o=s(a);return k(this,o)})},addClass:function(...n){return R(this,()=>{let a=n.join(" ").split(/\s+/).filter(o=>o.trim()!=="");return a.length&&this.for(o=>{o&&s.isElement(o)&&o.classList.add(...a)}),this})},removeClass:function(...n){return R(this,()=>{let a=n.join(" ").split(/\s+/).filter(o=>o.trim()!=="");return a.length&&this.for(o=>{o&&s.isElement(o)&&o.classList.remove(...a)}),this})},toggleClass:function(n){return R(this,()=>(n&&this.for(a=>{a.classList.toggle(n)}),this))},hasClass:function(n=""){return this[0]?this[0].classList.contains(n.replace(/^\./,"")):!1},findClass:function(n){let a=[];return s.scope(()=>{this[0]&&(a=[...this[0].classList||[]].filter(o=>o.match(n)))}),a},css:function(n){return R(this,()=>(this.for(a=>{if(s.isElement(a))for(let[o,l]of Object.entries(n)){if(s.isNumber(l)&&o.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){a.style[o]=l+"px";continue}a.style[o]=String(l)}}),this))},getAttribute:function(n){return this[0].getAttribute(String(n))||""},setAttribute:function(n,a){return R(this,()=>(this.for(o=>o.setAttribute(n,a)),this))},getStyleProperty:function(n){let a=this[0];return a&&s.isElement(a)?getComputedStyle(a).getPropertyValue(n):""},setStyleProperty:function(n,a){let o=this[0];return o&&s.isElement(o)&&o.style.setProperty(n,a),this},val:function(){var a;let n=this[0];return(n==null?void 0:n.value)||((a=n==null?void 0:n.dataset)==null?void 0:a.value)},position:function(){return s.isElement(this[0])?this[0].getBoundingClientRect():{x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON:()=>{}}}})}s.uniqueArray=(e,t)=>t?Array.from(new Map(e.map(r=>[s.getRecord(r,t||"0"),r])).values()):Array.from(new Set(e));s.getRecord=(e,t)=>{let r={},i=e;return t.split(".").forEach(n=>{i=i==null?void 0:i[n],r=i}),r};s.Arrayify=s.flatArray=(e,t)=>{if(!s.isArray(e))return[e];let r=[];for(let i of e)r.push(...t=="-R"?s.Arrayify(i,"-R"):[i]);return r};s.Stringify=(...e)=>{let[t,r,i]=e;return JSON.stringify(t,r!=null?r:(()=>{let n=new WeakSet;return(a,o)=>{if(typeof o=="object"&&o!==null){if(n.has(o))return"[Circular Reference]";n.add(o)}return o}})(),i)};s.Objectify=(e,t)=>{try{return JSON.parse(e)}catch(r){return t!=null?t:null}};s.SortifyObject=(e,t)=>{let r={};return!e||!s.isArray(e)&&!s.isRecord(e)?null:(Object.keys(e).sort().forEach(i=>{let n=e[i];if(t){if(s.isRecord(n)){r[i]=s.SortifyObject(n,t);return}if(s.isArray(n)){r[i]=n.map(a=>s.isRecord(a)||s.isArray(a)?s.SortifyObject(a,t):a);return}}r[i]=n}),r)};s.randomNumber=(e=0,t=100,r)=>{if(e>t)return NaN;let i=Math.round(Math.random()*(t-e))+e;return r&&r.length&&r.includes(i)?s.randomNumber(e,t,r):i};s.try=e=>{try{return[e(),!0]}catch(t){return[t,!1]}};s.trySync=e=>C(void 0,null,function*(){try{return[yield e(),!0]}catch(t){return[t,!1]}});s.scope=e=>e();s.scopeSync=e=>C(void 0,null,function*(){return yield e()});s.createElement=function(e){var y;let{tag:t,className:r="",id:i,html:n,attr:a,style:o,parent:l}=e,u=document.createElement(t||"div");if(r&&u.classList.add(...r.split(" ")),i&&(u.id=i),a)for(let g of Object.entries(a)){let m=g[0],p=(y=g[1])!=null?y:"";if(m=="data"&&s.isRecord(p))for(let[b,T]of Object.entries(p))u.dataset[b]=T;else m=="for"?m="htmlFor":m=="tabindex"?m="tabIndex":m=="aria-label"&&(m="ariaLabel"),u[m]=p}if(n&&s(u).append(n),o)for(var[h,d]of Object.entries(o))u.style[h]=d;return l&&s(l).append(u),u};s.setCookie=e=>{let{hostname:t}=new URL(location.toString()),{name:r,value:i="",age:n=60*60*24*365,path:a="/",domain:o=t,secure:l=!1}=e,u=`${r}=${i}max-age=${n}path=${a}domain=${o}`;l&&(u+=" Secure"),document.cookie=u};s.getCookie=e=>{let t=document.cookie.match(new RegExp(e+"=[^]*"));return t?t[0].replace(new RegExp(e+"="),""):""};s.localStorage={set:(e,t)=>{localStorage.setItem(e,s.Stringify(t))},get:e=>{let t=localStorage.getItem(e);return s.Objectify(t,t)}};s.deleteCookie=e=>{document.cookie=e+"=max-age=0"};s.getScreenSize=()=>{let{innerHeight:e,innerWidth:t,scrollY:r,scrollX:i,pageXOffset:n,pageYOffset:a}=window,o=Number(s(document.body).getStyleProperty("--sat").removeLetters()),l=Number(s(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:t,pageHeight:e-o-l,scrollY:r,scrollX:i,pageXOffset:n,pageYOffset:a,safeAreaTop:o,safeAreaBottom:l}};s.getCursor=e=>{var i,n,a,o,l,u,h,d;let t=(o=e.pageX)!=null?o:(a=(i=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:i.pageX)!=null?a:(((n=e==null?void 0:e.originalEvent)==null?void 0:n.touches)||[])[0].pageX,r=(d=e.pageY)!=null?d:(h=(l=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:l.pageY)!=null?h:(((u=e==null?void 0:e.originalEvent)==null?void 0:u.touches)||[])[0].pageY;return{x:t,y:r}};s.pending=(e,t)=>{var i;let r=(i=t||Number(e))!=null?i:-1;return new Promise((n,a)=>{s.isFunction(e)&&e(n),!(r<0)&&setTimeout(()=>{n(!0)},r)})};s.deepMerge=(e,...t)=>{if(!t.length)return e;let r=t.shift();if(s.isRecord(e)&&s.isRecord(r))for(let i in r)s.isRecord(r[i])?(e[i]||Object.assign(e,{[i]:{}}),s.deepMerge(e[i],r[i])):Object.assign(e,{[i]:r[i]});return s.deepMerge(e,...t)};s.deepCopy=e=>{let t=(r,i)=>{if(s.isArray(r))return i.has(r)?r:(i.add(r),r.map(n=>t(n,i)));if(s.isRecord(r)){if(i.has(r))return r;i.add(r);let n={};return Object.entries(r).forEach(([a,o])=>{n[a]=t(o,i)}),n}return r};return t(e,new WeakSet)};s.url={path:{get:e=>{let r=new URL(e||location.href).pathname||"";return r=r.replace(/^\//,"").replace(/\/$/,""),r.split("/")},set:(e,t)=>{let r=new URL(t||location.href);if(s.isString(e))r.pathname=e;else{let i=s.url.path.get();Object.entries(e).forEach(([n,a])=>{i[Number(n)]=a}),r.pathname="/"+i.filter(n=>n!=null).join("/")}return t||history.replaceState({},"",r.pathname+r.search),r.toString()}},search:{get:e=>{let t=new URL(e||location.href),r={};return t.searchParams.forEach((i,n)=>r[n]=i),r},set:(e,t)=>{let r=new URL(t||location.href);return Object.entries(e).forEach(([i,n])=>{r.searchParams.set(i,String(n))}),t||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,t)=>{let r=new URL(t||location.href);return e.forEach(i=>{r.searchParams.delete(i)}),t||history.replaceState({},"",r.pathname+r.search),r.toString()}}};s.queryParams={get:e=>{let t=new URL(e||location.href),r={};return t.searchParams.forEach((i,n)=>r[n]=i),r},set:(e,t)=>{let r=new URL(t||location.href);return Object.entries(e).forEach(([i,n])=>{r.searchParams.set(i,String(n))}),t||history.replaceState({},"",r.pathname+r.search),r.toString()},delete:(e,t)=>{let r=new URL(t||location.href);return e.forEach(i=>{r.searchParams.delete(i)}),t||history.replaceState({},"",r.pathname+r.search),r.toString()}};s.ellipsisText=(e,t)=>{let r=String(e);return r.length>t&&(r=r.slice(0,t)+" ..."),r};s.isEqual=(e,t,r)=>r==null||r?s.Stringify(e)===s.Stringify(t):e===t,s.isExist=e=>e===(e!=null?e:!e),s.isNullish=e=>!s.isExist(e),s.isVoid=e=>e===void 0,s.isNull=e=>e===null,s.isJmini=e=>{var t,r;return((t=e||{})==null?void 0:t.constructor)===s||((r=e||{})==null?void 0:r.__classAlias)===s.__classAlias},s.isString=e=>typeof e=="string",s.isBoolean=e=>typeof e=="boolean",s.isNumber=e=>!isNaN(e)&&typeof e=="number",s.isArray=e=>{let t={}.toString.call(e);return Array.isArray(e)||e instanceof Array||t=="[object NodeList]"||t=="[object HTMLCollection]"},s.isFunction=e=>typeof e=="function",s.isRecord=e=>({}).toString.call(e)==="[object Object]"&&!s.isJmini(e),s.isElement=e=>e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e)),s.isElements=e=>{let t={}.toString.call(e),r=Number(!!e&&!s.isString(e)&&s.isArray(e)&&t!=="[object Text]");if(r&&s.isArray(e)&&t!=="[object NodeList]")for(var i of e)r&=Number(s.isElement(i));return!!r},s.isShadowRoot=e=>e instanceof ShadowRoot,s.isDate=e=>s.isNumber(new Date(e).getTime()),s.isInRange=(e,t,r,i=!0)=>i?t<=e&&e<=r:t<e&&e<r,s.isOneOf=(e,...t)=>{if(!(t!=null&&t.length))return!1;let r=s.isArray(e),i=s.isRecord(e);return r||i?t==null?void 0:t.some(n=>s.isEqual(e,n)):t==null?void 0:t.includes(e)},s.isWhat=e=>{let t="other";return s.isJmini(e)?t="jmini":s.isElement(e)?t="element":s.isElements(e)?t="elements":s.isShadowRoot(e)?t="shadowRoot":s.isString(e)?t="string":s.isNumber(e)?t="number":s.isArray(e)?t="array":s.isFunction(e)?t="function":s.isDate(e)?t="date":typeof e=="undefined"?t="undefined":s.isRecord(e)?t="record":e==null?t="null":isNaN(e)&&(t="NaN"),t};s.is={equal:s.isEqual,exist:s.isExist,nullish:s.isNullish,jmini:s.isJmini,string:s.isString,boolean:s.isBoolean,number:s.isNumber,array:s.isArray,function:s.isFunction,record:s.isRecord,element:s.isElement,elements:s.isElements,shadowRoot:s.isShadowRoot,date:s.isDate,inRange:s.isInRange,oneOf:s.isOneOf,what:s.isWhat};var A={},M={set:(e,t)=>{let r=!0;return Object.entries(e).forEach(([i,n])=>{let a=A[i]||{};a&&a.privateKey&&a.privateKey!=t&&(r=!1),A[i]={privateKey:t,value:n}}),r},update:(e,t)=>{let r=!0;return Object.entries(e).forEach(([i,n])=>{var o;let a=A[i]||{};a&&a.privateKey&&a.privateKey!=t&&(r=!1),A[i]=_(v({},A[i]),{value:v(v({},(o=A[i])==null?void 0:o.value),n)})}),r},get:(e,t)=>{let r=A[e];if(!(r&&r.privateKey&&r.privateKey!=t))return r==null?void 0:r.value},delete:(e,t)=>{let r=A[e];return r&&r.privateKey&&r.privateKey!=t?!1:(delete A[e],!0)}};var te=-new Date().getTimezoneOffset(),ce=(e,t)=>new f.prototype.Time(e,t),f=ce;f.prototype={};f.__classAlias="jmini.Time";var de=function(e,t){if(t&&(this.localTimezoneOffset=t),f.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0?e=new Date:e===0&&(e=new Date(0))),e&&(s.isNumber(e)&&(e=new Date(e)),s.isString(e)&&(e=String(e).trim().replace(/\//g,"-").replace(/ +|\s+/g," ").replace(/\-+/g,"-"),e=e.replace(/^(\d{4}-\d{2}-\d{2})$/,"$1T00:00:00").replace(/^(\d{4}-\d{2}-\d{2})\s+/,"$1T").replace(/^(\d{4}-\d{2}-\d{2}T\d{2})(:?|:+)$/,"$1:00").replace(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(:?|:+)$/,"$1:00"),e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d{1,3})?$/)))){let i=this.getLocalTimezoneOffset(),n=Math.floor(i/60),a=i%60;n>=0&&(e+="+"),e+=n.zeroEmbed(2),e+=":"+a.zeroEmbed(2)}let r=new Date(String(e));return this.set(r)};s.extend({constructor:f,Time:de,__classAlias:f.__classAlias,value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,warekiYear:-1,wareki:"",warekiLabel:"",year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,localTimezoneOffset:void 0,getLocalTimezoneOffset:function(){var e,t;return(t=(e=this.localTimezoneOffset)!=null?e:M.get("jmini/time/env/localTimezoneOffset"))!=null?t:te},setLocalTimezoneOffset:function(e,t){return this.localTimezoneOffset=e,t&&M.set({"jmini/time/env/localTimezoneOffset":e}),this.set(this.value)},clone:function(){return f(this,this.localTimezoneOffset)},set:function(e){var n;this.value=e;let t=s.isDate(e);if(this.validate=t,s.isNullish(this.localTimezoneOffset)&&(this.localTimezoneOffset=(n=M.get("jmini/time/env/localTimezoneOffset"))!=null?n:te),!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;let r=e.getTime()+e.getTimezoneOffset()*6e4,i=new Date(r+this.getLocalTimezoneOffset()*60*1e3);this.ms=e.getTime(),this.year=i.getFullYear(),this.month=i.getMonth()+1,this.date=i.getDate(),this.weekday=i.getDay(),this.hours=i.getHours(),this.minutes=i.getMinutes(),this.seconds=i.getSeconds();{let a=this.year||0,o=this.month||0,l=this.date||0,u=Number(a+o.zeroEmbed(2)+l.zeroEmbed(2));u>=20190501?(this.warekiYear=a-2018,this.wareki="REIWA",this.warekiLabel="\u4EE4\u548C"):u>=19890108?(this.warekiYear=a-1988,this.wareki="HEISEI",this.warekiLabel="\u5E73\u6210"):u>=19261225?(this.warekiYear=a-1925,this.wareki="SHOUWA",this.warekiLabel="\u662D\u548C"):u>=19120730?(this.warekiYear=a-1911,this.wareki="TAISHO",this.warekiLabel="\u5927\u6B63"):u>=19680125?(this.warekiYear=a-1867,this.wareki="MEIJI",this.warekiLabel="\u660E\u6CBB"):(this.warekiYear=0,this.wareki="",this.warekiLabel="")}{let a=new Date(this.year,0,1),o=new Date(a.valueOf());o.setDate(o.getDate()-(a.getDay()+1));let l=this.ms-o.getTime(),u=Math.ceil(l/(1e3*60*60*24));this.weekInYear=Math.ceil(u/7)}{let a=new Date(this.year,this.month-1,1),o=new Date(a.valueOf());o.setDate(o.getDate()-(a.getDay()+1));let l=this.ms-o.getTime(),u=Math.ceil(l/(1e3*60*60*24)),h=Math.ceil(u/7);this.weekInMonth=h}{let a=new Date(this.year,this.month,0),o=a.getDay(),l=new Date(new Date(a).setDate(a.getDate()-o));this.isLastWeekInMonth=this.date>=l.getDate()}return this},isPast:function(){let e=f();return this.value.valueOf()<e.value.valueOf()},isSameYear:function(e){let t=f(e);return this.year==t.year},isSameMonth:function(e){let t=f(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=f(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=f(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},isInRange:function(e,t){return!this.validate||!e.validate||!t.validate?!1:this.value>=e.value&&this.value<=t.value},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf()),r=t.getDate();t.setDate(1),t.setMonth(e-1);let i=f(t).getLastDayOfMonth();return t.setDate(Math.min(r,i.date)),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+Number(e))},addMonth:function(e){return this.setMonth(this.month+Number(e))},addWeek:function(e){return this.addDate(7*Number(e))},addDate:function(e){return this.setDate(this.date+Number(e))},addHours:function(e){return this.setHours(this.hours+Number(e))},addMinutes:function(e){return this.setMinutes(this.minutes+Number(e))},addSeconds:function(e){return this.setSeconds(this.seconds+Number(e))},toFormat:function(e,t){if(!this.validate)return"";let r=this;return s.isExist(t)&&(r=r.clone(),r.setLocalTimezoneOffset(t||0)),e.replace(/\%y/ig,r.year.zeroEmbed(4)).replace(/\%m/ig,r.month.zeroEmbed(2)).replace(/\%d/ig,r.date.zeroEmbed(2)).replace(/\%w/ig,r.weekInYear.zeroEmbed(2)).replace(/\%h/ig,r.hours.zeroEmbed(2)).replace(/\%i/ig,r.minutes.zeroEmbed(2)).replace(/\%s/ig,r.seconds.zeroEmbed(2))},toFormatISO:function(){return this.value.toISOString()},toFormatabbrYMD:function(e,t){if(!this.validate)return"";let r=this.isSameYear(f()),i="%Y/%M/%D";return r&&(i="%M/%D"),e=="JP"&&(i="%Y\u5E74%M\u6708%D\u65E5",r&&(i="%M\u6708%D\u65E5")),this.toFormat(i,t)},toFormatYMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t):""},toFormatYM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708",t):this.toFormat("%Y/%M",t):""},toFormatMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):""},toFormatHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206",t):this.toFormat("%h:%i",t):""},toFormatHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206%s\u79D2",t):this.toFormat("%h:%i:%s",t):""},toFormatYMDHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%i\u5206",t):this.toFormat("%Y/%M/%D %h:%i",t):""},toFormatYMDHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2",t):this.toFormat("%Y/%M/%D %h:%i:%s",t):""},toLangYMD:function(e,t){if(!this.validate)return"";let r=f(),i=r.diff(this);return i.dates==0?"\u4ECA\u65E5":i.dates==1?"\u6628\u65E5":i.dates>=-7&&i.dates<0?-1*i.dates+"\u65E5\u5F8C":i.dates<=7&&i.dates>0?i.dates+"\u65E5\u524D":this.isSameYear(r)?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t)},setFirstOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},setFromFormatHHMM:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})/,"$1:$2"),[r,i]=t.split(":"),n=new Date(this.value.valueOf());return n.setHours(Number(r)),n.setMinutes(Number(i)),this.set(n)},setFromFormatHHMMSS:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(6).replace(/(\d{2})(\d{2})(\d{2})/,"$1:$2:$3"),[r,i,n]=t.split(":"),a=new Date(this.value.valueOf());return a.setHours(Number(r)),a.setMinutes(Number(i)),a.setSeconds(Number(n)),this.set(a)},getFirstDayOfYear:function(){return f(new Date(this.value.getFullYear(),0,1))},getLastDayOfYear:function(){return f(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfMonth:function(){return f(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfMonth:function(){return f(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfWeek:function(){let e=f(this.value);return e.addDate(-e.weekday)},getLastDayOfWeek:function(){let e=f(this.value);return e.addDate(6-e.weekday)},diff:function(e){return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:s.scope(()=>{let t=864e5,r=this.clone().setFirstOfDay(),i=e.clone().setFirstOfDay();return Math.floor((r.ms-i.ms)/t)}),hours:s.scope(()=>{let t=36e5,r=this.clone().setMinutes(0).setSeconds(0).setMilliseconds(0),i=e.clone().setMinutes(0).setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-i.ms)/t)}),minutes:s.scope(()=>{let t=6e4,r=this.clone().setSeconds(0).setMilliseconds(0),i=e.clone().setSeconds(0).setMilliseconds(0);return Math.floor((r.ms-i.ms)/t)}),seconds:s.scope(()=>{let t=this.clone().setMilliseconds(0),r=e.clone().setMilliseconds(0);return Math.floor((t.ms-r.ms)/1e3)}),ms:this.ms-e.ms}},getAge:function(e){let t=e||f(),r=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&r--,r}},f);f.isTimeObject=e=>{var t,r;return((t=e||{})==null?void 0:t.constructor)===f||((r=e||{})==null?void 0:r.__classAlias)===f.__classAlias};f.getFromNumberYYYYMMDD=e=>{let t=Number(e).zeroEmbed(8).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return f(t+" 00:00:00")};f.getShortYMDs=(e,t)=>{let r="",i="";return e.year==t.year&&e.year==f().year?r=e.toFormatMD():r=e.toFormatYMD(),e.year!=t.year?i=t.toFormatYMD():i=t.toFormatMD(),[r,i]};f.getPeriodArray=(e,t,r)=>{let i=[],n=t;if(!t.validate||!r.validate)return i;for(e=="year"?n=f(n).setMonth(1).setDate(1).setFirstOfDay():e=="month"?n=f(n).setDate(1):e=="week"?n=f(n).getFirstDayOfWeek():e=="day"?n=f(n).setFirstOfDay():e=="hours"?n=f(n).setMinutes(0).setSeconds(0).setMilliseconds(0):e=="minutes"?n=f(n).setSeconds(0).setMilliseconds(0):e=="seconds"&&(n=f(n).setMilliseconds(0));n.toFormatYMDHMS().toNumber()<=r.toFormatYMDHMS().toNumber();)i.push(n),e=="year"?n=f(n).addYear(1):e=="month"?n=f(n).addMonth(1):e=="week"?n=f(n).addWeek(1):e=="day"?n=f(n).addDate(1):e=="hours"?n=f(n).addHours(1):e=="minutes"?n=f(n).addMinutes(1):e=="seconds"&&(n=f(n).addSeconds(1));return i};f.prototype.Time.prototype=f.prototype;var pe=(...[e,t,r])=>new S.prototype.Interval(e,t,r),S=pe;S.prototype={};var ye=function(...[e,t,r]){return this.fn=e,this.ms=t,this.key=r,this.isFinished=!1,S.abort(this.key),this.store(),this};s.extend({key:"",ms:0,timeoutIndex:-1,fn:null,isFinished:!1,Interval:ye,store:function(){M.set({["Interval_"+this.key]:this})},once:function(){if(this.fn){let e=()=>{this.fn&&this.fn(),this.isFinished=!0,this.store()};this.timeoutIndex=setTimeout(e,this.ms)}return this.store(),this},start:function(){return this.fn&&(this.timeoutIndex=setInterval(this.fn,this.ms)),this.store(),this},abort:function(){return S.abort(this.timeoutIndex),this},setState:function(e){return Object.entries(e).forEach(([t,r])=>{this.hasOwnProperty(t)&&(this[t]=r)}),this.store(),this}},S);S.abort=e=>{if(s.isNumber(e))return clearInterval(e);let t=M.get("Interval_"+e);t&&(t&&clearInterval(t.timeoutIndex),t.setState({isFinished:!0}))};S.get=e=>M.get("Interval_"+e);S.once=(e,t,r)=>S(e,t,r).once();S.series=(e,t)=>C(void 0,null,function*(){return new Promise(r=>{let i=S.get(e);if(i&&!i.isFinished)return r(null);let n=()=>{S.abort(e)};r(n),t&&S(n,t,e).once()})});S.start=(e,t,r)=>S(e,t,r).start();S.prototype.Interval.prototype=S.prototype;var ge=(e,t)=>new c.prototype.Fetcher(e,t),c=ge;c.prototype={};c.waitList=[];c.setDefaultTrafficControl=0;c.setDefaultTimeout=1e3*60*10;c.abort=e=>{let t="fetcher.abortController."+e,r=M.get(t);console.log(r),r&&r.abort()};c.safetyRecords=e=>{let t={};return Object.entries(e).forEach(([r,i])=>{if(s.isArray(i)){t[r]=i.join(",");return}else if(s.isRecord(i)){Object.entries(c.safetyRecords(i)).forEach(([n,a])=>{t[`${r}.${n}`]=a});return}t[r]=i}),t};c.isReadableStream=e=>e instanceof ReadableStream;c.isReadableStreamReader=e=>e instanceof ReadableStreamDefaultReader;c.streamToContext=(e,t)=>C(void 0,null,function*(){try{let r=(t==null?void 0:t.reader)||e.getReader();if(!c.isReadableStreamReader(r))return{ok:!1,done:!0,data:null};if(!r)return{ok:!1,done:!0,data:null};let i=(t==null?void 0:t.decoder)||new TextDecoder("utf-8"),n=yield r.read();return{ok:!0,done:n.done,data:i.decode(n.value)}}catch(r){return{ok:!1,done:!0,data:r}}});var be=function(e,t){var n;t=t||{};let r=t.body;t.body&&!s.isString(t.body)&&((n=t.bodyStringify)==null||n)&&(r=s.Stringify(t.body||{}));let i=e;return s.isString(e)&&!e.match(/https?:/)&&(i=location.origin+"/"+e.replace(/^\//,"")),this.url=i,this.method=t.method||"get",this.streamStatus="open",this.params=_(v({key:x(),response_format:"json",timeout:c.setDefaultTimeout,trafficControl:c.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:v(v({"Content-Type":"application/json"},c.setDefaultHeaders&&c.setDefaultHeaders()),t.headers),body:r}),this};s.extend({Fetcher:be,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:void 0,onKeyDuplicateCB:void 0,onCompleteCB:void 0,onRetryCB:void 0,isRetry:!1,extraBody:{},abortController:null,genURL:function(){return s.url.search.set(v({},c.safetyRecords(this.params.queries||{})),String(this.url))},setExtraBody:function(e){return this.extraBody=v(v({},this.extraBody),e),this},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(e){return this.onStartCB=e,this},onKeyDuplicate:function(e){return this.onKeyDuplicateCB=e,this},onStream:function(e){return this.onStreamCB=e,this},onResult:function(e){return this.onResultCB=e,this},onComplete:function(e){return this.onCompleteCB=e,this},onRetry:function(e){return this.onRetryCB=e,this},onError:function(e){return this.onErrorCB=e,this},onStreamProcess:function(e){return C(this,null,function*(){let{response:t,errorCB:r,streamCB:i,reader:n,decoder:a}=e,o=t.body,l=this,u=function(){return Z(this,null,function*(){if(!t.ok){s.scope(()=>C(this,null,function*(){let{ok:p,done:b,data:T}=yield c.streamToContext(o,{reader:n,decoder:a});p&&r(T)}));return}let m=!1;for(;!m;){let{ok:p,done:b,data:T}=yield new $(c.streamToContext(o,{reader:n,decoder:a}));l.streamStatus=="abort"?(l.streamStatus="closed",n.cancel(),b=!0):l.streamStatus=="closed"&&(b=!0),b&&(m=b,n.releaseLock()),i(T,b)}})};try{for(var h=ee(u()),d,y,g;d=!(y=yield h.next()).done;d=!1){let m=y.value;;}}catch(y){g=[y]}finally{try{d&&(y=h.return)&&(yield y.call(h))}finally{if(g)throw g[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return C(this,null,function*(){var X;let e=this.params,t=performance.now(),V=e,{key:r,response_format:i,trafficControl:n=0,preventMultiRequest:a,timeout:o,queries:l}=V,u=O(V,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);u.method=this.method;let h=[this.method,r].join("."),d=c.waitList.includes(h);c.waitList=[...c.waitList,h];let y=!1,g=!1,m=!1,p=500,b="InternalServerError",T={},J=null,z=null;n>0&&(z=s.pending(n));let I=new AbortController,re=setTimeout(()=>{I.abort(),console.log("timeout",o)},e.timeout);u.signal=I.signal,this.abortController=I;let W="fetcher.abortController."+this.params.key;M.set({[W]:I});let H=()=>{y=!0},K=()=>(I.abort(),c.waitList=c.waitList.filter(w=>w!=h),{isCancelled:y,isAborted:g,ok:!1,status:0,statusText:"CANCELLED",body:T,requestTime:0,rawData:null});try{if(c.setDefaultOnStart&&(yield c.setDefaultOnStart(e,H)),this.onStartCB&&(yield this.onStartCB(e,H)),y)return K();if(d){if(this.onKeyDuplicateCB&&(yield this.onKeyDuplicateCB(H)),y)return K();if(a)throw p=429,new Error("TooManyRequests")}let w=this.genURL(),Y=yield fetch(w,u).then(F=>C(this,null,function*(){return m=F.ok,p=F.status,b=F.statusText,J=F,i=="none"||i=="stream"?F:F[i]()})).catch(F=>{throw new Error(F)});M.delete(W),T=Y}catch(w){p==200&&(p=500,m=!1),p==429&&(b="TooManyRequests"),I.signal.aborted&&(p=408,b="Timeout",g=!0),p==500&&(b=String(w)||b),T={errorCode:String(w)}}finally{clearTimeout(re)}let D={isCancelled:y,isAborted:g,ok:m,status:p,statusText:b,body:T,additionalBody:this.extraBody,requestTime:performance.now()-t,rawData:J};if(!m){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let w=yield this.onRetryCB(D.body,this.params,this);if(w)return c.waitList=c.waitList.filter(Y=>Y!=h),this.params=w,this.send()}this.onErrorCB&&this.onErrorCB(D.body)}if(m&&this.onStreamCB&&e.response_format=="stream"){let w=(X=J.body)==null?void 0:X.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:D,reader:w,decoder:new TextDecoder("utf-8")})}return yield z,D.requestTime=performance.now()-t,m&&this.onCompleteCB&&this.onCompleteCB(D.body),this.onResultCB&&this.onResultCB(D,e),c.setDefaultOnEnd&&c.setDefaultOnEnd(D,e),c.waitList=c.waitList.filter(w=>w!=h),D})},abortStream:function(){this.streamStatus="abort"}},c);c.prototype.Fetcher.prototype=c.prototype;var Ce=e=>new E.prototype.Filer(e),E=Ce;E.prototype={};var Re=function(e){this.ok=!0;try{let[t,r]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=r,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this};s.extend({ok:!1,extension:"",type:"",file:{},fileName:"",Filer:Re,isValid:function(){return this.ok},toBlob:function(){return C(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return C(this,null,function*(){return yield this.file.convert("dataURL")})},toAarrayBuffer:function(){return C(this,null,function*(){return yield this.file.convert("arrayBuffer")})},toObjectURL:function(){return C(this,null,function*(){return URL.createObjectURL(this.file)})},updateFileName:function(e){let t=new File([this.file],e+"."+this.extension);return this.file=t,this.fileName=e,this},updateMimeType:function(e){return this.file=new File([this.file],this.fileName+"."+this.extension,{type:e}),this.type=e,this},updateExtension:function(e){let t=new File([this.file],this.fileName+"."+e);return this.file=t,this.extension=e,this}},E);E.fromFile=e=>E(e);E.fromBlob=(e,t)=>{let r=(t==null?void 0:t.fileName)||"file",i=(t==null?void 0:t.extension)||"",n=new File([e],r+"."+i,{type:t==null?void 0:t.mimeType});return E(n)};E.fromArrayBuffer=(e,t)=>E.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t);E.fromObjectURL=(e,t)=>C(void 0,null,function*(){let r=yield c(e,{response_format:"blob"}).get();return r.ok?E.fromBlob(r.body,t):E({})});E.fromDataURL=(e,t)=>{let r=e.toBlob((t==null?void 0:t.mimeType)||"");return r?E.fromBlob(r,t):E({})};E.prototype.Filer.prototype=E.prototype;var Se=function(e){let t=e,r=null;return t.use((i,n,a)=>{let o=n;o.return=l=>{let p=l||{},{ok:u,status:h,body:d={},bodyStringify:y=!0}=p,g=O(p,["ok","status","body","bodyStringify"]);h=h!=null?h:(u!=null?u:!0)&&200||403;let m=d;return y&&!s.isString(d)&&(m=s.Stringify(d)),n.status(h).end(m)},a()}),t.onPathRouter=function(i){return r=i,this},t.pathRouter=function(i){if(!r)return;let n=r(i);return n.route(i),t.use(i,n),n},t.exception=function(i){return t.use(i),this},t},B=Se;B.getLocalIP=e=>{let t="";return s.scope(()=>{if(!e)return;let r=e.networkInterfaces();for(let[i,n]of Object.entries(r))n.forEach(a=>{!a.internal&&a.family==="IPv4"&&!a.address.match(/^(169|127)/)&&(t=a.address)})}),t};B.getIP=function(e){var i;return(((e==null?void 0:e.headers["x-forwarded-for"])||((i=e==null?void 0:e.socket)==null?void 0:i.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};s.copyToClipboard=e=>C(void 0,null,function*(){let t="";s.isString(e)?t=e:s.isFunction(e)&&(t=e());let r={ok:!1,body:"NotSupported"};return yield C(void 0,null,function*(){let i;if(navigator.clipboard){if(i=yield navigator.clipboard.writeText(t).then(()=>!0,()=>!1),!i)return}else{let n=document.createElement("input");if(s(document.body).append(n),n.value=t,n.select(),i=document.execCommand("copy"),document.body.removeChild(n),!i)return}r={ok:!0,body:""}}),r});s.ImageLoader=(e,t)=>{let r;return new Promise((i,n)=>{r=t||new Image,r.onload=()=>i(r),r.onerror=a=>n(a),r.crossOrigin="anonymous",r.src=e})};s.formatCharacter={postal:{JP:e=>{let t="";return e=String(e).replace(/\D/ig,""),e.length==7&&(t=e.replace(/^(\d{3})(.*)/,"$1-$2")),t}},tel:{_:e=>{let t=e;return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t},mobile:e=>{let t="";return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),t},fixed:e=>{let t="";return e=String(e).removeLetters(),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t}}};s.transformer={weekday:{ENG:e=>["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur"][e]+"day",JP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]+"\u66DC\u65E5",shortJP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]},wareki:e=>{let t=[],r=[],i=!1;return[{From:1868,To:1912,name:"\u660E\u6CBB"},{From:1912,To:1926,name:"\u5927\u6B63"},{From:1926,To:1989,name:"\u662D\u548C"},{From:1989,To:2019,name:"\u5E73\u6210"},{From:2019,To:1e5,name:"\u4EE4\u548C"}].forEach(a=>{let{From:o,To:l,name:u}=a;if(o<=e&&e<=l){let h=e-o+1;h==1&&(i=!0,h="\u5143"),r.push(u+h+"\u5E74"),t.push(u)}}),{era:t,value:r,gap:i}}};s.interval=S;c.setDefaultHeaders=()=>({});var Ee=s;0&&(module.exports={Fetcher,Filer,Server,Time,UUID,useStore});
package/esm/fetcher.d.ts CHANGED
@@ -65,6 +65,7 @@ declare namespace Fetcher {
65
65
  delete<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
66
66
  patch<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
67
67
  options<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E, _A>>;
68
+ genURL(): string;
68
69
  setExtraBody(body: Records): Chains<R, E, A>;
69
70
  send<_R = R, _E = E, _A = A>(): Promise<Output<_R, _E>>;
70
71
  abortStream(): void;
package/esm/fetcher.js CHANGED
@@ -1 +1 @@
1
- import{b as y,c as O,d as F,e as R,f as k,g as q,h as L}from"./chunk-ABA72NWU.js";import d from"./core";import{UUID as M}from"./uuid";import{useStore as w}from"./useStore";const U=(t,r)=>new e.prototype.Fetcher(t,r),e=U;e.prototype={},e.waitList=[],e.setDefaultTrafficControl=0,e.setDefaultTimeout=1e3*60*10,e.abort=t=>{let r="fetcher.abortController."+t,o=w.get(r);console.log(o),o&&o.abort()},e.safetyRecords=t=>{let r={};return Object.entries(t).forEach(([o,a])=>{if(d.isArray(a)){r[o]=a.join(",");return}else if(d.isRecord(a)){Object.entries(e.safetyRecords(a)).forEach(([n,p])=>{r[`${o}.${n}`]=p});return}r[o]=a}),r},e.isReadableStream=t=>t instanceof ReadableStream,e.isReadableStreamReader=t=>t instanceof ReadableStreamDefaultReader,e.streamToContext=(t,r)=>R(void 0,null,function*(){try{const o=(r==null?void 0:r.reader)||t.getReader();if(!e.isReadableStreamReader(o))return{ok:!1,done:!0,data:null};if(!o)return{ok:!1,done:!0,data:null};const a=(r==null?void 0:r.decoder)||new TextDecoder("utf-8");let n=yield o.read();return{ok:!0,done:n.done,data:a.decode(n.value)}}catch(o){return{ok:!1,done:!0,data:o}}});const H=function(t,r){var n;r=r||{};let o=r.body;r.body&&!d.isString(r.body)&&((n=r.bodyStringify)==null||n)&&(o=d.Stringify(r.body||{}));let a=t;return d.isString(t)&&!t.match(/https?:/)&&(a=location.origin+"/"+t.replace(/^\//,"")),this.url=a,this.method=r.method||"get",this.streamStatus="open",this.params=O(y({key:M(),response_format:"json",timeout:e.setDefaultTimeout,trafficControl:e.setDefaultTrafficControl,preventMultiRequest:!0},r),{headers:y(y({"Content-Type":"application/json"},e.setDefaultHeaders&&e.setDefaultHeaders()),r.headers),body:o}),this};d.extend({Fetcher:H,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:void 0,onKeyDuplicateCB:void 0,onCompleteCB:void 0,onRetryCB:void 0,isRetry:!1,extraBody:{},abortController:null,setExtraBody:function(t){return this.extraBody=y(y({},this.extraBody),t),this},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(t){return this.onStartCB=t,this},onKeyDuplicate:function(t){return this.onKeyDuplicateCB=t,this},onStream:function(t){return this.onStreamCB=t,this},onResult:function(t){return this.onResultCB=t,this},onComplete:function(t){return this.onCompleteCB=t,this},onRetry:function(t){return this.onRetryCB=t,this},onError:function(t){return this.onErrorCB=t,this},onStreamProcess:function(t){return R(this,null,function*(){let{response:r,errorCB:o,streamCB:a,reader:n,decoder:p}=t,A=r.body,C=this;const b=function(){return q(this,null,function*(){if(!r.ok){d.scope(()=>R(this,null,function*(){let{ok:u,done:s,data:c}=yield e.streamToContext(A,{reader:n,decoder:p});u&&o(c)}));return}let l=!1;for(;!l;){let{ok:u,done:s,data:c}=yield new k(e.streamToContext(A,{reader:n,decoder:p}));C.streamStatus=="abort"?(C.streamStatus="closed",n.cancel(),s=!0):C.streamStatus=="closed"&&(s=!0),s&&(l=s,n.releaseLock()),a(c,s)}})};try{for(var _=L(b()),K,E,S;K=!(E=yield _.next()).done;K=!1){let l=E.value;;}}catch(E){S=[E]}finally{try{K&&(E=_.return)&&(yield E.call(_))}finally{if(S)throw S[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return R(this,null,function*(){var I;let t=this.params,r=performance.now(),v=t,{key:o,response_format:a,trafficControl:n=0,preventMultiRequest:p,timeout:A,queries:C}=v,b=F(v,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);b.method=this.method;let _=[this.method,o].join("."),K=e.waitList.includes(_);e.waitList=[...e.waitList,_];let E=!1,S=!1,l=!1,u=500,s="InternalServerError",c={},B=null,g=null;n>0&&(g=d.pending(n));let f=new AbortController,j=setTimeout(()=>{f.abort(),console.log("timeout",A)},t.timeout);b.signal=f.signal,this.abortController=f;let x="fetcher.abortController."+this.params.key;w.set({[x]:f});const D=()=>{E=!0},P=()=>(f.abort(),e.waitList=e.waitList.filter(i=>i!=_),{isCancelled:E,isAborted:S,ok:!1,status:0,statusText:"CANCELLED",body:c,requestTime:0,rawData:null});try{if(e.setDefaultOnStart&&(yield e.setDefaultOnStart(t,D)),this.onStartCB&&(yield this.onStartCB(t,D)),E)return P();if(K){if(this.onKeyDuplicateCB&&(yield this.onKeyDuplicateCB(D)),E)return P();if(p)throw u=429,new Error("TooManyRequests")}let i=d.url.search.set(y({},e.safetyRecords(C||{})),String(this.url));const T=yield fetch(i,b).then(m=>R(this,null,function*(){return l=m.ok,u=m.status,s=m.statusText,B=m,a=="none"||a=="stream"?m:m[a]()})).catch(m=>{throw new Error(m)});w.delete(x),c=T}catch(i){u==200&&(u=500,l=!1),u==429&&(s="TooManyRequests"),f.signal.aborted&&(u=408,s="Timeout",S=!0),u==500&&(s=String(i)||s),c={errorCode:String(i)}}finally{clearTimeout(j)}let h={isCancelled:E,isAborted:S,ok:l,status:u,statusText:s,body:c,additionalBody:this.extraBody,requestTime:performance.now()-r,rawData:B};if(!l){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let i=yield this.onRetryCB(h.body,this.params,this);if(i)return e.waitList=e.waitList.filter(T=>T!=_),this.params=i,this.send()}this.onErrorCB&&this.onErrorCB(h.body)}if(l&&this.onStreamCB&&t.response_format=="stream"){let i=(I=B.body)==null?void 0:I.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:h,reader:i,decoder:new TextDecoder("utf-8")})}return yield g,h.requestTime=performance.now()-r,l&&this.onCompleteCB&&this.onCompleteCB(h.body),this.onResultCB&&this.onResultCB(h,t),e.setDefaultOnEnd&&e.setDefaultOnEnd(h,t),e.waitList=e.waitList.filter(i=>i!=_),h})},abortStream:function(){this.streamStatus="abort"}},e),e.prototype.Fetcher.prototype=e.prototype;export{e as Fetcher,e as default};
1
+ import{b as y,c as O,d as F,e as R,f as k,g as L,h as q}from"./chunk-ABA72NWU.js";import d from"./core";import{UUID as j}from"./uuid";import{useStore as g}from"./useStore";const M=(t,r)=>new e.prototype.Fetcher(t,r),e=M;e.prototype={},e.waitList=[],e.setDefaultTrafficControl=0,e.setDefaultTimeout=1e3*60*10,e.abort=t=>{let r="fetcher.abortController."+t,o=g.get(r);console.log(o),o&&o.abort()},e.safetyRecords=t=>{let r={};return Object.entries(t).forEach(([o,a])=>{if(d.isArray(a)){r[o]=a.join(",");return}else if(d.isRecord(a)){Object.entries(e.safetyRecords(a)).forEach(([n,p])=>{r[`${o}.${n}`]=p});return}r[o]=a}),r},e.isReadableStream=t=>t instanceof ReadableStream,e.isReadableStreamReader=t=>t instanceof ReadableStreamDefaultReader,e.streamToContext=(t,r)=>R(void 0,null,function*(){try{const o=(r==null?void 0:r.reader)||t.getReader();if(!e.isReadableStreamReader(o))return{ok:!1,done:!0,data:null};if(!o)return{ok:!1,done:!0,data:null};const a=(r==null?void 0:r.decoder)||new TextDecoder("utf-8");let n=yield o.read();return{ok:!0,done:n.done,data:a.decode(n.value)}}catch(o){return{ok:!1,done:!0,data:o}}});const H=function(t,r){var n;r=r||{};let o=r.body;r.body&&!d.isString(r.body)&&((n=r.bodyStringify)==null||n)&&(o=d.Stringify(r.body||{}));let a=t;return d.isString(t)&&!t.match(/https?:/)&&(a=location.origin+"/"+t.replace(/^\//,"")),this.url=a,this.method=r.method||"get",this.streamStatus="open",this.params=O(y({key:j(),response_format:"json",timeout:e.setDefaultTimeout,trafficControl:e.setDefaultTrafficControl,preventMultiRequest:!0},r),{headers:y(y({"Content-Type":"application/json"},e.setDefaultHeaders&&e.setDefaultHeaders()),r.headers),body:o}),this};d.extend({Fetcher:H,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:void 0,onKeyDuplicateCB:void 0,onCompleteCB:void 0,onRetryCB:void 0,isRetry:!1,extraBody:{},abortController:null,genURL:function(){return d.url.search.set(y({},e.safetyRecords(this.params.queries||{})),String(this.url))},setExtraBody:function(t){return this.extraBody=y(y({},this.extraBody),t),this},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(t){return this.onStartCB=t,this},onKeyDuplicate:function(t){return this.onKeyDuplicateCB=t,this},onStream:function(t){return this.onStreamCB=t,this},onResult:function(t){return this.onResultCB=t,this},onComplete:function(t){return this.onCompleteCB=t,this},onRetry:function(t){return this.onRetryCB=t,this},onError:function(t){return this.onErrorCB=t,this},onStreamProcess:function(t){return R(this,null,function*(){let{response:r,errorCB:o,streamCB:a,reader:n,decoder:p}=t,E=r.body,A=this;const C=function(){return L(this,null,function*(){if(!r.ok){d.scope(()=>R(this,null,function*(){let{ok:u,done:s,data:c}=yield e.streamToContext(E,{reader:n,decoder:p});u&&o(c)}));return}let l=!1;for(;!l;){let{ok:u,done:s,data:c}=yield new k(e.streamToContext(E,{reader:n,decoder:p}));A.streamStatus=="abort"?(A.streamStatus="closed",n.cancel(),s=!0):A.streamStatus=="closed"&&(s=!0),s&&(l=s,n.releaseLock()),a(c,s)}})};try{for(var b=q(C()),U,_,S;U=!(_=yield b.next()).done;U=!1){let l=_.value;;}}catch(_){S=[_]}finally{try{U&&(_=b.return)&&(yield _.call(b))}finally{if(S)throw S[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return R(this,null,function*(){var I;let t=this.params,r=performance.now(),v=t,{key:o,response_format:a,trafficControl:n=0,preventMultiRequest:p,timeout:E,queries:A}=v,C=F(v,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);C.method=this.method;let b=[this.method,o].join("."),U=e.waitList.includes(b);e.waitList=[...e.waitList,b];let _=!1,S=!1,l=!1,u=500,s="InternalServerError",c={},B=null,w=null;n>0&&(w=d.pending(n));let f=new AbortController,K=setTimeout(()=>{f.abort(),console.log("timeout",E)},t.timeout);C.signal=f.signal,this.abortController=f;let P="fetcher.abortController."+this.params.key;g.set({[P]:f});const D=()=>{_=!0},x=()=>(f.abort(),e.waitList=e.waitList.filter(i=>i!=b),{isCancelled:_,isAborted:S,ok:!1,status:0,statusText:"CANCELLED",body:c,requestTime:0,rawData:null});try{if(e.setDefaultOnStart&&(yield e.setDefaultOnStart(t,D)),this.onStartCB&&(yield this.onStartCB(t,D)),_)return x();if(U){if(this.onKeyDuplicateCB&&(yield this.onKeyDuplicateCB(D)),_)return x();if(p)throw u=429,new Error("TooManyRequests")}let i=this.genURL();const T=yield fetch(i,C).then(m=>R(this,null,function*(){return l=m.ok,u=m.status,s=m.statusText,B=m,a=="none"||a=="stream"?m:m[a]()})).catch(m=>{throw new Error(m)});g.delete(P),c=T}catch(i){u==200&&(u=500,l=!1),u==429&&(s="TooManyRequests"),f.signal.aborted&&(u=408,s="Timeout",S=!0),u==500&&(s=String(i)||s),c={errorCode:String(i)}}finally{clearTimeout(K)}let h={isCancelled:_,isAborted:S,ok:l,status:u,statusText:s,body:c,additionalBody:this.extraBody,requestTime:performance.now()-r,rawData:B};if(!l){if(this.onRetryCB&&!this.isRetry){this.isRetry=!0;let i=yield this.onRetryCB(h.body,this.params,this);if(i)return e.waitList=e.waitList.filter(T=>T!=b),this.params=i,this.send()}this.onErrorCB&&this.onErrorCB(h.body)}if(l&&this.onStreamCB&&t.response_format=="stream"){let i=(I=B.body)==null?void 0:I.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:h,reader:i,decoder:new TextDecoder("utf-8")})}return yield w,h.requestTime=performance.now()-r,l&&this.onCompleteCB&&this.onCompleteCB(h.body),this.onResultCB&&this.onResultCB(h,t),e.setDefaultOnEnd&&e.setDefaultOnEnd(h,t),e.waitList=e.waitList.filter(i=>i!=b),h})},abortStream:function(){this.streamStatus="abort"}},e),e.prototype.Fetcher.prototype=e.prototype;export{e as Fetcher,e as default};
package/esm/server.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-ABA72NWU.js";import i from"./core";const A=function(t){let s=t,n=null;return s.use((e,r,o)=>{let h=r;h.return=c=>{let{ok:u,status:a,body:d={},bodyStringify:x=!0}=c||{};a=a!=null?a:(u!=null?u:!0)&&200||403;let R=d;return x&&!i.isString(d)&&(R=i.Stringify(d)),r.status(a).end(R)},o()}),s.onPathRouter=function(e){return n=e,this},s.pathRouter=function(e){if(!n)return;let r=n(e);return r.route(e),s.use(e,r),r},s.exception=function(e){return s.use(e),this},s},p=A;p.getLocalIP=t=>{let s="";return i.scope(()=>{if(!t)return;let n=t.networkInterfaces();for(let[e,r]of Object.entries(n))r.forEach(o=>{!o.internal&&o.family==="IPv4"&&!o.address.match(/^(169|127)/)&&(s=o.address)})}),s},p.getIP=function(t){var e;return(((t==null?void 0:t.headers["x-forwarded-for"])||((e=t==null?void 0:t.socket)==null?void 0:e.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};export{p as Server,p as default};
1
+ import{d as c}from"./chunk-ABA72NWU.js";import i from"./core";const y=function(t){let s=t,n=null;return s.use((e,r,o)=>{let x=r;x.return=A=>{let R=A||{},{ok:u,status:a,body:d={},bodyStringify:g=!0}=R,l=c(R,["ok","status","body","bodyStringify"]);a=a!=null?a:(u!=null?u:!0)&&200||403;let h=d;return g&&!i.isString(d)&&(h=i.Stringify(d)),r.status(a).end(h)},o()}),s.onPathRouter=function(e){return n=e,this},s.pathRouter=function(e){if(!n)return;let r=n(e);return r.route(e),s.use(e,r),r},s.exception=function(e){return s.use(e),this},s},p=y;p.getLocalIP=t=>{let s="";return i.scope(()=>{if(!t)return;let n=t.networkInterfaces();for(let[e,r]of Object.entries(n))r.forEach(o=>{!o.internal&&o.family==="IPv4"&&!o.address.match(/^(169|127)/)&&(s=o.address)})}),s},p.getIP=function(t){var e;return(((t==null?void 0:t.headers["x-forwarded-for"])||((e=t==null?void 0:t.socket)==null?void 0:e.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};export{p as Server,p as default};
package/esm/time.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-ABA72NWU.js";import l from"./core";import{useStore as m}from"./useStore";let f=-new Date().getTimezoneOffset();const c=(e,t)=>new s.prototype.Time(e,t),s=c;s.prototype={},s.__classAlias="jmini.Time";const D=function(e,t){if(t&&(this.localTimezoneOffset=t),s.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0?e=new Date:e===0&&(e=new Date(0))),e&&(l.isNumber(e)&&(e=new Date(e)),l.isString(e)&&(e=String(e).trim().replace(/\//g,"-").replace(/ +|\s+/g," ").replace(/\-+/g,"-"),e=e.replace(/^(\d{4}-\d{2}-\d{2})$/,"$1T00:00:00").replace(/^(\d{4}-\d{2}-\d{2})\s+/,"$1T").replace(/^(\d{4}-\d{2}-\d{2}T\d{2})(:?|:+)$/,"$1:00").replace(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(:?|:+)$/,"$1:00"),e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d{1,3})?$/)))){let a=this.getLocalTimezoneOffset(),n=Math.floor(a/60),r=a%60;n>=0&&(e+="+"),e+=n.zeroEmbed(2),e+=":"+r.zeroEmbed(2)}let i=new Date(String(e));return this.set(i)};l.extend({constructor:s,Time:D,__classAlias:s.__classAlias,value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,warekiYear:-1,wareki:"",warekiLabel:"",year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,localTimezoneOffset:void 0,getLocalTimezoneOffset:function(){var e,t;return(t=(e=this.localTimezoneOffset)!=null?e:m.get("jmini/time/env/localTimezoneOffset"))!=null?t:f},setLocalTimezoneOffset:function(e,t){return this.localTimezoneOffset=e,t&&m.set({"jmini/time/env/localTimezoneOffset":e}),this.set(this.value)},clone:function(){return s(this,this.localTimezoneOffset)},set:function(e){var n;this.value=e;let t=l.isDate(e);if(this.validate=t,l.isNullish(this.localTimezoneOffset)&&(this.localTimezoneOffset=(n=m.get("jmini/time/env/localTimezoneOffset"))!=null?n:f),!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;let i=e.getTime()+e.getTimezoneOffset()*6e4,a=new Date(i+this.getLocalTimezoneOffset()*60*1e3);this.ms=e.getTime(),this.year=a.getFullYear(),this.month=a.getMonth()+1,this.date=a.getDate(),this.weekday=a.getDay(),this.hours=a.getHours(),this.minutes=a.getMinutes(),this.seconds=a.getSeconds();{let r=this.year||0,o=this.month||0,h=this.date||0,u=Number(r+o.zeroEmbed(2)+h.zeroEmbed(2));u>=20190501?(this.warekiYear=r-2018,this.wareki="REIWA",this.warekiLabel="\u4EE4\u548C"):u>=19890108?(this.warekiYear=r-1988,this.wareki="HEISEI",this.warekiLabel="\u5E73\u6210"):u>=19261225?(this.warekiYear=r-1925,this.wareki="SHOUWA",this.warekiLabel="\u662D\u548C"):u>=19120730?(this.warekiYear=r-1911,this.wareki="TAISHO",this.warekiLabel="\u5927\u6B63"):u>=19680125?(this.warekiYear=r-1867,this.wareki="MEIJI",this.warekiLabel="\u660E\u6CBB"):(this.warekiYear=0,this.wareki="",this.warekiLabel="")}{let r=new Date(this.year,0,1),o=new Date(r.valueOf());o.setDate(o.getDate()-(r.getDay()+1));let h=this.ms-o.getTime(),u=Math.ceil(h/(1e3*60*60*24));this.weekInYear=Math.ceil(u/7)}{let r=new Date(this.year,this.month-1,1),o=new Date(r.valueOf());o.setDate(o.getDate()-(r.getDay()+1));let h=this.ms-o.getTime(),u=Math.ceil(h/(1e3*60*60*24)),d=Math.ceil(u/7);this.weekInMonth=d}{let r=new Date(this.year,this.month,0),o=r.getDay(),h=new Date(new Date(r).setDate(r.getDate()-o));this.isLastWeekInMonth=this.date>=h.getDate()}return this},isPast:function(){let e=s();return this.value.valueOf()<e.value.valueOf()},isSameYear:function(e){let t=s(e);return this.year==t.year},isSameMonth:function(e){let t=s(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=s(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=s(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},isInRange:function(e,t){return!this.validate||!e.validate||!t.validate?!1:this.value>=e.value&&this.value<=t.value},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf()),i=t.getDate();t.setDate(1),t.setMonth(e-1);let a=s(t).getLastDayOfMonth();return t.setDate(Math.min(i,a.date)),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+e)},addMonth:function(e){return this.setMonth(this.month+e)},addWeek:function(e){return this.addDate(7*e)},addDate:function(e){return this.setDate(this.date+e)},addHours:function(e){return this.setHours(this.hours+e)},addMinutes:function(e){return this.setMinutes(this.minutes+e)},addSeconds:function(e){return this.setSeconds(this.seconds+e)},toFormat:function(e,t){if(!this.validate)return"";let i=this;return l.isExist(t)&&(i=i.clone(),i.setLocalTimezoneOffset(t||0)),e.replace(/\%y/ig,i.year.zeroEmbed(4)).replace(/\%m/ig,i.month.zeroEmbed(2)).replace(/\%d/ig,i.date.zeroEmbed(2)).replace(/\%w/ig,i.weekInYear.zeroEmbed(2)).replace(/\%h/ig,i.hours.zeroEmbed(2)).replace(/\%i/ig,i.minutes.zeroEmbed(2)).replace(/\%s/ig,i.seconds.zeroEmbed(2))},toFormatISO:function(){return this.value.toISOString()},toFormatabbrYMD:function(e,t){if(!this.validate)return"";let i=this.isSameYear(s()),a="%Y/%M/%D";return i&&(a="%M/%D"),e=="JP"&&(a="%Y\u5E74%M\u6708%D\u65E5",i&&(a="%M\u6708%D\u65E5")),this.toFormat(a,t)},toFormatYMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t):""},toFormatYM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708",t):this.toFormat("%Y/%M",t):""},toFormatMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):""},toFormatHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206",t):this.toFormat("%h:%i",t):""},toFormatHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206%s\u79D2",t):this.toFormat("%h:%i:%s",t):""},toFormatYMDHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%i\u5206",t):this.toFormat("%Y/%M/%D %h:%i",t):""},toFormatYMDHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2",t):this.toFormat("%Y/%M/%D %h:%i:%s",t):""},toLangYMD:function(e,t){if(!this.validate)return"";let i=s(),a=i.diff(this);return a.dates==0?"\u4ECA\u65E5":a.dates==1?"\u6628\u65E5":a.dates>=-7&&a.dates<0?-1*a.dates+"\u65E5\u5F8C":a.dates<=7&&a.dates>0?a.dates+"\u65E5\u524D":this.isSameYear(i)?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t)},setFirstOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},setFromFormatHHMM:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})/,"$1:$2"),[i,a]=t.split(":"),n=new Date(this.value.valueOf());return n.setHours(Number(i)),n.setMinutes(Number(a)),this.set(n)},setFromFormatHHMMSS:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(6).replace(/(\d{2})(\d{2})(\d{2})/,"$1:$2:$3"),[i,a,n]=t.split(":"),r=new Date(this.value.valueOf());return r.setHours(Number(i)),r.setMinutes(Number(a)),r.setSeconds(Number(n)),this.set(r)},getFirstDayOfYear:function(){return s(new Date(this.value.getFullYear(),0,1))},getLastDayOfYear:function(){return s(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfMonth:function(){return s(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfMonth:function(){return s(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfWeek:function(){let e=s(this.value);return e.addDate(-e.weekday)},getLastDayOfWeek:function(){let e=s(this.value);return e.addDate(6-e.weekday)},diff:function(e){return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:l.scope(()=>{let t=864e5,i=this.clone().setFirstOfDay(),a=e.clone().setFirstOfDay();return Math.floor((i.ms-a.ms)/t)}),hours:l.scope(()=>{let t=36e5,i=this.clone().setMinutes(0).setSeconds(0).setMilliseconds(0),a=e.clone().setMinutes(0).setSeconds(0).setMilliseconds(0);return Math.floor((i.ms-a.ms)/t)}),minutes:l.scope(()=>{let t=6e4,i=this.clone().setSeconds(0).setMilliseconds(0),a=e.clone().setSeconds(0).setMilliseconds(0);return Math.floor((i.ms-a.ms)/t)}),seconds:l.scope(()=>{let t=this.clone().setMilliseconds(0),i=e.clone().setMilliseconds(0);return Math.floor((t.ms-i.ms)/1e3)}),ms:this.ms-e.ms}},getAge:function(e){let t=e||s(),i=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&i--,i}},s),s.isTimeObject=e=>{var t,i;return((t=e||{})==null?void 0:t.constructor)===s||((i=e||{})==null?void 0:i.__classAlias)===s.__classAlias},s.getFromNumberYYYYMMDD=e=>{let t=Number(e).zeroEmbed(8).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return s(t+" 00:00:00")},s.getShortYMDs=(e,t)=>{let i="",a="";return e.year==t.year&&e.year==s().year?i=e.toFormatMD():i=e.toFormatYMD(),e.year!=t.year?a=t.toFormatYMD():a=t.toFormatMD(),[i,a]},s.getPeriodArray=(e,t,i)=>{let a=[],n=t;if(!t.validate||!i.validate)return a;for(e=="year"?n=s(n).setMonth(1).setDate(1).setFirstOfDay():e=="month"?n=s(n).setDate(1):e=="week"?n=s(n).getFirstDayOfWeek():e=="day"?n=s(n).setFirstOfDay():e=="hours"?n=s(n).setMinutes(0).setSeconds(0).setMilliseconds(0):e=="minutes"?n=s(n).setSeconds(0).setMilliseconds(0):e=="seconds"&&(n=s(n).setMilliseconds(0));n.toFormatYMDHMS().toNumber()<=i.toFormatYMDHMS().toNumber();)a.push(n),e=="year"?n=s(n).addYear(1):e=="month"?n=s(n).addMonth(1):e=="week"?n=s(n).addWeek(1):e=="day"?n=s(n).addDate(1):e=="hours"?n=s(n).addHours(1):e=="minutes"?n=s(n).addMinutes(1):e=="seconds"&&(n=s(n).addSeconds(1));return a},s.prototype.Time.prototype=s.prototype;export{s as Time,s as default};
1
+ import"./chunk-ABA72NWU.js";import l from"./core";import{useStore as h}from"./useStore";let f=-new Date().getTimezoneOffset();const c=(e,t)=>new s.prototype.Time(e,t),s=c;s.prototype={},s.__classAlias="jmini.Time";const D=function(e,t){if(t&&(this.localTimezoneOffset=t),s.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0?e=new Date:e===0&&(e=new Date(0))),e&&(l.isNumber(e)&&(e=new Date(e)),l.isString(e)&&(e=String(e).trim().replace(/\//g,"-").replace(/ +|\s+/g," ").replace(/\-+/g,"-"),e=e.replace(/^(\d{4}-\d{2}-\d{2})$/,"$1T00:00:00").replace(/^(\d{4}-\d{2}-\d{2})\s+/,"$1T").replace(/^(\d{4}-\d{2}-\d{2}T\d{2})(:?|:+)$/,"$1:00").replace(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(:?|:+)$/,"$1:00"),e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d{1,3})?$/)))){let a=this.getLocalTimezoneOffset(),n=Math.floor(a/60),r=a%60;n>=0&&(e+="+"),e+=n.zeroEmbed(2),e+=":"+r.zeroEmbed(2)}let i=new Date(String(e));return this.set(i)};l.extend({constructor:s,Time:D,__classAlias:s.__classAlias,value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,warekiYear:-1,wareki:"",warekiLabel:"",year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,localTimezoneOffset:void 0,getLocalTimezoneOffset:function(){var e,t;return(t=(e=this.localTimezoneOffset)!=null?e:h.get("jmini/time/env/localTimezoneOffset"))!=null?t:f},setLocalTimezoneOffset:function(e,t){return this.localTimezoneOffset=e,t&&h.set({"jmini/time/env/localTimezoneOffset":e}),this.set(this.value)},clone:function(){return s(this,this.localTimezoneOffset)},set:function(e){var n;this.value=e;let t=l.isDate(e);if(this.validate=t,l.isNullish(this.localTimezoneOffset)&&(this.localTimezoneOffset=(n=h.get("jmini/time/env/localTimezoneOffset"))!=null?n:f),!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;let i=e.getTime()+e.getTimezoneOffset()*6e4,a=new Date(i+this.getLocalTimezoneOffset()*60*1e3);this.ms=e.getTime(),this.year=a.getFullYear(),this.month=a.getMonth()+1,this.date=a.getDate(),this.weekday=a.getDay(),this.hours=a.getHours(),this.minutes=a.getMinutes(),this.seconds=a.getSeconds();{let r=this.year||0,o=this.month||0,m=this.date||0,u=Number(r+o.zeroEmbed(2)+m.zeroEmbed(2));u>=20190501?(this.warekiYear=r-2018,this.wareki="REIWA",this.warekiLabel="\u4EE4\u548C"):u>=19890108?(this.warekiYear=r-1988,this.wareki="HEISEI",this.warekiLabel="\u5E73\u6210"):u>=19261225?(this.warekiYear=r-1925,this.wareki="SHOUWA",this.warekiLabel="\u662D\u548C"):u>=19120730?(this.warekiYear=r-1911,this.wareki="TAISHO",this.warekiLabel="\u5927\u6B63"):u>=19680125?(this.warekiYear=r-1867,this.wareki="MEIJI",this.warekiLabel="\u660E\u6CBB"):(this.warekiYear=0,this.wareki="",this.warekiLabel="")}{let r=new Date(this.year,0,1),o=new Date(r.valueOf());o.setDate(o.getDate()-(r.getDay()+1));let m=this.ms-o.getTime(),u=Math.ceil(m/(1e3*60*60*24));this.weekInYear=Math.ceil(u/7)}{let r=new Date(this.year,this.month-1,1),o=new Date(r.valueOf());o.setDate(o.getDate()-(r.getDay()+1));let m=this.ms-o.getTime(),u=Math.ceil(m/(1e3*60*60*24)),d=Math.ceil(u/7);this.weekInMonth=d}{let r=new Date(this.year,this.month,0),o=r.getDay(),m=new Date(new Date(r).setDate(r.getDate()-o));this.isLastWeekInMonth=this.date>=m.getDate()}return this},isPast:function(){let e=s();return this.value.valueOf()<e.value.valueOf()},isSameYear:function(e){let t=s(e);return this.year==t.year},isSameMonth:function(e){let t=s(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=s(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=s(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},isInRange:function(e,t){return!this.validate||!e.validate||!t.validate?!1:this.value>=e.value&&this.value<=t.value},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf()),i=t.getDate();t.setDate(1),t.setMonth(e-1);let a=s(t).getLastDayOfMonth();return t.setDate(Math.min(i,a.date)),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+Number(e))},addMonth:function(e){return this.setMonth(this.month+Number(e))},addWeek:function(e){return this.addDate(7*Number(e))},addDate:function(e){return this.setDate(this.date+Number(e))},addHours:function(e){return this.setHours(this.hours+Number(e))},addMinutes:function(e){return this.setMinutes(this.minutes+Number(e))},addSeconds:function(e){return this.setSeconds(this.seconds+Number(e))},toFormat:function(e,t){if(!this.validate)return"";let i=this;return l.isExist(t)&&(i=i.clone(),i.setLocalTimezoneOffset(t||0)),e.replace(/\%y/ig,i.year.zeroEmbed(4)).replace(/\%m/ig,i.month.zeroEmbed(2)).replace(/\%d/ig,i.date.zeroEmbed(2)).replace(/\%w/ig,i.weekInYear.zeroEmbed(2)).replace(/\%h/ig,i.hours.zeroEmbed(2)).replace(/\%i/ig,i.minutes.zeroEmbed(2)).replace(/\%s/ig,i.seconds.zeroEmbed(2))},toFormatISO:function(){return this.value.toISOString()},toFormatabbrYMD:function(e,t){if(!this.validate)return"";let i=this.isSameYear(s()),a="%Y/%M/%D";return i&&(a="%M/%D"),e=="JP"&&(a="%Y\u5E74%M\u6708%D\u65E5",i&&(a="%M\u6708%D\u65E5")),this.toFormat(a,t)},toFormatYMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t):""},toFormatYM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708",t):this.toFormat("%Y/%M",t):""},toFormatMD:function(e,t){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):""},toFormatHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206",t):this.toFormat("%h:%i",t):""},toFormatHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%h\u6642%i\u5206%s\u79D2",t):this.toFormat("%h:%i:%s",t):""},toFormatYMDHM:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%i\u5206",t):this.toFormat("%Y/%M/%D %h:%i",t):""},toFormatYMDHMS:function(e,t){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2",t):this.toFormat("%Y/%M/%D %h:%i:%s",t):""},toLangYMD:function(e,t){if(!this.validate)return"";let i=s(),a=i.diff(this);return a.dates==0?"\u4ECA\u65E5":a.dates==1?"\u6628\u65E5":a.dates>=-7&&a.dates<0?-1*a.dates+"\u65E5\u5F8C":a.dates<=7&&a.dates>0?a.dates+"\u65E5\u524D":this.isSameYear(i)?e=="JP"?this.toFormat("%M\u6708%D\u65E5",t):this.toFormat("%M/%D",t):e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5",t):this.toFormat("%Y/%M/%D",t)},setFirstOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},setFromFormatHHMM:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(4).replace(/(\d{2})(\d{2})/,"$1:$2"),[i,a]=t.split(":"),n=new Date(this.value.valueOf());return n.setHours(Number(i)),n.setMinutes(Number(a)),this.set(n)},setFromFormatHHMMSS:function(e){let t=String(e).removeLetters().removeSpecifics().toNumber().zeroEmbed(6).replace(/(\d{2})(\d{2})(\d{2})/,"$1:$2:$3"),[i,a,n]=t.split(":"),r=new Date(this.value.valueOf());return r.setHours(Number(i)),r.setMinutes(Number(a)),r.setSeconds(Number(n)),this.set(r)},getFirstDayOfYear:function(){return s(new Date(this.value.getFullYear(),0,1))},getLastDayOfYear:function(){return s(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfMonth:function(){return s(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfMonth:function(){return s(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfWeek:function(){let e=s(this.value);return e.addDate(-e.weekday)},getLastDayOfWeek:function(){let e=s(this.value);return e.addDate(6-e.weekday)},diff:function(e){return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:l.scope(()=>{let t=864e5,i=this.clone().setFirstOfDay(),a=e.clone().setFirstOfDay();return Math.floor((i.ms-a.ms)/t)}),hours:l.scope(()=>{let t=36e5,i=this.clone().setMinutes(0).setSeconds(0).setMilliseconds(0),a=e.clone().setMinutes(0).setSeconds(0).setMilliseconds(0);return Math.floor((i.ms-a.ms)/t)}),minutes:l.scope(()=>{let t=6e4,i=this.clone().setSeconds(0).setMilliseconds(0),a=e.clone().setSeconds(0).setMilliseconds(0);return Math.floor((i.ms-a.ms)/t)}),seconds:l.scope(()=>{let t=this.clone().setMilliseconds(0),i=e.clone().setMilliseconds(0);return Math.floor((t.ms-i.ms)/1e3)}),ms:this.ms-e.ms}},getAge:function(e){let t=e||s(),i=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&i--,i}},s),s.isTimeObject=e=>{var t,i;return((t=e||{})==null?void 0:t.constructor)===s||((i=e||{})==null?void 0:i.__classAlias)===s.__classAlias},s.getFromNumberYYYYMMDD=e=>{let t=Number(e).zeroEmbed(8).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return s(t+" 00:00:00")},s.getShortYMDs=(e,t)=>{let i="",a="";return e.year==t.year&&e.year==s().year?i=e.toFormatMD():i=e.toFormatYMD(),e.year!=t.year?a=t.toFormatYMD():a=t.toFormatMD(),[i,a]},s.getPeriodArray=(e,t,i)=>{let a=[],n=t;if(!t.validate||!i.validate)return a;for(e=="year"?n=s(n).setMonth(1).setDate(1).setFirstOfDay():e=="month"?n=s(n).setDate(1):e=="week"?n=s(n).getFirstDayOfWeek():e=="day"?n=s(n).setFirstOfDay():e=="hours"?n=s(n).setMinutes(0).setSeconds(0).setMilliseconds(0):e=="minutes"?n=s(n).setSeconds(0).setMilliseconds(0):e=="seconds"&&(n=s(n).setMilliseconds(0));n.toFormatYMDHMS().toNumber()<=i.toFormatYMDHMS().toNumber();)a.push(n),e=="year"?n=s(n).addYear(1):e=="month"?n=s(n).addMonth(1):e=="week"?n=s(n).addWeek(1):e=="day"?n=s(n).addDate(1):e=="hours"?n=s(n).addHours(1):e=="minutes"?n=s(n).addMinutes(1):e=="seconds"&&(n=s(n).addSeconds(1));return a},s.prototype.Time.prototype=s.prototype;export{s as Time,s as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmini",
3
- "version": "0.0.123",
3
+ "version": "0.0.124",
4
4
  "description": "minified JavaScript Framework",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",