1import{a as fe,b as Oe,c as ye,d as ve,e as xe,f as Te}from"./chunk-PYHZOA7L.js";import{a as Me,b as Pe}from"./chunk-P7PQZVHQ.js";import{a as he}from"./chunk-RGWTER5P.js";import{a as Ee}from"./chunk-PCQZQ3U4.js";import{a as Ce,f as _e}from"./chunk-JDYWGDNH.js";import"./chunk-IRONFM6M.js";import"./chunk-VHX354RR.js";import{a as ce,b as ue}from"./chunk-22WJKAIZ.js";import{b as ge}from"./chunk-SLWPYULI.js";import{a as ee,b as te}from"./chunk-6S5SATLI.js";import"./chunk-6KF7XEC7.js";import{b as oe,c as re}from"./chunk-RPDGXIQT.js";import"./chunk-RFHORXFH.js";import{a as ae,b as le}from"./chunk-44BDWJO3.js";import"./chunk-YPSMJDVJ.js";import"./chunk-F6HJUGGY.js";import{a as pe,b as se}from"./chunk-W6FQLWKF.js";import"./chunk-6MXSXX3N.js";import"./chunk-MT62CIDI.js";import"./chunk-BXNQRMY5.js";import"./chunk-RFCDL6VX.js";import"./chunk-XWDSR7V3.js";import"./chunk-VV34F7XC.js";import"./chunk-3THAQ3J3.js";import{a as ie,b as ne}from"./chunk-OAED5FIG.js";import{a as z,b as J}from"./chunk-P37GQ53N.js";import{b as de,c as me}from"./chunk-NZ226J7R.js";import"./chunk-7EBKYMB6.js";import"./chunk-YK3HMHC4.js";import"./chunk-2DRXLVRR.js";import{d as Z,e as $}from"./chunk-OFHUO5H7.js";import"./chunk-M3XSAKW4.js";import"./chunk-H76LZNGX.js";import"./chunk-PGR2NPNS.js";import"./chunk-OZD37XM5.js";import"./chunk-DLIVM562.js";import"./chunk-CV2ZWZQE.js";import"./chunk-AVEXXPAT.js";import{ja as q}from"./chunk-FHU4TM37.js";import{a as Se}from"./chunk-UUEFXD6N.js";import{D as j,c as Y,g as X,l as K}from"./chunk-Q2KKZV5J.js";import{a as U}from"./chunk-JICM7NVH.js";import{a as Q}from"./chunk-BD6EMWWF.js";import"./chunk-AB6CKZTE.js";import{c as F,d as W,e as k}from"./chunk-DIGPPQJE.js";import{x as G}from"./chunk-EU6HCBUP.js";import"./chunk-KAJMKXZ6.js";import{D as B,x as H}from"./chunk-ZAQTNZYS.js";import"./chunk-SRTXE2HR.js";import{Dc as S,Ec as E,Fc as h,Jb as C,Kc as R,Lb as N,Mb as w,Rb as g,Uc as p,V as b,Vc as d,Wb as r,Wc as A,Xb as a,Yb as y,ac as v,da as T,db as o,f as I,gc as f,hc as _,la as M,ma as P,sb as V,uc as s,vc as c,wc as u,xc as D,yb as O,yc as L}from"./chunk-NTTV6FWH.js";import{g as x}from"./chunk-W7GRJBO5.js";var Re=()=>({width:"500px"}),Ae=()=>({width:"520px"}),Ie=()=>({width:"100%"}),be=()=>({width:"600px"});function Ve(i,e){if(i&1){let n=v();r(0,"div",6)(1,"p-button",33),p(2,"translate"),f("onClick",function(){M(n);let m=_();return P(m.openCreateDialog())}),a()()}i&2&&(o(),C("label",d(2,1,"MANAGER.SHOP.PROMO.CREATE")))}function Ne(i,e){i&1&&y(0,"app-widget-loading")}function De(i,e){if(i&1){let n=v();r(0,"app-widget-api-error",34),f("retry",function(){M(n);let m=_();return P(m.loadPromoCodes())}),a()}}function Le(i,e){if(i&1){let n=v();r(0,"app-widget-manager-empty-state",35),f("ctaClick",function(){M(n);let m=_();return P(m.openCreateDialog())}),a()}}function He(i,e){i&1&&(r(0,"tr")(1,"th"),s(2),p(3,"translate"),a(),r(4,"th"),s(5),p(6,"translate"),a(),r(7,"th"),s(8),p(9,"translate"),a(),r(10,"th"),s(11),p(12,"translate"),a(),r(13,"th"),s(14),p(15,"translate"),a(),r(16,"th"),s(17),p(18,"translate"),a(),y(19,"th",38),a()),i&2&&(o(2),u(" ",d(3,6,"MANAGER.SHOP.PROMO.COL_CODE")," "),o(3),u(" ",d(6,8,"MANAGER.SHOP.PROMO.COL_TYPE")," "),o(3),u(" ",d(9,10,"MANAGER.SHOP.PROMO.COL_DISCOUNT")," "),o(3),u(" ",d(12,12,"MANAGER.SHOP.PROMO.COL_USES")," "),o(3),u(" ",d(15,14,"MANAGER.SHOP.PROMO.COL_STATUS")," "),o(3),u(" ",d(18,16,"MANAGER.SHOP.PROMO.COL_DATES")," "))}function Be(i,e){if(i&1&&(r(0,"span"),s(1),a()),i&2){let n=_().$implicit;o(),u("/ ",n.maxUses,"")}}function Ge(i,e){i&1&&y(0,"p-tag",41)}function Fe(i,e){i&1&&(y(0,"p-tag",42),p(1,"translate")),i&2&&C("value",d(1,1,"MANAGER.SHOP.PROMO.EXPIRED"))}function We(i,e){i&1&&(y(0,"p-tag",43),p(1,"translate")),i&2&&C("value",d(1,1,"MANAGER.SHOP.PROMO.MAX_USED"))}function ke(i,e){i&1&&(y(0,"p-tag",44),p(1,"translate")),i&2&&C("value",d(1,1,"MANAGER.SHOP.PROMO.ACTIVE"))}function Ue(i,e){if(i&1&&(r(0,"span"),s(1),p(2,"date"),a()),i&2){let n=_().$implicit;o(),c(A(2,1,n.startsAt,"dd/MM/yyyy"))}}function Ye(i,e){i&1&&(r(0,"span"),s(1," - "),a())}function Xe(i,e){if(i&1&&(r(0,"span"),s(1),p(2,"date"),a()),i&2){let n=_().$implicit;o(),c(A(2,1,n.expiresAt,"dd/MM/yyyy"))}}function Ke(i,e){i&1&&(r(0,"span"),s(1,"-"),a())}function je(i,e){if(i&1){let n=v();r(0,"tr")(1,"td")(2,"span",39),s(3),a()(),r(4,"td"),y(5,"p-tag",40),a(),r(6,"td"),s(7),a(),r(8,"td"),s(9),O(10,Be,2,1,"span"),a(),r(11,"td"),O(12,Ge,1,0,"p-tag",41)(13,Fe,2,3,"p-tag",42)(14,We,2,3,"p-tag",43)(15,ke,2,3,"p-tag",44),a(),r(16,"td",45),O(17,Ue,3,4,"span")(18,Ye,2,0,"span")(19,Xe,3,4,"span")(20,Ke,2,0,"span"),a(),r(21,"td",46)(22,"div",47)(23,"p-button",48),p(24,"translate"),f("onClick",function(){let m=M(n).$implicit,l=_(2);return P(l.openEditDialog(m))}),a(),r(25,"p-button",49),p(26,"translate"),f("onClick",function(){let m=M(n).$implicit,l=_(2);return P(l.toggleActive(m))}),a(),r(27,"p-button",50),p(28,"translate"),f("onClick",function(){let m=M(n).$implicit,l=_(2);return P(l.deletePromoCode(m))}),a()()()()}if(i&2){let n=e.$implicit,t=_(2);o(3),c(n.code),o(2),C("value",t.getTypeLabel(n.type))("severity",t.getTypeSeverity(n.type)),o(2),c(t.formatDiscount(n)),o(2),u(" ",n.usesCount," "),o(),g(n.maxUses?10:-1),o(2),g(n.isActive?t.isExpired(n)?13:t.isMaxUsed(n)?14:15:12),o(5),g(n.startsAt?17:-1),o(),g(n.startsAt&&n.expiresAt?18:-1),o(),g(n.expiresAt?19:-1),o(),g(!n.startsAt&&!n.expiresAt?20:-1),o(3),C("text",!0)("rounded",!0)("pTooltip",d(24,21,"COMMON.EDIT")),o(2),C("icon",n.isActive?"pi pi-eye-slash":"pi pi-eye")("text",!0)("rounded",!0)("pTooltip",d(26,23,n.isActive?"MANAGER.SHOP.PROMO.DEACTIVATE":"MANAGER.SHOP.PROMO.ACTIVATE")),o(2),C("text",!0)("rounded",!0)("pTooltip",d(28,25,"COMMON.DELETE"))}}function qe(i,e){if(i&1&&(r(0,"p-table",8),O(1,He,20,18,"ng-template",36)(2,je,29,27,"ng-template",37),a()),i&2){let n=_();C("value",n.promoCodes)("responsive",!0)}}function ze(i,e){if(i&1){let n=v();r(0,"div",6)(1,"p-button",33),p(2,"translate"),f("onClick",function(){M(n);let m=_();return P(m.openCreateStoreCreditDialog())}),a()()}
1i&2&&(o(),C("label",d(2,1,"MANAGER.SHOP.STORE_CREDIT.CREATE")))}function Je(i,e){i&1&&y(0,"app-widget-loading")}function Qe(i,e){if(i&1){let n=v();r(0,"app-widget-api-error",34),f("retry",function(){M(n);let m=_();return P(m.loadStoreCredits())}),a()}}function Ze(i,e){if(i&1){let n=v();r(0,"div",9),y(1,"i",51),r(2,"p",5),s(3),p(4,"translate"),a(),r(5,"p-button",33),p(6,"translate"),f("onClick",function(){M(n);let m=_();return P(m.openCreateStoreCreditDialog())}),a()()}i&2&&(o(3),u(" ",d(4,2,"MANAGER.SHOP.STORE_CREDIT.EMPTY")," "),o(2),C("label",d(6,4,"MANAGER.SHOP.STORE_CREDIT.CREATE_FIRST")))}function $e(i,e){i&1&&(r(0,"tr")(1,"th"),s(2),p(3,"translate"),a(),r(4,"th"),s(5),p(6,"translate"),a(),r(7,"th"),s(8),p(9,"translate"),a(),r(10,"th"),s(11),p(12,"translate"),a(),r(13,"th"),s(14),p(15,"translate"),a(),r(16,"th"),s(17),p(18,"translate"),a(),y(19,"th",52),a()),i&2&&(o(2),u(" ",d(3,6,"MANAGER.SHOP.STORE_CREDIT.COL_CODE")," "),o(3),u(" ",d(6,8,"MANAGER.SHOP.STORE_CREDIT.COL_EMAIL")," "),o(3),u(" ",d(9,10,"MANAGER.SHOP.STORE_CREDIT.COL_INITIAL")," "),o(3),u(" ",d(12,12,"MANAGER.SHOP.STORE_CREDIT.COL_REMAINING")," "),o(3),u(" ",d(15,14,"MANAGER.SHOP.PROMO.COL_STATUS")," "),o(3),u(" ",d(18,16,"MANAGER.SHOP.STORE_CREDIT.COL_EXPIRES")," "))}function et(i,e){if(i&1&&(s(0),p(1,"date")),i&2){let n=_().$implicit;u(" ",A(1,1,n.expiresAt,"dd/MM/yyyy")," ")}}function tt(i,e){i&1&&s(0," - ")}function it(i,e){if(i&1){let n=v();r(0,"tr")(1,"td")(2,"span",39),s(3),a()(),r(4,"td",53),s(5),a(),r(6,"td"),s(7),a(),r(8,"td")(9,"span",54),s(10),a()(),r(11,"td"),y(12,"p-tag",40),p(13,"translate"),a(),r(14,"td",45),O(15,et,2,4)(16,tt,1,0),a(),r(17,"td",46)(18,"p-button",55),p(19,"translate"),f("onClick",function(){let m=M(n).$implicit,l=_(2);return P(l.openHistoryDialog(m))}),a()()()}if(i&2){let n,t=e.$implicit,m=_(2);o(3),c(t.code),o(2),c(t.targetEmail),o(2),u(" ",m.formatCents(t.initialValueCents)," "),o(2),N("text-danger",((n=t.valueCents)!==null&&n!==void 0?n:0)<=0),o(),u(" ",m.formatCents(t.valueCents)," "),o(2),C("value",d(13,12,"MANAGER.SHOP.STORE_CREDIT.STATUS_"+m.getStoreCreditStatus(t).toUpperCase()))("severity",m.getStoreCreditStatusSeverity(t)),o(3),g(t.expiresAt?15:16),o(3),C("text",!0)("rounded",!0)("pTooltip",d(19,14,"MANAGER.SHOP.STORE_CREDIT.VIEW_HISTORY"))}}function nt(i,e){if(i&1&&(r(0,"p-table",8),O(1,$e,20,18,"ng-template",36)(2,it,20,16,"ng-template",37),a()),i&2){let n=_();C("value",n.storeCredits)("responsive",!0)}}function ot(i,e){if(i&1&&(s(0),p(1,"translate")),i&2){let n=e.$implicit;u(" ",d(1,1,n.label)," ")}}function rt(i,e){if(i&1&&(s(0),p(1,"translate")),i&2){let n=e.$implicit;u(" ",d(1,1,n.label)," ")}}function at(i,e){if(i&1&&(s(0),p(1,"translate")),i&2){let n=e.$implicit;u(" ",d(1,1,n.label)," ")}}function lt(i,e){if(i&1&&(s(0),p(1,"translate")),i&2){let n=e.$implicit;u(" ",d(1,1,n.label)," ")}}function pt(i,e){if(i&1){let n=v();r(0,"div",11)(1,"label",12),s(2),p(3,"translate"),a(),r(4,"p-inputNumber",56),h("ngModelChange",function(m){M(n);let l=_();return E(l.form.valuePercent,m)||(l.form.valuePercent=m),P(m)}),a()()}if(i&2){let n=_();o(2),c(d(3,4,"MANAGER.SHOP.PROMO.FIELD_PERCENT")),o(2),S("ngModel",n.form.valuePercent),C("min",1)("max",100)}}function st(i,e){if(i&1){let n=v();r(0,"div",11)(1,"label",12),s(2),p(3,"translate"),a(),r(4,"p-inputNumber",19),h("ngModelChange",function(m){M(n);let l=_();return E(l.amountEuros,m)||(l.amountEuros=m),P(m)}),a()()}if(i&2){let n=_();o(2),c(d(3,5,"MANAGER.SHOP.PROMO.FIELD_AMOUNT")),o(2),S("ngModel",n.amountEuros),C("min",.01)("minFractionDigits",2)("maxFractionDigits",2)}}function dt(i,e){if(i&1){let n=v();r(0,"div",11)(1,"label",12),s(2),p(3,"translate"),a(),r(4,"p-inputNumber",19),h("ngModelChange",function(m){M(n);let l=_();return E(l.maxDiscountEuros,m)||(l.maxDiscountEuros=m),P(m)}),a()()}if(i&2){let n=_();o(2),c(d(3,5,"MANAGER.SHOP.PROMO.FIELD_MAX_DISCOUNT")),o(2),S("ngModel",n.maxDiscountEuros),C("min",0)("minFractionDigits",2)("maxFractionDigits",2)}}function mt(i,e){if(i&1){let n=v();r(0,"p-button",57),p(1,"translate"),f("onClick",function(){M(n);let m=_();return P(m.dialogVisible=!1)}),a(),r(2,"p-button",58),p(3,"translate"),f("onClick",function(){M(n);let m=_();return P(m.savePromoCode())}),a()}if(i&2){let n=_();C("label",d(1,4,"COMMON.CANCEL"))("text",!0),o(2),C("label",d(3,6,n.dialogMode==="create"?"MANAGER.SHOP.PROMO.CREATE":"COMMON.SAVE"))("loading",n.saving)}}function Ct(i,e){if(i&1&&(r(0,"div",59)(1,"span",60),s(2),a(),r(3,"small",28),s(4),a(),r(5,"small",28),s(6),p(7,"translate"),a()()),i&2){let n=e.$implicit,t=_();o(2),c(n.buyerName||n.buyerEmail),o(2),c(n.buyerEmail),o(2),L("",n.orderCount," ",d(7,5,"MANAGER.SHOP.STORE_CREDIT.CUSTOMER_RESULT_ORDERS")," - ",t.formatCents(n.totalSpentCents),"")}}function _t(i,e){if(i&1){let n=v();r(0,"p-button",57),p(1,"translate"),f("onClick",function(){M(n);let m=_();return P(m.storeCreditDialogVisible=!1)}),a(),r(2,"p-button",58),p(3,"translate"),f("onClick",function(){M(n);let m=_();return P(m.saveStoreCredit())}),a()}if(i&2){let n=_();C("label",d(1,4,"COMMON.CANCEL"))("text",!0),o(2),C("label",d(3,6,"MANAGER.SHOP.STORE_CREDIT.CREATE"))("loading",n.storeCreditSaving)}}function ct(i,e){if(i&1&&(r(0,"div",30)(1,"span",39),s(2),a(),r(3,"span",28),s(4),a(),r(5,"span",54),s(6),a()()),i&2){let n=_();o(2),c(n.historyCredit.code),o(2),c(n.historyCredit.targetEmail),o(2),D(" ",n.formatCents(n.historyCredit.valueCents)," / ",n.formatCents(n.historyCredit.initialValueCents)," ")}}function ut(i,e){i&1&&y(0,"app-widget-loading")}function gt(i,e){i&1&&(r(0,"p",31),s(1),p(2,"translate"),a()),i&2&&(o(),u(" ",d(2,1,"MANAGER.SHOP.STORE_CREDIT.NO_HISTORY")," "))}function St(i,e){i&1&&(r(0,"tr")(1,"th"),s(2),p(3,"translate"),a(),r(4,"th"),s(5),p(6,"translate"),a(),r(7,"th"),s(8),p(9,"translate"),a()()),i&2&&(o(2),u(" ",d(3,3,"MANAGER.SHOP.STORE_CREDIT.HIST_DATE")," "),o(3),u(" ",d(6,5,"MANAGER.SHOP.STORE_CREDIT.HIST_ORDER")," "),o(3),u(" ",d(9,7,"MANAGER.SHOP.STORE_CREDIT.HIST_AMOUNT")," "))}function Et(i,e){if(i&1&&(r(0,"tr")(1,"td",53),s(2),p(3,"date"),a(),r(4,"td",53),s(5),a(),r(6,"td",61),s(7),a()()),i&2){let n=e.$implicit,t=_(2);o(2),u(" ",A(3,3,n.createdAt,"dd/MM/yyyy HH:mm")," "),o(3),c(n.orderId||"-"),o(2),u(" -",t.formatCents(n.discountCents)," ")}}function ht(i,e){if(i&1&&(r(0,"p-table",32),O(1,St,10,9,"ng-template",36)(2,Et,8,6,"ng-template",37),a()),i&2){let n=_();C("value",n.historyItems)}}var we=class i{shopService=T(Ee);toastService=T(U);confirmService=T(Se);t=T(F);destroy$=new I;activeTab="0";loading=!0;error=null;promoCodes=[];dialogVisible=!1;dialogMode="create";editId=null;saving=!1;form=this.getEmptyForm();storeCredits=[];storeCreditsLoading=!1;storeCreditsError=null;storeCreditDialogVisible=!1;storeCreditSaving=!1;storeCreditForm=this.getEmptyStoreCreditForm();storeCreditCustomerSuggestions=[];storeCreditSelectedCustomer=null;historyDialogVisible=!1;historyLoading=!1;historyItems=[];historyCredit=null;typeOptions=[{label:"MANAGER.SHOP.PROMO.TYPE_PERCENTAGE",value:"percentage"},{label:"MANAGER.SHOP.PROMO.TYPE_FIXED",value:"fixed_amount"},{label:"MANAGER.SHOP.PROMO.TYPE_FREE_SHIPPING",value:"free_shipping"}];scopeOptions=[{label:"MANAGER.SHOP.PROMO.SCOPE_SHOP",value:"shop"},{label:"MANAGER.SHOP.PROMO.SCOPE_LINK",value:"link"},{label:"MANAGER.SHOP.PROMO.SCOPE_GENERIC",value:"generic"}];ngOnInit(){this.loadPromoCodes(),this.shopService.refresh$.pipe(b(this.destroy$)).subscribe(()=>
1{this.loadPromoCodes(),this.loadStoreCredits()})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadPromoCodes(){return x(this,null,function*(){this.loading=!0,this.error=null;try{this.promoCodes=yield this.shopService.listPromoCodes()}catch{this.error="load",this.toastService.error(this.t.instant("COMMON.ERROR"))}finally{this.loading=!1}})}openCreateDialog(){this.dialogMode="create",this.editId=null,this.form=this.getEmptyForm(),this.dialogVisible=!0}openEditDialog(e){this.dialogMode="edit",this.editId=e.id,this.form={code:e.code,type:e.type,scope:e.scope,valueCents:e.valueCents,valuePercent:e.valuePercent,minOrderCents:e.minOrderCents,maxDiscountCents:e.maxDiscountCents,maxUses:e.maxUses,maxUsesPerCustomer:e.maxUsesPerCustomer,startsAt:e.startsAt,expiresAt:e.expiresAt,isActive:e.isActive},this.dialogVisible=!0}savePromoCode(){return x(this,null,function*(){this.saving=!0;try{this.dialogMode==="create"?(yield this.shopService.createPromoCode(this.form),this.toastService.success(this.t.instant("MANAGER.SHOP.PROMO.CREATED"))):(yield this.shopService.updatePromoCode(this.editId,this.form),this.toastService.success(this.t.instant("MANAGER.SHOP.PROMO.UPDATED"))),this.dialogVisible=!1,yield this.loadPromoCodes()}catch(e){this.toastService.error(this.t.instant("COMMON.ERROR")),console.error("[promo-codes] echec enregistrement",e)}finally{this.saving=!1}})}deletePromoCode(e){return x(this,null,function*(){if(yield this.confirmService.confirm({message:this.t.instant("MANAGER.SHOP.PROMO.DELETE_CONFIRM",{code:e.code}),header:this.t.instant("MANAGER.SHOP.PROMO.DELETE_TITLE"),severity:"danger",acceptLabel:this.t.instant("COMMON.DELETE"),rejectLabel:this.t.instant("COMMON.CANCEL")}))try{yield this.shopService.deletePromoCode(e.id),this.toastService.success(this.t.instant("MANAGER.SHOP.PROMO.DELETED")),yield this.loadPromoCodes()}catch{this.toastService.error(this.t.instant("COMMON.ERROR"))}})}toggleActive(e){return x(this,null,function*(){try{yield this.shopService.updatePromoCode(e.id,{isActive:!e.isActive}),e.isActive=!e.isActive}catch{this.toastService.error(this.t.instant("COMMON.ERROR"))}})}onTabChange(e){this.activeTab=String(e),e==="1"&&this.storeCredits.length===0&&!this.storeCreditsLoading&&this.loadStoreCredits()}loadStoreCredits(){return x(this,null,function*(){this.storeCreditsLoading=!0,this.storeCreditsError=null;try{this.storeCredits=yield this.shopService.listStoreCredits()}catch{this.storeCreditsError="load",this.toastService.error(this.t.instant("COMMON.ERROR"))}finally{this.storeCreditsLoading=!1}})}openCreateStoreCreditDialog(){this.storeCreditForm=this.getEmptyStoreCreditForm(),this.storeCreditSelectedCustomer=null,this.storeCreditCustomerSuggestions=[],this.storeCreditDialogVisible=!0}saveStoreCredit(){return x(this,null,function*(){this.storeCreditSaving=!0;try{yield this.shopService.createStoreCredit(this.storeCreditForm),this.toastService.success(this.t.instant("MANAGER.SHOP.STORE_CREDIT.CREATED")),this.storeCreditDialogVisible=!1,yield this.loadStoreCredits()}catch(e){this.toastService.error(this.t.instant("COMMON.ERROR")),console.error("[promo-codes] echec enregistrement",e)}finally{this.storeCreditSaving=!1}})}openHistoryDialog(e){return x(this,null,function*(){this.historyCredit=e,this.historyDialogVisible=!0,this.historyLoading=!0,this.historyItems=[];try{this.historyItems=yield this.shopService.getStoreCreditHistory(e.id)}catch{this.toastService.error(this.t.instant("COMMON.ERROR"))}finally{this.historyLoading=!1}})}formatCents(e){return e==null?"-":(e/100).toFixed(2)+" \u20AC"}getStoreCreditStatus(e){return(e.valueCents??0)<=0?"exhausted":e.expiresAt&&new Date(e.expiresAt)<new Date?"expired":"active"}getStoreCreditStatusSeverity(e){switch(this.getStoreCreditStatus(e)){case"exhausted":return"danger";case"expired":return"warn";case"active":return"success"}}searchStoreCreditCustomers(e){return x(this,null,function*(){let n=e.query?.trim()||"";if(n.length<2){this.storeCreditCustomerSuggestions=[];return}try{this.storeCreditCustomerSuggestions=yield this.shopService.searchCustomers(n)}catch{this.storeCreditCustomerSuggestions=[]}})}onStoreCreditCustomerSelect(e){this.storeCreditSelectedCustomer=e,this.storeCreditForm.targetUserId=e?.buyerUserId||void 0,this.storeCreditForm.targetEmail=e?.buyerEmail||""}onStoreCreditEmailChange(e){let n=(e||"").trim().toLowerCase(),t=this.storeCreditSelectedCustomer?.buyerEmail?.trim().toLowerCase()||"";(!n||n!==t)&&(this.storeCreditSelectedCustomer=null,this.storeCreditForm.targetUserId=void 0)}getEmptyStoreCreditForm(){return{valueCents:0,targetEmail:"",targetUserId:void 0}}getTypeSeverity(e){switch(e){case"percentage":return"success";case"fixed_amount":return"info";case"free_shipping":return"warn"}}getTypeLabel(e){switch(e){case"percentage":return"%";case"fixed_amount":return"EUR";case"free_shipping":return"SHIP"}}formatDiscount(e){switch(e.type){case"percentage":return`-${e.valuePercent}%`;case"fixed_amount":return`-${((e.valueCents??0)/100).toFixed(2)} EUR`;case"free_shipping":return this.t.instant("MANAGER.SHOP.PROMO.FREE_SHIPPING_LABEL")}}isExpired(e){return e.expiresAt?new Date(e.expiresAt)<new Date:!1}isMaxUsed(e){return e.maxUses?e.usesCount>=e.maxUses:!1}static toCents(e){if(e==null)return;let n=Number(e);if(Number.isFinite(n))return Math.round(n*100)}static toEuros(e){if(e==null)return null;let n=Number(e);return Number.isFinite(n)?n/100:null}get amountEuros(){return i.toEuros(this.form.valueCents)}set amountEuros(e){this.form.valueCents=i.toCents(e)}get maxDiscountEuros(){return i.toEuros(this.form.maxDiscountCents)}set maxDiscountEuros(e){this.form.maxDiscountCents=i.toCents(e)}get minOrderEuros(){return i.toEuros(this.form.minOrderCents)}set minOrderEuros(e){this.form.minOrderCents=i.toCents(e)}get storeCreditEuros(){return i.toEuros(this.storeCreditForm.valueCents)}set storeCreditEuros(e){this.storeCreditForm.valueCents=i.toCents(e)??0}getEmptyForm(){return{code:"",type:"percentage",scope:"shop",valuePercent:10,maxUsesPerCustomer:1,isActive:!0}}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=V({type:i,selectors:[["app-view-manager-shop-promo-codes"]],decls:126,vars:141,consts:[[3,"valueChange","value"],["value","0"],[1,"pi","pi-ticket","me-2"],["value","1"],[1,"pi","pi-wallet","me-2"],[1,"mt-3"],[1,"d-flex","justify-content-end","mb-3"],["icon","pi pi-ticket","titleKey","MANAGER.SHOP.PROMO.EMPTY_TITLE","descriptionKey","MANAGER.SHOP.PROMO.EMPTY_DESC","ctaLabelKey","MANAGER.SHOP.PROMO.CREATE","ctaIcon","pi pi-plus"],["styleClass","p-datatable-sm",3,"value","responsive"],[1,"text-center","text-light","p-5"],[3,"visibleChange","visible","header","modal","closable"],[1,"mb-3"],[1,"form-label"],["pInputText","",1,"w-100",2,"text-transform","uppercase",3,"ngModelChange","ngModel","placeholder"],[1,"row","mb-3"],[1,"col-6"],["optionLabel","label","optionValue","value","appendTo","body",1,"w-100",3,"ngModelChange","ngModel","options"],["pTemplate","selectedItem"],["pTemplate","item"],["suffix"," \u20AC",1,"w-100",3,"ngModelChange","ngModel","min","minFractionDigits","maxFractionDigits"],[1,"w-100",3,"ngModelChange","ngModel","min"],["dateFormat","dd/mm/yy",1,"w-100",3,"ngModelChange","ngModel","showClear"],[1,"mb-3","d-flex","align-items-center","gap-2"],[3,"ngModelChange","ngModel"],["pTemplate","footer"],["optionLabel","buyerEmail",3,"ngModelChange","completeMethod","onSelect","onClear","ngModel","suggestions","dropdown","placeholder"],[1,"text-muted","d-block","mt-2"],["pInputText","","type","email",1,"w-100",3,"ngModelChange","ngModel","placeholder"],[1,"text-muted"],["pInputText","",1,"w-100",3,"ngModelChange","ngModel","placeholder"],[1,"mb-3","d-flex","align-items-center","gap-3"],[1,"text-center","text-muted","p-3"],["styleClass","p-datatable-sm",3,"value"],["icon","pi pi-plus","severity","secondary",3,"onClick","label"],[3,"retry"],["icon","pi pi-ticket","titleKey","MANAGER.SHOP.PROMO.EMPTY_TITLE","descriptionKey","MANAGER.SHOP.PROMO.EMPTY_DESC","ctaLabelKey","MANAGER.SHOP.PROMO.CREATE","ctaIcon","pi pi-plus",3,"ctaClick"],["pTemplate","header"],["pTemplate","body"],[2,"width","140px"],[1,"promo-code-badge"],[3,"value","severity"],["value","OFF","severity","secondary"],["severity","danger",3,"value"],["severity","warn",3,"value"],["severity","success",3,"value"],[1,"text-muted","small"],[1,"text-end"],[1,"d-flex","justify-content-end","gap-1","flex-nowrap"],["icon","pi pi-pencil","severity","secondary",3,"onClick","text","rounded","pTooltip"],["severity","secondary",3,"onClick","icon","text","rounded","pTooltip"],["icon","pi pi-trash","severity","danger",3,"onClick","text","rounded","pTooltip"],[1,"pi","pi-wallet","fs-1","mb-3","d-block","text-light"],[2,"width","80px"],[1,"small"],[1,"fw-bold"],["
1icon","pi pi-history","severity","secondary",3,"onClick","text","rounded","pTooltip"],["suffix","%",1,"w-100",3,"ngModelChange","ngModel","min","max"],["severity","secondary",3,"onClick","label","text"],["icon","pi pi-check",3,"onClick","label","loading"],[1,"d-flex","flex-column","gap-1","py-1"],[1,"fw-semibold"],[1,"fw-bold","text-danger"]],template:function(n,t){n&1&&(r(0,"p-tabs",0),f("valueChange",function(l){return t.onTabChange(l)}),r(1,"p-tablist")(2,"p-tab",1),y(3,"i",2),s(4),p(5,"translate"),a(),r(6,"p-tab",3),y(7,"i",4),s(8),p(9,"translate"),a()(),r(10,"p-tabpanels")(11,"p-tabpanel",1)(12,"div",5),O(13,Ve,3,3,"div",6)(14,Ne,1,0,"app-widget-loading")(15,De,1,0,"app-widget-api-error")(16,Le,1,0,"app-widget-manager-empty-state",7)(17,qe,3,2,"p-table",8),a()(),r(18,"p-tabpanel",3)(19,"div",5),O(20,ze,3,3,"div",6)(21,Je,1,0,"app-widget-loading")(22,Qe,1,0,"app-widget-api-error")(23,Ze,7,6,"div",9)(24,nt,3,2,"p-table",8),a()()()(),r(25,"p-dialog",10),p(26,"translate"),h("visibleChange",function(l){return E(t.dialogVisible,l)||(t.dialogVisible=l),l}),r(27,"div",11)(28,"label",12),s(29),p(30,"translate"),a(),r(31,"input",13),p(32,"translate"),h("ngModelChange",function(l){return E(t.form.code,l)||(t.form.code=l),l}),a()(),r(33,"div",14)(34,"div",15)(35,"label",12),s(36),p(37,"translate"),a(),r(38,"p-select",16),h("ngModelChange",function(l){return E(t.form.type,l)||(t.form.type=l),l}),O(39,ot,2,3,"ng-template",17)(40,rt,2,3,"ng-template",18),a()(),r(41,"div",15)(42,"label",12),s(43),p(44,"translate"),a(),r(45,"p-select",16),h("ngModelChange",function(l){return E(t.form.scope,l)||(t.form.scope=l),l}),O(46,at,2,3,"ng-template",17)(47,lt,2,3,"ng-template",18),a()()(),O(48,pt,5,6,"div",11)(49,st,5,7,"div",11)(50,dt,5,7,"div",11),r(51,"div",11)(52,"label",12),s(53),p(54,"translate"),a(),r(55,"p-inputNumber",19),h("ngModelChange",function(l){return E(t.minOrderEuros,l)||(t.minOrderEuros=l),l}),a()(),r(56,"div",14)(57,"div",15)(58,"label",12),s(59),p(60,"translate"),a(),r(61,"p-inputNumber",20),h("ngModelChange",function(l){return E(t.form.maxUses,l)||(t.form.maxUses=l),l}),a()(),r(62,"div",15)(63,"label",12),s(64),p(65,"translate"),a(),r(66,"p-inputNumber",20),h("ngModelChange",function(l){return E(t.form.maxUsesPerCustomer,l)||(t.form.maxUsesPerCustomer=l),l}),a()()(),r(67,"div",14)(68,"div",15)(69,"label",12),s(70),p(71,"translate"),a(),r(72,"p-datepicker",21),h("ngModelChange",function(l){return E(t.form.startsAt,l)||(t.form.startsAt=l),l}),a()(),r(73,"div",15)(74,"label",12),s(75),p(76,"translate"),a(),r(77,"p-datepicker",21),h("ngModelChange",function(l){return E(t.form.expiresAt,l)||(t.form.expiresAt=l),l}),a()()(),r(78,"div",22)(79,"p-inputSwitch",23),h("ngModelChange",function(l){return E(t.form.isActive,l)||(t.form.isActive=l),l}),a(),r(80,"label"),s(81),p(82,"translate"),a()(),O(83,mt,4,8,"ng-template",24),a(),r(84,"p-dialog",10),p(85,"translate"),h("visibleChange",function(l){return E(t.storeCreditDialogVisible,l)||(t.storeCreditDialogVisible=l),l}),r(86,"div",11)(87,"label",12),s(88),p(89,"translate"),a(),r(90,"p-autoComplete",25),p(91,"translate"),h("ngModelChange",function(l){return E(t.storeCreditSelectedCustomer,l)||(t.storeCreditSelectedCustomer=l),l}),f("completeMethod",function(l){return t.searchStoreCreditCustomers(l)})("onSelect",function(l){return t.onStoreCreditCustomerSelect(l.value)})("onClear",function(){return t.onStoreCreditCustomerSelect(null)}),O(92,Ct,8,7,"ng-template",18),a(),r(93,"small",26),s(94),p(95,"translate"),a()(),r(96,"div",11)(97,"label",12),s(98),p(99,"translate"),a(),r(100,"input",27),p(101,"translate"),h("ngModelChange",function(l){return E(t.storeCreditForm.targetEmail,l)||(t.storeCreditForm.targetEmail=l),l}),f("ngModelChange",function(l){return t.onStoreCreditEmailChange(l)}),a(),r(102,"small",26),s(103),p(104,"translate"),a()(),r(105,"div",11)(106,"label",12),s(107),p(108,"translate"),a(),r(109,"p-inputNumber",19),h("ngModelChange",function(l){return E(t.storeCreditEuros,l)||(t.storeCreditEuros=l),l}),a(),r(110,"small",28),s(111),p(112,"translate"),a()(),r(113,"div",11)(114,"label",12),s(115),p(116,"translate"),a(),r(117,"input",29),p(118,"translate"),h("ngModelChange",function(l){return E(t.storeCreditForm.reason,l)||(t.storeCreditForm.reason=l),l}),a()(),O(119,_t,4,8,"ng-template",24),a(),r(120,"p-dialog",10),p(121,"translate"),h("visibleChange",function(l){return E(t.historyDialogVisible,l)||(t.historyDialogVisible=l),l}),O(122,ct,7,4,"div",30)(123,ut,1,0,"app-widget-loading")(124,gt,3,3,"p",31)(125,ht,3,1,"p-table",32),a()),n&2&&(C("value",t.activeTab),o(4),u("",d(5,87,"MANAGER.SHOP.PROMO.TITLE")," "),o(4),u("",d(9,89,"MANAGER.SHOP.STORE_CREDIT.TITLE")," "),o(5),g(!t.loading&&!t.error&&t.promoCodes.length>0?13:-1),o(),g(t.loading?14:-1),o(),g(!t.loading&&t.error?15:-1),o(),g(!t.loading&&!t.error&&t.promoCodes.length===0?16:-1),o(),g(!t.loading&&t.promoCodes.length>0?17:-1),o(3),g(!t.storeCreditsLoading&&!t.storeCreditsError&&t.storeCredits.length>0?20:-1),o(),g(t.storeCreditsLoading?21:-1),o(),g(!t.storeCreditsLoading&&t.storeCreditsError?22:-1),o(),g(!t.storeCreditsLoading&&!t.storeCreditsError&&t.storeCredits.length===0?23:-1),o(),g(!t.storeCreditsLoading&&t.storeCredits.length>0?24:-1),o(),w(R(137,Re)),S("visible",t.dialogVisible),C("header",d(26,91,t.dialogMode==="create"?"MANAGER.SHOP.PROMO.DIALOG_CREATE":"MANAGER.SHOP.PROMO.DIALOG_EDIT"))("modal",!0)("closable",!0),o(4),c(d(30,93,"MANAGER.SHOP.PROMO.FIELD_CODE")),o(2),S("ngModel",t.form.code),C("placeholder",d(32,95,"MANAGER.SHOP.PROMO.FIELD_CODE_HINT")),o(5),c(d(37,97,"MANAGER.SHOP.PROMO.FIELD_TYPE")),o(2),S("ngModel",t.form.type),C("options",t.typeOptions),o(5),c(d(44,99,"MANAGER.SHOP.PROMO.FIELD_SCOPE")),o(2),S("ngModel",t.form.scope),C("options",t.scopeOptions),o(3),g(t.form.type==="percentage"?48:-1),o(),g(t.form.type==="fixed_amount"?49:-1),o(),g(t.form.type==="percentage"?50:-1),o(3),c(d(54,101,"MANAGER.SHOP.PROMO.FIELD_MIN_ORDER")),o(2),S("ngModel",t.minOrderEuros),C("min",0)("minFractionDigits",2)("maxFractionDigits",2),o(4),c(d(60,103,"MANAGER.SHOP.PROMO.FIELD_MAX_USES")),o(2),S("ngModel",t.form.maxUses),C("min",1),o(3),c(d(65,105,"MANAGER.SHOP.PROMO.FIELD_MAX_PER_CUSTOMER")),o(2),S("ngModel",t.form.maxUsesPerCustomer),C("min",1),o(4),c(d(71,107,"MANAGER.SHOP.PROMO.FIELD_STARTS")),o(2),S("ngModel",t.form.startsAt),C("showClear",!0),o(3),c(d(76,109,"MANAGER.SHOP.PROMO.FIELD_EXPIRES")),o(2),S("ngModel",t.form.expiresAt),C("showClear",!0),o(2),S("ngModel",t.form.isActive),o(2),c(d(82,111,"MANAGER.SHOP.PROMO.FIELD_ACTIVE")),o(3),w(R(138,Ae)),S("visible",t.storeCreditDialogVisible),C("header",d(85,113,"MANAGER.SHOP.STORE_CREDIT.DIALOG_CREATE"))("modal",!0)("closable",!0),o(4),c(d(89,115,"MANAGER.SHOP.STORE_CREDIT.CUSTOMER_SEARCH_LABEL")),o(2),w(R(139,Ie)),S("ngModel",t.storeCreditSelectedCustomer),C("suggestions",t.storeCreditCustomerSuggestions)("dropdown",!0)("placeholder",d(91,11
17,"MANAGER.SHOP.STORE_CREDIT.CUSTOMER_SEARCH_PLACEHOLDER")),o(4),c(d(95,119,"MANAGER.SHOP.STORE_CREDIT.CUSTOMER_SEARCH_HINT")),o(4),c(d(99,121,"MANAGER.SHOP.STORE_CREDIT.FIELD_EMAIL")),o(2),S("ngModel",t.storeCreditForm.targetEmail),C("placeholder",d(101,123,"MANAGER.SHOP.STORE_CREDIT.FIELD_EMAIL_HINT")),o(3),c(d(104,125,"MANAGER.SHOP.STORE_CREDIT.FIELD_EMAIL_OVERRIDE_HINT")),o(4),c(d(108,127,"MANAGER.SHOP.STORE_CREDIT.FIELD_AMOUNT")),o(2),S("ngModel",t.storeCreditEuros),C("min",.01)("minFractionDigits",2)("maxFractionDigits",2),o(2),c(d(112,129,"MANAGER.SHOP.STORE_CREDIT.FIELD_AMOUNT_HINT")),o(4),c(d(116,131,"MANAGER.SHOP.STORE_CREDIT.FIELD_REASON")),o(2),S("ngModel",t.storeCreditForm.reason),C("placeholder",d(118,133,"MANAGER.SHOP.STORE_CREDIT.FIELD_REASON_HINT")),o(3),w(R(140,be)),S("visible",t.historyDialogVisible),C("header",d(121,135,"MANAGER.SHOP.STORE_CREDIT.HISTORY_TITLE"))("modal",!0)("closable",!0),o(2),g(t.historyCredit?122:-1),o(),g(t.historyLoading?123:-1),o(),g(!t.historyLoading&&t.historyItems.length===0?124:-1),o(),g(!t.historyLoading&&t.historyItems.length>0?125:-1))},dependencies:[B,H,G,j,Y,X,K,k,W,$,Z,q,_e,Ce,me,de,ne,ie,le,ae,se,pe,te,ee,ue,ce,re,oe,J,z,Te,xe,ve,ye,fe,Oe,Pe,Me,Q,ge,he],styles:[".shop-tab-content[_ngcontent-%COMP%]{background:var(--p-surface-card);border:1px solid var(--p-surface-border);border-top:none;border-radius:0 0 10px 10px;padding:1.25rem}.promo-code-badge[_ngcontent-%COMP%]{font-family:Courier New,monospace;font-weight:700;font-size:.95rem;letter-spacing:.05em;background:var(--p-surface-ground, var(--surface-ground));border:1px solid var(--p-surface-border, var(--surface-border));border-radius:6px;padding:4px 10px;display:inline-block}"]})};export{we as ViewManagerShopPromoCodesComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.