szdl-utils-kit 0.1.4 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +788 -501
- package/dist/index.umd.cjs +2 -2
- package/dist/types/batch.d.ts +7 -1
- package/dist/types/bx-boot.d.ts +27 -10
- package/dist/types/bx-helper.d.ts +22 -0
- package/dist/types/bx-logger.d.ts +38 -0
- package/dist/types/index.d.ts +11 -2
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):e(JSON.parse(o.responseText))):n&&n(o))},o.open("GET",t,!1),o.send()},B={"%d":{format:function(t){return h(t.day()||i.MIN_DAY,2)},parse:function(t){var e=Number(t);return{day:isNaN(e)?s:e}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return h(t.month()||i.MIN_MONTH,2)},parse:function(t){var e=Number(t);return{month:isNaN(e)?s:e}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return h(t.year()||i.MIN_YEAR,4)},parse:function(t){var e=Number(t);return{year:isNaN(e)?s:e}},minLength:4,maxLength:4,type:"number"},"%w":{format:function(t){return t.dayOfWeek()||i.MIN_DAY_OF_WEEK},parse:function(){return{}},minLength:1,maxLength:1,type:"number"},"%a":{format:function(t){var e=t.dayOfWeek();return Ot[e!==s?e:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var e=t.dayOfWeek();return _t[e!==s?e:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var e=i.options("monthFromZero")?t.month():t.month()-1;return pt[e!==s?e:i.MIN_MONTH]},parse:function(t){var e=i.monthNames().indexOf(t)+(i.options("monthFromZero")?0:1);return{month:e!==-1?e:s}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var e=i.options("monthFromZero")?t.month():t.month()-1;return Lt[e!==s?e:i.MIN_MONTH]},parse:function(t){var e=i.monthNames(!0).indexOf(t)+(i.options("monthFromZero")?0:1);return{month:e!==-1?e:s}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return h(t.hours()||i.MIN_HOURS,2)},parse:function(t){var e=Number(t);return{hours:isNaN(e)?s:e}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return h(t.minutes()||i.MIN_MINUTES,2)},parse:function(t){var e=Number(t);return{minutes:isNaN(e)?s:e}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return h(t.seconds()||i.MIN_SECONDS,2)},parse:function(t){var e=Number(t);return{seconds:isNaN(e)?s:e}},minLength:2,maxLength:2,type:"number"},"%s":{format:function(t){return t.timestamp()},parse:function(t){return isNaN(Number(t))?{}:i(Number(t)).get()},minLength:1,maxLength:20,type:"number"},"%F":{format:function(t){return h(t.year()||i.MIN_YEAR,4)+"-"+h(t.month()||i.MIN_MONTH,2)+"-"+h(t.day()||i.MIN_DAY,2)},parse:function(t){var e=Number(t.slice(0,4)),n=Number(t.slice(5,7)),o=Number(t.slice(8,10));return{year:e,month:n,day:o}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return h(t.month()||i.MIN_MONTH,2)+"/"+h(t.day()||i.MIN_DAY,2)+"/"+h(t.year()||i.MIN_YEAR,4)},parse:function(t){var e=Number(t.slice(0,2)),n=Number(t.slice(3,5)),o=Number(t.slice(6,10));return{year:o,month:e,day:n}},minLength:10,maxLength:10,type:"string"}},bt={useMilliseconds:!1,monthFromZero:!1},y;y=function(t,e,n){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==s&&this.set(t,e,n),this},y.fn=y.prototype,y.fn.dayCount=function(){var t=this.month(),e=i.MAX_DAY_IN_MONTHS[t-(i.options("monthFromZero")?0:1)];return this.leapYear()&&t===(i.options("monthFromZero")?1:2)&&(e+=1),e},y.fn.year=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_YEAR&&Number(t)<=i.MAX_YEAR?(this._d.setFullYear(Number(t)),this._i.year=!1):this._i.year=Number(t):(this._d.setFullYear(i.MIN_YEAR),this._i.year=!1);else return this._i.year===!1?this._d.getFullYear():this._i.year;return this},y.fn.month=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MONTH&&Number(t)<=i.MAX_MONTH?(this._d.setMonth(i.options("monthFromZero")?Number(t):Number(t)-1),this._i.month=!1):this._i.month=Number(t):(this._d.setMonth(i.options("monthFromZero")?i.MIN_MONTH:i.MIN_MONTH-1),this._i.month=!1);else return this._i.month===!1?i.options("monthFromZero")?this._d.getMonth():this._d.getMonth()+1:this._i.month;return this},y.fn.day=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_DAY&&Number(t)<=this.dayCount()?(this._d.setDate(Number(t)),this._i.day=!1):this._i.day=Number(t):(this._d.setDate(i.MIN_DAY),this._i.day=!1);else return this._i.day===!1?this._d.getDate():this._i.day;return this},y.fn.hours=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_HOURS&&Number(t)<=i.MAX_HOURS?(this._d.setHours(Number(t)),this._i.hours=!1):this._i.hours=Number(t):(this._d.setHours(i.MIN_HOURS),this._i.hours=!1);else return this._i.hours===!1?this._d.getHours():this._i.hours;return this},y.fn.minutes=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MINUTES&&Number(t)<=i.MAX_MINUTES?(this._d.setMinutes(Number(t)),this._i.minutes=!1):this._i.minutes=Number(t):(this._d.setMinutes(i.MIN_MINUTES),this._i.minutes=!1);else return this._i.minutes===!1?this._d.getMinutes():this._i.minutes;return this},y.fn.seconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_SECONDS&&Number(t)<=i.MAX_SECONDS?(this._d.setSeconds(Number(t)),this._i.seconds=!1):this._i.seconds=Number(t):(this._d.setSeconds(i.MIN_SECONDS),this._i.seconds=!1);else return this._i.seconds===!1?this._d.getSeconds():this._i.seconds;return this},y.fn.milliseconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MILLISECONDS&&Number(t)<=i.MAX_MILLISECONDS?(this._d.setMilliseconds(Number(t)),this._i.milliseconds=!1):this._i.milliseconds=Number(t):(this._d.setMilliseconds(i.MIN_MILLISECONDS),this._i.milliseconds=!1);else return this._i.milliseconds===!1?this._d.getMilliseconds():this._i.milliseconds;return this},y.fn.week=function(){var t=new Date(this.year(),0,1),e=i(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((e-t.getTime())/864e5+t.getDay()+1)/7)},y.fn.set=function(t,e,n){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===s)return this._d=new Date,this;if(t instanceof Date)return this._d=t,this;if(typeof t=="number")return this._d=new Date(t*(i.options("useMilliseconds")?1:1e3)),this;if(typeof t=="object"&&(t instanceof Array?(this.day(i.MIN_DAY),this.year(t[0]),this.month(t[1]),this.day(t[2]),this.hours(t[3]),this.minutes(t[4]),this.seconds(t[5]),this.milliseconds(t[6])):(this.day(i.MIN_DAY),this.year(t.year),this.month(t.month),this.day(t.day),this.hours(t.hours),this.minutes(t.minutes),this.seconds(t.seconds),this.milliseconds(t.milliseconds))),typeof t=="string"){var o,L=[],O,M,x=[],D=0,U=0,p,P,b={},Y;if(t===s)return O=l(this,n),O===s&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),O;for(e===s&&(e=i.detectFormat(t));D<e.length;){if(e.charAt(D)==="%"){if(M=e.charAt(D)+e.charAt(D+1),B[M]!==s){switch(p=0,P="",B[M].type){case"number":for(;p<B[M].maxLength&&U+p<t.length&&!isNaN(Number(t.charAt(U+p)));)P+=t.charAt(U+p),p+=1;break;case"word":for(;p<B[M].maxLength&&U+p<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(U+p));)P+=t.charAt(U+p),p+=1;break;case"string":for(;p<B[M].maxLength&&U+p<t.length;)P+=t.charAt(U+p),p+=1;break}if(p<B[M].minLength)return O=l(this,n),O===s&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),O;L.push(M),x.push(P),p-=1,U+=p,D+=1}}else if(t.charAt(U)!==e.charAt(D))return O=l(this,n),O===s&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),O;D+=1,U+=1}for(o in L)L.hasOwnProperty(o)&&B.hasOwnProperty(L[o])&&(Y=B[L[o]].parse(x[o]),b={year:Y.year!==s?Y.year:b.year,month:Y.month!==s?Y.month:b.month,day:Y.day!==s?Y.day:b.day,hours:Y.hours!==s?Y.hours:b.hours,minutes:Y.minutes!==s?Y.minutes:b.minutes,seconds:Y.seconds!==s?Y.seconds:b.seconds});this.day(i.MIN_DAY),this.year(b.year),this.month(b.month),this.day(b.day),this.hours(b.hours),this.minutes(b.minutes),this.seconds(b.seconds),this.milliseconds(b.milliseconds)}return this},y.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},y.fn.timestamp=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(i.options("useMilliseconds")?1:1e3)+this._d.getTimezoneOffset()*6e4),this):i.options("useMilliseconds")?this._d.getTime()-this._d.getTimezoneOffset()*6e4:Math.floor(this._d.getTime()/1e3)-this._d.getTimezoneOffset()*60},y.fn.utc=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(i.options("useMilliseconds")?1:1e3)),this):i.options("useMilliseconds")?this._d.getTime():Math.floor(this._d.getTime()/1e3)},y.fn.dayOfWeek=function(t){if(t==="long")return _t[this._d.getDay()];if(t==="short")return Ot[this._d.getDay()];if(t===s)return this._d.getDay();if(t===0||t==="Sunday")return this.calc({day:-this.dayOfWeek()});if(t===1||t==="Monday")return this.calc({day:(this.dayOfWeek()===0?-6:1)-this.dayOfWeek()});if(t===2||t==="Tuesday")return this.calc({day:(this.dayOfWeek()===0?-5:2)-this.dayOfWeek()});if(t===3||t==="Wednesday")return this.calc({day:(this.dayOfWeek()===0?-4:3)-this.dayOfWeek()});if(t===4||t==="Thursday")return this.calc({day:(this.dayOfWeek()===0?-3:4)-this.dayOfWeek()});if(t===5||t==="Friday")return this.calc({day:(this.dayOfWeek()===0?-2:5)-this.dayOfWeek()});if(t===6||t==="Saturday")return this.calc({day:(this.dayOfWeek()===0?-1:6)-this.dayOfWeek()})},y.fn.timezone=function(t){switch(t){case"hours":return Math.floor(this._d.getTimezoneOffset()/60);case"minutes":return this._d.getTimezoneOffset();default:return this._d.getTimezoneOffset()*60}},y.fn.get=function(t){switch(t){case"Date":return new Date(this.year(),this.month()-(i.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds());case"DateUTC":return new Date(Date.UTC(this.year(),this.month()-(i.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()));case"Array":return[this.year(),this.month(),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()];default:return{year:this.year(),month:this.month(),week:this.week(),day:this.day(),hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds(),utc:this.utc(),dayOfWeek:this.dayOfWeek(),dayOfWeekShort:this.dayOfWeek("short"),dayOfWeekLong:this.dayOfWeek("long"),timestamp:this.timestamp()}}},y.fn.format=function(t){for(var e=0,n="",o;e<t.length;)t.charAt(e)==="%"?(o=t.charAt(e)+t.charAt(e+1),B[o]!==s?(n+=B[o].format(this),e+=1):n+="%"):n+=t.charAt(e),e+=1;return n},y.fn.valid=function(){return this._i.year===!1&&this._i.month===!1&&this._i.day===!1&&this._i.hours===!1&&this._i.minutes===!1&&this._i.seconds===!1&&this._i.milliseconds===!1},y.fn.errors=function(){return this._i},y.fn.between=function(t,e){var n=this.timestamp(),o=t.timestamp();switch(e){case"year":return Math.floor((o-n)/31556952);case"month":return Math.floor((o-n)/2629746);case"day":return Math.floor((o-n)/86400);case"hours":return Math.floor((o-n)/3600);case"minutes":return Math.floor((o-n)/60);case"seconds":return o-n;default:return s}},y.fn.calc=function(t){return t.year!==s&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==s&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==s&&this._d.setDate(this._d.getDate()+t.day),t.hours!==s&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==s&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==s&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==s&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},i=function(t,e,n){return new y(t,e,n)},i.MIN_YEAR=1e3,i.MAX_YEAR=3e3,i.MIN_MONTH=1,i.MAX_MONTH=12,i.MIN_DAY=1,i.MAX_DAY_IN_MONTHS=[31,28,31,30,31,30,31,31,30,31,30,31],i.MIN_DAY_OF_WEEK=0,i.MAX_DAY_OF_WEEK=6,i.MIN_HOURS=0,i.MAX_HOURS=23,i.MIN_MINUTES=0,i.MAX_MINUTES=59,i.MIN_SECONDS=0,i.MAX_SECONDS=59,i.MIN_MILLISECONDS=0,i.MAX_MILLISECONDS=999,i.VERSION="0.2.18",i.options=function(t,e){if(t===s)return bt;if(bt.hasOwnProperty(t)){if(e===s)return bt[t];bt[t]=e,t==="monthFromZero"&&(i.MIN_MONTH=e?0:1,i.MAX_MONTH=e?11:12)}return s},i.noConflict=function(){return a.tempus=S,i},i.generate=function(t){var e,n,o,L,O,M,x,D;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof y?e=t.dateFrom.utc():e=i(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof y?n=t.dateTo.utc():n=i(t.dateTo,t.formatTo!==s?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?O={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?O={year:t.period==="year"?1:0,month:t.period==="month"?1:0,day:t.period==="day"?1:0,hours:t.period==="hours"?1:0,minutes:t.period==="minutes"?1:0,seconds:t.period==="seconds"?1:0}:typeof t.period=="object"&&(O={year:t.period.year!==s?t.period.year:0,month:t.period.month!==s?t.period.month:0,day:t.period.day!==s?t.period.day:0,hours:t.period.hours!==s?t.period.hours:0,minutes:t.period.minutes!==s?t.period.minutes:0,seconds:t.period.seconds!==s?t.period.seconds:0}),t.groupBy===s?M=t.asObject===!0?{}:[]:(M=[],M.push([]),x=i(e).get()[t.groupBy]),D=function(P,b,Y){return t.asObject===!0?t.format!==s?P[i(b).format(t.format)]={}:P[i(b).format("%F %H:%M:%S")]={}:t.format!==s?P.push(Y?null:i(b).format(t.format)):P.push(Y?null:i(b)),P},t.groupBy!==s&&t.fillNulls){var U={year:O.year?-O.year:s,month:O.month?-O.month:s,day:O.day?-O.day:s,hours:O.hours?-O.hours:s,minutes:O.minutes?-O.minutes:s,seconds:O.seconds?-O.seconds:s,milliseconds:O.milliseconds?-O.milliseconds:s};for(o=i(e).calc(U).utc();i(o).get()[t.groupBy]===x;)D(M[M.length-1],o,!0),o=i(o).calc(U).utc();if(t.groupBy==="week"){var p=i(e).dayOfWeek();for(o=i(e).dayOfWeek(0).utc();M[0].length<p&&o<e;)D(M[M.length-1],o,!0),o=i(o).calc(O).utc()}}for(;e<=n;)t.groupBy===s?D(M,e):i(e).get()[t.groupBy]===x?D(M[M.length-1],e):(M.push([]),D(M[M.length-1],e),x=i(e).get()[t.groupBy]),e=i(e).calc(O).utc();if(t.groupBy!==s&&t.fillNulls)for(L=i(n).calc(O).utc();i(L).get()[t.groupBy]===x;)D(M[M.length-1],L,!0),L=i(L).calc(O).utc();return M},i.monthNames=function(t){switch(t){case"long":return Lt;default:return pt}},i.dayNames=function(t){switch(t){case"long":return _t;default:return Ot}},i.lang=function(t){if(t!==s)c=t,m[c]===s&&(c="en"),Lt=Nt(),pt=v(),_t=gt(),Ot=dt();else return c;return s},i.availableLangs=function(){return Object.keys(m)},i.registerFormat=function(t,e,n,o,L,O){B[t]={format:e,parse:n,minLength:o,maxLength:L,type:O}},i.unregisterFormat=function(t){delete B[t]},i.detectFormat=function(t){var e,n,o;return e=T(t,0),e!==""&&(o=10),n=t.charAt(o),(n==="T"||n===" ")&&(e+=n,o+=1),e+=f(t,o),e},g={TempusDate:y},i.classes=function(t,e){if(e===s)return g[t];g[t]=e},i.loadTranslations=function(t){typeof t=="object"?m=t:typeof t=="string"&&vt(t,function(e){m=e},function(e){})},c=(H.language||H.systemLanguage||H.userLanguage||"en").substr(0,2).toLowerCase(),m[c]===s&&(c="en"),Lt=Nt(),pt=v(),_t=gt(),Ot=dt(),F.exports&&(r=F.exports=i),r.tempus=i}).call(R)})($,$.exports);var Qt=$.exports;const jt=d(Qt);class Ut{constructor(r,s={}){_(this,tt);_(this,rt);_(this,nt);_(this,ot);_(this,ht);_(this,at);_(this,Rt);_(this,Tt);_(this,ut);_(this,ct);_(this,mt);_(this,et);_(this,lt);_(this,yt);_(this,q);_(this,st);_(this,ft);_(this,j,null);_(this,it,null);_(this,k,[]);_(this,G,{});_(this,w,{});_(this,W,50);_(this,V,!0);_(this,Z,null);_(this,I,null);_(this,J,null);_(this,St,100);_(this,z,"no");_(this,C,!1);_(this,K,!1);_(this,Q,!1);E(this,j,r),E(this,it,s)}get serial(){return u(this,C)}setSerial(){E(this,C,!0),E(this,K,!0),E(this,Q,!1)}setParallel(){E(this,C,!1),E(this,K,!1),E(this,Q,!0)}stop(){E(this,V,!1)}async batch(r,s){u(this,J)&&N(this,rt,Gt).call(this),s&&E(this,Z,s),u(this,K)===!1&&E(this,C,!1),Object.keys(r).length>500&&E(this,C,!0),E(this,V,!0),E(this,k,[]),E(this,G,{}),E(this,w,{});const a=N(this,ot,Ct).call(this,r);if(Object.keys(r).length<500){const h=a.map((l,f)=>N(this,ht,Pt).call(this,l,a[f]));return Promise.allSettled(h).then(l=>{let f={};for(let T of l)T.status==="fulfilled"&&(f={...f,...T.value});return f})}else{let h={},l=0,f=1,T=Object.keys(r).length||1,S=i=>{l+=Object.keys(i).length,f=Math.round(l/T*100)};for(let[i,g]of Object.entries(a)){let H=await N(this,ht,Pt).call(this,g,a[i],!0);S(g),s&&s({percent:f}),h={...h,...H}}return h}}async batchTotalCount(r,s){E(this,G,{}),E(this,w,{});let a=1,h=0,l=Object.keys(r).length||1,f=S=>{h+=Object.keys(S).length,a=Math.round(h/l*100)};s&&s({percent:a});const T=N(this,ot,Ct).call(this,r);if(u(this,Q)){const S=T.map(i=>N(this,at,Ft).call(this,i).then(g=>(f(i),s&&s({percent:a}),g)));return Promise.allSettled(S).then(i=>{let g={};for(let H of i)H.status==="fulfilled"&&(g={...g,...H.value});return g})}else{let S={};for(let i of T){let g=await N(this,at,Ft).call(this,i);f(i),s&&s({percent:a}),S={...S,...g}}return S}}}j=new WeakMap,it=new WeakMap,k=new WeakMap,G=new WeakMap,w=new WeakMap,W=new WeakMap,V=new WeakMap,Z=new WeakMap,I=new WeakMap,J=new WeakMap,St=new WeakMap,z=new WeakMap,C=new WeakMap,K=new WeakMap,Q=new WeakMap,tt=new WeakSet,Ht=function(){let r=0;if(!u(this,I))return Math.round(r);let s=0,a=0;return Object.values(u(this,I)).forEach(h=>{const{total:l,count:f}=h;s+=l??0,a+=f??0}),s?r=a/s*100:r=100,{percent:Math.round(r),allCount:a,allTotal:s}},rt=new WeakSet,Gt=function(){clearInterval(u(this,J)),E(this,J,""),E(this,I,""),E(this,Z,""),E(this,z,"no")},nt=new WeakSet,Bt=function({key:r,value:s}){const a=N(this,q,At).call(this,s.data()),h=Array.isArray(a)?a.length:0,l=N(this,st,Dt).call(this,s.total(),h);let f=1;a&&(f=h),u(this,Z)&&(u(this,I)||E(this,I,{}),u(this,I)[r]&&u(this,I)[r].count&&(f+=u(this,I)[r].count),u(this,I)[r]={total:l,count:f},u(this,J)||E(this,J,setInterval(()=>{const{percent:T,allCount:S,allTotal:i}=u(this,tt,Ht);(u(this,z)==="no"||u(this,z)<u(this,tt,Ht).percent)&&(u(this,Z).call(this,{data:u(this,I),percent:T,allCount:S,allTotal:i}),E(this,z,u(this,tt,Ht).percent)),T===100&&N(this,rt,Gt).call(this)},u(this,St))))},ot=new WeakSet,Ct=function(r){const s=[],a=Object.entries(r);for(let h=0;h<a.length;h+=u(this,W)){const l=a.slice(h,h+u(this,W));s.push(Object.fromEntries(l))}return s},ht=new WeakSet,Pt=function(r,s,a){return new Promise(h=>{const l=N(this,lt,xt).call(this,s),f=[];let T=0,S=0;u(this,j).call(this,r,i=>{Object.entries(i).forEach(([g,H])=>{const c=H.error();c&&(u(this,w)[g]=c,T+=1);const m=N(this,q,At).call(this,H.data()),Nt=Array.isArray(m)?m.length:0,v=N(this,st,Dt).call(this,H.total(),Nt);if(u(this,G)[g]=m,S+=v,a||N(this,nt,Bt).call(this,{key:g,value:H}),v>u(this,W)&&v>Nt){const gt=Math.ceil(v/u(this,W))-1,dt=Array.from({length:gt});f.push([g,l[g],dt])}}),S>5e3&&u(this,K)===!1&&u(this,Q)===!1&&E(this,C,!0),T>0&&N(this,ft,Xt).call(this),f.length?(N(this,Rt,kt).call(this,f),N(this,Tt,Vt).call(this).then(()=>h(N(this,et,Yt).call(this)))):h(N(this,et,Yt).call(this))})})},at=new WeakSet,Ft=function(r){return new Promise(s=>{const a=N(this,lt,xt).call(this,r);let h=0;u(this,j).call(this,a,l=>{Object.entries(l).forEach(([f,T])=>{const S=T.error();S&&(u(this,w)[f]=S,h+=1);const i=N(this,q,At).call(this,T.data()),g=Array.isArray(i)?i.length:0,H=N(this,st,Dt).call(this,T.total(),g);u(this,G)[f]=H}),h>0&&N(this,ft,Xt).call(this),s(N(this,et,Yt).call(this))})})},Rt=new WeakSet,kt=function(r){let s=[];r.forEach(([a,h,l])=>{l.forEach((f,T)=>{const S=T+1,i=u(this,W)*S,H=[[a,S].join("_"),N(this,yt,Zt).call(this,h,i)];s.length===u(this,W)?(u(this,k).push(s),s=[H]):s.push(H)})}),s.length&&u(this,k).push(s)},Tt=new WeakSet,Vt=function(){const r=[],s=[],a=h=>{Object.entries(h).forEach(([l,f])=>{const[T]=l.split("_"),S=N(this,q,At).call(this,f.data());Array.isArray(S)&&u(this,G)[T].push(...S),N(this,nt,Bt).call(this,{key:T,value:f})})};return u(this,k).forEach((h,l)=>{const f=Object.fromEntries(h),T=()=>new Promise(S=>u(this,j).call(this,f,i=>{u(this,C)?a(i):s[l]=i,S()}));r.push(T)}),u(this,C)?N(this,ct,wt).call(this,r):N(this,mt,Jt).call(this,r).then(()=>{s.forEach(a)})},ut=new WeakSet,Wt=function(){return new Promise(r=>setTimeout(r,500))},ct=new WeakSet,wt=function(r){if(!r.length)return Promise.resolve();const s=r.shift();return Promise.allSettled([s(),N(this,ut,Wt).call(this)]).then(()=>u(this,V)?N(this,ct,wt).call(this,r):Promise.resolve())},mt=new WeakSet,Jt=function(r){if(!r.length)return Promise.resolve();const s=r.shift();return N(this,ut,Wt).call(this).then(()=>s()).then(()=>u(this,V)?N(this,mt,Jt).call(this,r):Promise.resolve())},et=new WeakSet,Yt=function(){return Object.entries(u(this,it)).forEach(([r,s])=>{u(this,G)[r]&&(u(this,G)[r]=s(u(this,G)[r]))}),u(this,G)},lt=new WeakSet,xt=function(r){return Object.entries(r).reduce((s,[a,h])=>{if(Array.isArray(h)){const[l,f={}]=h;s[a]=[l,f]}else{const{method:l,params:f={}}=h;s[a]=[l,f]}return s},{})},yt=new WeakSet,Zt=function(r,s){const[a,h]=r;return[a,{start:s,...h}]},q=new WeakSet,At=function(r){return((r==null?void 0:r.items)||(r==null?void 0:r.documents))??r},st=new WeakSet,Dt=function(r,s){return r!==r&&(r=0),r===0&&s===0?0:r||s},ft=new WeakSet,Xt=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(u(this,w)).forEach(([r,s])=>{console.info(`[${r}]`,s.toString())}),console.groupEnd()};class qt{constructor(r){_(this,Et);_(this,Mt);X(this,"domain","");X(this,"isAdmin",!1);X(this,"appInfo",null);X(this,"appConst",null);X(this,"userInfo",null);X(this,"placeData",null);X(this,"placeInfo",null);this.appConst=r}init(){return new Promise(r=>{let s=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(s),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info();const[a,h]=await Promise.all([N(this,Et,zt).call(this),N(this,Mt,Kt).call(this)]);this.appInfo=a,this.userInfo=h,r(!0)})},100)})}userOption(r,s){return s?BX24.userOption.set(r,s):BX24.userOption.get(r)}call({method:r,params:s}){return new Promise(a=>{s||(s={}),BX24.callMethod(r,s,function(h){if(h.error()){let l=h.error();console.error(l),a(!1)}else{let l=h.data();l!=null&&l.items&&(l=l.items),a(l)}})})}batch(r,s){return new Ut(BX24.callBatch).batch(r,s)}batchTotalCount(r,s){return new Ut(BX24.callBatch).batchTotalCount(r,s)}getPlacement(){return this.call({method:"placement.get"}).then(r=>(this.placeData||(this.placeData=r),r))}async placementBind(r){this.placeData||(this.placeData=await this.getPlacement());const{appName:s,pathApp:a}=this.appConst,h=this.placeData.map(f=>f.placement);let l=this.placeData.find(f=>f.placement==r);h.includes(r)?l.handler!=a&&(window.placementUnBind||(window.placementUnBind={}),window.placementUnBind[r]||this.placementUnBind(l).then(()=>{window.placementUnBind[r]||(window.placementUnBind[r]=!0,this.placementBind(r))})):this.call({method:"placement.bind",params:{PLACEMENT:r,HANDLER:a,LANG_ALL:{ru:{TITLE:s}}}}).then(f=>{f?console.info("Приложение успешно встроено в",r):console.warn("Приложение не может быть встроено в",r)})}placementUnBind(r){const{pathApp:s,appName:a}=this.appConst;return this.call({method:"placement.unbind",params:{PLACEMENT:r,HANDLER:s,LANG_ALL:{ru:{TITLE:a}}}}).then(h=>(console.log("Встройка отвязана",r),h))}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(r=>{let s=Object.values(r);return console.log("chat-bot list:",s),s})}regBot({code:r,type:s,name:a}){const{appName:h,pathApp:l,chatBotLogo:f}=this.appConst,T=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:r??this.appInfo.CODE,TYPE:s??"O",EVENT_HANDLER:l,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${a??h} - бот #${T}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:jt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:f??""}}}).then(S=>(console.log("Чат-бот добавлен",S),S))}unRegBot(r){return this.call({method:"imbot.unregister",params:{BOT_ID:r}}).then(s=>(console.log("чат-бот удален",s),s))}}Et=new WeakSet,zt=function(){return this.call({method:"app.info"})},Mt=new WeakSet,Kt=function(){return this.call({method:"user.current"})},A.Batch=Ut,A.BxBoot=qt,A.tempus=jt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
var Ae=Object.defineProperty;var Te=(T,S,L)=>S in T?Ae(T,S,{enumerable:!0,configurable:!0,writable:!0,value:L}):T[S]=L;var J=(T,S,L)=>(Te(T,typeof S!="symbol"?S+"":S,L),L),zt=(T,S,L)=>{if(!S.has(T))throw TypeError("Cannot "+L)};var a=(T,S,L)=>(zt(T,S,"read from private field"),L?L.call(T):S.get(T)),_=(T,S,L)=>{if(S.has(T))throw TypeError("Cannot add the same private member more than once");S instanceof WeakSet?S.add(T):S.set(T,L)},g=(T,S,L,ht)=>(zt(T,S,"write to private field"),ht?ht.call(T,L):S.set(T,L),L);var O=(T,S,L)=>(zt(T,S,"access private method"),L);(function(T,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(T=typeof globalThis<"u"?globalThis:T||self,S(T["szdl-utils-kit"]={}))})(this,function(T){var K,ut,q,I,j,Q,v,B,x,Dt,$,P,tt,et,at,Xt,mt,Vt,ft,Zt,Nt,Kt,_t,qt,Ot,Qt,Ht,oe,Yt,he,yt,vt,At,$t,Tt,te,ct,jt,St,ee,Ut,ae,st,pt,lt,kt,dt,se,rt,W,z,It,it,gt,Bt,ce,Et,re,Gt,le,wt,ue,Ct,me,Pt,fe,Ft,Ne;"use strict";var S=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function L(w){return w&&w.__esModule&&Object.prototype.hasOwnProperty.call(w,"default")?w.default:w}var ht={exports:{}};(function(w,i){(function(e){Array.prototype.indexOf||(Array.prototype.indexOf=function(t,s){var h,c;for(h=s||0,c=this.length;h<c;h+=1)if(this[h]===t)return h;return-1});var o=this,n=function(t,s){for(var h=t.toString();h.length<s;)h="0"+h;return h},u=function(t,s){return s!==e?(t.year(s.year()||s.year),t.month(s.month()||s.month),t.day(s.day()||s.day),t.hours(s.hours()||s.hours),t.minutes(s.minutes()||s.minutes),t.seconds(s.seconds()||s.seconds),t.milliseconds(s.milliseconds()||s.milliseconds),t):e},l=function(t,s){var h,c="";return h=t.slice(s,s+1),h!==""&&!isNaN(Number(h))&&(c+="%H"),h=t.charAt(s+2),h!==""&&h===":"&&(c+=h),h=t.slice(s+3,s+4),h!==""&&!isNaN(Number(h))&&(c+="%M"),h=t.charAt(s+5),h!==""&&h===":"&&(c+=h),h=t.slice(s+6,s+7),h!==""&&!isNaN(Number(h))&&(c+="%S"),c},y=function(t,s){var h,c=[t.slice(s,s+1),t.charAt(s+2),t.slice(s+3,s+4),t.charAt(s+5),t.slice(s+6,s+9)],p;return!isNaN(Number(c[0]))&&!isNaN(Number(c[2]))&&!isNaN(Number(c[4]))?(c[1]==="."&&c[3]==="."?h="%d.%m.%Y":c[1]==="-"&&c[3]==="-"?h="%m-%d-%Y":c[1]==="/"&&c[3]==="/"&&(h="%m/%d/%Y"),h):(p=[t.slice(s,s+3),t.charAt(s+4),t.slice(s+5,s+6),t.charAt(s+7),t.slice(s+8,s+9)],!isNaN(Number(p[0]))&&!isNaN(Number(p[2]))&&!isNaN(Number(p[4]))?(p[1]==="-"&&p[3]==="-"&&(h="%Y-%m-%d"),h):"")},f=o.tempus,r,R,M=o.navigator||{},m="en",N={en:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"Mar",APRIL_SHORT:"Apr",MAY_SHORT:"May",JUNE_SHORT:"Jun",JULY_SHORT:"Jul",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sep",OCTOBER_SHORT:"Oct",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dec",JANUARY_LONG:"January",FEBRUARY_LONG:"February",MARCH_LONG:"March",APRIL_LONG:"April",MAY_LONG:"May",JUNE_LONG:"June",JULY_LONG:"July",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"October",NOVEMBER_LONG:"November",DECEMBER_LONG:"December",SUNDAY_SHORT:"Sun",MONDAY_SHORT:"Mon",TUESDAY_SHORT:"Tue",WEDNESDAY_SHORT:"Wed",THURSDAY_SHORT:"Thu",FRIDAY_SHORT:"Fri",SATURDAY_SHORT:"Sat",SUNDAY_LONG:"Sunday",MONDAY_LONG:"Monday",TUESDAY_LONG:"Tuesday",WEDNESDAY_LONG:"Wednesday",THURSDAY_LONG:"Thursday",FRIDAY_LONG:"Friday",SATURDAY_LONG:"Saturday"},ru:{JANUARY_SHORT:"Янв",FEBRUARY_SHORT:"Фев",MARCH_SHORT:"Мар",APRIL_SHORT:"Апр",MAY_SHORT:"Май",JUNE_SHORT:"Июн",JULY_SHORT:"Июл",AUGUST_SHORT:"Авг",SEPTEMBER_SHORT:"Сен",OCTOBER_SHORT:"Окт",NOVEMBER_SHORT:"Ноя",DECEMBER_SHORT:"Дек",JANUARY_LONG:"Январь",FEBRUARY_LONG:"Февраль",MARCH_LONG:"Март",APRIL_LONG:"Апрель",MAY_LONG:"Май",JUNE_LONG:"Июнь",JULY_LONG:"Июль",AUGUST_LONG:"Август",SEPTEMBER_LONG:"Сентябрь",OCTOBER_LONG:"Октябрь",NOVEMBER_LONG:"Ноябрь",DECEMBER_LONG:"Декабрь",SUNDAY_SHORT:"Вс",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Воскресенье",MONDAY_LONG:"Понедельник",TUESDAY_LONG:"Вторник",WEDNESDAY_LONG:"Среда",THURSDAY_LONG:"Четверг",FRIDAY_LONG:"Пятница",SATURDAY_LONG:"Суббота"},ua:{JANUARY_SHORT:"Січ",FEBRUARY_SHORT:"Лют",MARCH_SHORT:"Берез",APRIL_SHORT:"Квіт",MAY_SHORT:"Трав",JUNE_SHORT:"Черв",JULY_SHORT:"Лип",AUGUST_SHORT:"Серп",SEPTEMBER_SHORT:"Верес",OCTOBER_SHORT:"Жовт",NOVEMBER_SHORT:"Листоп",DECEMBER_SHORT:"Груд",JANUARY_LONG:"Січень",FEBRUARY_LONG:"Лютий",MARCH_LONG:"Березень",APRIL_LONG:"Квітень",MAY_LONG:"Травень",JUNE_LONG:"Червень",JULY_LONG:"Липень",AUGUST_LONG:"Серпень",SEPTEMBER_LONG:"Вересень",OCTOBER_LONG:"Жовтень",NOVEMBER_LONG:"Листопад",DECEMBER_LONG:"Грудень",SUNDAY_SHORT:"Нд",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Неділя",MONDAY_LONG:"Понеділок",TUESDAY_LONG:"Вівторок",WEDNESDAY_LONG:"Середа",THURSDAY_LONG:"Четвер",FRIDAY_LONG:"П’ятниця",SATURDAY_LONG:"Субота"},de:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"März",APRIL_SHORT:"Apr",MAY_SHORT:"Mai",JUNE_SHORT:"Juni",JULY_SHORT:"Juli",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sept",OCTOBER_SHORT:"Okt",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dez",JANUARY_LONG:"Januar",FEBRUARY_LONG:"Februar",MARCH_LONG:"März",APRIL_LONG:"April",MAY_LONG:"Mai",JUNE_LONG:"Juni",JULY_LONG:"Juli",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"Oktober",NOVEMBER_LONG:"November",DECEMBER_LONG:"Dezember",SUNDAY_SHORT:"So",MONDAY_SHORT:"Mo",TUESDAY_SHORT:"Di",WEDNESDAY_SHORT:"Mi",THURSDAY_SHORT:"Do",FRIDAY_SHORT:"Fr",SATURDAY_SHORT:"Sa",SUNDAY_LONG:"Sonntag",MONDAY_LONG:"Montag",TUESDAY_LONG:"Dienstag",WEDNESDAY_LONG:"Mittwoch",THURSDAY_LONG:"Donnerstag",FRIDAY_LONG:"Freitag",SATURDAY_LONG:"Samstag"}},V=function(){return[N[m].JANUARY_LONG,N[m].FEBRUARY_LONG,N[m].MARCH_LONG,N[m].APRIL_LONG,N[m].MAY_LONG,N[m].JUNE_LONG,N[m].JULY_LONG,N[m].AUGUST_LONG,N[m].SEPTEMBER_LONG,N[m].OCTOBER_LONG,N[m].NOVEMBER_LONG,N[m].DECEMBER_LONG]},Rt=function(){return[N[m].JANUARY_SHORT,N[m].FEBRUARY_SHORT,N[m].MARCH_SHORT,N[m].APRIL_SHORT,N[m].MAY_SHORT,N[m].JUNE_SHORT,N[m].JULY_SHORT,N[m].AUGUST_SHORT,N[m].SEPTEMBER_SHORT,N[m].OCTOBER_SHORT,N[m].NOVEMBER_SHORT,N[m].DECEMBER_SHORT]},nt=function(){return[N[m].SUNDAY_LONG,N[m].MONDAY_LONG,N[m].TUESDAY_LONG,N[m].WEDNESDAY_LONG,N[m].THURSDAY_LONG,N[m].FRIDAY_LONG,N[m].SATURDAY_LONG]},ot=function(){return[N[m].SUNDAY_SHORT,N[m].MONDAY_SHORT,N[m].TUESDAY_SHORT,N[m].WEDNESDAY_SHORT,N[m].THURSDAY_SHORT,N[m].FRIDAY_SHORT,N[m].SATURDAY_SHORT]},k,Jt,Mt,Lt,ye=function(t,s,h){var c;o.XMLHttpRequest?c=new XMLHttpRequest:c=new ActiveXObject("Microsoft.XMLHTTP"),c.onreadystatechange=function(){c.readyState===4&&(c.status===200?s&&(o.JSON===e?alert(`Please, include json2 into your project if you want use old browsers!
|
|
2
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):s(JSON.parse(c.responseText))):h&&h(c))},c.open("GET",t,!1),c.send()},C={"%d":{format:function(t){return n(t.day()||r.MIN_DAY,2)},parse:function(t){var s=Number(t);return{day:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return n(t.month()||r.MIN_MONTH,2)},parse:function(t){var s=Number(t);return{month:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return n(t.year()||r.MIN_YEAR,4)},parse:function(t){var s=Number(t);return{year:isNaN(s)?e:s}},minLength:4,maxLength:4,type:"number"},"%w":{format:function(t){return t.dayOfWeek()||r.MIN_DAY_OF_WEEK},parse:function(){return{}},minLength:1,maxLength:1,type:"number"},"%a":{format:function(t){var s=t.dayOfWeek();return Lt[s!==e?s:r.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var s=t.dayOfWeek();return Mt[s!==e?s:r.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var s=r.options("monthFromZero")?t.month():t.month()-1;return Jt[s!==e?s:r.MIN_MONTH]},parse:function(t){var s=r.monthNames().indexOf(t)+(r.options("monthFromZero")?0:1);return{month:s!==-1?s:e}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var s=r.options("monthFromZero")?t.month():t.month()-1;return k[s!==e?s:r.MIN_MONTH]},parse:function(t){var s=r.monthNames(!0).indexOf(t)+(r.options("monthFromZero")?0:1);return{month:s!==-1?s:e}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return n(t.hours()||r.MIN_HOURS,2)},parse:function(t){var s=Number(t);return{hours:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return n(t.minutes()||r.MIN_MINUTES,2)},parse:function(t){var s=Number(t);return{minutes:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return n(t.seconds()||r.MIN_SECONDS,2)},parse:function(t){var s=Number(t);return{seconds:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%s":{format:function(t){return t.timestamp()},parse:function(t){return isNaN(Number(t))?{}:r(Number(t)).get()},minLength:1,maxLength:20,type:"number"},"%F":{format:function(t){return n(t.year()||r.MIN_YEAR,4)+"-"+n(t.month()||r.MIN_MONTH,2)+"-"+n(t.day()||r.MIN_DAY,2)},parse:function(t){var s=Number(t.slice(0,4)),h=Number(t.slice(5,7)),c=Number(t.slice(8,10));return{year:s,month:h,day:c}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return n(t.month()||r.MIN_MONTH,2)+"/"+n(t.day()||r.MIN_DAY,2)+"/"+n(t.year()||r.MIN_YEAR,4)},parse:function(t){var s=Number(t.slice(0,2)),h=Number(t.slice(3,5)),c=Number(t.slice(6,10));return{year:c,month:s,day:h}},minLength:10,maxLength:10,type:"string"}},Wt={useMilliseconds:!1,monthFromZero:!1},d;d=function(t,s,h){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==e&&this.set(t,s,h),this},d.fn=d.prototype,d.fn.dayCount=function(){var t=this.month(),s=r.MAX_DAY_IN_MONTHS[t-(r.options("monthFromZero")?0:1)];return this.leapYear()&&t===(r.options("monthFromZero")?1:2)&&(s+=1),s},d.fn.year=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_YEAR&&Number(t)<=r.MAX_YEAR?(this._d.setFullYear(Number(t)),this._i.year=!1):this._i.year=Number(t):(this._d.setFullYear(r.MIN_YEAR),this._i.year=!1);else return this._i.year===!1?this._d.getFullYear():this._i.year;return this},d.fn.month=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_MONTH&&Number(t)<=r.MAX_MONTH?(this._d.setMonth(r.options("monthFromZero")?Number(t):Number(t)-1),this._i.month=!1):this._i.month=Number(t):(this._d.setMonth(r.options("monthFromZero")?r.MIN_MONTH:r.MIN_MONTH-1),this._i.month=!1);else return this._i.month===!1?r.options("monthFromZero")?this._d.getMonth():this._d.getMonth()+1:this._i.month;return this},d.fn.day=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_DAY&&Number(t)<=this.dayCount()?(this._d.setDate(Number(t)),this._i.day=!1):this._i.day=Number(t):(this._d.setDate(r.MIN_DAY),this._i.day=!1);else return this._i.day===!1?this._d.getDate():this._i.day;return this},d.fn.hours=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_HOURS&&Number(t)<=r.MAX_HOURS?(this._d.setHours(Number(t)),this._i.hours=!1):this._i.hours=Number(t):(this._d.setHours(r.MIN_HOURS),this._i.hours=!1);else return this._i.hours===!1?this._d.getHours():this._i.hours;return this},d.fn.minutes=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_MINUTES&&Number(t)<=r.MAX_MINUTES?(this._d.setMinutes(Number(t)),this._i.minutes=!1):this._i.minutes=Number(t):(this._d.setMinutes(r.MIN_MINUTES),this._i.minutes=!1);else return this._i.minutes===!1?this._d.getMinutes():this._i.minutes;return this},d.fn.seconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_SECONDS&&Number(t)<=r.MAX_SECONDS?(this._d.setSeconds(Number(t)),this._i.seconds=!1):this._i.seconds=Number(t):(this._d.setSeconds(r.MIN_SECONDS),this._i.seconds=!1);else return this._i.seconds===!1?this._d.getSeconds():this._i.seconds;return this},d.fn.milliseconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=r.MIN_MILLISECONDS&&Number(t)<=r.MAX_MILLISECONDS?(this._d.setMilliseconds(Number(t)),this._i.milliseconds=!1):this._i.milliseconds=Number(t):(this._d.setMilliseconds(r.MIN_MILLISECONDS),this._i.milliseconds=!1);else return this._i.milliseconds===!1?this._d.getMilliseconds():this._i.milliseconds;return this},d.fn.week=function(){var t=new Date(this.year(),0,1),s=r(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((s-t.getTime())/864e5+t.getDay()+1)/7)},d.fn.set=function(t,s,h){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===e)return this._d=new Date,this;if(t instanceof Date)return this._d=t,this;if(typeof t=="number")return this._d=new Date(t*(r.options("useMilliseconds")?1:1e3)),this;if(typeof t=="object"&&(t instanceof Array?(this.day(r.MIN_DAY),this.year(t[0]),this.month(t[1]),this.day(t[2]),this.hours(t[3]),this.minutes(t[4]),this.seconds(t[5]),this.milliseconds(t[6])):(this.day(r.MIN_DAY),this.year(t.year),this.month(t.month),this.day(t.day),this.hours(t.hours),this.minutes(t.minutes),this.seconds(t.seconds),this.milliseconds(t.milliseconds))),typeof t=="string"){var c,p=[],A,E,Z=[],Y=0,U=0,b,F,D={},H;if(t===e)return A=u(this,h),A===e&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),A;for(s===e&&(s=r.detectFormat(t));Y<s.length;){if(s.charAt(Y)==="%"){if(E=s.charAt(Y)+s.charAt(Y+1),C[E]!==e){switch(b=0,F="",C[E].type){case"number":for(;b<C[E].maxLength&&U+b<t.length&&!isNaN(Number(t.charAt(U+b)));)F+=t.charAt(U+b),b+=1;break;case"word":for(;b<C[E].maxLength&&U+b<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(U+b));)F+=t.charAt(U+b),b+=1;break;case"string":for(;b<C[E].maxLength&&U+b<t.length;)F+=t.charAt(U+b),b+=1;break}if(b<C[E].minLength)return A=u(this,h),A===e&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),A;p.push(E),Z.push(F),b-=1,U+=b,Y+=1}}else if(t.charAt(U)!==s.charAt(Y))return A=u(this,h),A===e&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),A;Y+=1,U+=1}for(c in p)p.hasOwnProperty(c)&&C.hasOwnProperty(p[c])&&(H=C[p[c]].parse(Z[c]),D={year:H.year!==e?H.year:D.year,month:H.month!==e?H.month:D.month,day:H.day!==e?H.day:D.day,hours:H.hours!==e?H.hours:D.hours,minutes:H.minutes!==e?H.minutes:D.minutes,seconds:H.seconds!==e?H.seconds:D.seconds});this.day(r.MIN_DAY),this.year(D.year),this.month(D.month),this.day(D.day),this.hours(D.hours),this.minutes(D.minutes),this.seconds(D.seconds),this.milliseconds(D.milliseconds)}return this},d.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},d.fn.timestamp=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(r.options("useMilliseconds")?1:1e3)+this._d.getTimezoneOffset()*6e4),this):r.options("useMilliseconds")?this._d.getTime()-this._d.getTimezoneOffset()*6e4:Math.floor(this._d.getTime()/1e3)-this._d.getTimezoneOffset()*60},d.fn.utc=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(r.options("useMilliseconds")?1:1e3)),this):r.options("useMilliseconds")?this._d.getTime():Math.floor(this._d.getTime()/1e3)},d.fn.dayOfWeek=function(t){if(t==="long")return Mt[this._d.getDay()];if(t==="short")return Lt[this._d.getDay()];if(t===e)return this._d.getDay();if(t===0||t==="Sunday")return this.calc({day:-this.dayOfWeek()});if(t===1||t==="Monday")return this.calc({day:(this.dayOfWeek()===0?-6:1)-this.dayOfWeek()});if(t===2||t==="Tuesday")return this.calc({day:(this.dayOfWeek()===0?-5:2)-this.dayOfWeek()});if(t===3||t==="Wednesday")return this.calc({day:(this.dayOfWeek()===0?-4:3)-this.dayOfWeek()});if(t===4||t==="Thursday")return this.calc({day:(this.dayOfWeek()===0?-3:4)-this.dayOfWeek()});if(t===5||t==="Friday")return this.calc({day:(this.dayOfWeek()===0?-2:5)-this.dayOfWeek()});if(t===6||t==="Saturday")return this.calc({day:(this.dayOfWeek()===0?-1:6)-this.dayOfWeek()})},d.fn.timezone=function(t){switch(t){case"hours":return Math.floor(this._d.getTimezoneOffset()/60);case"minutes":return this._d.getTimezoneOffset();default:return this._d.getTimezoneOffset()*60}},d.fn.get=function(t){switch(t){case"Date":return new Date(this.year(),this.month()-(r.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds());case"DateUTC":return new Date(Date.UTC(this.year(),this.month()-(r.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()));case"Array":return[this.year(),this.month(),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()];default:return{year:this.year(),month:this.month(),week:this.week(),day:this.day(),hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds(),utc:this.utc(),dayOfWeek:this.dayOfWeek(),dayOfWeekShort:this.dayOfWeek("short"),dayOfWeekLong:this.dayOfWeek("long"),timestamp:this.timestamp()}}},d.fn.format=function(t){for(var s=0,h="",c;s<t.length;)t.charAt(s)==="%"?(c=t.charAt(s)+t.charAt(s+1),C[c]!==e?(h+=C[c].format(this),s+=1):h+="%"):h+=t.charAt(s),s+=1;return h},d.fn.valid=function(){return this._i.year===!1&&this._i.month===!1&&this._i.day===!1&&this._i.hours===!1&&this._i.minutes===!1&&this._i.seconds===!1&&this._i.milliseconds===!1},d.fn.errors=function(){return this._i},d.fn.between=function(t,s){var h=this.timestamp(),c=t.timestamp();switch(s){case"year":return Math.floor((c-h)/31556952);case"month":return Math.floor((c-h)/2629746);case"day":return Math.floor((c-h)/86400);case"hours":return Math.floor((c-h)/3600);case"minutes":return Math.floor((c-h)/60);case"seconds":return c-h;default:return e}},d.fn.calc=function(t){return t.year!==e&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==e&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==e&&this._d.setDate(this._d.getDate()+t.day),t.hours!==e&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==e&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==e&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==e&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},r=function(t,s,h){return new d(t,s,h)},r.MIN_YEAR=1e3,r.MAX_YEAR=3e3,r.MIN_MONTH=1,r.MAX_MONTH=12,r.MIN_DAY=1,r.MAX_DAY_IN_MONTHS=[31,28,31,30,31,30,31,31,30,31,30,31],r.MIN_DAY_OF_WEEK=0,r.MAX_DAY_OF_WEEK=6,r.MIN_HOURS=0,r.MAX_HOURS=23,r.MIN_MINUTES=0,r.MAX_MINUTES=59,r.MIN_SECONDS=0,r.MAX_SECONDS=59,r.MIN_MILLISECONDS=0,r.MAX_MILLISECONDS=999,r.VERSION="0.2.18",r.options=function(t,s){if(t===e)return Wt;if(Wt.hasOwnProperty(t)){if(s===e)return Wt[t];Wt[t]=s,t==="monthFromZero"&&(r.MIN_MONTH=s?0:1,r.MAX_MONTH=s?11:12)}return e},r.noConflict=function(){return o.tempus=f,r},r.generate=function(t){var s,h,c,p,A,E,Z,Y;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof d?s=t.dateFrom.utc():s=r(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof d?h=t.dateTo.utc():h=r(t.dateTo,t.formatTo!==e?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?A={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?A={year:t.period==="year"?1:0,month:t.period==="month"?1:0,day:t.period==="day"?1:0,hours:t.period==="hours"?1:0,minutes:t.period==="minutes"?1:0,seconds:t.period==="seconds"?1:0}:typeof t.period=="object"&&(A={year:t.period.year!==e?t.period.year:0,month:t.period.month!==e?t.period.month:0,day:t.period.day!==e?t.period.day:0,hours:t.period.hours!==e?t.period.hours:0,minutes:t.period.minutes!==e?t.period.minutes:0,seconds:t.period.seconds!==e?t.period.seconds:0}),t.groupBy===e?E=t.asObject===!0?{}:[]:(E=[],E.push([]),Z=r(s).get()[t.groupBy]),Y=function(F,D,H){return t.asObject===!0?t.format!==e?F[r(D).format(t.format)]={}:F[r(D).format("%F %H:%M:%S")]={}:t.format!==e?F.push(H?null:r(D).format(t.format)):F.push(H?null:r(D)),F},t.groupBy!==e&&t.fillNulls){var U={year:A.year?-A.year:e,month:A.month?-A.month:e,day:A.day?-A.day:e,hours:A.hours?-A.hours:e,minutes:A.minutes?-A.minutes:e,seconds:A.seconds?-A.seconds:e,milliseconds:A.milliseconds?-A.milliseconds:e};for(c=r(s).calc(U).utc();r(c).get()[t.groupBy]===Z;)Y(E[E.length-1],c,!0),c=r(c).calc(U).utc();if(t.groupBy==="week"){var b=r(s).dayOfWeek();for(c=r(s).dayOfWeek(0).utc();E[0].length<b&&c<s;)Y(E[E.length-1],c,!0),c=r(c).calc(A).utc()}}for(;s<=h;)t.groupBy===e?Y(E,s):r(s).get()[t.groupBy]===Z?Y(E[E.length-1],s):(E.push([]),Y(E[E.length-1],s),Z=r(s).get()[t.groupBy]),s=r(s).calc(A).utc();if(t.groupBy!==e&&t.fillNulls)for(p=r(h).calc(A).utc();r(p).get()[t.groupBy]===Z;)Y(E[E.length-1],p,!0),p=r(p).calc(A).utc();return E},r.monthNames=function(t){switch(t){case"long":return k;default:return Jt}},r.dayNames=function(t){switch(t){case"long":return Mt;default:return Lt}},r.lang=function(t){if(t!==e)m=t,N[m]===e&&(m="en"),k=V(),Jt=Rt(),Mt=nt(),Lt=ot();else return m;return e},r.availableLangs=function(){return Object.keys(N)},r.registerFormat=function(t,s,h,c,p,A){C[t]={format:s,parse:h,minLength:c,maxLength:p,type:A}},r.unregisterFormat=function(t){delete C[t]},r.detectFormat=function(t){var s,h,c;return s=y(t,0),s!==""&&(c=10),h=t.charAt(c),(h==="T"||h===" ")&&(s+=h,c+=1),s+=l(t,c),s},R={TempusDate:d},r.classes=function(t,s){if(s===e)return R[t];R[t]=s},r.loadTranslations=function(t){typeof t=="object"?N=t:typeof t=="string"&&ye(t,function(s){N=s},function(s){})},m=(M.language||M.systemLanguage||M.userLanguage||"en").substr(0,2).toLowerCase(),N[m]===e&&(m="en"),k=V(),Jt=Rt(),Mt=nt(),Lt=ot(),w.exports&&(i=w.exports=r),i.tempus=r}).call(S)})(ht,ht.exports);var _e=ht.exports;const bt=L(_e);class X{constructor(i,e={}){_(this,at);_(this,mt);_(this,ft);_(this,Nt);_(this,_t);_(this,Ot);_(this,Ht);_(this,Yt);_(this,yt);_(this,At);_(this,Tt);_(this,ct);_(this,St);_(this,Ut);_(this,st);_(this,lt);_(this,dt);_(this,K,null);_(this,ut,null);_(this,q,[]);_(this,I,{});_(this,j,50);_(this,Q,!0);_(this,v,null);_(this,B,null);_(this,x,null);_(this,Dt,100);_(this,$,"no");_(this,P,!1);_(this,tt,!1);_(this,et,!1);J(this,"errors",{});J(this,"answerData",{});g(this,K,i),g(this,ut,e)}get serial(){return a(this,P)}setSerial(){g(this,P,!0),g(this,tt,!0),g(this,et,!1)}setParallel(){g(this,P,!1),g(this,tt,!1),g(this,et,!0)}stop(){g(this,Q,!1)}async batch(i,e){a(this,x)&&O(this,mt,Vt).call(this),e&&g(this,v,e),a(this,tt)===!1&&g(this,P,!1),Object.keys(i).length>500&&g(this,P,!0),g(this,Q,!0),g(this,q,[]),g(this,I,{}),this.errors={},this.answerData={};const o=O(this,Nt,Kt).call(this,i);if(Object.keys(i).length<500){const n=o.map((u,l)=>O(this,_t,qt).call(this,u,o[l]));return Promise.allSettled(n).then(u=>{let l={};for(let y of u)y.status==="fulfilled"&&(l={...l,...y.value});return l})}else{let n={},u=0,l=1,y=Object.keys(i).length||1,f=r=>{u+=Object.keys(r).length,l=Math.round(u/y*100)};for(let[r,R]of Object.entries(o)){let M=await O(this,_t,qt).call(this,R,o[r],!0);f(R),e&&e({percent:l}),n={...n,...M}}return n}}async batchTotalCount(i,e){g(this,I,{}),this.errors={};let o=1,n=0,u=Object.keys(i).length||1,l=f=>{n+=Object.keys(f).length,o=Math.round(n/u*100)};e&&e({percent:o});const y=O(this,Nt,Kt).call(this,i);if(a(this,et)){const f=y.map(r=>O(this,Ot,Qt).call(this,r).then(R=>(l(r),e&&e({percent:o}),R)));return Promise.allSettled(f).then(r=>{let R={};for(let M of r)M.status==="fulfilled"&&(R={...R,...M.value});return R})}else{let f={};for(let r of y){let R=await O(this,Ot,Qt).call(this,r);l(r),e&&e({percent:o}),f={...f,...R}}return f}}}K=new WeakMap,ut=new WeakMap,q=new WeakMap,I=new WeakMap,j=new WeakMap,Q=new WeakMap,v=new WeakMap,B=new WeakMap,x=new WeakMap,Dt=new WeakMap,$=new WeakMap,P=new WeakMap,tt=new WeakMap,et=new WeakMap,at=new WeakSet,Xt=function(){let i=0;if(!a(this,B))return Math.round(i);let e=0,o=0;return Object.values(a(this,B)).forEach(n=>{const{total:u,count:l}=n;e+=u??0,o+=l??0}),e?i=o/e*100:i=100,{percent:Math.round(i),allCount:o,allTotal:e}},mt=new WeakSet,Vt=function(){clearInterval(a(this,x)),g(this,x,""),g(this,B,""),g(this,v,""),g(this,$,"no")},ft=new WeakSet,Zt=function({key:i,value:e}){const o=O(this,st,pt).call(this,e.data()),n=Array.isArray(o)?o.length:0,u=O(this,lt,kt).call(this,e.total(),n);let l=1;o&&(l=n),a(this,v)&&(a(this,B)||g(this,B,{}),a(this,B)[i]&&a(this,B)[i].count&&(l+=a(this,B)[i].count),a(this,B)[i]={total:u,count:l},a(this,x)||g(this,x,setInterval(()=>{const{percent:y,allCount:f,allTotal:r}=a(this,at,Xt);(a(this,$)==="no"||a(this,$)<a(this,at,Xt).percent)&&(a(this,v).call(this,{data:a(this,B),percent:y,allCount:f,allTotal:r}),g(this,$,a(this,at,Xt).percent)),y===100&&O(this,mt,Vt).call(this)},a(this,Dt))))},Nt=new WeakSet,Kt=function(i){const e=[],o=Object.entries(i);for(let n=0;n<o.length;n+=a(this,j)){const u=o.slice(n,n+a(this,j));e.push(Object.fromEntries(u))}return e},_t=new WeakSet,qt=function(i,e,o){return new Promise(n=>{const u=O(this,St,ee).call(this,e),l=[];let y=0,f=0;a(this,K).call(this,i,r=>{Object.entries(r).forEach(([R,M])=>{let m={};const N=M.error();if(N&&(this.errors[R]=N,y+=1),M!=null&&M.answer&&Object.keys(M.answer).length){for(let[ot,k]of Object.entries(M.answer))ot!="result"&&k&&(m[ot]=k);Object.keys(m).length&&(this.answerData[R]=m)}const V=O(this,st,pt).call(this,M.data()),Rt=Array.isArray(V)?V.length:0,nt=O(this,lt,kt).call(this,M.total(),Rt);if(Array.isArray(V)?a(this,I)[R]=V:a(this,I)[R]=Object.values(V),f+=nt,o||O(this,ft,Zt).call(this,{key:R,value:M}),nt>a(this,j)&&nt>Rt){const ot=Math.ceil(nt/a(this,j))-1,k=Array.from({length:ot});l.push([R,u[R],k])}}),f>5e3&&a(this,tt)===!1&&a(this,et)===!1&&g(this,P,!0),y>0&&O(this,dt,se).call(this),l.length?(O(this,Ht,oe).call(this,l),O(this,Yt,he).call(this).then(()=>n(O(this,ct,jt).call(this)))):n(O(this,ct,jt).call(this))})})},Ot=new WeakSet,Qt=function(i){return new Promise(e=>{const o=O(this,St,ee).call(this,i);let n=0;a(this,K).call(this,o,u=>{Object.entries(u).forEach(([l,y])=>{const f=y.error();f&&(this.errors[l]=f,n+=1);const r=O(this,st,pt).call(this,y.data()),R=Array.isArray(r)?r.length:0,M=O(this,lt,kt).call(this,y.total(),R);a(this,I)[l]=M}),n>0&&O(this,dt,se).call(this),e(O(this,ct,jt).call(this))})})},Ht=new WeakSet,oe=function(i){let e=[];i.forEach(([o,n,u])=>{u.forEach((l,y)=>{const f=y+1,r=a(this,j)*f,M=[[o,f].join("_"),O(this,Ut,ae).call(this,n,r)];e.length===a(this,j)?(a(this,q).push(e),e=[M]):e.push(M)})}),e.length&&a(this,q).push(e)},Yt=new WeakSet,he=function(){const i=[],e=[],o=n=>{Object.entries(n).forEach(([u,l])=>{const[y]=u.split("_"),f=O(this,st,pt).call(this,l.data());Array.isArray(f)&&a(this,I)[y].push(...f),O(this,ft,Zt).call(this,{key:y,value:l})})};return a(this,q).forEach((n,u)=>{const l=Object.fromEntries(n),y=()=>new Promise(f=>a(this,K).call(this,l,r=>{a(this,P)?o(r):e[u]=r,f()}));i.push(y)}),a(this,P)?O(this,At,$t).call(this,i):O(this,Tt,te).call(this,i).then(()=>{e.forEach(o)})},yt=new WeakSet,vt=function(){return new Promise(i=>setTimeout(i,500))},At=new WeakSet,$t=function(i){if(!i.length)return Promise.resolve();const e=i.shift();return Promise.allSettled([e(),O(this,yt,vt).call(this)]).then(()=>a(this,Q)?O(this,At,$t).call(this,i):Promise.resolve())},Tt=new WeakSet,te=function(i){if(!i.length)return Promise.resolve();const e=i.shift();return O(this,yt,vt).call(this).then(()=>e()).then(()=>a(this,Q)?O(this,Tt,te).call(this,i):Promise.resolve())},ct=new WeakSet,jt=function(){return Object.entries(a(this,ut)).forEach(([i,e])=>{a(this,I)[i]&&(a(this,I)[i]=e(a(this,I)[i]))}),a(this,I)},St=new WeakSet,ee=function(i){return Object.entries(i).reduce((e,[o,n])=>{if(Array.isArray(n)){const[u,l={}]=n;e[o]=[u,l]}else{const{method:u,params:l={}}=n;e[o]=[u,l]}return e},{})},Ut=new WeakSet,ae=function(i,e){const[o,n]=i;return[o,{start:e,...n}]},st=new WeakSet,pt=function(i){return((i==null?void 0:i.items)||(i==null?void 0:i.documents))??i},lt=new WeakSet,kt=function(i,e){return i!==i&&(i=0),i===0&&e===0?0:i||e},dt=new WeakSet,se=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([i,e])=>{console.info(`[${i}]`,e.toString())}),console.groupEnd()};class ie{constructor(){_(this,rt,{})}get hash(){return this.createHash(8)}createHash(i){let e="abcdefghijklmnopqrstuvwxyz0123456789",o="";i=i||6;for(let n=0;n<i;n++)o+=e.charAt(Math.floor(Math.random()*e.length));return o}actionFilter({keyTimer:i,duration:e=10,action:o}){a(this,rt)[i]&&(clearTimeout(a(this,rt)[i]),a(this,rt)[i]=null),o&&(a(this,rt)[i]=setTimeout(()=>{o()},e))}}rt=new WeakMap;const xt=new ie;class ne{constructor(){_(this,Bt);_(this,Et);_(this,Gt);_(this,wt);_(this,Ct);_(this,W,"logger");_(this,z,!1);_(this,It,2e3);_(this,it,new Map);_(this,gt,{});J(this,"periodClear",3);O(this,Bt,ce).call(this)}async init(){let i=new X(BX24.callBatch),{entityList:e}=await i.batch({entityList:{method:"entity.get"}});if(e!=null&&e.length)if(e.find(n=>n.ENTITY==a(this,W)))g(this,z,!0);else{let{entityAdd:n}=await i.batch({entityAdd:{method:"entity.add",params:{ENTITY:a(this,W),NAME:a(this,W),ACCESS:{AU:"X"}}}});n&&g(this,z,!0)}return O(this,wt,ue).call(this),a(this,z)}start({type:i,data:e}){if(!a(this,z)){O(this,Et,re).call(this,"entity");return}const o=xt.hash;return a(this,it).set(o,{type:i,data:e,userInfo:a(this,gt),errorList:[],status:"",answer:null,date:new Date().getTime()}),o}stop({key:i,errorList:e,status:o,answer:n}){if(!a(this,z)){O(this,Et,re).call(this,"entity");return}let u=a(this,it).get(i);e&&(u.errorList=e),o&&(u.status=o),n&&(u.answer=n),xt.actionFilter({keyTimer:"add.entity.items",duration:a(this,It),action:()=>{O(this,Gt,le).call(this)}})}async getEntityList(){let i=new X(BX24.callBatch),{entityList:e}=await i.batch({entityList:{method:"entity.item.get",params:{ENTITY:a(this,W)}}});return e=e.map(o=>{const{ID:n,DATE_CREATE:u,DETAIL_TEXT:l}=o;return{...JSON.parse(l),id:n,dateCreate:u}}),e}}W=new WeakMap,z=new WeakMap,It=new WeakMap,it=new WeakMap,gt=new WeakMap,Bt=new WeakSet,ce=async function(){const i=new X(BX24.callBatch),e=BX24.isAdmin(),{curUser:o}=await i.batch({curUser:{method:"user.current"}});g(this,gt,{isAdmin:e,curUser:o})},Et=new WeakSet,re=function(i){i=="entity"&&xt.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},Gt=new WeakSet,le=async function(){let i={},e=new X(BX24.callBatch);for(let[o,n]of a(this,it).entries())n.status&&(i[o]={method:"entity.item.add",params:{ENTITY:a(this,W),NAME:a(this,W),DETAIL_TEXT:JSON.stringify(n)}});if(Object.keys(i).length){let o=await e.batch(i),{errors:n}=e;for(let[u,l]of Object.entries({...o,...n}))a(this,it).delete(u)}},wt=new WeakSet,ue=async function(){let i=new X(BX24.callBatch),e=await this.getEntityList(),{serverTime:o}=await i.batch({serverTime:{method:"server.time"}}),n=e.filter(u=>{let{dateCreate:l}=u;return bt(new Date(l)).between(bt(new Date(o)),"month")>=this.periodClear});O(this,Ct,me).call(this,n)},Ct=new WeakSet,me=async function(i){let e=new X(BX24.callBatch),o=i.map(n=>{let{id:u}=n;return{method:"entity.item.delete",params:{ENTITY:a(this,W),ID:u}}});return await e.batch(o)};const G=new ne;class Oe{constructor(i){_(this,Pt);_(this,Ft);J(this,"domain","");J(this,"isAdmin",!1);J(this,"appInfo",null);J(this,"appConst",null);J(this,"userInfo",null);J(this,"placeData",null);J(this,"placeInfo",null);this.appConst=i}init(){return new Promise(i=>{let e=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(e),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),await G.init();const[o,n]=await Promise.all([O(this,Pt,fe).call(this),O(this,Ft,Ne).call(this)]);this.appInfo=o,this.userInfo=n,i(!0)})},100)})}userOption(i,e){return e?BX24.userOption.set(i,e):BX24.userOption.get(i)}call({method:i,params:e,updateList:o}){let n=G.start({type:"call",data:{method:i,params:e,updateList:o}});return new Promise(u=>{e||(e={}),BX24.callMethod(i,e,function(l){let y={};if(l!=null&&l.answer)for(let[f,r]of Object.entries(l.answer))f!="result"&&r&&(y[f]=r);if(l.error()){let f=l.error();console.error(f),G.stop({answer:y,key:n,status:"fail",errorList:[f.toSting()]}),u(!1)}else{let f=l.data();f!=null&&f.items&&(f=f.items),G.stop({answer:y,key:n,status:"success"}),u(f)}})})}async batch(i,e,{updateList:o}={}){let n=new X(BX24.callBatch),u=G.start({type:"batch",data:{commandList:i,updateList:o}});try{let l=await n.batch(i,e);if(Object.keys(n.errors).length){let y=Object.entries(n.errors).map(([f,r])=>({key:f,error:r.toSting()}));G.stop({key:u,status:"fail",errorList:y,answer:n.answerData})}else G.stop({key:u,status:"success",answer:n.answerData});return l}catch(l){return G.stop({key:u,status:"fail-runtime",errorList:[l.toSting()],answer:n.answerData}),console.error(l),!1}}async batchTotalCount(i,e){let o=new X(BX24.callBatch),n=G.start({type:"batch",data:{commandList:i}});try{let u=await o.batchTotalCount(i,e);if(Object.keys(o.errors).length){let l=Object.entries(o.errors).map(([y,f])=>({key:y,error:f.toSting()}));G.stop({key:n,status:"fail",errorList:l})}else G.stop({key:n,status:"success"});return u}catch(u){return G.stop({key:n,status:"fail",errorList:[u.toSting()]}),console.error(u),!1}}getPlacement(){return this.call({method:"placement.get"}).then(i=>(this.placeData||(this.placeData=i),i))}async placementBind(i){this.placeData||(this.placeData=await this.getPlacement());const{appName:e,pathApp:o}=this.appConst,n=this.placeData.map(l=>l.placement);let u=this.placeData.find(l=>l.placement==i);n.includes(i)?u.handler!=o&&(window.placementUnBind||(window.placementUnBind={}),window.placementUnBind[i]||this.placementUnBind(u).then(()=>{window.placementUnBind[i]||(window.placementUnBind[i]=!0,this.placementBind(i))})):this.call({method:"placement.bind",params:{PLACEMENT:i,HANDLER:o,LANG_ALL:{ru:{TITLE:e}}}}).then(l=>{l?console.info("Приложение успешно встроено в",i):console.warn("Приложение не может быть встроено в",i)})}placementUnBind(i){const{pathApp:e,appName:o}=this.appConst;return this.call({method:"placement.unbind",params:{PLACEMENT:i,HANDLER:e,LANG_ALL:{ru:{TITLE:o}}}}).then(n=>(console.log("Встройка отвязана",i),n))}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(i=>{let e=Object.values(i);return console.log("chat-bot list:",e),e})}regBot({code:i,type:e,name:o}){const{appName:n,pathApp:u,chatBotLogo:l}=this.appConst,y=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:i??this.appInfo.CODE,TYPE:e??"O",EVENT_HANDLER:u,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${o??n} - бот #${y}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:bt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:l??""}}}).then(f=>(console.log("Чат-бот добавлен",f),f))}unRegBot(i){return this.call({method:"imbot.unregister",params:{BOT_ID:i}}).then(e=>(console.log("чат-бот удален",e),e))}}Pt=new WeakSet,fe=function(){return this.call({method:"app.info"})},Ft=new WeakSet,Ne=function(){return this.call({method:"user.current"})},T.Batch=X,T.BxBoot=Oe,T.BxHelper=ie,T.BxLogger=ne,T.tempus=bt,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types/batch.d.ts
CHANGED
|
@@ -20,7 +20,13 @@ declare class Batch{
|
|
|
20
20
|
/**
|
|
21
21
|
* Флаг режима передачи
|
|
22
22
|
*/
|
|
23
|
-
serial: boolean;
|
|
23
|
+
get serial(): boolean;
|
|
24
|
+
|
|
25
|
+
/** Объект ошибок key-value, где key - ключ чанка пакета, value - описание ошибки */
|
|
26
|
+
errors: Record<string, string>;
|
|
27
|
+
|
|
28
|
+
/** Объект служебной информации отработавшего запроса*/
|
|
29
|
+
answerData: Record<string, any>;
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* Установить последовательный режим
|
package/dist/types/bx-boot.d.ts
CHANGED
|
@@ -8,16 +8,26 @@ type TAppConst = {
|
|
|
8
8
|
}
|
|
9
9
|
type UserOptionReturnType<T> = T extends undefined ? string | number : void;
|
|
10
10
|
|
|
11
|
+
type TCommandParams = Record<string, unknown> | {
|
|
12
|
+
select?: string[],
|
|
13
|
+
filter?: Record<string, string | string[]>,
|
|
14
|
+
} | {
|
|
15
|
+
id?: string,
|
|
16
|
+
params?: Record<string, string>,
|
|
17
|
+
fields?: Record<string, unknown>,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type TUpdateList = {
|
|
21
|
+
method: string,
|
|
22
|
+
list: {
|
|
23
|
+
id: string | number,
|
|
24
|
+
fields: { [key: string]: string | number | string[] | number[] }
|
|
25
|
+
}[]
|
|
26
|
+
}[];
|
|
27
|
+
|
|
11
28
|
type TCommand = {
|
|
12
29
|
method: string,
|
|
13
|
-
params:
|
|
14
|
-
select?: string[],
|
|
15
|
-
filter?: Record<string, string | string[]>,
|
|
16
|
-
} | {
|
|
17
|
-
id?: string,
|
|
18
|
-
params?: Record<string, string>,
|
|
19
|
-
fields?: Record<string, unknown>,
|
|
20
|
-
}
|
|
30
|
+
params:TCommandParams,
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
declare class BxBoot{
|
|
@@ -86,16 +96,23 @@ declare class BxBoot{
|
|
|
86
96
|
|
|
87
97
|
|
|
88
98
|
/** Вызывает указанный метод REST-сервиса с указанными параметрам */
|
|
89
|
-
call({ method, params }:
|
|
99
|
+
call({ method, params, updateList}: {
|
|
100
|
+
method: string,
|
|
101
|
+
params: TCommandParams,
|
|
102
|
+
updateList: TUpdateList,
|
|
103
|
+
}): Promise<unknown[] | boolean>;
|
|
90
104
|
|
|
91
105
|
/**
|
|
92
106
|
* Пакетный запрос данных
|
|
93
107
|
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
94
108
|
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
109
|
+
* @param updateList - лист update данных, которые нужно записать в сессию логгера,
|
|
110
|
+
* для возможности отката к старым значениям
|
|
95
111
|
*/
|
|
96
112
|
batch(
|
|
97
113
|
commandList: Record<string, TCommand>,
|
|
98
|
-
progressCall?: (data:{ percent: number })=>void
|
|
114
|
+
progressCall?: (data:{ percent: number })=>void,
|
|
115
|
+
updateList: TUpdateList,
|
|
99
116
|
): Promise<Record<string, unknown[]> | boolean>;
|
|
100
117
|
|
|
101
118
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare class BxHelper{
|
|
2
|
+
/** Уникальная 8-символьная хэш-строка */
|
|
3
|
+
get hash(): string
|
|
4
|
+
|
|
5
|
+
/** Генератор хеш-кода
|
|
6
|
+
* @param length - длина хэш строки
|
|
7
|
+
*/
|
|
8
|
+
createHash(length:number):string
|
|
9
|
+
|
|
10
|
+
/** Фильтр часто запускаемых действий
|
|
11
|
+
* @param keyTimer - уникальный ключ таймера
|
|
12
|
+
* @param duration - время задержки для срабатывания action
|
|
13
|
+
* @param action - действие которое должно отработать
|
|
14
|
+
*/
|
|
15
|
+
actionFilter({ keyTimer, duration=10, action }:{
|
|
16
|
+
keyTimer: string;
|
|
17
|
+
duration: number;
|
|
18
|
+
action: ()=>void;
|
|
19
|
+
}):void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default BxHelper
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare class BxLogger {
|
|
2
|
+
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
3
|
+
periodClear: number;
|
|
4
|
+
|
|
5
|
+
/** Инициализация логгера */
|
|
6
|
+
async init(): Promise<boolean>;
|
|
7
|
+
|
|
8
|
+
/** Старт сессии логгера
|
|
9
|
+
* @param type - тип логирования
|
|
10
|
+
* @param data - данные для сохранения сессии логирования
|
|
11
|
+
* @return - генерирует уникальный ключ сессии логирования в виде строки
|
|
12
|
+
*/
|
|
13
|
+
start({ type, data }:{
|
|
14
|
+
type: 'call'|'batch'|'batch-total-count';
|
|
15
|
+
data: {
|
|
16
|
+
method: string,
|
|
17
|
+
params: { [key]: any }
|
|
18
|
+
}|{ commandList: { [key]: any } };
|
|
19
|
+
}):string;
|
|
20
|
+
|
|
21
|
+
/** Конец сессии логирования
|
|
22
|
+
* @param key - уникальный ключ сессии
|
|
23
|
+
* @param errorList - массив ошибок
|
|
24
|
+
* @param status - статус сессии
|
|
25
|
+
* @param answer - служебная информация
|
|
26
|
+
*/
|
|
27
|
+
stop({ key, errorList, status, answer }:{
|
|
28
|
+
key: string;
|
|
29
|
+
errorList: any[];
|
|
30
|
+
status: 'success'|'fail'|'fail-runtime';
|
|
31
|
+
answer: { [key]: unknown };
|
|
32
|
+
}):void
|
|
33
|
+
|
|
34
|
+
/** Получение списка логирования */
|
|
35
|
+
async getEntityList(): Promise<{[key]: any}[]>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default BxLogger;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import Batch from "./batch";
|
|
2
2
|
import BxBoot from "./bx-boot";
|
|
3
|
+
import BxHelper from "./bx-helper";
|
|
4
|
+
import BxLogger from './bx-logger';
|
|
3
5
|
|
|
4
|
-
declare const tempus = {
|
|
6
|
+
declare const tempus = ()=>{
|
|
7
|
+
format();
|
|
8
|
+
calc();
|
|
9
|
+
lang();
|
|
10
|
+
valid();
|
|
11
|
+
between();
|
|
12
|
+
generate();
|
|
13
|
+
};
|
|
5
14
|
|
|
6
|
-
export { Batch, BxBoot, tempus }
|
|
15
|
+
export { Batch, BxBoot, BxHelper, BxLogger, tempus }
|