customizable-toast-notification 3.9.7 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- /**
2
- * Public API for creating a toast
3
- * @param {Object} options Toast options
4
- */
5
- declare function createToast(options?: any): Promise<void>;
1
+ declare function dismissToast(): Promise<void>;
2
+ declare function noopAll(): Promise<void>;
3
+ declare function createToastWithPriority(options?: {}): Promise<any>;
6
4
  /**
7
5
  * Sets default colors
8
6
  * @param {Object} colors
@@ -13,16 +11,5 @@ declare function setDefaultColors(colors: any): void;
13
11
  * @param {Object} messages
14
12
  */
15
13
  declare function setDefaultMessages(messages: any): void;
16
- /**
17
- * Removes the first visible toast from the DOM.
18
- * Remove toast notifications from the DOM.
19
- *
20
- * @async
21
- * @function noop
22
- * @param {"all"} [mode] - If `"all"`, removes all matching toast elements.
23
- * Otherwise, removes only the first matching toast.
24
- * @returns {Promise<void>} Resolves when removal is attempted.
25
- */
26
- declare function noop(): Promise<void>;
27
14
 
28
- export { createToast, noop, setDefaultColors, setDefaultMessages };
15
+ export { createToastWithPriority as createToast, dismissToast as dismiss, dismissToast, noopAll as noop, noopAll, setDefaultColors, setDefaultMessages };
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.9.7
3
- * Build: 2025-10-08 00:37:32
4
- * Cache-Buster: 1759883852353
2
+ * Customizable Toast Notifications 3.10.0
3
+ * Build: 2025-11-08 18:32:14
4
+ * Cache-Buster: 1762626734797
5
5
  * Author: Priyanshu Patel
6
6
  * Email: [priyanshu.alt191@gmail.com](mailto:priyanshu.alt191@gmail.com)
7
7
  * License: Apache-2.0
@@ -12,5 +12,5 @@
12
12
  * Supports flexible positioning, theming, icons, animations, and timing options
13
13
  * out of the box — with CTA support and zero dependencies.
14
14
  */
15
- async function t(t,e){const n=document.createElement(t);return n.id=function(t){return`${t}-${Date.now().toString(36)}-${Math.floor(1048575*Math.random()).toString(36)}`}(e),n}const e=new class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200;this.maxSize=t,this.map=new Map}get(t){if(!this.map.has(t))return;const e=this.map.get(t);return this.map.delete(t),this.map.set(t,e),e}set(t,e){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxSize){const t=this.map.keys().next().value;this.map.delete(t)}this.map.set(t,e)}}(200),n={};function o(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(!t)return"snow";const i=`${t}|${o}`,a=e.get(i);if(a)return a;if(n[null==t?void 0:t.toLowerCase()]){const o=n[t.toLowerCase()];return e.set(i,o),o}let r,s,l;try{const e=null==t?void 0:t.match(/^#([0-9a-f]{3,8})$/i);if(e){let t=e[1];3===t.length&&(t=t.split("").map(t=>t+t).join("")),r=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),l=parseInt(t.slice(4,6),16)}else{const e=null==t?void 0:t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/i);if(!e)throw new Error("Unknown color");r=Number(e[1]),s=Number(e[2]),l=Number(e[3])}}catch(t){r=50+Math.floor(206*Math.random()),s=50+Math.floor(206*Math.random()),l=50+Math.floor(206*Math.random())}r=Math.round(r*o+255*(1-o)),s=Math.round(s*o+255*(1-o)),l=Math.round(l*o+255*(1-o));const u=(t,e,n)=>{const o=[t,e,n].map(t=>(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*o[0]+.7152*o[1]+.0722*o[2]},d=(t,e)=>{const n=u(...t),o=u(...e);return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)};let[c,h,m]=((t,e,n)=>{t/=255,e/=255,n/=255;const o=Math.max(t,e,n),i=Math.min(t,e,n);let a,r,s=(o+i)/2;if(o===i)a=r=0;else{const l=o-i;switch(r=s>.5?l/(2-o-i):l/(o+i),o){case t:a=(e-n)/l+(e<n?6:0);break;case e:a=(n-t)/l+2;break;case n:a=(t-e)/l+4}a/=6}return[360*a,r,s]})(r,s,l);let p=m<.5?Math.min(m+.5,1):Math.max(m-.5,0),[f,g,y]=((t,e,n)=>{let o,i,a;if(t/=360,0===e)o=i=a=n;else{const r=(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),s=n<.5?n*(1+e):n+e-n*e,l=2*n-s;o=r(l,s,t+1/3),i=r(l,s,t),a=r(l,s,t-1/3)}return[Math.round(255*o),Math.round(255*i),Math.round(255*a)]})(c,h,p);if(d([r,s,l],[f,g,y])<4.5){const t=d([r,s,l],[0,0,0]),e=d([r,s,l],[255,255,255]);[f,g,y]=t>=e?[0,0,0]:[255,255,255]}const b=((t,e,n)=>`#${t.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`)(f,g,y);return e.set(i,b),b}async function i(t,e,n){var o;const i=await async function(t){if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}return 500}(null==e?void 0:e.animationDuration);t.className=`toast toast-${null!==(o=null==e?void 0:e.type)&&void 0!==o?o:"info"}`,Object.assign(t.style,{background:null==e?void 0:e.backgroundColor,padding:"12px 16px",marginBottom:"10px",borderRadius:null==e?void 0:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:null==e?void 0:e.maxWidth,opacity:"0",position:"relative",cursor:"default",boxSizing:"border-box",userSelect:"text",transition:`opacity ${null==e?void 0:e.animationDuration} ${null==e?void 0:e.animationEasing}, transform ${null==e?void 0:e.animationDuration} ${null==e?void 0:e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t.setAttribute("role","alert"),t.setAttribute("aria-live","polite"),t.tabIndex=0,t._animationDuration=i;const a=document.createElement("span");null!=e&&e.wrapText?Object.assign(a.style,{display:"block",whiteSpace:"normal"}):Object.assign(a.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"nowrap"}),Object.assign(a.style,{flex:"1",padding:null==e?void 0:e.fontPadding,fontFamily:null==e?void 0:e.fontFamily,fontSize:null==e?void 0:e.fontSize,fontWeight:null==e?void 0:e.fontWeight,lineHeight:null==e?void 0:e.fontLineHeight,color:null==e?void 0:e.textColor,userSelect:"text",wordBreak:"break-word",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:"3",WebkitBoxOrient:"vertical"}),a.textContent=null==e?void 0:e.message,a.setAttribute("message",null==e?void 0:e.message),a.setAttribute("aria-label",null==e?void 0:e.message),t.appendChild(a),null!=e&&e.cta&&0!==Object.keys(e.cta).length&&function(t,e,n){const o=null==e?void 0:e.cta;if(!o)return;o.label||(o.label="CTA Label Missing!");const i=!!o.href&&"link"===o.variant,a=document.createElement(i?"a":"button");i?(a.href=o.href,o.target&&(a.target=o.target),a.rel=o.rel||("_blank"===o.target?"noopener noreferrer":"")):a.type="button",a.setAttribute("aria-label",o.ariaLabel||o.label),Object.assign(a.style,{marginLeft:"10px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:"1px solid rgba(255,255,255,0.35)",color:e.textColor||"#fff",background:"rgba(255,255,255,0.15)",cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0"}),a.textContent=o.label;const r=async e=>{try{if("function"==typeof o.onClick){const t=o.onClick(e);null!=t&&t.then&&await t}}finally{!1!==o.autoClose&&n(t)}};a.addEventListener("click",r),a._cleanup=()=>a.removeEventListener("click",r),t.appendChild(a)}(t,e,n),null!=e&&e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.setAttribute("aria-label","Close notification"),o.setAttribute("title","Close"),o.textContent="×",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"});const i=()=>n(t);o.addEventListener("click",i),t._cleanupCloseButton=()=>{o.removeEventListener("click",i)},t.appendChild(o)}(t,e,n),null!=e&&e.showProgressBar&&function(t,e){const n=document.createElement("div"),o=e.borderRadius||0,i=parseInt(o,10),a=i?`calc(100% - ${i-10+"px"})`:"100%",r=i?"12px":"0";Object.assign(n.style,{position:"absolute",left:`${r}`,height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:`${a}`,transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0",borderRadius:e.borderRadius||"4px"}),t.appendChild(n),setTimeout(()=>{n.offsetWidth,n.style.width="0%"},50)}(t,e),function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function a(t,e){try{const n=document.createElement("div");Object.assign(n.style,{background:"#333",color:"white",padding:"10px 15px",position:"fixed",top:"20px",right:"20px",zIndex:"99999",borderRadius:"3px",maxWidth:"250px",wordWrap:"break-word",boxShadow:"0 2px 10px rgba(0,0,0,0.3)",cursor:"pointer"});const o=document.createElement("span");o.textContent=(null==t?void 0:t.message)||"Emergency Toast Creation Showing!",n.appendChild(o);const i=document.createElement("span");return i.textContent="×",Object.assign(i.style,{float:"right",marginLeft:"10px",fontWeight:"bold"}),i.onclick=()=>{n.remove(),e(n)},n.appendChild(i),document.body.appendChild(n),setTimeout(()=>{n.remove(),e(n)},null==t?void 0:t.duration),n}catch(n){return setTimeout(()=>{alert((null==t?void 0:t.message)||"Emergency Toast Creation Showing!"),e(null)},100),null}}Object.entries({aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}).forEach(t=>{let[e,[o,i,a]]=t;const r=t=>{const e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)},s=.2126*r(o)+.7152*r(i)+.0722*r(a),l=(s+.05)/.05,u=1.05/(s+.05);n[e.toLowerCase()]=l>=u?"#000000":"#ffffff"});const r=new Map,s=new Map;function l(t){return`toast-container-${function(t){return String(t).toLowerCase().trim().replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-")}(t)}`}async function u(t,e){const n=l(t.position);if(s.has(n))return s.get(n);const o=(async()=>{const o=r.get(n);if(null!=o&&o.isConnected)return o;let i=document.getElementById(n);i&&!i.isConnected&&document.body.appendChild(i),i?(i.style.position=i.style.position||"fixed",i.style.zIndex=i.style.zIndex||"9999","function"==typeof e&&await e(i,t)):(i=document.createElement("div"),i.id=n,i.setAttribute("role","status"),i.setAttribute("aria-atomic","true"),i.style.position="fixed",i.style.zIndex="9999",i.style.inset="auto 10px 10px auto",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.flexDirection="column",i.style.overflow="hidden","function"==typeof e&&await e(i,t),document.body.appendChild(i));const a=document.querySelectorAll(`#${n}`);if(a.length>1)for(let t=1;t<a.length;t++)try{a[t].remove()}catch(t){}return r.set(n,i),i})();s.set(n,o);try{return await o}finally{s.delete(l(t.position))}}async function d(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const n=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,n){if(!n.hasFullWidth)return!1;if(e.maxWidth="100vw",n.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(n.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,n)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,n)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,n)}class c{constructor(t,e){this.callback=t,this.delay=e,this.remaining=e,this.startTime=null,this.timeoutId=null,this.isPaused=!1,this.isCompleted=!1}start(){return this.isCompleted||this.timeoutId||(this.startTime=Date.now(),this.timeoutId=setTimeout(()=>{this.isCompleted=!0,this.timeoutId=null,this.callback()},this.remaining)),this}pause(){return this.isPaused||!this.timeoutId||this.isCompleted||(clearTimeout(this.timeoutId),this.timeoutId=null,this.remaining-=Date.now()-this.startTime,this.remaining=Math.max(0,this.remaining),this.isPaused=!0),this}resume(){return!this.isPaused||this.isCompleted||(this.isPaused=!1,this.start()),this}clear(){return this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.isCompleted=!0,this}getRemainingTime(){return this.isCompleted?0:this.isPaused?this.remaining:this.timeoutId?Math.max(0,this.remaining-(Date.now()-this.startTime)):this.delay}}const h=new Map,m=new Map,p=[];let f=0;async function g(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return`${String(t.type).trim().toLowerCase()}|${function(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return e>>>0}(String(t.message||"")).toString(16)}|${String(t.position).trim().toLowerCase()}`}(t);if(h.has(e)){const n=h.get(e);if(!n)throw new Error(`Active toast with key ${e} not found`);return n.count++,n.timer.clear(),n.timer=b(n.toast,t),await v(n),void await k(n)}if(m.has(e)){const t=m.get(e);if(!t)throw new Error(`Pending toast with key ${e} not found`);return void t.count++}const n={options:t,count:1,rafId:0};m.set(e,n),n.rafId=requestAnimationFrame(async()=>{const t=m.get(e);if(t){if(m.delete(e),f>=3)return p.push({options:t.options,key:e,count:t.count}),void await x();try{await y(t.options,e,t.count)}catch(t){}}})}catch(t){}}async function y(e,n,o){try{if(!e||"object"!=typeof e)throw new TypeError("options must be an object");f++;const r=await u(e,d);if(!r)throw new Error("Failed to create toast container");const s=await async function(e,n){if(!document.querySelector('[id^="toast-container-"]'))return null;let o;try{return o=await t("div","toast"),await i(o,e,n),o}catch(t){return o=await a(e,n),o}}(e,w);if(!s)throw new Error("Toast element creation failed");const l=document.createElement("div");Object.assign(l.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%"});const c=document.createElement("div");Object.assign(c.style,{position:"relative",overflow:"hidden",zIndex:"1"}),c.appendChild(s),l.appendChild(c),r.id.includes("toast-container-")&&r.appendChild(l);const m=!1!==e.pauseOnHover&&(!0===e.pauseOnHover||!!e.cta),p={outer:l,toast:s,count:Math.max(1,Math.floor(null!=o?o:0)),timeout:null,pauseOnHover:m};h.set(n,p),s._key=n,p.count>1&&await k(p),p.timer=b(s,e),await v(p)}catch(t){f=Math.max(0,f-1);(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(await a(e,w))}}function b(t,e){var n;const o=Number(null!==(n=e.duration)&&void 0!==n?n:1800)+5,i=new c(async()=>await w(t),o);return i.start(),i}async function v(t){if(!t.pauseOnHover||!t.outer||!t.timer)return;const{outer:e,timer:n}=t,o=()=>n.pause(),i=()=>n.resume(),a=t=>{t.target.matches("[tabindex], div, span, button, a")&&n.pause()},r=t=>{e.contains(t.relatedTarget)||n.resume()};e.addEventListener("mouseenter",o),e.addEventListener("mouseleave",i),e.addEventListener("focusin",a),e.addEventListener("focusout",r),e._pauseCleanup=()=>{e.removeEventListener("mouseenter",o),e.removeEventListener("mouseleave",i),e.removeEventListener("focusin",a),e.removeEventListener("focusout",r)}}async function w(t){try{var e,n,o;if(null==t||!t._key)return;const i=h.get(t._key);if(!i)return;null===(e=i.timer)||void 0===e||e.clear(),null===(n=i.outer)||void 0===n||null===(o=n._pauseCleanup)||void 0===o||o.call(n),h.delete(t._key),f=Math.max(0,f-1);const a=i.outer.querySelector(".toast-count-badge");a&&a.remove(),await async function(t){return t?new Promise(e=>{let n=!1;const o=()=>{n||(n=!0,async function(t){if(!t)return!0;try{var e;if(null!=t&&null!==(e=t.parentNode)&&void 0!==e&&e.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(t){}try{if(t.remove)return t.remove(),!0}catch(t){}try{return Object.assign(t.style,{display:"none",opacity:"0",pointerEvents:"none",position:"absolute",left:"-9999px"}),!0}catch(t){}}(t),e())},i=t.firstElementChild||t;if(!i)return e();const a=t=>{try{if(t.target!==i)return;i.removeEventListener("transitionend",a,!0),o()}catch(t){}};try{i.addEventListener("transitionend",a,!0)}catch(t){}setTimeout(()=>{try{i.removeEventListener("transitionend",a,!0),o()}catch(t){}},700)}):Promise.resolve()}(i.outer),await x()}catch(t){}}async function x(){for(;f<3&&p.length;){const t=p.shift();if(h.has(t.key)){const e=h.get(t.key);e.count+=t.count,await k(e);continue}y(t.options,t.key,t.count)}}async function k(t){let{outer:e,count:n}=t;if(!(e&&e instanceof HTMLElement))throw new Error("updateBadge: outer must be a valid HTMLElement");if(n<2){const t=e.querySelector(".toast-count-badge");return void(t&&t.remove())}let o=e.querySelector(".toast-count-badge");o||(o=document.createElement("span"),o.className="toast-count-badge",o.setAttribute("aria-label",`${n} identical notifications`),Object.assign(o.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),e.appendChild(o)),o.textContent=n>99?"99+":String(n);try{o.style.transform="scale(1.2)",setTimeout(()=>o.style.transform="scale(1)",150)}catch(t){}}let C={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},E={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const S=[];let L=!1;async function M(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const e=await async function(t){var e,n;const i=null==t||null===(e=t.position)||void 0===e||null===(e=e.toLowerCase())||void 0===e?void 0:e.trim(),a=null!=i&&i.includes("top-full-width")||null!=i&&i.includes("bottom-full-width")?"100vw":"400px",r={pauseOnHover:void 0,duration:2500,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:a,..."object"!=typeof t||Array.isArray(t)?{}:t};r.message=null!==(n=null==t?void 0:t.message)&&void 0!==n?n:r.message;try{var s,l,u;if(!r.backgroundColor)r.backgroundColor=null!==(l=null===(u=C)||void 0===u?void 0:u[r.type])&&void 0!==l?l:window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111";if(r.message=r.message||(null===(s=E)||void 0===s?void 0:s[r.type])||"No Message Provided!",!r.textColor&&r.backgroundColor){const t=o(r.backgroundColor);r.textColor=t}if(!r.progressColor&&r.backgroundColor)if(r.textColor)r.progressColor=r.textColor;else{const t=o(r.backgroundColor);r.progressColor=t}}catch(t){}"string"!=typeof r.message&&(r.message="No Message Provided!");return r}(t);await async function(t){try{return await u(t,d)}catch(t){return document.body}}(e),await g(e)}catch(e){const n="string"==typeof(null==t?void 0:t.message)&&null!==(null==t?void 0:t.message)?`${t.message.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}async function T(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){L||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(L=!0,S.forEach(t=>setTimeout(()=>M(t),2500)),S.length=0):document.addEventListener("DOMContentLoaded",()=>{L=!0,S.forEach(t=>setTimeout(()=>M(t),2500)),S.length=0},{once:!0}))}(),L?await M(t):S.push(t))}function I(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(C={...C,...t})}catch(t){}}function j(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(E={...E,...t})}catch(t){}}const $=async function(){const t=document.querySelector('[id^="toast-"]:not([id*="container"])');await w(t)};try{"undefined"!=typeof window&&(window.customizableToast={createToast:T,setDefaultColors:I,setDefaultMessages:j,noop:$})}catch(t){}export{T as createToast,$ as noop,I as setDefaultColors,j as setDefaultMessages};
15
+ function t(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function n(n){for(var o=1;o<arguments.length;o++){var i=null!=arguments[o]?arguments[o]:{};o%2?e(Object(i),!0).forEach(function(e){t(n,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))})}return n}async function o(t,e){const n=document.createElement(t);return n.id=function(t){const e=Date.now().toString(36),n=Math.floor(1048575*Math.random()).toString(36);return"".concat(t,"-").concat(e,"-").concat(n)}(e),n}const i=new class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200;this.maxSize=t,this.map=new Map}get(t){if(!this.map.has(t))return;const e=this.map.get(t);return this.map.delete(t),this.map.set(t,e),e}set(t,e){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxSize){const t=this.map.keys().next().value;this.map.delete(t)}this.map.set(t,e)}}(200),r={};function a(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(!t)return"snow";const n="".concat(t,"|").concat(e),o=i.get(n);if(o)return o;if(r[null==t?void 0:t.toLowerCase()]){const e=r[t.toLowerCase()];return i.set(n,e),e}let a,s,l;try{const e=null==t?void 0:t.match(/^#([0-9a-f]{3,8})$/i);if(e){let t=e[1];3===t.length&&(t=t.split("").map(t=>t+t).join("")),a=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),l=parseInt(t.slice(4,6),16)}else{const e=null==t?void 0:t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/i);if(!e)throw new Error("Unknown color");a=Number(e[1]),s=Number(e[2]),l=Number(e[3])}}catch(t){a=50+Math.floor(206*Math.random()),s=50+Math.floor(206*Math.random()),l=50+Math.floor(206*Math.random())}a=Math.round(a*e+255*(1-e)),s=Math.round(s*e+255*(1-e)),l=Math.round(l*e+255*(1-e));const c=(t,e,n)=>{const o=[t,e,n].map(t=>(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*o[0]+.7152*o[1]+.0722*o[2]},u=(t,e)=>{const n=c(...t),o=c(...e);return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)};let[d,m,h]=((t,e,n)=>{t/=255,e/=255,n/=255;const o=Math.max(t,e,n),i=Math.min(t,e,n);let r,a,s=(o+i)/2;if(o===i)r=a=0;else{const l=o-i;switch(a=s>.5?l/(2-o-i):l/(o+i),o){case t:r=(e-n)/l+(e<n?6:0);break;case e:r=(n-t)/l+2;break;case n:r=(t-e)/l+4}r/=6}return[360*r,a,s]})(a,s,l);let p=h<.5?Math.min(h+.5,1):Math.max(h-.5,0),[f,y,g]=((t,e,n)=>{let o,i,r;if(t/=360,0===e)o=i=r=n;else{const a=(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),s=n<.5?n*(1+e):n+e-n*e,l=2*n-s;o=a(l,s,t+1/3),i=a(l,s,t),r=a(l,s,t-1/3)}return[Math.round(255*o),Math.round(255*i),Math.round(255*r)]})(d,m,p);if(u([a,s,l],[f,y,g])<4.5){const t=u([a,s,l],[0,0,0]),e=u([a,s,l],[255,255,255]);[f,y,g]=t>=e?[0,0,0]:[255,255,255]}const b=((t,e,n)=>"#".concat(t.toString(16).padStart(2,"0")).concat(e.toString(16).padStart(2,"0")).concat(n.toString(16).padStart(2,"0")))(f,y,g);return i.set(n,b),b}async function s(t,e,n){var o;const i=await async function(t){if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}return 500}(null==e?void 0:e.animationDuration);t.className="toast toast-".concat(null!==(o=null==e?void 0:e.type)&&void 0!==o?o:"info"),Object.assign(t.style,{background:null==e?void 0:e.backgroundColor,padding:"12px 16px",marginBottom:"10px",borderRadius:null==e?void 0:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:null==e?void 0:e.maxWidth,opacity:"0",position:"relative",cursor:"default",boxSizing:"border-box",userSelect:"text",transition:"opacity ".concat(null==e?void 0:e.animationDuration," ").concat(null==e?void 0:e.animationEasing,", transform ").concat(null==e?void 0:e.animationDuration," ").concat(null==e?void 0:e.animationEasing),transform:"translateY(20px)",zIndex:"9999"}),t.setAttribute("role","alert"),t.setAttribute("aria-live","polite"),t.tabIndex=0,t._animationDuration=i;const r=document.createElement("span");null!=e&&e.wrapText?Object.assign(r.style,{display:"block",whiteSpace:"normal"}):Object.assign(r.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"nowrap"}),Object.assign(r.style,{flex:"1",padding:null==e?void 0:e.fontPadding,fontFamily:null==e?void 0:e.fontFamily,fontSize:null==e?void 0:e.fontSize,fontWeight:null==e?void 0:e.fontWeight,lineHeight:null==e?void 0:e.fontLineHeight,color:null==e?void 0:e.textColor,userSelect:"text",wordBreak:"break-word",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:"3",WebkitBoxOrient:"vertical"}),r.textContent=null==e?void 0:e.message,r.setAttribute("message",null==e?void 0:e.message),r.setAttribute("aria-label",null==e?void 0:e.message),t.appendChild(r),null!=e&&e.cta&&0!==Object.keys(e.cta).length&&function(t,e,n){const o=null==e?void 0:e.cta;if(!o)return;o.label||(o.label="CTA Label Missing!");const i=!!o.href&&"link"===o.variant,r=document.createElement(i?"a":"button");i?(r.href=o.href,o.target&&(r.target=o.target),r.rel=o.rel||("_blank"===o.target?"noopener noreferrer":"")):r.type="button",r.setAttribute("aria-label",o.ariaLabel||o.label),Object.assign(r.style,{marginLeft:"10px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:"1px solid rgba(255,255,255,0.35)",color:e.textColor||"#fff",background:"rgba(255,255,255,0.15)",cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0"}),r.textContent=o.label;const a=async e=>{try{if("function"==typeof o.onClick){const t=o.onClick(e);null!=t&&t.then&&await t}}finally{!1!==o.autoClose&&n(t)}};r.addEventListener("click",a),r._cleanup=()=>r.removeEventListener("click",a),t.appendChild(r)}(t,e,n),null!=e&&e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.setAttribute("aria-label","Close notification"),o.setAttribute("title","Close"),o.textContent="×",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"});const i=()=>n(t);o.addEventListener("click",i),t._cleanupCloseButton=()=>{o.removeEventListener("click",i)},t.appendChild(o)}(t,e,n),null!=e&&e.showProgressBar&&function(t,e){const n=document.createElement("div"),o=e.borderRadius||0,i=parseInt(o,10),r=i?"calc(100% - ".concat(i-10+"px",")"):"100%",a=i?"12px":"0";Object.assign(n.style,{position:"absolute",left:"".concat(a),height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"".concat(r),transition:"width ".concat(e.duration||1800,"ms linear"),["top"===e.progressPosition?"top":"bottom"]:"0",borderRadius:e.borderRadius||"4px"}),t.appendChild(n),setTimeout(()=>{n.offsetWidth,n.style.width="0%"},50)}(t,e),function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function l(t,e){try{const n=document.createElement("div");Object.assign(n.style,{background:"#333",color:"white",padding:"10px 15px",position:"fixed",top:"20px",right:"20px",zIndex:"99999",borderRadius:"3px",maxWidth:"250px",wordWrap:"break-word",boxShadow:"0 2px 10px rgba(0,0,0,0.3)",cursor:"pointer"});const o=document.createElement("span");o.textContent=(null==t?void 0:t.message)||"Emergency Toast Creation Showing!",n.appendChild(o);const i=document.createElement("span");return i.textContent="×",Object.assign(i.style,{float:"right",marginLeft:"10px",fontWeight:"bold"}),i.onclick=()=>{n.remove(),e(n)},n.appendChild(i),document.body.appendChild(n),setTimeout(()=>{n.remove(),e(n)},null==t?void 0:t.duration),n}catch(n){return setTimeout(()=>{alert((null==t?void 0:t.message)||"Emergency Toast Creation Showing!"),e(null)},100),null}}Object.entries({aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}).forEach(t=>{let[e,[n,o,i]]=t;const a=t=>{const e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)},s=.2126*a(n)+.7152*a(o)+.0722*a(i),l=(s+.05)/.05,c=1.05/(s+.05);r[e.toLowerCase()]=l>=c?"#000000":"#ffffff"});const c=new Map,u=new Map;function d(t){return"toast-container-".concat(function(t){return String(t).toLowerCase().trim().replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-")}(t))}async function m(t,e){const n=d(t.position);if(u.has(n))return u.get(n);const o=(async()=>{const o=c.get(n);if(null!=o&&o.isConnected)return o;let i=document.getElementById(n);i&&!i.isConnected&&document.body.appendChild(i),i?(i.style.position=i.style.position||"fixed",i.style.zIndex=i.style.zIndex||"9999","function"==typeof e&&await e(i,t)):(i=document.createElement("div"),i.id=n,i.setAttribute("role","status"),i.setAttribute("aria-atomic","true"),i.style.position="fixed",i.style.zIndex="9999",i.style.inset="auto 10px 10px auto",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.flexDirection="column",i.style.overflow="hidden","function"==typeof e&&await e(i,t),document.body.appendChild(i));const r=document.querySelectorAll("#".concat(n));if(r.length>1)for(let t=1;t<r.length;t++)try{r[t].remove()}catch(t){}return c.set(n,i),i})();u.set(n,o);try{return await o}finally{u.delete(d(t.position))}}async function h(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const n=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,n){if(!n.hasFullWidth)return!1;if(e.maxWidth="100vw",n.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(n.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,n)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,n)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,n)}class p{constructor(t,e){this.callback=t,this.delay=e,this.remaining=e,this.startTime=null,this.timeoutId=null,this.isPaused=!1,this.isCompleted=!1}start(){return this.isCompleted||this.timeoutId||(this.startTime=Date.now(),this.timeoutId=setTimeout(()=>{this.isCompleted=!0,this.timeoutId=null,this.callback()},this.remaining)),this}pause(){return this.isPaused||!this.timeoutId||this.isCompleted||(clearTimeout(this.timeoutId),this.timeoutId=null,this.remaining-=Date.now()-this.startTime,this.remaining=Math.max(0,this.remaining),this.isPaused=!0),this}resume(){return!this.isPaused||this.isCompleted||(this.isPaused=!1,this.start()),this}clear(){return this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.isCompleted=!0,this}getRemainingTime(){return this.isCompleted?0:this.isPaused?this.remaining:this.timeoutId?Math.max(0,this.remaining-(Date.now()-this.startTime)):this.delay}}const f=new Map,y=new Map,g=[];let b=0;async function w(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=String(t.type).trim().toLowerCase(),n=function(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return e>>>0}(String(t.message||"")).toString(16),o=String(t.position).trim().toLowerCase();return"".concat(e,"|").concat(n,"|").concat(o)}(t);if(f.has(e)){const n=f.get(e);if(!n)throw new Error("Active toast with key ".concat(e," not found"));return n.count++,n.timer.clear(),n.timer=C(n.toast,t),await E(n),void await O(n)}if(y.has(e)){const t=y.get(e);if(!t)throw new Error("Pending toast with key ".concat(e," not found"));return void t.count++}const n={options:t,count:1,rafId:0};y.set(e,n),n.rafId=requestAnimationFrame(async()=>{const t=y.get(e);if(t){if(y.delete(e),b>=3)return g.push({options:t.options,key:e,count:t.count}),void await L();try{await v(t.options,e,t.count)}catch(t){}}})}catch(t){}}async function v(t,e,n){try{if(!t||"object"!=typeof t)throw new TypeError("options must be an object");b++;const i=await m(t,h);if(!i)throw new Error("Failed to create toast container");const r=await async function(t,e){if(!document.querySelector('[id^="toast-container-"]'))return null;let n;try{return n=await o("div","toast"),await s(n,t,e),n}catch(o){return n=await l(t,e),n}}(t,S);if(!r)throw new Error("Toast element creation failed");const a=document.createElement("div");Object.assign(a.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%"});const c=document.createElement("div");Object.assign(c.style,{position:"relative",overflow:"hidden",zIndex:"1"}),c.appendChild(r),a.appendChild(c),i.id.includes("toast-container-")&&i.appendChild(a);const u=!1!==t.pauseOnHover&&(!0===t.pauseOnHover||!!t.cta),d={outer:a,toast:r,count:Math.max(1,Math.floor(null!=n?n:0)),timeout:null,pauseOnHover:u};f.set(e,d),r._key=e,d.count>1&&await O(d),d.timer=C(r,t),await E(d)}catch(e){b=Math.max(0,b-1);(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(await l(t,S))}}const x=async function(){try{if(0===f.size)return;let t=null;if(document.querySelectorAll('[id^="toast-container-"]').forEach(e=>{const n=Array.from(e.children||[]);if(0===n.length)return;const o=n.at(0);o&&(t=o.querySelector('[id^="toast-"]')||o)}),!t){const e=Array.from(f.entries());if(e.length>0){const[,n]=e.at(0);t=n.toast||n.outer&&n.outer.querySelector('[id^="toast-"]')}}if(!t)return;const e=t._key?t:t.querySelector('[id^="toast-"]')||t;await S(e)}catch(t){}},k=async function(){try{const t=Array.from(f.values()).map(t=>t.toast).filter(Boolean);g.length=0,y.clear();for(let e=t.length-1;e>=0;e--){const n=t[e];try{await S(n)}catch(t){}}}catch(t){}};function C(t,e){var n;const o=Number(null!==(n=e.duration)&&void 0!==n?n:1800)+5,i=new p(async()=>await S(t),o);return i.start(),i}async function E(t){if(!t.pauseOnHover||!t.outer||!t.timer)return;const{outer:e,timer:n}=t,o=()=>n.pause(),i=()=>n.resume(),r=t=>{t.target.matches("[tabindex], div, span, button, a")&&n.pause()},a=t=>{e.contains(t.relatedTarget)||n.resume()};e.addEventListener("mouseenter",o),e.addEventListener("mouseleave",i),e.addEventListener("focusin",r),e.addEventListener("focusout",a),e._pauseCleanup=()=>{e.removeEventListener("mouseenter",o),e.removeEventListener("mouseleave",i),e.removeEventListener("focusin",r),e.removeEventListener("focusout",a)}}async function S(t){try{var e,n,o;if(null==t||!t._key)return;const i=f.get(t._key);if(!i)return;null===(e=i.timer)||void 0===e||e.clear(),null===(n=i.outer)||void 0===n||null===(o=n._pauseCleanup)||void 0===o||o.call(n),f.delete(t._key),b=Math.max(0,b-1);const r=i.outer.querySelector(".toast-count-badge");r&&r.remove(),await async function(t){return t?new Promise(e=>{let n=!1;const o=()=>{n||(n=!0,async function(t){if(!t)return!0;try{var e;if(null!=t&&null!==(e=t.parentNode)&&void 0!==e&&e.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(t){}try{if(t.remove)return t.remove(),!0}catch(t){}try{return Object.assign(t.style,{display:"none",opacity:"0",pointerEvents:"none",position:"absolute",left:"-9999px"}),!0}catch(t){}}(t),e())},i=t.firstElementChild||t;if(!i)return e();const r=t=>{try{if(t.target!==i)return;i.removeEventListener("transitionend",r,!0),o()}catch(t){}};try{i.addEventListener("transitionend",r,!0)}catch(t){}setTimeout(()=>{try{i.removeEventListener("transitionend",r,!0),o()}catch(t){}},700)}):Promise.resolve()}(i.outer),await L()}catch(t){}}async function L(){for(;b<3&&g.length;){const t=g.shift();if(f.has(t.key)){const e=f.get(t.key);e.count+=t.count,await O(e);continue}v(t.options,t.key,t.count)}}async function O(t){let{outer:e,count:n}=t;if(!(e&&e instanceof HTMLElement))throw new Error("updateBadge: outer must be a valid HTMLElement");if(n<2){const t=e.querySelector(".toast-count-badge");return void(t&&t.remove())}let o=e.querySelector(".toast-count-badge");o||(o=document.createElement("span"),o.className="toast-count-badge",o.setAttribute("aria-label","".concat(n," identical notifications")),Object.assign(o.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),e.appendChild(o)),o.textContent=n>99?"99+":String(n);try{o.style.transform="scale(1.2)",setTimeout(()=>o.style.transform="scale(1)",150)}catch(t){}}let M={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},j={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const T=[];let I=!1;async function P(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const e=await async function(t){var e,o;const i=null==t||null===(e=t.position)||void 0===e||null===(e=e.toLowerCase())||void 0===e?void 0:e.trim(),r=null!=i&&i.includes("top-full-width")||null!=i&&i.includes("bottom-full-width")?"100vw":"400px",s=n(n({},{pauseOnHover:void 0,duration:2500,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:r}),"object"!=typeof t||Array.isArray(t)?{}:t);s.message=null!==(o=null==t?void 0:t.message)&&void 0!==o?o:s.message;try{var l,c,u;if(!s.backgroundColor)s.backgroundColor=null!==(c=null===(u=M)||void 0===u?void 0:u[s.type])&&void 0!==c?c:window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111";if(s.message=s.message||(null===(l=j)||void 0===l?void 0:l[s.type])||"No Message Provided!",!s.textColor&&s.backgroundColor){const t=a(s.backgroundColor);s.textColor=t}if(!s.progressColor&&s.backgroundColor)if(s.textColor)s.progressColor=s.textColor;else{const t=a(s.backgroundColor);s.progressColor=t}}catch(t){}"string"!=typeof s.message&&(s.message="No Message Provided!");return s}(t);await async function(t){try{return await m(t,h)}catch(t){return document.body}}(e),await w(e)}catch(e){const n="string"==typeof(null==t?void 0:t.message)&&null!==(null==t?void 0:t.message)?"".concat(t.message.substring(0,200)," toast creation failed!"):"Toast creation failed!";alert(n)}}async function A(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){I||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(I=!0,T.forEach(t=>setTimeout(()=>P(t),2500)),T.length=0):document.addEventListener("DOMContentLoaded",()=>{I=!0,T.forEach(t=>setTimeout(()=>P(t),2500)),T.length=0},{once:!0}))}(),I?await P(t):T.push(t))}function W(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(M=n(n({},M),t))}catch(t){}}function B(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(j=n(n({},j),t))}catch(t){}}let z=!1,q=null;const D=A;async function R(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return async function(t){if(z&&q)try{await q}catch(t){}return t()}(()=>D(t))}const H=async()=>{z=!0,q=(async()=>{try{await x()}finally{z=!1,q=null}})(),await q},F=async()=>{z=!0,q=(async()=>{try{await k()}finally{z=!1,q=null}})(),await q};if("undefined"!=typeof window&&"undefined"!=typeof document){let t=!1;if(!t){const e=t=>{"Escape"!==t.key&&"Esc"!==t.key||(async()=>{z=!0,q=(async()=>{try{await x()}finally{z=!1,q=null}})(),await q})()};window.addEventListener("keydown",e,{passive:!0}),t=!0}}const N=async function(){await k()};try{"undefined"!=typeof window&&(window.customizableToast={createToast:A,setDefaultColors:W,setDefaultMessages:B,noop:N,dismiss:x})}catch(t){}export{R as createToast,H as dismiss,H as dismissToast,F as noop,F as noopAll,W as setDefaultColors,B as setDefaultMessages};
16
16
  //# sourceMappingURL=index.esm.mjs.map