@editora/toast 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +117 -19
- package/dist/api.d.ts +46 -0
- package/dist/chunks/AnimationUtils-CaHTcqKD.es.js +351 -0
- package/dist/chunks/AnimationUtils-Cp3BmULJ.cjs.js +2 -0
- package/dist/chunks/toast-1p-XtLiV.cjs.js +2 -0
- package/dist/chunks/toast-CISbzOBc.es.js +1251 -0
- package/dist/core/ToastManager.d.ts +6 -6
- package/dist/core/ToastRenderer.d.ts +2 -0
- package/dist/core/styles.d.ts +2 -0
- package/dist/core/types.d.ts +9 -6
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -46
- package/dist/index.esm.js +9 -1528
- package/dist/index.umd.js +1 -1
- package/dist/lite.cjs.js +2 -0
- package/dist/lite.d.ts +2 -0
- package/dist/lite.esm.js +9 -0
- package/dist/react.cjs.js +2 -0
- package/dist/react.d.ts +46 -0
- package/dist/react.esm.js +128 -0
- package/dist/styles.d.ts +1 -0
- package/package.json +32 -6
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(T,$){typeof exports=="object"&&typeof module!="undefined"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(T=typeof globalThis!="undefined"?globalThis:T||self,$(T.EditoraToast={}))})(this,(function(T){"use strict";class ${constructor(t){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...t}}addToast(t){this.toasts.set(t.id,t),this.updateGroup(t)}removeToast(t){const e=this.toasts.get(t);return e?(this.toasts.delete(t),this.updateGroup(e),!0):!1}getToast(t){return this.toasts.get(t)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(t){return this.getAllToasts().filter(e=>e.options.position===t)}updateToast(t,e){const s=this.toasts.get(t);return s?(Object.assign(s,e),this.updateGroup(s),!0):!1}updateGroup(t){const e=t.options.group;if(!e)return;let s=this.groups.get(e);s||(s={id:e,toasts:[]},this.groups.set(e,s)),s.toasts=s.toasts.filter(i=>i.id!==t.id),t.options.group===e&&s.toasts.push(t),s.toasts.length===0&&this.groups.delete(e)}getGroup(t){return this.groups.get(t)}getAllGroups(){return Array.from(this.groups.values())}getContainer(t){return this.containers.get(t)}setContainer(t,e){this.containers.set(t,e)}removeContainer(t){return this.containers.delete(t)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}clear(){this.toasts.clear(),this.groups.clear()}getStats(){return{totalToasts:this.toasts.size,totalGroups:this.groups.size,toastsByPosition:Object.fromEntries(Array.from(this.containers.keys()).map(t=>[t,this.getToastsByPosition(t).length]))}}}class X{constructor(t){this.queue=[],this.visible=[],this.config=this.normalizeConfig(t)}enqueue(t){var o;const e=this.findDuplicate(t);if(e&&((o=t.options.preventDuplicate)!=null?o:this.config.preventDuplicate))return{show:[],hide:[],rejected:e};const s=[];if(t.options.important&&this.visible.length>=this.maxVisible){const r=this.removeLowestPriorityVisible();return this.visible.push(t),{show:[t],hide:r?[...s,r]:s}}this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.sortQueue();const i=this.processQueue();return{show:i.show,hide:[...s,...i.hide]}}dequeue(t){return this.removeFromCollections(t)?{show:this.processQueue().show,hide:[]}:{show:[],hide:[]}}updateConfig(t){return this.config=this.normalizeConfig({...this.config,...t}),this.sortQueue(),this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}isVisible(t){return this.visible.some(e=>e.id===t)}clear(){const t=[...this.visible,...this.queue];return this.queue=[],this.visible=[],t}processQueue(){const t=[],e=[];for(;this.visible.length>this.maxVisible;){const s=this.visible.pop();s&&e.push(s)}for(;this.visible.length<this.maxVisible&&this.queue.length>0;){const s=this.queue.shift();if(!s)break;this.visible.push(s),t.push(s)}return{show:t,hide:e}}removeLowestPriorityVisible(){if(this.visible.length===0)return;let t=0;for(let e=1;e<this.visible.length;e+=1)(this.visible[e].options.priority||0)<(this.visible[t].options.priority||0)&&(t=e);return this.visible.splice(t,1)[0]}removeFromCollections(t){const e=this.visible.findIndex(i=>i.id===t);if(e!==-1)return this.visible.splice(e,1)[0];const s=this.queue.findIndex(i=>i.id===t);if(s!==-1)return this.queue.splice(s,1)[0]}findDuplicate(t){const e=t.options.dedupeScope||this.config.dedupeScope,s=e==="visible"?this.visible:e==="queue"?this.queue:[...this.visible,...this.queue],i=this.getDedupeKey(t);return s.find(o=>this.getDedupeKey(o)===i)}getDedupeKey(t){return t.options.dedupeKey||`${t.options.level||"info"}:${t.options.title||""}:${t.options.message||""}:${t.options.description||""}`}sortQueue(){this.queue.sort((t,e)=>{const s=(e.options.priority||0)-(t.options.priority||0);return s!==0?s:t.createdAt-e.createdAt})}get maxVisible(){return Math.max(1,this.config.visibleToasts||this.config.maxVisible||1)}normalizeConfig(t){return{...t,maxVisible:t.visibleToasts||t.maxVisible}}}const W=new Set(["a","b","strong","i","em","u","s","del","ins","mark","small","sub","sup","code","kbd","br","span","p","ul","ol","li"]),_=new Set(["script","style","iframe","frame","frameset","object","embed","applet","noscript","template","svg","math","form","input","button","textarea","select","option","head","title","link","meta","base","audio","video","canvas"]),G=/^(?:https?:|mailto:|tel:)/i;function K(n){const t=n.replace(/[\u0000- \u007f-\u009f]/g,"");return t?G.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t):!1}function q(n,t,e){for(const s of Array.from(n.childNodes)){if(s.nodeType===Node.TEXT_NODE){t.appendChild(e.createTextNode(s.textContent||""));continue}if(s.nodeType!==Node.ELEMENT_NODE)continue;const i=s,o=i.localName.toLowerCase();if(_.has(o))continue;if(!W.has(o)){q(i,t,e);continue}const r=e.createElement(o);if(o==="a"){const a=i.getAttribute("href");a&&K(a)&&(r.setAttribute("href",a.trim()),/^(?:https?:)?\/\//i.test(a.trim())&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")));const c=i.getAttribute("title");c&&r.setAttribute("title",c)}q(i,r,e),t.appendChild(r)}}function R(n,t){const e=document.createElement("template");e.innerHTML=t;const s=document.createDocumentFragment();q(e.content,s,document),n.textContent="",n.appendChild(s)}class U{constructor(t={}){var e,s,i,o;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(o=t.precision)!=null?o:.01}}animate(t,e,s,i,o){const r={...this.config,...o};let a,c=!1;const l=Object.keys(e).reduce((p,v)=>(p[v]=e[v].from,p),{}),h=Object.keys(e).reduce((p,v)=>(p[v]=0,p),{}),y=()=>{if(c)return;let p=!0;Object.keys(e).forEach(d=>{const m=e[d].to,x=l[d],f=h[d],w=-r.stiffness*(x-m),g=-r.damping*f,E=(w+g)/r.mass;h[d]+=E*.016,l[d]+=h[d]*.016,(Math.abs(x-m)>r.precision||Math.abs(f)>r.precision)&&(p=!1)});const v=Object.keys(l).reduce((d,m)=>{const x=e[m].unit||"px";return d[m]=`${l[m]}${x}`,d},{});s(v),p?(c=!0,i==null||i()):a=requestAnimationFrame(y)};return a=requestAnimationFrame(y),()=>{c=!0,a&&cancelAnimationFrame(a)}}}class Q{constructor(){this.springAnimation=new U}async showToast(t,e,s){switch(s.type){case"spring":await this.animateSpringShow(t,s);break;case"bounce":await this.animateBounceShow(t,s);break;case"slide":await this.animateSlideShow(t,s);break;case"zoom":await this.animateZoomShow(t,s);break;case"flip":await this.animateFlipShow(t,s);break;case"fade":await this.animateFadeShow(t,s);break;case"elastic":await this.animateElasticShow(t,s);break;case"rotate":await this.animateRotateShow(t,s);break;case"custom":s.show?await Promise.resolve(s.show(t,e)):await this.animateCssShow(t);break;default:await this.animateCssShow(t);break}}async hideToast(t,e,s){switch(s.type){case"spring":await this.animateSpringHide(t,s);break;case"bounce":await this.animateBounceHide(t,s);break;case"slide":await this.animateSlideHide(t,s);break;case"zoom":await this.animateZoomHide(t,s);break;case"flip":await this.animateFlipHide(t,s);break;case"fade":await this.animateFadeHide(t,s);break;case"elastic":await this.animateElasticHide(t,s);break;case"rotate":await this.animateRotateHide(t,s);break;case"custom":s.hide?await Promise.resolve(s.hide(t,e)):await this.animateCssHide(t);break;default:await this.animateCssHide(t);break}}async updateToast(t,e,s,i){i.type==="custom"&&i.update&&await Promise.resolve(i.update(t,e,s))}animateCssShow(t){return new Promise(e=>{requestAnimationFrame(()=>{t.classList.add("show"),window.setTimeout(e,220)})})}animateCssHide(t){return new Promise(e=>{t.classList.remove("show"),t.classList.add("hiding"),window.setTimeout(e,220)})}async animateSpringShow(t,e){return new Promise(s=>{var r,a,c;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const o=((r=t.parentElement)==null?void 0:r.classList.contains("editora-toast-bottom-right"))||((a=t.parentElement)==null?void 0:a.classList.contains("editora-toast-bottom-left"))||((c=t.parentElement)==null?void 0:c.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${o}px) scale(0.95)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition","opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)","important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},800)},16)})}async animateSpringHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important"),setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform","translateY(-10px) scale(0.95)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateBounceShow(t,e){return new Promise(s=>{var h,y,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.intensity||"normal",a=e.duration||800,c=r==="gentle"?.05:r==="strong"?.15:.1,l=o==="up"?30:o==="down"?-30:o==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o==="left"||o==="right"?`translateX(${l}px) scale(${1-c})`:`translateY(${l}px) scale(${1-c})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateBounceHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",o=i==="gentle"?.05:i==="strong"?.15:.1;setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1-o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var h,y,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.distance||100,a=e.easing||"ease-out",c=e.duration||400,l=o==="up"?`translateY(${r}px)`:o==="down"?`translateY(-${r}px)`:o==="left"?`translateX(${r}px)`:`translateX(-${r}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",l,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${c}ms ${a}, transform ${c}ms ${a}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},c)},16)})}async animateSlideHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"down",o=e.distance||100,r=e.easing||"ease-in",a=e.duration||300,c=i==="up"?`translateY(-${o}px)`:i==="down"?`translateY(${o}px)`:i==="left"?`translateX(-${o}px)`:`translateX(${o}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${r}, transform ${a}ms ${r}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",c,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateZoomShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,o=e.origin||"center",r=e.easing||"ease-out",a=e.duration||500;t.style.setProperty("transform-origin",o,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${r}, transform ${a}ms ${r}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}async animateZoomHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,o=e.origin||"center",r=e.easing||"ease-in",a=e.duration||300;t.style.setProperty("transform-origin",o,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${r}, transform ${a}ms ${r}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}async animateFlipShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",o=e.perspective||1e3,r=e.direction||"forward",a=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${o}px`,"important");const c=r==="forward"?i==="x"?-90:90:i==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${c}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotateX(0deg) rotateY(0deg)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},a)},16)})}async animateFlipHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",o=e.perspective||1e3,r=e.direction||"backward",a=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${o}px`,"important");const c=r==="backward"?i==="x"?-90:90:i==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${c}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},a)},16)})}async animateFadeShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",o=e.distance||20,r=e.duration||300;let a="translateY(0) translateX(0)";i!=="none"&&(a=i==="up"?`translateY(${o}px)`:i==="down"?`translateY(-${o}px)`:i==="left"?`translateX(${o}px)`:`translateX(-${o}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${r}ms ease, transform ${r}ms ease`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},r)},16)})}async animateFadeHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",o=e.distance||20,r=e.duration||200;let a="translateY(0) translateX(0)";i!=="none"&&(a=i==="up"?`translateY(-${o}px)`:i==="down"?`translateY(${o}px)`:i==="left"?`translateX(-${o}px)`:`translateX(${o}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${r}ms ease, transform ${r}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},r)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var h,y,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),o=e.direction||(i?"up":"down"),r=e.intensity||"normal",a=e.duration||1e3,c=r==="gentle"?.1:r==="strong"?.3:.2,l=o==="up"?40:o==="down"?-40:o==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o==="left"||o==="right"?`translateX(${l}px) scale(${1+c})`:`translateY(${l}px) scale(${1+c})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateElasticHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",o=i==="gentle"?.1:i==="strong"?.3:.2;e.duration,setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1+o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateRotateShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||360,o=e.direction||"clockwise",r=e.origin||"center",a=e.duration||500,c=o==="clockwise"?i:-i;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${c}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotate(0deg) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}async animateRotateHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||180,o=e.direction||"counterclockwise",r=e.origin||"center",a=e.duration||300,c=o==="clockwise"?i:-i;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ease, transform ${a}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${c}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},a)},16)})}}const z=new Q,N="http://www.w3.org/2000/svg",Z={success:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M6.6 10.3l2.3 2.3 4.5-4.9"}]],error:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M7.6 7.6l4.8 4.8M12.4 7.6l-4.8 4.8"}]],warning:[["path",{d:"M10 2.9L18 16.4H2L10 2.9z"}],["path",{d:"M10 8.3v3.4M10 13.9v.1"}]],info:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M10 9.2v4.4M10 6.5v.1"}]],loading:[["path",{d:"M10 2a8 8 0 1 0 8 8"}]]},J={success:"success",error:"error",warning:"warning",info:"info",loading:"loading",promise:"loading"};function I(n,t){const e=document.createElementNS(N,"svg");return e.setAttribute("viewBox","0 0 20 20"),e.setAttribute("width",String(t)),e.setAttribute("height",String(t)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.7"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("focusable","false"),e.setAttribute("aria-hidden","true"),n.forEach(([s,i])=>{const o=document.createElementNS(N,s);Object.keys(i).forEach(r=>o.setAttribute(r,i[r])),e.appendChild(o)}),e}function tt(n){const t=Z[J[n]||""];return t?I(t,18):null}function et(){const n=I([["path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"}]],14);return n.setAttribute("stroke-width","1.8"),n}const V=12,st=.05,F=3,H=new WeakMap;function it(n){const t=n.style.height;n.style.height="auto";const e=n.offsetHeight;return n.style.height=t,H.set(n,e),e}function ot(n){H.delete(n)}function rt(n,t){return!t.stack||t.expand||n.dataset.open==="true"}function nt(n,t,e=!1){const i=n.dataset.edge==="bottom"?-1:1,o=Array.from(n.querySelectorAll(".editora-toast")),r=o.filter(d=>!d.classList.contains("hiding")&&d.dataset.leaving!=="true"),a=r.slice().reverse(),c=rt(n,t);a.forEach(d=>{(e||!H.has(d))&&it(d)});const l=a.map(d=>H.get(d)||0),h=l[0]||0;let y=0;a.forEach((d,m)=>{const x=l[m],f=c?1:Math.max(1-m*st,.8),w=c?x:h,g=c?y:m*V+h*(1-f);d.style.setProperty("--et-y",`${i*g}px`),d.style.setProperty("--et-s",String(f)),d.style.setProperty("--et-index",String(m)),d.style.height=`${w}px`,d.style.zIndex=String(a.length-m),d.dataset.index=String(m),d.dataset.front=String(m===0),d.dataset.collapsed=String(!c&&m>0),d.dataset.hidden=String(!c&&m>=F),y+=x+t.gap}),o.forEach(d=>{r.includes(d)||(d.dataset.front="false")});const p=a.length,v=c?l.reduce((d,m)=>d+m,0)+Math.max(p-1,0)*t.gap:h+(Math.min(p,F)-1>0?(Math.min(p,F)-1)*V:0);n.style.height=p>0?`${v}px`:"0px",n.dataset.count=String(p),n.dataset.expanded=String(c)}class at{constructor(t){this.containers=new Map,this.cssInjected=!1,this.toastOf=new WeakMap,this.holds=new Map,this.timing=new Map,this.returnFocusTo=null,this.globalListeners=[],this.config=t}updateConfig(t){this.config=t,this.containers.forEach((e,s)=>{this.applyContainerStyles(e,s),this.layout(e,!0)})}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");return e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite"),e.dataset.expand=String(this.config.expand),e.dataset.stack=String(this.config.stack),this.applyContainerStyles(e,t),this.attachContainerListeners(e),document.body.appendChild(e),this.containers.set(t,e),this.attachGlobalListeners(),this.injectCSS(),e}attachContainerListeners(t){t.addEventListener("mouseenter",()=>{t.dataset.hover="true",this.holdAll(t,"pointer"),this.syncOpen(t)}),t.addEventListener("pointerdown",e=>{e.pointerType!=="touch"||t.dataset.hover==="true"||(t.dataset.hover="true",this.holdAll(t,"pointer"),this.syncOpen(t))}),t.addEventListener("mouseleave",()=>{delete t.dataset.hover,this.releaseAll(t,"pointer"),this.syncOpen(t)}),t.addEventListener("focusin",e=>{this.isKeyboardFocus(e.target)&&(t.dataset.focus="true",this.holdAll(t,"focus"),this.syncOpen(t))}),t.addEventListener("focusout",e=>{const s=e.relatedTarget;s&&t.contains(s)||(delete t.dataset.focus,this.releaseAll(t,"focus"),this.syncOpen(t))}),t.addEventListener("keydown",e=>this.onContainerKey(t,e))}syncOpen(t){const e=t.dataset.hover==="true"||t.dataset.focus==="true";t.dataset.open=String(e),this.layout(t)}isKeyboardFocus(t){if(!(t instanceof Element))return!1;try{return t.matches(":focus-visible")}catch(e){return!0}}onContainerKey(t,e){if(e.key!=="Escape")return;const s=e.target instanceof Element?e.target.closest(".editora-toast"):null,i=s?this.toastOf.get(s):void 0;if(!s||!i)return;e.preventDefault();const o=Array.from(t.querySelectorAll(".editora-toast:not(.hiding)")),r=o[o.indexOf(s)+1]||o[o.indexOf(s)-1];i.dismiss(),r&&r!==s?r.focus():this.restoreFocus()}restoreFocus(){const t=this.returnFocusTo;this.returnFocusTo=null,t&&t.isConnected&&t.focus()}attachGlobalListeners(){if(this.globalListeners.length>0||typeof window=="undefined")return;const t=(e,s,i)=>{e.addEventListener(s,i),this.globalListeners.push([e,s,i])};t(document,"keydown",(e=>{if(!this.matchesHotkey(e))return;const s=Array.from(this.containers.values()).find(r=>r.querySelector(".editora-toast:not(.hiding)"));if(!s)return;const i=s.querySelector('.editora-toast[data-front="true"]');if(!i)return;e.preventDefault();const o=document.activeElement;o instanceof HTMLElement&&!s.contains(o)&&(this.returnFocusTo=o),i.focus()})),t(document,"pointerdown",(e=>{this.containers.forEach(s=>{s.dataset.hover==="true"&&!s.contains(e.target)&&(delete s.dataset.hover,this.releaseAll(s,"pointer"),this.syncOpen(s))})})),t(window,"resize",(()=>{window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.containers.forEach(e=>this.layout(e,!0)),120)}))}matchesHotkey(t){const e=this.config.hotkey;if(!e)return!1;const s=e.toLowerCase().split("+").map(r=>r.trim()).filter(Boolean),i=s.pop();if(!i)return!1;const o=r=>s.includes(r);return t.altKey!==o("alt")||t.shiftKey!==o("shift")||t.ctrlKey!==o("ctrl")||t.metaKey!==(o("meta")||o("cmd"))?!1:t.code.toLowerCase()===`key${i}`||t.code.toLowerCase()===i||t.key.toLowerCase()===i}layout(t,e=!1){nt(t,{stack:this.config.stack,expand:this.config.expand,gap:this.toPx(this.config.gap)},e)}toPx(t){if(typeof t=="number")return t;const e=parseFloat(t||"");return Number.isFinite(e)?e:8}holdAll(t,e){t.querySelectorAll(".editora-toast").forEach(s=>{const i=this.toastOf.get(s);if(!i)return;(e==="focus"?i.options.pauseOnFocus:i.options.pauseOnHover)!==!1&&this.pauseToast(i,e)})}releaseAll(t,e){t.querySelectorAll(".editora-toast").forEach(s=>{const i=this.toastOf.get(s);i&&this.resumeToast(i,e)})}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,s.dataset.level=e.level||"info",e.customClass&&e.customClass.split(/\s+/).filter(Boolean).forEach(a=>s.classList.add(a)),s.setAttribute("role",e.role||(e.level==="error"?"alert":"status")),s.setAttribute("aria-atomic","true"),s.tabIndex=0,(e.closable||e.closeButton)&&(s.dataset.closable="true"),this.toastOf.set(s,t),e.ariaLive&&e.ariaLive!=="off"&&s.setAttribute("aria-live",e.ariaLive);const i=e.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(this.config.richColors||i==="colored")&&s.setAttribute("data-rich-colors","true"),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const r=this.createContent(t);if(s.appendChild(r),e.actions&&e.actions.length>0){const a=document.createElement("div");a.className="editora-toast-actions",e.actions.forEach(c=>a.appendChild(this.createActionButton(c,t))),s.appendChild(a)}return(e.closable||e.closeButton)&&s.appendChild(this.createCloseButton(t)),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var o,r;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s),e.dataset.hover==="true"&&t.options.pauseOnHover!==!1&&this.pauseToast(t,"pointer"),e.dataset.focus==="true"&&t.options.pauseOnFocus!==!1&&this.pauseToast(t,"focus"),this.layout(e);const i=t.options.animation||this.config.animation||{type:"css"};await z.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(r=(o=t.options).onShow)==null||r.call(o),this.startTimer(t)}async hideToast(t){var i,o;if(!t.element)return;this.stopTimer(t),this.holds.delete(t.id);const e=t.element;e.dataset.leaving="true",e.parentElement&&this.layout(e.parentElement);const s=t.options.animation||this.config.animation||{type:"css"};if(await z.hideToast(e,t,s),t.element&&t.element.parentNode){const r=t.element.parentElement;t.element.parentNode.removeChild(t.element),t.element=void 0,r&&(r.querySelector(".editora-toast")||(delete r.dataset.hover,delete r.dataset.focus,r.dataset.open="false"),this.layout(r))}(o=(i=t.options).onHide)==null||o.call(i)}async updateToast(t,e){var o,r,a;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await z.updateToast(t.element,t,e,s);return}if(Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g,""),t.element.classList.add(`editora-toast-${e.level}`),t.element.dataset.level=e.level),e.title!==void 0||e.description!==void 0||e.message!==void 0||e.icon!==void 0||e.level!==void 0||e.render){const c=t.element.querySelector(".editora-toast-content"),l=this.createContent(t);c==null||c.replaceWith(l)}const i=(o=e.closeButton)!=null?o:e.closable;if(i!==void 0){t.options.closable=i,t.options.closeButton=i,i?t.element.dataset.closable="true":delete t.element.dataset.closable;const c=t.element.querySelector(".editora-toast-close");i&&!c?t.element.appendChild(this.createCloseButton(t)):!i&&c&&c.remove()}if(e.progress!==void 0){const c=t.element.querySelector(".editora-toast-body"),l=t.element.querySelector(".editora-toast-progress-track");if(e.progress&&c){const h=this.createProgress(e.progress);l?l.replaceWith(h):c.appendChild(h)}else l&&l.remove()}if(e.actions!==void 0||e.action!==void 0||e.cancel!==void 0){let c=t.element.querySelector(".editora-toast-actions");const l=t.options.actions||[];l.length>0?(c?c.innerHTML="":(c=document.createElement("div"),c.className="editora-toast-actions",t.element.appendChild(c)),c&&l.forEach(h=>c.appendChild(this.createActionButton(h,t)))):c&&c.remove()}(e.duration!==void 0||e.persistent!==void 0||e.level!==void 0)&&this.startTimer(t),t.element.style.height="",ot(t.element),t.element.parentElement&&this.layout(t.element.parentElement),(a=(r=t.options).onUpdate)==null||a.call(r,e)}createContent(t){const e=t.options,s=document.createElement("div");s.className="editora-toast-content";const i=this.createIcon(t);i&&s.appendChild(i);const o=document.createElement("div");if(o.className="editora-toast-body",e.render)o.appendChild(e.render(t));else{if(e.title){const r=document.createElement("div");r.className="editora-toast-title",r.textContent=e.title,o.appendChild(r)}if(e.message){const r=document.createElement("div");r.className="editora-toast-message",e.html?R(r,e.message):r.textContent=e.message,o.appendChild(r)}if(e.description){const r=document.createElement("div");r.className="editora-toast-description",r.textContent=e.description,o.appendChild(r)}}return e.progress&&o.appendChild(this.createProgress(e.progress)),s.appendChild(o),s}createProgress(t){const e=Math.min(100,Math.max(0,t.value)),s=document.createElement("div");s.className="editora-toast-progress-track",s.setAttribute("role","progressbar"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuenow",String(e));const i=document.createElement("div");if(i.className="editora-toast-progress-bar",i.style.width=`${e}%`,t.showPercentage){const o=document.createElement("span");o.className="editora-toast-progress-text",o.textContent=`${Math.round(t.value)}%`,s.appendChild(o)}return s.appendChild(i),s}createCloseButton(t){const e=document.createElement("button");return e.className="editora-toast-close",e.setAttribute("type","button"),e.setAttribute("aria-label","Close notification"),e.appendChild(et()),e.onclick=()=>t.dismiss(),e}createIcon(t){const e=t.options;if(e.icon===!1)return null;const s=document.createElement("span");if(s.className="editora-toast-icon",s.setAttribute("aria-hidden","true"),typeof e.icon=="string"&&e.icon)return s.textContent=e.icon,s;if(e.icon&&typeof e.icon=="object")return s.appendChild(e.icon),s;if(this.config.icons===!1)return null;const i=e.level||"info",o=tt(i);return o?((i==="loading"||i==="promise")&&(s.dataset.spin="true"),s.appendChild(o),s):null}createActionButton(t,e){const s=document.createElement("button");return s.className=`editora-toast-action ${t.primary?"primary":""}`,s.textContent=t.label,t.altText&&s.setAttribute("aria-label",t.altText),s.onclick=i=>{i.stopPropagation(),t.onClick(),t.dismissOnClick!==!1&&e.dismiss()},s}applyContainerStyles(t,e){const s=this.toCssLength(this.config.offset),i=this.toCssLength(this.config.mobileOffset),o=this.toCssLength(this.config.gap);t.dataset.position=e,t.dataset.edge=e.startsWith("bottom")?"bottom":"top",t.dataset.expand=String(this.config.expand),t.dataset.stack=String(this.config.stack),t.style.setProperty("--editora-toast-offset",s),t.style.setProperty("--editora-toast-mobile-offset",i),t.style.setProperty("--editora-toast-gap",o),t.style.setProperty("--et-edge",e.startsWith("bottom")?"1":"-1");const r={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"block",width:"var(--et-width, 360px)",maxWidth:`calc(100vw - 2 * ${s})`,boxSizing:"border-box",top:"",right:"",bottom:"",left:"",transform:""};switch(e){case"top-left":r.top=`max(${s}, env(safe-area-inset-top))`,r.left=`max(${s}, env(safe-area-inset-left))`;break;case"top-center":r.top=`max(${s}, env(safe-area-inset-top))`,r.left="50%",r.transform="translateX(-50%)";break;case"top-right":r.top=`max(${s}, env(safe-area-inset-top))`,r.right=`max(${s}, env(safe-area-inset-right))`;break;case"bottom-left":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.left=`max(${s}, env(safe-area-inset-left))`;break;case"bottom-center":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.left="50%",r.transform="translateX(-50%)";break;case"bottom-right":r.bottom=`max(${s}, env(safe-area-inset-bottom))`,r.right=`max(${s}, env(safe-area-inset-right))`;break;case"center":r.top="50%",r.left="50%",r.transform="translate(-50%, -50%)";break}Object.assign(t.style,r),t.style.setProperty("--editora-toast-mobile-left",i)}toCssLength(t){return typeof t=="number"?`${t}px`:t||"16px"}startTimer(t){if(this.stopTimer(t),t.options.persistent||t.options.duration===0){this.timing.delete(t.id);return}this.arm(t,t.options.duration||this.config.duration)}arm(t,e){var s;this.timing.set(t.id,{remaining:e,startedAt:Date.now()}),!((((s=this.holds.get(t.id))==null?void 0:s.size)||0)>0)&&(t.timeoutId=window.setTimeout(()=>{t.timeoutId=void 0,t.dismiss()},e))}stopTimer(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}pauseToast(t,e="hover"){const s=this.holds.get(t.id)||new Set;if(this.holds.set(t.id,s),s.size===0&&t.timeoutId){const i=this.timing.get(t.id);this.stopTimer(t),i&&(i.remaining=Math.max(0,i.remaining-(Date.now()-i.startedAt)))}s.add(e)}resumeToast(t,e="hover"){const s=this.holds.get(t.id);if(!s||!s.delete(e)||s.size>0)return;this.holds.delete(t.id);const i=this.timing.get(t.id);i&&!t.timeoutId&&!t.options.persistent&&t.options.duration!==0&&this.arm(t,i.remaining)}addSwipeDismiss(t,e){let s=0,i=0,o=!1;const r=e.options.swipeDirection||this.config.swipeDirection||"any",a=40;let c="",l=!1;const h='button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]',y=()=>{t.style.transform=c,t.style.transition="",t.style.cursor="",t.style.userSelect=""},p=(f,w)=>{if("changedTouches"in f||"touches"in f){const g=w?f.changedTouches:f.touches,b=g&&g[0];return b?{x:b.clientX,y:b.clientY}:null}return{x:f.clientX,y:f.clientY}},v=f=>{const w=f.target;if(w instanceof Element&&t.contains(w)&&w.closest(h)||"button"in f&&f.button!==0)return;const g=p(f,!1);g&&(o=!0,l=!1,s=g.x,i=g.y,c=t.style.transform||"")},d=f=>{var P,D;if(!o)return;const w=p(f,!1);if(!w)return;const g=w.x-s,b=w.y-i,E=5;if(!l&&(Math.abs(g)>E||Math.abs(b)>E)&&(l=!0,t.style.transition="none",t.style.cursor="grabbing",t.style.userSelect="none",(D=(P=window.getSelection)==null?void 0:P.call(window))==null||D.removeAllRanges()),l){const S=Math.abs(b)>Math.abs(g)?25:20,ut=Math.min(Math.max(g*.2,-S),S),pt=Math.min(Math.max(b*.2,-S),S);t.style.transform=`${c} translate(${ut}px, ${pt}px)`,f.cancelable&&f.preventDefault()}},m=f=>{if(!o)return;o=!1;const w=l;if(y(),!w)return;const g=p(f,!0);if(!g)return;const b=g.x-s,E=g.y-i;let P=!1;const S=r==="vertical"||r==="up"||r==="down"?35:a;switch(r){case"any":P=Math.abs(b)>a||Math.abs(E)>a;break;case"horizontal":P=Math.abs(b)>a;break;case"vertical":P=Math.abs(E)>S;break;case"left":P=b<-a;break;case"right":P=b>a;break;case"up":P=E<-S;break;case"down":P=E>S;break}P&&e.dismiss()},x=()=>{o&&(o=!1,l=!1,y())};t.addEventListener("dragstart",f=>f.preventDefault()),t.addEventListener("touchstart",v,{passive:!0}),t.addEventListener("touchmove",d,{passive:!1}),t.addEventListener("touchend",m),t.addEventListener("touchcancel",x),t.addEventListener("mousedown",v),t.addEventListener("mousemove",d),t.addEventListener("mouseup",m),t.addEventListener("mouseleave",m)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){if(t.options.ariaLive==="off")return;const e=document.createElement("div");e.setAttribute("aria-live",t.options.ariaLive||(t.options.level==="error"?"assertive":"polite")),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.left="-10000px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden";const s=[t.options.title,t.options.message,t.options.description].filter(Boolean).join(". ");e.textContent=`${t.options.level||"info"}: ${s}`,document.body.appendChild(e),setTimeout(()=>{e.remove()},1e3)}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!(getComputedStyle(document.documentElement).getPropertyValue("--editora-toast-stylesheet").trim()!==""||Array.from(document.styleSheets).some(s=>{var i,o,r,a;return((o=(i=s.ownerNode)==null?void 0:i.href)==null?void 0:o.includes("toast.css"))||((a=(r=s.ownerNode)==null?void 0:r.textContent)==null?void 0:a.includes("editora-toast"))}))){console.warn("[@editora/toast] toast.css is not loaded, so toasts use a minimal fallback style. Import '@editora/toast/toast.css' once in your app (or link @editora/toast/dist/toast.css).");const s=document.createElement("style");s.setAttribute("data-editora-toast-fallback","true"),s.textContent=".editora-toast-container{position:fixed;width:360px;max-width:100vw;box-sizing:border-box}.editora-toast{position:absolute;left:0;width:100%;box-sizing:border-box;padding:12px 14px;background:#fff;color:#111;border:1px solid #ddd;border-radius:12px;font:13px/1.45 system-ui,sans-serif;overflow:hidden;pointer-events:auto;opacity:0;translate:0 var(--et-y,0px);scale:var(--et-s,1);transition:opacity .2s,translate .3s,scale .3s,height .3s}.editora-toast-container[data-edge=bottom] .editora-toast{bottom:0}.editora-toast-container[data-edge=top] .editora-toast{top:0}.editora-toast.show{opacity:1}.editora-toast.hiding,.editora-toast[data-hidden=true]{opacity:0}",document.head.appendChild(s)}this.cssInjected=!0}destroy(){this.globalListeners.forEach(([t,e,s])=>t.removeEventListener(e,s)),this.globalListeners=[],window.clearTimeout(this.resizeTimer),this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class ct{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(t){if(this.plugins.find(e=>e.name===t.name)){console.warn(`Plugin "${t.name}" is already installed`);return}this.plugins.push(t),t.install(this)}remove(t){const e=this.plugins.findIndex(i=>i.name===t);if(e===-1)return!1;const s=this.plugins[e];return s.uninstall&&s.uninstall(this),this.plugins.splice(e,1),!0}getPlugins(){return[...this.plugins]}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}off(t,e){if(this.hooks[t]){const s=this.hooks[t].indexOf(e);s!==-1&&this.hooks[t].splice(s,1)}}async trigger(t,e,...s){const i=this.hooks[t];if(!(!i||i.length===0))for(const o of i)try{await o(e,...s)}catch(r){console.error(`Error in ${t} hook:`,r)}}async beforeShow(t){await this.trigger("beforeShow",t)}async afterShow(t){await this.trigger("afterShow",t)}async beforeHide(t){await this.trigger("beforeHide",t)}async afterHide(t){await this.trigger("afterHide",t)}async beforeUpdate(t,e){await this.trigger("beforeUpdate",t,e)}async afterUpdate(t,e){await this.trigger("afterUpdate",t,e)}onEditorEvent(t,e){const s=`editor:${t}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(e)}triggerEditorEvent(t,e,...s){const i=`editor:${t}`;this.trigger(i,e,...s)}async handlePromise(t,e,s,i){e();try{const o=await t;return s(o),o}catch(o){throw i(o),o}}async batchShow(t){const e=t.map(i=>this.beforeShow(i));await Promise.all(e);const s=t.map(i=>this.afterShow(i));await Promise.all(s)}async batchHide(t){const e=t.map(i=>this.beforeHide(i));await Promise.all(e);const s=t.map(i=>this.afterHide(i));await Promise.all(s)}destroy(){this.plugins.forEach(t=>{t.uninstall&&t.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(t=>{this.hooks[t]=[]})}}const Y={position:"bottom-right",duration:4e3,maxVisible:3,queueStrategy:"fifo",theme:"system",richColors:!1,expand:!1,stack:!0,offset:16,mobileOffset:16,gap:8,pauseOnHover:!0,pauseOnFocus:!0,pauseOnWindowBlur:!1,swipeDismiss:!0,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,closeButton:!1,icons:!0,hotkey:"alt+t",preventDuplicate:!1,dedupeScope:"all",animation:{type:"css"}};class O{constructor(t={}){this.idCounter=0,this.pendingShows=new Map,this.subscribers=new Set,this.config=this.normalizeConfig({...Y,...t}),this.store=new $(this.config),this.queue=new X(this.config),this.renderer=new at(this.config),this.lifecycle=new ct,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:this.normalizeToastOptions({...this.config,...t},t),createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:r=>this.update(e,r)},i=this.lifecycle.beforeShow(s).then(async()=>{const r=this.queue.enqueue(s);r.rejected||(this.store.addToast(s),await this.hideToasts(r.hide,!0),await this.showToasts(r.show),this.notify())});this.pendingShows.set(e,i);const o=()=>{this.pendingShows.get(e)===i&&this.pendingShows.delete(e)};return i.then(o,o),s}update(t,e){const s=this.pendingShows.get(t);if(s)return s.then(()=>this.update(t,e),()=>{}),!0;const i=this.store.getToast(t);return i?(this.lifecycle.beforeUpdate(i,e).then(async()=>{const o=this.normalizeToastOptions({...i.options,...e},e);this.store.updateToast(t,{options:o}),this.queue.isVisible(t)&&await this.renderer.updateToast(i,e),this.lifecycle.afterUpdate(i,e),this.notify()}),!0):!1}dismiss(t){const e=this.pendingShows.get(t);if(e)return e.then(()=>this.dismiss(t),()=>{}),!0;const s=this.store.getToast(t);return s?(this.lifecycle.beforeHide(s).then(async()=>{const i=this.queue.isVisible(t),o=this.queue.dequeue(t);i&&await this.renderer.hideToast(s),this.store.removeToast(t),this.lifecycle.afterHide(s),await this.showToasts(o.show),this.notify()}),!0):!1}clear(){const t=this.queue.clear();Promise.all(t.map(e=>this.hideOne(e,!1))).then(()=>{this.store.clear(),this.notify()})}async promise(t,e){var i,o;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const r=await t,a=this.normalizeResult(typeof e.success=="function"?e.success(r):e.success,"success");return a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(i=e.onSuccess)==null||i.call(e,r),r}catch(r){const a=this.normalizeResult(typeof e.error=="function"?e.error(r):e.error,"error");throw a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(o=e.onError)==null||o.call(e,r),r}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur,s={...this.config,...t};t.maxVisible!==void 0&&t.visibleToasts===void 0&&delete s.visibleToasts,this.config=this.normalizeConfig(s),this.store.updateConfig(this.config),this.renderer.updateConfig(this.config);const i=this.queue.updateConfig(this.config);this.hideToasts(i.hide,!0).then(()=>this.showToasts(i.show)).then(()=>this.notify()),t.pauseOnWindowBlur!==void 0&&t.pauseOnWindowBlur!==e&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getState(){return{toasts:this.store.getAllToasts(),visible:this.queue.getVisible(),queued:this.queue.getQueued(),groups:this.store.getAllGroups(),config:this.getConfig()}}subscribe(t){return this.subscribers.add(t),t(this.getState()),()=>{this.subscribers.delete(t)}}getGroups(){return this.store.getAllGroups()}info(t,e){return this.show({message:t,level:"info",duration:e})}success(t,e){return this.show({message:t,level:"success",duration:e})}error(t,e){return this.show({message:t,level:"error",duration:e})}warning(t,e){return this.show({message:t,level:"warning",duration:e})}loading(t,e){return this.show({message:t,level:"loading",duration:e})}normalizeOptions(t,e){return typeof t=="string"?{message:t,level:e}:{...t,level:t.level||e}}normalizeResult(t,e){const s=this.normalizeOptions(t,e);return"message"in s?s:{...s,message:void 0}}normalizeConfig(t){const e=t.visibleToasts||t.maxVisible||Y.maxVisible;return{...t,maxVisible:e,visibleToasts:e}}normalizeToastOptions(t,e=t){var r,a,c,l,h,y;const s=(l=(c=(a=(r=e.closeButton)!=null?r:e.closable)!=null?a:t.closable)!=null?c:t.closeButton)!=null?l:this.config.closeButton,i=t.action?{...t.action,primary:(h=t.action.primary)!=null?h:!0}:void 0,o=[...i?[i]:[],...t.cancel?[t.cancel]:[],...t.actions||[]];return{...t,closable:s,closeButton:s,actions:o.length>0?o:void 0,ariaLive:t.ariaLive||(t.level==="error"||t.important?"assertive":"polite"),role:t.role||(t.level==="error"||t.important?"alert":"status"),preventDuplicate:(y=t.preventDuplicate)!=null?y:this.config.preventDuplicate,dedupeScope:t.dedupeScope||this.config.dedupeScope}}async showToasts(t){for(const e of t)await this.renderer.showToast(e),await this.lifecycle.afterShow(e)}async hideToasts(t,e){for(const s of t)await this.hideOne(s,e)}async hideOne(t,e){await this.lifecycle.beforeHide(t),await this.renderer.hideToast(t),e&&this.store.removeToast(t.id),await this.lifecycle.afterHide(t)}notify(){if(this.subscribers.size===0)return;const t=this.getState();this.subscribers.forEach(e=>e(t))}onEditorEvent(t,e){this.lifecycle.onEditorEvent(t,e)}triggerEditorEvent(t,e,...s){this.lifecycle.triggerEditorEvent(t,e,...s)}setupWindowFocusHandling(){typeof window=="undefined"||typeof document=="undefined"||!this.config.pauseOnWindowBlur||(this.teardownWindowFocusHandling(),this.windowBlurHandler=()=>this.pauseAllToasts(),this.windowFocusHandler=()=>this.resumeAllToasts(),this.visibilityChangeHandler=()=>{document.hidden?this.pauseAllToasts():this.resumeAllToasts()},window.addEventListener("blur",this.windowBlurHandler),window.addEventListener("focus",this.windowFocusHandler),document.addEventListener("visibilitychange",this.visibilityChangeHandler))}teardownWindowFocusHandling(){typeof window!="undefined"&&(this.windowBlurHandler&&(window.removeEventListener("blur",this.windowBlurHandler),this.windowBlurHandler=void 0),this.windowFocusHandler&&(window.removeEventListener("focus",this.windowFocusHandler),this.windowFocusHandler=void 0),typeof document!="undefined"&&this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=void 0))}pauseAllToasts(){this.store.getAllToasts().forEach(t=>this.renderer.pauseToast(t,"window"))}resumeAllToasts(){this.store.getAllToasts().forEach(t=>this.renderer.resumeToast(t,"window"))}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let C=null;function u(){return C||(C=new O),C}const lt=n=>({id:n.id||"",options:n,createdAt:0,dismiss:()=>{},update:()=>{}});function B(n){return typeof document=="undefined"?lt(n):u().show(n)}function j(n,t,e,s){let i={};t&&typeof t=="object"?i={...t}:typeof t=="number"&&(i.duration=t),e&&(i.theme=e),s&&(i.position=s);const o={message:n,...i,level:i.level||void 0};return i.duration!==void 0&&(o.duration=i.duration),i.position&&(o.position=i.position),i.theme&&(o.theme=i.theme),o}function k(n){return(t,e,s,i)=>B({...j(t,e,s,i),level:n})}const L=()=>typeof document!="undefined";function dt(n,t,e,s){const i=j(n,t,e,s);return B({...i,level:i.level||"custom"})}const M=Object.assign(dt,{info:k("info"),success:k("success"),error:k("error"),warning:k("warning"),loading:k("loading"),show:n=>B(n),promise:(n,t)=>L()?u().promise(n,t):n,update:(n,t)=>L()?u().update(n,t):!1,dismiss:n=>L()?n===void 0?(u().clear(),!0):u().dismiss(n):!1,clear:()=>{L()&&u().clear()},configure:n=>{L()&&u().configure(n)}}),A={show:n=>u().show(n),update:(n,t)=>u().update(n,t),dismiss:n=>u().dismiss(n),clear:()=>u().clear(),info:(n,t)=>u().show({message:n,level:"info",...t}),success:(n,t)=>u().show({message:n,level:"success",...t}),error:(n,t)=>u().show({message:n,level:"error",...t}),warning:(n,t)=>u().show({message:n,level:"warning",...t}),loading:(n,t)=>u().show({message:n,level:"loading",...t}),promise:(n,t)=>u().promise(n,t),group:(n,t)=>u().group(n,t),configure:n=>u().configure(n),use:n=>u().use(n),getToasts:()=>u().getToasts(),getGroups:()=>u().getGroups(),getConfig:()=>u().getConfig(),getState:()=>u().getState(),subscribe:n=>u().subscribe(n),onEditorEvent:(n,t)=>u().onEditorEvent(n,t),triggerEditorEvent:(n,t,...e)=>u().triggerEditorEvent(n,t,...e),destroy:()=>{C&&(C.destroy(),C=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const n=window;n.toast=M,n.toastAdvanced=A,n.toastPro=A,n.ToastManager=O,n.__editoraToastReady||(n.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:M,toastAdvanced:A,toastPro:A,ToastManager:O}})))}T.ToastManager=O,T.default=M,T.toast=M,T.toastAdvanced=A,T.toastPro=A,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(P,A){typeof exports=="object"&&typeof module!="undefined"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(P=typeof globalThis!="undefined"?globalThis:P||self,A(P.EditoraToast={}))})(this,(function(P){"use strict";const A=':root{--editora-toast-stylesheet: 1;--et-bg: #ffffff;--et-bg-subtle: #f6f6f5;--et-border: rgba(0,0,0,.09);--et-border-strong: rgba(0,0,0,.16);--et-text: #1c1917;--et-text-muted: #6b6560;--et-text-inverse: #fafaf9;--et-info: #2563eb;--et-success: #15803d;--et-error: #dc2626;--et-warning: #b45309;--et-loading: #4f46e5;--et-promise: #4f46e5;--et-info-tint: rgba(37,99,235,.08);--et-info-ring: rgba(37,99,235,.28);--et-success-tint: rgba(21,128,61,.08);--et-success-ring: rgba(21,128,61,.28);--et-error-tint: rgba(220,38,38,.07);--et-error-ring: rgba(220,38,38,.28);--et-warning-tint: rgba(180,83,9,.08);--et-warning-ring: rgba(180,83,9,.3);--et-loading-tint: rgba(79,70,229,.07);--et-loading-ring: rgba(79,70,229,.26);--et-promise-tint: var(--et-loading-tint);--et-promise-ring: var(--et-loading-ring);--et-radius: 12px;--et-radius-sm: 8px;--et-width: 356px;--et-offset: 20px;--et-gap: 8px;--et-z: 2147483647;--et-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.1);--et-dur-enter: .3s;--et-dur-exit: .2s;--et-ease-enter: cubic-bezier(.16,1,.3,1);--et-ease-exit: cubic-bezier(.4,0,1,1);--et-ease-move: cubic-bezier(.32,.72,0,1);--et-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--et-font-size-title: 13.5px;--et-font-size-body: 13px;--et-font-size-desc: 12.5px;--et-font-size-action: 12.5px;--editora-toast-bg: var(--et-bg);--editora-toast-color: var(--et-text);--editora-toast-muted-color: var(--et-text-muted);--editora-toast-border: var(--et-border);--editora-toast-shadow: var(--et-shadow);--editora-toast-border-radius: var(--et-radius);--editora-toast-font-family: var(--et-font);--editora-toast-font-size: var(--et-font-size-body);--editora-toast-gap: var(--et-gap);--editora-toast-z-index: var(--et-z);--editora-toast-width: var(--et-width);--editora-toast-offset: var(--et-offset);--editora-toast-mobile-offset: 12px}@media(prefers-color-scheme:dark){:root{--et-bg: #19181a;--et-bg-subtle: #232225;--et-border: rgba(255,255,255,.1);--et-border-strong: rgba(255,255,255,.18);--et-text: #f5f5f4;--et-text-muted: #a8a29e;--et-text-inverse: #19181a;--et-info: #60a5fa;--et-success: #4ade80;--et-error: #f87171;--et-warning: #fbbf24;--et-loading: #a5b4fc;--et-promise: #a5b4fc;--et-info-tint: rgba(96,165,250,.13);--et-info-ring: rgba(96,165,250,.32);--et-success-tint: rgba(74,222,128,.11);--et-success-ring: rgba(74,222,128,.3);--et-error-tint: rgba(248,113,113,.12);--et-error-ring: rgba(248,113,113,.32);--et-warning-tint: rgba(251,191,36,.11);--et-warning-ring: rgba(251,191,36,.3);--et-loading-tint: rgba(165,180,252,.12);--et-loading-ring: rgba(165,180,252,.3);--et-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 2px 6px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.45)}}:root.dark,:root[data-theme=dark],:root[data-bs-theme=dark],:root[data-color-scheme=dark],:root[data-mantine-color-scheme=dark]{--et-bg: #19181a;--et-bg-subtle: #232225;--et-border: rgba(255,255,255,.1);--et-border-strong: rgba(255,255,255,.18);--et-text: #f5f5f4;--et-text-muted: #a8a29e;--et-text-inverse: #19181a;--et-info: #60a5fa;--et-success: #4ade80;--et-error: #f87171;--et-warning: #fbbf24;--et-loading: #a5b4fc;--et-promise: #a5b4fc;--et-info-tint: rgba(96,165,250,.13);--et-info-ring: rgba(96,165,250,.32);--et-success-tint: rgba(74,222,128,.11);--et-success-ring: rgba(74,222,128,.3);--et-error-tint: rgba(248,113,113,.12);--et-error-ring: rgba(248,113,113,.32);--et-warning-tint: rgba(251,191,36,.11);--et-warning-ring: rgba(251,191,36,.3);--et-loading-tint: rgba(165,180,252,.12);--et-loading-ring: rgba(165,180,252,.3);--et-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 2px 6px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.45)}:root.light,:root[data-theme=light],:root[data-bs-theme=light],:root[data-color-scheme=light],:root[data-mantine-color-scheme=light]{--et-bg: #ffffff;--et-bg-subtle: #f6f6f5;--et-border: rgba(0,0,0,.09);--et-border-strong: rgba(0,0,0,.16);--et-text: #1c1917;--et-text-muted: #6b6560;--et-text-inverse: #fafaf9;--et-info: #2563eb;--et-success: #15803d;--et-error: #dc2626;--et-warning: #b45309;--et-loading: #4f46e5;--et-promise: #4f46e5;--et-info-tint: rgba(37,99,235,.08);--et-info-ring: rgba(37,99,235,.28);--et-success-tint: rgba(21,128,61,.08);--et-success-ring: rgba(21,128,61,.28);--et-error-tint: rgba(220,38,38,.07);--et-error-ring: rgba(220,38,38,.28);--et-warning-tint: rgba(180,83,9,.08);--et-warning-ring: rgba(180,83,9,.3);--et-loading-tint: rgba(79,70,229,.07);--et-loading-ring: rgba(79,70,229,.26);--et-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.1)}.editora-toast-container{position:fixed;z-index:var(--et-z);width:var(--et-width);max-width:calc(100vw - 2 * var(--et-offset));box-sizing:border-box;pointer-events:auto}.editora-toast-container[data-count="0"]{pointer-events:none}[dir=rtl] .editora-toast-container,.editora-toast-container[data-rtl=true]{direction:rtl}[dir=rtl] .editora-toast,.editora-toast[data-rtl=true]{direction:rtl;text-align:right}.editora-toast[data-rtl=true] .editora-toast-close,[dir=rtl] .editora-toast .editora-toast-close{right:auto;left:8px}.editora-toast[data-rtl=true][data-closable=true],[dir=rtl] .editora-toast[data-closable=true]{padding-right:14px;padding-left:40px}.editora-toast[data-rtl=true]:has(.editora-toast-icon) .editora-toast-actions,[dir=rtl] .editora-toast:has(.editora-toast-icon) .editora-toast-actions{margin-left:0;margin-right:28px}.editora-toast{--et-accent: var(--et-info);position:absolute;left:0;width:100%;box-sizing:border-box;padding:12px 14px;background:var(--et-bg);color:var(--et-text);border:1px solid var(--et-border);border-radius:var(--et-radius);box-shadow:var(--et-shadow);font-family:var(--et-font);font-size:var(--et-font-size-body);line-height:1.45;pointer-events:auto;touch-action:none;overflow:hidden;outline:none;-webkit-font-smoothing:antialiased;translate:0 var(--et-y, 0px);scale:var(--et-s, 1);opacity:0;transform:translateY(calc(var(--et-edge, 1) * 18px)) scale(.97);transition:opacity var(--et-dur-exit) var(--et-ease-exit),transform var(--et-dur-exit) var(--et-ease-exit),translate .38s var(--et-ease-move),scale .38s var(--et-ease-move),height .38s var(--et-ease-move),box-shadow .2s ease}.editora-toast-container[data-edge=bottom] .editora-toast{bottom:0;transform-origin:50% 100%}.editora-toast-container[data-edge=top] .editora-toast{top:0;transform-origin:50% 0}.editora-toast.show{opacity:1;transform:none;transition:opacity var(--et-dur-enter) var(--et-ease-enter),transform var(--et-dur-enter) var(--et-ease-enter),translate .38s var(--et-ease-move),scale .38s var(--et-ease-move),height .38s var(--et-ease-move),box-shadow .2s ease}.editora-toast.hiding{opacity:0;transform:translateY(calc(var(--et-edge, 1) * 12px)) scale(.96);pointer-events:none}.editora-toast.spring-animation{transition:none!important;animation:none!important}.editora-toast[data-collapsed=true]{pointer-events:none}.editora-toast[data-collapsed=true]>*{opacity:0;transition:opacity .2s ease}.editora-toast[data-hidden=true]{opacity:0!important;pointer-events:none}.editora-toast-info{--et-accent: var(--et-info)}.editora-toast-success{--et-accent: var(--et-success)}.editora-toast-error{--et-accent: var(--et-error)}.editora-toast-warning{--et-accent: var(--et-warning)}.editora-toast-loading,.editora-toast-progress,.editora-toast-promise{--et-accent: var(--et-loading)}.editora-toast[data-rich-colors=true]:not([data-theme=colored]).editora-toast-info{background:linear-gradient(var(--et-info-tint),var(--et-info-tint)),var(--et-bg);border-color:var(--et-info-ring)}.editora-toast[data-rich-colors=true]:not([data-theme=colored]).editora-toast-success{background:linear-gradient(var(--et-success-tint),var(--et-success-tint)),var(--et-bg);border-color:var(--et-success-ring)}.editora-toast[data-rich-colors=true]:not([data-theme=colored]).editora-toast-error{background:linear-gradient(var(--et-error-tint),var(--et-error-tint)),var(--et-bg);border-color:var(--et-error-ring)}.editora-toast[data-rich-colors=true]:not([data-theme=colored]).editora-toast-warning{background:linear-gradient(var(--et-warning-tint),var(--et-warning-tint)),var(--et-bg);border-color:var(--et-warning-ring)}.editora-toast[data-rich-colors=true]:not([data-theme=colored]).editora-toast-loading,.editora-toast[data-rich-colors=true]:not([data-theme=colored]).editora-toast-promise{background:linear-gradient(var(--et-loading-tint),var(--et-loading-tint)),var(--et-bg);border-color:var(--et-loading-ring)}.editora-toast[data-closable=true]{padding-right:40px}.editora-toast-content{display:flex;align-items:flex-start;gap:10px;min-height:20px}.editora-toast-icon{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:18px;height:18px;margin-top:1px;color:var(--et-accent);font-size:15px;line-height:1}.editora-toast-icon svg{display:block}.editora-toast-icon[data-spin=true] svg{animation:et-spin .8s linear infinite}.editora-toast-body{flex:1;min-width:0}.editora-toast-title{font-size:var(--et-font-size-title);font-weight:600;letter-spacing:-.01em;line-height:1.35;margin:0;color:var(--et-text)}.editora-toast-message{line-height:1.45;overflow-wrap:anywhere;color:var(--et-text)}.editora-toast-body>.editora-toast-message:only-child{font-weight:500}.editora-toast-title+.editora-toast-message,.editora-toast-title+.editora-toast-description,.editora-toast-message+.editora-toast-description{margin-top:2px}.editora-toast-description{color:var(--et-text-muted);font-size:var(--et-font-size-desc);line-height:1.45;overflow-wrap:anywhere}.editora-toast-actions{display:flex;gap:6px;margin-top:10px;flex-wrap:wrap;justify-content:flex-start}.editora-toast:has(.editora-toast-icon) .editora-toast-actions{margin-left:28px}.editora-toast-action{height:28px;padding:0 12px;border:1px solid var(--et-border-strong);background:transparent;color:var(--et-text);border-radius:var(--et-radius-sm);font-size:var(--et-font-size-action);font-weight:500;font-family:var(--et-font);line-height:1;cursor:pointer;white-space:nowrap;display:inline-flex;align-items:center;transition:background .15s ease,border-color .15s ease,transform .1s ease,opacity .15s ease}.editora-toast-action:hover{background:var(--et-bg-subtle)}.editora-toast-action:active{transform:scale(.97)}.editora-toast-action.primary{background:var(--et-action-bg, var(--et-text));border-color:var(--et-action-bg, var(--et-text));color:var(--et-action-ink, var(--et-bg))}.editora-toast-action.primary:hover{background:var(--et-action-bg, var(--et-text));opacity:.88}.editora-toast-close{position:absolute;top:8px;right:8px;width:24px;height:24px;padding:0;display:grid;place-items:center;border:0;background:transparent;color:var(--et-text-muted);border-radius:7px;cursor:pointer;opacity:0;transition:opacity .16s ease,background .15s ease,color .15s ease;z-index:1}.editora-toast-close svg{display:block}.editora-toast:hover .editora-toast-close,.editora-toast:focus-within .editora-toast-close,.editora-toast-close:focus-visible{opacity:1}@media(hover:none){.editora-toast-close{opacity:1}}.editora-toast-close:hover{background:var(--et-bg-subtle);color:var(--et-text)}.editora-toast-close:active{transform:scale(.92)}.editora-toast-progress-track{position:relative;height:4px;margin-top:10px;border-radius:99px;background:var(--et-border)}.editora-toast-progress-bar{height:100%;border-radius:inherit;background:var(--et-accent);transition:width .25s ease}.editora-toast-progress-text{position:absolute;top:-17px;right:0;font-size:11px;font-variant-numeric:tabular-nums;color:var(--et-text-muted)}.editora-toast-group{margin-bottom:4px}.editora-toast-group-header{font-size:10px;font-weight:600;opacity:.55;margin-bottom:4px;text-transform:uppercase;letter-spacing:.06em}.editora-toast-group-collapsed{max-height:40px;overflow:hidden}@keyframes et-spin{to{transform:rotate(360deg)}}.editora-toast[data-theme=light]{--et-bg: #ffffff;--et-bg-subtle: #f6f6f5;--et-border: rgba(0,0,0,.09);--et-border-strong: rgba(0,0,0,.16);--et-text: #1c1917;--et-text-muted: #6b6560;--et-info: #2563eb;--et-success: #15803d;--et-error: #dc2626;--et-warning: #b45309;--et-loading: #4f46e5;--et-promise: #4f46e5;--et-info-tint: rgba(37,99,235,.08);--et-info-ring: rgba(37,99,235,.28);--et-success-tint: rgba(21,128,61,.08);--et-success-ring: rgba(21,128,61,.28);--et-error-tint: rgba(220,38,38,.07);--et-error-ring: rgba(220,38,38,.28);--et-warning-tint: rgba(180,83,9,.08);--et-warning-ring: rgba(180,83,9,.3);--et-loading-tint: rgba(79,70,229,.07);--et-loading-ring: rgba(79,70,229,.26);--et-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.1)}.editora-toast[data-theme=dark]{--et-bg: #19181a;--et-bg-subtle: #232225;--et-border: rgba(255,255,255,.1);--et-border-strong: rgba(255,255,255,.18);--et-text: #f5f5f4;--et-text-muted: #a8a29e;--et-info: #60a5fa;--et-success: #4ade80;--et-error: #f87171;--et-warning: #fbbf24;--et-loading: #a5b4fc;--et-promise: #a5b4fc;--et-info-tint: rgba(96,165,250,.13);--et-info-ring: rgba(96,165,250,.32);--et-success-tint: rgba(74,222,128,.11);--et-success-ring: rgba(74,222,128,.3);--et-error-tint: rgba(248,113,113,.12);--et-error-ring: rgba(248,113,113,.32);--et-warning-tint: rgba(251,191,36,.11);--et-warning-ring: rgba(251,191,36,.3);--et-loading-tint: rgba(165,180,252,.12);--et-loading-ring: rgba(165,180,252,.3);--et-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 2px 6px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.45)}.editora-toast[data-theme=minimal]{--et-bg: #ffffff;--et-bg-subtle: #f6f6f5;--et-text: #1c1917;--et-text-muted: #6b6560;--et-border: rgba(0,0,0,.14);--et-border-strong: rgba(0,0,0,.22);--et-info: #2563eb;--et-success: #15803d;--et-error: #dc2626;--et-warning: #b45309;--et-loading: #4f46e5;border-radius:6px;box-shadow:0 1px 3px #00000014;border-left:3px solid var(--et-accent)}.editora-toast[data-theme=colored]{--et-info: #2563eb;--et-success: #15803d;--et-error: #c81e1e;--et-warning: #b45309;--et-loading: #4f46e5;--et-text: #ffffff;--et-text-muted: rgba(255,255,255,.95);--et-bg-subtle: rgba(255,255,255,.16);--et-border: rgba(255,255,255,.22);--et-border-strong: rgba(255,255,255,.38);--et-action-bg: #ffffff;--et-action-ink: var(--et-accent);background:var(--et-accent);border-color:transparent;box-shadow:0 8px 22px #00000038}.editora-toast[data-theme=colored] .editora-toast-icon{color:#fff}.editora-toast[data-theme=colored] .editora-toast-progress-bar{background:#fff}.editora-toast[data-theme=glass]{--et-bg: rgba(24,24,27,.72);--et-bg-subtle: rgba(255,255,255,.1);--et-text: #ffffff;--et-text-muted: rgba(255,255,255,.86);--et-border: rgba(255,255,255,.16);--et-border-strong: rgba(255,255,255,.3);--et-info: #7dd3fc;--et-success: #86efac;--et-error: #fca5a5;--et-warning: #fcd34d;--et-loading: #c4b5fd;--et-action-bg: #ffffff;--et-action-ink: #18181b;-webkit-backdrop-filter:blur(22px) saturate(170%);backdrop-filter:blur(22px) saturate(170%);box-shadow:0 10px 34px #00000047,inset 0 1px #ffffff24}.editora-toast[data-theme=neon]{--et-bg: #09090b;--et-bg-subtle: #18181b;--et-text: #e4e4e7;--et-text-muted: #a1a1aa;--et-border: rgba(255,255,255,.08);--et-border-strong: rgba(255,255,255,.2);--et-info: #38bdf8;--et-success: #4ade80;--et-error: #f87171;--et-warning: #fbbf24;--et-loading: #a5b4fc;border-color:var(--et-accent);box-shadow:0 0 18px color-mix(in srgb,var(--et-accent) 28%,transparent),0 4px 12px #00000080}.editora-toast[data-theme=ocean]{--et-bg: #0f2942;--et-bg-subtle: #1a3d5c;--et-text: #e0f2fe;--et-text-muted: rgba(224,242,254,.76);--et-border: rgba(186,230,253,.18);--et-border-strong: rgba(186,230,253,.32);--et-info: #38bdf8;--et-success: #34d399;--et-error: #fb7185;--et-warning: #fbbf24;--et-loading: #a5b4fc;background:linear-gradient(135deg,#0f2942,#1a3d5c);box-shadow:0 8px 28px #0f294266}.editora-toast[data-theme=forest]{--et-bg: #052e16;--et-bg-subtle: #14532d;--et-text: #dcfce7;--et-text-muted: rgba(220,252,231,.76);--et-border: rgba(220,252,231,.16);--et-border-strong: rgba(220,252,231,.3);--et-info: #4ade80;--et-success: #86efac;--et-error: #fca5a5;--et-warning: #fde68a;--et-loading: #6ee7b7;background:linear-gradient(135deg,#052e16,#14532d);box-shadow:0 8px 28px #052e1666}.editora-toast[data-theme=sunset]{--et-bg: #431407;--et-bg-subtle: #7c2d12;--et-text: #fed7aa;--et-text-muted: rgba(254,215,170,.78);--et-border: rgba(254,215,170,.16);--et-border-strong: rgba(254,215,170,.3);--et-info: #fb923c;--et-success: #fbbf24;--et-error: #fca5a5;--et-warning: #fde68a;--et-loading: #d8b4fe;background:linear-gradient(135deg,#431407,#7c2d12);box-shadow:0 8px 28px #43140766}.editora-toast[data-theme=midnight]{--et-bg: #0a0a0f;--et-bg-subtle: #14141f;--et-text: #e2e8f0;--et-text-muted: rgba(226,232,240,.72);--et-border: rgba(226,232,240,.1);--et-border-strong: rgba(226,232,240,.22);--et-info: #60a5fa;--et-success: #34d399;--et-error: #f87171;--et-warning: #fbbf24;--et-loading: #a5b4fc;box-shadow:0 8px 28px #0009,inset 0 1px #ffffff0a}.editora-toast[data-theme=retro]{--et-bg: #fefce8;--et-bg-subtle: #fef9c3;--et-text: #1c1917;--et-text-muted: #57534e;--et-border: #1c1917;--et-border-strong: #1c1917;--et-info: #1d4ed8;--et-success: #15803d;--et-error: #b91c1c;--et-warning: #b45309;--et-loading: #4338ca;border:2px solid var(--et-accent);border-radius:6px;box-shadow:4px 4px 0 var(--et-accent);font-family:Courier New,Courier,monospace}.editora-toast:focus-visible,.editora-toast-action:focus-visible,.editora-toast-close:focus-visible{outline:2px solid var(--et-focus, var(--et-info));outline-offset:2px}@media(prefers-reduced-motion:reduce){.editora-toast,.editora-toast.show,.editora-toast.hiding{transition:opacity .1s ease!important;transform:none!important}.editora-toast-icon[data-spin=true] svg{animation-duration:1.6s}}@media(prefers-contrast:more){.editora-toast{border-color:var(--et-text);box-shadow:none}.editora-toast-description,.editora-toast-progress-text{color:var(--et-text)}.editora-toast-close{opacity:1;color:var(--et-text)}.editora-toast-action{border-color:var(--et-text)}}@media(forced-colors:active){.editora-toast{forced-color-adjust:none;background:Canvas;color:CanvasText;border:1px solid CanvasText;box-shadow:none}.editora-toast-title,.editora-toast-message,.editora-toast-description,.editora-toast-progress-text,.editora-toast-icon{color:CanvasText}.editora-toast-action{background:ButtonFace;color:ButtonText;border-color:ButtonText}.editora-toast-action.primary{background:Highlight;color:HighlightText;border-color:Highlight}.editora-toast-close{opacity:1;color:ButtonText}.editora-toast-action:focus-visible,.editora-toast-close:focus-visible{outline:2px solid Highlight;outline-offset:2px}.editora-toast-progress-track{background:GrayText}.editora-toast-progress-bar{background:Highlight}}@media(max-width:480px){.editora-toast-container{left:max(12px,env(safe-area-inset-left))!important;right:max(12px,env(safe-area-inset-right))!important;width:auto!important;max-width:none!important;transform:none!important}.editora-toast-container[data-position=center]{top:max(12px,env(safe-area-inset-top))!important}.editora-toast-action{flex:1;justify-content:center}}.editora-toast .close{position:absolute;top:10px;right:10px;background:none;border:none;color:inherit;cursor:pointer;font-size:16px;opacity:.5;transition:opacity .2s ease}.editora-toast .close:hover{opacity:1}';let j=null;function J(a){j=a}function tt(){return j}J(A);class et{constructor(t){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...t}}addToast(t){this.toasts.set(t.id,t),this.updateGroup(t)}removeToast(t){const e=this.toasts.get(t);return e?(this.toasts.delete(t),this.updateGroup(e),!0):!1}getToast(t){return this.toasts.get(t)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(t){return this.getAllToasts().filter(e=>e.options.position===t)}updateToast(t,e){const s=this.toasts.get(t);return s?(Object.assign(s,e),this.updateGroup(s),!0):!1}updateGroup(t){const e=t.options.group;if(!e)return;let s=this.groups.get(e);s||(s={id:e,toasts:[]},this.groups.set(e,s)),s.toasts=s.toasts.filter(o=>o.id!==t.id),t.options.group===e&&s.toasts.push(t),s.toasts.length===0&&this.groups.delete(e)}getGroup(t){return this.groups.get(t)}getAllGroups(){return Array.from(this.groups.values())}getContainer(t){return this.containers.get(t)}setContainer(t,e){this.containers.set(t,e)}removeContainer(t){return this.containers.delete(t)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}clear(){this.toasts.clear(),this.groups.clear()}getStats(){return{totalToasts:this.toasts.size,totalGroups:this.groups.size,toastsByPosition:Object.fromEntries(Array.from(this.containers.keys()).map(t=>[t,this.getToastsByPosition(t).length]))}}}class st{constructor(t){this.queue=[],this.visible=[],this.config=this.normalizeConfig(t)}enqueue(t){var r;const e=this.findDuplicate(t);if(e&&((r=t.options.preventDuplicate)!=null?r:this.config.preventDuplicate))return{show:[],hide:[],rejected:e};const s=[];if(t.options.important&&this.visible.length>=this.maxVisible){const i=this.removeLowestPriorityVisible();return this.visible.push(t),{show:[t],hide:i?[...s,i]:s}}this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.sortQueue();const o=this.processQueue();return{show:o.show,hide:[...s,...o.hide]}}dequeue(t){return this.removeFromCollections(t)?{show:this.processQueue().show,hide:[]}:{show:[],hide:[]}}updateConfig(t){return this.config=this.normalizeConfig({...this.config,...t}),this.sortQueue(),this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}isVisible(t){return this.visible.some(e=>e.id===t)}clear(){const t=[...this.visible,...this.queue];return this.queue=[],this.visible=[],t}processQueue(){const t=[],e=[];for(;this.visible.length>this.maxVisible;){const s=this.visible.pop();s&&e.push(s)}for(;this.visible.length<this.maxVisible&&this.queue.length>0;){const s=this.queue.shift();if(!s)break;this.visible.push(s),t.push(s)}return{show:t,hide:e}}removeLowestPriorityVisible(){if(this.visible.length===0)return;let t=0;for(let e=1;e<this.visible.length;e+=1)(this.visible[e].options.priority||0)<(this.visible[t].options.priority||0)&&(t=e);return this.visible.splice(t,1)[0]}removeFromCollections(t){const e=this.visible.findIndex(o=>o.id===t);if(e!==-1)return this.visible.splice(e,1)[0];const s=this.queue.findIndex(o=>o.id===t);if(s!==-1)return this.queue.splice(s,1)[0]}findDuplicate(t){const e=t.options.dedupeScope||this.config.dedupeScope,s=e==="visible"?this.visible:e==="queue"?this.queue:[...this.visible,...this.queue],o=this.getDedupeKey(t);return s.find(r=>this.getDedupeKey(r)===o)}getDedupeKey(t){if(t.options.dedupeKey)return t.options.dedupeKey;const{level:e,title:s,message:o,description:r}=t.options;return typeof Node!="undefined"&&[s,o,r].some(n=>n instanceof Node)?`node:${t.id}`:`${e||"info"}:${s||""}:${o||""}:${r||""}`}sortQueue(){this.queue.sort((t,e)=>{const s=(e.options.priority||0)-(t.options.priority||0);return s!==0?s:t.createdAt-e.createdAt})}get maxVisible(){return Math.max(1,this.config.visibleToasts||this.config.maxVisible||1)}normalizeConfig(t){return{...t,maxVisible:t.visibleToasts||t.maxVisible}}}const ot=new Set(["a","b","strong","i","em","u","s","del","ins","mark","small","sub","sup","code","kbd","br","span","p","ul","ol","li"]),rt=new Set(["script","style","iframe","frame","frameset","object","embed","applet","noscript","template","svg","math","form","input","button","textarea","select","option","head","title","link","meta","base","audio","video","canvas"]),it=/^(?:https?:|mailto:|tel:)/i;function at(a){const t=a.replace(/[\u0000- \u007f-\u009f]/g,"");return t?it.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t):!1}function B(a,t,e){for(const s of Array.from(a.childNodes)){if(s.nodeType===Node.TEXT_NODE){t.appendChild(e.createTextNode(s.textContent||""));continue}if(s.nodeType!==Node.ELEMENT_NODE)continue;const o=s,r=o.localName.toLowerCase();if(rt.has(r))continue;if(!ot.has(r)){B(o,t,e);continue}const i=e.createElement(r);if(r==="a"){const n=o.getAttribute("href");n&&at(n)&&(i.setAttribute("href",n.trim()),/^(?:https?:)?\/\//i.test(n.trim())&&(i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer")));const c=o.getAttribute("title");c&&i.setAttribute("title",c)}B(o,i,e),t.appendChild(i)}}function nt(a,t){const e=document.createElement("template");e.innerHTML=t;const s=document.createDocumentFragment();B(e.content,s,document),a.textContent="",a.appendChild(s)}const Y="http://www.w3.org/2000/svg",ct={success:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M6.6 10.3l2.3 2.3 4.5-4.9"}]],error:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M7.6 7.6l4.8 4.8M12.4 7.6l-4.8 4.8"}]],warning:[["path",{d:"M10 2.9L18 16.4H2L10 2.9z"}],["path",{d:"M10 8.3v3.4M10 13.9v.1"}]],info:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M10 9.2v4.4M10 6.5v.1"}]],loading:[["path",{d:"M10 2a8 8 0 1 0 8 8"}]]},dt={success:"success",error:"error",warning:"warning",info:"info",loading:"loading",promise:"loading"};function V(a,t){const e=document.createElementNS(Y,"svg");return e.setAttribute("viewBox","0 0 20 20"),e.setAttribute("width",String(t)),e.setAttribute("height",String(t)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.7"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("focusable","false"),e.setAttribute("aria-hidden","true"),a.forEach(([s,o])=>{const r=document.createElementNS(Y,s);Object.keys(o).forEach(i=>r.setAttribute(i,o[i])),e.appendChild(r)}),e}function lt(a){const t=ct[dt[a]||""];return t?V(t,18):null}function ut(){const a=V([["path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"}]],14);return a.setAttribute("stroke-width","1.8"),a}const X=12,pt=.05,F=3,z=new WeakMap;function ft(a){const t=a.style.height;a.style.height="auto";const e=a.offsetHeight;return a.style.height=t,z.set(a,e),e}function W(a){z.delete(a)}function ht(a,t){return!t.stack||t.expand||a.dataset.open==="true"}function gt(a,t,e=!1){const o=a.dataset.edge==="bottom"?-1:1,r=Array.from(a.querySelectorAll(".editora-toast")),i=r.filter(l=>!l.classList.contains("hiding")&&l.dataset.leaving!=="true"),n=i.slice().reverse(),c=ht(a,t);n.forEach(l=>{(e||!z.has(l))&&ft(l)});const d=n.map(l=>z.get(l)||0),u=d[0]||0;let h=0;n.forEach((l,m)=>{const T=d[m],g=c?1:Math.max(1-m*pt,.8),y=c?T:u,b=c?h:m*X+u*(1-g);l.style.setProperty("--et-y",`${o*b}px`),l.style.setProperty("--et-s",String(g)),l.style.setProperty("--et-index",String(m)),l.style.height=`${y}px`,l.style.zIndex=String(n.length-m),l.dataset.index=String(m),l.dataset.front=String(m===0),l.dataset.collapsed=String(!c&&m>0),l.dataset.hidden=String(!c&&m>=F),h+=T+t.gap}),r.forEach(l=>{i.includes(l)||(l.dataset.front="false")});const f=n.length,w=c?d.reduce((l,m)=>l+m,0)+Math.max(f-1,0)*t.gap:u+(Math.min(f,F)-1>0?(Math.min(f,F)-1)*X:0);a.style.height=f>0?`${w}px`:"0px",a.dataset.count=String(f),a.dataset.expanded=String(c)}let _=null;const H=()=>_||(_=Promise.resolve().then(()=>kt).then(a=>a.animationManager)),O=a=>!!a&&a.type!=="css"&&a.type!=="custom",mt=a=>new Promise(t=>{requestAnimationFrame(()=>{a.classList.add("show"),window.setTimeout(t,220)})}),bt=a=>new Promise(t=>{a.classList.remove("show"),a.classList.add("hiding"),window.setTimeout(t,220)});async function R(a,t,e,s){if(O(s)){const o=await H();return a==="show"?o.showToast(t,e,s):o.hideToast(t,e,s)}if(s.type==="custom"){const o=a==="show"?s.show:s.hide;if(o)return void await Promise.resolve(o(t,e))}return a==="show"?mt(t):bt(t)}const G=a=>typeof Node!="undefined"&&a instanceof Node;function N(a,t,e){G(t)?a.appendChild(t):e?nt(a,t):a.textContent=t}function yt(){const a=document.querySelector('meta[property="csp-nonce"]');return a&&(a.nonce||a.getAttribute("nonce")||a.content)||void 0}const vt=a=>G(a)?a.textContent||"":a?String(a):"";class wt{constructor(t){this.containers=new Map,this.cssInjected=!1,this.toastOf=new WeakMap,this.holds=new Map,this.timing=new Map,this.returnFocusTo=null,this.globalListeners=[],this.resizeObserver=null,this.config=t,O(t.animation)&&H()}observeSize(t){if(typeof ResizeObserver=="undefined")return;if(!this.resizeObserver){const s=new Set;let o=0;this.resizeObserver=new ResizeObserver(r=>{for(const i of r){const n=i.target.closest(".editora-toast");n&&s.add(n)}o||(o=requestAnimationFrame(()=>{o=0;const i=new Set;s.forEach(n=>{W(n),n.parentElement&&i.add(n.parentElement)}),s.clear(),i.forEach(n=>this.layout(n))}))})}const e=t.querySelector(".editora-toast-content");e&&this.resizeObserver.observe(e)}updateConfig(t){O(t.animation)&&H(),this.config=t,this.containers.forEach((e,s)=>{this.applyContainerStyles(e,s),this.layout(e,!0)})}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");return e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite"),e.dataset.expand=String(this.config.expand),e.dataset.stack=String(this.config.stack),this.applyContainerStyles(e,t),this.attachContainerListeners(e),document.body.appendChild(e),this.containers.set(t,e),this.attachGlobalListeners(),this.injectCSS(),e}attachContainerListeners(t){t.addEventListener("mouseenter",()=>{t.dataset.hover="true",this.holdAll(t,"pointer"),this.syncOpen(t)}),t.addEventListener("pointerdown",e=>{e.pointerType!=="touch"||t.dataset.hover==="true"||(t.dataset.hover="true",this.holdAll(t,"pointer"),this.syncOpen(t))}),t.addEventListener("mouseleave",()=>{delete t.dataset.hover,this.releaseAll(t,"pointer"),this.syncOpen(t)}),t.addEventListener("focusin",e=>{this.isKeyboardFocus(e.target)&&(t.dataset.focus="true",this.holdAll(t,"focus"),this.syncOpen(t))}),t.addEventListener("focusout",e=>{const s=e.relatedTarget;s&&t.contains(s)||(delete t.dataset.focus,this.releaseAll(t,"focus"),this.syncOpen(t))}),t.addEventListener("keydown",e=>this.onContainerKey(t,e))}syncOpen(t){const e=t.dataset.hover==="true"||t.dataset.focus==="true";t.dataset.open=String(e),this.layout(t)}isKeyboardFocus(t){if(!(t instanceof Element))return!1;try{return t.matches(":focus-visible")}catch(e){return!0}}onContainerKey(t,e){if(e.key!=="Escape")return;const s=e.target instanceof Element?e.target.closest(".editora-toast"):null,o=s?this.toastOf.get(s):void 0;if(!s||!o)return;e.preventDefault();const r=Array.from(t.querySelectorAll(".editora-toast:not(.hiding)")),i=r[r.indexOf(s)+1]||r[r.indexOf(s)-1];o.dismiss(),i&&i!==s?i.focus():this.restoreFocus()}restoreFocus(){const t=this.returnFocusTo;this.returnFocusTo=null,t&&t.isConnected&&t.focus()}attachGlobalListeners(){if(this.globalListeners.length>0||typeof window=="undefined")return;const t=(e,s,o)=>{e.addEventListener(s,o),this.globalListeners.push([e,s,o])};t(document,"keydown",(e=>{if(!this.matchesHotkey(e))return;const s=Array.from(this.containers.values()).find(i=>i.querySelector(".editora-toast:not(.hiding)"));if(!s)return;const o=s.querySelector('.editora-toast[data-front="true"]');if(!o)return;e.preventDefault();const r=document.activeElement;r instanceof HTMLElement&&!s.contains(r)&&(this.returnFocusTo=r),o.focus()})),t(document,"pointerdown",(e=>{this.containers.forEach(s=>{s.dataset.hover==="true"&&!s.contains(e.target)&&(delete s.dataset.hover,this.releaseAll(s,"pointer"),this.syncOpen(s))})})),t(window,"resize",(()=>{window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.containers.forEach(e=>this.layout(e,!0)),120)}))}matchesHotkey(t){const e=this.config.hotkey;if(!e)return!1;const s=e.toLowerCase().split("+").map(i=>i.trim()).filter(Boolean),o=s.pop();if(!o)return!1;const r=i=>s.includes(i);return t.altKey!==r("alt")||t.shiftKey!==r("shift")||t.ctrlKey!==r("ctrl")||t.metaKey!==(r("meta")||r("cmd"))?!1:t.code.toLowerCase()===`key${o}`||t.code.toLowerCase()===o||t.key.toLowerCase()===o}layout(t,e=!1){gt(t,{stack:this.config.stack,expand:this.config.expand,gap:this.toPx(this.config.gap)},e)}toPx(t){if(typeof t=="number")return t;const e=parseFloat(t||"");return Number.isFinite(e)?e:8}holdAll(t,e){t.querySelectorAll(".editora-toast").forEach(s=>{const o=this.toastOf.get(s);if(!o)return;(e==="focus"?o.options.pauseOnFocus:o.options.pauseOnHover)!==!1&&this.pauseToast(o,e)})}releaseAll(t,e){t.querySelectorAll(".editora-toast").forEach(s=>{const o=this.toastOf.get(s);o&&this.resumeToast(o,e)})}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,s.dataset.level=e.level||"info",e.customClass&&e.customClass.split(/\s+/).filter(Boolean).forEach(n=>s.classList.add(n)),s.setAttribute("role",e.role||(e.level==="error"?"alert":"status")),s.setAttribute("aria-atomic","true"),s.tabIndex=0,(e.closable||e.closeButton)&&(s.dataset.closable="true"),this.toastOf.set(s,t),e.ariaLive&&e.ariaLive!=="off"&&s.setAttribute("aria-live",e.ariaLive);const o=e.theme||this.config.theme;o&&o!=="system"&&s.setAttribute("data-theme",o),(this.config.richColors||o==="colored")&&s.setAttribute("data-rich-colors","true"),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const i=this.createContent(t);if(s.appendChild(i),e.actions&&e.actions.length>0){const n=document.createElement("div");n.className="editora-toast-actions",e.actions.forEach(c=>n.appendChild(this.createActionButton(c,t))),s.appendChild(n)}return(e.closable||e.closeButton)&&s.appendChild(this.createCloseButton(t)),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var r,i;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s),e.dataset.hover==="true"&&t.options.pauseOnHover!==!1&&this.pauseToast(t,"pointer"),e.dataset.focus==="true"&&t.options.pauseOnFocus!==!1&&this.pauseToast(t,"focus"),this.layout(e);const o=t.options.animation||this.config.animation||{type:"css"};O(o)&&H(),this.observeSize(s),await R("show",s,t,o),this.config.enableAccessibility&&this.announceToast(t),(i=(r=t.options).onShow)==null||i.call(r),this.startTimer(t)}async hideToast(t){var r,i,n;if(!t.element)return;this.stopTimer(t),this.holds.delete(t.id);const e=t.element;e.dataset.leaving="true",e.parentElement&&this.layout(e.parentElement);const s=t.options.animation||this.config.animation||{type:"css"},o=e.querySelector(".editora-toast-content");if(o&&((r=this.resizeObserver)==null||r.unobserve(o)),await R("hide",e,t,s),t.element&&t.element.parentNode){const c=t.element.parentElement;t.element.parentNode.removeChild(t.element),t.element=void 0,c&&(c.querySelector(".editora-toast")||(delete c.dataset.hover,delete c.dataset.focus,c.dataset.open="false"),this.layout(c))}(n=(i=t.options).onHide)==null||n.call(i)}async updateToast(t,e){var r,i,n,c;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await Promise.resolve(s.update(t.element,t,e));return}if(Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g,""),t.element.classList.add(`editora-toast-${e.level}`),t.element.dataset.level=e.level),e.title!==void 0||e.description!==void 0||e.message!==void 0||e.icon!==void 0||e.level!==void 0||e.render){const d=t.element.querySelector(".editora-toast-content"),u=this.createContent(t);d&&((r=this.resizeObserver)==null||r.unobserve(d)),d==null||d.replaceWith(u),this.observeSize(t.element)}const o=(i=e.closeButton)!=null?i:e.closable;if(o!==void 0){t.options.closable=o,t.options.closeButton=o,o?t.element.dataset.closable="true":delete t.element.dataset.closable;const d=t.element.querySelector(".editora-toast-close");o&&!d?t.element.appendChild(this.createCloseButton(t)):!o&&d&&d.remove()}if(e.progress!==void 0){const d=t.element.querySelector(".editora-toast-body"),u=t.element.querySelector(".editora-toast-progress-track");if(e.progress&&d){const h=this.createProgress(e.progress);u?u.replaceWith(h):d.appendChild(h)}else u&&u.remove()}if(e.actions!==void 0||e.action!==void 0||e.cancel!==void 0){let d=t.element.querySelector(".editora-toast-actions");const u=t.options.actions||[];u.length>0?(d?d.innerHTML="":(d=document.createElement("div"),d.className="editora-toast-actions",t.element.appendChild(d)),d&&u.forEach(h=>d.appendChild(this.createActionButton(h,t)))):d&&d.remove()}(e.duration!==void 0||e.persistent!==void 0||e.level!==void 0)&&this.startTimer(t),t.element.style.height="",W(t.element),t.element.parentElement&&this.layout(t.element.parentElement),(c=(n=t.options).onUpdate)==null||c.call(n,e)}createContent(t){const e=t.options,s=document.createElement("div");s.className="editora-toast-content";const o=this.createIcon(t);o&&s.appendChild(o);const r=document.createElement("div");if(r.className="editora-toast-body",e.render)r.appendChild(e.render(t));else{if(e.title){const i=document.createElement("div");i.className="editora-toast-title",N(i,e.title),r.appendChild(i)}if(e.message){const i=document.createElement("div");i.className="editora-toast-message",N(i,e.message,e.html),r.appendChild(i)}if(e.description){const i=document.createElement("div");i.className="editora-toast-description",N(i,e.description),r.appendChild(i)}}return e.progress&&r.appendChild(this.createProgress(e.progress)),s.appendChild(r),s}createProgress(t){const e=Math.min(100,Math.max(0,t.value)),s=document.createElement("div");s.className="editora-toast-progress-track",s.setAttribute("role","progressbar"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax","100"),s.setAttribute("aria-valuenow",String(e));const o=document.createElement("div");if(o.className="editora-toast-progress-bar",o.style.width=`${e}%`,t.showPercentage){const r=document.createElement("span");r.className="editora-toast-progress-text",r.textContent=`${Math.round(t.value)}%`,s.appendChild(r)}return s.appendChild(o),s}createCloseButton(t){const e=document.createElement("button");return e.className="editora-toast-close",e.setAttribute("type","button"),e.setAttribute("aria-label","Close notification"),e.appendChild(ut()),e.onclick=()=>t.dismiss(),e}createIcon(t){const e=t.options;if(e.icon===!1)return null;const s=document.createElement("span");if(s.className="editora-toast-icon",s.setAttribute("aria-hidden","true"),typeof e.icon=="string"&&e.icon)return s.textContent=e.icon,s;if(e.icon&&typeof e.icon=="object")return s.appendChild(e.icon),s;if(this.config.icons===!1)return null;const o=e.level||"info",r=lt(o);return r?((o==="loading"||o==="promise")&&(s.dataset.spin="true"),s.appendChild(r),s):null}createActionButton(t,e){const s=document.createElement("button");return s.className=`editora-toast-action ${t.primary?"primary":""}`,s.textContent=t.label,t.altText&&s.setAttribute("aria-label",t.altText),s.onclick=o=>{o.stopPropagation(),t.onClick(),t.dismissOnClick!==!1&&e.dismiss()},s}applyContainerStyles(t,e){const s=this.toCssLength(this.config.offset),o=this.toCssLength(this.config.mobileOffset),r=this.toCssLength(this.config.gap);t.dataset.position=e,t.dataset.edge=e.startsWith("bottom")?"bottom":"top",t.dataset.expand=String(this.config.expand),t.dataset.stack=String(this.config.stack),t.style.setProperty("--editora-toast-offset",s),t.style.setProperty("--editora-toast-mobile-offset",o),t.style.setProperty("--editora-toast-gap",r),t.style.setProperty("--et-edge",e.startsWith("bottom")?"1":"-1");const i={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"block",width:"var(--et-width, 360px)",maxWidth:`calc(100vw - 2 * ${s})`,boxSizing:"border-box",top:"",right:"",bottom:"",left:"",transform:""};switch(e){case"top-left":i.top=`max(${s}, env(safe-area-inset-top))`,i.left=`max(${s}, env(safe-area-inset-left))`;break;case"top-center":i.top=`max(${s}, env(safe-area-inset-top))`,i.left="50%",i.transform="translateX(-50%)";break;case"top-right":i.top=`max(${s}, env(safe-area-inset-top))`,i.right=`max(${s}, env(safe-area-inset-right))`;break;case"bottom-left":i.bottom=`max(${s}, env(safe-area-inset-bottom))`,i.left=`max(${s}, env(safe-area-inset-left))`;break;case"bottom-center":i.bottom=`max(${s}, env(safe-area-inset-bottom))`,i.left="50%",i.transform="translateX(-50%)";break;case"bottom-right":i.bottom=`max(${s}, env(safe-area-inset-bottom))`,i.right=`max(${s}, env(safe-area-inset-right))`;break;case"center":i.top="50%",i.left="50%",i.transform="translate(-50%, -50%)";break}Object.assign(t.style,i),t.style.setProperty("--editora-toast-mobile-left",o)}toCssLength(t){return typeof t=="number"?`${t}px`:t||"16px"}startTimer(t){if(this.stopTimer(t),t.options.persistent||t.options.duration===0){this.timing.delete(t.id);return}this.arm(t,t.options.duration||this.config.duration)}arm(t,e){var s;this.timing.set(t.id,{remaining:e,startedAt:Date.now()}),!((((s=this.holds.get(t.id))==null?void 0:s.size)||0)>0)&&(t.timeoutId=window.setTimeout(()=>{t.timeoutId=void 0,t.dismiss()},e))}stopTimer(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}pauseToast(t,e="hover"){const s=this.holds.get(t.id)||new Set;if(this.holds.set(t.id,s),s.size===0&&t.timeoutId){const o=this.timing.get(t.id);this.stopTimer(t),o&&(o.remaining=Math.max(0,o.remaining-(Date.now()-o.startedAt)))}s.add(e)}resumeToast(t,e="hover"){const s=this.holds.get(t.id);if(!s||!s.delete(e)||s.size>0)return;this.holds.delete(t.id);const o=this.timing.get(t.id);o&&!t.timeoutId&&!t.options.persistent&&t.options.duration!==0&&this.arm(t,o.remaining)}addSwipeDismiss(t,e){let s=0,o=0,r=!1;const i=e.options.swipeDirection||this.config.swipeDirection||"any",n=40;let c="",d=!1;const u='button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]',h=()=>{t.style.transform=c,t.style.transition="",t.style.cursor="",t.style.userSelect=""},f=(g,y)=>{if("changedTouches"in g||"touches"in g){const b=y?g.changedTouches:g.touches,v=b&&b[0];return v?{x:v.clientX,y:v.clientY}:null}return{x:g.clientX,y:g.clientY}},w=g=>{const y=g.target;if(y instanceof Element&&t.contains(y)&&y.closest(u)||"button"in g&&g.button!==0)return;const b=f(g,!1);b&&(r=!0,d=!1,s=b.x,o=b.y,c=t.style.transform||"")},l=g=>{var x,I;if(!r)return;const y=f(g,!1);if(!y)return;const b=y.x-s,v=y.y-o,S=5;if(!d&&(Math.abs(b)>S||Math.abs(v)>S)&&(d=!0,t.style.transition="none",t.style.cursor="grabbing",t.style.userSelect="none",(I=(x=window.getSelection)==null?void 0:x.call(window))==null||I.removeAllRanges()),d){const E=Math.abs(v)>Math.abs(b)?25:20,Ct=Math.min(Math.max(b*.2,-E),E),At=Math.min(Math.max(v*.2,-E),E);t.style.transform=`${c} translate(${Ct}px, ${At}px)`,g.cancelable&&g.preventDefault()}},m=g=>{if(!r)return;r=!1;const y=d;if(h(),!y)return;const b=f(g,!0);if(!b)return;const v=b.x-s,S=b.y-o;let x=!1;const E=i==="vertical"||i==="up"||i==="down"?35:n;switch(i){case"any":x=Math.abs(v)>n||Math.abs(S)>n;break;case"horizontal":x=Math.abs(v)>n;break;case"vertical":x=Math.abs(S)>E;break;case"left":x=v<-n;break;case"right":x=v>n;break;case"up":x=S<-E;break;case"down":x=S>E;break}x&&e.dismiss()},T=()=>{r&&(r=!1,d=!1,h())};t.addEventListener("dragstart",g=>g.preventDefault()),t.addEventListener("touchstart",w,{passive:!0}),t.addEventListener("touchmove",l,{passive:!1}),t.addEventListener("touchend",m),t.addEventListener("touchcancel",T),t.addEventListener("mousedown",w),t.addEventListener("mousemove",l),t.addEventListener("mouseup",m),t.addEventListener("mouseleave",m)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){if(t.options.ariaLive==="off")return;const e=document.createElement("div");e.setAttribute("aria-live",t.options.ariaLive||(t.options.level==="error"?"assertive":"polite")),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.left="-10000px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden";const s=[t.options.title,t.options.message,t.options.description].map(vt).filter(Boolean).join(". ");e.textContent=`${t.options.level||"info"}: ${s}`,document.body.appendChild(e),setTimeout(()=>{e.remove()},1e3)}injectCSS(){if(this.cssInjected||typeof document=="undefined"||(this.cssInjected=!0,getComputedStyle(document.documentElement).getPropertyValue("--editora-toast-stylesheet").trim()!==""||Array.from(document.styleSheets).some(i=>{var n,c,d,u;return((c=(n=i.ownerNode)==null?void 0:n.href)==null?void 0:c.includes("toast.css"))||((u=(d=i.ownerNode)==null?void 0:d.textContent)==null?void 0:u.includes("editora-toast"))})))return;const s=document.createElement("style"),o=this.config.nonce||yt();o&&(s.nonce=o);const r=this.config.injectStyles===!1?null:tt();if(r){s.setAttribute("data-editora-toast",""),s.textContent=r,document.head.insertBefore(s,document.head.firstChild);return}console.warn("[@editora/toast] toast.css is not loaded, so toasts use a minimal fallback style. Import '@editora/toast/toast.css' once in your app (or link @editora/toast/dist/toast.css)."),s.setAttribute("data-editora-toast-fallback","true"),s.textContent=".editora-toast-container{position:fixed;width:360px;max-width:100vw;box-sizing:border-box}.editora-toast{position:absolute;left:0;width:100%;box-sizing:border-box;padding:12px 14px;background:#fff;color:#111;border:1px solid #ddd;border-radius:12px;font:13px/1.45 system-ui,sans-serif;overflow:hidden;pointer-events:auto;opacity:0;translate:0 var(--et-y,0px);scale:var(--et-s,1);transition:opacity .2s,translate .3s,scale .3s,height .3s}.editora-toast-container[data-edge=bottom] .editora-toast{bottom:0}.editora-toast-container[data-edge=top] .editora-toast{top:0}.editora-toast.show{opacity:1}.editora-toast.hiding,.editora-toast[data-hidden=true]{opacity:0}",document.head.appendChild(s)}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.globalListeners.forEach(([e,s,o])=>e.removeEventListener(s,o)),this.globalListeners=[],window.clearTimeout(this.resizeTimer),this.containers.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),this.containers.clear()}}class xt{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(t){if(this.plugins.find(e=>e.name===t.name)){console.warn(`Plugin "${t.name}" is already installed`);return}this.plugins.push(t),t.install(this)}remove(t){const e=this.plugins.findIndex(o=>o.name===t);if(e===-1)return!1;const s=this.plugins[e];return s.uninstall&&s.uninstall(this),this.plugins.splice(e,1),!0}getPlugins(){return[...this.plugins]}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}off(t,e){if(this.hooks[t]){const s=this.hooks[t].indexOf(e);s!==-1&&this.hooks[t].splice(s,1)}}async trigger(t,e,...s){const o=this.hooks[t];if(!(!o||o.length===0))for(const r of o)try{await r(e,...s)}catch(i){console.error(`Error in ${t} hook:`,i)}}async beforeShow(t){await this.trigger("beforeShow",t)}async afterShow(t){await this.trigger("afterShow",t)}async beforeHide(t){await this.trigger("beforeHide",t)}async afterHide(t){await this.trigger("afterHide",t)}async beforeUpdate(t,e){await this.trigger("beforeUpdate",t,e)}async afterUpdate(t,e){await this.trigger("afterUpdate",t,e)}onEditorEvent(t,e){const s=`editor:${t}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(e)}triggerEditorEvent(t,e,...s){const o=`editor:${t}`;this.trigger(o,e,...s)}async handlePromise(t,e,s,o){e();try{const r=await t;return s(r),r}catch(r){throw o(r),r}}async batchShow(t){const e=t.map(o=>this.beforeShow(o));await Promise.all(e);const s=t.map(o=>this.afterShow(o));await Promise.all(s)}async batchHide(t){const e=t.map(o=>this.beforeHide(o));await Promise.all(e);const s=t.map(o=>this.afterHide(o));await Promise.all(s)}destroy(){this.plugins.forEach(t=>{t.uninstall&&t.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(t=>{this.hooks[t]=[]})}}const Pt=a=>typeof Node!="undefined"&&a instanceof Node,K={position:"bottom-right",duration:4e3,maxVisible:3,queueStrategy:"fifo",theme:"system",richColors:!1,expand:!1,stack:!0,offset:16,mobileOffset:16,gap:8,pauseOnHover:!0,pauseOnFocus:!0,pauseOnWindowBlur:!1,swipeDismiss:!0,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,closeButton:!1,icons:!0,hotkey:"alt+t",preventDuplicate:!1,dedupeScope:"all",animation:{type:"css"}};class M{constructor(t={}){this.idCounter=0,this.pendingShows=new Map,this.subscribers=new Set,this.config=this.normalizeConfig({...K,...t}),this.store=new et(this.config),this.queue=new st(this.config),this.renderer=new wt(this.config),this.lifecycle=new xt,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:this.normalizeToastOptions({...this.config,...t},t),createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:i=>this.update(e,i)},o=this.lifecycle.beforeShow(s).then(async()=>{const i=this.queue.enqueue(s);i.rejected||(this.store.addToast(s),await this.hideToasts(i.hide,!0),await this.showToasts(i.show),this.notify())});this.pendingShows.set(e,o);const r=()=>{this.pendingShows.get(e)===o&&this.pendingShows.delete(e)};return o.then(r,r),s}update(t,e){const s=this.pendingShows.get(t);if(s)return s.then(()=>this.update(t,e),()=>{}),!0;const o=this.store.getToast(t);return o?(this.lifecycle.beforeUpdate(o,e).then(async()=>{const r=this.normalizeToastOptions({...o.options,...e},e);this.store.updateToast(t,{options:r}),this.queue.isVisible(t)&&await this.renderer.updateToast(o,e),this.lifecycle.afterUpdate(o,e),this.notify()}),!0):!1}dismiss(t){const e=this.pendingShows.get(t);if(e)return e.then(()=>this.dismiss(t),()=>{}),!0;const s=this.store.getToast(t);return s?(this.lifecycle.beforeHide(s).then(async()=>{const o=this.queue.isVisible(t),r=this.queue.dequeue(t);o&&await this.renderer.hideToast(s),this.store.removeToast(t),this.lifecycle.afterHide(s),await this.showToasts(r.show),this.notify()}),!0):!1}clear(){const t=this.queue.clear();Promise.all(t.map(e=>this.hideOne(e,!1))).then(()=>{this.store.clear(),this.notify()})}async promise(t,e){var o,r;const s=this.show({duration:0,...this.normalizeOptions(e.loading,"loading")});try{const i=await t,n=this.normalizeResult(typeof e.success=="function"?e.success(i):e.success,"success");return n.duration===void 0&&!n.persistent&&(n.duration=this.config.duration),this.update(s.id,n),(o=e.onSuccess)==null||o.call(e,i),i}catch(i){const n=this.normalizeResult(typeof e.error=="function"?e.error(i):e.error,"error");throw n.duration===void 0&&!n.persistent&&(n.duration=this.config.duration),this.update(s.id,n),(r=e.onError)==null||r.call(e,i),i}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur,s={...this.config,...t};t.maxVisible!==void 0&&t.visibleToasts===void 0&&delete s.visibleToasts,this.config=this.normalizeConfig(s),this.store.updateConfig(this.config),this.renderer.updateConfig(this.config);const o=this.queue.updateConfig(this.config);this.hideToasts(o.hide,!0).then(()=>this.showToasts(o.show)).then(()=>this.notify()),t.pauseOnWindowBlur!==void 0&&t.pauseOnWindowBlur!==e&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getState(){return{toasts:this.store.getAllToasts(),visible:this.queue.getVisible(),queued:this.queue.getQueued(),groups:this.store.getAllGroups(),config:this.getConfig()}}subscribe(t){return this.subscribers.add(t),t(this.getState()),()=>{this.subscribers.delete(t)}}getGroups(){return this.store.getAllGroups()}info(t,e){return this.show({message:t,level:"info",duration:e})}success(t,e){return this.show({message:t,level:"success",duration:e})}error(t,e){return this.show({message:t,level:"error",duration:e})}warning(t,e){return this.show({message:t,level:"warning",duration:e})}loading(t,e){return this.show({message:t,level:"loading",duration:e})}normalizeOptions(t,e){return typeof t=="string"||Pt(t)?{message:t,level:e}:{...t,level:t.level||e}}normalizeResult(t,e){const s=this.normalizeOptions(t,e);return"message"in s?s:{...s,message:void 0}}normalizeConfig(t){const e=t.visibleToasts||t.maxVisible||K.maxVisible;return{...t,maxVisible:e,visibleToasts:e}}normalizeToastOptions(t,e=t){var i,n,c,d,u,h;const s=(d=(c=(n=(i=e.closeButton)!=null?i:e.closable)!=null?n:t.closable)!=null?c:t.closeButton)!=null?d:this.config.closeButton,o=t.action?{...t.action,primary:(u=t.action.primary)!=null?u:!0}:void 0,r=[...o?[o]:[],...t.cancel?[t.cancel]:[],...t.actions||[]];return{...t,closable:s,closeButton:s,actions:r.length>0?r:void 0,ariaLive:t.ariaLive||(t.level==="error"||t.important?"assertive":"polite"),role:t.role||(t.level==="error"||t.important?"alert":"status"),preventDuplicate:(h=t.preventDuplicate)!=null?h:this.config.preventDuplicate,dedupeScope:t.dedupeScope||this.config.dedupeScope}}async showToasts(t){for(const e of t)await this.renderer.showToast(e),await this.lifecycle.afterShow(e)}async hideToasts(t,e){for(const s of t)await this.hideOne(s,e)}async hideOne(t,e){await this.lifecycle.beforeHide(t),await this.renderer.hideToast(t),e&&this.store.removeToast(t.id),await this.lifecycle.afterHide(t)}notify(){if(this.subscribers.size===0)return;const t=this.getState();this.subscribers.forEach(e=>e(t))}onEditorEvent(t,e){this.lifecycle.onEditorEvent(t,e)}triggerEditorEvent(t,e,...s){this.lifecycle.triggerEditorEvent(t,e,...s)}setupWindowFocusHandling(){typeof window=="undefined"||typeof document=="undefined"||!this.config.pauseOnWindowBlur||(this.teardownWindowFocusHandling(),this.windowBlurHandler=()=>this.pauseAllToasts(),this.windowFocusHandler=()=>this.resumeAllToasts(),this.visibilityChangeHandler=()=>{document.hidden?this.pauseAllToasts():this.resumeAllToasts()},window.addEventListener("blur",this.windowBlurHandler),window.addEventListener("focus",this.windowFocusHandler),document.addEventListener("visibilitychange",this.visibilityChangeHandler))}teardownWindowFocusHandling(){typeof window!="undefined"&&(this.windowBlurHandler&&(window.removeEventListener("blur",this.windowBlurHandler),this.windowBlurHandler=void 0),this.windowFocusHandler&&(window.removeEventListener("focus",this.windowFocusHandler),this.windowFocusHandler=void 0),typeof document!="undefined"&&this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=void 0))}pauseAllToasts(){this.store.getAllToasts().forEach(t=>this.renderer.pauseToast(t,"window"))}resumeAllToasts(){this.store.getAllToasts().forEach(t=>this.renderer.resumeToast(t,"window"))}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let k=null;function p(){return k||(k=new M),k}const Tt=a=>({id:a.id||"",options:a,createdAt:0,dismiss:()=>{},update:()=>{}});function D(a){return typeof document=="undefined"?Tt(a):p().show(a)}function U(a,t,e,s){let o={};t&&typeof t=="object"?o={...t}:typeof t=="number"&&(o.duration=t),e&&(o.theme=e),s&&(o.position=s);const r={message:a,...o,level:o.level||void 0};return o.duration!==void 0&&(r.duration=o.duration),o.position&&(r.position=o.position),o.theme&&(r.theme=o.theme),r}function $(a){return(t,e,s,o)=>D({...U(t,e,s,o),level:a})}const L=()=>typeof document!="undefined";function St(a,t,e,s){const o=U(a,t,e,s);return D({...o,level:o.level||"custom"})}const q=Object.assign(St,{info:$("info"),success:$("success"),error:$("error"),warning:$("warning"),loading:$("loading"),show:a=>D(a),promise:(a,t)=>L()?p().promise(a,t):a,update:(a,t)=>L()?p().update(a,t):!1,dismiss:a=>L()?a===void 0?(p().clear(),!0):p().dismiss(a):!1,clear:()=>{L()&&p().clear()},configure:a=>{L()&&p().configure(a)}}),C={show:a=>p().show(a),update:(a,t)=>p().update(a,t),dismiss:a=>p().dismiss(a),clear:()=>p().clear(),info:(a,t)=>p().show({message:a,level:"info",...t}),success:(a,t)=>p().show({message:a,level:"success",...t}),error:(a,t)=>p().show({message:a,level:"error",...t}),warning:(a,t)=>p().show({message:a,level:"warning",...t}),loading:(a,t)=>p().show({message:a,level:"loading",...t}),promise:(a,t)=>p().promise(a,t),group:(a,t)=>p().group(a,t),configure:a=>p().configure(a),use:a=>p().use(a),getToasts:()=>p().getToasts(),getGroups:()=>p().getGroups(),getConfig:()=>p().getConfig(),getState:()=>p().getState(),subscribe:a=>p().subscribe(a),onEditorEvent:(a,t)=>p().onEditorEvent(a,t),triggerEditorEvent:(a,t,...e)=>p().triggerEditorEvent(a,t,...e),destroy:()=>{k&&(k.destroy(),k=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const a=window;a.toast=q,a.toastAdvanced=C,a.toastPro=C,a.ToastManager=M,a.__editoraToastReady||(a.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:q,toastAdvanced:C,toastPro:C,ToastManager:M}})))}class Q{constructor(t={}){var e,s,o,r;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(o=t.mass)!=null?o:1,precision:(r=t.precision)!=null?r:.01}}animate(t,e,s,o,r){const i={...this.config,...r};let n,c=!1;const d=Object.keys(e).reduce((f,w)=>(f[w]=e[w].from,f),{}),u=Object.keys(e).reduce((f,w)=>(f[w]=0,f),{}),h=()=>{if(c)return;let f=!0;Object.keys(e).forEach(l=>{const m=e[l].to,T=d[l],g=u[l],y=-i.stiffness*(T-m),b=-i.damping*g,S=(y+b)/i.mass;u[l]+=S*.016,d[l]+=u[l]*.016,(Math.abs(T-m)>i.precision||Math.abs(g)>i.precision)&&(f=!1)});const w=Object.keys(d).reduce((l,m)=>{const T=e[m].unit||"px";return l[m]=`${d[m]}${T}`,l},{});s(w),f?(c=!0,o==null||o()):n=requestAnimationFrame(h)};return n=requestAnimationFrame(h),()=>{c=!0,n&&cancelAnimationFrame(n)}}}class Z{constructor(){this.springAnimation=new Q}async showToast(t,e,s){switch(s.type){case"spring":await this.animateSpringShow(t,s);break;case"bounce":await this.animateBounceShow(t,s);break;case"slide":await this.animateSlideShow(t,s);break;case"zoom":await this.animateZoomShow(t,s);break;case"flip":await this.animateFlipShow(t,s);break;case"fade":await this.animateFadeShow(t,s);break;case"elastic":await this.animateElasticShow(t,s);break;case"rotate":await this.animateRotateShow(t,s);break;case"custom":s.show?await Promise.resolve(s.show(t,e)):await this.animateCssShow(t);break;default:await this.animateCssShow(t);break}}async hideToast(t,e,s){switch(s.type){case"spring":await this.animateSpringHide(t,s);break;case"bounce":await this.animateBounceHide(t,s);break;case"slide":await this.animateSlideHide(t,s);break;case"zoom":await this.animateZoomHide(t,s);break;case"flip":await this.animateFlipHide(t,s);break;case"fade":await this.animateFadeHide(t,s);break;case"elastic":await this.animateElasticHide(t,s);break;case"rotate":await this.animateRotateHide(t,s);break;case"custom":s.hide?await Promise.resolve(s.hide(t,e)):await this.animateCssHide(t);break;default:await this.animateCssHide(t);break}}async updateToast(t,e,s,o){o.type==="custom"&&o.update&&await Promise.resolve(o.update(t,e,s))}animateCssShow(t){return new Promise(e=>{requestAnimationFrame(()=>{t.classList.add("show"),window.setTimeout(e,220)})})}animateCssHide(t){return new Promise(e=>{t.classList.remove("show"),t.classList.add("hiding"),window.setTimeout(e,220)})}async animateSpringShow(t,e){return new Promise(s=>{var i,n,c;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const r=((i=t.parentElement)==null?void 0:i.classList.contains("editora-toast-bottom-right"))||((n=t.parentElement)==null?void 0:n.classList.contains("editora-toast-bottom-left"))||((c=t.parentElement)==null?void 0:c.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${r}px) scale(0.95)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition","opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)","important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},800)},16)})}async animateSpringHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important"),setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform","translateY(-10px) scale(0.95)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateBounceShow(t,e){return new Promise(s=>{var u,h,f;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-right"))||((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-left"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-center")),r=e.direction||(o?"up":"down"),i=e.intensity||"normal",n=e.duration||800,c=i==="gentle"?.05:i==="strong"?.15:.1,d=r==="up"?30:r==="down"?-30:r==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",r==="left"||r==="right"?`translateX(${d}px) scale(${1-c})`:`translateY(${d}px) scale(${1-c})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateBounceHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.intensity||"normal",r=o==="gentle"?.05:o==="strong"?.15:.1;setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1-r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var u,h,f;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-right"))||((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-left"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-center")),r=e.direction||(o?"up":"down"),i=e.distance||100,n=e.easing||"ease-out",c=e.duration||400,d=r==="up"?`translateY(${i}px)`:r==="down"?`translateY(-${i}px)`:r==="left"?`translateX(${i}px)`:`translateX(-${i}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",d,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${c}ms ${n}, transform ${c}ms ${n}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},c)},16)})}async animateSlideHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.direction||"down",r=e.distance||100,i=e.easing||"ease-in",n=e.duration||300,c=o==="up"?`translateY(-${r}px)`:o==="down"?`translateY(${r}px)`:o==="left"?`translateX(-${r}px)`:`translateX(${r}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ${i}, transform ${n}ms ${i}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",c,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateZoomShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.scale||.3,r=e.origin||"center",i=e.easing||"ease-out",n=e.duration||500;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${o})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ${i}, transform ${n}ms ${i}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}async animateZoomHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.scale||.3,r=e.origin||"center",i=e.easing||"ease-in",n=e.duration||300;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ${i}, transform ${n}ms ${i}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}async animateFlipShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.axis||"y",r=e.perspective||1e3,i=e.direction||"forward",n=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const c=i==="forward"?o==="x"?-90:90:o==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${o.toUpperCase()}(${c}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotateX(0deg) rotateY(0deg)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},n)},16)})}async animateFlipHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.axis||"y",r=e.perspective||1e3,i=e.direction||"backward",n=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const c=i==="backward"?o==="x"?-90:90:o==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${o.toUpperCase()}(${c}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},n)},16)})}async animateFadeShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.direction||"none",r=e.distance||20,i=e.duration||300;let n="translateY(0) translateX(0)";o!=="none"&&(n=o==="up"?`translateY(${r}px)`:o==="down"?`translateY(-${r}px)`:o==="left"?`translateX(${r}px)`:`translateX(-${r}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",n,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ease, transform ${i}ms ease`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},i)},16)})}async animateFadeHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.direction||"none",r=e.distance||20,i=e.duration||200;let n="translateY(0) translateX(0)";o!=="none"&&(n=o==="up"?`translateY(-${r}px)`:o==="down"?`translateY(${r}px)`:o==="left"?`translateX(-${r}px)`:`translateX(${r}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ease, transform ${i}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",n,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},i)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var u,h,f;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-right"))||((h=t.parentElement)==null?void 0:h.classList.contains("editora-toast-bottom-left"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-center")),r=e.direction||(o?"up":"down"),i=e.intensity||"normal",n=e.duration||1e3,c=i==="gentle"?.1:i==="strong"?.3:.2,d=r==="up"?40:r==="down"?-40:r==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",r==="left"||r==="right"?`translateX(${d}px) scale(${1+c})`:`translateY(${d}px) scale(${1+c})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateElasticHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.intensity||"normal",r=o==="gentle"?.1:o==="strong"?.3:.2;e.duration,setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1+r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateRotateShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.degrees||360,r=e.direction||"clockwise",i=e.origin||"center",n=e.duration||500,c=r==="clockwise"?o:-o;t.style.setProperty("transform-origin",i,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${c}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotate(0deg) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}async animateRotateHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=e.degrees||180,r=e.direction||"counterclockwise",i=e.origin||"center",n=e.duration||300,c=r==="clockwise"?o:-o;t.style.setProperty("transform-origin",i,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${c}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},n)},16)})}}const Et=new Z,kt=Object.freeze(Object.defineProperty({__proto__:null,AnimationManager:Z,SpringAnimation:Q,animationManager:Et},Symbol.toStringTag,{value:"Module"}));P.ToastManager=M,P.default=q,P.toast=q,P.toastAdvanced=C,P.toastPro=C,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/lite.cjs.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./chunks/toast-1p-XtLiV.cjs.js");exports.ToastManager=t.ToastManager;exports.default=t.toast;exports.toast=t.toast;exports.toastAdvanced=t.toastAdvanced;exports.toastPro=t.toastAdvanced;
|
|
2
|
+
//# sourceMappingURL=lite.cjs.js.map
|
package/dist/lite.d.ts
ADDED
package/dist/lite.esm.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("react"),q=require("react-dom");require("./index.cjs.js");const i=require("./chunks/toast-1p-XtLiV.cjs.js");function $(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=$(_),A=["title","message","description","icon"],f=new Map,w=new Set;let b=0,v=!1,E=0;const p=()=>typeof document!="undefined",m=()=>w.forEach(e=>e());function D(e){f.delete(e)&&m()}function j(){setTimeout(()=>{b>0||v||f.size===0||(v=!0,console.warn("[@editora/toast] A toast has React content, which <Toaster /> renders: mount <Toaster /> once in your app (import { Toaster } from '@editora/toast/react'). Text works without it."))},0)}function O(e,t){const n={...t,id:e};if(!p())return n;let r=!1;for(const o of A){if(!(o in t))continue;const c=t[o],a=f.get(e);if(c==null||typeof c=="boolean"){o==="icon"&&c===!1?n.icon=!1:n[o]=void 0,a!=null&&a.delete(o)&&m();continue}if(typeof c=="string"||typeof c=="number"){n[o]=String(c),a!=null&&a.delete(o)&&m();continue}r=!0;let u=a==null?void 0:a.get(o);if(u)u.node=c;else{const d=document.createElement(o==="icon"?"span":"div");d.style.display="contents",u={host:d,node:c},f.has(e)||f.set(e,new Map),f.get(e).set(o,u)}n[o]=u.host}const s=t.onHide;return n.onHide=()=>{D(e),s==null||s()},r&&(m(),j()),n}function y(e){const t=e.id||`toast-react-${++E}`;return i.toast.show(O(t,e))}function S(e,t){return i.toast.update(e,O(e,t))}const T=e=>typeof e=="number"?{duration:e}:e||{},g=e=>(t,n)=>y({...T(n),message:t,level:e});function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!l.isValidElement(e)&&!(typeof Node!="undefined"&&e instanceof Node)}function h(e,t){return P(e)?{message:void 0,...e,level:e.level||t}:{message:e,level:t}}async function R(e,t){var c,a;const n=typeof e=="function"?e():e,r=h(t.loading,"loading"),s=y({duration:0,...r}),o=u=>p()&&S(s.id,{duration:i.toastAdvanced.getConfig().duration,persistent:!1,...u});try{const u=await n,d=typeof t.success=="function"?t.success(u):t.success;return o(h(d,"success")),(c=t.onSuccess)==null||c.call(t,u),u}catch(u){const d=typeof t.error=="function"?t.error(u):t.error;throw o(h(d,"error")),(a=t.onError)==null||a.call(t,u),u}}function k(e,t={}){const n=t.id||`toast-react-${++E}`,r=typeof e=="function"?e({id:n,dismiss:()=>i.toast.dismiss(n)}):e;if(!p())return i.toast.show({...t,id:n});const s=document.createElement("div");s.style.display="contents",f.set(n,new Map([["custom",{host:s,node:r}]])),m(),j();const o=O(n,{level:"custom",icon:!1,...t});return i.toast.show({...o,render:()=>s})}function C(e,t){const n=T(t);return y({...n,message:e,level:n.level||"custom"})}const M=Object.assign(C,{info:g("info"),success:g("success"),warning:g("warning"),error:g("error"),loading:g("loading"),show:y,custom:k,promise:R,update:S,dismiss:i.toast.dismiss,clear:i.toast.clear,configure:i.toast.configure});function N(e,t){const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>Object.is(e[r],t[r]))}function z(e){const[,t]=l.useState(0),n=l.useRef(null);l.useEffect(()=>{b++;const s=()=>t(o=>o+1);return w.add(s),s(),()=>{b--,w.delete(s)}},[]),l.useEffect(()=>{const s=e;n.current&&N(n.current,s)||(n.current=s,Object.keys(s).length>0&&i.toast.configure(s))});const r=[];return f.forEach((s,o)=>{s.forEach((c,a)=>{r.push(q.createPortal(c.node,c.host,`${o}:${a}`))})}),l.createElement(l.Fragment,null,...r)}exports.Toaster=z;exports.default=M;exports.toast=M;
|
|
2
|
+
//# sourceMappingURL=react.cjs.js.map
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ToastConfig, ToastInstance, ToastOptions } from "./core/types";
|
|
3
|
+
export type ToastNode = React.ReactNode;
|
|
4
|
+
type Field = "title" | "message" | "description" | "icon";
|
|
5
|
+
export interface ReactToastOptions extends Omit<ToastOptions, Field | "render"> {
|
|
6
|
+
title?: ToastNode;
|
|
7
|
+
message?: ToastNode;
|
|
8
|
+
description?: ToastNode;
|
|
9
|
+
icon?: ToastNode | false;
|
|
10
|
+
}
|
|
11
|
+
export interface ReactToastPromiseOptions<T> {
|
|
12
|
+
loading: ToastNode | ReactToastOptions;
|
|
13
|
+
success: ToastNode | ReactToastOptions | ((data: T) => ToastNode | ReactToastOptions);
|
|
14
|
+
error: ToastNode | ReactToastOptions | ((error: any) => ToastNode | ReactToastOptions);
|
|
15
|
+
onSuccess?: (data: T) => void;
|
|
16
|
+
onError?: (error: any) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface CustomToast {
|
|
19
|
+
id: string;
|
|
20
|
+
dismiss: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface ToasterProps extends Partial<Omit<ToastConfig, "container">> {
|
|
23
|
+
}
|
|
24
|
+
declare function show(options: ReactToastOptions): ToastInstance;
|
|
25
|
+
declare function update(id: string, options: Partial<ReactToastOptions>): boolean;
|
|
26
|
+
type Second = Partial<ReactToastOptions> | number | undefined;
|
|
27
|
+
declare function promise<T>(work: Promise<T> | (() => Promise<T>), options: ReactToastPromiseOptions<T>): Promise<T>;
|
|
28
|
+
declare function custom(render: ToastNode | ((toast: CustomToast) => ToastNode), options?: Partial<ReactToastOptions>): ToastInstance;
|
|
29
|
+
declare function toastBase(message: ToastNode, options?: Second): ToastInstance;
|
|
30
|
+
export declare const toast: typeof toastBase & {
|
|
31
|
+
info: (message: ToastNode, options?: Second) => ToastInstance;
|
|
32
|
+
success: (message: ToastNode, options?: Second) => ToastInstance;
|
|
33
|
+
warning: (message: ToastNode, options?: Second) => ToastInstance;
|
|
34
|
+
error: (message: ToastNode, options?: Second) => ToastInstance;
|
|
35
|
+
loading: (message: ToastNode, options?: Second) => ToastInstance;
|
|
36
|
+
show: typeof show;
|
|
37
|
+
custom: typeof custom;
|
|
38
|
+
promise: typeof promise;
|
|
39
|
+
update: typeof update;
|
|
40
|
+
dismiss: (id?: string) => boolean;
|
|
41
|
+
clear: () => void;
|
|
42
|
+
configure: (config: Partial<ToastConfig>) => void;
|
|
43
|
+
};
|
|
44
|
+
export declare function Toaster(props: ToasterProps): React.ReactElement;
|
|
45
|
+
export type { ToastConfig, ToastInstance, ToastLevel, ToastPosition, ToastTheme } from "./core/types";
|
|
46
|
+
export default toast;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import { createPortal as $ } from "react-dom";
|
|
4
|
+
import "./index.esm.js";
|
|
5
|
+
import { t as a, a as A } from "./chunks/toast-CISbzOBc.es.js";
|
|
6
|
+
const M = ["title", "message", "description", "icon"], f = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set();
|
|
7
|
+
let p = 0, b = !1, O = 0;
|
|
8
|
+
const E = () => typeof document != "undefined", g = () => w.forEach((e) => e());
|
|
9
|
+
function C(e) {
|
|
10
|
+
f.delete(e) && g();
|
|
11
|
+
}
|
|
12
|
+
function S() {
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
p > 0 || b || f.size === 0 || (b = !0, console.warn(
|
|
15
|
+
"[@editora/toast] A toast has React content, which <Toaster /> renders: mount <Toaster /> once in your app (import { Toaster } from '@editora/toast/react'). Text works without it."
|
|
16
|
+
));
|
|
17
|
+
}, 0);
|
|
18
|
+
}
|
|
19
|
+
function v(e, t) {
|
|
20
|
+
const n = { ...t, id: e };
|
|
21
|
+
if (!E()) return n;
|
|
22
|
+
let u = !1;
|
|
23
|
+
for (const o of M) {
|
|
24
|
+
if (!(o in t)) continue;
|
|
25
|
+
const r = t[o], i = f.get(e);
|
|
26
|
+
if (r == null || typeof r == "boolean") {
|
|
27
|
+
o === "icon" && r === !1 ? n.icon = !1 : n[o] = void 0, i != null && i.delete(o) && g();
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (typeof r == "string" || typeof r == "number") {
|
|
31
|
+
n[o] = String(r), i != null && i.delete(o) && g();
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
u = !0;
|
|
35
|
+
let c = i == null ? void 0 : i.get(o);
|
|
36
|
+
if (c)
|
|
37
|
+
c.node = r;
|
|
38
|
+
else {
|
|
39
|
+
const d = document.createElement(o === "icon" ? "span" : "div");
|
|
40
|
+
d.style.display = "contents", c = { host: d, node: r }, f.has(e) || f.set(e, /* @__PURE__ */ new Map()), f.get(e).set(o, c);
|
|
41
|
+
}
|
|
42
|
+
n[o] = c.host;
|
|
43
|
+
}
|
|
44
|
+
const s = t.onHide;
|
|
45
|
+
return n.onHide = () => {
|
|
46
|
+
C(e), s == null || s();
|
|
47
|
+
}, u && (g(), S()), n;
|
|
48
|
+
}
|
|
49
|
+
function h(e) {
|
|
50
|
+
const t = e.id || `toast-react-${++O}`;
|
|
51
|
+
return a.show(v(t, e));
|
|
52
|
+
}
|
|
53
|
+
function j(e, t) {
|
|
54
|
+
return a.update(e, v(e, t));
|
|
55
|
+
}
|
|
56
|
+
const T = (e) => typeof e == "number" ? { duration: e } : e || {}, m = (e) => (t, n) => h({ ...T(n), message: t, level: e });
|
|
57
|
+
function R(e) {
|
|
58
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && !l.isValidElement(e) && !(typeof Node != "undefined" && e instanceof Node);
|
|
59
|
+
}
|
|
60
|
+
function y(e, t) {
|
|
61
|
+
return R(e) ? { message: void 0, ...e, level: e.level || t } : { message: e, level: t };
|
|
62
|
+
}
|
|
63
|
+
async function k(e, t) {
|
|
64
|
+
var r, i;
|
|
65
|
+
const n = typeof e == "function" ? e() : e, u = y(t.loading, "loading"), s = h({ duration: 0, ...u }), o = (c) => E() && j(s.id, { duration: A.getConfig().duration, persistent: !1, ...c });
|
|
66
|
+
try {
|
|
67
|
+
const c = await n, d = typeof t.success == "function" ? t.success(c) : t.success;
|
|
68
|
+
return o(y(d, "success")), (r = t.onSuccess) == null || r.call(t, c), c;
|
|
69
|
+
} catch (c) {
|
|
70
|
+
const d = typeof t.error == "function" ? t.error(c) : t.error;
|
|
71
|
+
throw o(y(d, "error")), (i = t.onError) == null || i.call(t, c), c;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function x(e, t = {}) {
|
|
75
|
+
const n = t.id || `toast-react-${++O}`, u = typeof e == "function" ? e({ id: n, dismiss: () => a.dismiss(n) }) : e;
|
|
76
|
+
if (!E()) return a.show({ ...t, id: n });
|
|
77
|
+
const s = document.createElement("div");
|
|
78
|
+
s.style.display = "contents", f.set(n, /* @__PURE__ */ new Map([["custom", { host: s, node: u }]])), g(), S();
|
|
79
|
+
const o = v(n, { level: "custom", icon: !1, ...t });
|
|
80
|
+
return a.show({ ...o, render: () => s });
|
|
81
|
+
}
|
|
82
|
+
function D(e, t) {
|
|
83
|
+
const n = T(t);
|
|
84
|
+
return h({ ...n, message: e, level: n.level || "custom" });
|
|
85
|
+
}
|
|
86
|
+
const z = Object.assign(D, {
|
|
87
|
+
info: m("info"),
|
|
88
|
+
success: m("success"),
|
|
89
|
+
warning: m("warning"),
|
|
90
|
+
error: m("error"),
|
|
91
|
+
loading: m("loading"),
|
|
92
|
+
show: h,
|
|
93
|
+
custom: x,
|
|
94
|
+
promise: k,
|
|
95
|
+
update: j,
|
|
96
|
+
dismiss: a.dismiss,
|
|
97
|
+
clear: a.clear,
|
|
98
|
+
configure: a.configure
|
|
99
|
+
});
|
|
100
|
+
function F(e, t) {
|
|
101
|
+
const n = Object.keys(e);
|
|
102
|
+
return n.length === Object.keys(t).length && n.every((u) => Object.is(e[u], t[u]));
|
|
103
|
+
}
|
|
104
|
+
function B(e) {
|
|
105
|
+
const [, t] = l.useState(0), n = l.useRef(null);
|
|
106
|
+
l.useEffect(() => {
|
|
107
|
+
p++;
|
|
108
|
+
const s = () => t((o) => o + 1);
|
|
109
|
+
return w.add(s), s(), () => {
|
|
110
|
+
p--, w.delete(s);
|
|
111
|
+
};
|
|
112
|
+
}, []), l.useEffect(() => {
|
|
113
|
+
const s = e;
|
|
114
|
+
n.current && F(n.current, s) || (n.current = s, Object.keys(s).length > 0 && a.configure(s));
|
|
115
|
+
});
|
|
116
|
+
const u = [];
|
|
117
|
+
return f.forEach((s, o) => {
|
|
118
|
+
s.forEach((r, i) => {
|
|
119
|
+
u.push($(r.node, r.host, `${o}:${i}`));
|
|
120
|
+
});
|
|
121
|
+
}), l.createElement(l.Fragment, null, ...u);
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
B as Toaster,
|
|
125
|
+
z as default,
|
|
126
|
+
z as toast
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=react.esm.js.map
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/toast",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Toast notifications for any framework, with nothing to mount and no CSS to import: promise toasts, actions, progress, a stack that opens on hover, light and dark, keyboard access, and React content with <Toaster />.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
|
-
"browser": "dist/index.umd.js",
|
|
8
7
|
"unpkg": "dist/index.umd.js",
|
|
9
8
|
"jsdelivr": "dist/index.umd.js",
|
|
10
9
|
"types": "dist/index.d.ts",
|
|
@@ -13,10 +12,22 @@
|
|
|
13
12
|
"types": "./dist/index.d.ts",
|
|
14
13
|
"import": "./dist/index.esm.js",
|
|
15
14
|
"require": "./dist/index.cjs.js",
|
|
16
|
-
"browser": "./dist/index.umd.js",
|
|
17
15
|
"default": "./dist/index.esm.js"
|
|
18
16
|
},
|
|
19
|
-
"./
|
|
17
|
+
"./lite": {
|
|
18
|
+
"types": "./dist/lite.d.ts",
|
|
19
|
+
"import": "./dist/lite.esm.js",
|
|
20
|
+
"require": "./dist/lite.cjs.js",
|
|
21
|
+
"default": "./dist/lite.esm.js"
|
|
22
|
+
},
|
|
23
|
+
"./react": {
|
|
24
|
+
"types": "./dist/react.d.ts",
|
|
25
|
+
"import": "./dist/react.esm.js",
|
|
26
|
+
"require": "./dist/react.cjs.js",
|
|
27
|
+
"default": "./dist/react.esm.js"
|
|
28
|
+
},
|
|
29
|
+
"./toast.css": "./dist/toast.css",
|
|
30
|
+
"./package.json": "./package.json"
|
|
20
31
|
},
|
|
21
32
|
"files": [
|
|
22
33
|
"dist/**/*.js",
|
|
@@ -70,9 +81,24 @@
|
|
|
70
81
|
"test": "vitest run"
|
|
71
82
|
},
|
|
72
83
|
"devDependencies": {
|
|
84
|
+
"@testing-library/react": "^16.3.2",
|
|
85
|
+
"react": "^18.3.1",
|
|
86
|
+
"react-dom": "^18.3.1",
|
|
73
87
|
"typescript": "^5.0.0",
|
|
74
88
|
"vite": "^7.3.1",
|
|
75
89
|
"vitest": "^1.0.0"
|
|
76
90
|
},
|
|
77
|
-
"gitHead": "7883627e823aa99dd5ecb66a5201116df972f88b"
|
|
91
|
+
"gitHead": "7883627e823aa99dd5ecb66a5201116df972f88b",
|
|
92
|
+
"peerDependencies": {
|
|
93
|
+
"react": ">=16.8 <21",
|
|
94
|
+
"react-dom": ">=16.8 <21"
|
|
95
|
+
},
|
|
96
|
+
"peerDependenciesMeta": {
|
|
97
|
+
"react": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"react-dom": {
|
|
101
|
+
"optional": true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
78
104
|
}
|