Liferay.Loader.define("@liferay/object-web@1.0.145/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 ModalWithProvider({baseResourceURL:e}){const[t,n]=(0,i.useState)(null),{observer:l,onClose:c,open:u}=(0,r.useModal)({onClose:()=>n(null)});return(0,i.useEffect)((()=>(Liferay.on("deleteObjectDefinition",(async({itemData:t})=>{const r=(0,a.createResourceURL)(e,{objectDefinitionId:t.id,p_p_resource_id:"/object_definitions/get_object_definition_delete_info"}).href,{hasObjectRelationship:i,objectEntriesCount:l}=await o.API.fetchJSON(r);n(_objectSpread(_objectSpread({},t),{},{hasObjectRelationship:i,objectEntriesCount:l}))})),()=>Liferay.detach("deleteObjectDefinition"))),[e]),i.default.createElement(r.ClayModalProvider,null,t&&i.default.createElement(ModalDeleteObjectDefinition,{objectDefinition:t,observer:l,onClose:c,onDelete:async e=>{o.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>"))}),u?c():n(null),setTimeout((()=>window.location.reload()),1500)}))}}))};var r=n("@frontend-taglib-clay$clayui/modal"),o=n("@liferay/object-js-components-web"),a=n("frontend-js-web"),i=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=r?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),l=_interopRequireDefault(n("./DangerModal")),c=_interopRequireDefault(n("./WarningModal"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ModalDeleteObjectDefinition({objectDefinition:e,observer:t,onClose:n,onDelete:r}){const{hasObjectRelationship:o,id:u,name:s,objectEntriesCount:f,status:{code:d}}=e;return o?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(s))),i.default.createElement("div",null,(0,a.sub)(Liferay.Language.get("to-delete-x,-you-must-first-delete-its-relationships"),"".concat(s))),i.default.createElement("div",null,Liferay.Language.get("go-to-object-details-relationships"))):0!==d?(r(u),null):i.default.createElement(l.default,{errorMessage:(0,a.sub)(Liferay.Language.get("input-does-not-match-x"),"".concat(s)),observer:t,onClose:n,onDelete:()=>r(u),placeholder:Liferay.Language.get("confirm-object-definition-name"),title:Liferay.Language.get("delete-object-definition"),token:s},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(s,"</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(s,"</strong>"))}}))}}}));
//# sourceMappingURL=ModalDeleteObjectDefinition.js.map