!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,o,i=[],_n=!0,l=!1;try{for(n=n.call(e);!(_n=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);_n=!0);}catch(e){l=!0,o=e}finally{try{_n||null==n.return||n.return()}finally{if(l)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}e.r(t),e.d(t,{DeleteModal:function(){return p},Message:function(){return v}});var o=window.wp.element,i=window.lodash,l=window.React,a=window.wp.i18n,c=window.wp.components,s=window.wp.data,u=window.wp.apiFetch,d=e.n(u),m=window.nisje.components,f=window.nisje.history,w=e.n(f),p=function(e){var t=e.button,n=e.message,u=e.onRequestClose,f=e.onSuccess,p=void 0===f?i.noop:f,y=e.redirect,v=void 0!==y&&y,h=e.restPath,b=e.successMessage,g=e.title,E=r((0,l.useState)(!1),2),_=E[0],j=E[1],S=r((0,l.useState)(!1),2),M=S[0],x=S[1],C=(0,s.useDispatch)("nisje/notices").createInfoNotice;return(0,o.createElement)(c.Modal,{className:"views-delete-modal",closeButtonLabel:(0,a.__)("Cancel"),onRequestClose:u,title:g||(0,a.__)("Delete post?")},(0,o.createElement)("p",null,n||(0,a.__)("This will delete the post permanently")),M&&(0,o.createElement)(m.Notice,{status:"error"},M),(0,o.createElement)("div",{className:"views-delete-modal__actions"},(0,o.createElement)(m.Flex,{justify:"flex-end"},(0,o.createElement)(m.FlexItem,null,(0,o.createElement)(m.ExperimentalButton,{isSecondary:!0,onClick:u},(0,a.__)("Cancel"))),(0,o.createElement)(m.FlexItem,null,(0,o.createElement)(m.ExperimentalButton,{className:"delete-button",isDestructive:!0,isBusy:_,onClick:function(){j(!0),d()({path:h,method:"DELETE"}).then((function(){C(b||(0,a.__)("Successfully deleted the post")),p(),u(),v&&w().replace(v)})).catch((function(e){x(e.message),j(!1)}))}},t||(0,a.__)("Delete"))))))},y=window.nisje.icons,v=(0,window.nisje.viewport.withViewportMatch)({isHuge:"huge"})((function(e){var t=e.isHuge,n=e.icon,r=e.children;return(0,o.createElement)("div",{className:"views-message"},(0,o.createElement)("div",null,n&&(0,o.createElement)(y.Icon,{icon:n,size:t?80:60}),(0,o.createElement)("p",null,r)))}));(window.nisje=window.nisje||{}).views=t}();