@editora/toast 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,6 +16,9 @@ A modern, framework-agnostic toast notification library designed for enterprise
16
16
 
17
17
  ## 📸 Screenshots
18
18
 
19
+ ### Animated Toast Demo
20
+ ![Animated Toast Demo](toast-screenshots/toast-demo.gif)
21
+
19
22
  ### Hero Section
20
23
  ![Hero Section](toast-screenshots/hero-section.png)
21
24
 
@@ -29,7 +32,7 @@ A modern, framework-agnostic toast notification library designed for enterprise
29
32
  ![Interactive Actions](toast-screenshots/interactive-actions.png)
30
33
 
31
34
  ### Interactive Feedback Form
32
- ![Interactive Feedback Form](toast-screenshots/nteractive-feedback-form.png)
35
+ ![Interactive Feedback Form](toast-screenshots/interactive-feedback-form.png)
33
36
 
34
37
  ### Progress Scenarios
35
38
  ![Progress Scenarios](toast-screenshots/progress-scenarios.png)
@@ -63,6 +66,8 @@ A modern, framework-agnostic toast notification library designed for enterprise
63
66
  ### Advanced Features (v2.0.0)
64
67
  - 🔄 **Toast Updates** - Modify existing toasts dynamically with smooth transitions
65
68
  - đŸŽ¯ **Toast Grouping** - Group related notifications with stacking and management
69
+ - 🧱 **Stacked Layouts** - Sonner-style collapsed stacks with hover/focus expansion
70
+ - 📝 **Title + Description API** - Modern content hierarchy for concise messages
66
71
  - đŸŽĒ **Custom Animation Hooks** - User-defined animation functions for complete control
67
72
  - 📍 **Multiple Positions** - Support for all screen corners and center positioning
68
73
  - 🎨 **Animation Manager** - Centralized system supporting CSS, spring, and custom animations
@@ -71,8 +76,10 @@ A modern, framework-agnostic toast notification library designed for enterprise
71
76
  - 🔄 **Promise Integration** - Seamless integration with async operations and promises
72
77
  - 📊 **Progress Tracking** - Built-in progress bars with percentage display
73
78
  - đŸŽ¯ **Action Buttons** - Interactive buttons within toasts for user actions
79
+ - â†Šī¸ **Action/Cancel Shortcuts** - First-class `action` and `cancel` options for undo flows
74
80
  - 🎨 **Theme Variants** - Light, dark, system, colored, minimal, glass, neon, retro, ocean, forest, sunset, midnight themes
75
81
  - 🔧 **Global Configuration** - Comprehensive configuration system for all aspects
82
+ - 🧩 **Headless State** - `subscribe()` and `getState()` for custom renderers and framework adapters
76
83
 
77
84
  ### Performance & Architecture
78
85
 
@@ -228,28 +235,35 @@ import "@editora/toast/toast.css";
228
235
  // Global configuration with all available options
229
236
  toast.configure({
230
237
  // Positioning
231
- position: 'top-right', // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'
238
+ position: 'top-right', // 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center'
239
+ offset: 16,
240
+ mobileOffset: 16,
232
241
 
233
242
  // Timing
234
243
  duration: 5000, // Default duration in milliseconds
235
244
  pauseOnHover: true, // Pause timer when hovering
245
+ pauseOnWindowBlur: true, // Pause timers when the tab/window is inactive
236
246
 
237
247
  // Display
238
- maxVisible: 5, // Maximum visible toasts
248
+ maxVisible: 3, // Maximum visible toasts
249
+ visibleToasts: 3, // Sonner-compatible alias
250
+ stack: false, // Set true to collapse visible toasts into a stack
251
+ expand: true, // Keep stacked toasts expanded by default
252
+ richColors: false, // Use semantic colored surfaces
253
+ closeButton: true, // Show close buttons globally
239
254
  theme: 'system', // Theme: 'light' | 'dark' | 'system' | 'colored' | 'minimal' | 'glass' | 'neon' | 'retro' | 'ocean' | 'forest' | 'sunset' | 'midnight' | 'custom'
240
255
 
241
256
  // Accessibility
242
257
  enableAccessibility: true, // Enable screen reader support
243
- enableKeyboardNavigation: true, // Enable keyboard navigation
244
258
 
245
259
  // Interactions
246
260
  swipeDismiss: true, // Enable swipe to dismiss on mobile
247
261
  dragDismiss: false, // Enable drag to dismiss
248
- clickToDismiss: true, // Click anywhere to dismiss
249
262
 
250
263
  // Queue Management
251
- queueStrategy: 'priority', // 'fifo' | 'priority' | 'stack'
252
- maxQueueSize: 10, // Maximum queued toasts
264
+ queueStrategy: 'fifo', // 'fifo' | 'lifo'
265
+ preventDuplicate: true,
266
+ dedupeScope: 'all', // 'visible' | 'queue' | 'all'
253
267
 
254
268
  // Animations
255
269
  animation: {
@@ -263,10 +277,7 @@ toast.configure({
263
277
  },
264
278
 
265
279
  // Advanced
266
- enableHtml: false, // Allow HTML in messages (use with caution)
267
- sanitizeHtml: true, // Sanitize HTML content
268
- zIndex: 9999, // Base z-index for toasts
269
- containerClass: 'custom-container' // Custom container class
280
+ zIndex: 9999 // Base z-index for toasts
270
281
  });
271
282
  ```
272
283
 
@@ -513,7 +524,7 @@ toast.group('validation-errors', {
513
524
  ```
514
525
 
515
526
  ### Interactive Feedback Forms
516
- ![Interactive Feedback Form](toast-screenshots/nteractive-feedback-form.png)
527
+ ![Interactive Feedback Form](toast-screenshots/interactive-feedback-form.png)
517
528
 
518
529
  Create interactive forms within toasts:
519
530
 
@@ -722,6 +733,8 @@ toast.triggerEditorEvent('media-upload-progress', { progress: 50 });
722
733
  - `toast.group(id, options)` - Group related toasts with stacking behavior
723
734
  - `toast.configure(config)` - Update global configuration
724
735
  - `toast.use(plugin)` - Install a plugin
736
+ - `toast.getState()` - Read visible, queued, grouped, and configured toast state
737
+ - `toast.subscribe(listener)` - Subscribe to state changes for headless/custom renderers
725
738
  - `toast.onEditorEvent(event, handler)` - Listen for editor integration events
726
739
  - `toast.triggerEditorEvent(event, data)` - Trigger editor integration events
727
740
 
@@ -730,22 +743,27 @@ toast.triggerEditorEvent('media-upload-progress', { progress: 50 });
730
743
  ```typescript
731
744
  interface ToastOptions {
732
745
  // Content
733
- message: string;
746
+ message?: string;
747
+ title?: string;
748
+ description?: string;
734
749
  level?: 'info' | 'success' | 'error' | 'warning' | 'loading' | 'progress' | 'promise' | 'custom';
735
750
  icon?: string;
736
751
  html?: boolean;
737
- render?: () => HTMLElement;
752
+ render?: (toast: ToastInstance) => HTMLElement;
738
753
 
739
754
  // Behavior
740
755
  duration?: number;
741
756
  pauseOnHover?: boolean;
742
- clickToDismiss?: boolean;
757
+ persistent?: boolean;
758
+ closeButton?: boolean;
743
759
 
744
760
  // Positioning
745
- position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
761
+ position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center';
746
762
 
747
763
  // Interactions
748
764
  actions?: ToastAction[];
765
+ action?: ToastAction;
766
+ cancel?: ToastAction;
749
767
  swipeDismiss?: boolean;
750
768
  dragDismiss?: boolean;
751
769
 
@@ -754,30 +772,33 @@ interface ToastOptions {
754
772
 
755
773
  // Styling
756
774
  theme?: string;
757
- className?: string;
775
+ customClass?: string;
758
776
 
759
777
  // Advanced
760
- groupId?: string;
778
+ group?: string;
761
779
  priority?: number;
780
+ important?: boolean;
781
+ preventDuplicate?: boolean;
782
+ dedupeKey?: string;
783
+ dedupeScope?: 'visible' | 'queue' | 'all';
784
+ ariaLive?: 'polite' | 'assertive' | 'off';
762
785
  animation?: ToastAnimation;
763
- onShow?: (toast: Toast) => void;
764
- onHide?: (toast: Toast) => void;
765
- onUpdate?: (toast: Toast, updates: Partial<ToastOptions>) => void;
786
+ onShow?: () => void;
787
+ onHide?: () => void;
788
+ onUpdate?: (updates: Partial<ToastOptions>) => void;
766
789
  }
767
790
 
768
791
  interface ToastAction {
769
792
  label: string;
770
- onClick: (toast: Toast) => void;
771
- variant?: 'primary' | 'secondary' | 'ghost';
793
+ onClick: () => void;
772
794
  primary?: boolean;
795
+ dismissOnClick?: boolean;
796
+ altText?: string;
773
797
  }
774
798
 
775
799
  interface ToastProgress {
776
800
  value: number; // 0-100
777
801
  showPercentage?: boolean;
778
- indeterminate?: boolean;
779
- color?: string;
780
- size?: 'sm' | 'md' | 'lg';
781
802
  }
782
803
 
783
804
  interface ToastAnimation {
@@ -801,11 +822,10 @@ cd Editora/packages/editora-toast
801
822
  # Install dependencies
802
823
  npm install
803
824
 
804
- # Start the demo server
805
- npm run demo
806
- # or
807
- python3 -m http.server 8086
808
- # Then open: http://localhost:8086/examples/web/toast-demo.html
825
+ # Start the standalone CodeSandbox-ready example
826
+ cd ../../examples/editora-toast
827
+ npm install
828
+ npm run dev
809
829
  ```
810
830
 
811
831
  The demo showcases:
@@ -1,4 +1,4 @@
1
- import { ToastInstance, ToastOptions, ToastConfig, ToastManager as IToastManager, ToastPromiseOptions, ToastPlugin } from './types';
1
+ import { ToastInstance, ToastOptions, ToastConfig, ToastManager as IToastManager, ToastPromiseOptions, ToastPlugin, ToastState, ToastSubscriber } from './types';
2
2
  export declare class ToastManager implements IToastManager {
3
3
  private store;
4
4
  private queue;
@@ -7,6 +7,7 @@ export declare class ToastManager implements IToastManager {
7
7
  private config;
8
8
  private idCounter;
9
9
  private pausedToasts;
10
+ private subscribers;
10
11
  private windowFocusHandler?;
11
12
  private windowBlurHandler?;
12
13
  private visibilityChangeHandler?;
@@ -21,6 +22,8 @@ export declare class ToastManager implements IToastManager {
21
22
  configure(config: Partial<ToastConfig>): void;
22
23
  getConfig(): ToastConfig;
23
24
  getToasts(): ToastInstance[];
25
+ getState(): ToastState;
26
+ subscribe(listener: ToastSubscriber): () => void;
24
27
  getGroups(): import("./types").ToastGroup[];
25
28
  info(message: string, duration?: number): ToastInstance;
26
29
  success(message: string, duration?: number): ToastInstance;
@@ -28,6 +31,12 @@ export declare class ToastManager implements IToastManager {
28
31
  warning(message: string, duration?: number): ToastInstance;
29
32
  loading(message: string, duration?: number): ToastInstance;
30
33
  private normalizeOptions;
34
+ private normalizeConfig;
35
+ private normalizeToastOptions;
36
+ private showToasts;
37
+ private hideToasts;
38
+ private hideOne;
39
+ private notify;
31
40
  onEditorEvent(event: string, callback: (toast: ToastInstance, ...args: any[]) => void): void;
32
41
  triggerEditorEvent(event: string, toast: ToastInstance, ...args: any[]): void;
33
42
  private setupWindowFocusHandling;
@@ -1,19 +1,28 @@
1
1
  import { ToastInstance, ToastConfig } from './types';
2
+ export interface ToastQueueChanges {
3
+ show: ToastInstance[];
4
+ hide: ToastInstance[];
5
+ rejected?: ToastInstance;
6
+ }
2
7
  export declare class ToastQueue {
3
8
  private queue;
4
9
  private visible;
5
10
  private config;
6
11
  constructor(config: ToastConfig);
7
- enqueue(toast: ToastInstance): void;
8
- dequeue(id: string): boolean;
9
- private processQueue;
10
- private showToast;
11
- private hideToast;
12
- private deduplicate;
13
- updateConfig(config: Partial<ToastConfig>): void;
12
+ enqueue(toast: ToastInstance): ToastQueueChanges;
13
+ dequeue(id: string): ToastQueueChanges;
14
+ updateConfig(config: Partial<ToastConfig>): ToastQueueChanges;
14
15
  getQueued(): ToastInstance[];
15
16
  getVisible(): ToastInstance[];
16
17
  getAll(): ToastInstance[];
17
- clear(): void;
18
- forceShow(toast: ToastInstance): void;
18
+ isVisible(id: string): boolean;
19
+ clear(): ToastInstance[];
20
+ private processQueue;
21
+ private removeLowestPriorityVisible;
22
+ private removeFromCollections;
23
+ private findDuplicate;
24
+ private getDedupeKey;
25
+ private sortQueue;
26
+ private get maxVisible();
27
+ private normalizeConfig;
19
28
  }
@@ -4,11 +4,17 @@ export declare class ToastRenderer {
4
4
  private config;
5
5
  private cssInjected;
6
6
  constructor(config: ToastConfig);
7
+ updateConfig(config: ToastConfig): void;
7
8
  ensureContainer(position: ToastPosition): HTMLElement;
8
9
  createToastElement(toast: ToastInstance): HTMLElement;
9
10
  showToast(toast: ToastInstance): Promise<void>;
10
11
  hideToast(toast: ToastInstance): Promise<void>;
11
12
  updateToast(toast: ToastInstance, updates: Partial<ToastInstance['options']>): Promise<void>;
13
+ private createContent;
14
+ private createActionButton;
15
+ private applyContainerStyles;
16
+ private applyStackState;
17
+ private toCssLength;
12
18
  private pauseToast;
13
19
  private resumeToast;
14
20
  private addSwipeDismiss;
@@ -73,18 +73,24 @@ export interface ToastAction {
73
73
  label: string;
74
74
  onClick: () => void;
75
75
  primary?: boolean;
76
+ dismissOnClick?: boolean;
77
+ altText?: string;
76
78
  }
77
79
  export interface ToastProgress {
78
80
  value: number;
79
81
  showPercentage?: boolean;
80
82
  }
81
83
  export interface ToastContent {
82
- message: string;
84
+ message?: string;
85
+ title?: string;
86
+ description?: string;
83
87
  icon?: string;
84
88
  actions?: ToastAction[];
89
+ action?: ToastAction;
90
+ cancel?: ToastAction;
85
91
  progress?: ToastProgress;
86
92
  html?: boolean;
87
- render?: () => HTMLElement;
93
+ render?: (toast: ToastInstance) => HTMLElement;
88
94
  }
89
95
  export interface ToastOptions extends Partial<ToastContent> {
90
96
  id?: string;
@@ -95,6 +101,7 @@ export interface ToastOptions extends Partial<ToastContent> {
95
101
  group?: string;
96
102
  persistent?: boolean;
97
103
  closable?: boolean;
104
+ closeButton?: boolean;
98
105
  pauseOnHover?: boolean;
99
106
  pauseOnFocus?: boolean;
100
107
  swipeDismiss?: boolean;
@@ -103,6 +110,12 @@ export interface ToastOptions extends Partial<ToastContent> {
103
110
  rtl?: boolean;
104
111
  theme?: ToastTheme;
105
112
  customClass?: string;
113
+ important?: boolean;
114
+ preventDuplicate?: boolean;
115
+ dedupeKey?: string;
116
+ dedupeScope?: 'visible' | 'queue' | 'all';
117
+ ariaLive?: 'polite' | 'assertive' | 'off';
118
+ role?: 'status' | 'alert';
106
119
  animation?: AnimationConfig;
107
120
  onShow?: () => void;
108
121
  onHide?: () => void;
@@ -134,8 +147,15 @@ export interface ToastConfig {
134
147
  position: ToastPosition;
135
148
  duration: number;
136
149
  maxVisible: number;
150
+ visibleToasts?: number;
137
151
  queueStrategy: QueueStrategy;
138
152
  theme: ToastTheme;
153
+ richColors: boolean;
154
+ expand: boolean;
155
+ stack: boolean;
156
+ offset: number | string;
157
+ mobileOffset: number | string;
158
+ gap: number;
139
159
  pauseOnHover: boolean;
140
160
  pauseOnFocus: boolean;
141
161
  pauseOnWindowBlur: boolean;
@@ -144,10 +164,21 @@ export interface ToastConfig {
144
164
  dragDismiss: boolean;
145
165
  rtl: boolean;
146
166
  enableAccessibility: boolean;
167
+ closeButton: boolean;
168
+ preventDuplicate: boolean;
169
+ dedupeScope: 'visible' | 'queue' | 'all';
147
170
  container?: HTMLElement;
148
171
  zIndex?: number;
149
172
  animation?: AnimationConfig;
150
173
  }
174
+ export interface ToastState {
175
+ toasts: ToastInstance[];
176
+ visible: ToastInstance[];
177
+ queued: ToastInstance[];
178
+ groups: ToastGroup[];
179
+ config: ToastConfig;
180
+ }
181
+ export type ToastSubscriber = (state: ToastState) => void;
151
182
  export interface ToastPlugin {
152
183
  name: string;
153
184
  install: (manager: ToastManager) => void;
@@ -164,5 +195,7 @@ export interface ToastManager {
164
195
  use(plugin: ToastPlugin): void;
165
196
  getConfig(): ToastConfig;
166
197
  getToasts(): ToastInstance[];
198
+ getState(): ToastState;
199
+ subscribe(listener: ToastSubscriber): () => void;
167
200
  getGroups(): ToastGroup[];
168
201
  }
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class k{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 M{constructor(t){this.queue=[],this.visible=[],this.config=t}enqueue(t){this.deduplicate(t),this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.queue.sort((e,s)=>(s.options.priority||0)-(e.options.priority||0)),this.processQueue()}dequeue(t){let e=!1;const s=this.queue.findIndex(r=>r.id===t);s!==-1&&(this.queue.splice(s,1),e=!0);const i=this.visible.findIndex(r=>r.id===t);return i!==-1&&(this.visible.splice(i,1),e=!0),e&&this.processQueue(),e}processQueue(){const t=this.config.maxVisible;for(;this.visible.length>t;){const e=this.visible.pop();this.hideToast(e)}for(;this.visible.length<t&&this.queue.length>0;){const e=this.queue.shift();this.showToast(e)}}showToast(t){this.visible.push(t)}hideToast(t){}deduplicate(t){this.queue.filter(s=>s.options.message===t.options.message&&s.options.level===t.options.level).forEach(s=>{const i=this.queue.indexOf(s);i!==-1&&this.queue.splice(i,1)})}updateConfig(t){this.config={...this.config,...t},this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}clear(){const t=[...this.visible,...this.queue];this.queue=[],this.visible=[],t.forEach(e=>{e.element&&this.hideToast(e)})}forceShow(t){if(this.visible.length>=this.config.maxVisible){const e=this.visible.reduce((s,i)=>(i.options.priority||0)<(s.options.priority||0)?i:s);this.dequeue(e.id)}this.showToast(t)}}class A{constructor(t={}){var e,s,i,r;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(r=t.precision)!=null?r:.01}}animate(t,e,s,i,r){const n={...this.config,...r};let o,a=!1;const l=Object.keys(e).reduce((u,d)=>(u[d]=e[d].from,u),{}),p=Object.keys(e).reduce((u,d)=>(u[d]=0,u),{}),y=()=>{if(a)return;let u=!0;Object.keys(e).forEach(g=>{const b=e[g].to,m=l[g],w=p[g],f=-n.stiffness*(m-b),v=-n.damping*w,C=(f+v)/n.mass;p[g]+=C*.016,l[g]+=p[g]*.016,(Math.abs(m-b)>n.precision||Math.abs(w)>n.precision)&&(u=!1)});const d=Object.keys(l).reduce((g,b)=>{const m=e[b].unit||"px";return g[b]=`${l[b]}${m}`,g},{});s(d),u?(a=!0,i==null||i()):o=requestAnimationFrame(y)};return o=requestAnimationFrame(y),()=>{a=!0,o&&cancelAnimationFrame(o)}}}class q{constructor(){this.springAnimation=new A}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)):this.animateCssShow(t);break;case"css":default: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)):this.animateCssHide(t);break;case"css":default: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){requestAnimationFrame(()=>{t.classList.add("show")})}animateCssHide(t){t.classList.remove("show"),t.classList.add("hiding")}async animateSpringShow(t,e){return new Promise(s=>{var n,o,a;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const r=((n=t.parentElement)==null?void 0:n.classList.contains("editora-toast-bottom-right"))||((o=t.parentElement)==null?void 0:o.classList.contains("editora-toast-bottom-left"))||((a=t.parentElement)==null?void 0:a.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 p,y,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.intensity||"normal",o=e.duration||800,a=n==="gentle"?.05:n==="strong"?.15:.1,l=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(${l}px) scale(${1-a})`:`translateY(${l}px) scale(${1-a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${o}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()},o)},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",r=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-r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var p,y,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.distance||100,o=e.easing||"ease-out",a=e.duration||400,l=r==="up"?`translateY(${n}px)`:r==="down"?`translateY(-${n}px)`:r==="left"?`translateX(${n}px)`:`translateX(-${n}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",l,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${o}, transform ${a}ms ${o}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},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",r=e.distance||100,n=e.easing||"ease-in",o=e.duration||300,a=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},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,r=e.origin||"center",n=e.easing||"ease-out",o=e.duration||500;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"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()},o)},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,r=e.origin||"center",n=e.easing||"ease-in",o=e.duration||300;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"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()},o)},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",r=e.perspective||1e3,n=e.direction||"forward",o=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const a=n==="forward"?i==="x"?-90:90:i==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}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()},o)},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",r=e.perspective||1e3,n=e.direction||"backward",o=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const a=n==="backward"?i==="x"?-90:90:i==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},o)},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",r=e.distance||20,n=e.duration||300;let o="translateY(0) translateX(0)";i!=="none"&&(o=i==="up"?`translateY(${r}px)`:i==="down"?`translateY(-${r}px)`:i==="left"?`translateX(${r}px)`:`translateX(-${r}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}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()},n)},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",r=e.distance||20,n=e.duration||200;let o="translateY(0) translateX(0)";i!=="none"&&(o=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var p,y,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.intensity||"normal",o=e.duration||1e3,a=n==="gentle"?.1:n==="strong"?.3:.2,l=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(${l}px) scale(${1+a})`:`translateY(${l}px) scale(${1+a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${o}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()},o)},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",r=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+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 i=e.degrees||360,r=e.direction||"clockwise",n=e.origin||"center",o=e.duration||500,a=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",n,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}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()},o)},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,r=e.direction||"counterclockwise",n=e.origin||"center",o=e.duration||300,a=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",n,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}}const L=new q;class Y{constructor(t){this.containers=new Map,this.cssInjected=!1,this.config=t}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite");const s={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none",maxWidth:"100%",boxSizing:"border-box"};switch(t){case"top-left":s.top="16px",s.left="16px";break;case"top-right":s.top="16px",s.right="16px";break;case"bottom-left":s.bottom="16px",s.left="16px";break;case"bottom-right":s.bottom="16px",s.right="16px";break;case"center":s.top="50%",s.left="50%",s.transform="translate(-50%, -50%)",s.alignItems="center";break}return Object.assign(e.style,s),document.body.appendChild(e),this.containers.set(t,e),this.injectCSS(),e}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,e.customClass&&s.classList.add(e.customClass),s.setAttribute("role","alert"),s.setAttribute("aria-atomic","true");const i=e.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const n=document.createElement("div");if(n.className="editora-toast-content",e.icon){const a=document.createElement("span");a.className="editora-toast-icon",a.textContent=e.icon,n.appendChild(a)}const o=document.createElement("span");if(o.className="editora-toast-message",e.html&&e.message)o.innerHTML=this.sanitizeHTML(e.message);else if(e.render){const a=e.render();o.appendChild(a)}else o.textContent=e.message||"";if(n.appendChild(o),e.progress){const a=document.createElement("div");a.className="editora-toast-progress";const l=document.createElement("div");if(l.className="editora-toast-progress-bar",l.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`,e.progress.showPercentage){const p=document.createElement("span");p.className="editora-toast-progress-text",p.textContent=`${Math.round(e.progress.value)}%`,a.appendChild(p)}a.appendChild(l),n.appendChild(a)}if(s.appendChild(n),e.actions&&e.actions.length>0){const a=document.createElement("div");a.className="editora-toast-actions",e.actions.forEach(l=>{const p=document.createElement("button");p.className=`editora-toast-action ${l.primary?"primary":""}`,p.textContent=l.label,p.onclick=y=>{y.stopPropagation(),l.onClick()},a.appendChild(p)}),s.appendChild(a)}if(e.closable!==!1){const a=document.createElement("button");a.className="editora-toast-close",a.setAttribute("aria-label","Close notification"),a.innerHTML="×",a.onclick=()=>t.dismiss(),s.appendChild(a)}return e.pauseOnHover&&(s.addEventListener("mouseenter",()=>this.pauseToast(t)),s.addEventListener("mouseleave",()=>this.resumeToast(t))),e.pauseOnFocus&&(s.addEventListener("focusin",()=>this.pauseToast(t)),s.addEventListener("focusout",()=>this.resumeToast(t))),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var r,n;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s);const i=t.options.animation||this.config.animation||{type:"css"};if(await L.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(n=(r=t.options).onShow)==null||n.call(r),!t.options.persistent&&t.options.duration!==0){const o=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{this.hideToast(t)},o)}}async hideToast(t){var s,i;if(!t.element)return;t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0);const e=t.options.animation||this.config.animation||{type:"css"};await L.hideToast(t.element,t,e),t.element&&t.element.parentNode&&(t.element.parentNode.removeChild(t.element),t.element=void 0),(i=(s=t.options).onHide)==null||i.call(s)}async updateToast(t,e){var r,n;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await L.updateToast(t.element,t,e,s);return}Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast--(info|success|error|warning|loading|custom)/g,""),t.element.classList.add(`editora-toast--${e.level}`));const i=t.element.querySelector(".editora-toast-message");if(i&&e.message!==void 0)if(t.options.html&&e.message)i.innerHTML=this.sanitizeHTML(e.message);else if(t.options.render){const o=t.element.querySelector(".editora-toast-content");if(o){const a=t.options.render();o.innerHTML="",o.appendChild(a)}}else i.textContent=e.message||"";if(e.progress!==void 0){let o=t.element.querySelector(".editora-toast-progress");if(e.progress){if(!o){o=document.createElement("div"),o.className="editora-toast-progress";const l=t.element.querySelector(".editora-toast-content");l&&l.appendChild(o)}const a=o.querySelector(".editora-toast-progress-bar");if(a&&(a.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`),e.progress.showPercentage){let l=o.querySelector(".editora-toast-progress-text");l||(l=document.createElement("span"),l.className="editora-toast-progress-text",o.insertBefore(l,o.firstChild)),l.textContent=`${Math.round(e.progress.value)}%`}else{const l=o.querySelector(".editora-toast-progress-text");l&&l.remove()}}else o&&o.remove()}if(e.actions!==void 0){let o=t.element.querySelector(".editora-toast-actions");e.actions&&e.actions.length>0?(o?o.innerHTML="":(o=document.createElement("div"),o.className="editora-toast-actions",t.element.appendChild(o)),o&&e.actions.forEach(a=>{const l=document.createElement("button");l.className=`editora-toast-action ${a.primary?"primary":""}`,l.textContent=a.label,l.onclick=p=>{p.stopPropagation(),a.onClick()},o.appendChild(l)})):o&&o.remove()}(n=(r=t.options).onUpdate)==null||n.call(r,e)}pauseToast(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}resumeToast(t){if(!t.options.persistent&&t.options.duration!==0){const e=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{this.hideToast(t)},e)}}addSwipeDismiss(t,e){let s=0,i=0,r=!1;const n=e.options.swipeDirection||this.config.swipeDirection||"any",o=40;let a="",l=!1;const p=d=>{r=!0,l=!1,s="touches"in d?d.touches[0].clientX:d.clientX,i="touches"in d?d.touches[0].clientY:d.clientY,a=t.style.transform||"",t.style.transition="none",t.style.cursor="grabbing",d.preventDefault()},y=d=>{if(!r)return;const g="touches"in d?d.touches[0].clientX:d.clientX,b="touches"in d?d.touches[0].clientY:d.clientY,m=g-s,w=b-i,f=5;if((Math.abs(m)>f||Math.abs(w)>f)&&(l=!0),l){const v=Math.abs(w)>Math.abs(m)?25:20,P=Math.min(Math.max(m*.2,-v),v),C=Math.min(Math.max(w*.2,-v),v);t.style.transform=`${a} translate(${P}px, ${C}px)`}(Math.abs(w)>Math.abs(m)||n==="vertical"||n==="up"||n==="down")&&d.preventDefault()},u=d=>{if(!r)return;if(t.style.transform=a,t.style.transition="",t.style.cursor="",!l){r=!1;return}const g="changedTouches"in d?d.changedTouches[0].clientX:d.clientX,b="changedTouches"in d?d.changedTouches[0].clientY:d.clientY,m=g-s,w=b-i;let f=!1;const v=n==="vertical"||n==="up"||n==="down",P=v?35:o;switch(n){case"any":f=Math.abs(m)>o||Math.abs(w)>o;break;case"horizontal":f=Math.abs(m)>o;break;case"vertical":f=Math.abs(w)>P;break;case"left":f=m<-o;break;case"right":f=m>o;break;case"up":f=w<-P;break;case"down":f=w>P;break}v&&console.log(`Vertical swipe attempt: direction=${n}, deltaY=${w}, effectiveMinDistance=${P}, shouldDismiss=${f}`),f&&e.dismiss(),r=!1};t.addEventListener("dragstart",d=>d.preventDefault()),t.addEventListener("touchstart",p,{passive:!1}),t.addEventListener("touchmove",y,{passive:!1}),t.addEventListener("touchend",u,{passive:!1}),t.addEventListener("mousedown",p),t.addEventListener("mousemove",y),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",u)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){const e=document.createElement("div");e.setAttribute("aria-live","assertive"),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",e.textContent=`${t.options.level||"info"}: ${t.options.message}`,document.body.appendChild(e),setTimeout(()=>{document.body.removeChild(e)},1e3)}sanitizeHTML(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!Array.from(document.styleSheets).find(e=>{var s,i,r,n;return((i=(s=e.ownerNode)==null?void 0:s.href)==null?void 0:i.includes("toast.css"))||((n=(r=e.ownerNode)==null?void 0:r.textContent)==null?void 0:n.includes("editora-toast"))})){const e=document.createElement("link");e.rel="stylesheet",e.href="/packages/editora-toast/dist/toast.css",document.head.appendChild(e)}this.cssInjected=!0}destroy(){this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class F{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 r of i)try{await r(e,...s)}catch(n){console.error(`Error in ${t} hook:`,n)}}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 r=await t;return s(r),r}catch(r){throw i(r),r}}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 I={position:"bottom-right",duration:4e3,maxVisible:5,queueStrategy:"fifo",theme:"system",pauseOnHover:!0,pauseOnFocus:!1,pauseOnWindowBlur:!1,swipeDismiss:!1,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,animation:{type:"css"}};class S{constructor(t={}){this.idCounter=0,this.pausedToasts=new Set,this.config={...I,...t},this.store=new k(this.config),this.queue=new M(this.config),this.renderer=new Y(this.config),this.lifecycle=new F,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:{...this.config,...t},createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:i=>this.update(e,i)};return this.lifecycle.beforeShow(s).then(async()=>{this.store.addToast(s),this.queue.enqueue(s),await this.renderer.showToast(s),this.lifecycle.afterShow(s)}),s}update(t,e){const s=this.store.getToast(t);return s?(this.lifecycle.beforeUpdate(s,e).then(async()=>{this.store.updateToast(t,{options:{...s.options,...e}}),await this.renderer.updateToast(s,e),this.lifecycle.afterUpdate(s,e)}),!0):!1}dismiss(t){const e=this.store.getToast(t);return e?(this.lifecycle.beforeHide(e).then(async()=>{this.queue.dequeue(t),await this.renderer.hideToast(e),this.store.removeToast(t),this.lifecycle.afterHide(e)}),!0):!1}clear(){const t=this.store.getAllToasts();this.lifecycle.batchHide(t).then(()=>{this.queue.clear(),this.store.clear()})}async promise(t,e){var i,r;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const n=await t,o=this.normalizeOptions(typeof e.success=="function"?e.success(n):e.success,"success");return this.update(s.id,o),(i=e.onSuccess)==null||i.call(e,n),n}catch(n){const o=this.normalizeOptions(typeof e.error=="function"?e.error(n):e.error,"error");throw this.update(s.id,o),(r=e.onError)==null||r.call(e,n),n}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur;this.config={...this.config,...t},this.store.updateConfig(t),this.queue.updateConfig(t),t.pauseOnWindowBlur!==void 0&&t.pauseOnWindowBlur!==e&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}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}}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(e=>{e.timeoutId&&!this.pausedToasts.has(e.id)&&(clearTimeout(e.timeoutId),e.timeoutId=void 0,this.pausedToasts.add(e.id))})}resumeAllToasts(){this.store.getAllToasts().forEach(e=>{if(this.pausedToasts.has(e.id)&&!e.options.persistent&&e.options.duration!==0){const s=e.options.duration||this.config.duration;e.timeoutId=window.setTimeout(()=>{this.dismiss(e.id)},s),this.pausedToasts.delete(e.id)}})}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let E=null;function h(){return E||(E=new S),E}function $(c){return typeof document=="undefined"?{dismiss:()=>{}}:h().show(c)}function x(c,t,e,s){const i={position:"top-right",theme:"light"};let r={};return t&&typeof t=="object"?r={...t}:typeof t=="number"&&(r.duration=t),e&&(r.theme=e),s&&(r.position=s),{message:c,...r,duration:r.duration,level:r.level||void 0,position:r.position||i.position,theme:r.theme||i.theme}}const H={info:(c,t,e,s)=>$({...x(c,t,e,s),level:"info"}),success:(c,t,e,s)=>$({...x(c,t,e,s),level:"success"}),error:(c,t,e,s)=>$({...x(c,t,e,s),level:"error"}),warning:(c,t,e,s)=>$({...x(c,t,e,s),level:"warning"}),loading:(c,t,e,s)=>$({...x(c,t,e,s),level:"loading"})},T={show:c=>h().show(c),update:(c,t)=>h().update(c,t),dismiss:c=>h().dismiss(c),clear:()=>h().clear(),info:(c,t)=>h().show({message:c,level:"info",...t}),success:(c,t)=>h().show({message:c,level:"success",...t}),error:(c,t)=>h().show({message:c,level:"error",...t}),warning:(c,t)=>h().show({message:c,level:"warning",...t}),loading:(c,t)=>h().show({message:c,level:"loading",...t}),promise:(c,t)=>h().promise(c,t),group:(c,t)=>h().group(c,t),configure:c=>h().configure(c),use:c=>h().use(c),getToasts:()=>h().getToasts(),getGroups:()=>h().getGroups(),getConfig:()=>h().getConfig(),onEditorEvent:(c,t)=>h().onEditorEvent(c,t),triggerEditorEvent:(c,t,...e)=>h().triggerEditorEvent(c,t,...e),destroy:()=>{E&&(E.destroy(),E=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const c=window;c.toast=H,c.toastAdvanced=T,c.toastPro=T,c.ToastManager=S,c.__editoraToastReady||(c.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:H,toastAdvanced:T,toastPro:T,ToastManager:S}})))}exports.ToastManager=S;exports.default=H;exports.toast=H;exports.toastAdvanced=T;exports.toastPro=T;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class A{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 M{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 o=this.removeLowestPriorityVisible();return this.visible.push(t),{show:[t],hide:o?[...s,o]: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(r=>this.getDedupeKey(r)===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}}}class q{constructor(t={}){var e,s,i,r;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(r=t.precision)!=null?r:.01}}animate(t,e,s,i,r){const o={...this.config,...r};let a,c=!1;const d=Object.keys(e).reduce((p,l)=>(p[l]=e[l].from,p),{}),h=Object.keys(e).reduce((p,l)=>(p[l]=0,p),{}),f=()=>{if(c)return;let p=!0;Object.keys(e).forEach(y=>{const b=e[y].to,m=d[y],w=h[y],g=-o.stiffness*(m-b),v=-o.damping*w,k=(g+v)/o.mass;h[y]+=k*.016,d[y]+=h[y]*.016,(Math.abs(m-b)>o.precision||Math.abs(w)>o.precision)&&(p=!1)});const l=Object.keys(d).reduce((y,b)=>{const m=e[b].unit||"px";return y[b]=`${d[b]}${m}`,y},{});s(l),p?(c=!0,i==null||i()):a=requestAnimationFrame(f)};return a=requestAnimationFrame(f),()=>{c=!0,a&&cancelAnimationFrame(a)}}}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;case"css":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;case"css":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 o,a,c;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const r=((o=t.parentElement)==null?void 0:o.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(${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 h,f,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"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),o=e.intensity||"normal",a=e.duration||800,c=o==="gentle"?.05:o==="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 ${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",r=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-r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var h,f,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"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),o=e.distance||100,a=e.easing||"ease-out",c=e.duration||400,d=r==="up"?`translateY(${o}px)`:r==="down"?`translateY(-${o}px)`:r==="left"?`translateX(${o}px)`:`translateX(-${o}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",d,"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",r=e.distance||100,o=e.easing||"ease-in",a=e.duration||300,c=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${o}, transform ${a}ms ${o}`,"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,r=e.origin||"center",o=e.easing||"ease-out",a=e.duration||500;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${o}, transform ${a}ms ${o}`,"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,r=e.origin||"center",o=e.easing||"ease-in",a=e.duration||300;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${o}, transform ${a}ms ${o}`,"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",r=e.perspective||1e3,o=e.direction||"forward",a=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const c=o==="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",r=e.perspective||1e3,o=e.direction||"backward",a=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const c=o==="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",r=e.distance||20,o=e.duration||300;let a="translateY(0) translateX(0)";i!=="none"&&(a=i==="up"?`translateY(${r}px)`:i==="down"?`translateY(-${r}px)`:i==="left"?`translateX(${r}px)`:`translateX(-${r}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}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()},o)},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",r=e.distance||20,o=e.duration||200;let a="translateY(0) translateX(0)";i!=="none"&&(a=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var h,f,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"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),o=e.intensity||"normal",a=e.duration||1e3,c=o==="gentle"?.1:o==="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 ${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",r=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+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 i=e.degrees||360,r=e.direction||"clockwise",o=e.origin||"center",a=e.duration||500,c=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",o,"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,r=e.direction||"counterclockwise",o=e.origin||"center",a=e.duration||300,c=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",o,"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 L=new z;class O{constructor(t){this.containers=new Map,this.cssInjected=!1,this.config=t}updateConfig(t){this.config=t,this.containers.forEach((e,s)=>{this.applyContainerStyles(e,s),this.applyStackState(e)})}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),document.body.appendChild(e),this.containers.set(t,e),this.injectCSS(),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"),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 o=this.createContent(t);if(e.progress){const a=document.createElement("div");a.className="editora-toast-progress-track",a.setAttribute("role","progressbar"),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax","100"),a.setAttribute("aria-valuenow",String(Math.min(100,Math.max(0,e.progress.value))));const c=document.createElement("div");if(c.className="editora-toast-progress-bar",c.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`,e.progress.showPercentage){const d=document.createElement("span");d.className="editora-toast-progress-text",d.textContent=`${Math.round(e.progress.value)}%`,a.appendChild(d)}a.appendChild(c),o.appendChild(a)}if(s.appendChild(o),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)}if(e.closable||e.closeButton){const a=document.createElement("button");a.className="editora-toast-close",a.setAttribute("aria-label","Close notification"),a.textContent="×",a.onclick=()=>t.dismiss(),s.appendChild(a)}return e.pauseOnHover&&(s.addEventListener("mouseenter",()=>this.pauseToast(t)),s.addEventListener("mouseleave",()=>this.resumeToast(t))),e.pauseOnFocus&&(s.addEventListener("focusin",()=>this.pauseToast(t)),s.addEventListener("focusout",()=>this.resumeToast(t))),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var r,o;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s),this.applyStackState(e);const i=t.options.animation||this.config.animation||{type:"css"};if(await L.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(o=(r=t.options).onShow)==null||o.call(r),!t.options.persistent&&t.options.duration!==0){const a=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{t.dismiss()},a)}}async hideToast(t){var s,i;if(!t.element)return;t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0);const e=t.options.animation||this.config.animation||{type:"css"};if(await L.hideToast(t.element,t,e),t.element&&t.element.parentNode){const r=t.element.parentElement;t.element.parentNode.removeChild(t.element),t.element=void 0,r&&this.applyStackState(r)}(i=(s=t.options).onHide)==null||i.call(s)}async updateToast(t,e){var i,r;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await L.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.render){const o=t.element.querySelector(".editora-toast-content"),a=this.createContent(t);o==null||o.replaceWith(a)}if(e.progress!==void 0){let o=t.element.querySelector(".editora-toast-progress-track");if(e.progress){if(!o){o=document.createElement("div"),o.className="editora-toast-progress-track",o.setAttribute("role","progressbar"),o.setAttribute("aria-valuemin","0"),o.setAttribute("aria-valuemax","100");const c=t.element.querySelector(".editora-toast-content");c&&c.appendChild(o)}o.setAttribute("aria-valuenow",String(Math.min(100,Math.max(0,e.progress.value))));const a=o.querySelector(".editora-toast-progress-bar");if(a&&(a.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`),e.progress.showPercentage){let c=o.querySelector(".editora-toast-progress-text");c||(c=document.createElement("span"),c.className="editora-toast-progress-text",o.insertBefore(c,o.firstChild)),c.textContent=`${Math.round(e.progress.value)}%`}else{const c=o.querySelector(".editora-toast-progress-text");c&&c.remove()}}else o&&o.remove()}if(e.actions!==void 0||e.action!==void 0||e.cancel!==void 0){let o=t.element.querySelector(".editora-toast-actions");const a=t.options.actions||[];a.length>0?(o?o.innerHTML="":(o=document.createElement("div"),o.className="editora-toast-actions",t.element.appendChild(o)),o&&a.forEach(c=>o.appendChild(this.createActionButton(c,t)))):o&&o.remove()}if((e.duration!==void 0||e.persistent!==void 0||e.level!==void 0)&&(t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0),!t.options.persistent&&t.options.duration!==0)){const o=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{t.dismiss()},o)}(r=(i=t.options).onUpdate)==null||r.call(i,e)}createContent(t){const e=t.options,s=document.createElement("div");if(s.className="editora-toast-content",e.icon){const r=document.createElement("span");r.className="editora-toast-icon",r.setAttribute("aria-hidden","true"),r.textContent=e.icon,s.appendChild(r)}const i=document.createElement("div");if(i.className="editora-toast-body",e.render)i.appendChild(e.render(t));else{if(e.title){const r=document.createElement("div");r.className="editora-toast-title",r.textContent=e.title,i.appendChild(r)}if(e.message){const r=document.createElement("div");r.className="editora-toast-message",e.html?r.innerHTML=this.sanitizeHTML(e.message):r.textContent=e.message,i.appendChild(r)}if(e.description){const r=document.createElement("div");r.className="editora-toast-description",r.textContent=e.description,i.appendChild(r)}}return s.appendChild(i),s}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),r=this.toCssLength(this.config.gap);t.dataset.position=e,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",r);const o={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"flex",flexDirection:e.startsWith("top")?"column":"column-reverse",gap:r,pointerEvents:"none",maxWidth:"100%",boxSizing:"border-box",top:"",right:"",bottom:"",left:"",transform:"",alignItems:e.includes("center")?"center":"stretch"};switch(e){case"top-left":o.top=`max(${s}, env(safe-area-inset-top))`,o.left=`max(${s}, env(safe-area-inset-left))`;break;case"top-center":o.top=`max(${s}, env(safe-area-inset-top))`,o.left="50%",o.transform="translateX(-50%)";break;case"top-right":o.top=`max(${s}, env(safe-area-inset-top))`,o.right=`max(${s}, env(safe-area-inset-right))`;break;case"bottom-left":o.bottom=`max(${s}, env(safe-area-inset-bottom))`,o.left=`max(${s}, env(safe-area-inset-left))`;break;case"bottom-center":o.bottom=`max(${s}, env(safe-area-inset-bottom))`,o.left="50%",o.transform="translateX(-50%)";break;case"bottom-right":o.bottom=`max(${s}, env(safe-area-inset-bottom))`,o.right=`max(${s}, env(safe-area-inset-right))`;break;case"center":o.top="50%",o.left="50%",o.transform="translate(-50%, -50%)",o.alignItems="center";break}Object.assign(t.style,o),t.style.setProperty("--editora-toast-mobile-left",i)}applyStackState(t){const e=Array.from(t.querySelectorAll(".editora-toast"));e.forEach((s,i)=>{const r=e.length-i-1;s.dataset.index=String(i),s.dataset.front=String(r===0),s.style.setProperty("--editora-toast-index",String(i)),s.style.setProperty("--editora-toast-before",String(r))})}toCssLength(t){return typeof t=="number"?`${t}px`:t||"16px"}pauseToast(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}resumeToast(t){if(!t.options.persistent&&t.options.duration!==0){const e=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{t.dismiss()},e)}}addSwipeDismiss(t,e){let s=0,i=0,r=!1;const o=e.options.swipeDirection||this.config.swipeDirection||"any",a=40;let c="",d=!1;const h=l=>{r=!0,d=!1,s="touches"in l?l.touches[0].clientX:l.clientX,i="touches"in l?l.touches[0].clientY:l.clientY,c=t.style.transform||"",t.style.transition="none",t.style.cursor="grabbing",l.preventDefault()},f=l=>{if(!r)return;const y="touches"in l?l.touches[0].clientX:l.clientX,b="touches"in l?l.touches[0].clientY:l.clientY,m=y-s,w=b-i,g=5;if((Math.abs(m)>g||Math.abs(w)>g)&&(d=!0),d){const v=Math.abs(w)>Math.abs(m)?25:20,P=Math.min(Math.max(m*.2,-v),v),k=Math.min(Math.max(w*.2,-v),v);t.style.transform=`${c} translate(${P}px, ${k}px)`}(Math.abs(w)>Math.abs(m)||o==="vertical"||o==="up"||o==="down")&&l.preventDefault()},p=l=>{if(!r)return;if(t.style.transform=c,t.style.transition="",t.style.cursor="",!d){r=!1;return}const y="changedTouches"in l?l.changedTouches[0].clientX:l.clientX,b="changedTouches"in l?l.changedTouches[0].clientY:l.clientY,m=y-s,w=b-i;let g=!1;const P=o==="vertical"||o==="up"||o==="down"?35:a;switch(o){case"any":g=Math.abs(m)>a||Math.abs(w)>a;break;case"horizontal":g=Math.abs(m)>a;break;case"vertical":g=Math.abs(w)>P;break;case"left":g=m<-a;break;case"right":g=m>a;break;case"up":g=w<-P;break;case"down":g=w>P;break}g&&e.dismiss(),r=!1};t.addEventListener("dragstart",l=>l.preventDefault()),t.addEventListener("touchstart",h,{passive:!1}),t.addEventListener("touchmove",f,{passive:!1}),t.addEventListener("touchend",p,{passive:!1}),t.addEventListener("mousedown",h),t.addEventListener("mousemove",f),t.addEventListener("mouseup",p),t.addEventListener("mouseleave",p)}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(()=>{document.body.removeChild(e)},1e3)}sanitizeHTML(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!Array.from(document.styleSheets).find(e=>{var s,i,r,o;return((i=(s=e.ownerNode)==null?void 0:s.href)==null?void 0:i.includes("toast.css"))||((o=(r=e.ownerNode)==null?void 0:r.textContent)==null?void 0:o.includes("editora-toast"))})){const e=document.createElement("style");e.setAttribute("data-editora-toast-fallback","true"),e.textContent=".editora-toast{box-sizing:border-box;pointer-events:auto}.editora-toast-container{box-sizing:border-box;pointer-events:none}.editora-toast.show{opacity:1;transform:translateY(0) scale(1)}.editora-toast.hiding{opacity:0}",document.head.appendChild(e)}this.cssInjected=!0}destroy(){this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class I{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 r of i)try{await r(e,...s)}catch(o){console.error(`Error in ${t} hook:`,o)}}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 r=await t;return s(r),r}catch(r){throw i(r),r}}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 H={position:"bottom-right",duration:4e3,maxVisible:3,queueStrategy:"fifo",theme:"system",richColors:!1,expand:!0,stack:!1,offset:16,mobileOffset:16,gap:8,pauseOnHover:!0,pauseOnFocus:!1,pauseOnWindowBlur:!1,swipeDismiss:!0,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,closeButton:!1,preventDuplicate:!1,dedupeScope:"all",animation:{type:"css"}};class E{constructor(t={}){this.idCounter=0,this.pausedToasts=new Set,this.subscribers=new Set,this.config=this.normalizeConfig({...H,...t}),this.store=new A(this.config),this.queue=new M(this.config),this.renderer=new O(this.config),this.lifecycle=new I,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:this.normalizeToastOptions({...this.config,...t}),createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:i=>this.update(e,i)};return 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())}),s}update(t,e){const s=this.store.getToast(t);return s?(this.lifecycle.beforeUpdate(s,e).then(async()=>{const i=this.normalizeToastOptions({...s.options,...e});this.store.updateToast(t,{options:i}),this.queue.isVisible(t)&&await this.renderer.updateToast(s,e),this.lifecycle.afterUpdate(s,e),this.notify()}),!0):!1}dismiss(t){const e=this.store.getToast(t);return e?(this.lifecycle.beforeHide(e).then(async()=>{const s=this.queue.isVisible(t),i=this.queue.dequeue(t);s&&await this.renderer.hideToast(e),this.store.removeToast(t),this.lifecycle.afterHide(e),await this.showToasts(i.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,r;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const o=await t,a=this.normalizeOptions(typeof e.success=="function"?e.success(o):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,o),o}catch(o){const a=this.normalizeOptions(typeof e.error=="function"?e.error(o):e.error,"error");throw a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(r=e.onError)==null||r.call(e,o),o}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur;this.config=this.normalizeConfig({...this.config,...t}),this.store.updateConfig(this.config),this.renderer.updateConfig(this.config);const s=this.queue.updateConfig(this.config);this.hideToasts(s.hide,!0).then(()=>this.showToasts(s.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}}normalizeConfig(t){const e=t.visibleToasts||t.maxVisible||H.maxVisible;return{...t,maxVisible:e,visibleToasts:e}}normalizeToastOptions(t){var r,o,a,c;const e=(o=(r=t.closeButton)!=null?r:t.closable)!=null?o:this.config.closeButton,s=t.action?{...t.action,primary:(a=t.action.primary)!=null?a:!0}:void 0,i=[...s?[s]:[],...t.cancel?[t.cancel]:[],...t.actions||[]];return{...t,closable:e,actions:i.length>0?i:void 0,ariaLive:t.ariaLive||(t.level==="error"||t.important?"assertive":"polite"),role:t.role||(t.level==="error"||t.important?"alert":"status"),preventDuplicate:(c=t.preventDuplicate)!=null?c: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(e=>{e.timeoutId&&!this.pausedToasts.has(e.id)&&(clearTimeout(e.timeoutId),e.timeoutId=void 0,this.pausedToasts.add(e.id))})}resumeAllToasts(){this.store.getAllToasts().forEach(e=>{if(this.pausedToasts.has(e.id)&&!e.options.persistent&&e.options.duration!==0){const s=e.options.duration||this.config.duration;e.timeoutId=window.setTimeout(()=>{this.dismiss(e.id)},s),this.pausedToasts.delete(e.id)}})}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let x=null;function u(){return x||(x=new E),x}function S(n){return typeof document=="undefined"?{dismiss:()=>{}}:u().show(n)}function $(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 r={message:n,...i,level:i.level||void 0};return i.duration!==void 0&&(r.duration=i.duration),i.position&&(r.position=i.position),i.theme&&(r.theme=i.theme),r}const C={info:(n,t,e,s)=>S({...$(n,t,e,s),level:"info"}),success:(n,t,e,s)=>S({...$(n,t,e,s),level:"success"}),error:(n,t,e,s)=>S({...$(n,t,e,s),level:"error"}),warning:(n,t,e,s)=>S({...$(n,t,e,s),level:"warning"}),loading:(n,t,e,s)=>S({...$(n,t,e,s),level:"loading"})},T={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:()=>{x&&(x.destroy(),x=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const n=window;n.toast=C,n.toastAdvanced=T,n.toastPro=T,n.ToastManager=E,n.__editoraToastReady||(n.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:C,toastAdvanced:T,toastPro:T,ToastManager:E}})))}exports.ToastManager=E;exports.default=C;exports.toast=C;exports.toastAdvanced=T;exports.toastPro=T;
2
2
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ToastOptions, ToastInstance, ToastConfig, ToastPlugin, ToastPromiseOptions, ToastTheme, ToastPosition } from './core/types';
2
- export type ToastLevel = 'info' | 'success' | 'error' | 'warning' | 'loading';
1
+ import { ToastOptions, ToastInstance, ToastConfig, ToastPlugin, ToastPromiseOptions, ToastTheme, ToastPosition, ToastSubscriber } from "./core/types";
2
+ export type ToastLevel = "info" | "success" | "error" | "warning" | "loading";
3
3
  export interface ToastOptionsLegacy extends ToastOptions {
4
4
  message: string;
5
5
  }
@@ -21,8 +21,8 @@ export declare const toast: {
21
21
  };
22
22
  };
23
23
  export default toast;
24
- export { ToastManager } from './core/ToastManager';
25
- export type { ToastLevel as ToastLevelAdvanced, ToastPosition, ToastTheme, ToastAction, ToastProgress, ToastContent, ToastOptions as ToastOptionsAdvanced, ToastInstance, ToastConfig, ToastPlugin, ToastPromiseOptions, SpringConfig, AnimationType, AnimationConfig, SpringAnimation, BounceAnimation, SlideAnimation, ZoomAnimation, FlipAnimation, FadeAnimation, ElasticAnimation, RotateAnimation, CustomAnimation } from './core/types';
24
+ export { ToastManager } from "./core/ToastManager";
25
+ export type { ToastLevel as ToastLevelAdvanced, ToastPosition, ToastTheme, ToastAction, ToastProgress, ToastContent, ToastOptions as ToastOptionsAdvanced, ToastInstance, ToastConfig, ToastPlugin, ToastPromiseOptions, ToastState, ToastSubscriber, SpringConfig, AnimationType, AnimationConfig, SpringAnimation, BounceAnimation, SlideAnimation, ZoomAnimation, FlipAnimation, FadeAnimation, ElasticAnimation, RotateAnimation, CustomAnimation, } from "./core/types";
26
26
  export declare const toastAdvanced: {
27
27
  show: (options: ToastOptions) => ToastInstance;
28
28
  update: (id: string, options: Partial<ToastOptions>) => boolean;
@@ -40,6 +40,8 @@ export declare const toastAdvanced: {
40
40
  getToasts: () => ToastInstance[];
41
41
  getGroups: () => import("./core/types").ToastGroup[];
42
42
  getConfig: () => ToastConfig;
43
+ getState: () => import("./core/types").ToastState;
44
+ subscribe: (listener: ToastSubscriber) => () => void;
43
45
  onEditorEvent: (event: string, callback: (toast: ToastInstance, ...args: any[]) => void) => void;
44
46
  triggerEditorEvent: (event: string, toast: ToastInstance, ...args: any[]) => void;
45
47
  destroy: () => void;