@yewdiel21/motion-kit 0.18.0 → 0.19.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.
Files changed (68) hide show
  1. package/README.md +240 -222
  2. package/dist/auto/index.d.ts +4 -3
  3. package/dist/auto/index.js +5 -3
  4. package/dist/auto/index.js.map +1 -1
  5. package/dist/{chunk-QFBOHPWZ.js → chunk-CQP66AZK.js} +2 -2
  6. package/dist/{chunk-QP4QJOEN.js → chunk-H4STLMCM.js} +2 -2
  7. package/dist/{chunk-EDMXWUW3.js → chunk-KDIJX6G4.js} +3 -3
  8. package/dist/{chunk-DOOMULVV.js → chunk-OLT3CWDJ.js} +4 -2
  9. package/dist/chunk-OLT3CWDJ.js.map +1 -0
  10. package/dist/{chunk-AWDEKDEJ.js → chunk-PEDYJ2TV.js} +8 -22
  11. package/dist/chunk-PEDYJ2TV.js.map +1 -0
  12. package/dist/{chunk-Q7IW4FV3.js → chunk-Y4GIBTRG.js} +1422 -967
  13. package/dist/chunk-Y4GIBTRG.js.map +1 -0
  14. package/dist/css/components/code-block.css +267 -0
  15. package/dist/css/components/command-search.css +274 -2
  16. package/dist/css/components/dialog.css +264 -0
  17. package/dist/css/components/heatmap-chart.css +267 -1
  18. package/dist/css/components/scroll-area.css +261 -0
  19. package/dist/css/components/select.css +284 -4
  20. package/dist/elements/index.d.ts +15 -4
  21. package/dist/elements/index.js +36 -6
  22. package/dist/elements/index.js.map +1 -1
  23. package/dist/{engine-t8d7brjn.d.ts → engine-D6XV-WNt.d.ts} +50 -1
  24. package/dist/gl/index.js +2 -2
  25. package/dist/index.css +308 -7
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +7 -5
  28. package/dist/index.js.map +1 -1
  29. package/dist/react/index.d.ts +20 -7
  30. package/dist/react/index.js +56 -7
  31. package/dist/react/index.js.map +1 -1
  32. package/dist/{reduced-dPsZYqtI.d.ts → reduced-4croIXl-.d.ts} +1 -1
  33. package/dist/{store-6hZNKiee.d.ts → store-CAHWkurn.d.ts} +1 -1
  34. package/package.json +110 -110
  35. package/registry.json +1357 -1340
  36. package/src/auto/auto-init.ts +341 -339
  37. package/src/components/code-block/README.md +1 -1
  38. package/src/components/code-block/code-block.css +5 -0
  39. package/src/components/code-block/engine.ts +5 -0
  40. package/src/components/command-search/README.md +1 -1
  41. package/src/components/command-search/command-search.css +12 -2
  42. package/src/components/command-search/engine.ts +6 -0
  43. package/src/components/dialog/README.md +104 -103
  44. package/src/components/dialog/dialog.css +2 -0
  45. package/src/components/dialog/engine.ts +465 -449
  46. package/src/components/heatmap-chart/README.md +48 -48
  47. package/src/components/heatmap-chart/engine.ts +6 -1
  48. package/src/components/heatmap-chart/heatmap-chart.css +5 -1
  49. package/src/components/icons.ts +1 -0
  50. package/src/components/scroll-area/README.md +89 -0
  51. package/src/components/scroll-area/element.ts +35 -0
  52. package/src/components/scroll-area/engine.ts +528 -0
  53. package/src/components/scroll-area/react.tsx +67 -0
  54. package/src/components/scroll-area/scroll-area.css +260 -0
  55. package/src/components/select/README.md +1 -1
  56. package/src/components/select/engine.ts +16 -4
  57. package/src/components/select/select.css +22 -4
  58. package/src/core/timing.ts +2 -0
  59. package/src/elements/index.ts +321 -318
  60. package/src/index.ts +1 -0
  61. package/src/motion/morph.ts +5 -2
  62. package/src/react/index.ts +2 -1
  63. package/dist/chunk-AWDEKDEJ.js.map +0 -1
  64. package/dist/chunk-DOOMULVV.js.map +0 -1
  65. package/dist/chunk-Q7IW4FV3.js.map +0 -1
  66. /package/dist/{chunk-QFBOHPWZ.js.map → chunk-CQP66AZK.js.map} +0 -0
  67. /package/dist/{chunk-QP4QJOEN.js.map → chunk-H4STLMCM.js.map} +0 -0
  68. /package/dist/{chunk-EDMXWUW3.js.map → chunk-KDIJX6G4.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  createScope,
4
4
  entrances,
5
5
  reduced
6
- } from "./chunk-DOOMULVV.js";
6
+ } from "./chunk-OLT3CWDJ.js";
7
7
  import {
8
8
  inert,
9
9
  warnOnce
@@ -1643,6 +1643,7 @@ function faceOf(surface, origin, shape, withCopy) {
1643
1643
  return { face, copy };
1644
1644
  }
1645
1645
  var running = /* @__PURE__ */ new WeakMap();
1646
+ var OVERLAY = "[data-mk-scroll-rail], [data-mk-scroll-top]";
1646
1647
  var isMorphing = (surface) => running.has(surface);
1647
1648
  function stop(surface) {
1648
1649
  running.get(surface)?.kill();
@@ -1653,7 +1654,7 @@ function stop(surface) {
1653
1654
  }
1654
1655
  function stopMorph(surface) {
1655
1656
  stop(surface);
1656
- const parts = [...surface.querySelectorAll(":scope > *")].filter((element) => !element.classList.contains("mk-liquid"));
1657
+ const parts = [...surface.querySelectorAll(":scope > *")].filter((element) => !element.classList.contains("mk-liquid") && !element.matches(OVERLAY));
1657
1658
  gsap.killTweensOf(parts);
1658
1659
  clearStyles(parts, MORPH_STYLES);
1659
1660
  }
@@ -1772,7 +1773,7 @@ function shareBack(surface, origin, duration = TIMING.dialog.close) {
1772
1773
  }
1773
1774
  }
1774
1775
  var partsOf = (surface, content) => [...surface.querySelectorAll(content ?? ":scope > *")].filter(
1775
- (element) => !element.classList.contains(FACE) && !element.classList.contains("mk-liquid")
1776
+ (element) => !element.classList.contains(FACE) && !element.classList.contains("mk-liquid") && !element.matches(OVERLAY)
1776
1777
  );
1777
1778
  function morphOpen(surface, origin, options = {}) {
1778
1779
  registerMotion();
@@ -2021,938 +2022,1376 @@ function releaseUnderlay(elements, animated = true) {
2021
2022
  gsap.to(elements, { scale: 1, opacity: 1, duration, ease, overwrite: "auto", onComplete: restore });
2022
2023
  }
2023
2024
 
2024
- // src/components/dialog/engine.ts
2025
- var DEFAULT_LABELS = { close: "Cerrar", float: "Ventana flotante", dock: "Volver a su sitio" };
2026
- var FIELDS = '[autofocus], input:not([type="hidden"]):not(:disabled), textarea:not(:disabled), select:not(:disabled)';
2027
- var CORNERS = ["tl", "tr", "bl", "br"];
2028
- var uid = 0;
2029
- var part = (dialog, name) => dialog.querySelector(`[data-mk-part="${name}"]`);
2030
- function createDialog(dialog, options = {}) {
2031
- if (!dialog) {
2032
- warnOnce("dialog: missing <dialog> element");
2033
- return inert({ open() {
2034
- }, close() {
2035
- }, toggle() {
2036
- }, float() {
2037
- }, dock() {
2038
- }, isOpen: false, isFloating: false, element: null });
2039
- }
2025
+ // src/motion/micro.ts
2026
+ var list2 = (targets) => !targets ? [] : targets instanceof Element ? [targets] : [...targets];
2027
+ var live = () => {
2040
2028
  registerMotion();
2041
- const {
2042
- variant = "morph",
2043
- placement = "center",
2044
- backdrop = true,
2045
- closeOnBackdrop = true,
2046
- drag = true,
2047
- float: floatKey = false,
2048
- autoResize = true,
2049
- triggers = true,
2050
- modal = true
2051
- } = options;
2052
- const labels = { ...DEFAULT_LABELS, ...options.labels };
2053
- const liquid = variant === "liquid";
2054
- const sheet = variant === "sheet";
2055
- const drawer = variant === "drawer";
2056
- const scope = createScope();
2057
- let session = [];
2058
- let opener = null;
2059
- let isOpen = false;
2060
- let closing = false;
2061
- let floating = false;
2062
- let ownCloses = 0;
2063
- const closeNatively = () => {
2064
- if (!dialog.hasAttribute("open")) return;
2065
- ownCloses += 1;
2066
- closeModal(dialog);
2067
- };
2068
- let destroyed = false;
2069
- let tearingDown = false;
2070
- if (placement !== "center") scope.attr(dialog, "data-mk-placement", placement);
2071
- if (!backdrop) scope.attr(dialog, "data-mk-backdrop", "none");
2072
- scope.attr(dialog, "data-mk-variant", variant);
2073
- const title = part(dialog, "title");
2074
- if (title && !dialog.hasAttribute("aria-label") && !dialog.hasAttribute("aria-labelledby")) {
2075
- if (!title.id) scope.attr(title, "id", `mk-dialog-title-${++uid}`);
2076
- scope.attr(dialog, "aria-labelledby", title.id);
2077
- }
2078
- const description = part(dialog, "description");
2079
- if (description && !dialog.hasAttribute("aria-describedby")) {
2080
- if (!description.id) scope.attr(description, "id", `mk-dialog-description-${++uid}`);
2081
- scope.attr(dialog, "aria-describedby", description.id);
2082
- }
2083
- const closeButton = part(dialog, "close");
2084
- if (closeButton && !closeButton.hasAttribute("aria-label") && !closeButton.textContent?.trim()) {
2085
- scope.attr(closeButton, "aria-label", labels.close);
2086
- }
2087
- const handle = floatKey ? part(dialog, "handle") : null;
2088
- if (handle) {
2089
- scope.attr(handle, "data-mk-no-drag", "");
2090
- scope.attr(handle, "aria-pressed", "false");
2091
- scope.attr(handle, "aria-label", labels.float);
2092
- }
2093
- const corners = [];
2094
- if (floatKey) {
2095
- for (const corner of CORNERS) {
2096
- const element = document.createElement("span");
2097
- element.className = "mk-float-corner";
2098
- element.dataset.mkFloatCorner = corner;
2099
- element.dataset.mkNoDrag = "";
2100
- element.setAttribute("aria-hidden", "true");
2101
- dialog.append(element);
2102
- corners.push(element);
2029
+ return !reduced();
2030
+ };
2031
+ function press(el5) {
2032
+ if (!el5 || !live()) return null;
2033
+ gsap.killTweensOf(el5, "scaleX,scaleY");
2034
+ return gsap.timeline({
2035
+ onComplete: () => {
2036
+ gsap.set(el5, { clearProps: "scale,transform" });
2103
2037
  }
2104
- scope.add(() => corners.forEach((corner) => corner.remove()));
2038
+ }).to(el5, { scaleX: 0.95, scaleY: 0.9, duration: 0.1, ease: "power2.out" }).to(el5, { scaleX: 1, scaleY: 1, duration: 0.5, ease: EASE.click });
2039
+ }
2040
+ function blurIn(targets, { from = "rise", stagger = 0.05, delay = 0, duration } = {}) {
2041
+ const items = list2(targets);
2042
+ if (!items.length || !live()) return null;
2043
+ const start = from === "pop" ? { opacity: 0, scale: 0.7, filter: "blur(32px)" } : from === "soft" ? { opacity: 0, scale: 0.96, filter: "blur(16px)" } : { opacity: 0, y: -20, filter: "blur(16px)" };
2044
+ return gsap.fromTo(items, start, {
2045
+ opacity: 1,
2046
+ y: 0,
2047
+ scale: 1,
2048
+ filter: "blur(0px)",
2049
+ duration: duration ?? (from === "pop" ? 0.3 : 0.5),
2050
+ ease: from === "pop" ? EASE.pop : "power2.out",
2051
+ stagger,
2052
+ delay,
2053
+ clearProps: "opacity,transform,filter"
2054
+ });
2055
+ }
2056
+ function blurOut(targets, { to = "up", onComplete } = {}) {
2057
+ const items = list2(targets);
2058
+ if (!items.length) return null;
2059
+ if (!live()) {
2060
+ onComplete?.();
2061
+ return null;
2105
2062
  }
2106
- const emit = (type, cancelable = false, detail = {}) => dialog.dispatchEvent(new CustomEvent(type, { bubbles: true, cancelable, detail: { dialog, ...detail } }));
2107
- const endSession = () => {
2108
- for (const cleanup of session.splice(0).reverse()) cleanup();
2109
- };
2110
- const settleFloating = () => {
2111
- if (!floating) return;
2112
- floating = false;
2113
- if (typeof dialog.hidePopover === "function" && dialog.hasAttribute("popover")) {
2114
- try {
2115
- dialog.hidePopover();
2116
- } catch {
2117
- }
2118
- }
2119
- dialog.removeAttribute("popover");
2120
- unplaceWindow(dialog);
2121
- if (handle) {
2122
- handle.setAttribute("aria-pressed", "false");
2123
- handle.setAttribute("aria-label", labels.float);
2124
- }
2125
- };
2126
- const closedQuietly = () => {
2127
- stopMorph(dialog);
2128
- endSession();
2129
- isOpen = false;
2130
- closing = false;
2131
- showOrigin(opener);
2132
- releaseShared(opener);
2133
- emit("mk:closed");
2134
- options.onClose?.();
2135
- };
2136
- const lift = () => {
2137
- if (!floatKey || floating || !isOpen || !floatingAvailable()) return;
2138
- const box = dialog.getBoundingClientRect();
2139
- const rect = savedFloat(floatKey) ?? { top: box.top, left: box.left, width: box.width, height: box.height };
2140
- const focused = document.activeElement;
2141
- const backdropStyle = getComputedStyle(dialog, "::backdrop");
2142
- const veil = document.createElement("div");
2143
- veil.setAttribute("aria-hidden", "true");
2144
- Object.assign(veil.style, {
2145
- position: "fixed",
2146
- inset: "0",
2147
- background: backdropStyle.background || backdropStyle.backgroundColor,
2148
- backdropFilter: backdropStyle.backdropFilter,
2149
- pointerEvents: "none"
2150
- });
2151
- closeNatively();
2152
- document.body.append(veil);
2153
- dialog.setAttribute("popover", "manual");
2154
- if (typeof dialog.showPopover === "function") dialog.showPopover();
2155
- else openModal(dialog, false);
2156
- liftWindow(dialog, rect);
2157
- gsap.to(veil, { opacity: 0, duration: reduced() ? 0 : TIMING.float.shadow, ease: EASE.signature, onComplete: () => veil.remove() });
2158
- floating = true;
2159
- if (handle) {
2160
- handle.setAttribute("aria-pressed", "true");
2161
- handle.setAttribute("aria-label", labels.dock);
2162
- }
2163
- showOrigin(opener, { fade: true });
2164
- if (focused instanceof HTMLElement && dialog.contains(focused)) focused.focus();
2165
- };
2166
- const dock = () => {
2167
- if (!floatKey || !floating) return;
2168
- const box = dialog.getBoundingClientRect();
2169
- const focused = document.activeElement;
2170
- floating = false;
2171
- if (typeof dialog.hidePopover === "function") dialog.hidePopover();
2172
- dialog.removeAttribute("popover");
2173
- closeNatively();
2174
- openModal(dialog, modal);
2175
- dockWindow(dialog, { top: box.top, left: box.left, width: box.width, height: box.height });
2176
- if (backdrop) void fadeBackdrop(dialog, "in");
2177
- forgetFloat(floatKey);
2178
- if (handle) {
2179
- handle.setAttribute("aria-pressed", "false");
2180
- handle.setAttribute("aria-label", labels.float);
2181
- }
2182
- if (focused instanceof HTMLElement && dialog.contains(focused)) focused.focus();
2183
- };
2184
- const anchorBox = () => options.anchor ? options.anchor() : opener?.isConnected ? opener.getBoundingClientRect() : null;
2185
- const startSession = () => {
2186
- if (drawer && modal) {
2187
- const root = document.documentElement;
2188
- const overflow = root.style.overflow;
2189
- root.style.overflow = "hidden";
2190
- session.push(() => {
2191
- root.style.overflow = overflow;
2192
- if (root.getAttribute("style") === "") root.removeAttribute("style");
2193
- });
2194
- }
2195
- if (sheet) {
2196
- const behind = [...document.querySelectorAll("[data-mk-underlay]")];
2197
- pushUnderlay(behind);
2198
- const root = document.documentElement;
2199
- const overflow = root.style.overflow;
2200
- root.style.overflow = "hidden";
2201
- session.push(() => {
2202
- root.style.overflow = overflow;
2203
- if (root.getAttribute("style") === "") root.removeAttribute("style");
2204
- releaseUnderlay(behind, !tearingDown);
2205
- });
2206
- }
2207
- if (autoResize && typeof ResizeObserver === "function") {
2208
- let last = dialog.offsetHeight;
2209
- let resizing = null;
2210
- const observer = new ResizeObserver(() => {
2211
- if (resizing?.isActive()) return;
2212
- const next = dialog.offsetHeight;
2213
- const previous = last;
2214
- last = next;
2215
- if (floating || Math.abs(next - previous) < 2 || !previous || isMorphing(dialog) || reduced()) return;
2216
- resizing = gsap.fromTo(
2217
- dialog,
2218
- { height: previous },
2219
- {
2220
- height: next,
2221
- duration: TIMING.dialog.autoResize,
2222
- ease: EASE.signature,
2223
- clearProps: "height",
2224
- onComplete: () => {
2225
- last = dialog.offsetHeight;
2226
- }
2227
- }
2228
- );
2229
- });
2230
- observer.observe(dialog);
2231
- session.push(() => {
2232
- observer.disconnect();
2233
- resizing?.kill();
2234
- clearStyles([dialog], ["height"]);
2235
- });
2236
- }
2237
- if (drag) {
2238
- session.push(
2239
- attachDragDismiss(dialog, {
2240
- canDrag: () => !isMorphing(dialog) && !floating && !closing && isOpen,
2241
- onDismiss: () => close(true)
2242
- })
2243
- );
2244
- }
2245
- if (placement === "anchor") {
2246
- const onResize = () => {
2247
- if (isOpen && !floating) anchorSurface(dialog, anchorBox());
2248
- };
2249
- addEventListener("resize", onResize);
2250
- session.push(() => {
2251
- removeEventListener("resize", onResize);
2252
- clearAnchor(dialog);
2253
- });
2254
- }
2255
- if (floatKey && handle) {
2256
- session.push(attachFloating(dialog, { key: floatKey, handle, corners, isFloating: () => floating, float: lift, dock }));
2257
- const onResize = () => {
2258
- if (floating && !floatingAvailable()) dock();
2259
- };
2260
- addEventListener("resize", onResize);
2261
- session.push(() => removeEventListener("resize", onResize));
2262
- }
2263
- };
2264
- const open = (origin) => {
2265
- if (destroyed || isOpen) return;
2266
- const active = document.activeElement;
2267
- opener = origin !== void 0 ? origin : active instanceof HTMLElement && active !== document.body && !dialog.contains(active) ? active : null;
2268
- closing = false;
2269
- isOpen = true;
2270
- openModal(dialog, modal);
2271
- if (placement === "anchor") anchorSurface(dialog, anchorBox());
2272
- if (backdrop && modal) void fadeBackdrop(dialog, "in");
2273
- if (sheet) sheetOpen(dialog);
2274
- else if (drawer) slideOpen(dialog);
2275
- else morphOpen(dialog, opener, { hideOrigin: true, liquid, content: options.animateContent === false ? ":scope > :not(*)" : void 0 });
2276
- startSession();
2277
- dialog.querySelector(FIELDS)?.focus({ preventScroll: true });
2278
- emit("mk:open", false, { origin: opener });
2279
- options.onOpen?.();
2280
- };
2281
- const close = (inPlace = false) => {
2282
- if (destroyed || !isOpen || closing) return;
2283
- if (!emit("mk:close", true, { inPlace })) return;
2284
- closing = true;
2285
- if (sheet) sheetClose(dialog, { inPlace });
2286
- else if (drawer) slideClose(dialog);
2287
- else morphCloseWithGhost(dialog, opener, { inPlace, liquid });
2288
- endSession();
2289
- if (floating) settleFloating();
2290
- if (dialog.hasAttribute("open")) closeModal(dialog);
2291
- isOpen = false;
2292
- closing = false;
2293
- if (opener?.isConnected) opener.focus();
2294
- emit("mk:closed");
2295
- options.onClose?.();
2296
- };
2297
- scope.on(dialog, "cancel", (event) => {
2298
- event.preventDefault();
2299
- close();
2063
+ const end = to === "left" ? { x: -64 } : to === "down" ? { y: 24 } : { y: -20 };
2064
+ return gsap.to(items, { ...end, opacity: 0, filter: "blur(16px)", duration: 0.5, ease: "power2.out", onComplete });
2065
+ }
2066
+ function collapse(el5, { onComplete } = {}) {
2067
+ if (!el5) return null;
2068
+ if (!live()) {
2069
+ onComplete?.();
2070
+ return null;
2071
+ }
2072
+ return gsap.to(el5, {
2073
+ height: 0,
2074
+ paddingTop: 0,
2075
+ paddingBottom: 0,
2076
+ marginTop: 0,
2077
+ marginBottom: 0,
2078
+ opacity: 0,
2079
+ filter: "blur(16px)",
2080
+ overflow: "hidden",
2081
+ duration: 0.25,
2082
+ ease: "power2.in",
2083
+ onComplete
2300
2084
  });
2301
- scope.on(dialog, "close", () => {
2302
- if (ownCloses > 0) {
2303
- ownCloses -= 1;
2304
- return;
2305
- }
2306
- if (!isOpen || closing) return;
2307
- closedQuietly();
2085
+ }
2086
+ function shake(el5, distance = 4) {
2087
+ if (!el5 || !live()) return null;
2088
+ gsap.killTweensOf(el5, "x");
2089
+ return gsap.to(el5, {
2090
+ keyframes: { x: [0, -distance, distance, -distance, 0] },
2091
+ duration: 0.5,
2092
+ ease: EASE.shake,
2093
+ clearProps: "x,transform"
2308
2094
  });
2309
- scope.on(dialog, "keydown", (event) => {
2310
- if (event.key === "Escape" && floating) {
2311
- event.preventDefault();
2312
- close();
2095
+ }
2096
+ function ringPulse(el5, color = "var(--mk-accent-soft)") {
2097
+ if (!el5 || !live()) return null;
2098
+ const before = { color: el5.style.outlineColor, style: el5.style.outlineStyle, offset: el5.style.outlineOffset };
2099
+ el5.style.outlineColor = color;
2100
+ el5.style.outlineStyle = "solid";
2101
+ el5.style.outlineOffset = "-4px";
2102
+ const restore = () => {
2103
+ el5.style.outlineColor = before.color;
2104
+ el5.style.outlineStyle = before.style;
2105
+ el5.style.outlineOffset = before.offset;
2106
+ el5.style.removeProperty("outline-width");
2107
+ if (el5.getAttribute("style") === "") el5.removeAttribute("style");
2108
+ };
2109
+ return gsap.fromTo(el5, { outlineWidth: 0 }, { keyframes: { outlineWidth: [0, 4, 0] }, duration: 1, ease: "power1.inOut", onComplete: restore, onInterrupt: restore });
2110
+ }
2111
+ function burst(origin, { count = 7, distance = 28, colors = ["var(--mk-accent)"], ring = true, size = 6 } = {}) {
2112
+ if (!origin || !live()) return null;
2113
+ const layer = document.createElement("span");
2114
+ layer.setAttribute("aria-hidden", "true");
2115
+ layer.dataset.mkBurst = "";
2116
+ Object.assign(layer.style, { position: "absolute", inset: "0", pointerEvents: "none", overflow: "visible", display: "grid", placeItems: "center" });
2117
+ const positioned = getComputedStyle(origin).position !== "static";
2118
+ const previousPosition = origin.style.position;
2119
+ if (!positioned) origin.style.position = "relative";
2120
+ origin.append(layer);
2121
+ const cleanup = () => {
2122
+ layer.remove();
2123
+ if (!positioned) origin.style.position = previousPosition;
2124
+ if (origin.getAttribute("style") === "") origin.removeAttribute("style");
2125
+ };
2126
+ const timeline = gsap.timeline({ onComplete: cleanup, onInterrupt: cleanup });
2127
+ if (ring) {
2128
+ const circle = document.createElement("span");
2129
+ Object.assign(circle.style, { position: "absolute", width: "100%", aspectRatio: "1", borderRadius: "50%", border: `2px solid ${colors[0]}` });
2130
+ layer.append(circle);
2131
+ timeline.fromTo(circle, { scale: 0.3, opacity: 0.9 }, { scale: 1.6, opacity: 0, duration: 0.5, ease: "power2.out" }, 0);
2132
+ }
2133
+ for (let i = 0; i < count; i++) {
2134
+ const angle2 = i / count * Math.PI * 2 - Math.PI / 2;
2135
+ for (const [k, scale] of [[0, 1], [1, 0.6]]) {
2136
+ const dot = document.createElement("span");
2137
+ Object.assign(dot.style, {
2138
+ position: "absolute",
2139
+ width: `${size * scale}px`,
2140
+ height: `${size * scale}px`,
2141
+ borderRadius: "50%",
2142
+ background: colors[(i + k) % colors.length]
2143
+ });
2144
+ layer.append(dot);
2145
+ const reach = distance * (k ? 0.72 : 1);
2146
+ const turn = k ? 0.32 : 0;
2147
+ timeline.fromTo(
2148
+ dot,
2149
+ { x: 0, y: 0, scale: 0, opacity: 1 },
2150
+ { x: Math.cos(angle2 + turn) * reach, y: Math.sin(angle2 + turn) * reach, scale: 1, duration: 0.45, ease: "power3.out" },
2151
+ 0.05
2152
+ );
2153
+ timeline.to(dot, { scale: 0, opacity: 0, duration: 0.3, ease: "power2.in" }, 0.38);
2313
2154
  }
2314
- });
2315
- scope.on(dialog, "click", (event) => {
2316
- const target = event.target;
2317
- if (target?.closest('[data-mk-part="close"], [data-mk-close]') && dialog.contains(target)) {
2318
- close();
2319
- return;
2155
+ }
2156
+ return timeline;
2157
+ }
2158
+ var rolling = /* @__PURE__ */ new WeakMap();
2159
+ function rollDigits(el5, text, direction = 1, duration = 0.5) {
2160
+ if (!el5) return null;
2161
+ rolling.get(el5)?.progress(1).kill();
2162
+ rolling.delete(el5);
2163
+ const previous = el5.textContent ?? "";
2164
+ if (previous === text || !live()) {
2165
+ el5.textContent = text;
2166
+ return null;
2167
+ }
2168
+ const width = Math.max(previous.length, text.length);
2169
+ const oldChars = previous.padStart(width, " ");
2170
+ const newChars = text.padStart(width, " ");
2171
+ el5.textContent = "";
2172
+ const label = document.createElement("span");
2173
+ label.className = "mk-sr-only";
2174
+ label.textContent = text;
2175
+ const visual = document.createElement("span");
2176
+ visual.setAttribute("aria-hidden", "true");
2177
+ visual.style.display = "inline-flex";
2178
+ const moving = [];
2179
+ const padding = Math.min(width - previous.length, width - text.length);
2180
+ for (let i = padding; i < width; i++) {
2181
+ const before = oldChars[i];
2182
+ const after = newChars[i];
2183
+ const cell = document.createElement("span");
2184
+ Object.assign(cell.style, { position: "relative", display: "inline-block", overflow: "hidden", whiteSpace: "pre" });
2185
+ const next = document.createElement("span");
2186
+ next.style.display = "inline-block";
2187
+ next.textContent = after;
2188
+ cell.append(next);
2189
+ if (before !== after) {
2190
+ const old = document.createElement("span");
2191
+ Object.assign(old.style, { position: "absolute", left: "0", top: "0", display: "inline-block" });
2192
+ old.textContent = before;
2193
+ cell.append(old);
2194
+ moving.push([old, next]);
2320
2195
  }
2321
- if (target !== dialog || !closeOnBackdrop || floating) return;
2322
- const mouse = event;
2323
- const box = dialog.getBoundingClientRect();
2324
- if (mouse.clientX < box.left || mouse.clientX > box.right || mouse.clientY < box.top || mouse.clientY > box.bottom) close();
2325
- });
2326
- const triggerId = triggers === true ? dialog.id : triggers || "";
2327
- if (triggerId) {
2328
- const selector = `[data-mk-open="${typeof CSS !== "undefined" && CSS.escape ? CSS.escape(triggerId) : triggerId}"]`;
2329
- scope.on(document, "click", (event) => {
2330
- const trigger = event.target?.closest(selector);
2331
- if (!trigger || dialog.contains(trigger)) return;
2332
- event.preventDefault();
2333
- if (isOpen) close();
2334
- else open(trigger);
2335
- });
2196
+ visual.append(cell);
2336
2197
  }
2337
- dialog.dataset.mkReady = "";
2338
- return {
2339
- open,
2340
- close: () => close(),
2341
- toggle: (origin) => isOpen ? close() : open(origin),
2342
- float: lift,
2343
- dock,
2344
- get isOpen() {
2345
- return isOpen;
2346
- },
2347
- get isFloating() {
2348
- return floating;
2349
- },
2350
- element: dialog,
2351
- destroy() {
2352
- if (destroyed) return;
2353
- tearingDown = true;
2354
- if (isOpen) {
2355
- settleFloating();
2356
- closing = true;
2357
- if (dialog.hasAttribute("open")) closeModal(dialog);
2358
- closedQuietly();
2359
- }
2360
- destroyed = true;
2361
- endSession();
2362
- gsap.killTweensOf(dialog);
2363
- clearStyles([dialog], [...MORPH_STYLES, "height"]);
2364
- scope.dispose();
2365
- delete dialog.dataset.mkReady;
2198
+ el5.append(label, visual);
2199
+ const timeline = gsap.timeline({
2200
+ onComplete: () => {
2201
+ el5.textContent = text;
2202
+ rolling.delete(el5);
2366
2203
  }
2367
- };
2204
+ });
2205
+ moving.forEach(([old, next], i) => {
2206
+ timeline.to(old, { yPercent: -100 * direction, opacity: 0, filter: "blur(4px)", duration, ease: EASE.signature }, i * 0.03);
2207
+ timeline.fromTo(next, { yPercent: 100 * direction, opacity: 0, filter: "blur(4px)" }, { yPercent: 0, opacity: 1, filter: "blur(0px)", duration, ease: EASE.signature }, i * 0.03);
2208
+ });
2209
+ rolling.set(el5, timeline);
2210
+ return timeline;
2368
2211
  }
2369
2212
 
2370
- // src/components/menu/engine.ts
2371
- var ITEM = "[data-mk-item]";
2372
- function createMenu(dialog, options = {}) {
2373
- if (!dialog) {
2374
- warnOnce("menu: missing <dialog> element");
2375
- return inert({
2376
- open() {
2377
- },
2378
- close() {
2379
- },
2380
- toggle() {
2381
- },
2382
- float() {
2383
- },
2384
- dock() {
2385
- },
2386
- isOpen: false,
2387
- isFloating: false,
2388
- element: null,
2389
- items: []
2390
- });
2213
+ // src/components/icons.ts
2214
+ var ICON_PATHS = {
2215
+ close: "M6 6l12 12M18 6L6 18",
2216
+ expand: "M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7",
2217
+ shrink: "M4 14h6v6M20 10h-6V4M10 14l-7 7M14 10l7-7",
2218
+ check: "M5 12.5l4.5 4.5L19 7.5",
2219
+ alert: "M12 8v5M12 16.5v.01M10.3 3.9L2.6 17.3a2 2 0 001.7 3h15.4a2 2 0 001.7-3L13.7 3.9a2 2 0 00-3.4 0z",
2220
+ info: "M12 11v6M12 7.5v.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",
2221
+ send: "M12 19V5M5.5 11.5L12 5l6.5 6.5",
2222
+ mic: "M12 3a3 3 0 00-3 3v6a3 3 0 006 0V6a3 3 0 00-3-3zM5.5 11a6.5 6.5 0 0013 0M12 17.5V21",
2223
+ sparkle: "M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z",
2224
+ grip: "M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01",
2225
+ toTop: "M12 20V9M6.5 14.5L12 9l5.5 5.5M6 4.5h12"
2226
+ };
2227
+ function iconSvg(name, size = 20) {
2228
+ return `<svg aria-hidden="true" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${ICON_PATHS[name]}"/></svg>`;
2229
+ }
2230
+
2231
+ // src/components/scroll-area/engine.ts
2232
+ var sequence = 0;
2233
+ var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
2234
+ function createScrollArea(root, options = {}) {
2235
+ if (!root) {
2236
+ warnOnce("scroll-area: missing root");
2237
+ return inert({ scrollTo() {
2238
+ }, refresh() {
2239
+ }, viewport: null });
2391
2240
  }
2392
- const { closeOnSelect = true } = options;
2241
+ registerMotion();
2393
2242
  const scope = createScope();
2394
- let ticketAnimation;
2395
- if (options.ticket) {
2396
- scope.attr(dialog, "data-mk-ticket", "");
2397
- scope.attr(dialog, "style", dialog.getAttribute("style"));
2398
- for (const item of dialog.querySelectorAll(ITEM)) scope.attr(item, "style", item.getAttribute("style"));
2399
- scope.add(() => ticketAnimation?.kill());
2400
- }
2401
- const items = () => [...dialog.querySelectorAll(ITEM)].filter((item) => !item.hasAttribute("disabled") && item.getAttribute("aria-disabled") !== "true");
2402
- scope.attr(dialog, "role", "menu");
2403
- const markItems = () => {
2404
- for (const item of dialog.querySelectorAll(ITEM)) {
2405
- scope.attr(item, "role", "menuitem");
2406
- scope.attr(item, "tabindex", "-1");
2407
- }
2408
- };
2409
- markItems();
2410
- const surface = createDialog(dialog, {
2411
- ...options,
2412
- placement: "anchor",
2413
- backdrop: false,
2414
- drag: false,
2415
- autoResize: false,
2416
- animateContent: false,
2417
- onOpen: () => {
2418
- markItems();
2419
- const list3 = items();
2420
- if (options.ticket && !reduced()) {
2421
- ticketAnimation?.kill();
2422
- ticketAnimation = gsap.timeline().fromTo(dialog, { clipPath: "inset(0 0 100% 0)" }, { clipPath: "inset(0 0 0% 0)", duration: TIMING.ticketMenu.open, ease: "expo.out" }).fromTo(list3, { yPercent: TIMING.ticketMenu.from }, { yPercent: 0, duration: TIMING.ticketMenu.content, stagger: TIMING.ticketMenu.stagger, ease: "expo.out" }, 0);
2423
- } else flowInMenu(list3);
2424
- list3[0]?.focus({ preventScroll: true });
2425
- options.onOpen?.();
2426
- }
2243
+ const visibility = options.visibility === "scroll" || options.visibility === "always" ? options.visibility : "hover";
2244
+ const axis = options.axis === "x" || options.axis === "y" ? options.axis : "both";
2245
+ const idle2 = Number.isFinite(options.idle) ? Math.max(0, options.idle) : TIMING.scrollArea.idleMs;
2246
+ const fade = options.fade === false ? 0 : typeof options.fade === "number" && Number.isFinite(options.fade) ? Math.max(0, options.fade) : TIMING.scrollArea.fade;
2247
+ let viewport = options.viewport && options.viewport !== root && root.contains(options.viewport) ? options.viewport : null;
2248
+ if (!viewport) {
2249
+ const own = document.createElement("div");
2250
+ own.append(...root.childNodes);
2251
+ root.append(own);
2252
+ scope.add(() => own.replaceWith(...own.childNodes));
2253
+ viewport = own;
2254
+ }
2255
+ const view = viewport;
2256
+ scope.attr(view, "style", view.getAttribute("style"));
2257
+ scope.attr(view, "data-mk-scroll-viewport", "");
2258
+ if (!options.decorative && !view.id) scope.attr(view, "id", `mk-scroll-${++sequence}`);
2259
+ if (options.focusable !== false && !view.hasAttribute("tabindex")) scope.attr(view, "tabindex", "0");
2260
+ if (options.label) {
2261
+ scope.attr(view, "role", "region");
2262
+ scope.attr(view, "aria-label", options.label);
2263
+ }
2264
+ scope.attr(root, "data-mk-scroll-area", "");
2265
+ scope.attr(root, "data-mk-scroll-axis", axis);
2266
+ if (fade) scope.attr(root, "data-mk-fade", "");
2267
+ if (getComputedStyle(root).position === "static") scope.attr(root, "data-mk-scroll-anchor", "");
2268
+ scope.attr(root, "data-mk-ready", "");
2269
+ scope.add(() => {
2270
+ for (const name of ["data-mk-active", "data-mk-dragging", "data-mk-overflow-x", "data-mk-overflow-y"]) root.removeAttribute(name);
2427
2271
  });
2428
- const select = (item) => {
2429
- const value = item.dataset.mkValue ?? item.textContent?.trim() ?? "";
2430
- dialog.dispatchEvent(new CustomEvent("mk:select", { bubbles: true, detail: { value, item } }));
2431
- options.onSelect?.(value, item);
2432
- if (closeOnSelect) surface.close();
2272
+ const effects = /* @__PURE__ */ new Set();
2273
+ const keep = (animation) => {
2274
+ if (!animation) return;
2275
+ effects.add(animation);
2276
+ for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
2433
2277
  };
2434
- scope.on(dialog, "click", (event) => {
2435
- const item = event.target?.closest(ITEM);
2436
- if (item && dialog.contains(item) && items().includes(item)) select(item);
2278
+ scope.add(() => {
2279
+ for (const effect of effects) effect.kill();
2280
+ effects.clear();
2437
2281
  });
2438
- scope.on(dialog, "keydown", (event) => {
2439
- const key2 = event.key;
2440
- const list3 = items();
2441
- if (!list3.length) return;
2442
- const at = list3.indexOf(document.activeElement);
2443
- const moves = {
2444
- ArrowDown: at < 0 ? 0 : (at + 1) % list3.length,
2445
- ArrowUp: at < 0 ? list3.length - 1 : (at - 1 + list3.length) % list3.length,
2446
- Home: 0,
2447
- End: list3.length - 1
2448
- };
2449
- if (key2 in moves) {
2450
- event.preventDefault();
2451
- list3[moves[key2]]?.focus();
2282
+ const makeBar = (which) => {
2283
+ const rail = document.createElement("div");
2284
+ rail.dataset.mkScrollRail = "";
2285
+ rail.dataset.mkAxis = which;
2286
+ if (options.decorative) rail.setAttribute("aria-hidden", "true");
2287
+ else {
2288
+ rail.setAttribute("role", "scrollbar");
2289
+ rail.setAttribute("aria-controls", view.id);
2290
+ rail.setAttribute("aria-orientation", which === "y" ? "vertical" : "horizontal");
2291
+ rail.setAttribute("aria-valuemin", "0");
2292
+ rail.setAttribute("aria-valuemax", "100");
2293
+ rail.setAttribute("aria-valuenow", "0");
2294
+ }
2295
+ rail.hidden = true;
2296
+ rail.setAttribute("data-mk-no-drag", "");
2297
+ const thumb = document.createElement("div");
2298
+ thumb.dataset.mkScrollThumb = "";
2299
+ const pill = document.createElement("span");
2300
+ pill.dataset.mkScrollPill = "";
2301
+ thumb.append(pill);
2302
+ rail.append(thumb);
2303
+ root.append(rail);
2304
+ scope.add(() => rail.remove());
2305
+ return { axis: which, rail, thumb, pill, overflow: false, track: 0, size: 0 };
2306
+ };
2307
+ const bars = (axis === "both" ? ["y", "x"] : [axis]).map(makeBar);
2308
+ let rtl = false;
2309
+ const range = (which) => Math.max(0, which === "y" ? view.scrollHeight - view.clientHeight : view.scrollWidth - view.clientWidth);
2310
+ const travelled = (which) => which === "y" ? view.scrollTop : rtl ? -view.scrollLeft : view.scrollLeft;
2311
+ const progress = (which) => {
2312
+ const total = range(which);
2313
+ return total > 0 ? clamp2(travelled(which) / total, 0, 1) : 0;
2314
+ };
2315
+ const positionAt = (which, share) => {
2316
+ const at = clamp2(share, 0, 1) * range(which);
2317
+ return which === "x" && rtl ? -at : at;
2318
+ };
2319
+ let hideTimer;
2320
+ scope.add(() => clearTimeout(hideTimer));
2321
+ let hovering = false;
2322
+ let overRail = null;
2323
+ let drag = null;
2324
+ const anyOverflow = () => bars.some((bar) => bar.overflow);
2325
+ const show = () => {
2326
+ if (!anyOverflow()) return;
2327
+ clearTimeout(hideTimer);
2328
+ root.setAttribute("data-mk-active", "");
2329
+ };
2330
+ const settle = () => {
2331
+ clearTimeout(hideTimer);
2332
+ if (visibility === "always") return;
2333
+ hideTimer = setTimeout(() => {
2334
+ if (drag || overRail || visibility === "hover" && hovering) return;
2335
+ root.removeAttribute("data-mk-active");
2336
+ }, idle2);
2337
+ };
2338
+ let held = null;
2339
+ const holdBehavior = () => {
2340
+ if (held) return;
2341
+ held = { value: view.style.getPropertyValue("scroll-behavior"), priority: view.style.getPropertyPriority("scroll-behavior") };
2342
+ view.style.setProperty("scroll-behavior", "auto", "important");
2343
+ };
2344
+ const releaseBehavior = () => {
2345
+ if (!held) return;
2346
+ if (held.value) view.style.setProperty("scroll-behavior", held.value, held.priority);
2347
+ else view.style.removeProperty("scroll-behavior");
2348
+ held = null;
2349
+ };
2350
+ let glide = null;
2351
+ const stopGlide = () => {
2352
+ if (!glide) return;
2353
+ glide.kill();
2354
+ glide = null;
2355
+ releaseBehavior();
2356
+ };
2357
+ scope.add(stopGlide);
2358
+ const glideTo = (top, left, animate = true) => {
2359
+ stopGlide();
2360
+ const to = { top: top === void 0 ? view.scrollTop : top, left: left === void 0 ? view.scrollLeft : left };
2361
+ if (!animate || reduced()) {
2362
+ view.scrollTop = to.top;
2363
+ view.scrollLeft = to.left;
2364
+ return;
2365
+ }
2366
+ holdBehavior();
2367
+ const at = { top: view.scrollTop, left: view.scrollLeft };
2368
+ glide = gsap.to(at, {
2369
+ ...to,
2370
+ duration: TIMING.scrollArea.glide,
2371
+ ease: EASE.signature,
2372
+ onUpdate: () => {
2373
+ view.scrollTop = at.top;
2374
+ view.scrollLeft = at.left;
2375
+ },
2376
+ onComplete: () => {
2377
+ glide = null;
2378
+ releaseBehavior();
2379
+ }
2380
+ });
2381
+ };
2382
+ for (const type of ["wheel", "touchstart", "keydown", "pointerdown"]) scope.on(view, type, stopGlide, { passive: true });
2383
+ let topButton = null;
2384
+ let topShown = false;
2385
+ if (options.backToTop) {
2386
+ const button2 = document.createElement("button");
2387
+ button2.type = "button";
2388
+ button2.dataset.mkScrollTop = "";
2389
+ button2.setAttribute("aria-label", "Volver arriba");
2390
+ button2.innerHTML = iconSvg("toTop", 20);
2391
+ button2.hidden = true;
2392
+ button2.setAttribute("data-mk-no-drag", "");
2393
+ root.append(button2);
2394
+ scope.add(() => button2.remove());
2395
+ scope.on(button2, "click", () => {
2396
+ keep(press(button2));
2397
+ glideTo(0, void 0);
2398
+ });
2399
+ topButton = button2;
2400
+ }
2401
+ const topThreshold = () => typeof options.backToTop === "number" && Number.isFinite(options.backToTop) ? Math.max(0, options.backToTop) : view.clientHeight;
2402
+ const toggleTop = (next) => {
2403
+ const button2 = topButton;
2404
+ if (!button2 || next === topShown) return;
2405
+ topShown = next;
2406
+ gsap.killTweensOf(button2);
2407
+ if (next) {
2408
+ gsap.set(button2, { clearProps: "opacity,transform,filter" });
2409
+ button2.hidden = false;
2410
+ keep(blurIn(button2, { from: "pop" }));
2452
2411
  return;
2453
2412
  }
2454
- const target = event.target;
2455
- if ((key2 === "Enter" || key2 === " ") && list3.includes(target) && !target.matches("button, a[href]")) {
2456
- event.preventDefault();
2457
- select(target);
2413
+ if (document.activeElement === button2) (view.hasAttribute("tabindex") ? view : root).focus({ preventScroll: true });
2414
+ const hide = () => {
2415
+ if (topShown) return;
2416
+ button2.hidden = true;
2417
+ gsap.set(button2, { clearProps: "opacity,transform,filter" });
2418
+ };
2419
+ const out = reduced() ? null : blurOut(button2, { to: "down", onComplete: hide });
2420
+ if (out) keep(out);
2421
+ else hide();
2422
+ };
2423
+ const placeOverlays = () => {
2424
+ let top = 0;
2425
+ let left = 0;
2426
+ for (let node = view; node && node !== root; ) {
2427
+ top += node.offsetTop;
2428
+ left += node.offsetLeft;
2429
+ const parent = node.offsetParent;
2430
+ node = parent && root.contains(parent) ? parent : null;
2431
+ }
2432
+ const edges = {
2433
+ top,
2434
+ left,
2435
+ right: root.clientWidth - left - view.offsetWidth,
2436
+ bottom: root.clientHeight - top - view.offsetHeight
2437
+ };
2438
+ for (const element of [...bars.map((bar) => bar.rail), topButton]) {
2439
+ if (!element) continue;
2440
+ for (const [edge, value] of Object.entries(edges)) element.style.setProperty(`--mk-scroll-view-${edge}`, `${Math.max(0, Math.round(value))}px`);
2458
2441
  }
2459
- });
2460
- return {
2461
- open: surface.open,
2462
- close: surface.close,
2463
- toggle: surface.toggle,
2464
- float: surface.float,
2465
- dock: surface.dock,
2466
- get isOpen() {
2467
- return surface.isOpen;
2468
- },
2469
- get isFloating() {
2470
- return surface.isFloating;
2471
- },
2472
- get items() {
2473
- return items();
2474
- },
2475
- element: dialog,
2476
- destroy() {
2477
- surface.destroy();
2478
- scope.dispose();
2442
+ };
2443
+ let measured = false;
2444
+ const measure = () => {
2445
+ rtl = getComputedStyle(view).direction === "rtl";
2446
+ const had = anyOverflow();
2447
+ for (const bar of bars) {
2448
+ bar.overflow = range(bar.axis) > 1;
2449
+ bar.rail.hidden = !bar.overflow;
2450
+ root.toggleAttribute(`data-mk-overflow-${bar.axis}`, bar.overflow);
2451
+ }
2452
+ placeOverlays();
2453
+ for (const bar of bars) {
2454
+ if (!bar.overflow) continue;
2455
+ const vertical = bar.axis === "y";
2456
+ bar.track = vertical ? bar.rail.clientHeight : bar.rail.clientWidth;
2457
+ const seen = vertical ? view.clientHeight : view.clientWidth;
2458
+ const total = vertical ? view.scrollHeight : view.scrollWidth;
2459
+ bar.size = clamp2(bar.track * seen / Math.max(1, total), Math.min(TIMING.scrollArea.minThumb, bar.track), bar.track);
2460
+ bar.thumb.style[vertical ? "height" : "width"] = `${bar.size}px`;
2461
+ }
2462
+ const now2 = anyOverflow();
2463
+ if (!now2) {
2464
+ clearTimeout(hideTimer);
2465
+ root.removeAttribute("data-mk-active");
2466
+ } else if (visibility === "always") show();
2467
+ else if (measured && !had) {
2468
+ show();
2469
+ settle();
2479
2470
  }
2471
+ measured = true;
2480
2472
  };
2481
- }
2482
-
2483
- // src/components/chat-background/engine.ts
2484
- var VARS = ["--mk-chat-orbit-1", "--mk-chat-orbit-2", "--mk-chat-blob-opacity", "--mk-chat-scale"];
2485
- var instances = /* @__PURE__ */ new WeakMap();
2486
- var chatBackgroundOf = (el5) => el5 ? instances.get(el5) ?? null : null;
2487
- function createChatBackground(root, options = {}) {
2488
- if (!root) {
2489
- warnOnce("chat-background: missing root");
2490
- return inert({ setEnergy() {
2491
- }, setScale() {
2492
- }, busy() {
2493
- }, energy: 0, scale: 1 });
2494
- }
2495
- registerMotion();
2496
- const scope = createScope();
2497
- const state = { energy: options.energy ?? 0, scale: options.scale ?? 1 };
2498
- let noise = root.querySelector(":scope > .mk-chat-background__noise");
2499
- if (!noise) {
2500
- noise = document.createElement("div");
2501
- noise.className = "mk-chat-background__noise";
2502
- noise.setAttribute("aria-hidden", "true");
2503
- root.append(noise);
2504
- const created = noise;
2505
- scope.add(() => created.remove());
2506
- }
2507
- scope.attr(root, "aria-hidden", "true");
2508
2473
  const paint = () => {
2509
- const e = Math.max(0, state.energy);
2510
- root.style.setProperty("--mk-chat-orbit-1", `${Math.max(1, 10 - 3.5 * e).toFixed(3)}s`);
2511
- root.style.setProperty("--mk-chat-orbit-2", `${Math.max(1, 15 - 4.5 * e).toFixed(3)}s`);
2512
- root.style.setProperty("--mk-chat-blob-opacity", (0.5 + 0.15 * e).toFixed(3));
2513
- root.style.setProperty("--mk-chat-scale", ((1 + 0.1 * e) * state.scale).toFixed(3));
2474
+ for (const bar of bars) {
2475
+ if (!bar.overflow) continue;
2476
+ const share = progress(bar.axis);
2477
+ const room = Math.max(0, bar.track - bar.size);
2478
+ const offset = bar.axis === "x" && rtl ? room * (1 - share) : room * share;
2479
+ bar.thumb.style.transform = bar.axis === "y" ? `translate3d(0, ${offset}px, 0)` : `translate3d(${offset}px, 0, 0)`;
2480
+ if (!options.decorative) bar.rail.setAttribute("aria-valuenow", String(Math.round(share * 100)));
2481
+ }
2482
+ if (fade) {
2483
+ const down = range("y");
2484
+ const across = range("x");
2485
+ const fromStart = Math.max(0, travelled("x"));
2486
+ const depth = (hidden) => `${Math.round(clamp2(hidden, 0, fade))}px`;
2487
+ view.style.setProperty("--mk-scroll-fade-top", depth(view.scrollTop));
2488
+ view.style.setProperty("--mk-scroll-fade-bottom", depth(down - view.scrollTop));
2489
+ view.style.setProperty("--mk-scroll-fade-left", depth(rtl ? across - fromStart : fromStart));
2490
+ view.style.setProperty("--mk-scroll-fade-right", depth(rtl ? fromStart : across - fromStart));
2491
+ }
2492
+ if (topButton) toggleTop(view.scrollTop > topThreshold());
2493
+ };
2494
+ let cancelFrame = null;
2495
+ const schedule = () => {
2496
+ if (cancelFrame) return;
2497
+ cancelFrame = requestFrame(() => {
2498
+ cancelFrame = null;
2499
+ if (scope.disposed) return;
2500
+ measure();
2501
+ paint();
2502
+ });
2503
+ };
2504
+ scope.add(() => cancelFrame?.());
2505
+ scope.on(
2506
+ view,
2507
+ "scroll",
2508
+ () => {
2509
+ paint();
2510
+ if (visibility !== "always") {
2511
+ show();
2512
+ settle();
2513
+ }
2514
+ const detail = { x: progress("x"), y: progress("y") };
2515
+ options.onScroll?.(detail);
2516
+ root.dispatchEvent(new CustomEvent("mk:scroll", { bubbles: true, detail }));
2517
+ },
2518
+ { passive: true }
2519
+ );
2520
+ scope.on(root, "pointerenter", (event) => {
2521
+ if (event.pointerType === "touch") return;
2522
+ hovering = true;
2523
+ if (visibility === "hover") show();
2524
+ });
2525
+ scope.on(root, "pointerleave", () => {
2526
+ hovering = false;
2527
+ settle();
2528
+ });
2529
+ for (const bar of bars) {
2530
+ const vertical = bar.axis === "y";
2531
+ scope.on(bar.rail, "pointerenter", (event) => {
2532
+ if (event.pointerType === "touch") return;
2533
+ overRail = bar.rail;
2534
+ show();
2535
+ });
2536
+ scope.on(bar.rail, "pointerleave", () => {
2537
+ if (overRail === bar.rail) overRail = null;
2538
+ settle();
2539
+ });
2540
+ scope.on(bar.thumb, "pointerdown", (event) => {
2541
+ const down = event;
2542
+ if (down.button !== 0) return;
2543
+ down.preventDefault();
2544
+ down.stopPropagation();
2545
+ stopGlide();
2546
+ holdBehavior();
2547
+ const thumbBox = bar.thumb.getBoundingClientRect();
2548
+ const railBox = bar.rail.getBoundingClientRect();
2549
+ drag = {
2550
+ bar,
2551
+ id: down.pointerId,
2552
+ offset: vertical ? down.clientY - thumbBox.top : down.clientX - thumbBox.left,
2553
+ start: vertical ? railBox.top : railBox.left
2554
+ };
2555
+ bar.rail.setAttribute("data-mk-dragging", "");
2556
+ root.setAttribute("data-mk-dragging", "");
2557
+ try {
2558
+ bar.thumb.setPointerCapture(down.pointerId);
2559
+ } catch {
2560
+ }
2561
+ show();
2562
+ keep(press(bar.pill));
2563
+ });
2564
+ scope.on(bar.rail, "pointerdown", (event) => {
2565
+ const down = event;
2566
+ if (down.button !== 0 || bar.thumb.contains(down.target)) return;
2567
+ down.preventDefault();
2568
+ const box = bar.rail.getBoundingClientRect();
2569
+ const at = vertical ? down.clientY - box.top : down.clientX - box.left;
2570
+ const share = (at - bar.size / 2) / Math.max(1, bar.track - bar.size);
2571
+ const target = positionAt(bar.axis, bar.axis === "x" && rtl ? 1 - share : share);
2572
+ if (vertical) glideTo(target, void 0);
2573
+ else glideTo(void 0, target);
2574
+ });
2575
+ }
2576
+ scope.on(window, "pointermove", (event) => {
2577
+ const move = event;
2578
+ if (!drag || move.pointerId !== drag.id) return;
2579
+ const { bar } = drag;
2580
+ const at = (bar.axis === "y" ? move.clientY : move.clientX) - drag.start - drag.offset;
2581
+ const share = at / Math.max(1, bar.track - bar.size);
2582
+ const target = positionAt(bar.axis, bar.axis === "x" && rtl ? 1 - share : share);
2583
+ if (bar.axis === "y") view.scrollTop = target;
2584
+ else view.scrollLeft = target;
2585
+ paint();
2586
+ });
2587
+ const endDrag = () => {
2588
+ if (!drag) return;
2589
+ const { bar, id } = drag;
2590
+ drag = null;
2591
+ try {
2592
+ if (bar.thumb.hasPointerCapture?.(id)) bar.thumb.releasePointerCapture(id);
2593
+ } catch {
2594
+ }
2595
+ bar.rail.removeAttribute("data-mk-dragging");
2596
+ root.removeAttribute("data-mk-dragging");
2597
+ releaseBehavior();
2598
+ if (!scope.disposed) settle();
2599
+ };
2600
+ const release = (event) => {
2601
+ if (drag && event.pointerId === drag.id) endDrag();
2514
2602
  };
2603
+ scope.on(window, "pointerup", release);
2604
+ scope.on(window, "pointercancel", release);
2605
+ for (const bar of bars) scope.on(bar.thumb, "lostpointercapture", release);
2515
2606
  scope.add(() => {
2516
- gsap.killTweensOf(state);
2517
- for (const name of VARS) root.style.removeProperty(name);
2518
- if (root.getAttribute("style") === "") root.removeAttribute("style");
2607
+ endDrag();
2608
+ releaseBehavior();
2519
2609
  });
2610
+ if (typeof ResizeObserver === "function") {
2611
+ const resize = scope.observe(new ResizeObserver(schedule));
2612
+ const watch = () => {
2613
+ resize.observe(view);
2614
+ for (const child of view.children) resize.observe(child);
2615
+ };
2616
+ watch();
2617
+ if (typeof MutationObserver === "function")
2618
+ scope.observe(
2619
+ new MutationObserver(() => {
2620
+ watch();
2621
+ schedule();
2622
+ })
2623
+ ).observe(view, { childList: true });
2624
+ }
2625
+ scope.on(window, "resize", schedule);
2626
+ measure();
2520
2627
  paint();
2521
- const instance = {
2522
- setEnergy(energy) {
2523
- state.energy = Number.isFinite(energy) ? energy : 0;
2524
- paint();
2525
- },
2526
- setScale(scale) {
2527
- state.scale = Number.isFinite(scale) ? scale : 1;
2628
+ return {
2629
+ scrollTo: ({ top, left } = {}, { animate = true } = {}) => glideTo(top, left, animate),
2630
+ refresh: () => {
2631
+ measure();
2528
2632
  paint();
2529
2633
  },
2530
- busy(on) {
2531
- const to = on ? { energy: 1.6, scale: 1.8 } : { energy: 0, scale: 1 };
2532
- gsap.killTweensOf(state);
2533
- if (reduced()) {
2534
- Object.assign(state, to);
2535
- paint();
2536
- return;
2537
- }
2538
- gsap.to(state, {
2539
- ...to,
2540
- duration: on ? TIMING.onboarding.busy : TIMING.onboarding.idle,
2541
- ease: on ? "power2.out" : "power2.inOut",
2542
- onUpdate: paint
2543
- });
2544
- },
2545
- get energy() {
2546
- return state.energy;
2547
- },
2548
- get scale() {
2549
- return state.scale;
2634
+ get viewport() {
2635
+ return view;
2550
2636
  },
2551
- destroy() {
2552
- instances.delete(root);
2553
- scope.dispose();
2554
- delete root.dataset.mkReady;
2555
- }
2637
+ destroy: () => scope.dispose()
2556
2638
  };
2557
- instances.set(root, instance);
2558
- root.dataset.mkReady = "";
2559
- return instance;
2560
2639
  }
2561
2640
 
2562
- // src/components/steps/engine.ts
2563
- var STEP2 = "[data-mk-step]";
2564
- var ITEM_STYLES = ["transform", "translate", "rotate", "scale", "filter", "opacity", "visibility"];
2565
- function createSteps(root, options = {}) {
2566
- const steps = root ? [...root.querySelectorAll(STEP2)].filter((step) => {
2567
- const outer = step.parentElement?.closest(STEP2);
2568
- return !outer || !root.contains(outer);
2569
- }) : [];
2570
- if (!root || !steps.length) {
2571
- warnOnce("steps: needs [data-mk-step] children");
2572
- return inert({ next: async () => {
2573
- }, prev: async () => {
2574
- }, goTo: async () => {
2575
- }, busy() {
2576
- }, index: -1, count: 0, steps: [] });
2641
+ // src/components/dialog/engine.ts
2642
+ var DEFAULT_LABELS = { close: "Cerrar", float: "Ventana flotante", dock: "Volver a su sitio" };
2643
+ var FIELDS = '[autofocus], input:not([type="hidden"]):not(:disabled), textarea:not(:disabled), select:not(:disabled)';
2644
+ var CORNERS = ["tl", "tr", "bl", "br"];
2645
+ var uid = 0;
2646
+ var part = (dialog, name) => dialog.querySelector(`[data-mk-part="${name}"]`);
2647
+ function createDialog(dialog, options = {}) {
2648
+ if (!dialog) {
2649
+ warnOnce("dialog: missing <dialog> element");
2650
+ return inert({ open() {
2651
+ }, close() {
2652
+ }, toggle() {
2653
+ }, float() {
2654
+ }, dock() {
2655
+ }, isOpen: false, isFloating: false, element: null });
2656
+ }
2657
+ registerMotion();
2658
+ const {
2659
+ variant = "morph",
2660
+ placement = "center",
2661
+ backdrop = true,
2662
+ closeOnBackdrop = true,
2663
+ drag = true,
2664
+ float: floatKey = false,
2665
+ autoResize = true,
2666
+ triggers = true,
2667
+ modal = true
2668
+ } = options;
2669
+ const labels = { ...DEFAULT_LABELS, ...options.labels };
2670
+ const liquid = variant === "liquid";
2671
+ const sheet = variant === "sheet";
2672
+ const drawer = variant === "drawer";
2673
+ const scope = createScope();
2674
+ let session = [];
2675
+ let opener = null;
2676
+ let isOpen = false;
2677
+ let closing = false;
2678
+ let floating = false;
2679
+ let ownCloses = 0;
2680
+ const closeNatively = () => {
2681
+ if (!dialog.hasAttribute("open")) return;
2682
+ ownCloses += 1;
2683
+ closeModal(dialog);
2684
+ };
2685
+ let destroyed = false;
2686
+ let tearingDown = false;
2687
+ if (placement !== "center") scope.attr(dialog, "data-mk-placement", placement);
2688
+ if (!backdrop) scope.attr(dialog, "data-mk-backdrop", "none");
2689
+ scope.attr(dialog, "data-mk-variant", variant);
2690
+ const title = part(dialog, "title");
2691
+ if (title && !dialog.hasAttribute("aria-label") && !dialog.hasAttribute("aria-labelledby")) {
2692
+ if (!title.id) scope.attr(title, "id", `mk-dialog-title-${++uid}`);
2693
+ scope.attr(dialog, "aria-labelledby", title.id);
2694
+ }
2695
+ const description = part(dialog, "description");
2696
+ if (description && !dialog.hasAttribute("aria-describedby")) {
2697
+ if (!description.id) scope.attr(description, "id", `mk-dialog-description-${++uid}`);
2698
+ scope.attr(dialog, "aria-describedby", description.id);
2699
+ }
2700
+ const closeButton = part(dialog, "close");
2701
+ if (closeButton && !closeButton.hasAttribute("aria-label") && !closeButton.textContent?.trim()) {
2702
+ scope.attr(closeButton, "aria-label", labels.close);
2703
+ }
2704
+ const handle = floatKey ? part(dialog, "handle") : null;
2705
+ if (handle) {
2706
+ scope.attr(handle, "data-mk-no-drag", "");
2707
+ scope.attr(handle, "aria-pressed", "false");
2708
+ scope.attr(handle, "aria-label", labels.float);
2709
+ }
2710
+ const corners = [];
2711
+ if (floatKey) {
2712
+ for (const corner of CORNERS) {
2713
+ const element = document.createElement("span");
2714
+ element.className = "mk-float-corner";
2715
+ element.dataset.mkFloatCorner = corner;
2716
+ element.dataset.mkNoDrag = "";
2717
+ element.setAttribute("aria-hidden", "true");
2718
+ dialog.append(element);
2719
+ corners.push(element);
2720
+ }
2721
+ scope.add(() => corners.forEach((corner) => corner.remove()));
2577
2722
  }
2578
- registerMotion();
2579
- const scope = createScope();
2580
- const { duration = TIMING.onboarding.step, animateFirst = true, target = "[data-mk-flow-item]" } = options;
2581
- const clamp5 = (value) => Math.min(steps.length - 1, Math.max(0, Math.round(value)));
2582
- const marked3 = steps.findIndex((step) => step.hasAttribute("data-mk-current"));
2583
- let index = clamp5(options.index ?? (marked3 >= 0 ? marked3 : 0));
2584
- let wanted = index;
2585
- let running2 = null;
2586
- let stopCounter = () => {
2723
+ const emit = (type, cancelable = false, detail = {}) => dialog.dispatchEvent(new CustomEvent(type, { bubbles: true, cancelable, detail: { dialog, ...detail } }));
2724
+ const endSession = () => {
2725
+ for (const cleanup of session.splice(0).reverse()) cleanup();
2587
2726
  };
2588
- const itemsOf = (step) => {
2589
- const marked4 = [...step.querySelectorAll(target)];
2590
- return marked4.length ? marked4 : [...step.children];
2727
+ const settleFloating = () => {
2728
+ if (!floating) return;
2729
+ floating = false;
2730
+ if (typeof dialog.hidePopover === "function" && dialog.hasAttribute("popover")) {
2731
+ try {
2732
+ dialog.hidePopover();
2733
+ } catch {
2734
+ }
2735
+ }
2736
+ dialog.removeAttribute("popover");
2737
+ unplaceWindow(dialog);
2738
+ if (handle) {
2739
+ handle.setAttribute("aria-pressed", "false");
2740
+ handle.setAttribute("aria-label", labels.float);
2741
+ }
2591
2742
  };
2592
- const show = (current3) => {
2593
- steps.forEach((step, i) => {
2594
- scope.attr(step, "hidden", i === current3 ? null : "");
2595
- scope.attr(step, "data-mk-current", i === current3 ? "" : null);
2596
- });
2743
+ const closedQuietly = () => {
2744
+ stopMorph(dialog);
2745
+ endSession();
2746
+ isOpen = false;
2747
+ closing = false;
2748
+ showOrigin(opener);
2749
+ releaseShared(opener);
2750
+ emit("mk:closed");
2751
+ options.onClose?.();
2597
2752
  };
2598
- const counter = () => {
2599
- const el5 = root.querySelector("[data-mk-counter]");
2600
- if (!el5) return;
2601
- stopCounter();
2602
- stopCounter = revealCounter(el5, index + 1, { duration: TIMING.onboarding.counter });
2753
+ const lift = () => {
2754
+ if (!floatKey || floating || !isOpen || !floatingAvailable()) return;
2755
+ const box = dialog.getBoundingClientRect();
2756
+ const rect = savedFloat(floatKey) ?? { top: box.top, left: box.left, width: box.width, height: box.height };
2757
+ const focused = document.activeElement;
2758
+ const backdropStyle = getComputedStyle(dialog, "::backdrop");
2759
+ const veil = document.createElement("div");
2760
+ veil.setAttribute("aria-hidden", "true");
2761
+ Object.assign(veil.style, {
2762
+ position: "fixed",
2763
+ inset: "0",
2764
+ background: backdropStyle.background || backdropStyle.backgroundColor,
2765
+ backdropFilter: backdropStyle.backdropFilter,
2766
+ pointerEvents: "none"
2767
+ });
2768
+ closeNatively();
2769
+ document.body.append(veil);
2770
+ dialog.setAttribute("popover", "manual");
2771
+ if (typeof dialog.showPopover === "function") dialog.showPopover();
2772
+ else openModal(dialog, false);
2773
+ liftWindow(dialog, rect);
2774
+ gsap.to(veil, { opacity: 0, duration: reduced() ? 0 : TIMING.float.shadow, ease: EASE.signature, onComplete: () => veil.remove() });
2775
+ floating = true;
2776
+ if (handle) {
2777
+ handle.setAttribute("aria-pressed", "true");
2778
+ handle.setAttribute("aria-label", labels.dock);
2779
+ }
2780
+ showOrigin(opener, { fade: true });
2781
+ if (focused instanceof HTMLElement && dialog.contains(focused)) focused.focus();
2603
2782
  };
2604
- const focusTitle = (step) => {
2605
- const title = step.querySelector("[data-mk-step-title]") ?? step.querySelector("h1, h2, h3, h4, h5, h6");
2606
- if (!title) return;
2607
- if (!title.hasAttribute("tabindex") && title.tabIndex < 0) scope.attr(title, "tabindex", "-1");
2608
- title.focus({ preventScroll: true });
2783
+ const dock = () => {
2784
+ if (!floatKey || !floating) return;
2785
+ const box = dialog.getBoundingClientRect();
2786
+ const focused = document.activeElement;
2787
+ floating = false;
2788
+ if (typeof dialog.hidePopover === "function") dialog.hidePopover();
2789
+ dialog.removeAttribute("popover");
2790
+ closeNatively();
2791
+ openModal(dialog, modal);
2792
+ dockWindow(dialog, { top: box.top, left: box.left, width: box.width, height: box.height });
2793
+ if (backdrop) void fadeBackdrop(dialog, "in");
2794
+ forgetFloat(floatKey);
2795
+ if (handle) {
2796
+ handle.setAttribute("aria-pressed", "false");
2797
+ handle.setAttribute("aria-label", labels.float);
2798
+ }
2799
+ if (focused instanceof HTMLElement && dialog.contains(focused)) focused.focus();
2609
2800
  };
2610
- const change = async () => {
2611
- try {
2612
- while (wanted !== index && !scope.disposed) {
2613
- const previous = index;
2614
- const next = wanted;
2615
- const out = reduced() ? null : flowOut(itemsOf(steps[previous]), { duration });
2616
- if (out) await out;
2617
- if (scope.disposed) return;
2618
- index = next;
2619
- show(index);
2620
- const step = steps[index];
2621
- await nextFrame();
2622
- if (scope.disposed) return;
2623
- const items = itemsOf(step);
2624
- clearStyles(items, ["visibility"]);
2625
- flowIn(items, { duration, autoAlpha: false });
2626
- counter();
2627
- focusTitle(step);
2628
- root.dispatchEvent(new CustomEvent("mk:step", { bubbles: true, detail: { index, previous, step } }));
2629
- options.onChange?.(index, previous);
2630
- }
2631
- } finally {
2632
- running2 = null;
2801
+ const anchorBox = () => options.anchor ? options.anchor() : opener?.isConnected ? opener.getBoundingClientRect() : null;
2802
+ const startSession = () => {
2803
+ if (drawer && modal) {
2804
+ const root = document.documentElement;
2805
+ const overflow = root.style.overflow;
2806
+ root.style.overflow = "hidden";
2807
+ session.push(() => {
2808
+ root.style.overflow = overflow;
2809
+ if (root.getAttribute("style") === "") root.removeAttribute("style");
2810
+ });
2811
+ }
2812
+ if (sheet) {
2813
+ const behind = [...document.querySelectorAll("[data-mk-underlay]")];
2814
+ pushUnderlay(behind);
2815
+ const root = document.documentElement;
2816
+ const overflow = root.style.overflow;
2817
+ root.style.overflow = "hidden";
2818
+ session.push(() => {
2819
+ root.style.overflow = overflow;
2820
+ if (root.getAttribute("style") === "") root.removeAttribute("style");
2821
+ releaseUnderlay(behind, !tearingDown);
2822
+ });
2823
+ }
2824
+ if (autoResize && typeof ResizeObserver === "function") {
2825
+ let last = dialog.offsetHeight;
2826
+ let resizing = null;
2827
+ const observer = new ResizeObserver(() => {
2828
+ if (resizing?.isActive()) return;
2829
+ const next = dialog.offsetHeight;
2830
+ const previous = last;
2831
+ last = next;
2832
+ if (floating || Math.abs(next - previous) < 2 || !previous || isMorphing(dialog) || reduced()) return;
2833
+ resizing = gsap.fromTo(
2834
+ dialog,
2835
+ { height: previous },
2836
+ {
2837
+ height: next,
2838
+ duration: TIMING.dialog.autoResize,
2839
+ ease: EASE.signature,
2840
+ clearProps: "height",
2841
+ onComplete: () => {
2842
+ last = dialog.offsetHeight;
2843
+ }
2844
+ }
2845
+ );
2846
+ });
2847
+ observer.observe(dialog);
2848
+ session.push(() => {
2849
+ observer.disconnect();
2850
+ resizing?.kill();
2851
+ clearStyles([dialog], ["height"]);
2852
+ });
2853
+ }
2854
+ if (drag) {
2855
+ session.push(
2856
+ attachDragDismiss(dialog, {
2857
+ canDrag: () => !isMorphing(dialog) && !floating && !closing && isOpen,
2858
+ onDismiss: () => close(true)
2859
+ })
2860
+ );
2861
+ }
2862
+ if (placement === "anchor") {
2863
+ const onResize = () => {
2864
+ if (isOpen && !floating) anchorSurface(dialog, anchorBox());
2865
+ };
2866
+ addEventListener("resize", onResize);
2867
+ session.push(() => {
2868
+ removeEventListener("resize", onResize);
2869
+ clearAnchor(dialog);
2870
+ });
2871
+ }
2872
+ if (floatKey && handle) {
2873
+ session.push(attachFloating(dialog, { key: floatKey, handle, corners, isFloating: () => floating, float: lift, dock }));
2874
+ const onResize = () => {
2875
+ if (floating && !floatingAvailable()) dock();
2876
+ };
2877
+ addEventListener("resize", onResize);
2878
+ session.push(() => removeEventListener("resize", onResize));
2633
2879
  }
2634
2880
  };
2635
- const goTo = (to) => {
2636
- wanted = clamp5(to);
2637
- if (wanted === index && !running2) return Promise.resolve();
2638
- running2 ??= change();
2639
- return running2;
2881
+ const open = (origin) => {
2882
+ if (destroyed || isOpen) return;
2883
+ const active = document.activeElement;
2884
+ opener = origin !== void 0 ? origin : active instanceof HTMLElement && active !== document.body && !dialog.contains(active) ? active : null;
2885
+ closing = false;
2886
+ isOpen = true;
2887
+ openModal(dialog, modal);
2888
+ if (placement === "anchor") anchorSurface(dialog, anchorBox());
2889
+ if (backdrop && modal) void fadeBackdrop(dialog, "in");
2890
+ if (sheet) sheetOpen(dialog);
2891
+ else if (drawer) slideOpen(dialog);
2892
+ else morphOpen(dialog, opener, { hideOrigin: true, liquid, content: options.animateContent === false ? ":scope > :not(*)" : void 0 });
2893
+ startSession();
2894
+ attachScroll();
2895
+ dialog.querySelector(FIELDS)?.focus({ preventScroll: true });
2896
+ emit("mk:open", false, { origin: opener });
2897
+ options.onOpen?.();
2640
2898
  };
2641
- show(index);
2642
- scope.add(() => {
2643
- stopCounter();
2644
- for (const step of steps) {
2645
- const items = itemsOf(step);
2646
- gsap.killTweensOf(items);
2647
- clearStyles(items, ITEM_STYLES);
2899
+ const close = (inPlace = false) => {
2900
+ if (destroyed || !isOpen || closing) return;
2901
+ if (!emit("mk:close", true, { inPlace })) return;
2902
+ closing = true;
2903
+ if (sheet) sheetClose(dialog, { inPlace });
2904
+ else if (drawer) slideClose(dialog);
2905
+ else morphCloseWithGhost(dialog, opener, { inPlace, liquid });
2906
+ endSession();
2907
+ if (floating) settleFloating();
2908
+ if (dialog.hasAttribute("open")) closeModal(dialog);
2909
+ isOpen = false;
2910
+ closing = false;
2911
+ if (opener?.isConnected) opener.focus();
2912
+ emit("mk:closed");
2913
+ options.onClose?.();
2914
+ };
2915
+ scope.on(dialog, "cancel", (event) => {
2916
+ event.preventDefault();
2917
+ close();
2918
+ });
2919
+ scope.on(dialog, "close", () => {
2920
+ if (ownCloses > 0) {
2921
+ ownCloses -= 1;
2922
+ return;
2923
+ }
2924
+ if (!isOpen || closing) return;
2925
+ closedQuietly();
2926
+ });
2927
+ scope.on(dialog, "keydown", (event) => {
2928
+ if (event.key === "Escape" && floating) {
2929
+ event.preventDefault();
2930
+ close();
2648
2931
  }
2649
2932
  });
2650
- scope.on(root, "click", (event) => {
2651
- const trigger = event.target?.closest("[data-mk-step-next], [data-mk-step-prev], [data-mk-step-goto]");
2652
- if (!trigger || !root.contains(trigger)) return;
2653
- if (trigger.hasAttribute("data-mk-step-next")) void goTo(wanted + 1);
2654
- else if (trigger.hasAttribute("data-mk-step-prev")) void goTo(wanted - 1);
2655
- else void goTo(Number(trigger.dataset.mkStepGoto) - 1);
2933
+ scope.on(dialog, "click", (event) => {
2934
+ const target = event.target;
2935
+ if (target?.closest('[data-mk-part="close"], [data-mk-close]') && dialog.contains(target)) {
2936
+ close();
2937
+ return;
2938
+ }
2939
+ if (target !== dialog || !closeOnBackdrop || floating) return;
2940
+ const mouse = event;
2941
+ const box = dialog.getBoundingClientRect();
2942
+ if (mouse.clientX < box.left || mouse.clientX > box.right || mouse.clientY < box.top || mouse.clientY > box.bottom) close();
2656
2943
  });
2657
- const counterEl = root.querySelector("[data-mk-counter]");
2658
- if (counterEl) {
2659
- const text = counterEl.textContent;
2660
- counterEl.textContent = String(index + 1);
2661
- scope.add(() => {
2662
- counterEl.textContent = text;
2944
+ const triggerId = triggers === true ? dialog.id : triggers || "";
2945
+ if (triggerId) {
2946
+ const selector = `[data-mk-open="${typeof CSS !== "undefined" && CSS.escape ? CSS.escape(triggerId) : triggerId}"]`;
2947
+ scope.on(document, "click", (event) => {
2948
+ const trigger = event.target?.closest(selector);
2949
+ if (!trigger || dialog.contains(trigger)) return;
2950
+ event.preventDefault();
2951
+ if (isOpen) close();
2952
+ else open(trigger);
2663
2953
  });
2664
2954
  }
2665
- if (animateFirst && entrances()) flowIn(itemsOf(steps[index]), { duration });
2666
- root.dataset.mkReady = "";
2955
+ dialog.dataset.mkReady = "";
2956
+ let bodyScroll = null;
2957
+ function attachScroll() {
2958
+ const body = part(dialog, "body");
2959
+ if (bodyScroll && bodyScroll.body === body) return bodyScroll.area.refresh();
2960
+ bodyScroll?.area.destroy();
2961
+ bodyScroll = body ? { body, area: createScrollArea(dialog, { viewport: body, axis: "y", focusable: false, decorative: true }) } : null;
2962
+ }
2963
+ attachScroll();
2964
+ scope.add(() => bodyScroll?.area.destroy());
2667
2965
  return {
2668
- next: () => goTo(wanted + 1),
2669
- prev: () => goTo(wanted - 1),
2670
- goTo,
2671
- busy(on) {
2672
- scope.attr(root, "aria-busy", on ? "true" : null);
2673
- const background = root.querySelector(".mk-chat-background, mk-chat-background");
2674
- chatBackgroundOf(background)?.busy(on);
2675
- },
2676
- get index() {
2677
- return index;
2678
- },
2679
- get count() {
2680
- return steps.length;
2966
+ open,
2967
+ close: () => close(),
2968
+ toggle: (origin) => isOpen ? close() : open(origin),
2969
+ float: lift,
2970
+ dock,
2971
+ get isOpen() {
2972
+ return isOpen;
2681
2973
  },
2682
- get steps() {
2683
- return steps;
2974
+ get isFloating() {
2975
+ return floating;
2684
2976
  },
2977
+ element: dialog,
2685
2978
  destroy() {
2979
+ if (destroyed) return;
2980
+ tearingDown = true;
2981
+ if (isOpen) {
2982
+ settleFloating();
2983
+ closing = true;
2984
+ if (dialog.hasAttribute("open")) closeModal(dialog);
2985
+ closedQuietly();
2986
+ }
2987
+ destroyed = true;
2988
+ endSession();
2989
+ gsap.killTweensOf(dialog);
2990
+ clearStyles([dialog], [...MORPH_STYLES, "height"]);
2686
2991
  scope.dispose();
2687
- delete root.dataset.mkReady;
2992
+ delete dialog.dataset.mkReady;
2688
2993
  }
2689
2994
  };
2690
2995
  }
2691
2996
 
2692
- // src/components/quantity/engine.ts
2693
- function createQuantity(root, options = {}) {
2694
- const input = root?.querySelector("[data-mk-quantity-input]");
2695
- if (!root || !input) return inert({ setValue() {
2696
- }, value: 0 });
2997
+ // src/components/menu/engine.ts
2998
+ var ITEM = "[data-mk-item]";
2999
+ function createMenu(dialog, options = {}) {
3000
+ if (!dialog) {
3001
+ warnOnce("menu: missing <dialog> element");
3002
+ return inert({
3003
+ open() {
3004
+ },
3005
+ close() {
3006
+ },
3007
+ toggle() {
3008
+ },
3009
+ float() {
3010
+ },
3011
+ dock() {
3012
+ },
3013
+ isOpen: false,
3014
+ isFloating: false,
3015
+ element: null,
3016
+ items: []
3017
+ });
3018
+ }
3019
+ const { closeOnSelect = true } = options;
2697
3020
  const scope = createScope();
2698
- const min = Number.isFinite(options.min) ? options.min : 1;
2699
- const max = Number.isFinite(options.max) ? Math.max(min, options.max) : Math.max(min, 999);
2700
- const step = Number.isFinite(options.step) && options.step > 0 ? options.step : 1;
2701
- const steps = Math.floor((max - min) / step + 1e-9);
2702
- const upper = Math.min(max, Number((min + steps * step).toFixed(10)));
2703
- const normalize3 = (n) => Math.max(min, Math.min(upper, Number((min + Math.round((n - min) / step) * step).toFixed(10))));
2704
- const original = input.value;
2705
- const disabled = options.disabled ?? input.disabled;
2706
- const decrease = root.querySelector("[data-mk-quantity-decrease]");
2707
- const increase = root.querySelector("[data-mk-quantity-increase]");
2708
- scope.attr(input, "min", String(min));
2709
- scope.attr(input, "max", String(max));
2710
- scope.attr(input, "step", String(step));
2711
- scope.attr(input, "disabled", disabled ? "" : null);
2712
- scope.attr(root, "data-mk-ready", "");
2713
- const initial = input.value.trim() ? Number(input.value) : NaN;
2714
- let value = normalize3(Number.isFinite(options.value) ? options.value : Number.isFinite(initial) ? initial : min);
2715
- let pendingReset = null;
2716
- const typed = () => input.value.trim() && Number.isFinite(input.valueAsNumber) ? input.valueAsNumber : NaN;
2717
- const render = (syncInput = true) => {
2718
- if (pendingReset) {
2719
- if (pendingReset.eventPhase !== 0) return;
2720
- if (!pendingReset.defaultPrevented) value = normalize3(Number.isFinite(typed()) ? typed() : min);
2721
- pendingReset = null;
3021
+ let ticketAnimation;
3022
+ if (options.ticket) {
3023
+ scope.attr(dialog, "data-mk-ticket", "");
3024
+ scope.attr(dialog, "style", dialog.getAttribute("style"));
3025
+ for (const item of dialog.querySelectorAll(ITEM)) scope.attr(item, "style", item.getAttribute("style"));
3026
+ scope.add(() => ticketAnimation?.kill());
3027
+ }
3028
+ const items = () => [...dialog.querySelectorAll(ITEM)].filter((item) => !item.hasAttribute("disabled") && item.getAttribute("aria-disabled") !== "true");
3029
+ scope.attr(dialog, "role", "menu");
3030
+ const markItems = () => {
3031
+ for (const item of dialog.querySelectorAll(ITEM)) {
3032
+ scope.attr(item, "role", "menuitem");
3033
+ scope.attr(item, "tabindex", "-1");
2722
3034
  }
2723
- if (syncInput) input.value = String(value);
2724
- if (decrease) scope.attr(decrease, "disabled", disabled || value <= min ? "" : null);
2725
- if (increase) scope.attr(increase, "disabled", disabled || value >= upper ? "" : null);
2726
3035
  };
2727
- const commit = (next, notify, syncInput) => {
2728
- if (scope.disposed || !Number.isFinite(next)) return;
2729
- if (pendingReset?.eventPhase === 0) pendingReset = null;
2730
- const previous = value;
2731
- value = normalize3(next);
2732
- render(syncInput);
2733
- if (notify && value !== previous) {
2734
- options.onChange?.(value);
2735
- root.dispatchEvent(new CustomEvent("mk:change", { bubbles: true, detail: { value, previous } }));
3036
+ markItems();
3037
+ const surface = createDialog(dialog, {
3038
+ ...options,
3039
+ placement: "anchor",
3040
+ backdrop: false,
3041
+ drag: false,
3042
+ autoResize: false,
3043
+ animateContent: false,
3044
+ onOpen: () => {
3045
+ markItems();
3046
+ const list3 = items();
3047
+ if (options.ticket && !reduced()) {
3048
+ ticketAnimation?.kill();
3049
+ ticketAnimation = gsap.timeline().fromTo(dialog, { clipPath: "inset(0 0 100% 0)" }, { clipPath: "inset(0 0 0% 0)", duration: TIMING.ticketMenu.open, ease: "expo.out" }).fromTo(list3, { yPercent: TIMING.ticketMenu.from }, { yPercent: 0, duration: TIMING.ticketMenu.content, stagger: TIMING.ticketMenu.stagger, ease: "expo.out" }, 0);
3050
+ } else flowInMenu(list3);
3051
+ list3[0]?.focus({ preventScroll: true });
3052
+ options.onOpen?.();
2736
3053
  }
2737
- };
2738
- const setValue = (next, notify = true) => commit(next, notify, true);
2739
- if (decrease) scope.on(decrease, "click", () => {
2740
- if (!decrease.disabled) setValue(value - step);
2741
- });
2742
- if (increase) scope.on(increase, "click", () => {
2743
- if (!increase.disabled) setValue(value + step);
2744
- });
2745
- scope.on(input, "input", () => {
2746
- const n = typed();
2747
- if (Number.isFinite(n) && normalize3(n) === n) commit(n, true, false);
2748
- });
2749
- scope.on(input, "change", () => {
2750
- if (Number.isFinite(typed())) setValue(typed());
2751
- else render();
2752
- });
2753
- scope.on(input, "blur", () => render());
2754
- if (input.form) scope.on(input.form, "reset", (event) => {
2755
- render();
2756
- pendingReset = event;
2757
- scope.timeout(() => {
2758
- if (pendingReset === event) render();
2759
- }, 0);
2760
3054
  });
2761
- scope.add(() => {
2762
- input.value = original;
3055
+ const select = (item) => {
3056
+ const value = item.dataset.mkValue ?? item.textContent?.trim() ?? "";
3057
+ dialog.dispatchEvent(new CustomEvent("mk:select", { bubbles: true, detail: { value, item } }));
3058
+ options.onSelect?.(value, item);
3059
+ if (closeOnSelect) surface.close();
3060
+ };
3061
+ scope.on(dialog, "click", (event) => {
3062
+ const item = event.target?.closest(ITEM);
3063
+ if (item && dialog.contains(item) && items().includes(item)) select(item);
2763
3064
  });
2764
- render();
2765
- return { setValue, get value() {
2766
- return value;
2767
- }, destroy: () => scope.dispose() };
2768
- }
2769
-
2770
- // src/motion/micro.ts
2771
- var list2 = (targets) => !targets ? [] : targets instanceof Element ? [targets] : [...targets];
2772
- var live = () => {
2773
- registerMotion();
2774
- return !reduced();
2775
- };
2776
- function press(el5) {
2777
- if (!el5 || !live()) return null;
2778
- gsap.killTweensOf(el5, "scaleX,scaleY");
2779
- return gsap.timeline({
2780
- onComplete: () => {
2781
- gsap.set(el5, { clearProps: "scale,transform" });
3065
+ scope.on(dialog, "keydown", (event) => {
3066
+ const key2 = event.key;
3067
+ const list3 = items();
3068
+ if (!list3.length) return;
3069
+ const at = list3.indexOf(document.activeElement);
3070
+ const moves = {
3071
+ ArrowDown: at < 0 ? 0 : (at + 1) % list3.length,
3072
+ ArrowUp: at < 0 ? list3.length - 1 : (at - 1 + list3.length) % list3.length,
3073
+ Home: 0,
3074
+ End: list3.length - 1
3075
+ };
3076
+ if (key2 in moves) {
3077
+ event.preventDefault();
3078
+ list3[moves[key2]]?.focus();
3079
+ return;
3080
+ }
3081
+ const target = event.target;
3082
+ if ((key2 === "Enter" || key2 === " ") && list3.includes(target) && !target.matches("button, a[href]")) {
3083
+ event.preventDefault();
3084
+ select(target);
2782
3085
  }
2783
- }).to(el5, { scaleX: 0.95, scaleY: 0.9, duration: 0.1, ease: "power2.out" }).to(el5, { scaleX: 1, scaleY: 1, duration: 0.5, ease: EASE.click });
2784
- }
2785
- function blurIn(targets, { from = "rise", stagger = 0.05, delay = 0, duration } = {}) {
2786
- const items = list2(targets);
2787
- if (!items.length || !live()) return null;
2788
- const start = from === "pop" ? { opacity: 0, scale: 0.7, filter: "blur(32px)" } : from === "soft" ? { opacity: 0, scale: 0.96, filter: "blur(16px)" } : { opacity: 0, y: -20, filter: "blur(16px)" };
2789
- return gsap.fromTo(items, start, {
2790
- opacity: 1,
2791
- y: 0,
2792
- scale: 1,
2793
- filter: "blur(0px)",
2794
- duration: duration ?? (from === "pop" ? 0.3 : 0.5),
2795
- ease: from === "pop" ? EASE.pop : "power2.out",
2796
- stagger,
2797
- delay,
2798
- clearProps: "opacity,transform,filter"
2799
3086
  });
3087
+ return {
3088
+ open: surface.open,
3089
+ close: surface.close,
3090
+ toggle: surface.toggle,
3091
+ float: surface.float,
3092
+ dock: surface.dock,
3093
+ get isOpen() {
3094
+ return surface.isOpen;
3095
+ },
3096
+ get isFloating() {
3097
+ return surface.isFloating;
3098
+ },
3099
+ get items() {
3100
+ return items();
3101
+ },
3102
+ element: dialog,
3103
+ destroy() {
3104
+ surface.destroy();
3105
+ scope.dispose();
3106
+ }
3107
+ };
2800
3108
  }
2801
- function blurOut(targets, { to = "up", onComplete } = {}) {
2802
- const items = list2(targets);
2803
- if (!items.length) return null;
2804
- if (!live()) {
2805
- onComplete?.();
2806
- return null;
3109
+
3110
+ // src/components/chat-background/engine.ts
3111
+ var VARS = ["--mk-chat-orbit-1", "--mk-chat-orbit-2", "--mk-chat-blob-opacity", "--mk-chat-scale"];
3112
+ var instances = /* @__PURE__ */ new WeakMap();
3113
+ var chatBackgroundOf = (el5) => el5 ? instances.get(el5) ?? null : null;
3114
+ function createChatBackground(root, options = {}) {
3115
+ if (!root) {
3116
+ warnOnce("chat-background: missing root");
3117
+ return inert({ setEnergy() {
3118
+ }, setScale() {
3119
+ }, busy() {
3120
+ }, energy: 0, scale: 1 });
2807
3121
  }
2808
- const end = to === "left" ? { x: -64 } : to === "down" ? { y: 24 } : { y: -20 };
2809
- return gsap.to(items, { ...end, opacity: 0, filter: "blur(16px)", duration: 0.5, ease: "power2.out", onComplete });
2810
- }
2811
- function collapse(el5, { onComplete } = {}) {
2812
- if (!el5) return null;
2813
- if (!live()) {
2814
- onComplete?.();
2815
- return null;
3122
+ registerMotion();
3123
+ const scope = createScope();
3124
+ const state = { energy: options.energy ?? 0, scale: options.scale ?? 1 };
3125
+ let noise = root.querySelector(":scope > .mk-chat-background__noise");
3126
+ if (!noise) {
3127
+ noise = document.createElement("div");
3128
+ noise.className = "mk-chat-background__noise";
3129
+ noise.setAttribute("aria-hidden", "true");
3130
+ root.append(noise);
3131
+ const created = noise;
3132
+ scope.add(() => created.remove());
2816
3133
  }
2817
- return gsap.to(el5, {
2818
- height: 0,
2819
- paddingTop: 0,
2820
- paddingBottom: 0,
2821
- marginTop: 0,
2822
- marginBottom: 0,
2823
- opacity: 0,
2824
- filter: "blur(16px)",
2825
- overflow: "hidden",
2826
- duration: 0.25,
2827
- ease: "power2.in",
2828
- onComplete
2829
- });
2830
- }
2831
- function shake(el5, distance = 4) {
2832
- if (!el5 || !live()) return null;
2833
- gsap.killTweensOf(el5, "x");
2834
- return gsap.to(el5, {
2835
- keyframes: { x: [0, -distance, distance, -distance, 0] },
2836
- duration: 0.5,
2837
- ease: EASE.shake,
2838
- clearProps: "x,transform"
3134
+ scope.attr(root, "aria-hidden", "true");
3135
+ const paint = () => {
3136
+ const e = Math.max(0, state.energy);
3137
+ root.style.setProperty("--mk-chat-orbit-1", `${Math.max(1, 10 - 3.5 * e).toFixed(3)}s`);
3138
+ root.style.setProperty("--mk-chat-orbit-2", `${Math.max(1, 15 - 4.5 * e).toFixed(3)}s`);
3139
+ root.style.setProperty("--mk-chat-blob-opacity", (0.5 + 0.15 * e).toFixed(3));
3140
+ root.style.setProperty("--mk-chat-scale", ((1 + 0.1 * e) * state.scale).toFixed(3));
3141
+ };
3142
+ scope.add(() => {
3143
+ gsap.killTweensOf(state);
3144
+ for (const name of VARS) root.style.removeProperty(name);
3145
+ if (root.getAttribute("style") === "") root.removeAttribute("style");
2839
3146
  });
2840
- }
2841
- function ringPulse(el5, color = "var(--mk-accent-soft)") {
2842
- if (!el5 || !live()) return null;
2843
- const before = { color: el5.style.outlineColor, style: el5.style.outlineStyle, offset: el5.style.outlineOffset };
2844
- el5.style.outlineColor = color;
2845
- el5.style.outlineStyle = "solid";
2846
- el5.style.outlineOffset = "-4px";
2847
- const restore = () => {
2848
- el5.style.outlineColor = before.color;
2849
- el5.style.outlineStyle = before.style;
2850
- el5.style.outlineOffset = before.offset;
2851
- el5.style.removeProperty("outline-width");
2852
- if (el5.getAttribute("style") === "") el5.removeAttribute("style");
3147
+ paint();
3148
+ const instance = {
3149
+ setEnergy(energy) {
3150
+ state.energy = Number.isFinite(energy) ? energy : 0;
3151
+ paint();
3152
+ },
3153
+ setScale(scale) {
3154
+ state.scale = Number.isFinite(scale) ? scale : 1;
3155
+ paint();
3156
+ },
3157
+ busy(on) {
3158
+ const to = on ? { energy: 1.6, scale: 1.8 } : { energy: 0, scale: 1 };
3159
+ gsap.killTweensOf(state);
3160
+ if (reduced()) {
3161
+ Object.assign(state, to);
3162
+ paint();
3163
+ return;
3164
+ }
3165
+ gsap.to(state, {
3166
+ ...to,
3167
+ duration: on ? TIMING.onboarding.busy : TIMING.onboarding.idle,
3168
+ ease: on ? "power2.out" : "power2.inOut",
3169
+ onUpdate: paint
3170
+ });
3171
+ },
3172
+ get energy() {
3173
+ return state.energy;
3174
+ },
3175
+ get scale() {
3176
+ return state.scale;
3177
+ },
3178
+ destroy() {
3179
+ instances.delete(root);
3180
+ scope.dispose();
3181
+ delete root.dataset.mkReady;
3182
+ }
2853
3183
  };
2854
- return gsap.fromTo(el5, { outlineWidth: 0 }, { keyframes: { outlineWidth: [0, 4, 0] }, duration: 1, ease: "power1.inOut", onComplete: restore, onInterrupt: restore });
3184
+ instances.set(root, instance);
3185
+ root.dataset.mkReady = "";
3186
+ return instance;
2855
3187
  }
2856
- function burst(origin, { count = 7, distance = 28, colors = ["var(--mk-accent)"], ring = true, size = 6 } = {}) {
2857
- if (!origin || !live()) return null;
2858
- const layer = document.createElement("span");
2859
- layer.setAttribute("aria-hidden", "true");
2860
- layer.dataset.mkBurst = "";
2861
- Object.assign(layer.style, { position: "absolute", inset: "0", pointerEvents: "none", overflow: "visible", display: "grid", placeItems: "center" });
2862
- const positioned = getComputedStyle(origin).position !== "static";
2863
- const previousPosition = origin.style.position;
2864
- if (!positioned) origin.style.position = "relative";
2865
- origin.append(layer);
2866
- const cleanup = () => {
2867
- layer.remove();
2868
- if (!positioned) origin.style.position = previousPosition;
2869
- if (origin.getAttribute("style") === "") origin.removeAttribute("style");
2870
- };
2871
- const timeline = gsap.timeline({ onComplete: cleanup, onInterrupt: cleanup });
2872
- if (ring) {
2873
- const circle = document.createElement("span");
2874
- Object.assign(circle.style, { position: "absolute", width: "100%", aspectRatio: "1", borderRadius: "50%", border: `2px solid ${colors[0]}` });
2875
- layer.append(circle);
2876
- timeline.fromTo(circle, { scale: 0.3, opacity: 0.9 }, { scale: 1.6, opacity: 0, duration: 0.5, ease: "power2.out" }, 0);
3188
+
3189
+ // src/components/steps/engine.ts
3190
+ var STEP2 = "[data-mk-step]";
3191
+ var ITEM_STYLES = ["transform", "translate", "rotate", "scale", "filter", "opacity", "visibility"];
3192
+ function createSteps(root, options = {}) {
3193
+ const steps = root ? [...root.querySelectorAll(STEP2)].filter((step) => {
3194
+ const outer = step.parentElement?.closest(STEP2);
3195
+ return !outer || !root.contains(outer);
3196
+ }) : [];
3197
+ if (!root || !steps.length) {
3198
+ warnOnce("steps: needs [data-mk-step] children");
3199
+ return inert({ next: async () => {
3200
+ }, prev: async () => {
3201
+ }, goTo: async () => {
3202
+ }, busy() {
3203
+ }, index: -1, count: 0, steps: [] });
2877
3204
  }
2878
- for (let i = 0; i < count; i++) {
2879
- const angle2 = i / count * Math.PI * 2 - Math.PI / 2;
2880
- for (const [k, scale] of [[0, 1], [1, 0.6]]) {
2881
- const dot = document.createElement("span");
2882
- Object.assign(dot.style, {
2883
- position: "absolute",
2884
- width: `${size * scale}px`,
2885
- height: `${size * scale}px`,
2886
- borderRadius: "50%",
2887
- background: colors[(i + k) % colors.length]
2888
- });
2889
- layer.append(dot);
2890
- const reach = distance * (k ? 0.72 : 1);
2891
- const turn = k ? 0.32 : 0;
2892
- timeline.fromTo(
2893
- dot,
2894
- { x: 0, y: 0, scale: 0, opacity: 1 },
2895
- { x: Math.cos(angle2 + turn) * reach, y: Math.sin(angle2 + turn) * reach, scale: 1, duration: 0.45, ease: "power3.out" },
2896
- 0.05
2897
- );
2898
- timeline.to(dot, { scale: 0, opacity: 0, duration: 0.3, ease: "power2.in" }, 0.38);
3205
+ registerMotion();
3206
+ const scope = createScope();
3207
+ const { duration = TIMING.onboarding.step, animateFirst = true, target = "[data-mk-flow-item]" } = options;
3208
+ const clamp6 = (value) => Math.min(steps.length - 1, Math.max(0, Math.round(value)));
3209
+ const marked3 = steps.findIndex((step) => step.hasAttribute("data-mk-current"));
3210
+ let index = clamp6(options.index ?? (marked3 >= 0 ? marked3 : 0));
3211
+ let wanted = index;
3212
+ let running2 = null;
3213
+ let stopCounter = () => {
3214
+ };
3215
+ const itemsOf = (step) => {
3216
+ const marked4 = [...step.querySelectorAll(target)];
3217
+ return marked4.length ? marked4 : [...step.children];
3218
+ };
3219
+ const show = (current3) => {
3220
+ steps.forEach((step, i) => {
3221
+ scope.attr(step, "hidden", i === current3 ? null : "");
3222
+ scope.attr(step, "data-mk-current", i === current3 ? "" : null);
3223
+ });
3224
+ };
3225
+ const counter = () => {
3226
+ const el5 = root.querySelector("[data-mk-counter]");
3227
+ if (!el5) return;
3228
+ stopCounter();
3229
+ stopCounter = revealCounter(el5, index + 1, { duration: TIMING.onboarding.counter });
3230
+ };
3231
+ const focusTitle = (step) => {
3232
+ const title = step.querySelector("[data-mk-step-title]") ?? step.querySelector("h1, h2, h3, h4, h5, h6");
3233
+ if (!title) return;
3234
+ if (!title.hasAttribute("tabindex") && title.tabIndex < 0) scope.attr(title, "tabindex", "-1");
3235
+ title.focus({ preventScroll: true });
3236
+ };
3237
+ const change = async () => {
3238
+ try {
3239
+ while (wanted !== index && !scope.disposed) {
3240
+ const previous = index;
3241
+ const next = wanted;
3242
+ const out = reduced() ? null : flowOut(itemsOf(steps[previous]), { duration });
3243
+ if (out) await out;
3244
+ if (scope.disposed) return;
3245
+ index = next;
3246
+ show(index);
3247
+ const step = steps[index];
3248
+ await nextFrame();
3249
+ if (scope.disposed) return;
3250
+ const items = itemsOf(step);
3251
+ clearStyles(items, ["visibility"]);
3252
+ flowIn(items, { duration, autoAlpha: false });
3253
+ counter();
3254
+ focusTitle(step);
3255
+ root.dispatchEvent(new CustomEvent("mk:step", { bubbles: true, detail: { index, previous, step } }));
3256
+ options.onChange?.(index, previous);
3257
+ }
3258
+ } finally {
3259
+ running2 = null;
3260
+ }
3261
+ };
3262
+ const goTo = (to) => {
3263
+ wanted = clamp6(to);
3264
+ if (wanted === index && !running2) return Promise.resolve();
3265
+ running2 ??= change();
3266
+ return running2;
3267
+ };
3268
+ show(index);
3269
+ scope.add(() => {
3270
+ stopCounter();
3271
+ for (const step of steps) {
3272
+ const items = itemsOf(step);
3273
+ gsap.killTweensOf(items);
3274
+ clearStyles(items, ITEM_STYLES);
2899
3275
  }
3276
+ });
3277
+ scope.on(root, "click", (event) => {
3278
+ const trigger = event.target?.closest("[data-mk-step-next], [data-mk-step-prev], [data-mk-step-goto]");
3279
+ if (!trigger || !root.contains(trigger)) return;
3280
+ if (trigger.hasAttribute("data-mk-step-next")) void goTo(wanted + 1);
3281
+ else if (trigger.hasAttribute("data-mk-step-prev")) void goTo(wanted - 1);
3282
+ else void goTo(Number(trigger.dataset.mkStepGoto) - 1);
3283
+ });
3284
+ const counterEl = root.querySelector("[data-mk-counter]");
3285
+ if (counterEl) {
3286
+ const text = counterEl.textContent;
3287
+ counterEl.textContent = String(index + 1);
3288
+ scope.add(() => {
3289
+ counterEl.textContent = text;
3290
+ });
2900
3291
  }
2901
- return timeline;
3292
+ if (animateFirst && entrances()) flowIn(itemsOf(steps[index]), { duration });
3293
+ root.dataset.mkReady = "";
3294
+ return {
3295
+ next: () => goTo(wanted + 1),
3296
+ prev: () => goTo(wanted - 1),
3297
+ goTo,
3298
+ busy(on) {
3299
+ scope.attr(root, "aria-busy", on ? "true" : null);
3300
+ const background = root.querySelector(".mk-chat-background, mk-chat-background");
3301
+ chatBackgroundOf(background)?.busy(on);
3302
+ },
3303
+ get index() {
3304
+ return index;
3305
+ },
3306
+ get count() {
3307
+ return steps.length;
3308
+ },
3309
+ get steps() {
3310
+ return steps;
3311
+ },
3312
+ destroy() {
3313
+ scope.dispose();
3314
+ delete root.dataset.mkReady;
3315
+ }
3316
+ };
2902
3317
  }
2903
- var rolling = /* @__PURE__ */ new WeakMap();
2904
- function rollDigits(el5, text, direction = 1, duration = 0.5) {
2905
- if (!el5) return null;
2906
- rolling.get(el5)?.progress(1).kill();
2907
- rolling.delete(el5);
2908
- const previous = el5.textContent ?? "";
2909
- if (previous === text || !live()) {
2910
- el5.textContent = text;
2911
- return null;
2912
- }
2913
- const width = Math.max(previous.length, text.length);
2914
- const oldChars = previous.padStart(width, " ");
2915
- const newChars = text.padStart(width, " ");
2916
- el5.textContent = "";
2917
- const label = document.createElement("span");
2918
- label.className = "mk-sr-only";
2919
- label.textContent = text;
2920
- const visual = document.createElement("span");
2921
- visual.setAttribute("aria-hidden", "true");
2922
- visual.style.display = "inline-flex";
2923
- const moving = [];
2924
- const padding = Math.min(width - previous.length, width - text.length);
2925
- for (let i = padding; i < width; i++) {
2926
- const before = oldChars[i];
2927
- const after = newChars[i];
2928
- const cell = document.createElement("span");
2929
- Object.assign(cell.style, { position: "relative", display: "inline-block", overflow: "hidden", whiteSpace: "pre" });
2930
- const next = document.createElement("span");
2931
- next.style.display = "inline-block";
2932
- next.textContent = after;
2933
- cell.append(next);
2934
- if (before !== after) {
2935
- const old = document.createElement("span");
2936
- Object.assign(old.style, { position: "absolute", left: "0", top: "0", display: "inline-block" });
2937
- old.textContent = before;
2938
- cell.append(old);
2939
- moving.push([old, next]);
3318
+
3319
+ // src/components/quantity/engine.ts
3320
+ function createQuantity(root, options = {}) {
3321
+ const input = root?.querySelector("[data-mk-quantity-input]");
3322
+ if (!root || !input) return inert({ setValue() {
3323
+ }, value: 0 });
3324
+ const scope = createScope();
3325
+ const min = Number.isFinite(options.min) ? options.min : 1;
3326
+ const max = Number.isFinite(options.max) ? Math.max(min, options.max) : Math.max(min, 999);
3327
+ const step = Number.isFinite(options.step) && options.step > 0 ? options.step : 1;
3328
+ const steps = Math.floor((max - min) / step + 1e-9);
3329
+ const upper = Math.min(max, Number((min + steps * step).toFixed(10)));
3330
+ const normalize3 = (n) => Math.max(min, Math.min(upper, Number((min + Math.round((n - min) / step) * step).toFixed(10))));
3331
+ const original = input.value;
3332
+ const disabled = options.disabled ?? input.disabled;
3333
+ const decrease = root.querySelector("[data-mk-quantity-decrease]");
3334
+ const increase = root.querySelector("[data-mk-quantity-increase]");
3335
+ scope.attr(input, "min", String(min));
3336
+ scope.attr(input, "max", String(max));
3337
+ scope.attr(input, "step", String(step));
3338
+ scope.attr(input, "disabled", disabled ? "" : null);
3339
+ scope.attr(root, "data-mk-ready", "");
3340
+ const initial = input.value.trim() ? Number(input.value) : NaN;
3341
+ let value = normalize3(Number.isFinite(options.value) ? options.value : Number.isFinite(initial) ? initial : min);
3342
+ let pendingReset = null;
3343
+ const typed = () => input.value.trim() && Number.isFinite(input.valueAsNumber) ? input.valueAsNumber : NaN;
3344
+ const render = (syncInput = true) => {
3345
+ if (pendingReset) {
3346
+ if (pendingReset.eventPhase !== 0) return;
3347
+ if (!pendingReset.defaultPrevented) value = normalize3(Number.isFinite(typed()) ? typed() : min);
3348
+ pendingReset = null;
2940
3349
  }
2941
- visual.append(cell);
2942
- }
2943
- el5.append(label, visual);
2944
- const timeline = gsap.timeline({
2945
- onComplete: () => {
2946
- el5.textContent = text;
2947
- rolling.delete(el5);
3350
+ if (syncInput) input.value = String(value);
3351
+ if (decrease) scope.attr(decrease, "disabled", disabled || value <= min ? "" : null);
3352
+ if (increase) scope.attr(increase, "disabled", disabled || value >= upper ? "" : null);
3353
+ };
3354
+ const commit = (next, notify, syncInput) => {
3355
+ if (scope.disposed || !Number.isFinite(next)) return;
3356
+ if (pendingReset?.eventPhase === 0) pendingReset = null;
3357
+ const previous = value;
3358
+ value = normalize3(next);
3359
+ render(syncInput);
3360
+ if (notify && value !== previous) {
3361
+ options.onChange?.(value);
3362
+ root.dispatchEvent(new CustomEvent("mk:change", { bubbles: true, detail: { value, previous } }));
2948
3363
  }
3364
+ };
3365
+ const setValue = (next, notify = true) => commit(next, notify, true);
3366
+ if (decrease) scope.on(decrease, "click", () => {
3367
+ if (!decrease.disabled) setValue(value - step);
2949
3368
  });
2950
- moving.forEach(([old, next], i) => {
2951
- timeline.to(old, { yPercent: -100 * direction, opacity: 0, filter: "blur(4px)", duration, ease: EASE.signature }, i * 0.03);
2952
- timeline.fromTo(next, { yPercent: 100 * direction, opacity: 0, filter: "blur(4px)" }, { yPercent: 0, opacity: 1, filter: "blur(0px)", duration, ease: EASE.signature }, i * 0.03);
3369
+ if (increase) scope.on(increase, "click", () => {
3370
+ if (!increase.disabled) setValue(value + step);
2953
3371
  });
2954
- rolling.set(el5, timeline);
2955
- return timeline;
3372
+ scope.on(input, "input", () => {
3373
+ const n = typed();
3374
+ if (Number.isFinite(n) && normalize3(n) === n) commit(n, true, false);
3375
+ });
3376
+ scope.on(input, "change", () => {
3377
+ if (Number.isFinite(typed())) setValue(typed());
3378
+ else render();
3379
+ });
3380
+ scope.on(input, "blur", () => render());
3381
+ if (input.form) scope.on(input.form, "reset", (event) => {
3382
+ render();
3383
+ pendingReset = event;
3384
+ scope.timeout(() => {
3385
+ if (pendingReset === event) render();
3386
+ }, 0);
3387
+ });
3388
+ scope.add(() => {
3389
+ input.value = original;
3390
+ });
3391
+ render();
3392
+ return { setValue, get value() {
3393
+ return value;
3394
+ }, destroy: () => scope.dispose() };
2956
3395
  }
2957
3396
 
2958
3397
  // src/components/pagination/engine.ts
@@ -3081,7 +3520,7 @@ function createPagination(root, options = {}) {
3081
3520
  }
3082
3521
 
3083
3522
  // src/components/hover-card/engine.ts
3084
- var sequence = 0;
3523
+ var sequence2 = 0;
3085
3524
  var EDGE2 = 12;
3086
3525
  var GAP2 = 12;
3087
3526
  var FOLD_MS = 400;
@@ -3103,7 +3542,7 @@ function createHoverCard(root, options = {}) {
3103
3542
  let id = panel.id;
3104
3543
  if (!id) {
3105
3544
  do {
3106
- id = `mk-hover-${++sequence}`;
3545
+ id = `mk-hover-${++sequence2}`;
3107
3546
  } while (document.getElementById(id));
3108
3547
  }
3109
3548
  scope.attr(panel, "id", id);
@@ -4605,7 +5044,7 @@ var DEFAULT_LABELS2 = {
4605
5044
  removed: (name) => `${name} quitado`,
4606
5045
  rejected: ({ name, code, limit }) => code === "type" ? `${name}: tipo no permitido` : code === "size" ? `${name}: supera ${limit}` : `${name}: m\xE1ximo ${limit}`
4607
5046
  };
4608
- var sequence2 = 0;
5047
+ var sequence3 = 0;
4609
5048
  function formatBytes(bytes) {
4610
5049
  if (!Number.isFinite(bytes) || bytes < 0) return "";
4611
5050
  const units = ["B", "KB", "MB", "GB"];
@@ -4817,7 +5256,7 @@ function createAttachment(root, options = {}) {
4817
5256
  owned.add(preview);
4818
5257
  }
4819
5258
  const progress = Number.isFinite(seed.progress) ? Math.min(100, Math.max(0, seed.progress)) : void 0;
4820
- return { id: seed.id ?? `mk-file-${++sequence2}`, name: seed.name, size: seed.size ?? source?.size ?? 0, type, file: source ?? seed.file, progress, status: seed.status ?? "idle", preview };
5259
+ return { id: seed.id ?? `mk-file-${++sequence3}`, name: seed.name, size: seed.size ?? source?.size ?? 0, type, file: source ?? seed.file, progress, status: seed.status ?? "idle", preview };
4821
5260
  };
4822
5261
  const addFiles = (incoming) => {
4823
5262
  if (scope.disposed || disabled) return [];
@@ -5008,7 +5447,7 @@ function createSkeleton(root, options = {}) {
5008
5447
  // src/components/questionnaire/engine.ts
5009
5448
  var FIELDS2 = "input[name], select[name], textarea[name]";
5010
5449
  var SKIP = /* @__PURE__ */ new Set(["button", "submit", "reset", "image", "file"]);
5011
- var sequence3 = 0;
5450
+ var sequence4 = 0;
5012
5451
  function readAnswers(form) {
5013
5452
  const answers = {};
5014
5453
  for (const field of form.querySelectorAll(FIELDS2)) {
@@ -5055,7 +5494,7 @@ function createQuestionnaire(root, options = {}) {
5055
5494
  };
5056
5495
  scope.add(() => errorTexts.forEach((text, element) => element.textContent = text));
5057
5496
  for (const element of form.querySelectorAll("[data-mk-question-error]")) {
5058
- if (!element.id) scope.attr(element, "id", `mk-question-error-${++sequence3}`);
5497
+ if (!element.id) scope.attr(element, "id", `mk-question-error-${++sequence4}`);
5059
5498
  if (!element.matches("output") && !element.hasAttribute("role")) scope.attr(element, "role", "alert");
5060
5499
  }
5061
5500
  const markValid = (field) => {
@@ -5492,6 +5931,8 @@ function createCodeBlock(root, options = {}) {
5492
5931
  if (options.language) scope.attr(root, "data-mk-language", options.language);
5493
5932
  if (options.lineNumbers) scope.attr(root, "data-mk-line-numbers", "");
5494
5933
  scope.attr(root, "data-mk-ready", "");
5934
+ const area = createScrollArea(root, { viewport: pre, focusable: false, decorative: true });
5935
+ scope.add(() => area.destroy());
5495
5936
  const prerendered = Boolean(code.querySelector("[data-mk-code-line]"));
5496
5937
  let given = null;
5497
5938
  const highlight = !prerendered && (options.highlight ?? languageFamily(options.language) !== "plain");
@@ -5777,7 +6218,7 @@ function linkDomain(href) {
5777
6218
  return "";
5778
6219
  }
5779
6220
  }
5780
- var sequence4 = 0;
6221
+ var sequence5 = 0;
5781
6222
  var part2 = (tag, name, text) => {
5782
6223
  const element = document.createElement(tag);
5783
6224
  element.dataset.mkPart = name;
@@ -5795,7 +6236,7 @@ function buildCard(options, href) {
5795
6236
  if (options.target === "_blank") card.setAttribute("rel", "noopener noreferrer");
5796
6237
  }
5797
6238
  }
5798
- const id = `mk-link-${++sequence4}`;
6239
+ const id = `mk-link-${++sequence5}`;
5799
6240
  const media = part2("span", "media");
5800
6241
  const fallback = part2("span", "fallback", (options.siteName || domain || options.title || "?").trim().charAt(0).toUpperCase());
5801
6242
  fallback.setAttribute("aria-hidden", "true");
@@ -5905,8 +6346,8 @@ function createProgress(root, options = {}) {
5905
6346
  const max = finite(options.max) && options.max > min ? options.max : Math.max(min + 1, 100);
5906
6347
  const variant = options.variant === "ring" ? "ring" : "linear";
5907
6348
  const duration = finite(options.duration) ? Math.max(0, options.duration) : 0.7;
5908
- const clamp5 = (n) => Math.min(max, Math.max(min, n));
5909
- let value = options.value === null ? null : clamp5(finite(options.value) ? options.value : min);
6349
+ const clamp6 = (n) => Math.min(max, Math.max(min, n));
6350
+ let value = options.value === null ? null : clamp6(finite(options.value) ? options.value : min);
5910
6351
  const visual = document.createElement("span");
5911
6352
  visual.dataset.mkProgressVisual = "";
5912
6353
  visual.setAttribute("aria-hidden", "true");
@@ -6007,7 +6448,7 @@ function createProgress(root, options = {}) {
6007
6448
  if (scope.disposed) return;
6008
6449
  const previous = value;
6009
6450
  if (next === null) value = null;
6010
- else if (finite(next)) value = clamp5(next);
6451
+ else if (finite(next)) value = clamp6(next);
6011
6452
  else return;
6012
6453
  render(previous, true);
6013
6454
  },
@@ -6275,7 +6716,7 @@ var SLOTS = 8;
6275
6716
  var BAR_MAX = 24;
6276
6717
  var GAP3 = 2;
6277
6718
  var END_RADIUS = 3;
6278
- var sequence5 = 0;
6719
+ var sequence6 = 0;
6279
6720
  var svg = (tag, attrs = {}) => {
6280
6721
  const element = document.createElementNS(SVG2, tag);
6281
6722
  for (const [name, value] of Object.entries(attrs)) element.setAttribute(name, String(value));
@@ -6335,7 +6776,7 @@ function createChart(root, initial = {}) {
6335
6776
  }, selected: null });
6336
6777
  registerMotion();
6337
6778
  const scope = createScope();
6338
- const uid2 = `mk-chart-${++sequence5}`;
6779
+ const uid2 = `mk-chart-${++sequence6}`;
6339
6780
  let options = { ...initial };
6340
6781
  let selected = null;
6341
6782
  let model = modelOf(options);
@@ -7138,7 +7579,7 @@ var LABELS = {
7138
7579
  };
7139
7580
  var FIELDS3 = ["number", "name", "expiry", "cvc"];
7140
7581
  var NAMES = { number: "cc-number", name: "cc-name", expiry: "cc-exp", cvc: "cc-csc" };
7141
- var sequence6 = 0;
7582
+ var sequence7 = 0;
7142
7583
  var el = (tag, attrs = {}, text) => {
7143
7584
  const element = document.createElement(tag);
7144
7585
  for (const [name, value] of Object.entries(attrs)) element.setAttribute(name, value);
@@ -7152,7 +7593,7 @@ function createCreditCard(root, options = {}) {
7152
7593
  registerMotion();
7153
7594
  const scope = createScope();
7154
7595
  const labels = { ...LABELS, ...options.labels };
7155
- const uid2 = `mk-card-${++sequence6}`;
7596
+ const uid2 = `mk-card-${++sequence7}`;
7156
7597
  const made = [];
7157
7598
  const own = (element) => {
7158
7599
  made.push(element);
@@ -7491,7 +7932,7 @@ function matchScore(query, text) {
7491
7932
 
7492
7933
  // src/components/command-search/engine.ts
7493
7934
  var SEARCH_ICON = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="6.5"/><path d="M16 16l4 4"/></svg>';
7494
- var sequence7 = 0;
7935
+ var sequence8 = 0;
7495
7936
  var el2 = (tag, attrs = {}, text) => {
7496
7937
  const element = document.createElement(tag);
7497
7938
  for (const [name, value] of Object.entries(attrs)) element.setAttribute(name, value);
@@ -7516,7 +7957,7 @@ function createCommandSearch(root, options = {}) {
7516
7957
  }, isOpen: false });
7517
7958
  registerMotion();
7518
7959
  const scope = createScope();
7519
- const uid2 = `mk-command-${++sequence7}`;
7960
+ const uid2 = `mk-command-${++sequence8}`;
7520
7961
  let items = [...options.items ?? []];
7521
7962
  const limit = Number.isFinite(options.limit) && options.limit > 0 ? Math.floor(options.limit) : 50;
7522
7963
  const dialog = el2("dialog", { "data-mk-command": "", "aria-label": options.label ?? "Buscar" });
@@ -7550,6 +7991,8 @@ function createCommandSearch(root, options = {}) {
7550
7991
  root.append(dialog);
7551
7992
  scope.add(() => dialog.remove());
7552
7993
  scope.attr(root, "data-mk-ready", "");
7994
+ const area = createScrollArea(panel, { viewport: scroller, axis: "y", focusable: false, decorative: true });
7995
+ scope.add(() => area.destroy());
7553
7996
  let isOpen = false;
7554
7997
  let opener = null;
7555
7998
  let from = null;
@@ -7674,6 +8117,7 @@ function createCommandSearch(root, options = {}) {
7674
8117
  input.value = "";
7675
8118
  openModal(dialog);
7676
8119
  render(false);
8120
+ area.refresh();
7677
8121
  input.focus();
7678
8122
  void fadeBackdrop(dialog, "in");
7679
8123
  morphOpen(panel, from, { hideOrigin: true });
@@ -7771,7 +8215,7 @@ function createCommandSearch(root, options = {}) {
7771
8215
 
7772
8216
  // src/components/hold-confirm/engine.ts
7773
8217
  var CHECK = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5" pathLength="1"/></svg>';
7774
- var sequence8 = 0;
8218
+ var sequence9 = 0;
7775
8219
  function createHoldConfirm(root, options = {}) {
7776
8220
  const button2 = root ? root.matches("button") ? root : root.querySelector("button") : null;
7777
8221
  if (!root || !button2) return inert({ reset() {
@@ -7805,7 +8249,7 @@ function createHoldConfirm(root, options = {}) {
7805
8249
  check.innerHTML = CHECK;
7806
8250
  const hint = add(root === button2 ? button2 : root, document.createElement("span"));
7807
8251
  hint.className = "mk-sr-only";
7808
- hint.id = `mk-hold-${++sequence8}`;
8252
+ hint.id = `mk-hold-${++sequence9}`;
7809
8253
  hint.textContent = options.hint ?? "Mant\xE9n pulsado para confirmar";
7810
8254
  const live2 = add(root === button2 ? button2 : root, document.createElement("span"));
7811
8255
  live2.className = "mk-sr-only";
@@ -8585,7 +9029,7 @@ var PUPIL = "M12 9.2a2.8 2.8 0 1 0 0 5.6 2.8 2.8 0 0 0 0-5.6z";
8585
9029
  var SLASH = "M4 4l16 16";
8586
9030
  var CHECK2 = "M5 12.5l4.5 4.5L19 7.5";
8587
9031
  var ORDER = ["length", "lower", "upper", "number", "symbol"];
8588
- var sequence9 = 0;
9032
+ var sequence10 = 0;
8589
9033
  var icon = (paths, part3) => {
8590
9034
  const svg2 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
8591
9035
  svg2.setAttribute("viewBox", "0 0 24 24");
@@ -8603,7 +9047,7 @@ function createPasswordStrength(root, options = {}) {
8603
9047
  if (!root) return inert({ score: 0, value: "" });
8604
9048
  registerMotion();
8605
9049
  const scope = createScope();
8606
- const uid2 = `mk-password-${++sequence9}`;
9050
+ const uid2 = `mk-password-${++sequence10}`;
8607
9051
  const minLength = Number.isFinite(options.minLength) && options.minLength > 0 ? Math.floor(options.minLength) : 8;
8608
9052
  const score = options.score ?? ((value) => scorePassword(value, minLength));
8609
9053
  const labels = {
@@ -8961,7 +9405,7 @@ function createScratchCard(root, options = {}) {
8961
9405
  // src/components/star-rating/engine.ts
8962
9406
  var STAR = "M12 3.2l2.6 5.4 5.9.8-4.3 4.1 1 5.9L12 16.6l-5.2 2.8 1-5.9-4.3-4.1 5.9-.8z";
8963
9407
  var LABELS2 = ["Mala", "Regular", "Buena", "Muy buena", "Excelente"];
8964
- var sequence10 = 0;
9408
+ var sequence11 = 0;
8965
9409
  var star = () => {
8966
9410
  const svg2 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
8967
9411
  svg2.setAttribute("viewBox", "0 0 24 24");
@@ -8982,9 +9426,9 @@ function createStarRating(root, options = {}) {
8982
9426
  const scope = createScope();
8983
9427
  const max = Math.max(1, Math.min(10, Math.round(Number.isFinite(options.max) ? options.max : 5)));
8984
9428
  const texts = options.labels ?? (max === 5 ? LABELS2 : []);
8985
- const clamp5 = (n) => Math.max(0, Math.min(max, n));
8986
- let value = clamp5(Number.isFinite(options.value) ? options.value : 0);
8987
- const name = options.name ?? `rating-${++sequence10}`;
9429
+ const clamp6 = (n) => Math.max(0, Math.min(max, n));
9430
+ let value = clamp6(Number.isFinite(options.value) ? options.value : 0);
9431
+ const name = options.name ?? `rating-${++sequence11}`;
8988
9432
  const group = document.createElement("div");
8989
9433
  group.dataset.mkStars = "";
8990
9434
  const caption = document.createElement("span");
@@ -9071,7 +9515,7 @@ function createStarRating(root, options = {}) {
9071
9515
  };
9072
9516
  const choose = (next, notify, animate) => {
9073
9517
  if (scope.disposed) return;
9074
- const target = clamp5(Math.round(next));
9518
+ const target = clamp6(Math.round(next));
9075
9519
  if (target === value) return;
9076
9520
  value = target;
9077
9521
  paint();
@@ -9360,17 +9804,17 @@ var CHANNEL_RANGE = {
9360
9804
  blue: [0, 255],
9361
9805
  alpha: [0, 1]
9362
9806
  };
9363
- var clamp2 = (n, min, max) => Math.min(max, Math.max(min, Number.isFinite(n) ? n : min));
9807
+ var clamp3 = (n, min, max) => Math.min(max, Math.max(min, Number.isFinite(n) ? n : min));
9364
9808
  var tidy = (n) => Math.round(n * 100) / 100;
9365
9809
  var wrapHue = (h) => {
9366
9810
  const hue = (h % 360 + 360) % 360;
9367
9811
  return hue === 0 && h > 0 ? 360 : hue;
9368
9812
  };
9369
9813
  var hsva = (h, s, v, a) => ({
9370
- h: tidy(clamp2(h, 0, 360)),
9371
- s: tidy(clamp2(s, 0, 100)),
9372
- v: tidy(clamp2(v, 0, 100)),
9373
- a: Math.round(clamp2(a, 0, 1) * 1e3) / 1e3
9814
+ h: tidy(clamp3(h, 0, 360)),
9815
+ s: tidy(clamp3(s, 0, 100)),
9816
+ v: tidy(clamp3(v, 0, 100)),
9817
+ a: Math.round(clamp3(a, 0, 1) * 1e3) / 1e3
9374
9818
  });
9375
9819
  function hsvToRgb({ h, s, v, a }) {
9376
9820
  const sat = s / 100;
@@ -9415,7 +9859,7 @@ var number = (text, scale) => {
9415
9859
  if (!Number.isFinite(value)) return Number.NaN;
9416
9860
  return text.trim().endsWith("%") ? value / 100 * scale : value;
9417
9861
  };
9418
- var alphaOf = (text) => text === void 0 ? 1 : clamp2(number(text, 1), 0, 1);
9862
+ var alphaOf = (text) => text === void 0 ? 1 : clamp3(number(text, 1), 0, 1);
9419
9863
  var angle = (text) => {
9420
9864
  const value = Number.parseFloat(text);
9421
9865
  if (!Number.isFinite(value)) return Number.NaN;
@@ -9452,7 +9896,7 @@ function parseColor(input, hue) {
9452
9896
  const [r, g, b] = rgb.slice(0, 3).map((part3) => number(part3, 255));
9453
9897
  const a = alphaOf(rgb[3]);
9454
9898
  if (![r, g, b, a].every(Number.isFinite)) return null;
9455
- return rgbToHsv({ r: clamp2(r, 0, 255), g: clamp2(g, 0, 255), b: clamp2(b, 0, 255), a }, hue);
9899
+ return rgbToHsv({ r: clamp3(r, 0, 255), g: clamp3(g, 0, 255), b: clamp3(b, 0, 255), a }, hue);
9456
9900
  }
9457
9901
  const hsl = args(text, "hsl");
9458
9902
  if (hsl) {
@@ -9461,7 +9905,7 @@ function parseColor(input, hue) {
9461
9905
  const l = Number.parseFloat(hsl[2]);
9462
9906
  const a = alphaOf(hsl[3]);
9463
9907
  if (![h, s, l, a].every(Number.isFinite)) return null;
9464
- const color = hslToHsv({ h: wrapHue(h), s: clamp2(s, 0, 100), l: clamp2(l, 0, 100), a });
9908
+ const color = hslToHsv({ h: wrapHue(h), s: clamp3(s, 0, 100), l: clamp3(l, 0, 100), a });
9465
9909
  return color.s === 0 && hue !== void 0 ? { ...color, h: hue } : color;
9466
9910
  }
9467
9911
  return null;
@@ -9471,7 +9915,7 @@ function toHsva(input, fallback = DEFAULT) {
9471
9915
  if (input && typeof input === "object") return hsva(input.h, input.s, input.v, input.a ?? 1);
9472
9916
  return parseColor(input, fallback.h) ?? { ...fallback };
9473
9917
  }
9474
- var byte = (n) => Math.round(clamp2(n, 0, 255));
9918
+ var byte = (n) => Math.round(clamp3(n, 0, 255));
9475
9919
  var hex2 = (n) => byte(n).toString(16).padStart(2, "0");
9476
9920
  var short = (n) => String(Math.round(n * 100) / 100);
9477
9921
  function toHex(color) {
@@ -9519,7 +9963,7 @@ function getChannel(color, channel) {
9519
9963
  }
9520
9964
  function setChannel(color, channel, value) {
9521
9965
  const [min, max] = CHANNEL_RANGE[channel];
9522
- const next = clamp2(value, min, max);
9966
+ const next = clamp3(value, min, max);
9523
9967
  switch (channel) {
9524
9968
  case "hue":
9525
9969
  return hsva(next, color.s, color.v, color.a);
@@ -11098,7 +11542,7 @@ var ERRORS = {
11098
11542
  bounds: "Fecha fuera del rango permitido",
11099
11543
  blocked: "El rango incluye d\xEDas no disponibles"
11100
11544
  };
11101
- var sequence11 = 0;
11545
+ var sequence12 = 0;
11102
11546
  var SETTLE = 0.35;
11103
11547
  var dateOf = (values) => {
11104
11548
  const { day: day2, month, year } = values;
@@ -11121,7 +11565,7 @@ function createDateRangePicker(root, options = {}) {
11121
11565
  effects.add(animation);
11122
11566
  for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
11123
11567
  };
11124
- const uid2 = `mk-range-${++sequence11}`;
11568
+ const uid2 = `mk-range-${++sequence12}`;
11125
11569
  const locale = options.locale ?? root.closest("[lang]")?.getAttribute("lang") ?? "es";
11126
11570
  const unavailable = options.unavailable;
11127
11571
  const rules = {
@@ -11357,7 +11801,7 @@ function createDateRangePicker(root, options = {}) {
11357
11801
 
11358
11802
  // src/core/position.ts
11359
11803
  var OPPOSITE = { top: "bottom", bottom: "top", left: "right", right: "left" };
11360
- var clamp3 = (value, min, max) => Math.max(min, Math.min(value, max));
11804
+ var clamp4 = (value, min, max) => Math.max(min, Math.min(value, max));
11361
11805
  var round2 = (n) => Math.round(n * 100) / 100;
11362
11806
  function place2(anchor, size, options = {}) {
11363
11807
  const { placement = "top", gap = 8, edge = 8, align = "center", arrowPad = 12 } = options;
@@ -11383,16 +11827,16 @@ function place2(anchor, size, options = {}) {
11383
11827
  if (vertical) {
11384
11828
  y = side === "top" ? anchor.top - gap - size.height : anchor.top + anchor.height + gap;
11385
11829
  x = align === "start" ? anchor.left : align === "end" ? anchor.left + anchor.width - size.width : anchor.left + anchor.width / 2 - size.width / 2;
11386
- x = clamp3(x, edge, view.width - edge - size.width);
11830
+ x = clamp4(x, edge, view.width - edge - size.width);
11387
11831
  } else {
11388
11832
  x = side === "left" ? anchor.left - gap - size.width : anchor.left + anchor.width + gap;
11389
11833
  y = align === "start" ? anchor.top : align === "end" ? anchor.top + anchor.height - size.height : anchor.top + anchor.height / 2 - size.height / 2;
11390
- y = clamp3(y, edge, view.height - edge - size.height);
11834
+ y = clamp4(y, edge, view.height - edge - size.height);
11391
11835
  }
11392
11836
  const length = vertical ? size.width : size.height;
11393
11837
  const centre = vertical ? anchor.left + anchor.width / 2 - x : anchor.top + anchor.height / 2 - y;
11394
11838
  const pad3 = Math.min(arrowPad, length / 2);
11395
- return { side, x: round2(x), y: round2(y), arrow: round2(clamp3(centre, pad3, length - pad3)) };
11839
+ return { side, x: round2(x), y: round2(y), arrow: round2(clamp4(centre, pad3, length - pad3)) };
11396
11840
  }
11397
11841
  function originOf({ side, arrow }) {
11398
11842
  if (side === "top") return `${arrow}px 100%`;
@@ -11404,7 +11848,7 @@ function originOf({ side, arrow }) {
11404
11848
  // src/components/tooltip/engine.ts
11405
11849
  var FOCUSABLE2 = 'a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
11406
11850
  var WARM = 400;
11407
- var sequence12 = 0;
11851
+ var sequence13 = 0;
11408
11852
  var current2 = null;
11409
11853
  var lastHidden = -Infinity;
11410
11854
  var now = () => typeof performance !== "undefined" ? performance.now() : Date.now();
@@ -11427,7 +11871,7 @@ function createTooltip(root, options = {}) {
11427
11871
  const bubble = document.createElement("div");
11428
11872
  bubble.dataset.mkTooltipBubble = "";
11429
11873
  bubble.setAttribute("role", "tooltip");
11430
- bubble.id = `mk-tooltip-${++sequence12}`;
11874
+ bubble.id = `mk-tooltip-${++sequence13}`;
11431
11875
  if (options.interactive) bubble.dataset.mkInteractive = "";
11432
11876
  const label = document.createElement("span");
11433
11877
  label.dataset.mkTooltipText = "";
@@ -11628,7 +12072,7 @@ function createTooltip(root, options = {}) {
11628
12072
  }
11629
12073
 
11630
12074
  // src/components/popover/engine.ts
11631
- var sequence13 = 0;
12075
+ var sequence14 = 0;
11632
12076
  function createPopover(root, options = {}) {
11633
12077
  const inertInstance = inert({ open() {
11634
12078
  }, close() {
@@ -11654,7 +12098,7 @@ function createPopover(root, options = {}) {
11654
12098
  }
11655
12099
  const panel = dialog;
11656
12100
  scope.attr(panel, "class", [panel.getAttribute("class"), "mk-dialog", "mk-popover-panel"].filter(Boolean).join(" "));
11657
- if (!panel.id) scope.attr(panel, "id", `mk-popover-${++sequence13}`);
12101
+ if (!panel.id) scope.attr(panel, "id", `mk-popover-${++sequence14}`);
11658
12102
  if (!panel.hasAttribute("aria-label") && !panel.hasAttribute("aria-labelledby")) scope.attr(panel, "aria-label", options.label ?? trigger.textContent?.trim() ?? "Panel");
11659
12103
  scope.attr(trigger, "aria-haspopup", "dialog");
11660
12104
  scope.attr(trigger, "aria-expanded", "false");
@@ -12919,7 +13363,7 @@ function createChips(options) {
12919
13363
 
12920
13364
  // src/core/listbox.ts
12921
13365
  var CHECK3 = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5" pathLength="1"/></svg>';
12922
- var sequence14 = 0;
13366
+ var sequence15 = 0;
12923
13367
  function marked2(text, query) {
12924
13368
  const fragment = document.createDocumentFragment();
12925
13369
  const match = query.trim() ? matchScore(query, text) : null;
@@ -12941,7 +13385,7 @@ function filterOptions(options, query) {
12941
13385
  function createListbox(options) {
12942
13386
  registerMotion();
12943
13387
  const scope = createScope();
12944
- const uid2 = `mk-listbox-${++sequence14}`;
13388
+ const uid2 = `mk-listbox-${++sequence15}`;
12945
13389
  const list3 = document.createElement("div");
12946
13390
  list3.id = uid2;
12947
13391
  list3.dataset.mkListbox = "";
@@ -13404,7 +13848,7 @@ function createMultiSelect(root, settings = {}) {
13404
13848
  // src/components/tag-input/engine.ts
13405
13849
  var fold2 = (text) => text.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
13406
13850
  var SEPARATORS = /[,;\n]+/;
13407
- var sequence15 = 0;
13851
+ var sequence16 = 0;
13408
13852
  function createTagInput(root, settings = {}) {
13409
13853
  if (!root) return inert({ setValue() {
13410
13854
  }, add: () => false, remove() {
@@ -13412,7 +13856,7 @@ function createTagInput(root, settings = {}) {
13412
13856
  }, value: [] });
13413
13857
  registerMotion();
13414
13858
  const scope = createScope();
13415
- const uid2 = `mk-tags-${++sequence15}`;
13859
+ const uid2 = `mk-tags-${++sequence16}`;
13416
13860
  const max = Number.isFinite(settings.max) && settings.max > 0 ? Math.floor(settings.max) : Infinity;
13417
13861
  const clean = settings.transform ?? ((tag) => tag.replace(/\s+/g, " ").trim());
13418
13862
  let suggestions = [...settings.suggestions ?? []];
@@ -13657,7 +14101,7 @@ function createTagInput(root, settings = {}) {
13657
14101
 
13658
14102
  // src/components/date-time-picker/engine.ts
13659
14103
  var CALENDAR_ICON2 = '<svg aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3.5" y="5" width="17" height="15.5" rx="3"/><path d="M3.5 10h17M8 3v4M16 3v4"/><path d="M12 13.5v2.5l1.6 1"/></svg>';
13660
- var sequence16 = 0;
14104
+ var sequence17 = 0;
13661
14105
  var pad2 = (n) => String(n).padStart(2, "0");
13662
14106
  function toDateTimeValue(input) {
13663
14107
  if (input === null || input === void 0 || input === "") return null;
@@ -13692,7 +14136,7 @@ function createDateTimePicker(root, options = {}) {
13692
14136
  for (const effect of effects) effect.kill();
13693
14137
  effects.clear();
13694
14138
  });
13695
- const uid2 = `mk-datetime-${++sequence16}`;
14139
+ const uid2 = `mk-datetime-${++sequence17}`;
13696
14140
  const locale = options.locale ?? root.closest("[lang]")?.getAttribute("lang") ?? "es";
13697
14141
  const step = options.minuteStep && options.minuteStep > 0 ? Math.round(options.minuteStep) : 5;
13698
14142
  const min = toDateTimeValue(options.min);
@@ -13834,7 +14278,7 @@ function createDateTimePicker(root, options = {}) {
13834
14278
  result.setMinutes(Math.round(result.getMinutes() / step) * step);
13835
14279
  return result;
13836
14280
  };
13837
- const clamp5 = (date) => min && date < min ? new Date(min.getTime()) : max && date > max ? new Date(max.getTime()) : date;
14281
+ const clamp6 = (date) => min && date < min ? new Date(min.getTime()) : max && date > max ? new Date(max.getTime()) : date;
13838
14282
  const timeOfDay = () => {
13839
14283
  if (value) return { hour: value.getHours(), minute: value.getMinutes() };
13840
14284
  const time2 = timeField.value?.split(":").map(Number);
@@ -13855,7 +14299,7 @@ function createDateTimePicker(root, options = {}) {
13855
14299
  const { hour, minute } = timeOfDay();
13856
14300
  const next = new Date(range.start.getTime());
13857
14301
  next.setHours(hour, minute, 0, 0);
13858
- commit(clamp5(next), true);
14302
+ commit(clamp6(next), true);
13859
14303
  }
13860
14304
  });
13861
14305
  scope.add(() => calendar.destroy());
@@ -13871,7 +14315,7 @@ function createDateTimePicker(root, options = {}) {
13871
14315
  const base = value ?? toDate(options.today ?? /* @__PURE__ */ new Date());
13872
14316
  const next = new Date(base.getTime());
13873
14317
  next.setHours(hour, minute, 0, 0);
13874
- commit(clamp5(next), true);
14318
+ commit(clamp6(next), true);
13875
14319
  }
13876
14320
  });
13877
14321
  scope.add(() => timeField.destroy());
@@ -13970,8 +14414,8 @@ var OPERATORS = {
13970
14414
  { id: "false", label: "es no", arity: 0 }
13971
14415
  ]
13972
14416
  };
13973
- var sequence17 = 0;
13974
- var filterId = () => `f${(++sequence17).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
14417
+ var sequence18 = 0;
14418
+ var filterId = () => `f${(++sequence18).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
13975
14419
  var isGroup = (node) => "rules" in node && Array.isArray(node.rules);
13976
14420
  var emptyFilter = (combinator = "and") => ({ id: filterId(), combinator, rules: [] });
13977
14421
  var typeOf = (field) => field?.type ?? "text";
@@ -14164,6 +14608,9 @@ function createSelect(root, options = {}) {
14164
14608
  dialog.className = "mk-dialog mk-menu mk-select-menu";
14165
14609
  dialog.dataset.mkSelectMenu = "";
14166
14610
  dialog.setAttribute("aria-label", options.label ?? "Opciones");
14611
+ const list3 = document.createElement("div");
14612
+ list3.dataset.mkSelectList = "";
14613
+ dialog.append(list3);
14167
14614
  root.append(dialog);
14168
14615
  made.push(dialog);
14169
14616
  scope.attr(root, "data-mk-ready", "");
@@ -14201,7 +14648,7 @@ function createSelect(root, options = {}) {
14201
14648
  nodes.push(heading, ...[...child.children].filter((node) => node instanceof HTMLOptionElement).map(item));
14202
14649
  } else if (child instanceof HTMLOptionElement) nodes.push(item(child));
14203
14650
  }
14204
- dialog.replaceChildren(...nodes);
14651
+ list3.replaceChildren(...nodes);
14205
14652
  };
14206
14653
  const placeholderText = () => options.placeholder ?? choices().find((option) => option.value === "")?.text ?? "Elige\u2026";
14207
14654
  const markItems = () => {
@@ -14237,13 +14684,18 @@ function createSelect(root, options = {}) {
14237
14684
  options.onChange?.(value);
14238
14685
  root.dispatchEvent(new CustomEvent("mk:change", { bubbles: true, detail: { value } }));
14239
14686
  };
14687
+ const area = createScrollArea(dialog, { viewport: list3, axis: "y", focusable: false, decorative: true });
14240
14688
  const menu = createMenu(dialog, {
14241
14689
  triggers: false,
14242
- onOpen: markItems,
14690
+ onOpen: () => {
14691
+ markItems();
14692
+ area.refresh();
14693
+ },
14243
14694
  onClose: () => trigger.setAttribute("aria-expanded", "false"),
14244
14695
  onSelect: (value) => choose(value, true)
14245
14696
  });
14246
14697
  scope.add(() => menu.destroy());
14698
+ scope.add(() => area.destroy());
14247
14699
  scope.on(dialog, "mk:select", (event) => event.stopPropagation());
14248
14700
  const open = () => {
14249
14701
  if (trigger.disabled || menu.isOpen) return;
@@ -14263,10 +14715,10 @@ function createSelect(root, options = {}) {
14263
14715
  open();
14264
14716
  } else if (key2.key.length === 1 && key2.key.trim()) {
14265
14717
  const letter = fold4(key2.key);
14266
- const list3 = choices();
14267
- const from = list3.findIndex((option) => option.value === select.value);
14268
- for (let step = 1; step <= list3.length; step++) {
14269
- const option = list3[(from + step) % list3.length];
14718
+ const list4 = choices();
14719
+ const from = list4.findIndex((option) => option.value === select.value);
14720
+ for (let step = 1; step <= list4.length; step++) {
14721
+ const option = list4[(from + step) % list4.length];
14270
14722
  if (!option.disabled && option.value !== "" && fold4(option.text).startsWith(letter)) {
14271
14723
  choose(option.value, true);
14272
14724
  break;
@@ -15286,7 +15738,7 @@ function moveTreeNode(nodes, id, into) {
15286
15738
  }
15287
15739
  var CHEVRON3 = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>';
15288
15740
  var CHECK5 = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path data-mk-tree-tick d="M5 12.5l4.5 4.5L19 7.5" pathLength="1"/><path data-mk-tree-dash d="M6 12h12"/></svg>';
15289
- var sequence18 = 0;
15741
+ var sequence19 = 0;
15290
15742
  var fold6 = foldText;
15291
15743
  function createTreeView(root, options = {}) {
15292
15744
  if (!root) return inert({ expand() {
@@ -15303,7 +15755,7 @@ function createTreeView(root, options = {}) {
15303
15755
  }, selected: null, checked: [], expanded: [], element: null });
15304
15756
  registerMotion();
15305
15757
  const scope = createScope();
15306
- const uid2 = `mk-tree-${++sequence18}`;
15758
+ const uid2 = `mk-tree-${++sequence19}`;
15307
15759
  let nodes = fromJson(options.nodes) ?? [];
15308
15760
  const expanded = /* @__PURE__ */ new Set();
15309
15761
  if (options.expanded === true) walk(nodes, (node) => isBranch(node) && expanded.add(node.id));
@@ -15979,7 +16431,7 @@ var FOLDER2 = '<svg aria-hidden="true" viewBox="0 0 48 40"><path data-mk-fx-fold
15979
16431
  var PAGE2 = '<svg aria-hidden="true" viewBox="0 0 40 48"><path data-mk-fx-page d="M7 2h18.5L37 13.5V42a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4z"/><path data-mk-fx-fold d="M25.5 2v8.5a3 3 0 0 0 3 3H37z"/></svg>';
15980
16432
  var SORT_LABEL = { name: "Nombre", size: "Tama\xF1o", modified: "Modificado" };
15981
16433
  var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
15982
- var sequence19 = 0;
16434
+ var sequence20 = 0;
15983
16435
  function iconOf(entry) {
15984
16436
  const icon2 = document.createElement("span");
15985
16437
  icon2.dataset.mkFxIcon = "";
@@ -16023,7 +16475,7 @@ function createFileExplorer(root, options = {}) {
16023
16475
  }
16024
16476
  registerMotion();
16025
16477
  const scope = createScope();
16026
- const uid2 = `mk-fx-${++sequence19}`;
16478
+ const uid2 = `mk-fx-${++sequence20}`;
16027
16479
  const locale = options.locale ?? root.closest("[lang]")?.getAttribute("lang") ?? "es";
16028
16480
  const readOnly = Boolean(options.readOnly);
16029
16481
  const top = { id: ROOT_FOLDER, name: options.rootLabel ?? "Inicio", kind: "folder", children: cloneEntries(fromJson(options.files) ?? []) };
@@ -17498,7 +17950,7 @@ function createSizes(heights) {
17498
17950
 
17499
17951
  // src/components/virtual-list/engine.ts
17500
17952
  var FOOT_HEIGHT = 48;
17501
- var sequence20 = 0;
17953
+ var sequence21 = 0;
17502
17954
  var defaultText = (item) => {
17503
17955
  if (item === null || item === void 0) return "";
17504
17956
  if (typeof item !== "object") return String(item);
@@ -17529,7 +17981,7 @@ function createVirtualList(root, options = {}) {
17529
17981
  }
17530
17982
  registerMotion();
17531
17983
  const scope = createScope();
17532
- const uid2 = `mk-vl-${++sequence20}`;
17984
+ const uid2 = `mk-vl-${++sequence21}`;
17533
17985
  const locale = options.locale ?? root.closest("[lang]")?.getAttribute("lang") ?? "es";
17534
17986
  const adopted = root.querySelector(":scope > [data-mk-vl-viewport]");
17535
17987
  const authored = [...root.querySelectorAll(":scope > ul > li, :scope > ol > li")].map((li) => li.textContent?.trim() ?? "");
@@ -18068,7 +18520,7 @@ function createVirtualList(root, options = {}) {
18068
18520
  // src/components/resizable-panel/engine.ts
18069
18521
  var CHEVRON4 = (path) => `<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="${path}"/></svg>`;
18070
18522
  var ARROWS = { left: CHEVRON4("M15 6l-6 6 6 6"), right: CHEVRON4("M9 6l6 6-6 6"), up: CHEVRON4("M6 15l6-6 6 6"), down: CHEVRON4("M6 9l6 6 6-6") };
18071
- var sequence21 = 0;
18523
+ var sequence22 = 0;
18072
18524
  var round3 = (n) => Math.round(n * 10) / 10;
18073
18525
  function normaliseSizes(sizes, count) {
18074
18526
  const given = Array.from({ length: count }, (_, i) => {
@@ -18095,7 +18547,7 @@ function createResizablePanel(root, options = {}) {
18095
18547
  }
18096
18548
  registerMotion();
18097
18549
  const scope = createScope();
18098
- const uid2 = `mk-rp-${++sequence21}`;
18550
+ const uid2 = `mk-rp-${++sequence22}`;
18099
18551
  const panels = [...root.children].filter((child) => child instanceof HTMLElement && !child.hasAttribute("data-mk-resize-handle"));
18100
18552
  const count = panels.length;
18101
18553
  let orientation = options.orientation === "vertical" ? "vertical" : "horizontal";
@@ -18597,7 +19049,7 @@ var ICONS3 = {
18597
19049
  };
18598
19050
  var CHECK7 = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path data-mk-dt-tick d="M5.5 12l4 4L18.5 7.5" pathLength="1"/><path data-mk-dt-dash d="M6.5 12h11"/></svg>';
18599
19051
  var plural3 = (n, one, many) => `${n} ${n === 1 ? one : many}`;
18600
- var sequence22 = 0;
19052
+ var sequence23 = 0;
18601
19053
  function createDataTable(root, options = {}) {
18602
19054
  if (!root) {
18603
19055
  return inert({
@@ -18642,7 +19094,7 @@ function createDataTable(root, options = {}) {
18642
19094
  }
18643
19095
  registerMotion();
18644
19096
  const scope = createScope();
18645
- const uid2 = `mk-dt-${++sequence22}`;
19097
+ const uid2 = `mk-dt-${++sequence23}`;
18646
19098
  const locale = options.locale ?? root.closest("[lang]")?.getAttribute("lang") ?? "es";
18647
19099
  const columns = (fromJson(options.columns) ?? []).map((column) => ({ ...column }));
18648
19100
  let rows = [...fromJson(options.rows) ?? []];
@@ -19539,7 +19991,7 @@ function createDataTable(root, options = {}) {
19539
19991
 
19540
19992
  // src/components/editable-table/engine.ts
19541
19993
  var plural4 = (n, one, many) => `${n} ${n === 1 ? one : many}`;
19542
- var sequence23 = 0;
19994
+ var sequence24 = 0;
19543
19995
  var sameValue = (a, b) => a === b || (a === null || a === void 0 || a === "") && (b === null || b === void 0 || b === "");
19544
19996
  function createEditableTable(root, options = {}) {
19545
19997
  if (!root) {
@@ -19563,7 +20015,7 @@ function createEditableTable(root, options = {}) {
19563
20015
  }
19564
20016
  registerMotion();
19565
20017
  const scope = createScope();
19566
- const uid2 = `mk-et-${++sequence23}`;
20018
+ const uid2 = `mk-et-${++sequence24}`;
19567
20019
  const columns = (fromJson(options.columns) ?? []).map((column) => ({ ...column }));
19568
20020
  const rowKey = options.rowKey ?? "id";
19569
20021
  const idOf = (row) => typeof rowKey === "function" ? rowKey(row) : row[rowKey];
@@ -21231,7 +21683,7 @@ var sameStrokes = (left, right) => left.length === right.length && left.every((s
21231
21683
  return stroke.color === other.color && stroke.width === other.width && stroke.points.length === other.points.length && stroke.points.every((point, index2) => point.x === other.points[index2].x && point.y === other.points[index2].y);
21232
21684
  });
21233
21685
  var finite5 = (value) => typeof value === "number" && Number.isFinite(value);
21234
- var clamp4 = (value, min, max) => Math.min(max, Math.max(min, value));
21686
+ var clamp5 = (value, min, max) => Math.min(max, Math.max(min, value));
21235
21687
  function validColor(value) {
21236
21688
  if (typeof value !== "string" || value.length > 100) return false;
21237
21689
  if (/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(value)) return true;
@@ -21319,8 +21771,8 @@ function createSignaturePad(root, options = {}) {
21319
21771
  let readOnly = Boolean(options.readOnly);
21320
21772
  let undoStack = [];
21321
21773
  let redoStack = [];
21322
- const historyLimit = finite5(options.historyLimit) ? clamp4(Math.floor(options.historyLimit), 1, 100) : 50;
21323
- const inkWidth = finite5(options.width) ? clamp4(options.width, 0.1, 64) : 2.4;
21774
+ const historyLimit = finite5(options.historyLimit) ? clamp5(Math.floor(options.historyLimit), 1, 100) : 50;
21775
+ const inkWidth = finite5(options.width) ? clamp5(options.width, 0.1, 64) : 2.4;
21324
21776
  const exportData = () => ({ version: 1, strokes: cloneStrokes(strokes) });
21325
21777
  const wrapper = document.createElement("div");
21326
21778
  wrapper.dataset.mkSignatureBody = "";
@@ -21588,7 +22040,7 @@ function createSignaturePad(root, options = {}) {
21588
22040
  const pointFrom = (event) => {
21589
22041
  const rect = surface.getBoundingClientRect();
21590
22042
  if (!rect.width || !rect.height || !finite5(event.clientX) || !finite5(event.clientY)) return null;
21591
- return { x: clamp4((event.clientX - rect.left) / rect.width, 0, 1), y: clamp4((event.clientY - rect.top) / rect.height, 0, 1) };
22043
+ return { x: clamp5((event.clientX - rect.left) / rect.width, 0, 1), y: clamp5((event.clientY - rect.top) / rect.height, 0, 1) };
21592
22044
  };
21593
22045
  const addPoint = (event) => {
21594
22046
  if (!active) return;
@@ -21669,8 +22121,8 @@ function createSignaturePad(root, options = {}) {
21669
22121
  render();
21670
22122
  update();
21671
22123
  const exportSVG = (settings = {}) => {
21672
- const width = finite5(settings.width) ? clamp4(settings.width, 1, 4096) : dimensions.width;
21673
- const height = finite5(settings.height) ? clamp4(settings.height, 1, 4096) : dimensions.height;
22124
+ const width = finite5(settings.width) ? clamp5(settings.width, 1, 4096) : dimensions.width;
22125
+ const height = finite5(settings.height) ? clamp5(settings.height, 1, 4096) : dimensions.height;
21674
22126
  const output = document.createElementNS(SVG_NS, "svg");
21675
22127
  output.setAttribute("width", String(rounded(width)));
21676
22128
  output.setAttribute("height", String(rounded(height)));
@@ -21732,9 +22184,9 @@ function createSignaturePad(root, options = {}) {
21732
22184
  return Promise.resolve(null);
21733
22185
  }
21734
22186
  if (!context || typeof canvas.toBlob !== "function") return Promise.resolve(null);
21735
- const scale = finite5(settings.scale) ? clamp4(settings.scale, 1, 4) : 2;
21736
- canvas.width = Math.round((finite5(settings.width) ? clamp4(settings.width, 1, 4096) : dimensions.width) * scale);
21737
- canvas.height = Math.round((finite5(settings.height) ? clamp4(settings.height, 1, 4096) : dimensions.height) * scale);
22187
+ const scale = finite5(settings.scale) ? clamp5(settings.scale, 1, 4) : 2;
22188
+ canvas.width = Math.round((finite5(settings.width) ? clamp5(settings.width, 1, 4096) : dimensions.width) * scale);
22189
+ canvas.height = Math.round((finite5(settings.height) ? clamp5(settings.height, 1, 4096) : dimensions.height) * scale);
21738
22190
  return new Promise((resolve2) => {
21739
22191
  const image = new Image();
21740
22192
  let finished = false;
@@ -22216,7 +22668,7 @@ function createVoiceMessageBubble(root, options = {}) {
22216
22668
 
22217
22669
  // src/components/drilldown-menu/engine.ts
22218
22670
  var CHEVRON5 = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 6 6 6-6 6"/></svg>';
22219
- var sequence24 = 0;
22671
+ var sequence25 = 0;
22220
22672
  var samePath = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
22221
22673
  var branch = (item) => Array.isArray(item.children);
22222
22674
  var copyItems = (items) => items.map((item) => ({ ...item, ...branch(item) ? { children: copyItems(item.children) } : {} }));
@@ -22230,7 +22682,7 @@ function createDrilldownMenu(root, options = {}) {
22230
22682
  }, path: [], items: [], element: null });
22231
22683
  registerMotion();
22232
22684
  const scope = createScope();
22233
- const uid2 = `mk-drilldown-${++sequence24}`;
22685
+ const uid2 = `mk-drilldown-${++sequence25}`;
22234
22686
  const authored = [...root.childNodes];
22235
22687
  const holder = document.createDocumentFragment();
22236
22688
  holder.append(...authored);
@@ -22556,7 +23008,7 @@ function createDrilldownMenu(root, options = {}) {
22556
23008
  }
22557
23009
 
22558
23010
  // src/components/wheel-picker/engine.ts
22559
- var sequence25 = 0;
23011
+ var sequence26 = 0;
22560
23012
  function normalize(items) {
22561
23013
  const seen = /* @__PURE__ */ new Set();
22562
23014
  return items.flatMap((item) => {
@@ -22573,7 +23025,7 @@ function createWheelPicker(root, options = {}) {
22573
23025
  }, setItems() {
22574
23026
  }, value: "" });
22575
23027
  registerMotion();
22576
- const scope = createScope(), uid2 = `mk-wheel-${++sequence25}`;
23028
+ const scope = createScope(), uid2 = `mk-wheel-${++sequence26}`;
22577
23029
  let items = normalize(Array.isArray(options.items) ? options.items : []);
22578
23030
  const rawRows = Number.isFinite(options.visibleItems) ? Math.round(options.visibleItems) : 5;
22579
23031
  const rows = Math.min(9, Math.max(3, rawRows % 2 ? rawRows : rawRows + 1));
@@ -22910,9 +23362,9 @@ function createStepper(root, options = {}) {
22910
23362
  effects.clear();
22911
23363
  });
22912
23364
  const items = (Array.isArray(options.items) ? options.items : []).filter((item) => item && typeof item.label === "string");
22913
- const clamp5 = (n) => Math.max(0, Math.min(Math.max(0, items.length - 1), Number.isFinite(n) ? Math.round(n) : 0));
22914
- const initial = clamp5(options.defaultValue ?? options.value ?? 0);
22915
- let value = clamp5(options.value ?? initial);
23365
+ const clamp6 = (n) => Math.max(0, Math.min(Math.max(0, items.length - 1), Number.isFinite(n) ? Math.round(n) : 0));
23366
+ const initial = clamp6(options.defaultValue ?? options.value ?? 0);
23367
+ let value = clamp6(options.value ?? initial);
22916
23368
  let furthest = value;
22917
23369
  let pending = null;
22918
23370
  const nav = document.createElement("nav");
@@ -22996,7 +23448,7 @@ function createStepper(root, options = {}) {
22996
23448
  if (scope.disposed) return;
22997
23449
  if (notify) pending = { value, furthest };
22998
23450
  const before = value;
22999
- value = clamp5(next);
23451
+ value = clamp6(next);
23000
23452
  furthest = Math.max(furthest, value);
23001
23453
  paint(before !== value, before);
23002
23454
  if (before === value) return;
@@ -23031,7 +23483,7 @@ function createStepper(root, options = {}) {
23031
23483
  return value;
23032
23484
  },
23033
23485
  setValue(next, notify = false) {
23034
- const target = clamp5(next);
23486
+ const target = clamp6(next);
23035
23487
  if (!notify && pending && target === pending.value) furthest = pending.furthest;
23036
23488
  pending = null;
23037
23489
  choose(target, notify);
@@ -23048,7 +23500,7 @@ function createStepper(root, options = {}) {
23048
23500
  }
23049
23501
 
23050
23502
  // src/components/radio-group/shared.ts
23051
- var sequence26 = 0;
23503
+ var sequence27 = 0;
23052
23504
  function createChoices(root, prefix, options) {
23053
23505
  if (!root) return inert({ value: null, setValue() {
23054
23506
  }, reset() {
@@ -23078,7 +23530,7 @@ function createChoices(root, prefix, options) {
23078
23530
  group.setAttribute("aria-required", String(Boolean(options.required)));
23079
23531
  if (options.disabled) group.setAttribute("aria-disabled", "true");
23080
23532
  const message = part3("span", shell, "message");
23081
- message.id = `mk-${prefix}-message-${++sequence26}`;
23533
+ message.id = `mk-${prefix}-message-${++sequence27}`;
23082
23534
  message.setAttribute("aria-live", "polite");
23083
23535
  group.setAttribute("aria-describedby", message.id);
23084
23536
  if (options.error) group.setAttribute("aria-invalid", "true");
@@ -23088,7 +23540,7 @@ function createChoices(root, prefix, options) {
23088
23540
  seen.add(item.value);
23089
23541
  return true;
23090
23542
  });
23091
- const name = options.name ?? `mk-${prefix}-${sequence26}`;
23543
+ const name = options.name ?? `mk-${prefix}-${sequence27}`;
23092
23544
  const valid2 = (candidate) => candidate != null && items.some((item) => item.value === candidate) ? candidate : null;
23093
23545
  const initial = valid2(options.defaultValue !== void 0 ? options.defaultValue : options.value);
23094
23546
  let value = valid2(options.value !== void 0 ? options.value : initial);
@@ -23173,7 +23625,7 @@ function createRadioGroup(root, options = {}) {
23173
23625
 
23174
23626
  // src/components/equalizer-slider/shared.ts
23175
23627
  var finite7 = (n) => typeof n === "number" && Number.isFinite(n);
23176
- var sequence27 = 0;
23628
+ var sequence28 = 0;
23177
23629
  function createNumericRange(root, options, design) {
23178
23630
  if (!root) return inert({ value: design.value, setValue() {
23179
23631
  }, reset() {
@@ -23224,7 +23676,7 @@ function createNumericRange(root, options, design) {
23224
23676
  input.step = String(step);
23225
23677
  input.defaultValue = String(initial);
23226
23678
  input.value = String(value);
23227
- input.id = `mk-${prefix}-${++sequence27}`;
23679
+ input.id = `mk-${prefix}-${++sequence28}`;
23228
23680
  label.htmlFor = input.id;
23229
23681
  input.disabled = Boolean(options.disabled);
23230
23682
  if (options.name) input.name = options.name;
@@ -23495,7 +23947,7 @@ function createRatingScale(root, options = {}) {
23495
23947
  }
23496
23948
 
23497
23949
  // src/components/notification-stack/engine.ts
23498
- var sequence28 = 0;
23950
+ var sequence29 = 0;
23499
23951
  function createNotificationStack(root, options = {}) {
23500
23952
  if (!root) return inert({ push() {
23501
23953
  }, dismiss() {
@@ -23523,7 +23975,7 @@ function createNotificationStack(root, options = {}) {
23523
23975
  };
23524
23976
  const deck = document.createElement("div");
23525
23977
  deck.className = "mk-notification-stack__deck";
23526
- deck.id = `mk-notifications-${++sequence28}`;
23978
+ deck.id = `mk-notifications-${++sequence29}`;
23527
23979
  const empty = document.createElement("p");
23528
23980
  empty.className = "mk-notification-stack__empty";
23529
23981
  const toggle = document.createElement("button");
@@ -24812,7 +25264,7 @@ function createMagnetizeButton(root, options = {}) {
24812
25264
 
24813
25265
  // src/components/badge-button/engine.ts
24814
25266
  var normalize2 = (value) => Number.isFinite(value) ? Math.max(0, Math.min(Number.MAX_SAFE_INTEGER, Math.round(value))) : 0;
24815
- var sequence29 = 0;
25267
+ var sequence30 = 0;
24816
25268
  function createBadgeButton(root, options = {}) {
24817
25269
  if (!root) return inert({ setCount() {
24818
25270
  }, count: 0 });
@@ -24850,7 +25302,7 @@ function createBadgeButton(root, options = {}) {
24850
25302
  const authoredLabel = control.getAttribute("aria-label");
24851
25303
  const labelledBy = control.getAttribute("aria-labelledby");
24852
25304
  if (labelledBy?.trim()) {
24853
- spoken.id = `mk-badge-quantity-${++sequence29}`;
25305
+ spoken.id = `mk-badge-quantity-${++sequence30}`;
24854
25306
  scope.attr(control, "aria-labelledby", `${labelledBy} ${spoken.id}`);
24855
25307
  }
24856
25308
  scope.attr(control, "type", control.getAttribute("type") ?? "button");
@@ -25177,12 +25629,6 @@ export {
25177
25629
  sheetClose,
25178
25630
  pushUnderlay,
25179
25631
  releaseUnderlay,
25180
- createDialog,
25181
- createMenu,
25182
- chatBackgroundOf,
25183
- createChatBackground,
25184
- createSteps,
25185
- createQuantity,
25186
25632
  press,
25187
25633
  blurIn,
25188
25634
  blurOut,
@@ -25191,6 +25637,15 @@ export {
25191
25637
  ringPulse,
25192
25638
  burst,
25193
25639
  rollDigits,
25640
+ ICON_PATHS,
25641
+ iconSvg,
25642
+ createScrollArea,
25643
+ createDialog,
25644
+ createMenu,
25645
+ chatBackgroundOf,
25646
+ createChatBackground,
25647
+ createSteps,
25648
+ createQuantity,
25194
25649
  createPagination,
25195
25650
  createHoverCard,
25196
25651
  createInputOtp,
@@ -25340,4 +25795,4 @@ export {
25340
25795
  createMorphingPageDots,
25341
25796
  createNotFound
25342
25797
  };
25343
- //# sourceMappingURL=chunk-Q7IW4FV3.js.map
25798
+ //# sourceMappingURL=chunk-Y4GIBTRG.js.map