@vendure/admin-ui-plugin 2.0.0-next.3 → 2.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";(self.webpackChunkvendure_admin=self.webpackChunkvendure_admin||[]).push([[349],{9592:(lr,ce,u)=>{u.r(ce),u.d(ce,{ApplyFacetDialogComponent:()=>gt,AssetDetailComponent:()=>et,AssetListComponent:()=>nt,AssetResolver:()=>Ft,AssetsComponent:()=>Y,AssignProductsToChannelDialogComponent:()=>X,CatalogModule:()=>Ut,CollectionContentsComponent:()=>W,CollectionDetailComponent:()=>lt,CollectionListComponent:()=>ut,CollectionResolver:()=>Ot,CollectionTreeComponent:()=>pt,CollectionTreeNodeComponent:()=>E,CollectionTreeService:()=>G,ConfirmVariantDeletionDialogComponent:()=>Pt,FacetDetailComponent:()=>mt,FacetListComponent:()=>_t,FacetResolver:()=>It,GenerateProductVariantsComponent:()=>ht,GeneratedVariant:()=>Pe,OPTION_VALUE_INPUT_VALUE_ACCESSOR:()=>be,OptionValueInputComponent:()=>H,ProductDetailComponent:()=>bt,ProductDetailService:()=>j,ProductListComponent:()=>Tt,ProductOptionsEditorComponent:()=>At,ProductResolver:()=>Lt,ProductSearchInputComponent:()=>Zt,ProductVariantsEditorComponent:()=>yt,ProductVariantsListComponent:()=>xt,ProductVariantsResolver:()=>tt,ProductVariantsTableComponent:()=>ft,UpdateProductOptionDialogComponent:()=>vt,VariantPriceDetailComponent:()=>Ct,arrayToTree:()=>ue,assetBreadcrumb:()=>we,catalogRoutes:()=>ye,collectionBreadcrumb:()=>Me,facetBreadcrumb:()=>Le,productBreadcrumb:()=>Fe,productOptionsEditorBreadcrumb:()=>Ie,productVariantEditorBreadcrumb:()=>Oe,replaceLast:()=>ie});var T=u(9720),s=u(279),_=u(8270),v=u(635),l=u(587),t=u(3184),A=u(7346),kt=u(3146),R=u(8276),J=u(9416),ke=u(3616),C=u(6362),F=u(7514);function Ve(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",4),t.NdJ("click",function(){return t.CHM(e),t.oxw().save()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw();t.Q6J("disabled",e.detailForm.invalid||e.detailForm.pristine),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.update")," ")}}const Je=function(){return["UpdateCatalog","UpdateAsset"]};class et extends s.UT_{constructor(n,e,o,a,r,c){super(e,n,o,r),this.notificationService=a,this.dataService=r,this.formBuilder=c,this.detailForm=new l.cw({}),this.customFields=this.getCustomFieldConfig("Asset")}ngOnInit(){this.detailForm=new l.cw({name:new l.NI(""),tags:new l.NI([]),customFields:this.formBuilder.group(this.customFields.reduce((n,e)=>Object.assign(Object.assign({},n),{[e.name]:""}),{}))}),this.init()}ngOnDestroy(){this.destroy()}onAssetChange(n){var e,o;null===(e=this.detailForm.get("name"))||void 0===e||e.setValue(n.name),null===(o=this.detailForm.get("tags"))||void 0===o||o.setValue(n.tags),this.detailForm.markAsDirty()}save(){this.dataService.product.updateAsset({id:this.id,name:this.detailForm.value.name,tags:this.detailForm.value.tags,customFields:this.detailForm.value.customFields}).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-update-success"),{entity:"Asset"})},n=>{this.notificationService.error((0,_.J)("common.notify-update-error"),{entity:"Asset"})})}setFormValues(n,e){var o,a;null===(o=this.detailForm.get("name"))||void 0===o||o.setValue(n.name),null===(a=this.detailForm.get("tags"))||void 0===a||a.setValue(n.tags),this.customFields.length&&this.setCustomFieldFormValues(this.customFields,this.detailForm.get(["customFields"]),n)}}et.\u0275fac=function(n){return new(n||et)(t.Y36(T.F0),t.Y36(T.gz),t.Y36(s.iHG),t.Y36(s.gqp),t.Y36(s.DoR),t.Y36(l.qu))},et.\u0275cmp=t.Xpm({type:et,selectors:[["vdr-asset-detail"]],features:[t.qOj],decls:9,vars:11,consts:[[3,"entity"],["locationId","asset-detail"],["class","btn btn-primary",3,"disabled","click",4,"vdrIfPermissions"],[3,"asset","editable","customFields","customFieldsForm","assetChange"],[1,"btn","btn-primary",3,"disabled","click"]],template:function(n,e){1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left"),t._UZ(2,"vdr-entity-info",0),t.ALo(3,"async"),t.qZA(),t.TgZ(4,"vdr-ab-right"),t._UZ(5,"vdr-action-bar-items",1),t.YNc(6,Ve,3,4,"button",2),t.qZA()(),t.TgZ(7,"vdr-asset-preview",3),t.NdJ("assetChange",function(a){return e.onAssetChange(a)}),t.ALo(8,"async"),t.qZA()),2&n&&(t.xp6(2),t.Q6J("entity",t.lcZ(3,6,e.entity$)),t.xp6(4),t.Q6J("vdrIfPermissions",t.DdM(10,Je)),t.xp6(1),t.Q6J("asset",t.lcZ(8,8,e.entity$))("editable",!0)("customFields",e.customFields)("customFieldsForm",e.detailForm.get("customFields")))},directives:[A.Kk,A.BN,kt.V,A.mz,R.W,J.H,ke.A],pipes:[C.Ov,F.X$],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;height:100%}"],changeDetection:0});var N=u(6317),O=u(6562),D=u(591),$=u(1989),q=u(8951),se=u(2313),y=u(2673),Ue=u(2688),Ne=u(4042),De=u(9206),le=u(6940),de=u(322),Kt=u(5595),U=u(7388);const qe=function(){return{}},Se=function(){return["DeleteCatalog","DeleteAsset"]};class nt extends s.t7C{constructor(n,e,o,a,r){super(a,r),this.notificationService=n,this.modalService=e,this.dataService=o,this.searchTerm$=new N.X(void 0),this.filterByTags$=new N.X(void 0),this.uploading=!1,super.setQueryFn((...c)=>this.dataService.product.getAssetList(...c),c=>c.assets,(c,d)=>{var p;const h=this.searchTerm$.value,m=null===(p=this.filterByTags$.value)||void 0===p?void 0:p.map(g=>g.value);return{options:Object.assign(Object.assign({skip:c,take:d},h?{filter:{name:{contains:h}}}:{}),{sort:{createdAt:s.Asd.DESC},tags:m,tagsOperator:s.FnJ.AND})}},{take:25,skip:0})}ngOnInit(){super.ngOnInit(),this.paginationConfig$=(0,O.a)(this.itemsPerPage$,this.currentPage$,this.totalItems$).pipe((0,v.U)(([n,e,o])=>({itemsPerPage:n,currentPage:e,totalItems:o}))),this.searchTerm$.pipe((0,$.b)(250),(0,q.R)(this.destroy$)).subscribe(()=>this.refresh()),this.filterByTags$.pipe((0,q.R)(this.destroy$)).subscribe(()=>this.refresh()),this.allTags$=this.dataService.product.getTagList().mapStream(n=>n.tags.items)}filesSelected(n){n.length&&(this.uploading=!0,this.dataService.product.createAssets(n).pipe((0,se.x)(()=>this.uploading=!1)).subscribe(({createAssets:e})=>{let o=0;for(const a of e)switch(a.__typename){case"Asset":o++;break;case"MimeTypeError":this.notificationService.error(a.message)}0<o&&(super.refresh(),this.notificationService.success((0,_.J)("asset.notify-create-assets-success"),{count:o}))}))}deleteAssets(n){this.showModalAndDelete(n.map(e=>e.id)).pipe((0,y.w)(e=>e.result===s.PcR.DELETED?[!0]:this.showModalAndDelete(n.map(o=>o.id),e.message||"").pipe((0,v.U)(o=>o.result===s.PcR.DELETED)))).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-delete-success"),{entity:"Assets"}),this.refresh()},e=>{this.notificationService.error((0,_.J)("common.notify-delete-error"),{entity:"Assets"})})}showModalAndDelete(n,e){return this.modalService.dialog({title:(0,_.J)("catalog.confirm-delete-assets"),translationVars:{count:n.length},body:e,buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("common.delete"),returnValue:!0}]}).pipe((0,y.w)(o=>o?this.dataService.product.deleteAssets(n,!!e):D.E),(0,v.U)(o=>o.deleteAssets))}}nt.\u0275fac=function(n){return new(n||nt)(t.Y36(s.gqp),t.Y36(s.Z7U),t.Y36(s.DoR),t.Y36(T.F0),t.Y36(T.gz))},nt.\u0275cmp=t.Xpm({type:nt,selectors:[["vdr-asset-list"]],features:[t.qOj],decls:19,vars:31,consts:[[3,"grow"],[1,"pr4","mt1",3,"tags","searchTermChange","tagsChange"],["locationId","asset-list"],["dropZoneTarget",".content-area",3,"uploading","selectFiles"],[3,"assets","multiSelect","canDelete","deleteAssets"],[1,"paging-controls"],[3,"itemsPerPage","itemsPerPageChange"],[3,"currentPage","itemsPerPage","totalItems","pageChange"]],template:function(n,e){1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left",0)(2,"vdr-asset-search-input",1),t.NdJ("searchTermChange",function(a){return e.searchTerm$.next(a)})("tagsChange",function(a){return e.filterByTags$.next(a)}),t.ALo(3,"async"),t.qZA()(),t.TgZ(4,"vdr-ab-right"),t._UZ(5,"vdr-action-bar-items",2),t.TgZ(6,"vdr-asset-file-input",3),t.NdJ("selectFiles",function(a){return e.filesSelected(a)}),t.qZA()()(),t.TgZ(7,"vdr-asset-gallery",4),t.NdJ("deleteAssets",function(a){return e.deleteAssets(a)}),t.ALo(8,"paginate"),t.ALo(9,"async"),t.ALo(10,"async"),t.ALo(11,"hasPermission"),t.qZA(),t.TgZ(12,"div",5)(13,"vdr-items-per-page-controls",6),t.NdJ("itemsPerPageChange",function(a){return e.setItemsPerPage(a)}),t.ALo(14,"async"),t.qZA(),t.TgZ(15,"vdr-pagination-controls",7),t.NdJ("pageChange",function(a){return e.setPageNumber(a)}),t.ALo(16,"async"),t.ALo(17,"async"),t.ALo(18,"async"),t.qZA()()),2&n&&(t.xp6(1),t.Q6J("grow",!0),t.xp6(1),t.Q6J("tags",t.lcZ(3,10,e.allTags$)),t.xp6(4),t.Q6J("uploading",e.uploading),t.xp6(1),t.Q6J("assets",t.xi3(8,12,t.lcZ(9,15,e.items$),t.lcZ(10,17,e.paginationConfig$)||t.DdM(29,qe)))("multiSelect",!0)("canDelete",t.lcZ(11,19,t.DdM(30,Se))),t.xp6(6),t.Q6J("itemsPerPage",t.lcZ(14,21,e.itemsPerPage$)),t.xp6(2),t.Q6J("currentPage",t.lcZ(16,23,e.currentPage$))("itemsPerPage",t.lcZ(17,25,e.itemsPerPage$))("totalItems",t.lcZ(18,27,e.totalItems$)))},directives:[A.Kk,A.BN,Ue.V,A.mz,R.W,Ne.e,De.K,le.w,de.L],pipes:[C.Ov,Kt._s,U.j],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;height:100%}vdr-asset-gallery[_ngcontent-%COMP%]{flex:1}.paging-controls[_ngcontent-%COMP%]{padding-top:6px;border-top:1px solid var(--color-component-border-100);display:flex;justify-content:space-between}.search-input[_ngcontent-%COMP%]{margin-top:6px;min-width:300px}"]});var z=u(2604),L=u(745),Gt=u(116),k=u(9295),P=u(9525),ot=u(7425),Dt=u(4652),f=u(2748),M=u(7890),Et=u(3516),pe=u(3628),qt=u(837),Wt=u(2505),Q=u(6998),St=u(9493),it=u(735),at=u(1519),rt=u(8854),ct=u(5111),Xt=u(1353);function $e(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"img",11),t.NdJ("click",function(){t.CHM(e);const a=t.oxw(2);return a.previewAsset(a.featuredAsset)}),t.ALo(1,"assetPreview"),t.qZA()}if(2&i){const e=t.oxw(2);t.Q6J("src",t.xi3(1,1,e.featuredAsset,"small"),t.LSH)}}function Qe(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",12),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).selectAssets()}),t._UZ(1,"clr-icon",13),t.TgZ(2,"div"),t._uU(3),t.ALo(4,"translate"),t.qZA()()}2&i&&(t.xp6(3),t.Oqu(t.lcZ(4,1,"catalog.no-featured-asset")))}function Ye(i,n){1&i&&t.GkF(0)}function Ge(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",14)(1,"button",15),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).selectAssets()}),t._UZ(2,"clr-icon",16),t._uU(3),t.ALo(4,"translate"),t.qZA()()}2&i&&(t.xp6(3),t.hij(" ",t.lcZ(4,1,"asset.add-asset")," "))}function Ee(i,n){if(1&i&&(t.TgZ(0,"div",3)(1,"div",4)(2,"div",5),t.YNc(3,$e,2,4,"img",6),t.YNc(4,Qe,5,3,"div",7),t.qZA()(),t.TgZ(5,"div",8),t.YNc(6,Ye,1,0,"ng-container",9),t.qZA(),t.YNc(7,Ge,5,3,"div",10),t.qZA()),2&i){const e=t.oxw(),o=t.MAs(4);t.xp6(3),t.Q6J("ngIf",e.featuredAsset),t.xp6(1),t.Q6J("ngIf",!e.featuredAsset),t.xp6(2),t.Q6J("ngTemplateOutlet",o),t.xp6(1),t.Q6J("vdrIfPermissions",e.updatePermissions)}}function je(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"img",11),t.NdJ("click",function(){t.CHM(e);const a=t.oxw(2);return a.previewAsset(a.featuredAsset)}),t.ALo(1,"assetPreview"),t.qZA()}if(2&i){const e=t.oxw(2);t.Q6J("src",t.xi3(1,1,e.featuredAsset,"thumb"),t.LSH)}}function He(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",12),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).selectAssets()}),t._UZ(1,"clr-icon",19),t.qZA()}}function Be(i,n){1&i&&t.GkF(0)}function Re(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",20),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).selectAssets()}),t.ALo(1,"translate"),t._UZ(2,"clr-icon",16),t._uU(3),t.ALo(4,"translate"),t.qZA()}2&i&&(t.Q6J("title",t.lcZ(1,2,"asset.add-asset")),t.xp6(3),t.hij(" ",t.lcZ(4,4,"asset.add-asset")," "))}function ze(i,n){if(1&i&&(t.TgZ(0,"div",17),t.YNc(1,je,2,4,"img",6),t.YNc(2,He,2,0,"div",7),t.qZA(),t.YNc(3,Be,1,0,"ng-container",9),t.YNc(4,Re,5,6,"button",18)),2&i){const e=t.oxw(),o=t.MAs(4);t.xp6(1),t.Q6J("ngIf",e.featuredAsset),t.xp6(1),t.Q6J("ngIf",!e.featuredAsset),t.xp6(1),t.Q6J("ngTemplateOutlet",o),t.xp6(1),t.Q6J("vdrIfPermissions",e.updatePermissions)}}function Ke(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",23),t.NdJ("cdkDropListDropped",function(a){return t.CHM(e),t.oxw(2).dropListDropped(a)}),t.ALo(1,"hasPermission"),t.TgZ(2,"vdr-dropdown",24)(3,"div",25),t._UZ(4,"img",26),t.ALo(5,"assetPreview"),t.qZA(),t.TgZ(6,"vdr-dropdown-menu",27)(7,"button",28),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw(2).previewAsset(r)}),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.TgZ(10,"button",29),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw(2).setAsFeatured(r)}),t.ALo(11,"hasPermission"),t._uU(12),t.ALo(13,"translate"),t.qZA(),t._UZ(14,"div",30),t.TgZ(15,"button",31),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw(2).removeAsset(r)}),t.ALo(16,"hasPermission"),t._uU(17),t.ALo(18,"translate"),t.qZA()()()()}if(2&i){const e=n.$implicit,o=n.index,a=t.oxw(2);t.Q6J("cdkDropListData",o)("cdkDropListDisabled",!t.lcZ(1,10,a.updatePermissions)),t.xp6(3),t.ekj("featured",a.isFeatured(e)),t.xp6(1),t.Q6J("src",t.xi3(5,12,e,"tiny"),t.LSH),t.xp6(4),t.hij(" ",t.lcZ(9,15,"asset.preview")," "),t.xp6(2),t.Q6J("disabled",a.isFeatured(e)||!t.lcZ(11,17,a.updatePermissions)),t.xp6(2),t.hij(" ",t.lcZ(13,19,"asset.set-as-featured-asset")," "),t.xp6(3),t.Q6J("disabled",!t.lcZ(16,21,a.updatePermissions)),t.xp6(2),t.hij(" ",t.lcZ(18,23,"asset.remove-asset")," ")}}function We(i,n){if(1&i&&(t.TgZ(0,"div",21),t.YNc(1,Ke,19,25,"div",22),t.qZA()),2&i){const e=t.oxw();t.ekj("compact",e.compact),t.xp6(1),t.Q6J("ngForOf",e.assets)}}class Y{constructor(n,e){this.modalService=n,this.changeDetector=e,this.compact=!1,this.change=new t.vpe,this.assets=[]}set assetsSetter(n){this.assets=(n||[]).slice()}selectAssets(){this.modalService.fromComponent(s.V61,{size:"xl"}).subscribe(n=>{n&&n.length&&(this.assets=(0,St.T)(this.assets.concat(n),"id"),this.featuredAsset||(this.featuredAsset=n[0]),this.emitChangeEvent(this.assets,this.featuredAsset),this.changeDetector.markForCheck())})}setAsFeatured(n){this.featuredAsset=n,this.emitChangeEvent(this.assets,n)}isFeatured(n){return!!this.featuredAsset&&this.featuredAsset.id===n.id}previewAsset(n){this.modalService.fromComponent(s.IW,{size:"xl",closable:!0,locals:{asset:n}}).subscribe()}removeAsset(n){this.assets=this.assets.filter(e=>e.id!==n.id),this.featuredAsset&&this.featuredAsset.id===n.id&&(this.featuredAsset=this.assets.length>0?this.assets[0]:void 0),this.emitChangeEvent(this.assets,this.featuredAsset)}emitChangeEvent(n,e){this.change.emit({assets:n,featuredAsset:e})}dropListDropped(n){(0,Q.bA)(this.assets,n.previousContainer.data,n.container.data),this.emitChangeEvent(this.assets,this.featuredAsset)}}Y.\u0275fac=function(n){return new(n||Y)(t.Y36(s.Z7U),t.Y36(t.sBO))},Y.\u0275cmp=t.Xpm({type:Y,selectors:[["vdr-assets"]],hostVars:2,hostBindings:function(n,e){2&n&&t.ekj("compact",e.compact)},inputs:{assetsSetter:["assets","assetsSetter"],featuredAsset:"featuredAsset",compact:"compact",updatePermissions:"updatePermissions"},outputs:{change:"change"},decls:5,vars:2,consts:[["class","card",4,"ngIf","ngIfElse"],["compactView",""],["assetList",""],[1,"card"],[1,"card-img"],[1,"featured-asset"],[3,"src","click",4,"ngIf"],["class","placeholder",3,"click",4,"ngIf"],[1,"card-block"],[4,"ngTemplateOutlet"],["class","card-footer",4,"vdrIfPermissions"],[3,"src","click"],[1,"placeholder",3,"click"],["shape","image","size","128"],[1,"card-footer"],[1,"btn",3,"click"],["shape","attachment"],[1,"featured-asset","compact"],["class","compact-select btn btn-icon btn-sm btn-block",3,"title","click",4,"vdrIfPermissions"],["shape","image","size","150"],[1,"compact-select","btn","btn-icon","btn-sm","btn-block",3,"title","click"],["cdkDropListGroup","",1,"all-assets"],["class","drop-list","cdkDropList","","cdkDropListOrientation","horizontal",3,"cdkDropListData","cdkDropListDisabled","cdkDropListDropped",4,"ngFor","ngForOf"],["cdkDropList","","cdkDropListOrientation","horizontal",1,"drop-list",3,"cdkDropListData","cdkDropListDisabled","cdkDropListDropped"],["cdkDrag",""],["vdrDropdownTrigger","","tabindex","0",1,"asset-thumb",3,"title"],[3,"src"],["vdrPosition","bottom-right"],["type","button","vdrDropdownItem","",3,"click"],["type","button","vdrDropdownItem","",3,"disabled","click"],[1,"dropdown-divider"],["type","button","vdrDropdownItem","",1,"remove-asset",3,"disabled","click"]],template:function(n,e){if(1&n&&(t.YNc(0,Ee,8,4,"div",0),t.YNc(1,ze,5,4,"ng-template",null,1,t.W1O),t.YNc(3,We,2,3,"ng-template",null,2,t.W1O)),2&n){const o=t.MAs(2);t.Q6J("ngIf",!e.compact)("ngIfElse",o)}},directives:[C.O5,f.qvL,C.tP,J.H,Q.Fd,C.sg,Q.Wj,it.J,Q.Zt,at.U,rt.N,ct.H],pipes:[Xt.M,F.X$,U.j],styles:["[_nghost-%COMP%]{width:340px;display:block}.compact[_nghost-%COMP%]{width:162px}.placeholder[_ngcontent-%COMP%]{text-align:center;color:var(--color-grey-300)}.featured-asset[_ngcontent-%COMP%]{text-align:center;background:var(--color-component-bg-200);padding:6px;cursor:pointer}.featured-asset.compact[_ngcontent-%COMP%]{width:100%;min-height:40px;position:relative;padding:6px}.featured-asset[_ngcontent-%COMP%] .compact-select[_ngcontent-%COMP%]{position:absolute;bottom:6px;right:6px;margin:0}.all-assets[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap}.all-assets[_ngcontent-%COMP%] .drop-list[_ngcontent-%COMP%]{min-width:60px}.all-assets[_ngcontent-%COMP%] .asset-thumb[_ngcontent-%COMP%]{margin:3px;padding:0;border:2px solid var(--color-component-border-100);cursor:pointer}.all-assets[_ngcontent-%COMP%] .asset-thumb[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:50px;height:50px}.all-assets[_ngcontent-%COMP%] .asset-thumb.featured[_ngcontent-%COMP%]{border-color:var(--color-primary-500)}.all-assets[_ngcontent-%COMP%] .remove-asset[_ngcontent-%COMP%]{color:var(--color-warning-500)}.all-assets.compact[_ngcontent-%COMP%] .drop-list[_ngcontent-%COMP%]{min-width:54px}.all-assets.compact[_ngcontent-%COMP%] .asset-thumb[_ngcontent-%COMP%]{margin:1px;border-width:1px}.all-assets.compact[_ngcontent-%COMP%] .cdk-drag-placeholder[_ngcontent-%COMP%], .all-assets.compact[_ngcontent-%COMP%] .cdk-drag-placeholder[_ngcontent-%COMP%] .asset-thumb[_ngcontent-%COMP%]{width:50px}.cdk-drag-animating[_ngcontent-%COMP%]{transition:transform .25s cubic-bezier(0,0,.2,1)}.example-box[_ngcontent-%COMP%]:last-child{border:none}.all-assets.cdk-drop-list-dragging[_ngcontent-%COMP%] vdr-dropdown[_ngcontent-%COMP%]:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.cdk-drop-list-dragging[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:not(.cdk-drag-placeholder){display:none}"],changeDetection:0});var Xe=u(8931),jt=u(253),Vt=u(4874),st=u(8977),K=u(9337),tn=u(3158),te=u(365),ee=u(8899);function en(i,n){1&i&&t.GkF(0)}const nn=function(){return{tab:"variants"}},on=function(i,n){return["/catalog/products",i,n]};function an(i,n){if(1&i&&(t.TgZ(0,"td",7),t._uU(1),t.qZA(),t.TgZ(2,"td",7)(3,"small",8),t._uU(4),t.qZA()(),t.TgZ(5,"td",9),t._UZ(6,"vdr-table-row-action",10),t.ALo(7,"translate"),t.qZA()),2&i){const e=n.item;t.xp6(1),t.Oqu(e.name),t.xp6(3),t.Oqu(e.sku),t.xp6(2),t.Q6J("label",t.lcZ(7,4,"common.edit"))("linkTo",t.WLB(7,on,e.productId,t.DdM(6,nn)))}}const rn=function(i){return{$implicit:i}};class W{constructor(n,e,o){this.route=n,this.router=e,this.dataService=o,this.previewUpdatedFilters=!1,this.filterTermControl=new l.NI(""),this.isLoading=!1,this.collectionIdChange$=new N.X(""),this.parentIdChange$=new N.X(""),this.filterChanges$=new N.X([]),this.refresh$=new N.X(!0),this.destroy$=new jt.x}ngOnInit(){this.contentsCurrentPage$=this.route.queryParamMap.pipe((0,v.U)(r=>r.get("contentsPage")),(0,v.U)(r=>r?+r:1),(0,Vt.O)(1),(0,st.x)()),this.contentsItemsPerPage$=this.route.queryParamMap.pipe((0,v.U)(r=>r.get("contentsPerPage")),(0,v.U)(r=>r?+r:10),(0,Vt.O)(10),(0,st.x)());const n=this.filterTermControl.valueChanges.pipe((0,$.b)(250),(0,K.b)(()=>this.setContentsPageNumber(1)),(0,Vt.O)("")),e=this.filterChanges$.asObservable().pipe((0,Gt.h)(()=>this.previewUpdatedFilters),(0,K.b)(()=>this.setContentsPageNumber(1)),(0,Vt.O)([])),a=(0,O.a)(this.collectionIdChange$,this.parentIdChange$,this.contentsCurrentPage$,this.contentsItemsPerPage$,n,e,this.refresh$).pipe((0,q.R)(this.destroy$),(0,K.b)(()=>this.isLoading=!0),(0,$.b)(50),(0,y.w)(([r,c,d,p,h,m])=>{const g=p,x=(d-1)*p;if(m.length&&this.previewUpdatedFilters){const b=h?{name:{contains:h}}:void 0;return this.dataService.collection.previewCollectionVariants({parentId:c,filters:m},{take:g,skip:x,filter:b}).mapSingle(Z=>Z.previewCollectionVariants).pipe((0,tn.K)(()=>(0,L.of)({items:[],totalItems:0})))}return r?this.dataService.collection.getCollectionContents(r,g,x,h).mapSingle(b=>{var Z;return null===(Z=b.collection)||void 0===Z?void 0:Z.productVariants}):(0,L.of)(null)}),(0,K.b)(()=>this.isLoading=!1),(0,se.x)(()=>this.isLoading=!1));this.contents$=a.pipe((0,v.U)(r=>r?r.items:[])),this.contentsTotalItems$=a.pipe((0,v.U)(r=>r?r.totalItems:0))}ngOnChanges(n){"collectionId"in n&&this.collectionIdChange$.next(n.collectionId.currentValue),"parentId"in n&&this.parentIdChange$.next(n.parentId.currentValue),"updatedFilters"in n&&this.updatedFilters&&this.filterChanges$.next(this.updatedFilters)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}setContentsPageNumber(n){this.setParam("contentsPage",n)}setContentsItemsPerPage(n){this.setParam("contentsPerPage",n)}refresh(){this.refresh$.next(!0)}setParam(n,e){this.router.navigate(["./"],{relativeTo:this.route,queryParams:{[n]:e},queryParamsHandling:"merge",replaceUrl:!0})}}W.\u0275fac=function(n){return new(n||W)(t.Y36(T.gz),t.Y36(T.F0),t.Y36(s.DoR))},W.\u0275cmp=t.Xpm({type:W,selectors:[["vdr-collection-contents"]],contentQueries:function(n,e,o){if(1&n&&t.Suo(o,t.Rgc,7),2&n){let a;t.iGM(a=t.CRH())&&(e.headerTemplate=a.first)}},inputs:{collectionId:"collectionId",parentId:"parentId",updatedFilters:"updatedFilters",previewUpdatedFilters:"previewUpdatedFilters"},features:[t.TTD],decls:14,vars:26,consts:[[1,"contents-header"],[1,"header-title-row"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],["type","text",3,"placeholder","formControl"],[1,"table-wrapper"],[1,"progress","loop"],[3,"items","itemsPerPage","totalItems","currentPage","pageChange","itemsPerPageChange"],[1,"left","align-middle"],[1,"sku"],[1,"right","align-middle"],["iconShape","edit",3,"label","linkTo"]],template:function(n,e){1&n&&(t.TgZ(0,"div",0)(1,"div",1),t.YNc(2,en,1,0,"ng-container",2),t.ALo(3,"async"),t.qZA(),t._UZ(4,"input",3),t.ALo(5,"translate"),t.qZA(),t.TgZ(6,"div",4),t._UZ(7,"div",5),t.TgZ(8,"vdr-data-table",6),t.NdJ("pageChange",function(a){return e.setContentsPageNumber(a)})("itemsPerPageChange",function(a){return e.setContentsItemsPerPage(a)}),t.ALo(9,"async"),t.ALo(10,"async"),t.ALo(11,"async"),t.ALo(12,"async"),t.YNc(13,an,8,10,"ng-template"),t.qZA()()),2&n&&(t.xp6(2),t.Q6J("ngTemplateOutlet",e.headerTemplate)("ngTemplateOutletContext",t.VKq(24,rn,t.lcZ(3,12,e.contentsTotalItems$))),t.xp6(2),t.Q6J("placeholder",t.lcZ(5,14,"catalog.filter-by-name"))("formControl",e.filterTermControl),t.xp6(3),t.ekj("visible",e.isLoading),t.xp6(1),t.ekj("loading",e.isLoading),t.Q6J("items",t.lcZ(9,16,e.contents$))("itemsPerPage",t.lcZ(10,18,e.contentsItemsPerPage$))("totalItems",t.lcZ(11,20,e.contentsTotalItems$))("currentPage",t.lcZ(12,22,e.contentsCurrentPage$)))},directives:[C.tP,M.y,l.Fj,l.JJ,l.oH,te.Q,ee.v],pipes:[C.Ov,F.X$],styles:[".contents-header[_ngcontent-%COMP%]{background-color:var(--color-component-bg-100);position:sticky;top:0;padding:6px;z-index:1;border-bottom:1px solid var(--color-component-border-200)}.contents-header[_ngcontent-%COMP%] .header-title-row[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}.contents-header[_ngcontent-%COMP%] .clr-input[_ngcontent-%COMP%]{width:100%}[_nghost-%COMP%]{display:block}[_nghost-%COMP%] table{margin-top:-1px}vdr-data-table[_ngcontent-%COMP%]{opacity:1;transition:opacity .3s}vdr-data-table.loading[_ngcontent-%COMP%]{opacity:.5}.table-wrapper[_ngcontent-%COMP%]{position:relative}.progress[_ngcontent-%COMP%]{position:absolute;top:0;left:0;overflow:hidden;height:6px;opacity:0;transition:opacity .1s}.progress.visible[_ngcontent-%COMP%]{opacity:1}.sku[_ngcontent-%COMP%]{color:var(--color-text-200)}"],changeDetection:0});const cn=["collectionContents"];function sn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",6),t.NdJ("click",function(){return t.CHM(e),t.oxw().create()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw();t.Q6J("disabled",e.detailForm.invalid||e.detailForm.pristine),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.create")," ")}}function ln(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",6),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).save()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw(2);t.Q6J("disabled",(e.detailForm.invalid||e.detailForm.pristine)&&!e.assetsChanged()),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.update")," ")}}function dn(i,n){if(1&i&&t.YNc(0,ln,3,4,"button",7),2&i){const e=t.oxw();t.Q6J("vdrIfPermissions",e.updatePermission)}}function pn(i,n){1&i&&(t.ynx(0),t._uU(1),t.ALo(2,"translate"),t.BQk()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.public")))}function un(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.private"))}const mn=function(){return["customFields"]};function _n(i,n){if(1&i&&(t.TgZ(0,"section",33)(1,"label"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t._UZ(4,"vdr-tabbed-custom-fields",34),t.ALo(5,"hasPermission"),t.qZA()),2&i){const e=t.oxw(2);t.xp6(2),t.Oqu(t.lcZ(3,4,"common.custom-fields")),t.xp6(2),t.Q6J("customFields",e.customFields)("customFieldsFormGroup",e.detailForm.get(t.DdM(8,mn)))("readonly",!t.lcZ(5,6,e.updatePermission))}}function gn(i,n){1&i&&(t.ynx(0),t._uU(1),t.ALo(2,"translate"),t.BQk()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.inherit-filters-from-parent")))}function hn(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.do-not-inherit-filters"))}function fn(i,n){if(1&i){const e=t.EpF();t.ynx(0),t.TgZ(1,"vdr-configurable-input",35),t.NdJ("remove",function(){const r=t.CHM(e).index;return t.oxw(2).removeFilter(r)}),t.ALo(2,"hasPermission"),t.qZA(),t.BQk()}if(2&i){const e=n.$implicit,o=n.index,a=t.oxw(2);t.xp6(1),t.Q6J("operation",e)("operationDefinition",a.getFilterDefinition(e))("formControlName",o)("readonly",!t.lcZ(2,4,a.updatePermission))}}function vn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",40),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw(3).addFilter(r)}),t._uU(1),t.qZA()}if(2&i){const e=n.$implicit;t.xp6(1),t.hij(" ",e.description," ")}}function Cn(i,n){if(1&i&&(t.TgZ(0,"div")(1,"vdr-dropdown")(2,"button",36),t._UZ(3,"clr-icon",37),t._uU(4),t.ALo(5,"translate"),t.qZA(),t.TgZ(6,"vdr-dropdown-menu",38),t.YNc(7,vn,2,1,"button",39),t.qZA()()()),2&i){const e=t.oxw(2);t.xp6(4),t.hij(" ",t.lcZ(5,2,"marketing.add-condition")," "),t.xp6(3),t.Q6J("ngForOf",e.allFilters)}}const xn=function(i){return{count:i}},bn=function(){return{standalone:!0}};function Zn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",41),t._uU(1),t.ALo(2,"translate"),t.ALo(3,"translate"),t.qZA(),t.TgZ(4,"clr-checkbox-wrapper")(5,"input",42),t.NdJ("ngModelChange",function(){return t.CHM(e),t.oxw(2).toggleLivePreview()}),t.qZA(),t.TgZ(6,"label"),t._uU(7),t.ALo(8,"translate"),t.qZA()()}if(2&i){const e=n.$implicit,o=t.oxw(2);let a,r;t.xp6(1),t.AsE(" ",t.lcZ(2,8,"catalog.collection-contents")," (",t.xi3(3,10,"common.results-count",t.VKq(15,xn,e)),") "),t.xp6(3),t.ekj("disabled",null==(a=o.detailForm.get("filters"))?null:a.pristine),t.xp6(1),t.Q6J("ngModelOptions",t.DdM(17,bn))("disabled",null==(r=o.detailForm.get("filters"))?null:r.pristine)("ngModel",o.livePreview),t.xp6(2),t.Oqu(t.lcZ(8,13,"catalog.live-preview-contents"))}}const Tn=function(i){return{pattern:i}};function An(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"form",8)(1,"div",9)(2,"div",10)(3,"vdr-form-field",11),t.ALo(4,"translate"),t.TgZ(5,"clr-toggle-wrapper"),t._UZ(6,"input",12),t.ALo(7,"hasPermission"),t.TgZ(8,"label",13),t.YNc(9,pn,3,3,"ng-container",14),t.YNc(10,un,2,3,"ng-template",null,15,t.W1O),t.qZA()()(),t.TgZ(12,"vdr-form-field",16),t.ALo(13,"translate"),t.TgZ(14,"input",17),t.NdJ("input",function(a){return t.CHM(e),t.oxw().updateSlug(a.target.value)}),t.ALo(15,"hasPermission"),t.qZA()(),t.TgZ(16,"vdr-form-field",18),t.ALo(17,"translate"),t.ALo(18,"translate"),t._UZ(19,"input",19),t.ALo(20,"hasPermission"),t.qZA(),t._UZ(21,"vdr-rich-text-editor",20),t.ALo(22,"hasPermission"),t.ALo(23,"translate"),t.YNc(24,_n,6,9,"section",21),t._UZ(25,"vdr-custom-detail-component-host",22),t.qZA(),t.TgZ(26,"div",23)(27,"vdr-assets",24),t.NdJ("change",function(a){t.CHM(e);return t.oxw().assetChanges=a}),t.qZA()()(),t.TgZ(28,"div",9)(29,"div",10)(30,"label"),t._uU(31),t.ALo(32,"translate"),t.qZA(),t.TgZ(33,"vdr-form-field",25),t.ALo(34,"translate"),t.TgZ(35,"clr-toggle-wrapper"),t._UZ(36,"input",26),t.ALo(37,"hasPermission"),t.TgZ(38,"label",13),t.YNc(39,gn,3,3,"ng-container",14),t.YNc(40,hn,2,3,"ng-template",null,27,t.W1O),t.qZA()()(),t.TgZ(42,"div",28),t.YNc(43,fn,3,6,"ng-container",29),t.qZA(),t.YNc(44,Cn,8,4,"div",30),t.qZA(),t.TgZ(45,"div",10)(46,"vdr-collection-contents",31,32),t.ALo(48,"async"),t.ALo(49,"async"),t.YNc(50,Zn,9,18,"ng-template"),t.qZA()()()()}if(2&i){const e=n.ngIf,o=t.MAs(11),a=t.MAs(41),r=t.oxw();t.Q6J("formGroup",r.detailForm),t.xp6(3),t.Q6J("label",t.lcZ(4,30,"catalog.visibility")),t.xp6(3),t.Q6J("vdrDisabled",!t.lcZ(7,32,r.updatePermission)),t.xp6(3),t.Q6J("ngIf",r.detailForm.value.visible)("ngIfElse",o),t.xp6(3),t.Q6J("label",t.lcZ(13,34,"common.name")),t.xp6(2),t.Q6J("readonly",!t.lcZ(15,36,r.updatePermission)),t.xp6(2),t.Q6J("label",t.lcZ(17,38,"catalog.slug"))("errors",t.VKq(58,Tn,t.lcZ(18,40,"catalog.slug-pattern-error"))),t.xp6(3),t.Q6J("readonly",!t.lcZ(20,42,r.updatePermission)),t.xp6(2),t.Q6J("readonly",!t.lcZ(22,44,r.updatePermission))("label",t.lcZ(23,46,"common.description")),t.xp6(3),t.Q6J("ngIf",r.customFields.length),t.xp6(1),t.Q6J("entity$",r.entity$)("detailForm",r.detailForm),t.xp6(2),t.Q6J("assets",e.assets)("featuredAsset",e.featuredAsset)("updatePermissions",r.updatePermission),t.xp6(4),t.Oqu(t.lcZ(32,48,"catalog.filters")),t.xp6(2),t.Q6J("label",t.lcZ(34,50,"catalog.filter-inheritance")),t.xp6(3),t.Q6J("vdrDisabled",!t.lcZ(37,52,r.updatePermission)),t.xp6(3),t.Q6J("ngIf",r.detailForm.value.inheritFilters)("ngIfElse",a),t.xp6(4),t.Q6J("ngForOf",r.filters)("ngForTrackBy",r.trackByFn),t.xp6(1),t.Q6J("vdrIfPermissions",r.updatePermission),t.xp6(2),t.Q6J("collectionId",r.id)("parentId",t.lcZ(48,54,r.parentId$))("updatedFilters",t.lcZ(49,56,r.updatedFilters$))("previewUpdatedFilters",r.livePreview)}}class lt extends s.UT_{constructor(n,e,o,a,r,c,d,p,h){var m;super(e,n,o,r),this.changeDetector=a,this.dataService=r,this.formBuilder=c,this.notificationService=d,this.modalService=p,this.localStorageService=h,this.assetChanges={},this.filters=[],this.allFilters=[],this.livePreview=!1,this.updatePermission=[s.y3$.UpdateCatalog,s.y3$.UpdateCollection],this.customFields=this.getCustomFieldConfig("Collection"),this.detailForm=this.formBuilder.group({name:["",l.kI.required],slug:["",(0,s.Foo)(/^[\p{Letter}0-9_-]+$/)],description:"",visible:!1,inheritFilters:!0,filters:this.formBuilder.array([]),customFields:this.formBuilder.group(this.customFields.reduce((g,x)=>Object.assign(Object.assign({},g),{[x.name]:""}),{}))}),this.livePreview=null!==(m=this.localStorageService.get("livePreviewCollectionContents"))&&void 0!==m&&m}ngOnInit(){this.init(),this.dataService.collection.getCollectionFilters().single$.subscribe(e=>{this.allFilters=e.collectionFilters});const n=this.detailForm.get("filters");this.updatedFilters$=n.statusChanges.pipe((0,$.b)(200),(0,Gt.h)(()=>n.touched),(0,v.U)(e=>this.mapOperationsToInputs(this.filters,n.value))),this.parentId$=this.route.paramMap.pipe((0,v.U)(e=>e.get("parentId")||void 0),(0,y.w)(e=>e?(0,L.of)(e):this.entity$.pipe((0,v.U)(o=>{var a;return null===(a=o.parent)||void 0===a?void 0:a.id}))))}ngOnDestroy(){this.destroy()}getFilterDefinition(n){return this.allFilters.find(e=>e.code===n.code)}assetsChanged(){return!!Object.values(this.assetChanges).length}updateSlug(n){(0,O.a)(this.entity$,this.languageCode$).pipe((0,k.q)(1)).subscribe(([e,o])=>{const a=this.detailForm.get(["slug"]),r=(0,s.ZIM)(e,o),c=!r||!r.slug;a&&a.pristine&&c&&a.setValue((0,z.U)(`${n}`,"-"))})}addFilter(n){const e=this.detailForm.get("filters"),o=n.args.reduce((a,r)=>Object.assign(Object.assign({},a),{[r.name]:(0,s.sux)(r.value)}),{});e.push(this.formBuilder.control({code:n.code,args:o})),this.filters.push({code:n.code,args:n.args.map(a=>({name:a.name,value:(0,s.sux)(a.value)}))})}removeFilter(n){const e=this.detailForm.get("filters");-1!==n&&(e.removeAt(n),this.filters.splice(n,1))}create(){!this.detailForm.dirty||(0,O.a)(this.entity$,this.languageCode$).pipe((0,k.q)(1),(0,P.z)(([n,e])=>{const o=this.getUpdatedCollection(n,this.detailForm,e),a=this.route.snapshot.paramMap.get("parentId");return a&&(o.parentId=a),this.dataService.collection.createCollection(o)})).subscribe(n=>{this.notificationService.success((0,_.J)("common.notify-create-success"),{entity:"Collection"}),this.assetChanges={},this.detailForm.markAsPristine(),this.changeDetector.markForCheck(),this.router.navigate(["../",n.createCollection.id],{relativeTo:this.route})},n=>{this.notificationService.error((0,_.J)("common.notify-create-error"),{entity:"Collection"})})}save(){(0,O.a)(this.entity$,this.languageCode$).pipe((0,k.q)(1),(0,P.z)(([n,e])=>{const o=this.getUpdatedCollection(n,this.detailForm,e);return this.dataService.collection.updateCollection(o)})).subscribe(()=>{this.assetChanges={},this.detailForm.markAsPristine(),this.changeDetector.markForCheck(),this.notificationService.success((0,_.J)("common.notify-update-success"),{entity:"Collection"}),this.contentsComponent.refresh()},n=>{this.notificationService.error((0,_.J)("common.notify-update-error"),{entity:"Collection"})})}canDeactivate(){return super.canDeactivate()&&!this.assetChanges.assets&&!this.assetChanges.featuredAsset}toggleLivePreview(){this.livePreview=!this.livePreview,this.localStorageService.set("livePreviewCollectionContents",this.livePreview)}trackByFn(n,e){return JSON.stringify(e)}setFormValues(n,e){const o=(0,s.ZIM)(n,e);this.detailForm.patchValue({name:o?o.name:"",slug:o?o.slug:"",description:o?o.description:"",visible:!n.isPrivate,inheritFilters:n.inheritFilters});const a=this.detailForm.get("filters");a.length!==n.filters.length&&(a.clear(),this.filters=[],n.filters.forEach(r=>this.addFilter(r))),this.customFields.length&&this.setCustomFieldFormValues(this.customFields,this.detailForm.get(["customFields"]),n,o)}getUpdatedCollection(n,e,o){var a,r;const c=(0,s.iSy)({translatable:n,updatedFields:e.value,customFieldConfig:this.customFields,languageCode:o,defaultTranslation:{languageCode:o,name:n.name||"",slug:n.slug||"",description:n.description||""}});return Object.assign(Object.assign({},c),{assetIds:null===(a=this.assetChanges.assets)||void 0===a?void 0:a.map(d=>d.id),featuredAssetId:null===(r=this.assetChanges.featuredAsset)||void 0===r?void 0:r.id,isPrivate:!e.value.visible,filters:this.mapOperationsToInputs(this.filters,this.detailForm.value.filters)})}mapOperationsToInputs(n,e){return n.map((o,a)=>({code:o.code,arguments:Object.entries(e[a].args).map(([r,c],d)=>({name:r,value:(0,s.qrw)(c)}))}))}}lt.\u0275fac=function(n){return new(n||lt)(t.Y36(T.F0),t.Y36(T.gz),t.Y36(s.iHG),t.Y36(t.sBO),t.Y36(s.DoR),t.Y36(l.qu),t.Y36(s.gqp),t.Y36(s.Z7U),t.Y36(s.n2A))},lt.\u0275cmp=t.Xpm({type:lt,selectors:[["vdr-collection-detail"]],viewQuery:function(n,e){if(1&n&&t.Gf(cn,5),2&n){let o;t.iGM(o=t.CRH())&&(e.contentsComponent=o.first)}},features:[t.qOj],decls:16,vars:19,consts:[[3,"entity"],[3,"disabled","availableLanguageCodes","currentLanguageCode","languageCodeChange"],["locationId","collection-detail"],["class","btn btn-primary",3,"disabled","click",4,"ngIf","ngIfElse"],["updateButton",""],["class","form",3,"formGroup",4,"ngIf"],[1,"btn","btn-primary",3,"disabled","click"],["class","btn btn-primary",3,"disabled","click",4,"vdrIfPermissions"],[1,"form",3,"formGroup"],[1,"clr-row"],[1,"clr-col"],["for","visibility",3,"label"],["type","checkbox","clrToggle","","formControlName","visible","id","visibility",3,"vdrDisabled"],[1,"visible-toggle"],[4,"ngIf","ngIfElse"],["private",""],["for","name",3,"label"],["id","name","type","text","formControlName","name",3,"readonly","input"],["for","slug",3,"label","errors"],["id","slug","type","text","formControlName","slug",3,"readonly"],["formControlName","description",3,"readonly","label"],["formGroupName","customFields",4,"ngIf"],["locationId","collection-detail",3,"entity$","detailForm"],[1,"clr-col-md-auto"],[3,"assets","featuredAsset","updatePermissions","change"],["for","inheritFilters",3,"label"],["type","checkbox","clrToggle","","formControlName","inheritFilters","id","inheritFilters",3,"vdrDisabled"],["noInherit",""],["formArrayName","filters"],[4,"ngFor","ngForOf","ngForTrackBy"],[4,"vdrIfPermissions"],[3,"collectionId","parentId","updatedFilters","previewUpdatedFilters"],["collectionContents",""],["formGroupName","customFields"],["entityName","Collection",3,"customFields","customFieldsFormGroup","readonly"],[3,"operation","operationDefinition","formControlName","readonly","remove"],["vdrDropdownTrigger","",1,"btn","btn-outline"],["shape","plus"],["vdrPosition","bottom-left"],["type","button","vdrDropdownItem","",3,"click",4,"ngFor","ngForOf"],["type","button","vdrDropdownItem","",3,"click"],[1,"contents-title"],["type","checkbox","clrCheckbox","",3,"ngModelOptions","disabled","ngModel","ngModelChange"]],template:function(n,e){if(1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left"),t._UZ(2,"vdr-entity-info",0),t.ALo(3,"async"),t.TgZ(4,"vdr-language-selector",1),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(5,"async"),t.ALo(6,"async"),t.ALo(7,"async"),t.qZA()(),t.TgZ(8,"vdr-ab-right"),t._UZ(9,"vdr-action-bar-items",2),t.YNc(10,sn,3,4,"button",3),t.ALo(11,"async"),t.YNc(12,dn,1,1,"ng-template",null,4,t.W1O),t.qZA()(),t.YNc(14,An,51,60,"form",5),t.ALo(15,"async")),2&n){const o=t.MAs(13);t.xp6(2),t.Q6J("entity",t.lcZ(3,7,e.entity$)),t.xp6(2),t.Q6J("disabled",t.lcZ(5,9,e.isNew$))("availableLanguageCodes",t.lcZ(6,11,e.availableLanguages$))("currentLanguageCode",t.lcZ(7,13,e.languageCode$)),t.xp6(6),t.Q6J("ngIf",t.lcZ(11,15,e.isNew$))("ngIfElse",o),t.xp6(4),t.Q6J("ngIf",t.lcZ(15,17,e.entity$))}},directives:[A.Kk,A.BN,kt.V,ot.S,A.mz,R.W,C.O5,J.H,l._Y,l.JL,l.sg,Dt.h,f.PEh,M.y,l.Wl,f.KKC,l.JJ,l.u,Et.x,f.MgK,l.Fj,pe.Y,l.x0,qt.y,Wt.C,Y,l.CE,C.sg,f.q0d,Xe.q,it.J,at.U,f.qvL,rt.N,ct.H,W,l.On],pipes:[C.Ov,F.X$,U.j],styles:[".visible-toggle[_ngcontent-%COMP%]{margin-top:-3px!important}clr-checkbox-wrapper[_ngcontent-%COMP%]{transition:opacity .3s}clr-checkbox-wrapper.disabled[_ngcontent-%COMP%]{opacity:.5}"],changeDetection:0});var Jt=u(9196);function ue(i,n,e=[]){var o,a;const r=[],c={},d=function Pn(i){const n=new Map;function e(o){n.set(o.id,o),o.children.forEach(e)}return i&&e(i),n}(n);for(const h of i)c[h.id]=Object.assign(Object.assign({},h),{children:[]});for(const h of i.map(m=>m.id))if(c.hasOwnProperty(h)){const m=c[h];m.expanded=null!==(a=null===(o=d.get(h))||void 0===o?void 0:o.expanded)&&void 0!==a?a:e.includes(h);const g=m.parent;if(!g)continue;c[g.id]?c[g.id]?c[g.id].children.push(m):c[g.id]={children:[m]}:r.push(m)}return{id:r.length?r[0].parent.id:void 0,children:r}}class G{constructor(){this.allMoveListItems=[],this._rearrange$=new jt.x,this._delete$=new jt.x,this.rearrange$=this._rearrange$.asObservable(),this.delete$=this._delete$.asObservable()}ngOnDestroy(){this._rearrange$.complete(),this._delete$.complete()}setCollectionTree(n){this.collectionTree=n}resetMoveList(){this.allMoveListItems=[]}getMoveListItems(n){return 0===this.allMoveListItems.length&&(this.allMoveListItems=this.calculateAllMoveListItems()),this.allMoveListItems.filter(e=>{var o;return e.id!==n.id&&!e.ancestorIdPath.has(n.id)&&e.id!==(null===(o=n.parent)||void 0===o?void 0:o.id)})}onDrop(n){const e=n.item.data,a=n.container.data.id;if(null==a)throw new Error("Could not determine the ID of the root Collection");this._rearrange$.next({collectionId:e.id,parentId:a,index:n.currentIndex})}onMove(n){this._rearrange$.next(n)}onDelete(n){this._delete$.next(n)}calculateAllMoveListItems(){const n=(e,o,a,r)=>{const c=o.concat(e.name);return r.push({path:c.slice(1).join(" / ")||"root",id:e.id,ancestorIdPath:a}),e.children.forEach(d=>n(d,c,new Set([...a,e.id]),r)),r};return n(this.collectionTree,[],new Set,[])}}G.\u0275fac=function(n){return new(n||G)},G.\u0275prov=t.Yz7({token:G,factory:G.\u0275fac});var dt=u(4447);function yn(i,n){1&i&&t._UZ(0,"clr-icon",31)}function Fn(i,n){1&i&&t._UZ(0,"clr-icon",32)}function On(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",28),t.NdJ("click",function(){t.CHM(e);const a=t.oxw().$implicit;return t.oxw().toggleExpanded(a)}),t.YNc(1,yn,1,0,"clr-icon",29),t.YNc(2,Fn,1,0,"clr-icon",30),t.qZA()}if(2&i){const e=t.oxw().$implicit,o=t.oxw();t.Q6J("disabled",o.expandAll),t.xp6(1),t.Q6J("ngIf",!e.expanded&&!o.expandAll),t.xp6(1),t.Q6J("ngIf",e.expanded||o.expandAll)}}function In(i,n){1&i&&t._UZ(0,"div",33)}function Ln(i,n){1&i&&(t.TgZ(0,"vdr-chip"),t._uU(1),t.ALo(2,"translate"),t.qZA()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.private")))}function Mn(i,n){1&i&&(t.TgZ(0,"div",34),t._UZ(1,"clr-icon",35),t.qZA())}const wn=function(i){return{parentId:i}},kn=function(i){return["./","create",i]};function Vn(i,n){if(1&i&&(t.TgZ(0,"a",36),t._UZ(1,"clr-icon",37),t._uU(2),t.ALo(3,"translate"),t.qZA()),2&i){const e=t.oxw().$implicit;t.Q6J("routerLink",t.VKq(6,kn,t.VKq(4,wn,e.id))),t.xp6(2),t.hij(" ",t.lcZ(3,2,"catalog.create-new-collection")," ")}}function Jn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",20),t.NdJ("click",function(){const r=t.CHM(e).$implicit,c=t.oxw().$implicit;return t.oxw().move(c,r.id)}),t.ALo(1,"async"),t.TgZ(2,"div",38)(3,"div",39),t._UZ(4,"clr-icon",40),t.qZA(),t.TgZ(5,"div",41),t._uU(6),t.qZA()()()}if(2&i){const e=n.$implicit,o=t.oxw(2);t.Q6J("disabled",!t.lcZ(1,2,o.hasUpdatePermission$)),t.xp6(6),t.hij(" ",e.path," ")}}function Un(i,n){if(1&i&&t._UZ(0,"vdr-collection-tree-node",42),2&i){const e=t.oxw().$implicit,o=t.oxw();t.Q6J("expandAll",o.expandAll)("collectionTree",e)("activeCollectionId",o.activeCollectionId)}}const Nn=function(i){return{contents:i}},Dn=function(i){return["./",i]},qn=function(i){return["/catalog/collections/",i]},Sn=function(){return["UpdateCatalog","UpdateCollection"]},$n=function(){return["CreateCatalog","CreateCollection"]};function Qn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",3)(1,"div",4)(2,"div",5),t.YNc(3,On,3,3,"button",6),t.YNc(4,In,1,0,"ng-template",null,7,t.W1O),t._uU(6),t.qZA(),t._UZ(7,"div",8),t.YNc(8,Ln,3,3,"vdr-chip",9),t.TgZ(9,"a",10),t._UZ(10,"clr-icon",11),t._uU(11),t.ALo(12,"translate"),t.qZA(),t.TgZ(13,"a",12),t._UZ(14,"clr-icon",13),t._uU(15),t.ALo(16,"translate"),t.qZA(),t.YNc(17,Mn,2,0,"div",14),t.TgZ(18,"vdr-dropdown")(19,"button",15),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw().getMoveListItems(r)}),t._UZ(20,"clr-icon",16),t.qZA(),t.TgZ(21,"vdr-dropdown-menu",17),t.YNc(22,Vn,4,8,"a",18),t._UZ(23,"div",19),t.TgZ(24,"button",20),t.NdJ("click",function(){const a=t.CHM(e),r=a.$implicit,c=a.index;return t.oxw().moveUp(r,c)}),t.ALo(25,"async"),t._UZ(26,"clr-icon",21),t._uU(27),t.ALo(28,"translate"),t.qZA(),t.TgZ(29,"button",20),t.NdJ("click",function(){const a=t.CHM(e),r=a.$implicit,c=a.index;return t.oxw().moveDown(r,c)}),t.ALo(30,"async"),t._UZ(31,"clr-icon",22),t._uU(32),t.ALo(33,"translate"),t.qZA(),t.TgZ(34,"h4",23),t._uU(35),t.ALo(36,"translate"),t.qZA(),t.YNc(37,Jn,7,4,"button",24),t._UZ(38,"div",19),t.TgZ(39,"button",25),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw().delete(r.id)}),t.ALo(40,"async"),t._UZ(41,"clr-icon",26),t._uU(42),t.ALo(43,"translate"),t.qZA()()()(),t.YNc(44,Un,1,3,"vdr-collection-tree-node",27),t.qZA()}if(2&i){const e=n.$implicit,o=n.index,a=t.MAs(5),r=t.oxw();t.ekj("private",e.isPrivate),t.Q6J("cdkDragData",e),t.xp6(1),t.ekj("active",e.id===r.activeCollectionId),t.Q6J("ngClass","depth-"+r.depth),t.xp6(2),t.Q6J("ngIf",null==e.children?null:e.children.length)("ngIfElse",a),t.xp6(3),t.hij(" ",e.name," "),t.xp6(2),t.Q6J("ngIf",e.isPrivate),t.xp6(1),t.Q6J("routerLink",t.VKq(45,Dn,t.VKq(43,Nn,e.id))),t.xp6(2),t.hij(" ",t.lcZ(12,25,"catalog.view-contents")," "),t.xp6(2),t.Q6J("routerLink",t.VKq(47,qn,e.id)),t.xp6(2),t.hij(" ",t.lcZ(16,27,"common.edit")," "),t.xp6(2),t.Q6J("vdrIfPermissions",t.DdM(49,Sn)),t.xp6(5),t.Q6J("vdrIfPermissions",t.DdM(50,$n)),t.xp6(2),t.Q6J("disabled",0===o||!t.lcZ(25,29,r.hasUpdatePermission$)),t.xp6(3),t.hij(" ",t.lcZ(28,31,"catalog.move-up")," "),t.xp6(2),t.Q6J("disabled",o===r.collectionTree.children.length-1||!t.lcZ(30,33,r.hasUpdatePermission$)),t.xp6(3),t.hij(" ",t.lcZ(33,35,"catalog.move-down")," "),t.xp6(3),t.Oqu(t.lcZ(36,37,"catalog.move-to")),t.xp6(2),t.Q6J("ngForOf",r.moveListItems),t.xp6(2),t.Q6J("disabled",!t.lcZ(40,39,r.hasDeletePermission$)),t.xp6(3),t.hij(" ",t.lcZ(43,41,"common.delete")," "),t.xp6(2),t.Q6J("ngIf",e.expanded||r.expandAll)}}class E{constructor(n,e,o,a,r){this.parent=n,this.dataService=e,this.collectionTreeService=o,this.router=a,this.route=r,this.depth=0,this.expandAll=!1,this.moveListItems=[],n&&(this.depth=n.depth+1)}ngOnInit(){this.parentName=this.collectionTree.name||"<root>";const n=this.dataService.client.userStatus().mapStream(e=>e.userStatus.permissions).pipe((0,Jt.d)(1));this.hasUpdatePermission$=n.pipe((0,v.U)(e=>e.includes(s.y3$.UpdateCatalog)||e.includes(s.y3$.UpdateCollection))),this.hasDeletePermission$=n.pipe((0,v.U)(e=>e.includes(s.y3$.DeleteCatalog)||e.includes(s.y3$.DeleteCollection)))}ngOnChanges(n){const e=n.expandAll;e&&!0===e.previousValue&&!1===e.currentValue&&this.collectionTree.children.forEach(o=>o.expanded=!1)}trackByFn(n,e){return e.id}toggleExpanded(n){var e,o;n.expanded=!n.expanded;let a=null!==(o=null===(e=this.route.snapshot.queryParamMap.get("expanded"))||void 0===e?void 0:e.split(","))&&void 0!==o?o:[];n.expanded?a.push(n.id):a=a.filter(r=>r!==n.id),this.router.navigate(["./"],{queryParams:{expanded:a.filter(r=>!!r).join(",")},queryParamsHandling:"merge",relativeTo:this.route})}getMoveListItems(n){this.moveListItems=this.collectionTreeService.getMoveListItems(n)}move(n,e){this.collectionTreeService.onMove({index:0,parentId:e,collectionId:n.id})}moveUp(n,e){!n.parent||this.collectionTreeService.onMove({index:e-1,parentId:n.parent.id,collectionId:n.id})}moveDown(n,e){!n.parent||this.collectionTreeService.onMove({index:e+1,parentId:n.parent.id,collectionId:n.id})}drop(n){(0,Q.bA)(this.collectionTree.children,n.previousIndex,n.currentIndex),this.collectionTreeService.onDrop(n)}delete(n){this.collectionTreeService.onDelete(n)}}function Yn(i,n){if(1&i&&t._UZ(0,"vdr-collection-tree-node",1),2&i){const e=t.oxw();t.Q6J("expandAll",e.expandAll)("collectionTree",e.collectionTree)("activeCollectionId",e.activeCollectionId)}}E.\u0275fac=function(n){return new(n||E)(t.Y36(E,12),t.Y36(s.DoR),t.Y36(G),t.Y36(T.F0),t.Y36(T.gz))},E.\u0275cmp=t.Xpm({type:E,selectors:[["vdr-collection-tree-node"]],inputs:{collectionTree:"collectionTree",activeCollectionId:"activeCollectionId",expandAll:"expandAll"},features:[t.TTD],decls:4,vars:6,consts:[["cdkDropList","",1,"tree-node",3,"cdkDropListData","cdkDropListDisabled","cdkDropListDropped"],["dropList",""],["class","collection","cdkDrag","",3,"private","cdkDragData",4,"ngFor","ngForOf","ngForTrackBy"],["cdkDrag","",1,"collection",3,"cdkDragData"],[1,"collection-detail",3,"ngClass"],[1,"name"],["class","icon-button folder-button",3,"disabled","click",4,"ngIf","ngIfElse"],["folderSpacer",""],[1,"flex-spacer"],[4,"ngIf"],["queryParamsHandling","preserve",1,"btn","btn-link","btn-sm",3,"routerLink"],["shape","view-list"],[1,"btn","btn-link","btn-sm",3,"routerLink"],["shape","edit"],["class","drag-handle","cdkDragHandle","",4,"vdrIfPermissions"],["vdrDropdownTrigger","",1,"icon-button",3,"click"],["shape","ellipsis-vertical"],["vdrPosition","bottom-right"],["class","dropdown-item",3,"routerLink",4,"vdrIfPermissions"],[1,"dropdown-divider"],["type","button","vdrDropdownItem","",3,"disabled","click"],["shape","caret up"],["shape","caret down"],[1,"dropdown-header"],["type","button","vdrDropdownItem","",3,"disabled","click",4,"ngFor","ngForOf"],["vdrDropdownItem","",1,"button",3,"disabled","click"],["shape","trash",1,"is-danger"],[3,"expandAll","collectionTree","activeCollectionId",4,"ngIf"],[1,"icon-button","folder-button",3,"disabled","click"],["shape","folder",4,"ngIf"],["shape","folder-open",4,"ngIf"],["shape","folder"],["shape","folder-open"],[1,"folder-button-spacer"],["cdkDragHandle","",1,"drag-handle"],["shape","drag-handle","size","24"],[1,"dropdown-item",3,"routerLink"],["shape","plus"],[1,"move-to-item"],[1,"move-icon"],["shape","child-arrow"],[1,"path"],[3,"expandAll","collectionTree","activeCollectionId"]],template:function(n,e){1&n&&(t.TgZ(0,"div",0,1),t.NdJ("cdkDropListDropped",function(a){return e.drop(a)}),t.ALo(2,"async"),t.YNc(3,Qn,45,51,"div",2),t.qZA()),2&n&&(t.Q6J("cdkDropListData",e.collectionTree)("cdkDropListDisabled",!t.lcZ(2,4,e.hasUpdatePermission$)),t.xp6(3),t.Q6J("ngForOf",e.collectionTree.children)("ngForTrackBy",e.trackByFn))},directives:[Q.Wj,C.sg,f.q0d,Q.Zt,C.mk,C.O5,f.qvL,dt.Y,T.yS,J.H,Q.Bh,it.J,at.U,rt.N,ct.H,E],pipes:[C.Ov,F.X$],styles:["[_nghost-%COMP%]{display:block}.collection[_ngcontent-%COMP%]{background-color:var(--color-component-bg-100);font-size:.65rem;transition:transform .25s cubic-bezier(0,0,.2,1);margin-bottom:2px;border-left:2px solid transparent;transition:border-left-color .2s}.collection.private[_ngcontent-%COMP%]{background-color:var(--color-component-bg-200)}.collection[_ngcontent-%COMP%] .collection-detail[_ngcontent-%COMP%]{padding:6px 12px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--color-component-border-100)}.collection[_ngcontent-%COMP%] .collection-detail.active[_ngcontent-%COMP%]{background-color:var(--clr-global-selection-color)}.collection[_ngcontent-%COMP%] .collection-detail.depth-1[_ngcontent-%COMP%]{padding-left:36px}.collection[_ngcontent-%COMP%] .collection-detail.depth-2[_ngcontent-%COMP%]{padding-left:60px}.collection[_ngcontent-%COMP%] .collection-detail.depth-3[_ngcontent-%COMP%]{padding-left:84px}.collection[_ngcontent-%COMP%] .collection-detail.depth-4[_ngcontent-%COMP%]{padding-left:108px}.collection[_ngcontent-%COMP%] .collection-detail[_ngcontent-%COMP%] .folder-button-spacer[_ngcontent-%COMP%]{display:inline-block;width:28px}.tree-node[_ngcontent-%COMP%]{display:block;background:var(--color-component-bg-100);overflow:hidden}.tree-node.cdk-drop-list-dragging[_ngcontent-%COMP%] > .collection[_ngcontent-%COMP%]{border-left-color:var(--color-primary-300)}.drag-placeholder[_ngcontent-%COMP%]{min-height:120px;background-color:var(--color-component-bg-300);transition:transform .25s cubic-bezier(0,0,.2,1)}.cdk-drag-preview[_ngcontent-%COMP%]{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-placeholder[_ngcontent-%COMP%]{opacity:0}.cdk-drag-animating[_ngcontent-%COMP%]{transition:transform .25s cubic-bezier(0,0,.2,1)}.example-list.cdk-drop-list-dragging[_ngcontent-%COMP%] .tree-node[_ngcontent-%COMP%]:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.move-to-item[_ngcontent-%COMP%]{display:flex;white-space:normal;align-items:baseline}.move-to-item[_ngcontent-%COMP%] .move-icon[_ngcontent-%COMP%]{flex:none;margin-right:3px}.move-to-item[_ngcontent-%COMP%] .path[_ngcontent-%COMP%]{line-height:18px}"],changeDetection:0});class pt{constructor(n){this.collectionTreeService=n,this.expandAll=!1,this.expandedIds=[],this.rearrange=new t.vpe,this.deleteCollection=new t.vpe}ngOnChanges(n){"collections"in n&&this.collections&&(this.collectionTree=ue(this.collections,this.collectionTree,this.expandedIds),this.collectionTreeService.setCollectionTree(this.collectionTree),this.collectionTreeService.resetMoveList())}ngOnInit(){this.collectionTreeService.rearrange$.subscribe(n=>this.rearrange.emit(n)),this.collectionTreeService.delete$.subscribe(n=>this.deleteCollection.emit(n))}}pt.\u0275fac=function(n){return new(n||pt)(t.Y36(G))},pt.\u0275cmp=t.Xpm({type:pt,selectors:[["vdr-collection-tree"]],inputs:{collections:"collections",activeCollectionId:"activeCollectionId",expandAll:"expandAll",expandedIds:"expandedIds"},outputs:{rearrange:"rearrange",deleteCollection:"deleteCollection"},features:[t._Bn([G]),t.TTD],decls:1,vars:1,consts:[["cdkDropListGroup","",3,"expandAll","collectionTree","activeCollectionId",4,"ngIf"],["cdkDropListGroup","",3,"expandAll","collectionTree","activeCollectionId"]],template:function(n,e){1&n&&t.YNc(0,Yn,1,3,"vdr-collection-tree-node",0),2&n&&t.Q6J("ngIf",e.collectionTree)},directives:[C.O5,E,Q.Fd],styles:[""],changeDetection:0});const Gn=function(){return["./create"]};function En(i,n){1&i&&(t.TgZ(0,"a",11),t._UZ(1,"clr-icon",12),t._uU(2),t.ALo(3,"translate"),t.qZA()),2&i&&(t.Q6J("routerLink",t.DdM(4,Gn)),t.xp6(2),t.hij(" ",t.lcZ(3,2,"catalog.create-new-collection")," "))}const jn=function(i){return{count:i}};function Hn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",13),t._uU(1),t.ALo(2,"async"),t.ALo(3,"translate"),t.qZA(),t.TgZ(4,"button",14),t.NdJ("click",function(){return t.CHM(e),t.oxw().closeContents()}),t._UZ(5,"clr-icon",15),t.qZA()}if(2&i){const e=n.$implicit,o=t.oxw();t.xp6(1),t.AsE(" ",t.lcZ(2,2,o.activeCollectionTitle$)," (",t.xi3(3,4,"common.results-count",t.VKq(7,jn,e)),") ")}}const Bn=function(){return["CreateCatalog","CreateCollection"]};class ut{constructor(n,e,o,a,r,c){this.dataService=n,this.notificationService=e,this.modalService=o,this.router=a,this.route=r,this.serverConfigService=c,this.filterTermControl=new l.NI(""),this.expandAll=!1,this.expandedIds=[],this.destroy$=new jt.x}ngOnInit(){var n,e;this.queryResult=this.dataService.collection.getCollections(1e3,0).refetchOnChannelChange(),this.items$=this.queryResult.mapStream(o=>o.collections.items).pipe((0,Jt.d)(1)),this.activeCollectionId$=this.route.paramMap.pipe((0,v.U)(o=>o.get("contents")),(0,st.x)()),this.expandedIds=null!==(e=null===(n=this.route.snapshot.queryParamMap.get("expanded"))||void 0===n?void 0:n.split(","))&&void 0!==e?e:[],this.expandAll="all"===this.route.snapshot.queryParamMap.get("expanded"),this.activeCollectionTitle$=(0,O.a)(this.activeCollectionId$,this.items$).pipe((0,v.U)(([o,a])=>{if(o){const r=a.find(c=>c.id===o);return r?r.name:""}return""})),this.availableLanguages$=this.serverConfigService.getAvailableLanguages(),this.contentLanguage$=this.dataService.client.uiState().mapStream(({uiState:o})=>o.contentLanguage).pipe((0,K.b)(()=>this.refresh())),this.filterTermControl.valueChanges.pipe((0,$.b)(250),(0,q.R)(this.destroy$)).subscribe(o=>{this.router.navigate(["./"],{queryParams:{q:o||void 0},queryParamsHandling:"merge",relativeTo:this.route})}),this.route.queryParamMap.pipe((0,v.U)(o=>o.get("q")),(0,st.x)(),(0,q.R)(this.destroy$)).subscribe(()=>this.refresh()),this.filterTermControl.patchValue(this.route.snapshot.queryParamMap.get("q"))}ngOnDestroy(){this.queryResult.completed$.next(),this.destroy$.next(void 0),this.destroy$.complete()}toggleExpandAll(){this.router.navigate(["./"],{queryParams:{expanded:this.expandAll?"all":void 0},queryParamsHandling:"merge",relativeTo:this.route})}onRearrange(n){this.dataService.collection.moveCollection([n]).subscribe({next:()=>{this.notificationService.success((0,_.J)("common.notify-saved-changes")),this.refresh()},error:e=>{this.notificationService.error((0,_.J)("common.notify-save-changes-error"))}})}deleteCollection(n){this.items$.pipe((0,k.q)(1),(0,v.U)(e=>-1<e.findIndex(o=>o.parent&&o.parent.id===n)),(0,y.w)(e=>this.modalService.dialog({title:(0,_.J)("catalog.confirm-delete-collection"),body:e?(0,_.J)("catalog.confirm-delete-collection-and-children-body"):void 0,buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("common.delete"),returnValue:!0}]})),(0,y.w)(e=>e?this.dataService.collection.deleteCollection(n):D.E)).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-delete-success"),{entity:"Collection"}),this.refresh()},e=>{this.notificationService.error((0,_.J)("common.notify-delete-error"),{entity:"Collection"})})}closeContents(){const n=Object.assign({},this.route.snapshot.params);delete n.contents,this.router.navigate(["./",n],{relativeTo:this.route,queryParamsHandling:"preserve"})}setLanguage(n){this.dataService.client.setContentLanguage(n).subscribe()}refresh(){const n=this.route.snapshot.queryParamMap.get("q");this.queryResult.ref.refetch({options:Object.assign({skip:0,take:1e3},n?{filter:{name:{contains:n}}}:{})})}}ut.\u0275fac=function(n){return new(n||ut)(t.Y36(s.DoR),t.Y36(s.gqp),t.Y36(s.Z7U),t.Y36(T.F0),t.Y36(T.gz),t.Y36(s.iHG))},ut.\u0275cmp=t.Xpm({type:ut,selectors:[["vdr-collection-list"]],decls:26,vars:34,consts:[[1,"flex","center","wrap"],[1,"mt2",3,"availableLanguageCodes","currentLanguageCode","languageCodeChange"],[1,"expand-all-toggle","ml3",3,"ngClass"],["type","checkbox","clrCheckbox","",3,"ngModel","ngModelChange","change"],["type","text","name","searchTerm",1,"clr-input","search-input","ml4",3,"formControl","placeholder"],["locationId","collection-list"],["class","btn btn-primary",3,"routerLink",4,"vdrIfPermissions"],[1,"collection-wrapper"],[3,"collections","activeCollectionId","expandAll","expandedIds","rearrange","deleteCollection"],[1,"collection-contents"],[3,"collectionId"],[1,"btn","btn-primary",3,"routerLink"],["shape","plus"],[1,"collection-title"],["type","button",1,"close-button",3,"click"],["shape","close"]],template:function(n,e){if(1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left")(2,"div",0)(3,"vdr-language-selector",1),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(4,"async"),t.ALo(5,"async"),t.qZA(),t.TgZ(6,"clr-checkbox-wrapper",2),t.ALo(7,"async"),t.TgZ(8,"input",3),t.NdJ("ngModelChange",function(a){return e.expandAll=a})("change",function(){return e.toggleExpandAll()}),t.qZA(),t.TgZ(9,"label"),t._uU(10),t.ALo(11,"translate"),t.qZA()(),t._UZ(12,"input",4),t.ALo(13,"translate"),t.qZA()(),t.TgZ(14,"vdr-ab-right"),t._UZ(15,"vdr-action-bar-items",5),t.YNc(16,En,4,5,"a",6),t.qZA()(),t.TgZ(17,"div",7)(18,"vdr-collection-tree",8),t.NdJ("rearrange",function(a){return e.onRearrange(a)})("deleteCollection",function(a){return e.deleteCollection(a)}),t.ALo(19,"async"),t.ALo(20,"async"),t.qZA(),t.TgZ(21,"div",9),t.ALo(22,"async"),t.TgZ(23,"vdr-collection-contents",10),t.ALo(24,"async"),t.YNc(25,Hn,6,9,"ng-template"),t.qZA()()()),2&n){let o;t.xp6(3),t.Q6J("availableLanguageCodes",t.lcZ(4,15,e.availableLanguages$))("currentLanguageCode",t.lcZ(5,17,e.contentLanguage$)),t.xp6(3),t.Q6J("ngClass",1===(null==(o=t.lcZ(7,19,e.availableLanguages$))?null:o.length)?"mt3":"mt1"),t.xp6(2),t.Q6J("ngModel",e.expandAll),t.xp6(2),t.Oqu(t.lcZ(11,21,"catalog.expand-all-collections")),t.xp6(2),t.Q6J("formControl",e.filterTermControl)("placeholder",t.lcZ(13,23,"catalog.filter-by-name")),t.xp6(4),t.Q6J("vdrIfPermissions",t.DdM(33,Bn)),t.xp6(2),t.Q6J("collections",t.lcZ(19,25,e.items$))("activeCollectionId",t.lcZ(20,27,e.activeCollectionId$))("expandAll",e.expandAll)("expandedIds",e.expandedIds),t.xp6(3),t.ekj("expanded",t.lcZ(22,29,e.activeCollectionId$)),t.xp6(2),t.Q6J("collectionId",t.lcZ(24,31,e.activeCollectionId$))}},directives:[A.Kk,A.BN,ot.S,f.PEh,C.mk,M.y,l.Wl,f.KKC,l.JJ,l.On,f.MgK,l.Fj,l.oH,A.mz,R.W,J.H,T.yS,f.qvL,pt,W],pipes:[C.Ov,F.X$],styles:["[_nghost-%COMP%]{height:100%;display:flex;flex-direction:column}.expand-all-toggle[_ngcontent-%COMP%]{display:block}.collection-wrapper[_ngcontent-%COMP%]{display:flex;height:calc(100% - 50px)}.collection-wrapper[_ngcontent-%COMP%] vdr-collection-tree[_ngcontent-%COMP%]{flex:1;height:100%;overflow:auto}.collection-wrapper[_ngcontent-%COMP%] .collection-contents[_ngcontent-%COMP%]{height:100%;width:0;opacity:0;visibility:hidden;overflow:auto;transition:width .3s,opacity .2s .3s,visibility 0s .3s}.collection-wrapper[_ngcontent-%COMP%] .collection-contents.expanded[_ngcontent-%COMP%]{width:30vw;visibility:visible;opacity:1;padding-left:12px}.collection-wrapper[_ngcontent-%COMP%] .collection-contents[_ngcontent-%COMP%] .close-button[_ngcontent-%COMP%]{margin:0;background:none;border:none;cursor:pointer}.paging-controls[_ngcontent-%COMP%]{padding-top:6px;border-top:1px solid var(--color-component-border-100);display:flex;justify-content:space-between}"],changeDetection:0});var w=u(234),S=u(1640),Rn=u(73);function zn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",6),t.NdJ("click",function(){return t.CHM(e),t.oxw().create()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw();t.Q6J("disabled",e.detailForm.invalid||e.detailForm.pristine),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.create")," ")}}function Kn(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",6),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).save()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw(2);t.Q6J("disabled",e.detailForm.invalid||e.detailForm.pristine),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.update")," ")}}function Wn(i,n){if(1&i&&t.YNc(0,Kn,3,4,"button",7),2&i){const e=t.oxw();t.Q6J("vdrIfPermissions",e.updatePermission)}}function Xn(i,n){1&i&&(t.ynx(0),t._uU(1),t.ALo(2,"translate"),t.BQk()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.public")))}function to(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.private"))}const eo=function(){return["facet","customFields"]};function no(i,n){if(1&i&&(t.TgZ(0,"section",22)(1,"label"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t._UZ(4,"vdr-tabbed-custom-fields",23),t.ALo(5,"hasPermission"),t.qZA()),2&i){const e=t.oxw(2);t.xp6(2),t.Oqu(t.lcZ(3,4,"common.custom-fields")),t.xp6(2),t.Q6J("customFields",e.customFields)("customFieldsFormGroup",e.detailForm.get(t.DdM(8,eo)))("readonly",!t.lcZ(5,6,e.updatePermission))}}function oo(i,n){1&i&&(t.ynx(0),t.TgZ(1,"th"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t.BQk()),2&i&&(t.xp6(2),t.Oqu(t.lcZ(3,1,"common.custom-fields")))}const io=function(i){return["values",i,"customFields"]};function ao(i,n){if(1&i&&(t.TgZ(0,"td",40),t._UZ(1,"vdr-tabbed-custom-fields",41),t.ALo(2,"hasPermission"),t.qZA()),2&i){const e=t.oxw().index,o=t.oxw(4);t.xp6(1),t.Q6J("customFields",o.customValueFields)("compact",!0)("customFieldsFormGroup",o.detailForm.get(t.VKq(6,io,e)))("readonly",!t.lcZ(2,4,o.updatePermission))}}function ro(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"tr",30)(1,"td",31),t._UZ(2,"vdr-entity-info",0),t.qZA(),t.TgZ(3,"td",31)(4,"input",32),t.NdJ("input",function(a){const c=t.CHM(e).index,d=t.oxw(3).ngIf;return t.oxw().updateValueCode(null==d.values[c]?null:d.values[c].code,a.target.value,c)}),t.ALo(5,"hasPermission"),t.qZA()(),t.TgZ(6,"td",31),t._UZ(7,"input",33),t.qZA(),t.YNc(8,ao,3,8,"td",34),t.TgZ(9,"td",31)(10,"vdr-dropdown")(11,"button",35),t._uU(12),t.ALo(13,"translate"),t._UZ(14,"clr-icon",36),t.qZA(),t.TgZ(15,"vdr-dropdown-menu",37)(16,"button",38),t.NdJ("click",function(){const r=t.CHM(e).index,c=t.oxw(3).ngIf;return t.oxw().deleteFacetValue(null==c.values[r]?null:c.values[r].id,r)}),t.ALo(17,"hasPermission"),t._UZ(18,"clr-icon",39),t._uU(19),t.ALo(20,"translate"),t.qZA()()()()()}if(2&i){const e=n.$implicit,o=n.index,a=t.oxw(4);t.Q6J("formGroupName",o),t.xp6(2),t.Q6J("entity",e),t.xp6(2),t.Q6J("readonly",!t.lcZ(5,7,a.updatePermission)),t.xp6(4),t.Q6J("ngIf",a.customValueFields.length),t.xp6(4),t.hij(" ",t.lcZ(13,9,"common.actions")," "),t.xp6(4),t.Q6J("disabled",!t.lcZ(17,11,a.updatePermission)),t.xp6(3),t.hij(" ",t.lcZ(20,13,"common.delete")," ")}}function co(i,n){if(1&i&&(t.TgZ(0,"table",27)(1,"thead")(2,"tr"),t._UZ(3,"th"),t.TgZ(4,"th"),t._uU(5),t.ALo(6,"translate"),t.qZA(),t.TgZ(7,"th"),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.YNc(10,oo,4,3,"ng-container",28),t._UZ(11,"th"),t.qZA()(),t.TgZ(12,"tbody"),t.YNc(13,ro,21,15,"tr",29),t.qZA()()),2&i){const e=t.oxw(3);t.xp6(5),t.Oqu(t.lcZ(6,4,"common.name")),t.xp6(3),t.Oqu(t.lcZ(9,6,"common.code")),t.xp6(2),t.Q6J("ngIf",e.customValueFields.length),t.xp6(3),t.Q6J("ngForOf",e.values)}}function so(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",42),t.NdJ("click",function(){return t.CHM(e),t.oxw(3).addFacetValue()}),t._UZ(1,"clr-icon",43),t._uU(2),t.ALo(3,"translate"),t.qZA()}2&i&&(t.xp6(2),t.hij(" ",t.lcZ(3,1,"catalog.add-facet-value")," "))}const lo=function(){return["CreateCatalog","CreateFacet"]};function po(i,n){if(1&i&&(t.TgZ(0,"section",24)(1,"label"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t.YNc(4,co,14,8,"table",25),t.TgZ(5,"div"),t.YNc(6,so,4,3,"button",26),t.qZA()()),2&i){const e=t.oxw(2);t.xp6(2),t.Oqu(t.lcZ(3,3,"catalog.facet-values")),t.xp6(2),t.Q6J("ngIf",0<e.getValuesFormArray().length),t.xp6(2),t.Q6J("vdrIfPermissions",t.DdM(5,lo))}}function uo(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"form",8)(1,"section",9)(2,"vdr-form-field",10),t.ALo(3,"translate"),t.TgZ(4,"clr-toggle-wrapper"),t._UZ(5,"input",11),t.ALo(6,"hasPermission"),t.TgZ(7,"label",12),t.YNc(8,Xn,3,3,"ng-container",13),t.YNc(9,to,2,3,"ng-template",null,14,t.W1O),t.qZA()()(),t.TgZ(11,"vdr-form-field",15),t.ALo(12,"translate"),t.TgZ(13,"input",16),t.NdJ("input",function(a){const c=t.CHM(e).ngIf;return t.oxw().updateCode(c.code,a.target.value)}),t.ALo(14,"hasPermission"),t.qZA()(),t.TgZ(15,"vdr-form-field",17),t.ALo(16,"translate"),t.ALo(17,"hasPermission"),t._UZ(18,"input",18),t.ALo(19,"hasPermission"),t.qZA(),t.YNc(20,no,6,9,"section",19),t._UZ(21,"vdr-custom-detail-component-host",20),t.qZA(),t.YNc(22,po,7,6,"section",21),t.ALo(23,"async"),t.qZA()}if(2&i){const e=t.MAs(10),o=t.oxw();t.Q6J("formGroup",o.detailForm),t.xp6(2),t.Q6J("label",t.lcZ(3,14,"catalog.visibility")),t.xp6(3),t.Q6J("vdrDisabled",!t.lcZ(6,16,o.updatePermission)),t.xp6(3),t.Q6J("ngIf",o.detailForm.value.facet.visible)("ngIfElse",e),t.xp6(3),t.Q6J("label",t.lcZ(12,18,"common.name")),t.xp6(2),t.Q6J("readonly",!t.lcZ(14,20,o.updatePermission)),t.xp6(2),t.Q6J("label",t.lcZ(16,22,"common.code"))("readOnlyToggle",t.lcZ(17,24,o.updatePermission)),t.xp6(3),t.Q6J("readonly",!t.lcZ(19,26,o.updatePermission)),t.xp6(2),t.Q6J("ngIf",o.customFields.length),t.xp6(1),t.Q6J("entity$",o.entity$)("detailForm",o.detailForm),t.xp6(1),t.Q6J("ngIf",!t.lcZ(23,28,o.isNew$))}}class mt extends s.UT_{constructor(n,e,o,a,r,c,d,p){super(e,n,o,r),this.changeDetector=a,this.dataService=r,this.formBuilder=c,this.notificationService=d,this.modalService=p,this.updatePermission=[s.y3$.UpdateCatalog,s.y3$.UpdateFacet],this.customFields=this.getCustomFieldConfig("Facet"),this.customValueFields=this.getCustomFieldConfig("FacetValue"),this.detailForm=this.formBuilder.group({facet:this.formBuilder.group({code:["",l.kI.required],name:"",visible:!0,customFields:this.formBuilder.group(this.customFields.reduce((h,m)=>Object.assign(Object.assign({},h),{[m.name]:""}),{}))}),values:this.formBuilder.array([])})}ngOnInit(){this.init()}ngOnDestroy(){this.destroy()}updateCode(n,e){if(!n){const o=this.detailForm.get(["facet","code"]);o&&o.pristine&&o.setValue((0,z.U)(e,"-"))}}updateValueCode(n,e,o){if(!n){const a=this.detailForm.get(["values",o,"code"]);a&&a.pristine&&a.setValue((0,z.U)(e,"-"))}}customValueFieldIsSet(n,e){return!!this.detailForm.get(["values",n,"customFields",e])}getValuesFormArray(){return this.detailForm.get("values")}addFacetValue(){const n=this.detailForm.get("values");if(n){const e=this.formBuilder.group({id:"",name:["",l.kI.required],code:""}),o={name:"",code:""};if(this.customValueFields.length){const a=new l.cw({});o.customFields={};for(const r of this.customValueFields){const c=r.name;a.addControl(c,new l.NI)}e.addControl("customFields",a)}n.insert(n.length,e),this.values.push(o)}}create(){const n=this.detailForm.get("facet");!n||!n.dirty||(0,O.a)(this.entity$,this.languageCode$).pipe((0,k.q)(1),(0,P.z)(([e,o])=>{const a=this.getUpdatedFacet(e,n,o);return this.dataService.facet.createFacet(a)}),(0,y.w)(e=>this.dataService.facet.getAllFacets().single$.pipe((0,Rn.h)(e)))).subscribe(e=>{this.notificationService.success((0,_.J)("common.notify-create-success"),{entity:"Facet"}),this.detailForm.markAsPristine(),this.changeDetector.markForCheck(),this.router.navigate(["../",e.createFacet.id],{relativeTo:this.route})},e=>{this.notificationService.error((0,_.J)("common.notify-create-error"),{entity:"Facet"})})}save(){(0,O.a)(this.entity$,this.languageCode$).pipe((0,k.q)(1),(0,P.z)(([n,e])=>{const o=this.detailForm.get("facet"),a=[];if(o&&o.dirty){const c=this.getUpdatedFacet(n,o,e);c&&a.push(this.dataService.facet.updateFacet(c))}const r=this.detailForm.get("values");if(r&&r.dirty){const c=this.getCreatedFacetValues(n,r,e);c.length&&a.push(this.dataService.facet.createFacetValues(c).pipe((0,y.w)(()=>this.dataService.facet.getFacet(this.id).single$)));const d=this.getUpdatedFacetValues(n,r,e);d.length&&a.push(this.dataService.facet.updateFacetValues(d))}return(0,S.D)(a)}),(0,y.w)(()=>this.dataService.facet.getAllFacets().single$)).subscribe(()=>{this.detailForm.markAsPristine(),this.changeDetector.markForCheck(),this.notificationService.success((0,_.J)("common.notify-update-success"),{entity:"Facet"})},n=>{this.notificationService.error((0,_.J)("common.notify-update-error"),{entity:"Facet"})})}deleteFacetValue(n,e){if(!n){const o=this.detailForm.get("values");return o&&o.removeAt(e),void this.values.splice(e,1)}this.showModalAndDelete(n).pipe((0,y.w)(o=>o.result===s.PcR.DELETED?[!0]:this.showModalAndDelete(n,o.message||"").pipe((0,v.U)(a=>a.result===s.PcR.DELETED))),(0,y.w)(o=>o?this.dataService.facet.getFacet(this.id).single$:[])).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-delete-success"),{entity:"FacetValue"})},o=>{this.notificationService.error((0,_.J)("common.notify-delete-error"),{entity:"FacetValue"})})}showModalAndDelete(n,e){return this.modalService.dialog({title:(0,_.J)("catalog.confirm-delete-facet-value"),body:e,buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("common.delete"),returnValue:!0}]}).pipe((0,y.w)(o=>o?this.dataService.facet.deleteFacetValues([n],!!e):D.E),(0,v.U)(o=>o.deleteFacetValues[0]))}setFormValues(n,e){var o;const a=(0,s.ZIM)(n,e);if(this.detailForm.patchValue({facet:{code:n.code,visible:!n.isPrivate,name:null!==(o=null==a?void 0:a.name)&&void 0!==o?o:""}}),this.customFields.length){this.detailForm.get(["facet","customFields"]);this.setCustomFieldFormValues(this.customFields,this.detailForm.get(["facet","customFields"]),n,a)}const r=this.detailForm.get("values");this.values=[...n.values],n.values.forEach((c,d)=>{var p,h,m,g,x;const b=(0,s.ZIM)(c,e),Z={id:c.id,code:c.code,name:b?b.name:""},I=r.at(d);if(I?(null===(p=I.get("id"))||void 0===p||p.setValue(Z.id),null===(h=I.get("code"))||void 0===h||h.setValue(Z.code),null===(m=I.get("name"))||void 0===m||m.setValue(Z.name)):r.insert(d,this.formBuilder.group(Z)),this.customValueFields.length){let V=this.detailForm.get(["values",d,"customFields"]);if(V||(V=new l.cw({}),this.detailForm.get(["values",d]).addControl("customFields",V)),V)for(const Mt of this.customValueFields){const Nt=Mt.name,wt="localeString"===Mt.type?null===(x=null===(g=b)||void 0===g?void 0:g.customFields)||void 0===x?void 0:x[Nt]:c.customFields[Nt],Qt=V.get(Nt);Qt?Qt.setValue(wt):V.addControl(Nt,new l.NI(wt))}}})}getUpdatedFacet(n,e,o){const a=(0,s.iSy)({translatable:n,updatedFields:e.value,customFieldConfig:this.customFields,languageCode:o,defaultTranslation:{languageCode:o,name:n.name||""}});return a.isPrivate=!e.value.visible,a}getCreatedFacetValues(n,e,o){return e.controls.filter(a=>!a.value.id).map(a=>a.value).map(a=>(0,s.iSy)({translatable:Object.assign(Object.assign({},a),{translations:[]}),updatedFields:a,customFieldConfig:this.customValueFields,languageCode:o,defaultTranslation:{languageCode:o,name:""}})).map(a=>Object.assign({facetId:n.id},a))}getUpdatedFacetValues(n,e,o){const a=n.values.filter((c,d)=>{const p=e.get(d.toString());return p&&p.dirty&&p.value.id}),r=e.controls.filter(c=>c.dirty&&c.value.id).map(c=>c.value);if(a.length!==r.length)throw new Error((0,_.J)("error.facet-value-form-values-do-not-match"));return a.map((c,d)=>(0,s.iSy)({translatable:c,updatedFields:r[d],customFieldConfig:this.customValueFields,languageCode:o,defaultTranslation:{languageCode:o,name:""}})).filter(w.notNullOrUndefined)}}mt.\u0275fac=function(n){return new(n||mt)(t.Y36(T.F0),t.Y36(T.gz),t.Y36(s.iHG),t.Y36(t.sBO),t.Y36(s.DoR),t.Y36(l.qu),t.Y36(s.gqp),t.Y36(s.Z7U))},mt.\u0275cmp=t.Xpm({type:mt,selectors:[["vdr-facet-detail"]],features:[t.qOj],decls:16,vars:19,consts:[[3,"entity"],[3,"disabled","availableLanguageCodes","currentLanguageCode","languageCodeChange"],["locationId","facet-detail"],["class","btn btn-primary",3,"disabled","click",4,"ngIf","ngIfElse"],["updateButton",""],["class","form",3,"formGroup",4,"ngIf"],[1,"btn","btn-primary",3,"disabled","click"],["class","btn btn-primary",3,"disabled","click",4,"vdrIfPermissions"],[1,"form",3,"formGroup"],["formGroupName","facet",1,"form-block"],["for","visibility",3,"label"],["type","checkbox","clrToggle","","formControlName","visible","id","visibility",3,"vdrDisabled"],[1,"visible-toggle"],[4,"ngIf","ngIfElse"],["private",""],["for","name",3,"label"],["id","name","type","text","formControlName","name",3,"readonly","input"],["for","code",3,"label","readOnlyToggle"],["id","code","type","text","formControlName","code",3,"readonly"],["formGroupName","customFields",4,"ngIf"],["locationId","facet-detail",3,"entity$","detailForm"],["class","form-block",4,"ngIf"],["formGroupName","customFields"],["entityName","Facet",3,"customFields","customFieldsFormGroup","readonly"],[1,"form-block"],["class","facet-values-list table","formArrayName","values",4,"ngIf"],["type","button","class","btn btn-secondary",3,"click",4,"vdrIfPermissions"],["formArrayName","values",1,"facet-values-list","table"],[4,"ngIf"],["class","facet-value",3,"formGroupName",4,"ngFor","ngForOf"],[1,"facet-value",3,"formGroupName"],[1,"align-middle"],["type","text","formControlName","name",3,"readonly","input"],["type","text","formControlName","code","readonly",""],["class","",4,"ngIf"],["type","button","vdrDropdownTrigger","",1,"btn","btn-link","btn-sm"],["shape","caret down"],["vdrPosition","bottom-right"],["type","button","vdrDropdownItem","",1,"delete-button",3,"disabled","click"],["shape","trash",1,"is-danger"],[1,""],["entityName","FacetValue",3,"customFields","compact","customFieldsFormGroup","readonly"],["type","button",1,"btn","btn-secondary",3,"click"],["shape","add"]],template:function(n,e){if(1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left"),t._UZ(2,"vdr-entity-info",0),t.ALo(3,"async"),t.TgZ(4,"vdr-language-selector",1),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(5,"async"),t.ALo(6,"async"),t.ALo(7,"async"),t.qZA()(),t.TgZ(8,"vdr-ab-right"),t._UZ(9,"vdr-action-bar-items",2),t.YNc(10,zn,3,4,"button",3),t.ALo(11,"async"),t.YNc(12,Wn,1,1,"ng-template",null,4,t.W1O),t.qZA()(),t.YNc(14,uo,24,30,"form",5),t.ALo(15,"async")),2&n){const o=t.MAs(13);t.xp6(2),t.Q6J("entity",t.lcZ(3,7,e.entity$)),t.xp6(2),t.Q6J("disabled",t.lcZ(5,9,e.isNew$))("availableLanguageCodes",t.lcZ(6,11,e.availableLanguages$))("currentLanguageCode",t.lcZ(7,13,e.languageCode$)),t.xp6(6),t.Q6J("ngIf",t.lcZ(11,15,e.isNew$))("ngIfElse",o),t.xp6(4),t.Q6J("ngIf",t.lcZ(15,17,e.entity$))}},directives:[A.Kk,A.BN,kt.V,ot.S,A.mz,R.W,C.O5,J.H,l._Y,l.JL,l.sg,l.x0,Dt.h,f.PEh,M.y,l.Wl,f.KKC,l.JJ,l.u,Et.x,f.MgK,l.Fj,qt.y,Wt.C,l.CE,C.sg,it.J,at.U,f.qvL,rt.N,ct.H],pipes:[C.Ov,F.X$,U.j],styles:[".visible-toggle[_ngcontent-%COMP%]{margin-top:-3px!important}"],changeDetection:0});var mo=u(8165),_o=u(901),Ht=u(6074);const go=function(){return["./create"]};function ho(i,n){1&i&&(t.TgZ(0,"a",7),t._UZ(1,"clr-icon",8),t._uU(2),t.ALo(3,"translate"),t.qZA()),2&i&&(t.Q6J("routerLink",t.DdM(4,go)),t.xp6(2),t.hij(" ",t.lcZ(3,2,"catalog.create-new-facet")," "))}function fo(i,n){if(1&i&&t._UZ(0,"vdr-facet-value-chip",21),2&i){const e=n.$implicit;t.Q6J("facetValue",e)("removable",!1)("displayFacetName",!1)}}function vo(i,n){if(1&i&&(t.ynx(0),t._UZ(1,"clr-icon",8),t._uU(2),t.BQk()),2&i){const e=t.oxw(2).item,o=t.oxw();t.xp6(2),t.hij(" ",e.values.length-o.initialLimit," ")}}function Co(i,n){1&i&&t._UZ(0,"clr-icon",24)}function xo(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",22),t.NdJ("click",function(){t.CHM(e);const a=t.oxw().item;return t.oxw().toggleDisplayLimit(a)}),t.YNc(1,vo,3,1,"ng-container",12),t.YNc(2,Co,1,0,"ng-template",null,23,t.W1O),t.qZA()}if(2&i){const e=t.MAs(3),o=t.oxw().item,a=t.oxw();t.xp6(1),t.Q6J("ngIf",(a.displayLimit[o.id]||0)<o.values.length)("ngIfElse",e)}}function bo(i,n){1&i&&(t.ynx(0),t._uU(1),t.ALo(2,"translate"),t.BQk()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.public")))}function Zo(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.private"))}const To=function(i){return["./",i]},Ao=function(){return["DeleteCatalog","DeleteFacet"]};function Po(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"td",9),t._uU(1),t.qZA(),t.TgZ(2,"td",9),t._uU(3),t.qZA(),t.TgZ(4,"td",9),t.YNc(5,fo,1,3,"vdr-facet-value-chip",10),t.ALo(6,"slice"),t.YNc(7,xo,4,2,"button",11),t.qZA(),t.TgZ(8,"td",9)(9,"vdr-chip"),t.YNc(10,bo,3,3,"ng-container",12),t.YNc(11,Zo,2,3,"ng-template",null,13,t.W1O),t.qZA()(),t.TgZ(13,"td",14),t._UZ(14,"vdr-table-row-action",15),t.ALo(15,"translate"),t.qZA(),t.TgZ(16,"td",14)(17,"vdr-dropdown")(18,"button",16),t._uU(19),t.ALo(20,"translate"),t._UZ(21,"clr-icon",17),t.qZA(),t.TgZ(22,"vdr-dropdown-menu",18)(23,"button",19),t.NdJ("click",function(){const r=t.CHM(e).item;return t.oxw().deleteFacet(r.id)}),t.ALo(24,"hasPermission"),t._UZ(25,"clr-icon",20),t._uU(26),t.ALo(27,"translate"),t.qZA()()()()}if(2&i){const e=n.item,o=t.MAs(12),a=t.oxw();t.ekj("private",e.isPrivate),t.xp6(1),t.Oqu(e.code),t.xp6(1),t.ekj("private",e.isPrivate),t.xp6(1),t.Oqu(e.name),t.xp6(1),t.ekj("private",e.isPrivate),t.xp6(1),t.Q6J("ngForOf",t.Dn7(6,23,e.values,0,a.displayLimit[e.id]||3)),t.xp6(2),t.Q6J("ngIf",e.values.length>a.initialLimit),t.xp6(1),t.ekj("private",e.isPrivate),t.xp6(2),t.Q6J("ngIf",!e.isPrivate)("ngIfElse",o),t.xp6(3),t.ekj("private",e.isPrivate),t.xp6(1),t.Q6J("label",t.lcZ(15,27,"common.edit"))("linkTo",t.VKq(35,To,e.id)),t.xp6(2),t.ekj("private",e.isPrivate),t.xp6(3),t.hij(" ",t.lcZ(20,29,"common.actions")," "),t.xp6(4),t.Q6J("disabled",!t.lcZ(24,31,t.DdM(37,Ao))),t.xp6(3),t.hij(" ",t.lcZ(27,33,"common.delete")," ")}}const yo=function(){return["CreateCatalog","CreateFacet"]};class _t extends s.t7C{constructor(n,e,o,a,r,c){super(r,c),this.dataService=n,this.modalService=e,this.notificationService=o,this.serverConfigService=a,this.filterTermControl=new l.NI(""),this.initialLimit=3,this.displayLimit={},super.setQueryFn((...d)=>this.dataService.facet.getFacets(...d).refetchOnChannelChange(),d=>d.facets,(d,p)=>({options:{skip:d,take:p,filter:{name:{contains:this.filterTermControl.value}},sort:{createdAt:mo.As.DESC}}}))}ngOnInit(){super.ngOnInit(),this.availableLanguages$=this.serverConfigService.getAvailableLanguages(),this.contentLanguage$=this.dataService.client.uiState().mapStream(({uiState:n})=>n.contentLanguage).pipe((0,K.b)(()=>this.refresh())),this.filterTermControl.valueChanges.pipe((0,Gt.h)(n=>2<=n.length||0===n.length),(0,$.b)(250),(0,q.R)(this.destroy$)).subscribe(()=>this.refresh())}toggleDisplayLimit(n){this.displayLimit[n.id]===n.values.length?this.displayLimit[n.id]=this.initialLimit:this.displayLimit[n.id]=n.values.length}deleteFacet(n){this.showModalAndDelete(n).pipe((0,y.w)(e=>e.result===s.PcR.DELETED?[!0]:this.showModalAndDelete(n,e.message||"").pipe((0,v.U)(o=>o.result===s.PcR.DELETED))),(0,y.w)(()=>this.dataService.facet.getAllFacets().single$)).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-delete-success"),{entity:"FacetValue"}),this.refresh()},e=>{this.notificationService.error((0,_.J)("common.notify-delete-error"),{entity:"FacetValue"})})}setLanguage(n){this.dataService.client.setContentLanguage(n).subscribe()}showModalAndDelete(n,e){return this.modalService.dialog({title:(0,_.J)("catalog.confirm-delete-facet"),body:e,buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("common.delete"),returnValue:!0}]}).pipe((0,y.w)(o=>o?this.dataService.facet.deleteFacet(n,!!e):D.E),(0,v.U)(o=>o.deleteFacet))}}_t.\u0275fac=function(n){return new(n||_t)(t.Y36(s.DoR),t.Y36(s.Z7U),t.Y36(s.gqp),t.Y36(s.iHG),t.Y36(T.F0),t.Y36(T.gz))},_t.\u0275cmp=t.Xpm({type:_t,selectors:[["vdr-facet-list"]],features:[t.qOj],decls:31,vars:37,consts:[[1,"flex","center","wrap"],[3,"availableLanguageCodes","currentLanguageCode","languageCodeChange"],["type","text","name","searchTerm",1,"clr-input","search-input","ml4",3,"formControl","placeholder"],["locationId","facet-list"],["class","btn btn-primary",3,"routerLink",4,"vdrIfPermissions"],[3,"items","itemsPerPage","totalItems","currentPage","pageChange","itemsPerPageChange"],[3,"expand"],[1,"btn","btn-primary",3,"routerLink"],["shape","plus"],[1,"left","align-middle"],[3,"facetValue","removable","displayFacetName",4,"ngFor","ngForOf"],["class","btn btn-sm btn-secondary btn-icon",3,"click",4,"ngIf"],[4,"ngIf","ngIfElse"],["private",""],[1,"right","align-middle"],["iconShape","edit",3,"label","linkTo"],["type","button","vdrDropdownTrigger","",1,"btn","btn-link","btn-sm"],["shape","caret down"],["vdrPosition","bottom-right"],["type","button","vdrDropdownItem","",1,"delete-button",3,"disabled","click"],["shape","trash",1,"is-danger"],[3,"facetValue","removable","displayFacetName"],[1,"btn","btn-sm","btn-secondary","btn-icon",3,"click"],["collapse",""],["shape","minus"]],template:function(n,e){1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left")(2,"div",0)(3,"vdr-language-selector",1),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(4,"async"),t.ALo(5,"async"),t.qZA(),t._UZ(6,"input",2),t.ALo(7,"translate"),t.qZA()(),t.TgZ(8,"vdr-ab-right"),t._UZ(9,"vdr-action-bar-items",3),t.YNc(10,ho,4,5,"a",4),t.qZA()(),t.TgZ(11,"vdr-data-table",5),t.NdJ("pageChange",function(a){return e.setPageNumber(a)})("itemsPerPageChange",function(a){return e.setItemsPerPage(a)}),t.ALo(12,"async"),t.ALo(13,"async"),t.ALo(14,"async"),t.ALo(15,"async"),t.TgZ(16,"vdr-dt-column"),t._uU(17),t.ALo(18,"translate"),t.qZA(),t.TgZ(19,"vdr-dt-column"),t._uU(20),t.ALo(21,"translate"),t.qZA(),t.TgZ(22,"vdr-dt-column",6),t._uU(23),t.ALo(24,"translate"),t.qZA(),t.TgZ(25,"vdr-dt-column"),t._uU(26),t.ALo(27,"translate"),t.qZA(),t._UZ(28,"vdr-dt-column")(29,"vdr-dt-column"),t.YNc(30,Po,28,38,"ng-template"),t.qZA()),2&n&&(t.xp6(3),t.Q6J("availableLanguageCodes",t.lcZ(4,14,e.availableLanguages$))("currentLanguageCode",t.lcZ(5,16,e.contentLanguage$)),t.xp6(3),t.Q6J("formControl",e.filterTermControl)("placeholder",t.lcZ(7,18,"catalog.filter-by-name")),t.xp6(4),t.Q6J("vdrIfPermissions",t.DdM(36,yo)),t.xp6(1),t.Q6J("items",t.lcZ(12,20,e.items$))("itemsPerPage",t.lcZ(13,22,e.itemsPerPage$))("totalItems",t.lcZ(14,24,e.totalItems$))("currentPage",t.lcZ(15,26,e.currentPage$)),t.xp6(6),t.Oqu(t.lcZ(18,28,"common.code")),t.xp6(3),t.Oqu(t.lcZ(21,30,"common.name")),t.xp6(2),t.Q6J("expand",!0),t.xp6(1),t.Oqu(t.lcZ(24,32,"catalog.values")),t.xp6(3),t.Oqu(t.lcZ(27,34,"catalog.visibility")))},directives:[A.Kk,A.BN,ot.S,M.y,l.Fj,l.JJ,l.oH,A.mz,R.W,J.H,T.yS,f.qvL,te.Q,_o.E,C.sg,Ht.q,C.O5,dt.Y,ee.v,it.J,at.U,rt.N,ct.H],pipes:[C.Ov,F.X$,C.OU,U.j],styles:["td.private[_ngcontent-%COMP%]{background-color:var(--color-component-bg-200)}"]});var me=u(5454),_e=u(6646),Fo=u(1944),ge=u(3945),Oo=u(4987),Io=u(9635);var Mo=u(7260),he=u(538),Bt=u(309),wo=u(7206),Rt=u(8318);function ko(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.add-facets"))}function Vo(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",3),t.NdJ("click",function(){return t.CHM(e),t.oxw().cancel()}),t._uU(1),t.ALo(2,"translate"),t.qZA(),t.TgZ(3,"button",4),t.NdJ("click",function(){return t.CHM(e),t.oxw().selectValues()}),t._uU(4),t.ALo(5,"translate"),t.qZA()}if(2&i){const e=t.oxw();t.xp6(1),t.Oqu(t.lcZ(2,3,"common.cancel")),t.xp6(2),t.Q6J("disabled",0===e.selectedValues.length),t.xp6(1),t.hij(" ",t.lcZ(5,5,"catalog.add-facets")," ")}}class gt{constructor(n){this.changeDetector=n,this.selectedValues=[]}ngAfterViewInit(){setTimeout(()=>this.selector.focus(),0)}selectValues(){this.resolveWith(this.selectedValues)}cancel(){this.resolveWith()}}gt.\u0275fac=function(n){return new(n||gt)(t.Y36(t.sBO))},gt.\u0275cmp=t.Xpm({type:gt,selectors:[["vdr-apply-facet-dialog"]],viewQuery:function(n,e){if(1&n&&t.Gf(s.$MF,5),2&n){let o;t.iGM(o=t.CRH())&&(e.selector=o.first)}},decls:3,vars:1,consts:[["vdrDialogTitle",""],[3,"facets","selectedValuesChange"],["vdrDialogButtons",""],["type","button",1,"btn",3,"click"],["type","submit",1,"btn","btn-primary",3,"disabled","click"]],template:function(n,e){1&n&&(t.YNc(0,ko,2,3,"ng-template",0),t.TgZ(1,"vdr-facet-value-selector",1),t.NdJ("selectedValuesChange",function(a){return e.selectedValues=a}),t.qZA(),t.YNc(2,Vo,6,7,"ng-template",2)),2&n&&(t.xp6(1),t.Q6J("facets",e.facets))},directives:[Bt.q,wo.$,Rt.n],pipes:[F.X$],styles:[""],changeDetection:0});var Jo=u(4929),Uo=u(7400),No=u(5646),ne=u(8766),oe=u(4187);function Do(i,n){1&i&&(t.ynx(0),t._uU(1),t.ALo(2,"translate"),t.BQk()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.assign-variants-to-channel")))}function qo(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.assign-products-to-channel"))}function So(i,n){if(1&i&&(t.YNc(0,Do,3,3,"ng-container",12),t.YNc(1,qo,2,3,"ng-template",null,13,t.W1O)),2&i){const e=t.MAs(2),o=t.oxw();t.Q6J("ngIf",o.isProductVariantMode)("ngIfElse",e)}}const fe=function(i){return{channel:i}};function $o(i,n){if(1&i&&(t._uU(0),t.ALo(1,"translate")),2&i){const e=t.oxw();t.hij(" ",t.xi3(1,1,"catalog.price-in-channel",t.VKq(4,fe,null==e.selectedChannel?null:e.selectedChannel.code))," ")}}function Qo(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.hij(" ",t.lcZ(1,1,"catalog.no-channel-selected")," ")}function Yo(i,n){if(1&i&&(t._uU(0),t.ALo(1,"localeCurrency")),2&i){const e=t.oxw().$implicit,o=t.oxw();t.hij(" ",t.xi3(1,1,e.pricePreview,null==o.selectedChannel?null:o.selectedChannel.currencyCode)," ")}}function Go(i,n){1&i&&t._uU(0," - ")}function Eo(i,n){if(1&i&&(t.TgZ(0,"tr")(1,"td"),t._uU(2),t.qZA(),t.TgZ(3,"td"),t._uU(4),t.ALo(5,"localeCurrency"),t.qZA(),t.TgZ(6,"td"),t.YNc(7,Yo,2,4,"ng-template",8),t.YNc(8,Go,1,0,"ng-template",null,14,t.W1O),t.qZA()()),2&i){const e=n.$implicit,o=t.MAs(9),a=t.oxw();t.xp6(2),t.Oqu(e.name),t.xp6(2),t.Oqu(t.xi3(5,4,e.price,null==a.currentChannel?null:a.currentChannel.currencyCode)),t.xp6(3),t.Q6J("ngIf",a.selectedChannel)("ngIfElse",o)}}const jo=function(i){return{channelCode:i}};function Ho(i,n){if(1&i&&(t._uU(0),t.ALo(1,"translate")),2&i){const e=t.oxw(2);t.hij(" ",t.xi3(1,1,"catalog.assign-to-named-channel",t.VKq(4,jo,null==e.selectedChannel?null:e.selectedChannel.code))," ")}}function Bo(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.hij(" ",t.lcZ(1,1,"catalog.no-channel-selected")," ")}function Ro(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",15),t.NdJ("click",function(){return t.CHM(e),t.oxw().cancel()}),t._uU(1),t.ALo(2,"translate"),t.qZA(),t.TgZ(3,"button",16),t.NdJ("click",function(){return t.CHM(e),t.oxw().assign()}),t.YNc(4,Ho,2,6,"ng-template",8),t.YNc(5,Bo,2,3,"ng-template",null,9,t.W1O),t.qZA()}if(2&i){const e=t.MAs(6),o=t.oxw();t.xp6(1),t.Oqu(t.lcZ(2,4,"common.cancel")),t.xp6(2),t.Q6J("disabled",!o.selectedChannel),t.xp6(1),t.Q6J("ngIf",o.selectedChannel)("ngIfElse",e)}}class X{constructor(n,e){this.dataService=n,this.notificationService=e,this.priceFactorControl=new l.NI(1),this.selectedChannelIdControl=new l.NI}get isProductVariantMode(){return null!=this.productVariantIds}ngOnInit(){const n=this.dataService.client.userStatus().mapSingle(({userStatus:o})=>o.activeChannelId),e=this.dataService.settings.getChannels().mapSingle(o=>o.channels);(0,O.a)(n,e).subscribe(([o,a])=>{this.currentChannel=a.find(r=>r.id===o),this.availableChannels=a}),this.selectedChannelIdControl.valueChanges.subscribe(o=>{this.selectChannel(o)}),this.variantsPreview$=(0,O.a)((0,Uo.D)(this.getTopVariants(10)),this.priceFactorControl.valueChanges.pipe((0,Vt.O)(1))).pipe((0,v.U)(([o,a])=>o.map(r=>({id:r.id,name:r.name,price:r.price,pricePreview:r.price*+a}))))}selectChannel(n){this.selectedChannel=this.availableChannels.find(e=>e.id===n[0])}assign(){const n=this.selectedChannel;n&&(this.isProductVariantMode?this.productVariantIds&&this.dataService.product.assignVariantsToChannel({channelId:n.id,productVariantIds:this.productVariantIds,priceFactor:+this.priceFactorControl.value}).subscribe(()=>{this.notificationService.success((0,_.J)("catalog.assign-variant-to-channel-success"),{channel:n.code}),this.resolveWith(!0)}):this.dataService.product.assignProductsToChannel({channelId:n.id,productIds:this.productIds,priceFactor:+this.priceFactorControl.value}).subscribe(()=>{this.notificationService.success((0,_.J)("catalog.assign-product-to-channel-success"),{channel:n.code}),this.resolveWith(!0)}))}cancel(){this.resolveWith()}getTopVariants(n){return(0,Jo.mG)(this,void 0,void 0,function*(){const e=[];for(let o=0;o<this.productIds.length&&e.length<n;o++){const a=yield this.dataService.product.getProduct(this.productIds[o],{take:this.isProductVariantMode?void 0:n}).mapSingle(({product:r})=>(r?r.variantList.items:[]).filter(d=>{var p;return!this.isProductVariantMode||(null===(p=this.productVariantIds)||void 0===p?void 0:p.includes(d.id))})).toPromise();e.push(...a||[])}return e.slice(0,n)})}}X.\u0275fac=function(n){return new(n||X)(t.Y36(s.DoR),t.Y36(s.gqp))},X.\u0275cmp=t.Xpm({type:X,selectors:[["vdr-assign-products-to-channel-dialog"]],decls:36,vars:32,consts:[["vdrDialogTitle",""],[1,"flex"],["clrInput","",3,"multiple","includeDefaultChannel","disableChannelIds","formControl"],[1,"flex-spacer"],["clrInput","","type","number","min","0","max","99999",3,"formControl"],[1,"channel-price-preview"],[1,"clr-control-label"],[1,"table"],[3,"ngIf","ngIfElse"],["noSelection",""],[4,"ngFor","ngForOf"],["vdrDialogButtons",""],[4,"ngIf","ngIfElse"],["productModeTitle",""],["noChannelSelected",""],["type","button",1,"btn",3,"click"],["type","submit",1,"btn","btn-primary",3,"disabled","click"]],template:function(n,e){if(1&n&&(t.YNc(0,So,3,2,"ng-template",0),t.TgZ(1,"div",1)(2,"clr-input-container")(3,"label"),t._uU(4),t.ALo(5,"translate"),t.qZA(),t._UZ(6,"vdr-channel-assignment-control",2),t.qZA(),t._UZ(7,"div",3),t.TgZ(8,"clr-input-container")(9,"label"),t._uU(10),t.ALo(11,"translate"),t.qZA(),t._UZ(12,"input",4),t.qZA()(),t.TgZ(13,"div",5)(14,"label",6),t._uU(15),t.ALo(16,"translate"),t.qZA(),t.TgZ(17,"table",7)(18,"thead")(19,"tr")(20,"th"),t._uU(21),t.ALo(22,"translate"),t.qZA(),t.TgZ(23,"th"),t._uU(24),t.ALo(25,"translate"),t.ALo(26,"translate"),t.ALo(27,"channelCodeToLabel"),t.qZA(),t.TgZ(28,"th"),t.YNc(29,$o,2,6,"ng-template",8),t.YNc(30,Qo,2,3,"ng-template",null,9,t.W1O),t.qZA()()(),t.TgZ(32,"tbody"),t.YNc(33,Eo,10,7,"tr",10),t.ALo(34,"async"),t.qZA()()(),t.YNc(35,Ro,7,6,"ng-template",11)),2&n){const o=t.MAs(31);t.xp6(4),t.Oqu(t.lcZ(5,13,"common.channel")),t.xp6(2),t.Q6J("multiple",!1)("includeDefaultChannel",!1)("disableChannelIds",e.currentChannelIds)("formControl",e.selectedChannelIdControl),t.xp6(4),t.Oqu(t.lcZ(11,15,"catalog.price-conversion-factor")),t.xp6(2),t.Q6J("formControl",e.priceFactorControl),t.xp6(3),t.Oqu(t.lcZ(16,17,"catalog.channel-price-preview")),t.xp6(6),t.Oqu(t.lcZ(22,19,"common.name")),t.xp6(3),t.hij(" ",t.xi3(25,21,"catalog.price-in-channel",t.VKq(30,fe,t.lcZ(26,24,t.lcZ(27,26,null==e.currentChannel?null:e.currentChannel.code))))," "),t.xp6(5),t.Q6J("ngIf",e.selectedChannel)("ngIfElse",o),t.xp6(4),t.Q6J("ngForOf",t.lcZ(34,28,e.variantsPreview$))}},directives:[Bt.q,C.O5,f.G55,f.MgK,No.S,f.xRP,l.JJ,l.oH,M.y,l.qQ,l.Fd,l.wV,l.Fj,C.sg,Rt.n],pipes:[F.X$,ne.E,C.Ov,oe.k],styles:["vdr-channel-assignment-control[_ngcontent-%COMP%]{min-width:200px}.channel-price-preview[_ngcontent-%COMP%]{margin-top:24px}.channel-price-preview[_ngcontent-%COMP%] table.table[_ngcontent-%COMP%]{margin-top:6px}"],changeDetection:0});var zo=u(3336),Ko=u(2971);function ie(i,n,e){if(!i)return"";const o=i.lastIndexOf(n);if(-1===o)return i;return i.substr(0,o)+i.substr(o).replace(n,e)}class j{constructor(n){this.dataService=n}getFacets(){return this.dataService.facet.getAllFacets().mapSingle(n=>n.facets.items)}getTaxCategories(){return this.dataService.settings.getTaxCategories().mapSingle(n=>n.taxCategories).pipe((0,Jt.d)(1))}createProductWithVariants(n,e,o){const a=this.dataService.product.createProduct(n),r=e.groups.filter(d=>0<d.values.length),c=this.createProductOptionGroups(r,o);return(0,S.D)(a,c).pipe((0,P.z)(([{createProduct:d},p])=>(p.length?(0,S.D)(p.map(m=>this.dataService.product.addOptionGroupToProduct({productId:d.id,optionGroupId:m.id}))):(0,L.of)([])).pipe((0,v.U)(()=>({createProduct:d,optionGroups:p})))),(0,P.z)(({createProduct:d,optionGroups:p})=>{const h=e.variants.map(g=>{const x=p.length?g.optionValues.map((b,Z)=>{const I=p[Z].options.find(V=>V.name===b);if(!I)throw new Error(`Could not find a matching ProductOption "${b}" when creating variant`);return I.id}):[];return Object.assign(Object.assign({},g),{optionIds:x})}),m=p.map(g=>g.options).reduce((g,x)=>[...g,...x],[]);return this.createProductVariants(d,h,m,o)}))}createProductOptionGroups(n,e){return n.length?(0,S.D)(n.map(o=>this.dataService.product.createProductOptionGroups({code:(0,z.U)(o.name,"-"),translations:[{languageCode:e,name:o.name}],options:o.values.map(a=>({code:(0,z.U)(a,"-"),translations:[{languageCode:e,name:a}]}))}).pipe((0,v.U)(a=>a.createProductOptionGroup)))):(0,L.of)([])}createProductVariants(n,e,o,a){const r=e.map(c=>{const d=o.length?`${n.name} ${c.optionIds.map(p=>o.find(h=>h.id===p)).filter(w.notNullOrUndefined).map(p=>p.name).join(" ")}`:n.name;return{productId:n.id,price:c.price,sku:c.sku,stockOnHand:c.stock,translations:[{languageCode:a,name:d}],optionIds:c.optionIds}});return this.dataService.product.createProductVariants(r).pipe((0,v.U)(({createProductVariants:c})=>({createProductVariants:c,productId:n.id})))}updateProduct(n){const{product:e,languageCode:o,autoUpdate:a,productInput:r,variantsInput:c}=n,d=[],p=c||[];return(a?this.dataService.product.getProductVariants({},e.id).mapSingle(({productVariants:m})=>m.items):(0,L.of)([])).pipe((0,P.z)(m=>{var g,x,b,Z;if(r){d.push(this.dataService.product.updateProduct(r));const I=null!==(x=null===(g=(0,s.ZIM)(e,o))||void 0===g?void 0:g.name)&&void 0!==x?x:"",V=null===(b=(0,s.ZIM)(r,o))||void 0===b?void 0:b.name;if(V&&I!==V&&a)for(const Mt of m){const Nt=(null===(Z=(0,s.ZIM)(Mt,o))||void 0===Z?void 0:Z.name)||"";let wt;const Qt=p.find(re=>re.id===Mt.id);Qt?wt=Qt:(wt={id:Mt.id,translations:[{languageCode:o,name:Nt}]},p.push(wt));const Yt=(0,s.ZIM)(wt,o);Yt&&(Yt.name?Yt.name=ie(Yt.name,I,V):Yt.name=[V,...Mt.options.map(re=>re.name)].join(" "))}}return p.length&&d.push(this.dataService.product.updateProductVariants(p)),(0,S.D)(d)}))}updateProductOption(n,e,o){return(n.autoUpdate?this.dataService.product.getProductVariants({},e.id).mapSingle(({productVariants:r})=>r.items):(0,L.of)([])).pipe((0,P.z)(r=>{var c,d,p;let h=(0,L.of)([]);if(n.autoUpdate){let m;const g=null===(c=(0,s.ZIM)(n,o))||void 0===c?void 0:c.name;g||(h=(0,L.of)([]));const x=[];for(const b of r)if(b.options.map(Z=>Z.id).includes(n.id)){m||(m=null===(d=(0,s.ZIM)(b.options.find(I=>I.id===n.id),o))||void 0===d?void 0:d.name);const Z=(null===(p=(0,s.ZIM)(b,o))||void 0===p?void 0:p.name)||"";m&&g&&Z.includes(m)&&x.push({id:b.id,translations:[{languageCode:o,name:ie(Z,m,g)}]})}x.length&&(h=this.dataService.product.updateProductVariants(x))}return this.dataService.product.updateProductOption(n).pipe((0,P.z)(()=>h))}))}deleteProductVariant(n,e){return this.dataService.product.deleteProductVariant(n).pipe((0,y.w)(o=>o.deleteProductVariant.result===s.PcR.DELETED?this.dataService.product.getProduct(e).single$:function Wo(i,n){const e=(0,Ko.m)(i)?i:()=>i,o=a=>a.error(e());return new zo.y(n?a=>n.schedule(o,0,a):o)}(o.deleteProductVariant.message)))}}j.\u0275fac=function(n){return new(n||j)(t.LFG(s.DoR))},j.\u0275prov=t.Yz7({token:j,factory:j.\u0275fac,providedIn:"root"});var ve=u(6444),Ce=u(4209),Xo=u(2930),xe=u(1185);const ti=["textArea"];function ei(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-chip",6),t.NdJ("iconClick",function(){const r=t.CHM(e).$implicit;return t.oxw(2).removeOption(r)}),t._uU(1),t.qZA()}if(2&i){const e=n.$implicit,o=n.last,a=t.oxw(2);t.ekj("selected",o&&a.lastSelected)("locked",e.locked),t.Q6J("icon",e.locked?"lock":"times")("colorFrom",a.groupName),t.xp6(1),t.hij(" ",e.name," ")}}function ni(i,n){if(1&i&&(t.TgZ(0,"div",4),t.YNc(1,ei,2,7,"vdr-chip",5),t.qZA()),2&i){const e=t.oxw();t.xp6(1),t.Q6J("ngForOf",e.options)}}const be={provide:l.JU,useExisting:(0,t.Gpc)(()=>H),multi:!0};class H{constructor(n){this.changeDetector=n,this.groupName="",this.disabled=!1,this.input="",this.isFocussed=!1,this.lastSelected=!1}registerOnChange(n){this.onChangeFn=n}registerOnTouched(n){this.onTouchFn=n}setDisabledState(n){this.disabled=n,this.changeDetector.markForCheck()}writeValue(n){this.options=n||[]}focus(){this.textArea.nativeElement.focus()}removeOption(n){n.locked||(this.options=this.options.filter(e=>e.name!==n.name),this.onChangeFn(this.options))}handleKey(n){switch(n.key){case",":case"Enter":this.addOptionValue(),n.preventDefault();break;case"Backspace":this.lastSelected?(this.removeLastOption(),this.lastSelected=!1):""===this.input&&(this.lastSelected=!0);break;default:this.lastSelected=!1}}handleBlur(){this.isFocussed=!1,this.addOptionValue()}addOptionValue(){this.options=(0,St.T)([...this.options,...this.parseInputIntoOptions(this.input)]),this.input="",this.onChangeFn(this.options)}parseInputIntoOptions(n){return n.split(/[,\n]/).map(e=>e.trim()).filter(e=>""!==e).map(e=>({name:e,locked:!1}))}removeLastOption(){this.options[this.options.length-1].locked||(this.options=this.options.slice(0,this.options.length-1))}}H.\u0275fac=function(n){return new(n||H)(t.Y36(t.sBO))},H.\u0275cmp=t.Xpm({type:H,selectors:[["vdr-option-value-input"]],viewQuery:function(n,e){if(1&n&&t.Gf(ti,7),2&n){let o;t.iGM(o=t.CRH())&&(e.textArea=o.first)}},inputs:{groupName:"groupName"},features:[t._Bn([be])],decls:4,vars:5,consts:[[1,"input-wrapper",3,"click"],["class","chips",4,"ngIf"],[3,"ngModel","disabled","keyup","focus","blur","ngModelChange"],["textArea",""],[1,"chips"],[3,"icon","selected","locked","colorFrom","iconClick",4,"ngFor","ngForOf"],[3,"icon","colorFrom","iconClick"]],template:function(n,e){if(1&n){const o=t.EpF();t.TgZ(0,"div",0),t.NdJ("click",function(){return t.CHM(o),t.MAs(3).focus()}),t.YNc(1,ni,2,1,"div",1),t.TgZ(2,"textarea",2,3),t.NdJ("keyup",function(r){return e.handleKey(r)})("focus",function(){return e.isFocussed=!0})("blur",function(){return e.handleBlur()})("ngModelChange",function(r){return e.input=r}),t.qZA()()}2&n&&(t.ekj("focus",e.isFocussed),t.xp6(1),t.Q6J("ngIf",0<e.options.length),t.xp6(1),t.Q6J("ngModel",e.input)("disabled",e.disabled))},directives:[C.O5,C.sg,dt.Y,M.y,l.Fj,l.JJ,l.On],styles:[".input-wrapper[_ngcontent-%COMP%]{background-color:#fff;border-radius:3px!important;border:1px solid var(--color-grey-300)!important;cursor:text}.input-wrapper.focus[_ngcontent-%COMP%]{border-color:var(--color-primary-500)!important;box-shadow:0 0 1px 1px var(--color-primary-100)}.input-wrapper[_ngcontent-%COMP%] .chips[_ngcontent-%COMP%]{padding:5px}.input-wrapper[_ngcontent-%COMP%] textarea[_ngcontent-%COMP%]{border:none;width:100%;height:24px;margin-top:3px;padding:0 6px}.input-wrapper[_ngcontent-%COMP%] textarea[_ngcontent-%COMP%]:focus{outline:none}.input-wrapper[_ngcontent-%COMP%] textarea[_ngcontent-%COMP%]:disabled{background-color:var(--color-component-bg-100)}vdr-chip[_ngcontent-%COMP%] .wrapper{margin:0 3px}vdr-chip.locked[_ngcontent-%COMP%]{opacity:.8}vdr-chip.selected[_ngcontent-%COMP%] .wrapper{border-color:var(--color-warning-500)!important;box-shadow:0 0 1px 1px var(--color-warning-400);opacity:.6}"]});var zt=u(7283);function oi(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",7)(1,"div",8)(2,"label"),t._uU(3),t.ALo(4,"translate"),t.qZA(),t.TgZ(5,"input",9),t.NdJ("ngModelChange",function(a){return t.CHM(e).$implicit.name=a})("keydown.enter",function(a){t.CHM(e);const r=t.MAs(11);return t.oxw().handleEnter(a,r)}),t.qZA()(),t.TgZ(6,"div",10)(7,"label"),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.TgZ(10,"vdr-option-value-input",11,12),t.NdJ("ngModelChange",function(a){return t.CHM(e).$implicit.values=a})("ngModelChange",function(){return t.CHM(e),t.oxw().generateVariants()}),t.qZA()(),t.TgZ(12,"div",13)(13,"button",14),t.NdJ("click",function(){const r=t.CHM(e).$implicit;return t.oxw().removeOption(r.name)}),t.ALo(14,"translate"),t._UZ(15,"clr-icon",15),t.qZA()()()}if(2&i){const e=n.$implicit;t.xp6(3),t.Oqu(t.lcZ(4,7,"catalog.option")),t.xp6(2),t.Q6J("ngModel",e.name),t.xp6(3),t.Oqu(t.lcZ(9,9,"catalog.option-values")),t.xp6(2),t.Q6J("ngModel",e.values)("groupName",e.name)("disabled",""===e.name),t.xp6(3),t.Q6J("title",t.lcZ(14,11,"catalog.remove-option"))}}function ii(i,n){1&i&&(t.TgZ(0,"th"),t._uU(1),t.ALo(2,"translate"),t.qZA()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"common.create")))}function ai(i,n){1&i&&(t.TgZ(0,"th"),t._uU(1),t.ALo(2,"translate"),t.qZA()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"catalog.variant")))}function ri(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"td")(1,"input",19),t.NdJ("change",function(){return t.CHM(e),t.oxw(2).onFormChange()})("ngModelChange",function(a){t.CHM(e);const r=t.oxw().$implicit;return t.oxw().variantFormValues[r.id].enabled=a}),t.qZA()()}if(2&i){const e=t.oxw().$implicit,o=t.oxw();t.xp6(1),t.Q6J("ngModel",o.variantFormValues[e.id].enabled)}}function ci(i,n){if(1&i&&(t.TgZ(0,"td"),t._uU(1),t.qZA()),2&i){const e=t.oxw().$implicit;t.xp6(1),t.hij(" ",e.values.join(" ")," ")}}function si(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"tr"),t.YNc(1,ri,2,1,"td",5),t.YNc(2,ci,2,1,"td",5),t.TgZ(3,"td")(4,"clr-input-container")(5,"input",16),t.NdJ("change",function(){return t.CHM(e),t.oxw().onFormChange()})("ngModelChange",function(a){const c=t.CHM(e).$implicit;return t.oxw().variantFormValues[c.id].sku=a}),t.ALo(6,"translate"),t.qZA()()(),t.TgZ(7,"td")(8,"clr-input-container")(9,"vdr-currency-input",17),t.NdJ("ngModelChange",function(a){const c=t.CHM(e).$implicit;return t.oxw().variantFormValues[c.id].price=a})("ngModelChange",function(){return t.CHM(e),t.oxw().onFormChange()}),t.qZA()()(),t.TgZ(10,"td")(11,"clr-input-container")(12,"input",18),t.NdJ("ngModelChange",function(a){const c=t.CHM(e).$implicit;return t.oxw().variantFormValues[c.id].stock=a})("change",function(){return t.CHM(e),t.oxw().onFormChange()}),t.qZA()()()()}if(2&i){const e=n.$implicit,o=t.oxw();t.ekj("disabled",!o.variantFormValues[e.id].enabled),t.xp6(1),t.Q6J("ngIf",1<o.variants.length),t.xp6(1),t.Q6J("ngIf",1<o.variants.length),t.xp6(3),t.Q6J("ngModel",o.variantFormValues[e.id].sku)("placeholder",t.lcZ(6,9,"catalog.sku")),t.xp6(4),t.Q6J("ngModel",o.variantFormValues[e.id].price)("currencyCode",o.currencyCode),t.xp6(3),t.Q6J("ngModel",o.variantFormValues[e.id].stock)}}const ae="__DEFAULT_VARIANT__";class ht{constructor(n){this.dataService=n,this.variantsChange=new t.vpe,this.optionGroups=[],this.variantFormValues={}}ngOnInit(){this.dataService.settings.getActiveChannel().single$.subscribe(n=>{this.currencyCode=n.activeChannel.currencyCode}),this.generateVariants()}addOption(){this.optionGroups.push({name:"",values:[]})}removeOption(n){this.optionGroups=this.optionGroups.filter(e=>e.name!==n),this.generateVariants()}generateVariants(){const e=this.optionGroups.reduce((o,a)=>o+a.values.length,0)?this.optionGroups.map(o=>o.values.map(a=>a.name)):[[ae]];this.variants=(0,w.generateAllCombinations)(e).map(o=>({id:o.join("|"),values:o})),this.variants.forEach(o=>{this.variantFormValues[o.id]||(this.variantFormValues[o.id]={optionValues:o.values,enabled:!0,price:this.copyFromDefault(o.id,"price",0),sku:this.copyFromDefault(o.id,"sku",""),stock:this.copyFromDefault(o.id,"stock",0)})}),this.onFormChange()}trackByFn(n,e){return e.values.join("|")}handleEnter(n,e){n.preventDefault(),n.stopPropagation(),e.focus()}onFormChange(){const n=this.variants.map(e=>this.variantFormValues[e.id]).filter(e=>e.enabled);this.variantsChange.emit({groups:this.optionGroups.map(e=>({name:e.name,values:e.values.map(o=>o.name)})),variants:n})}copyFromDefault(n,e,o){return n!==ae?this.variantFormValues[ae][e]:o}}ht.\u0275fac=function(n){return new(n||ht)(t.Y36(s.DoR))},ht.\u0275cmp=t.Xpm({type:ht,selectors:[["vdr-generate-product-variants"]],outputs:{variantsChange:"variantsChange"},decls:21,vars:17,consts:[["class","option-groups",4,"ngFor","ngForOf"],[1,"btn","btn-primary-outline","btn-sm",3,"click"],["shape","plus"],[1,"variants-preview"],[1,"table"],[4,"ngIf"],[3,"disabled",4,"ngFor","ngForOf","ngForTrackBy"],[1,"option-groups"],[1,"name"],["placeholder","e.g. Size","clrInput","","name","name","required","",3,"ngModel","ngModelChange","keydown.enter"],[1,"values"],[3,"ngModel","groupName","disabled","ngModelChange"],["optionValueInputComponent",""],[1,"remove-group"],[1,"btn","btn-icon","btn-warning-outline",3,"title","click"],["shape","trash"],["clrInput","","type","text",3,"ngModel","placeholder","change","ngModelChange"],["clrInput","",3,"ngModel","currencyCode","ngModelChange"],["clrInput","","type","number","min","0","step","1",3,"ngModel","ngModelChange","change"],["type","checkbox","clrCheckbox","",3,"ngModel","change","ngModelChange"]],template:function(n,e){1&n&&(t.YNc(0,oi,16,13,"div",0),t.TgZ(1,"button",1),t.NdJ("click",function(){return e.addOption()}),t._UZ(2,"clr-icon",2),t._uU(3),t.ALo(4,"translate"),t.qZA(),t.TgZ(5,"div",3)(6,"table",4)(7,"thead")(8,"tr"),t.YNc(9,ii,3,3,"th",5),t.YNc(10,ai,3,3,"th",5),t.TgZ(11,"th"),t._uU(12),t.ALo(13,"translate"),t.qZA(),t.TgZ(14,"th"),t._uU(15),t.ALo(16,"translate"),t.qZA(),t.TgZ(17,"th"),t._uU(18),t.ALo(19,"translate"),t.qZA()()(),t.YNc(20,si,13,11,"tr",6),t.qZA()()),2&n&&(t.Q6J("ngForOf",e.optionGroups),t.xp6(3),t.hij(" ",t.lcZ(4,9,"catalog.add-option"),"\n"),t.xp6(6),t.Q6J("ngIf",1<e.variants.length),t.xp6(1),t.Q6J("ngIf",1<e.variants.length),t.xp6(2),t.Oqu(t.lcZ(13,11,"catalog.sku")),t.xp6(3),t.Oqu(t.lcZ(16,13,"catalog.price")),t.xp6(3),t.Oqu(t.lcZ(19,15,"catalog.stock-on-hand")),t.xp6(2),t.Q6J("ngForOf",e.variants)("ngForTrackBy",e.trackByFn))},directives:[C.sg,f.MgK,M.y,l.Fj,f.xRP,l.Q7,l.JJ,l.On,H,f.qvL,C.O5,f.q0d,l.Wl,f.KKC,f.G55,zt.K,l.qQ,l.wV],pipes:[F.X$],styles:["[_nghost-%COMP%]{display:block;margin-bottom:120px}.option-groups[_ngcontent-%COMP%]{display:flex}.values[_ngcontent-%COMP%]{flex:1;margin:0 6px}.remove-group[_ngcontent-%COMP%]{padding-top:18px}.variants-preview[_ngcontent-%COMP%] tr.disabled[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{background-color:var(--color-component-bg-100);color:var(--color-grey-400)}"]});var Ze=u(5850),li=u(3477);function di(i,n){if(1&i&&(t.ynx(0),t.TgZ(1,"th"),t._uU(2),t.qZA(),t.BQk()),2&i){const e=n.$implicit;t.xp6(2),t.Oqu(e.name)}}function pi(i,n){if(1&i&&(t._UZ(0,"img",18),t.ALo(1,"assetPreview")),2&i){const e=n.ngIf;t.Q6J("src",t.xi3(1,1,e,"tiny"),t.LSH)}}function ui(i,n){1&i&&(t.TgZ(0,"div",19),t._UZ(1,"clr-icon",20),t.qZA())}function mi(i,n){if(1&i&&(t.ynx(0),t.TgZ(1,"td",5),t.ALo(2,"stringToColor"),t._uU(3),t.qZA(),t.BQk()),2&i){const e=n.$implicit,o=t.oxw().ngIf,a=t.oxw(2);t.xp6(1),t.Udp("color",t.lcZ(2,5,a.optionGroupName(e.groupId))),t.ekj("disabled",!o.get("enabled").value),t.xp6(2),t.hij(" ",e.name," ")}}function _i(i,n){if(1&i&&(t._UZ(0,"vdr-currency-input",21),t.ALo(1,"hasPermission")),2&i){const e=t.oxw(2).$implicit,o=t.oxw();t.Q6J("currencyCode",e.currencyCode)("readonly",!t.lcZ(1,2,o.updatePermission))}}function gi(i,n){if(1&i&&(t._UZ(0,"vdr-currency-input",22),t.ALo(1,"hasPermission")),2&i){const e=t.oxw(2).$implicit,o=t.oxw();t.Q6J("currencyCode",e.currencyCode)("readonly",!t.lcZ(1,2,o.updatePermission))}}function hi(i,n){if(1&i&&(t.ynx(0,4),t.TgZ(1,"td",5)(2,"div",6)(3,"div",7),t.YNc(4,pi,2,4,"img",8),t.YNc(5,ui,2,0,"ng-template",null,9,t.W1O),t.qZA()()(),t.TgZ(7,"td",5)(8,"clr-input-container"),t._UZ(9,"input",10),t.ALo(10,"hasPermission"),t.ALo(11,"translate"),t.qZA()(),t.TgZ(12,"td",5)(13,"clr-input-container"),t._UZ(14,"input",11),t.ALo(15,"hasPermission"),t.ALo(16,"translate"),t.qZA()(),t.YNc(17,mi,4,7,"ng-container",1),t.ALo(18,"sort"),t.TgZ(19,"td",12)(20,"clr-input-container"),t.YNc(21,_i,2,4,"vdr-currency-input",13),t.YNc(22,gi,2,4,"vdr-currency-input",14),t.qZA()(),t.TgZ(23,"td",15)(24,"clr-input-container"),t._UZ(25,"input",16),t.ALo(26,"hasPermission"),t.qZA()(),t.TgZ(27,"td",15)(28,"clr-toggle-wrapper"),t._UZ(29,"input",17),t.ALo(30,"hasPermission"),t.qZA()(),t.BQk()),2&i){const e=n.ngIf,o=t.MAs(6),a=t.oxw().$implicit,r=t.oxw();t.Q6J("formGroup",e),t.xp6(1),t.ekj("disabled",!e.get("enabled").value),t.xp6(3),t.Q6J("ngIf",r.getFeaturedAsset(a))("ngIfElse",o),t.xp6(3),t.ekj("disabled",!e.get("enabled").value),t.xp6(2),t.Q6J("readonly",!t.lcZ(10,24,r.updatePermission))("placeholder",t.lcZ(11,26,"common.name")),t.xp6(3),t.ekj("disabled",!e.get("enabled").value),t.xp6(2),t.Q6J("readonly",!t.lcZ(15,28,r.updatePermission))("placeholder",t.lcZ(16,30,"catalog.sku")),t.xp6(3),t.Q6J("ngForOf",t.xi3(18,32,a.options,"groupId")),t.xp6(2),t.ekj("disabled",!e.get("enabled").value),t.xp6(2),t.Q6J("ngIf",!r.channelPriceIncludesTax),t.xp6(1),t.Q6J("ngIf",r.channelPriceIncludesTax),t.xp6(1),t.ekj("disabled",!e.get("enabled").value),t.xp6(2),t.Q6J("readonly",!t.lcZ(26,35,r.updatePermission)),t.xp6(2),t.ekj("disabled",!e.get("enabled").value),t.xp6(2),t.Q6J("vdrDisabled",!t.lcZ(30,37,r.updatePermission))}}function fi(i,n){if(1&i&&(t.TgZ(0,"tr"),t.YNc(1,hi,31,39,"ng-container",3),t.qZA()),2&i){const e=n.$implicit,o=t.oxw();t.xp6(1),t.Q6J("ngIf",o.formGroupMap.get(e.id))}}class ft{constructor(n){this.changeDetector=n,this.formGroupMap=new Map,this.updatePermission=[s.y3$.UpdateCatalog,s.y3$.UpdateProduct]}ngOnInit(){this.subscription=this.formArray.valueChanges.pipe((0,v.U)(n=>n.length),(0,$.b)(1),(0,st.x)()).subscribe(()=>{this.buildFormGroupMap()}),this.buildFormGroupMap()}ngOnDestroy(){this.subscription&&this.subscription.unsubscribe()}trackByFn(n,e){return null!=e.id?e.id:n}getFeaturedAsset(n){var e;return(null===(e=this.pendingAssetChanges[n.id])||void 0===e?void 0:e.featuredAsset)||n.featuredAsset}optionGroupName(n){const e=this.optionGroups.find(o=>o.id===n);return e&&e.name}buildFormGroupMap(){this.formGroupMap.clear();for(const n of this.formArray.controls)this.formGroupMap.set(n.value.id,n);this.changeDetector.markForCheck()}}function vi(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.Oqu(t.lcZ(1,1,"catalog.update-product-option"))}ft.\u0275fac=function(n){return new(n||ft)(t.Y36(t.sBO))},ft.\u0275cmp=t.Xpm({type:ft,selectors:[["vdr-product-variants-table"]],inputs:{formArray:["productVariantsFormArray","formArray"],variants:"variants",paginationConfig:"paginationConfig",channelPriceIncludesTax:"channelPriceIncludesTax",optionGroups:"optionGroups",pendingAssetChanges:"pendingAssetChanges"},decls:24,vars:24,consts:[[1,"table"],[4,"ngFor","ngForOf"],[4,"ngFor","ngForOf","ngForTrackBy"],[3,"formGroup",4,"ngIf"],[3,"formGroup"],[1,"left","align-middle"],[1,"card-img"],[1,"featured-asset"],[3,"src",4,"ngIf","ngIfElse"],["placeholder",""],["clrInput","","type","text","formControlName","name",3,"readonly","placeholder"],["clrInput","","type","text","formControlName","sku",3,"readonly","placeholder"],[1,"left","align-middle","price"],["clrInput","","formControlName","price",3,"currencyCode","readonly",4,"ngIf"],["clrInput","","formControlName","priceWithTax",3,"currencyCode","readonly",4,"ngIf"],[1,"left","align-middle","stock"],["clrInput","","type","number","min","0","step","1","formControlName","stockOnHand",3,"readonly"],["type","checkbox","clrToggle","","name","enabled","formControlName","enabled",3,"vdrDisabled"],[3,"src"],[1,"placeholder"],["shape","image","size","48"],["clrInput","","formControlName","price",3,"currencyCode","readonly"],["clrInput","","formControlName","priceWithTax",3,"currencyCode","readonly"]],template:function(n,e){1&n&&(t.TgZ(0,"table",0)(1,"thead")(2,"tr"),t._UZ(3,"th"),t.TgZ(4,"th"),t._uU(5),t.ALo(6,"translate"),t.qZA(),t.TgZ(7,"th"),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.YNc(10,di,3,1,"ng-container",1),t.ALo(11,"sort"),t.TgZ(12,"th"),t._uU(13),t.ALo(14,"translate"),t.qZA(),t.TgZ(15,"th"),t._uU(16),t.ALo(17,"translate"),t.qZA(),t.TgZ(18,"th"),t._uU(19),t.ALo(20,"translate"),t.qZA()()(),t.TgZ(21,"tbody"),t.YNc(22,fi,2,1,"tr",2),t.ALo(23,"paginate"),t.qZA()()),2&n&&(t.xp6(5),t.Oqu(t.lcZ(6,8,"common.name")),t.xp6(3),t.Oqu(t.lcZ(9,10,"catalog.sku")),t.xp6(2),t.Q6J("ngForOf",t.xi3(11,12,e.optionGroups,"id")),t.xp6(3),t.Oqu(t.lcZ(14,15,"catalog.price")),t.xp6(3),t.Oqu(t.lcZ(17,17,"catalog.stock-on-hand")),t.xp6(3),t.Oqu(t.lcZ(20,19,"common.enabled")),t.xp6(3),t.Q6J("ngForOf",t.xi3(23,21,e.variants,e.paginationConfig))("ngForTrackBy",e.trackByFn))},directives:[C.sg,f.q0d,C.O5,l.JL,l.sg,f.qvL,f.G55,M.y,l.Fj,f.xRP,l.JJ,l.u,zt.K,l.qQ,l.wV,f.PEh,l.Wl,f.KKC,Et.x],pipes:[F.X$,Ze.U,Kt._s,Xt.M,U.j,li.s],styles:[".placeholder[_ngcontent-%COMP%]{color:var(--color-grey-300)}.stock[_ngcontent-%COMP%] input[_ngcontent-%COMP%], .price[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{max-width:96px}td[_ngcontent-%COMP%]{transition:background-color .2s}td.disabled[_ngcontent-%COMP%]{background-color:var(--color-component-bg-200)}"],changeDetection:0});const Ci=function(){return["UpdateCatalog","UpdateProduct"]};function xi(i,n){if(1&i&&(t.TgZ(0,"section")(1,"label"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t._UZ(4,"vdr-tabbed-custom-fields",10),t.ALo(5,"hasPermission"),t.qZA()),2&i){const e=t.oxw();t.xp6(2),t.Oqu(t.lcZ(3,4,"common.custom-fields")),t.xp6(2),t.Q6J("customFields",e.customFields)("customFieldsFormGroup",e.customFieldsForm)("readonly",!t.lcZ(5,6,t.DdM(8,Ci)))}}function bi(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",11),t.NdJ("click",function(){return t.CHM(e),t.oxw().cancel()}),t._uU(1),t.ALo(2,"translate"),t.qZA(),t.TgZ(3,"button",12),t.NdJ("click",function(){return t.CHM(e),t.oxw().update()}),t._uU(4),t.ALo(5,"translate"),t.qZA()}if(2&i){const e=t.oxw(),o=t.MAs(4),a=t.MAs(8);t.xp6(1),t.Oqu(t.lcZ(2,3,"common.cancel")),t.xp6(2),t.Q6J("disabled",o.invalid||a.invalid||o.pristine&&a.pristine&&e.customFieldsForm.pristine),t.xp6(1),t.hij(" ",t.lcZ(5,5,"catalog.update-product-option")," ")}}class vt{constructor(){this.updateVariantName=!0,this.codeInputTouched=!1}ngOnInit(){var n;const e=this.productOption.translations.find(o=>o.languageCode===this.activeLanguage);if(this.name=null!==(n=null==e?void 0:e.name)&&void 0!==n?n:"",this.code=this.productOption.code,this.customFieldsForm=new l.cw({}),this.customFields){const o=e&&e.customFields||{};for(const a of this.customFields){const r=a.name,c="localeString"===a.type?o[r]:this.productOption.customFields[r];this.customFieldsForm.addControl(a.name,new l.NI(c))}}}update(){const n=(0,s.iSy)({translatable:this.productOption,languageCode:this.activeLanguage,updatedFields:{code:this.code,name:this.name,customFields:this.customFieldsForm.value},customFieldConfig:this.customFields,defaultTranslation:{languageCode:this.activeLanguage,name:""}});this.resolveWith(Object.assign(Object.assign({},n),{autoUpdate:this.updateVariantName}))}cancel(){this.resolveWith()}updateCode(n){!this.codeInputTouched&&!this.productOption.code&&(this.code=(0,z.U)(n,"-"))}}vt.\u0275fac=function(n){return new(n||vt)},vt.\u0275cmp=t.Xpm({type:vt,selectors:[["vdr-update-product-option-dialog"]],decls:16,vars:13,consts:[["vdrDialogTitle",""],["for","name",3,"label"],["id","name","type","text","required","",3,"ngModel","ngModelChange","input"],["nameInput","ngModel"],["for","code",3,"label"],["id","code","type","text","required","","pattern","[a-z0-9_-]+",3,"ngModel","ngModelChange"],["codeInput","ngModel"],["type","checkbox","clrCheckbox","",3,"ngModel","ngModelChange"],[4,"ngIf"],["vdrDialogButtons",""],["entityName","ProductOption",3,"customFields","customFieldsFormGroup","readonly"],["type","button",1,"btn",3,"click"],["type","submit",1,"btn","btn-primary",3,"disabled","click"]],template:function(n,e){1&n&&(t.YNc(0,vi,2,3,"ng-template",0),t.TgZ(1,"vdr-form-field",1),t.ALo(2,"translate"),t.TgZ(3,"input",2,3),t.NdJ("ngModelChange",function(a){return e.name=a})("input",function(a){return e.updateCode(a.target.value)}),t.qZA()(),t.TgZ(5,"vdr-form-field",4),t.ALo(6,"translate"),t.TgZ(7,"input",5,6),t.NdJ("ngModelChange",function(a){return e.code=a}),t.qZA()(),t.TgZ(9,"clr-checkbox-wrapper")(10,"input",7),t.NdJ("ngModelChange",function(a){return e.updateVariantName=a}),t.qZA(),t.TgZ(11,"label"),t._uU(12),t.ALo(13,"translate"),t.qZA()(),t.YNc(14,xi,6,9,"section",8),t.YNc(15,bi,6,7,"ng-template",9)),2&n&&(t.xp6(1),t.Q6J("label",t.lcZ(2,7,"catalog.option-name")),t.xp6(2),t.Q6J("ngModel",e.name),t.xp6(2),t.Q6J("label",t.lcZ(6,9,"common.code")),t.xp6(2),t.Q6J("ngModel",e.code),t.xp6(3),t.Q6J("ngModel",e.updateVariantName),t.xp6(2),t.Oqu(t.lcZ(13,11,"catalog.auto-update-option-variant-name")),t.xp6(2),t.Q6J("ngIf",e.customFields.length))},directives:[Bt.q,Dt.h,M.y,l.Fj,l.Q7,l.JJ,l.On,l.c5,f.PEh,l.Wl,f.KKC,f.MgK,C.O5,qt.y,Rt.n],pipes:[F.X$,U.j],styles:[""],changeDetection:0});var Zi=u(7861);const Ti=function(i){return{rate:i}};function Ai(i,n){if(1&i&&(t.TgZ(0,"div",2),t._uU(1),t.ALo(2,"translate"),t.ALo(3,"async"),t.qZA()),2&i){const e=t.oxw();t.xp6(1),t.hij(" ",t.xi3(2,1,"catalog.price-includes-tax-at",t.VKq(6,Ti,t.lcZ(3,4,e.taxRate$))),"\n")}}const Pi=function(i,n){return{price:i,rate:n}};function yi(i,n){if(1&i&&(t.TgZ(0,"div",2),t._uU(1),t.ALo(2,"translate"),t.ALo(3,"localeCurrency"),t.ALo(4,"async"),t.ALo(5,"async"),t.qZA()),2&i){const e=t.oxw();t.xp6(1),t.hij(" ",t.xi3(2,1,"catalog.price-with-tax-in-default-zone",t.WLB(11,Pi,t.xi3(3,4,t.lcZ(4,7,e.grossPrice$),e.currencyCode),t.lcZ(5,9,e.taxRate$))),"\n")}}class Ct{constructor(n){this.dataService=n,this.priceChange$=new N.X(0),this.taxCategoryIdChange$=new N.X("")}ngOnInit(){const n=this.dataService.settings.getTaxRatesSimple(999,0,"cache-first").mapStream(o=>o.taxRates.items),e=this.dataService.settings.getActiveChannel("cache-first").refetchOnChannelChange().mapStream(o=>o.activeChannel);this.taxRate$=(0,O.a)(e,n,this.taxCategoryIdChange$).pipe((0,v.U)(([o,a,r])=>{const c=o.defaultTaxZone;if(!c)return 0;const d=a.find(p=>p.zone.id===c.id&&p.category.id===r);return d?d.value:0})),this.grossPrice$=(0,O.a)(this.taxRate$,this.priceChange$).pipe((0,v.U)(([o,a])=>Math.round(a*((100+o)/100))))}ngOnChanges(n){"price"in n&&this.priceChange$.next(n.price.currentValue),"taxCategoryId"in n&&this.taxCategoryIdChange$.next(n.taxCategoryId.currentValue)}}Ct.\u0275fac=function(n){return new(n||Ct)(t.Y36(s.DoR))},Ct.\u0275cmp=t.Xpm({type:Ct,selectors:[["vdr-variant-price-detail"]],inputs:{priceIncludesTax:"priceIncludesTax",price:"price",currencyCode:"currencyCode",taxCategoryId:"taxCategoryId"},features:[t.TTD],decls:5,vars:5,consts:[[1,"clr-control-label"],["class","value",4,"ngIf"],[1,"value"]],template:function(n,e){1&n&&(t.TgZ(0,"label",0),t._uU(1),t.ALo(2,"translate"),t.qZA(),t.YNc(3,Ai,4,8,"div",1),t.YNc(4,yi,6,14,"div",1)),2&n&&(t.xp6(1),t.Oqu(t.lcZ(2,3,"catalog.taxes")),t.xp6(2),t.Q6J("ngIf",e.priceIncludesTax),t.xp6(1),t.Q6J("ngIf",!e.priceIncludesTax))},directives:[f.MgK,C.O5],pipes:[F.X$,C.Ov,oe.k],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column}.value[_ngcontent-%COMP%]{margin-top:3px}"],changeDetection:0});var Fi=u(9435);function Oi(i,n){1&i&&(t.TgZ(0,"clr-toggle-wrapper"),t._UZ(1,"input",45),t.TgZ(2,"label"),t._uU(3),t.ALo(4,"translate"),t.qZA()()),2&i&&(t.xp6(3),t.Oqu(t.lcZ(4,1,"common.enabled")))}function Ii(i,n){if(1&i&&(t.TgZ(0,"option",48),t._uU(1),t.qZA()),2&i){const e=n.$implicit;t.Q6J("value",e.id),t.xp6(1),t.hij(" ",e.name," ")}}function Li(i,n){if(1&i&&(t.TgZ(0,"clr-select-container")(1,"label"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t.TgZ(4,"select",46),t.YNc(5,Ii,2,2,"option",47),t.qZA()()),2&i){const e=t.oxw(3);t.xp6(2),t.Oqu(t.lcZ(3,2,"catalog.tax-category")),t.xp6(3),t.Q6J("ngForOf",e.taxCategories)}}function Mi(i,n){if(1&i&&(t.TgZ(0,"label",29),t._uU(1),t.ALo(2,"translate"),t.qZA(),t.TgZ(3,"div",49),t._uU(4),t.qZA()),2&i){const e=t.oxw().ngIf,o=t.oxw(2);t.xp6(1),t.Oqu(t.lcZ(2,2,"catalog.tax-category")),t.xp6(3),t.hij(" ",o.getTaxCategoryName(e)," ")}}function wi(i,n){if(1&i&&(t._UZ(0,"vdr-currency-input",50),t.ALo(1,"hasPermission")),2&i){const e=t.oxw(2).$implicit,o=t.oxw();t.Q6J("currencyCode",e.currencyCode)("readonly",!t.lcZ(1,2,o.updatePermission))}}function ki(i,n){if(1&i&&(t._UZ(0,"vdr-currency-input",51),t.ALo(1,"hasPermission")),2&i){const e=t.oxw(2).$implicit,o=t.oxw();t.Q6J("currencyCode",e.currencyCode)("readonly",!t.lcZ(1,2,o.updatePermission))}}function Vi(i,n){if(1&i&&(t.TgZ(0,"clr-select-container")(1,"label"),t._uU(2),t.ALo(3,"translate"),t._UZ(4,"vdr-help-tooltip",27),t.ALo(5,"translate"),t.qZA(),t.TgZ(6,"select",52)(7,"option",48),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.TgZ(10,"option",48),t._uU(11),t.ALo(12,"translate"),t.qZA(),t.TgZ(13,"option",48),t._uU(14),t.ALo(15,"translate"),t.qZA()()()),2&i){const e=t.oxw(3);t.xp6(2),t.hij("",t.lcZ(3,8,"catalog.track-inventory")," "),t.xp6(2),t.Q6J("content",t.lcZ(5,10,"catalog.track-inventory-tooltip")),t.xp6(3),t.Q6J("value",e.GlobalFlag.TRUE),t.xp6(1),t.hij(" ",t.lcZ(9,12,"catalog.track-inventory-true")," "),t.xp6(2),t.Q6J("value",e.GlobalFlag.FALSE),t.xp6(1),t.hij(" ",t.lcZ(12,14,"catalog.track-inventory-false")," "),t.xp6(2),t.Q6J("value",e.GlobalFlag.INHERIT),t.xp6(1),t.hij(" ",t.lcZ(15,16,"catalog.track-inventory-inherit")," ")}}function Ji(i,n){if(1&i&&(t.TgZ(0,"section",53),t._UZ(1,"vdr-tabbed-custom-fields",54),t.ALo(2,"hasPermission"),t.qZA()),2&i){const e=t.oxw().ngIf,o=t.oxw(2);t.xp6(1),t.Q6J("customFields",o.customFields)("compact",!0)("customFieldsFormGroup",e.get("customFields"))("readonly",!t.lcZ(2,4,o.updatePermission))}}function Ui(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-chip",58),t.NdJ("iconClick",function(){const r=t.CHM(e).$implicit;return t.oxw(4).editOption(r)}),t.ALo(1,"hasPermission"),t.TgZ(2,"span",59),t._uU(3),t.qZA(),t._uU(4),t.qZA()}if(2&i){const e=n.$implicit,o=t.oxw(4);t.Q6J("colorFrom",o.optionGroupName(e.groupId))("invert",!0)("icon",t.lcZ(1,5,o.updatePermission)&&"pencil"),t.xp6(3),t.Oqu(o.optionGroupName(e.groupId)),t.xp6(1),t.hij(" ",o.optionName(e)," ")}}const Ni=function(){return["./","options"]};function Di(i,n){if(1&i&&(t.TgZ(0,"div")(1,"div",55),t.YNc(2,Ui,5,7,"vdr-chip",56),t.ALo(3,"sort"),t.TgZ(4,"a",57),t._uU(5),t.ALo(6,"translate"),t.qZA()()()),2&i){const e=t.oxw(2).$implicit;t.xp6(2),t.Q6J("ngForOf",t.xi3(3,3,e.options,"groupId")),t.xp6(2),t.Q6J("routerLink",t.DdM(8,Ni)),t.xp6(1),t.hij("",t.lcZ(6,6,"catalog.edit-options"),"...")}}function qi(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-facet-value-chip",60),t.NdJ("remove",function(){const r=t.CHM(e).$implicit,c=t.oxw(2).$implicit;return t.oxw().removeFacetValue(c,r.id)}),t.ALo(1,"hasPermission"),t.qZA()}if(2&i){const e=n.$implicit,o=t.oxw(3);t.Q6J("facetValue",e)("removable",t.lcZ(1,2,o.updatePermission))}}function Si(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-facet-value-chip",60),t.NdJ("remove",function(){const r=t.CHM(e).$implicit,c=t.oxw(2).$implicit;return t.oxw().removeFacetValue(c,r.id)}),t.ALo(1,"hasPermission"),t.qZA()}if(2&i){const e=n.$implicit,o=t.oxw(3);t.Q6J("facetValue",e)("removable",t.lcZ(1,2,o.updatePermission))}}function $i(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",61),t.NdJ("click",function(){t.CHM(e);const a=t.oxw(2).$implicit;return t.oxw().selectFacetValueClick.emit([a.id])}),t._UZ(1,"clr-icon",62),t._uU(2),t.ALo(3,"translate"),t.qZA()}2&i&&(t.xp6(2),t.hij(" ",t.lcZ(3,1,"catalog.add-facets")," "))}function Qi(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-chip",69),t.NdJ("iconClick",function(){t.CHM(e);const a=t.oxw().$implicit,r=t.oxw(4).$implicit;return t.oxw().removeFromChannel.emit({channelId:a.id,variant:r})}),t.ALo(1,"translate"),t._UZ(2,"vdr-channel-badge",70),t._uU(3),t.ALo(4,"channelCodeToLabel"),t.qZA()}if(2&i){const e=t.oxw().$implicit;t.Q6J("title",t.lcZ(1,3,"catalog.remove-from-channel")),t.xp6(2),t.Q6J("channelCode",e.code),t.xp6(1),t.hij(" ",t.lcZ(4,5,e.code)," ")}}function Yi(i,n){if(1&i&&(t.ynx(0),t.YNc(1,Qi,5,7,"vdr-chip",68),t.BQk()),2&i){const e=n.$implicit,o=t.oxw(5);t.xp6(1),t.Q6J("ngIf",!o.isDefaultChannel(e.code))}}function Gi(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",13)(1,"div",64),t.YNc(2,Yi,2,1,"ng-container",65),t.TgZ(3,"button",66),t.NdJ("click",function(){t.CHM(e);const a=t.oxw(3).$implicit;return t.oxw().assignToChannel.emit(a)}),t._UZ(4,"clr-icon",67),t._uU(5),t.ALo(6,"translate"),t.qZA()()()}if(2&i){const e=t.oxw(3).$implicit;t.xp6(2),t.Q6J("ngForOf",e.channels),t.xp6(3),t.hij(" ",t.lcZ(6,2,"catalog.assign-to-channel")," ")}}function Ei(i,n){1&i&&(t.ynx(0),t.YNc(1,Gi,7,4,"div",63),t.BQk())}function ji(i,n){if(1&i){const e=t.EpF();t.ynx(0,4),t.TgZ(1,"div",5)(2,"div",6)(3,"vdr-title-input",7),t.ALo(4,"hasPermission"),t.TgZ(5,"clr-input-container"),t._UZ(6,"input",8),t.ALo(7,"hasPermission"),t.ALo(8,"translate"),t.qZA()(),t.TgZ(9,"vdr-title-input",9),t.ALo(10,"hasPermission"),t.TgZ(11,"clr-input-container"),t._UZ(12,"input",10),t.ALo(13,"hasPermission"),t.ALo(14,"translate"),t.qZA()()(),t.TgZ(15,"div",11),t.YNc(16,Oi,5,3,"clr-toggle-wrapper",12),t.qZA()(),t.TgZ(17,"div",13)(18,"div",14)(19,"div",15)(20,"vdr-assets",16),t.NdJ("change",function(a){t.CHM(e);const r=t.oxw().$implicit;return t.oxw().onAssetChange(r.id,a)}),t.qZA()(),t.TgZ(21,"div",17)(22,"div",18)(23,"div",19)(24,"div",20),t.YNc(25,Li,6,4,"clr-select-container",21),t.YNc(26,Mi,5,4,"ng-template",null,22,t.W1O),t.qZA(),t.TgZ(28,"div",23)(29,"clr-input-container")(30,"label"),t._uU(31),t.ALo(32,"translate"),t.qZA(),t.YNc(33,wi,2,4,"vdr-currency-input",24),t.YNc(34,ki,2,4,"vdr-currency-input",25),t.qZA()(),t._UZ(35,"vdr-variant-price-detail",26),t.qZA(),t.TgZ(36,"div",19),t.YNc(37,Vi,16,18,"clr-select-container",12),t.TgZ(38,"clr-input-container")(39,"label"),t._uU(40),t.ALo(41,"translate"),t._UZ(42,"vdr-help-tooltip",27),t.ALo(43,"translate"),t.qZA(),t._UZ(44,"input",28),t.ALo(45,"hasPermission"),t.qZA(),t.TgZ(46,"div")(47,"label",29),t._uU(48),t.ALo(49,"translate"),t._UZ(50,"vdr-help-tooltip",27),t.ALo(51,"translate"),t.qZA(),t.TgZ(52,"div",30),t._uU(53),t.qZA()(),t.TgZ(54,"div")(55,"label",29),t._uU(56),t.ALo(57,"translate"),t._UZ(58,"vdr-help-tooltip",27),t.ALo(59,"translate"),t.qZA(),t.TgZ(60,"div",30),t._uU(61),t.qZA()()(),t.TgZ(62,"div",19)(63,"div",31)(64,"label",29),t._uU(65),t.ALo(66,"translate"),t._UZ(67,"vdr-help-tooltip",27),t.ALo(68,"translate"),t.qZA(),t.TgZ(69,"div",32)(70,"clr-input-container"),t._UZ(71,"input",33),t.ALo(72,"hasPermission"),t.qZA(),t.TgZ(73,"clr-toggle-wrapper"),t._UZ(74,"input",34),t.ALo(75,"hasPermission"),t.TgZ(76,"label"),t._uU(77),t.ALo(78,"translate"),t.qZA()()()()()(),t.TgZ(79,"div",35)(80,"div",19),t.YNc(81,Ji,3,6,"section",36),t.qZA()()()()(),t.TgZ(82,"div",13)(83,"div",37),t._UZ(84,"vdr-entity-info",38),t.YNc(85,Di,7,9,"div",39),t._UZ(86,"div",40),t.TgZ(87,"div",41),t.YNc(88,qi,2,4,"vdr-facet-value-chip",42),t.YNc(89,Si,2,4,"vdr-facet-value-chip",42),t.YNc(90,$i,4,3,"button",43),t.qZA()()(),t.YNc(91,Ei,2,0,"ng-container",44),t.BQk()}if(2&i){const e=n.ngIf,o=t.MAs(27),a=t.oxw().$implicit,r=t.oxw();let c;t.Q6J("formGroup",e),t.xp6(3),t.Q6J("readonly",!t.lcZ(4,55,r.updatePermission)),t.xp6(3),t.Q6J("readonly",!t.lcZ(7,57,r.updatePermission))("placeholder",t.lcZ(8,59,"catalog.sku")),t.xp6(3),t.Q6J("readonly",!t.lcZ(10,61,r.updatePermission)),t.xp6(3),t.Q6J("readonly",!t.lcZ(13,63,r.updatePermission))("placeholder",t.lcZ(14,65,"common.name")),t.xp6(4),t.Q6J("vdrIfPermissions",r.updatePermission),t.xp6(4),t.Q6J("compact",!0)("assets",(null==r.pendingAssetChanges[a.id]?null:r.pendingAssetChanges[a.id].assets)||a.assets)("featuredAsset",(null==r.pendingAssetChanges[a.id]?null:r.pendingAssetChanges[a.id].featuredAsset)||a.featuredAsset)("updatePermissions",r.updatePermission),t.xp6(5),t.Q6J("vdrIfPermissions",r.updatePermission)("vdrIfPermissionsElse",o),t.xp6(6),t.Oqu(t.lcZ(32,67,"catalog.price")),t.xp6(2),t.Q6J("ngIf",!r.channelPriceIncludesTax),t.xp6(1),t.Q6J("ngIf",r.channelPriceIncludesTax),t.xp6(1),t.Q6J("price",e.get("price").value)("currencyCode",a.currencyCode)("priceIncludesTax",r.channelPriceIncludesTax)("taxCategoryId",e.get("taxCategoryId").value),t.xp6(2),t.Q6J("vdrIfPermissions",r.updatePermission),t.xp6(3),t.hij("",t.lcZ(41,69,"catalog.stock-on-hand")," "),t.xp6(2),t.Q6J("content",t.lcZ(43,71,"catalog.stock-on-hand-tooltip")),t.xp6(2),t.ekj("inventory-untracked",r.inventoryIsNotTracked(e)),t.Q6J("min",r.getStockOnHandMinValue(e))("readonly",!t.lcZ(45,73,r.updatePermission))("vdrDisabled",r.inventoryIsNotTracked(e)),t.xp6(2),t.ekj("inventory-untracked",r.inventoryIsNotTracked(e)),t.xp6(2),t.hij("",t.lcZ(49,75,"catalog.stock-allocated")," "),t.xp6(2),t.Q6J("content",t.lcZ(51,77,"catalog.stock-allocated-tooltip")),t.xp6(3),t.hij(" ",a.stockAllocated," "),t.xp6(1),t.ekj("inventory-untracked",r.inventoryIsNotTracked(e)),t.xp6(2),t.hij("",t.lcZ(57,79,"catalog.stock-saleable")," "),t.xp6(2),t.Q6J("content",t.lcZ(59,81,"catalog.stock-saleable-tooltip")),t.xp6(3),t.hij(" ",r.getSaleableStockLevel(a)," "),t.xp6(2),t.ekj("inventory-untracked",r.inventoryIsNotTracked(e)),t.xp6(2),t.Oqu(t.lcZ(66,83,"catalog.out-of-stock-threshold")),t.xp6(2),t.Q6J("content",t.lcZ(68,85,"catalog.out-of-stock-threshold-tooltip")),t.xp6(4),t.Q6J("formControl",e.get("outOfStockThreshold"))("readonly",!t.lcZ(72,87,r.updatePermission))("vdrDisabled",!1!==(null==(c=e.get("useGlobalOutOfStockThreshold"))?null:c.value)||r.inventoryIsNotTracked(e)),t.xp6(3),t.Q6J("vdrDisabled",!t.lcZ(75,89,r.updatePermission)||r.inventoryIsNotTracked(e)),t.xp6(3),t.AsE("",t.lcZ(78,91,"catalog.use-global-value")," (",r.globalOutOfStockThreshold,")"),t.xp6(4),t.Q6J("ngIf",r.customFields.length),t.xp6(3),t.Q6J("entity",a),t.xp6(1),t.Q6J("ngIf",a.options.length),t.xp6(3),t.Q6J("ngForOf",r.existingFacetValues(a)),t.xp6(1),t.Q6J("ngForOf",r.pendingFacetValues(a)),t.xp6(1),t.Q6J("vdrIfPermissions",r.updatePermission)}}function Hi(i,n){if(1&i&&(t.TgZ(0,"div",2),t.YNc(1,ji,92,93,"ng-container",3),t.qZA()),2&i){const e=n.$implicit,o=t.oxw();let a,r;t.ekj("disabled",!(null!=(a=o.formGroupMap.get(e.id))&&null!=(r=a.get("enabled"))&&r.value)),t.xp6(1),t.Q6J("ngIf",o.formGroupMap.get(e.id))}}const Bi=function(){return{itemsPerPage:10,currentPage:1}};class xt{constructor(n,e,o){this.changeDetector=n,this.modalService=e,this.dataService=o,this.assignToChannel=new t.vpe,this.removeFromChannel=new t.vpe,this.assetChange=new t.vpe,this.selectionChange=new t.vpe,this.selectFacetValueClick=new t.vpe,this.updateProductOption=new t.vpe,this.selectedVariantIds=[],this.formGroupMap=new Map,this.GlobalFlag=s.TvZ,this.updatePermission=[s.y3$.UpdateCatalog,s.y3$.UpdateProduct]}ngOnInit(){this.dataService.settings.getGlobalSettings("cache-first").single$.subscribe(({globalSettings:n})=>{this.globalTrackInventory=n.trackInventory,this.globalOutOfStockThreshold=n.outOfStockThreshold,this.changeDetector.markForCheck()}),this.subscription=this.formArray.valueChanges.subscribe(()=>this.changeDetector.markForCheck()),this.subscription.add(this.formArray.valueChanges.pipe((0,v.U)(n=>n.length),(0,$.b)(1),(0,st.x)()).subscribe(()=>{this.buildFormGroupMap()})),this.buildFormGroupMap()}ngOnChanges(n){"facets"in n&&n.facets.currentValue&&(this.facetValues=(0,s.k2u)(this.facets))}ngOnDestroy(){this.subscription&&this.subscription.unsubscribe()}isDefaultChannel(n){return n===me.z$}trackById(n,e){return e.id}inventoryIsNotTracked(n){var e;const o=null===(e=n.get("trackInventory"))||void 0===e?void 0:e.value;return o===s.TvZ.FALSE||o===s.TvZ.INHERIT&&!1===this.globalTrackInventory}getTaxCategoryName(n){const e=n.get(["taxCategoryId"]);if(e&&this.taxCategories){const o=this.taxCategories.find(a=>a.id===e.value);return o?o.name:""}return""}getStockOnHandMinValue(n){var e,o;return(null===(e=n.get("useGlobalOutOfStockThreshold"))||void 0===e?void 0:e.value)?this.globalOutOfStockThreshold:null===(o=n.get("outOfStockThreshold"))||void 0===o?void 0:o.value}getSaleableStockLevel(n){const e=n.useGlobalOutOfStockThreshold?this.globalOutOfStockThreshold:n.outOfStockThreshold;return n.stockOnHand-n.stockAllocated-e}areAllSelected(){return!!this.variants&&this.selectedVariantIds.length===this.variants.length}onAssetChange(n,e){this.assetChange.emit(Object.assign({variantId:n},e));const o=this.variants.findIndex(a=>a.id===n);this.formArray.at(o).markAsDirty()}toggleSelectAll(){this.areAllSelected()?this.selectedVariantIds=[]:this.selectedVariantIds=this.variants.map(n=>n.id),this.selectionChange.emit(this.selectedVariantIds)}toggleSelectVariant(n){const e=this.selectedVariantIds.indexOf(n);-1<e?this.selectedVariantIds.splice(e,1):this.selectedVariantIds.push(n),this.selectionChange.emit(this.selectedVariantIds)}optionGroupName(n){var e;const o=this.optionGroups.find(a=>a.id===n);if(o)return(null!==(e=null==o?void 0:o.translations.find(r=>r.languageCode===this.activeLanguage))&&void 0!==e?e:o.translations[0]).name}optionName(n){var e;return(null!==(e=n.translations.find(a=>a.languageCode===this.activeLanguage))&&void 0!==e?e:n.translations[0]).name}pendingFacetValues(n){if(this.facets){const e=this.getFacetValueIds(n.id),o=n.facetValues.map(a=>a.id);return e.filter(a=>!o.includes(a)).map(a=>this.facetValues.find(r=>r.id===a)).filter(w.notNullOrUndefined)}return[]}existingFacetValues(n){return[...this.getFacetValueIds(n.id)].filter(a=>n.facetValues.map(r=>r.id).includes(a)).map(a=>n.facetValues.find(r=>r.id===a)).filter(w.notNullOrUndefined)}removeFacetValue(n,e){const o=this.formGroupMap.get(n.id);if(o){const a=o.value.facetValueIds.filter(r=>r!==e);o.patchValue({facetValueIds:a}),o.markAsDirty()}}isVariantSelected(n){return-1<this.selectedVariantIds.indexOf(n)}editOption(n){this.modalService.fromComponent(vt,{size:"md",locals:{productOption:n,activeLanguage:this.activeLanguage,customFields:this.customOptionFields}}).subscribe(e=>{e&&this.updateProductOption.emit(e)})}buildFormGroupMap(){this.formGroupMap.clear();for(const n of this.formArray.controls)this.formGroupMap.set(n.value.id,n);this.changeDetector.markForCheck()}getFacetValueIds(n){var e;return(null===(e=this.formGroupMap.get(n))||void 0===e?void 0:e.value).facetValueIds}}xt.\u0275fac=function(n){return new(n||xt)(t.Y36(t.sBO),t.Y36(s.Z7U),t.Y36(s.DoR))},xt.\u0275cmp=t.Xpm({type:xt,selectors:[["vdr-product-variants-list"]],inputs:{formArray:["productVariantsFormArray","formArray"],variants:"variants",paginationConfig:"paginationConfig",channelPriceIncludesTax:"channelPriceIncludesTax",taxCategories:"taxCategories",facets:"facets",optionGroups:"optionGroups",customFields:"customFields",customOptionFields:"customOptionFields",activeLanguage:"activeLanguage",pendingAssetChanges:"pendingAssetChanges"},outputs:{assignToChannel:"assignToChannel",removeFromChannel:"removeFromChannel",assetChange:"assetChange",selectionChange:"selectionChange",selectFacetValueClick:"selectFacetValueClick",updateProductOption:"updateProductOption"},features:[t.TTD],decls:3,vars:6,consts:[[1,"variants-list"],["class","variant-container card",3,"disabled",4,"ngFor","ngForOf","ngForTrackBy"],[1,"variant-container","card"],[3,"formGroup",4,"ngIf"],[3,"formGroup"],[1,"card-block","header-row"],[1,"details"],[1,"sku",3,"readonly"],["clrInput","","type","text","formControlName","sku",3,"readonly","placeholder"],[1,"name",3,"readonly"],["clrInput","","type","text","formControlName","name",3,"readonly","placeholder"],[1,"right-controls"],[4,"vdrIfPermissions"],[1,"card-block"],[1,"variant-body"],[1,"assets"],[3,"compact","assets","featuredAsset","updatePermissions","change"],[1,"variant-form-inputs"],[1,"standard-fields"],[1,"variant-form-input-row"],[1,"tax-category"],[4,"vdrIfPermissions","vdrIfPermissionsElse"],["taxCategoryLabel",""],[1,"price"],["clrInput","","formControlName","price",3,"currencyCode","readonly",4,"ngIf"],["clrInput","","formControlName","priceWithTax",3,"currencyCode","readonly",4,"ngIf"],[3,"price","currencyCode","priceIncludesTax","taxCategoryId"],[3,"content"],["clrInput","","type","number","step","1","formControlName","stockOnHand",3,"min","readonly","vdrDisabled"],[1,"clr-control-label"],[1,"value"],[1,"out-of-stock-threshold-wrapper"],[1,"flex"],["clrInput","","type","number",3,"formControl","readonly","vdrDisabled"],["type","checkbox","clrToggle","","name","useGlobalOutOfStockThreshold","formControlName","useGlobalOutOfStockThreshold",3,"vdrDisabled"],[1,"custom-fields"],["formGroupName","customFields",4,"ngIf"],[1,"options-facets"],[3,"entity"],[4,"ngIf"],[1,"flex-spacer"],[1,"facets"],[3,"facetValue","removable","remove",4,"ngFor","ngForOf"],["class","btn btn-sm btn-secondary",3,"click",4,"vdrIfPermissions"],[4,"vdrIfMultichannel"],["type","checkbox","clrToggle","","name","enabled","formControlName","enabled"],["clrSelect","","name","options","formControlName","taxCategoryId"],[3,"value",4,"ngFor","ngForOf"],[3,"value"],[1,"tax-category-label"],["clrInput","","formControlName","price",3,"currencyCode","readonly"],["clrInput","","formControlName","priceWithTax",3,"currencyCode","readonly"],["clrSelect","","name","options","formControlName","trackInventory"],["formGroupName","customFields"],["entityName","ProductVariant",3,"customFields","compact","customFieldsFormGroup","readonly"],[1,"options"],[3,"colorFrom","invert","icon","iconClick",4,"ngFor","ngForOf"],[1,"btn","btn-link","btn-sm",3,"routerLink"],[3,"colorFrom","invert","icon","iconClick"],[1,"option-group-name"],[3,"facetValue","removable","remove"],[1,"btn","btn-sm","btn-secondary",3,"click"],["shape","plus"],["class","card-block",4,"vdrIfDefaultChannelActive"],[1,"flex","channel-assignment"],[4,"ngFor","ngForOf"],[1,"btn","btn-sm",3,"click"],["shape","layers"],["icon","times-circle",3,"title","iconClick",4,"ngIf"],["icon","times-circle",3,"title","iconClick"],[3,"channelCode"]],template:function(n,e){1&n&&(t.TgZ(0,"div",0),t.YNc(1,Hi,2,3,"div",1),t.ALo(2,"paginate"),t.qZA()),2&n&&(t.xp6(1),t.Q6J("ngForOf",t.xi3(2,2,e.variants,e.paginationConfig||t.DdM(5,Bi)))("ngForTrackBy",e.trackById))},directives:[C.sg,f.q0d,C.O5,l.JL,l.sg,Zi.G,f.G55,M.y,l.Fj,f.xRP,l.JJ,l.u,J.H,f.PEh,l.Wl,f.KKC,f.MgK,Y,f.dTv,l.EJ,f.otW,l.YN,l.Kr,zt.K,Ct,Fi.o,l.wV,l.qQ,Et.x,l.oH,l.x0,qt.y,kt.V,dt.Y,T.yS,Ht.q,f.qvL,ve.u,Ce.M,xe.n],pipes:[Kt._s,U.j,F.X$,Ze.U,ne.E],styles:[".with-selected[_ngcontent-%COMP%]{display:flex;min-height:52px;align-items:center;border:1px solid var(--color-component-border-100);border-radius:3px;padding:6px 18px}.with-selected[_ngcontent-%COMP%] vdr-select-toggle[_ngcontent-%COMP%]{margin-right:12px}.with-selected[_ngcontent-%COMP%] > label[_ngcontent-%COMP%]{margin-right:12px}.variant-container[_ngcontent-%COMP%]{transition:background-color .2s;min-height:330px}.variant-container.disabled[_ngcontent-%COMP%]{background-color:var(--color-component-bg-200)}.variant-container[_ngcontent-%COMP%] .header-row[_ngcontent-%COMP%]{display:flex;align-items:center;flex-wrap:wrap}.variant-container[_ngcontent-%COMP%] .variant-body[_ngcontent-%COMP%]{display:flex;flex-direction:column}@media screen and (min-width: 768px){.variant-container[_ngcontent-%COMP%] .variant-body[_ngcontent-%COMP%]{flex-direction:row}}.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;margin-right:12px}@media screen and (min-width: 768px){.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%]{flex-direction:row;height:36px}}.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%] .name[_ngcontent-%COMP%]{flex:1}.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%] .name[_ngcontent-%COMP%] .clr-control-container{width:100%}.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%] .name[_ngcontent-%COMP%] .clr-control-container input.clr-input{min-width:100%}.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%] .sku[_ngcontent-%COMP%]{width:160px;margin-right:20px;flex:0}.variant-container[_ngcontent-%COMP%] .details[_ngcontent-%COMP%] .name input{min-width:300px}.variant-container[_ngcontent-%COMP%] .right-controls[_ngcontent-%COMP%]{display:flex}.variant-container[_ngcontent-%COMP%] .tax-category-label[_ngcontent-%COMP%]{margin-top:3px}.variant-container[_ngcontent-%COMP%] .variant-form-inputs[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column}@media screen and (min-width: 768px){.variant-container[_ngcontent-%COMP%] .variant-form-inputs[_ngcontent-%COMP%]{flex-direction:row}}.variant-container[_ngcontent-%COMP%] .variant-form-input-row[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap}@media screen and (min-width: 768px){.variant-container[_ngcontent-%COMP%] .variant-form-input-row[_ngcontent-%COMP%]{margin:0 6px 8px 24px}}.variant-container[_ngcontent-%COMP%] .variant-form-input-row[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{margin-right:24px;margin-bottom:24px}.variant-container[_ngcontent-%COMP%] .track-inventory-toggle[_ngcontent-%COMP%]{margin-top:22px}.variant-container[_ngcontent-%COMP%] .clr-form-control[_ngcontent-%COMP%]{margin-top:0}.variant-container[_ngcontent-%COMP%] .facets[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center}.variant-container[_ngcontent-%COMP%] .pricing[_ngcontent-%COMP%]{display:flex}.variant-container[_ngcontent-%COMP%] .pricing[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{margin-right:12px}.variant-container[_ngcontent-%COMP%] .option-group-name[_ngcontent-%COMP%]{color:var(--color-text-200);text-transform:uppercase;font-size:10px;margin-right:3px;height:11px}.variant-container[_ngcontent-%COMP%] .options-facets[_ngcontent-%COMP%]{display:flex;color:var(--color-grey-400)}.variant-container[_ngcontent-%COMP%] .clr-control-container{width:100%}.channel-assignment[_ngcontent-%COMP%]{justify-content:flex-end}.channel-assignment[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]{margin:6px 12px 6px 0}.out-of-stock-threshold-wrapper[_ngcontent-%COMP%]{display:flex;flex-direction:column}.out-of-stock-threshold-wrapper[_ngcontent-%COMP%] clr-toggle-wrapper[_ngcontent-%COMP%]{margin-left:24px}.inventory-untracked[_ngcontent-%COMP%]{opacity:.5}"],changeDetection:0});const Ri=function(){return["product","enabled"]};function zi(i,n){if(1&i&&(t.TgZ(0,"clr-toggle-wrapper"),t._UZ(1,"input",8),t.TgZ(2,"label"),t._uU(3),t.ALo(4,"translate"),t.qZA()()),2&i){const e=t.oxw();t.xp6(1),t.Q6J("formControl",e.detailForm.get(t.DdM(4,Ri))),t.xp6(2),t.Oqu(t.lcZ(4,2,"common.enabled"))}}function Ki(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",9),t.NdJ("click",function(){return t.CHM(e),t.oxw().create()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw();t.Q6J("disabled",e.detailForm.invalid||e.detailForm.pristine||!e.variantsToCreateAreValid()),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.create")," ")}}function Wi(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",9),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).save()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw(2);t.Q6J("disabled",(e.detailForm.invalid||e.detailForm.pristine)&&!e.assetsChanged()&&!e.variantAssetsChanged()),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.update")," ")}}const B=function(){return["UpdateCatalog","UpdateProduct"]};function Xi(i,n){1&i&&t.YNc(0,Wi,3,4,"button",10),2&i&&t.Q6J("vdrIfPermissions",t.DdM(1,B))}function ta(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-chip",41),t.NdJ("iconClick",function(){t.CHM(e);const a=t.oxw().$implicit;return t.oxw(6).removeFromChannel(a.id)}),t._UZ(1,"vdr-channel-badge",42),t._uU(2),t.ALo(3,"channelCodeToLabel"),t.qZA()}if(2&i){const e=t.oxw().$implicit;t.xp6(1),t.Q6J("channelCode",e.code),t.xp6(1),t.hij(" ",t.lcZ(3,2,e.code)," ")}}function ea(i,n){if(1&i&&(t.ynx(0),t.YNc(1,ta,4,4,"vdr-chip",40),t.BQk()),2&i){const e=n.$implicit,o=t.oxw(6);t.xp6(1),t.Q6J("ngIf",!o.isDefaultChannel(e.code))}}function na(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-form-item",35),t.ALo(1,"translate"),t.TgZ(2,"div",36),t.YNc(3,ea,2,1,"ng-container",37),t.ALo(4,"async"),t.TgZ(5,"button",38),t.NdJ("click",function(){return t.CHM(e),t.oxw(5).assignToChannel()}),t._UZ(6,"clr-icon",39),t._uU(7),t.ALo(8,"translate"),t.qZA()()()}if(2&i){const e=t.oxw(5);t.Q6J("label",t.lcZ(1,3,"common.channels")),t.xp6(3),t.Q6J("ngForOf",t.lcZ(4,5,e.productChannels$)),t.xp6(4),t.hij(" ",t.lcZ(8,7,"catalog.assign-to-channel")," ")}}function oa(i,n){1&i&&(t.ynx(0),t.YNc(1,na,9,9,"vdr-form-item",34),t.BQk())}function ia(i,n){1&i&&(t.ynx(0),t.YNc(1,oa,2,0,"ng-container",33),t.BQk())}const aa=function(){return["product","customFields"]};function ra(i,n){if(1&i&&(t.TgZ(0,"section",43)(1,"label"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t._UZ(4,"vdr-tabbed-custom-fields",44),t.ALo(5,"hasPermission"),t.qZA()),2&i){const e=t.oxw(3);t.xp6(2),t.Oqu(t.lcZ(3,4,"common.custom-fields")),t.xp6(2),t.Q6J("customFields",e.customFields)("customFieldsFormGroup",e.detailForm.get(t.DdM(8,aa)))("readonly",!t.lcZ(5,6,t.DdM(9,B)))}}function ca(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-facet-value-chip",45),t.NdJ("remove",function(){const r=t.CHM(e).$implicit;return t.oxw(3).removeProductFacetValue(r.id)}),t.ALo(1,"hasPermission"),t.qZA()}if(2&i){const e=n.$implicit;t.Q6J("facetValue",e)("removable",t.lcZ(1,2,t.DdM(4,B)))}}function sa(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",46),t.NdJ("click",function(){return t.CHM(e),t.oxw(3).selectProductFacetValue()}),t._UZ(1,"clr-icon",47),t._uU(2),t.ALo(3,"translate"),t.qZA()}2&i&&(t.xp6(2),t.hij(" ",t.lcZ(3,1,"catalog.add-facets")," "))}function la(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div")(1,"h4"),t._uU(2),t.ALo(3,"translate"),t.qZA(),t.TgZ(4,"vdr-generate-product-variants",48),t.NdJ("variantsChange",function(a){t.CHM(e);return t.oxw(3).createVariantsConfig=a}),t.qZA()()}2&i&&(t.xp6(2),t.Oqu(t.lcZ(3,1,"catalog.product-variants")))}const da=function(){return["product","name"]},pa=function(i){return{pattern:i}};function ua(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"clr-tab-content")(1,"div",16)(2,"div",17)(3,"section",18),t.YNc(4,ia,2,0,"ng-container",15),t.ALo(5,"async"),t.TgZ(6,"vdr-form-field",19),t.ALo(7,"translate"),t.TgZ(8,"input",20),t.NdJ("input",function(a){return t.CHM(e),t.oxw(2).updateSlug(a.target.value)}),t.ALo(9,"hasPermission"),t.qZA()(),t.TgZ(10,"div",21),t.ALo(11,"async"),t.TgZ(12,"clr-checkbox-wrapper"),t._UZ(13,"input",22),t.TgZ(14,"label"),t._uU(15),t.ALo(16,"translate"),t.qZA()()(),t.TgZ(17,"vdr-form-field",23),t.ALo(18,"translate"),t.ALo(19,"translate"),t._UZ(20,"input",24),t.ALo(21,"hasPermission"),t.qZA(),t._UZ(22,"vdr-rich-text-editor",25),t.ALo(23,"hasPermission"),t.ALo(24,"translate"),t.YNc(25,ra,6,10,"section",26),t._UZ(26,"vdr-custom-detail-component-host",27),t.qZA()(),t.TgZ(27,"div",28)(28,"vdr-assets",29),t.NdJ("change",function(a){t.CHM(e);return t.oxw(2).assetChanges=a}),t.qZA(),t.TgZ(29,"div",30),t.YNc(30,ca,2,5,"vdr-facet-value-chip",31),t.ALo(31,"async"),t.YNc(32,sa,4,3,"button",32),t.qZA()()(),t.YNc(33,la,5,3,"div",15),t.ALo(34,"async"),t.qZA()}if(2&i){const e=t.oxw().ngIf,o=t.oxw();let a;t.xp6(4),t.Q6J("ngIf",!t.lcZ(5,20,o.isNew$)),t.xp6(2),t.Q6J("label",t.lcZ(7,22,"catalog.product-name")),t.xp6(2),t.Q6J("readonly",!t.lcZ(9,24,t.DdM(44,B))),t.xp6(2),t.ekj("visible",!1===t.lcZ(11,26,o.isNew$)&&(null==(a=o.detailForm.get(t.DdM(45,da)))?null:a.dirty)),t.xp6(5),t.Oqu(t.lcZ(16,28,"catalog.auto-update-product-variant-name")),t.xp6(2),t.Q6J("label",t.lcZ(18,30,"catalog.slug"))("errors",t.VKq(46,pa,t.lcZ(19,32,"catalog.slug-pattern-error"))),t.xp6(3),t.Q6J("readonly",!t.lcZ(21,34,t.DdM(48,B))),t.xp6(2),t.Q6J("readonly",!t.lcZ(23,36,t.DdM(49,B)))("label",t.lcZ(24,38,"common.description")),t.xp6(3),t.Q6J("ngIf",o.customFields.length),t.xp6(1),t.Q6J("entity$",o.entity$)("detailForm",o.detailForm),t.xp6(2),t.Q6J("assets",o.assetChanges.assets||e.assets)("featuredAsset",o.assetChanges.featuredAsset||e.featuredAsset)("updatePermissions",o.updatePermissions),t.xp6(2),t.Q6J("ngForOf",t.lcZ(31,40,o.facetValues$)),t.xp6(2),t.Q6J("vdrIfPermissions",t.DdM(50,B)),t.xp6(1),t.Q6J("ngIf",t.lcZ(34,42,o.isNew$))}}const ma=function(){return["./","manage-variants"]};function _a(i,n){1&i&&(t.TgZ(0,"a",65),t._UZ(1,"clr-icon",66),t._uU(2),t.ALo(3,"translate"),t.qZA()),2&i&&(t.Q6J("routerLink",t.DdM(4,ma)),t.xp6(2),t.hij(" ",t.lcZ(3,2,"catalog.manage-variants")," "))}function ga(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",67)(1,"vdr-items-per-page-controls",68),t.NdJ("itemsPerPageChange",function(a){return t.CHM(e),t.oxw(4).setItemsPerPage(a)}),t.ALo(2,"async"),t.qZA(),t.TgZ(3,"vdr-pagination-controls",69),t.NdJ("pageChange",function(a){return t.CHM(e),t.oxw(4).setPage(a)}),t.ALo(4,"async"),t.ALo(5,"async"),t.ALo(6,"async"),t.qZA()()}if(2&i){const e=t.oxw(4);let o;t.xp6(1),t.Q6J("itemsPerPage",t.lcZ(2,4,e.itemsPerPage$)),t.xp6(2),t.Q6J("id",null==(o=t.lcZ(4,6,e.paginationConfig$))?null:o.id)("currentPage",t.lcZ(5,8,e.currentPage$))("itemsPerPage",t.lcZ(6,10,e.itemsPerPage$))}}function ha(i,n){if(1&i&&(t._UZ(0,"vdr-product-variants-table",70),t.ALo(1,"async"),t.ALo(2,"async"),t.ALo(3,"async")),2&i){const e=t.oxw(3).ngIf,o=t.oxw();t.Q6J("variants",t.lcZ(1,6,o.variants$))("paginationConfig",t.lcZ(2,8,o.paginationConfig$))("optionGroups",e.optionGroups)("channelPriceIncludesTax",t.lcZ(3,10,o.channelPriceIncludesTax$))("productVariantsFormArray",o.detailForm.get("variants"))("pendingAssetChanges",o.variantAssetChanges)}}function fa(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-product-variants-list",71),t.NdJ("assignToChannel",function(a){return t.CHM(e),t.oxw(4).assignVariantToChannel(a)})("removeFromChannel",function(a){return t.CHM(e),t.oxw(4).removeVariantFromChannel(a)})("assetChange",function(a){return t.CHM(e),t.oxw(4).variantAssetChange(a)})("updateProductOption",function(a){return t.CHM(e),t.oxw(4).updateProductOption(a)})("selectionChange",function(a){t.CHM(e);return t.oxw(4).selectedVariantIds=a})("selectFacetValueClick",function(a){return t.CHM(e),t.oxw(4).selectVariantFacetValue(a)}),t.ALo(1,"async"),t.ALo(2,"async"),t.ALo(3,"async"),t.ALo(4,"async"),t.ALo(5,"async"),t.ALo(6,"async"),t.qZA()}if(2&i){const e=t.oxw(3).ngIf,o=t.oxw();t.Q6J("variants",t.lcZ(1,11,o.variants$))("paginationConfig",t.lcZ(2,13,o.paginationConfig$))("channelPriceIncludesTax",t.lcZ(3,15,o.channelPriceIncludesTax$))("facets",t.lcZ(4,17,o.facets$))("optionGroups",e.optionGroups)("productVariantsFormArray",o.detailForm.get("variants"))("taxCategories",t.lcZ(5,19,o.taxCategories$))("customFields",o.customVariantFields)("customOptionFields",o.customOptionFields)("activeLanguage",t.lcZ(6,21,o.languageCode$))("pendingAssetChanges",o.variantAssetChanges)}}function va(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",67)(1,"vdr-items-per-page-controls",68),t.NdJ("itemsPerPageChange",function(a){return t.CHM(e),t.oxw(4).setItemsPerPage(a)}),t.ALo(2,"async"),t.qZA(),t.TgZ(3,"vdr-pagination-controls",69),t.NdJ("pageChange",function(a){return t.CHM(e),t.oxw(4).setPage(a)}),t.ALo(4,"async"),t.ALo(5,"async"),t.ALo(6,"async"),t.qZA()()}if(2&i){const e=t.oxw(4);let o;t.xp6(1),t.Q6J("itemsPerPage",t.lcZ(2,4,e.itemsPerPage$)),t.xp6(2),t.Q6J("id",null==(o=t.lcZ(4,6,e.paginationConfig$))?null:o.id)("currentPage",t.lcZ(5,8,e.currentPage$))("itemsPerPage",t.lcZ(6,10,e.itemsPerPage$))}}function Ca(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"clr-tab-content")(1,"section",49)(2,"div",50)(3,"div",51)(4,"button",52),t.NdJ("click",function(){t.CHM(e);return t.oxw(3).variantDisplayMode="card"}),t._UZ(5,"clr-icon",53),t._uU(6),t.ALo(7,"translate"),t.qZA(),t.TgZ(8,"button",54),t.NdJ("click",function(){t.CHM(e);return t.oxw(3).variantDisplayMode="table"}),t._UZ(9,"clr-icon",55),t._uU(10),t.ALo(11,"translate"),t.qZA()(),t.TgZ(12,"div",56),t._UZ(13,"input",57),t.ALo(14,"translate"),t.TgZ(15,"button",58),t.NdJ("click",function(){return t.CHM(e),t.oxw(3).filterInput.setValue("")}),t._UZ(16,"clr-icon",59),t.qZA()(),t._UZ(17,"div",60),t.YNc(18,_a,4,5,"a",61),t.qZA(),t.YNc(19,ga,7,12,"div",62),t.ALo(20,"async"),t.YNc(21,ha,4,12,"vdr-product-variants-table",63),t.YNc(22,fa,7,23,"vdr-product-variants-list",64),t.qZA(),t.YNc(23,va,7,12,"div",62),t.ALo(24,"async"),t.qZA()}if(2&i){const e=t.oxw(3);let o,a;t.xp6(4),t.ekj("btn-primary","card"===e.variantDisplayMode),t.xp6(2),t.hij(" ",t.lcZ(7,13,"catalog.display-variant-cards")," "),t.xp6(2),t.ekj("btn-primary","table"===e.variantDisplayMode),t.xp6(2),t.hij(" ",t.lcZ(11,15,"catalog.display-variant-table")," "),t.xp6(3),t.Q6J("formControl",e.filterInput)("placeholder",t.lcZ(14,17,"catalog.filter-by-name-or-sku")),t.xp6(5),t.Q6J("vdrIfPermissions",t.DdM(23,B)),t.xp6(1),t.Q6J("ngIf",10<(null==(o=t.lcZ(20,19,e.paginationConfig$))?null:o.totalItems)),t.xp6(2),t.Q6J("ngIf","table"===e.variantDisplayMode),t.xp6(1),t.Q6J("ngIf","card"===e.variantDisplayMode),t.xp6(1),t.Q6J("ngIf",10<(null==(a=t.lcZ(24,21,e.paginationConfig$))?null:a.totalItems))}}function xa(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"clr-tab")(1,"button",13),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).navigateToTab("variants")}),t._uU(2),t.ALo(3,"translate"),t.qZA(),t.YNc(4,Ca,25,24,"clr-tab-content",14),t.ALo(5,"async"),t.qZA()}if(2&i){const e=t.oxw(2);t.xp6(2),t.hij(" ",t.lcZ(3,2,"catalog.product-variants")," "),t.xp6(2),t.Q6J("clrIfActive","variants"===t.lcZ(5,4,e.activeTab$))}}function ba(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"form",11),t._UZ(1,"button",12),t.TgZ(2,"clr-tabs")(3,"clr-tab")(4,"button",13),t.NdJ("click",function(){return t.CHM(e),t.oxw().navigateToTab("details")}),t._uU(5),t.ALo(6,"translate"),t.qZA(),t.YNc(7,ua,35,51,"clr-tab-content",14),t.ALo(8,"async"),t.qZA(),t.YNc(9,xa,6,6,"clr-tab",15),t.ALo(10,"async"),t.qZA()()}if(2&i){const e=t.oxw();t.Q6J("formGroup",e.detailForm),t.xp6(5),t.hij(" ",t.lcZ(6,4,"catalog.product-details")," "),t.xp6(2),t.Q6J("clrIfActive","details"===t.lcZ(8,6,e.activeTab$)),t.xp6(2),t.Q6J("ngIf",!t.lcZ(10,8,e.isNew$))}}class bt extends s.UT_{constructor(n,e,o,a,r,c,d,p,h,m){super(n,e,o,p),this.productDetailService=a,this.formBuilder=r,this.modalService=c,this.notificationService=d,this.dataService=p,this.location=h,this.changeDetector=m,this.filterInput=new l.NI(""),this.assetChanges={},this.variantAssetChanges={},this.variantFacetValueChanges={},this.currentPage$=new N.X(1),this.itemsPerPage$=new N.X(10),this.selectedVariantIds=[],this.variantDisplayMode="card",this.createVariantsConfig={groups:[],variants:[]},this.productVariantMap=new Map,this.updatePermissions=[s.y3$.UpdateCatalog,s.y3$.UpdateProduct],this.customFields=this.getCustomFieldConfig("Product"),this.customVariantFields=this.getCustomFieldConfig("ProductVariant"),this.customOptionGroupFields=this.getCustomFieldConfig("ProductOptionGroup"),this.customOptionFields=this.getCustomFieldConfig("ProductOption"),this.detailForm=this.formBuilder.group({product:this.formBuilder.group({enabled:!0,name:["",l.kI.required],autoUpdateVariantNames:!0,slug:["",(0,s.Foo)(/^[\p{Letter}0-9_-]+$/)],description:"",facetValueIds:[[]],customFields:this.formBuilder.group(this.customFields.reduce((g,x)=>Object.assign(Object.assign({},g),{[x.name]:""}),{}))}),variants:this.formBuilder.array([])})}ngOnInit(){this.init(),this.product$=this.entity$,this.totalItems$=this.product$.pipe((0,v.U)(m=>m.variantList.totalItems)),this.paginationConfig$=(0,O.a)(this.totalItems$,this.itemsPerPage$,this.currentPage$).pipe((0,v.U)(([m,g,x])=>({totalItems:m,itemsPerPage:g,currentPage:x})));this.product$.pipe((0,v.U)(m=>m.variantList.items));const e=this.filterInput.valueChanges.pipe((0,Vt.O)(""),(0,$.b)(200),(0,Jt.d)()),o=this.product$.pipe((0,v.U)(m=>m.variantList.items)),a=(0,O.a)(e,this.currentPage$,this.itemsPerPage$).pipe(function Lo(i){return(0,Fo.e)((n,e)=>{let o=!1;const a=(0,ge.x)(e,()=>{null==a||a.unsubscribe(),o=!0},Io.Z);(0,Oo.Xf)(i).subscribe(a),n.subscribe((0,ge.x)(e,r=>o&&e.next(r)))})}(o),(0,Mo.T)(1),(0,y.w)(([m,g,x])=>this.dataService.product.getProductVariants(Object.assign(Object.assign({skip:(g-1)*x,take:x},m?{filter:{name:{contains:m},sku:{contains:m}}}:{}),{filterOperator:s.FnJ.OR}),this.id).mapStream(({productVariants:b})=>b.items)),(0,Jt.d)({bufferSize:1,refCount:!0}));this.variants$=(0,_e.T)(o,a).pipe((0,K.b)(m=>{for(const g of m)this.productVariantMap.set(g.id,g)})),this.taxCategories$=this.productDetailService.getTaxCategories().pipe((0,q.R)(this.destroy$)),this.activeTab$=this.route.paramMap.pipe((0,v.U)(m=>m.get("tab"))),(0,O.a)(a,this.languageCode$).pipe((0,q.R)(this.destroy$)).subscribe(([m,g])=>{this.buildVariantFormArray(m,g)}),this.facets$=this.productDetailService.getFacets();const r=this.product$.pipe((0,v.U)(m=>m.facetValues)),c=this.facets$.pipe((0,v.U)(s.k2u)),p=this.getProductFormGroup().valueChanges.pipe((0,v.U)(m=>m.facetValueIds),(0,st.x)()),h=(0,O.a)(p,r,c).pipe((0,v.U)(([m,g,x])=>{const b=[...g,...x];return m.map(Z=>b.find(I=>I.id===Z)).filter(w.notNullOrUndefined)}));this.facetValues$=(0,_e.T)(r,h),this.productChannels$=this.product$.pipe((0,v.U)(m=>m.channels)),this.channelPriceIncludesTax$=this.dataService.settings.getActiveChannel("cache-first").refetchOnChannelChange().mapStream(m=>m.activeChannel.pricesIncludeTax).pipe((0,Jt.d)(1))}ngOnDestroy(){this.destroy()}navigateToTab(n){this.location.replaceState(this.router.createUrlTree(["./",Object.assign(Object.assign({},this.route.snapshot.params),{tab:n})],{queryParamsHandling:"merge",relativeTo:this.route}).toString())}isDefaultChannel(n){return n===me.z$}setPage(n){this.currentPage$.next(n)}setItemsPerPage(n){this.itemsPerPage$.next(+n),this.currentPage$.next(1)}assignToChannel(){this.productChannels$.pipe((0,k.q)(1),(0,y.w)(n=>this.modalService.fromComponent(X,{size:"lg",locals:{productIds:[this.id],currentChannelIds:n.map(e=>e.id)}}))).subscribe()}removeFromChannel(n){this.modalService.dialog({title:(0,_.J)("catalog.remove-product-from-channel"),buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("catalog.remove-from-channel"),returnValue:!0}]}).pipe((0,y.w)(e=>e?this.dataService.product.removeProductsFromChannel({channelId:n,productIds:[this.id]}):D.E)).subscribe(()=>{this.notificationService.success((0,_.J)("catalog.notify-remove-product-from-channel-success"))},e=>{this.notificationService.error((0,_.J)("catalog.notify-remove-product-from-channel-error"))})}assignVariantToChannel(n){return this.modalService.fromComponent(X,{size:"lg",locals:{productIds:[this.id],productVariantIds:[n.id],currentChannelIds:n.channels.map(e=>e.id)}}).subscribe()}removeVariantFromChannel({channelId:n,variant:e}){this.modalService.dialog({title:(0,_.J)("catalog.remove-product-variant-from-channel"),buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("catalog.remove-from-channel"),returnValue:!0}]}).pipe((0,y.w)(o=>o?this.dataService.product.removeVariantsFromChannel({channelId:n,productVariantIds:[e.id]}):D.E)).subscribe(()=>{this.notificationService.success((0,_.J)("catalog.notify-remove-variant-from-channel-success"))},o=>{this.notificationService.error((0,_.J)("catalog.notify-remove-variant-from-channel-error"))})}assetsChanged(){return!!Object.values(this.assetChanges).length}variantAssetsChanged(){return!!Object.keys(this.variantAssetChanges).length}variantAssetChange(n){this.variantAssetChanges[n.variantId]=n}updateSlug(n){(0,O.a)(this.entity$,this.languageCode$).pipe((0,k.q)(1)).subscribe(([e,o])=>{const a=this.detailForm.get(["product","slug"]),r=(0,s.ZIM)(e,o),c=!r||!r.slug;a&&a.pristine&&c&&a.setValue((0,z.U)(`${n}`,"-"))})}selectProductFacetValue(){this.displayFacetValueModal().subscribe(n=>{if(n){const e=this.getProductFormGroup(),o=e.value.facetValueIds;e.patchValue({facetValueIds:(0,St.T)([...o,...n])}),e.markAsDirty()}})}updateProductOption(n){(0,O.a)(this.product$,this.languageCode$).pipe((0,k.q)(1),(0,P.z)(([e,o])=>this.productDetailService.updateProductOption(n,e,o))).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-update-success"),{entity:"ProductOption"})},e=>{this.notificationService.error((0,_.J)("common.notify-update-error"),{entity:"ProductOption"})})}removeProductFacetValue(n){const e=this.getProductFormGroup(),o=e.value.facetValueIds;e.patchValue({facetValueIds:o.filter(a=>a!==n)}),e.markAsDirty()}selectVariantFacetValue(n){this.displayFacetValueModal().pipe((0,he.M)(this.variants$)).subscribe(([e,o])=>{if(e){for(const a of n){const r=o.findIndex(h=>h.id===a),c=o[r],d=c?c.facetValues.map(h=>h.id):[],p=this.detailForm.get("variants").controls.find(h=>h.value.id===a);if(p){const h=(0,St.T)([...d,...e]);p.patchValue({facetValueIds:h}),p.markAsDirty(),this.variantFacetValueChanges[a]=h}}this.changeDetector.markForCheck()}})}variantsToCreateAreValid(){return 0<this.createVariantsConfig.variants.length&&this.createVariantsConfig.variants.every(n=>""!==n.sku)}displayFacetValueModal(){return this.productDetailService.getFacets().pipe((0,P.z)(n=>this.modalService.fromComponent(gt,{size:"md",closable:!0,locals:{facets:n}})),(0,v.U)(n=>n&&n.map(e=>e.id)))}create(){const n=this.getProductFormGroup();!n.dirty||(0,O.a)(this.product$,this.languageCode$).pipe((0,k.q)(1),(0,P.z)(([e,o])=>{const a=this.getUpdatedProduct(e,n,o);return this.productDetailService.createProductWithVariants(a,this.createVariantsConfig,o)})).subscribe(({createProductVariants:e,productId:o})=>{this.notificationService.success((0,_.J)("common.notify-create-success"),{entity:"Product"}),this.assetChanges={},this.variantAssetChanges={},this.detailForm.markAsPristine(),this.router.navigate(["../",o],{relativeTo:this.route})},e=>{console.error(e),this.notificationService.error((0,_.J)("common.notify-create-error"),{entity:"Product"})})}save(){(0,O.a)(this.product$,this.languageCode$,this.channelPriceIncludesTax$).pipe((0,k.q)(1),(0,P.z)(([n,e,o])=>{var a,r;const c=this.getProductFormGroup();let d,p;(c.dirty||this.assetsChanged())&&(d=this.getUpdatedProduct(n,c,e));const h=this.detailForm.get("variants");return(h&&h.dirty||this.variantAssetsChanged())&&(p=this.getUpdatedProductVariants(n,h,e,o)),this.productDetailService.updateProduct({product:n,languageCode:e,autoUpdate:null!==(r=null===(a=this.detailForm.get(["product","autoUpdateVariantNames"]))||void 0===a?void 0:a.value)&&void 0!==r&&r,productInput:d,variantsInput:p})})).subscribe(n=>{this.updateSlugAfterSave(n),this.detailForm.markAsPristine(),this.assetChanges={},this.variantAssetChanges={},this.notificationService.success((0,_.J)("common.notify-update-success"),{entity:"Product"}),this.changeDetector.markForCheck()},n=>{this.notificationService.error((0,_.J)("common.notify-update-error"),{entity:"Product"})})}canDeactivate(){return super.canDeactivate()&&!this.assetChanges.assets&&!this.assetChanges.featuredAsset}setFormValues(n,e){const o=(0,s.ZIM)(n,e);this.detailForm.patchValue({product:{enabled:n.enabled,name:o?o.name:"",slug:o?o.slug:"",description:o?o.description:"",facetValueIds:n.facetValues.map(a=>a.id)}}),this.customFields.length&&this.setCustomFieldFormValues(this.customFields,this.detailForm.get(["product","customFields"]),n,o),this.buildVariantFormArray(n.variantList.items,e)}buildVariantFormArray(n,e){const o=this.detailForm.get("variants");n.forEach((a,r)=>{const c=(0,s.ZIM)(a,e),p=this.variantFacetValueChanges[a.id]||a.facetValues.map(g=>g.id),h={id:a.id,enabled:a.enabled,sku:a.sku,name:c?c.name:"",price:a.price,priceWithTax:a.priceWithTax,taxCategoryId:a.taxCategory.id,stockOnHand:a.stockOnHand,useGlobalOutOfStockThreshold:a.useGlobalOutOfStockThreshold,outOfStockThreshold:a.outOfStockThreshold,trackInventory:a.trackInventory,facetValueIds:p};let m=o.controls.find(g=>g.value.id===a.id);if(m?m.pristine&&m.patchValue(h):(m=this.formBuilder.group(Object.assign(Object.assign({},h),{facetValueIds:this.formBuilder.control(p)})),o.insert(r,m)),this.customVariantFields.length){let g=m.get(["customFields"]);g||(g=this.formBuilder.group(this.customVariantFields.reduce((x,b)=>Object.assign(Object.assign({},x),{[b.name]:""}),{})),m.addControl("customFields",g)),this.setCustomFieldFormValues(this.customVariantFields,g,a,c)}})}getUpdatedProduct(n,e,o){var a,r;const c=(0,s.iSy)({translatable:n,updatedFields:e.value,customFieldConfig:this.customFields,languageCode:o,defaultTranslation:{languageCode:o,name:n.name||"",slug:n.slug||"",description:n.description||""}});return Object.assign(Object.assign({},c),{assetIds:null===(a=this.assetChanges.assets)||void 0===a?void 0:a.map(d=>d.id),featuredAssetId:null===(r=this.assetChanges.featuredAsset)||void 0===r?void 0:r.id,facetValueIds:e.value.facetValueIds})}getUpdatedProductVariants(n,e,o,a){const r=e.controls.filter(p=>p.dirty),c=r.map(p=>this.productVariantMap.get(p.value.id)).filter(w.notNullOrUndefined),d=r.map(p=>p.value);if(c.length!==d.length)throw new Error((0,_.J)("error.product-variant-form-values-do-not-match"));return c.map((p,h)=>{var m,g;const x=d.find(I=>I.id===p.id),b=(0,s.iSy)({translatable:p,updatedFields:x,customFieldConfig:this.customVariantFields,languageCode:o,defaultTranslation:{languageCode:o,name:""}});b.taxCategoryId=x.taxCategoryId,b.facetValueIds=x.facetValueIds,b.price=a?x.priceWithTax:x.price;const Z=this.variantAssetChanges[p.id];return Z&&(b.featuredAssetId=null===(m=Z.featuredAsset)||void 0===m?void 0:m.id,b.assetIds=null===(g=Z.assets)||void 0===g?void 0:g.map(I=>I.id)),b}).filter(w.notNullOrUndefined)}getProductFormGroup(){return this.detailForm.get("product")}updateSlugAfterSave(n){const e=n[0],o=this.detailForm.get(["product","slug"]);o&&function a(r){return r.hasOwnProperty("updateProduct")}(e)&&o.setValue(e.updateProduct.slug,{emitEvent:!1})}}bt.\u0275fac=function(n){return new(n||bt)(t.Y36(T.gz),t.Y36(T.F0),t.Y36(s.iHG),t.Y36(j),t.Y36(l.qu),t.Y36(s.Z7U),t.Y36(s.gqp),t.Y36(s.DoR),t.Y36(C.Ye),t.Y36(t.sBO))},bt.\u0275cmp=t.Xpm({type:bt,selectors:[["vdr-product-detail"]],features:[t.qOj],decls:18,vars:21,consts:[[1,"flex","clr-flex-row"],[3,"entity"],[4,"vdrIfPermissions"],[3,"disabled","availableLanguageCodes","currentLanguageCode","languageCodeChange"],["locationId","product-detail"],["class","btn btn-primary",3,"disabled","click",4,"ngIf","ngIfElse"],["updateButton",""],["class","form",3,"formGroup",4,"ngIf"],["type","checkbox","clrToggle","","name","enabled",3,"formControl"],[1,"btn","btn-primary",3,"disabled","click"],["class","btn btn-primary",3,"disabled","click",4,"vdrIfPermissions"],[1,"form",3,"formGroup"],["type","submit","hidden","","x-data","prevents enter key from triggering other buttons"],["clrTabLink","",3,"click"],[4,"clrIfActive"],[4,"ngIf"],[1,"clr-row"],[1,"clr-col"],["formGroupName","product",1,"form-block"],["for","name",3,"label"],["id","name","type","text","formControlName","name",3,"readonly","input"],[1,"auto-rename-wrapper"],["clrCheckbox","","type","checkbox","id","auto-update","formControlName","autoUpdateVariantNames"],["for","slug",3,"label","errors"],["id","slug","type","text","formControlName","slug",3,"readonly"],["formControlName","description",3,"readonly","label"],["formGroupName","customFields",4,"ngIf"],["locationId","product-detail",3,"entity$","detailForm"],[1,"clr-col-md-auto"],[3,"assets","featuredAsset","updatePermissions","change"],[1,"facets"],[3,"facetValue","removable","remove",4,"ngFor","ngForOf"],["class","btn btn-sm btn-secondary",3,"click",4,"vdrIfPermissions"],[4,"vdrIfMultichannel"],[3,"label",4,"vdrIfDefaultChannelActive"],[3,"label"],[1,"flex","channel-assignment"],[4,"ngFor","ngForOf"],[1,"btn","btn-sm",3,"click"],["shape","layers"],["icon","times-circle",3,"iconClick",4,"ngIf"],["icon","times-circle",3,"iconClick"],[3,"channelCode"],["formGroupName","customFields"],["entityName","Product",3,"customFields","customFieldsFormGroup","readonly"],[3,"facetValue","removable","remove"],[1,"btn","btn-sm","btn-secondary",3,"click"],["shape","plus"],[3,"variantsChange"],[1,"form-block"],[1,"view-mode"],[1,"btn-group"],[1,"btn","btn-secondary-outline",3,"click"],["shape","list"],[1,"btn",3,"click"],["shape","table"],[1,"variant-filter"],[3,"formControl","placeholder"],[1,"icon-button",3,"click"],["shape","times"],[1,"flex-spacer"],["class","btn btn-secondary edit-variants-btn",3,"routerLink",4,"vdrIfPermissions"],["class","pagination-row mt4",4,"ngIf"],[3,"variants","paginationConfig","optionGroups","channelPriceIncludesTax","productVariantsFormArray","pendingAssetChanges",4,"ngIf"],[3,"variants","paginationConfig","channelPriceIncludesTax","facets","optionGroups","productVariantsFormArray","taxCategories","customFields","customOptionFields","activeLanguage","pendingAssetChanges","assignToChannel","removeFromChannel","assetChange","updateProductOption","selectionChange","selectFacetValueClick",4,"ngIf"],[1,"btn","btn-secondary","edit-variants-btn",3,"routerLink"],["shape","add-text"],[1,"pagination-row","mt4"],[3,"itemsPerPage","itemsPerPageChange"],[3,"id","currentPage","itemsPerPage","pageChange"],[3,"variants","paginationConfig","optionGroups","channelPriceIncludesTax","productVariantsFormArray","pendingAssetChanges"],[3,"variants","paginationConfig","channelPriceIncludesTax","facets","optionGroups","productVariantsFormArray","taxCategories","customFields","customOptionFields","activeLanguage","pendingAssetChanges","assignToChannel","removeFromChannel","assetChange","updateProductOption","selectionChange","selectFacetValueClick"]],template:function(n,e){if(1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left")(2,"div",0),t._UZ(3,"vdr-entity-info",1),t.ALo(4,"async"),t.YNc(5,zi,5,5,"clr-toggle-wrapper",2),t.qZA(),t.TgZ(6,"vdr-language-selector",3),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(7,"async"),t.ALo(8,"async"),t.ALo(9,"async"),t.qZA()(),t.TgZ(10,"vdr-ab-right"),t._UZ(11,"vdr-action-bar-items",4),t.YNc(12,Ki,3,4,"button",5),t.ALo(13,"async"),t.YNc(14,Xi,1,2,"ng-template",null,6,t.W1O),t.qZA()(),t.YNc(16,ba,11,10,"form",7),t.ALo(17,"async")),2&n){const o=t.MAs(15);t.xp6(3),t.Q6J("entity",t.lcZ(4,8,e.entity$)),t.xp6(2),t.Q6J("vdrIfPermissions",t.DdM(20,B)),t.xp6(1),t.Q6J("disabled",t.lcZ(7,10,e.isNew$))("availableLanguageCodes",t.lcZ(8,12,e.availableLanguages$))("currentLanguageCode",t.lcZ(9,14,e.languageCode$)),t.xp6(6),t.Q6J("ngIf",t.lcZ(13,16,e.isNew$))("ngIfElse",o),t.xp6(4),t.Q6J("ngIf",t.lcZ(17,18,e.product$))}},directives:[A.Kk,A.BN,kt.V,J.H,f.PEh,M.y,l.Wl,f.KKC,l.JJ,l.oH,f.MgK,ot.S,A.mz,R.W,C.O5,l._Y,l.JL,l.sg,f.gKI,f.dl,f.S4y,f.Iq$,f.Qs7,f.tam,f.UkA,l.x0,ve.u,Ce.M,Xo.J,C.sg,dt.Y,xe.n,f.qvL,Dt.h,l.Fj,l.u,pe.Y,qt.y,Wt.C,Y,Ht.q,ht,T.yS,le.w,de.L,ft,xt],pipes:[C.Ov,F.X$,ne.E,U.j],styles:["[_nghost-%COMP%] trix-toolbar{top:24px}.facets[_ngcontent-%COMP%]{margin-top:12px;display:flex;flex-wrap:wrap;align-items:center}@media screen and (min-width: 768px){.facets[_ngcontent-%COMP%]{max-width:340px}}vdr-action-bar[_ngcontent-%COMP%] clr-toggle-wrapper[_ngcontent-%COMP%]{margin-top:12px}.variant-filter[_ngcontent-%COMP%]{flex:1;display:flex}.variant-filter[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{flex:1;max-width:initial;border-radius:3px 0 0 3px!important}.variant-filter[_ngcontent-%COMP%] .icon-button[_ngcontent-%COMP%]{border:1px solid var(--color-component-border-300);background-color:var(--color-component-bg-100);border-radius:0 3px 3px 0;border-left:none}.group-name[_ngcontent-%COMP%]{padding-right:6px}.view-mode[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;align-items:center}.edit-variants-btn[_ngcontent-%COMP%]{margin-top:0}.channel-assignment[_ngcontent-%COMP%]{flex-wrap:wrap}.auto-rename-wrapper[_ngcontent-%COMP%]{overflow:hidden;max-height:0;padding-left:9.5rem;margin-bottom:0;transition:max-height .2s,margin-bottom .2s}.auto-rename-wrapper.visible[_ngcontent-%COMP%]{max-height:24px;margin-bottom:12px}.pagination-row[_ngcontent-%COMP%]{display:flex;align-items:baseline;justify-content:space-between}"],changeDetection:0});var Te=u(6441),$t=u(8660);const Za=["selectComponent"];function Ta(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",6),t.NdJ("click",function(){return t.CHM(e),t.oxw(2),t.MAs(1).selectTag()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw(2),o=t.MAs(1);t.ekj("selected",e.isSearchHeaderSelected()),t.xp6(1),t.AsE(" ",t.lcZ(2,4,"catalog.search-for-term"),": ",o.searchTerm," ")}}function Aa(i,n){if(1&i&&t.YNc(0,Ta,3,6,"div",5),2&i){t.oxw();const e=t.MAs(1);t.Q6J("ngIf",e.searchTerm)}}function Pa(i,n){if(1&i){const e=t.EpF();t.ynx(0),t.TgZ(1,"vdr-facet-value-chip",8),t.NdJ("remove",function(){t.CHM(e);const a=t.oxw(),r=a.item;return a.clear(r)}),t.qZA(),t.BQk()}if(2&i){const e=t.oxw().item;t.xp6(1),t.Q6J("facetValue",e.facetValue)("removable",!0)}}function ya(i,n){if(1&i){const e=t.EpF();t.ynx(0),t.TgZ(1,"vdr-chip",9),t.NdJ("iconClick",function(){t.CHM(e);const a=t.oxw(),r=a.item;return a.clear(r)}),t._uU(2),t.qZA(),t.BQk()}if(2&i){const e=t.oxw().item;t.xp6(1),t.Q6J("icon","times"),t.xp6(1),t.hij('"',e.label,'"')}}function Fa(i,n){if(1&i&&(t.YNc(0,Pa,2,2,"ng-container",7),t.YNc(1,ya,3,2,"ng-container",7)),2&i){const e=n.item;t.Q6J("ngIf",e.facetValue),t.xp6(1),t.Q6J("ngIf",!e.facetValue)}}function Oa(i,n){if(1&i&&(t.ynx(0),t._UZ(1,"vdr-facet-value-chip",10),t.BQk()),2&i){const e=t.oxw().item;t.xp6(1),t.Q6J("facetValue",e.facetValue)("removable",!1)}}function Ia(i,n){if(1&i&&t.YNc(0,Oa,2,2,"ng-container",7),2&i){const e=n.item;t.Q6J("ngIf",e.facetValue)}}class Zt{constructor(){this.searchTermChange=new t.vpe,this.facetValueChange=new t.vpe,this.lastTerm="",this.lastFacetValueIds=[],this.filterFacetResults=(n,e)=>{if(!this.isFacetValueItem(e))return!1;const o=n.indexOf(":"),a=o>-1?n.toLowerCase().slice(0,o):null,r=o>-1?n.toLowerCase().slice(o+1):n.toLowerCase();return a?e.facetValue.facet.name.toLowerCase().includes(a)&&e.facetValue.name.toLocaleLowerCase().includes(r):e.facetValue.name.toLowerCase().includes(n.toLowerCase())||e.facetValue.facet.name.toLowerCase().includes(n.toLowerCase())},this.isFacetValueItem=n=>"object"==typeof n&&!!n&&n.hasOwnProperty("facetValue")}setSearchTerm(n){if(n)this.selectComponent.select({label:n,value:{label:n}});else{const e=this.selectComponent.selectedItems.find(o=>!this.isFacetValueItem(o.value));e&&this.selectComponent.unselect(e)}}setFacetValues(n){const e=this.selectComponent.items;this.selectComponent.selectedItems.forEach(o=>{this.isFacetValueItem(o.value)&&!n.includes(o.value.facetValue.id)&&this.selectComponent.unselect(o)}),n.map(o=>null==e?void 0:e.find(a=>this.isFacetValueItem(a)&&a.facetValue.id===o)).filter(w.notNullOrUndefined).forEach(o=>{this.selectComponent.selectedItems.find(r=>{const c=r.value;return!!this.isFacetValueItem(c)&&c.facetValue.id===o.facetValue.id})||this.selectComponent.select({label:"",value:o})})}onSelectChange(n){Array.isArray(n)||(n=[n]);const e=n.find(r=>!this.isFacetValueItem(r)),o=e?e.label:"",a=n.filter(this.isFacetValueItem).map(r=>r.facetValue.id);o!==this.lastTerm&&(this.searchTermChange.emit(o),this.lastTerm=o),this.lastFacetValueIds.join(",")!==a.join(",")&&(this.facetValueChange.emit(a),this.lastFacetValueIds=a)}addTagFn(n){return{label:n}}isSearchHeaderSelected(){return-1===this.selectComponent.itemsList.markedIndex}}Zt.\u0275fac=function(n){return new(n||Zt)},Zt.\u0275cmp=t.Xpm({type:Zt,selectors:[["vdr-product-search-input"]],viewQuery:function(n,e){if(1&n&&t.Gf(Za,7),2&n){let o;t.iGM(o=t.CRH())&&(e.selectComponent=o.first)}},inputs:{facetValueResults:"facetValueResults"},outputs:{searchTermChange:"searchTermChange",facetValueChange:"facetValueChange"},features:[t._Bn([{provide:$t.w8,useValue:s.cKx}])],decls:6,vars:9,consts:[[3,"addTag","placeholder","items","searchFn","hideSelected","multiple","markFirst","change"],["selectComponent",""],["ng-header-tmp",""],["ng-label-tmp",""],["ng-option-tmp",""],["class","search-header",3,"selected","click",4,"ngIf"],[1,"search-header",3,"click"],[4,"ngIf"],[3,"facetValue","removable","remove"],[3,"icon","iconClick"],[3,"facetValue","removable"]],template:function(n,e){1&n&&(t.TgZ(0,"ng-select",0,1),t.NdJ("change",function(a){return e.onSelectChange(a)}),t.ALo(2,"translate"),t.YNc(3,Aa,1,1,"ng-template",2),t.YNc(4,Fa,2,2,"ng-template",3),t.YNc(5,Ia,1,1,"ng-template",4),t.qZA()),2&n&&t.Q6J("addTag",e.addTagFn)("placeholder",t.lcZ(2,7,"catalog.search-product-name-or-code"))("items",e.facetValueResults)("searchFn",e.filterFacetResults)("hideSelected",!0)("multiple",!0)("markFirst",!1)},directives:[$t.w9,$t.Cm,C.O5,$t.mR,Ht.q,dt.Y,$t.ir],pipes:[F.X$],styles:["[_nghost-%COMP%]{margin-top:6px;display:block;width:100%}[_nghost-%COMP%] .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value{background:none;margin:0}[_nghost-%COMP%] .ng-dropdown-panel-items div.ng-option:last-child{display:none}[_nghost-%COMP%] .ng-dropdown-panel .ng-dropdown-header{border:none;padding:0}[_nghost-%COMP%] .ng-select.ng-select-multiple .ng-select-container .ng-value-container{padding:0}[_nghost-%COMP%] .ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-placeholder{padding-left:8px}ng-select[_ngcontent-%COMP%]{width:100%;min-width:300px;margin-right:12px}.search-header[_ngcontent-%COMP%]{padding:8px 10px;border-bottom:1px solid var(--color-component-border-100);cursor:pointer}.search-header.selected[_ngcontent-%COMP%], .search-header[_ngcontent-%COMP%]:hover{background-color:var(--color-component-bg-200)}"],changeDetection:0});var La=u(809);const Ma=["productSearchInputComponent"];function wa(i,n){1&i&&t._UZ(0,"vdr-status-badge",19)}const Ae=function(){return["UpdateCatalog","UpdateProduct"]},ka=function(i){return{count:i}};function Va(i,n){if(1&i){const e=t.EpF();t.ynx(0),t.TgZ(1,"button",20),t.NdJ("click",function(){return t.CHM(e),t.oxw().runPendingSearchIndexUpdates()}),t.ALo(2,"hasPermission"),t._UZ(3,"vdr-status-badge",19),t._uU(4),t.ALo(5,"translate"),t.qZA(),t._UZ(6,"div",21),t.BQk()}if(2&i){const e=t.oxw();t.xp6(1),t.Q6J("disabled",!t.lcZ(2,2,t.DdM(7,Ae))),t.xp6(3),t.hij(" ",t.xi3(5,4,"catalog.run-pending-search-index-updates",t.VKq(8,ka,e.pendingSearchIndexUpdates))," ")}}const Ja=function(){return["./create"]};function Ua(i,n){1&i&&(t.TgZ(0,"a",22),t._UZ(1,"clr-icon",23),t.TgZ(2,"span",24),t._uU(3),t.ALo(4,"translate"),t.qZA()()),2&i&&(t.Q6J("routerLink",t.DdM(4,Ja)),t.xp6(3),t.Oqu(t.lcZ(4,2,"catalog.create-new-product")))}function Na(i,n){if(1&i&&(t._UZ(0,"img",36),t.ALo(1,"assetPreview")),2&i){const e=n.ngIf;t.Q6J("src",t.xi3(1,1,e,"tiny"),t.LSH)}}function Da(i,n){1&i&&(t.TgZ(0,"div",37),t._UZ(1,"clr-icon",38),t.qZA())}function qa(i,n){1&i&&(t.TgZ(0,"vdr-chip"),t._uU(1),t.ALo(2,"translate"),t.qZA()),2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,1,"common.disabled")))}const Sa=function(i){return["./",i]},$a=function(){return["DeleteCatalog","DeleteProduct"]};function Qa(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"td",25)(1,"div",26),t.YNc(2,Na,2,4,"img",27),t.YNc(3,Da,2,0,"ng-template",null,28,t.W1O),t.qZA()(),t.TgZ(5,"td",25),t._uU(6),t.qZA(),t.TgZ(7,"td",29),t.YNc(8,qa,3,3,"vdr-chip",10),t.qZA(),t.TgZ(9,"td",30),t._UZ(10,"vdr-table-row-action",31),t.ALo(11,"translate"),t.qZA(),t.TgZ(12,"td",30)(13,"vdr-dropdown")(14,"button",32),t._uU(15),t.ALo(16,"translate"),t._UZ(17,"clr-icon",33),t.qZA(),t.TgZ(18,"vdr-dropdown-menu",8)(19,"button",34),t.NdJ("click",function(){const r=t.CHM(e).item;return t.oxw().deleteProduct(r.productId)}),t.ALo(20,"hasPermission"),t._UZ(21,"clr-icon",35),t._uU(22),t.ALo(23,"translate"),t.qZA()()()()}if(2&i){const e=n.item,o=t.MAs(4),a=t.oxw();t.ekj("disabled",!e.enabled),t.xp6(2),t.Q6J("ngIf",a.groupByProduct?e.productAsset:e.productVariantAsset||e.productAsset)("ngIfElse",o),t.xp6(3),t.ekj("disabled",!e.enabled),t.xp6(1),t.hij(" ",a.groupByProduct?e.productName:e.productVariantName," "),t.xp6(1),t.ekj("disabled",!e.enabled),t.xp6(1),t.Q6J("ngIf",!e.enabled),t.xp6(1),t.ekj("disabled",!e.enabled),t.xp6(1),t.Q6J("label",t.lcZ(11,19,"common.edit"))("linkTo",t.VKq(27,Sa,e.productId)),t.xp6(2),t.ekj("disabled",!e.enabled),t.xp6(3),t.hij(" ",t.lcZ(16,21,"common.actions")," "),t.xp6(4),t.Q6J("disabled",!t.lcZ(20,23,t.DdM(29,$a))),t.xp6(3),t.hij(" ",t.lcZ(23,25,"common.delete")," ")}}const Ya=function(){return["CreateCatalog","CreateProduct"]};class Tt extends s.t7C{constructor(n,e,o,a,r,c,d){super(c,d),this.dataService=n,this.modalService=e,this.notificationService=o,this.jobQueueService=a,this.serverConfigService=r,this.searchTerm="",this.facetValueIds=[],this.groupByProduct=!0,this.pendingSearchIndexUpdates=0,this.route.queryParamMap.pipe((0,v.U)(p=>p.get("q")),(0,q.R)(this.destroy$)).subscribe(p=>{this.searchTerm=p||"",this.productSearchInput&&this.productSearchInput.setSearchTerm(p)}),this.selectedFacetValueIds$=this.route.queryParamMap.pipe((0,v.U)(p=>p.getAll("fvids"))),this.selectedFacetValueIds$.pipe((0,q.R)(this.destroy$)).subscribe(p=>{this.facetValueIds=p,this.productSearchInput&&this.productSearchInput.setFacetValues(p)}),super.setQueryFn((...p)=>this.dataService.product.searchProducts(this.searchTerm,...p).refetchOnChannelChange(),p=>p.search,(p,h)=>({input:{skip:p,take:h,term:this.searchTerm,facetValueIds:this.facetValueIds,facetValueOperator:s.FnJ.AND,groupByProduct:this.groupByProduct}}))}ngOnInit(){super.ngOnInit(),this.facetValues$=this.result$.pipe((0,v.U)(n=>n.search.facetValues)),this.facetValues$.pipe((0,k.q)(1),(0,Te.g)(100),(0,he.M)(this.selectedFacetValueIds$)).subscribe(([n,e])=>{this.productSearchInput.setFacetValues(e)}),this.availableLanguages$=this.serverConfigService.getAvailableLanguages(),this.contentLanguage$=this.dataService.client.uiState().mapStream(({uiState:n})=>n.contentLanguage).pipe((0,K.b)(()=>this.refresh())),this.dataService.product.getPendingSearchIndexUpdates().mapSingle(({pendingSearchIndexUpdates:n})=>n).subscribe(n=>this.pendingSearchIndexUpdates=n)}ngAfterViewInit(){this.productSearchInput&&this.searchTerm&&setTimeout(()=>this.productSearchInput.setSearchTerm(this.searchTerm))}setSearchTerm(n){this.searchTerm=n,this.setQueryParam({q:n||null,page:1}),this.refresh()}setFacetValueIds(n){this.facetValueIds=n,this.setQueryParam({fvids:n,page:1}),this.refresh()}rebuildSearchIndex(){this.dataService.product.reindex().subscribe(({reindex:n})=>{this.notificationService.info((0,_.J)("catalog.reindexing")),this.jobQueueService.addJob(n.id,e=>{if(e.state===s.Zyh.COMPLETED){const o=(new Intl.NumberFormat).format(e.duration||0);this.notificationService.success((0,_.J)("catalog.reindex-successful"),{count:e.result.indexedItemCount,time:o}),this.refresh()}else this.notificationService.error((0,_.J)("catalog.reindex-error"))})})}runPendingSearchIndexUpdates(){this.dataService.product.runPendingSearchIndexUpdates().subscribe(n=>{this.notificationService.info((0,_.J)("catalog.running-search-index-updates"),{count:this.pendingSearchIndexUpdates}),this.pendingSearchIndexUpdates=0})}deleteProduct(n){this.modalService.dialog({title:(0,_.J)("catalog.confirm-delete-product"),buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("common.delete"),returnValue:!0}]}).pipe((0,y.w)(e=>e?this.dataService.product.deleteProduct(n):D.E),(0,Te.g)(500)).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-delete-success"),{entity:"Product"}),this.refresh()},e=>{this.notificationService.error((0,_.J)("common.notify-delete-error"),{entity:"Product"})})}setLanguage(n){this.dataService.client.setContentLanguage(n).subscribe()}}function Ga(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",6),t.NdJ("click",function(){return t.CHM(e),t.oxw().save()}),t._uU(1),t.ALo(2,"translate"),t.qZA()}if(2&i){const e=t.oxw();t.Q6J("disabled",e.detailForm.pristine||e.detailForm.invalid),t.xp6(1),t.hij(" ",t.lcZ(2,2,"common.update")," ")}}function Ea(i,n){if(1&i&&(t.TgZ(0,"tr",22)(1,"td",23),t._UZ(2,"vdr-entity-info",13),t.qZA(),t.TgZ(3,"td",23),t._UZ(4,"input",24),t.ALo(5,"hasPermission"),t.qZA(),t.TgZ(6,"td",23),t._UZ(7,"input",25),t.qZA()()),2&i){const e=n.$implicit,o=n.index,a=t.oxw(3);t.Q6J("formGroupName",o),t.xp6(2),t.Q6J("entity",e.value),t.xp6(2),t.Q6J("readonly",!t.lcZ(5,3,a.updatePermission))}}function ja(i,n){if(1&i&&(t.TgZ(0,"div",10)(1,"section",11)(2,"div",12),t._UZ(3,"vdr-entity-info",13),t.TgZ(4,"div",14),t._uU(5),t.qZA()(),t.TgZ(6,"div",15)(7,"vdr-form-field",16),t.ALo(8,"translate"),t._UZ(9,"input",17),t.ALo(10,"hasPermission"),t.qZA(),t.TgZ(11,"vdr-form-field",18),t.ALo(12,"translate"),t._UZ(13,"input",19),t.ALo(14,"hasPermission"),t.qZA()(),t.TgZ(15,"section",15)(16,"table",20)(17,"thead")(18,"tr"),t._UZ(19,"th"),t.TgZ(20,"th"),t._uU(21),t.ALo(22,"translate"),t.qZA(),t.TgZ(23,"th"),t._uU(24),t.ALo(25,"translate"),t.qZA()()(),t.TgZ(26,"tbody"),t.YNc(27,Ea,8,5,"tr",21),t.qZA()()()()()),2&i){const e=n.$implicit,o=n.index,a=t.oxw(2);t.xp6(1),t.Q6J("formArrayName",o),t.xp6(2),t.Q6J("entity",e.value),t.xp6(2),t.Oqu(e.value.code),t.xp6(2),t.Q6J("label",t.lcZ(8,12,"common.name")),t.xp6(2),t.Q6J("id","name-"+o)("readonly",!t.lcZ(10,14,a.updatePermission)),t.xp6(2),t.Q6J("label",t.lcZ(12,16,"common.code")),t.xp6(2),t.Q6J("id","code-"+o)("readonly",!t.lcZ(14,18,a.updatePermission)),t.xp6(8),t.Oqu(t.lcZ(22,20,"common.name")),t.xp6(3),t.Oqu(t.lcZ(25,22,"common.code")),t.xp6(3),t.Q6J("ngForOf",a.getOptions(e))}}function Ha(i,n){if(1&i&&(t.TgZ(0,"form",7)(1,"div",8),t.YNc(2,ja,28,24,"div",9),t.qZA()()),2&i){const e=t.oxw();t.Q6J("formGroup",e.detailForm),t.xp6(2),t.Q6J("ngForOf",e.getOptionGroups())}}Tt.\u0275fac=function(n){return new(n||Tt)(t.Y36(s.DoR),t.Y36(s.Z7U),t.Y36(s.gqp),t.Y36(s.u8d),t.Y36(s.iHG),t.Y36(T.F0),t.Y36(T.gz))},Tt.\u0275cmp=t.Xpm({type:Tt,selectors:[["vdr-products-list"]],viewQuery:function(n,e){if(1&n&&t.Gf(Ma,7),2&n){let o;t.iGM(o=t.CRH())&&(e.productSearchInput=o.first)}},features:[t.qOj],decls:38,vars:43,consts:[[3,"grow"],[1,"search-form"],[3,"facetValueResults","searchTermChange","facetValueChange"],["productSearchInputComponent",""],[1,"search-settings-menu","mr3"],["type","button","vdrDropdownTrigger","",1,"icon-button","search-index-button",3,"title"],["shape","cog"],["type","warning",4,"ngIf"],["vdrPosition","bottom-right"],[1,"dropdown-header"],[4,"ngIf"],["type","button","vdrDropdownItem","",3,"disabled","click"],[1,"flex","wrap"],[1,"mt2"],["type","checkbox","clrCheckbox","",3,"ngModel","ngModelChange"],[3,"availableLanguageCodes","currentLanguageCode","languageCodeChange"],["locationId","product-list"],["class","btn btn-primary",3,"routerLink",4,"vdrIfPermissions"],[3,"items","itemsPerPage","totalItems","currentPage","pageChange","itemsPerPageChange"],["type","warning"],["type","button","vdrDropdownItem","",1,"run-updates-button",3,"disabled","click"],[1,"dropdown-divider"],[1,"btn","btn-primary",3,"routerLink"],["shape","plus"],[1,"full-label"],[1,"left","align-middle"],[1,"image-placeholder"],[3,"src",4,"ngIf","ngIfElse"],["imagePlaceholder",""],[1,"align-middle"],[1,"right","align-middle"],["iconShape","edit",3,"label","linkTo"],["type","button","vdrDropdownTrigger","",1,"btn","btn-link","btn-sm"],["shape","caret down"],["type","button","vdrDropdownItem","",1,"delete-button",3,"disabled","click"],["shape","trash",1,"is-danger"],[3,"src"],[1,"placeholder"],["shape","image","size","48"]],template:function(n,e){1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left",0)(2,"div",1)(3,"vdr-product-search-input",2,3),t.NdJ("searchTermChange",function(a){return e.setSearchTerm(a)})("facetValueChange",function(a){return e.setFacetValueIds(a)}),t.ALo(5,"async"),t.qZA(),t.TgZ(6,"vdr-dropdown",4)(7,"button",5),t.ALo(8,"translate"),t._UZ(9,"clr-icon",6),t.YNc(10,wa,1,0,"vdr-status-badge",7),t.qZA(),t.TgZ(11,"vdr-dropdown-menu",8)(12,"h4",9),t._uU(13),t.ALo(14,"translate"),t.qZA(),t.YNc(15,Va,7,10,"ng-container",10),t.TgZ(16,"button",11),t.NdJ("click",function(){return e.rebuildSearchIndex()}),t.ALo(17,"hasPermission"),t._uU(18),t.ALo(19,"translate"),t.qZA()()()(),t.TgZ(20,"div",12)(21,"clr-checkbox-wrapper",13)(22,"input",14),t.NdJ("ngModelChange",function(a){return e.groupByProduct=a})("ngModelChange",function(){return e.refresh()}),t.qZA(),t.TgZ(23,"label"),t._uU(24),t.ALo(25,"translate"),t.qZA()(),t.TgZ(26,"vdr-language-selector",15),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(27,"async"),t.ALo(28,"async"),t.qZA()()(),t.TgZ(29,"vdr-ab-right"),t._UZ(30,"vdr-action-bar-items",16),t.YNc(31,Ua,5,5,"a",17),t.qZA()(),t.TgZ(32,"vdr-data-table",18),t.NdJ("pageChange",function(a){return e.setPageNumber(a)})("itemsPerPageChange",function(a){return e.setItemsPerPage(a)}),t.ALo(33,"async"),t.ALo(34,"async"),t.ALo(35,"async"),t.ALo(36,"async"),t.YNc(37,Qa,24,30,"ng-template"),t.qZA()),2&n&&(t.xp6(1),t.Q6J("grow",!0),t.xp6(2),t.Q6J("facetValueResults",t.lcZ(5,17,e.facetValues$)),t.xp6(4),t.Q6J("title",t.lcZ(8,19,e.pendingSearchIndexUpdates?"catalog.pending-search-index-updates":"catalog.search-index-controls")),t.xp6(3),t.Q6J("ngIf",e.pendingSearchIndexUpdates),t.xp6(3),t.Oqu(t.lcZ(14,21,"catalog.search-index-controls")),t.xp6(2),t.Q6J("ngIf",e.pendingSearchIndexUpdates),t.xp6(1),t.Q6J("disabled",!t.lcZ(17,23,t.DdM(41,Ae))),t.xp6(2),t.hij(" ",t.lcZ(19,25,"catalog.rebuild-search-index")," "),t.xp6(4),t.Q6J("ngModel",e.groupByProduct),t.xp6(2),t.Oqu(t.lcZ(25,27,"catalog.group-by-product")),t.xp6(2),t.Q6J("availableLanguageCodes",t.lcZ(27,29,e.availableLanguages$))("currentLanguageCode",t.lcZ(28,31,e.contentLanguage$)),t.xp6(5),t.Q6J("vdrIfPermissions",t.DdM(42,Ya)),t.xp6(1),t.Q6J("items",t.lcZ(33,33,e.items$))("itemsPerPage",t.lcZ(34,35,e.itemsPerPage$))("totalItems",t.lcZ(35,37,e.totalItems$))("currentPage",t.lcZ(36,39,e.currentPage$)))},directives:[A.Kk,A.BN,Zt,it.J,at.U,f.qvL,C.O5,La.e,rt.N,ct.H,f.PEh,M.y,l.Wl,f.KKC,l.JJ,l.On,f.MgK,ot.S,A.mz,R.W,J.H,T.yS,te.Q,dt.Y,ee.v],pipes:[C.Ov,F.X$,U.j,Xt.M],styles:[".image-placeholder[_ngcontent-%COMP%]{width:50px;height:50px;background-color:var(--color-component-bg-200)}.image-placeholder[_ngcontent-%COMP%] .placeholder[_ngcontent-%COMP%]{text-align:center;color:var(--color-grey-300)}.search-form[_ngcontent-%COMP%]{display:flex;align-items:center;width:100%;margin-bottom:6px}.search-input[_ngcontent-%COMP%]{min-width:300px}@media screen and (max-width: 768px){.search-input[_ngcontent-%COMP%]{min-width:100px}}.search-settings-menu[_ngcontent-%COMP%]{margin:0 12px}td.disabled[_ngcontent-%COMP%]{background-color:var(--color-component-bg-200)}.search-index-button[_ngcontent-%COMP%]{position:relative}.search-index-button[_ngcontent-%COMP%] vdr-status-badge[_ngcontent-%COMP%]{right:0;top:0}.run-updates-button[_ngcontent-%COMP%]{position:relative}.run-updates-button[_ngcontent-%COMP%] vdr-status-badge[_ngcontent-%COMP%]{left:10px;top:10px}"]});class At extends s.UT_{constructor(n,e,o,a,r,c,d,p){super(n,e,o,a),this.route=n,this.router=e,this.serverConfigService=o,this.dataService=a,this.productDetailService=r,this.formBuilder=c,this.changeDetector=d,this.notificationService=p,this.autoUpdateVariantNames=!0,this.updatePermission=[s.y3$.UpdateCatalog,s.y3$.UpdateProduct],this.optionGroupCustomFields=this.getCustomFieldConfig("ProductOptionGroup"),this.optionCustomFields=this.getCustomFieldConfig("ProductOption")}ngOnInit(){this.optionGroups$=this.route.snapshot.data.entity.pipe((0,v.U)(n=>n.optionGroups)),this.detailForm=new l.cw({optionGroups:new l.Oe([])}),super.init()}getOptionGroups(){return this.detailForm.get("optionGroups").controls}getOptions(n){return n.get("options").controls}save(){if(this.detailForm.invalid||this.detailForm.pristine)return;const n=this.dataService.product.getProduct(this.id).mapSingle(e=>e.product);(0,O.a)(this.entity$,this.languageCode$,n).pipe((0,k.q)(1),(0,P.z)(([{optionGroups:e},o,a])=>{var r,c,d,p,h;const m=[];for(const g of this.getOptionGroups()){if((null===(r=g.get("name"))||void 0===r?void 0:r.dirty)||(null===(c=g.get("code"))||void 0===c?void 0:c.dirty)){const x=e.find(b=>b.id===g.value.id);if(x){const b=this.getUpdatedOptionGroup(x,g,o);m.push(this.dataService.product.updateProductOptionGroup(b))}}for(const x of this.getOptions(g))if((null===(d=x.get("name"))||void 0===d?void 0:d.dirty)||(null===(p=x.get("code"))||void 0===p?void 0:p.dirty)){const b=null===(h=e.find(Z=>Z.id===g.value.id))||void 0===h?void 0:h.options.find(Z=>Z.id===x.value.id);if(b){const Z=this.getUpdatedOption(b,x,o);m.push(this.productDetailService.updateProductOption(Object.assign(Object.assign({},Z),{autoUpdate:this.autoUpdateVariantNames}),a,o))}}}return(0,S.D)(m)})).subscribe(()=>{this.detailForm.markAsPristine(),this.changeDetector.markForCheck(),this.notificationService.success((0,_.J)("common.notify-update-success"),{entity:"ProductOptionGroup"})},e=>{this.notificationService.error((0,_.J)("common.notify-update-error"),{entity:"ProductOptionGroup"})})}getUpdatedOptionGroup(n,e,o){return(0,s.iSy)({translatable:n,updatedFields:e.value,customFieldConfig:this.optionGroupCustomFields,languageCode:o,defaultTranslation:{languageCode:o,name:n.name||""}})}getUpdatedOption(n,e,o){return(0,s.iSy)({translatable:n,updatedFields:e.value,customFieldConfig:this.optionGroupCustomFields,languageCode:o,defaultTranslation:{languageCode:o,name:n.name||""}})}setFormValues(n,e){const o=new l.Oe([]);for(const a of n.optionGroups){const r=(0,s.ZIM)(a,e),c={id:a.id,createdAt:a.createdAt,updatedAt:a.updatedAt,code:a.code,name:r?r.name:""},d=new l.Oe([]);for(const h of a.options){const m=(0,s.ZIM)(h,e),g=this.formBuilder.group({id:h.id,createdAt:h.createdAt,updatedAt:h.updatedAt,code:h.code,name:m?m.name:""});d.push(g)}const p=this.formBuilder.group(c);p.addControl("options",d),o.push(p)}this.detailForm.setControl("optionGroups",o)}}At.\u0275fac=function(n){return new(n||At)(t.Y36(T.gz),t.Y36(T.F0),t.Y36(s.iHG),t.Y36(s.DoR),t.Y36(j),t.Y36(l.qu),t.Y36(t.sBO),t.Y36(s.gqp))},At.\u0275cmp=t.Xpm({type:At,selectors:[["vdr-product-options-editor"]],features:[t.qOj],decls:16,vars:14,consts:[[3,"availableLanguageCodes","currentLanguageCode","languageCodeChange"],[1,"flex","center"],[1,"mr2"],["clrCheckbox","","type","checkbox","id","auto-update",3,"ngModel","ngModelChange"],["class","btn btn-primary",3,"disabled","click",4,"vdrIfPermissions"],["class","form",3,"formGroup",4,"ngIf"],[1,"btn","btn-primary",3,"disabled","click"],[1,"form",3,"formGroup"],["formGroupName","optionGroups",1,"clr-row"],["class","clr-col-12 clr-col-xl-6",4,"ngFor","ngForOf"],[1,"clr-col-12","clr-col-xl-6"],[1,"card",3,"formArrayName"],[1,"card-header","option-group-header"],[3,"entity"],[1,"ml2"],[1,"card-block"],["for","name",3,"label"],["type","text","formControlName","name",3,"id","readonly"],["for","code",3,"label"],["type","text","formControlName","code",3,"id","readonly"],["formGroupName","options",1,"facet-values-list","table","mt2","mb4"],["class","facet-value",3,"formGroupName",4,"ngFor","ngForOf"],[1,"facet-value",3,"formGroupName"],[1,"align-middle"],["type","text","formControlName","name",3,"readonly"],["type","text","formControlName","code"]],template:function(n,e){1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-left")(2,"vdr-language-selector",0),t.NdJ("languageCodeChange",function(a){return e.setLanguage(a)}),t.ALo(3,"async"),t.ALo(4,"async"),t.qZA()(),t.TgZ(5,"vdr-ab-right")(6,"div",1)(7,"div",2)(8,"clr-checkbox-wrapper")(9,"input",3),t.NdJ("ngModelChange",function(a){return e.autoUpdateVariantNames=a}),t.qZA(),t.TgZ(10,"label"),t._uU(11),t.ALo(12,"translate"),t.qZA()()(),t.YNc(13,Ga,3,4,"button",4),t.qZA()()(),t.YNc(14,Ha,3,2,"form",5),t.ALo(15,"async")),2&n&&(t.xp6(2),t.Q6J("availableLanguageCodes",t.lcZ(3,6,e.availableLanguages$))("currentLanguageCode",t.lcZ(4,8,e.languageCode$)),t.xp6(7),t.Q6J("ngModel",e.autoUpdateVariantNames),t.xp6(2),t.Oqu(t.lcZ(12,10,"catalog.auto-update-product-variant-name")),t.xp6(2),t.Q6J("vdrIfPermissions",e.updatePermission),t.xp6(1),t.Q6J("ngIf",t.lcZ(15,12,e.optionGroups$)))},directives:[A.Kk,A.BN,ot.S,A.mz,f.PEh,M.y,l.Wl,f.KKC,l.JJ,l.On,f.MgK,J.H,C.O5,l._Y,l.JL,l.sg,l.x0,C.sg,l.CE,kt.V,Dt.h,l.Fj,l.u],pipes:[C.Ov,F.X$,U.j],styles:[".option-group-header[_ngcontent-%COMP%]{display:flex;align-items:baseline}"],changeDetection:0});var Ba=u(1057);function Ra(i,n){1&i&&(t._uU(0),t.ALo(1,"translate")),2&i&&t.hij(" ",t.lcZ(1,1,"catalog.confirm-deletion-of-unused-variants-title"),"\n")}function za(i,n){if(1&i&&(t.TgZ(0,"li"),t._uU(1),t.qZA()),2&i){const e=n.$implicit;t.xp6(1),t.AsE("",e.name," (",e.sku,")")}}function Ka(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"button",3),t.NdJ("click",function(){return t.CHM(e),t.oxw().cancel()}),t._uU(1),t.ALo(2,"translate"),t.qZA(),t.TgZ(3,"button",4),t.NdJ("click",function(){return t.CHM(e),t.oxw().confirm()}),t._uU(4),t.ALo(5,"translate"),t.qZA()}2&i&&(t.xp6(1),t.Oqu(t.lcZ(2,2,"common.cancel")),t.xp6(3),t.hij(" ",t.lcZ(5,4,"common.confirm")," "))}class Pt{constructor(){this.variants=[]}confirm(){this.resolveWith(!0)}cancel(){this.resolveWith()}}function Wa(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"div",7)(1,"div",8)(2,"label"),t._uU(3),t.ALo(4,"translate"),t.qZA(),t.TgZ(5,"input",9),t.NdJ("ngModelChange",function(a){return t.CHM(e).$implicit.name=a}),t.qZA()(),t.TgZ(6,"div",10)(7,"label"),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.TgZ(10,"vdr-option-value-input",11,12),t.NdJ("ngModelChange",function(a){return t.CHM(e).$implicit.values=a})("ngModelChange",function(){return t.CHM(e),t.oxw().generateVariants()}),t.qZA()()()}if(2&i){const e=n.$implicit;t.xp6(3),t.Oqu(t.lcZ(4,7,"catalog.option")),t.xp6(2),t.Q6J("ngModel",e.name)("readonly",!e.isNew),t.xp6(3),t.Oqu(t.lcZ(9,9,"catalog.option-values")),t.xp6(2),t.Q6J("ngModel",e.values)("groupName",e.name)("disabled",""===e.name)}}function Xa(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"input",15),t.NdJ("ngModelChange",function(a){t.CHM(e);return t.oxw().$implicit.enabled=a})("ngModelChange",function(){t.CHM(e);return t.oxw(2).formValueChanged=!0}),t.qZA()}if(2&i){const e=t.oxw().$implicit;t.Q6J("ngModel",e.enabled)}}function tr(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"clr-input-container")(1,"input",16),t.NdJ("ngModelChange",function(a){t.CHM(e);return t.oxw().$implicit.sku=a})("ngModelChange",function(){t.CHM(e);const a=t.oxw().$implicit;return t.oxw().onFormChanged(a)}),t.ALo(2,"translate"),t.qZA()()}if(2&i){const e=t.oxw().$implicit;t.xp6(1),t.Q6J("ngModel",e.sku)("placeholder",t.lcZ(2,2,"catalog.sku"))}}function er(i,n){if(1&i&&(t.TgZ(0,"span"),t._uU(1),t.qZA()),2&i){const e=t.oxw().$implicit;t.xp6(1),t.Oqu(e.sku)}}function nr(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"clr-input-container")(1,"vdr-currency-input",17),t.NdJ("ngModelChange",function(a){t.CHM(e);return t.oxw().$implicit.price=a})("ngModelChange",function(){t.CHM(e);const a=t.oxw().$implicit;return t.oxw().onFormChanged(a)}),t.qZA()()}if(2&i){const e=t.oxw().$implicit,o=t.oxw();t.xp6(1),t.Q6J("ngModel",e.price)("currencyCode",o.currencyCode)}}function or(i,n){if(1&i&&(t.TgZ(0,"span"),t._uU(1),t.ALo(2,"localeCurrency"),t.qZA()),2&i){const e=t.oxw().$implicit,o=t.oxw();t.xp6(1),t.Oqu(t.xi3(2,1,e.price,o.currencyCode))}}function ir(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"clr-input-container")(1,"input",18),t.NdJ("ngModelChange",function(a){t.CHM(e);return t.oxw().$implicit.stock=a})("ngModelChange",function(){t.CHM(e);const a=t.oxw().$implicit;return t.oxw().onFormChanged(a)}),t.qZA()()}if(2&i){const e=t.oxw().$implicit;t.xp6(1),t.Q6J("ngModel",e.stock)}}function ar(i,n){if(1&i&&(t.TgZ(0,"span"),t._uU(1),t.qZA()),2&i){const e=t.oxw().$implicit;t.xp6(1),t.Oqu(e.stock)}}function rr(i,n){if(1&i){const e=t.EpF();t.TgZ(0,"vdr-dropdown")(1,"button",19),t._UZ(2,"clr-icon",20),t.qZA(),t.TgZ(3,"vdr-dropdown-menu",21)(4,"button",22),t.NdJ("click",function(){const r=t.CHM(e).ngIf;return t.oxw(2).deleteVariant(r)}),t._UZ(5,"clr-icon",23),t._uU(6),t.ALo(7,"translate"),t.qZA()()()}2&i&&(t.xp6(6),t.hij(" ",t.lcZ(7,1,"common.delete")," "))}function cr(i,n){if(1&i&&(t.TgZ(0,"tr")(1,"td"),t.YNc(2,Xa,1,1,"input",13),t.qZA(),t.TgZ(3,"td"),t._uU(4),t.ALo(5,"translate"),t.qZA(),t.TgZ(6,"td"),t.YNc(7,tr,3,4,"clr-input-container",14),t.YNc(8,er,2,1,"span",14),t.qZA(),t.TgZ(9,"td"),t.YNc(10,nr,2,2,"clr-input-container",14),t.YNc(11,or,3,4,"span",14),t.qZA(),t.TgZ(12,"td"),t.YNc(13,ir,2,1,"clr-input-container",14),t.YNc(14,ar,2,1,"span",14),t.qZA(),t.TgZ(15,"td"),t.YNc(16,rr,8,3,"vdr-dropdown",14),t.qZA()()),2&i){const e=n.$implicit,o=t.oxw();t.ekj("disabled",!e.enabled||e.existing),t.xp6(2),t.Q6J("ngIf",!e.existing),t.xp6(2),t.hij(" ",t.lcZ(5,11,o.getVariantName(e))," "),t.xp6(3),t.Q6J("ngIf",!e.existing),t.xp6(1),t.Q6J("ngIf",e.existing),t.xp6(2),t.Q6J("ngIf",!e.existing),t.xp6(1),t.Q6J("ngIf",e.existing),t.xp6(2),t.Q6J("ngIf",!e.existing),t.xp6(1),t.Q6J("ngIf",e.existing),t.xp6(2),t.Q6J("ngIf",e.productVariantId)}}Pt.\u0275fac=function(n){return new(n||Pt)},Pt.\u0275cmp=t.Xpm({type:Pt,selectors:[["vdr-confirm-variant-deletion-dialog"]],decls:6,vars:4,consts:[["vdrDialogTitle",""],[4,"ngFor","ngForOf"],["vdrDialogButtons",""],["type","button",1,"btn",3,"click"],["type","submit",1,"btn","btn-primary",3,"click"]],template:function(n,e){1&n&&(t.YNc(0,Ra,2,3,"ng-template",0),t._uU(1),t.ALo(2,"translate"),t.TgZ(3,"ul"),t.YNc(4,za,2,2,"li",1),t.qZA(),t.YNc(5,Ka,6,6,"ng-template",2)),2&n&&(t.xp6(1),t.hij("\n",t.lcZ(2,2,"catalog.confirm-deletion-of-unused-variants-body"),"\n"),t.xp6(3),t.Q6J("ngForOf",e.variants))},directives:[Bt.q,C.sg,Rt.n],pipes:[F.X$],styles:[""],changeDetection:0});const sr=function(i){return{count:i}};class Pe{constructor(n){for(const e of Object.keys(n))this[e]=n[e]}}class yt{constructor(n,e,o,a,r){this.route=n,this.dataService=e,this.productDetailService=o,this.notificationService=a,this.modalService=r,this.formValueChanged=!1,this.generatedVariants=[]}ngOnInit(){this.initOptionsAndVariants(),this.languageCode=this.route.snapshot.paramMap.get("lang")||(0,s.kAh)(),this.dataService.settings.getActiveChannel().single$.subscribe(n=>{this.currencyCode=n.activeChannel.currencyCode})}onFormChanged(n){this.formValueChanged=!0,n.enabled=!0}canDeactivate(){return!this.formValueChanged}getVariantsToAdd(){return this.generatedVariants.filter(n=>!n.existing&&n.enabled)}getVariantName(n){return 0===n.options.length?(0,_.J)("catalog.default-variant"):n.options.map(e=>e.name).join(" ")}addOption(){this.optionGroups.push({isNew:!0,name:"",values:[]})}generateVariants(){const n=this.optionGroups.map(a=>a.values),e=this.generatedVariants,o=(a,r,c,d)=>{var p,h,m,g,x,b;const Z=this.getVariantPrototype(r,e);return new Pe({enabled:!0,existing:!!c,productVariantId:null==c?void 0:c.id,isDefault:a,options:r,price:null!==(h=null!==(p=null==c?void 0:c.price)&&void 0!==p?p:null==d?void 0:d.price)&&void 0!==h?h:Z.price,sku:null!==(g=null!==(m=null==c?void 0:c.sku)&&void 0!==m?m:null==d?void 0:d.sku)&&void 0!==g?g:Z.sku,stock:null!==(b=null!==(x=null==c?void 0:c.stockOnHand)&&void 0!==x?x:null==d?void 0:d.stockOnHand)&&void 0!==b?b:Z.stock})};this.generatedVariants=n.length?(0,w.generateAllCombinations)(n).map(a=>{const r=this.product.variants.find(d=>this.optionsAreEqual(d.options,a)),c=this.product.variants.find(d=>this.optionsAreSubset(d.options,a));return o(!1,a,r,c)}):[o(!0,[],this.product.variants[0])]}getVariantPrototype(n,e){return e.filter(a=>n.map(r=>r.name).filter(r=>a.options.map(c=>c.name).includes(r))).length?(0,Ba.e)(e[0],["sku","price","stock"]):{sku:"",price:0,stock:0}}deleteVariant(n){this.modalService.dialog({title:(0,_.J)("catalog.confirm-delete-product-variant"),buttons:[{type:"secondary",label:(0,_.J)("common.cancel")},{type:"danger",label:(0,_.J)("common.delete"),returnValue:!0}]}).pipe((0,y.w)(e=>e?this.productDetailService.deleteProductVariant(n,this.product.id):D.E),(0,y.w)(()=>this.reFetchProduct(null))).subscribe(()=>{this.notificationService.success((0,_.J)("common.notify-delete-success"),{entity:"ProductVariant"}),this.initOptionsAndVariants()},e=>{this.notificationService.error((0,_.J)("common.notify-delete-error"),{entity:"ProductVariant"})})}save(){const n=this.optionGroups.filter(e=>e.isNew).map(e=>({name:e.name,values:[]}));this.checkUniqueSkus().pipe((0,P.z)(()=>this.confirmDeletionOfObsoleteVariants()),(0,P.z)(()=>this.productDetailService.createProductOptionGroups(n,this.languageCode)),(0,P.z)(e=>this.addOptionGroupsToProduct(e)),(0,P.z)(e=>this.addNewOptionsToGroups(e)),(0,P.z)(e=>this.fetchOptionGroups(e)),(0,P.z)(e=>this.createNewProductVariants(e)),(0,P.z)(e=>this.deleteObsoleteVariants(e.createProductVariants)),(0,P.z)(e=>this.reFetchProduct(e))).subscribe({next:e=>{this.formValueChanged=!1,this.notificationService.success((0,_.J)("catalog.created-new-variants-success"),{count:e.length}),this.initOptionsAndVariants()}})}checkUniqueSkus(){const n=this.generatedVariants.filter((e,o)=>this.generatedVariants.find(a=>a.sku.trim()===e.sku.trim()&&a!==e));return n.length?this.modalService.dialog({title:(0,_.J)("catalog.duplicate-sku-warning"),body:(0,St.T)(n.map(e=>`${e.sku}`)).join(", "),buttons:[{label:(0,_.J)("common.close"),returnValue:!1,type:"primary"}]}).pipe((0,P.z)(e=>D.E)):(0,L.of)(!0)}confirmDeletionOfObsoleteVariants(){const n=this.getObsoleteVariants();return n.length?this.modalService.fromComponent(Pt,{locals:{variants:n}}).pipe((0,P.z)(e=>!0===e?(0,L.of)(!0):D.E)):(0,L.of)(!0)}getObsoleteVariants(){return this.product.variants.filter(n=>!this.generatedVariants.find(e=>e.productVariantId===n.id))}hasOnlyDefaultVariant(n){return 1===n.variants.length&&0===n.optionGroups.length}addOptionGroupsToProduct(n){return n.length?(0,S.D)(n.map(e=>this.dataService.product.addOptionGroupToProduct({productId:this.product.id,optionGroupId:e.id}))).pipe((0,v.U)(()=>n)):(0,L.of)([])}addNewOptionsToGroups(n){const e=this.optionGroups.map(a=>{const r=n.find(d=>d.name===a.name),c=r?r.id:a.id;if(!c)throw new Error("Could not get a productOptionGroupId");return a.values.filter(d=>!d.locked).map(d=>({productOptionGroupId:c,code:(0,z.U)(d.name,"-"),translations:[{name:d.name,languageCode:this.languageCode}]}))}).reduce((a,r)=>[...a,...r],[]),o=[...n.map(a=>a.id),...this.optionGroups.map(a=>a.id).filter(w.notNullOrUndefined)];return e.length?(0,S.D)(e.map(a=>this.dataService.product.addOptionToGroup(a))).pipe((0,v.U)(()=>o)):(0,L.of)(o)}fetchOptionGroups(n){return(0,S.D)(n.map(e=>this.dataService.product.getProductOptionGroup(e).mapSingle(o=>o.productOptionGroup).pipe((0,Gt.h)(w.notNullOrUndefined))))}createNewProductVariants(n){const e=n.filter(w.notNullOrUndefined).map(a=>a.options).reduce((a,r)=>[...a,...r],[]),o=this.generatedVariants.filter(a=>a.enabled&&!a.existing).map(a=>({price:a.price,sku:a.sku,stock:a.stock,optionIds:a.options.map(r=>e.find(c=>c.name===r.name)).filter(w.notNullOrUndefined).map(r=>r.id)}));return this.productDetailService.createProductVariants(this.product,o,e,this.languageCode)}deleteObsoleteVariants(n){const e=this.getObsoleteVariants();if(e.length){const o=e.map(a=>this.dataService.product.deleteProductVariant(a.id).pipe((0,v.U)(()=>n)));return(0,S.D)(...o)}return(0,L.of)(n)}reFetchProduct(n){const e=this.route.snapshot.paramMap.get("id");return e?this.dataService.product.getProduct(e).single$.pipe((0,v.U)(()=>n)):(0,L.of)(n)}initOptionsAndVariants(){this.dataService.product.getProductVariantsOptions(this.route.snapshot.paramMap.get("id")).mapSingle(({product:n})=>n).subscribe(n=>{this.product=n,this.optionGroups=n.optionGroups.map(e=>({id:e.id,isNew:!1,name:e.name,values:e.options.map(o=>({id:o.id,name:o.name,locked:!0}))})),this.generateVariants()})}optionsAreEqual(n,e){return this.toOptionString(n)===this.toOptionString(e)}optionsAreSubset(n,e){return this.toOptionString(e).includes(this.toOptionString(n))}toOptionString(n){return n.map(e=>e.name).sort().join("|")}}yt.\u0275fac=function(n){return new(n||yt)(t.Y36(T.gz),t.Y36(s.DoR),t.Y36(j),t.Y36(s.gqp),t.Y36(s.Z7U))},yt.\u0275cmp=t.Xpm({type:yt,selectors:[["vdr-product-variants-editor"]],decls:31,vars:27,consts:[[1,"btn","btn-primary",3,"disabled","click"],["class","option-groups",4,"ngFor","ngForOf"],[1,"btn","btn-primary-outline","btn-sm",3,"click"],["shape","plus"],[1,"variants-preview"],[1,"table"],[3,"disabled",4,"ngFor","ngForOf"],[1,"option-groups"],[1,"name"],["clrInput","","name","name",3,"ngModel","readonly","ngModelChange"],[1,"values"],[3,"ngModel","groupName","disabled","ngModelChange"],["optionValueInputComponent",""],["type","checkbox","name","enabled","clrCheckbox","",3,"ngModel","ngModelChange",4,"ngIf"],[4,"ngIf"],["type","checkbox","name","enabled","clrCheckbox","",3,"ngModel","ngModelChange"],["clrInput","","type","text","name","sku","required","",3,"ngModel","placeholder","ngModelChange"],["clrInput","","name","price",3,"ngModel","currencyCode","ngModelChange"],["clrInput","","type","number","name","stock","min","0","step","1",3,"ngModel","ngModelChange"],["vdrDropdownTrigger","",1,"icon-button"],["shape","ellipsis-vertical"],["vdrPosition","bottom-right"],["type","button","vdrDropdownItem","",1,"delete-button",3,"click"],["shape","trash",1,"is-danger"]],template:function(n,e){1&n&&(t.TgZ(0,"vdr-action-bar")(1,"vdr-ab-right")(2,"button",0),t.NdJ("click",function(){return e.save()}),t._uU(3),t.ALo(4,"translate"),t.qZA()()(),t.YNc(5,Wa,12,11,"div",1),t.TgZ(6,"button",2),t.NdJ("click",function(){return e.addOption()}),t._UZ(7,"clr-icon",3),t._uU(8),t.ALo(9,"translate"),t.qZA(),t.TgZ(10,"div",4)(11,"table",5)(12,"thead")(13,"tr")(14,"th"),t._uU(15),t.ALo(16,"translate"),t.qZA(),t.TgZ(17,"th"),t._uU(18),t.ALo(19,"translate"),t.qZA(),t.TgZ(20,"th"),t._uU(21),t.ALo(22,"translate"),t.qZA(),t.TgZ(23,"th"),t._uU(24),t.ALo(25,"translate"),t.qZA(),t.TgZ(26,"th"),t._uU(27),t.ALo(28,"translate"),t.qZA(),t._UZ(29,"th"),t.qZA()(),t.YNc(30,cr,17,13,"tr",6),t.qZA()()),2&n&&(t.xp6(2),t.Q6J("disabled",!e.formValueChanged||0===e.getVariantsToAdd().length),t.xp6(1),t.hij(" ",t.xi3(4,10,"common.add-new-variants",t.VKq(25,sr,e.getVariantsToAdd().length))," "),t.xp6(2),t.Q6J("ngForOf",e.optionGroups),t.xp6(3),t.hij(" ",t.lcZ(9,13,"catalog.add-option"),"\n"),t.xp6(7),t.Oqu(t.lcZ(16,15,"common.create")),t.xp6(3),t.Oqu(t.lcZ(19,17,"catalog.variant")),t.xp6(3),t.Oqu(t.lcZ(22,19,"catalog.sku")),t.xp6(3),t.Oqu(t.lcZ(25,21,"catalog.price")),t.xp6(3),t.Oqu(t.lcZ(28,23,"catalog.stock-on-hand")),t.xp6(3),t.Q6J("ngForOf",e.generatedVariants))},directives:[A.Kk,A.mz,C.sg,f.MgK,M.y,l.Fj,f.xRP,l.JJ,l.On,H,f.qvL,C.O5,l.Wl,f.KKC,f.G55,l.Q7,zt.K,l.qQ,l.wV,it.J,at.U,rt.N,ct.H],pipes:[F.X$,oe.k],styles:[".option-groups[_ngcontent-%COMP%]{display:flex}.option-groups[_ngcontent-%COMP%]:first-of-type{margin-top:24px}.values[_ngcontent-%COMP%]{flex:1;margin:0 6px}.variants-preview[_ngcontent-%COMP%] tr.disabled[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{background-color:var(--color-component-bg-100);color:var(--color-grey-400)}"]});class Ft extends s.p_9{constructor(n,e){super(n,{__typename:"Asset",id:"",createdAt:"",updatedAt:"",name:"",type:s.h3s.IMAGE,fileSize:0,mimeType:"",width:0,height:0,source:"",preview:"",focalPoint:null},o=>e.product.getAsset(o).mapStream(a=>a.asset))}}Ft.\u0275fac=function(n){return new(n||Ft)(t.LFG(T.F0),t.LFG(s.DoR))},Ft.\u0275prov=t.Yz7({token:Ft,factory:Ft.\u0275fac,providedIn:"root"});class Ot extends s.p_9{constructor(n,e){super(n,{__typename:"Collection",id:"",createdAt:"",updatedAt:"",languageCode:(0,s.kAh)(),name:"",slug:"",isPrivate:!1,description:"",featuredAsset:null,assets:[],translations:[],inheritFilters:!0,filters:[],parent:{},children:null},o=>e.collection.getCollection(o).mapStream(a=>a.collection))}}Ot.\u0275fac=function(n){return new(n||Ot)(t.LFG(T.F0),t.LFG(s.DoR))},Ot.\u0275prov=t.Yz7({token:Ot,factory:Ot.\u0275fac,providedIn:"root"});class It extends s.p_9{constructor(n,e){super(n,{__typename:"Facet",id:"",createdAt:"",updatedAt:"",isPrivate:!1,languageCode:(0,s.kAh)(),name:"",code:"",translations:[],values:[]},o=>e.facet.getFacet(o).mapStream(a=>a.facet))}}It.\u0275fac=function(n){return new(n||It)(t.LFG(T.F0),t.LFG(s.DoR))},It.\u0275prov=t.Yz7({token:It,factory:It.\u0275fac,providedIn:"root"});class Lt extends s.p_9{constructor(n,e){super(e,{__typename:"Product",id:"",createdAt:"",updatedAt:"",enabled:!0,languageCode:(0,s.kAh)(),name:"",slug:"",featuredAsset:null,assets:[],description:"",translations:[],optionGroups:[],facetValues:[],variantList:{items:[],totalItems:0},channels:[]},o=>n.product.getProduct(o,{take:10}).refetchOnChannelChange().mapStream(a=>a.product))}}Lt.\u0275fac=function(n){return new(n||Lt)(t.LFG(s.DoR),t.LFG(T.F0))},Lt.\u0275prov=t.Yz7({token:Lt,factory:Lt.\u0275fac,providedIn:"root"});class tt extends s.p_9{constructor(n,e){super(n,{__typename:"Product",id:"",createdAt:"",updatedAt:"",name:"",optionGroups:[],variants:[]},o=>e.product.getProductVariantsOptions(o).mapStream(a=>a.product))}}tt.\u0275fac=function(n){return new(n||tt)(t.LFG(T.F0),t.LFG(s.DoR))},tt.\u0275prov=t.Yz7({token:tt,factory:tt.\u0275fac,providedIn:"root"});const ye=[{path:"products",component:Tt,data:{breadcrumb:(0,_.J)("breadcrumb.products")}},{path:"products/:id",component:bt,resolve:(0,s.Po4)(Lt),canDeactivate:[s.TSp],data:{breadcrumb:Fe}},{path:"products/:id/manage-variants",component:yt,resolve:(0,s.Po4)(tt),canDeactivate:[s.TSp],data:{breadcrumb:Oe}},{path:"products/:id/options",component:At,resolve:(0,s.Po4)(tt),canDeactivate:[s.TSp],data:{breadcrumb:Ie}},{path:"facets",component:_t,data:{breadcrumb:(0,_.J)("breadcrumb.facets")}},{path:"facets/:id",component:mt,resolve:(0,s.Po4)(It),canDeactivate:[s.TSp],data:{breadcrumb:Le}},{path:"collections",component:ut,data:{breadcrumb:(0,_.J)("breadcrumb.collections")}},{path:"collections/:id",component:lt,resolve:(0,s.Po4)(Ot),canDeactivate:[s.TSp],data:{breadcrumb:Me}},{path:"assets",component:nt,data:{breadcrumb:(0,_.J)("breadcrumb.assets")}},{path:"assets/:id",component:et,resolve:(0,s.Po4)(Ft),data:{breadcrumb:we}}];function Fe(i,n){return(0,s.YWC)({entity:i.entity,id:n.id,breadcrumbKey:"breadcrumb.products",getName:e=>e.name,route:"products"})}function Oe(i,n){return i.entity.pipe((0,v.U)(e=>[{label:(0,_.J)("breadcrumb.products"),link:["../","products"]},{label:`${e.name}`,link:["../","products",n.id,{tab:"variants"}]},{label:(0,_.J)("breadcrumb.manage-variants"),link:["manage-variants"]}]))}function Ie(i,n){return i.entity.pipe((0,v.U)(e=>[{label:(0,_.J)("breadcrumb.products"),link:["../","products"]},{label:`${e.name}`,link:["../","products",n.id,{tab:"variants"}]},{label:(0,_.J)("breadcrumb.product-options"),link:["options"]}]))}function Le(i,n){return(0,s.YWC)({entity:i.entity,id:n.id,breadcrumbKey:"breadcrumb.facets",getName:e=>e.name,route:"facets"})}function Me(i,n){return(0,s.YWC)({entity:i.entity,id:n.id,breadcrumbKey:"breadcrumb.collections",getName:e=>e.name,route:"collections"})}function we(i,n){return(0,s.YWC)({entity:i.entity,id:n.id,breadcrumbKey:"breadcrumb.assets",getName:e=>e.name,route:"assets"})}class Ut{}Ut.\u0275fac=function(n){return new(n||Ut)},Ut.\u0275mod=t.oAB({type:Ut}),Ut.\u0275inj=t.cJS({imports:[[s.m81,T.Bz.forChild(ye)]]})}}]);
2
+ //# sourceMappingURL=349.bf78d0411766ae60.js.map