@kerfjs/ui 5.0.0-beta.125 → 5.0.0-beta.127

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 (306) hide show
  1. package/README.md +5 -0
  2. package/ai/application-ui-diagnostic-ids-v1.json +1 -0
  3. package/ai/component-catalog.json +77 -6
  4. package/ai/component-catalog.schema.json +14 -1
  5. package/ai/component-composition.json +27 -6
  6. package/ai/component-props.json +265 -40
  7. package/ai/components/combobox.md +1 -1
  8. package/ai/components/surface-scaffold.md +19 -5
  9. package/ai/components/tab-bar.md +2 -0
  10. package/ai/components/toolbar.md +1 -0
  11. package/ai/public-api-signatures-v1.md +251 -298
  12. package/ai/skill.md +10 -4
  13. package/ai/view-document.schema.json +55 -2
  14. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  15. package/analyzer/cli.mjs +60 -24
  16. package/analyzer/index.mjs +331 -58
  17. package/catalog-projection-cli.mjs +86 -50
  18. package/dist/anchored-surface.js +2 -1
  19. package/dist/browser/editor.js +12 -7
  20. package/dist/catalog-resources.d.ts +1 -1
  21. package/dist/catalog.d.ts +1 -1
  22. package/dist/catalog.js +6 -6
  23. package/dist/{chunk-VX3YF2UD.js → chunk-3K5V3ZSD.js} +3 -3
  24. package/dist/{chunk-VX3YF2UD.js.map → chunk-3K5V3ZSD.js.map} +1 -1
  25. package/dist/{chunk-NHQOX7T4.js → chunk-3ZKUXWAV.js} +4 -4
  26. package/dist/chunk-3ZKUXWAV.js.map +1 -0
  27. package/dist/{chunk-ADMWT7FX.js → chunk-3ZWYGGEC.js} +136 -8
  28. package/dist/chunk-3ZWYGGEC.js.map +1 -0
  29. package/dist/{chunk-KLR3DCHH.js → chunk-4L5ZIKDZ.js} +1 -1
  30. package/dist/chunk-4L5ZIKDZ.js.map +1 -0
  31. package/dist/{chunk-2E7S5C4D.js → chunk-4UWLHKNU.js} +5 -5
  32. package/dist/chunk-4UWLHKNU.js.map +1 -0
  33. package/dist/{chunk-EXGDKG7B.js → chunk-5A2DN3LR.js} +5 -5
  34. package/dist/chunk-5A2DN3LR.js.map +1 -0
  35. package/dist/{chunk-DJ65XFVN.js → chunk-63TJH2RF.js} +4 -4
  36. package/dist/chunk-63TJH2RF.js.map +1 -0
  37. package/dist/{chunk-Q2CLQ3IJ.js → chunk-6PHG2DMG.js} +1 -1
  38. package/dist/chunk-6PHG2DMG.js.map +1 -0
  39. package/dist/{chunk-SPI6VMIY.js → chunk-6T7AX365.js} +4 -4
  40. package/dist/chunk-6T7AX365.js.map +1 -0
  41. package/dist/{chunk-GVII4JSD.js → chunk-6V6UHPJD.js} +4 -4
  42. package/dist/chunk-6V6UHPJD.js.map +1 -0
  43. package/dist/{chunk-NR3ZO4LK.js → chunk-7U65KLDL.js} +1 -1
  44. package/dist/chunk-7U65KLDL.js.map +1 -0
  45. package/dist/chunk-BMOZSNDU.js +133 -0
  46. package/dist/chunk-BMOZSNDU.js.map +1 -0
  47. package/dist/{chunk-2LM3PYHA.js → chunk-C2TY5DJC.js} +11 -8
  48. package/dist/chunk-C2TY5DJC.js.map +1 -0
  49. package/dist/{chunk-3WYREXW4.js → chunk-COMEWURO.js} +8 -6
  50. package/dist/chunk-COMEWURO.js.map +1 -0
  51. package/dist/{chunk-VPDSPD76.js → chunk-DB64I3DB.js} +4 -3
  52. package/dist/chunk-DB64I3DB.js.map +1 -0
  53. package/dist/{chunk-SBCXWGNP.js → chunk-DBCDYBZP.js} +2 -2
  54. package/dist/{chunk-SBCXWGNP.js.map → chunk-DBCDYBZP.js.map} +1 -1
  55. package/dist/{chunk-CNM6ZWP2.js → chunk-DJWBXEF4.js} +4 -2
  56. package/dist/chunk-DJWBXEF4.js.map +1 -0
  57. package/dist/{chunk-SVUJIVMR.js → chunk-E2MTHHLS.js} +3 -3
  58. package/dist/{chunk-SVUJIVMR.js.map → chunk-E2MTHHLS.js.map} +1 -1
  59. package/dist/{chunk-JG4ONAOI.js → chunk-EI55KWHP.js} +2 -2
  60. package/dist/chunk-EI55KWHP.js.map +1 -0
  61. package/dist/{chunk-MVKHSAKE.js → chunk-GE2BQXB3.js} +41 -4
  62. package/dist/chunk-GE2BQXB3.js.map +1 -0
  63. package/dist/chunk-GHV36C6I.js +94 -0
  64. package/dist/chunk-GHV36C6I.js.map +1 -0
  65. package/dist/{chunk-BCO673YW.js → chunk-GQUDCWOD.js} +10 -4
  66. package/dist/chunk-GQUDCWOD.js.map +1 -0
  67. package/dist/chunk-HD7ZLISK.js +808 -0
  68. package/dist/chunk-HD7ZLISK.js.map +1 -0
  69. package/dist/{chunk-KELWWCMX.js → chunk-I2K4OQKB.js} +4 -4
  70. package/dist/chunk-I2K4OQKB.js.map +1 -0
  71. package/dist/chunk-IFDTSVE6.js +9 -0
  72. package/dist/chunk-IFDTSVE6.js.map +1 -0
  73. package/dist/{chunk-TPLVC5BE.js → chunk-IR32NI2O.js} +336 -247
  74. package/dist/chunk-IR32NI2O.js.map +1 -0
  75. package/dist/{chunk-ZKKO4MHC.js → chunk-JYKP7TBZ.js} +4 -2
  76. package/dist/chunk-JYKP7TBZ.js.map +1 -0
  77. package/dist/{chunk-6OT7FOSA.js → chunk-K3C35KGR.js} +4 -4
  78. package/dist/chunk-K3C35KGR.js.map +1 -0
  79. package/dist/{chunk-4RECPEHI.js → chunk-KBS3GP6S.js} +4 -3
  80. package/dist/chunk-KBS3GP6S.js.map +1 -0
  81. package/dist/{chunk-YHRJNKD5.js → chunk-KS7EXW4P.js} +6 -4
  82. package/dist/chunk-KS7EXW4P.js.map +1 -0
  83. package/dist/{chunk-V6N3YLTM.js → chunk-LTOTL5AS.js} +3 -3
  84. package/dist/chunk-LTOTL5AS.js.map +1 -0
  85. package/dist/chunk-M64TAGZY.js +590 -0
  86. package/dist/chunk-M64TAGZY.js.map +1 -0
  87. package/dist/{chunk-JZZVWTUB.js → chunk-MMOQR426.js} +2 -2
  88. package/dist/chunk-MMOQR426.js.map +1 -0
  89. package/dist/{chunk-SJBMKA4X.js → chunk-OHT2AXER.js} +11 -10
  90. package/dist/chunk-OHT2AXER.js.map +1 -0
  91. package/dist/{chunk-TTFW6E6C.js → chunk-OZKBIPXU.js} +2 -2
  92. package/dist/chunk-OZKBIPXU.js.map +1 -0
  93. package/dist/{chunk-Q2SLOMN6.js → chunk-RHMY45DK.js} +4 -4
  94. package/dist/chunk-RHMY45DK.js.map +1 -0
  95. package/dist/{chunk-BZXA5SSA.js → chunk-S7QB5KMM.js} +2 -2
  96. package/dist/{chunk-BZXA5SSA.js.map → chunk-S7QB5KMM.js.map} +1 -1
  97. package/dist/{chunk-HDXUHLTQ.js → chunk-SHECA2N4.js} +8 -2
  98. package/dist/chunk-SHECA2N4.js.map +1 -0
  99. package/dist/{chunk-R6FIXYAE.js → chunk-SJEPM5ZU.js} +2 -2
  100. package/dist/{chunk-R6FIXYAE.js.map → chunk-SJEPM5ZU.js.map} +1 -1
  101. package/dist/{chunk-FJMABKKV.js → chunk-UQ4FRQ6M.js} +35 -17
  102. package/dist/chunk-UQ4FRQ6M.js.map +1 -0
  103. package/dist/{chunk-S4ZGTDSG.js → chunk-UU37OR3D.js} +2 -2
  104. package/dist/chunk-UU37OR3D.js.map +1 -0
  105. package/dist/{chunk-SWXWLSUD.js → chunk-WEQNPYVA.js} +1 -1
  106. package/dist/{chunk-SWXWLSUD.js.map → chunk-WEQNPYVA.js.map} +1 -1
  107. package/dist/{chunk-5SFHBYEY.js → chunk-WUVHP3UC.js} +97 -24
  108. package/dist/chunk-WUVHP3UC.js.map +1 -0
  109. package/dist/{chunk-3S3WXAZ5.js → chunk-X43QQWVC.js} +3 -2
  110. package/dist/chunk-X43QQWVC.js.map +1 -0
  111. package/dist/{chunk-Z3T24FX3.js → chunk-YE6KCAIN.js} +3 -2
  112. package/dist/chunk-YE6KCAIN.js.map +1 -0
  113. package/dist/{chunk-KQZIC5CA.js → chunk-ZC4KSRAF.js} +7 -7
  114. package/dist/chunk-ZC4KSRAF.js.map +1 -0
  115. package/dist/collapsible-panel.d.ts +2 -2
  116. package/dist/collapsible-panel.js +2 -2
  117. package/dist/collapsible-panel.js.map +1 -1
  118. package/dist/column-explorer.d.ts +3 -3
  119. package/dist/column-explorer.js +16 -138
  120. package/dist/column-explorer.js.map +1 -1
  121. package/dist/dialog-surface-controller-BeKZ3e8Z.d.ts +251 -0
  122. package/dist/editor-frame.d.ts +1 -1
  123. package/dist/editor-frame.js +1 -1
  124. package/dist/editor.d.ts +38 -20
  125. package/dist/editor.js +11651 -7052
  126. package/dist/editor.js.map +1 -1
  127. package/dist/file-picker.js +1 -1
  128. package/dist/help-tags-register.js +2 -1
  129. package/dist/help-tags-register.js.map +1 -1
  130. package/dist/index.d.ts +2 -1
  131. package/dist/index.js +24 -23
  132. package/dist/list-action-row.d.ts +1 -1
  133. package/dist/list-action-row.js +1 -1
  134. package/dist/list-detail-dialog.d.ts +7 -7
  135. package/dist/list-detail-dialog.js +6 -5
  136. package/dist/list-detail-dialog.js.map +1 -1
  137. package/dist/list-header.d.ts +1 -1
  138. package/dist/list-header.js +1 -1
  139. package/dist/list-item.d.ts +1 -1
  140. package/dist/list-item.js +1 -1
  141. package/dist/message-composer.js +1 -1
  142. package/dist/nav-stack.d.ts +6 -6
  143. package/dist/nav-stack.js +1 -1
  144. package/dist/popup-menu-register.js +1 -7
  145. package/dist/popup-menu-register.js.map +1 -1
  146. package/dist/popup-menu.d.ts +2 -2
  147. package/dist/popup-menu.js +1 -1
  148. package/dist/resizable-region.js +1 -1
  149. package/dist/segmented-control.d.ts +1 -1
  150. package/dist/segmented-control.js +1 -1
  151. package/dist/select-register.js +17 -23
  152. package/dist/select-register.js.map +1 -1
  153. package/dist/split-view.d.ts +6 -6
  154. package/dist/split-view.js +1 -1
  155. package/dist/styles/collapsible-panel.css +34 -25
  156. package/dist/styles/components/actions/popup-menu/popup-menu.css +4 -4
  157. package/dist/styles/components/actions/toolbar/toolbar.css +34 -1
  158. package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +1 -1
  159. package/dist/styles/components/forms/segmented-control/segmented-control.css +1 -1
  160. package/dist/styles/components/layout/collapsible-panel/collapsible-panel.css +34 -25
  161. package/dist/styles/components/layout/split-view/split-view.css +19 -33
  162. package/dist/styles/components/navigation/nav-stack/nav-stack.css +15 -19
  163. package/dist/styles/components/navigation/tab-navigator/tab-navigator.css +30 -29
  164. package/dist/styles/components/surfaces/editor-frame/editor-frame.css +10 -3
  165. package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +291 -4
  166. package/dist/styles/editor/editor.css +78 -0
  167. package/dist/styles/editor-frame.css +10 -3
  168. package/dist/styles/nav-stack.css +15 -19
  169. package/dist/styles/popup-menu.css +4 -4
  170. package/dist/styles/segmented-control.css +1 -1
  171. package/dist/styles/split-view.css +19 -33
  172. package/dist/styles/surface-scaffold.css +291 -4
  173. package/dist/styles/tab-navigator.css +30 -29
  174. package/dist/styles/toolbar-control-group.css +1 -1
  175. package/dist/styles/toolbar.css +34 -1
  176. package/dist/styles/webawesome.css +4 -5
  177. package/dist/surface-scaffold-register.js +2 -1
  178. package/dist/surface-scaffold-register.js.map +1 -1
  179. package/dist/surface-scaffold.d.ts +155 -246
  180. package/dist/surface-scaffold.js +3 -2
  181. package/dist/toolbar-control-group.d.ts +2 -2
  182. package/dist/toolbar-control-group.js +1 -1
  183. package/dist/toolbar.d.ts +6 -1
  184. package/dist/toolbar.js +1 -1
  185. package/dist/tree-list.d.ts +4 -4
  186. package/dist/tree-list.js +2 -2
  187. package/dist/{tree-rows-eHnnGLGM.d.ts → tree-rows-Bms5QJvG.d.ts} +3 -0
  188. package/dist/wire-catalog.d.ts +1 -1
  189. package/dist/wire-catalog.js +3 -2
  190. package/dist/wire-catalog.js.map +1 -1
  191. package/dist/wire-checkboxes.js +2 -1
  192. package/dist/wire-choice-chips.js +2 -1
  193. package/dist/wire-color-fields.js +2 -1
  194. package/dist/wire-color-pickers.js +2 -1
  195. package/dist/wire-column-explorer.js +1 -92
  196. package/dist/wire-column-explorer.js.map +1 -1
  197. package/dist/wire-comboboxes.d.ts +2 -0
  198. package/dist/wire-comboboxes.js +2 -1
  199. package/dist/wire-content-items.js +2 -1
  200. package/dist/wire-corner-status.js +2 -1
  201. package/dist/wire-nav-stack.js +2 -1
  202. package/dist/wire-overlay-sheets.js +2 -1
  203. package/dist/wire-paged-views.js +2 -2
  204. package/dist/wire-paged-views.js.map +1 -1
  205. package/dist/wire-resizable-regions.js +2 -1
  206. package/dist/wire-scroll-dividers.js +1 -1
  207. package/dist/wire-search-fields.js +2 -1
  208. package/dist/wire-sidebar.js +2 -1
  209. package/dist/wire-tab-bars.d.ts +41 -2
  210. package/dist/wire-tab-bars.js +1 -1
  211. package/dist/wire-tab-navigator.js +2 -1
  212. package/dist/wire-tag-fields.js +2 -1
  213. package/dist/wire-workbench.js +2 -1
  214. package/dist/workbench-dialog.d.ts +7 -7
  215. package/dist/workbench-dialog.js +5 -4
  216. package/dist/workbench-dialog.js.map +1 -1
  217. package/dist/workbench.d.ts +1 -1
  218. package/dist/workbench.js +1 -1
  219. package/docs/accessibility.md +3 -6
  220. package/docs/component-contract.md +47 -7
  221. package/docs/component-selection.md +90 -80
  222. package/docs/design/templates.md +5 -4
  223. package/docs/editor-frame.md +1 -1
  224. package/docs/editor-host.md +15 -2
  225. package/docs/overlay-tooltip.md +1 -1
  226. package/docs/recipes.md +1 -1
  227. package/docs/surface-scaffold.md +63 -2
  228. package/docs/ui-analyzer.md +42 -0
  229. package/docs/ui-doctor.md +45 -1
  230. package/docs/ui-evaluator.md +35 -0
  231. package/docs/ux-demo.md +1 -1
  232. package/docs/view.md +314 -0
  233. package/docs/webawesome-theme.md +16 -0
  234. package/doctor/cli.mjs +36 -31
  235. package/doctor/index.mjs +349 -162
  236. package/evaluator/cli.mjs +36 -30
  237. package/llms.txt +17 -4
  238. package/package.json +6 -2
  239. package/props/cli.mjs +47 -21
  240. package/scripts/lib/cli-args.mjs +98 -0
  241. package/ux-demo/recipes/app-shell.tsx +48 -141
  242. package/ux-demo/recipes/collapsible-sidebar.tsx +43 -169
  243. package/ux-demo/recipes/compact-toolbar.tsx +22 -114
  244. package/ux-demo/recipes/composer-form.tsx +14 -104
  245. package/ux-demo/recipes/list-detail-dialog.tsx +38 -84
  246. package/ux-demo/recipes/list-workspace-states.tsx +29 -152
  247. package/ux-demo/recipes/loading-inspector.tsx +30 -174
  248. package/ux-demo/recipes/media-detail.tsx +29 -146
  249. package/ux-demo/recipes/navigation-sidebar.tsx +24 -113
  250. package/ux-demo/recipes/navigation-stack.tsx +7 -43
  251. package/ux-demo/recipes/workspace-header.tsx +2 -66
  252. package/view/catalog.mjs +229 -0
  253. package/view/child-kind.mjs +22 -0
  254. package/view/cli.mjs +142 -119
  255. package/view/contract.mjs +84 -11
  256. package/view/css-grammar.mjs +93 -0
  257. package/view/generate.d.mts +16 -0
  258. package/view/generate.mjs +155 -56
  259. package/view/index.d.mts +80 -14
  260. package/view/index.mjs +5 -9
  261. package/view/interpret.mjs +104 -36
  262. package/view/types.mjs +161 -0
  263. package/view/validate-move.mjs +66 -30
  264. package/view/validate.mjs +420 -654
  265. package/vite-editor.d.mts +16 -1
  266. package/vite-editor.mjs +74 -4
  267. package/dist/chunk-2E7S5C4D.js.map +0 -1
  268. package/dist/chunk-2LM3PYHA.js.map +0 -1
  269. package/dist/chunk-3S3WXAZ5.js.map +0 -1
  270. package/dist/chunk-3WYREXW4.js.map +0 -1
  271. package/dist/chunk-4RECPEHI.js.map +0 -1
  272. package/dist/chunk-5SFHBYEY.js.map +0 -1
  273. package/dist/chunk-6OT7FOSA.js.map +0 -1
  274. package/dist/chunk-ADMWT7FX.js.map +0 -1
  275. package/dist/chunk-BCO673YW.js.map +0 -1
  276. package/dist/chunk-CNM6ZWP2.js.map +0 -1
  277. package/dist/chunk-DJ65XFVN.js.map +0 -1
  278. package/dist/chunk-EXGDKG7B.js.map +0 -1
  279. package/dist/chunk-FJMABKKV.js.map +0 -1
  280. package/dist/chunk-GVII4JSD.js.map +0 -1
  281. package/dist/chunk-HDXUHLTQ.js.map +0 -1
  282. package/dist/chunk-JG4ONAOI.js.map +0 -1
  283. package/dist/chunk-JZZVWTUB.js.map +0 -1
  284. package/dist/chunk-KELWWCMX.js.map +0 -1
  285. package/dist/chunk-KLR3DCHH.js.map +0 -1
  286. package/dist/chunk-KQZIC5CA.js.map +0 -1
  287. package/dist/chunk-LD6A6PYB.js +0 -268
  288. package/dist/chunk-LD6A6PYB.js.map +0 -1
  289. package/dist/chunk-MVKHSAKE.js.map +0 -1
  290. package/dist/chunk-NHQOX7T4.js.map +0 -1
  291. package/dist/chunk-NR3ZO4LK.js.map +0 -1
  292. package/dist/chunk-Q2CLQ3IJ.js.map +0 -1
  293. package/dist/chunk-Q2SLOMN6.js.map +0 -1
  294. package/dist/chunk-S4ZGTDSG.js.map +0 -1
  295. package/dist/chunk-SJBMKA4X.js.map +0 -1
  296. package/dist/chunk-SPI6VMIY.js.map +0 -1
  297. package/dist/chunk-TPLVC5BE.js.map +0 -1
  298. package/dist/chunk-TTFW6E6C.js.map +0 -1
  299. package/dist/chunk-V6N3YLTM.js.map +0 -1
  300. package/dist/chunk-VNT4MXR5.js +0 -548
  301. package/dist/chunk-VNT4MXR5.js.map +0 -1
  302. package/dist/chunk-VPDSPD76.js.map +0 -1
  303. package/dist/chunk-YHRJNKD5.js.map +0 -1
  304. package/dist/chunk-Z3T24FX3.js.map +0 -1
  305. package/dist/chunk-ZKKO4MHC.js.map +0 -1
  306. package/dist/{nav-stack-DwxpXxqJ.d.ts → nav-stack-vQ3ieerq.d.ts} +3 -3
@@ -0,0 +1,808 @@
1
+ import { watchOwnedStyles } from './chunk-UQ4FRQ6M.js';
2
+ import { checkedAnchorName } from './chunk-DKPYHVIV.js';
3
+ import { LucideIcon } from './chunk-CMG4OZPV.js';
4
+ import { filterDataAttributes } from './chunk-COQI4OMZ.js';
5
+ import { X, Pin } from 'lucide';
6
+ import { jsxs, jsx } from 'kerfjs/jsx-runtime';
7
+
8
+ var DIALOG_SURFACE_PROTECTED = /* @__PURE__ */ new Set([
9
+ "data-component",
10
+ "data-size",
11
+ "data-presentation",
12
+ "data-preferred-width",
13
+ "data-body-inset",
14
+ "data-footer-inset",
15
+ "data-viewport-gutter",
16
+ "data-max-height",
17
+ "data-height",
18
+ "data-body-layout",
19
+ "data-footer-presentation",
20
+ "data-header-presentation",
21
+ "data-min-height",
22
+ "data-resizable",
23
+ "data-enter-motion",
24
+ "data-exit-motion",
25
+ "data-light-dismiss",
26
+ "data-stack-open",
27
+ "data-stack-active",
28
+ "data-stack-position",
29
+ "data-stack-count"
30
+ ]);
31
+ function DialogSurface({
32
+ id,
33
+ label,
34
+ labelledBy,
35
+ describedBy,
36
+ alert = false,
37
+ heading,
38
+ headerActions,
39
+ footer,
40
+ withoutHeader = false,
41
+ lightDismiss = false,
42
+ closeLabel = "Close",
43
+ closeEmphasis = "normal",
44
+ children,
45
+ stack,
46
+ size = "medium",
47
+ presentation = "modal",
48
+ preferredWidth,
49
+ bodyInset = "default",
50
+ footerInset = "comfortable",
51
+ viewportGutter,
52
+ maxHeight,
53
+ height,
54
+ minHeight,
55
+ resizable = false,
56
+ enterMotion = "slide",
57
+ exitMotion = "slide",
58
+ bodyLayout = "flow",
59
+ headerPresentation = "docked",
60
+ footerPresentation = "docked",
61
+ footerOffset,
62
+ rootAttributes = {},
63
+ className = "",
64
+ slot
65
+ }) {
66
+ if (stack && (!Number.isInteger(stack.position) || !Number.isInteger(stack.count) || stack.count < 1 || stack.position < 1 || stack.position > stack.count || stack.active && !stack.open))
67
+ throw new RangeError(
68
+ "DialogSurface stack needs a valid frontmost active layer"
69
+ );
70
+ const style = [
71
+ preferredWidth === void 0 ? "" : `--_kui-dialog-surface-preferred-width:${preferredWidth}`,
72
+ viewportGutter === void 0 ? "" : `--_kui-dialog-surface-gutter:${viewportGutter}`,
73
+ maxHeight === void 0 || maxHeight === "viewport" ? "" : `--_kui-dialog-surface-max-height:${maxHeight}`,
74
+ height === void 0 || height === "viewport" ? "" : `--_kui-dialog-surface-height:${height}`,
75
+ footerOffset === void 0 ? "" : `--_kui-dialog-surface-footer-offset:${footerOffset}`,
76
+ minHeight === void 0 ? "" : `--_kui-dialog-surface-min-height:${minHeight}`,
77
+ stack?.offset === void 0 ? "" : `--_kui-dialog-surface-stack-offset:${stack.offset}`
78
+ ].filter(Boolean).join(";");
79
+ return /* @__PURE__ */ jsxs(
80
+ "dialog",
81
+ {
82
+ ...filterDataAttributes(rootAttributes, DIALOG_SURFACE_PROTECTED),
83
+ id,
84
+ class: `kui-dialog-surface ${className}`.trim(),
85
+ open: presentation === "embedded" ? true : void 0,
86
+ role: alert ? "alertdialog" : void 0,
87
+ "aria-label": label,
88
+ "aria-labelledby": labelledBy,
89
+ "aria-describedby": describedBy,
90
+ "aria-modal": stack ? stack.open && stack.active ? "true" : "false" : void 0,
91
+ "aria-hidden": stack ? stack.open && stack.active ? "false" : "true" : void 0,
92
+ inert: stack && (!stack.open || !stack.active) ? true : void 0,
93
+ tabindex: -1,
94
+ "data-light-dismiss": lightDismiss ? "" : void 0,
95
+ "data-component": "dialog-surface",
96
+ "data-stack-open": stack ? String(stack.open) : void 0,
97
+ "data-stack-active": stack ? String(stack.active) : void 0,
98
+ "data-stack-position": stack?.position,
99
+ "data-stack-count": stack?.count,
100
+ "data-size": size,
101
+ "data-presentation": presentation,
102
+ "data-preferred-width": preferredWidth === void 0 ? void 0 : "",
103
+ "data-body-inset": bodyInset === "compact" ? "default" : bodyInset,
104
+ "data-footer-inset": footerInset === "compact" ? "default" : footerInset,
105
+ "data-viewport-gutter": viewportGutter === void 0 && !stack ? void 0 : "",
106
+ "data-max-height": maxHeight === void 0 ? void 0 : "",
107
+ "data-height": height === void 0 ? void 0 : "",
108
+ "data-body-layout": bodyLayout === "flow" ? void 0 : bodyLayout,
109
+ "data-header-presentation": headerPresentation === "floating" ? "floating" : void 0,
110
+ "data-footer-presentation": footerPresentation === "floating" ? "floating" : void 0,
111
+ "data-min-height": minHeight === void 0 ? void 0 : "",
112
+ "data-resizable": resizable ? "" : void 0,
113
+ "data-enter-motion": enterMotion === "slide" ? void 0 : enterMotion,
114
+ "data-exit-motion": exitMotion === "slide" ? void 0 : exitMotion,
115
+ style: style || void 0,
116
+ slot,
117
+ children: [
118
+ withoutHeader ? null : /* @__PURE__ */ jsxs("header", { class: "kui-dialog-surface__header", children: [
119
+ heading === void 0 ? /* @__PURE__ */ jsx("h2", { class: "kui-dialog-surface__title", children: label }) : /* @__PURE__ */ jsx("div", { class: "kui-dialog-surface__title", children: heading }),
120
+ /* @__PURE__ */ jsxs("div", { class: "kui-dialog-surface__header-actions", children: [
121
+ headerActions,
122
+ /* @__PURE__ */ jsx(
123
+ "button",
124
+ {
125
+ type: "button",
126
+ class: "kui-dialog-surface__close",
127
+ "aria-label": closeLabel,
128
+ "data-emphasis": closeEmphasis === "quiet" ? "quiet" : void 0,
129
+ "data-dialog-close": "",
130
+ children: /* @__PURE__ */ jsx(
131
+ LucideIcon,
132
+ {
133
+ icon: X,
134
+ name: "x",
135
+ size: closeEmphasis === "quiet" ? "m" : "l"
136
+ }
137
+ )
138
+ }
139
+ )
140
+ ] })
141
+ ] }),
142
+ presentation === "bottom-sheet" && resizable ? /* @__PURE__ */ jsx(
143
+ "div",
144
+ {
145
+ class: "kui-dialog-surface__sheet-handle",
146
+ role: "separator",
147
+ "aria-orientation": "horizontal",
148
+ "aria-label": "Resize sheet",
149
+ tabindex: 0
150
+ }
151
+ ) : null,
152
+ /* @__PURE__ */ jsx("div", { class: "kui-dialog-surface__body", children }),
153
+ footer === void 0 ? null : /* @__PURE__ */ jsx("footer", { class: "kui-dialog-surface__footer", children: footer }),
154
+ /* @__PURE__ */ jsx("div", { "data-kerf-overlay-host": true, "data-morph-skip": true, style: "display:contents" })
155
+ ]
156
+ }
157
+ );
158
+ }
159
+ var PINNABLE_POPOVER_PROTECTED = /* @__PURE__ */ new Set([
160
+ "data-component",
161
+ "data-presentation",
162
+ "data-size",
163
+ "data-height",
164
+ "data-max-height",
165
+ "data-body-layout",
166
+ "data-pinned",
167
+ "data-placed",
168
+ "data-scrolled",
169
+ "data-resize-from-bottom"
170
+ ]);
171
+ var DEFAULT_MOVE_DESCRIPTION = "Drag the title or press the arrow keys to move it; hold Shift to move farther. Moving it pins it.";
172
+ function PinnablePopoverSurface({
173
+ id,
174
+ label,
175
+ describedBy,
176
+ children,
177
+ headerActions,
178
+ presentation = "overlay",
179
+ pinned = false,
180
+ size = "medium",
181
+ preferredWidth,
182
+ height,
183
+ maxHeight,
184
+ viewportGutter,
185
+ bodyLayout = "flow",
186
+ resizeFromBottom = false,
187
+ pinLabel = "Pin",
188
+ closeLabel = "Close",
189
+ moveDescription = DEFAULT_MOVE_DESCRIPTION,
190
+ rootAttributes = {},
191
+ className = "",
192
+ slot
193
+ }) {
194
+ const style = [
195
+ preferredWidth === void 0 ? "" : `--_kui-pinnable-popover-surface-preferred-width:${preferredWidth}`,
196
+ viewportGutter === void 0 ? "" : `--_kui-pinnable-popover-surface-gutter:${viewportGutter}`,
197
+ height === void 0 || height === "viewport" ? "" : `--_kui-pinnable-popover-surface-height:${height}`,
198
+ maxHeight === void 0 || maxHeight === "viewport" ? "" : `--_kui-pinnable-popover-surface-max-height:${maxHeight}`
199
+ ].filter(Boolean).join(";");
200
+ const overlay = presentation === "overlay";
201
+ return /* @__PURE__ */ jsxs(
202
+ "section",
203
+ {
204
+ ...filterDataAttributes(rootAttributes, PINNABLE_POPOVER_PROTECTED),
205
+ id,
206
+ class: `kui-pinnable-popover-surface ${className}`.trim(),
207
+ "data-component": "pinnable-popover-surface",
208
+ "data-presentation": presentation,
209
+ "data-size": size,
210
+ "data-height": height === void 0 ? void 0 : "",
211
+ "data-max-height": maxHeight === void 0 ? void 0 : "",
212
+ "data-body-layout": bodyLayout === "flow" ? void 0 : bodyLayout,
213
+ "data-resize-from-bottom": resizeFromBottom ? "" : void 0,
214
+ "data-pinned": pinned ? "" : void 0,
215
+ popover: overlay ? "manual" : void 0,
216
+ role: "dialog",
217
+ "aria-labelledby": `${id}-title`,
218
+ "aria-describedby": describedBy,
219
+ style: style || void 0,
220
+ slot,
221
+ children: [
222
+ /* @__PURE__ */ jsxs("header", { class: "kui-pinnable-popover-surface__header", children: [
223
+ /* @__PURE__ */ jsx(
224
+ "button",
225
+ {
226
+ type: "button",
227
+ class: "kui-pinnable-popover-surface__handle",
228
+ "aria-describedby": `${id}-move-description`,
229
+ children: /* @__PURE__ */ jsx("span", { id: `${id}-title`, class: "kui-pinnable-popover-surface__title", children: label })
230
+ }
231
+ ),
232
+ /* @__PURE__ */ jsx("span", { id: `${id}-move-description`, hidden: true, children: moveDescription }),
233
+ /* @__PURE__ */ jsxs("div", { class: "kui-pinnable-popover-surface__header-actions", children: [
234
+ headerActions,
235
+ /* @__PURE__ */ jsx(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ class: "kui-pinnable-popover-surface__control",
240
+ "aria-label": pinLabel,
241
+ "aria-pressed": String(pinned),
242
+ "data-pinnable-popover-pin": "",
243
+ children: /* @__PURE__ */ jsx(LucideIcon, { icon: Pin, name: "pin", size: "m" })
244
+ }
245
+ ),
246
+ /* @__PURE__ */ jsx(
247
+ "button",
248
+ {
249
+ type: "button",
250
+ class: "kui-pinnable-popover-surface__control",
251
+ "aria-label": closeLabel,
252
+ popoverTarget: overlay ? id : void 0,
253
+ popoverTargetAction: overlay ? "hide" : void 0,
254
+ children: /* @__PURE__ */ jsx(LucideIcon, { icon: X, name: "x", size: "l" })
255
+ }
256
+ )
257
+ ] })
258
+ ] }),
259
+ /* @__PURE__ */ jsx("div", { class: "kui-pinnable-popover-surface__body", children }),
260
+ resizeFromBottom && overlay ? /* @__PURE__ */ jsx(
261
+ "button",
262
+ {
263
+ type: "button",
264
+ class: "kui-pinnable-popover-surface__bottom-resize",
265
+ "aria-label": `Resize ${label} vertically`,
266
+ title: `Resize ${label} vertically`
267
+ }
268
+ ) : void 0
269
+ ]
270
+ }
271
+ );
272
+ }
273
+ var POPOVER_DIALOG_PROTECTED = /* @__PURE__ */ new Set([
274
+ "data-anchored",
275
+ "data-component",
276
+ "data-presentation",
277
+ "data-size",
278
+ "data-height",
279
+ "data-max-height",
280
+ "data-body-layout"
281
+ ]);
282
+ function PopoverDialogSurface({
283
+ id,
284
+ children,
285
+ label,
286
+ labelledBy,
287
+ describedBy,
288
+ presentation = "overlay",
289
+ dismiss = "light",
290
+ anchorName,
291
+ size = "medium",
292
+ preferredWidth,
293
+ height,
294
+ maxHeight,
295
+ viewportGutter,
296
+ bodyLayout = "flow",
297
+ rootAttributes = {},
298
+ className = "",
299
+ slot
300
+ }) {
301
+ if (anchorName !== void 0)
302
+ checkedAnchorName(anchorName, "PopoverDialogSurface anchorName");
303
+ const anchored = anchorName !== void 0 && presentation === "overlay";
304
+ const style = [
305
+ anchored ? `position-anchor:${anchorName}` : "",
306
+ preferredWidth === void 0 ? "" : `--_kui-popover-dialog-surface-preferred-width:${preferredWidth}`,
307
+ viewportGutter === void 0 ? "" : `--_kui-popover-dialog-surface-gutter:${viewportGutter}`,
308
+ height === void 0 || height === "viewport" ? "" : `--_kui-popover-dialog-surface-height:${height}`,
309
+ maxHeight === void 0 || maxHeight === "viewport" ? "" : `--_kui-popover-dialog-surface-max-height:${maxHeight}`
310
+ ].filter(Boolean).join(";");
311
+ return /* @__PURE__ */ jsx(
312
+ "section",
313
+ {
314
+ ...filterDataAttributes(rootAttributes, POPOVER_DIALOG_PROTECTED),
315
+ id,
316
+ class: `kui-popover-dialog-surface ${className}`.trim(),
317
+ "data-component": "popover-dialog-surface",
318
+ "data-presentation": presentation,
319
+ "data-size": size,
320
+ "data-height": height === void 0 ? void 0 : "",
321
+ "data-max-height": maxHeight === void 0 ? void 0 : "",
322
+ "data-body-layout": bodyLayout === "flow" ? void 0 : bodyLayout,
323
+ "data-anchored": anchored ? "" : void 0,
324
+ popover: presentation !== "overlay" ? void 0 : dismiss === "manual" ? "manual" : "auto",
325
+ role: "dialog",
326
+ "aria-label": label,
327
+ "aria-labelledby": labelledBy,
328
+ "aria-describedby": describedBy,
329
+ style: style || void 0,
330
+ slot,
331
+ children
332
+ }
333
+ );
334
+ }
335
+ var POPUP_SURFACE_PROTECTED = /* @__PURE__ */ new Set([
336
+ "data-body-inset",
337
+ "data-body-layout",
338
+ "data-component",
339
+ "data-dialog-close",
340
+ "data-emphasis",
341
+ "data-enter-motion",
342
+ "data-exit-motion",
343
+ "data-footer-inset",
344
+ "data-footer-presentation",
345
+ "data-header-presentation",
346
+ "data-height",
347
+ "data-inset",
348
+ "data-light-dismiss",
349
+ "data-max-height",
350
+ "data-min-height",
351
+ "data-preferred-width",
352
+ "data-presentation",
353
+ "data-resizable",
354
+ "data-size",
355
+ "data-stack-active",
356
+ "data-stack-count",
357
+ "data-stack-open",
358
+ "data-stack-position",
359
+ "data-viewport-gutter"
360
+ ]);
361
+ function PopupSurface({
362
+ children,
363
+ inset = "default",
364
+ className = "",
365
+ slot,
366
+ rootAttributes = {}
367
+ }) {
368
+ return /* @__PURE__ */ jsx(
369
+ "span",
370
+ {
371
+ ...filterDataAttributes(rootAttributes, POPUP_SURFACE_PROTECTED),
372
+ class: `kui-popup-surface ${className}`.trim(),
373
+ "data-component": "popup-surface",
374
+ "data-inset": inset === "standard" ? "default" : inset === "list-zero" ? "none" : inset,
375
+ slot,
376
+ children
377
+ }
378
+ );
379
+ }
380
+
381
+ // src/components/surfaces/surface-scaffold/wiring/wire-pinnable-popover.ts
382
+ var controllers = /* @__PURE__ */ new WeakMap();
383
+ var X_PROPERTY = "--_kui-pinnable-popover-surface-x";
384
+ var Y_PROPERTY = "--_kui-pinnable-popover-surface-y";
385
+ var GUTTER_PROPERTY = "--_kui-pinnable-popover-surface-gutter-px";
386
+ var DEFAULT_GUTTER = 16;
387
+ var ANCHOR_GAP = 4;
388
+ var DRAG_THRESHOLD = 3;
389
+ var MIN_RESIZE_HEIGHT = 160;
390
+ var ARROWS = {
391
+ ArrowLeft: [-1, 0],
392
+ ArrowRight: [1, 0],
393
+ ArrowUp: [0, -1],
394
+ ArrowDown: [0, 1]
395
+ };
396
+ function isPopoverPinned(surface) {
397
+ return controllers.get(surface)?.pinned ?? surface.hasAttribute("data-pinned");
398
+ }
399
+ function pinPopover(surface, pinned = true) {
400
+ controllers.get(surface)?.setPinned(pinned);
401
+ }
402
+ function wirePinnablePopover(surface, options = {}) {
403
+ if (surface.dataset.presentation === "embedded") return () => {
404
+ };
405
+ const doc = surface.ownerDocument;
406
+ const view = doc.defaultView ?? globalThis;
407
+ const step = options.step ?? 8;
408
+ const largeStep = options.largeStep ?? 40;
409
+ let pinned = options.pinned ?? false;
410
+ let requested = pinned && options.placement ? options.placement : null;
411
+ const owned = /* @__PURE__ */ new Map();
412
+ let frame = 0;
413
+ const isOpen = () => surface.matches(":popover-open");
414
+ const report = (reason) => options.onChange?.({ pinned, placement: requested, reason });
415
+ const own = (property, value) => {
416
+ if (value === null) {
417
+ owned.delete(property);
418
+ surface.style.removeProperty(property);
419
+ } else {
420
+ owned.set(property, value);
421
+ if (surface.style.getPropertyValue(property) !== value)
422
+ surface.style.setProperty(property, value);
423
+ }
424
+ };
425
+ const syncAttributes = () => {
426
+ surface.toggleAttribute("data-pinned", pinned);
427
+ surface.toggleAttribute("data-placed", owned.has(X_PROPERTY));
428
+ const pin = surface.querySelector("[data-pinnable-popover-pin]");
429
+ if (pin && pin.getAttribute("aria-pressed") !== String(pinned))
430
+ pin.setAttribute("aria-pressed", String(pinned));
431
+ };
432
+ const gutter = () => {
433
+ const value = parseFloat(
434
+ view.getComputedStyle(surface).getPropertyValue(GUTTER_PROPERTY)
435
+ );
436
+ return Number.isFinite(value) ? value : DEFAULT_GUTTER;
437
+ };
438
+ const viewport = () => ({
439
+ width: doc.documentElement.clientWidth || view.innerWidth,
440
+ height: view.innerHeight
441
+ });
442
+ const clamp = (x, y) => {
443
+ const box = surface.getBoundingClientRect();
444
+ const g = gutter();
445
+ const { width, height } = viewport();
446
+ return {
447
+ x: Math.max(g, Math.min(x, width - g - box.width)),
448
+ y: Math.max(g, Math.min(y, height - g - box.height))
449
+ };
450
+ };
451
+ const place = (x, y) => {
452
+ const at = clamp(x, y);
453
+ own(X_PROPERTY, `${at.x}px`);
454
+ own(Y_PROPERTY, `${at.y}px`);
455
+ syncAttributes();
456
+ return at;
457
+ };
458
+ const applySize = () => {
459
+ own(
460
+ "width",
461
+ requested?.width === void 0 ? null : `${requested.width}px`
462
+ );
463
+ own(
464
+ "height",
465
+ requested?.height === void 0 ? null : `${requested.height}px`
466
+ );
467
+ };
468
+ const resolveAnchor = () => {
469
+ const anchor = typeof options.anchor === "function" ? options.anchor() : options.anchor;
470
+ if (anchor) return anchor;
471
+ if (!surface.id) return null;
472
+ for (const invoker of doc.querySelectorAll(
473
+ `[popovertarget="${CSS.escape(surface.id)}"]`
474
+ ))
475
+ if (!surface.contains(invoker)) return invoker;
476
+ return null;
477
+ };
478
+ const placeAtAnchor = () => {
479
+ const anchor = resolveAnchor();
480
+ if (!anchor) {
481
+ own(X_PROPERTY, null);
482
+ own(Y_PROPERTY, null);
483
+ syncAttributes();
484
+ return;
485
+ }
486
+ const target = anchor.getBoundingClientRect();
487
+ const box = surface.getBoundingClientRect();
488
+ const rtl = view.getComputedStyle(surface).direction === "rtl";
489
+ let y = target.bottom + ANCHOR_GAP;
490
+ if (y + box.height > viewport().height - gutter() && target.top - ANCHOR_GAP - box.height >= gutter())
491
+ y = target.top - ANCHOR_GAP - box.height;
492
+ place(rtl ? target.right - box.width : target.left, y);
493
+ };
494
+ const layout = () => {
495
+ if (!isOpen()) return;
496
+ if (!pinned) placeAtAnchor();
497
+ else if (requested) place(requested.x, requested.y);
498
+ else if (owned.has(X_PROPERTY)) {
499
+ const box = surface.getBoundingClientRect();
500
+ place(box.left, box.top);
501
+ }
502
+ };
503
+ const settle = (at) => {
504
+ requested = {
505
+ ...requested ?? {},
506
+ x: at.x,
507
+ y: at.y
508
+ };
509
+ };
510
+ const setPinned = (next) => {
511
+ if (next === pinned) return;
512
+ pinned = next;
513
+ if (pinned) {
514
+ if (isOpen()) {
515
+ const box = surface.getBoundingClientRect();
516
+ settle(place(box.left, box.top));
517
+ }
518
+ } else {
519
+ requested = null;
520
+ applySize();
521
+ layout();
522
+ }
523
+ syncAttributes();
524
+ report(pinned ? "pin" : "unpin");
525
+ };
526
+ const controller = {
527
+ get pinned() {
528
+ return pinned;
529
+ },
530
+ setPinned
531
+ };
532
+ controllers.set(surface, controller);
533
+ const onBeforeToggle = (event) => {
534
+ if (event.newState !== "open") return;
535
+ applySize();
536
+ view.cancelAnimationFrame(frame);
537
+ frame = view.requestAnimationFrame(layout);
538
+ };
539
+ const scrollOwner = () => surface.querySelector(
540
+ ":scope > .kui-pinnable-popover-surface__body > :last-child"
541
+ );
542
+ const syncScrollDivider = () => {
543
+ surface.toggleAttribute(
544
+ "data-scrolled",
545
+ surface.dataset.bodyLayout === "fill-last" && (scrollOwner()?.scrollTop ?? 0) > 1
546
+ );
547
+ };
548
+ const onToggle = (event) => {
549
+ if (event.newState === "open") {
550
+ layout();
551
+ syncScrollDivider();
552
+ }
553
+ };
554
+ const onSurfaceScroll = (event) => {
555
+ if (event.target === scrollOwner()) syncScrollDivider();
556
+ };
557
+ const onClick = (event) => {
558
+ const pin = event.target.closest(
559
+ "[data-pinnable-popover-pin]"
560
+ );
561
+ if (pin && surface.contains(pin)) setPinned(!pinned);
562
+ };
563
+ const onKeyDown = (event) => {
564
+ const resizeHandle = event.target.closest(
565
+ ".kui-pinnable-popover-surface__bottom-resize"
566
+ );
567
+ if (resizeHandle?.parentElement === surface && (event.key === "ArrowUp" || event.key === "ArrowDown") && !event.altKey && !event.ctrlKey && !event.metaKey) {
568
+ event.preventDefault();
569
+ setPinned(true);
570
+ const box2 = surface.getBoundingClientRect();
571
+ const distance2 = event.shiftKey ? largeStep : step;
572
+ const maxHeight = Math.max(0, viewport().height - gutter() - box2.top);
573
+ const height = Math.min(
574
+ Math.max(
575
+ MIN_RESIZE_HEIGHT,
576
+ box2.height + (event.key === "ArrowDown" ? distance2 : -distance2)
577
+ ),
578
+ maxHeight
579
+ );
580
+ own("height", `${Math.round(height)}px`);
581
+ requested = {
582
+ ...requested ?? { x: box2.left, y: box2.top },
583
+ height: Math.round(height)
584
+ };
585
+ report("resize");
586
+ return;
587
+ }
588
+ const handle = event.target.closest(
589
+ ".kui-pinnable-popover-surface__handle"
590
+ );
591
+ const delta = ARROWS[event.key];
592
+ if (!handle || !delta || event.altKey || event.ctrlKey || event.metaKey)
593
+ return;
594
+ event.preventDefault();
595
+ setPinned(true);
596
+ const distance = event.shiftKey ? largeStep : step;
597
+ const box = surface.getBoundingClientRect();
598
+ settle(
599
+ place(box.left + delta[0] * distance, box.top + delta[1] * distance)
600
+ );
601
+ report("move");
602
+ };
603
+ let drag;
604
+ let resizeDrag;
605
+ const onPointerDown = (event) => {
606
+ const target = event.target;
607
+ const resizeHandle = target.closest(
608
+ ".kui-pinnable-popover-surface__bottom-resize"
609
+ );
610
+ if (resizeHandle?.parentElement === surface && event.button === 0) {
611
+ const box2 = surface.getBoundingClientRect();
612
+ setPinned(true);
613
+ resizeDrag = {
614
+ id: event.pointerId,
615
+ handle: resizeHandle,
616
+ startY: event.clientY,
617
+ height: box2.height
618
+ };
619
+ resizeHandle.setPointerCapture?.(event.pointerId);
620
+ event.preventDefault();
621
+ return;
622
+ }
623
+ const header = target.closest(
624
+ ".kui-pinnable-popover-surface__header"
625
+ );
626
+ if (!header || header.parentElement !== surface || event.button !== 0 || target.closest(".kui-pinnable-popover-surface__header-actions"))
627
+ return;
628
+ const box = surface.getBoundingClientRect();
629
+ drag = {
630
+ id: event.pointerId,
631
+ header,
632
+ startX: event.clientX,
633
+ startY: event.clientY,
634
+ left: box.left,
635
+ top: box.top,
636
+ moving: false
637
+ };
638
+ header.setPointerCapture?.(event.pointerId);
639
+ };
640
+ const onPointerMove = (event) => {
641
+ if (resizeDrag && event.pointerId === resizeDrag.id) {
642
+ const box = surface.getBoundingClientRect();
643
+ const maxHeight = Math.max(0, viewport().height - gutter() - box.top);
644
+ const height = Math.min(
645
+ Math.max(
646
+ MIN_RESIZE_HEIGHT,
647
+ resizeDrag.height + event.clientY - resizeDrag.startY
648
+ ),
649
+ maxHeight
650
+ );
651
+ own("height", `${Math.round(height)}px`);
652
+ return;
653
+ }
654
+ if (!drag || event.pointerId !== drag.id) return;
655
+ const dx = event.clientX - drag.startX;
656
+ const dy = event.clientY - drag.startY;
657
+ if (!drag.moving && Math.hypot(dx, dy) < DRAG_THRESHOLD) return;
658
+ const firstMove = !drag.bounds;
659
+ if (!drag.bounds) {
660
+ drag.moving = true;
661
+ setPinned(true);
662
+ const box = surface.getBoundingClientRect();
663
+ const min2 = gutter();
664
+ const viewSize = viewport();
665
+ drag.bounds = {
666
+ min: min2,
667
+ maxX: viewSize.width - min2 - box.width,
668
+ maxY: viewSize.height - min2 - box.height
669
+ };
670
+ }
671
+ const { min, maxX, maxY } = drag.bounds;
672
+ own(X_PROPERTY, `${Math.max(min, Math.min(drag.left + dx, maxX))}px`);
673
+ own(Y_PROPERTY, `${Math.max(min, Math.min(drag.top + dy, maxY))}px`);
674
+ if (firstMove) syncAttributes();
675
+ };
676
+ const onPointerEnd = (event) => {
677
+ if (resizeDrag && event.pointerId === resizeDrag.id) {
678
+ const { handle } = resizeDrag;
679
+ resizeDrag = void 0;
680
+ if (handle.hasPointerCapture?.(event.pointerId))
681
+ handle.releasePointerCapture(event.pointerId);
682
+ const box2 = surface.getBoundingClientRect();
683
+ requested = {
684
+ ...requested ?? { x: box2.left, y: box2.top },
685
+ height: Math.round(box2.height)
686
+ };
687
+ report("resize");
688
+ return;
689
+ }
690
+ if (!drag || event.pointerId !== drag.id) return;
691
+ const { header, moving } = drag;
692
+ drag = void 0;
693
+ if (header.hasPointerCapture?.(event.pointerId))
694
+ header.releasePointerCapture(event.pointerId);
695
+ if (!moving) return;
696
+ const box = surface.getBoundingClientRect();
697
+ settle(place(box.left, box.top));
698
+ report("move");
699
+ };
700
+ const onDocumentPointerDown = (event) => {
701
+ if (pinned || !isOpen()) return;
702
+ const path = event.composedPath();
703
+ if (path.includes(surface)) return;
704
+ const anchor = resolveAnchor();
705
+ if (anchor && path.includes(anchor)) return;
706
+ if (path.some(
707
+ (node) => node instanceof Element && node.getAttribute("popovertarget") === surface.id
708
+ ))
709
+ return;
710
+ surface.hidePopover();
711
+ };
712
+ const onDocumentKeyDown = (event) => {
713
+ if (event.key !== "Escape" || event.defaultPrevented || !isOpen()) return;
714
+ if (pinned && !surface.contains(doc.activeElement)) return;
715
+ if (doc.querySelector(
716
+ ':is([popover=""], [popover="auto"]):popover-open, dialog:modal'
717
+ ))
718
+ return;
719
+ event.preventDefault();
720
+ surface.hidePopover();
721
+ };
722
+ const onResize = () => {
723
+ if (drag?.moving) {
724
+ drag.bounds = void 0;
725
+ return;
726
+ }
727
+ layout();
728
+ };
729
+ const onScroll = () => {
730
+ if (!pinned) layout();
731
+ };
732
+ const adoptResize = () => {
733
+ if (pinned) {
734
+ const width = surface.style.width;
735
+ const height = surface.style.height;
736
+ const resized = width !== "" && width !== owned.get("width") || height !== "" && height !== owned.get("height");
737
+ if (resized) {
738
+ const box = surface.getBoundingClientRect();
739
+ requested = {
740
+ ...requested ?? { x: box.left, y: box.top },
741
+ width: Math.round(box.width),
742
+ height: Math.round(box.height)
743
+ };
744
+ if (width !== "") owned.set("width", width);
745
+ if (height !== "") owned.set("height", height);
746
+ report("resize");
747
+ }
748
+ }
749
+ };
750
+ if (pinned) syncAttributes();
751
+ syncScrollDivider();
752
+ if (isOpen()) {
753
+ applySize();
754
+ layout();
755
+ }
756
+ const restore = watchOwnedStyles(surface, owned, {
757
+ attributes: ["data-pinned", "data-placed", "data-scrolled", "aria-pressed"],
758
+ childList: true,
759
+ subtree: true,
760
+ beforeRestore: adoptResize,
761
+ afterRestore: () => {
762
+ syncAttributes();
763
+ syncScrollDivider();
764
+ }
765
+ });
766
+ surface.addEventListener("beforetoggle", onBeforeToggle);
767
+ surface.addEventListener("toggle", onToggle);
768
+ surface.addEventListener("scroll", onSurfaceScroll, {
769
+ capture: true,
770
+ passive: true
771
+ });
772
+ surface.addEventListener("click", onClick);
773
+ surface.addEventListener("keydown", onKeyDown);
774
+ surface.addEventListener("pointerdown", onPointerDown);
775
+ surface.addEventListener("pointermove", onPointerMove);
776
+ surface.addEventListener("pointerup", onPointerEnd);
777
+ surface.addEventListener("pointercancel", onPointerEnd);
778
+ doc.addEventListener("pointerdown", onDocumentPointerDown, true);
779
+ doc.addEventListener("keydown", onDocumentKeyDown);
780
+ view.addEventListener("resize", onResize);
781
+ doc.addEventListener("scroll", onScroll, { capture: true, passive: true });
782
+ return () => {
783
+ view.cancelAnimationFrame(frame);
784
+ restore.disconnect();
785
+ surface.removeEventListener("beforetoggle", onBeforeToggle);
786
+ surface.removeEventListener("toggle", onToggle);
787
+ surface.removeEventListener("scroll", onSurfaceScroll, { capture: true });
788
+ surface.removeEventListener("click", onClick);
789
+ surface.removeEventListener("keydown", onKeyDown);
790
+ surface.removeEventListener("pointerdown", onPointerDown);
791
+ surface.removeEventListener("pointermove", onPointerMove);
792
+ surface.removeEventListener("pointerup", onPointerEnd);
793
+ surface.removeEventListener("pointercancel", onPointerEnd);
794
+ doc.removeEventListener("pointerdown", onDocumentPointerDown, true);
795
+ doc.removeEventListener("keydown", onDocumentKeyDown);
796
+ view.removeEventListener("resize", onResize);
797
+ doc.removeEventListener("scroll", onScroll, { capture: true });
798
+ for (const property of owned.keys()) surface.style.removeProperty(property);
799
+ owned.clear();
800
+ surface.removeAttribute("data-placed");
801
+ surface.removeAttribute("data-scrolled");
802
+ if (controllers.get(surface) === controller) controllers.delete(surface);
803
+ };
804
+ }
805
+
806
+ export { DialogSurface, PinnablePopoverSurface, PopoverDialogSurface, PopupSurface, isPopoverPinned, pinPopover, wirePinnablePopover };
807
+
808
+ //# sourceMappingURL=chunk-HD7ZLISK.js.map