!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},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={};e.r(t),e.d(t,{DeleteModal:function(){return w},Message:function(){return p}});var n=window.wp.element,o=window.lodash,i=window.React,s=window.wp.i18n,l=window.wp.components,c=window.nisje.app.fetch,a=window.nisje.components,r=window.nisje.app.components,u=window.nisje.app.router,d=window.nisje.app.toast,w=function(e){let{button:t,message:w,onRequestClose:m,onSuccess:p=o.noop,redirect:j=!1,restPath:f,successMessage:h,title:E}=e;const _=(0,u.useHistory)(),[y,v]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1);return(0,n.createElement)(l.Modal,{className:"views-delete-modal",closeButtonLabel:(0,s.__)("Cancel","nisje"),onRequestClose:m,title:E||(0,s.__)("Delete post?","nisje")},(0,n.createElement)("p",null,w||(0,s.__)("This will delete the post permanently","nisje")),g&&(0,n.createElement)(a.Notice,{status:"error"},g),(0,n.createElement)("div",{className:"views-delete-modal__actions"},(0,n.createElement)(r.Flex,{justify:"flex-end"},(0,n.createElement)(r.FlexItem,null,(0,n.createElement)(r.Button,{isSecondary:!0,onClick:m},(0,s.__)("Cancel","nisje"))),(0,n.createElement)(r.FlexItem,null,(0,n.createElement)(r.Button,{isDestructive:!0,isBusy:y,onClick:function(){v(!0),(0,c.apiFetch)({path:f,method:"DELETE"}).then((()=>{(0,d.toast)(h||(0,s.__)("Successfully deleted the post","nisje")),p(),m(),j&&_.replace(j)})).catch((e=>{b(e.message),v(!1)}))}},t||(0,s.__)("Delete","nisje"))))))},m=window.nisje.icons,p=(0,window.nisje.viewport.withViewportMatch)({isHuge:"huge"})((function(e){let{isHuge:t,icon:o,children:i}=e;return(0,n.createElement)("div",{className:"views-message"},(0,n.createElement)("div",null,o&&(0,n.createElement)(m.Icon,{icon:o,size:t?80:60}),(0,n.createElement)("p",null,i)))}));(window.nisje=window.nisje||{}).views=t}();