import{d as D,bm as F,A as b,bn as o,bo as _,h as r,bu as s,a9 as t,aa as h,by as O,bq as i,bw as V,a4 as K,bs as L,bC as A,bz as E,bJ as N}from"./preload-helper.BAt0wiQU.js";import{a as R,b as U,c as $,g as q,l as z,_ as I,s as J,e as w}from"../apps/settings/index.DetZ7Cvo.js";import{u as M}from"./settings-store.DAVbzJl3.js";import{_ as W}from"./ChildTabs.vue_vue_type_script_setup_true_lang.DPcG3VYt.js";import G from"../apps/settings/upgrade/LicenseInterstitial.Bwua1H7J.js";import{T as H,A as Q}from"./index.C7EHgkrV.js";import{B as X}from"./index.BQlS3R_s.js";import{F as Y,M as Z}from"./index.BsGj85Vg.js";const ee="wwp-parent-tab",ce=D({__name:"ParentTabs",setup(te){var g,v;const C=M(),{isLoading:p,showPopup:u,componentUpgrade:S}=F(C),c=R.settings.tabs,f=b([]),T=U("tab"),m=$(T,c),k=b((v=(g=Object.values(c))==null?void 0:g[0])!=null?v:""),d=b(m!=null?m:k.value.key),x=l=>{Object.entries(l).forEach(([a,e])=>{f.value[a]=e})},P=async l=>{l.preventDefault(),p.value=!0;const a=[];for(const[e,n]of Object.entries(f.value)){let y=n;typeof n=="object"&&n!==null&&(y=JSON.stringify(n)),a.push({key:e,value:y})}try{J(a),setTimeout(()=>{p.value=!1},1e3)}catch(e){console.error(e)}},j=()=>{u.value=!1},B=l=>{w("tab",l),w("tab-child","")};return(l,a)=>(o(),_(h,null,[r(t(Y),{id:"wwp-admin-tab-settings",method:"post",onSubmit:P},{default:s(()=>[r(t(H),{activeKey:d.value,"onUpdate:activeKey":a[0]||(a[0]=e=>d.value=e),"destroy-inactive-tab-pane":!0,onChange:a[1]||(a[1]=e=>B(d.value))},{rightExtra:s(()=>[r(t(X),{type:"primary","html-type":"submit",class:"wwp-settings-save-btn",loading:t(p)},{default:s(()=>[K(L(t(q)("submitText",t(wp.i18n.__)("Save Changes","woocommerce-wholesale-prices"))),1)]),_:1},8,["loading"])]),default:s(()=>[(o(!0),_(h,null,O(t(c),(e,n)=>(o(),i(t(Q),{key:n,class:V(ee),tab:e.label},{default:s(()=>[e!=null&&e.interstitial?(o(),i(G,{key:0,"interstitial-details":e.interstitial_details},null,8,["interstitial-details"])):(o(),i(W,{key:1,"parent-tab":n.toString(),"parent-data":e.child,onFieldData:x},null,8,["parent-tab","parent-data"]))]),_:2},1032,["tab"]))),128))]),_:1},8,["activeKey"])]),_:1}),r(t(Z),{open:t(u),"onUpdate:open":a[2]||(a[2]=e=>N(u)?u.value=e:null),centered:"",title:null,footer:null,onCancel:j},{default:s(()=>[(o(),i(A,null,{fallback:s(()=>[r(I)]),default:s(()=>[(o(),i(E(t(z)(t(S)))))]),_:1}))]),_:1},8,["open"])],64))}});export{ce as _};
