1import{a as le,b as pe}from"./chunk-CDXP36YL.js";import{a as ie,c as re,d as oe,e as ne}from"./chunk-XJTISS3N.js";import{f as ae,i as me}from"./chunk-YRK3PJSM.js";import"./chunk-4VR3POOM.js";import{d as K,e as N,g as X,h as J,m as U,n as W,p as Q,s as Y}from"./chunk-UBXQQOH2.js";import{b as A}from"./chunk-OWBU4FZ3.js";import{a as Z,b as ee,c as te}from"./chunk-R33LP3LO.js";import"./chunk-U3EQYU4R.js";import{a as V,b as $,d as P,f as q}from"./chunk-OSTRH6YC.js";import"./chunk-3QL3M56K.js";import"./chunk-BPTSU525.js";import"./chunk-MLKVIX4M.js";import"./chunk-4G2PXBE2.js";import"./chunk-WSJXSSN6.js";import"./chunk-BSH3DMWI.js";import"./chunk-GSLQYO25.js";import{e as w}from"./chunk-ZXLVJXZ6.js";import"./chunk-3OZN2F4M.js";import"./chunk-IPPDDQKQ.js";import"./chunk-VT3QQRYT.js";import{Fd as j,Gd as R,Ib as m,Ja as b,Jb as p,Kb as C,Lb as k,Mb as D,Ob as E,Rb as y,Tb as s,Ua as n,Ya as f,ad as B,bd as M,dc as d,ec as I,fc as z,gb as T,gc as G,jd as O,mb as u,md as H,nd as L,tc as v,ua as F,ub as a,uc as _,va as x}from"./chunk-STUAVJKB.js";import{e as S}from"./chunk-6MDQTQU3.js";function ce(o,t){o&1&&(m(0,"div"),d(1),v(2,"translate"),p()),o&2&&(n(),I(_(2,1,"HOLDERS.LOADING")))}function fe(o,t){if(o&1&&(m(0,"div",11)(1,"nz-form-item")(2,"nz-form-label",12),d(3),p(),m(4,"nz-form-control",13),C(5,"input",14),p()()()),o&2){let e=t.$implicit,r=s().$implicit,i=s().$implicit,l=s(2);a("nzSpan",12),n(2),a("nzFor",e.key),n(),z(" ",l.getHolderFieldLabel(i.item,e.key)," "),n(),a("nzErrorTip",l.getErrorTip(i.item,e.key,r)),n(),a("id",e.key)("formControlName",e.key)}}function ue(o,t){if(o&1&&(m(0,"div",8)(1,"h4"),d(2),p(),m(3,"div",9),u(4,fe,6,6,"div",10),v(5,"keyvalue"),p()()),o&2){let e=t.$implicit,r=t.index,i=s().$implicit;a("formGroup",e),n(2),G("",i.item.variationName," #",r+1,""),n(2),a("ngForOf",_(5,4,e.controls))}}function ve(o,t){if(o&1&&(k(0),C(1,"nz-divider"),m(2,"h3"),d(3),p(),C(4,"nz-divider"),u(5,ue,6,6,"div",7),D()),o&2){let e=t.$implicit;n(3),I(e.item.productTitle),n(2),a("ngForOf",e.formGroup)}}function _e(o,t){if(o&1){let e=E();m(0,"div"),u(1,ve,6,2,"ng-container",3),m(2,"div",4)(3,"button",5),y("click",function(){F(e);let i=s();return x(i.goBack())}),d(4),v(5,"translate"),p(),m(6,"button",6),y("click",function(){F(e);let i=s();return x(i.submitAll())}),d(7),v(8,"translate"),p()()()}if(o&2){let e=s();n(),a("ngForOf",e.forms),n(3),z(" ",_(5,3,"HOLDERS.BUTTON_BACK")," "),n(3),z(" ",_(8,5,"HOLDERS.BUTTON_NEXT")," ")}}var se=class o{constructor(t,e,r,i){this.platformId=t;this.fb=e;this.cartService=r;this.router=i}isBrowser=!1;isLoading=!0;cart;forms=[];ngOnInit(){if(this.isBrowser=L(this.platformId),!this.isBrowser){this.isLoading=!1;return}this.loadCart()}loadCart(){return S(this,null,function*(){this.cart=this.cartService.getCart(),this.forms=this.cart.items.map(t=>{let e=t.holderFieldMeta??[];if(!e.length)return null;let r=[],i=t.holderData??[];for(let l=0;l<t.quantity;l++){let g=this.fb.group({});for(let c of e){let h=[];c.required&&h.push(N.required),c.pattern&&h.push(N.pattern(c.pattern));let de=i[l]?.[c.key]||"";g.addControl(c.key,this.fb.control(de,h))}r.push(g)}return{item:t,formGroup:r}}).filter(t=>t!==null),this.isLoading=!1})}getHolderFieldLabel(t,e){return t.holderFieldMeta?.find(i=>i.key==e)?.label??e}submitAll(){let t=!1;for(let e of this.forms)for(let r of e.formGroup)r.invalid&&(r.markAllAsTouched(),t=!0);if(!t){for(let{item:e,formGroup:r}of this.forms)e.holderData=r.map(i=>i.value);this.cartService.persistCart(),this.router.navigate(["/checkout/delivery"])}}getErrorTip(t,e,r){let i=r.get(e);if(i?.invalid&&(i.dirty||i.touched)){let l=t.holderFieldMeta?.find(g=>g.key==e);if(i.errors?.required)return`${l?.label||e} je obavezno polje.`;if(i.errors?.pattern)return l?.errorMessage||`${l?.label||e} nije u ispravnom formatu.`}}goBack(){this.router.navigate(["/checkout/buyer"])}static \u0275fac=function(e){return new(e||o)(f(b),f(Q),f(A),f(w))};static \u0275cmp=T({type:o,selectors:[["app-checkout-holders"]],decls:4,vars:7,consts:[[3,"nzJustify"],[3,"nzSpan","nzMd","nzLg","nzXl"],[4,"ngIf"],[4,"ngFor","ngForOf"],[2,"text-align","right"],["nz-button","","nzType","default",3,"click"],["nz-button","","nzType","primary",3,"click"],["style","margin-bottom: 24px",3,"formGroup",4,"ngFor","ngForOf"],[2,"margin-bottom","24px",3,"formGroup"],["nz-row","","nzGutter","16"],["nz-col","",3,"nzSpan",4,"ngFor","ngForOf"],["nz-col","",3,"nzSpan"],[3,"nzFor"],[3,"nzErrorTip"],["nz-input","",3,"id","formControlName"]],template:function(e,r){e&1&&(m(0,"nz-row",0)(1,"nz-col",1),u(2,ce,3,3,"div",2)(3,_e,9,7,"div",2),p()()),e&2&&(a("nzJustify","center"),n(),a("nzSpan",24)("nzMd",16)("nzLg",12)("nzXl",8),n(),a("ngIf",r.isLoading),n(),a("ngIf",!r.isLoading))},dependencies:[H,B,M,O,Y,K,X,J,U,W,q,P,V,$,ne,ee,Z,ie,oe,re,me,ae,pe,le,te,R,j],encapsulation:2})};export{se as HoldersComponent};
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.