@snabcentr/common-lib 1.76.2 → 1.77.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.
@@ -1,2 +1,2 @@
1
- (function(c,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("jwt-decode"),require("lodash-es"),require("ts-case-convert"),require("date-fns"),require("pinia"),require("vue"),require("axios")):typeof define=="function"&&define.amd?define(["exports","jwt-decode","lodash-es","ts-case-convert","date-fns","pinia","vue","axios"],T):(c=typeof globalThis<"u"?globalThis:c||self,T(c["SC Common Lib"]={},c["jwt-decode"],c["lodash-es"],c["ts-case-convert"],c["date-fns"],c.pinia,c.vue,c.axios))})(this,function(c,T,l,ne,g,J,m,Vr){"use strict";var $t=Object.defineProperty;var bt=(c,T,l)=>T in c?$t(c,T,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[T]=l;var t=(c,T,l)=>bt(c,typeof T!="symbol"?T+"":T,l);class q{constructor(r){t(this,"exp",0);t(this,"iat",0);t(this,"authTime",0);t(this,"jti","");t(this,"iss","");t(this,"aud",[]);t(this,"sub","");t(this,"typ","Bearer");t(this,"azp","");t(this,"sid","");t(this,"acr","");t(this,"allowedOrigins",[]);t(this,"realmAccess",{roles:[]});t(this,"resourceAccess",{});t(this,"scope","");t(this,"emailVerified",!1);t(this,"name","");t(this,"guid","");t(this,"preferredUsername","");t(this,"givenName","");t(this,"email","");l.merge(this,r)}static getJwtPayload(r){const e=T.jwtDecode(r),i=new q(ne.objectToCamel(e));return i.resourceAccess=e.resource_access,i}}class Fr extends q{constructor(e){super(e);t(this,"familyName");t(this,"middleName");t(this,"locale");t(this,"phoneNumber");t(this,"phoneNumberVerified");t(this,"address");l.merge(this,e)}static getJwtPayload(e){return new q(ne.objectToCamel(T.jwtDecode(e)))}}const ee=class ee{static init(r){ee.config=r}static getConfig(){if(l.isUndefined(ee.config))throw new Error("Config is undefined. Please set config by AppConfigProvider.init().");return ee.config}static loadRemoteConfig(r="/config.json"){const e=fetch(r).then(i=>i.ok?i.json():(console.error(new Error(`Ошибка загрузки ${r}: ${i.statusText}`)),new Promise(s=>{s({})})));return e.catch(i=>{console.error(i)}),e}};t(ee,"config");let A=ee;class oe{static getActualDataFromStorage(r){if(!this.isLocalStorageAvailable())return;let e=null;try{e=localStorage.getItem(r)}catch{return}if(e)try{const i=JSON.parse(e);if(!i.availableFor||g.isAfter(g.parseISO(i.availableFor)||g.startOfToday(),new Date)){if(l.isNil(i.data)||l.isEmpty(i.data))throw new Error("Data is empty");return i.data}}catch{try{localStorage.removeItem(r)}catch{}}}static saveActualDataToStorage(r,e,i){if(this.isLocalStorageAvailable())try{if(l.isNil(e)||l.isEmpty(e))throw new Error("Data is empty");const s=JSON.stringify({availableFor:i,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:i,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 i=localStorage.key(e);if(i)try{const s=localStorage.getItem(i);if(s){const o=JSON.parse(s);o.availableFor&&!g.isAfter(g.parseISO(o.availableFor)||g.startOfToday(),new Date)&&r.push(i)}}catch{r.push(i)}}r.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}catch{}}}function ur(n){try{const r=q.getJwtPayload(n);return new Date(r.exp*1e3)}catch{return}}const V=J.defineStore("__auth_state_private",()=>{const n=m.ref((()=>{var h;const o=oe.getActualDataFromStorage("sc.token");if(o)return Promise.resolve(o);const u=(h=A.getConfig().devMode)==null?void 0:h.initAuthBearerToken;return u?Promise.resolve(u):void 0})()),r=m.ref(void 0),e=m.ref(void 0),i=m.markRaw(new Map);function s(){e.value=void 0,l.isNil(n.value)||n.value.then(o=>{const u=q.getJwtPayload(o);e.value=u.exp*1e3>Date.now()?l.mapValues(u.resourceAccess,h=>(h==null?void 0:h.roles)??[]):void 0}).catch(l.noop)}return{jwtToken:n,jwtTokenUpdater:r,userPermissions:e,userPermissionsComputedRefs:i,recalculateUserPermissions:s}}),ve=J.defineStore("__auth_state",()=>{const n=m.computed(()=>{const o=V();if(l.isNil(o.jwtToken)&&!l.isNil(o.jwtTokenUpdater)){const u=o.jwtTokenUpdater();o.jwtToken=u,u.then(h=>{o.jwtToken=Promise.resolve(h),oe.saveActualDataToStorage("sc.token",h,ur(h)),o.recalculateUserPermissions()}).catch(l.noop)}return o.jwtToken});function r(o){V().jwtTokenUpdater=o}function e(o){const u=V();u.jwtToken=Promise.resolve(o),oe.saveActualDataToStorage("sc.token",o,ur(o)),u.recalculateUserPermissions()}function i(){const o=V();o.jwtToken=void 0,o.userPermissions=void 0,oe.saveActualDataToStorage("sc.token",void 0)}function s(o){const u=V();!l.isNil(u.jwtToken)&&l.isNil(u.userPermissions)&&u.jwtToken.then(w=>{const C=q.getJwtPayload(w);u.userPermissions=C.exp*1e3>Date.now()?l.mapValues(C.resourceAccess,I=>(I==null?void 0:I.roles)??[]):void 0}).catch(l.noop);const h=l.isArray(o)?o.join(" && "):o;if(u.userPermissionsComputedRefs.has(h))return u.userPermissionsComputedRefs.get(h);const y=m.computed(()=>{const w=C=>{var se;const I=l.split(C,".");if(I.length<2)return!1;const[Pe,we]=I,ie=(se=V().userPermissions)==null?void 0:se[Pe];return l.isArray(ie)&&ie.includes(we)};return l.isArray(o)?l.every(o,C=>w(C)):w(o)});return u.userPermissionsComputedRefs.set(h,y),y}return{jwtToken:n,setJwtTokenUpdater:r,setJwtToken:e,invalidateJwtToken:i,hasUserPermission:s}});class _{constructor(r,e){t(this,"id");t(this,"guid");this.id=r==null?void 0:r.id,l.isNil(this.id)&&(l.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==="":l.isNil(this.id)}}class a extends _{constructor(e){super(e);t(this,"name","");this.name=(e==null?void 0:e.name)??""}}class F extends a{constructor(e){super(e);t(this,"code","");this.code=(e==null?void 0:e.code)??""}}class de extends F{constructor(e){super(e);t(this,"slug");t(this,"type");this.slug=(e==null?void 0:e.slug)??""}}class Re extends de{constructor(e){super(e);t(this,"isPrimary");this.isPrimary=(e==null?void 0:e.isPrimary)??!1}}class ce extends Re{constructor(e){super(e);t(this,"isHidden");t(this,"parentCategoryId");t(this,"properties");t(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(([i,s])=>[l.toUpper(i),s])):void 0}}var Ue=(n=>(n.K0="k0",n.K1="k1",n.K2="k2",n.K3="k3",n.K4="k4",n.Retail="retail",n))(Ue||{});class v extends a{constructor(e){super(e);t(this,"slug");t(this,"description");this.description=e==null?void 0:e.description,this.slug=e==null?void 0:e.slug}}class ue extends v{static getRetailPriceCoefficient(){return{id:-2,slug:Ue.Retail,name:"Розн. цена",guid:"",isNewRec:l.constant(!0)}}}class De{constructor(r){t(this,"coefficient");t(this,"value");t(this,"cost");t(this,"percent");t(this,"readOnly");this.coefficient=new ue(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 je{constructor(r){t(this,"lat");t(this,"long");this.lat=(r==null?void 0:r.lat)??0,this.long=(r==null?void 0:r.long)??0}}class j extends v{}class le extends v{constructor(e){var i;super(e);t(this,"address");t(this,"isMain");t(this,"deliveryTypes");t(this,"regions");t(this,"coordinates");this.address=(e==null?void 0:e.address)??"",this.isMain=(e==null?void 0:e.isMain)??!1,this.deliveryTypes=((i=e==null?void 0:e.deliveryTypes)==null?void 0:i.map(s=>new j(s)))??[],this.regions=(e==null?void 0:e.regions)??[],this.coordinates=new je(e==null?void 0:e.coordinates)}}class lr{constructor(r){t(this,"warehouse");t(this,"count");this.warehouse=new le(r==null?void 0:r.warehouse),this.count=(r==null?void 0:r.count)??0}}class pr extends de{constructor(e){super(e);t(this,"isHidden");this.isHidden=(e==null?void 0:e.isHidden)??!1}}class hr{constructor(r,e){t(this,"image");t(this,"preview");t(this,"isDefault");this.image=`${e??""}${r.image}`,this.preview=`${e??""}${r.preview}`,this.isDefault=r.isDefault}}class S extends pr{constructor(e){var s,o,u,h;super(e);t(this,"supplierSku");t(this,"unit");t(this,"pack");t(this,"minCount");t(this,"quantityUnit");t(this,"currency");t(this,"currencySignature");t(this,"cost");t(this,"costRub");t(this,"costDate");t(this,"onOrder");t(this,"stockCount");t(this,"category");t(this,"categories");t(this,"images");t(this,"properties");t(this,"retailCost");t(this,"retailCostRub");t(this,"priceCoefficients");this.supplierSku=e==null?void 0:e.supplierSku,this.unit=(e==null?void 0:e.unit)??"",this.pack=e==null?void 0:e.pack,this.minCount=e==null?void 0:e.minCount,this.quantityUnit=e==null?void 0:e.quantityUnit,this.currency=(e==null?void 0:e.currency)??"",this.cost=(e==null?void 0:e.cost)??0,this.costRub=(e==null?void 0:e.costRub)??0,this.costDate=l.isString(e==null?void 0:e.costDate)?g.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(y=>new lr(y)))??[],this.currencySignature=(e==null?void 0:e.currencySignature)??"",this.type="product";const i=(e==null?void 0:e.category)??((o=e==null?void 0:e.categories)==null?void 0:o.find(y=>y.isPrimary));i&&(this.category=new Re({...i,isPrimary:!0}),this.categories=[this.category]),e!=null&&e.categories&&(this.categories=e.categories.map(y=>new Re(y))),this.images=((u=e==null?void 0:e.images)==null?void 0:u.map(y=>new hr(y,A.getConfig().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=((h=e==null?void 0:e.priceCoefficients)==null?void 0:h.map(y=>new De(y)))??[],e&&"codeNumber"in e&&!e.code&&(this.code=e==null?void 0:e.codeNumber)}getIsMeasurable(){var i;const e=(i=A.getConfig().catalog)==null?void 0:i.products.units;return[...(e==null?void 0:e.linear)??["пог.м.","м."],...(e==null?void 0:e.square)??["м2"]].includes(this.unit)}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}}class gr extends _{constructor(e){super(e);t(this,"category");t(this,"product");t(this,"quantity");t(this,"height");t(this,"length");t(this,"width");t(this,"barcode");t(this,"marker");t(this,"configurator");t(this,"configuratorParams");t(this,"dopProdaga");this.product=new S(e==null?void 0:e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new ce,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&l.cloneDeep(e.configuratorParams),this.dopProdaga=e.dopProdaga}}class mr extends gr{constructor(e){super(e);t(this,"currency");t(this,"cost");t(this,"costOne");t(this,"costOneRub");t(this,"costRub");t(this,"logicGroupId");t(this,"salesDirection");t(this,"specificationImgUrl");t(this,"sawing");this.currency=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=e.sawing}}class pe{constructor(r){t(this,"items");t(this,"resultSum");t(this,"directionsSum");this.items=r.items.map(e=>new mr(e)),this.resultSum=r.resultSum,this.directionsSum=r.directionsSum}}class Ae{static simpleInstanceInitializer(r){return new r}static instanceInitializer(r,e){return new r(e)}}const b=class b{constructor(){t(this,"httpClient");t(this,"baseUrl",`${A.getConfig().http.portalApiUrl}/api`);t(this,"errorResponseHandler",l.noop);t(this,"interceptorIds",{request:{},response:{}});t(this,"setBaseUrlRequestInterceptor",r=>(r.baseURL=this.baseUrl,r));t(this,"authRequestInterceptor",async r=>{let e;return l.isNil(ve().jwtToken)||(e=await ve().jwtToken),e&&r.headers.set("Authorization",`Bearer ${e}`),r});t(this,"dataConverterRequestInterceptor",r=>(r.method&&(r.method==="get"&&r.params&&(r.params=ne.objectToSnake(r.params)),["put","patch","post"].includes(l.toLower(r.method))&&r.data&&(r.data=ne.objectToSnake(r.data))),r));t(this,"authErrorsResponseInterceptors",r=>{var i;const e=r.rawError?(i=r.rawError)==null?void 0:i.config:void 0;return r.status===401?!e||e.__isRetryRequest?Promise.reject(r):(ve().invalidateJwtToken(),e.__isRetryRequest=!0,this.httpClient(e)):Promise.reject(r)});t(this,"dataConverterResponseInterceptor",r=>(r.data&&(r.data=ne.objectToCamel(r.data)),r));const r=A.getConfig().version;this.errorResponseHandler=b.defaultErrorsResponseHandler,this.httpClient=Vr.create({headers:{"APP-VERSION":`${r.name} (${r.version}, ${g.format(r.date,A.getConfig().dateFormats.uiDate)})`,Accept:"application/json","Content-Type":"application/json"}}),this.interceptorIds.request.setBaseUrlRequestInterceptor=this.httpClient.interceptors.request.use(this.setBaseUrlRequestInterceptor,e=>Promise.reject(e)),this.interceptorIds.request.authRequestInterceptor=this.httpClient.interceptors.request.use(this.authRequestInterceptor,e=>Promise.reject(e)),this.interceptorIds.request.dataConverterRequestInterceptor=this.httpClient.interceptors.request.use(this.dataConverterRequestInterceptor,e=>Promise.reject(e)),this.interceptorIds.response.convertHttpErrorResponseInterceptor=this.httpClient.interceptors.response.use(e=>e,e=>b.convertHttpErrorResponse(e)),this.interceptorIds.response.authErrorsResponseInterceptor=this.httpClient.interceptors.response.use(e=>e,this.authErrorsResponseInterceptors),this.interceptorIds.response.dataConverterResponseInterceptor=this.httpClient.interceptors.response.use(this.dataConverterResponseInterceptor,e=>Promise.reject(e))}static setDefaultErrorsResponseHandler(r){b.defaultErrorsResponseHandler=r}static getInstance(r){return Object.prototype.hasOwnProperty.call(b.instances,r.name)||(b.instances[r.name]=Ae.simpleInstanceInitializer(r)),b.instances[r.name]}static convertHttpErrorResponse(r){var e,i;if(!l.isNil(r.request)||!l.isNil(r.response)){const s=r==null?void 0:r.response;return Promise.reject({status:(s==null?void 0:s.status)??0,statusText:(s==null?void 0:s.statusText)??"Unknown",message:((e=s==null?void 0:s.data)==null?void 0:e.message)??"Unknown Error. Probably network error.",errors:(i=s==null?void 0:s.data)==null?void 0:i.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,i={},s=!1){const o=this.httpClient.request(r).then(u=>e?e(u):u.data);return o.catch(u=>{this.errorResponseHandler(u,i,s)}),o}get(r,e={},i=void 0,s=!1){return this.request({method:"GET",url:r,params:e},i,{},s)}getBlob(r,e={},i=void 0,s=!1){return this.request({method:"GET",url:r,params:e,responseType:"blob"},i,{},s)}patch(r,e={},i=void 0,s={},o=!1){return this.request({method:"PATCH",url:r,data:e},i,s,o)}post(r,e={},i=void 0,s={},o=!1){return this.request({method:"POST",url:r,data:e},i,s,o)}delete(r,e=void 0,i=!1){return this.request({method:"DELETE",url:r},e,{},i)}};t(b,"instances",{}),t(b,"defaultErrorsResponseHandler",l.noop);let f=b;class Kr extends f{getCart(r){return this.get(`internal/clients/${r.id}/cart`,{},e=>new pe(e.data))}deleteCart(r){return this.delete(`internal/clients/${r.id}/cart`)}addCartItem(r,e,i={}){return this.patch(`internal/clients/${r.id}/cart`,{id:e.configurator&&e.category.id,productId:e.product.id,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,dopProdaga:e.dopProdaga,...e.configuratorParams},s=>new pe(s.data),i)}patchCartItem(r,e,i={}){return this.patch(`internal/clients/${r.id}/cart/${e.id}`,{id:e.configurator&&e.category.id,productId:e.product.id,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,dopProdaga:e.dopProdaga,...e.configuratorParams},s=>new pe(s.data),i)}deleteCartItem(r,e){return this.get(`internal/clients/${r.id}/cart/${e.id}`,{})}addCartItemFromCSV(r,e){return this.post(`internal/clients/${r.id}/cart/add-products-from-csv`,e,i=>new pe(i.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||{}),ae=(n=>(n.Discount="discount",n.PriceTemplate="price_template",n.ClientPrice="client_price",n.Product="product",n))(ae||{}),yr=(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))(yr||{});class G extends ce{constructor(e){var i,s;super(e);t(this,"categories");t(this,"products");this.categories=(i=e==null?void 0:e.categories)==null?void 0:i.map(o=>new G(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new S(o))}}class Ge extends a{constructor(e){super(e);t(this,"updatedAt");this.updatedAt=l.isString(e==null?void 0:e.updatedAt)?g.parseISO(e.updatedAt):e==null?void 0:e.updatedAt}}class Cr extends Ge{constructor(e){super(e);t(this,"deletedAt");this.deletedAt=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class k extends a{constructor(e){super(e);t(this,"type");this.type=e==null?void 0:e.type}}class Pr extends a{constructor(e){super(e);t(this,"costCoefficient");t(this,"isLowPriceAllowed");t(this,"publishedAt");t(this,"description");t(this,"percent");t(this,"owner");t(this,"deletedAt");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.isLowPriceAllowed=(e==null?void 0:e.isLowPriceAllowed)??!1,this.publishedAt=l.isString(e==null?void 0:e.publishedAt)?g.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 k(e==null?void 0:e.owner),this.deletedAt=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class M extends Ge{constructor(e){super(e);t(this,"description");t(this,"createdAt");this.description=(e==null?void 0:e.description)??"",this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date}}class B extends S{constructor(e){super(e);t(this,"costCoefficient");t(this,"costSource");t(this,"discount");t(this,"priceTemplate");t(this,"isPreviouslyOrdered");t(this,"isRequired");t(this,"isFavorite");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.costSource=(e==null?void 0:e.costSource)??ae.Product,this.discount=e!=null&&e.discount?new Pr(e.discount):void 0,this.priceTemplate=e!=null&&e.priceTemplate?new M(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 Me{constructor(r){t(this,"phone");t(this,"email");this.phone=/^\d+$/.test(r.phone??"")?`+${r.phone}`:r.phone,this.email=r.email}}class L extends v{}class Te extends a{constructor(e){super(e);t(this,"salesDirection");t(this,"photo");t(this,"contacts");t(this,"isDefault");t(this,"isRegionalDirector");this.salesDirection=e!=null&&e.salesDirection?new L(e.salesDirection):new L,this.photo=e==null?void 0:e.photo,this.contacts=e!=null&&e.contacts?new Me(e.contacts):void 0,this.isDefault=(e==null?void 0:e.isDefault)??!1,this.isRegionalDirector=(e==null?void 0:e.isRegionalDirector)??!1}}class Se extends v{}class wr extends a{constructor(e){super(e);t(this,"description");t(this,"canChangeLowCost");t(this,"parentRoleId");this.description=e.description,this.canChangeLowCost=e.canChangeLowCost,this.parentRoleId=e.parentRoleId}}class he extends Te{constructor(e){var i;super(e);t(this,"isActive");t(this,"isSupervisor");t(this,"canDoReclamations");t(this,"createdAt");t(this,"supervisorId");t(this,"pricingRole");t(this,"curatedDirections");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=e==null?void 0:e.createdAt,this.supervisorId=e==null?void 0:e.supervisorId,this.pricingRole=e!=null&&e.pricingRole?new wr(e.pricingRole):void 0,this.curatedDirections=((i=e==null?void 0:e.curatedDirections)==null?void 0:i.map(s=>new Se(s)))??[]}}class Qr extends ce{constructor(e){super(e);t(this,"isDisabled");t(this,"isRequired");t(this,"isFavorite");t(this,"hidingComment");t(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 he(e.manager):void 0}}class ge extends Qr{constructor(e){var i,s;super(e);t(this,"categories");t(this,"products");this.categories=(i=e==null?void 0:e.categories)==null?void 0:i.map(o=>new ge(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new B(o))}}class Be{constructor(r){t(this,"priceCoefficient");t(this,"increasePercent");this.priceCoefficient=(r==null?void 0:r.priceCoefficient)&&new ue(r.priceCoefficient),this.increasePercent=r==null?void 0:r.increasePercent}}class $e extends Be{constructor(e){super(e);t(this,"productCategory");this.productCategory=new ce(e==null?void 0:e.productCategory)}}class be extends a{constructor(e){super(e);t(this,"photo");t(this,"contacts");t(this,"curatedDirection");this.photo=e.photo,this.contacts=new Me(e.contacts),this.curatedDirection=new Se(e.curatedDirection)}}class H extends v{}class K extends v{constructor(e){super(e);t(this,"country",new H);e&&(this.country=new H(e.country))}}class Ie extends v{constructor(e){super(e);t(this,"region",new K);e&&(this.region=new K(e.region))}}class He extends a{constructor(e){super(e);t(this,"phone");t(this,"email");t(this,"getNews");t(this,"salesDirection");t(this,"createdAt");t(this,"lastLoginAt");t(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 L(e.salesDirection):void 0,this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.lastLoginAt=l.isString(e==null?void 0:e.lastLoginAt)?g.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt,this.isActive=(e==null?void 0:e.isActive)??!1}}class Q extends He{constructor(e){var i,s;super(e);t(this,"salesDirection");t(this,"debt");t(this,"alternativeName");t(this,"city");t(this,"comment");t(this,"isPhoneApproved");t(this,"isEmailApproved");t(this,"managers");t(this,"curators");this.salesDirection=new L(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=((i=e==null?void 0:e.managers)==null?void 0:i.map(o=>new Te(o)))??[],this.curators=((s=e==null?void 0:e.curators)==null?void 0:s.map(o=>new be(o)))??void 0}}class Y extends _{constructor(e){super(e);t(this,"createdAt");t(this,"deletedAt");t(this,"client");t(this,"priceTemplate");this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.deletedAt=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt,this.client=new Q(e==null?void 0:e.client),this.priceTemplate=new M(e==null?void 0:e.priceTemplate)}}class ke extends Be{constructor(e){super(e);t(this,"product");this.product=new S(e==null?void 0:e.product)}}class ze extends v{}class X extends a{constructor(e){super(e);t(this,"type");t(this,"description");t(this,"metadata");this.type=new ze(e==null?void 0:e.type),this.description=(e==null?void 0:e.description)??"",this.metadata=e==null?void 0:e.metadata}}class z{constructor(r){t(this,"property");t(this,"value");this.property=new X(r==null?void 0:r.property),this.value=(r==null?void 0:r.value)??""}}class O{constructor(r){t(this,"from");t(this,"to");this.from=l.isString(r==null?void 0:r.from)?g.parseISO(r.from):(r==null?void 0:r.from)??null,this.to=l.isString(r==null?void 0:r.to)?g.parseISO(r.to):(r==null?void 0:r.to)??null}}class Yr{constructor(r){t(this,"id");t(this,"name");t(this,"description");t(this,"createdAt",new O);t(this,"updatedAt",new O);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.createdAt=new O(r==null?void 0:r.createdAt),this.updatedAt=new O(r==null?void 0:r.updatedAt)}resetFilterValue(r){switch(r){case"id":case"name":case"description":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,i,s,o;const r={};return Object.keys(this).forEach(u=>{const h=this[u];l.isNil(h)||l.isString(h)&&h.trim().length===0||l.isFunction(h.isNewRec)&&h.isNewRec()||(r[u]=h)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((i=r==null?void 0:r.createdAt)!=null&&i.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 Z extends a{constructor(e){super(e);t(this,"description");t(this,"canChangeLowCost");t(this,"parentRoleId");t(this,"subRoles",[]);t(this,"parentRole");t(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 We{constructor(r){t(this,"role");t(this,"category");t(this,"minCoefficient");this.role=new Z(r==null?void 0:r.role),this.category=new ce(r==null?void 0:r.category),this.minCoefficient=new ue(r==null?void 0:r.minCoefficient)}}class vr{constructor(r){t(this,"phone");t(this,"tablet");t(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 Rr{constructor(r){t(this,"portalApiUrl");t(this,"mediaUrl");t(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 Dr{constructor(r){t(this,"dsn");t(this,"environment");t(this,"ignoreErrors");t(this,"trace");t(this,"replay");t(this,"additionalParams");var e,i,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:((i=r==null?void 0:r.trace)==null?void 0:i.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 Ar{constructor(r){t(this,"date");t(this,"name");t(this,"version");this.date=l.isString(r==null?void 0:r.date)?g.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"}}class ar{constructor(r){t(this,"broadcaster");t(this,"key");t(this,"wsHost");t(this,"wsPort");t(this,"wssPort");t(this,"forceTLS");t(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 Xr{constructor(r){t(this,"environment");t(this,"devMode");t(this,"http");t(this,"deviceTypeByResolution");t(this,"sentry");t(this,"tableDefaultHeightCoefficient");t(this,"urls");t(this,"version");t(this,"websocket");t(this,"dateFormats");var e,i,s;this.environment=(r==null?void 0:r.environment)??"production",this.devMode=(r==null?void 0:r.devMode)??{},this.http=new Rr(r==null?void 0:r.http),this.deviceTypeByResolution=new vr(r==null?void 0:r.deviceTypeByResolution),this.sentry=new Dr({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.version=new Ar(r==null?void 0:r.version),this.websocket=r!=null&&r.websocket?new ar(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:((i=r==null?void 0:r.dateFormats)==null?void 0:i.uiDate)??"dd.MM.yyyy",uiDateWithTime:((s=r==null?void 0:r.dateFormats)==null?void 0:s.uiDateWithTime)??"dd.MM.yyyy HH:mm"}}}class Zr extends f{search(r,e=!1){return this.get("/internal/catalog/search",{term:r,show_hidden:e})}getPriceExportLink(r="csv",e=!1,i=void 0,s=void 0){let u=`${A.getConfig().http.portalApiUrl}/api/internal/price/export?format=${r}&show_hidden=${e}`;return i&&(u+=`&category_id=${i}`),s&&(u+=`&client_id=${s}`),u}}class xr extends f{importPrices(r,e){return this.post(`/internal/clients/${r}/price/import`,e)}updateCategoryPrices(r,e,i){var s;return this.patch(`/internal/clients/${r}/price/categories/${e}`,{price_coefficient_id:(s=i.coefficient)==null?void 0:s.id,increase_percent:i.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,i){return this.post(`/internal/clients/${r}/price/categories/${e}/disabled`,{comment:i})}unmarkCategoryDisabled(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/disabled`)}addCategoryManager(r,e,i){return this.post(`/internal/clients/${r}/price/categories/${e}/manager`,{manager_id:i})}removeCategoryManager(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/manager`)}updateProductPrice(r,e,i){var s;return this.patch(`/internal/clients/${r}/price/products/${e}`,{price_coefficient_id:(s=i.coefficient)==null?void 0:s.id,increase_percent:i.value},o=>new B(o.data))}removeProductPrice(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}`,i=>new B(i.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,i=>new Blob([i.data],{type:"text/html"}))}getCommercialOfferPdf(r,e){return this.getBlob(`/internal/clients/${r}/price/commercial-offer/download`,e,i=>new Blob([i.request.response],{type:"application/pdf"}))}sendCommercialOffer(r,e){return this.post(`/internal/clients/${r}/price/commercial-offer/send`,e)}}class Er extends f{getTemplateList(r){return this.get(`/internal/clients/${r}/price/templates`,{},e=>e.data.map(i=>new Y(i)))}getActiveTemplate(r){return this.get(`/internal/clients/${r}/price/templates/active`,{},e=>new Y(e.data),!0)}attachTemplate(r,e,i){const s=A.getConfig().dateFormats.api;return this.post(`/internal/clients/${r}/price/templates/${e}`,i&&{startAt:i.startAt&&g.format(i.startAt,s),endAt:i.endAt&&g.format(i.endAt,s)},o=>new Y(o.data),{},!0)}applyTemplate(r,e){return this.post(`/internal/clients/${r}/price/templates/${e}/apply`,{},void 0,{},!0)}changeTemplate(r,e,i,s){const o=A.getConfig().dateFormats.api;return this.patch(`/internal/clients/${r}/price/templates/${e}/${i}`,s&&{startAt:s.startAt&&g.format(s.startAt,o),endAt:s.endAt&&g.format(s.endAt,o)},u=>new Y(u.data))}detachTemplate(r,e,i){return this.delete(`/internal/clients/${r}/price/templates/${e}/${i}`)}}class et extends f{getRootCategoriesList(r=!1){return this.get("/internal/catalog/categories",{showHidden:r},e=>e.data.map(i=>new G(i)))}getCategoryData(r,e=!1,i=!1){return this.get(`/internal/catalog/categories/${r}`,{showHidden:e,withNestedCategories:i},s=>new G(s.data))}getPublicCategoryData(r){return this.get(`/public/catalog/categories/${r}`,{},e=>new G(e.data))}getCategoryProductsList(r,e=!0,i=!1){return this.get(`/internal/catalog/categories/${r}/products`,{showHidden:i,withPriceCoefficients:e},s=>l.map(s.data,o=>new S(o)))}getCategoryProductsCoefficients(r){return this.get(`/internal/catalog/categories/${r}/products/coefficients`,{},e=>{const{data:i}=e;return l.forEach(i,s=>s.map(o=>new De(o))),i})}publicSimpleSearch(r,e=10){return new Promise((i,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{i(o.categories.map(u=>new G(u)))}).catch(o=>{s(o)})})}}class rt extends f{getProductData(r,e=!1){return this.get(`/internal/catalog/products/${r}`,{withPriceCoefficients:e},i=>new S(i.data))}getPublicProductData(r){return this.get(`/public/catalog/products/${r}`,{},e=>new S(e.data))}getProductPriceCoefficients(r){return this.get(`/internal/catalog/products/${r}/coefficients`,{},e=>l.map(e.data,i=>new De(i)))}publicSimpleSearch(r,e=10){return new Promise((i,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{i(o.products.map(u=>new S(u)))}).catch(o=>{s(o)})})}}class tt extends f{getRootCategoriesList(r,e=!1){return this.get("/internal/catalog/categories",{clientId:r,showHidden:e},i=>i.data.map(s=>new ge(s)))}getCategoryData(r,e,i=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{clientId:r,showHidden:i,withNestedCategories:s},o=>new ge(o.data))}getCategoryProductsList(r,e,i=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{client_id:r,showHidden:s,withPriceCoefficients:i},o=>l.map(o.data,u=>new B(u)))}}class it extends f{getProductData(r,e,i=!1){return this.get(`/internal/catalog/products/${r}`,{clientId:e,withPriceCoefficients:i},s=>new B(s.data))}}var Le=(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))(Le||{});class Je{constructor(r){t(this,"field");t(this,"op");t(this,"value");this.field=(r==null?void 0:r.field)??"",this.op=(r==null?void 0:r.op)??Le.Equals,this.value=(r==null?void 0:r.value)??""}toPrimitive(){const r={field:this.field,op:this.op};return r.value=l.isDate(this.value)?g.format(this.value,A.getConfig().dateFormats.api):this.value,r}}class x{constructor(r){t(this,"groupOp");t(this,"filters");t(this,"groups");var e,i;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 Je(s)))??[],this.groups=((i=r==null?void 0:r.groups)==null?void 0:i.map(s=>new x(s)))??[]}toPrimitive(){return{groupOp:this.groupOp,filters:this.filters.map(r=>r instanceof Je&&l.isFunction(r.toPrimitive)?r.toPrimitive():r),groups:this.groups.map(r=>r instanceof x?r.toPrimitive():r)}}}class me extends f{getPaginated(r,e,i,s,o,u,h){let y={page:(s==null?void 0:s.page)??1,perPage:(s==null?void 0:s.pageSize)??10};return e&&(y.filters=JSON.stringify((e instanceof x?e:new x(e)).toPrimitive())),l.isEmpty(i)||(y.sort=l.isArray(i)?i:[i]),o&&(y={...y,...o}),this.get(r,y,u,h)}}class st extends me{getTemplateList(r,e,i){return this.getPaginated("/internal/price/templates",r,e,i,{},s=>{const o={...s.data};return o.data=o.data.map(u=>new M(u)),o})}createTemplate(r,e={}){return this.post("/internal/price/templates",r,i=>new M(i.data),e)}getTemplate(r){return this.get(`/internal/price/templates/${r}`,{},e=>new M(e.data))}updateTemplate(r,e,i={}){return this.patch(`/internal/price/templates/${r}`,e,s=>new M(s.data),i)}removeTemplate(r){return this.delete(`/internal/price/templates/${r}`)}getProductTemplatePrices(r){return this.get(`/internal/price/templates/${r}/products`,{},e=>e.data.map(i=>new ke(i)))}getProductTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/products/${e}`,{},i=>new ke(i.data))}saveProductTemplatePrice(r,e,i){var s;return this.post(`/internal/price/templates/${r}/products/${e}`,{price_coefficient_id:(s=i.coefficient)==null?void 0:s.id,increase_percent:i.value},o=>new ke(o.data))}deleteProductTemplatePrice(r,e){return this.delete(`/internal/price/templates/${r}/products/${e}`)}getCategoryTemplatePrices(r){return this.get(`/internal/price/templates/${r}/categories`,{},e=>e.data.map(i=>new $e(i)))}getCategoryTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/categories/${e}`,{},i=>new $e(i.data))}saveCategoryTemplatePrice(r,e,i,s=!1){var o;return this.request({method:"POST",url:`/internal/price/templates/${r}/categories/${e}`,data:{price_coefficient_id:(o=i.coefficient)==null?void 0:o.id,increase_percent:i.value},params:s?{recursively:!0}:{}},u=>new $e(u.data))}deleteCategoryTemplatePrice(r,e,i=!1){return this.request({method:"DELETE",url:`/internal/price/templates/${r}/categories/${e}`,params:i?{recursively:!0}:{}})}getTemplateClients(r){return this.get(`/internal/price/templates/${r}/clients`,{},e=>e.data.map(i=>new Y(i)))}}class nt extends f{getRoles(){return this.get("/internal/price/roles",{},r=>r.data.map(e=>new Z(e)))}createRole(r){return this.post("/internal/price/roles",r,e=>new Z(e.data))}getRole(r){return this.get(`/internal/price/roles/${r}`,{},e=>new Z(e.data))}updateRole(r,e){return this.patch(`/internal/price/roles/${r}`,e,i=>new Z(i.data))}deleteRole(r){return this.delete(`/internal/price/roles/${r}`)}getCategoryRules(r){return this.get(`/internal/price/roles/rules/categories/${r}`,{},e=>e.data.map(i=>new We(i)))}updateCategoryRules(r,e){return this.patch(`/internal/price/roles/rules/categories/${r}`,e,i=>i.data.map(s=>new We(s)))}}class ot extends me{getProperties(r,e,i){return this.getPaginated("/internal/catalog/properties",r,e,i,{},s=>{const o={...s.data};return o.data=o.data.map(u=>new X(u)),o})}createProperty(r){const{typeId:e,...i}=r;return this.post("/internal/catalog/properties",{...i,type:e},s=>new X(s.data))}getProperty(r){return this.get(`/internal/catalog/properties/${r}`,{},e=>new X(e.data))}updateProperty(r,e){const{typeId:i,...s}=e;return this.patch(`/internal/catalog/properties/${r}`,{...s,type:i},o=>new X(o.data))}deleteProperty(r){return this.delete(`/internal/catalog/properties/${r}`)}getProductProperties(r){return this.get(`/internal/catalog/products/${r}/properties`,{},e=>e.data.map(i=>new z(i)))}getProductProperty(r,e){return this.get(`/internal/catalog/products/${r}/properties/${e}`,{},i=>new z(i.data))}updateProductProperty(r,e,i){return this.patch(`/internal/catalog/products/${r}/properties/${e}`,{value:i},s=>new z(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,i){return this.patch(`/internal/catalog/products/${r}/properties/files/${e}`,i)}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.get(`/internal/catalog/categories/${r}/properties`,{},e=>e.data.map(i=>new z(i)))}getCategoryProperty(r,e){return this.get(`/internal/catalog/categories/${r}/properties/${e}`,{},i=>new z(i.data))}updateCategoryProperty(r,e,i){return this.patch(`/internal/catalog/categories/${r}/properties/${e}`,{value:i},s=>new z(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,i){return this.patch(`/internal/catalog/categories/${r}/properties/files/${e}`,i)}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})}}function Ve(n,r,e){let i;return n.some(s=>{if(s.type===e&&s.id===r)return i=s,!0;if(s.type==="product")return!1;const o=s;if(o.products&&o.products.length>0){const u=Ve(o.products,r,e);if(u)return i=u,!0}if(o.categories&&o.categories.length>0){const u=Ve(o.categories,r,e);if(u)return i=u,!0}return!1}),i}function Fe(n){const r=[];return n.forEach(e=>{if(r.push(e),e.type==="category"){const i=e;i.products&&i.products.length>0&&r.push(...Fe(i.products)),i.categories&&i.categories.length>0&&r.push(...Fe(i.categories))}}),r}var Tr=(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))(Tr||{}),N=(n=>(n.Person="individual",n.Ic="entrepreneur",n.UlR="legal",n.UlNr="non_resident_legal",n))(N||{});class Sr extends v{}class Ke extends v{}class ct extends v{}class $r extends v{}class fe extends a{constructor(e){super(e);t(this,"signature","");t(this,"symbol","");e&&(this.signature=e.signature??"",this.symbol=e.symbol??"")}}class d extends v{static generatePersonItem(){return new d({id:1,guid:"",slug:N.Person,name:""})}}class br extends v{}class Ir extends v{}class W extends v{}class kr extends v{}class Lr extends v{}class Qe extends v{}class Ye extends v{}class Oe extends _{constructor(e){super(e);t(this,"bankName","");t(this,"bic","");t(this,"accountNumber","");t(this,"correspondentAccount","");t(this,"currency",new fe);e&&(this.bankName=e.bankName??"",this.bic=e.bic??"",this.accountNumber=e.accountNumber??"",this.correspondentAccount=e.correspondentAccount??"",this.currency=new fe(e.currency))}}class Ne extends a{constructor(e){super(e);t(this,"phone");t(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 U extends Ne{constructor(e){super(e);t(this,"isPrimary");t(this,"position");t(this,"notDisturb");t(this,"comment");t(this,"updatedAt");t(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=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class Xe extends a{constructor(e){super(e);t(this,"opf",d.generatePersonItem());t(this,"partnerGroup",new W);t(this,"contacts",[]);t(this,"bankAccounts",[]);t(this,"comment");t(this,"alternativeName");t(this,"createdAt");t(this,"creator");t(this,"updatedAt");t(this,"updater");if(e){if(this.opf=new d(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e.createdAt,this.creator=e.creator?new k(e.creator):void 0,this.updatedAt=l.isString(e==null?void 0:e.updatedAt)?g.parseISO(e.updatedAt):e.updatedAt,this.updater=e.updater?new k(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new W(e.partnerGroup)),e.contacts){const i=[];e.contacts.forEach(s=>{i.push(new U(s))}),this.contacts=i}if(e.bankAccounts){const i=[];e.bankAccounts.forEach(s=>{i.push(new Oe(s))}),this.bankAccounts=i}}}}class Or extends Xe{constructor(r){super(r)}}class Ze extends Xe{constructor(e){super(e);t(this,"inn","");t(this,"okpo","");t(this,"directorName","");t(this,"directorPosition","");t(this,"directorActsOn","");t(this,"legalAddress","");t(this,"postalAddress","");t(this,"actualAddress","");e&&(this.inn=e.inn??"",this.okpo=e.okpo??"",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 xe extends Ze{constructor(e){super(e);t(this,"kpp","");e&&(this.kpp=e.kpp??"")}}class Nr extends xe{constructor(e){super(e);t(this,"registrationCountry",new H);t(this,"registrationNumber","");t(this,"taxNumber","");e&&(this.registrationCountry=new H(e.registrationCountry),this.registrationNumber=e.registrationNumber??"",this.taxNumber=e.taxNumber??"")}}class ye{static createInstance(r){switch(r.opf.slug){case N.Ic:return new Ze(r);case N.UlR:return new xe(r);case N.UlNr:return new Nr(r);default:return new Or(r)}}}class qe extends _{constructor(e){super(e);t(this,"isPrimary");this.isPrimary=e.isPrimary}}class qr extends U{constructor(e){super(e);t(this,"relations",{clients:[],contragents:[],addresses:[]});e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(i=>new qe(i))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(i=>new qe(i))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(i=>new qe(i))))}}class Ce extends Cr{constructor(e){var i;super(e);t(this,"address","");t(this,"coordinates");t(this,"contacts");t(this,"comment");t(this,"operatingHours");t(this,"isOneTime");t(this,"isTransportCompanyAddress");this.address=(e==null?void 0:e.address)??"",this.coordinates=new je(e==null?void 0:e.coordinates),this.contacts=((i=e==null?void 0:e.contacts)==null?void 0:i.map(s=>new U(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 Ee extends Q{constructor(e){var i,s,o,u;super(e);t(this,"contragents");t(this,"partnerGroups");t(this,"contacts");t(this,"deliveryAddresses");t(this,"channelPrimaryInterest");t(this,"sourcePrimaryInterest");t(this,"preferredDeliveryType");t(this,"primaryDemand");t(this,"preferredWarehouse");t(this,"extraData");this.contragents=((i=e==null?void 0:e.contragents)==null?void 0:i.map(h=>ye.createInstance(h)))??[],this.partnerGroups=((s=e==null?void 0:e.partnerGroups)==null?void 0:s.map(h=>new W(h)))??[],this.contacts=((o=e==null?void 0:e.contacts)==null?void 0:o.map(h=>new U(h)))??[],this.deliveryAddresses=((u=e==null?void 0:e.deliveryAddresses)==null?void 0:u.map(h=>new Ce(h)))??[],this.channelPrimaryInterest=new Ke(e==null?void 0:e.channelPrimaryInterest),this.sourcePrimaryInterest=new Ye(e==null?void 0:e.sourcePrimaryInterest),this.preferredDeliveryType=new j(e==null?void 0:e.preferredDeliveryType),this.primaryDemand=e==null?void 0:e.primaryDemand,this.preferredWarehouse=e!=null&&e.preferredWarehouse?new le(e.preferredWarehouse):void 0,this.extraData=(e==null?void 0:e.extraData)??{}}}class ut{constructor(r){t(this,"id");t(this,"name");t(this,"alternativeName");t(this,"searchTerm");t(this,"cities");t(this,"region");t(this,"country");t(this,"phone");t(this,"email");t(this,"isActive");t(this,"createdAt",new O);t(this,"lastLoginDate",new O);t(this,"lastLoginDateHasOrder");t(this,"managers");t(this,"curators");t(this,"isManagerRequired");t(this,"salesDirections");t(this,"contragentInn");t(this,"contragentType");t(this,"preferredDeliveryType");t(this,"partnerGroups");t(this,"contact");t(this,"lastOrder");var e,i,s,o,u,h,y,w;this.id=r==null?void 0:r.id,this.name=r==null?void 0:r.name,this.alternativeName=r==null?void 0:r.alternativeName,this.searchTerm=r==null?void 0:r.searchTerm,this.cities=(e=r==null?void 0:r.cities)==null?void 0:e.map(C=>new Ie(C)),this.region=new K(r==null?void 0:r.region),this.country=new H(r==null?void 0:r.country),this.phone=r==null?void 0:r.phone,this.email=r==null?void 0:r.email,this.isActive=r&&Object.prototype.hasOwnProperty.call(r,"isActive")?r==null?void 0:r.isActive:!0,this.createdAt=new O(r==null?void 0:r.createdAt),this.lastLoginDate=new O(r==null?void 0:r.lastLoginDate),this.lastLoginDateHasOrder=(r==null?void 0:r.lastLoginDateHasOrder)??void 0,this.managers=((i=r==null?void 0:r.managers)==null?void 0:i.map(C=>new he(C)))??[],this.curators=((s=r==null?void 0:r.curators)==null?void 0:s.map(C=>new be(C)))??[],this.salesDirections=(o=r==null?void 0:r.salesDirections)==null?void 0:o.map(C=>new L(C)),this.contragentInn=r==null?void 0:r.contragentInn,this.contragentType=new d(r==null?void 0:r.contragentType),this.preferredDeliveryType=new j(r==null?void 0:r.preferredDeliveryType),this.partnerGroups=(u=r==null?void 0:r.partnerGroups)==null?void 0:u.map(C=>new W(C)),this.contact=new Ne(r==null?void 0:r.contact),this.lastOrder={createdAt:new O((h=r==null?void 0:r.lastOrder)==null?void 0:h.createdAt),creator:(y=r==null?void 0:r.lastOrder)==null?void 0:y.creator,isApproved:(w=r==null?void 0:r.lastOrder)==null?void 0:w.isApproved}}resetFilterValue(r){switch(r){case"cities":this.cities=[];break;case"region":this.region=new K;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"lastOrder":this.lastOrder={};break;case"managers":this.managers=[];break;case"curators":this.curators=[];break;case"salesDirections":this.salesDirections=[];break;case"contragentType":this.contragentType=new d;break;case"preferredDeliveryType":this.preferredDeliveryType=new j;break;case"partnerGroups":this.partnerGroups=[];break;case"contact":this.contact=new Ne;break;default:this[r]=void 0;break}return this}asClearRaw(){var e,i,s,o;const r={};return Object.keys(this).forEach(u=>{const h=this[u];l.isNil(h)||l.isString(h)&&h.trim().length===0||l.isFunction(h.isNewRec)&&h.isNewRec()||(r[u]=h)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((i=r==null?void 0:r.createdAt)!=null&&i.to)&&delete r.createdAt,!((s=r==null?void 0:r.lastLoginDate)!=null&&s.from)&&!((o=r==null?void 0:r.lastLoginDate)!=null&&o.to)&&delete r.lastLoginDate,r}}class er extends _{constructor(e){super(e);t(this,"createdAt");t(this,"creator");t(this,"isApproved1c");this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.creator=new k(e==null?void 0:e.creator),this.isApproved1c=(e==null?void 0:e.isApproved1c)??!1}}class _r extends a{constructor(e){var i,s,o,u;super(e);t(this,"contacts",[]);t(this,"preferredDeliveryType");t(this,"partnerGroups",[]);t(this,"lastOrder");t(this,"salesDirection");t(this,"managers");t(this,"curators");this.contacts=((i=e.contacts)==null?void 0:i.map(h=>new U(h)))??void 0,this.lastOrder=e.lastOrder?new er(e.lastOrder):void 0,this.partnerGroups=((s=e.partnerGroups)==null?void 0:s.map(h=>new W(h)))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new j(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new L(e.salesDirection):void 0,this.managers=((o=e.managers)==null?void 0:o.map(h=>new Te(h)))??void 0,this.curators=((u=e.curators)==null?void 0:u.map(h=>new be(h)))??void 0}}class dr{constructor(r){t(this,"page",1);t(this,"pageSize",50);this.page=(r==null?void 0:r.page)??1,this.pageSize=(r==null?void 0:r.pageSize)??50}}class lt extends dr{constructor(e){super(e);t(this,"itemCount",0);t(this,"pageCount",1);t(this,"pageSlot",5);t(this,"pageSizes",[25,50,100]);t(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 pt{constructor(r){t(this,"field");t(this,"direction");this.field=(r==null?void 0:r.field)??"",this.direction=(r==null?void 0:r.direction)??"asc"}}class $ extends me{static transformClientDataToRequest(r){var i;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:(i=r.preferredWarehouse)==null?void 0:i.id}}static transformContragentClientDataToRequest(r){var u,h,y,w;let e;const i=r,s=r,o=r;switch(r.opf.slug){case N.Ic:e={opf:i.opf.slug,name:i.name,alternative_name:i.alternativeName,partner_group_id:(u=i.partnerGroup)==null?void 0:u.id,comment:i.comment,inn:i.inn,okpo:i.okpo,director_name:i.directorName,director_position:i.directorPosition,director_acts_on:i.directorActsOn,legal_address:i.legalAddress,postal_address:i.postalAddress,actual_address:i.actualAddress};break;case N.UlR:e={opf:s.opf.slug,name:s.name,alternative_name:s.alternativeName,partner_group_id:(h=s.partnerGroup)==null?void 0:h.id,comment:s.comment,inn:s.inn,kpp:s.kpp,okpo:s.okpo,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 N.UlNr:e={opf:o.opf.slug,name:o.name,alternative_name:o.alternativeName,partner_group_id:(y=o.partnerGroup)==null?void 0:y.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:(w=r.partnerGroup)==null?void 0:w.id,comment:r.comment};break}return e}static transformClientDeliveryAddressToRequest(r){var i,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:(i=r.coordinates)==null?void 0:i.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 Ee(e.data))}getClientsList(r,e,i,s){return this.getPaginated("/internal/clients",r,e,i,s,o=>{const u={...o.data};return u.data=u.data.map(h=>new Q(h)),u})}getClientByPhone(r){return this.getClientsList({groupOp:"and",groups:[],filters:[{field:"phone",op:Le.Contains,value:r}]})}getAdditionalClientsData(r,e){const i=r.map(s=>s.id);return this.post("/internal/clients/additional-data",{clients:i,requested_data_types:e},s=>{let o=[];return(s==null?void 0:s.data.length)>0&&(o=s.data.map(u=>new _r(u))),o})}getAllClientContacts(r){return this.get(`/internal/clients/${r}/contacts/all`,{},e=>{let i=[];return(e==null?void 0:e.data.length)>0&&(i=e.data.map(s=>new qr(s))),i})}createClientCommonData(r,e={}){return this.post("/internal/clients",$.transformClientDataToRequest(r),i=>new Ee(i.data),e)}updateClientCommonData(r,e={}){return this.patch(`/internal/clients/${r.id}`,$.transformClientDataToRequest(r),void 0,e)}updateClientNotDistribCommonData(r,e={}){const i={get_news:r.getNews};return this.patch(`/internal/clients/${r.id}`,i,void 0,e)}changeClientPassword(r,e,i,s={}){return this.patch(`/internal/clients/${r}`,{password:e,password_confirmation:i},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 i=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/attach`,{is_primary:s.isDefault}));await Promise.all(i)}async detachClientFromManagers(r,e){const i=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/detach`));await Promise.all(i)}attachToCurator(r,e,i){return this.patch(`/internal/clients/${r}/curators/${e}/attach`,{curated_direction_id:i.id})}detachFromCurator(r,e,i){return this.patch(`/internal/clients/${r}/curators/${e}/detach`,{curated_direction_id:i.id})}setCurators(r,e){return this.patch(`/internal/clients/${r}/curators`,{curators:e.map(i=>({curator_id:i.curatorId,curated_direction_id:i.curatedDirection.id}))})}createContragentClientData(r,e,i={}){return this.post(`/internal/clients/${r}/contragents`,$.transformContragentClientDataToRequest(e),s=>ye.createInstance(s.data),i)}updateContragentClientData(r,e,i={}){return this.patch(`/internal/clients/${r}/contragents/${e.id}`,$.transformContragentClientDataToRequest(e),s=>ye.createInstance(s.data),i)}deleteClientContragent(r,e){return this.delete(`/internal/clients/${r}/contragents/${e.id}`)}createClientDeliveryAddress(r,e,i={}){return this.post(`/internal/clients/${r}/delivery-addresses`,$.transformClientDeliveryAddressToRequest(e),s=>new Ce(s.data),i)}updateClientDeliveryAddress(r,e,i={}){return this.patch(`/internal/clients/${r}/delivery-addresses/${e.id}`,$.transformClientDeliveryAddressToRequest(e),s=>new Ce(s.data),i)}deleteClientDeliveryAddress(r,e){return this.delete(`/internal/clients/${r}/delivery-addresses/${e.id}`)}createContragentBankAccount(r,e,i,s={}){return this.post(`/internal/clients/${r}/contragents/${e}/bank-accounts`,$.transformClientContragentBankAccountToRequest(i),o=>new Oe(o.data),s)}updateContragentBankAccount(r,e,i,s={}){return this.patch(`/internal/clients/${r}/contragents/${e}/bank-accounts/${i.id}`,$.transformClientContragentBankAccountToRequest(i),o=>new Oe(o.data),s)}deleteContragentBankAccount(r,e,i){return this.delete(`/internal/clients/${r}/contragents/${e}/bank-accounts/${i.id}`)}createClientContact(r,e,i={}){return this.createContact(r,e,{client:{id:r,is_primary:e.isPrimary??!1,not_disturb:e.notDisturb??!1}},i)}updateClientContact(r,e,i={}){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 U(s.data),i)}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,i,s={}){return this.createContact(r,i,{contragents:[{id:e,is_primary:i.isPrimary??!1,not_disturb:i.notDisturb??!1}]},s)}setPrimaryContragentContact(r,e,i){return this.setPrimaryContact(`/internal/clients/${r}/contragents/${e}/contacts/${i.id}/primary`,i.isPrimary??!1)}detachContragentContact(r,e,i){return this.detachContact(`/internal/clients/${r}/contragents/${e}/contacts/${i.id}/detach`)}createDeliveryAddressContact(r,e,i,s={}){return this.createContact(r,i,{addresses:[{id:e,is_primary:i.isPrimary??!1,not_disturb:i.notDisturb??!1}]},s)}setPrimaryDeliveryAddressContact(r,e,i){return this.setPrimaryContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${i.id}/primary`,i.isPrimary??!1)}detachDeliveryAddressContact(r,e,i){return this.detachContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${i.id}/detach`)}createContact(r,e,i,s={}){var u,h;const o={name:e.name,position:e.position,comment:e.comment,...i};return(u=e.phone)!=null&&u.length&&(o.phone=e.phone),(h=e.email)!=null&&h.length&&(o.email=e.email),this.post(`/internal/clients/${r}/contacts`,o,y=>new U(y.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}`)}}const re=class re extends f{constructor(){super();t(this,"responseDataCacheTimeout");this.responseDataCacheTimeout=A.getConfig().http.responseDataCacheTimeout}static getCachedResponse(e){const i=re.responseDataCache.get(e);if(i&&i.validTo>new Date)return i.val}cacheResponse(e,i){re.responseDataCache.set(e,{validTo:g.addSeconds(new Date,this.responseDataCacheTimeout),val:i})}getTypedDataArrayRequester(e,i,s=!1,o={}){const u=i+(l.isEmpty(o)?"":` >>> ${JSON.stringify(o)}`),h=s?re.getCachedResponse(u):void 0;return h?Promise.resolve(h):this.get(i,o).then(y=>{const w=y.map(C=>Ae.instanceInitializer(e,C));return s&&w&&this.cacheResponse(i,w),w})}};t(re,"responseDataCache",new Map);let E=re;class ht extends f{checkPhoneIsBusy(r){return new Promise((e,i)=>{this.request({method:"GET",url:"/public/user/verification/phone/check",params:{phone:r}}).then(s=>{e(!!s.isBusy)}).catch(i)})}}class gt extends f{getConfiguratorSettings(r,e){var i;return this.get(`internal/catalog/categories/${r.id}/configurators/${(i=r.properties)==null?void 0:i.configurator}/settings?client_id=${e}`)}searchProduct(r,e,i,s={}){var u;const o=this.get(`internal/catalog/categories/${r.id}/configurators/${(u=r.properties)==null?void 0:u.configurator}/product`,{params:i,client_id:e},h=>new S(h.data));return o.catch(h=>{this.errorResponseHandler(h,s)}),o}createTemplate(r,e,i,s={}){var o;return this.post(`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/template?client_id=${e}`,{...i},()=>{},s)}removeTemplate(r,e,i){var s;return this.delete(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/template/${i}?client_id=${e}`)}}class mt{static defaultDateRanges(){const r=g.addBusinessDays(new Date,1);return{nextWorkingDay:{label:"Следующий рабочий день",from:g.startOfDay(r),to:g.endOfDay(r)},today:{label:"Сегодня",from:g.startOfToday(),to:g.endOfToday()},yesterday:{label:"Вчера",from:g.startOfYesterday(),to:g.endOfYesterday()},tomorrow:{label:"Завтра",from:g.startOfTomorrow(),to:g.endOfTomorrow()}}}}const te=class te{static setLinearValues(r){te.linearValues=r}static productIsMeasurable(r){return te.linearValues.includes(r.unit)}static getProductMultiplicity(r){var e,i;return!((e=r.properties)!=null&&e.ignoreMinCountCheck)&&((i=r.properties)!=null&&i.minCount)&&!te.productIsMeasurable(r)?r.properties.minCount:1}static getProductLengthMultiplicity(r){var e,i,s;return(e=r.properties)!=null&&e.lengthStep?r.properties.lengthStep:!((i=r.properties)!=null&&i.ignoreMinCountCheck)&&((s=r.properties)!=null&&s.minCount)?r.properties.minCount:.01}};t(te,"linearValues",["пог.м.","м.","м2"]);let rr=te;class ft{static generateUndefinedManagerInstance(){return new he({id:0,name:"- Не назначен -",isActive:!0,guid:"-undefined-"})}static isUndefinedManagerInstance(r){return r.id===0&&r.guid==="-undefined-"}}class Ur extends E{async getManagers(){const r="/internal/managers",e=E.getCachedResponse(r);if(e)return e;const s=(await this.get(r)).data.map(o=>Ae.instanceInitializer(he,o));return this.cacheResponse(r,s),s}}class tr extends er{constructor(e){var i,s,o,u,h,y,w,C;super(e);t(this,"client");t(this,"payment");t(this,"delivery");t(this,"attachedUser");t(this,"status");t(this,"salesDirection");t(this,"pendingAt");t(this,"processedAt");t(this,"isOnOrder");t(this,"isNotInStock");this.client=new Q(e==null?void 0:e.client),this.payment={type:((i=e==null?void 0:e.payment)==null?void 0:i.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:((u=e==null?void 0:e.delivery)==null?void 0:u.type)??-1,date:l.isString((h=e==null?void 0:e.delivery)==null?void 0:h.date)?g.parseISO(e.delivery.date):((y=e==null?void 0:e.delivery)==null?void 0:y.date)??new Date,address:(w=e==null?void 0:e.delivery)!=null&&w.address?new Ce(e.delivery.address):void 0,warehouse:(C=e==null?void 0:e.delivery)!=null&&C.warehouse?new le(e.delivery.warehouse):void 0},this.attachedUser=new k(e==null?void 0:e.attachedUser),this.status=(e==null?void 0:e.status)??0,this.salesDirection=new L(e==null?void 0:e.salesDirection),this.pendingAt=l.isString(e==null?void 0:e.pendingAt)?g.parseISO(e.pendingAt):e==null?void 0:e.pendingAt,this.processedAt=l.isString(e==null?void 0:e.processedAt)?g.parseISO(e.processedAt):e==null?void 0:e.processedAt,this.isOnOrder=(e==null?void 0:e.isOnOrder)??!1,this.isNotInStock=(e==null?void 0:e.isNotInStock)??!1}}class jr extends _{constructor(e){super(e);t(this,"product");t(this,"quantity");t(this,"currency");t(this,"costOne");t(this,"costOneRub");t(this,"cost");t(this,"costRub");t(this,"marker");t(this,"height");t(this,"length");t(this,"width");t(this,"logicGroupId");t(this,"salesDirection");t(this,"specificationImgUrl");t(this,"configurator");t(this,"configuratorParams");t(this,"sawing");t(this,"creatorUser");this.product=new B(e.product),this.quantity=e.quantity,this.currency=e.currency,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.cost=e.cost,this.costRub=e.costRub,this.marker=e.marker,this.height=e.height,this.length=e.length,this.width=e.width,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams,this.sawing=e.sawing,this.creatorUser=e.creatorUser&&new k(e.creatorUser)}}class ir extends tr{constructor(e){super(e);t(this,"products");t(this,"invoices");t(this,"comment");t(this,"image");t(this,"contragent");t(this,"barcode");t(this,"orderSource");t(this,"isAllowProcessingWithoutPayment");this.products=(e.products??[]).map(i=>new jr(i)),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?ye.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new v(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment}}class yt extends me{getOrders(r,e,i){return this.getPaginated("/internal/orders",r,e?[e]:void 0,i,{},s=>{const o={...s.data};return o.data=o.data.map(u=>new tr(u)),o})}getClientOrderStatistics(r,e){return this.get(`/internal/clients/${r}/orders/statistics`,e?{period:e}:{})}getOrder(r){return this.get(`/internal/orders/${r}`,{},e=>new ir(e.data))}addOrderProduct(r,e,i={}){return this.post(`/internal/orders/${r}/products`,{id:e.configurator&&e.category.id,productId:e.product.id,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,dopProdaga:e.dopProdaga,...e.configuratorParams},s=>new ir(s.data),i)}}class _e{constructor(r){t(this,"client");t(this,"product");t(this,"cost");t(this,"costCoefficient");t(this,"source");this.client=new Q(r==null?void 0:r.client),this.product=new S(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)??ae.Product}}const sr=n=>{var r,e,i,s,o;return n?l.omitBy({cities:(r=n.cities)==null?void 0:r.map(u=>u.id),clients:(e=n.clients)==null?void 0:e.map(u=>u.id),managers:(i=n.managers)==null?void 0:i.map(u=>u.id),partnerGroups:(s=n.partnerGroups)==null?void 0:s.map(u=>u.id),salesDirections:(o=n.salesDirections)==null?void 0:o.map(u=>u.id),hideNotActive:n.hideNotActive},u=>l.isNil(u)||(l.isArray(u)||l.isObject(u))&&l.isEmpty(u)):{}},Gr=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 Ct extends f{analyzeProductPrices(r,e,i){return this.get(`/internal/price/products/${r}/analyze`,{...Gr(e),filters:sr(i)},s=>s.data.map(o=>new _e(o)))}analyzeCategoryPrices(r,e,i){return this.get(`/internal/price/categories/${r}/analyze`,{...Gr(e),filters:sr(i)},s=>s.data.map(o=>new _e(o)))}analyzeCategoryPricesBySquare(r,e,i){return this.get(`/internal/price/categories/${r}/analyze/square`,{...e,filters:sr(i)},s=>s.data.map(o=>new _e(o)))}}class Mr{constructor(r){t(this,"cost");t(this,"isLowCost");t(this,"isRetail");t(this,"costDate");t(this,"discountName");t(this,"priceTemplateName");t(this,"product");t(this,"client");t(this,"executor");t(this,"currency");this.cost=r.cost??0,this.isLowCost=r.isLowCost??!1,this.isRetail=r.isRetail??!1,this.costDate=l.isString(r.costDate)?g.parseISO(r.costDate):r.costDate??new Date,this.discountName=r.discountName,this.priceTemplateName=r.priceTemplateName,this.product=r.product?new F(r.product):void 0,this.client=r.client?new k(r.client):void 0,this.executor=r.executor?new k(r.executor):void 0,this.currency=r.currency?new fe(r.currency):void 0}}class Br extends F{constructor(e){super(e);t(this,"history");this.history=l.map(e.history,i=>new Mr(i))}}class Pt extends f{getProductPriceHistory(r){var o,u,h,y,w;const e=A.getConfig().dateFormats.api,i=l.omitBy(l.merge(r,{costDate:{from:l.isDate((o=r.costDate)==null?void 0:o.from)?g.format(r.costDate.from,e):(u=r.costDate)==null?void 0:u.from,to:l.isDate((h=r.costDate)==null?void 0:h.to)?g.format(r.costDate.to,e):(y=r.costDate)==null?void 0:y.to}}),C=>l.isNil(C)||(l.isArray(C)||l.isObject(C))&&l.isEmpty(C)),s=((w=r.product)==null?void 0:w[0])??0;return delete i.product,this.get(`/internal/price/products/${s}/history`,i).then(C=>[new Br(l.merge(C[0],{history:C}))])}}class nr{constructor(r){t(this,"products",[]);t(this,"productCategories",[]);r!=null&&r.products&&(this.products=r.products.map(e=>new F(e))),r!=null&&r.productCategories&&(this.productCategories=r.productCategories.map(e=>new F(e)))}}class wt extends f{getProductCategoryRecommendations(r){return this.get(`/internal/catalog/recommendations/categories/${r.id}`,{},e=>new nr(e.data))}getProductRecommendations(r){return this.get(`/internal/catalog/recommendations/products/${r.id}`,{},e=>new nr(e.data))}saveProductCategoryRecommendations(r,e){return this.post(`/internal/catalog/recommendations/categories/${r.id}`,{product_categories:e.productCategories.map(i=>i.id),products:e.products.map(i=>i.id)})}saveProductRecommendations(r,e){return this.post(`/internal/catalog/recommendations/products/${r.id}`,{product_categories:e.productCategories.map(i=>i.id),products:e.products.map(i=>i.id)})}}class R extends E{getReference(r,e=!1){return this.getTypedDataArrayRequester(Sr,`/internal/references/${r}`,e)}getChannelPrimaryInterest(){return this.getTypedDataArrayRequester(Ke,"/internal/references/channel-primary-interest",!0)}getContactPositions(){return this.getTypedDataArrayRequester($r,"/internal/references/contact-position",!0)}getCuratedDirection(){return this.getTypedDataArrayRequester(Se,"/internal/references/curated-direction",!0)}getCurrency(){return this.getTypedDataArrayRequester(fe,"/public/references/currency",!0)}getPartnerGroup(){return this.getTypedDataArrayRequester(W,"/internal/references/partner-group",!0)}getOpf(){return this.getTypedDataArrayRequester(d,"/public/references/opf",!0)}getOrderPaymentStatuses(){return this.getTypedDataArrayRequester(br,"/public/references/order-payment-status",!0)}getOrderStatuses(){return this.getTypedDataArrayRequester(Ir,"/public/references/order-status",!0)}getPaymentTypes(){return this.getTypedDataArrayRequester(kr,"/public/references/payment-type",!0)}getResourceTypes(){return this.getTypedDataArrayRequester(Qe,"/internal/references/resource-type",!0)}getSalesDirections(){return this.getTypedDataArrayRequester(L,"/public/references/sales-direction",!0)}getSourcePrimaryInterest(){return this.getTypedDataArrayRequester(Ye,"/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(K,`/internal/references/region-with-country/search?term=${r}`)}searchCountry(r){return this.getTypedDataArrayRequester(H,`/internal/references/country/search?term=${r}`)}getDeliveryTypes(){return this.getTypedDataArrayRequester(j,"/internal/references/delivery-type",!0)}getWarehouses(){return this.getTypedDataArrayRequester(le,"/public/references/warehouse",!0)}getPropertyTypes(){return this.getTypedDataArrayRequester(ze,"/internal/references/property-type",!0)}getPriceCoefficients(){return this.getTypedDataArrayRequester(ue,"/internal/references/price-coefficient",!0)}getProductFileType(){return this.getTypedDataArrayRequester(Lr,"/public/references/product-file-type",!0)}}const D=J.defineStore("__references_private",()=>{const n=m.ref({}),r=m.ref(void 0),e=m.ref(void 0),i=m.ref(void 0),s=m.ref(void 0),o=m.ref(void 0),u=m.ref(void 0),h=m.ref(void 0),y=m.ref(void 0),w=m.ref(void 0),C=m.ref(void 0),I=m.ref(void 0),Pe=m.ref(void 0),we=m.ref(void 0),ie=m.ref(void 0),se=m.ref(void 0),cr=m.ref(void 0),p=m.ref(void 0);return{dataLoaderList:n,channelPrimaryInterestReference:r,contactPositionsReference:e,currencyReference:i,deliveryTypeReference:s,managersList:o,opfReference:u,orderPaymentStatusReference:h,orderStatusReference:y,paymentTypeReference:w,partnerGroupReference:C,productFileTypeReference:I,resourceTypesReference:Pe,salesDirectionsReference:we,sourcePrimaryInterestReference:ie,warehousesReference:se,propertyTypesReference:cr,priceCoefficientsReference:p}}),vt=J.defineStore("references",()=>{const n=m.computed(()=>{const p=D();return!p.channelPrimaryInterestReference&&!p.dataLoaderList.channelPrimaryInterestReference&&(p.dataLoaderList.channelPrimaryInterestReference=!0,f.getInstance(R).getChannelPrimaryInterest().then(P=>{p.channelPrimaryInterestReference=P}).catch(l.noop)),p.channelPrimaryInterestReference}),r=m.computed(()=>{const p=D();return!p.contactPositionsReference&&!p.dataLoaderList.contactPositionsReference&&(p.dataLoaderList.contactPositionsReference=!0,f.getInstance(R).getContactPositions().then(P=>{p.contactPositionsReference=P}).catch(l.noop)),p.contactPositionsReference}),e=m.computed(()=>{const p=D();return!p.currencyReference&&!p.dataLoaderList.currencyReference&&(p.dataLoaderList.currencyReference=!0,f.getInstance(R).getCurrency().then(P=>{p.currencyReference=P}).catch(l.noop)),p.currencyReference}),i=m.computed(()=>{const p=D();return!p.opfReference&&!p.dataLoaderList.opfReference&&(p.dataLoaderList.opfReference=!0,f.getInstance(R).getOpf().then(P=>{p.opfReference=P}).catch(l.noop)),p.opfReference}),s=m.computed(()=>{const p=D();return!p.orderPaymentStatusReference&&!p.dataLoaderList.orderPaymentStatusReference&&(p.dataLoaderList.orderPaymentStatusReference=!0,f.getInstance(R).getOrderPaymentStatuses().then(P=>{p.orderPaymentStatusReference=P}).catch(l.noop)),p.orderPaymentStatusReference}),o=m.computed(()=>{const p=D();return!p.orderStatusReference&&!p.dataLoaderList.orderStatusReference&&(p.dataLoaderList.orderStatusReference=!0,f.getInstance(R).getOrderStatuses().then(P=>{p.orderStatusReference=P}).catch(l.noop)),p.orderStatusReference}),u=m.computed(()=>{const p=D();return!p.paymentTypeReference&&!p.dataLoaderList.paymentTypeReference&&(p.dataLoaderList.paymentTypeReference=!0,f.getInstance(R).getPaymentTypes().then(P=>{p.paymentTypeReference=P}).catch(l.noop)),p.paymentTypeReference}),h=m.computed(()=>{const p=D();return!p.partnerGroupReference&&!p.dataLoaderList.partnerGroupReference&&(p.dataLoaderList.partnerGroupReference=!0,f.getInstance(R).getPartnerGroup().then(P=>{p.partnerGroupReference=P}).catch(l.noop)),p.partnerGroupReference}),y=m.computed(()=>{const p=D();return!p.productFileTypeReference&&!p.dataLoaderList.productFileTypeReference&&(p.dataLoaderList.productFileTypeReference=!0,f.getInstance(R).getProductFileType().then(P=>{p.productFileTypeReference=P}).catch(l.noop)),p.productFileTypeReference}),w=m.computed(()=>{const p=D();return!p.resourceTypesReference&&!p.dataLoaderList.resourceTypesReference&&(p.dataLoaderList.resourceTypesReference=!0,f.getInstance(R).getResourceTypes().then(P=>{p.resourceTypesReference=P}).catch(l.noop)),p.resourceTypesReference}),C=m.computed(()=>{const p=D();return!p.salesDirectionsReference&&!p.dataLoaderList.salesDirectionsReference&&(p.dataLoaderList.salesDirectionsReference=!0,f.getInstance(R).getSalesDirections().then(P=>{p.salesDirectionsReference=P}).catch(l.noop)),p.salesDirectionsReference}),I=m.computed(()=>{const p=D();return!p.sourcePrimaryInterestReference&&!p.dataLoaderList.sourcePrimaryInterestReference&&(p.dataLoaderList.sourcePrimaryInterestReference=!0,f.getInstance(R).getSourcePrimaryInterest().then(P=>{p.sourcePrimaryInterestReference=P}).catch(l.noop)),p.sourcePrimaryInterestReference}),Pe=m.computed(()=>{const p=D();return!p.deliveryTypeReference&&!p.dataLoaderList.deliveryTypeReference&&(p.dataLoaderList.deliveryTypeReference=!0,f.getInstance(R).getDeliveryTypes().then(P=>{p.deliveryTypeReference=P}).catch(l.noop)),p.deliveryTypeReference}),we=m.computed(()=>{const p=D();return!p.managersList&&!p.dataLoaderList.managersList&&(p.dataLoaderList.managersList=!0,f.getInstance(Ur).getManagers().then(P=>{p.managersList=P}).catch(l.noop)),p.managersList}),ie=m.computed(()=>{const p=D();return!p.warehousesReference&&!p.dataLoaderList.warehousesReference&&(p.dataLoaderList.warehousesReference=!0,f.getInstance(R).getWarehouses().then(P=>{p.warehousesReference=P}).catch(l.noop)),p.warehousesReference}),se=m.computed(()=>{const p=D();return!p.propertyTypesReference&&!p.dataLoaderList.propertyTypesReference&&(p.dataLoaderList.propertyTypesReference=!0,f.getInstance(R).getPropertyTypes().then(P=>{p.propertyTypesReference=P}).catch(l.noop)),p.propertyTypesReference}),cr=m.computed(()=>{const p=D();return!p.priceCoefficientsReference&&!p.dataLoaderList.priceCoefficientsReference&&(p.dataLoaderList.priceCoefficientsReference=!0,f.getInstance(R).getPriceCoefficients().then(P=>{p.priceCoefficientsReference=P}).catch(l.noop)),p.priceCoefficientsReference});return{channelPrimaryInterestsReference:n,contactPositionsReference:r,currencyReference:e,opfReference:i,orderPaymentStatusReference:s,orderStatusReference:o,paymentTypeReference:u,partnerGroupsReference:h,productFilesTypesReference:y,resourceTypesReference:w,salesDirectionsReference:C,sourcePrimaryInterestsReference:I,deliveryTypeReference:Pe,managersList:we,warehousesReference:ie,propertyTypesReference:se,priceCoefficientsReference:cr}});class Hr{constructor(r){t(this,"name");t(this,"content");this.name=r.name,this.content=r.content}}class or{constructor(r){t(this,"resourceType");t(this,"resourceId");t(this,"h1");t(this,"title");t(this,"description");t(this,"keywords");t(this,"meta");var e;this.resourceType=new Qe(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(i=>new Hr(i)))??[]}}class Rt extends f{getResourceSeoData(r,e){return this.get(`/internal/seo/${r.slug}/${e}`,{},i=>new or(i.data))}saveResourceSeoData(r,e={}){return this.post(`/internal/seo/${r.resourceType.slug}/${r.resourceId}`,r,i=>new or(i.data),e)}deleteResourceSeoData(r,e){return this.delete(`/internal/seo/${r.slug}/${e}`)}}class Dt extends f{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(i=>{const s=[...i];let o=1;return s.forEach(u=>{u.id=o++}),s})}}var zr=(n=>(n.Admin="admin",n.Manager="manager",n.Operator="operator",n.Client="client",n.Guest="guest",n))(zr||{});class Wr extends He{constructor(e){super(e);t(this,"type");t(this,"canDoReclamations");t(this,"photo");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}}class At extends f{constructor(){super(),this.baseUrl=`${A.getConfig().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 Jr extends f{getCurrentUser(){return this.get("/internal/users/info",{},r=>new Wr(r.data),!0)}}const at=J.defineStore("__user_state_private",()=>{const n=m.ref({}),r=m.ref(void 0);return{dataLoaderList:n,currentUser:r}}),Tt=J.defineStore("user_state",()=>({currentUser:m.computed(()=>{const r=at();return!r.currentUser&&!r.dataLoaderList.currentUser&&(r.dataLoaderList.currentUser=!0,f.getInstance(Jr).getCurrentUser().then(e=>{r.currentUser=e}).catch(l.noop).finally(()=>{r.dataLoaderList.currentUser=!1})),r.currentUser})}));class St{constructor(r,e){t(this,"showFeedback",!1);t(this,"feedback","");t(this,"validationStatus");this.showFeedback=!!r,this.feedback=r,this.validationStatus=e}}c.AnyReference=Sr,c.AppBaseConfig=Xr,c.AppConfigProvider=A,c.BankAccount=Oe,c.BasePaginationProvider=me,c.CalculationTypeEnum=fr,c.Cart=pe,c.CartItem=mr,c.CartItemBase=gr,c.CartProvider=Kr,c.CatalogProvider=Zr,c.CatalogableItem=de,c.Category=G,c.CategoryPricingRule=We,c.ChannelPrimaryInterest=Ke,c.City=ct,c.CityWithRegionAndCountry=Ie,c.Client=Ee,c.ClientAdditionalData=_r,c.ClientCategory=ge,c.ClientDataProvider=$,c.ClientPriceProvider=xr,c.ClientPriceTemplateProvider=Er,c.ClientProduct=B,c.ClientProductCategoryDataProvider=tt,c.ClientProductDataProvider=it,c.ClientShortInfo=Q,c.ClientsAdditionalDataRequestTypeEnum=Tr,c.ClientsListFilters=ut,c.CodedIdentity=F,c.ConfiguratorProvider=gt,c.Contact=Ne,c.ContactLinks=Me,c.ContactPerson=U,c.ContactPersonRelated=qr,c.ContactPosition=$r,c.ContactRelation=qe,c.ContragentBase=Xe,c.ContragentFactory=ye,c.ContragentIc=Ze,c.ContragentPerson=Or,c.ContragentUlNr=Nr,c.ContragentUlR=xe,c.CostSourceEnum=ae,c.Country=H,c.CuratedDirection=Se,c.Curator=be,c.Currency=fe,c.DataSuggestionProvider=Dt,c.DataTablePagination=lt,c.DataTablePaginationRequestParams=dr,c.DataTableSortRequestParams=pt,c.DateTimeProvider=mt,c.DeletableNamedIdentity=Cr,c.DeliveryAddress=Ce,c.DeliveryType=j,c.DetailedJwtPayload=Fr,c.DeviceTypeResolutionConfig=vr,c.DiscountShortInfo=Pr,c.FieldValidationResultData=St,c.FilterGroup=x,c.FilterItem=Je,c.FilterOpEnum=Le,c.GeoCoordinates=je,c.HiddenCatalogableItem=pr,c.HttpCachedRequester=E,c.HttpParamsConfig=Rr,c.HttpRequester=f,c.Identity=_,c.Image=hr,c.JwtPayload=q,c.Manager=he,c.ManagerCommon=Te,c.ManagerDataFactory=ft,c.ManagerDataProvider=Ur,c.MetaTagItem=Hr,c.NamedIdentity=a,c.Opf=d,c.OpfEnum=N,c.Order=ir,c.OrderInfo=tr,c.OrderPaymentStatus=br,c.OrderProduct=jr,c.OrderShortInfo=er,c.OrderStatus=Ir,c.OrdersDataProvider=yt,c.PartnerGroup=W,c.PaymentType=kr,c.PreferencesStorageProvider=oe,c.PriceAnalyze=_e,c.PriceAnalyzeProvider=Ct,c.PriceCoefficient=ue,c.PriceCoefficientEnum=Ue,c.PriceHistoryDataProvider=Pt,c.PriceHistoryItem=Mr,c.PriceTemplate=M,c.PriceTemplateCategory=$e,c.PriceTemplateClient=Y,c.PriceTemplateICatalogableItem=Be,c.PriceTemplateProduct=ke,c.PriceTemplateProvider=st,c.PricingRole=Z,c.PricingRoleProvider=nt,c.PrimaryCatalogableItem=Re,c.Product=S,c.ProductCategoryDataProvider=et,c.ProductDataProvider=rt,c.ProductFileType=Lr,c.ProductPriceCoefficient=De,c.ProductPriceHistory=Br,c.PropertiesProvider=ot,c.Property=X,c.PropertyType=ze,c.PropertyTypeEnum=yr,c.PropertyValue=z,c.RecommendationsDataProvider=wt,c.RecommendationsList=nr,c.Reference=v,c.ReferenceDataProvider=R,c.Region=K,c.ResourceType=Qe,c.SalesDirection=L,c.SentryConfig=Dr,c.Seo=or,c.SeoDataProvider=Rt,c.SourcePrimaryInterest=Ye,c.StockCount=lr,c.TemplatesListFilters=Yr,c.TypedInstanceFactory=Ae,c.UnitsHelper=rr,c.UnknownClientDataProvider=ht,c.UpdatableNamedIdentity=Ge,c.User=Wr,c.UserAuthDataProvider=At,c.UserCommonInfo=He,c.UserDataProvider=Jr,c.UserPricingRole=wr,c.UserShortInfo=k,c.UserTypeEnum=zr,c.VersionConfig=Ar,c.Warehouse=le,c.WebSocketConfig=ar,c.findCatalogItemByIdRecursive=Ve,c.flattenCatalogItems=Fe,c.useAuthStateStore=ve,c.useReferencesStore=vt,c.useUserStateStore=Tt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("jwt-decode"),require("lodash-es"),require("ts-case-convert"),require("date-fns"),require("pinia"),require("vue"),require("axios")):typeof define=="function"&&define.amd?define(["exports","jwt-decode","lodash-es","ts-case-convert","date-fns","pinia","vue","axios"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c["SC Common Lib"]={},c["jwt-decode"],c["lodash-es"],c["ts-case-convert"],c["date-fns"],c.pinia,c.vue,c.axios))})(this,function(c,a,l,se,g,j,m,Vr){"use strict";var $t=Object.defineProperty;var bt=(c,a,l)=>a in c?$t(c,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[a]=l;var t=(c,a,l)=>bt(c,typeof a!="symbol"?a+"":a,l);class q{constructor(r){t(this,"exp",0);t(this,"iat",0);t(this,"authTime",0);t(this,"jti","");t(this,"iss","");t(this,"aud",[]);t(this,"sub","");t(this,"typ","Bearer");t(this,"azp","");t(this,"sid","");t(this,"acr","");t(this,"allowedOrigins",[]);t(this,"realmAccess",{roles:[]});t(this,"resourceAccess",{});t(this,"scope","");t(this,"emailVerified",!1);t(this,"name","");t(this,"guid","");t(this,"preferredUsername","");t(this,"givenName","");t(this,"email","");l.merge(this,r)}static getJwtPayload(r){const e=a.jwtDecode(r),i=new q(se.objectToCamel(e));return i.resourceAccess=e.resource_access,i}}class Fr extends q{constructor(e){super(e);t(this,"familyName");t(this,"middleName");t(this,"locale");t(this,"phoneNumber");t(this,"phoneNumberVerified");t(this,"address");l.merge(this,e)}static getJwtPayload(e){return new q(se.objectToCamel(a.jwtDecode(e)))}}class cr{constructor(r){t(this,"phone");t(this,"tablet");t(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 ur{constructor(r){t(this,"portalApiUrl");t(this,"mediaUrl");t(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 lr{constructor(r){t(this,"dsn");t(this,"environment");t(this,"ignoreErrors");t(this,"trace");t(this,"replay");t(this,"additionalParams");var e,i,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:((i=r==null?void 0:r.trace)==null?void 0:i.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 pr{constructor(r){t(this,"date");t(this,"name");t(this,"version");this.date=l.isString(r==null?void 0:r.date)?g.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"}}class hr{constructor(r){t(this,"broadcaster");t(this,"key");t(this,"wsHost");t(this,"wsPort");t(this,"wssPort");t(this,"forceTLS");t(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 gr{constructor(r){t(this,"environment");t(this,"devMode");t(this,"http");t(this,"deviceTypeByResolution");t(this,"sentry");t(this,"tableDefaultHeightCoefficient");t(this,"urls");t(this,"version");t(this,"websocket");t(this,"dateFormats");var e,i,s;this.environment=(r==null?void 0:r.environment)??"production",this.devMode=(r==null?void 0:r.devMode)??{},this.http=new ur(r==null?void 0:r.http),this.deviceTypeByResolution=new cr(r==null?void 0:r.deviceTypeByResolution),this.sentry=new lr({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.version=new pr(r==null?void 0:r.version),this.websocket=r!=null&&r.websocket?new hr(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:((i=r==null?void 0:r.dateFormats)==null?void 0:i.uiDate)??"dd.MM.yyyy",uiDateWithTime:((s=r==null?void 0:r.dateFormats)==null?void 0:s.uiDateWithTime)??"dd.MM.yyyy HH:mm"}}}const T=j.defineStore("common.config",()=>{const n=m.ref(new gr);return{config:n,getConfig:()=>n.value,setConfig:i=>{n.value=l.merge(n.value,i)}}});class ne{static getActualDataFromStorage(r){if(!this.isLocalStorageAvailable())return;let e=null;try{e=localStorage.getItem(r)}catch{return}if(e)try{const i=JSON.parse(e);if(!i.availableFor||g.isAfter(g.parseISO(i.availableFor)||g.startOfToday(),new Date)){if(l.isNil(i.data)||l.isEmpty(i.data))throw new Error("Data is empty");return i.data}}catch{try{localStorage.removeItem(r)}catch{}}}static saveActualDataToStorage(r,e,i){if(this.isLocalStorageAvailable())try{if(l.isNil(e)||l.isEmpty(e))throw new Error("Data is empty");const s=JSON.stringify({availableFor:i,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:i,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 i=localStorage.key(e);if(i)try{const s=localStorage.getItem(i);if(s){const o=JSON.parse(s);o.availableFor&&!g.isAfter(g.parseISO(o.availableFor)||g.startOfToday(),new Date)&&r.push(i)}}catch{r.push(i)}}r.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}catch{}}}function mr(n){try{const r=q.getJwtPayload(n);return new Date(r.exp*1e3)}catch{return}}const V=j.defineStore("common.auth_state_private",()=>{const n=m.ref((()=>{var h;const o=ne.getActualDataFromStorage("sc.token");if(o)return Promise.resolve(o);const u=(h=T().config.devMode)==null?void 0:h.initAuthBearerToken;return u?Promise.resolve(u):void 0})()),r=m.ref(void 0),e=m.ref(void 0),i=m.markRaw(new Map);function s(){e.value=void 0,l.isNil(n.value)||n.value.then(o=>{const u=q.getJwtPayload(o);e.value=u.exp*1e3>Date.now()?l.mapValues(u.resourceAccess,h=>(h==null?void 0:h.roles)??[]):void 0}).catch(l.noop)}return{jwtToken:n,jwtTokenUpdater:r,userPermissions:e,userPermissionsComputedRefs:i,recalculateUserPermissions:s}}),we=j.defineStore("common.auth_state",()=>{const n=m.computed(()=>{const o=V();if(l.isNil(o.jwtToken)&&!l.isNil(o.jwtTokenUpdater)){const u=o.jwtTokenUpdater();o.jwtToken=u,u.then(h=>{o.jwtToken=Promise.resolve(h),ne.saveActualDataToStorage("sc.token",h,mr(h)),o.recalculateUserPermissions()}).catch(l.noop)}return o.jwtToken});function r(o){V().jwtTokenUpdater=o}function e(o){const u=V();u.jwtToken=Promise.resolve(o),ne.saveActualDataToStorage("sc.token",o,mr(o)),u.recalculateUserPermissions()}function i(){const o=V();o.jwtToken=void 0,o.userPermissions=void 0,ne.saveActualDataToStorage("sc.token",void 0)}function s(o){const u=V();!l.isNil(u.jwtToken)&&l.isNil(u.userPermissions)&&u.jwtToken.then(w=>{const C=q.getJwtPayload(w);u.userPermissions=C.exp*1e3>Date.now()?l.mapValues(C.resourceAccess,I=>(I==null?void 0:I.roles)??[]):void 0}).catch(l.noop);const h=l.isArray(o)?o.join(" && "):o;if(u.userPermissionsComputedRefs.has(h))return u.userPermissionsComputedRefs.get(h);const y=m.computed(()=>{const w=C=>{var ie;const I=l.split(C,".");if(I.length<2)return!1;const[Ce,Pe]=I,te=(ie=V().userPermissions)==null?void 0:ie[Ce];return l.isArray(te)&&te.includes(Pe)};return l.isArray(o)?l.every(o,C=>w(C)):w(o)});return u.userPermissionsComputedRefs.set(h,y),y}return{jwtToken:n,setJwtTokenUpdater:r,setJwtToken:e,invalidateJwtToken:i,hasUserPermission:s}});class _{constructor(r,e){t(this,"id");t(this,"guid");this.id=r==null?void 0:r.id,l.isNil(this.id)&&(l.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==="":l.isNil(this.id)}}class A extends _{constructor(e){super(e);t(this,"name","");this.name=(e==null?void 0:e.name)??""}}class F extends A{constructor(e){super(e);t(this,"code","");this.code=(e==null?void 0:e.code)??""}}class _e extends F{constructor(e){super(e);t(this,"slug");t(this,"type");this.slug=(e==null?void 0:e.slug)??""}}class ve extends _e{constructor(e){super(e);t(this,"isPrimary");this.isPrimary=(e==null?void 0:e.isPrimary)??!1}}class oe extends ve{constructor(e){super(e);t(this,"isHidden");t(this,"parentCategoryId");t(this,"properties");t(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(([i,s])=>[l.toUpper(i),s])):void 0}}var Ue=(n=>(n.K0="k0",n.K1="k1",n.K2="k2",n.K3="k3",n.K4="k4",n.Retail="retail",n))(Ue||{});class v extends A{constructor(e){super(e);t(this,"slug");t(this,"description");this.description=e==null?void 0:e.description,this.slug=e==null?void 0:e.slug}}class ce extends v{static getRetailPriceCoefficient(){return{id:-2,slug:Ue.Retail,name:"Розн. цена",guid:"",isNewRec:l.constant(!0)}}}class Re{constructor(r){t(this,"coefficient");t(this,"value");t(this,"cost");t(this,"percent");t(this,"readOnly");this.coefficient=new ce(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 de{constructor(r){t(this,"lat");t(this,"long");this.lat=(r==null?void 0:r.lat)??0,this.long=(r==null?void 0:r.long)??0}}class G extends v{}class ue extends v{constructor(e){var i;super(e);t(this,"address");t(this,"isMain");t(this,"deliveryTypes");t(this,"regions");t(this,"coordinates");this.address=(e==null?void 0:e.address)??"",this.isMain=(e==null?void 0:e.isMain)??!1,this.deliveryTypes=((i=e==null?void 0:e.deliveryTypes)==null?void 0:i.map(s=>new G(s)))??[],this.regions=(e==null?void 0:e.regions)??[],this.coordinates=new de(e==null?void 0:e.coordinates)}}class fr{constructor(r){t(this,"warehouse");t(this,"count");this.warehouse=new ue(r==null?void 0:r.warehouse),this.count=(r==null?void 0:r.count)??0}}class yr extends _e{constructor(e){super(e);t(this,"isHidden");this.isHidden=(e==null?void 0:e.isHidden)??!1}}class Cr{constructor(r,e){t(this,"image");t(this,"preview");t(this,"isDefault");this.image=`${e??""}${r.image}`,this.preview=`${e??""}${r.preview}`,this.isDefault=r.isDefault}}class S extends yr{constructor(e){var s,o,u,h;super(e);t(this,"supplierSku");t(this,"unit");t(this,"pack");t(this,"minCount");t(this,"quantityUnit");t(this,"currency");t(this,"currencySignature");t(this,"cost");t(this,"costRub");t(this,"costDate");t(this,"onOrder");t(this,"stockCount");t(this,"category");t(this,"categories");t(this,"images");t(this,"properties");t(this,"retailCost");t(this,"retailCostRub");t(this,"priceCoefficients");this.supplierSku=e==null?void 0:e.supplierSku,this.unit=(e==null?void 0:e.unit)??"",this.pack=e==null?void 0:e.pack,this.minCount=e==null?void 0:e.minCount,this.quantityUnit=e==null?void 0:e.quantityUnit,this.currency=(e==null?void 0:e.currency)??"",this.cost=(e==null?void 0:e.cost)??0,this.costRub=(e==null?void 0:e.costRub)??0,this.costDate=l.isString(e==null?void 0:e.costDate)?g.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(y=>new fr(y)))??[],this.currencySignature=(e==null?void 0:e.currencySignature)??"",this.type="product";const i=(e==null?void 0:e.category)??((o=e==null?void 0:e.categories)==null?void 0:o.find(y=>y.isPrimary));i&&(this.category=new ve({...i,isPrimary:!0}),this.categories=[this.category]),e!=null&&e.categories&&(this.categories=e.categories.map(y=>new ve(y))),this.images=((u=e==null?void 0:e.images)==null?void 0:u.map(y=>new Cr(y,T().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=((h=e==null?void 0:e.priceCoefficients)==null?void 0:h.map(y=>new Re(y)))??[],e&&"codeNumber"in e&&!e.code&&(this.code=e==null?void 0:e.codeNumber)}getIsMeasurable(){var s;const i=(s=T().getConfig().catalog)==null?void 0:s.products.units;return[...(i==null?void 0:i.linear)??["пог.м.","м."],...(i==null?void 0:i.square)??["м2"]].includes(this.unit)}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}}class Pr extends _{constructor(e){super(e);t(this,"category");t(this,"product");t(this,"quantity");t(this,"height");t(this,"length");t(this,"width");t(this,"barcode");t(this,"marker");t(this,"configurator");t(this,"configuratorParams");t(this,"dopProdaga");this.product=new S(e==null?void 0:e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new oe,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&l.cloneDeep(e.configuratorParams),this.dopProdaga=e.dopProdaga}}class wr extends Pr{constructor(e){super(e);t(this,"currency");t(this,"cost");t(this,"costOne");t(this,"costOneRub");t(this,"costRub");t(this,"logicGroupId");t(this,"salesDirection");t(this,"specificationImgUrl");t(this,"sawing");this.currency=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=e.sawing}}class le{constructor(r){t(this,"items");t(this,"resultSum");t(this,"directionsSum");this.items=r.items.map(e=>new wr(e)),this.resultSum=r.resultSum,this.directionsSum=r.directionsSum}}class De{static simpleInstanceInitializer(r){return new r}static instanceInitializer(r,e){return new r(e)}}const b=class b{constructor(){t(this,"httpClient");t(this,"baseUrl",`${T().config.http.portalApiUrl}/api`);t(this,"errorResponseHandler",l.noop);t(this,"interceptorIds",{request:{},response:{}});t(this,"setBaseUrlRequestInterceptor",r=>(r.baseURL=this.baseUrl,r));t(this,"authRequestInterceptor",async r=>{let e;return l.isNil(we().jwtToken)||(e=await we().jwtToken),e&&r.headers.set("Authorization",`Bearer ${e}`),r});t(this,"dataConverterRequestInterceptor",r=>(r.method&&(r.method==="get"&&r.params&&(r.params=se.objectToSnake(r.params)),["put","patch","post"].includes(l.toLower(r.method))&&r.data&&(r.data=se.objectToSnake(r.data))),r));t(this,"authErrorsResponseInterceptors",r=>{var i;const e=r.rawError?(i=r.rawError)==null?void 0:i.config:void 0;return r.status===401?!e||e.__isRetryRequest?Promise.reject(r):(we().invalidateJwtToken(),e.__isRetryRequest=!0,this.httpClient(e)):Promise.reject(r)});t(this,"dataConverterResponseInterceptor",r=>(r.data&&(r.data=se.objectToCamel(r.data)),r));const r=T().config.version;this.errorResponseHandler=b.defaultErrorsResponseHandler,this.httpClient=Vr.create({headers:{"APP-VERSION":`${r.name} (${r.version}, ${g.format(r.date,T().config.dateFormats.uiDate)})`,Accept:"application/json","Content-Type":"application/json"}}),this.interceptorIds.request.setBaseUrlRequestInterceptor=this.httpClient.interceptors.request.use(this.setBaseUrlRequestInterceptor,e=>Promise.reject(e)),this.interceptorIds.request.authRequestInterceptor=this.httpClient.interceptors.request.use(this.authRequestInterceptor,e=>Promise.reject(e)),this.interceptorIds.request.dataConverterRequestInterceptor=this.httpClient.interceptors.request.use(this.dataConverterRequestInterceptor,e=>Promise.reject(e)),this.interceptorIds.response.convertHttpErrorResponseInterceptor=this.httpClient.interceptors.response.use(e=>e,e=>b.convertHttpErrorResponse(e)),this.interceptorIds.response.authErrorsResponseInterceptor=this.httpClient.interceptors.response.use(e=>e,this.authErrorsResponseInterceptors),this.interceptorIds.response.dataConverterResponseInterceptor=this.httpClient.interceptors.response.use(this.dataConverterResponseInterceptor,e=>Promise.reject(e))}static setDefaultErrorsResponseHandler(r){b.defaultErrorsResponseHandler=r}static getInstance(r){return Object.prototype.hasOwnProperty.call(b.instances,r.name)||(b.instances[r.name]=De.simpleInstanceInitializer(r)),b.instances[r.name]}static convertHttpErrorResponse(r){var e,i;if(!l.isNil(r.request)||!l.isNil(r.response)){const s=r==null?void 0:r.response;return Promise.reject({status:(s==null?void 0:s.status)??0,statusText:(s==null?void 0:s.statusText)??"Unknown",message:((e=s==null?void 0:s.data)==null?void 0:e.message)??"Unknown Error. Probably network error.",errors:(i=s==null?void 0:s.data)==null?void 0:i.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,i={},s=!1){const o=this.httpClient.request(r).then(u=>e?e(u):u.data);return o.catch(u=>{this.errorResponseHandler(u,i,s)}),o}get(r,e={},i=void 0,s=!1){return this.request({method:"GET",url:r,params:e},i,{},s)}getBlob(r,e={},i=void 0,s=!1){return this.request({method:"GET",url:r,params:e,responseType:"blob"},i,{},s)}patch(r,e={},i=void 0,s={},o=!1){return this.request({method:"PATCH",url:r,data:e},i,s,o)}post(r,e={},i=void 0,s={},o=!1){return this.request({method:"POST",url:r,data:e},i,s,o)}delete(r,e=void 0,i=!1){return this.request({method:"DELETE",url:r},e,{},i)}};t(b,"instances",{}),t(b,"defaultErrorsResponseHandler",l.noop);let f=b;class Kr extends f{getCart(r){return this.get(`internal/clients/${r.id}/cart`,{},e=>new le(e.data))}deleteCart(r){return this.delete(`internal/clients/${r.id}/cart`)}addCartItem(r,e,i={}){return this.patch(`internal/clients/${r.id}/cart`,{id:e.configurator&&e.category.id,productId:e.product.id,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,dopProdaga:e.dopProdaga,...e.configuratorParams},s=>new le(s.data),i)}patchCartItem(r,e,i={}){return this.patch(`internal/clients/${r.id}/cart/${e.id}`,{id:e.configurator&&e.category.id,productId:e.product.id,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,dopProdaga:e.dopProdaga,...e.configuratorParams},s=>new le(s.data),i)}deleteCartItem(r,e){return this.get(`internal/clients/${r.id}/cart/${e.id}`,{})}addCartItemFromCSV(r,e){return this.post(`internal/clients/${r.id}/cart/add-products-from-csv`,e,i=>new le(i.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 vr=(n=>(n.m2Cost="m2Cost",n.percent="percent",n.value="value",n))(vr||{}),Ae=(n=>(n.Discount="discount",n.PriceTemplate="price_template",n.ClientPrice="client_price",n.Product="product",n))(Ae||{}),Rr=(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))(Rr||{});class B extends oe{constructor(e){var i,s;super(e);t(this,"categories");t(this,"products");this.categories=(i=e==null?void 0:e.categories)==null?void 0:i.map(o=>new B(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new S(o))}}class je extends A{constructor(e){super(e);t(this,"updatedAt");this.updatedAt=l.isString(e==null?void 0:e.updatedAt)?g.parseISO(e.updatedAt):e==null?void 0:e.updatedAt}}class Dr extends je{constructor(e){super(e);t(this,"deletedAt");this.deletedAt=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class k extends A{constructor(e){super(e);t(this,"type");this.type=e==null?void 0:e.type}}class Ar extends A{constructor(e){super(e);t(this,"costCoefficient");t(this,"isLowPriceAllowed");t(this,"publishedAt");t(this,"description");t(this,"percent");t(this,"owner");t(this,"deletedAt");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.isLowPriceAllowed=(e==null?void 0:e.isLowPriceAllowed)??!1,this.publishedAt=l.isString(e==null?void 0:e.publishedAt)?g.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 k(e==null?void 0:e.owner),this.deletedAt=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class M extends je{constructor(e){super(e);t(this,"description");t(this,"createdAt");this.description=(e==null?void 0:e.description)??"",this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date}}class H extends S{constructor(e){super(e);t(this,"costCoefficient");t(this,"costSource");t(this,"discount");t(this,"priceTemplate");t(this,"isPreviouslyOrdered");t(this,"isRequired");t(this,"isFavorite");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.costSource=(e==null?void 0:e.costSource)??Ae.Product,this.discount=e!=null&&e.discount?new Ar(e.discount):void 0,this.priceTemplate=e!=null&&e.priceTemplate?new M(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 Ge{constructor(r){t(this,"phone");t(this,"email");this.phone=/^\d+$/.test(r.phone??"")?`+${r.phone}`:r.phone,this.email=r.email}}class L extends v{}class ae extends A{constructor(e){super(e);t(this,"salesDirection");t(this,"photo");t(this,"contacts");t(this,"isDefault");t(this,"isRegionalDirector");this.salesDirection=e!=null&&e.salesDirection?new L(e.salesDirection):new L,this.photo=e==null?void 0:e.photo,this.contacts=e!=null&&e.contacts?new Ge(e.contacts):void 0,this.isDefault=(e==null?void 0:e.isDefault)??!1,this.isRegionalDirector=(e==null?void 0:e.isRegionalDirector)??!1}}class Te extends v{}class ar extends A{constructor(e){super(e);t(this,"description");t(this,"canChangeLowCost");t(this,"parentRoleId");this.description=e.description,this.canChangeLowCost=e.canChangeLowCost,this.parentRoleId=e.parentRoleId}}class pe extends ae{constructor(e){var i;super(e);t(this,"isActive");t(this,"isSupervisor");t(this,"canDoReclamations");t(this,"createdAt");t(this,"supervisorId");t(this,"pricingRole");t(this,"curatedDirections");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=e==null?void 0:e.createdAt,this.supervisorId=e==null?void 0:e.supervisorId,this.pricingRole=e!=null&&e.pricingRole?new ar(e.pricingRole):void 0,this.curatedDirections=((i=e==null?void 0:e.curatedDirections)==null?void 0:i.map(s=>new Te(s)))??[]}}class Qr extends oe{constructor(e){super(e);t(this,"isDisabled");t(this,"isRequired");t(this,"isFavorite");t(this,"hidingComment");t(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 pe(e.manager):void 0}}class he extends Qr{constructor(e){var i,s;super(e);t(this,"categories");t(this,"products");this.categories=(i=e==null?void 0:e.categories)==null?void 0:i.map(o=>new he(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new H(o))}}class Be{constructor(r){t(this,"priceCoefficient");t(this,"increasePercent");this.priceCoefficient=(r==null?void 0:r.priceCoefficient)&&new ce(r.priceCoefficient),this.increasePercent=r==null?void 0:r.increasePercent}}class Se extends Be{constructor(e){super(e);t(this,"productCategory");this.productCategory=new oe(e==null?void 0:e.productCategory)}}class $e extends A{constructor(e){super(e);t(this,"photo");t(this,"contacts");t(this,"curatedDirection");this.photo=e.photo,this.contacts=new Ge(e.contacts),this.curatedDirection=new Te(e.curatedDirection)}}class z extends v{}class K extends v{constructor(e){super(e);t(this,"country",new z);e&&(this.country=new z(e.country))}}class be extends v{constructor(e){super(e);t(this,"region",new K);e&&(this.region=new K(e.region))}}class Me extends A{constructor(e){super(e);t(this,"phone");t(this,"email");t(this,"getNews");t(this,"salesDirection");t(this,"createdAt");t(this,"lastLoginAt");t(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 L(e.salesDirection):void 0,this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.lastLoginAt=l.isString(e==null?void 0:e.lastLoginAt)?g.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt,this.isActive=(e==null?void 0:e.isActive)??!1}}class Q extends Me{constructor(e){var i,s;super(e);t(this,"salesDirection");t(this,"debt");t(this,"alternativeName");t(this,"city");t(this,"comment");t(this,"isPhoneApproved");t(this,"isEmailApproved");t(this,"managers");t(this,"curators");this.salesDirection=new L(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 be(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=((i=e==null?void 0:e.managers)==null?void 0:i.map(o=>new ae(o)))??[],this.curators=((s=e==null?void 0:e.curators)==null?void 0:s.map(o=>new $e(o)))??void 0}}class Y extends _{constructor(e){super(e);t(this,"createdAt");t(this,"deletedAt");t(this,"client");t(this,"priceTemplate");this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.deletedAt=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt,this.client=new Q(e==null?void 0:e.client),this.priceTemplate=new M(e==null?void 0:e.priceTemplate)}}class Ie extends Be{constructor(e){super(e);t(this,"product");this.product=new S(e==null?void 0:e.product)}}class He extends v{}class X extends A{constructor(e){super(e);t(this,"type");t(this,"description");t(this,"metadata");this.type=new He(e==null?void 0:e.type),this.description=(e==null?void 0:e.description)??"",this.metadata=e==null?void 0:e.metadata}}class W{constructor(r){t(this,"property");t(this,"value");this.property=new X(r==null?void 0:r.property),this.value=(r==null?void 0:r.value)??""}}class O{constructor(r){t(this,"from");t(this,"to");this.from=l.isString(r==null?void 0:r.from)?g.parseISO(r.from):(r==null?void 0:r.from)??null,this.to=l.isString(r==null?void 0:r.to)?g.parseISO(r.to):(r==null?void 0:r.to)??null}}class Yr{constructor(r){t(this,"id");t(this,"name");t(this,"description");t(this,"createdAt",new O);t(this,"updatedAt",new O);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.createdAt=new O(r==null?void 0:r.createdAt),this.updatedAt=new O(r==null?void 0:r.updatedAt)}resetFilterValue(r){switch(r){case"id":case"name":case"description":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,i,s,o;const r={};return Object.keys(this).forEach(u=>{const h=this[u];l.isNil(h)||l.isString(h)&&h.trim().length===0||l.isFunction(h.isNewRec)&&h.isNewRec()||(r[u]=h)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((i=r==null?void 0:r.createdAt)!=null&&i.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 Z extends A{constructor(e){super(e);t(this,"description");t(this,"canChangeLowCost");t(this,"parentRoleId");t(this,"subRoles",[]);t(this,"parentRole");t(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 ze{constructor(r){t(this,"role");t(this,"category");t(this,"minCoefficient");this.role=new Z(r==null?void 0:r.role),this.category=new oe(r==null?void 0:r.category),this.minCoefficient=new ce(r==null?void 0:r.minCoefficient)}}class Xr extends f{search(r,e=!1){return this.get("/internal/catalog/search",{term:r,show_hidden:e})}getPriceExportLink(r="csv",e=!1,i=void 0,s=void 0){let u=`${T().config.http.portalApiUrl}/api/internal/price/export?format=${r}&show_hidden=${e}`;return i&&(u+=`&category_id=${i}`),s&&(u+=`&client_id=${s}`),u}}class Zr extends f{importPrices(r,e){return this.post(`/internal/clients/${r}/price/import`,e)}updateCategoryPrices(r,e,i){var s;return this.patch(`/internal/clients/${r}/price/categories/${e}`,{price_coefficient_id:(s=i.coefficient)==null?void 0:s.id,increase_percent:i.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,i){return this.post(`/internal/clients/${r}/price/categories/${e}/disabled`,{comment:i})}unmarkCategoryDisabled(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/disabled`)}addCategoryManager(r,e,i){return this.post(`/internal/clients/${r}/price/categories/${e}/manager`,{manager_id:i})}removeCategoryManager(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/manager`)}updateProductPrice(r,e,i){var s;return this.patch(`/internal/clients/${r}/price/products/${e}`,{price_coefficient_id:(s=i.coefficient)==null?void 0:s.id,increase_percent:i.value},o=>new H(o.data))}removeProductPrice(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}`,i=>new H(i.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,i=>new Blob([i.data],{type:"text/html"}))}getCommercialOfferPdf(r,e){return this.getBlob(`/internal/clients/${r}/price/commercial-offer/download`,e,i=>new Blob([i.request.response],{type:"application/pdf"}))}sendCommercialOffer(r,e){return this.post(`/internal/clients/${r}/price/commercial-offer/send`,e)}}class xr extends f{getTemplateList(r){return this.get(`/internal/clients/${r}/price/templates`,{},e=>e.data.map(i=>new Y(i)))}getActiveTemplate(r){return this.get(`/internal/clients/${r}/price/templates/active`,{},e=>new Y(e.data),!0)}attachTemplate(r,e,i){const s=T().config.dateFormats.api;return this.post(`/internal/clients/${r}/price/templates/${e}`,i&&{startAt:i.startAt&&g.format(i.startAt,s),endAt:i.endAt&&g.format(i.endAt,s)},o=>new Y(o.data),{},!0)}applyTemplate(r,e){return this.post(`/internal/clients/${r}/price/templates/${e}/apply`,{},void 0,{},!0)}changeTemplate(r,e,i,s){const o=T().config.dateFormats.api;return this.patch(`/internal/clients/${r}/price/templates/${e}/${i}`,s&&{startAt:s.startAt&&g.format(s.startAt,o),endAt:s.endAt&&g.format(s.endAt,o)},u=>new Y(u.data))}detachTemplate(r,e,i){return this.delete(`/internal/clients/${r}/price/templates/${e}/${i}`)}}class Er extends f{getRootCategoriesList(r=!1){return this.get("/internal/catalog/categories",{showHidden:r},e=>e.data.map(i=>new B(i)))}getCategoryData(r,e=!1,i=!1){return this.get(`/internal/catalog/categories/${r}`,{showHidden:e,withNestedCategories:i},s=>new B(s.data))}getPublicCategoryData(r){return this.get(`/public/catalog/categories/${r}`,{},e=>new B(e.data))}getCategoryProductsList(r,e=!0,i=!1){return this.get(`/internal/catalog/categories/${r}/products`,{showHidden:i,withPriceCoefficients:e},s=>l.map(s.data,o=>new S(o)))}getCategoryProductsCoefficients(r){return this.get(`/internal/catalog/categories/${r}/products/coefficients`,{},e=>{const{data:i}=e;return l.forEach(i,s=>s.map(o=>new Re(o))),i})}publicSimpleSearch(r,e=10){return new Promise((i,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{i(o.categories.map(u=>new B(u)))}).catch(o=>{s(o)})})}}class et extends f{getProductData(r,e=!1){return this.get(`/internal/catalog/products/${r}`,{withPriceCoefficients:e},i=>new S(i.data))}getPublicProductData(r){return this.get(`/public/catalog/products/${r}`,{},e=>new S(e.data))}getProductPriceCoefficients(r){return this.get(`/internal/catalog/products/${r}/coefficients`,{},e=>l.map(e.data,i=>new Re(i)))}publicSimpleSearch(r,e=10){return new Promise((i,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{i(o.products.map(u=>new S(u)))}).catch(o=>{s(o)})})}}class rt extends f{getRootCategoriesList(r,e=!1){return this.get("/internal/catalog/categories",{clientId:r,showHidden:e},i=>i.data.map(s=>new he(s)))}getCategoryData(r,e,i=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{clientId:r,showHidden:i,withNestedCategories:s},o=>new he(o.data))}getCategoryProductsList(r,e,i=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{client_id:r,showHidden:s,withPriceCoefficients:i},o=>l.map(o.data,u=>new H(u)))}}class tt extends f{getProductData(r,e,i=!1){return this.get(`/internal/catalog/products/${r}`,{clientId:e,withPriceCoefficients:i},s=>new H(s.data))}}var ke=(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))(ke||{});class We{constructor(r){t(this,"field");t(this,"op");t(this,"value");this.field=(r==null?void 0:r.field)??"",this.op=(r==null?void 0:r.op)??ke.Equals,this.value=(r==null?void 0:r.value)??""}toPrimitive(){const r={field:this.field,op:this.op};return r.value=l.isDate(this.value)?g.format(this.value,T().config.dateFormats.api):this.value,r}}class x{constructor(r){t(this,"groupOp");t(this,"filters");t(this,"groups");var e,i;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 We(s)))??[],this.groups=((i=r==null?void 0:r.groups)==null?void 0:i.map(s=>new x(s)))??[]}toPrimitive(){return{groupOp:this.groupOp,filters:this.filters.map(r=>r instanceof We&&l.isFunction(r.toPrimitive)?r.toPrimitive():r),groups:this.groups.map(r=>r instanceof x?r.toPrimitive():r)}}}class ge extends f{getPaginated(r,e,i,s,o,u,h){let y={page:(s==null?void 0:s.page)??1,perPage:(s==null?void 0:s.pageSize)??10};return e&&(y.filters=JSON.stringify((e instanceof x?e:new x(e)).toPrimitive())),l.isEmpty(i)||(y.sort=l.isArray(i)?i:[i]),o&&(y={...y,...o}),this.get(r,y,u,h)}}class it extends ge{getTemplateList(r,e,i){return this.getPaginated("/internal/price/templates",r,e,i,{},s=>{const o={...s.data};return o.data=o.data.map(u=>new M(u)),o})}createTemplate(r,e={}){return this.post("/internal/price/templates",r,i=>new M(i.data),e)}getTemplate(r){return this.get(`/internal/price/templates/${r}`,{},e=>new M(e.data))}updateTemplate(r,e,i={}){return this.patch(`/internal/price/templates/${r}`,e,s=>new M(s.data),i)}removeTemplate(r){return this.delete(`/internal/price/templates/${r}`)}getProductTemplatePrices(r){return this.get(`/internal/price/templates/${r}/products`,{},e=>e.data.map(i=>new Ie(i)))}getProductTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/products/${e}`,{},i=>new Ie(i.data))}saveProductTemplatePrice(r,e,i){var s;return this.post(`/internal/price/templates/${r}/products/${e}`,{price_coefficient_id:(s=i.coefficient)==null?void 0:s.id,increase_percent:i.value},o=>new Ie(o.data))}deleteProductTemplatePrice(r,e){return this.delete(`/internal/price/templates/${r}/products/${e}`)}getCategoryTemplatePrices(r){return this.get(`/internal/price/templates/${r}/categories`,{},e=>e.data.map(i=>new Se(i)))}getCategoryTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/categories/${e}`,{},i=>new Se(i.data))}saveCategoryTemplatePrice(r,e,i,s=!1){var o;return this.request({method:"POST",url:`/internal/price/templates/${r}/categories/${e}`,data:{price_coefficient_id:(o=i.coefficient)==null?void 0:o.id,increase_percent:i.value},params:s?{recursively:!0}:{}},u=>new Se(u.data))}deleteCategoryTemplatePrice(r,e,i=!1){return this.request({method:"DELETE",url:`/internal/price/templates/${r}/categories/${e}`,params:i?{recursively:!0}:{}})}getTemplateClients(r){return this.get(`/internal/price/templates/${r}/clients`,{},e=>e.data.map(i=>new Y(i)))}}class st extends f{getRoles(){return this.get("/internal/price/roles",{},r=>r.data.map(e=>new Z(e)))}createRole(r){return this.post("/internal/price/roles",r,e=>new Z(e.data))}getRole(r){return this.get(`/internal/price/roles/${r}`,{},e=>new Z(e.data))}updateRole(r,e){return this.patch(`/internal/price/roles/${r}`,e,i=>new Z(i.data))}deleteRole(r){return this.delete(`/internal/price/roles/${r}`)}getCategoryRules(r){return this.get(`/internal/price/roles/rules/categories/${r}`,{},e=>e.data.map(i=>new ze(i)))}updateCategoryRules(r,e){return this.patch(`/internal/price/roles/rules/categories/${r}`,e,i=>i.data.map(s=>new ze(s)))}}class nt extends ge{getProperties(r,e,i){return this.getPaginated("/internal/catalog/properties",r,e,i,{},s=>{const o={...s.data};return o.data=o.data.map(u=>new X(u)),o})}createProperty(r){const{typeId:e,...i}=r;return this.post("/internal/catalog/properties",{...i,type:e},s=>new X(s.data))}getProperty(r){return this.get(`/internal/catalog/properties/${r}`,{},e=>new X(e.data))}updateProperty(r,e){const{typeId:i,...s}=e;return this.patch(`/internal/catalog/properties/${r}`,{...s,type:i},o=>new X(o.data))}deleteProperty(r){return this.delete(`/internal/catalog/properties/${r}`)}getProductProperties(r){return this.get(`/internal/catalog/products/${r}/properties`,{},e=>e.data.map(i=>new W(i)))}getProductProperty(r,e){return this.get(`/internal/catalog/products/${r}/properties/${e}`,{},i=>new W(i.data))}updateProductProperty(r,e,i){return this.patch(`/internal/catalog/products/${r}/properties/${e}`,{value:i},s=>new W(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,i){return this.patch(`/internal/catalog/products/${r}/properties/files/${e}`,i)}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.get(`/internal/catalog/categories/${r}/properties`,{},e=>e.data.map(i=>new W(i)))}getCategoryProperty(r,e){return this.get(`/internal/catalog/categories/${r}/properties/${e}`,{},i=>new W(i.data))}updateCategoryProperty(r,e,i){return this.patch(`/internal/catalog/categories/${r}/properties/${e}`,{value:i},s=>new W(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,i){return this.patch(`/internal/catalog/categories/${r}/properties/files/${e}`,i)}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})}}function Je(n,r,e){let i;return n.some(s=>{if(s.type===e&&s.id===r)return i=s,!0;if(s.type==="product")return!1;const o=s;if(o.products&&o.products.length>0){const u=Je(o.products,r,e);if(u)return i=u,!0}if(o.categories&&o.categories.length>0){const u=Je(o.categories,r,e);if(u)return i=u,!0}return!1}),i}function Ve(n){const r=[];return n.forEach(e=>{if(r.push(e),e.type==="category"){const i=e;i.products&&i.products.length>0&&r.push(...Ve(i.products)),i.categories&&i.categories.length>0&&r.push(...Ve(i.categories))}}),r}var Tr=(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))(Tr||{}),N=(n=>(n.Person="individual",n.Ic="entrepreneur",n.UlR="legal",n.UlNr="non_resident_legal",n))(N||{});class Sr extends v{}class Fe extends v{}class ot extends v{}class $r extends v{}class me extends A{constructor(e){super(e);t(this,"signature","");t(this,"symbol","");e&&(this.signature=e.signature??"",this.symbol=e.symbol??"")}}class U extends v{static generatePersonItem(){return new U({id:1,guid:"",slug:N.Person,name:""})}}class br extends v{}class Ir extends v{}class J extends v{}class kr extends v{}class Lr extends v{}class Ke extends v{}class Qe extends v{}class Le extends _{constructor(e){super(e);t(this,"bankName","");t(this,"bic","");t(this,"accountNumber","");t(this,"correspondentAccount","");t(this,"currency",new me);e&&(this.bankName=e.bankName??"",this.bic=e.bic??"",this.accountNumber=e.accountNumber??"",this.correspondentAccount=e.correspondentAccount??"",this.currency=new me(e.currency))}}class Oe extends A{constructor(e){super(e);t(this,"phone");t(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 d extends Oe{constructor(e){super(e);t(this,"isPrimary");t(this,"position");t(this,"notDisturb");t(this,"comment");t(this,"updatedAt");t(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=l.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class Ye extends A{constructor(e){super(e);t(this,"opf",U.generatePersonItem());t(this,"partnerGroup",new J);t(this,"contacts",[]);t(this,"bankAccounts",[]);t(this,"comment");t(this,"alternativeName");t(this,"createdAt");t(this,"creator");t(this,"updatedAt");t(this,"updater");if(e){if(this.opf=new U(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e.createdAt,this.creator=e.creator?new k(e.creator):void 0,this.updatedAt=l.isString(e==null?void 0:e.updatedAt)?g.parseISO(e.updatedAt):e.updatedAt,this.updater=e.updater?new k(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new J(e.partnerGroup)),e.contacts){const i=[];e.contacts.forEach(s=>{i.push(new d(s))}),this.contacts=i}if(e.bankAccounts){const i=[];e.bankAccounts.forEach(s=>{i.push(new Le(s))}),this.bankAccounts=i}}}}class Or extends Ye{constructor(r){super(r)}}class Xe extends Ye{constructor(e){super(e);t(this,"inn","");t(this,"okpo","");t(this,"directorName","");t(this,"directorPosition","");t(this,"directorActsOn","");t(this,"legalAddress","");t(this,"postalAddress","");t(this,"actualAddress","");e&&(this.inn=e.inn??"",this.okpo=e.okpo??"",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 Ze extends Xe{constructor(e){super(e);t(this,"kpp","");e&&(this.kpp=e.kpp??"")}}class Nr extends Ze{constructor(e){super(e);t(this,"registrationCountry",new z);t(this,"registrationNumber","");t(this,"taxNumber","");e&&(this.registrationCountry=new z(e.registrationCountry),this.registrationNumber=e.registrationNumber??"",this.taxNumber=e.taxNumber??"")}}class fe{static createInstance(r){switch(r.opf.slug){case N.Ic:return new Xe(r);case N.UlR:return new Ze(r);case N.UlNr:return new Nr(r);default:return new Or(r)}}}class Ne extends _{constructor(e){super(e);t(this,"isPrimary");this.isPrimary=e.isPrimary}}class qr extends d{constructor(e){super(e);t(this,"relations",{clients:[],contragents:[],addresses:[]});e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(i=>new Ne(i))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(i=>new Ne(i))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(i=>new Ne(i))))}}class ye extends Dr{constructor(e){var i;super(e);t(this,"address","");t(this,"coordinates");t(this,"contacts");t(this,"comment");t(this,"operatingHours");t(this,"isOneTime");t(this,"isTransportCompanyAddress");this.address=(e==null?void 0:e.address)??"",this.coordinates=new de(e==null?void 0:e.coordinates),this.contacts=((i=e==null?void 0:e.contacts)==null?void 0:i.map(s=>new d(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 xe extends Q{constructor(e){var i,s,o,u;super(e);t(this,"contragents");t(this,"partnerGroups");t(this,"contacts");t(this,"deliveryAddresses");t(this,"channelPrimaryInterest");t(this,"sourcePrimaryInterest");t(this,"preferredDeliveryType");t(this,"primaryDemand");t(this,"preferredWarehouse");t(this,"extraData");this.contragents=((i=e==null?void 0:e.contragents)==null?void 0:i.map(h=>fe.createInstance(h)))??[],this.partnerGroups=((s=e==null?void 0:e.partnerGroups)==null?void 0:s.map(h=>new J(h)))??[],this.contacts=((o=e==null?void 0:e.contacts)==null?void 0:o.map(h=>new d(h)))??[],this.deliveryAddresses=((u=e==null?void 0:e.deliveryAddresses)==null?void 0:u.map(h=>new ye(h)))??[],this.channelPrimaryInterest=new Fe(e==null?void 0:e.channelPrimaryInterest),this.sourcePrimaryInterest=new Qe(e==null?void 0:e.sourcePrimaryInterest),this.preferredDeliveryType=new G(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 ct{constructor(r){t(this,"id");t(this,"name");t(this,"alternativeName");t(this,"searchTerm");t(this,"cities");t(this,"region");t(this,"country");t(this,"phone");t(this,"email");t(this,"isActive");t(this,"createdAt",new O);t(this,"lastLoginDate",new O);t(this,"lastLoginDateHasOrder");t(this,"managers");t(this,"curators");t(this,"isManagerRequired");t(this,"salesDirections");t(this,"contragentInn");t(this,"contragentType");t(this,"preferredDeliveryType");t(this,"partnerGroups");t(this,"contact");t(this,"lastOrder");var e,i,s,o,u,h,y,w;this.id=r==null?void 0:r.id,this.name=r==null?void 0:r.name,this.alternativeName=r==null?void 0:r.alternativeName,this.searchTerm=r==null?void 0:r.searchTerm,this.cities=(e=r==null?void 0:r.cities)==null?void 0:e.map(C=>new be(C)),this.region=new K(r==null?void 0:r.region),this.country=new z(r==null?void 0:r.country),this.phone=r==null?void 0:r.phone,this.email=r==null?void 0:r.email,this.isActive=r&&Object.prototype.hasOwnProperty.call(r,"isActive")?r==null?void 0:r.isActive:!0,this.createdAt=new O(r==null?void 0:r.createdAt),this.lastLoginDate=new O(r==null?void 0:r.lastLoginDate),this.lastLoginDateHasOrder=(r==null?void 0:r.lastLoginDateHasOrder)??void 0,this.managers=((i=r==null?void 0:r.managers)==null?void 0:i.map(C=>new pe(C)))??[],this.curators=((s=r==null?void 0:r.curators)==null?void 0:s.map(C=>new $e(C)))??[],this.salesDirections=(o=r==null?void 0:r.salesDirections)==null?void 0:o.map(C=>new L(C)),this.contragentInn=r==null?void 0:r.contragentInn,this.contragentType=new U(r==null?void 0:r.contragentType),this.preferredDeliveryType=new G(r==null?void 0:r.preferredDeliveryType),this.partnerGroups=(u=r==null?void 0:r.partnerGroups)==null?void 0:u.map(C=>new J(C)),this.contact=new Oe(r==null?void 0:r.contact),this.lastOrder={createdAt:new O((h=r==null?void 0:r.lastOrder)==null?void 0:h.createdAt),creator:(y=r==null?void 0:r.lastOrder)==null?void 0:y.creator,isApproved:(w=r==null?void 0:r.lastOrder)==null?void 0:w.isApproved}}resetFilterValue(r){switch(r){case"cities":this.cities=[];break;case"region":this.region=new K;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"lastOrder":this.lastOrder={};break;case"managers":this.managers=[];break;case"curators":this.curators=[];break;case"salesDirections":this.salesDirections=[];break;case"contragentType":this.contragentType=new U;break;case"preferredDeliveryType":this.preferredDeliveryType=new G;break;case"partnerGroups":this.partnerGroups=[];break;case"contact":this.contact=new Oe;break;default:this[r]=void 0;break}return this}asClearRaw(){var e,i,s,o;const r={};return Object.keys(this).forEach(u=>{const h=this[u];l.isNil(h)||l.isString(h)&&h.trim().length===0||l.isFunction(h.isNewRec)&&h.isNewRec()||(r[u]=h)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((i=r==null?void 0:r.createdAt)!=null&&i.to)&&delete r.createdAt,!((s=r==null?void 0:r.lastLoginDate)!=null&&s.from)&&!((o=r==null?void 0:r.lastLoginDate)!=null&&o.to)&&delete r.lastLoginDate,r}}class Ee extends _{constructor(e){super(e);t(this,"createdAt");t(this,"creator");t(this,"isApproved1c");this.createdAt=l.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.creator=new k(e==null?void 0:e.creator),this.isApproved1c=(e==null?void 0:e.isApproved1c)??!1}}class _r extends A{constructor(e){var i,s,o,u;super(e);t(this,"contacts",[]);t(this,"preferredDeliveryType");t(this,"partnerGroups",[]);t(this,"lastOrder");t(this,"salesDirection");t(this,"managers");t(this,"curators");this.contacts=((i=e.contacts)==null?void 0:i.map(h=>new d(h)))??void 0,this.lastOrder=e.lastOrder?new Ee(e.lastOrder):void 0,this.partnerGroups=((s=e.partnerGroups)==null?void 0:s.map(h=>new J(h)))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new G(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new L(e.salesDirection):void 0,this.managers=((o=e.managers)==null?void 0:o.map(h=>new ae(h)))??void 0,this.curators=((u=e.curators)==null?void 0:u.map(h=>new $e(h)))??void 0}}class Ur{constructor(r){t(this,"page",1);t(this,"pageSize",50);this.page=(r==null?void 0:r.page)??1,this.pageSize=(r==null?void 0:r.pageSize)??50}}class ut extends Ur{constructor(e){super(e);t(this,"itemCount",0);t(this,"pageCount",1);t(this,"pageSlot",5);t(this,"pageSizes",[25,50,100]);t(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 lt{constructor(r){t(this,"field");t(this,"direction");this.field=(r==null?void 0:r.field)??"",this.direction=(r==null?void 0:r.direction)??"asc"}}class $ extends ge{static transformClientDataToRequest(r){var i;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:(i=r.preferredWarehouse)==null?void 0:i.id}}static transformContragentClientDataToRequest(r){var u,h,y,w;let e;const i=r,s=r,o=r;switch(r.opf.slug){case N.Ic:e={opf:i.opf.slug,name:i.name,alternative_name:i.alternativeName,partner_group_id:(u=i.partnerGroup)==null?void 0:u.id,comment:i.comment,inn:i.inn,okpo:i.okpo,director_name:i.directorName,director_position:i.directorPosition,director_acts_on:i.directorActsOn,legal_address:i.legalAddress,postal_address:i.postalAddress,actual_address:i.actualAddress};break;case N.UlR:e={opf:s.opf.slug,name:s.name,alternative_name:s.alternativeName,partner_group_id:(h=s.partnerGroup)==null?void 0:h.id,comment:s.comment,inn:s.inn,kpp:s.kpp,okpo:s.okpo,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 N.UlNr:e={opf:o.opf.slug,name:o.name,alternative_name:o.alternativeName,partner_group_id:(y=o.partnerGroup)==null?void 0:y.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:(w=r.partnerGroup)==null?void 0:w.id,comment:r.comment};break}return e}static transformClientDeliveryAddressToRequest(r){var i,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:(i=r.coordinates)==null?void 0:i.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 xe(e.data))}getClientsList(r,e,i,s){return this.getPaginated("/internal/clients",r,e,i,s,o=>{const u={...o.data};return u.data=u.data.map(h=>new Q(h)),u})}getClientByPhone(r){return this.getClientsList({groupOp:"and",groups:[],filters:[{field:"phone",op:ke.Contains,value:r}]})}getAdditionalClientsData(r,e){const i=r.map(s=>s.id);return this.post("/internal/clients/additional-data",{clients:i,requested_data_types:e},s=>{let o=[];return(s==null?void 0:s.data.length)>0&&(o=s.data.map(u=>new _r(u))),o})}getAllClientContacts(r){return this.get(`/internal/clients/${r}/contacts/all`,{},e=>{let i=[];return(e==null?void 0:e.data.length)>0&&(i=e.data.map(s=>new qr(s))),i})}createClientCommonData(r,e={}){return this.post("/internal/clients",$.transformClientDataToRequest(r),i=>new xe(i.data),e)}updateClientCommonData(r,e={}){return this.patch(`/internal/clients/${r.id}`,$.transformClientDataToRequest(r),void 0,e)}updateClientNotDistribCommonData(r,e={}){const i={get_news:r.getNews};return this.patch(`/internal/clients/${r.id}`,i,void 0,e)}changeClientPassword(r,e,i,s={}){return this.patch(`/internal/clients/${r}`,{password:e,password_confirmation:i},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 i=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/attach`,{is_primary:s.isDefault}));await Promise.all(i)}async detachClientFromManagers(r,e){const i=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/detach`));await Promise.all(i)}attachToCurator(r,e,i){return this.patch(`/internal/clients/${r}/curators/${e}/attach`,{curated_direction_id:i.id})}detachFromCurator(r,e,i){return this.patch(`/internal/clients/${r}/curators/${e}/detach`,{curated_direction_id:i.id})}setCurators(r,e){return this.patch(`/internal/clients/${r}/curators`,{curators:e.map(i=>({curator_id:i.curatorId,curated_direction_id:i.curatedDirection.id}))})}createContragentClientData(r,e,i={}){return this.post(`/internal/clients/${r}/contragents`,$.transformContragentClientDataToRequest(e),s=>fe.createInstance(s.data),i)}updateContragentClientData(r,e,i={}){return this.patch(`/internal/clients/${r}/contragents/${e.id}`,$.transformContragentClientDataToRequest(e),s=>fe.createInstance(s.data),i)}deleteClientContragent(r,e){return this.delete(`/internal/clients/${r}/contragents/${e.id}`)}createClientDeliveryAddress(r,e,i={}){return this.post(`/internal/clients/${r}/delivery-addresses`,$.transformClientDeliveryAddressToRequest(e),s=>new ye(s.data),i)}updateClientDeliveryAddress(r,e,i={}){return this.patch(`/internal/clients/${r}/delivery-addresses/${e.id}`,$.transformClientDeliveryAddressToRequest(e),s=>new ye(s.data),i)}deleteClientDeliveryAddress(r,e){return this.delete(`/internal/clients/${r}/delivery-addresses/${e.id}`)}createContragentBankAccount(r,e,i,s={}){return this.post(`/internal/clients/${r}/contragents/${e}/bank-accounts`,$.transformClientContragentBankAccountToRequest(i),o=>new Le(o.data),s)}updateContragentBankAccount(r,e,i,s={}){return this.patch(`/internal/clients/${r}/contragents/${e}/bank-accounts/${i.id}`,$.transformClientContragentBankAccountToRequest(i),o=>new Le(o.data),s)}deleteContragentBankAccount(r,e,i){return this.delete(`/internal/clients/${r}/contragents/${e}/bank-accounts/${i.id}`)}createClientContact(r,e,i={}){return this.createContact(r,e,{client:{id:r,is_primary:e.isPrimary??!1,not_disturb:e.notDisturb??!1}},i)}updateClientContact(r,e,i={}){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 d(s.data),i)}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,i,s={}){return this.createContact(r,i,{contragents:[{id:e,is_primary:i.isPrimary??!1,not_disturb:i.notDisturb??!1}]},s)}setPrimaryContragentContact(r,e,i){return this.setPrimaryContact(`/internal/clients/${r}/contragents/${e}/contacts/${i.id}/primary`,i.isPrimary??!1)}detachContragentContact(r,e,i){return this.detachContact(`/internal/clients/${r}/contragents/${e}/contacts/${i.id}/detach`)}createDeliveryAddressContact(r,e,i,s={}){return this.createContact(r,i,{addresses:[{id:e,is_primary:i.isPrimary??!1,not_disturb:i.notDisturb??!1}]},s)}setPrimaryDeliveryAddressContact(r,e,i){return this.setPrimaryContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${i.id}/primary`,i.isPrimary??!1)}detachDeliveryAddressContact(r,e,i){return this.detachContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${i.id}/detach`)}createContact(r,e,i,s={}){var u,h;const o={name:e.name,position:e.position,comment:e.comment,...i};return(u=e.phone)!=null&&u.length&&(o.phone=e.phone),(h=e.email)!=null&&h.length&&(o.email=e.email),this.post(`/internal/clients/${r}/contacts`,o,y=>new d(y.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}`)}}const ee=class ee extends f{constructor(){super();t(this,"responseDataCacheTimeout");this.responseDataCacheTimeout=T().config.http.responseDataCacheTimeout}static getCachedResponse(e){const i=ee.responseDataCache.get(e);if(i&&i.validTo>new Date)return i.val}cacheResponse(e,i){ee.responseDataCache.set(e,{validTo:g.addSeconds(new Date,this.responseDataCacheTimeout),val:i})}getTypedDataArrayRequester(e,i,s=!1,o={}){const u=i+(l.isEmpty(o)?"":` >>> ${JSON.stringify(o)}`),h=s?ee.getCachedResponse(u):void 0;return h?Promise.resolve(h):this.get(i,o).then(y=>{const w=y.map(C=>De.instanceInitializer(e,C));return s&&w&&this.cacheResponse(i,w),w})}};t(ee,"responseDataCache",new Map);let E=ee;class pt extends f{checkPhoneIsBusy(r){return new Promise((e,i)=>{this.request({method:"GET",url:"/public/user/verification/phone/check",params:{phone:r}}).then(s=>{e(!!s.isBusy)}).catch(i)})}}function ht(n="/config.json"){const r=fetch(n).then(e=>e.ok?e.json():(console.error(new Error(`Ошибка загрузки ${n}: ${e.statusText}`)),new Promise(i=>{i({})})));return r.catch(e=>{console.error(e)}),r}class gt extends f{getConfiguratorSettings(r,e){var i;return this.get(`internal/catalog/categories/${r.id}/configurators/${(i=r.properties)==null?void 0:i.configurator}/settings?client_id=${e}`)}searchProduct(r,e,i,s={}){var u;const o=this.get(`internal/catalog/categories/${r.id}/configurators/${(u=r.properties)==null?void 0:u.configurator}/product`,{params:i,client_id:e},h=>new S(h.data));return o.catch(h=>{this.errorResponseHandler(h,s)}),o}createTemplate(r,e,i,s={}){var o;return this.post(`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/template?client_id=${e}`,{...i},()=>{},s)}removeTemplate(r,e,i){var s;return this.delete(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/template/${i}?client_id=${e}`)}}class mt{static defaultDateRanges(){const r=g.addBusinessDays(new Date,1);return{nextWorkingDay:{label:"Следующий рабочий день",from:g.startOfDay(r),to:g.endOfDay(r)},today:{label:"Сегодня",from:g.startOfToday(),to:g.endOfToday()},yesterday:{label:"Вчера",from:g.startOfYesterday(),to:g.endOfYesterday()},tomorrow:{label:"Завтра",from:g.startOfTomorrow(),to:g.endOfTomorrow()}}}}const re=class re{static setLinearValues(r){re.linearValues=r}static productIsMeasurable(r){return re.linearValues.includes(r.unit)}static getProductMultiplicity(r){var e,i;return!((e=r.properties)!=null&&e.ignoreMinCountCheck)&&((i=r.properties)!=null&&i.minCount)&&!re.productIsMeasurable(r)?r.properties.minCount:1}static getProductLengthMultiplicity(r){var e,i,s;return(e=r.properties)!=null&&e.lengthStep?r.properties.lengthStep:!((i=r.properties)!=null&&i.ignoreMinCountCheck)&&((s=r.properties)!=null&&s.minCount)?r.properties.minCount:.01}};t(re,"linearValues",["пог.м.","м.","м2"]);let er=re;class ft{static generateUndefinedManagerInstance(){return new pe({id:0,name:"- Не назначен -",isActive:!0,guid:"-undefined-"})}static isUndefinedManagerInstance(r){return r.id===0&&r.guid==="-undefined-"}}class dr extends E{async getManagers(){const r="/internal/managers",e=E.getCachedResponse(r);if(e)return e;const s=(await this.get(r)).data.map(o=>De.instanceInitializer(pe,o));return this.cacheResponse(r,s),s}}class rr extends Ee{constructor(e){var i,s,o,u,h,y,w,C;super(e);t(this,"client");t(this,"payment");t(this,"delivery");t(this,"attachedUser");t(this,"status");t(this,"salesDirection");t(this,"pendingAt");t(this,"processedAt");t(this,"isOnOrder");t(this,"isNotInStock");t(this,"sum");this.client=new Q(e==null?void 0:e.client),this.payment={type:((i=e==null?void 0:e.payment)==null?void 0:i.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:((u=e==null?void 0:e.delivery)==null?void 0:u.type)??-1,date:l.isString((h=e==null?void 0:e.delivery)==null?void 0:h.date)?g.parseISO(e.delivery.date):((y=e==null?void 0:e.delivery)==null?void 0:y.date)??new Date,address:(w=e==null?void 0:e.delivery)!=null&&w.address?new ye(e.delivery.address):void 0,warehouse:(C=e==null?void 0:e.delivery)!=null&&C.warehouse?new ue(e.delivery.warehouse):void 0},this.attachedUser=new k(e==null?void 0:e.attachedUser),this.status=(e==null?void 0:e.status)??0,this.salesDirection=new L(e==null?void 0:e.salesDirection),this.pendingAt=l.isString(e==null?void 0:e.pendingAt)?g.parseISO(e.pendingAt):e==null?void 0:e.pendingAt,this.processedAt=l.isString(e==null?void 0:e.processedAt)?g.parseISO(e.processedAt):e==null?void 0:e.processedAt,this.isOnOrder=(e==null?void 0:e.isOnOrder)??!1,this.isNotInStock=(e==null?void 0:e.isNotInStock)??!1,this.sum=(e==null?void 0:e.sum)??0}}class jr extends _{constructor(e){super(e);t(this,"product");t(this,"quantity");t(this,"currency");t(this,"costOne");t(this,"costOneRub");t(this,"cost");t(this,"costRub");t(this,"marker");t(this,"height");t(this,"length");t(this,"width");t(this,"logicGroupId");t(this,"salesDirection");t(this,"specificationImgUrl");t(this,"configurator");t(this,"configuratorParams");t(this,"sawing");t(this,"creatorUser");this.product=new H(e.product),this.quantity=e.quantity,this.currency=e.currency,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.cost=e.cost,this.costRub=e.costRub,this.marker=e.marker,this.height=e.height,this.length=e.length,this.width=e.width,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams,this.sawing=e.sawing,this.creatorUser=e.creatorUser&&new k(e.creatorUser)}}class tr extends rr{constructor(e){super(e);t(this,"products");t(this,"invoices");t(this,"comment");t(this,"image");t(this,"contragent");t(this,"barcode");t(this,"orderSource");t(this,"isAllowProcessingWithoutPayment");this.products=(e.products??[]).map(i=>new jr(i)),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?fe.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new v(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment}}class yt extends ge{getOrders(r,e,i){return this.getPaginated("/internal/orders",r,e?[e]:void 0,i,{},s=>{const o={...s.data};return o.data=o.data.map(u=>new rr(u)),o})}getClientOrderStatistics(r,e){return this.get(`/internal/clients/${r}/orders/statistics`,e?{period:e}:{})}getOrder(r){return this.get(`/internal/orders/${r}`,{},e=>new tr(e.data))}addOrderProduct(r,e,i={}){return this.post(`/internal/orders/${r}/products`,{id:e.configurator&&e.category.id,productId:e.product.id,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,dopProdaga:e.dopProdaga,...e.configuratorParams},s=>new tr(s.data),i)}}class qe{constructor(r){t(this,"client");t(this,"product");t(this,"cost");t(this,"costCoefficient");t(this,"source");this.client=new Q(r==null?void 0:r.client),this.product=new S(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)??Ae.Product}}const ir=n=>{var r,e,i,s,o;return n?l.omitBy({cities:(r=n.cities)==null?void 0:r.map(u=>u.id),clients:(e=n.clients)==null?void 0:e.map(u=>u.id),managers:(i=n.managers)==null?void 0:i.map(u=>u.id),partnerGroups:(s=n.partnerGroups)==null?void 0:s.map(u=>u.id),salesDirections:(o=n.salesDirections)==null?void 0:o.map(u=>u.id),hideNotActive:n.hideNotActive},u=>l.isNil(u)||(l.isArray(u)||l.isObject(u))&&l.isEmpty(u)):{}},Gr=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 Ct extends f{analyzeProductPrices(r,e,i){return this.get(`/internal/price/products/${r}/analyze`,{...Gr(e),filters:ir(i)},s=>s.data.map(o=>new qe(o)))}analyzeCategoryPrices(r,e,i){return this.get(`/internal/price/categories/${r}/analyze`,{...Gr(e),filters:ir(i)},s=>s.data.map(o=>new qe(o)))}analyzeCategoryPricesBySquare(r,e,i){return this.get(`/internal/price/categories/${r}/analyze/square`,{...e,filters:ir(i)},s=>s.data.map(o=>new qe(o)))}}class Br{constructor(r){t(this,"cost");t(this,"isLowCost");t(this,"isRetail");t(this,"costDate");t(this,"discountName");t(this,"priceTemplateName");t(this,"product");t(this,"client");t(this,"executor");t(this,"currency");this.cost=r.cost??0,this.isLowCost=r.isLowCost??!1,this.isRetail=r.isRetail??!1,this.costDate=l.isString(r.costDate)?g.parseISO(r.costDate):r.costDate??new Date,this.discountName=r.discountName,this.priceTemplateName=r.priceTemplateName,this.product=r.product?new F(r.product):void 0,this.client=r.client?new k(r.client):void 0,this.executor=r.executor?new k(r.executor):void 0,this.currency=r.currency?new me(r.currency):void 0}}class Mr extends F{constructor(e){super(e);t(this,"history");this.history=l.map(e.history,i=>new Br(i))}}class Pt extends f{getProductPriceHistory(r){var o,u,h,y,w;const e=T().config.dateFormats.api,i=l.omitBy(l.merge(r,{costDate:{from:l.isDate((o=r.costDate)==null?void 0:o.from)?g.format(r.costDate.from,e):(u=r.costDate)==null?void 0:u.from,to:l.isDate((h=r.costDate)==null?void 0:h.to)?g.format(r.costDate.to,e):(y=r.costDate)==null?void 0:y.to}}),C=>l.isNil(C)||(l.isArray(C)||l.isObject(C))&&l.isEmpty(C)),s=((w=r.product)==null?void 0:w[0])??0;return delete i.product,this.get(`/internal/price/products/${s}/history`,i).then(C=>[new Mr(l.merge(C[0],{history:C}))])}}class sr{constructor(r){t(this,"products",[]);t(this,"productCategories",[]);r!=null&&r.products&&(this.products=r.products.map(e=>new F(e))),r!=null&&r.productCategories&&(this.productCategories=r.productCategories.map(e=>new F(e)))}}class wt extends f{getProductCategoryRecommendations(r){return this.get(`/internal/catalog/recommendations/categories/${r.id}`,{},e=>new sr(e.data))}getProductRecommendations(r){return this.get(`/internal/catalog/recommendations/products/${r.id}`,{},e=>new sr(e.data))}saveProductCategoryRecommendations(r,e){return this.post(`/internal/catalog/recommendations/categories/${r.id}`,{product_categories:e.productCategories.map(i=>i.id),products:e.products.map(i=>i.id)})}saveProductRecommendations(r,e){return this.post(`/internal/catalog/recommendations/products/${r.id}`,{product_categories:e.productCategories.map(i=>i.id),products:e.products.map(i=>i.id)})}}class R extends E{getReference(r,e=!1){return this.getTypedDataArrayRequester(Sr,`/internal/references/${r}`,e)}getChannelPrimaryInterest(){return this.getTypedDataArrayRequester(Fe,"/internal/references/channel-primary-interest",!0)}getContactPositions(){return this.getTypedDataArrayRequester($r,"/internal/references/contact-position",!0)}getCuratedDirection(){return this.getTypedDataArrayRequester(Te,"/internal/references/curated-direction",!0)}getCurrency(){return this.getTypedDataArrayRequester(me,"/public/references/currency",!0)}getPartnerGroup(){return this.getTypedDataArrayRequester(J,"/internal/references/partner-group",!0)}getOpf(){return this.getTypedDataArrayRequester(U,"/public/references/opf",!0)}getOrderPaymentStatuses(){return this.getTypedDataArrayRequester(br,"/public/references/order-payment-status",!0)}getOrderStatuses(){return this.getTypedDataArrayRequester(Ir,"/public/references/order-status",!0)}getPaymentTypes(){return this.getTypedDataArrayRequester(kr,"/public/references/payment-type",!0)}getResourceTypes(){return this.getTypedDataArrayRequester(Ke,"/internal/references/resource-type",!0)}getSalesDirections(){return this.getTypedDataArrayRequester(L,"/public/references/sales-direction",!0)}getSourcePrimaryInterest(){return this.getTypedDataArrayRequester(Qe,"/internal/references/source-primary-interest",!0)}searchCity(r){return this.getTypedDataArrayRequester(be,`/internal/references/city-with-region-and-country/search?term=${r}`)}searchRegion(r){return this.getTypedDataArrayRequester(K,`/internal/references/region-with-country/search?term=${r}`)}searchCountry(r){return this.getTypedDataArrayRequester(z,`/internal/references/country/search?term=${r}`)}getDeliveryTypes(){return this.getTypedDataArrayRequester(G,"/internal/references/delivery-type",!0)}getWarehouses(){return this.getTypedDataArrayRequester(ue,"/public/references/warehouse",!0)}getPropertyTypes(){return this.getTypedDataArrayRequester(He,"/internal/references/property-type",!0)}getPriceCoefficients(){return this.getTypedDataArrayRequester(ce,"/internal/references/price-coefficient",!0)}getProductFileType(){return this.getTypedDataArrayRequester(Lr,"/public/references/product-file-type",!0)}}const D=j.defineStore("common.references_private",()=>{const n=m.ref({}),r=m.ref(void 0),e=m.ref(void 0),i=m.ref(void 0),s=m.ref(void 0),o=m.ref(void 0),u=m.ref(void 0),h=m.ref(void 0),y=m.ref(void 0),w=m.ref(void 0),C=m.ref(void 0),I=m.ref(void 0),Ce=m.ref(void 0),Pe=m.ref(void 0),te=m.ref(void 0),ie=m.ref(void 0),or=m.ref(void 0),p=m.ref(void 0);return{dataLoaderList:n,channelPrimaryInterestReference:r,contactPositionsReference:e,currencyReference:i,deliveryTypeReference:s,managersList:o,opfReference:u,orderPaymentStatusReference:h,orderStatusReference:y,paymentTypeReference:w,partnerGroupReference:C,productFileTypeReference:I,resourceTypesReference:Ce,salesDirectionsReference:Pe,sourcePrimaryInterestReference:te,warehousesReference:ie,propertyTypesReference:or,priceCoefficientsReference:p}}),vt=j.defineStore("common.references",()=>{const n=m.computed(()=>{const p=D();return!p.channelPrimaryInterestReference&&!p.dataLoaderList.channelPrimaryInterestReference&&(p.dataLoaderList.channelPrimaryInterestReference=!0,f.getInstance(R).getChannelPrimaryInterest().then(P=>{p.channelPrimaryInterestReference=P}).catch(l.noop)),p.channelPrimaryInterestReference}),r=m.computed(()=>{const p=D();return!p.contactPositionsReference&&!p.dataLoaderList.contactPositionsReference&&(p.dataLoaderList.contactPositionsReference=!0,f.getInstance(R).getContactPositions().then(P=>{p.contactPositionsReference=P}).catch(l.noop)),p.contactPositionsReference}),e=m.computed(()=>{const p=D();return!p.currencyReference&&!p.dataLoaderList.currencyReference&&(p.dataLoaderList.currencyReference=!0,f.getInstance(R).getCurrency().then(P=>{p.currencyReference=P}).catch(l.noop)),p.currencyReference}),i=m.computed(()=>{const p=D();return!p.opfReference&&!p.dataLoaderList.opfReference&&(p.dataLoaderList.opfReference=!0,f.getInstance(R).getOpf().then(P=>{p.opfReference=P}).catch(l.noop)),p.opfReference}),s=m.computed(()=>{const p=D();return!p.orderPaymentStatusReference&&!p.dataLoaderList.orderPaymentStatusReference&&(p.dataLoaderList.orderPaymentStatusReference=!0,f.getInstance(R).getOrderPaymentStatuses().then(P=>{p.orderPaymentStatusReference=P}).catch(l.noop)),p.orderPaymentStatusReference}),o=m.computed(()=>{const p=D();return!p.orderStatusReference&&!p.dataLoaderList.orderStatusReference&&(p.dataLoaderList.orderStatusReference=!0,f.getInstance(R).getOrderStatuses().then(P=>{p.orderStatusReference=P}).catch(l.noop)),p.orderStatusReference}),u=m.computed(()=>{const p=D();return!p.paymentTypeReference&&!p.dataLoaderList.paymentTypeReference&&(p.dataLoaderList.paymentTypeReference=!0,f.getInstance(R).getPaymentTypes().then(P=>{p.paymentTypeReference=P}).catch(l.noop)),p.paymentTypeReference}),h=m.computed(()=>{const p=D();return!p.partnerGroupReference&&!p.dataLoaderList.partnerGroupReference&&(p.dataLoaderList.partnerGroupReference=!0,f.getInstance(R).getPartnerGroup().then(P=>{p.partnerGroupReference=P}).catch(l.noop)),p.partnerGroupReference}),y=m.computed(()=>{const p=D();return!p.productFileTypeReference&&!p.dataLoaderList.productFileTypeReference&&(p.dataLoaderList.productFileTypeReference=!0,f.getInstance(R).getProductFileType().then(P=>{p.productFileTypeReference=P}).catch(l.noop)),p.productFileTypeReference}),w=m.computed(()=>{const p=D();return!p.resourceTypesReference&&!p.dataLoaderList.resourceTypesReference&&(p.dataLoaderList.resourceTypesReference=!0,f.getInstance(R).getResourceTypes().then(P=>{p.resourceTypesReference=P}).catch(l.noop)),p.resourceTypesReference}),C=m.computed(()=>{const p=D();return!p.salesDirectionsReference&&!p.dataLoaderList.salesDirectionsReference&&(p.dataLoaderList.salesDirectionsReference=!0,f.getInstance(R).getSalesDirections().then(P=>{p.salesDirectionsReference=P}).catch(l.noop)),p.salesDirectionsReference}),I=m.computed(()=>{const p=D();return!p.sourcePrimaryInterestReference&&!p.dataLoaderList.sourcePrimaryInterestReference&&(p.dataLoaderList.sourcePrimaryInterestReference=!0,f.getInstance(R).getSourcePrimaryInterest().then(P=>{p.sourcePrimaryInterestReference=P}).catch(l.noop)),p.sourcePrimaryInterestReference}),Ce=m.computed(()=>{const p=D();return!p.deliveryTypeReference&&!p.dataLoaderList.deliveryTypeReference&&(p.dataLoaderList.deliveryTypeReference=!0,f.getInstance(R).getDeliveryTypes().then(P=>{p.deliveryTypeReference=P}).catch(l.noop)),p.deliveryTypeReference}),Pe=m.computed(()=>{const p=D();return!p.managersList&&!p.dataLoaderList.managersList&&(p.dataLoaderList.managersList=!0,f.getInstance(dr).getManagers().then(P=>{p.managersList=P}).catch(l.noop)),p.managersList}),te=m.computed(()=>{const p=D();return!p.warehousesReference&&!p.dataLoaderList.warehousesReference&&(p.dataLoaderList.warehousesReference=!0,f.getInstance(R).getWarehouses().then(P=>{p.warehousesReference=P}).catch(l.noop)),p.warehousesReference}),ie=m.computed(()=>{const p=D();return!p.propertyTypesReference&&!p.dataLoaderList.propertyTypesReference&&(p.dataLoaderList.propertyTypesReference=!0,f.getInstance(R).getPropertyTypes().then(P=>{p.propertyTypesReference=P}).catch(l.noop)),p.propertyTypesReference}),or=m.computed(()=>{const p=D();return!p.priceCoefficientsReference&&!p.dataLoaderList.priceCoefficientsReference&&(p.dataLoaderList.priceCoefficientsReference=!0,f.getInstance(R).getPriceCoefficients().then(P=>{p.priceCoefficientsReference=P}).catch(l.noop)),p.priceCoefficientsReference});return{channelPrimaryInterestsReference:n,contactPositionsReference:r,currencyReference:e,opfReference:i,orderPaymentStatusReference:s,orderStatusReference:o,paymentTypeReference:u,partnerGroupsReference:h,productFilesTypesReference:y,resourceTypesReference:w,salesDirectionsReference:C,sourcePrimaryInterestsReference:I,deliveryTypeReference:Ce,managersList:Pe,warehousesReference:te,propertyTypesReference:ie,priceCoefficientsReference:or}});class Hr{constructor(r){t(this,"name");t(this,"content");this.name=r.name,this.content=r.content}}class nr{constructor(r){t(this,"resourceType");t(this,"resourceId");t(this,"h1");t(this,"title");t(this,"description");t(this,"keywords");t(this,"meta");var e;this.resourceType=new Ke(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(i=>new Hr(i)))??[]}}class Rt extends f{getResourceSeoData(r,e){return this.get(`/internal/seo/${r.slug}/${e}`,{},i=>new nr(i.data))}saveResourceSeoData(r,e={}){return this.post(`/internal/seo/${r.resourceType.slug}/${r.resourceId}`,r,i=>new nr(i.data),e)}deleteResourceSeoData(r,e){return this.delete(`/internal/seo/${r.slug}/${e}`)}}class Dt extends f{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(i=>{const s=[...i];let o=1;return s.forEach(u=>{u.id=o++}),s})}}var zr=(n=>(n.Admin="admin",n.Manager="manager",n.Operator="operator",n.Client="client",n.Guest="guest",n))(zr||{});class Wr extends Me{constructor(e){super(e);t(this,"type");t(this,"canDoReclamations");t(this,"photo");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}}class At extends f{constructor(){super(),this.baseUrl=`${T().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 Jr extends f{getCurrentUser(){return this.get("/internal/users/info",{},r=>new Wr(r.data),!0)}}const at=j.defineStore("common.user_state_private",()=>{const n=m.ref({}),r=m.ref(void 0);return{dataLoaderList:n,currentUser:r}}),Tt=j.defineStore("common.user_state",()=>({currentUser:m.computed(()=>{const r=at();return!r.currentUser&&!r.dataLoaderList.currentUser&&(r.dataLoaderList.currentUser=!0,f.getInstance(Jr).getCurrentUser().then(e=>{r.currentUser=e}).catch(l.noop).finally(()=>{r.dataLoaderList.currentUser=!1})),r.currentUser})}));class St{constructor(r,e){t(this,"showFeedback",!1);t(this,"feedback","");t(this,"validationStatus");this.showFeedback=!!r,this.feedback=r,this.validationStatus=e}}c.AnyReference=Sr,c.AppBaseConfig=gr,c.BankAccount=Le,c.BasePaginationProvider=ge,c.CalculationTypeEnum=vr,c.Cart=le,c.CartItem=wr,c.CartItemBase=Pr,c.CartProvider=Kr,c.CatalogProvider=Xr,c.CatalogableItem=_e,c.Category=B,c.CategoryPricingRule=ze,c.ChannelPrimaryInterest=Fe,c.City=ot,c.CityWithRegionAndCountry=be,c.Client=xe,c.ClientAdditionalData=_r,c.ClientCategory=he,c.ClientDataProvider=$,c.ClientPriceProvider=Zr,c.ClientPriceTemplateProvider=xr,c.ClientProduct=H,c.ClientProductCategoryDataProvider=rt,c.ClientProductDataProvider=tt,c.ClientShortInfo=Q,c.ClientsAdditionalDataRequestTypeEnum=Tr,c.ClientsListFilters=ct,c.CodedIdentity=F,c.ConfiguratorProvider=gt,c.Contact=Oe,c.ContactLinks=Ge,c.ContactPerson=d,c.ContactPersonRelated=qr,c.ContactPosition=$r,c.ContactRelation=Ne,c.ContragentBase=Ye,c.ContragentFactory=fe,c.ContragentIc=Xe,c.ContragentPerson=Or,c.ContragentUlNr=Nr,c.ContragentUlR=Ze,c.CostSourceEnum=Ae,c.Country=z,c.CuratedDirection=Te,c.Curator=$e,c.Currency=me,c.DataSuggestionProvider=Dt,c.DataTablePagination=ut,c.DataTablePaginationRequestParams=Ur,c.DataTableSortRequestParams=lt,c.DateTimeProvider=mt,c.DeletableNamedIdentity=Dr,c.DeliveryAddress=ye,c.DeliveryType=G,c.DetailedJwtPayload=Fr,c.DeviceTypeResolutionConfig=cr,c.DiscountShortInfo=Ar,c.FieldValidationResultData=St,c.FilterGroup=x,c.FilterItem=We,c.FilterOpEnum=ke,c.GeoCoordinates=de,c.HiddenCatalogableItem=yr,c.HttpCachedRequester=E,c.HttpParamsConfig=ur,c.HttpRequester=f,c.Identity=_,c.Image=Cr,c.JwtPayload=q,c.Manager=pe,c.ManagerCommon=ae,c.ManagerDataFactory=ft,c.ManagerDataProvider=dr,c.MetaTagItem=Hr,c.NamedIdentity=A,c.Opf=U,c.OpfEnum=N,c.Order=tr,c.OrderInfo=rr,c.OrderPaymentStatus=br,c.OrderProduct=jr,c.OrderShortInfo=Ee,c.OrderStatus=Ir,c.OrdersDataProvider=yt,c.PartnerGroup=J,c.PaymentType=kr,c.PreferencesStorageProvider=ne,c.PriceAnalyze=qe,c.PriceAnalyzeProvider=Ct,c.PriceCoefficient=ce,c.PriceCoefficientEnum=Ue,c.PriceHistoryDataProvider=Pt,c.PriceHistoryItem=Br,c.PriceTemplate=M,c.PriceTemplateCategory=Se,c.PriceTemplateClient=Y,c.PriceTemplateICatalogableItem=Be,c.PriceTemplateProduct=Ie,c.PriceTemplateProvider=it,c.PricingRole=Z,c.PricingRoleProvider=st,c.PrimaryCatalogableItem=ve,c.Product=S,c.ProductCategoryDataProvider=Er,c.ProductDataProvider=et,c.ProductFileType=Lr,c.ProductPriceCoefficient=Re,c.ProductPriceHistory=Mr,c.PropertiesProvider=nt,c.Property=X,c.PropertyType=He,c.PropertyTypeEnum=Rr,c.PropertyValue=W,c.RecommendationsDataProvider=wt,c.RecommendationsList=sr,c.Reference=v,c.ReferenceDataProvider=R,c.Region=K,c.ResourceType=Ke,c.SalesDirection=L,c.SentryConfig=lr,c.Seo=nr,c.SeoDataProvider=Rt,c.SourcePrimaryInterest=Qe,c.StockCount=fr,c.TemplatesListFilters=Yr,c.TypedInstanceFactory=De,c.UnitsHelper=er,c.UnknownClientDataProvider=pt,c.UpdatableNamedIdentity=je,c.User=Wr,c.UserAuthDataProvider=At,c.UserCommonInfo=Me,c.UserDataProvider=Jr,c.UserPricingRole=ar,c.UserShortInfo=k,c.UserTypeEnum=zr,c.VersionConfig=pr,c.Warehouse=ue,c.WebSocketConfig=hr,c.findCatalogItemByIdRecursive=Je,c.flattenCatalogItems=Ve,c.loadRemoteConfig=ht,c.useAuthStateStore=we,c.useReferencesStore=vt,c.useUserStateStore=Tt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=sc-common-lib.umd.cjs.map