customizable-toast-notification 3.6.0 → 3.7.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/README.md CHANGED
@@ -31,17 +31,11 @@ or
31
31
  yarn add customizable-toast-notification
32
32
  ```
33
33
 
34
- ### CDN (UMD Build)
35
-
36
- ```bash
37
- <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@latest/dist/index.umd.js"></script>
38
- ```
39
-
40
34
  ## 🚀 Quick Start
41
35
 
42
36
  ### ES Modules
43
37
 
44
- ```json
38
+ ```bash
45
39
 
46
40
  import { createToast, setDefaultColors, setDefaultMessages } from 'customizable-toast-notification';
47
41
 
@@ -54,11 +48,13 @@ duration: 3000
54
48
 
55
49
  ```
56
50
 
57
- ### CDN/Browser
51
+ ### CDN/Browser (UMD Build)
58
52
 
59
- ```json
53
+ ```bash
54
+ Global Variable Name: customizableToast
60
55
 
61
56
  <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@latest/dist/index.umd.js"></script>
57
+
62
58
  <script> customizableToast.createToast({ message: "Hello from CDN!", type: "success", position: "top-right" }); </script>
63
59
 
64
60
  ```
@@ -89,16 +85,17 @@ Creates and displays a toast notification.
89
85
 
90
86
  #### Position Options
91
87
 
92
- ```josn
88
+ ```bash
93
89
 
94
- - `"top-left"`, `"top-right"`, `"top-center"`
95
- - `"bottom-left"`, `"bottom-right"`, `"bottom-center"`
90
+ - `"top-left"`, `"top-right"`, `"top-center"`, `"top-full-width"`
91
+ - `"left-center"`, `"center"`, `"right-center"`
92
+ - `"bottom-left"`, `"bottom-right"`, `"bottom-center"`, `"bottom-full-width"`
96
93
 
97
94
  ```
98
95
 
99
96
  ### `setDefaultColors(colors)`
100
97
 
101
- ```json
98
+ ```bash
102
99
 
103
100
  Configure default colors for toast types.
104
101
 
@@ -113,7 +110,7 @@ info: "#3b82f6"
113
110
 
114
111
  ### `setDefaultMessages(messages)`
115
112
 
116
- ```json
113
+ ```bash
117
114
  Configure default messages for toast types.
118
115
 
119
116
  setDefaultMessages({
@@ -129,7 +126,7 @@ info: "Here's some information!"
129
126
 
130
127
  ### Basic Toast Types
131
128
 
132
- ```json
129
+ ```bash
133
130
  // Success
134
131
  createToast({ type: "success", message: "Data saved!" });
135
132
 
@@ -146,7 +143,7 @@ createToast({ type: "info", message: "New update available!" });
146
143
 
147
144
  ### Advanced Customization
148
145
 
149
- ```json
146
+ ```bash
150
147
  createToast({
151
148
  message: "File uploading...",
152
149
  type: "info",
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.6.0
3
- * Build: 2025-09-01 13:01:31
4
- * Cache-Buster: 1756731691017
2
+ * Customizable Toast Notifications 3.7.1
3
+ * Build: 2025-09-13 10:09:28
4
+ * Cache-Buster: 1757758168805
5
5
  * Author: Priyanshu Patel
6
6
  * Email: priyanshu.alt191@gmail.com
7
7
  * License: Apache-2.0
@@ -12,23 +12,7 @@
12
12
  * Supports flexible positioning, theming, icons, animations, and timing options
13
13
  * out of the box — with zero dependencies.
14
14
  */
15
- "use strict";async function t(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function n(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body){const n=e.cloneNode(!0);return t.appendChild(n),!0}}catch(t){return!1}}}return!1}async function o(t){return t.backgroundColor&&await async function(t){let e,n,o;if(t.startsWith("#")){const a=t.substring(1);3===a.length?(e=parseInt(a[0]+a[0],16),n=parseInt(a[1]+a[1],16),o=parseInt(a[2]+a[2],16)):(e=parseInt(a.substring(0,2),16),n=parseInt(a.substring(2,4),16),o=parseInt(a.substring(4,6),16))}else if(t.startsWith("rgb")||t.startsWith("rgba")){const a=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);a&&(e=parseInt(a[1]),n=parseInt(a[2]),o=parseInt(a[3]))}else{const a={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!a)throw new Error(`Unsupported color format: ${t}`);e=a[0],n=a[1],o=a[2]}const a=(.2126*e+.7152*n+.0722*o)/255,r=.05;return(Math.max(a,r)+.05)/Math.min(a,r)}(t.backgroundColor)>3.5?"black":"white"}async function a(t,e,n){const o=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const a=document.createElement("span");a.style.position=e.fontPosition,a.style.display="inline-block",a.style.flex="1",a.style.padding=e.fontPadding,a.style.borderRadius=e.fontBorderRadius,a.style.background=e.fontBackgroundColor,a.style.fontFamily=e.fontFamily,a.style.fontSize=e.fontSize,a.style.fontWeight=e.fontWeight,a.style.lineHeight=e.fontLineHeight,a.style.color=e.textColor,a.style.userSelect="text",a.style.wordBreak="break-word",a.style.direction=e.fontDirection,a.style.webkitLineClamp="3",a.style.webkitBoxOrient="vertical",a.style.whiteSpace=e.wrapText?"normal":"nowrap",a.style.display="block",a.style.overflow="hidden",a.style.textOverflow="ellipsis",a.style.lineClamp="3",a.style.boxOrient="vertical",a.style.display="-webkit-box",a.textContent=e.message,a.setAttribute("aria-label","Toast Notification Center"),a.setAttribute("title",e.message),t.appendChild(a),e.showCloseButton&&await async function(t,e,n){const o=document.createElement("button");o.setAttribute("aria-label","Close notification"),o.setAttribute("title","Close"),o.textContent="×",Object.assign(o.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&await async function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function r(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function i(t,n){let o;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return o=await async function(t,n){try{const o=document.createElement(t);return o.id=await e(n),o}catch(t){try{const t="div",n="fallback",o=document.createElement(t);return o.id=await e(n),o.setAttribute("data-original-tag",t),o}catch(t){}}}("div","toast"),await a(o,t,n),o}catch(e){return await r(t,n),o}}let s=[],c=[];async function l(e){try{const o=await async function(e){try{let o=document.getElementById(`toast-container-${e}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(e.position),a=await i(e,d);if(!a)throw new Error("Toast element creation failed!");s.push(a),o.id.includes("toast-container-")&&o.appendChild(a);const r="number"==typeof e.duration&&e.duration>0?e.duration+2:1800,l=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>d(a),r);return void c.push(l)}catch(t){const n=document.querySelector('[id^="toast-container-"]'),o=r(e,d);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(o):alert(t.substring(0,200)))}}async function d(t){if(s.length>0){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}
16
- /**
17
- * @fileoverview A simple toast notification library for any JavaScript framework.
18
- * @name Customizable Toast Notifications
19
- * @author Priyanshu Patel
20
- * @version "3.6.0"
21
- * @build Production
22
- * @license Apache-2.0
23
- * @depends None
24
- * @description A lightweight and fully customizable toast notification library
25
- * designed for seamless integration with any JavaScript or framework-based UI.
26
- * Supports flexible positioning, theming, icons, animations, and timing options
27
- * out of the box — with zero dependencies.
28
- * Author: Priyanshu Patel
29
- * Email: priyanshu.alt191@gmail.com
30
- * Created: July 31, 2024
31
- * License: Apache-2.0
32
- * Dependencies: None
33
- */let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},p={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const y=[];let m=!1;async function f(e={}){try{const a=await async function(t){const e={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",..."object"!=typeof t||Array.isArray(t)?{}:t};e.message=t?.message??e.message;try{e.backgroundColor||(e.backgroundColor=u?.[e.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),e.message=e.message||p?.[e.type]||"No Message Provided!",!e.textColor&&e.backgroundColor&&(e.textColor=await o(e)),!e.progressColor&&e.backgroundColor&&(e.progressColor=await o(e))}catch(t){}"string"!=typeof e.message&&(e.message="No Message Provided!");return e}(e);await async function(e){try{let o=document.getElementById(`toast-container-${e}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(a.position),await l(a)}catch(t){const n="string"==typeof e?.message?`${e.message.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}let g=!1;async function h(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){m||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(m=!0,y.forEach(t=>setTimeout(()=>f(t),2e3)),y.length=0):document.addEventListener("DOMContentLoaded",()=>{m=!0,y.forEach(t=>setTimeout(()=>f(t),2e3)),y.length=0},{once:!0}))}(),m?g?await f(t):(g=!0,setTimeout(await f(t),2e3)):y.push(t))}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function w(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(p={...p,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:h,setDefaultColors:b,setDefaultMessages:w})}catch(t){}exports.createToast=h,exports.noop=function(){d(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=b,exports.setDefaultMessages=w;
15
+ "use strict";async function t(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const o=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,o){if(!o.hasFullWidth)return!1;if(e.maxWidth="100vw",o.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(o.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,o)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,o)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,o)}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function o(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(o){try{return t.insertAdjacentElement("beforeend",e),!0}catch(o){try{if(t===document.body){const o=e.cloneNode(!0);return t.appendChild(o),!0}}catch(t){return!1}}}return!1}async function n(t){if(!t)return"black";try{return await async function(t){if(!t)throw new Error("Color is required");let e,o,n;if(t.startsWith("#")){const r=t.substring(1);if(3===r.length)e=parseInt(r[0]+r[0],16),o=parseInt(r[1]+r[1],16),n=parseInt(r[2]+r[2],16);else{if(6!==r.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const r=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!r)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(r[1]),o=parseInt(r[2]),n=parseInt(r[3])}else{const r={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!r)throw new Error(`Unsupported color format: ${t}`);e=r[0],o=r[1],n=r[2]}if(isNaN(e)||isNaN(o)||isNaN(n))throw new Error(`Invalid color value: ${t}`);const r=(.2126*e+.7152*o+.0722*n)/255,a=.05;return(Math.max(r,a)+.05)/Math.min(r,a)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function r(t,e,o){const n=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:e.maxWidth,opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=n;const r=document.createElement("span");r.style.position=e.fontPosition,r.style.display="inline-block",r.style.flex="1",r.style.padding=e.fontPadding,r.style.borderRadius=e.fontBorderRadius,r.style.background=e.fontBackgroundColor,r.style.fontFamily=e.fontFamily,r.style.fontSize=e.fontSize,r.style.fontWeight=e.fontWeight,r.style.lineHeight=e.fontLineHeight,r.style.color=e.textColor,r.style.userSelect="text",r.style.wordBreak="break-word",r.style.direction=e.fontDirection,r.style.webkitLineClamp="3",r.style.webkitBoxOrient="vertical",r.style.whiteSpace=e.wrapText?"normal":"nowrap",r.style.display="block",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.lineClamp="3",r.style.boxOrient="vertical",r.style.display="-webkit-box",r.textContent=e.message,r.setAttribute("aria-label","Toast Notification Center"),r.setAttribute("title",e.message),t.appendChild(r),e.showCloseButton&&await async function(t,e,o){const n=document.createElement("button");n.setAttribute("aria-label","Close notification"),n.setAttribute("title","Close"),n.textContent="×",Object.assign(n.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),n.onclick=()=>o(t),t.appendChild(n),t._cleanupCloseButton=()=>{n.onclick=null}}(t,e,o),e.showProgressBar&&await async function(t,e){const o=document.createElement("div");Object.assign(o.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(o),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(o),o.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function a(t,e){try{const o=document.createElement("div");return o.id=`emergency-${Date.now()}`,o.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,o._animationDuration=500,o._isEmergencyToast=!0,setTimeout(()=>{try{o.parentNode&&o.parentNode.removeChild(o),e(o)}catch(t){}},t.duration||1800),o}catch(o){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function i(t,o){let n;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return n=await async function(t,o){try{const n=document.createElement(t);return n.id=await e(o),n}catch(t){try{const t="div",o="fallback",n=document.createElement(t);return n.id=await e(o),n.setAttribute("data-original-tag",t),n}catch(t){}}}("div","toast"),await r(n,t,o),n}catch(e){return await a(t,o),n}}let s=[],l=[];async function c(e){try{const n=await async function(e){try{let n=document.getElementById(`toast-container-${e.position}`);return n||(n=document.createElement("div"),n.id=`toast-container-${e.position}`,n.style.position="fixed",n.style.zIndex="9999",await t(n,e),await o(document.body,n)),n}catch(t){return document.body}}(e),r=await i(e,d);if(!r)throw new Error("Toast element creation failed!");s.push(r),n.id.includes("toast-container-")&&n.appendChild(r);const a="number"==typeof e.duration&&e.duration>0?e.duration+2:1800,c=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>d(r),a);return void l.push(c)}catch(t){const o=document.querySelector('[id^="toast-container-"]'),n=a(e,d);return void(o&&o?.id?.includes("toast-container-")?o.appendChild(n):alert(t.substring(0,200)))}}async function d(t){if(s.length>0){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}
16
+ // * @license Apache-2.0
17
+ let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},p={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const f=[];let y=!1;async function m(e={}){try{const r=await async function(t){const e=t?.position?.toLowerCase()?.trim(),o=e?.includes("top-full-width")||e?.includes("bottom-full-width")?"100vw":"400px",r={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:o,..."object"!=typeof t||Array.isArray(t)?{}:t};r.message=t?.message??r.message;try{r.backgroundColor||(r.backgroundColor=u?.[r.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),r.message=r.message||p?.[r.type]||"No Message Provided!",!r.textColor&&r.backgroundColor&&(r.textColor=await n(r.backgroundColor)),!r.progressColor&&r.backgroundColor&&(r.progressColor=await n(r.backgroundColor))}catch(t){}"string"!=typeof r.message&&(r.message="No Message Provided!");return r}(e);await async function(e){try{let n=document.getElementById(`toast-container-${e.position}`);return n||(n=document.createElement("div"),n.id=`toast-container-${e.position}`,n.style.position="fixed",n.style.zIndex="9999",await t(n,e),await o(document.body,n)),n}catch(t){return document.body}}(r),await c(r)}catch(t){const o="string"==typeof e?.message&&null!==e?.message?`${e?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(o)}}let h=!1;async function g(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){y||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0):document.addEventListener("DOMContentLoaded",()=>{y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0},{once:!0}))}(),y?h?await m(t):(h=!0,setTimeout(await m(t),2e3)):f.push(t))}function w(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(p={...p,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:g,setDefaultColors:w,setDefaultMessages:b})}catch(t){}exports.createToast=g,exports.noop=function(){d(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=w,exports.setDefaultMessages=b;
34
18
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/utils/position.js","../src/utils/id.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/components/ToastContainer.js","../src/index.js"],"sourcesContent":["// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container (EXACT same logic as original)\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {string} position - Position string\r\n */\r\nexport async function setPosition(container, position) {\r\n // Reset all position properties first\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n\r\n if (position.includes(\"bottom\")) {\r\n container.style.bottom = \"10px\";\r\n } else if (position.includes(\"top\")) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n if (position.includes(\"right\")) {\r\n container.style.right = \"10px\";\r\n } else if (position.includes(\"left\")) {\r\n container.style.left = \"10px\";\r\n } else if (position.includes(\"center\")) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n }\r\n}\r\n","// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = await generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = await generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n // Emergency fallback removed: avoid using outerHTML (drops listeners & risks XSS).\r\n // Final attempt: clone and append using standard APIs.\r\n try {\r\n if (parent === document.body) {\r\n const clone = child.cloneNode(true);\r\n parent.appendChild(clone);\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport async function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n\r\nexport async function getTextColor(options) {\r\n return options.backgroundColor &&\r\n (await contrast(options.backgroundColor)) > 3.5\r\n ? \"black\"\r\n : \"white\";\r\n}\r\n\r\nasync function contrast(color) {\r\n let r, g, b;\r\n\r\n // If color is in hex format\r\n if (color.startsWith(\"#\")) {\r\n const hex = color.substring(1);\r\n if (hex.length === 3) {\r\n r = parseInt(hex[0] + hex[0], 16);\r\n g = parseInt(hex[1] + hex[1], 16);\r\n b = parseInt(hex[2] + hex[2], 16);\r\n } else {\r\n r = parseInt(hex.substring(0, 2), 16);\r\n g = parseInt(hex.substring(2, 4), 16);\r\n b = parseInt(hex.substring(4, 6), 16);\r\n }\r\n }\r\n // If color is in rgb/rgba format\r\n else if (color.startsWith(\"rgb\") || color.startsWith(\"rgba\")) {\r\n const match = color.match(\r\n /^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/\r\n );\r\n if (match) {\r\n r = parseInt(match[1]);\r\n g = parseInt(match[2]);\r\n b = parseInt(match[3]);\r\n }\r\n }\r\n // If color is a color name\r\n else {\r\n const colorMap = {\r\n black: [0, 0, 0],\r\n white: [255, 255, 255],\r\n // Add more color names as needed\r\n };\r\n const colorArray = colorMap[color.toLowerCase()];\r\n if (colorArray) {\r\n r = colorArray[0];\r\n g = colorArray[1];\r\n b = colorArray[2];\r\n } else {\r\n throw new Error(`Unsupported color format: ${color}`);\r\n }\r\n }\r\n\r\n const l1 = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 255;\r\n const l2 = 0.05;\r\n return (Math.max(l1, l2) + 0.05) / Math.min(l1, l2);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n // Accessibility + avoid innerHTML (XSS surface)\r\n closeButton.setAttribute(\"aria-label\", \"Close notification\");\r\n closeButton.setAttribute(\"title\", \"Close\");\r\n closeButton.textContent = \"×\"; // U+00D7 multiplication sign\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor,\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport async function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport async function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n requestAnimationFrame(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n });\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = await parseAnimationDuration(\r\n options.animationDuration\r\n );\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor,\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: options.borderRadius,\r\n overflow: \"hidden\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: \"400px\",\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${options.animationDuration} ${options.animationEasing}, transform ${options.animationDuration} ${options.animationEasing}`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n // willChange: \"opacity, transform\",\r\n });\r\n\r\n // TODO! Later\r\n // await animateElement(toast, {\r\n // animationType: options.animationType,\r\n // duration: animDurationMs,\r\n // easing: options.animationEasing,\r\n // });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n\r\n // Layout & positioning\r\n messageSpan.style.position = options.fontPosition;\r\n messageSpan.style.display = \"inline-block\"; // ensure consistent layout\r\n messageSpan.style.flex = \"1\";\r\n\r\n // Spacing & container styling\r\n messageSpan.style.padding = options.fontPadding;\r\n messageSpan.style.borderRadius = options.fontBorderRadius;\r\n messageSpan.style.background = options.fontBackgroundColor;\r\n\r\n // Font stack (system + emoji + fallback)\r\n messageSpan.style.fontFamily = options.fontFamily;\r\n\r\n // Font size & readability\r\n messageSpan.style.fontSize = options.fontSize; // minimum for readability\r\n messageSpan.style.fontWeight = options.fontWeight;\r\n messageSpan.style.lineHeight = options.fontLineHeight; // balance readability\r\n\r\n //TODO LATER Icons (auto dark/light fallback)\r\n // messageSpan.style.color =\r\n // options.iconColor ||\r\n // (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n // ? \"#f5f5f5\"\r\n // : \"#111111\");\r\n\r\n // Colors (auto dark/light fallback)\r\n messageSpan.style.color = options.textColor;\r\n\r\n // Accessibility\r\n messageSpan.style.userSelect = \"text\"; // allow copy/paste if needed\r\n messageSpan.style.wordBreak = \"break-word\"; // avoid layout breaking on long strings\r\n messageSpan.style.direction = options.fontDirection; // RTL/LTR auto-detect\r\n // ✅ Multi-line ellipsis (max 3 lines)\r\n messageSpan.style.webkitLineClamp = \"3\"; // maximum 3 lines\r\n messageSpan.style.webkitBoxOrient = \"vertical\";\r\n messageSpan.style.whiteSpace = options.wrapText ? \"normal\" : \"nowrap\"; // allow wrapping if wanted\r\n messageSpan.style.display = \"block\";\r\n messageSpan.style.overflow = \"hidden\";\r\n messageSpan.style.textOverflow = \"ellipsis\";\r\n messageSpan.style.lineClamp = \"3\"; // modern property\r\n messageSpan.style.boxOrient = \"vertical\"; // non-prefixed\r\n messageSpan.style.display = \"-webkit-box\";\r\n // messageSpan.style.mixBlendMode = \"difference\";\r\n // Assign message\r\n messageSpan.textContent = options.message;\r\n messageSpan.setAttribute(\"aria-label\", \"Toast Notification Center\");\r\n messageSpan.setAttribute(\"title\", options.message);\r\n // Add to toast\r\n toast.appendChild(messageSpan);\r\n\r\n // TODO Icon Later\r\n // if (options.icon) {\r\n // createIcon(toast, options);\r\n // }\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n await createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n await createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n await runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message;\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n// CSS injection function\r\nasync function injectToastStyles() {\r\n if (document.getElementById(\"ctoast-styles\")) return; // Already injected\r\n\r\n const style = document.createElement(\"style\");\r\n style.id = \"ctoast-styles\";\r\n style.textContent = `\r\n .ctoast-toast {\r\n padding: 12px 20px;\r\n margin-bottom: 10px;\r\n border-radius: 5px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\r\n min-width: 250px;\r\n max-width: 400px;\r\n opacity: 0;\r\n position: relative;\r\n transform: translateY(20px);\r\n z-index: 9999;\r\n }\r\n\r\n .ctoast-message {\r\n flex: 1;\r\n }\r\n\r\n .ctoast-close {\r\n cursor: pointer;\r\n margin-left: 10px;\r\n font-weight: bold;\r\n background: transparent;\r\n border: none;\r\n }\r\n\r\n .ctoast-progress {\r\n position: absolute;\r\n bottom: 0;\r\n left: 0;\r\n height: 4px;\r\n background: rgba(255,255,255,0.7);\r\n width: 100%;\r\n transform-origin: left;\r\n }\r\n\r\n .ctoast-show {\r\n opacity: 1 !important;\r\n transform: translateY(0) !important;\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n await applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n await createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet emergencyCleanupScheduled = false;\r\nlet currentToast = [];\r\nlet emergencyTimeouts = [];\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport async function showToast(options) {\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = await createToastContainer(options.position);\r\n const toast = await createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast element creation failed!\");\r\n }\r\n\r\n currentToast.push(toast);\r\n\r\n // Append to container\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const cleanUpTime =\r\n typeof options.duration === \"number\" && options.duration > 0\r\n ? options.duration + 2\r\n : 1800; //safety margin\r\n const dismissTimeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n cleanUpTime\r\n );\r\n emergencyTimeouts.push(dismissTimeout);\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\r\n \"Primary toast system failed showing emergency toast:\",\r\n primaryError\r\n );\r\n const elContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n const emergencyToast = createEmergencyToast(options, closeToast);\r\n elContainer && elContainer?.id?.includes(\"toast-container-\")\r\n ? elContainer.appendChild(emergencyToast)\r\n : alert(primaryError.substring(0, 200));\r\n return;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Created Simple Toast!\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nexport async function closeToast(toast) {\r\n if (currentToast.length > 0) {\r\n const index = currentToast.indexOf(toast);\r\n if (index !== -1) {\r\n currentToast.splice(index, 1);\r\n }\r\n }\r\n await removeElement(toast);\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nasync function performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = [];\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.pop();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n const cleanUpTime = typeof duration === \"number\" ? duration + 2 : 1800; //safety margin\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, cleanUpTime);\r\n\r\n emergencyTimeouts.push(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nasync function forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id^=\"toast-\"]:not([id*=\"container\"]), [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = [];\r\n }\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport async function createToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, position);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// src/index.js\r\n/**\r\n * @fileoverview A simple toast notification library for any JavaScript framework.\r\n * @name Customizable Toast Notifications\r\n * @author Priyanshu Patel\r\n * @version __VERSION__\r\n * @build Production\r\n * @license Apache-2.0\r\n * @depends None\r\n * @description A lightweight and fully customizable toast notification library\r\n * designed for seamless integration with any JavaScript or framework-based UI.\r\n * Supports flexible positioning, theming, icons, animations, and timing options\r\n * out of the box — with zero dependencies.\r\n * Author: Priyanshu Patel\r\n * Email: priyanshu.alt191@gmail.com\r\n * Created: July 31, 2024\r\n * License: Apache-2.0\r\n * Dependencies: None\r\n */\r\n\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\nimport { appendChild, getTextColor } from \"./utils/dom.js\";\r\nimport { setPosition } from \"./utils/position.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\n// Toast queue for calls before DOM ready\r\nconst pendingToasts = [];\r\n\r\n// Flag to indicate DOM ready for toast execution\r\nlet domReady = false;\r\n\r\n// DOM ready check\r\nasync function checkDOMReady() {\r\n if (domReady) return;\r\n\r\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\r\n if (\r\n document.readyState === \"complete\" ||\r\n document.readyState === \"interactive\"\r\n ) {\r\n domReady = true;\r\n // Flush queued toasts after 2s delay\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n } else {\r\n // Wait for DOMContentLoaded\r\n document.addEventListener(\r\n \"DOMContentLoaded\",\r\n () => {\r\n domReady = true;\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n },\r\n { once: true }\r\n );\r\n }\r\n }\r\n}\r\n\r\n// Core toast creation logic\r\nasync function createToastNow(options = {}) {\r\n try {\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n await createFirstToastContainer(sanitizedOptions.position);\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n const safeMessage =\r\n typeof options?.message === \"string\"\r\n ? `${options.message.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\nlet initialDelayDone = false; // flag to ensure single execution\r\n\r\n// Public API\r\nasync function createToast(options = {}) {\r\n // Check browser environment\r\n const isBrowser =\r\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\r\n\r\n if (!isBrowser) {\r\n console.warn(\r\n \"ToastNotification: running in non-browser environment, no DOM available.\"\r\n );\r\n return;\r\n }\r\n\r\n // Check if DOM ready\r\n await checkDOMReady();\r\n\r\n if (!domReady) {\r\n // Queue for later execution\r\n pendingToasts.push(options);\r\n return;\r\n }\r\n\r\n // If DOM ready → execute after 2s delay\r\n if (!initialDelayDone) {\r\n // First call → wait 2 seconds\r\n initialDelayDone = true;\r\n setTimeout(await createToastNow(options), 2000);\r\n } else {\r\n // Subsequent calls → run immediately\r\n await createToastNow(options);\r\n }\r\n}\r\n\r\nasync function createFirstToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, position);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n\r\n/**\r\n * Sanitizes and normalizes toast options.\r\n * Fills in defaults, validates input, and ensures colors & messages are set.\r\n * @param {Object} options - User-provided toast options\r\n * @returns {Promise<Object>} final sanitized toast options\r\n */\r\nasync function sanitizeToastOptions(options) {\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n borderRadius: \"50px\",\r\n backgroundColor: undefined,\r\n textColor: undefined,\r\n showCloseButton: true,\r\n animationDuration: \"0.4s\",\r\n animationType: \"fade\",\r\n animationEasing: \"ease\",\r\n showProgressBar: true,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n fontPosition: \"relative\",\r\n fontPadding: undefined,\r\n fontBorderRadius: undefined,\r\n fontBackgroundColor: undefined,\r\n fontFamily:\r\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\r\n fontSize: \"14px\",\r\n fontWeight: \"400\",\r\n fontLineHeight: \"1.4\",\r\n fontDirection: \"auto\",\r\n wrapText: \"normal\",\r\n };\r\n\r\n // Merge defaults with user options\r\n const final = {\r\n ...defaults,\r\n ...(typeof options === \"object\" && !Array.isArray(options) ? options : {}),\r\n };\r\n\r\n // Ensure message property separately\r\n final.message = options?.message ?? final.message;\r\n\r\n try {\r\n // Background color fallback based on type or system preference\r\n if (!final.backgroundColor) {\r\n final.backgroundColor =\r\n defaultColors?.[final.type] ??\r\n (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n ? \"#f5f5f5\"\r\n : \"#111111\");\r\n }\r\n\r\n // Default message if not provided\r\n final.message =\r\n final.message || defaultMessages?.[final.type] || \"No Message Provided!\";\r\n\r\n // Ensure textColor is set\r\n if (!final.textColor && final.backgroundColor) {\r\n final.textColor = await getTextColor(final);\r\n }\r\n\r\n // Ensure progressColor is set\r\n if (!final.progressColor && final.backgroundColor) {\r\n final.progressColor = await getTextColor(final);\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Safety check for message type\r\n if (typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","setPosition","container","position","style","top","bottom","left","right","transform","includes","generateUniqueId","prefix","Date","now","Math","floor","random","appendChild","parent","child","contains","error","insertAdjacentElement","fallbackError","document","body","clone","cloneNode","emergencyError","getTextColor","options","backgroundColor","color","r","g","b","startsWith","hex","substring","length","parseInt","match","colorArray","black","white","toLowerCase","Error","l1","l2","max","min","contrast","applyRichStyling","toast","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","padding","marginBottom","borderRadius","overflow","display","alignItems","justifyContent","boxShadow","minWidth","maxWidth","opacity","transition","animationEasing","zIndex","_animationDuration","messageSpan","createElement","fontPosition","flex","fontPadding","fontBorderRadius","fontBackgroundColor","fontFamily","fontSize","fontWeight","lineHeight","fontLineHeight","textColor","userSelect","wordBreak","direction","fontDirection","webkitLineClamp","webkitBoxOrient","whiteSpace","wrapText","textOverflow","lineClamp","boxOrient","textContent","message","setAttribute","showCloseButton","closeButton","border","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","requestAnimationFrame","runToastAnimation","createEmergencyToast","emergency","id","innerHTML","_isEmergencyToast","parentNode","removeChild","alert","alertError","createToastElement","querySelector","tagName","fallbackTag","fallbackPrefix","fallbackEl","createElementWithId","currentToast","emergencyTimeouts","showToast","toastContainer","getElementById","createToastContainer","closeToast","push","cleanUpTime","dismissTimeout","fn","delay","safeSetTimeout","primaryError","elContainer","emergencyToast","index","indexOf","splice","remove","pointerEvents","hideError","removeElement","defaultColors","success","warning","info","defaultMessages","pendingToasts","domReady","createToastNow","sanitizedOptions","final","type","undefined","animationType","Array","isArray","window","matchMedia","matches","sanitizeToastOptions","createFirstToastContainer","safeMessage","initialDelayDone","createToast","readyState","forEach","addEventListener","once","checkDOMReady","setDefaultColors","colors","setDefaultMessages","messages","customizableToast"],"mappings":";;;;;;;;;;;;;;aAQOA,eAAeC,EAAYC,EAAWC,GAE3CD,EAAUE,MAAMC,IAAM,OACtBH,EAAUE,MAAME,OAAS,OACzBJ,EAAUE,MAAMG,KAAO,OACvBL,EAAUE,MAAMI,MAAQ,OACxBN,EAAUE,MAAMK,UAAY,OAExBN,EAASO,SAAS,UACpBR,EAAUE,MAAME,OAAS,OAChBH,EAASO,SAAS,SAC3BR,EAAUE,MAAMC,IAAM,QAGpBF,EAASO,SAAS,SACpBR,EAAUE,MAAMI,MAAQ,OACfL,EAASO,SAAS,QAC3BR,EAAUE,MAAMG,KAAO,OACdJ,EAASO,SAAS,YAC3BR,EAAUE,MAAMC,IAAM,MACtBH,EAAUE,MAAMG,KAAO,MACvBL,EAAUE,MAAMK,UAAY,wBAEhC,CCvBOT,eAAeW,EAAiBC,GACrC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CC0BOjB,eAAekB,EAAYC,EAAQC,GACxC,IAAKD,IAAWC,EAAO,OAAO,EAG9B,IACE,OAAKD,EAAOE,SAASD,IACnBD,EAAOD,YAAYE,IAGd,CACT,CAAE,MAAOE,GAIP,IAEE,OADAH,EAAOI,sBAAsB,YAAaH,IACnC,CACT,CAAE,MAAOI,GAMP,IACE,GAAIL,IAAWM,SAASC,KAAM,CAC5B,MAAMC,EAAQP,EAAMQ,WAAU,GAE9B,OADAT,EAAOD,YAAYS,IACZ,CACT,CACF,CAAE,MAAOE,GAEP,OAAO,CACT,CACF,CACF,CACA,OAAO,CACT,CAwFO7B,eAAe8B,EAAaC,GACjC,OAAOA,EAAQC,uBAMjBhC,eAAwBiC,GACtB,IAAIC,EAAGC,EAAGC,EAGV,GAAIH,EAAMI,WAAW,KAAM,CACzB,MAAMC,EAAML,EA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J,GAAU,MAE5C+I,EAActI,OAAS,GAGvBf,SAASyK,iBACP,mBACA,KACEnB,GAAW,EACXD,EAAcmB,QAASlK,GACrB4F,WAAW,IAAMqD,EAAejJ,GAAU,MAE5C+I,EAActI,OAAS,GAEzB,CAAE2J,MAAM,IAIhB,CAoCQC,GAEDrB,EAOAe,QAMGd,EAAejJ,IAJrB+J,GAAmB,EACnBnE,iBAAiBqD,EAAejJ,GAAU,MAR1C+I,EAAcrB,KAAK1H,GAavB,CAyGA,SAASsK,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBhB,MAAMC,QAAQe,KACzD7B,EAAgB,IAAKA,KAAkB6B,GAE3C,CAAE,MAAOhL,GAET,CACF,CAKA,SAASiL,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BlB,MAAMC,QAAQiB,KAC7D3B,EAAkB,IAAKA,KAAoB2B,GAE/C,CAAE,MAAOlL,GAET,CACF,CAWA,IAEwB,oBAAXkK,SACTA,OAAOiB,kBAAoB,CACzBV,cACAM,mBACAE,sBAGN,CAAE,MAAOjL,GAET,oCApBA,WAEEkI,EADc/H,SAASmH,cAAc,yCAEvC"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/position.js","../src/utils/id.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/components/ToastContainer.js","../src/index.js"],"sourcesContent":["// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {Object} options - Options object containing position\r\n * @returns {Promise<void>}\r\n */\r\nexport async function setPosition(container, options) {\r\n if (!container || !options.position) {\r\n throw new Error(\"Invalid container or position!\");\r\n }\r\n\r\n resetContainerStyles(container);\r\n const positionFlags = parsePosition(options.position);\r\n\r\n if (handleFullWidthPositions(container, options, positionFlags)) return;\r\n if (handleCenterPositions(container, positionFlags)) return;\r\n\r\n applyStandardPositioning(container, positionFlags);\r\n}\r\n\r\n/**\r\n * Reset all position-related styles\r\n * @param {HTMLElement} container\r\n */\r\nfunction resetContainerStyles(container) {\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n}\r\n\r\n/**\r\n * Parse position string into boolean flags\r\n * @param {string} position\r\n * @returns {Object} Position flags\r\n */\r\nfunction parsePosition(position) {\r\n const pos = position.toLowerCase().trim();\r\n return {\r\n hasTop: pos.includes(\"top\"),\r\n hasBottom: pos.includes(\"bottom\") || pos.includes(\"below\"),\r\n hasLeft: pos.includes(\"left\"),\r\n hasRight: pos.includes(\"right\"),\r\n hasCenter: pos.includes(\"center\"),\r\n hasFullWidth:\r\n pos.includes(\"top-full-width\") ||\r\n pos.includes(\"bottom-full-width\") ||\r\n pos.includes(\"fullwidth\"),\r\n };\r\n}\r\n\r\n/**\r\n * Handle full-width positioning cases\r\n * @param {HTMLElement} container\r\n * @param {Object} options\r\n * @param {Object} flags\r\n * @returns {boolean} True if position was handled\r\n */\r\nfunction handleFullWidthPositions(container, options, flags) {\r\n if (!flags.hasFullWidth) return false;\r\n\r\n options.maxWidth = \"100vw\";\r\n\r\n if (flags.hasTop) {\r\n container.style.top = \"10px\";\r\n container.style.left = \"10px\";\r\n container.style.right = \"10px\";\r\n return true;\r\n }\r\n\r\n if (flags.hasBottom) {\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"10px\";\r\n container.style.right = \"10px\";\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Handle center positioning cases\r\n * @param {HTMLElement} container\r\n * @param {Object} flags\r\n * @returns {boolean} True if position was handled\r\n */\r\nfunction handleCenterPositions(container, flags) {\r\n if (!flags.hasCenter) return false;\r\n\r\n // top-center\r\n if (flags.hasTop && !flags.hasLeft && !flags.hasRight) {\r\n container.style.top = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n return true;\r\n }\r\n\r\n // bottom-center\r\n if (flags.hasBottom && !flags.hasLeft && !flags.hasRight) {\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n return true;\r\n }\r\n\r\n // left-center\r\n if (flags.hasLeft && !flags.hasTop && !flags.hasBottom) {\r\n container.style.left = \"10px\";\r\n container.style.top = \"50%\";\r\n container.style.transform = \"translateY(-50%)\";\r\n return true;\r\n }\r\n\r\n // right-center\r\n if (flags.hasRight && !flags.hasTop && !flags.hasBottom) {\r\n container.style.right = \"10px\";\r\n container.style.top = \"50%\";\r\n container.style.transform = \"translateY(-50%)\";\r\n return true;\r\n }\r\n\r\n // full center (no sides specified)\r\n if (!flags.hasLeft && !flags.hasRight && !flags.hasTop && !flags.hasBottom) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Apply standard positioning (corners and edges)\r\n * @param {HTMLElement} container\r\n * @param {Object} flags\r\n */\r\nfunction applyStandardPositioning(container, flags) {\r\n // Set vertical position\r\n if (flags.hasBottom) {\r\n container.style.bottom = \"10px\";\r\n } else if (flags.hasTop) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n // Set horizontal position\r\n if (flags.hasRight) {\r\n container.style.right = \"10px\";\r\n } else if (flags.hasLeft) {\r\n container.style.left = \"10px\";\r\n } else {\r\n // Default: bottom-center\r\n container.style.bottom = \"10px\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translateX(-50%)\";\r\n }\r\n}\r\n","// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = await generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = await generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n // Emergency fallback removed: avoid using outerHTML (drops listeners & risks XSS).\r\n // Final attempt: clone and append using standard APIs.\r\n try {\r\n if (parent === document.body) {\r\n const clone = child.cloneNode(true);\r\n parent.appendChild(clone);\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport async function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n\r\n/**\r\n * Determine text color based on background color.\r\n * @param {string} toastBg Toast background color in hex, rgb, or rgba format.\r\n * @returns {Promise<string>} Text color, either `\"black\"` or `\"white\"`.\r\n */\r\nexport async function getTextColor(toastBg) {\r\n if (!toastBg) return \"black\";\r\n try {\r\n return (await contrast(toastBg)) > 3.5 ? \"black\" : \"white\";\r\n } catch (error) {\r\n console.warn(\"TextColor calculation failed:\", error);\r\n return \"black\";\r\n }\r\n}\r\n\r\n/**\r\n * Calculates the contrast ratio between the given color and black or white.\r\n * @param {string} color A color in hex, rgb, rgba, or color name format.\r\n * @returns {Promise<number>} The contrast ratio between the given color and black or white.\r\n * @throws {Error} If the given color is not supported.\r\n */\r\nasync function contrast(color) {\r\n if (!color) {\r\n throw new Error(\"Color is required\");\r\n }\r\n\r\n let r, g, b;\r\n\r\n // If color is in hex format\r\n if (color.startsWith(\"#\")) {\r\n const hex = color.substring(1);\r\n if (hex.length === 3) {\r\n r = parseInt(hex[0] + hex[0], 16);\r\n g = parseInt(hex[1] + hex[1], 16);\r\n b = parseInt(hex[2] + hex[2], 16);\r\n } else if (hex.length === 6) {\r\n r = parseInt(hex.substring(0, 2), 16);\r\n g = parseInt(hex.substring(2, 4), 16);\r\n b = parseInt(hex.substring(4, 6), 16);\r\n } else {\r\n throw new Error(`Invalid hex color format: ${color}`);\r\n }\r\n }\r\n // If color is in rgb/rgba format\r\n else if (color.startsWith(\"rgb\") || color.startsWith(\"rgba\")) {\r\n const match = color.match(\r\n /^rgba?\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/\r\n );\r\n if (match) {\r\n r = parseInt(match[1]);\r\n g = parseInt(match[2]);\r\n b = parseInt(match[3]);\r\n } else {\r\n throw new Error(`Invalid rgb/rgba color format: ${color}`);\r\n }\r\n }\r\n // If color is a color name\r\n else {\r\n const colorMap = {\r\n black: [0, 0, 0],\r\n white: [255, 255, 255],\r\n // Add more color names as needed\r\n };\r\n const colorArray = colorMap[color.toLowerCase()];\r\n if (colorArray) {\r\n r = colorArray[0];\r\n g = colorArray[1];\r\n b = colorArray[2];\r\n } else {\r\n throw new Error(`Unsupported color format: ${color}`);\r\n }\r\n }\r\n\r\n if (isNaN(r) || isNaN(g) || isNaN(b)) {\r\n throw new Error(`Invalid color value: ${color}`);\r\n }\r\n\r\n const l1 = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 255;\r\n const l2 = 0.05;\r\n return (Math.max(l1, l2) + 0.05) / Math.min(l1, l2);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n // Accessibility + avoid innerHTML (XSS surface)\r\n closeButton.setAttribute(\"aria-label\", \"Close notification\");\r\n closeButton.setAttribute(\"title\", \"Close\");\r\n closeButton.textContent = \"×\"; // U+00D7 multiplication sign\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor,\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport async function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport async function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n requestAnimationFrame(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n });\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = await parseAnimationDuration(\r\n options.animationDuration\r\n );\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor,\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: options.borderRadius,\r\n overflow: \"hidden\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: options.maxWidth,\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${options.animationDuration} ${options.animationEasing}, transform ${options.animationDuration} ${options.animationEasing}`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n // willChange: \"opacity, transform\",\r\n });\r\n\r\n // TODO! Later\r\n // await animateElement(toast, {\r\n // animationType: options.animationType,\r\n // duration: animDurationMs,\r\n // easing: options.animationEasing,\r\n // });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n\r\n // Layout & positioning\r\n messageSpan.style.position = options.fontPosition;\r\n messageSpan.style.display = \"inline-block\"; // ensure consistent layout\r\n messageSpan.style.flex = \"1\";\r\n\r\n // Spacing & container styling\r\n messageSpan.style.padding = options.fontPadding;\r\n messageSpan.style.borderRadius = options.fontBorderRadius;\r\n messageSpan.style.background = options.fontBackgroundColor;\r\n\r\n // Font stack (system + emoji + fallback)\r\n messageSpan.style.fontFamily = options.fontFamily;\r\n\r\n // Font size & readability\r\n messageSpan.style.fontSize = options.fontSize; // minimum for readability\r\n messageSpan.style.fontWeight = options.fontWeight;\r\n messageSpan.style.lineHeight = options.fontLineHeight; // balance readability\r\n\r\n //TODO LATER Icons (auto dark/light fallback)\r\n // messageSpan.style.color =\r\n // options.iconColor ||\r\n // (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n // ? \"#f5f5f5\"\r\n // : \"#111111\");\r\n\r\n // Colors (auto dark/light fallback)\r\n messageSpan.style.color = options.textColor;\r\n\r\n // Accessibility\r\n messageSpan.style.userSelect = \"text\"; // allow copy/paste if needed\r\n messageSpan.style.wordBreak = \"break-word\"; // avoid layout breaking on long strings\r\n messageSpan.style.direction = options.fontDirection; // RTL/LTR auto-detect\r\n // ✅ Multi-line ellipsis (max 3 lines)\r\n messageSpan.style.webkitLineClamp = \"3\"; // maximum 3 lines\r\n messageSpan.style.webkitBoxOrient = \"vertical\";\r\n messageSpan.style.whiteSpace = options.wrapText ? \"normal\" : \"nowrap\"; // allow wrapping if wanted\r\n messageSpan.style.display = \"block\";\r\n messageSpan.style.overflow = \"hidden\";\r\n messageSpan.style.textOverflow = \"ellipsis\";\r\n messageSpan.style.lineClamp = \"3\"; // modern property\r\n messageSpan.style.boxOrient = \"vertical\"; // non-prefixed\r\n messageSpan.style.display = \"-webkit-box\";\r\n // messageSpan.style.mixBlendMode = \"difference\";\r\n // Assign message\r\n messageSpan.textContent = options.message;\r\n messageSpan.setAttribute(\"aria-label\", \"Toast Notification Center\");\r\n messageSpan.setAttribute(\"title\", options.message);\r\n // Add to toast\r\n toast.appendChild(messageSpan);\r\n\r\n // TODO Icon Later\r\n // if (options.icon) {\r\n // createIcon(toast, options);\r\n // }\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n await createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n await createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n await runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message;\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n// CSS injection function\r\nasync function injectToastStyles() {\r\n if (document.getElementById(\"ctoast-styles\")) return; // Already injected\r\n\r\n const style = document.createElement(\"style\");\r\n style.id = \"ctoast-styles\";\r\n style.textContent = `\r\n .ctoast-toast {\r\n padding: 12px 20px;\r\n margin-bottom: 10px;\r\n border-radius: 5px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\r\n min-width: 250px;\r\n max-width: 400px;\r\n opacity: 0;\r\n position: relative;\r\n transform: translateY(20px);\r\n z-index: 9999;\r\n }\r\n\r\n .ctoast-message {\r\n flex: 1;\r\n }\r\n\r\n .ctoast-close {\r\n cursor: pointer;\r\n margin-left: 10px;\r\n font-weight: bold;\r\n background: transparent;\r\n border: none;\r\n }\r\n\r\n .ctoast-progress {\r\n position: absolute;\r\n bottom: 0;\r\n left: 0;\r\n height: 4px;\r\n background: rgba(255,255,255,0.7);\r\n width: 100%;\r\n transform-origin: left;\r\n }\r\n\r\n .ctoast-show {\r\n opacity: 1 !important;\r\n transform: translateY(0) !important;\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport async function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n await applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n await createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet emergencyCleanupScheduled = false;\r\nlet currentToast = [];\r\nlet emergencyTimeouts = [];\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport async function showToast(options) {\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = await createToastContainer(options);\r\n const toast = await createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast element creation failed!\");\r\n }\r\n\r\n currentToast.push(toast);\r\n\r\n // Append to container\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const cleanUpTime =\r\n typeof options.duration === \"number\" && options.duration > 0\r\n ? options.duration + 2\r\n : 1800; //safety margin\r\n const dismissTimeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n cleanUpTime\r\n );\r\n emergencyTimeouts.push(dismissTimeout);\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\r\n \"Primary toast system failed showing emergency toast:\",\r\n primaryError\r\n );\r\n const elContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n const emergencyToast = createEmergencyToast(options, closeToast);\r\n elContainer && elContainer?.id?.includes(\"toast-container-\")\r\n ? elContainer.appendChild(emergencyToast)\r\n : alert(primaryError.substring(0, 200));\r\n return;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Created Simple Toast!\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nexport async function closeToast(toast) {\r\n if (currentToast.length > 0) {\r\n const index = currentToast.indexOf(toast);\r\n if (index !== -1) {\r\n currentToast.splice(index, 1);\r\n }\r\n }\r\n await removeElement(toast);\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nasync function performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = [];\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.pop();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n const cleanUpTime = typeof duration === \"number\" ? duration + 2 : 1800; //safety margin\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, cleanUpTime);\r\n\r\n emergencyTimeouts.push(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nasync function forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id^=\"toast-\"]:not([id*=\"container\"]), [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = [];\r\n }\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport async function createToastContainer(options) {\r\n try {\r\n let toastContainer = document.getElementById(\r\n `toast-container-${options.position}`\r\n );\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${options.position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, options);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// // src/index.js\r\n// /**\r\n// * @fileoverview A simple toast notification library for any JavaScript framework.\r\n// * @name Customizable Toast Notifications\r\n// * @author Priyanshu Patel\r\n// * @version __VERSION__\r\n// * @build Production\r\n// * @license Apache-2.0\r\n// * @depends None\r\n// * @description A lightweight and fully customizable toast notification library\r\n// * designed for seamless integration with any JavaScript or framework-based UI.\r\n// * Supports flexible positioning, theming, icons, animations, and timing options\r\n// * out of the box — with zero dependencies.\r\n// * Author: Priyanshu Patel\r\n// * Email: priyanshu.alt191@gmail.com\r\n// * Created: July 31, 2024\r\n// * License: Apache-2.0\r\n// * Dependencies: None\r\n// */\r\n//\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\nimport { appendChild, getTextColor } from \"./utils/dom.js\";\r\nimport { setPosition } from \"./utils/position.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\n// Toast queue for calls before DOM ready\r\nconst pendingToasts = [];\r\n\r\n// Flag to indicate DOM ready for toast execution\r\nlet domReady = false;\r\n\r\n// DOM ready check\r\nasync function checkDOMReady() {\r\n if (domReady) return;\r\n\r\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\r\n if (\r\n document.readyState === \"complete\" ||\r\n document.readyState === \"interactive\"\r\n ) {\r\n domReady = true;\r\n // Flush queued toasts after 2s delay\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n } else {\r\n // Wait for DOMContentLoaded\r\n document.addEventListener(\r\n \"DOMContentLoaded\",\r\n () => {\r\n domReady = true;\r\n pendingToasts.forEach((options) =>\r\n setTimeout(() => createToastNow(options), 2000)\r\n );\r\n pendingToasts.length = 0;\r\n },\r\n { once: true }\r\n );\r\n }\r\n }\r\n}\r\n\r\n// Core toast creation logic\r\nasync function createToastNow(options = {}) {\r\n try {\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n await createFirstToastContainer(sanitizedOptions);\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n const safeMessage =\r\n typeof options?.message === \"string\" && options?.message !== null\r\n ? `${options?.message?.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\nlet initialDelayDone = false; // flag to ensure single execution\r\n\r\n// Public API\r\nasync function createToast(options = {}) {\r\n // Check browser environment\r\n const isBrowser =\r\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\r\n\r\n if (!isBrowser) {\r\n console.warn(\r\n \"ToastNotification: running in non-browser environment, no DOM available.\"\r\n );\r\n return;\r\n }\r\n\r\n // Check if DOM ready\r\n await checkDOMReady();\r\n\r\n if (!domReady) {\r\n // Queue for later execution\r\n pendingToasts.push(options);\r\n return;\r\n }\r\n\r\n // If DOM ready → execute after 2s delay\r\n if (!initialDelayDone) {\r\n // First call → wait 2 seconds\r\n initialDelayDone = true;\r\n setTimeout(await createToastNow(options), 2000);\r\n } else {\r\n // Subsequent calls → run immediately\r\n await createToastNow(options);\r\n }\r\n}\r\n\r\nasync function createFirstToastContainer(options) {\r\n try {\r\n let toastContainer = document.getElementById(\r\n `toast-container-${options.position}`\r\n );\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${options.position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, options);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n\r\n/**\r\n * Sanitizes and normalizes toast options.\r\n * Fills in defaults, validates input, and ensures colors & messages are set.\r\n * @param {Object} options - User-provided toast options\r\n * @returns {Promise<Object>} final sanitized toast options\r\n */\r\nasync function sanitizeToastOptions(options) {\r\n const contPosition = options?.position?.toLowerCase()?.trim();\r\n const contMaxWidth =\r\n contPosition?.includes(\"top-full-width\") ||\r\n contPosition?.includes(\"bottom-full-width\")\r\n ? \"100vw\"\r\n : \"400px\";\r\n\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n borderRadius: \"50px\",\r\n backgroundColor: undefined,\r\n textColor: undefined,\r\n showCloseButton: true,\r\n animationDuration: \"0.4s\",\r\n animationType: \"fade\",\r\n animationEasing: \"ease\",\r\n showProgressBar: true,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n fontPosition: \"relative\",\r\n fontPadding: undefined,\r\n fontBorderRadius: undefined,\r\n fontBackgroundColor: undefined,\r\n fontFamily:\r\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\r\n fontSize: \"14px\",\r\n fontWeight: \"400\",\r\n fontLineHeight: \"1.4\",\r\n fontDirection: \"auto\",\r\n wrapText: \"normal\",\r\n maxWidth: contMaxWidth,\r\n };\r\n\r\n // Merge defaults with user options\r\n const final = {\r\n ...defaults,\r\n ...(typeof options === \"object\" && !Array.isArray(options) ? options : {}),\r\n };\r\n\r\n // Ensure message property separately\r\n final.message = options?.message ?? final.message;\r\n\r\n try {\r\n // Background color fallback based on type or system preference\r\n if (!final.backgroundColor) {\r\n final.backgroundColor =\r\n defaultColors?.[final.type] ??\r\n (window.matchMedia(\"(prefers-color-scheme: dark)\").matches\r\n ? \"#f5f5f5\"\r\n : \"#111111\");\r\n }\r\n\r\n // Default message if not provided\r\n final.message =\r\n final.message || defaultMessages?.[final.type] || \"No Message Provided!\";\r\n\r\n // Ensure textColor is set\r\n if (!final.textColor && final.backgroundColor) {\r\n final.textColor = await getTextColor(final.backgroundColor);\r\n }\r\n\r\n // Ensure progressColor is set\r\n if (!final.progressColor && final.backgroundColor) {\r\n final.progressColor = await getTextColor(final.backgroundColor);\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Safety check for message type\r\n if (typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","setPosition","container","options","position","Error","style","top","bottom","left","right","transform","resetContainerStyles","positionFlags","pos","toLowerCase","trim","hasTop","includes","hasBottom","hasLeft","hasRight","hasCenter","hasFullWidth","parsePosition","flags","maxWidth","handleFullWidthPositions","handleCenterPositions","applyStandardPositioning","generateUniqueId","prefix","Date","now","Math","floor","random","appendChild","parent","child","contains","error","insertAdjacentElement","fallbackError","document","body","clone","cloneNode","emergencyError","getTextColor","toastBg","color","r","g","b","startsWith","hex","substring","length","parseInt","match","colorArray","black","white","isNaN","l1","l2","max","min","contrast","applyRichStyling","toast","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","padding","marginBottom","borderRadius","overflow","display","alignItems","justifyContent","boxShadow","minWidth","opacity","transition","animationEasing","zIndex","_animationDuration","messageSpan","createElement","fontPosition","flex","fontPadding","fontBorderRadius","fontBackgroundColor","fontFamily","fontSize","fontWeight","lineHeight","fontLineHeight","textColor","userSelect","wordBreak","direction","fontDirection","webkitLineClamp","webkitBoxOrient","whiteSpace","wrapText","textOverflow","lineClamp","boxOrient","textContent","message","setAttribute","showCloseButton","closeButton","border","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","requestAnimationFrame","runToastAnimation","createEmergencyToast","emergency","id","innerHTML","_isEmergencyToast","parentNode","removeChild","alert","alertError","createToastElement","querySelector","tagName","fallbackTag","fallbackPrefix","fallbackEl","createElementWithId","currentToast","emergencyTimeouts","showToast","toastContainer","getElementById","createToastContainer","closeToast","push","cleanUpTime","dismissTimeout","fn","delay","safeSetTimeout","primaryError","elContainer","emergencyToast","index","indexOf","splice","remove","pointerEvents","hideError","removeElement","defaultColors","success","warning","info","defaultMessages","pendingToasts","domReady","createToastNow","sanitizedOptions","contPosition","contMaxWidth","final","type","undefined","animationType","Array","isArray","window","matchMedia","matches","sanitizeToastOptions","createFirstToastContainer","safeMessage","initialDelayDone","createToast","readyState","forEach","addEventListener","once","checkDOMReady","setDefaultColors","colors","setDefaultMessages","messages","customizableToast"],"mappings":";;;;;;;;;;;;;;aASOA,eAAeC,EAAYC,EAAWC,GAC3C,IAAKD,IAAcC,EAAQC,SACzB,MAAM,IAAIC,MAAM,mCAgBpB,SAA8BH,GAC5BA,EAAUI,MAAMC,IAAM,OACtBL,EAAUI,MAAME,OAAS,OACzBN,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAMI,MAAQ,OACxBR,EAAUI,MAAMK,UAAY,MAC9B,CAnBEC,CAAqBV,GACrB,MAAMW,EAyBR,SAAuBT,GACrB,MAAMU,EAAMV,EAASW,cAAcC,OACnC,MAAO,CACLC,OAAQH,EAAII,SAAS,OACrBC,UAAWL,EAAII,SAAS,WAAaJ,EAAII,SAAS,SAClDE,QAASN,EAAII,SAAS,QACtBG,SAAUP,EAAII,SAAS,SACvBI,UAAWR,EAAII,SAAS,UACxBK,aACET,EAAII,SAAS,mBACbJ,EAAII,SAAS,sBACbJ,EAAII,SAAS,aAEnB,CAtCwBM,CAAcrB,EAAQC,WA+C9C,SAAkCF,EAAWC,EAASsB,GACpD,IAAKA,EAAMF,aAAc,OAAO,EAIhC,GAFApB,EAAQuB,SAAW,QAEfD,EAAMR,OAIR,OAHAf,EAAUI,MAAMC,IAAM,OACtBL,EAAUI,MAAMG,KAAO,OACvBP,EAAUI,MAAMI,MAAQ,QACjB,EAGT,GAAIe,EAAMN,UAIR,OAHAjB,EAAUI,MAAME,OAAS,OACzBN,EAAUI,M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rI,OAAS,GAEzB,CAAE4J,MAAM,IAIhB,CAoCQC,GAEDvB,EAOAiB,QAMGhB,EAAe9L,IAJrB8M,GAAmB,EACnBrE,iBAAiBqD,EAAe9L,GAAU,MAR1C4L,EAAcrB,KAAKvK,GAavB,CAmHA,SAASqN,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBhB,MAAMC,QAAQe,KACzD/B,EAAgB,IAAKA,KAAkB+B,GAE3C,CAAE,MAAOhL,GAET,CACF,CAKA,SAASiL,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BlB,MAAMC,QAAQiB,KAC7D7B,EAAkB,IAAKA,KAAoB6B,GAE/C,CAAE,MAAOlL,GAET,CACF,CAWA,IAEwB,oBAAXkK,SACTA,OAAOiB,kBAAoB,CACzBV,cACAM,mBACAE,sBAGN,CAAE,MAAOjL,GAET,oCApBA,WAEEgI,EADc7H,SAASiH,cAAc,yCAEvC"}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.6.0
3
- * Build: 2025-09-01 13:01:31
4
- * Cache-Buster: 1756731691017
2
+ * Customizable Toast Notifications 3.7.1
3
+ * Build: 2025-09-13 10:09:28
4
+ * Cache-Buster: 1757758168805
5
5
  * Author: Priyanshu Patel
6
6
  * Email: priyanshu.alt191@gmail.com
7
7
  * License: Apache-2.0
@@ -12,23 +12,7 @@
12
12
  * Supports flexible positioning, theming, icons, animations, and timing options
13
13
  * out of the box — with zero dependencies.
14
14
  */
15
- async function t(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function n(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body){const n=e.cloneNode(!0);return t.appendChild(n),!0}}catch(t){return!1}}}return!1}async function o(t){return t.backgroundColor&&await async function(t){let e,n,o;if(t.startsWith("#")){const a=t.substring(1);3===a.length?(e=parseInt(a[0]+a[0],16),n=parseInt(a[1]+a[1],16),o=parseInt(a[2]+a[2],16)):(e=parseInt(a.substring(0,2),16),n=parseInt(a.substring(2,4),16),o=parseInt(a.substring(4,6),16))}else if(t.startsWith("rgb")||t.startsWith("rgba")){const a=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);a&&(e=parseInt(a[1]),n=parseInt(a[2]),o=parseInt(a[3]))}else{const a={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!a)throw new Error(`Unsupported color format: ${t}`);e=a[0],n=a[1],o=a[2]}const a=(.2126*e+.7152*n+.0722*o)/255,i=.05;return(Math.max(a,i)+.05)/Math.min(a,i)}(t.backgroundColor)>3.5?"black":"white"}async function a(t,e,n){const o=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const a=document.createElement("span");a.style.position=e.fontPosition,a.style.display="inline-block",a.style.flex="1",a.style.padding=e.fontPadding,a.style.borderRadius=e.fontBorderRadius,a.style.background=e.fontBackgroundColor,a.style.fontFamily=e.fontFamily,a.style.fontSize=e.fontSize,a.style.fontWeight=e.fontWeight,a.style.lineHeight=e.fontLineHeight,a.style.color=e.textColor,a.style.userSelect="text",a.style.wordBreak="break-word",a.style.direction=e.fontDirection,a.style.webkitLineClamp="3",a.style.webkitBoxOrient="vertical",a.style.whiteSpace=e.wrapText?"normal":"nowrap",a.style.display="block",a.style.overflow="hidden",a.style.textOverflow="ellipsis",a.style.lineClamp="3",a.style.boxOrient="vertical",a.style.display="-webkit-box",a.textContent=e.message,a.setAttribute("aria-label","Toast Notification Center"),a.setAttribute("title",e.message),t.appendChild(a),e.showCloseButton&&await async function(t,e,n){const o=document.createElement("button");o.setAttribute("aria-label","Close notification"),o.setAttribute("title","Close"),o.textContent="×",Object.assign(o.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&await async function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function i(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function r(t,n){let o;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return o=await async function(t,n){try{const o=document.createElement(t);return o.id=await e(n),o}catch(t){try{const t="div",n="fallback",o=document.createElement(t);return o.id=await e(n),o.setAttribute("data-original-tag",t),o}catch(t){}}}("div","toast"),await a(o,t,n),o}catch(e){return await i(t,n),o}}let s=[],c=[];async function l(e){try{const o=await async function(e){try{let o=document.getElementById(`toast-container-${e}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(e.position),a=await r(e,d);if(!a)throw new Error("Toast element creation failed!");s.push(a),o.id.includes("toast-container-")&&o.appendChild(a);const i="number"==typeof e.duration&&e.duration>0?e.duration+2:1800,l=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>d(a),i);return void c.push(l)}catch(t){const n=document.querySelector('[id^="toast-container-"]'),o=i(e,d);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(o):alert(t.substring(0,200)))}}async function d(t){if(s.length>0){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}
16
- /**
17
- * @fileoverview A simple toast notification library for any JavaScript framework.
18
- * @name Customizable Toast Notifications
19
- * @author Priyanshu Patel
20
- * @version "3.6.0"
21
- * @build Production
22
- * @license Apache-2.0
23
- * @depends None
24
- * @description A lightweight and fully customizable toast notification library
25
- * designed for seamless integration with any JavaScript or framework-based UI.
26
- * Supports flexible positioning, theming, icons, animations, and timing options
27
- * out of the box — with zero dependencies.
28
- * Author: Priyanshu Patel
29
- * Email: priyanshu.alt191@gmail.com
30
- * Created: July 31, 2024
31
- * License: Apache-2.0
32
- * Dependencies: None
33
- */let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},p={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const y=[];let m=!1;async function f(e={}){try{const a=await async function(t){const e={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",..."object"!=typeof t||Array.isArray(t)?{}:t};e.message=t?.message??e.message;try{e.backgroundColor||(e.backgroundColor=u?.[e.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),e.message=e.message||p?.[e.type]||"No Message Provided!",!e.textColor&&e.backgroundColor&&(e.textColor=await o(e)),!e.progressColor&&e.backgroundColor&&(e.progressColor=await o(e))}catch(t){}"string"!=typeof e.message&&(e.message="No Message Provided!");return e}(e);await async function(e){try{let o=document.getElementById(`toast-container-${e}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(a.position),await l(a)}catch(t){const n="string"==typeof e?.message?`${e.message.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}let g=!1;async function h(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){m||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(m=!0,y.forEach(t=>setTimeout(()=>f(t),2e3)),y.length=0):document.addEventListener("DOMContentLoaded",()=>{m=!0,y.forEach(t=>setTimeout(()=>f(t),2e3)),y.length=0},{once:!0}))}(),m?g?await f(t):(g=!0,setTimeout(await f(t),2e3)):y.push(t))}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function w(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(p={...p,...t})}catch(t){}}function x(){d(document.querySelector('[id^="toast-"]:not([id*="container"])'))}try{"undefined"!=typeof window&&(window.customizableToast={createToast:h,setDefaultColors:b,setDefaultMessages:w})}catch(t){}export{h as createToast,x as noop,b as setDefaultColors,w as setDefaultMessages};
15
+ async function t(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const n=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,n){if(!n.hasFullWidth)return!1;if(e.maxWidth="100vw",n.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(n.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,n)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,n)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,n)}async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function n(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body){const n=e.cloneNode(!0);return t.appendChild(n),!0}}catch(t){return!1}}}return!1}async function o(t){if(!t)return"black";try{return await async function(t){if(!t)throw new Error("Color is required");let e,n,o;if(t.startsWith("#")){const r=t.substring(1);if(3===r.length)e=parseInt(r[0]+r[0],16),n=parseInt(r[1]+r[1],16),o=parseInt(r[2]+r[2],16);else{if(6!==r.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(r.substring(0,2),16),n=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const r=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!r)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(r[1]),n=parseInt(r[2]),o=parseInt(r[3])}else{const r={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!r)throw new Error(`Unsupported color format: ${t}`);e=r[0],n=r[1],o=r[2]}if(isNaN(e)||isNaN(n)||isNaN(o))throw new Error(`Invalid color value: ${t}`);const r=(.2126*e+.7152*n+.0722*o)/255,a=.05;return(Math.max(r,a)+.05)/Math.min(r,a)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function r(t,e,n){const o=await async function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor,padding:"12px 20px",marginBottom:"10px",borderRadius:e.borderRadius,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:e.maxWidth,opacity:"0",position:"relative",transition:`opacity ${e.animationDuration} ${e.animationEasing}, transform ${e.animationDuration} ${e.animationEasing}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.style.position=e.fontPosition,r.style.display="inline-block",r.style.flex="1",r.style.padding=e.fontPadding,r.style.borderRadius=e.fontBorderRadius,r.style.background=e.fontBackgroundColor,r.style.fontFamily=e.fontFamily,r.style.fontSize=e.fontSize,r.style.fontWeight=e.fontWeight,r.style.lineHeight=e.fontLineHeight,r.style.color=e.textColor,r.style.userSelect="text",r.style.wordBreak="break-word",r.style.direction=e.fontDirection,r.style.webkitLineClamp="3",r.style.webkitBoxOrient="vertical",r.style.whiteSpace=e.wrapText?"normal":"nowrap",r.style.display="block",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.lineClamp="3",r.style.boxOrient="vertical",r.style.display="-webkit-box",r.textContent=e.message,r.setAttribute("aria-label","Toast Notification Center"),r.setAttribute("title",e.message),t.appendChild(r),e.showCloseButton&&await async function(t,e,n){const o=document.createElement("button");o.setAttribute("aria-label","Close notification"),o.setAttribute("title","Close"),o.textContent="×",Object.assign(o.style,{background:"none",border:"none",color:e.textColor,fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&await async function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),await async function(t){setTimeout(()=>{requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},50)}(t)}async function a(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function i(t,n){let o;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return o=await async function(t,n){try{const o=document.createElement(t);return o.id=await e(n),o}catch(t){try{const t="div",n="fallback",o=document.createElement(t);return o.id=await e(n),o.setAttribute("data-original-tag",t),o}catch(t){}}}("div","toast"),await r(o,t,n),o}catch(e){return await a(t,n),o}}let s=[],l=[];async function c(e){try{const o=await async function(e){try{let o=document.getElementById(`toast-container-${e.position}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e.position}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(e),r=await i(e,d);if(!r)throw new Error("Toast element creation failed!");s.push(r),o.id.includes("toast-container-")&&o.appendChild(r);const a="number"==typeof e.duration&&e.duration>0?e.duration+2:1800,c=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>d(r),a);return void l.push(c)}catch(t){const n=document.querySelector('[id^="toast-container-"]'),o=a(e,d);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(o):alert(t.substring(0,200)))}}async function d(t){if(s.length>0){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}
16
+ // * @license Apache-2.0
17
+ let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},p={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const f=[];let y=!1;async function m(e={}){try{const r=await async function(t){const e=t?.position?.toLowerCase()?.trim(),n=e?.includes("top-full-width")||e?.includes("bottom-full-width")?"100vw":"400px",r={duration:1800,position:"bottom-right",type:"info",borderRadius:"50px",backgroundColor:void 0,textColor:void 0,showCloseButton:!0,animationDuration:"0.4s",animationType:"fade",animationEasing:"ease",showProgressBar:!0,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom",fontPosition:"relative",fontPadding:void 0,fontBorderRadius:void 0,fontBackgroundColor:void 0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:"14px",fontWeight:"400",fontLineHeight:"1.4",fontDirection:"auto",wrapText:"normal",maxWidth:n,..."object"!=typeof t||Array.isArray(t)?{}:t};r.message=t?.message??r.message;try{r.backgroundColor||(r.backgroundColor=u?.[r.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),r.message=r.message||p?.[r.type]||"No Message Provided!",!r.textColor&&r.backgroundColor&&(r.textColor=await o(r.backgroundColor)),!r.progressColor&&r.backgroundColor&&(r.progressColor=await o(r.backgroundColor))}catch(t){}"string"!=typeof r.message&&(r.message="No Message Provided!");return r}(e);await async function(e){try{let o=document.getElementById(`toast-container-${e.position}`);return o||(o=document.createElement("div"),o.id=`toast-container-${e.position}`,o.style.position="fixed",o.style.zIndex="9999",await t(o,e),await n(document.body,o)),o}catch(t){return document.body}}(r),await c(r)}catch(t){const n="string"==typeof e?.message&&null!==e?.message?`${e?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}let h=!1;async function g(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){y||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0):document.addEventListener("DOMContentLoaded",()=>{y=!0,f.forEach(t=>setTimeout(()=>m(t),2e3)),f.length=0},{once:!0}))}(),y?h?await m(t):(h=!0,setTimeout(await m(t),2e3)):f.push(t))}function w(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(p={...p,...t})}catch(t){}}function x(){d(document.querySelector('[id^="toast-"]:not([id*="container"])'))}try{"undefined"!=typeof window&&(window.customizableToast={createToast:g,setDefaultColors:w,setDefaultMessages:b})}catch(t){}export{g as createToast,x as noop,w as setDefaultColors,b as setDefaultMessages};
34
18
  //# sourceMappingURL=index.esm.mjs.map