export default class{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this)}hook(o,t){if(!o||"function"!=typeof t)return;const s=o;let e;for(;this._deprecatedHooks[o];)"string"==typeof(e=this._deprecatedHooks[o])&&(e={to:e}),o=e.to;e&&(e.message?this._logger.warn(e.message):this._logger.warn(`${s} hook has been deprecated`+(e.to?`, please use ${e.to}`:""))),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(t)}deprecateHook(o,t){this._deprecatedHooks[o]=t}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const t=function o(t,s={},e){for(const h in t){const r=t[h],i=e?`${e}:${h}`:h;"object"==typeof r&&null!==r?o(r,s,i):s[i]=r}return s}(o);for(const o in t)this.hook(o,t[o])}async callHook(o,...t){var s,e;if(this._hooks[o])try{await(s=this._hooks[o],e=(o=>o(...t)),s.reduce((o,t)=>o.then(o=>e(t,o)),Promise.resolve(null)))}catch(t){"error"!==o&&await this.callHook("error",t),this._logger.fatal?this._logger.fatal(t):this._logger.error(t)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}
//# sourceMappingURL=hable.esm.js.map
