customizable-toast-notification 3.9.0 → 3.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,18 +1,16 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.9.0
3
- * Build: 2025-09-16 13:41:46
4
- * Cache-Buster: 1758030106007
2
+ * Customizable Toast Notifications 3.9.2
3
+ * Build: 2025-09-18 02:31:41
4
+ * Cache-Buster: 1758162701572
5
5
  * Author: Priyanshu Patel
6
- * Email: priyanshu.alt191@gmail.com
6
+ * Email: [priyanshu.alt191@gmail.com](mailto:priyanshu.alt191@gmail.com)
7
7
  * License: Apache-2.0
8
8
  * Dependencies: None
9
9
  * Created: July 31, 2024
10
10
  * A lightweight and fully customizable toast notification library
11
11
  * designed for seamless integration with any JavaScript or framework-based UI.
12
12
  * Supports flexible positioning, theming, icons, animations, and timing options
13
- * out of the box — with zero dependencies.
13
+ * out of the box — with CTA support and zero dependencies.
14
14
  */
15
- "use strict";async function t(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function e(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 i=t.substring(1);if(3===i.length)e=parseInt(i[0]+i[0],16),n=parseInt(i[1]+i[1],16),o=parseInt(i[2]+i[2],16);else{if(6!==i.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const i=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!i)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3])}else{const i={black:[0,0,0],white:[255,255,255]}[t.toLowerCase()];if(!i)throw new Error(`Unsupported color format: ${t}`);e=i[0],n=i[1],o=i[2]}if(isNaN(e)||isNaN(n)||isNaN(o))throw new Error(`Invalid color value: ${t}`);const i=(.2126*e+.7152*n+.0722*o)/255,r=.05;return(Math.max(i,r)+.05)/Math.min(i,r)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function n(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 i=document.createElement("span");i.style.position=e.fontPosition,i.style.display="inline-block",i.style.flex="1",i.style.padding=e.fontPadding,i.style.borderRadius=e.fontBorderRadius,i.style.background=e.fontBackgroundColor,i.style.fontFamily=e.fontFamily,i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.lineHeight=e.fontLineHeight,i.style.color=e.textColor,i.style.userSelect="text",i.style.wordBreak="break-word",i.style.direction=e.fontDirection,i.style.webkitLineClamp="3",i.style.webkitBoxOrient="vertical",i.style.whiteSpace=e.wrapText?"normal":"nowrap",i.style.display="block",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.lineClamp="3",i.style.boxOrient="vertical",i.style.display="-webkit-box",i.textContent=e.message,i.setAttribute("aria-label","Toast Notification Center"),i.setAttribute("title",e.message),t.appendChild(i),await async function(t,e,n){const o=e?.cta;if(!o||!o.label)return;const i=!!o.href&&"link"===o.variant,r=document.createElement(i?"a":"button");i?(r.href=o.href,o.target&&(r.target=o.target),r.rel=o.rel||("_blank"===o.target?"noopener noreferrer":"")):r.type="button";r.setAttribute("aria-label",o.ariaLabel||o.label),Object.assign(r.style,{marginLeft:"10px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:"1px solid rgba(255,255,255,0.35)",color:e.textColor||"#fff",background:"rgba(255,255,255,0.15)",cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0"}),r.textContent=o.label,r.addEventListener("click",async e=>{try{if("function"==typeof o.onClick){const t=o.onClick(e);t?.then&&await t}}finally{!1!==o.autoClose&&n(t)}}),t.appendChild(r)}(t,e,n),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 o(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(e,i){let r;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return r=await async function(e,n){try{const o=document.createElement(e);return o.id=await t(n),o}catch(e){try{const e="div",n="fallback",o=document.createElement(e);return o.id=await t(n),o.setAttribute("data-original-tag",e),o}catch(t){}}}("div","toast"),await n(r,e,i),r}catch(t){return await o(e,i),r}}const r=new Map,s=new Map;function a(t="bottom-right"){return`toast-container-${function(t="bottom-right"){return String(t).toLowerCase().trim().replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"-").replace(/\-+/g,"-")}(t)}`}async function l(t={},e){const n=a(t.position);if(s.has(n))return s.get(n);const o=(async()=>{const o=r.get(n);if(o&&o.isConnected)return o;let i=document.getElementById(n);i&&!i.isConnected&&document.body.appendChild(i),i?(i.style.position=i.style.position||"fixed",i.style.zIndex=i.style.zIndex||"9999","function"==typeof e&&await e(i,t)):(i=document.createElement("div"),i.id=n,i.setAttribute("role","status"),i.setAttribute("aria-atomic","true"),i.style.position="fixed",i.style.zIndex="9999",i.style.inset="auto 10px 10px auto",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.flexDirection="column",i.style.overflow="hidden","function"==typeof e&&await e(i,t),document.body.appendChild(i));const s=document.querySelectorAll(`#${n}`);if(s.length>1)for(let t=1;t<s.length;t++)try{s[t].remove()}catch{}return r.set(n,i),i})();s.set(n,o);try{return await o}finally{s.delete(a(t.position))}}async function c(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const n=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,n){if(!n.hasFullWidth)return!1;if(e.maxWidth="100vw",n.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(n.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,n)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,n)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,n)}class u{constructor(t,e){this.callback=t,this.delay=e,this.remaining=e,this.startTime=null,this.timeoutId=null,this.isPaused=!1,this.isCompleted=!1}start(){return this.isCompleted||this.timeoutId||(this.startTime=Date.now(),this.timeoutId=setTimeout(()=>{this.isCompleted=!0,this.timeoutId=null,this.callback()},this.remaining)),this}pause(){return this.isPaused||!this.timeoutId||this.isCompleted||(clearTimeout(this.timeoutId),this.timeoutId=null,this.remaining-=Date.now()-this.startTime,this.remaining=Math.max(0,this.remaining),this.isPaused=!0),this}resume(){return!this.isPaused||this.isCompleted||(this.isPaused=!1,this.start()),this}clear(){return this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.isCompleted=!0,this}getRemainingTime(){return this.isCompleted?0:this.isPaused?this.remaining:this.timeoutId?Math.max(0,this.remaining-(Date.now()-this.startTime)):this.delay}}const d=new Map,p=new Map,m=[];let f=0;function h(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return e>>>0}async function y(t={}){const e=function({type:t="info",message:e="",position:n="bottom-right"}){return[String(t).trim().toLowerCase(),h(String(e)).toString(16),String(n).trim().toLowerCase()].join("|")}(t);if(d.has(e)){const n=d.get(e);return n.count++,n.timer.clear(),n.timer=b(n.toast,t),w(n),void C(n)}if(p.has(e))return void p.get(e).count++;const n={options:t,count:1,rafId:0};p.set(e,n),n.rafId=requestAnimationFrame(async()=>{const t=p.get(e);if(t){if(p.delete(e),f>=3)return m.push({options:t.options,key:e,count:t.count}),void v();await g(t.options,e,t.count)}})}async function g(t,e,n){try{f++;const o=await l(t,c),r=await i(t,x);if(!r)throw new Error("Toast element creation failed");const s=document.createElement("div");Object.assign(s.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%"});const a=document.createElement("div");Object.assign(a.style,{position:"relative",overflow:"hidden",borderRadius:t.borderRadius||"8px",zIndex:"1"}),a.appendChild(r),s.appendChild(a),o.id.includes("toast-container-")&&o.appendChild(s);const u=!1!==t.pauseOnHover&&(!0===t.pauseOnHover||!!t.cta),p={outer:s,toast:r,count:Math.max(1,0|n),timeout:null,pauseOnHover:u};d.set(e,p),r._key=e,p.count>1&&C(p),p.timer=b(r,t),w(p)}catch(e){f=Math.max(0,f-1);(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(o(t,x))}}function b(t,e){const n=(e.duration||1800)+10,o=new u(()=>x(t),n);return o.start(),o}function w(t){if(!t.pauseOnHover||!t.outer||!t.timer)return;const{outer:e,timer:n}=t,o=()=>{n.pause()},i=()=>{n.resume()},r=t=>{t.target.matches("button, a, [tabindex]")&&n.pause()},s=t=>{e.contains(t.relatedTarget)||n.resume()};e.addEventListener("mouseenter",o),e.addEventListener("mouseleave",i),e.addEventListener("focusin",r),e.addEventListener("focusout",s),e._pauseCleanup=()=>{e.removeEventListener("mouseenter",o),e.removeEventListener("mouseleave",i),e.removeEventListener("focusin",r),e.removeEventListener("focusout",s)}}async function x(t){if(!t||!t._key)return;const e=d.get(t._key);var n;e&&(e.timer?.clear(),e.outer?._pauseCleanup?.(),d.delete(t._key),f=Math.max(0,f-1),e.outer.querySelector(".toast-count-badge")?.remove(),await(n=e.outer,new Promise(t=>{let e=!1;const o=()=>{e||(e=!0,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}}}}(n),t())},i=n.firstElementChild||n,r=t=>{t.target===i&&(i.removeEventListener("transitionend",r,!0),o())};i.addEventListener("transitionend",r,!0),setTimeout(()=>{i.removeEventListener("transitionend",r,!0),o()},700)})),v())}function v(){for(;f<3&&m.length;){const t=m.shift();if(d.has(t.key)){const e=d.get(t.key);e.count+=t.count,C(e);continue}g(t.options,t.key,t.count)}}function C({outer:t,count:e}){if(e<2)return void t.querySelector(".toast-count-badge")?.remove();let n=t.querySelector(".toast-count-badge");n||(n=document.createElement("span"),n.className="toast-count-badge",n.setAttribute("aria-label",`${e} identical notifications`),Object.assign(n.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),t.appendChild(n)),n.textContent=e>99?"99+":String(e),n.style.transform="scale(1.2)",setTimeout(()=>n.style.transform="scale(1)",150)}
16
- // * @license Apache-2.0
17
- let k={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},E={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const I=[];let T=!1;async function S(t={}){try{const n=await async function(t){const n=t?.position?.toLowerCase()?.trim(),o=n?.includes("top-full-width")||n?.includes("bottom-full-width")?"100vw":"400px",i={pauseOnHover:void 0,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};i.message=t?.message??i.message;try{i.backgroundColor||(i.backgroundColor=k?.[i.type]??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111")),i.message=i.message||E?.[i.type]||"No Message Provided!",!i.textColor&&i.backgroundColor&&(i.textColor=await e(i.backgroundColor)),!i.progressColor&&i.backgroundColor&&(i.progressColor=await e(i.backgroundColor))}catch(t){}"string"!=typeof i.message&&(i.message="No Message Provided!");return i}(t);await async function(t){try{return await l(t,c)}catch(t){return document.body}}(n),await y(n)}catch(e){const n="string"==typeof t?.message&&null!==t?.message?`${t?.message?.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}let L=!1;async function A(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){T||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(T=!0,I.forEach(t=>setTimeout(()=>S(t),2e3)),I.length=0):document.addEventListener("DOMContentLoaded",()=>{T=!0,I.forEach(t=>setTimeout(()=>S(t),2e3)),I.length=0},{once:!0}))}(),T?L?await S(t):(L=!0,setTimeout(await S(t),2e3)):I.push(t))}function B(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(k={...k,...t})}catch(t){}}function M(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(E={...E,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:A,setDefaultColors:B,setDefaultMessages:M})}catch(t){}exports.createToast=A,exports.noop=function(){x(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=B,exports.setDefaultMessages=M;
15
+ "use strict";async function t(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function e(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 i=t.substring(1);if(3===i.length)e=parseInt(i[0]+i[0],16),n=parseInt(i[1]+i[1],16),o=parseInt(i[2]+i[2],16);else{if(6!==i.length)throw new Error(`Invalid hex color format: ${t}`);e=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16)}}else if(t.startsWith("rgb")||t.startsWith("rgba")){const i=t.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(!i)throw new Error(`Invalid rgb/rgba color format: ${t}`);e=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3])}else{const i={black:[255,255,255],white:[0,0,0]}[t.toLowerCase()];if(!i)throw new Error(`Unsupported color format: ${t}`);e=i[0],n=i[1],o=i[2]}if(isNaN(e)||isNaN(n)||isNaN(o))throw new Error(`Invalid color value: ${t}`);const i=(.2126*e+.7152*n+.0722*o)/255,r=.05;return(Math.max(i,r)+.05)/Math.min(i,r)}(t)>3.5?"black":"white"}catch(t){return"black"}}async function n(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 i=document.createElement("span");i.style.position=e.fontPosition,i.style.display="inline-block",i.style.flex="1",i.style.padding=e.fontPadding,i.style.borderRadius=e.fontBorderRadius,i.style.background=e.fontBackgroundColor,i.style.fontFamily=e.fontFamily,i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.lineHeight=e.fontLineHeight,i.style.color=e.textColor,i.style.userSelect="text",i.style.wordBreak="break-word",i.style.direction=e.fontDirection,i.style.webkitLineClamp="3",i.style.webkitBoxOrient="vertical",i.style.whiteSpace=e.wrapText?"normal":"nowrap",i.style.display="block",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.lineClamp="3",i.style.boxOrient="vertical",i.style.display="-webkit-box",i.textContent=e.message,i.setAttribute("aria-label","Toast Notification Center"),i.setAttribute("title",e.message),t.appendChild(i),await async function(t,e,n){const o=null==e?void 0:e.cta;if(!o||!o.label)return;const i=!!o.href&&"link"===o.variant,r=document.createElement(i?"a":"button");i?(r.href=o.href,o.target&&(r.target=o.target),r.rel=o.rel||("_blank"===o.target?"noopener noreferrer":"")):r.type="button";r.setAttribute("aria-label",o.ariaLabel||o.label),Object.assign(r.style,{marginLeft:"10px",padding:"6px 10px",borderRadius:"6px",fontSize:"12px",fontWeight:"600",lineHeight:"1",border:"1px solid rgba(255,255,255,0.35)",color:e.textColor||"#fff",background:"rgba(255,255,255,0.15)",cursor:"pointer",whiteSpace:"nowrap",flexShrink:"0"}),r.textContent=o.label,r.addEventListener("click",async e=>{try{if("function"==typeof o.onClick){const t=o.onClick(e);null!=t&&t.then&&await t}}finally{!1!==o.autoClose&&n(t)}}),t.appendChild(r)}(t,e,n),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(null==t?void 0: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 o(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(e,i){let r;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return r=await async function(e,n){try{const o=document.createElement(e);return o.id=await t(n),o}catch(e){try{const e="div",n="fallback",o=document.createElement(e);return o.id=await t(n),o.setAttribute("data-original-tag",e),o}catch(t){}}}("div","toast"),await n(r,e,i),r}catch(t){return await o(e,i),r}}const r=new Map,a=new Map;function s(t="bottom-right"){return`toast-container-${function(t="bottom-right"){return String(t).toLowerCase().trim().replace(/\bbelow\b/g,"bottom").replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"-").replace(/\-+/g,"-")}(t)}`}async function l(t={},e){const n=s(t.position);if(a.has(n))return a.get(n);const o=(async()=>{const o=r.get(n);if(o&&o.isConnected)return o;let i=document.getElementById(n);i&&!i.isConnected&&document.body.appendChild(i),i?(i.style.position=i.style.position||"fixed",i.style.zIndex=i.style.zIndex||"9999","function"==typeof e&&await e(i,t)):(i=document.createElement("div"),i.id=n,i.setAttribute("role","status"),i.setAttribute("aria-atomic","true"),i.style.position="fixed",i.style.zIndex="9999",i.style.inset="auto 10px 10px auto",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.flexDirection="column",i.style.overflow="hidden","function"==typeof e&&await e(i,t),document.body.appendChild(i));const a=document.querySelectorAll(`#${n}`);if(a.length>1)for(let t=1;t<a.length;t++)try{a[t].remove()}catch{}return r.set(n,i),i})();a.set(n,o);try{return await o}finally{a.delete(s(t.position))}}async function c(t,e){if(!t||!e.position)throw new Error("Invalid container or position!");!function(t){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none"}(t);const n=function(t){const e=t.toLowerCase().trim();return{hasTop:e.includes("top"),hasBottom:e.includes("bottom")||e.includes("below"),hasLeft:e.includes("left"),hasRight:e.includes("right"),hasCenter:e.includes("center"),hasFullWidth:e.includes("top-full-width")||e.includes("bottom-full-width")||e.includes("fullwidth")}}(e.position);(function(t,e,n){if(!n.hasFullWidth)return!1;if(e.maxWidth="100vw",n.hasTop)return t.style.top="10px",t.style.left="10px",t.style.right="10px",!0;if(n.hasBottom)return t.style.bottom="10px",t.style.left="10px",t.style.right="10px",!0;return!1})(t,e,n)||function(t,e){if(!e.hasCenter)return!1;if(e.hasTop&&!e.hasLeft&&!e.hasRight)return t.style.top="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasBottom&&!e.hasLeft&&!e.hasRight)return t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)",!0;if(e.hasLeft&&!e.hasTop&&!e.hasBottom)return t.style.left="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(e.hasRight&&!e.hasTop&&!e.hasBottom)return t.style.right="10px",t.style.top="50%",t.style.transform="translateY(-50%)",!0;if(!(e.hasLeft||e.hasRight||e.hasTop||e.hasBottom))return t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",!0;return!1}(t,n)||function(t,e){e.hasBottom?t.style.bottom="10px":e.hasTop&&(t.style.top="10px");e.hasRight?t.style.right="10px":e.hasLeft?t.style.left="10px":(t.style.bottom="10px",t.style.left="50%",t.style.transform="translateX(-50%)")}(t,n)}class u{constructor(t,e){this.callback=t,this.delay=e,this.remaining=e,this.startTime=null,this.timeoutId=null,this.isPaused=!1,this.isCompleted=!1}start(){return this.isCompleted||this.timeoutId||(this.startTime=Date.now(),this.timeoutId=setTimeout(()=>{this.isCompleted=!0,this.timeoutId=null,this.callback()},this.remaining)),this}pause(){return this.isPaused||!this.timeoutId||this.isCompleted||(clearTimeout(this.timeoutId),this.timeoutId=null,this.remaining-=Date.now()-this.startTime,this.remaining=Math.max(0,this.remaining),this.isPaused=!0),this}resume(){return!this.isPaused||this.isCompleted||(this.isPaused=!1,this.start()),this}clear(){return this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.isCompleted=!0,this}getRemainingTime(){return this.isCompleted?0:this.isPaused?this.remaining:this.timeoutId?Math.max(0,this.remaining-(Date.now()-this.startTime)):this.delay}}const d=new Map,p=new Map,m=[];let f=0;function h(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return e>>>0}async function y(t={}){const e=function({type:t="info",message:e="",position:n="bottom-right"}){return[String(t).trim().toLowerCase(),h(String(e)).toString(16),String(n).trim().toLowerCase()].join("|")}(t);if(d.has(e)){const n=d.get(e);return n.count++,n.timer.clear(),n.timer=b(n.toast,t),w(n),void C(n)}if(p.has(e))return void p.get(e).count++;const n={options:t,count:1,rafId:0};p.set(e,n),n.rafId=requestAnimationFrame(async()=>{const t=p.get(e);if(t){if(p.delete(e),f>=3)return m.push({options:t.options,key:e,count:t.count}),void v();await g(t.options,e,t.count)}})}async function g(t,e,n){try{f++;const o=await l(t,c),r=await i(t,x);if(!r)throw new Error("Toast element creation failed");const a=document.createElement("div");Object.assign(a.style,{position:"relative",display:"inline-block",overflow:"visible",marginBottom:"10px",zIndex:"0",width:"100%"});const s=document.createElement("div");Object.assign(s.style,{position:"relative",overflow:"hidden",borderRadius:t.borderRadius||"8px",zIndex:"1"}),s.appendChild(r),a.appendChild(s),o.id.includes("toast-container-")&&o.appendChild(a);const u=!1!==t.pauseOnHover&&(!0===t.pauseOnHover||!!t.cta),p={outer:a,toast:r,count:Math.max(1,0|n),timeout:null,pauseOnHover:u};d.set(e,p),r._key=e,p.count>1&&C(p),p.timer=b(r,t),w(p)}catch(e){f=Math.max(0,f-1);(document.querySelector('[id^="toast-container-"]')||document.body).appendChild(o(t,x))}}function b(t,e){const n=(e.duration||1800)+10,o=new u(()=>x(t),n);return o.start(),o}function w(t){if(!t.pauseOnHover||!t.outer||!t.timer)return;const{outer:e,timer:n}=t,o=()=>{n.pause()},i=()=>{n.resume()},r=t=>{t.target.matches("button, a, [tabindex]")&&n.pause()},a=t=>{e.contains(t.relatedTarget)||n.resume()};e.addEventListener("mouseenter",o),e.addEventListener("mouseleave",i),e.addEventListener("focusin",r),e.addEventListener("focusout",a),e._pauseCleanup=()=>{e.removeEventListener("mouseenter",o),e.removeEventListener("mouseleave",i),e.removeEventListener("focusin",r),e.removeEventListener("focusout",a)}}async function x(t){var e,n,o,i;if(!t||!t._key)return;const r=d.get(t._key);var a;r&&(null===(e=r.timer)||void 0===e||e.clear(),null===(n=r.outer)||void 0===n||null===(o=n._pauseCleanup)||void 0===o||o.call(n),d.delete(t._key),f=Math.max(0,f-1),null===(i=r.outer.querySelector(".toast-count-badge"))||void 0===i||i.remove(),await(a=r.outer,new Promise(t=>{let e=!1;const n=()=>{e||(e=!0,async function(t){if(!t)return!0;try{var e;if(null!=t&&null!==(e=t.parentNode)&&void 0!==e&&e.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(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}}}}(a),t())},o=a.firstElementChild||a,i=t=>{t.target===o&&(o.removeEventListener("transitionend",i,!0),n())};o.addEventListener("transitionend",i,!0),setTimeout(()=>{o.removeEventListener("transitionend",i,!0),n()},700)})),v())}function v(){for(;f<3&&m.length;){const t=m.shift();if(d.has(t.key)){const e=d.get(t.key);e.count+=t.count,C(e);continue}g(t.options,t.key,t.count)}}function C({outer:t,count:e}){var n;if(e<2)return void(null===(n=t.querySelector(".toast-count-badge"))||void 0===n||n.remove());let o=t.querySelector(".toast-count-badge");o||(o=document.createElement("span"),o.className="toast-count-badge",o.setAttribute("aria-label",`${e} identical notifications`),Object.assign(o.style,{position:"absolute",top:"6px",right:"6px",backgroundColor:"#f44336",color:"#fff",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #fff",boxShadow:"0 2px 6px rgba(0,0,0,0.3)",zIndex:"2",pointerEvents:"none",transition:"transform 150ms ease"}),t.appendChild(o)),o.textContent=e>99?"99+":String(e),o.style.transform="scale(1.2)",setTimeout(()=>o.style.transform="scale(1)",150)}let k={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},E={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};const I=[];let T=!1;async function S(t={}){try{const n=await async function(t){var n;const o=null==t||null===(n=t.position)||void 0===n||null===(n=n.toLowerCase())||void 0===n?void 0:n.trim(),i=null!=o&&o.includes("top-full-width")||null!=o&&o.includes("bottom-full-width")?"100vw":"400px",r={pauseOnHover:void 0,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:i,..."object"!=typeof t||Array.isArray(t)?{}:t};r.message=(null==t?void 0:t.message)??r.message;try{var a,s;if(!r.backgroundColor)r.backgroundColor=(null===(s=k)||void 0===s?void 0:s[r.type])??(window.matchMedia("(prefers-color-scheme: dark)").matches?"#f5f5f5":"#111111");r.message=r.message||(null===(a=E)||void 0===a?void 0:a[r.type])||"No Message Provided!",!r.textColor&&r.backgroundColor&&(r.textColor=await e(r.backgroundColor)),!r.progressColor&&r.backgroundColor&&(r.progressColor=await e(r.backgroundColor))}catch(t){}"string"!=typeof r.message&&(r.message="No Message Provided!");return r}(t);await async function(t){try{return await l(t,c)}catch(t){return document.body}}(n),await y(n)}catch(e){var n;const o="string"==typeof(null==t?void 0:t.message)&&null!==(null==t?void 0:t.message)?`${null==t||null===(n=t.message)||void 0===n?void 0:n.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(o)}}let L=!1;async function A(t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(await async function(){T||"undefined"!=typeof window&&"undefined"!=typeof document&&("complete"===document.readyState||"interactive"===document.readyState?(T=!0,I.forEach(t=>setTimeout(()=>S(t),2e3)),I.length=0):document.addEventListener("DOMContentLoaded",()=>{T=!0,I.forEach(t=>setTimeout(()=>S(t),2e3)),I.length=0},{once:!0}))}(),T?L?await S(t):(L=!0,setTimeout(await S(t),2e3)):I.push(t))}function B(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(k={...k,...t})}catch(t){}}function M(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(E={...E,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:A,setDefaultColors:B,setDefaultMessages:M})}catch(t){}exports.createToast=A,exports.noop=function(){x(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=B,exports.setDefaultMessages=M;
18
16
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/utils/id.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/utils/containerRegistry.js","../src/utils/position.js","../src/utils/PausableTimer.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// 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 // CTA factory that appends a safe, keyboard‑accessible button/link at the end of the row\r\n await createCTA(toast, options, onClose);\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\r\n/**\r\n * Append a Call-To-Action (CTA) element to the toast container.\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n * @returns {HTMLElement} CTA element\r\n * @example\r\n * const toast = createToast({ ... });\r\n * const cta = createCTA(toast, { cta: { label: \"Visit our website\", href: \"https://www.example.com/\", variant: \"link\" } });\r\n */\r\nexport async function createCTA(toast, options, onClose) {\r\n const cfg = options?.cta;\r\n if (!cfg || !cfg.label) return;\r\n\r\n const isLink = !!cfg.href && cfg.variant === \"link\";\r\n const el = document.createElement(isLink ? \"a\" : \"button\");\r\n\r\n // Base a11y and semantics\r\n if (isLink) {\r\n el.href = cfg.href;\r\n if (cfg.target) el.target = cfg.target;\r\n el.rel = cfg.rel || (cfg.target === \"_blank\" ? \"noopener noreferrer\" : \"\");\r\n } else {\r\n el.type = \"button\";\r\n }\r\n el.setAttribute(\"aria-label\", cfg.ariaLabel || cfg.label);\r\n\r\n // Visuals that fit any theme; minimal, non-intrusive\r\n Object.assign(el.style, {\r\n marginLeft: \"10px\",\r\n padding: \"6px 10px\",\r\n borderRadius: \"6px\",\r\n fontSize: \"12px\",\r\n fontWeight: \"600\",\r\n lineHeight: \"1\",\r\n border: \"1px solid rgba(255,255,255,0.35)\",\r\n color: options.textColor || \"#fff\",\r\n background: \"rgba(255,255,255,0.15)\",\r\n cursor: \"pointer\",\r\n whiteSpace: \"nowrap\",\r\n flexShrink: \"0\",\r\n });\r\n\r\n el.textContent = cfg.label;\r\n\r\n // Click behavior\r\n el.addEventListener(\"click\", async (e) => {\r\n try {\r\n if (typeof cfg.onClick === \"function\") {\r\n const ret = cfg.onClick(e);\r\n if (ret?.then) await ret; // allow async actions\r\n }\r\n } finally {\r\n if (cfg.autoClose !== false) onClose(toast);\r\n }\r\n });\r\n\r\n // Append after message span, before close/progress doesn’t matter (flex)\r\n toast.appendChild(el);\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/utils/containerRegistry.js\r\n\"use strict\";\r\n\r\nconst containerRegistry = new Map(); // id -> HTMLElement\r\nconst containerLocks = new Map(); // id -> Promise<HTMLElement>\r\n\r\n/**\r\n * Normalize a position string to a canonical key (id-safe, stable).\r\n */\r\nexport function normalizePositionKey(position = \"bottom-right\") {\r\n // lower-case, trim, unify separators, alias \"below\" -> \"bottom\"\r\n const raw = String(position).toLowerCase().trim();\r\n const aliased = raw.replace(/\\bbelow\\b/g, \"bottom\");\r\n return aliased\r\n .replace(/\\s+/g, \"-\")\r\n .replace(/[^a-z0-9\\-]/g, \"-\")\r\n .replace(/\\-+/g, \"-\");\r\n}\r\n\r\n/**\r\n * Canonical container id\r\n */\r\nexport function getContainerId(position = \"bottom-right\") {\r\n return `toast-container-${normalizePositionKey(position)}`;\r\n}\r\n\r\n/**\r\n * Atomically get or create a single container per canonical id.\r\n */\r\nexport async function getOrCreateToastContainer(options = {}, setPosition) {\r\n const id = getContainerId(options.position);\r\n // If a creation is in-flight, await it\r\n if (containerLocks.has(id)) {\r\n return containerLocks.get(id);\r\n }\r\n\r\n const p = (async () => {\r\n // 1) Prefer registry cache if still connected\r\n const cached = containerRegistry.get(id);\r\n if (cached && cached.isConnected) {\r\n return cached;\r\n }\r\n\r\n // 2) Find existing in DOM\r\n let el = document.getElementById(id); // unique by spec, but may return first if duplicates exist\r\n if (el && !el.isConnected) {\r\n // re-attach if detached\r\n document.body.appendChild(el);\r\n }\r\n\r\n // 3) If not found, create\r\n if (!el) {\r\n el = document.createElement(\"div\");\r\n el.id = id;\r\n el.setAttribute(\"role\", \"status\"); // polite + atomic by default\r\n el.setAttribute(\"aria-atomic\", \"true\"); // explicit for consistency\r\n el.style.position = \"fixed\";\r\n el.style.zIndex = \"9999\";\r\n el.style.inset = \"auto 10px 10px auto\";\r\n el.style.display = \"flex\";\r\n el.style.justifyContent = \"space-between\";\r\n el.style.alignItems = \"center\";\r\n el.style.flexDirection = \"column\";\r\n el.style.overflow = \"hidden\";\r\n // Position with provided helper\r\n if (typeof setPosition === \"function\") {\r\n await setPosition(el, options);\r\n }\r\n document.body.appendChild(el);\r\n } else {\r\n // Ensure base styles and (re)apply position in case options changed\r\n el.style.position = el.style.position || \"fixed\";\r\n el.style.zIndex = el.style.zIndex || \"9999\";\r\n if (typeof setPosition === \"function\") {\r\n await setPosition(el, options);\r\n }\r\n }\r\n\r\n // 4) If somehow duplicates exist, keep the first and remove the rest\r\n // getElementById would have returned the first; clean up others proactively\r\n const all = document.querySelectorAll(`#${id}`);\r\n if (all.length > 1) {\r\n for (let i = 1; i < all.length; i++) {\r\n try {\r\n all[i].remove();\r\n } catch {}\r\n }\r\n }\r\n\r\n containerRegistry.set(id, el);\r\n return el;\r\n })();\r\n\r\n containerLocks.set(id, p);\r\n try {\r\n const out = await p;\r\n return out;\r\n } finally {\r\n // Clear the lock so future calls can re-enter if needed\r\n containerLocks.delete(getContainerId(options.position));\r\n }\r\n}\r\n","// 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/PausableTimer.js\r\n\"use strict\";\r\n\r\nexport class PausableTimer {\r\n constructor(callback, delay) {\r\n this.callback = callback;\r\n this.delay = delay;\r\n this.remaining = delay;\r\n this.startTime = null;\r\n this.timeoutId = null;\r\n this.isPaused = false;\r\n this.isCompleted = false;\r\n }\r\n\r\n start() {\r\n if (this.isCompleted || this.timeoutId) return this;\r\n this.startTime = Date.now();\r\n this.timeoutId = setTimeout(() => {\r\n this.isCompleted = true;\r\n this.timeoutId = null;\r\n this.callback();\r\n }, this.remaining);\r\n return this;\r\n }\r\n\r\n pause() {\r\n if (this.isPaused || !this.timeoutId || this.isCompleted) return this;\r\n clearTimeout(this.timeoutId);\r\n this.timeoutId = null;\r\n this.remaining -= Date.now() - this.startTime;\r\n this.remaining = Math.max(0, this.remaining); // prevent negative\r\n this.isPaused = true;\r\n return this;\r\n }\r\n\r\n resume() {\r\n if (!this.isPaused || this.isCompleted) return this;\r\n this.isPaused = false;\r\n this.start();\r\n return this;\r\n }\r\n\r\n clear() {\r\n if (this.timeoutId) {\r\n clearTimeout(this.timeoutId);\r\n this.timeoutId = null;\r\n }\r\n this.isCompleted = true;\r\n return this;\r\n }\r\n\r\n getRemainingTime() {\r\n if (this.isCompleted) return 0;\r\n if (this.isPaused) return this.remaining;\r\n if (!this.timeoutId) return this.delay;\r\n return Math.max(0, this.remaining - (Date.now() - this.startTime));\r\n }\r\n}\r\n","// src/components/ToastManager.js\r\n\"use strict\";\r\n\r\n// import { 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\nimport { getOrCreateToastContainer } from \"../utils/containerRegistry.js\";\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { PausableTimer } from \"../utils/PausableTimer.js\";\r\n\r\n// Config\r\nconst MAX_VISIBLE = 3;\r\n\r\n// State\r\nconst active = new Map(); // key -> { outer, toast, count, timeout }\r\nconst pending = new Map(); // key -> { options, count, rafId }\r\nconst queue = []; // [{ options, key, count }]\r\nlet visibleCount = 0;\r\n\r\n// djb2 hash for full-message dedupe\r\nfunction hashString(str) {\r\n let h = 5381;\r\n for (let i = 0; i < str.length; i++) h = (h << 5) + h + str.charCodeAt(i);\r\n return h >>> 0;\r\n}\r\n\r\n/**\r\n * Creates a unique key for a toast notification based on its type, message, and position.\r\n * This key is used to identify and deduplicate identical toast notifications.\r\n * @param {Object} options - Toast options with type, message, and position.\r\n * @returns {string} A unique key for the toast notification.\r\n */\r\nfunction makeKey({ type = \"info\", message = \"\", position = \"bottom-right\" }) {\r\n return [\r\n String(type).trim().toLowerCase(),\r\n hashString(String(message)).toString(16),\r\n String(position).trim().toLowerCase(),\r\n ].join(\"|\");\r\n}\r\n\r\n/**\r\n * Shows a toast notification with the given options.\r\n * If there is already an active toast with the same type, message, and position,\r\n * it will be grouped immediately and the count will be incremented.\r\n * If there is already a pending toast with the same type, message, and position,\r\n * it will be coalesced and the count will be incremented.\r\n * If there is no capacity left (i.e. the number of visible toasts is at the maximum),\r\n * the grouped request will be enqueued and processed later.\r\n * @param {Object} options - Toast options with type, message, and position.\r\n * @returns {Promise<void>} A promise that resolves when the toast is fully created and displayed.\r\n */\r\nexport async function showToast(options = {}) {\r\n const key = makeKey(options);\r\n\r\n // If already active: group immediately\r\n if (active.has(key)) {\r\n const data = active.get(key);\r\n data.count++;\r\n // clearTimeout(data.timeout);\r\n // data.timeout = await safeSetTimeout(\r\n // () => closeToast(data.toast),\r\n // (options.duration || 1800) + 10\r\n // );\r\n\r\n // Reset timer with new duration\r\n data.timer.clear();\r\n data.timer = createDismissTimer(data.toast, options);\r\n setupPauseOnHover(data);\r\n updateBadge(data);\r\n return;\r\n }\r\n\r\n // If coalescing is already scheduled for this key, just increment the pending count\r\n if (pending.has(key)) {\r\n pending.get(key).count++;\r\n return;\r\n }\r\n\r\n // Start coalescing identical calls in the same frame\r\n const entry = { options, count: 1, rafId: 0 };\r\n pending.set(key, entry);\r\n\r\n entry.rafId = requestAnimationFrame(async () => {\r\n // finalize batch for this key\r\n const current = pending.get(key);\r\n if (!current) return;\r\n pending.delete(key);\r\n\r\n // If capacity full, enqueue the grouped request\r\n if (visibleCount >= MAX_VISIBLE) {\r\n queue.push({ options: current.options, key, count: current.count });\r\n drainQueue();\r\n return;\r\n }\r\n\r\n // Otherwise create immediately with the grouped count\r\n await createOne(current.options, key, current.count);\r\n });\r\n}\r\n\r\n/**\r\n * Creates a single toast notification with the given options and initial count.\r\n * Will create and mount the toast element, and setup a timer to auto-dismiss.\r\n * If the toast creation fails, it will fallback to an emergency toast.\r\n * @param {Object} options - Toast options with type, message, and position.\r\n * @param {string} key - Unique key for the toast.\r\n * @param {number} initialCount - Initial count for the toast.\r\n * @returns {Promise<void>} A promise that resolves when the toast is fully created and displayed.\r\n */\r\nasync function createOne(options, key, initialCount) {\r\n try {\r\n visibleCount++;\r\n\r\n const container = await getOrCreateToastContainer(options, setPosition);\r\n\r\n // Build the toast element\r\n const toast = await createToastElement(options, closeToast);\r\n if (!toast) throw new Error(\"Toast element creation failed\");\r\n\r\n // Outer wrapper (badge surface; visible overflow)\r\n const outer = document.createElement(\"div\");\r\n Object.assign(outer.style, {\r\n position: \"relative\",\r\n display: \"inline-block\",\r\n overflow: \"visible\",\r\n marginBottom: \"10px\",\r\n zIndex: \"0\",\r\n width: \"100%\",\r\n });\r\n\r\n // Inner wrapper (clip progress bar & rounded corners)\r\n const inner = document.createElement(\"div\");\r\n Object.assign(inner.style, {\r\n position: \"relative\",\r\n overflow: \"hidden\",\r\n borderRadius: options.borderRadius || \"8px\",\r\n zIndex: \"1\",\r\n });\r\n\r\n inner.appendChild(toast);\r\n outer.appendChild(inner);\r\n\r\n // Mount\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(outer);\r\n }\r\n\r\n // Determine if should pause on hover (default: true if has CTA)\r\n const shouldPauseOnHover =\r\n options.pauseOnHover !== false &&\r\n (options.pauseOnHover === true || !!options.cta);\r\n\r\n // Track\r\n const data = {\r\n outer,\r\n toast,\r\n count: Math.max(1, initialCount | 0),\r\n timeout: null,\r\n pauseOnHover: shouldPauseOnHover,\r\n };\r\n active.set(key, data);\r\n toast._key = key;\r\n\r\n if (data.count > 1) updateBadge(data);\r\n // Create and start timer\r\n data.timer = createDismissTimer(toast, options);\r\n setupPauseOnHover(data);\r\n\r\n // Auto-dismiss timer\r\n // data.timeout = await safeSetTimeout(\r\n // () => closeToast(toast),\r\n // (options.duration || 1800) + 10\r\n // );\r\n } catch (err) {\r\n // Rollback slot and fall back\r\n visibleCount = Math.max(0, visibleCount - 1);\r\n console.warn(\"Toast creation failed:\", err);\r\n const el =\r\n document.querySelector('[id^=\"toast-container-\"]') || document.body;\r\n el.appendChild(createEmergencyToast(options, closeToast));\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PausableTimer that auto-closes a toast after a delay.\r\n * @param {HTMLElement} toast - The toast element to auto-close.\r\n * @param {Object} options - Toast options with duration.\r\n * @returns {PausableTimer} A timer that can be paused, resumed, or cleared.\r\n */\r\nfunction createDismissTimer(toast, options) {\r\n const delay = (options.duration || 1800) + 10;\r\n const timer = new PausableTimer(() => closeToast(toast), delay);\r\n timer.start();\r\n return timer;\r\n}\r\n\r\nfunction setupPauseOnHover(data) {\r\n if (!data.pauseOnHover || !data.outer || !data.timer) return;\r\n\r\n const { outer, timer } = data;\r\n\r\n // Mouse events\r\n const onMouseEnter = () => {\r\n timer.pause();\r\n };\r\n\r\n const onMouseLeave = () => {\r\n timer.resume();\r\n };\r\n\r\n // Focus events (for keyboard users)\r\n const onFocusIn = (e) => {\r\n // Only pause if focus is on interactive elements (CTA, close button)\r\n if (e.target.matches(\"button, a, [tabindex]\")) {\r\n timer.pause();\r\n }\r\n };\r\n\r\n const onFocusOut = (e) => {\r\n // Only resume if focus is leaving the toast entirely\r\n if (!outer.contains(e.relatedTarget)) {\r\n timer.resume();\r\n }\r\n };\r\n\r\n // Add event listeners\r\n outer.addEventListener(\"mouseenter\", onMouseEnter);\r\n outer.addEventListener(\"mouseleave\", onMouseLeave);\r\n outer.addEventListener(\"focusin\", onFocusIn);\r\n outer.addEventListener(\"focusout\", onFocusOut);\r\n\r\n // Store cleanup function\r\n outer._pauseCleanup = () => {\r\n outer.removeEventListener(\"mouseenter\", onMouseEnter);\r\n outer.removeEventListener(\"mouseleave\", onMouseLeave);\r\n outer.removeEventListener(\"focusin\", onFocusIn);\r\n outer.removeEventListener(\"focusout\", onFocusOut);\r\n };\r\n}\r\n\r\n/**\r\n * Closes a toast notification immediately.\r\n * If the toast is not found in the active toasts map, this function does nothing.\r\n * @param {HTMLElement} toast - The toast element to close.\r\n * @returns {Promise<void>} A promise that resolves when the toast is fully removed from the DOM.\r\n */\r\nexport async function closeToast(toast) {\r\n if (!toast || !toast._key) return;\r\n const data = active.get(toast._key);\r\n if (!data) return;\r\n\r\n // Clear timer and cleanup pause events\r\n data.timer?.clear();\r\n data.outer?._pauseCleanup?.();\r\n // clearTimeout(data.timeout);\r\n active.delete(toast._key);\r\n visibleCount = Math.max(0, visibleCount - 1);\r\n\r\n // Remove badge if present\r\n data.outer.querySelector(\".toast-count-badge\")?.remove();\r\n\r\n // Remove wrapper after transition ends (or fallback)\r\n await removeWithTransition(data.outer);\r\n\r\n // Drain queue after a slot frees\r\n drainQueue();\r\n}\r\n\r\nfunction drainQueue() {\r\n // Fill available slots; coalesce queued entries against active if they became active meanwhile\r\n while (visibleCount < MAX_VISIBLE && queue.length) {\r\n const item = queue.shift();\r\n if (active.has(item.key)) {\r\n const data = active.get(item.key);\r\n data.count += item.count;\r\n updateBadge(data);\r\n continue;\r\n }\r\n // Create without awaiting to keep loop responsive; visibleCount is incremented inside createOne\r\n void createOne(item.options, item.key, item.count);\r\n }\r\n}\r\n\r\nfunction removeWithTransition(el) {\r\n return new Promise((resolve) => {\r\n let done = false;\r\n const finish = () => {\r\n if (done) return;\r\n done = true;\r\n removeElement(el);\r\n resolve();\r\n };\r\n\r\n // Listen on the immediate child (inner wrapper) if possible\r\n const child = el.firstElementChild || el;\r\n const onEnd = (e) => {\r\n if (e.target !== child) return;\r\n child.removeEventListener(\"transitionend\", onEnd, true);\r\n finish();\r\n };\r\n\r\n child.addEventListener(\"transitionend\", onEnd, true);\r\n // Hard fallback if no transition fires\r\n setTimeout(() => {\r\n child.removeEventListener(\"transitionend\", onEnd, true);\r\n finish();\r\n }, 700);\r\n });\r\n}\r\n\r\nfunction updateBadge({ outer, count }) {\r\n if (count < 2) {\r\n outer.querySelector(\".toast-count-badge\")?.remove();\r\n return;\r\n }\r\n let badge = outer.querySelector(\".toast-count-badge\");\r\n if (!badge) {\r\n badge = document.createElement(\"span\");\r\n badge.className = \"toast-count-badge\";\r\n badge.setAttribute(\"aria-label\", `${count} identical notifications`);\r\n Object.assign(badge.style, {\r\n position: \"absolute\",\r\n top: \"6px\",\r\n right: \"6px\",\r\n backgroundColor: \"#f44336\",\r\n color: \"#fff\",\r\n borderRadius: \"50%\",\r\n minWidth: \"20px\",\r\n height: \"20px\",\r\n fontSize: \"12px\",\r\n fontWeight: \"600\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n border: \"2px solid #fff\",\r\n boxShadow: \"0 2px 6px rgba(0,0,0,0.3)\",\r\n zIndex: \"2\",\r\n pointerEvents: \"none\",\r\n transition: \"transform 150ms ease\",\r\n });\r\n outer.appendChild(badge);\r\n }\r\n badge.textContent = count > 99 ? \"99+\" : String(count);\r\n badge.style.transform = \"scale(1.2)\";\r\n setTimeout(() => (badge.style.transform = \"scale(1)\"), 150);\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 { getOrCreateToastContainer } from \"./utils/containerRegistry.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 // Single source of truth for containers; prevents same-id duplicates\r\n const toastContainer = await getOrCreateToastContainer(\r\n options,\r\n setPosition\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 pauseOnHover: undefined,\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","generateUniqueId","prefix","Date","now","Math","floor","random","getTextColor","toastBg","color","Error","r","g","b","startsWith","hex","substring","length","parseInt","match","colorArray","black","white","toLowerCase","isNaN","l1","l2","max","min","contrast","error","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","style","background","backgroundColor","padding","marginBottom","borderRadius","overflow","display","alignItems","justifyContent","boxShadow","minWidth","maxWidth","opacity","position","transition","animationEasing","transform","zIndex","_animationDuration","messageSpan","document","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","appendChild","cfg","cta","label","isLink","href","variant","el","target","rel","type","ariaLabel","marginLeft","border","cursor","flexShrink","addEventListener","e","onClick","ret","then","autoClose","createCTA","showCloseButton","closeButton","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","left","height","progressHeight","progressColor","width","progressPosition","setTimeout","offsetWidth","forceReflow","createProgressBar","requestAnimationFrame","runToastAnimation","createEmergencyToast","emergency","id","innerHTML","_isEmergencyToast","parentNode","removeChild","emergencyError","alert","alertError","createToastElement","querySelector","tagName","fallbackTag","fallbackPrefix","fallbackEl","fallbackError","createElementWithId","containerRegistry","Map","containerLocks","getContainerId","String","trim","replace","normalizePositionKey","getOrCreateToastContainer","setPosition","has","get","p","cached","isConnected","getElementById","body","inset","flexDirection","all","querySelectorAll","i","remove","set","delete","container","top","bottom","right","resetContainerStyles","positionFlags","pos","hasTop","includes","hasBottom","hasLeft","hasRight","hasCenter","hasFullWidth","parsePosition","flags","handleFullWidthPositions","handleCenterPositions","applyStandardPositioning","PausableTimer","constructor","callback","delay","this","remaining","startTime","timeoutId","isPaused","isCompleted","start","pause","clearTimeout","resume","clear","getRemainingTime","active","pending","queue","visibleCount","hashString","str","h","charCodeAt","showToast","key","toString","join","makeKey","data","count","timer","createDismissTimer","setupPauseOnHover","updateBadge","entry","rafId","current","push","drainQueue","createOne","initialCount","closeToast","outer","inner","shouldPauseOnHover","pauseOnHover","timeout","_key","err","onMouseEnter","onMouseLeave","onFocusIn","matches","onFocusOut","contains","relatedTarget","_pauseCleanup","removeEventListener","Promise","resolve","done","finish","pointerEvents","hideError","removeElement","child","firstElementChild","onEnd","item","shift","badge","className","defaultColors","success","warning","info","defaultMessages","pendingToasts","domReady","createToastNow","sanitizedOptions","contPosition","contMaxWidth","final","undefined","animationType","Array","isArray","window","matchMedia","sanitizeToastOptions","createFirstToastContainer","safeMessage","initialDelayDone","createToast","readyState","forEach","once","checkDOMReady","setDefaultColors","colors","setDefaultMessages","messages","customizableToast"],"mappings":";;;;;;;;;;;;;;aAQOA,eAAeC,EAAiBC,GACrC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CC2JOP,eAAeQ,EAAaC,GACjC,IAAKA,EAAS,MAAO,QACrB,IACE,aAaJT,eAAwBU,GACtB,IAAKA,EACH,MAAM,IAAIC,MAAM,qBAGlB,IAAIC,EAAGC,EAAGC,EAGV,GAAIJ,EAAMK,WAAW,KAAM,CACzB,MAAMC,EAAMN,EAAMO,UAAU,GAC5B,GAAmB,IAAfD,EAAIE,OACNN,EAAIO,SAASH,EAAI,GAAKA,EAAI,GAAI,IAC9BH,EAAIM,SAASH,EAAI,GAAKA,EAAI,GAAI,IAC9BF,EAAIK,SAASH,EAAI,GAAKA,EAAI,GAAI,QACzB,IAAmB,IAAfA,EAAIE,OAKb,MAAM,IAAIP,MAAM,6BAA6BD,KAJ7CE,EAAIO,SAASH,EAAIC,UAAU,EAAG,GAAI,IAClCJ,EAAIM,SAASH,EAAIC,UAAU,EAAG,GAAI,IAClCH,EAAIK,SAASH,EAAIC,UAAU,EAAG,GAAI,GAGpC,CACF,MAEK,GAAIP,EAAMK,WAAW,QAAUL,EAAMK,WAAW,QAAS,CAC5D,MAAMK,EAAQV,EAAMU,MAClB,0EAEF,IAAIA,EAKF,MAAM,IAAIT,MAAM,kCAAkCD,KAJlDE,EAAIO,SAASC,EAAM,IACnBP,EAAIM,SAASC,EAAM,IACnBN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WAEhB,aAAxBA,SAASmO,YACe,gBAAxBnO,SAASmO,YAETjB,GAAW,EAEXD,EAAcmB,QAASpQ,GACrB+F,WAAW,IAAMoJ,EAAenP,GAAU,MAE5CiP,EAAcjQ,OAAS,GAGvBgD,SAAS2C,iBACP,mBACA,KACEuK,GAAW,EACXD,EAAcmB,QAASpQ,GACrB+F,WAAW,IAAMoJ,EAAenP,GAAU,MAE5CiP,EAAcjQ,OAAS,GAEzB,CAAEqR,MAAM,IAIhB,CAoCQC,GAEDpB,EAOAe,QAMGd,EAAenP,IAJrBiQ,GAAmB,EACnBlK,iBAAiBoJ,EAAenP,GAAU,MAR1CiP,EAAcxC,KAAKzM,GAavB,CA4GA,SAASuQ,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBd,MAAMC,QAAQa,KACzD5B,EAAgB,IAAKA,KAAkB4B,GAE3C,CAAE,MAAO3Q,GAET,CACF,CAKA,SAAS4Q,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BhB,MAAMC,QAAQe,KAC7D1B,EAAkB,IAAKA,KAAoB0B,GAE/C,CAAE,MAAO7Q,GAET,CACF,CAWA,IAEwB,oBAAX+P,SACTA,OAAOe,kBAAoB,CACzBT,cACAK,mBACAE,sBAGN,CAAE,MAAO5Q,GAET,oCApBA,WAEEgN,EADc7K,SAASgF,cAAc,yCAEvC"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/id.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/utils/containerRegistry.js","../src/utils/position.js","../src/utils/PausableTimer.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// 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: [255, 255, 255],\r\n white: [0, 0, 0],\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 // CTA factory that appends a safe, keyboard‑accessible button/link at the end of the row\r\n await createCTA(toast, options, onClose);\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\r\n/**\r\n * Append a Call-To-Action (CTA) element to the toast container.\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n * @returns {HTMLElement} CTA element\r\n * @example\r\n * const toast = createToast({ ... });\r\n * const cta = createCTA(toast, { cta: { label: \"Visit our website\", href: \"https://www.example.com/\", variant: \"link\" } });\r\n */\r\nexport async function createCTA(toast, options, onClose) {\r\n const cfg = options?.cta;\r\n if (!cfg || !cfg.label) return;\r\n\r\n const isLink = !!cfg.href && cfg.variant === \"link\";\r\n const el = document.createElement(isLink ? \"a\" : \"button\");\r\n\r\n // Base a11y and semantics\r\n if (isLink) {\r\n el.href = cfg.href;\r\n if (cfg.target) el.target = cfg.target;\r\n el.rel = cfg.rel || (cfg.target === \"_blank\" ? \"noopener noreferrer\" : \"\");\r\n } else {\r\n el.type = \"button\";\r\n }\r\n el.setAttribute(\"aria-label\", cfg.ariaLabel || cfg.label);\r\n\r\n // Visuals that fit any theme; minimal, non-intrusive\r\n Object.assign(el.style, {\r\n marginLeft: \"10px\",\r\n padding: \"6px 10px\",\r\n borderRadius: \"6px\",\r\n fontSize: \"12px\",\r\n fontWeight: \"600\",\r\n lineHeight: \"1\",\r\n border: \"1px solid rgba(255,255,255,0.35)\",\r\n color: options.textColor || \"#fff\",\r\n background: \"rgba(255,255,255,0.15)\",\r\n cursor: \"pointer\",\r\n whiteSpace: \"nowrap\",\r\n flexShrink: \"0\",\r\n });\r\n\r\n el.textContent = cfg.label;\r\n\r\n // Click behavior\r\n el.addEventListener(\"click\", async (e) => {\r\n try {\r\n if (typeof cfg.onClick === \"function\") {\r\n const ret = cfg.onClick(e);\r\n if (ret?.then) await ret; // allow async actions\r\n }\r\n } finally {\r\n if (cfg.autoClose !== false) onClose(toast);\r\n }\r\n });\r\n\r\n // Append after message span, before close/progress doesn’t matter (flex)\r\n toast.appendChild(el);\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/utils/containerRegistry.js\r\n\"use strict\";\r\n\r\nconst containerRegistry = new Map(); // id -> HTMLElement\r\nconst containerLocks = new Map(); // id -> Promise<HTMLElement>\r\n\r\n/**\r\n * Normalize a position string to a canonical key (id-safe, stable).\r\n */\r\nexport function normalizePositionKey(position = \"bottom-right\") {\r\n // lower-case, trim, unify separators, alias \"below\" -> \"bottom\"\r\n const raw = String(position).toLowerCase().trim();\r\n const aliased = raw.replace(/\\bbelow\\b/g, \"bottom\");\r\n return aliased\r\n .replace(/\\s+/g, \"-\")\r\n .replace(/[^a-z0-9\\-]/g, \"-\")\r\n .replace(/\\-+/g, \"-\");\r\n}\r\n\r\n/**\r\n * Canonical container id\r\n */\r\nexport function getContainerId(position = \"bottom-right\") {\r\n return `toast-container-${normalizePositionKey(position)}`;\r\n}\r\n\r\n/**\r\n * Atomically get or create a single container per canonical id.\r\n */\r\nexport async function getOrCreateToastContainer(options = {}, setPosition) {\r\n const id = getContainerId(options.position);\r\n // If a creation is in-flight, await it\r\n if (containerLocks.has(id)) {\r\n return containerLocks.get(id);\r\n }\r\n\r\n const p = (async () => {\r\n // 1) Prefer registry cache if still connected\r\n const cached = containerRegistry.get(id);\r\n if (cached && cached.isConnected) {\r\n return cached;\r\n }\r\n\r\n // 2) Find existing in DOM\r\n let el = document.getElementById(id); // unique by spec, but may return first if duplicates exist\r\n if (el && !el.isConnected) {\r\n // re-attach if detached\r\n document.body.appendChild(el);\r\n }\r\n\r\n // 3) If not found, create\r\n if (!el) {\r\n el = document.createElement(\"div\");\r\n el.id = id;\r\n el.setAttribute(\"role\", \"status\"); // polite + atomic by default\r\n el.setAttribute(\"aria-atomic\", \"true\"); // explicit for consistency\r\n el.style.position = \"fixed\";\r\n el.style.zIndex = \"9999\";\r\n el.style.inset = \"auto 10px 10px auto\";\r\n el.style.display = \"flex\";\r\n el.style.justifyContent = \"space-between\";\r\n el.style.alignItems = \"center\";\r\n el.style.flexDirection = \"column\";\r\n el.style.overflow = \"hidden\";\r\n // Position with provided helper\r\n if (typeof setPosition === \"function\") {\r\n await setPosition(el, options);\r\n }\r\n document.body.appendChild(el);\r\n } else {\r\n // Ensure base styles and (re)apply position in case options changed\r\n el.style.position = el.style.position || \"fixed\";\r\n el.style.zIndex = el.style.zIndex || \"9999\";\r\n if (typeof setPosition === \"function\") {\r\n await setPosition(el, options);\r\n }\r\n }\r\n\r\n // 4) If somehow duplicates exist, keep the first and remove the rest\r\n // getElementById would have returned the first; clean up others proactively\r\n const all = document.querySelectorAll(`#${id}`);\r\n if (all.length > 1) {\r\n for (let i = 1; i < all.length; i++) {\r\n try {\r\n all[i].remove();\r\n } catch {}\r\n }\r\n }\r\n\r\n containerRegistry.set(id, el);\r\n return el;\r\n })();\r\n\r\n containerLocks.set(id, p);\r\n try {\r\n const out = await p;\r\n return out;\r\n } finally {\r\n // Clear the lock so future calls can re-enter if needed\r\n containerLocks.delete(getContainerId(options.position));\r\n }\r\n}\r\n","// 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/PausableTimer.js\r\n\"use strict\";\r\n\r\nexport class PausableTimer {\r\n constructor(callback, delay) {\r\n this.callback = callback;\r\n this.delay = delay;\r\n this.remaining = delay;\r\n this.startTime = null;\r\n this.timeoutId = null;\r\n this.isPaused = false;\r\n this.isCompleted = false;\r\n }\r\n\r\n start() {\r\n if (this.isCompleted || this.timeoutId) return this;\r\n this.startTime = Date.now();\r\n this.timeoutId = setTimeout(() => {\r\n this.isCompleted = true;\r\n this.timeoutId = null;\r\n this.callback();\r\n }, this.remaining);\r\n return this;\r\n }\r\n\r\n pause() {\r\n if (this.isPaused || !this.timeoutId || this.isCompleted) return this;\r\n clearTimeout(this.timeoutId);\r\n this.timeoutId = null;\r\n this.remaining -= Date.now() - this.startTime;\r\n this.remaining = Math.max(0, this.remaining); // prevent negative\r\n this.isPaused = true;\r\n return this;\r\n }\r\n\r\n resume() {\r\n if (!this.isPaused || this.isCompleted) return this;\r\n this.isPaused = false;\r\n this.start();\r\n return this;\r\n }\r\n\r\n clear() {\r\n if (this.timeoutId) {\r\n clearTimeout(this.timeoutId);\r\n this.timeoutId = null;\r\n }\r\n this.isCompleted = true;\r\n return this;\r\n }\r\n\r\n getRemainingTime() {\r\n if (this.isCompleted) return 0;\r\n if (this.isPaused) return this.remaining;\r\n if (!this.timeoutId) return this.delay;\r\n return Math.max(0, this.remaining - (Date.now() - this.startTime));\r\n }\r\n}\r\n","// src/components/ToastManager.js\r\n\"use strict\";\r\n\r\n// import { 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\nimport { getOrCreateToastContainer } from \"../utils/containerRegistry.js\";\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { PausableTimer } from \"../utils/PausableTimer.js\";\r\n\r\n// Config\r\nconst MAX_VISIBLE = 3;\r\n\r\n// State\r\nconst active = new Map(); // key -> { outer, toast, count, timeout }\r\nconst pending = new Map(); // key -> { options, count, rafId }\r\nconst queue = []; // [{ options, key, count }]\r\nlet visibleCount = 0;\r\n\r\n// djb2 hash for full-message dedupe\r\nfunction hashString(str) {\r\n let h = 5381;\r\n for (let i = 0; i < str.length; i++) h = (h << 5) + h + str.charCodeAt(i);\r\n return h >>> 0;\r\n}\r\n\r\n/**\r\n * Creates a unique key for a toast notification based on its type, message, and position.\r\n * This key is used to identify and deduplicate identical toast notifications.\r\n * @param {Object} options - Toast options with type, message, and position.\r\n * @returns {string} A unique key for the toast notification.\r\n */\r\nfunction makeKey({ type = \"info\", message = \"\", position = \"bottom-right\" }) {\r\n return [\r\n String(type).trim().toLowerCase(),\r\n hashString(String(message)).toString(16),\r\n String(position).trim().toLowerCase(),\r\n ].join(\"|\");\r\n}\r\n\r\n/**\r\n * Shows a toast notification with the given options.\r\n * If there is already an active toast with the same type, message, and position,\r\n * it will be grouped immediately and the count will be incremented.\r\n * If there is already a pending toast with the same type, message, and position,\r\n * it will be coalesced and the count will be incremented.\r\n * If there is no capacity left (i.e. the number of visible toasts is at the maximum),\r\n * the grouped request will be enqueued and processed later.\r\n * @param {Object} options - Toast options with type, message, and position.\r\n * @returns {Promise<void>} A promise that resolves when the toast is fully created and displayed.\r\n */\r\nexport async function showToast(options = {}) {\r\n const key = makeKey(options);\r\n\r\n // If already active: group immediately\r\n if (active.has(key)) {\r\n const data = active.get(key);\r\n data.count++;\r\n // clearTimeout(data.timeout);\r\n // data.timeout = await safeSetTimeout(\r\n // () => closeToast(data.toast),\r\n // (options.duration || 1800) + 10\r\n // );\r\n\r\n // Reset timer with new duration\r\n data.timer.clear();\r\n data.timer = createDismissTimer(data.toast, options);\r\n setupPauseOnHover(data);\r\n updateBadge(data);\r\n return;\r\n }\r\n\r\n // If coalescing is already scheduled for this key, just increment the pending count\r\n if (pending.has(key)) {\r\n pending.get(key).count++;\r\n return;\r\n }\r\n\r\n // Start coalescing identical calls in the same frame\r\n const entry = { options, count: 1, rafId: 0 };\r\n pending.set(key, entry);\r\n\r\n entry.rafId = requestAnimationFrame(async () => {\r\n // finalize batch for this key\r\n const current = pending.get(key);\r\n if (!current) return;\r\n pending.delete(key);\r\n\r\n // If capacity full, enqueue the grouped request\r\n if (visibleCount >= MAX_VISIBLE) {\r\n queue.push({ options: current.options, key, count: current.count });\r\n drainQueue();\r\n return;\r\n }\r\n\r\n // Otherwise create immediately with the grouped count\r\n await createOne(current.options, key, current.count);\r\n });\r\n}\r\n\r\n/**\r\n * Creates a single toast notification with the given options and initial count.\r\n * Will create and mount the toast element, and setup a timer to auto-dismiss.\r\n * If the toast creation fails, it will fallback to an emergency toast.\r\n * @param {Object} options - Toast options with type, message, and position.\r\n * @param {string} key - Unique key for the toast.\r\n * @param {number} initialCount - Initial count for the toast.\r\n * @returns {Promise<void>} A promise that resolves when the toast is fully created and displayed.\r\n */\r\nasync function createOne(options, key, initialCount) {\r\n try {\r\n visibleCount++;\r\n\r\n const container = await getOrCreateToastContainer(options, setPosition);\r\n\r\n // Build the toast element\r\n const toast = await createToastElement(options, closeToast);\r\n if (!toast) throw new Error(\"Toast element creation failed\");\r\n\r\n // Outer wrapper (badge surface; visible overflow)\r\n const outer = document.createElement(\"div\");\r\n Object.assign(outer.style, {\r\n position: \"relative\",\r\n display: \"inline-block\",\r\n overflow: \"visible\",\r\n marginBottom: \"10px\",\r\n zIndex: \"0\",\r\n width: \"100%\",\r\n });\r\n\r\n // Inner wrapper (clip progress bar & rounded corners)\r\n const inner = document.createElement(\"div\");\r\n Object.assign(inner.style, {\r\n position: \"relative\",\r\n overflow: \"hidden\",\r\n borderRadius: options.borderRadius || \"8px\",\r\n zIndex: \"1\",\r\n });\r\n\r\n inner.appendChild(toast);\r\n outer.appendChild(inner);\r\n\r\n // Mount\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(outer);\r\n }\r\n\r\n // Determine if should pause on hover (default: true if has CTA)\r\n const shouldPauseOnHover =\r\n options.pauseOnHover !== false &&\r\n (options.pauseOnHover === true || !!options.cta);\r\n\r\n // Track\r\n const data = {\r\n outer,\r\n toast,\r\n count: Math.max(1, initialCount | 0),\r\n timeout: null,\r\n pauseOnHover: shouldPauseOnHover,\r\n };\r\n active.set(key, data);\r\n toast._key = key;\r\n\r\n if (data.count > 1) updateBadge(data);\r\n // Create and start timer\r\n data.timer = createDismissTimer(toast, options);\r\n setupPauseOnHover(data);\r\n\r\n // Auto-dismiss timer\r\n // data.timeout = await safeSetTimeout(\r\n // () => closeToast(toast),\r\n // (options.duration || 1800) + 10\r\n // );\r\n } catch (err) {\r\n // Rollback slot and fall back\r\n visibleCount = Math.max(0, visibleCount - 1);\r\n console.warn(\"Toast creation failed:\", err);\r\n const el =\r\n document.querySelector('[id^=\"toast-container-\"]') || document.body;\r\n el.appendChild(createEmergencyToast(options, closeToast));\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PausableTimer that auto-closes a toast after a delay.\r\n * @param {HTMLElement} toast - The toast element to auto-close.\r\n * @param {Object} options - Toast options with duration.\r\n * @returns {PausableTimer} A timer that can be paused, resumed, or cleared.\r\n */\r\nfunction createDismissTimer(toast, options) {\r\n const delay = (options.duration || 1800) + 10;\r\n const timer = new PausableTimer(() => closeToast(toast), delay);\r\n timer.start();\r\n return timer;\r\n}\r\n\r\nfunction setupPauseOnHover(data) {\r\n if (!data.pauseOnHover || !data.outer || !data.timer) return;\r\n\r\n const { outer, timer } = data;\r\n\r\n // Mouse events\r\n const onMouseEnter = () => {\r\n timer.pause();\r\n };\r\n\r\n const onMouseLeave = () => {\r\n timer.resume();\r\n };\r\n\r\n // Focus events (for keyboard users)\r\n const onFocusIn = (e) => {\r\n // Only pause if focus is on interactive elements (CTA, close button)\r\n if (e.target.matches(\"button, a, [tabindex]\")) {\r\n timer.pause();\r\n }\r\n };\r\n\r\n const onFocusOut = (e) => {\r\n // Only resume if focus is leaving the toast entirely\r\n if (!outer.contains(e.relatedTarget)) {\r\n timer.resume();\r\n }\r\n };\r\n\r\n // Add event listeners\r\n outer.addEventListener(\"mouseenter\", onMouseEnter);\r\n outer.addEventListener(\"mouseleave\", onMouseLeave);\r\n outer.addEventListener(\"focusin\", onFocusIn);\r\n outer.addEventListener(\"focusout\", onFocusOut);\r\n\r\n // Store cleanup function\r\n outer._pauseCleanup = () => {\r\n outer.removeEventListener(\"mouseenter\", onMouseEnter);\r\n outer.removeEventListener(\"mouseleave\", onMouseLeave);\r\n outer.removeEventListener(\"focusin\", onFocusIn);\r\n outer.removeEventListener(\"focusout\", onFocusOut);\r\n };\r\n}\r\n\r\n/**\r\n * Closes a toast notification immediately.\r\n * If the toast is not found in the active toasts map, this function does nothing.\r\n * @param {HTMLElement} toast - The toast element to close.\r\n * @returns {Promise<void>} A promise that resolves when the toast is fully removed from the DOM.\r\n */\r\nexport async function closeToast(toast) {\r\n if (!toast || !toast._key) return;\r\n const data = active.get(toast._key);\r\n if (!data) return;\r\n\r\n // Clear timer and cleanup pause events\r\n data.timer?.clear();\r\n data.outer?._pauseCleanup?.();\r\n // clearTimeout(data.timeout);\r\n active.delete(toast._key);\r\n visibleCount = Math.max(0, visibleCount - 1);\r\n\r\n // Remove badge if present\r\n data.outer.querySelector(\".toast-count-badge\")?.remove();\r\n\r\n // Remove wrapper after transition ends (or fallback)\r\n await removeWithTransition(data.outer);\r\n\r\n // Drain queue after a slot frees\r\n drainQueue();\r\n}\r\n\r\nfunction drainQueue() {\r\n // Fill available slots; coalesce queued entries against active if they became active meanwhile\r\n while (visibleCount < MAX_VISIBLE && queue.length) {\r\n const item = queue.shift();\r\n if (active.has(item.key)) {\r\n const data = active.get(item.key);\r\n data.count += item.count;\r\n updateBadge(data);\r\n continue;\r\n }\r\n // Create without awaiting to keep loop responsive; visibleCount is incremented inside createOne\r\n void createOne(item.options, item.key, item.count);\r\n }\r\n}\r\n\r\nfunction removeWithTransition(el) {\r\n return new Promise((resolve) => {\r\n let done = false;\r\n const finish = () => {\r\n if (done) return;\r\n done = true;\r\n removeElement(el);\r\n resolve();\r\n };\r\n\r\n // Listen on the immediate child (inner wrapper) if possible\r\n const child = el.firstElementChild || el;\r\n const onEnd = (e) => {\r\n if (e.target !== child) return;\r\n child.removeEventListener(\"transitionend\", onEnd, true);\r\n finish();\r\n };\r\n\r\n child.addEventListener(\"transitionend\", onEnd, true);\r\n // Hard fallback if no transition fires\r\n setTimeout(() => {\r\n child.removeEventListener(\"transitionend\", onEnd, true);\r\n finish();\r\n }, 700);\r\n });\r\n}\r\n\r\nfunction updateBadge({ outer, count }) {\r\n if (count < 2) {\r\n outer.querySelector(\".toast-count-badge\")?.remove();\r\n return;\r\n }\r\n let badge = outer.querySelector(\".toast-count-badge\");\r\n if (!badge) {\r\n badge = document.createElement(\"span\");\r\n badge.className = \"toast-count-badge\";\r\n badge.setAttribute(\"aria-label\", `${count} identical notifications`);\r\n Object.assign(badge.style, {\r\n position: \"absolute\",\r\n top: \"6px\",\r\n right: \"6px\",\r\n backgroundColor: \"#f44336\",\r\n color: \"#fff\",\r\n borderRadius: \"50%\",\r\n minWidth: \"20px\",\r\n height: \"20px\",\r\n fontSize: \"12px\",\r\n fontWeight: \"600\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n border: \"2px solid #fff\",\r\n boxShadow: \"0 2px 6px rgba(0,0,0,0.3)\",\r\n zIndex: \"2\",\r\n pointerEvents: \"none\",\r\n transition: \"transform 150ms ease\",\r\n });\r\n outer.appendChild(badge);\r\n }\r\n badge.textContent = count > 99 ? \"99+\" : String(count);\r\n badge.style.transform = \"scale(1.2)\";\r\n setTimeout(() => (badge.style.transform = \"scale(1)\"), 150);\r\n}\r\n","// src/index.js\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\nimport { getOrCreateToastContainer } from \"./utils/containerRegistry.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 // Single source of truth for containers; prevents same-id duplicates\r\n const toastContainer = await getOrCreateToastContainer(\r\n options,\r\n setPosition\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 pauseOnHover: undefined,\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","generateUniqueId","prefix","Date","now","Math","floor","random","getTextColor","toastBg","color","Error","r","g","b","startsWith","hex","substring","length","parseInt","match","colorArray","black","white","toLowerCase","isNaN","l1","l2","max","min","contrast","error","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","style","background","backgroundColor","padding","marginBottom","borderRadius","overflow","display","alignItems","justifyContent","boxShadow","minWidth","maxWidth","opacity","position","transition","animationEasing","transform","zIndex","_animationDuration","messageSpan","document","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","appendChild","cfg","cta","label","isLink","href","variant","el","target","rel","type","ariaLabel","marginLeft","border","cursor","flexShrink","addEventListener","onClick","ret","e","then","autoClose","createCTA","showCloseButton","closeButton","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","left","height","progressHeight","progressColor","width","progressPosition","setTimeout","offsetWidth","forceReflow","createProgressBar","requestAnimationFrame","runToastAnimation","createEmergencyToast","emergency","id","innerHTML","_isEmergencyToast","parentNode","removeChild","emergencyError","alert","alertError","createToastElement","querySelector","tagName","fallbackTag","fallbackPrefix","fallbackEl","fallbackError","createElementWithId","containerRegistry","Map","containerLocks","getContainerId","String","trim","replace","normalizePositionKey","getOrCreateToastContainer","setPosition","has","get","p","cached","isConnected","getElementById","body","inset","flexDirection","all","querySelectorAll","i","remove","set","delete","container","top","bottom","right","resetContainerStyles","positionFlags","pos","hasTop","includes","hasBottom","hasLeft","hasRight","hasCenter","hasFullWidth","parsePosition","flags","handleFullWidthPositions","handleCenterPositions","applyStandardPositioning","PausableTimer","constructor","callback","delay","this","remaining","startTime","timeoutId","isPaused","isCompleted","start","pause","clearTimeout","resume","clear","getRemainingTime","active","pending","queue","visibleCount","hashString","str","h","charCodeAt","showToast","key","toString","join","makeKey","data","count","timer","createDismissTimer","setupPauseOnHover","updateBadge","entry","rafId","current","push","drainQueue","createOne","initialCount","closeToast","outer","inner","shouldPauseOnHover","pauseOnHover","timeout","_key","err","onMouseEnter","onMouseLeave","onFocusIn","matches","onFocusOut","contains","relatedTarget","_pauseCleanup","removeEventListener","_data$timer","_data$outer","_data$outer$_pauseCle","_data$outer$querySele","call","Promise","resolve","done","finish","_el$parentNode","pointerEvents","hideError","removeElement","child","firstElementChild","onEnd","item","shift","_outer$querySelector","badge","className","defaultColors","success","warning","info","defaultMessages","pendingToasts","domReady","createToastNow","sanitizedOptions","_options$position","contPosition","contMaxWidth","final","undefined","animationType","Array","isArray","_defaultMessages","_defaultColors","window","matchMedia","sanitizeToastOptions","createFirstToastContainer","_options$message","safeMessage","initialDelayDone","createToast","readyState","forEach","once","checkDOMReady","setDef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