Liferay.Loader.define("@liferay/object-web@1.0.108/js/components/ModalDeleteObjectDefinition",["module","exports","require","@frontend-taglib-clay$clayui/modal","@liferay/object-js-components-web","frontend-js-web","liferay!frontend-js-react-web$react","./DangerModal","./WarningModal"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({baseResourceURL:e}){const[t,n]=(0,i.useState)(null),{observer:l,onClose:c,open:s}=(0,o.useModal)({onClose:()=>n(null)});return(0,i.useEffect)((()=>(Liferay.on("deleteObjectDefinition",(async({itemData:t})=>{const o=(0,a.createResourceURL)(e,{objectDefinitionId:t.id,p_p_resource_id:"/object_definitions/get_object_definition_delete_info"}).href,{hasObjectRelationship:i,objectEntriesCount:l}=await r.API.fetchJSON(o);n(d(d({},t),{},{hasObjectRelationship:i,objectEntriesCount:l}))})),()=>Liferay.detach("deleteObjectDefinition"))),[e]),i.default.createElement(o.ClayModalProvider,null,t&&i.default.createElement(g,{objectDefinition:t,observer:l,onClose:c,onDelete:async e=>{r.API.deleteObjectDefinitions(Number(e)).then((()=>{Liferay.Util.openToast({message:(0,a.sub)(Liferay.Language.get("x-was-deleted-successfully"),"<strong>".concat(null==t?void 0:t.name,"</strong>"))}),s?c():n(null),setTimeout((()=>window.location.reload()),1500)}))}}))};var o=n("@frontend-taglib-clay$clayui/modal"),r=n("@liferay/object-js-components-web"),a=n("frontend-js-web"),i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var a=o?Object.getOwnPropertyDescriptor(e,r):null;a&&(a.get||a.set)?Object.defineProperty(n,r,a):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),l=s(n("./DangerModal")),c=s(n("./WarningModal"));function s(e){return e&&e.__esModule?e:{default:e}}function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){b(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g({objectDefinition:e,observer:t,onClose:n,onDelete:o}){const{hasObjectRelationship:r,id:s,name:u,objectEntriesCount:f,status:{code:d}}=e;return r?i.default.createElement(c.default,{observer:t,onClose:n,title:Liferay.Language.get("deletion-not-allowed")},i.default.createElement("div",null,(0,a.sub)(Liferay.Language.get("x-has-active-relationships-and-cannot-be-deleted"),"".concat(u))),i.default.createElement("div",null,(0,a.sub)(Liferay.Language.get("to-delete-x,-you-must-first-delete-its-relationships"),"".concat(u))),i.default.createElement("div",null,Liferay.Language.get("go-to-object-details-relationships"))):0!==d?(o(s),null):i.default.createElement(l.default,{errorMessage:(0,a.sub)(Liferay.Language.get("input-does-not-match-x"),"".concat(u)),observer:t,onClose:n,onDelete:()=>o(s),placeholder:Liferay.Language.get("confirm-object-definition-name"),title:Liferay.Language.get("delete-object-definition"),token:u},i.default.createElement("p",null,Liferay.Language.get("deleting-an-object-definition-also-removes-its-data-records")),i.default.createElement("p",{dangerouslySetInnerHTML:{__html:(0,a.sub)(Liferay.Language.get("x-has-x-object-entries"),"<strong>".concat(u,"</strong>"),"".concat(f))}}),i.default.createElement("p",null,Liferay.Language.get("before-deleting-this-object-definition-you-may-want-to-back-up-its-entries-to-prevent-data-loss")),i.default.createElement("p",{dangerouslySetInnerHTML:{__html:(0,a.sub)(Liferay.Language.get("please-enter-x-to-confirm"),"<strong>".concat(u,"</strong>"))}}))}}}));
//# sourceMappingURL=ModalDeleteObjectDefinition.js.map