@freshworks/crayons
Version:
Crayons Web Components library
1 lines • 24.4 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,e,n,o){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,r){function a(t){try{l(o.next(t))}catch(e){r(e)}}function s(t){try{l(o["throw"](t))}catch(e){r(e)}}function l(t){t.done?n(t.value):i(t.value).then(a,s)}l((o=o.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return l([t,e])}}function l(a){if(o)throw new TypeError("Generator is already executing.");while(n)try{if(o=1,i&&(r=a[0]&2?i["return"]:a[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;if(i=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(s){a=[6,s];i=0}finally{o=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,e as Host,i as getElement}from"./index-25bc21e4.js";import{t as throttle,h as hasSlot,a as handleKeyDown}from"./index-04e9b0fa.js";import{w as waitUntilVisible,a as unwatchIcon,g as getSVGElement,f as fetchIcon,b as getIconLibrary,c as watchIcon}from"./crayons-7f310575.js";import"./toast-util-eb89e79f.js";import"./progress-loader-util-1fff4614.js";import"./_commonjsHelpers-9943807e.js";import"./format-date-util-cbbbafe3.js";var buttonCss=':host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}@media screen and (prefers-reduced-motion: reduce){.fw-btn,.fw-btn--label,.fw-btn--loader{-webkit-transition:none;transition:none}}:host{display:inline-block;width:auto;cursor:pointer}.fw-btn{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-line-pack:center;align-content:center;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:center;justify-content:center;width:100%;border-style:solid;border-width:1px;font-weight:600;font-family:inherit;text-decoration:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;vertical-align:middle;padding:0;cursor:inherit;letter-spacing:0;outline:0;border-radius:4px;--fw-icon-color:currentColor}.fw-btn .fw-btn--label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.fw-btn:active:not(.fw-btn--loading){-webkit-box-shadow:inset 0 0 4px 0 rgba(0, 0, 0, 0.25);box-shadow:inset 0 0 4px 0 rgba(0, 0, 0, 0.25)}.fw-btn:focus{border:1px solid #2c5cc5;-webkit-box-shadow:0 0 0 1px #2c5cc5;box-shadow:0 0 0 1px #2c5cc5}.fw-btn.disabled,.fw-btn[disabled]{cursor:not-allowed}.fw-btn--primary{background-color:#264966;color:#fff;border-color:#12344d;background-image:-webkit-gradient(linear, left top, left bottom, from(#264966), to(#12344d));background-image:linear-gradient(to bottom, #264966, #12344d)}.fw-btn--primary:active{border-color:#264966}.fw-btn--primary:focus:not([disabled]),.fw-btn--primary:hover:not([disabled]){background-color:#12344d;background-image:none}.fw-btn--primary.disabled,.fw-btn--primary[disabled]{background-image:-webkit-gradient(linear, left top, left bottom, from(#92a2b1), to(#7b8e9f));background-image:linear-gradient(to bottom, #92a2b1, #7b8e9f);border-color:#7b8e9f;color:rgba(255, 255, 255, 0.5)}.fw-btn--secondary{background-color:#f5f7f9;color:#12344d;border-color:#cfd7df;background-image:-webkit-gradient(linear, left top, left bottom, from(#fff), to(#f5f7f9));background-image:linear-gradient(to bottom, #fff, #f5f7f9)}.fw-btn--secondary:active{border-color:#ebeff3}.fw-btn--secondary:focus:not([disabled]),.fw-btn--secondary:hover:not([disabled]){background-color:#f5f7f9;background-image:none}.fw-btn--secondary.disabled,.fw-btn--secondary[disabled]{background:#ebeff3;border-color:#cfd7df;color:#92a2b1}.fw-btn--danger{color:#fff;background-color:#d72d30;border-color:#c82124;background-image:-webkit-gradient(linear, left top, left bottom, from(#d72d30), to(#c82124));background-image:linear-gradient(to bottom, #d72d30, #c82124)}.fw-btn--danger:focus:not([disabled]),.fw-btn--danger:hover:not([disabled]){background-color:#c82124;background-image:none}.fw-btn--danger.disabled,.fw-btn--danger[disabled]{background-image:-webkit-gradient(linear, left top, left bottom, from(#f89fa1), to(#f2797b));background-image:linear-gradient(to bottom, #f89fa1, #f2797b);border-color:#f2797b;color:rgba(255, 255, 255, 0.5)}.fw-btn--link{background-color:transparent;background-image:none;border:1px solid transparent;color:#2c5cc5}.fw-btn--text{background-color:transparent;background-image:none;border:1px solid transparent;color:#264966}.fw-btn--text:focus:not([disabled]),.fw-btn--text:hover:not([disabled]){background-color:#ebeff3}.fw-btn--text:focus:not([disabled]),.fw-btn--text:hover:not([disabled]),.fw-btn--link:focus:not([disabled]),.fw-btn--link:hover:not([disabled]){border-color:#2c5cc5;-webkit-box-shadow:0 0 0 1px #2c5cc5;box-shadow:0 0 0 1px #2c5cc5}.fw-btn--text.disabled,.fw-btn--text[disabled],.fw-btn--link.disabled,.fw-btn--link[disabled]{opacity:0.5}.fw-btn--mini{height:16px;line-height:calc(16px - 1px * 2)}.fw-btn--mini .fw-btn--label{font-size:10px}.fw-btn--mini fw-spinner{-webkit-transform:scale(0.5);transform:scale(0.5)}.fw-btn--small{height:24px;line-height:calc(24px - 1px * 2)}.fw-btn--small .fw-btn--label{font-size:12px}.fw-btn--small fw-spinner{-webkit-transform:scale(0.75);transform:scale(0.75)}.fw-btn--normal{min-width:var(--fw-button-min-width, 80px);height:32px;line-height:calc(32px - 1px * 2)}.fw-btn--icon{min-width:32px;width:32px;height:32px;padding:0;line-height:calc(32px - 1px * 2)}.fw-btn--icon-small{min-width:24px;width:24px;height:22px;padding:0;line-height:calc(22px - 1px * 2)}.fw-btn--before,.fw-btn--after,.fw-btn--caret{-ms-flex:0 0 auto;flex:0 0 auto;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.fw-btn--normal ::slotted(fw-icon){--fw-icon-size:12px}.fw-btn--small ::slotted(fw-icon){--fw-icon-size:10px}.fw-btn--mini ::slotted(fw-icon){--fw-icon-size:8px}.fw-btn--has-label.fw-btn--normal .fw-btn--label{padding:0 var(--fw-button-label-vertical-padding, 12px)}.fw-btn--has-before.fw-btn--normal{padding-left:8px}.fw-btn--has-before.fw-btn--normal .fw-btn--label{padding-left:8px}.fw-btn--has-after.fw-btn--normal,.fw-btn--caret.fw-btn--normal{padding-right:8px}.fw-btn--has-after.fw-btn--normal .fw-btn--label,.fw-btn--caret.fw-btn--normal .fw-btn--label{padding-right:8px}.fw-btn--has-label.fw-btn--small .fw-btn--label{padding:0 var(--fw-button-label-vertical-padding, 8px)}.fw-btn--has-before.fw-btn--small{padding-left:6px}.fw-btn--has-before.fw-btn--small .fw-btn--label{padding-left:6px}.fw-btn--has-after.fw-btn--small,.fw-btn--caret.fw-btn--small{padding-right:6px}.fw-btn--has-after.fw-btn--small .fw-btn--label,.fw-btn--caret.fw-btn--small .fw-btn--label{padding-right:6px}.fw-btn--has-label.fw-btn--mini .fw-btn--label{padding:0 var(--fw-button-label-vertical-padding, 6px)}.fw-btn--has-before.fw-btn--mini{padding-left:4px}.fw-btn--has-before.fw-btn--mini .fw-btn--label{padding-left:4px}.fw-btn--has-after.fw-btn--mini,.fw-btn--caret.fw-btn--mini{padding-right:4px}.fw-btn--has-after.fw-btn--mini .fw-btn--label,.fw-btn--caret.fw-btn--mini .fw-btn--label{padding-right:4px}.fw-btn--caret fw-icon{--fw-icon-size:9px}.fw-btn--caret.fw-btn--mini fw-icon{--fw-icon-size:6px}.fw-btn--loading{position:relative;cursor:wait}.fw-btn--loading .fw-btn--label,.fw-btn--loading .fw-btn--before,.fw-btn--loading .fw-btn--after,.fw-btn--loading .fw-btn--caret{opacity:0}.fw-btn--loading .fw-btn--loader{--fw-spinner-color:currentColor;opacity:1;line-height:0}.fw-btn--label,.fw-btn--loader{-webkit-transition:opacity 0.3s ease-out;transition:opacity 0.3s ease-out}.fw-btn--loader{opacity:0;position:absolute;font-size:1em;height:1em;width:1em;top:calc(50% - 0.5em);left:calc(50% - 0.5em);margin-top:-1px;margin-left:-1px}:host(.fw-button-group__button--first:not(.fw-button-group__button--last)) .fw-btn{border-top-right-radius:0;border-bottom-right-radius:0}:host(.fw-button-group__button--inner) .fw-btn{border-radius:0;border-left:0}:host(.fw-button-group__button--last:not(.fw-button-group__button--first)) .fw-btn{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}';var Button=function(){function t(t){registerInstance(this,t);this.fwClick=createEvent(this,"fwClick",7);this.fwFocus=createEvent(this,"fwFocus",7);this.fwBlur=createEvent(this,"fwBlur",7);this.type="button";this.color="primary";this.size="normal";this.disabled=false;this.loading=false;this.showCaretIcon=false;this.modalTriggerId="";this.fileUploaderId="";this.throttleDelay=200;this.hasLabel=false;this.hasBeforeLabel=false;this.hasAfterLabel=false}t.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.button.focus();return[2]}))}))};t.prototype.onFocus=function(){this.fwFocus.emit()};t.prototype.onBlur=function(){this.fwBlur.emit()};t.prototype.connectedCallback=function(){this.handleClickWithThrottle=throttle(this.handleClick,this,this.throttleDelay)};t.prototype.handlePreventDefault=function(t){t.preventDefault();t.stopPropagation()};t.prototype.handleClick=function(t){if(this.modalTriggerId!==""){this.modalTrigger()}if(this.fileUploaderId!==""){this.fileSubmit()}else if(this.type==="submit"){this.fakeSubmit(t)}this.fwClick.emit()};t.prototype.fileSubmit=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){t=document.querySelector("fw-file-uploader#"+this.fileUploaderId);t===null||t===void 0?void 0:t.uploadFiles();return[2]}))}))};t.prototype.modalTrigger=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){t=document.querySelector("fw-modal#"+this.modalTriggerId);t===null||t===void 0?void 0:t.open();return[2]}))}))};t.prototype.fakeSubmit=function(t){return __awaiter(this,void 0,void 0,(function(){var e,n;return __generator(this,(function(o){e=this.host.closest("form");if(e){t.preventDefault();n=document.createElement("button");n.type="submit";n.style.display="none";e.appendChild(n);n.click();n.remove()}return[2]}))}))};t.prototype.componentWillLoad=function(){this.handleSlotChange()};t.prototype.handleSlotChange=function(){this.hasLabel=hasSlot(this.host);this.hasBeforeLabel=hasSlot(this.host,"before-label");this.hasAfterLabel=hasSlot(this.host,"after-label")};t.prototype.render=function(){var t=this;return h(Host,null,h("button",{type:this.type,class:"\n fw-btn fw-btn--"+this.color.toLowerCase()+"\n fw-btn--"+this.size.toLowerCase()+"\n "+(this.loading?"fw-btn--loading":"")+"\n "+(this.hasLabel?"fw-btn--has-label":"")+"\n "+(this.hasBeforeLabel?"fw-btn--has-before":"")+"\n "+(this.hasAfterLabel?"fw-btn--has-after":"")+"\n "+(this.showCaretIcon?"fw-btn--caret":"")+"\n ",onClick:this.disabled||this.loading?this.handlePreventDefault:this.handleClickWithThrottle,onFocus:function(){return t.onFocus()},onBlur:function(){return t.onBlur()},ref:function(e){return t.button=e},"aria-disabled":this.disabled,disabled:this.disabled},h("span",{class:"fw-btn--before"},h("slot",{onSlotchange:function(){return t.handleSlotChange()},name:"before-label"})),h("span",{class:"fw-btn--label"},h("slot",{onSlotchange:function(){return t.handleSlotChange()}})),h("span",{class:"fw-btn--after"},h("slot",{onSlotchange:function(){return t.handleSlotChange()},name:"after-label"})),this.loading?h("fw-spinner",{class:"fw-btn--loader"}):"",this.showCaretIcon?h("fw-icon",{name:"chevron-down",library:"system"}):""))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();Button.style=buttonCss;var iconCss=':host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}:host{display:inline-block}.icon{display:block;color:var(--fw-icon-color, #12344d);height:var(--fw-icon-size, 12px);width:var(--fw-icon-size, 12px)}.icon svg{display:block;width:100%;height:100%}';var Icon=function(){function t(t){registerInstance(this,t);this.dataSvg="";this.xRootMargin="50px";this.color="";this.library="crayons";this.lazy=false;this.setElVisible=false;this.visible=false}t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(!this.lazy)this.visible=true;else this.visible=this.setElVisible;if(!this.visible){return[2]}this.applyIconPropstoState();return[2]}))}))};t.prototype.connectedCallback=function(){var t=this;watchIcon(this);this.lazy&&waitUntilVisible(this.intersectionObserver,this.xRootMargin,this.el,(function(){t.setElVisible=true;t.applyIconPropstoState()}))};t.prototype.nameChangeHandler=function(){this.applyIconPropstoState()};t.prototype.disconnectedCallback=function(){unwatchIcon(this);if(this.intersectionObserver){this.intersectionObserver.disconnect();this.intersectionObserver=undefined}};t.prototype.applyIconPropstoState=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n,o,i,r,a;return __generator(this,(function(s){switch(s.label){case 0:t=this,e=t.name,n=t.dataSvg,o=t.library;s.label=1;case 1:s.trys.push([1,6,,7]);if(!(!e&&n))return[3,2];this.svg=n;return[3,5];case 2:if(!e)return[3,4];i=this.getIconUrl(e,o);r=this;return[4,this.drawIcon(i)];case 3:r.svg=s.sent();return[3,5];case 4:console.error("Please provide valid props either 'name' or 'data-svg'.Check the usage docs.");throw"-invalid props-";case 5:return[3,7];case 6:a=s.sent();console.error(a.message);this.loadFallbackImage();return[3,7];case 7:return[2]}}))}))};t.prototype.drawIcon=function(t){return __awaiter(this,void 0,void 0,(function(){var e,n,o,i,r;return __generator(this,(function(a){switch(a.label){case 0:e=this,n=e.name,o=e.library;a.label=1;case 1:a.trys.push([1,3,,4]);return[4,getSVGElement(t)];case 2:i=a.sent();this.applySVGMutation(o,n,i);return[2,i.outerHTML];case 3:r=a.sent();throw new Error("Exception occured while drawing Icon- "+n+" : "+r.message);case 4:return[2]}}))}))};t.prototype.redrawIcon=function(){this.applyIconPropstoState()};t.prototype.loadFallbackImage=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){switch(e.label){case 0:t=this;return[4,fetchIcon(this.getIconUrlfromlib("image","system"))];case 1:t.svg=e.sent();return[2]}}))}))};t.prototype.getIconUrl=function(t,e){var n="";if(!this.src){n=this.getIconUrlfromlib(t,e);if(n===undefined){console.error("Error while resolving url for "+this.name+"|"+this.library+". Please check the lib registration/resolver function.");return}}else n=this.src+"/"+this.name+".svg";return n};t.prototype.getIconUrlfromlib=function(t,e){var n=getIconLibrary(e);if(t&&n){return n.resolver(t)}else{console.error("Icon "+t+"/"+e+" not registered.Check the Implementation.");return}};t.prototype.applySVGMutation=function(t,e,n){var o=getIconLibrary(t);if(o&&o.mutator){o.mutator(n,e)}};t.prototype.render=function(){var t={};var e={"aria-hidden":true};var n=typeof this.label==="string"&&this.label.length>0;if(n){e["role"]="img";e["aria-label"]=this.label}if(this.size!==undefined)t["--fw-icon-size"]=this.size+"px";if(this.color!==undefined)t["--fw-icon-color"]=this.color;return h("div",Object.assign({class:"icon"},e,{style:Object.assign({height:" "+this.height+"px",width:this.width+"px"},t),innerHTML:this.svg}))};Object.defineProperty(t,"assetsDirs",{get:function(){return["icon-assets"]},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{name:["nameChangeHandler"]}},enumerable:false,configurable:true});return t}();Icon.style=iconCss;var spinnerCss=':host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}@media screen and (prefers-reduced-motion: reduce){.spinner{-webkit-animation:none;animation:none}}@media screen and (prefers-reduced-motion: reduce) and (prefers-reduced-motion: reduce){.spinner .path{-webkit-animation:none;animation:none}}.spinner{-webkit-animation:rotate 2s linear infinite;animation:rotate 2s linear infinite;z-index:2}@media screen and (prefers-reduced-motion: reduce){.spinner .path{stroke:var(--fw-spinner-color, #2c5cc5);stroke-linecap:round;-webkit-animation:none;animation:none}}.spinner .path{stroke:var(--fw-spinner-color, #2c5cc5);stroke-linecap:round;-webkit-animation:dash 1s ease-in-out infinite;animation:dash 1s ease-in-out infinite}@-webkit-keyframes rotate{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes dash{0%{stroke-dasharray:1, 150;stroke-dashoffset:0}50%{stroke-dasharray:90, 150;stroke-dashoffset:-35}100%{stroke-dasharray:90, 150;stroke-dashoffset:-124}}@keyframes dash{0%{stroke-dasharray:1, 150;stroke-dashoffset:0}50%{stroke-dasharray:90, 150;stroke-dashoffset:-35}100%{stroke-dasharray:90, 150;stroke-dashoffset:-124}}';var Spinner=function(){function t(t){registerInstance(this,t);this.size="default";this.color="";this.sizeMap={small:12,default:16,medium:24,large:32}}t.prototype.getSize=function(){return this.sizeMap[this.size]||16};t.prototype.render=function(){var t=this.getSize();return h(Host,null,h("svg",{class:"spinner "+this.size,style:{width:t+"px",height:t+"px","--fw-spinner-color":""+this.color},viewBox:"0 0 50 50"},h("circle",{class:"path",cx:"25",cy:"25",r:"18",fill:"none","stroke-width":"8"})))};return t}();Spinner.style=spinnerCss;var toastMessageCss=':host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}@media screen and (prefers-reduced-motion: reduce){.toast.is-open{-webkit-animation:none;animation:none}}.toast.is-open{display:block;-webkit-animation-duration:0.5s;animation-duration:0.5s;-webkit-animation-name:fadeIn;animation-name:fadeIn;z-index:999}.toast{display:none;position:relative;top:10px;width:400px;padding:0px 0px 16px 0px;border:1px solid #ebeff3;border-radius:4px;background-color:#fff;margin-bottom:16px;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0px 2px 4px rgba(18, 52, 77, 0.06), 0px 2px 16px rgba(18, 52, 77, 0.16);box-shadow:0px 2px 4px rgba(18, 52, 77, 0.06), 0px 2px 16px rgba(18, 52, 77, 0.16);overflow-wrap:anywhere;word-break:break-word;white-space:normal}.toast.success{border-top:5px solid #00a886}.toast.error{border-top:5px solid #d72d30}.toast.warning{border-top:5px solid #f8ab59}.toast.inprogress{border-top:5px solid #2c5cc5}.toast-container{margin-top:16px;display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;place-content:center}.toast-container .content{color:#12344d;line-height:20px;-ms-flex:1 1 auto;flex:1 1 auto;font-size:14px;font-weight:500;vertical-align:top}.toast-container .icon{margin:5px 16px 0px 16px}.toast-container .remove{margin:5px 12px 0px 12px}.action-link{color:#2c5cc5;line-height:14px;cursor:pointer;font-size:12px;font-weight:600;padding:8px 0px}@-webkit-keyframes fadeOut{100%{top:-600px}}@keyframes fadeOut{100%{top:-600px}}@-webkit-keyframes fadeIn{0%{top:-600px}100%{top:10px}}@keyframes fadeIn{0%{top:-600px}100%{top:10px}}@media screen and (prefers-reduced-motion: reduce){.toast.fade-out{-webkit-animation:none;animation:none}}.toast.fade-out{-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-name:fadeOut;animation-name:fadeOut}';var iconColorMap={error:"#e43538",warning:"#c7502f",info:"#264966",success:"#00795b"};var ToastMessage=function(){function t(t){registerInstance(this,t);this.fwLinkClick=createEvent(this,"fwLinkClick",7);this.fwRemoveToast=createEvent(this,"fwRemoveToast",7);this.open=false;this.isTimedOut=false;this.fadeOut=false;this.iconSize=16;this.type="warning";this.timeout=4e3;this.actionLinkText="";this.sticky=false}t.prototype.openChanged=function(t){if(t)this.setUpToast()};t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(this.open)this.setUpToast();return[2]}))}))};t.prototype.setUpToast=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){this.fadeOut=false;this.isTimedOut=false;this.timerId=setTimeout((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!!this.sticky)return[3,3];if(!(!this.pauseOnHover||this.pauseOnHover&&!this.isMouseHovered))return[3,2];return[4,this.closeToast()];case 1:t.sent();t.label=2;case 2:this.isTimedOut=true;t.label=3;case 3:return[2]}}))}))}),this.timeout);return[2]}))}))};t.prototype.mouseHover=function(t){if(t===void 0){t=false}return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:this.isMouseHovered=t;if(!(this.isTimedOut&&!this.isMouseHovered))return[3,2];return[4,this.closeToast()];case 1:e.sent();e.label=2;case 2:return[2]}}))}))};t.prototype.closingAnimation=function(){var t=this;this.fadeOut=true;return new Promise((function(e){return setTimeout((function(){t.open=false;t.fwRemoveToast.emit(t.controllerEl);e()}),500)}))};t.prototype.closeToast=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(this.timerId){clearTimeout(this.timerId)}return[4,this.closingAnimation()];case 1:t.sent();return[2]}}))}))};t.prototype.disconnectedCallback=function(){this.fwRemoveToast.emit(this.controllerEl);if(this.timerId)clearTimeout(this.timerId)};t.prototype.render=function(){var t=this;return h(Host,{onmouseover:function(){return t.mouseHover(true)},onmouseout:function(){return t.mouseHover(false)},"aria-hidden":this.open?"false":"true"},h("div",{class:"toast "+this.type+" "+(this.open?"is-open":"")+" "+(this.fadeOut?"fade-out":""),"aria-hidden":this.open?"false":"true"},h("div",{class:"toast-container"},this.type==="inprogress"?h("fw-spinner",{class:"icon"}):h("fw-icon",{class:"icon",size:this.iconSize,name:this.type,color:iconColorMap[this.type]}),h("div",{class:"content"},h("slot",null),this.content,this.actionLinkText.length>0?h("div",{class:"action-link",role:"button",tabindex:"0",onClick:function(){return t.fwLinkClick.emit()},onKeyDown:handleKeyDown((function(){return t.fwLinkClick.emit()}))},this.actionLinkText):""),h("fw-icon",{size:10,name:"cross",class:"remove",color:"#183247",onClick:function(){return t.closeToast()},library:"system"}))))};Object.defineProperty(t.prototype,"controllerEl",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{open:["openChanged"]}},enumerable:false,configurable:true});return t}();ToastMessage.style=toastMessageCss;export{Button as fw_button,Icon as fw_icon,Spinner as fw_spinner,ToastMessage as fw_toast_message};