(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.Bootoast={}))})(this,function(o){"use strict";const s=window.jQuery;if(!s)throw new Error("jQuery not found, Bootoast won't work.");var a="bootoast";const p=["primary","secondary","info","success","warning","danger"],h={warn:"warning",error:"danger"},l={warning:"exclamation-sign",success:"ok-sign",danger:"remove-sign",info:"info-sign"};function g(t){if(p[t])return t;if(!t)return"default";var e=h[t];return e||(console.warn('Bootoast: type "'+t+'" is not valid.'),e=t),e}function u(t,e,i=null){const n=g(e),r=i||l[n];return`<div class="${a} alert alert-${n}"><span class="glyphicon glyphicon-${r}"></span><span class="bootoast-alert-container"><span class="bootoast-alert-content">${t}</span></span></div>`}function c(t){if(typeof t=="string"&&(t={message:t}),typeof t=="object"){this.settings=s.extend({},this.defaults,t),this.content=this.settings.content||this.settings.text||this.settings.message,this.timeoutProgress=null,this.position=this.positionFor(this.settings.position).split("-"),this.settings.icon=this.settings.icon||l[this.settings.type];var e=a+"-container";this.containerSelector="."+e+"."+this.position.join("."),s("body > "+this.containerSelector).length===0&&s("<div>",{class:e+" "+this.position.join(" ")}).appendTo("body"),this.$el=s(u(this.content,this.settings.type,this.settings.icon)),this.init()}}s.extend(c.prototype,{defaults:{message:"Bootoast!",type:"info",position:"bottom-center",icon:null,timeout:3,timeoutProgress:!1,animationDuration:300,dismissible:!0,instant:!0},positions:["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],positionSinonym:{bottom:"bottom-center",leftBottom:"bottom-left",rightBottom:"bottom-right",top:"top-center",rightTop:"top-right",leftTop:"top-left"},init:function(){this.$el[(this.position[0]==="bottom"?"append":"prepend")+"To"](this.containerSelector);var t=this;if(this.settings.dismissible===!0&&this.$el.addClass("alert-dismissible").prepend('<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>').on("click","button.close",function(i){i.preventDefault(),t.hide()}),this.settings.instant===!0&&(this.$el.animate({opacity:1},this.settings.animationDuration),this.settings.timeout)){var e=parseInt(this.settings.timeout*1e3);this.hide(e)}},hide:function(t){var e=this;this.settings.timeoutProgress&&this.setTimeoutProgress(this.settings.timeoutProgress);var i=setTimeout(function(){e.$el.animate({opacity:0},e.settings.animationDuration,function(){e.$el.remove()})},t||0);return this.$el.hover(clearTimeout.bind(window,i),function(){i=e.hide(t)}),i},setTimeoutProgress:function(t){this.timeoutProgress!==null&&this.timeoutProgress.remove();var e={top:"prepend",bottom:"append"},i=s("<div>",{class:"progress",html:s("<div>",{class:"progress-bar progress-bar-striped active",role:"progressbar","aria-valuemin":0,"aria-valuenow":0,"aria-valuemax":100})}),n=e[t]||"append",r=typeof e[t]=="string"?t:"background";return this.timeoutProgress=i.addClass("progress-"+r)[n+"To"](this.$el),this.timeoutProgress},positionFor:function(t){for(var e=0;e<this.positions.length;e++)if(this.positions[e]===t)return t;var i=s.camelCase(t);return this.positionSinonym[i]||"bottom-center"},moveProgressbar:function(t,e){var i=100,n=setInterval(()=>{i<=0?clearInterval(n):(i--,t.style.width=i+"%")},100/e);return n}});const m=function(t){return new c(t)};o.createAlertTemplate=u,o.toast=m,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
