import{j as s,u as t}from"./fields-wnm5Jtc6.js";import{R as T,u as S,a as x,h as C}from"./vendor-D21mNUGX.js";import{P as c,w as P,r as N,a as q,u as L,h as E,m as $,c as A,L as k,s as m}from"./index-pmrLY__j.js";import{P as B}from"./index-D0W-z-hb.js";import{B as j}from"./index-CRkUIX16.js";import{s as I,n as M,B as D,f as F,L as W}from"./Layout-CFk9FOHT.js";import{C as a}from"./CardRow-Bf5pkBel.js";import{C as g}from"./index-5Ilcd7WA.js";import{t as V}from"./taxonomyLabels-D1-o3InT.js";import{B as i}from"./index-z-Hpcrdu.js";const p=({data:e})=>{if(e.length>0)return s.jsxs(g,{children:[s.jsx(a,{label:t("Slug"),value:e[0].slug}),s.jsx(a,{label:t("Singular"),value:e[0].singular}),s.jsx(a,{label:t("Plural"),value:e[0].plural})]})};p.propTypes={data:c.object.isRequired};const v=({taxonomy:e,data:o})=>{const u=()=>{P("regenerateTaxonomyLabelsAction",{taxonomy:e}).then(l=>{l.success&&(I("Labels successfully regenerated"),N(50)),l.error&&M.error(error)}).catch(l=>{console.error(l.message)})};if(o.length>0)return s.jsxs(g,{children:[s.jsxs("div",{className:"acpt-card-row",children:[s.jsx("span",{className:"label",children:s.jsx("a",{style:{fontWeight:"normal"},href:"#",onClick:l=>{l.preventDefault(),u()},children:t("Regenerate")})}),s.jsx("span",{className:"value"})]}),V.map(l=>s.jsx(a,{index:l.id,label:t(l.label),value:o[0].labels[l.id]}))]})};v.propTypes={taxonomy:c.string.isRequired,data:c.object.isRequired};const f=({data:e})=>{if(e.length>0)return s.jsxs(g,{children:[s.jsx(a,{label:t("Is Public"),value:s.jsx(i,{status:e[0].settings.public})}),s.jsx(a,{label:t("Publicly queryable"),value:s.jsx(i,{status:e[0].settings.publicly_queryable})}),s.jsx(a,{label:t("Hierarchical"),value:s.jsx(i,{status:e[0].settings.hierarchical})}),s.jsx(a,{label:t("Show in menu"),value:s.jsx(i,{status:e[0].settings.show_in_menu})}),s.jsx(a,{label:t("Show in nav menus"),value:s.jsx(i,{status:e[0].settings.show_in_nav_menus})}),s.jsx(a,{label:t("Show in REST API"),value:s.jsx(i,{status:e[0].settings.show_in_rest})}),s.jsx(a,{label:t("REST API base slug"),value:e[0].settings.rest_base}),s.jsx(a,{label:t("REST Controller class"),value:e[0].settings.rest_controller_class}),s.jsx(a,{label:t("Show Tagcloud"),value:s.jsx(i,{status:e[0].settings.show_tagcloud})}),s.jsx(a,{label:t("Show Tagcloud"),value:s.jsx(i,{status:e[0].settings.show_in_quick_edit})}),s.jsx(a,{label:t("Show admin column"),value:s.jsx(i,{status:e[0].settings.show_admin_column})}),s.jsx(a,{label:t("Capabilities"),value:s.jsx("div",{className:"i-flex-center s-8",children:e[0].settings.capabilities&&e[0].settings.capabilities.map(o=>s.jsx(D,{children:o}))})}),s.jsx(a,{label:t("Rewrite"),value:s.jsx(i,{status:e[0].settings.rewrite})}),e[0].settings.rewrite&&s.jsxs(T.Fragment,{children:[s.jsx(a,{label:t("Custom rewrite"),value:e[0].settings.custom_rewrite}),s.jsx(a,{label:t("With front"),value:s.jsx(i,{status:e[0].settings.with_front})}),s.jsx(a,{label:t("Rewrite hierarchical"),value:s.jsx(i,{status:e[0].settings.rewrite_hierarchical})})]}),s.jsx(a,{label:t("Query var"),value:s.jsx(i,{status:e[0].settings.query_var})}),s.jsx(a,{label:t("Custom query var"),value:s.jsx(i,{status:e[0].settings.custom_query_var})})]})};f.propTypes={data:c.object.isRequired};const Z=()=>{const{data:e,loading:o}=q(r=>r.fetchTaxonomies),u=L(),{taxonomy:l}=S(),[n,d]=x.useState(0),[y,h]=x.useState(!1),w=C();if((l==="category"||l==="product_cat")&&w("/"),x.useEffect(()=>{u(E({taxonomy:l})).then(r=>{r.payload.length!==1&&h(!0),$(`${r.payload[0].singular}: ${t("global settings")}`),F()}).catch(r=>{h(!0),console.error(r)}),A("#/taxonomies")},[l]),o)return s.jsx(k,{});if(y)return s.jsx(B,{});const _=[s.jsx(j,{style:m.PRIMARY,to:`/edit_taxonomy/${l}/${n}`,children:t("Edit")}),s.jsx(j,{style:m.SECONDARY,to:`/assoc-post-taxonomy/${l}`,children:t("Taxonomies association")}),s.jsx(j,{style:m.WARNING,to:`/permissions/taxonomy/${l}/${e.length>0?e[0].id:""}`,children:t("Permissions")})],R=["Basic","Labels","Settings"];return s.jsx(W,{title:t("Taxonomy global settings"),actions:_,crumbs:[{label:t("Registered Taxonomies"),link:"/taxonomies"},{label:`${e.length>0?e[0].singular:""}: ${t("global settings")}`}],children:s.jsxs("div",{children:[s.jsx("div",{className:"acpt-tabs",children:s.jsx("ul",{role:"tablist",className:"tablist mb-12",children:R.map((r,b)=>s.jsx("li",{className:`acpt-accordion-tab ${n===b?"active":""}`,onClick:()=>{d(parseInt(b))},children:r}))})}),n===0&&s.jsx(p,{data:e}),n===1&&s.jsx(v,{data:e,taxonomy:l}),n===2&&s.jsx(f,{data:e})]})})};export{Z as default};
