@bitrix24/b24jssdk 0.4.10 → 0.5.1

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.
@@ -4,12 +4,12 @@ Request: ${this.requestInfo.method} ${this.requestInfo.url}`),this.stack&&(e+=`
4
4
  Stack trace:
5
5
  ${this.stack}`),e}static formatErrorMessage(e){const t=[e.code];return e.description&&t.push(`- ${e.description}`),e.requestInfo?.method&&e.requestInfo.url&&t.push(`(on ${e.requestInfo.method} ${e.requestInfo.url})`),t.join(" ")}cleanErrorStack(){typeof this.stack=="string"&&(this.stack=this.stack.split(`
6
6
  `).filter(e=>!e.includes("AjaxError.constructor")).join(`
7
- `))}}class Tr extends qe{_status;_query;_data;constructor(e){super(),this._data=Object.freeze(e.answer),this._query=Object.freeze(structuredClone(e.query)),this._status=e.status,this.#e()}#e(){const{error:e}=this._data;if(!e)return;const t=this.#t(e);this.addError(this.#r(t),"base-error")}#t(e){return typeof e=="string"?{code:e,description:this._data.error_description||""}:{code:e.error,description:e.error_description||""}}#r(e){return new xe({code:String(this._status),description:e.description,status:this._status,requestInfo:{method:this._query.method,params:this._query.params}})}getData(){return Object.freeze({result:this._data.result,next:this._data.next,total:this._data.total,time:this._data.time})}hasMore(){return this.isMore()}isMore(){return C.isNumber(this._data?.next)}getTotal(){return V.toInteger(this._data?.total)}getStatus(){return this._status}getQuery(){return this._query}async fetchNext(e){const t=await this.getNext(e);return t===!1?null:t}async getNext(e){if(!this.isMore()||!this.isSuccess)return!1;const t=this.#n();return e.call(t.method,t.params,t.start)}#n(){return{...this._query,start:V.toInteger(this._data.next)}}setData(){throw new ReferenceError("AjaxResult does not allow data modification")}}let _c=class{#e;#t;#r;_logger=null;constructor(){this.#e=Ni,this.#r=0,this.#t=0}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}get params(){return{...this.#e}}set params(e){this.#e=e,this.getLogger().log("new restriction manager params",e)}check(e=""){return new Promise(t=>{if(this.#s(),this.#i())return this.getLogger().log(`>> no sleep >>> ${e}`,this.#n()),this.#o(),t(null);{const n=i=>{this.getLogger().info(`>> go sleep >>> ${e}`,this.#n()),setTimeout(()=>{i()},this.#e.sleep)},s=()=>{if(this.#s(),this.#i())return this.getLogger().info(`<< stop sleep <<< ${e}`,this.#n()),this.#o(),t(null);n(s)};n(s)}})}#n(){return`${this.#r.toFixed(4)} from ${this.#e.amount}`}#s(){this.#t>0&&(this.#r-=(Date.now()-this.#t)*this.#e.speed,this.#r<0&&(this.#r=0)),this.#t=Date.now()}#o(){this.#r++}#i(){return this.#r<this.#e.amount}};const kc="X-Request-ID",vc="bx24_request_id",Ec="bx24_sdk_ver",Tc="bx24_sdk_type";let Oc=class{getQueryStringParameterName(){return vc}getQueryStringSdkParameterName(){return Ec}getQueryStringSdkTypeParameterName(){return Tc}generate(){return V.getUuidRfc4122()}getRequestId(){return this.generate()}getHeaderFieldName(){return kc}};function Ui(r,e){return function(){return r.apply(e,arguments)}}const{toString:Ac}=Object.prototype,{getPrototypeOf:_n}=Object,{iterator:Or,toStringTag:$i}=Symbol,Ar=(r=>e=>{const t=Ac.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),ze=r=>(r=r.toLowerCase(),e=>Ar(e)===r),Ir=r=>e=>typeof e===r,{isArray:Mt}=Array,Ft=Ir("undefined");function Xt(r){return r!==null&&!Ft(r)&&r.constructor!==null&&!Ft(r.constructor)&&Oe(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Wi=ze("ArrayBuffer");function Ic(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Wi(r.buffer),e}const Cc=Ir("string"),Oe=Ir("function"),Vi=Ir("number"),er=r=>r!==null&&typeof r=="object",Nc=r=>r===!0||r===!1,Cr=r=>{if(Ar(r)!=="object")return!1;const e=_n(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!($i in r)&&!(Or in r)},Rc=r=>{if(!er(r)||Xt(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},Lc=ze("Date"),Pc=ze("File"),Dc=ze("Blob"),Mc=ze("FileList"),Fc=r=>er(r)&&Oe(r.pipe),xc=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Oe(r.append)&&((e=Ar(r))==="formdata"||e==="object"&&Oe(r.toString)&&r.toString()==="[object FormData]"))},jc=ze("URLSearchParams"),[Bc,Uc,$c,Wc]=["ReadableStream","Request","Response","Headers"].map(ze),Vc=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function tr(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,s;if(typeof r!="object"&&(r=[r]),Mt(r))for(n=0,s=r.length;n<s;n++)e.call(null,r[n],n,r);else{if(Xt(r))return;const i=t?Object.getOwnPropertyNames(r):Object.keys(r),o=i.length;let l;for(n=0;n<o;n++)l=i[n],e.call(null,r[l],l,r)}}function qi(r,e){if(Xt(r))return null;e=e.toLowerCase();const t=Object.keys(r);let n=t.length,s;for(;n-- >0;)if(s=t[n],e===s.toLowerCase())return s;return null}const wt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,zi=r=>!Ft(r)&&r!==wt;function kn(){const{caseless:r,skipUndefined:e}=zi(this)&&this||{},t={},n=(s,i)=>{const o=r&&qi(t,i)||i;Cr(t[o])&&Cr(s)?t[o]=kn(t[o],s):Cr(s)?t[o]=kn({},s):Mt(s)?t[o]=s.slice():(!e||!Ft(s))&&(t[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&tr(arguments[s],n);return t}const qc=(r,e,t,{allOwnKeys:n}={})=>(tr(e,(s,i)=>{t&&Oe(s)?r[i]=Ui(s,t):r[i]=s},{allOwnKeys:n}),r),zc=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),Hc=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},Jc=(r,e,t,n)=>{let s,i,o;const l={};if(e=e||{},r==null)return e;do{for(s=Object.getOwnPropertyNames(r),i=s.length;i-- >0;)o=s[i],(!n||n(o,r,e))&&!l[o]&&(e[o]=r[o],l[o]=!0);r=t!==!1&&_n(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Zc=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const n=r.indexOf(e,t);return n!==-1&&n===t},Gc=r=>{if(!r)return null;if(Mt(r))return r;let e=r.length;if(!Vi(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},Yc=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&_n(Uint8Array)),Kc=(r,e)=>{const n=(r&&r[Or]).call(r);let s;for(;(s=n.next())&&!s.done;){const i=s.value;e.call(r,i[0],i[1])}},Qc=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},Xc=ze("HTMLFormElement"),eu=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,s){return n.toUpperCase()+s}),Hi=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),tu=ze("RegExp"),Ji=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};tr(t,(s,i)=>{let o;(o=e(s,i,r))!==!1&&(n[i]=o||s)}),Object.defineProperties(r,n)},ru=r=>{Ji(r,(e,t)=>{if(Oe(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(Oe(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},nu=(r,e)=>{const t={},n=s=>{s.forEach(i=>{t[i]=!0})};return Mt(r)?n(r):n(String(r).split(e)),t},su=()=>{},iu=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function ou(r){return!!(r&&Oe(r.append)&&r[$i]==="FormData"&&r[Or])}const au=r=>{const e=new Array(10),t=(n,s)=>{if(er(n)){if(e.indexOf(n)>=0)return;if(Xt(n))return n;if(!("toJSON"in n)){e[s]=n;const i=Mt(n)?[]:{};return tr(n,(o,l)=>{const a=t(o,s+1);!Ft(a)&&(i[l]=a)}),e[s]=void 0,i}}return n};return t(r,0)},lu=ze("AsyncFunction"),cu=r=>r&&(er(r)||Oe(r))&&Oe(r.then)&&Oe(r.catch),Zi=((r,e)=>r?setImmediate:e?((t,n)=>(wt.addEventListener("message",({source:s,data:i})=>{s===wt&&i===t&&n.length&&n.shift()()},!1),s=>{n.push(s),wt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Oe(wt.postMessage)),uu=typeof queueMicrotask<"u"?queueMicrotask.bind(wt):typeof process<"u"&&process.nextTick||Zi,k={isArray:Mt,isArrayBuffer:Wi,isBuffer:Xt,isFormData:xc,isArrayBufferView:Ic,isString:Cc,isNumber:Vi,isBoolean:Nc,isObject:er,isPlainObject:Cr,isEmptyObject:Rc,isReadableStream:Bc,isRequest:Uc,isResponse:$c,isHeaders:Wc,isUndefined:Ft,isDate:Lc,isFile:Pc,isBlob:Dc,isRegExp:tu,isFunction:Oe,isStream:Fc,isURLSearchParams:jc,isTypedArray:Yc,isFileList:Mc,forEach:tr,merge:kn,extend:qc,trim:Vc,stripBOM:zc,inherits:Hc,toFlatObject:Jc,kindOf:Ar,kindOfTest:ze,endsWith:Zc,toArray:Gc,forEachEntry:Kc,matchAll:Qc,isHTMLForm:Xc,hasOwnProperty:Hi,hasOwnProp:Hi,reduceDescriptors:Ji,freezeMethods:ru,toObjectSet:nu,toCamelCase:eu,noop:su,toFiniteNumber:iu,findKey:qi,global:wt,isContextDefined:zi,isSpecCompliantForm:ou,toJSONObject:au,isAsyncFn:lu,isThenable:cu,setImmediate:Zi,asap:uu,isIterable:r=>r!=null&&Oe(r[Or])};function H(r,e,t,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}k.inherits(H,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:k.toJSONObject(this.config),code:this.code,status:this.status}}});const Gi=H.prototype,Yi={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Yi[r]={value:r}}),Object.defineProperties(H,Yi),Object.defineProperty(Gi,"isAxiosError",{value:!0}),H.from=(r,e,t,n,s,i)=>{const o=Object.create(Gi);k.toFlatObject(r,o,function(c){return c!==Error.prototype},u=>u!=="isAxiosError");const l=r&&r.message?r.message:"Error",a=e==null&&r?r.code:e;return H.call(o,l,a,t,n,s),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",i&&Object.assign(o,i),o};const hu=null;function vn(r){return k.isPlainObject(r)||k.isArray(r)}function Ki(r){return k.endsWith(r,"[]")?r.slice(0,-2):r}function Qi(r,e,t){return r?r.concat(e).map(function(s,i){return s=Ki(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function fu(r){return k.isArray(r)&&!r.some(vn)}const du=k.toFlatObject(k,{},null,function(e){return/^is[A-Z]/.test(e)});function Nr(r,e,t){if(!k.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=k.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,m){return!k.isUndefined(m[g])});const n=t.metaTokens,s=t.visitor||c,i=t.dots,o=t.indexes,a=(t.Blob||typeof Blob<"u"&&Blob)&&k.isSpecCompliantForm(e);if(!k.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(k.isDate(d))return d.toISOString();if(k.isBoolean(d))return d.toString();if(!a&&k.isBlob(d))throw new H("Blob is not supported. Use a Buffer instead.");return k.isArrayBuffer(d)||k.isTypedArray(d)?a&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,g,m){let y=d;if(d&&!m&&typeof d=="object"){if(k.endsWith(g,"{}"))g=n?g:g.slice(0,-2),d=JSON.stringify(d);else if(k.isArray(d)&&fu(d)||(k.isFileList(d)||k.endsWith(g,"[]"))&&(y=k.toArray(d)))return g=Ki(g),y.forEach(function(_,b){!(k.isUndefined(_)||_===null)&&e.append(o===!0?Qi([g],b,i):o===null?g:g+"[]",u(_))}),!1}return vn(d)?!0:(e.append(Qi(m,g,i),u(d)),!1)}const f=[],h=Object.assign(du,{defaultVisitor:c,convertValue:u,isVisitable:vn});function p(d,g){if(!k.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(d),k.forEach(d,function(y,w){(!(k.isUndefined(y)||y===null)&&s.call(e,y,k.isString(w)?w.trim():w,g,h))===!0&&p(y,g?g.concat(w):[w])}),f.pop()}}if(!k.isObject(r))throw new TypeError("data must be an object");return p(r),e}function Xi(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function En(r,e){this._pairs=[],r&&Nr(r,this,e)}const eo=En.prototype;eo.append=function(e,t){this._pairs.push([e,t])},eo.toString=function(e){const t=e?function(n){return e.call(this,n,Xi)}:Xi;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function pu(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function to(r,e,t){if(!e)return r;const n=t&&t.encode||pu;k.isFunction(t)&&(t={serialize:t});const s=t&&t.serialize;let i;if(s?i=s(e,t):i=k.isURLSearchParams(e)?e.toString():new En(e,t).toString(n),i){const o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+i}return r}class ro{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){k.forEach(this.handlers,function(n){n!==null&&e(n)})}}const no={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:En,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Tn=typeof window<"u"&&typeof document<"u",On=typeof navigator=="object"&&navigator||void 0,mu=Tn&&(!On||["ReactNative","NativeScript","NS"].indexOf(On.product)<0),yu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wu=Tn&&window.location.href||"http://localhost",ke={...{__proto__:null,hasBrowserEnv:Tn,hasStandardBrowserEnv:mu,hasStandardBrowserWebWorkerEnv:yu,navigator:On,origin:wu},...gu};function bu(r,e){return Nr(r,new ke.classes.URLSearchParams,{visitor:function(t,n,s,i){return ke.isNode&&k.isBuffer(t)?(this.append(n,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...e})}function Su(r){return k.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function _u(r){const e={},t=Object.keys(r);let n;const s=t.length;let i;for(n=0;n<s;n++)i=t[n],e[i]=r[i];return e}function so(r){function e(t,n,s,i){let o=t[i++];if(o==="__proto__")return!0;const l=Number.isFinite(+o),a=i>=t.length;return o=!o&&k.isArray(s)?s.length:o,a?(k.hasOwnProp(s,o)?s[o]=[s[o],n]:s[o]=n,!l):((!s[o]||!k.isObject(s[o]))&&(s[o]=[]),e(t,n,s[o],i)&&k.isArray(s[o])&&(s[o]=_u(s[o])),!l)}if(k.isFormData(r)&&k.isFunction(r.entries)){const t={};return k.forEachEntry(r,(n,s)=>{e(Su(n),s,t,0)}),t}return null}function ku(r,e,t){if(k.isString(r))try{return(e||JSON.parse)(r),k.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}const rr={transitional:no,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",s=n.indexOf("application/json")>-1,i=k.isObject(e);if(i&&k.isHTMLForm(e)&&(e=new FormData(e)),k.isFormData(e))return s?JSON.stringify(so(e)):e;if(k.isArrayBuffer(e)||k.isBuffer(e)||k.isStream(e)||k.isFile(e)||k.isBlob(e)||k.isReadableStream(e))return e;if(k.isArrayBufferView(e))return e.buffer;if(k.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return bu(e,this.formSerializer).toString();if((l=k.isFileList(e))||n.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return Nr(l?{"files[]":e}:e,a&&new a,this.formSerializer)}}return i||s?(t.setContentType("application/json",!1),ku(e)):e}],transformResponse:[function(e){const t=this.transitional||rr.transitional,n=t&&t.forcedJSONParsing,s=this.responseType==="json";if(k.isResponse(e)||k.isReadableStream(e))return e;if(e&&k.isString(e)&&(n&&!this.responseType||s)){const o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(l){if(o)throw l.name==="SyntaxError"?H.from(l,H.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};k.forEach(["delete","get","head","post","put","patch"],r=>{rr.headers[r]={}});const vu=k.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Eu=r=>{const e={};let t,n,s;return r&&r.split(`
7
+ `))}}class Tr extends qe{_status;_query;_data;constructor(e){super(),this._data=Object.freeze(e.answer),this._query=Object.freeze(structuredClone(e.query)),this._status=e.status,this.#e()}#e(){const{error:e}=this._data;if(!e)return;const t=this.#t(e);this.addError(this.#r(t),"base-error")}#t(e){return typeof e=="string"?{code:e,description:this._data.error_description||""}:{code:e.error,description:e.error_description||""}}#r(e){return new xe({code:String(this._status),description:e.description,status:this._status,requestInfo:{method:this._query.method,params:this._query.params}})}getData(){return Object.freeze({result:this._data.result,next:this._data.next,total:this._data.total,time:this._data.time})}hasMore(){return this.isMore()}isMore(){return C.isNumber(this._data?.next)}getTotal(){return V.toInteger(this._data?.total)}getStatus(){return this._status}getQuery(){return this._query}async fetchNext(e){const t=await this.getNext(e);return t===!1?null:t}async getNext(e){if(!this.isMore()||!this.isSuccess)return!1;const t=this.#n();return e.call(t.method,t.params,t.start)}#n(){return{...this._query,start:V.toInteger(this._data.next)}}setData(){throw new ReferenceError("AjaxResult does not allow data modification")}}let _c=class{#e;#t;#r;_logger=null;constructor(){this.#e=Ni,this.#r=0,this.#t=0}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}get params(){return{...this.#e}}set params(e){this.#e=e,this.getLogger().log("new restriction manager params",e)}check(e=""){return new Promise(t=>{if(this.#s(),this.#o())return this.getLogger().log(`>> no sleep >>> ${e}`,this.#n()),this.#i(),t(null);{const n=i=>{this.getLogger().info(`>> go sleep >>> ${e}`,this.#n()),setTimeout(()=>{i()},this.#e.sleep)},s=()=>{if(this.#s(),this.#o())return this.getLogger().info(`<< stop sleep <<< ${e}`,this.#n()),this.#i(),t(null);n(s)};n(s)}})}#n(){return`${this.#r.toFixed(4)} from ${this.#e.amount}`}#s(){this.#t>0&&(this.#r-=(Date.now()-this.#t)*this.#e.speed,this.#r<0&&(this.#r=0)),this.#t=Date.now()}#i(){this.#r++}#o(){return this.#r<this.#e.amount}};const kc="X-Request-ID",vc="bx24_request_id",Ec="bx24_sdk_ver",Tc="bx24_sdk_type";let Oc=class{getQueryStringParameterName(){return vc}getQueryStringSdkParameterName(){return Ec}getQueryStringSdkTypeParameterName(){return Tc}generate(){return V.getUuidRfc4122()}getRequestId(){return this.generate()}getHeaderFieldName(){return kc}};function Ui(r,e){return function(){return r.apply(e,arguments)}}const{toString:Ac}=Object.prototype,{getPrototypeOf:_n}=Object,{iterator:Or,toStringTag:$i}=Symbol,Ar=(r=>e=>{const t=Ac.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),ze=r=>(r=r.toLowerCase(),e=>Ar(e)===r),Ir=r=>e=>typeof e===r,{isArray:Mt}=Array,Ft=Ir("undefined");function Xt(r){return r!==null&&!Ft(r)&&r.constructor!==null&&!Ft(r.constructor)&&Oe(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Wi=ze("ArrayBuffer");function Ic(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Wi(r.buffer),e}const Cc=Ir("string"),Oe=Ir("function"),Vi=Ir("number"),er=r=>r!==null&&typeof r=="object",Nc=r=>r===!0||r===!1,Cr=r=>{if(Ar(r)!=="object")return!1;const e=_n(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!($i in r)&&!(Or in r)},Rc=r=>{if(!er(r)||Xt(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},Lc=ze("Date"),Pc=ze("File"),Dc=ze("Blob"),Mc=ze("FileList"),Fc=r=>er(r)&&Oe(r.pipe),xc=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Oe(r.append)&&((e=Ar(r))==="formdata"||e==="object"&&Oe(r.toString)&&r.toString()==="[object FormData]"))},jc=ze("URLSearchParams"),[Bc,Uc,$c,Wc]=["ReadableStream","Request","Response","Headers"].map(ze),Vc=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function tr(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,s;if(typeof r!="object"&&(r=[r]),Mt(r))for(n=0,s=r.length;n<s;n++)e.call(null,r[n],n,r);else{if(Xt(r))return;const i=t?Object.getOwnPropertyNames(r):Object.keys(r),o=i.length;let l;for(n=0;n<o;n++)l=i[n],e.call(null,r[l],l,r)}}function qi(r,e){if(Xt(r))return null;e=e.toLowerCase();const t=Object.keys(r);let n=t.length,s;for(;n-- >0;)if(s=t[n],e===s.toLowerCase())return s;return null}const wt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,zi=r=>!Ft(r)&&r!==wt;function kn(){const{caseless:r,skipUndefined:e}=zi(this)&&this||{},t={},n=(s,i)=>{const o=r&&qi(t,i)||i;Cr(t[o])&&Cr(s)?t[o]=kn(t[o],s):Cr(s)?t[o]=kn({},s):Mt(s)?t[o]=s.slice():(!e||!Ft(s))&&(t[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&tr(arguments[s],n);return t}const qc=(r,e,t,{allOwnKeys:n}={})=>(tr(e,(s,i)=>{t&&Oe(s)?r[i]=Ui(s,t):r[i]=s},{allOwnKeys:n}),r),zc=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),Hc=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},Jc=(r,e,t,n)=>{let s,i,o;const l={};if(e=e||{},r==null)return e;do{for(s=Object.getOwnPropertyNames(r),i=s.length;i-- >0;)o=s[i],(!n||n(o,r,e))&&!l[o]&&(e[o]=r[o],l[o]=!0);r=t!==!1&&_n(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Zc=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const n=r.indexOf(e,t);return n!==-1&&n===t},Gc=r=>{if(!r)return null;if(Mt(r))return r;let e=r.length;if(!Vi(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},Yc=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&_n(Uint8Array)),Kc=(r,e)=>{const n=(r&&r[Or]).call(r);let s;for(;(s=n.next())&&!s.done;){const i=s.value;e.call(r,i[0],i[1])}},Qc=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},Xc=ze("HTMLFormElement"),eu=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,s){return n.toUpperCase()+s}),Hi=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),tu=ze("RegExp"),Ji=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};tr(t,(s,i)=>{let o;(o=e(s,i,r))!==!1&&(n[i]=o||s)}),Object.defineProperties(r,n)},ru=r=>{Ji(r,(e,t)=>{if(Oe(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(Oe(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},nu=(r,e)=>{const t={},n=s=>{s.forEach(i=>{t[i]=!0})};return Mt(r)?n(r):n(String(r).split(e)),t},su=()=>{},iu=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function ou(r){return!!(r&&Oe(r.append)&&r[$i]==="FormData"&&r[Or])}const au=r=>{const e=new Array(10),t=(n,s)=>{if(er(n)){if(e.indexOf(n)>=0)return;if(Xt(n))return n;if(!("toJSON"in n)){e[s]=n;const i=Mt(n)?[]:{};return tr(n,(o,l)=>{const a=t(o,s+1);!Ft(a)&&(i[l]=a)}),e[s]=void 0,i}}return n};return t(r,0)},lu=ze("AsyncFunction"),cu=r=>r&&(er(r)||Oe(r))&&Oe(r.then)&&Oe(r.catch),Zi=((r,e)=>r?setImmediate:e?((t,n)=>(wt.addEventListener("message",({source:s,data:i})=>{s===wt&&i===t&&n.length&&n.shift()()},!1),s=>{n.push(s),wt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Oe(wt.postMessage)),uu=typeof queueMicrotask<"u"?queueMicrotask.bind(wt):typeof process<"u"&&process.nextTick||Zi,k={isArray:Mt,isArrayBuffer:Wi,isBuffer:Xt,isFormData:xc,isArrayBufferView:Ic,isString:Cc,isNumber:Vi,isBoolean:Nc,isObject:er,isPlainObject:Cr,isEmptyObject:Rc,isReadableStream:Bc,isRequest:Uc,isResponse:$c,isHeaders:Wc,isUndefined:Ft,isDate:Lc,isFile:Pc,isBlob:Dc,isRegExp:tu,isFunction:Oe,isStream:Fc,isURLSearchParams:jc,isTypedArray:Yc,isFileList:Mc,forEach:tr,merge:kn,extend:qc,trim:Vc,stripBOM:zc,inherits:Hc,toFlatObject:Jc,kindOf:Ar,kindOfTest:ze,endsWith:Zc,toArray:Gc,forEachEntry:Kc,matchAll:Qc,isHTMLForm:Xc,hasOwnProperty:Hi,hasOwnProp:Hi,reduceDescriptors:Ji,freezeMethods:ru,toObjectSet:nu,toCamelCase:eu,noop:su,toFiniteNumber:iu,findKey:qi,global:wt,isContextDefined:zi,isSpecCompliantForm:ou,toJSONObject:au,isAsyncFn:lu,isThenable:cu,setImmediate:Zi,asap:uu,isIterable:r=>r!=null&&Oe(r[Or])};function H(r,e,t,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}k.inherits(H,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:k.toJSONObject(this.config),code:this.code,status:this.status}}});const Gi=H.prototype,Yi={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Yi[r]={value:r}}),Object.defineProperties(H,Yi),Object.defineProperty(Gi,"isAxiosError",{value:!0}),H.from=(r,e,t,n,s,i)=>{const o=Object.create(Gi);k.toFlatObject(r,o,function(c){return c!==Error.prototype},u=>u!=="isAxiosError");const l=r&&r.message?r.message:"Error",a=e==null&&r?r.code:e;return H.call(o,l,a,t,n,s),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",i&&Object.assign(o,i),o};const hu=null;function vn(r){return k.isPlainObject(r)||k.isArray(r)}function Ki(r){return k.endsWith(r,"[]")?r.slice(0,-2):r}function Qi(r,e,t){return r?r.concat(e).map(function(s,i){return s=Ki(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function fu(r){return k.isArray(r)&&!r.some(vn)}const du=k.toFlatObject(k,{},null,function(e){return/^is[A-Z]/.test(e)});function Nr(r,e,t){if(!k.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=k.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,m){return!k.isUndefined(m[g])});const n=t.metaTokens,s=t.visitor||c,i=t.dots,o=t.indexes,a=(t.Blob||typeof Blob<"u"&&Blob)&&k.isSpecCompliantForm(e);if(!k.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(k.isDate(d))return d.toISOString();if(k.isBoolean(d))return d.toString();if(!a&&k.isBlob(d))throw new H("Blob is not supported. Use a Buffer instead.");return k.isArrayBuffer(d)||k.isTypedArray(d)?a&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,g,m){let y=d;if(d&&!m&&typeof d=="object"){if(k.endsWith(g,"{}"))g=n?g:g.slice(0,-2),d=JSON.stringify(d);else if(k.isArray(d)&&fu(d)||(k.isFileList(d)||k.endsWith(g,"[]"))&&(y=k.toArray(d)))return g=Ki(g),y.forEach(function(_,b){!(k.isUndefined(_)||_===null)&&e.append(o===!0?Qi([g],b,i):o===null?g:g+"[]",u(_))}),!1}return vn(d)?!0:(e.append(Qi(m,g,i),u(d)),!1)}const f=[],h=Object.assign(du,{defaultVisitor:c,convertValue:u,isVisitable:vn});function p(d,g){if(!k.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(d),k.forEach(d,function(y,w){(!(k.isUndefined(y)||y===null)&&s.call(e,y,k.isString(w)?w.trim():w,g,h))===!0&&p(y,g?g.concat(w):[w])}),f.pop()}}if(!k.isObject(r))throw new TypeError("data must be an object");return p(r),e}function Xi(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function En(r,e){this._pairs=[],r&&Nr(r,this,e)}const eo=En.prototype;eo.append=function(e,t){this._pairs.push([e,t])},eo.toString=function(e){const t=e?function(n){return e.call(this,n,Xi)}:Xi;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function pu(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function to(r,e,t){if(!e)return r;const n=t&&t.encode||pu;k.isFunction(t)&&(t={serialize:t});const s=t&&t.serialize;let i;if(s?i=s(e,t):i=k.isURLSearchParams(e)?e.toString():new En(e,t).toString(n),i){const o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+i}return r}class ro{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){k.forEach(this.handlers,function(n){n!==null&&e(n)})}}const no={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:En,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Tn=typeof window<"u"&&typeof document<"u",On=typeof navigator=="object"&&navigator||void 0,mu=Tn&&(!On||["ReactNative","NativeScript","NS"].indexOf(On.product)<0),yu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wu=Tn&&window.location.href||"http://localhost",ke={...{__proto__:null,hasBrowserEnv:Tn,hasStandardBrowserEnv:mu,hasStandardBrowserWebWorkerEnv:yu,navigator:On,origin:wu},...gu};function bu(r,e){return Nr(r,new ke.classes.URLSearchParams,{visitor:function(t,n,s,i){return ke.isNode&&k.isBuffer(t)?(this.append(n,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...e})}function Su(r){return k.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function _u(r){const e={},t=Object.keys(r);let n;const s=t.length;let i;for(n=0;n<s;n++)i=t[n],e[i]=r[i];return e}function so(r){function e(t,n,s,i){let o=t[i++];if(o==="__proto__")return!0;const l=Number.isFinite(+o),a=i>=t.length;return o=!o&&k.isArray(s)?s.length:o,a?(k.hasOwnProp(s,o)?s[o]=[s[o],n]:s[o]=n,!l):((!s[o]||!k.isObject(s[o]))&&(s[o]=[]),e(t,n,s[o],i)&&k.isArray(s[o])&&(s[o]=_u(s[o])),!l)}if(k.isFormData(r)&&k.isFunction(r.entries)){const t={};return k.forEachEntry(r,(n,s)=>{e(Su(n),s,t,0)}),t}return null}function ku(r,e,t){if(k.isString(r))try{return(e||JSON.parse)(r),k.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}const rr={transitional:no,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",s=n.indexOf("application/json")>-1,i=k.isObject(e);if(i&&k.isHTMLForm(e)&&(e=new FormData(e)),k.isFormData(e))return s?JSON.stringify(so(e)):e;if(k.isArrayBuffer(e)||k.isBuffer(e)||k.isStream(e)||k.isFile(e)||k.isBlob(e)||k.isReadableStream(e))return e;if(k.isArrayBufferView(e))return e.buffer;if(k.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return bu(e,this.formSerializer).toString();if((l=k.isFileList(e))||n.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return Nr(l?{"files[]":e}:e,a&&new a,this.formSerializer)}}return i||s?(t.setContentType("application/json",!1),ku(e)):e}],transformResponse:[function(e){const t=this.transitional||rr.transitional,n=t&&t.forcedJSONParsing,s=this.responseType==="json";if(k.isResponse(e)||k.isReadableStream(e))return e;if(e&&k.isString(e)&&(n&&!this.responseType||s)){const o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(l){if(o)throw l.name==="SyntaxError"?H.from(l,H.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};k.forEach(["delete","get","head","post","put","patch"],r=>{rr.headers[r]={}});const vu=k.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Eu=r=>{const e={};let t,n,s;return r&&r.split(`
8
8
  `).forEach(function(o){s=o.indexOf(":"),t=o.substring(0,s).trim().toLowerCase(),n=o.substring(s+1).trim(),!(!t||e[t]&&vu[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},io=Symbol("internals");function nr(r){return r&&String(r).trim().toLowerCase()}function Rr(r){return r===!1||r==null?r:k.isArray(r)?r.map(Rr):String(r)}function Tu(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}const Ou=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function An(r,e,t,n,s){if(k.isFunction(n))return n.call(this,e,t);if(s&&(e=t),!!k.isString(e)){if(k.isString(n))return e.indexOf(n)!==-1;if(k.isRegExp(n))return n.test(e)}}function Au(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Iu(r,e){const t=k.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(s,i,o){return this[n].call(this,e,s,i,o)},configurable:!0})})}let Ae=class{constructor(e){e&&this.set(e)}set(e,t,n){const s=this;function i(l,a,u){const c=nr(a);if(!c)throw new Error("header name must be a non-empty string");const f=k.findKey(s,c);(!f||s[f]===void 0||u===!0||u===void 0&&s[f]!==!1)&&(s[f||a]=Rr(l))}const o=(l,a)=>k.forEach(l,(u,c)=>i(u,c,a));if(k.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(k.isString(e)&&(e=e.trim())&&!Ou(e))o(Eu(e),t);else if(k.isObject(e)&&k.isIterable(e)){let l={},a,u;for(const c of e){if(!k.isArray(c))throw TypeError("Object iterator must return a key-value pair");l[u=c[0]]=(a=l[u])?k.isArray(a)?[...a,c[1]]:[a,c[1]]:c[1]}o(l,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=nr(e),e){const n=k.findKey(this,e);if(n){const s=this[n];if(!t)return s;if(t===!0)return Tu(s);if(k.isFunction(t))return t.call(this,s,n);if(k.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=nr(e),e){const n=k.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||An(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let s=!1;function i(o){if(o=nr(o),o){const l=k.findKey(n,o);l&&(!t||An(n,n[l],l,t))&&(delete n[l],s=!0)}}return k.isArray(e)?e.forEach(i):i(e),s}clear(e){const t=Object.keys(this);let n=t.length,s=!1;for(;n--;){const i=t[n];(!e||An(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){const t=this,n={};return k.forEach(this,(s,i)=>{const o=k.findKey(n,i);if(o){t[o]=Rr(s),delete t[i];return}const l=e?Au(i):String(i).trim();l!==i&&delete t[i],t[l]=Rr(s),n[l]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return k.forEach(this,(n,s)=>{n!=null&&n!==!1&&(t[s]=e&&k.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
9
9
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(s=>n.set(s)),n}static accessor(e){const n=(this[io]=this[io]={accessors:{}}).accessors,s=this.prototype;function i(o){const l=nr(o);n[l]||(Iu(s,o),n[l]=!0)}return k.isArray(e)?e.forEach(i):i(e),this}};Ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),k.reduceDescriptors(Ae.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),k.freezeMethods(Ae);function In(r,e){const t=this||rr,n=e||t,s=Ae.from(n.headers);let i=n.data;return k.forEach(r,function(l){i=l.call(t,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function oo(r){return!!(r&&r.__CANCEL__)}function xt(r,e,t){H.call(this,r??"canceled",H.ERR_CANCELED,e,t),this.name="CanceledError"}k.inherits(xt,H,{__CANCEL__:!0});function ao(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new H("Request failed with status code "+t.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Cu(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function Nu(r,e){r=r||10;const t=new Array(r),n=new Array(r);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(a){const u=Date.now(),c=n[i];o||(o=u),t[s]=a,n[s]=u;let f=i,h=0;for(;f!==s;)h+=t[f++],f=f%r;if(s=(s+1)%r,s===i&&(i=(i+1)%r),u-o<e)return;const p=c&&u-c;return p?Math.round(h*1e3/p):void 0}}function Ru(r,e){let t=0,n=1e3/e,s,i;const o=(u,c=Date.now())=>{t=c,s=null,i&&(clearTimeout(i),i=null),r(...u)};return[(...u)=>{const c=Date.now(),f=c-t;f>=n?o(u,c):(s=u,i||(i=setTimeout(()=>{i=null,o(s)},n-f)))},()=>s&&o(s)]}const Lr=(r,e,t=3)=>{let n=0;const s=Nu(50,250);return Ru(i=>{const o=i.loaded,l=i.lengthComputable?i.total:void 0,a=o-n,u=s(a),c=o<=l;n=o;const f={loaded:o,total:l,progress:l?o/l:void 0,bytes:a,rate:u||void 0,estimated:u&&l&&c?(l-o)/u:void 0,event:i,lengthComputable:l!=null,[e?"download":"upload"]:!0};r(f)},t)},lo=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},co=r=>(...e)=>k.asap(()=>r(...e)),Lu=ke.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,ke.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,Pu=ke.hasStandardBrowserEnv?{write(r,e,t,n,s,i){const o=[r+"="+encodeURIComponent(e)];k.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),k.isString(n)&&o.push("path="+n),k.isString(s)&&o.push("domain="+s),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(r){const e=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Du(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Mu(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function uo(r,e,t){let n=!Du(e);return r&&(n||t==!1)?Mu(r,e):e}const ho=r=>r instanceof Ae?{...r}:r;function bt(r,e){e=e||{};const t={};function n(u,c,f,h){return k.isPlainObject(u)&&k.isPlainObject(c)?k.merge.call({caseless:h},u,c):k.isPlainObject(c)?k.merge({},c):k.isArray(c)?c.slice():c}function s(u,c,f,h){if(k.isUndefined(c)){if(!k.isUndefined(u))return n(void 0,u,f,h)}else return n(u,c,f,h)}function i(u,c){if(!k.isUndefined(c))return n(void 0,c)}function o(u,c){if(k.isUndefined(c)){if(!k.isUndefined(u))return n(void 0,u)}else return n(void 0,c)}function l(u,c,f){if(f in e)return n(u,c);if(f in r)return n(void 0,u)}const a={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(u,c,f)=>s(ho(u),ho(c),f,!0)};return k.forEach(Object.keys({...r,...e}),function(c){const f=a[c]||s,h=f(r[c],e[c],c);k.isUndefined(h)&&f!==l||(t[c]=h)}),t}const fo=r=>{const e=bt({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:l}=e;if(e.headers=o=Ae.from(o),e.url=to(uo(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),k.isFormData(t)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(k.isFunction(t.getHeaders)){const a=t.getHeaders(),u=["content-type","content-length"];Object.entries(a).forEach(([c,f])=>{u.includes(c.toLowerCase())&&o.set(c,f)})}}if(ke.hasStandardBrowserEnv&&(n&&k.isFunction(n)&&(n=n(e)),n||n!==!1&&Lu(e.url))){const a=s&&i&&Pu.read(i);a&&o.set(s,a)}return e},Fu=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const s=fo(r);let i=s.data;const o=Ae.from(s.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:u}=s,c,f,h,p,d;function g(){p&&p(),d&&d(),s.cancelToken&&s.cancelToken.unsubscribe(c),s.signal&&s.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(s.method.toUpperCase(),s.url,!0),m.timeout=s.timeout;function y(){if(!m)return;const _=Ae.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),E={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:_,config:r,request:m};ao(function(v){t(v),g()},function(v){n(v),g()},E),m=null}"onloadend"in m?m.onloadend=y:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(y)},m.onabort=function(){m&&(n(new H("Request aborted",H.ECONNABORTED,r,m)),m=null)},m.onerror=function(b){const E=b&&b.message?b.message:"Network Error",S=new H(E,H.ERR_NETWORK,r,m);S.event=b||null,n(S),m=null},m.ontimeout=function(){let b=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const E=s.transitional||no;s.timeoutErrorMessage&&(b=s.timeoutErrorMessage),n(new H(b,E.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,r,m)),m=null},i===void 0&&o.setContentType(null),"setRequestHeader"in m&&k.forEach(o.toJSON(),function(b,E){m.setRequestHeader(E,b)}),k.isUndefined(s.withCredentials)||(m.withCredentials=!!s.withCredentials),l&&l!=="json"&&(m.responseType=s.responseType),u&&([h,d]=Lr(u,!0),m.addEventListener("progress",h)),a&&m.upload&&([f,p]=Lr(a),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",p)),(s.cancelToken||s.signal)&&(c=_=>{m&&(n(!_||_.type?new xt(null,r,m):_),m.abort(),m=null)},s.cancelToken&&s.cancelToken.subscribe(c),s.signal&&(s.signal.aborted?c():s.signal.addEventListener("abort",c)));const w=Cu(s.url);if(w&&ke.protocols.indexOf(w)===-1){n(new H("Unsupported protocol "+w+":",H.ERR_BAD_REQUEST,r));return}m.send(i||null)})},xu=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,s;const i=function(u){if(!s){s=!0,l();const c=u instanceof Error?u:this.reason;n.abort(c instanceof H?c:new xt(c instanceof Error?c.message:c))}};let o=e&&setTimeout(()=>{o=null,i(new H(`timeout ${e} of ms exceeded`,H.ETIMEDOUT))},e);const l=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),r=null)};r.forEach(u=>u.addEventListener("abort",i));const{signal:a}=n;return a.unsubscribe=()=>k.asap(l),a}},ju=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let n=0,s;for(;n<t;)s=n+e,yield r.slice(n,s),n=s},Bu=async function*(r,e){for await(const t of Uu(r))yield*ju(t,e)},Uu=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},po=(r,e,t,n)=>{const s=Bu(r,e);let i=0,o,l=a=>{o||(o=!0,n&&n(a))};return new ReadableStream({async pull(a){try{const{done:u,value:c}=await s.next();if(u){l(),a.close();return}let f=c.byteLength;if(t){let h=i+=f;t(h)}a.enqueue(new Uint8Array(c))}catch(u){throw l(u),u}},cancel(a){return l(a),s.return()}},{highWaterMark:2})},go=64*1024,{isFunction:Pr}=k,$u=(({Request:r,Response:e})=>({Request:r,Response:e}))(k.global),{ReadableStream:mo,TextEncoder:yo}=k.global,wo=(r,...e)=>{try{return!!r(...e)}catch{return!1}},Wu=r=>{r=k.merge.call({skipUndefined:!0},$u,r);const{fetch:e,Request:t,Response:n}=r,s=e?Pr(e):typeof fetch=="function",i=Pr(t),o=Pr(n);if(!s)return!1;const l=s&&Pr(mo),a=s&&(typeof yo=="function"?(d=>g=>d.encode(g))(new yo):async d=>new Uint8Array(await new t(d).arrayBuffer())),u=i&&l&&wo(()=>{let d=!1;const g=new t(ke.origin,{body:new mo,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!g}),c=o&&l&&wo(()=>k.isReadableStream(new n("").body)),f={stream:c&&(d=>d.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!f[d]&&(f[d]=(g,m)=>{let y=g&&g[d];if(y)return y.call(g);throw new H(`Response type '${d}' is not supported`,H.ERR_NOT_SUPPORT,m)})});const h=async d=>{if(d==null)return 0;if(k.isBlob(d))return d.size;if(k.isSpecCompliantForm(d))return(await new t(ke.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(k.isArrayBufferView(d)||k.isArrayBuffer(d))return d.byteLength;if(k.isURLSearchParams(d)&&(d=d+""),k.isString(d))return(await a(d)).byteLength},p=async(d,g)=>{const m=k.toFiniteNumber(d.getContentLength());return m??h(g)};return async d=>{let{url:g,method:m,data:y,signal:w,cancelToken:_,timeout:b,onDownloadProgress:E,onUploadProgress:S,responseType:v,headers:L,withCredentials:j="same-origin",fetchOptions:x}=fo(d),J=e||fetch;v=v?(v+"").toLowerCase():"text";let ue=xu([w,_&&_.toAbortSignal()],b),$=null;const Z=ue&&ue.unsubscribe&&(()=>{ue.unsubscribe()});let B;try{if(S&&u&&m!=="get"&&m!=="head"&&(B=await p(L,y))!==0){let ye=new t(g,{method:"POST",body:y,duplex:"half"}),q;if(k.isFormData(y)&&(q=ye.headers.get("content-type"))&&L.setContentType(q),ye.body){const[te,re]=lo(B,Lr(co(S)));y=po(ye.body,go,te,re)}}k.isString(j)||(j=j?"include":"omit");const X=i&&"credentials"in t.prototype,ie={...x,signal:ue,method:m.toUpperCase(),headers:L.normalize().toJSON(),body:y,duplex:"half",credentials:X?j:void 0};$=i&&new t(g,ie);let M=await(i?J($,x):J(g,ie));const He=c&&(v==="stream"||v==="response");if(c&&(E||He&&Z)){const ye={};["status","statusText","headers"].forEach(oe=>{ye[oe]=M[oe]});const q=k.toFiniteNumber(M.headers.get("content-length")),[te,re]=E&&lo(q,Lr(co(E),!0))||[];M=new n(po(M.body,go,te,()=>{re&&re(),Z&&Z()}),ye)}v=v||"text";let st=await f[k.findKey(f,v)||"text"](M,d);return!He&&Z&&Z(),await new Promise((ye,q)=>{ao(ye,q,{data:st,headers:Ae.from(M.headers),status:M.status,statusText:M.statusText,config:d,request:$})})}catch(X){throw Z&&Z(),X&&X.name==="TypeError"&&/Load failed|fetch/i.test(X.message)?Object.assign(new H("Network Error",H.ERR_NETWORK,d,$),{cause:X.cause||X}):H.from(X,X&&X.code,d,$)}}},Vu=new Map,bo=r=>{let e=r?r.env:{};const{fetch:t,Request:n,Response:s}=e,i=[n,s,t];let o=i.length,l=o,a,u,c=Vu;for(;l--;)a=i[l],u=c.get(a),u===void 0&&c.set(a,u=l?new Map:Wu(e)),c=u;return u};bo();const Cn={http:hu,xhr:Fu,fetch:{get:bo}};k.forEach(Cn,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const So=r=>`- ${r}`,qu=r=>k.isFunction(r)||r===null||r===!1,_o={getAdapter:(r,e)=>{r=k.isArray(r)?r:[r];const{length:t}=r;let n,s;const i={};for(let o=0;o<t;o++){n=r[o];let l;if(s=n,!qu(n)&&(s=Cn[(l=String(n)).toLowerCase()],s===void 0))throw new H(`Unknown adapter '${l}'`);if(s&&(k.isFunction(s)||(s=s.get(e))))break;i[l||"#"+o]=s}if(!s){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let l=t?o.length>1?`since :
10
10
  `+o.map(So).join(`
11
11
  `):" "+So(o[0]):"as no adapter specified";throw new H("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return s},adapters:Cn};function Nn(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new xt(null,r)}function ko(r){return Nn(r),r.headers=Ae.from(r.headers),r.data=In.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),_o.getAdapter(r.adapter||rr.adapter,r)(r).then(function(n){return Nn(r),n.data=In.call(r,r.transformResponse,n),n.headers=Ae.from(n.headers),n},function(n){return oo(n)||(Nn(r),n&&n.response&&(n.response.data=In.call(r,r.transformResponse,n.response),n.response.headers=Ae.from(n.response.headers))),Promise.reject(n)})}const vo="1.12.2",Dr={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{Dr[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const Eo={};Dr.transitional=function(e,t,n){function s(i,o){return"[Axios v"+vo+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return(i,o,l)=>{if(e===!1)throw new H(s(o," has been removed"+(t?" in "+t:"")),H.ERR_DEPRECATED);return t&&!Eo[o]&&(Eo[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,l):!0}},Dr.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function zu(r,e,t){if(typeof r!="object")throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let s=n.length;for(;s-- >0;){const i=n[s],o=e[i];if(o){const l=r[i],a=l===void 0||o(l,i,r);if(a!==!0)throw new H("option "+i+" must be "+a,H.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new H("Unknown option "+i,H.ERR_BAD_OPTION)}}const Mr={assertOptions:zu,validators:Dr},Ze=Mr.validators;let St=class{constructor(e){this.defaults=e||{},this.interceptors={request:new ro,response:new ro}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
12
- `+i):n.stack=i}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=bt(this.defaults,t);const{transitional:n,paramsSerializer:s,headers:i}=t;n!==void 0&&Mr.assertOptions(n,{silentJSONParsing:Ze.transitional(Ze.boolean),forcedJSONParsing:Ze.transitional(Ze.boolean),clarifyTimeoutError:Ze.transitional(Ze.boolean)},!1),s!=null&&(k.isFunction(s)?t.paramsSerializer={serialize:s}:Mr.assertOptions(s,{encode:Ze.function,serialize:Ze.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Mr.assertOptions(t,{baseUrl:Ze.spelling("baseURL"),withXsrfToken:Ze.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&k.merge(i.common,i[t.method]);i&&k.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),t.headers=Ae.concat(o,i);const l=[];let a=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(a=a&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let c,f=0,h;if(!a){const d=[ko.bind(this),void 0];for(d.unshift(...l),d.push(...u),h=d.length,c=Promise.resolve(t);f<h;)c=c.then(d[f++],d[f++]);return c}h=l.length;let p=t;for(;f<h;){const d=l[f++],g=l[f++];try{p=d(p)}catch(m){g.call(this,m);break}}try{c=ko.call(this,p)}catch(d){return Promise.reject(d)}for(f=0,h=u.length;f<h;)c=c.then(u[f++],u[f++]);return c}getUri(e){e=bt(this.defaults,e);const t=uo(e.baseURL,e.url,e.allowAbsoluteUrls);return to(t,e.params,e.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(e){St.prototype[e]=function(t,n){return this.request(bt(n||{},{method:e,url:t,data:(n||{}).data}))}}),k.forEach(["post","put","patch"],function(e){function t(n){return function(i,o,l){return this.request(bt(l||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}St.prototype[e]=t(),St.prototype[e+"Form"]=t(!0)});let Hu=class oa{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{n.subscribe(l),i=l}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,l){n.reason||(n.reason=new xt(i,o,l),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new oa(function(s){e=s}),cancel:e}}};function Ju(r){return function(t){return r.apply(null,t)}}function Zu(r){return k.isObject(r)&&r.isAxiosError===!0}const Rn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Rn).forEach(([r,e])=>{Rn[e]=r});function To(r){const e=new St(r),t=Ui(St.prototype.request,e);return k.extend(t,St.prototype,e,{allOwnKeys:!0}),k.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return To(bt(r,s))},t}const ce=To(rr);ce.Axios=St,ce.CanceledError=xt,ce.CancelToken=Hu,ce.isCancel=oo,ce.VERSION=vo,ce.toFormData=Nr,ce.AxiosError=H,ce.Cancel=ce.CanceledError,ce.all=function(e){return Promise.all(e)},ce.spread=Ju,ce.isAxiosError=Zu,ce.mergeConfig=bt,ce.AxiosHeaders=Ae,ce.formToJSON=r=>so(k.isHTMLForm(r)?new FormData(r):r),ce.getAdapter=_o.getAdapter,ce.HttpStatusCode=Rn,ce.default=ce;const{Axios:kf,AxiosError:Ln,CanceledError:vf,isCancel:Ef,CancelToken:Tf,VERSION:Of,all:Af,Cancel:If,isAxiosError:Cf,spread:Nf,toFormData:Rf,AxiosHeaders:Lf,HttpStatusCode:Pf,formToJSON:Df,getAdapter:Mf,mergeConfig:Ff}=ce,Gu=String.prototype.replace,Yu=/%20/g,Oo={RFC1738:"RFC1738",RFC3986:"RFC3986"},Ku={RFC1738:function(r){return Gu.call(r,Yu,"+")},RFC3986:function(r){return String(r)}},Qu=Oo.RFC1738,Xu=Oo.RFC3986,Pn=Object.prototype.hasOwnProperty,_t=Array.isArray,Ge=(function(){const r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})(),eh=function(e){for(;e.length>1;){const t=e.pop(),n=t.obj[t.prop];if(_t(n)){const s=[];for(let i=0;i<n.length;++i)typeof n[i]<"u"&&s.push(n[i]);t.obj[t.prop]=s}}},th=function(e,t){const n=t&&t.plainObjects?Object.create(null):{};for(let s=0;s<e.length;++s)typeof e[s]<"u"&&(n[s]=e[s]);return n},rh=function r(e,t,n){if(!t)return e;if(typeof t!="object"){if(_t(e))e.push(t);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!Pn.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);let s=e;return _t(e)&&!_t(t)&&(s=th(e,n)),_t(e)&&_t(t)?(t.forEach(function(i,o){if(Pn.call(e,o)){const l=e[o];l&&typeof l=="object"&&i&&typeof i=="object"?e[o]=r(l,i,n):e.push(i)}else e[o]=i}),e):Object.keys(t).reduce(function(i,o){const l=t[o];return Pn.call(i,o)?i[o]=r(i[o],l,n):i[o]=l,i},s)},nh=function(r,e,t){const n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Dn=1024,sh=function(e,t,n,s,i){if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let l="";for(let a=0;a<o.length;a+=Dn){const u=o.length>=Dn?o.slice(a,a+Dn):o,c=[];for(let f=0;f<u.length;++f){let h=u.charCodeAt(f);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||i===Qu&&(h===40||h===41)){c[c.length]=u.charAt(f);continue}if(h<128){c[c.length]=Ge[h];continue}if(h<2048){c[c.length]=Ge[192|h>>6]+Ge[128|h&63];continue}if(h<55296||h>=57344){c[c.length]=Ge[224|h>>12]+Ge[128|h>>6&63]+Ge[128|h&63];continue}f+=1,h=65536+((h&1023)<<10|u.charCodeAt(f)&1023),c[c.length]=Ge[240|h>>18]+Ge[128|h>>12&63]+Ge[128|h>>6&63]+Ge[128|h&63]}l+=c.join("")}return l},ih=function(e){const t=[{obj:{o:e},prop:"o"}],n=[];for(let s=0;s<t.length;++s){const i=t[s],o=i.obj[i.prop],l=Object.keys(o);for(let a=0;a<l.length;++a){const u=l[a],c=o[u];typeof c=="object"&&c!==null&&n.indexOf(c)===-1&&(t.push({obj:o,prop:u}),n.push(c))}}return eh(t),e},oh=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},ah=function(e,t){return[].concat(e,t)},Mn=function(e,t){if(_t(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)},lh={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},rt=Array.isArray,ch=Array.prototype.push,Ao=function(r,e){ch.apply(r,rt(e)?e:[e])},uh=Date.prototype.toISOString,Io=Xu,Fr={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:sh,encodeValuesOnly:!1,format:Io,formatter:Ku[Io],indices:!1,serializeDate:function(e){return uh.call(e)},skipNulls:!1,strictNullHandling:!1},hh=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Fn={},Co=function(e,t,n,s,i,o,l,a,u,c,f,h,p,d,g,m,y,w){let _=e,b=w,E=0,S=!1;for(;(b=b.get(Fn))!==void 0&&!S;){const J=b.get(e);if(E+=1,typeof J<"u"){if(J===E)throw new RangeError("Cyclic object value");S=!0}typeof b.get(Fn)>"u"&&(E=0)}if(typeof c=="function"?_=c(t,_):_ instanceof Date?_=p(_):n==="comma"&&rt(_)&&(_=Mn(_,function(J){return J instanceof Date?p(J):J})),_===null){if(o)return u&&!m?u(t,Fr.encoder,y,"key",d):t;_=""}if(hh(_)||oh(_)){if(u){const J=m?t:u(t,Fr.encoder,y,"key",d);return[g(J)+"="+g(u(_,Fr.encoder,y,"value",d))]}return[g(t)+"="+g(String(_))]}const v=[];if(typeof _>"u")return v;let L;if(n==="comma"&&rt(_))m&&u&&(_=Mn(_,u)),L=[{value:_.length>0?_.join(",")||null:void 0}];else if(rt(c))L=c;else{const J=Object.keys(_);L=f?J.sort(f):J}const j=a?t.replace(/\./g,"%2E"):t,x=s&&rt(_)&&_.length===1?j+"[]":j;if(i&&rt(_)&&_.length===0)return x+"[]";for(let J=0;J<L.length;++J){const ue=L[J],$=typeof ue=="object"&&typeof ue.value<"u"?ue.value:_[ue];if(l&&$===null)continue;const Z=h&&a?ue.replace(/\./g,"%2E"):ue,B=rt(_)?typeof n=="function"?n(x,Z):x:x+(h?"."+Z:"["+Z+"]");w.set(e,E);const X=new WeakMap;X.set(Fn,w),Ao(v,Co($,B,n,s,i,o,l,a,n==="comma"&&m&&rt(_)?null:u,c,f,h,p,d,g,m,y,X))}return v},fh=function(e){return Fr};function No(r,e){let t=r;const n=fh();let s,i;typeof n.filter=="function"?(i=n.filter,t=i("",t)):rt(n.filter)&&(i=n.filter,s=i);const o=[];if(typeof t!="object"||t===null)return"";const l=lh[n.arrayFormat],a=l==="comma"&&n.commaRoundTrip;s||(s=Object.keys(t)),n.sort&&s.sort(n.sort);const u=new WeakMap;for(let h=0;h<s.length;++h){const p=s[h];n.skipNulls&&t[p]===null||Ao(o,Co(t[p],p,l,a,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}const c=o.join(n.delimiter);let f=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),c.length>0?f+c:""}const xn=Object.prototype.hasOwnProperty,dh=Array.isArray,xr={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:nh,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},ph=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Ro=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},gh="utf8=%26%2310003%3B",mh="utf8=%E2%9C%93",yh=function(e,t){const n={__proto__:null},s=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,o=s.split(t.delimiter,i);let l=-1,a,u=t.charset;if(t.charsetSentinel)for(a=0;a<o.length;++a)o[a].indexOf("utf8=")===0&&(o[a]===mh?u="utf-8":o[a]===gh&&(u="iso-8859-1"),l=a,a=o.length);for(a=0;a<o.length;++a){if(a===l)continue;const c=o[a],f=c.indexOf("]="),h=f===-1?c.indexOf("="):f+1;let p,d;h===-1?(p=t.decoder(c,xr.decoder,u,"key"),d=t.strictNullHandling?null:""):(p=t.decoder(c.slice(0,h),xr.decoder,u,"key"),d=Mn(Ro(c.slice(h+1),t),function(m){return t.decoder(m,xr.decoder,u,"value")})),d&&t.interpretNumericEntities&&u==="iso-8859-1"&&(d=ph(d)),c.indexOf("[]=")>-1&&(d=dh(d)?[d]:d);const g=xn.call(n,p);g&&t.duplicates==="combine"?n[p]=ah(n[p],d):(!g||t.duplicates==="last")&&(n[p]=d)}return n},wh=function(r,e,t,n){let s=n?e:Ro(e,t);for(let i=r.length-1;i>=0;--i){let o;const l=r[i];if(l==="[]"&&t.parseArrays)o=t.allowEmptyArrays&&s===""?[]:[].concat(s);else{o=t.plainObjects?Object.create(null):{};const a=l.charAt(0)==="["&&l.charAt(l.length-1)==="]"?l.slice(1,-1):l,u=t.decodeDotInKeys?a.replace(/%2E/g,"."):a,c=parseInt(u,10);!t.parseArrays&&u===""?o={0:s}:!isNaN(c)&&l!==u&&String(c)===u&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(o=[],o[c]=s):u!=="__proto__"&&(o[u]=s)}s=o}return s},bh=function(e,t,n,s){if(!e)return;const i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,l=/(\[[^[\]]*])/g;let a=n.depth>0&&o.exec(i);const u=a?i.slice(0,a.index):i,c=[];if(u){if(!n.plainObjects&&xn.call(Object.prototype,u)&&!n.allowPrototypes)return;c.push(u)}let f=0;for(;n.depth>0&&(a=l.exec(i))!==null&&f<n.depth;){if(f+=1,!n.plainObjects&&xn.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(a[1])}return a&&c.push("["+i.slice(a.index)+"]"),wh(c,t,n,s)},Sh=function(e){return xr};function Lo(r,e){const t=Sh();if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};const n=typeof r=="string"?yh(r,t):r;let s=t.plainObjects?Object.create(null):{};const i=Object.keys(n);for(let o=0;o<i.length;++o){const l=i[o],a=bh(l,n[l],t,typeof r=="string");s=rh(s,a,t)}return t.allowSparse===!0?s:ih(s)}class jn{#e;#t;#r;#n;_logger=null;_loggerSystem=null;#s="";#o=!1;#i="";constructor(e,t,n){const s={};this.#e=ce.create({baseURL:e,headers:{...s,...n?n.headers:{}},...n&&{...n,headers:void 0}}),this.#t=t,this.#r=new _c,this.#n=new Oc}setLogger(e){this._logger=e,this.#r.setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}getSystemLogger(){return this._loggerSystem===null&&(this._loggerSystem=we.build("SystemLogger"),this._loggerSystem.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!0,[I.warn]:!0,[I.error]:!0,[I.trace]:!1})),this._loggerSystem}setRestrictionManagerParams(e){this.#r.params=e}getRestrictionManagerParams(){return this.#r.params}setLogTag(e){this.#s=e}clearLogTag(){this.#s=""}async batch(e,t=!0,n=!1){return Array.isArray(e)?this.#c(e,t,n):this.#l(e,t,n)}async#l(e,t=!0,n=!1){const s={};let i=0;const o=(l,a)=>{let u=null,c=null;l.method?(u=l.method??null,c=l?.params??null):Array.isArray(l)&&l.length>0&&(u=l[0]??null,c=l[1]??null),u&&(i++,s[a]=u+"?"+No(c))};for(const[l,a]of Object.entries(e))o(a,l);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u={},c=(d,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=d.split("?");u[g]=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()})}};for(const[d,g]of Object.entries(s))c(g,d);const f={},h=d=>d.hasError("base-error")?d.errors.get("base-error"):new xe({code:"0",description:d.getErrorMessages().join("; "),status:0,requestInfo:{method:d.getQuery().method,params:d.getQuery().params},originalError:d.getErrors().next().value}),p=new qe;for(const d of Object.keys(u)){const g=u[d];if(g.getStatus()!==200||!g.isSuccess){const m=h(g);if(!t&&!g.isSuccess){p.addError(m,d);continue}return Promise.reject(m)}f[d]=n?g:g.getData().result}return p.setData(f),Promise.resolve(p)})}async#c(e,t=!0,n=!1){const s=[];let i=0;const o=l=>{let a=null,u=null;if(l.method?(a=l.method??null,u=l?.params??null):Array.isArray(l)&&l.length>0&&(a=l[0]??null,u=l[1]??null),a){i++;const c=a+"?"+No(u);s.push(c)}};for(const[l,a]of e.entries())o(a);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u=[],c=(d,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=d.split("?"),y=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()});u.push(y)}};for(const[d,g]of s.entries())c(g,d);const f=[],h=d=>d.hasError("base-error")?d.errors.get("base-error"):new xe({code:"0",description:d.getErrorMessages().join("; "),status:0,requestInfo:{method:d.getQuery().method,params:d.getQuery().params},originalError:d.getErrors().next().value}),p=new qe;for(const d of u){if(d.getStatus()!==200||!d.isSuccess){const g=h(d);if(!t&&!d.isSuccess){p.addError(g);continue}return Promise.reject(g)}f.push(n?d:d.getData().result)}return p.setData(f),Promise.resolve(p)})}async call(e,t,n=0){let s=this.#t.getAuthData();return s===!1&&(s=await this.#t.refreshAuth()),await this.#r.check(),this.#o&&!this.isServerSide()&&C.isStringFilled(this.#i)&&this.getSystemLogger().warn(this.#i),this.#e.post(this.#u(e),this.#a(s,t,n)).then(i=>{const o=i.data;return Promise.resolve({status:i.status,payload:o})},async i=>{let o={error:i?.code||0,errorDescription:i?.message||""};if(i instanceof Ln&&i.response&&i.response.data&&!C.isUndefined(i.response.data.error)){const a=i.response.data;o={error:a.error,errorDescription:a.error_description}}const l=new xe({code:String(o.error),description:o.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:i});return l.status===401&&["expired_token","invalid_token"].includes(l.answerError.error)?(this.getLogger().info(`refreshAuth >> ${l.answerError.error} >>>`),s=await this.#t.refreshAuth(),await this.#r.check(),this.#e.post(this.#u(e),this.#a(s,t,n)).then(async a=>{const u=a.data;return Promise.resolve({status:a.status,payload:u})},async a=>{let u={error:a?.code||0,errorDescription:a?.message||""};if(a instanceof Ln&&a.response&&a.response.data){const f=a.response.data;u={error:f.error,errorDescription:f.error_description}}const c=new xe({code:String(u.error),description:u.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:a});return Promise.reject(c)})):Promise.reject(l)}).then(i=>{const o=new Tr({answer:i.payload,query:{method:e,params:t,start:n},status:i.status});return Promise.resolve(o)})}#a(e,t,n=0){const s=Object.assign({},t);return this.#s.length>0&&(s.logTag=this.#s),s.data&&s.data.start&&delete s.data.start,e.refresh_token!=="hook"&&(s.auth=e.access_token),s.start=n,s}#u(e){const t=`${encodeURIComponent(e)}.json`;if(e.includes("task."))return`${t}`;const n=new URLSearchParams({[this.#n.getQueryStringParameterName()]:this.#n.getRequestId(),[this.#n.getQueryStringSdkParameterName()]:"0.4.10",[this.#n.getQueryStringSdkTypeParameterName()]:"b24-js-sdk"});return`${t}?${n.toString()}`}setClientSideWarning(e,t){this.#o=e,this.#i=t}isServerSide(){return typeof window>"u"}}class kt{static batchSize=50;_isInit=!1;_http=null;_logger=null;constructor(){this._isInit=!1}get isInit(){return this._isInit}async init(){this._isInit=!0}destroy(){}setLogger(e){this._logger=e,this.getHttpClient().setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}callMethod(e,t,n){return this.getHttpClient().call(e,t||{},n||0)}async callListMethod(e,t={},n=null,s=null){const i=new qe;return C.isFunction(n)&&n!==null&&n(0),this.callMethod(e,t,0).then(async o=>{let l=[],a;if(s===null?a=o.getData().result:a=o.getData().result[s],l=[...l,...a],o.isMore()){let u=o;for(;u=await u.getNext(this.getHttpClient()),u!==!1;){let c;if(s===null?c=u.getData().result:c=u.getData().result[s],l=[...l,...c],n){const f=u.getTotal();n(f>0?Math.round(100*l.length/f):100)}}}return i.setData(l),n&&n(100),i})}async*fetchListMethod(e,t={},n="ID",s=null){t.order=t.order||{},t.filter=t.filter||{},t.start=-1;const i=`>${n}`;t.order[n]="ASC",t.filter[i]=0;do{const o=await this.callMethod(e,t,t.start);let l;if(!C.isNull(s)&&s!==null?l=o.getData().result[s]:l=o.getData().result,l.length===0||(yield l,l.length<kt.batchSize))break;const a=l.at(-1);a&&n in a&&(t.filter[i]=a[n])}while(!0)}async callBatch(e,t=!0,n=!1){return this.getHttpClient().batch(e,t,n)}chunkArray(e,t=50){const n=[];for(let s=0;s<e.length;s+=t){const i=e.slice(s,s+t);n.push(i)}return n}async callBatchByChunk(e,t=!0){const n=new qe,s=[],i=this.chunkArray(e,kt.batchSize);for(const o of i){const l=await this.callBatch(o,t);s.push(...l.getData())}return n.setData(s)}getHttpClient(){if(!this.isInit||this._http===null)throw new Error("Http not init");return this._http}_getHttpOptions(){return null}_ensureInitialized(){if(!this._isInit)throw new Error("B24 not initialized")}}var Bn=(r=>(r.en="en",r.de="de",r.la="la",r.br="br",r.fr="fr",r.it="it",r.pl="pl",r.ru="ru",r.ua="ua",r.tr="tr",r.sc="sc",r.tc="tc",r.ja="ja",r.vn="vn",r.id="id",r.ms="ms",r.th="th",r.ar="ar",r))(Bn||{});const _h={en:"en-EN",de:"de-DE",la:"es-ES",br:"pt-BR",fr:"fr-FR",it:"it-IT",pl:"pl-PL",ru:"ru-RU",ua:"uk-UA",tr:"tr-TR",sc:"zh-CN",tc:"zh-TW",ja:"ja-JP",vn:"vi-VN",id:"id-ID",ms:"ms-MY",th:"th-TH",ar:"ar-SA"},kh=()=>({scrollWidth:Math.max(document.documentElement.scrollWidth,document.documentElement.offsetWidth),scrollHeight:Math.max(document.documentElement.scrollHeight,document.documentElement.offsetHeight)});let vh=class ft{static isInternalConstructing=!1;static instance=null;_defLocale=null;constructor(){if(!ft.isInternalConstructing)throw new TypeError("FormatterNumber is not constructable");ft.isInternalConstructing=!1}static getInstance(){return ft.instance||(ft.isInternalConstructing=!0,ft.instance=new ft),ft.instance}setDefLocale(e){this._defLocale=e}format(e,t){let n;(typeof t>"u"||!C.isStringFilled(t))&&(t=C.isStringFilled(this._defLocale)?this._defLocale||"en":typeof navigator>"u"?"en":navigator?.language||"en"),Number.isInteger(e)?n=new Intl.NumberFormat(t,{minimumFractionDigits:0,maximumFractionDigits:0}):n=new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2});let s=n.format(e);return t.includes("ru")&&(s=s.replace(",",".")),s}};class T{countryCode;length;structure;example;_cachedRegex=null;constructor(e,t,n,s){this.countryCode=e,this.length=t,this.structure=n,this.example=s}isValid(e){return this.length===e.length&&this.countryCode===e.slice(0,2)&&this._regex().test(e.slice(4))&&this._iso7064Mod9710(this._iso13616Prepare(e))==1}toBBAN(e,t){return(this._regex().exec(e.slice(4)||"")||[]).slice(1).join(t)}fromBBAN(e){if(!this.isValidBBAN(e))throw new Error("Invalid BBAN");const t=("0"+(98-this._iso7064Mod9710(this._iso13616Prepare(this.countryCode+"00"+e)))).slice(-2);return this.countryCode+t+e}isValidBBAN(e){return this.length-4===e.length&&this._regex().test(e)}_regex(){return this._cachedRegex===null&&(this._cachedRegex=this._parseStructure(this.structure)),this._cachedRegex}_parseStructure(e){const t=(e.match(/(.{3})/g)||[]).map(n=>{let s;const i=n.slice(0,1),o=Number.parseInt(n.slice(1),10);switch(i){case"A":s="0-9A-Za-z";break;case"B":s="0-9A-Z";break;case"C":s="A-Za-z";break;case"F":s="0-9";break;case"L":s="a-z";break;case"U":s="A-Z";break;case"W":s="0-9a-z";break}return"(["+s+"]{"+o+"})"});return new RegExp("^"+t.join("")+"$")}_iso13616Prepare(e){return e=e.toUpperCase(),e=e.substring(4)+e.substring(0,4),e.split("").map(t=>{const n=t.charCodeAt(0);return n>=65&&n<=90?(n-65+10).toString():t}).join("")}_iso7064Mod9710(e){let t=e,n;for(;t.length>2;)n=t.slice(0,9),t=Number.parseInt(n,10)%97+t.slice(n.length);return Number.parseInt(t,10)%97}}class nt{static isInternalConstructing=!1;static instance=null;_countries;constructor(){if(!nt.isInternalConstructing)throw new TypeError("FormatterIban is not constructable");nt.isInternalConstructing=!1,this._countries=new Map}static getInstance(){return nt.instance||(nt.isInternalConstructing=!0,nt.instance=new nt),nt.instance}addSpecification(e){this._countries.set(e.countryCode,e)}isValid(e){if(!C.isString(e))return!1;e=this.electronicFormat(e);const t=e.slice(0,2);if(!this._countries.has(t))throw new Error(`No country with code ${t}`);const n=this._countries.get(t);return!!n&&n.isValid(e)}printFormat(e,t){typeof t>"u"&&(t=" ");const n=/(.{4})(?!$)/g;return this.electronicFormat(e).replace(n,"$1"+t)}electronicFormat(e){const t=/[^a-zA-Z0-9]/g;return e.replace(t,"").toUpperCase()}toBBAN(e,t){typeof t>"u"&&(t=" "),e=this.electronicFormat(e);const n=e.slice(0,2);if(!this._countries.has(n))throw new Error(`No country with code ${n}`);const s=this._countries.get(n);if(!s)throw new Error(`No country with code ${n}`);return s.toBBAN(e,t)}fromBBAN(e,t){if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);if(!n)throw new Error(`No country with code ${e}`);return n.fromBBAN(this.electronicFormat(t))}isValidBBAN(e,t){if(!C.isString(t))return!1;if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);return!!n&&n.isValidBBAN(this.electronicFormat(t))}}const Eh=()=>{const r=vh.getInstance(),e=nt.getInstance();return e.addSpecification(new T("AD",24,"F04F04A12","AD1200012030200359100100")),e.addSpecification(new T("AE",23,"F03F16","AE070331234567890123456")),e.addSpecification(new T("AL",28,"F08A16","AL47212110090000000235698741")),e.addSpecification(new T("AT",20,"F05F11","AT611904300234573201")),e.addSpecification(new T("AZ",28,"U04A20","AZ21NABZ00000000137010001944")),e.addSpecification(new T("BA",20,"F03F03F08F02","BA391290079401028494")),e.addSpecification(new T("BE",16,"F03F07F02","BE68539007547034")),e.addSpecification(new T("BG",22,"U04F04F02A08","BG80BNBG96611020345678")),e.addSpecification(new T("BH",22,"U04A14","BH67BMAG00001299123456")),e.addSpecification(new T("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1")),e.addSpecification(new T("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00")),e.addSpecification(new T("CH",21,"F05A12","CH9300762011623852957")),e.addSpecification(new T("CR",22,"F04F14","CR72012300000171549015")),e.addSpecification(new T("CY",28,"F03F05A16","CY17002001280000001200527600")),e.addSpecification(new T("CZ",24,"F04F06F10","CZ6508000000192000145399")),e.addSpecification(new T("DE",22,"F08F10","DE89370400440532013000")),e.addSpecification(new T("DK",18,"F04F09F01","DK5000400440116243")),e.addSpecification(new T("DO",28,"U04F20","DO28BAGR00000001212453611324")),e.addSpecification(new T("EE",20,"F02F02F11F01","EE382200221020145685")),e.addSpecification(new T("EG",29,"F04F04F17","EG800002000156789012345180002")),e.addSpecification(new T("ES",24,"F04F04F01F01F10","ES9121000418450200051332")),e.addSpecification(new T("FI",18,"F06F07F01","FI2112345600000785")),e.addSpecification(new T("FO",18,"F04F09F01","FO6264600001631634")),e.addSpecification(new T("FR",27,"F05F05A11F02","FR1420041010050500013M02606")),e.addSpecification(new T("GB",22,"U04F06F08","GB29NWBK60161331926819")),e.addSpecification(new T("GE",22,"U02F16","GE29NB0000000101904917")),e.addSpecification(new T("GI",23,"U04A15","GI75NWBK000000007099453")),e.addSpecification(new T("GL",18,"F04F09F01","GL8964710001000206")),e.addSpecification(new T("GR",27,"F03F04A16","GR1601101250000000012300695")),e.addSpecification(new T("GT",28,"A04A20","GT82TRAJ01020000001210029690")),e.addSpecification(new T("HR",21,"F07F10","HR1210010051863000160")),e.addSpecification(new T("HU",28,"F03F04F01F15F01","HU42117730161111101800000000")),e.addSpecification(new T("IE",22,"U04F06F08","IE29AIBK93115212345678")),e.addSpecification(new T("IL",23,"F03F03F13","IL620108000000099999999")),e.addSpecification(new T("IS",26,"F04F02F06F10","IS140159260076545510730339")),e.addSpecification(new T("IT",27,"U01F05F05A12","IT60X0542811101000000123456")),e.addSpecification(new T("IQ",23,"U04F03A12","IQ98NBIQ850123456789012")),e.addSpecification(new T("JO",30,"A04F22","JO15AAAA1234567890123456789012")),e.addSpecification(new T("KW",30,"U04A22","KW81CBKU0000000000001234560101")),e.addSpecification(new T("KZ",20,"F03A13","KZ86125KZT5004100100")),e.addSpecification(new T("LB",28,"F04A20","LB62099900000001001901229114")),e.addSpecification(new T("LC",32,"U04F24","LC07HEMM000100010012001200013015")),e.addSpecification(new T("LI",21,"F05A12","LI21088100002324013AA")),e.addSpecification(new T("LT",20,"F05F11","LT121000011101001000")),e.addSpecification(new T("LU",20,"F03A13","LU280019400644750000")),e.addSpecification(new T("LV",21,"U04A13","LV80BANK0000435195001")),e.addSpecification(new T("MC",27,"F05F05A11F02","MC5811222000010123456789030")),e.addSpecification(new T("MD",24,"U02A18","MD24AG000225100013104168")),e.addSpecification(new T("ME",22,"F03F13F02","ME25505000012345678951")),e.addSpecification(new T("MK",19,"F03A10F02","MK07250120000058984")),e.addSpecification(new T("MR",27,"F05F05F11F02","MR1300020001010000123456753")),e.addSpecification(new T("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S")),e.addSpecification(new T("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR")),e.addSpecification(new T("NL",18,"U04F10","NL91ABNA0417164300")),e.addSpecification(new T("NO",15,"F04F06F01","NO9386011117947")),e.addSpecification(new T("PK",24,"U04A16","PK36SCBL0000001123456702")),e.addSpecification(new T("PL",28,"F08F16","PL61109010140000071219812874")),e.addSpecification(new T("PS",29,"U04A21","PS92PALS000000000400123456702")),e.addSpecification(new T("PT",25,"F04F04F11F02","PT50000201231234567890154")),e.addSpecification(new T("QA",29,"U04A21","QA30AAAA123456789012345678901")),e.addSpecification(new T("RO",24,"U04A16","RO49AAAA1B31007593840000")),e.addSpecification(new T("RS",22,"F03F13F02","RS35260005601001611379")),e.addSpecification(new T("SA",24,"F02A18","SA0380000000608010167519")),e.addSpecification(new T("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD")),e.addSpecification(new T("SE",24,"F03F16F01","SE4550000000058398257466")),e.addSpecification(new T("SI",19,"F05F08F02","SI56263300012039086")),e.addSpecification(new T("SK",24,"F04F06F10","SK3112000000198742637541")),e.addSpecification(new T("SM",27,"U01F05F05A12","SM86U0322509800000000270100")),e.addSpecification(new T("ST",25,"F08F11F02","ST68000100010051845310112")),e.addSpecification(new T("SV",28,"U04F20","SV62CENR00000000000000700025")),e.addSpecification(new T("TL",23,"F03F14F02","TL380080012345678910157")),e.addSpecification(new T("TN",24,"F02F03F13F02","TN5910006035183598478831")),e.addSpecification(new T("TR",26,"F05F01A16","TR330006100519786457841326")),e.addSpecification(new T("UA",29,"F25","UA511234567890123456789012345")),e.addSpecification(new T("VA",22,"F18","VA59001123000012345678")),e.addSpecification(new T("VG",24,"U04F16","VG96VPVG0000012345678901")),e.addSpecification(new T("XK",20,"F04F10F02","XK051212012345678906")),e.addSpecification(new T("AO",25,"F21","AO69123456789012345678901")),e.addSpecification(new T("BF",27,"F23","BF2312345678901234567890123")),e.addSpecification(new T("BI",16,"F12","BI41123456789012")),e.addSpecification(new T("BJ",28,"F24","BJ39123456789012345678901234")),e.addSpecification(new T("CI",28,"U02F22","CI70CI1234567890123456789012")),e.addSpecification(new T("CM",27,"F23","CM9012345678901234567890123")),e.addSpecification(new T("CV",25,"F21","CV30123456789012345678901")),e.addSpecification(new T("DZ",24,"F20","DZ8612345678901234567890")),e.addSpecification(new T("IR",26,"F22","IR861234568790123456789012")),e.addSpecification(new T("MG",27,"F23","MG1812345678901234567890123")),e.addSpecification(new T("ML",28,"U01F23","ML15A12345678901234567890123")),e.addSpecification(new T("MZ",25,"F21","MZ25123456789012345678901")),e.addSpecification(new T("SN",28,"U01F23","SN52A12345678901234567890123")),e.addSpecification(new T("GF",27,"F05F05A11F02","GF121234512345123456789AB13")),e.addSpecification(new T("GP",27,"F05F05A11F02","GP791234512345123456789AB13")),e.addSpecification(new T("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13")),e.addSpecification(new T("RE",27,"F05F05A11F02","RE131234512345123456789AB13")),e.addSpecification(new T("PF",27,"F05F05A11F02","PF281234512345123456789AB13")),e.addSpecification(new T("TF",27,"F05F05A11F02","TF891234512345123456789AB13")),e.addSpecification(new T("YT",27,"F05F05A11F02","YT021234512345123456789AB13")),e.addSpecification(new T("NC",27,"F05F05A11F02","NC551234512345123456789AB13")),e.addSpecification(new T("BL",27,"F05F05A11F02","BL391234512345123456789AB13")),e.addSpecification(new T("MF",27,"F05F05A11F02","MF551234512345123456789AB13")),e.addSpecification(new T("PM",27,"F05F05A11F02","PM071234512345123456789AB13")),e.addSpecification(new T("WF",27,"F05F05A11F02","WF621234512345123456789AB13")),{formatterNumber:r,formatterIban:e}};class Po{#e;#t;#r;#n;constructor(e){this.#e=Object.freeze(Object.assign({},e)),this.#t=this.#e.b24Url.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#r=`https://${this.#t}/rest`,this.#n=`https://${this.#t}`}getAuthData(){return{access_token:this.#e.secret,refresh_token:"hook",expires_in:0,domain:this.#t,member_id:this.#t}}refreshAuth(){return Promise.resolve(this.getAuthData())}getUniq(e){const t=this.getAuthData();if(t===!1)throw new Error("AuthData not init");return[e,t.member_id].join("_")}getTargetOrigin(){return`${this.#n}`}getTargetOriginWithPath(){return`${this.#r}/${this.#e.userId}/${this.#e.secret}`}get isAdmin(){return!0}}class Un extends kt{#e;constructor(e){super(),this.#e=new Po(e),this._http=new jn(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use hook requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}get auth(){return this.#e}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}static fromWebhookUrl(e){if(!e.trim())throw new Error("Webhook URL cannot be empty");let t;try{t=new URL(e)}catch{throw new Error(`Invalid webhook URL format: ${e}`)}if(t.protocol!=="https:")throw new Error("Webhook requires HTTPS protocol");const n=t.pathname.split("/").filter(Boolean);if(n.length<3||n[0]!=="rest")throw new Error("Webhook URL must follow format: /rest/<userId>/<secret>");const s=n[1],i=n[2];if(!/^\d+$/.test(s))throw new Error(`User ID must be numeric in webhook URL, received: ${s}`);const o=Number.parseInt(s,10);return new Un({b24Url:t.origin,userId:o,secret:i})}}var ee=(r=>(r.getInitData="getInitData",r.setInstallFinish="setInstallFinish",r.setInstall="setInstall",r.refreshAuth="refreshAuth",r.setAppOption="setAppOption",r.setUserOption="setUserOption",r.resizeWindow="resizeWindow",r.reloadWindow="reloadWindow",r.setTitle="setTitle",r.setScroll="setScroll",r.openApplication="openApplication",r.closeApplication="closeApplication",r.openPath="openPath",r.imCallTo="imCallTo",r.imPhoneTo="imPhoneTo",r.imOpenMessenger="imOpenMessenger",r.imOpenHistory="imOpenHistory",r.selectUser="selectUser",r.selectAccess="selectAccess",r.selectCRM="selectCRM",r.showAppForm="showAppForm",r.getInterface="getInterface",r.placementBindEvent="placementBindEvent",r))(ee||{});class Do{#e;#t;#r;_logger=null;runCallbackHandler;constructor(e){this.#e=e,this.#t=new Map,this.#r=new Map,this.runCallbackHandler=this._runCallback.bind(this)}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}subscribe(){window.addEventListener("message",this.runCallbackHandler)}unsubscribe(){window.removeEventListener("message",this.runCallbackHandler)}async send(e,t=null){return new Promise((n,s)=>{let i;const o={resolve:n,reject:s,timeoutId:null},l=this.#n(o);let a=null;const u=Kn(t||{},["singleOption","callBack","isSafely","safelyTime"]),{callBack:c,singleOption:f}=t||{};if(c&&this.#r.set(l,c),f?a=f:Object.keys(u).length>0&&(a={...u}),e.toString().includes(":"))i={method:e.toString(),params:a||"",callback:l,appSid:this.#e.getAppSid()};else{i=e.toString(),t?.isRawValue!==!0&&a?a=JSON.stringify(a):t?.isRawValue===!0&&a&&C.isPlainObject(a)&&a.value&&(a=a.value);const h=[a||"",l,this.#e.getAppSid()];i+=":"+h.filter(Boolean).join(":")}this.getLogger().log(`send to ${this.#e.getTargetOrigin()}`,{cmd:i}),parent.postMessage(i,this.#e.getTargetOrigin()),t?.isSafely&&(this.#t.get(l).timeoutId=window.setTimeout(()=>{this.#t.has(l)&&(this.getLogger().warn(`Action ${e.toString()} stop by timeout`),this.#t.delete(l),n({isSafely:!0}))},Number.parseInt(String(t?.safelyTime||900))))})}_runCallback(e){if(e.origin===this.#e.getTargetOrigin()&&e.data){this.getLogger().log(`get from ${e.origin}`,{data:e.data});const t=e.data.split(":"),n={id:t[0],args:t.slice(1).join(":")};if(n.args&&(n.args=JSON.parse(n.args)),this.#t.has(n.id)){const s=this.#t.get(n.id);s.timeoutId&&clearTimeout(s.timeoutId),this.#t.delete(n.id),s.resolve(n.args)}else if(this.#r.has(n.id)){const s=this.#r.get(n.id);s&&s.apply(globalThis,[n.args])}}}#n(e){const t=V.getUniqId();return this.#t.set(t,e),t}}class Mo{#e="";#t=!0;#r=null;#n=null;#s=null;constructor(e){e.DOMAIN&&(this.#e=e.DOMAIN,this.#e=this.#e.replace(/:(80|443)$/,"")),this.#t=e.PROTOCOL===!0,e.LANG&&(this.#s=e.LANG),e.APP_SID&&(this.#r=e.APP_SID)}initData(e){return this.#e||(this.#e=e.DOMAIN),this.#n||(this.#n=e.PATH),this.#s||(this.#s=e.LANG),this.#t=Number.parseInt(e.PROTOCOL)===1,this.#e=this.#e.replace(/:(80|443)$/,""),this}getAppSid(){if(this.#r===null)throw new Error("Not init appSid");return this.#r}getTargetOrigin(){return`${this.#t?"https":"http"}://${this.#e}`}getTargetOriginWithPath(){return this.getTargetOrigin()+(this.#n??"")}getLang(){return this.#s||Bn.en}}class Fo{#e=null;#t=null;#r=0;#n=null;#s=!1;#o;#i;constructor(e,t){this.#o=e,this.#i=t}initData(e){return e.AUTH_ID&&(this.#e=e.AUTH_ID,this.#t=e.REFRESH_ID,this.#r=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,this.#s=e.IS_ADMIN,this.#n=e.MEMBER_ID||""),this}getAuthData(){return this.#r>Date.now()?{access_token:this.#e,refresh_token:this.#t,expires_in:this.#r,domain:this.#o.getTargetOrigin(),member_id:this.#n}:!1}async refreshAuth(){return this.#i.send(ee.refreshAuth,{}).then(e=>(this.#e=e.AUTH_ID,this.#t=e.REFRESH_ID,this.#r=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,Promise.resolve(this.getAuthData())))}getUniq(e){return[e,this.#n||""].join("_")}get isAdmin(){return this.#s}}class xo{#e;constructor(e){this.#e=e}async closeApplication(){return this.#e.send(ee.closeApplication,{isSafely:!1})}async fitWindow(){const e="100%",t=this.getScrollSize().scrollHeight;return this.#e.send(ee.resizeWindow,{width:e,height:t,isSafely:!0})}async resizeWindow(e,t){return e>0&&t>0?this.#e.send(ee.resizeWindow,{width:e,height:t,isSafely:!0}):Promise.reject(new Error(`Wrong width:number = ${e} or height:number = ${t}`))}async resizeWindowAuto(e=null,t=0,n=0){const s=document.body;let i=Math.max(s.scrollWidth,s.offsetWidth);n>0&&(i=Math.max(n,i));let o=Math.max(s.scrollHeight,s.offsetHeight);return e&&(o=Math.max(e.scrollHeight,e.offsetHeight)),t>0&&(o=Math.max(t,o)),this.resizeWindow(i,o)}getScrollSize(){return kh()}async scrollParentWindow(e){return Number.isInteger(e)?(e<0&&(e=0),this.#e.send(ee.setScroll,{scroll:e,isSafely:!0})):Promise.reject(new Error("Wrong scroll number"))}async reloadWindow(){return this.#e.send(ee.reloadWindow,{isSafely:!0})}async setTitle(e){return this.#e.send(ee.setTitle,{title:e.toString(),isSafely:!0})}async imCallTo(e,t=!0){return this.#e.send(ee.imCallTo,{userId:e,video:t,isSafely:!0})}async imPhoneTo(e){return this.#e.send(ee.imPhoneTo,{phone:e,isSafely:!0})}async imOpenMessenger(e){return this.#e.send(ee.imOpenMessenger,{dialogId:e,isSafely:!0})}async imOpenHistory(e){return this.#e.send(ee.imOpenHistory,{dialogId:e,isSafely:!0})}}let jo=class{#e;#t=null;#r=null;constructor(e){this.#e=e}initData(e){return e.APP_OPTIONS&&(this.#t=e.APP_OPTIONS),e.USER_OPTIONS&&(this.#r=e.USER_OPTIONS),this}appGet(e){if(this.#t&&this.#t[e])return this.#t[e];throw new Error(`app.option.${e} not set`)}async appSet(e,t){return this.#t||(this.#t=[]),this.#t[e]=t,this.#n(ee.setAppOption,e,this.#t[e])}userGet(e){if(this.#r&&this.#r[e])return this.#r[e];throw new Error(`user.option.${e} not set`)}async userSet(e,t){return this.#t||(this.#t=[]),this.#t[e]||(this.#t[e]=null),this.#r[e]=t,this.#n(ee.setUserOption,e,this.#r[e])}async#n(e,t,n){return this.#e.send(e,{name:t,value:n,isSafely:!0}).then(()=>Promise.resolve())}};class Bo{#e;constructor(e){this.#e=e}async selectUser(){return this.#e.send(ee.selectUser,{mult:!1})}async selectUsers(){return this.#e.send(ee.selectUser,{mult:!0})}async selectAccess(e=[]){return console.warn("@deprecated selectAccess"),this.#e.send(ee.selectAccess,{value:e})}async selectCRM(e){return console.warn("@deprecated selectCRM"),this.#e.send(ee.selectCRM,{entityType:e?.entityType,multiple:e?.multiple,value:e?.value})}}class Uo{#e;#t;constructor(e,t){this.#e=e,this.#t=t}getUrl(e="/"){return new URL(e,this.#e.getTargetOrigin())}getTargetOrigin(){return this.#e.getTargetOrigin()}async openSliderAppPage(e={}){return this.#t.send(ee.openApplication,e)}async closeSliderAppPage(){return this.#t.send(ee.closeApplication,{isSafely:!1})}#r(e=1640){return e>0?e>1200&&e<=1640?"/crm/type/0/details/0/../../../../..":e>950&&e<=1200?"/company/personal/user/0/groups/create/../../../../../..":e>900&&e<=950?"/crm/company/requisite/0/../../../..":e<=900?"/workgroups/group/0/card/../../../..":"/crm/deal/../..":"/crm/deal/../.."}async openPath(e,t=1640){const n=new URL(e);return n.searchParams.set("IFRAME","Y"),n.searchParams.set("IFRAME_TYPE","SIDE_SLIDER"),this.#t.send(ee.openPath,{path:[this.#r(t),n.pathname,n.search].join("")}).then(s=>s?.result==="error"?s?.errorCode==="METHOD_NOT_SUPPORTED_ON_DEVICE"?new Promise((i,o)=>{const l=window.open(e,"_blank");if(!l){o(new Error("Error open window"));return}let a=0;const u=1e3*60*5,c=window.setInterval(()=>{a=a+1,l.closed?(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!0})):a>u&&(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!1}))},1e3)}):Promise.reject(new Error(s?.errorCode)):s?.result==="close"?Promise.resolve({isOpenAtNewWindow:!1,isClose:!0}):Promise.resolve({isOpenAtNewWindow:!1,isClose:!1}))}async showAppForm(e){return console.warn("@deprecated showAppForm"),this.#t.send(ee.showAppForm,{params:e,isSafely:!0})}}class $o{#e;#t="";#r={};constructor(e){this.#e=e}initData(e){this.#t=e.PLACEMENT||"DEFAULT";const t=e.PLACEMENT_OPTIONS;return this.#r=Object.freeze(t),this}get title(){return this.#t}get isDefault(){return this.title==="DEFAULT"}get options(){return this.#r}get isSliderMode(){return this.options?.IFRAME==="Y"}async getInterface(){return this.#e.send(ee.getInterface,{isSafely:!0})}async bindEvent(e,t){return this.#e.send(ee.placementBindEvent,{event:e,callBack:t,isSafely:!0})}async call(e,t={}){return this.#e.send(e,{...t,isSafely:!0,isRawValue:["setValue"].includes(e)})}async callCustomBind(e,t=null,n){let s={};return C.isString(t)?s.singleOption=t:C.isObjectLike(t)&&(s={...t}),this.#e.send(e,{...s,callBack:n,isSafely:!0})}}class Wo extends kt{#e=!1;#t=!1;#r;#n;#s;#o;#i;#l;#c;#a;constructor(e){super(),this.#r=new Mo(e),this.#n=new Do(this.#r),this.#n.subscribe(),this.#s=new Fo(this.#r,this.#n),this.#o=new xo(this.#n),this.#i=new jo(this.#n),this.#l=new Bo(this.#n),this.#c=new Uo(this.#r,this.#n),this.#a=new $o(this.#n),this._isInit=!1}setLogger(e){super.setLogger(e),this.#n.setLogger(this.getLogger())}get isFirstRun(){return this._ensureInitialized(),this.#t}get isInstallMode(){return this._ensureInitialized(),this.#e}get parent(){return this._ensureInitialized(),this.#o}get auth(){return this._ensureInitialized(),this.#s}get slider(){return this._ensureInitialized(),this.#c}get placement(){return this._ensureInitialized(),this.#a}get options(){return this._ensureInitialized(),this.#i}get dialog(){return this._ensureInitialized(),this.#l}async init(){return this.#n.send(ee.getInitData,{}).then(e=>(this.getLogger().log("init data:",e),this.#r.initData(e),this.#s.initData(e),this.#a.initData(e),this.#i.initData(e),this.#e=e.INSTALL,this.#t=e.FIRST_RUN,this._http=new jn(this.#r.getTargetOriginWithPath(),this.#s,this._getHttpOptions()),this._isInit=!0,this.#t?this.#n.send(ee.setInstall,{install:!0}):Promise.resolve()))}destroy(){this.#n.unsubscribe(),super.destroy()}async installFinish(){return this.isInstallMode?this.#n.send(ee.setInstallFinish,{}):Promise.reject(new Error("Application was previously installed. You cannot call installFinish"))}getTargetOrigin(){return this._ensureInitialized(),this.#r.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#r.getTargetOriginWithPath()}getAppSid(){return this._ensureInitialized(),this.#r.getAppSid()}getLang(){return this._ensureInitialized(),this.#r.getLang()}}class Th extends xe{}class Vo{#e;#t=null;#r=null;#n;#s;#o=0;#i;#l;#c;#a;#u=null;constructor(e,t){this.#n=Object.assign({},e),this.#s=Object.freeze(Object.assign({},t)),this.#i=this.#n.domain.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#l=this.#n.clientEndpoint,this.#c=this.#l.replace("/rest/",""),this.#a=this.#n.serverEndpoint.replace("/rest/",""),this.#o=this.#n.expires*1e3,this.#e=ce.create({baseURL:this.#a,headers:{"Content-Type":"application/json"}})}getAuthData(){return this.#o>Date.now()?{access_token:this.#n.accessToken,refresh_token:this.#n.refreshToken,expires_in:this.#n.expiresIn,domain:this.#i,member_id:this.#n.memberId}:!1}async refreshAuth(){try{let e;if(this.#r)e=await this.#r();else{const n=await this.#e.get("/oauth/token/",{params:{grant_type:"refresh_token",client_id:this.#s.clientId,client_secret:this.#s.clientSecret,refresh_token:this.#n.refreshToken}});if(n.data.error)throw new Error(`Token update error: ${n.data.error}`);if(n.status!==200)throw new Error(`Token update error status code: ${n.status}`);e=n.data}if(!e)throw new Error("Unable to obtain authorization update data");this.#n.accessToken=e.access_token,this.#n.refreshToken=e.refresh_token,this.#n.expires=Number.parseInt(e.expires||"0"),this.#n.expiresIn=Number.parseInt(e.expires_in||"3600"),this.#n.clientEndpoint=e.client_endpoint,this.#n.serverEndpoint=e.server_endpoint,this.#n.scope=e.scope,this.#n.status=Object.values(et).find(n=>n===e.status)||et.Free,this.#o=this.#n.expires*1e3;const t=this.getAuthData();return this.#t&&await this.#t({authData:t,b24OAuthParams:this.#n}),t}catch(e){if(e instanceof Ln){let t={error:e?.code||0,errorDescription:e?.message||""};if(e.response&&e.response.data&&!C.isUndefined(e.response.data.error)){const n=e.response.data;t={error:n.error,errorDescription:n.error_description}}throw new Th({code:String(t.error),description:t.errorDescription,status:e.response?.status||0,requestInfo:{method:"/oauth/token/"}})}else if(e instanceof Error)throw e;throw new Error(`Strange error: ${e instanceof Error?e.message:e}`,{cause:e})}}setCallbackRefreshAuth(e){this.#t=e}removeCallbackRefreshAuth(){this.#t=null}setCustomRefreshAuth(e){this.#r=e}removeCustomRefreshAuth(){this.#r=null}getUniq(e){return[e,this.#n.memberId||""].join("_")}getTargetOrigin(){return`${this.#c}`}getTargetOriginWithPath(){return`${this.#l}`}get isAdmin(){if(this.#u===null)throw new Error("isAdmin not init. You need call B24OAuth::initIsAdmin().");return this.#u}async initIsAdmin(e){const t=await e.call("profile",{},0);if(!t.isSuccess)throw new Error(t.getErrorMessages().join(";"));t.getData().result?.ADMIN&&(this.#u=!0)}}class Oh extends kt{#e;constructor(e,t){super(),this.#e=new Vo(e,t),this._http=new jn(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use oauth requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}async initIsAdmin(){return this._ensureInitialized(),this.#e.initIsAdmin(this._http)}setCallbackRefreshAuth(e){this._ensureInitialized(),this.#e.setCallbackRefreshAuth(e)}removeCallbackRefreshAuth(){this._ensureInitialized(),this.#e.removeCallbackRefreshAuth()}setCustomRefreshAuth(e){this._ensureInitialized(),this.#e.setCustomRefreshAuth(e)}removeCustomRefreshAuth(){this._ensureInitialized(),this.#e.removeCustomRefreshAuth()}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}get auth(){return this.#e}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}}class $n extends Error{constructor(e,...t){super(...t),this.name="UnhandledMatchError",this.message=`Unhandled match value of type ${e}`,this.stack=new Error("for stack").stack}}class jt{_b24;_logger=null;_data=null;constructor(e){this._b24=e}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async initData(e){return this.getLogger().log(e),Promise.reject(new Error("Rewrite this function"))}}class Ah extends jt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("ProfileManager.data not initialized");return this._data}}class Ih extends jt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("AppManager.data not initialized");return this._data}get statusCode(){return Bi[this.data.status]||"Unknown status"}}class Ch extends jt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("PaymentManager.data not initialized");return this._data}}class Nh extends jt{_data=null;async initData(e){this._data=e,this.makeRestrictionManagerParams()}get data(){if(this._data===null)throw new Error("LicenseManager.data not initialized");return this._data}makeRestrictionManagerParams(){this.data?.license&&this.data.license.includes("ent")&&(this.getLogger().log(`LICENSE ${this.data.license} => up restriction manager params`,mn),this._b24.getHttpClient().setRestrictionManagerParams(mn))}}class Rh extends jt{async initData(e){this._data={currencyBase:"?",currencyList:new Map},this.setBaseCurrency(e.currencyBase),this.setCurrencyList(e.currencyList);try{await this.loadData()}catch(t){throw t instanceof Error?t:(console.error(t),new Error("Failed to load data"))}}async loadData(){const e=this.currencyList.map(t=>({method:"crm.currency.get",params:{id:t}}));if(e.length===0)return Promise.resolve();try{(await this._b24.callBatchByChunk(e,!0)).getData().forEach(t=>{if(typeof t.LANG>"u")return;const n=t.CURRENCY,s=this.data.currencyList.get(n);if(!(typeof s>"u"))for(const[i,o]of Object.entries(t.LANG))switch(s.lang[i]={decimals:Number.parseInt(o.DECIMALS),decPoint:o.DEC_POINT,formatString:o.FORMAT_STRING,fullName:o.FULL_NAME,isHideZero:o.HIDE_ZERO==="Y",thousandsSep:o.THOUSANDS_SEP,thousandsVariant:o.THOUSANDS_VARIANT},s.lang[i].thousandsVariant){case"N":s.lang[i].thousandsSep="";break;case"D":s.lang[i].thousandsSep=".";break;case"C":s.lang[i].thousandsSep=",";break;case"S":s.lang[i].thousandsSep=" ";break;case"B":s.lang[i].thousandsSep="&nbsp;";break;default:C.isStringFilled(s.lang[i].thousandsSep)||(s.lang[i].thousandsSep=" ");break}})}catch(t){console.error(t)}}get data(){if(this._data===null)throw new Error("CurrencyManager.data not initialized");return this._data}setBaseCurrency(e){this._data.currencyBase=e}get baseCurrency(){return this.data.currencyBase}setCurrencyList(e=[]){this.data.currencyList.clear();for(const t of e)this.data.currencyList.set(t.CURRENCY,{amount:Number.parseFloat(t.CURRENCY),amountCnt:Number.parseInt(t.AMOUNT_CNT),isBase:t.BASE==="Y",currencyCode:t.CURRENCY,dateUpdate:V.toDateTime(t.DATE_UPDATE),decimals:Number.parseInt(t.DECIMALS),decPoint:t.DEC_POINT,formatString:t.FORMAT_STRING,fullName:t.FULL_NAME,lid:t.LID,sort:Number.parseInt(t.SORT),thousandsSep:t?.THOUSANDS_SEP||null,lang:{}})}getCurrencyFullName(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new $n(e);let s=n.fullName;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.fullName)}return s}getCurrencyLiteral(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new $n(e);let s=n.formatString;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.formatString)}return s.replaceAll("&#","&%").replaceAll("#","").replaceAll("&%","&#").trim()||""}get currencyList(){return[...this.data.currencyList.keys()]}format(e,t,n){const s=this.data.currencyList.get(t);if(typeof s>"u")throw new $n(t);const i={formatString:s.formatString,decimals:s.decimals,decPoint:s.decPoint,thousandsSep:s.thousandsSep};C.isStringFilled(i.thousandsSep)||(i.thousandsSep="");const o=s.lang[n];return C.isUndefined(o)||(i.formatString=o.formatString,i.decimals=o.decimals,i.decPoint=o.decPoint,i.thousandsSep=o.thousandsSep),i.formatString.replaceAll("&#","&%").replace("#",V.numberFormat(e,i.decimals,i.decPoint,i.thousandsSep)).replaceAll("&%","&#")||""}}class Wn extends jt{_data;_type;static getSupportTypes(){return[tt.NotSet,tt.JsonArray,tt.JsonObject,tt.FloatVal,tt.IntegerVal,tt.BoolYN,tt.StringVal]}static prepareArrayList(e){return C.isArray(e)?e:C.isObject(e)?Object.values(e):[]}constructor(e,t){super(e),this._type=t,this._data=new Map}get data(){return this._data}reset(){this.data.clear()}async initData(e){if(this.reset(),C.isObject(e))for(const[t,n]of Object.entries(e))this.data.set(t,n)}getJsonArray(e,t=[]){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n),!C.isArray(n)&&!C.isObject(n)&&(n=t)}catch(s){this.getLogger().error(s),n=t}return Wn.prepareArrayList(n)}getJsonObject(e,t={}){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n)}catch(s){this.getLogger().error(s),n=t}return C.isObject(n)||(n=t),n}getFloat(e,t=0){return this.data.has(e)?V.toNumber(this.data.get(e)):t}getInteger(e,t=0){return this.data.has(e)?V.toInteger(this.data.get(e)):t}getBoolYN(e,t=!0){return this.data.has(e)?V.toBoolean(this.data.get(e)):t}getBoolNY(e,t=!1){return this.data.has(e)?V.toBoolean(this.data.get(e)):t}getString(e,t=""){return this.data.has(e)?this.data.get(e).toString():t}getDate(e,t=null){if(!this.data.has(e))return t;try{const n=V.toDateTime(this.data.get(e).toString());return n.isValid?n:t}catch{return t}}encode(e){return JSON.stringify(e)}decode(e,t){try{return e.length>0?JSON.parse(e):t}catch(n){this.getLogger().warn(n,e)}return t}getMethodSave(){switch(this._type){case"app":return"app.option.set";case"user":return"user.option.set"}}async save(e,t){const n=[];return n.push({method:this.getMethodSave(),params:{options:e}}),C.isObject(t)&&n.push({method:"pull.application.event.add",params:{COMMAND:t?.command,PARAMS:t?.params,MODULE_ID:t?.moduleId}}),this._b24.callBatch(n,!0)}}class qo{_logger=null;userId;siteId;constructor(e={}){this.userId=e.userId?V.toInteger(e.userId):0,this.siteId=e.siteId??"none"}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}set(e,t){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}typeof t!="string"&&t&&(t=JSON.stringify(t)),window.localStorage.setItem(this._getKey(e),t)}get(e,t){if(typeof window.localStorage>"u")return t||null;const n=window.localStorage.getItem(this._getKey(e));return n===null?t||null:JSON.parse(n)}remove(e){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}return window.localStorage.removeItem(this._getKey(e))}_getKey(e){return`@bitrix24/b24jssdk-pull-${this.userId}-${this.siteId}-${e}`}compareKey(e,t){return e===this._getKey(t)}}class Lh extends Error{constructor(e){super(e),this.name="ErrorNotConnected"}}class Ph extends Error{constructor(e){super(e),this.name="ErrorTimeout"}}const jr="2.0";class Dh{_logger=null;_connector;_idCounter=0;_handlers={};_rpcResponseAwaiters=new Map;constructor(e){if(this._connector=e.connector,C.isPlainObject(e.handlers))for(const t in e.handlers)this.handle(t,e.handlers[t])}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}handle(e,t){this._handlers[e]=t}async executeOutgoingRpcCommand(e,t,n=5){return new Promise((s,i)=>{const o=this.createRequest(e,t);this._connector.send(JSON.stringify(o))||i(new Lh("websocket is not connected"));const l=setTimeout(()=>{this._rpcResponseAwaiters.delete(o.id),i(new Ph("no response"))},n*1e3);this._rpcResponseAwaiters.set(o.id,{resolve:s,reject:i,timeout:l})})}executeOutgoingRpcBatch(e){const t=[],n=[];return e.forEach(({method:s,params:i,id:o})=>{const l=this.createRequest(s,i,o);t.push(l),n.push(new Promise((a,u)=>this._rpcResponseAwaiters.set(l.id,{resolve:a,reject:u})))}),this._connector.send(JSON.stringify(t)),n}processRpcResponse(e){if("id"in e&&this._rpcResponseAwaiters.has(Number(e.id))){const t=this._rpcResponseAwaiters.get(Number(e.id));t&&("result"in e?t.resolve(e.result):"error"in e?t.reject(e?.error||"error"):t.reject("wrong response structure"),clearTimeout(t.timeout),this._rpcResponseAwaiters.delete(Number(e.id)));return}this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Received rpc response with unknown id`),e)}parseJsonRpcMessage(e){let t;try{t=JSON.parse(e)}catch(n){this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Could not decode json rpc message`),n);return}if(C.isArray(t))return this.executeIncomingRpcBatch(t);if(C.isJsonRpcRequest(t))return this.executeIncomingRpcCommand(t);if(C.isJsonRpcResponse(t))return this.processRpcResponse(t);this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: unknown rpc packet`),t)}executeIncomingRpcCommand({method:e,params:t}){return e in this._handlers?this._handlers[e].call(this,t||{}):{jsonrpc:jr,error:Sn.MethodNotFound}}executeIncomingRpcBatch(e){const t=[];for(const n of e)if("jsonrpc"in n)if("method"in n){const s=this.executeIncomingRpcCommand(n);s&&(s.jsonrpc=jr,s.id=n.id,t.push(s))}else this.processRpcResponse(n);else this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: unknown rpc command in batch`),n),t.push({jsonrpc:jr,error:Sn.InvalidRequest});return t}nextId(){return++this._idCounter}createPublishRequest(e){return e.map(t=>this.createRequest("publish",t))}createRequest(e,t,n){return n||(n=this.nextId()),{jsonrpc:jr,method:e,params:t,id:n}}}class Mh{_logger=null;_storage;_ttl=1440*60;_callbacks;constructor(e={}){e=e||{},this._storage=e.storage||new qo,this._callbacks={onWebSocketBlockChanged:C.isFunction(e.onWebSocketBlockChanged)?e.onWebSocketBlockChanged:()=>{}},this._storage&&window.addEventListener("storage",this.onLocalStorageSet.bind(this))}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}onLocalStorageSet(e){this._storage.compareKey(e.key||"",Re.WebsocketBlocked)&&e.newValue!==e.oldValue&&this._callbacks.onWebSocketBlockChanged({isWebSocketBlocked:this.isWebSocketBlocked()})}isWebSocketBlocked(){return this._storage?this._storage.get(Re.WebsocketBlocked,0)>Date.now():!1}setWebSocketBlocked(e){if(!this._storage)return!1;try{this._storage.set(Re.WebsocketBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Could not save WS_blocked flag in local storage. Error: `),t),!1}return!0}isLongPollingBlocked(){return this._storage?this._storage.get(Re.LongPollingBlocked,0)>Date.now():!1}setLongPollingBlocked(e){if(!this._storage)return!1;try{this._storage.set(Re.LongPollingBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Could not save LP_blocked flag in local storage. Error: `),t),!1}return!0}isLoggingEnabled(){return this._storage?this._storage.get(Re.LoggingEnabled,0)>this.getTimestamp():!1}setLoggingEnabled(e){if(!this._storage)return!1;try{this._storage.set(Re.LoggingEnabled,e?this.getTimestamp()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${V.getDateForLog()}: LocalStorage error: `),t),!1}return!0}getTimestamp(){return Date.now()}}class Fh{_logger=null;_publicIds;_restClient;_getPublicListMethod;constructor(e){this._publicIds=new Map,this._restClient=e.b24,this._getPublicListMethod=e.getPublicListMethod}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async getPublicIds(e){const t=new Date,n={},s=[];for(const i of e){const o=this._publicIds.get(i);o&&o.end>t?n[o.userId]=o:s.push(i)}return s.length===0?Promise.resolve(n):new Promise(i=>{this._restClient.callMethod(this._getPublicListMethod,{users:s}).then(o=>{const l=o.getData().result;this.setPublicIds(Object.values(l));for(const a of s){const u=this._publicIds.get(a);u&&(n[u.userId]=u)}i(n)}).catch(o=>(this.getLogger().error(o),i({})))})}setPublicIds(e){e.forEach(t=>{const n=Number(t.user_id);this._publicIds.set(n,{userId:n,publicId:t.public_id,signature:t.signature,start:new Date(t.start),end:new Date(t.end)})})}}var sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vn={exports:{}};/*!
12
+ `+i):n.stack=i}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=bt(this.defaults,t);const{transitional:n,paramsSerializer:s,headers:i}=t;n!==void 0&&Mr.assertOptions(n,{silentJSONParsing:Ze.transitional(Ze.boolean),forcedJSONParsing:Ze.transitional(Ze.boolean),clarifyTimeoutError:Ze.transitional(Ze.boolean)},!1),s!=null&&(k.isFunction(s)?t.paramsSerializer={serialize:s}:Mr.assertOptions(s,{encode:Ze.function,serialize:Ze.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Mr.assertOptions(t,{baseUrl:Ze.spelling("baseURL"),withXsrfToken:Ze.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&k.merge(i.common,i[t.method]);i&&k.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),t.headers=Ae.concat(o,i);const l=[];let a=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(a=a&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let c,f=0,h;if(!a){const d=[ko.bind(this),void 0];for(d.unshift(...l),d.push(...u),h=d.length,c=Promise.resolve(t);f<h;)c=c.then(d[f++],d[f++]);return c}h=l.length;let p=t;for(;f<h;){const d=l[f++],g=l[f++];try{p=d(p)}catch(m){g.call(this,m);break}}try{c=ko.call(this,p)}catch(d){return Promise.reject(d)}for(f=0,h=u.length;f<h;)c=c.then(u[f++],u[f++]);return c}getUri(e){e=bt(this.defaults,e);const t=uo(e.baseURL,e.url,e.allowAbsoluteUrls);return to(t,e.params,e.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(e){St.prototype[e]=function(t,n){return this.request(bt(n||{},{method:e,url:t,data:(n||{}).data}))}}),k.forEach(["post","put","patch"],function(e){function t(n){return function(i,o,l){return this.request(bt(l||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}St.prototype[e]=t(),St.prototype[e+"Form"]=t(!0)});let Hu=class oa{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{n.subscribe(l),i=l}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,l){n.reason||(n.reason=new xt(i,o,l),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new oa(function(s){e=s}),cancel:e}}};function Ju(r){return function(t){return r.apply(null,t)}}function Zu(r){return k.isObject(r)&&r.isAxiosError===!0}const Rn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Rn).forEach(([r,e])=>{Rn[e]=r});function To(r){const e=new St(r),t=Ui(St.prototype.request,e);return k.extend(t,St.prototype,e,{allOwnKeys:!0}),k.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return To(bt(r,s))},t}const ce=To(rr);ce.Axios=St,ce.CanceledError=xt,ce.CancelToken=Hu,ce.isCancel=oo,ce.VERSION=vo,ce.toFormData=Nr,ce.AxiosError=H,ce.Cancel=ce.CanceledError,ce.all=function(e){return Promise.all(e)},ce.spread=Ju,ce.isAxiosError=Zu,ce.mergeConfig=bt,ce.AxiosHeaders=Ae,ce.formToJSON=r=>so(k.isHTMLForm(r)?new FormData(r):r),ce.getAdapter=_o.getAdapter,ce.HttpStatusCode=Rn,ce.default=ce;const{Axios:kf,AxiosError:Ln,CanceledError:vf,isCancel:Ef,CancelToken:Tf,VERSION:Of,all:Af,Cancel:If,isAxiosError:Cf,spread:Nf,toFormData:Rf,AxiosHeaders:Lf,HttpStatusCode:Pf,formToJSON:Df,getAdapter:Mf,mergeConfig:Ff}=ce,Gu=String.prototype.replace,Yu=/%20/g,Oo={RFC1738:"RFC1738",RFC3986:"RFC3986"},Ku={RFC1738:function(r){return Gu.call(r,Yu,"+")},RFC3986:function(r){return String(r)}},Qu=Oo.RFC1738,Xu=Oo.RFC3986,Pn=Object.prototype.hasOwnProperty,_t=Array.isArray,Ge=(function(){const r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})(),eh=function(e){for(;e.length>1;){const t=e.pop(),n=t.obj[t.prop];if(_t(n)){const s=[];for(let i=0;i<n.length;++i)typeof n[i]<"u"&&s.push(n[i]);t.obj[t.prop]=s}}},th=function(e,t){const n=t&&t.plainObjects?Object.create(null):{};for(let s=0;s<e.length;++s)typeof e[s]<"u"&&(n[s]=e[s]);return n},rh=function r(e,t,n){if(!t)return e;if(typeof t!="object"){if(_t(e))e.push(t);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!Pn.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);let s=e;return _t(e)&&!_t(t)&&(s=th(e,n)),_t(e)&&_t(t)?(t.forEach(function(i,o){if(Pn.call(e,o)){const l=e[o];l&&typeof l=="object"&&i&&typeof i=="object"?e[o]=r(l,i,n):e.push(i)}else e[o]=i}),e):Object.keys(t).reduce(function(i,o){const l=t[o];return Pn.call(i,o)?i[o]=r(i[o],l,n):i[o]=l,i},s)},nh=function(r,e,t){const n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Dn=1024,sh=function(e,t,n,s,i){if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let l="";for(let a=0;a<o.length;a+=Dn){const u=o.length>=Dn?o.slice(a,a+Dn):o,c=[];for(let f=0;f<u.length;++f){let h=u.charCodeAt(f);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||i===Qu&&(h===40||h===41)){c[c.length]=u.charAt(f);continue}if(h<128){c[c.length]=Ge[h];continue}if(h<2048){c[c.length]=Ge[192|h>>6]+Ge[128|h&63];continue}if(h<55296||h>=57344){c[c.length]=Ge[224|h>>12]+Ge[128|h>>6&63]+Ge[128|h&63];continue}f+=1,h=65536+((h&1023)<<10|u.charCodeAt(f)&1023),c[c.length]=Ge[240|h>>18]+Ge[128|h>>12&63]+Ge[128|h>>6&63]+Ge[128|h&63]}l+=c.join("")}return l},ih=function(e){const t=[{obj:{o:e},prop:"o"}],n=[];for(let s=0;s<t.length;++s){const i=t[s],o=i.obj[i.prop],l=Object.keys(o);for(let a=0;a<l.length;++a){const u=l[a],c=o[u];typeof c=="object"&&c!==null&&n.indexOf(c)===-1&&(t.push({obj:o,prop:u}),n.push(c))}}return eh(t),e},oh=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},ah=function(e,t){return[].concat(e,t)},Mn=function(e,t){if(_t(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)},lh={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},rt=Array.isArray,ch=Array.prototype.push,Ao=function(r,e){ch.apply(r,rt(e)?e:[e])},uh=Date.prototype.toISOString,Io=Xu,Fr={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:sh,encodeValuesOnly:!1,format:Io,formatter:Ku[Io],indices:!1,serializeDate:function(e){return uh.call(e)},skipNulls:!1,strictNullHandling:!1},hh=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Fn={},Co=function(e,t,n,s,i,o,l,a,u,c,f,h,p,d,g,m,y,w){let _=e,b=w,E=0,S=!1;for(;(b=b.get(Fn))!==void 0&&!S;){const J=b.get(e);if(E+=1,typeof J<"u"){if(J===E)throw new RangeError("Cyclic object value");S=!0}typeof b.get(Fn)>"u"&&(E=0)}if(typeof c=="function"?_=c(t,_):_ instanceof Date?_=p(_):n==="comma"&&rt(_)&&(_=Mn(_,function(J){return J instanceof Date?p(J):J})),_===null){if(o)return u&&!m?u(t,Fr.encoder,y,"key",d):t;_=""}if(hh(_)||oh(_)){if(u){const J=m?t:u(t,Fr.encoder,y,"key",d);return[g(J)+"="+g(u(_,Fr.encoder,y,"value",d))]}return[g(t)+"="+g(String(_))]}const v=[];if(typeof _>"u")return v;let L;if(n==="comma"&&rt(_))m&&u&&(_=Mn(_,u)),L=[{value:_.length>0?_.join(",")||null:void 0}];else if(rt(c))L=c;else{const J=Object.keys(_);L=f?J.sort(f):J}const j=a?t.replace(/\./g,"%2E"):t,x=s&&rt(_)&&_.length===1?j+"[]":j;if(i&&rt(_)&&_.length===0)return x+"[]";for(let J=0;J<L.length;++J){const ue=L[J],$=typeof ue=="object"&&typeof ue.value<"u"?ue.value:_[ue];if(l&&$===null)continue;const Z=h&&a?ue.replace(/\./g,"%2E"):ue,B=rt(_)?typeof n=="function"?n(x,Z):x:x+(h?"."+Z:"["+Z+"]");w.set(e,E);const X=new WeakMap;X.set(Fn,w),Ao(v,Co($,B,n,s,i,o,l,a,n==="comma"&&m&&rt(_)?null:u,c,f,h,p,d,g,m,y,X))}return v},fh=function(e){return Fr};function No(r,e){let t=r;const n=fh();let s,i;typeof n.filter=="function"?(i=n.filter,t=i("",t)):rt(n.filter)&&(i=n.filter,s=i);const o=[];if(typeof t!="object"||t===null)return"";const l=lh[n.arrayFormat],a=l==="comma"&&n.commaRoundTrip;s||(s=Object.keys(t)),n.sort&&s.sort(n.sort);const u=new WeakMap;for(let h=0;h<s.length;++h){const p=s[h];n.skipNulls&&t[p]===null||Ao(o,Co(t[p],p,l,a,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}const c=o.join(n.delimiter);let f=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),c.length>0?f+c:""}const xn=Object.prototype.hasOwnProperty,dh=Array.isArray,xr={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:nh,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},ph=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Ro=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},gh="utf8=%26%2310003%3B",mh="utf8=%E2%9C%93",yh=function(e,t){const n={__proto__:null},s=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,o=s.split(t.delimiter,i);let l=-1,a,u=t.charset;if(t.charsetSentinel)for(a=0;a<o.length;++a)o[a].indexOf("utf8=")===0&&(o[a]===mh?u="utf-8":o[a]===gh&&(u="iso-8859-1"),l=a,a=o.length);for(a=0;a<o.length;++a){if(a===l)continue;const c=o[a],f=c.indexOf("]="),h=f===-1?c.indexOf("="):f+1;let p,d;h===-1?(p=t.decoder(c,xr.decoder,u,"key"),d=t.strictNullHandling?null:""):(p=t.decoder(c.slice(0,h),xr.decoder,u,"key"),d=Mn(Ro(c.slice(h+1),t),function(m){return t.decoder(m,xr.decoder,u,"value")})),d&&t.interpretNumericEntities&&u==="iso-8859-1"&&(d=ph(d)),c.indexOf("[]=")>-1&&(d=dh(d)?[d]:d);const g=xn.call(n,p);g&&t.duplicates==="combine"?n[p]=ah(n[p],d):(!g||t.duplicates==="last")&&(n[p]=d)}return n},wh=function(r,e,t,n){let s=n?e:Ro(e,t);for(let i=r.length-1;i>=0;--i){let o;const l=r[i];if(l==="[]"&&t.parseArrays)o=t.allowEmptyArrays&&s===""?[]:[].concat(s);else{o=t.plainObjects?Object.create(null):{};const a=l.charAt(0)==="["&&l.charAt(l.length-1)==="]"?l.slice(1,-1):l,u=t.decodeDotInKeys?a.replace(/%2E/g,"."):a,c=parseInt(u,10);!t.parseArrays&&u===""?o={0:s}:!isNaN(c)&&l!==u&&String(c)===u&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(o=[],o[c]=s):u!=="__proto__"&&(o[u]=s)}s=o}return s},bh=function(e,t,n,s){if(!e)return;const i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,l=/(\[[^[\]]*])/g;let a=n.depth>0&&o.exec(i);const u=a?i.slice(0,a.index):i,c=[];if(u){if(!n.plainObjects&&xn.call(Object.prototype,u)&&!n.allowPrototypes)return;c.push(u)}let f=0;for(;n.depth>0&&(a=l.exec(i))!==null&&f<n.depth;){if(f+=1,!n.plainObjects&&xn.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(a[1])}return a&&c.push("["+i.slice(a.index)+"]"),wh(c,t,n,s)},Sh=function(e){return xr};function Lo(r,e){const t=Sh();if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};const n=typeof r=="string"?yh(r,t):r;let s=t.plainObjects?Object.create(null):{};const i=Object.keys(n);for(let o=0;o<i.length;++o){const l=i[o],a=bh(l,n[l],t,typeof r=="string");s=rh(s,a,t)}return t.allowSparse===!0?s:ih(s)}class jn{#e;#t;#r;#n;_logger=null;_loggerSystem=null;#s="";#i=!1;#o="";constructor(e,t,n){const s={};this.#e=ce.create({baseURL:e,headers:{...s,...n?n.headers:{}},...n&&{...n,headers:void 0}}),this.#t=t,this.#r=new _c,this.#n=new Oc}setLogger(e){this._logger=e,this.#r.setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}getSystemLogger(){return this._loggerSystem===null&&(this._loggerSystem=we.build("SystemLogger"),this._loggerSystem.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!0,[I.warn]:!0,[I.error]:!0,[I.trace]:!1})),this._loggerSystem}setRestrictionManagerParams(e){this.#r.params=e}getRestrictionManagerParams(){return this.#r.params}setLogTag(e){this.#s=e}clearLogTag(){this.#s=""}async batch(e,t=!0,n=!1){return Array.isArray(e)?this.#c(e,t,n):this.#a(e,t,n)}async#a(e,t=!0,n=!1){const s={};let i=0;const o=(l,a)=>{let u=null,c=null;l.method?(u=l.method??null,c=l?.params??null):Array.isArray(l)&&l.length>0&&(u=l[0]??null,c=l[1]??null),u&&(i++,s[a]=u+"?"+No(c))};for(const[l,a]of Object.entries(e))o(a,l);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u={},c=(d,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=d.split("?");u[g]=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()})}};for(const[d,g]of Object.entries(s))c(g,d);const f={},h=d=>d.hasError("base-error")?d.errors.get("base-error"):new xe({code:"0",description:d.getErrorMessages().join("; "),status:0,requestInfo:{method:d.getQuery().method,params:d.getQuery().params},originalError:d.getErrors().next().value}),p=new qe;for(const d of Object.keys(u)){const g=u[d];if(g.getStatus()!==200||!g.isSuccess){const m=h(g);if(!t&&!g.isSuccess){p.addError(m,d);continue}return Promise.reject(m)}f[d]=n?g:g.getData().result}return p.setData(f),Promise.resolve(p)})}async#c(e,t=!0,n=!1){const s=[];let i=0;const o=l=>{let a=null,u=null;if(l.method?(a=l.method??null,u=l?.params??null):Array.isArray(l)&&l.length>0&&(a=l[0]??null,u=l[1]??null),a){i++;const c=a+"?"+No(u);s.push(c)}};for(const[l,a]of e.entries())o(a);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u=[],c=(d,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=d.split("?"),y=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()});u.push(y)}};for(const[d,g]of s.entries())c(g,d);const f=[],h=d=>d.hasError("base-error")?d.errors.get("base-error"):new xe({code:"0",description:d.getErrorMessages().join("; "),status:0,requestInfo:{method:d.getQuery().method,params:d.getQuery().params},originalError:d.getErrors().next().value}),p=new qe;for(const d of u){if(d.getStatus()!==200||!d.isSuccess){const g=h(d);if(!t&&!d.isSuccess){p.addError(g);continue}return Promise.reject(g)}f.push(n?d:d.getData().result)}return p.setData(f),Promise.resolve(p)})}async call(e,t,n=0){let s=this.#t.getAuthData();return s===!1&&(s=await this.#t.refreshAuth()),await this.#r.check(),this.#i&&!this.isServerSide()&&C.isStringFilled(this.#o)&&this.getSystemLogger().warn(this.#o),this.#e.post(this.#u(e),this.#l(s,t,n)).then(i=>{const o=i.data;return Promise.resolve({status:i.status,payload:o})},async i=>{let o={error:i?.code||0,errorDescription:i?.message||""};if(i instanceof Ln&&i.response&&i.response.data&&!C.isUndefined(i.response.data.error)){const a=i.response.data;o={error:a.error,errorDescription:a.error_description}}const l=new xe({code:String(o.error),description:o.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:i});return l.status===401&&["expired_token","invalid_token"].includes(l.answerError.error)?(this.getLogger().info(`refreshAuth >> ${l.answerError.error} >>>`),s=await this.#t.refreshAuth(),await this.#r.check(),this.#e.post(this.#u(e),this.#l(s,t,n)).then(async a=>{const u=a.data;return Promise.resolve({status:a.status,payload:u})},async a=>{let u={error:a?.code||0,errorDescription:a?.message||""};if(a instanceof Ln&&a.response&&a.response.data){const f=a.response.data;u={error:f.error,errorDescription:f.error_description}}const c=new xe({code:String(u.error),description:u.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:a});return Promise.reject(c)})):Promise.reject(l)}).then(i=>{const o=new Tr({answer:i.payload,query:{method:e,params:t,start:n},status:i.status});return Promise.resolve(o)})}#l(e,t,n=0){const s=Object.assign({},t);return this.#s.length>0&&(s.logTag=this.#s),s.data&&s.data.start&&delete s.data.start,e.refresh_token!=="hook"&&(s.auth=e.access_token),s.start=n,s}#u(e){const t=`${encodeURIComponent(e)}.json`;if(e.includes("task."))return`${t}`;const n=new URLSearchParams({[this.#n.getQueryStringParameterName()]:this.#n.getRequestId(),[this.#n.getQueryStringSdkParameterName()]:"0.5.1",[this.#n.getQueryStringSdkTypeParameterName()]:"b24-js-sdk"});return`${t}?${n.toString()}`}setClientSideWarning(e,t){this.#i=e,this.#o=t}isServerSide(){return typeof window>"u"}}class kt{static batchSize=50;_isInit=!1;_http=null;_logger=null;constructor(){this._isInit=!1}get isInit(){return this._isInit}async init(){this._isInit=!0}destroy(){}setLogger(e){this._logger=e,this.getHttpClient().setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}callMethod(e,t,n){return this.getHttpClient().call(e,t||{},n||0)}async callListMethod(e,t={},n=null,s=null){const i=new qe;return C.isFunction(n)&&n!==null&&n(0),this.callMethod(e,t,0).then(async o=>{let l=[],a;if(s===null?a=o.getData().result:a=o.getData().result[s],l=[...l,...a],o.isMore()){let u=o;for(;u=await u.getNext(this.getHttpClient()),u!==!1;){let c;if(s===null?c=u.getData().result:c=u.getData().result[s],l=[...l,...c],n){const f=u.getTotal();n(f>0?Math.round(100*l.length/f):100)}}}return i.setData(l),n&&n(100),i})}async*fetchListMethod(e,t={},n="ID",s=null){t.order=t.order||{},t.filter=t.filter||{},t.start=-1;const i=`>${n}`;t.order[n]="ASC",t.filter[i]=0;do{const o=await this.callMethod(e,t,t.start);let l;if(!C.isNull(s)&&s!==null?l=o.getData().result[s]:l=o.getData().result,l.length===0||(yield l,l.length<kt.batchSize))break;const a=l.at(-1);a&&n in a&&(t.filter[i]=a[n])}while(!0)}async callBatch(e,t=!0,n=!1){return this.getHttpClient().batch(e,t,n)}chunkArray(e,t=50){const n=[];for(let s=0;s<e.length;s+=t){const i=e.slice(s,s+t);n.push(i)}return n}async callBatchByChunk(e,t=!0){const n=new qe,s=[],i=this.chunkArray(e,kt.batchSize);for(const o of i){const l=await this.callBatch(o,t);s.push(...l.getData())}return n.setData(s)}getHttpClient(){if(!this.isInit||this._http===null)throw new Error("Http not init");return this._http}_getHttpOptions(){return null}_ensureInitialized(){if(!this._isInit)throw new Error("B24 not initialized")}}var Bn=(r=>(r.en="en",r.de="de",r.la="la",r.br="br",r.fr="fr",r.it="it",r.pl="pl",r.ru="ru",r.ua="ua",r.tr="tr",r.sc="sc",r.tc="tc",r.ja="ja",r.vn="vn",r.id="id",r.ms="ms",r.th="th",r.ar="ar",r))(Bn||{});const _h={en:"en-EN",de:"de-DE",la:"es-ES",br:"pt-BR",fr:"fr-FR",it:"it-IT",pl:"pl-PL",ru:"ru-RU",ua:"uk-UA",tr:"tr-TR",sc:"zh-CN",tc:"zh-TW",ja:"ja-JP",vn:"vi-VN",id:"id-ID",ms:"ms-MY",th:"th-TH",ar:"ar-SA"},kh=()=>({scrollWidth:Math.max(document.documentElement.scrollWidth,document.documentElement.offsetWidth),scrollHeight:Math.max(document.documentElement.scrollHeight,document.documentElement.offsetHeight)});let vh=class ft{static isInternalConstructing=!1;static instance=null;_defLocale=null;constructor(){if(!ft.isInternalConstructing)throw new TypeError("FormatterNumber is not constructable");ft.isInternalConstructing=!1}static getInstance(){return ft.instance||(ft.isInternalConstructing=!0,ft.instance=new ft),ft.instance}setDefLocale(e){this._defLocale=e}format(e,t){let n;(typeof t>"u"||!C.isStringFilled(t))&&(t=C.isStringFilled(this._defLocale)?this._defLocale||"en":typeof navigator>"u"?"en":navigator?.language||"en"),Number.isInteger(e)?n=new Intl.NumberFormat(t,{minimumFractionDigits:0,maximumFractionDigits:0}):n=new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2});let s=n.format(e);return t.includes("ru")&&(s=s.replace(",",".")),s}};class T{countryCode;length;structure;example;_cachedRegex=null;constructor(e,t,n,s){this.countryCode=e,this.length=t,this.structure=n,this.example=s}isValid(e){return this.length===e.length&&this.countryCode===e.slice(0,2)&&this._regex().test(e.slice(4))&&this._iso7064Mod9710(this._iso13616Prepare(e))==1}toBBAN(e,t){return(this._regex().exec(e.slice(4)||"")||[]).slice(1).join(t)}fromBBAN(e){if(!this.isValidBBAN(e))throw new Error("Invalid BBAN");const t=("0"+(98-this._iso7064Mod9710(this._iso13616Prepare(this.countryCode+"00"+e)))).slice(-2);return this.countryCode+t+e}isValidBBAN(e){return this.length-4===e.length&&this._regex().test(e)}_regex(){return this._cachedRegex===null&&(this._cachedRegex=this._parseStructure(this.structure)),this._cachedRegex}_parseStructure(e){const t=(e.match(/(.{3})/g)||[]).map(n=>{let s;const i=n.slice(0,1),o=Number.parseInt(n.slice(1),10);switch(i){case"A":s="0-9A-Za-z";break;case"B":s="0-9A-Z";break;case"C":s="A-Za-z";break;case"F":s="0-9";break;case"L":s="a-z";break;case"U":s="A-Z";break;case"W":s="0-9a-z";break}return"(["+s+"]{"+o+"})"});return new RegExp("^"+t.join("")+"$")}_iso13616Prepare(e){return e=e.toUpperCase(),e=e.substring(4)+e.substring(0,4),e.split("").map(t=>{const n=t.charCodeAt(0);return n>=65&&n<=90?(n-65+10).toString():t}).join("")}_iso7064Mod9710(e){let t=e,n;for(;t.length>2;)n=t.slice(0,9),t=Number.parseInt(n,10)%97+t.slice(n.length);return Number.parseInt(t,10)%97}}class nt{static isInternalConstructing=!1;static instance=null;_countries;constructor(){if(!nt.isInternalConstructing)throw new TypeError("FormatterIban is not constructable");nt.isInternalConstructing=!1,this._countries=new Map}static getInstance(){return nt.instance||(nt.isInternalConstructing=!0,nt.instance=new nt),nt.instance}addSpecification(e){this._countries.set(e.countryCode,e)}isValid(e){if(!C.isString(e))return!1;e=this.electronicFormat(e);const t=e.slice(0,2);if(!this._countries.has(t))throw new Error(`No country with code ${t}`);const n=this._countries.get(t);return!!n&&n.isValid(e)}printFormat(e,t){typeof t>"u"&&(t=" ");const n=/(.{4})(?!$)/g;return this.electronicFormat(e).replace(n,"$1"+t)}electronicFormat(e){const t=/[^a-zA-Z0-9]/g;return e.replace(t,"").toUpperCase()}toBBAN(e,t){typeof t>"u"&&(t=" "),e=this.electronicFormat(e);const n=e.slice(0,2);if(!this._countries.has(n))throw new Error(`No country with code ${n}`);const s=this._countries.get(n);if(!s)throw new Error(`No country with code ${n}`);return s.toBBAN(e,t)}fromBBAN(e,t){if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);if(!n)throw new Error(`No country with code ${e}`);return n.fromBBAN(this.electronicFormat(t))}isValidBBAN(e,t){if(!C.isString(t))return!1;if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);return!!n&&n.isValidBBAN(this.electronicFormat(t))}}const Eh=()=>{const r=vh.getInstance(),e=nt.getInstance();return e.addSpecification(new T("AD",24,"F04F04A12","AD1200012030200359100100")),e.addSpecification(new T("AE",23,"F03F16","AE070331234567890123456")),e.addSpecification(new T("AL",28,"F08A16","AL47212110090000000235698741")),e.addSpecification(new T("AT",20,"F05F11","AT611904300234573201")),e.addSpecification(new T("AZ",28,"U04A20","AZ21NABZ00000000137010001944")),e.addSpecification(new T("BA",20,"F03F03F08F02","BA391290079401028494")),e.addSpecification(new T("BE",16,"F03F07F02","BE68539007547034")),e.addSpecification(new T("BG",22,"U04F04F02A08","BG80BNBG96611020345678")),e.addSpecification(new T("BH",22,"U04A14","BH67BMAG00001299123456")),e.addSpecification(new T("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1")),e.addSpecification(new T("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00")),e.addSpecification(new T("CH",21,"F05A12","CH9300762011623852957")),e.addSpecification(new T("CR",22,"F04F14","CR72012300000171549015")),e.addSpecification(new T("CY",28,"F03F05A16","CY17002001280000001200527600")),e.addSpecification(new T("CZ",24,"F04F06F10","CZ6508000000192000145399")),e.addSpecification(new T("DE",22,"F08F10","DE89370400440532013000")),e.addSpecification(new T("DK",18,"F04F09F01","DK5000400440116243")),e.addSpecification(new T("DO",28,"U04F20","DO28BAGR00000001212453611324")),e.addSpecification(new T("EE",20,"F02F02F11F01","EE382200221020145685")),e.addSpecification(new T("EG",29,"F04F04F17","EG800002000156789012345180002")),e.addSpecification(new T("ES",24,"F04F04F01F01F10","ES9121000418450200051332")),e.addSpecification(new T("FI",18,"F06F07F01","FI2112345600000785")),e.addSpecification(new T("FO",18,"F04F09F01","FO6264600001631634")),e.addSpecification(new T("FR",27,"F05F05A11F02","FR1420041010050500013M02606")),e.addSpecification(new T("GB",22,"U04F06F08","GB29NWBK60161331926819")),e.addSpecification(new T("GE",22,"U02F16","GE29NB0000000101904917")),e.addSpecification(new T("GI",23,"U04A15","GI75NWBK000000007099453")),e.addSpecification(new T("GL",18,"F04F09F01","GL8964710001000206")),e.addSpecification(new T("GR",27,"F03F04A16","GR1601101250000000012300695")),e.addSpecification(new T("GT",28,"A04A20","GT82TRAJ01020000001210029690")),e.addSpecification(new T("HR",21,"F07F10","HR1210010051863000160")),e.addSpecification(new T("HU",28,"F03F04F01F15F01","HU42117730161111101800000000")),e.addSpecification(new T("IE",22,"U04F06F08","IE29AIBK93115212345678")),e.addSpecification(new T("IL",23,"F03F03F13","IL620108000000099999999")),e.addSpecification(new T("IS",26,"F04F02F06F10","IS140159260076545510730339")),e.addSpecification(new T("IT",27,"U01F05F05A12","IT60X0542811101000000123456")),e.addSpecification(new T("IQ",23,"U04F03A12","IQ98NBIQ850123456789012")),e.addSpecification(new T("JO",30,"A04F22","JO15AAAA1234567890123456789012")),e.addSpecification(new T("KW",30,"U04A22","KW81CBKU0000000000001234560101")),e.addSpecification(new T("KZ",20,"F03A13","KZ86125KZT5004100100")),e.addSpecification(new T("LB",28,"F04A20","LB62099900000001001901229114")),e.addSpecification(new T("LC",32,"U04F24","LC07HEMM000100010012001200013015")),e.addSpecification(new T("LI",21,"F05A12","LI21088100002324013AA")),e.addSpecification(new T("LT",20,"F05F11","LT121000011101001000")),e.addSpecification(new T("LU",20,"F03A13","LU280019400644750000")),e.addSpecification(new T("LV",21,"U04A13","LV80BANK0000435195001")),e.addSpecification(new T("MC",27,"F05F05A11F02","MC5811222000010123456789030")),e.addSpecification(new T("MD",24,"U02A18","MD24AG000225100013104168")),e.addSpecification(new T("ME",22,"F03F13F02","ME25505000012345678951")),e.addSpecification(new T("MK",19,"F03A10F02","MK07250120000058984")),e.addSpecification(new T("MR",27,"F05F05F11F02","MR1300020001010000123456753")),e.addSpecification(new T("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S")),e.addSpecification(new T("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR")),e.addSpecification(new T("NL",18,"U04F10","NL91ABNA0417164300")),e.addSpecification(new T("NO",15,"F04F06F01","NO9386011117947")),e.addSpecification(new T("PK",24,"U04A16","PK36SCBL0000001123456702")),e.addSpecification(new T("PL",28,"F08F16","PL61109010140000071219812874")),e.addSpecification(new T("PS",29,"U04A21","PS92PALS000000000400123456702")),e.addSpecification(new T("PT",25,"F04F04F11F02","PT50000201231234567890154")),e.addSpecification(new T("QA",29,"U04A21","QA30AAAA123456789012345678901")),e.addSpecification(new T("RO",24,"U04A16","RO49AAAA1B31007593840000")),e.addSpecification(new T("RS",22,"F03F13F02","RS35260005601001611379")),e.addSpecification(new T("SA",24,"F02A18","SA0380000000608010167519")),e.addSpecification(new T("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD")),e.addSpecification(new T("SE",24,"F03F16F01","SE4550000000058398257466")),e.addSpecification(new T("SI",19,"F05F08F02","SI56263300012039086")),e.addSpecification(new T("SK",24,"F04F06F10","SK3112000000198742637541")),e.addSpecification(new T("SM",27,"U01F05F05A12","SM86U0322509800000000270100")),e.addSpecification(new T("ST",25,"F08F11F02","ST68000100010051845310112")),e.addSpecification(new T("SV",28,"U04F20","SV62CENR00000000000000700025")),e.addSpecification(new T("TL",23,"F03F14F02","TL380080012345678910157")),e.addSpecification(new T("TN",24,"F02F03F13F02","TN5910006035183598478831")),e.addSpecification(new T("TR",26,"F05F01A16","TR330006100519786457841326")),e.addSpecification(new T("UA",29,"F25","UA511234567890123456789012345")),e.addSpecification(new T("VA",22,"F18","VA59001123000012345678")),e.addSpecification(new T("VG",24,"U04F16","VG96VPVG0000012345678901")),e.addSpecification(new T("XK",20,"F04F10F02","XK051212012345678906")),e.addSpecification(new T("AO",25,"F21","AO69123456789012345678901")),e.addSpecification(new T("BF",27,"F23","BF2312345678901234567890123")),e.addSpecification(new T("BI",16,"F12","BI41123456789012")),e.addSpecification(new T("BJ",28,"F24","BJ39123456789012345678901234")),e.addSpecification(new T("CI",28,"U02F22","CI70CI1234567890123456789012")),e.addSpecification(new T("CM",27,"F23","CM9012345678901234567890123")),e.addSpecification(new T("CV",25,"F21","CV30123456789012345678901")),e.addSpecification(new T("DZ",24,"F20","DZ8612345678901234567890")),e.addSpecification(new T("IR",26,"F22","IR861234568790123456789012")),e.addSpecification(new T("MG",27,"F23","MG1812345678901234567890123")),e.addSpecification(new T("ML",28,"U01F23","ML15A12345678901234567890123")),e.addSpecification(new T("MZ",25,"F21","MZ25123456789012345678901")),e.addSpecification(new T("SN",28,"U01F23","SN52A12345678901234567890123")),e.addSpecification(new T("GF",27,"F05F05A11F02","GF121234512345123456789AB13")),e.addSpecification(new T("GP",27,"F05F05A11F02","GP791234512345123456789AB13")),e.addSpecification(new T("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13")),e.addSpecification(new T("RE",27,"F05F05A11F02","RE131234512345123456789AB13")),e.addSpecification(new T("PF",27,"F05F05A11F02","PF281234512345123456789AB13")),e.addSpecification(new T("TF",27,"F05F05A11F02","TF891234512345123456789AB13")),e.addSpecification(new T("YT",27,"F05F05A11F02","YT021234512345123456789AB13")),e.addSpecification(new T("NC",27,"F05F05A11F02","NC551234512345123456789AB13")),e.addSpecification(new T("BL",27,"F05F05A11F02","BL391234512345123456789AB13")),e.addSpecification(new T("MF",27,"F05F05A11F02","MF551234512345123456789AB13")),e.addSpecification(new T("PM",27,"F05F05A11F02","PM071234512345123456789AB13")),e.addSpecification(new T("WF",27,"F05F05A11F02","WF621234512345123456789AB13")),{formatterNumber:r,formatterIban:e}};class Po{#e;#t;#r;#n;constructor(e){this.#e=Object.freeze(Object.assign({},e)),this.#t=this.#e.b24Url.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#r=`https://${this.#t}/rest`,this.#n=`https://${this.#t}`}getAuthData(){return{access_token:this.#e.secret,refresh_token:"hook",expires:0,expires_in:0,domain:this.#t,member_id:this.#t}}refreshAuth(){return Promise.resolve(this.getAuthData())}getUniq(e){const t=this.getAuthData();if(t===!1)throw new Error("AuthData not init");return[e,t.member_id].join("_")}getTargetOrigin(){return`${this.#n}`}getTargetOriginWithPath(){return`${this.#r}/${this.#e.userId}/${this.#e.secret}`}get isAdmin(){return!0}}class Un extends kt{#e;constructor(e){super(),this.#e=new Po(e),this._http=new jn(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use hook requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}get auth(){return this.#e}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}static fromWebhookUrl(e){if(!e.trim())throw new Error("Webhook URL cannot be empty");let t;try{t=new URL(e)}catch{throw new Error(`Invalid webhook URL format: ${e}`)}if(t.protocol!=="https:")throw new Error("Webhook requires HTTPS protocol");const n=t.pathname.split("/").filter(Boolean);if(n.length<3||n[0]!=="rest")throw new Error("Webhook URL must follow format: /rest/<userId>/<secret>");const s=n[1],i=n[2];if(!/^\d+$/.test(s))throw new Error(`User ID must be numeric in webhook URL, received: ${s}`);const o=Number.parseInt(s,10);return new Un({b24Url:t.origin,userId:o,secret:i})}}var ee=(r=>(r.getInitData="getInitData",r.setInstallFinish="setInstallFinish",r.setInstall="setInstall",r.refreshAuth="refreshAuth",r.setAppOption="setAppOption",r.setUserOption="setUserOption",r.resizeWindow="resizeWindow",r.reloadWindow="reloadWindow",r.setTitle="setTitle",r.setScroll="setScroll",r.openApplication="openApplication",r.closeApplication="closeApplication",r.openPath="openPath",r.imCallTo="imCallTo",r.imPhoneTo="imPhoneTo",r.imOpenMessenger="imOpenMessenger",r.imOpenHistory="imOpenHistory",r.selectUser="selectUser",r.selectAccess="selectAccess",r.selectCRM="selectCRM",r.showAppForm="showAppForm",r.getInterface="getInterface",r.placementBindEvent="placementBindEvent",r))(ee||{});class Do{#e;#t;#r;_logger=null;runCallbackHandler;constructor(e){this.#e=e,this.#t=new Map,this.#r=new Map,this.runCallbackHandler=this._runCallback.bind(this)}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}subscribe(){window.addEventListener("message",this.runCallbackHandler)}unsubscribe(){window.removeEventListener("message",this.runCallbackHandler)}async send(e,t=null){return new Promise((n,s)=>{let i;const o={resolve:n,reject:s,timeoutId:null},l=this.#n(o);let a=null;const u=Kn(t||{},["singleOption","callBack","isSafely","safelyTime"]),{callBack:c,singleOption:f}=t||{};if(c&&this.#r.set(l,c),f?a=f:Object.keys(u).length>0&&(a={...u}),e.toString().includes(":"))i={method:e.toString(),params:a||"",callback:l,appSid:this.#e.getAppSid()};else{i=e.toString(),t?.isRawValue!==!0&&a?a=JSON.stringify(a):t?.isRawValue===!0&&a&&C.isPlainObject(a)&&a.value&&(a=a.value);const h=[a||"",l,this.#e.getAppSid()];i+=":"+h.filter(Boolean).join(":")}this.getLogger().log(`send to ${this.#e.getTargetOrigin()}`,{cmd:i}),parent.postMessage(i,this.#e.getTargetOrigin()),t?.isSafely&&(this.#t.get(l).timeoutId=window.setTimeout(()=>{this.#t.has(l)&&(this.getLogger().warn(`Action ${e.toString()} stop by timeout`),this.#t.delete(l),n({isSafely:!0}))},Number.parseInt(String(t?.safelyTime||900))))})}_runCallback(e){if(e.origin===this.#e.getTargetOrigin()&&e.data){this.getLogger().log(`get from ${e.origin}`,{data:e.data});const t=e.data.split(":"),n={id:t[0],args:t.slice(1).join(":")};if(n.args&&(n.args=JSON.parse(n.args)),this.#t.has(n.id)){const s=this.#t.get(n.id);s.timeoutId&&clearTimeout(s.timeoutId),this.#t.delete(n.id),s.resolve(n.args)}else if(this.#r.has(n.id)){const s=this.#r.get(n.id);s&&s.apply(globalThis,[n.args])}}}#n(e){const t=V.getUniqId();return this.#t.set(t,e),t}}class Mo{#e="";#t=!0;#r=null;#n=null;#s=null;constructor(e){e.DOMAIN&&(this.#e=e.DOMAIN,this.#e=this.#e.replace(/:(80|443)$/,"")),this.#t=e.PROTOCOL===!0,e.LANG&&(this.#s=e.LANG),e.APP_SID&&(this.#r=e.APP_SID)}initData(e){return this.#e||(this.#e=e.DOMAIN),this.#n||(this.#n=e.PATH),this.#s||(this.#s=e.LANG),this.#t=Number.parseInt(e.PROTOCOL)===1,this.#e=this.#e.replace(/:(80|443)$/,""),this}getAppSid(){if(this.#r===null)throw new Error("Not init appSid");return this.#r}getTargetOrigin(){return`${this.#t?"https":"http"}://${this.#e}`}getTargetOriginWithPath(){return this.getTargetOrigin()+(this.#n??"")}getLang(){return this.#s||Bn.en}}class Fo{#e=null;#t=null;#r=0;#n=0;#s=null;#i=!1;#o;#a;constructor(e,t){this.#o=e,this.#a=t}initData(e){return e.AUTH_ID&&(this.#e=e.AUTH_ID,this.#t=e.REFRESH_ID,this.#n=Number.parseInt(e.AUTH_EXPIRES),this.#r=Date.now()+this.#n*1e3,this.#i=e.IS_ADMIN,this.#s=e.MEMBER_ID||""),this}getAuthData(){return this.#r>Date.now()?{access_token:this.#e,refresh_token:this.#t,expires:this.#r/1e3,expires_in:this.#n,domain:this.#o.getTargetOrigin(),member_id:this.#s}:!1}async refreshAuth(){return this.#a.send(ee.refreshAuth,{}).then(e=>(this.#e=e.AUTH_ID,this.#t=e.REFRESH_ID,this.#r=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,Promise.resolve(this.getAuthData())))}getUniq(e){return[e,this.#s||""].join("_")}get isAdmin(){return this.#i}}class xo{#e;constructor(e){this.#e=e}async closeApplication(){return this.#e.send(ee.closeApplication,{isSafely:!1})}async fitWindow(){const e="100%",t=this.getScrollSize().scrollHeight;return this.#e.send(ee.resizeWindow,{width:e,height:t,isSafely:!0})}async resizeWindow(e,t){return e>0&&t>0?this.#e.send(ee.resizeWindow,{width:e,height:t,isSafely:!0}):Promise.reject(new Error(`Wrong width:number = ${e} or height:number = ${t}`))}async resizeWindowAuto(e=null,t=0,n=0){const s=document.body;let i=Math.max(s.scrollWidth,s.offsetWidth);n>0&&(i=Math.max(n,i));let o=Math.max(s.scrollHeight,s.offsetHeight);return e&&(o=Math.max(e.scrollHeight,e.offsetHeight)),t>0&&(o=Math.max(t,o)),this.resizeWindow(i,o)}getScrollSize(){return kh()}async scrollParentWindow(e){return Number.isInteger(e)?(e<0&&(e=0),this.#e.send(ee.setScroll,{scroll:e,isSafely:!0})):Promise.reject(new Error("Wrong scroll number"))}async reloadWindow(){return this.#e.send(ee.reloadWindow,{isSafely:!0})}async setTitle(e){return this.#e.send(ee.setTitle,{title:e.toString(),isSafely:!0})}async imCallTo(e,t=!0){return this.#e.send(ee.imCallTo,{userId:e,video:t,isSafely:!0})}async imPhoneTo(e){return this.#e.send(ee.imPhoneTo,{phone:e,isSafely:!0})}async imOpenMessenger(e){return this.#e.send(ee.imOpenMessenger,{dialogId:e,isSafely:!0})}async imOpenHistory(e){return this.#e.send(ee.imOpenHistory,{dialogId:e,isSafely:!0})}}let jo=class{#e;#t=null;#r=null;constructor(e){this.#e=e}initData(e){return e.APP_OPTIONS&&(this.#t=e.APP_OPTIONS),e.USER_OPTIONS&&(this.#r=e.USER_OPTIONS),this}appGet(e){if(this.#t&&this.#t[e])return this.#t[e];throw new Error(`app.option.${e} not set`)}async appSet(e,t){return this.#t||(this.#t=[]),this.#t[e]=t,this.#n(ee.setAppOption,e,this.#t[e])}userGet(e){if(this.#r&&this.#r[e])return this.#r[e];throw new Error(`user.option.${e} not set`)}async userSet(e,t){return this.#t||(this.#t=[]),this.#t[e]||(this.#t[e]=null),this.#r[e]=t,this.#n(ee.setUserOption,e,this.#r[e])}async#n(e,t,n){return this.#e.send(e,{name:t,value:n,isSafely:!0}).then(()=>Promise.resolve())}};class Bo{#e;constructor(e){this.#e=e}async selectUser(){return this.#e.send(ee.selectUser,{mult:!1})}async selectUsers(){return this.#e.send(ee.selectUser,{mult:!0})}async selectAccess(e=[]){return console.warn("@deprecated selectAccess"),this.#e.send(ee.selectAccess,{value:e})}async selectCRM(e){return console.warn("@deprecated selectCRM"),this.#e.send(ee.selectCRM,{entityType:e?.entityType,multiple:e?.multiple,value:e?.value})}}class Uo{#e;#t;constructor(e,t){this.#e=e,this.#t=t}getUrl(e="/"){return new URL(e,this.#e.getTargetOrigin())}getTargetOrigin(){return this.#e.getTargetOrigin()}async openSliderAppPage(e={}){return this.#t.send(ee.openApplication,e)}async closeSliderAppPage(){return this.#t.send(ee.closeApplication,{isSafely:!1})}#r(e=1640){return e>0?e>1200&&e<=1640?"/crm/type/0/details/0/../../../../..":e>950&&e<=1200?"/company/personal/user/0/groups/create/../../../../../..":e>900&&e<=950?"/crm/company/requisite/0/../../../..":e<=900?"/workgroups/group/0/card/../../../..":"/crm/deal/../..":"/crm/deal/../.."}async openPath(e,t=1640){const n=new URL(e);return n.searchParams.set("IFRAME","Y"),n.searchParams.set("IFRAME_TYPE","SIDE_SLIDER"),this.#t.send(ee.openPath,{path:[this.#r(t),n.pathname,n.search].join("")}).then(s=>s?.result==="error"?s?.errorCode==="METHOD_NOT_SUPPORTED_ON_DEVICE"?new Promise((i,o)=>{const l=window.open(e,"_blank");if(!l){o(new Error("Error open window"));return}let a=0;const u=1e3*60*5,c=window.setInterval(()=>{a=a+1,l.closed?(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!0})):a>u&&(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!1}))},1e3)}):Promise.reject(new Error(s?.errorCode)):s?.result==="close"?Promise.resolve({isOpenAtNewWindow:!1,isClose:!0}):Promise.resolve({isOpenAtNewWindow:!1,isClose:!1}))}async showAppForm(e){return console.warn("@deprecated showAppForm"),this.#t.send(ee.showAppForm,{params:e,isSafely:!0})}}class $o{#e;#t="";#r={};constructor(e){this.#e=e}initData(e){this.#t=e.PLACEMENT||"DEFAULT";const t=e.PLACEMENT_OPTIONS;return this.#r=Object.freeze(t),this}get title(){return this.#t}get isDefault(){return this.title==="DEFAULT"}get options(){return this.#r}get isSliderMode(){return this.options?.IFRAME==="Y"}async getInterface(){return this.#e.send(ee.getInterface,{isSafely:!0})}async bindEvent(e,t){return this.#e.send(ee.placementBindEvent,{event:e,callBack:t,isSafely:!0})}async call(e,t={}){return this.#e.send(e,{...t,isSafely:!0,isRawValue:["setValue"].includes(e)})}async callCustomBind(e,t=null,n){let s={};return C.isString(t)?s.singleOption=t:C.isObjectLike(t)&&(s={...t}),this.#e.send(e,{...s,callBack:n,isSafely:!0})}}class Wo extends kt{#e=!1;#t=!1;#r;#n;#s;#i;#o;#a;#c;#l;constructor(e){super(),this.#r=new Mo(e),this.#n=new Do(this.#r),this.#n.subscribe(),this.#s=new Fo(this.#r,this.#n),this.#i=new xo(this.#n),this.#o=new jo(this.#n),this.#a=new Bo(this.#n),this.#c=new Uo(this.#r,this.#n),this.#l=new $o(this.#n),this._isInit=!1}setLogger(e){super.setLogger(e),this.#n.setLogger(this.getLogger())}get isFirstRun(){return this._ensureInitialized(),this.#t}get isInstallMode(){return this._ensureInitialized(),this.#e}get parent(){return this._ensureInitialized(),this.#i}get auth(){return this._ensureInitialized(),this.#s}get slider(){return this._ensureInitialized(),this.#c}get placement(){return this._ensureInitialized(),this.#l}get options(){return this._ensureInitialized(),this.#o}get dialog(){return this._ensureInitialized(),this.#a}async init(){return this.#n.send(ee.getInitData,{}).then(e=>(this.getLogger().log("init data:",e),this.#r.initData(e),this.#s.initData(e),this.#l.initData(e),this.#o.initData(e),this.#e=e.INSTALL,this.#t=e.FIRST_RUN,this._http=new jn(this.#r.getTargetOriginWithPath(),this.#s,this._getHttpOptions()),this._isInit=!0,this.#t?this.#n.send(ee.setInstall,{install:!0}):Promise.resolve()))}destroy(){this.#n.unsubscribe(),super.destroy()}async installFinish(){return this.isInstallMode?this.#n.send(ee.setInstallFinish,{}):Promise.reject(new Error("Application was previously installed. You cannot call installFinish"))}getTargetOrigin(){return this._ensureInitialized(),this.#r.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#r.getTargetOriginWithPath()}getAppSid(){return this._ensureInitialized(),this.#r.getAppSid()}getLang(){return this._ensureInitialized(),this.#r.getLang()}}class Th extends xe{}class Vo{#e;#t=null;#r=null;#n;#s;#i=0;#o=0;#a;#c;#l;#u;#h=null;constructor(e,t){this.#n=Object.assign({},e),this.#s=Object.freeze(Object.assign({},t)),this.#a=this.#n.domain.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#c=this.#n.clientEndpoint,this.#l=this.#c.replace("/rest/",""),this.#u=this.#n.serverEndpoint.replace("/rest/",""),this.#i=this.#n.expires*1e3,this.#o=this.#n.expiresIn,this.#e=ce.create({baseURL:this.#u,headers:{"Content-Type":"application/json"}})}getAuthData(){return this.#i>Date.now()?{access_token:this.#n.accessToken,refresh_token:this.#n.refreshToken,expires:this.#i/1e3,expires_in:this.#o,domain:this.#a,member_id:this.#n.memberId}:!1}async refreshAuth(){try{let e;if(this.#r)e=await this.#r();else{const n=await this.#e.get("/oauth/token/",{params:{grant_type:"refresh_token",client_id:this.#s.clientId,client_secret:this.#s.clientSecret,refresh_token:this.#n.refreshToken}});if(n.data.error)throw new Error(`Token update error: ${n.data.error}`);if(n.status!==200)throw new Error(`Token update error status code: ${n.status}`);e=n.data}if(!e)throw new Error("Unable to obtain authorization update data");this.#n.accessToken=e.access_token,this.#n.refreshToken=e.refresh_token,this.#n.expires=Number.parseInt(e.expires||"0"),this.#n.expiresIn=Number.parseInt(e.expires_in||"3600"),this.#n.clientEndpoint=e.client_endpoint,this.#n.serverEndpoint=e.server_endpoint,this.#n.scope=e.scope,this.#n.status=Object.values(et).find(n=>n===e.status)||et.Free,this.#i=this.#n.expires*1e3;const t=this.getAuthData();return this.#t&&await this.#t({authData:t,b24OAuthParams:this.#n}),t}catch(e){if(e instanceof Ln){let t={error:e?.code||0,errorDescription:e?.message||""};if(e.response&&e.response.data&&!C.isUndefined(e.response.data.error)){const n=e.response.data;t={error:n.error,errorDescription:n.error_description}}throw new Th({code:String(t.error),description:t.errorDescription,status:e.response?.status||0,requestInfo:{method:"/oauth/token/"}})}else if(e instanceof Error)throw e;throw new Error(`Strange error: ${e instanceof Error?e.message:e}`,{cause:e})}}setCallbackRefreshAuth(e){this.#t=e}removeCallbackRefreshAuth(){this.#t=null}setCustomRefreshAuth(e){this.#r=e}removeCustomRefreshAuth(){this.#r=null}getUniq(e){return[e,this.#n.memberId||""].join("_")}getTargetOrigin(){return`${this.#l}`}getTargetOriginWithPath(){return`${this.#c}`}get isAdmin(){if(this.#h===null)throw new Error("isAdmin not init. You need call B24OAuth::initIsAdmin().");return this.#h}async initIsAdmin(e){const t=await e.call("profile",{},0);if(!t.isSuccess)throw new Error(t.getErrorMessages().join(";"));t.getData().result?.ADMIN&&(this.#h=!0)}}class Oh extends kt{#e;constructor(e,t){super(),this.#e=new Vo(e,t),this._http=new jn(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use oauth requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}async initIsAdmin(){return this._ensureInitialized(),this.#e.initIsAdmin(this._http)}setCallbackRefreshAuth(e){this._ensureInitialized(),this.#e.setCallbackRefreshAuth(e)}removeCallbackRefreshAuth(){this._ensureInitialized(),this.#e.removeCallbackRefreshAuth()}setCustomRefreshAuth(e){this._ensureInitialized(),this.#e.setCustomRefreshAuth(e)}removeCustomRefreshAuth(){this._ensureInitialized(),this.#e.removeCustomRefreshAuth()}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}get auth(){return this.#e}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}}class $n extends Error{constructor(e,...t){super(...t),this.name="UnhandledMatchError",this.message=`Unhandled match value of type ${e}`,this.stack=new Error("for stack").stack}}class jt{_b24;_logger=null;_data=null;constructor(e){this._b24=e}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async initData(e){return this.getLogger().log(e),Promise.reject(new Error("Rewrite this function"))}}class Ah extends jt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("ProfileManager.data not initialized");return this._data}}class Ih extends jt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("AppManager.data not initialized");return this._data}get statusCode(){return Bi[this.data.status]||"Unknown status"}}class Ch extends jt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("PaymentManager.data not initialized");return this._data}}class Nh extends jt{_data=null;async initData(e){this._data=e,this.makeRestrictionManagerParams()}get data(){if(this._data===null)throw new Error("LicenseManager.data not initialized");return this._data}makeRestrictionManagerParams(){this.data?.license&&this.data.license.includes("ent")&&(this.getLogger().log(`LICENSE ${this.data.license} => up restriction manager params`,mn),this._b24.getHttpClient().setRestrictionManagerParams(mn))}}class Rh extends jt{async initData(e){this._data={currencyBase:"?",currencyList:new Map},this.setBaseCurrency(e.currencyBase),this.setCurrencyList(e.currencyList);try{await this.loadData()}catch(t){throw t instanceof Error?t:(console.error(t),new Error("Failed to load data"))}}async loadData(){const e=this.currencyList.map(t=>({method:"crm.currency.get",params:{id:t}}));if(e.length===0)return Promise.resolve();try{(await this._b24.callBatchByChunk(e,!0)).getData().forEach(t=>{if(typeof t.LANG>"u")return;const n=t.CURRENCY,s=this.data.currencyList.get(n);if(!(typeof s>"u"))for(const[i,o]of Object.entries(t.LANG))switch(s.lang[i]={decimals:Number.parseInt(o.DECIMALS),decPoint:o.DEC_POINT,formatString:o.FORMAT_STRING,fullName:o.FULL_NAME,isHideZero:o.HIDE_ZERO==="Y",thousandsSep:o.THOUSANDS_SEP,thousandsVariant:o.THOUSANDS_VARIANT},s.lang[i].thousandsVariant){case"N":s.lang[i].thousandsSep="";break;case"D":s.lang[i].thousandsSep=".";break;case"C":s.lang[i].thousandsSep=",";break;case"S":s.lang[i].thousandsSep=" ";break;case"B":s.lang[i].thousandsSep="&nbsp;";break;default:C.isStringFilled(s.lang[i].thousandsSep)||(s.lang[i].thousandsSep=" ");break}})}catch(t){console.error(t)}}get data(){if(this._data===null)throw new Error("CurrencyManager.data not initialized");return this._data}setBaseCurrency(e){this._data.currencyBase=e}get baseCurrency(){return this.data.currencyBase}setCurrencyList(e=[]){this.data.currencyList.clear();for(const t of e)this.data.currencyList.set(t.CURRENCY,{amount:Number.parseFloat(t.CURRENCY),amountCnt:Number.parseInt(t.AMOUNT_CNT),isBase:t.BASE==="Y",currencyCode:t.CURRENCY,dateUpdate:V.toDateTime(t.DATE_UPDATE),decimals:Number.parseInt(t.DECIMALS),decPoint:t.DEC_POINT,formatString:t.FORMAT_STRING,fullName:t.FULL_NAME,lid:t.LID,sort:Number.parseInt(t.SORT),thousandsSep:t?.THOUSANDS_SEP||null,lang:{}})}getCurrencyFullName(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new $n(e);let s=n.fullName;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.fullName)}return s}getCurrencyLiteral(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new $n(e);let s=n.formatString;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.formatString)}return s.replaceAll("&#","&%").replaceAll("#","").replaceAll("&%","&#").trim()||""}get currencyList(){return[...this.data.currencyList.keys()]}format(e,t,n){const s=this.data.currencyList.get(t);if(typeof s>"u")throw new $n(t);const i={formatString:s.formatString,decimals:s.decimals,decPoint:s.decPoint,thousandsSep:s.thousandsSep};C.isStringFilled(i.thousandsSep)||(i.thousandsSep="");const o=s.lang[n];return C.isUndefined(o)||(i.formatString=o.formatString,i.decimals=o.decimals,i.decPoint=o.decPoint,i.thousandsSep=o.thousandsSep),i.formatString.replaceAll("&#","&%").replace("#",V.numberFormat(e,i.decimals,i.decPoint,i.thousandsSep)).replaceAll("&%","&#")||""}}class Wn extends jt{_data;_type;static getSupportTypes(){return[tt.NotSet,tt.JsonArray,tt.JsonObject,tt.FloatVal,tt.IntegerVal,tt.BoolYN,tt.StringVal]}static prepareArrayList(e){return C.isArray(e)?e:C.isObject(e)?Object.values(e):[]}constructor(e,t){super(e),this._type=t,this._data=new Map}get data(){return this._data}reset(){this.data.clear()}async initData(e){if(this.reset(),C.isObject(e))for(const[t,n]of Object.entries(e))this.data.set(t,n)}getJsonArray(e,t=[]){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n),!C.isArray(n)&&!C.isObject(n)&&(n=t)}catch(s){this.getLogger().error(s),n=t}return Wn.prepareArrayList(n)}getJsonObject(e,t={}){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n)}catch(s){this.getLogger().error(s),n=t}return C.isObject(n)||(n=t),n}getFloat(e,t=0){return this.data.has(e)?V.toNumber(this.data.get(e)):t}getInteger(e,t=0){return this.data.has(e)?V.toInteger(this.data.get(e)):t}getBoolYN(e,t=!0){return this.data.has(e)?V.toBoolean(this.data.get(e)):t}getBoolNY(e,t=!1){return this.data.has(e)?V.toBoolean(this.data.get(e)):t}getString(e,t=""){return this.data.has(e)?this.data.get(e).toString():t}getDate(e,t=null){if(!this.data.has(e))return t;try{const n=V.toDateTime(this.data.get(e).toString());return n.isValid?n:t}catch{return t}}encode(e){return JSON.stringify(e)}decode(e,t){try{return e.length>0?JSON.parse(e):t}catch(n){this.getLogger().warn(n,e)}return t}getMethodSave(){switch(this._type){case"app":return"app.option.set";case"user":return"user.option.set"}}async save(e,t){const n=[];return n.push({method:this.getMethodSave(),params:{options:e}}),C.isObject(t)&&n.push({method:"pull.application.event.add",params:{COMMAND:t?.command,PARAMS:t?.params,MODULE_ID:t?.moduleId}}),this._b24.callBatch(n,!0)}}class qo{_logger=null;userId;siteId;constructor(e={}){this.userId=e.userId?V.toInteger(e.userId):0,this.siteId=e.siteId??"none"}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}set(e,t){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}typeof t!="string"&&t&&(t=JSON.stringify(t)),window.localStorage.setItem(this._getKey(e),t)}get(e,t){if(typeof window.localStorage>"u")return t||null;const n=window.localStorage.getItem(this._getKey(e));return n===null?t||null:JSON.parse(n)}remove(e){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}return window.localStorage.removeItem(this._getKey(e))}_getKey(e){return`@bitrix24/b24jssdk-pull-${this.userId}-${this.siteId}-${e}`}compareKey(e,t){return e===this._getKey(t)}}class Lh extends Error{constructor(e){super(e),this.name="ErrorNotConnected"}}class Ph extends Error{constructor(e){super(e),this.name="ErrorTimeout"}}const jr="2.0";class Dh{_logger=null;_connector;_idCounter=0;_handlers={};_rpcResponseAwaiters=new Map;constructor(e){if(this._connector=e.connector,C.isPlainObject(e.handlers))for(const t in e.handlers)this.handle(t,e.handlers[t])}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}handle(e,t){this._handlers[e]=t}async executeOutgoingRpcCommand(e,t,n=5){return new Promise((s,i)=>{const o=this.createRequest(e,t);this._connector.send(JSON.stringify(o))||i(new Lh("websocket is not connected"));const l=setTimeout(()=>{this._rpcResponseAwaiters.delete(o.id),i(new Ph("no response"))},n*1e3);this._rpcResponseAwaiters.set(o.id,{resolve:s,reject:i,timeout:l})})}executeOutgoingRpcBatch(e){const t=[],n=[];return e.forEach(({method:s,params:i,id:o})=>{const l=this.createRequest(s,i,o);t.push(l),n.push(new Promise((a,u)=>this._rpcResponseAwaiters.set(l.id,{resolve:a,reject:u})))}),this._connector.send(JSON.stringify(t)),n}processRpcResponse(e){if("id"in e&&this._rpcResponseAwaiters.has(Number(e.id))){const t=this._rpcResponseAwaiters.get(Number(e.id));t&&("result"in e?t.resolve(e.result):"error"in e?t.reject(e?.error||"error"):t.reject("wrong response structure"),clearTimeout(t.timeout),this._rpcResponseAwaiters.delete(Number(e.id)));return}this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Received rpc response with unknown id`),e)}parseJsonRpcMessage(e){let t;try{t=JSON.parse(e)}catch(n){this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Could not decode json rpc message`),n);return}if(C.isArray(t))return this.executeIncomingRpcBatch(t);if(C.isJsonRpcRequest(t))return this.executeIncomingRpcCommand(t);if(C.isJsonRpcResponse(t))return this.processRpcResponse(t);this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: unknown rpc packet`),t)}executeIncomingRpcCommand({method:e,params:t}){return e in this._handlers?this._handlers[e].call(this,t||{}):{jsonrpc:jr,error:Sn.MethodNotFound}}executeIncomingRpcBatch(e){const t=[];for(const n of e)if("jsonrpc"in n)if("method"in n){const s=this.executeIncomingRpcCommand(n);s&&(s.jsonrpc=jr,s.id=n.id,t.push(s))}else this.processRpcResponse(n);else this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: unknown rpc command in batch`),n),t.push({jsonrpc:jr,error:Sn.InvalidRequest});return t}nextId(){return++this._idCounter}createPublishRequest(e){return e.map(t=>this.createRequest("publish",t))}createRequest(e,t,n){return n||(n=this.nextId()),{jsonrpc:jr,method:e,params:t,id:n}}}class Mh{_logger=null;_storage;_ttl=1440*60;_callbacks;constructor(e={}){e=e||{},this._storage=e.storage||new qo,this._callbacks={onWebSocketBlockChanged:C.isFunction(e.onWebSocketBlockChanged)?e.onWebSocketBlockChanged:()=>{}},this._storage&&window.addEventListener("storage",this.onLocalStorageSet.bind(this))}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}onLocalStorageSet(e){this._storage.compareKey(e.key||"",Re.WebsocketBlocked)&&e.newValue!==e.oldValue&&this._callbacks.onWebSocketBlockChanged({isWebSocketBlocked:this.isWebSocketBlocked()})}isWebSocketBlocked(){return this._storage?this._storage.get(Re.WebsocketBlocked,0)>Date.now():!1}setWebSocketBlocked(e){if(!this._storage)return!1;try{this._storage.set(Re.WebsocketBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Could not save WS_blocked flag in local storage. Error: `),t),!1}return!0}isLongPollingBlocked(){return this._storage?this._storage.get(Re.LongPollingBlocked,0)>Date.now():!1}setLongPollingBlocked(e){if(!this._storage)return!1;try{this._storage.set(Re.LongPollingBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${V.getDateForLog()}: Pull: Could not save LP_blocked flag in local storage. Error: `),t),!1}return!0}isLoggingEnabled(){return this._storage?this._storage.get(Re.LoggingEnabled,0)>this.getTimestamp():!1}setLoggingEnabled(e){if(!this._storage)return!1;try{this._storage.set(Re.LoggingEnabled,e?this.getTimestamp()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${V.getDateForLog()}: LocalStorage error: `),t),!1}return!0}getTimestamp(){return Date.now()}}class Fh{_logger=null;_publicIds;_restClient;_getPublicListMethod;constructor(e){this._publicIds=new Map,this._restClient=e.b24,this._getPublicListMethod=e.getPublicListMethod}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=we.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async getPublicIds(e){const t=new Date,n={},s=[];for(const i of e){const o=this._publicIds.get(i);o&&o.end>t?n[o.userId]=o:s.push(i)}return s.length===0?Promise.resolve(n):new Promise(i=>{this._restClient.callMethod(this._getPublicListMethod,{users:s}).then(o=>{const l=o.getData().result;this.setPublicIds(Object.values(l));for(const a of s){const u=this._publicIds.get(a);u&&(n[u.userId]=u)}i(n)}).catch(o=>(this.getLogger().error(o),i({})))})}setPublicIds(e){e.forEach(t=>{const n=Number(t.user_id);this._publicIds.set(n,{userId:n,publicId:t.public_id,signature:t.signature,start:new Date(t.start),end:new Date(t.end)})})}}var sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vn={exports:{}};/*!
13
13
  * protobuf.js v6.8.6 (c) 2016, daniel wirtz
14
14
  * compiled mon, 26 feb 2018 11:35:34 utc
15
15
  * licensed under the bsd-3-clause license