import{j as e,u as s}from"./fields-wnm5Jtc6.js";import{M as m}from"./index-76LCHVw3.js";import{a as l,R as x,L as g}from"./vendor-D21mNUGX.js";import{P as c,w as b,u as E,a as R,ac as A,A as C,s as S}from"./index-pmrLY__j.js";import{T,a as u}from"./index-D8v0Ahx2.js";import{C as j}from"./index-D1Z9ck5W.js";const v=({belongsTo:o,find:n})=>{const[h,p]=l.useState({}),[r,i]=l.useState(!1);return l.useEffect(()=>{r===!0&&b("exportCodeAction",{belongsTo:o,find:n}).then(t=>{p(t)}).catch(t=>{console.error(t.message)})},[r]),e.jsxs(x.Fragment,{children:[e.jsx(m,{title:s("Export code"),visible:r,textAlign:"left",children:e.jsxs(T,{children:[e.jsx(u,{title:"WORDPRESS",children:e.jsx(j,{language:"php",code:h.wordpress,editable:!1})}),e.jsx(u,{title:"ACPT",children:e.jsx(j,{language:"php",code:h.acpt,editable:!1})})]})}),e.jsx("a",{href:"#",onClick:t=>{t.preventDefault(),i(!r)},children:s("Export code")})]})};v.propTypes={belongsTo:c.string.isRequired,find:c.string.isRequired};const M=({belongsTo:o,find:n})=>{const p=document.globals.globals,r=E(),{data:i,loading:t}=R(a=>a.fetchMeta),[d,f]=l.useState(!1);return l.useEffect(()=>{d&&r(A({belongsTo:o,find:n}))},[d,o,n]),e.jsxs(x.Fragment,{children:[e.jsx(m,{title:s("Associated meta fields"),visible:d,textAlign:"left",children:t?e.jsx("div",{children:s("Loading...")}):e.jsx(x.Fragment,{children:i.records&&i.records.length>0?e.jsx("div",{className:"responsive with-shadow b-rounded",children:e.jsxs("table",{className:`acpt-table ${p.is_rtl?"rtl":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("Group name")}),e.jsx("th",{children:s("Fields count")}),e.jsx("th",{children:s("Actions")})]})}),e.jsx("tbody",{children:i.records.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.name}),e.jsx("td",{children:a.fieldsCount}),e.jsx("td",{children:e.jsx("div",{className:"i-flex-center s-8",children:e.jsx(g,{to:`/edit_meta/${a.id}`,children:s("Edit")})})})]}))})]})}):e.jsx(C,{style:S.SECONDARY,children:s("No meta group found.")})})}),e.jsx("a",{href:"#",onClick:a=>{a.preventDefault(),f(!d)},children:s("Show")})]})};M.propTypes={belongsTo:c.string.isRequired,find:c.string.isRequired};export{v as E,M as F};
