1import{a as nr}from"./chunk-CJRK3T4L.js";import{a as hi}from"./chunk-OXQUHS3H.js";import{b as rr}from"./chunk-P5KFRL6V.js";import{c as K,d as qe,g as mi}from"./chunk-A26O3FGY.js";import{a as ae}from"./chunk-MFRGMXK5.js";import{c as ci}from"./chunk-7GEZUKAP.js";import{a as gi}from"./chunk-BY25MCOB.js";import{H as ui,I as se,J as me,O as We,b as ie,h as yt,i as tr,k as te,l as Q,m as oe,n as li,q as di,u as Qr,w as Ot,y as Te,z as pi}from"./chunk-4ELR7O6R.js";import{P as Qn,S as er,T as Kr,U as Gr,V as Wr,W as qr,X as Jn,Y as Xr,Z as Zn,_ as ei,a as Zt,c as He,d as Ke,e as Ge,ka as ti,r as Xn,s as Yn,sa as Yr}from"./chunk-XH2FTEW6.js";import{b as qn,d as Jt}from"./chunk-UZCIA3XM.js";import{A as Qt,E as xe,c as le,e as Vn,i as w,k as Y,r as Yt,s as Hn,t as Kn,u as Gn,v as _e,w as bt,x as q,y as ee,z as Vr}from"./chunk-JAHL4O5B.js";import{c as Xt,e as ft,f as zn,g as Ln,k as _t}from"./chunk-S6YIDZD3.js";import{a as ue,c as Je,d as Ze}from"./chunk-LW3GYOL2.js";import{a as Wn,c as vt}from"./chunk-WV5NZCWG.js";import{a as ri,b as ni,c as ii,j as oi,m as si,p as ai}from"./chunk-XP7IAX7E.js";import{a as Hr}from"./chunk-NKUYZACS.js";import{c as Ne,d as ze}from"./chunk-53DOX2OC.js";import{c as ht,e as gt}from"./chunk-GL5VAVUH.js";import{H as Le,I as Be,K as Ve,S as Bn,h as Rn,i as Nn}from"./chunk-OWD7JG7T.js";import{A as zr,B as $n,D as U,Fa as mt,Ha as Un,Ka as Re,g as Wt,j as Mn,ja as qt,k as Tn,ka as An,l as In,p as pt,q as En,v as Rr,w as Nr,x as ut,y as On,ya as Br,z as Dn}from"./chunk-7LUFMYSS.js";import{a as Lr,b as Fn}from"./chunk-U4TFHOKU.js";import{$a as _,$b as Kt,A as Nt,Aa as $e,C as Z,Ca as Bt,Cc as Sn,Dc as Me,E as he,Ec as $,F as Mr,Fc as ne,G as Tr,Hb as at,Hc as It,I as Oe,Ic as Ce,Jb as R,Jc as Dr,Kb as vn,Kc as V,L as nt,Lb as N,Lc as wn,M as De,Ob as yn,Pb as Cn,Qb as k,Rb as g,S as Ye,Sb as b,Tb as Ae,Tc as M,U as Ir,Uc as T,V as D,W as ye,Y as G,Yc as $r,Zb as Fe,_b as W,aa as P,ba as zt,c as mn,cc as I,cd as Ar,da as gn,e as J,ec as S,f as ve,fa as h,fb as bn,g as Ut,gd as kn,hc as Or,ib as Er,ic as Gt,id as Et,j as hn,jc as ct,jd as H,ka as z,kb as Vt,kc as lt,kd as jn,l as E,la as L,mc as xn,n as kr,nc as Pn,ob as ge,oc as fe,pa as it,pb as Ht,pd as Fr,q as O,qa as Lt,qb as de,qd as Ur,r as Tt,sa as ot,tb as je,tc as v,td as Qe,u as jr,ua as fn,ub as st,uc as dt,ud as Ue,vc as B,w as Rt,wa as X,x as Ee,ya as ce,za as _n}from"./chunk-2HTR7ORR.js";import{a as we,b as ke,f as rt}from"./chunk-VTHXE323.js";var be=class{constructor(t,e,r){this._dialogsService=t;this._projectHelper=e;this._selectedProductsService=r}canDrop(t,e){let r=this._getProductsSize(t,e);
1return r.sameProduct?!1:r.sameShelf?!0:this._canDrop(t,e,r.size)}createTargets(t,e,r,n,i,o){let a=oe(t,r,n),d=e.holders[n];if(a.length>1&&a[0].mounting!==d)return[];let u=[],l=this._maxYCombined(t,r,n),m=parseFloat((d.type===-1?l-d.location.y:l-d.location.y-d.size.h).toFixed(2));if(m<=0)return[];let C=a.length>1?a.reduce((f,y)=>f+parseFloat(y.mounting.size.w.toFixed(2)),0):parseFloat(d.size.w.toFixed(2));return u.push({x:d.type===-1?d.location.x:i+d.location.x,y:d.type===-1?d.location.y:d.location.y+d.size.h,width:C,height:m,mode:0,section:e,sectionIndex:r,mounting:d,mountingIndex:n,alignment:d.alignment,relatedProduct:d.relatedProduct}),u}deleteProduct({project:t,sectionIndex:e,mountingIndex:r,products:n,mounting:i,product:o,sendToBasket:a=!0}){let c=t.rack.sections[e];i||(n&&r===void 0&&(r=c.holders.findIndex(m=>m.products===n)),i=c.holders[r]),n=i.products;let d=n.findIndex(m=>o===m);if(n.splice(d,1),a){let m=le(o);m.location=void 0,t.products.push(m)}let u=c.holders.findIndex(m=>m.relatedProduct===o),l=c.holders[u];l&&l.products.length>0&&(this._moveProductsDown(c,l,o.fronts.h*o.size.h),i.products.push(...l.products)),u!==-1&&c.holders.splice(u,1),this.alignProducts(t,e,i.name),Q(t,e,i)}dropMounting(t,e){this.deleteShelf(t,e.sourceMounting,e.sectionIndex);let r=!1,n=new J;return setTimeout(()=>{let i=e.sourceMounting,o=e.sectionIndex,a=e.target,c=e.sectionIndexNew,d=t.rack.size.h,u=0,l=3,m=()=>{t.rack.sections[o].holders.push(e.sourceMounting),t.rack.sections[o].holders.sort((f,y)=>f.location.y-y.location.y),r=!1};if(e.target){let C=e.target.holders;a.sectionWidth<e.sourceMounting.size.w&&(e.sourceMounting.size.w=a.sectionWidth);let f=this.canDropPegboard(t,e);if(f.canDrop&&e.position.y>=-l){if(this.toBetween(e.position.y+i.size.h,d-l,d)){let y=d-(e.position.y+i.size.h);e.position.y+=parseFloat(y.toFixed(2))}this.toBetween(e.position.y,u-l,u+l)&&(e.position.y=0),i.location={x:e.position.x,y:e.position.y},C.push(i),t.rack.sections[c].holders=C.sort((y,j)=>y.location.y-j.location.y),r=!0}else if(f.mounting?.location.y===0&&f.mounting.type===1){let y=f.mounting.location.y+f.mounting.size.h-e.position.y;i.location={x:0,y:e.position.y+parseFloat(y.toFixed(2))},C.push(i),t.rack.sections[c].holders=C.sort((j,p)=>j.location.y-p.location.y),r=!0}else m()}else m();n.next(r)},200),n.asObservable()}dropMountingShelf(t,e){this.deleteShelf(t,e.sourceMounting,e.sectionIndex);let r=!1,n=new J;return setTimeout(()=>{let i=e.sourceMounting,o=e.sectionIndex,a=e.target,c=e.sectionIndexNew,d=t.rack.size.h,u=0,l=3,m=()=>{t.rack.sections[o].holders.push(e.sourceMounting),t.rack.sections[o].holders.sort((C,f)=>C.location.y-f.location.y),r=!1};if(a&&u<e.position.y+i.size.h&&e.position.y<d){let C=e.target.holders;if(a.sectionWidth<e.sourceMounting.size.w&&(e.sourceMounting.size.w=a.sectionWidth),this._canInsertPosition(t,c,e.position.y,i.size.h)){let f=this.shelfAlingment(t,i,c,e.position.y);if(f===0&&this.toBetween(e.position.y,u-l,u+l,i.size.h)&&(e.position.y=0),i.location={x:e.position.x,y:f===0?e.position.y:f},e.sectionIndex!==e.sectionIndexNew&&(i.name=C.length>0?(Math.max(...C.map(y=>parseInt(y.name,10)))+1).toString():"1"),C.push(i),C.sort((y,j)=>y.location.y-j.location.y),t.rack.sections[c].holders=C,r=!0,i.alignment===Yr.free&&i.products?.length>0)for(let y of i.products)y.location.x=y.dx+i.location.x+t.rack.sections[c].sectionX,y.location.y=y.dy+i.location.y+i.size.h}else m()}else m();n.next(r)},350),n.asObservable()}_canDrop(t,e,r){let n=this._maxYCombined(t,e.sectionIndex,e.mountingIndex),i=this._maxWCombined(t,e.sectionIndex,e.mountingIndex);return!(r.w>i||e.mounting.location.y+e.mounting.size.h+r.h>n)}_deleteProduct(t,e,r){let n=e.sourceMounting;r||e.fromBasket||n.type===3||n.type===4||(n.type===1||n.type===-1)&&n.alignment===Yr.free?e.products.splice(e.products.indexOf(e.product),1):this._projectHelper.mountingGetShelfAlignment(n.alignment).deleteProduct({project:t,mounting:n,sectionIndex:e.sectionIndex,mountingIndex:e.mountingIndex,products:e.products,product:e.product,sendToBasket:!1})}_getMaxFrontsW(t,e,r,n,i){if(n){if(e===0){let o=yt(t,r),a=i?n.size.w*n.fronts.w:0;return Math.trunc((o+a)/n.size.w)}return Math.trunc(r.size.w/n.size.w)}return 1}_getProductsSize(t,e){let r=!0,n=!1,i={w:0,h:0};for(let o of this._selectedProductsService.selectedProducts)if(i.w+=o.product.size.w*o.product.fronts.w,o.product.size.h*o.product.fronts.h>i.h&&(i.h=o.product.size.h*o.product.fronts.h),o.sectionIndex!==void 0?t.rack.sections[o.sectionIndex].holders[o.mountingIndex]!==e.mounting&&(r=!1):r=!1,o.product===e.relatedProduct){n=!0;break}return{size:i,sameShelf:r,sameProduct:n}}_maxWCombined(t,e,r){return oe(t,e,r,!0).reduce((i,o)=>
1i+o.mounting.size.w,0)}_maxYCombined(t,e,r){let n=oe(t,e,r,!0),i=t.rack.size.h;for(let o of n){let a=t.rack.sections[o.sectionIndex].holders,c=te(t,a,a.findIndex(d=>d===o.mounting));i=c<i?c:i}return i}_updateFacings(t,e,r){t.fronts?(t.fronts.w=t.fronts.w>e?e:t.fronts.w,t.fronts.h=t.fronts.h>r?r:t.fronts.h):t.fronts={w:1,h:1},t.facingSpace={w:0,h:0}}_updateStock(t,e){t.size.d>e.d&&(t.stock=null,this._dialogsService.showErrorSnackbar("drop.error-no-depth"))}_canInsertPosition(t,e,r,n){let i=!0,o=t.rack.sections[e].holders;for(let a of o)a.location.y<=r+n&&r<=a.location.y+a.size.h&&(i=!1);return i}_moveProductsDown(t,e,r){if(e&&e.products.length>0)for(let n of e.products)n.location.y-=r,this._moveProductsDown(t,t.holders.find(i=>i.relatedProduct===n),r)}canDropPegboard(t,e){let r={mounting:void 0,canDrop:!0},n=this.getPegboardSize(e.sourceMounting),i=t.rack.size.w,o=t.rack.size.h,a,c;return n.h!==0&&(a=this.getMountingMaxHeigth(t,e),r.mounting=a,c=a?a.location.y:o,o=c<o?a.type===1?c:c+a.size.h:o),(e.position.x>i||e.position.y+n.h>o)&&(r.canDrop=!1),r}deleteShelf(t,e,r){let n=t.rack.sections[r].holders;for(let i=0;i<n.length;i++)if(n[i]===e){n.splice(i,1);break}}getMountingMaxHeigth(t,e){let r=e.position.y;return t.rack.sections[e.sectionIndexNew].holders.filter(i=>i.type!==-1).find(i=>i.location.y+i.size.h>=r)}getPegboardSize(t){let e={w:0,h:0};return t&&(e.w=t.size.w,e.h=t.size.h),e}getPositionBetween(t,e,r){let n={positionY:0,height:0},i=t.rack.sections[e]?.holders??[];for(let o of i)o.type===1&&o.location.y-o.size.h<=r&&r<=o.location.y+o.size.h&&(n.positionY=o.location.y,n.height=o.size.h);return n}shelfAlingment(t,e,r,n){let i=0,o;if(r>0&&(o=this.getPositionBetween(t,r-1,n)),(!o||o.positionY===0)&&(o=this.getPositionBetween(t,r+1,n)),o&&o.positionY!==0){let a=e.size.h;if(o.height===a)i=o.positionY;else if(a>o.height||a<o.height){let c=a>o.height?a-o.height:o.height-a;i=o.positionY-c}}return i}toBetween(t,e,r,n){return e<=t+n&&t<=r}};var Ct=class s{_gtag;_userService=h(xe);constructor(){this._gtag=typeof gtag=="function"?gtag:()=>{}}trackEvent(t,e){this._gtag("event",t,ke(we({},e??{}),{fecha_hora:vt.now().toFormat("yyyy-MM-dd HH:mm"),user_id:this._userService.user?.email.replaceAll("@","_")}))}trackException(t){this._gtag("event","exception",{fecha_hora:vt.now().toFormat("yyyy-MM-dd HH:mm"),description:t instanceof Error?t.message:String(t),user_id:this._userService.user?.email.replaceAll("@","_"),stack_trace:t instanceof Error?t.stack:void 0})}trackPageView(t){this._gtag("event","page_view",{url:t,fecha_hora:vt.now().toFormat("yyyy-MM-dd HH:mm"),page_title:null,user_id:this._userService.user?.email.replaceAll("@","_")})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var pe=class s extends fn{_analyticsService=h(Ct);static logError(t,e){try{let r=t instanceof Error?{message:t.message,stack:t.stack??""}:{message:t.toString(),stack:""};r.url=window.location.href,r.userAgent=window.navigator.userAgent,e&&(r.extra=e),fetch("api/config/log-error",{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}}).catch()}catch(r){}}handleError(t){super.handleError(t);try{this._analyticsService.trackException(t)}catch(e){}nr.production&&s.logError(t)}static \u0275fac=(()=>{let t;return function(r){return(t||(t=$e(s)))(r||s)}})();static \u0275prov=P({token:s,factory:s.\u0275fac})};var ir=class s extends be{alignProducts(t,e,r,n=!0){let i=t.rack.sections[e],o=i.holders.findIndex(m=>m.name===r&&m.type===1),a=i.holders[o],c=ie(t.rack.sections,e),d=te(t,i.holders,o,c),u=oe(t,a),l=u.length>1&&u[0].sectionIndex===e?u[u.length-1].absoluteX+u[u.length-1].mounting.size.w:c+a.location.x+a.size.w;this._alignProducts({project:t,section:i,shelf:a,sectionLeft:c,products:a.products,x:c+a.location.x,y:a.location.y+a.size.h,maxX:l,maxY:d}),u.length>1&&u[0].sectionIndex===e?s._updateFronts(u[0].mounting,c+u[0].mounting.location.x,l):s._updateFronts(a,c+a.location.x,l),Q(t,e,a),n&&me(t.products)}canDrop(t,e){let r=this._getProductsSize(t,e);if(r.sameShelf)return!0;
1if(r.sameProduct)return!1;if(e.mode===0){if(r.size.w>yt(t,e.mounting)||r.size.h>e.height)return!1}else{let n=tr(e.section.holders,e.mountingIndex,ie(t.rack.sections,e.sectionIndex)),i=n?n.location.y:t.rack.size.h;if(r.size.w>e.mounting.size.w||r.size.h>i)return!1}return!0}createTargets(t,e,r,n,i,o){let a=e.holders[n];if(a.products.length===0)return super.createTargets(t,e,r,n,i,o);let c=a.type===-1,d=[],u=c?a.location.y:a.location.y+a.size.h,l=this._maxYCombined(t,r,n),m=(c?0:i)+a.location.x,C=Math.max(...a.products.map(p=>p.location.x+p.size.w*p.fronts.w)),f=Math.min(...a.products.map(p=>p.location.x)),y=oe(t,a),j=y.length>1?y[y.length-1].absoluteX+y[y.length-1].mounting.size.w:Vn((c?0:i)+a.size.w+a.location.x,2);d.push({x:m,y:u,width:f-m,height:l-u,mode:0,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:a.relatedProduct}),d.push({x:C,y:u,width:j-C,height:l-u,mode:0,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:a.relatedProduct});for(let p of a.products)d.push({x:p.location.x,y:p.location.y,width:.6,height:p.size.h*p.fronts.h,mode:1,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:p});return d}onDrop(t,e){if(e.sameShelf)return this._onSameShelfDrop(t,e);if(!e.product)return pe.logError(new Error("shelf-alignment-center:onDrop data.product is empty"),JSON.stringify(e)),!1;let r=e.target,n=r.mounting,i=n.size,o=e.product,a=!e.fromBasket&&t.rack.sections[e.sectionIndex].holders[e.mountingIndex]===n,c=a?o:le(o),d=a?o.fronts.w:this._getMaxFrontsW(t,r.mode,n,o,a),u;if(a)u=o.fronts.h;else if(r.mode===0)u=Math.trunc(r.height/o.size.h);else{let l=te(t,r.section.holders,r.mountingIndex,ie(t.rack.sections,r.sectionIndex));u=Math.trunc(l/o.size.h)}return this._updateFacings(c,d,u),c.location={x:r.x,y:r.y},this._updateStock(c,i),c.new=!0,n.products.push(c),e.copy||this._deleteProduct(t,e,a),this.alignProducts(t,r.sectionIndex,n.name),n.products.sort((l,m)=>{let C=l.location.y-m.location.y;return C===0?l.location.x-m.location.x:C}),Q(t,r.sectionIndex,n),!0}static _updateFronts(t,e,r){if(t.products.length<=0)return;for(let o=t.products.length-1;o>=0;o--){let a=t.products[o],c=a.location.x+a.size.w*a.fronts.w;(c<e||c>r)&&t.products.splice(o,1)}if(t.products.length<=0)return;let n=t.products[t.products.length-1];if(n.location.x+n.size.w*n.fronts.w>r){let o=Math.ceil((n.location.x+n.size.w*n.fronts.w-r)/n.size.w);n.fronts.w-=o,n.fronts.w<=0&&t.products.splice(t.products.length-1,1)}let i=t.products[0];if(i.location.x<e){let o=Math.ceil((e-i.location.x)/i.size.w);i.fronts.w-=o,i.fronts.w<=0?t.products.splice(0,1):i.location.x+=i.size.w*o}}_alignProducts({project:t,section:e,shelf:r,sectionLeft:n,products:i,x:o,y:a,maxX:c,maxY:d}){if(!i||i.length===0)return;i.sort(We);let u=i.reduce((m,C)=>m+C.size.w*C.fronts.w,0),l=o;o=o+(c-o-u)/2;for(let m of i){m.location.x=o,m.facingSpace={w:0,h:0},m.new||(m.location.y=a),m.new=void 0,m.location.y+m.size.h*m.fronts.h>d&&(m.fronts.h=Math.trunc((d-m.location.y)/m.size.h)),m.dx=m.location.x-(n+r.location.x);let C=e.holders.findIndex(y=>y.relatedProduct===m&&y.type===-1),f=e.holders[C];f&&f.products.length>0&&this._alignProducts({project:t,section:e,shelf:f,sectionLeft:n,products:f.products,x:o,y:m.location.y+m.size.h*m.fronts.h,maxX:o+m.size.w*m.fronts.w,maxY:d}),o+=m.size.w*m.fronts.w}this._removeInvalidProducts(t,i,l,c,d)}_onSameShelfDrop(t,e){let r=[...this._selectedProductsService.selectedProducts].sort((o,a)=>o.product.location.x-a.product.location.x),n=r.reduce((o,a)=>o+se(a.product),0);for(let o of e.sourceMounting.products.filter(a=>a.location.x>=e.target.x))o.location.x+=n;let i=e.target.x;for(let o of r)o.product.location.x=i,i+=se(o.product);return this.alignProducts(t,e.target.sectionIndex,e.target.mounting.name,!0),!0}_removeInvalidProducts(t,e,r,n,i){for(let o=e.length-1;o>=0;o--){let a=e[o];(a.location.y>i||a.fronts.h<=0||a.location.x>n||a.location.x<r)&&t.products.push(...e.splice(o,1))}}};var or=class s{_baseUrl="api/project";_dialogsService=h(Y);_httpClient=h(U);facings(t,e,r,n){return this._httpClient.post(`${this._baseUrl}/${t}/analysis/facings`,{days:e,period:r,margin:n})}salesTree(){return this._httpClient.get(`${this._baseUrl}/analysis/sales/tree`)}salesAggregates(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/analysis/sales/aggregates`,e)}spaceByCriteria(t,e){switch(e.criteria){case 6:delete e.segmentLevel;break;case 2:delete e.segments;break;default:delete e.segments,delete e.segmentLevel}return this._httpClient.post(`${this._baseUrl}/${t}/analysis/space-by-criteria`,e)}
1spaceByCriteriaPdf(t,e,r){let n=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"}),i=`${t.rack.name} - ${t.rack.store} - ${t.rack.category}.pdf`;return this._httpClient.post(`${this._baseUrl}/${t.id}/analysis/space-by-criteria/pdf`,e,{observe:"body",responseType:"arraybuffer",params:{withPrices:(r||!1).toString()}}).pipe(O(o=>new Blob([new Uint8Array(o,0,o.byteLength)])),Gn(i),Kn(i),G({error:o=>this._dialogsService.showErrorSnackbar(o)}),w("download-pdf"),De(()=>n.dismiss()))}spaceOptimization(t,{units:e,sales:r,margin:n,price:i}){return this._httpClient.post(`${this._baseUrl}/${t.id}/analysis/optimization`,{units:e,sales:r,margin:n,price:i,selected:this._getSelectedMountings(t)})}_getSelectedMountings(t){return t.rack.sections.flatMap(e=>e.holders.filter(r=>r.selected).map(r=>({sectionId:e.id,mountingName:r.name})))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var xt=class s{id=crypto.randomUUID();static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var fi=class s{_dialogsService=h(Y);_help=new Map;_langApi=h(qn);_showHelpPanelSubject=new J;_showHelpPanel=!1;_key;showHelpPanel$=this._showHelpPanelSubject.asObservable();get showHelpPanel(){return this._showHelpPanel}set showHelpPanel(t){this._showHelpPanel=t}load(t){this._key=t}showModal(){this._key&&this._getHelpText().subscribe({next:t=>{this._dialogsService.showModal(ae.helpNew(),{width:"75vw",data:t,autoFocus:"dialog"}).subscribe()}})}getHelpText(){return this._getHelpText(!1)}triggerHelpPanel(){if(this._key)switch(this._key){case"project":case"rack":case"analysis":this._showHelpPanelSubject.next();break;default:this.showModal()}}_getHelpText(t=!0){let e=`help.${this._key}`,r=`${e}.${this._langApi.current}`;return this._help.has(r)?E(this._help.get(r)):(t&&this._dialogsService.showLoadingModal(),this._langApi.getTranslationForKey(e).pipe(G({next:n=>this._help.set(r,n)}),he(()=>E("")),De(()=>this._dialogsService.hideLoadingModal())))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var sr=class s{altPressed;ctrlPressed;keyDown;keyPress;keyUp;shiftPressed;_isShiftPressed;constructor(){let t=h(it),e=new J,r=new J,n=new J;this.altPressed=e.pipe(nt()),this.ctrlPressed=r.pipe(nt()),this.shiftPressed=n.pipe(nt());let i=new J,o=new J;this.keyPress=i.pipe(Z(a=>!a.repeat)),this.keyDown=i.asObservable(),this.keyUp=o.asObservable(),Nt(Ee(t,"keydown"),Ee(t,"keyup")).subscribe({next:a=>{e.next(a.altKey),r.next(a.ctrlKey),n.next(a.shiftKey),this._isShiftPressed=a.shiftKey,a.type==="keydown"&&i.next(a),a.type==="keyup"&&o.next(a)}})}get isShiftPressed(){return this._isShiftPressed}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var _i=class s{mouseMove;mouseUp;touchEnd;touchMove;constructor(){let t=h(it);this.mouseUp=Ee(t,"mouseup"),this.mouseMove=Ee(t,"mousemove"),this.touchEnd=Ee(t,"touchend"),this.touchMove=Ee(t,"touchmove")}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var bi=class s{_messages=new J;messages$=this._messages.asObservable();connected=X(!1);_clientInstance=h(xt);_eventSource;_currentProjectId;connect(t){this._currentProjectId===t&&this._eventSource||(this.disconnect(),this._currentProjectId=t,this._eventSource=new EventSource(`api2/project/${t}/events`,{withCredentials:!0}),this._eventSource.onopen=()=>this.connected.set(!0),this._eventSource.onerror=()=>this.connected.set(!1),this._eventSource.onmessage=e=>{let r=JSON.parse(e.data);r.originClientId&&r.originClientId===this._clientInstance.id||this._messages.next(r)})}disconnect(){this._eventSource?.close(),this._eventSource=void 0,this._currentProjectId=void 0,this.connected.set(!1)}ngOnDestroy(){this.disconnect()}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var ar=class s{combinedShelfs=X(q("showCombinedShelfs",!1));comments=X(q("showComments",!1));grid=X(q("showGrid",!0));hideReadComments=X(q("hideReadComments",!1));images=X(q("showImages",!0));librartyProducts=X(q("showLibraryProducts",!1));numbering=X(q("showNumbering",!1));prices=X(q("showPriceTags",!1));rackImages=X(q("rackImages",!0));rulers=X(q("showRuler",!0));visualElements=X(q("showVisualElements",!0));_dialogsService=h(Y);
1_forceShowPageHeaderChangeSubject=new ve(!1);_skusChange=new ot;_unitApiService=h(cr);_unitChange=new ot(!0);_units$;_userApiService=h(rr);_userService=h(xe);_zoom=X(q("zoom",100));_zoomRO=this._zoom.asReadonly();_forceShowPageHeader=!1;constructor(){this._units$=this._unitApiService.all(),ce(()=>ee("showCombinedShelfs",this.combinedShelfs())),ce(()=>ee("showComments",this.comments())),ce(()=>ee("showGrid",this.grid())),ce(()=>ee("hideReadComments",this.hideReadComments())),ce(()=>ee("showImages",this.images())),ce(()=>ee("showLibraryProducts",this.librartyProducts())),ce(()=>ee("showNumbering",this.numbering())),ce(()=>ee("showPriceTags",this.prices())),ce(()=>ee("rackImages",this.rackImages())),ce(()=>ee("showRuler",this.rulers())),ce(()=>ee("showVisualElements",this.visualElements())),ce(()=>ee("zoom",this._zoom()))}get forceShowPageHeader(){return this._forceShowPageHeader}set forceShowPageHeader(t){this._forceShowPageHeader=t,this._forceShowPageHeaderChangeSubject.next(t)}get forceShowPageHeaderChange(){return this._forceShowPageHeaderChangeSubject.asObservable()}get skus(){return q("showSkus",!1)}set skus(t){ee("showSkus",t),this._skusChange.emit(t)}get skusChange(){return this._skusChange.asObservable()}get unit(){return this._userService.user.unit.id}set unit(t){let e=this._userService.user.unit;this._units$.pipe(D(r=>(this._userService.user.unit=r.find(n=>n.id===t),this._unitChange.emit(this._userService.user.unit),this._userApiService.updateUnit(t)))).subscribe({error:r=>{this._userService.user.unit=e,this._unitChange.emit(this._userService.user.unit),this._dialogsService.showErrorSnackbar(r)}})}get unitChange(){return this._unitChange.asObservable()}get zoom(){return this._zoomRO}setZoom(t){t>1e3?t=1e3:t<10&&(t=10),this._zoom.set(t)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var vi=class s{_context;clear(){this._context=void 0}getContext(){return this._context}setContext(t){this._context=t}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};function Gi(s,t){let e="";return s&&(s.cfn!==null?(e+=`<div>${t.instant("project.analysis.stock-days",{value:s.stockDays||0})}</div>`,e+=`<div>${t.instant("project.analysis.fronts.cfn",{value:s.cfn})}</div>`):e+=`<div>${t.instant("project.analysis.fronts.no-data",{value:s.cfn})}</div>`),e}function Wi(s,t,e){let r="";if(t)if(r+=`<div>${s.instant("project.analysis.optimization.mix.tooltip.space",{espacio:(t.area*100).toFixed(2)})}</div>`,t.relation){let n=(t.units*100).toFixed(2),i=(t.sales*100).toFixed(2),o=(t.marginp*100).toFixed(2),a=(t.margins*100).toFixed(2),c=(t.units*e?.perUnits+t.sales*e?.perSales+t.marginp*e?.perMarginPercent+t.margins*e?.perMarginPrice).toFixed(2);t.units!==void 0&&t.sales!==void 0&&t.marginp!==void 0&&t.margins!==void 0?r+=`<div>${s.instant("project.analysis.optimization.mix.tooltip.all",{unidades:n,facturacion:i,margen_p:o,margen_v:a,promedio:c})}</div>`:t.units!==void 0?r+=`<div>${s.instant("project.analysis.optimization.mix.tooltip.units",{unidades:n})}</div>`:t.sales!==void 0?r+=`<div>${s.instant("project.analysis.optimization.mix.tooltip.sales",{facturacion:i})}</div>`:t.marginp!==void 0?r+=`<div>${s.instant("project.analysis.optimization.mix.tooltip.marginp",{margen_p:o})}</div>`:t.margins!==void 0&&(r+=`<div>${s.instant("project.analysis.optimization.mix.tooltip.margins",{margen_v:a})}</div>`)}else r+=`<div>${s.instant("project.analysis.fronts.no-data")}</div>`;return r}function qi(s){let{tooltip:t,product:e,projectTotalStock:r,productTotalAdjustedCapacity:n,projectTotalAdjustedCapacity:i,totalFacings:o,sales:a,extra:c,periodDays:d,translateService:u,frontsAnalysis:l,optimizationAnalysis:m,spaceAnalysisForm:C,units:f,unitsTotal:y,salesTotals:j}=s,p=t,et=s.productStock??0,kt=a?.units??0,jt=a?.sales??0,Mt=a?.margin??0,tt=a?.newPrice??0,Ft=1-Mt/100;p=p.replace(/\n/g,"<br />"),p=p.replace(/\r/g,"");let wr=p.match(/{[^}]+}/g);if(wr&&wr.length>0)for(let x of wr)switch(x){case"{product_upc}":p=p.replace(x,e.code);break;case"{product_sku}":p=p.replace(x,e.sku??"");break;case"{product_description}":p=p.replace(x,e.name);break;case"{product_brand}":p=p.replace(x,e.brand??"");break;case"{product_brandkind}":p=p.replace(x,e.brandKind??"");break;case"{product_manufacturer}":p=p.replace(x,e.manufacturer??"");break;case"{product_width}":p=p.replace(x,e.size.w.toString());break;case"{product_height}":p=p.replace(x,e.size.h.toString());break;case"{product_depth}":p=p.replace(x,e.size.d.toString());break;case"{product_unit}":p=p.replace(x,e.units??"");break;case"{product_compression_h}":p=p.replace(x,e.compression.h.toString());break;case"{product_compression_w}":p=p.replace(x,e.compression.w.toString());break;case"{product_compression_d}":p=p.replace(x,e.compression.d?.toString()??"");break;case"{product_fronts_h}":p=p.replace(x,e.fronts.w.toString());break;case"{product_fronts_v}":p=p.replace(x,e.fronts.h.toString());break;case"{product_fronts_d}":p=p.replace(x,e.fronts.d?.toString()??"");break;case"{product_fronts}":p=p.replace(x,(e.fronts.h*e.fronts.w).toString());break;case"{product_fronts_total}":p=p.replace(x,o?.toString()??"");break;case"{product_fronts_presentation}":p=p.replace(x,u.instant(e.isCase?"product.size.case":"product.size.unit"));break;case"{product_fronts_orientation}":p=p.replace(x,di(e,u));break;case"{product_project_compression_h}":p=p.replace(x,e.projectCompression.h.toString());break;case"{product_project_compression_w}":p=p.replace(x,e.projectCompression.w.toString());break;case"{product_project_compression_d}":p=p.replace(x,e.projectCompression.d?.toString()??"");break;case"{product_case_width}":p=p.replace(x,e.caseSize?.w.toString()??"");break;case"{product_case_height}":p=p.replace(x,e.caseSize?.h.toString()??"");break;case"{product_case_depth}":p=p.replace(x,e.caseSize?.d?.toString()??"");break;case"{product_caseunits}":p=p.replace(x,e.caseUnits?.toString()??"");break;case"{product_case_front_w}":p=p.replace(x,e.caseFacings?.w?.toString()??"");break;case"{product_case_front_h}":p=p.replace(x,e.caseFacings?.h?.toString()??"");break;case"{product_case_front_d}":p=p.replace(x,e.caseFacings?.d?.toString()??"");break;case"{product_category}":p=p.replace(x,c?.categories[0]??"");break;case"{product_subcategory1}":p=p.replace(x,c?.categories[1]??"");break;case"{product_subcategory2}":p=p.replace(x,c?.categories[2]??"");break;case"{product_subcategory3}":p=p.replace(x,c?.categories[3]??"");break;case"{product_subcategory4}":p=p.replace(x,c?.categories[4]??"");break;case"{product_units}":p=p.replace(x,a?.units?.toString()??"");break;case"{product_sales}":p=p.replace(x,a?.sales?.toString()??"");break;case"{product_margin}":p=p.replace(x,a?.margin?.toString()??"");break;case"{product_stock_total}":case"{product_capacity}":case"{product_capacity_total}":case"{product_quantityunits_total}":p=p.replace(x,y?.toString()??"");break;case"{product_total_stock}":p=p.replace(x,r?.toString()??"");break;case"{product_quantityunits}":p=p.replace(x,f?.toString()??"");break;case"{product_stock_store}":case"{product_stock}":p=p.replace(x,et?.toString()??"N/D");break;case"{product_newprice}":case"{product_price}":p=p.replace(x,a?.newPrice?.toString()??"");break;case"{product_analysis_case}":case"{product_analysis_case2}":case"{product_analysis_case3}":case"{product_analysis_case4}":break;case"{producto_capacidad_porcentaje}":{let F=i&&i!==0?n/i*100:null;p=p.replace(x,F===null?"-":Number(F.toFixed(4)).toString())}break;case"{producto_dias_cantidad_unidades}":if(kt>0&&d>0){let F=n/(kt/d);p=p.replace(x,Number(F.toFixed(2)).toString())}else p=p.replace(x,"-");break;case"{producto_capacidad_compra}":{let F=n*tt*Ft;p=p.replace(x,Number(F.toFixed(2)).toString())}break;case"{producto_capacidad_venta}":{let F=n*tt;p=p.replace(x,Number(F.toFixed(2)).toString())}break;case"{producto_gmroi_capacidad}":{let F=n*tt*Ft,Ie=F===0?null:jt*Mt/100/F;p=p.replace(x,Ie===null?"-":Number(Ie.toFixed(2)).toString())}break;case"{producto_stock_porcentaje}":{let F=r&&r!==0?et/r*100:null;p=p.replace(x,F===null?"-":Number(F.toFixed(2)).toString())+"%"}break;case"{producto_dias_stock}":if(d>0&&kt>0){let F=et/(kt/d);p=p.replace(x,Number(F.toFixed(2)).toString())}else p=p.replace(x,"-");break;case"{producto_costo_stock_compra}":{let F=et*tt*Ft;p=p.replace(x,Number(F.toFixed(2)).toString())}break;case"{producto_costo_stock_venta}":{let F=et*tt;p=p.replace(x,Number(F.toFixed(2)).toString())}break;case"{producto_gmroi_stock}":{let F=et*tt*Ft,Ie=F===0?null:jt*Mt/100/F;p=p.replace(x,Ie===null?"-":Number(Ie.toFixed(2)).toString())}break;case"{producto_facturacion_porcentaje}":{let F=j?.sales?(jt??0)/j.sales*100:null;p=p.replace(x,F===null?"-":Number(F.toFixed(2)).toString())}break;case"{producto_margen_porcentaje}":{let F=(jt??0)*(Mt??0)/100,Ie=j?.margin?F/j.margin*100:null;p=p.replace(x,Ie===null?"-":Number(Ie.toFixed(2)).toString())}break;case"{producto_margen_valor}":{let F=(jt??0)*(Mt??0)/100;p=p.replace(x,Number(F.toFixed(2)).toString())}break;case"{producto_unidades_porcentaje}":{let F=j?.units?(kt??0)/j.units*100:null;p=p.replace(x,F===null?"-":Number(F.toFixed(2)).toString())}break;case"{product_result_analysis}":l?p=p.replace("{product_result_analysis}",Gi(l,u)):m?p=p.replace("{product_result_analysis}",Wi(u,m,C)):p=p.replace("{product_result_analysis}","");break}return p}var Ba=s=>s==null?"":s.logo?`<img src="${s.logo}" />`:s.businessName,Va=s=>{let t="";return s.imageFront&&(t=`<div><img src="${s.imageFront}" alt="" /></div>`),`<div class='container-product-tooltip'> 2 ${t} 3 <div>${qi(s)}</div> 4 </div>`},Jr={es:`{product_upc} - {product_sku} 5{product_description} 6Frentes actuales: {product_fronts_total} - Capacidad: {product_quantityunits} 7Stock real: {product_total_stock} - Precio: {product_price} 8{product_result_analysis}`,en:`{product_upc} - {product_sku} 9{product_description} 10Current facings: {product_fronts_total} - Stock capacity: {product_quantityunits} 11Stock on hand: {product_total_stock} - Price: {product_price} 12{product_result_analysis}`,pt:`{product_upc} - {product_sku} 13{product_description} 14Frentes atuais: {product_fronts_total} - Estoque t\xE9orico: {product_quantityunits} 15Stock real: {product_total_stock} - Pre\xE7o: {product_price} 16{product_result_analysis}`,fr:`{product_upc} - {product_sku} 17{product_description} 18Facings actuels: {product_fronts_total} - Stock th\xE9orique: {product_quantityunits} 19Stock: {product_total_stock} - Prix: {product_price} 20{product_result_analysis}`},Zr={es:`{product_upc} - {product_sku} 21{product_description} 22{product_fronts} frentes - Capacidad: {product_quantityunits} 23Stock real: {product_total_stock} - Precio: {product_price}`,en:`{product_upc} - {product_sku} 24{product_description} 25{product_fronts} facings - Stock capacity: {product_quantityunits} 26Stock on hand: {product_total_stock} - Price: {product_price}`,pt:`{product_upc} - {product_sku} 27{product_description} 28{product_fronts} frentes - Estoque t\xE9orico: {product_quantityunits} 29Stock: {product_total_stock} - Pre\xE7o: {product_price}`,fr:`{product_upc} - {product_sku} 30{product_description} 31{product_fronts} facings - Stock th\xE9orique: {product_quantityunits} 32Stock: {product_total_stock} - Prix: {product_price}`};var yi="tooltip.analysis",Ci="tooltip.product",xi="tooltip.salesPeriod",Pi=class s{_translateService=h(Le);
32_tooltipAnalysis;_tooltipProduct;_tooltipSalesPeriod;constructor(){let t=q("user")?.languageId??this._translateService.currentLang??"en";this._tooltipAnalysis=q(yi,Jr[t]),this._tooltipProduct=q(Ci,Zr[t]),this._tooltipSalesPeriod=q(xi,1)}get analysis(){return this._tooltipAnalysis}set analysis(t){if((t??"").trim().length===0){let e=q("user")?.languageId??this._translateService.currentLang??"en";t=Jr[e]}this._tooltipAnalysis=t,ee(yi,t)}get product(){return this._tooltipProduct}set product(t){if((t??"").trim().length===0){let e=q("user")?.languageId??this._translateService.currentLang??"en";t=Zr[e]}this._tooltipProduct=t,ee(Ci,t)}get salesPeriod(){return this._tooltipSalesPeriod}set salesPeriod(t){this._tooltipSalesPeriod=t??1,ee(xi,this._tooltipSalesPeriod)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Xi=["api/project","api/rack","api/product"],fc=(s,t)=>{let e=h(Ct),r=s.params.toString();return Xi.some(n=>s.url.startsWith(n))?t(s).pipe(G({next:n=>{n.type===On.Response&&e.trackEvent("http_request",{method:s.method,url:s.url,params:r,status:n.status})},error:n=>{e.trackEvent("http_request",{method:s.method,url:s.url,params:r,status:n.status})}})):t(s)};var yc=(s,t)=>{let e=h(xt);return t(s.clone({setHeaders:{"X-Client-Instance-Id":e.id}}))};var Si=class s{_baseUrl="api2/corporate/message";_httpClient=h(U);all(t,e,r){let n=new ut;n=n.set("admin",r),t&&(n=n.set("sort",t)),e&&(n=n.set("filter",e));let i=n.keys().length>0?{params:n}:{};return this._httpClient.get(`${this._baseUrl}`,i)}get(t,e){let r={admin:e};return this._httpClient.get(`${this._baseUrl}/${t}`,{params:r})}getMe(t){return this._httpClient.get(`${this._baseUrl}/${t}/me`)}upsert(t,e,r,n,i,o){let a=new FormData;a.append("title",t.title),a.append("content",t.content),a.append("allow_likes",t.allowLike),a.append("allow_comments",t.allowComment),a.append("admin",e.toString()),t.published&&a.append("published",t.published),r.forEach(d=>{a.append("images",d)}),n.forEach(d=>{a.append("attachments",d)}),o&&o.length>0&&o.forEach(d=>{a.append("corporateFiles",d)});let c=i?{params:{messageid:i}}:{};return this._httpClient.post(`${this._baseUrl}`,a,c)}delete(t,e){let r={admin:e};return this._httpClient.delete(`${this._baseUrl}/${t}`,{params:r})}share(t,e){let r={listLabel:e.map(n=>({Idlabel:n}))};return this._httpClient.post(`${this._baseUrl}/${t}/share`,r)}markPublished(t){return this._httpClient.post(`${this._baseUrl}/${t}/publish`,null)}shareGet(t){return this._httpClient.get(`${this._baseUrl}/${t}/share`)}sharedRemove(t,e){return this._httpClient.delete(`${this._baseUrl}/${e}/share/${t}`)}imageDelete(t,e){return this._httpClient.delete(`${this._baseUrl}/${t}/image/${e}`)}attachmentDelete(t,e,r,n){return this._httpClient.delete(`${this._baseUrl}/${t}/file/${e}`,{params:{corporateFile:r,admin:n}})}commentUpsert(t,e,r){let n={comment:e,isCorporate:r};return this._httpClient.post(`${this._baseUrl}/${t}/comment`,n)}like(t,e){let r={liked:e};return this._httpClient.post(`${this._baseUrl}/${t}/likes`,null,{params:r})}maskRead(t){return this._httpClient.post(`${this._baseUrl}/${t}/comment/read`,null)}download(t,e){let r={admin:e};return this._httpClient.get(`${this._baseUrl}/files/${t.id}/download`,{params:r,responseType:"blob"}).pipe(K(t.filename),w("downloadfile"))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var wi=class s{_httpClient=h(U);_all$;all(){return this._all$||(this._all$=this._httpClient.get("api/country").pipe(Ye({bufferSize:1,refCount:!1})))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var ki=class s extends $n{static cache=new Nr(()=>"no-cache");static useXhr=new Nr(()=>!1);_canUseWorkers;constructor(){let t=h(En);super(t),this._canUseWorkers="Worker"in window&&typeof window.Worker=="function"}handle(t){return this._canUseWorkers===!1||nr.disableWorkers||t.context.get(s.useXhr)||t.body instanceof FormData?super.handle(t):this._worker(t)}_convertHeaders(t){let e={};
32if(t.headers.keys().forEach(r=>{e[r]=t.headers.get(r)}),e.Accept||(e.Accept="application/json, text/plain, */*"),!e["Content-Type"]){let r=t.detectContentTypeHeader();r!==null&&(e["Content-Type"]=r)}return e}_worker(t){return new mn(e=>{let r=new Worker(new URL("worker-LXTNNFKI.js",import.meta.url),{type:"module"});return r.addEventListener("message",n=>{let i=n.data;i.status>=200&&i.status<300?e.next(new Dn({body:i.body,headers:new Rr(i.headers),status:i.status,statusText:i.statusText,url:i.url})):e.error(new zr({error:i.body,headers:new Rr(i.headers),status:i.status,statusText:i.statusText,url:i.url})),i.type==="response"&&(e.complete(),r.terminate(),r=void 0)}),r.addEventListener("error",n=>{e.error(new zr({error:n,status:0,statusText:"Unknown Error",url:t.url})),r.terminate(),r=void 0}),r.postMessage({url:t.url,body:t.serializeBody(),headers:this._convertHeaders(t),context:null,reportProgress:t.reportProgress,withCredentials:t.withCredentials,responseType:t.responseType,method:t.method,params:null,urlWithParams:t.urlWithParams,caches:t.context.get(s.cache)}),()=>{r&&r.postMessage("abort")}})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var ji=class s{_baseUrl="api/lang";
32_changedSubject=new Ut(1);_dateAdapter=h(Yn);_httpClient=h(U);_translate=h(Le);_all$;_portalLinks$;get current(){return this._translate.currentLang}set current(t){t!=="es"&&t!=="en"&&t!=="pt"&&t!=="fr"||t!==this.current&&(this._translate.use(t).subscribe({next:()=>this._changedSubject.next(t)}),this._dateAdapter.setLocale(t),Wn.defaultLocale=t)}get languageChanged(){return this._changedSubject.asObservable()}all(){return this._all$||(this._all$=this._httpClient.get(this._baseUrl).pipe(Ye({bufferSize:1,refCount:!1})))}allSections(){return this._httpClient.get(`${this._baseUrl}/sections`)}fromBrowser(){return this._httpClient.post(`${this._baseUrl}/match`,navigator.languages)}getTranslationForKey(t){return this._httpClient.get(`${this._baseUrl}/${this.current}`,{params:{key:t}}).pipe(w("get-translation"))}portalLinks(){return this._portalLinks$||(this._portalLinks$=this._httpClient.get(`${this._baseUrl}/portal/${this.current}`).pipe(Ye({bufferSize:1,refCount:!1})))}reload(t){this._translate.reloadLang(t).subscribe()}translations(t,e){return this._httpClient.get(`${this._baseUrl}/${t}`,{params:new ut({fromObject:{section:e}})})}update(t,e,r){return this._httpClient.post(`${this._baseUrl}/${e}`,{id:t,text:r})}updateTranslation(t,e){this._translate.set(t,e)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Mi=class s{_baseUrl="api/notification";_httpClient=h(U);all(){return this._httpClient.get(this._baseUrl)}get(t){return this._httpClient.get(`${this._baseUrl}/${t}`)}getVariables(t){return this._httpClient.get(`${this._baseUrl}/${t}/variables`)}sendComments(t){let e=new FormData;return e.append("name",t.name),e.append("email",t.email),e.append("business",t.business),e.append("country",t.country),e.append("comments",t.comments),e.append("captcha",t.captcha),e.append("language",t.language),e.append("isSupport",t.isSupport.toString()),t.file&&e.append("file",t.file),this._httpClient.post(`${this._baseUrl}/sendComments`,e)}update(t){return this._httpClient.post(`${this._baseUrl}/${t.id}`,t)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var lr=class s{_baseUrl="api/config";_httpClient=h(U);getParameter(t){return this._httpClient.get(`${this._baseUrl}/getparameter/${encodeURI(btoa(t))}`)}getStripeKey(){return this._httpClient.get(`${this._baseUrl}/stripe`)}parameters(){return this._httpClient.get(this._baseUrl).pipe(O(t=>(Object.entries(t).forEach(e=>
32{e[1].forEach(r=>{switch(r.type){case 1:case 6:r.value=Number(r.value);break;case 8:r.value=r.value==="True";break}})}),t)))}updateParameter(t,e){return this._httpClient.post(this._baseUrl,{label:t,value:e.toString()})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var dr=class s{_baseUrl="api/pdfconfiguration";_httpClient=h(U);all({userId:t,page:e,pageSize:r,sort:n}){let i={page:e.toString(),pageSize:r.toString(),sort:n};return t&&(i.userId=t),this._httpClient.get(this._baseUrl,{params:i}).pipe(w("pdfconfiguration"))}copy(t,e){let r={userid:e};return this._httpClient.post(`${this._baseUrl}/${t}/copy`,null,{params:r})}delete(t,e){let r={userid:e};return this._httpClient.delete(`${this._baseUrl}/${t}`,{params:r})}get(t){return this._httpClient.get(`${this._baseUrl}/${t}`).pipe(w("pdfconfiguration"))}getPdfConfigToExport(t){return this._httpClient.get(`${this._baseUrl}/${t}/export`).pipe(w("pdfconfiguration"))}getPdfConfiguracion(t=!1,e){return this._httpClient.get(`${this._baseUrl}/export/getPdfConf`,{params:{includeCorporate:t,userid:e}})}pageType(){return this._httpClient.get(`${this._baseUrl}/pagetype`).pipe(w("pdfConfiguration"))}update(t,e){return this._httpClient.put(`${this._baseUrl}/${t}`,e)}upsert(t){return this._httpClient.post(`${this._baseUrl}`,t)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Ti=class s{_baseUrl="api/product";_httpClient=h(U);createVersion(t,e){return this._httpClient.put(`${this._baseUrl}/create-version`,t,{params:{updateLibrary:e}})}deleteProduct(t,e){return this._httpClient.post(`${this._baseUrl}/delete`,{projectId:t,productId:e})}deleteProducts(t,e,r){return this._httpClient.post(`${this._baseUrl}/products/delete`,{projectId:t,codes:e,isCorporate:r})}exportExcel(t){return this._httpClient.post(`${this._baseUrl}/sync-library/export/excel`,t,{responseType:"blob"}).pipe(K("DesynchronizedProjects.xlsx"),w("download-excel"))}get(t){return this._httpClient.get(`${this._baseUrl}/${t}`)}getAllByUserID(t,e,r,n,i,o,a,c,d,u){let l=n===""?null:n,m=i===""?null:i;return this._httpClient.post(`${this._baseUrl}/getbyuserid/`,{userId:t,page:e,pageSize:r,criteria:l,segmentation:m,category:o,type:a,sort:c,projectid:u,segmentId:d}).pipe(w("getAllByUserID"))}getCategories(t,e){let r={};return t&&(r.userId=t),e&&(r.filter=e),this._httpClient.get(`${this._baseUrl}/library/categories`,{params:r}).pipe(w("getCategories"))}getImageVersions(t,e){return this._httpClient.get(`${this._baseUrl}/${qe(t)}/image/all/${e}`)}getLastCertified(){return this._httpClient.get(`${this._baseUrl}/last-certified`)}getLastUsed(t){return this._httpClient.get(`${this._baseUrl}/last-used/${t}`)}getManufacturerProducts({id:t,filter:e,page:r,pageSize:n,sort:i}){let o={page:r.toString(),pageSize:n.toString(),sort:i};return e&&e.trim().length>0&&(o.filter=e.trim()),this._httpClient.get(`${this._baseUrl}/manufaturers/${t}`,{params:o}).pipe(w("manufacturer-products"))}getVersion(t,e){return this._httpClient.get(`${this._baseUrl}/${qe(t)}/${e}`).pipe(w("product.getVersion"))}getVersionId(t){return this._httpClient.get(`${this._baseUrl}/Id/${t}`)}getVersions(t){return this._httpClient.get(`${this._baseUrl}/${qe(t)}/all`).pipe(w(`${t}_versions`))}insertLibrary(t){return this._httpClient.post(`${this._baseUrl}/insert-certified/${t}`,null)}isProductOwner(t){return this._httpClient.get(`${this._baseUrl}/id/${t}/is-owner`)}resetLibrary(t){return this._httpClient.post(`${this._baseUrl}/reset-library/${t}`,null)}salesAggregates(t){return this._httpClient.post(`${this._baseUrl}/sales/aggregates`,t)}searchByBrand(t){return this._httpClient.get(`${this._baseUrl}/search`,{params:{brand:t}}).pipe(he(()=>E([])))}searchByCode(t){return this._httpClient.get(`${this._baseUrl}/search`,{params:{code:t}}).pipe(he(()=>E([])))}share(t,e){return this._httpClient.post(`${this._baseUrl}/share`,{codes:t,users:e})}shareGet(t,e){return this._httpClient.get(`${this._baseUrl}/share/${qe(e)}/${t}`)}shareGetUsers(t){let e=[];
32return t instanceof Array?e=t:e.push(t),this._httpClient.post(`${this._baseUrl}/share/users`,e)}syncLibProductWithProject(t,e){return this._httpClient.get(`${this._baseUrl}/sync-from-library/${t}`,{params:{updateLibrary:e}})}syncProductToLibrary(t){return this._httpClient.post(`${this._baseUrl}/sync-library/${t}`,null)}syncProductToLibraryByCode(t,e,r,n){return this._httpClient.post(`${this._baseUrl}/sync-library/${t}/bycode`,{code:e,version:r,updateLibrary:n})}unshareAll(t,e){return this._httpClient.post(`${this._baseUrl}/unshareall`,{email:e,projectid:t})}updateCertified(t,e){return this._httpClient.put(`${this._baseUrl}/${t}/certify`,void 0,{params:{certified:e}})}updateLastUsed(t,e){return this._httpClient.put(`${this._baseUrl}/last-used/${t??"me"}/${e}`,void 0)}uploadImage(t,e,r){let n=new FormData;return n.append("file",e,e.name),this._httpClient.post(`${this._baseUrl}/${qe(t)}/image/${r}`,n)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Pe=class s{_baseUrl="api/project";_baseUrlProducts="api/product";_dialogsService=h(Y);_httpClient=h(U);_projectHelper=h(Pt);_router=h(ft);_routerEx=h(bt);_user=h(xe);addProductListToProject(t,e,r){return this._httpClient.post(`${this._baseUrlProducts}/addProductListToProject/${t}/${e}`,r)}all({page:t,pageSize:e,sort:r,filter:n,user:i}){let o={page:t.toString(),pageSize:e.toString()};return r&&(o.sort=r),n.name&&(o.name=n.name),n.sharedBy&&(o.sharedBy=n.sharedBy),n.store&&(o.store=n.store),n.category&&(o.category=n.category),n.folder&&(o.parentId=n.folder),n.product&&(o.product=n.product),i&&(o.user=i),o.viewproject=n.viewProjects===!0?"1":"0",o.models=n.models===!0?"1":"0",this._httpClient.get(this._baseUrl,{params:o}).pipe(w("projects"))}allMaster(t){return this._httpClient.get(`${this._baseUrl}/projects-master`,{params:{folderId:t}}).pipe(w("projects"))}allNavPdv(t){return this._httpClient.get(`${this._baseUrl}/${t}/list/pdvs`)}allPdvs(t){return this._httpClient.get(`${this._baseUrl}/${t}/pdvs`)}assortmentExportExcel(t){return this._httpClient.get(`${this._baseUrl}/${t}/export-excel`,{responseType:"blob"}).pipe(K("ProductExport.xlsx"),w("ProductExport"))}assortmentGetProducts(t){return this._httpClient.get(`${this._baseUrl}/${t}/products`)}assortmentImportExcel({id:t,file:e,option:r}){let n={addProd:r.addProduct,updProd:r.updateProduct,delProd:r.deleteProduct};return this._httpClient.post(`${this._baseUrl}/${t}/import-excel/${r.type}`,_e({file:e}),{params:n})}attachmentDelete(t){return this._httpClient.delete(`${this._baseUrl}/${t}/attachment`)}attachmentDownload(t,e){return this._httpClient.get(`${this._baseUrl}/${t}/attachment`,{responseType:"blob"}).pipe(K(e),w("download-attachment"))}attachmentGet(t){return this._httpClient.get(`${this._baseUrl}/${t}/has-attachment`)}attachmentUpload(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/attachment`,_e({file:e}),{observe:"events",reportProgress:!0})}batchShare(t,e){return this._httpClient.post(`${this._baseUrl}/share`,ke(we({},e),{projectIds:t}))}byPdv(t,e){let r={idFolder:e};return this._httpClient.get(`${this._baseUrl}/${t}/bypdv`,{params:r}).pipe(n=>n)}chain(t){return this._httpClient.get(`${this._baseUrl}/${t}/chain`).pipe(G(e=>Qt(`chain_${t}`,e)))}commentDelete(t,e){return this._httpClient.delete(`${this._baseUrl}/${t}/comments/${e}`)}commentRead(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/comments/${e}/read`,void 0).pipe(O(r=>{let n=JSON.parse(r);for(let i of n)i.date=vt.fromISO(i.date,{zone:"utc"}).toLocal().toJSDate();return n}))}commentUnread(t){return this._httpClient.get(`${this._baseUrl}/${t}/comments/unread`)}commentUpsert(t){return this._httpClient.post(`${this._baseUrl}/${t.projectId}/comments`,{comments:t.comments,productCode:t.productCode,id:t.id,selectedPdvs:t.selectedPdvs})}comments(t,e){return this._httpClient.get(`${this._baseUrl}/${t}/comments`,{params:e?{lastUpdate:e?.toISOString()}:void 0}).pipe(O(r=>(this._convertDates(r),r)))}commentsAll(t,e,r){return this._httpClient.get(`${this._baseUrl}
32/commentsAll`,{params:{page:t,pageSize:e,filter:r}}).pipe(O(n=>(this._convertDatesNotification(n.results),n)))}commentsCount(){return this._user.userToken?this._httpClient.get(`${this._baseUrl}/CommentsCount`):E(0)}copyDemo(t){let e=this._dialogsService.showSnackbar({message:"project.copy.progress",config:{verticalPosition:"top"}});return this._httpClient.post(`${this._baseUrl}/demo/${t}`,void 0).pipe(G({error:r=>{e.dismiss(),this._dialogsService.showErrorSnackbar(r)},complete:()=>e.dismiss()}))}copyFolder(t){return this._httpClient.post(`${this._baseUrl}/folders/${t}/copy`,null)}copyProductsBatch(t,e,r){let n;return e&&(n={projectId:e,timestamp:encodeURIComponent(r)}),this._httpClient.post(`${this._baseUrlProducts}/batch-copy`,_e({file:t}),{params:n})}copyProject(t,e,r,n,i,o,a){let c=this._dialogsService.showSnackbar({message:"project.copy.progress",config:{verticalPosition:"top"}}),d={name:e,type:r.toString(),copyPDVs:n,reverseProject:i,fromAdmin:o},u;return this._httpClient.post(`${this._baseUrl}/${t}/copy`,void 0,{params:d}).pipe(G({next:l=>u=l,error:l=>{c.dismiss(),this._dialogsService.showErrorSnackbar(l)},complete:()=>{if(c.dismiss(),a&&u){let l=this._routerEx.segments[this._routerEx.segments.length-1].toLowerCase(),m=["my-projects",u];(l==="rack"||l==="analysis")&&m.push(l),this._router.navigate(m)}}}))}copyProjectNewName(t){return this._httpClient.post(`${this._baseUrl}/${t}/copy/new-name`,void 0)}copyRackImage(t){let e=t.replace("project/rack-image/","");return this._httpClient.post(`${this._baseUrl}/rack-image/copy/${e}`,void 0).pipe(O(r=>`project/rack-image/${r}`))}delete(t){return this._httpClient.delete(`${this._baseUrl}/${t}`)}emptyTrash(t){return this._httpClient.delete(`${this._baseUrl}/folders/trash`,{params:t?{userId:t}:void 0})}folderCreate({parentFolderId:t,folderName:e,ownerId:r,folderType:n}){let i={folderName:e};return t&&(i.parentId=t),r&&(i.userId=r),n&&(i.special=n.toString()),this._httpClient.post(`${this._baseUrl}/folders`,void 0,{params:i})}folderDelete(t,e){return this._httpClient.delete(`${this._baseUrl}/folders/${t}/${e}`)}folderMoveProjects({destinationFolderId:t,destinationOwnerId:e,projects:r,sourceFolderId:n,sourceOwnerId:i}){return this._httpClient.post(`${this._baseUrl}/folders/projects`,{destinationFolderId:t,destinationOwnerId:e,projectIds:r.map(o=>o.id),sourceFolderId:n,sourceOwnerId:i})}folderMoveProjectsPdv({projects:t,destinationFolderIds:e}){return this._httpClient.post(`${this._baseUrl}/folders/projectspdv`,{projectIds:t,destinationFolderId:e})}folderMoveProjectsPdvChain({projects:t,destinationFolderIds:e,parentProjectId:r,copyProject:n}){return this._httpClient.post(`${this._baseUrl}/folders/chain/projectpdv`,{projectIds:t,destinationFolderId:e,parentProjectId:r,copyProject:n})}folderRename(t,e,r){return this._httpClient.post(`${this._baseUrl}/folders/${t}`,{name:e,special:r})}folders(t,e){let r={};return t&&(r.userId=t),e&&(r.rootId=e),this._httpClient.get(`${this._baseUrl}/folders`,{params:r}).pipe(w("folders"))}get(t){return this._httpClient.get(`${this._baseUrl}/${t}`,{params:{withProducts:"true"}}).pipe(O(e=>{Ii(e,this._user.user.unit),this._projectHelper.projectInitialize(e);for(let r of e.rack.sections)for(let n of r.holders.filter(i=>i.type===-1))for(let i of n.products)i.dx=i.location.x-n.location.x;return e}),w("project.get"))}getCategories(t){let e=r=>r?.map(n=>({id:n.Id,name:n.Name,children:n.Children?e(n.Children):void 0}));return this._httpClient.get(`${this._baseUrl}/${t}/categories`).pipe(O(r=>e(r.Categories)))}getClustersPDVs(t){return this._httpClient.get(`${this._baseUrl}/${t}/clustersandpdvs`)}getImage(t,e=!0){return this._httpClient.get(`${this._baseUrl}/${t}/image`,{observe:"body",responseType:"blob",params:{withProducts:e.toString(),withRulers:"false",size:"1920"}}).pipe(O(r=>`url(${URL.createObjectURL(r)})`),w("project.getImage"))}hasImportedImage(t){return this._httpClient.get(`${this._baseUrl}/${t}/import/has-image`).pipe(w("project.hasImportedImage"),he(()=>E(!1)))}getImportedImage(t){return this._httpClient.get(`${this._baseUrl}/${t}/import/image`,{observe:"body",responseType:"blob"}).pipe(w("project.getImportedImage"))}getMaster(t){return this._httpClient.get(`${this._baseUrl}/${t}`,{params:{withProducts:!1,master:!0}}).pipe(w("project.get-master"))}getProductUpdateImage(t,e,r){return this._httpClient.post(`${this._baseUrl}/${t}/getProductUpdate`,null,{params:{all:e.toString(),code:r.toString()}})}getProjectHide(t){return this._httpClient.get(`${this._baseUrl}/projecthide`,{params:{isCorporate:t}})}getRelationPDVsToMaster(t,e){return this._httpClient.get(`${this._baseUrl}/${t}/pdvs`,{params:{folderId:e}}).pipe(w("projects"))}importCopyPasteValidation(t,e){return this._httpClient.post(`${this._baseUrl}/import/${t}/copypaste-validation`,e)}importExcel(t,e,r,n,i,o,a,c){return this._httpClient.post(`${this._baseUrl}/import/${t}/excel`,_e({file:e}),{params:{timestamp:encodeURIComponent(c),fields:r,importAll:n,syncLib:i??!1,addNewProducts:o,userId:a??null}})}
32importExcelValidation(t,e,r,n){return this._httpClient.post(`${this._baseUrl}/import/${t}/excel-validation`,_e({file:e}),{params:{fields:r,importAll:n}})}importFile(t,e,r,n,i){let o={typeImport:n,codeMode:i,folderId:r};return e&&(o.userId=e),this._httpClient.post(`${this._baseUrl}/import/file`,_e({file:t}),{params:o,observe:"events",reportProgress:!0})}importFileConfirm(t,e,r){return this._httpClient.post(`${this._baseUrl}/import/file/confirm`,{projects:t,changeRack:e,userId:r})}psaEditorRead(t){return this._httpClient.post(`${this._baseUrl}/import/psa/read`,_e({file:t}))}psaEditorGenerateImage(t,e){return e?this._httpClient.post(`${this._baseUrl}/import/psa/image`,t,{params:{UPC:e},responseType:"blob"}):this._httpClient.post(`${this._baseUrl}/import/psa/image`,t,{responseType:"blob"})}psaEditorParse(t){return this.psaEditorRead(t).pipe(O(e=>e.planograms))}psaEditorSave(t,e){return this._httpClient.post(`${this._baseUrl}/import/psa/save`,{planograms:e,psaBase64:t})}psaEditorExport(t){return this._httpClient.post(`${this._baseUrl}/export/psa`,{psaBase64:t},{responseType:"blob"})}psaEditorImport(t,e,r,n,i,o){let a={fileName:e,psaBase64:t,folderId:n,userId:r,typeImport:i,codeImportMode:o};return this._httpClient.post(`${this._baseUrl}/import/file/psa`,a)}latest(){return this._httpClient.get(`${this._baseUrl}/latest`)}mountingRelationGet(t){return this._httpClient.get(`${this._baseUrl}/${t}/relation`)}mountingRelationUpsert(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/relation`,e)}navigationPdv(t,e){let r={idParentProject:e};return this._httpClient.get(`${this._baseUrl}/${t}/navegation/pdvs`,{params:r})}productAdd(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/product-add/${e}`,void 0)}productDelete(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/product-delete/${e}`,void 0)}productReplace(t,e,r){return this._httpClient.post(`${this._baseUrl}/${t}/product-replace/${e}/${r}`,void 0)}share(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/share`,e)}shareByLink(t){return er(t).pipe(D(e=>this._httpClient.post(`${this._baseUrl}/shared`,e)))}shareGet(t){return this._httpClient.get(`${this._baseUrl}/${t}/share`)}syncGetStatus(t){return this._httpClient.get(`${this._baseUrl}/${t}/sync-status`)}syncProject(t){return this._httpClient.get(`${this._baseUrl}/${t}/sync`)}syncProjectWithLocations(t){return this._httpClient.post(`${this._baseUrl}/sync-location`,t)}syncProjectWithProducts(t){return this._httpClient.post(`${this._baseUrl}/sync-all`,t)}updateActive(t,e){return this._httpClient.put(`${this._baseUrl}/${t}/active`,{active:e})}updateImagesProducts(t,e,r){return this._httpClient.put(`${this._baseUrl}/${t}/updateImagesProducts`,null,{params:{all:e.toString(),code:r.toString()}})}updateImagesProductsUp(t,e,r){return this._httpClient.put(`${this._baseUrl}/${t}/updateImagesProductsUp`,r,{params:{code:e.toString()}})}updateProject(t){let e={name:t.name,segmentId:t.segmentId,idPdfConfig:t.idPdfConfig,sync:t.sync,frontsRhythm:t.frontsRhythm,frontsMargin:t.frontsMargin,periodDays:t.periodDays??null,sales:s._generateUpdateSales(t.salesMap),extra:s._generateUpdateExtra(t.extraMap),products:s._generateUpdateProducts(t.products,!0),sections:s._generateUpdateRack(t.rack),timestamp:t.timestamp,rack:s._generateFullUpdateRack(t.rack),visualElements:t.visualElements};
32return Kr(e).pipe(D(r=>this._httpClient.put(`${this._baseUrl}/${t.id}/compressed/binary`,r,{headers:{"Content-Type":"application/gzip"},params:{updateRack:"true"}})))}updateRack(t){let e={name:t.name,rack:s._generateFullUpdateRack(t.rack),timestamp:t.timestamp,visualElements:t.visualElements};return Kr(e).pipe(D(r=>this._httpClient.put(`${this._baseUrl}/${t.id}/rack/compressed/binary`,r,{headers:{"Content-Type":"application/gzip"}})))}updateSalesPeriod(t,e){return this._httpClient.put(`${this._baseUrl}/${t}/sales-period`,{period:e})}uploadImage(t,e,r){return this._httpClient.post(`${this._baseUrl}/rack-image`,_e({position:t.position,stretch:t.stretch,file:e,projectId:r}))}uploadProductImage(t,e,r,n){return this._httpClient.post(`${this._baseUrl}/${t}/image/${qe(e)}/${n}`,_e({file:r}),{observe:"events",reportProgress:!0})}static _generateFullUpdateRack(t){return ke(we({},t),{sections:t.sections.map(e=>ke(we({},e),{holders:e.holders.filter(r=>r.type===4||r.type===3||r.type===1).map(r=>ke(we({},r),{products:[]}))}))})}static _generateUpdateExtra(t){if(!t)return;let e=[],r=document.createElement("div");for(let n of t.values()){let i=n.categories;if(!i)continue;let o=[];for(let a of i)a&&a.length>0&&(r.textContent=a,o.push(r.innerHTML));e.push({upc:n.upc,categories:`<cs><c>${o.join("</c><c>")}</c></cs>`})}return e}static _generateUpdateMounting(t){if(t?.length>0){let e=[];for(let r of t){let n=s._generateUpdateProducts(r.products);n&&e.push({name:r.name,products:n})}return e}}static _generateUpdateProducts(t,e=!1){if(t?.length>0)return t.map(r=>e?{id:r.id,fronts:r.fronts,stock:r.stock,orientation:r.orientation,isCase:r.isCase,width:r.size.w,height:r.size.h,compression:r.projectCompression}:{id:r.id,fronts:r.fronts,stock:r.stock,location:r.location,orientation:r.orientation,isCase:r.isCase,width:r.size.w,height:Ot(r),compression:r.projectCompression})}static _generateUpdateRack(t){if(t.sections?.length>0){let e=[];for(let r of t.sections){let n=s._generateUpdateMounting(r.holders);n&&e.push({id:r.id,mountings:n})}return e}}static _generateUpdateSales(t){return t?Array.from(t.values()).map(e=>({upc:e.upc,units:e.units,sales:e.sales,margin:e.margin,newPrice:e.newPrice,quantityUnits:e.quantityUnits})):void 0}_convertDates(t){for(let e of t)e.date=new Date(Date.parse(e.date)),e.lastUpdate=new Date(Date.parse(e.lastUpdate)),e.readBy=e.readBy?JSON.parse(e.readBy):void 0}_convertDatesNotification(t){for(let e of t)e.date=new Date(Date.parse(e.date)),e.lastUpdate=new Date(Date.parse(e.lastUpdate)),e.readBy=e.readBy?JSON.parse(e.readBy):void 0}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var pr=class s{_baseUrl="api/project";_dialogsService=h(Y);_httpClient=h(U);backup(t){let e=t?`/${t}`:"";return this._httpClient.post(`${this._baseUrl}/export/backup${e}`,void 0,{responseType:"blob"}).pipe(K("OpenCatman-Backup.zip"),w("backup"))}batchExportFile(t,e,r){return this._httpClient.post(`${this._baseUrl}/export/file/${t}`,{projectIds:e,mappings:this._convertFieldMapping(r)},{responseType:"blob"}).pipe(K("OpenCatman.zip"))}exportCustomExcel({project:t,fields:e,mode:r,margin:n,rhythm:i,salesPeriod:o,includeProjectMaster:a}){return this._httpClient.post(`${this._baseUrl}/export/${t.id}/excel/custom`,{fields:e,mode:r,margin:n,rhythm:i,salesPeriod:o,includeProjectMaster:a},{responseType:"blob"}).pipe(K(`${t.name} - ${t.store??t.rack.store} - ${t.category??t.rack.category}.xlsx`),w("download-custom-excel"))}exportCustomExcelBatch({projects:t,fields:e,oneFile:r,mode:n,margin:i,rhythm:o,salesPeriod:a,folderName:c}){let d=this._dialogsService.showSnackbar("download.excel",void 0,{verticalPosition:"top"});this._httpClient.post(`${this._baseUrl}/export/excel/custom`,{projectIds:t,fields:e,oneFile:r,mode:n,margin:i,rhythm:o,salesPeriod:a},{responseType:"blob"}).pipe(K(r?`${c??""}OpenCatman.xlsx`:"OpenCatman.zip")).subscribe({error:u=>{d.dismiss(),this._dialogsService.showErrorSnackbar(u)},complete:()=>d.dismiss()})}exportExcel(t,e,r,n){let i=Number(n)===1?"xlsx":"csv";return this._httpClient.get(`${this._baseUrl}/export/${t}/excel`,{params:{withProducts:r.toString(),format:n},responseType:"blob"}).pipe(K(`${e.name} - ${e.store} - ${e.category}.${i}`),w("download-excel"))}exportExcelBatch(t){let e=this._dialogsService.showSnackbar("download.excel",void 0,{verticalPosition:"top"});this._httpClient.post(`${this._baseUrl}/export/excel`,t,{responseType:"blob"}).pipe(K("OpenCatman.zip")).subscribe({error:r=>{e.dismiss(),this._dialogsService.showErrorSnackbar(r)},complete:()=>e.dismiss()})}exportExcelStoreCheck(t,e,r,n,i){let o={state:n.toString(),format:r.toString()};i&&i.trim().length>0&&(o.filter=i.trim());let a=Number(r)===1?"xlsx":"csv",c=new Date().getTime();return this._httpClient.get(`${this._baseUrl}/export/${t.id}/storecheck/${e}`,{params:o,responseType:"blob"}).pipe(K(`storecheck-${t.name}-${c}.${a}`),w("download-excel"))}exportFile(t,e,r){let n=e.rack?`${e.rack.name} - ${e.rack.store} - ${e.rack.category}`:`${e.name} - ${e.store} - ${e.category}`;switch(t){case 1:n+=".opc";break;case 2:case 3:n+=".zip";break}return this._httpClient.post(`${this._baseUrl}/export/${e.id}/file/${t}`,this._convertFieldMapping(r),{responseType:"blob"}).pipe(K(n))}exportMappingFields(t,e,r){let n={};return e&&(n.userId=e),r&&(n.projectId=r),this._httpClient.get(`${this._baseUrl}/export/file/mapping/${t}`,{params:n}).pipe(w("export-mapping-fields"))}exportMappingFieldsUpdate(t,e,r){let n;return r&&(n={userId:r}),this._httpClient.post(`${this._baseUrl}/export/file/mapping/${t}`,this._convertFieldMapping(e),{params:n})}exportPdfCustom(t,e){let r=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"});return this._downloadPdfCustom(t,e).pipe(G({error:n=>{r.dismiss(),this._dialogsService.showErrorSnackbar(n)},complete:()=>r.dismiss()}))}exportPdfCustomBatch(t,e,r,n){let i=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"}),o={};return n&&(o={special:n}),this._httpClient.post(`${this._baseUrl}/export/pdf/batch/custom/${t}/${e??0}`,r,{params:o,responseType:"blob"}).pipe(K("OpenCatman.zip"),De(()=>i.dismiss()),O(()=>{}),w("download-pdf"))}exportPdfDetailed(t){let e=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"});return this._downloadPdf({project:t,full:!0}).pipe(G({error:r=>{e.dismiss(),this._dialogsService.showErrorSnackbar(r)},complete:()=>e.dismiss()}))}exportPdfDetailedBatch(t,e){let r=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"});return this._downloadPdfBatch(t,!0,e).pipe(De(()=>r.dismiss()),O(()=>{}))}exportPdfSimple(t,e,r,n=!1){let i=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"});return this._downloadPdf({project:t,withProducts:e,withPrices:r,full:!1,withSizes:n}).pipe(G({error:o=>
32{i.dismiss(),this._dialogsService.showErrorSnackbar(o)},complete:()=>i.dismiss()}))}exportPdfSimpleBatch(t,e){let r=this._dialogsService.showSnackbar("download.pdf",void 0,{verticalPosition:"top"});return this._downloadPdfBatch(t,!1,e).pipe(De(()=>r.dismiss()),O(()=>{}))}exportProductLibraryExcel(t,e){let r;return e&&(r={projectId:e}),this._httpClient.get("api/product/export",{params:r,responseType:"blob"}).pipe(K(t),w("download-excel"))}_downloadPdfCustom(t,e){return this._httpClient.post(`${this._baseUrl}/export/pdf/custom`,e,{responseType:"blob"}).pipe(K(`${t.name} - ${t.rack.store} - ${t.rack.category}.pdf`),w("download-pdf"))}_convertFieldMapping(t){return t?t.reduce((e,r)=>(e.push({group:r.source.group,source:r.source.id,destination:r.destination.id}),e),[]):[]}_downloadPdf({full:t,project:e,withPrices:r,withProducts:n,withSizes:i}){let o={};return i&&(o.withSizes=i.toString()),n&&(o.withProducts=i??!1?"false":n.toString()),r&&(o.withPrices=i??!1?"false":r.toString()),this._httpClient.get(`${this._baseUrl}/export/${e.id}/pdf${t?"/full":""}`,{responseType:"blob",params:o}).pipe(K(`${e.name} - ${e.rack.store} - ${e.rack.category}.pdf`),w("download-pdf"))}_downloadPdfBatch(t,e=!1,r=!1){let n={};return r&&(n={special:r}),this._httpClient.post(`${this._baseUrl}/export/pdf/batch${e?"/full":""}`,t,{params:n,responseType:"blob"}).pipe(K("OpenCatman.zip"),w("download-pdf"))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Ei=class s{_baseUrl="api2/storecheck";_httpClient=h(U);all({projectId:t,filter:e,page:r,pageSize:n,sort:i}){let o={page:r.toString(),pageSize:n.toString(),sort:i};return e&&e.trim().length>0&&(o.filter=e.trim()),this._httpClient.get(`${this._baseUrl}/${t}`,{params:o}).pipe(w("storecheck-all"))}delete(t,e){return this._httpClient.delete(`${this._baseUrl}/${t}/${e}`).pipe(w("storecheck"))}get(t){return this._httpClient.get(`${this._baseUrl}/${t}`).pipe(w("storecheck"))}imageGetAll(t){return this._httpClient.get(`${this._baseUrl}/${t}/photos`).pipe(w("storecheck-images"))}productDelete(t,e){return this._httpClient.delete(`${this._baseUrl}/${t}/products/${e}`).pipe(w("store-product"))}productGetAll({storeId:t,projectId:e,filter:r,page:n,pageSize:i,sort:o}){let a={page:n.toString(),pageSize:i.toString(),sort:o};return r&&r.trim().length>0&&(a.filter=r.trim()),this._httpClient.get(`${this._baseUrl}/${t}/${e}/products`,{params:a}).pipe(w("storecheck-prodcuts"))}applyToPlanogram(t,e,r){return this._httpClient.post(`${this._baseUrl}/${t}/${e}/products/apply`,r).pipe(w("storecheck-apply-planogram"))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Oi=class s{_baseUrl="api/rack";_httpClient=h(U);categories({filter:t,userId:e,folderId:r,filterByFolder:n}={}){let i=new ut;return t&&(i=i.append("filter",t)),e&&(i=i.append("userId",e)),r&&(i=i.append("folderId",r)),n&&(i=i.append("filterByFolder",String(n))),this._httpClient.get(`${this._baseUrl}/category`,{params:i})}create(t,e,r,n,i,o){return this._httpClient.post(this._baseUrl,{name:t,category:e,store:r,userId:o,folderId:n,isModel:i})}stores({filter:t,userId:e,folderId:r,filterByFolder:n}={}){let i={};return t&&(i.filter=t),e&&(i.userId=e),r&&(i.folderId=r),n&&(i.filterByFolder=String(n)),this._httpClient.get(`${this._baseUrl}/store`,{params:i})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Di=class s{_baseUrl="api/segmentation";_httpClient=h(U);addSegmentation(t,e,r){return this._httpClient.post(`${this._baseUrl}/addSegmentation/`,{name:t,isDefault:e,userId:r})}addUpdProdSegmentation(t,e,r,n,i,o,a){return this._httpClient.post(`${this._baseUrl}/addUpdProdSegmentation/`,{idSegmentation:t,upc:e,segment:r,subSegment1:n,subSegment2:i,subSegment3:o,subSegment4:a})}deleteSegmentation(t){return this._httpClient.delete(`${this._baseUrl}/deleteSegmentation?id=${t}`)}exportSegmentationLibraryExcel(t,e,r,n){return this._httpClient.get(`${this._baseUrl}/export/${e}${t?"/corporate":""}`,{params:r?{projectId:r}:void 0,responseType:"blob"}).pipe(K(n)).subscribe()}getAll(t){return this._httpClient.get(`${this._baseUrl}/getSegmentationAll`,{params:{userId:t}})}getByProject(t,e){return this._httpClient.get(`${this._baseUrl}/${t}/products/byproject`,{params:{projectId:e}})}getProductCategory(t,e){let r={code:t,projectId:e};return this._httpClient.post(`${this._baseUrl}/category`,r)}getProductSegmentationBySegment(t,e,r,n){return this._httpClient.post(`${this._baseUrl}/getProductSegmentationBySegment/`,{idSegmentation:t,page:e,pageSize:r,sort:n})}importSegmentationLibraryExcel(t,e,r,n){let i={addProd:n.addProduct,updProd:n.updateProduct,delProd:n.deleteProduct,delete:n.confirmed??null};return this._httpClient.post(`${this._baseUrl}/import/excel/${e}/${n.type}${t?"/corporate":""}`,_e({fileImport:r}),{params:i})}updateLibrary(t,e){return this._httpClient.post(`${this._baseUrl}/${t}/updatelibrary`,e)}updateSegmentation(t,e,r,n){return this._httpClient.put(`${this._baseUrl}/${t}/update`,{name:e,isDefault:r,userId:n})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};
32var $i=class s{_allowedFunctionalitySubject=new Ut(1);_baseUrl="api/subscription";_dialogsService=h(Y);_httpClient=h(U);_parametersApiService=h(lr);constructor(){let t=h(bt),e=h(xe);t.navigated.pipe(D(()=>e.userToken?this.canUseAll():E({})),he(()=>E({}))).subscribe({next:r=>{this._allowedFunctionalitySubject.next(r)}})}get allowedFunctionality(){return this._allowedFunctionalitySubject.asObservable()}all(){return this._httpClient.get(this._baseUrl)}allowedFunctionalityShared(t){return this.canUseAllShared(t).subscribe({next:e=>{this._allowedFunctionalitySubject.next(e)}}),this._allowedFunctionalitySubject.asObservable()}canUse(t,e){return er(t).pipe(D(r=>this._httpClient.get("api/user/can-use",{params:{permission:r.data,projectId:e??null}})),w("subscription.can-use"),O(r=>r?!0:(this._parametersApiService.getParameter("application.showButtonTour").pipe(D(n=>Rt({showTour:E(n),showButton:this._parametersApiService.getParameter("stripe.plan.year")})),D(n=>this._dialogsService.showModal(ae.subscriptionRequired(),{data:{showTour:n.showTour==="True",hasAnualPlan:n.showButton!==""}}))).subscribe(),!1)),he(r=>(this._dialogsService.showErrorSnackbar(r),E(!1))))}canUseAll(){return this._httpClient.get("api/user/can-use").pipe(D(t=>Gr(t)),he(t=>(this._dialogsService.showErrorSnackbar(t),E({}))))}canUseAllShared(t){return this._httpClient.get(`api/user/can-use/${t}`).pipe(D(e=>Gr(e)),he(e=>(this._dialogsService.showErrorSnackbar(e),E({}))))}levelAdd(t){return this._httpClient.post(`${this._baseUrl}/level`,{name:t})}levelDelete(t){return this._httpClient.delete(`${this._baseUrl}/level/${t}`)}levels(){return this._httpClient.get(`${this._baseUrl}/level`)}update(t,e,r){return this._httpClient.post(this._baseUrl,{permissionId:t,levelId:e,canUse:r}).pipe(w(`subscription_update_${t}_${e}`))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var cr=class s{_baseUrl="api/unit";_httpClient=h(U);_all$;all(){return this._all$||(this._all$=this._httpClient.get(this._baseUrl).pipe(Ye({bufferSize:1,refCount:!1})))}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var en=class{dataNodes;expansionModel=new Hr(!0);trackBy;getLevel;isExpandable;getChildren;toggle(t){this.expansionModel.toggle(this._trackByValue(t))}expand(t){this.expansionModel.select(this._trackByValue(t))}collapse(t){this.expansionModel.deselect(this._trackByValue(t))}isExpanded(t){return this.expansionModel.isSelected(this._trackByValue(t))}toggleDescendants(t){this.expansionModel.isSelected(this._trackByValue(t))?this.collapseDescendants(t):this.expandDescendants(t)}collapseAll(){this.expansionModel.clear()}expandDescendants(t){let e=[t];e.push(...this.getDescendants(t)),this.expansionModel.select(...e.map(r=>this._trackByValue(r)))}collapseDescendants(t){let e=[t];e.push(...this.getDescendants(t)),this.expansionModel.deselect(...e.map(r=>this._trackByValue(r)))}_trackByValue(t){return this.trackBy?this.trackBy(t):t}};var ur=class extends en{getChildren;options;constructor(t,e){super(),this.getChildren=t,this.options=e,this.options&&(this.trackBy=this.options.trackBy),this.options?.isExpandable&&(this.isExpandable=this.options.isExpandable)}expandAll(){this.expansionModel.clear();let t=this.dataNodes.reduce((e,r)=>[...e,...this.getDescendants(r),r],[]);this.expansionModel.select(...t.map(e=>this._trackByValue(e)))}getDescendants(t){let e=[];return this._getDescendants(e,t),e.splice(1)}_getDescendants(t,e){t.push(e);let r=this.getChildren(e);Array.isArray(r)?r.forEach(n=>this._getDescendants(t,n)):kr(r)&&r.pipe(Oe(1),Z(Boolean)).subscribe(n=>{for(let i of n)this._getDescendants(t,i)})}},At=new gn("CDK_TREE_NODE_OUTLET_NODE"),$t=(()=>{class s{viewContainer=h(Vt);_node=h(At,{optional:!0});constructor(){}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["","cdkTreeNodeOutlet",""]]})}return s})(),tn=class{$implicit;level;index;count;constructor(t){this.$implicit=t}},mr=(()=>{class s{template=h(bn);when;constructor(){}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["","cdkTreeNodeDef",""]],inputs:{when:[0,"cdkTreeNodeDefWhen","when"]}})}return s})();function Ai(){return Error("Could not find a tree control, levelAccessor, or childrenAccessor for the tree.")}var St=(()=>{class s{_differs=h(Ur);_changeDetectorRef=h(Fr);_elementRef=h(Bt);_dir=h(Lr);_onDestroy=new J;_dataDiffer;_defaultNodeDef=null;_dataSubscription;_levels=new Map;_parents=new Map;_ariaSets=new Map;get dataSource(){return this._dataSource}set dataSource(e){this._dataSource!==e&&this._switchDataSource(e)}_dataSource;treeControl;levelAccessor;childrenAccessor;trackBy;expansionKey;_nodeOutlet;_nodeDefs;viewChange=new ve({start:0,end:Number.MAX_VALUE});_expansionModel;_flattenedNodes=new ve([]);_nodeType=new ve(null);_nodes=new ve(new Map);_keyManagerNodes=new ve([]);_keyManagerFactory=h(An);_keyManager;_viewInit=!1;constructor(){}ngAfterContentInit(){this._initializeKeyManager()}ngAfterContentChecked(){this._updateDefaultNodeDefinition(),this._subscribeToDataChanges()}ngOnDestroy(){this._nodeOutlet.viewContainer.clear(),this._nodes.complete(),this._keyManagerNodes.complete(),this._nodeType.complete(),this._flattenedNodes.complete(),this.viewChange.complete(),this._onDestroy.next(),this._onDestroy.complete(),this._dataSource&&typeof this._dataSource.disconnect=="function"&&this.dataSource.disconnect(this),this._dataSubscription?.unsubscribe(),this._dataSubscription=void 0,this._keyManager?.destroy()}ngOnInit(){this._checkTreeControlUsage(),this._initializeDataDiffer()}ngAfterViewInit(){this._viewInit=!0}_updateDefaultNodeDefinition(){let e=this._nodeDefs.filter(r=>!r.when);e.length>1,this._defaultNodeDef=e[0]}_setNodeTypeIfUnset(e){this._nodeType.value===null&&this._nodeType.next(e)}_switchDataSource(e){this._dataSource&&typeof this._dataSource.disconnect=="function"&&this.dataSource.disconnect(this),this._dataSubscription?.unsubscribe(),this._dataSubscription=void 0,e||this._nodeOutlet.viewContainer.clear(),this._dataSource=e,this._nodeDefs&&this._subscribeToDataChanges()}_getExpansionModel(){return this.treeControl?this.treeControl.expansionModel:(this._expansionModel??=new Hr(!0),this._expansionModel)}_subscribeToDataChanges(){if(this._dataSubscription)return;let e;Nn(this._dataSource)?e=this._dataSource.connect(this):kr(this._dataSource)?e=this._dataSource:Array.isArray(this._dataSource)&&(e=E(this._dataSource)),e&&(this._dataSubscription=this._getRenderData(e).pipe(ye(this._onDestroy)).subscribe(r=>{this._renderDataChanges(r)}))}_getRenderData(e){let r=this._getExpansionModel();return Tt([e,this._nodeType,r.changed.pipe(Ir(null),G(n=>{this._emitExpansionChanges(n)}))]).pipe(D(([n,i])=>i===null?E({renderNodes:n,flattenedNodes:null,nodeType:i}):this._computeRenderingData(n,i).pipe(O(o=>ke(we({},o),{nodeType:i})))))}_renderDataChanges(e){if(e.nodeType===null){this.renderNodeChanges(e.renderNodes);return}this._updateCachedData(e.flattenedNodes),this.renderNodeChanges(e.renderNodes),this._updateKeyManagerItems(e.flattenedNodes)}_emitExpansionChanges(e){if(!e)return;let r=this._nodes.value;for(let n of e.added)r.get(n)?._emitExpansionState(!0);for(let n of e.removed)r.get(n)?._emitExpansionState(!1)}_initializeKeyManager(){let e=Tt([this._keyManagerNodes,this._nodes]).pipe(O(([n,i])=>n.reduce((o,a)=>{let c=i.get(this._getExpansionKey(a));return c&&o.push(c),o},[]))),r={trackBy:n=>this._getExpansionKey(n.data),skipPredicate:n=>!!n.isDisabled,typeAheadDebounceInterval:!0,horizontalOrientation:this._dir.value};this._keyManager=this._keyManagerFactory(e,r)}_initializeDataDiffer(){let e=this.trackBy??((r,n)=>this._getExpansionKey(n));this._dataDiffer=this._differs.find([]).create(e)}_checkTreeControlUsage(){}renderNodeChanges(e,r=this._dataDiffer,n=this._nodeOutlet.viewContainer,i){let o=r.diff(e);!o&&!this._viewInit||(o?.forEachOperation((a,c,d)=>
32{if(a.previousIndex==null)this.insertNode(e[d],d,n,i);else if(d==null)n.remove(c);else{let u=n.get(c);n.move(u,d)}}),o?.forEachIdentityChange(a=>{let c=a.item;if(a.currentIndex!=null){let d=n.get(a.currentIndex);d.context.$implicit=c}}),i?this._changeDetectorRef.markForCheck():this._changeDetectorRef.detectChanges())}_getNodeDef(e,r){if(this._nodeDefs.length===1)return this._nodeDefs.first;let n=this._nodeDefs.find(i=>i.when&&i.when(r,e))||this._defaultNodeDef;return n}insertNode(e,r,n,i){let o=this._getLevelAccessor(),a=this._getNodeDef(e,r),c=this._getExpansionKey(e),d=new tn(e);d.index=r,i??=this._parents.get(c)??void 0,o?d.level=o(e):i!==void 0&&this._levels.has(this._getExpansionKey(i))?d.level=this._levels.get(this._getExpansionKey(i))+1:d.level=0,this._levels.set(c,d.level),(n||this._nodeOutlet.viewContainer).createEmbeddedView(a.template,d,r),Se.mostRecentTreeNode&&(Se.mostRecentTreeNode.data=e)}isExpanded(e){return!!(this.treeControl?.isExpanded(e)||this._expansionModel?.isSelected(this._getExpansionKey(e)))}toggle(e){this.treeControl?this.treeControl.toggle(e):this._expansionModel&&this._expansionModel.toggle(this._getExpansionKey(e))}expand(e){this.treeControl?this.treeControl.expand(e):this._expansionModel&&this._expansionModel.select(this._getExpansionKey(e))}collapse(e){this.treeControl?this.treeControl.collapse(e):this._expansionModel&&this._expansionModel.deselect(this._getExpansionKey(e))}toggleDescendants(e){this.treeControl?this.treeControl.toggleDescendants(e):this._expansionModel&&(this.isExpanded(e)?this.collapseDescendants(e):this.expandDescendants(e))}expandDescendants(e){if(this.treeControl)this.treeControl.expandDescendants(e);else if(this._expansionModel){let r=this._expansionModel;r.select(this._getExpansionKey(e)),this._getDescendants(e).pipe(Oe(1),ye(this._onDestroy)).subscribe(n=>{r.select(...n.map(i=>this._getExpansionKey(i)))})}}collapseDescendants(e){if(this.treeControl)this.treeControl.collapseDescendants(e);else if(this._expansionModel){let r=this._expansionModel;r.deselect(this._getExpansionKey(e)),this._getDescendants(e).pipe(Oe(1),ye(this._onDestroy)).subscribe(n=>{r.deselect(...n.map(i=>this._getExpansionKey(i)))})}}expandAll(){this.treeControl?this.treeControl.expandAll():this._expansionModel&&this._forEachExpansionKey(e=>this._expansionModel?.select(...e))}collapseAll(){this.treeControl?this.treeControl.collapseAll():this._expansionModel&&this._forEachExpansionKey(e=>this._expansionModel?.deselect(...e))}_getLevelAccessor(){return this.treeControl?.getLevel?.bind(this.treeControl)??this.levelAccessor}_getChildrenAccessor(){return this.treeControl?.getChildren?.bind(this.treeControl)??this.childrenAccessor}_getDirectChildren(e){let r=this._getLevelAccessor(),n=this._expansionModel??this.treeControl?.expansionModel;if(!n)return E([]);let i=this._getExpansionKey(e),o=n.changed.pipe(D(c=>c.added.includes(i)?E(!0):c.removed.includes(i)?E(!1):hn),Ir(this.isExpanded(e)));if(r)return Tt([o,this._flattenedNodes]).pipe(O(([c,d])=>c?this._findChildrenByLevel(r,d,e,1):[]));let a=this._getChildrenAccessor();if(a)return qt(a(e)??[]);throw Ai()}_findChildrenByLevel(e,r,n,i){let o=this._getExpansionKey(n),a=r.findIndex(l=>this._getExpansionKey(l)===o),c=e(n),d=c+i,u=[];for(let l=a+1;l<r.length;l++){let m=e(r[l]);if(m<=c)break;m<=d&&u.push(r[l])}return u}_registerNode(e){this._nodes.value.set(this._getExpansionKey(e.data),e),this._nodes.next(this._nodes.value)}_unregisterNode(e){this._nodes.value.delete(this._getExpansionKey(e.data)),this._nodes.next(this._nodes.value)}_getLevel(e){return this._levels.get(this._getExpansionKey(e))}_getSetSize(e){return this._getAriaSet(e).length}_getPositionInSet(e){let r=this._getAriaSet(e),n=this._getExpansionKey(e);return r.findIndex(i=>this._getExpansionKey(i)===n)+1}_getNodeParent(e){let r=this._parents.get(this._getExpansionKey(e.data));return r&&this._nodes.value.get(this._getExpansionKey(r))}_getNodeChildren(e){return this._getDirectChildren(e.data).pipe(O(r=>r.reduce((n,i)=>{let o=this._nodes.value.get(this._getExpansionKey(i));return o&&n.push(o),n},[])))}_sendKeydownToKeyManager(e){if(e.target===this._elementRef.nativeElement)this._keyManager.onKeydown(e);else{let r=this._nodes.getValue();for(let[,n]of r)if(e.target===n._elementRef.nativeElement){this._keyManager.onKeydown(e);break}}}_getDescendants(e){if(this.treeControl)return E(this.treeControl.getDescendants(e));
32if(this.levelAccessor){let r=this._findChildrenByLevel(this.levelAccessor,this._flattenedNodes.value,e,1/0);return E(r)}if(this.childrenAccessor)return this._getAllChildrenRecursively(e).pipe(Mr((r,n)=>(r.push(...n),r),[]));throw Ai()}_getAllChildrenRecursively(e){return this.childrenAccessor?qt(this.childrenAccessor(e)).pipe(Oe(1),D(r=>{for(let n of r)this._parents.set(this._getExpansionKey(n),e);return E(...r).pipe(Tr(n=>jr(E([n]),this._getAllChildrenRecursively(n))))})):E([])}_getExpansionKey(e){return this.expansionKey?.(e)??e}_getAriaSet(e){let r=this._getExpansionKey(e),n=this._parents.get(r),i=n?this._getExpansionKey(n):null;return this._ariaSets.get(i)??[e]}_findParentForNode(e,r,n){if(!n.length)return null;let i=this._levels.get(this._getExpansionKey(e))??0;for(let o=r-1;o>=0;o--){let a=n[o];if((this._levels.get(this._getExpansionKey(a))??0)<i)return a}return null}_flattenNestedNodesWithExpansion(e,r=0){let n=this._getChildrenAccessor();return n?E(...e).pipe(Tr(i=>{let o=this._getExpansionKey(i);this._parents.has(o)||this._parents.set(o,null),this._levels.set(o,r);let a=qt(n(i));return jr(E([i]),a.pipe(Oe(1),G(c=>{this._ariaSets.set(o,[...c??[]]);for(let d of c??[]){let u=this._getExpansionKey(d);this._parents.set(u,i),this._levels.set(u,r+1)}}),D(c=>c?this._flattenNestedNodesWithExpansion(c,r+1).pipe(O(d=>this.isExpanded(i)?d:[])):E([]))))}),Mr((i,o)=>(i.push(...o),i),[])):E([...e])}_computeRenderingData(e,r){if(this.childrenAccessor&&r==="flat")return this._clearPreviousCache(),this._ariaSets.set(null,[...e]),this._flattenNestedNodesWithExpansion(e).pipe(O(n=>({renderNodes:n,flattenedNodes:n})));if(this.levelAccessor&&r==="nested"){let n=this.levelAccessor;return E(e.filter(i=>n(i)===0)).pipe(O(i=>({renderNodes:i,flattenedNodes:e})),G(({flattenedNodes:i})=>{this._calculateParents(i)}))}else return r==="flat"?E({renderNodes:e,flattenedNodes:e}).pipe(G(({flattenedNodes:n})=>{this._calculateParents(n)})):(this._clearPreviousCache(),this._ariaSets.set(null,[...e]),this._flattenNestedNodesWithExpansion(e).pipe(O(n=>({renderNodes:e,flattenedNodes:n}))))}_updateCachedData(e){this._flattenedNodes.next(e)}_updateKeyManagerItems(e){this._keyManagerNodes.next(e)}_calculateParents(e){let r=this._getLevelAccessor();if(r){this._clearPreviousCache();for(let n=0;n<e.length;n++){let i=e[n],o=this._getExpansionKey(i);this._levels.set(o,r(i));let a=this._findParentForNode(i,n,e);this._parents.set(o,a);let c=a?this._getExpansionKey(a):null,d=this._ariaSets.get(c)??[];d.splice(n,0,i),this._ariaSets.set(c,d)}}}_forEachExpansionKey(e){let r=[],n=[];this._nodes.value.forEach(i=>{r.push(this._getExpansionKey(i.data)),n.push(this._getDescendants(i.data))}),n.length>0?Tt(n).pipe(Oe(1),ye(this._onDestroy)).subscribe(i=>{i.forEach(o=>o.forEach(a=>r.push(this._getExpansionKey(a)))),e(r)}):e(r)}_clearPreviousCache(){this._parents.clear(),this._levels.clear(),this._ariaSets.clear()}static \u0275fac=function(r){return new(r||s)};static \u0275cmp=ge({type:s,selectors:[["cdk-tree"]],contentQueries:function(r,n,i){if(r&1&&Or(i,mr,5),r&2){let o;ct(o=lt())&&(n._nodeDefs=o)}},viewQuery:function(r,n){if(r&1&&Gt($t,7),r&2){let i;ct(i=lt())&&(n._nodeOutlet=i.first)}},hostAttrs:["role","tree",1,"cdk-tree"],hostBindings:function(r,n){r&1&&I("keydown",function(o){return n._sendKeydownToKeyManager(o)})},inputs:{dataSource:"dataSource",treeControl:"treeControl",levelAccessor:"levelAccessor",childrenAccessor:"childrenAccessor",trackBy:"trackBy",expansionKey:"expansionKey"},exportAs:["cdkTree"],decls:1,vars:0,consts:[["cdkTreeNodeOutlet",""]],template:function(r,n){r&1&&Fe(0,0)},dependencies:[$t],encapsulation:2})}return s})(),Se=(()=>{class s{_elementRef=h(Bt);_tree=h(St);_tabindex=-1;_type="flat";get role(){return"treeitem"}set role(e){}get isExpandable(){return this._isExpandable()}set isExpandable(e){this._inputIsExpandable=e,!(this.data&&!this._isExpandable||!this._inputIsExpandable)&&(this._inputIsExpanded?this.expand():this._inputIsExpanded===!1&&this.collapse())}get isExpanded(){return this._tree.isExpanded(this._data)}set isExpanded(e){this._inputIsExpanded=e,e?this.expand():this.collapse()}isDisabled=!1;typeaheadLabel=null;getLabel(){return this.typeaheadLabel||this._elementRef.nativeElement.textContent?.trim()||""}activation=new ot;expandedChange=new ot;static mostRecentTreeNode=null;_destroyed=new J;_dataChanges=new J;_inputIsExpandable=!1;_inputIsExpanded=void 0;_shouldFocus=!0;_parentNodeAriaLevel;get data(){return this._data}set data(e){e!==this._data&&(this._data=e,this._dataChanges.next())}_data;
32get isLeafNode(){return this._tree.treeControl?.isExpandable!==void 0&&!this._tree.treeControl.isExpandable(this._data)?!0:this._tree.treeControl?.isExpandable===void 0&&this._tree.treeControl?.getDescendants(this._data).length===0}get level(){return this._tree._getLevel(this._data)??this._parentNodeAriaLevel}_isExpandable(){return this._tree.treeControl?!this.isLeafNode:this._inputIsExpandable}_getAriaExpanded(){return this._isExpandable()?String(this.isExpanded):null}_getSetSize(){return this._tree._getSetSize(this._data)}_getPositionInSet(){return this._tree._getPositionInSet(this._data)}_changeDetectorRef=h(Fr);constructor(){s.mostRecentTreeNode=this}ngOnInit(){this._parentNodeAriaLevel=Yi(this._elementRef.nativeElement),this._tree._getExpansionModel().changed.pipe(O(()=>this.isExpanded),nt(),ye(this._destroyed)).pipe(ye(this._destroyed)).subscribe(()=>this._changeDetectorRef.markForCheck()),this._tree._setNodeTypeIfUnset(this._type),this._tree._registerNode(this)}ngOnDestroy(){s.mostRecentTreeNode===this&&(s.mostRecentTreeNode=null),this._dataChanges.complete(),this._destroyed.next(),this._destroyed.complete()}getParent(){return this._tree._getNodeParent(this)??null}getChildren(){return this._tree._getNodeChildren(this)}focus(){this._tabindex=0,this._shouldFocus&&this._elementRef.nativeElement.focus(),this._changeDetectorRef.markForCheck()}unfocus(){this._tabindex=-1,this._changeDetectorRef.markForCheck()}activate(){this.isDisabled||this.activation.next(this._data)}collapse(){this.isExpandable&&this._tree.collapse(this._data)}expand(){this.isExpandable&&this._tree.expand(this._data)}makeFocusable(){this._tabindex=0,this._changeDetectorRef.markForCheck()}_focusItem(){this.isDisabled||this._tree._keyManager.focusItem(this)}_setActiveItem(){this.isDisabled||(this._shouldFocus=!1,this._tree._keyManager.focusItem(this),this._shouldFocus=!0)}_emitExpansionState(e){this.expandedChange.emit(e)}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["cdk-tree-node"]],hostAttrs:["role","treeitem",1,"cdk-tree-node"],hostVars:5,hostBindings:function(r,n){r&1&&I("click",function(){return n._setActiveItem()})("focus",function(){return n._focusItem()}),r&2&&(Kt("tabIndex",n._tabindex),at("aria-expanded",n._getAriaExpanded())("aria-level",n.level+1)("aria-posinset",n._getPositionInSet())("aria-setsize",n._getSetSize()))},inputs:{role:"role",isExpandable:[2,"isExpandable","isExpandable",Qe],isExpanded:"isExpanded",isDisabled:[2,"isDisabled","isDisabled",Qe],typeaheadLabel:[0,"cdkTreeNodeTypeaheadLabel","typeaheadLabel"]},outputs:{activation:"activation",expandedChange:"expandedChange"},exportAs:["cdkTreeNode"]})}return s})();function Yi(s){let t=s.parentElement;for(;t&&!Qi(t);)t=t.parentElement;return t?t.classList.contains("cdk-nested-tree-node")?Ue(t.getAttribute("aria-level")):0:-1}function Qi(s){let t=s.classList;return!!(t?.contains("cdk-nested-tree-node")||t?.contains("cdk-tree"))}var rn=(()=>{class s extends Se{_type="nested";_differs=h(Ur);_dataDiffer;_children;nodeOutlet;constructor(){super()}ngAfterContentInit(){this._dataDiffer=this._differs.find([]).create(this._tree.trackBy),this._tree._getDirectChildren(this.data).pipe(ye(this._destroyed)).subscribe(e=>this.updateChildrenNodes(e)),this.nodeOutlet.changes.pipe(ye(this._destroyed)).subscribe(()=>this.updateChildrenNodes())}ngOnDestroy(){this._clear(),super.ngOnDestroy()}updateChildrenNodes(e){let r=this._getNodeOutlet();if(e&&(this._children=e),r&&this._children){let n=r.viewContainer;this._tree.renderNodeChanges(this._children,this._dataDiffer,n,this._data)}else this._dataDiffer.diff([])}_clear(){let e=this._getNodeOutlet();e&&(e.viewContainer.clear(),this._dataDiffer.diff([]))}_getNodeOutlet(){let e=this.nodeOutlet;return e&&e.find(r=>!r._node||r._node===this)}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["cdk-nested-tree-node"]],contentQueries:function(r,n,i){if(r&1&&Or(i,$t,5),r&2){let o;ct(o=lt())&&(n.nodeOutlet=o)}},hostAttrs:[1,"cdk-nested-tree-node"],exportAs:["cdkNestedTreeNode"],features:[Ce([{provide:Se,useExisting:s},{provide:At,useExisting:s}]),je]})}return s})(),Ji=/([A-Za-z%]+)$/,nn=(()=>{class s{_treeNode=h(Se);_tree=h(St);_element=h(Bt);_dir=h(Lr,{optional:!0});_currentPadding=null;_destroyed=new J;indentUnits="px";get level(){return this._level}set level(e){this._setLevelInput(e)}_level;get indent(){return this._indent}set indent(e){this._setIndentInput(e)}_indent=40;constructor(){this._setPadding(),this._dir?.change.pipe(ye(this._destroyed)).subscribe(()=>this._setPadding(!0)),this._treeNode._dataChanges.subscribe(()=>this._setPadding())}ngOnDestroy(){this._destroyed.next(),this._destroyed.complete()}_paddingIndent(){let e=(this._treeNode.data&&this._tree._getLevel(this._treeNode.data))??null,r=this._level==null?e:this._level;return typeof r=="number"?`${r*this._indent}${this.indentUnits}`:null}_setPadding(e=!1){let r=this._paddingIndent();if(r!==this._currentPadding||e){let n=this._element.nativeElement,i=this._dir&&this._dir.value==="rtl"?"paddingRight":"paddingLeft",o=i==="paddingLeft"?"paddingRight":"paddingLeft";n.style[i]=r||"",n.style[o]="",this._currentPadding=r}}_setLevelInput(e){this._level=isNaN(e)?null:e,this._setPadding()}_setIndentInput(e){let r=e,n="px";if(typeof e=="string"){let i=e.split(Ji);r=i[0],n=i[1]||n}this.indentUnits=n,this._indent=Ue(r),this._setPadding()}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["","cdkTreeNodePadding",""]],inputs:{level:[2,"cdkTreeNodePadding","level",Ue],indent:[0,"cdkTreeNodePaddingIndent","indent"]}})}return s})(),on=(()=>{class s{_tree=h(St);_treeNode=h(Se);recursive=!1;constructor(){}
32_toggle(){this.recursive?this._tree.toggleDescendants(this._treeNode.data):this._tree.toggle(this._treeNode.data),this._tree._keyManager.focusItem(this._treeNode)}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["","cdkTreeNodeToggle",""]],hostAttrs:["tabindex","-1"],hostBindings:function(r,n){r&1&&I("click",function(o){return n._toggle(),o.stopPropagation()})("keydown.Enter",function(o){return n._toggle(),o.preventDefault()})("keydown.Space",function(o){return n._toggle(),o.preventDefault()})},inputs:{recursive:[2,"cdkTreeNodeToggleRecursive","recursive",Qe]}})}return s})();var Fi=(()=>{class s{static \u0275fac=function(r){return new(r||s)};static \u0275mod=Ht({type:s});static \u0275inj=zt({})}return s})();function Zi(s){return!!s._isNoopTreeKeyManager}var uu=(()=>{class s extends Se{get tabIndexInputBinding(){return this._tabIndexInputBinding}set tabIndexInputBinding(e){this._tabIndexInputBinding=e}_tabIndexInputBinding;defaultTabIndex=0;_getTabindexAttribute(){return Zi(this._tree._keyManager)?this.tabIndexInputBinding:this._tabindex}get disabled(){return this.isDisabled}set disabled(e){this.isDisabled=e}constructor(){super();let e=h(new kn("tabindex"),{optional:!0});this.tabIndexInputBinding=Number(e)||this.defaultTabIndex}ngOnInit(){super.ngOnInit()}ngOnDestroy(){super.ngOnDestroy()}static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["mat-tree-node"]],hostAttrs:[1,"mat-tree-node"],hostVars:5,hostBindings:function(r,n){r&1&&I("click",function(){return n._focusItem()}),r&2&&(Kt("tabIndex",n._getTabindexAttribute()),at("aria-expanded",n._getAriaExpanded())("aria-level",n.level+1)("aria-posinset",n._getPositionInSet())("aria-setsize",n._getSetSize()))},inputs:{tabIndexInputBinding:[2,"tabIndex","tabIndexInputBinding",e=>e==null?0:Ue(e)],disabled:[2,"disabled","disabled",Qe]},outputs:{activation:"activation",expandedChange:"expandedChange"},exportAs:["matTreeNode"],features:[Ce([{provide:Se,useExisting:s}]),je]})}return s})(),Ui=(()=>{class s extends mr{data;static \u0275fac=(()=>{let e;return function(n){return(e||(e=$e(s)))(n||s)}})();static \u0275dir=de({type:s,selectors:[["","matTreeNodeDef",""]],inputs:{when:[0,"matTreeNodeDefWhen","when"],data:[0,"matTreeNode","data"]},features:[Ce([{provide:mr,useExisting:s}]),je]})}return s})(),Ri=(()=>{class s extends rn{node;get disabled(){return this.isDisabled}set disabled(e){this.isDisabled=e}get tabIndex(){return this.isDisabled?-1:this._tabIndex}set tabIndex(e){this._tabIndex=e}_tabIndex;ngOnInit(){super.ngOnInit()}ngAfterContentInit(){super.ngAfterContentInit()}ngOnDestroy(){super.ngOnDestroy()}static \u0275fac=(()=>{let e;return function(n){return(e||(e=$e(s)))(n||s)}})();static \u0275dir=de({type:s,selectors:[["mat-nested-tree-node"]],hostAttrs:[1,"mat-nested-tree-node"],inputs:{node:[0,"matNestedTreeNode","node"],disabled:[2,"disabled","disabled",Qe],tabIndex:[2,"tabIndex","tabIndex",e=>e==null?0:Ue(e)]},outputs:{activation:"activation",expandedChange:"expandedChange"},exportAs:["matNestedTreeNode"],features:[Ce([{provide:rn,useExisting:s},{provide:Se,useExisting:s},{provide:At,useExisting:s}]),je]})}return s})(),mu=(()=>{class s extends nn{get level(){return this._level}set level(e){this._setLevelInput(e)}get indent(){return this._indent}set indent(e){this._setIndentInput(e)}static \u0275fac=(()=>{let e;return function(n){return(e||(e=$e(s)))(n||s)}})();static \u0275dir=de({type:s,selectors:[["","matTreeNodePadding",""]],inputs:{level:[2,"matTreeNodePadding","level",Ue],indent:[0,"matTreeNodePaddingIndent","indent"]},features:[Ce([{provide:nn,useExisting:s}]),je]})}return s})(),hr=(()=>{class s{viewContainer=h(Vt);_node=h(At,{optional:!0});static \u0275fac=function(r){return new(r||s)};static \u0275dir=de({type:s,selectors:[["","matTreeNodeOutlet",""]],features:[Ce([{provide:$t,useExisting:s}])]})}return s})(),Ni=(()=>{class s extends St{_nodeOutlet=void 0;static \u0275fac=(()=>{let e;return function(n){return(e||(e=$e(s)))(n||s)}})();static \u0275cmp=ge({type:s,selectors:[["mat-tree"]],viewQuery:function(r,n){if(r&1&&Gt(hr,7),r&2){let i;ct(i=lt())&&(n._nodeOutlet=i.first)}},hostAttrs:[1,"mat-tree"],exportAs:["matTree"],features:[Ce([{provide:St,useExisting:s}]),je],decls:1,vars:0,consts:[["matTreeNodeOutlet",""]],template:function(r,n){r&1&&Fe(0,0)},dependencies:[hr],styles:[`.mat-tree { 33 display: block; 34 background-color: var(--mat-tree-container-background-color, var(--mat-sys-surface)); 35} 36 37.mat-tree-node, 38.mat-nested-tree-node { 39 color: var(--mat-tree-node-text-color, var(--mat-sys-on-surface)); 40 font-family: var(--mat-tree-node-text-font, var(--mat-sys-body-large-font)); 41 font-size: var(--mat-tree-node-text-size, var(--mat-sys-body-large-size)); 42 font-weight: var(--mat-tree-node-text-weight, var(--mat-sys-body-large-weight)); 43} 44 45.mat-tree-node { 46 display: flex; 47 align-items: center; 48 flex: 1; 49 word-wrap: break-word; 50 min-height: var(--mat-tree-node-min-height, 48px); 51} 52 53.mat-nested-tree-node { 54 border-bottom-width: 0; 55} 56`],encapsulation:2})}return s})(),zi=(()=>{class s extends on{static \u0275fac=(()=>{let e;return function(n){return(e||(e=$e(s)))(n||s)}})();static \u0275dir=de({type:s,selectors:[["","matTreeNodeToggle",""]],inputs:{recursive:[0,"matTreeNodeToggleRecursive","recursive"]},features:[Ce([{provide:on,useExisting:s}]),je]})}return s})();var Li=(()=>{class s{static \u0275fac=function(r){return new(r||s)};static \u0275mod=Ht({type:s});static \u0275inj=zt({imports:[Fi,Fn]})}return s})();var gr=class extends Rn{get data(){return this._data.value}set data(t){this._data.next(t)}_data=new ve([]);connect(t){return Nt(t.viewChange,this._data).pipe(O(()=>this.data))}disconnect(){}};var ro=["listTrigger"],no=s=>({node:s,hasChild:!1}),io=s=>({node:s,hasChild:!0}),oo=s=>({"padding-left":s}),so=s=>({selected:s});function ao(s,t){s&1&&Fe(0)}function co(s,t){if(s&1&&(g(0,"mat-nested-tree-node",10),st(1,ao,1,0,"ng-container",11),b()),s&2){let e=t.$implicit;S();let r=fe(19);_(),k("ngTemplateOutlet",r)("ngTemplateOutletContext",V(2,no,e))}}function lo(s,t){s&1&&Fe(0)}function po(s,t){if(s&1&&(g(0,"div",12),Fe(1,13),b()),s&2){let e=S().$implicit;k("ngStyle",V(1,oo,e.id?"16px":"2px"))}}function uo(s,t){if(s&1&&(g(0,"mat-nested-tree-node",10),st(1,lo,1,0,"ng-container",11),R(2,po,2,3,"div",12),b()),s&2){let e=t.$implicit,r=S(),n=fe(19);_(),k("ngTemplateOutlet",n)("ngTemplateOutletContext",V(3,io,e)),_(),N(r._treeControl.isExpanded(e)?2:-1)}}function mo(s,t){if(s&1&&(g(0,"button",15)(1,"mat-icon",18),v(2),b()()),s&2){let e=S().node,r=S();at("aria-label","Toggle "+e.name),_(2),B(" ",r._treeControl.isExpanded(e)?"expand_more":"chevron_right"," ")}}function ho(s,t){s&1&&(g(0,"button",19),v(1,"\xA0"),b())}function go(s,t){if(s&1&&R(0,ho,2,0,"button",19),s&2){let e=S().node;N(e.id&&e.type===0||e.type>=4?0:-1)}}function fo(s,t){s&1&&(g(0,"button",19),v(1,"\xA0"),b())}function _o(s,t){if(s&1&&R(0,fo,2,0,"button",19),s&2){let e=S().node;N(e.id&&e.type===0||e.type>=4?0:-1)}}function bo(s,t){if(s&1&&(g(0,"mat-icon",20),v(1,"folder"),b(),v(2)),s&2){let e=S().node;_(2),B(" ",e.name," ")}}function vo(s,t){if(s&1&&(g(0,"mat-icon",21),v(1,"folder"),b(),v(2)),s&2){let e=S().node;_(2),B(" ",e.name," ")}}function yo(s,t){if(s&1&&(g(0,"mat-icon",22),v(1,"folder"),b(),v(2)),s&2){let e=S().node;_(2),B(" ",e.name," ")}}function Co(s,t){if(s&1){let e=W();g(0,"div",14),R(1,mo,3,2,"button",15)(2,go,1,1),st(3,_o,1,1,"ng-template",null,3,$r),g(5,"div",16)(6,"div",17),I("keydown.enter",function(){let n=z(e).node,i=S();return L(i._onNodeClick(n))})("click",function(){let n=z(e).node,i=S();return L(i._onNodeClick(n))}),R(7,bo,3,1)(8,vo,3,1)(9,yo,3,1),b()()()}if(s&2){let e,r,n=t.hasChild,i=t.node,o=S();_(),N(n?1:2),_(4),k("ngClass",V(3,so,i.id===((e=o.project())==null?null:e.folder))),_(2),N((r=i.type)===4?7:r===5?8:r===6?9:-1)}}var fr=class s{project=H();isCorporate;userId;_translate=h(Le);_current;_link="my-projects";_nextProject;_pdvs;_previousProject;_treeControl=new ur(t=>t.children);_treeSource=new gr;_destroyRef=h(Lt);_dialogsService=h(Y);_listTrigger=jn("listTrigger");_projectApiService=h(Pe);_router=h(ft);ngOnInit(){this.loadFolders()}_findPdvTree(t,e){if(t.id===e)return t;if(t.children)for(let r of t.children){let n=this._findPdvTree(r,e);if(n)return n}}_hasChild(t,e){return e.children?.length>0}_onNextProject(){this.loadPreviousAndNextProject(2)}_onNodeClick(t){if(t.type!==5){let e=this.project(),r=t.type===4?e.idParentProject:e.id;this._projectApiService.byPdv(r,t.id).pipe(ue(this._destroyRef)).subscribe({next:n=>{n&&(this._listTrigger().closeMenu(),this._router.navigate([this._link,n]))}})}}_onPreviousProject(){this.loadPreviousAndNextProject(1)}_expand(t,e){let r=[],n=o=>{for(let a=0;a<o.children?.length;a++)r.push({parent:o,child:o.children[a]}),n(o.children[a])};n(t);let i=r.find(o=>o.child.id===e);for(;i;)this._treeControl.expand(i.parent),i=r.find(o=>o.child===i.parent)}createRouterLink(t,e){let r=e&&e!=="00000000-0000-0000-0000-000000000000"?e:t;this._router.navigate([this._link,r])}loadFolders(){let t=this.project();this._projectApiService.allNavPdv(t.idParentProject??t.id).pipe(ue(this._destroyRef)).subscribe({next:e=>{e&&(this._treeSource.data=[e],this._treeControl.expand(e),t.folder&&this._expand(e,t.folder))},error:e=>{this._dialogsService.showErrorSnackbar(e)}})}loadPreviousAndNextProject(t){let e=this.project();this._projectApiService.navigationPdv(e.id,e.idParentProject??e.id).pipe(ue(this._destroyRef)).subscribe({next:r=>{switch(t){case 1:this.createRouterLink(e.id,r.PreviousProject);break;case 2:this.createRouterLink(e.id,r.NextProject);break}},error:r=>{this._dialogsService.showErrorSnackbar(r)}})}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=ge({type:s,selectors:[["catman-project-navigation-chain"]],viewQuery:function(e,r){e&1&&xn(r._listTrigger,ro,5),e&2&&Pn()},inputs:{project:[1,"project"],isCorporate:"isCorporate",userId:"userId"},decls:20,vars:19,consts:[["listTrigger","matMenuTrigger"],["menu","matMenu"],["nodeTemplate",""],["padding",""],["mat-icon-button","",3,"click","matTooltip","disabled"],["mat-icon-button","",3,"matTooltip","disabled","matMenuTriggerFor"],[1,"mat-menu-project-navegation"],[3,"dataSource","tree
56Control"],["matTreeNodeToggle","",4,"matTreeNodeDef"],["matTreeNodeToggle","",4,"matTreeNodeDef","matTreeNodeDefWhen"],["matTreeNodeToggle",""],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"ngStyle"],["matTreeNodeOutlet",""],[1,"mat-tree-node-nav","items-center"],["mat-icon-button",""],[1,"folder-name-container",3,"ngClass"],["tabindex","0",1,"folder-name",3,"keydown.enter","click"],[1,"mat-icon-rtl-mirror"],["disabled","","mat-icon-button",""],[1,"chain",2,"vertical-align","middle"],[1,"cluster",2,"vertical-align","middle"],[1,"pdv",2,"vertical-align","middle"]],template:function(e,r){if(e&1&&(g(0,"button",4),M(1,"translate"),I("click",function(){return r._onPreviousProject()}),g(2,"mat-icon"),v(3,"arrow_left"),b()(),g(4,"button",5,0),M(6,"translate"),g(7,"mat-icon"),v(8,"list"),b()(),g(9,"button",4),M(10,"translate"),I("click",function(){return r._onNextProject()}),g(11,"mat-icon"),v(12,"arrow_right"),b()(),g(13,"mat-menu",6,1)(15,"mat-tree",7),st(16,co,2,4,"mat-nested-tree-node",8)(17,uo,3,5,"mat-nested-tree-node",9),b()(),st(18,Co,10,5,"ng-template",null,2,$r)),e&2){let n=fe(14),i=r._treeSource.data.length===0;k("matTooltip",ne(T(1,13,"project.navegation.previous.project")))("disabled",i),_(4),k("matTooltip",ne(T(6,15,"project.navegation.list.project")))("disabled",i)("matMenuTriggerFor",n),_(5),k("matTooltip",ne(T(10,17,"project.navegation.next.project")))("disabled",i),_(6),k("dataSource",r._treeSource)("treeControl",r._treeControl),_(2),k("matTreeNodeDefWhen",r._hasChild)}},dependencies:[ze,Ne,pt,Wt,Tn,Mn,Re,mt,Ge,He,Ke,gt,ht,Li,Ri,Ui,zi,Ni,hr,_t,Ve,Be],styles:[".mat-mdc-menu-panel[_ngcontent-%COMP%]{width:150px!important;max-height:100px!important}.mat-tree-node-nav[_ngcontent-%COMP%]{display:flex;min-height:unset;margin-bottom:2px;margin-left:1px;margin-right:14px}.expand-label[_ngcontent-%COMP%]{flex-grow:1;font-size:14px;font-weight:400;line-height:38px;padding-left:4px}.folder-icon[_ngcontent-%COMP%]{margin-right:5px;font-size:16px;width:16px;height:16px;vertical-align:middle}.folder-name-container[_ngcontent-%COMP%]{display:flex;flex-grow:1;border-radius:4px;cursor:pointer;position:relative}.folder-name-container[_ngcontent-%COMP%]:hover:not(.selected){background-color:#0000001a}.folder-name[_ngcontent-%COMP%]{text-decoration:none;padding:4px 8px;flex-grow:1}.selected[_ngcontent-%COMP%]{background-color:#51aec9;color:#fff;cursor:default}.mat-tree[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{width:16px;height:16px;font-size:16px!important;line-height:16px!important}.menu-project-navegation[_ngcontent-%COMP%] .mat-mdc-icon-button[_ngcontent-%COMP%]{width:28px!important;height:28px!important;line-height:28px!important;padding:0!important}.menu-project-navegation[_ngcontent-%COMP%] .mat-mdc-icon-button[_ngcontent-%COMP%] .mat-icon[_ngcontent-%COMP%]{line-height:28px!important}.folder-actions[_ngcontent-%COMP%]{display:flex;position:absolute;right:5px;top:50%;transform:translateY(-50%);align-items:center;padding-left:40px}.chain[_ngcontent-%COMP%]{color:brown}.cluster[_ngcontent-%COMP%]{color:#87ceeb}.pdv[_ngcontent-%COMP%]{color:orange}.user[_ngcontent-%COMP%]{border-top:solid 1px rgba(0,0,0,.1);padding-top:5px;margin-bottom:5px;display:block}"]})};var wt=class s{_activatedRoute=h(Xt);_projectApiService=h(Pe);_routerEx=h(bt);_corporate=!1;_isSample=!1;_parentId;_segments;_userId;get corporate(){return this._corporate}get sample(){return this._isSample}get userId(){return this._userId}getLink(t=!1){this._parentId=this._activatedRoute.snapshot.queryParams.parentId,this._segments=this._routerEx.segments,this._isSample=!1;let e=null;return this._corporate=this._segments.includes("admin")&&this._segments.includes("corporate")||this._segments.includes("corporate-projects")||this._segments.includes("users"),this._segments.includes("admin")&&this._segments.includes("corporate")?(this._userId=this._segments[2],e=t?this._segments.slice(0,this._segments.length-1).join("/"):`/${this._segments.slice(0,this._segments.length-1).join("/")}`):this._segments.includes("corporate-projects")?e="/corporate-projects":this._parentId&&window.history.length>1?e=`/my-projects/${this._parentId}/assortment`:this._segments.includes("samples")?(this._isSample=!0,e="/admin/samples"):this._segments.includes("users")&&(e=`/admin/users/${this._segments[2]}/projects`),e}getLinkStore(){this._segments=this._routerEx.segments;let t=null;return this._segments?.includes("storecheck")&&(t=`/${this._segments.slice(0,this._segments.length).join("/")}`),t}validateSharedProject(){let t=this._routerEx.previousUrl,e=this._getFolderTypeFromLink(t);e&&this.getFolderUser().pipe(D(r=>rt(this,null,function*(){return this.getFolderByType(r,e)})),G(r=>this.setStorageProjectFilter(r))).subscribe()}_getFolderTypeFromLink(t){return t.includes("demo")?"demo":t.includes("shared")?"shared":null}getFolderByType(t,e){switch(e){case"demo":return this.getFolderDemo(t);case"shared":return this.getFolderShared(t);default:throw Error}}getFolderDemo(t){return t.children?.find(e=>e.name==="Demos"&&e.special===0)}getFolderShared(t){return t.children?.find(e=>e.name==="folder.shared-projects"&&e.special===1)}getFolderUser(){return this._projectApiService.folders()}setStorageProjectFilter(t){Qt(`my-projects.filter${this._userId?`.${this._userId}`:""}`,{nameFilter:null,sharedByFilter:null,categoryFilter:null,storeFilter:null,folder:{children:[],id:t.id,name:t.name,ownerId:t.ownerId,special:t.special,total:t.total},productFilter:null,viewProjects:!1})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var Po=(s,t)=>[s,t],So=(s,t)=>t.id;function wo(s,t){if(s&1&&(g(0,"a",3)(1,"div",4),v(2),b()()),s&2){let e=t.$implicit,r=S();k("routerLink",wn(3,Po,r._link,e.id))("routerLinkActive","selected"),_(2),dt(e.name)}
56}var _r=class s{isCorporate=H(void 0);project=H();userId=H(void 0);_link;_nextProject=Ar(()=>this._getNextProject());_onBackgroundProcess;_previousProject=Ar(()=>this._getPrevProject());_projectList=Ze({params:()=>this._projectsRequest(),stream:({params:t})=>this._projectsLoader(t)});_configurationService=h(Yt);_projectApiService=h(Pe);_routerService=h(wt);constructor(){this._onBackgroundProcess=Je(this._configurationService.onBackgroundProcess.pipe(ue())),this._link=this._routerService.getLink()??"/my-projects"}_getNextProject(){let t=this._projectList.value(),e=this.project();if(t&&e){let r=t.findIndex(n=>n.id===e.id);if(r<t.length-1)return`${this._link}/${t[r+1].id}`}return null}_getPrevProject(){let t=this._projectList.value(),e=this.project();if(t&&e){let r=t.findIndex(n=>n.id===e.id);if(r>0)return`${this._link}/${t[r-1].id}`}return null}_projectsLoader(t){let e=t.project,r=t.userId;if(!e)return E([]);let n;if(this.isCorporate()){let i=Vr(`my-projects-corporate.filter${r?`.${r}`:""}`);n=e.shared?i?.folder.id:e.folder,r=i?.folder?.ownerId}else{let i=Vr(`my-projects.filter${r?`.${r}`:""}`);n=e.shared?i?.folder.id:e.folder}return this._projectApiService.all({page:0,pageSize:1e4,sort:"modified_desc",filter:{name:null,sharedBy:null,store:null,category:null,folder:n,viewProjects:!1},user:r}).pipe(O(i=>i.results))}_projectsRequest(){return{project:this.project(),userId:this.userId()}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=ge({type:s,selectors:[["catman-project-select"]],inputs:{isCorporate:[1,"isCorporate"],project:[1,"project"],userId:[1,"userId"]},decls:17,vars:18,consts:[["menu","matMenu"],["mat-icon-button","",3,"matTooltip","disabled","routerLink"],["mat-icon-button","","id","listElm",3,"matTooltip","disabled","matMenuTriggerFor"],["mat-list-item","",3,"routerLink","routerLinkActive"],["matListItemTitle",""]],template:function(e,r){if(e&1&&(g(0,"button",1),M(1,"translate"),g(2,"mat-icon"),v(3,"arrow_left"),b()(),g(4,"button",2),M(5,"translate"),g(6,"mat-icon"),v(7,"list"),b()(),g(8,"button",1),M(9,"translate"),g(10,"mat-icon"),v(11,"arrow_right"),b()(),g(12,"mat-menu",null,0)(14,"mat-nav-list"),yn(15,wo,3,6,"a",3,So),b()()),e&2){let n=fe(13),i=r._projectList.value(),o=r._onBackgroundProcess()||((i==null?null:i.length)??0)<=1,a=r._previousProject(),c=r._nextProject();k("matTooltip",ne(T(1,12,"project.navegation.previous.project")))("disabled",o||a===null)("routerLink",a),_(4),k("matTooltip",ne(T(5,14,"project.navegation.list.project")))("disabled",o)("matMenuTriggerFor",n),_(4),k("matTooltip",ne(T(9,16,"project.navegation.next.project")))("disabled",o||c===null)("routerLink",c),_(7),Cn(i)}},dependencies:[Re,mt,ci,ze,Ne,ai,si,oi,ii,Ge,He,Ke,Xn,gt,ht,_t,zn,Ln,Ve,Be],styles:[".mdc-list[_ngcontent-%COMP%]{padding:0;--mat-list-list-item-leading-icon-start-space: 16px;--mat-list-list-item-leading-icon-end-space: 32px;--mat-list-list-item-one-line-container-height: 32px;--mat-list-list-item-two-line-container-height: 48px;--mat-list-list-item-three-line-container-height: 72px}.mdc-list[_ngcontent-%COMP%] .mdc-list-item__start[_ngcontent-%COMP%], .mdc-list[_ngcontent-%COMP%] .mdc-list-item__end[_ngcontent-%COMP%]{--mat-radio-state-layer-size: 28px;--mat-radio-touch-target-display: none}.mdc-list[_ngcontent-%COMP%] .mat-mdc-list-item.mdc-list-item--with-leading-avatar.mdc-list-item--with-one-line[_ngcontent-%COMP%], .mdc-list[_ngcontent-%COMP%] .mat-mdc-list-item.mdc-list-item--with-leading-checkbox.mdc-list-item--with-one-line[_ngcontent-%COMP%], .mdc-list[_ngcontent-%COMP%] .mat-mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-one-line[_ngcontent-%COMP%]{height:40px}.mdc-list[_ngcontent-%COMP%] .mat-mdc-list-item.mdc-list-item--with-leading-avatar.mdc-list-item--with-two-lines[_ngcontent-%COMP%], .mdc-list[_ngcontent-%COMP%] .mat-mdc-list-item.mdc-list-item--with-leading-checkbox.mdc-list-item--with-two-lines[_ngcontent-%COMP%], .mdc-list[_ngcontent-%COMP%] .mat-mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-two-lines[_ngcontent-%COMP%]{height:56px}.selected[_ngcontent-%COMP%]{--mat-list-list-item-container-color: var(--mat-sys-primary);--mat-list-list-item-label-text-color: var(--mat-sys-on-primary)}"]})};var br=class s{PROVIDER_URLS={chatgpt:{primary:"https://chatgpt.com/?q="},claude:{primary:"claude://claude.ai/new?q=",fallback:"https://claude.ai/new?q="}};FALLBACK_DELAY_MS=1500;_translate=h(Le);buildContextPrompt(t){let e=[];return e.push(this._translate.instant("project.aiassistant.promps",{projectId:t.id,projectName:t.name})),e.join(` 57`)}openAssistant(t,e){return rt(this,null,function*(){let r=encodeURIComponent(e);try{yield navigator.clipboard.writeText(e)}catch(o){}let{primary:n,fallback:i}=this.PROVIDER_URLS[t];if(!i){window.open(`${n}${r}`,"_blank","noopener,noreferrer");return}this.openWithFallback(`${n}${r}`,`${i}${r}`)})}openWithFallback(t,e){let r=!1,n=()=>{r=!0};window.addEventListener("blur",n),window.location.href=t,setTimeout(()=>{window.removeEventListener("blur",n),r||window.open(e,"_blank","noopener,noreferrer")},this.FALLBACK_DELAY_MS)}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};var vr=class s{constructor(t,e){this.aiAssistantService=t;this.dialogsService=e}
57loggedIn=H({chatgpt:!1,claude:!1});project=H.required();isSending=X(!1);selectProvider(t){return rt(this,null,function*(){if(!this.isSending()){if(!this.loggedIn()[t]){this.dialogsService.showModal(ae.mcpAssistance()).subscribe();return}this.isSending.set(!0);try{let e=this.aiAssistantService.buildContextPrompt(this.project());yield this.aiAssistantService.openAssistant(t,e)}finally{this.isSending.set(!1)}}})}static \u0275fac=function(e){return new(e||s)(Er(br),Er(Y))};static \u0275cmp=ge({type:s,selectors:[["catman-ai-assistant"]],inputs:{loggedIn:[1,"loggedIn"],project:[1,"project"]},decls:30,vars:14,consts:[["menu",""],["type","button","matButton","tonal","color","tertiary","aria-haspopup","true",3,"disabled","matMenuTriggerFor"],[1,"size-4!","text-sm!"],[1,"px-2","opacity-60"],["mat-menu-item","","type","button","role","menuitem",3,"click"],[1,"flex","items-center","gap-1"],[1,"flex","size-8","items-center","justify-center","rounded","bg-[#109D7D]","text-xs","text-white"],[1,"flex","flex-col","items-start"],[1,"m-0!","text-xs!","opacity-70"],["mat-menu-item","","type","button","role","menuitem",1,"ai-assistant__option",3,"click"],[1,"flex","size-8","items-center","justify-center","rounded","bg-[#D27053]","text-xs","text-white"]],template:function(e,r){if(e&1&&(g(0,"button",1)(1,"mat-icon",2),v(2,"stars_2"),b(),v(3),M(4,"translate"),b(),g(5,"mat-menu",null,0)(7,"div",3),v(8),M(9,"translate"),b(),g(10,"button",4),I("click",function(){return r.selectProvider("chatgpt")}),g(11,"span",5)(12,"span",6),v(13,"GPT"),b(),g(14,"span",7)(15,"span"),v(16,"ChatGPT"),b(),g(17,"span",8),v(18),M(19,"translate"),b()()()(),g(20,"button",9),I("click",function(){return r.selectProvider("claude")}),g(21,"span",5)(22,"span",10),v(23,"C"),b(),g(24,"span",7)(25,"span"),v(26,"Claude"),b(),g(27,"span",8),v(28),M(29,"translate"),b()()()()()),e&2){let n=fe(6);k("disabled",r.isSending())("matMenuTriggerFor",n),_(3),B(" ",T(4,6,"project.aiassistant.btn"),` 58`);let i=r.loggedIn();_(5),dt(T(9,8,"project.aiassistant.desc")),_(10),dt(T(19,10,i.chatgpt?"project.aiassistant.chatgpt.desc":"project.aiassistant.chatgpt.desc.notlogged")),_(10),dt(T(29,12,i.claude?"project.aiassistant.claude.desc":"project.aiassistant.claude.desc.notlogged"))}},dependencies:[pt,Re,Un,ze,Ne,Ge,He,Zt,Ke,Ve,Be],encapsulation:2})};var Vi=()=>({}),re=s=>({"subscription-required":s});function jo(s,t){if(s&1&&(g(0,"button",3)(1,"mat-icon"),v(2,"more_vert"),b()()),s&2){S();let e=fe(12);k("matMenuTriggerFor",e)}}function Mo(s,t){if(s&1&&Ae(0,"catman-ai-assistant",8),s&2){let e=S(2),r=$(5);k("project",r)("loggedIn",e._mcpLoggedIn.value())}}function To(s,t){if(s&1){let e=W();g(0,"button",9),M(1,"translate"),I("click",function(){z(e);let n=S(2);return L(n._onRefreshClick())}),g(2,"mat-icon"),v(3,"refresh"),b()()}s&2&&k("matTooltip",ne(T(1,2,"button.refresh")))}function Io(s,t){if(s&1&&Ae(0,"catman-project-select",12),s&2){let e=S(2),r=$(3),n=$(5);k("project",n)("userId",e.userId())("isCorporate",r)}}function Eo(s,t){if(s&1&&Ae(0,"catman-project-navigation-chain",12),s&2){let e=S(2),r=$(3),n=$(5);k("project",n)("userId",e.userId())("isCorporate",r)}}function Oo(s,t){if(s&1){let e=W();g(0,"button",16),M(1,"translate"),I("click",function(){z(e);let n=S(2);return L(n._onUndoClick())}),g(2,"mat-icon",17),v(3,"switch_access_shortcut"),b()()}if(s&2){let e=S(2),r=$(6);k("matTooltip",It("",T(1,4,"button.undo")," (",e._ctrl,"-Z)"))("disabled",r)}}function Do(s,t){if(s&1){let e=W();g(0,"button",9),M(1,"translate"),I("click",function(){z(e);let n=S(2);return L(n._fullscreen.exit())}),g(2,"mat-icon"),v(3,"fullscreen_exit"),b()()}s&2&&k("matTooltip",ne(T(1,2,"button.fullscreen.exit")))}function $o(s,t){if(s&1){let e=W();g(0,"button",9),M(1,"translate"),I("click",function(){z(e);let n=S(2);return L(n._fullscreen.enter())}),g(2,"mat-icon"),v(3,"fullscreen"),b()()}s&2&&k("matTooltip",ne(T(1,2,"button.fullscreen")))}function Ao(s,t){if(s&1){let e=W();g(0,"button",18),M(1,"translate"),I("click",function(){z(e);let n=S(2);return L(n._onFindClick())}),g(2,"mat-icon"),v(3,"search"),b()()}if(s&2){let e=S(2),r=$(0);k("matTooltip",It("",T(1,4,"button.search")," (",e._ctrl,"-F)"))("ngClass",V(6,re,!r["project.find-product"]))}}function Fo(s,t){if(s&1){let e=W();g(0,"button",19),M(1,"translate"),I("click",function(){z(e);let n=S(2);return L(n._onSyncSectionsClick())}),g(2,"mat-icon"),v(3,"sync"),b()()}if(s&2){S(2);let e=$(0),r=$(4);k("matTooltip",ne(T(1,4,"assortment.sync-product-price")))("disabled",r)("ngClass",V(6,re,!e["project.assortment"]))}}function Uo(s,t){if(s&1){let e=W();g(0,"button",19),M(1,"translate"),I("click",function(){z(e);let n=S(3);return L(n._onExportClick())}),g(2,"mat-icon"),v(3,"upload"),b()(),g(4,"button",19),M(5,"translate"),I("click",function(){z(e);let n=S(3);return L(n._onCopyClick())}),g(6,"mat-icon"),v(7,"file_copy"),b()()}if(s&2){let e=S(3),r=$(0),n=$(4),i=$(5);k("matTooltip",It("",T(1,9,"button.export")," (",e._alt,"-S)"))("disabled",n)("ngClass",V(13,re,!r["project.export"])),_(4),k("matTooltip",ne(T(5,11,"button.copy")))("disabled",n)("ngClass",V(15,re,!r["project.copy"]&&!(i!=null&&i.shared)||!r["project.copy-shared"]&&(i==null?null:i.shared)))}}function Ro(s,t){if(s&1){let e=W();g(0,"button",16),M(1,"translate"),I("click",function(){z(e);let n=S(3);return L(n._onViewImageClick())}),g(2,"mat-icon"),v(3,"image"),b()()}if(s&2){S(3);let e=$(4);k("matTooltip",ne(T(1,3,"button.view-image")))("disabled",e)}}function No(s,t){if(s&1&&(g(0,"button",21)(1,"mat-icon"),v(2,"share"),b()()),s&2){S(4);let e=fe(35),r=$(0),n=$(4);k("disabled",n)("matMenuTriggerFor",e)("ngClass",V(3,re,!r["project.share"]))}}function zo(s,t){if(s&1){let e=W();g(0,"button",19),M(1,"translate"),I("click",function(){z(e);let n=S(4);return L(n._onShareClick())}),g(2,"mat-icon"),v(3,"share"),b()()}if(s&2){S(4);let e=$(0),r=$(4);k("matTooltip",ne(T(1,4,"button.share")))("disabled",r)("ngClass",V(6,re,!e["project.share"]))}}function Lo(s,t){if(s&1&&R(0,No,3,5,"button",21)(1,zo,4,8,"button",15),s&2){S(3);let e=$(2),r=$(3);N(r||e?0:1)}}function Bo(s,t){if(s&1&&(g(0,"button",20),M(1,"translate"),g(2,"mat-icon"),v(3,"picture_as_pdf"),b()(),R(4,Uo,8,17),R(5,Ro,4,5,"button",13),R(6,Lo,2,1)),s&2){let e=S(2),r=fe(23),n=$(0),i=$(1),o=$(2),a=$(3),c=$(4),d=$(5);k("matTooltip",It("",T(1,9,"button.pdf")," (",e._alt,"-Shift-P)"))("disabled",c)("matMenuTriggerFor",r)("ngClass",V(11,re,!n["project.export-pdf"])),_(4),N(a&&(!i["corporate.project.view"]||e._userAdmin||o)||!a?4:-1),_(),N(e._hasProjectImage.value()?5:-1),_(),N(d.shared?-1:6)}}function Vo(s,t){if(s&1){let e=W();R(0,Mo,1,2,"catman-ai-assistant",8),g(1,"button",9),M(2,"translate"),I("click",function(){z(e);let n=S();return L(n._onBackClick(n._backLink))}),g(3,"mat-icon"),v(4,"keyboard_arrow_left"),b()(),R(5,To,4,4,"button",10),Ae(6,"mat-divider",11),R(7,Io,1,3,"catman-project-select",12)(8,Eo,1,3,"catman-project-navigation-chain",12),Ae(9,"mat-divider",11),R(10,Oo,4,6,"button",13),R(11,Do,4,4,"button",10)(12,$o,4,4,"button",10),R(13,Ao,4,8,"button",14),R(14,Fo,4,8,"button",15),R(15,Bo,7,13),Ae(16,"mat-divider",11)}if(s&2){let e=S(),r=$(0),n=$(5),i=$(7);N(r["user.mcp.client-id"]&&e._hasclientSecret.value()?0:-1),_(),k("matTooltip",ne(T(2,13,"button.back"))),_(4),N(i?5:-1),_(),k("vertical",!0),_(),N(e._isSpecialProject()?8:7),_(2),k("vertical",!0),_(),N(e.undoVisible&&n?10:-1),_(),N(e._fullscreen.isFullscreen?11:12),_(2),N(e.showFind()?13:-1),_(),N(n!=null&&n.idParentProject||n!=null&&n.folderName&&!(n!=null&&n.idParentProject)?14:-1),_(),N(n?15:-1),_(),k("vertical",!0)}}function Ho(s,t){if(s&1){let e=W();g(0,"button",22),I("click",function(){z(e);let n=S();return L(n._onUndoClick())}),g(1,"mat-icon",17),v(2,"switch_access_shortcut"),b(),v(3),M(4,"translate"),b()}if(s&2){S();let e=$(6);k("disabled",e),_(3),B(" ",T(4,2,"button.undo")," ")}}function Ko(s,t){if(s&1){let e=W();g(0,"button",4),I("click",function(){z(e);let n=S();return L(n._fullscreen.enter())}),g(1,"mat-icon"),v(2,"fullscreen"),b(),v(3),M(4,"translate"),b()}s&2&&(_(3),B(" ",T(4,1,"button.fullscreen")," "))}function Go(s,t){if(s&1){let e=W();g(0,"button",4),I("click",function(){z(e);let n=S();return L(n._fullscreen.exit())}),g(1,"mat-icon"),v(2,"fullscreen_exit"),b(),v(3),M(4,"translate"),b()}s&2&&(_(3),B(" ",T(4,1,"button.fullscreen.exit")," "))}function Wo(s,t){if(s&1){let e=W();g(0,"button",4),I("click",function(){z(e);let n=S(2);return L(n._onViewImageClick())}),g(1,"mat-icon"),v(2,"image"),b(),v(3),M(4,"translate"),b()}s&2&&(_(3),B(" ",T(4,1,"button.view-image")," "))}function qo(s,t){if(s&1){let e=W();g(0,"button",7),I("click",function(){z(e);let n=S(2);return L(n._onShareClick())}),g(1,"mat-icon"),v(2,"share"),b(),v(3),M(4,"translate"),b()}if(s&2){S(2);let e=$(0);k("ngClass",V(4,re,!e["project.share"])),_(3),B(" ",T(4,2,"button.share")," ")}}function Xo(s,t){if(s&1){let e=W();g(0,"button",4),I("click",function(){z(e);let n=S(2);return L(n._onRefreshClick())}),g(1,"mat-icon"),v(2,"refresh"),b(),v(3),M(4,"translate"),b()}s&2&&(_(3),B(" ",T(4,1,"button.refresh")," "))}function Yo(s,t){if(s&1){let e=W();g(0,"button",7),I("click",function(){z(e);let n=S();return L(n._onExportClick())}),g(1,"mat-icon"),v(2,"upload"),b(),v(3),M(4,"translate"),b(),g(5,"button",7),I("click",function(){z(e);let n=S();return L(n._onExportPdfSimpleClick())}),g(6,"mat-icon"),v(7,"print"),b(),v(8),M(9,"translate"),b(),g(10,"button",7),I("click",function(){z(e);let n=S();return L(n._onExportPdfDetailedClick())}),g(11,"mat-icon"),v(12,"picture_as_pdf"),b(),v(13),M(14,"translate"),b(),g(15,"button",7),I("click",function(){z(e);let n=S();return L(n._onCopyClick())}
58),g(16,"mat-icon"),v(17,"file_copy"),b(),v(18),M(19,"translate"),b(),R(20,Wo,5,3,"button",6),R(21,qo,5,6,"button",23),R(22,Xo,5,3,"button",6)}if(s&2){let e=S(),r=$(0),n=$(5),i=$(7);k("ngClass",V(19,re,!r["project.export"])),_(3),B(" ",T(4,11,"button.export")," "),_(2),k("ngClass",V(21,re,!r["project.print"])),_(3),B(" ",T(9,13,"button.print")," "),_(2),k("ngClass",V(23,re,!r["project.export-pdf"])),_(3),B(" ",T(14,15,"button.pdf")," "),_(2),k("ngClass",V(25,re,!r["project.copy"]&&!(n!=null&&n.shared)||!r["project.copy-shared"]&&(n==null?null:n.shared))),_(3),B(" ",T(19,17,"button.copy")," "),_(2),N(e._hasProjectImage.value()?20:-1),_(),N(n!=null&&n.shared?-1:21),_(),N(i?22:-1)}}function Qo(s,t){if(s&1){let e=W();g(0,"button",7),I("click",function(){z(e);let n=S();return L(n._onExportPdfCustomProjectClick())}),v(1),b(),Ae(2,"mat-divider")}if(s&2){let e=S(),r=$(0);k("ngClass",V(2,re,!r["project.export.custom.pdf"])),_(),B(" ",e._onGetSetting()," ")}}var Hi=class s{chain=H.required();changed=Et();editProductData=H(!1);graph=H(void 0);isCorporate=H(void 0);isRack=H(!1);printMode=H(0);project=H.required();refresh=Et();saleData=H(void 0);showFind=H(!0);showSave=H(!1);spaceAnalysisOptions=H(void 0);syncAssortment=Et();undo=Et();undoDisabled=H(!1,{transform:Br});undoVisible=H(!1,{transform:Br});userId=H(void 0);_allowedFunctionality;_alt;_corporateFunctionality;_ctrl;_fullscreen=h(Hn);
58_hasclientSecret=Ze({stream:()=>this._getMcpClientSecret(),defaultValue:!1});_mcpLoggedIn=Ze({stream:()=>this._getMcpLoggedIn(),defaultValue:{claude:!1,chatgpt:!1}});_isCorporateAdmin;_isSpecialProject=X(!1);_media=h(ti);_onBackgroundProcess;_pdfSettings=Ze({params:()=>this.project(),stream:({params:t})=>this._pdfSettingsLoader(t),defaultValue:null});_hasProjectImage=Ze({params:()=>{let t=this.project()?.id;return t&&t!=="00000000-0000-0000-0000-000000000000"?t:void 0},stream:({params:t})=>this._hasProjectImportImage(t),defaultValue:!1});_showRefresh=X(!1);_userAdmin;_backLink="/my-projects";_analysisApi=h(or);_configurationService=h(Yt);_corporateApiService=h(hi);_destroyRef=h(Lt);_dialogsService=h(Y);_document=h(it);_isSample;_keyboardService=h(sr);_projectApiService=h(Pe);_projectExportApiService=h(pr);_projectHelperService=h(Pt);_projectOptions=h(ar);_router=h(ft);_subscriptionApiService=h(Jt);_userApiService=h(rr);_userService=h(xe);_pdfConfigurationApiService=h(dr);constructor(){let t=h(Xt);this._alt=Qn(),this._ctrl=Jn(),this._allowedFunctionality=Je(this._subscriptionApiService.allowedFunctionality.pipe(ue())),this._corporateFunctionality=Je(this._corporateApiService.allowedFunctionality.pipe(ue())),this._onBackgroundProcess=Je(this._configurationService.onBackgroundProcess.pipe(ue())),this._keyboardService.keyPress.pipe(ue()).subscribe({next:r=>this._onKeyPress(r)}),t.snapshot.data.corporate?(this._userAdmin=this._userService.user.isAdmin,this._isCorporateAdmin=Je(this._corporateApiService.userIsAdmin().pipe(ue()))):this._userAdmin=!1;let e=h(wt);this._backLink=e.getLink()??this._backLink,this._isSample=e.sample,e.validateSharedProject(),ce(()=>{let r=this.project();r&&(r.shared?(this._showRefresh.set(!0),this._isSpecialProject.set(!1)):(this._isSpecialProject.set(!!this.chain()),this._projectApiService.shareGet(r.id).pipe(ue(this._destroyRef)).subscribe({next:n=>{this._showRefresh.set(n?.length>0)}})))})}ngOnChanges(t){(t.project||this.project())&&this._pdfSettings.reload()}_onBackClick(t){this._fullscreen.isFullscreen&&this._fullscreen.exit(),this._router.navigateByUrl(t)}_onCopyClick(){let t=this.project();this._canUse(t.shared?"project.copy-shared":"project.copy",!0).pipe(D(()=>this._projectApiService.copyProjectNewName(t.id)),D(e=>this._dialogsService.showModal(ae.projectCopy(),{data:{name:e}})),Z(e=>!!e),D(e=>this._projectApiService.copyProject(t.id,e.name,e.type,e.copyPdvs,e.reverseProject,!0))).subscribe({next:e=>{this._router.navigateByUrl(`${this._backLink}/${e}`)},error:e=>this._dialogsService.showErrorSnackbar(e)})}_onExportClick(){let t=this.project();this._projectHelperService.projectExport(this._projectExportApiService,t,this.userId())}_onGetSetting(){return this._pdfSettings.value()?.name}_onExportPdfCustomProjectClick(){let t=this.project();this._subscriptionApiService.canUse("project.export.custom.pdf").pipe(Z(e=>e),D(()=>this._projectExportApiService.exportPdfCustom(t,{id:t.id,idPdfConfiguration:t.idPdfConfig,frecuency:0}))).subscribe({error:e=>this._dialogsService.showErrorSnackbar(e)})}_onExportPdfCustomClick(){let t=this.project();this._subscriptionApiService.canUse("project.export.custom.pdf").pipe(Z(e=>e),D(()=>this._dialogsService.showModal(ae.projectExportCustomPDF(),{data:{project:t,isCorporate:this.isCorporate()}}))).subscribe({error:e=>this._dialogsService.showErrorSnackbar(e)})}_onExportPdfDetailedClick(){let t=this.project();this._subscriptionApiService.canUse("project.export-pdf",t.id).pipe(Z(e=>e),D(()=>Ki({projects:[t],printMode:this.printMode(),projectOptions:this._projectOptions,projectExportApiService:this._projectExportApiService,spaceAnalysisOptions:this.spaceAnalysisOptions(),analysisApi:this._analysisApi}))).subscribe({error:e=>this._dialogsService.showErrorSnackbar(e)})}_onExportPdfSimpleClick(){let t=this.project();this._canUse("project.print").pipe(D(()=>this._projectExportApiService.exportPdfSimple(t,!0,this._projectOptions.prices())),D(()=>mi(t.id,this._dialogsService,this._userApiService))).subscribe()}_onFindClick(){let t=this.graph();
58if(t&&!this.editProductData()){t.findProducts();return}this._subscriptionApiService.canUse("project.find-product").pipe(Z(e=>e),D(()=>this._dialogsService.showModal(ae.productSearch()))).subscribe({next:e=>this.saleData()?.searchToProduct(e)})}_onRefreshClick(){this.refresh.emit()}_onViewImageClick(){let e=this.project().id;if(!e||e==="00000000-0000-0000-0000-000000000000")return;let r=this._router.createUrlTree(["/project-image-preview",e]),n=this._router.serializeUrl(r);window.open(n,"_blank","noopener,noreferrer,width=1200,height=800")}_onShareClick(){this._isSample?this._dialogsService.showPrompt({message:"Link",initialValue:this._document.URL.replace("admin/samples","demo"),width:"70vw",readonly:!1}).subscribe():this._canUse("project.share",!0).pipe(Z(t=>t)).subscribe({next:()=>this._projectHelperService.projectShare([this.project().id],[2])})}_onShareCorporateClick(){this._subscriptionApiService.canUse("project.share").pipe(Z(t=>t)).subscribe({next:()=>this._projectHelperService.projectShareCorporate([this.project()],this._userService.user.corporateId)})}_onSyncComplete(){this._dialogsService.showModal(ae.projectAssortmentSyncComplete()).subscribe({next:()=>{this._router.navigateByUrl("/my-projects")}})}_onSyncSectionsClick(){let t=this.project(),e=t.id;this._subscriptionApiService.canUse("project.assortment").pipe(Z(r=>r),D(()=>this._dialogsService.showModal(ae.projectAssortmentSyncSections(),{data:{showPdvs:!t.idParentProject,project:t}})),Z(r=>r!==void 0),D(r=>{let n=t.idParentProject?[t.id]:r.pdvs,i=t.idParentProject?t.idParentProject:e;return this._projectApiService.syncProjectWithLocations({projectId:i,sections:r.mountings,pdvs:n})})).subscribe({next:()=>this.syncAssortment.emit(),error:r=>this._dialogsService.showErrorSnackbar(r)})}_onUndoClick(){this.undo.emit()}_canUse(t,e){let r=e?this.project().id:null;return this._subscriptionApiService.canUse(t,r).pipe(Z(n=>n))}_getMcpClientSecret(){return this._allowedFunctionality()?.["user.mcp.client-id"]?this._userApiService.mcpCredentials().pipe(O(t=>!!t?.clientSecret)):E(!1)}_getMcpLoggedIn(){return this._allowedFunctionality()?.["user.mcp.client-id"]?Rt([this._userApiService.configuracion("logged-from-claude"),this._userApiService.configuracion("logged-from-chatgpt")]).pipe(O(([t,e])=>({claude:t==="true",chatgpt:e==="true"}))):E({claude:!1,chatgpt:!1})}_onKeyPress(t){if(!this._dialogsService.dialogOpened)switch(t.key){case"p":case"P":Zn(t)?(this._onExportPdfDetailedClick(),t.preventDefault()):Xr(t)&&(this._onExportPdfSimpleClick(),t.preventDefault());break;case"s":case"S":Xr(t)&&(this._onExportClick(),t.preventDefault());break;case"z":case"Z":ei(t)&&(this._onUndoClick(),t.preventDefault());break}}_pdfSettingsLoader(t){return t?.idPdfConfig?this._pdfConfigurationApiService.getPdfConfigToExport(t.idPdfConfig):E(null)}_hasProjectImportImage(t){return this._projectApiService.hasImportedImage(t)}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=ge({type:s,selectors:[["catman-project-toolbar"]],inputs:{chain:[1,"chain"],editProductData:[1,"editProductData"],graph:[1,"graph"],isCorporate:[1,"isCorporate"],isRack:[1,"isRack"],printMode:[1,"printMode"],project:[1,"project"],saleData:[1,"saleData"],showFind:[1,"showFind"],showSave:[1,"showSave"],spaceAnalysisOptions:[1,"spaceAnalysisOptions"],undoDisabled:[1,"undoDisabled"],undoVisible:[1,"undoVisible"],userId:[1,"userId"]},outputs:{changed:"changed",refresh:"refresh",syncAssortment:"syncAssortment",undo:"undo"},features:[_n],decls:42,vars:51,consts:[["mobileToolbar",""],["exportPdf",""],["projectShare",""],["mat-icon-button","",3,"matMenuTriggerFor"],["mat-menu-item","",3,"click"],["mat-menu-item","",3,"disabled"],["mat-menu-item",""],["mat-menu-item","",3,"click","ngClass"],[3,"project","loggedIn"],["mat-icon-button","",3,"click","matTooltip"],["mat-icon-button","",3,"matTooltip"],[3,"vertical"],[3,"project","userId","isCorporate"],["mat-icon-button","",3,"matTooltip","disabled"],["mat-icon-button","",3,"matTooltip","ngClass"],["mat-icon-button","",3,"matTooltip","disabled","ngClass"],["mat-icon-button","",3,"click","matTooltip","disabled"],[1,"undo-icon"],["mat-icon-button","",3,"click","matTooltip","ngClass"],["mat-icon-button","",3,"click","matTooltip","disabled","ngClass"],["mat-icon-button","",3,"matTooltip","disabled","matMenuTriggerFor","ngClass"],["mat-icon-button","",3,"disabled","matMenuTriggerFor","ngClass"],["mat-menu-item","",3,"click","disabled"],["mat-menu-item","",3,"ngClass"]],template:function(e,r){if(e&1&&(Sn(0)(1)(2)(3)(4)(5)(6)(7),R(8,jo,3,1,"button",3),M(9,"async"),vn(10,Vo,17,15),g(11,"mat-menu",null,0)(13,"button",4),I("click",function(){return r._onBackClick(r._backLink)}),g(14,"mat-icon"),v(15,"keyboard_arrow_left"),b(),v(16),M(17,"translate"),b(),R(18,Ho,5,4,"button",5),R(19,Ko,5,3,"button",6),R(20,Go,5,3,"button",6),R(21,Yo,23,27),b(),g(22,"mat-menu",null,1),R(24,Qo,3,4),g(25,"button",7),I("click",function(){return r._onExportPdfSimpleClick()}),v(26),M(27,"translate"),b(),g(28,"button",7),I("click",function(){return r._onExportPdfDetailedClick()}),v(29),M(30,"translate"),b(),g(31,"button",7),I("click",function(){return r._onExportPdfCustomClick()}),v(32),M(33,"translate"),b()(),g(34,"mat-menu",null,2)(36,"button",7),I("click",function(){return r._onShareClick()}),v(37),M(38,"translate"),b(),g(39,"button",7),I("click",function(){return r._onShareCorporateClick()}),v(40),M(41,"translate"),b()()),e&2){let n=Me(r._allowedFunctionality()??Dr(39,Vi));_(),Me(r._corporateFunctionality()??Dr(40,Vi)),_(),Me((r._isCorporateAdmin==null?null:r._isCorporateAdmin())??!1),_(),Me(r.isCorporate()),_(),Me(r._onBackgroun
58dProcess()),_();let i=Me(r.project());_(),Me(r.undoDisabled()),_(),Me(r._showRefresh()),_(),N(T(9,25,r._media.isMobileAsync)?8:10),_(8),B(" ",T(17,27,"button.back")," "),_(2),N(r.undoVisible&&i?18:-1),_(),N(r._fullscreen.isFullscreen?-1:19),_(),N(r._fullscreen.isFullscreen?20:-1),_(),N(i?21:-1),_(3),N((i==null?null:i.idPdfConfig)>0?24:-1),_(),k("ngClass",V(41,re,!n["project.print"])),_(),B(" ",T(27,29,"folder.export-pdf-simple")," "),_(2),k("ngClass",V(43,re,!n["project.export-pdf"])),_(),B(" ",T(30,31,"folder.export-pdf-full")," "),_(2),k("ngClass",V(45,re,!n["project.export.custom.pdf"])),_(),B(" ",T(33,33,"folder.export-pdf-custom")," "),_(4),k("ngClass",V(47,re,!n["project.share"])),_(),B(" ",T(38,35,"button.share")," "),_(2),k("ngClass",V(49,re,!n["project.share"])),_(),B(" ",T(41,37,"button.corporate.share")," ")}},dependencies:[_r,fr,vr,pt,Wt,_t,Re,mt,ni,ri,ze,Ne,gt,ht,Ge,He,Zt,Ke,Bn,Ve,In,Be],styles:[`[_nghost-%COMP%]{display:flex;gap:calc(var(--spacing, .25rem) * 1)} 59`],changeDetection:0})};function Ki({projects:s,printMode:t=0,projectOptions:e,spaceAnalysisOptions:r,projectExportApiService:n,analysisApi:i}){switch(t){case 1:return n.exportPdfSimple(s[0],!1,!1,!0);case 2:return i.spaceByCriteriaPdf(s[0],r,e.prices());default:return n.exportPdfDetailed(s[0])}}var Ph=s=>{let t=[...new Set(yr(s).map(e=>e.brand).filter(e=>e&&e.trim().length>0))];return t.sort(),t},Sh=s=>{let t=[...new Set(yr(s).map(e=>e.brandKind).filter(e=>e&&e.trim().length>0))];return t.sort(),t},wh=s=>{let t=[...new Set(yr(s).map(e=>e.manufacturer).filter(e=>e&&e.trim().length>0))];return t.sort(),t},kh=s=>{let t=[...new Set(yr(s,!1).map(e=>s.salesMap.get(e.code)?.newPrice).filter(e=>e!==void 0))];return t.sort((e,r)=>e-r),t},yr=(s,t=!0)=>{let e=t?[...s.products]:[];for(let r of pn(s))e.some(n=>n.id===r.id)||e.push(r);return e},jh=s=>s.rack.sections.flatMap(t=>t.holders),pn=s=>s.rack.sections.flatMap(t=>t.holders.flatMap(e=>e.products??[])),Jo=s=>s.rack.sections.flatMap(t=>t.holders.flatMap(e=>(e.products??[]).map(r=>{let n=Te(r,r.orientation,r.isCase,r.projectCompression),i=r.fronts.d?r.fronts.d:Math.trunc(e.size.d/n.d),o=r.fronts.w*r.fronts.h*(i<1?1:i);return{id:r.id,code:r.code,front:o}}))),Mh=s=>pn(s).map(t=>t.code),Th=(s,t=!0)=>{let e=t?[...s.products.map(r=>({id:r.id,code:r.code,images:r.images,name:r.name,stock:r.stock,front:r.fronts.w*r.fronts.h*(r.fronts.d??1),inBasket:!0}))]:[];for(let r of pn(s)){let n=e.find(i=>i.id===r.id);n===void 0?e.push({id:r.id,code:r.code,images:r.images,name:r.name,stock:r.stock,front:r.fronts.w*r.fronts.h*(r.fronts.d??1),inBasket:!1}):(r.stock&&(n.stock+=r.stock),n.front+=r.fronts.w*r.fronts.h*(r.fronts.d??1),n.inBasket=!1)}return[...new Set(e)]},Ih=(s,t,e=!0,r,n)=>{let i=[];if(r!==void 0&&n!==void 0){let a=s.rack.sections[r].holders[n],c=a.products.find(d=>d.code===t);if(c){let d=Te(c,c.orientation,c.isCase,c.projectCompression),u=c.fronts.d??Math.trunc(a.size.d/d.d),l=c.fronts.w*c.fronts.h*(u<1?1:u);return l<1?1:l}return 1}let o=s.products.filter(a=>a.code===t);e&&o.length>0&&i.push(...o.map(a=>({code:a.code,id:a.id,front:a.fronts.w*a.fronts.h*(a.fronts.d?a.fronts.d:1)})));for(let a of Jo(s).filter(c=>
59c.code===t)){let c=i.find(d=>d.id===a.id);c===void 0?i.push({code:a.code,id:a.id,front:a.front}):c.front+=a.front}return i.reduce((a,c)=>a+c.front,0)},un=(s,t)=>{for(let e of s.rack.sections.flatMap(r=>r.holders.filter(n=>n.type===-1&&n.relatedProduct===t)).flatMap(r=>r.products))e.location.x=t.location.x+e.dx,un(s,e)},Ii=(s,t)=>{if(!t||t.cms===1)return;let e=o=>qr(Wr(o,t),t),r=o=>qr(Wr(o,t,2,!1,!0),t),n=o=>{o&&(o.w=e(o.w),o.h=e(o.h),o.d!==void 0&&(o.d=e(o.d)))},i=o=>{o.location&&(o.location.x=e(o.location.x),o.location.y=e(o.location.y)),n(o.size),n(o.absoluteSize),n(o.caseSize)};n(s.rack.size);for(let o of Object.values(s.rack.borders??{}))o.width=e(o.width);for(let o of s.rack.sections){o.x=e(o.x),o.w=e(o.w),o.sectionWidth!==void 0&&(o.sectionWidth=e(o.sectionWidth));for(let a of o.holders){a.location.x=e(a.location.x),a.location.y=r(a.location.y),n(a.size),a.pegSpacing&&(a.pegSpacing.x=e(a.pegSpacing.x),a.pegSpacing.y=e(a.pegSpacing.y)),a.pegSpacingStart&&(a.pegSpacingStart.x=e(a.pegSpacingStart.x),a.pegSpacingStart.y=e(a.pegSpacingStart.y));for(let c of a.products??[])i(c)}}for(let o of s.products??[])i(o);for(let o of s.visualElements??[])o.x=e(o.x),o.y=e(o.y),o.width=e(o.width),o.height=e(o.height)};var Cr=class extends be{alignProducts(t,e,r,n=!0){let i=t.rack.sections[e],o=i.holders.findIndex(m=>m.name===r&&m.type===1),a=i.holders[o],c=ie(t.rack.sections,e),d=te(t,i.holders,o,c),u=oe(t,a),l=c+a.location.x+a.size.w;if(u.length>1&&u[0].sectionIndex===e){let m=u[u.length-1];l=m.absoluteX+m.mounting.size.w}this._alignProducts(t,i,a.products,c+a.location.x,a.location.y+a.size.h,l,d),Q(t,e,a),n&&me(t.products)}canDrop(t,e){return!0}createTargets(t,e,r,n,i,o){let a=e.holders,c=a[n],d=[],u=te(t,a,n,i),l=parseFloat((c.type===-1?u-c.location.y:u-c.location.y-c.size.h).toFixed(2)),m=super.createTargets(t,e,r,n,i,o);if(c.products.length===0||m.length===0)return m;if(l<=0)return[];if(c.type===-1)d.push({x:c.location.x,y:c.location.y,width:parseFloat(c.size.w.toFixed(2)),height:l,mode:0,section:e,sectionIndex:r,mounting:c,mountingIndex:n,alignment:c.alignment,relatedProduct:c.relatedProduct});else return m;return d}onDrop(t,e){if(!e.product)return pe.logError(new Error("shelf-alignment-free:onDrop data.product is empty"),JSON.stringify(e)),!1;let r=e.target,n=r.mounting,i=n.size,o=e.product,a=!e.fromBasket&&t.rack.sections[e.sectionIndex].holders[e.mountingIndex]===n,c=a?o.fronts.w:this._getMaxFrontsW(t,r.mode,n,o,a),d=ie(t.rack.sections,r.sectionIndex),u=a?o.fronts.h:r.mode===0?Math.trunc(r.height/o.size.h):Math.trunc(te(t,r.section.holders,r.mountingIndex,d)/o.size.h),l=a?o:le(o);return this._updateFacings(l,c,u),l.location={x:r.dropPosition.x,y:r.dropPosition.y},l.dx=r.dropPosition.x-n.location.x-d,l.dy=r.dropPosition.y-n.location.y,un(t,l),this._updateStock(l,i),l.new=!0,a||n.products.push(l),!e.copy&&!a&&this._deleteProduct(t,e,a),n.products.sort((m,C)=>{let f=m.location.y-C.location.y;return f===0?m.location.x-C.location.x:f}),Q(t,r.sectionIndex,n),!0}_adjustProductFacings(t,e,r){t.location.x+t.size.w*t.fronts.w>e&&(t.fronts.w=Math.trunc((e-t.location.x)/t.size.w)),t.location.y+t.size.h*t.fronts.h>r&&(t.fronts.h=Math.trunc((r-t.location.y)/t.size.h))}_alignProducts(t,e,r,n,i,o,a){if(!r||r.length===0)return;r.sort(We);let c=n,d=this._calculateOffsetX(r,n,o);this._repositionProducts(t,e,r,c,i,o,a,d),this._removeOutOfBoundsProducts(t,r,o,a)}_calculateOffsetX(t,e,r){let n=t.reduce((o,a)=>o+a.size.w*a.fronts.w,0),i=(r-e-n)/(t.length>1?t.length-1:1);return i<0?0:i}_handleProductOverlap(t,e,r,n){if(r.compression.w>0&&r.compression.w>r.projectCompression.w){let i=n-t[e+1].location.x,o=Te(r,r.orientation,r.isCase,{w:0,h:0}),a=parseFloat((i*100/o.w).toFixed(2));a<r.compression.w&&(this._setCompression(r,a),r.size=Te(r,r.orientation,r.isCase,r.projectCompression));let c=parseFloat((r.location.x+r.size.w*r.fronts.w).toFixed(2));return e<t.length-1&&c>t[e+1].location.x&&(t[e+1].location.x=c),c}return t[e+1].location.x=n,n}_processVirtualShelf(t,e,r,n,i,o){let a=e.holders.findIndex(d=>d.relatedProduct===r&&d.type===-1),c=e.holders[a];c&&c.products.length>0&&this._alignProducts(t,e,c.products,n,r.location.y+r.size.h*r.fronts.h,r.location.x+r.size.w*r.fronts.w,o)}_removeOutOfBoundsProducts(t,e,r,n){for(let i=e.length-1;i>=0;i--){let o=e[i];(o.location.y>n||o.fronts.h<=0||o.location.x>r||o.fronts.w<=0)&&t.products.push(...e.splice(i,1))}}_repositionProducts(t,e,r,n,i,o,a,c){let d=n;for(let u=0;u<r.length;u++){let l=r[u];l.facingSpace={w:0,h:0}
59,l.location.x=n+l.dx,l.new||(l.location.y=i),l.new=void 0;let m=parseFloat((l.location.x+l.size.w*l.fronts.w).toFixed(2));u<r.length-1&&m>r[u+1].location.x&&(m=this._handleProductOverlap(r,u,l,m)),this._adjustProductFacings(l,o,a),this._processVirtualShelf(t,e,l,d,o,a),d+=l.size.w*l.fronts.w+c}}_setCompression(t,e){switch(t.orientation){case 0:case 12:case 6:case 18:case 4:case 16:case 10:case 22:t.projectCompression.w=e;break;case 1:case 13:case 7:case 19:case 3:case 15:case 9:case 21:t.projectCompression.h=e;break;case 5:case 17:case 11:case 23:case 2:case 14:case 8:case 20:t.projectCompression.d=e;break}}};var xr=class extends be{alignProducts(t,e,r,n=!0){let i=t.rack.sections[e],o=i.holders.findIndex(m=>m.name===r&&m.type===1);if(o===-1)return;let a=i.holders[o],c=ie(t.rack.sections,e),d=te(t,i.holders,o,c),u=oe(t,a),l=u.length>1&&u[0].sectionIndex===e?u[u.length-1].absoluteX+u[u.length-1].mounting.size.w:c+a.location.x+a.size.w;this._alignProducts({project:t,section:i,shelf:a,sectionLeft:c,products:a.products,x:c+a.location.x,y:a.location.y+a.size.h,maxX:l,maxY:d}),Q(t,e,a),n&&me(t.products)}canDrop(t,e){let r=this._getProductsSize(t,e);if(r.sameShelf)return!0;if(r.sameProduct)return!1;if(e.mode===0){if(r.size.w>yt(t,e.mounting)||r.size.h>e.height)return!1}else{let n=tr(e.section.holders,e.mountingIndex,ie(t.rack.sections,e.sectionIndex)),i=n?n.location.y:t.rack.size.h;if(r.size.w>e.mounting.size.w||r.size.h>i)return!1}return!0}createTargets(t,e,r,n,i,o){let a=e.holders[n];if(a.products.length===0)return super.createTargets(t,e,r,n,i,o);let c=this._maxYCombined(t,r,n),d=[],u=a.products,l=oe(t,a),m=l.length>1?l.reduce((y,j)=>y+j.mounting.size.w,0):a.size.w,C=u.reduce((y,j)=>y+j.fronts.w,0),f=m-u.reduce((y,j)=>y+j.size.w*j.fronts.w,0);f<0?f=0:C>1&&(f=f/(C-1));for(let y=0;y<u.length;y++){let j=u[y],p=se(j);y===0||f===0?(d.push({x:j.location.x,y:j.location.y,width:.6,height:j.size.h*j.fronts.h,mode:1,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:j}),d.push({x:j.location.x+p,y:j.location.y,width:f,height:c-j.location.y,mode:0,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:a.relatedProduct})):y===u.length-1?d.push({x:j.location.x+p-2,y:j.location.y,width:.6,height:j.size.h*j.fronts.h,mode:1,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:j}):d.push({x:j.location.x+p,y:j.location.y,width:f,height:c-j.location.y,mode:0,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:a.relatedProduct})}return d}onDrop(t,e){if(e.sameShelf)return this._onSameShelfDrop(t,e);if(!e.product)return pe.logError(new Error("shelf-alignment-justified:onDrop data.product is empty"),JSON.stringify(e)),!1;let r=e.target,n=r.mounting,i=n.size,o=e.product,a=!e.fromBasket&&t.rack.sections[e.sectionIndex].holders[e.mountingIndex]===n,c=a?o.fronts.w:this._getMaxFrontsW(t,r.mode,n,o,a),d;if(a)d=o.fronts.h;else if(r.mode===0)d=Math.trunc(r.height/o.size.h);else{let m=te(t,r.section.holders,r.mountingIndex,ie(t.rack.sections,r.sectionIndex));d=Math.trunc(m/o.size.h)}let u=a?o:le(o);this._updateFacings(u,c,d);let l=r.x;if(e.prevProduct){let m=n.products.find(C=>C.id===e.prevProduct.id);l=m?m.location.x+m.size.w*m.fronts.w:r.x}return u.location={x:l,y:r.y},this._updateStock(u,i),u.new=!0,n.products.push(u),e.copy||this._deleteProduct(t,e,a),this.alignProducts(t,r.sectionIndex,r.mounting.name),n.products.sort((m,C)=>{let f=m.location.y-C.location.y;return f===0?m.location.x-C.location.x:f}),Q(t,r.sectionIndex,n),!0}_alignProducts({project:t,section:e,shelf:r,sectionLeft:n,products:i,x:o,y:a,maxX:c,maxY:d}){if(!i||i.length===0)return;i.sort(We);let u=i.reduce((f,y)=>f+y.size.w*y.fronts.w,0),l=i.reduce((f,y)=>f+y.fronts.w,0),m=c-o-u;m<0?m=0:l>1&&(m=m/(l-1));let C=o;for(let f of i){f.location.x=C,f.new||(f.location.y=a),f.new=void 0,f.facingSpace={w:m,h:f.facingSpace?.h??0};let y=f.location.x+se(f);parseFloat(y.toFixed(2))>parseFloat(c.toFixed(2))&&(f.fronts.w=Math.max(1,Math.trunc((c-f.location.x)/f.size.w)),f.facingSpace={w:m,h:f.facingSpace?.h??0}),f.location.y+f.size.h*f.fronts.h>d&&(f.fronts.h=Math.max(1,Math.trunc((d-f.location.y)/f.size.h))),f.dx=f.location.x-(n+r.location.x);let j=e.holders.findIndex(p=>p.relatedProduct===f&&p.type===-1);if(j!==-1){let p=e.holders[j];p&&p.products.length>0&&this._alignProducts({project:t,section:e,shelf:p,sectionLeft:n,products:p.products,x:C,y:f.location.y+f.size.h*f.fronts.h,maxX:C+se(f),maxY:d})}C+=se(f)+m}this._removeInvalidProducts(t,i,c,d)}_onSameShelfDrop(t,e){let r=[...this._selectedProductsService.selectedProducts].sort((o,a)=>o.product.location.x-a.product.location.x),n=r.reduce((o,a)=>o+se(a.product),0);for(let o of e.sourceMounting.products.filter(a=>a.location.x>=e.target.x))o.location.x+=n;let i=e.target.x;for(let o of r)o.product.location.x=i,i+=se(o.product);return this.alignProducts(t,e.target.sectionIndex,e.target.mounting.name,!0),!0}_removeInvalidProducts(t,e,r,n){let i=[];for(let o=e.length-1;o>=0;o--){let a=e[o];(a.location.y>n||a.fronts.h<=0||a.location.x>r||a.fronts.w<=0)&&(i.push(a),e.splice(o,1))}i.length>0&&t.products.push(...i)}};var Pr=class extends be{alignProducts(t,e,r,n=!0){let i=t.rack.sections[e],o=i.holders.find(u=>u.name===r&&u.type===1);if(!o){pe.logError(new Error(`Shelf ${r} not found in section ${e}`));return}let a=ie(t.rack.sections,e),c=te(t,i.holders,i.holders.indexOf(o),a),d=this._calculateMaxX(t,e,o,a);this._alignProducts({project:t,section:i,shelf:o,products:o.products,sectionLeft:a,x:a+o.location.x,y:o.location.y+o.size.h,maxX:d,maxY:c}),Q(t,e,o),n&&me(t.products)}createTargets(t,e,r,n,i,o){let a=e.holders[n],c=super.createTargets(t,e,r,n,i,o);if(a.products.length===0||c.length===0)return c;
59let d=[],u=Math.max(...a.products.map(l=>l.location.x+l.size.w*l.fronts.w));c[0].width=a.type===-1?c[0].width+c[0].x-u:c[0].width-u+e.sectionX+a.location.x,c[0].x=u,d.push(...c);for(let l of a.products)d.push({x:l.location.x,y:l.location.y,width:.6,height:l.size.h*l.fronts.h,mode:1,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:l});return d}onDrop(t,e){if(e.sameShelf)return this._onSameShelfDrop(t,e);if(!e.product)return pe.logError(new Error("shelf-alignment-left:onDrop data.product is empty"),JSON.stringify(e)),!1;let r=e.target,n=e.product,i=r.mounting,o=i.size,a=n.size,c=!e.fromBasket&&t.rack.sections[e.sectionIndex].holders[e.mountingIndex]===i,d=c?n:le(n),u=r.mode===0,l,m;if(c)l=n.fronts.w,m=n.fronts.h;else{let C,f;u?(C=r.width,f=r.height):(C=this._maxWCombined(t,e.target.sectionIndex,e.target.mountingIndex),f=te(t,r.section.holders,r.mountingIndex,ie(t.rack.sections,r.sectionIndex))),l=Math.trunc(C/a.w),m=Math.trunc(f/a.h)}return this._updateFacings(d,l,m),d.location={x:r.x,y:r.y},this._updateStock(d,o),d.new=!0,i.products.push(d),e.copy||this._deleteProduct(t,e,c),this.alignProducts(t,r.sectionIndex,i.name),i.products.sort((C,f)=>{let y=C.location.y-f.location.y;return y===0?C.location.x-f.location.x:y}),Q(t,r.sectionIndex,i),!0}_alignProducts({project:t,section:e,shelf:r,products:n,sectionLeft:i,x:o,y:a,maxX:c,maxY:d}){if(!(!n||n.length===0)){n.sort(We);for(let u of n){let{location:l,size:m,fronts:C}=u;l.x=o,u.facingSpace={w:0,h:0},u.new||(l.y=a),u.new=void 0;let f=m.w*C.w,y=m.h*C.h;l.x+f>c&&(C.w=Math.max(1,Math.trunc((c-l.x)/m.w)));let j=this._getMountingAbove(e,o,i,u),p=j&&d>j.location.y?j.location.y:d;l.y+y>p&&(C.h=Math.max(1,Math.trunc((p-l.y)/m.h))),u.dx=u.location.x-(i+r.location.x),this._processVirtualShelf(t,e,u,i,o,l,m,C,d),o+=m.w*C.w}this._removeInvalidProducts(t,n,c,d)}}_calculateMaxX(t,e,r,n){let i=oe(t,r);if(i.length>1&&i[0].sectionIndex===e){let o=i[i.length-1];return o.absoluteX+o.mounting.size.w}return n+r.location.x+r.size.w}_getMountingAbove(t,e,r,n){return t.holders.filter(i=>i.type!==-1&&e>=i.location.x+r&&e<i.location.x+i.size.w+r&&i.location.y>n.location.y).sort((i,o)=>i.location.y-o.location.y)[0]}_onSameShelfDrop(t,e){let r=[...this._selectedProductsService.selectedProducts].sort((o,a)=>o.product.location.x-a.product.location.x),n=r.reduce((o,a)=>o+se(a.product),0);for(let o of e.sourceMounting.products.filter(a=>a.location.x>=e.target.x))o.location.x+=n;let i=e.target.x;for(let o of r)o.product.location.x=i,i+=se(o.product);return this.alignProducts(t,e.target.sectionIndex,e.target.mounting.name,!0),!0}_processVirtualShelf(t,e,r,n,i,o,a,c,d){let u=e.holders.findIndex(m=>m.relatedProduct===r&&m.type===-1);if(u===-1)return;let l=e.holders[u];l&&l.products.length>0&&this._alignProducts({project:t,section:e,shelf:l,products:l.products,sectionLeft:n,x:i,y:o.y+a.h*c.h,maxX:i+a.w*c.w,maxY:d})}_removeInvalidProducts(t,e,r,n){for(let i=e.length-1;i>=0;i--){let{location:o,fronts:a}=e[i];(o.y>n||o.x>r||a.w<=0||a.h<=0)&&t.products.push(...e.splice(i,1))}}};var Sr=class extends be{alignProducts(t,e,r,n=!0){let i=t.rack.sections[e],o=i.holders.findIndex(m=>m.name===r&&m.type===1);if(o===-1){pe.logError(new Error(`Shelf ${r} not found in section ${e}`));return}let a=i.holders[o],c=ie(t.rack.sections,e),d=te(t,i.holders,o,c),u=oe(t,a),l=u.length>1&&u[0].sectionIndex===e?u[u.length-1].absoluteX+u[u.length-1].mounting.size.w:c+a.location.x+a.size.w;this._alignProducts({project:t,section:i,shelf:a,sectionLeft:c,products:a.products,x:l,y:a.location.y+a.size.h,minX:c+a.location.x,maxY:d}),Q(t,e,a),n&&me(t.products)}createTargets(t,e,r,n,i,o){let a=e.holders[n],c=super.createTargets(t,e,r,n,i,o);if(a.products.length===0||c.length===0)return c;let d=[],u=Math.min(...a.products.map(l=>l.location.x));c[0].width=u-c[0].x,d.push(...c);for(let l of a.products)d.push({x:l.location.x+l.size.w*l.fronts.w-2,y:l.location.y,width:.6,height:l.size.h*l.fronts.h,mode:1,section:e,sectionIndex:r,mounting:a,mountingIndex:n,alignment:a.alignment,relatedProduct:l});return d}onDrop(t,e){if(e.sameShelf)return this._onSameShelfDrop(t,e);if(!e.product)return pe.logError(new Error("shelf-alignment-right:onDrop data.product is empty"),JSON.stringify(e)),!1;let r=e.target,n=e.product,i=r.mounting,o=r.mounting.size,a=n.size,c=!e.fromBasket&&t.rack.sections[e.sectionIndex].holders[e.mountingIndex]===i,d=c?n:le(n),u=r.mode===0,l,m;if(c)l=n.fronts.w,m=n.fronts.h;else{let f,y;u?(f=r.width,y=r.height):(f=this._maxWCombined(t,e.target.sectionIndex,e.target.mountingIndex),y=te(t,r.section.holders,r.mountingIndex,ie(t.rack.sections,r.sectionIndex))),l=Math.trunc(f/a.w),m=Math.trunc(y/a.h)}this._updateFacings(d,l,m);let C=d.size.w*d.fronts.w;if(d.location={x:r.x-C,y:r.y},r.mode===1)for(let f of i.products.filter(y=>y.location.x<r.x&&y!==d))f.location.x-=C;return this._updateStock(d,o),d.new=!0,i.products.push(d),e.copy||this._deleteProduct(t,e,c),this.alignProducts(t,r.sectionIndex,r.mounting.name),i.products.sort((f,y)=>{let j=f.location.y-y.location.y;return j===0?f.location.x-y.location.x:j}),Q(t,r.sectionIndex,i),!0}_alignProducts({project:t,section:e,shelf:r,sectionLeft:n,products:i,x:o,y:a,minX:c,maxY:d}){if(!i?.length)return;i.sort((l,m)=>{let C=m.location.x-l.location.x;return C===0?l.new?-1:1:C});let u=n+r.location.x;for(let l of i){let m=l.size.w*l.fronts.w;l.location.x=o-m,l.facingSpace={w:0,h:0}
59,l.new||(l.location.y=a),l.new=void 0,l.location.x<c&&l.location.x+m>c&&(l.fronts.w=Math.trunc((l.location.x+m-c)/l.size.w));let C=l.size.h*l.fronts.h;l.location.y+C>d&&(l.fronts.h=Math.trunc((d-l.location.y)/l.size.h)),l.dx=l.location.x-u;let f=e.holders.findIndex(y=>y.relatedProduct===l&&y.type===-1);if(f!==-1){let y=e.holders[f];y.products.length>0&&this._alignProducts({project:t,section:e,shelf:y,sectionLeft:n,products:y.products,x:o,y:l.location.y+C,minX:o-m,maxY:d})}o-=m}this._removeInvalidProducts(t,i,c,d)}_onSameShelfDrop(t,e){let r=[...this._selectedProductsService.selectedProducts].sort((o,a)=>a.product.location.x-o.product.location.x),n=r.reduce((o,a)=>o+se(a.product),0);for(let o of e.sourceMounting.products.filter(a=>a.location.x<=e.target.x))o.location.x-=n;let i=e.target.x;for(let o of r){let a=se(o.product);o.product.location.x=i-a,i-=a}return this.alignProducts(t,e.target.sectionIndex,e.target.mounting.name,!0),!0}_removeInvalidProducts(t,e,r,n){for(let i=e.length-1;i>=0;i--){let o=e[i];(o.location.y>n||o.location.x<r||o.fronts.w<=0||o.fronts.h<=0)&&t.products.push(...e.splice(i,1))}}};var Pt=class s{_alignment;_dialogsService=h(Y);_subscriptionApiService=h(Jt);constructor(){let t=h(gi),e=this._dialogsService;this._alignment=[new Pr(e,this,t),new ir(e,this,t),new Sr(e,this,t),new xr(e,this,t),new Cr(e,this,t)]}generateExtraMap(t,e){if(e&&e.length>0){t.extraMap=new Map;for(let r of e)t.extraMap.set(r.upc,r)}else t.extraMap=new Map}generateSalesMap(t,e){if(e&&e.length>0){t.salesMap=new Map;for(let r of e)t.salesMap.set(r.upc,r)}else t.salesMap=new Map}mountingGetShelfAlignment(t){return this._alignment[t]}productUpdateVersion(t,e,r){if(r=r??e,t?.products){let o=t.products.findIndex(a=>a.code.trim()===e.code.trim());o!==-1&&t.products.splice(o,1,le(r))}let n=t?.salesMap.get(e.code.trim());n&&(n.upc=r.code.trim());let i=t?.extraMap.get(e.code.trim());i&&(i.upc=r.code.trim()),t?.rack?.sections.forEach((o,a)=>{this._productUpdateVersionShelfs(t,o,a,e,r),this._productUpdateVersionPanel(t,o,e,r)}),me(t?.products)}projectExport(t,e,r){let n,i=e instanceof Array?null:e.id;this._subscriptionApiService.canUse("project.export",i).pipe(Z(o=>o),D(()=>this._dialogsService.showModal(ae.projectExport(),{data:{userId:r,projectId:i}})),Z(o=>!!o),D(o=>(n=this._dialogsService.showSnackbar({message:"project.export.processing",config:{verticalPosition:"top"}}),e instanceof Array?t.batchExportFile(o.format,e,o.mappings):t.exportFile(o.format,e,o.mappings)))).subscribe({error:o=>{this._dialogsService.showErrorSnackbar(o),n&&n.dismiss()},complete:()=>{n&&n.dismiss()}})}projectInitialize(t){li(t);for(let e=0;e<t.rack.sections.length;e++){let r=t.rack.sections[e];for(let n of r.holders)switch(n.type){case 1:Q(t,e,n),this.mountingGetShelfAlignment(n.alignment).alignProducts(t,e,n.name,!1);break;case 3:for(let i of n.products)i.facingSpace=Qr(i.size,n.pegSpacing);break}}return me(t.products),"sales"in t&&this.generateSalesMap(t,t.sales),"extra"in t&&this.generateExtraMap(t,t.extra),t}projectShare(t,e){let r={projectId:t.length===1?t[0]:t,projectType:e.length===1?e[0]:e};return this._dialogsService.showModal(ae.projectShare(),{data:r})}projectShareCorporate(t,e){let r={projects:t,corporateId:e};return this._dialogsService.showModal(ae.projectShareCorporate(),{data:r})}_productUpdateVersionPanel(t,e,r,n){e.holders.filter(i=>(i.type===3||i.type===4)&&i.products&&i.products.length>0).forEach(i=>{i.products.filter(o=>o.code.trim()===r.code).forEach(o=>{let a=n.caseSize&&o.isCase,c=o.orientation,d=o.projectCompression,u=ui(t,e,i,o),l=pi(n,i,c,a,{w:u.w,h:u.h},o.projectCompression);if(l.w>0&&l.h>0){let m=Te(n,c,a,o.projectCompression),C={w:o.fronts.w>l.w?l.w:o.fronts.w,h:o.fronts.h>l.h?l.h:o.fronts.h},f=o.location.y+Ot(o);Object.assign(o,n),o.code=o.code.trim(),o.id=n.id,o.isCase=a,o.orientation=c,o.fronts=C,o.size=m,o.facingSpace=i.type===3?Qr(m,i.pegSpacing):void 0,o.stock=null,o.location.y=f-Ot(o),o.projectCompression=d}else o.fronts={w:0,h:0},t.products.push(le(n))}),i.products=i.products.filter(o=>o.fronts.w>0&&o.fronts.h>0)})}_productUpdateVersionShelfs(t,e,r,n,i){e.holders.filter(o=>(o.type===1||o.type===-1)&&o.products&&o.products.length>
590).forEach(o=>{o.products.filter(a=>a.code.trim()===n.code).forEach(a=>{let c=a.isCase,d=a.orientation,u=a.fronts,l=a.stock,m=a.projectCompression;Object.assign(a,i),a.code=a.code.trim(),a.id=i.id,a.isCase=c,a.orientation=d,a.fronts=u,a.stock=l,a.projectCompression=m,a.size=Te(a,a.orientation,a.isCase,a.projectCompression)}),this.mountingGetShelfAlignment(o.alignment).alignProducts(t,r,o.name)})}static \u0275fac=function(e){return new(e||s)};static \u0275prov=P({token:s,factory:s.\u0275fac,providedIn:"root"})};export{or as a,Ct as b,Ba as c,Va as d,Jr as e,Zr as f,ur as g,uu as h,Ui as i,Ri as j,mu as k,hr as l,Ni as m,zi as n,Li as o,gr as p,wt as q,pe as r,Pt as s,ar as t,Hi as u,Ph as v,Sh as w,wh as x,kh as y,yr as z,jh as A,pn as B,Mh as C,Th as D,Ih as E,un as F,Ii as G,Pe as H,fi as I,sr as J,_i as K,bi as L,vi as M,Pi as N,fc as O,yc as P,Si as Q,wi as R,ki as S,ji as T,Mi as U,lr as V,dr as W,Ti as X,pr as Y,Ei as Z,Oi as _,Di as $,$i as aa,cr as ba};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.