@snabcentr/common-lib 2.52.3 → 2.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.json +1 -1
- package/dist/release_notes.tmp +2 -6
- package/dist/sc-common-lib.js +642 -609
- package/dist/sc-common-lib.js.map +1 -1
- package/dist/sc-common-lib.umd.cjs +1 -1
- package/dist/sc-common-lib.umd.cjs.map +1 -1
- package/dist/src/suggestion/enums/address-quality-enum.d.ts +18 -0
- package/dist/src/suggestion/enums/address-quality-enum.d.ts.map +1 -0
- package/dist/src/suggestion/enums/index.d.ts +2 -0
- package/dist/src/suggestion/enums/index.d.ts.map +1 -0
- package/dist/src/suggestion/helpers/address-quality-helper.d.ts +25 -0
- package/dist/src/suggestion/helpers/address-quality-helper.d.ts.map +1 -0
- package/dist/src/suggestion/helpers/index.d.ts +2 -0
- package/dist/src/suggestion/helpers/index.d.ts.map +1 -0
- package/dist/src/suggestion/index.d.ts +2 -0
- package/dist/src/suggestion/index.d.ts.map +1 -1
- package/dist/src/suggestion/interfaces/i-address-suggestion.d.ts +5 -0
- package/dist/src/suggestion/interfaces/i-address-suggestion.d.ts.map +1 -1
- package/dist/src/suggestion/interfaces/i-organization-suggestion.d.ts +13 -0
- package/dist/src/suggestion/interfaces/i-organization-suggestion.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("jwt-decode"),require("lodash-es"),require("ts-case-convert"),require("pinia"),require("vue"),require("date-fns"),require("axios")):typeof define=="function"&&define.amd?define(["exports","jwt-decode","lodash-es","ts-case-convert","pinia","vue","date-fns","axios"],k):(c=typeof globalThis<"u"?globalThis:c||self,k(c["SC Common Lib"]={},c["jwt-decode"],c["lodash-es"],c["ts-case-convert"],c.pinia,c.vue,c["date-fns"],c.axios))})(this,function(c,k,u,de,x,f,l,Wr){"use strict";var Ti=Object.defineProperty;var Si=(c,k,u)=>k in c?Ti(c,k,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[k]=u;var i=(c,k,u)=>Si(c,typeof k!="symbol"?k+"":k,u);class X{constructor(r){i(this,"exp",0);i(this,"iat",0);i(this,"authTime",0);i(this,"jti","");i(this,"iss","");i(this,"aud",[]);i(this,"sub","");i(this,"typ","Bearer");i(this,"azp","");i(this,"sid","");i(this,"acr","");i(this,"allowedOrigins",[]);i(this,"realmAccess",{roles:[]});i(this,"resourceAccess",{});i(this,"scope","");i(this,"emailVerified",!1);i(this,"name","");i(this,"guid","");i(this,"preferredUsername","");i(this,"givenName","");i(this,"email","");u.merge(this,r)}static getJwtPayload(r){const e=k.jwtDecode(r),t=new X(de.objectToCamel(e));return t.resourceAccess=e.resource_access,t}}class Xe extends X{constructor(e){super(e);i(this,"familyName");i(this,"middleName");i(this,"locale");i(this,"phoneNumber");i(this,"phoneNumberVerified");i(this,"address");u.merge(this,e)}static getJwtPayload(e){const t=k.jwtDecode(e),s=new Xe(de.objectToCamel(t));return s.resourceAccess=t.resource_access,s}}class zr{constructor(r){i(this,"phone");i(this,"tablet");i(this,"laptop");this.phone=(r==null?void 0:r.phone)??360,this.tablet=(r==null?void 0:r.tablet)??600,this.laptop=(r==null?void 0:r.laptop)??1024}}class jr{constructor(r){i(this,"portalApiUrl");i(this,"mediaUrl");i(this,"responseDataCacheTimeout");this.portalApiUrl=(r==null?void 0:r.portalApiUrl)??"",this.mediaUrl=(r==null?void 0:r.mediaUrl)??"",this.responseDataCacheTimeout=(r==null?void 0:r.responseDataCacheTimeout)??3*60*60}}class Yr{constructor(r){i(this,"dsn");i(this,"environment");i(this,"ignoreErrors");i(this,"trace");i(this,"replay");i(this,"additionalParams");var e,t,s,o;this.dsn=(r==null?void 0:r.dsn)??"",this.environment=(r==null?void 0:r.environment)??"production",this.ignoreErrors=(r==null?void 0:r.ignoreErrors)??[/Network\s{1,3}Error/,/Request\s{1,3}aborted/,/Request\s{1,3}failed\s{1,3}with\s{1,3}status\s{1,3}code\s{1,3}(401|403|404|422)/],this.trace={allowedTargets:((e=r==null?void 0:r.trace)==null?void 0:e.allowedTargets)??[/^\//],sampleRate:((t=r==null?void 0:r.trace)==null?void 0:t.sampleRate)??0},this.replay={replaysOnErrorSampleRate:((s=r==null?void 0:r.replay)==null?void 0:s.replaysOnErrorSampleRate)??0,replaysSessionSampleRate:((o=r==null?void 0:r.replay)==null?void 0:o.replaysSessionSampleRate)??0},this.additionalParams=(r==null?void 0:r.additionalParams)??{}}}class Gr{constructor(r){i(this,"broadcaster");i(this,"key");i(this,"wsHost");i(this,"wsPort");i(this,"wssPort");i(this,"forceTLS");i(this,"enabledTransports");this.broadcaster=r.broadcaster??"reverb",this.key=r.key??"",this.wsHost=r.wsHost??"",this.wsPort=r.wsPort??8080,this.wssPort=r.wssPort??8080,this.forceTLS=r.forceTLS??!1,this.enabledTransports=r.enabledTransports??["wss"]}}class Qr{constructor(r){i(this,"environment");i(this,"devMode");i(this,"http");i(this,"deviceTypeByResolution");i(this,"sentry");i(this,"tableDefaultHeightCoefficient");i(this,"urls");i(this,"websocket");i(this,"dateFormats");var e,t,s;this.environment=(r==null?void 0:r.environment)??"production",this.devMode=(r==null?void 0:r.devMode)??{},this.http=new jr(r==null?void 0:r.http),this.deviceTypeByResolution=new zr(r==null?void 0:r.deviceTypeByResolution),this.sentry=new Yr({environment:this.environment,...r==null?void 0:r.sentry}),this.tableDefaultHeightCoefficient=(r==null?void 0:r.tableDefaultHeightCoefficient)??.7,this.urls=r==null?void 0:r.urls,this.websocket=r!=null&&r.websocket?new Gr(r.websocket):void 0,this.dateFormats={api:((e=r==null?void 0:r.dateFormats)==null?void 0:e.api)??"yyyy-MM-dd HH:mm:ss",uiDate:((t=r==null?void 0:r.dateFormats)==null?void 0:t.uiDate)??"dd.MM.yyyy",uiDateWithTime:((s=r==null?void 0:r.dateFormats)==null?void 0:s.uiDateWithTime)??"dd.MM.yyyy HH:mm"}}}const b=x.defineStore("common.config",()=>{const n=f.ref(new Qr);return{config:n,getConfig:()=>n.value,setConfig:t=>{n.value=u.merge(n.value,t)}}});class De{static getActualDataFromStorage(r){if(!this.isLocalStorageAvailable())return;let e=null;try{e=localStorage.getItem(r)}catch{return}if(e)try{const t=JSON.parse(e);if(!t.availableFor||l.isAfter(l.parseISO(t.availableFor)||l.startOfToday(),new Date)){if(u.isNil(t.data)||u.isEmpty(t.data))throw new Error("Data is empty");return t.data}localStorage.removeItem(r)}catch{try{localStorage.removeItem(r)}catch{}}}static saveActualDataToStorage(r,e,t){if(this.isLocalStorageAvailable())try{if(u.isNil(e)||u.isEmpty(e))throw new Error("Data is empty");const s=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,s)}catch(s){if(s instanceof DOMException&&s.code===DOMException.QUOTA_EXCEEDED_ERR){this.clearOldData();try{const o=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,o)}catch{}}else try{localStorage.removeItem(r)}catch{}}}static isLocalStorageAvailable(){try{const r="__localStorage_test__";return localStorage.setItem(r,"test"),localStorage.removeItem(r),!0}catch{return!1}}static clearOldData(){try{const r=[];for(let e=0;e<localStorage.length;e++){const t=localStorage.key(e);if(t)try{const s=localStorage.getItem(t);if(s){const o=JSON.parse(s);o.availableFor&&!l.isAfter(l.parseISO(o.availableFor)||l.startOfToday(),new Date)&&r.push(t)}}catch{r.push(t)}}r.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}catch{}}}function Vr(n){try{const r=X.getJwtPayload(n);return new Date(r.exp*1e3)}catch{return}}const ce=x.defineStore("common.auth_state_private",()=>{const n=f.ref((()=>{var g;const o=De.getActualDataFromStorage("sc.token");if(o)return Promise.resolve(o);const p=(g=b().config.devMode)==null?void 0:g.initAuthBearerToken;return p?Promise.resolve(p):void 0})()),r=f.ref(void 0),e=f.ref(void 0),t=f.markRaw(new Map);function s(){e.value=void 0,u.isNil(n.value)||n.value.then(o=>{const p=X.getJwtPayload(o);e.value=p.exp*1e3>Date.now()?u.mapValues(p.resourceAccess,g=>(g==null?void 0:g.roles)??[]):void 0}).catch(u.noop)}return{jwtToken:n,jwtTokenUpdater:r,userPermissions:e,userPermissionsComputedRefs:t,recalculateUserPermissions:s}}),Re=x.defineStore("common.auth_state",()=>{const n=f.computed(()=>{const o=ce();if(u.isNil(o.jwtToken)&&!u.isNil(o.jwtTokenUpdater)){const p=o.jwtTokenUpdater();o.jwtToken=p,p.then(g=>{o.jwtToken=Promise.resolve(g),De.saveActualDataToStorage("sc.token",g,Vr(g)),o.recalculateUserPermissions()}).catch(u.noop)}return o.jwtToken});function r(o){ce().jwtTokenUpdater=o}function e(o){const p=ce();p.jwtToken=Promise.resolve(o),De.saveActualDataToStorage("sc.token",o,Vr(o)),p.recalculateUserPermissions()}function t(){const o=ce();o.jwtToken=void 0,o.userPermissions=void 0,De.saveActualDataToStorage("sc.token",void 0)}function s(o){const p=ce();!u.isNil(p.jwtToken)&&u.isNil(p.userPermissions)&&p.jwtToken.then(a=>{const v=X.getJwtPayload(a);p.userPermissions=v.exp*1e3>Date.now()?u.mapValues(v.resourceAccess,R=>(R==null?void 0:R.roles)??[]):void 0}).catch(u.noop);const g=u.isArray(o)?o.join(" && "):o;if(p.userPermissionsComputedRefs.has(g))return p.userPermissionsComputedRefs.get(g);const m=f.computed(()=>{const a=v=>{var ve;const R=u.split(v,".");if(R.length<2)return!1;const[ke,Ie]=R,Pe=(ve=ce().userPermissions)==null?void 0:ve[ke];return u.isArray(Pe)&&Pe.includes(Ie)};return u.isArray(o)?u.every(o,v=>a(v)):a(o)});return p.userPermissionsComputedRefs.set(g,m),m}return{jwtToken:n,setJwtTokenUpdater:r,setJwtToken:e,invalidateJwtToken:t,hasUserPermission:s}});var Te=(n=>(n.Image="image",n.Video="video",n))(Te||{});class N{constructor(r,e){i(this,"id");i(this,"guid");this.id=r==null?void 0:r.id,u.isNil(this.id)&&(u.isNil(e)?typeof(r==null?void 0:r.id)=="number"?this.id=-1:typeof(r==null?void 0:r.id)=="string"&&(this.id=""):this.id=e),this.guid=(r==null?void 0:r.guid)??""}isNewRec(){return typeof this.id=="number"?this.id===-1:typeof this.id=="string"?this.id==="":u.isNil(this.id)}}class Le extends N{constructor(e){super(e,"");i(this,"mediaType");i(this,"isCover");i(this,"isUnused");i(this,"url");i(this,"urlWebp");this.mediaType=(e==null?void 0:e.mediaType)??Te.Image,this.isCover=(e==null?void 0:e.isCover)??!1,this.isUnused=(e==null?void 0:e.isUnused)??!1,this.url=(e==null?void 0:e.url)??"",this.urlWebp=e==null?void 0:e.urlWebp}isImage(){return this.mediaType===Te.Image}isVideo(){return this.mediaType===Te.Video}}var Se=(n=>(n.Draft="draft",n.Published="published",n.Scheduled="scheduled",n))(Se||{});class Z extends N{constructor(e){super(e,-1);i(this,"slug");i(this,"title");i(this,"publishedAt");i(this,"createdAt");this.slug=(e==null?void 0:e.slug)??"",this.title=(e==null?void 0:e.title)??"",this.publishedAt=Z.parseDate(e==null?void 0:e.publishedAt),this.createdAt=Z.parseDate(e==null?void 0:e.createdAt)??new Date}static resolvePublicationStatus(e){return u.isNil(e)?Se.Draft:e.getTime()>Date.now()?Se.Scheduled:Se.Published}static getSlugError(e){return e?/[^a-z0-9-]/.test(e)?"Допустимы только строчные латинские буквы, цифры и дефис: пример «kak-vybrat-podokonnik».":u.startsWith(e,"-")||u.endsWith(e,"-")?"Обозначение не может начинаться или заканчиваться дефисом.":u.includes(e,"--")?"Дефисы не могут идти подряд: разделяйте слова одним дефисом.":"":""}static parseDate(e){return u.isNil(e)?null:u.isString(e)?l.parseISO(e):e}getPublicationStatus(){return Z.resolvePublicationStatus(this.publishedAt)}}class _e extends Z{constructor(e){super(e);i(this,"content");i(this,"media");this.content=(e==null?void 0:e.content)??"",this.media=((e==null?void 0:e.media)??[]).map(t=>new Le(t))}toSaveData(e=!1){return{title:this.title,slug:this.slug.length>0?this.slug:void 0,content:e?this.content:void 0,publishedAt:this.publishedAt}}getCover(){return this.media.find(e=>e.isCover)}getUnusedMedia(){return this.media.filter(e=>e.isUnused)}}class le{asClearRaw(){const r={};return Object.keys(this).forEach(e=>{const t=this[e];u.isNil(t)||u.isString(t)&&t.trim().length===0||u.isFunction(t.isNewRec)&&t.isNewRec()||(r[e]=t)}),r}}class T{constructor(r){i(this,"from");i(this,"to");this.from=u.isString(r==null?void 0:r.from)?l.parseISO(r.from):(r==null?void 0:r.from)??null,this.to=u.isString(r==null?void 0:r.to)?l.parseISO(r.to):(r==null?void 0:r.to)??null}}class It extends le{constructor(e){super();i(this,"id");i(this,"title");i(this,"slug");i(this,"content");i(this,"publicationStatus");i(this,"publishedAt");i(this,"createdAt");this.id=e==null?void 0:e.id,this.title=e==null?void 0:e.title,this.slug=e==null?void 0:e.slug,this.content=e==null?void 0:e.content,this.publicationStatus=e==null?void 0:e.publicationStatus,this.publishedAt=new T(e==null?void 0:e.publishedAt),this.createdAt=new T(e==null?void 0:e.createdAt)}resetFilterValue(e){switch(e){case"id":case"title":case"slug":case"content":case"publicationStatus":this[e]=void 0;break;case"publishedAt":this.publishedAt.from=null,this.publishedAt.to=null;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break}return this}asClearRaw(){var t,s,o,p;const e=super.asClearRaw();return!((t=e==null?void 0:e.publishedAt)!=null&&t.from)&&!((s=e==null?void 0:e.publishedAt)!=null&&s.to)&&delete e.publishedAt,!((o=e==null?void 0:e.createdAt)!=null&&o.from)&&!((p=e==null?void 0:e.createdAt)!=null&&p.to)&&delete e.createdAt,e}}var M=(n=>(n.BASE_URL_REQUEST_INTERCEPTOR="baseUrlRequestInterceptor",n.DEFAULT_REQUEST_INTERCEPTOR="defaultRequestInterceptor",n.AUTH_REQUEST_INTERCEPTOR="authRequestInterceptor",n.DATA_CONVERTER_REQUEST_INTERCEPTOR="dataConverterRequestInterceptor",n.CONVERT_HTTP_ERROR_RESPONSE_INTERCEPTOR="convertHttpErrorResponseInterceptor",n.CANCELED_RESPONSE_INTERCEPTOR="canceledResponseInterceptor",n.AUTH_ERRORS_RESPONSE_INTERCEPTOR="authErrorsResponseInterceptor",n.DATA_CONVERTER_RESPONSE_INTERCEPTOR="dataConverterResponseInterceptor",n))(M||{});class I{static simpleInstanceInitializer(r){return new r}static instanceInitializer(r,e){return new r(e)}static instanceListInitializer(r,e){if(!u.isArray(e))throw new TypeError(`Ожидался список данных для инициализации "${r.name}", получены данные типа "${typeof e}".`);return u.map(e,t=>I.instanceInitializer(r,t))}}const P=class P{constructor(){i(this,"httpClient");i(this,"baseUrl",`${b().config.http.portalApiUrl}/api`);i(this,"interceptorIds",{request:{},response:{}});i(this,"setBaseUrlRequestInterceptor",r=>(r.baseURL=this.baseUrl,r));i(this,"authRequestInterceptor",async r=>{const e=Re().jwtToken,t=u.isNil(e)?void 0:await e;return t&&r.headers.set("Authorization",`Bearer ${t}`),r});i(this,"dataConverterRequestInterceptor",r=>(r.method&&(r.method==="get"&&!u.isNil(r.params)&&(r.params=P.toSnakeCaseData(r.params)),["put","patch","post"].includes(u.toLower(r.method))&&!u.isNil(r.data)&&(r.data=P.toSnakeCaseData(r.data))),r));i(this,"authErrorsResponseInterceptors",async r=>{var t;const e=r.rawError?(t=r.rawError)==null?void 0:t.config:void 0;if(r.status===401){if(!e||e.__isRetryRequest)return Promise.reject(r);e.__isRetryRequest=!0;try{await P.isStaleUnauthorizedRequest(e)||await P.refreshAccessToken()}catch{return Promise.reject(r)}return this.httpClient(e)}return Promise.reject(r)});i(this,"canceledResponseInterceptor",r=>{const e=r.rawError??r;if(e.name==="CanceledError"||e.code==="ERR_CANCELED")throw new Wr.CanceledError("Request canceled");return Promise.reject(r)});i(this,"dataConverterResponseInterceptor",r=>(r.data=P.toCamelCaseData(r.data),r));this.httpClient=Wr.create({headers:{Accept:"application/json","Content-Type":"application/json"}}),this.interceptorIds.request[M.DATA_CONVERTER_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(this.dataConverterRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request[M.AUTH_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(this.authRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request[M.DEFAULT_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(r=>P.applyDefaultRequestHook(r),r=>Promise.reject(r)),this.interceptorIds.request[M.BASE_URL_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(this.setBaseUrlRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.response[M.CONVERT_HTTP_ERROR_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(r=>r,r=>P.convertHttpErrorResponse(r)),this.interceptorIds.response[M.CANCELED_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(r=>r,this.canceledResponseInterceptor),this.interceptorIds.response[M.AUTH_ERRORS_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(r=>r,this.authErrorsResponseInterceptors),this.interceptorIds.response[M.DATA_CONVERTER_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(this.dataConverterResponseInterceptor,r=>Promise.reject(r))}static setDefaultErrorsResponseHandler(r){P.defaultErrorsResponseHandler=r}static setDefaultRequestHook(r){P.defaultRequestHook=r}static canConvertCaseKeys(r){return u.isObject(r)?!(r instanceof Blob||r instanceof FormData||r instanceof ArrayBuffer||u.isDate(r)||ArrayBuffer.isView(r)):!1}static toCamelCaseData(r){return P.canConvertCaseKeys(r)?de.objectToCamel(r):r}static toSnakeCaseData(r){return P.canConvertCaseKeys(r)?de.objectToSnake(r):r}static getRequestAccessToken(r){const e=r.headers.get("Authorization"),t=u.isString(e)?e:void 0,s="Bearer ";if(u.isNil(t)||!u.startsWith(t,s))return;const o=t.slice(s.length);return o===""?void 0:o}static async isStaleUnauthorizedRequest(r){const e=P.getRequestAccessToken(r);if(u.isNil(e))return!1;const t=Re().jwtToken;if(u.isNil(t))return!1;try{return await t!==e}catch{return!1}}static refreshAccessToken(){if(!u.isNil(P.tokenRefreshPromise))return P.tokenRefreshPromise;Re().invalidateJwtToken();const e=Re().jwtToken??Promise.resolve();return P.tokenRefreshPromise=e.finally(()=>{P.tokenRefreshPromise=void 0}),P.tokenRefreshPromise}static applyDefaultRequestHook(r){return u.isNil(P.defaultRequestHook)?r:P.defaultRequestHook(r)}static getInstance(r){return Object.prototype.hasOwnProperty.call(P.instances,r.name)||(P.instances[r.name]=I.simpleInstanceInitializer(r)),P.instances[r.name]}static toHttpResponseError(r){if(u.isObject(r)&&"status"in r)return r;const e=u.isError(r)?r.message:"Не удалось обработать данные ответа сервера.";return u.assign(new Error(e),{name:"HttpResponseError",status:0,statusText:"Invalid response data",headers:{},rawError:u.isError(r)?r:new Error(String(r))})}static convertHttpErrorResponse(r){var e,t;if(u.isNil(r)||!u.isNil(r.request)||!u.isNil(r.response)){const s=u.isNil(r)?{}:r==null?void 0:r.response;return Promise.reject(u.assign(new Error(((e=s==null?void 0:s.data)==null?void 0:e.message)??"Unknown Error. Probably network error."),{name:"HttpResponseError",status:(s==null?void 0:s.status)??0,statusText:(s==null?void 0:s.statusText)??"Unknown",errors:(t=s==null?void 0:s.data)==null?void 0:t.errors,headers:(s==null?void 0:s.headers)??{},data:s==null?void 0:s.data,rawError:r}))}return Promise.reject(r)}request(r,e=void 0,t={},s=!1){const o=this.httpClient.request(r).then(p=>e?e(p):p.data);return o.catch(p=>{(p==null?void 0:p.name)!=="CanceledError"&&P.defaultErrorsResponseHandler(P.toHttpResponseError(p),t,s)}),o}get(r,e={},t=void 0,s=!1,o=void 0){return this.request({method:"GET",url:r,params:e,signal:o},t,{},s)}getTypedList(r,e,t={},s=!1,o=void 0){return this.get(e,t,p=>I.instanceListInitializer(r,p.data),s,o)}getBlob(r,e={},t=void 0,s=!1,o=void 0){return this.request({method:"GET",url:r,params:e,responseType:"blob",signal:o},t,{},s)}patch(r,e={},t=void 0,s={},o=!1,p=void 0){return this.request({method:"PATCH",url:r,data:e,signal:p},t,s,o)}post(r,e={},t=void 0,s={},o=!1,p=void 0){return this.request({method:"POST",url:r,data:e,signal:p},t,s,o)}delete(r,e=void 0,t=!1,s=void 0){return this.request({method:"DELETE",url:r,signal:s},e,{},t)}};i(P,"instances",{}),i(P,"defaultErrorsResponseHandler",u.noop),i(P,"defaultRequestHook"),i(P,"tokenRefreshPromise");let y=P;var Ne=(n=>(n.BeginWith="bw",n.Contains="cn",n.Custom="custom",n.EndsWith="ew",n.Equals="eq",n.GreaterOrEqual="ge",n.GreaterThan="gt",n.InList="in",n.LessOrEqual="le",n.LessThan="lt",n.NotBeginWith="bn",n.NotContains="nc",n.NotEndsWith="en",n.NotEqual="ne",n.NotInList="ni",n.NotNull="nn",n.Null="nu",n))(Ne||{});class Ze{constructor(r){i(this,"field");i(this,"op");i(this,"value");this.field=(r==null?void 0:r.field)??"",this.op=(r==null?void 0:r.op)??Ne.Equals,this.value=(r==null?void 0:r.value)??""}toPrimitive(){const r=b().config.dateFormats.api,e={field:this.field,op:this.op};if(u.isDate(this.value))e.value=l.format(this.value,r);else if(u.isPlainObject(this.value)){const t=this.value;e.value={from:t.from?l.format(t.from,r):null,to:t.to?l.format(t.to,r):null}}else e.value=this.value;return e}}class V{constructor(r){i(this,"groupOp");i(this,"filters");i(this,"groups");var e,t;this.groupOp=(r==null?void 0:r.groupOp)??"and",this.filters=((e=r==null?void 0:r.filters)==null?void 0:e.map(s=>new Ze(s)))??[],this.groups=((t=r==null?void 0:r.groups)==null?void 0:t.map(s=>new V(s)))??[]}toPrimitive(){return{groupOp:this.groupOp,filters:this.filters.map(r=>r instanceof Ze&&u.isFunction(r.toPrimitive)?r.toPrimitive():r),groups:this.groups.map(r=>r instanceof V?r.toPrimitive():r)}}}class U extends y{getPaginated(r,e,t,s,o,p,g,m=void 0){let a={page:(s==null?void 0:s.page)??1,perPage:(s==null?void 0:s.pageSize)??10};return e&&(a.filters=JSON.stringify((e instanceof V?e:new V(e)).toPrimitive())),u.isEmpty(t)||(a.sort=u.isArray(t)?t:[t]),o&&(a={...a,...o}),this.get(r,a,p,g,m)}getTypedPaginated(r,e,t,s,o,p,g,m=void 0){return this.getPaginated(e,t,s,o,p,a=>({...a.data,data:I.instanceListInitializer(r,a.data.data)}),g,m)}}class Me extends U{static preparePostSaveData(r){const e={};if(u.isUndefined(r.title)||(e.title=r.title),u.isUndefined(r.slug)||(e.slug=r.slug),u.isUndefined(r.content)||(e.content=r.content),!u.isUndefined(r.publishedAt)){const t=b().config.dateFormats.api;e.publishedAt=u.isNil(r.publishedAt)?null:l.format(r.publishedAt,t)}return e}getPostList(r,e,t){return this.getPaginated("/internal/blog",r,e,t,{},s=>({...s.data,data:s.data.data.map(o=>new Z(o))}))}getPost(r){return this.get(`/internal/blog/${r}`,{},e=>new _e(e.data))}createPost(r,e={}){return this.post("/internal/blog",Me.preparePostSaveData(r),t=>new _e(t.data),e)}updatePost(r,e,t={}){return this.patch(`/internal/blog/${r}`,Me.preparePostSaveData(e),s=>new _e(s.data),t)}removePost(r){return this.delete(`/internal/blog/${r}`)}uploadMedia(r,e,t,s,o={}){return this.request({method:"POST",url:`/internal/blog/${r}/media`,data:{file:e,isCover:t??!1},onUploadProgress:p=>{s&&s(p.total?Math.round(p.loaded/p.total*100):0)}},p=>new Le(p.data),o)}updateMedia(r,e,t,s={}){return this.patch(`/internal/blog/${r}/media/${e}`,{isCover:t},o=>new Le(o.data),s)}removeMedia(r,e){return this.delete(`/internal/blog/${r}/media/${e}`)}}class O extends N{constructor(e){super(e);i(this,"name","");this.name=(e==null?void 0:e.name)??""}nameOrGuid(){return u.isEmpty(this.name)?this.guid:this.name}}class d extends O{constructor(e){super(e);i(this,"type");i(this,"isActive");this.type=e==null?void 0:e.type,this.isActive=(e==null?void 0:e.isActive)??!0}}class Jr extends O{constructor(e){super(e);i(this,"costCoefficient");i(this,"isLowPriceAllowed");i(this,"publishedAt");i(this,"description");i(this,"percent");i(this,"owner");i(this,"deletedAt");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.isLowPriceAllowed=(e==null?void 0:e.isLowPriceAllowed)??!1,this.publishedAt=u.isString(e==null?void 0:e.publishedAt)?l.parseISO(e.publishedAt):e==null?void 0:e.publishedAt,this.description=(e==null?void 0:e.description)??void 0,this.percent=(e==null?void 0:e.percent)??0,this.owner=new d(e==null?void 0:e.owner),this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class Fe extends O{constructor(e){super(e);i(this,"updatedAt");this.updatedAt=u.isString(e==null?void 0:e.updatedAt)?l.parseISO(e.updatedAt):e==null?void 0:e.updatedAt}}class F extends Fe{constructor(e){super(e);i(this,"description");i(this,"createdAt");i(this,"owner");this.description=(e==null?void 0:e.description)??"",this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.owner=e!=null&&e.owner?new d(e.owner):void 0}}var er=(n=>(n.K0="k0",n.K1="k1",n.K2="k2",n.K3="k3",n.K4="k4",n.Retail="retail",n))(er||{});class D extends O{constructor(e){super(e);i(this,"slug");i(this,"description");this.description=e==null?void 0:e.description,this.slug=e==null?void 0:e.slug}}class ee extends D{static getRetailPriceCoefficient(){const r=new ee({id:-2,slug:er.Retail,name:"Розн. цена",guid:""});return r.isNewRec=u.constant(!0),r}}class Ue{constructor(r){i(this,"coefficient");i(this,"value");i(this,"cost");i(this,"percent");i(this,"readOnly");this.coefficient=new ee(r==null?void 0:r.coefficient),this.value=(r==null?void 0:r.value)??0,this.cost=(r==null?void 0:r.cost)??0,this.percent=(r==null?void 0:r.percent)??0,this.readOnly=(r==null?void 0:r.readOnly)??!0}}class rr{constructor(r){i(this,"lat");i(this,"long");this.lat=(r==null?void 0:r.lat)??0,this.long=(r==null?void 0:r.long)??0}}class W extends D{}class ue extends D{constructor(e){var t;super(e);i(this,"address");i(this,"isMain");i(this,"deliveryTypes");i(this,"regions");i(this,"coordinates");this.address=(e==null?void 0:e.address)??"",this.isMain=(e==null?void 0:e.isMain)??!1,this.deliveryTypes=((t=e==null?void 0:e.deliveryTypes)==null?void 0:t.map(s=>new W(s)))??[],this.regions=(e==null?void 0:e.regions)??[],this.coordinates=new rr(e==null?void 0:e.coordinates)}}class Kr{constructor(r){i(this,"warehouse");i(this,"count");this.warehouse=new ue(r==null?void 0:r.warehouse),this.count=(r==null?void 0:r.count)??0}}class q extends O{constructor(e){super(e);i(this,"signature","");i(this,"code");i(this,"symbol","");i(this,"precision");e&&(this.signature=e.signature??"",this.code=e.code,this.symbol=e.symbol??"",this.precision=e.precision)}}class tr extends O{constructor(e){super(e);i(this,"slug","");i(this,"description");i(this,"isSquare",!1);i(this,"isLinear",!1);e&&(this.slug=e.slug??"",this.description=e.description,this.isSquare=e.isSquare??!1,this.isLinear=e.isLinear??!1)}}class pe extends O{constructor(e){super(e);i(this,"code","");this.code=(e==null?void 0:e.code)??""}}class ir extends pe{constructor(e){super(e);i(this,"slug");i(this,"type");this.slug=(e==null?void 0:e.slug)??""}}class Er extends ir{constructor(e){super(e);i(this,"isHidden");this.isHidden=(e==null?void 0:e.isHidden)??!1}}class xr{constructor(r,e){i(this,"image");i(this,"preview");i(this,"isDefault");this.image=`${e??""}${r.image}`,this.preview=`${e??""}${r.preview}`,this.isDefault=r.isDefault}}class qe extends ir{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=(e==null?void 0:e.isPrimary)??!1}}class L extends Er{constructor(e){var s,o,p,g;super(e);i(this,"supplierSku");i(this,"unit");i(this,"pack");i(this,"minCount");i(this,"currency");i(this,"cost");i(this,"costRub");i(this,"costDate");i(this,"onOrder");i(this,"stockCount");i(this,"category");i(this,"categories");i(this,"images");i(this,"properties");i(this,"retailCost");i(this,"retailCostRub");i(this,"priceCoefficients");this.supplierSku=e==null?void 0:e.supplierSku,this.unit=e!=null&&e.unit?new tr(e.unit):new tr,this.pack=e==null?void 0:e.pack,this.minCount=e==null?void 0:e.minCount,this.currency=e!=null&&e.currency?new q(e.currency):new q,this.cost=(e==null?void 0:e.cost)??0,this.costRub=(e==null?void 0:e.costRub)??0,this.costDate=u.isString(e==null?void 0:e.costDate)?l.parseISO(e.costDate):e==null?void 0:e.costDate,this.onOrder=(e==null?void 0:e.onOrder)??!1,this.stockCount=((s=e==null?void 0:e.stockCount)==null?void 0:s.map(m=>new Kr(m)))??[],this.type="product";const t=(e==null?void 0:e.category)??((o=e==null?void 0:e.categories)==null?void 0:o.find(m=>m.isPrimary));t&&(this.category=new qe({...t,isPrimary:!0}),this.categories=[this.category]),e!=null&&e.categories&&(this.categories=e.categories.map(m=>new qe(m))),this.images=((p=e==null?void 0:e.images)==null?void 0:p.map(m=>new xr(m,b().config.http.mediaUrl)))??[],this.properties=(e==null?void 0:e.properties)??{},this.retailCost=e==null?void 0:e.retailCost,this.retailCostRub=e==null?void 0:e.retailCostRub,this.priceCoefficients=((g=e==null?void 0:e.priceCoefficients)==null?void 0:g.map(m=>new Ue(m)))??[],e&&"codeNumber"in e&&!e.code&&(this.code=e==null?void 0:e.codeNumber)}getIsMeasurable(){return this.unit.isLinear||this.unit.isSquare}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}}var He=(n=>(n.Discount="discount",n.PriceTemplate="price_template",n.ClientPrice="client_price",n.Product="product",n))(He||{});class z extends L{constructor(e){super(e);i(this,"costCoefficient");i(this,"costSource");i(this,"discount");i(this,"priceTemplate");i(this,"isPreviouslyOrdered");i(this,"isRequired");i(this,"isFavorite");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.costSource=(e==null?void 0:e.costSource)??He.Product,this.discount=e!=null&&e.discount?new Jr(e.discount):void 0,this.priceTemplate=e!=null&&e.priceTemplate?new F(e.priceTemplate):void 0,this.isPreviouslyOrdered=e==null?void 0:e.isPreviouslyOrdered,this.isRequired=e==null?void 0:e.isRequired,this.isFavorite=e==null?void 0:e.isFavorite}}class he extends qe{constructor(e){super(e);i(this,"isHidden");i(this,"parentCategoryId");i(this,"properties");i(this,"currencyRates");this.isHidden=(e==null?void 0:e.isHidden)??!1,this.parentCategoryId=e==null?void 0:e.parentCategoryId,this.properties=e==null?void 0:e.properties,this.type="category",this.currencyRates=e!=null&&e.currencyRates?Object.fromEntries(Object.entries(e.currencyRates).map(([t,s])=>[u.toUpper(t),s])):void 0}}class sr extends N{constructor(e){super(e);i(this,"category");i(this,"product");i(this,"quantity");i(this,"currency");i(this,"marker");i(this,"height");i(this,"length");i(this,"width");i(this,"configurator");i(this,"configuratorParams");i(this,"isAdditionalSale");i(this,"creator");i(this,"isRemoved");i(this,"ord");i(this,"onOrder");i(this,"originalId");i(this,"replacementId");this.product=new z(e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new he,this.currency=e.currency?new q(e.currency):void 0,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&u.cloneDeep(e.configuratorParams),this.isAdditionalSale=e.isAdditionalSale,this.creator=e.creator&&new d(e.creator),this.isRemoved=e.isRemoved,this.ord=e.ord,this.onOrder=e.onOrder,this.originalId=e.originalId,this.replacementId=e.replacementId}}let nr=class extends sr{constructor(e){super(e);i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,this.currency=new q(e.currency)}};class ge{constructor(r){i(this,"items");i(this,"resultSum");i(this,"directionsSum");this.items=r.items.map(e=>new nr(e)),this.resultSum=r.resultSum,this.directionsSum=r.directionsSum}}class dt extends y{getCart(r){return this.get(`internal/clients/${r.id}/cart`,{},e=>new ge(e.data))}deleteCart(r){return this.delete(`internal/clients/${r.id}/cart`)}addCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ge(s.data),t)}patchCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart/${e.id}`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ge(s.data),t)}deleteCartItem(r,e){return this.delete(`internal/clients/${r.id}/cart/${e.id}`,t=>new ge(t.data))}addCartItemFromCSV(r,e){return this.post(`internal/clients/${r.id}/cart/add-products-from-csv`,e,t=>new ge(t.data))}getCartItemFromCSVExample(r){return this.get(`internal/clients/${r.id}/cart/add-products-from-csv/example`,{},e=>new Blob([e.data],{type:"text/csv"}))}}var Xr=(n=>(n.m2Cost="m2Cost",n.percent="percent",n.value="value",n))(Xr||{}),Zr=(n=>(n.Unknown="unknown",n.Bool="bool",n.Integer="integer",n.Float="float",n.String="string",n.Range="range",n.Json="json",n.Object="object",n))(Zr||{}),or=(n=>(n.Checkbox="checkbox",n.Range="range",n.Toggle="toggle",n))(or||{});class j extends he{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new j(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new L(o))}}class cr{constructor(r){i(this,"phone");i(this,"email");this.phone=/^\d+$/.test(r.phone??"")?`+${r.phone}`:r.phone,this.email=r.email}}class _ extends D{}class Be extends O{constructor(e){super(e);i(this,"salesDirection");i(this,"photo");i(this,"contacts");i(this,"isDefault");i(this,"isRegionalDirector");this.salesDirection=e!=null&&e.salesDirection?new _(e.salesDirection):new _,this.photo=e==null?void 0:e.photo,this.contacts=e!=null&&e.contacts?new cr(e.contacts):void 0,this.isDefault=(e==null?void 0:e.isDefault)??!1,this.isRegionalDirector=(e==null?void 0:e.isRegionalDirector)??!1}}class We extends D{}class lr extends O{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");this.description=e.description,this.canChangeLowCost=e.canChangeLowCost,this.parentRoleId=e.parentRoleId}}class Ae extends O{constructor(e){super(e);i(this,"abbr");this.abbr=(e==null?void 0:e.abbr)??""}}class Y extends Be{constructor(e){var t,s,o;super(e);i(this,"isActive");i(this,"isSupervisor");i(this,"canDoReclamations");i(this,"createdAt");i(this,"supervisorId");i(this,"pricingRole");i(this,"curatedDirections");i(this,"showAllCosts");i(this,"authAsOperator");i(this,"managerRegions");i(this,"managers");i(this,"lastLoginAt");this.isActive=(e==null?void 0:e.isActive)??!1,this.isSupervisor=(e==null?void 0:e.isSupervisor)??!1,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.supervisorId=e==null?void 0:e.supervisorId,this.pricingRole=e!=null&&e.pricingRole?new lr(e.pricingRole):void 0,this.curatedDirections=((t=e==null?void 0:e.curatedDirections)==null?void 0:t.map(p=>new We(p)))??[],this.showAllCosts=e==null?void 0:e.showAllCosts,this.authAsOperator=e==null?void 0:e.authAsOperator,this.managerRegions=(s=e==null?void 0:e.managerRegions)==null?void 0:s.map(p=>new Ae(p)),this.managers=(o=e==null?void 0:e.managers)==null?void 0:o.map(p=>new Y(p)),this.lastLoginAt=u.isString(e==null?void 0:e.lastLoginAt)?l.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt}}class Lt extends he{constructor(e){super(e);i(this,"isDisabled");i(this,"isRequired");i(this,"isFavorite");i(this,"hidingComment");i(this,"manager");this.isDisabled=(e==null?void 0:e.isDisabled)??!1,this.isRequired=(e==null?void 0:e.isRequired)??!1,this.isFavorite=(e==null?void 0:e.isFavorite)??!1,this.hidingComment=e==null?void 0:e.hidingComment,this.manager=e!=null&&e.manager?new Y(e.manager):void 0}}class be extends Lt{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new be(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new z(o))}}class ur{constructor(r){i(this,"priceCoefficient");i(this,"increasePercent");this.priceCoefficient=(r==null?void 0:r.priceCoefficient)&&new ee(r.priceCoefficient),this.increasePercent=r==null?void 0:r.increasePercent}}class ze extends ur{constructor(e){super(e);i(this,"productCategory");this.productCategory=new he(e==null?void 0:e.productCategory)}}class je extends O{constructor(e){super(e);i(this,"photo");i(this,"contacts");i(this,"curatedDirection");this.photo=e.photo,this.contacts=new cr(e.contacts),this.curatedDirection=new We(e.curatedDirection)}}class re extends D{}class te extends D{constructor(e){super(e);i(this,"country",new re);e&&(this.country=new re(e.country))}}class ie extends D{constructor(e){super(e);i(this,"region",new te);e&&(this.region=new te(e.region))}}class pr extends O{constructor(e){super(e);i(this,"phone");i(this,"email");i(this,"getNews");i(this,"salesDirection");i(this,"createdAt");i(this,"lastLoginAt");i(this,"isActive");this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:(e==null?void 0:e.phone)??"",this.email=(e==null?void 0:e.email)??"",this.getNews=(e==null?void 0:e.getNews)??!1,this.salesDirection=e!=null&&e.salesDirection?new _(e.salesDirection):void 0,this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.lastLoginAt=u.isString(e==null?void 0:e.lastLoginAt)?l.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt,this.isActive=(e==null?void 0:e.isActive)??!1}}class J extends pr{constructor(e){var t,s;super(e);i(this,"salesDirection");i(this,"debt");i(this,"alternativeName");i(this,"city");i(this,"comment");i(this,"isPhoneApproved");i(this,"isEmailApproved");i(this,"managers");i(this,"curators");this.salesDirection=new _(e==null?void 0:e.salesDirection),this.debt=(e==null?void 0:e.debt)??0,this.alternativeName=(e==null?void 0:e.alternativeName)??"",this.city=new ie(e==null?void 0:e.city),this.comment=e==null?void 0:e.comment,this.isPhoneApproved=(e==null?void 0:e.isPhoneApproved)??!1,this.isEmailApproved=(e==null?void 0:e.isEmailApproved)??!1,this.managers=((t=e==null?void 0:e.managers)==null?void 0:t.map(o=>new Be(o)))??[],this.curators=((s=e==null?void 0:e.curators)==null?void 0:s.map(o=>new je(o)))??void 0}}class fe extends N{constructor(e){super(e);i(this,"createdAt");i(this,"deletedAt");i(this,"client");i(this,"priceTemplate");this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt,this.client=new J(e==null?void 0:e.client),this.priceTemplate=new F(e==null?void 0:e.priceTemplate)}}class Ye extends ur{constructor(e){super(e);i(this,"product");this.product=new L(e==null?void 0:e.product)}}class hr extends D{}class se extends O{constructor(e){super(e);i(this,"type");i(this,"description");i(this,"metadata");i(this,"isFilterable");this.type=new hr(e==null?void 0:e.type),this.description=(e==null?void 0:e.description)??"",this.metadata=e==null?void 0:e.metadata,this.isFilterable=e==null?void 0:e.isFilterable}}class ne{constructor(r){i(this,"property");i(this,"value");this.property=new se(r==null?void 0:r.property),this.value=(r==null?void 0:r.value)??""}}class _t{constructor(r){i(this,"id");i(this,"name");i(this,"description");i(this,"ownerName");i(this,"createdAt",new T);i(this,"updatedAt",new T);this.id=r==null?void 0:r.id,this.name=r==null?void 0:r.name,this.description=r==null?void 0:r.description,this.ownerName=r==null?void 0:r.ownerName,this.createdAt=new T(r==null?void 0:r.createdAt),this.updatedAt=new T(r==null?void 0:r.updatedAt)}resetFilterValue(r){switch(r){case"id":case"name":case"description":case"ownerName":this[r]=void 0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"updatedAt":this.updatedAt.from=null,this.updatedAt.to=null;break}return this}asClearRaw(){var e,t,s,o;const r={};return Object.keys(this).forEach(p=>{const g=this[p];u.isNil(g)||u.isString(g)&&g.trim().length===0||u.isFunction(g.isNewRec)&&g.isNewRec()||(r[p]=g)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((t=r==null?void 0:r.createdAt)!=null&&t.to)&&delete r.createdAt,!((s=r==null?void 0:r.updatedAt)!=null&&s.from)&&!((o=r==null?void 0:r.updatedAt)!=null&&o.to)&&delete r.updatedAt,r}}class me extends O{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");i(this,"subRoles",[]);i(this,"parentRole");i(this,"level",0);this.description=e==null?void 0:e.description,this.canChangeLowCost=(e==null?void 0:e.canChangeLowCost)??!1,this.parentRoleId=e==null?void 0:e.parentRoleId}}class gr{constructor(r){i(this,"role");i(this,"category");i(this,"minCoefficient");this.role=new me(r==null?void 0:r.role),this.category=new he(r==null?void 0:r.category),this.minCoefficient=new ee(r==null?void 0:r.minCoefficient)}}class Fr{constructor(r){i(this,"isFake");i(this,"isHidden");i(this,"isMultiple");i(this,"type");i(this,"ord");this.isFake=(r==null?void 0:r.isFake)??!1,this.isHidden=(r==null?void 0:r.isHidden)??!1,this.isMultiple=(r==null?void 0:r.isMultiple)??null,this.type=(r==null?void 0:r.type)??null,this.ord=(r==null?void 0:r.ord)??0}}class fr{constructor(r){i(this,"category");i(this,"property");i(this,"settings");this.category=new he(r==null?void 0:r.category),this.property=new se(r==null?void 0:r.property),this.settings=new Fr(r==null?void 0:r.settings)}}class et{constructor(r){i(this,"id");i(this,"label");this.id=(r==null?void 0:r.id)??"",this.label=(r==null?void 0:r.label)??""}}class rt{constructor(r){i(this,"id");i(this,"label");i(this,"type");i(this,"ord");i(this,"isMultiple");i(this,"values");i(this,"min");i(this,"max");var e;this.id=(r==null?void 0:r.id)??"",this.label=(r==null?void 0:r.label)??"",this.type=(r==null?void 0:r.type)??or.Checkbox,this.ord=(r==null?void 0:r.ord)??0,this.isMultiple=(r==null?void 0:r.isMultiple)??null,this.values=((e=r==null?void 0:r.values)==null?void 0:e.map(t=>new et(t)))??[],this.min=(r==null?void 0:r.min)??null,this.max=(r==null?void 0:r.max)??null}}class Nt extends y{search(r,e=!1){return this.get("/internal/catalog/search",{term:r,show_hidden:e})}getPriceExportLink(r="csv",e=!1,t=void 0,s=void 0){let p=`${b().config.http.portalApiUrl}/api/internal/price/export?format=${r}&show_hidden=${e}`;return t&&(p+=`&category_id=${t}`),s&&(p+=`&client_id=${s}`),p}}class Mt extends y{importPrices(r,e){return this.post(`/internal/clients/${r}/price/import`,e)}updateCategoryPrices(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/categories/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value})}removeCategoryPrices(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}`)}markCategoryRequired(r,e){return this.post(`/internal/clients/${r}/price/categories/${e}/required`)}unmarkCategoryRequired(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/required`)}markCategoryDisabled(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/disabled`,{comment:t})}unmarkCategoryDisabled(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/disabled`)}addCategoryManager(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/manager`,{manager_id:t})}removeCategoryManager(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/manager`)}updateProductPrice(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new z(o.data))}removeProductPrice(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}`,t=>new z(t.data))}markProductRequired(r,e){return this.post(`/internal/clients/${r}/price/products/${e}/required`)}unmarkProductRequired(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}/required`)}getCommercialOfferHtml(r,e){return this.get(`/internal/clients/${r}/price/commercial-offer/view`,e,t=>new Blob([t.data],{type:"text/html"}))}getCommercialOfferPdf(r,e){return this.getBlob(`/internal/clients/${r}/price/commercial-offer/download`,e,t=>new Blob([t.request.response],{type:"application/pdf"}))}sendCommercialOffer(r,e){return this.post(`/internal/clients/${r}/price/commercial-offer/send`,e)}}class Ut extends y{getTemplateList(r){return this.getTypedList(fe,`/internal/clients/${r}/price/templates`)}getActiveTemplate(r){return this.get(`/internal/clients/${r}/price/templates/active`,{},e=>new fe(e.data),!0)}attachTemplate(r,e,t){const s=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/price/templates/${e}`,t&&{startAt:t.startAt&&l.format(t.startAt,s),endAt:t.endAt&&l.format(t.endAt,s)},o=>new fe(o.data),{},!0)}applyTemplate(r,e){return this.post(`/internal/clients/${r}/price/templates/${e}/apply`,{},void 0,{},!0)}changeTemplate(r,e,t,s){const o=b().config.dateFormats.api;return this.patch(`/internal/clients/${r}/price/templates/${e}/${t}`,s&&{startAt:s.startAt&&l.format(s.startAt,o),endAt:s.endAt&&l.format(s.endAt,o)},p=>new fe(p.data))}detachTemplate(r,e,t){return this.delete(`/internal/clients/${r}/price/templates/${e}/${t}`)}}class qt extends y{getRootCategoriesList(r=!1){return this.getTypedList(j,"/internal/catalog/categories",{showHidden:r})}getCategoryData(r,e=!1,t=!1){return this.get(`/internal/catalog/categories/${r}`,{showHidden:e,withNestedCategories:t},s=>new j(s.data))}getPublicCategoryData(r){return this.get(`/public/catalog/categories/${r}`,{},e=>new j(e.data))}getCategoryProductsList(r,e=!0,t=!1){return this.get(`/internal/catalog/categories/${r}/products`,{showHidden:t,withPriceCoefficients:e},s=>u.map(s.data,o=>new L(o)))}getCategoryProductsCoefficients(r){return this.get(`/internal/catalog/categories/${r}/products/coefficients`,{},e=>{const{data:t}=e;return u.forEach(t,s=>s.map(o=>new Ue(o))),t})}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.categories.map(p=>new j(p)))}).catch(o=>{s(o)})})}}class Ht extends U{getProductData(r,e=!1){return this.get(`/internal/catalog/products/${r}`,{withPriceCoefficients:e},t=>new L(t.data))}getPublicProductData(r){return this.get(`/public/catalog/products/${r}`,{},e=>new L(e.data))}getProductPriceCoefficients(r){return this.get(`/internal/catalog/products/${r}/coefficients`,{},e=>u.map(e.data,t=>new Ue(t)))}getNewProducts(r,e,t=!0){const s=b().config.dateFormats.api;return this.getTypedPaginated(L,"/internal/catalog/products/new",void 0,void 0,e,{period:{from:l.format(r,s)},withPriceCoefficients:t})}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.products.map(p=>new L(p)))}).catch(o=>{s(o)})})}}class Bt extends y{getRootCategoriesList(r,e=!1){return this.getTypedList(be,"/internal/catalog/categories",{clientId:r,showHidden:e})}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{clientId:r,showHidden:t,withNestedCategories:s},o=>new be(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{client_id:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,p=>new z(p)))}}class Wt extends U{getProductData(r,e,t=!1){return this.get(`/internal/catalog/products/${r}`,{clientId:e,withPriceCoefficients:t},s=>new z(s.data))}getNewProducts(r,e,t,s=!0){const o=b().config.dateFormats.api;return this.getTypedPaginated(z,"/internal/catalog/products/new",void 0,void 0,t,{clientId:r,period:{from:l.format(e,o)},withPriceCoefficients:s})}}class zt extends U{getTemplateList(r,e,t){return this.getTypedPaginated(F,"/internal/price/templates",r,e,t)}createTemplate(r,e={}){return this.post("/internal/price/templates",r,t=>new F(t.data),e)}getTemplate(r){return this.get(`/internal/price/templates/${r}`,{},e=>new F(e.data))}updateTemplate(r,e,t={}){return this.patch(`/internal/price/templates/${r}`,e,s=>new F(s.data),t)}removeTemplate(r){return this.delete(`/internal/price/templates/${r}`)}getProductTemplatePrices(r){return this.getTypedList(Ye,`/internal/price/templates/${r}/products`)}getProductTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/products/${e}`,{},t=>new Ye(t.data))}saveProductTemplatePrice(r,e,t){var s;return this.post(`/internal/price/templates/${r}/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new Ye(o.data))}deleteProductTemplatePrice(r,e){return this.delete(`/internal/price/templates/${r}/products/${e}`)}getCategoryTemplatePrices(r){return this.getTypedList(ze,`/internal/price/templates/${r}/categories`)}getCategoryTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/categories/${e}`,{},t=>new ze(t.data))}saveCategoryTemplatePrice(r,e,t,s=!1){var o;return this.request({method:"POST",url:`/internal/price/templates/${r}/categories/${e}`,data:{price_coefficient_id:(o=t.coefficient)==null?void 0:o.id,increase_percent:t.value},params:s?{recursively:!0}:{}},p=>new ze(p.data))}deleteCategoryTemplatePrice(r,e,t=!1){return this.request({method:"DELETE",url:`/internal/price/templates/${r}/categories/${e}`,params:t?{recursively:!0}:{}})}getTemplateClients(r){return this.getTypedList(fe,`/internal/price/templates/${r}/clients`)}}class jt extends y{getRoles(){return this.getTypedList(me,"/internal/price/roles")}createRole(r){return this.post("/internal/price/roles",r,e=>new me(e.data))}getRole(r){return this.get(`/internal/price/roles/${r}`,{},e=>new me(e.data))}updateRole(r,e){return this.patch(`/internal/price/roles/${r}`,e,t=>new me(t.data))}deleteRole(r){return this.delete(`/internal/price/roles/${r}`)}getCategoryRules(r){return this.getTypedList(gr,`/internal/price/roles/rules/categories/${r}`)}updateCategoryRules(r,e){return this.patch(`/internal/price/roles/rules/categories/${r}`,e,t=>I.instanceListInitializer(gr,t.data))}}class Yt extends U{getProperties(r,e,t){return this.getTypedPaginated(se,"/internal/catalog/properties",r,e,t)}createProperty(r){const{typeId:e,...t}=r;return this.post("/internal/catalog/properties",{...t,type:e},s=>new se(s.data))}getProperty(r){return this.get(`/internal/catalog/properties/${r}`,{},e=>new se(e.data))}updateProperty(r,e){const{typeId:t,...s}=e;return this.patch(`/internal/catalog/properties/${r}`,{...s,type:t},o=>new se(o.data))}deleteProperty(r){return this.delete(`/internal/catalog/properties/${r}`)}getProductProperties(r){return this.getTypedList(ne,`/internal/catalog/products/${r}/properties`)}getProductProperty(r,e){return this.get(`/internal/catalog/products/${r}/properties/${e}`,{},t=>new ne(t.data))}updateProductProperty(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/${e}`,{value:t},s=>new ne(s.data))}deleteProductProperty(r,e){return this.delete(`/internal/catalog/products/${r}/properties/${e}`)}getProductDescription(r){return this.get(`/internal/catalog/products/${r}/properties/description`)}updateProductDescription(r,e){return this.patch(`/internal/catalog/products/${r}/properties/description`,{text:e})}deleteProductDescription(r){return this.delete(`/internal/catalog/products/${r}/properties/description`)}getProductSpecification(r){return this.get(`/internal/catalog/products/${r}/properties/specification`)}updateProductSpecification(r,e){return this.patch(`/internal/catalog/products/${r}/properties/specification`,{text:e})}deleteProductSpecification(r){return this.delete(`/internal/catalog/products/${r}/properties/specification`)}getProductFiles(r){return this.get(`/internal/catalog/products/${r}/properties/files`)}addProductFile(r,e){return this.post(`/internal/catalog/products/${r}/properties/files`,e)}updateProductFile(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/files/${e}`,t)}deleteProductFile(r,e){return this.delete(`/internal/catalog/products/${r}/properties/files/${e}`)}updateProductSlug(r,e){return this.patch(`/internal/catalog/products/${r}/properties/slug`,{slug:e})}getCategoryProperties(r){return this.getTypedList(ne,`/internal/catalog/categories/${r}/properties`)}getCategoryProperty(r,e){return this.get(`/internal/catalog/categories/${r}/properties/${e}`,{},t=>new ne(t.data))}updateCategoryProperty(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/${e}`,{value:t},s=>new ne(s.data))}deleteCategoryProperty(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/${e}`)}getCategoryDescription(r){return this.get(`/internal/catalog/categories/${r}/properties/description`)}updateCategoryDescription(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/description`,{text:e})}deleteCategoryDescription(r){return this.delete(`/internal/catalog/categories/${r}/properties/description`)}getCategorySpecification(r){return this.get(`/internal/catalog/categories/${r}/properties/specification`)}updateCategorySpecification(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/specification`,{text:e})}deleteCategorySpecification(r){return this.delete(`/internal/catalog/categories/${r}/properties/specification`)}getCategoryFiles(r){return this.get(`/internal/catalog/categories/${r}/properties/files`)}addCategoryFile(r,e){return this.post(`/internal/catalog/categories/${r}/properties/files`,e)}updateCategoryFile(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/files/${e}`,t)}deleteCategoryFile(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/files/${e}`)}updateCategorySlug(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/slug`,{slug:e})}updateCategoryImage(r,e){return this.post(`/internal/catalog/categories/${r}/image`,{image:e})}getCategoryFilters(r,e=!1){return this.get(`/internal/catalog/categories/${r}/filters`,{recursively:e},t=>t.data.map(s=>new rt(s)))}getCategoryFilterSettings(r){return this.getTypedList(fr,`/internal/catalog/categories/${r}/filter-settings`)}saveCategoryFilterSetting(r,e,t){return this.patch(`/internal/catalog/categories/${r}/filter-settings/${e}`,t,s=>new fr(s.data))}deleteCategoryFilterSetting(r,e){return this.delete(`/internal/catalog/categories/${r}/filter-settings/${e}`)}}class Gt extends y{getRootCategoriesList(r,e=!1){return this.getTypedList(j,"/internal/catalog/categories",{priceTemplateId:r,showHidden:e})}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{priceTemplateId:r,showHidden:t,withNestedCategories:s},o=>new j(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{priceTemplateId:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,p=>new L(p)))}}function mr(n,r,e){let t;return n.some(s=>{if(s.type===e&&s.id===r)return t=s,!0;if(s.type==="product")return!1;const o=s;if(o.products&&o.products.length>0){const p=mr(o.products,r,e);if(p)return t=p,!0}if(o.categories&&o.categories.length>0){const p=mr(o.categories,r,e);if(p)return t=p,!0}return!1}),t}function yr(n){const r=[];return n.forEach(e=>{if(r.push(e),e.type==="category"){const t=e;t.products&&t.products.length>0&&r.push(...yr(t.products)),t.categories&&t.categories.length>0&&r.push(...yr(t.categories))}}),r}var tt=(n=>(n.LastOrder="last_order",n.Contacts="contacts",n.PartnerGroups="partner_groups",n.PreferredDeliveryType="preferred_delivery_type",n.SalesDirection="sales_direction",n.Managers="managers",n.Curators="curators",n))(tt||{}),G=(n=>(n.Person="individual",n.Ic="entrepreneur",n.UlR="legal",n.UlNr="non_resident_legal",n))(G||{});class Ge extends N{constructor(e){super(e);i(this,"bankName","");i(this,"bic","");i(this,"accountNumber","");i(this,"correspondentAccount","");i(this,"currency",new q);e&&(this.bankName=e.bankName??"",this.bic=e.bic??"",this.accountNumber=e.accountNumber??"",this.correspondentAccount=e.correspondentAccount??"",this.currency=new q(e.currency))}}class Qe extends O{constructor(e){super(e);i(this,"phone");i(this,"email");this.email=e==null?void 0:e.email,this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:e==null?void 0:e.phone}}class K extends Qe{constructor(e){super(e);i(this,"isPrimary");i(this,"position");i(this,"notDisturb");i(this,"comment");i(this,"updatedAt");i(this,"deletedAt");this.isPrimary=(e==null?void 0:e.isPrimary)??!1,this.position=e==null?void 0:e.position,this.notDisturb=(e==null?void 0:e.notDisturb)??!1,this.comment=e==null?void 0:e.comment,this.updatedAt=e==null?void 0:e.updatedAt,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class E extends D{static generatePersonItem(){return new E({id:1,guid:"",slug:G.Person,name:""})}}class oe extends D{}class ar extends Fe{constructor(e){super(e);i(this,"deletedAt");this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class Cr extends ar{constructor(e){super(e);i(this,"opf",E.generatePersonItem());i(this,"partnerGroup",new oe);i(this,"contacts",[]);i(this,"bankAccounts",[]);i(this,"comment");i(this,"alternativeName");i(this,"createdAt");i(this,"creator");i(this,"updater");if(e){if(this.opf=new E(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):e.createdAt,this.creator=e.creator?new d(e.creator):void 0,this.updater=e.updater?new d(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new oe(e.partnerGroup)),e.contacts){const t=[];e.contacts.forEach(s=>{t.push(new K(s))}),this.contacts=t}if(e.bankAccounts){const t=[];e.bankAccounts.forEach(s=>{t.push(new Ge(s))}),this.bankAccounts=t}}}}class it extends Cr{constructor(r){super(r)}}class wr extends Cr{constructor(e){super(e);i(this,"inn","");i(this,"okpo","");i(this,"ogrn","");i(this,"directorName","");i(this,"directorPosition","");i(this,"directorActsOn","");i(this,"legalAddress","");i(this,"postalAddress","");i(this,"actualAddress","");e&&(this.inn=e.inn??"",this.okpo=e.okpo??"",this.ogrn=e.ogrn??"",this.directorName=e.directorName??"",this.directorPosition=e.directorPosition??"",this.directorActsOn=e.directorActsOn??"",this.legalAddress=e.legalAddress??"",this.postalAddress=e.postalAddress??"",this.actualAddress=e.actualAddress??"")}}class Pr extends wr{constructor(e){super(e);i(this,"kpp","");e&&(this.kpp=e.kpp??"")}}class st extends Pr{constructor(e){super(e);i(this,"registrationCountry",new re);i(this,"registrationNumber","");i(this,"taxNumber","");e&&(this.registrationCountry=new re(e.registrationCountry),this.registrationNumber=e.registrationNumber??"",this.taxNumber=e.taxNumber??"")}}class Oe{static createInstance(r){switch(r.opf.slug){case G.Ic:return new wr(r);case G.UlR:return new Pr(r);case G.UlNr:return new st(r);default:return new it(r)}}}class ye extends ar{constructor(e){var t;super(e);i(this,"address","");i(this,"coordinates");i(this,"contacts");i(this,"comment");i(this,"operatingHours");i(this,"isOneTime");i(this,"isTransportCompanyAddress");this.address=(e==null?void 0:e.address)??"",this.coordinates=new rr(e==null?void 0:e.coordinates),this.contacts=((t=e==null?void 0:e.contacts)==null?void 0:t.map(s=>new K(s)))??[],this.comment=e==null?void 0:e.comment,this.operatingHours=e==null?void 0:e.operatingHours,this.isOneTime=e==null?void 0:e.isOneTime,this.isTransportCompanyAddress=e==null?void 0:e.isTransportCompanyAddress}}class vr extends D{}class Dr extends D{}class Rr extends J{constructor(e){var t,s,o,p;super(e);i(this,"contragents");i(this,"partnerGroups");i(this,"contacts");i(this,"deliveryAddresses");i(this,"channelPrimaryInterest");i(this,"sourcePrimaryInterest");i(this,"preferredDeliveryType");i(this,"primaryDemand");i(this,"preferredWarehouse");i(this,"extraData");this.contragents=((t=e==null?void 0:e.contragents)==null?void 0:t.map(g=>Oe.createInstance(g)))??[],this.partnerGroups=((s=e==null?void 0:e.partnerGroups)==null?void 0:s.map(g=>new oe(g)))??[],this.contacts=((o=e==null?void 0:e.contacts)==null?void 0:o.map(g=>new K(g)))??[],this.deliveryAddresses=((p=e==null?void 0:e.deliveryAddresses)==null?void 0:p.map(g=>new ye(g)))??[],this.channelPrimaryInterest=new vr(e==null?void 0:e.channelPrimaryInterest),this.sourcePrimaryInterest=new Dr(e==null?void 0:e.sourcePrimaryInterest),this.preferredDeliveryType=new W(e==null?void 0:e.preferredDeliveryType),this.primaryDemand=e==null?void 0:e.primaryDemand,this.preferredWarehouse=e!=null&&e.preferredWarehouse?new ue(e.preferredWarehouse):void 0,this.extraData=(e==null?void 0:e.extraData)??{}}}class Qt extends le{constructor(e){var t,s,o,p,g,m,a,v;super();i(this,"id");i(this,"guid");i(this,"name");i(this,"alternativeName");i(this,"searchTerm");i(this,"cities");i(this,"region");i(this,"country");i(this,"phone");i(this,"email");i(this,"isActive");i(this,"createdAt",new T);i(this,"lastLoginDate",new T);i(this,"lastLoginDateHasOrder");i(this,"managers");i(this,"includeSubordinateManagers");i(this,"curators");i(this,"isManagerRequired");i(this,"salesDirections");i(this,"contragentInn");i(this,"contragentType");i(this,"preferredDeliveryType");i(this,"partnerGroups");i(this,"contact");i(this,"lastOrder");i(this,"noOrdersPeriod",new T);this.id=e==null?void 0:e.id,this.guid=e==null?void 0:e.guid,this.name=e==null?void 0:e.name,this.alternativeName=e==null?void 0:e.alternativeName,this.searchTerm=e==null?void 0:e.searchTerm,this.cities=(t=e==null?void 0:e.cities)==null?void 0:t.map(R=>new ie(R)),this.region=new te(e==null?void 0:e.region),this.country=new re(e==null?void 0:e.country),this.phone=e==null?void 0:e.phone,this.email=e==null?void 0:e.email,this.isActive=e&&Object.prototype.hasOwnProperty.call(e,"isActive")?e==null?void 0:e.isActive:!0,this.createdAt=new T(e==null?void 0:e.createdAt),this.lastLoginDate=new T(e==null?void 0:e.lastLoginDate),this.lastLoginDateHasOrder=(e==null?void 0:e.lastLoginDateHasOrder)??void 0,this.managers=((s=e==null?void 0:e.managers)==null?void 0:s.map(R=>new Y(R)))??[],this.includeSubordinateManagers=(e==null?void 0:e.includeSubordinateManagers)??!0,this.curators=((o=e==null?void 0:e.curators)==null?void 0:o.map(R=>new je(R)))??[],this.salesDirections=(p=e==null?void 0:e.salesDirections)==null?void 0:p.map(R=>new _(R)),this.contragentInn=e==null?void 0:e.contragentInn,this.contragentType=new E(e==null?void 0:e.contragentType),this.preferredDeliveryType=e!=null&&e.preferredDeliveryType?new W(e==null?void 0:e.preferredDeliveryType):void 0,this.partnerGroups=(g=e==null?void 0:e.partnerGroups)==null?void 0:g.map(R=>new oe(R)),this.contact=new Qe(e==null?void 0:e.contact),this.lastOrder={createdAt:new T((m=e==null?void 0:e.lastOrder)==null?void 0:m.createdAt),creator:(a=e==null?void 0:e.lastOrder)==null?void 0:a.creator,isApproved:(v=e==null?void 0:e.lastOrder)==null?void 0:v.isApproved},this.noOrdersPeriod=new T(e==null?void 0:e.noOrdersPeriod)}resetFilterValue(e){switch(e){case"cities":this.cities=[];break;case"region":this.region=new te;break;case"isActive":this.isActive=!0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"lastLoginDate":this.lastLoginDate.from=null,this.lastLoginDate.to=null;break;case"noOrdersPeriod":this.noOrdersPeriod.from=null,this.noOrdersPeriod.to=null;break;case"lastOrder":this.lastOrder={};break;case"managers":this.managers=[];break;case"curators":this.curators=[];break;case"salesDirections":this.salesDirections=[];break;case"contragentType":this.contragentType=new E;break;case"preferredDeliveryType":this.preferredDeliveryType=new W;break;case"partnerGroups":this.partnerGroups=[];break;case"contact":this.contact=new Qe;break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,p,g,m;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.lastLoginDate)!=null&&o.from)&&!((p=e==null?void 0:e.lastLoginDate)!=null&&p.to)&&delete e.lastLoginDate,!((g=e==null?void 0:e.noOrdersPeriod)!=null&&g.from)&&!((m=e==null?void 0:e.noOrdersPeriod)!=null&&m.to)&&delete e.noOrdersPeriod,e}}class Tr extends N{constructor(e){super(e);i(this,"createdAt");i(this,"creator");this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.creator=new d(e==null?void 0:e.creator)}}class nt extends O{constructor(e){var t,s,o,p;super(e);i(this,"contacts",[]);i(this,"preferredDeliveryType");i(this,"partnerGroups",[]);i(this,"lastOrder");i(this,"salesDirection");i(this,"managers");i(this,"curators");this.contacts=((t=e.contacts)==null?void 0:t.map(g=>new K(g)))??void 0,this.lastOrder=e.lastOrder?new Tr(e.lastOrder):void 0,this.partnerGroups=((s=e.partnerGroups)==null?void 0:s.map(g=>new oe(g)))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new W(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new _(e.salesDirection):void 0,this.managers=((o=e.managers)==null?void 0:o.map(g=>new Be(g)))??void 0,this.curators=((p=e.curators)==null?void 0:p.map(g=>new je(g)))??void 0}}class Ve extends N{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=e.isPrimary}}class ot extends K{constructor(e){super(e);i(this,"relations",{clients:[],contragents:[],addresses:[]});e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(t=>new Ve(t))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(t=>new Ve(t))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(t=>new Ve(t))))}}class H extends U{static transformClientDataToRequest(r){var t;return{name:r.name,alternative_name:r.alternativeName,partner_groups:r.partnerGroups.map(s=>s.id),phone:r.phone,email:r.email,city_id:r.city.id,get_news:r.getNews,channel_primary_interest_id:r.channelPrimaryInterest.id,source_primary_interest_id:r.sourcePrimaryInterest.id,primary_demand:r.primaryDemand,preferred_warehouse_id:(t=r.preferredWarehouse)==null?void 0:t.id}}static transformContragentClientDataToRequest(r){var p,g,m,a;let e;const t=r,s=r,o=r;switch(r.opf.slug){case G.Ic:e={opf:t.opf.slug,name:t.name,alternative_name:t.alternativeName,partner_group_id:(p=t.partnerGroup)==null?void 0:p.id,comment:t.comment,inn:t.inn,okpo:t.okpo,ogrn:t.ogrn||void 0,director_name:t.directorName,director_position:t.directorPosition,director_acts_on:t.directorActsOn,legal_address:t.legalAddress,postal_address:t.postalAddress,actual_address:t.actualAddress};break;case G.UlR:e={opf:s.opf.slug,name:s.name,alternative_name:s.alternativeName,partner_group_id:(g=s.partnerGroup)==null?void 0:g.id,comment:s.comment,inn:s.inn,kpp:s.kpp,okpo:s.okpo,ogrn:s.ogrn||void 0,director_name:s.directorName,director_position:s.directorPosition,director_acts_on:s.directorActsOn,legal_address:s.legalAddress,postal_address:s.postalAddress,actual_address:s.actualAddress};break;case G.UlNr:e={opf:o.opf.slug,name:o.name,alternative_name:o.alternativeName,partner_group_id:(m=o.partnerGroup)==null?void 0:m.id,comment:o.comment,director_name:o.directorName,director_position:o.directorPosition,director_acts_on:o.directorActsOn,legal_address:o.legalAddress,postal_address:o.postalAddress,actual_address:o.actualAddress,registration_country_id:o.registrationCountry.id,registration_number:o.registrationNumber,tax_number:o.taxNumber||void 0};break;default:e={opf:r.opf.slug,name:r.name,alternative_name:r.alternativeName,partner_group_id:(a=r.partnerGroup)==null?void 0:a.id,comment:r.comment};break}return e}static transformClientDeliveryAddressToRequest(r){var t,s;const e={address:r.address,is_one_time:r.isOneTime??!1,is_transport_company_address:r.isTransportCompanyAddress??!1,comment:r.comment??""};return r.coordinates&&(e.coordinates={lat:(t=r.coordinates)==null?void 0:t.lat,long:(s=r.coordinates)==null?void 0:s.long}),r.operatingHours&&(e.operating_hours={from:r.operatingHours.from,to:r.operatingHours.to}),e}static transformClientContragentBankAccountToRequest(r){return{bank_name:r.bankName,bic:r.bic,account_number:r.accountNumber,correspondent_account:r.correspondentAccount,currency_id:r.currency.id}}getClient(r){return this.get(`/internal/clients/${r}`,{},e=>new Rr(e.data))}getClientsList(r,e,t,s,o=void 0){return this.getTypedPaginated(J,"/internal/clients",r,e,t,s,void 0,o)}searchClient(r){return this.getClientsList(void 0,void 0,void 0,{searchTerm:r}).then(e=>e.data)}getClientByPhone(r){return this.getClientsList({groupOp:"and",groups:[],filters:[{field:"phone",op:Ne.Contains,value:r}]})}getAdditionalClientsData(r,e){const t=r.map(s=>s.id);return this.post("/internal/clients/additional-data",{clients:t,requested_data_types:e},s=>I.instanceListInitializer(nt,s.data))}getAllClientContacts(r){return this.getTypedList(ot,`/internal/clients/${r}/contacts/all`)}createClientCommonData(r,e={}){return this.post("/internal/clients",H.transformClientDataToRequest(r),t=>new Rr(t.data),e)}updateClientCommonData(r,e={}){return this.patch(`/internal/clients/${r.id}`,H.transformClientDataToRequest(r),void 0,e)}updateClientNotDistribCommonData(r,e={}){const t={get_news:r.getNews};return this.patch(`/internal/clients/${r.id}`,t,void 0,e)}changeClientPassword(r,e,t,s={}){return this.patch(`/internal/clients/${r}`,{password:e,password_confirmation:t},void 0,s)}updateClientComment(r){return this.patch(`/internal/clients/${r.id}`,{comment:r.comment})}changeClientActivation(r){return this.patch(`/internal/clients/${r.id}`,{is_active:r.isActive})}async attachClientToManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/attach`,{is_primary:s.isDefault}));await Promise.all(t)}async detachClientFromManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/detach`));await Promise.all(t)}attachToCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/attach`,{curated_direction_id:t.id})}detachFromCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/detach`,{curated_direction_id:t.id})}setCurators(r,e){return this.patch(`/internal/clients/${r}/curators`,{curators:e.map(t=>({curator_id:t.curatorId,curated_direction_id:t.curatedDirection.id}))})}createContragentClientData(r,e,t={}){return this.post(`/internal/clients/${r}/contragents`,H.transformContragentClientDataToRequest(e),s=>Oe.createInstance(s.data),t)}updateContragentClientData(r,e,t={}){return this.patch(`/internal/clients/${r}/contragents/${e.id}`,H.transformContragentClientDataToRequest(e),s=>Oe.createInstance(s.data),t)}deleteClientContragent(r,e){return this.delete(`/internal/clients/${r}/contragents/${e.id}`)}getClientDeliveryAddresses(r){return this.getTypedList(ye,`/internal/clients/${r}/delivery-addresses`)}createClientDeliveryAddress(r,e,t={}){return this.post(`/internal/clients/${r}/delivery-addresses`,H.transformClientDeliveryAddressToRequest(e),s=>new ye(s.data),t)}updateClientDeliveryAddress(r,e,t={}){return this.patch(`/internal/clients/${r}/delivery-addresses/${e.id}`,H.transformClientDeliveryAddressToRequest(e),s=>new ye(s.data),t)}deleteClientDeliveryAddress(r,e){return this.delete(`/internal/clients/${r}/delivery-addresses/${e.id}`)}createContragentBankAccount(r,e,t,s={}){return this.post(`/internal/clients/${r}/contragents/${e}/bank-accounts`,H.transformClientContragentBankAccountToRequest(t),o=>new Ge(o.data),s)}updateContragentBankAccount(r,e,t,s={}){return this.patch(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`,H.transformClientContragentBankAccountToRequest(t),o=>new Ge(o.data),s)}deleteContragentBankAccount(r,e,t){return this.delete(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`)}createClientContact(r,e,t={}){return this.createContact(r,e,{client:{id:r,is_primary:e.isPrimary??!1,not_disturb:e.notDisturb??!1}},t)}updateClientContact(r,e,t={}){return this.patch(`/internal/clients/${r}/contacts/${e.id}`,{name:e.name,position:e.position,phone:e.phone,email:e.email,comment:e.comment,not_disturb:e.notDisturb},s=>new K(s.data),t)}setPrimaryClientContact(r,e){return this.setPrimaryContact(`/internal/clients/${r}/contacts/${e.id}/primary`,e.isPrimary??!1)}detachClientContact(r,e){return this.detachContact(`/internal/clients/${r}/contacts/${e.id}/detach`)}createContragentContact(r,e,t,s={}){return this.createContact(r,t,{contragents:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryContragentContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachContragentContact(r,e,t){return this.detachContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/detach`)}createDeliveryAddressContact(r,e,t,s={}){return this.createContact(r,t,{addresses:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryDeliveryAddressContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachDeliveryAddressContact(r,e,t){return this.detachContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/detach`)}createContact(r,e,t,s={}){var p,g;const o={name:e.name,position:e.position,comment:e.comment,...t};return(p=e.phone)!=null&&p.length&&(o.phone=e.phone),(g=e.email)!=null&&g.length&&(o.email=e.email),this.post(`/internal/clients/${r}/contacts`,o,m=>new K(m.data),s)}setPrimaryContact(r,e){return this.patch(r,{is_primary:e})}detachContact(r){return this.patch(r)}sendClientEmailConfirmation(r){return this.get(`/internal/clients/${r.id}/verification/email?email=${r.email}`)}}class Vt extends y{checkPhoneIsBusy(r){return new Promise((e,t)=>{this.request({method:"GET",url:"/public/user/verification/phone/check",params:{phone:r}}).then(s=>{e(!!s.isBusy)}).catch(t)})}}class Jt{constructor(r){i(this,"date");i(this,"name");i(this,"version");this.date=u.isString(r==null?void 0:r.date)?l.parseISO(r.date):(r==null?void 0:r.date)??new Date,this.name=(r==null?void 0:r.name)??"",this.version=(r==null?void 0:r.version)??"0.0.0"}}var ct=(n=>(n.Kozyrek="kozyrek",n.Mosquitto="mosquitto",n.Strip="strip",n.MetalForDoors="metal_for_doors",n.Sandwich="sandwich",n.SandwichM2="sandwich_m2",n))(ct||{});class Kt extends y{getConfiguratorSettings(r,e){var t;return this.get(`internal/catalog/categories/${r.id}/configurators/${(t=r.properties)==null?void 0:t.configurator}/settings?client_id=${e}`)}searchProduct(r,e,t,s={}){var o;return this.request({method:"GET",url:`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/product`,params:{params:t,client_id:e}},p=>new L(p.data),s)}createTemplate(r,e,t,s={}){var o;return this.post(`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/template?client_id=${e}`,{...t},()=>{},s)}removeTemplate(r,e,t){var s;return this.delete(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/template/${t}?client_id=${e}`)}calculate(r,e,t){var s;return this.get(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/calculate`,{client_id:e,...t})}}class lt{constructor(r){i(this,"page",1);i(this,"pageSize",50);this.page=(r==null?void 0:r.page)??1,this.pageSize=(r==null?void 0:r.pageSize)??50}}class Et extends lt{constructor(e){super(e);i(this,"itemCount",0);i(this,"pageCount",1);i(this,"pageSlot",5);i(this,"pageSizes",[25,50,100]);i(this,"showSizePicker",!0);this.itemCount=(e==null?void 0:e.itemCount)??0,this.pageCount=(e==null?void 0:e.pageCount)??1,this.pageSlot=(e==null?void 0:e.pageSlot)??5,this.pageSizes=(e==null?void 0:e.pageSizes)??[25,50,100],this.showSizePicker=(e==null?void 0:e.showSizePicker)??!0}}class xt{constructor(r){i(this,"field");i(this,"direction");this.field=(r==null?void 0:r.field)??"",this.direction=(r==null?void 0:r.direction)??"asc"}}class w{static decadeInterval(r){const[e,t]=w.shiftedDecadeBounds(r,0);return{from:e,to:t}}static shiftDecadeInterval(r,e){const[t,s]=w.shiftedDecadeBounds(r,e);return{from:t,to:s}}static startOfHalfYear(r){return new Date(r.getFullYear(),r.getMonth()<6?0:6,1)}static endOfHalfYear(r){return l.endOfMonth(new Date(r.getFullYear(),r.getMonth()<6?5:11,1))}static addHalfYears(r,e){return l.addMonths(r,e*6)}static intervalTillSameDate(r,e,t){const s=l.differenceInCalendarMonths(l.startOfMonth(t),l.startOfMonth(r)),o=l.startOfMonth(l.addMonths(e,s)),p=Math.min(l.getDate(t),l.getDaysInMonth(o));return{from:l.startOfDay(e),to:l.endOfDay(l.setDate(o,p))}}static weekTillSameWeekday(r,e){const t=l.startOfWeek(l.addWeeks(r,e),{weekStartsOn:1}),s=l.differenceInCalendarDays(r,l.startOfWeek(r,{weekStartsOn:1}));return{from:t,to:l.endOfDay(l.addDays(t,s))}}static decadeTillSameDayNumber(r,e){const[t]=w.shiftedDecadeBounds(r,0),s=l.differenceInCalendarDays(r,t)+1,[o,p]=w.shiftedDecadeBounds(r,e),g=l.differenceInCalendarDays(p,o)+1;return{from:o,to:l.endOfDay(l.addDays(o,Math.min(s,g)-1))}}static shiftedDecadeBounds(r,e){const t=l.getDate(r);let s=2;t<=10?s=0:t<=20&&(s=1);const o=s+e,p=Math.floor(o/3),g=(o%3+3)%3,m=l.startOfMonth(l.addMonths(r,p)),a=l.addDays(m,g*10),v=g===2?l.endOfMonth(m):l.endOfDay(l.addDays(a,9));return[a,v]}}class Je{static parse(r){if(u.isNil(r))return;const e=u.isString(r)?l.parseISO(r):r;return l.isValid(e)?e:void 0}}function Xt(n){return l.format(l.subDays(l.startOfToday(),n),"yyyy-MM-dd")}function ut(n,r){const e=[2,0,1,1,1,2],t=Math.floor(Math.abs(n));return r[t%100>4&&t%100<20?2:e[Math.min(t%10,5)]]}function Zt(n){const r=l.parseISO(n),e=l.differenceInCalendarDays(l.startOfToday(),r);switch(!0){case e===0:return"Сегодня";case e===1:return"Вчера";case e<0:return n;default:return`${e} ${ut(e,["день","дня","дней"])} назад`}}class Ft{static defaultDateRanges(r){const e=l.addBusinessDays(new Date,1),t=new Date,s=l.startOfYear(r===void 0?t:new Date(r,0,1)),o=l.endOfYear(s);return{nextWorkingDay:{label:"Следующий рабочий день",from:l.startOfDay(e),to:l.endOfDay(e)},today:{label:"Сегодня",from:l.startOfToday(),to:l.endOfToday()},yesterday:{label:"Вчера",from:l.startOfYesterday(),to:l.endOfYesterday()},tomorrow:{label:"Завтра",from:l.startOfTomorrow(),to:l.endOfTomorrow()},currentWeek:{label:"Неделя",from:l.startOfWeek(t,{weekStartsOn:1}),to:l.endOfWeek(t,{weekStartsOn:1})},currentMonth:{label:"Месяц",from:l.startOfMonth(t),to:l.endOfMonth(t)},oneMonth:{label:"1 месяц",from:s,to:l.endOfMonth(s)},threeMonths:{label:"3 месяца",from:s,to:l.endOfMonth(l.addMonths(s,2))},nineMonths:{label:"9 месяцев",from:s,to:l.endOfMonth(l.addMonths(s,8))},firstQuarter:{label:"I квартал",from:s,to:l.endOfMonth(l.addMonths(s,2))},secondQuarter:{label:"II квартал",from:l.addMonths(s,3),to:l.endOfMonth(l.addMonths(s,5))},thirdQuarter:{label:"III квартал",from:l.addMonths(s,6),to:l.endOfMonth(l.addMonths(s,8))},fourthQuarter:{label:"IV квартал",from:l.addMonths(s,9),to:l.endOfMonth(l.addMonths(s,11))},firstHalfYear:{label:"I полугодие",from:s,to:l.endOfMonth(l.addMonths(s,5))},secondHalfYear:{label:"II полугодие",from:l.addMonths(s,6),to:o},currentYear:{label:"12 месяцев",from:s,to:o}}}static standardPeriods(r=new Date){const e={weekStartsOn:1},t=l.startOfDay(r),s=l.endOfDay(r),o=w.decadeInterval(r),p=l.startOfMonth(r),g=l.startOfQuarter(r),m=w.startOfHalfYear(r),a=l.startOfYear(r),v=w.addHalfYears(r,-1),R=w.addHalfYears(r,1);return{yesterday:{label:"Вчера",group:"day",from:l.startOfDay(l.subDays(r,1)),to:l.endOfDay(l.subDays(r,1))},today:{label:"Сегодня",group:"day",from:t,to:s},tomorrow:{label:"Завтра",group:"day",from:l.startOfDay(l.addDays(r,1)),to:l.endOfDay(l.addDays(r,1))},lastWeek:{label:"Прошлая неделя",group:"week",from:l.startOfWeek(l.subWeeks(r,1),e),to:l.endOfWeek(l.subWeeks(r,1),e)},thisWeek:{label:"Эта неделя",group:"week",from:l.startOfWeek(r,e),to:l.endOfWeek(r,e)},nextWeek:{label:"Следующая неделя",group:"week",from:l.startOfWeek(l.addWeeks(r,1),e),to:l.endOfWeek(l.addWeeks(r,1),e)},lastTenDays:{label:"Прошлая декада",group:"decade",...w.shiftDecadeInterval(r,-1)},thisTenDays:{label:"Эта декада",group:"decade",...o},nextTenDays:{label:"Следующая декада",group:"decade",...w.shiftDecadeInterval(r,1)},lastMonth:{label:"Прошлый месяц",group:"month",from:l.startOfMonth(l.subMonths(r,1)),to:l.endOfMonth(l.subMonths(r,1))},thisMonth:{label:"Этот месяц",group:"month",from:p,to:l.endOfMonth(r)},nextMonth:{label:"Следующий месяц",group:"month",from:l.startOfMonth(l.addMonths(r,1)),to:l.endOfMonth(l.addMonths(r,1))},lastQuarter:{label:"Прошлый квартал",group:"quarter",from:l.startOfQuarter(l.subQuarters(r,1)),to:l.endOfQuarter(l.subQuarters(r,1))},thisQuarter:{label:"Этот квартал",group:"quarter",from:g,to:l.endOfQuarter(r)},nextQuarter:{label:"Следующий квартал",group:"quarter",from:l.startOfQuarter(l.addQuarters(r,1)),to:l.endOfQuarter(l.addQuarters(r,1))},lastHalfYear:{label:"Прошлое полугодие",group:"halfYear",from:w.startOfHalfYear(v),to:w.endOfHalfYear(v)},thisHalfYear:{label:"Это полугодие",group:"halfYear",from:m,to:w.endOfHalfYear(r)},nextHalfYear:{label:"Следующее полугодие",group:"halfYear",from:w.startOfHalfYear(R),to:w.endOfHalfYear(R)},lastYear:{label:"Прошлый год",group:"year",from:l.startOfYear(l.subYears(r,1)),to:l.endOfYear(l.subYears(r,1))},thisYear:{label:"Этот год",group:"year",from:a,to:l.endOfYear(r)},nextYear:{label:"Следующий год",group:"year",from:l.startOfYear(l.addYears(r,1)),to:l.endOfYear(l.addYears(r,1))},fromBeginningOfThisWeek:{label:"С начала этой недели",group:"other",section:"fromBeginning",from:l.startOfWeek(r,e),to:s},fromBeginningOfThisTenDays:{label:"С начала этой декады",group:"other",section:"fromBeginning",from:o.from,to:s},fromBeginningOfThisMonth:{label:"С начала этого месяца",group:"other",section:"fromBeginning",from:p,to:s},fromBeginningOfThisQuarter:{label:"С начала этого квартала",group:"other",section:"fromBeginning",from:g,to:s},fromBeginningOfThisHalfYear:{label:"С начала этого полугодия",group:"other",section:"fromBeginning",from:m,to:s},fromBeginningOfThisYear:{label:"С начала этого года",group:"other",section:"fromBeginning",from:a,to:s},tillEndOfThisWeek:{label:"До конца этой недели",group:"other",section:"tillEnd",from:t,to:l.endOfWeek(r,e)},tillEndOfThisTenDays:{label:"До конца этой декады",group:"other",section:"tillEnd",from:t,to:o.to},tillEndOfThisMonth:{label:"До конца этого месяца",group:"other",section:"tillEnd",from:t,to:l.endOfMonth(r)},tillEndOfThisQuarter:{label:"До конца этого квартала",group:"other",section:"tillEnd",from:t,to:l.endOfQuarter(r)},tillEndOfThisHalfYear:{label:"До конца этого полугодия",group:"other",section:"tillEnd",from:t,to:w.endOfHalfYear(r)},tillEndOfThisYear:{label:"До конца этого года",group:"other",section:"tillEnd",from:t,to:l.endOfYear(r)},lastWeekTillSameWeekDay:{label:"Прошлая неделя, до такого же дня недели",group:"other",section:"lastTillSame",...w.weekTillSameWeekday(r,-1)},lastTenDaysTillSameDayNumber:{label:"Прошлая декада, до такого же номера дня",group:"other",section:"lastTillSame",...w.decadeTillSameDayNumber(r,-1)},lastMonthTillSameDate:{label:"Прошлый месяц, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(p,l.startOfMonth(l.subMonths(r,1)),r)},lastQuarterTillSameDate:{label:"Прошлый квартал, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(g,l.startOfQuarter(l.subQuarters(r,1)),r)},lastHalfYearTillSameDate:{label:"Прошлое полугодие, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(m,w.startOfHalfYear(v),r)},lastYearTillSameDate:{label:"Прошлый год, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(a,l.startOfYear(l.subYears(r,1)),r)},nextWeekTillSameWeekDay:{label:"Следующая неделя, до такого же дня недели",group:"other",section:"nextTillSame",...w.weekTillSameWeekday(r,1)},nextTenDaysTillSameDayNumber:{label:"Следующая декада, до такого же номера дня",group:"other",section:"nextTillSame",...w.decadeTillSameDayNumber(r,1)},nextMonthTillSameDate:{label:"Следующий месяц, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(p,l.startOfMonth(l.addMonths(r,1)),r)},nextQuarterTillSameDate:{label:"Следующий квартал, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(g,l.startOfQuarter(l.addQuarters(r,1)),r)},nextHalfYearTillSameDate:{label:"Следующее полугодие, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(m,w.startOfHalfYear(R),r)},nextYearTillSameDate:{label:"Следующий год, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(a,l.startOfYear(l.addYears(r,1)),r)},last7Days:{label:"Последние 7 дней",group:"other",section:"rollingDays",from:l.startOfDay(l.subDays(r,6)),to:s},next7Days:{label:"Следующие 7 дней",group:"other",section:"rollingDays",from:t,to:l.endOfDay(l.addDays(r,6))}}}}const ei=[{key:"day",label:"День"},{key:"week",label:"Неделя"},{key:"decade",label:"Декада"},{key:"month",label:"Месяц"},{key:"quarter",label:"Квартал"},{key:"halfYear",label:"Полугодие"},{key:"year",label:"Год"},{key:"other",label:"Прочее"}],ri=[{key:"fromBeginning",label:"С начала периода"},{key:"tillEnd",label:"До конца периода"},{key:"lastTillSame",label:"Прошлые, до такой же даты"},{key:"nextTillSame",label:"Следующие, до такой же даты"},{key:"rollingDays",label:"7 дней"}];function ti(n){const r=u.round(n*100);return`${r>=0?"+":""}${r}%`}class Sr{static productIsMeasurable(r){return r.unit.isLinear||r.unit.isSquare}static getProductMultiplicity(r){var e,t;return!((e=r.properties)!=null&&e.ignoreMinCountCheck)&&((t=r.properties)==null?void 0:t.minCount)!=null&&!Sr.productIsMeasurable(r)?r.properties.minCount:1}static getProductLengthMultiplicity(r){var e,t,s;return((e=r.properties)==null?void 0:e.lengthStep)!=null?r.properties.lengthStep:!((t=r.properties)!=null&&t.ignoreMinCountCheck)&&((s=r.properties)==null?void 0:s.minCount)!=null?r.properties.minCount:.01}}const we=class we extends y{constructor(){super();i(this,"responseDataCacheTimeout");this.responseDataCacheTimeout=b().config.http.responseDataCacheTimeout}static getCachedResponse(e){const t=we.responseDataCache.get(e);if(t&&t.validTo>new Date)return t.val}cacheResponse(e,t){we.responseDataCache.set(e,{validTo:l.addSeconds(new Date,this.responseDataCacheTimeout),val:t})}getTypedDataArrayRequester(e,t,s=!1,o={},p=void 0){const g=t+(u.isEmpty(o)?"":` >>> ${JSON.stringify(o)}`),m=s?we.getCachedResponse(g):void 0;return m?Promise.resolve(m):this.getTypedList(e,t,o,!1,p).then(a=>(s&&a&&this.cacheResponse(g,a),a))}};i(we,"responseDataCache",new Map);let ae=we;class ii{static generateUndefinedManagerInstance(){return new Y({id:0,name:"- Не назначен -",isActive:!0,guid:"-undefined-"})}static isUndefinedManagerInstance(r){return r.id===0&&r.guid==="-undefined-"}}class Ar extends ae{async getManagers(){const r="/internal/managers",e=ae.getCachedResponse(r);if(e)return e;const t=await this.get(r),s=I.instanceListInitializer(Y,t.data);return this.cacheResponse(r,s),s}getManager(r){return this.get(`/internal/managers/${r}`,{},e=>new Y(e.data))}}var Ce=(n=>(n.Processing="processing",n.Completed="completed",n.Error="error",n.NeedsActualization="needs_actualization",n))(Ce||{});class pt{constructor(r){i(this,"status");i(this,"actualizedAt");i(this,"expiresAt");i(this,"error");this.status=(r==null?void 0:r.status)??Ce.Processing,this.actualizedAt=Je.parse(r==null?void 0:r.actualizedAt),this.expiresAt=Je.parse(r==null?void 0:r.expiresAt),this.error=r==null?void 0:r.error}get isProcessing(){return this.status===Ce.Processing}get isOutdated(){return this.isOutdatedAt(new Date)}get isOrderAllowed(){return this.isOrderAllowedAt(new Date)}isOutdatedAt(r){return this.status!==Ce.Completed||u.isNil(this.actualizedAt)?!0:!u.isNil(this.expiresAt)&&this.expiresAt.getTime()<r.getTime()}isOrderAllowedAt(r){return this.status===Ce.Completed&&!this.isOutdatedAt(r)}}class br extends N{constructor(e){super(e);i(this,"name");i(this,"createdAt");i(this,"client");i(this,"sum");i(this,"isProfstroy");i(this,"actualization");i(this,"file");this.name=e==null?void 0:e.name,this.createdAt=Je.parse(e==null?void 0:e.createdAt)??new Date,this.client=new J(e==null?void 0:e.client),this.sum=e==null?void 0:e.sum,this.isProfstroy=e==null?void 0:e.isProfstroy,this.actualization=(e==null?void 0:e.actualization)&&new pt(e.actualization),this.file=e==null?void 0:e.file}}class ht extends nr{constructor(e){super(e);i(this,"groupName");i(this,"supplierSku");i(this,"isIgnored");i(this,"lineError");this.groupName=e.groupName,this.supplierSku=e.supplierSku??e.product.supplierSku,this.isIgnored=e.isIgnored,this.lineError=e.lineError}get isProductStub(){return u.isNil(this.product.id)}get isOrderable(){return!this.isProductStub&&!this.isIgnored&&u.isEmpty(this.lineError)}}class B extends br{constructor(e){super(e);i(this,"sum");i(this,"products");this.sum=e.sum??0,this.products=(e.products??[]).map(t=>e.isProfstroy?new ht(t):new nr(t))}}class si extends le{constructor(e){super();i(this,"id");i(this,"clientSearchTerm");i(this,"name");i(this,"createdAt",new T);this.id=e==null?void 0:e.id,this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.name=e==null?void 0:e.name,this.createdAt=new T(e==null?void 0:e.createdAt)}resetFilterValue(e){return e==="createdAt"?(this.createdAt.from=null,this.createdAt.to=null):this[e]=void 0,this}asClearRaw(){var t,s;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,e}}class $e extends D{}class Or extends Tr{constructor(e){var t,s,o,p,g,m,a,v;super(e);i(this,"client");i(this,"payment");i(this,"delivery");i(this,"attachedUser");i(this,"status");i(this,"statusDetail");i(this,"salesDirection");i(this,"attachedAt");i(this,"isOnOrder");i(this,"isProfstroy");i(this,"isNotInStock");i(this,"sum");i(this,"isLargeOrder");this.client=new J(e==null?void 0:e.client),this.payment={type:((t=e==null?void 0:e.payment)==null?void 0:t.type)??-1,status:((s=e==null?void 0:e.payment)==null?void 0:s.status)??-1,onlinePaymentLink:(o=e==null?void 0:e.payment)==null?void 0:o.onlinePaymentLink},this.delivery={type:((p=e==null?void 0:e.delivery)==null?void 0:p.type)??-1,date:u.isString((g=e==null?void 0:e.delivery)==null?void 0:g.date)?l.parseISO(e.delivery.date):((m=e==null?void 0:e.delivery)==null?void 0:m.date)??new Date,address:(a=e==null?void 0:e.delivery)!=null&&a.address?new ye(e.delivery.address):void 0,warehouse:(v=e==null?void 0:e.delivery)!=null&&v.warehouse?new ue(e.delivery.warehouse):void 0},this.attachedUser=e!=null&&e.attachedUser?new d(e==null?void 0:e.attachedUser):void 0,this.status=new $e(e==null?void 0:e.status),this.statusDetail=e!=null&&e.statusDetail?new D(e.statusDetail):void 0,this.salesDirection=new _(e==null?void 0:e.salesDirection),this.attachedAt=u.isString(e==null?void 0:e.attachedAt)?l.parseISO(e.attachedAt):e==null?void 0:e.attachedAt,this.isOnOrder=(e==null?void 0:e.isOnOrder)??!1,this.isProfstroy=(e==null?void 0:e.isProfstroy)??!1,this.isNotInStock=(e==null?void 0:e.isNotInStock)??!1,this.sum=(e==null?void 0:e.sum)??0,this.isLargeOrder=(e==null?void 0:e.isLargeOrder)??!1}}class gt extends sr{constructor(e,t){super(e);i(this,"product");i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");i(this,"changedFields",[]);i(this,"replacement");this.product=new z(e.product),this.currency=new q(e.currency),this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,t&&(this.replacement=t,this.quantity!==t.quantity&&this.changedFields.push("quantity"),this.length!==t.length&&this.changedFields.push("length"))}}class $ extends Or{constructor(e){var t;super(e);i(this,"products");i(this,"invoices");i(this,"comment");i(this,"image");i(this,"contragent");i(this,"barcode");i(this,"orderSource");i(this,"isAllowProcessingWithoutPayment");i(this,"nextStatuses");i(this,"actions");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"erpOrderUrl");i(this,"numberDoc");this.products=(e.products??[]).map(s=>{var p;const o=s.replacementId?(p=e.products)==null?void 0:p.find(g=>g.id===s.replacementId):void 0;return new gt(s,o)}),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?Oe.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new D(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment,this.nextStatuses=(t=e.nextStatuses)==null?void 0:t.map(s=>new $e(s)),this.actions=e.actions,this.operatorsComment=e.operatorsComment,this.operatorsForWarehouseComment=e.operatorsForWarehouseComment,this.erpOrderUrl=e.erpOrderUrl,this.numberDoc=e.numberDoc}}class ni extends U{getOffers(r,e,t,s=void 0){return this.getTypedPaginated(br,"/internal/orders/offers",r,e,t,{},void 0,s)}createOfferFromCart(r,e,t){return this.post(`/internal/orders/offers/${r}`,{name:e,items:t!=null&&t.length?t:void 0},s=>new B(s.data))}createProfstroyOffer(r,e,t,s={}){return this.post(`/internal/orders/offers/${r}/profstroy`,{file:e,name:t},o=>new B(o.data),s)}actualizeProfstroyOffer(r){return this.post(`/internal/orders/offers/${r}/profstroy/actualize`,{},e=>new B(e.data))}reloadProfstroyOffer(r){return this.post(`/internal/orders/offers/${r}/profstroy/reload`,{},e=>new B(e.data))}getOffer(r){return this.get(`/internal/orders/offers/${r}`,{},e=>new B(e.data))}updateOffer(r,e){return this.patch(`/internal/orders/offers/${r}`,{name:e},t=>new B(t.data))}deleteOffer(r){return this.delete(`/internal/orders/offers/${r}`)}createOrderFromDraft(r,e,t,s={}){const o=b().config.dateFormats.api;return this.post(`/internal/orders/offers/${r}/create-order`,{...e,deliveryDate:e.deliveryDate?l.format(e.deliveryDate,o):void 0,items:t!=null&&t.length?t:void 0},p=>I.instanceListInitializer($,p.data),s)}addOfferProduct(r,e,t={}){return this.post(`/internal/orders/offers/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new B(s.data),t)}patchOfferProduct(r,e,t,s={}){return this.patch(`/internal/orders/offers/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},o=>new B(o.data),s)}deleteOfferProduct(r,e){return this.delete(`/internal/orders/offers/${r}/products/${e}`,t=>new B(t.data))}getOfferHtml(r,e){return this.get(`/internal/orders/offers/${r}/view`,e?{recipientText:e}:{},t=>new Blob([t.data],{type:"text/html"}))}getOfferPdf(r,e){return this.getBlob(`/internal/orders/offers/${r}/download`,e?{recipientText:e}:{},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOffer(r,e){return this.post(`/internal/orders/offers/${r}/send`,e)}}class oi{static isProfstroy(r){return!!(r!=null&&r.isProfstroy)}static isProfstroyOffer(r){return!u.isNil(r)&&r.isProfstroy===!0&&!u.isNil(r.actualization)}}var ft=(n=>(n.View="view",n.Share="share",n.EditTags="edit_tags",n.SaveOrderIgnoredProducts="save_order_ignored_products",n.ChangeStatus="change_status",n.ChangeProducts="change_products",n.ChangeOrderParameters="change_order_parameters",n.Recalculate="recalculate",n.AttachOrder="attach_order",n.DetachOrder="detach_order",n.ChangeAttachedOperator="change_attached_operator",n.SendOnlinePaymentLink="send_online_payment_link",n.ConfirmOnlineFullPayment="confirm_online_full_payment",n.MergeOrders="merge_orders",n.GetHistory="get_history",n.CloneOrder="clone_order",n.DeleteAttachedFile="delete_attached_file",n))(ft||{});class ci{constructor(r){i(this,"paymentType");i(this,"deliveryType");i(this,"contragentId");i(this,"deliveryDate");i(this,"addressId");i(this,"warehouseId");i(this,"image");i(this,"comment");i(this,"barcode");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"additionalEmails");i(this,"isAllowProcessingWithoutPayment");i(this,"isAdditionalSale");var e,t,s;this.paymentType=r==null?void 0:r.payment.type,this.deliveryType=r==null?void 0:r.delivery.type,this.contragentId=(e=r==null?void 0:r.contragent)==null?void 0:e.id,this.deliveryDate=r!=null&&r.delivery.date?new Date(r.delivery.date):void 0,this.addressId=(t=r==null?void 0:r.delivery.address)==null?void 0:t.id,this.warehouseId=(s=r==null?void 0:r.delivery.warehouse)==null?void 0:s.id,this.comment=r==null?void 0:r.comment,this.barcode=r==null?void 0:r.barcode,this.operatorsComment=r==null?void 0:r.operatorsComment,this.operatorsForWarehouseComment=r==null?void 0:r.operatorsForWarehouseComment,this.isAllowProcessingWithoutPayment=r==null?void 0:r.isAllowProcessingWithoutPayment}}class $r extends D{}class kr extends D{}class li extends le{constructor(e){var t,s,o,p;super();i(this,"attachedUsers");i(this,"clientSearchTerm");i(this,"client");i(this,"contragent");i(this,"createdAt",new T);i(this,"creator");i(this,"deliveryDate",new T);i(this,"deliveryAddressSearch");i(this,"clientCities");i(this,"id");i(this,"isApproved");i(this,"isNotInStock");i(this,"isOnOrder");i(this,"attachedAt",new T);i(this,"salesDirections");i(this,"status");i(this,"statusDetail");i(this,"deliveryType");i(this,"paymentType");i(this,"warehouses");i(this,"isLargeOrder");i(this,"isToProcess");i(this,"onlyMyRegions");this.attachedUsers=(t=e==null?void 0:e.attachedUsers)==null?void 0:t.map(g=>"isActive"in g?new Y(g):new $r(g)),this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.client=e!=null&&e.client?new J(e.client):void 0,this.contragent=e==null?void 0:e.contragent,this.createdAt=new T(e==null?void 0:e.createdAt),this.creator=e!=null&&e.creator?new d(e.creator):void 0,this.deliveryDate=new T(e==null?void 0:e.deliveryDate),this.deliveryAddressSearch=e==null?void 0:e.deliveryAddressSearch,this.clientCities=(s=e==null?void 0:e.clientCities)==null?void 0:s.map(g=>new ie(g)),this.id=e==null?void 0:e.id,this.isApproved=e==null?void 0:e.isApproved,this.isNotInStock=e==null?void 0:e.isNotInStock,this.isOnOrder=e==null?void 0:e.isOnOrder,this.isLargeOrder=e==null?void 0:e.isLargeOrder,this.attachedAt=new T(e==null?void 0:e.attachedAt),this.salesDirections=(o=e==null?void 0:e.salesDirections)==null?void 0:o.map(g=>new _(g)),this.status=e==null?void 0:e.status,this.statusDetail=e==null?void 0:e.statusDetail,this.deliveryType=e!=null&&e.deliveryType?new W(e.deliveryType):void 0,this.paymentType=e!=null&&e.paymentType?new kr(e.paymentType):void 0,this.warehouses=(p=e==null?void 0:e.warehouses)==null?void 0:p.map(g=>new ue(g)),this.isToProcess=e==null?void 0:e.isToProcess}resetFilterValue(e){switch(e){case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"creator":this.creator=void 0;break;case"deliveryDate":this.deliveryDate.from=null,this.deliveryDate.to=null;break;case"deliveryType":this.deliveryType=new W;break;case"clientCities":this.clientCities=[];break;case"attachedAt":this.attachedAt.from=null,this.attachedAt.to=null;break;case"salesDirection":case"salesDirections":this.salesDirections=[];break;case"status":this.status=[];break;case"warehouse":case"warehouses":this.warehouses=[];break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,p,g,m;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.deliveryDate)!=null&&o.from)&&!((p=e==null?void 0:e.deliveryDate)!=null&&p.to)&&delete e.deliveryDate,!((g=e==null?void 0:e.attachedAt)!=null&&g.from)&&!((m=e==null?void 0:e.attachedAt)!=null&&m.to)&&delete e.attachedAt,e}}class mt{constructor(r){i(this,"user");i(this,"status");i(this,"statusDetail");i(this,"createdAt");this.user=new d(r==null?void 0:r.user),this.status=new $e(r==null?void 0:r.status),this.statusDetail=r!=null&&r.statusDetail?new D(r.statusDetail):void 0,this.createdAt=u.isString(r==null?void 0:r.createdAt)?l.parseISO(r.createdAt):(r==null?void 0:r.createdAt)??new Date}}class ui extends U{getOrders(r,e,t,s=void 0){return this.getTypedPaginated(Or,"/internal/orders",r,e,t,{},void 0,s)}getOrdersCount(r,e=void 0){return this.get("/internal/orders/count",r?{filters:JSON.stringify((r instanceof V?r:new V(r)).toPrimitive())}:{},void 0,void 0,e).then(t=>t.count)}getClientOrderStatistics(r,e){return this.get(`/internal/clients/${r}/orders/statistics`,e?{period:e}:{})}getOrder(r){return this.get(`/internal/orders/${r}`,{},e=>new $(e.data))}createClientOrder(r,e,t,s,o={}){const p=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/orders/${e}`,{...t,deliveryDate:l.format(t.deliveryDate,p),items:s!=null&&s.length?s:void 0},g=>I.instanceListInitializer($,g.data),o)}attachOrder(r){return this.patch(`/internal/orders/${r}/attach`,{},e=>new $(e.data))}detachOrder(r){return this.patch(`/internal/orders/${r}/detach`,{},e=>new $(e.data))}mergeOrders(r,e){return this.patch(`/internal/orders/${r}/merge`,{ids:e},t=>new $(t.data))}recalculateOrder(r){return this.patch(`/internal/orders/${r}/recalculate`,{},e=>new $(e.data))}cloneOrder(r){return this.get(`/internal/orders/${r}/clone`,{})}updateOrder(r,e,t={}){const s=b().config.dateFormats.api;return this.patch(`/internal/orders/${r}`,{...e,deliveryDate:e.deliveryDate?l.format(e.deliveryDate,s):void 0},o=>new $(o.data),t)}addOrderProduct(r,e,t={}){return this.post(`/internal/orders/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new $(s.data),t)}changeOrderStatus(r,e,t,s={}){return this.patch(`/internal/orders/${r}/status`,{status:e,statusDetail:t},o=>new $(o.data),s)}changeOrderStatusDetail(r,e){return this.patch(`/internal/orders/${r}/status`,{statusDetail:e},t=>new $(t.data))}getOrderStatusHistory(r){return this.getTypedList(mt,`/internal/orders/${r}/history`)}getOrderPrintHtml(r,e){return this.get(`/internal/orders/${r}/print/view`,{...e},t=>new Blob([t.data],{type:"text/html"}))}getOrderPrintPdf(r,e){return this.getBlob(`/internal/orders/${r}/print/download`,{...e},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOrderPrint(r,e){return this.post(`/internal/orders/${r}/print/send`,e)}changeAttachedOperator(r,e){return this.patch(`/internal/orders/${r}/change-attached-operator`,{operatorId:e},t=>new $(t.data))}deleteOrderAttachedFile(r){return this.delete(`/internal/orders/${r}/file/attached`,e=>new $(e.data))}deleteOrderProduct(r,e){return this.delete(`/internal/orders/${r}/products/${e}`,t=>new $(t.data))}patchOrderProduct(r,e,t,s={}){return this.patch(`/internal/orders/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},o=>new $(o.data),s)}getDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getSelfDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/self-delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getDeliveryCost(r,e,t,s=void 0){const o=b().config.dateFormats.api;return this.get(`/internal/orders/delivery/${r}/cost`,{date:l.format(e,o),warehouse_id:t},p=>p.data,void 0,s)}}const pi=Symbol("currentOrder");class Ke{constructor(r){i(this,"client");i(this,"product");i(this,"cost");i(this,"costCoefficient");i(this,"source");this.client=new J(r==null?void 0:r.client),this.product=new L(r==null?void 0:r.product),this.cost=(r==null?void 0:r.cost)??0,this.costCoefficient=(r==null?void 0:r.costCoefficient)??0,this.source=(r==null?void 0:r.source)??He.Product}}const Ir=n=>{var r,e,t,s,o;return n?u.omitBy({cities:(r=n.cities)==null?void 0:r.map(p=>p.id),clients:(e=n.clients)==null?void 0:e.map(p=>p.id),managers:(t=n.managers)==null?void 0:t.map(p=>p.id),partnerGroups:(s=n.partnerGroups)==null?void 0:s.map(p=>p.id),salesDirections:(o=n.salesDirections)==null?void 0:o.map(p=>p.id),hideNotActive:n.hideNotActive},p=>u.isNil(p)||(u.isArray(p)||u.isObject(p))&&u.isEmpty(p)):{}},yt=n=>{const r={};return n.from&&(n.from.coefficient||n.from.value)&&(r.from={},n.from.coefficient&&(r.from.priceCoefficientId=n.from.coefficient.id),n.from.value&&(r.from.increasePercent=n.from.value)),n.to&&(n.to.coefficient||n.to.value)&&(r.to={},n.to.coefficient&&(r.to.priceCoefficientId=n.to.coefficient.id),n.to.value&&(r.to.increasePercent=n.to.value)),r};class hi extends y{analyzeProductPrices(r,e,t){return this.get(`/internal/price/products/${r}/analyze`,{...yt(e),filters:Ir(t)},s=>I.instanceListInitializer(Ke,s.data))}analyzeCategoryPrices(r,e,t){return this.get(`/internal/price/categories/${r}/analyze`,{...yt(e),filters:Ir(t)},s=>I.instanceListInitializer(Ke,s.data))}analyzeCategoryPricesBySquare(r,e,t){return this.get(`/internal/price/categories/${r}/analyze/square`,{...e,filters:Ir(t)},s=>I.instanceListInitializer(Ke,s.data))}}class at{constructor(r){i(this,"cost");i(this,"isLowCost");i(this,"isRetail");i(this,"costDate");i(this,"discountName");i(this,"priceTemplateName");i(this,"product");i(this,"client");i(this,"executor");i(this,"currency");this.cost=r.cost??0,this.isLowCost=r.isLowCost??!1,this.isRetail=r.isRetail??!1,this.costDate=u.isString(r.costDate)?l.parseISO(r.costDate):r.costDate??new Date,this.discountName=r.discountName,this.priceTemplateName=r.priceTemplateName,this.product=r.product?new pe(r.product):void 0,this.client=r.client?new d(r.client):void 0,this.executor=r.executor?new d(r.executor):void 0,this.currency=r.currency?new q(r.currency):void 0}}class Ct extends pe{constructor(e){super(e);i(this,"history");this.history=u.map(e.history,t=>new at(t))}}class gi extends y{getProductPriceHistory(r){var o,p,g,m,a;const e=b().config.dateFormats.api,t=u.omitBy(u.merge(r,{costDate:{from:u.isDate((o=r.costDate)==null?void 0:o.from)?l.format(r.costDate.from,e):(p=r.costDate)==null?void 0:p.from,to:u.isDate((g=r.costDate)==null?void 0:g.to)?l.format(r.costDate.to,e):(m=r.costDate)==null?void 0:m.to}}),v=>u.isNil(v)||(u.isArray(v)||u.isObject(v))&&u.isEmpty(v)),s=((a=r.product)==null?void 0:a[0])??0;return delete t.product,this.get(`/internal/price/products/${s}/history`,t).then(v=>[new Ct(u.merge(v[0],{history:v}))])}}class dr{constructor(r){i(this,"products",[]);i(this,"productCategories",[]);r!=null&&r.products&&(this.products=r.products.map(e=>new pe(e))),r!=null&&r.productCategories&&(this.productCategories=r.productCategories.map(e=>new pe(e)))}}class fi extends y{getProductCategoryRecommendations(r){return this.get(`/internal/catalog/recommendations/categories/${r.id}`,{},e=>new dr(e.data))}getProductRecommendations(r){return this.get(`/internal/catalog/recommendations/products/${r.id}`,{},e=>new dr(e.data))}saveProductCategoryRecommendations(r,e){return this.post(`/internal/catalog/recommendations/categories/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}saveProductRecommendations(r,e){return this.post(`/internal/catalog/recommendations/products/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}}var wt=(n=>(n.New="new",n.Processing="processing",n.AwaitingSupplyProducts="awaiting_supply_products",n.InvoiceIssued="invoice_issued",n.ProcessingOnStock="processing_on_stock",n.Finished="finished",n.OrderUpdated="order_updated",n.Canceled="canceled",n.Error="error",n))(wt||{}),Pt=(n=>(n.CanceledBy1c="canceled_by1c",n.CanceledByClient="canceled_by_client",n.FinishedNotApproved="finished_not_approved",n.ProcessingByPurchasingDepartment="processing_by_purchasing_department",n.WillWaiting="will_waiting",n))(Pt||{});class vt extends D{}class Dt extends D{}class Lr extends D{constructor(e){var t;super(e);i(this,"userRegions");this.userRegions=((t=e==null?void 0:e.userRegions)==null?void 0:t.map(s=>new Ae(s)))??[]}}class Rt extends D{}class Tt extends D{}class St extends D{}class At extends D{}class mi{static generateUndefinedInstance(r,e="- Не определён -"){return new r({id:0,name:e,slug:"-undefined-"})}static isUndefinedInstance(r){return r.id===0&&r.slug==="-undefined-"}}class _r extends D{}const Q=class Q extends ae{static withoutUnknownLocation(r){return r.filter(e=>e.id!==Q.unknownLocationId)}getReference(r,e=!1){return this.getTypedDataArrayRequester(vt,`/internal/references/${r}`,e)}getChannelPrimaryInterest(){return this.getTypedDataArrayRequester(vr,"/internal/references/channel-primary-interest",!0)}getContactPositions(){return this.getTypedDataArrayRequester(Rt,"/internal/references/contact-position",!0)}getCuratedDirection(){return this.getTypedDataArrayRequester(We,"/internal/references/curated-direction",!0)}getCurrency(){return this.getTypedDataArrayRequester(q,"/public/references/currency",!0)}getPartnerGroup(){return this.getTypedDataArrayRequester(oe,"/internal/references/partner-group",!0)}getOpf(){return this.getTypedDataArrayRequester(E,"/public/references/opf",!0)}getOperators(){return this.getTypedDataArrayRequester($r,"/internal/references/operator",!0)}getOrderPaymentStatuses(){return this.getTypedDataArrayRequester(Tt,"/public/references/order-payment-status",!0)}getOrderStatuses(){return this.getTypedDataArrayRequester($e,"/internal/references/order-status",!0)}getOrderStatusDetails(){return this.getTypedDataArrayRequester(St,"/internal/references/order-status-detail",!0)}getPaymentTypes(){return this.getTypedDataArrayRequester(kr,"/public/references/payment-type",!0)}getResourceTypes(){return this.getTypedDataArrayRequester(_r,"/internal/references/resource-type",!0)}getSalesDirections(){return this.getTypedDataArrayRequester(_,"/public/references/sales-direction",!0)}getSourcePrimaryInterest(){return this.getTypedDataArrayRequester(Dr,"/internal/references/source-primary-interest",!0)}searchCity(r){return this.getTypedDataArrayRequester(ie,`/internal/references/city-with-region-and-country/search?term=${r}`)}searchRegion(r){return this.getTypedDataArrayRequester(te,`/internal/references/region-with-country/search?term=${r}`)}getRegionsByCountry(r){return this.getTypedDataArrayRequester(te,"/internal/references/region",!1,{params:{countryId:r}}).then(e=>Q.withoutUnknownLocation(e))}getCitiesByRegion(r){return this.getTypedDataArrayRequester(Dt,"/internal/references/city",!1,{params:{regionId:r}}).then(e=>Q.withoutUnknownLocation(e))}getCitiesWithUserRegionByRegion(r){return this.getTypedDataArrayRequester(Lr,"/internal/references/city-with-user-region",!1,{params:{regionId:r}}).then(e=>Q.withoutUnknownLocation(e))}searchCityWithRegion(r,e,t=void 0){return this.getTypedDataArrayRequester(ie,"/internal/references/city-with-region/search",!1,{term:r,...e?{params:{countryId:e}}:{}},t).then(s=>Q.withoutUnknownLocation(s))}searchCityWithUserRegion(r,e=void 0){return this.getTypedDataArrayRequester(Lr,"/internal/references/city-with-user-region/search",!1,{term:r},e).then(t=>Q.withoutUnknownLocation(t))}searchCountry(r){return this.getTypedDataArrayRequester(re,`/internal/references/country/search?term=${r}`)}getDeliveryTypes(){return this.getTypedDataArrayRequester(W,"/internal/references/delivery-type",!0)}getWarehouses(){return this.getTypedDataArrayRequester(ue,"/public/references/warehouse",!0)}getPropertyTypes(){return this.getTypedDataArrayRequester(hr,"/internal/references/property-type",!0)}getPriceCoefficients(){return this.getTypedDataArrayRequester(ee,"/internal/references/price-coefficient",!0)}getProductFileType(){return this.getTypedDataArrayRequester(At,"/public/references/product-file-type",!0)}};i(Q,"unknownLocationId",1);let S=Q;const A=x.defineStore("common.references_private",()=>{const n=f.ref({}),r=f.ref(void 0),e=f.ref(void 0),t=f.ref(void 0),s=f.ref(void 0),o=f.ref(void 0),p=f.ref(void 0),g=f.ref(void 0),m=f.ref(void 0),a=f.ref(void 0),v=f.ref(void 0),R=f.ref(void 0),ke=f.ref(void 0),Ie=f.ref(void 0),Pe=f.ref(void 0),ve=f.ref(void 0),qr=f.ref(void 0),Hr=f.ref(void 0),Br=f.ref(void 0),h=f.ref(void 0);return{dataLoaderList:n,channelPrimaryInterestReference:r,contactPositionsReference:e,currencyReference:t,deliveryTypeReference:s,managersList:o,opfReference:p,operatorReference:g,orderPaymentStatusReference:m,orderStatusReference:a,orderStatusDetailReference:v,paymentTypeReference:R,partnerGroupReference:ke,productFileTypeReference:Ie,resourceTypesReference:Pe,salesDirectionsReference:ve,sourcePrimaryInterestReference:qr,warehousesReference:Hr,propertyTypesReference:Br,priceCoefficientsReference:h}}),yi=x.defineStore("common.references",()=>{const n=f.computed(()=>{const h=A();return!h.channelPrimaryInterestReference&&!h.dataLoaderList.channelPrimaryInterestReference&&(h.dataLoaderList.channelPrimaryInterestReference=!0,y.getInstance(S).getChannelPrimaryInterest().then(C=>{h.channelPrimaryInterestReference=C}).catch(u.noop)),h.channelPrimaryInterestReference}),r=f.computed(()=>{const h=A();return!h.contactPositionsReference&&!h.dataLoaderList.contactPositionsReference&&(h.dataLoaderList.contactPositionsReference=!0,y.getInstance(S).getContactPositions().then(C=>{h.contactPositionsReference=C}).catch(u.noop)),h.contactPositionsReference}),e=f.computed(()=>{const h=A();return!h.currencyReference&&!h.dataLoaderList.currencyReference&&(h.dataLoaderList.currencyReference=!0,y.getInstance(S).getCurrency().then(C=>{h.currencyReference=C}).catch(u.noop)),h.currencyReference}),t=f.computed(()=>{const h=A();return!h.opfReference&&!h.dataLoaderList.opfReference&&(h.dataLoaderList.opfReference=!0,y.getInstance(S).getOpf().then(C=>{h.opfReference=C}).catch(u.noop)),h.opfReference}),s=f.computed(()=>{const h=A();return!h.operatorReference&&!h.dataLoaderList.operatorReference&&(h.dataLoaderList.operatorReference=!0,y.getInstance(S).getOperators().then(C=>{h.operatorReference=C}).catch(u.noop)),h.operatorReference}),o=f.computed(()=>{const h=A();return!h.orderPaymentStatusReference&&!h.dataLoaderList.orderPaymentStatusReference&&(h.dataLoaderList.orderPaymentStatusReference=!0,y.getInstance(S).getOrderPaymentStatuses().then(C=>{h.orderPaymentStatusReference=C}).catch(u.noop)),h.orderPaymentStatusReference}),p=f.computed(()=>{const h=A();return!h.orderStatusReference&&!h.dataLoaderList.orderStatusReference&&(h.dataLoaderList.orderStatusReference=!0,y.getInstance(S).getOrderStatuses().then(C=>{h.orderStatusReference=C}).catch(u.noop)),h.orderStatusReference}),g=f.computed(()=>{const h=A();return!h.orderStatusDetailReference&&!h.dataLoaderList.orderStatusDetailReference&&(h.dataLoaderList.orderStatusDetailReference=!0,y.getInstance(S).getOrderStatusDetails().then(C=>{h.orderStatusDetailReference=C}).catch(u.noop)),h.orderStatusDetailReference}),m=f.computed(()=>{const h=A();return!h.paymentTypeReference&&!h.dataLoaderList.paymentTypeReference&&(h.dataLoaderList.paymentTypeReference=!0,y.getInstance(S).getPaymentTypes().then(C=>{h.paymentTypeReference=C}).catch(u.noop)),h.paymentTypeReference}),a=f.computed(()=>{const h=A();return!h.partnerGroupReference&&!h.dataLoaderList.partnerGroupReference&&(h.dataLoaderList.partnerGroupReference=!0,y.getInstance(S).getPartnerGroup().then(C=>{h.partnerGroupReference=C}).catch(u.noop)),h.partnerGroupReference}),v=f.computed(()=>{const h=A();return!h.productFileTypeReference&&!h.dataLoaderList.productFileTypeReference&&(h.dataLoaderList.productFileTypeReference=!0,y.getInstance(S).getProductFileType().then(C=>{h.productFileTypeReference=C}).catch(u.noop)),h.productFileTypeReference}),R=f.computed(()=>{const h=A();return!h.resourceTypesReference&&!h.dataLoaderList.resourceTypesReference&&(h.dataLoaderList.resourceTypesReference=!0,y.getInstance(S).getResourceTypes().then(C=>{h.resourceTypesReference=C}).catch(u.noop)),h.resourceTypesReference}),ke=f.computed(()=>{const h=A();return!h.salesDirectionsReference&&!h.dataLoaderList.salesDirectionsReference&&(h.dataLoaderList.salesDirectionsReference=!0,y.getInstance(S).getSalesDirections().then(C=>{h.salesDirectionsReference=C}).catch(u.noop)),h.salesDirectionsReference}),Ie=f.computed(()=>{const h=A();return!h.sourcePrimaryInterestReference&&!h.dataLoaderList.sourcePrimaryInterestReference&&(h.dataLoaderList.sourcePrimaryInterestReference=!0,y.getInstance(S).getSourcePrimaryInterest().then(C=>{h.sourcePrimaryInterestReference=C}).catch(u.noop)),h.sourcePrimaryInterestReference}),Pe=f.computed(()=>{const h=A();return!h.deliveryTypeReference&&!h.dataLoaderList.deliveryTypeReference&&(h.dataLoaderList.deliveryTypeReference=!0,y.getInstance(S).getDeliveryTypes().then(C=>{h.deliveryTypeReference=C}).catch(u.noop)),h.deliveryTypeReference}),ve=f.computed(()=>{const h=A();return!h.managersList&&!h.dataLoaderList.managersList&&(h.dataLoaderList.managersList=!0,y.getInstance(Ar).getManagers().then(C=>{h.managersList=C}).catch(u.noop)),h.managersList}),qr=f.computed(()=>{const h=A();return!h.warehousesReference&&!h.dataLoaderList.warehousesReference&&(h.dataLoaderList.warehousesReference=!0,y.getInstance(S).getWarehouses().then(C=>{h.warehousesReference=C}).catch(u.noop)),h.warehousesReference}),Hr=f.computed(()=>{const h=A();return!h.propertyTypesReference&&!h.dataLoaderList.propertyTypesReference&&(h.dataLoaderList.propertyTypesReference=!0,y.getInstance(S).getPropertyTypes().then(C=>{h.propertyTypesReference=C}).catch(u.noop)),h.propertyTypesReference}),Br=f.computed(()=>{const h=A();return!h.priceCoefficientsReference&&!h.dataLoaderList.priceCoefficientsReference&&(h.dataLoaderList.priceCoefficientsReference=!0,y.getInstance(S).getPriceCoefficients().then(C=>{h.priceCoefficientsReference=C}).catch(u.noop)),h.priceCoefficientsReference});return{channelPrimaryInterestsReference:n,contactPositionsReference:r,currencyReference:e,opfReference:t,operatorReference:s,orderPaymentStatusReference:o,orderStatusReference:p,orderStatusDetailReference:g,paymentTypeReference:m,partnerGroupsReference:a,productFilesTypesReference:v,resourceTypesReference:R,salesDirectionsReference:ke,sourcePrimaryInterestsReference:Ie,deliveryTypeReference:Pe,managersList:ve,warehousesReference:qr,propertyTypesReference:Hr,priceCoefficientsReference:Br}});class bt{constructor(r){i(this,"name");i(this,"content");this.name=r.name,this.content=r.content}}class Nr{constructor(r){i(this,"resourceType");i(this,"resourceId");i(this,"h1");i(this,"title");i(this,"description");i(this,"keywords");i(this,"meta");i(this,"tags");var e;this.resourceType=new _r(r==null?void 0:r.resourceType),this.resourceId=(r==null?void 0:r.resourceId)??"",this.h1=r==null?void 0:r.h1,this.title=r==null?void 0:r.title,this.description=r==null?void 0:r.description,this.keywords=r==null?void 0:r.keywords,this.meta=((e=r==null?void 0:r.meta)==null?void 0:e.map(t=>new bt(t)))??[],this.tags=r==null?void 0:r.tags}}class ai extends y{getResourceSeoData(r,e){return this.get(`/internal/seo/${r.slug}/${e}`,{},t=>new Nr(t.data))}saveResourceSeoData(r,e={}){return this.post(`/internal/seo/${r.resourceType.slug}/${r.resourceId}`,r,t=>new Nr(t.data),e)}deleteResourceSeoData(r,e){return this.delete(`/internal/seo/${r.slug}/${e}`)}}class Ci extends y{searchAddresses(r){return this.execSuggestionQuery("/public/suggestions/address",r)}searchBank(r){return this.execSuggestionQuery("/public/suggestions/bank",r)}searchOrganization(r){return this.execSuggestionQuery("/public/suggestions/organization",r)}execSuggestionQuery(r,e){return this.get(r,{query:e}).then(t=>{const s=[...t];let o=1;return s.forEach(p=>{p.id=o++}),s})}}var Mr=(n=>(n.Admin="admin",n.Manager="manager",n.Operator="operator",n.Client="client",n.ExternalSeo="external_seo",n.Guest="guest",n))(Mr||{});class Ot extends pr{constructor(e){super(e);i(this,"type");i(this,"canDoReclamations");i(this,"photo");i(this,"pricingRole");this.type=e==null?void 0:e.type,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.photo=e==null?void 0:e.photo,this.pricingRole=e!=null&&e.pricingRole?new lr(e.pricingRole):void 0}}class wi extends y{constructor(){super(),this.baseUrl=`${b().config.http.portalApiUrl}/api`,this.interceptorIds.request.authRequestInterceptor&&this.httpClient.interceptors.request.eject(this.interceptorIds.request.authRequestInterceptor)}getAccessToken(){return this.get("internal/users/current-tokens").then(r=>r.accessToken)}}class $t extends y{getCurrentUser(){return this.get("/internal/users/info",{},r=>new Ot(r.data),!0)}}const Ur=x.defineStore("common.user_state_private",()=>{const n=f.ref({}),r=f.ref(void 0),e=f.ref(void 0);return{dataLoaderList:n,currentUser:r,currentManager:e}});function kt(n){const r=Ur();(n==null?void 0:n.type)!==Mr.Manager||r.currentManager||r.dataLoaderList.currentManager||(r.dataLoaderList.currentManager=!0,y.getInstance(Ar).getManager(n.id).then(e=>{r.currentManager=e}).catch(u.noop).finally(()=>{r.dataLoaderList.currentManager=!1}))}const Pi=x.defineStore("common.user_state",()=>{const n=f.computed(()=>{const e=Ur();return!e.currentUser&&!e.dataLoaderList.currentUser&&(e.dataLoaderList.currentUser=!0,y.getInstance($t).getCurrentUser().then(t=>{e.currentUser=t,kt(t)}).catch(u.noop).finally(()=>{e.dataLoaderList.currentUser=!1})),e.currentUser}),r=f.computed(()=>(kt(n.value),Ur().currentManager));return{currentUser:n,currentManager:r}});class Ee{constructor(r){i(this,"user");i(this,"salesDirection");this.user=new d(r==null?void 0:r.user),this.salesDirection=new _(r==null?void 0:r.salesDirection)}}class xe extends Ae{constructor(e){var t,s;super(e);i(this,"cities");i(this,"users");this.cities=((t=e==null?void 0:e.cities)==null?void 0:t.map(o=>new ie(o)))??[],this.users=((s=e==null?void 0:e.users)==null?void 0:s.map(o=>new Ee(o)))??[]}}class vi extends le{constructor(e){super();i(this,"id");i(this,"name");i(this,"abbr");this.id=e==null?void 0:e.id,this.name=e==null?void 0:e.name,this.abbr=e==null?void 0:e.abbr}resetFilterValue(e){switch(e){case"id":case"name":case"abbr":this[e]=void 0;break}return this}}class Di extends U{getRegionsList(r,e,t){return this.getTypedPaginated(Ae,"/internal/users/regions",r,e,t)}getRegion(r){return this.get(`/internal/users/regions/${r}`,{},e=>new xe(e.data))}createRegion(r,e={}){return this.post("/internal/users/regions",r,t=>new xe(t.data),e)}updateRegion(r,e,t={}){return this.patch(`/internal/users/regions/${r}`,e,s=>new xe(s.data),t)}removeRegion(r){return this.delete(`/internal/users/regions/${r}`)}getRegionEmployees(r){return this.getTypedList(Ee,`/internal/users/regions/${r}/users`)}attachRegionEmployee(r,e,t){return this.post(`/internal/users/regions/${r}/users/${e}`,{salesDirectionId:t},s=>new Ee(s.data))}detachRegionEmployee(r,e,t){return this.request({method:"DELETE",url:`/internal/users/regions/${r}/users/${e}`,params:{sales_direction_id:t}})}}class Ri{constructor(r,e){i(this,"showFeedback",!1);i(this,"feedback","");i(this,"validationStatus");this.showFeedback=!!r,this.feedback=r,this.validationStatus=e}}c.AnyReference=vt,c.AppBaseConfig=Qr,c.BankAccount=Ge,c.BasePaginationProvider=U,c.BlogPost=_e,c.BlogPostMediaFile=Le,c.BlogPostMediaTypeEnum=Te,c.BlogPostPublicationStatusEnum=Se,c.BlogPostShortInfo=Z,c.BlogPostsListFilters=It,c.BlogProvider=Me,c.CalculationTypeEnum=Xr,c.CalendarHelper=w,c.Cart=ge,c.CartProvider=dt,c.CatalogProvider=Nt,c.CatalogableItem=ir,c.Category=j,c.CategoryFilter=rt,c.CategoryFilterSetting=fr,c.CategoryFilterValue=et,c.CategoryPricingRule=gr,c.ChannelPrimaryInterest=vr,c.City=Dt,c.CityWithRegionAndCountry=ie,c.CityWithUserRegion=Lr,c.Client=Rr,c.ClientAdditionalData=nt,c.ClientCategory=be,c.ClientDataProvider=H,c.ClientPriceProvider=Mt,c.ClientPriceTemplateProvider=Ut,c.ClientProduct=z,c.ClientProductCategoryDataProvider=Bt,c.ClientProductDataProvider=Wt,c.ClientShortInfo=J,c.ClientsAdditionalDataRequestTypeEnum=tt,c.ClientsListFilters=Qt,c.CodedIdentity=pe,c.ConfiguratorProvider=Kt,c.ConfiguratorsEnum=ct,c.Contact=Qe,c.ContactLinks=cr,c.ContactPerson=K,c.ContactPersonRelated=ot,c.ContactPosition=Rt,c.ContactRelation=Ve,c.ContragentBase=Cr,c.ContragentFactory=Oe,c.ContragentIc=wr,c.ContragentPerson=it,c.ContragentUlNr=st,c.ContragentUlR=Pr,c.CostSourceEnum=He,c.Country=re,c.CuratedDirection=We,c.Curator=je,c.Currency=q,c.DataSuggestionProvider=Ci,c.DateHelper=Je,c.DateTimeProvider=Ft,c.DeletableNamedIdentity=ar,c.DeliveryAddress=ye,c.DeliveryType=W,c.DetailedJwtPayload=Xe,c.DeviceTypeResolutionConfig=zr,c.DiscountShortInfo=Jr,c.FieldValidationResultData=Ri,c.FilterGroup=V,c.FilterItem=Ze,c.FilterOpEnum=Ne,c.FilterSettings=Fr,c.GeoCoordinates=rr,c.HiddenCatalogableItem=Er,c.HttpCachedRequester=ae,c.HttpParamsConfig=jr,c.HttpRequester=y,c.Identity=N,c.Image=xr,c.InterceptorsEnum=M,c.JwtPayload=X,c.Manager=Y,c.ManagerCommon=Be,c.ManagerDataFactory=ii,c.ManagerDataProvider=Ar,c.MetaTagItem=bt,c.NamedIdentity=O,c.Offer=B,c.OfferActualization=pt,c.OfferActualizationStatus=Ce,c.OfferHelper=oi,c.OfferShortInfo=br,c.OffersDataProvider=ni,c.OffersListFilters=si,c.Operator=$r,c.Opf=E,c.OpfEnum=G,c.Order=$,c.OrderAction=ft,c.OrderEditorData=ci,c.OrderInfo=Or,c.OrderItem=gt,c.OrderItemBase=sr,c.OrderPaymentStatus=Tt,c.OrderShortInfo=Tr,c.OrderStatus=$e,c.OrderStatusDetail=St,c.OrderStatusDetailEnum=Pt,c.OrderStatusEnum=wt,c.OrderStatusHistoryInfo=mt,c.OrdersDataProvider=ui,c.OrdersListFilters=li,c.PaginationFiltersBase=le,c.PartnerGroup=oe,c.PaymentType=kr,c.PreferencesStorageProvider=De,c.PriceAnalyze=Ke,c.PriceAnalyzeProvider=hi,c.PriceCoefficient=ee,c.PriceCoefficientEnum=er,c.PriceHistoryDataProvider=gi,c.PriceHistoryItem=at,c.PriceTemplate=F,c.PriceTemplateCategory=ze,c.PriceTemplateClient=fe,c.PriceTemplateICatalogableItem=ur,c.PriceTemplateProduct=Ye,c.PriceTemplateProvider=zt,c.PricingRole=me,c.PricingRoleProvider=jt,c.PrimaryCatalogableItem=qe,c.Product=L,c.ProductCategoryDataProvider=qt,c.ProductDataProvider=Ht,c.ProductFileType=At,c.ProductFilterTypeEnum=or,c.ProductPriceCoefficient=Ue,c.ProductPriceHistory=Ct,c.ProductUnit=tr,c.ProfstroyOfferItem=ht,c.PropertiesProvider=Yt,c.Property=se,c.PropertyType=hr,c.PropertyTypeEnum=Zr,c.PropertyValue=ne,c.RecommendationsDataProvider=fi,c.RecommendationsList=dr,c.Reference=D,c.ReferenceDataFactory=mi,c.ReferenceDataProvider=S,c.Region=te,c.ResourceType=_r,c.STANDARD_PERIOD_GROUPS=ei,c.STANDARD_PERIOD_SECTIONS=ri,c.SalesDirection=_,c.SentryConfig=Yr,c.Seo=Nr,c.SeoDataProvider=ai,c.SourcePrimaryInterest=Dr,c.StockCount=Kr,c.TableDataPagination=Et,c.TableDataPaginationRequestParams=lt,c.TableDataSortRequestParams=xt,c.TemplateProductCategoryDataProvider=Gt,c.TemplatesListFilters=_t,c.TypedInstanceFactory=I,c.UnitsHelper=Sr,c.UnknownClientDataProvider=Vt,c.UpdatableNamedIdentity=Fe,c.User=Ot,c.UserAuthDataProvider=wi,c.UserCommonInfo=pr,c.UserDataProvider=$t,c.UserPricingRole=lr,c.UserRegion=xe,c.UserRegionEmployee=Ee,c.UserRegionProvider=Di,c.UserRegionShortInfo=Ae,c.UserRegionsListFilters=vi,c.UserShortInfo=d,c.UserTypeEnum=Mr,c.VersionConfig=Jt,c.Warehouse=ue,c.WebSocketConfig=Gr,c.currentOrderInjectionKey=pi,c.daysAgoIso=Xt,c.findCatalogItemByIdRecursive=mr,c.flattenCatalogItems=yr,c.formatPercentChange=ti,c.formatRelativeDate=Zt,c.pluralize=ut,c.useAuthStateStore=Re,c.useBaseConfigStateStore=b,c.useReferencesStore=yi,c.useUserStateStore=Pi,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("jwt-decode"),require("lodash-es"),require("ts-case-convert"),require("pinia"),require("vue"),require("date-fns"),require("axios")):typeof define=="function"&&define.amd?define(["exports","jwt-decode","lodash-es","ts-case-convert","pinia","vue","date-fns","axios"],I):(c=typeof globalThis<"u"?globalThis:c||self,I(c["SC Common Lib"]={},c["jwt-decode"],c["lodash-es"],c["ts-case-convert"],c.pinia,c.vue,c["date-fns"],c.axios))})(this,function(c,I,u,Le,E,f,l,jr){"use strict";var Ai=Object.defineProperty;var bi=(c,I,u)=>I in c?Ai(c,I,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[I]=u;var i=(c,I,u)=>bi(c,typeof I!="symbol"?I+"":I,u);class X{constructor(r){i(this,"exp",0);i(this,"iat",0);i(this,"authTime",0);i(this,"jti","");i(this,"iss","");i(this,"aud",[]);i(this,"sub","");i(this,"typ","Bearer");i(this,"azp","");i(this,"sid","");i(this,"acr","");i(this,"allowedOrigins",[]);i(this,"realmAccess",{roles:[]});i(this,"resourceAccess",{});i(this,"scope","");i(this,"emailVerified",!1);i(this,"name","");i(this,"guid","");i(this,"preferredUsername","");i(this,"givenName","");i(this,"email","");u.merge(this,r)}static getJwtPayload(r){const e=I.jwtDecode(r),t=new X(Le.objectToCamel(e));return t.resourceAccess=e.resource_access,t}}class Fe extends X{constructor(e){super(e);i(this,"familyName");i(this,"middleName");i(this,"locale");i(this,"phoneNumber");i(this,"phoneNumberVerified");i(this,"address");u.merge(this,e)}static getJwtPayload(e){const t=I.jwtDecode(e),s=new Fe(Le.objectToCamel(t));return s.resourceAccess=t.resource_access,s}}class Yr{constructor(r){i(this,"phone");i(this,"tablet");i(this,"laptop");this.phone=(r==null?void 0:r.phone)??360,this.tablet=(r==null?void 0:r.tablet)??600,this.laptop=(r==null?void 0:r.laptop)??1024}}class Gr{constructor(r){i(this,"portalApiUrl");i(this,"mediaUrl");i(this,"responseDataCacheTimeout");this.portalApiUrl=(r==null?void 0:r.portalApiUrl)??"",this.mediaUrl=(r==null?void 0:r.mediaUrl)??"",this.responseDataCacheTimeout=(r==null?void 0:r.responseDataCacheTimeout)??3*60*60}}class Qr{constructor(r){i(this,"dsn");i(this,"environment");i(this,"ignoreErrors");i(this,"trace");i(this,"replay");i(this,"additionalParams");var e,t,s,o;this.dsn=(r==null?void 0:r.dsn)??"",this.environment=(r==null?void 0:r.environment)??"production",this.ignoreErrors=(r==null?void 0:r.ignoreErrors)??[/Network\s{1,3}Error/,/Request\s{1,3}aborted/,/Request\s{1,3}failed\s{1,3}with\s{1,3}status\s{1,3}code\s{1,3}(401|403|404|422)/],this.trace={allowedTargets:((e=r==null?void 0:r.trace)==null?void 0:e.allowedTargets)??[/^\//],sampleRate:((t=r==null?void 0:r.trace)==null?void 0:t.sampleRate)??0},this.replay={replaysOnErrorSampleRate:((s=r==null?void 0:r.replay)==null?void 0:s.replaysOnErrorSampleRate)??0,replaysSessionSampleRate:((o=r==null?void 0:r.replay)==null?void 0:o.replaysSessionSampleRate)??0},this.additionalParams=(r==null?void 0:r.additionalParams)??{}}}class Vr{constructor(r){i(this,"broadcaster");i(this,"key");i(this,"wsHost");i(this,"wsPort");i(this,"wssPort");i(this,"forceTLS");i(this,"enabledTransports");this.broadcaster=r.broadcaster??"reverb",this.key=r.key??"",this.wsHost=r.wsHost??"",this.wsPort=r.wsPort??8080,this.wssPort=r.wssPort??8080,this.forceTLS=r.forceTLS??!1,this.enabledTransports=r.enabledTransports??["wss"]}}class Jr{constructor(r){i(this,"environment");i(this,"devMode");i(this,"http");i(this,"deviceTypeByResolution");i(this,"sentry");i(this,"tableDefaultHeightCoefficient");i(this,"urls");i(this,"websocket");i(this,"dateFormats");var e,t,s;this.environment=(r==null?void 0:r.environment)??"production",this.devMode=(r==null?void 0:r.devMode)??{},this.http=new Gr(r==null?void 0:r.http),this.deviceTypeByResolution=new Yr(r==null?void 0:r.deviceTypeByResolution),this.sentry=new Qr({environment:this.environment,...r==null?void 0:r.sentry}),this.tableDefaultHeightCoefficient=(r==null?void 0:r.tableDefaultHeightCoefficient)??.7,this.urls=r==null?void 0:r.urls,this.websocket=r!=null&&r.websocket?new Vr(r.websocket):void 0,this.dateFormats={api:((e=r==null?void 0:r.dateFormats)==null?void 0:e.api)??"yyyy-MM-dd HH:mm:ss",uiDate:((t=r==null?void 0:r.dateFormats)==null?void 0:t.uiDate)??"dd.MM.yyyy",uiDateWithTime:((s=r==null?void 0:r.dateFormats)==null?void 0:s.uiDateWithTime)??"dd.MM.yyyy HH:mm"}}}const b=E.defineStore("common.config",()=>{const n=f.ref(new Jr);return{config:n,getConfig:()=>n.value,setConfig:t=>{n.value=u.merge(n.value,t)}}});class De{static getActualDataFromStorage(r){if(!this.isLocalStorageAvailable())return;let e=null;try{e=localStorage.getItem(r)}catch{return}if(e)try{const t=JSON.parse(e);if(!t.availableFor||l.isAfter(l.parseISO(t.availableFor)||l.startOfToday(),new Date)){if(u.isNil(t.data)||u.isEmpty(t.data))throw new Error("Data is empty");return t.data}localStorage.removeItem(r)}catch{try{localStorage.removeItem(r)}catch{}}}static saveActualDataToStorage(r,e,t){if(this.isLocalStorageAvailable())try{if(u.isNil(e)||u.isEmpty(e))throw new Error("Data is empty");const s=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,s)}catch(s){if(s instanceof DOMException&&s.code===DOMException.QUOTA_EXCEEDED_ERR){this.clearOldData();try{const o=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,o)}catch{}}else try{localStorage.removeItem(r)}catch{}}}static isLocalStorageAvailable(){try{const r="__localStorage_test__";return localStorage.setItem(r,"test"),localStorage.removeItem(r),!0}catch{return!1}}static clearOldData(){try{const r=[];for(let e=0;e<localStorage.length;e++){const t=localStorage.key(e);if(t)try{const s=localStorage.getItem(t);if(s){const o=JSON.parse(s);o.availableFor&&!l.isAfter(l.parseISO(o.availableFor)||l.startOfToday(),new Date)&&r.push(t)}}catch{r.push(t)}}r.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}catch{}}}function Kr(n){try{const r=X.getJwtPayload(n);return new Date(r.exp*1e3)}catch{return}}const ce=E.defineStore("common.auth_state_private",()=>{const n=f.ref((()=>{var g;const o=De.getActualDataFromStorage("sc.token");if(o)return Promise.resolve(o);const p=(g=b().config.devMode)==null?void 0:g.initAuthBearerToken;return p?Promise.resolve(p):void 0})()),r=f.ref(void 0),e=f.ref(void 0),t=f.markRaw(new Map);function s(){e.value=void 0,u.isNil(n.value)||n.value.then(o=>{const p=X.getJwtPayload(o);e.value=p.exp*1e3>Date.now()?u.mapValues(p.resourceAccess,g=>(g==null?void 0:g.roles)??[]):void 0}).catch(u.noop)}return{jwtToken:n,jwtTokenUpdater:r,userPermissions:e,userPermissionsComputedRefs:t,recalculateUserPermissions:s}}),Re=E.defineStore("common.auth_state",()=>{const n=f.computed(()=>{const o=ce();if(u.isNil(o.jwtToken)&&!u.isNil(o.jwtTokenUpdater)){const p=o.jwtTokenUpdater();o.jwtToken=p,p.then(g=>{o.jwtToken=Promise.resolve(g),De.saveActualDataToStorage("sc.token",g,Kr(g)),o.recalculateUserPermissions()}).catch(u.noop)}return o.jwtToken});function r(o){ce().jwtTokenUpdater=o}function e(o){const p=ce();p.jwtToken=Promise.resolve(o),De.saveActualDataToStorage("sc.token",o,Kr(o)),p.recalculateUserPermissions()}function t(){const o=ce();o.jwtToken=void 0,o.userPermissions=void 0,De.saveActualDataToStorage("sc.token",void 0)}function s(o){const p=ce();!u.isNil(p.jwtToken)&&u.isNil(p.userPermissions)&&p.jwtToken.then(a=>{const P=X.getJwtPayload(a);p.userPermissions=P.exp*1e3>Date.now()?u.mapValues(P.resourceAccess,R=>(R==null?void 0:R.roles)??[]):void 0}).catch(u.noop);const g=u.isArray(o)?o.join(" && "):o;if(p.userPermissionsComputedRefs.has(g))return p.userPermissionsComputedRefs.get(g);const m=f.computed(()=>{const a=P=>{var Pe;const R=u.split(P,".");if(R.length<2)return!1;const[ke,de]=R,ve=(Pe=ce().userPermissions)==null?void 0:Pe[ke];return u.isArray(ve)&&ve.includes(de)};return u.isArray(o)?u.every(o,P=>a(P)):a(o)});return p.userPermissionsComputedRefs.set(g,m),m}return{jwtToken:n,setJwtTokenUpdater:r,setJwtToken:e,invalidateJwtToken:t,hasUserPermission:s}});var Te=(n=>(n.Image="image",n.Video="video",n))(Te||{});class N{constructor(r,e){i(this,"id");i(this,"guid");this.id=r==null?void 0:r.id,u.isNil(this.id)&&(u.isNil(e)?typeof(r==null?void 0:r.id)=="number"?this.id=-1:typeof(r==null?void 0:r.id)=="string"&&(this.id=""):this.id=e),this.guid=(r==null?void 0:r.guid)??""}isNewRec(){return typeof this.id=="number"?this.id===-1:typeof this.id=="string"?this.id==="":u.isNil(this.id)}}class _e extends N{constructor(e){super(e,"");i(this,"mediaType");i(this,"isCover");i(this,"isUnused");i(this,"url");i(this,"urlWebp");this.mediaType=(e==null?void 0:e.mediaType)??Te.Image,this.isCover=(e==null?void 0:e.isCover)??!1,this.isUnused=(e==null?void 0:e.isUnused)??!1,this.url=(e==null?void 0:e.url)??"",this.urlWebp=e==null?void 0:e.urlWebp}isImage(){return this.mediaType===Te.Image}isVideo(){return this.mediaType===Te.Video}}var Se=(n=>(n.Draft="draft",n.Published="published",n.Scheduled="scheduled",n))(Se||{});class Z extends N{constructor(e){super(e,-1);i(this,"slug");i(this,"title");i(this,"publishedAt");i(this,"createdAt");this.slug=(e==null?void 0:e.slug)??"",this.title=(e==null?void 0:e.title)??"",this.publishedAt=Z.parseDate(e==null?void 0:e.publishedAt),this.createdAt=Z.parseDate(e==null?void 0:e.createdAt)??new Date}static resolvePublicationStatus(e){return u.isNil(e)?Se.Draft:e.getTime()>Date.now()?Se.Scheduled:Se.Published}static getSlugError(e){return e?/[^a-z0-9-]/.test(e)?"Допустимы только строчные латинские буквы, цифры и дефис: пример «kak-vybrat-podokonnik».":u.startsWith(e,"-")||u.endsWith(e,"-")?"Обозначение не может начинаться или заканчиваться дефисом.":u.includes(e,"--")?"Дефисы не могут идти подряд: разделяйте слова одним дефисом.":"":""}static parseDate(e){return u.isNil(e)?null:u.isString(e)?l.parseISO(e):e}getPublicationStatus(){return Z.resolvePublicationStatus(this.publishedAt)}}class Ne extends Z{constructor(e){super(e);i(this,"content");i(this,"media");this.content=(e==null?void 0:e.content)??"",this.media=((e==null?void 0:e.media)??[]).map(t=>new _e(t))}toSaveData(e=!1){return{title:this.title,slug:this.slug.length>0?this.slug:void 0,content:e?this.content:void 0,publishedAt:this.publishedAt}}getCover(){return this.media.find(e=>e.isCover)}getUnusedMedia(){return this.media.filter(e=>e.isUnused)}}class le{asClearRaw(){const r={};return Object.keys(this).forEach(e=>{const t=this[e];u.isNil(t)||u.isString(t)&&t.trim().length===0||u.isFunction(t.isNewRec)&&t.isNewRec()||(r[e]=t)}),r}}class T{constructor(r){i(this,"from");i(this,"to");this.from=u.isString(r==null?void 0:r.from)?l.parseISO(r.from):(r==null?void 0:r.from)??null,this.to=u.isString(r==null?void 0:r.to)?l.parseISO(r.to):(r==null?void 0:r.to)??null}}class Lt extends le{constructor(e){super();i(this,"id");i(this,"title");i(this,"slug");i(this,"content");i(this,"publicationStatus");i(this,"publishedAt");i(this,"createdAt");this.id=e==null?void 0:e.id,this.title=e==null?void 0:e.title,this.slug=e==null?void 0:e.slug,this.content=e==null?void 0:e.content,this.publicationStatus=e==null?void 0:e.publicationStatus,this.publishedAt=new T(e==null?void 0:e.publishedAt),this.createdAt=new T(e==null?void 0:e.createdAt)}resetFilterValue(e){switch(e){case"id":case"title":case"slug":case"content":case"publicationStatus":this[e]=void 0;break;case"publishedAt":this.publishedAt.from=null,this.publishedAt.to=null;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break}return this}asClearRaw(){var t,s,o,p;const e=super.asClearRaw();return!((t=e==null?void 0:e.publishedAt)!=null&&t.from)&&!((s=e==null?void 0:e.publishedAt)!=null&&s.to)&&delete e.publishedAt,!((o=e==null?void 0:e.createdAt)!=null&&o.from)&&!((p=e==null?void 0:e.createdAt)!=null&&p.to)&&delete e.createdAt,e}}var U=(n=>(n.BASE_URL_REQUEST_INTERCEPTOR="baseUrlRequestInterceptor",n.DEFAULT_REQUEST_INTERCEPTOR="defaultRequestInterceptor",n.AUTH_REQUEST_INTERCEPTOR="authRequestInterceptor",n.DATA_CONVERTER_REQUEST_INTERCEPTOR="dataConverterRequestInterceptor",n.CONVERT_HTTP_ERROR_RESPONSE_INTERCEPTOR="convertHttpErrorResponseInterceptor",n.CANCELED_RESPONSE_INTERCEPTOR="canceledResponseInterceptor",n.AUTH_ERRORS_RESPONSE_INTERCEPTOR="authErrorsResponseInterceptor",n.DATA_CONVERTER_RESPONSE_INTERCEPTOR="dataConverterResponseInterceptor",n))(U||{});class k{static simpleInstanceInitializer(r){return new r}static instanceInitializer(r,e){return new r(e)}static instanceListInitializer(r,e){if(!u.isArray(e))throw new TypeError(`Ожидался список данных для инициализации "${r.name}", получены данные типа "${typeof e}".`);return u.map(e,t=>k.instanceInitializer(r,t))}}const v=class v{constructor(){i(this,"httpClient");i(this,"baseUrl",`${b().config.http.portalApiUrl}/api`);i(this,"interceptorIds",{request:{},response:{}});i(this,"setBaseUrlRequestInterceptor",r=>(r.baseURL=this.baseUrl,r));i(this,"authRequestInterceptor",async r=>{const e=Re().jwtToken,t=u.isNil(e)?void 0:await e;return t&&r.headers.set("Authorization",`Bearer ${t}`),r});i(this,"dataConverterRequestInterceptor",r=>(r.method&&(r.method==="get"&&!u.isNil(r.params)&&(r.params=v.toSnakeCaseData(r.params)),["put","patch","post"].includes(u.toLower(r.method))&&!u.isNil(r.data)&&(r.data=v.toSnakeCaseData(r.data))),r));i(this,"authErrorsResponseInterceptors",async r=>{var t;const e=r.rawError?(t=r.rawError)==null?void 0:t.config:void 0;if(r.status===401){if(!e||e.__isRetryRequest)return Promise.reject(r);e.__isRetryRequest=!0;try{await v.isStaleUnauthorizedRequest(e)||await v.refreshAccessToken()}catch{return Promise.reject(r)}return this.httpClient(e)}return Promise.reject(r)});i(this,"canceledResponseInterceptor",r=>{const e=r.rawError??r;if(e.name==="CanceledError"||e.code==="ERR_CANCELED")throw new jr.CanceledError("Request canceled");return Promise.reject(r)});i(this,"dataConverterResponseInterceptor",r=>(r.data=v.toCamelCaseData(r.data),r));this.httpClient=jr.create({headers:{Accept:"application/json","Content-Type":"application/json"}}),this.interceptorIds.request[U.DATA_CONVERTER_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(this.dataConverterRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request[U.AUTH_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(this.authRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request[U.DEFAULT_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(r=>v.applyDefaultRequestHook(r),r=>Promise.reject(r)),this.interceptorIds.request[U.BASE_URL_REQUEST_INTERCEPTOR]=this.httpClient.interceptors.request.use(this.setBaseUrlRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.response[U.CONVERT_HTTP_ERROR_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(r=>r,r=>v.convertHttpErrorResponse(r)),this.interceptorIds.response[U.CANCELED_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(r=>r,this.canceledResponseInterceptor),this.interceptorIds.response[U.AUTH_ERRORS_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(r=>r,this.authErrorsResponseInterceptors),this.interceptorIds.response[U.DATA_CONVERTER_RESPONSE_INTERCEPTOR]=this.httpClient.interceptors.response.use(this.dataConverterResponseInterceptor,r=>Promise.reject(r))}static setDefaultErrorsResponseHandler(r){v.defaultErrorsResponseHandler=r}static setDefaultRequestHook(r){v.defaultRequestHook=r}static canConvertCaseKeys(r){return u.isObject(r)?!(r instanceof Blob||r instanceof FormData||r instanceof ArrayBuffer||u.isDate(r)||ArrayBuffer.isView(r)):!1}static toCamelCaseData(r){return v.canConvertCaseKeys(r)?Le.objectToCamel(r):r}static toSnakeCaseData(r){return v.canConvertCaseKeys(r)?Le.objectToSnake(r):r}static getRequestAccessToken(r){const e=r.headers.get("Authorization"),t=u.isString(e)?e:void 0,s="Bearer ";if(u.isNil(t)||!u.startsWith(t,s))return;const o=t.slice(s.length);return o===""?void 0:o}static async isStaleUnauthorizedRequest(r){const e=v.getRequestAccessToken(r);if(u.isNil(e))return!1;const t=Re().jwtToken;if(u.isNil(t))return!1;try{return await t!==e}catch{return!1}}static refreshAccessToken(){if(!u.isNil(v.tokenRefreshPromise))return v.tokenRefreshPromise;Re().invalidateJwtToken();const e=Re().jwtToken??Promise.resolve();return v.tokenRefreshPromise=e.finally(()=>{v.tokenRefreshPromise=void 0}),v.tokenRefreshPromise}static applyDefaultRequestHook(r){return u.isNil(v.defaultRequestHook)?r:v.defaultRequestHook(r)}static getInstance(r){return Object.prototype.hasOwnProperty.call(v.instances,r.name)||(v.instances[r.name]=k.simpleInstanceInitializer(r)),v.instances[r.name]}static toHttpResponseError(r){if(u.isObject(r)&&"status"in r)return r;const e=u.isError(r)?r.message:"Не удалось обработать данные ответа сервера.";return u.assign(new Error(e),{name:"HttpResponseError",status:0,statusText:"Invalid response data",headers:{},rawError:u.isError(r)?r:new Error(String(r))})}static convertHttpErrorResponse(r){var e,t;if(u.isNil(r)||!u.isNil(r.request)||!u.isNil(r.response)){const s=u.isNil(r)?{}:r==null?void 0:r.response;return Promise.reject(u.assign(new Error(((e=s==null?void 0:s.data)==null?void 0:e.message)??"Unknown Error. Probably network error."),{name:"HttpResponseError",status:(s==null?void 0:s.status)??0,statusText:(s==null?void 0:s.statusText)??"Unknown",errors:(t=s==null?void 0:s.data)==null?void 0:t.errors,headers:(s==null?void 0:s.headers)??{},data:s==null?void 0:s.data,rawError:r}))}return Promise.reject(r)}request(r,e=void 0,t={},s=!1){const o=this.httpClient.request(r).then(p=>e?e(p):p.data);return o.catch(p=>{(p==null?void 0:p.name)!=="CanceledError"&&v.defaultErrorsResponseHandler(v.toHttpResponseError(p),t,s)}),o}get(r,e={},t=void 0,s=!1,o=void 0){return this.request({method:"GET",url:r,params:e,signal:o},t,{},s)}getTypedList(r,e,t={},s=!1,o=void 0){return this.get(e,t,p=>k.instanceListInitializer(r,p.data),s,o)}getBlob(r,e={},t=void 0,s=!1,o=void 0){return this.request({method:"GET",url:r,params:e,responseType:"blob",signal:o},t,{},s)}patch(r,e={},t=void 0,s={},o=!1,p=void 0){return this.request({method:"PATCH",url:r,data:e,signal:p},t,s,o)}post(r,e={},t=void 0,s={},o=!1,p=void 0){return this.request({method:"POST",url:r,data:e,signal:p},t,s,o)}delete(r,e=void 0,t=!1,s=void 0){return this.request({method:"DELETE",url:r,signal:s},e,{},t)}};i(v,"instances",{}),i(v,"defaultErrorsResponseHandler",u.noop),i(v,"defaultRequestHook"),i(v,"tokenRefreshPromise");let y=v;var Ue=(n=>(n.BeginWith="bw",n.Contains="cn",n.Custom="custom",n.EndsWith="ew",n.Equals="eq",n.GreaterOrEqual="ge",n.GreaterThan="gt",n.InList="in",n.LessOrEqual="le",n.LessThan="lt",n.NotBeginWith="bn",n.NotContains="nc",n.NotEndsWith="en",n.NotEqual="ne",n.NotInList="ni",n.NotNull="nn",n.Null="nu",n))(Ue||{});class er{constructor(r){i(this,"field");i(this,"op");i(this,"value");this.field=(r==null?void 0:r.field)??"",this.op=(r==null?void 0:r.op)??Ue.Equals,this.value=(r==null?void 0:r.value)??""}toPrimitive(){const r=b().config.dateFormats.api,e={field:this.field,op:this.op};if(u.isDate(this.value))e.value=l.format(this.value,r);else if(u.isPlainObject(this.value)){const t=this.value;e.value={from:t.from?l.format(t.from,r):null,to:t.to?l.format(t.to,r):null}}else e.value=this.value;return e}}class V{constructor(r){i(this,"groupOp");i(this,"filters");i(this,"groups");var e,t;this.groupOp=(r==null?void 0:r.groupOp)??"and",this.filters=((e=r==null?void 0:r.filters)==null?void 0:e.map(s=>new er(s)))??[],this.groups=((t=r==null?void 0:r.groups)==null?void 0:t.map(s=>new V(s)))??[]}toPrimitive(){return{groupOp:this.groupOp,filters:this.filters.map(r=>r instanceof er&&u.isFunction(r.toPrimitive)?r.toPrimitive():r),groups:this.groups.map(r=>r instanceof V?r.toPrimitive():r)}}}class M extends y{getPaginated(r,e,t,s,o,p,g,m=void 0){let a={page:(s==null?void 0:s.page)??1,perPage:(s==null?void 0:s.pageSize)??10};return e&&(a.filters=JSON.stringify((e instanceof V?e:new V(e)).toPrimitive())),u.isEmpty(t)||(a.sort=u.isArray(t)?t:[t]),o&&(a={...a,...o}),this.get(r,a,p,g,m)}getTypedPaginated(r,e,t,s,o,p,g,m=void 0){return this.getPaginated(e,t,s,o,p,a=>({...a.data,data:k.instanceListInitializer(r,a.data.data)}),g,m)}}class Me extends M{static preparePostSaveData(r){const e={};if(u.isUndefined(r.title)||(e.title=r.title),u.isUndefined(r.slug)||(e.slug=r.slug),u.isUndefined(r.content)||(e.content=r.content),!u.isUndefined(r.publishedAt)){const t=b().config.dateFormats.api;e.publishedAt=u.isNil(r.publishedAt)?null:l.format(r.publishedAt,t)}return e}getPostList(r,e,t){return this.getPaginated("/internal/blog",r,e,t,{},s=>({...s.data,data:s.data.data.map(o=>new Z(o))}))}getPost(r){return this.get(`/internal/blog/${r}`,{},e=>new Ne(e.data))}createPost(r,e={}){return this.post("/internal/blog",Me.preparePostSaveData(r),t=>new Ne(t.data),e)}updatePost(r,e,t={}){return this.patch(`/internal/blog/${r}`,Me.preparePostSaveData(e),s=>new Ne(s.data),t)}removePost(r){return this.delete(`/internal/blog/${r}`)}uploadMedia(r,e,t,s,o={}){return this.request({method:"POST",url:`/internal/blog/${r}/media`,data:{file:e,isCover:t??!1},onUploadProgress:p=>{s&&s(p.total?Math.round(p.loaded/p.total*100):0)}},p=>new _e(p.data),o)}updateMedia(r,e,t,s={}){return this.patch(`/internal/blog/${r}/media/${e}`,{isCover:t},o=>new _e(o.data),s)}removeMedia(r,e){return this.delete(`/internal/blog/${r}/media/${e}`)}}class O extends N{constructor(e){super(e);i(this,"name","");this.name=(e==null?void 0:e.name)??""}nameOrGuid(){return u.isEmpty(this.name)?this.guid:this.name}}class d extends O{constructor(e){super(e);i(this,"type");i(this,"isActive");this.type=e==null?void 0:e.type,this.isActive=(e==null?void 0:e.isActive)??!0}}class xr extends O{constructor(e){super(e);i(this,"costCoefficient");i(this,"isLowPriceAllowed");i(this,"publishedAt");i(this,"description");i(this,"percent");i(this,"owner");i(this,"deletedAt");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.isLowPriceAllowed=(e==null?void 0:e.isLowPriceAllowed)??!1,this.publishedAt=u.isString(e==null?void 0:e.publishedAt)?l.parseISO(e.publishedAt):e==null?void 0:e.publishedAt,this.description=(e==null?void 0:e.description)??void 0,this.percent=(e==null?void 0:e.percent)??0,this.owner=new d(e==null?void 0:e.owner),this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class rr extends O{constructor(e){super(e);i(this,"updatedAt");this.updatedAt=u.isString(e==null?void 0:e.updatedAt)?l.parseISO(e.updatedAt):e==null?void 0:e.updatedAt}}class F extends rr{constructor(e){super(e);i(this,"description");i(this,"createdAt");i(this,"owner");this.description=(e==null?void 0:e.description)??"",this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.owner=e!=null&&e.owner?new d(e.owner):void 0}}var tr=(n=>(n.K0="k0",n.K1="k1",n.K2="k2",n.K3="k3",n.K4="k4",n.Retail="retail",n))(tr||{});class D extends O{constructor(e){super(e);i(this,"slug");i(this,"description");this.description=e==null?void 0:e.description,this.slug=e==null?void 0:e.slug}}class ee extends D{static getRetailPriceCoefficient(){const r=new ee({id:-2,slug:tr.Retail,name:"Розн. цена",guid:""});return r.isNewRec=u.constant(!0),r}}class qe{constructor(r){i(this,"coefficient");i(this,"value");i(this,"cost");i(this,"percent");i(this,"readOnly");this.coefficient=new ee(r==null?void 0:r.coefficient),this.value=(r==null?void 0:r.value)??0,this.cost=(r==null?void 0:r.cost)??0,this.percent=(r==null?void 0:r.percent)??0,this.readOnly=(r==null?void 0:r.readOnly)??!0}}class ir{constructor(r){i(this,"lat");i(this,"long");this.lat=(r==null?void 0:r.lat)??0,this.long=(r==null?void 0:r.long)??0}}class W extends D{}class ue extends D{constructor(e){var t;super(e);i(this,"address");i(this,"isMain");i(this,"deliveryTypes");i(this,"regions");i(this,"coordinates");this.address=(e==null?void 0:e.address)??"",this.isMain=(e==null?void 0:e.isMain)??!1,this.deliveryTypes=((t=e==null?void 0:e.deliveryTypes)==null?void 0:t.map(s=>new W(s)))??[],this.regions=(e==null?void 0:e.regions)??[],this.coordinates=new ir(e==null?void 0:e.coordinates)}}class Er{constructor(r){i(this,"warehouse");i(this,"count");this.warehouse=new ue(r==null?void 0:r.warehouse),this.count=(r==null?void 0:r.count)??0}}class q extends O{constructor(e){super(e);i(this,"signature","");i(this,"code");i(this,"symbol","");i(this,"precision");e&&(this.signature=e.signature??"",this.code=e.code,this.symbol=e.symbol??"",this.precision=e.precision)}}class sr extends O{constructor(e){super(e);i(this,"slug","");i(this,"description");i(this,"isSquare",!1);i(this,"isLinear",!1);e&&(this.slug=e.slug??"",this.description=e.description,this.isSquare=e.isSquare??!1,this.isLinear=e.isLinear??!1)}}class pe extends O{constructor(e){super(e);i(this,"code","");this.code=(e==null?void 0:e.code)??""}}class nr extends pe{constructor(e){super(e);i(this,"slug");i(this,"type");this.slug=(e==null?void 0:e.slug)??""}}class Xr extends nr{constructor(e){super(e);i(this,"isHidden");this.isHidden=(e==null?void 0:e.isHidden)??!1}}class Zr{constructor(r,e){i(this,"image");i(this,"preview");i(this,"isDefault");this.image=`${e??""}${r.image}`,this.preview=`${e??""}${r.preview}`,this.isDefault=r.isDefault}}class He extends nr{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=(e==null?void 0:e.isPrimary)??!1}}class L extends Xr{constructor(e){var s,o,p,g;super(e);i(this,"supplierSku");i(this,"unit");i(this,"pack");i(this,"minCount");i(this,"currency");i(this,"cost");i(this,"costRub");i(this,"costDate");i(this,"onOrder");i(this,"stockCount");i(this,"category");i(this,"categories");i(this,"images");i(this,"properties");i(this,"retailCost");i(this,"retailCostRub");i(this,"priceCoefficients");this.supplierSku=e==null?void 0:e.supplierSku,this.unit=e!=null&&e.unit?new sr(e.unit):new sr,this.pack=e==null?void 0:e.pack,this.minCount=e==null?void 0:e.minCount,this.currency=e!=null&&e.currency?new q(e.currency):new q,this.cost=(e==null?void 0:e.cost)??0,this.costRub=(e==null?void 0:e.costRub)??0,this.costDate=u.isString(e==null?void 0:e.costDate)?l.parseISO(e.costDate):e==null?void 0:e.costDate,this.onOrder=(e==null?void 0:e.onOrder)??!1,this.stockCount=((s=e==null?void 0:e.stockCount)==null?void 0:s.map(m=>new Er(m)))??[],this.type="product";const t=(e==null?void 0:e.category)??((o=e==null?void 0:e.categories)==null?void 0:o.find(m=>m.isPrimary));t&&(this.category=new He({...t,isPrimary:!0}),this.categories=[this.category]),e!=null&&e.categories&&(this.categories=e.categories.map(m=>new He(m))),this.images=((p=e==null?void 0:e.images)==null?void 0:p.map(m=>new Zr(m,b().config.http.mediaUrl)))??[],this.properties=(e==null?void 0:e.properties)??{},this.retailCost=e==null?void 0:e.retailCost,this.retailCostRub=e==null?void 0:e.retailCostRub,this.priceCoefficients=((g=e==null?void 0:e.priceCoefficients)==null?void 0:g.map(m=>new qe(m)))??[],e&&"codeNumber"in e&&!e.code&&(this.code=e==null?void 0:e.codeNumber)}getIsMeasurable(){return this.unit.isLinear||this.unit.isSquare}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}}var Be=(n=>(n.Discount="discount",n.PriceTemplate="price_template",n.ClientPrice="client_price",n.Product="product",n))(Be||{});class z extends L{constructor(e){super(e);i(this,"costCoefficient");i(this,"costSource");i(this,"discount");i(this,"priceTemplate");i(this,"isPreviouslyOrdered");i(this,"isRequired");i(this,"isFavorite");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.costSource=(e==null?void 0:e.costSource)??Be.Product,this.discount=e!=null&&e.discount?new xr(e.discount):void 0,this.priceTemplate=e!=null&&e.priceTemplate?new F(e.priceTemplate):void 0,this.isPreviouslyOrdered=e==null?void 0:e.isPreviouslyOrdered,this.isRequired=e==null?void 0:e.isRequired,this.isFavorite=e==null?void 0:e.isFavorite}}class he extends He{constructor(e){super(e);i(this,"isHidden");i(this,"parentCategoryId");i(this,"properties");i(this,"currencyRates");this.isHidden=(e==null?void 0:e.isHidden)??!1,this.parentCategoryId=e==null?void 0:e.parentCategoryId,this.properties=e==null?void 0:e.properties,this.type="category",this.currencyRates=e!=null&&e.currencyRates?Object.fromEntries(Object.entries(e.currencyRates).map(([t,s])=>[u.toUpper(t),s])):void 0}}class or extends N{constructor(e){super(e);i(this,"category");i(this,"product");i(this,"quantity");i(this,"currency");i(this,"marker");i(this,"height");i(this,"length");i(this,"width");i(this,"configurator");i(this,"configuratorParams");i(this,"isAdditionalSale");i(this,"creator");i(this,"isRemoved");i(this,"ord");i(this,"onOrder");i(this,"originalId");i(this,"replacementId");this.product=new z(e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new he,this.currency=e.currency?new q(e.currency):void 0,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&u.cloneDeep(e.configuratorParams),this.isAdditionalSale=e.isAdditionalSale,this.creator=e.creator&&new d(e.creator),this.isRemoved=e.isRemoved,this.ord=e.ord,this.onOrder=e.onOrder,this.originalId=e.originalId,this.replacementId=e.replacementId}}let cr=class extends or{constructor(e){super(e);i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,this.currency=new q(e.currency)}};class ge{constructor(r){i(this,"items");i(this,"resultSum");i(this,"directionsSum");this.items=r.items.map(e=>new cr(e)),this.resultSum=r.resultSum,this.directionsSum=r.directionsSum}}class _t extends y{getCart(r){return this.get(`internal/clients/${r.id}/cart`,{},e=>new ge(e.data))}deleteCart(r){return this.delete(`internal/clients/${r.id}/cart`)}addCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ge(s.data),t)}patchCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart/${e.id}`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ge(s.data),t)}deleteCartItem(r,e){return this.delete(`internal/clients/${r.id}/cart/${e.id}`,t=>new ge(t.data))}addCartItemFromCSV(r,e){return this.post(`internal/clients/${r.id}/cart/add-products-from-csv`,e,t=>new ge(t.data))}getCartItemFromCSVExample(r){return this.get(`internal/clients/${r.id}/cart/add-products-from-csv/example`,{},e=>new Blob([e.data],{type:"text/csv"}))}}var Fr=(n=>(n.m2Cost="m2Cost",n.percent="percent",n.value="value",n))(Fr||{}),et=(n=>(n.Unknown="unknown",n.Bool="bool",n.Integer="integer",n.Float="float",n.String="string",n.Range="range",n.Json="json",n.Object="object",n))(et||{}),lr=(n=>(n.Checkbox="checkbox",n.Range="range",n.Toggle="toggle",n))(lr||{});class j extends he{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new j(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new L(o))}}class ur{constructor(r){i(this,"phone");i(this,"email");this.phone=/^\d+$/.test(r.phone??"")?`+${r.phone}`:r.phone,this.email=r.email}}class _ extends D{}class We extends O{constructor(e){super(e);i(this,"salesDirection");i(this,"photo");i(this,"contacts");i(this,"isDefault");i(this,"isRegionalDirector");this.salesDirection=e!=null&&e.salesDirection?new _(e.salesDirection):new _,this.photo=e==null?void 0:e.photo,this.contacts=e!=null&&e.contacts?new ur(e.contacts):void 0,this.isDefault=(e==null?void 0:e.isDefault)??!1,this.isRegionalDirector=(e==null?void 0:e.isRegionalDirector)??!1}}class ze extends D{}class pr extends O{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");this.description=e.description,this.canChangeLowCost=e.canChangeLowCost,this.parentRoleId=e.parentRoleId}}class Ae extends O{constructor(e){super(e);i(this,"abbr");this.abbr=(e==null?void 0:e.abbr)??""}}class Y extends We{constructor(e){var t,s,o;super(e);i(this,"isActive");i(this,"isSupervisor");i(this,"canDoReclamations");i(this,"createdAt");i(this,"supervisorId");i(this,"pricingRole");i(this,"curatedDirections");i(this,"showAllCosts");i(this,"authAsOperator");i(this,"managerRegions");i(this,"managers");i(this,"lastLoginAt");this.isActive=(e==null?void 0:e.isActive)??!1,this.isSupervisor=(e==null?void 0:e.isSupervisor)??!1,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.supervisorId=e==null?void 0:e.supervisorId,this.pricingRole=e!=null&&e.pricingRole?new pr(e.pricingRole):void 0,this.curatedDirections=((t=e==null?void 0:e.curatedDirections)==null?void 0:t.map(p=>new ze(p)))??[],this.showAllCosts=e==null?void 0:e.showAllCosts,this.authAsOperator=e==null?void 0:e.authAsOperator,this.managerRegions=(s=e==null?void 0:e.managerRegions)==null?void 0:s.map(p=>new Ae(p)),this.managers=(o=e==null?void 0:e.managers)==null?void 0:o.map(p=>new Y(p)),this.lastLoginAt=u.isString(e==null?void 0:e.lastLoginAt)?l.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt}}class Nt extends he{constructor(e){super(e);i(this,"isDisabled");i(this,"isRequired");i(this,"isFavorite");i(this,"hidingComment");i(this,"manager");this.isDisabled=(e==null?void 0:e.isDisabled)??!1,this.isRequired=(e==null?void 0:e.isRequired)??!1,this.isFavorite=(e==null?void 0:e.isFavorite)??!1,this.hidingComment=e==null?void 0:e.hidingComment,this.manager=e!=null&&e.manager?new Y(e.manager):void 0}}class be extends Nt{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new be(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new z(o))}}class hr{constructor(r){i(this,"priceCoefficient");i(this,"increasePercent");this.priceCoefficient=(r==null?void 0:r.priceCoefficient)&&new ee(r.priceCoefficient),this.increasePercent=r==null?void 0:r.increasePercent}}class je extends hr{constructor(e){super(e);i(this,"productCategory");this.productCategory=new he(e==null?void 0:e.productCategory)}}class Ye extends O{constructor(e){super(e);i(this,"photo");i(this,"contacts");i(this,"curatedDirection");this.photo=e.photo,this.contacts=new ur(e.contacts),this.curatedDirection=new ze(e.curatedDirection)}}class re extends D{}class te extends D{constructor(e){super(e);i(this,"country",new re);e&&(this.country=new re(e.country))}}class ie extends D{constructor(e){super(e);i(this,"region",new te);e&&(this.region=new te(e.region))}}class gr extends O{constructor(e){super(e);i(this,"phone");i(this,"email");i(this,"getNews");i(this,"salesDirection");i(this,"createdAt");i(this,"lastLoginAt");i(this,"isActive");this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:(e==null?void 0:e.phone)??"",this.email=(e==null?void 0:e.email)??"",this.getNews=(e==null?void 0:e.getNews)??!1,this.salesDirection=e!=null&&e.salesDirection?new _(e.salesDirection):void 0,this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.lastLoginAt=u.isString(e==null?void 0:e.lastLoginAt)?l.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt,this.isActive=(e==null?void 0:e.isActive)??!1}}class J extends gr{constructor(e){var t,s;super(e);i(this,"salesDirection");i(this,"debt");i(this,"alternativeName");i(this,"city");i(this,"comment");i(this,"isPhoneApproved");i(this,"isEmailApproved");i(this,"managers");i(this,"curators");this.salesDirection=new _(e==null?void 0:e.salesDirection),this.debt=(e==null?void 0:e.debt)??0,this.alternativeName=(e==null?void 0:e.alternativeName)??"",this.city=new ie(e==null?void 0:e.city),this.comment=e==null?void 0:e.comment,this.isPhoneApproved=(e==null?void 0:e.isPhoneApproved)??!1,this.isEmailApproved=(e==null?void 0:e.isEmailApproved)??!1,this.managers=((t=e==null?void 0:e.managers)==null?void 0:t.map(o=>new We(o)))??[],this.curators=((s=e==null?void 0:e.curators)==null?void 0:s.map(o=>new Ye(o)))??void 0}}class fe extends N{constructor(e){super(e);i(this,"createdAt");i(this,"deletedAt");i(this,"client");i(this,"priceTemplate");this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt,this.client=new J(e==null?void 0:e.client),this.priceTemplate=new F(e==null?void 0:e.priceTemplate)}}class Ge extends hr{constructor(e){super(e);i(this,"product");this.product=new L(e==null?void 0:e.product)}}class fr extends D{}class se extends O{constructor(e){super(e);i(this,"type");i(this,"description");i(this,"metadata");i(this,"isFilterable");this.type=new fr(e==null?void 0:e.type),this.description=(e==null?void 0:e.description)??"",this.metadata=e==null?void 0:e.metadata,this.isFilterable=e==null?void 0:e.isFilterable}}class ne{constructor(r){i(this,"property");i(this,"value");this.property=new se(r==null?void 0:r.property),this.value=(r==null?void 0:r.value)??""}}class Ut{constructor(r){i(this,"id");i(this,"name");i(this,"description");i(this,"ownerName");i(this,"createdAt",new T);i(this,"updatedAt",new T);this.id=r==null?void 0:r.id,this.name=r==null?void 0:r.name,this.description=r==null?void 0:r.description,this.ownerName=r==null?void 0:r.ownerName,this.createdAt=new T(r==null?void 0:r.createdAt),this.updatedAt=new T(r==null?void 0:r.updatedAt)}resetFilterValue(r){switch(r){case"id":case"name":case"description":case"ownerName":this[r]=void 0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"updatedAt":this.updatedAt.from=null,this.updatedAt.to=null;break}return this}asClearRaw(){var e,t,s,o;const r={};return Object.keys(this).forEach(p=>{const g=this[p];u.isNil(g)||u.isString(g)&&g.trim().length===0||u.isFunction(g.isNewRec)&&g.isNewRec()||(r[p]=g)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((t=r==null?void 0:r.createdAt)!=null&&t.to)&&delete r.createdAt,!((s=r==null?void 0:r.updatedAt)!=null&&s.from)&&!((o=r==null?void 0:r.updatedAt)!=null&&o.to)&&delete r.updatedAt,r}}class me extends O{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");i(this,"subRoles",[]);i(this,"parentRole");i(this,"level",0);this.description=e==null?void 0:e.description,this.canChangeLowCost=(e==null?void 0:e.canChangeLowCost)??!1,this.parentRoleId=e==null?void 0:e.parentRoleId}}class mr{constructor(r){i(this,"role");i(this,"category");i(this,"minCoefficient");this.role=new me(r==null?void 0:r.role),this.category=new he(r==null?void 0:r.category),this.minCoefficient=new ee(r==null?void 0:r.minCoefficient)}}class rt{constructor(r){i(this,"isFake");i(this,"isHidden");i(this,"isMultiple");i(this,"type");i(this,"ord");this.isFake=(r==null?void 0:r.isFake)??!1,this.isHidden=(r==null?void 0:r.isHidden)??!1,this.isMultiple=(r==null?void 0:r.isMultiple)??null,this.type=(r==null?void 0:r.type)??null,this.ord=(r==null?void 0:r.ord)??0}}class yr{constructor(r){i(this,"category");i(this,"property");i(this,"settings");this.category=new he(r==null?void 0:r.category),this.property=new se(r==null?void 0:r.property),this.settings=new rt(r==null?void 0:r.settings)}}class tt{constructor(r){i(this,"id");i(this,"label");this.id=(r==null?void 0:r.id)??"",this.label=(r==null?void 0:r.label)??""}}class it{constructor(r){i(this,"id");i(this,"label");i(this,"type");i(this,"ord");i(this,"isMultiple");i(this,"values");i(this,"min");i(this,"max");var e;this.id=(r==null?void 0:r.id)??"",this.label=(r==null?void 0:r.label)??"",this.type=(r==null?void 0:r.type)??lr.Checkbox,this.ord=(r==null?void 0:r.ord)??0,this.isMultiple=(r==null?void 0:r.isMultiple)??null,this.values=((e=r==null?void 0:r.values)==null?void 0:e.map(t=>new tt(t)))??[],this.min=(r==null?void 0:r.min)??null,this.max=(r==null?void 0:r.max)??null}}class Mt extends y{search(r,e=!1){return this.get("/internal/catalog/search",{term:r,show_hidden:e})}getPriceExportLink(r="csv",e=!1,t=void 0,s=void 0){let p=`${b().config.http.portalApiUrl}/api/internal/price/export?format=${r}&show_hidden=${e}`;return t&&(p+=`&category_id=${t}`),s&&(p+=`&client_id=${s}`),p}}class qt extends y{importPrices(r,e){return this.post(`/internal/clients/${r}/price/import`,e)}updateCategoryPrices(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/categories/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value})}removeCategoryPrices(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}`)}markCategoryRequired(r,e){return this.post(`/internal/clients/${r}/price/categories/${e}/required`)}unmarkCategoryRequired(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/required`)}markCategoryDisabled(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/disabled`,{comment:t})}unmarkCategoryDisabled(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/disabled`)}addCategoryManager(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/manager`,{manager_id:t})}removeCategoryManager(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/manager`)}updateProductPrice(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new z(o.data))}removeProductPrice(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}`,t=>new z(t.data))}markProductRequired(r,e){return this.post(`/internal/clients/${r}/price/products/${e}/required`)}unmarkProductRequired(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}/required`)}getCommercialOfferHtml(r,e){return this.get(`/internal/clients/${r}/price/commercial-offer/view`,e,t=>new Blob([t.data],{type:"text/html"}))}getCommercialOfferPdf(r,e){return this.getBlob(`/internal/clients/${r}/price/commercial-offer/download`,e,t=>new Blob([t.request.response],{type:"application/pdf"}))}sendCommercialOffer(r,e){return this.post(`/internal/clients/${r}/price/commercial-offer/send`,e)}}class Ht extends y{getTemplateList(r){return this.getTypedList(fe,`/internal/clients/${r}/price/templates`)}getActiveTemplate(r){return this.get(`/internal/clients/${r}/price/templates/active`,{},e=>new fe(e.data),!0)}attachTemplate(r,e,t){const s=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/price/templates/${e}`,t&&{startAt:t.startAt&&l.format(t.startAt,s),endAt:t.endAt&&l.format(t.endAt,s)},o=>new fe(o.data),{},!0)}applyTemplate(r,e){return this.post(`/internal/clients/${r}/price/templates/${e}/apply`,{},void 0,{},!0)}changeTemplate(r,e,t,s){const o=b().config.dateFormats.api;return this.patch(`/internal/clients/${r}/price/templates/${e}/${t}`,s&&{startAt:s.startAt&&l.format(s.startAt,o),endAt:s.endAt&&l.format(s.endAt,o)},p=>new fe(p.data))}detachTemplate(r,e,t){return this.delete(`/internal/clients/${r}/price/templates/${e}/${t}`)}}class Bt extends y{getRootCategoriesList(r=!1){return this.getTypedList(j,"/internal/catalog/categories",{showHidden:r})}getCategoryData(r,e=!1,t=!1){return this.get(`/internal/catalog/categories/${r}`,{showHidden:e,withNestedCategories:t},s=>new j(s.data))}getPublicCategoryData(r){return this.get(`/public/catalog/categories/${r}`,{},e=>new j(e.data))}getCategoryProductsList(r,e=!0,t=!1){return this.get(`/internal/catalog/categories/${r}/products`,{showHidden:t,withPriceCoefficients:e},s=>u.map(s.data,o=>new L(o)))}getCategoryProductsCoefficients(r){return this.get(`/internal/catalog/categories/${r}/products/coefficients`,{},e=>{const{data:t}=e;return u.forEach(t,s=>s.map(o=>new qe(o))),t})}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.categories.map(p=>new j(p)))}).catch(o=>{s(o)})})}}class Wt extends M{getProductData(r,e=!1){return this.get(`/internal/catalog/products/${r}`,{withPriceCoefficients:e},t=>new L(t.data))}getPublicProductData(r){return this.get(`/public/catalog/products/${r}`,{},e=>new L(e.data))}getProductPriceCoefficients(r){return this.get(`/internal/catalog/products/${r}/coefficients`,{},e=>u.map(e.data,t=>new qe(t)))}getNewProducts(r,e,t=!0){const s=b().config.dateFormats.api;return this.getTypedPaginated(L,"/internal/catalog/products/new",void 0,void 0,e,{period:{from:l.format(r,s)},withPriceCoefficients:t})}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.products.map(p=>new L(p)))}).catch(o=>{s(o)})})}}class zt extends y{getRootCategoriesList(r,e=!1){return this.getTypedList(be,"/internal/catalog/categories",{clientId:r,showHidden:e})}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{clientId:r,showHidden:t,withNestedCategories:s},o=>new be(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{client_id:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,p=>new z(p)))}}class jt extends M{getProductData(r,e,t=!1){return this.get(`/internal/catalog/products/${r}`,{clientId:e,withPriceCoefficients:t},s=>new z(s.data))}getNewProducts(r,e,t,s=!0){const o=b().config.dateFormats.api;return this.getTypedPaginated(z,"/internal/catalog/products/new",void 0,void 0,t,{clientId:r,period:{from:l.format(e,o)},withPriceCoefficients:s})}}class Yt extends M{getTemplateList(r,e,t){return this.getTypedPaginated(F,"/internal/price/templates",r,e,t)}createTemplate(r,e={}){return this.post("/internal/price/templates",r,t=>new F(t.data),e)}getTemplate(r){return this.get(`/internal/price/templates/${r}`,{},e=>new F(e.data))}updateTemplate(r,e,t={}){return this.patch(`/internal/price/templates/${r}`,e,s=>new F(s.data),t)}removeTemplate(r){return this.delete(`/internal/price/templates/${r}`)}getProductTemplatePrices(r){return this.getTypedList(Ge,`/internal/price/templates/${r}/products`)}getProductTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/products/${e}`,{},t=>new Ge(t.data))}saveProductTemplatePrice(r,e,t){var s;return this.post(`/internal/price/templates/${r}/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new Ge(o.data))}deleteProductTemplatePrice(r,e){return this.delete(`/internal/price/templates/${r}/products/${e}`)}getCategoryTemplatePrices(r){return this.getTypedList(je,`/internal/price/templates/${r}/categories`)}getCategoryTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/categories/${e}`,{},t=>new je(t.data))}saveCategoryTemplatePrice(r,e,t,s=!1){var o;return this.request({method:"POST",url:`/internal/price/templates/${r}/categories/${e}`,data:{price_coefficient_id:(o=t.coefficient)==null?void 0:o.id,increase_percent:t.value},params:s?{recursively:!0}:{}},p=>new je(p.data))}deleteCategoryTemplatePrice(r,e,t=!1){return this.request({method:"DELETE",url:`/internal/price/templates/${r}/categories/${e}`,params:t?{recursively:!0}:{}})}getTemplateClients(r){return this.getTypedList(fe,`/internal/price/templates/${r}/clients`)}}class Gt extends y{getRoles(){return this.getTypedList(me,"/internal/price/roles")}createRole(r){return this.post("/internal/price/roles",r,e=>new me(e.data))}getRole(r){return this.get(`/internal/price/roles/${r}`,{},e=>new me(e.data))}updateRole(r,e){return this.patch(`/internal/price/roles/${r}`,e,t=>new me(t.data))}deleteRole(r){return this.delete(`/internal/price/roles/${r}`)}getCategoryRules(r){return this.getTypedList(mr,`/internal/price/roles/rules/categories/${r}`)}updateCategoryRules(r,e){return this.patch(`/internal/price/roles/rules/categories/${r}`,e,t=>k.instanceListInitializer(mr,t.data))}}class Qt extends M{getProperties(r,e,t){return this.getTypedPaginated(se,"/internal/catalog/properties",r,e,t)}createProperty(r){const{typeId:e,...t}=r;return this.post("/internal/catalog/properties",{...t,type:e},s=>new se(s.data))}getProperty(r){return this.get(`/internal/catalog/properties/${r}`,{},e=>new se(e.data))}updateProperty(r,e){const{typeId:t,...s}=e;return this.patch(`/internal/catalog/properties/${r}`,{...s,type:t},o=>new se(o.data))}deleteProperty(r){return this.delete(`/internal/catalog/properties/${r}`)}getProductProperties(r){return this.getTypedList(ne,`/internal/catalog/products/${r}/properties`)}getProductProperty(r,e){return this.get(`/internal/catalog/products/${r}/properties/${e}`,{},t=>new ne(t.data))}updateProductProperty(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/${e}`,{value:t},s=>new ne(s.data))}deleteProductProperty(r,e){return this.delete(`/internal/catalog/products/${r}/properties/${e}`)}getProductDescription(r){return this.get(`/internal/catalog/products/${r}/properties/description`)}updateProductDescription(r,e){return this.patch(`/internal/catalog/products/${r}/properties/description`,{text:e})}deleteProductDescription(r){return this.delete(`/internal/catalog/products/${r}/properties/description`)}getProductSpecification(r){return this.get(`/internal/catalog/products/${r}/properties/specification`)}updateProductSpecification(r,e){return this.patch(`/internal/catalog/products/${r}/properties/specification`,{text:e})}deleteProductSpecification(r){return this.delete(`/internal/catalog/products/${r}/properties/specification`)}getProductFiles(r){return this.get(`/internal/catalog/products/${r}/properties/files`)}addProductFile(r,e){return this.post(`/internal/catalog/products/${r}/properties/files`,e)}updateProductFile(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/files/${e}`,t)}deleteProductFile(r,e){return this.delete(`/internal/catalog/products/${r}/properties/files/${e}`)}updateProductSlug(r,e){return this.patch(`/internal/catalog/products/${r}/properties/slug`,{slug:e})}getCategoryProperties(r){return this.getTypedList(ne,`/internal/catalog/categories/${r}/properties`)}getCategoryProperty(r,e){return this.get(`/internal/catalog/categories/${r}/properties/${e}`,{},t=>new ne(t.data))}updateCategoryProperty(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/${e}`,{value:t},s=>new ne(s.data))}deleteCategoryProperty(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/${e}`)}getCategoryDescription(r){return this.get(`/internal/catalog/categories/${r}/properties/description`)}updateCategoryDescription(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/description`,{text:e})}deleteCategoryDescription(r){return this.delete(`/internal/catalog/categories/${r}/properties/description`)}getCategorySpecification(r){return this.get(`/internal/catalog/categories/${r}/properties/specification`)}updateCategorySpecification(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/specification`,{text:e})}deleteCategorySpecification(r){return this.delete(`/internal/catalog/categories/${r}/properties/specification`)}getCategoryFiles(r){return this.get(`/internal/catalog/categories/${r}/properties/files`)}addCategoryFile(r,e){return this.post(`/internal/catalog/categories/${r}/properties/files`,e)}updateCategoryFile(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/files/${e}`,t)}deleteCategoryFile(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/files/${e}`)}updateCategorySlug(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/slug`,{slug:e})}updateCategoryImage(r,e){return this.post(`/internal/catalog/categories/${r}/image`,{image:e})}getCategoryFilters(r,e=!1){return this.get(`/internal/catalog/categories/${r}/filters`,{recursively:e},t=>t.data.map(s=>new it(s)))}getCategoryFilterSettings(r){return this.getTypedList(yr,`/internal/catalog/categories/${r}/filter-settings`)}saveCategoryFilterSetting(r,e,t){return this.patch(`/internal/catalog/categories/${r}/filter-settings/${e}`,t,s=>new yr(s.data))}deleteCategoryFilterSetting(r,e){return this.delete(`/internal/catalog/categories/${r}/filter-settings/${e}`)}}class Vt extends y{getRootCategoriesList(r,e=!1){return this.getTypedList(j,"/internal/catalog/categories",{priceTemplateId:r,showHidden:e})}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{priceTemplateId:r,showHidden:t,withNestedCategories:s},o=>new j(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{priceTemplateId:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,p=>new L(p)))}}function ar(n,r,e){let t;return n.some(s=>{if(s.type===e&&s.id===r)return t=s,!0;if(s.type==="product")return!1;const o=s;if(o.products&&o.products.length>0){const p=ar(o.products,r,e);if(p)return t=p,!0}if(o.categories&&o.categories.length>0){const p=ar(o.categories,r,e);if(p)return t=p,!0}return!1}),t}function Cr(n){const r=[];return n.forEach(e=>{if(r.push(e),e.type==="category"){const t=e;t.products&&t.products.length>0&&r.push(...Cr(t.products)),t.categories&&t.categories.length>0&&r.push(...Cr(t.categories))}}),r}var st=(n=>(n.LastOrder="last_order",n.Contacts="contacts",n.PartnerGroups="partner_groups",n.PreferredDeliveryType="preferred_delivery_type",n.SalesDirection="sales_direction",n.Managers="managers",n.Curators="curators",n))(st||{}),G=(n=>(n.Person="individual",n.Ic="entrepreneur",n.UlR="legal",n.UlNr="non_resident_legal",n))(G||{});class Qe extends N{constructor(e){super(e);i(this,"bankName","");i(this,"bic","");i(this,"accountNumber","");i(this,"correspondentAccount","");i(this,"currency",new q);e&&(this.bankName=e.bankName??"",this.bic=e.bic??"",this.accountNumber=e.accountNumber??"",this.correspondentAccount=e.correspondentAccount??"",this.currency=new q(e.currency))}}class Ve extends O{constructor(e){super(e);i(this,"phone");i(this,"email");this.email=e==null?void 0:e.email,this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:e==null?void 0:e.phone}}class K extends Ve{constructor(e){super(e);i(this,"isPrimary");i(this,"position");i(this,"notDisturb");i(this,"comment");i(this,"updatedAt");i(this,"deletedAt");this.isPrimary=(e==null?void 0:e.isPrimary)??!1,this.position=e==null?void 0:e.position,this.notDisturb=(e==null?void 0:e.notDisturb)??!1,this.comment=e==null?void 0:e.comment,this.updatedAt=e==null?void 0:e.updatedAt,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class x extends D{static generatePersonItem(){return new x({id:1,guid:"",slug:G.Person,name:""})}}class oe extends D{}class wr extends rr{constructor(e){super(e);i(this,"deletedAt");this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?l.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class vr extends wr{constructor(e){super(e);i(this,"opf",x.generatePersonItem());i(this,"partnerGroup",new oe);i(this,"contacts",[]);i(this,"bankAccounts",[]);i(this,"comment");i(this,"alternativeName");i(this,"createdAt");i(this,"creator");i(this,"updater");if(e){if(this.opf=new x(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):e.createdAt,this.creator=e.creator?new d(e.creator):void 0,this.updater=e.updater?new d(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new oe(e.partnerGroup)),e.contacts){const t=[];e.contacts.forEach(s=>{t.push(new K(s))}),this.contacts=t}if(e.bankAccounts){const t=[];e.bankAccounts.forEach(s=>{t.push(new Qe(s))}),this.bankAccounts=t}}}}class nt extends vr{constructor(r){super(r)}}class Pr extends vr{constructor(e){super(e);i(this,"inn","");i(this,"okpo","");i(this,"ogrn","");i(this,"directorName","");i(this,"directorPosition","");i(this,"directorActsOn","");i(this,"legalAddress","");i(this,"postalAddress","");i(this,"actualAddress","");e&&(this.inn=e.inn??"",this.okpo=e.okpo??"",this.ogrn=e.ogrn??"",this.directorName=e.directorName??"",this.directorPosition=e.directorPosition??"",this.directorActsOn=e.directorActsOn??"",this.legalAddress=e.legalAddress??"",this.postalAddress=e.postalAddress??"",this.actualAddress=e.actualAddress??"")}}class Dr extends Pr{constructor(e){super(e);i(this,"kpp","");e&&(this.kpp=e.kpp??"")}}class ot extends Dr{constructor(e){super(e);i(this,"registrationCountry",new re);i(this,"registrationNumber","");i(this,"taxNumber","");e&&(this.registrationCountry=new re(e.registrationCountry),this.registrationNumber=e.registrationNumber??"",this.taxNumber=e.taxNumber??"")}}class Oe{static createInstance(r){switch(r.opf.slug){case G.Ic:return new Pr(r);case G.UlR:return new Dr(r);case G.UlNr:return new ot(r);default:return new nt(r)}}}class ye extends wr{constructor(e){var t;super(e);i(this,"address","");i(this,"coordinates");i(this,"contacts");i(this,"comment");i(this,"operatingHours");i(this,"isOneTime");i(this,"isTransportCompanyAddress");this.address=(e==null?void 0:e.address)??"",this.coordinates=new ir(e==null?void 0:e.coordinates),this.contacts=((t=e==null?void 0:e.contacts)==null?void 0:t.map(s=>new K(s)))??[],this.comment=e==null?void 0:e.comment,this.operatingHours=e==null?void 0:e.operatingHours,this.isOneTime=e==null?void 0:e.isOneTime,this.isTransportCompanyAddress=e==null?void 0:e.isTransportCompanyAddress}}class Rr extends D{}class Tr extends D{}class Sr extends J{constructor(e){var t,s,o,p;super(e);i(this,"contragents");i(this,"partnerGroups");i(this,"contacts");i(this,"deliveryAddresses");i(this,"channelPrimaryInterest");i(this,"sourcePrimaryInterest");i(this,"preferredDeliveryType");i(this,"primaryDemand");i(this,"preferredWarehouse");i(this,"extraData");this.contragents=((t=e==null?void 0:e.contragents)==null?void 0:t.map(g=>Oe.createInstance(g)))??[],this.partnerGroups=((s=e==null?void 0:e.partnerGroups)==null?void 0:s.map(g=>new oe(g)))??[],this.contacts=((o=e==null?void 0:e.contacts)==null?void 0:o.map(g=>new K(g)))??[],this.deliveryAddresses=((p=e==null?void 0:e.deliveryAddresses)==null?void 0:p.map(g=>new ye(g)))??[],this.channelPrimaryInterest=new Rr(e==null?void 0:e.channelPrimaryInterest),this.sourcePrimaryInterest=new Tr(e==null?void 0:e.sourcePrimaryInterest),this.preferredDeliveryType=new W(e==null?void 0:e.preferredDeliveryType),this.primaryDemand=e==null?void 0:e.primaryDemand,this.preferredWarehouse=e!=null&&e.preferredWarehouse?new ue(e.preferredWarehouse):void 0,this.extraData=(e==null?void 0:e.extraData)??{}}}class Jt extends le{constructor(e){var t,s,o,p,g,m,a,P;super();i(this,"id");i(this,"guid");i(this,"name");i(this,"alternativeName");i(this,"searchTerm");i(this,"cities");i(this,"region");i(this,"country");i(this,"phone");i(this,"email");i(this,"isActive");i(this,"createdAt",new T);i(this,"lastLoginDate",new T);i(this,"lastLoginDateHasOrder");i(this,"managers");i(this,"includeSubordinateManagers");i(this,"curators");i(this,"isManagerRequired");i(this,"salesDirections");i(this,"contragentInn");i(this,"contragentType");i(this,"preferredDeliveryType");i(this,"partnerGroups");i(this,"contact");i(this,"lastOrder");i(this,"noOrdersPeriod",new T);this.id=e==null?void 0:e.id,this.guid=e==null?void 0:e.guid,this.name=e==null?void 0:e.name,this.alternativeName=e==null?void 0:e.alternativeName,this.searchTerm=e==null?void 0:e.searchTerm,this.cities=(t=e==null?void 0:e.cities)==null?void 0:t.map(R=>new ie(R)),this.region=new te(e==null?void 0:e.region),this.country=new re(e==null?void 0:e.country),this.phone=e==null?void 0:e.phone,this.email=e==null?void 0:e.email,this.isActive=e&&Object.prototype.hasOwnProperty.call(e,"isActive")?e==null?void 0:e.isActive:!0,this.createdAt=new T(e==null?void 0:e.createdAt),this.lastLoginDate=new T(e==null?void 0:e.lastLoginDate),this.lastLoginDateHasOrder=(e==null?void 0:e.lastLoginDateHasOrder)??void 0,this.managers=((s=e==null?void 0:e.managers)==null?void 0:s.map(R=>new Y(R)))??[],this.includeSubordinateManagers=(e==null?void 0:e.includeSubordinateManagers)??!0,this.curators=((o=e==null?void 0:e.curators)==null?void 0:o.map(R=>new Ye(R)))??[],this.salesDirections=(p=e==null?void 0:e.salesDirections)==null?void 0:p.map(R=>new _(R)),this.contragentInn=e==null?void 0:e.contragentInn,this.contragentType=new x(e==null?void 0:e.contragentType),this.preferredDeliveryType=e!=null&&e.preferredDeliveryType?new W(e==null?void 0:e.preferredDeliveryType):void 0,this.partnerGroups=(g=e==null?void 0:e.partnerGroups)==null?void 0:g.map(R=>new oe(R)),this.contact=new Ve(e==null?void 0:e.contact),this.lastOrder={createdAt:new T((m=e==null?void 0:e.lastOrder)==null?void 0:m.createdAt),creator:(a=e==null?void 0:e.lastOrder)==null?void 0:a.creator,isApproved:(P=e==null?void 0:e.lastOrder)==null?void 0:P.isApproved},this.noOrdersPeriod=new T(e==null?void 0:e.noOrdersPeriod)}resetFilterValue(e){switch(e){case"cities":this.cities=[];break;case"region":this.region=new te;break;case"isActive":this.isActive=!0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"lastLoginDate":this.lastLoginDate.from=null,this.lastLoginDate.to=null;break;case"noOrdersPeriod":this.noOrdersPeriod.from=null,this.noOrdersPeriod.to=null;break;case"lastOrder":this.lastOrder={};break;case"managers":this.managers=[];break;case"curators":this.curators=[];break;case"salesDirections":this.salesDirections=[];break;case"contragentType":this.contragentType=new x;break;case"preferredDeliveryType":this.preferredDeliveryType=new W;break;case"partnerGroups":this.partnerGroups=[];break;case"contact":this.contact=new Ve;break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,p,g,m;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.lastLoginDate)!=null&&o.from)&&!((p=e==null?void 0:e.lastLoginDate)!=null&&p.to)&&delete e.lastLoginDate,!((g=e==null?void 0:e.noOrdersPeriod)!=null&&g.from)&&!((m=e==null?void 0:e.noOrdersPeriod)!=null&&m.to)&&delete e.noOrdersPeriod,e}}class Ar extends N{constructor(e){super(e);i(this,"createdAt");i(this,"creator");this.createdAt=u.isString(e==null?void 0:e.createdAt)?l.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.creator=new d(e==null?void 0:e.creator)}}class ct extends O{constructor(e){var t,s,o,p;super(e);i(this,"contacts",[]);i(this,"preferredDeliveryType");i(this,"partnerGroups",[]);i(this,"lastOrder");i(this,"salesDirection");i(this,"managers");i(this,"curators");this.contacts=((t=e.contacts)==null?void 0:t.map(g=>new K(g)))??void 0,this.lastOrder=e.lastOrder?new Ar(e.lastOrder):void 0,this.partnerGroups=((s=e.partnerGroups)==null?void 0:s.map(g=>new oe(g)))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new W(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new _(e.salesDirection):void 0,this.managers=((o=e.managers)==null?void 0:o.map(g=>new We(g)))??void 0,this.curators=((p=e.curators)==null?void 0:p.map(g=>new Ye(g)))??void 0}}class Je extends N{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=e.isPrimary}}class lt extends K{constructor(e){super(e);i(this,"relations",{clients:[],contragents:[],addresses:[]});e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(t=>new Je(t))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(t=>new Je(t))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(t=>new Je(t))))}}class H extends M{static transformClientDataToRequest(r){var t;return{name:r.name,alternative_name:r.alternativeName,partner_groups:r.partnerGroups.map(s=>s.id),phone:r.phone,email:r.email,city_id:r.city.id,get_news:r.getNews,channel_primary_interest_id:r.channelPrimaryInterest.id,source_primary_interest_id:r.sourcePrimaryInterest.id,primary_demand:r.primaryDemand,preferred_warehouse_id:(t=r.preferredWarehouse)==null?void 0:t.id}}static transformContragentClientDataToRequest(r){var p,g,m,a;let e;const t=r,s=r,o=r;switch(r.opf.slug){case G.Ic:e={opf:t.opf.slug,name:t.name,alternative_name:t.alternativeName,partner_group_id:(p=t.partnerGroup)==null?void 0:p.id,comment:t.comment,inn:t.inn,okpo:t.okpo,ogrn:t.ogrn||void 0,director_name:t.directorName,director_position:t.directorPosition,director_acts_on:t.directorActsOn,legal_address:t.legalAddress,postal_address:t.postalAddress,actual_address:t.actualAddress};break;case G.UlR:e={opf:s.opf.slug,name:s.name,alternative_name:s.alternativeName,partner_group_id:(g=s.partnerGroup)==null?void 0:g.id,comment:s.comment,inn:s.inn,kpp:s.kpp,okpo:s.okpo,ogrn:s.ogrn||void 0,director_name:s.directorName,director_position:s.directorPosition,director_acts_on:s.directorActsOn,legal_address:s.legalAddress,postal_address:s.postalAddress,actual_address:s.actualAddress};break;case G.UlNr:e={opf:o.opf.slug,name:o.name,alternative_name:o.alternativeName,partner_group_id:(m=o.partnerGroup)==null?void 0:m.id,comment:o.comment,director_name:o.directorName,director_position:o.directorPosition,director_acts_on:o.directorActsOn,legal_address:o.legalAddress,postal_address:o.postalAddress,actual_address:o.actualAddress,registration_country_id:o.registrationCountry.id,registration_number:o.registrationNumber,tax_number:o.taxNumber||void 0};break;default:e={opf:r.opf.slug,name:r.name,alternative_name:r.alternativeName,partner_group_id:(a=r.partnerGroup)==null?void 0:a.id,comment:r.comment};break}return e}static transformClientDeliveryAddressToRequest(r){var t,s;const e={address:r.address,is_one_time:r.isOneTime??!1,is_transport_company_address:r.isTransportCompanyAddress??!1,comment:r.comment??""};return r.coordinates&&(e.coordinates={lat:(t=r.coordinates)==null?void 0:t.lat,long:(s=r.coordinates)==null?void 0:s.long}),r.operatingHours&&(e.operating_hours={from:r.operatingHours.from,to:r.operatingHours.to}),e}static transformClientContragentBankAccountToRequest(r){return{bank_name:r.bankName,bic:r.bic,account_number:r.accountNumber,correspondent_account:r.correspondentAccount,currency_id:r.currency.id}}getClient(r){return this.get(`/internal/clients/${r}`,{},e=>new Sr(e.data))}getClientsList(r,e,t,s,o=void 0){return this.getTypedPaginated(J,"/internal/clients",r,e,t,s,void 0,o)}searchClient(r){return this.getClientsList(void 0,void 0,void 0,{searchTerm:r}).then(e=>e.data)}getClientByPhone(r){return this.getClientsList({groupOp:"and",groups:[],filters:[{field:"phone",op:Ue.Contains,value:r}]})}getAdditionalClientsData(r,e){const t=r.map(s=>s.id);return this.post("/internal/clients/additional-data",{clients:t,requested_data_types:e},s=>k.instanceListInitializer(ct,s.data))}getAllClientContacts(r){return this.getTypedList(lt,`/internal/clients/${r}/contacts/all`)}createClientCommonData(r,e={}){return this.post("/internal/clients",H.transformClientDataToRequest(r),t=>new Sr(t.data),e)}updateClientCommonData(r,e={}){return this.patch(`/internal/clients/${r.id}`,H.transformClientDataToRequest(r),void 0,e)}updateClientNotDistribCommonData(r,e={}){const t={get_news:r.getNews};return this.patch(`/internal/clients/${r.id}`,t,void 0,e)}changeClientPassword(r,e,t,s={}){return this.patch(`/internal/clients/${r}`,{password:e,password_confirmation:t},void 0,s)}updateClientComment(r){return this.patch(`/internal/clients/${r.id}`,{comment:r.comment})}changeClientActivation(r){return this.patch(`/internal/clients/${r.id}`,{is_active:r.isActive})}async attachClientToManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/attach`,{is_primary:s.isDefault}));await Promise.all(t)}async detachClientFromManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/detach`));await Promise.all(t)}attachToCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/attach`,{curated_direction_id:t.id})}detachFromCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/detach`,{curated_direction_id:t.id})}setCurators(r,e){return this.patch(`/internal/clients/${r}/curators`,{curators:e.map(t=>({curator_id:t.curatorId,curated_direction_id:t.curatedDirection.id}))})}createContragentClientData(r,e,t={}){return this.post(`/internal/clients/${r}/contragents`,H.transformContragentClientDataToRequest(e),s=>Oe.createInstance(s.data),t)}updateContragentClientData(r,e,t={}){return this.patch(`/internal/clients/${r}/contragents/${e.id}`,H.transformContragentClientDataToRequest(e),s=>Oe.createInstance(s.data),t)}deleteClientContragent(r,e){return this.delete(`/internal/clients/${r}/contragents/${e.id}`)}getClientDeliveryAddresses(r){return this.getTypedList(ye,`/internal/clients/${r}/delivery-addresses`)}createClientDeliveryAddress(r,e,t={}){return this.post(`/internal/clients/${r}/delivery-addresses`,H.transformClientDeliveryAddressToRequest(e),s=>new ye(s.data),t)}updateClientDeliveryAddress(r,e,t={}){return this.patch(`/internal/clients/${r}/delivery-addresses/${e.id}`,H.transformClientDeliveryAddressToRequest(e),s=>new ye(s.data),t)}deleteClientDeliveryAddress(r,e){return this.delete(`/internal/clients/${r}/delivery-addresses/${e.id}`)}createContragentBankAccount(r,e,t,s={}){return this.post(`/internal/clients/${r}/contragents/${e}/bank-accounts`,H.transformClientContragentBankAccountToRequest(t),o=>new Qe(o.data),s)}updateContragentBankAccount(r,e,t,s={}){return this.patch(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`,H.transformClientContragentBankAccountToRequest(t),o=>new Qe(o.data),s)}deleteContragentBankAccount(r,e,t){return this.delete(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`)}createClientContact(r,e,t={}){return this.createContact(r,e,{client:{id:r,is_primary:e.isPrimary??!1,not_disturb:e.notDisturb??!1}},t)}updateClientContact(r,e,t={}){return this.patch(`/internal/clients/${r}/contacts/${e.id}`,{name:e.name,position:e.position,phone:e.phone,email:e.email,comment:e.comment,not_disturb:e.notDisturb},s=>new K(s.data),t)}setPrimaryClientContact(r,e){return this.setPrimaryContact(`/internal/clients/${r}/contacts/${e.id}/primary`,e.isPrimary??!1)}detachClientContact(r,e){return this.detachContact(`/internal/clients/${r}/contacts/${e.id}/detach`)}createContragentContact(r,e,t,s={}){return this.createContact(r,t,{contragents:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryContragentContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachContragentContact(r,e,t){return this.detachContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/detach`)}createDeliveryAddressContact(r,e,t,s={}){return this.createContact(r,t,{addresses:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryDeliveryAddressContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachDeliveryAddressContact(r,e,t){return this.detachContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/detach`)}createContact(r,e,t,s={}){var p,g;const o={name:e.name,position:e.position,comment:e.comment,...t};return(p=e.phone)!=null&&p.length&&(o.phone=e.phone),(g=e.email)!=null&&g.length&&(o.email=e.email),this.post(`/internal/clients/${r}/contacts`,o,m=>new K(m.data),s)}setPrimaryContact(r,e){return this.patch(r,{is_primary:e})}detachContact(r){return this.patch(r)}sendClientEmailConfirmation(r){return this.get(`/internal/clients/${r.id}/verification/email?email=${r.email}`)}}class Kt extends y{checkPhoneIsBusy(r){return new Promise((e,t)=>{this.request({method:"GET",url:"/public/user/verification/phone/check",params:{phone:r}}).then(s=>{e(!!s.isBusy)}).catch(t)})}}class xt{constructor(r){i(this,"date");i(this,"name");i(this,"version");this.date=u.isString(r==null?void 0:r.date)?l.parseISO(r.date):(r==null?void 0:r.date)??new Date,this.name=(r==null?void 0:r.name)??"",this.version=(r==null?void 0:r.version)??"0.0.0"}}var ut=(n=>(n.Kozyrek="kozyrek",n.Mosquitto="mosquitto",n.Strip="strip",n.MetalForDoors="metal_for_doors",n.Sandwich="sandwich",n.SandwichM2="sandwich_m2",n))(ut||{});class Et extends y{getConfiguratorSettings(r,e){var t;return this.get(`internal/catalog/categories/${r.id}/configurators/${(t=r.properties)==null?void 0:t.configurator}/settings?client_id=${e}`)}searchProduct(r,e,t,s={}){var o;return this.request({method:"GET",url:`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/product`,params:{params:t,client_id:e}},p=>new L(p.data),s)}createTemplate(r,e,t,s={}){var o;return this.post(`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/template?client_id=${e}`,{...t},()=>{},s)}removeTemplate(r,e,t){var s;return this.delete(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/template/${t}?client_id=${e}`)}calculate(r,e,t){var s;return this.get(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/calculate`,{client_id:e,...t})}}class pt{constructor(r){i(this,"page",1);i(this,"pageSize",50);this.page=(r==null?void 0:r.page)??1,this.pageSize=(r==null?void 0:r.pageSize)??50}}class Xt extends pt{constructor(e){super(e);i(this,"itemCount",0);i(this,"pageCount",1);i(this,"pageSlot",5);i(this,"pageSizes",[25,50,100]);i(this,"showSizePicker",!0);this.itemCount=(e==null?void 0:e.itemCount)??0,this.pageCount=(e==null?void 0:e.pageCount)??1,this.pageSlot=(e==null?void 0:e.pageSlot)??5,this.pageSizes=(e==null?void 0:e.pageSizes)??[25,50,100],this.showSizePicker=(e==null?void 0:e.showSizePicker)??!0}}class Zt{constructor(r){i(this,"field");i(this,"direction");this.field=(r==null?void 0:r.field)??"",this.direction=(r==null?void 0:r.direction)??"asc"}}class w{static decadeInterval(r){const[e,t]=w.shiftedDecadeBounds(r,0);return{from:e,to:t}}static shiftDecadeInterval(r,e){const[t,s]=w.shiftedDecadeBounds(r,e);return{from:t,to:s}}static startOfHalfYear(r){return new Date(r.getFullYear(),r.getMonth()<6?0:6,1)}static endOfHalfYear(r){return l.endOfMonth(new Date(r.getFullYear(),r.getMonth()<6?5:11,1))}static addHalfYears(r,e){return l.addMonths(r,e*6)}static intervalTillSameDate(r,e,t){const s=l.differenceInCalendarMonths(l.startOfMonth(t),l.startOfMonth(r)),o=l.startOfMonth(l.addMonths(e,s)),p=Math.min(l.getDate(t),l.getDaysInMonth(o));return{from:l.startOfDay(e),to:l.endOfDay(l.setDate(o,p))}}static weekTillSameWeekday(r,e){const t=l.startOfWeek(l.addWeeks(r,e),{weekStartsOn:1}),s=l.differenceInCalendarDays(r,l.startOfWeek(r,{weekStartsOn:1}));return{from:t,to:l.endOfDay(l.addDays(t,s))}}static decadeTillSameDayNumber(r,e){const[t]=w.shiftedDecadeBounds(r,0),s=l.differenceInCalendarDays(r,t)+1,[o,p]=w.shiftedDecadeBounds(r,e),g=l.differenceInCalendarDays(p,o)+1;return{from:o,to:l.endOfDay(l.addDays(o,Math.min(s,g)-1))}}static shiftedDecadeBounds(r,e){const t=l.getDate(r);let s=2;t<=10?s=0:t<=20&&(s=1);const o=s+e,p=Math.floor(o/3),g=(o%3+3)%3,m=l.startOfMonth(l.addMonths(r,p)),a=l.addDays(m,g*10),P=g===2?l.endOfMonth(m):l.endOfDay(l.addDays(a,9));return[a,P]}}class Ke{static parse(r){if(u.isNil(r))return;const e=u.isString(r)?l.parseISO(r):r;return l.isValid(e)?e:void 0}}function Ft(n){return l.format(l.subDays(l.startOfToday(),n),"yyyy-MM-dd")}function ht(n,r){const e=[2,0,1,1,1,2],t=Math.floor(Math.abs(n));return r[t%100>4&&t%100<20?2:e[Math.min(t%10,5)]]}function ei(n){const r=l.parseISO(n),e=l.differenceInCalendarDays(l.startOfToday(),r);switch(!0){case e===0:return"Сегодня";case e===1:return"Вчера";case e<0:return n;default:return`${e} ${ht(e,["день","дня","дней"])} назад`}}class ri{static defaultDateRanges(r){const e=l.addBusinessDays(new Date,1),t=new Date,s=l.startOfYear(r===void 0?t:new Date(r,0,1)),o=l.endOfYear(s);return{nextWorkingDay:{label:"Следующий рабочий день",from:l.startOfDay(e),to:l.endOfDay(e)},today:{label:"Сегодня",from:l.startOfToday(),to:l.endOfToday()},yesterday:{label:"Вчера",from:l.startOfYesterday(),to:l.endOfYesterday()},tomorrow:{label:"Завтра",from:l.startOfTomorrow(),to:l.endOfTomorrow()},currentWeek:{label:"Неделя",from:l.startOfWeek(t,{weekStartsOn:1}),to:l.endOfWeek(t,{weekStartsOn:1})},currentMonth:{label:"Месяц",from:l.startOfMonth(t),to:l.endOfMonth(t)},oneMonth:{label:"1 месяц",from:s,to:l.endOfMonth(s)},threeMonths:{label:"3 месяца",from:s,to:l.endOfMonth(l.addMonths(s,2))},nineMonths:{label:"9 месяцев",from:s,to:l.endOfMonth(l.addMonths(s,8))},firstQuarter:{label:"I квартал",from:s,to:l.endOfMonth(l.addMonths(s,2))},secondQuarter:{label:"II квартал",from:l.addMonths(s,3),to:l.endOfMonth(l.addMonths(s,5))},thirdQuarter:{label:"III квартал",from:l.addMonths(s,6),to:l.endOfMonth(l.addMonths(s,8))},fourthQuarter:{label:"IV квартал",from:l.addMonths(s,9),to:l.endOfMonth(l.addMonths(s,11))},firstHalfYear:{label:"I полугодие",from:s,to:l.endOfMonth(l.addMonths(s,5))},secondHalfYear:{label:"II полугодие",from:l.addMonths(s,6),to:o},currentYear:{label:"12 месяцев",from:s,to:o}}}static standardPeriods(r=new Date){const e={weekStartsOn:1},t=l.startOfDay(r),s=l.endOfDay(r),o=w.decadeInterval(r),p=l.startOfMonth(r),g=l.startOfQuarter(r),m=w.startOfHalfYear(r),a=l.startOfYear(r),P=w.addHalfYears(r,-1),R=w.addHalfYears(r,1);return{yesterday:{label:"Вчера",group:"day",from:l.startOfDay(l.subDays(r,1)),to:l.endOfDay(l.subDays(r,1))},today:{label:"Сегодня",group:"day",from:t,to:s},tomorrow:{label:"Завтра",group:"day",from:l.startOfDay(l.addDays(r,1)),to:l.endOfDay(l.addDays(r,1))},lastWeek:{label:"Прошлая неделя",group:"week",from:l.startOfWeek(l.subWeeks(r,1),e),to:l.endOfWeek(l.subWeeks(r,1),e)},thisWeek:{label:"Эта неделя",group:"week",from:l.startOfWeek(r,e),to:l.endOfWeek(r,e)},nextWeek:{label:"Следующая неделя",group:"week",from:l.startOfWeek(l.addWeeks(r,1),e),to:l.endOfWeek(l.addWeeks(r,1),e)},lastTenDays:{label:"Прошлая декада",group:"decade",...w.shiftDecadeInterval(r,-1)},thisTenDays:{label:"Эта декада",group:"decade",...o},nextTenDays:{label:"Следующая декада",group:"decade",...w.shiftDecadeInterval(r,1)},lastMonth:{label:"Прошлый месяц",group:"month",from:l.startOfMonth(l.subMonths(r,1)),to:l.endOfMonth(l.subMonths(r,1))},thisMonth:{label:"Этот месяц",group:"month",from:p,to:l.endOfMonth(r)},nextMonth:{label:"Следующий месяц",group:"month",from:l.startOfMonth(l.addMonths(r,1)),to:l.endOfMonth(l.addMonths(r,1))},lastQuarter:{label:"Прошлый квартал",group:"quarter",from:l.startOfQuarter(l.subQuarters(r,1)),to:l.endOfQuarter(l.subQuarters(r,1))},thisQuarter:{label:"Этот квартал",group:"quarter",from:g,to:l.endOfQuarter(r)},nextQuarter:{label:"Следующий квартал",group:"quarter",from:l.startOfQuarter(l.addQuarters(r,1)),to:l.endOfQuarter(l.addQuarters(r,1))},lastHalfYear:{label:"Прошлое полугодие",group:"halfYear",from:w.startOfHalfYear(P),to:w.endOfHalfYear(P)},thisHalfYear:{label:"Это полугодие",group:"halfYear",from:m,to:w.endOfHalfYear(r)},nextHalfYear:{label:"Следующее полугодие",group:"halfYear",from:w.startOfHalfYear(R),to:w.endOfHalfYear(R)},lastYear:{label:"Прошлый год",group:"year",from:l.startOfYear(l.subYears(r,1)),to:l.endOfYear(l.subYears(r,1))},thisYear:{label:"Этот год",group:"year",from:a,to:l.endOfYear(r)},nextYear:{label:"Следующий год",group:"year",from:l.startOfYear(l.addYears(r,1)),to:l.endOfYear(l.addYears(r,1))},fromBeginningOfThisWeek:{label:"С начала этой недели",group:"other",section:"fromBeginning",from:l.startOfWeek(r,e),to:s},fromBeginningOfThisTenDays:{label:"С начала этой декады",group:"other",section:"fromBeginning",from:o.from,to:s},fromBeginningOfThisMonth:{label:"С начала этого месяца",group:"other",section:"fromBeginning",from:p,to:s},fromBeginningOfThisQuarter:{label:"С начала этого квартала",group:"other",section:"fromBeginning",from:g,to:s},fromBeginningOfThisHalfYear:{label:"С начала этого полугодия",group:"other",section:"fromBeginning",from:m,to:s},fromBeginningOfThisYear:{label:"С начала этого года",group:"other",section:"fromBeginning",from:a,to:s},tillEndOfThisWeek:{label:"До конца этой недели",group:"other",section:"tillEnd",from:t,to:l.endOfWeek(r,e)},tillEndOfThisTenDays:{label:"До конца этой декады",group:"other",section:"tillEnd",from:t,to:o.to},tillEndOfThisMonth:{label:"До конца этого месяца",group:"other",section:"tillEnd",from:t,to:l.endOfMonth(r)},tillEndOfThisQuarter:{label:"До конца этого квартала",group:"other",section:"tillEnd",from:t,to:l.endOfQuarter(r)},tillEndOfThisHalfYear:{label:"До конца этого полугодия",group:"other",section:"tillEnd",from:t,to:w.endOfHalfYear(r)},tillEndOfThisYear:{label:"До конца этого года",group:"other",section:"tillEnd",from:t,to:l.endOfYear(r)},lastWeekTillSameWeekDay:{label:"Прошлая неделя, до такого же дня недели",group:"other",section:"lastTillSame",...w.weekTillSameWeekday(r,-1)},lastTenDaysTillSameDayNumber:{label:"Прошлая декада, до такого же номера дня",group:"other",section:"lastTillSame",...w.decadeTillSameDayNumber(r,-1)},lastMonthTillSameDate:{label:"Прошлый месяц, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(p,l.startOfMonth(l.subMonths(r,1)),r)},lastQuarterTillSameDate:{label:"Прошлый квартал, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(g,l.startOfQuarter(l.subQuarters(r,1)),r)},lastHalfYearTillSameDate:{label:"Прошлое полугодие, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(m,w.startOfHalfYear(P),r)},lastYearTillSameDate:{label:"Прошлый год, до такой же даты",group:"other",section:"lastTillSame",...w.intervalTillSameDate(a,l.startOfYear(l.subYears(r,1)),r)},nextWeekTillSameWeekDay:{label:"Следующая неделя, до такого же дня недели",group:"other",section:"nextTillSame",...w.weekTillSameWeekday(r,1)},nextTenDaysTillSameDayNumber:{label:"Следующая декада, до такого же номера дня",group:"other",section:"nextTillSame",...w.decadeTillSameDayNumber(r,1)},nextMonthTillSameDate:{label:"Следующий месяц, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(p,l.startOfMonth(l.addMonths(r,1)),r)},nextQuarterTillSameDate:{label:"Следующий квартал, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(g,l.startOfQuarter(l.addQuarters(r,1)),r)},nextHalfYearTillSameDate:{label:"Следующее полугодие, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(m,w.startOfHalfYear(R),r)},nextYearTillSameDate:{label:"Следующий год, до такой же даты",group:"other",section:"nextTillSame",...w.intervalTillSameDate(a,l.startOfYear(l.addYears(r,1)),r)},last7Days:{label:"Последние 7 дней",group:"other",section:"rollingDays",from:l.startOfDay(l.subDays(r,6)),to:s},next7Days:{label:"Следующие 7 дней",group:"other",section:"rollingDays",from:t,to:l.endOfDay(l.addDays(r,6))}}}}const ti=[{key:"day",label:"День"},{key:"week",label:"Неделя"},{key:"decade",label:"Декада"},{key:"month",label:"Месяц"},{key:"quarter",label:"Квартал"},{key:"halfYear",label:"Полугодие"},{key:"year",label:"Год"},{key:"other",label:"Прочее"}],ii=[{key:"fromBeginning",label:"С начала периода"},{key:"tillEnd",label:"До конца периода"},{key:"lastTillSame",label:"Прошлые, до такой же даты"},{key:"nextTillSame",label:"Следующие, до такой же даты"},{key:"rollingDays",label:"7 дней"}];function si(n){const r=u.round(n*100);return`${r>=0?"+":""}${r}%`}class br{static productIsMeasurable(r){return r.unit.isLinear||r.unit.isSquare}static getProductMultiplicity(r){var e,t;return!((e=r.properties)!=null&&e.ignoreMinCountCheck)&&((t=r.properties)==null?void 0:t.minCount)!=null&&!br.productIsMeasurable(r)?r.properties.minCount:1}static getProductLengthMultiplicity(r){var e,t,s;return((e=r.properties)==null?void 0:e.lengthStep)!=null?r.properties.lengthStep:!((t=r.properties)!=null&&t.ignoreMinCountCheck)&&((s=r.properties)==null?void 0:s.minCount)!=null?r.properties.minCount:.01}}const we=class we extends y{constructor(){super();i(this,"responseDataCacheTimeout");this.responseDataCacheTimeout=b().config.http.responseDataCacheTimeout}static getCachedResponse(e){const t=we.responseDataCache.get(e);if(t&&t.validTo>new Date)return t.val}cacheResponse(e,t){we.responseDataCache.set(e,{validTo:l.addSeconds(new Date,this.responseDataCacheTimeout),val:t})}getTypedDataArrayRequester(e,t,s=!1,o={},p=void 0){const g=t+(u.isEmpty(o)?"":` >>> ${JSON.stringify(o)}`),m=s?we.getCachedResponse(g):void 0;return m?Promise.resolve(m):this.getTypedList(e,t,o,!1,p).then(a=>(s&&a&&this.cacheResponse(g,a),a))}};i(we,"responseDataCache",new Map);let ae=we;class ni{static generateUndefinedManagerInstance(){return new Y({id:0,name:"- Не назначен -",isActive:!0,guid:"-undefined-"})}static isUndefinedManagerInstance(r){return r.id===0&&r.guid==="-undefined-"}}class Or extends ae{async getManagers(){const r="/internal/managers",e=ae.getCachedResponse(r);if(e)return e;const t=await this.get(r),s=k.instanceListInitializer(Y,t.data);return this.cacheResponse(r,s),s}getManager(r){return this.get(`/internal/managers/${r}`,{},e=>new Y(e.data))}}var Ce=(n=>(n.Processing="processing",n.Completed="completed",n.Error="error",n.NeedsActualization="needs_actualization",n))(Ce||{});class gt{constructor(r){i(this,"status");i(this,"actualizedAt");i(this,"expiresAt");i(this,"error");this.status=(r==null?void 0:r.status)??Ce.Processing,this.actualizedAt=Ke.parse(r==null?void 0:r.actualizedAt),this.expiresAt=Ke.parse(r==null?void 0:r.expiresAt),this.error=r==null?void 0:r.error}get isProcessing(){return this.status===Ce.Processing}get isOutdated(){return this.isOutdatedAt(new Date)}get isOrderAllowed(){return this.isOrderAllowedAt(new Date)}isOutdatedAt(r){return this.status!==Ce.Completed||u.isNil(this.actualizedAt)?!0:!u.isNil(this.expiresAt)&&this.expiresAt.getTime()<r.getTime()}isOrderAllowedAt(r){return this.status===Ce.Completed&&!this.isOutdatedAt(r)}}class $r extends N{constructor(e){super(e);i(this,"name");i(this,"createdAt");i(this,"client");i(this,"sum");i(this,"isProfstroy");i(this,"actualization");i(this,"file");this.name=e==null?void 0:e.name,this.createdAt=Ke.parse(e==null?void 0:e.createdAt)??new Date,this.client=new J(e==null?void 0:e.client),this.sum=e==null?void 0:e.sum,this.isProfstroy=e==null?void 0:e.isProfstroy,this.actualization=(e==null?void 0:e.actualization)&&new gt(e.actualization),this.file=e==null?void 0:e.file}}class ft extends cr{constructor(e){super(e);i(this,"groupName");i(this,"supplierSku");i(this,"isIgnored");i(this,"lineError");this.groupName=e.groupName,this.supplierSku=e.supplierSku??e.product.supplierSku,this.isIgnored=e.isIgnored,this.lineError=e.lineError}get isProductStub(){return u.isNil(this.product.id)}get isOrderable(){return!this.isProductStub&&!this.isIgnored&&u.isEmpty(this.lineError)}}class B extends $r{constructor(e){super(e);i(this,"sum");i(this,"products");this.sum=e.sum??0,this.products=(e.products??[]).map(t=>e.isProfstroy?new ft(t):new cr(t))}}class oi extends le{constructor(e){super();i(this,"id");i(this,"clientSearchTerm");i(this,"name");i(this,"createdAt",new T);this.id=e==null?void 0:e.id,this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.name=e==null?void 0:e.name,this.createdAt=new T(e==null?void 0:e.createdAt)}resetFilterValue(e){return e==="createdAt"?(this.createdAt.from=null,this.createdAt.to=null):this[e]=void 0,this}asClearRaw(){var t,s;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,e}}class $e extends D{}class Ir extends Ar{constructor(e){var t,s,o,p,g,m,a,P;super(e);i(this,"client");i(this,"payment");i(this,"delivery");i(this,"attachedUser");i(this,"status");i(this,"statusDetail");i(this,"salesDirection");i(this,"attachedAt");i(this,"isOnOrder");i(this,"isProfstroy");i(this,"isNotInStock");i(this,"sum");i(this,"isLargeOrder");this.client=new J(e==null?void 0:e.client),this.payment={type:((t=e==null?void 0:e.payment)==null?void 0:t.type)??-1,status:((s=e==null?void 0:e.payment)==null?void 0:s.status)??-1,onlinePaymentLink:(o=e==null?void 0:e.payment)==null?void 0:o.onlinePaymentLink},this.delivery={type:((p=e==null?void 0:e.delivery)==null?void 0:p.type)??-1,date:u.isString((g=e==null?void 0:e.delivery)==null?void 0:g.date)?l.parseISO(e.delivery.date):((m=e==null?void 0:e.delivery)==null?void 0:m.date)??new Date,address:(a=e==null?void 0:e.delivery)!=null&&a.address?new ye(e.delivery.address):void 0,warehouse:(P=e==null?void 0:e.delivery)!=null&&P.warehouse?new ue(e.delivery.warehouse):void 0},this.attachedUser=e!=null&&e.attachedUser?new d(e==null?void 0:e.attachedUser):void 0,this.status=new $e(e==null?void 0:e.status),this.statusDetail=e!=null&&e.statusDetail?new D(e.statusDetail):void 0,this.salesDirection=new _(e==null?void 0:e.salesDirection),this.attachedAt=u.isString(e==null?void 0:e.attachedAt)?l.parseISO(e.attachedAt):e==null?void 0:e.attachedAt,this.isOnOrder=(e==null?void 0:e.isOnOrder)??!1,this.isProfstroy=(e==null?void 0:e.isProfstroy)??!1,this.isNotInStock=(e==null?void 0:e.isNotInStock)??!1,this.sum=(e==null?void 0:e.sum)??0,this.isLargeOrder=(e==null?void 0:e.isLargeOrder)??!1}}class mt extends or{constructor(e,t){super(e);i(this,"product");i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");i(this,"changedFields",[]);i(this,"replacement");this.product=new z(e.product),this.currency=new q(e.currency),this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,t&&(this.replacement=t,this.quantity!==t.quantity&&this.changedFields.push("quantity"),this.length!==t.length&&this.changedFields.push("length"))}}class $ extends Ir{constructor(e){var t;super(e);i(this,"products");i(this,"invoices");i(this,"comment");i(this,"image");i(this,"contragent");i(this,"barcode");i(this,"orderSource");i(this,"isAllowProcessingWithoutPayment");i(this,"nextStatuses");i(this,"actions");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"erpOrderUrl");i(this,"numberDoc");this.products=(e.products??[]).map(s=>{var p;const o=s.replacementId?(p=e.products)==null?void 0:p.find(g=>g.id===s.replacementId):void 0;return new mt(s,o)}),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?Oe.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new D(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment,this.nextStatuses=(t=e.nextStatuses)==null?void 0:t.map(s=>new $e(s)),this.actions=e.actions,this.operatorsComment=e.operatorsComment,this.operatorsForWarehouseComment=e.operatorsForWarehouseComment,this.erpOrderUrl=e.erpOrderUrl,this.numberDoc=e.numberDoc}}class ci extends M{getOffers(r,e,t,s=void 0){return this.getTypedPaginated($r,"/internal/orders/offers",r,e,t,{},void 0,s)}createOfferFromCart(r,e,t){return this.post(`/internal/orders/offers/${r}`,{name:e,items:t!=null&&t.length?t:void 0},s=>new B(s.data))}createProfstroyOffer(r,e,t,s={}){return this.post(`/internal/orders/offers/${r}/profstroy`,{file:e,name:t},o=>new B(o.data),s)}actualizeProfstroyOffer(r){return this.post(`/internal/orders/offers/${r}/profstroy/actualize`,{},e=>new B(e.data))}reloadProfstroyOffer(r){return this.post(`/internal/orders/offers/${r}/profstroy/reload`,{},e=>new B(e.data))}getOffer(r){return this.get(`/internal/orders/offers/${r}`,{},e=>new B(e.data))}updateOffer(r,e){return this.patch(`/internal/orders/offers/${r}`,{name:e},t=>new B(t.data))}deleteOffer(r){return this.delete(`/internal/orders/offers/${r}`)}createOrderFromDraft(r,e,t,s={}){const o=b().config.dateFormats.api;return this.post(`/internal/orders/offers/${r}/create-order`,{...e,deliveryDate:e.deliveryDate?l.format(e.deliveryDate,o):void 0,items:t!=null&&t.length?t:void 0},p=>k.instanceListInitializer($,p.data),s)}addOfferProduct(r,e,t={}){return this.post(`/internal/orders/offers/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new B(s.data),t)}patchOfferProduct(r,e,t,s={}){return this.patch(`/internal/orders/offers/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},o=>new B(o.data),s)}deleteOfferProduct(r,e){return this.delete(`/internal/orders/offers/${r}/products/${e}`,t=>new B(t.data))}getOfferHtml(r,e){return this.get(`/internal/orders/offers/${r}/view`,e?{recipientText:e}:{},t=>new Blob([t.data],{type:"text/html"}))}getOfferPdf(r,e){return this.getBlob(`/internal/orders/offers/${r}/download`,e?{recipientText:e}:{},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOffer(r,e){return this.post(`/internal/orders/offers/${r}/send`,e)}}class li{static isProfstroy(r){return!!(r!=null&&r.isProfstroy)}static isProfstroyOffer(r){return!u.isNil(r)&&r.isProfstroy===!0&&!u.isNil(r.actualization)}}var yt=(n=>(n.View="view",n.Share="share",n.EditTags="edit_tags",n.SaveOrderIgnoredProducts="save_order_ignored_products",n.ChangeStatus="change_status",n.ChangeProducts="change_products",n.ChangeOrderParameters="change_order_parameters",n.Recalculate="recalculate",n.AttachOrder="attach_order",n.DetachOrder="detach_order",n.ChangeAttachedOperator="change_attached_operator",n.SendOnlinePaymentLink="send_online_payment_link",n.ConfirmOnlineFullPayment="confirm_online_full_payment",n.MergeOrders="merge_orders",n.GetHistory="get_history",n.CloneOrder="clone_order",n.DeleteAttachedFile="delete_attached_file",n))(yt||{});class ui{constructor(r){i(this,"paymentType");i(this,"deliveryType");i(this,"contragentId");i(this,"deliveryDate");i(this,"addressId");i(this,"warehouseId");i(this,"image");i(this,"comment");i(this,"barcode");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"additionalEmails");i(this,"isAllowProcessingWithoutPayment");i(this,"isAdditionalSale");var e,t,s;this.paymentType=r==null?void 0:r.payment.type,this.deliveryType=r==null?void 0:r.delivery.type,this.contragentId=(e=r==null?void 0:r.contragent)==null?void 0:e.id,this.deliveryDate=r!=null&&r.delivery.date?new Date(r.delivery.date):void 0,this.addressId=(t=r==null?void 0:r.delivery.address)==null?void 0:t.id,this.warehouseId=(s=r==null?void 0:r.delivery.warehouse)==null?void 0:s.id,this.comment=r==null?void 0:r.comment,this.barcode=r==null?void 0:r.barcode,this.operatorsComment=r==null?void 0:r.operatorsComment,this.operatorsForWarehouseComment=r==null?void 0:r.operatorsForWarehouseComment,this.isAllowProcessingWithoutPayment=r==null?void 0:r.isAllowProcessingWithoutPayment}}class kr extends D{}class dr extends D{}class pi extends le{constructor(e){var t,s,o,p;super();i(this,"attachedUsers");i(this,"clientSearchTerm");i(this,"client");i(this,"contragent");i(this,"createdAt",new T);i(this,"creator");i(this,"deliveryDate",new T);i(this,"deliveryAddressSearch");i(this,"clientCities");i(this,"id");i(this,"isApproved");i(this,"isNotInStock");i(this,"isOnOrder");i(this,"attachedAt",new T);i(this,"salesDirections");i(this,"status");i(this,"statusDetail");i(this,"deliveryType");i(this,"paymentType");i(this,"warehouses");i(this,"isLargeOrder");i(this,"isToProcess");i(this,"onlyMyRegions");this.attachedUsers=(t=e==null?void 0:e.attachedUsers)==null?void 0:t.map(g=>"isActive"in g?new Y(g):new kr(g)),this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.client=e!=null&&e.client?new J(e.client):void 0,this.contragent=e==null?void 0:e.contragent,this.createdAt=new T(e==null?void 0:e.createdAt),this.creator=e!=null&&e.creator?new d(e.creator):void 0,this.deliveryDate=new T(e==null?void 0:e.deliveryDate),this.deliveryAddressSearch=e==null?void 0:e.deliveryAddressSearch,this.clientCities=(s=e==null?void 0:e.clientCities)==null?void 0:s.map(g=>new ie(g)),this.id=e==null?void 0:e.id,this.isApproved=e==null?void 0:e.isApproved,this.isNotInStock=e==null?void 0:e.isNotInStock,this.isOnOrder=e==null?void 0:e.isOnOrder,this.isLargeOrder=e==null?void 0:e.isLargeOrder,this.attachedAt=new T(e==null?void 0:e.attachedAt),this.salesDirections=(o=e==null?void 0:e.salesDirections)==null?void 0:o.map(g=>new _(g)),this.status=e==null?void 0:e.status,this.statusDetail=e==null?void 0:e.statusDetail,this.deliveryType=e!=null&&e.deliveryType?new W(e.deliveryType):void 0,this.paymentType=e!=null&&e.paymentType?new dr(e.paymentType):void 0,this.warehouses=(p=e==null?void 0:e.warehouses)==null?void 0:p.map(g=>new ue(g)),this.isToProcess=e==null?void 0:e.isToProcess}resetFilterValue(e){switch(e){case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"creator":this.creator=void 0;break;case"deliveryDate":this.deliveryDate.from=null,this.deliveryDate.to=null;break;case"deliveryType":this.deliveryType=new W;break;case"clientCities":this.clientCities=[];break;case"attachedAt":this.attachedAt.from=null,this.attachedAt.to=null;break;case"salesDirection":case"salesDirections":this.salesDirections=[];break;case"status":this.status=[];break;case"warehouse":case"warehouses":this.warehouses=[];break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,p,g,m;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.deliveryDate)!=null&&o.from)&&!((p=e==null?void 0:e.deliveryDate)!=null&&p.to)&&delete e.deliveryDate,!((g=e==null?void 0:e.attachedAt)!=null&&g.from)&&!((m=e==null?void 0:e.attachedAt)!=null&&m.to)&&delete e.attachedAt,e}}class at{constructor(r){i(this,"user");i(this,"status");i(this,"statusDetail");i(this,"createdAt");this.user=new d(r==null?void 0:r.user),this.status=new $e(r==null?void 0:r.status),this.statusDetail=r!=null&&r.statusDetail?new D(r.statusDetail):void 0,this.createdAt=u.isString(r==null?void 0:r.createdAt)?l.parseISO(r.createdAt):(r==null?void 0:r.createdAt)??new Date}}class hi extends M{getOrders(r,e,t,s=void 0){return this.getTypedPaginated(Ir,"/internal/orders",r,e,t,{},void 0,s)}getOrdersCount(r,e=void 0){return this.get("/internal/orders/count",r?{filters:JSON.stringify((r instanceof V?r:new V(r)).toPrimitive())}:{},void 0,void 0,e).then(t=>t.count)}getClientOrderStatistics(r,e){return this.get(`/internal/clients/${r}/orders/statistics`,e?{period:e}:{})}getOrder(r){return this.get(`/internal/orders/${r}`,{},e=>new $(e.data))}createClientOrder(r,e,t,s,o={}){const p=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/orders/${e}`,{...t,deliveryDate:l.format(t.deliveryDate,p),items:s!=null&&s.length?s:void 0},g=>k.instanceListInitializer($,g.data),o)}attachOrder(r){return this.patch(`/internal/orders/${r}/attach`,{},e=>new $(e.data))}detachOrder(r){return this.patch(`/internal/orders/${r}/detach`,{},e=>new $(e.data))}mergeOrders(r,e){return this.patch(`/internal/orders/${r}/merge`,{ids:e},t=>new $(t.data))}recalculateOrder(r){return this.patch(`/internal/orders/${r}/recalculate`,{},e=>new $(e.data))}cloneOrder(r){return this.get(`/internal/orders/${r}/clone`,{})}updateOrder(r,e,t={}){const s=b().config.dateFormats.api;return this.patch(`/internal/orders/${r}`,{...e,deliveryDate:e.deliveryDate?l.format(e.deliveryDate,s):void 0},o=>new $(o.data),t)}addOrderProduct(r,e,t={}){return this.post(`/internal/orders/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new $(s.data),t)}changeOrderStatus(r,e,t,s={}){return this.patch(`/internal/orders/${r}/status`,{status:e,statusDetail:t},o=>new $(o.data),s)}changeOrderStatusDetail(r,e){return this.patch(`/internal/orders/${r}/status`,{statusDetail:e},t=>new $(t.data))}getOrderStatusHistory(r){return this.getTypedList(at,`/internal/orders/${r}/history`)}getOrderPrintHtml(r,e){return this.get(`/internal/orders/${r}/print/view`,{...e},t=>new Blob([t.data],{type:"text/html"}))}getOrderPrintPdf(r,e){return this.getBlob(`/internal/orders/${r}/print/download`,{...e},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOrderPrint(r,e){return this.post(`/internal/orders/${r}/print/send`,e)}changeAttachedOperator(r,e){return this.patch(`/internal/orders/${r}/change-attached-operator`,{operatorId:e},t=>new $(t.data))}deleteOrderAttachedFile(r){return this.delete(`/internal/orders/${r}/file/attached`,e=>new $(e.data))}deleteOrderProduct(r,e){return this.delete(`/internal/orders/${r}/products/${e}`,t=>new $(t.data))}patchOrderProduct(r,e,t,s={}){return this.patch(`/internal/orders/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},o=>new $(o.data),s)}getDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getSelfDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/self-delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getDeliveryCost(r,e,t,s=void 0){const o=b().config.dateFormats.api;return this.get(`/internal/orders/delivery/${r}/cost`,{date:l.format(e,o),warehouse_id:t},p=>p.data,void 0,s)}}const gi=Symbol("currentOrder");class xe{constructor(r){i(this,"client");i(this,"product");i(this,"cost");i(this,"costCoefficient");i(this,"source");this.client=new J(r==null?void 0:r.client),this.product=new L(r==null?void 0:r.product),this.cost=(r==null?void 0:r.cost)??0,this.costCoefficient=(r==null?void 0:r.costCoefficient)??0,this.source=(r==null?void 0:r.source)??Be.Product}}const Lr=n=>{var r,e,t,s,o;return n?u.omitBy({cities:(r=n.cities)==null?void 0:r.map(p=>p.id),clients:(e=n.clients)==null?void 0:e.map(p=>p.id),managers:(t=n.managers)==null?void 0:t.map(p=>p.id),partnerGroups:(s=n.partnerGroups)==null?void 0:s.map(p=>p.id),salesDirections:(o=n.salesDirections)==null?void 0:o.map(p=>p.id),hideNotActive:n.hideNotActive},p=>u.isNil(p)||(u.isArray(p)||u.isObject(p))&&u.isEmpty(p)):{}},Ct=n=>{const r={};return n.from&&(n.from.coefficient||n.from.value)&&(r.from={},n.from.coefficient&&(r.from.priceCoefficientId=n.from.coefficient.id),n.from.value&&(r.from.increasePercent=n.from.value)),n.to&&(n.to.coefficient||n.to.value)&&(r.to={},n.to.coefficient&&(r.to.priceCoefficientId=n.to.coefficient.id),n.to.value&&(r.to.increasePercent=n.to.value)),r};class fi extends y{analyzeProductPrices(r,e,t){return this.get(`/internal/price/products/${r}/analyze`,{...Ct(e),filters:Lr(t)},s=>k.instanceListInitializer(xe,s.data))}analyzeCategoryPrices(r,e,t){return this.get(`/internal/price/categories/${r}/analyze`,{...Ct(e),filters:Lr(t)},s=>k.instanceListInitializer(xe,s.data))}analyzeCategoryPricesBySquare(r,e,t){return this.get(`/internal/price/categories/${r}/analyze/square`,{...e,filters:Lr(t)},s=>k.instanceListInitializer(xe,s.data))}}class wt{constructor(r){i(this,"cost");i(this,"isLowCost");i(this,"isRetail");i(this,"costDate");i(this,"discountName");i(this,"priceTemplateName");i(this,"product");i(this,"client");i(this,"executor");i(this,"currency");this.cost=r.cost??0,this.isLowCost=r.isLowCost??!1,this.isRetail=r.isRetail??!1,this.costDate=u.isString(r.costDate)?l.parseISO(r.costDate):r.costDate??new Date,this.discountName=r.discountName,this.priceTemplateName=r.priceTemplateName,this.product=r.product?new pe(r.product):void 0,this.client=r.client?new d(r.client):void 0,this.executor=r.executor?new d(r.executor):void 0,this.currency=r.currency?new q(r.currency):void 0}}class vt extends pe{constructor(e){super(e);i(this,"history");this.history=u.map(e.history,t=>new wt(t))}}class mi extends y{getProductPriceHistory(r){var o,p,g,m,a;const e=b().config.dateFormats.api,t=u.omitBy(u.merge(r,{costDate:{from:u.isDate((o=r.costDate)==null?void 0:o.from)?l.format(r.costDate.from,e):(p=r.costDate)==null?void 0:p.from,to:u.isDate((g=r.costDate)==null?void 0:g.to)?l.format(r.costDate.to,e):(m=r.costDate)==null?void 0:m.to}}),P=>u.isNil(P)||(u.isArray(P)||u.isObject(P))&&u.isEmpty(P)),s=((a=r.product)==null?void 0:a[0])??0;return delete t.product,this.get(`/internal/price/products/${s}/history`,t).then(P=>[new vt(u.merge(P[0],{history:P}))])}}class _r{constructor(r){i(this,"products",[]);i(this,"productCategories",[]);r!=null&&r.products&&(this.products=r.products.map(e=>new pe(e))),r!=null&&r.productCategories&&(this.productCategories=r.productCategories.map(e=>new pe(e)))}}class yi extends y{getProductCategoryRecommendations(r){return this.get(`/internal/catalog/recommendations/categories/${r.id}`,{},e=>new _r(e.data))}getProductRecommendations(r){return this.get(`/internal/catalog/recommendations/products/${r.id}`,{},e=>new _r(e.data))}saveProductCategoryRecommendations(r,e){return this.post(`/internal/catalog/recommendations/categories/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}saveProductRecommendations(r,e){return this.post(`/internal/catalog/recommendations/products/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}}var Pt=(n=>(n.New="new",n.Processing="processing",n.AwaitingSupplyProducts="awaiting_supply_products",n.InvoiceIssued="invoice_issued",n.ProcessingOnStock="processing_on_stock",n.Finished="finished",n.OrderUpdated="order_updated",n.Canceled="canceled",n.Error="error",n))(Pt||{}),Dt=(n=>(n.CanceledBy1c="canceled_by1c",n.CanceledByClient="canceled_by_client",n.FinishedNotApproved="finished_not_approved",n.ProcessingByPurchasingDepartment="processing_by_purchasing_department",n.WillWaiting="will_waiting",n))(Dt||{});class Rt extends D{}class Tt extends D{}class Nr extends D{constructor(e){var t;super(e);i(this,"userRegions");this.userRegions=((t=e==null?void 0:e.userRegions)==null?void 0:t.map(s=>new Ae(s)))??[]}}class St extends D{}class At extends D{}class bt extends D{}class Ot extends D{}class ai{static generateUndefinedInstance(r,e="- Не определён -"){return new r({id:0,name:e,slug:"-undefined-"})}static isUndefinedInstance(r){return r.id===0&&r.slug==="-undefined-"}}class Ur extends D{}const Q=class Q extends ae{static withoutUnknownLocation(r){return r.filter(e=>e.id!==Q.unknownLocationId)}getReference(r,e=!1){return this.getTypedDataArrayRequester(Rt,`/internal/references/${r}`,e)}getChannelPrimaryInterest(){return this.getTypedDataArrayRequester(Rr,"/internal/references/channel-primary-interest",!0)}getContactPositions(){return this.getTypedDataArrayRequester(St,"/internal/references/contact-position",!0)}getCuratedDirection(){return this.getTypedDataArrayRequester(ze,"/internal/references/curated-direction",!0)}getCurrency(){return this.getTypedDataArrayRequester(q,"/public/references/currency",!0)}getPartnerGroup(){return this.getTypedDataArrayRequester(oe,"/internal/references/partner-group",!0)}getOpf(){return this.getTypedDataArrayRequester(x,"/public/references/opf",!0)}getOperators(){return this.getTypedDataArrayRequester(kr,"/internal/references/operator",!0)}getOrderPaymentStatuses(){return this.getTypedDataArrayRequester(At,"/public/references/order-payment-status",!0)}getOrderStatuses(){return this.getTypedDataArrayRequester($e,"/internal/references/order-status",!0)}getOrderStatusDetails(){return this.getTypedDataArrayRequester(bt,"/internal/references/order-status-detail",!0)}getPaymentTypes(){return this.getTypedDataArrayRequester(dr,"/public/references/payment-type",!0)}getResourceTypes(){return this.getTypedDataArrayRequester(Ur,"/internal/references/resource-type",!0)}getSalesDirections(){return this.getTypedDataArrayRequester(_,"/public/references/sales-direction",!0)}getSourcePrimaryInterest(){return this.getTypedDataArrayRequester(Tr,"/internal/references/source-primary-interest",!0)}searchCity(r){return this.getTypedDataArrayRequester(ie,`/internal/references/city-with-region-and-country/search?term=${r}`)}searchRegion(r){return this.getTypedDataArrayRequester(te,`/internal/references/region-with-country/search?term=${r}`)}getRegionsByCountry(r){return this.getTypedDataArrayRequester(te,"/internal/references/region",!1,{params:{countryId:r}}).then(e=>Q.withoutUnknownLocation(e))}getCitiesByRegion(r){return this.getTypedDataArrayRequester(Tt,"/internal/references/city",!1,{params:{regionId:r}}).then(e=>Q.withoutUnknownLocation(e))}getCitiesWithUserRegionByRegion(r){return this.getTypedDataArrayRequester(Nr,"/internal/references/city-with-user-region",!1,{params:{regionId:r}}).then(e=>Q.withoutUnknownLocation(e))}searchCityWithRegion(r,e,t=void 0){return this.getTypedDataArrayRequester(ie,"/internal/references/city-with-region/search",!1,{term:r,...e?{params:{countryId:e}}:{}},t).then(s=>Q.withoutUnknownLocation(s))}searchCityWithUserRegion(r,e=void 0){return this.getTypedDataArrayRequester(Nr,"/internal/references/city-with-user-region/search",!1,{term:r},e).then(t=>Q.withoutUnknownLocation(t))}searchCountry(r){return this.getTypedDataArrayRequester(re,`/internal/references/country/search?term=${r}`)}getDeliveryTypes(){return this.getTypedDataArrayRequester(W,"/internal/references/delivery-type",!0)}getWarehouses(){return this.getTypedDataArrayRequester(ue,"/public/references/warehouse",!0)}getPropertyTypes(){return this.getTypedDataArrayRequester(fr,"/internal/references/property-type",!0)}getPriceCoefficients(){return this.getTypedDataArrayRequester(ee,"/internal/references/price-coefficient",!0)}getProductFileType(){return this.getTypedDataArrayRequester(Ot,"/public/references/product-file-type",!0)}};i(Q,"unknownLocationId",1);let S=Q;const A=E.defineStore("common.references_private",()=>{const n=f.ref({}),r=f.ref(void 0),e=f.ref(void 0),t=f.ref(void 0),s=f.ref(void 0),o=f.ref(void 0),p=f.ref(void 0),g=f.ref(void 0),m=f.ref(void 0),a=f.ref(void 0),P=f.ref(void 0),R=f.ref(void 0),ke=f.ref(void 0),de=f.ref(void 0),ve=f.ref(void 0),Pe=f.ref(void 0),Br=f.ref(void 0),Wr=f.ref(void 0),zr=f.ref(void 0),h=f.ref(void 0);return{dataLoaderList:n,channelPrimaryInterestReference:r,contactPositionsReference:e,currencyReference:t,deliveryTypeReference:s,managersList:o,opfReference:p,operatorReference:g,orderPaymentStatusReference:m,orderStatusReference:a,orderStatusDetailReference:P,paymentTypeReference:R,partnerGroupReference:ke,productFileTypeReference:de,resourceTypesReference:ve,salesDirectionsReference:Pe,sourcePrimaryInterestReference:Br,warehousesReference:Wr,propertyTypesReference:zr,priceCoefficientsReference:h}}),Ci=E.defineStore("common.references",()=>{const n=f.computed(()=>{const h=A();return!h.channelPrimaryInterestReference&&!h.dataLoaderList.channelPrimaryInterestReference&&(h.dataLoaderList.channelPrimaryInterestReference=!0,y.getInstance(S).getChannelPrimaryInterest().then(C=>{h.channelPrimaryInterestReference=C}).catch(u.noop)),h.channelPrimaryInterestReference}),r=f.computed(()=>{const h=A();return!h.contactPositionsReference&&!h.dataLoaderList.contactPositionsReference&&(h.dataLoaderList.contactPositionsReference=!0,y.getInstance(S).getContactPositions().then(C=>{h.contactPositionsReference=C}).catch(u.noop)),h.contactPositionsReference}),e=f.computed(()=>{const h=A();return!h.currencyReference&&!h.dataLoaderList.currencyReference&&(h.dataLoaderList.currencyReference=!0,y.getInstance(S).getCurrency().then(C=>{h.currencyReference=C}).catch(u.noop)),h.currencyReference}),t=f.computed(()=>{const h=A();return!h.opfReference&&!h.dataLoaderList.opfReference&&(h.dataLoaderList.opfReference=!0,y.getInstance(S).getOpf().then(C=>{h.opfReference=C}).catch(u.noop)),h.opfReference}),s=f.computed(()=>{const h=A();return!h.operatorReference&&!h.dataLoaderList.operatorReference&&(h.dataLoaderList.operatorReference=!0,y.getInstance(S).getOperators().then(C=>{h.operatorReference=C}).catch(u.noop)),h.operatorReference}),o=f.computed(()=>{const h=A();return!h.orderPaymentStatusReference&&!h.dataLoaderList.orderPaymentStatusReference&&(h.dataLoaderList.orderPaymentStatusReference=!0,y.getInstance(S).getOrderPaymentStatuses().then(C=>{h.orderPaymentStatusReference=C}).catch(u.noop)),h.orderPaymentStatusReference}),p=f.computed(()=>{const h=A();return!h.orderStatusReference&&!h.dataLoaderList.orderStatusReference&&(h.dataLoaderList.orderStatusReference=!0,y.getInstance(S).getOrderStatuses().then(C=>{h.orderStatusReference=C}).catch(u.noop)),h.orderStatusReference}),g=f.computed(()=>{const h=A();return!h.orderStatusDetailReference&&!h.dataLoaderList.orderStatusDetailReference&&(h.dataLoaderList.orderStatusDetailReference=!0,y.getInstance(S).getOrderStatusDetails().then(C=>{h.orderStatusDetailReference=C}).catch(u.noop)),h.orderStatusDetailReference}),m=f.computed(()=>{const h=A();return!h.paymentTypeReference&&!h.dataLoaderList.paymentTypeReference&&(h.dataLoaderList.paymentTypeReference=!0,y.getInstance(S).getPaymentTypes().then(C=>{h.paymentTypeReference=C}).catch(u.noop)),h.paymentTypeReference}),a=f.computed(()=>{const h=A();return!h.partnerGroupReference&&!h.dataLoaderList.partnerGroupReference&&(h.dataLoaderList.partnerGroupReference=!0,y.getInstance(S).getPartnerGroup().then(C=>{h.partnerGroupReference=C}).catch(u.noop)),h.partnerGroupReference}),P=f.computed(()=>{const h=A();return!h.productFileTypeReference&&!h.dataLoaderList.productFileTypeReference&&(h.dataLoaderList.productFileTypeReference=!0,y.getInstance(S).getProductFileType().then(C=>{h.productFileTypeReference=C}).catch(u.noop)),h.productFileTypeReference}),R=f.computed(()=>{const h=A();return!h.resourceTypesReference&&!h.dataLoaderList.resourceTypesReference&&(h.dataLoaderList.resourceTypesReference=!0,y.getInstance(S).getResourceTypes().then(C=>{h.resourceTypesReference=C}).catch(u.noop)),h.resourceTypesReference}),ke=f.computed(()=>{const h=A();return!h.salesDirectionsReference&&!h.dataLoaderList.salesDirectionsReference&&(h.dataLoaderList.salesDirectionsReference=!0,y.getInstance(S).getSalesDirections().then(C=>{h.salesDirectionsReference=C}).catch(u.noop)),h.salesDirectionsReference}),de=f.computed(()=>{const h=A();return!h.sourcePrimaryInterestReference&&!h.dataLoaderList.sourcePrimaryInterestReference&&(h.dataLoaderList.sourcePrimaryInterestReference=!0,y.getInstance(S).getSourcePrimaryInterest().then(C=>{h.sourcePrimaryInterestReference=C}).catch(u.noop)),h.sourcePrimaryInterestReference}),ve=f.computed(()=>{const h=A();return!h.deliveryTypeReference&&!h.dataLoaderList.deliveryTypeReference&&(h.dataLoaderList.deliveryTypeReference=!0,y.getInstance(S).getDeliveryTypes().then(C=>{h.deliveryTypeReference=C}).catch(u.noop)),h.deliveryTypeReference}),Pe=f.computed(()=>{const h=A();return!h.managersList&&!h.dataLoaderList.managersList&&(h.dataLoaderList.managersList=!0,y.getInstance(Or).getManagers().then(C=>{h.managersList=C}).catch(u.noop)),h.managersList}),Br=f.computed(()=>{const h=A();return!h.warehousesReference&&!h.dataLoaderList.warehousesReference&&(h.dataLoaderList.warehousesReference=!0,y.getInstance(S).getWarehouses().then(C=>{h.warehousesReference=C}).catch(u.noop)),h.warehousesReference}),Wr=f.computed(()=>{const h=A();return!h.propertyTypesReference&&!h.dataLoaderList.propertyTypesReference&&(h.dataLoaderList.propertyTypesReference=!0,y.getInstance(S).getPropertyTypes().then(C=>{h.propertyTypesReference=C}).catch(u.noop)),h.propertyTypesReference}),zr=f.computed(()=>{const h=A();return!h.priceCoefficientsReference&&!h.dataLoaderList.priceCoefficientsReference&&(h.dataLoaderList.priceCoefficientsReference=!0,y.getInstance(S).getPriceCoefficients().then(C=>{h.priceCoefficientsReference=C}).catch(u.noop)),h.priceCoefficientsReference});return{channelPrimaryInterestsReference:n,contactPositionsReference:r,currencyReference:e,opfReference:t,operatorReference:s,orderPaymentStatusReference:o,orderStatusReference:p,orderStatusDetailReference:g,paymentTypeReference:m,partnerGroupsReference:a,productFilesTypesReference:P,resourceTypesReference:R,salesDirectionsReference:ke,sourcePrimaryInterestsReference:de,deliveryTypeReference:ve,managersList:Pe,warehousesReference:Br,propertyTypesReference:Wr,priceCoefficientsReference:zr}});class $t{constructor(r){i(this,"name");i(this,"content");this.name=r.name,this.content=r.content}}class Mr{constructor(r){i(this,"resourceType");i(this,"resourceId");i(this,"h1");i(this,"title");i(this,"description");i(this,"keywords");i(this,"meta");i(this,"tags");var e;this.resourceType=new Ur(r==null?void 0:r.resourceType),this.resourceId=(r==null?void 0:r.resourceId)??"",this.h1=r==null?void 0:r.h1,this.title=r==null?void 0:r.title,this.description=r==null?void 0:r.description,this.keywords=r==null?void 0:r.keywords,this.meta=((e=r==null?void 0:r.meta)==null?void 0:e.map(t=>new $t(t)))??[],this.tags=r==null?void 0:r.tags}}class wi extends y{getResourceSeoData(r,e){return this.get(`/internal/seo/${r.slug}/${e}`,{},t=>new Mr(t.data))}saveResourceSeoData(r,e={}){return this.post(`/internal/seo/${r.resourceType.slug}/${r.resourceId}`,r,t=>new Mr(t.data),e)}deleteResourceSeoData(r,e){return this.delete(`/internal/seo/${r.slug}/${e}`)}}var Ie=(n=>(n[n.Undetermined=0]="Undetermined",n[n.Complete=1]="Complete",n[n.Incomplete=2]="Incomplete",n))(Ie||{});class Ee{constructor(r,e){i(this,"showFeedback",!1);i(this,"feedback","");i(this,"validationStatus");this.showFeedback=!!r,this.feedback=r,this.validationStatus=e}}class vi{static isBlocked(r,e){return e&&r===Ie.Incomplete}static getValidationResult(r,e){switch(r){case Ie.Incomplete:return e?new Ee("Адрес неполный, выберите более точный вариант из подсказок","error"):new Ee("Адрес неполный, проверьте его","warning");case Ie.Undetermined:return new Ee("Не удалось определить полноту адреса, проверьте его","warning");default:return}}}class Pi extends y{searchAddresses(r){return this.execSuggestionQuery("/public/suggestions/address",r)}searchBank(r){return this.execSuggestionQuery("/public/suggestions/bank",r)}searchOrganization(r){return this.execSuggestionQuery("/public/suggestions/organization",r)}execSuggestionQuery(r,e){return this.get(r,{query:e}).then(t=>{const s=[...t];let o=1;return s.forEach(p=>{p.id=o++}),s})}}var qr=(n=>(n.Admin="admin",n.Manager="manager",n.Operator="operator",n.Client="client",n.ExternalSeo="external_seo",n.Guest="guest",n))(qr||{});class It extends gr{constructor(e){super(e);i(this,"type");i(this,"canDoReclamations");i(this,"photo");i(this,"pricingRole");this.type=e==null?void 0:e.type,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.photo=e==null?void 0:e.photo,this.pricingRole=e!=null&&e.pricingRole?new pr(e.pricingRole):void 0}}class Di extends y{constructor(){super(),this.baseUrl=`${b().config.http.portalApiUrl}/api`,this.interceptorIds.request.authRequestInterceptor&&this.httpClient.interceptors.request.eject(this.interceptorIds.request.authRequestInterceptor)}getAccessToken(){return this.get("internal/users/current-tokens").then(r=>r.accessToken)}}class kt extends y{getCurrentUser(){return this.get("/internal/users/info",{},r=>new It(r.data),!0)}}const Hr=E.defineStore("common.user_state_private",()=>{const n=f.ref({}),r=f.ref(void 0),e=f.ref(void 0);return{dataLoaderList:n,currentUser:r,currentManager:e}});function dt(n){const r=Hr();(n==null?void 0:n.type)!==qr.Manager||r.currentManager||r.dataLoaderList.currentManager||(r.dataLoaderList.currentManager=!0,y.getInstance(Or).getManager(n.id).then(e=>{r.currentManager=e}).catch(u.noop).finally(()=>{r.dataLoaderList.currentManager=!1}))}const Ri=E.defineStore("common.user_state",()=>{const n=f.computed(()=>{const e=Hr();return!e.currentUser&&!e.dataLoaderList.currentUser&&(e.dataLoaderList.currentUser=!0,y.getInstance(kt).getCurrentUser().then(t=>{e.currentUser=t,dt(t)}).catch(u.noop).finally(()=>{e.dataLoaderList.currentUser=!1})),e.currentUser}),r=f.computed(()=>(dt(n.value),Hr().currentManager));return{currentUser:n,currentManager:r}});class Xe{constructor(r){i(this,"user");i(this,"salesDirection");this.user=new d(r==null?void 0:r.user),this.salesDirection=new _(r==null?void 0:r.salesDirection)}}class Ze extends Ae{constructor(e){var t,s;super(e);i(this,"cities");i(this,"users");this.cities=((t=e==null?void 0:e.cities)==null?void 0:t.map(o=>new ie(o)))??[],this.users=((s=e==null?void 0:e.users)==null?void 0:s.map(o=>new Xe(o)))??[]}}class Ti extends le{constructor(e){super();i(this,"id");i(this,"name");i(this,"abbr");this.id=e==null?void 0:e.id,this.name=e==null?void 0:e.name,this.abbr=e==null?void 0:e.abbr}resetFilterValue(e){switch(e){case"id":case"name":case"abbr":this[e]=void 0;break}return this}}class Si extends M{getRegionsList(r,e,t){return this.getTypedPaginated(Ae,"/internal/users/regions",r,e,t)}getRegion(r){return this.get(`/internal/users/regions/${r}`,{},e=>new Ze(e.data))}createRegion(r,e={}){return this.post("/internal/users/regions",r,t=>new Ze(t.data),e)}updateRegion(r,e,t={}){return this.patch(`/internal/users/regions/${r}`,e,s=>new Ze(s.data),t)}removeRegion(r){return this.delete(`/internal/users/regions/${r}`)}getRegionEmployees(r){return this.getTypedList(Xe,`/internal/users/regions/${r}/users`)}attachRegionEmployee(r,e,t){return this.post(`/internal/users/regions/${r}/users/${e}`,{salesDirectionId:t},s=>new Xe(s.data))}detachRegionEmployee(r,e,t){return this.request({method:"DELETE",url:`/internal/users/regions/${r}/users/${e}`,params:{sales_direction_id:t}})}}c.AddressQualityEnum=Ie,c.AddressQualityHelper=vi,c.AnyReference=Rt,c.AppBaseConfig=Jr,c.BankAccount=Qe,c.BasePaginationProvider=M,c.BlogPost=Ne,c.BlogPostMediaFile=_e,c.BlogPostMediaTypeEnum=Te,c.BlogPostPublicationStatusEnum=Se,c.BlogPostShortInfo=Z,c.BlogPostsListFilters=Lt,c.BlogProvider=Me,c.CalculationTypeEnum=Fr,c.CalendarHelper=w,c.Cart=ge,c.CartProvider=_t,c.CatalogProvider=Mt,c.CatalogableItem=nr,c.Category=j,c.CategoryFilter=it,c.CategoryFilterSetting=yr,c.CategoryFilterValue=tt,c.CategoryPricingRule=mr,c.ChannelPrimaryInterest=Rr,c.City=Tt,c.CityWithRegionAndCountry=ie,c.CityWithUserRegion=Nr,c.Client=Sr,c.ClientAdditionalData=ct,c.ClientCategory=be,c.ClientDataProvider=H,c.ClientPriceProvider=qt,c.ClientPriceTemplateProvider=Ht,c.ClientProduct=z,c.ClientProductCategoryDataProvider=zt,c.ClientProductDataProvider=jt,c.ClientShortInfo=J,c.ClientsAdditionalDataRequestTypeEnum=st,c.ClientsListFilters=Jt,c.CodedIdentity=pe,c.ConfiguratorProvider=Et,c.ConfiguratorsEnum=ut,c.Contact=Ve,c.ContactLinks=ur,c.ContactPerson=K,c.ContactPersonRelated=lt,c.ContactPosition=St,c.ContactRelation=Je,c.ContragentBase=vr,c.ContragentFactory=Oe,c.ContragentIc=Pr,c.ContragentPerson=nt,c.ContragentUlNr=ot,c.ContragentUlR=Dr,c.CostSourceEnum=Be,c.Country=re,c.CuratedDirection=ze,c.Curator=Ye,c.Currency=q,c.DataSuggestionProvider=Pi,c.DateHelper=Ke,c.DateTimeProvider=ri,c.DeletableNamedIdentity=wr,c.DeliveryAddress=ye,c.DeliveryType=W,c.DetailedJwtPayload=Fe,c.DeviceTypeResolutionConfig=Yr,c.DiscountShortInfo=xr,c.FieldValidationResultData=Ee,c.FilterGroup=V,c.FilterItem=er,c.FilterOpEnum=Ue,c.FilterSettings=rt,c.GeoCoordinates=ir,c.HiddenCatalogableItem=Xr,c.HttpCachedRequester=ae,c.HttpParamsConfig=Gr,c.HttpRequester=y,c.Identity=N,c.Image=Zr,c.InterceptorsEnum=U,c.JwtPayload=X,c.Manager=Y,c.ManagerCommon=We,c.ManagerDataFactory=ni,c.ManagerDataProvider=Or,c.MetaTagItem=$t,c.NamedIdentity=O,c.Offer=B,c.OfferActualization=gt,c.OfferActualizationStatus=Ce,c.OfferHelper=li,c.OfferShortInfo=$r,c.OffersDataProvider=ci,c.OffersListFilters=oi,c.Operator=kr,c.Opf=x,c.OpfEnum=G,c.Order=$,c.OrderAction=yt,c.OrderEditorData=ui,c.OrderInfo=Ir,c.OrderItem=mt,c.OrderItemBase=or,c.OrderPaymentStatus=At,c.OrderShortInfo=Ar,c.OrderStatus=$e,c.OrderStatusDetail=bt,c.OrderStatusDetailEnum=Dt,c.OrderStatusEnum=Pt,c.OrderStatusHistoryInfo=at,c.OrdersDataProvider=hi,c.OrdersListFilters=pi,c.PaginationFiltersBase=le,c.PartnerGroup=oe,c.PaymentType=dr,c.PreferencesStorageProvider=De,c.PriceAnalyze=xe,c.PriceAnalyzeProvider=fi,c.PriceCoefficient=ee,c.PriceCoefficientEnum=tr,c.PriceHistoryDataProvider=mi,c.PriceHistoryItem=wt,c.PriceTemplate=F,c.PriceTemplateCategory=je,c.PriceTemplateClient=fe,c.PriceTemplateICatalogableItem=hr,c.PriceTemplateProduct=Ge,c.PriceTemplateProvider=Yt,c.PricingRole=me,c.PricingRoleProvider=Gt,c.PrimaryCatalogableItem=He,c.Product=L,c.ProductCategoryDataProvider=Bt,c.ProductDataProvider=Wt,c.ProductFileType=Ot,c.ProductFilterTypeEnum=lr,c.ProductPriceCoefficient=qe,c.ProductPriceHistory=vt,c.ProductUnit=sr,c.ProfstroyOfferItem=ft,c.PropertiesProvider=Qt,c.Property=se,c.PropertyType=fr,c.PropertyTypeEnum=et,c.PropertyValue=ne,c.RecommendationsDataProvider=yi,c.RecommendationsList=_r,c.Reference=D,c.ReferenceDataFactory=ai,c.ReferenceDataProvider=S,c.Region=te,c.ResourceType=Ur,c.STANDARD_PERIOD_GROUPS=ti,c.STANDARD_PERIOD_SECTIONS=ii,c.SalesDirection=_,c.SentryConfig=Qr,c.Seo=Mr,c.SeoDataProvider=wi,c.SourcePrimaryInterest=Tr,c.StockCount=Er,c.TableDataPagination=Xt,c.TableDataPaginationRequestParams=pt,c.TableDataSortRequestParams=Zt,c.TemplateProductCategoryDataProvider=Vt,c.TemplatesListFilters=Ut,c.TypedInstanceFactory=k,c.UnitsHelper=br,c.UnknownClientDataProvider=Kt,c.UpdatableNamedIdentity=rr,c.User=It,c.UserAuthDataProvider=Di,c.UserCommonInfo=gr,c.UserDataProvider=kt,c.UserPricingRole=pr,c.UserRegion=Ze,c.UserRegionEmployee=Xe,c.UserRegionProvider=Si,c.UserRegionShortInfo=Ae,c.UserRegionsListFilters=Ti,c.UserShortInfo=d,c.UserTypeEnum=qr,c.VersionConfig=xt,c.Warehouse=ue,c.WebSocketConfig=Vr,c.currentOrderInjectionKey=gi,c.daysAgoIso=Ft,c.findCatalogItemByIdRecursive=ar,c.flattenCatalogItems=Cr,c.formatPercentChange=si,c.formatRelativeDate=ei,c.pluralize=ht,c.useAuthStateStore=Re,c.useBaseConfigStateStore=b,c.useReferencesStore=Ci,c.useUserStateStore=Ri,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|