"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[490],{26781:function(e,t,n){n.r(t),n.d(t,{default:function(){return x}});var a=n(3453),r=n(51609),i=n(17437),l=n(27723),c=n(1455),o=n.n(c),u=n(75532),s=["160px","120px","180px"],d=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new URLSearchParams;return t.forEach((function(e){return r.append("ids[]",e)})),Object.entries(n).forEach((function(e){var t=(0,a.A)(e,2),n=t[0],i=t[1];null!=i&&r.append(n,String(i))})),"".concat(e,"?").concat(r.toString())},m=function(e,t){var n=new URL(window.location.href);return n.search=new URLSearchParams({page:e,action:"edit",id:t}).toString(),n.toString()},p={name:"12pfexa",styles:"gap:1em"},h={name:"1hsulih",styles:"font-size:13px;margin:0;padding-left:1.2em;li{margin-bottom:0.25em;}li a{display:inline-flex;align-items:center;gap:0.5em;color:var(\n\t\t\t\t\t\t\t\t\t\t\t\t\t--sc-color-danger-500\n\t\t\t\t\t\t\t\t\t\t\t\t);text-decoration:none;}li a:hover{text-decoration:underline;}"},f={name:"1dqz4cy",styles:"font-size:24px;color:var(--sc-color-danger-500)"},g={name:"e1ptu",styles:"width:100%;max-width:600px"},y={name:"1j2t2ez",styles:"padding-top:3em;display:flex;justify-content:center"};function x(e){var t=e.navigation,n=t.bulkDeleteIds,c=void 0===n?[]:n,x=t.goToList,v=t.pageSlug,b="sc-bundles"===v,Y=(0,r.useState)([]),w=(0,a.A)(Y,2),k=w[0],_=w[1],S=(0,r.useState)(!0),A=(0,a.A)(S,2),C=A[0],D=A[1],z=(0,r.useState)(!1),E=(0,a.A)(z,2),N=E[0],T=E[1],$=(0,r.useState)(null),F=(0,a.A)($,2),P=F[0],j=F[1];(0,r.useEffect)((function(){0===c.length&&x()}),[c,x]),(0,r.useEffect)((function(){if(0!==c.length){var e=!1;return D(!0),j(null),o()({path:d("/surecart/v1/products",c,{per_page:c.length})}).then((function(t){e||_(Array.isArray(t)?t:[])})).catch((function(t){e||j((null==t?void 0:t.message)||(b?(0,l.__)("Failed to load bundles.","surecart"):(0,l.__)("Failed to load products.","surecart")))})).finally((function(){e||D(!1)})),function(){e=!0}}}),[c]);var L=(0,r.useCallback)((function(){var e;if(!N){T(!0);var t=document.createElement("form");t.method="POST",t.action="".concat(window.location.pathname,"?page=").concat(v);var n=function(e,n){var a=document.createElement("input");a.type="hidden",a.name=e,a.value=n,t.appendChild(a)};n("nonce",(null===(e=window.scData)||void 0===e?void 0:e.bulk_delete_nonce)||""),n("confirm-bulk-delete","true"),c.forEach((function(e){return n("bulk_action_product_ids[]",e)})),document.body.appendChild(t),t.submit()}}),[N,c]),R=C?c.length:k.length;return(0,i.Y)("div",{className:"wrap"},(0,i.Y)("div",{css:y},(0,i.Y)("div",{css:g},(0,i.Y)("sc-card",{style:{display:"block",width:"100%","--sc-card-padding":"var(--sc-spacing-xxx-large)"}},(0,i.Y)("sc-flex",{"flex-direction":"column",style:{"--sc-flex-column-gap":"1em"}},(0,i.Y)("sc-icon",{name:"alert-triangle",css:f}),C?(0,i.Y)(u.euC,{flexDirection:"column",style:{"--sc-flex-column-gap":"1em"}},(0,i.Y)(u.k$N,{style:{width:"60%",height:"1.5em"}}),(0,i.Y)(u.euC,{flexDirection:"column",style:{"--sc-flex-column-gap":"0.4em"}},(0,i.Y)(u.k$N,{style:{width:"100%",height:"1em"}}),(0,i.Y)(u.k$N,{style:{width:"75%",height:"1em"}})),(0,i.Y)(u.euC,{flexDirection:"column",style:{"--sc-flex-column-gap":"0.6em"}},c.map((function(e,t){return(0,i.Y)(u.k$N,{key:e,style:{width:s[t%s.length],height:"1em"}})})))):(0,i.Y)(r.Fragment,null,(0,i.Y)("sc-heading",{size:"large"},b?(0,l._n)("Delete Bundle","Delete Bundles",R||1,"surecart"):(0,l._n)("Delete Product","Delete Products",R||1,"surecart")),(0,i.Y)("sc-text",null,b?(0,l._n)("Are you sure you want to permanently delete this bundle? This cannot be undone.","Are you sure you want to permanently delete these bundles? This cannot be undone.",R||1,"surecart"):(0,l._n)("Are you sure you want to permanently delete this product? This cannot be undone.","Are you sure you want to permanently delete these products? This cannot be undone.",R||1,"surecart")),P&&(0,i.Y)("sc-alert",{type:"danger",open:!0},P),(0,i.Y)("ul",{css:h},k.map((function(e){return(0,i.Y)("li",{key:e.id},(0,i.Y)("a",{href:m(v,e.id),target:"_blank",rel:"noreferrer"},e.name,(0,i.Y)("sc-icon",{name:"external-link"})))})))),(0,i.Y)("sc-flex",{"justify-content":"flex-start",css:p},C?(0,i.Y)(r.Fragment,null,(0,i.Y)(u.k$N,{style:{width:"90px",height:"36px","--border-radius":"var(--sc-input-border-radius-medium, 6px)"}}),(0,i.Y)(u.k$N,{style:{width:"70px",height:"36px","--border-radius":"var(--sc-input-border-radius-medium, 6px)"}})):(0,i.Y)(r.Fragment,null,(0,i.Y)("sc-button",{size:"medium",type:"danger",loading:N||void 0,disabled:N||!!P||void 0,onClick:L},(0,l.__)("Delete","surecart")),(0,i.Y)("sc-button",{size:"medium",type:"link",disabled:N||void 0,onClick:function(){return x()}},(0,l.__)("Cancel","surecart")))))))))}}}]);