@snabcentr/common-lib 4.4.0-dev → 4.5.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.json +1 -1
- package/dist/sc-common-lib.js +564 -507
- package/dist/sc-common-lib.js.map +1 -1
- package/dist/sc-common-lib.umd.cjs +1 -1
- package/dist/sc-common-lib.umd.cjs.map +1 -1
- package/dist/src/admins/classes/admin-full-info.d.ts +18 -0
- package/dist/src/admins/classes/admin-full-info.d.ts.map +1 -0
- package/dist/src/admins/classes/admin-short-info.d.ts +18 -0
- package/dist/src/admins/classes/admin-short-info.d.ts.map +1 -0
- package/dist/src/admins/classes/admins-list-filters.d.ts +38 -0
- package/dist/src/admins/classes/admins-list-filters.d.ts.map +1 -0
- package/dist/src/admins/classes/index.d.ts +4 -0
- package/dist/src/admins/classes/index.d.ts.map +1 -0
- package/dist/src/admins/index.d.ts +4 -0
- package/dist/src/admins/index.d.ts.map +1 -0
- package/dist/src/admins/interfaces/i-admin-full-info.d.ts +11 -0
- package/dist/src/admins/interfaces/i-admin-full-info.d.ts.map +1 -0
- package/dist/src/admins/interfaces/i-admin-short-info.d.ts +11 -0
- package/dist/src/admins/interfaces/i-admin-short-info.d.ts.map +1 -0
- package/dist/src/admins/interfaces/i-admins-list-filters.d.ts +27 -0
- package/dist/src/admins/interfaces/i-admins-list-filters.d.ts.map +1 -0
- package/dist/src/admins/interfaces/index.d.ts +4 -0
- package/dist/src/admins/interfaces/index.d.ts.map +1 -0
- package/dist/src/admins/providers/admin-provider.d.ts +69 -0
- package/dist/src/admins/providers/admin-provider.d.ts.map +1 -0
- package/dist/src/admins/providers/index.d.ts +2 -0
- package/dist/src/admins/providers/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@snabcentr/common-core"),require("date-fns"),require("lodash-es")):typeof define==`function`&&define.amd?define([`exports`,`@snabcentr/common-core`,`date-fns`,`lodash-es`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`SC Common Lib`]={},e[`@snabcentr/common-core`],e[`date-fns`],e[`lodash-es`]))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=function(e){return e.Image=`image`,e.Video=`video`,e}({}),a=class extends t.Identity{mediaType;isCover;isUnused;url;urlWebp;constructor(e){super(e,``),this.mediaType=e?.mediaType??i.Image,this.isCover=e?.isCover??!1,this.isUnused=e?.isUnused??!1,this.url=e?.url??``,this.urlWebp=e?.urlWebp}isImage(){return this.mediaType===i.Image}isVideo(){return this.mediaType===i.Video}},o=function(e){return e.Draft=`draft`,e.Published=`published`,e.Scheduled=`scheduled`,e}({}),s=class extends t.Identity{createdAt;constructor(e,n){super(e,n),this.createdAt=t.DateHelper.parse(e?.createdAt)??new Date}},c=class e extends s{static resolvePublicationStatus(e){return(0,r.isNil)(e)?o.Draft:e.getTime()>Date.now()?o.Scheduled:o.Published}static getSlugError(e){return e?/[^a-z0-9-]/.test(e)?`Допустимы только строчные латинские буквы, цифры и дефис: пример «kak-vybrat-podokonnik».`:(0,r.startsWith)(e,`-`)||(0,r.endsWith)(e,`-`)?`Обозначение не может начинаться или заканчиваться дефисом.`:(0,r.includes)(e,`--`)?`Дефисы не могут идти подряд: разделяйте слова одним дефисом.`:``:``}static parseDate(e){return(0,r.isNil)(e)?null:(0,r.isString)(e)?(0,n.parseISO)(e):e}slug;title;publishedAt;constructor(t){super(t,-1),this.slug=t?.slug??``,this.title=t?.title??``,this.publishedAt=e.parseDate(t?.publishedAt)}getPublicationStatus(){return e.resolvePublicationStatus(this.publishedAt)}},l=class extends c{content;media;constructor(e){super(e),this.content=e?.content??``,this.media=(e?.media??[]).map(e=>new a(e))}toSaveData(e=!1){return{title:this.title,slug:this.slug.length>0?this.slug:void 0,content:e?this.content:void 0,publishedAt:this.publishedAt}}getCover(){return this.media.find(e=>e.isCover)}getUnusedMedia(){return this.media.filter(e=>e.isUnused)}},u=class{asClearRaw(){let e={};return Object.keys(this).forEach(t=>{let n=this[t];(0,r.isNil)(n)||(0,r.isString)(n)&&n.trim().length===0||(0,r.isFunction)(n.isNewRec)&&n.isNewRec()||(e[t]=n)}),e}},d=class{from;to;constructor(e){this.from=(0,r.isString)(e?.from)?(0,n.parseISO)(e.from):e?.from??null,this.to=(0,r.isString)(e?.to)?(0,n.parseISO)(e.to):e?.to??null}},ee=class extends u{id;title;slug;content;publicationStatus;publishedAt;createdAt;constructor(e){super(),this.id=e?.id,this.title=e?.title,this.slug=e?.slug,this.content=e?.content,this.publicationStatus=e?.publicationStatus,this.publishedAt=new d(e?.publishedAt),this.createdAt=new d(e?.createdAt)}resetFilterValue(e){switch(e){case`id`:case`title`:case`slug`:case`content`:case`publicationStatus`:this[e]=void 0;break;case`publishedAt`:this.publishedAt.from=null,this.publishedAt.to=null;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null}return this}asClearRaw(){let e=super.asClearRaw();return!e?.publishedAt?.from&&!e?.publishedAt?.to&&delete e.publishedAt,!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,e}},te=class e extends t.BasePaginationProvider{static preparePostSaveData(e){let i={};if((0,r.isUndefined)(e.title)||(i.title=e.title),(0,r.isUndefined)(e.slug)||(i.slug=e.slug),(0,r.isUndefined)(e.content)||(i.content=e.content),!(0,r.isUndefined)(e.publishedAt)){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;i.publishedAt=(0,r.isNil)(e.publishedAt)?null:(0,n.format)(e.publishedAt,a)}return i}getPostList(e,t,n){return this.getPaginated(`/internal/blog`,e,t,n,{},e=>({...e.data,data:e.data.data.map(e=>new c(e))}))}getPost(e){return this.get(`/internal/blog/${e}`,{},e=>new l(e.data))}createPost(t,n={}){return this.post(`/internal/blog`,e.preparePostSaveData(t),e=>new l(e.data),n)}updatePost(t,n,r={}){return this.patch(`/internal/blog/${t}`,e.preparePostSaveData(n),e=>new l(e.data),r)}removePost(e){return this.delete(`/internal/blog/${e}`)}uploadMedia(e,t,n,r,i={}){return this.request({method:`POST`,url:`/internal/blog/${e}/media`,data:{file:t,isCover:n??!1},onUploadProgress:e=>{r&&r(e.total?Math.round(e.loaded/e.total*100):0)}},e=>new a(e.data),i)}updateMedia(e,t,n,r={}){return this.patch(`/internal/blog/${e}/media/${t}`,{isCover:n},e=>new a(e.data),r)}removeMedia(e,t){return this.delete(`/internal/blog/${e}/media/${t}`)}},f=class extends t.UpdatableNamedIdentity{deletedAt;constructor(e){super(e),this.deletedAt=t.DateHelper.parse(e?.deletedAt)}},p=class extends t.NamedIdentity{type;isActive;constructor(e){super(e),this.type=e?.type,this.isActive=e?.isActive??!0}},m=class extends f{costCoefficient;isLowPriceAllowed;publishedAt;description;percent;owner;constructor(e){super(e),this.costCoefficient=e?.costCoefficient??0,this.isLowPriceAllowed=e?.isLowPriceAllowed??!1,this.publishedAt=t.DateHelper.parse(e?.publishedAt),this.description=e?.description??void 0,this.percent=e?.percent??0,this.owner=new p(e?.owner)}},h=class extends t.UpdatableNamedIdentity{description;owner;constructor(e){super(e),this.description=e?.description??``,this.owner=e?.owner?new p(e.owner):void 0}},g=class{coefficient;value;cost;percent;readOnly;constructor(e){this.coefficient=new t.PriceCoefficient(e?.coefficient),this.value=e?.value??0,this.cost=e?.cost??0,this.percent=e?.percent??0,this.readOnly=e?.readOnly??!0}},ne=class{warehouse;count;constructor(e){this.warehouse=new t.Warehouse(e?.warehouse),this.count=e?.count??0}},re=class extends t.NamedIdentity{slug=``;description;isSquare=!1;isLinear=!1;constructor(e){super(e),e&&(this.slug=e.slug??``,this.description=e.description,this.isSquare=e.isSquare??!1,this.isLinear=e.isLinear??!1)}},_=class extends t.NamedIdentity{code=``;constructor(e){super(e),this.code=e?.code??``}},ie=class extends _{slug;type;constructor(e){super(e),this.slug=e?.slug??``}},ae=class extends ie{isHidden;constructor(e){super(e),this.isHidden=e?.isHidden??!1}},oe=class{image;preview;isDefault;constructor(e,t){this.image=`${t??``}${e.image}`,this.preview=`${t??``}${e.preview}`,this.isDefault=e.isDefault}},v=class extends ie{isPrimary;constructor(e){super(e),this.isPrimary=e?.isPrimary??!1}},y=class extends ae{supplierSku;unit;pack;minCount;currency;cost;costRub;costDate;onOrder;stockCount;category;categories;images;properties;retailCost;retailCostRub;priceCoefficients;constructor(e){super(e),this.supplierSku=e?.supplierSku,this.unit=e?.unit?new re(e.unit):new re,this.pack=e?.pack,this.minCount=e?.minCount,this.currency=e?.currency?new t.Currency(e.currency):new t.Currency,this.cost=e?.cost??0,this.costRub=e?.costRub??0,this.costDate=(0,r.isString)(e?.costDate)?(0,n.parseISO)(e.costDate):e?.costDate,this.onOrder=e?.onOrder??!1,this.stockCount=e?.stockCount?.map(e=>new ne(e))??[],this.type=`product`;let i=e?.category??e?.categories?.find(e=>e.isPrimary);i&&(this.category=new v({...i,isPrimary:!0}),this.categories=[this.category]),e?.categories&&(this.categories=e.categories.map(e=>new v(e))),this.images=e?.images?.map(e=>new oe(e,(0,t.useBaseConfigStore)().config.http.mediaUrl))??[],this.properties=e?.properties??{},this.retailCost=e?.retailCost,this.retailCostRub=e?.retailCostRub,this.priceCoefficients=e?.priceCoefficients?.map(e=>new g(e))??[],e&&`codeNumber`in e&&!e.code&&(this.code=e?.codeNumber)}getIsMeasurable(){return this.unit.isLinear||this.unit.isSquare}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}},se=function(e){return e.Discount=`discount`,e.PriceTemplate=`price_template`,e.ClientPrice=`client_price`,e.Product=`product`,e}({}),b=class extends y{costCoefficient;costSource;discount;priceTemplate;priceCoefficient;increasePercent;isPreviouslyOrdered;isRequired;isFavorite;constructor(e){super(e),this.costCoefficient=e?.costCoefficient??0,this.costSource=e?.costSource??se.Product,this.discount=e?.discount?new m(e.discount):void 0,this.priceTemplate=e?.priceTemplate?new h(e.priceTemplate):void 0,this.priceCoefficient=e?.priceCoefficient?new t.PriceCoefficient(e.priceCoefficient):void 0,this.increasePercent=e?.increasePercent,this.isPreviouslyOrdered=e?.isPreviouslyOrdered,this.isRequired=e?.isRequired,this.isFavorite=e?.isFavorite}},x=class extends v{isHidden;parentCategoryId;properties;currencyRates;constructor(e){super(e),this.isHidden=e?.isHidden??!1,this.parentCategoryId=e?.parentCategoryId,this.properties=e?.properties,this.type=`category`,this.currencyRates=e?.currencyRates?Object.fromEntries(Object.entries(e.currencyRates).map(([e,t])=>[(0,r.toUpper)(e),t])):void 0}},ce=class extends t.Identity{category;product;quantity;currency;marker;height;length;width;configurator;configuratorParams;isAdditionalSale;creator;isRemoved;ord;onOrder;originalId;replacementId;constructor(e){super(e),this.product=new b(e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new x,this.currency=e.currency?new t.Currency(e.currency):void 0,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&(0,r.cloneDeep)(e.configuratorParams),this.isAdditionalSale=e.isAdditionalSale,this.creator=e.creator&&new p(e.creator),this.isRemoved=e.isRemoved,this.ord=e.ord,this.onOrder=e.onOrder,this.originalId=e.originalId,this.replacementId=e.replacementId}},le=class extends ce{cost;costOne;costOneRub;costRub;logicGroupId;salesDirection;specificationImgUrl;sawing;currency;constructor(e){super(e),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=(0,r.isArray)(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,this.currency=new t.Currency(e.currency)}},S=class{items;resultSum;directionsSum;constructor(e){this.items=e.items.map(e=>new le(e)),this.resultSum=e.resultSum,this.directionsSum=e.directionsSum}},ue=class extends t.HttpRequester{getCart(e){return this.get(`internal/clients/${e.id}/cart`,{},e=>new S(e.data))}deleteCart(e){return this.delete(`internal/clients/${e.id}/cart`)}addCartItem(e,t,n={}){return this.patch(`internal/clients/${e.id}/cart`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new S(e.data),n)}patchCartItem(e,t,n={}){return this.patch(`internal/clients/${e.id}/cart/${t.id}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new S(e.data),n)}deleteCartItem(e,t){return this.delete(`internal/clients/${e.id}/cart/${t.id}`,e=>new S(e.data))}addCartItemFromCSV(e,t){return this.post(`internal/clients/${e.id}/cart/add-products-from-csv`,t,e=>new S(e.data))}getCartItemFromCSVExample(e){return this.get(`internal/clients/${e.id}/cart/add-products-from-csv/example`,{},e=>new Blob([e.data],{type:`text/csv`}))}},de=function(e){return e.m2Cost=`m2Cost`,e.percent=`percent`,e.value=`value`,e}({}),fe=function(e){return e.Checkbox=`checkbox`,e.Range=`range`,e.Toggle=`toggle`,e}({}),C=class e extends x{categories;products;constructor(t){super(t),this.categories=t?.categories?.map(t=>new e(t)),this.products=t?.products?.map(e=>new y(e))}},pe=class extends x{isDisabled;isRequired;isFavorite;hidingComment;manager;constructor(e){super(e),this.isDisabled=e?.isDisabled??!1,this.isRequired=e?.isRequired??!1,this.isFavorite=e?.isFavorite??!1,this.hidingComment=e?.hidingComment,this.manager=e?.manager?new t.Manager(e.manager):void 0}},me=class e extends pe{categories;products;constructor(t){super(t),this.categories=t?.categories?.map(t=>new e(t)),this.products=t?.products?.map(e=>new b(e))}},he=class{priceCoefficient;increasePercent;constructor(e){this.priceCoefficient=e?.priceCoefficient&&new t.PriceCoefficient(e.priceCoefficient),this.increasePercent=e?.increasePercent}},ge=class extends he{constructor(e){super(e)}},w=class extends ge{productCategory;constructor(e){super(e),this.productCategory=new x(e?.productCategory)}},T=class extends t.NamedIdentity{photo;contacts;curatedDirection;constructor(e){super(e),this.photo=e.photo,this.contacts=new t.ContactLinks(e.contacts),this.curatedDirection=new t.CuratedDirection(e.curatedDirection)}},E=class extends t.UserCommonInfo{salesDirection;debt;alternativeName;city;comment;isPhoneApproved;isEmailApproved;managers;curators;constructor(e){super(e),this.salesDirection=new t.SalesDirection(e?.salesDirection),this.debt=e?.debt??0,this.alternativeName=e?.alternativeName??``,this.city=new t.CityWithRegionAndCountry(e?.city),this.comment=e?.comment,this.isPhoneApproved=e?.isPhoneApproved??!1,this.isEmailApproved=e?.isEmailApproved??!1,this.managers=e?.managers?.map(e=>new t.ManagerCommon(e))??[],this.curators=e?.curators?.map(e=>new T(e))??void 0}},_e=class extends s{deletedAt;constructor(e,n){super(e,n),this.deletedAt=t.DateHelper.parse(e?.deletedAt)}},D=class extends _e{client;priceTemplate;constructor(e){super(e),this.client=new E(e?.client),this.priceTemplate=new h(e?.priceTemplate)}},O=class extends ge{product;constructor(e){super(e),this.product=new y(e?.product)}},k=class extends t.NamedIdentity{type;description;metadata;isFilterable;constructor(e){super(e),this.type=new t.PropertyType(e?.type),this.description=e?.description??``,this.metadata=e?.metadata,this.isFilterable=e?.isFilterable}},A=class{property;value;constructor(e){this.property=new k(e?.property),this.value=e?.value??``}},ve=class{id;name;description;ownerName;createdAt=new d;updatedAt=new d;constructor(e){this.id=e?.id,this.name=e?.name,this.description=e?.description,this.ownerName=e?.ownerName,this.createdAt=new d(e?.createdAt),this.updatedAt=new d(e?.updatedAt)}resetFilterValue(e){switch(e){case`id`:case`name`:case`description`:case`ownerName`:this[e]=void 0;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`updatedAt`:this.updatedAt.from=null,this.updatedAt.to=null}return this}asClearRaw(){let e={};return Object.keys(this).forEach(t=>{let n=this[t];(0,r.isNil)(n)||(0,r.isString)(n)&&n.trim().length===0||(0,r.isFunction)(n.isNewRec)&&n.isNewRec()||(e[t]=n)}),!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,!e?.updatedAt?.from&&!e?.updatedAt?.to&&delete e.updatedAt,e}},ye=class extends he{executor;createdAt;constructor(e){super(e),this.executor=e?.executor?new p(e.executor):void 0,this.createdAt=t.DateHelper.parse(e?.createdAt)}},j=class extends ye{product;constructor(e){super(e),this.product=new y(e?.product)}},be=class extends ye{productCategory;constructor(e){super(e),this.productCategory=new x(e?.productCategory)}},M=class extends t.NamedIdentity{description;canChangeLowCost;parentRoleId;subRoles=[];parentRole;level=0;constructor(e){super(e),this.description=e?.description,this.canChangeLowCost=e?.canChangeLowCost??!1,this.parentRoleId=e?.parentRoleId}},xe=class{role;category;minCoefficient;constructor(e){this.role=new M(e?.role),this.category=new x(e?.category),this.minCoefficient=new t.PriceCoefficient(e?.minCoefficient)}},Se=class{isFake;isHidden;isMultiple;type;ord;constructor(e){this.isFake=e?.isFake??!1,this.isHidden=e?.isHidden??!1,this.isMultiple=e?.isMultiple??null,this.type=e?.type??null,this.ord=e?.ord??0}},Ce=class{category;property;settings;constructor(e){this.category=new x(e?.category),this.property=new k(e?.property),this.settings=new Se(e?.settings)}},we=class{id;label;constructor(e){this.id=e?.id??``,this.label=e?.label??``}},Te=class{id;label;type;ord;isMultiple;values;min;max;constructor(e){this.id=e?.id??``,this.label=e?.label??``,this.type=e?.type??fe.Checkbox,this.ord=e?.ord??0,this.isMultiple=e?.isMultiple??null,this.values=e?.values?.map(e=>new we(e))??[],this.min=e?.min??null,this.max=e?.max??null}},Ee=class extends t.HttpRequester{search(e,t=!1){return this.get(`/internal/catalog/search`,{term:e,show_hidden:t})}getPriceExportLink(e=`csv`,n=!1,r=void 0,i=void 0){let a=`${(0,t.useBaseConfigStore)().config.http.portalApiUrl}/api/internal/price/export?format=${e}&show_hidden=${n}`;return r&&(a+=`&category_id=${r}`),i&&(a+=`&client_id=${i}`),a}},De=class extends t.HttpRequester{importPrices(e,t,n=!1){return this.post(`/internal/clients/${e}/price/import`,t,void 0,{},n)}getCategoryPrices(e){return this.getTypedList(be,`/internal/clients/${e}/price/categories`)}getCategoryPrice(e,t){return this.get(`/internal/clients/${e}/price/categories/${t}`,{},e=>new be(e.data))}updateCategoryPrices(e,t,n,r=!1){return this.request({method:`PATCH`,url:`/internal/clients/${e}/price/categories/${t}`,data:{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},params:r?{recursively:!0}:{}})}removeCategoryPrices(e,t,n=!1){return this.request({method:`DELETE`,url:`/internal/clients/${e}/price/categories/${t}`,params:n?{recursively:!0}:{}})}removeCategoryProductsPrices(e,t,n=!1){return this.request({method:`DELETE`,url:`/internal/clients/${e}/price/categories/${t}/products`,params:n?{recursively:!0}:{}})}markCategoryRequired(e,t){return this.post(`/internal/clients/${e}/price/categories/${t}/required`)}unmarkCategoryRequired(e,t){return this.delete(`/internal/clients/${e}/price/categories/${t}/required`)}markCategoryDisabled(e,t,n){return this.post(`/internal/clients/${e}/price/categories/${t}/disabled`,{comment:n})}unmarkCategoryDisabled(e,t){return this.delete(`/internal/clients/${e}/price/categories/${t}/disabled`)}addCategoryManager(e,t,n){return this.post(`/internal/clients/${e}/price/categories/${t}/manager`,{manager_id:n})}removeCategoryManager(e,t){return this.delete(`/internal/clients/${e}/price/categories/${t}/manager`)}getProductPrices(e){return this.getTypedList(j,`/internal/clients/${e}/price/products`)}getProductPrice(e,t){return this.get(`/internal/clients/${e}/price/products/${t}`,{},e=>new j(e.data))}updateProductPrice(e,t,n){return this.patch(`/internal/clients/${e}/price/products/${t}`,{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},e=>new j(e.data))}removeProductPrice(e,t){return this.delete(`/internal/clients/${e}/price/products/${t}`)}markProductRequired(e,t){return this.post(`/internal/clients/${e}/price/products/${t}/required`)}unmarkProductRequired(e,t){return this.delete(`/internal/clients/${e}/price/products/${t}/required`)}getCommercialOfferHtml(e,t){return this.get(`/internal/clients/${e}/price/commercial-offer/view`,t,e=>new Blob([e.data],{type:`text/html`}))}getCommercialOfferPdf(e,t){return this.getBlob(`/internal/clients/${e}/price/commercial-offer/download`,t,e=>new Blob([e.request.response],{type:`application/pdf`}))}sendCommercialOffer(e,t){return this.post(`/internal/clients/${e}/price/commercial-offer/send`,t)}},Oe=class extends t.HttpRequester{getTemplateList(e){return this.getTypedList(D,`/internal/clients/${e}/price/templates`)}getActiveTemplate(e){return this.get(`/internal/clients/${e}/price/templates/active`,{},e=>new D(e.data),!0)}attachTemplate(e,r,i){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.post(`/internal/clients/${e}/price/templates/${r}`,i&&{startAt:i.startAt&&(0,n.format)(i.startAt,a),endAt:i.endAt&&(0,n.format)(i.endAt,a)},e=>new D(e.data),{},!0)}applyTemplate(e,t){return this.post(`/internal/clients/${e}/price/templates/${t}/apply`,{},void 0,{},!0)}changeTemplate(e,r,i,a){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.patch(`/internal/clients/${e}/price/templates/${r}/${i}`,a&&{startAt:a.startAt&&(0,n.format)(a.startAt,o),endAt:a.endAt&&(0,n.format)(a.endAt,o)},e=>new D(e.data))}detachTemplate(e,t,n){return this.delete(`/internal/clients/${e}/price/templates/${t}/${n}`)}},ke=class extends t.HttpRequester{getRootCategoriesList(e=!1){return this.getTypedList(C,`/internal/catalog/categories`,{showHidden:e})}getCategoryData(e,t=!1,n=!1){return this.get(`/internal/catalog/categories/${e}`,{showHidden:t,withNestedCategories:n},e=>new C(e.data))}getPublicCategoryData(e){return this.get(`/public/catalog/categories/${e}`,{},e=>new C(e.data))}getCategoryProductsList(e,t=!0,n=!1){return this.get(`/internal/catalog/categories/${e}/products`,{showHidden:n,withPriceCoefficients:t},e=>(0,r.map)(e.data,e=>new y(e)))}getCategoryProductsCoefficients(e){return this.get(`/internal/catalog/categories/${e}/products/coefficients`,{},e=>{let{data:t}=e;return(0,r.forEach)(t,e=>e.map(e=>new g(e))),t})}publicSimpleSearch(e,t=10){return new Promise((n,r)=>{this.get(`/public/catalog/search/simple?limit=${t}&term=${e}`).then(e=>{n(e.categories.map(e=>new C(e)))}).catch(e=>{r(e)})})}},Ae=class extends t.BasePaginationProvider{getProductData(e,t=!1){return this.get(`/internal/catalog/products/${e}`,{withPriceCoefficients:t},e=>new y(e.data))}getPublicProductData(e){return this.get(`/public/catalog/products/${e}`,{},e=>new y(e.data))}getProductPriceCoefficients(e){return this.get(`/internal/catalog/products/${e}/coefficients`,{},e=>(0,r.map)(e.data,e=>new g(e)))}getNewProducts(e,r,i=!0){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.getTypedPaginated(y,`/internal/catalog/products/new`,void 0,void 0,r,{period:{from:(0,n.format)(e,a)},withPriceCoefficients:i})}publicSimpleSearch(e,t=10){return new Promise((n,r)=>{this.get(`/public/catalog/search/simple?limit=${t}&term=${e}`).then(e=>{n(e.products.map(e=>new y(e)))}).catch(e=>{r(e)})})}},je=class extends t.HttpRequester{getRootCategoriesList(e,t=!1){return this.getTypedList(me,`/internal/catalog/categories`,{clientId:e,showHidden:t})}getCategoryData(e,t,n=!1,r=!1){return this.get(`/internal/catalog/categories/${t}`,{clientId:e,showHidden:n,withNestedCategories:r},e=>new me(e.data))}getCategoryProductsList(e,t,n=!0,i=!1){return this.get(`/internal/catalog/categories/${t}/products`,{client_id:e,showHidden:i,withPriceCoefficients:n},e=>(0,r.map)(e.data,e=>new b(e)))}},Me=class extends t.BasePaginationProvider{getProductData(e,t,n=!1){return this.get(`/internal/catalog/products/${e}`,{clientId:t,withPriceCoefficients:n},e=>new b(e.data))}getNewProducts(e,r,i,a=!0){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.getTypedPaginated(b,`/internal/catalog/products/new`,void 0,void 0,i,{clientId:e,period:{from:(0,n.format)(r,o)},withPriceCoefficients:a})}},Ne=class extends t.BasePaginationProvider{getTemplateList(e,t,n){return this.getTypedPaginated(h,`/internal/price/templates`,e,t,n)}createTemplate(e,t={}){return this.post(`/internal/price/templates`,e,e=>new h(e.data),t)}getTemplate(e){return this.get(`/internal/price/templates/${e}`,{},e=>new h(e.data))}updateTemplate(e,t,n={}){return this.patch(`/internal/price/templates/${e}`,t,e=>new h(e.data),n)}removeTemplate(e){return this.delete(`/internal/price/templates/${e}`)}getProductTemplatePrices(e){return this.getTypedList(O,`/internal/price/templates/${e}/products`)}getProductTemplatePrice(e,t){return this.get(`/internal/price/templates/${e}/products/${t}`,{},e=>new O(e.data))}saveProductTemplatePrice(e,t,n){return this.post(`/internal/price/templates/${e}/products/${t}`,{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},e=>new O(e.data))}deleteProductTemplatePrice(e,t){return this.delete(`/internal/price/templates/${e}/products/${t}`)}getCategoryTemplatePrices(e){return this.getTypedList(w,`/internal/price/templates/${e}/categories`)}getCategoryTemplatePrice(e,t){return this.get(`/internal/price/templates/${e}/categories/${t}`,{},e=>new w(e.data))}saveCategoryTemplatePrice(e,t,n,r=!1){return this.request({method:`POST`,url:`/internal/price/templates/${e}/categories/${t}`,data:{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},params:r?{recursively:!0}:{}},e=>new w(e.data))}deleteCategoryTemplatePrice(e,t,n=!1){return this.request({method:`DELETE`,url:`/internal/price/templates/${e}/categories/${t}`,params:n?{recursively:!0}:{}})}getTemplateClients(e){return this.getTypedList(D,`/internal/price/templates/${e}/clients`)}},Pe=class extends t.HttpRequester{getRoles(){return this.getTypedList(M,`/internal/price/roles`)}createRole(e){return this.post(`/internal/price/roles`,e,e=>new M(e.data))}getRole(e){return this.get(`/internal/price/roles/${e}`,{},e=>new M(e.data))}updateRole(e,t){return this.patch(`/internal/price/roles/${e}`,t,e=>new M(e.data))}deleteRole(e){return this.delete(`/internal/price/roles/${e}`)}getCategoryRules(e){return this.getTypedList(xe,`/internal/price/roles/rules/categories/${e}`)}updateCategoryRules(e,n){return this.patch(`/internal/price/roles/rules/categories/${e}`,n,e=>t.TypedInstanceFactory.instanceListInitializer(xe,e.data))}},Fe=class extends t.BasePaginationProvider{getProperties(e,t,n){return this.getTypedPaginated(k,`/internal/catalog/properties`,e,t,n)}createProperty(e){let{typeId:t,...n}=e;return this.post(`/internal/catalog/properties`,{...n,type:t},e=>new k(e.data))}getProperty(e){return this.get(`/internal/catalog/properties/${e}`,{},e=>new k(e.data))}updateProperty(e,t){let{typeId:n,...r}=t;return this.patch(`/internal/catalog/properties/${e}`,{...r,type:n},e=>new k(e.data))}deleteProperty(e){return this.delete(`/internal/catalog/properties/${e}`)}getProductProperties(e){return this.getTypedList(A,`/internal/catalog/products/${e}/properties`)}getProductProperty(e,t){return this.get(`/internal/catalog/products/${e}/properties/${t}`,{},e=>new A(e.data))}updateProductProperty(e,t,n){return this.patch(`/internal/catalog/products/${e}/properties/${t}`,{value:n},e=>new A(e.data))}deleteProductProperty(e,t){return this.delete(`/internal/catalog/products/${e}/properties/${t}`)}getProductDescription(e){return this.get(`/internal/catalog/products/${e}/properties/description`)}updateProductDescription(e,t){return this.patch(`/internal/catalog/products/${e}/properties/description`,{text:t})}deleteProductDescription(e){return this.delete(`/internal/catalog/products/${e}/properties/description`)}getProductSpecification(e){return this.get(`/internal/catalog/products/${e}/properties/specification`)}updateProductSpecification(e,t){return this.patch(`/internal/catalog/products/${e}/properties/specification`,{text:t})}deleteProductSpecification(e){return this.delete(`/internal/catalog/products/${e}/properties/specification`)}getProductFiles(e){return this.get(`/internal/catalog/products/${e}/properties/files`)}addProductFile(e,t){return this.post(`/internal/catalog/products/${e}/properties/files`,t)}updateProductFile(e,t,n){return this.patch(`/internal/catalog/products/${e}/properties/files/${t}`,n)}deleteProductFile(e,t){return this.delete(`/internal/catalog/products/${e}/properties/files/${t}`)}updateProductSlug(e,t){return this.patch(`/internal/catalog/products/${e}/properties/slug`,{slug:t})}getCategoryProperties(e){return this.getTypedList(A,`/internal/catalog/categories/${e}/properties`)}getCategoryProperty(e,t){return this.get(`/internal/catalog/categories/${e}/properties/${t}`,{},e=>new A(e.data))}updateCategoryProperty(e,t,n){return this.patch(`/internal/catalog/categories/${e}/properties/${t}`,{value:n},e=>new A(e.data))}deleteCategoryProperty(e,t){return this.delete(`/internal/catalog/categories/${e}/properties/${t}`)}getCategoryDescription(e){return this.get(`/internal/catalog/categories/${e}/properties/description`)}updateCategoryDescription(e,t){return this.patch(`/internal/catalog/categories/${e}/properties/description`,{text:t})}deleteCategoryDescription(e){return this.delete(`/internal/catalog/categories/${e}/properties/description`)}getCategorySpecification(e){return this.get(`/internal/catalog/categories/${e}/properties/specification`)}updateCategorySpecification(e,t){return this.patch(`/internal/catalog/categories/${e}/properties/specification`,{text:t})}deleteCategorySpecification(e){return this.delete(`/internal/catalog/categories/${e}/properties/specification`)}getCategoryFiles(e){return this.get(`/internal/catalog/categories/${e}/properties/files`)}addCategoryFile(e,t){return this.post(`/internal/catalog/categories/${e}/properties/files`,t)}updateCategoryFile(e,t,n){return this.patch(`/internal/catalog/categories/${e}/properties/files/${t}`,n)}deleteCategoryFile(e,t){return this.delete(`/internal/catalog/categories/${e}/properties/files/${t}`)}updateCategorySlug(e,t){return this.patch(`/internal/catalog/categories/${e}/properties/slug`,{slug:t})}updateCategoryImage(e,t){return this.post(`/internal/catalog/categories/${e}/image`,{image:t})}getCategoryFilters(e,t=!1){return this.get(`/internal/catalog/categories/${e}/filters`,{recursively:t},e=>e.data.map(e=>new Te(e)))}getCategoryFilterSettings(e){return this.getTypedList(Ce,`/internal/catalog/categories/${e}/filter-settings`)}saveCategoryFilterSetting(e,t,n){return this.patch(`/internal/catalog/categories/${e}/filter-settings/${t}`,n,e=>new Ce(e.data))}deleteCategoryFilterSetting(e,t){return this.delete(`/internal/catalog/categories/${e}/filter-settings/${t}`)}},Ie=class extends t.HttpRequester{getRootCategoriesList(e,t=!1){return this.getTypedList(C,`/internal/catalog/categories`,{priceTemplateId:e,showHidden:t})}getCategoryData(e,t,n=!1,r=!1){return this.get(`/internal/catalog/categories/${t}`,{priceTemplateId:e,showHidden:n,withNestedCategories:r},e=>new C(e.data))}getCategoryProductsList(e,t,n=!0,i=!1){return this.get(`/internal/catalog/categories/${t}/products`,{priceTemplateId:e,showHidden:i,withPriceCoefficients:n},e=>(0,r.map)(e.data,e=>new y(e)))}};function Le(e,t,n){let r;return e.some(e=>{if(e.type===n&&e.id===t)return r=e,!0;if(e.type===`product`)return!1;let i=e;if(i.products&&i.products.length>0){let e=Le(i.products,t,n);if(e)return r=e,!0}if(i.categories&&i.categories.length>0){let e=Le(i.categories,t,n);if(e)return r=e,!0}return!1}),r}function Re(e){let t=[];return e.forEach(e=>{if(t.push(e),e.type===`category`){let n=e;n.products&&n.products.length>0&&t.push(...Re(n.products)),n.categories&&n.categories.length>0&&t.push(...Re(n.categories))}}),t}var ze=function(e){return e.LastOrder=`last_order`,e.Contacts=`contacts`,e.PartnerGroups=`partner_groups`,e.PreferredDeliveryType=`preferred_delivery_type`,e.SalesDirection=`sales_direction`,e.Managers=`managers`,e.Curators=`curators`,e}({}),N=class extends t.Identity{bankName=``;bic=``;accountNumber=``;correspondentAccount=``;currency=new t.Currency;constructor(e){super(e),e&&(this.bankName=e.bankName??``,this.bic=e.bic??``,this.accountNumber=e.accountNumber??``,this.correspondentAccount=e.correspondentAccount??``,this.currency=new t.Currency(e.currency))}},P=class extends f{phone;email;constructor(e){super(e),this.email=e?.email,this.phone=/^\d+$/.test(e?.phone??``)?`+${e?.phone}`:e?.phone}},F=class extends P{isPrimary;position;notDisturb;comment;constructor(e){super(e),this.isPrimary=e?.isPrimary??!1,this.position=e?.position,this.notDisturb=e?.notDisturb??!1,this.comment=e?.comment}},Be=class extends f{opf=t.Opf.generatePersonItem();partnerGroup=new t.PartnerGroup;contacts=[];bankAccounts=[];comment;alternativeName;creator;updater;constructor(e){if(super(e),e){if(this.opf=new t.Opf(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.creator=e.creator?new p(e.creator):void 0,this.updater=e.updater?new p(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new t.PartnerGroup(e.partnerGroup)),e.contacts){let t=[];e.contacts.forEach(e=>{t.push(new F(e))}),this.contacts=t}if(e.bankAccounts){let t=[];e.bankAccounts.forEach(e=>{t.push(new N(e))}),this.bankAccounts=t}}}},Ve=class extends Be{constructor(e){super(e)}},He=class extends Be{inn=``;okpo=``;ogrn=``;directorName=``;directorPosition=``;directorActsOn=``;legalAddress=``;postalAddress=``;actualAddress=``;constructor(e){super(e),e&&(this.inn=e.inn??``,this.okpo=e.okpo??``,this.ogrn=e.ogrn??``,this.directorName=e.directorName??``,this.directorPosition=e.directorPosition??``,this.directorActsOn=e.directorActsOn??``,this.legalAddress=e.legalAddress??``,this.postalAddress=e.postalAddress??``,this.actualAddress=e.actualAddress??``)}},Ue=class extends He{kpp=``;constructor(e){super(e),e&&(this.kpp=e.kpp??``)}},We=class extends Ue{registrationCountry=new t.Country;registrationNumber=``;taxNumber=``;constructor(e){super(e),e&&(this.registrationCountry=new t.Country(e.registrationCountry),this.registrationNumber=e.registrationNumber??``,this.taxNumber=e.taxNumber??``)}},I=class{static createInstance(e){switch(e.opf.slug){case t.OpfEnum.Ic:return new He(e);case t.OpfEnum.UlR:return new Ue(e);case t.OpfEnum.UlNr:return new We(e);default:return new Ve(e)}}},Ge=class extends t.NamedIdentity{city;isActive;constructor(e){super(e),this.city=e?.city?new t.CityWithRegionAndCountry(e.city):void 0,this.isActive=e?.isActive??!1}},L=class extends f{address=``;coordinates;contacts;comment;operatingHours;isOneTime;isTransportCompanyAddress;constructor(e){super(e),this.address=e?.address??``,this.coordinates=new t.GeoCoordinates(e?.coordinates),this.contacts=e?.contacts?.map(e=>new F(e))??[],this.comment=e?.comment,this.operatingHours=e?.operatingHours,this.isOneTime=e?.isOneTime,this.isTransportCompanyAddress=e?.isTransportCompanyAddress}},Ke=class extends E{contragents;partnerGroups;contacts;deliveryAddresses;channelPrimaryInterest;sourcePrimaryInterest;preferredDeliveryType;primaryDemand;preferredWarehouse;extraData;constructor(e){super(e),this.contragents=e?.contragents?.map(e=>I.createInstance(e))??[],this.partnerGroups=e?.partnerGroups?.map(e=>new t.PartnerGroup(e))??[],this.contacts=e?.contacts?.map(e=>new F(e))??[],this.deliveryAddresses=e?.deliveryAddresses?.map(e=>new L(e))??[],this.channelPrimaryInterest=new t.ChannelPrimaryInterest(e?.channelPrimaryInterest),this.sourcePrimaryInterest=new t.SourcePrimaryInterest(e?.sourcePrimaryInterest),this.preferredDeliveryType=new t.DeliveryType(e?.preferredDeliveryType),this.primaryDemand=e?.primaryDemand,this.preferredWarehouse=e?.preferredWarehouse?new t.Warehouse(e.preferredWarehouse):void 0,this.extraData=e?.extraData??{}}},qe=class extends u{id;guid;name;alternativeName;searchTerm;cities;region;country;phone;email;isActive;createdAt=new d;lastLoginDate=new d;lastLoginDateHasOrder;managers;includeSubordinateManagers;curators;isManagerRequired;salesDirections;contragentInn;contragentType;preferredDeliveryType;partnerGroups;contact;lastOrder;noOrdersPeriod=new d;constructor(e){super(),this.id=e?.id,this.guid=e?.guid,this.name=e?.name,this.alternativeName=e?.alternativeName,this.searchTerm=e?.searchTerm,this.cities=e?.cities?.map(e=>new t.CityWithRegionAndCountry(e)),this.region=new t.Region(e?.region),this.country=new t.Country(e?.country),this.phone=e?.phone,this.email=e?.email,this.isActive=e&&Object.prototype.hasOwnProperty.call(e,`isActive`)?e?.isActive:!0,this.createdAt=new d(e?.createdAt),this.lastLoginDate=new d(e?.lastLoginDate),this.lastLoginDateHasOrder=e?.lastLoginDateHasOrder??void 0,this.managers=e?.managers?.map(e=>new t.Manager(e))??[],this.includeSubordinateManagers=e?.includeSubordinateManagers??!0,this.curators=e?.curators?.map(e=>new T(e))??[],this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.contragentInn=e?.contragentInn,this.contragentType=new t.Opf(e?.contragentType),this.preferredDeliveryType=e?.preferredDeliveryType?new t.DeliveryType(e?.preferredDeliveryType):void 0,this.partnerGroups=e?.partnerGroups?.map(e=>new t.PartnerGroup(e)),this.contact=new P(e?.contact),this.lastOrder={createdAt:new d(e?.lastOrder?.createdAt),creator:e?.lastOrder?.creator,isApproved:e?.lastOrder?.isApproved},this.noOrdersPeriod=new d(e?.noOrdersPeriod)}resetFilterValue(e){switch(e){case`cities`:this.cities=[];break;case`region`:this.region=new t.Region;break;case`isActive`:this.isActive=!0;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`lastLoginDate`:this.lastLoginDate.from=null,this.lastLoginDate.to=null;break;case`noOrdersPeriod`:this.noOrdersPeriod.from=null,this.noOrdersPeriod.to=null;break;case`lastOrder`:this.lastOrder={};break;case`managers`:this.managers=[];break;case`curators`:this.curators=[];break;case`salesDirections`:this.salesDirections=[];break;case`contragentType`:this.contragentType=new t.Opf;break;case`preferredDeliveryType`:this.preferredDeliveryType=new t.DeliveryType;break;case`partnerGroups`:this.partnerGroups=[];break;case`contact`:this.contact=new P;break;default:this[e]=void 0}return this}asClearRaw(){let e=super.asClearRaw();return!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,!e?.lastLoginDate?.from&&!e?.lastLoginDate?.to&&delete e.lastLoginDate,!e?.noOrdersPeriod?.from&&!e?.noOrdersPeriod?.to&&delete e.noOrdersPeriod,e}},Je=class extends s{creator;constructor(e){super(e),this.creator=new p(e?.creator)}},Ye=class extends t.NamedIdentity{contacts=[];preferredDeliveryType;partnerGroups=[];lastOrder;salesDirection;managers;curators;constructor(e){super(e),this.contacts=e.contacts?.map(e=>new F(e))??void 0,this.lastOrder=e.lastOrder?new Je(e.lastOrder):void 0,this.partnerGroups=e.partnerGroups?.map(e=>new t.PartnerGroup(e))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new t.DeliveryType(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new t.SalesDirection(e.salesDirection):void 0,this.managers=e.managers?.map(e=>new t.ManagerCommon(e))??void 0,this.curators=e.curators?.map(e=>new T(e))??void 0}},R=class extends t.Identity{isPrimary;constructor(e){super(e),this.isPrimary=e.isPrimary}},Xe=class extends F{relations={clients:[],contragents:[],addresses:[]};constructor(e){super(e),e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(e=>new R(e))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(e=>new R(e))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(e=>new R(e))))}},Ze=class e extends t.BasePaginationProvider{static transformClientDataToRequest(e){return{name:e.name,alternative_name:e.alternativeName,partner_groups:e.partnerGroups.map(e=>e.id),phone:e.phone,email:e.email,city_id:e.city.id,get_news:e.getNews,channel_primary_interest_id:e.channelPrimaryInterest.id,source_primary_interest_id:e.sourcePrimaryInterest.id,primary_demand:e.primaryDemand,preferred_warehouse_id:e.preferredWarehouse?.id}}static transformContragentClientDataToRequest(e){let n,r=e,i=e,a=e;switch(e.opf.slug){case t.OpfEnum.Ic:n={opf:r.opf.slug,name:r.name,alternative_name:r.alternativeName,partner_group_id:r.partnerGroup?.id,comment:r.comment,inn:r.inn,okpo:r.okpo,ogrn:r.ogrn||void 0,director_name:r.directorName,director_position:r.directorPosition,director_acts_on:r.directorActsOn,legal_address:r.legalAddress,postal_address:r.postalAddress,actual_address:r.actualAddress};break;case t.OpfEnum.UlR:n={opf:i.opf.slug,name:i.name,alternative_name:i.alternativeName,partner_group_id:i.partnerGroup?.id,comment:i.comment,inn:i.inn,kpp:i.kpp,okpo:i.okpo,ogrn:i.ogrn||void 0,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 t.OpfEnum.UlNr:n={opf:a.opf.slug,name:a.name,alternative_name:a.alternativeName,partner_group_id:a.partnerGroup?.id,comment:a.comment,director_name:a.directorName,director_position:a.directorPosition,director_acts_on:a.directorActsOn,legal_address:a.legalAddress,postal_address:a.postalAddress,actual_address:a.actualAddress,registration_country_id:a.registrationCountry.id,registration_number:a.registrationNumber,tax_number:a.taxNumber||void 0};break;default:n={opf:e.opf.slug,name:e.name,alternative_name:e.alternativeName,partner_group_id:e.partnerGroup?.id,comment:e.comment}}return n}static transformClientDeliveryAddressToRequest(e){let t={address:e.address,is_one_time:e.isOneTime??!1,is_transport_company_address:e.isTransportCompanyAddress??!1,comment:e.comment??``};return e.coordinates&&(t.coordinates={lat:e.coordinates?.lat,long:e.coordinates?.long}),e.operatingHours&&(t.operating_hours={from:e.operatingHours.from,to:e.operatingHours.to}),t}static transformClientContragentBankAccountToRequest(e){return{bank_name:e.bankName,bic:e.bic,account_number:e.accountNumber,correspondent_account:e.correspondentAccount,currency_id:e.currency.id}}getClient(e){return this.get(`/internal/clients/${e}`,{},e=>new Ke(e.data))}getClientsList(e,t,n,r,i){return this.getTypedPaginated(E,`/internal/clients`,e,t,n,r,void 0,i)}searchClient(e){return this.getClientsList(void 0,void 0,void 0,{searchTerm:e}).then(e=>e.data)}getClientByPhone(e){return this.getClientsList({groupOp:`and`,groups:[],filters:[{field:`phone`,op:t.FilterOpEnum.Contains,value:e}]})}getAdditionalClientsData(e,n){let r=e.map(e=>e.id);return this.post(`/internal/clients/additional-data`,{clients:r,requested_data_types:n},e=>t.TypedInstanceFactory.instanceListInitializer(Ye,e.data))}getAllClientContacts(e){return this.getTypedList(Xe,`/internal/clients/${e}/contacts/all`)}createClientCommonData(t,n={}){return this.post(`/internal/clients`,e.transformClientDataToRequest(t),e=>new Ke(e.data),n)}updateClientCommonData(t,n={}){return this.patch(`/internal/clients/${t.id}`,e.transformClientDataToRequest(t),void 0,n)}updateClientNotDistribCommonData(e,t={}){let n={get_news:e.getNews};return this.patch(`/internal/clients/${e.id}`,n,void 0,t)}changeClientPassword(e,t,n,r={}){return this.patch(`/internal/clients/${e}`,{password:t,password_confirmation:n},void 0,r)}updateClientComment(e){return this.patch(`/internal/clients/${e.id}`,{comment:e.comment})}changeClientActivation(e){return this.patch(`/internal/clients/${e.id}`,{is_active:e.isActive})}async attachClientToManagers(e,t){let n=t.map(t=>this.patch(`/internal/clients/${e}/managers/${t.id}/attach`,{is_primary:t.isDefault}));await Promise.all(n)}async detachClientFromManagers(e,t){let n=t.map(t=>this.patch(`/internal/clients/${e}/managers/${t.id}/detach`));await Promise.all(n)}attachToCurator(e,t,n){return this.patch(`/internal/clients/${e}/curators/${t}/attach`,{curated_direction_id:n.id})}detachFromCurator(e,t,n){return this.patch(`/internal/clients/${e}/curators/${t}/detach`,{curated_direction_id:n.id})}setCurators(e,t){return this.patch(`/internal/clients/${e}/curators`,{curators:t.map(e=>({curator_id:e.curatorId,curated_direction_id:e.curatedDirection.id}))})}createContragentClientData(t,n,r={}){return this.post(`/internal/clients/${t}/contragents`,e.transformContragentClientDataToRequest(n),e=>I.createInstance(e.data),r)}updateContragentClientData(t,n,r={}){return this.patch(`/internal/clients/${t}/contragents/${n.id}`,e.transformContragentClientDataToRequest(n),e=>I.createInstance(e.data),r)}deleteClientContragent(e,t){return this.delete(`/internal/clients/${e}/contragents/${t.id}`)}getClientDeliveryAddresses(e){return this.getTypedList(L,`/internal/clients/${e}/delivery-addresses`)}createClientDeliveryAddress(t,n,r={}){return this.post(`/internal/clients/${t}/delivery-addresses`,e.transformClientDeliveryAddressToRequest(n),e=>new L(e.data),r)}updateClientDeliveryAddress(t,n,r={}){return this.patch(`/internal/clients/${t}/delivery-addresses/${n.id}`,e.transformClientDeliveryAddressToRequest(n),e=>new L(e.data),r)}deleteClientDeliveryAddress(e,t){return this.delete(`/internal/clients/${e}/delivery-addresses/${t.id}`)}createContragentBankAccount(t,n,r,i={}){return this.post(`/internal/clients/${t}/contragents/${n}/bank-accounts`,e.transformClientContragentBankAccountToRequest(r),e=>new N(e.data),i)}updateContragentBankAccount(t,n,r,i={}){return this.patch(`/internal/clients/${t}/contragents/${n}/bank-accounts/${r.id}`,e.transformClientContragentBankAccountToRequest(r),e=>new N(e.data),i)}deleteContragentBankAccount(e,t,n){return this.delete(`/internal/clients/${e}/contragents/${t}/bank-accounts/${n.id}`)}createClientContact(e,t,n={}){return this.createContact(e,t,{client:{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}},n)}updateClientContact(e,t,n={}){return this.patch(`/internal/clients/${e}/contacts/${t.id}`,{name:t.name,position:t.position,phone:t.phone,email:t.email,comment:t.comment,not_disturb:t.notDisturb},e=>new F(e.data),n)}setPrimaryClientContact(e,t){return this.setPrimaryContact(`/internal/clients/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachClientContact(e,t){return this.detachContact(`/internal/clients/${e}/contacts/${t.id}/detach`)}createContragentContact(e,t,n,r={}){return this.createContact(e,n,{contragents:[{id:t,is_primary:n.isPrimary??!1,not_disturb:n.notDisturb??!1}]},r)}setPrimaryContragentContact(e,t,n){return this.setPrimaryContact(`/internal/clients/${e}/contragents/${t}/contacts/${n.id}/primary`,n.isPrimary??!1)}detachContragentContact(e,t,n){return this.detachContact(`/internal/clients/${e}/contragents/${t}/contacts/${n.id}/detach`)}createDeliveryAddressContact(e,t,n,r={}){return this.createContact(e,n,{addresses:[{id:t,is_primary:n.isPrimary??!1,not_disturb:n.notDisturb??!1}]},r)}setPrimaryDeliveryAddressContact(e,t,n){return this.setPrimaryContact(`/internal/clients/${e}/delivery-addresses/${t}/contacts/${n.id}/primary`,n.isPrimary??!1)}detachDeliveryAddressContact(e,t,n){return this.detachContact(`/internal/clients/${e}/delivery-addresses/${t}/contacts/${n.id}/detach`)}createContact(e,t,n,r={}){let i={name:t.name,position:t.position,comment:t.comment,...n};return t.phone?.length&&(i.phone=t.phone),t.email?.length&&(i.email=t.email),this.post(`/internal/clients/${e}/contacts`,i,e=>new F(e.data),r)}setPrimaryContact(e,t){return this.patch(e,{is_primary:t})}detachContact(e){return this.patch(e)}sendClientEmailConfirmation(e){return this.get(`/internal/clients/${e.id}/verification/email?email=${e.email}`)}},Qe=class extends t.HttpRequester{checkPhoneIsBusy(e){return new Promise((t,n)=>{this.request({method:`GET`,url:`/public/user/verification/phone/check`,params:{phone:e}}).then(e=>{t(!!e.isBusy)}).catch(n)})}},$e=class{date;name;version;constructor(e){this.date=(0,r.isString)(e?.date)?(0,n.parseISO)(e.date):e?.date??new Date,this.name=e?.name??``,this.version=e?.version??`0.0.0`}},et=function(e){return e.Kozyrek=`kozyrek`,e.Mosquitto=`mosquitto`,e.Strip=`strip`,e.MetalForDoors=`metal_for_doors`,e.Sandwich=`sandwich`,e.SandwichM2=`sandwich_m2`,e}({}),tt=class extends t.HttpRequester{getConfiguratorSettings(e,t){return this.get(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/settings?client_id=${t}`)}searchProduct(e,t,n,r={}){return this.request({method:`GET`,url:`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/product`,params:{params:n,client_id:t}},e=>new y(e.data),r)}createTemplate(e,t,n,r={}){return this.post(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/template?client_id=${t}`,{...n},()=>{},r)}removeTemplate(e,t,n){return this.delete(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/template/${n}?client_id=${t}`)}calculate(e,t,n){return this.get(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/calculate`,{client_id:t,...n})}},nt=class{page=1;pageSize=50;constructor(e){this.page=e?.page??1,this.pageSize=e?.pageSize??50}},rt=class extends nt{itemCount=0;pageCount=1;pageSlot=5;pageSizes=[25,50,100];showSizePicker=!0;constructor(e){super(e),this.itemCount=e?.itemCount??0,this.pageCount=e?.pageCount??1,this.pageSlot=e?.pageSlot??5,this.pageSizes=e?.pageSizes??[25,50,100],this.showSizePicker=e?.showSizePicker??!0}},it=class{field;direction;constructor(e){this.field=e?.field??``,this.direction=e?.direction??`asc`}},z=class e{static decadeInterval(t){let[n,r]=e.shiftedDecadeBounds(t,0);return{from:n,to:r}}static shiftDecadeInterval(t,n){let[r,i]=e.shiftedDecadeBounds(t,n);return{from:r,to:i}}static startOfHalfYear(e){return new Date(e.getFullYear(),e.getMonth()<6?0:6,1)}static endOfHalfYear(e){return(0,n.endOfMonth)(new Date(e.getFullYear(),e.getMonth()<6?5:11,1))}static addHalfYears(e,t){return(0,n.addMonths)(e,t*6)}static intervalTillSameDate(e,t,r){let i=(0,n.differenceInCalendarMonths)((0,n.startOfMonth)(r),(0,n.startOfMonth)(e)),a=(0,n.startOfMonth)((0,n.addMonths)(t,i)),o=Math.min((0,n.getDate)(r),(0,n.getDaysInMonth)(a));return{from:(0,n.startOfDay)(t),to:(0,n.endOfDay)((0,n.setDate)(a,o))}}static weekTillSameWeekday(e,t){let r=(0,n.startOfWeek)((0,n.addWeeks)(e,t),{weekStartsOn:1}),i=(0,n.differenceInCalendarDays)(e,(0,n.startOfWeek)(e,{weekStartsOn:1}));return{from:r,to:(0,n.endOfDay)((0,n.addDays)(r,i))}}static decadeTillSameDayNumber(t,r){let[i]=e.shiftedDecadeBounds(t,0),a=(0,n.differenceInCalendarDays)(t,i)+1,[o,s]=e.shiftedDecadeBounds(t,r),c=(0,n.differenceInCalendarDays)(s,o)+1;return{from:o,to:(0,n.endOfDay)((0,n.addDays)(o,Math.min(a,c)-1))}}static shiftedDecadeBounds(e,t){let r=(0,n.getDate)(e),i=2;r<=10?i=0:r<=20&&(i=1);let a=i+t,o=Math.floor(a/3),s=(a%3+3)%3,c=(0,n.startOfMonth)((0,n.addMonths)(e,o)),l=(0,n.addDays)(c,s*10);return[l,s===2?(0,n.endOfMonth)(c):(0,n.endOfDay)((0,n.addDays)(l,9))]}};function at(e){return(0,n.format)((0,n.subDays)((0,n.startOfToday)(),e),`yyyy-MM-dd`)}function ot(e,t){let n=[2,0,1,1,1,2],r=Math.floor(Math.abs(e));return t[r%100>4&&r%100<20?2:n[Math.min(r%10,5)]]}function st(e){let t=(0,n.parseISO)(e),r=(0,n.differenceInCalendarDays)((0,n.startOfToday)(),t);switch(!0){case r===0:return`Сегодня`;case r===1:return`Вчера`;case r<0:return e;default:return`${r} ${ot(r,[`день`,`дня`,`дней`])} назад`}}var ct=class{static defaultDateRanges(e){let t=(0,n.addBusinessDays)(new Date,1),r=new Date,i=(0,n.startOfYear)(e===void 0?r:new Date(e,0,1)),a=(0,n.endOfYear)(i);return{nextWorkingDay:{label:`Следующий рабочий день`,from:(0,n.startOfDay)(t),to:(0,n.endOfDay)(t)},today:{label:`Сегодня`,from:(0,n.startOfToday)(),to:(0,n.endOfToday)()},yesterday:{label:`Вчера`,from:(0,n.startOfYesterday)(),to:(0,n.endOfYesterday)()},tomorrow:{label:`Завтра`,from:(0,n.startOfTomorrow)(),to:(0,n.endOfTomorrow)()},currentWeek:{label:`Неделя`,from:(0,n.startOfWeek)(r,{weekStartsOn:1}),to:(0,n.endOfWeek)(r,{weekStartsOn:1})},currentMonth:{label:`Месяц`,from:(0,n.startOfMonth)(r),to:(0,n.endOfMonth)(r)},oneMonth:{label:`1 месяц`,from:i,to:(0,n.endOfMonth)(i)},threeMonths:{label:`3 месяца`,from:i,to:(0,n.endOfMonth)((0,n.addMonths)(i,2))},nineMonths:{label:`9 месяцев`,from:i,to:(0,n.endOfMonth)((0,n.addMonths)(i,8))},firstQuarter:{label:`I квартал`,from:i,to:(0,n.endOfMonth)((0,n.addMonths)(i,2))},secondQuarter:{label:`II квартал`,from:(0,n.addMonths)(i,3),to:(0,n.endOfMonth)((0,n.addMonths)(i,5))},thirdQuarter:{label:`III квартал`,from:(0,n.addMonths)(i,6),to:(0,n.endOfMonth)((0,n.addMonths)(i,8))},fourthQuarter:{label:`IV квартал`,from:(0,n.addMonths)(i,9),to:(0,n.endOfMonth)((0,n.addMonths)(i,11))},firstHalfYear:{label:`I полугодие`,from:i,to:(0,n.endOfMonth)((0,n.addMonths)(i,5))},secondHalfYear:{label:`II полугодие`,from:(0,n.addMonths)(i,6),to:a},currentYear:{label:`12 месяцев`,from:i,to:a}}}static standardPeriods(e=new Date){let t={weekStartsOn:1},r=(0,n.startOfDay)(e),i=(0,n.endOfDay)(e),a=z.decadeInterval(e),o=(0,n.startOfMonth)(e),s=(0,n.startOfQuarter)(e),c=z.startOfHalfYear(e),l=(0,n.startOfYear)(e),u=z.addHalfYears(e,-1),d=z.addHalfYears(e,1);return{yesterday:{label:`Вчера`,group:`day`,from:(0,n.startOfDay)((0,n.subDays)(e,1)),to:(0,n.endOfDay)((0,n.subDays)(e,1))},today:{label:`Сегодня`,group:`day`,from:r,to:i},tomorrow:{label:`Завтра`,group:`day`,from:(0,n.startOfDay)((0,n.addDays)(e,1)),to:(0,n.endOfDay)((0,n.addDays)(e,1))},lastWeek:{label:`Прошлая неделя`,group:`week`,from:(0,n.startOfWeek)((0,n.subWeeks)(e,1),t),to:(0,n.endOfWeek)((0,n.subWeeks)(e,1),t)},thisWeek:{label:`Эта неделя`,group:`week`,from:(0,n.startOfWeek)(e,t),to:(0,n.endOfWeek)(e,t)},nextWeek:{label:`Следующая неделя`,group:`week`,from:(0,n.startOfWeek)((0,n.addWeeks)(e,1),t),to:(0,n.endOfWeek)((0,n.addWeeks)(e,1),t)},lastTenDays:{label:`Прошлая декада`,group:`decade`,...z.shiftDecadeInterval(e,-1)},thisTenDays:{label:`Эта декада`,group:`decade`,...a},nextTenDays:{label:`Следующая декада`,group:`decade`,...z.shiftDecadeInterval(e,1)},lastMonth:{label:`Прошлый месяц`,group:`month`,from:(0,n.startOfMonth)((0,n.subMonths)(e,1)),to:(0,n.endOfMonth)((0,n.subMonths)(e,1))},thisMonth:{label:`Этот месяц`,group:`month`,from:o,to:(0,n.endOfMonth)(e)},nextMonth:{label:`Следующий месяц`,group:`month`,from:(0,n.startOfMonth)((0,n.addMonths)(e,1)),to:(0,n.endOfMonth)((0,n.addMonths)(e,1))},lastQuarter:{label:`Прошлый квартал`,group:`quarter`,from:(0,n.startOfQuarter)((0,n.subQuarters)(e,1)),to:(0,n.endOfQuarter)((0,n.subQuarters)(e,1))},thisQuarter:{label:`Этот квартал`,group:`quarter`,from:s,to:(0,n.endOfQuarter)(e)},nextQuarter:{label:`Следующий квартал`,group:`quarter`,from:(0,n.startOfQuarter)((0,n.addQuarters)(e,1)),to:(0,n.endOfQuarter)((0,n.addQuarters)(e,1))},lastHalfYear:{label:`Прошлое полугодие`,group:`halfYear`,from:z.startOfHalfYear(u),to:z.endOfHalfYear(u)},thisHalfYear:{label:`Это полугодие`,group:`halfYear`,from:c,to:z.endOfHalfYear(e)},nextHalfYear:{label:`Следующее полугодие`,group:`halfYear`,from:z.startOfHalfYear(d),to:z.endOfHalfYear(d)},lastYear:{label:`Прошлый год`,group:`year`,from:(0,n.startOfYear)((0,n.subYears)(e,1)),to:(0,n.endOfYear)((0,n.subYears)(e,1))},thisYear:{label:`Этот год`,group:`year`,from:l,to:(0,n.endOfYear)(e)},nextYear:{label:`Следующий год`,group:`year`,from:(0,n.startOfYear)((0,n.addYears)(e,1)),to:(0,n.endOfYear)((0,n.addYears)(e,1))},fromBeginningOfThisWeek:{label:`С начала этой недели`,group:`other`,section:`fromBeginning`,from:(0,n.startOfWeek)(e,t),to:i},fromBeginningOfThisTenDays:{label:`С начала этой декады`,group:`other`,section:`fromBeginning`,from:a.from,to:i},fromBeginningOfThisMonth:{label:`С начала этого месяца`,group:`other`,section:`fromBeginning`,from:o,to:i},fromBeginningOfThisQuarter:{label:`С начала этого квартала`,group:`other`,section:`fromBeginning`,from:s,to:i},fromBeginningOfThisHalfYear:{label:`С начала этого полугодия`,group:`other`,section:`fromBeginning`,from:c,to:i},fromBeginningOfThisYear:{label:`С начала этого года`,group:`other`,section:`fromBeginning`,from:l,to:i},tillEndOfThisWeek:{label:`До конца этой недели`,group:`other`,section:`tillEnd`,from:r,to:(0,n.endOfWeek)(e,t)},tillEndOfThisTenDays:{label:`До конца этой декады`,group:`other`,section:`tillEnd`,from:r,to:a.to},tillEndOfThisMonth:{label:`До конца этого месяца`,group:`other`,section:`tillEnd`,from:r,to:(0,n.endOfMonth)(e)},tillEndOfThisQuarter:{label:`До конца этого квартала`,group:`other`,section:`tillEnd`,from:r,to:(0,n.endOfQuarter)(e)},tillEndOfThisHalfYear:{label:`До конца этого полугодия`,group:`other`,section:`tillEnd`,from:r,to:z.endOfHalfYear(e)},tillEndOfThisYear:{label:`До конца этого года`,group:`other`,section:`tillEnd`,from:r,to:(0,n.endOfYear)(e)},lastWeekTillSameWeekDay:{label:`Прошлая неделя, до такого же дня недели`,group:`other`,section:`lastTillSame`,...z.weekTillSameWeekday(e,-1)},lastTenDaysTillSameDayNumber:{label:`Прошлая декада, до такого же номера дня`,group:`other`,section:`lastTillSame`,...z.decadeTillSameDayNumber(e,-1)},lastMonthTillSameDate:{label:`Прошлый месяц, до такой же даты`,group:`other`,section:`lastTillSame`,...z.intervalTillSameDate(o,(0,n.startOfMonth)((0,n.subMonths)(e,1)),e)},lastQuarterTillSameDate:{label:`Прошлый квартал, до такой же даты`,group:`other`,section:`lastTillSame`,...z.intervalTillSameDate(s,(0,n.startOfQuarter)((0,n.subQuarters)(e,1)),e)},lastHalfYearTillSameDate:{label:`Прошлое полугодие, до такой же даты`,group:`other`,section:`lastTillSame`,...z.intervalTillSameDate(c,z.startOfHalfYear(u),e)},lastYearTillSameDate:{label:`Прошлый год, до такой же даты`,group:`other`,section:`lastTillSame`,...z.intervalTillSameDate(l,(0,n.startOfYear)((0,n.subYears)(e,1)),e)},nextWeekTillSameWeekDay:{label:`Следующая неделя, до такого же дня недели`,group:`other`,section:`nextTillSame`,...z.weekTillSameWeekday(e,1)},nextTenDaysTillSameDayNumber:{label:`Следующая декада, до такого же номера дня`,group:`other`,section:`nextTillSame`,...z.decadeTillSameDayNumber(e,1)},nextMonthTillSameDate:{label:`Следующий месяц, до такой же даты`,group:`other`,section:`nextTillSame`,...z.intervalTillSameDate(o,(0,n.startOfMonth)((0,n.addMonths)(e,1)),e)},nextQuarterTillSameDate:{label:`Следующий квартал, до такой же даты`,group:`other`,section:`nextTillSame`,...z.intervalTillSameDate(s,(0,n.startOfQuarter)((0,n.addQuarters)(e,1)),e)},nextHalfYearTillSameDate:{label:`Следующее полугодие, до такой же даты`,group:`other`,section:`nextTillSame`,...z.intervalTillSameDate(c,z.startOfHalfYear(d),e)},nextYearTillSameDate:{label:`Следующий год, до такой же даты`,group:`other`,section:`nextTillSame`,...z.intervalTillSameDate(l,(0,n.startOfYear)((0,n.addYears)(e,1)),e)},last7Days:{label:`Последние 7 дней`,group:`other`,section:`rollingDays`,from:(0,n.startOfDay)((0,n.subDays)(e,6)),to:i},next7Days:{label:`Следующие 7 дней`,group:`other`,section:`rollingDays`,from:r,to:(0,n.endOfDay)((0,n.addDays)(e,6))}}}},lt=[{key:`day`,label:`День`},{key:`week`,label:`Неделя`},{key:`decade`,label:`Декада`},{key:`month`,label:`Месяц`},{key:`quarter`,label:`Квартал`},{key:`halfYear`,label:`Полугодие`},{key:`year`,label:`Год`},{key:`other`,label:`Прочее`}],ut=[{key:`fromBeginning`,label:`С начала периода`},{key:`tillEnd`,label:`До конца периода`},{key:`lastTillSame`,label:`Прошлые, до такой же даты`},{key:`nextTillSame`,label:`Следующие, до такой же даты`},{key:`rollingDays`,label:`7 дней`}],B=class extends Ge{},dt=class{salesDirections;partnerGroups;managers;additionalClients;fixedClients;regions;cities;lastLoginDate;lastOrderDate;constructor(e){this.salesDirections=(0,r.map)(e?.salesDirections??[],e=>new t.SalesDirection(e)),this.partnerGroups=(0,r.map)(e?.partnerGroups??[],e=>new t.PartnerGroup(e)),this.managers=(0,r.map)(e?.managers??[],e=>new p(e)),this.additionalClients=(0,r.map)(e?.additionalClients??[],e=>new B(e)),this.fixedClients=(0,r.map)(e?.fixedClients??[],e=>new B(e)),this.regions=(0,r.map)(e?.regions??[],e=>new t.Region(e)),this.cities=(0,r.map)(e?.cities??[],e=>new t.CityWithRegionAndCountry(e)),this.lastLoginDate=new d(e?.lastLoginDate),this.lastOrderDate=new d(e?.lastOrderDate)}hasClientConditions(){return(0,r.some)([this.salesDirections,this.partnerGroups,this.managers,this.additionalClients,this.fixedClients,this.regions,this.cities],e=>!(0,r.isEmpty)(e))||(0,r.some)([this.lastLoginDate,this.lastOrderDate],e=>!!e.from||!!e.to)}setPeriod(e,t){return this[e]=new d({from:t?.from?(0,n.startOfDay)(t.from):null,to:t?.to?(0,n.endOfDay)(t.to):null}),this}toSaveData(){return{salesDirections:(0,r.map)(this.salesDirections,`id`),partnerGroups:(0,r.map)(this.partnerGroups,`id`),managers:(0,r.map)(this.managers,`id`),additionalClients:(0,r.map)(this.additionalClients,`id`),regions:(0,r.map)(this.regions,`id`),cities:(0,r.map)(this.cities,`id`),lastLoginDate:new d(this.lastLoginDate),lastOrderDate:new d(this.lastOrderDate)}}},V=function(e){return e.Active=`active`,e.Scheduled=`scheduled`,e.Completed=`completed`,e}({}),ft=class{static resolve(e,t=new Date){return e.deletedAt&&e.deletedAt.getTime()<=t.getTime()?V.Completed:e.publishedAt&&e.publishedAt.getTime()>t.getTime()?V.Scheduled:V.Active}},H=class extends m{conditions;products;productCategories;countDiscountedPrices;expectedCountDiscountedPrices;countDiscountedProducts;countDiscountedClients;constructor(e){super(e),this.conditions=new dt(e?.conditions),this.products=(0,r.map)(e?.products??[],e=>new y(e)),this.productCategories=(0,r.map)(e?.productCategories??[],e=>new C(e)),this.countDiscountedPrices=e?.countDiscountedPrices??0,this.expectedCountDiscountedPrices=e?.expectedCountDiscountedPrices??0,this.countDiscountedProducts=e?.countDiscountedProducts??0,this.countDiscountedClients=e?.countDiscountedClients??0}getState(e=new Date){return ft.resolve(this,e)}assignCounters(e){this.countDiscountedPrices=e.countDiscountedPrices,this.expectedCountDiscountedPrices=e.expectedCountDiscountedPrices,this.countDiscountedProducts=e.countDiscountedProducts,this.countDiscountedClients=e.countDiscountedClients}isPricesUpdating(){return this.countDiscountedPrices!==this.expectedCountDiscountedPrices}toSaveData(){return{name:this.name,percent:this.percent,isLowPriceAllowed:this.isLowPriceAllowed,publishedAt:this.publishedAt??null,deletedAt:this.deletedAt??null,description:this.description??``,products:(0,r.map)(this.products,`id`),productCategories:(0,r.map)(this.productCategories,`id`),conditions:this.conditions.toSaveData()}}},pt=class{client;additionalClientsCondition;fixedClientsCondition;partnerGroupsCondition;managersCondition;citiesCondition;regionsCondition;salesDirectionsCondition;constructor(e){this.client=new B(e?.client),this.additionalClientsCondition=e?.additionalClientsCondition??!1,this.fixedClientsCondition=e?.fixedClientsCondition??!1,this.partnerGroupsCondition=e?.partnerGroupsCondition??!1,this.managersCondition=e?.managersCondition??!1,this.citiesCondition=e?.citiesCondition??!1,this.regionsCondition=e?.regionsCondition??!1,this.salesDirectionsCondition=e?.salesDirectionsCondition??!1}isEligible(){return this.additionalClientsCondition||this.fixedClientsCondition||this.partnerGroupsCondition||this.managersCondition||this.citiesCondition||this.regionsCondition||this.salesDirectionsCondition}},mt=class extends u{id;name;states;constructor(e){super(),this.id=e?.id,this.name=e?.name,this.states=e?.states}resetFilterValue(e){switch(e){case`id`:case`name`:case`states`:this[e]=void 0}return this}},ht=class e extends t.BasePaginationProvider{static prepareSaveData(e,n){return{...e,publishedAt:t.DateHelper.toApiFormat(e.publishedAt),deletedAt:t.DateHelper.toApiFormat(e.deletedAt),conditions:{...e.conditions,lastLoginDate:t.DateHelper.periodToApiFormat(e.conditions.lastLoginDate),lastOrderDate:t.DateHelper.periodToApiFormat(e.conditions.lastOrderDate),updateFixedClients:n}}}getDiscountsList(e,t,n,r){return this.getTypedPaginated(m,`/internal/price/discounts`,e,t,n,{},void 0,r)}getDiscount(e){return this.get(`/internal/price/discounts/${e}`,{},e=>new H(e.data))}createDiscount(t,n,r={}){return this.post(`/internal/price/discounts`,e.prepareSaveData(t,n),e=>new H(e.data),r)}updateDiscount(t,n,r,i={}){return this.patch(`/internal/price/discounts/${t}`,e.prepareSaveData(n,r),e=>new H(e.data),i)}removeDiscount(e){return this.delete(`/internal/price/discounts/${e}`)}getEligibleClients(e){return this.getTypedList(pt,`/internal/price/discounts/${e}/clients`)}checkClient(e,t){return this.get(`/internal/price/discounts/${e}/clients/${t}/check`,{},e=>new pt(e.data))}},U=class extends t.User{showAllCosts;constructor(e){super(e),this.showAllCosts=e?.showAllCosts}},gt=class extends u{name;phone;email;isActive;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.isActive=e?.isActive}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`isActive`:this[e]=void 0}return this}},_t=class e extends t.BasePaginationProvider{static transformExternalSeoDataToRequest(e){return{name:e.name,phone:e.phone,email:e.email,password:e.password,isActive:e.isActive,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1}}getExternalSeoList(e,n,r,i){return this.getTypedPaginated(t.User,`/internal/external-seo`,e,n,r,{},void 0,i)}getExternalSeo(e,t=!1){return this.get(`/internal/external-seo/${e}`,{},e=>new U(e.data),t)}createExternalSeo(t,n={}){return this.post(`/internal/external-seo`,e.transformExternalSeoDataToRequest(t),e=>new U(e.data),n)}updateExternalSeo(t,n={}){return this.patch(`/internal/external-seo/${t.id}`,e.transformExternalSeoDataToRequest(t),e=>new U(e.data),n)}deleteExternalSeo(e){return this.delete(`/internal/external-seo/${e}`)}},W=class extends t.NamedIdentity{constructor(e){super(e)}},G=class extends t.Identity{question;answer;groups;constructor(e){super(e,-1),this.question=e?.question??``,this.answer=e?.answer??``,this.groups=(0,r.map)(e?.groups??[],e=>new W(e))}toSaveData(){return{question:this.question,answer:this.answer,groups:(0,r.map)(this.groups,`id`)}}},vt=class extends t.BasePaginationProvider{getFaqList(e,t){return this.getTypedPaginated(G,`/internal/faq`,void 0,void 0,t,(0,r.isNil)(e)?{}:{group:e})}getFaq(e){return this.get(`/internal/faq/${e}`,{},e=>new G(e.data))}createFaq(e,t={}){return this.post(`/internal/faq`,e,e=>new G(e.data),t)}updateFaq(e,t,n={}){return this.patch(`/internal/faq/${e}`,t,e=>new G(e.data),n)}removeFaq(e){return this.delete(`/internal/faq/${e}`)}getGroupsList(){return this.getTypedList(W,`/internal/faq/groups`)}createGroup(e,t={}){return this.post(`/internal/faq/groups`,e,e=>new W(e.data),t)}updateGroup(e,t,n={}){return this.patch(`/internal/faq/groups/${e}`,t,e=>new W(e.data),n)}removeGroup(e){return this.delete(`/internal/faq/groups/${e}`)}};function yt(e){let t=(0,r.round)(e*100);return`${t>=0?`+`:``}${t}%`}var bt=class e{static productIsMeasurable(e){return e.unit.isLinear||e.unit.isSquare}static getProductMultiplicity(t){return!t.properties?.ignoreMinCountCheck&&t.properties?.minCount!=null&&!e.productIsMeasurable(t)?t.properties.minCount:1}static getProductLengthMultiplicity(e){return e.properties?.lengthStep==null?!e.properties?.ignoreMinCountCheck&&e.properties?.minCount!=null?e.properties.minCount:.01:e.properties.lengthStep}},xt=class{static generateUndefinedManagerInstance(){return new t.Manager({id:0,name:`- Не назначен -`,isActive:!0,guid:`-undefined-`})}static isUndefinedManagerInstance(e){return e.id===0&&e.guid===`-undefined-`}},St=class extends u{name;phone;email;salesDirections;isActive;isSupervisor;canDoReclamations;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.isActive=e?.isActive,this.isSupervisor=e?.isSupervisor,this.canDoReclamations=e?.canDoReclamations}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`salesDirections`:case`isActive`:case`isSupervisor`:case`canDoReclamations`:this[e]=void 0}return this}},Ct=class e extends t.ManagerDataProvider{static transformManagerDataToRequest(e){return{name:e.name,phone:e.contacts?.phone??``,email:e.contacts?.email??``,password:e.password,isActive:e.isActive,isSupervisor:e.isSupervisor,canDoReclamations:e.canDoReclamations,authAsOperator:e.authAsOperator??!1,salesDirectionId:e.salesDirection.id,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1,storeIds:(0,r.map)(e.stores,`id`),curatedDirectionIds:(0,r.map)(e.curatedDirections,`id`),managerRegionIds:(0,r.map)(e.managerRegions,`id`),managerIds:(0,r.map)(e.managers,`id`),photo:e.photoFile}}getManagersList(e,n,r,i){return this.getTypedPaginated(t.Manager,`/internal/managers`,e,n,r,{},void 0,i)}createManager(n,r={}){return this.post(`/internal/managers`,e.transformManagerDataToRequest(n),e=>new t.Manager(e.data),r)}updateManager(n,r={}){return this.patch(`/internal/managers/${n.id}`,e.transformManagerDataToRequest(n),e=>new t.Manager(e.data),r)}getManagerRegionsList(e,n,r){return this.getTypedPaginated(t.UserRegionShortInfo,`/internal/managers/regions`,e,n,r)}},K=function(e){return e.Processing=`processing`,e.Completed=`completed`,e.Error=`error`,e.NeedsActualization=`needs_actualization`,e}({}),wt=class{status;actualizedAt;expiresAt;error;constructor(e){this.status=e?.status??K.Processing,this.actualizedAt=t.DateHelper.parse(e?.actualizedAt),this.expiresAt=t.DateHelper.parse(e?.expiresAt),this.error=e?.error}get isProcessing(){return this.status===K.Processing}get isOutdated(){return this.isOutdatedAt(new Date)}get isOrderAllowed(){return this.isOrderAllowedAt(new Date)}isOutdatedAt(e){return this.status!==K.Completed||(0,r.isNil)(this.actualizedAt)?!0:!(0,r.isNil)(this.expiresAt)&&this.expiresAt.getTime()<e.getTime()}isOrderAllowedAt(e){return this.status===K.Completed&&!this.isOutdatedAt(e)}},Tt=class extends s{name;client;sum;isProfstroy;actualization;file;constructor(e){super(e),this.name=e?.name,this.client=new E(e?.client),this.sum=e?.sum,this.isProfstroy=e?.isProfstroy,this.actualization=e?.actualization&&new wt(e.actualization),this.file=e?.file}},Et=class extends le{groupName;supplierSku;isIgnored;lineError;constructor(e){super(e),this.groupName=e.groupName,this.supplierSku=e.supplierSku??e.product.supplierSku,this.isIgnored=e.isIgnored,this.lineError=e.lineError}get isProductStub(){return(0,r.isNil)(this.product.id)}get isOrderable(){return!this.isProductStub&&!this.isIgnored&&(0,r.isEmpty)(this.lineError)}},q=class extends Tt{sum;products;constructor(e){super(e),this.sum=e.sum??0,this.products=(e.products??[]).map(t=>e.isProfstroy?new Et(t):new le(t))}},Dt=class extends u{id;clientSearchTerm;name;createdAt=new d;constructor(e){super(),this.id=e?.id,this.clientSearchTerm=e?.clientSearchTerm,this.name=e?.name,this.createdAt=new d(e?.createdAt)}resetFilterValue(e){return e===`createdAt`?(this.createdAt.from=null,this.createdAt.to=null):this[e]=void 0,this}asClearRaw(){let e=super.asClearRaw();return!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,e}},Ot=class extends Je{client;payment;delivery;attachedUser;status;statusDetail;salesDirection;attachedAt;isOnOrder;isProfstroy;isNotInStock;sum;isLargeOrder;constructor(e){super(e),this.client=new E(e?.client),this.payment={type:e?.payment?.type??-1,status:e?.payment?.status??-1,onlinePaymentLink:e?.payment?.onlinePaymentLink},this.delivery={type:e?.delivery?.type??-1,date:(0,r.isString)(e?.delivery?.date)?(0,n.parseISO)(e.delivery.date):e?.delivery?.date??new Date,address:e?.delivery?.address?new L(e.delivery.address):void 0,warehouse:e?.delivery?.warehouse?new t.Warehouse(e.delivery.warehouse):void 0},this.attachedUser=e?.attachedUser?new p(e?.attachedUser):void 0,this.status=new t.OrderStatus(e?.status),this.statusDetail=e?.statusDetail?new t.Reference(e.statusDetail):void 0,this.salesDirection=new t.SalesDirection(e?.salesDirection);let i=e?.attachedAt;this.attachedAt=(0,r.isString)(i)?(0,n.parseISO)(i):e?.attachedAt,this.isOnOrder=e?.isOnOrder??!1,this.isProfstroy=e?.isProfstroy??!1,this.isNotInStock=e?.isNotInStock??!1,this.sum=e?.sum??0,this.isLargeOrder=e?.isLargeOrder??!1}},kt=class extends ce{product;cost;costOne;costOneRub;costRub;logicGroupId;salesDirection;specificationImgUrl;sawing;currency;changedFields=[];replacement;constructor(e,n){super(e),this.product=new b(e.product),this.currency=new t.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=(0,r.isArray)(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,n&&(this.replacement=n,this.quantity!==n.quantity&&this.changedFields.push(`quantity`),this.length!==n.length&&this.changedFields.push(`length`))}},J=class extends Ot{products;invoices;comment;image;contragent;barcode;orderSource;isAllowProcessingWithoutPayment;nextStatuses;actions;operatorsComment;operatorsForWarehouseComment;erpOrderUrl;numberDoc;constructor(e){super(e),this.products=(e.products??[]).map(t=>new kt(t,t.replacementId?e.products?.find(e=>e.id===t.replacementId):void 0)),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?I.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new t.Reference(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment,this.nextStatuses=e.nextStatuses?.map(e=>new t.OrderStatus(e)),this.actions=e.actions,this.operatorsComment=e.operatorsComment,this.operatorsForWarehouseComment=e.operatorsForWarehouseComment,this.erpOrderUrl=e.erpOrderUrl,this.numberDoc=e.numberDoc}},At=class extends t.BasePaginationProvider{getOffers(e,t,n,r){return this.getTypedPaginated(Tt,`/internal/orders/offers`,e,t,n,{},void 0,r)}createOfferFromCart(e,t,n){return this.post(`/internal/orders/offers/${e}`,{name:t,items:n?.length?n:void 0},e=>new q(e.data))}createProfstroyOffer(e,t,n,r={}){return this.post(`/internal/orders/offers/${e}/profstroy`,{file:t,name:n},e=>new q(e.data),r)}actualizeProfstroyOffer(e){return this.post(`/internal/orders/offers/${e}/profstroy/actualize`,{},e=>new q(e.data))}reloadProfstroyOffer(e){return this.post(`/internal/orders/offers/${e}/profstroy/reload`,{},e=>new q(e.data))}getOffer(e){return this.get(`/internal/orders/offers/${e}`,{},e=>new q(e.data))}updateOffer(e,t){return this.patch(`/internal/orders/offers/${e}`,{name:t},e=>new q(e.data))}deleteOffer(e){return this.delete(`/internal/orders/offers/${e}`)}createOrderFromDraft(e,r,i,a={}){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.post(`/internal/orders/offers/${e}/create-order`,{...r,deliveryDate:r.deliveryDate?(0,n.format)(r.deliveryDate,o):void 0,items:i?.length?i:void 0},e=>t.TypedInstanceFactory.instanceListInitializer(J,e.data),a)}addOfferProduct(e,t,n={}){return this.post(`/internal/orders/offers/${e}/products`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new q(e.data),n)}patchOfferProduct(e,t,n,r={}){return this.patch(`/internal/orders/offers/${e}/products/${t}`,{product_id:n.product.id,product_category_id:n.configurator?n.category.id:void 0,quantity:n.quantity,height:n.height,length:n.length,width:n.width,configurator:n.configurator,marker:n.marker,is_additional_sale:n.isAdditionalSale,...n.configuratorParams},e=>new q(e.data),r)}deleteOfferProduct(e,t){return this.delete(`/internal/orders/offers/${e}/products/${t}`,e=>new q(e.data))}deleteOfferProducts(e,t){return this.request({method:`DELETE`,url:`/internal/orders/offers/${e}/products`,data:{items:t}},e=>new q(e.data))}getOfferHtml(e,t){return this.get(`/internal/orders/offers/${e}/view`,t?{recipientText:t}:{},e=>new Blob([e.data],{type:`text/html`}))}getOfferPdf(e,t){return this.getBlob(`/internal/orders/offers/${e}/download`,t?{recipientText:t}:{},e=>new Blob([e.request.response],{type:`application/pdf`}))}sendOffer(e,t){return this.post(`/internal/orders/offers/${e}/send`,t)}},jt=class{static isProfstroy(e){return!!e?.isProfstroy}static isProfstroyOffer(e){return!(0,r.isNil)(e)&&e.isProfstroy===!0&&!(0,r.isNil)(e.actualization)}},Mt=class extends t.User{isBillingSupervisor;constructor(e){super(e),this.isBillingSupervisor=e?.isBillingSupervisor??!1}},Y=class extends Mt{showAllCosts;stores;constructor(e){super(e),this.showAllCosts=e?.showAllCosts,this.stores=e?.stores?.map(e=>new t.Shop(e))}},Nt=class extends u{name;phone;email;salesDirections;isActive;isBillingSupervisor;canDoReclamations;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.isActive=e?.isActive,this.isBillingSupervisor=e?.isBillingSupervisor,this.canDoReclamations=e?.canDoReclamations}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`salesDirections`:case`isActive`:case`isBillingSupervisor`:case`canDoReclamations`:this[e]=void 0}return this}},Pt=class e extends t.BasePaginationProvider{static transformOperatorDataToRequest(e){return{name:e.name,phone:e.phone,email:e.email,password:e.password,isActive:e.isActive,isBillingSupervisor:e.isBillingSupervisor,canDoReclamations:e.canDoReclamations,salesDirectionId:e.salesDirection?.id,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1,storeIds:(0,r.map)(e.stores,`id`),photo:e.photoFile}}getOperatorsList(e,t,n,r){return this.getTypedPaginated(Mt,`/internal/operators`,e,t,n,{},void 0,r)}getOperator(e,t=!1){return this.get(`/internal/operators/${e}`,{},e=>new Y(e.data),t)}createOperator(t,n={}){return this.post(`/internal/operators`,e.transformOperatorDataToRequest(t),e=>new Y(e.data),n)}updateOperator(t,n={}){return this.patch(`/internal/operators/${t.id}`,e.transformOperatorDataToRequest(t),e=>new Y(e.data),n)}},Ft=function(e){return e.View=`view`,e.Share=`share`,e.EditTags=`edit_tags`,e.SaveOrderIgnoredProducts=`save_order_ignored_products`,e.ChangeStatus=`change_status`,e.ChangeProducts=`change_products`,e.ChangeOrderParameters=`change_order_parameters`,e.Recalculate=`recalculate`,e.AttachOrder=`attach_order`,e.DetachOrder=`detach_order`,e.ChangeAttachedOperator=`change_attached_operator`,e.SendOnlinePaymentLink=`send_online_payment_link`,e.ConfirmOnlineFullPayment=`confirm_online_full_payment`,e.MergeOrders=`merge_orders`,e.GetHistory=`get_history`,e.CloneOrder=`clone_order`,e.DeleteAttachedFile=`delete_attached_file`,e}({}),It=class{paymentType;deliveryType;contragentId;deliveryDate;addressId;warehouseId;image;comment;barcode;operatorsComment;operatorsForWarehouseComment;additionalEmails;isAllowProcessingWithoutPayment;isAdditionalSale;constructor(e){this.paymentType=e?.payment.type,this.deliveryType=e?.delivery.type,this.contragentId=e?.contragent?.id,this.deliveryDate=e?.delivery.date?new Date(e.delivery.date):void 0,this.addressId=e?.delivery.address?.id,this.warehouseId=e?.delivery.warehouse?.id,this.comment=e?.comment,this.barcode=e?.barcode,this.operatorsComment=e?.operatorsComment,this.operatorsForWarehouseComment=e?.operatorsForWarehouseComment,this.isAllowProcessingWithoutPayment=e?.isAllowProcessingWithoutPayment}},Lt=class extends u{attachedUsers;clientSearchTerm;client;contragent;createdAt=new d;creator;deliveryDate=new d;deliveryAddressSearch;clientCities;id;isApproved;isNotInStock;isOnOrder;attachedAt=new d;salesDirections;status;statusDetail;deliveryType;paymentType;warehouses;isLargeOrder;isToProcess;onlyMyRegions;constructor(e){super(),this.attachedUsers=e?.attachedUsers?.map(e=>`isActive`in e?new t.Manager(e):new t.Operator(e)),this.clientSearchTerm=e?.clientSearchTerm,this.client=e?.client?new E(e.client):void 0,this.contragent=e?.contragent,this.createdAt=new d(e?.createdAt),this.creator=e?.creator?new p(e.creator):void 0,this.deliveryDate=new d(e?.deliveryDate),this.deliveryAddressSearch=e?.deliveryAddressSearch,this.clientCities=e?.clientCities?.map(e=>new t.CityWithRegionAndCountry(e)),this.id=e?.id,this.isApproved=e?.isApproved,this.isNotInStock=e?.isNotInStock,this.isOnOrder=e?.isOnOrder,this.isLargeOrder=e?.isLargeOrder,this.attachedAt=new d(e?.attachedAt),this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.status=e?.status,this.statusDetail=e?.statusDetail,this.deliveryType=e?.deliveryType?new t.DeliveryType(e.deliveryType):void 0,this.paymentType=e?.paymentType?new t.PaymentType(e.paymentType):void 0,this.warehouses=e?.warehouses?.map(e=>new t.Warehouse(e)),this.isToProcess=e?.isToProcess}resetFilterValue(e){switch(e){case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`creator`:this.creator=void 0;break;case`deliveryDate`:this.deliveryDate.from=null,this.deliveryDate.to=null;break;case`deliveryType`:this.deliveryType=new t.DeliveryType;break;case`clientCities`:this.clientCities=[];break;case`attachedAt`:this.attachedAt.from=null,this.attachedAt.to=null;break;case`salesDirection`:case`salesDirections`:this.salesDirections=[];break;case`status`:this.status=[];break;case`warehouse`:case`warehouses`:this.warehouses=[];break;default:this[e]=void 0}return this}asClearRaw(){let e=super.asClearRaw();return!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,!e?.deliveryDate?.from&&!e?.deliveryDate?.to&&delete e.deliveryDate,!e?.attachedAt?.from&&!e?.attachedAt?.to&&delete e.attachedAt,e}},Rt=class{user;status;statusDetail;createdAt;constructor(e){this.user=new p(e?.user),this.status=new t.OrderStatus(e?.status),this.statusDetail=e?.statusDetail?new t.Reference(e.statusDetail):void 0;let i=e?.createdAt;this.createdAt=(0,r.isString)(i)?(0,n.parseISO)(i):e?.createdAt??new Date}},zt=class extends t.BasePaginationProvider{getOrders(e,t,n,r){return this.getTypedPaginated(Ot,`/internal/orders`,e,t,n,{},void 0,r)}getOrdersCount(e,n){return this.get(`/internal/orders/count`,e?{filters:JSON.stringify((e instanceof t.FilterGroup?e:new t.FilterGroup(e)).toPrimitive())}:{},void 0,void 0,n).then(e=>e.count)}getClientOrderStatistics(e,t){return this.get(`/internal/clients/${e}/orders/statistics`,t?{period:t}:{})}getOrder(e){return this.get(`/internal/orders/${e}`,{},e=>new J(e.data))}createClientOrder(e,r,i,a={}){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.post(`/internal/clients/${e}/orders`,{...r,deliveryDate:(0,n.format)(r.deliveryDate,o),items:i?.length?i:void 0},e=>t.TypedInstanceFactory.instanceListInitializer(J,e.data),a)}attachOrder(e){return this.patch(`/internal/orders/${e}/attach`,{},e=>new J(e.data))}detachOrder(e){return this.patch(`/internal/orders/${e}/detach`,{},e=>new J(e.data))}mergeOrders(e,t){return this.patch(`/internal/orders/${e}/merge`,{ids:t},e=>new J(e.data))}recalculateOrder(e){return this.patch(`/internal/orders/${e}/recalculate`,{},e=>new J(e.data))}cloneOrder(e){return this.get(`/internal/orders/${e}/clone`,{})}updateOrder(e,r,i={}){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.patch(`/internal/orders/${e}`,{...r,deliveryDate:r.deliveryDate?(0,n.format)(r.deliveryDate,a):void 0},e=>new J(e.data),i)}addOrderProduct(e,t,n={}){return this.post(`/internal/orders/${e}/products`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new J(e.data),n)}changeOrderStatus(e,t,n,r={}){return this.patch(`/internal/orders/${e}/status`,{status:t,statusDetail:n},e=>new J(e.data),r)}changeOrderStatusDetail(e,t){return this.patch(`/internal/orders/${e}/status`,{statusDetail:t},e=>new J(e.data))}getOrderStatusHistory(e){return this.getTypedList(Rt,`/internal/orders/${e}/history`)}getOrderPrintHtml(e,t){return this.get(`/internal/orders/${e}/print/view`,{...t},e=>new Blob([e.data],{type:`text/html`}))}getOrderPrintPdf(e,t){return this.getBlob(`/internal/orders/${e}/print/download`,{...t},e=>new Blob([e.request.response],{type:`application/pdf`}))}sendOrderPrint(e,t){return this.post(`/internal/orders/${e}/print/send`,t)}changeAttachedOperator(e,t){return this.patch(`/internal/orders/${e}/change-attached-operator`,{operatorId:t},e=>new J(e.data))}deleteOrderAttachedFile(e){return this.delete(`/internal/orders/${e}/file/attached`,e=>new J(e.data))}deleteOrderProduct(e,t){return this.delete(`/internal/orders/${e}/products/${t}`,e=>new J(e.data))}patchOrderProduct(e,t,n,r={}){return this.patch(`/internal/orders/${e}/products/${t}`,{product_id:n.product.id,product_category_id:n.configurator?n.category.id:void 0,quantity:n.quantity,height:n.height,length:n.length,width:n.width,configurator:n.configurator,marker:n.marker,is_additional_sale:n.isAdditionalSale,...n.configuratorParams},e=>new J(e.data),r)}getDeliveryNearestDates(e,t){return this.get(`/internal/orders/delivery/${e}/nearest-dates`,{},e=>e.data,void 0,t)}getSelfDeliveryNearestDates(e,t){return this.get(`/internal/orders/self-delivery/${e}/nearest-dates`,{},e=>e.data,void 0,t)}getDeliveryCost(e,r,i,a){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.get(`/internal/orders/delivery/${e}/cost`,{date:(0,n.format)(r,o),warehouse_id:i},e=>e.data,void 0,a)}},Bt=Symbol(`currentOrder`),X=class{client;product;cost;costCoefficient;source;constructor(e){this.client=new E(e?.client),this.product=new y(e?.product),this.cost=e?.cost??0,this.costCoefficient=e?.costCoefficient??0,this.source=e?.source??se.Product}},Vt=e=>e?(0,r.omitBy)({cities:e.cities?.map(e=>e.id),clients:e.clients?.map(e=>e.id),managers:e.managers?.map(e=>e.id),partnerGroups:e.partnerGroups?.map(e=>e.id),salesDirections:e.salesDirections?.map(e=>e.id),hideNotActive:e.hideNotActive},e=>(0,r.isNil)(e)||((0,r.isArray)(e)||(0,r.isObject)(e))&&(0,r.isEmpty)(e)):{},Ht=e=>{let t={};return e.from&&(e.from.coefficient||e.from.value)&&(t.from={},e.from.coefficient&&(t.from.priceCoefficientId=e.from.coefficient.id),e.from.value&&(t.from.increasePercent=e.from.value)),e.to&&(e.to.coefficient||e.to.value)&&(t.to={},e.to.coefficient&&(t.to.priceCoefficientId=e.to.coefficient.id),e.to.value&&(t.to.increasePercent=e.to.value)),t},Ut=class extends t.HttpRequester{analyzeProductPrices(e,n,r){return this.get(`/internal/price/products/${e}/analyze`,{...Ht(n),filters:Vt(r)},e=>t.TypedInstanceFactory.instanceListInitializer(X,e.data))}analyzeCategoryPrices(e,n,r){return this.get(`/internal/price/categories/${e}/analyze`,{...Ht(n),filters:Vt(r)},e=>t.TypedInstanceFactory.instanceListInitializer(X,e.data))}analyzeCategoryPricesBySquare(e,n,r){return this.get(`/internal/price/categories/${e}/analyze/square`,{...n,filters:Vt(r)},e=>t.TypedInstanceFactory.instanceListInitializer(X,e.data))}},Wt=class{cost;isLowCost;isRetail;costDate;discountName;priceTemplateName;product;client;executor;currency;constructor(e){this.cost=e.cost??0,this.isLowCost=e.isLowCost??!1,this.isRetail=e.isRetail??!1,this.costDate=(0,r.isString)(e.costDate)?(0,n.parseISO)(e.costDate):e.costDate??new Date,this.discountName=e.discountName,this.priceTemplateName=e.priceTemplateName,this.product=e.product?new _(e.product):void 0,this.client=e.client?new p(e.client):void 0,this.executor=e.executor?new p(e.executor):void 0,this.currency=e.currency?new t.Currency(e.currency):void 0}},Gt=class extends _{history;constructor(e){super(e),this.history=(0,r.map)(e.history,e=>new Wt(e))}},Kt=class extends t.HttpRequester{getProductPriceHistory(e){let i=(0,t.useBaseConfigStore)().config.dateFormats.api,a=(0,r.omitBy)((0,r.merge)(e,{costDate:{from:(0,r.isDate)(e.costDate?.from)?(0,n.format)(e.costDate.from,i):e.costDate?.from,to:(0,r.isDate)(e.costDate?.to)?(0,n.format)(e.costDate.to,i):e.costDate?.to}}),e=>(0,r.isNil)(e)||((0,r.isArray)(e)||(0,r.isObject)(e))&&(0,r.isEmpty)(e)),o=e.product?.[0]??0;return delete a.product,this.get(`/internal/price/products/${o}/history`,a).then(e=>[new Gt((0,r.merge)(e[0],{history:e}))])}},qt=class{createdAt;creator;files;text;status;constructor(e){this.createdAt=t.DateHelper.parse(e?.createdAt)??new Date,this.creator=(0,r.isNil)(e?.creator)?void 0:new p(e.creator),this.files=e?.files??[],this.text=e?.text??void 0,this.status=e?.status??void 0}isStatusChanged(){return!(0,r.isNil)(this.status)}},Z=function(e){return e[e.Initiated=1]=`Initiated`,e[e.InfoRequired=2]=`InfoRequired`,e[e.Pending=3]=`Pending`,e[e.Completed=4]=`Completed`,e}({}),Jt=class extends s{status;closedAt;isRead;isDeleted;client;constructor(e){super(e),this.status=e?.status??Z.Initiated,this.closedAt=t.DateHelper.parse(e?.closedAt),this.isRead=e?.isRead??!1,this.isDeleted=e?.isDeleted??!1,this.client=new Ge(e?.client)}isClosed(){return this.status===Z.Completed}isDeletionPending(){return this.isDeleted&&!this.isClosed()}canAddMessage(){return!this.isClosed()}getConsiderationDays(e=new Date){return Math.max((0,n.differenceInCalendarDays)(this.closedAt??e,this.createdAt),0)}},Q=class extends Jt{items;constructor(e){super(e),this.items=(0,r.map)(e?.items??[],e=>new qt(e))}isClientMessage(e){return e.creator?.id===this.client.id}},Yt=class extends u{id;statuses;createdAt;closedAt;isRead;isDeleted;clientName;cityName;constructor(e){super(),this.id={from:e?.id?.from??null,to:e?.id?.to??null},this.statuses=e?.statuses,this.createdAt=new d(e?.createdAt),this.closedAt=new d(e?.closedAt),this.isRead=e?.isRead,this.isDeleted=e?.isDeleted,this.clientName=e?.clientName,this.cityName=e?.cityName}resetFilterValue(e){switch(e){case`isDeleted`:this.isDeleted=!1;break;case`statuses`:case`isRead`:case`clientName`:case`cityName`:this[e]=void 0;break;case`id`:this.id.from=null,this.id.to=null;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`closedAt`:this.closedAt.from=null,this.closedAt.to=null}return this}},Xt=class e{static apiCodes={[Z.Initiated]:`initiated`,[Z.InfoRequired]:`info_required`,[Z.Pending]:`pending`,[Z.Completed]:`completed`};static toApiCode(t){return e.apiCodes[t]}static toApiCodes(t){return(0,r.map)(t,t=>e.toApiCode(t))}},Zt=class extends t.BasePaginationProvider{getReclamationsList(e,t,n,r,i=!1){return this.getTypedPaginated(Jt,`/internal/reclamations`,e,t,n,{},i,r)}getReclamation(e,t,n=!1){return this.get(`/internal/reclamations/${e}`,{},e=>new Q(e.data),n,t)}createMessage(e,t,n={}){return this.post(`/internal/reclamations/${e}/messages`,t,e=>new Q(e.data),n)}deleteReclamation(e){return this.delete(`/internal/reclamations/${e}`)}restoreReclamation(e){return this.post(`/internal/reclamations/${e}/restore`,{},e=>new Q(e.data))}downloadReclamation(e,t=!1){return this.getBlob(`/internal/reclamations/${e}/download`,{},e=>new Blob([e.request.response],{type:`application/pdf`}),t)}getUpdates(e,t=!1){return this.get(`/internal/reclamations/updates`,{},void 0,t,e)}},Qt=class{products=[];productCategories=[];constructor(e){e?.products&&(this.products=e.products.map(e=>new _(e))),e?.productCategories&&(this.productCategories=e.productCategories.map(e=>new _(e)))}},$t=class extends t.HttpRequester{getProductCategoryRecommendations(e){return this.get(`/internal/catalog/recommendations/categories/${e.id}`,{},e=>new Qt(e.data))}getProductRecommendations(e){return this.get(`/internal/catalog/recommendations/products/${e.id}`,{},e=>new Qt(e.data))}saveProductCategoryRecommendations(e,t){return this.post(`/internal/catalog/recommendations/categories/${e.id}`,{product_categories:t.productCategories.map(e=>e.id),products:t.products.map(e=>e.id)})}saveProductRecommendations(e,t){return this.post(`/internal/catalog/recommendations/products/${e.id}`,{product_categories:t.productCategories.map(e=>e.id),products:t.products.map(e=>e.id)})}},en=class{static generateUndefinedInstance(e,t=`- Не определён -`){return new e({id:0,name:t,slug:`-undefined-`})}static isUndefinedInstance(e){return e.id===0&&e.slug===`-undefined-`}},tn=class{name;content;constructor(e){this.name=e.name,this.content=e.content}},nn=class{resourceType;resourceId;h1;title;description;keywords;meta;tags;constructor(e){this.resourceType=new t.ResourceType(e?.resourceType),this.resourceId=e?.resourceId??``,this.h1=e?.h1,this.title=e?.title,this.description=e?.description,this.keywords=e?.keywords,this.meta=e?.meta?.map(e=>new tn(e))??[],this.tags=e?.tags}},rn=class extends t.HttpRequester{getResourceSeoData(e,t){return this.get(`/internal/seo/${e.slug}/${t}`,{},e=>new nn(e.data))}saveResourceSeoData(e,t={}){return this.post(`/internal/seo/${e.resourceType.slug}/${e.resourceId}`,e,e=>new nn(e.data),t)}deleteResourceSeoData(e,t){return this.delete(`/internal/seo/${e.slug}/${t}`)}},an=class extends t.Identity{text;searchCount;lastSearchedAt;constructor(e){super(e),this.text=e?.text??``,this.searchCount=e?.searchCount??0,this.lastSearchedAt=t.DateHelper.parse(e?.lastSearchedAt)}},on=class extends t.HttpRequester{getSearchProductsStatistics(e,n){return this.getTypedList(an,`/internal/statistics/search/products`,{date:t.DateHelper.periodToApiFormat(e)},!1,n)}removeSearchProductStatistic(e){return this.delete(`/internal/statistics/search/products/${e}`)}},$=function(e){return e[e.Undetermined=0]=`Undetermined`,e[e.Complete=1]=`Complete`,e[e.Incomplete=2]=`Incomplete`,e}({}),sn=class e{static isBlocked(e,t){return t&&e===$.Incomplete}static getValidationResult(n,r){return e.isBlocked(n,r)?new t.FieldValidationResultData(`Проверьте адрес и выберите более точный вариант из подсказок`,`error`):n===$.Incomplete||n===$.Undetermined?new t.FieldValidationResultData(`Проверьте правильность адреса`,`warning`):void 0}},cn=class extends t.HttpRequester{searchAddresses(e){return this.execSuggestionQuery(`/public/suggestions/address`,e)}searchBank(e){return this.execSuggestionQuery(`/public/suggestions/bank`,e)}searchOrganization(e){return this.execSuggestionQuery(`/public/suggestions/organization`,e)}execSuggestionQuery(e,t){return this.get(e,{query:t}).then(e=>{let t=[...e],n=1;return t.forEach(e=>{e.id=n++}),t})}},ln=class extends t.HttpRequester{constructor(){super(),this.baseUrl=`${(0,t.useBaseConfigStore)().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(e=>e.accessToken)}},un=class{user;salesDirection;constructor(e){this.user=new p(e?.user),this.salesDirection=new t.SalesDirection(e?.salesDirection)}},dn=class extends t.UserRegionShortInfo{cities;users;constructor(e){super(e),this.cities=e?.cities?.map(e=>new t.CityWithRegionAndCountry(e))??[],this.users=e?.users?.map(e=>new un(e))??[]}},fn=class extends u{id;name;abbr;constructor(e){super(),this.id=e?.id,this.name=e?.name,this.abbr=e?.abbr}resetFilterValue(e){switch(e){case`id`:case`name`:case`abbr`:this[e]=void 0}return this}},pn=class extends t.BasePaginationProvider{getRegionsList(e,n,r){return this.getTypedPaginated(t.UserRegionShortInfo,`/internal/users/regions`,e,n,r)}getRegion(e){return this.get(`/internal/users/regions/${e}`,{},e=>new dn(e.data))}createRegion(e,t={}){return this.post(`/internal/users/regions`,e,e=>new dn(e.data),t)}updateRegion(e,t,n={}){return this.patch(`/internal/users/regions/${e}`,t,e=>new dn(e.data),n)}removeRegion(e){return this.delete(`/internal/users/regions/${e}`)}getRegionEmployees(e){return this.getTypedList(un,`/internal/users/regions/${e}/users`)}attachRegionEmployee(e,t,n){return this.post(`/internal/users/regions/${e}/users/${t}`,{salesDirectionId:n},e=>new un(e.data))}detachRegionEmployee(e,t,n){return this.request({method:`DELETE`,url:`/internal/users/regions/${e}/users/${t}`,params:{sales_direction_id:n}})}};e.AddressQualityEnum=$,e.AddressQualityHelper=sn,e.BankAccount=N,e.BlogPost=l,e.BlogPostMediaFile=a,e.BlogPostMediaTypeEnum=i,e.BlogPostPublicationStatusEnum=o,e.BlogPostShortInfo=c,e.BlogPostsListFilters=ee,e.BlogProvider=te,e.CalculationTypeEnum=de,e.CalendarHelper=z,e.Cart=S,e.CartProvider=ue,e.CatalogProvider=Ee,e.CatalogableItem=ie,e.Category=C,e.CategoryFilter=Te,e.CategoryFilterSetting=Ce,e.CategoryFilterValue=we,e.CategoryPricingRule=xe,e.Client=Ke,e.ClientAdditionalData=Ye,e.ClientBaseInfo=Ge,e.ClientCategory=me,e.ClientDataProvider=Ze,e.ClientPriceCatalogableItem=ye,e.ClientPriceCategory=be,e.ClientPriceProduct=j,e.ClientPriceProvider=De,e.ClientPriceTemplateProvider=Oe,e.ClientProduct=b,e.ClientProductCategoryDataProvider=je,e.ClientProductDataProvider=Me,e.ClientShortInfo=E,e.ClientsAdditionalDataRequestTypeEnum=ze,e.ClientsListFilters=qe,e.CodedIdentity=_,e.ConfiguratorProvider=tt,e.ConfiguratorsEnum=et,e.Contact=P,e.ContactPerson=F,e.ContactPersonRelated=Xe,e.ContactRelation=R,e.ContragentBase=Be,e.ContragentFactory=I,e.ContragentIc=He,e.ContragentPerson=Ve,e.ContragentUlNr=We,e.ContragentUlR=Ue,e.CostSourceEnum=se,e.CreatableIdentity=s,e.Curator=T,e.DataSuggestionProvider=cn,e.DateTimeProvider=ct,e.DeletableIdentity=_e,e.DeletableNamedIdentity=f,e.DeliveryAddress=L,e.Discount=H,e.DiscountClient=B,e.DiscountClientEligibility=pt,e.DiscountConditions=dt,e.DiscountProvider=ht,e.DiscountShortInfo=m,e.DiscountStateEnum=V,e.DiscountStateHelper=ft,e.DiscountsListFilters=mt,e.ExternalSeoFullInfo=U,e.ExternalSeoListFilters=gt,e.ExternalSeoProvider=_t,e.Faq=G,e.FaqGroup=W,e.FaqProvider=vt,e.FilterSettings=Se,e.HiddenCatalogableItem=ae,e.Image=oe,e.ManagerDataFactory=xt,e.ManagerProvider=Ct,e.ManagersListFilters=St,e.MetaTagItem=tn,e.Offer=q,e.OfferActualization=wt,e.OfferActualizationStatus=K,e.OfferHelper=jt,e.OfferShortInfo=Tt,e.OffersDataProvider=At,e.OffersListFilters=Dt,e.OperatorFullInfo=Y,e.OperatorProvider=Pt,e.OperatorShortInfo=Mt,e.OperatorsListFilters=Nt,e.Order=J,e.OrderAction=Ft,e.OrderEditorData=It,e.OrderInfo=Ot,e.OrderItem=kt,e.OrderItemBase=ce,e.OrderShortInfo=Je,e.OrderStatusHistoryInfo=Rt,e.OrdersDataProvider=zt,e.OrdersListFilters=Lt,e.PaginationFiltersBase=u,e.PriceAnalyze=X,e.PriceAnalyzeProvider=Ut,e.PriceCatalogableItem=he,e.PriceHistoryDataProvider=Kt,e.PriceHistoryItem=Wt,e.PriceTemplate=h,e.PriceTemplateCategory=w,e.PriceTemplateClient=D,e.PriceTemplateICatalogableItem=ge,e.PriceTemplateProduct=O,e.PriceTemplateProvider=Ne,e.PricingRole=M,e.PricingRoleProvider=Pe,e.PrimaryCatalogableItem=v,e.Product=y,e.ProductCategoryDataProvider=ke,e.ProductDataProvider=Ae,e.ProductFilterTypeEnum=fe,e.ProductPriceCoefficient=g,e.ProductPriceHistory=Gt,e.ProductUnit=re,e.ProfstroyOfferItem=Et,e.PropertiesProvider=Fe,e.Property=k,e.PropertyValue=A,e.Reclamation=Q,e.ReclamationItem=qt,e.ReclamationProvider=Zt,e.ReclamationShortInfo=Jt,e.ReclamationStatusEnum=Z,e.ReclamationStatusHelper=Xt,e.ReclamationsListFilters=Yt,e.RecommendationsDataProvider=$t,e.RecommendationsList=Qt,e.ReferenceDataFactory=en,e.STANDARD_PERIOD_GROUPS=lt,e.STANDARD_PERIOD_SECTIONS=ut,e.SearchProductStatistic=an,e.Seo=nn,e.SeoDataProvider=rn,e.StatisticsProvider=on,e.StockCount=ne,e.TableDataPagination=rt,e.TableDataPaginationRequestParams=nt,e.TableDataSortRequestParams=it,e.TemplateProductCategoryDataProvider=Ie,e.TemplatesListFilters=ve,e.UnitsHelper=bt,e.UnknownClientDataProvider=Qe,e.UserAuthDataProvider=ln,e.UserRegion=dn,e.UserRegionEmployee=un,e.UserRegionProvider=pn,e.UserRegionsListFilters=fn,e.UserShortInfo=p,e.VersionConfig=$e,e.currentOrderInjectionKey=Bt,e.daysAgoIso=at,e.findCatalogItemByIdRecursive=Le,e.flattenCatalogItems=Re,e.formatPercentChange=yt,e.formatRelativeDate=st,e.pluralize=ot,Object.keys(t).forEach(function(n){n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@snabcentr/common-core"),require("lodash-es"),require("date-fns")):typeof define==`function`&&define.amd?define([`exports`,`@snabcentr/common-core`,`lodash-es`,`date-fns`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`SC Common Lib`]={},e[`@snabcentr/common-core`],e[`lodash-es`],e[`date-fns`]))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=class extends t.User{isSuperadmin;constructor(e){super(e),this.isSuperadmin=e?.isSuperadmin??!1}},a=class extends i{showAllCosts;constructor(e){super(e),this.showAllCosts=e?.showAllCosts}},o=class{asClearRaw(){let e={};return Object.keys(this).forEach(t=>{let r=this[t];(0,n.isNil)(r)||(0,n.isString)(r)&&r.trim().length===0||(0,n.isFunction)(r.isNewRec)&&r.isNewRec()||(e[t]=r)}),e}},s=class extends o{name;phone;email;isActive;isSuperadmin;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.isActive=e?.isActive,this.isSuperadmin=e?.isSuperadmin}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`isActive`:case`isSuperadmin`:this[e]=void 0}return this}},c=class e extends t.BasePaginationProvider{static transformAdminDataToRequest(e){return{name:e.name,phone:e.phone,email:e.email,password:e.password,isActive:e.isActive,isSuperadmin:e.isSuperadmin,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1}}getAdminsList(e,t,n,r){return this.getTypedPaginated(i,`/internal/admins`,e,t,n,{},void 0,r)}getAdmin(e,t=!1){return this.get(`/internal/admins/${e}`,{},e=>new a(e.data),t)}createAdmin(t,n={}){return this.post(`/internal/admins`,e.transformAdminDataToRequest(t),e=>new a(e.data),n)}updateAdmin(t,n={}){return this.patch(`/internal/admins/${t.id}`,e.transformAdminDataToRequest(t),e=>new a(e.data),n)}deleteAdmin(e){return this.delete(`/internal/admins/${e}`)}},l=function(e){return e.Image=`image`,e.Video=`video`,e}({}),u=class extends t.Identity{mediaType;isCover;isUnused;url;urlWebp;constructor(e){super(e,``),this.mediaType=e?.mediaType??l.Image,this.isCover=e?.isCover??!1,this.isUnused=e?.isUnused??!1,this.url=e?.url??``,this.urlWebp=e?.urlWebp}isImage(){return this.mediaType===l.Image}isVideo(){return this.mediaType===l.Video}},d=function(e){return e.Draft=`draft`,e.Published=`published`,e.Scheduled=`scheduled`,e}({}),f=class extends t.Identity{createdAt;constructor(e,n){super(e,n),this.createdAt=t.DateHelper.parse(e?.createdAt)??new Date}},ee=class e extends f{static resolvePublicationStatus(e){return(0,n.isNil)(e)?d.Draft:e.getTime()>Date.now()?d.Scheduled:d.Published}static getSlugError(e){return e?/[^a-z0-9-]/.test(e)?`Допустимы только строчные латинские буквы, цифры и дефис: пример «kak-vybrat-podokonnik».`:(0,n.startsWith)(e,`-`)||(0,n.endsWith)(e,`-`)?`Обозначение не может начинаться или заканчиваться дефисом.`:(0,n.includes)(e,`--`)?`Дефисы не могут идти подряд: разделяйте слова одним дефисом.`:``:``}static parseDate(e){return(0,n.isNil)(e)?null:(0,n.isString)(e)?(0,r.parseISO)(e):e}slug;title;publishedAt;constructor(t){super(t,-1),this.slug=t?.slug??``,this.title=t?.title??``,this.publishedAt=e.parseDate(t?.publishedAt)}getPublicationStatus(){return e.resolvePublicationStatus(this.publishedAt)}},p=class extends ee{content;media;constructor(e){super(e),this.content=e?.content??``,this.media=(e?.media??[]).map(e=>new u(e))}toSaveData(e=!1){return{title:this.title,slug:this.slug.length>0?this.slug:void 0,content:e?this.content:void 0,publishedAt:this.publishedAt}}getCover(){return this.media.find(e=>e.isCover)}getUnusedMedia(){return this.media.filter(e=>e.isUnused)}},m=class{from;to;constructor(e){this.from=(0,n.isString)(e?.from)?(0,r.parseISO)(e.from):e?.from??null,this.to=(0,n.isString)(e?.to)?(0,r.parseISO)(e.to):e?.to??null}},te=class extends o{id;title;slug;content;publicationStatus;publishedAt;createdAt;constructor(e){super(),this.id=e?.id,this.title=e?.title,this.slug=e?.slug,this.content=e?.content,this.publicationStatus=e?.publicationStatus,this.publishedAt=new m(e?.publishedAt),this.createdAt=new m(e?.createdAt)}resetFilterValue(e){switch(e){case`id`:case`title`:case`slug`:case`content`:case`publicationStatus`:this[e]=void 0;break;case`publishedAt`:this.publishedAt.from=null,this.publishedAt.to=null;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null}return this}asClearRaw(){let e=super.asClearRaw();return!e?.publishedAt?.from&&!e?.publishedAt?.to&&delete e.publishedAt,!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,e}},ne=class e extends t.BasePaginationProvider{static preparePostSaveData(e){let i={};if((0,n.isUndefined)(e.title)||(i.title=e.title),(0,n.isUndefined)(e.slug)||(i.slug=e.slug),(0,n.isUndefined)(e.content)||(i.content=e.content),!(0,n.isUndefined)(e.publishedAt)){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;i.publishedAt=(0,n.isNil)(e.publishedAt)?null:(0,r.format)(e.publishedAt,a)}return i}getPostList(e,t,n){return this.getPaginated(`/internal/blog`,e,t,n,{},e=>({...e.data,data:e.data.data.map(e=>new ee(e))}))}getPost(e){return this.get(`/internal/blog/${e}`,{},e=>new p(e.data))}createPost(t,n={}){return this.post(`/internal/blog`,e.preparePostSaveData(t),e=>new p(e.data),n)}updatePost(t,n,r={}){return this.patch(`/internal/blog/${t}`,e.preparePostSaveData(n),e=>new p(e.data),r)}removePost(e){return this.delete(`/internal/blog/${e}`)}uploadMedia(e,t,n,r,i={}){return this.request({method:`POST`,url:`/internal/blog/${e}/media`,data:{file:t,isCover:n??!1},onUploadProgress:e=>{r&&r(e.total?Math.round(e.loaded/e.total*100):0)}},e=>new u(e.data),i)}updateMedia(e,t,n,r={}){return this.patch(`/internal/blog/${e}/media/${t}`,{isCover:n},e=>new u(e.data),r)}removeMedia(e,t){return this.delete(`/internal/blog/${e}/media/${t}`)}},h=class extends t.UpdatableNamedIdentity{deletedAt;constructor(e){super(e),this.deletedAt=t.DateHelper.parse(e?.deletedAt)}},g=class extends t.NamedIdentity{type;isActive;constructor(e){super(e),this.type=e?.type,this.isActive=e?.isActive??!0}},_=class extends h{costCoefficient;isLowPriceAllowed;publishedAt;description;percent;owner;constructor(e){super(e),this.costCoefficient=e?.costCoefficient??0,this.isLowPriceAllowed=e?.isLowPriceAllowed??!1,this.publishedAt=t.DateHelper.parse(e?.publishedAt),this.description=e?.description??void 0,this.percent=e?.percent??0,this.owner=new g(e?.owner)}},v=class extends t.UpdatableNamedIdentity{description;owner;constructor(e){super(e),this.description=e?.description??``,this.owner=e?.owner?new g(e.owner):void 0}},y=class{coefficient;value;cost;percent;readOnly;constructor(e){this.coefficient=new t.PriceCoefficient(e?.coefficient),this.value=e?.value??0,this.cost=e?.cost??0,this.percent=e?.percent??0,this.readOnly=e?.readOnly??!0}},re=class{warehouse;count;constructor(e){this.warehouse=new t.Warehouse(e?.warehouse),this.count=e?.count??0}},ie=class extends t.NamedIdentity{slug=``;description;isSquare=!1;isLinear=!1;constructor(e){super(e),e&&(this.slug=e.slug??``,this.description=e.description,this.isSquare=e.isSquare??!1,this.isLinear=e.isLinear??!1)}},b=class extends t.NamedIdentity{code=``;constructor(e){super(e),this.code=e?.code??``}},ae=class extends b{slug;type;constructor(e){super(e),this.slug=e?.slug??``}},oe=class extends ae{isHidden;constructor(e){super(e),this.isHidden=e?.isHidden??!1}},se=class{image;preview;isDefault;constructor(e,t){this.image=`${t??``}${e.image}`,this.preview=`${t??``}${e.preview}`,this.isDefault=e.isDefault}},x=class extends ae{isPrimary;constructor(e){super(e),this.isPrimary=e?.isPrimary??!1}},S=class extends oe{supplierSku;unit;pack;minCount;currency;cost;costRub;costDate;onOrder;stockCount;category;categories;images;properties;retailCost;retailCostRub;priceCoefficients;constructor(e){super(e),this.supplierSku=e?.supplierSku,this.unit=e?.unit?new ie(e.unit):new ie,this.pack=e?.pack,this.minCount=e?.minCount,this.currency=e?.currency?new t.Currency(e.currency):new t.Currency,this.cost=e?.cost??0,this.costRub=e?.costRub??0,this.costDate=(0,n.isString)(e?.costDate)?(0,r.parseISO)(e.costDate):e?.costDate,this.onOrder=e?.onOrder??!1,this.stockCount=e?.stockCount?.map(e=>new re(e))??[],this.type=`product`;let i=e?.category??e?.categories?.find(e=>e.isPrimary);i&&(this.category=new x({...i,isPrimary:!0}),this.categories=[this.category]),e?.categories&&(this.categories=e.categories.map(e=>new x(e))),this.images=e?.images?.map(e=>new se(e,(0,t.useBaseConfigStore)().config.http.mediaUrl))??[],this.properties=e?.properties??{},this.retailCost=e?.retailCost,this.retailCostRub=e?.retailCostRub,this.priceCoefficients=e?.priceCoefficients?.map(e=>new y(e))??[],e&&`codeNumber`in e&&!e.code&&(this.code=e?.codeNumber)}getIsMeasurable(){return this.unit.isLinear||this.unit.isSquare}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}},ce=function(e){return e.Discount=`discount`,e.PriceTemplate=`price_template`,e.ClientPrice=`client_price`,e.Product=`product`,e}({}),C=class extends S{costCoefficient;costSource;discount;priceTemplate;priceCoefficient;increasePercent;isPreviouslyOrdered;isRequired;isFavorite;constructor(e){super(e),this.costCoefficient=e?.costCoefficient??0,this.costSource=e?.costSource??ce.Product,this.discount=e?.discount?new _(e.discount):void 0,this.priceTemplate=e?.priceTemplate?new v(e.priceTemplate):void 0,this.priceCoefficient=e?.priceCoefficient?new t.PriceCoefficient(e.priceCoefficient):void 0,this.increasePercent=e?.increasePercent,this.isPreviouslyOrdered=e?.isPreviouslyOrdered,this.isRequired=e?.isRequired,this.isFavorite=e?.isFavorite}},w=class extends x{isHidden;parentCategoryId;properties;currencyRates;constructor(e){super(e),this.isHidden=e?.isHidden??!1,this.parentCategoryId=e?.parentCategoryId,this.properties=e?.properties,this.type=`category`,this.currencyRates=e?.currencyRates?Object.fromEntries(Object.entries(e.currencyRates).map(([e,t])=>[(0,n.toUpper)(e),t])):void 0}},le=class extends t.Identity{category;product;quantity;currency;marker;height;length;width;configurator;configuratorParams;isAdditionalSale;creator;isRemoved;ord;onOrder;originalId;replacementId;constructor(e){super(e),this.product=new C(e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new w,this.currency=e.currency?new t.Currency(e.currency):void 0,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&(0,n.cloneDeep)(e.configuratorParams),this.isAdditionalSale=e.isAdditionalSale,this.creator=e.creator&&new g(e.creator),this.isRemoved=e.isRemoved,this.ord=e.ord,this.onOrder=e.onOrder,this.originalId=e.originalId,this.replacementId=e.replacementId}},ue=class extends le{cost;costOne;costOneRub;costRub;logicGroupId;salesDirection;specificationImgUrl;sawing;currency;constructor(e){super(e),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=(0,n.isArray)(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,this.currency=new t.Currency(e.currency)}},T=class{items;resultSum;directionsSum;constructor(e){this.items=e.items.map(e=>new ue(e)),this.resultSum=e.resultSum,this.directionsSum=e.directionsSum}},de=class extends t.HttpRequester{getCart(e){return this.get(`internal/clients/${e.id}/cart`,{},e=>new T(e.data))}deleteCart(e){return this.delete(`internal/clients/${e.id}/cart`)}addCartItem(e,t,n={}){return this.patch(`internal/clients/${e.id}/cart`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new T(e.data),n)}patchCartItem(e,t,n={}){return this.patch(`internal/clients/${e.id}/cart/${t.id}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new T(e.data),n)}deleteCartItem(e,t){return this.delete(`internal/clients/${e.id}/cart/${t.id}`,e=>new T(e.data))}addCartItemFromCSV(e,t){return this.post(`internal/clients/${e.id}/cart/add-products-from-csv`,t,e=>new T(e.data))}getCartItemFromCSVExample(e){return this.get(`internal/clients/${e.id}/cart/add-products-from-csv/example`,{},e=>new Blob([e.data],{type:`text/csv`}))}},fe=function(e){return e.m2Cost=`m2Cost`,e.percent=`percent`,e.value=`value`,e}({}),pe=function(e){return e.Checkbox=`checkbox`,e.Range=`range`,e.Toggle=`toggle`,e}({}),E=class e extends w{categories;products;constructor(t){super(t),this.categories=t?.categories?.map(t=>new e(t)),this.products=t?.products?.map(e=>new S(e))}},me=class extends w{isDisabled;isRequired;isFavorite;hidingComment;manager;constructor(e){super(e),this.isDisabled=e?.isDisabled??!1,this.isRequired=e?.isRequired??!1,this.isFavorite=e?.isFavorite??!1,this.hidingComment=e?.hidingComment,this.manager=e?.manager?new t.Manager(e.manager):void 0}},he=class e extends me{categories;products;constructor(t){super(t),this.categories=t?.categories?.map(t=>new e(t)),this.products=t?.products?.map(e=>new C(e))}},ge=class{priceCoefficient;increasePercent;constructor(e){this.priceCoefficient=e?.priceCoefficient&&new t.PriceCoefficient(e.priceCoefficient),this.increasePercent=e?.increasePercent}},_e=class extends ge{constructor(e){super(e)}},D=class extends _e{productCategory;constructor(e){super(e),this.productCategory=new w(e?.productCategory)}},O=class extends t.NamedIdentity{photo;contacts;curatedDirection;constructor(e){super(e),this.photo=e.photo,this.contacts=new t.ContactLinks(e.contacts),this.curatedDirection=new t.CuratedDirection(e.curatedDirection)}},k=class extends t.UserCommonInfo{salesDirection;debt;alternativeName;city;comment;isPhoneApproved;isEmailApproved;managers;curators;constructor(e){super(e),this.salesDirection=new t.SalesDirection(e?.salesDirection),this.debt=e?.debt??0,this.alternativeName=e?.alternativeName??``,this.city=new t.CityWithRegionAndCountry(e?.city),this.comment=e?.comment,this.isPhoneApproved=e?.isPhoneApproved??!1,this.isEmailApproved=e?.isEmailApproved??!1,this.managers=e?.managers?.map(e=>new t.ManagerCommon(e))??[],this.curators=e?.curators?.map(e=>new O(e))??void 0}},ve=class extends f{deletedAt;constructor(e,n){super(e,n),this.deletedAt=t.DateHelper.parse(e?.deletedAt)}},A=class extends ve{client;priceTemplate;constructor(e){super(e),this.client=new k(e?.client),this.priceTemplate=new v(e?.priceTemplate)}},j=class extends _e{product;constructor(e){super(e),this.product=new S(e?.product)}},M=class extends t.NamedIdentity{type;description;metadata;isFilterable;constructor(e){super(e),this.type=new t.PropertyType(e?.type),this.description=e?.description??``,this.metadata=e?.metadata,this.isFilterable=e?.isFilterable}},N=class{property;value;constructor(e){this.property=new M(e?.property),this.value=e?.value??``}},ye=class{id;name;description;ownerName;createdAt=new m;updatedAt=new m;constructor(e){this.id=e?.id,this.name=e?.name,this.description=e?.description,this.ownerName=e?.ownerName,this.createdAt=new m(e?.createdAt),this.updatedAt=new m(e?.updatedAt)}resetFilterValue(e){switch(e){case`id`:case`name`:case`description`:case`ownerName`:this[e]=void 0;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`updatedAt`:this.updatedAt.from=null,this.updatedAt.to=null}return this}asClearRaw(){let e={};return Object.keys(this).forEach(t=>{let r=this[t];(0,n.isNil)(r)||(0,n.isString)(r)&&r.trim().length===0||(0,n.isFunction)(r.isNewRec)&&r.isNewRec()||(e[t]=r)}),!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,!e?.updatedAt?.from&&!e?.updatedAt?.to&&delete e.updatedAt,e}},be=class extends ge{executor;createdAt;constructor(e){super(e),this.executor=e?.executor?new g(e.executor):void 0,this.createdAt=t.DateHelper.parse(e?.createdAt)}},P=class extends be{product;constructor(e){super(e),this.product=new S(e?.product)}},xe=class extends be{productCategory;constructor(e){super(e),this.productCategory=new w(e?.productCategory)}},F=class extends t.NamedIdentity{description;canChangeLowCost;parentRoleId;subRoles=[];parentRole;level=0;constructor(e){super(e),this.description=e?.description,this.canChangeLowCost=e?.canChangeLowCost??!1,this.parentRoleId=e?.parentRoleId}},Se=class{role;category;minCoefficient;constructor(e){this.role=new F(e?.role),this.category=new w(e?.category),this.minCoefficient=new t.PriceCoefficient(e?.minCoefficient)}},Ce=class{isFake;isHidden;isMultiple;type;ord;constructor(e){this.isFake=e?.isFake??!1,this.isHidden=e?.isHidden??!1,this.isMultiple=e?.isMultiple??null,this.type=e?.type??null,this.ord=e?.ord??0}},we=class{category;property;settings;constructor(e){this.category=new w(e?.category),this.property=new M(e?.property),this.settings=new Ce(e?.settings)}},Te=class{id;label;constructor(e){this.id=e?.id??``,this.label=e?.label??``}},Ee=class{id;label;type;ord;isMultiple;values;min;max;constructor(e){this.id=e?.id??``,this.label=e?.label??``,this.type=e?.type??pe.Checkbox,this.ord=e?.ord??0,this.isMultiple=e?.isMultiple??null,this.values=e?.values?.map(e=>new Te(e))??[],this.min=e?.min??null,this.max=e?.max??null}},De=class extends t.HttpRequester{search(e,t=!1){return this.get(`/internal/catalog/search`,{term:e,show_hidden:t})}getPriceExportLink(e=`csv`,n=!1,r=void 0,i=void 0){let a=`${(0,t.useBaseConfigStore)().config.http.portalApiUrl}/api/internal/price/export?format=${e}&show_hidden=${n}`;return r&&(a+=`&category_id=${r}`),i&&(a+=`&client_id=${i}`),a}},Oe=class extends t.HttpRequester{importPrices(e,t,n=!1){return this.post(`/internal/clients/${e}/price/import`,t,void 0,{},n)}getCategoryPrices(e){return this.getTypedList(xe,`/internal/clients/${e}/price/categories`)}getCategoryPrice(e,t){return this.get(`/internal/clients/${e}/price/categories/${t}`,{},e=>new xe(e.data))}updateCategoryPrices(e,t,n,r=!1){return this.request({method:`PATCH`,url:`/internal/clients/${e}/price/categories/${t}`,data:{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},params:r?{recursively:!0}:{}})}removeCategoryPrices(e,t,n=!1){return this.request({method:`DELETE`,url:`/internal/clients/${e}/price/categories/${t}`,params:n?{recursively:!0}:{}})}removeCategoryProductsPrices(e,t,n=!1){return this.request({method:`DELETE`,url:`/internal/clients/${e}/price/categories/${t}/products`,params:n?{recursively:!0}:{}})}markCategoryRequired(e,t){return this.post(`/internal/clients/${e}/price/categories/${t}/required`)}unmarkCategoryRequired(e,t){return this.delete(`/internal/clients/${e}/price/categories/${t}/required`)}markCategoryDisabled(e,t,n){return this.post(`/internal/clients/${e}/price/categories/${t}/disabled`,{comment:n})}unmarkCategoryDisabled(e,t){return this.delete(`/internal/clients/${e}/price/categories/${t}/disabled`)}addCategoryManager(e,t,n){return this.post(`/internal/clients/${e}/price/categories/${t}/manager`,{manager_id:n})}removeCategoryManager(e,t){return this.delete(`/internal/clients/${e}/price/categories/${t}/manager`)}getProductPrices(e){return this.getTypedList(P,`/internal/clients/${e}/price/products`)}getProductPrice(e,t){return this.get(`/internal/clients/${e}/price/products/${t}`,{},e=>new P(e.data))}updateProductPrice(e,t,n){return this.patch(`/internal/clients/${e}/price/products/${t}`,{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},e=>new P(e.data))}removeProductPrice(e,t){return this.delete(`/internal/clients/${e}/price/products/${t}`)}markProductRequired(e,t){return this.post(`/internal/clients/${e}/price/products/${t}/required`)}unmarkProductRequired(e,t){return this.delete(`/internal/clients/${e}/price/products/${t}/required`)}getCommercialOfferHtml(e,t){return this.get(`/internal/clients/${e}/price/commercial-offer/view`,t,e=>new Blob([e.data],{type:`text/html`}))}getCommercialOfferPdf(e,t){return this.getBlob(`/internal/clients/${e}/price/commercial-offer/download`,t,e=>new Blob([e.request.response],{type:`application/pdf`}))}sendCommercialOffer(e,t){return this.post(`/internal/clients/${e}/price/commercial-offer/send`,t)}},ke=class extends t.HttpRequester{getTemplateList(e){return this.getTypedList(A,`/internal/clients/${e}/price/templates`)}getActiveTemplate(e){return this.get(`/internal/clients/${e}/price/templates/active`,{},e=>new A(e.data),!0)}attachTemplate(e,n,i){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.post(`/internal/clients/${e}/price/templates/${n}`,i&&{startAt:i.startAt&&(0,r.format)(i.startAt,a),endAt:i.endAt&&(0,r.format)(i.endAt,a)},e=>new A(e.data),{},!0)}applyTemplate(e,t){return this.post(`/internal/clients/${e}/price/templates/${t}/apply`,{},void 0,{},!0)}changeTemplate(e,n,i,a){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.patch(`/internal/clients/${e}/price/templates/${n}/${i}`,a&&{startAt:a.startAt&&(0,r.format)(a.startAt,o),endAt:a.endAt&&(0,r.format)(a.endAt,o)},e=>new A(e.data))}detachTemplate(e,t,n){return this.delete(`/internal/clients/${e}/price/templates/${t}/${n}`)}},Ae=class extends t.HttpRequester{getRootCategoriesList(e=!1){return this.getTypedList(E,`/internal/catalog/categories`,{showHidden:e})}getCategoryData(e,t=!1,n=!1){return this.get(`/internal/catalog/categories/${e}`,{showHidden:t,withNestedCategories:n},e=>new E(e.data))}getPublicCategoryData(e){return this.get(`/public/catalog/categories/${e}`,{},e=>new E(e.data))}getCategoryProductsList(e,t=!0,r=!1){return this.get(`/internal/catalog/categories/${e}/products`,{showHidden:r,withPriceCoefficients:t},e=>(0,n.map)(e.data,e=>new S(e)))}getCategoryProductsCoefficients(e){return this.get(`/internal/catalog/categories/${e}/products/coefficients`,{},e=>{let{data:t}=e;return(0,n.forEach)(t,e=>e.map(e=>new y(e))),t})}publicSimpleSearch(e,t=10){return new Promise((n,r)=>{this.get(`/public/catalog/search/simple?limit=${t}&term=${e}`).then(e=>{n(e.categories.map(e=>new E(e)))}).catch(e=>{r(e)})})}},je=class extends t.BasePaginationProvider{getProductData(e,t=!1){return this.get(`/internal/catalog/products/${e}`,{withPriceCoefficients:t},e=>new S(e.data))}getPublicProductData(e){return this.get(`/public/catalog/products/${e}`,{},e=>new S(e.data))}getProductPriceCoefficients(e){return this.get(`/internal/catalog/products/${e}/coefficients`,{},e=>(0,n.map)(e.data,e=>new y(e)))}getNewProducts(e,n,i=!0){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.getTypedPaginated(S,`/internal/catalog/products/new`,void 0,void 0,n,{period:{from:(0,r.format)(e,a)},withPriceCoefficients:i})}publicSimpleSearch(e,t=10){return new Promise((n,r)=>{this.get(`/public/catalog/search/simple?limit=${t}&term=${e}`).then(e=>{n(e.products.map(e=>new S(e)))}).catch(e=>{r(e)})})}},Me=class extends t.HttpRequester{getRootCategoriesList(e,t=!1){return this.getTypedList(he,`/internal/catalog/categories`,{clientId:e,showHidden:t})}getCategoryData(e,t,n=!1,r=!1){return this.get(`/internal/catalog/categories/${t}`,{clientId:e,showHidden:n,withNestedCategories:r},e=>new he(e.data))}getCategoryProductsList(e,t,r=!0,i=!1){return this.get(`/internal/catalog/categories/${t}/products`,{client_id:e,showHidden:i,withPriceCoefficients:r},e=>(0,n.map)(e.data,e=>new C(e)))}},Ne=class extends t.BasePaginationProvider{getProductData(e,t,n=!1){return this.get(`/internal/catalog/products/${e}`,{clientId:t,withPriceCoefficients:n},e=>new C(e.data))}getNewProducts(e,n,i,a=!0){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.getTypedPaginated(C,`/internal/catalog/products/new`,void 0,void 0,i,{clientId:e,period:{from:(0,r.format)(n,o)},withPriceCoefficients:a})}},Pe=class extends t.BasePaginationProvider{getTemplateList(e,t,n){return this.getTypedPaginated(v,`/internal/price/templates`,e,t,n)}createTemplate(e,t={}){return this.post(`/internal/price/templates`,e,e=>new v(e.data),t)}getTemplate(e){return this.get(`/internal/price/templates/${e}`,{},e=>new v(e.data))}updateTemplate(e,t,n={}){return this.patch(`/internal/price/templates/${e}`,t,e=>new v(e.data),n)}removeTemplate(e){return this.delete(`/internal/price/templates/${e}`)}getProductTemplatePrices(e){return this.getTypedList(j,`/internal/price/templates/${e}/products`)}getProductTemplatePrice(e,t){return this.get(`/internal/price/templates/${e}/products/${t}`,{},e=>new j(e.data))}saveProductTemplatePrice(e,t,n){return this.post(`/internal/price/templates/${e}/products/${t}`,{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},e=>new j(e.data))}deleteProductTemplatePrice(e,t){return this.delete(`/internal/price/templates/${e}/products/${t}`)}getCategoryTemplatePrices(e){return this.getTypedList(D,`/internal/price/templates/${e}/categories`)}getCategoryTemplatePrice(e,t){return this.get(`/internal/price/templates/${e}/categories/${t}`,{},e=>new D(e.data))}saveCategoryTemplatePrice(e,t,n,r=!1){return this.request({method:`POST`,url:`/internal/price/templates/${e}/categories/${t}`,data:{price_coefficient_id:n.coefficient?.id,increase_percent:n.value},params:r?{recursively:!0}:{}},e=>new D(e.data))}deleteCategoryTemplatePrice(e,t,n=!1){return this.request({method:`DELETE`,url:`/internal/price/templates/${e}/categories/${t}`,params:n?{recursively:!0}:{}})}getTemplateClients(e){return this.getTypedList(A,`/internal/price/templates/${e}/clients`)}},Fe=class extends t.HttpRequester{getRoles(){return this.getTypedList(F,`/internal/price/roles`)}createRole(e){return this.post(`/internal/price/roles`,e,e=>new F(e.data))}getRole(e){return this.get(`/internal/price/roles/${e}`,{},e=>new F(e.data))}updateRole(e,t){return this.patch(`/internal/price/roles/${e}`,t,e=>new F(e.data))}deleteRole(e){return this.delete(`/internal/price/roles/${e}`)}getCategoryRules(e){return this.getTypedList(Se,`/internal/price/roles/rules/categories/${e}`)}updateCategoryRules(e,n){return this.patch(`/internal/price/roles/rules/categories/${e}`,n,e=>t.TypedInstanceFactory.instanceListInitializer(Se,e.data))}},Ie=class extends t.BasePaginationProvider{getProperties(e,t,n){return this.getTypedPaginated(M,`/internal/catalog/properties`,e,t,n)}createProperty(e){let{typeId:t,...n}=e;return this.post(`/internal/catalog/properties`,{...n,type:t},e=>new M(e.data))}getProperty(e){return this.get(`/internal/catalog/properties/${e}`,{},e=>new M(e.data))}updateProperty(e,t){let{typeId:n,...r}=t;return this.patch(`/internal/catalog/properties/${e}`,{...r,type:n},e=>new M(e.data))}deleteProperty(e){return this.delete(`/internal/catalog/properties/${e}`)}getProductProperties(e){return this.getTypedList(N,`/internal/catalog/products/${e}/properties`)}getProductProperty(e,t){return this.get(`/internal/catalog/products/${e}/properties/${t}`,{},e=>new N(e.data))}updateProductProperty(e,t,n){return this.patch(`/internal/catalog/products/${e}/properties/${t}`,{value:n},e=>new N(e.data))}deleteProductProperty(e,t){return this.delete(`/internal/catalog/products/${e}/properties/${t}`)}getProductDescription(e){return this.get(`/internal/catalog/products/${e}/properties/description`)}updateProductDescription(e,t){return this.patch(`/internal/catalog/products/${e}/properties/description`,{text:t})}deleteProductDescription(e){return this.delete(`/internal/catalog/products/${e}/properties/description`)}getProductSpecification(e){return this.get(`/internal/catalog/products/${e}/properties/specification`)}updateProductSpecification(e,t){return this.patch(`/internal/catalog/products/${e}/properties/specification`,{text:t})}deleteProductSpecification(e){return this.delete(`/internal/catalog/products/${e}/properties/specification`)}getProductFiles(e){return this.get(`/internal/catalog/products/${e}/properties/files`)}addProductFile(e,t){return this.post(`/internal/catalog/products/${e}/properties/files`,t)}updateProductFile(e,t,n){return this.patch(`/internal/catalog/products/${e}/properties/files/${t}`,n)}deleteProductFile(e,t){return this.delete(`/internal/catalog/products/${e}/properties/files/${t}`)}updateProductSlug(e,t){return this.patch(`/internal/catalog/products/${e}/properties/slug`,{slug:t})}getCategoryProperties(e){return this.getTypedList(N,`/internal/catalog/categories/${e}/properties`)}getCategoryProperty(e,t){return this.get(`/internal/catalog/categories/${e}/properties/${t}`,{},e=>new N(e.data))}updateCategoryProperty(e,t,n){return this.patch(`/internal/catalog/categories/${e}/properties/${t}`,{value:n},e=>new N(e.data))}deleteCategoryProperty(e,t){return this.delete(`/internal/catalog/categories/${e}/properties/${t}`)}getCategoryDescription(e){return this.get(`/internal/catalog/categories/${e}/properties/description`)}updateCategoryDescription(e,t){return this.patch(`/internal/catalog/categories/${e}/properties/description`,{text:t})}deleteCategoryDescription(e){return this.delete(`/internal/catalog/categories/${e}/properties/description`)}getCategorySpecification(e){return this.get(`/internal/catalog/categories/${e}/properties/specification`)}updateCategorySpecification(e,t){return this.patch(`/internal/catalog/categories/${e}/properties/specification`,{text:t})}deleteCategorySpecification(e){return this.delete(`/internal/catalog/categories/${e}/properties/specification`)}getCategoryFiles(e){return this.get(`/internal/catalog/categories/${e}/properties/files`)}addCategoryFile(e,t){return this.post(`/internal/catalog/categories/${e}/properties/files`,t)}updateCategoryFile(e,t,n){return this.patch(`/internal/catalog/categories/${e}/properties/files/${t}`,n)}deleteCategoryFile(e,t){return this.delete(`/internal/catalog/categories/${e}/properties/files/${t}`)}updateCategorySlug(e,t){return this.patch(`/internal/catalog/categories/${e}/properties/slug`,{slug:t})}updateCategoryImage(e,t){return this.post(`/internal/catalog/categories/${e}/image`,{image:t})}getCategoryFilters(e,t=!1){return this.get(`/internal/catalog/categories/${e}/filters`,{recursively:t},e=>e.data.map(e=>new Ee(e)))}getCategoryFilterSettings(e){return this.getTypedList(we,`/internal/catalog/categories/${e}/filter-settings`)}saveCategoryFilterSetting(e,t,n){return this.patch(`/internal/catalog/categories/${e}/filter-settings/${t}`,n,e=>new we(e.data))}deleteCategoryFilterSetting(e,t){return this.delete(`/internal/catalog/categories/${e}/filter-settings/${t}`)}},Le=class extends t.HttpRequester{getRootCategoriesList(e,t=!1){return this.getTypedList(E,`/internal/catalog/categories`,{priceTemplateId:e,showHidden:t})}getCategoryData(e,t,n=!1,r=!1){return this.get(`/internal/catalog/categories/${t}`,{priceTemplateId:e,showHidden:n,withNestedCategories:r},e=>new E(e.data))}getCategoryProductsList(e,t,r=!0,i=!1){return this.get(`/internal/catalog/categories/${t}/products`,{priceTemplateId:e,showHidden:i,withPriceCoefficients:r},e=>(0,n.map)(e.data,e=>new S(e)))}};function Re(e,t,n){let r;return e.some(e=>{if(e.type===n&&e.id===t)return r=e,!0;if(e.type===`product`)return!1;let i=e;if(i.products&&i.products.length>0){let e=Re(i.products,t,n);if(e)return r=e,!0}if(i.categories&&i.categories.length>0){let e=Re(i.categories,t,n);if(e)return r=e,!0}return!1}),r}function ze(e){let t=[];return e.forEach(e=>{if(t.push(e),e.type===`category`){let n=e;n.products&&n.products.length>0&&t.push(...ze(n.products)),n.categories&&n.categories.length>0&&t.push(...ze(n.categories))}}),t}var Be=function(e){return e.LastOrder=`last_order`,e.Contacts=`contacts`,e.PartnerGroups=`partner_groups`,e.PreferredDeliveryType=`preferred_delivery_type`,e.SalesDirection=`sales_direction`,e.Managers=`managers`,e.Curators=`curators`,e}({}),I=class extends t.Identity{bankName=``;bic=``;accountNumber=``;correspondentAccount=``;currency=new t.Currency;constructor(e){super(e),e&&(this.bankName=e.bankName??``,this.bic=e.bic??``,this.accountNumber=e.accountNumber??``,this.correspondentAccount=e.correspondentAccount??``,this.currency=new t.Currency(e.currency))}},L=class extends h{phone;email;constructor(e){super(e),this.email=e?.email,this.phone=/^\d+$/.test(e?.phone??``)?`+${e?.phone}`:e?.phone}},R=class extends L{isPrimary;position;notDisturb;comment;constructor(e){super(e),this.isPrimary=e?.isPrimary??!1,this.position=e?.position,this.notDisturb=e?.notDisturb??!1,this.comment=e?.comment}},Ve=class extends h{opf=t.Opf.generatePersonItem();partnerGroup=new t.PartnerGroup;contacts=[];bankAccounts=[];comment;alternativeName;creator;updater;constructor(e){if(super(e),e){if(this.opf=new t.Opf(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.creator=e.creator?new g(e.creator):void 0,this.updater=e.updater?new g(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new t.PartnerGroup(e.partnerGroup)),e.contacts){let t=[];e.contacts.forEach(e=>{t.push(new R(e))}),this.contacts=t}if(e.bankAccounts){let t=[];e.bankAccounts.forEach(e=>{t.push(new I(e))}),this.bankAccounts=t}}}},He=class extends Ve{constructor(e){super(e)}},Ue=class extends Ve{inn=``;okpo=``;ogrn=``;directorName=``;directorPosition=``;directorActsOn=``;legalAddress=``;postalAddress=``;actualAddress=``;constructor(e){super(e),e&&(this.inn=e.inn??``,this.okpo=e.okpo??``,this.ogrn=e.ogrn??``,this.directorName=e.directorName??``,this.directorPosition=e.directorPosition??``,this.directorActsOn=e.directorActsOn??``,this.legalAddress=e.legalAddress??``,this.postalAddress=e.postalAddress??``,this.actualAddress=e.actualAddress??``)}},We=class extends Ue{kpp=``;constructor(e){super(e),e&&(this.kpp=e.kpp??``)}},Ge=class extends We{registrationCountry=new t.Country;registrationNumber=``;taxNumber=``;constructor(e){super(e),e&&(this.registrationCountry=new t.Country(e.registrationCountry),this.registrationNumber=e.registrationNumber??``,this.taxNumber=e.taxNumber??``)}},z=class{static createInstance(e){switch(e.opf.slug){case t.OpfEnum.Ic:return new Ue(e);case t.OpfEnum.UlR:return new We(e);case t.OpfEnum.UlNr:return new Ge(e);default:return new He(e)}}},Ke=class extends t.NamedIdentity{city;isActive;constructor(e){super(e),this.city=e?.city?new t.CityWithRegionAndCountry(e.city):void 0,this.isActive=e?.isActive??!1}},B=class extends h{address=``;coordinates;contacts;comment;operatingHours;isOneTime;isTransportCompanyAddress;constructor(e){super(e),this.address=e?.address??``,this.coordinates=new t.GeoCoordinates(e?.coordinates),this.contacts=e?.contacts?.map(e=>new R(e))??[],this.comment=e?.comment,this.operatingHours=e?.operatingHours,this.isOneTime=e?.isOneTime,this.isTransportCompanyAddress=e?.isTransportCompanyAddress}},qe=class extends k{contragents;partnerGroups;contacts;deliveryAddresses;channelPrimaryInterest;sourcePrimaryInterest;preferredDeliveryType;primaryDemand;preferredWarehouse;extraData;constructor(e){super(e),this.contragents=e?.contragents?.map(e=>z.createInstance(e))??[],this.partnerGroups=e?.partnerGroups?.map(e=>new t.PartnerGroup(e))??[],this.contacts=e?.contacts?.map(e=>new R(e))??[],this.deliveryAddresses=e?.deliveryAddresses?.map(e=>new B(e))??[],this.channelPrimaryInterest=new t.ChannelPrimaryInterest(e?.channelPrimaryInterest),this.sourcePrimaryInterest=new t.SourcePrimaryInterest(e?.sourcePrimaryInterest),this.preferredDeliveryType=new t.DeliveryType(e?.preferredDeliveryType),this.primaryDemand=e?.primaryDemand,this.preferredWarehouse=e?.preferredWarehouse?new t.Warehouse(e.preferredWarehouse):void 0,this.extraData=e?.extraData??{}}},Je=class extends o{id;guid;name;alternativeName;searchTerm;cities;region;country;phone;email;isActive;createdAt=new m;lastLoginDate=new m;lastLoginDateHasOrder;managers;includeSubordinateManagers;curators;isManagerRequired;salesDirections;contragentInn;contragentType;preferredDeliveryType;partnerGroups;contact;lastOrder;noOrdersPeriod=new m;constructor(e){super(),this.id=e?.id,this.guid=e?.guid,this.name=e?.name,this.alternativeName=e?.alternativeName,this.searchTerm=e?.searchTerm,this.cities=e?.cities?.map(e=>new t.CityWithRegionAndCountry(e)),this.region=new t.Region(e?.region),this.country=new t.Country(e?.country),this.phone=e?.phone,this.email=e?.email,this.isActive=e&&Object.prototype.hasOwnProperty.call(e,`isActive`)?e?.isActive:!0,this.createdAt=new m(e?.createdAt),this.lastLoginDate=new m(e?.lastLoginDate),this.lastLoginDateHasOrder=e?.lastLoginDateHasOrder??void 0,this.managers=e?.managers?.map(e=>new t.Manager(e))??[],this.includeSubordinateManagers=e?.includeSubordinateManagers??!0,this.curators=e?.curators?.map(e=>new O(e))??[],this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.contragentInn=e?.contragentInn,this.contragentType=new t.Opf(e?.contragentType),this.preferredDeliveryType=e?.preferredDeliveryType?new t.DeliveryType(e?.preferredDeliveryType):void 0,this.partnerGroups=e?.partnerGroups?.map(e=>new t.PartnerGroup(e)),this.contact=new L(e?.contact),this.lastOrder={createdAt:new m(e?.lastOrder?.createdAt),creator:e?.lastOrder?.creator,isApproved:e?.lastOrder?.isApproved},this.noOrdersPeriod=new m(e?.noOrdersPeriod)}resetFilterValue(e){switch(e){case`cities`:this.cities=[];break;case`region`:this.region=new t.Region;break;case`isActive`:this.isActive=!0;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`lastLoginDate`:this.lastLoginDate.from=null,this.lastLoginDate.to=null;break;case`noOrdersPeriod`:this.noOrdersPeriod.from=null,this.noOrdersPeriod.to=null;break;case`lastOrder`:this.lastOrder={};break;case`managers`:this.managers=[];break;case`curators`:this.curators=[];break;case`salesDirections`:this.salesDirections=[];break;case`contragentType`:this.contragentType=new t.Opf;break;case`preferredDeliveryType`:this.preferredDeliveryType=new t.DeliveryType;break;case`partnerGroups`:this.partnerGroups=[];break;case`contact`:this.contact=new L;break;default:this[e]=void 0}return this}asClearRaw(){let e=super.asClearRaw();return!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,!e?.lastLoginDate?.from&&!e?.lastLoginDate?.to&&delete e.lastLoginDate,!e?.noOrdersPeriod?.from&&!e?.noOrdersPeriod?.to&&delete e.noOrdersPeriod,e}},Ye=class extends f{creator;constructor(e){super(e),this.creator=new g(e?.creator)}},Xe=class extends t.NamedIdentity{contacts=[];preferredDeliveryType;partnerGroups=[];lastOrder;salesDirection;managers;curators;constructor(e){super(e),this.contacts=e.contacts?.map(e=>new R(e))??void 0,this.lastOrder=e.lastOrder?new Ye(e.lastOrder):void 0,this.partnerGroups=e.partnerGroups?.map(e=>new t.PartnerGroup(e))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new t.DeliveryType(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new t.SalesDirection(e.salesDirection):void 0,this.managers=e.managers?.map(e=>new t.ManagerCommon(e))??void 0,this.curators=e.curators?.map(e=>new O(e))??void 0}},V=class extends t.Identity{isPrimary;constructor(e){super(e),this.isPrimary=e.isPrimary}},Ze=class extends R{relations={clients:[],contragents:[],addresses:[]};constructor(e){super(e),e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(e=>new V(e))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(e=>new V(e))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(e=>new V(e))))}},Qe=class e extends t.BasePaginationProvider{static transformClientDataToRequest(e){return{name:e.name,alternative_name:e.alternativeName,partner_groups:e.partnerGroups.map(e=>e.id),phone:e.phone,email:e.email,city_id:e.city.id,get_news:e.getNews,channel_primary_interest_id:e.channelPrimaryInterest.id,source_primary_interest_id:e.sourcePrimaryInterest.id,primary_demand:e.primaryDemand,preferred_warehouse_id:e.preferredWarehouse?.id}}static transformContragentClientDataToRequest(e){let n,r=e,i=e,a=e;switch(e.opf.slug){case t.OpfEnum.Ic:n={opf:r.opf.slug,name:r.name,alternative_name:r.alternativeName,partner_group_id:r.partnerGroup?.id,comment:r.comment,inn:r.inn,okpo:r.okpo,ogrn:r.ogrn||void 0,director_name:r.directorName,director_position:r.directorPosition,director_acts_on:r.directorActsOn,legal_address:r.legalAddress,postal_address:r.postalAddress,actual_address:r.actualAddress};break;case t.OpfEnum.UlR:n={opf:i.opf.slug,name:i.name,alternative_name:i.alternativeName,partner_group_id:i.partnerGroup?.id,comment:i.comment,inn:i.inn,kpp:i.kpp,okpo:i.okpo,ogrn:i.ogrn||void 0,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 t.OpfEnum.UlNr:n={opf:a.opf.slug,name:a.name,alternative_name:a.alternativeName,partner_group_id:a.partnerGroup?.id,comment:a.comment,director_name:a.directorName,director_position:a.directorPosition,director_acts_on:a.directorActsOn,legal_address:a.legalAddress,postal_address:a.postalAddress,actual_address:a.actualAddress,registration_country_id:a.registrationCountry.id,registration_number:a.registrationNumber,tax_number:a.taxNumber||void 0};break;default:n={opf:e.opf.slug,name:e.name,alternative_name:e.alternativeName,partner_group_id:e.partnerGroup?.id,comment:e.comment}}return n}static transformClientDeliveryAddressToRequest(e){let t={address:e.address,is_one_time:e.isOneTime??!1,is_transport_company_address:e.isTransportCompanyAddress??!1,comment:e.comment??``};return e.coordinates&&(t.coordinates={lat:e.coordinates?.lat,long:e.coordinates?.long}),e.operatingHours&&(t.operating_hours={from:e.operatingHours.from,to:e.operatingHours.to}),t}static transformClientContragentBankAccountToRequest(e){return{bank_name:e.bankName,bic:e.bic,account_number:e.accountNumber,correspondent_account:e.correspondentAccount,currency_id:e.currency.id}}getClient(e){return this.get(`/internal/clients/${e}`,{},e=>new qe(e.data))}getClientsList(e,t,n,r,i){return this.getTypedPaginated(k,`/internal/clients`,e,t,n,r,void 0,i)}searchClient(e){return this.getClientsList(void 0,void 0,void 0,{searchTerm:e}).then(e=>e.data)}getClientByPhone(e){return this.getClientsList({groupOp:`and`,groups:[],filters:[{field:`phone`,op:t.FilterOpEnum.Contains,value:e}]})}getAdditionalClientsData(e,n){let r=e.map(e=>e.id);return this.post(`/internal/clients/additional-data`,{clients:r,requested_data_types:n},e=>t.TypedInstanceFactory.instanceListInitializer(Xe,e.data))}getAllClientContacts(e){return this.getTypedList(Ze,`/internal/clients/${e}/contacts/all`)}createClientCommonData(t,n={}){return this.post(`/internal/clients`,e.transformClientDataToRequest(t),e=>new qe(e.data),n)}updateClientCommonData(t,n={}){return this.patch(`/internal/clients/${t.id}`,e.transformClientDataToRequest(t),void 0,n)}updateClientNotDistribCommonData(e,t={}){let n={get_news:e.getNews};return this.patch(`/internal/clients/${e.id}`,n,void 0,t)}changeClientPassword(e,t,n,r={}){return this.patch(`/internal/clients/${e}`,{password:t,password_confirmation:n},void 0,r)}updateClientComment(e){return this.patch(`/internal/clients/${e.id}`,{comment:e.comment})}changeClientActivation(e){return this.patch(`/internal/clients/${e.id}`,{is_active:e.isActive})}async attachClientToManagers(e,t){let n=t.map(t=>this.patch(`/internal/clients/${e}/managers/${t.id}/attach`,{is_primary:t.isDefault}));await Promise.all(n)}async detachClientFromManagers(e,t){let n=t.map(t=>this.patch(`/internal/clients/${e}/managers/${t.id}/detach`));await Promise.all(n)}attachToCurator(e,t,n){return this.patch(`/internal/clients/${e}/curators/${t}/attach`,{curated_direction_id:n.id})}detachFromCurator(e,t,n){return this.patch(`/internal/clients/${e}/curators/${t}/detach`,{curated_direction_id:n.id})}setCurators(e,t){return this.patch(`/internal/clients/${e}/curators`,{curators:t.map(e=>({curator_id:e.curatorId,curated_direction_id:e.curatedDirection.id}))})}createContragentClientData(t,n,r={}){return this.post(`/internal/clients/${t}/contragents`,e.transformContragentClientDataToRequest(n),e=>z.createInstance(e.data),r)}updateContragentClientData(t,n,r={}){return this.patch(`/internal/clients/${t}/contragents/${n.id}`,e.transformContragentClientDataToRequest(n),e=>z.createInstance(e.data),r)}deleteClientContragent(e,t){return this.delete(`/internal/clients/${e}/contragents/${t.id}`)}getClientDeliveryAddresses(e){return this.getTypedList(B,`/internal/clients/${e}/delivery-addresses`)}createClientDeliveryAddress(t,n,r={}){return this.post(`/internal/clients/${t}/delivery-addresses`,e.transformClientDeliveryAddressToRequest(n),e=>new B(e.data),r)}updateClientDeliveryAddress(t,n,r={}){return this.patch(`/internal/clients/${t}/delivery-addresses/${n.id}`,e.transformClientDeliveryAddressToRequest(n),e=>new B(e.data),r)}deleteClientDeliveryAddress(e,t){return this.delete(`/internal/clients/${e}/delivery-addresses/${t.id}`)}createContragentBankAccount(t,n,r,i={}){return this.post(`/internal/clients/${t}/contragents/${n}/bank-accounts`,e.transformClientContragentBankAccountToRequest(r),e=>new I(e.data),i)}updateContragentBankAccount(t,n,r,i={}){return this.patch(`/internal/clients/${t}/contragents/${n}/bank-accounts/${r.id}`,e.transformClientContragentBankAccountToRequest(r),e=>new I(e.data),i)}deleteContragentBankAccount(e,t,n){return this.delete(`/internal/clients/${e}/contragents/${t}/bank-accounts/${n.id}`)}createClientContact(e,t,n={}){return this.createContact(e,t,{client:{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}},n)}updateClientContact(e,t,n={}){return this.patch(`/internal/clients/${e}/contacts/${t.id}`,{name:t.name,position:t.position,phone:t.phone,email:t.email,comment:t.comment,not_disturb:t.notDisturb},e=>new R(e.data),n)}setPrimaryClientContact(e,t){return this.setPrimaryContact(`/internal/clients/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachClientContact(e,t){return this.detachContact(`/internal/clients/${e}/contacts/${t.id}/detach`)}createContragentContact(e,t,n,r={}){return this.createContact(e,n,{contragents:[{id:t,is_primary:n.isPrimary??!1,not_disturb:n.notDisturb??!1}]},r)}setPrimaryContragentContact(e,t,n){return this.setPrimaryContact(`/internal/clients/${e}/contragents/${t}/contacts/${n.id}/primary`,n.isPrimary??!1)}detachContragentContact(e,t,n){return this.detachContact(`/internal/clients/${e}/contragents/${t}/contacts/${n.id}/detach`)}createDeliveryAddressContact(e,t,n,r={}){return this.createContact(e,n,{addresses:[{id:t,is_primary:n.isPrimary??!1,not_disturb:n.notDisturb??!1}]},r)}setPrimaryDeliveryAddressContact(e,t,n){return this.setPrimaryContact(`/internal/clients/${e}/delivery-addresses/${t}/contacts/${n.id}/primary`,n.isPrimary??!1)}detachDeliveryAddressContact(e,t,n){return this.detachContact(`/internal/clients/${e}/delivery-addresses/${t}/contacts/${n.id}/detach`)}createContact(e,t,n,r={}){let i={name:t.name,position:t.position,comment:t.comment,...n};return t.phone?.length&&(i.phone=t.phone),t.email?.length&&(i.email=t.email),this.post(`/internal/clients/${e}/contacts`,i,e=>new R(e.data),r)}setPrimaryContact(e,t){return this.patch(e,{is_primary:t})}detachContact(e){return this.patch(e)}sendClientEmailConfirmation(e){return this.get(`/internal/clients/${e.id}/verification/email?email=${e.email}`)}},$e=class extends t.HttpRequester{checkPhoneIsBusy(e){return new Promise((t,n)=>{this.request({method:`GET`,url:`/public/user/verification/phone/check`,params:{phone:e}}).then(e=>{t(!!e.isBusy)}).catch(n)})}},et=class{date;name;version;constructor(e){this.date=(0,n.isString)(e?.date)?(0,r.parseISO)(e.date):e?.date??new Date,this.name=e?.name??``,this.version=e?.version??`0.0.0`}},tt=function(e){return e.Kozyrek=`kozyrek`,e.Mosquitto=`mosquitto`,e.Strip=`strip`,e.MetalForDoors=`metal_for_doors`,e.Sandwich=`sandwich`,e.SandwichM2=`sandwich_m2`,e}({}),nt=class extends t.HttpRequester{getConfiguratorSettings(e,t){return this.get(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/settings?client_id=${t}`)}searchProduct(e,t,n,r={}){return this.request({method:`GET`,url:`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/product`,params:{params:n,client_id:t}},e=>new S(e.data),r)}createTemplate(e,t,n,r={}){return this.post(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/template?client_id=${t}`,{...n},()=>{},r)}removeTemplate(e,t,n){return this.delete(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/template/${n}?client_id=${t}`)}calculate(e,t,n){return this.get(`internal/catalog/categories/${e.id}/configurators/${e.properties?.configurator}/calculate`,{client_id:t,...n})}},rt=class{page=1;pageSize=50;constructor(e){this.page=e?.page??1,this.pageSize=e?.pageSize??50}},it=class extends rt{itemCount=0;pageCount=1;pageSlot=5;pageSizes=[25,50,100];showSizePicker=!0;constructor(e){super(e),this.itemCount=e?.itemCount??0,this.pageCount=e?.pageCount??1,this.pageSlot=e?.pageSlot??5,this.pageSizes=e?.pageSizes??[25,50,100],this.showSizePicker=e?.showSizePicker??!0}},at=class{field;direction;constructor(e){this.field=e?.field??``,this.direction=e?.direction??`asc`}},H=class e{static decadeInterval(t){let[n,r]=e.shiftedDecadeBounds(t,0);return{from:n,to:r}}static shiftDecadeInterval(t,n){let[r,i]=e.shiftedDecadeBounds(t,n);return{from:r,to:i}}static startOfHalfYear(e){return new Date(e.getFullYear(),e.getMonth()<6?0:6,1)}static endOfHalfYear(e){return(0,r.endOfMonth)(new Date(e.getFullYear(),e.getMonth()<6?5:11,1))}static addHalfYears(e,t){return(0,r.addMonths)(e,t*6)}static intervalTillSameDate(e,t,n){let i=(0,r.differenceInCalendarMonths)((0,r.startOfMonth)(n),(0,r.startOfMonth)(e)),a=(0,r.startOfMonth)((0,r.addMonths)(t,i)),o=Math.min((0,r.getDate)(n),(0,r.getDaysInMonth)(a));return{from:(0,r.startOfDay)(t),to:(0,r.endOfDay)((0,r.setDate)(a,o))}}static weekTillSameWeekday(e,t){let n=(0,r.startOfWeek)((0,r.addWeeks)(e,t),{weekStartsOn:1}),i=(0,r.differenceInCalendarDays)(e,(0,r.startOfWeek)(e,{weekStartsOn:1}));return{from:n,to:(0,r.endOfDay)((0,r.addDays)(n,i))}}static decadeTillSameDayNumber(t,n){let[i]=e.shiftedDecadeBounds(t,0),a=(0,r.differenceInCalendarDays)(t,i)+1,[o,s]=e.shiftedDecadeBounds(t,n),c=(0,r.differenceInCalendarDays)(s,o)+1;return{from:o,to:(0,r.endOfDay)((0,r.addDays)(o,Math.min(a,c)-1))}}static shiftedDecadeBounds(e,t){let n=(0,r.getDate)(e),i=2;n<=10?i=0:n<=20&&(i=1);let a=i+t,o=Math.floor(a/3),s=(a%3+3)%3,c=(0,r.startOfMonth)((0,r.addMonths)(e,o)),l=(0,r.addDays)(c,s*10);return[l,s===2?(0,r.endOfMonth)(c):(0,r.endOfDay)((0,r.addDays)(l,9))]}};function ot(e){return(0,r.format)((0,r.subDays)((0,r.startOfToday)(),e),`yyyy-MM-dd`)}function st(e,t){let n=[2,0,1,1,1,2],r=Math.floor(Math.abs(e));return t[r%100>4&&r%100<20?2:n[Math.min(r%10,5)]]}function ct(e){let t=(0,r.parseISO)(e),n=(0,r.differenceInCalendarDays)((0,r.startOfToday)(),t);switch(!0){case n===0:return`Сегодня`;case n===1:return`Вчера`;case n<0:return e;default:return`${n} ${st(n,[`день`,`дня`,`дней`])} назад`}}var lt=class{static defaultDateRanges(e){let t=(0,r.addBusinessDays)(new Date,1),n=new Date,i=(0,r.startOfYear)(e===void 0?n:new Date(e,0,1)),a=(0,r.endOfYear)(i);return{nextWorkingDay:{label:`Следующий рабочий день`,from:(0,r.startOfDay)(t),to:(0,r.endOfDay)(t)},today:{label:`Сегодня`,from:(0,r.startOfToday)(),to:(0,r.endOfToday)()},yesterday:{label:`Вчера`,from:(0,r.startOfYesterday)(),to:(0,r.endOfYesterday)()},tomorrow:{label:`Завтра`,from:(0,r.startOfTomorrow)(),to:(0,r.endOfTomorrow)()},currentWeek:{label:`Неделя`,from:(0,r.startOfWeek)(n,{weekStartsOn:1}),to:(0,r.endOfWeek)(n,{weekStartsOn:1})},currentMonth:{label:`Месяц`,from:(0,r.startOfMonth)(n),to:(0,r.endOfMonth)(n)},oneMonth:{label:`1 месяц`,from:i,to:(0,r.endOfMonth)(i)},threeMonths:{label:`3 месяца`,from:i,to:(0,r.endOfMonth)((0,r.addMonths)(i,2))},nineMonths:{label:`9 месяцев`,from:i,to:(0,r.endOfMonth)((0,r.addMonths)(i,8))},firstQuarter:{label:`I квартал`,from:i,to:(0,r.endOfMonth)((0,r.addMonths)(i,2))},secondQuarter:{label:`II квартал`,from:(0,r.addMonths)(i,3),to:(0,r.endOfMonth)((0,r.addMonths)(i,5))},thirdQuarter:{label:`III квартал`,from:(0,r.addMonths)(i,6),to:(0,r.endOfMonth)((0,r.addMonths)(i,8))},fourthQuarter:{label:`IV квартал`,from:(0,r.addMonths)(i,9),to:(0,r.endOfMonth)((0,r.addMonths)(i,11))},firstHalfYear:{label:`I полугодие`,from:i,to:(0,r.endOfMonth)((0,r.addMonths)(i,5))},secondHalfYear:{label:`II полугодие`,from:(0,r.addMonths)(i,6),to:a},currentYear:{label:`12 месяцев`,from:i,to:a}}}static standardPeriods(e=new Date){let t={weekStartsOn:1},n=(0,r.startOfDay)(e),i=(0,r.endOfDay)(e),a=H.decadeInterval(e),o=(0,r.startOfMonth)(e),s=(0,r.startOfQuarter)(e),c=H.startOfHalfYear(e),l=(0,r.startOfYear)(e),u=H.addHalfYears(e,-1),d=H.addHalfYears(e,1);return{yesterday:{label:`Вчера`,group:`day`,from:(0,r.startOfDay)((0,r.subDays)(e,1)),to:(0,r.endOfDay)((0,r.subDays)(e,1))},today:{label:`Сегодня`,group:`day`,from:n,to:i},tomorrow:{label:`Завтра`,group:`day`,from:(0,r.startOfDay)((0,r.addDays)(e,1)),to:(0,r.endOfDay)((0,r.addDays)(e,1))},lastWeek:{label:`Прошлая неделя`,group:`week`,from:(0,r.startOfWeek)((0,r.subWeeks)(e,1),t),to:(0,r.endOfWeek)((0,r.subWeeks)(e,1),t)},thisWeek:{label:`Эта неделя`,group:`week`,from:(0,r.startOfWeek)(e,t),to:(0,r.endOfWeek)(e,t)},nextWeek:{label:`Следующая неделя`,group:`week`,from:(0,r.startOfWeek)((0,r.addWeeks)(e,1),t),to:(0,r.endOfWeek)((0,r.addWeeks)(e,1),t)},lastTenDays:{label:`Прошлая декада`,group:`decade`,...H.shiftDecadeInterval(e,-1)},thisTenDays:{label:`Эта декада`,group:`decade`,...a},nextTenDays:{label:`Следующая декада`,group:`decade`,...H.shiftDecadeInterval(e,1)},lastMonth:{label:`Прошлый месяц`,group:`month`,from:(0,r.startOfMonth)((0,r.subMonths)(e,1)),to:(0,r.endOfMonth)((0,r.subMonths)(e,1))},thisMonth:{label:`Этот месяц`,group:`month`,from:o,to:(0,r.endOfMonth)(e)},nextMonth:{label:`Следующий месяц`,group:`month`,from:(0,r.startOfMonth)((0,r.addMonths)(e,1)),to:(0,r.endOfMonth)((0,r.addMonths)(e,1))},lastQuarter:{label:`Прошлый квартал`,group:`quarter`,from:(0,r.startOfQuarter)((0,r.subQuarters)(e,1)),to:(0,r.endOfQuarter)((0,r.subQuarters)(e,1))},thisQuarter:{label:`Этот квартал`,group:`quarter`,from:s,to:(0,r.endOfQuarter)(e)},nextQuarter:{label:`Следующий квартал`,group:`quarter`,from:(0,r.startOfQuarter)((0,r.addQuarters)(e,1)),to:(0,r.endOfQuarter)((0,r.addQuarters)(e,1))},lastHalfYear:{label:`Прошлое полугодие`,group:`halfYear`,from:H.startOfHalfYear(u),to:H.endOfHalfYear(u)},thisHalfYear:{label:`Это полугодие`,group:`halfYear`,from:c,to:H.endOfHalfYear(e)},nextHalfYear:{label:`Следующее полугодие`,group:`halfYear`,from:H.startOfHalfYear(d),to:H.endOfHalfYear(d)},lastYear:{label:`Прошлый год`,group:`year`,from:(0,r.startOfYear)((0,r.subYears)(e,1)),to:(0,r.endOfYear)((0,r.subYears)(e,1))},thisYear:{label:`Этот год`,group:`year`,from:l,to:(0,r.endOfYear)(e)},nextYear:{label:`Следующий год`,group:`year`,from:(0,r.startOfYear)((0,r.addYears)(e,1)),to:(0,r.endOfYear)((0,r.addYears)(e,1))},fromBeginningOfThisWeek:{label:`С начала этой недели`,group:`other`,section:`fromBeginning`,from:(0,r.startOfWeek)(e,t),to:i},fromBeginningOfThisTenDays:{label:`С начала этой декады`,group:`other`,section:`fromBeginning`,from:a.from,to:i},fromBeginningOfThisMonth:{label:`С начала этого месяца`,group:`other`,section:`fromBeginning`,from:o,to:i},fromBeginningOfThisQuarter:{label:`С начала этого квартала`,group:`other`,section:`fromBeginning`,from:s,to:i},fromBeginningOfThisHalfYear:{label:`С начала этого полугодия`,group:`other`,section:`fromBeginning`,from:c,to:i},fromBeginningOfThisYear:{label:`С начала этого года`,group:`other`,section:`fromBeginning`,from:l,to:i},tillEndOfThisWeek:{label:`До конца этой недели`,group:`other`,section:`tillEnd`,from:n,to:(0,r.endOfWeek)(e,t)},tillEndOfThisTenDays:{label:`До конца этой декады`,group:`other`,section:`tillEnd`,from:n,to:a.to},tillEndOfThisMonth:{label:`До конца этого месяца`,group:`other`,section:`tillEnd`,from:n,to:(0,r.endOfMonth)(e)},tillEndOfThisQuarter:{label:`До конца этого квартала`,group:`other`,section:`tillEnd`,from:n,to:(0,r.endOfQuarter)(e)},tillEndOfThisHalfYear:{label:`До конца этого полугодия`,group:`other`,section:`tillEnd`,from:n,to:H.endOfHalfYear(e)},tillEndOfThisYear:{label:`До конца этого года`,group:`other`,section:`tillEnd`,from:n,to:(0,r.endOfYear)(e)},lastWeekTillSameWeekDay:{label:`Прошлая неделя, до такого же дня недели`,group:`other`,section:`lastTillSame`,...H.weekTillSameWeekday(e,-1)},lastTenDaysTillSameDayNumber:{label:`Прошлая декада, до такого же номера дня`,group:`other`,section:`lastTillSame`,...H.decadeTillSameDayNumber(e,-1)},lastMonthTillSameDate:{label:`Прошлый месяц, до такой же даты`,group:`other`,section:`lastTillSame`,...H.intervalTillSameDate(o,(0,r.startOfMonth)((0,r.subMonths)(e,1)),e)},lastQuarterTillSameDate:{label:`Прошлый квартал, до такой же даты`,group:`other`,section:`lastTillSame`,...H.intervalTillSameDate(s,(0,r.startOfQuarter)((0,r.subQuarters)(e,1)),e)},lastHalfYearTillSameDate:{label:`Прошлое полугодие, до такой же даты`,group:`other`,section:`lastTillSame`,...H.intervalTillSameDate(c,H.startOfHalfYear(u),e)},lastYearTillSameDate:{label:`Прошлый год, до такой же даты`,group:`other`,section:`lastTillSame`,...H.intervalTillSameDate(l,(0,r.startOfYear)((0,r.subYears)(e,1)),e)},nextWeekTillSameWeekDay:{label:`Следующая неделя, до такого же дня недели`,group:`other`,section:`nextTillSame`,...H.weekTillSameWeekday(e,1)},nextTenDaysTillSameDayNumber:{label:`Следующая декада, до такого же номера дня`,group:`other`,section:`nextTillSame`,...H.decadeTillSameDayNumber(e,1)},nextMonthTillSameDate:{label:`Следующий месяц, до такой же даты`,group:`other`,section:`nextTillSame`,...H.intervalTillSameDate(o,(0,r.startOfMonth)((0,r.addMonths)(e,1)),e)},nextQuarterTillSameDate:{label:`Следующий квартал, до такой же даты`,group:`other`,section:`nextTillSame`,...H.intervalTillSameDate(s,(0,r.startOfQuarter)((0,r.addQuarters)(e,1)),e)},nextHalfYearTillSameDate:{label:`Следующее полугодие, до такой же даты`,group:`other`,section:`nextTillSame`,...H.intervalTillSameDate(c,H.startOfHalfYear(d),e)},nextYearTillSameDate:{label:`Следующий год, до такой же даты`,group:`other`,section:`nextTillSame`,...H.intervalTillSameDate(l,(0,r.startOfYear)((0,r.addYears)(e,1)),e)},last7Days:{label:`Последние 7 дней`,group:`other`,section:`rollingDays`,from:(0,r.startOfDay)((0,r.subDays)(e,6)),to:i},next7Days:{label:`Следующие 7 дней`,group:`other`,section:`rollingDays`,from:n,to:(0,r.endOfDay)((0,r.addDays)(e,6))}}}},ut=[{key:`day`,label:`День`},{key:`week`,label:`Неделя`},{key:`decade`,label:`Декада`},{key:`month`,label:`Месяц`},{key:`quarter`,label:`Квартал`},{key:`halfYear`,label:`Полугодие`},{key:`year`,label:`Год`},{key:`other`,label:`Прочее`}],dt=[{key:`fromBeginning`,label:`С начала периода`},{key:`tillEnd`,label:`До конца периода`},{key:`lastTillSame`,label:`Прошлые, до такой же даты`},{key:`nextTillSame`,label:`Следующие, до такой же даты`},{key:`rollingDays`,label:`7 дней`}],U=class extends Ke{},ft=class{salesDirections;partnerGroups;managers;additionalClients;fixedClients;regions;cities;lastLoginDate;lastOrderDate;constructor(e){this.salesDirections=(0,n.map)(e?.salesDirections??[],e=>new t.SalesDirection(e)),this.partnerGroups=(0,n.map)(e?.partnerGroups??[],e=>new t.PartnerGroup(e)),this.managers=(0,n.map)(e?.managers??[],e=>new g(e)),this.additionalClients=(0,n.map)(e?.additionalClients??[],e=>new U(e)),this.fixedClients=(0,n.map)(e?.fixedClients??[],e=>new U(e)),this.regions=(0,n.map)(e?.regions??[],e=>new t.Region(e)),this.cities=(0,n.map)(e?.cities??[],e=>new t.CityWithRegionAndCountry(e)),this.lastLoginDate=new m(e?.lastLoginDate),this.lastOrderDate=new m(e?.lastOrderDate)}hasClientConditions(){return(0,n.some)([this.salesDirections,this.partnerGroups,this.managers,this.additionalClients,this.fixedClients,this.regions,this.cities],e=>!(0,n.isEmpty)(e))||(0,n.some)([this.lastLoginDate,this.lastOrderDate],e=>!!e.from||!!e.to)}setPeriod(e,t){return this[e]=new m({from:t?.from?(0,r.startOfDay)(t.from):null,to:t?.to?(0,r.endOfDay)(t.to):null}),this}toSaveData(){return{salesDirections:(0,n.map)(this.salesDirections,`id`),partnerGroups:(0,n.map)(this.partnerGroups,`id`),managers:(0,n.map)(this.managers,`id`),additionalClients:(0,n.map)(this.additionalClients,`id`),regions:(0,n.map)(this.regions,`id`),cities:(0,n.map)(this.cities,`id`),lastLoginDate:new m(this.lastLoginDate),lastOrderDate:new m(this.lastOrderDate)}}},W=function(e){return e.Active=`active`,e.Scheduled=`scheduled`,e.Completed=`completed`,e}({}),pt=class{static resolve(e,t=new Date){return e.deletedAt&&e.deletedAt.getTime()<=t.getTime()?W.Completed:e.publishedAt&&e.publishedAt.getTime()>t.getTime()?W.Scheduled:W.Active}},G=class extends _{conditions;products;productCategories;countDiscountedPrices;expectedCountDiscountedPrices;countDiscountedProducts;countDiscountedClients;constructor(e){super(e),this.conditions=new ft(e?.conditions),this.products=(0,n.map)(e?.products??[],e=>new S(e)),this.productCategories=(0,n.map)(e?.productCategories??[],e=>new E(e)),this.countDiscountedPrices=e?.countDiscountedPrices??0,this.expectedCountDiscountedPrices=e?.expectedCountDiscountedPrices??0,this.countDiscountedProducts=e?.countDiscountedProducts??0,this.countDiscountedClients=e?.countDiscountedClients??0}getState(e=new Date){return pt.resolve(this,e)}assignCounters(e){this.countDiscountedPrices=e.countDiscountedPrices,this.expectedCountDiscountedPrices=e.expectedCountDiscountedPrices,this.countDiscountedProducts=e.countDiscountedProducts,this.countDiscountedClients=e.countDiscountedClients}isPricesUpdating(){return this.countDiscountedPrices!==this.expectedCountDiscountedPrices}toSaveData(){return{name:this.name,percent:this.percent,isLowPriceAllowed:this.isLowPriceAllowed,publishedAt:this.publishedAt??null,deletedAt:this.deletedAt??null,description:this.description??``,products:(0,n.map)(this.products,`id`),productCategories:(0,n.map)(this.productCategories,`id`),conditions:this.conditions.toSaveData()}}},mt=class{client;additionalClientsCondition;fixedClientsCondition;partnerGroupsCondition;managersCondition;citiesCondition;regionsCondition;salesDirectionsCondition;constructor(e){this.client=new U(e?.client),this.additionalClientsCondition=e?.additionalClientsCondition??!1,this.fixedClientsCondition=e?.fixedClientsCondition??!1,this.partnerGroupsCondition=e?.partnerGroupsCondition??!1,this.managersCondition=e?.managersCondition??!1,this.citiesCondition=e?.citiesCondition??!1,this.regionsCondition=e?.regionsCondition??!1,this.salesDirectionsCondition=e?.salesDirectionsCondition??!1}isEligible(){return this.additionalClientsCondition||this.fixedClientsCondition||this.partnerGroupsCondition||this.managersCondition||this.citiesCondition||this.regionsCondition||this.salesDirectionsCondition}},ht=class extends o{id;name;states;constructor(e){super(),this.id=e?.id,this.name=e?.name,this.states=e?.states}resetFilterValue(e){switch(e){case`id`:case`name`:case`states`:this[e]=void 0}return this}},gt=class e extends t.BasePaginationProvider{static prepareSaveData(e,n){return{...e,publishedAt:t.DateHelper.toApiFormat(e.publishedAt),deletedAt:t.DateHelper.toApiFormat(e.deletedAt),conditions:{...e.conditions,lastLoginDate:t.DateHelper.periodToApiFormat(e.conditions.lastLoginDate),lastOrderDate:t.DateHelper.periodToApiFormat(e.conditions.lastOrderDate),updateFixedClients:n}}}getDiscountsList(e,t,n,r){return this.getTypedPaginated(_,`/internal/price/discounts`,e,t,n,{},void 0,r)}getDiscount(e){return this.get(`/internal/price/discounts/${e}`,{},e=>new G(e.data))}createDiscount(t,n,r={}){return this.post(`/internal/price/discounts`,e.prepareSaveData(t,n),e=>new G(e.data),r)}updateDiscount(t,n,r,i={}){return this.patch(`/internal/price/discounts/${t}`,e.prepareSaveData(n,r),e=>new G(e.data),i)}removeDiscount(e){return this.delete(`/internal/price/discounts/${e}`)}getEligibleClients(e){return this.getTypedList(mt,`/internal/price/discounts/${e}/clients`)}checkClient(e,t){return this.get(`/internal/price/discounts/${e}/clients/${t}/check`,{},e=>new mt(e.data))}},K=class extends t.User{showAllCosts;constructor(e){super(e),this.showAllCosts=e?.showAllCosts}},_t=class extends o{name;phone;email;isActive;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.isActive=e?.isActive}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`isActive`:this[e]=void 0}return this}},vt=class e extends t.BasePaginationProvider{static transformExternalSeoDataToRequest(e){return{name:e.name,phone:e.phone,email:e.email,password:e.password,isActive:e.isActive,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1}}getExternalSeoList(e,n,r,i){return this.getTypedPaginated(t.User,`/internal/external-seo`,e,n,r,{},void 0,i)}getExternalSeo(e,t=!1){return this.get(`/internal/external-seo/${e}`,{},e=>new K(e.data),t)}createExternalSeo(t,n={}){return this.post(`/internal/external-seo`,e.transformExternalSeoDataToRequest(t),e=>new K(e.data),n)}updateExternalSeo(t,n={}){return this.patch(`/internal/external-seo/${t.id}`,e.transformExternalSeoDataToRequest(t),e=>new K(e.data),n)}deleteExternalSeo(e){return this.delete(`/internal/external-seo/${e}`)}},q=class extends t.NamedIdentity{constructor(e){super(e)}},J=class extends t.Identity{question;answer;groups;constructor(e){super(e,-1),this.question=e?.question??``,this.answer=e?.answer??``,this.groups=(0,n.map)(e?.groups??[],e=>new q(e))}toSaveData(){return{question:this.question,answer:this.answer,groups:(0,n.map)(this.groups,`id`)}}},yt=class extends t.BasePaginationProvider{getFaqList(e,t){return this.getTypedPaginated(J,`/internal/faq`,void 0,void 0,t,(0,n.isNil)(e)?{}:{group:e})}getFaq(e){return this.get(`/internal/faq/${e}`,{},e=>new J(e.data))}createFaq(e,t={}){return this.post(`/internal/faq`,e,e=>new J(e.data),t)}updateFaq(e,t,n={}){return this.patch(`/internal/faq/${e}`,t,e=>new J(e.data),n)}removeFaq(e){return this.delete(`/internal/faq/${e}`)}getGroupsList(){return this.getTypedList(q,`/internal/faq/groups`)}createGroup(e,t={}){return this.post(`/internal/faq/groups`,e,e=>new q(e.data),t)}updateGroup(e,t,n={}){return this.patch(`/internal/faq/groups/${e}`,t,e=>new q(e.data),n)}removeGroup(e){return this.delete(`/internal/faq/groups/${e}`)}};function bt(e){let t=(0,n.round)(e*100);return`${t>=0?`+`:``}${t}%`}var xt=class e{static productIsMeasurable(e){return e.unit.isLinear||e.unit.isSquare}static getProductMultiplicity(t){return!t.properties?.ignoreMinCountCheck&&t.properties?.minCount!=null&&!e.productIsMeasurable(t)?t.properties.minCount:1}static getProductLengthMultiplicity(e){return e.properties?.lengthStep==null?!e.properties?.ignoreMinCountCheck&&e.properties?.minCount!=null?e.properties.minCount:.01:e.properties.lengthStep}},St=class{static generateUndefinedManagerInstance(){return new t.Manager({id:0,name:`- Не назначен -`,isActive:!0,guid:`-undefined-`})}static isUndefinedManagerInstance(e){return e.id===0&&e.guid===`-undefined-`}},Ct=class extends o{name;phone;email;salesDirections;isActive;isSupervisor;canDoReclamations;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.isActive=e?.isActive,this.isSupervisor=e?.isSupervisor,this.canDoReclamations=e?.canDoReclamations}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`salesDirections`:case`isActive`:case`isSupervisor`:case`canDoReclamations`:this[e]=void 0}return this}},wt=class e extends t.ManagerDataProvider{static transformManagerDataToRequest(e){return{name:e.name,phone:e.contacts?.phone??``,email:e.contacts?.email??``,password:e.password,isActive:e.isActive,isSupervisor:e.isSupervisor,canDoReclamations:e.canDoReclamations,authAsOperator:e.authAsOperator??!1,salesDirectionId:e.salesDirection.id,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1,storeIds:(0,n.map)(e.stores,`id`),curatedDirectionIds:(0,n.map)(e.curatedDirections,`id`),managerRegionIds:(0,n.map)(e.managerRegions,`id`),managerIds:(0,n.map)(e.managers,`id`),photo:e.photoFile}}getManagersList(e,n,r,i){return this.getTypedPaginated(t.Manager,`/internal/managers`,e,n,r,{},void 0,i)}createManager(n,r={}){return this.post(`/internal/managers`,e.transformManagerDataToRequest(n),e=>new t.Manager(e.data),r)}updateManager(n,r={}){return this.patch(`/internal/managers/${n.id}`,e.transformManagerDataToRequest(n),e=>new t.Manager(e.data),r)}getManagerRegionsList(e,n,r){return this.getTypedPaginated(t.UserRegionShortInfo,`/internal/managers/regions`,e,n,r)}},Y=function(e){return e.Processing=`processing`,e.Completed=`completed`,e.Error=`error`,e.NeedsActualization=`needs_actualization`,e}({}),Tt=class{status;actualizedAt;expiresAt;error;constructor(e){this.status=e?.status??Y.Processing,this.actualizedAt=t.DateHelper.parse(e?.actualizedAt),this.expiresAt=t.DateHelper.parse(e?.expiresAt),this.error=e?.error}get isProcessing(){return this.status===Y.Processing}get isOutdated(){return this.isOutdatedAt(new Date)}get isOrderAllowed(){return this.isOrderAllowedAt(new Date)}isOutdatedAt(e){return this.status!==Y.Completed||(0,n.isNil)(this.actualizedAt)?!0:!(0,n.isNil)(this.expiresAt)&&this.expiresAt.getTime()<e.getTime()}isOrderAllowedAt(e){return this.status===Y.Completed&&!this.isOutdatedAt(e)}},Et=class extends f{name;client;sum;isProfstroy;actualization;file;constructor(e){super(e),this.name=e?.name,this.client=new k(e?.client),this.sum=e?.sum,this.isProfstroy=e?.isProfstroy,this.actualization=e?.actualization&&new Tt(e.actualization),this.file=e?.file}},Dt=class extends ue{groupName;supplierSku;isIgnored;lineError;constructor(e){super(e),this.groupName=e.groupName,this.supplierSku=e.supplierSku??e.product.supplierSku,this.isIgnored=e.isIgnored,this.lineError=e.lineError}get isProductStub(){return(0,n.isNil)(this.product.id)}get isOrderable(){return!this.isProductStub&&!this.isIgnored&&(0,n.isEmpty)(this.lineError)}},X=class extends Et{sum;products;constructor(e){super(e),this.sum=e.sum??0,this.products=(e.products??[]).map(t=>e.isProfstroy?new Dt(t):new ue(t))}},Ot=class extends o{id;clientSearchTerm;name;createdAt=new m;constructor(e){super(),this.id=e?.id,this.clientSearchTerm=e?.clientSearchTerm,this.name=e?.name,this.createdAt=new m(e?.createdAt)}resetFilterValue(e){return e===`createdAt`?(this.createdAt.from=null,this.createdAt.to=null):this[e]=void 0,this}asClearRaw(){let e=super.asClearRaw();return!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,e}},kt=class extends Ye{client;payment;delivery;attachedUser;status;statusDetail;salesDirection;attachedAt;isOnOrder;isProfstroy;isNotInStock;sum;isLargeOrder;constructor(e){super(e),this.client=new k(e?.client),this.payment={type:e?.payment?.type??-1,status:e?.payment?.status??-1,onlinePaymentLink:e?.payment?.onlinePaymentLink},this.delivery={type:e?.delivery?.type??-1,date:(0,n.isString)(e?.delivery?.date)?(0,r.parseISO)(e.delivery.date):e?.delivery?.date??new Date,address:e?.delivery?.address?new B(e.delivery.address):void 0,warehouse:e?.delivery?.warehouse?new t.Warehouse(e.delivery.warehouse):void 0},this.attachedUser=e?.attachedUser?new g(e?.attachedUser):void 0,this.status=new t.OrderStatus(e?.status),this.statusDetail=e?.statusDetail?new t.Reference(e.statusDetail):void 0,this.salesDirection=new t.SalesDirection(e?.salesDirection);let i=e?.attachedAt;this.attachedAt=(0,n.isString)(i)?(0,r.parseISO)(i):e?.attachedAt,this.isOnOrder=e?.isOnOrder??!1,this.isProfstroy=e?.isProfstroy??!1,this.isNotInStock=e?.isNotInStock??!1,this.sum=e?.sum??0,this.isLargeOrder=e?.isLargeOrder??!1}},At=class extends le{product;cost;costOne;costOneRub;costRub;logicGroupId;salesDirection;specificationImgUrl;sawing;currency;changedFields=[];replacement;constructor(e,r){super(e),this.product=new C(e.product),this.currency=new t.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=(0,n.isArray)(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,r&&(this.replacement=r,this.quantity!==r.quantity&&this.changedFields.push(`quantity`),this.length!==r.length&&this.changedFields.push(`length`))}},Z=class extends kt{products;invoices;comment;image;contragent;barcode;orderSource;isAllowProcessingWithoutPayment;nextStatuses;actions;operatorsComment;operatorsForWarehouseComment;erpOrderUrl;numberDoc;constructor(e){super(e),this.products=(e.products??[]).map(t=>new At(t,t.replacementId?e.products?.find(e=>e.id===t.replacementId):void 0)),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?z.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new t.Reference(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment,this.nextStatuses=e.nextStatuses?.map(e=>new t.OrderStatus(e)),this.actions=e.actions,this.operatorsComment=e.operatorsComment,this.operatorsForWarehouseComment=e.operatorsForWarehouseComment,this.erpOrderUrl=e.erpOrderUrl,this.numberDoc=e.numberDoc}},jt=class extends t.BasePaginationProvider{getOffers(e,t,n,r){return this.getTypedPaginated(Et,`/internal/orders/offers`,e,t,n,{},void 0,r)}createOfferFromCart(e,t,n){return this.post(`/internal/orders/offers/${e}`,{name:t,items:n?.length?n:void 0},e=>new X(e.data))}createProfstroyOffer(e,t,n,r={}){return this.post(`/internal/orders/offers/${e}/profstroy`,{file:t,name:n},e=>new X(e.data),r)}actualizeProfstroyOffer(e){return this.post(`/internal/orders/offers/${e}/profstroy/actualize`,{},e=>new X(e.data))}reloadProfstroyOffer(e){return this.post(`/internal/orders/offers/${e}/profstroy/reload`,{},e=>new X(e.data))}getOffer(e){return this.get(`/internal/orders/offers/${e}`,{},e=>new X(e.data))}updateOffer(e,t){return this.patch(`/internal/orders/offers/${e}`,{name:t},e=>new X(e.data))}deleteOffer(e){return this.delete(`/internal/orders/offers/${e}`)}createOrderFromDraft(e,n,i,a={}){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.post(`/internal/orders/offers/${e}/create-order`,{...n,deliveryDate:n.deliveryDate?(0,r.format)(n.deliveryDate,o):void 0,items:i?.length?i:void 0},e=>t.TypedInstanceFactory.instanceListInitializer(Z,e.data),a)}addOfferProduct(e,t,n={}){return this.post(`/internal/orders/offers/${e}/products`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new X(e.data),n)}patchOfferProduct(e,t,n,r={}){return this.patch(`/internal/orders/offers/${e}/products/${t}`,{product_id:n.product.id,product_category_id:n.configurator?n.category.id:void 0,quantity:n.quantity,height:n.height,length:n.length,width:n.width,configurator:n.configurator,marker:n.marker,is_additional_sale:n.isAdditionalSale,...n.configuratorParams},e=>new X(e.data),r)}deleteOfferProduct(e,t){return this.delete(`/internal/orders/offers/${e}/products/${t}`,e=>new X(e.data))}deleteOfferProducts(e,t){return this.request({method:`DELETE`,url:`/internal/orders/offers/${e}/products`,data:{items:t}},e=>new X(e.data))}getOfferHtml(e,t){return this.get(`/internal/orders/offers/${e}/view`,t?{recipientText:t}:{},e=>new Blob([e.data],{type:`text/html`}))}getOfferPdf(e,t){return this.getBlob(`/internal/orders/offers/${e}/download`,t?{recipientText:t}:{},e=>new Blob([e.request.response],{type:`application/pdf`}))}sendOffer(e,t){return this.post(`/internal/orders/offers/${e}/send`,t)}},Mt=class{static isProfstroy(e){return!!e?.isProfstroy}static isProfstroyOffer(e){return!(0,n.isNil)(e)&&e.isProfstroy===!0&&!(0,n.isNil)(e.actualization)}},Nt=class extends t.User{isBillingSupervisor;constructor(e){super(e),this.isBillingSupervisor=e?.isBillingSupervisor??!1}},Q=class extends Nt{showAllCosts;stores;constructor(e){super(e),this.showAllCosts=e?.showAllCosts,this.stores=e?.stores?.map(e=>new t.Shop(e))}},Pt=class extends o{name;phone;email;salesDirections;isActive;isBillingSupervisor;canDoReclamations;constructor(e){super(),this.name=e?.name,this.phone=e?.phone,this.email=e?.email,this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.isActive=e?.isActive,this.isBillingSupervisor=e?.isBillingSupervisor,this.canDoReclamations=e?.canDoReclamations}resetFilterValue(e){switch(e){case`name`:case`phone`:case`email`:case`salesDirections`:case`isActive`:case`isBillingSupervisor`:case`canDoReclamations`:this[e]=void 0}return this}},Ft=class e extends t.BasePaginationProvider{static transformOperatorDataToRequest(e){return{name:e.name,phone:e.phone,email:e.email,password:e.password,isActive:e.isActive,isBillingSupervisor:e.isBillingSupervisor,canDoReclamations:e.canDoReclamations,salesDirectionId:e.salesDirection?.id,pricingRoleId:e.pricingRole?.id,showAllCosts:e.showAllCosts??!1,storeIds:(0,n.map)(e.stores,`id`),photo:e.photoFile}}getOperatorsList(e,t,n,r){return this.getTypedPaginated(Nt,`/internal/operators`,e,t,n,{},void 0,r)}getOperator(e,t=!1){return this.get(`/internal/operators/${e}`,{},e=>new Q(e.data),t)}createOperator(t,n={}){return this.post(`/internal/operators`,e.transformOperatorDataToRequest(t),e=>new Q(e.data),n)}updateOperator(t,n={}){return this.patch(`/internal/operators/${t.id}`,e.transformOperatorDataToRequest(t),e=>new Q(e.data),n)}},It=function(e){return e.View=`view`,e.Share=`share`,e.EditTags=`edit_tags`,e.SaveOrderIgnoredProducts=`save_order_ignored_products`,e.ChangeStatus=`change_status`,e.ChangeProducts=`change_products`,e.ChangeOrderParameters=`change_order_parameters`,e.Recalculate=`recalculate`,e.AttachOrder=`attach_order`,e.DetachOrder=`detach_order`,e.ChangeAttachedOperator=`change_attached_operator`,e.SendOnlinePaymentLink=`send_online_payment_link`,e.ConfirmOnlineFullPayment=`confirm_online_full_payment`,e.MergeOrders=`merge_orders`,e.GetHistory=`get_history`,e.CloneOrder=`clone_order`,e.DeleteAttachedFile=`delete_attached_file`,e}({}),Lt=class{paymentType;deliveryType;contragentId;deliveryDate;addressId;warehouseId;image;comment;barcode;operatorsComment;operatorsForWarehouseComment;additionalEmails;isAllowProcessingWithoutPayment;isAdditionalSale;constructor(e){this.paymentType=e?.payment.type,this.deliveryType=e?.delivery.type,this.contragentId=e?.contragent?.id,this.deliveryDate=e?.delivery.date?new Date(e.delivery.date):void 0,this.addressId=e?.delivery.address?.id,this.warehouseId=e?.delivery.warehouse?.id,this.comment=e?.comment,this.barcode=e?.barcode,this.operatorsComment=e?.operatorsComment,this.operatorsForWarehouseComment=e?.operatorsForWarehouseComment,this.isAllowProcessingWithoutPayment=e?.isAllowProcessingWithoutPayment}},Rt=class extends o{attachedUsers;clientSearchTerm;client;contragent;createdAt=new m;creator;deliveryDate=new m;deliveryAddressSearch;clientCities;id;isApproved;isNotInStock;isOnOrder;attachedAt=new m;salesDirections;status;statusDetail;deliveryType;paymentType;warehouses;isLargeOrder;isToProcess;onlyMyRegions;constructor(e){super(),this.attachedUsers=e?.attachedUsers?.map(e=>`isActive`in e?new t.Manager(e):new t.Operator(e)),this.clientSearchTerm=e?.clientSearchTerm,this.client=e?.client?new k(e.client):void 0,this.contragent=e?.contragent,this.createdAt=new m(e?.createdAt),this.creator=e?.creator?new g(e.creator):void 0,this.deliveryDate=new m(e?.deliveryDate),this.deliveryAddressSearch=e?.deliveryAddressSearch,this.clientCities=e?.clientCities?.map(e=>new t.CityWithRegionAndCountry(e)),this.id=e?.id,this.isApproved=e?.isApproved,this.isNotInStock=e?.isNotInStock,this.isOnOrder=e?.isOnOrder,this.isLargeOrder=e?.isLargeOrder,this.attachedAt=new m(e?.attachedAt),this.salesDirections=e?.salesDirections?.map(e=>new t.SalesDirection(e)),this.status=e?.status,this.statusDetail=e?.statusDetail,this.deliveryType=e?.deliveryType?new t.DeliveryType(e.deliveryType):void 0,this.paymentType=e?.paymentType?new t.PaymentType(e.paymentType):void 0,this.warehouses=e?.warehouses?.map(e=>new t.Warehouse(e)),this.isToProcess=e?.isToProcess}resetFilterValue(e){switch(e){case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`creator`:this.creator=void 0;break;case`deliveryDate`:this.deliveryDate.from=null,this.deliveryDate.to=null;break;case`deliveryType`:this.deliveryType=new t.DeliveryType;break;case`clientCities`:this.clientCities=[];break;case`attachedAt`:this.attachedAt.from=null,this.attachedAt.to=null;break;case`salesDirection`:case`salesDirections`:this.salesDirections=[];break;case`status`:this.status=[];break;case`warehouse`:case`warehouses`:this.warehouses=[];break;default:this[e]=void 0}return this}asClearRaw(){let e=super.asClearRaw();return!e?.createdAt?.from&&!e?.createdAt?.to&&delete e.createdAt,!e?.deliveryDate?.from&&!e?.deliveryDate?.to&&delete e.deliveryDate,!e?.attachedAt?.from&&!e?.attachedAt?.to&&delete e.attachedAt,e}},zt=class{user;status;statusDetail;createdAt;constructor(e){this.user=new g(e?.user),this.status=new t.OrderStatus(e?.status),this.statusDetail=e?.statusDetail?new t.Reference(e.statusDetail):void 0;let i=e?.createdAt;this.createdAt=(0,n.isString)(i)?(0,r.parseISO)(i):e?.createdAt??new Date}},Bt=class extends t.BasePaginationProvider{getOrders(e,t,n,r){return this.getTypedPaginated(kt,`/internal/orders`,e,t,n,{},void 0,r)}getOrdersCount(e,n){return this.get(`/internal/orders/count`,e?{filters:JSON.stringify((e instanceof t.FilterGroup?e:new t.FilterGroup(e)).toPrimitive())}:{},void 0,void 0,n).then(e=>e.count)}getClientOrderStatistics(e,t){return this.get(`/internal/clients/${e}/orders/statistics`,t?{period:t}:{})}getOrder(e){return this.get(`/internal/orders/${e}`,{},e=>new Z(e.data))}createClientOrder(e,n,i,a={}){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.post(`/internal/clients/${e}/orders`,{...n,deliveryDate:(0,r.format)(n.deliveryDate,o),items:i?.length?i:void 0},e=>t.TypedInstanceFactory.instanceListInitializer(Z,e.data),a)}attachOrder(e){return this.patch(`/internal/orders/${e}/attach`,{},e=>new Z(e.data))}detachOrder(e){return this.patch(`/internal/orders/${e}/detach`,{},e=>new Z(e.data))}mergeOrders(e,t){return this.patch(`/internal/orders/${e}/merge`,{ids:t},e=>new Z(e.data))}recalculateOrder(e){return this.patch(`/internal/orders/${e}/recalculate`,{},e=>new Z(e.data))}cloneOrder(e){return this.get(`/internal/orders/${e}/clone`,{})}updateOrder(e,n,i={}){let a=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.patch(`/internal/orders/${e}`,{...n,deliveryDate:n.deliveryDate?(0,r.format)(n.deliveryDate,a):void 0},e=>new Z(e.data),i)}addOrderProduct(e,t,n={}){return this.post(`/internal/orders/${e}/products`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,is_additional_sale:t.isAdditionalSale,...t.configuratorParams},e=>new Z(e.data),n)}changeOrderStatus(e,t,n,r={}){return this.patch(`/internal/orders/${e}/status`,{status:t,statusDetail:n},e=>new Z(e.data),r)}changeOrderStatusDetail(e,t){return this.patch(`/internal/orders/${e}/status`,{statusDetail:t},e=>new Z(e.data))}getOrderStatusHistory(e){return this.getTypedList(zt,`/internal/orders/${e}/history`)}getOrderPrintHtml(e,t){return this.get(`/internal/orders/${e}/print/view`,{...t},e=>new Blob([e.data],{type:`text/html`}))}getOrderPrintPdf(e,t){return this.getBlob(`/internal/orders/${e}/print/download`,{...t},e=>new Blob([e.request.response],{type:`application/pdf`}))}sendOrderPrint(e,t){return this.post(`/internal/orders/${e}/print/send`,t)}changeAttachedOperator(e,t){return this.patch(`/internal/orders/${e}/change-attached-operator`,{operatorId:t},e=>new Z(e.data))}deleteOrderAttachedFile(e){return this.delete(`/internal/orders/${e}/file/attached`,e=>new Z(e.data))}deleteOrderProduct(e,t){return this.delete(`/internal/orders/${e}/products/${t}`,e=>new Z(e.data))}patchOrderProduct(e,t,n,r={}){return this.patch(`/internal/orders/${e}/products/${t}`,{product_id:n.product.id,product_category_id:n.configurator?n.category.id:void 0,quantity:n.quantity,height:n.height,length:n.length,width:n.width,configurator:n.configurator,marker:n.marker,is_additional_sale:n.isAdditionalSale,...n.configuratorParams},e=>new Z(e.data),r)}getDeliveryNearestDates(e,t){return this.get(`/internal/orders/delivery/${e}/nearest-dates`,{},e=>e.data,void 0,t)}getSelfDeliveryNearestDates(e,t){return this.get(`/internal/orders/self-delivery/${e}/nearest-dates`,{},e=>e.data,void 0,t)}getDeliveryCost(e,n,i,a){let o=(0,t.useBaseConfigStore)().config.dateFormats.api;return this.get(`/internal/orders/delivery/${e}/cost`,{date:(0,r.format)(n,o),warehouse_id:i},e=>e.data,void 0,a)}},Vt=Symbol(`currentOrder`),Ht=class{client;product;cost;costCoefficient;source;constructor(e){this.client=new k(e?.client),this.product=new S(e?.product),this.cost=e?.cost??0,this.costCoefficient=e?.costCoefficient??0,this.source=e?.source??ce.Product}},Ut=e=>e?(0,n.omitBy)({cities:e.cities?.map(e=>e.id),clients:e.clients?.map(e=>e.id),managers:e.managers?.map(e=>e.id),partnerGroups:e.partnerGroups?.map(e=>e.id),salesDirections:e.salesDirections?.map(e=>e.id),hideNotActive:e.hideNotActive},e=>(0,n.isNil)(e)||((0,n.isArray)(e)||(0,n.isObject)(e))&&(0,n.isEmpty)(e)):{},Wt=e=>{let t={};return e.from&&(e.from.coefficient||e.from.value)&&(t.from={},e.from.coefficient&&(t.from.priceCoefficientId=e.from.coefficient.id),e.from.value&&(t.from.increasePercent=e.from.value)),e.to&&(e.to.coefficient||e.to.value)&&(t.to={},e.to.coefficient&&(t.to.priceCoefficientId=e.to.coefficient.id),e.to.value&&(t.to.increasePercent=e.to.value)),t},Gt=class extends t.HttpRequester{analyzeProductPrices(e,n,r){return this.get(`/internal/price/products/${e}/analyze`,{...Wt(n),filters:Ut(r)},e=>t.TypedInstanceFactory.instanceListInitializer(Ht,e.data))}analyzeCategoryPrices(e,n,r){return this.get(`/internal/price/categories/${e}/analyze`,{...Wt(n),filters:Ut(r)},e=>t.TypedInstanceFactory.instanceListInitializer(Ht,e.data))}analyzeCategoryPricesBySquare(e,n,r){return this.get(`/internal/price/categories/${e}/analyze/square`,{...n,filters:Ut(r)},e=>t.TypedInstanceFactory.instanceListInitializer(Ht,e.data))}},Kt=class{cost;isLowCost;isRetail;costDate;discountName;priceTemplateName;product;client;executor;currency;constructor(e){this.cost=e.cost??0,this.isLowCost=e.isLowCost??!1,this.isRetail=e.isRetail??!1,this.costDate=(0,n.isString)(e.costDate)?(0,r.parseISO)(e.costDate):e.costDate??new Date,this.discountName=e.discountName,this.priceTemplateName=e.priceTemplateName,this.product=e.product?new b(e.product):void 0,this.client=e.client?new g(e.client):void 0,this.executor=e.executor?new g(e.executor):void 0,this.currency=e.currency?new t.Currency(e.currency):void 0}},qt=class extends b{history;constructor(e){super(e),this.history=(0,n.map)(e.history,e=>new Kt(e))}},Jt=class extends t.HttpRequester{getProductPriceHistory(e){let i=(0,t.useBaseConfigStore)().config.dateFormats.api,a=(0,n.omitBy)((0,n.merge)(e,{costDate:{from:(0,n.isDate)(e.costDate?.from)?(0,r.format)(e.costDate.from,i):e.costDate?.from,to:(0,n.isDate)(e.costDate?.to)?(0,r.format)(e.costDate.to,i):e.costDate?.to}}),e=>(0,n.isNil)(e)||((0,n.isArray)(e)||(0,n.isObject)(e))&&(0,n.isEmpty)(e)),o=e.product?.[0]??0;return delete a.product,this.get(`/internal/price/products/${o}/history`,a).then(e=>[new qt((0,n.merge)(e[0],{history:e}))])}},Yt=class{createdAt;creator;files;text;status;constructor(e){this.createdAt=t.DateHelper.parse(e?.createdAt)??new Date,this.creator=(0,n.isNil)(e?.creator)?void 0:new g(e.creator),this.files=e?.files??[],this.text=e?.text??void 0,this.status=e?.status??void 0}isStatusChanged(){return!(0,n.isNil)(this.status)}},$=function(e){return e[e.Initiated=1]=`Initiated`,e[e.InfoRequired=2]=`InfoRequired`,e[e.Pending=3]=`Pending`,e[e.Completed=4]=`Completed`,e}({}),Xt=class extends f{status;closedAt;isRead;isDeleted;client;constructor(e){super(e),this.status=e?.status??$.Initiated,this.closedAt=t.DateHelper.parse(e?.closedAt),this.isRead=e?.isRead??!1,this.isDeleted=e?.isDeleted??!1,this.client=new Ke(e?.client)}isClosed(){return this.status===$.Completed}isDeletionPending(){return this.isDeleted&&!this.isClosed()}canAddMessage(){return!this.isClosed()}getConsiderationDays(e=new Date){return Math.max((0,r.differenceInCalendarDays)(this.closedAt??e,this.createdAt),0)}},Zt=class extends Xt{items;constructor(e){super(e),this.items=(0,n.map)(e?.items??[],e=>new Yt(e))}isClientMessage(e){return e.creator?.id===this.client.id}},Qt=class extends o{id;statuses;createdAt;closedAt;isRead;isDeleted;clientName;cityName;constructor(e){super(),this.id={from:e?.id?.from??null,to:e?.id?.to??null},this.statuses=e?.statuses,this.createdAt=new m(e?.createdAt),this.closedAt=new m(e?.closedAt),this.isRead=e?.isRead,this.isDeleted=e?.isDeleted,this.clientName=e?.clientName,this.cityName=e?.cityName}resetFilterValue(e){switch(e){case`isDeleted`:this.isDeleted=!1;break;case`statuses`:case`isRead`:case`clientName`:case`cityName`:this[e]=void 0;break;case`id`:this.id.from=null,this.id.to=null;break;case`createdAt`:this.createdAt.from=null,this.createdAt.to=null;break;case`closedAt`:this.closedAt.from=null,this.closedAt.to=null}return this}},$t=class e{static apiCodes={[$.Initiated]:`initiated`,[$.InfoRequired]:`info_required`,[$.Pending]:`pending`,[$.Completed]:`completed`};static toApiCode(t){return e.apiCodes[t]}static toApiCodes(t){return(0,n.map)(t,t=>e.toApiCode(t))}},en=class extends t.BasePaginationProvider{getReclamationsList(e,t,n,r,i=!1){return this.getTypedPaginated(Xt,`/internal/reclamations`,e,t,n,{},i,r)}getReclamation(e,t,n=!1){return this.get(`/internal/reclamations/${e}`,{},e=>new Zt(e.data),n,t)}createMessage(e,t,n={}){return this.post(`/internal/reclamations/${e}/messages`,t,e=>new Zt(e.data),n)}deleteReclamation(e){return this.delete(`/internal/reclamations/${e}`)}restoreReclamation(e){return this.post(`/internal/reclamations/${e}/restore`,{},e=>new Zt(e.data))}downloadReclamation(e,t=!1){return this.getBlob(`/internal/reclamations/${e}/download`,{},e=>new Blob([e.request.response],{type:`application/pdf`}),t)}getUpdates(e,t=!1){return this.get(`/internal/reclamations/updates`,{},void 0,t,e)}},tn=class{products=[];productCategories=[];constructor(e){e?.products&&(this.products=e.products.map(e=>new b(e))),e?.productCategories&&(this.productCategories=e.productCategories.map(e=>new b(e)))}},nn=class extends t.HttpRequester{getProductCategoryRecommendations(e){return this.get(`/internal/catalog/recommendations/categories/${e.id}`,{},e=>new tn(e.data))}getProductRecommendations(e){return this.get(`/internal/catalog/recommendations/products/${e.id}`,{},e=>new tn(e.data))}saveProductCategoryRecommendations(e,t){return this.post(`/internal/catalog/recommendations/categories/${e.id}`,{product_categories:t.productCategories.map(e=>e.id),products:t.products.map(e=>e.id)})}saveProductRecommendations(e,t){return this.post(`/internal/catalog/recommendations/products/${e.id}`,{product_categories:t.productCategories.map(e=>e.id),products:t.products.map(e=>e.id)})}},rn=class{static generateUndefinedInstance(e,t=`- Не определён -`){return new e({id:0,name:t,slug:`-undefined-`})}static isUndefinedInstance(e){return e.id===0&&e.slug===`-undefined-`}},an=class{name;content;constructor(e){this.name=e.name,this.content=e.content}},on=class{resourceType;resourceId;h1;title;description;keywords;meta;tags;constructor(e){this.resourceType=new t.ResourceType(e?.resourceType),this.resourceId=e?.resourceId??``,this.h1=e?.h1,this.title=e?.title,this.description=e?.description,this.keywords=e?.keywords,this.meta=e?.meta?.map(e=>new an(e))??[],this.tags=e?.tags}},sn=class extends t.HttpRequester{getResourceSeoData(e,t){return this.get(`/internal/seo/${e.slug}/${t}`,{},e=>new on(e.data))}saveResourceSeoData(e,t={}){return this.post(`/internal/seo/${e.resourceType.slug}/${e.resourceId}`,e,e=>new on(e.data),t)}deleteResourceSeoData(e,t){return this.delete(`/internal/seo/${e.slug}/${t}`)}},cn=class extends t.Identity{text;searchCount;lastSearchedAt;constructor(e){super(e),this.text=e?.text??``,this.searchCount=e?.searchCount??0,this.lastSearchedAt=t.DateHelper.parse(e?.lastSearchedAt)}},ln=class extends t.HttpRequester{getSearchProductsStatistics(e,n){return this.getTypedList(cn,`/internal/statistics/search/products`,{date:t.DateHelper.periodToApiFormat(e)},!1,n)}removeSearchProductStatistic(e){return this.delete(`/internal/statistics/search/products/${e}`)}},un=function(e){return e[e.Undetermined=0]=`Undetermined`,e[e.Complete=1]=`Complete`,e[e.Incomplete=2]=`Incomplete`,e}({}),dn=class e{static isBlocked(e,t){return t&&e===un.Incomplete}static getValidationResult(n,r){return e.isBlocked(n,r)?new t.FieldValidationResultData(`Проверьте адрес и выберите более точный вариант из подсказок`,`error`):n===un.Incomplete||n===un.Undetermined?new t.FieldValidationResultData(`Проверьте правильность адреса`,`warning`):void 0}},fn=class extends t.HttpRequester{searchAddresses(e){return this.execSuggestionQuery(`/public/suggestions/address`,e)}searchBank(e){return this.execSuggestionQuery(`/public/suggestions/bank`,e)}searchOrganization(e){return this.execSuggestionQuery(`/public/suggestions/organization`,e)}execSuggestionQuery(e,t){return this.get(e,{query:t}).then(e=>{let t=[...e],n=1;return t.forEach(e=>{e.id=n++}),t})}},pn=class extends t.HttpRequester{constructor(){super(),this.baseUrl=`${(0,t.useBaseConfigStore)().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(e=>e.accessToken)}},mn=class{user;salesDirection;constructor(e){this.user=new g(e?.user),this.salesDirection=new t.SalesDirection(e?.salesDirection)}},hn=class extends t.UserRegionShortInfo{cities;users;constructor(e){super(e),this.cities=e?.cities?.map(e=>new t.CityWithRegionAndCountry(e))??[],this.users=e?.users?.map(e=>new mn(e))??[]}},gn=class extends o{id;name;abbr;constructor(e){super(),this.id=e?.id,this.name=e?.name,this.abbr=e?.abbr}resetFilterValue(e){switch(e){case`id`:case`name`:case`abbr`:this[e]=void 0}return this}},_n=class extends t.BasePaginationProvider{getRegionsList(e,n,r){return this.getTypedPaginated(t.UserRegionShortInfo,`/internal/users/regions`,e,n,r)}getRegion(e){return this.get(`/internal/users/regions/${e}`,{},e=>new hn(e.data))}createRegion(e,t={}){return this.post(`/internal/users/regions`,e,e=>new hn(e.data),t)}updateRegion(e,t,n={}){return this.patch(`/internal/users/regions/${e}`,t,e=>new hn(e.data),n)}removeRegion(e){return this.delete(`/internal/users/regions/${e}`)}getRegionEmployees(e){return this.getTypedList(mn,`/internal/users/regions/${e}/users`)}attachRegionEmployee(e,t,n){return this.post(`/internal/users/regions/${e}/users/${t}`,{salesDirectionId:n},e=>new mn(e.data))}detachRegionEmployee(e,t,n){return this.request({method:`DELETE`,url:`/internal/users/regions/${e}/users/${t}`,params:{sales_direction_id:n}})}};e.AddressQualityEnum=un,e.AddressQualityHelper=dn,e.AdminFullInfo=a,e.AdminProvider=c,e.AdminShortInfo=i,e.AdminsListFilters=s,e.BankAccount=I,e.BlogPost=p,e.BlogPostMediaFile=u,e.BlogPostMediaTypeEnum=l,e.BlogPostPublicationStatusEnum=d,e.BlogPostShortInfo=ee,e.BlogPostsListFilters=te,e.BlogProvider=ne,e.CalculationTypeEnum=fe,e.CalendarHelper=H,e.Cart=T,e.CartProvider=de,e.CatalogProvider=De,e.CatalogableItem=ae,e.Category=E,e.CategoryFilter=Ee,e.CategoryFilterSetting=we,e.CategoryFilterValue=Te,e.CategoryPricingRule=Se,e.Client=qe,e.ClientAdditionalData=Xe,e.ClientBaseInfo=Ke,e.ClientCategory=he,e.ClientDataProvider=Qe,e.ClientPriceCatalogableItem=be,e.ClientPriceCategory=xe,e.ClientPriceProduct=P,e.ClientPriceProvider=Oe,e.ClientPriceTemplateProvider=ke,e.ClientProduct=C,e.ClientProductCategoryDataProvider=Me,e.ClientProductDataProvider=Ne,e.ClientShortInfo=k,e.ClientsAdditionalDataRequestTypeEnum=Be,e.ClientsListFilters=Je,e.CodedIdentity=b,e.ConfiguratorProvider=nt,e.ConfiguratorsEnum=tt,e.Contact=L,e.ContactPerson=R,e.ContactPersonRelated=Ze,e.ContactRelation=V,e.ContragentBase=Ve,e.ContragentFactory=z,e.ContragentIc=Ue,e.ContragentPerson=He,e.ContragentUlNr=Ge,e.ContragentUlR=We,e.CostSourceEnum=ce,e.CreatableIdentity=f,e.Curator=O,e.DataSuggestionProvider=fn,e.DateTimeProvider=lt,e.DeletableIdentity=ve,e.DeletableNamedIdentity=h,e.DeliveryAddress=B,e.Discount=G,e.DiscountClient=U,e.DiscountClientEligibility=mt,e.DiscountConditions=ft,e.DiscountProvider=gt,e.DiscountShortInfo=_,e.DiscountStateEnum=W,e.DiscountStateHelper=pt,e.DiscountsListFilters=ht,e.ExternalSeoFullInfo=K,e.ExternalSeoListFilters=_t,e.ExternalSeoProvider=vt,e.Faq=J,e.FaqGroup=q,e.FaqProvider=yt,e.FilterSettings=Ce,e.HiddenCatalogableItem=oe,e.Image=se,e.ManagerDataFactory=St,e.ManagerProvider=wt,e.ManagersListFilters=Ct,e.MetaTagItem=an,e.Offer=X,e.OfferActualization=Tt,e.OfferActualizationStatus=Y,e.OfferHelper=Mt,e.OfferShortInfo=Et,e.OffersDataProvider=jt,e.OffersListFilters=Ot,e.OperatorFullInfo=Q,e.OperatorProvider=Ft,e.OperatorShortInfo=Nt,e.OperatorsListFilters=Pt,e.Order=Z,e.OrderAction=It,e.OrderEditorData=Lt,e.OrderInfo=kt,e.OrderItem=At,e.OrderItemBase=le,e.OrderShortInfo=Ye,e.OrderStatusHistoryInfo=zt,e.OrdersDataProvider=Bt,e.OrdersListFilters=Rt,e.PaginationFiltersBase=o,e.PriceAnalyze=Ht,e.PriceAnalyzeProvider=Gt,e.PriceCatalogableItem=ge,e.PriceHistoryDataProvider=Jt,e.PriceHistoryItem=Kt,e.PriceTemplate=v,e.PriceTemplateCategory=D,e.PriceTemplateClient=A,e.PriceTemplateICatalogableItem=_e,e.PriceTemplateProduct=j,e.PriceTemplateProvider=Pe,e.PricingRole=F,e.PricingRoleProvider=Fe,e.PrimaryCatalogableItem=x,e.Product=S,e.ProductCategoryDataProvider=Ae,e.ProductDataProvider=je,e.ProductFilterTypeEnum=pe,e.ProductPriceCoefficient=y,e.ProductPriceHistory=qt,e.ProductUnit=ie,e.ProfstroyOfferItem=Dt,e.PropertiesProvider=Ie,e.Property=M,e.PropertyValue=N,e.Reclamation=Zt,e.ReclamationItem=Yt,e.ReclamationProvider=en,e.ReclamationShortInfo=Xt,e.ReclamationStatusEnum=$,e.ReclamationStatusHelper=$t,e.ReclamationsListFilters=Qt,e.RecommendationsDataProvider=nn,e.RecommendationsList=tn,e.ReferenceDataFactory=rn,e.STANDARD_PERIOD_GROUPS=ut,e.STANDARD_PERIOD_SECTIONS=dt,e.SearchProductStatistic=cn,e.Seo=on,e.SeoDataProvider=sn,e.StatisticsProvider=ln,e.StockCount=re,e.TableDataPagination=it,e.TableDataPaginationRequestParams=rt,e.TableDataSortRequestParams=at,e.TemplateProductCategoryDataProvider=Le,e.TemplatesListFilters=ye,e.UnitsHelper=xt,e.UnknownClientDataProvider=$e,e.UserAuthDataProvider=pn,e.UserRegion=hn,e.UserRegionEmployee=mn,e.UserRegionProvider=_n,e.UserRegionsListFilters=gn,e.UserShortInfo=g,e.VersionConfig=et,e.currentOrderInjectionKey=Vt,e.daysAgoIso=ot,e.findCatalogItemByIdRecursive=Re,e.flattenCatalogItems=ze,e.formatPercentChange=bt,e.formatRelativeDate=ct,e.pluralize=st,Object.keys(t).forEach(function(n){n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})});
|