import{d as I,I as $,J as A,K as E,r,o as i,c,b as p,L as J,e as d,w,u as s,M as f,N as C,h as b,H as g,a as K,g as N,O as R,P as O}from"./index.DXvi0yH9.js";import{u as q}from"./settings-store.BEthvEFu.js";import{s as z}from"./pinia.D9yoqqEz.js";import{_ as H}from"./ChildTabs.vue_vue_type_script_setup_true_lang.DifOCvYJ.js";import{_ as U}from"./Notification.vue_vue_type_script_setup_true_lang.D_vuSbU1.js";import{p as W,x as G,I as Q,y as X,m as Y}from"./tabs.Ddypml2y.js";const Z={class:"stwlite-tw-w-full"},tt={key:0,class:"stwlite-tw-max-w-7xl stwlite-tw-mx-auto stwlite-tw-flex stwlite-tw-items-center stwlite-tw-space-x-4 stwlite-tw-px-3 stwlite-tw-pb-0 stwlite-tw-pt-6 stwlite-tw-border-0"},et=["onClick"],ct=I({__name:"ParentTabs",setup(st,{expose:j}){var T,V;const M=q(),{isLoading:v,inputValues:_}=z(M),a=$.settings.tabs,P=A("tab"),m=E(P,a),B=r((V=(T=Object.values(a))==null?void 0:T[0])!=null?V:""),y=r(m!=null?m:B.value.key),u=r(""),h=r(""),x=r(""),L=n=>{Object.entries(n).forEach(([l,t])=>{_.value[l]=t})},S=async n=>{v.value=!0;const l=[];for(const[t,e]of Object.entries(_.value)){let o=e;typeof e=="object"&&e!==null&&(o=JSON.stringify(e)),l.push({key:t,value:o})}try{const t=await R(l);t&&(x.value=t.title,u.value=t.message,h.value=t.type,v.value=!1)}catch(t){console.error(t)}};j({onSubmit:S});const D=n=>{O("tab",n),O("tab-child","")},F=()=>{u.value=""},k=Array.isArray(a)?a.length>1:Object.keys(a).length>1;return(n,l)=>(i(),c(f,null,[p("div",Z,[p("form",{id:"stw-admin-tab-settings",method:"post",onSubmit:J(S,["prevent"])},[d(s(Y),null,{default:w(()=>[s(k)?(i(),c("div",tt,[d(s(W),{class:"stwlite-tw-flex stwlite-tw-space-x-1 stwlite-tw-flex-1 stwlite-tw-rounded-md stwlite-tw-bg-white stwlite-tw-px-6 stwlite-tw-pt-6 stwlite-tw-shadow-sm stwlite-tw-border stwlite-tw-border-gray-200 stwlite-tw-border-solid"},{default:w(()=>[(i(!0),c(f,null,C(s(a),(t,e)=>(i(),b(s(G),{modelValue:y.value,"onUpdate:modelValue":l[0]||(l[0]=o=>y.value=o),as:"template",key:e},{default:w(({selected:o})=>[p("button",{onClick:lt=>D(e.toString()),class:g(["stwlite-tw-px-8 stwlite-tw-py-2.5 stwlite-tw-text-sm stwlite-tw-font-medium stwlite-tw-border-0 stwlite-tw-cursor-pointer stwlite-tw-bg-transparent focus:stwlite-tw-outline-none",o?"stwlite-tw-text-blue-700 stwlite-tw-border-b-2 stwlite-tw-border-blue-700":"stwlite-tw-border-b-2 stwlite-tw-border-transparent"])},K(t.label),11,et)]),_:2},1032,["modelValue"]))),128))]),_:1})])):N("",!0),d(s(Q),{class:g(["stwlite-tw-mt-2",s(k)?"":"stwlite-tw-pt-8"])},{default:w(()=>[(i(!0),c(f,null,C(s(a),(t,e)=>(i(),b(s(X),{key:e,class:g(["stwlite-tw-rounded-xl stwlite-tw-p-3","stwlite-tw-ring-white/60 stwlite-tw-ring-offset-2 stwlite-tw-ring-offset-blue-400"])},{default:w(()=>[d(H,{"parent-tab":e.toString(),"parent-data":t.child,onFieldData:L},null,8,["parent-tab","parent-data"])]),_:2},1024))),128))]),_:1},8,["class"])]),_:1})],32)]),u.value?(i(),b(U,{key:0,message:u.value,type:h.value,messageTitle:x.value,onCloseNotification:F},null,8,["message","type","messageTitle"])):N("",!0)],64))}});export{ct as _};
