"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/regenerator"),n=require("react"),a=require("../../types.js"),u=require("../../utils.js"),o=require("../utils.js"),s=require("./sharedHooks.js"),i=require("./useCloseFolderMenu.js");require("../../../../utils/index.js");var c=require("../../../../utils/notificationToasts.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=l(e),f=l(t),d=l(r);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){p.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}exports.useUpdateFolderName=function(){var e=s.useGet("get"),t=s.useGet("set"),r=i.useCloseFolderMenu();return n.useCallback(function(){var n=f.default(d.default.mark((function n(s,i){var l,p;return d.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!s||!i){n.next=14;break}return r(),l=s.items.filter(u.isTemplate).map((function(e){return e.id})),p=o.setBusy(t,s.id,a.Action.UpdateName),n.prev=4,n.next=7,o.updateTemplates(e,t,l,(function(e){return{metadata:j(j({},e.metadata),{},{folderPath:i})}}),a.Action.UpdateMetadata);case 7:c.showSuccessNotification('"'.concat(s.name,'" was renamed to "').concat(i,'"')),n.next=13;break;case 10:n.prev=10,n.t0=n.catch(4),console.error(n.t0);case 13:p();case 14:case"end":return n.stop()}}),n,null,[[4,10]])})));return function(e,t){return n.apply(this,arguments)}}(),[r,e,t])};
//# sourceMappingURL=useUpdateFolderName.js.map
