import{T as x}from"./vendor-vue-runtime-dom-B2rky8vu.js";import{a as R}from"./MobileTotalSummary.vue_vue_type_style_index_0_lang-CAUpXdiw.js";import{_}from"./Button.vue_vue_type_style_index_0_lang-CxqKrtR4.js";import{u as S,p as T}from"./fieldsStore-CNpVuoPu.js";import{d as I,e as u,f as p,i as n,x as l,F as b,r as g,j as d,m as N,t as w,k as L}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as V,r as $,u as m}from"./vendor-vue-reactivity-CheHbvBM.js";import{a as M,t as h}from"./vendor-vue-shared-DrzsEcag.js";import{_ as P}from"./vendor-vue3-html2pdf-KR020wX8.js";import"./convert-case-to-camel-case.utils-CK5dBN7n.js";import"./widget-RmM7xAIR.js";import"./appStore-CFAkQG2b.js";import"./vendor-pinia-BSPefQhS.js";import"./appearanceStore-Cp-euDX2.js";import"./settingsStore-8bwiLMEn.js";import"./translationsStore-D6vLzgNA.js";import"./pageBreakerStore-Bkj6mcUr.js";import"./vendor-vueform-slider-CCH9_7pb.js";import"./vendor-moment-Cv92BTSA.js";import"./vendor-bootstrap-CCU-90um.js";import"./vendor-jspdf-UFhKzYHA.js";import"./vendor-php-date-formatter-DSpPwBF8.js";import"./callbackStore-BhxBUA6V.js";import"./index-D2j7l29-.js";import"./Wrapper.vue_vue_type_script_setup_true_lang-D49ddy6w.js";import"./Popup.vue_vue_type_style_index_0_lang-uNTBWSeR.js";import"./ThankYouPage-CQHohb6N.js";import"./ProBadge.vue_vue_type_style_index_0_lang-DqDXUf8-.js";import"./vendor-html2pdf.js-B-tok4Ns.js";import"./vendor-html2canvas-BfYXEYrK.js";const j={class:"ccb-repeater-wrapper"},z=["onClick"],D={class:"ccb-repeater-item--label"},O={class:"ccb-repeater-item--counter"},q={key:0,class:"ccb-repeater-item--body"},G={class:"ccb-repeater-item--fields"},H={class:"ccb-repeater-item--actions"},J={class:"ccb-repeater-actions"},K=I({__name:"Repeater",props:{field:{}},setup(E){const y=E,{field:e}=V(y),f=S(),i=$({}),k=u(()=>o=>Array.from(o.values())),C=o=>{if(confirm("Are you sure to delete the repeated group of elements?")){const a=e.value.groupElements;Array.isArray(a)&&e.value.groupElements.splice(o,1),e.value.groupElements.forEach((c,t)=>Array.from(c.entries()).forEach(([s,r])=>{r.repeaterIdx=t})),f.recalculateTotals()}},A=()=>{var s;if(e.value.repeatCount===e.value.groupElements.length)return;const o=T(),a=new Map,c=e.value.originalElements||[];for(const r of c){const v=o.addField(r,e.value.groupElements.length,e.value.alias);v&&a.set(r.alias,v)}const t=e.value.groupElements.length-1;e.value.groupElements.push(a),(s=e.value)!=null&&s.collapseOnAddAnother&&t>=0&&(i.value[t]=!0),f.recalculateTotals()},F=u(()=>+e.value.repeatCount===e.value.groupElements.length),B=u(()=>{var o;return((o=e.value)==null?void 0:o.additionalStyles)||""});return(o,a)=>(n(),p("div",j,[(n(!0),p(b,null,g(m(e).groupElements,(c,t)=>(n(),p("div",{class:M(["ccb-repeater-item",{"ccb-collapsed":i.value[t],[B.value]:!0}])},[l("div",{class:"ccb-repeater-item--header",onClick:s=>i.value[t]=!i.value[t]},[a[0]||(a[0]=l("span",{class:"ccb-repeater-item--icon ccb-icon-Path-3514"},null,-1)),l("span",D,h(m(e).label),1),l("span",O,"#"+h(t+1),1)],8,z),d(x,{name:"fade"},{default:N(()=>{var s;return[i.value[t]?w("",!0):(n(),p("div",q,[l("div",G,[(n(!0),p(b,null,g(k.value(c),r=>(n(),L(R,{key:r.alias,name:r.fieldName,field:r},null,8,["name","field"]))),128))]),l("div",H,[d(_,{type:"danger","on-click":()=>C(t),text:m(e).removeButtonLabel,icon:"ccb-icon-Trash-filled","icon-position":"before",disabled:((s=m(e).groupElements)==null?void 0:s.length)===1},null,8,["on-click","text","disabled"])])]))]}),_:2},1024)],2))),256)),l("div",J,[d(_,{type:"success-outlined","on-click":A,text:m(e).addButtonLabel,icon:"ccb-icon-Add-Plus-Circle","icon-position":"before",disabled:F.value},null,8,["text","disabled"])])]))}}),Ce=P(K,[["__scopeId","data-v-04b9c087"]]);export{Ce as default};
//# sourceMappingURL=index-B4H8Gp1W.js.map
