import PNotify from"./PNotify.js";let _open=PNotify.prototype.open,_close=PNotify.prototype.close;const callbacks=(t,e,s)=>{let i=t?t.get().modules:e.modules,o=i&&i.Callbacks?i.Callbacks:{};return o[s]?o[s]:()=>!0};function setup(t){t.key="Callbacks",t.getCallbacks=callbacks;let e=PNotify.alert,s=PNotify.notice,i=PNotify.info,o=PNotify.success,n=PNotify.error,a=(t,e)=>{callbacks(null,e,"beforeInit")(e);let s=t(e);return callbacks(s,null,"afterInit")(s),s};PNotify.alert=(t=>a(e,t)),PNotify.notice=(t=>a(s,t)),PNotify.info=(t=>a(i,t)),PNotify.success=(t=>a(o,t)),PNotify.error=(t=>a(n,t)),PNotify.modules.Callbacks=t}function create_main_fragment(t,e){return{c:noop,m:noop,p:noop,d:noop}}function PNotifyCallbacks(t){init(this,t),this._state=assign({},t.data),this._intro=!0,this._fragment=create_main_fragment(this,this._state),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor))}function noop(){}function init(t,e){t._handlers=blankObject(),t._slots=blankObject(),t._bind=e._bind,t._staged={},t.options=e,t.root=e.root||t,t.store=e.store||t.root.store,e.root||(t._beforecreate=[],t._oncreate=[],t._aftercreate=[])}function assign(t,e){for(var s in e)t[s]=e[s];return t}function destroy(t){this.destroy=noop,this.fire("destroy"),this.set=noop,this._fragment.d(!1!==t),this._fragment=null,this._state={}}function get(){return this._state}function fire(t,e){var s=t in this._handlers&&this._handlers[t].slice();if(s)for(var i=0;i<s.length;i+=1){var o=s[i];if(!o.__calling)try{o.__calling=!0,o.call(this,e)}finally{o.__calling=!1}}}function on(t,e){var s=this._handlers[t]||(this._handlers[t]=[]);return s.push(e),{cancel:function(){var t=s.indexOf(e);~t&&s.splice(t,1)}}}function set(t){this._set(assign({},t)),this.root._lock||flush(this.root)}function _set(t){var e=this._state,s={},i=!1;for(var o in t=assign(this._staged,t),this._staged={},t)this._differs(t[o],e[o])&&(s[o]=i=!0);i&&(this._state=assign(assign({},e),t),this._recompute(s,this._state),this._bind&&this._bind(s,this._state),this._fragment&&(this.fire("state",{changed:s,current:this._state,previous:e}),this._fragment.p(s,this._state),this.fire("update",{changed:s,current:this._state,previous:e})))}function _stage(t){assign(this._staged,t)}function _mount(t,e){this._fragment[this._fragment.i?"i":"m"](t,e||null)}function _differs(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function blankObject(){return Object.create(null)}function flush(t){t._lock=!0,callAll(t._beforecreate),callAll(t._oncreate),callAll(t._aftercreate),t._lock=!1}function callAll(t){for(;t&&t.length;)t.shift()()}PNotify.prototype.open=function(...t){!1!==callbacks(this,null,"beforeOpen")(this)&&(_open.apply(this,t),callbacks(this,null,"afterOpen")(this))},PNotify.prototype.close=function(t,...e){!1!==callbacks(this,null,"beforeClose")(this,t)&&(_close.apply(this,[t,...e]),callbacks(this,null,"afterClose")(this,t))},assign(PNotifyCallbacks.prototype,{destroy:destroy,get:get,fire:fire,on:on,set:set,_set:_set,_stage:_stage,_mount:_mount,_differs:_differs}),PNotifyCallbacks.prototype._recompute=noop,setup(PNotifyCallbacks);export default PNotifyCallbacks;
//# sourceMappingURL=PNotifyCallbacks.js.map