dynaura 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,558 @@
1
+ "use client";
2
+
3
+ // src/store.ts
4
+ var g = globalThis;
5
+ var _a;
6
+ var S = (_a = g.__dynaura) != null ? _a : g.__dynaura = { current: null, queue: [], n: 0, subs: /* @__PURE__ */ new Set(), useQueue: false };
7
+ var set = (t) => {
8
+ S.current = t;
9
+ S.subs.forEach((f) => f());
10
+ };
11
+ var subscribe = (f) => {
12
+ S.subs.add(f);
13
+ return () => {
14
+ S.subs.delete(f);
15
+ };
16
+ };
17
+ var getCurrent = () => S.current;
18
+ var setQueue = (v) => {
19
+ S.useQueue = v;
20
+ };
21
+ var norm = (o) => typeof o === "string" ? { title: o } : o;
22
+ var make = (type) => (o) => {
23
+ var _a2;
24
+ const id = String(++S.n);
25
+ const sticky = type === "loading" || type === "live";
26
+ const t = { duration: sticky ? null : 4e3, ...type === "live" ? { kind: "timer" } : {}, ...norm(o), id, type };
27
+ if (S.current && ((_a2 = t.queue) != null ? _a2 : S.useQueue)) S.queue.push(t);
28
+ else set(t);
29
+ return id;
30
+ };
31
+ var update = (id, patch) => {
32
+ var _a2;
33
+ if (((_a2 = S.current) == null ? void 0 : _a2.id) === id) return set({ ...S.current, ...patch });
34
+ const i = S.queue.findIndex((t) => t.id === id);
35
+ if (i >= 0) S.queue[i] = { ...S.queue[i], ...patch };
36
+ };
37
+ var pick = (r, v) => norm(typeof r === "function" ? r(v) : r);
38
+ var dynaura = {
39
+ success: make("success"),
40
+ error: make("error"),
41
+ warning: make("warning"),
42
+ info: make("info"),
43
+ loading: make("loading"),
44
+ /** Live activity: sticky island with a running timer (default) or waveform. */
45
+ live: make("live"),
46
+ update,
47
+ /** dismiss the current toast (next queued one shows) or a specific id */
48
+ dismiss: (id) => {
49
+ var _a2, _b;
50
+ if (id && ((_a2 = S.current) == null ? void 0 : _a2.id) !== id) {
51
+ S.queue = S.queue.filter((t) => t.id !== id);
52
+ return;
53
+ }
54
+ set((_b = S.queue.shift()) != null ? _b : null);
55
+ },
56
+ clear: () => {
57
+ S.queue = [];
58
+ set(null);
59
+ },
60
+ promise(p, o) {
61
+ const id = make("loading")(o.loading);
62
+ p.then(
63
+ (v) => update(id, { duration: 4e3, ...pick(o.success, v), type: "success" }),
64
+ (e) => update(id, { duration: 4e3, ...pick(o.error, e), type: "error" })
65
+ );
66
+ return p;
67
+ }
68
+ };
69
+
70
+ // src/confetti.ts
71
+ function burst(x, y, color) {
72
+ const c = document.createElement("canvas");
73
+ const dpr = window.devicePixelRatio || 1;
74
+ const W = innerWidth, H = innerHeight;
75
+ c.width = W * dpr;
76
+ c.height = H * dpr;
77
+ c.style.cssText = `position:fixed;top:0;left:0;width:${W}px;height:${H}px;pointer-events:none;z-index:2147483647`;
78
+ document.body.append(c);
79
+ const ctx = c.getContext("2d");
80
+ if (!ctx) return c.remove();
81
+ ctx.scale(dpr, dpr);
82
+ const colors = [color, "#fff", color, "#ffd60a", "#0a84ff"];
83
+ const ps = Array.from({ length: 36 }, () => {
84
+ const a = Math.random() * Math.PI * 2, s = 3 + Math.random() * 6;
85
+ return { x, y, vx: Math.cos(a) * s, vy: Math.sin(a) * s - 3, r: 2 + Math.random() * 3, rot: Math.random() * 6, c: colors[Math.random() * colors.length | 0] };
86
+ });
87
+ const t0 = performance.now();
88
+ const frame = (t) => {
89
+ const k = (t - t0) / 1e3;
90
+ if (k >= 1) return c.remove();
91
+ ctx.clearRect(0, 0, W, H);
92
+ for (const p of ps) {
93
+ p.x += p.vx;
94
+ p.y += p.vy;
95
+ p.vy += 0.28;
96
+ p.vx *= 0.985;
97
+ p.rot += 0.2;
98
+ ctx.globalAlpha = 1 - k * k;
99
+ ctx.fillStyle = p.c;
100
+ ctx.save();
101
+ ctx.translate(p.x, p.y);
102
+ ctx.rotate(p.rot);
103
+ ctx.fillRect(-p.r, -p.r / 2, p.r * 2, p.r);
104
+ ctx.restore();
105
+ }
106
+ requestAnimationFrame(frame);
107
+ };
108
+ requestAnimationFrame(frame);
109
+ }
110
+
111
+ // src/core.ts
112
+ var VAR = {
113
+ background: "bg",
114
+ foreground: "fg",
115
+ muted: "muted",
116
+ ring: "ring",
117
+ button: "btn",
118
+ success: "success",
119
+ error: "error",
120
+ warning: "warning",
121
+ info: "info",
122
+ loading: "loading",
123
+ live: "live"
124
+ };
125
+ var svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`;
126
+ var ICON = {
127
+ success: svg('<path class="dynaura-draw" d="M5 12.5l4.5 4.5L19 7.5"/>'),
128
+ error: svg('<path class="dynaura-draw" d="M7 7l10 10M17 7L7 17"/>'),
129
+ warning: svg('<path class="dynaura-draw" d="M12 6v7M12 17.5v.01"/>'),
130
+ info: svg('<path class="dynaura-draw" d="M12 11v6M12 7.5v.01"/>'),
131
+ loading: svg('<circle class="dynaura-spin" cx="12" cy="12" r="8" stroke-dasharray="30 50"/>')
132
+ };
133
+ var DOT = '<span class="dynaura-dot"></span>';
134
+ var WAVE = '<span class="dynaura-wave"><i></i><i></i><i></i><i></i></span>';
135
+ var VIBRATE = { success: [12], error: [24, 40, 24], warning: [30], info: [8], loading: [], live: [8] };
136
+ var f2 = (n) => +n.toFixed(2);
137
+ function outline(w, h2, cw, ch, hx) {
138
+ if (h2 <= ch + 1 || w <= cw + 1) {
139
+ const q = f2(Math.min(h2 / 2, w / 2, 32));
140
+ return `M${q} 0H${f2(w - q)}A${q} ${q} 0 0 1 ${f2(w)} ${q}V${f2(h2 - q)}A${q} ${q} 0 0 1 ${f2(w - q)} ${f2(h2)}H${q}A${q} ${q} 0 0 1 0 ${f2(h2 - q)}V${q}A${q} ${q} 0 0 1 ${q} 0Z`;
141
+ }
142
+ const r = f2(Math.min(ch / 2, 32));
143
+ const b = f2(Math.max(0, Math.min(28, (h2 - ch) / 2, (w - cw) / 2)));
144
+ const f = f2(Math.min(16, b));
145
+ const x0 = f2(hx), x1 = f2(hx + cw);
146
+ const flushL = hx < 1, flushR = hx + cw > w - 1;
147
+ let d = `M${f2(x0 + r)} 0H${f2(x1 - r)}A${r} ${r} 0 0 1 ${x1} ${r}`;
148
+ d += flushR ? `V${f2(h2 - b)}` : `V${f2(ch - f)}A${f} ${f} 0 0 0 ${f2(x1 + f)} ${f2(ch)}H${f2(w - b)}A${b} ${b} 0 0 1 ${f2(w)} ${f2(ch + b)}V${f2(h2 - b)}`;
149
+ d += `A${b} ${b} 0 0 1 ${f2(w - b)} ${f2(h2)}H${b}A${b} ${b} 0 0 1 0 ${f2(h2 - b)}`;
150
+ d += flushL ? `V${r}` : `V${f2(ch + b)}A${b} ${b} 0 0 1 ${b} ${f2(ch)}H${f2(x0 - f)}A${f} ${f} 0 0 0 ${x0} ${f2(ch - f)}V${r}`;
151
+ return d + `A${r} ${r} 0 0 1 ${f2(x0 + r)} 0Z`;
152
+ }
153
+ var h = (tag, cls, parent) => {
154
+ const e = document.createElement(tag);
155
+ e.className = cls;
156
+ parent == null ? void 0 : parent.append(e);
157
+ return e;
158
+ };
159
+ var restart = (e) => {
160
+ e.style.animation = "none";
161
+ void e.offsetWidth;
162
+ e.style.animation = "";
163
+ };
164
+ function roll(e, s) {
165
+ const sig = s.replace(/\d/g, "0");
166
+ if (e.dataset.sig !== sig) {
167
+ e.dataset.sig = sig;
168
+ e.replaceChildren();
169
+ e.setAttribute("role", "img");
170
+ for (const ch of s) {
171
+ if (/\d/.test(ch)) {
172
+ const d = h("span", "dynaura-digit", e);
173
+ d.setAttribute("aria-hidden", "true");
174
+ h("span", "dynaura-strip", d).innerHTML = "0123456789".replace(/\d/g, "<i>$&</i>");
175
+ } else h("span", "dynaura-char", e).textContent = ch;
176
+ }
177
+ }
178
+ e.setAttribute("aria-label", s);
179
+ [...s].forEach((ch, i) => {
180
+ if (/\d/.test(ch)) e.children[i].style.setProperty("--d", ch);
181
+ });
182
+ }
183
+ function createToaster(initial = {}) {
184
+ const o = { position: "top", offset: 12, theme: "dark", timer: true, haptics: true, queue: false };
185
+ const merge = (n) => {
186
+ for (const k in n) if (n[k] !== void 0) o[k] = n[k];
187
+ };
188
+ merge(initial);
189
+ const root = h("div", "dynaura-root");
190
+ const drag = h("div", "dynaura-drag", root);
191
+ const island = h("div", "dynaura-island", drag);
192
+ island.setAttribute("role", "status");
193
+ island.setAttribute("aria-live", "polite");
194
+ const inner = h("div", "dynaura-inner", island);
195
+ const row = h("div", "dynaura-row", inner);
196
+ const badge = h("span", "dynaura-badge", row);
197
+ const title = h("span", "dynaura-title", row);
198
+ const trail = h("span", "dynaura-trailing", row);
199
+ const body = h("div", "dynaura-body", inner);
200
+ const desc = h("div", "dynaura-desc", body);
201
+ const btn = h("button", "dynaura-button", body);
202
+ const bar = h("div", "dynaura-bar", island);
203
+ island.hidden = true;
204
+ island.dataset.expanded = "false";
205
+ island.dataset.paused = "false";
206
+ document.body.append(root);
207
+ let t = null;
208
+ let expanded = false, hovered = false, pinned = false, dragging = false, ready = false;
209
+ let hideT, expandT, collapseT, dismissT, liveI, lp;
210
+ let remaining = 0, startedAt = 0, liveStart = 0;
211
+ let sz = { cw: 0, ch: 0, ew: 0, eh: 0 };
212
+ let applied = [];
213
+ const hosts = /* @__PURE__ */ new Map();
214
+ const dir = () => o.position.startsWith("bottom") ? 1 : -1;
215
+ const hasBody = () => !!t && (t.description != null && typeof t.description !== "boolean" || !!t.button);
216
+ const paused = () => hovered || pinned || dragging;
217
+ function put(slot, c) {
218
+ var _a2;
219
+ const old = hosts.get(slot);
220
+ if (old) {
221
+ (_a2 = o.render) == null ? void 0 : _a2.call(o, old, null);
222
+ hosts.delete(slot);
223
+ }
224
+ slot.replaceChildren();
225
+ if (c == null || typeof c === "boolean") return;
226
+ if (typeof c === "string" || typeof c === "number") slot.textContent = String(c);
227
+ else if (c instanceof Node) slot.append(c);
228
+ else if (o.render) {
229
+ const host = h("span", "dynaura-host", slot);
230
+ hosts.set(slot, host);
231
+ o.render(host, c);
232
+ }
233
+ }
234
+ let raf = 0;
235
+ const isCard = () => (t == null ? void 0 : t.variant) === "card";
236
+ function shape() {
237
+ if (!isCard()) {
238
+ island.style.clipPath = "";
239
+ row.style.transform = "";
240
+ return;
241
+ }
242
+ const cs = getComputedStyle(island);
243
+ const w = parseFloat(cs.width), hh = parseFloat(cs.height);
244
+ if (!isFinite(w) || !isFinite(hh) || w <= 0) return;
245
+ const x = o.position.split("-")[1];
246
+ const hx = x === "left" ? 0 : x === "right" ? Math.max(0, w - sz.cw) : Math.max(0, (w - sz.cw) / 2);
247
+ row.style.transform = `translateX(${f2(hx)}px)`;
248
+ island.style.clipPath = `path('${outline(w, hh, sz.cw, sz.ch, hx)}')`;
249
+ }
250
+ function shapeLoop() {
251
+ cancelAnimationFrame(raf);
252
+ const end = performance.now() + 1300;
253
+ const f = () => {
254
+ shape();
255
+ if (performance.now() < end) raf = requestAnimationFrame(f);
256
+ };
257
+ f();
258
+ }
259
+ function size() {
260
+ if (!sz.cw) return;
261
+ const w = expanded ? sz.ew : sz.cw, hh = expanded ? sz.eh : sz.ch;
262
+ island.style.width = w + "px";
263
+ island.style.height = hh + "px";
264
+ island.style.borderRadius = isCard() ? "0" : Math.min(hh / 2, 32) + "px";
265
+ if (isCard()) shapeLoop();
266
+ else island.style.clipPath = "";
267
+ }
268
+ function measure() {
269
+ if (island.hidden) return;
270
+ sz = { cw: row.offsetWidth, ch: row.offsetHeight, ew: inner.offsetWidth, eh: inner.offsetHeight };
271
+ size();
272
+ if (!ready && sz.cw) requestAnimationFrame(() => {
273
+ ready = true;
274
+ island.dataset.ready = "true";
275
+ });
276
+ }
277
+ const ro = new ResizeObserver(measure);
278
+ ro.observe(row);
279
+ ro.observe(inner);
280
+ function setExpanded(v) {
281
+ v = v && hasBody();
282
+ if (v === expanded) return;
283
+ expanded = v;
284
+ island.dataset.expanded = String(v);
285
+ size();
286
+ }
287
+ function clear() {
288
+ if (startedAt) {
289
+ remaining -= Date.now() - startedAt;
290
+ startedAt = 0;
291
+ }
292
+ clearTimeout(collapseT);
293
+ clearTimeout(dismissT);
294
+ }
295
+ function arm() {
296
+ clear();
297
+ if (!t || t.duration == null || paused()) return;
298
+ const id = t.id;
299
+ startedAt = Date.now();
300
+ collapseT = setTimeout(() => {
301
+ if (!pinned) setExpanded(false);
302
+ }, Math.max(0, remaining - 500));
303
+ dismissT = setTimeout(() => dynaura.dismiss(id), remaining);
304
+ }
305
+ function sync() {
306
+ island.dataset.paused = String(paused());
307
+ if (paused()) {
308
+ clear();
309
+ if (hovered || pinned) setExpanded(true);
310
+ } else arm();
311
+ }
312
+ function tick() {
313
+ var _a2;
314
+ if (!t || t.trailing != null) return;
315
+ if (t.progress != null) roll(trail, Math.round(t.progress * 100) + "%");
316
+ else if (t.type === "live" && ((_a2 = t.kind) != null ? _a2 : "timer") === "timer") {
317
+ const s = Math.floor((Date.now() - liveStart) / 1e3);
318
+ roll(trail, `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`);
319
+ }
320
+ }
321
+ const hasTrail = (n) => {
322
+ var _a2;
323
+ return n.trailing != null || n.progress != null || n.type === "live" && ((_a2 = n.kind) != null ? _a2 : "timer") === "timer";
324
+ };
325
+ function apply(n, p) {
326
+ var _a2, _b, _c;
327
+ const ch = (k) => !p || n[k] !== p[k];
328
+ island.dataset.type = n.type;
329
+ island.dataset.variant = drag.dataset.variant = (_a2 = n.variant) != null ? _a2 : "default";
330
+ if (ch("type") || ch("icon") || ch("kind")) {
331
+ put(badge, void 0);
332
+ if (n.icon != null) put(badge, n.icon);
333
+ else badge.innerHTML = n.type === "live" ? ((_b = n.kind) != null ? _b : "timer") === "wave" ? WAVE : DOT : ICON[n.type];
334
+ restart(badge);
335
+ }
336
+ if (ch("title")) {
337
+ title.textContent = n.title;
338
+ restart(title);
339
+ }
340
+ if (ch("trailing") || ch("progress") || ch("type") || ch("kind")) {
341
+ trail.hidden = !hasTrail(n);
342
+ if (n.trailing != null) {
343
+ delete trail.dataset.sig;
344
+ trail.removeAttribute("aria-label");
345
+ put(trail, n.trailing);
346
+ } else if (!hasTrail(n)) {
347
+ delete trail.dataset.sig;
348
+ put(trail, void 0);
349
+ }
350
+ }
351
+ if (ch("description")) put(desc, n.description);
352
+ desc.hidden = n.description == null || typeof n.description === "boolean";
353
+ btn.hidden = !n.button;
354
+ if (n.button) btn.textContent = n.button.title;
355
+ body.hidden = !(n.description != null && typeof n.description !== "boolean") && !n.button;
356
+ bar.dataset.mode = n.progress != null ? "value" : n.duration != null ? "time" : "none";
357
+ bar.style.setProperty("--p", String((_c = n.progress) != null ? _c : 0));
358
+ }
359
+ function feedback(n) {
360
+ var _a2, _b;
361
+ const active = (_b = (_a2 = navigator.userActivation) == null ? void 0 : _a2.hasBeenActive) != null ? _b : true;
362
+ if (o.haptics && typeof navigator !== "undefined" && navigator.vibrate && active && VIBRATE[n.type].length) navigator.vibrate(VIBRATE[n.type]);
363
+ if (n.confetti && !matchMedia("(prefers-reduced-motion: reduce)").matches) {
364
+ requestAnimationFrame(() => {
365
+ const r = island.getBoundingClientRect();
366
+ burst(r.left + r.width / 2, r.top + r.height / 2, getComputedStyle(island).getPropertyValue("--state").trim() || "#30d158");
367
+ });
368
+ }
369
+ }
370
+ const onlyProgress = (p, n) => p.progress == null === (n.progress == null) && [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(p)])].every((k) => k === "progress" || n[k] === p[k]);
371
+ function render() {
372
+ var _a2, _b, _c;
373
+ const n = getCurrent();
374
+ const p = t;
375
+ if (!n) {
376
+ if (p) leave();
377
+ return;
378
+ }
379
+ const same = !!p && p.id === n.id;
380
+ if (same && onlyProgress(p, n)) {
381
+ t = n;
382
+ bar.style.setProperty("--p", String((_a2 = n.progress) != null ? _a2 : 0));
383
+ tick();
384
+ return;
385
+ }
386
+ t = n;
387
+ clearTimeout(hideT);
388
+ if (island.hidden) {
389
+ island.hidden = false;
390
+ drag.style.transform = "";
391
+ drag.style.opacity = "";
392
+ restart(island);
393
+ }
394
+ island.dataset.open = "true";
395
+ if (!same) {
396
+ liveStart = Date.now();
397
+ pinned = false;
398
+ }
399
+ apply(n, same ? p : null);
400
+ measure();
401
+ if (!same || n.type !== p.type) feedback(n);
402
+ clearInterval(liveI);
403
+ if (n.type === "live") liveI = setInterval(tick, 1e3);
404
+ tick();
405
+ clear();
406
+ startedAt = 0;
407
+ remaining = (_b = n.duration) != null ? _b : 0;
408
+ restart(bar);
409
+ bar.style.animationDuration = ((_c = n.duration) != null ? _c : 0) + "ms";
410
+ if (!pinned) setExpanded(false);
411
+ clearTimeout(expandT);
412
+ if (hasBody()) expandT = setTimeout(() => setExpanded(true), 450);
413
+ sync();
414
+ }
415
+ function leave() {
416
+ clear();
417
+ startedAt = 0;
418
+ clearTimeout(expandT);
419
+ clearInterval(liveI);
420
+ hovered = pinned = dragging = false;
421
+ t = null;
422
+ island.dataset.open = "false";
423
+ hideT = setTimeout(() => {
424
+ cancelAnimationFrame(raf);
425
+ island.style.clipPath = "";
426
+ island.hidden = true;
427
+ ready = false;
428
+ expanded = false;
429
+ delete island.dataset.ready;
430
+ island.dataset.expanded = "false";
431
+ island.style.width = island.style.height = island.style.borderRadius = "";
432
+ [badge, trail, desc].forEach((s) => put(s, void 0));
433
+ delete trail.dataset.sig;
434
+ }, 450);
435
+ }
436
+ btn.onclick = () => {
437
+ const c = t;
438
+ if (c == null ? void 0 : c.button) {
439
+ c.button.onClick();
440
+ dynaura.dismiss(c.id);
441
+ }
442
+ };
443
+ let sy = 0, t0 = 0, moved = false, longed = false;
444
+ island.addEventListener("pointerenter", (e) => {
445
+ if (e.pointerType === "mouse") {
446
+ hovered = true;
447
+ sync();
448
+ }
449
+ });
450
+ island.addEventListener("pointerleave", (e) => {
451
+ if (e.pointerType !== "mouse") return;
452
+ hovered = false;
453
+ if (!pinned) setExpanded(false);
454
+ sync();
455
+ });
456
+ drag.addEventListener("pointerdown", (e) => {
457
+ var _a2;
458
+ if (!t || e.target.closest("button")) return;
459
+ dragging = true;
460
+ moved = longed = false;
461
+ sy = e.clientY;
462
+ t0 = Date.now();
463
+ (_a2 = drag.setPointerCapture) == null ? void 0 : _a2.call(drag, e.pointerId);
464
+ drag.style.transition = "none";
465
+ lp = setTimeout(() => {
466
+ var _a3;
467
+ if (!moved) {
468
+ longed = true;
469
+ pinned = true;
470
+ if (o.haptics) (_a3 = navigator.vibrate) == null ? void 0 : _a3.call(navigator, 8);
471
+ sync();
472
+ }
473
+ }, 450);
474
+ sync();
475
+ });
476
+ drag.addEventListener("pointermove", (e) => {
477
+ if (!dragging) return;
478
+ const dy = e.clientY - sy;
479
+ if (Math.abs(dy) > 6) {
480
+ moved = true;
481
+ clearTimeout(lp);
482
+ }
483
+ if (!moved) return;
484
+ const d = dy * dir();
485
+ const off = d > 0 ? d : -Math.sqrt(-d) * 4;
486
+ drag.style.transform = `translateY(${off * dir()}px)`;
487
+ });
488
+ const up = (e) => {
489
+ if (!dragging) return;
490
+ dragging = false;
491
+ clearTimeout(lp);
492
+ drag.style.transition = "";
493
+ const d = (e.clientY - sy) * dir();
494
+ const v = d / Math.max(1, Date.now() - t0);
495
+ if (e.type === "pointerup" && moved && (d > 40 || v > 0.5 && d > 10) && t) {
496
+ dynaura.dismiss(t.id);
497
+ return;
498
+ }
499
+ drag.style.transform = "";
500
+ if (e.type === "pointerup" && !moved && !longed && hasBody()) {
501
+ pinned = !pinned;
502
+ if (!pinned && !hovered) setExpanded(false);
503
+ }
504
+ sync();
505
+ };
506
+ drag.addEventListener("pointerup", up);
507
+ drag.addEventListener("pointercancel", up);
508
+ const outside = (e) => {
509
+ if (pinned && !island.contains(e.target)) {
510
+ pinned = false;
511
+ if (!hovered) setExpanded(false);
512
+ sync();
513
+ }
514
+ };
515
+ document.addEventListener("pointerdown", outside);
516
+ function set2(n) {
517
+ merge(n);
518
+ setQueue(o.queue);
519
+ const [y, x = "center"] = o.position.split("-");
520
+ root.dataset.y = y;
521
+ root.dataset.x = x;
522
+ root.dataset.timer = String(o.timer);
523
+ root.dataset.theme = typeof o.theme === "object" ? "custom" : o.theme;
524
+ root.style.setProperty("--dynaura-offset", o.offset + "px");
525
+ applied.forEach((v) => root.style.removeProperty(v));
526
+ applied = [];
527
+ if (typeof o.theme === "object")
528
+ for (const k in o.theme) {
529
+ const v = `--dynaura-${VAR[k]}`;
530
+ root.style.setProperty(v, o.theme[k]);
531
+ applied.push(v);
532
+ }
533
+ }
534
+ set2({});
535
+ const unsub = subscribe(render);
536
+ render();
537
+ return {
538
+ set: set2,
539
+ destroy() {
540
+ unsub();
541
+ ro.disconnect();
542
+ cancelAnimationFrame(raf);
543
+ document.removeEventListener("pointerdown", outside);
544
+ clear();
545
+ [hideT, expandT, liveI, lp].forEach((x) => {
546
+ clearTimeout(x);
547
+ clearInterval(x);
548
+ });
549
+ [badge, trail, desc].forEach((s) => put(s, void 0));
550
+ root.remove();
551
+ }
552
+ };
553
+ }
554
+
555
+ export {
556
+ dynaura,
557
+ createToaster
558
+ };