import{a as R,C as S,k as x,b as d,m as u,g as n,p as l,F as _,H as b,I,n as m,D as g,u as p,w as T,q as w,f as N,T as L}from"./convert-case-to-camel-case.utils-DDUpNI96.js";import{a as V}from"./WooRedirectCart-BJuCLpzi.js";import{a as h}from"./ThankYouPage-bf4cLsjC.js";import{c as $,q}from"./widget-BUAABBRb.js";import{_ as D}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./translationsStore-DBJu9sBR.js";import"./index-CEuXXsrq.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";const M={class:"ccb-repeater-wrapper"},P=["onClick"],z={class:"ccb-repeater-item--label"},H={class:"ccb-repeater-item--counter"},O={key:0,class:"ccb-repeater-item--body"},j={class:"ccb-repeater-item--fields"},G={class:"ccb-repeater-item--actions"},J={class:"ccb-repeater-actions"},K=R({__name:"Repeater",props:{field:{}},setup(E){const y=E,{field:e}=S(y),f=$(),c=x({}),k=d(()=>a=>Array.from(a.values())),C=a=>{if(confirm("Are you sure to delete the repeated group of elements?")){const o=e.value.groupElements;Array.isArray(o)&&e.value.groupElements.splice(a,1),e.value.groupElements.forEach((i,t)=>Array.from(i.entries()).forEach(([r,s])=>{s.repeaterIdx=t})),f.recalculateTotals()}},A=()=>{var r;if(e.value.repeatCount===e.value.groupElements.length)return;const a=q(),o=new Map,i=e.value.originalElements||[];for(const s of i){const v=a.addField(s,e.value.groupElements.length,e.value.alias);v&&o.set(s.alias,v)}const t=e.value.groupElements.length-1;e.value.groupElements.push(o),(r=e.value)!=null&&r.collapseOnAddAnother&&t>=0&&(c.value[t]=!0),f.recalculateTotals()},F=d(()=>+e.value.repeatCount===e.value.groupElements.length),B=d(()=>{var a;return((a=e.value)==null?void 0:a.additionalStyles)||""});return(a,o)=>(n(),u("div",M,[(n(!0),u(_,null,b(p(e).groupElements,(i,t)=>(n(),u("div",{class:I(["ccb-repeater-item",{"ccb-collapsed":c.value[t],[B.value]:!0}])},[l("div",{class:"ccb-repeater-item--header",onClick:r=>c.value[t]=!c.value[t]},[o[0]||(o[0]=l("span",{class:"ccb-repeater-item--icon ccb-icon-Path-3514"},null,-1)),l("span",z,g(p(e).label),1),l("span",H,"#"+g(t+1),1)],8,P),m(L,{name:"fade"},{default:T(()=>{var r;return[c.value[t]?w("",!0):(n(),u("div",O,[l("div",j,[(n(!0),u(_,null,b(k.value(i),s=>(n(),N(V,{key:s.alias,name:s.fieldName,field:s},null,8,["name","field"]))),128))]),l("div",G,[m(h,{type:"danger","on-click":()=>C(t),text:p(e).removeButtonLabel,icon:"ccb-icon-Trash-filled","icon-position":"before",disabled:((r=p(e).groupElements)==null?void 0:r.length)===1},null,8,["on-click","text","disabled"])])]))]}),_:2},1024)],2))),256)),l("div",J,[m(h,{type:"success-outlined","on-click":A,text:p(e).addButtonLabel,icon:"ccb-icon-Add-Plus-Circle","icon-position":"before",disabled:F.value},null,8,["text","disabled"])])]))}}),se=D(K,[["__scopeId","data-v-2f445028"]]);export{se as default};
//# sourceMappingURL=index-DCbzwaIx.js.map
