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