var Notice=function(){function e(e,t,i){var s=this;this.stateValue=e;this.messageValue=t;this.task=i;this.listeners=[];switch(e){case"delayed":this.timer=window.setTimeout((function(){return s.execute()}),5e3);break;case"executing":this.execute();break;case"success":case"warning":case"failed":this.startCloseTimer();break}}Object.defineProperty(e.prototype,"state",{get:function(){return this.stateValue},set:function(e){if(this.stateValue!=e){this.stateValue=e;this.emit()}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"message",{get:function(){return this.messageValue},set:function(e){if(this.messageValue!=e){this.messageValue=e;this.emit()}},enumerable:false,configurable:true});e.prototype.listen=function(e){this.listeners.push(e)};e.prototype.unlisten=function(e){this.listeners.filter((function(t){return t!=e}))};e.prototype.emit=function(){var e=this;this.listeners.forEach((function(t){return t(e)}))};e.prototype.execute=function(){var e=this;this.clearTimer();if(this.task){this.state="executing";this.task(this).then((function(t){e.messageValue=t[1];e.state=t[0]?"success":"failed";e.startCloseTimer()}))}else this.state="failed"};e.prototype.startCloseTimer=function(){var e=this;this.timer=window.setTimeout((function(){return e.close()}),15e3)};e.prototype.close=function(){this.clearTimer();this.state="closed"};e.prototype.clearTimer=function(){if(this.timer){window.clearTimeout(this.timer);this.timer=undefined}};e.delay=function(t,i){return new e("delayed",t,i)};e.execute=function(t,i){return new e("executing",t,i)};e.succeded=function(t){return new e("success",t)};e.failed=function(t){return new e("failed",t)};e.warn=function(t){return new e("warning",t)};return e}();export{Notice as N};