var __awaiter=this&&this.__awaiter||function(t,e,i,a){function n(t){return t instanceof i?t:new i((function(e){e(t)}))}return new(i||(i=Promise))((function(i,o){function r(t){try{l(a.next(t))}catch(t){o(t)}}function s(t){try{l(a["throw"](t))}catch(t){o(t)}}function l(t){t.done?i(t.value):n(t.value).then(r,s)}l((a=a.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a,n,o,r;return r={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function s(t){return function(e){return l([t,e])}}function l(r){if(a)throw new TypeError("Generator is already executing.");while(i)try{if(a=1,n&&(o=r[0]&2?n["return"]:r[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;if(n=0,o)r=[r[0]&2,o.value];switch(r[0]){case 0:case 1:o=r;break;case 4:i.label++;return{value:r[1],done:false};case 5:i.label++;n=r[1];r=[0];continue;case 7:r=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!o||r[1]>o[0]&&r[1]2?this.queueLength-1:1);var n=h("div",{class:"".concat(this.queueLength>1?"active ":"","alert-queue-count")},h("calcite-chip",{scale:this.scale,value:a},a));var o=this,r=o.active,s=o.autoDismiss,l=o.label,c=o.placement,u=o.queued,d=o.requestedIcon;var m=s?"alert":"alertdialog";var f=!r;return h(Host,{"aria-hidden":toAriaBoolean(f),"aria-label":l,"calcite-hydrated-hidden":f,role:m},h("div",{class:(t={container:true,queued:u},t[c]=true,t),onTransitionEnd:this.transitionEnd},d?h("div",{class:"alert-icon"},h("calcite-icon",{icon:d,scale:this.scale==="l"?"m":"s"})):null,h("div",{class:"alert-content"},h("slot",{name:SLOTS.title}),h("slot",{name:SLOTS.message}),h("slot",{name:SLOTS.link})),n,!s?i:null,r&&!u&&s?h("div",{class:"alert-dismiss-progress"}):null))};t.prototype.alertSync=function(t){if(this.queue!==t.detail.queue){this.queue=t.detail.queue}this.queueLength=this.queue.length;this.determineActiveAlert()};t.prototype.alertRegister=function(){if(this.active&&!this.queue.includes(this.el)){this.queued=true;this.queue.push(this.el)}this.calciteAlertSync.emit({queue:this.queue});this.determineActiveAlert()};t.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){t=getSlotted(this.el,{selector:"calcite-link"});if(!this.closeButton&&!t){return[2]}else if(t){t.setFocus()}else if(this.closeButton){this.closeButton.focus()}return[2]}))}))};t.prototype.determineActiveAlert=function(){var t=this;var e;if(((e=this.queue)===null||e===void 0?void 0:e[0])===this.el){this.openAlert();if(this.autoDismiss&&!this.autoDismissTimeoutId){this.trackTimer=Date.now();this.autoDismissTimeoutId=window.setTimeout((function(){return t.closeAlert()}),DURATIONS[this.autoDismissDuration])}}else{return}};t.prototype.openAlert=function(){var t=this;window.clearTimeout(this.queueTimeout);this.queueTimeout=window.setTimeout((function(){return t.queued=false}),300)};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{active:["watchActive"],icon:["updateRequestedIcon"],color:["updateRequestedIcon"],autoDismissDuration:["updateDuration"]}},enumerable:false,configurable:true});return t}();Alert.style=alertCss;export{Alert as calcite_alert};