import{T as x}from"./vendor-vue-runtime-dom-B2rky8vu.js";import{a as R}from"./MobileTotalSummary-DueRF4Zq.js";import{_}from"./Button.vue_vue_type_style_index_0_lang-CxqKrtR4.js";import{u as S,p as T}from"./fieldsStore-CQRN0FvQ.js";import{d as I,e as m,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}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-BSjzAbGy.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-BevSHYnU.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"./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(),c=$({}),k=m(()=>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=T(),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=m(()=>+e.value.repeatCount===e.value.groupElements.length),B=m(()=>{var a;return((a=e.value)==null?void 0:a.additionalStyles)||""});return(a,o)=>(n(),p("div",j,[(n(!0),p(b,null,g(u(e).groupElements,(i,t)=>(n(),p("div",{class:M(["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",D,h(u(e).label),1),l("span",O,"#"+h(t+1),1)],8,z),d(x,{name:"fade"},{default:N(()=>{var r;return[c.value[t]?w("",!0):(n(),p("div",q,[l("div",G,[(n(!0),p(b,null,g(k.value(i),s=>(n(),L(R,{key:s.alias,name:s.fieldName,field:s},null,8,["name","field"]))),128))]),l("div",H,[d(_,{type:"danger","on-click":()=>C(t),text:u(e).removeButtonLabel,icon:"ccb-icon-Trash-filled","icon-position":"before",disabled:((r=u(e).groupElements)==null?void 0:r.length)===1},null,8,["on-click","text","disabled"])])]))]}),_:2},1024)],2))),256)),l("div",J,[d(_,{type:"success-outlined","on-click":A,text:u(e).addButtonLabel,icon:"ccb-icon-Add-Plus-Circle","icon-position":"before",disabled:F.value},null,8,["text","disabled"])])]))}}),he=P(K,[["__scopeId","data-v-04b9c087"]]);export{he as default};
//# sourceMappingURL=index-k-6GetpK.js.map
