{o[e]&&(o[e]={})},getSupportedLocales:I,isLocaleSupported:N,getLocaleName:H,getLocaleDirection:D,getLocaleInfo:O,getAllLocaleInfo:()=>I().map(O),formatNumber:(e,t={})=>{try{return new Intl.NumberFormat(_,t).format(e)}catch(t){return e.toString()}},formatCurrency:(e,t="USD",n={})=>{try{return new Intl.NumberFormat(_,{style:"currency",currency:t,...n}).format(e)}catch(t){return e.toString()}},formatPercent:(e,t={})=>{try{return new Intl.NumberFormat(_,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2,...t}).format(e/100)}catch(t){return`${e}%`}},formatDate:U,formatTime:(e,t={})=>U(e,{hour:"numeric",minute:"numeric",second:"numeric",...t}),formatRelativeTime:(e,t={})=>{try{const n=e instanceof Date?e:new Date(e),o=new Date,r=n.getTime()-o.getTime(),i=new Intl.RelativeTimeFormat(_,{numeric:"auto",...t}),s=[{unit:"year",ms:31536e6},{unit:"month",ms:2592e6},{unit:"week",ms:6048e5},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}];for(const{unit:e,ms:t}of s)if(Math.abs(r)>=t||"second"===e){const n=Math.round(r/t);return i.format(n,e)}return String(e)}catch(t){return String(e)}},formatList:(e,t={})=>{const n=Intl;if("function"==typeof n.ListFormat)try{return new n.ListFormat(_,{style:"long",type:"conjunction"}).format(e)}catch(e){}return e.join(", ")},formatPlural:X,addLocaleListener:e=>(T.add(e),()=>{T.delete(e)}),removeLocaleListener:e=>{T.delete(e)},clearLocaleListeners:()=>{T.clear()},initI18n:()=>{const e=F();z(e)},saveLocale:q,loadLocale:F,getDefaultLocale:V};o["zh-CN"],o["en-US"];class W{static setCallbacks(e){void 0!==e.onError&&(W._onError=e.onError),void 0!==e.removeToast&&(W._removeToast=e.removeToast)}static on(e,t){return this._hooks.has(e)||this._hooks.set(e,[]),this._hooks.get(e).push(t),()=>this.off(e,t)}static off(e,t){const n=this._hooks.get(e);n&&this._hooks.set(e,n.filter(e=>e!==t))}static trigger(e,t){const n=this._hooks.get(e);if(!n||0===n.length)return!0;let o=!0;return n.forEach(n=>{try{!1===n(t)&&(o=!1)}catch(n){if(W._onError)try{W._onError({hook:e,error:n,toast:t})}catch(e){}}}),o}constructor(e){this.el=null,this.barEl=null,this.rafId=null,this.startedAt=0,this.paused=!1,this.closing=!1,this.group=null,this._cleanups=[],this.id=e.id||"met-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,8),this.type=e.type||"default",this.title=e.title||"",this.message=e.message??e.content??"",this.html=e.html||"",this.iconHTML=e.iconHTML||"",this.config={...r,...e},e.style&&"object"==typeof e.style&&(this.config.style={...e.style}),this.remaining=this.config.duration||0,this.group=e.group||null}_palette(){const e=(e=>u(e))(this.config.theme||"auto"),t=i[this.type]||i.default,n=a[e]||a.light;return{theme:e,c:t,t:{bg:n.bg,border:n.border,shadow:n.shadow}}}create(){if("undefined"==typeof window||"undefined"==typeof document)return this;if(!W.trigger("beforeShow",this))return this;if("function"==typeof this.config.onBeforeShow)try{if(!1===this.config.onBeforeShow(this))return this}catch(e){}(()=>{if("undefined"==typeof document)return;if(l&&document.getElementById("metona-toast-styles"))return;l=document.createElement("style"),l.id="metona-toast-styles",l.textContent='\n .met-container {\n pointer-events: none;\n display: flex;\n flex-direction: column;\n gap: 12px;\n box-sizing: border-box;\n padding: 24px;\n max-width: 100vw;\n position: fixed;\n z-index: 9999;\n }\n\n .met-container.top-left { top: 0; left: 0; align-items: flex-start; }\n .met-container.top-center { top: 0; left: 0; right: 0; align-items: center; }\n .met-container.top-right { top: 0; right: 0; align-items: flex-end; }\n .met-container.bottom-left { bottom: 0; left: 0; align-items: flex-start; }\n .met-container.bottom-center{ bottom: 0; left: 0; right: 0; align-items: center; }\n .met-container.bottom-right { bottom: 0; right: 0; align-items: flex-end; }\n\n .met-toast {\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: 12px;\n padding: 14px 16px;\n border-radius: 12px;\n box-sizing: border-box;\n backdrop-filter: blur(14px) saturate(180%);\n -webkit-backdrop-filter: blur(14px) saturate(180%);\n font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;\n user-select: none;\n -webkit-user-select: none;\n transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),\n box-shadow 0.25s ease,\n opacity 0.25s ease;\n will-change: transform, opacity;\n flex-shrink: 0;\n pointer-events: auto;\n min-width: 240px;\n max-width: calc(100vw - 48px);\n width: 360px;\n border: 1px solid var(--met-border, rgba(0,0,0,0.06));\n background: var(--met-bg, rgba(255,255,255,0.96));\n color: var(--met-text, #1f2937);\n box-shadow: var(--met-shadow, 0 10px 36px -10px rgba(0,0,0,0.18), 0 4px 14px -4px rgba(0,0,0,0.08));\n transform: translateZ(0);\n -webkit-transform: translateZ(0);\n backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n perspective: 1000;\n }\n\n .met-toast:hover {\n box-shadow: var(--met-hover-shadow, 0 14px 48px -10px rgba(0,0,0,0.22), 0 6px 18px -4px rgba(0,0,0,0.10)) !important;\n }\n\n .met-toast.met-clickable {\n cursor: pointer;\n }\n\n .met-icon {\n flex-shrink: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n margin-top: 1px;\n }\n\n .met-content {\n flex: 1;\n min-width: 0;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n\n .met-title {\n font-weight: 600;\n font-size: 14px;\n letter-spacing: 0.1px;\n }\n\n .met-message {\n font-size: 13px;\n opacity: 0.85;\n margin-top: 2px;\n }\n\n .met-close {\n flex-shrink: 0;\n background: transparent;\n border: 0;\n padding: 4px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 6px;\n transition: background 0.2s, color 0.2s;\n line-height: 0;\n color: inherit;\n opacity: 0.5;\n }\n\n .met-close:hover {\n opacity: 1;\n background: var(--met-close-hover-bg, rgba(0,0,0,0.06));\n }\n\n .met-progress {\n position: absolute;\n left: 0; right: 0; bottom: 0;\n height: 3px;\n overflow: hidden;\n background: var(--met-progress-bg, rgba(0,0,0,0.06));\n border-radius: 0 0 12px 12px;\n }\n\n .met-progress-v {\n position: absolute;\n left: 0; top: 0; bottom: 0;\n width: 3px;\n overflow: hidden;\n background: var(--met-progress-bg, rgba(0,0,0,0.06));\n border-radius: 12px 0 0 12px;\n }\n\n .met-bar {\n position: absolute;\n left: 0; top: 0;\n height: 100%; width: 100%;\n transform-origin: left;\n transform: scaleX(1);\n }\n\n .met-bar-v {\n position: absolute;\n left: 0; bottom: 0;\n width: 100%; height: 100%;\n transform-origin: bottom;\n transform: scaleY(1);\n }\n\n .met-side {\n position: absolute;\n left: 0; top: 0; bottom: 0;\n width: 4px;\n border-radius: 12px 0 0 12px;\n }\n\n .met-spin {\n animation: met-rot 1s linear infinite;\n transform-origin: 50% 50%;\n }\n\n .met-toast.met-leaving {\n pointer-events: none;\n z-index: 1;\n }\n\n @keyframes met-rot {\n to { transform: rotate(360deg); }\n }\n\n .met-anim-slide.met-toast,\n .met-anim-fade.met-toast,\n .met-anim-scale.met-toast,\n .met-anim-bounce.met-toast,\n .met-anim-flip.met-toast,\n .met-anim-rotate.met-toast,\n .met-anim-zoom.met-toast,\n .met-anim-slideUp.met-toast,\n .met-anim-slideDown.met-toast,\n .met-anim-slideLeft.met-toast,\n .met-anim-slideRight.met-toast {\n opacity: 0;\n }\n\n @keyframes met-slide-in {\n 0% { transform: translateX(80px); opacity: 0; }\n 65% { transform: translateX(-6px); opacity: 1; }\n 100% { transform: translateX(0); opacity: 1; }\n }\n @keyframes met-fade-in {\n 0% { opacity: 0; filter: blur(3px); }\n 100% { opacity: 1; filter: blur(0); }\n }\n @keyframes met-scale-in {\n 0% { transform: scale(0.55); opacity: 0; }\n 65% { transform: scale(1.07); opacity: 1; }\n 100% { transform: scale(1); opacity: 1; }\n }\n @keyframes met-bounce-in {\n 0% { transform: translateY(-80px); opacity: 0; animation-timing-function: ease-in; }\n 45% { transform: translateY(14px); opacity: 1; animation-timing-function: ease-out; }\n 65% { transform: translateY(-12px); animation-timing-function: ease-in; }\n 82% { transform: translateY(4px); animation-timing-function: ease-out; }\n 100% { transform: translateY(0); opacity: 1; }\n }\n @keyframes met-flip-in {\n 0% { transform: perspective(500px) rotateX(-90deg); opacity: 0; }\n 60% { transform: perspective(500px) rotateX(8deg); opacity: 1; }\n 85% { transform: perspective(500px) rotateX(-2deg); }\n 100% { transform: perspective(500px) rotateX(0); opacity: 1; }\n }\n @keyframes met-rotate-in {\n 0% { transform: rotate(-25deg) scale(0.6); opacity: 0; }\n 60% { transform: rotate(4deg) scale(1.05); opacity: 1; }\n 85% { transform: rotate(-1deg) scale(0.98); }\n 100% { transform: rotate(0) scale(1); opacity: 1; }\n }\n @keyframes met-zoom-in {\n 0% { transform: scale(0.1); opacity: 0; }\n 50% { transform: scale(1.12); opacity: 1; }\n 75% { transform: scale(0.94); }\n 100% { transform: scale(1); opacity: 1; }\n }\n @keyframes met-slideUp-in {\n 0% { transform: translateY(60px); opacity: 0; }\n 70% { transform: translateY(-6px); opacity: 1; }\n 100% { transform: translateY(0); opacity: 1; }\n }\n @keyframes met-slideDown-in {\n 0% { transform: translateY(-60px); opacity: 0; }\n 70% { transform: translateY(6px); opacity: 1; }\n 100% { transform: translateY(0); opacity: 1; }\n }\n @keyframes met-slideLeft-in {\n 0% { transform: translateX(-90px); opacity: 0; }\n 65% { transform: translateX(6px); opacity: 1; }\n 100% { transform: translateX(0); opacity: 1; }\n }\n @keyframes met-slideRight-in {\n 0% { transform: translateX(90px); opacity: 0; }\n 65% { transform: translateX(-6px); opacity: 1; }\n 100% { transform: translateX(0); opacity: 1; }\n }\n\n .met-anim-slide.met-toast.met-show { animation: met-slide-in 0.40s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n .met-anim-fade.met-toast.met-show { animation: met-fade-in 0.50s ease forwards; }\n .met-anim-scale.met-toast.met-show { animation: met-scale-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }\n .met-anim-bounce.met-toast.met-show { animation: met-bounce-in 0.65s ease forwards; }\n .met-anim-flip.met-toast.met-show { animation: met-flip-in 0.50s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n .met-anim-rotate.met-toast.met-show { animation: met-rotate-in 0.50s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n .met-anim-zoom.met-toast.met-show { animation: met-zoom-in 0.50s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }\n .met-anim-slideUp.met-toast.met-show { animation: met-slideUp-in 0.40s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n .met-anim-slideDown.met-toast.met-show { animation: met-slideDown-in 0.40s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n .met-anim-slideLeft.met-toast.met-show { animation: met-slideLeft-in 0.40s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n .met-anim-slideRight.met-toast.met-show { animation: met-slideRight-in 0.40s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }\n\n @media (max-width: 480px) {\n .met-container { padding: 12px !important; }\n .met-toast { width: 100% !important; min-width: 0 !important; }\n }\n\n @media (max-width: 768px) {\n .met-toast { font-size: 13px; }\n .met-title { font-size: 13px; }\n .met-message { font-size: 12px; }\n }\n\n @media (min-width: 1200px) {\n .met-toast { width: 400px; }\n }\n\n @media (min-width: 1920px) {\n .met-toast { width: 440px; }\n }\n\n @media (max-width: 320px) {\n .met-toast { width: 100%; min-width: 0; padding: 12px 14px; }\n .met-container { padding: 8px; }\n }\n\n @media (orientation: landscape) and (max-height: 500px) {\n .met-container { padding: 12px 24px; }\n .met-toast { min-height: 44px; padding: 10px 14px; }\n }\n\n @media (orientation: portrait) and (max-width: 500px) {\n .met-container { padding: 12px; }\n .met-toast { width: 100%; min-width: 0; }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .met-toast { transition: opacity 0.15s !important; }\n .met-toast.met-show { animation: none !important; opacity: 1 !important; }\n .met-spin { animation-duration: 2.5s !important; }\n }\n\n @media (forced-colors: active) {\n .met-toast { border: 2px solid ButtonText; }\n .met-close { border: 1px solid ButtonText; }\n }\n\n @media (prefers-contrast: high) {\n .met-toast { border-width: 3px; border-style: solid; }\n .met-close { border: 2px solid currentColor; border-radius: 4px; }\n }\n\n .met-toast:focus-visible {\n outline: 2px solid #3b82f6;\n outline-offset: 2px;\n }\n .met-close:focus-visible {\n outline: 2px solid #3b82f6;\n outline-offset: 2px;\n }\n\n @media (hover: none) and (pointer: coarse) {\n .met-toast:hover { box-shadow: inherit; }\n .met-toast { min-height: 48px; }\n .met-close { min-width: 48px; min-height: 48px; }\n }\n\n @media print {\n .met-container { display: none !important; }\n .met-toast { display: none !important; }\n }\n\n :fullscreen .met-container,\n :picture-in-picture .met-container {\n z-index: 2147483647;\n }\n\n @supports (padding: max(0px)) {\n .met-container {\n padding: max(24px, env(safe-area-inset-top))\n max(24px, env(safe-area-inset-right))\n max(24px, env(safe-area-inset-bottom))\n max(24px, env(safe-area-inset-left));\n }\n }\n\n .met-toast:active {\n transform: scale(0.98);\n }\n\n .met-toast.met-success { border-left: 4px solid #10b981; }\n .met-toast.met-error { border-left: 4px solid #ef4444; }\n .met-toast.met-warning { border-left: 4px solid #f59e0b; }\n .met-toast.met-info { border-left: 4px solid #3b82f6; }\n .met-toast.met-loading { border-left: 4px solid #6366f1; }\n\n .met-bar, .met-bar-v {\n transition: transform 0.1s linear;\n }\n\n .met-container::-webkit-scrollbar { width: 6px; height: 6px; }\n .met-container::-webkit-scrollbar-track { background: transparent; }\n .met-container::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }\n .met-container::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }\n\n .met-toast.met-theme-dark {\n background: rgba(28, 32, 40, 0.94);\n color: #e6e8eb;\n border-color: rgba(255, 255, 255, 0.08);\n box-shadow: 0 10px 36px -10px rgba(0, 0, 0, 0.6), 0 4px 14px -4px rgba(0, 0, 0, 0.4);\n }\n .met-toast.met-theme-dark:hover {\n box-shadow: 0 14px 48px -8px rgba(0, 0, 0, 0.6), 0 6px 18px -4px rgba(0, 0, 0, 0.4) !important;\n }\n .met-toast.met-theme-dark .met-close:hover {\n background: rgba(255, 255, 255, 0.08);\n }\n .met-toast.met-theme-dark .met-progress,\n .met-toast.met-theme-dark .met-progress-v {\n background: rgba(255, 255, 255, 0.08);\n }\n\n .met-toast.met-theme-light {\n background: rgba(255, 255, 255, 0.96);\n color: #1f2937;\n border-color: rgba(0, 0, 0, 0.06);\n box-shadow: 0 10px 36px -10px rgba(0, 0, 0, 0.18), 0 4px 14px -4px rgba(0, 0, 0, 0.08);\n }\n .met-toast.met-theme-light:hover {\n box-shadow: 0 14px 48px -10px rgba(0, 0, 0, 0.22), 0 6px 18px -4px rgba(0, 0, 0, 0.10) !important;\n }\n .met-toast.met-theme-light .met-close:hover {\n background: rgba(0, 0, 0, 0.06);\n }\n .met-toast.met-theme-light .met-progress,\n .met-toast.met-theme-light .met-progress-v {\n background: rgba(0, 0, 0, 0.06);\n }\n\n .met-toast[data-theme] {\n --met-bg: var(--met-theme-bg);\n --met-text: var(--met-theme-text);\n --met-border: var(--met-theme-border);\n --met-shadow: var(--met-theme-shadow);\n }\n\n @media (prefers-color-scheme: dark) {\n .met-theme-auto .met-toast {\n background: rgba(28, 32, 40, 0.94);\n color: #e6e8eb;\n border-color: rgba(255, 255, 255, 0.08);\n box-shadow: 0 10px 36px -10px rgba(0, 0, 0, 0.6), 0 4px 14px -4px rgba(0, 0, 0, 0.4);\n }\n .met-theme-auto .met-toast:hover {\n box-shadow: 0 14px 48px -8px rgba(0, 0, 0, 0.6), 0 6px 18px -4px rgba(0, 0, 0, 0.4) !important;\n }\n .met-theme-auto .met-close:hover { background: rgba(255, 255, 255, 0.08); }\n .met-theme-auto .met-progress,\n .met-theme-auto .met-progress-v { background: rgba(255, 255, 255, 0.08); }\n }\n\n @media (prefers-color-scheme: light) {\n .met-theme-auto .met-toast {\n background: rgba(255, 255, 255, 0.96);\n color: #1f2937;\n border-color: rgba(0, 0, 0, 0.06);\n box-shadow: 0 10px 36px -10px rgba(0, 0, 0, 0.18), 0 4px 14px -4px rgba(0, 0, 0, 0.08);\n }\n .met-theme-auto .met-toast:hover {\n box-shadow: 0 14px 48px -10px rgba(0, 0, 0, 0.22), 0 6px 18px -4px rgba(0, 0, 0, 0.10) !important;\n }\n .met-theme-auto .met-close:hover { background: rgba(0, 0, 0, 0.06); }\n .met-theme-auto .met-progress,\n .met-theme-auto .met-progress-v { background: rgba(0, 0, 0, 0.06); }\n }\n '.replace(/\s+/g," "),document.head.appendChild(l)})();const e=this._getContainer(),{theme:t,c:n,t:o}=this._palette();this._limitToasts(e);const r=document.createElement("div");if(r.className=this._buildClassName(t),r.setAttribute("role","error"===this.type||"warning"===this.type?"alert":"status"),r.setAttribute("aria-live","error"===this.type?"assertive":"polite"),r.dataset.id=this.id,this._applyStyles(r,t,o),this._buildContent(r,n),this.el=r,(this.config.position||"top-right").startsWith("top")?e.insertBefore(r,e.firstChild):e.appendChild(r),this._bindEvents(r),this._startTimer(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classList.add("met-show")})}),"function"==typeof this.config.onShow)try{this.config.onShow(this)}catch(e){}return W.trigger("afterShow",this),this}_getContainer(){const e=this.config.position||"top-right",t=this.config.zIndex||9999,n="rtl"===D(M())?e.replace("left","__TMP__").replace("right","left").replace("__TMP__","right"):e,o=G.get(document.body);if(o&&o.has(n))return o.get(n);G.has(document.body)||G.set(document.body,new Map);const r=document.createElement("div");return r.className=`met-container ${n}`,r.setAttribute("aria-label","Notifications"),r.setAttribute("role","region"),r.style.cssText=`\n display:flex;\n flex-direction:column;\n gap:${this.config.gap||12}px;\n box-sizing:border-box;\n padding:${this.config.offset||24}px;\n max-width:100vw;\n position:fixed;\n z-index:${t};\n pointer-events:none;\n ${{"top-left":"top:0;left:0;align-items:flex-start","top-center":"top:0;left:0;right:0;align-items:center","top-right":"top:0;right:0;align-items:flex-end","bottom-left":"bottom:0;left:0;align-items:flex-start","bottom-center":"bottom:0;left:0;right:0;align-items:center","bottom-right":"bottom:0;right:0;align-items:flex-end"}[n]||"top:0;right:0;align-items:flex-end"}\n `,document.body.appendChild(r),G.get(document.body).set(n,r),r}_limitToasts(e){const t=this.config.max||6,n=Array.from(e.querySelectorAll(".met-toast"));if(n.length>=t){const e=n[0],t=e?.dataset.id;t&&W._removeToast&&W._removeToast(t)}}_buildClassName(e){const t=["slide","fade","scale","bounce","flip","rotate","zoom","slideUp","slideDown","slideLeft","slideRight"].includes(this.config.animation||"")?this.config.animation:"slide";return["met-toast",`met-${this.type}`,`met-theme-${e}`,`met-anim-${t}`,this.config.closeOnClick||this.config.draggable?"met-clickable":"",this.config.className||""].filter(Boolean).join(" ")}_applyStyles(e,t,n){const o="number"==typeof this.config.width?`${this.config.width}px`:"string"==typeof this.config.width?this.config.width:"360px",r=(t,n)=>e.style.setProperty(t,n,"important");r("position","relative"),r("flex-shrink","0"),r("min-width","240px"),r("max-width","calc(100vw - 48px)"),r("width",o),this.config.style&&Object.keys(this.config.style).length>0&&Object.entries(this.config.style).forEach(([t,n])=>{e.style[t]=n})}_buildContent(e,o){if("function"==typeof this.config.render)return e.innerHTML=this.config.render(this),void(this.barEl=e.querySelector(".met-bar, .met-bar-v"));const r=!1!==this.config.icon&&(this.iconHTML||n[this.type]),i=!1!==this.config.closeButton,s=!1!==this.config.showProgress&&(this.config.duration||0)>0,a=!r&&"default"!==this.type,l=this.title?`${t(this.title)}
`:"",c=this.html?`${this.html}
`:this.message?`${t(this.message)}
`:"",d=r?`${this.iconHTML||n[this.type]}
`:"",h=i?``:"",g=s?"vertical"===this.config.progressDirection?``:``:"",p=a?``:"";e.innerHTML=`\n ${d}\n ${p}\n \n ${l}\n ${c}\n
\n ${h}\n ${g}\n `,this.barEl=e.querySelector(".met-bar, .met-bar-v")}_bindEvents(e){const t=e=>{const t=e.target;if(t.closest(".met-close"))return e.stopPropagation(),void this.close();if(!this.config.closeOnClick||t.closest(".met-close"));else{if("function"==typeof this.config.onClick)try{this.config.onClick(this)}catch(e){}this.close()}};if(e.addEventListener("click",t),this._cleanups.push(()=>e.removeEventListener("click",t)),this.config.pauseOnHover&&(this.config.duration||0)>0){const t=()=>this._pause(),n=()=>this._resume();e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",n),this._cleanups.push(()=>{e.removeEventListener("mouseenter",t),e.removeEventListener("mouseleave",n)})}this.config.draggable&&this._bindDrag(e)}_bindDrag(e){let t=0,n=0,o=0,r=0,i=!1;const s=o=>{o.target.closest(".met-close")||(i=!0,t=o.clientX,n=o.clientY,e.setPointerCapture(o.pointerId),e.style.transition="none",this._pause())},a=s=>{i&&(o=s.clientX-t,r=s.clientY-n,e.style.transform=`translate(${o}px, ${r}px) rotate(${.1*o}deg)`,e.style.opacity=String(Math.max(0,1-Math.abs(o)/200)))},l=t=>{i&&(i=!1,e.releasePointerCapture(t.pointerId),e.style.transition="",Math.abs(o)>120?(e.style.transform=`translate(${2*o}px, ${r}px) rotate(${.2*o}deg)`,e.style.opacity="0",setTimeout(()=>this.close(!0),250)):(e.style.transform="",e.style.opacity="",this._resume()),o=r=0)};e.addEventListener("pointerdown",s),e.addEventListener("pointermove",a),e.addEventListener("pointerup",l),e.addEventListener("pointercancel",l),this._cleanups.push(()=>{e.removeEventListener("pointerdown",s),e.removeEventListener("pointermove",a),e.removeEventListener("pointerup",l),e.removeEventListener("pointercancel",l)})}_startTimer(e=!1){if((this.config.duration||0)<=0)return;e||(this.startedAt=Date.now(),this.remaining=this.config.duration||0);const t=()=>{if(!this.paused&&!this.closing){try{const e=Date.now()-this.startedAt;if(this.remaining=Math.max(0,(this.config.duration||0)-e),this.barEl){const e=this.remaining/(this.config.duration||1),t="vertical"===this.config.progressDirection?`scaleY(${e})`:`scaleX(${e})`;this.barEl.style.transform=t}if(this.remaining<=0)return void this.close()}catch(e){if(W._onError)try{W._onError({source:"timer",error:e,toast:this})}catch(e){}}this.rafId=requestAnimationFrame(t)}};this.rafId=requestAnimationFrame(t)}_pause(){this.paused||(this.config.duration||0)<=0||(this.paused=!0,null!==this.rafId&&cancelAnimationFrame(this.rafId),this.remaining=Math.max(0,(this.config.duration||0)-(Date.now()-this.startedAt)))}_resume(){this.paused&&(this.paused=!1,this.startedAt=Date.now()-((this.config.duration||0)-this.remaining),this._startTimer(!0))}update(e){W.trigger("beforeUpdate",this);const n=e.type&&e.type!==this.type;if(e.type&&(this.type=e.type),void 0!==e.title&&(this.title=e.title),void 0!==e.message&&(this.message=e.message),void 0!==e.html&&(this.html=e.html),!this.el)return W.trigger("afterUpdate",this),this;if(n){if(["met-success","met-error","met-warning","met-info","met-loading","met-default"].forEach(e=>this.el.classList.remove(e)),this.el.classList.add(`met-${this.type}`),this.barEl){const e=i[this.type]||i.default;this.barEl.style.background=e.fg}const e=this.el.querySelector(".met-side");if(e){const t=i[this.type]||i.default;e.style.background=t.fg}}const o=this.el.querySelector(".met-content");if(o){const e=this.title?`${t(this.title)}
`:"",n=this.html?`${this.html}
`:this.message?`${t(this.message)}
`:"";o.innerHTML=`${e}${n}`}if(this.config.resetTimerOnUpdate&&(this.config.duration||0)>0&&(null!==this.rafId&&cancelAnimationFrame(this.rafId),this.startedAt=Date.now(),this.remaining=this.config.duration||0,this._startTimer()),"function"==typeof this.config.onUpdate)try{this.config.onUpdate(this)}catch(e){}return W.trigger("afterUpdate",this),this}updatePosition(e){if(!e||!this.el)return this;const t=this.el.parentNode;this.config.position=e;const n=this._getContainer();return t===n||(t&&this.el.parentNode===t&&t.removeChild(this.el),e.startsWith("top")?n.insertBefore(this.el,n.firstChild):n.appendChild(this.el)),this}remove(){null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this._cleanups.forEach(e=>{try{e()}catch(e){}}),this._cleanups=[],this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=null,W._removeToast&&W._removeToast(this.id)}close(e=!1){if(this.closing)return;this.closing=!0,W.trigger("beforeClose",this),null!==this.rafId&&cancelAnimationFrame(this.rafId),this._cleanups.forEach(e=>{try{e()}catch(e){}}),this._cleanups=[];const t=this.el;if(!t)return void(W._removeToast&&W._removeToast(this.id));const n=t.parentNode;if(n&&!e){const e=t.getBoundingClientRect(),o=n.getBoundingClientRect();t.style.position="absolute",t.style.top=e.top-o.top+"px",t.style.left=e.left-o.left+"px",t.style.width=e.width+"px",t.style.margin="0"}t.classList.add("met-leaving"),t.classList.remove("met-show");const o=this.config.position||"top-right",r="rtl"===D(M());let i="scale(.96)";i=o.includes("right")?r?"translateX(-120%)":"translateX(120%)":o.includes("left")?r?"translateX(120%)":"translateX(-120%)":o.startsWith("top")?"translateY(-20px)":"translateY(20px)",t.style.transform=i,t.style.opacity="0",setTimeout(()=>this._destroy(),e?0:300)}_destroy(){if(this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=null,"function"==typeof this.config.onClose)try{this.config.onClose(this)}catch(e){}W.trigger("afterClose",this),W._removeToast&&W._removeToast(this.id)}}W._hooks=new Map,W._onError=null,W._removeToast=null;const G=new Map,K=e=>`\n \n ${e}\n
`,Z=e=>{const n=e.confirmText||L("confirm"),o=e.cancelText||L("cancel"),r=e.confirmColor||"#10b981",i=e.cancelColor||"#6b7280";return K(`\n \n \n `)},J=e=>{const n=e.submitText||L("confirm"),o=e.cancelText||L("cancel"),r=e.submitColor||"#3b82f6",i=e.cancelColor||"#6b7280";return`\n \n ${K(`\n \n \n `)}\n `},Q=e=>`\n \n 0%
\n `,ee=e=>{if(!Array.isArray(e)||0===e.length)return"";const n=e.map((e,n)=>``).join("");return K(n)};class te{constructor(){this.plugins=new Map,this.initialized=!1}register(e,t){if(this.plugins.has(e))return this;if(!t||"object"!=typeof t||!t.name)return this;const n={...t,installed:!1,enabled:!0};if(n.name||(n.name=e),this.plugins.set(e,n),n.install)try{n.install(this),n.installed=!0}catch(e){}return this}unregister(e){const t=this.plugins.get(e);if(!t)return this;if(t.uninstall)try{t.uninstall(this)}catch(e){}return this.plugins.delete(e),this}get(e){return this.plugins.get(e)||null}has(e){return this.plugins.has(e)}getAll(){return Array.from(this.plugins.values())}getNames(){return Array.from(this.plugins.keys())}enable(e){const t=this.plugins.get(e);return t&&(t.enabled=!0),this}disable(e){const t=this.plugins.get(e);return t&&(t.enabled=!1),this}isEnabled(e){const t=this.plugins.get(e);return!!t&&!!t.enabled}destroy(){this.plugins.forEach(e=>{if(e.destroy)try{e.destroy(this)}catch(e){}}),this.plugins.clear()}}const ne={keyboard:{name:"keyboard",version:"1.0.0",description:"ESC 关闭所有 Toast",_handler:null,install(){if("undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&document.querySelectorAll(".met-toast .met-close").forEach(e=>{try{e.click()}catch(e){}})};this._handler=e,document.addEventListener("keydown",e)},uninstall(){const e=this._handler;e&&"undefined"!=typeof document&&(document.removeEventListener("keydown",e),this._handler=null)}},persistence:{name:"persistence",version:"1.0.0",description:"自动持久化配置到 localStorage",storageKey:"metona-toast-config",install(){if("undefined"!=typeof localStorage)try{const e=this.storageKey,t=localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return null}return null},save(e){if("undefined"!=typeof localStorage)try{const t=this.storageKey;localStorage.setItem(t,JSON.stringify(e))}catch(e){}},uninstall(){if("undefined"!=typeof localStorage)try{const e=this.storageKey;localStorage.removeItem(e)}catch(e){}}},accessibility:{name:"accessibility",version:"1.0.0",description:"通过屏幕阅读器朗读 Toast 内容",announce(e){if("undefined"==typeof document)return;const t=document.createElement("div");t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),t.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";const n=L(e.type)||e.type;t.textContent=`${n}: ${e.title||""} ${e.message||""}`,document.body.appendChild(t),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},3e3)}}},oe={createManager:()=>new te,register:(e,t)=>re.register(e,t),unregister:e=>re.unregister(e),get:e=>re.get(e),has:e=>re.has(e),getAll:()=>re.getAll(),getNames:()=>re.getNames(),enable:e=>re.enable(e),disable:e=>re.disable(e),isEnabled:e=>re.isEnabled(e),getPreset:e=>ne[e]||null,getAllPresets:()=>({...ne}),createPlugin:e=>({name:e.name||"custom",version:e.version||"1.0.0",description:e.description||"",hooks:e.hooks||{},install:e.install||void 0,uninstall:e.uninstall||void 0,...e}),validatePlugin(e){const t=[];return e&&"object"==typeof e||t.push("Plugin must be an object"),e.name||e.version||t.push("Plugin must have a name or version"),{valid:0===t.length,errors:t}}},re=new te,ie=(e,t="default")=>{const[n,o]=e;return"string"==typeof n?{...o||{},type:o?.type||t,message:n}:n&&"object"==typeof n?{...n,type:n.type||t}:{type:t,message:""}},se={_toasts:new Map,_config:{...r},version:"0.2.1",configure(e){return e&&"object"==typeof e?(Object.assign(this._config,e),e.theme&&f(e.theme),e.locale&&z(e.locale),this):this},_emit(e){const t={...this._config,...e};t.content&&!t.message&&(t.message=t.content);const n=new W(t);return n.create(),this._toasts.set(n.id,n),n},_remove(e){this._toasts.delete(e)},find(e){if(e)return this._toasts.get(e)},show(e,t={}){const n=ie([e,t],"default");return this._emit(n)},success(e,t={}){const n=ie([e,t],"success");return this._emit(n)},error(e,t={}){const n=ie([e,t],"error");return this._emit(n)},warning(e,t={}){const n=ie([e,t],"warning");return this._emit(n)},info(e,t={}){const n=ie([e,t],"info");return this._emit(n)},loading(e,t={}){const n=ie([e,t],"loading");n.duration=0,n.closeButton=!1,n.showProgress=!1;const o=this._emit(n);return{id:o.id,success:(e,t={})=>this._resolve(o,"success",e||L("success"),t),error:(e,t={})=>this._resolve(o,"error",e||L("error"),t),info:(e,t={})=>this._resolve(o,"info",e||L("info"),t),warning:(e,t={})=>this._resolve(o,"warning",e||L("warning"),t),update:e=>(o.update(e),this),dismiss:()=>o.close()}},promise(e,t={}){if(!e||"function"!=typeof e.then)return Promise.reject(new Error("Invalid promise"));const n=t.loading||L("loading"),o=t.success||L("success"),r=t.error||L("error"),i=this.loading(n);return Promise.resolve(e).then(e=>(i.success(o),e)).catch(e=>{throw i.error(r),e})},_resolve(e,t,n,o){const r=e.id,i=this._toasts.get(r);if(!i)return null;const s=i.config.position;return i.close(),this._emit({...o,type:t,message:n,position:s})},confirm(e,t={}){return"string"!=typeof e?Promise.resolve(!1):new Promise(n=>{let o=!1;const r=e=>{o||(o=!0,clearTimeout(i),n(e))},i=setTimeout(()=>r(!1),1e4),s=this._emit({...t,type:t.type||"warning",message:e,duration:0,closeButton:!1,closeOnClick:!1,draggable:!1,html:Z(t)});setTimeout(()=>{const e=s.el?.querySelector(".met-confirm-btn"),t=s.el?.querySelector(".met-cancel-btn");e&&e.addEventListener("click",()=>{s.close(),r(!0)}),t&&t.addEventListener("click",()=>{s.close(),r(!1)})},0)})},prompt(e,t={}){return"string"!=typeof e?Promise.resolve(null):new Promise(n=>{let o=!1;const r=e=>{o||(o=!0,clearTimeout(i),n(e))},i=setTimeout(()=>r(null),1e4),s=this._emit({...t,type:t.type||"info",message:e,duration:0,closeButton:!1,closeOnClick:!1,draggable:!1,html:J(t)});setTimeout(()=>{const e=s.el?.querySelector(".met-input"),t=s.el?.querySelector(".met-submit-btn"),n=s.el?.querySelector(".met-cancel-btn");e&&(e.focus(),e.addEventListener("keydown",t=>{"Enter"===t.key&&(s.close(),r(e.value))})),t&&t.addEventListener("click",()=>{s.close(),r(e?.value||null)}),n&&n.addEventListener("click",()=>{s.close(),r(null)})},0)})},progress(e,t={}){const n=ie([e,t],"info");n.duration=0,n.closeButton=!1,n.showProgress=!1;const o=this._emit({...n,html:Q(t)});return{id:o.id,setProgress(e){const t=o.el?.querySelector(".met-progress-fill"),n=o.el?.querySelector(".met-progress-text");t&&(t.style.width=`${Math.min(100,Math.max(0,e))}%`),n&&(n.textContent=`${Math.round(e)}%`)},complete(e){this.setProgress(100),setTimeout(()=>{o.update({type:"success",message:e||L("success"),html:""}),setTimeout(()=>o.close(),1e3)},300)},error(e){o.update({type:"error",message:e||L("error"),html:""}),setTimeout(()=>o.close(),2e3)},dismiss(){o.close()}}},countdown(e,t=10,n={}){if("string"!=typeof e)return{id:"",cancel:()=>{},pause:()=>{},resume:()=>{}};let o=Math.max(1,parseInt(String(t))||10),r=null;const i=this._emit({...n,type:n.type||"warning",message:e.replace(/\{seconds\}/g,String(o)),duration:0,closeButton:!0,showProgress:!1}),s=()=>{if(o--,o<=0){if(null!==r&&clearInterval(r),i.close(),"function"==typeof n.onComplete)try{n.onComplete()}catch(e){}}else i.update({message:e.replace(/\{seconds\}/g,String(o))})};return r=setInterval(s,1e3),{id:i.id,cancel(){null!==r&&clearInterval(r),i.close()},pause(){null!==r&&clearInterval(r)},resume(){null!==r&&clearInterval(r),r=setInterval(s,1e3)}}},action(e,t=[],n={}){const o=ie([e,n],"info");o.duration=n.duration??0,o.closeButton=n.closeButton??!0;const r=this._emit({...o,html:(o.html||"")+ee(t)});return Array.isArray(t)&&setTimeout(()=>{t.forEach((e,t)=>{const n=r.el?.querySelector(`.met-action-btn-${t}`);n&&"function"==typeof e.onClick&&n.addEventListener("click",()=>{try{e.onClick(r)}catch(e){}!1!==e.close&&r.close()})})},0),{id:r.id,toast:r,dismiss:()=>r.close()}},queue(e,t={}){if(!Array.isArray(e)){const e=Promise.resolve();return{then:t=>e.then(t),catch:t=>e.catch(t),cancel:()=>{}}}let n=!1;const o=new Promise(o=>{let r=0;const i=t.delay||1e3,s=t.onClose,a=()=>{if(n||r>=e.length)return void o();const l=e[r];r++;const c="string"==typeof l?l:l?.message||"",d="object"==typeof l&&null!==l?l:{},h=d.onClose;this._emit({...t,...d,message:c,duration:d.duration||t.duration||3e3,onClose:e=>{if("function"==typeof h)try{h(e)}catch(e){}if("function"==typeof s)try{s(e)}catch(e){}setTimeout(a,i)}})};a()});return{then:(e,t)=>o.then(e,t),catch:e=>o.catch(e),cancel:()=>{n=!0}}},stack(e,t={}){Array.isArray(e)&&e.forEach((e,n)=>{setTimeout(()=>{const n="string"==typeof e?e:e?.message||"";this._emit({...t,..."object"==typeof e&&null!==e?e:{},message:n})},n*(t.stagger||100))})},dismiss(e){if(e){const t=this._toasts.get(e);return void(t&&t.close())}this._toasts.forEach(e=>e.close())},removeToast(e){if(!e)return;const t=this._toasts.get(e);t&&t.remove()},clear(e){this._toasts.forEach(t=>{e&&t.config.position!==e||t.close()})},getAll(){return new Map(this._toasts)},count(){return this._toasts.size},group(e){const t=this,n={_group:e};return["show","success","error","warning","info","loading","action"].forEach(o=>{n[o]=(...n)=>{const r=n[n.length-1],i="object"==typeof r&&null!==r&&!Array.isArray(r),s=t;return i&&1===n.length?s[o]({...r,group:e}):i?(n.pop(),s[o](...n,{...r,group:e})):s[o](...n,{group:e})}}),n.dismiss=()=>t.dismissGroup(e),n.count=()=>t._groupCount(e),n},dismissGroup(e){this._toasts.forEach(t=>{t.group===e&&t.close()})},_groupCount(e){let t=0;return this._toasts.forEach(n=>{n.group===e&&t++}),t},getToasts(){return Array.from(this._toasts.values())},hasToasts(){return this._toasts.size>0},getToast(e){return e&&this._toasts.get(e)||null},closeAll(){this._toasts.forEach(e=>e.close())},clearAll(){this._toasts.forEach(e=>e.close())},pauseAll(){this._toasts.forEach(e=>e._pause())},resumeAll(){this._toasts.forEach(e=>e._resume())},updateAll(e){e&&"object"==typeof e&&this._toasts.forEach(t=>t.update(e))},findToasts(e){return"function"!=typeof e?[]:Array.from(this._toasts.values()).filter(e)},findByType(e){return this.findToasts(t=>t.type===e)},findByPosition(e){return this.findToasts(t=>t.config.position===e)},init(e={}){return e.config&&this.configure(e.config),e.theme&&this.themes&&this.themes.switchTheme(e.theme),e.locale&&this.i18n&&this.i18n.switchLocale(e.locale),e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(e=>{this.use(e)}),this},getStatus(){return{version:"0.2.1",toasts:this._toasts.size,theme:this.themes?.getCurrentTheme?.()||"auto",locale:this.i18n?.getCurrentLocale?.()||"zh-CN",plugins:this.plugins?.getNames?.()||[],animations:this.animations?.getActiveCount?.()||0}},getConfig(){return{...this._config}},updateConfig(e){return e&&"object"==typeof e&&Object.assign(this._config,e),this},resetConfig(){return Object.keys(this._config).forEach(e=>delete this._config[e]),Object.assign(this._config,r),this},use(e,t={}){if("string"==typeof e){const n=ne[e];if(!n)return this;if(this.plugins.register(e,{...n,...t}),"accessibility"===e&&W.on("afterShow",e=>{const t=n;"function"==typeof t.announce&&t.announce(e)}),"persistence"===e){const e="function"==typeof n.install?n.install(this.plugins):null;e&&this.configure(e),W.on("afterClose",()=>{const e=n;"function"==typeof e.save&&e.save(this.getConfig())})}}else e&&"object"==typeof e&&this.plugins.register(e.name||"custom",{...e,...t});return this},destroy(){if(!this._destroyed){if(this._destroyed=!0,this.dismiss(),this.plugins&&"function"==typeof this.plugins.destroy&&this.plugins.destroy(),this.themes&&("function"==typeof this.themes.clearThemeListeners&&this.themes.clearThemeListeners(),"function"==typeof this.themes.unwatchSystemTheme&&this.themes.unwatchSystemTheme()),this.i18n&&"function"==typeof this.i18n.clearLocaleListeners&&this.i18n.clearLocaleListeners(),this.animations&&"function"==typeof this.animations.cancelAll&&this.animations.cancelAll(),"undefined"!=typeof document){document.querySelectorAll(".met-container").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)});const e=document.getElementById("metona-toast-styles");e&&e.parentNode&&e.parentNode.removeChild(e)}this._toasts.clear(),G.clear()}},animations:null,themes:null,i18n:null,plugins:null,presetPlugins:{}};W.setCallbacks({onError:e=>{const t=se._config.onError;if("function"==typeof t)try{t(e)}catch(e){}},removeToast:e=>{se._toasts.delete(e)}});const ae=new Map;Object.entries(s).forEach(([e,t])=>{ae.set(e,{name:e,enter:t.enter,leave:t.leave,duration:t.duration,easing:t.easing})});const le={register(e,t){ae.set(e,{name:e,enter:t.enter||{},leave:t.leave||{},duration:t.duration||300,easing:t.easing||"cubic-bezier(0.4, 0, 0.2, 1)"})},unregister(e){ae.delete(e)},get:e=>ae.get(e)||null,getAnimationNames:()=>Array.from(ae.keys()),getActiveCount:()=>ae.size,cancelAll(){},reset(){ae.clear(),Object.entries(s).forEach(([e,t])=>{ae.set(e,{name:e,enter:t.enter,leave:t.leave,duration:t.duration,easing:t.easing})})},destroy(){ae.clear()}},ce="0.2.1",de={...se,version:ce,animations:le,themes:j,i18n:Y,plugins:oe,presetPlugins:ne};if("function"==typeof j.initTheme&&j.initTheme(),"function"==typeof Y.initI18n&&Y.initI18n(),"undefined"!=typeof window){window.MeToast=de,window.Met=de;const e=e=>{try{new Notification(e.title||e.type,{body:e.message})}catch(e){}};de._notify=t=>{"undefined"!=typeof Notification&&"denied"!==Notification.permission&&document.hidden&&("default"!==Notification.permission?e(t):Notification.requestPermission().then(n=>{"granted"===n&&e(t)}))},W.on("afterShow",e=>{e.config.notifyWhenHidden&&de._notify(e)})}e.MeToast=de,e.Met=de,e.Toast=W,e.VERSION=ce,e.default=de,e.meToast=de,Object.defineProperty(e,"__esModule",{value:!0})});