luxen-ui 0.8.0 → 0.9.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 (150) hide show
  1. package/bin/cli.mjs +135 -8
  2. package/cdn/chunks/floating-ui.dom.js +1 -1
  3. package/cdn/chunks/floating-ui.dom.js.map +1 -1
  4. package/cdn/custom-elements.json +521 -66
  5. package/cdn/elements/avatar/avatar.d.ts +8 -0
  6. package/cdn/elements/avatar/avatar.d.ts.map +1 -1
  7. package/cdn/elements/avatar/avatar.js +2 -2
  8. package/cdn/elements/avatar/avatar.js.map +1 -1
  9. package/cdn/elements/button/button.meta.d.ts +1 -1
  10. package/cdn/elements/button-group/button-group.d.ts +33 -0
  11. package/cdn/elements/button-group/button-group.d.ts.map +1 -0
  12. package/cdn/elements/button-group/button-group.js +2 -0
  13. package/cdn/elements/button-group/button-group.js.map +1 -0
  14. package/cdn/elements/button-group/index.d.ts +2 -0
  15. package/cdn/elements/button-group/index.d.ts.map +1 -0
  16. package/cdn/elements/button-group/index.js +2 -0
  17. package/cdn/elements/button-group/index.js.map +1 -0
  18. package/cdn/elements/checkbox/checkbox.meta.d.ts +31 -0
  19. package/cdn/elements/checkbox/checkbox.meta.d.ts.map +1 -0
  20. package/cdn/elements/checkbox/checkbox.meta.js +0 -0
  21. package/cdn/elements/dropdown/dropdown.d.ts +9 -1
  22. package/cdn/elements/dropdown/dropdown.d.ts.map +1 -1
  23. package/cdn/elements/dropdown/dropdown.js +2 -2
  24. package/cdn/elements/dropdown/dropdown.js.map +1 -1
  25. package/cdn/elements/dropdown-label/dropdown-label.d.ts +17 -0
  26. package/cdn/elements/dropdown-label/dropdown-label.d.ts.map +1 -0
  27. package/cdn/elements/dropdown-label/dropdown-label.js +4 -0
  28. package/cdn/elements/dropdown-label/dropdown-label.js.map +1 -0
  29. package/cdn/elements/dropdown-label/index.d.ts +2 -0
  30. package/cdn/elements/dropdown-label/index.d.ts.map +1 -0
  31. package/cdn/elements/dropdown-label/index.js +2 -0
  32. package/cdn/elements/dropdown-label/index.js.map +1 -0
  33. package/cdn/elements/form-field/form-field.d.ts +62 -0
  34. package/cdn/elements/form-field/form-field.d.ts.map +1 -0
  35. package/cdn/elements/form-field/form-field.js +2 -0
  36. package/cdn/elements/form-field/form-field.js.map +1 -0
  37. package/cdn/elements/form-field/index.d.ts +2 -0
  38. package/cdn/elements/form-field/index.d.ts.map +1 -0
  39. package/cdn/elements/form-field/index.js +2 -0
  40. package/cdn/elements/form-field/index.js.map +1 -0
  41. package/cdn/elements/prose-editor/prose-editor.d.ts +8 -0
  42. package/cdn/elements/prose-editor/prose-editor.d.ts.map +1 -1
  43. package/cdn/elements/prose-editor/prose-editor.js +1 -1
  44. package/cdn/elements/prose-editor/prose-editor.js.map +1 -1
  45. package/cdn/elements/tree/tree.d.ts.map +1 -1
  46. package/cdn/elements/tree/tree.js +1 -1
  47. package/cdn/elements/tree/tree.js.map +1 -1
  48. package/cdn/elements/tree-item/tree-item.d.ts.map +1 -1
  49. package/cdn/elements/tree-item/tree-item.js +3 -3
  50. package/cdn/elements/tree-item/tree-item.js.map +1 -1
  51. package/cdn/registry.d.ts +1 -1
  52. package/cdn/registry.d.ts.map +1 -1
  53. package/cdn/registry.js.map +1 -1
  54. package/cdn/shared/controllers/popover.d.ts +2 -0
  55. package/cdn/shared/controllers/popover.d.ts.map +1 -1
  56. package/cdn/shared/controllers/popover.js +1 -1
  57. package/cdn/shared/controllers/popover.js.map +1 -1
  58. package/cdn/shared/styles/checkbox-appearance.styles.d.ts +9 -0
  59. package/cdn/shared/styles/checkbox-appearance.styles.d.ts.map +1 -0
  60. package/cdn/shared/styles/checkbox-appearance.styles.js +2 -0
  61. package/cdn/shared/styles/checkbox-appearance.styles.js.map +1 -0
  62. package/cdn/standalone.css +337 -9
  63. package/cdn/standalone.js +364 -31
  64. package/cdn/standalone.js.map +1 -1
  65. package/cdn/styles/elements/button-group.css +88 -0
  66. package/cdn/styles/elements/button.css +7 -2
  67. package/cdn/styles/elements/checkbox.css +101 -0
  68. package/cdn/styles/elements/form-field.css +67 -0
  69. package/cdn/styles/elements/input-stepper/default.css +10 -4
  70. package/cdn/styles/elements/input-stepper/rounded.css +9 -3
  71. package/cdn/styles/preset.css +49 -0
  72. package/cdn/styles/tokens/forms.css +52 -0
  73. package/cdn/styles/tokens.css +49 -0
  74. package/dist/css/elements/button-group.css +88 -0
  75. package/dist/css/elements/button.css +7 -2
  76. package/dist/css/elements/checkbox.css +101 -0
  77. package/dist/css/elements/form-field.css +67 -0
  78. package/dist/css/elements/input-stepper/default.css +10 -4
  79. package/dist/css/elements/input-stepper/rounded.css +9 -3
  80. package/dist/css/preset.css +49 -0
  81. package/dist/css/tokens/forms.css +52 -0
  82. package/dist/css/tokens.css +49 -0
  83. package/dist/custom-elements.json +521 -66
  84. package/dist/elements/avatar/avatar.css +37 -10
  85. package/dist/elements/avatar/avatar.d.ts +8 -0
  86. package/dist/elements/avatar/avatar.d.ts.map +1 -1
  87. package/dist/elements/avatar/avatar.js +9 -1
  88. package/dist/elements/button/button.meta.d.ts +1 -1
  89. package/dist/elements/button/button.meta.js +1 -1
  90. package/dist/elements/button-group/button-group.d.ts +33 -0
  91. package/dist/elements/button-group/button-group.d.ts.map +1 -0
  92. package/dist/elements/button-group/button-group.js +57 -0
  93. package/dist/elements/button-group/index.d.ts +2 -0
  94. package/dist/elements/button-group/index.d.ts.map +1 -0
  95. package/dist/elements/button-group/index.js +4 -0
  96. package/dist/elements/checkbox/checkbox.meta.d.ts +31 -0
  97. package/dist/elements/checkbox/checkbox.meta.d.ts.map +1 -0
  98. package/dist/elements/checkbox/checkbox.meta.js +41 -0
  99. package/dist/elements/dropdown/dropdown.css +0 -1
  100. package/dist/elements/dropdown/dropdown.d.ts +9 -1
  101. package/dist/elements/dropdown/dropdown.d.ts.map +1 -1
  102. package/dist/elements/dropdown/dropdown.js +21 -4
  103. package/dist/elements/dropdown-label/dropdown-label.css +18 -0
  104. package/dist/elements/dropdown-label/dropdown-label.d.ts +17 -0
  105. package/dist/elements/dropdown-label/dropdown-label.d.ts.map +1 -0
  106. package/dist/elements/dropdown-label/dropdown-label.js +31 -0
  107. package/dist/elements/dropdown-label/index.d.ts +2 -0
  108. package/dist/elements/dropdown-label/index.d.ts.map +1 -0
  109. package/dist/elements/dropdown-label/index.js +4 -0
  110. package/dist/elements/form-field/form-field.d.ts +62 -0
  111. package/dist/elements/form-field/form-field.d.ts.map +1 -0
  112. package/dist/elements/form-field/form-field.js +191 -0
  113. package/dist/elements/form-field/index.d.ts +2 -0
  114. package/dist/elements/form-field/index.d.ts.map +1 -0
  115. package/dist/elements/form-field/index.js +4 -0
  116. package/dist/elements/prose-editor/prose-editor.d.ts +8 -0
  117. package/dist/elements/prose-editor/prose-editor.d.ts.map +1 -1
  118. package/dist/elements/prose-editor/prose-editor.js +50 -11
  119. package/dist/elements/tree/tree.d.ts.map +1 -1
  120. package/dist/elements/tree/tree.js +11 -1
  121. package/dist/elements/tree-item/tree-item.css +6 -12
  122. package/dist/elements/tree-item/tree-item.d.ts.map +1 -1
  123. package/dist/elements/tree-item/tree-item.js +3 -2
  124. package/dist/metadata/avatar.json +16 -6
  125. package/dist/metadata/button-group.json +49 -0
  126. package/dist/metadata/button.json +2 -2
  127. package/dist/metadata/checkbox.json +89 -0
  128. package/dist/metadata/dropdown-label.json +37 -0
  129. package/dist/metadata/dropdown.json +9 -1
  130. package/dist/metadata/form-field.json +87 -0
  131. package/dist/metadata/index.json +290 -10
  132. package/dist/registry.d.ts +1 -1
  133. package/dist/registry.d.ts.map +1 -1
  134. package/dist/shared/controllers/popover.d.ts +2 -0
  135. package/dist/shared/controllers/popover.d.ts.map +1 -1
  136. package/dist/shared/controllers/popover.js +14 -1
  137. package/dist/shared/styles/checkbox-appearance.css +92 -0
  138. package/dist/shared/styles/checkbox-appearance.styles.d.ts +9 -0
  139. package/dist/shared/styles/checkbox-appearance.styles.d.ts.map +1 -0
  140. package/dist/shared/styles/checkbox-appearance.styles.js +9 -0
  141. package/dist/templates/elements/avatar.md +19 -17
  142. package/dist/templates/elements/button-group.md +164 -0
  143. package/dist/templates/elements/button.md +9 -11
  144. package/dist/templates/elements/checkbox.md +200 -0
  145. package/dist/templates/elements/form-field.md +115 -0
  146. package/dist/templates/elements/tree.md +8 -8
  147. package/elements.json +34 -0
  148. package/package.json +5 -1
  149. package/templates/SKILL.md.tpl +15 -1
  150. package/templates/integration.md.tpl +1 -1
package/bin/cli.mjs CHANGED
@@ -122,7 +122,7 @@ const DEFAULT_CONFIG = {
122
122
  name: 'luxen-ui',
123
123
  displayName: 'Luxen UI',
124
124
  description:
125
- 'Generate UI with Luxen UI, a CSS-first web component library. Provides CSS classes for native HTML elements and custom elements (l-badge, l-dialog, l-toast). Use when building interfaces with Luxen UI.',
125
+ "Build, edit, migrate, or review UI with Luxen UI, a CSS-first web component library. Provides CSS classes for native HTML elements plus custom elements (l-badge, l-dialog, l-toast). Use whenever a task touches UI in a project using Luxen UI — creating or styling interfaces, editing or refactoring existing components, reviewing UI, or migrating from another component library to Luxen (replacing another library's web components with Luxen elements). Each element has a per-element spec under references/.",
126
126
  // Prefixes use the Vite plugin convention: bare identifier without trailing
127
127
  // dash. `elementPrefix: 'pulse'` means tags are `<pulse-badge>`, type selectors
128
128
  // are `pulse-badge`. `cssPrefix: 'pulse'` controls `.pulse-button` classes,
@@ -293,6 +293,14 @@ async function runGenerateSkill(ctx) {
293
293
  writeFileSync(dst, out, 'utf-8');
294
294
  }
295
295
 
296
+ // 4b. Design-token reference — generated from the shipped token CSS, prefix-
297
+ // substituted (`--l-*` → css prefix; Tailwind utility names pass through).
298
+ writeFileSync(
299
+ join(ctx.outDir, 'references', 'tokens.md'),
300
+ applyPackageName(applyPrefix(buildTokensDoc(ctx), ctx), ctx),
301
+ 'utf-8',
302
+ );
303
+
296
304
  // Everything below is mockup / Claude Design mode only — the standalone
297
305
  // bundle and the docs that point at it. Skipped unless `--with-mockups`.
298
306
  if (!ctx.mockups) return;
@@ -404,6 +412,12 @@ function applyPackageName(content, ctx) {
404
412
  function applyPrefix(content, ctx) {
405
413
  const { elementPrefix: e, cssPrefix: c } = ctx;
406
414
  if (e === 'l' && c === 'l') return content;
415
+ // CSS classes live in `class="…"`. Every `l-` token there is a css-prefix
416
+ // surface regardless of quoting — do this *before* the generic quoted-form
417
+ // rules below, which assume a quoted `l-` is a tag name (true for JS/JSON
418
+ // strings, false for HTML class attributes). Once a class value is rewritten
419
+ // to the css prefix it carries no `l-` token, so the later rules skip it.
420
+ content = applyClassAttrPrefix(content, c);
407
421
  return content
408
422
  .replace(/<l-/g, `<${e}-`)
409
423
  .replace(/<\/l-/g, `</${e}-`)
@@ -420,6 +434,18 @@ function applyPrefix(content, ctx) {
420
434
  .replace(/\nl-/g, `\n${e}-`);
421
435
  }
422
436
 
437
+ // Rewrites every `l-` token inside an HTML `class="…"` / `class='…'` value to
438
+ // the css prefix. Classes are a css-prefix surface (mirrors `.l-` in
439
+ // applyPrefixCss), but in markdown they appear quoted inside class attributes,
440
+ // where applyPrefix's quoted-form rules would otherwise mistake them for tag
441
+ // names. When cssPrefix === 'l' this is a no-op.
442
+ function applyClassAttrPrefix(content, c) {
443
+ return content.replace(
444
+ /class=(["'])(.*?)\1/g,
445
+ (_, q, val) => `class=${q}${val.replace(/\bl-/g, `${c}-`)}${q}`,
446
+ );
447
+ }
448
+
423
449
  // Prefix substitution for CSS files. Three surfaces, two prefixes (mirrors
424
450
  // postcss-plugin-prefix):
425
451
  // - CSS variables `--l-*` → cssPrefix
@@ -484,6 +510,100 @@ function buildElementsList(elements) {
484
510
  return elements.map((e) => e.displayName).join(', ') + '.';
485
511
  }
486
512
 
513
+ // Builds references/tokens.md from the shipped token CSS — a read-only inventory
514
+ // of the design system's semantic surface so an agent uses real tokens instead
515
+ // of improvising values. Two sources:
516
+ // - dist/css/tokens/aliases.css → the `--l-*` custom properties + their
517
+ // descriptions (consumers reference these directly in element CSS knobs).
518
+ // - dist/css/tailwind/preset.css → the semantic Tailwind utility classes
519
+ // (`text-primary`, `bg-fill-brand`, `border-interactive`, …) generated from
520
+ // those aliases.
521
+ // The result is run through applyPrefix at the call site, so `--l-*` becomes the
522
+ // consumer's css prefix; Tailwind utility names are unprefixed and pass through.
523
+ const TOKEN_GROUPS = [
524
+ { title: 'Text colors', test: (n) => n.startsWith('--l-color-text-') },
525
+ { title: 'Backgrounds', test: (n) => /^--l-color-(surface|bg-)/.test(n) },
526
+ { title: 'Borders & dividers', test: (n) => /^--l-color-(border|divider)/.test(n) },
527
+ { title: 'Effects', test: (n) => /^--l-(backdrop|focus-ring)/.test(n) },
528
+ { title: 'Control sizes', test: (n) => n.startsWith('--l-size-control-') },
529
+ ];
530
+
531
+ function buildTokensDoc(ctx) {
532
+ const aliasesPath = resolve(ctx.pkgRoot, 'dist/css/tokens/aliases.css');
533
+ const presetPath = resolve(ctx.pkgRoot, 'dist/css/tailwind/preset.css');
534
+ if (!existsSync(aliasesPath)) {
535
+ console.error(`✗ Missing ${aliasesPath}.`);
536
+ console.error(" This file is generated by luxen-ui's build. Reinstall the package.");
537
+ process.exit(1);
538
+ }
539
+
540
+ // Each entry is a single `/* description */` immediately above a `--l-…:`
541
+ // property. The tempered `(?:(?!\*\/)[\s\S])*?` keeps the comment body from
542
+ // spanning across `*/`, so the file-header comments don't get glued onto the
543
+ // first token's description.
544
+ const aliases = readFileSync(aliasesPath, 'utf-8');
545
+ const entries = [];
546
+ const varRe = /\/\*((?:(?!\*\/)[\s\S])*?)\*\/\s*(--l-[\w-]+)\s*:/g;
547
+ for (let m; (m = varRe.exec(aliases)); ) {
548
+ entries.push({ name: m[2], desc: m[1].replace(/\s+/g, ' ').trim() });
549
+ }
550
+
551
+ const groups = TOKEN_GROUPS.map((g) => ({
552
+ title: g.title,
553
+ rows: entries.filter((e) => g.test(e.name)),
554
+ })).filter((g) => g.rows.length);
555
+ const otherRows = entries.filter((e) => !TOKEN_GROUPS.some((g) => g.test(e.name)));
556
+ if (otherRows.length) groups.push({ title: 'Other', rows: otherRows });
557
+
558
+ const sections = groups.map((g) => {
559
+ const rows = g.rows.map((r) => `| \`${r.name}\` | ${r.desc} |`).join('\n');
560
+ return `### ${g.title}\n\n| Token | Usage |\n|-------|-------|\n${rows}`;
561
+ });
562
+
563
+ // Semantic Tailwind utilities from the preset's @theme inline namespaces.
564
+ const utilities = buildUtilityClasses(presetPath);
565
+
566
+ const parts = [
567
+ `# ${ctx.displayName} — design tokens`,
568
+ '',
569
+ 'Read-only reference for the design system. Use these semantic tokens and utility classes for colors, spacing, and typography instead of arbitrary values — they adapt to theming and dark mode automatically.',
570
+ '',
571
+ '## CSS custom properties',
572
+ '',
573
+ 'Reference these in element CSS custom properties and your own styles (e.g. `color: var(--l-color-text-secondary)`).',
574
+ '',
575
+ sections.join('\n\n'),
576
+ ];
577
+ if (utilities) parts.push('', '## Utility classes', '', utilities);
578
+ return parts.join('\n') + '\n';
579
+ }
580
+
581
+ // Maps the preset's semantic per-property namespaces to their Tailwind utility
582
+ // prefixes. Skips commented-out lines (palette families the consumer can opt in).
583
+ const UTILITY_NAMESPACES = [
584
+ { ns: '--text-color-', util: 'text-' },
585
+ { ns: '--background-color-', util: 'bg-' },
586
+ { ns: '--border-color-', util: 'border-' },
587
+ ];
588
+
589
+ function buildUtilityClasses(presetPath) {
590
+ if (!existsSync(presetPath)) return '';
591
+ const lines = readFileSync(presetPath, 'utf-8').split('\n');
592
+ const blocks = [];
593
+ for (const { ns, util } of UTILITY_NAMESPACES) {
594
+ const names = [];
595
+ for (const raw of lines) {
596
+ const line = raw.trim();
597
+ if (line.startsWith('/*') || line.startsWith('*')) continue;
598
+ const m = line.match(new RegExp(`^${ns}([\\w-]+)\\s*:`));
599
+ if (m) names.push(`\`${util}${m[1]}\``);
600
+ }
601
+ if (names.length) blocks.push(`- **${util}***: ${names.join(', ')}`);
602
+ }
603
+ if (!blocks.length) return '';
604
+ return ['Semantic utility classes generated from the tokens above:', '', ...blocks].join('\n');
605
+ }
606
+
487
607
  // Builds the comma-separated `l-foo` tag list for mockups.md (from manifest
488
608
  // entries flagged `inMockups`, excluding native CSS-only elements). The result
489
609
  // is processed by applyPrefix at render time, so the tags reflect the consumer's
@@ -559,13 +679,20 @@ function usage(code = 1) {
559
679
  process.exit(code);
560
680
  }
561
681
 
562
- const [, , command, ...rest] = process.argv;
682
+ // Run the dispatcher only when executed directly as a CLI — guarded so the
683
+ // module can be imported by tests (which exercise the pure prefix helpers
684
+ // below) without triggering argv parsing / process.exit.
685
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
686
+ const [, , command, ...rest] = process.argv;
563
687
 
564
- if (!command || command === '-h' || command === '--help') usage(0);
688
+ if (!command || command === '-h' || command === '--help') usage(0);
565
689
 
566
- if (command === 'import') cmdImport(rest);
567
- else if (command === 'generate-skill') await cmdGenerateSkill(rest);
568
- else {
569
- console.error(`✗ Unknown command: ${command}`);
570
- usage(1);
690
+ if (command === 'import') cmdImport(rest);
691
+ else if (command === 'generate-skill') await cmdGenerateSkill(rest);
692
+ else {
693
+ console.error(`✗ Unknown command: ${command}`);
694
+ usage(1);
695
+ }
571
696
  }
697
+
698
+ export { applyPrefix, applyClassAttrPrefix, applyPrefixCss, applyPackageName };
@@ -1,2 +1,2 @@
1
- var e=Math.min,t=Math.max,n=Math.round,r=Math.floor,i=e=>({x:e,y:e}),a={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function o(n,r,i){return t(n,e(r,i))}function s(e,t){return typeof e==`function`?e(t):e}function c(e){return e.split(`-`)[0]}function l(e){return e.split(`-`)[1]}function u(e){return e===`x`?`y`:`x`}function d(e){return e===`y`?`height`:`width`}function f(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function p(e){return u(f(e))}function m(e,t,n){n===void 0&&(n=!1);let r=l(e),i=p(e),a=d(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=C(o)),[o,C(o)]}function h(e){let t=C(e);return[g(e),t,g(t)]}function g(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var _=[`left`,`right`],v=[`right`,`left`],y=[`top`,`bottom`],b=[`bottom`,`top`];function x(e,t,n){switch(e){case`top`:case`bottom`:return n?t?v:_:t?_:v;case`left`:case`right`:return t?y:b;default:return[]}}function S(e,t,n,r){let i=l(e),a=x(c(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(g)))),a}function C(e){let t=c(e);return a[t]+e.slice(t.length)}function w(e){return{top:0,right:0,bottom:0,left:0,...e}}function ee(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:w(e)}function T(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function E(e,t,n){let{reference:r,floating:i}=e,a=f(t),o=p(t),s=d(o),u=c(t),m=a===`y`,h=r.x+r.width/2-i.width/2,g=r.y+r.height/2-i.height/2,_=r[s]/2-i[s]/2,v;switch(u){case`top`:v={x:h,y:r.y-i.height};break;case`bottom`:v={x:h,y:r.y+r.height};break;case`right`:v={x:r.x+r.width,y:g};break;case`left`:v={x:r.x-i.width,y:g};break;default:v={x:r.x,y:r.y}}switch(l(t)){case`start`:v[o]-=_*(n&&m?-1:1);break;case`end`:v[o]+=_*(n&&m?-1:1);break}return v}async function D(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=s(t,e),m=ee(p),h=o[f?d===`floating`?`reference`:`floating`:d],g=T(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(h))??!0?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(v))&&await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1},b=T(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var O=50,k=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:D},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=E(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<O&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=E(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},A=t=>({name:`arrow`,options:t,async fn(n){let{x:r,y:i,placement:a,rects:c,platform:u,elements:f,middlewareData:m}=n,{element:h,padding:g=0}=s(t,n)||{};if(h==null)return{};let _=ee(g),v={x:r,y:i},y=p(a),b=d(y),x=await u.getDimensions(h),S=y===`y`,C=S?`top`:`left`,w=S?`bottom`:`right`,T=S?`clientHeight`:`clientWidth`,E=c.reference[b]+c.reference[y]-v[y]-c.floating[b],D=v[y]-c.reference[y],O=await(u.getOffsetParent==null?void 0:u.getOffsetParent(h)),k=O?O[T]:0;(!k||!await(u.isElement==null?void 0:u.isElement(O)))&&(k=f.floating[T]||c.floating[b]);let A=E/2-D/2,j=k/2-x[b]/2-1,M=e(_[C],j),N=e(_[w],j),P=M,te=k-x[b]-N,F=k/2-x[b]/2+A,I=o(P,F,te),L=!m.arrow&&l(a)!=null&&F!==I&&c.reference[b]/2-(F<P?M:N)-x[b]/2<0,R=L?F<P?F-P:F-te:0;return{[y]:v[y]+R,data:{[y]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),j=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:g,fallbackStrategy:_=`bestFit`,fallbackAxisSideDirection:v=`none`,flipAlignment:y=!0,...b}=s(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let x=c(r),w=f(o),ee=c(o)===o,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),E=g||(ee||!y?[C(o)]:h(o)),D=v!==`none`;!g&&D&&E.push(...S(o,y,v,T));let O=[o,...E],k=await l.detectOverflow(t,b),A=[],j=i.flip?.overflows||[];if(d&&A.push(k[x]),p){let e=m(r,a,T);A.push(k[e[0]],k[e[1]])}if(j=[...j,{placement:r,overflows:A}],!A.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=O[e];if(t&&(!(p===`alignment`&&w!==f(t))||j.every(e=>f(e.placement)===w?e.overflows[0]>0:!0)))return{data:{index:e,overflows:j},reset:{placement:t}};let n=j.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(_){case`bestFit`:{let e=j.filter(e=>{if(D){let t=f(e.placement);return t===w||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}},M=new Set([`left`,`top`]);async function N(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=c(n),u=l(n),d=f(n)===`y`,p=M.has(o)?-1:1,m=a&&d?-1:1,h=s(t,e),{mainAxis:g,crossAxis:_,alignmentAxis:v}=typeof h==`number`?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return u&&typeof v==`number`&&(_=u===`end`?v*-1:v),d?{x:_*m,y:g*p}:{x:g*p,y:_*m}}var P=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await N(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},te=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:d=!1,limiter:p={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...m}=s(e,t),h={x:n,y:r},g=await a.detectOverflow(t,m),_=f(c(i)),v=u(_),y=h[v],b=h[_];if(l){let e=v===`y`?`top`:`left`,t=v===`y`?`bottom`:`right`,n=y+g[e],r=y-g[t];y=o(n,y,r)}if(d){let e=_===`y`?`top`:`left`,t=_===`y`?`bottom`:`right`,n=b+g[e],r=b-g[t];b=o(n,b,r)}let x=p.fn({...t,[v]:y,[_]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:l,[_]:d}}}}}};function F(){return typeof window<`u`}function I(e){return ne(e)?(e.nodeName||``).toLowerCase():`#document`}function L(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function R(e){return((ne(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ne(e){return F()?e instanceof Node||e instanceof L(e).Node:!1}function z(e){return F()?e instanceof Element||e instanceof L(e).Element:!1}function B(e){return F()?e instanceof HTMLElement||e instanceof L(e).HTMLElement:!1}function re(e){return!F()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof L(e).ShadowRoot}function V(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ie(e){return/^(table|td|th)$/.test(I(e))}function H(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ae=/transform|translate|scale|rotate|perspective|filter/,oe=/paint|layout|strict|content/,U=e=>!!e&&e!==`none`,se;function W(e){let t=z(e)?q(e):e;return U(t.transform)||U(t.translate)||U(t.scale)||U(t.rotate)||U(t.perspective)||!G()&&(U(t.backdropFilter)||U(t.filter))||ae.test(t.willChange||``)||oe.test(t.contain||``)}function ce(e){let t=Y(e);for(;B(t)&&!K(t);){if(W(t))return t;if(H(t))return null;t=Y(t)}return null}function G(){return se??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),se}function K(e){return/^(html|body|#document)$/.test(I(e))}function q(e){return L(e).getComputedStyle(e)}function J(e){return z(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(I(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||re(e)&&e.host||R(e);return re(t)?t.host:t}function le(e){let t=Y(e);return K(t)?e.ownerDocument?e.ownerDocument.body:e.body:B(t)&&V(t)?t:le(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=le(e),i=r===e.ownerDocument?.body,a=L(r);if(i){let e=ue(a);return t.concat(a,a.visualViewport||[],V(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function ue(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function de(e){let t=q(e),r=parseFloat(t.width)||0,i=parseFloat(t.height)||0,a=B(e),o=a?e.offsetWidth:r,s=a?e.offsetHeight:i,c=n(r)!==o||n(i)!==s;return c&&(r=o,i=s),{width:r,height:i,$:c}}function fe(e){return z(e)?e:e.contextElement}function Z(e){let t=fe(e);if(!B(t))return i(1);let r=t.getBoundingClientRect(),{width:a,height:o,$:s}=de(t),c=(s?n(r.width):r.width)/a,l=(s?n(r.height):r.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}var pe=i(0);function me(e){let t=L(e);return!G()||!t.visualViewport?pe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function he(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==L(e)?!1:t}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),o=fe(e),s=i(1);t&&(r?z(r)&&(s=Z(r)):s=Z(e));let c=he(o,n,r)?me(o):i(0),l=(a.left+c.x)/s.x,u=(a.top+c.y)/s.y,d=a.width/s.x,f=a.height/s.y;if(o){let e=L(o),t=r&&z(r)?L(r):r,n=e,i=ue(n);for(;i&&r&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=q(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,u*=e.y,d*=e.x,f*=e.y,l+=a,u+=o,n=L(i),i=ue(n)}}return T({width:d,height:f,x:l,y:u})}function $(e,t){let n=J(e).scrollLeft;return t?t.left+n:Q(R(e)).left+n}function ge(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-$(e,n),y:n.top+t.scrollTop}}function _e(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e,o=a===`fixed`,s=R(r),c=t?H(t.floating):!1;if(r===s||c&&o)return n;let l={scrollLeft:0,scrollTop:0},u=i(1),d=i(0),f=B(r);if((f||!f&&!o)&&((I(r)!==`body`||V(s))&&(l=J(r)),f)){let e=Q(r);u=Z(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=s&&!f&&!o?ge(s,l):i(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-l.scrollTop*u.y+d.y+p.y}}function ve(e){return Array.from(e.getClientRects())}function ye(e){let n=R(e),r=J(e),i=e.ownerDocument.body,a=t(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),o=t(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight),s=-r.scrollLeft+$(e),c=-r.scrollTop;return q(i).direction===`rtl`&&(s+=t(n.clientWidth,i.clientWidth)-a),{width:a,height:o,x:s,y:c}}var be=25;function xe(e,t){let n=L(e),r=R(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=G();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=$(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=be&&(a-=o)}else l<=be&&(a+=l);return{width:a,height:o,x:s,y:c}}function Se(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=B(e)?Z(e):i(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:a*o.x,y:r*o.y}}function Ce(e,t,n){let r;if(t===`viewport`)r=xe(e,n);else if(t===`document`)r=ye(R(e));else if(z(t))r=Se(t,n);else{let n=me(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return T(r)}function we(e,t){let n=Y(e);return n===t||!z(n)||K(n)?!1:q(n).position===`fixed`||we(n,t)}function Te(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>z(e)&&I(e)!==`body`),i=null,a=q(e).position===`fixed`,o=a?Y(e):e;for(;z(o)&&!K(o);){let t=q(o),n=W(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||V(o)&&!n&&we(e,o))?r=r.filter(e=>e!==o):i=t,o=Y(o)}return t.set(e,r),r}function Ee(n){let{element:r,boundary:i,rootBoundary:a,strategy:o}=n,s=[...i===`clippingAncestors`?H(r)?[]:Te(r,this._c):[].concat(i),a],c=Ce(r,s[0],o),l=c.top,u=c.right,d=c.bottom,f=c.left;for(let n=1;n<s.length;n++){let i=Ce(r,s[n],o);l=t(i.top,l),u=e(i.right,u),d=e(i.bottom,d),f=t(i.left,f)}return{width:u-f,height:d-l,x:f,y:l}}function De(e){let{width:t,height:n}=de(e);return{width:t,height:n}}function Oe(e,t,n){let r=B(t),a=R(t),o=n===`fixed`,s=Q(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=i(0);function u(){l.x=$(a)}if(r||!r&&!o)if((I(t)!==`body`||V(a))&&(c=J(t)),r){let e=Q(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else a&&u();o&&!r&&a&&u();let d=a&&!r&&!o?ge(a,c):i(0);return{x:s.left+c.scrollLeft-l.x-d.x,y:s.top+c.scrollTop-l.y-d.y,width:s.width,height:s.height}}function ke(e){return q(e).position===`static`}function Ae(e,t){if(!B(e)||q(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return R(e)===n&&(n=n.ownerDocument.body),n}function je(e,t){let n=L(e);if(H(e))return n;if(!B(e)){let t=Y(e);for(;t&&!K(t);){if(z(t)&&!ke(t))return t;t=Y(t)}return n}let r=Ae(e,t);for(;r&&ie(r)&&ke(r);)r=Ae(r,t);return r&&K(r)&&ke(r)&&!W(r)?n:r||ce(e)||n}var Me=async function(e){let t=this.getOffsetParent||je,n=this.getDimensions,r=await n(e.floating);return{reference:Oe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ne(e){return q(e).direction===`rtl`}var Pe={convertOffsetParentRelativeRectToViewportRelativeRect:_e,getDocumentElement:R,getClippingRect:Ee,getOffsetParent:je,getElementRects:Me,getClientRects:ve,getDimensions:De,getScale:Z,isElement:z,isRTL:Ne};function Fe(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ie(n,i){let a=null,o,s=R(n);function c(){var e;clearTimeout(o),(e=a)==null||e.disconnect(),a=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),c();let f=n.getBoundingClientRect(),{left:p,top:m,width:h,height:g}=f;if(u||i(),!h||!g)return;let _=r(m),v=r(s.clientWidth-(p+h)),y=r(s.clientHeight-(m+g)),b=r(p),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:t(0,e(1,d))||1},S=!0;function C(e){let t=e[0].intersectionRatio;if(t!==d){if(!S)return l();t?l(!1,t):o=setTimeout(()=>{l(!1,1e-7)},1e3)}t===1&&!Fe(f,n.getBoundingClientRect())&&l(),S=!1}try{a=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{a=new IntersectionObserver(C,x)}a.observe(n)}return l(!0),c}function Le(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=fe(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ie(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!Fe(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Re=P,ze=te,Be=j,Ve=A,He=(e,t,n)=>{let r=new Map,i={platform:Pe,...n},a={...i.platform,_c:r};return k(e,t,{...i,platform:a})};export{Re as a,Be as i,Le as n,ze as o,He as r,Ve as t};
1
+ var e=Math.min,t=Math.max,n=Math.round,r=Math.floor,i=e=>({x:e,y:e}),a={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function o(n,r,i){return t(n,e(r,i))}function s(e,t){return typeof e==`function`?e(t):e}function c(e){return e.split(`-`)[0]}function l(e){return e.split(`-`)[1]}function u(e){return e===`x`?`y`:`x`}function d(e){return e===`y`?`height`:`width`}function f(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function p(e){return u(f(e))}function m(e,t,n){n===void 0&&(n=!1);let r=l(e),i=p(e),a=d(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=C(o)),[o,C(o)]}function h(e){let t=C(e);return[g(e),t,g(t)]}function g(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var _=[`left`,`right`],v=[`right`,`left`],y=[`top`,`bottom`],b=[`bottom`,`top`];function x(e,t,n){switch(e){case`top`:case`bottom`:return n?t?v:_:t?_:v;case`left`:case`right`:return t?y:b;default:return[]}}function S(e,t,n,r){let i=l(e),a=x(c(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(g)))),a}function C(e){let t=c(e);return a[t]+e.slice(t.length)}function w(e){return{top:0,right:0,bottom:0,left:0,...e}}function T(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:w(e)}function E(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function D(e,t,n){let{reference:r,floating:i}=e,a=f(t),o=p(t),s=d(o),u=c(t),m=a===`y`,h=r.x+r.width/2-i.width/2,g=r.y+r.height/2-i.height/2,_=r[s]/2-i[s]/2,v;switch(u){case`top`:v={x:h,y:r.y-i.height};break;case`bottom`:v={x:h,y:r.y+r.height};break;case`right`:v={x:r.x+r.width,y:g};break;case`left`:v={x:r.x-i.width,y:g};break;default:v={x:r.x,y:r.y}}switch(l(t)){case`start`:v[o]-=_*(n&&m?-1:1);break;case`end`:v[o]+=_*(n&&m?-1:1);break}return v}async function O(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=s(t,e),m=T(p),h=o[f?d===`floating`?`reference`:`floating`:d],g=E(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(h))??!0?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(v))&&await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1},b=E(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var k=50,A=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:O},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=D(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<k&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=D(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},j=t=>({name:`arrow`,options:t,async fn(n){let{x:r,y:i,placement:a,rects:c,platform:u,elements:f,middlewareData:m}=n,{element:h,padding:g=0}=s(t,n)||{};if(h==null)return{};let _=T(g),v={x:r,y:i},y=p(a),b=d(y),x=await u.getDimensions(h),S=y===`y`,C=S?`top`:`left`,w=S?`bottom`:`right`,E=S?`clientHeight`:`clientWidth`,D=c.reference[b]+c.reference[y]-v[y]-c.floating[b],O=v[y]-c.reference[y],k=await(u.getOffsetParent==null?void 0:u.getOffsetParent(h)),A=k?k[E]:0;(!A||!await(u.isElement==null?void 0:u.isElement(k)))&&(A=f.floating[E]||c.floating[b]);let j=D/2-O/2,M=A/2-x[b]/2-1,ee=e(_[C],M),N=e(_[w],M),P=ee,te=A-x[b]-N,F=A/2-x[b]/2+j,I=o(P,F,te),L=!m.arrow&&l(a)!=null&&F!==I&&c.reference[b]/2-(F<P?ee:N)-x[b]/2<0,R=L?F<P?F-P:F-te:0;return{[y]:v[y]+R,data:{[y]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),M=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:g,fallbackStrategy:_=`bestFit`,fallbackAxisSideDirection:v=`none`,flipAlignment:y=!0,...b}=s(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let x=c(r),w=f(o),T=c(o)===o,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),D=g||(T||!y?[C(o)]:h(o)),O=v!==`none`;!g&&O&&D.push(...S(o,y,v,E));let k=[o,...D],A=await l.detectOverflow(t,b),j=[],M=i.flip?.overflows||[];if(d&&j.push(A[x]),p){let e=m(r,a,E);j.push(A[e[0]],A[e[1]])}if(M=[...M,{placement:r,overflows:j}],!j.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=k[e];if(t&&(!(p===`alignment`&&w!==f(t))||M.every(e=>f(e.placement)===w?e.overflows[0]>0:!0)))return{data:{index:e,overflows:M},reset:{placement:t}};let n=M.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(_){case`bestFit`:{let e=M.filter(e=>{if(O){let t=f(e.placement);return t===w||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}},ee=new Set([`left`,`top`]);async function N(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=c(n),u=l(n),d=f(n)===`y`,p=ee.has(o)?-1:1,m=a&&d?-1:1,h=s(t,e),{mainAxis:g,crossAxis:_,alignmentAxis:v}=typeof h==`number`?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return u&&typeof v==`number`&&(_=u===`end`?v*-1:v),d?{x:_*m,y:g*p}:{x:g*p,y:_*m}}var P=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await N(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},te=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:d=!1,limiter:p={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...m}=s(e,t),h={x:n,y:r},g=await a.detectOverflow(t,m),_=f(c(i)),v=u(_),y=h[v],b=h[_];if(l){let e=v===`y`?`top`:`left`,t=v===`y`?`bottom`:`right`,n=y+g[e],r=y-g[t];y=o(n,y,r)}if(d){let e=_===`y`?`top`:`left`,t=_===`y`?`bottom`:`right`,n=b+g[e],r=b-g[t];b=o(n,b,r)}let x=p.fn({...t,[v]:y,[_]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:l,[_]:d}}}}}},F=function(n){return n===void 0&&(n={}),{name:`size`,options:n,async fn(r){var i,a;let{placement:o,rects:u,platform:d,elements:p}=r,{apply:m=()=>{},...h}=s(n,r),g=await d.detectOverflow(r,h),_=c(o),v=l(o),y=f(o)===`y`,{width:b,height:x}=u.floating,S,C;_===`top`||_===`bottom`?(S=_,C=v===(await(d.isRTL==null?void 0:d.isRTL(p.floating))?`start`:`end`)?`left`:`right`):(C=_,S=v===`end`?`top`:`bottom`);let w=x-g.top-g.bottom,T=b-g.left-g.right,E=e(x-g[S],w),D=e(b-g[C],T),O=!r.middlewareData.shift,k=E,A=D;if((i=r.middlewareData.shift)!=null&&i.enabled.x&&(A=T),(a=r.middlewareData.shift)!=null&&a.enabled.y&&(k=w),O&&!v){let e=t(g.left,0),n=t(g.right,0),r=t(g.top,0),i=t(g.bottom,0);y?A=b-2*(e!==0||n!==0?e+n:t(g.left,g.right)):k=x-2*(r!==0||i!==0?r+i:t(g.top,g.bottom))}await m({...r,availableWidth:A,availableHeight:k});let j=await d.getDimensions(p.floating);return b!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function I(){return typeof window<`u`}function L(e){return ne(e)?(e.nodeName||``).toLowerCase():`#document`}function R(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function z(e){return((ne(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ne(e){return I()?e instanceof Node||e instanceof R(e).Node:!1}function B(e){return I()?e instanceof Element||e instanceof R(e).Element:!1}function V(e){return I()?e instanceof HTMLElement||e instanceof R(e).HTMLElement:!1}function re(e){return!I()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof R(e).ShadowRoot}function H(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ie(e){return/^(table|td|th)$/.test(L(e))}function U(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ae=/transform|translate|scale|rotate|perspective|filter/,oe=/paint|layout|strict|content/,W=e=>!!e&&e!==`none`,se;function ce(e){let t=B(e)?q(e):e;return W(t.transform)||W(t.translate)||W(t.scale)||W(t.rotate)||W(t.perspective)||!G()&&(W(t.backdropFilter)||W(t.filter))||ae.test(t.willChange||``)||oe.test(t.contain||``)}function le(e){let t=Y(e);for(;V(t)&&!K(t);){if(ce(t))return t;if(U(t))return null;t=Y(t)}return null}function G(){return se??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),se}function K(e){return/^(html|body|#document)$/.test(L(e))}function q(e){return R(e).getComputedStyle(e)}function J(e){return B(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(L(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||re(e)&&e.host||z(e);return re(t)?t.host:t}function ue(e){let t=Y(e);return K(t)?e.ownerDocument?e.ownerDocument.body:e.body:V(t)&&H(t)?t:ue(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ue(e),i=r===e.ownerDocument?.body,a=R(r);if(i){let e=de(a);return t.concat(a,a.visualViewport||[],H(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function de(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fe(e){let t=q(e),r=parseFloat(t.width)||0,i=parseFloat(t.height)||0,a=V(e),o=a?e.offsetWidth:r,s=a?e.offsetHeight:i,c=n(r)!==o||n(i)!==s;return c&&(r=o,i=s),{width:r,height:i,$:c}}function pe(e){return B(e)?e:e.contextElement}function Z(e){let t=pe(e);if(!V(t))return i(1);let r=t.getBoundingClientRect(),{width:a,height:o,$:s}=fe(t),c=(s?n(r.width):r.width)/a,l=(s?n(r.height):r.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}var me=i(0);function he(e){let t=R(e);return!G()||!t.visualViewport?me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ge(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==R(e)?!1:t}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),o=pe(e),s=i(1);t&&(r?B(r)&&(s=Z(r)):s=Z(e));let c=ge(o,n,r)?he(o):i(0),l=(a.left+c.x)/s.x,u=(a.top+c.y)/s.y,d=a.width/s.x,f=a.height/s.y;if(o){let e=R(o),t=r&&B(r)?R(r):r,n=e,i=de(n);for(;i&&r&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=q(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,u*=e.y,d*=e.x,f*=e.y,l+=a,u+=o,n=R(i),i=de(n)}}return E({width:d,height:f,x:l,y:u})}function $(e,t){let n=J(e).scrollLeft;return t?t.left+n:Q(z(e)).left+n}function _e(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-$(e,n),y:n.top+t.scrollTop}}function ve(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e,o=a===`fixed`,s=z(r),c=t?U(t.floating):!1;if(r===s||c&&o)return n;let l={scrollLeft:0,scrollTop:0},u=i(1),d=i(0),f=V(r);if((f||!f&&!o)&&((L(r)!==`body`||H(s))&&(l=J(r)),f)){let e=Q(r);u=Z(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=s&&!f&&!o?_e(s,l):i(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-l.scrollTop*u.y+d.y+p.y}}function ye(e){return Array.from(e.getClientRects())}function be(e){let n=z(e),r=J(e),i=e.ownerDocument.body,a=t(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),o=t(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight),s=-r.scrollLeft+$(e),c=-r.scrollTop;return q(i).direction===`rtl`&&(s+=t(n.clientWidth,i.clientWidth)-a),{width:a,height:o,x:s,y:c}}var xe=25;function Se(e,t){let n=R(e),r=z(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=G();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=$(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=xe&&(a-=o)}else l<=xe&&(a+=l);return{width:a,height:o,x:s,y:c}}function Ce(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=V(e)?Z(e):i(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:a*o.x,y:r*o.y}}function we(e,t,n){let r;if(t===`viewport`)r=Se(e,n);else if(t===`document`)r=be(z(e));else if(B(t))r=Ce(t,n);else{let n=he(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return E(r)}function Te(e,t){let n=Y(e);return n===t||!B(n)||K(n)?!1:q(n).position===`fixed`||Te(n,t)}function Ee(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>B(e)&&L(e)!==`body`),i=null,a=q(e).position===`fixed`,o=a?Y(e):e;for(;B(o)&&!K(o);){let t=q(o),n=ce(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||H(o)&&!n&&Te(e,o))?r=r.filter(e=>e!==o):i=t,o=Y(o)}return t.set(e,r),r}function De(n){let{element:r,boundary:i,rootBoundary:a,strategy:o}=n,s=[...i===`clippingAncestors`?U(r)?[]:Ee(r,this._c):[].concat(i),a],c=we(r,s[0],o),l=c.top,u=c.right,d=c.bottom,f=c.left;for(let n=1;n<s.length;n++){let i=we(r,s[n],o);l=t(i.top,l),u=e(i.right,u),d=e(i.bottom,d),f=t(i.left,f)}return{width:u-f,height:d-l,x:f,y:l}}function Oe(e){let{width:t,height:n}=fe(e);return{width:t,height:n}}function ke(e,t,n){let r=V(t),a=z(t),o=n===`fixed`,s=Q(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=i(0);function u(){l.x=$(a)}if(r||!r&&!o)if((L(t)!==`body`||H(a))&&(c=J(t)),r){let e=Q(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else a&&u();o&&!r&&a&&u();let d=a&&!r&&!o?_e(a,c):i(0);return{x:s.left+c.scrollLeft-l.x-d.x,y:s.top+c.scrollTop-l.y-d.y,width:s.width,height:s.height}}function Ae(e){return q(e).position===`static`}function je(e,t){if(!V(e)||q(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return z(e)===n&&(n=n.ownerDocument.body),n}function Me(e,t){let n=R(e);if(U(e))return n;if(!V(e)){let t=Y(e);for(;t&&!K(t);){if(B(t)&&!Ae(t))return t;t=Y(t)}return n}let r=je(e,t);for(;r&&ie(r)&&Ae(r);)r=je(r,t);return r&&K(r)&&Ae(r)&&!ce(r)?n:r||le(e)||n}var Ne=async function(e){let t=this.getOffsetParent||Me,n=this.getDimensions,r=await n(e.floating);return{reference:ke(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Pe(e){return q(e).direction===`rtl`}var Fe={convertOffsetParentRelativeRectToViewportRelativeRect:ve,getDocumentElement:z,getClippingRect:De,getOffsetParent:Me,getElementRects:Ne,getClientRects:ye,getDimensions:Oe,getScale:Z,isElement:B,isRTL:Pe};function Ie(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Le(n,i){let a=null,o,s=z(n);function c(){var e;clearTimeout(o),(e=a)==null||e.disconnect(),a=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),c();let f=n.getBoundingClientRect(),{left:p,top:m,width:h,height:g}=f;if(u||i(),!h||!g)return;let _=r(m),v=r(s.clientWidth-(p+h)),y=r(s.clientHeight-(m+g)),b=r(p),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:t(0,e(1,d))||1},S=!0;function C(e){let t=e[0].intersectionRatio;if(t!==d){if(!S)return l();t?l(!1,t):o=setTimeout(()=>{l(!1,1e-7)},1e3)}t===1&&!Ie(f,n.getBoundingClientRect())&&l(),S=!1}try{a=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{a=new IntersectionObserver(C,x)}a.observe(n)}return l(!0),c}function Re(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=pe(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Le(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!Ie(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ze=P,Be=te,Ve=M,He=F,Ue=j,We=(e,t,n)=>{let r=new Map,i={platform:Fe,...n},a={...i.platform,_c:r};return A(e,t,{...i,platform:a})};export{ze as a,Ve as i,Re as n,Be as o,We as r,He as s,Ue as t};
2
2
  //# sourceMappingURL=floating-ui.dom.js.map