import{j as e,u as t}from"./fields-wnm5Jtc6.js";import{a as j,R as y}from"./vendor-D21mNUGX.js";import{u as R,b as k}from"./index.esm-DCQn2FO4.js";import{P as v,aK as E,cJ as w,B as A,s as N}from"./index-pmrLY__j.js";import{u as O}from"./index-DRV1MUeg.js";import{M as B}from"./index-76LCHVw3.js";import{m as b}from"./metaTypes-Bb9tjSPe.js";const g=({belongsTo:n})=>{const a=document.globals.globals,h=a.is_rtl,l=a.find,r=E(n),[c,p]=j.useState(!1),[o,i]=j.useReducer(s=>s+1,0),f=s=>{if(l[n])switch(n){case"block":case"dataset":case"form":case"woo_product_data":case b.META:const d=l[n].filter(x=>x.value===s);return d.length!==1?void 0:d[0].label;case b.OPTION_PAGE:const u=l[n].filter(x=>x.id===s);return u.length!==1?void 0:u[0].label;default:return s}};return r.length===0?null:e.jsxs(y.Fragment,{children:[e.jsx(B,{title:t("Restore elements"),visible:c,buttons:[],children:e.jsxs("table",{className:`acpt-table with-border ${h?"rtl":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("Name")}),e.jsx("th",{children:t("Action")})]})}),e.jsx("tbody",{children:r.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:f(s)}),e.jsx("td",{children:e.jsx("a",{href:"#",onClick:d=>{d.preventDefault(),w(s,n),i();const u=new Event("restoredElement");document.dispatchEvent(u)},children:t("Restore")})})]}))})]})}),e.jsxs("div",{className:"flex s-8 mb-24",children:[e.jsxs("span",{children:[r.length," ",t("hidden elements")]}),e.jsx("a",{href:"#",onClick:s=>{s.preventDefault(),p(!c)},children:t("Restore elements")})]})]})};g.propTypes={belongsTo:v.string.isRequired};const M=({belongsTo:n})=>{const m=E(n),[a]=O(),{control:h,register:l}=R(),r=k({control:h,name:"elements"}),c=()=>{if(!r)return!1;for(const[o,i]of Object.entries(r))if(i===!0)return!0;return!1},p=()=>{let o=0;for(const[i,f]of Object.entries(r))f===!0&&o++;return o};return e.jsxs("div",{ref:a,children:[m&&m.length>0&&e.jsx(g,{belongsTo:n}),c()&&e.jsxs("div",{className:"flex-between s-8 mb-24","data-cy":"bulk-actions",children:[e.jsxs("span",{children:[p()," ",t("Selected items")]}),e.jsxs("div",{className:"i-flex-center s-8",children:[e.jsxs("select",{name:"action","data-cy":"cpt-bulk-actions",className:"form-control sm",...l("action"),children:[e.jsx("option",{value:"",children:t("Select")}),e.jsx("option",{value:"delete",children:t("Delete")}),e.jsx("option",{value:"duplicate",children:t("Duplicate")}),e.jsx("option",{value:"hide",children:t("Hide")})]}),e.jsx(A,{testId:"cpt-bulk-actions",style:N.WHITE,size:"sm",children:t("Execute")})]})]})]})};M.propTypes={belongsTo:v.string.isRequired};export{M as B};
