customizable-toast-notification 4.0.0 → 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 +7 -0
- package/README.md +3 -3
- package/dist/angular.cjs +16 -7
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.esm.mjs +16 -7
- package/dist/angular.esm.mjs.map +1 -1
- package/dist/index.cjs +18 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.d.ts +14 -0
- package/dist/index.css.map +2 -2
- package/dist/index.esm.mjs +16 -7
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +16 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/react.cjs +16 -7
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +2 -0
- package/dist/react.esm.mjs +16 -7
- package/dist/react.esm.mjs.map +1 -1
- package/dist/solid.cjs +16 -7
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.esm.mjs +16 -7
- package/dist/solid.esm.mjs.map +1 -1
- package/dist/svelte.cjs +18 -9
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.esm.mjs +16 -7
- package/dist/svelte.esm.mjs.map +1 -1
- package/dist/vue.cjs +16 -7
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.esm.mjs +16 -7
- package/dist/vue.esm.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.0.1](https://github.com/sammy-cool/customizable-toast-notification/compare/v4.0.0...v4.0.1) (2026-10-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fortify progress bar desync, pop animation, stacked margins, and theme overrides ([e7dceb7](https://github.com/sammy-cool/customizable-toast-notification/commit/e7dceb719585bbc1f010c0555e3a290e8c0736b5))
|
|
7
|
+
|
|
1
8
|
# [4.0.0](https://github.com/sammy-cool/customizable-toast-notification/compare/v3.20.2...v4.0.0) (2026-10-27)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ Global Variable Name: `customizableToast`
|
|
|
116
116
|
<script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification/dist/index.umd.js"></script>
|
|
117
117
|
|
|
118
118
|
<!-- OR pin to a specific version -->
|
|
119
|
-
<script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@4.0.
|
|
119
|
+
<script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@4.0.1/dist/index.umd.js"></script>
|
|
120
120
|
|
|
121
121
|
<script>
|
|
122
122
|
// Access the global UMD export
|
|
@@ -974,8 +974,8 @@ createToast({ message: "Using external CSS!" });
|
|
|
974
974
|
|
|
975
975
|
```html
|
|
976
976
|
<!-- HTML (CDN) -->
|
|
977
|
-
<link rel="stylesheet" href="https://unpkg.com/customizable-toast-notification@4.0.
|
|
978
|
-
<script src="https://unpkg.com/customizable-toast-notification@4.0.
|
|
977
|
+
<link rel="stylesheet" href="https://unpkg.com/customizable-toast-notification@4.0.1/dist/index.css">
|
|
978
|
+
<script src="https://unpkg.com/customizable-toast-notification@4.0.1/dist/index.umd.js"></script>
|
|
979
979
|
<script>
|
|
980
980
|
customizableToast.setConfig({ disableInlineStyles: true });
|
|
981
981
|
customizableToast.createToast({ message: "Using external CSS!" });
|
package/dist/angular.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";/*!
|
|
2
2
|
* Customizable Toast Notifications
|
|
3
|
-
* Build: 2026-10-27
|
|
4
|
-
* Cache-Buster:
|
|
3
|
+
* Build: 2026-10-27 11:02:51
|
|
4
|
+
* Cache-Buster: 1793098971889
|
|
5
5
|
* Author: Priyanshu Patel
|
|
6
6
|
* Email: priyanshu.alt191@gmail.com
|
|
7
7
|
* License: Apache-2.0
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* designed for seamless integration with any JavaScript or framework-based UI.
|
|
12
12
|
* Supports flexible positioning, theming, icons, animations, and timing options
|
|
13
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:n,zIndex:r,targetNode:s,disableInlineStyles:i,reducedMotion:a,defaultPosition:o,theme:u,stacked:l,swipeToDismiss:c,sound:m,icon:f,pauseOnHover:p,priorityQueue:y,shadowDom:d,trapFocus:b,priorityScorer:h,onMetrics:w,debug:L}=t;if(d!==void 0&&(globalConfig.shadowDom=!!d),b!==void 0&&(globalConfig.trapFocus=!!b),L!==void 0&&(globalConfig.debug=!!L),e!==void 0){const v=Number(e);Number.isFinite(v)&&v>0&&(globalConfig.maxVisible=Math.max(1,Math.floor(v)))}if(n!==void 0){const v=Number(n);Number.isFinite(v)&&v>=0&&(globalConfig.maxQueueSize=Math.floor(v))}if(r!==void 0){const v=Number(r);Number.isFinite(v)&&(globalConfig.zIndex=Math.trunc(v))}if(s!==void 0&&(globalConfig.targetNode=s&&typeof s=="object"&&typeof s.appendChild=="function"?s:null),i!==void 0&&(globalConfig.disableInlineStyles=!!i),a!==void 0){const v=String(a||"auto").toLowerCase();["auto","always","never"].includes(v)&&(globalConfig.reducedMotion=v,typeof document<"u"&&(v==="always"?document.documentElement.setAttribute("data-toast-reduced-motion","always"):v==="never"?document.documentElement.setAttribute("data-toast-reduced-motion","never"):document.documentElement.removeAttribute("data-toast-reduced-motion")))}if(o!==void 0){const v=String(o||"").toLowerCase().trim();v&&(globalConfig.defaultPosition=v)}if(u!==void 0){const v=String(u||"light").toLowerCase();["light","dark","high-contrast","compact","spacious","glass"].includes(v)&&(globalConfig.theme=v,typeof document<"u"&&document.documentElement.setAttribute("data-toast-theme",v))}return l!==void 0&&(globalConfig.stacked=!!l),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),h!==void 0&&(globalConfig.priorityScorer=typeof h=="function"?h:null),w!==void 0&&(globalConfig.onMetrics=typeof w=="function"?w: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,""):"",n=e&&!/^[0-9]/.test(e)?e:"toast",r=Date.now().toString(36);counter=counter+1&16777215;const s=counter.toString(36);return`${n}-${r}-${sessionSalt}${s}`}async function createElementWithId(t,e){const n=document.createElement(t);return n.id=generateToastId(e),n}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 n=Number.parseFloat(e);return Number.isFinite(n)&&n>=0?n:500}return 500}class LRUCache{constructor(e=200){this.maxSize=e,this.map=new Map}get(e){if(!this.map.has(e))return;const n=this.map.get(e);return this.map.delete(e),this.map.set(e,n),n}set(e,n){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,n)}}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,n,r]])=>{const s=u=>{const l=u/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)},i=.2126*s(e)+.7152*s(n)+.0722*s(r),a=(i+.05)/.05,o=1.05/(i+.05);precomputedNamedTextColors[t.toLowerCase()]=a>=o?"#000000":"#ffffff"});function getDynamicAccessibleTextColorHex(t){if(!t)return"#ffffff";const e=String(t),n=colorCache.get(e);if(n)return n;if(precomputedNamedTextColors[t==null?void 0:t.toLowerCase()]){const g=precomputedNamedTextColors[t.toLowerCase()];return colorCache.set(e,g),g}let r,s,i;function a(g){if(typeof g!="string")return g;let x=g.trim(),S=0;for(;x.toLowerCase().startsWith("var(")&&x.endsWith(")")&&S<5;){S++;const T=x.slice(4,-1).trim(),E=T.indexOf(","),M=(E===-1?T:T.slice(0,E)).trim(),D=E===-1?"":T.slice(E+1).trim();if(!M.startsWith("--"))return x;let C="";try{typeof document<"u"&&typeof getComputedStyle=="function"&&(C=getComputedStyle(document.documentElement).getPropertyValue(M).trim())}catch{}if(C)x=C;else if(D)x=D;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 k=x[1]||x[2]||x[3];if((k.length===3||k.length===4)&&(k=k.slice(0,3).split("").map(A=>A+A).join("")),k.length>=6){const A=Number.parseInt(k.slice(0,2),16),_=Number.parseInt(k.slice(2,4),16),W=Number.parseInt(k.slice(4,6),16);if(Number.isFinite(A)&&Number.isFinite(_)&&Number.isFinite(W))return{r:A,g:_,b:W}}return null}const S=k=>{if(typeof k!="string")return Number(k);const A=k.trim();return A.endsWith("%")?Math.round(Number.parseFloat(A)/100*255):Number(A)},T=g==null?void 0:g.match(/rgba?\(\s*([\d.]+%?)\s*,\s*([\d.]+%?)\s*,\s*([\d.]+%?)(?:\s*,\s*[\d.%]+)?\s*\)/i);if(T){const k=Math.min(255,Math.max(0,S(T[1]))),A=Math.min(255,Math.max(0,S(T[2]))),_=Math.min(255,Math.max(0,S(T[3])));if(Number.isFinite(k)&&Number.isFinite(A)&&Number.isFinite(_))return{r:k,g:A,b:_}}const E=g==null?void 0:g.match(/rgba?\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+%?)(?:\s*\/\s*[\d.%]+)?\s*\)/i);if(E){const k=Math.min(255,Math.max(0,S(E[1]))),A=Math.min(255,Math.max(0,S(E[2]))),_=Math.min(255,Math.max(0,S(E[3])));if(Number.isFinite(k)&&Number.isFinite(A)&&Number.isFinite(_))return{r:k,g:A,b:_}}const M=k=>{const A=k.trim().toLowerCase();let _=Number.parseFloat(A);return Number.isFinite(_)?(A.endsWith("turn")?_=_*360:A.endsWith("grad")?_=_*360/400:A.endsWith("rad")&&(_=_*180/Math.PI),(_%360+360)%360/360):0},D=g==null?void 0:g.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*[\d.%]+)?\s*\)/i),C=!D&&(g==null?void 0:g.match(/hsla?\(\s*(-?[\d.]+(?:deg|grad|rad|turn)?)\s+([\d.]+)%\s+([\d.]+)%(?:\s*\/\s*[\d.%]+)?\s*\)/i)),N=D||C;if(N){const k=M(N[1]),A=Math.min(1,Math.max(0,Number(N[2])/100)),_=Math.min(1,Math.max(0,Number(N[3])/100));if(A===0){const B=Math.round(_*255);return{r:B,g:B,b:B}}const W=(B,F,j)=>{let z=j;return z<0&&(z+=1),z>1&&(z-=1),z<1/6?B+(F-B)*6*z:z<1/2?F:z<2/3?B+(F-B)*(2/3-z)*6:B},R=_<.5?_*(1+A):_+A-_*A,P=2*_-R;return{r:Math.round(W(P,R,k+1/3)*255),g:Math.round(W(P,R,k)*255),b:Math.round(W(P,R,k-1/3)*255)}}return null}try{const g=typeof t=="string"?t.trim():String(t||""),x=a(g).trim(),S=o(x);if(!S)throw new Error("Unknown color");({r,g:s,b:i}=S)}catch{r=s=i=128}const u=(g,x,S)=>{g/=255,x/=255,S/=255;const T=Math.max(g,x,S),E=Math.min(g,x,S);let M,D,C=(T+E)/2;if(T===E)M=D=0;else{const N=T-E;switch(D=C>.5?N/(2-T-E):N/(T+E),T){case g:M=(x-S)/N+(x<S?6:0);break;case x:M=(S-g)/N+2;break;case S:M=(g-x)/N+4}M/=6}return[M*360,D,C]},l=(g,x,S)=>{g/=360;let T,E,M;if(x===0)T=E=M=S;else{const D=(k,A,_)=>(_<0&&(_+=1),_>1&&(_-=1),_<.16666666666666666?k+(A-k)*6*_:_<.5?A:_<.6666666666666666?k+(A-k)*(.6666666666666666-_)*6:k),C=S<.5?S*(1+x):S+x-S*x,N=2*S-C;T=D(N,C,g+1/3),E=D(N,C,g),M=D(N,C,g-1/3)}return[Math.round(T*255),Math.round(E*255),Math.round(M*255)]},c=(g,x,S)=>{const T=[g,x,S].map(E=>(E/=255,E<=.03928?E/12.92:Math.pow((E+.055)/1.055,2.4)));return .2126*T[0]+.7152*T[1]+.0722*T[2]},m=(g,x)=>{const S=c(...g),T=c(...x);return(Math.max(S,T)+.05)/(Math.min(S,T)+.05)},f=(g,x,S)=>`#${g.toString(16).padStart(2,"0")}${x.toString(16).padStart(2,"0")}${S.toString(16).padStart(2,"0")}`;let[p,y,d]=u(r,s,i);const b=4.5;let h=d<.5?Math.min(d+.5,1):Math.max(d-.5,0),[w,L,v]=l(p,y,h);if(m([r,s,i],[w,L,v])<b){const g=m([r,s,i],[0,0,0]),x=m([r,s,i],[255,255,255]);[w,L,v]=g>=x?[0,0,0]:[255,255,255]}const I=f(w,L,v);return colorCache.set(e,I),I}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 n=[];Array.from(t.attributes||[]).forEach(s=>{const i=s.name.toLowerCase(),a=s.value;if(!e.has(i)||i.startsWith("on")){n.push(s.name);return}if(i==="href"||i==="src"){const o=typeof a=="string"?a.trim().toLowerCase():"";if((o.startsWith("javascript:")||o.startsWith("vbscript:")||o.startsWith("data:"))&&!(i==="src"&&o.startsWith("data:image/")&&!o.startsWith("data:image/svg+xml"))){if(i==="href"){t.setAttribute("href","#");return}n.push(s.name);return}if(!ALLOWED_URI_REGEX.test(a)){if(i==="href"){t.setAttribute("href","#");return}n.push(s.name);return}}if(i==="target"&&typeof a=="string"&&a.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(" "))}}),n.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,n){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 i=document.createDocumentFragment();return Array.from(t.childNodes).forEach(a=>{const o=sanitizeNode(a,e,n);o&&i.appendChild(o)}),i}const s=document.createElement(t.tagName);return Array.from(t.attributes||[]).forEach(i=>{s.setAttribute(i.name,i.value)}),sanitizeAttributes(s,n),Array.from(t.childNodes).forEach(i=>{const a=sanitizeNode(i,e,n);a&&s.appendChild(a)}),s}function parseHtmlInert(t){if(typeof DOMParser<"u")try{const n=new DOMParser().parseFromString(t,"text/html");if(n&&n.body)return n.body}catch{}if(typeof document<"u"){const e=document.createElement("template");if("content"in e)return e.innerHTML=t,e.content;const n=document.createElement("div");return n.innerHTML=t,n}return null}function fallbackSanitize(t){if(!t||typeof t!="string")return"";const e=parseHtmlInert(t);if(!e)return"";const n=document.createDocumentFragment();Array.from(e.childNodes).forEach(s=>{const i=sanitizeNode(s,ALLOWED_TAGS,ALLOWED_ATTRS);i&&n.appendChild(i)});const r=document.createElement("div");return r.appendChild(n),r.querySelectorAll('a[target="_blank"]').forEach(s=>{const i=(s.getAttribute("rel")||"").split(/\s+/).filter(Boolean);i.includes("noopener")||i.push("noopener"),i.includes("noreferrer")||i.push("noreferrer"),s.setAttribute("rel",i.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(i=>{const a=i.getAttribute("href")||"";ALLOWED_URI_REGEX.test(a)||i.setAttribute("href","#")}),s.querySelectorAll('a[target="_blank"]').forEach(i=>{const a=(i.getAttribute("rel")||"").split(/\s+/).filter(Boolean);a.includes("noopener")||a.push("noopener"),a.includes("noreferrer")||a.push("noreferrer"),i.setAttribute("rel",a.join(" "))}),s.innerHTML}}catch(n){console.warn("DOMPurify sanitization failed, falling back:",n)}return fallbackSanitize(t)}function createLoader(t={}){if(typeof document>"u")return null;const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n=Number(e.size),r=Number.isFinite(n)&&n>0?n:14,s=typeof e.color=="string"&&e.color.trim()?e.color.trim():"currentColor",i=/[\r\n<>"';]/.test(s)||/^\s*javascript:/i.test(s)?"currentColor":s,a=typeof e.text=="string"?e.text:"",o=document.createElement("span");o.className="toast-loader",o.setAttribute("role","status"),o.setAttribute("aria-label",a||"Loading");const u=getConfig();u.disableInlineStyles||(o.style.display="inline-flex",o.style.alignItems="center",o.style.gap="8px");const l="http://www.w3.org/2000/svg",c=document.createElementNS(l,"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(l,"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",i),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),a){const f=document.createElement("span");f.className="toast-loader-label",u.disableInlineStyles||(f.style.fontSize="13px"),f.textContent=a,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,n){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 i=[];s.forEach((o,u)=>{if(!o||typeof o!="object")return;const l={...o};l.label||(l.label=s.length>1?`Action ${u+1}`:"CTA Label Missing!");const c=l.variant==="link"||!l.variant&&!!l.href,m=document.createElement(c?"a":"button");if(c){if(l.href){const x=String(l.href).trim(),S=/^(javascript:|vbscript:|data:(?!image\/[a-z0-9.+-]+;base64,))/i.test(x);m.href=S?"#":x}else m.setAttribute("role","button"),m.tabIndex=0;l.target&&(m.target=l.target);const g=new Set((l.rel||"").split(/\s+/).filter(Boolean));typeof l.target=="string"&&l.target.trim().toLowerCase()==="_blank"&&(g.add("noopener"),g.add("noreferrer")),m.rel=Array.from(g).join(" ")}else m.type="button";m.setAttribute("aria-label",l.ariaLabel||l.label);const f=l.textColor||l.color||e.textColor||getDynamicAccessibleTextColorHex(e.backgroundColor),p=l.backgroundColor||l.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 h=e.fontDirection==="rtl";getConfig().disableInlineStyles||Object.assign(m.style,{marginLeft:h?"0px":u===0?"10px":"6px",marginRight:h?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=l.label;const w=async g=>{if(!m._isExecuting){m._isExecuting=!0;try{if(typeof l.onClick=="function"){const x=l.onClick(g);x!=null&&x.then&&await x}}catch(x){console.error("CTA onClick handler error:",x)}finally{m._isExecuting=!1,l.autoClose!==!1&&typeof n=="function"&&await n(t)}}},L=g=>{c&&!l.href&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),w(g))};m.addEventListener("click",w),c&&!l.href&&m.addEventListener("keydown",L);const v=()=>{m.removeEventListener("click",w),c&&!l.href&&m.removeEventListener("keydown",L)};m._cleanup=v,i.push(v);const I=t.querySelector(".toast-undo-btn")||t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");I?t.insertBefore(m,I):t.appendChild(m)});const a=t._cleanupCTA;t._cleanupCTA=()=>{a==null||a(),i.forEach(o=>o())}}function createUndoAction(t,e,n){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 i=s?{onUndo:r}:{...r},a=typeof i.label=="string"&&i.label.trim()?i.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=i.showCountdown!==!1&&Number.isFinite(o)&&o>0,l=document.createElement("button");l.type="button",l.className="toast-undo-btn",l.setAttribute("aria-label",`${a} 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(l.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 h=()=>{l.textContent=u?`${a} (${b}s)`:a};h();let w=null,L=!1;u&&(w=setInterval(()=>{L||(b=Math.max(0,b-1),h(),b<=0&&w&&(clearInterval(w),w=null))},1e3),typeof(w==null?void 0:w.unref)=="function"&&w.unref()),t._pauseUndo=()=>{L=!0},t._resumeUndo=()=>{L=!1};const v=()=>{w&&(clearInterval(w),w=null),t._pauseUndo=null,t._resumeUndo=null},I=async x=>{v(),l.removeEventListener("click",I);try{if(typeof i.onUndo=="function"){const S=i.onUndo(x,t);S!=null&&S.then&&await S}}catch(S){console.error("Undo action error:",S)}finally{typeof n=="function"&&await n(t)}};l.addEventListener("click",I),l._cleanup=()=>{v(),l.removeEventListener("click",I)},t._cleanupUndo=()=>{v(),l.removeEventListener("click",I)};const g=t.querySelector(".toast-close-btn")||t.querySelector(".toast-progress-bar");g?t.insertBefore(l,g):t.appendChild(l)}function createCloseButton(t,e,n){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 i=e.textColor||getDynamicAccessibleTextColorHex(e.backgroundColor);r.className="toast-close-btn";const a=e.fontDirection==="rtl";getConfig().disableInlineStyles||Object.assign(r.style,{background:"none",border:"none",color:i,fontSize:"18px",marginLeft:a?"0px":"10px",marginRight:a?"10px":"0px",cursor:"pointer",lineHeight:"1",padding:"0 4px",flexShrink:"0",display:"inline-flex",alignItems:"center",justifyContent:"center"});const o=()=>{typeof n=="function"&&n(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=`
|
|
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:n,zIndex:r,targetNode:s,disableInlineStyles:i,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(n!==void 0){const S=Number(n);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),i!==void 0&&(globalConfig.disableInlineStyles=!!i),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,""):"",n=e&&!/^[0-9]/.test(e)?e:"toast",r=Date.now().toString(36);counter=counter+1&16777215;const s=counter.toString(36);return`${n}-${r}-${sessionSalt}${s}`}async function createElementWithId(t,e){const n=document.createElement(t);return n.id=generateToastId(e),n}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 n=Number.parseFloat(e);return Number.isFinite(n)&&n>=0?n:500}return 500}class LRUCache{constructor(e=200){this.maxSize=e,this.map=new Map}get(e){if(!this.map.has(e))return;const n=this.map.get(e);return this.map.delete(e),this.map.set(e,n),n}set(e,n){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,n)}}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,n,r]])=>{const s=u=>{const a=u/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)},i=.2126*s(e)+.7152*s(n)+.0722*s(r),l=(i+.05)/.05,o=1.05/(i+.05);precomputedNamedTextColors[t.toLowerCase()]=l>=o?"#000000":"#ffffff"});function getDynamicAccessibleTextColorHex(t){if(!t)return"#ffffff";const e=String(t),n=colorCache.get(e);if(n)return n;if(precomputedNamedTextColors[t==null?void 0:t.toLowerCase()]){const g=precomputedNamedTextColors[t.toLowerCase()];return colorCache.set(e,g),g}let r,s,i;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},F=T<.5?T*(1+E):T+E-T*E,j=2*T-F;return{r:Math.round(P(j,F,h+1/3)*255),g:Math.round(P(j,F,h)*255),b:Math.round(P(j,F,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:i}=C)}catch{r=s=i=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,i);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,i],[v,w,S])<b){const g=m([r,s,i],[0,0,0]),x=m([r,s,i],[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 n=[];Array.from(t.attributes||[]).forEach(s=>{const i=s.name.toLowerCase(),l=s.value;if(!e.has(i)||i.startsWith("on")){n.push(s.name);return}if(i==="href"||i==="src"){const o=typeof l=="string"?l.trim().toLowerCase():"";if((o.startsWith("javascript:")||o.startsWith("vbscript:")||o.startsWith("data:"))&&!(i==="src"&&o.startsWith("data:image/")&&!o.startsWith("data:image/svg+xml"))){if(i==="href"){t.setAttribute("href","#");return}n.push(s.name);return}if(!ALLOWED_URI_REGEX.test(l)){if(i==="href"){t.setAttribute("href","#");return}n.push(s.name);return}}if(i==="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(" "))}}),n.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,n){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 i=document.createDocumentFragment();return Array.from(t.childNodes).forEach(l=>{const o=sanitizeNode(l,e,n);o&&i.appendChild(o)}),i}const s=document.createElement(t.tagName);return Array.from(t.attributes||[]).forEach(i=>{s.setAttribute(i.name,i.value)}),sanitizeAttributes(s,n),Array.from(t.childNodes).forEach(i=>{const l=sanitizeNode(i,e,n);l&&s.appendChild(l)}),s}function parseHtmlInert(t){if(typeof DOMParser<"u")try{const n=new DOMParser().parseFromString(t,"text/html");if(n&&n.body)return n.body}catch{}if(typeof document<"u"){const e=document.createElement("template");if("content"in e)return e.innerHTML=t,e.content;const n=document.createElement("div");return n.innerHTML=t,n}return null}function fallbackSanitize(t){if(!t||typeof t!="string")return"";const e=parseHtmlInert(t);if(!e)return"";const n=document.createDocumentFragment();Array.from(e.childNodes).forEach(s=>{const i=sanitizeNode(s,ALLOWED_TAGS,ALLOWED_ATTRS);i&&n.appendChild(i)});const r=document.createElement("div");return r.appendChild(n),r.querySelectorAll('a[target="_blank"]').forEach(s=>{const i=(s.getAttribute("rel")||"").split(/\s+/).filter(Boolean);i.includes("noopener")||i.push("noopener"),i.includes("noreferrer")||i.push("noreferrer"),s.setAttribute("rel",i.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(i=>{const l=i.getAttribute("href")||"";ALLOWED_URI_REGEX.test(l)||i.setAttribute("href","#")}),s.querySelectorAll('a[target="_blank"]').forEach(i=>{const l=(i.getAttribute("rel")||"").split(/\s+/).filter(Boolean);l.includes("noopener")||l.push("noopener"),l.includes("noreferrer")||l.push("noreferrer"),i.setAttribute("rel",l.join(" "))}),s.innerHTML}}catch(n){console.warn("DOMPurify sanitization failed, falling back:",n)}return fallbackSanitize(t)}function createLoader(t={}){if(typeof document>"u")return null;const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n=Number(e.size),r=Number.isFinite(n)&&n>0?n:14,s=typeof e.color=="string"&&e.color.trim()?e.color.trim():"currentColor",i=/[\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",i),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,n){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 i=[];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 n=="function"&&await n(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,i.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(),i.forEach(o=>o())}}function createUndoAction(t,e,n){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 i=s?{onUndo:r}:{...r},l=typeof i.label=="string"&&i.label.trim()?i.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=i.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 i.onUndo=="function"){const C=i.onUndo(x,t);C!=null&&C.then&&await C}}catch(C){console.error("Undo action error:",C)}finally{typeof n=="function"&&await n(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,n){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 i=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:i,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 n=="function"&&n(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
15
|
@keyframes toast-progress-indeterminate {
|
|
16
16
|
0% { left: 0%; width: 0%; }
|
|
17
17
|
50% { left: 20%; width: 60%; }
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
.toast-progress-bar-indeterminate-rtl {
|
|
29
29
|
animation: toast-progress-indeterminate-rtl 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
|
|
30
30
|
}
|
|
31
|
-
`;const e=document.head||document.documentElement;e&&e.appendChild(t)}function parseProgressValue(t,e,n={}){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),((n.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 n;if(!t)return;const r=document.createElement("div");r.className="toast-progress-bar",t._progressBar=r;const s=e.borderRadius||"0",i=Number.parseInt(s,10),
|
|
31
|
+
`;const e=document.head||document.documentElement;e&&e.appendChild(t)}function parseProgressValue(t,e,n={}){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),((n.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 n;if(!t)return;const r=document.createElement("div");r.className="toast-progress-bar",t._progressBar=r;const s=e.borderRadius||"0",i=Number.parseInt(s,10),l=Number.isFinite(i)&&i>0?i: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"||((n=t==null?void 0:t.style)==null?void 0:n.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 n=0,r=0,s=0,i=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,n=b.clientX,r=b.clientY,s=n,i=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-n,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-n,_=Math.max(1,Date.now()-i),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,n=()=>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=n();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=n();l.length>0&&typeof l[0].focus=="function"&&l[0].focus()},30);typeof(s==null?void 0:s.unref)=="function"&&s.unref();const i=()=>{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=i,i}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 i=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=i(l.childNodes[a]);c&&u.appendChild(c)}return u};return i(s)}catch{return null}}const ICON_SVGS={success:`
|
|
32
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
33
|
<path d="M20 6L9 17l-5-5"/>
|
|
34
34
|
</svg>
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
<line x1="12" y1="16" x2="12" y2="12"/>
|
|
51
51
|
<line x1="12" y1="8" x2="12.01" y2="8"/>
|
|
52
52
|
</svg>
|
|
53
|
-
`};function createToastIcon(t={}){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};let n=e.icon;if(n===void 0){const u=getConfig().icon;u!==void 0&&(n=u)}if(typeof n=="function")try{n=n(e)}catch(u){console.warn("options.icon callback error:",u),n=null}if(n===!1||n===""||n===null||typeof document>"u")return null;const r=e.type,s=getConfig(),i=document.createElement("i");i.className="toast-icon",i.setAttribute("aria-hidden","true");const a=e.fontDirection==="rtl";if(s.disableInlineStyles||Object.assign(i.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:"0",marginLeft:a?"8px":"0px",marginRight:a?"0px":"8px",lineHeight:"1",fontStyle:"normal"}),n&&typeof n=="object"&&(n.nodeType===1||n.nodeType===11||typeof HTMLElement<"u"&&n instanceof HTMLElement)&&typeof n.cloneNode=="function")return i.appendChild(n.cloneNode(!0)),i;if(typeof n=="string"&&n.trim()){const u=n.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&&i.appendChild(m),i}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"),i.appendChild(m)):i.textContent=u}else i.textContent=u;return i}const o=typeof r=="string"?r.toLowerCase().trim():"";if((n===!0||n===void 0)&&o&&ICON_SVGS[o]){const u=sanitizeInlineSvg(ICON_SVGS[o].trim());return u&&i.appendChild(u),i}return null}function getInitialTransform(t,e,n){const r=String(t||"").toLowerCase(),s=r.includes("top"),i=r.includes("left"),a=r.includes("right"),o=String(e||"").toLowerCase().trim();return o==="fade"?"none":o==="zoom"||o==="scale"?"scale(0.75)":o==="flip"?"perspective(600px) rotateX(45deg)":o==="slide"?i?"translateX(-100%)":a?"translateX(100%)":s?"translateY(-100%)":"translateY(100%)":n?r.includes("center")&&!s&&!r.includes("bottom")?i?"translateX(-36px) scale(0.92)":a?"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,n){const r=getConfig(),s=String((e==null?void 0:e.animationType)||"").toLowerCase().trim(),i=!!(e!=null&&e.spring)||s==="spring",a=i?400:await parseAnimationDuration(e==null?void 0:e.animationDuration),o=`${a}ms`,u=i?"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 l=typeof(e==null?void 0:e.className)=="string"&&e.className.trim()?` ${e.className.trim()}`:"";t.className=`toast toast-${(e==null?void 0:e.type)??"info"}${l}`;const c=typeof(e==null?void 0:e.borderRadius)=="number"?`${e.borderRadius}px`:e==null?void 0:e.borderRadius,m=typeof(e==null?void 0:e.maxWidth)=="number"?`${e.maxWidth}px`:e==null?void 0:e.maxWidth,f=i?`${Math.min(300,a)}ms`:o,p=i?"ease":u;r.disableInlineStyles||Object.assign(t.style,{background:e==null?void 0:e.backgroundColor,padding:"12px 16px",marginBottom:"10px",borderRadius:c,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:m,opacity:"0",position:"relative",cursor:"default",boxSizing:"border-box",userSelect:"text",pointerEvents:"auto",transition:`opacity ${f} ${p}, transform ${o} ${u}`,transform:getInitialTransform(e==null?void 0:e.position,e==null?void 0:e.animationType,i),zIndex:String(r.zIndex),direction:e!=null&&e.fontDirection&&e.fontDirection!=="auto"?e.fontDirection:void 0});const y=(e==null?void 0:e.type)==="error",d=(e==null?void 0:e.role)||"alert",b=(e==null?void 0:e.ariaLive)||(y?"assertive":"polite");t.setAttribute("role",d),t.setAttribute("aria-live",b),t.tabIndex=0,t._animationDuration=a;const h=document.createElement("span");h.className="toast-message",t._messageSpan=h,(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)?(h.classList.add("is-truncated"),r.disableInlineStyles||Object.assign(h.style,{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3",whiteSpace:"normal",overflow:"hidden",textOverflow:"ellipsis"})):r.disableInlineStyles||Object.assign(h.style,{display:"block",whiteSpace:"normal"});const L=typeof(e==null?void 0:e.fontSize)=="number"?`${e.fontSize}px`:e==null?void 0:e.fontSize;r.disableInlineStyles||Object.assign(h.style,{flex:"1",padding:e==null?void 0:e.fontPadding,fontFamily:e==null?void 0:e.fontFamily,fontSize:L,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 v=!!e.allowHtml,I=e.message??"",g=createToastIcon(e);if(g&&t.appendChild(g),e.loader||e.showLoader){const T=createLoader(e.loader||{});h.appendChild(T);const E=document.createElement("span");E.className="toast-message-spacer",r.disableInlineStyles||(E.style.display="inline-block",E.style.width="8px"),h.appendChild(E)}if(v&&typeof I=="string"&&I.trim().length>0)try{const T=sanitizeHtml(I),E=document.createElement("div");for(E.innerHTML=T;E.firstChild;)h.appendChild(E.firstChild)}catch(T){console.warn("HTML message sanitization failed, falling back to text:",T),h.appendChild(document.createTextNode(String(I)))}else h.appendChild(document.createTextNode(String(I)));if(h.setAttribute("title",h.textContent||""),t.appendChild(h),e!=null&&e.cta&&typeof e.cta=="object"&&createCTA(t,e,n),e!=null&&e.undo&&createUndoAction(t,e,n),e!=null&&e.showCloseButton&&createCloseButton(t,e,n),(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,n),(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),runToastAnimation(t)}async function createEmergencyToast(t={},e){try{const n=getConfig(),r=document.createElement("div"),s=(t==null?void 0:t.position)||n.defaultPosition,i=String(s).toLowerCase().trim();let a="auto",o="auto",u="auto",l="auto",c="none";i.startsWith("top")?a="20px":(i.startsWith("bottom")||i.includes("below"))&&(o="20px"),i.startsWith("left")?u="20px":i.startsWith("right")?l="20px":i==="center"?(u="50%",a="50%",c="translate(-50%, -50%)"):i.includes("center")?i.includes("left")?(u="20px",a="50%",c="translateY(-50%)"):i.includes("right")?(l="20px",a="50%",c="translateY(-50%)"):i.includes("top")?(a="20px",u="50%",c="translateX(-50%)"):i.includes("bottom")&&(o="20px",u="50%",c="translateX(-50%)"):(l="20px",o="20px"),r.className="toast-emergency",r.tabIndex=0,r.setAttribute("role","alert"),r.setAttribute("aria-live","assertive"),n.disableInlineStyles||Object.assign(r.style,{background:"#333",color:"white",padding:"10px 15px",position:"fixed",top:a,bottom:o,left:u,right:l,transform:c,zIndex:String(n.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",n.disableInlineStyles||(f.style.display="inline-block"),t.allowHtml)try{const h=sanitizeHtml(String(t.message||"Emergency Toast Showing!")),w=document.createElement("div");for(w.innerHTML=h;w.firstChild;)f.appendChild(w.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"),n.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(n){return console.error("Emergency toast creation failed:",n),typeof e=="function"&&e(null),null}}async function createToastElement(t,e){let n;const s="toast";try{return n=await createElementWithId("div",s),await applyRichStyling(n,t,e),n}catch(i){return console.warn("toast creation failed with error showing fallback one: ",i),n=await createEmergencyToast(t,e),n}}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="hidden")}async function getOrCreateToastContainer(t={},e){const n=getConfig(),r=getContainerId((t==null?void 0:t.position)||n.defaultPosition);let s=getContainerRoot();if(!s)throw new Error("Toast container root is unavailable");if(!!((t==null?void 0:t.shadowDom)??n.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(n.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=`
|
|
53
|
+
`};function createToastIcon(t={}){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};let n=e.icon;if(n===void 0){const u=getConfig().icon;u!==void 0&&(n=u)}if(typeof n=="function")try{n=n(e)}catch(u){console.warn("options.icon callback error:",u),n=null}if(n===!1||n===""||n===null||typeof document>"u")return null;const r=e.type,s=getConfig(),i=document.createElement("i");i.className="toast-icon",i.setAttribute("aria-hidden","true");const l=e.fontDirection==="rtl";if(s.disableInlineStyles||Object.assign(i.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:"0",marginLeft:l?"8px":"0px",marginRight:l?"0px":"8px",lineHeight:"1",fontStyle:"normal"}),n&&typeof n=="object"&&(n.nodeType===1||n.nodeType===11||typeof HTMLElement<"u"&&n instanceof HTMLElement)&&typeof n.cloneNode=="function")return i.appendChild(n.cloneNode(!0)),i;if(typeof n=="string"&&n.trim()){const u=n.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&&i.appendChild(m),i}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"),i.appendChild(m)):i.textContent=u}else i.textContent=u;return i}const o=typeof r=="string"?r.toLowerCase().trim():"";if((n===!0||n===void 0)&&o&&ICON_SVGS[o]){const u=sanitizeInlineSvg(ICON_SVGS[o].trim());return u&&i.appendChild(u),i}return null}function getInitialTransform(t,e,n){const r=String(t||"").toLowerCase(),s=r.includes("top"),i=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"?i?"translateX(-100%)":l?"translateX(100%)":s?"translateY(-100%)":"translateY(100%)":n?r.includes("center")&&!s&&!r.includes("bottom")?i?"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,n){const r=getConfig(),s=String((e==null?void 0:e.animationType)||"").toLowerCase().trim(),i=!!(e!=null&&e.spring)||s==="spring",l=i?400:await parseAnimationDuration(e==null?void 0:e.animationDuration),o=`${l}ms`,u=i?"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=i?`${Math.min(300,l)}ms`:o,d=i?"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,i),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,n),e!=null&&e.undo&&createUndoAction(t,e,n),e!=null&&e.showCloseButton&&createCloseButton(t,e,n),(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,n),(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 n=getConfig(),r=document.createElement("div"),s=(t==null?void 0:t.position)||n.defaultPosition,i=String(s).toLowerCase().trim();let l="auto",o="auto",u="auto",a="auto",c="none";i.startsWith("top")?l="20px":(i.startsWith("bottom")||i.includes("below"))&&(o="20px"),i.startsWith("left")?u="20px":i.startsWith("right")?a="20px":i==="center"?(u="50%",l="50%",c="translate(-50%, -50%)"):i.includes("center")?i.includes("left")?(u="20px",l="50%",c="translateY(-50%)"):i.includes("right")?(a="20px",l="50%",c="translateY(-50%)"):i.includes("top")?(l="20px",u="50%",c="translateX(-50%)"):i.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"),n.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(n.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",n.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"),n.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(n){return console.error("Emergency toast creation failed:",n),typeof e=="function"&&e(null),null}}async function createToastElement(t,e){let n;const s="toast";try{return n=await createElementWithId("div",s),await applyRichStyling(n,t,e),n}catch(i){return console.warn("toast creation failed with error showing fallback one: ",i),n=await createEmergencyToast(t,e),n}}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 n=getConfig(),r=getContainerId((t==null?void 0:t.position)||n.defaultPosition);let s=getContainerRoot();if(!s)throw new Error("Toast container root is unavailable");if(!!((t==null?void 0:t.shadowDom)??n.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(n.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
54
|
:host { position: fixed; inset: 0; pointer-events: none; z-index: ${n.zIndex||9999}; }
|
|
55
55
|
* { box-sizing: border-box; }
|
|
56
56
|
.toast-container-base {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
justify-content: space-between;
|
|
62
62
|
align-items: center;
|
|
63
63
|
flex-direction: column;
|
|
64
|
-
overflow:
|
|
64
|
+
overflow: visible;
|
|
65
65
|
inset: auto 10px 10px auto;
|
|
66
66
|
contain: layout style;
|
|
67
67
|
}
|
|
@@ -93,6 +93,8 @@
|
|
|
93
93
|
}
|
|
94
94
|
[data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="1"] {
|
|
95
95
|
transform: scale(0.95) translateY(10px);
|
|
96
|
+
margin-top: 0px;
|
|
97
|
+
margin-bottom: -55px;
|
|
96
98
|
}
|
|
97
99
|
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="2"] {
|
|
98
100
|
transform: scale(0.90) translateY(-20px);
|
|
@@ -104,6 +106,8 @@
|
|
|
104
106
|
}
|
|
105
107
|
[data-stacked="true"][id*="top"] .toast-outer-wrapper[data-stacked-depth="2"] {
|
|
106
108
|
transform: scale(0.90) translateY(20px);
|
|
109
|
+
margin-top: 0px;
|
|
110
|
+
margin-bottom: -55px;
|
|
107
111
|
}
|
|
108
112
|
[data-stacked="true"] .toast-outer-wrapper[data-stacked-depth="overflow"] {
|
|
109
113
|
transform: scale(0.85) translateY(-30px);
|
|
@@ -113,5 +117,10 @@
|
|
|
113
117
|
z-index: 1;
|
|
114
118
|
pointer-events: none;
|
|
115
119
|
}
|
|
116
|
-
`,s.appendChild(u)}}if(containerLocks.has(r))return containerLocks.get(r);const a=(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 l=(s==null?void 0:s.ownerDocument)||(typeof document<"u"?document:null);if(!l)throw new Error("Document is unavailable");u=l.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 l=s.querySelectorAll(`#${r}`);if(l.length>1)for(let c=1;c<l.length;c++)try{l[c].remove()}catch{}}return containerRegistry.set(r,u),u})();containerLocks.set(r,a);try{return await a}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 n;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 i=s;if(!isDocumentedPosition(s)&&!LEGACY_POSITIONS.has(s)&&(console.warn(`Unknown position "${e.position}", defaulting to "bottom-right"`),i="bottom-right"),resetPositionClasses(t),(n=t.classList)==null||n.add("toast-position-"+i),getConfig().disableInlineStyles)return;resetContainerStyles(t);const a=parsePosition(i);handleFullWidthPositions(t,a)||handleCenterPositions(t,a)||applyStandardPositioning(t,a)}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="none"}function parsePosition(t){const e=t.toLowerCase().trim(),n=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"),i=e.startsWith("left")||e.endsWith("left"),a=e.startsWith("right")||e.endsWith("right"),o=e.includes("center");return{hasTop:r,hasBottom:s,hasLeft:i,hasRight:a,hasCenter:o,hasFullWidth:n}}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,n){this.callback=typeof e=="function"?e:()=>{};const r=n===1/0,s=Number.isFinite(n)&&n>=0?n: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(n){console.error("PausableTimer callback error:",n)}},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,n,r,s,i,a;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=(n=t==null?void 0:t.priority)==null?void 0:n.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:(i=t==null?void 0:t.options)==null?void 0:i.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}[(a=t==null?void 0:t.options)==null?void 0:a.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 a=()=>{t._isExpanded=!0,updateStackedLayout(t)},o=()=>{t._isExpanded=!1,updateStackedLayout(t)},u=()=>{t._isExpanded=!0,updateStackedLayout(t)},l=c=>{t.contains(c.relatedTarget)||(t._isExpanded=!1,updateStackedLayout(t))};t.addEventListener("mouseenter",a),t.addEventListener("mouseleave",o),t.addEventListener("focusin",u),t.addEventListener("focusout",l),t._stackedCleanup=()=>{t.removeEventListener("mouseenter",a),t.removeEventListener("mouseleave",o),t.removeEventListener("focusin",u),t.removeEventListener("focusout",l),t._stackedInitialized=!1}}if(!t.children||t.children.length===0)return;const n=Array.from(t.children),r=n.length,s=!!t._isExpanded,i=!!(t.id&&t.id.includes("top"));n.forEach((a,o)=>{const u=r-1-o,l=s?"expanded":u>=3?"overflow":String(u);if(typeof a.setAttribute=="function"&&a.setAttribute("data-stacked-depth",l),!getConfig().disableInlineStyles)if(a.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)a.style.transform="none",a.style.marginTop="0px",a.style.marginBottom="10px",a.style.opacity="1",a.style.zIndex=String(100+o),a.style.pointerEvents="auto";else if(u===0)a.style.transform="scale(1)",a.style.marginTop="0px",a.style.marginBottom="0px",a.style.opacity="1",a.style.zIndex="30",a.style.pointerEvents="auto";else if(u===1){const c=i?10:-10;a.style.transform=`scale(0.95) translateY(${c}px)`,a.style.marginTop="-55px",a.style.marginBottom="0px",a.style.opacity="0.9",a.style.zIndex="20",a.style.pointerEvents="auto"}else if(u===2){const c=i?20:-20;a.style.transform=`scale(0.90) translateY(${c}px)`,a.style.marginTop="-55px",a.style.marginBottom="0px",a.style.opacity="0.75",a.style.zIndex="10",a.style.pointerEvents="auto"}else{const c=i?30:-30;a.style.transform=`scale(0.85) translateY(${c}px)`,a.style.marginTop="-55px",a.style.marginBottom="0px",a.style.opacity="0",a.style.zIndex="1",a.style.pointerEvents="none"}})}function hashString(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);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 i=normalizePositionKey(e.position||"bottom-right");return`tag:${String(e.tag).trim()}:${i}`}if(e.groupId!==void 0&&e.groupId!==null&&e.groupId!==""){const i=normalizePositionKey(e.position||"bottom-right");return`group:${String(e.groupId).trim()}:${i}`}const n=String(e.type||"info").trim().toLowerCase(),r=hashString(String(e.message||"")).toString(16),s=normalizePositionKey(e.position||"bottom-right");return`${n}|${r}|${s}`}async function showToast(t={}){var e,n;try{const r=makeKey(t);if(active.has(r)){const i=active.get(r);if(!i)throw new Error(`Active toast with key ${r} not found`);return i.count++,(t.tag||t.groupId)&&t.message&&((e=i.toast)!=null&&e._messageSpan)&&(i.toast._messageSpan.textContent=String(t.message),i.toast._messageSpan.title=String(t.message)),(n=i.timer)==null||n.clear(),i.timer=createDismissTimer(i.toast,t),await setupPauseOnHover(i),await updateBadge(i),emitMetrics(),r}if(pending.has(r)){const i=pending.get(r);if(!i)throw new Error(`Pending toast with key ${r} not found`);return i.count++,(t.tag||t.groupId)&&t.message&&(i.options={...i.options,...t}),r}const s={options:t,count:1,rafId:0};return pending.set(r,s),s.rafId=requestAnimationFrame(async()=>{var i,a;const o=pending.get(r);if(o){if(pending.delete(r),visibleCount>=getConfig().maxVisible){const u={options:o.options,key:r,count:o.count},l=getConfig().maxQueueSize??100;if(l<=0){droppedCount++,emitMetrics();return}const c=queue.find(f=>f.key===r);if(c){c.count+=o.count,typeof((i=o.options)==null?void 0:i.priority)=="number"&&(c.options={...c.options,...o.options},c.priority={score:getItemPriority(c)}),emitMetrics();return}const m=typeof((a=o.options)==null?void 0:a.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>=l){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,n){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 i=document.createElement("div");i.className="toast-outer-wrapper",getConfig().disableInlineStyles||Object.assign(i.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%",pointerEvents:"auto"});const a=document.createElement("div");a.className="toast-inner-wrapper",getConfig().disableInlineStyles||Object.assign(a.style,{position:"relative",overflow:"hidden",zIndex:"1"}),a.appendChild(s),i.appendChild(a),r.id.includes("toast-container-")&&(r.appendChild(i),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:i,toast:s,options:t,count:Math.max(1,Math.floor(n??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(active.size===0){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(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 i=Array.from(s.children||[]);if(i.length===0)return;const a=i.at(-1);a&&(t=a.querySelector('[id^="toast-"]')||a)}),!t)return;const n=t._key?t:t.querySelector('[id^="toast-"]')||t;await closeToast(n)}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(n){console.warn("closeAllToasts: failed to close one toast:",n)}}))}catch(t){console.error("closeAllToasts failed:",t)}}const dismiss=dismissMostRecent,noop=closeAllToasts;function createDismissTimer(t,e){const n=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(n)&&n>0?n:2500)+5,i=new PausableTimer(()=>{closeToast(t).catch(console.error)},s);return i.start(),i}async function setupPauseOnHover(t){var e,n;if(!t.pauseOnHover||!t.outer||!t.timer)return;(n=(e=t.outer)._pauseCleanup)==null||n.call(e);const{outer:r,timer:s,toast:i}=t,a=()=>{if(i!=null&&i._progressAnimation)try{i._progressAnimation.pause()}catch{}else if(i!=null&&i._progressBar)try{if(i._progressBar._isIndeterminate)i._progressBar.style.animationPlayState="paused";else if(!i._progressBar._isManualProgress){const f=window.getComputedStyle(i._progressBar).width;i._progressBar._pausedWidth=f,i._progressBar.style.transition="none",i._progressBar.style.width=f}}catch{}},o=()=>{var f;if(i!=null&&i._progressAnimation)try{i._progressAnimation.play()}catch{}else if(i!=null&&i._progressBar)try{if(i._progressBar._isIndeterminate)i._progressBar.style.animationPlayState="running";else if(!i._progressBar._isManualProgress){if(i._progressBar._pausedWidth){const p=((f=s.getRemainingTime)==null?void 0:f.call(s))??1e3,y=i._progressBar._isReverse,d=i._progressBar._finalWidth||"100%";i._progressBar.style.transition=`width ${Math.max(0,p)}ms linear`,i._progressBar.style.width=y?d:"0%",i._progressBar._pausedWidth=null}}}catch{}},u=()=>{var f;s.pause(),a(),(f=i==null?void 0:i._pauseUndo)==null||f.call(i),i==null||i.classList.add("toast-paused")},l=()=>{var f;s.resume(),o(),(f=i==null?void 0:i._resumeUndo)==null||f.call(i),i==null||i.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(),a(),(p=i==null?void 0:i._pauseUndo)==null||p.call(i),i==null||i.classList.add("toast-paused"))},m=f=>{var p;r.contains(f.relatedTarget)||(s.resume(),o(),(p=i==null?void 0:i._resumeUndo)==null||p.call(i),i==null||i.classList.remove("toast-paused"))};r.addEventListener("mouseenter",u),r.addEventListener("mouseleave",l),r.addEventListener("focusin",c),r.addEventListener("focusout",m),r._pauseCleanup=()=>{r.removeEventListener("mouseenter",u),r.removeEventListener("mouseleave",l),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,n,r,s,i,a,o,u,l,c,m,f,p,y,d,b,h,w,L,v,I,g,x,S,T,E,M,D;try{if(!t)return;const C=active.get(t),N=pending.get(t);if(N){cancelAnimationFrame(N.rafId),pending.delete(t),emitMetrics();return}const k=queue.findIndex(B=>B.key===t);if(k!==-1){queue.splice(k,1),emitMetrics();return}if(!C)return;if((e=C.timer)==null||e.clear(),(r=(n=C.outer)==null?void 0:n._pauseCleanup)==null||r.call(n),(i=(s=C.toast)==null?void 0:s._cleanupCloseButton)==null||i.call(s),(o=(a=C.toast)==null?void 0:a._cleanupCTA)==null||o.call(a),(l=(u=C.toast)==null?void 0:u._cleanupUndo)==null||l.call(u),(m=(c=C.toast)==null?void 0:c._cleanupSwipe)==null||m.call(c),(p=(f=C.toast)==null?void 0:f._cleanupFocusTrap)==null||p.call(f),(d=(y=C.toast)==null?void 0:y._cleanup)==null||d.call(y),(b=C.toast)!=null&&b._progressAnimation){try{C.toast._progressAnimation.cancel()}catch{}C.toast._progressAnimation=null}const A=(h=C.outer)==null?void 0:h.querySelector(".toast-count-badge");A!=null&&A._scaleTimer&&(clearTimeout(A._scaleTimer),A._scaleTimer=null);const _=(w=C.toast)==null?void 0:w.querySelector("button, a");(L=_==null?void 0:_._cleanup)==null||L.call(_),active.delete(t),visibleCount=Math.max(0,visibleCount-1),emitMetrics(),A&&A.remove();const W=((v=C.toast)==null?void 0:v._animationDuration)??400,R=Math.min(W,300);if(C.toast){if(!getConfig().disableInlineStyles){const B=String(((I=C.options)==null?void 0:I.position)||((x=(g=C.outer)==null?void 0:g.parentElement)==null?void 0:x.id)||"").toLowerCase(),F=B.includes("top"),j=B.includes("left"),z=B.includes("right"),$=String(((S=C.options)==null?void 0:S.animationType)||"").toLowerCase().trim();let H="translateY(20px)";shouldReduceMotion()?(C.toast.style.transition="none",C.toast.style.opacity="0"):($==="fade"?H="none":$==="zoom"||$==="scale"?H="scale(0.75)":$==="flip"?H="perspective(600px) rotateX(-45deg)":$==="slide"?H=j?"translateX(-100%)":z?"translateX(100%)":F?"translateY(-100%)":"translateY(100%)":$==="bounce"?H=F?"translateY(-36px) scale(0.9)":"translateY(36px) scale(0.9)":((T=C.options)!=null&&T.spring||$==="spring")&&(H=F?"translateY(-28px) scale(0.94)":"translateY(28px) scale(0.94)"),C.toast.style.transition=`opacity ${R}ms ease-in, transform ${R}ms ease-in`,C.toast.style.opacity="0",C.toast.style.transform=H)}C.toast.classList.remove("active")}const P=(E=C.outer)==null?void 0:E.parentElement;if(await removeWithTransition(C.outer,C.toast,R),P&&P.children.length===0&&((M=P.id)!=null&&M.startsWith("toast-container-")))try{(D=P._stackedCleanup)==null||D.call(P),unregisterContainer(P.id),P.remove()}catch{}else P&&P.getAttribute("data-stacked")==="true"&&updateStackedLayout(P);await drainQueue()}catch(C){console.error("Closing Toast failed!: ",C)}}let isDraining=!1;async function drainQueue(){var t,e;if(!isDraining){isDraining=!0;try{const n=getConfig();for((n.priorityQueue||typeof n.priorityScorer=="function"||queue.some(r=>{var s,i;return((s=r.options)==null?void 0:s.priorityQueue)||typeof((i=r.options)==null?void 0:i.priority)=="number"}))&&queue.length>1&&queue.sort((r,s)=>getItemPriority(s)-getItemPriority(r));visibleCount<n.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,n=400){return t?new Promise(r=>{let s=!1,i=null;const a=e||t.firstElementChild||t,o=()=>{var c;if(!s){s=!0,i&&(clearTimeout(i),i=null);try{(c=a==null?void 0:a.removeEventListener)==null||c.call(a,"transitionend",u,!0)}catch{}removeElement(t).catch(console.error),r()}};if(shouldReduceMotion()||n<=0){o();return}const u=c=>{try{if(c.target!==a)return;(c.propertyName==="transform"||(!a.style.transform||a.style.transform==="none"||a.style.transform==="initial")&&c.propertyName==="opacity")&&o()}catch(m){console.error("removeWithTransition error:",m)}};if(!a)return o();try{a.addEventListener("transitionend",u,!0)}catch(c){console.error("removeWithTransition error:",c)}const l=n+100;i=setTimeout(o,l),typeof(i==null?void 0:i.unref)=="function"&&i.unref()}):Promise.resolve()}async function updateBadge({outer:t,count:e}){var n;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((n=r._scaleTimer)==null?void 0:n.unref)=="function"&&r._scaleTimer.unref())}catch(s){console.error("updateBadge animation error:",s)}}async function updateToastByKey(t,e={}){var n,r,s,i;if(!t||typeof e!="object"||e===null)return;if(pending.has(t)){const d=pending.get(t);d.options={...d.options,...e};return}const a=queue.find(d=>d.key===t);if(a){a.options={...a.options,...e};return}const o=active.get(t);if(!o||!o.toast)return;const u={...o.options};o.options={...o.options,...e};const l=o.toast,c=l._messageSpan||l.querySelector(".toast-message")||l.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,h=(e.type==="success"||e.type==="error"||e.type==="warning"||e.type==="info")&&e.showLoader!==!0;if(c){const w=c.querySelector(".toast-loader");if(c.innerHTML="",w&&e.showLoader!==!1&&e.loader!==null&&!h){c.appendChild(w);const L=document.createElement("span");L.style.display="inline-block",L.style.width="8px",c.appendChild(L)}if(b&&d.trim().length>0)try{const L=sanitizeHtml(d),v=document.createElement("div");for(v.innerHTML=L;v.firstChild;)c.appendChild(v.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();l.className=l.className.replace(/\btoast-(info|success|error|warning)\b/g,`toast-${d}`);const b=d==="error";if(e.role?l.setAttribute("role",e.role):l.setAttribute("role","alert"),l.setAttribute("aria-live",e.ariaLive||(b?"assertive":"polite")),!e.backgroundColor){const h={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"};h[d]&&(l.style.background=h[d])}}if(e.icon!==void 0||e.type!==void 0){const d=l==null?void 0:l.querySelector(".toast-icon");d&&d.remove();const b={...o.options,...e},h=createToastIcon(b);h&&(c?l.insertBefore(h,c):l.appendChild(h))}if(e.backgroundColor&&(l.style.background=e.backgroundColor),e.textColor)l.style.color=e.textColor,c&&(c.style.color=e.textColor);else if(e.type||e.backgroundColor){const d=l.style.background;if(d){const b=getDynamicAccessibleTextColorHex(d);l.style.color=b,c&&(c.style.color=b)}}if(e.borderRadius!==void 0){const d=typeof e.borderRadius=="number"?`${e.borderRadius}px`:e.borderRadius;l.style.borderRadius=d}if(e.maxWidth!==void 0){const d=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth;l.style.maxWidth=d}if(e.fontDirection!==void 0){const d=e.fontDirection!=="auto"?e.fontDirection:"";l.style.direction=d,c&&(c.style.direction=d);const b=d==="rtl";l.querySelectorAll(".toast-cta, .toast-undo-btn, .toast-close-btn").forEach(h=>{h.style.marginLeft=b?"0px":"10px",h.style.marginRight=b?"10px":"0px"})}if(e.fontSize!==void 0){const d=typeof e.fontSize=="number"?`${e.fontSize}px`:e.fontSize;l.style.fontSize=d,c&&(c.style.fontSize=d)}if(e.fontFamily!==void 0&&(l.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;l.style.fontWeight=d,c&&(c.style.fontWeight=d)}if(e.fontLineHeight!==void 0&&(l.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&&l.setAttribute("role",e.role),e.ariaLive!==void 0&&l.setAttribute("aria-live",e.ariaLive),e.className!==void 0){const d=u.className;d&&typeof d=="string"&&l.classList.remove(...d.trim().split(/\s+/)),e.className&&typeof e.className=="string"&&l.classList.add(...e.className.trim().split(/\s+/))}let f=l.querySelector(".toast-progress-bar");if(e.showProgressBar===!1){if(l._progressAnimation){try{l._progressAnimation.cancel()}catch{}l._progressAnimation=null}f&&f.remove(),l._progressBar=null,f=null}else!f&&e.showProgressBar!==!1&&(e.progress!==void 0||e.showProgressBar===!0)&&(createProgressBar(l,{...o.options,...e,showProgressBar:!0}),f=l.querySelector(".toast-progress-bar"));if(f){if(e.progress!==void 0)if(e.progress==="indeterminate"){if(f._isIndeterminate=!0,f._isManualProgress=!1,l._progressAnimation){try{l._progressAnimation.cancel()}catch{}l._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,l,{...o.options,...e});if(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",l._progressAnimation){try{l._progressAnimation.cancel()}catch{}l._progressAnimation=null}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,l._animationType=e.animationType),e.spring!==void 0&&(o.options.spring=e.spring),e.swipeToDismiss!==void 0&&(o.options.swipeToDismiss=e.swipeToDismiss,e.swipeToDismiss===!1?((n=l._cleanupSwipe)==null||n.call(l),l._cleanupSwipe=null):e.swipeToDismiss===!0&&!l._cleanupSwipe&&attachSwipeToDismiss(l,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(l,{duration:d}),await setupPauseOnHover(o),f&&!f._isManualProgress&&!f._isIndeterminate){const b=d+5;if(l._progressAnimation){try{l._progressAnimation.cancel()}catch{}const h=f._isReverse,w=f._finalWidth||"100%",L=h?[{width:"0%"},{width:w}]:[{width:w},{width:"0%"}];l._progressAnimation=f.animate(L,{duration:b,easing:"linear",fill:"forwards",delay:0})}else{f.style.transition=`width ${b}ms linear`;const h=f._isReverse,w=f._finalWidth||"100%";f.style.width=h?w:"0%"}}}else if(o.timer=null,f&&!f._isManualProgress&&!f._isIndeterminate){if(l._progressAnimation){try{l._progressAnimation.cancel()}catch{}l._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(l,{duration:2500}),await setupPauseOnHover(o));if(e.cta!==void 0&&(l._cleanupCTA&&(l._cleanupCTA(),l._cleanupCTA=null),l.querySelectorAll(".toast-cta").forEach(d=>d.remove()),e.cta&&typeof e.cta=="object")){const d={...o.options,...e};createCTA(l,d,closeToast)}if(e.undo!==void 0&&(l._cleanupUndo&&(l._cleanupUndo(),l._cleanupUndo=null),l.querySelectorAll(".toast-undo-btn").forEach(d=>d.remove()),e.undo)){const d={...o.options,...e};createUndoAction(l,d,closeToast)}if(e.showCloseButton!==void 0){const d=l.querySelector(".toast-close-btn");if(e.showCloseButton===!1)l._cleanupCloseButton&&(l._cleanupCloseButton(),l._cleanupCloseButton=null),d&&d.remove();else if(e.showCloseButton===!0&&!d){const b={...o.options,...e};createCloseButton(l,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=l.closest('[id^="toast-container-"]');y&&(e.stacked===!0?(y.setAttribute("data-stacked","true"),updateStackedLayout(y)):e.stacked===!1?(y.removeAttribute("data-stacked"),(i=y._stackedCleanup)==null||i.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 n=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{...n,message:String(t)}:t instanceof Error?{...n,message:t.message||String(t)}:typeof t=="object"&&t!==null&&!Array.isArray(t)?{...n,...t}:{...n}}async function sanitizeToastOptions(t){var e;const n=normalizeToastOptions(t),r=getConfig(),s=String((n==null?void 0:n.position)??r.defaultPosition).toLowerCase().trim(),i=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:i},...n};o.message=(n==null?void 0:n.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=(n==null?void 0:n.progressBarColor)||(n==null?void 0:n.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"],n={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(n[r]=s.trim());Object.keys(n).length>0&&(defaultColors={...defaultColors,...n})}}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"],n={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(n[r]=s.trim());Object.keys(n).length>0&&(customDefaultMessages={...customDefaultMessages,...n})}}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 n=normalizeToastOptions(t,e),r=await runWithClosePriority(()=>originalCreateToast(n));return{id:r,dismiss:()=>r?closeToastByKey(r):Promise.resolve(),update:s=>r?updateToastByKey(r,s):Promise.resolve()}}createToastWithPriority.success=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"success"})},createToastWithPriority.error=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"error"})},createToastWithPriority.warning=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"warning"})},createToastWithPriority.info=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"info"})},createToastWithPriority.loading=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({type:"info",showLoader:!0,duration:0,showProgressBar:!1,pauseOnHover:!1,...n})},createToastWithPriority.custom=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({allowHtml:!0,...n})};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={},n={}){const r=e&&typeof e=="object"?e:{},s=n&&typeof n=="object"?n:{},i=r.loading??"Loading...",a=typeof i=="object"&&i!==null&&!Array.isArray(i)?{...s,type:"info",duration:TOAST_PROMISE_LOADING_DURATION_MS,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0,...i}:{...s,type:"info",message:String(i),duration:TOAST_PROMISE_LOADING_DURATION_MS,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0},o=await createToastWithPriority(a),u={...s,pauseOnHover:s.pauseOnHover};try{const c=await(typeof t=="function"?t():t);if(o&&typeof o.dismiss=="function")try{await o.dismiss()}catch{}const m=typeof r.success=="function"?r.success(c):r.success??"Done!",f=typeof m=="object"&&m!==null&&!Array.isArray(m)?{...u,type:"success",...m}:{...u,type:"success",message:String(m)};return await createToastWithPriority(f),c}catch(l){if(o&&typeof o.dismiss=="function")try{await o.dismiss()}catch{}const c=typeof r.error=="function"?r.error(l):r.error??"Something went wrong.",m=typeof c=="object"&&c!==null&&!Array.isArray(c)?{...u,type:"error",...c}:{...u,type:"error",message:String(c)};throw await createToastWithPriority(m),l}}createToastWithPriority.promise=toastPromise,createToastWithPriority.dismiss=dismissToast,createToastWithPriority.dismissAll=noopAll,createToastWithPriority.clear=noopAll;const version="4.0.0";function initKeyboardShortcuts(t=typeof window<"u"?window:null){if(!t||!t.document||t.__customizableToastEscapeAttached)return;t.__customizableToastEscapeAttached=!0;const e=n=>{if(n.key==="Escape"||n.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(n.key==="F6"||(n.altKey||n.metaKey)&&(n.key==="t"||n.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 i=s[s.length-1],a=i.querySelector("button, a, [tabindex='0']");a&&typeof a.focus=="function"?a.focus():typeof i.focus=="function"&&i.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)}class ToastService{success(e,n){return createToastWithPriority.success(e,n)}error(e,n){return createToastWithPriority.error(e,n)}warning(e,n){return createToastWithPriority.warning(e,n)}info(e,n){return createToastWithPriority.info(e,n)}loading(e,n){return createToastWithPriority.loading(e,n)}custom(e,n){return createToastWithPriority.custom(e,n)}show(e){return createToastWithPriority(e)}promise(e,n,r){return toastPromise(e,n,r)}dismiss(e){return dismissToast(e)}dismissAll(){return dismissAll()}clear(){return clear()}setConfig(e){return setConfig(e)}getConfig(){return getConfig()}resetConfig(){return resetConfig()}}ToastService.\u0275fac=function(e){return new(e||ToastService)},ToastService.\u0275prov={token:ToastService,providedIn:"root",factory:ToastService.\u0275fac};let cachedInstance=null;function injectToast(){return cachedInstance||(cachedInstance=new ToastService),cachedInstance}const toast=injectToast();exports.ToastService=ToastService,exports.clear=clear,exports.createToast=createToastWithPriority,exports.dismiss=dismissToast,exports.dismissAll=dismissAll,exports.getConfig=getConfig,exports.injectToast=injectToast,exports.resetConfig=resetConfig,exports.setConfig=setConfig,exports.toast=toast,exports.toastPromise=toastPromise;
|
|
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 n;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 i=s;if(!isDocumentedPosition(s)&&!LEGACY_POSITIONS.has(s)&&(console.warn(`Unknown position "${e.position}", defaulting to "bottom-right"`),i="bottom-right"),resetPositionClasses(t),(n=t.classList)==null||n.add("toast-position-"+i),getConfig().disableInlineStyles)return;resetContainerStyles(t);const l=parsePosition(i);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(),n=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"),i=e.startsWith("left")||e.endsWith("left"),l=e.startsWith("right")||e.endsWith("right"),o=e.includes("center");return{hasTop:r,hasBottom:s,hasLeft:i,hasRight:l,hasCenter:o,hasFullWidth:n}}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,n){this.callback=typeof e=="function"?e:()=>{};const r=n===1/0,s=Number.isFinite(n)&&n>=0?n: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(n){console.error("PausableTimer callback error:",n)}},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,n,r,s,i,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=(n=t==null?void 0:t.priority)==null?void 0:n.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:(i=t==null?void 0:t.options)==null?void 0:i.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 n=Array.from(t.children),r=n.length,s=!!t._isExpanded,i=!!(t.id&&t.id.includes("top"));n.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=i?10:-10;l.style.transform=`scale(0.95) translateY(${c}px)`,l.style.marginTop=i?"0px":"-55px",l.style.marginBottom=i?"-55px":"0px",l.style.opacity="0.9",l.style.zIndex="20",l.style.pointerEvents="auto"}else if(u===2){const c=i?20:-20;l.style.transform=`scale(0.90) translateY(${c}px)`,l.style.marginTop=i?"0px":"-55px",l.style.marginBottom=i?"-55px":"0px",l.style.opacity="0.75",l.style.zIndex="10",l.style.pointerEvents="auto"}else{const c=i?30:-30;l.style.transform=`scale(0.85) translateY(${c}px)`,l.style.marginTop=i?"0px":"-55px",l.style.marginBottom=i?"-55px":"0px",l.style.opacity="0",l.style.zIndex="1",l.style.pointerEvents="none"}})}function hashString(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);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 i=normalizePositionKey(e.position||"bottom-right");return`tag:${String(e.tag).trim()}:${i}`}if(e.groupId!==void 0&&e.groupId!==null&&e.groupId!==""){const i=normalizePositionKey(e.position||"bottom-right");return`group:${String(e.groupId).trim()}:${i}`}const n=String(e.type||"info").trim().toLowerCase(),r=hashString(String(e.message||"")).toString(16),s=normalizePositionKey(e.position||"bottom-right");return`${n}|${r}|${s}`}async function showToast(t={}){var e,n;try{const r=makeKey(t);if(active.has(r)){const i=active.get(r);if(!i)throw new Error(`Active toast with key ${r} not found`);return i.count++,(t.tag||t.groupId)&&t.message&&((e=i.toast)!=null&&e._messageSpan)&&(i.toast._messageSpan.textContent=String(t.message),i.toast._messageSpan.title=String(t.message)),(n=i.timer)==null||n.clear(),i.timer=createDismissTimer(i.toast,t),await setupPauseOnHover(i),await updateBadge(i),emitMetrics(),r}if(pending.has(r)){const i=pending.get(r);if(!i)throw new Error(`Pending toast with key ${r} not found`);return i.count++,(t.tag||t.groupId)&&t.message&&(i.options={...i.options,...t}),r}const s={options:t,count:1,rafId:0};return pending.set(r,s),s.rafId=requestAnimationFrame(async()=>{var i,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((i=o.options)==null?void 0:i.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,n){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 i=document.createElement("div");i.className="toast-outer-wrapper",getConfig().disableInlineStyles||Object.assign(i.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),i.appendChild(l),r.id.includes("toast-container-")&&(r.appendChild(i),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:i,toast:s,options:t,count:Math.max(1,Math.floor(n??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 i=Array.from(s.children||[]);if(i.length===0)return;const l=i.at(-1);l&&(t=l.querySelector('[id^="toast-"]')||l)}),!t)return;const n=t._key?t:t.querySelector('[id^="toast-"]')||t;await closeToast(n)}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(n){console.warn("closeAllToasts: failed to close one toast:",n)}}))}catch(t){console.error("closeAllToasts failed:",t)}}const dismiss=dismissMostRecent,noop=closeAllToasts;function createDismissTimer(t,e){const n=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(n)&&n>0?n:2500)+5,i=new PausableTimer(()=>{closeToast(t).catch(console.error)},s);return i.start(),i}async function setupPauseOnHover(t){var e,n;if(!t.pauseOnHover||!t.outer||!t.timer)return;(n=(e=t.outer)._pauseCleanup)==null||n.call(e);const{outer:r,timer:s,toast:i}=t,l=()=>{if(i!=null&&i._progressAnimation)try{i._progressAnimation.pause()}catch{}else if(i!=null&&i._progressBar)try{if(i._progressBar._isIndeterminate)i._progressBar.style.animationPlayState="paused";else if(!i._progressBar._isManualProgress){const f=window.getComputedStyle(i._progressBar).width;i._progressBar._pausedWidth=f,i._progressBar.style.transition="none",i._progressBar.style.width=f}}catch{}},o=()=>{var f;if(i!=null&&i._progressAnimation)try{i._progressAnimation.play()}catch{}else if(i!=null&&i._progressBar)try{if(i._progressBar._isIndeterminate)i._progressBar.style.animationPlayState="running";else if(!i._progressBar._isManualProgress){if(i._progressBar._pausedWidth){const p=((f=s.getRemainingTime)==null?void 0:f.call(s))??1e3,y=i._progressBar._isReverse,d=i._progressBar._finalWidth||"100%";i._progressBar.style.transition=`width ${Math.max(0,p)}ms linear`,i._progressBar.offsetWidth,i._progressBar.style.width=y?d:"0%",i._progressBar._pausedWidth=null}}}catch{}},u=()=>{var f;s.pause(),l(),(f=i==null?void 0:i._pauseUndo)==null||f.call(i),i==null||i.classList.add("toast-paused")},a=()=>{var f;s.resume(),o(),(f=i==null?void 0:i._resumeUndo)==null||f.call(i),i==null||i.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=i==null?void 0:i._pauseUndo)==null||p.call(i),i==null||i.classList.add("toast-paused"))},m=f=>{var p;r.contains(f.relatedTarget)||(s.resume(),o(),(p=i==null?void 0:i._resumeUndo)==null||p.call(i),i==null||i.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,n,r,s,i,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=(n=h.outer)==null?void 0:n._pauseCleanup)==null||r.call(n),(i=(s=h.toast)==null?void 0:s._cleanupCloseButton)==null||i.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 F=(v=h.toast)==null?void 0:v.querySelector("button, a");(w=F==null?void 0:F._cleanup)==null||w.call(F),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 $="translateY(20px)";if(shouldReduceMotion())h.toast.style.transition="none",h.toast.style.opacity="0";else{R==="fade"?$="none":R==="pop"?$="scale(0.6)":R==="zoom"||R==="scale"?$="scale(0.75)":R==="flip"?$="perspective(600px) rotateX(-45deg)":R==="slide"?$=U?"translateX(-100%)":Y?"translateX(100%)":W?"translateY(-100%)":"translateY(100%)":R==="bounce"?$=W?"translateY(-36px) scale(0.9)":"translateY(36px) scale(0.9)":((A=h.options)!=null&&A.spring||R==="spring")&&($=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=$}}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 n=getConfig();for((n.priorityQueue||typeof n.priorityScorer=="function"||queue.some(r=>{var s,i;return((s=r.options)==null?void 0:s.priorityQueue)||typeof((i=r.options)==null?void 0:i.priority)=="number"}))&&queue.length>1&&queue.sort((r,s)=>getItemPriority(s)-getItemPriority(r));visibleCount<n.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,n=400){return t?new Promise(r=>{let s=!1,i=null;const l=e||t.firstElementChild||t,o=()=>{var c;if(!s){s=!0,i&&(clearTimeout(i),i=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()||n<=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=n+100;i=setTimeout(o,a),typeof(i==null?void 0:i.unref)=="function"&&i.unref()}):Promise.resolve()}async function updateBadge({outer:t,count:e}){var n;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((n=r._scaleTimer)==null?void 0:n.unref)=="function"&&r._scaleTimer.unref())}catch(s){console.error("updateBadge animation error:",s)}}async function updateToastByKey(t,e={}){var n,r,s,i;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?((n=a._cleanupSwipe)==null||n.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"),(i=y._stackedCleanup)==null||i.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 n=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{...n,message:String(t)}:t instanceof Error?{...n,message:t.message||String(t)}:typeof t=="object"&&t!==null&&!Array.isArray(t)?{...n,...t}:{...n}}async function sanitizeToastOptions(t){var e;const n=normalizeToastOptions(t),r=getConfig(),s=String((n==null?void 0:n.position)??r.defaultPosition).toLowerCase().trim(),i=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:i},...n};o.message=(n==null?void 0:n.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=(n==null?void 0:n.progressBarColor)||(n==null?void 0:n.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"],n={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(n[r]=s.trim());Object.keys(n).length>0&&(defaultColors={...defaultColors,...n})}}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"],n={};for(const[r,s]of Object.entries(t))e.includes(r)&&typeof s=="string"&&s.trim()&&(n[r]=s.trim());Object.keys(n).length>0&&(customDefaultMessages={...customDefaultMessages,...n})}}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 n=normalizeToastOptions(t,e),r=await runWithClosePriority(()=>originalCreateToast(n));return{id:r,dismiss:()=>r?closeToastByKey(r):Promise.resolve(),update:s=>r?updateToastByKey(r,s):Promise.resolve()}}createToastWithPriority.success=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"success"})},createToastWithPriority.error=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"error"})},createToastWithPriority.warning=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"warning"})},createToastWithPriority.info=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({...n,type:"info"})},createToastWithPriority.loading=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({type:"info",showLoader:!0,duration:0,showProgressBar:!1,pauseOnHover:!1,...n})},createToastWithPriority.custom=(t,e)=>{const n=normalizeToastOptions(t,e);return createToastWithPriority({allowHtml:!0,...n})};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={},n={}){const r=e&&typeof e=="object"?e:{},s=n&&typeof n=="object"?n:{},i=r.loading??"Loading...",l=typeof i=="object"&&i!==null&&!Array.isArray(i)?{...s,type:"info",duration:TOAST_PROMISE_LOADING_DURATION_MS,showProgressBar:!1,pauseOnHover:!1,showLoader:s.showLoader??!0,...i}:{...s,type:"info",message:String(i),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=n=>{if(n.key==="Escape"||n.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(n.key==="F6"||(n.altKey||n.metaKey)&&(n.key==="t"||n.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 i=s[s.length-1],l=i.querySelector("button, a, [tabindex='0']");l&&typeof l.focus=="function"?l.focus():typeof i.focus=="function"&&i.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)}class ToastService{success(e,n){return createToastWithPriority.success(e,n)}error(e,n){return createToastWithPriority.error(e,n)}warning(e,n){return createToastWithPriority.warning(e,n)}info(e,n){return createToastWithPriority.info(e,n)}loading(e,n){return createToastWithPriority.loading(e,n)}custom(e,n){return createToastWithPriority.custom(e,n)}show(e){return createToastWithPriority(e)}promise(e,n,r){return toastPromise(e,n,r)}dismiss(e){return dismissToast(e)}dismissAll(){return dismissAll()}clear(){return clear()}setConfig(e){return setConfig(e)}getConfig(){return getConfig()}resetConfig(){return resetConfig()}}ToastService.\u0275fac=function(e){return new(e||ToastService)},ToastService.\u0275prov={token:ToastService,providedIn:"root",factory:ToastService.\u0275fac};let cachedInstance=null;function injectToast(){return cachedInstance||(cachedInstance=new ToastService),cachedInstance}const toast=injectToast();exports.ToastService=ToastService,exports.clear=clear,exports.createToast=createToastWithPriority,exports.dismiss=dismissToast,exports.dismissAll=dismissAll,exports.getConfig=getConfig,exports.injectToast=injectToast,exports.resetConfig=resetConfig,exports.setConfig=setConfig,exports.toast=toast,exports.toastPromise=toastPromise;
|
|
117
126
|
//# sourceMappingURL=angular.cjs.map
|