import{d as r}from"./vendor-pinia-BSPefQhS.js";import{u}from"./fieldsStore-CQRN0FvQ.js";const p=["checkbox","checkbox_with_img","toggle"],f=["dropDown","dropDown_with_img","radio","radio_with_img"],h=r("page_breaker_store",{state:()=>({conditions:{},disableNextButton:!1}),getters:{getConditions:e=>e.conditions,getDisableNextButton:e=>e.disableNextButton},actions:{updateConditions(e){this.conditions=e},setDisableNextButton(e){this.disableNextButton=e},initPageConditions(){u().getPages.filter(s=>"groupElements"in s&&"conditions"in s).forEach(s=>{this.updateConditions({...this.getConditions,[s.alias]:s.conditions})})},checkPageFieldsConditions(){const e=u(),t=[],s=e.getActivePage,l=s.condition;Array.isArray(s.conditions)&&s.conditions.forEach(n=>{const o=e.getField(n.field);if(!o)return!1;const i=this.checkFieldCondition(o,n);t.push(i)});let d=!1;return l==="and"?d=t.every(n=>n):l==="any"&&(d=t.some(n=>n)),s.action==="not_skip"&&this.setDisableNextButton(d),d},checkFieldCondition(e,t){var d,n;let s=!1;const l=e.value;switch(t.condition){case"==":if(f.includes(e.fieldName)&&"selectedOption"in e&&!Array.isArray(e.selectedOption)){const o=((n=(d=e==null?void 0:e.selectedOption)==null?void 0:d.optionValue)==null?void 0:n.split("_")[1])||void 0;o===void 0?s=!1:s=t.key==="any"?!!o:+o==+t.key}else s=l===+t.value;break;case"!=":s=l!==+t.value;break;case">=":s=Number(l||0)>+t.value;break;case"<=":s=Number(l||0)<+t.value;break;case"in":if(p.includes(e.fieldName)&&"selectedOption"in e){const o=Array.isArray(e.selectedOption)?e.selectedOption:[],i=(o==null?void 0:o.map(a=>{var c;return+((c=a.optionValue)==null?void 0:c.split("_")[1])}))||[];s=Array.from(t.checkedValues).every(a=>i.includes(a))}break;case"not in":if(p.includes(e.fieldName)&&"selectedOption"in e){const i=(Array.isArray(e.selectedOption)?e.selectedOption:[]).map(a=>{var c;return+((c=a.optionValue)==null?void 0:c.split("_")[1])})||[];s=Array.from(t.checkedValues).every(a=>!i.includes(a))}break;case"contains":if(p.includes(e.fieldName)&&"selectedOption"in e){const i=(Array.isArray(e.selectedOption)?e.selectedOption:[]).map(a=>{var c;return+((c=a.optionValue)==null?void 0:c.split("_")[1])})||[];s=t.key==="any"?i.length>0:i.includes(Number(t.key))}break;default:s=!1}return s}}});export{h as u};
//# sourceMappingURL=pageBreakerStore-BevSHYnU.js.map
