customizable-toast-notification 3.20.2 → 4.0.1
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/CHANGELOG.md +29 -0
- package/README.md +56 -132
- package/dist/angular.cjs +126 -0
- package/dist/angular.cjs.map +1 -0
- package/dist/angular.d.ts +44 -0
- package/dist/angular.esm.mjs +126 -0
- package/dist/angular.esm.mjs.map +1 -0
- package/dist/index.cjs +115 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.d.ts +14 -12
- package/dist/index.css.map +2 -2
- package/dist/index.d.ts +28 -630
- package/dist/index.esm.mjs +114 -4
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +114 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/react.cjs +126 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +46 -0
- package/dist/react.esm.mjs +126 -0
- package/dist/react.esm.mjs.map +1 -0
- package/dist/solid.cjs +126 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.ts +45 -0
- package/dist/solid.esm.mjs +126 -0
- package/dist/solid.esm.mjs.map +1 -0
- package/dist/svelte.cjs +126 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.ts +50 -0
- package/dist/svelte.esm.mjs +126 -0
- package/dist/svelte.esm.mjs.map +1 -0
- package/dist/vue.cjs +126 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.ts +45 -0
- package/dist/vue.esm.mjs +126 -0
- package/dist/vue.esm.mjs.map +1 -0
- package/package.json +20 -28
package/dist/svelte.cjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";/*!
|
|
2
|
+
* Customizable Toast Notifications
|
|
3
|
+
* Build: 2026-10-27 11:02:51
|
|
4
|
+
* Cache-Buster: 1793098971889
|
|
5
|
+
* Author: Priyanshu Patel
|
|
6
|
+
* Email: priyanshu.alt191@gmail.com
|
|
7
|
+
* License: Apache-2.0
|
|
8
|
+
* Dependencies: None
|
|
9
|
+
* Created: July 31, 2024
|
|
10
|
+
* A lightweight and fully customizable toast notification library
|
|
11
|
+
* designed for seamless integration with any JavaScript or framework-based UI.
|
|
12
|
+
* Supports flexible positioning, theming, icons, animations, and timing options
|
|
13
|
+
* out of the box — with CTA support and zero dependencies.
|
|
14
|
+
*/const DEFAULT_GLOBAL_CONFIG=Object.freeze({maxVisible:3,maxQueueSize:100,zIndex:9999,targetNode:null,disableInlineStyles:!1,reducedMotion:"auto",defaultPosition:"bottom-right",theme:"light",stacked:!1,swipeToDismiss:!0,sound:!1,icon:!0,pauseOnHover:!1,priorityQueue:!1,shadowDom:!1,trapFocus:!1,priorityScorer:null,onMetrics:null,debug:!1}),globalConfig={...DEFAULT_GLOBAL_CONFIG};function isValidMountTarget(t){return t&&typeof t=="object"&&typeof t.appendChild=="function"}function setConfig(t={}){if(!t||typeof t!="object"||Array.isArray(t))return getConfig();const{maxVisible:e,maxQueueSize:i,zIndex:r,targetNode:s,disableInlineStyles:n,reducedMotion:l,defaultPosition:o,theme:u,stacked:a,swipeToDismiss:c,sound:m,icon:f,pauseOnHover:p,priorityQueue:y,shadowDom:d,trapFocus:b,priorityScorer:_,onMetrics:v,debug:w}=t;if(d!==void 0&&(globalConfig.shadowDom=!!d),b!==void 0&&(globalConfig.trapFocus=!!b),w!==void 0&&(globalConfig.debug=!!w),e!==void 0){const S=Number(e);Number.isFinite(S)&&S>0&&(globalConfig.maxVisible=Math.max(1,Math.floor(S)))}if(i!==void 0){const S=Number(i);Number.isFinite(S)&&S>=0&&(globalConfig.maxQueueSize=Math.floor(S))}if(r!==void 0){const S=Number(r);Number.isFinite(S)&&(globalConfig.zIndex=Math.trunc(S))}if(s!==void 0&&(globalConfig.targetNode=s&&typeof s=="object"&&typeof s.appendChild=="function"?s:null),n!==void 0&&(globalConfig.disableInlineStyles=!!n),l!==void 0){const S=String(l||"auto").toLowerCase();["auto","always","never"].includes(S)&&(globalConfig.reducedMotion=S,typeof document<"u"&&(S==="always"?document.documentElement.setAttribute("data-toast-reduced-motion","always"):S==="never"?document.documentElement.setAttribute("data-toast-reduced-motion","never"):document.documentElement.removeAttribute("data-toast-reduced-motion")))}if(o!==void 0){const S=String(o||"").toLowerCase().trim();S&&(globalConfig.defaultPosition=S)}if(u!==void 0){const S=String(u||"light").toLowerCase();["light","dark","high-contrast","compact","spacious","glass"].includes(S)&&(globalConfig.theme=S,typeof document<"u"&&document.documentElement.setAttribute("data-toast-theme",S))}return a!==void 0&&(globalConfig.stacked=!!a),c!==void 0&&(globalConfig.swipeToDismiss=!!c),m!==void 0&&(globalConfig.sound=!!m),f!==void 0&&(globalConfig.icon=!!f),p!==void 0&&(globalConfig.pauseOnHover=!!p),y!==void 0&&(globalConfig.priorityQueue=!!y),_!==void 0&&(globalConfig.priorityScorer=typeof _=="function"?_:null),v!==void 0&&(globalConfig.onMetrics=typeof v=="function"?v:null),getConfig()}function resetConfig(){return Object.assign(globalConfig,DEFAULT_GLOBAL_CONFIG),typeof document<"u"&&(document.documentElement.removeAttribute("data-toast-theme"),document.documentElement.removeAttribute("data-toast-reduced-motion")),getConfig()}function getConfig(){return{...globalConfig}}function getToastRoot(){return isValidMountTarget(globalConfig.targetNode)?globalConfig.targetNode:typeof document<"u"?document.body:null}function shouldReduceMotion(){if(globalConfig.reducedMotion==="always")return!0;if(globalConfig.reducedMotion==="never")return!1;try{return!!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}catch{return!1}}let counter=0;function generateSalt(t=typeof globalThis<"u"?globalThis.crypto:null){if(t&&typeof t.getRandomValues=="function"){const r=new Uint16Array(1);return t.getRandomValues(r),r[0].toString(36).padStart(3,"0").slice(-3)}const e=typeof performance<"u"&&typeof performance.now=="function"?Math.floor(performance.now()*1e3):0;return((Date.now()^e)&65535).toString(36).padStart(3,"0").slice(-3)}const sessionSalt=generateSalt();function resetToastIdCounter(){counter=0}function generateToastId(t="toast"){const e=typeof t=="string"?t.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""):"",i=e&&!/^[0-9]/.test(e)?e:"toast",r=Date.now().toString(36);counter=counter+1&16777215;const s=counter.toString(36);return`${i}-${r}-${sessionSalt}${s}`}async function createElementWithId(t,e){const i=document.createElement(t);return i.id=generateToastId(e),i}async function removeElement(t){if(!t)return!0;try{if(typeof t.remove=="function")return t.remove(),!0}catch{}try{if(t.parentNode)return t.parentNode.removeChild(t),!0}catch{}return!1}async function parseAnimationDuration(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.endsWith("s")&&!e.endsWith("ms")){const r=Number.parseFloat(e)*1e3;return Number.isFinite(r)&&r>=0?r:500}const i=Number.parseFloat(e);return Number.isFinite(i)&&i>=0?i:500}return 500}class LRUCache{constructor(e=200){this.maxSize=e,this.map=new Map}get(e){if(!this.map.has(e))return;const i=this.map.get(e);return this.map.delete(e),this.map.set(e,i),i}set(e,i){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxSize){const r=this.map.keys().next().value;this.map.delete(r)}this.map.set(e,i)}}const colorCache=new LRUCache(200),namedColors={black:[0,0,0],white:[255,255,255],gray:[128,128,128],grey:[128,128,128],red:[255,0,0],green:[0,128,0],blue:[0,0,255],yellow:[255,255,0],orange:[255,165,0],purple:[128,0,128],transparent:[255,255,255]},precomputedNamedTextColors={};Object.entries(namedColors).forEach(([t,[e,i,r]])=>{const s=u=>{const a=u/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)},n=.2126*s(e)+.7152*s(i)+.0722*s(r),l=(n+.05)/.05,o=1.05/(n+.05);precomputedNamedTextColors[t.toLowerCase()]=l>=o?"#000000":"#ffffff"});function getDynamicAccessibleTextColorHex(t){if(!t)return"#ffffff";const e=String(t),i=colorCache.get(e);if(i)return i;if(precomputedNamedTextColors[t==null?void 0:t.toLowerCase()]){const g=precomputedNamedTextColors[t.toLowerCase()];return colorCache.set(e,g),g}let r,s,n;function l(g){if(typeof g!="string")return g;let x=g.trim(),C=0;for(;x.toLowerCase().startsWith("var(")&&x.endsWith(")")&&C<5;){C++;const A=x.slice(4,-1).trim(),k=A.indexOf(","),I=(k===-1?A:A.slice(0,k)).trim(),L=k===-1?"":A.slice(k+1).trim();if(!I.startsWith("--"))return x;let D="";try{typeof document<"u"&&typeof getComputedStyle=="function"&&(D=getComputedStyle(document.documentElement).getPropertyValue(I).trim())}catch{}if(D)x=D;else if(L)x=L;else break}return x}function o(g){const x=g==null?void 0:g.match(/^#(?:([0-9a-f]{3,4})|([0-9a-f]{6})|([0-9a-f]{8}))$/i);if(x){let h=x[1]||x[2]||x[3];if((h.length===3||h.length===4)&&(h=h.slice(0,3).split("").map(E=>E+E).join("")),h.length>=6){const E=Number.parseInt(h.slice(0,2),16),T=Number.parseInt(h.slice(2,4),16),P=Number.parseInt(h.slice(4,6),16);if(Number.isFinite(E)&&Number.isFinite(T)&&Number.isFinite(P))return{r:E,g:T,b:P}}return null}const C=h=>{if(typeof h!="string")return Number(h);const E=h.trim();return E.endsWith("%")?Math.round(Number.parseFloat(E)/100*255):Number(E)},A=g==null?void 0:g.match(/rgba?\(\s*([\d.]+%?)\s*,\s*([\d.]+%?)\s*,\s*([\d.]+%?)(?:\s*,\s*[\d.%]+)?\s*\)/i);if(A){const h=Math.min(255,Math.max(0,C(A[1]))),E=Math.min(255,Math.max(0,C(A[2]))),T=Math.min(255,Math.max(0,C(A[3])));if(Number.isFinite(h)&&Number.isFinite(E)&&Number.isFinite(T))return{r:h,g:E,b:T}}const k=g==null?void 0:g.match(/rgba?\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+%?)(?:\s*\/\s*[\d.%]+)?\s*\)/i);if(k){const h=Math.min(255,Math.max(0,C(k[1]))),E=Math.min(255,Math.max(0,C(k[2]))),T=Math.min(255,Math.max(0,C(k[3])));if(Number.isFinite(h)&&Number.isFinite(E)&&Number.isFinite(T))return{r:h,g:E,b:T}}const I=h=>{const E=h.trim().toLowerCase();let T=Number.parseFloat(E);return Number.isFinite(T)?(E.endsWith("turn")?T=T*360:E.endsWith("grad")?T=T*360/400:E.endsWith("rad")&&(T=T*180/Math.PI),(T%360+360)%360/360):0},L=g==null?void 0:g.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*[\d.%]+)?\s*\)/i),D=!L&&(g==null?void 0:g.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s+([\d.]+)%\s+([\d.]+)%(?:\s*\/\s*[\d.%]+)?\s*\)/i)),N=L||D;if(N){const h=I(N[1]),E=Math.min(1,Math.max(0,Number(N[2])/100)),T=Math.min(1,Math.max(0,Number(N[3])/100));if(E===0){const z=Math.round(T*255);return{r:z,g:z,b:z}}const P=(z,B,H)=>{let W=H;return W<0&&(W+=1),W>1&&(W-=1),W<1/6?z+(B-z)*6*W:W<1/2?B:W<2/3?z+(B-z)*(2/3-W)*6:z},$=T<.5?T*(1+E):T+E-T*E,j=2*T-$;return{r:Math.round(P(j,$,h+1/3)*255),g:Math.round(P(j,$,h)*255),b:Math.round(P(j,$,h-1/3)*255)}}return null}try{const g=typeof t=="string"?t.trim():String(t||""),x=l(g).trim(),C=o(x);if(!C)throw new Error("Unknown color");({r,g:s,b:n}=C)}catch{r=s=n=128}const u=(g,x,C)=>{g/=255,x/=255,C/=255;const A=Math.max(g,x,C),k=Math.min(g,x,C);let I,L,D=(A+k)/2;if(A===k)I=L=0;else{const N=A-k;switch(L=D>.5?N/(2-A-k):N/(A+k),A){case g:I=(x-C)/N+(x<C?6:0);break;case x:I=(C-g)/N+2;break;case C:I=(g-x)/N+4}I/=6}return[I*360,L,D]},a=(g,x,C)=>{g/=360;let A,k,I;if(x===0)A=k=I=C;else{const L=(h,E,T)=>(T<0&&(T+=1),T>1&&(T-=1),T<.16666666666666666?h+(E-h)*6*T:T<.5?E:T<.6666666666666666?h+(E-h)*(.6666666666666666-T)*6:h),D=C<.5?C*(1+x):C+x-C*x,N=2*C-D;A=L(N,D,g+1/3),k=L(N,D,g),I=L(N,D,g-1/3)}return[Math.round(A*255),Math.round(k*255),Math.round(I*255)]},c=(g,x,C)=>{const A=[g,x,C].map(k=>(k/=255,k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4)));return .2126*A[0]+.7152*A[1]+.0722*A[2]},m=(g,x)=>{const C=c(...g),A=c(...x);return(Math.max(C,A)+.05)/(Math.min(C,A)+.05)},f=(g,x,C)=>`#${g.toString(16).padStart(2,"0")}${x.toString(16).padStart(2,"0")}${C.toString(16).padStart(2,"0")}`;let[p,y,d]=u(r,s,n);const b=4.5;let _=d<.5?Math.min(d+.5,1):Math.max(d-.5,0),[v,w,S]=a(p,y,_);if(m([r,s,n],[v,w,S])<b){const g=m([r,s,n],[0,0,0]),x=m([r,s,n],[255,255,255]);[v,w,S]=g>=x?[0,0,0]:[255,255,255]}const M=f(v,w,S);return colorCache.set(e,M),M}const ALLOWED_TAGS=new Set(["DIV","SPAN","P","BR","STRONG","B","EM","I","U","SMALL","UL","OL","LI","A","IMG","PRE","CODE","MARK"]),ALLOWED_ATTRS=new Set(["href","src","alt","title","class","target","rel","loading"]),DISCARDED_TAGS=new Set(["SCRIPT","STYLE","IFRAME","NOSCRIPT","OBJECT","EMBED","SVG","MATH","AUDIO","VIDEO","CANVAS","TEMPLATE"]),ALLOWED_URI_REGEX=/^\s*(?:https?:|mailto:|data:image\/(?:png|jpe?g|gif|webp|avif|bmp|ico);|\/(?!\/|\\)|\.\/|\.\.\/|#)/i;function hasDOMPurify(){try{return!!(typeof window<"u"&&window.DOMPurify&&typeof window.DOMPurify.sanitize=="function")}catch{}return!1}function sanitizeAttributes(t,e){const i=[];Array.from(t.attributes||[]).forEach(s=>{const n=s.name.toLowerCase(),l=s.value;if(!e.has(n)||n.startsWith("on")){i.push(s.name);return}if(n==="href"||n==="src"){const o=typeof l=="string"?l.trim().toLowerCase():"";if((o.startsWith("javascript:")||o.startsWith("vbscript:")||o.startsWith("data:"))&&!(n==="src"&&o.startsWith("data:image/")&&!o.startsWith("data:image/svg+xml"))){if(n==="href"){t.setAttribute("href","#");return}i.push(s.name);return}if(!ALLOWED_URI_REGEX.test(l)){if(n==="href"){t.setAttribute("href","#");return}i.push(s.name);return}}if(n==="target"&&typeof l=="string"&&l.trim().toLowerCase()==="_blank"){const o=(t.getAttribute("rel")||"").split(/\s+/).filter(Boolean);o.includes("noopener")||o.push("noopener"),o.includes("noreferrer")||o.push("noreferrer"),t.setAttribute("rel",o.join(" "))}}),i.forEach(s=>t.removeAttribute(s));const r=t.getAttribute("target");if(t.tagName==="A"&&typeof r=="string"&&r.trim().toLowerCase()==="_blank"){const s=(t.getAttribute("rel")||"").split(/\s+/).filter(Boolean);s.includes("noopener")||s.push("noopener"),s.includes("noreferrer")||s.push("noreferrer"),t.setAttribute("rel",s.join(" "))}}function sanitizeNode(t,e,i){if(t.nodeType===Node.TEXT_NODE)return document.createTextNode(t.nodeValue);if(t.nodeType===Node.COMMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return null;const r=t.tagName.toUpperCase();if(DISCARDED_TAGS.has(r)||r.includes("SCRIPT")||r.includes("<")||r.includes(">"))return null;if(!e.has(r)){const n=document.createDocumentFragment();return Array.from(t.childNodes).forEach(l=>{const o=sanitizeNode(l,e,i);o&&n.appendChild(o)}),n}const s=document.createElement(t.tagName);return Array.from(t.attributes||[]).forEach(n=>{s.setAttribute(n.name,n.value)}),sanitizeAttributes(s,i),Array.from(t.childNodes).forEach(n=>{const l=sanitizeNode(n,e,i);l&&s.appendChild(l)}),s}function parseHtmlInert(t){if(typeof DOMParser<"u")try{const i=new DOMParser().parseFromString(t,"text/html");if(i&&i.body)return i.body}catch{}if(typeof document<"u"){const e=document.createElement("template");if("content"in e)return e.innerHTML=t,e.content;const i=document.createElement("div");return i.innerHTML=t,i}return null}function fallbackSanitize(t){if(!t||typeof t!="string")return"";const e=parseHtmlInert(t);if(!e)return"";const i=document.createDocumentFragment();Array.from(e.childNodes).forEach(s=>{const n=sanitizeNode(s,ALLOWED_TAGS,ALLOWED_ATTRS);n&&i.appendChild(n)});const r=document.createElement("div");return r.appendChild(i),r.querySelectorAll('a[target="_blank"]').forEach(s=>{const n=(s.getAttribute("rel")||"").split(/\s+/).filter(Boolean);n.includes("noopener")||n.push("noopener"),n.includes("noreferrer")||n.push("noreferrer"),s.setAttribute("rel",n.join(" "))}),r.innerHTML}function sanitizeHtml(t,e={}){if(typeof t!="string"||!t.trim())return"";try{if(!e.forceFallback&&hasDOMPurify()){const r=window.DOMPurify.sanitize(t,{ALLOWED_TAGS:Array.from(ALLOWED_TAGS),ALLOWED_ATTR:Array.from(ALLOWED_ATTRS),ALLOWED_URI_REGEXP:ALLOWED_URI_REGEX}),s=document.createElement("div");return s.innerHTML=r,s.querySelectorAll("a[href]").forEach(n=>{const l=n.getAttribute("href")||"";ALLOWED_URI_REGEX.test(l)||n.setAttribute("href","#")}),s.querySelectorAll('a[target="_blank"]').forEach(n=>{const l=(n.getAttribute("rel")||"").split(/\s+/).filter(Boolean);l.includes("noopener")||l.push("noopener"),l.includes("noreferrer")||l.push("noreferrer"),n.setAttribute("rel",l.join(" "))}),s.innerHTML}}catch(i){console.warn("DOMPurify sanitization failed, falling back:",i)}return fallbackSanitize(t)}function createLoader(t={}){if(typeof document>"u")return null;const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},i=Number(e.size),r=Number.isFinite(i)&&i>0?i:14,s=typeof e.color=="string"&&e.color.trim()?e.color.trim():"currentColor",n=/[\r\n<>"';]/.test(s)||/^\s*javascript:/i.test(s)?"currentColor":s,l=typeof e.text=="string"?e.text:"",o=document.createElement("span");o.className="toast-loader",o.setAttribute("role","status"),o.setAttribute("aria-label",l||"Loading");const u=getConfig();u.disableInlineStyles||(o.style.display="inline-flex",o.style.alignItems="center",o.style.gap="8px");const a="http://www.w3.org/2000/svg",c=document.createElementNS(a,"svg");c.setAttribute("width",String(r)),c.setAttribute("height",String(r)),c.setAttribute("viewBox","0 0 50 50"),c.setAttribute("aria-hidden","true");const m=document.createElementNS(a,"circle");if(m.classList.add("toast-loader-circle"),m.setAttribute("cx","25"),m.setAttribute("cy","25"),m.setAttribute("r","20"),m.setAttribute("fill","none"),m.setAttribute("stroke",n),m.setAttribute("stroke-width","4"),m.setAttribute("stroke-linecap","round"),u.disableInlineStyles||(m.style.opacity="0.85",m.style.strokeDasharray="90",m.style.strokeDashoffset="60",m.style.transformOrigin="center",shouldReduceMotion()||(m.style.animation="toast-spinner 1s linear infinite")),c.appendChild(m),o.appendChild(c),l){const f=document.createElement("span");f.className="toast-loader-label",u.disableInlineStyles||(f.style.fontSize="13px"),f.textContent=l,o.appendChild(f)}if(!u.disableInlineStyles&&typeof document<"u"&&!document.getElementById("toast-spinner-styles"))try{const f=document.createElement("style");f.id="toast-spinner-styles",f.textContent="@keyframes toast-spinner { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }";const p=document.head||document.documentElement;p&&p.appendChild(f)}catch{}return o}function createCTA(t,e,i){const r=e==null?void 0:e.cta;if(!r||typeof r!="object")return;const s=Array.isArray(r)?r.filter(o=>o&&typeof o=="object"):[r];if(s.length===0)return;const n=[];s.forEach((o,u)=>{if(!o||typeof o!="object")return;const a={...o};a.label||(a.label=s.length>1?`Action ${u+1}`:"CTA Label Missing!");const c=a.variant==="link"||!a.variant&&!!a.href,m=document.createElement(c?"a":"button");if(c){if(a.href){const x=String(a.href).trim(),C=/^(javascript:|vbscript:|data:(?!image\/[a-z0-9.+-]+;base64,))/i.test(x);m.href=C?"#":x}else m.setAttribute("role","button"),m.tabIndex=0;a.target&&(m.target=a.target);const g=new Set((a.rel||"").split(/\s+/).filter(Boolean));typeof a.target=="string"&&a.target.trim().toLowerCase()==="_blank"&&(g.add("noopener"),g.add("noreferrer")),m.rel=Array.from(g).join(" ")}else m.type="button";m.setAttribute("aria-label",a.ariaLabel||a.label);const f=a.textColor||a.color||e.textColor||getDynamicAccessibleTextColorHex(e.backgroundColor),p=a.backgroundColor||a.background||(e.backgroundColor?getContrastBackground(e.backgroundColor):"rgba(255,255,255,0.15)"),d=(typeof f=="string"?f.trim():"").match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);let b="rgba(128, 128, 128, 0.3)";d&&(b=`${d[1].length===3?`#${d[1][0]}${d[1][0]}${d[1][1]}${d[1][1]}${d[1][2]}${d[1][2]}`:`#${d[1]}`}44`),m.className="toast-cta";const _=e.fontDirection==="rtl";getConfig().disableInlineStyles||Object.assign(m.style,{marginLeft:_?"0px":u===0?"10px":"6px",marginRight:_?u===0?"10px":"6px":"0px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:`1px solid ${b}`,color:f,background:p,cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0",display:"inline-flex",alignItems:"center",textDecoration:"none",outline:"none"}),m.textContent=a.label;const v=async g=>{if(!m._isExecuting){m._isExecuting=!0;try{if(typeof a.onClick=="function"){const x=a.onClick(g);x!=null&&x.then&&await x}}catch(x){console.error("CTA onClick handler error:",x)}finally{m._isExecuting=!1,a.autoClose!==!1&&typeof i=="function"&&await i(t)}}},w=g=>{c&&!a.href&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),v(g))};m.addEventListener("click",v),c&&!a.href&&m.addEventListener("keydown",w);const S=()=>{m.removeEventListener("click",v),c&&!a.href&&m.removeEventListener("keydown",w)};m._cleanup=S,n.push(S);const M=t.querySelector(".toast-undo-btn")||t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");M?t.insertBefore(m,M):t.appendChild(m)});const l=t._cleanupCTA;t._cleanupCTA=()=>{l==null||l(),n.forEach(o=>o())}}function createUndoAction(t,e,i){const r=e==null?void 0:e.undo;if(!r)return;const s=typeof r=="function";if(!s&&(typeof r!="object"||Array.isArray(r)))return;const n=s?{onUndo:r}:{...r},l=typeof n.label=="string"&&n.label.trim()?n.label.trim():typeof(e==null?void 0:e.undoText)=="string"&&e.undoText.trim()?e.undoText.trim():"Undo",o=Number(e==null?void 0:e.duration),u=n.showCountdown!==!1&&Number.isFinite(o)&&o>0,a=document.createElement("button");a.type="button",a.className="toast-undo-btn",a.setAttribute("aria-label",`${l} action`);const c=e.textColor||getDynamicAccessibleTextColorHex(e.backgroundColor),m=e.backgroundColor?getContrastBackground(e.backgroundColor):"rgba(255,255,255,0.18)",p=(typeof c=="string"?c.trim():"").match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);let y="rgba(128, 128, 128, 0.35)";p&&(y=`${p[1].length===3?`#${p[1][0]}${p[1][0]}${p[1][1]}${p[1][1]}${p[1][2]}${p[1][2]}`:`#${p[1]}`}55`);const d=e.fontDirection==="rtl";getConfig().disableInlineStyles||Object.assign(a.style,{marginLeft:d?"0px":"10px",marginRight:d?"10px":"0px",padding:"5px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"700",lineHeight:"1",border:`1px solid ${y}`,color:c,background:m,cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0",display:"inline-flex",alignItems:"center",gap:"4px"});let b=Math.max(1,Math.ceil((o||2500)/1e3));const _=()=>{a.textContent=u?`${l} (${b}s)`:l};_();let v=null,w=!1;u&&(v=setInterval(()=>{w||(b=Math.max(0,b-1),_(),b<=0&&v&&(clearInterval(v),v=null))},1e3),typeof(v==null?void 0:v.unref)=="function"&&v.unref()),t._pauseUndo=()=>{w=!0},t._resumeUndo=()=>{w=!1};const S=()=>{v&&(clearInterval(v),v=null),t._pauseUndo=null,t._resumeUndo=null},M=async x=>{S(),a.removeEventListener("click",M);try{if(typeof n.onUndo=="function"){const C=n.onUndo(x,t);C!=null&&C.then&&await C}}catch(C){console.error("Undo action error:",C)}finally{typeof i=="function"&&await i(t)}};a.addEventListener("click",M),a._cleanup=()=>{S(),a.removeEventListener("click",M)},t._cleanupUndo=()=>{S(),a.removeEventListener("click",M)};const g=t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");g?t.insertBefore(a,g):t.appendChild(a)}function createCloseButton(t,e,i){const r=document.createElement("button");r.type="button";const s=typeof(e==null?void 0:e.closeAriaLabel)=="string"&&e.closeAriaLabel.trim()?e.closeAriaLabel.trim():"Close notification";r.setAttribute("aria-label",s),r.setAttribute("title",s),r.textContent="\xD7";const n=e.textColor||getDynamicAccessibleTextColorHex(e.backgroundColor);r.className="toast-close-btn";const l=e.fontDirection==="rtl";getConfig().disableInlineStyles||Object.assign(r.style,{background:"none",border:"none",color:n,fontSize:"18px",marginLeft:l?"0px":"10px",marginRight:l?"10px":"0px",cursor:"pointer",lineHeight:"1",padding:"0 4px",flexShrink:"0",display:"inline-flex",alignItems:"center",justifyContent:"center"});const o=()=>{typeof i=="function"&&i(t)};r.addEventListener("click",o),t._cleanupCloseButton=()=>{r.removeEventListener("click",o)},t.appendChild(r)}function getContrastBackground(t){return t&&getDynamicAccessibleTextColorHex(t)==="#000000"?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"}function ensureProgressIndeterminateStyles(){if(typeof document>"u"||document.getElementById("toast-progress-indeterminate-styles"))return;const t=document.createElement("style");t.id="toast-progress-indeterminate-styles",t.textContent=`
|
|
15
|
+
@keyframes toast-progress-indeterminate {
|
|
16
|
+
0% { left: 0%; width: 0%; }
|
|
17
|
+
50% { left: 20%; width: 60%; }
|
|
18
|
+
100% { left: 100%; width: 0%; }
|
|
19
|
+
}
|
|
20
|
+
@keyframes toast-progress-indeterminate-rtl {
|
|
21
|
+
0% { right: 0%; width: 0%; }
|
|
22
|
+
50% { right: 20%; width: 60%; }
|
|
23
|
+
100% { right: 100%; width: 0%; }
|
|
24
|
+
}
|
|
25
|
+
.toast-progress-bar-indeterminate {
|
|
26
|
+
animation: toast-progress-indeterminate 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
|
|
27
|
+
}
|
|
28
|
+
.toast-progress-bar-indeterminate-rtl {
|
|
29
|
+
animation: toast-progress-indeterminate-rtl 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
|
|
30
|
+
}
|
|
31
|
+
`;const e=document.head||document.documentElement;e&&e.appendChild(t)}function parseProgressValue(t,e,i={}){if(t==null)return null;if(t==="indeterminate")return"indeterminate";let r;return typeof t=="string"?r=Number.parseFloat(t.trim()):r=Number(t),Number.isFinite(r)?(e&&r>0&&r<1&&(e._progressRatioMode=!0),((i.progressNormalized||e!=null&&e._progressRatioMode)&&r>0&&r<=1||r>0&&r<1)&&(r=r*100),Math.min(100,Math.max(0,r))):0}function createProgressBar(t,e={}){var i;if(!t)return;const r=document.createElement("div");r.className="toast-progress-bar",t._progressBar=r;const s=e.borderRadius||"0",n=Number.parseInt(s,10),l=Number.isFinite(n)&&n>0?n:0;let o=4,u="4px";if(typeof e.progressHeight=="number"&&Number.isFinite(e.progressHeight)&&e.progressHeight>0)o=e.progressHeight,u=`${o}px`;else if(typeof e.progressHeight=="string"&&e.progressHeight.trim()){const v=e.progressHeight.trim(),w=Number.parseFloat(v);Number.isFinite(w)&&w>0&&(v.endsWith("rem")||v.endsWith("em")?(o=w*16,u=v):(o=w,u=/^\d+(\.\d+)?$/.test(v)?`${w}px`:v))}const a=Number(e.duration??2500),c=Math.max(0,a+5),m=Math.min(l,o*2),f=l>0?`calc(100% - ${m*2}px)`:"100%",p=e.progressDirection==="reverse"||e.progressDirection==="increasing"||e.progressDirection==="ltr",y=e.fontDirection==="rtl"||e.progressDirection==="rtl"||((i=t==null?void 0:t.style)==null?void 0:i.direction)==="rtl";r._leftOffset=m,r._finalWidth=f,r._isReverse=p,r._isRtl=y;const d=e.progressBarColor||e.progressColor||"currentColor",b=typeof r.animate=="function";getConfig().disableInlineStyles||Object.assign(r.style,{position:"absolute",left:y?"auto":`${m}px`,right:y?`${m}px`:"auto",height:u,background:d,width:p?"0%":`${f}`,transition:b?"none":`width ${c}ms linear`,[e.progressPosition==="top"?"top":"bottom"]:"0",borderRadius:`${o/2}px`,opacity:"0.8",zIndex:"2",willChange:"width"}),t.appendChild(r);const _=e.progress==="indeterminate"||!!e.showProgressBar&&(e.duration===0||e.duration===1/0)&&e.progress===void 0;if(r._isIndeterminate=_,r._isManualProgress=e.progress!==void 0&&e.progress!=="indeterminate",_){if(r.classList.add("toast-progress-bar-indeterminate"),y&&r.classList.add("toast-progress-bar-indeterminate-rtl"),!getConfig().disableInlineStyles){ensureProgressIndeterminateStyles();const v=y?"toast-progress-indeterminate-rtl":"toast-progress-indeterminate";r.style.animation=`${v} 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite`}r.style.width=f;return}if(e.progress!==void 0){const v=parseProgressValue(e.progress,t,e);r.style.width=`${v}%`,r.style.transition="width 200ms ease";return}if(e.duration===0||e.duration===1/0){r.style.width="0%";return}if(shouldReduceMotion())r.style.display="none";else if(typeof r.animate=="function"){const v=p?[{width:"0%"},{width:f}]:[{width:f},{width:"0%"}];t._progressAnimation=r.animate(v,{duration:c,easing:"linear",fill:"forwards",delay:50})}else r.style.transition=`width ${c}ms linear`,requestAnimationFrame(()=>{r.style.width=p?f:"0%"})}function runToastAnimation(t){if(!t||t._hasAnimated)return;if(shouldReduceMotion()){t._hasAnimated=!0,t.style.transition="none",t.style.opacity="1",t.style.transform="translateY(0)",t.classList.add("active");return}const e=()=>{if(!t._hasAnimated){t._hasAnimated=!0;try{t.offsetHeight}catch{}requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="none",t.classList.add("active")})}};t.isConnected?e():requestAnimationFrame(()=>{t.isConnected?e():requestAnimationFrame(()=>{e()})})}function attachSwipeToDismiss(t,e){if(!t||typeof t.addEventListener!="function")return;let i=0,r=0,s=0,n=0,l=!1,o=!1,u=null,a=!1;const c=()=>{a&&(a=!1,window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",p))},m=y=>{if(!y||y.button!==void 0&&y.button!==0)return;const d=y.target;if(d&&typeof d.closest=="function"&&d.closest("button, a, input, textarea, select, label"))return;let b=y;y.touches&&y.touches.length>0?(b=y.touches[0],u=b.identifier??null):u=null,i=b.clientX,r=b.clientY,s=i,n=Date.now(),l=!0,o=!1,t._originalTransition=t.style.transition||"",t.style.transition="none",t.style.userSelect="none",!a&&typeof window<"u"&&(a=!0,window.addEventListener("mousemove",f,{passive:!1}),window.addEventListener("mouseup",p,{passive:!0}))},f=y=>{if(!l||!y)return;let d=y;if(y.touches)if(u!==null){for(let S=0;S<y.touches.length;S++)if(y.touches[S].identifier===u){d=y.touches[S];break}}else y.touches.length>0&&(d=y.touches[0]);const b=d.clientX,_=d.clientY,v=b-i,w=_-r;if(!o){if(Math.abs(v)>8&&Math.abs(v)>Math.abs(w))o=!0;else if(Math.abs(w)>8){l=!1,t.style.userSelect="",c();return}}if(o){s=b;const S=Math.max(0,1-Math.abs(v)/280);!getConfig().disableInlineStyles&&!shouldReduceMotion()&&(t.style.transform=`translateX(${v}px)`,t.style.opacity=String(S)),y.cancelable&&y.preventDefault()}},p=()=>{var y,d;if(c(),u=null,!l||!o){l=!1,t.style.userSelect="";return}l=!1,t.style.userSelect="";const b=s-i,_=Math.max(1,Date.now()-n),w=(_>0?Math.abs(b)/_:0)>=.65&&Math.abs(b)>=50,S=w?50:75;if(Math.abs(b)>=S){const M=b>0?320:-320,g=w?120:180;!getConfig().disableInlineStyles&&!shouldReduceMotion()&&(t.style.transition=`transform ${g}ms ease-out, opacity ${g}ms ease-out`,t.style.transform=`translateX(${M}px)`,t.style.opacity="0"),t._swipeTimeout&&clearTimeout(t._swipeTimeout),t._swipeTimeout=setTimeout(()=>{t._swipeTimeout=null,typeof e=="function"&&e(t)},g),typeof((y=t._swipeTimeout)==null?void 0:y.unref)=="function"&&t._swipeTimeout.unref()}else if(!getConfig().disableInlineStyles&&!shouldReduceMotion()){const M="cubic-bezier(0.34, 1.56, 0.64, 1)";t.style.transition=`transform 200ms ${M}, opacity 200ms ease`,t.style.transform="translateX(0)",t.style.opacity="1",t._snapbackTimer&&clearTimeout(t._snapbackTimer),t._snapbackTimer=setTimeout(()=>{t._snapbackTimer=null,t.style.transform="none",t._originalTransition&&(t.style.transition=t._originalTransition)},200),typeof((d=t._snapbackTimer)==null?void 0:d.unref)=="function"&&t._snapbackTimer.unref()}};t.addEventListener("touchstart",m,{passive:!0}),t.addEventListener("touchmove",f,{passive:!1}),t.addEventListener("touchend",p,{passive:!0}),t.addEventListener("touchcancel",p,{passive:!0}),t.addEventListener("mousedown",m,{passive:!0}),t._cleanupSwipe=()=>{t._swipeTimeout&&(clearTimeout(t._swipeTimeout),t._swipeTimeout=null),t._snapbackTimer&&(clearTimeout(t._snapbackTimer),t._snapbackTimer=null),c(),t.removeEventListener("touchstart",m),t.removeEventListener("touchmove",f),t.removeEventListener("touchend",p),t.removeEventListener("touchcancel",p),t.removeEventListener("mousedown",m)}}function attachFocusTrap(t){if(!t||typeof t.querySelectorAll!="function")return null;const e=typeof document<"u"&&document.activeElement&&document.activeElement!==document.body?document.activeElement:null,i=()=>Array.from(t.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(l=>{try{if(typeof l.offsetWidth=="number"&&typeof l.offsetHeight=="number"){const o=typeof window<"u"&&window.getComputedStyle?window.getComputedStyle(l):null;if(o&&(o.display==="none"||o.visibility==="hidden"))return!1;if(typeof document<"u"&&document.body&&(document.body.offsetWidth>0||document.body.offsetHeight>0)&&l.offsetWidth===0&&l.offsetHeight===0)return l===document.activeElement}return!0}catch{return!0}}),r=l=>{if(l.defaultPrevented||l.key!=="Tab"||!t.isConnected)return;const o=i();if(o.length===0)return;const u=o[0],a=o[o.length-1];l.shiftKey?(document.activeElement===u||!t.contains(document.activeElement))&&(a.focus(),l.preventDefault()):(document.activeElement===a||!t.contains(document.activeElement))&&(u.focus(),l.preventDefault())};t.addEventListener("keydown",r),typeof document<"u"&&document.addEventListener("keydown",r);const s=setTimeout(()=>{const l=i();l.length>0&&typeof l[0].focus=="function"&&l[0].focus()},30);typeof(s==null?void 0:s.unref)=="function"&&s.unref();const n=()=>{if(clearTimeout(s),t.removeEventListener("keydown",r),typeof document<"u"&&document.removeEventListener("keydown",r),e&&typeof e.focus=="function"&&e.isConnected)try{e.focus()}catch{}};return t._cleanupFocusTrap=n,n}const svgNS="http://www.w3.org/2000/svg",ALLOWED_SVG_TAGS=new Set(["svg","g","path","circle","rect","line","polyline","polygon","ellipse","title","desc","defs","clippath","use"]),ALLOWED_SVG_ATTRS=new Set(["viewbox","width","height","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","opacity","fill-opacity","stroke-opacity","d","cx","cy","r","x","y","x1","y1","x2","y2","points","rx","ry","transform","role","aria-hidden","focusable","xmlns","preserveaspectratio","class","id","href","xlink:href"]);function isUnsafeUrl(t=""){return/^\s*javascript:/i.test(t)}function sanitizeInlineSvg(t){const e=typeof DOMParser<"u"?DOMParser:typeof window<"u"&&window.DOMParser?window.DOMParser:null;if(!e)return null;try{const r=new e().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return null;const s=r.documentElement;if(!s||s.tagName.toLowerCase()!=="svg")return null;const n=l=>{if(l.nodeType===3)return document.createTextNode(l.textContent||"");if(l.nodeType!==1)return null;const o=l.tagName.toLowerCase();if(!ALLOWED_SVG_TAGS.has(o))return null;const u=document.createElementNS(svgNS,o);if(l.attributes)for(let a=0;a<l.attributes.length;a++){const c=l.attributes[a],m=c.name,f=m.toLowerCase(),p=c.value||"";f.startsWith("on")||ALLOWED_SVG_ATTRS.has(f)&&((f==="href"||f==="xlink:href")&&(isUnsafeUrl(p)||o==="use"&&p&&!p.startsWith("#"))||u.setAttribute(m,p))}if(l.childNodes)for(let a=0;a<l.childNodes.length;a++){const c=n(l.childNodes[a]);c&&u.appendChild(c)}return u};return n(s)}catch{return null}}const ICON_SVGS={success:`
|
|
32
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
33
|
+
<path d="M20 6L9 17l-5-5"/>
|
|
34
|
+
</svg>
|
|
35
|
+
`,error:`
|
|
36
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
37
|
+
<circle cx="12" cy="12" r="10"/>
|
|
38
|
+
<line x1="15" y1="9" x2="9" y2="15"/>
|
|
39
|
+
<line x1="9" y1="9" x2="15" y2="15"/>
|
|
40
|
+
</svg>
|
|
41
|
+
`,warning:`
|
|
42
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
43
|
+
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
|
|
44
|
+
<line x1="12" y1="9" x2="12" y2="13"/>
|
|
45
|
+
<line x1="12" y1="17" x2="12.01" y2="17"/>
|
|
46
|
+
</svg>
|
|
47
|
+
`,info:`
|
|
48
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
49
|
+
<circle cx="12" cy="12" r="10"/>
|
|
50
|
+
<line x1="12" y1="16" x2="12" y2="12"/>
|
|
51
|
+
<line x1="12" y1="8" x2="12.01" y2="8"/>
|
|
52
|
+
</svg>
|
|
53
|
+
`};function createToastIcon(t={}){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};let i=e.icon;if(i===void 0){const u=getConfig().icon;u!==void 0&&(i=u)}if(typeof i=="function")try{i=i(e)}catch(u){console.warn("options.icon callback error:",u),i=null}if(i===!1||i===""||i===null||typeof document>"u")return null;const r=e.type,s=getConfig(),n=document.createElement("i");n.className="toast-icon",n.setAttribute("aria-hidden","true");const l=e.fontDirection==="rtl";if(s.disableInlineStyles||Object.assign(n.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:"0",marginLeft:l?"8px":"0px",marginRight:l?"0px":"8px",lineHeight:"1",fontStyle:"normal"}),i&&typeof i=="object"&&(i.nodeType===1||i.nodeType===11||typeof HTMLElement<"u"&&i instanceof HTMLElement)&&typeof i.cloneNode=="function")return n.appendChild(i.cloneNode(!0)),n;if(typeof i=="string"&&i.trim()){const u=i.trim(),c={check:ICON_SVGS.success,checkmark:ICON_SVGS.success,success:ICON_SVGS.success,cross:ICON_SVGS.error,error:ICON_SVGS.error,alert:ICON_SVGS.warning,warning:ICON_SVGS.warning,circle:ICON_SVGS.info,info:ICON_SVGS.info}[u.toLowerCase()];if(c){const m=sanitizeInlineSvg(c.trim());return m&&n.appendChild(m),n}if(u.startsWith("<svg")&&u.endsWith("</svg>")){const m=sanitizeInlineSvg(u);m?(m.setAttribute("aria-hidden","true"),m.setAttribute("focusable","false"),m.getAttribute("width")||m.setAttribute("width","18"),m.getAttribute("height")||m.setAttribute("height","18"),n.appendChild(m)):n.textContent=u}else n.textContent=u;return n}const o=typeof r=="string"?r.toLowerCase().trim():"";if((i===!0||i===void 0)&&o&&ICON_SVGS[o]){const u=sanitizeInlineSvg(ICON_SVGS[o].trim());return u&&n.appendChild(u),n}return null}function getInitialTransform(t,e,i){const r=String(t||"").toLowerCase(),s=r.includes("top"),n=r.includes("left"),l=r.includes("right"),o=String(e||"").toLowerCase().trim();return o==="fade"?"none":o==="pop"?"scale(0.6)":o==="zoom"||o==="scale"?"scale(0.75)":o==="flip"?"perspective(600px) rotateX(45deg)":o==="slide"?n?"translateX(-100%)":l?"translateX(100%)":s?"translateY(-100%)":"translateY(100%)":i?r.includes("center")&&!s&&!r.includes("bottom")?n?"translateX(-36px) scale(0.92)":l?"translateX(36px) scale(0.92)":"scale(0.85)":s?"translateY(-36px) scale(0.92)":"translateY(36px) scale(0.92)":o==="bounce"?s?"translateY(-36px) scale(0.9)":"translateY(36px) scale(0.9)":s?"translateY(-20px)":"translateY(20px)"}async function applyRichStyling(t,e,i){const r=getConfig(),s=String((e==null?void 0:e.animationType)||"").toLowerCase().trim(),n=!!(e!=null&&e.spring)||s==="spring",l=n?400:await parseAnimationDuration(e==null?void 0:e.animationDuration),o=`${l}ms`,u=n?"cubic-bezier(0.34, 1.56, 0.64, 1)":typeof(e==null?void 0:e.animationEasing)=="string"&&e.animationEasing.trim()?e.animationEasing.trim():"ease";t._animationType=e==null?void 0:e.animationType;const a=typeof(e==null?void 0:e.className)=="string"&&e.className.trim()?` ${e.className.trim()}`:"",c=s?` toast-anim-${s}`:"";t.className=`toast toast-${(e==null?void 0:e.type)??"info"}${c}${a}`;const m=(e==null?void 0:e.theme)||r.theme;m&&t.setAttribute("data-toast-theme",String(m).toLowerCase());const f=typeof(e==null?void 0:e.borderRadius)=="number"?`${e.borderRadius}px`:e==null?void 0:e.borderRadius,p=typeof(e==null?void 0:e.maxWidth)=="number"?`${e.maxWidth}px`:e==null?void 0:e.maxWidth,y=n?`${Math.min(300,l)}ms`:o,d=n?"ease":u;r.disableInlineStyles||Object.assign(t.style,{background:e==null?void 0:e.backgroundColor,padding:"12px 16px",marginBottom:"10px",borderRadius:f,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:p,opacity:"0",position:"relative",cursor:"default",boxSizing:"border-box",userSelect:"text",pointerEvents:"auto",transition:`opacity ${y} ${d}, transform ${o} ${u}`,transform:getInitialTransform(e==null?void 0:e.position,e==null?void 0:e.animationType,n),zIndex:String(r.zIndex),direction:e!=null&&e.fontDirection&&e.fontDirection!=="auto"?e.fontDirection:void 0});const b=(e==null?void 0:e.type)==="error",_=(e==null?void 0:e.role)||"alert",v=(e==null?void 0:e.ariaLive)||(b?"assertive":"polite");t.setAttribute("role",_),t.setAttribute("aria-live",v),t.tabIndex=0,t._animationDuration=l;const w=document.createElement("span");w.className="toast-message",t._messageSpan=w,(e==null?void 0:e.wrapText)==="truncate"||(e==null?void 0:e.wrapText)==="ellipsis"||(e==null?void 0:e.wrapText)===!1||!(e!=null&&e.wrapText)?(w.classList.add("is-truncated"),r.disableInlineStyles||Object.assign(w.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"normal",overflow:"hidden",textOverflow:"ellipsis"})):r.disableInlineStyles||Object.assign(w.style,{display:"block",whiteSpace:"normal"});const M=typeof(e==null?void 0:e.fontSize)=="number"?`${e.fontSize}px`:e==null?void 0:e.fontSize;r.disableInlineStyles||Object.assign(w.style,{flex:"1",padding:e==null?void 0:e.fontPadding,fontFamily:e==null?void 0:e.fontFamily,fontSize:M,fontWeight:e==null?void 0:e.fontWeight,lineHeight:e==null?void 0:e.fontLineHeight,color:e==null?void 0:e.textColor,userSelect:"text",wordBreak:"break-word",overflow:"hidden",textOverflow:"ellipsis",direction:e!=null&&e.fontDirection&&e.fontDirection!=="auto"?e.fontDirection:void 0});const g=!!e.allowHtml,x=e.message??"",C=createToastIcon(e);if(C&&t.appendChild(C),e.loader||e.showLoader){const I=createLoader(e.loader||{});w.appendChild(I);const L=document.createElement("span");L.className="toast-message-spacer",r.disableInlineStyles||(L.style.display="inline-block",L.style.width="8px"),w.appendChild(L)}if(g&&typeof x=="string"&&x.trim().length>0)try{const I=sanitizeHtml(x),L=document.createElement("div");for(L.innerHTML=I;L.firstChild;)w.appendChild(L.firstChild)}catch(I){console.warn("HTML message sanitization failed, falling back to text:",I),w.appendChild(document.createTextNode(String(x)))}else w.appendChild(document.createTextNode(String(x)));if(w.setAttribute("title",w.textContent||""),t.appendChild(w),e!=null&&e.cta&&typeof e.cta=="object"&&createCTA(t,e,i),e!=null&&e.undo&&createUndoAction(t,e,i),e!=null&&e.showCloseButton&&createCloseButton(t,e,i),(e==null?void 0:e.showProgressBar)!==!1&&(e!=null&&e.showProgressBar||(e==null?void 0:e.progress)!==void 0)&&createProgressBar(t,e),((e==null?void 0:e.swipeToDismiss)!==void 0?e.swipeToDismiss:r.swipeToDismiss)!==!1&&attachSwipeToDismiss(t,i),(e==null?void 0:e.sound)!==void 0?e.sound:r.sound){if(typeof(e==null?void 0:e.sound)=="string"&&typeof window<"u"&&typeof window.Audio=="function")try{new window.Audio(e.sound).play().catch(()=>{})}catch{}else if(typeof(e==null?void 0:e.onSound)=="function")try{e.onSound(e)}catch{}}((e==null?void 0:e.trapFocus)??r.trapFocus)&&attachFocusTrap(t)}async function createEmergencyToast(t={},e){try{const i=getConfig(),r=document.createElement("div"),s=(t==null?void 0:t.position)||i.defaultPosition,n=String(s).toLowerCase().trim();let l="auto",o="auto",u="auto",a="auto",c="none";n.startsWith("top")?l="20px":(n.startsWith("bottom")||n.includes("below"))&&(o="20px"),n.startsWith("left")?u="20px":n.startsWith("right")?a="20px":n==="center"?(u="50%",l="50%",c="translate(-50%, -50%)"):n.includes("center")?n.includes("left")?(u="20px",l="50%",c="translateY(-50%)"):n.includes("right")?(a="20px",l="50%",c="translateY(-50%)"):n.includes("top")?(l="20px",u="50%",c="translateX(-50%)"):n.includes("bottom")&&(o="20px",u="50%",c="translateX(-50%)"):(a="20px",o="20px"),r.className="toast-emergency",r.tabIndex=0,r.setAttribute("role","alert"),r.setAttribute("aria-live","assertive"),i.disableInlineStyles||Object.assign(r.style,{background:"#333",color:"white",padding:"10px 15px",position:"fixed",top:l,bottom:o,left:u,right:a,transform:c,zIndex:String(i.zIndex+100),borderRadius:"3px",maxWidth:"250px",wordWrap:"break-word",boxShadow:"0 2px 10px rgba(0,0,0,0.3)"});const m=document.createElement("div"),f=document.createElement("span");if(f.className="toast-emergency-message",i.disableInlineStyles||(f.style.display="inline-block"),t.allowHtml)try{const _=sanitizeHtml(String(t.message||"Emergency Toast Showing!")),v=document.createElement("div");for(v.innerHTML=_;v.firstChild;)f.appendChild(v.firstChild)}catch{f.appendChild(document.createTextNode(String(t.message||"Emergency Toast Showing!")))}else f.textContent=String(t.message||"Emergency Toast Creation Showing!");m.appendChild(f);const p=document.createElement("button");for(p.type="button",p.className="toast-emergency-close",p.setAttribute("aria-label","Close emergency notification"),i.disableInlineStyles||Object.assign(p.style,{float:"right",marginLeft:"10px",fontWeight:"bold",cursor:"pointer",background:"transparent",border:"none",color:"inherit",padding:"0",font:"inherit"}),p.textContent="\xD7",m.appendChild(p);r.firstChild;)r.removeChild(r.firstChild);r.appendChild(m);let y=null;const d=()=>{y&&clearTimeout(y),p.removeEventListener("click",d),r.remove(),typeof e=="function"&&e(r)};p.addEventListener("click",d);const b=Number(t==null?void 0:t.duration)||2500;return y=setTimeout(()=>{p.removeEventListener("click",d),r.remove(),typeof e=="function"&&e(r)},b),typeof(y==null?void 0:y.unref)=="function"&&y.unref(),r}catch(i){return console.error("Emergency toast creation failed:",i),typeof e=="function"&&e(null),null}}async function createToastElement(t,e){let i;const s="toast";try{return i=await createElementWithId("div",s),await applyRichStyling(i,t,e),i}catch(n){return console.warn("toast creation failed with error showing fallback one: ",n),i=await createEmergencyToast(t,e),i}}const containerRegistry=new Map,containerLocks=new Map;function normalizePositionKey(t){if(!t||typeof t!="string")return"bottom-right";const e=t.toLowerCase().trim();if(!e)return"bottom-right";const r=e.replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-");return{"center-top":"top-center","center-bottom":"bottom-center","center-left":"left-center","center-right":"right-center",top:"top-center",bottom:"bottom-center"}[r]||r}function getContainerId(t){return`toast-container-${normalizePositionKey(t)}`}function unregisterContainer(t){if(!t)return;const e=typeof t=="string"&&t.startsWith("toast-container-")?t:getContainerId(t);containerRegistry.delete(e),containerLocks.delete(e)}function getContainerRoot(){return getToastRoot()}function findContainerById(t,e){return t?typeof t.getElementById=="function"?t.getElementById(e):typeof t.querySelector=="function"?t.querySelector(`#${e}`):null:null}function isConnectedToRoot(t,e){return!t||!e?!1:e===document.body?t.isConnected&&t.ownerDocument===document:typeof e.contains=="function"?e.contains(t):t.isConnected&&t.ownerDocument===document}function applyContainerBaseStyles(t){const e=getConfig();t.className="toast-container-base",!e.disableInlineStyles&&(t.style.position="fixed",t.style.zIndex=String(e.zIndex),t.style.pointerEvents="none",t.style.inset="auto 10px 10px auto",t.style.display="flex",t.style.justifyContent="space-between",t.style.alignItems="center",t.style.flexDirection="column",t.style.overflow="visible")}async function getOrCreateToastContainer(t={},e){const i=getConfig(),r=getContainerId((t==null?void 0:t.position)||i.defaultPosition);let s=getContainerRoot();if(!s)throw new Error("Toast container root is unavailable");if(!!((t==null?void 0:t.shadowDom)??i.shadowDom)&&typeof document<"u"&&typeof document.createElement=="function"){let o=null;try{o=s.querySelector?s.querySelector("#toast-shadow-host"):null}catch{}if(o||(o=document.createElement("div"),o.id="toast-shadow-host",o.style.position="fixed",o.style.zIndex=String(i.zIndex||9999),o.style.pointerEvents="none",o.style.inset="0",o.style.overflow="visible",s.appendChild(o)),!o.shadowRoot&&typeof o.attachShadow=="function")try{o.attachShadow({mode:"open"})}catch{}if(o.shadowRoot&&(s=o.shadowRoot,!s.querySelector("style[data-toast-shadow-style]"))){const u=document.createElement("style");u.setAttribute("data-toast-shadow-style","true"),u.textContent=`
|
|
54
|
+
:host { position: fixed; inset: 0; pointer-events: none; z-index: ${i.zIndex||9999}; }
|
|
55
|
+
* { box-sizing: border-box; }
|
|
56
|
+
.toast-container-base {
|
|
57
|
+
position: fixed;
|
|
58
|
+
z-index: ${i.zIndex||9999};
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
align-items: center;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
overflow: visible;
|
|
65
|
+
inset: auto 10px 10px auto;
|
|
66
|
+
contain: layout style;
|
|
67
|
+
}
|
|
68
|
+
[data-stacked="true"] .toast-outer-wrapper {
|
|
69
|
+
transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), margin 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 240ms ease;
|
|
70
|
+
}
|
|
71
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="expanded"] {
|
|
72
|
+
transform: none;
|
|
73
|
+
margin-top: 0px;
|
|
74
|
+
margin-bottom: 10px;
|
|
75
|
+
opacity: 1;
|
|
76
|
+
pointer-events: auto;
|
|
77
|
+
}
|
|
78
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="0"] {
|
|
79
|
+
transform: scale(1);
|
|
80
|
+
margin-top: 0px;
|
|
81
|
+
margin-bottom: 0px;
|
|
82
|
+
opacity: 1;
|
|
83
|
+
z-index: 30;
|
|
84
|
+
pointer-events: auto;
|
|
85
|
+
}
|
|
86
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="1"] {
|
|
87
|
+
transform: scale(0.95) translateY(-10px);
|
|
88
|
+
margin-top: -55px;
|
|
89
|
+
margin-bottom: 0px;
|
|
90
|
+
opacity: 0.9;
|
|
91
|
+
z-index: 20;
|
|
92
|
+
pointer-events: auto;
|
|
93
|
+
}
|
|
94
|
+
[data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="1"] {
|
|
95
|
+
transform: scale(0.95) translateY(10px);
|
|
96
|
+
margin-top: 0px;
|
|
97
|
+
margin-bottom: -55px;
|
|
98
|
+
}
|
|
99
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="2"] {
|
|
100
|
+
transform: scale(0.90) translateY(-20px);
|
|
101
|
+
margin-top: -55px;
|
|
102
|
+
margin-bottom: 0px;
|
|
103
|
+
opacity: 0.75;
|
|
104
|
+
z-index: 10;
|
|
105
|
+
pointer-events: auto;
|
|
106
|
+
}
|
|
107
|
+
[data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="2"] {
|
|
108
|
+
transform: scale(0.90) translateY(20px);
|
|
109
|
+
margin-top: 0px;
|
|
110
|
+
margin-bottom: -55px;
|
|
111
|
+
}
|
|
112
|
+
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="overflow"] {
|
|
113
|
+
transform: scale(0.85) translateY(-30px);
|
|
114
|
+
margin-top: -55px;
|
|
115
|
+
margin-bottom: 0px;
|
|
116
|
+
opacity: 0;
|
|
117
|
+
z-index: 1;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
}
|
|
120
|
+
[data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="overflow"] {
|
|
121
|
+
transform: scale(0.85) translateY(30px);
|
|
122
|
+
margin-top: 0px;
|
|
123
|
+
margin-bottom: -55px;
|
|
124
|
+
}
|
|
125
|
+
`,s.appendChild(u)}}if(containerLocks.has(r))return containerLocks.get(r);const l=(async()=>{const o=containerRegistry.get(r);if(isConnectedToRoot(o,s))return o;o&&containerRegistry.delete(r);let u=findContainerById(s,r);if(u)applyContainerBaseStyles(u),typeof e=="function"&&await e(u,t);else{const a=(s==null?void 0:s.ownerDocument)||(typeof document<"u"?document:null);if(!a)throw new Error("Document is unavailable");u=a.createElement("div"),u.id=r,u.setAttribute("role","status"),u.setAttribute("aria-atomic","true"),applyContainerBaseStyles(u),typeof e=="function"&&await e(u,t),s.appendChild(u)}if(typeof s.querySelectorAll=="function"){const a=s.querySelectorAll(`#${r}`);if(a.length>1)for(let c=1;c<a.length;c++)try{a[c].remove()}catch{}}return containerRegistry.set(r,u),u})();containerLocks.set(r,l);try{return await l}finally{containerLocks.delete(r)}}const DOCUMENTED_POSITIONS=new Set(["top-left","top-right","bottom-left","bottom-right","top-center","bottom-center","center-top","center-bottom","left-center","right-center","center-left","center-right","top-full-width","bottom-full-width","center"]),LEGACY_POSITIONS=new Set(["top","bottom"]),ALL_POSITIONS=[...DOCUMENTED_POSITIONS,...LEGACY_POSITIONS];function isDocumentedPosition(t){return DOCUMENTED_POSITIONS.has(t)}function resetPositionClasses(t){if(t!=null&&t.classList)for(let e=0;e<ALL_POSITIONS.length;e++)t.classList.remove("toast-position-"+ALL_POSITIONS[e])}async function setPosition(t,e={}){var i;if(!t||!e||typeof e!="object")throw new Error("Invalid container or position!");const r=getConfig(),s=String((e==null?void 0:e.position)||r.defaultPosition||"bottom-right").toLowerCase().trim().replace(/\s+/g,"-");let n=s;if(!isDocumentedPosition(s)&&!LEGACY_POSITIONS.has(s)&&(console.warn(`Unknown position "${e.position}", defaulting to "bottom-right"`),n="bottom-right"),resetPositionClasses(t),(i=t.classList)==null||i.add("toast-position-"+n),getConfig().disableInlineStyles)return;resetContainerStyles(t);const l=parsePosition(n);handleFullWidthPositions(t,l)||handleCenterPositions(t,l)||applyStandardPositioning(t,l)}function resetContainerStyles(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",t.style.maxWidth="calc(100vw - 20px)",t.style.boxSizing="border-box"}function parsePosition(t){const e=t.toLowerCase().trim(),i=e==="top-full-width"||e==="bottom-full-width",r=e.startsWith("top")||e.endsWith("top"),s=e.startsWith("bottom")||e.endsWith("bottom")||e.includes("below"),n=e.startsWith("left")||e.endsWith("left"),l=e.startsWith("right")||e.endsWith("right"),o=e.includes("center");return{hasTop:r,hasBottom:s,hasLeft:n,hasRight:l,hasCenter:o,hasFullWidth:i}}function handleFullWidthPositions(t,e){return e.hasFullWidth?(t.style.maxWidth="100vw",e.hasTop?(t.style.top="10px",t.style.left="10px",t.style.right="10px",!0):e.hasBottom?(t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0):!1):!1}function handleCenterPositions(t,e){return e.hasCenter?e.hasTop&&!e.hasLeft&&!e.hasRight?(t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0):e.hasBottom&&!e.hasLeft&&!e.hasRight?(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0):e.hasLeft&&!e.hasTop&&!e.hasBottom?(t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0):e.hasRight&&!e.hasTop&&!e.hasBottom?(t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0):!e.hasLeft&&!e.hasRight&&!e.hasTop&&!e.hasBottom?(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0):!1:!1}function applyStandardPositioning(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop?t.style.top="10px":t.style.bottom="10px",e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.left="50%",t.style.transform="translateX(-50%)")}class PausableTimer{constructor(e,i){this.callback=typeof e=="function"?e:()=>{};const r=i===1/0,s=Number.isFinite(i)&&i>=0?i:r?1/0:0;this.delay=s,this.remaining=s,this.startTime=null,this.timeoutId=null,this.isPaused=!1,this.isCompleted=!1,this.isInfinite=r}start(){var e;return this.isCompleted||this.timeoutId||this.isInfinite?this:(this.isPaused=!1,this.startTime=Date.now(),this.timeoutId=setTimeout(()=>{this.isCompleted=!0,this.timeoutId=null;try{this.callback()}catch(i){console.error("PausableTimer callback error:",i)}},this.remaining),typeof((e=this.timeoutId)==null?void 0:e.unref)=="function"&&this.timeoutId.unref(),this)}pause(){if(this.isPaused||!this.timeoutId||this.isCompleted)return this;clearTimeout(this.timeoutId),this.timeoutId=null;const e=Math.max(0,Date.now()-this.startTime);return this.remaining=Math.min(this.delay,Math.max(0,this.remaining-e)),this.isPaused=!0,this}resume(){return!this.isPaused||this.isCompleted?this:(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 active=new Map,pending=new Map,queue=[];let visibleCount=0,droppedCount=0;function getToastMetrics(){return{activeCount:active.size,queueDepth:queue.length,visibleCount,droppedCount,timestamp:Date.now()}}function emitMetrics(){const t=getConfig();if(typeof t.onMetrics=="function")try{t.onMetrics(getToastMetrics())}catch(e){console.error("onMetrics callback error:",e)}}function getItemPriority(t){var e,i,r,s,n,l;if(typeof((e=t==null?void 0:t.options)==null?void 0:e.priority)=="number"&&Number.isFinite(t.options.priority))return t.options.priority;const o=(i=t==null?void 0:t.priority)==null?void 0:i.score;if(typeof o=="number"&&Number.isFinite(o))return o;const u=getConfig();if(typeof u.priorityScorer=="function")try{const c=u.priorityScorer({type:((r=t==null?void 0:t.options)==null?void 0:r.type)||"info",message:((s=t==null?void 0:t.options)==null?void 0:s.message)||"",duration:(n=t==null?void 0:t.options)==null?void 0:n.duration,options:t==null?void 0:t.options});if(typeof c=="number"&&Number.isFinite(c))return c;if(c&&typeof c.score=="number"&&Number.isFinite(c.score))return c.score}catch(c){console.warn("[Toast] Custom priorityScorer error, falling back to built-in:",c)}return{error:80,warning:60,info:40,success:20}[(l=t==null?void 0:t.options)==null?void 0:l.type]||0}function updateStackedLayout(t){if(!t||!t.children||!(t.getAttribute("data-stacked")==="true"))return;if(!t._stackedInitialized&&typeof t.addEventListener=="function"){t._stackedInitialized=!0;const l=()=>{t._isExpanded=!0,updateStackedLayout(t)},o=()=>{t._isExpanded=!1,updateStackedLayout(t)},u=()=>{t._isExpanded=!0,updateStackedLayout(t)},a=c=>{t.contains(c.relatedTarget)||(t._isExpanded=!1,updateStackedLayout(t))};t.addEventListener("mouseenter",l),t.addEventListener("mouseleave",o),t.addEventListener("focusin",u),t.addEventListener("focusout",a),t._stackedCleanup=()=>{t.removeEventListener("mouseenter",l),t.removeEventListener("mouseleave",o),t.removeEventListener("focusin",u),t.removeEventListener("focusout",a),t._stackedInitialized=!1}}if(!t.children||t.children.length===0)return;const i=Array.from(t.children),r=i.length,s=!!t._isExpanded,n=!!(t.id&&t.id.includes("top"));i.forEach((l,o)=>{const u=r-1-o,a=s?"expanded":u>=3?"overflow":String(u);if(typeof l.setAttribute=="function"&&l.setAttribute("data-stacked-depth",a),!getConfig().disableInlineStyles)if(l.style.transition="transform 240ms cubic-bezier(0.16, 1, 0.3, 1), margin 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 240ms ease",s)l.style.transform="none",l.style.marginTop="0px",l.style.marginBottom="10px",l.style.opacity="1",l.style.zIndex=String(100+o),l.style.pointerEvents="auto";else if(u===0)l.style.transform="scale(1)",l.style.marginTop="0px",l.style.marginBottom="0px",l.style.opacity="1",l.style.zIndex="30",l.style.pointerEvents="auto";else if(u===1){const c=n?10:-10;l.style.transform=`scale(0.95) translateY(${c}px)`,l.style.marginTop=n?"0px":"-55px",l.style.marginBottom=n?"-55px":"0px",l.style.opacity="0.9",l.style.zIndex="20",l.style.pointerEvents="auto"}else if(u===2){const c=n?20:-20;l.style.transform=`scale(0.90) translateY(${c}px)`,l.style.marginTop=n?"0px":"-55px",l.style.marginBottom=n?"-55px":"0px",l.style.opacity="0.75",l.style.zIndex="10",l.style.pointerEvents="auto"}else{const c=n?30:-30;l.style.transform=`scale(0.85) translateY(${c}px)`,l.style.marginTop=n?"0px":"-55px",l.style.marginBottom=n?"-55px":"0px",l.style.opacity="0",l.style.zIndex="1",l.style.pointerEvents="none"}})}function hashString(t){let e=5381;for(let i=0;i<t.length;i++)e=(e<<5)+e+t.charCodeAt(i);return e>>>0}function makeKey(t={}){const e=t&&typeof t=="object"?t:{};if(e.id!==void 0&&e.id!==null&&e.id!=="")return String(e.id);if(e.tag!==void 0&&e.tag!==null&&e.tag!==""){const n=normalizePositionKey(e.position||"bottom-right");return`tag:${String(e.tag).trim()}:${n}`}if(e.groupId!==void 0&&e.groupId!==null&&e.groupId!==""){const n=normalizePositionKey(e.position||"bottom-right");return`group:${String(e.groupId).trim()}:${n}`}const i=String(e.type||"info").trim().toLowerCase(),r=hashString(String(e.message||"")).toString(16),s=normalizePositionKey(e.position||"bottom-right");return`${i}|${r}|${s}`}async function showToast(t={}){var e,i;try{const r=makeKey(t);if(active.has(r)){const n=active.get(r);if(!n)throw new Error(`Active toast with key ${r} not found`);return n.count++,(t.tag||t.groupId)&&t.message&&((e=n.toast)!=null&&e._messageSpan)&&(n.toast._messageSpan.textContent=String(t.message),n.toast._messageSpan.title=String(t.message)),(i=n.timer)==null||i.clear(),n.timer=createDismissTimer(n.toast,t),await setupPauseOnHover(n),await updateBadge(n),emitMetrics(),r}if(pending.has(r)){const n=pending.get(r);if(!n)throw new Error(`Pending toast with key ${r} not found`);return n.count++,(t.tag||t.groupId)&&t.message&&(n.options={...n.options,...t}),r}const s={options:t,count:1,rafId:0};return pending.set(r,s),s.rafId=requestAnimationFrame(async()=>{var n,l;const o=pending.get(r);if(o){if(pending.delete(r),visibleCount>=getConfig().maxVisible){const u={options:o.options,key:r,count:o.count},a=getConfig().maxQueueSize??100;if(a<=0){droppedCount++,emitMetrics();return}const c=queue.find(f=>f.key===r);if(c){c.count+=o.count,typeof((n=o.options)==null?void 0:n.priority)=="number"&&(c.options={...c.options,...o.options},c.priority={score:getItemPriority(c)}),emitMetrics();return}const m=typeof((l=o.options)==null?void 0:l.priority)=="number"||typeof getConfig().priorityScorer=="function"||queue.some(f=>{var p;return typeof((p=f==null?void 0:f.options)==null?void 0:p.priority)=="number"});if(m&&(u.priority={score:getItemPriority(u)}),queue.length>=a){if(m){const f=getItemPriority(u);let p=0,y=getItemPriority(queue[0]);for(let d=1;d<queue.length;d++){const b=getItemPriority(queue[d]);b<y&&(p=d,y=b)}if(f<=y){droppedCount++,emitMetrics();return}queue.splice(p,1)}else queue.shift();droppedCount++}queue.push(u),m&&queue.sort((f,p)=>getItemPriority(p)-getItemPriority(f)),emitMetrics(),await drainQueue();return}try{await createOne(o.options,r,o.count)}catch(u){console.error("showToast failed:",u)}}}),r}catch(r){console.error("showToast failed:",r)}}async function createOne(t,e,i){try{if(!t||typeof t!="object")throw new TypeError("options must be an object");visibleCount++;const r=await getOrCreateToastContainer(t,setPosition);if(!r)throw new Error("Failed to create toast container");const s=await createToastElement(t,closeToast);if(!s)throw new Error("Toast element creation failed");const n=document.createElement("div");n.className="toast-outer-wrapper",getConfig().disableInlineStyles||Object.assign(n.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%",pointerEvents:"auto"});const l=document.createElement("div");l.className="toast-inner-wrapper",getConfig().disableInlineStyles||Object.assign(l.style,{position:"relative",overflow:"hidden",zIndex:"1"}),l.appendChild(s),n.appendChild(l),r.id.includes("toast-container-")&&(r.appendChild(n),t.stacked&&r.setAttribute("data-stacked","true"),r.getAttribute("data-stacked")==="true"&&updateStackedLayout(r)),runToastAnimation(s);const o=t.pauseOnHover!==!1&&(t.pauseOnHover===!0||!!t.cta||!!getConfig().pauseOnHover),u={outer:n,toast:s,options:t,count:Math.max(1,Math.floor(i??0)),pauseOnHover:o};active.set(e,u),s._key=e,emitMetrics(),u.count>1&&await updateBadge(u),u.timer=createDismissTimer(s,t),await setupPauseOnHover(u)}catch(r){console.error("Something went wrong: ",r),visibleCount=Math.max(0,visibleCount-1),emitMetrics(),(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(await createEmergencyToast(t,closeToast))}}async function dismissMostRecent(){try{if(pending.size>0){const[r,s]=Array.from(pending.entries()).at(-1);s!=null&&s.rafId&&cancelAnimationFrame(s.rafId),pending.delete(r),emitMetrics();return}if(active.size===0){if(queue.length>0){queue.pop(),emitMetrics();return}return}let t=null;const e=Array.from(active.values());if(e.length>0){const r=e.at(-1);t=r.toast||r.outer&&r.outer.querySelector('[id^="toast-"]')}if(t||document.querySelectorAll('[id^="toast-container-"]').forEach(s=>{const n=Array.from(s.children||[]);if(n.length===0)return;const l=n.at(-1);l&&(t=l.querySelector('[id^="toast-"]')||l)}),!t)return;const i=t._key?t:t.querySelector('[id^="toast-"]')||t;await closeToast(i)}catch(t){console.error("dismissMostRecent failed:",t)}}async function closeAllToasts(){try{for(const[,e]of pending)e!=null&&e.rafId&&cancelAnimationFrame(e.rafId);pending.clear(),queue.length=0,emitMetrics();const t=Array.from(active.values()).map(e=>e.toast).filter(Boolean);await Promise.allSettled(t.map(async e=>{try{await closeToast(e)}catch(i){console.warn("closeAllToasts: failed to close one toast:",i)}}))}catch(t){console.error("closeAllToasts failed:",t)}}const dismiss=dismissMostRecent,noop=closeAllToasts;function createDismissTimer(t,e){const i=Number(e==null?void 0:e.duration);if((e==null?void 0:e.duration)===1/0||typeof(e==null?void 0:e.duration)=="number"&&(e==null?void 0:e.duration)<=0)return null;const s=(Number.isFinite(i)&&i>0?i:2500)+5,n=new PausableTimer(()=>{closeToast(t).catch(console.error)},s);return n.start(),n}async function setupPauseOnHover(t){var e,i;if(!t.pauseOnHover||!t.outer||!t.timer)return;(i=(e=t.outer)._pauseCleanup)==null||i.call(e);const{outer:r,timer:s,toast:n}=t,l=()=>{if(n!=null&&n._progressAnimation)try{n._progressAnimation.pause()}catch{}else if(n!=null&&n._progressBar)try{if(n._progressBar._isIndeterminate)n._progressBar.style.animationPlayState="paused";else if(!n._progressBar._isManualProgress){const f=window.getComputedStyle(n._progressBar).width;n._progressBar._pausedWidth=f,n._progressBar.style.transition="none",n._progressBar.style.width=f}}catch{}},o=()=>{var f;if(n!=null&&n._progressAnimation)try{n._progressAnimation.play()}catch{}else if(n!=null&&n._progressBar)try{if(n._progressBar._isIndeterminate)n._progressBar.style.animationPlayState="running";else if(!n._progressBar._isManualProgress){if(n._progressBar._pausedWidth){const p=((f=s.getRemainingTime)==null?void 0:f.call(s))??1e3,y=n._progressBar._isReverse,d=n._progressBar._finalWidth||"100%";n._progressBar.style.transition=`width ${Math.max(0,p)}ms linear`,n._progressBar.offsetWidth,n._progressBar.style.width=y?d:"0%",n._progressBar._pausedWidth=null}}}catch{}},u=()=>{var f;s.pause(),l(),(f=n==null?void 0:n._pauseUndo)==null||f.call(n),n==null||n.classList.add("toast-paused")},a=()=>{var f;s.resume(),o(),(f=n==null?void 0:n._resumeUndo)==null||f.call(n),n==null||n.classList.remove("toast-paused")},c=f=>{var p;f!=null&&f.target&&typeof f.target.matches=="function"&&f.target.matches("[tabindex], div, span, button, a")&&(s.pause(),l(),(p=n==null?void 0:n._pauseUndo)==null||p.call(n),n==null||n.classList.add("toast-paused"))},m=f=>{var p;r.contains(f.relatedTarget)||(s.resume(),o(),(p=n==null?void 0:n._resumeUndo)==null||p.call(n),n==null||n.classList.remove("toast-paused"))};r.addEventListener("mouseenter",u),r.addEventListener("mouseleave",a),r.addEventListener("focusin",c),r.addEventListener("focusout",m),r._pauseCleanup=()=>{r.removeEventListener("mouseenter",u),r.removeEventListener("mouseleave",a),r.removeEventListener("focusin",c),r.removeEventListener("focusout",m)}}async function closeToast(t){if(t!=null&&t._key)return closeToastByKey(t._key)}async function closeToastByKey(t){var e,i,r,s,n,l,o,u,a,c,m,f,p,y,d,b,_,v,w,S,M,g,x,C,A,k,I,L,D,N;try{if(!t)return;const h=active.get(t),E=pending.get(t);if(E){cancelAnimationFrame(E.rafId),pending.delete(t),emitMetrics();return}const T=queue.findIndex(H=>H.key===t);if(T!==-1){queue.splice(T,1),emitMetrics();return}if(!h)return;if((e=h.timer)==null||e.clear(),(r=(i=h.outer)==null?void 0:i._pauseCleanup)==null||r.call(i),(n=(s=h.toast)==null?void 0:s._cleanupCloseButton)==null||n.call(s),(o=(l=h.toast)==null?void 0:l._cleanupCTA)==null||o.call(l),(a=(u=h.toast)==null?void 0:u._cleanupUndo)==null||a.call(u),(m=(c=h.toast)==null?void 0:c._cleanupSwipe)==null||m.call(c),(p=(f=h.toast)==null?void 0:f._cleanupFocusTrap)==null||p.call(f),(d=(y=h.toast)==null?void 0:y._cleanup)==null||d.call(y),(b=h.toast)!=null&&b._progressAnimation)try{h.toast._progressAnimation.pause()}catch{}const P=(_=h.outer)==null?void 0:_.querySelector(".toast-count-badge");P!=null&&P._scaleTimer&&(clearTimeout(P._scaleTimer),P._scaleTimer=null);const $=(v=h.toast)==null?void 0:v.querySelector("button, a");(w=$==null?void 0:$._cleanup)==null||w.call($),active.delete(t),visibleCount=Math.max(0,visibleCount-1),emitMetrics(),P&&P.remove();const j=((S=h.toast)==null?void 0:S._animationDuration)??400,z=Math.min(j,300);if(h.toast){if(!getConfig().disableInlineStyles){const H=String(((M=h.options)==null?void 0:M.position)||((x=(g=h.outer)==null?void 0:g.parentElement)==null?void 0:x.id)||"").toLowerCase(),W=H.includes("top"),U=H.includes("left"),Y=H.includes("right"),R=String(((C=h.options)==null?void 0:C.animationType)||"").toLowerCase().trim();let F="translateY(20px)";if(shouldReduceMotion())h.toast.style.transition="none",h.toast.style.opacity="0";else{R==="fade"?F="none":R==="pop"?F="scale(0.6)":R==="zoom"||R==="scale"?F="scale(0.75)":R==="flip"?F="perspective(600px) rotateX(-45deg)":R==="slide"?F=U?"translateX(-100%)":Y?"translateX(100%)":W?"translateY(-100%)":"translateY(100%)":R==="bounce"?F=W?"translateY(-36px) scale(0.9)":"translateY(36px) scale(0.9)":((A=h.options)!=null&&A.spring||R==="spring")&&(F=W?"translateY(-28px) scale(0.94)":"translateY(28px) scale(0.94)");const q=typeof((k=h.options)==null?void 0:k.animationEasing)=="string"&&h.options.animationEasing.trim()?h.options.animationEasing.trim():(I=h.options)!=null&&I.spring||R==="spring"?"cubic-bezier(0.16, 1, 0.3, 1)":"ease-in";h.toast.style.transition=`opacity ${z}ms ${q}, transform ${z}ms ${q}`,h.toast.style.opacity="0",h.toast.style.transform=F}}h.toast.classList.remove("active")}const B=(L=h.outer)==null?void 0:L.parentElement;if(await removeWithTransition(h.outer,h.toast,z),B&&B.children.length===0&&((D=B.id)!=null&&D.startsWith("toast-container-")))try{(N=B._stackedCleanup)==null||N.call(B),unregisterContainer(B.id),B.remove()}catch{}else B&&B.getAttribute("data-stacked")==="true"&&updateStackedLayout(B);await drainQueue()}catch(h){console.error("Closing Toast failed!: ",h)}}let isDraining=!1;async function drainQueue(){var t,e;if(!isDraining){isDraining=!0;try{const i=getConfig();for((i.priorityQueue||typeof i.priorityScorer=="function"||queue.some(r=>{var s,n;return((s=r.options)==null?void 0:s.priorityQueue)||typeof((n=r.options)==null?void 0:n.priority)=="number"}))&&queue.length>1&&queue.sort((r,s)=>getItemPriority(s)-getItemPriority(r));visibleCount<i.maxVisible&&queue.length;){const r=queue.shift();if(active.has(r.key)){const s=active.get(r.key);s.count+=r.count,(r.options.tag||r.options.groupId)&&r.options.message&&((t=s.toast)!=null&&t._messageSpan)&&(s.toast._messageSpan.textContent=String(r.options.message),s.toast._messageSpan.title=String(r.options.message),(e=s.timer)==null||e.clear(),s.timer=createDismissTimer(s.toast,r.options)),await updateBadge(s),emitMetrics();continue}await createOne(r.options,r.key,r.count)}emitMetrics()}finally{isDraining=!1}}}async function removeWithTransition(t,e,i=400){return t?new Promise(r=>{let s=!1,n=null;const l=e||t.firstElementChild||t,o=()=>{var c;if(!s){s=!0,n&&(clearTimeout(n),n=null);try{(c=l==null?void 0:l.removeEventListener)==null||c.call(l,"transitionend",u,!0)}catch{}removeElement(t).catch(console.error),r()}};if(shouldReduceMotion()||i<=0){o();return}const u=c=>{try{if(c.target!==l)return;(c.propertyName==="transform"||(!l.style.transform||l.style.transform==="none"||l.style.transform==="initial")&&c.propertyName==="opacity")&&o()}catch(m){console.error("removeWithTransition error:",m)}};if(!l)return o();try{l.addEventListener("transitionend",u,!0)}catch(c){console.error("removeWithTransition error:",c)}const a=i+100;n=setTimeout(o,a),typeof(n==null?void 0:n.unref)=="function"&&n.unref()}):Promise.resolve()}async function updateBadge({outer:t,count:e}){var i;if(!t||!(t instanceof HTMLElement))throw new Error("updateBadge: outer must be a valid HTMLElement");if(e<2){const s=t.querySelector(".toast-count-badge");s&&s.remove();return}let r=t.querySelector(".toast-count-badge");r||(r=document.createElement("span"),r.className="toast-count-badge",r.setAttribute("aria-label",`${e} identical notifications`),getConfig().disableInlineStyles||Object.assign(r.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"}),t.appendChild(r)),r.textContent=e>99?"99+":String(e);try{shouldReduceMotion()||(r._scaleTimer&&clearTimeout(r._scaleTimer),r.style.transform="scale(1.2)",r._scaleTimer=setTimeout(()=>{r.style.transform="scale(1)",r._scaleTimer=null},150),typeof((i=r._scaleTimer)==null?void 0:i.unref)=="function"&&r._scaleTimer.unref())}catch(s){console.error("updateBadge animation error:",s)}}async function updateToastByKey(t,e={}){var i,r,s,n;if(!t||typeof e!="object"||e===null)return;if(pending.has(t)){const d=pending.get(t);d.options={...d.options,...e};return}const l=queue.find(d=>d.key===t);if(l){l.options={...l.options,...e};return}const o=active.get(t);if(!o||!o.toast)return;const u={...o.options};o.options={...o.options,...e};const a=o.toast,c=a._messageSpan||a.querySelector(".toast-message")||a.querySelector("span:not(.toast-count-badge)");if(e.message!==void 0){const d=String(e.message??""),b=e.allowHtml!==void 0?!!e.allowHtml:!!o.options.allowHtml,_=(e.type==="success"||e.type==="error"||e.type==="warning"||e.type==="info")&&e.showLoader!==!0;if(c){const v=c.querySelector(".toast-loader");if(c.innerHTML="",v&&e.showLoader!==!1&&e.loader!==null&&!_){c.appendChild(v);const w=document.createElement("span");w.style.display="inline-block",w.style.width="8px",c.appendChild(w)}if(b&&d.trim().length>0)try{const w=sanitizeHtml(d),S=document.createElement("div");for(S.innerHTML=w;S.firstChild;)c.appendChild(S.firstChild)}catch{c.appendChild(document.createTextNode(d))}else c.appendChild(document.createTextNode(d));c.setAttribute("title",c.textContent||"")}}const m=(e.type==="success"||e.type==="error"||e.type==="warning"||e.type==="info")&&e.showLoader!==!0;if(e.showLoader===!1||e.loader===null||m){const d=c==null?void 0:c.querySelector(".toast-loader");d&&(d.nextSibling&&d.nextSibling.nodeName==="SPAN"&&d.nextSibling.remove(),d.remove())}else if((e.showLoader===!0||e.loader&&typeof e.loader=="object")&&c&&!c.querySelector(".toast-loader")){const d=createLoader(e.loader||{});c.insertBefore(d,c.firstChild);const b=document.createElement("span");b.style.display="inline-block",b.style.width="8px",c.insertBefore(b,d.nextSibling)}if(e.type){const d=String(e.type).toLowerCase().trim();a.className=a.className.replace(/\btoast-(info|success|error|warning)\b/g,`toast-${d}`);const b=d==="error";if(e.role?a.setAttribute("role",e.role):a.setAttribute("role","alert"),a.setAttribute("aria-live",e.ariaLive||(b?"assertive":"polite")),!e.backgroundColor){const _={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"};_[d]&&(a.style.background=_[d],a.style.backgroundColor=_[d])}}if(e.icon!==void 0||e.type!==void 0){const d=a==null?void 0:a.querySelector(".toast-icon");d&&d.remove();const b={...o.options,...e},_=createToastIcon(b);_&&(c?a.insertBefore(_,c):a.appendChild(_))}if(e.backgroundColor&&(a.style.background=e.backgroundColor,a.style.backgroundColor=e.backgroundColor),e.textColor)a.style.color=e.textColor,c&&(c.style.color=e.textColor);else if(e.type||e.backgroundColor){const d=a.style.backgroundColor||a.style.background;if(d){const b=getDynamicAccessibleTextColorHex(d);a.style.color=b,c&&(c.style.color=b)}}if(e.borderRadius!==void 0){const d=typeof e.borderRadius=="number"?`${e.borderRadius}px`:e.borderRadius;a.style.borderRadius=d}if(e.maxWidth!==void 0){const d=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth;a.style.maxWidth=d}if(e.fontDirection!==void 0){const d=e.fontDirection!=="auto"?e.fontDirection:"";a.style.direction=d,c&&(c.style.direction=d);const b=d==="rtl";a.querySelectorAll(".toast-cta, .toast-undo-btn, .toast-close-btn").forEach(_=>{_.style.marginLeft=b?"0px":"10px",_.style.marginRight=b?"10px":"0px"})}if(e.fontSize!==void 0){const d=typeof e.fontSize=="number"?`${e.fontSize}px`:e.fontSize;a.style.fontSize=d,c&&(c.style.fontSize=d)}if(e.fontFamily!==void 0&&(a.style.fontFamily=e.fontFamily,c&&(c.style.fontFamily=e.fontFamily)),e.fontWeight!==void 0){const d=typeof e.fontWeight=="number"?String(e.fontWeight):e.fontWeight;a.style.fontWeight=d,c&&(c.style.fontWeight=d)}if(e.fontLineHeight!==void 0&&(a.style.lineHeight=e.fontLineHeight,c&&(c.style.lineHeight=e.fontLineHeight)),e.fontPadding!==void 0&&c&&(c.style.padding=e.fontPadding),e.wrapText!==void 0&&c&&(e.wrapText==="truncate"||e.wrapText==="ellipsis"||e.wrapText===!1||!e.wrapText?(c.classList.add("is-truncated"),getConfig().disableInlineStyles||Object.assign(c.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"normal",overflow:"hidden",textOverflow:"ellipsis"})):(c.classList.remove("is-truncated"),getConfig().disableInlineStyles||Object.assign(c.style,{display:"block",WebkitBoxOrient:"",WebkitLineClamp:"",whiteSpace:"normal",overflow:"visible",textOverflow:"clip"}))),e.role!==void 0&&a.setAttribute("role",e.role),e.ariaLive!==void 0&&a.setAttribute("aria-live",e.ariaLive),e.className!==void 0){const d=u.className;d&&typeof d=="string"&&a.classList.remove(...d.trim().split(/\s+/)),e.className&&typeof e.className=="string"&&a.classList.add(...e.className.trim().split(/\s+/))}let f=a.querySelector(".toast-progress-bar");if(e.showProgressBar===!1){if(a._progressAnimation){try{a._progressAnimation.cancel()}catch{}a._progressAnimation=null}f&&f.remove(),a._progressBar=null,f=null}else!f&&e.showProgressBar!==!1&&(e.progress!==void 0||e.showProgressBar===!0||e.duration&&Number(e.duration)>0||o.options.duration&&Number(o.options.duration)>0)&&(createProgressBar(a,{...o.options,...e,showProgressBar:!0}),f=a.querySelector(".toast-progress-bar"));if(f){if(e.progress!==void 0)if(e.progress==="indeterminate"){if(f._isIndeterminate=!0,f._isManualProgress=!1,a._progressAnimation){try{a._progressAnimation.cancel()}catch{}a._progressAnimation=null}f.classList.add("toast-progress-bar-indeterminate");const d=f._isRtl||e.fontDirection==="rtl"||e.progressDirection==="rtl";if(d&&f.classList.add("toast-progress-bar-indeterminate-rtl"),!getConfig().disableInlineStyles){ensureProgressIndeterminateStyles();const b=d?"toast-progress-indeterminate-rtl":"toast-progress-indeterminate";f.style.animation=`${b} 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite`}f.style.width=f._finalWidth||"100%"}else{const d=parseProgressValue(e.progress,a,{...o.options,...e});f._isIndeterminate=!1,f._isManualProgress=!0,f.classList.remove("toast-progress-bar-indeterminate"),f.classList.remove("toast-progress-bar-indeterminate-rtl"),f.style.animation="none";const b=typeof window<"u"&&window.getComputedStyle?window.getComputedStyle(f).width:null;if(a._progressAnimation){try{a._progressAnimation.cancel()}catch{}a._progressAnimation=null}b&&(f.style.transition="none",f.style.width=b,f.offsetWidth),f.style.transition="width 200ms ease",f.style.width=`${d}%`}if((e.progressBarColor||e.progressColor)&&(f.style.background=e.progressBarColor||e.progressColor),e.progressPosition&&(f.style.top=e.progressPosition==="top"?"0":"auto",f.style.bottom=e.progressPosition==="bottom"?"0":"auto"),e.progressHeight!==void 0){const d=typeof e.progressHeight=="number"?`${e.progressHeight}px`:e.progressHeight;f.style.height=d}}if(e.animationType!==void 0&&(o.options.animationType=e.animationType,a._animationType=e.animationType),e.spring!==void 0&&(o.options.spring=e.spring),e.swipeToDismiss!==void 0&&(o.options.swipeToDismiss=e.swipeToDismiss,e.swipeToDismiss===!1?((i=a._cleanupSwipe)==null||i.call(a),a._cleanupSwipe=null):e.swipeToDismiss===!0&&!a._cleanupSwipe&&attachSwipeToDismiss(a,closeToast)),e.duration!==void 0){(r=o.timer)==null||r.clear();const d=Number(e.duration);if(Number.isFinite(d)&&d>0){if(o.timer=createDismissTimer(a,{duration:d}),await setupPauseOnHover(o),f&&(e.progress===void 0&&(f._isManualProgress=!1),!f._isManualProgress&&!f._isIndeterminate)){const b=d+5;if(a._progressAnimation){try{a._progressAnimation.cancel()}catch{}const _=f._isReverse,v=f._finalWidth||"100%",w=_?[{width:"0%"},{width:v}]:[{width:v},{width:"0%"}];a._progressAnimation=f.animate(w,{duration:b,easing:"linear",fill:"forwards",delay:0})}else{f.style.transition=`width ${b}ms linear`;const _=f._isReverse,v=f._finalWidth||"100%";f.style.width=_?v:"0%"}}if(a.classList.contains("toast-paused")&&(o.timer.pause(),a._progressAnimation))try{a._progressAnimation.pause()}catch{}}else if(o.timer=null,f&&!f._isManualProgress&&!f._isIndeterminate){if(a._progressAnimation){try{a._progressAnimation.cancel()}catch{}a._progressAnimation=null}f.style.width="0%"}}else(o.options.duration===0||!o.timer)&&(e.type==="success"||e.type==="error"||e.type==="warning"||e.showLoader===!1)&&(o.options.duration=2500,(s=o.timer)==null||s.clear(),o.timer=createDismissTimer(a,{duration:2500}),await setupPauseOnHover(o));if(e.cta!==void 0&&(a._cleanupCTA&&(a._cleanupCTA(),a._cleanupCTA=null),a.querySelectorAll(".toast-cta").forEach(d=>d.remove()),e.cta&&typeof e.cta=="object")){const d={...o.options,...e};createCTA(a,d,closeToast)}if(e.undo!==void 0&&(a._cleanupUndo&&(a._cleanupUndo(),a._cleanupUndo=null),a.querySelectorAll(".toast-undo-btn").forEach(d=>d.remove()),e.undo)){const d={...o.options,...e};createUndoAction(a,d,closeToast)}if(e.showCloseButton!==void 0){const d=a.querySelector(".toast-close-btn");if(e.showCloseButton===!1)a._cleanupCloseButton&&(a._cleanupCloseButton(),a._cleanupCloseButton=null),d&&d.remove();else if(e.showCloseButton===!0&&!d){const b={...o.options,...e};createCloseButton(a,b,closeToast)}}if(e.sound!==void 0?!!e.sound:!!(e.type&&(o.options.sound||getConfig().sound))){if(typeof e.sound=="string"&&typeof window<"u"&&typeof window.Audio=="function")try{new window.Audio(e.sound).play().catch(()=>{})}catch{}else if(typeof e.onSound=="function")try{e.onSound(e)}catch{}}const y=a.closest('[id^="toast-container-"]');y&&(e.stacked===!0?(y.setAttribute("data-stacked","true"),updateStackedLayout(y)):e.stacked===!1?(y.removeAttribute("data-stacked"),(n=y._stackedCleanup)==null||n.call(y),Array.from(y.children).forEach(d=>{d.removeAttribute("data-stacked-depth"),d.style.transform="",d.style.marginTop="",d.style.marginBottom="10px",d.style.opacity="",d.style.zIndex="",d.style.pointerEvents="auto"})):y.getAttribute("data-stacked")==="true"&&updateStackedLayout(y))}let defaultColors={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"};const DEFAULT_TYPE_MESSAGES={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!",loading:"Loading, please wait..."};let customDefaultMessages={},domReady=!1,domReadyPromise=null;async function checkDOMReady(){if(!domReady&&!(typeof window>"u"||typeof document>"u")){if(document.readyState==="complete"||document.readyState==="interactive"){domReady=!0;return}domReadyPromise||(domReadyPromise=new Promise(t=>{document.addEventListener("DOMContentLoaded",()=>{domReady=!0,t()},{once:!0})})),await domReadyPromise}}async function createToastNow(t={}){try{const e=await sanitizeToastOptions(t);return await createFirstToastContainer(e),await showToast(e)}catch(e){return console.error("CreateToast failed:",e),null}}async function createToast(t={}){return typeof window<"u"&&typeof document<"u"?(await checkDOMReady(),await createToastNow(t)):(console.warn("ToastNotification: running in non-browser environment, no DOM available."),null)}async function createFirstToastContainer(t){try{return await getOrCreateToastContainer(t,setPosition)}catch(e){return console.error("Failed to create toast container:",e),getConfig().targetNode||document.body}}function normalizeToastOptions(t,e){const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{...i,message:String(t)}:t instanceof Error?{...i,message:t.message||String(t)}:typeof t=="object"&&t!==null&&!Array.isArray(t)?{...i,...t}:{...i}}async function sanitizeToastOptions(t){var e;const i=normalizeToastOptions(t),r=getConfig(),s=String((i==null?void 0:i.position)??r.defaultPosition).toLowerCase().trim(),n=s!=null&&s.includes("top-full-width")||s!=null&&s.includes("bottom-full-width")?"100vw":"400px",o={...{allowHtml:!1,sanitizeHtml:!0,pauseOnHover:void 0,duration:2500,position:r.defaultPosition,type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressBarColor:void 0,progressHeight:"4px",progressPosition:"bottom",progressDirection:"decreasing",animationType:"default",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:n},...i};o.message=(i==null?void 0:i.message)??o.message;try{if(!o.backgroundColor){const u=typeof window<"u"&&typeof window.matchMedia=="function"&&((e=window.matchMedia("(prefers-color-scheme: dark)"))==null?void 0:e.matches);o.backgroundColor=(defaultColors==null?void 0:defaultColors[o.type])??(u?"#f5f5f5":"#111111")}}catch(u){console.warn("Background color resolution failed:",u),o.backgroundColor||(o.backgroundColor="#111111")}try{o.message=o.message||customDefaultMessages[o.type]||DEFAULT_TYPE_MESSAGES[o.type]||"No Message Provided!"}catch(u){console.warn("Default message resolution failed:",u)}try{!o.textColor&&o.backgroundColor&&(o.textColor=getDynamicAccessibleTextColorHex(o.backgroundColor))}catch(u){console.warn("Text color resolution failed:",u)}try{const u=(i==null?void 0:i.progressBarColor)||(i==null?void 0:i.progressColor);u?(o.progressColor=u,o.progressBarColor=u):!o.progressColor&&o.backgroundColor&&(o.progressColor=o.textColor||getDynamicAccessibleTextColorHex(o.backgroundColor),o.progressBarColor=o.progressColor)}catch(u){console.warn("Progress bar color resolution failed:",u)}return typeof o.message!="string"&&(o.message="No Message Provided!"),o}function setDefaultColors(t){try{if(t&&typeof t=="object"&&!Array.isArray(t)){const e=["success","error","warning","info"],i={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(i[r]=s.trim());Object.keys(i).length>0&&(defaultColors={...defaultColors,...i})}}catch(e){console.error("setDefaultColors failed:",e)}}function setDefaultMessages(t){try{if(t&&typeof t=="object"&&!Array.isArray(t)){const e=["success","error","warning","info"],i={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(i[r]=s.trim());Object.keys(i).length>0&&(customDefaultMessages={...customDefaultMessages,...i})}}catch(e){console.error("setDefaultMessages failed:",e)}}let closeInProgress=!1,closePromise=null;async function runWithClosePriority(t){if(closeInProgress&&closePromise)try{await closePromise}catch(e){console.warn("Previous close operation failed (continuing anyway):",e)}return t()}const originalCreateToast=createToast;async function createToastWithPriority(t={},e){const i=normalizeToastOptions(t,e),r=await runWithClosePriority(()=>originalCreateToast(i));return{id:r,dismiss:()=>r?closeToastByKey(r):Promise.resolve(),update:s=>r?updateToastByKey(r,s):Promise.resolve()}}createToastWithPriority.success=(t,e)=>{const i=normalizeToastOptions(t,e);return createToastWithPriority({...i,type:"success"})},createToastWithPriority.error=(t,e)=>{const i=normalizeToastOptions(t,e);return createToastWithPriority({...i,type:"error"})},createToastWithPriority.warning=(t,e)=>{const i=normalizeToastOptions(t,e);return createToastWithPriority({...i,type:"warning"})},createToastWithPriority.info=(t,e)=>{const i=normalizeToastOptions(t,e);return createToastWithPriority({...i,type:"info"})},createToastWithPriority.loading=(t,e)=>{const i=normalizeToastOptions(t,e);return createToastWithPriority({type:"info",showLoader:!0,duration:0,showProgressBar:!1,pauseOnHover:!1,...i})},createToastWithPriority.custom=(t,e)=>{const i=normalizeToastOptions(t,e);return createToastWithPriority({allowHtml:!0,...i})};const success=createToastWithPriority.success,error=createToastWithPriority.error,warning=createToastWithPriority.warning,info=createToastWithPriority.info,loading=createToastWithPriority.loading,custom=createToastWithPriority.custom,dismissToast=async t=>{let e=t;if(t&&typeof t.then=="function")try{e=await t}catch{return}closeInProgress=!0,closePromise=(async()=>{try{typeof e=="string"&&e.length>0?await closeToastByKey(e):e&&typeof e=="object"?typeof e.dismiss=="function"?await e.dismiss():e._key&&typeof e._key=="string"?await closeToastByKey(e._key):e.id&&typeof e.id=="string"?await closeToastByKey(e.id):await dismiss():await dismiss()}finally{closeInProgress=!1,closePromise=null}})(),await closePromise},noopAll=async()=>{closeInProgress=!0,closePromise=(async()=>{try{await noop()}finally{closeInProgress=!1,closePromise=null}})(),await closePromise},clear=noopAll,dismissAll=noopAll,TOAST_PROMISE_LOADING_DURATION_MS=1440*60*1e3;async function toastPromise(t,e={},i={}){const r=e&&typeof e=="object"?e:{},s=i&&typeof i=="object"?i:{},n=r.loading??"Loading...",l=typeof n=="object"&&n!==null&&!Array.isArray(n)?{...s,type:"info",duration:TOAST_PROMISE_LOADING_DURATION_MS,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0,...n}:{...s,type:"info",message:String(n),duration:TOAST_PROMISE_LOADING_DURATION_MS,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0},o=await createToastWithPriority(l),u={...s,pauseOnHover:s.pauseOnHover};try{const c=await(typeof t=="function"?t():t),m=typeof r.success=="function"?r.success(c):r.success??"Done!",f=typeof m=="object"&&m!==null&&!Array.isArray(m)?{...u,type:"success",showLoader:!1,...m}:{...u,type:"success",showLoader:!1,message:String(m)};return o&&typeof o.update=="function"&&await o.update(f),c}catch(a){const c=typeof r.error=="function"?r.error(a):r.error??"Something went wrong.",m=typeof c=="object"&&c!==null&&!Array.isArray(c)?{...u,type:"error",showLoader:!1,...c}:{...u,type:"error",showLoader:!1,message:String(c)};throw o&&typeof o.update=="function"&&await o.update(m),a}}createToastWithPriority.promise=toastPromise,createToastWithPriority.dismiss=dismissToast,createToastWithPriority.dismissAll=noopAll,createToastWithPriority.clear=noopAll;const version="4.0.1";function initKeyboardShortcuts(t=typeof window<"u"?window:null){if(!t||!t.document||t.__customizableToastEscapeAttached)return;t.__customizableToastEscapeAttached=!0;const e=i=>{if(i.key==="Escape"||i.key==="Esc")(async()=>{try{closeInProgress=!0,closePromise=(async()=>{try{await dismiss()}finally{closeInProgress=!1,closePromise=null}})(),await closePromise}catch(r){console.error("Escape key dismiss failed:",r),closeInProgress=!1,closePromise=null}})();else if(i.key==="F6"||(i.altKey||i.metaKey)&&(i.key==="t"||i.key==="T")){const s=(getConfig().targetNode&&typeof getConfig().targetNode.querySelectorAll=="function"?getConfig().targetNode:t.document).querySelectorAll('[id^="toast-container-"] [id^="toast-"]');if(s.length>0){const n=s[s.length-1],l=n.querySelector("button, a, [tabindex='0']");l&&typeof l.focus=="function"?l.focus():typeof n.focus=="function"&&n.focus()}}};t.addEventListener("keydown",e,{passive:!0})}typeof window<"u"&&typeof document<"u"&&initKeyboardShortcuts(window);try{typeof window<"u"&&(window.customizableToast={setConfig,getConfig,resetConfig,shouldReduceMotion,version,createToast:createToastWithPriority,success,error,warning,info,loading,custom,setDefaultColors,setDefaultMessages,noop:noopAll,dismiss:dismissToast,dismissAll:noopAll,clear:noopAll,toastPromise,promise:toastPromise,updateToastByKey,generateToastId,resetToastIdCounter,getToastMetrics,initKeyboardShortcuts})}catch(t){console.error("Global assignment failed:",t)}const subscribers=new Set;function notifySubscribers(){const t={metrics:getToastMetrics()};for(const e of subscribers)try{e(t)}catch{}}function createToastStore(){return{subscribe(t){return typeof t=="function"?(subscribers.add(t),t({metrics:getToastMetrics()}),()=>subscribers.delete(t)):()=>{}},success:(t,e)=>{const i=createToastWithPriority.success(t,e);return notifySubscribers(),i},error:(t,e)=>{const i=createToastWithPriority.error(t,e);return notifySubscribers(),i},warning:(t,e)=>{const i=createToastWithPriority.warning(t,e);return notifySubscribers(),i},info:(t,e)=>{const i=createToastWithPriority.info(t,e);return notifySubscribers(),i},loading:(t,e)=>{const i=createToastWithPriority.loading(t,e);return notifySubscribers(),i},custom:(t,e)=>{const i=createToastWithPriority.custom(t,e);return notifySubscribers(),i},show:t=>{const e=createToastWithPriority(t);return notifySubscribers(),e},promise:toastPromise,dismiss:async t=>{await dismissToast(t),notifySubscribers()},dismissAll:async()=>{await dismissAll(),notifySubscribers()},clear:async()=>{await clear(),notifySubscribers()},setConfig,getConfig,resetConfig}}const toast=createToastStore(),useToast=()=>toast;exports.clear=clear,exports.createToast=createToastWithPriority,exports.createToastStore=createToastStore,exports.dismiss=dismissToast,exports.dismissAll=dismissAll,exports.getConfig=getConfig,exports.getToastMetrics=getToastMetrics,exports.resetConfig=resetConfig,exports.setConfig=setConfig,exports.toast=toast,exports.toastPromise=toastPromise,exports.useToast=useToast;
|
|
126
|
+
//# sourceMappingURL=svelte.cjs.map
|