import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import{useCallback as t}from"react";import{findTemplate as n,ensureTemplateSettings as a}from"../utils.js";import{useGet as o}from"./sharedHooks.js";var i=function(){var i=o("get"),u=o("set");return t(function(){var t=e(r.mark((function e(t){var o,s,p,m,c,l,f=arguments;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=f.length>1&&void 0!==f[1]&&f[1],s=i(),p=s.onChange,m=s.currentTemplateId,void 0!==t){e.next=6;break}return u({currentTemplateId:t,templateSettings:void 0}),p&&p(void 0,"selectTemplate"),e.abrupt("return",void 0);case 6:if(c=n(i,t),!t||!c||t===m&&!o){e.next=14;break}return e.next=10,a(i,u,c);case 10:return l=e.sent,u({currentTemplateId:t,templateSettings:l.settings}),p&&p(l,"selectTemplate"),e.abrupt("return",l);case 14:return e.abrupt("return",void 0);case 15:case"end":return e.stop()}}),e)})));return function(e){return t.apply(this,arguments)}}(),[i,u])};export{i as useSelectTemplate};
//# sourceMappingURL=useSelectTemplate.js.map
