import{g as l,A as c,j as t,a6 as F,ab as I,B as u,C as T,J as d,a8 as w,H as v,t as i,P as b,O as _,K as k,L as N,c as D,r as $}from"./index-DOFLUERq.js";import E from"./Section-DxBAHwzX.js";import L from"./EditableInput-DhGmkLrc.js";import{u as z,i as V,c as G,s as K}from"./utils-DMBE_oxT.js";import{d as x}from"./vuedraggable.umd-CrsnNXKf.js";import{u as M}from"./index-CRx3oDcD.js";import{I as P}from"./iconify-p99pbjf9.js";import{_ as R}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{h as j}from"./index-DuPUrsw1.js";import"./Column-Cl9RGhQs.js";import"./Field-DRxYLPpS.js";import"./AddFieldButton-DEq3S2HV.js";import"./Autocomplete-SEbcHX6m.js";import"./Dropdown-MNW89qbM.js";import"./_commonjsHelpers-CE1G-McA.js";const H={key:0,class:"tab-header"},J=["title","data-is-user-generated","onClick","onDragover"],Y=["title","onClick","hidden"],q=["hidden"],Q=["title"],W={class:"add-btn-text"},X={class:"tab-contents"},Z=["hidden"],ee={key:0},te={key:1},ae={__name:"Tabs",setup(se){const e=z(),{Backspace:C}=M();j(C,s=>{s&&O.value&&e.notUsingInput&&g(e.currentTab,"",!0)});const p=$(!1),O=D(()=>e.selected(e.currentTab?.df?.name)),f=D(()=>e.form.layout.tabs.length>1);e.form.layout.tabs.length>0&&!e.form.active_tab&&(e.form.active_tab=e.form.layout.tabs[0].df.name);function A(s){e.activateTab(s)}function B(s){!p.value&&setTimeout(()=>{e.form.active_tab=s.df.name},500)}function U(){e.addNewTab()}function S(){let s=K(e.getDf);e.currentTab.sections.push(s),e.form.selected_field=s.df}function h(s){return!s.sections.some(n=>n.columns.some(a=>a.fields.length))}function g(s,n,a=!1){if(!(!n?.currentTarget?.offsetParent&&!a)){if(e.isCustomizeForm&&e.currentTab.df.is_custom_field===0)throw alert(i("Cannot delete standard field. You can hide it if you want")),"cannot delete standard field";e.hasStandardField(e.currentTab)?m(s):h(s)?m(s,!0):G(i("Delete Tab"),i("Are you sure you want to delete the tab? All the sections along with fields in the tab will be moved to the previous tab."),()=>m(s),i("Delete tab"),()=>m(s,!0),i("Delete entire tab with fields"))}}function m(s,n){let a=e.form.layout.tabs,o=a.indexOf(s);if(!n)if(o>0){let y=a[o-1];h(s)||(y.sections=[...y.sections,...s.sections])}else a.unshift({df:e.getDf("Tab Break","",i("Details")),sections:s.sections,is_first:!0}),o++;a.splice(o,1);let r=o===0?0:o-1;e.form.active_tab=a[r].df.name,e.form.selected_field=null}return(s,n)=>(l(),c(k,null,[t(e).form.layout.tabs.length>1?(l(),c("div",H,[F(u(t(x),{class:"tabs",modelValue:t(e).form.layout.tabs,"onUpdate:modelValue":n[2]||(n[2]=a=>t(e).form.layout.tabs=a),group:"tabs",delay:t(V)()?200:0,animation:200,easing:t(e).getAnimation,"item-key":"id",disabled:t(e).readOnly},{item:T(({element:a})=>[d("div",{class:v(["tab",t(e).form.active_tab===a.df.name?"active":""]),title:a.df.fieldname,"data-is-user-generated":t(e).isUserGeneratedField(a),onClick:w(o=>A(a),["stop"]),onDragstart:n[0]||(n[0]=o=>p.value=!0),onDragend:n[1]||(n[1]=o=>p.value=!1),onDragover:o=>B(a)},[u(L,{text:a.df.label,placeholder:t(i)("Tab Label"),modelValue:a.df.label,"onUpdate:modelValue":o=>a.df.label=o},null,8,["text","placeholder","modelValue","onUpdate:modelValue"]),d("button",{class:"remove-tab-btn btn btn-xs",title:t(i)("Remove tab"),onClick:w(o=>g(a,o),["stop"]),hidden:t(e).readOnly},[u(t(P),{icon:"mdi:close",class:"icon-sm"})],8,Y)],42,J)]),_:1},8,["modelValue","delay","easing","disabled"]),[[I,f.value]]),d("div",{class:"tab-actions",hidden:t(e).readOnly},[d("button",{class:v(["new-tab-btn btn btn-xs",{"no-tabs":!f.value}]),title:t(i)("Add new tab"),onClick:U},[d("div",W,b(t(i)("Add tab")),1)],10,Q)],8,q)])):_("",!0),d("div",X,[(l(!0),c(k,null,N(t(e).form.layout.tabs,(a,o)=>(l(),c("div",{class:v(["tab-content",[t(e).form.active_tab===a.df.name?"active":""]]),key:o},[u(t(x),{class:"tab-content-container",modelValue:a.sections,"onUpdate:modelValue":r=>a.sections=r,group:"sections",delay:t(V)()?200:0,animation:200,easing:t(e).getAnimation,"item-key":"id",disabled:t(e).readOnly},{item:T(({element:r})=>[u(E,{tab:a,section:r,"data-is-user-generated":t(e).isUserGeneratedField(r)},null,8,["tab","section","data-is-user-generated"])]),_:2},1032,["modelValue","onUpdate:modelValue","delay","easing","disabled"]),d("div",{class:"empty-tab",hidden:t(e).readOnly},[f.value?(l(),c("div",ee,b(t(i)("Drag & Drop a section here from another tab")),1)):_("",!0),f.value?(l(),c("div",te,b(t(i)("OR")),1)):_("",!0),d("button",{class:"btn btn-default btn-sm",onClick:S},b(t(i)("Add a new section")),1)],8,Z)],2))),128))])],64))}},ge=R(ae,[["__scopeId","data-v-d9c8f43a"]]);export{ge as default};
