import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import{useCallback as t}from"react";import{ConfirmationModalType as o}from"../../types.js";import{isTemplate as n}from"../../utils.js";import{selectTemplateOnDeletion as i}from"../utils.js";import{useGet as s,useConfirmation as a}from"./sharedHooks.js";import{useCloseFolderMenu as m}from"./useCloseFolderMenu.js";import"../../../../utils/index.js";import{deleteAppSettingsTemplate as l}from"../../../../clients/jsonApi/index.js";import{showSuccessNotification as u}from"../../../../utils/notificationToasts.js";var c=function(c){var f=s("get"),p=s("set"),d=m(),j=t(e(r.mark((function e(){var t,o,s;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!c){e.next=11;break}return d(),t=f(),o=t.currentTemplateId,s=c.items.filter(n).map((function(e){return e.id})),p((function(e){return{loadedTemplates:e.loadedTemplates.filter((function(e){var r=e.id;return!s.includes(r)}))}})),e.next=7,Promise.all(s.map((function(e){return l(f().appKey,e)})));case 7:if(void 0===o||!s.includes(o)){e.next=10;break}return e.next=10,i(f,p);case 10:u('Folder "'.concat(null==c?void 0:c.name,'" has been successfully deleted.'));case 11:case"end":return e.stop()}}),e)}))),[d,c,f,p]);return a(o.DeleteFolder,j,{confirmationTargetFolder:c})};export{c as useDeleteFolder};
//# sourceMappingURL=useDeleteFolder.js.map
