import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import{useCallback as t}from"react";import{addTemplate as o,setBusy as n}from"../utils.js";import{Action as s}from"../../types.js";import{parseTemplateImportData as a,loadTextFile as c}from"../../utils.js";import{useGet as i}from"./sharedHooks.js";import{useSelectTemplate as m}from"./useSelectTemplate.js";import"../../../../utils/index.js";import{showErrorNotification as p,showSuccessNotification as u}from"../../../../utils/notificationToasts.js";var f=function(){var f=i("get"),l=i("set"),v=m();return t(e(r.mark((function e(){var t,i,m,x;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n(l,0,s.Create),e.prev=1,e.next=4,c({extensions:[".json"]});case 4:return i=e.sent,e.prev=5,m=a(i),e.next=9,o(f,l,m);case 9:return x=e.sent,e.next=12,v(x.id);case 12:u('"'.concat(x.name,'" was created')),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(5),p("An error occurred: ".concat((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"Unknown error")),console.error(e.t0);case 19:e.next=23;break;case 21:e.prev=21,e.t1=e.catch(1);case 23:t();case 24:case"end":return e.stop()}}),e,null,[[1,21],[5,15]])}))),[f,l,v])};export{f as useImportTemplate};
//# sourceMappingURL=useImportTemplate.js.map
