szdl-utils-kit 0.2.28 → 0.2.29
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/Readme.md +168 -162
- package/dist/index.js +122 -122
- package/dist/index.umd.cjs +2 -2
- package/dist/types/batch.d.ts +71 -71
- package/dist/types/bx-boot.d.ts +176 -176
- package/dist/types/bx-helper.d.ts +27 -27
- package/dist/types/bx-logger.d.ts +43 -43
- package/dist/types/index.d.ts +14 -14
- package/package.json +41 -41
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Se=Object.defineProperty;var pe=(T,p,b)=>p in T?Se(T,p,{enumerable:!0,configurable:!0,writable:!0,value:b}):T[p]=b;var W=(T,p,b)=>(pe(T,typeof p!="symbol"?p+"":p,b),b),ee=(T,p,b)=>{if(!p.has(T))throw TypeError("Cannot "+b)};var
|
|
2
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):s(JSON.parse(m.responseText))):l&&l(m))},m.open("GET",t,!1),m.send()},G={"%d":{format:function(t){return r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t);return{day:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return r(t.month()||i.MIN_MONTH,2)},parse:function(t){var s=Number(t);return{month:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t);return{year:isNaN(s)?A:s}},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 s=t.dayOfWeek();return x[s!==A?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var s=t.dayOfWeek();return q[s!==A?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return v[s!==A?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames().indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:A}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return L[s!==A?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames(!0).indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:A}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return r(t.hours()||i.MIN_HOURS,2)},parse:function(t){var s=Number(t);return{hours:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return r(t.minutes()||i.MIN_MINUTES,2)},parse:function(t){var s=Number(t);return{minutes:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return r(t.seconds()||i.MIN_SECONDS,2)},parse:function(t){var s=Number(t);return{seconds:isNaN(s)?A:s}},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 r(t.year()||i.MIN_YEAR,4)+"-"+r(t.month()||i.MIN_MONTH,2)+"-"+r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t.slice(0,4)),l=Number(t.slice(5,7)),m=Number(t.slice(8,10));return{year:s,month:l,day:m}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return r(t.month()||i.MIN_MONTH,2)+"/"+r(t.day()||i.MIN_DAY,2)+"/"+r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t.slice(0,2)),l=Number(t.slice(3,5)),m=Number(t.slice(6,10));return{year:m,month:s,day:l}},minLength:10,maxLength:10,type:"string"}},ut={useMilliseconds:!1,monthFromZero:!1},R;R=function(t,s,l){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==A&&this.set(t,s,l),this},R.fn=R.prototype,R.fn.dayCount=function(){var t=this.month(),s=i.MAX_DAY_IN_MONTHS[t-(i.options("monthFromZero")?0:1)];return this.leapYear()&&t===(i.options("monthFromZero")?1:2)&&(s+=1),s},R.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},R.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},R.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},R.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},R.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},R.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},R.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},R.fn.week=function(){var t=new Date(this.year(),0,1),s=i(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((s-t.getTime())/864e5+t.getDay()+1)/7)},R.fn.set=function(t,s,l){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===A)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 m,M=[],E,S,J=[],B=0,C=0,D,Q,Y={},U;if(t===A)return E=a(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;for(s===A&&(s=i.detectFormat(t));B<s.length;){if(s.charAt(B)==="%"){if(S=s.charAt(B)+s.charAt(B+1),G[S]!==A){switch(D=0,Q="",G[S].type){case"number":for(;D<G[S].maxLength&&C+D<t.length&&!isNaN(Number(t.charAt(C+D)));)Q+=t.charAt(C+D),D+=1;break;case"word":for(;D<G[S].maxLength&&C+D<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(C+D));)Q+=t.charAt(C+D),D+=1;break;case"string":for(;D<G[S].maxLength&&C+D<t.length;)Q+=t.charAt(C+D),D+=1;break}if(D<G[S].minLength)return E=a(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;M.push(S),J.push(Q),D-=1,C+=D,B+=1}}else if(t.charAt(C)!==s.charAt(B))return E=a(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;B+=1,C+=1}for(m in M)M.hasOwnProperty(m)&&G.hasOwnProperty(M[m])&&(U=G[M[m]].parse(J[m]),Y={year:U.year!==A?U.year:Y.year,month:U.month!==A?U.month:Y.month,day:U.day!==A?U.day:Y.day,hours:U.hours!==A?U.hours:Y.hours,minutes:U.minutes!==A?U.minutes:Y.minutes,seconds:U.seconds!==A?U.seconds:Y.seconds});this.day(i.MIN_DAY),this.year(Y.year),this.month(Y.month),this.day(Y.day),this.hours(Y.hours),this.minutes(Y.minutes),this.seconds(Y.seconds),this.milliseconds(Y.milliseconds)}return this},R.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},R.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},R.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)},R.fn.dayOfWeek=function(t){if(t==="long")return q[this._d.getDay()];if(t==="short")return x[this._d.getDay()];if(t===A)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()})},R.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}},R.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()}}},R.fn.format=function(t){for(var s=0,l="",m;s<t.length;)t.charAt(s)==="%"?(m=t.charAt(s)+t.charAt(s+1),G[m]!==A?(l+=G[m].format(this),s+=1):l+="%"):l+=t.charAt(s),s+=1;return l},R.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},R.fn.errors=function(){return this._i},R.fn.between=function(t,s){var l=this.timestamp(),m=t.timestamp();switch(s){case"year":return Math.floor((m-l)/31556952);case"month":return Math.floor((m-l)/2629746);case"day":return Math.floor((m-l)/86400);case"hours":return Math.floor((m-l)/3600);case"minutes":return Math.floor((m-l)/60);case"seconds":return m-l;default:return A}},R.fn.calc=function(t){return t.year!==A&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==A&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==A&&this._d.setDate(this._d.getDate()+t.day),t.hours!==A&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==A&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==A&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==A&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},i=function(t,s,l){return new R(t,s,l)},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,s){if(t===A)return ut;if(ut.hasOwnProperty(t)){if(s===A)return ut[t];ut[t]=s,t==="monthFromZero"&&(i.MIN_MONTH=s?0:1,i.MAX_MONTH=s?11:12)}return A},i.noConflict=function(){return n.tempus=c,i},i.generate=function(t){var s,l,m,M,E,S,J,B;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof R?s=t.dateFrom.utc():s=i(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof R?l=t.dateTo.utc():l=i(t.dateTo,t.formatTo!==A?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?E={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?E={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"&&(E={year:t.period.year!==A?t.period.year:0,month:t.period.month!==A?t.period.month:0,day:t.period.day!==A?t.period.day:0,hours:t.period.hours!==A?t.period.hours:0,minutes:t.period.minutes!==A?t.period.minutes:0,seconds:t.period.seconds!==A?t.period.seconds:0}),t.groupBy===A?S=t.asObject===!0?{}:[]:(S=[],S.push([]),J=i(s).get()[t.groupBy]),B=function(Q,Y,U){return t.asObject===!0?t.format!==A?Q[i(Y).format(t.format)]={}:Q[i(Y).format("%F %H:%M:%S")]={}:t.format!==A?Q.push(U?null:i(Y).format(t.format)):Q.push(U?null:i(Y)),Q},t.groupBy!==A&&t.fillNulls){var C={year:E.year?-E.year:A,month:E.month?-E.month:A,day:E.day?-E.day:A,hours:E.hours?-E.hours:A,minutes:E.minutes?-E.minutes:A,seconds:E.seconds?-E.seconds:A,milliseconds:E.milliseconds?-E.milliseconds:A};for(m=i(s).calc(C).utc();i(m).get()[t.groupBy]===J;)B(S[S.length-1],m,!0),m=i(m).calc(C).utc();if(t.groupBy==="week"){var D=i(s).dayOfWeek();for(m=i(s).dayOfWeek(0).utc();S[0].length<D&&m<s;)B(S[S.length-1],m,!0),m=i(m).calc(E).utc()}}for(;s<=l;)t.groupBy===A?B(S,s):i(s).get()[t.groupBy]===J?B(S[S.length-1],s):(S.push([]),B(S[S.length-1],s),J=i(s).get()[t.groupBy]),s=i(s).calc(E).utc();if(t.groupBy!==A&&t.fillNulls)for(M=i(l).calc(E).utc();i(M).get()[t.groupBy]===J;)B(S[S.length-1],M,!0),M=i(M).calc(E).utc();return S},i.monthNames=function(t){switch(t){case"long":return L;default:return v}},i.dayNames=function(t){switch(t){case"long":return q;default:return x}},i.lang=function(t){if(t!==A)u=t,N[u]===A&&(u="en"),L=I(),v=X(),q=P(),x=H();else return u;return A},i.availableLangs=function(){return Object.keys(N)},i.registerFormat=function(t,s,l,m,M,E){G[t]={format:s,parse:l,minLength:m,maxLength:M,type:E}},i.unregisterFormat=function(t){delete G[t]},i.detectFormat=function(t){var s,l,m;return s=f(t,0),s!==""&&(m=10),l=t.charAt(m),(l==="T"||l===" ")&&(s+=l,m+=1),s+=o(t,m),s},d={TempusDate:R},i.classes=function(t,s){if(s===A)return d[t];d[t]=s},i.loadTranslations=function(t){typeof t=="object"?N=t:typeof t=="string"&&mt(t,function(s){N=s},function(s){})},u=(y.language||y.systemLanguage||y.userLanguage||"en").substr(0,2).toLowerCase(),N[u]===A&&(u="en"),L=I(),v=X(),q=P(),x=H(),j.exports&&(e=j.exports=i),e.tempus=i}).call(p)})(ft,ft.exports);var Te=ft.exports;const Tt=b(Te);class Z{constructor(e,A={}){O(this,Nt);O(this,Ot);O(this,St);O(this,_t);O(this,pt);O(this,Mt);O(this,Lt);O(this,Ct);O(this,kt);O(this,bt);O(this,Dt);O(this,Ht);O(this,yt);O(this,Yt);O(this,Ft);O(this,ht);O(this,dt);O(this,gt);O(this,Pt);O(this,tt,null);O(this,Rt,null);O(this,et,[]);O(this,w,{});O(this,V,50);O(this,z,50);O(this,At,!0);O(this,st,null);O(this,k,null);O(this,$,null);O(this,Gt,100);O(this,ot,"no");O(this,F,!1);O(this,it,!1);O(this,at,!1);W(this,"errors",{});W(this,"answerData",{});W(this,"timeLimit",!1);g(this,tt,e),g(this,Rt,A)}get serial(){return h(this,F)}get limitCommandSerial(){return h(this,z)}set limitCommandSerial(e){if(e<10)throw new Error("limitCommandSerial не может быть меньше 10");e>=10&&e<50&&(g(this,V,e),g(this,z,e)),g(this,z,e)}setSerial(){g(this,F,!0),g(this,it,!0),g(this,at,!1)}setParallel(){g(this,F,!1),g(this,it,!1),g(this,at,!0)}stop(){g(this,At,!1)}async batch(e,A){h(this,$)&&_(this,Ot,zt).call(this),A&&g(this,st,A),h(this,it)===!1&&g(this,F,!1),Object.keys(e).length>h(this,z)&&g(this,F,!0),g(this,At,!0),g(this,et,[]),g(this,w,{}),this.errors={},this.answerData={};const n=_(this,_t,Kt).call(this,e);if(Object.keys(e).length<h(this,z)){const r=n.map((a,o)=>_(this,pt,se).call(this,a,n[o]));return Promise.allSettled(r).then(a=>{let o={};for(let f of a)f.status==="fulfilled"&&(o={...o,...f.value});return o})}else{let r={},a=0,o=1,f=Object.keys(e).length||1,c=i=>{a+=Object.keys(i).length,o=Math.round(a/f*100)};for(let[i,d]of Object.entries(n)){let y=await _(this,pt,se).call(this,d,n[i],!0);c(d),A&&A({percent:o}),r={...r,...y}}return r}}async batchUpdateField(e,A){h(this,$)&&_(this,Ot,zt).call(this),A&&g(this,st,A),h(this,it)===!1&&g(this,F,!1),Object.keys(e).length>h(this,z)&&g(this,F,!0),g(this,At,!0),g(this,et,[]),g(this,w,{}),this.errors={},this.answerData={};const n=_(this,_t,Kt).call(this,e);if(Object.keys(e).length<h(this,z)){let r={};for(let[a,o]of Object.entries(n)){let f=await _(this,Mt,ie).call(this,o,n[a]);r={...r,...f}}return r}else{let r={},a=0,o=1,f=Object.keys(e).length||1,c=i=>{a+=Object.keys(i).length,o=Math.round(a/f*100)};for(let[i,d]of Object.entries(n)){let y=await _(this,Mt,ie).call(this,d,n[i],!0);c(d),A&&A({percent:o}),r={...r,...y},this.timeLimit&&(console.log("Был достигнут лимит operating time - сделана остановка на 2 минуты, timeLimit = ",this.timeLimit),await new Promise(u=>setTimeout(u,12e4)),this.timeLimit=!1,console.log("Остановка в 2 минуты по лимиту operating time закончена, timeLimit = ",this.timeLimit))}return r}}async batchTotalCount(e,A){g(this,w,{}),this.errors={};let n=1,r=0,a=Object.keys(e).length||1,o=c=>{r+=Object.keys(c).length,n=Math.round(r/a*100)};A&&A({percent:n});const f=_(this,_t,Kt).call(this,e);if(h(this,at)){const c=f.map(i=>_(this,Lt,re).call(this,i).then(d=>(o(i),A&&A({percent:n}),d)));return Promise.allSettled(c).then(i=>{let d={};for(let y of i)y.status==="fulfilled"&&(d={...d,...y.value});return d})}else{let c={};for(let i of f){let d=await _(this,Lt,re).call(this,i);o(i),A&&A({percent:n}),c={...c,...d}}return c}}}tt=new WeakMap,Rt=new WeakMap,et=new WeakMap,w=new WeakMap,V=new WeakMap,z=new WeakMap,At=new WeakMap,st=new WeakMap,k=new WeakMap,$=new WeakMap,Gt=new WeakMap,ot=new WeakMap,F=new WeakMap,it=new WeakMap,at=new WeakMap,Nt=new WeakSet,Vt=function(){let e=0;if(!h(this,k))return Math.round(e);let A=0,n=0;return Object.values(h(this,k)).forEach(r=>{const{total:a,count:o}=r;A+=a??0,n+=o??0}),A?e=n/A*100:e=100,{percent:Math.round(e),allCount:n,allTotal:A}},Ot=new WeakSet,zt=function(){clearInterval(h(this,$)),g(this,$,""),g(this,k,""),g(this,st,""),g(this,ot,"no")},St=new WeakSet,Ae=function({key:e,value:A}){const n=_(this,ht,Ut).call(this,A.data()),r=Array.isArray(n)?n.length:0,a=_(this,dt,qt).call(this,A.total(),r);let o=1;n&&(o=r),h(this,st)&&(h(this,k)||g(this,k,{}),h(this,k)[e]&&h(this,k)[e].count&&(o+=h(this,k)[e].count),h(this,k)[e]={total:a,count:o},h(this,$)||g(this,$,setInterval(()=>{const{percent:f,allCount:c,allTotal:i}=h(this,Nt,Vt);(h(this,ot)==="no"||h(this,ot)<h(this,Nt,Vt).percent)&&(h(this,st).call(this,{data:h(this,k),percent:f,allCount:c,allTotal:i}),g(this,ot,h(this,Nt,Vt).percent)),f===100&&_(this,Ot,zt).call(this)},h(this,Gt))))},_t=new WeakSet,Kt=function(e){const A=[],n=Object.entries(e);for(let r=0;r<n.length;r+=h(this,V)){const a=n.slice(r,r+h(this,V));A.push(Object.fromEntries(a))}return A},pt=new WeakSet,se=function(e,A,n){return new Promise(r=>{const a=_(this,Yt,he).call(this,A),o=[];let f=0,c=0;h(this,tt).call(this,e,i=>{Object.entries(i).forEach(([d,y])=>{let u={};const N=y.error();if(N){let{query:{method:H},answer:L}=y;this.errors[d]={error:N,method:H},f+=1}if(y!=null&&y.answer&&Object.keys(y.answer).length){for(let[H,L]of Object.entries(y.answer))H!="result"&&L&&(u[H]=L);Object.keys(u).length&&(this.answerData[d]=u)}const I=_(this,ht,Ut).call(this,y.data()),X=Array.isArray(I)?I.length:0,P=_(this,dt,qt).call(this,y.total(),X);if(Array.isArray(I)?h(this,w)[d]=I:typeof I=="object"&&I!==null&&Object.keys(I).length===0?h(this,w)[d]=[]:h(this,w)[d]=I,c+=P,n||_(this,St,Ae).call(this,{key:d,value:y}),P>h(this,V)&&P>X){const H=Math.ceil(P/h(this,V))-1,L=Array.from({length:H});o.push([d,a[d],L])}}),c>5e3&&h(this,it)===!1&&h(this,at)===!1&&g(this,F,!0),f>0&&_(this,gt,$t).call(this),o.length?(_(this,Ct,me).call(this,o),_(this,kt,ue).call(this).then(()=>r(_(this,yt,vt).call(this)))):r(_(this,yt,vt).call(this))})})},Mt=new WeakSet,ie=function(e,A,n){let r=_(this,Pt,Ne).call(this,e);return new Promise(a=>{let o=0;h(this,tt).call(this,"batch",r,f=>{var y,u,N,I,X,P;let c=((u=(y=f==null?void 0:f.answer)==null?void 0:y.result)==null?void 0:u.result)??null,i=((I=(N=f==null?void 0:f.answer)==null?void 0:N.result)==null?void 0:I.result_error)??null,d=((P=(X=f==null?void 0:f.answer)==null?void 0:X.result)==null?void 0:P.result_time)??null;(c||Object.keys(c).length)&&Object.entries(c).forEach(([H,L])=>{this.answerData[H]=L}),(i||Object.keys(i).length)&&Object.entries(i).forEach(([H,L])=>{var x,mt;let v=((x=e[H])==null?void 0:x.method)??null,q=((mt=e[H])==null?void 0:mt.params)??null;this.errors[H]={error:L,method:v,params:q},o+=1}),(d||Object.keys(d).length)&&Object.entries(d).forEach(([H,L])=>{((L==null?void 0:L.operating)??0)>=475&&(this.timeLimit=!0)}),o>0&&_(this,gt,$t).call(this),a(this.answerData)})})},Lt=new WeakSet,re=function(e){return new Promise(A=>{const n=_(this,Yt,he).call(this,e);let r=0;h(this,tt).call(this,n,a=>{Object.entries(a).forEach(([o,f])=>{const c=f.error();c&&(this.errors[o]=c,r+=1);const i=_(this,ht,Ut).call(this,f.data()),d=Array.isArray(i)?i.length:0,y=_(this,dt,qt).call(this,f.total(),d);h(this,w)[o]=y}),r>0&&_(this,gt,$t).call(this),A(_(this,yt,vt).call(this))})})},Ct=new WeakSet,me=function(e){let A=[];e.forEach(([n,r,a])=>{a.forEach((o,f)=>{const c=f+1,i=h(this,V)*c,y=[[n,c].join("_"),_(this,Ft,fe).call(this,r,i)];A.length===h(this,V)?(h(this,et).push(A),A=[y]):A.push(y)})}),A.length&&h(this,et).push(A)},kt=new WeakSet,ue=function(){const e=[],A=[],n=r=>{Object.entries(r).forEach(([a,o])=>{const[f]=a.split("_"),c=_(this,ht,Ut).call(this,o.data());Array.isArray(c)&&h(this,w)[f].push(...c),_(this,St,Ae).call(this,{key:f,value:o})})};return h(this,et).forEach((r,a)=>{const o=Object.fromEntries(r),f=()=>new Promise(c=>h(this,tt).call(this,o,i=>{h(this,F)?n(i):A[a]=i,c()}));e.push(f)}),h(this,F)?_(this,Dt,oe).call(this,e):_(this,Ht,ae).call(this,e).then(()=>{A.forEach(n)})},bt=new WeakSet,ne=function(){return new Promise(e=>setTimeout(e,500))},Dt=new WeakSet,oe=function(e){if(!e.length)return Promise.resolve();const A=e.shift();return Promise.allSettled([A(),_(this,bt,ne).call(this)]).then(()=>h(this,At)?_(this,Dt,oe).call(this,e):Promise.resolve())},Ht=new WeakSet,ae=function(e){if(!e.length)return Promise.resolve();const A=e.shift();return _(this,bt,ne).call(this).then(()=>A()).then(()=>h(this,At)?_(this,Ht,ae).call(this,e):Promise.resolve())},yt=new WeakSet,vt=function(){return Object.entries(h(this,Rt)).forEach(([e,A])=>{h(this,w)[e]&&(h(this,w)[e]=A(h(this,w)[e]))}),h(this,w)},Yt=new WeakSet,he=function(e){return Object.entries(e).reduce((A,[n,r])=>{if(Array.isArray(r)){const[a,o={}]=r;A[n]=[a,o]}else{const{method:a,params:o={}}=r;A[n]=[a,o]}return A},{})},Ft=new WeakSet,fe=function(e,A){const[n,r]=e;return[n,{start:A,...r}]},ht=new WeakSet,Ut=function(e){return((e==null?void 0:e.items)||(e==null?void 0:e.documents)||(e==null?void 0:e.tasks))??e},dt=new WeakSet,qt=function(e,A){return e!==e&&(e=0),e===0&&A===0?0:e||A},gt=new WeakSet,$t=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([e,A])=>{console.info(`[${e}]`,A)}),console.groupEnd()},Pt=new WeakSet,Ne=function(e){var n,r,a,o,f,c,i,d,y,u,N,I,X,P,H,L,v,q,x,mt,G,ut,R,t;let A={halt:0,cmd:{}};for(let s in e){const l=s;let m=(n=e[s])!=null&&n.method?(r=e[s])==null?void 0:r.method:"",M="",E="",S="";const J=(o=(a=e[s])==null?void 0:a.params)==null?void 0:o.fields;if((c=(f=e[s])==null?void 0:f.params)!=null&&c.entityTypeId?(M=`?entityTypeId=${parseInt((d=(i=e[s])==null?void 0:i.params)==null?void 0:d.entityTypeId)}`,(u=(y=e[s])==null?void 0:y.params)!=null&&u.id&&(E=`&id=${(I=(N=e[s])==null?void 0:N.params)==null?void 0:I.id}`),(P=(X=e[s])==null?void 0:X.params)!=null&&P.ID&&(E=`&ID=${(L=(H=e[s])==null?void 0:H.params)==null?void 0:L.ID}`)):((q=(v=e[s])==null?void 0:v.params)!=null&&q.id&&(E=`?id=${(mt=(x=e[s])==null?void 0:x.params)==null?void 0:mt.id}`),(ut=(G=e[s])==null?void 0:G.params)!=null&&ut.ID&&(E=`?ID=${(t=(R=e[s])==null?void 0:R.params)==null?void 0:t.ID}`)),Object.keys(J).length>0)for(let B in J)S+=`&fields[${B}]=${J[B]}`;A.cmd[l]=`${m}${M}${E}${S}`.trim()}return A};class te{constructor(){O(this,lt,{})}get hash(){return this.createHash(8)}createHash(e){let A="abcdefghijklmnopqrstuvwxyz0123456789",n="";e=e||6;for(let r=0;r<e;r++)n+=A.charAt(Math.floor(Math.random()*A.length));return n}actionFilter({keyTimer:e,duration:A=10,action:n}){h(this,lt)[e]&&(clearTimeout(h(this,lt)[e]),h(this,lt)[e]=null),n&&(h(this,lt)[e]=setTimeout(()=>{n()},A))}async noSleep(){let e=document.createElement("video");e.classList.add("no-sleep"),e.addEventListener("loadeddata",()=>{e.style.position="fixed",e.style.left="-9999px",document.querySelector("body").append(e),e.play()}),e.addEventListener("ended",()=>{this.actionFilter({keyTimer:"no-sleep",duration:5e3,action:()=>e.play()})}),e.src="data:video/mp4;base64,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"}downloadFileJson(e,A){let n=new Blob([JSON.stringify(e)],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.style.display="none",a.href=r,a.download=`${A}.json`,document.body.appendChild(a),a.click(),setTimeout(()=>{document.body.removeChild(a),URL.revokeObjectURL(r)},200)}}lt=new WeakMap;const wt=new te;class ce{constructor(){O(this,jt);O(this,It);O(this,Jt);O(this,Xt);O(this,xt);O(this,K,"logger");O(this,rt,!1);O(this,Wt,2e3);O(this,ct,new Map);O(this,Bt,{});O(this,nt,null);O(this,Et,!1);W(this,"periodClear",3);_(this,jt,Oe).call(this)}async init(){let e=new Z(BX24.callBatch),{entityList:A}=await e.batch({entityList:{method:"entity.get"}});if(A&&Array.isArray(A))if(A.find(r=>r.ENTITY==h(this,K)))g(this,rt,!0);else{let{entityAdd:r}=await e.batch({entityAdd:{method:"entity.add",params:{ENTITY:h(this,K),NAME:h(this,K),ACCESS:{AU:"X"}}}});r&&g(this,rt,!0)}return _(this,Xt,ye).call(this),h(this,rt)}start({type:e,data:A}){if(!h(this,rt)){_(this,It,le).call(this,"entity");return}const n=wt.hash;return h(this,ct).set(n,{type:e,data:A,userInfo:h(this,Bt),errorList:[],status:"",answer:null,date:new Date().getTime()}),n}stop({key:e,errorList:A,status:n,answer:r}){if(!h(this,rt)){_(this,It,le).call(this,"entity");return}let a=h(this,ct).get(e);A&&(a.errorList=A),n&&(a.status=n),r&&(a.answer=r),wt.actionFilter({keyTimer:"add.entity.items",duration:h(this,Wt),action:async()=>{var o;await _(this,Jt,_e).call(this),(o=a==null?void 0:a.data)!=null&&o.updateList&&g(this,Et,!0)}})}async getEntityList(e){var r;if((r=h(this,nt))!=null&&r.length&&!h(this,Et))return h(this,nt);let A=new Z(BX24.callBatch),{entityList:n}=await A.batch({entityList:{method:"entity.item.get",params:{ENTITY:h(this,K),SORT:{ID:"DESC"}}}},e);return n=n.map(a=>{const{ID:o,DATE_CREATE:f,DETAIL_TEXT:c}=a;return{...JSON.parse(c),id:o,dateCreate:f}}),g(this,Et,!1),n}async downAllEntityJson(){let e=await this.getEntityList(),A=Tt().format("%Y-%m-%d");wt.downloadFileJson(e,`sdklogger-entity-data__${A}`)}}K=new WeakMap,rt=new WeakMap,Wt=new WeakMap,ct=new WeakMap,Bt=new WeakMap,nt=new WeakMap,Et=new WeakMap,jt=new WeakSet,Oe=async function(){const e=new Z(BX24.callBatch),A=BX24.isAdmin(),{curUser:n}=await e.batch({curUser:{method:"user.current"}});g(this,Bt,{isAdmin:A,curUser:n})},It=new WeakSet,le=function(e){e=="entity"&&wt.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},Jt=new WeakSet,_e=async function(){let e={},A=new Z(BX24.callBatch);for(let[n,r]of h(this,ct).entries())r.status&&(e[n]={method:"entity.item.add",params:{ENTITY:h(this,K),NAME:h(this,K),DETAIL_TEXT:JSON.stringify(r)}});if(Object.keys(e).length){let n=await A.batch(e),{errors:r}=A;for(let[a,o]of Object.entries({...n,...r}))h(this,ct).delete(a);return!0}},Xt=new WeakSet,ye=async function(){let e=new Z(BX24.callBatch),{serverTime:A}=await e.batch({serverTime:{method:"server.time"}});h(this,nt)||g(this,nt,await this.getEntityList());let n=h(this,nt).filter(r=>{let{dateCreate:a}=r;return Tt(new Date(a)).between(Tt(new Date(A)),"month")>=this.periodClear});_(this,xt,de).call(this,n)},xt=new WeakSet,de=async function(e){let A=new Z(BX24.callBatch),n=e.map(r=>{let{id:a}=r;return{method:"entity.item.delete",params:{ENTITY:h(this,K),ID:a}}});return await A.batch(n)};class Re{constructor(e){O(this,Qt);O(this,Zt);W(this,"domain","");W(this,"isAdmin",!1);W(this,"appInfo",null);W(this,"appConst",null);W(this,"userInfo",null);W(this,"placeData",null);W(this,"placeInfo",null);W(this,"logger",new ce);this.appConst=e}init(){return new Promise(e=>{let A=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(A),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),await this.logger.init();const[n,r]=await Promise.all([_(this,Qt,ge).call(this),_(this,Zt,Ee).call(this)]);this.appInfo=n,this.userInfo=r,new te().noSleep(),e(!0)})},100)})}userOption(e,A){return A?BX24.userOption.set(e,A):BX24.userOption.get(e)}call({method:e,params:A,updateList:n}){let r=this.logger.start({type:"call",data:{method:e,params:A,updateList:n}});return new Promise(a=>{A||(A={}),BX24.callMethod(e,A,o=>{let f={};if(o!=null&&o.answer)for(let[c,i]of Object.entries(o.answer))c!="result"&&i&&(f[c]=i);if(o.error()){let c=o.error();console.error(c),this.logger.stop({answer:f,key:r,status:"fail",errorList:[c.toString()]}),a(!1)}else{let c=o.data();c!=null&&c.items&&(c=c.items),this.logger.stop({answer:f,key:r,status:"success"}),a(c)}})})}async batch(e,A,{updateList:n,errorCall:r,limitCommandSerial:a}={}){let o=new Z(BX24.callBatch),f=this.logger.start({type:"batch",data:{commandList:e,updateList:n}});a&&(o.limitCommandSerial=a);try{let c=await o.batch(e,A);if(Object.keys(o.errors).length){let i=Object.entries(o.errors).map(([d,y])=>{var u;return{key:d,error:`${y==null?void 0:y.method} ${(u=y==null?void 0:y.error)==null?void 0:u.toString()}`.trim()}});r&&r(o.errors),this.logger.stop({key:f,status:"fail",errorList:i,answer:o.answerData})}else this.logger.stop({key:f,status:"success",answer:o.answerData});return c}catch(c){let i=c==null?void 0:c.toString();return this.logger.stop({key:f,status:"fail-runtime",errorList:[i],answer:o.answerData}),console.error(c),!1}}async batchUpdateField(e,A,{updateList:n,errorCall:r,limitCommandSerial:a}={}){let o=new Z(BX24.callMethod),f=this.logger.start({type:"callMethod-batch",data:{commandList:e,updateList:n}});a&&(o.limitCommandSerial=a);try{let c=await o.batchUpdateField(e,A);if(Object.keys(o.errors).length){let i=Object.entries(o.errors).map(([d,y])=>{var u;return{key:d,error:`${y==null?void 0:y.method} ${(u=y==null?void 0:y.error)==null?void 0:u.toString()}`.trim()}});r&&r(o.errors),this.logger.stop({key:f,status:"fail",errorList:i,answer:o.answerData})}else this.logger.stop({key:f,status:"success",answer:o.answerData});return c}catch(c){let i=c==null?void 0:c.toString();return this.logger.stop({key:f,status:"fail-runtime",errorList:[i],answer:o.answerData}),console.error(c),!1}}async batchTotalCount(e,A){let n=new Z(BX24.callBatch),r=this.logger.start({type:"batch",data:{commandList:e}});try{let a=await n.batchTotalCount(e,A);if(Object.keys(n.errors).length){let o=Object.entries(n.errors).map(([f,c])=>({key:f,error:c.toString()}));this.logger.stop({key:r,status:"fail",errorList:o})}else this.logger.stop({key:r,status:"success"});return a}catch(a){return this.logger.stop({key:r,status:"fail",errorList:[a.toString()]}),console.error(a),!1}}getPlacement(){return this.call({method:"placement.get"}).then(e=>(this.placeData||(this.placeData=e),e))}async placementBind(e){this.placeData||(this.placeData=await this.getPlacement());const{appName:A,pathApp:n}=this.appConst,r=this.placeData.map(o=>o.placement);let a=this.placeData.find(o=>o.placement==e);r.includes(e)?a.handler!=n&&(window.placementUnBind||(window.placementUnBind={}),window.placementUnBind[e]||this.placementUnBind(a).then(()=>{window.placementUnBind[e]||(window.placementUnBind[e]=!0,this.placementBind(e))})):this.call({method:"placement.bind",params:{PLACEMENT:e,HANDLER:n,LANG_ALL:{ru:{TITLE:A}}}}).then(o=>{o?console.info("Приложение успешно встроено в",e):console.warn("Приложение не может быть встроено в",e)})}placementUnBind(e){const{pathApp:A,appName:n}=this.appConst;return this.call({method:"placement.unbind",params:{PLACEMENT:e,HANDLER:A,LANG_ALL:{ru:{TITLE:n}}}}).then(r=>(console.log("Встройка отвязана",e),r))}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(e=>{let A=Object.values(e);return console.log("chat-bot list:",A),A})}regBot({code:e,type:A,name:n}){const{appName:r,pathApp:a,chatBotLogo:o}=this.appConst,f=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:e??this.appInfo.CODE,TYPE:A??"O",EVENT_HANDLER:a,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${n??r} - бот #${f}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:Tt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:o??""}}}).then(c=>(console.log("Чат-бот добавлен",c),c))}unRegBot(e){return this.call({method:"imbot.unregister",params:{BOT_ID:e}}).then(A=>(console.log("чат-бот удален",A),A))}getLoggerList(e){return this.logger.getEntityList(e)}}Qt=new WeakSet,ge=function(){return this.call({method:"app.info"})},Zt=new WeakSet,Ee=function(){return this.call({method:"user.current"})},T.Batch=Z,T.BxBoot=Re,T.BxHelper=te,T.BxLogger=ce,T.tempus=Tt,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
var Se=Object.defineProperty;var pe=(T,p,b)=>p in T?Se(T,p,{enumerable:!0,configurable:!0,writable:!0,value:b}):T[p]=b;var W=(T,p,b)=>(pe(T,typeof p!="symbol"?p+"":p,b),b),ee=(T,p,b)=>{if(!p.has(T))throw TypeError("Cannot "+b)};var a=(T,p,b)=>(ee(T,p,"read from private field"),b?b.call(T):p.get(T)),O=(T,p,b)=>{if(p.has(T))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(T):p.set(T,b)},g=(T,p,b,ft)=>(ee(T,p,"write to private field"),ft?ft.call(T,b):p.set(T,b),b);var _=(T,p,b)=>(ee(T,p,"access private method"),b);(function(T,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(T=typeof globalThis<"u"?globalThis:T||self,p(T["szdl-utils-kit"]={}))})(this,function(T){var tt,Rt,et,w,V,z,At,st,k,$,Gt,ot,F,it,at,Nt,Vt,Ot,zt,St,Ae,_t,Kt,pt,se,Mt,ie,Lt,re,Ct,me,kt,ue,bt,ne,Dt,oe,Ht,ae,yt,vt,Yt,he,Ft,fe,ht,Ut,dt,qt,gt,$t,Pt,Ne,lt,K,rt,Wt,ct,Bt,nt,Et,jt,Oe,It,le,Jt,_e,Xt,ye,xt,de,Qt,ge,Zt,Ee;"use strict";var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function b(j){return j&&j.__esModule&&Object.prototype.hasOwnProperty.call(j,"default")?j.default:j}var ft={exports:{}};(function(j,e){(function(A){Array.prototype.indexOf||(Array.prototype.indexOf=function(t,s){var l,m;for(l=s||0,m=this.length;l<m;l+=1)if(this[l]===t)return l;return-1});var n=this,r=function(t,s){for(var l=t.toString();l.length<s;)l="0"+l;return l},h=function(t,s){return s!==A?(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):A},o=function(t,s){var l,m="";return l=t.slice(s,s+1),l!==""&&!isNaN(Number(l))&&(m+="%H"),l=t.charAt(s+2),l!==""&&l===":"&&(m+=l),l=t.slice(s+3,s+4),l!==""&&!isNaN(Number(l))&&(m+="%M"),l=t.charAt(s+5),l!==""&&l===":"&&(m+=l),l=t.slice(s+6,s+7),l!==""&&!isNaN(Number(l))&&(m+="%S"),m},f=function(t,s){var l,m=[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)],M;return!isNaN(Number(m[0]))&&!isNaN(Number(m[2]))&&!isNaN(Number(m[4]))?(m[1]==="."&&m[3]==="."?l="%d.%m.%Y":m[1]==="-"&&m[3]==="-"?l="%m-%d-%Y":m[1]==="/"&&m[3]==="/"&&(l="%m/%d/%Y"),l):(M=[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(M[0]))&&!isNaN(Number(M[2]))&&!isNaN(Number(M[4]))?(M[1]==="-"&&M[3]==="-"&&(l="%Y-%m-%d"),l):"")},c=n.tempus,i,d,y=n.navigator||{},u="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"}},I=function(){return[N[u].JANUARY_LONG,N[u].FEBRUARY_LONG,N[u].MARCH_LONG,N[u].APRIL_LONG,N[u].MAY_LONG,N[u].JUNE_LONG,N[u].JULY_LONG,N[u].AUGUST_LONG,N[u].SEPTEMBER_LONG,N[u].OCTOBER_LONG,N[u].NOVEMBER_LONG,N[u].DECEMBER_LONG]},X=function(){return[N[u].JANUARY_SHORT,N[u].FEBRUARY_SHORT,N[u].MARCH_SHORT,N[u].APRIL_SHORT,N[u].MAY_SHORT,N[u].JUNE_SHORT,N[u].JULY_SHORT,N[u].AUGUST_SHORT,N[u].SEPTEMBER_SHORT,N[u].OCTOBER_SHORT,N[u].NOVEMBER_SHORT,N[u].DECEMBER_SHORT]},P=function(){return[N[u].SUNDAY_LONG,N[u].MONDAY_LONG,N[u].TUESDAY_LONG,N[u].WEDNESDAY_LONG,N[u].THURSDAY_LONG,N[u].FRIDAY_LONG,N[u].SATURDAY_LONG]},H=function(){return[N[u].SUNDAY_SHORT,N[u].MONDAY_SHORT,N[u].TUESDAY_SHORT,N[u].WEDNESDAY_SHORT,N[u].THURSDAY_SHORT,N[u].FRIDAY_SHORT,N[u].SATURDAY_SHORT]},L,v,q,x,mt=function(t,s,l){var m;n.XMLHttpRequest?m=new XMLHttpRequest:m=new ActiveXObject("Microsoft.XMLHTTP"),m.onreadystatechange=function(){m.readyState===4&&(m.status===200?s&&(n.JSON===A?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(m.responseText))):l&&l(m))},m.open("GET",t,!1),m.send()},G={"%d":{format:function(t){return r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t);return{day:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return r(t.month()||i.MIN_MONTH,2)},parse:function(t){var s=Number(t);return{month:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t);return{year:isNaN(s)?A:s}},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 s=t.dayOfWeek();return x[s!==A?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var s=t.dayOfWeek();return q[s!==A?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return v[s!==A?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames().indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:A}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return L[s!==A?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames(!0).indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:A}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return r(t.hours()||i.MIN_HOURS,2)},parse:function(t){var s=Number(t);return{hours:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return r(t.minutes()||i.MIN_MINUTES,2)},parse:function(t){var s=Number(t);return{minutes:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return r(t.seconds()||i.MIN_SECONDS,2)},parse:function(t){var s=Number(t);return{seconds:isNaN(s)?A:s}},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 r(t.year()||i.MIN_YEAR,4)+"-"+r(t.month()||i.MIN_MONTH,2)+"-"+r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t.slice(0,4)),l=Number(t.slice(5,7)),m=Number(t.slice(8,10));return{year:s,month:l,day:m}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return r(t.month()||i.MIN_MONTH,2)+"/"+r(t.day()||i.MIN_DAY,2)+"/"+r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t.slice(0,2)),l=Number(t.slice(3,5)),m=Number(t.slice(6,10));return{year:m,month:s,day:l}},minLength:10,maxLength:10,type:"string"}},ut={useMilliseconds:!1,monthFromZero:!1},R;R=function(t,s,l){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==A&&this.set(t,s,l),this},R.fn=R.prototype,R.fn.dayCount=function(){var t=this.month(),s=i.MAX_DAY_IN_MONTHS[t-(i.options("monthFromZero")?0:1)];return this.leapYear()&&t===(i.options("monthFromZero")?1:2)&&(s+=1),s},R.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},R.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},R.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},R.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},R.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},R.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},R.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},R.fn.week=function(){var t=new Date(this.year(),0,1),s=i(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((s-t.getTime())/864e5+t.getDay()+1)/7)},R.fn.set=function(t,s,l){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===A)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 m,M=[],E,S,J=[],B=0,C=0,D,Q,Y={},U;if(t===A)return E=h(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;for(s===A&&(s=i.detectFormat(t));B<s.length;){if(s.charAt(B)==="%"){if(S=s.charAt(B)+s.charAt(B+1),G[S]!==A){switch(D=0,Q="",G[S].type){case"number":for(;D<G[S].maxLength&&C+D<t.length&&!isNaN(Number(t.charAt(C+D)));)Q+=t.charAt(C+D),D+=1;break;case"word":for(;D<G[S].maxLength&&C+D<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(C+D));)Q+=t.charAt(C+D),D+=1;break;case"string":for(;D<G[S].maxLength&&C+D<t.length;)Q+=t.charAt(C+D),D+=1;break}if(D<G[S].minLength)return E=h(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;M.push(S),J.push(Q),D-=1,C+=D,B+=1}}else if(t.charAt(C)!==s.charAt(B))return E=h(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;B+=1,C+=1}for(m in M)M.hasOwnProperty(m)&&G.hasOwnProperty(M[m])&&(U=G[M[m]].parse(J[m]),Y={year:U.year!==A?U.year:Y.year,month:U.month!==A?U.month:Y.month,day:U.day!==A?U.day:Y.day,hours:U.hours!==A?U.hours:Y.hours,minutes:U.minutes!==A?U.minutes:Y.minutes,seconds:U.seconds!==A?U.seconds:Y.seconds});this.day(i.MIN_DAY),this.year(Y.year),this.month(Y.month),this.day(Y.day),this.hours(Y.hours),this.minutes(Y.minutes),this.seconds(Y.seconds),this.milliseconds(Y.milliseconds)}return this},R.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},R.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},R.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)},R.fn.dayOfWeek=function(t){if(t==="long")return q[this._d.getDay()];if(t==="short")return x[this._d.getDay()];if(t===A)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()})},R.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}},R.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()}}},R.fn.format=function(t){for(var s=0,l="",m;s<t.length;)t.charAt(s)==="%"?(m=t.charAt(s)+t.charAt(s+1),G[m]!==A?(l+=G[m].format(this),s+=1):l+="%"):l+=t.charAt(s),s+=1;return l},R.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},R.fn.errors=function(){return this._i},R.fn.between=function(t,s){var l=this.timestamp(),m=t.timestamp();switch(s){case"year":return Math.floor((m-l)/31556952);case"month":return Math.floor((m-l)/2629746);case"day":return Math.floor((m-l)/86400);case"hours":return Math.floor((m-l)/3600);case"minutes":return Math.floor((m-l)/60);case"seconds":return m-l;default:return A}},R.fn.calc=function(t){return t.year!==A&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==A&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==A&&this._d.setDate(this._d.getDate()+t.day),t.hours!==A&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==A&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==A&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==A&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},i=function(t,s,l){return new R(t,s,l)},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,s){if(t===A)return ut;if(ut.hasOwnProperty(t)){if(s===A)return ut[t];ut[t]=s,t==="monthFromZero"&&(i.MIN_MONTH=s?0:1,i.MAX_MONTH=s?11:12)}return A},i.noConflict=function(){return n.tempus=c,i},i.generate=function(t){var s,l,m,M,E,S,J,B;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof R?s=t.dateFrom.utc():s=i(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof R?l=t.dateTo.utc():l=i(t.dateTo,t.formatTo!==A?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?E={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?E={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"&&(E={year:t.period.year!==A?t.period.year:0,month:t.period.month!==A?t.period.month:0,day:t.period.day!==A?t.period.day:0,hours:t.period.hours!==A?t.period.hours:0,minutes:t.period.minutes!==A?t.period.minutes:0,seconds:t.period.seconds!==A?t.period.seconds:0}),t.groupBy===A?S=t.asObject===!0?{}:[]:(S=[],S.push([]),J=i(s).get()[t.groupBy]),B=function(Q,Y,U){return t.asObject===!0?t.format!==A?Q[i(Y).format(t.format)]={}:Q[i(Y).format("%F %H:%M:%S")]={}:t.format!==A?Q.push(U?null:i(Y).format(t.format)):Q.push(U?null:i(Y)),Q},t.groupBy!==A&&t.fillNulls){var C={year:E.year?-E.year:A,month:E.month?-E.month:A,day:E.day?-E.day:A,hours:E.hours?-E.hours:A,minutes:E.minutes?-E.minutes:A,seconds:E.seconds?-E.seconds:A,milliseconds:E.milliseconds?-E.milliseconds:A};for(m=i(s).calc(C).utc();i(m).get()[t.groupBy]===J;)B(S[S.length-1],m,!0),m=i(m).calc(C).utc();if(t.groupBy==="week"){var D=i(s).dayOfWeek();for(m=i(s).dayOfWeek(0).utc();S[0].length<D&&m<s;)B(S[S.length-1],m,!0),m=i(m).calc(E).utc()}}for(;s<=l;)t.groupBy===A?B(S,s):i(s).get()[t.groupBy]===J?B(S[S.length-1],s):(S.push([]),B(S[S.length-1],s),J=i(s).get()[t.groupBy]),s=i(s).calc(E).utc();if(t.groupBy!==A&&t.fillNulls)for(M=i(l).calc(E).utc();i(M).get()[t.groupBy]===J;)B(S[S.length-1],M,!0),M=i(M).calc(E).utc();return S},i.monthNames=function(t){switch(t){case"long":return L;default:return v}},i.dayNames=function(t){switch(t){case"long":return q;default:return x}},i.lang=function(t){if(t!==A)u=t,N[u]===A&&(u="en"),L=I(),v=X(),q=P(),x=H();else return u;return A},i.availableLangs=function(){return Object.keys(N)},i.registerFormat=function(t,s,l,m,M,E){G[t]={format:s,parse:l,minLength:m,maxLength:M,type:E}},i.unregisterFormat=function(t){delete G[t]},i.detectFormat=function(t){var s,l,m;return s=f(t,0),s!==""&&(m=10),l=t.charAt(m),(l==="T"||l===" ")&&(s+=l,m+=1),s+=o(t,m),s},d={TempusDate:R},i.classes=function(t,s){if(s===A)return d[t];d[t]=s},i.loadTranslations=function(t){typeof t=="object"?N=t:typeof t=="string"&&mt(t,function(s){N=s},function(s){})},u=(y.language||y.systemLanguage||y.userLanguage||"en").substr(0,2).toLowerCase(),N[u]===A&&(u="en"),L=I(),v=X(),q=P(),x=H(),j.exports&&(e=j.exports=i),e.tempus=i}).call(p)})(ft,ft.exports);var Te=ft.exports;const Tt=b(Te);class Z{constructor(e,A={}){O(this,Nt);O(this,Ot);O(this,St);O(this,_t);O(this,pt);O(this,Mt);O(this,Lt);O(this,Ct);O(this,kt);O(this,bt);O(this,Dt);O(this,Ht);O(this,yt);O(this,Yt);O(this,Ft);O(this,ht);O(this,dt);O(this,gt);O(this,Pt);O(this,tt,null);O(this,Rt,null);O(this,et,[]);O(this,w,{});O(this,V,50);O(this,z,50);O(this,At,!0);O(this,st,null);O(this,k,null);O(this,$,null);O(this,Gt,100);O(this,ot,"no");O(this,F,!1);O(this,it,!1);O(this,at,!1);W(this,"errors",{});W(this,"answerData",{});W(this,"timeLimit",!1);g(this,tt,e),g(this,Rt,A)}get serial(){return a(this,F)}get limitCommandSerial(){return a(this,z)}set limitCommandSerial(e){if(e<10)throw new Error("limitCommandSerial не может быть меньше 10");e>=10&&e<50&&(g(this,V,e),g(this,z,e)),g(this,z,e)}setSerial(){g(this,F,!0),g(this,it,!0),g(this,at,!1)}setParallel(){g(this,F,!1),g(this,it,!1),g(this,at,!0)}stop(){g(this,At,!1)}async batch(e,A){a(this,$)&&_(this,Ot,zt).call(this),A&&g(this,st,A),a(this,it)===!1&&g(this,F,!1),Object.keys(e).length>a(this,z)&&g(this,F,!0),g(this,At,!0),g(this,et,[]),g(this,w,{}),this.errors={},this.answerData={};const n=_(this,_t,Kt).call(this,e);if(Object.keys(e).length<a(this,z)){const r=n.map((h,o)=>_(this,pt,se).call(this,h,n[o]));return Promise.allSettled(r).then(h=>{let o={};for(let f of h)f.status==="fulfilled"&&(o={...o,...f.value});return o})}else{let r={},h=0,o=1,f=Object.keys(e).length||1,c=i=>{h+=Object.keys(i).length,o=Math.round(h/f*100)};for(let[i,d]of Object.entries(n)){let y=await _(this,pt,se).call(this,d,n[i],!0);c(d),A&&A({percent:o}),r={...r,...y}}return r}}async batchUpdateField(e,A){a(this,$)&&_(this,Ot,zt).call(this),A&&g(this,st,A),a(this,it)===!1&&g(this,F,!1),Object.keys(e).length>a(this,z)&&g(this,F,!0),g(this,At,!0),g(this,et,[]),g(this,w,{}),this.errors={},this.answerData={};const n=_(this,_t,Kt).call(this,e);if(Object.keys(e).length<a(this,z)){let r={};for(let[h,o]of Object.entries(n)){let f=await _(this,Mt,ie).call(this,o,n[h]);r={...r,...f}}return r}else{let r={},h=0,o=1,f=Object.keys(e).length||1,c=i=>{h+=Object.keys(i).length,o=Math.round(h/f*100)};for(let[i,d]of Object.entries(n)){let y=await _(this,Mt,ie).call(this,d,n[i],!0);c(d),A&&A({percent:o}),r={...r,...y},this.timeLimit&&(console.log("Был достигнут лимит operating time - сделана остановка на 2 минуты, timeLimit = ",this.timeLimit),await new Promise(u=>setTimeout(u,12e4)),this.timeLimit=!1,console.log("Остановка в 2 минуты по лимиту operating time закончена, timeLimit = ",this.timeLimit))}return r}}async batchTotalCount(e,A){g(this,w,{}),this.errors={};let n=1,r=0,h=Object.keys(e).length||1,o=c=>{r+=Object.keys(c).length,n=Math.round(r/h*100)};A&&A({percent:n});const f=_(this,_t,Kt).call(this,e);if(a(this,at)){const c=f.map(i=>_(this,Lt,re).call(this,i).then(d=>(o(i),A&&A({percent:n}),d)));return Promise.allSettled(c).then(i=>{let d={};for(let y of i)y.status==="fulfilled"&&(d={...d,...y.value});return d})}else{let c={};for(let i of f){let d=await _(this,Lt,re).call(this,i);o(i),A&&A({percent:n}),c={...c,...d}}return c}}}tt=new WeakMap,Rt=new WeakMap,et=new WeakMap,w=new WeakMap,V=new WeakMap,z=new WeakMap,At=new WeakMap,st=new WeakMap,k=new WeakMap,$=new WeakMap,Gt=new WeakMap,ot=new WeakMap,F=new WeakMap,it=new WeakMap,at=new WeakMap,Nt=new WeakSet,Vt=function(){let e=0;if(!a(this,k))return Math.round(e);let A=0,n=0;return Object.values(a(this,k)).forEach(r=>{const{total:h,count:o}=r;A+=h??0,n+=o??0}),A?e=n/A*100:e=100,{percent:Math.round(e),allCount:n,allTotal:A}},Ot=new WeakSet,zt=function(){clearInterval(a(this,$)),g(this,$,""),g(this,k,""),g(this,st,""),g(this,ot,"no")},St=new WeakSet,Ae=function({key:e,value:A}){const n=_(this,ht,Ut).call(this,A.data()),r=Array.isArray(n)?n.length:0,h=_(this,dt,qt).call(this,A.total(),r);let o=1;n&&(o=r),a(this,st)&&(a(this,k)||g(this,k,{}),a(this,k)[e]&&a(this,k)[e].count&&(o+=a(this,k)[e].count),a(this,k)[e]={total:h,count:o},a(this,$)||g(this,$,setInterval(()=>{const{percent:f,allCount:c,allTotal:i}=a(this,Nt,Vt);(a(this,ot)==="no"||a(this,ot)<a(this,Nt,Vt).percent)&&(a(this,st).call(this,{data:a(this,k),percent:f,allCount:c,allTotal:i}),g(this,ot,a(this,Nt,Vt).percent)),f===100&&_(this,Ot,zt).call(this)},a(this,Gt))))},_t=new WeakSet,Kt=function(e){const A=[],n=Object.entries(e);for(let r=0;r<n.length;r+=a(this,V)){const h=n.slice(r,r+a(this,V));A.push(Object.fromEntries(h))}return A},pt=new WeakSet,se=function(e,A,n){return new Promise(r=>{const h=_(this,Yt,he).call(this,A),o=[];let f=0,c=0;a(this,tt).call(this,e,i=>{Object.entries(i).forEach(([d,y])=>{let u={};const N=y.error();if(N){let{query:{method:H},answer:L}=y;this.errors[d]={error:N,method:H},f+=1}if(y!=null&&y.answer&&Object.keys(y.answer).length){for(let[H,L]of Object.entries(y.answer))H!="result"&&L&&(u[H]=L);Object.keys(u).length&&(this.answerData[d]=u)}const I=_(this,ht,Ut).call(this,y.data()),X=Array.isArray(I)?I.length:0,P=_(this,dt,qt).call(this,y.total(),X);if(Array.isArray(I)?a(this,w)[d]=I:typeof I=="object"&&I!==null&&Object.keys(I).length===0?a(this,w)[d]=[]:a(this,w)[d]=I,c+=P,n||_(this,St,Ae).call(this,{key:d,value:y}),P>a(this,V)&&P>X){const H=Math.ceil(P/a(this,V))-1,L=Array.from({length:H});o.push([d,h[d],L])}}),c>5e3&&a(this,it)===!1&&a(this,at)===!1&&g(this,F,!0),f>0&&_(this,gt,$t).call(this),o.length?(_(this,Ct,me).call(this,o),_(this,kt,ue).call(this).then(()=>r(_(this,yt,vt).call(this)))):r(_(this,yt,vt).call(this))})})},Mt=new WeakSet,ie=function(e,A,n){let r=_(this,Pt,Ne).call(this,e);return new Promise(h=>{let o=0;a(this,tt).call(this,"batch",r,f=>{var y,u,N,I,X,P;let c=((u=(y=f==null?void 0:f.answer)==null?void 0:y.result)==null?void 0:u.result)??null,i=((I=(N=f==null?void 0:f.answer)==null?void 0:N.result)==null?void 0:I.result_error)??null,d=((P=(X=f==null?void 0:f.answer)==null?void 0:X.result)==null?void 0:P.result_time)??null;(c||Object.keys(c).length)&&Object.entries(c).forEach(([H,L])=>{this.answerData[H]=L}),(i||Object.keys(i).length)&&Object.entries(i).forEach(([H,L])=>{var x,mt;let v=((x=e[H])==null?void 0:x.method)??null,q=((mt=e[H])==null?void 0:mt.params)??null;this.errors[H]={error:L,method:v,params:q},o+=1}),(d||Object.keys(d).length)&&Object.entries(d).forEach(([H,L])=>{((L==null?void 0:L.operating)??0)>=475&&(this.timeLimit=!0)}),o>0&&_(this,gt,$t).call(this),h(this.answerData)})})},Lt=new WeakSet,re=function(e){return new Promise(A=>{const n=_(this,Yt,he).call(this,e);let r=0;a(this,tt).call(this,n,h=>{Object.entries(h).forEach(([o,f])=>{const c=f.error();c&&(this.errors[o]=c,r+=1);const i=_(this,ht,Ut).call(this,f.data()),d=Array.isArray(i)?i.length:0,y=_(this,dt,qt).call(this,f.total(),d);a(this,w)[o]=y}),r>0&&_(this,gt,$t).call(this),A(_(this,yt,vt).call(this))})})},Ct=new WeakSet,me=function(e){let A=[];e.forEach(([n,r,h])=>{h.forEach((o,f)=>{const c=f+1,i=a(this,V)*c,y=[[n,c].join("_"),_(this,Ft,fe).call(this,r,i)];A.length===a(this,V)?(a(this,et).push(A),A=[y]):A.push(y)})}),A.length&&a(this,et).push(A)},kt=new WeakSet,ue=function(){const e=[],A=[],n=r=>{Object.entries(r).forEach(([h,o])=>{const[f]=h.split("_"),c=_(this,ht,Ut).call(this,o.data());Array.isArray(c)&&a(this,w)[f].push(...c),_(this,St,Ae).call(this,{key:f,value:o})})};return a(this,et).forEach((r,h)=>{const o=Object.fromEntries(r),f=()=>new Promise(c=>a(this,tt).call(this,o,i=>{a(this,F)?n(i):A[h]=i,c()}));e.push(f)}),a(this,F)?_(this,Dt,oe).call(this,e):_(this,Ht,ae).call(this,e).then(()=>{A.forEach(n)})},bt=new WeakSet,ne=function(){return new Promise(e=>setTimeout(e,500))},Dt=new WeakSet,oe=function(e){if(!e.length)return Promise.resolve();const A=e.shift();return Promise.allSettled([A(),_(this,bt,ne).call(this)]).then(()=>a(this,At)?_(this,Dt,oe).call(this,e):Promise.resolve())},Ht=new WeakSet,ae=function(e){if(!e.length)return Promise.resolve();const A=e.shift();return _(this,bt,ne).call(this).then(()=>A()).then(()=>a(this,At)?_(this,Ht,ae).call(this,e):Promise.resolve())},yt=new WeakSet,vt=function(){return Object.entries(a(this,Rt)).forEach(([e,A])=>{a(this,w)[e]&&(a(this,w)[e]=A(a(this,w)[e]))}),a(this,w)},Yt=new WeakSet,he=function(e){return Object.entries(e).reduce((A,[n,r])=>{if(Array.isArray(r)){const[h,o={}]=r;A[n]=[h,o]}else{const{method:h,params:o={}}=r;A[n]=[h,o]}return A},{})},Ft=new WeakSet,fe=function(e,A){const[n,r]=e;return[n,{start:A,...r}]},ht=new WeakSet,Ut=function(e){return((e==null?void 0:e.items)||(e==null?void 0:e.documents)||(e==null?void 0:e.tasks))??e},dt=new WeakSet,qt=function(e,A){return e!==e&&(e=0),e===0&&A===0?0:e||A},gt=new WeakSet,$t=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([e,A])=>{console.info(`[${e}]`,A)}),console.groupEnd()},Pt=new WeakSet,Ne=function(e){var n,r,h,o,f,c,i,d,y,u,N,I,X,P,H,L,v,q,x,mt,G,ut,R,t;let A={halt:0,cmd:{}};for(let s in e){const l=s;let m=(n=e[s])!=null&&n.method?(r=e[s])==null?void 0:r.method:"",M="",E="",S="";const J=(o=(h=e[s])==null?void 0:h.params)==null?void 0:o.fields;if((c=(f=e[s])==null?void 0:f.params)!=null&&c.entityTypeId?(M=`?entityTypeId=${parseInt((d=(i=e[s])==null?void 0:i.params)==null?void 0:d.entityTypeId)}`,(u=(y=e[s])==null?void 0:y.params)!=null&&u.id&&(E=`&id=${(I=(N=e[s])==null?void 0:N.params)==null?void 0:I.id}`),(P=(X=e[s])==null?void 0:X.params)!=null&&P.ID&&(E=`&ID=${(L=(H=e[s])==null?void 0:H.params)==null?void 0:L.ID}`)):((q=(v=e[s])==null?void 0:v.params)!=null&&q.id&&(E=`?id=${(mt=(x=e[s])==null?void 0:x.params)==null?void 0:mt.id}`),(ut=(G=e[s])==null?void 0:G.params)!=null&&ut.ID&&(E=`?ID=${(t=(R=e[s])==null?void 0:R.params)==null?void 0:t.ID}`)),Object.keys(J).length>0)for(let B in J)S+=`&fields[${B}]=${J[B]}`;A.cmd[l]=`${m}${M}${E}${S}`.trim()}return A};class te{constructor(){O(this,lt,{})}get hash(){return this.createHash(8)}createHash(e){let A="abcdefghijklmnopqrstuvwxyz0123456789",n="";e=e||6;for(let r=0;r<e;r++)n+=A.charAt(Math.floor(Math.random()*A.length));return n}actionFilter({keyTimer:e,duration:A=10,action:n}){a(this,lt)[e]&&(clearTimeout(a(this,lt)[e]),a(this,lt)[e]=null),n&&(a(this,lt)[e]=setTimeout(()=>{n()},A))}async noSleep(){let e=document.createElement("video");e.classList.add("no-sleep"),e.addEventListener("loadeddata",()=>{e.style.position="fixed",e.style.left="-9999px",document.querySelector("body").append(e),e.play()}),e.addEventListener("ended",()=>{this.actionFilter({keyTimer:"no-sleep",duration:5e3,action:()=>e.play()})}),e.src="data:video/mp4;base64,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"}downloadFileJson(e,A){let n=new Blob([JSON.stringify(e)],{type:"application/json"}),r=URL.createObjectURL(n),h=document.createElement("a");h.style.display="none",h.href=r,h.download=`${A}.json`,document.body.appendChild(h),h.click(),setTimeout(()=>{document.body.removeChild(h),URL.revokeObjectURL(r)},200)}}lt=new WeakMap;const wt=new te;class ce{constructor(){O(this,jt);O(this,It);O(this,Jt);O(this,Xt);O(this,xt);O(this,K,"logger");O(this,rt,!1);O(this,Wt,2e3);O(this,ct,new Map);O(this,Bt,{});O(this,nt,null);O(this,Et,!1);W(this,"periodClear",3);_(this,jt,Oe).call(this)}async init(){let e=new Z(BX24.callBatch),{entityList:A}=await e.batch({entityList:{method:"entity.get"}});if(A&&Array.isArray(A))if(A.find(r=>r.ENTITY==a(this,K)))g(this,rt,!0);else{let{entityAdd:r}=await e.batch({entityAdd:{method:"entity.add",params:{ENTITY:a(this,K),NAME:a(this,K),ACCESS:{AU:"X"}}}});r&&g(this,rt,!0)}return _(this,Xt,ye).call(this),a(this,rt)}start({type:e,data:A}){if(!a(this,rt)){_(this,It,le).call(this,"entity");return}const n=wt.hash;return a(this,ct).set(n,{type:e,data:A,userInfo:a(this,Bt),errorList:[],status:"",answer:null,date:new Date().getTime()}),n}stop({key:e,errorList:A,status:n,answer:r}){if(!a(this,rt)){_(this,It,le).call(this,"entity");return}let h=a(this,ct).get(e);A&&(h.errorList=A),n&&(h.status=n),r&&(h.answer=r),wt.actionFilter({keyTimer:"add.entity.items",duration:a(this,Wt),action:async()=>{var o;await _(this,Jt,_e).call(this),(o=h==null?void 0:h.data)!=null&&o.updateList&&g(this,Et,!0)}})}async getEntityList(e){var r;if((r=a(this,nt))!=null&&r.length&&!a(this,Et))return a(this,nt);let A=new Z(BX24.callBatch),{entityList:n}=await A.batch({entityList:{method:"entity.item.get",params:{ENTITY:a(this,K),SORT:{ID:"DESC"}}}},e);return n=n.map(h=>{const{ID:o,DATE_CREATE:f,DETAIL_TEXT:c}=h;return{...JSON.parse(c),id:o,dateCreate:f}}),g(this,Et,!1),n}async downAllEntityJson(){let e=await this.getEntityList(),A=Tt().format("%Y-%m-%d");wt.downloadFileJson(e,`sdklogger-entity-data__${A}`)}}K=new WeakMap,rt=new WeakMap,Wt=new WeakMap,ct=new WeakMap,Bt=new WeakMap,nt=new WeakMap,Et=new WeakMap,jt=new WeakSet,Oe=async function(){const e=new Z(BX24.callBatch),A=BX24.isAdmin(),{curUser:n}=await e.batch({curUser:{method:"user.current"}});g(this,Bt,{isAdmin:A,curUser:n})},It=new WeakSet,le=function(e){e=="entity"&&wt.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},Jt=new WeakSet,_e=async function(){let e={},A=new Z(BX24.callBatch);for(let[n,r]of a(this,ct).entries())r.status&&(e[n]={method:"entity.item.add",params:{ENTITY:a(this,K),NAME:a(this,K),DETAIL_TEXT:JSON.stringify(r)}});if(Object.keys(e).length){let n=await A.batch(e),{errors:r}=A;for(let[h,o]of Object.entries({...n,...r}))a(this,ct).delete(h);return!0}},Xt=new WeakSet,ye=async function(){let e=new Z(BX24.callBatch),{serverTime:A}=await e.batch({serverTime:{method:"server.time"}});a(this,nt)||g(this,nt,await this.getEntityList());let n=a(this,nt).filter(r=>{let{dateCreate:h}=r;return Tt(new Date(h)).between(Tt(new Date(A)),"month")>=this.periodClear});_(this,xt,de).call(this,n)},xt=new WeakSet,de=async function(e){let A=new Z(BX24.callBatch),n=e.map(r=>{let{id:h}=r;return{method:"entity.item.delete",params:{ENTITY:a(this,K),ID:h}}});return await A.batch(n)};class Re{constructor(e){O(this,Qt);O(this,Zt);W(this,"domain","");W(this,"isAdmin",!1);W(this,"appInfo",null);W(this,"appConst",null);W(this,"userInfo",null);W(this,"placeData",null);W(this,"placeInfo",null);W(this,"logger",new ce);this.appConst=e}init(){return new Promise(e=>{let A=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(A),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),await this.logger.init();const[n,r]=await Promise.all([_(this,Qt,ge).call(this),_(this,Zt,Ee).call(this)]);this.appInfo=n,this.userInfo=r,new te().noSleep(),e(!0)})},100)})}userOption(e,A){return A?BX24.userOption.set(e,A):BX24.userOption.get(e)}call({method:e,params:A,updateList:n}){let r=this.logger.start({type:"call",data:{method:e,params:A,updateList:n}});return new Promise(h=>{A||(A={}),BX24.callMethod(e,A,o=>{let f={};if(o!=null&&o.answer)for(let[c,i]of Object.entries(o.answer))c!="result"&&i&&(f[c]=i);if(o.error()){let c=o.error();console.error(c),this.logger.stop({answer:f,key:r,status:"fail",errorList:[c.toString()]}),h(!1)}else{let c=o.data();c!=null&&c.items&&(c=c.items),this.logger.stop({answer:f,key:r,status:"success"}),h(c)}})})}async batch(e,A,{updateList:n,errorCall:r,limitCommandSerial:h}={}){let o=new Z(BX24.callBatch),f=this.logger.start({type:"batch",data:{commandList:e,updateList:n}});h&&(o.limitCommandSerial=h);try{let c=await o.batch(e,A);if(Object.keys(o.errors).length){let i=Object.entries(o.errors).map(([d,y])=>{var u;return{key:d,error:`${y==null?void 0:y.method} ${(u=y==null?void 0:y.error)==null?void 0:u.toString()}`.trim()}});r&&r(o.errors),this.logger.stop({key:f,status:"fail",errorList:i,answer:o.answerData})}else this.logger.stop({key:f,status:"success",answer:o.answerData});return c}catch(c){let i=c==null?void 0:c.toString();return this.logger.stop({key:f,status:"fail-runtime",errorList:[i],answer:o.answerData}),console.error(c),!1}}async batchUpdateField(e,A,{updateList:n,errorCall:r,limitCommandSerial:h}={}){let o=new Z(BX24.callMethod),f=this.logger.start({type:"callMethod-batch",data:{commandList:e,updateList:n}});h&&(o.limitCommandSerial=h);try{let c=await o.batchUpdateField(e,A);if(Object.keys(o.errors).length){let i=Object.entries(o.errors).map(([d,y])=>{var u;return{key:d,error:`${y==null?void 0:y.method} ${(u=y==null?void 0:y.error)==null?void 0:u.toString()}`.trim()}});r&&r(o.errors),this.logger.stop({key:f,status:"fail",errorList:i,answer:o.answerData})}else this.logger.stop({key:f,status:"success",answer:o.answerData});return c}catch(c){let i=c==null?void 0:c.toString();return this.logger.stop({key:f,status:"fail-runtime",errorList:[i],answer:o.answerData}),console.error(c),!1}}async batchTotalCount(e,A){let n=new Z(BX24.callBatch),r=this.logger.start({type:"batch",data:{commandList:e}});try{let h=await n.batchTotalCount(e,A);if(Object.keys(n.errors).length){let o=Object.entries(n.errors).map(([f,c])=>({key:f,error:c.toString()}));this.logger.stop({key:r,status:"fail",errorList:o})}else this.logger.stop({key:r,status:"success"});return h}catch(h){return this.logger.stop({key:r,status:"fail",errorList:[h.toString()]}),console.error(h),!1}}getPlacement(){return this.call({method:"placement.get"}).then(e=>(this.placeData||(this.placeData=e),e))}async placementBind(e){this.placeData||(this.placeData=await this.getPlacement());const{appName:A,pathApp:n}=this.appConst,r=this.placeData.map(o=>o.placement);let h=this.placeData.find(o=>o.placement==e);r.includes(e)?h.handler!=n&&(window.placementUnBind||(window.placementUnBind={}),window.placementUnBind[e]||this.placementUnBind(e).then(()=>{window.placementUnBind[e]||(window.placementUnBind[e]=!0,this.placementBind(e))})):this.call({method:"placement.bind",params:{PLACEMENT:e,HANDLER:n,LANG_ALL:{ru:{TITLE:A}}}}).then(o=>{o?console.info("Приложение успешно встроено в",e):console.warn("Приложение не может быть встроено в",e)})}placementUnBind(e){const{pathApp:A,appName:n}=this.appConst;return this.call({method:"placement.unbind",params:{PLACEMENT:e,HANDLER:A,LANG_ALL:{ru:{TITLE:n}}}}).then(r=>(console.log("Встройка отвязана",e),r))}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(e=>{let A=Object.values(e);return console.log("chat-bot list:",A),A})}regBot({code:e,type:A,name:n}){const{appName:r,pathApp:h,chatBotLogo:o}=this.appConst,f=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:e??this.appInfo.CODE,TYPE:A??"O",EVENT_HANDLER:h,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${n??r} - бот #${f}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:Tt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:o??""}}}).then(c=>(console.log("Чат-бот добавлен",c),c))}unRegBot(e){return this.call({method:"imbot.unregister",params:{BOT_ID:e}}).then(A=>(console.log("чат-бот удален",A),A))}getLoggerList(e){return this.logger.getEntityList(e)}}Qt=new WeakSet,ge=function(){return this.call({method:"app.info"})},Zt=new WeakSet,Ee=function(){return this.call({method:"user.current"})},T.Batch=Z,T.BxBoot=Re,T.BxHelper=te,T.BxLogger=ce,T.tempus=Tt,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types/batch.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
type TCommand = {
|
|
2
|
-
method: string,
|
|
3
|
-
params: Record<string, unknown> | {
|
|
4
|
-
select?: string[],
|
|
5
|
-
filter?: Record<string, string | string[]>,
|
|
6
|
-
} | {
|
|
7
|
-
id?: string,
|
|
8
|
-
params?: Record<string, string>,
|
|
9
|
-
fields?: Record<string, unknown>,
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare class Batch{
|
|
14
|
-
/**
|
|
15
|
-
* @constructor
|
|
16
|
-
* @param {()=>void} callBatch - пробрасываем метод BX24.callBatch
|
|
17
|
-
*/
|
|
18
|
-
constructor(callBatch: ()=>void);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Флаг режима передачи
|
|
22
|
-
*/
|
|
23
|
-
get serial(): boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* лимит команд при котором происходит переключение батча в последовательный режим по дефолту 50
|
|
27
|
-
*/
|
|
28
|
-
limitCommandSerial: number
|
|
29
|
-
|
|
30
|
-
/** Объект ошибок key-value, где key - ключ чанка пакета, value - описание ошибки */
|
|
31
|
-
errors: Record<string, string>;
|
|
32
|
-
|
|
33
|
-
/** Объект служебной информации отработавшего запроса*/
|
|
34
|
-
answerData: Record<string, any>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Установить последовательный режим
|
|
38
|
-
*/
|
|
39
|
-
setSerial(): void;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Установить параллельный режим режим
|
|
43
|
-
*/
|
|
44
|
-
setParallel(): void;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Принудительно остановить выгрузку данных
|
|
48
|
-
*/
|
|
49
|
-
stop(): void;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Пакетный запрос данных
|
|
53
|
-
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
54
|
-
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
55
|
-
*/
|
|
56
|
-
batch(
|
|
57
|
-
commandList: Record<string, TCommand>,
|
|
58
|
-
progressCall?: (data:{ percent: number })=>void
|
|
59
|
-
): Awaited<Record<string, unknown[]> | boolean>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Пакетный запрос количества элементов по запрощенным сущностям
|
|
63
|
-
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
64
|
-
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
65
|
-
*/
|
|
66
|
-
batchTotalCount(
|
|
67
|
-
commandList: Record<string, TCommand>,
|
|
68
|
-
progressCall?: (data:{ percent: number })=>void
|
|
69
|
-
): Awaited<Record<string, unknown[]> | boolean>;
|
|
70
|
-
}
|
|
71
|
-
|
|
1
|
+
type TCommand = {
|
|
2
|
+
method: string,
|
|
3
|
+
params: Record<string, unknown> | {
|
|
4
|
+
select?: string[],
|
|
5
|
+
filter?: Record<string, string | string[]>,
|
|
6
|
+
} | {
|
|
7
|
+
id?: string,
|
|
8
|
+
params?: Record<string, string>,
|
|
9
|
+
fields?: Record<string, unknown>,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class Batch{
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {()=>void} callBatch - пробрасываем метод BX24.callBatch
|
|
17
|
+
*/
|
|
18
|
+
constructor(callBatch: ()=>void);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Флаг режима передачи
|
|
22
|
+
*/
|
|
23
|
+
get serial(): boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* лимит команд при котором происходит переключение батча в последовательный режим по дефолту 50
|
|
27
|
+
*/
|
|
28
|
+
limitCommandSerial: number
|
|
29
|
+
|
|
30
|
+
/** Объект ошибок key-value, где key - ключ чанка пакета, value - описание ошибки */
|
|
31
|
+
errors: Record<string, string>;
|
|
32
|
+
|
|
33
|
+
/** Объект служебной информации отработавшего запроса*/
|
|
34
|
+
answerData: Record<string, any>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Установить последовательный режим
|
|
38
|
+
*/
|
|
39
|
+
setSerial(): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Установить параллельный режим режим
|
|
43
|
+
*/
|
|
44
|
+
setParallel(): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Принудительно остановить выгрузку данных
|
|
48
|
+
*/
|
|
49
|
+
stop(): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Пакетный запрос данных
|
|
53
|
+
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
54
|
+
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
55
|
+
*/
|
|
56
|
+
batch(
|
|
57
|
+
commandList: Record<string, TCommand>,
|
|
58
|
+
progressCall?: (data:{ percent: number })=>void
|
|
59
|
+
): Awaited<Record<string, unknown[]> | boolean>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Пакетный запрос количества элементов по запрощенным сущностям
|
|
63
|
+
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
64
|
+
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
65
|
+
*/
|
|
66
|
+
batchTotalCount(
|
|
67
|
+
commandList: Record<string, TCommand>,
|
|
68
|
+
progressCall?: (data:{ percent: number })=>void
|
|
69
|
+
): Awaited<Record<string, unknown[]> | boolean>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
72
|
export default Batch;
|