@editora/ui-core 0.1.18 → 0.1.20

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 (307) hide show
  1. package/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
  2. package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
  3. package/dist/accordion.cjs.js +3 -3
  4. package/dist/accordion.esm.js +39 -62
  5. package/dist/alert-dialog.cjs.js +19 -19
  6. package/dist/alert-dialog.esm.js +69 -87
  7. package/dist/alert.cjs.js +1 -1
  8. package/dist/alert.esm.js +4 -7
  9. package/dist/anchor.cjs.js +2 -2
  10. package/dist/anchor.esm.js +3 -3
  11. package/dist/animated-beam.cjs.js +83 -83
  12. package/dist/animated-beam.esm.js +250 -277
  13. package/dist/animated-list.cjs.js +4 -4
  14. package/dist/animated-list.esm.js +47 -61
  15. package/dist/animated-text.cjs.js +2 -2
  16. package/dist/animated-text.esm.js +13 -24
  17. package/dist/app-header.cjs.js +3 -3
  18. package/dist/app-header.esm.js +11 -13
  19. package/dist/aspect-ratio.cjs.js +1 -1
  20. package/dist/aspect-ratio.esm.js +4 -7
  21. package/dist/avatar.cjs.js +1 -1
  22. package/dist/avatar.esm.js +7 -13
  23. package/dist/badge.cjs.js +1 -1
  24. package/dist/badge.esm.js +4 -7
  25. package/dist/block-controls.cjs.js +2 -2
  26. package/dist/block-controls.esm.js +19 -35
  27. package/dist/box.cjs.js +1 -1
  28. package/dist/box.esm.js +8 -15
  29. package/dist/breadcrumb.cjs.js +2 -2
  30. package/dist/breadcrumb.esm.js +20 -37
  31. package/dist/button.cjs.js +1 -521
  32. package/dist/button.esm.js +2 -669
  33. package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
  34. package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
  35. package/dist/calendar.cjs.js +1 -1
  36. package/dist/calendar.esm.js +8 -9
  37. package/dist/card.cjs.js +4 -4
  38. package/dist/card.esm.js +13 -19
  39. package/dist/chart.cjs.js +64 -64
  40. package/dist/chart.esm.js +223 -254
  41. package/dist/checkbox.cjs.js +1 -1
  42. package/dist/checkbox.esm.js +2 -3
  43. package/dist/collapsible.cjs.js +1 -1
  44. package/dist/collapsible.esm.js +5 -9
  45. package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
  46. package/dist/collection.cjs.js +1 -1
  47. package/dist/collection.esm.js +4 -7
  48. package/dist/color-picker.cjs.js +9 -9
  49. package/dist/color-picker.esm.js +189 -252
  50. package/dist/combobox.cjs.js +13 -13
  51. package/dist/combobox.esm.js +93 -126
  52. package/dist/command-palette.cjs.js +3 -3
  53. package/dist/command-palette.esm.js +19 -30
  54. package/dist/command.cjs.js +4 -4
  55. package/dist/command.esm.js +41 -53
  56. package/dist/components/ui-button.d.ts +1 -0
  57. package/dist/components/ui-button.d.ts.map +1 -1
  58. package/dist/components/ui-date-picker.d.ts.map +1 -1
  59. package/dist/components/ui-date-range-picker.d.ts.map +1 -1
  60. package/dist/components/ui-date-range-time-picker.d.ts +1 -0
  61. package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
  62. package/dist/components/ui-date-time-picker.d.ts +1 -0
  63. package/dist/components/ui-date-time-picker.d.ts.map +1 -1
  64. package/dist/components/ui-orbiter.d.ts.map +1 -1
  65. package/dist/components/ui-skeleton.d.ts.map +1 -1
  66. package/dist/components/ui-split-button.d.ts +1 -0
  67. package/dist/components/ui-split-button.d.ts.map +1 -1
  68. package/dist/components/ui-time-picker.d.ts.map +1 -1
  69. package/dist/container.cjs.js +2 -2
  70. package/dist/container.esm.js +2 -3
  71. package/dist/context-menu.cjs.js +8 -8
  72. package/dist/context-menu.esm.js +157 -219
  73. package/dist/control-group.cjs.js +1 -1
  74. package/dist/control-group.esm.js +2 -3
  75. package/dist/data-table.cjs.js +4 -4
  76. package/dist/data-table.esm.js +299 -381
  77. package/dist/date-field.cjs.js +3 -3
  78. package/dist/date-field.esm.js +68 -80
  79. package/dist/date-picker.cjs.js +30 -9
  80. package/dist/date-picker.esm.js +90 -97
  81. package/dist/date-range-picker.cjs.js +22 -3
  82. package/dist/date-range-picker.esm.js +103 -108
  83. package/dist/date-range-time-picker.cjs.js +28 -12
  84. package/dist/date-range-time-picker.esm.js +137 -150
  85. package/dist/date-time-picker.cjs.js +25 -9
  86. package/dist/date-time-picker.esm.js +139 -155
  87. package/dist/date-time-utils-Dmost5Ee.js +1 -0
  88. package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
  89. package/dist/description.cjs.js +1 -1
  90. package/dist/description.esm.js +3 -5
  91. package/dist/dialog.cjs.js +12 -12
  92. package/dist/dialog.esm.js +44 -63
  93. package/dist/direction-provider.cjs.js +1 -1
  94. package/dist/direction-provider.esm.js +2 -3
  95. package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
  96. package/dist/dismissable-layer-DNfrKA20.js +1 -0
  97. package/dist/dismissable-layer.cjs.js +2 -2
  98. package/dist/dismissable-layer.esm.js +4 -6
  99. package/dist/dock.cjs.js +5 -5
  100. package/dist/dock.esm.js +134 -155
  101. package/dist/drawer.cjs.js +2 -2
  102. package/dist/drawer.esm.js +18 -35
  103. package/dist/dropdown.cjs.js +2 -2
  104. package/dist/dropdown.esm.js +119 -149
  105. package/dist/dropzone.cjs.js +1 -1
  106. package/dist/dropzone.esm.js +0 -1
  107. package/dist/empty-state.cjs.js +1 -1
  108. package/dist/empty-state.esm.js +1 -1
  109. package/dist/field-error.cjs.js +1 -1
  110. package/dist/field-error.esm.js +3 -5
  111. package/dist/field.cjs.js +5 -5
  112. package/dist/field.esm.js +27 -34
  113. package/dist/fieldset.cjs.js +4 -4
  114. package/dist/fieldset.esm.js +19 -24
  115. package/dist/file-upload.cjs.js +4 -4
  116. package/dist/file-upload.esm.js +69 -93
  117. package/dist/flex.cjs.js +1 -1
  118. package/dist/flex.esm.js +5 -9
  119. package/dist/floating-toolbar.cjs.js +4 -4
  120. package/dist/floating-toolbar.esm.js +60 -85
  121. package/dist/focus-scope-Bwug2gDv.js +1 -0
  122. package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
  123. package/dist/focus-scope.cjs.js +2 -2
  124. package/dist/focus-scope.esm.js +15 -20
  125. package/dist/form.cjs.js +2 -2
  126. package/dist/form.esm.js +26 -53
  127. package/dist/gantt.cjs.js +43 -43
  128. package/dist/gantt.esm.js +295 -322
  129. package/dist/grid.cjs.js +1 -1
  130. package/dist/grid.esm.js +5 -9
  131. package/dist/hover-card.cjs.js +4 -4
  132. package/dist/hover-card.esm.js +22 -28
  133. package/dist/icon-cloud.cjs.js +7 -7
  134. package/dist/icon-cloud.esm.js +48 -62
  135. package/dist/icon.cjs.js +1 -1
  136. package/dist/icon.esm.js +2 -4
  137. package/dist/index.cjs.js +1 -1
  138. package/dist/index.esm.js +378 -390
  139. package/dist/inline-edit.cjs.js +11 -11
  140. package/dist/inline-edit.esm.js +32 -36
  141. package/dist/input.cjs.js +17 -17
  142. package/dist/input.esm.js +50 -63
  143. package/dist/label.cjs.js +2 -2
  144. package/dist/label.esm.js +8 -17
  145. package/dist/layout.cjs.js +2 -2
  146. package/dist/layout.esm.js +20 -26
  147. package/dist/listbox-B6QgECax.js +46 -0
  148. package/dist/listbox-DJamVeFj.mjs +200 -0
  149. package/dist/listbox.cjs.js +1 -1
  150. package/dist/listbox.esm.js +2 -4
  151. package/dist/marquee.cjs.js +5 -5
  152. package/dist/marquee.esm.js +33 -50
  153. package/dist/masonry-grid.cjs.js +1 -1
  154. package/dist/masonry-grid.esm.js +5 -9
  155. package/dist/menu.cjs.js +3 -3
  156. package/dist/menu.esm.js +106 -126
  157. package/dist/menubar.cjs.js +5 -5
  158. package/dist/menubar.esm.js +118 -164
  159. package/dist/meter.cjs.js +2 -2
  160. package/dist/meter.esm.js +4 -4
  161. package/dist/multi-select.cjs.js +4 -4
  162. package/dist/multi-select.esm.js +120 -140
  163. package/dist/navigation-menu.cjs.js +4 -4
  164. package/dist/navigation-menu.esm.js +44 -55
  165. package/dist/number-field.cjs.js +2 -2
  166. package/dist/number-field.esm.js +73 -98
  167. package/dist/number-ticker.cjs.js +3 -3
  168. package/dist/number-ticker.esm.js +22 -43
  169. package/dist/odometer.cjs.js +1 -1
  170. package/dist/odometer.esm.js +5 -9
  171. package/dist/orbiter.cjs.js +13 -13
  172. package/dist/orbiter.esm.js +79 -90
  173. package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
  174. package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
  175. package/dist/pagination.cjs.js +2 -2
  176. package/dist/pagination.esm.js +14 -18
  177. package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
  178. package/dist/panel-group-CaD0_KQf.js +36 -0
  179. package/dist/panel-group.cjs.js +1 -1
  180. package/dist/panel-group.esm.js +2 -5
  181. package/dist/panel.cjs.js +4 -4
  182. package/dist/panel.esm.js +8 -10
  183. package/dist/password-field.cjs.js +9 -9
  184. package/dist/password-field.esm.js +62 -82
  185. package/dist/pin-input.cjs.js +3 -3
  186. package/dist/pin-input.esm.js +33 -39
  187. package/dist/placement-grid.cjs.js +4 -4
  188. package/dist/placement-grid.esm.js +108 -131
  189. package/dist/plugin-panel.cjs.js +7 -7
  190. package/dist/plugin-panel.esm.js +13 -15
  191. package/dist/popover.cjs.js +2 -2
  192. package/dist/popover.esm.js +21 -31
  193. package/dist/portal-DgpQ3Jo1.js +1 -0
  194. package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
  195. package/dist/portal.cjs.js +2 -2
  196. package/dist/portal.esm.js +10 -19
  197. package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
  198. package/dist/positioner-D_fqyx_j.js +1 -0
  199. package/dist/positioner.cjs.js +2 -2
  200. package/dist/positioner.esm.js +11 -18
  201. package/dist/presence.cjs.js +1 -1
  202. package/dist/presence.esm.js +7 -13
  203. package/dist/progress.cjs.js +1 -1
  204. package/dist/progress.esm.js +5 -9
  205. package/dist/quick-actions.cjs.js +6 -6
  206. package/dist/quick-actions.esm.js +52 -62
  207. package/dist/radio-group.cjs.js +13 -13
  208. package/dist/radio-group.esm.js +39 -51
  209. package/dist/radio.cjs.js +1 -1
  210. package/dist/radio.esm.js +5 -9
  211. package/dist/rating.cjs.js +1 -1
  212. package/dist/rating.esm.js +12 -23
  213. package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
  214. package/dist/roving-focus-group.cjs.js +1 -1
  215. package/dist/roving-focus-group.esm.js +3 -5
  216. package/dist/runtime-CTaOSmBj.js +1 -0
  217. package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
  218. package/dist/runtime.cjs.js +1 -1
  219. package/dist/runtime.esm.js +6 -6
  220. package/dist/scroll-area.cjs.js +3 -3
  221. package/dist/scroll-area.esm.js +38 -46
  222. package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
  223. package/dist/section.cjs.js +1 -1
  224. package/dist/section.esm.js +1 -1
  225. package/dist/select.cjs.js +7 -7
  226. package/dist/select.esm.js +67 -97
  227. package/dist/selection-popup.cjs.js +1 -1
  228. package/dist/selection-popup.esm.js +8 -15
  229. package/dist/separator.cjs.js +1 -1
  230. package/dist/separator.esm.js +1 -1
  231. package/dist/sidebar.cjs.js +18 -18
  232. package/dist/sidebar.esm.js +117 -139
  233. package/dist/skeleton.cjs.js +11 -11
  234. package/dist/skeleton.esm.js +27 -24
  235. package/dist/slider.cjs.js +1 -1
  236. package/dist/slider.esm.js +6 -11
  237. package/dist/slot.cjs.js +4 -4
  238. package/dist/slot.esm.js +16 -19
  239. package/dist/sortable.cjs.js +45 -45
  240. package/dist/sortable.esm.js +421 -524
  241. package/dist/spinning-text.cjs.js +12 -12
  242. package/dist/spinning-text.esm.js +80 -92
  243. package/dist/split-button.cjs.js +4 -4
  244. package/dist/split-button.esm.js +77 -62
  245. package/dist/splitter.cjs.js +1 -1
  246. package/dist/splitter.esm.js +1 -1
  247. package/dist/stepper.cjs.js +8 -8
  248. package/dist/stepper.esm.js +32 -52
  249. package/dist/switch.cjs.js +7 -7
  250. package/dist/switch.esm.js +23 -31
  251. package/dist/table.cjs.js +2 -2
  252. package/dist/table.esm.js +46 -56
  253. package/dist/tabs.cjs.js +3 -3
  254. package/dist/tabs.esm.js +35 -55
  255. package/dist/tags-input.cjs.js +4 -4
  256. package/dist/tags-input.esm.js +45 -62
  257. package/dist/textarea.cjs.js +6 -6
  258. package/dist/textarea.esm.js +32 -41
  259. package/dist/time-field.cjs.js +4 -4
  260. package/dist/time-field.esm.js +70 -84
  261. package/dist/time-picker.cjs.js +29 -21
  262. package/dist/time-picker.esm.js +96 -110
  263. package/dist/timeline.cjs.js +1 -1
  264. package/dist/timeline.esm.js +3 -5
  265. package/dist/toast.cjs.js +2 -2
  266. package/dist/toast.esm.js +33 -47
  267. package/dist/toggle-group.cjs.js +6 -6
  268. package/dist/toggle-group.esm.js +85 -105
  269. package/dist/toggle.cjs.js +1 -1
  270. package/dist/toggle.esm.js +3 -5
  271. package/dist/toolbar.cjs.js +1 -1
  272. package/dist/toolbar.esm.js +13 -24
  273. package/dist/tooltip.cjs.js +2 -2
  274. package/dist/tooltip.esm.js +31 -42
  275. package/dist/transfer-list.cjs.js +19 -19
  276. package/dist/transfer-list.esm.js +98 -111
  277. package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
  278. package/dist/tree-Dx_kv_ih.js +39 -0
  279. package/dist/tree-item.cjs.js +2 -2
  280. package/dist/tree-item.esm.js +2 -3
  281. package/dist/tree.cjs.js +1 -1
  282. package/dist/tree.esm.js +2 -5
  283. package/dist/ui-button-Q0GNNWKC.mjs +665 -0
  284. package/dist/ui-button-rXQOS9QJ.js +521 -0
  285. package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
  286. package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
  287. package/dist/visually-hidden.cjs.js +1 -1
  288. package/dist/visually-hidden.esm.js +1 -1
  289. package/dist/wizard.cjs.js +14 -14
  290. package/dist/wizard.esm.js +85 -105
  291. package/package.json +3 -3
  292. package/dist/date-time-utils-66480de4.js +0 -1
  293. package/dist/date-time-utils-a2c7af25.mjs +0 -307
  294. package/dist/dismissable-layer-193e3bed.js +0 -1
  295. package/dist/focus-scope-2b12b4e7.js +0 -1
  296. package/dist/listbox-308789a0.mjs +0 -210
  297. package/dist/listbox-ef2f708e.js +0 -46
  298. package/dist/panel-group-40254cdd.js +0 -36
  299. package/dist/portal-c69756c0.js +0 -1
  300. package/dist/positioner-33529bb8.js +0 -1
  301. package/dist/runtime-3f13807b.js +0 -1
  302. package/dist/tree-0a7a8d05.js +0 -39
  303. /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
  304. /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
  305. /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
  306. /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
  307. /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./ElementBase-1b301e7f.js"),_=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./ElementBase-EV6mVBUV.js"),_=`
2
2
  :host {
3
3
  --ui-slider-width: min(340px, 100%);
4
4
  --ui-slider-track-size: 6px;
@@ -1,4 +1,4 @@
1
- import { E as f } from "./ElementBase-909688f3.mjs";
1
+ import { E as f } from "./ElementBase-YlTLMsGk.mjs";
2
2
  const x = `
3
3
  :host {
4
4
  --ui-slider-width: min(340px, 100%);
@@ -477,8 +477,7 @@ function b(n) {
477
477
  return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
478
478
  }
479
479
  function m(n, t, e) {
480
- if (!n)
481
- return [];
480
+ if (!n) return [];
482
481
  try {
483
482
  const r = JSON.parse(n);
484
483
  return Array.isArray(r) ? r.map((i) => typeof i == "number" ? { value: i } : i && typeof i == "object" && Number.isFinite(Number(i.value)) ? {
@@ -490,8 +489,7 @@ function m(n, t, e) {
490
489
  }
491
490
  }
492
491
  function p(n, t = !1) {
493
- if (n == null)
494
- return t;
492
+ if (n == null) return t;
495
493
  const e = String(n).toLowerCase();
496
494
  return e !== "false" && e !== "0" && e !== "off";
497
495
  }
@@ -632,21 +630,18 @@ class k extends f {
632
630
  t.classList.contains("start") ? this._valueStart = Math.min(l, this._valueEnd) : this._valueEnd = Math.max(l, this._valueStart), this._valueStart = Math.round(this._valueStart / i) * i, this._valueEnd = Math.round(this._valueEnd / i) * i, this._value = this._valueEnd, this.setAttribute("value-start", String(this._valueStart)), this.setAttribute("value-end", String(this._valueEnd)), this.setAttribute("value", String(this._valueEnd));
633
631
  }
634
632
  _onInput(t) {
635
- if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled"))
636
- return;
633
+ if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled")) return;
637
634
  const e = t.target;
638
635
  !e || e.type !== "range" || (this._updateFromInput(e), this._syncDom(), this._emit("input"), this._emit("valuechange"));
639
636
  }
640
637
  _onChange(t) {
641
- if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled"))
642
- return;
638
+ if (p(this.getAttribute("disabled")) || this.hasAttribute("disabled")) return;
643
639
  const e = t.target;
644
640
  !e || e.type !== "range" || (this._updateFromInput(e), this._syncDom(), this._emit("change"));
645
641
  }
646
642
  _renderMarks(t, e) {
647
643
  const r = m(this.getAttribute("marks"), t, e);
648
- if (!r.length)
649
- return '<div class="marks" part="marks" hidden></div>';
644
+ if (!r.length) return '<div class="marks" part="marks" hidden></div>';
650
645
  const i = Math.max(1, e - t), l = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal";
651
646
  return `<div class="marks" part="marks">${r.map((s) => {
652
647
  const o = (s.value - t) / i * 100, d = l === "vertical" ? `style="bottom:${o}%"` : `style="left:${o}%"`, c = s.label != null ? b(s.label) : String(s.value);
package/dist/slot.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./ElementBase-1b301e7f.js"),u=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./ElementBase-EV6mVBUV.js"),u=`
2
2
  :host {
3
3
  --ui-slot-bg: transparent;
4
4
  --ui-slot-text: inherit;
@@ -150,10 +150,10 @@
150
150
  --ui-slot-border-color: CanvasText;
151
151
  }
152
152
  }
153
- `;function o(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}class a extends r.ElementBase{constructor(){super(),this._slotEl=null,this._shellEl=null,this._lastEmpty=!0,this._lastCount=-1,this._lastName="",this._initialized=!1,this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["name","headless","inline","align","size","variant","tone","fallback","required"]}disconnectedCallback(){this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=null,this._shellEl=null,this._initialized=!1,this._lastCount=-1,this._lastName="",this._lastEmpty=!0,super.disconnectedCallback()}attributeChangedCallback(s,t,e){if(t!==e){if(s==="required"){this.isConnected&&this._syncState(!0);return}super.attributeChangedCallback(s,t,e)}}_assignedCount(){return this._slotEl?this._slotEl.assignedNodes({flatten:!0}).filter(t=>{var e;return t.nodeType===Node.ELEMENT_NODE?!0:t.nodeType===Node.TEXT_NODE?!!((e=t.textContent)!=null&&e.trim()):!1}).length:0}_syncState(s=!1){const t=this._assignedCount(),e=t===0,i=this.getAttribute("name")||"",n=s||!this._initialized||t!==this._lastCount||i!==this._lastName;this._shellEl&&this._shellEl.setAttribute("data-empty",e?"true":"false"),n&&this.dispatchEvent(new CustomEvent("slotchange",{detail:{name:i,count:t,empty:e},bubbles:!0,composed:!0})),e&&this.hasAttribute("required")&&(!this._initialized||!this._lastEmpty)&&this.dispatchEvent(new CustomEvent("missing",{bubbles:!0,composed:!0})),!e&&(!this._initialized||this._lastEmpty)&&this.dispatchEvent(new CustomEvent("resolved",{bubbles:!0,composed:!0})),this._lastEmpty=e,this._lastCount=t,this._lastName=i,this._initialized=!0}_onSlotChange(){this._syncState()}render(){const s=(this.getAttribute("name")||"").trim(),t=this.getAttribute("fallback")||"",e=s?`<slot name="${o(s)}"></slot>`:"<slot></slot>";this.setContent(`
153
+ `;function o(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}class a extends r.ElementBase{constructor(){super(),this._slotEl=null,this._shellEl=null,this._lastEmpty=!0,this._lastCount=-1,this._lastName="",this._initialized=!1,this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["name","headless","inline","align","size","variant","tone","fallback","required"]}disconnectedCallback(){this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=null,this._shellEl=null,this._initialized=!1,this._lastCount=-1,this._lastName="",this._lastEmpty=!0,super.disconnectedCallback()}attributeChangedCallback(e,t,s){if(t!==s){if(e==="required"){this.isConnected&&this._syncState(!0);return}super.attributeChangedCallback(e,t,s)}}_assignedCount(){return this._slotEl?this._slotEl.assignedNodes({flatten:!0}).filter(t=>t.nodeType===Node.ELEMENT_NODE?!0:t.nodeType===Node.TEXT_NODE?!!t.textContent?.trim():!1).length:0}_syncState(e=!1){const t=this._assignedCount(),s=t===0,i=this.getAttribute("name")||"",n=e||!this._initialized||t!==this._lastCount||i!==this._lastName;this._shellEl&&this._shellEl.setAttribute("data-empty",s?"true":"false"),n&&this.dispatchEvent(new CustomEvent("slotchange",{detail:{name:i,count:t,empty:s},bubbles:!0,composed:!0})),s&&this.hasAttribute("required")&&(!this._initialized||!this._lastEmpty)&&this.dispatchEvent(new CustomEvent("missing",{bubbles:!0,composed:!0})),!s&&(!this._initialized||this._lastEmpty)&&this.dispatchEvent(new CustomEvent("resolved",{bubbles:!0,composed:!0})),this._lastEmpty=s,this._lastCount=t,this._lastName=i,this._initialized=!0}_onSlotChange(){this._syncState()}render(){const e=(this.getAttribute("name")||"").trim(),t=this.getAttribute("fallback")||"",s=e?`<slot name="${o(e)}"></slot>`:"<slot></slot>";this.setContent(`
154
154
  <style>${u}</style>
155
155
  <span class="shell" part="shell" data-empty="true">
156
- <span class="content" part="content">${e}</span>
156
+ <span class="content" part="content">${s}</span>
157
157
  <span class="fallback" part="fallback"><slot name="fallback">${o(t)}</slot></span>
158
158
  </span>
159
- `),this._shellEl=this.root.querySelector(".shell"),this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=this.root.querySelector('slot:not([name="fallback"])'),this._slotEl&&this._slotEl.addEventListener("slotchange",this._onSlotChange),this._syncState()}shouldRenderOnAttributeChange(s,t,e){return s==="name"||s==="fallback"}}typeof customElements<"u"&&!customElements.get("ui-slot")&&customElements.define("ui-slot",a);exports.UISlot=a;
159
+ `),this._shellEl=this.root.querySelector(".shell"),this._slotEl&&this._slotEl.removeEventListener("slotchange",this._onSlotChange),this._slotEl=this.root.querySelector('slot:not([name="fallback"])'),this._slotEl&&this._slotEl.addEventListener("slotchange",this._onSlotChange),this._syncState()}shouldRenderOnAttributeChange(e,t,s){return e==="name"||e==="fallback"}}typeof customElements<"u"&&!customElements.get("ui-slot")&&customElements.define("ui-slot",a);exports.UISlot=a;
package/dist/slot.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E as n } from "./ElementBase-909688f3.mjs";
1
+ import { E as n } from "./ElementBase-YlTLMsGk.mjs";
2
2
  const r = `
3
3
  :host {
4
4
  --ui-slot-bg: transparent;
@@ -175,50 +175,47 @@ class u extends n {
175
175
  disconnectedCallback() {
176
176
  this._slotEl && this._slotEl.removeEventListener("slotchange", this._onSlotChange), this._slotEl = null, this._shellEl = null, this._initialized = !1, this._lastCount = -1, this._lastName = "", this._lastEmpty = !0, super.disconnectedCallback();
177
177
  }
178
- attributeChangedCallback(s, t, e) {
179
- if (t !== e) {
180
- if (s === "required") {
178
+ attributeChangedCallback(e, t, s) {
179
+ if (t !== s) {
180
+ if (e === "required") {
181
181
  this.isConnected && this._syncState(!0);
182
182
  return;
183
183
  }
184
- super.attributeChangedCallback(s, t, e);
184
+ super.attributeChangedCallback(e, t, s);
185
185
  }
186
186
  }
187
187
  _assignedCount() {
188
- return this._slotEl ? this._slotEl.assignedNodes({ flatten: !0 }).filter((t) => {
189
- var e;
190
- return t.nodeType === Node.ELEMENT_NODE ? !0 : t.nodeType === Node.TEXT_NODE ? !!((e = t.textContent) != null && e.trim()) : !1;
191
- }).length : 0;
192
- }
193
- _syncState(s = !1) {
194
- const t = this._assignedCount(), e = t === 0, i = this.getAttribute("name") || "", a = s || !this._initialized || t !== this._lastCount || i !== this._lastName;
195
- this._shellEl && this._shellEl.setAttribute("data-empty", e ? "true" : "false"), a && this.dispatchEvent(
188
+ return this._slotEl ? this._slotEl.assignedNodes({ flatten: !0 }).filter((t) => t.nodeType === Node.ELEMENT_NODE ? !0 : t.nodeType === Node.TEXT_NODE ? !!t.textContent?.trim() : !1).length : 0;
189
+ }
190
+ _syncState(e = !1) {
191
+ const t = this._assignedCount(), s = t === 0, i = this.getAttribute("name") || "", a = e || !this._initialized || t !== this._lastCount || i !== this._lastName;
192
+ this._shellEl && this._shellEl.setAttribute("data-empty", s ? "true" : "false"), a && this.dispatchEvent(
196
193
  new CustomEvent("slotchange", {
197
194
  detail: {
198
195
  name: i,
199
196
  count: t,
200
- empty: e
197
+ empty: s
201
198
  },
202
199
  bubbles: !0,
203
200
  composed: !0
204
201
  })
205
- ), e && this.hasAttribute("required") && (!this._initialized || !this._lastEmpty) && this.dispatchEvent(new CustomEvent("missing", { bubbles: !0, composed: !0 })), !e && (!this._initialized || this._lastEmpty) && this.dispatchEvent(new CustomEvent("resolved", { bubbles: !0, composed: !0 })), this._lastEmpty = e, this._lastCount = t, this._lastName = i, this._initialized = !0;
202
+ ), s && this.hasAttribute("required") && (!this._initialized || !this._lastEmpty) && this.dispatchEvent(new CustomEvent("missing", { bubbles: !0, composed: !0 })), !s && (!this._initialized || this._lastEmpty) && this.dispatchEvent(new CustomEvent("resolved", { bubbles: !0, composed: !0 })), this._lastEmpty = s, this._lastCount = t, this._lastName = i, this._initialized = !0;
206
203
  }
207
204
  _onSlotChange() {
208
205
  this._syncState();
209
206
  }
210
207
  render() {
211
- const s = (this.getAttribute("name") || "").trim(), t = this.getAttribute("fallback") || "", e = s ? `<slot name="${o(s)}"></slot>` : "<slot></slot>";
208
+ const e = (this.getAttribute("name") || "").trim(), t = this.getAttribute("fallback") || "", s = e ? `<slot name="${o(e)}"></slot>` : "<slot></slot>";
212
209
  this.setContent(`
213
210
  <style>${r}</style>
214
211
  <span class="shell" part="shell" data-empty="true">
215
- <span class="content" part="content">${e}</span>
212
+ <span class="content" part="content">${s}</span>
216
213
  <span class="fallback" part="fallback"><slot name="fallback">${o(t)}</slot></span>
217
214
  </span>
218
215
  `), this._shellEl = this.root.querySelector(".shell"), this._slotEl && this._slotEl.removeEventListener("slotchange", this._onSlotChange), this._slotEl = this.root.querySelector('slot:not([name="fallback"])'), this._slotEl && this._slotEl.addEventListener("slotchange", this._onSlotChange), this._syncState();
219
216
  }
220
- shouldRenderOnAttributeChange(s, t, e) {
221
- return s === "name" || s === "fallback";
217
+ shouldRenderOnAttributeChange(e, t, s) {
218
+ return e === "name" || e === "fallback";
222
219
  }
223
220
  }
224
221
  typeof customElements < "u" && !customElements.get("ui-slot") && customElements.define("ui-slot", u);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const te=require("./ElementBase-1b301e7f.js"),re=1,ie=44,se=72,ne=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const te=require("./ElementBase-EV6mVBUV.js"),re=1,ie=44,se=72,oe=`
2
2
  :host {
3
3
  --ui-sortable-accent: var(--ui-color-primary, #2563eb);
4
4
  --ui-sortable-surface: var(--ui-color-surface, #ffffff);
@@ -720,93 +720,93 @@
720
720
  background: Highlight;
721
721
  }
722
722
  }
723
- `;function V(u){if(!u)return[];try{const e=JSON.parse(u);return Array.isArray(e)?e:[]}catch{return[]}}function I(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function z(u,e){return`${u}::${e??"__root__"}`}function X(u){return u?[u.listId,u.parentId??"",u.beforeId??"",u.mode].join("::"):""}function B(u,e){return X(u)===X(e)}function oe(u){if(!u||u==="none")return{x:1,y:1};const e=u.match(/^matrix3d\((.+)\)$/);if(e){const t=e[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===16&&t.every(i=>Number.isFinite(i)))return{x:t[0]||1,y:t[5]||1}}const r=u.match(/^matrix\((.+)\)$/);if(r){const t=r[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===6&&t.every(i=>Number.isFinite(i))){const[i,s,o,a]=t;return{x:Math.sqrt(i*i+s*s)||1,y:Math.sqrt(o*o+a*a)||1}}}return{x:1,y:1}}function ae(u){return u==="item"?"item":"handle"}function $(u){return{...u}}function de(u,e,r,t,i,s){const o=M(u),a=E(u),l=new Set,n=[],d=h=>{const x=o.get(h);!x||l.has(h)||(l.add(h),n.push(h),(a.get(z(x.listId,h))||[]).forEach(d))};t.forEach(d);const c=u.map($),g=c.filter(h=>l.has(h.id)),m=i?c.map($):c.filter(h=>!l.has(h.id)),f=i?g.map(h=>s(h,n)):g.map($),v=new Map,b=new Map;i&&g.forEach((h,x)=>{v.set(h.id,f[x].id),b.set(f[x].id,h.id)}),f.forEach(h=>{const x=i?b.get(h.id):h.id,F=x?o.get(x):null;F&&(i&&(h.parentId=F.parentId&&v.has(F.parentId)&&v.get(F.parentId)||null),h.listId=r.listId)});const y=t.map(h=>v.get(h)||h),w=[...m,...f],k=E(m),A=z(r.listId,r.parentId),_=[...k.get(A)||[]],R=r.beforeId?_.indexOf(r.beforeId):_.length,S=R>=0?R:_.length;_.splice(S,0,...y),k.set(A,_),E(f).forEach((h,x)=>{const[,F]=x.split("::");(F||"")!=="__root__"&&k.set(x,[...h])});const T=M(w);y.forEach(h=>{const x=T.get(h);x&&(x.parentId=r.parentId,x.listId=r.listId)});const P=[],L=new Set,G=(h,x)=>{(k.get(z(h,x))||[]).forEach((O,K)=>{const p=T.get(O);!p||L.has(O)||(L.add(O),p.listId=h,p.parentId=x,p.order=K,P.push(p),G(h,O))})};return e.forEach(h=>G(h.id,null)),w.forEach(h=>{L.has(h.id)||(h.parentId=null,P.push(h))}),{items:P.map($),insertedRootIds:y}}function E(u){const e=new Map;return u.forEach(r=>{const t=z(r.listId,r.parentId),i=e.get(t);i?i.push(r.id):e.set(t,[r.id])}),e}function M(u){return new Map(u.map(e=>[e.id,e]))}function Y(u){const e=new Set,r=[];return u.forEach((t,i)=>{const s=typeof(t==null?void 0:t.id)=="string"&&t.id.trim()?t.id.trim():`list-${i+1}`;e.has(s)||(e.add(s),r.push({id:s,label:typeof(t==null?void 0:t.label)=="string"&&t.label.trim()?t.label.trim():`List ${i+1}`,description:typeof(t==null?void 0:t.description)=="string"?t.description:"",emptyLabel:typeof(t==null?void 0:t.emptyLabel)=="string"&&t.emptyLabel.trim()?t.emptyLabel.trim():"Drop items here.",orientation:(t==null?void 0:t.orientation)==="horizontal"?"horizontal":"vertical",disabled:!!(t!=null&&t.disabled),cloneOnDrag:!!(t!=null&&t.cloneOnDrag),accepts:Array.isArray(t==null?void 0:t.accepts)?t.accepts.filter(o=>typeof o=="string"&&o.trim().length>0):void 0}))}),r.length?r:[{id:"default",label:"Items",description:"",emptyLabel:"Drop items here.",orientation:"vertical",disabled:!1,cloneOnDrag:!1}]}function U(u,e){const r=new Set(u.map(n=>n.id)),t=[];e.forEach((n,d)=>{const c=typeof(n==null?void 0:n.id)=="string"&&n.id.trim()?n.id.trim():"",g=typeof(n==null?void 0:n.label)=="string"&&n.label.trim()?n.label.trim():"";if(!c||!g)return;const m=typeof(n==null?void 0:n.listId)=="string"&&r.has(n.listId)?n.listId:u[0].id;t.push({id:c,label:g,listId:m,parentId:typeof(n==null?void 0:n.parentId)=="string"&&n.parentId.trim()?n.parentId.trim():null,description:typeof(n==null?void 0:n.description)=="string"?n.description:"",order:Number.isFinite(n==null?void 0:n.order)?Number(n.order):d,disabled:!!(n!=null&&n.disabled),dragDisabled:!!(n!=null&&n.dragDisabled),cloneOnDrag:!!(n!=null&&n.cloneOnDrag),hidden:!!(n!=null&&n.hidden)})});const i=new Map(t.map(n=>[n.id,n]));t.forEach(n=>{if(!n.parentId)return;const d=i.get(n.parentId);(!d||d.id===n.id||d.listId!==n.listId)&&(n.parentId=null)});const s=new Map;t.forEach(n=>{const d=z(n.listId,n.parentId),c=s.get(d);c?c.push(n):s.set(d,[n])}),s.forEach(n=>n.sort((d,c)=>d.order-c.order||d.label.localeCompare(c.label)));const o=[],a=new Set,l=(n,d)=>{(s.get(z(n,d))||[]).forEach((g,m)=>{a.has(g.id)||(a.add(g.id),g.order=m,o.push(g),l(n,g.id))})};return u.forEach(n=>l(n.id,null)),t.forEach(n=>{a.has(n.id)||(n.parentId=null,o.push(n))}),o.map($)}function le(u){return JSON.stringify(u.map(e=>({id:e.id,label:e.label,listId:e.listId,parentId:e.parentId,description:e.description,order:e.order,disabled:e.disabled,dragDisabled:e.dragDisabled,cloneOnDrag:e.cloneOnDrag,hidden:e.hidden})))}function ce(u){return JSON.stringify(u.map(e=>({id:e.id,label:e.label,description:e.description,emptyLabel:e.emptyLabel,orientation:e.orientation,disabled:e.disabled,cloneOnDrag:e.cloneOnDrag,accepts:e.accepts})))}function j(u){return JSON.stringify(u)}function J(u){const e=new Map,r=u.map(t=>{const i=z(t.listId,t.parentId),s=e.get(i)??0;return e.set(i,s+1),{id:t.id,listId:t.listId,parentId:t.parentId,index:s}});return{version:re,records:r}}function W(u,e){return e?`${u.label} ${u.description}`.toLowerCase().includes(e.toLowerCase()):!0}function Q(u,e,r,t,i){const s=M(u),o=E(u),a=new Map,l=(c,g)=>{const m=[...o.get(z(c,g))||[]];return i==="label"&&m.sort((f,v)=>{const b=s.get(f),y=s.get(v);return!b||!y?0:b.label.localeCompare(y.label)}),m},n=(c,g,m)=>{const f=[];return l(c,g).forEach(v=>{const b=s.get(v);if(!b||b.hidden)return;const y=n(c,b.id);!W(b,t)&&y.length===0||(f.push({id:b.id,disabled:b.disabled}),y.length&&f.push(...y))}),f};return Array.from(new Set(u.map(c=>c.listId))).forEach(c=>{a.set(c,n(c,null))}),a}class Z extends te.ElementBase{constructor(){super(),this._lists=Y([]),this._items=[],this._selection=[],this._focusedId=null,this._rangeAnchorId=null,this._dragState=null,this._liveMessage="Sortable list ready.",this._lastListsAttr=null,this._lastItemsAttr=null,this._lastSelectionAttr=null,this._hydratedPersistKey=null,this._cloneSeed=1,this._dragImage=null,this._dragPreviewOverlay=null,this._pendingFocusId=null,this._pointerGesture=null,this._pendingDropTarget=null,this._suppressAttributeRender=!1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onDragStart=this._onDragStart.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDrop=this._onDrop.bind(this),this._onDragEnd=this._onDragEnd.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerCancel=this._onPointerCancel.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this)}static get observedAttributes(){return["lists","items","selection","filter-query","sort","persist-key","allow-filtered-drag","allow-nesting","drop-indicator-visibility","dropzone-style","drag-preview-size","drag-handle-mode","drag-handle-selector","custom-item-rendering","show-selection-badge","disabled"]}shouldRenderOnAttributeChange(e,r,t){return this._suppressAttributeRender?!["lists","items","selection"].includes(e):!0}attributeChangedCallback(e,r,t){if(r!==t&&this.isConnected){if(e==="selection"&&!this._suppressAttributeRender&&this._canSyncInteractiveStateInPlace()){this._syncSelectionFromAttribute(t??null),this._syncSelectionVisualState();return}if(e==="show-selection-badge"&&this._canSyncInteractiveStateInPlace()){this._syncSelectionVisualState();return}super.attributeChangedCallback(e,r,t)}}connectedCallback(){var e,r,t,i;super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("dragstart",this._onDragStart),this.root.addEventListener("dragover",this._onDragOver),this.root.addEventListener("drop",this._onDrop),this.root.addEventListener("dragend",this._onDragEnd),this.root.addEventListener("pointerdown",this._onPointerDown),this.root.addEventListener("focusin",this._onFocusIn),(e=this.ownerDocument)==null||e.addEventListener("keydown",this._onDocumentKeyDown,!0),(r=this.ownerDocument)==null||r.addEventListener("pointermove",this._onPointerMove,!0),(t=this.ownerDocument)==null||t.addEventListener("pointerup",this._onPointerUp,!0),(i=this.ownerDocument)==null||i.addEventListener("pointercancel",this._onPointerCancel,!0)}disconnectedCallback(){var e,r,t,i;this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("dragstart",this._onDragStart),this.root.removeEventListener("dragover",this._onDragOver),this.root.removeEventListener("drop",this._onDrop),this.root.removeEventListener("dragend",this._onDragEnd),this.root.removeEventListener("pointerdown",this._onPointerDown),this.root.removeEventListener("focusin",this._onFocusIn),(e=this.ownerDocument)==null||e.removeEventListener("keydown",this._onDocumentKeyDown,!0),(r=this.ownerDocument)==null||r.removeEventListener("pointermove",this._onPointerMove,!0),(t=this.ownerDocument)==null||t.removeEventListener("pointerup",this._onPointerUp,!0),(i=this.ownerDocument)==null||i.removeEventListener("pointercancel",this._onPointerCancel,!0),this._removeDragPreviewOverlay(),this._removeDragImage(),super.disconnectedCallback()}get lists(){return this._lists.map(e=>({...e}))}set lists(e){this.setAttribute("lists",JSON.stringify(e??[]))}get items(){return this._items.map(e=>({...e}))}set items(e){this.setAttribute("items",JSON.stringify(e??[]))}get selection(){return[...this._selection]}set selection(e){this.setAttribute("selection",JSON.stringify(e??[]))}get sort(){return this.getAttribute("sort")==="label"?"label":"manual"}set sort(e){!e||e==="manual"?this.removeAttribute("sort"):this.setAttribute("sort",e)}get filterQuery(){return this.getAttribute("filter-query")||""}set filterQuery(e){e?this.setAttribute("filter-query",e):this.removeAttribute("filter-query")}select(e){this._setSelection(e,"api")}clearSelection(){this._setSelection([],"api")}cancelDrag(){this._cancelDrag(!0)}focusItem(e){this._items.some(r=>r.id===e)&&(this._focusedId=e,this._pendingFocusId=e,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender())}moveSelection(e){this._syncSelectionFromAttribute(this.getAttribute("selection"));const r=this._selectedRootIds();r.length&&this._commitMove({listId:e.targetListId,parentId:e.parentId??null,beforeId:e.beforeId??null,mode:e.mode??(e.parentId?"inside":"before")},r,!!e.clone,e.source??"api")}getPersistenceSnapshot(){return J(this._items)}render(){var _,R;this._syncStateFromAttributes();const e=this._measureItemShellRects(),r=new Set(this._draggingIds()),t=new Set(this._selection),s=!!((_=this._dragState)!=null&&_.keyboard)?this._projectedMoveResult():null,o=(s==null?void 0:s.items)||this._items,a=new Set((s==null?void 0:s.insertedRootIds)||[]),l=!!this._dragState&&!this._dragState.keyboard&&!!this._dragState.dropTarget,n=Q(o,t,r,this.filterQuery,this.sort),d=this._resolvedFocusedId(n),c=this._isDragLocked(),g=this._selection.length,m=this.getAttribute("allow-nesting")!=="false",f=this.getAttribute("drop-indicator-visibility")==="always"?"always":"active",v=this._dropzoneStyle(),b=this.getAttribute("show-selection-badge")!=="false",y=this._dragHandleMode(),w=this._usesCustomHandleSelector(),k=c?this.sort==="label"?"Dragging is paused while alphabetical sorting is active.":this.filterQuery&&!this.hasAttribute("allow-filtered-drag")?"Dragging is paused while the list is filtered.":"Dragging is currently disabled.":(R=this._dragState)!=null&&R.keyboard?"Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel.":y==="item"?"Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering.":w?"Use your custom drag handle element, or press Space on a focused item to start keyboard reordering.":"Use the handle to drag, or press Space on a focused item to start keyboard reordering.",A=`
724
- <style>${ne}</style>
723
+ `;function V(l){if(!l)return[];try{const e=JSON.parse(l);return Array.isArray(e)?e:[]}catch{return[]}}function I(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(l,e){return`${l}::${e??"__root__"}`}function j(l){return l?[l.listId,l.parentId??"",l.beforeId??"",l.mode].join("::"):""}function B(l,e){return j(l)===j(e)}function ne(l){if(!l||l==="none")return{x:1,y:1};const e=l.match(/^matrix3d\((.+)\)$/);if(e){const t=e[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===16&&t.every(i=>Number.isFinite(i)))return{x:t[0]||1,y:t[5]||1}}const r=l.match(/^matrix\((.+)\)$/);if(r){const t=r[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===6&&t.every(i=>Number.isFinite(i))){const[i,s,a,n]=t;return{x:Math.sqrt(i*i+s*s)||1,y:Math.sqrt(a*a+n*n)||1}}}return{x:1,y:1}}function ae(l){return l==="item"?"item":"handle"}function A(l){return{...l}}function de(l,e,r,t,i,s){const a=$(l),n=P(l),d=new Set,o=[],u=g=>{const S=a.get(g);!S||d.has(g)||(d.add(g),o.push(g),(n.get(D(S.listId,g))||[]).forEach(u))};t.forEach(u);const p=l.map(A),m=p.filter(g=>d.has(g.id)),_=i?p.map(A):p.filter(g=>!d.has(g.id)),f=i?m.map(g=>s(g,o)):m.map(A),v=new Map,b=new Map;i&&m.forEach((g,S)=>{v.set(g.id,f[S].id),b.set(f[S].id,g.id)}),f.forEach(g=>{const S=i?b.get(g.id):g.id,T=S?a.get(S):null;T&&(i&&(g.parentId=T.parentId&&v.has(T.parentId)&&v.get(T.parentId)||null),g.listId=r.listId)});const y=t.map(g=>v.get(g)||g),x=[..._,...f],z=P(_),k=D(r.listId,r.parentId),h=[...z.get(k)||[]],E=r.beforeId?h.indexOf(r.beforeId):h.length,H=E>=0?E:h.length;h.splice(H,0,...y),z.set(k,h),P(f).forEach((g,S)=>{const[,T]=S.split("::");(T||"")!=="__root__"&&z.set(S,[...g])});const F=$(x);y.forEach(g=>{const S=F.get(g);S&&(S.parentId=r.parentId,S.listId=r.listId)});const M=[],O=new Set,q=(g,S)=>{(z.get(D(g,S))||[]).forEach((R,K)=>{const c=F.get(R);!c||O.has(R)||(O.add(R),c.listId=g,c.parentId=S,c.order=K,M.push(c),q(g,R))})};return e.forEach(g=>q(g.id,null)),x.forEach(g=>{O.has(g.id)||(g.parentId=null,M.push(g))}),{items:M.map(A),insertedRootIds:y}}function P(l){const e=new Map;return l.forEach(r=>{const t=D(r.listId,r.parentId),i=e.get(t);i?i.push(r.id):e.set(t,[r.id])}),e}function $(l){return new Map(l.map(e=>[e.id,e]))}function X(l){const e=new Set,r=[];return l.forEach((t,i)=>{const s=typeof t?.id=="string"&&t.id.trim()?t.id.trim():`list-${i+1}`;e.has(s)||(e.add(s),r.push({id:s,label:typeof t?.label=="string"&&t.label.trim()?t.label.trim():`List ${i+1}`,description:typeof t?.description=="string"?t.description:"",emptyLabel:typeof t?.emptyLabel=="string"&&t.emptyLabel.trim()?t.emptyLabel.trim():"Drop items here.",orientation:t?.orientation==="horizontal"?"horizontal":"vertical",disabled:!!t?.disabled,cloneOnDrag:!!t?.cloneOnDrag,accepts:Array.isArray(t?.accepts)?t.accepts.filter(a=>typeof a=="string"&&a.trim().length>0):void 0}))}),r.length?r:[{id:"default",label:"Items",description:"",emptyLabel:"Drop items here.",orientation:"vertical",disabled:!1,cloneOnDrag:!1}]}function Y(l,e){const r=new Set(l.map(o=>o.id)),t=[];e.forEach((o,u)=>{const p=typeof o?.id=="string"&&o.id.trim()?o.id.trim():"",m=typeof o?.label=="string"&&o.label.trim()?o.label.trim():"";if(!p||!m)return;const _=typeof o?.listId=="string"&&r.has(o.listId)?o.listId:l[0].id;t.push({id:p,label:m,listId:_,parentId:typeof o?.parentId=="string"&&o.parentId.trim()?o.parentId.trim():null,description:typeof o?.description=="string"?o.description:"",order:Number.isFinite(o?.order)?Number(o.order):u,disabled:!!o?.disabled,dragDisabled:!!o?.dragDisabled,cloneOnDrag:!!o?.cloneOnDrag,hidden:!!o?.hidden})});const i=new Map(t.map(o=>[o.id,o]));t.forEach(o=>{if(!o.parentId)return;const u=i.get(o.parentId);(!u||u.id===o.id||u.listId!==o.listId)&&(o.parentId=null)});const s=new Map;t.forEach(o=>{const u=D(o.listId,o.parentId),p=s.get(u);p?p.push(o):s.set(u,[o])}),s.forEach(o=>o.sort((u,p)=>u.order-p.order||u.label.localeCompare(p.label)));const a=[],n=new Set,d=(o,u)=>{(s.get(D(o,u))||[]).forEach((m,_)=>{n.has(m.id)||(n.add(m.id),m.order=_,a.push(m),d(o,m.id))})};return l.forEach(o=>d(o.id,null)),t.forEach(o=>{n.has(o.id)||(o.parentId=null,a.push(o))}),a.map(A)}function le(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,listId:e.listId,parentId:e.parentId,description:e.description,order:e.order,disabled:e.disabled,dragDisabled:e.dragDisabled,cloneOnDrag:e.cloneOnDrag,hidden:e.hidden})))}function ce(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,description:e.description,emptyLabel:e.emptyLabel,orientation:e.orientation,disabled:e.disabled,cloneOnDrag:e.cloneOnDrag,accepts:e.accepts})))}function U(l){return JSON.stringify(l)}function J(l){const e=new Map,r=l.map(t=>{const i=D(t.listId,t.parentId),s=e.get(i)??0;return e.set(i,s+1),{id:t.id,listId:t.listId,parentId:t.parentId,index:s}});return{version:re,records:r}}function W(l,e){return e?`${l.label} ${l.description}`.toLowerCase().includes(e.toLowerCase()):!0}function Q(l,e,r,t,i){const s=$(l),a=P(l),n=new Map,d=(p,m)=>{const _=[...a.get(D(p,m))||[]];return i==="label"&&_.sort((f,v)=>{const b=s.get(f),y=s.get(v);return!b||!y?0:b.label.localeCompare(y.label)}),_},o=(p,m,_)=>{const f=[];return d(p,m).forEach(v=>{const b=s.get(v);if(!b||b.hidden)return;const y=o(p,b.id);!W(b,t)&&y.length===0||(f.push({id:b.id,disabled:b.disabled}),y.length&&f.push(...y))}),f};return Array.from(new Set(l.map(p=>p.listId))).forEach(p=>{n.set(p,o(p,null))}),n}class Z extends te.ElementBase{constructor(){super(),this._lists=X([]),this._items=[],this._selection=[],this._focusedId=null,this._rangeAnchorId=null,this._dragState=null,this._liveMessage="Sortable list ready.",this._lastListsAttr=null,this._lastItemsAttr=null,this._lastSelectionAttr=null,this._hydratedPersistKey=null,this._cloneSeed=1,this._dragImage=null,this._dragPreviewOverlay=null,this._pendingFocusId=null,this._pointerGesture=null,this._pendingDropTarget=null,this._suppressAttributeRender=!1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onDragStart=this._onDragStart.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDrop=this._onDrop.bind(this),this._onDragEnd=this._onDragEnd.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerCancel=this._onPointerCancel.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this)}static get observedAttributes(){return["lists","items","selection","filter-query","sort","persist-key","allow-filtered-drag","allow-nesting","drop-indicator-visibility","dropzone-style","drag-preview-size","drag-handle-mode","drag-handle-selector","custom-item-rendering","show-selection-badge","disabled"]}shouldRenderOnAttributeChange(e,r,t){return this._suppressAttributeRender?!["lists","items","selection"].includes(e):!0}attributeChangedCallback(e,r,t){if(r!==t&&this.isConnected){if(e==="selection"&&!this._suppressAttributeRender&&this._canSyncInteractiveStateInPlace()){this._syncSelectionFromAttribute(t??null),this._syncSelectionVisualState();return}if(e==="show-selection-badge"&&this._canSyncInteractiveStateInPlace()){this._syncSelectionVisualState();return}super.attributeChangedCallback(e,r,t)}}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("dragstart",this._onDragStart),this.root.addEventListener("dragover",this._onDragOver),this.root.addEventListener("drop",this._onDrop),this.root.addEventListener("dragend",this._onDragEnd),this.root.addEventListener("pointerdown",this._onPointerDown),this.root.addEventListener("focusin",this._onFocusIn),this.ownerDocument?.addEventListener("keydown",this._onDocumentKeyDown,!0),this.ownerDocument?.addEventListener("pointermove",this._onPointerMove,!0),this.ownerDocument?.addEventListener("pointerup",this._onPointerUp,!0),this.ownerDocument?.addEventListener("pointercancel",this._onPointerCancel,!0)}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("dragstart",this._onDragStart),this.root.removeEventListener("dragover",this._onDragOver),this.root.removeEventListener("drop",this._onDrop),this.root.removeEventListener("dragend",this._onDragEnd),this.root.removeEventListener("pointerdown",this._onPointerDown),this.root.removeEventListener("focusin",this._onFocusIn),this.ownerDocument?.removeEventListener("keydown",this._onDocumentKeyDown,!0),this.ownerDocument?.removeEventListener("pointermove",this._onPointerMove,!0),this.ownerDocument?.removeEventListener("pointerup",this._onPointerUp,!0),this.ownerDocument?.removeEventListener("pointercancel",this._onPointerCancel,!0),this._removeDragPreviewOverlay(),this._removeDragImage(),super.disconnectedCallback()}get lists(){return this._lists.map(e=>({...e}))}set lists(e){this.setAttribute("lists",JSON.stringify(e??[]))}get items(){return this._items.map(e=>({...e}))}set items(e){this.setAttribute("items",JSON.stringify(e??[]))}get selection(){return[...this._selection]}set selection(e){this.setAttribute("selection",JSON.stringify(e??[]))}get sort(){return this.getAttribute("sort")==="label"?"label":"manual"}set sort(e){!e||e==="manual"?this.removeAttribute("sort"):this.setAttribute("sort",e)}get filterQuery(){return this.getAttribute("filter-query")||""}set filterQuery(e){e?this.setAttribute("filter-query",e):this.removeAttribute("filter-query")}select(e){this._setSelection(e,"api")}clearSelection(){this._setSelection([],"api")}cancelDrag(){this._cancelDrag(!0)}focusItem(e){this._items.some(r=>r.id===e)&&(this._focusedId=e,this._pendingFocusId=e,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender())}moveSelection(e){this._syncSelectionFromAttribute(this.getAttribute("selection"));const r=this._selectedRootIds();r.length&&this._commitMove({listId:e.targetListId,parentId:e.parentId??null,beforeId:e.beforeId??null,mode:e.mode??(e.parentId?"inside":"before")},r,!!e.clone,e.source??"api")}getPersistenceSnapshot(){return J(this._items)}render(){this._syncStateFromAttributes();const e=this._measureItemShellRects(),r=new Set(this._draggingIds()),t=new Set(this._selection),s=!!this._dragState?.keyboard?this._projectedMoveResult():null,a=s?.items||this._items,n=new Set(s?.insertedRootIds||[]),d=!!this._dragState&&!this._dragState.keyboard&&!!this._dragState.dropTarget,o=Q(a,t,r,this.filterQuery,this.sort),u=this._resolvedFocusedId(o),p=this._isDragLocked(),m=this._selection.length,_=this.getAttribute("allow-nesting")!=="false",f=this.getAttribute("drop-indicator-visibility")==="always"?"always":"active",v=this._dropzoneStyle(),b=this.getAttribute("show-selection-badge")!=="false",y=this._dragHandleMode(),x=this._usesCustomHandleSelector(),z=p?this.sort==="label"?"Dragging is paused while alphabetical sorting is active.":this.filterQuery&&!this.hasAttribute("allow-filtered-drag")?"Dragging is paused while the list is filtered.":"Dragging is currently disabled.":this._dragState?.keyboard?"Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel.":y==="item"?"Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering.":x?"Use your custom drag handle element, or press Space on a focused item to start keyboard reordering.":"Use the handle to drag, or press Space on a focused item to start keyboard reordering.",k=`
724
+ <style>${oe}</style>
725
725
  <div
726
726
  class="root"
727
727
  part="root"
728
- data-drag-locked="${c}"
729
- data-drag-preview="${a.size||l?"true":"false"}"
728
+ data-drag-locked="${p}"
729
+ data-drag-preview="${n.size||d?"true":"false"}"
730
730
  data-drop-indicator-visibility="${f}"
731
731
  data-dropzone-style="${v}"
732
732
  >
733
733
  <div class="toolbar" part="toolbar">
734
- <div class="helper">${I(k)}</div>
734
+ <div class="helper">${I(z)}</div>
735
735
  <div class="helper selection-summary">
736
- <span class="selection-pill" part="selection-count">${g}</span>
737
- <span class="selection-text">${g===1?"item selected":"items selected"}</span>
736
+ <span class="selection-pill" part="selection-count">${m}</span>
737
+ <span class="selection-text">${m===1?"item selected":"items selected"}</span>
738
738
  </div>
739
739
  </div>
740
740
  <div class="lists" part="lists">
741
- ${this._lists.map(S=>{var L;const C=n.get(S.id)||[],T=C.length?this._renderListTree(o,S,d,r,m,a,b):"",P=S.disabled?"This list is read-only.":S.cloneOnDrag?"Dragging from this list creates a copy.":(L=S.accepts)!=null&&L.length?`Accepts drops from: ${S.accepts.join(", ")}`:"";return`
741
+ ${this._lists.map(h=>{const E=o.get(h.id)||[],H=E.length?this._renderListTree(a,h,u,r,_,n,b):"",L=h.disabled?"This list is read-only.":h.cloneOnDrag?"Dragging from this list creates a copy.":h.accepts?.length?`Accepts drops from: ${h.accepts.join(", ")}`:"";return`
742
742
  <section
743
743
  class="list"
744
744
  part="list"
745
- data-list-id="${I(S.id)}"
746
- data-orientation="${S.orientation}"
747
- data-disabled="${S.disabled}"
748
- aria-label="${I(S.label)}"
745
+ data-list-id="${I(h.id)}"
746
+ data-orientation="${h.orientation}"
747
+ data-disabled="${h.disabled}"
748
+ aria-label="${I(h.label)}"
749
749
  >
750
750
  <header class="list-header">
751
- <div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(S.id)}"></div>
751
+ <div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(h.id)}"></div>
752
752
  <div class="list-default-header">
753
753
  <div class="list-topline">
754
- <div class="list-label">${I(S.label)}</div>
755
- <span class="list-count">${C.length}</span>
754
+ <div class="list-label">${I(h.label)}</div>
755
+ <span class="list-count">${E.length}</span>
756
756
  </div>
757
- ${S.description?`<div class="list-description">${I(S.description)}</div>`:""}
758
- ${P?`<div class="list-helper">${I(P)}</div>`:""}
757
+ ${h.description?`<div class="list-description">${I(h.description)}</div>`:""}
758
+ ${L?`<div class="list-helper">${I(L)}</div>`:""}
759
759
  </div>
760
760
  </header>
761
761
  <div class="items" role="listbox" aria-multiselectable="true">
762
- ${T||`<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${I(S.id)}"></div><div class="empty">${I(S.emptyLabel)}</div>${this._renderDropzone({listId:S.id,parentId:null,beforeId:null,mode:"before"},"Drop here")}`}
762
+ ${H||`<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${I(h.id)}"></div><div class="empty">${I(h.emptyLabel)}</div>${this._renderDropzone({listId:h.id,parentId:null,beforeId:null,mode:"before"},"Drop here")}`}
763
763
  </div>
764
764
  </section>
765
765
  `}).join("")}
766
766
  </div>
767
767
  <div class="sr-only" aria-live="polite" aria-atomic="true">${I(this._liveMessage)}</div>
768
768
  </div>
769
- `;this.setContent(A),queueMicrotask(()=>{this._restorePendingFocus(),this._applyCurrentDropTargetVisualState(),this._applyLiveMessage(),this._updatePointerDragPreview(),this._animateItemShellReflow(e)})}_syncStateFromAttributes(){var i;const e=this.getAttribute("lists");e!==this._lastListsAttr&&(this._lastListsAttr=e,this._lists=Y(V(e)));const r=this.getAttribute("items");if(r!==this._lastItemsAttr){this._lastItemsAttr=r,this._items=U(this._lists,V(r));const s=this.getAttribute("persist-key");s&&this._hydratedPersistKey!==s&&(this._items=this._restorePersistedItems(s,this._items),this._hydratedPersistKey=s)}const t=this.getAttribute("selection");t!==this._lastSelectionAttr&&this._syncSelectionFromAttribute(t),this._focusedId||(this._focusedId=((i=this._items.find(s=>!s.hidden))==null?void 0:i.id)||null)}_restorePersistedItems(e,r){try{const t=window.localStorage.getItem(e);if(!t)return r;const i=JSON.parse(t);if(!i||typeof i!="object"||!Array.isArray(i.records))return r;const s=new Map(i.records.map(a=>[a.id,a])),o=r.map((a,l)=>{const n=s.get(a.id);return n?{...a,listId:this._lists.some(d=>d.id===n.listId)?n.listId:a.listId,parentId:typeof n.parentId=="string"?n.parentId:null,order:Number.isFinite(n.index)?n.index:l}:{...a,order:l}});return U(this._lists,o)}catch{return r}}_resolvedFocusedId(e){const r=new Set(Array.from(e.values()).flat().map(i=>i.id));if(this._focusedId&&r.has(this._focusedId))return this._focusedId;const t=Array.from(e.values()).flat().find(i=>!i.disabled);return(t==null?void 0:t.id)||null}_restorePendingFocus(){const e=this._pendingFocusId||this._focusedId;if(!e)return;const r=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"'),t=this.root.querySelector(`.item[data-id="${r}"]`);t&&(document.activeElement!==t&&t.focus({preventScroll:!0}),this._pendingFocusId=null)}_escapeSelectorValue(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}_findDropzone(e){const r=this._escapeSelectorValue(e.listId),t=this._escapeSelectorValue(e.parentId??""),i=this._escapeSelectorValue(e.beforeId??""),s=this._escapeSelectorValue(e.mode);return this.root.querySelector(`.dropzone[data-list-id="${r}"][data-parent-id="${t}"][data-before-id="${i}"][data-mode="${s}"]`)}_findItemElement(e){const r=this._escapeSelectorValue(e);return this.root.querySelector(`.item[data-id="${r}"]`)}_dragHandleMode(){return ae(this.getAttribute("drag-handle-mode"))}_dropzoneStyle(){return this.getAttribute("dropzone-style")==="container"?"container":"indicator"}_usesCustomHandleSelector(){var e;return!!((e=this.getAttribute("drag-handle-selector"))!=null&&e.trim())}_dragActivatorFromPath(e){var o;const r=e.find(a=>a instanceof HTMLElement&&!!a.getAttribute("data-drag-trigger"));if(!r)return null;const t=r.getAttribute("data-drag-trigger"),i=t==="item"?"item":t==="custom"?"custom":"handle",s=r.getAttribute("data-id")||((o=r.closest(".item[data-id]"))==null?void 0:o.getAttribute("data-id"));return s?{element:r,id:s,kind:i}:null}_setDropTargetVisualState(e,r){var i;if(!e)return;const t=this._findDropzone(e);t&&(t.setAttribute("data-active",r?"true":"false"),r?this._syncDropzoneContainerSize(t,e):this._clearDropzoneContainerSize(t)),e.mode==="inside"&&e.parentId&&((i=this._findItemElement(e.parentId))==null||i.setAttribute("data-drop-inside-active",r?"true":"false"))}_applyCurrentDropTargetVisualState(e){var r;this._setDropTargetVisualState(e??null,!1),this._setDropTargetVisualState(((r=this._dragState)==null?void 0:r.dropTarget)??null,!0)}_applyLiveMessage(){const e=this.root.querySelector(".sr-only[aria-live]");e&&(e.textContent=this._liveMessage)}_canSyncInteractiveStateInPlace(){return!!this.root.querySelector(".root")&&!this._dragState}_applyInteractiveStateInPlace(e){return this._canSyncInteractiveStateInPlace()?(this._syncSelectionVisualState(),e!=null&&e.restoreFocus&&this._restorePendingFocus(),this._applyLiveMessage(),!0):!1}_hasCustomItemRendering(){return this.hasAttribute("custom-item-rendering")}_syncSelectionFromAttribute(e){this._lastSelectionAttr=e;const r=new Set(this._items.map(t=>t.id));this._selection=V(e).filter(t=>r.has(t)),!this._selection.length&&this._focusedId&&!r.has(this._focusedId)&&(this._focusedId=null)}_syncSelectionVisualState(){const e=new Set(this._selection),r=this.getAttribute("show-selection-badge")!=="false";this.root.querySelectorAll(".item[data-id]").forEach(s=>{const o=s.getAttribute("data-id");if(!o)return;const a=e.has(o),l=this._focusedId===o;s.setAttribute("data-selected",a?"true":"false"),s.setAttribute("aria-selected",a?"true":"false"),s.setAttribute("data-focused",l?"true":"false"),s.setAttribute("tabindex",l?"0":"-1");const n=s.querySelector('[data-selection-badge="true"]');if(n){const d=a&&r;n.hidden=!d,n.textContent=d?"Selected":""}});const t=this.root.querySelector(".selection-pill");t&&(t.textContent=String(this._selection.length));const i=this.root.querySelector(".selection-text");i&&(i.textContent=this._selection.length===1?"item selected":"items selected")}_clearDropzoneContainerSize(e){e.style.removeProperty("--ui-sortable-dropzone-match-block-size"),e.style.removeProperty("--ui-sortable-dropzone-match-inline-size")}_dropzoneReferenceElement(e,r){if(e.mode==="inside"&&e.parentId)return this._findItemElement(e.parentId);let t=r.nextElementSibling;for(;t;){if(t instanceof HTMLElement&&t.classList.contains("item-shell"))return t.querySelector(".item[data-id]");t=t.nextElementSibling}let i=r.previousElementSibling;for(;i;){if(i instanceof HTMLElement&&i.classList.contains("item-shell"))return i.querySelector(".item[data-id]");i=i.previousElementSibling}const s=this._escapeSelectorValue(e.listId),o=this.root.querySelector(`.list[data-list-id="${s}"] .items`),a=o==null?void 0:o.querySelector(".item[data-id]");return a||o||null}_syncDropzoneContainerSize(e,r){if(this._clearDropzoneContainerSize(e),this._dropzoneStyle()!=="container")return;const t=this._dropzoneReferenceElement(r,e);if(!t)return;const i=t.getBoundingClientRect();e.style.setProperty("--ui-sortable-dropzone-match-block-size",`${Math.max(76,Math.round(i.height))}px`),e.style.setProperty("--ui-sortable-dropzone-match-inline-size",`${Math.max(180,Math.round(i.width))}px`)}_ensureDragPreviewOverlay(){if(this._dragPreviewOverlay&&this._dragPreviewOverlay.isConnected)return this._dragPreviewOverlay;const e=document.createElement("div");return e.className="drag-preview-overlay",e.setAttribute("data-visible","false"),this.root.appendChild(e),this._dragPreviewOverlay=e,e}_clearPointerDragPreview(){var r,t,i,s;(r=this._dragPreviewOverlay)==null||r.setAttribute("data-visible","false"),(t=this._dragPreviewOverlay)==null||t.style.setProperty("left","-9999px"),(i=this._dragPreviewOverlay)==null||i.style.setProperty("top","-9999px");const e=this.root.querySelector(".root");e&&!((s=this._dragState)!=null&&s.keyboard)&&e.setAttribute("data-drag-preview","false")}_pointerPreviewContent(){if(!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=this._items.find(t=>t.id===e);return r?{kicker:this._dragState.clone?"Copy preview":"Drop preview",title:this._dragState.clone?`${r.label} copy`:r.label,description:this._dragState.clone?"Release to add a copy here.":this._dragState.movedRootIds.length>1?"Release to place this selection here.":"Release to place this item here."}:null}_pointerPreviewSize(){if(this.getAttribute("drag-preview-size")==="compact"||!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=e?this._findItemElement(e):null;if(!r)return null;const t=window.getComputedStyle(r),i=oe(t.transform);return{width:r.offsetWidth*i.x,height:r.offsetHeight*i.y}}_updatePointerDragPreview(){if(!this._dragState||this._dragState.keyboard){this._clearPointerDragPreview();return}const e=this._pointerPreviewContent();if(!e){this._clearPointerDragPreview();return}const r=this.root.querySelector(".root"),t=this._dragPreviewOverlay,i=(t==null?void 0:t.getAttribute("data-visible"))==="true",s=this._pointerPreviewSize();if(!this._dragState.dropTarget){i&&r&&r.setAttribute("data-drag-preview","true");return}const o=this._findDropzone(this._dragState.dropTarget);if(!o){i&&r&&r.setAttribute("data-drag-preview","true");return}const a=this._ensureDragPreviewOverlay();a.innerHTML=`
769
+ `;this.setContent(k),queueMicrotask(()=>{this._restorePendingFocus(),this._applyCurrentDropTargetVisualState(),this._applyLiveMessage(),this._updatePointerDragPreview(),this._animateItemShellReflow(e)})}_syncStateFromAttributes(){const e=this.getAttribute("lists");e!==this._lastListsAttr&&(this._lastListsAttr=e,this._lists=X(V(e)));const r=this.getAttribute("items");if(r!==this._lastItemsAttr){this._lastItemsAttr=r,this._items=Y(this._lists,V(r));const i=this.getAttribute("persist-key");i&&this._hydratedPersistKey!==i&&(this._items=this._restorePersistedItems(i,this._items),this._hydratedPersistKey=i)}const t=this.getAttribute("selection");t!==this._lastSelectionAttr&&this._syncSelectionFromAttribute(t),this._focusedId||(this._focusedId=this._items.find(i=>!i.hidden)?.id||null)}_restorePersistedItems(e,r){try{const t=window.localStorage.getItem(e);if(!t)return r;const i=JSON.parse(t);if(!i||typeof i!="object"||!Array.isArray(i.records))return r;const s=new Map(i.records.map(n=>[n.id,n])),a=r.map((n,d)=>{const o=s.get(n.id);return o?{...n,listId:this._lists.some(u=>u.id===o.listId)?o.listId:n.listId,parentId:typeof o.parentId=="string"?o.parentId:null,order:Number.isFinite(o.index)?o.index:d}:{...n,order:d}});return Y(this._lists,a)}catch{return r}}_resolvedFocusedId(e){const r=new Set(Array.from(e.values()).flat().map(i=>i.id));return this._focusedId&&r.has(this._focusedId)?this._focusedId:Array.from(e.values()).flat().find(i=>!i.disabled)?.id||null}_restorePendingFocus(){const e=this._pendingFocusId||this._focusedId;if(!e)return;const r=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"'),t=this.root.querySelector(`.item[data-id="${r}"]`);t&&(document.activeElement!==t&&t.focus({preventScroll:!0}),this._pendingFocusId=null)}_escapeSelectorValue(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}_findDropzone(e){const r=this._escapeSelectorValue(e.listId),t=this._escapeSelectorValue(e.parentId??""),i=this._escapeSelectorValue(e.beforeId??""),s=this._escapeSelectorValue(e.mode);return this.root.querySelector(`.dropzone[data-list-id="${r}"][data-parent-id="${t}"][data-before-id="${i}"][data-mode="${s}"]`)}_findItemElement(e){const r=this._escapeSelectorValue(e);return this.root.querySelector(`.item[data-id="${r}"]`)}_dragHandleMode(){return ae(this.getAttribute("drag-handle-mode"))}_dropzoneStyle(){return this.getAttribute("dropzone-style")==="container"?"container":"indicator"}_usesCustomHandleSelector(){return!!this.getAttribute("drag-handle-selector")?.trim()}_dragActivatorFromPath(e){const r=e.find(a=>a instanceof HTMLElement&&!!a.getAttribute("data-drag-trigger"));if(!r)return null;const t=r.getAttribute("data-drag-trigger"),i=t==="item"?"item":t==="custom"?"custom":"handle",s=r.getAttribute("data-id")||r.closest(".item[data-id]")?.getAttribute("data-id");return s?{element:r,id:s,kind:i}:null}_setDropTargetVisualState(e,r){if(!e)return;const t=this._findDropzone(e);t&&(t.setAttribute("data-active",r?"true":"false"),r?this._syncDropzoneContainerSize(t,e):this._clearDropzoneContainerSize(t)),e.mode==="inside"&&e.parentId&&this._findItemElement(e.parentId)?.setAttribute("data-drop-inside-active",r?"true":"false")}_applyCurrentDropTargetVisualState(e){this._setDropTargetVisualState(e??null,!1),this._setDropTargetVisualState(this._dragState?.dropTarget??null,!0)}_applyLiveMessage(){const e=this.root.querySelector(".sr-only[aria-live]");e&&(e.textContent=this._liveMessage)}_canSyncInteractiveStateInPlace(){return!!this.root.querySelector(".root")&&!this._dragState}_applyInteractiveStateInPlace(e){return this._canSyncInteractiveStateInPlace()?(this._syncSelectionVisualState(),e?.restoreFocus&&this._restorePendingFocus(),this._applyLiveMessage(),!0):!1}_hasCustomItemRendering(){return this.hasAttribute("custom-item-rendering")}_syncSelectionFromAttribute(e){this._lastSelectionAttr=e;const r=new Set(this._items.map(t=>t.id));this._selection=V(e).filter(t=>r.has(t)),!this._selection.length&&this._focusedId&&!r.has(this._focusedId)&&(this._focusedId=null)}_syncSelectionVisualState(){const e=new Set(this._selection),r=this.getAttribute("show-selection-badge")!=="false";this.root.querySelectorAll(".item[data-id]").forEach(s=>{const a=s.getAttribute("data-id");if(!a)return;const n=e.has(a),d=this._focusedId===a;s.setAttribute("data-selected",n?"true":"false"),s.setAttribute("aria-selected",n?"true":"false"),s.setAttribute("data-focused",d?"true":"false"),s.setAttribute("tabindex",d?"0":"-1");const o=s.querySelector('[data-selection-badge="true"]');if(o){const u=n&&r;o.hidden=!u,o.textContent=u?"Selected":""}});const t=this.root.querySelector(".selection-pill");t&&(t.textContent=String(this._selection.length));const i=this.root.querySelector(".selection-text");i&&(i.textContent=this._selection.length===1?"item selected":"items selected")}_clearDropzoneContainerSize(e){e.style.removeProperty("--ui-sortable-dropzone-match-block-size"),e.style.removeProperty("--ui-sortable-dropzone-match-inline-size")}_dropzoneReferenceElement(e,r){if(e.mode==="inside"&&e.parentId)return this._findItemElement(e.parentId);let t=r.nextElementSibling;for(;t;){if(t instanceof HTMLElement&&t.classList.contains("item-shell"))return t.querySelector(".item[data-id]");t=t.nextElementSibling}let i=r.previousElementSibling;for(;i;){if(i instanceof HTMLElement&&i.classList.contains("item-shell"))return i.querySelector(".item[data-id]");i=i.previousElementSibling}const s=this._escapeSelectorValue(e.listId),a=this.root.querySelector(`.list[data-list-id="${s}"] .items`),n=a?.querySelector(".item[data-id]");return n||a||null}_syncDropzoneContainerSize(e,r){if(this._clearDropzoneContainerSize(e),this._dropzoneStyle()!=="container")return;const t=this._dropzoneReferenceElement(r,e);if(!t)return;const i=t.getBoundingClientRect();e.style.setProperty("--ui-sortable-dropzone-match-block-size",`${Math.max(76,Math.round(i.height))}px`),e.style.setProperty("--ui-sortable-dropzone-match-inline-size",`${Math.max(180,Math.round(i.width))}px`)}_ensureDragPreviewOverlay(){if(this._dragPreviewOverlay&&this._dragPreviewOverlay.isConnected)return this._dragPreviewOverlay;const e=document.createElement("div");return e.className="drag-preview-overlay",e.setAttribute("data-visible","false"),this.root.appendChild(e),this._dragPreviewOverlay=e,e}_clearPointerDragPreview(){this._dragPreviewOverlay?.setAttribute("data-visible","false"),this._dragPreviewOverlay?.style.setProperty("left","-9999px"),this._dragPreviewOverlay?.style.setProperty("top","-9999px");const e=this.root.querySelector(".root");e&&!this._dragState?.keyboard&&e.setAttribute("data-drag-preview","false")}_pointerPreviewContent(){if(!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=this._items.find(t=>t.id===e);return r?{kicker:this._dragState.clone?"Copy preview":"Drop preview",title:this._dragState.clone?`${r.label} copy`:r.label,description:this._dragState.clone?"Release to add a copy here.":this._dragState.movedRootIds.length>1?"Release to place this selection here.":"Release to place this item here."}:null}_pointerPreviewSize(){if(this.getAttribute("drag-preview-size")==="compact"||!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=e?this._findItemElement(e):null;if(!r)return null;const t=window.getComputedStyle(r),i=ne(t.transform);return{width:r.offsetWidth*i.x,height:r.offsetHeight*i.y}}_updatePointerDragPreview(){if(!this._dragState||this._dragState.keyboard){this._clearPointerDragPreview();return}const e=this._pointerPreviewContent();if(!e){this._clearPointerDragPreview();return}const r=this.root.querySelector(".root"),i=this._dragPreviewOverlay?.getAttribute("data-visible")==="true",s=this._pointerPreviewSize();if(!this._dragState.dropTarget){i&&r&&r.setAttribute("data-drag-preview","true");return}const a=this._findDropzone(this._dragState.dropTarget);if(!a){i&&r&&r.setAttribute("data-drag-preview","true");return}const n=this._ensureDragPreviewOverlay();n.innerHTML=`
770
770
  <div class="placeholder-content">
771
771
  <div class="placeholder-kicker">${I(e.kicker)}</div>
772
772
  <div class="placeholder-title">${I(e.title)}</div>
773
773
  <div class="placeholder-description">${I(e.description)}</div>
774
774
  </div>
775
- `;const l=o.getBoundingClientRect();r&&r.setAttribute("data-drag-preview","true"),a.style.setProperty("left","-9999px"),a.style.setProperty("top","-9999px"),s?(a.style.setProperty("inline-size",`${s.width}px`),a.style.setProperty("block-size",`${s.height}px`)):(a.style.removeProperty("inline-size"),a.style.removeProperty("block-size")),a.setAttribute("data-visible","true");const n=a.getBoundingClientRect(),d=(s==null?void 0:s.width)??n.width,c=(s==null?void 0:s.height)??n.height,g=Math.max(16,Math.min(l.left,window.innerWidth-d-16)),m=Math.max(16,Math.min(l.top+(l.height-c)/2,window.innerHeight-c-16));a.style.setProperty("left",`${Math.round(g)}px`),a.style.setProperty("top",`${Math.round(m)}px`)}_setDraggingVisualState(e,r){e.forEach(t=>{const i=this._findItemElement(t);i&&(i.setAttribute("data-dragging",r?"true":"false"),i.setAttribute("aria-grabbed",r?"true":"false"),r&&i.getBoundingClientRect())})}_setDropTarget(e,r){var i;const t=((i=this._dragState)==null?void 0:i.dropTarget)??null;if(!(!this._dragState||B(t,e))){if(this._pendingDropTarget=null,this._dragState.dropTarget=e,this._applyCurrentDropTargetVisualState(t),r!=null&&r.announceLabel&&this._announce(r.announceLabel),this._dragState.keyboard){this.requestRender();return}this._updatePointerDragPreview()}}_queueDropTarget(e,r,t){if(!this._dragState)return;const i=this._dragState.dropTarget??null;if(B(i,e)){this._pendingDropTarget=null;return}if(!i&&e){this._setDropTarget(e,t);return}const s=typeof r=="number"&&Number.isFinite(r)?r:performance.now(),o=this._pendingDropTarget;if(o&&B(o.target,e)){const a=e?ie:se;s-o.startedAt>=a&&this._setDropTarget(e,o.announceLabel?{announceLabel:o.announceLabel}:t);return}this._pendingDropTarget={target:e,startedAt:s,announceLabel:t==null?void 0:t.announceLabel}}_releaseDropTarget(e,r){var s;if(!this._dragState)return null;if(Number.isFinite(e)&&Number.isFinite(r)){const o=this._dropTargetFromPoint(e,r);if(o&&this._canDrop(o,this._dragState.movedRootIds))return this._pendingDropTarget=null,o}const t=((s=this._pendingDropTarget)==null?void 0:s.target)??null;if(this._pendingDropTarget=null,t&&this._canDrop(t,this._dragState.movedRootIds))return t;const i=this._dragState.dropTarget??null;return i&&this._canDrop(i,this._dragState.movedRootIds)?i:null}_pathFromPoint(e,r){var o,a;const t=[],i=this.root;let s=typeof i.elementFromPoint=="function"?i.elementFromPoint(e,r):((o=this.ownerDocument)==null?void 0:o.elementFromPoint(e,r))??null;for(;s&&(s instanceof HTMLElement&&t.push(s),s!==this);){if(s instanceof ShadowRoot){s=s.host;continue}s=s.parentNode,!s&&((a=t[t.length-1])==null?void 0:a.getRootNode())instanceof ShadowRoot&&(s=t[t.length-1].getRootNode().host)}return t}_measureItemShellRects(){const e=new Map;return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(r=>{const t=r.getAttribute("data-item-shell");if(!t)return;const i=r.getBoundingClientRect();e.set(t,{top:i.top,left:i.left})}),e}_animateItemShellReflow(e){if(!e.size)return;const r=new Set(this._draggingIds());this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(t=>{const i=t.getAttribute("data-item-shell");if(!i||r.has(i))return;const s=e.get(i);if(!s)return;const o=t.getBoundingClientRect(),a=s.left-o.left,l=s.top-o.top;Math.abs(a)<.5&&Math.abs(l)<.5||(t.style.transition="none",t.style.transform=`translate(${a}px, ${l}px)`,t.style.willChange="transform",t.getBoundingClientRect(),requestAnimationFrame(()=>{t.style.transition="transform 180ms ease",t.style.transform="";const n=()=>{t.style.transition="",t.style.willChange="",t.removeEventListener("transitionend",n)};t.addEventListener("transitionend",n),window.setTimeout(n,220)}))})}_previewCloneSubtreeItem(e,r){const t=e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id;return{...e,id:`${t}--preview`,label:r[0]===e.id?`${e.label} copy`:e.label}}_projectedMoveResult(){var e;return!((e=this._dragState)!=null&&e.dropTarget)||!this._canDrop(this._dragState.dropTarget,this._dragState.movedRootIds)?null:de(this._items,this._lists,this._dragState.dropTarget,this._dragState.movedRootIds,this._dragState.clone,(r,t)=>this._previewCloneSubtreeItem(r,t))}_renderListTree(e,r,t,i,s,o,a){const l=M(e),n=E(e),d=c=>{const g=n.get(z(r.id,c))||[],m=this.sort==="label"?[...g].sort((v,b)=>{const y=l.get(v),w=l.get(b);return!y||!w?0:y.label.localeCompare(w.label)}):g;let f="";return m.forEach(v=>{const b=l.get(v);if(!b||b.hidden)return;const y=this._renderChildBranch(b,t,i,d,s,o,a);!W(b,this.filterQuery)&&!y.includes('class="item"')||(f+=this._renderDropzone({listId:r.id,parentId:c,beforeId:v,mode:"before"},"Drop here"),f+=y)}),f+=this._renderDropzone({listId:r.id,parentId:c,beforeId:null,mode:"before"},"Drop here"),f};return`<div class="tree">${d(null)}</div>`}_renderChildBranch(e,r,t,i,s,o,a){var S,C,T,P;const l=I(e.id),n=o.has(e.id),d=n?"":i(e.id),c=d.includes('class="item"'),g=n?!1:this._selection.includes(e.id),m=n?!1:t.has(e.id),f=e.disabled,v=f||e.dragDisabled||this._isDragLocked(),b=((C=(S=this._dragState)==null?void 0:S.dropTarget)==null?void 0:C.mode)==="inside"&&this._dragState.dropTarget.parentId===e.id,y=(T=this._dragState)!=null&&T.clone?"Copy preview":"Drop preview",w=(P=this._dragState)!=null&&P.clone?"Release to add a copy here.":this._dragState&&this._dragState.movedRootIds.length>1?"Release to place this selection here.":"Release to place this item here.",k=this._dragHandleMode(),A=this._usesCustomHandleSelector(),_=A?"custom":k,R=!A&&k==="handle";return`
776
- <div class="item-shell" data-item-shell="${l}">
775
+ `;const d=a.getBoundingClientRect();r&&r.setAttribute("data-drag-preview","true"),n.style.setProperty("left","-9999px"),n.style.setProperty("top","-9999px"),s?(n.style.setProperty("inline-size",`${s.width}px`),n.style.setProperty("block-size",`${s.height}px`)):(n.style.removeProperty("inline-size"),n.style.removeProperty("block-size")),n.setAttribute("data-visible","true");const o=n.getBoundingClientRect(),u=s?.width??o.width,p=s?.height??o.height,m=Math.max(16,Math.min(d.left,window.innerWidth-u-16)),_=Math.max(16,Math.min(d.top+(d.height-p)/2,window.innerHeight-p-16));n.style.setProperty("left",`${Math.round(m)}px`),n.style.setProperty("top",`${Math.round(_)}px`)}_setDraggingVisualState(e,r){e.forEach(t=>{const i=this._findItemElement(t);i&&(i.setAttribute("data-dragging",r?"true":"false"),i.setAttribute("aria-grabbed",r?"true":"false"),r&&i.getBoundingClientRect())})}_setDropTarget(e,r){const t=this._dragState?.dropTarget??null;if(!(!this._dragState||B(t,e))){if(this._pendingDropTarget=null,this._dragState.dropTarget=e,this._applyCurrentDropTargetVisualState(t),r?.announceLabel&&this._announce(r.announceLabel),this._dragState.keyboard){this.requestRender();return}this._updatePointerDragPreview()}}_queueDropTarget(e,r,t){if(!this._dragState)return;const i=this._dragState.dropTarget??null;if(B(i,e)){this._pendingDropTarget=null;return}if(!i&&e){this._setDropTarget(e,t);return}const s=typeof r=="number"&&Number.isFinite(r)?r:performance.now(),a=this._pendingDropTarget;if(a&&B(a.target,e)){const n=e?ie:se;s-a.startedAt>=n&&this._setDropTarget(e,a.announceLabel?{announceLabel:a.announceLabel}:t);return}this._pendingDropTarget={target:e,startedAt:s,announceLabel:t?.announceLabel}}_releaseDropTarget(e,r){if(!this._dragState)return null;if(Number.isFinite(e)&&Number.isFinite(r)){const s=this._dropTargetFromPoint(e,r);if(s&&this._canDrop(s,this._dragState.movedRootIds))return this._pendingDropTarget=null,s}const t=this._pendingDropTarget?.target??null;if(this._pendingDropTarget=null,t&&this._canDrop(t,this._dragState.movedRootIds))return t;const i=this._dragState.dropTarget??null;return i&&this._canDrop(i,this._dragState.movedRootIds)?i:null}_pathFromPoint(e,r){const t=[],i=this.root;let s=typeof i.elementFromPoint=="function"?i.elementFromPoint(e,r):this.ownerDocument?.elementFromPoint(e,r)??null;for(;s&&(s instanceof HTMLElement&&t.push(s),s!==this);){if(s instanceof ShadowRoot){s=s.host;continue}s=s.parentNode,!s&&t[t.length-1]?.getRootNode()instanceof ShadowRoot&&(s=t[t.length-1].getRootNode().host)}return t}_measureItemShellRects(){const e=new Map;return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(r=>{const t=r.getAttribute("data-item-shell");if(!t)return;const i=r.getBoundingClientRect();e.set(t,{top:i.top,left:i.left})}),e}_animateItemShellReflow(e){if(!e.size)return;const r=new Set(this._draggingIds());this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(t=>{const i=t.getAttribute("data-item-shell");if(!i||r.has(i))return;const s=e.get(i);if(!s)return;const a=t.getBoundingClientRect(),n=s.left-a.left,d=s.top-a.top;Math.abs(n)<.5&&Math.abs(d)<.5||(t.style.transition="none",t.style.transform=`translate(${n}px, ${d}px)`,t.style.willChange="transform",t.getBoundingClientRect(),requestAnimationFrame(()=>{t.style.transition="transform 180ms ease",t.style.transform="";const o=()=>{t.style.transition="",t.style.willChange="",t.removeEventListener("transitionend",o)};t.addEventListener("transitionend",o),window.setTimeout(o,220)}))})}_previewCloneSubtreeItem(e,r){const t=e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id;return{...e,id:`${t}--preview`,label:r[0]===e.id?`${e.label} copy`:e.label}}_projectedMoveResult(){return!this._dragState?.dropTarget||!this._canDrop(this._dragState.dropTarget,this._dragState.movedRootIds)?null:de(this._items,this._lists,this._dragState.dropTarget,this._dragState.movedRootIds,this._dragState.clone,(e,r)=>this._previewCloneSubtreeItem(e,r))}_renderListTree(e,r,t,i,s,a,n){const d=$(e),o=P(e),u=p=>{const m=o.get(D(r.id,p))||[],_=this.sort==="label"?[...m].sort((v,b)=>{const y=d.get(v),x=d.get(b);return!y||!x?0:y.label.localeCompare(x.label)}):m;let f="";return _.forEach(v=>{const b=d.get(v);if(!b||b.hidden)return;const y=this._renderChildBranch(b,t,i,u,s,a,n);!W(b,this.filterQuery)&&!y.includes('class="item"')||(f+=this._renderDropzone({listId:r.id,parentId:p,beforeId:v,mode:"before"},"Drop here"),f+=y)}),f+=this._renderDropzone({listId:r.id,parentId:p,beforeId:null,mode:"before"},"Drop here"),f};return`<div class="tree">${u(null)}</div>`}_renderChildBranch(e,r,t,i,s,a,n){const d=I(e.id),o=a.has(e.id),u=o?"":i(e.id),p=u.includes('class="item"'),m=o?!1:this._selection.includes(e.id),_=o?!1:t.has(e.id),f=e.disabled,v=f||e.dragDisabled||this._isDragLocked(),b=this._dragState?.dropTarget?.mode==="inside"&&this._dragState.dropTarget.parentId===e.id,y=this._dragState?.clone?"Copy preview":"Drop preview",x=this._dragState?.clone?"Release to add a copy here.":this._dragState&&this._dragState.movedRootIds.length>1?"Release to place this selection here.":"Release to place this item here.",z=this._dragHandleMode(),k=this._usesCustomHandleSelector(),h=k?"custom":z,E=!k&&z==="handle";return`
776
+ <div class="item-shell" data-item-shell="${d}">
777
777
  <article
778
- class="item${n?" item-placeholder":""}"
778
+ class="item${o?" item-placeholder":""}"
779
779
  part="item"
780
- data-id="${l}"
781
- data-drag-handle-mode="${_}"
782
- ${!n&&_==="item"?'data-drag-trigger="item"':""}
783
- data-selected="${g}"
784
- data-focused="${n?"false":r===e.id}"
785
- data-dragging="${m}"
780
+ data-id="${d}"
781
+ data-drag-handle-mode="${h}"
782
+ ${!o&&h==="item"?'data-drag-trigger="item"':""}
783
+ data-selected="${m}"
784
+ data-focused="${o?"false":r===e.id}"
785
+ data-dragging="${_}"
786
786
  data-disabled="${f}"
787
787
  data-drop-inside-active="${b?"true":"false"}"
788
- role="${n?"presentation":"option"}"
789
- aria-selected="${n?"false":g}"
788
+ role="${o?"presentation":"option"}"
789
+ aria-selected="${o?"false":m}"
790
790
  aria-disabled="${f}"
791
- aria-grabbed="${n?"false":m}"
792
- aria-hidden="${n?"true":"false"}"
793
- tabindex="${n?"-1":r===e.id?"0":"-1"}"
791
+ aria-grabbed="${o?"false":_}"
792
+ aria-hidden="${o?"true":"false"}"
793
+ tabindex="${o?"-1":r===e.id?"0":"-1"}"
794
794
  >
795
- ${n?`
795
+ ${o?`
796
796
  <div class="placeholder-content">
797
797
  <div class="placeholder-kicker">${I(y)}</div>
798
798
  <div class="placeholder-title">${I(e.label)}</div>
799
- <div class="placeholder-description">${I(w)}</div>
799
+ <div class="placeholder-description">${I(x)}</div>
800
800
  </div>
801
801
  `:`
802
- ${R?`
802
+ ${E?`
803
803
  <button
804
804
  class="handle"
805
805
  part="handle"
806
806
  type="button"
807
807
  data-action="handle"
808
808
  data-drag-trigger="handle"
809
- data-id="${l}"
809
+ data-id="${d}"
810
810
  draggable="false"
811
811
  ${v?"disabled":""}
812
812
  aria-label="Drag ${I(e.label)}"
@@ -821,13 +821,13 @@
821
821
  </svg>
822
822
  </button>
823
823
  `:""}
824
- <div class="item-content" data-action="select" data-id="${l}">
825
- <div class="item-custom-content" part="item-custom-content" data-item-content-target="${l}"></div>
824
+ <div class="item-content" data-action="select" data-id="${d}">
825
+ <div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
826
826
  <div class="item-default-content">
827
827
  <div class="item-title">${I(e.label)}</div>
828
828
  ${e.description?`<div class="item-description">${I(e.description)}</div>`:""}
829
829
  <div class="item-meta">
830
- <span class="item-badge selection-badge" data-selection-badge="true" ${g&&a?"":"hidden"}>${g&&a?"Selected":""}</span>
830
+ <span class="item-badge selection-badge" data-selection-badge="true" ${m&&n?"":"hidden"}>${m&&n?"Selected":""}</span>
831
831
  ${e.cloneOnDrag?'<span class="item-badge">Clone on drag</span>':""}
832
832
  ${e.dragDisabled?'<span class="item-badge">Pinned</span>':""}
833
833
  ${s?'<span class="item-badge drop-badge">Nest here</span>':""}
@@ -836,10 +836,10 @@
836
836
  </div>
837
837
  `}
838
838
  </article>
839
- ${s&&!n?this._renderDropzone({listId:e.listId,parentId:e.id,beforeId:null,mode:"inside"},"Nest here"):""}
840
- ${c?`<div class="children">${d}</div>`:""}
839
+ ${s&&!o?this._renderDropzone({listId:e.listId,parentId:e.id,beforeId:null,mode:"inside"},"Nest here"):""}
840
+ ${p?`<div class="children">${u}</div>`:""}
841
841
  </div>
842
- `}_renderDropzone(e,r){var i;const t=((i=this._dragState)==null?void 0:i.dropTarget)&&this._dragState.dropTarget.listId===e.listId&&this._dragState.dropTarget.parentId===e.parentId&&this._dragState.dropTarget.beforeId===e.beforeId&&this._dragState.dropTarget.mode===e.mode;return`
842
+ `}_renderDropzone(e,r){const t=this._dragState?.dropTarget&&this._dragState.dropTarget.listId===e.listId&&this._dragState.dropTarget.parentId===e.parentId&&this._dragState.dropTarget.beforeId===e.beforeId&&this._dragState.dropTarget.mode===e.mode;return`
843
843
  <div
844
844
  class="dropzone"
845
845
  part="dropzone"
@@ -852,4 +852,4 @@
852
852
  >
853
853
  <span class="dropzone-label">${I(r)}</span>
854
854
  </div>
855
- `}_onClick(e){const r=e.composedPath(),t=r.find(n=>{var d;return n instanceof HTMLElement&&((d=n.classList)==null?void 0:d.contains("toolbar"))}),i=this._dragActivatorFromPath(r),s=r.find(n=>n instanceof HTMLElement&&n.classList.contains("item"));if(i&&i.kind!=="item")return;if(!s)return t&&!(e.target instanceof HTMLButtonElement),void 0;const o=s.getAttribute("data-id");if(!o)return;const a=this._items.find(n=>n.id===o);if(!a||a.disabled)return;const l=e;if(l.shiftKey?this._selectRangeTo(o):l.metaKey||l.ctrlKey?this._toggleSelection(o):this._setSelection([o],"pointer"),this._focusedId=o,this._rangeAnchorId=o,this._pendingFocusId=o,this._hasCustomItemRendering()){this._syncSelectionVisualState(),this._restorePendingFocus();return}this.requestRender()}_onFocusIn(e){const r=e.composedPath().find(i=>i instanceof HTMLElement&&i.classList.contains("item")),t=r==null?void 0:r.getAttribute("data-id");t&&(this._focusedId=t,this._syncSelectionVisualState())}_onKeyDown(e){var l;const r=this._visibleItemIds();if(!r.length)return;const t=this._focusedId&&r.includes(this._focusedId)?this._focusedId:r[0],i=r.indexOf(t),s=this._items.find(n=>n.id===t),o=s?this._lists.find(n=>n.id===s.listId):null,a=(o==null?void 0:o.orientation)==="horizontal";if(!((l=this._dragState)!=null&&l.keyboard)){if(e.key==="ArrowDown"&&!a||e.key==="ArrowRight"&&a){e.preventDefault(),this._moveFocusBy(r,i,1);return}if(e.key==="ArrowUp"&&!a||e.key==="ArrowLeft"&&a){e.preventDefault(),this._moveFocusBy(r,i,-1);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"){e.preventDefault(),this._setSelection(r,"keyboard"),this._announce(`${r.length} items selected.`);return}if(e.key==="Enter"){e.preventDefault(),this._setSelection([t],"keyboard");return}if(e.key===" "||e.code==="Space"){if(e.preventDefault(),this._isDragLocked()){this._announce("Dragging is disabled right now.");return}const n=this._selectedRootIds(t);if(!n.length)return;const d=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map($),movedRootIds:n,originId:t,clone:d,keyboard:!0,dropTarget:this._initialKeyboardDropTarget(t),committed:!1};const c=n.length===1?`Lifted ${(s==null?void 0:s.label)||"item"}.`:`Lifted ${n.length} items.`;this._announce(`${c} Use arrow keys to choose a destination.`),this.requestRender();return}if(e.key==="Escape"){this._setSelection([],"keyboard");return}return}if(e.key==="Escape"){e.preventDefault(),this._cancelDrag(!0);return}if(e.key==="Enter"||e.key===" "||e.code==="Space"){e.preventDefault();const n=this._dragState.dropTarget;if(!n)return;this._commitMove(n,this._dragState.movedRootIds,this._dragState.clone,"keyboard");return}if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const n=e.key==="ArrowDown"||e.key==="ArrowRight"?1:-1;this._moveKeyboardDropTarget(n)}}_moveFocusBy(e,r,t){const i=Math.max(0,Math.min(e.length-1,r+t)),s=e[i];this._focusedId=s,this._pendingFocusId=s,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender()}_onDragStart(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r==null?void 0:r.id;if(!r||!t){e.preventDefault();return}if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(a=>a.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._selection.includes(t)||this._setSelection([t],"pointer");const o=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map($),movedRootIds:s,originId:t,clone:o,keyboard:!1,dropTarget:null,committed:!1},e.dataTransfer&&(e.dataTransfer.effectAllowed=o?"copyMove":"move",e.dataTransfer.setData("text/plain",s.join(",")),this._applyDragImage(e.dataTransfer,s.length)),this._announce(o?`Dragging ${s.length===1?i.label:`${s.length} items`} as a copy.`:`Dragging ${s.length===1?i.label:`${s.length} items`}.`),this.requestRender()}_onDragOver(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}e.preventDefault(),this._queueDropTarget(r,e.timeStamp),e.dataTransfer&&(e.dataTransfer.dropEffect=this._dragState.clone?"copy":"move")}_onDrop(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);!r||!this._canDrop(r,this._dragState.movedRootIds)||(e.preventDefault(),this._commitMove(r,this._dragState.movedRootIds,this._dragState.clone,"pointer"))}_onDocumentKeyDown(e){e.key==="Escape"&&(!this._dragState||this._dragState.keyboard||(e.preventDefault(),this._cancelDrag(!0)))}_onDragEnd(){!this._dragState||this._dragState.keyboard||this._dragState.committed||(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this._announce("Drag cancelled."),this.requestRender())}_dropTargetFromEvent(e){return this._dropTargetFromPath(e.composedPath(),e.clientX,e.clientY)}_dropTargetFromPath(e,r,t){const i=e.find(_=>_ instanceof HTMLElement&&_.classList.contains("dropzone"));if(i){const _={listId:i.getAttribute("data-list-id")||"",parentId:i.getAttribute("data-parent-id")||null,beforeId:i.getAttribute("data-before-id")||null,mode:i.getAttribute("data-mode")==="inside"?"inside":"before"};if(_.listId)return _}const s=e.find(_=>_ instanceof HTMLElement&&_.classList.contains("item"));if(!s)return null;const o=s.getAttribute("data-id");if(!o)return null;const a=this._items.find(_=>_.id===o);if(!a)return null;const l=this._lists.find(_=>_.id===a.listId),n=s.getBoundingClientRect(),d=(l==null?void 0:l.orientation)==="horizontal",c=d?n.left:n.top,g=d?n.right:n.bottom,m=d?r:t,f=Math.max(1,g-c),v=(m-c)/f,b=this.getAttribute("allow-nesting")!=="false"&&!a.disabled;if(v<=.34)return{listId:a.listId,parentId:a.parentId,beforeId:a.id,mode:"before"};if(b&&v>=.34&&v<=.74)return{listId:a.listId,parentId:a.id,beforeId:null,mode:"inside"};const w=E(this._items).get(z(a.listId,a.parentId))||[],k=w.indexOf(a.id),A=k>=0&&w[k+1]||null;return{listId:a.listId,parentId:a.parentId,beforeId:A,mode:"before"}}_dropTargetFromPoint(e,r){return this._dropTargetFromPath(this._pathFromPoint(e,r),e,r)}_beginPointerDrag(e,r){if(!this._pointerGesture||this._dragState)return;const t=this._items.find(i=>{var s;return i.id===((s=this._pointerGesture)==null?void 0:s.originId)});t&&(this._dragState={snapshot:this._items.map($),movedRootIds:[...this._pointerGesture.movedRootIds],originId:this._pointerGesture.originId,clone:this._pointerGesture.clone,keyboard:!1,dropTarget:null,committed:!1},this._pendingDropTarget=null,this._applyPointerPreview(e,r,this._dragState.movedRootIds.length,this._dragState.clone),this._setDraggingVisualState(this._draggingIds(),!0),this._announce(this._dragState.clone?`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`} as a copy.`:`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`}.`))}_onPointerDown(e){var o,a;const r=this._dragActivatorFromPath(e.composedPath()),t=r==null?void 0:r.id;if(!r||!t)return;if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(l=>l.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}e.preventDefault();try{(a=(o=r.element).setPointerCapture)==null||a.call(o,e.pointerId)}catch{}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._pointerGesture={pointerId:e.pointerId,pointerType:e.pointerType,originId:t,movedRootIds:s,clone:this._itemClonesOnDrag(t),startX:e.clientX,startY:e.clientY,moved:!1,captureTarget:r.element}}_onPointerMove(e){if(!(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)){if(e.preventDefault(),!this._pointerGesture.moved){if(Math.hypot(e.clientX-this._pointerGesture.startX,e.clientY-this._pointerGesture.startY)<6)return;this._pointerGesture.moved=!0,this._beginPointerDrag(e.clientX,e.clientY)}if(!(!this._dragState||this._dragState.keyboard)&&(this._movePointerPreview(e.clientX,e.clientY),!this._dragState.committed)){const r=this._dropTargetFromPoint(e.clientX,e.clientY);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}this._queueDropTarget(r,e.timeStamp)}}}_onPointerUp(e){var i,s;if(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)return;e.preventDefault();try{(s=(i=this._pointerGesture.captureTarget)==null?void 0:i.releasePointerCapture)==null||s.call(i,e.pointerId)}catch{}const r=this._pointerGesture;if(this._pointerGesture=null,!this._dragState||this._dragState.keyboard)return;const t=r.moved?this._releaseDropTarget(e.clientX,e.clientY):null;if(r.moved&&t){this._commitMove(t,this._dragState.movedRootIds,this._dragState.clone,"pointer");return}r.moved?this._cancelDrag(!0):(this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this.requestRender())}_onPointerCancel(e){!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId||(this._pointerGesture=null,this._dragState&&this._cancelDrag(!0))}_setSelection(e,r){const t=new Set(this._items.map(a=>a.id)),i=Array.from(new Set(e.filter(a=>t.has(a)))),s=[...this._selection];this._selection=i,this._rangeAnchorId=i[i.length-1]||null,this._focusedId=i[i.length-1]||this._focusedId;const o=j(i);if(this.getAttribute("selection")!==o){this._lastSelectionAttr=o,this._suppressAttributeRender=!0;try{i.length?this.setAttribute("selection",o):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}if(this.dispatchEvent(new CustomEvent("selection-change",{detail:{selection:[...i],previousSelection:s},bubbles:!0,composed:!0})),r!=="restore"){if(this._applyInteractiveStateInPlace({restoreFocus:!0}))return;this.requestRender()}}_toggleSelection(e){const r=this._selection.includes(e)?this._selection.filter(t=>t!==e):[...this._selection,e];this._setSelection(r,"pointer"),this._announce(`${r.length} items selected.`)}_selectRangeTo(e){const r=this._visibleItemIds(),t=this._rangeAnchorId||this._focusedId||e,i=r.indexOf(t),s=r.indexOf(e);if(i<0||s<0){this._setSelection([e],"pointer");return}const[o,a]=i<=s?[i,s]:[s,i];this._setSelection(r.slice(o,a+1),"pointer"),this._announce(`${a-o+1} items selected.`)}_visibleItemIds(){const e=Q(this._items,new Set(this._selection),new Set(this._draggingIds()),this.filterQuery,this.sort);return Array.from(e.values()).flat().filter(r=>!r.disabled).map(r=>r.id)}_selectedRootIds(e){const r=this._selection.length?[...this._selection]:e?[e]:[],t=M(this._items),i=new Set(r);return r.filter(s=>{var l;const o=t.get(s);if(!o)return!1;let a=o.parentId;for(;a;){if(i.has(a))return!1;a=((l=t.get(a))==null?void 0:l.parentId)??null}return!o.disabled})}_draggingIds(){if(!this._dragState)return[];const e=M(this._items),r=E(this._items),t=[],i=s=>{t.push(s);const o=e.get(s);if(!o)return;(r.get(z(o.listId,s))||[]).forEach(i)};return this._dragState.movedRootIds.forEach(i),t}_itemClonesOnDrag(e){const r=this._items.find(i=>i.id===e);if(!r)return!1;if(r.cloneOnDrag)return!0;const t=this._lists.find(i=>i.id===r.listId);return!!(t!=null&&t.cloneOnDrag)}_isDragLocked(){return!!(this.hasAttribute("disabled")||this.sort!=="manual"||this.filterQuery&&!this.hasAttribute("allow-filtered-drag"))}_canDrop(e,r){var n;if(this._isDragLocked())return!1;const t=this._lists.find(d=>d.id===e.listId);if(!t||t.disabled)return!1;const i=M(this._items),s=new Set,o=E(this._items),a=d=>{s.add(d);const c=i.get(d);c&&(o.get(z(c.listId,d))||[]).forEach(a)};if(r.forEach(a),e.parentId&&s.has(e.parentId)||e.beforeId&&s.has(e.beforeId))return!1;const l=Array.from(new Set(r.map(d=>{var c;return(c=i.get(d))==null?void 0:c.listId}).filter(Boolean)));return!((n=t.accepts)!=null&&n.length&&l.some(d=>{var c;return!((c=t.accepts)!=null&&c.includes(d))})||e.mode==="inside"&&this.getAttribute("allow-nesting")==="false")}_commitMove(e,r,t,i){if(!this._canDrop(e,r))return;const s=M(this._items),o=E(this._items),a=new Set,l=[],n=p=>{const D=s.get(p);!D||a.has(p)||(a.add(p),l.push(p),(o.get(z(D.listId,p))||[]).forEach(n))};r.forEach(n);const d=this._items.map($),c=d.filter(p=>a.has(p.id)),g=t?d.map($):d.filter(p=>!a.has(p.id)),m=t?c.map(p=>this._cloneSubtreeItem(p,l)):c.map($),f=new Map,v=new Map;t&&c.forEach((p,D)=>{f.set(p.id,m[D].id),v.set(m[D].id,p.id)}),m.forEach(p=>{const D=t?v.get(p.id):p.id,q=D?s.get(D):null;q&&(t&&(p.parentId=q.parentId&&f.has(q.parentId)&&f.get(q.parentId)||null),p.listId=e.listId)});const b=r.map(p=>f.get(p)||p),y=[...g,...m],w=E(g),k=z(e.listId,e.parentId),A=[...w.get(k)||[]],_=e.beforeId?A.indexOf(e.beforeId):A.length,R=_>=0?_:A.length;A.splice(R,0,...b),w.set(k,A),E(m).forEach((p,D)=>{const[,q]=D.split("::");(q||"")!=="__root__"&&w.set(D,[...p])});const C=M(y);b.forEach(p=>{const D=C.get(p);D&&(D.parentId=e.parentId,D.listId=e.listId)});const T=[],P=new Set,L=(p,D)=>{(w.get(z(p,D))||[]).forEach((N,ee)=>{const H=C.get(N);!H||P.has(N)||(P.add(N),H.listId=p,H.parentId=D,H.order=ee,T.push(H),L(p,N))})};this._lists.forEach(p=>L(p.id,null)),y.forEach(p=>{P.has(p.id)||(p.parentId=null,T.push(p))}),this._dragState&&(this._dragState.committed=!0),this._items=T.map($),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage();const G=[...b],h=[...this._selection];this._selection=G,this._focusedId=G[0]||null,this._pendingFocusId=this._focusedId,this._syncAttributesFromState();const x=J(this._items);this._persistSnapshot(x);const F=r.map(p=>s.get(p)).filter(p=>!!p),O=t?"clone":e.mode==="inside"?"nest":F.some(p=>p.listId!==e.listId)?"transfer":"reorder",K={items:this.items,lists:this.lists,selection:[...G],previousSelection:h,movedIds:[...b],source:i,operation:O,persistence:x};this.dispatchEvent(new CustomEvent("change",{detail:K,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("persist-request",{detail:K,bubbles:!0,composed:!0})),this._announce(this._messageForMove(O,b.length,e)),this.requestRender()}_syncAttributesFromState(){const e=ce(this._lists),r=le(this._items),t=j(this._selection);this._lastListsAttr=e,this._lastItemsAttr=r,this._lastSelectionAttr=t,this._suppressAttributeRender=!0;try{this.setAttribute("lists",e),this.setAttribute("items",r),this._selection.length?this.setAttribute("selection",t):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}_cloneSubtreeItem(e,r){const i=`copy-${this._cloneSeed++}`,o=`${e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id}--${i}`;return{...e,id:o,label:r[0]===e.id?`${e.label} copy`:e.label}}_messageForMove(e,r,t){const i=this._lists.find(o=>o.id===t.listId),s=(i==null?void 0:i.label)||t.listId;return e==="clone"?`${r===1?"Item copied":`${r} items copied`} into ${s}.`:e==="nest"?`${r===1?"Item nested":`${r} items nested`} in ${s}.`:e==="transfer"?`${r===1?"Item moved":`${r} items moved`} to ${s}.`:`${r===1?"Item reordered":`${r} items reordered`} in ${s}.`}_persistSnapshot(e){const r=this.getAttribute("persist-key");if(r)try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}}_announce(e){this._liveMessage=e,this._applyLiveMessage()}_cancelDrag(e){this._dragState&&(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._items=this._dragState.snapshot.map($),this._dragState=null,this._pointerGesture=null,this._removeDragImage(),e&&this._announce("Drag cancelled."),this._syncAttributesFromState(),this.requestRender())}_applyDragImage(e,r){this._removeDragImage();const t=document.createElement("div");t.textContent=r===1?"Dragging item":`Dragging ${r} items`,t.style.position="fixed",t.style.top="-999px",t.style.left="-999px",t.style.padding="8px 12px",t.style.borderRadius="999px",t.style.background="rgba(15, 23, 42, 0.92)",t.style.color="#f8fafc",t.style.font="600 12px/1 Inter, sans-serif",t.style.pointerEvents="none",document.body.appendChild(t),e.setDragImage(t,12,12),this._dragImage=t}_removeDragImage(){var e;(e=this._dragImage)==null||e.remove(),this._dragImage=null}_removeDragPreviewOverlay(){var e;(e=this._dragPreviewOverlay)==null||e.remove(),this._dragPreviewOverlay=null}_applyPointerPreview(e,r,t,i){this._removeDragImage();const s=document.createElement("div");s.textContent=i?t===1?"Copying item":`Copying ${t} items`:t===1?"Moving item":`Moving ${t} items`,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.zIndex="2147483647",s.style.padding="8px 12px",s.style.borderRadius="999px",s.style.background="rgba(15, 23, 42, 0.92)",s.style.color="#f8fafc",s.style.font="600 12px/1 Inter, sans-serif",s.style.pointerEvents="none",s.style.boxShadow="0 12px 28px rgba(15, 23, 42, 0.22)",document.body.appendChild(s),this._dragImage=s,this._movePointerPreview(e,r)}_movePointerPreview(e,r){this._dragImage&&(this._dragImage.style.transform=`translate(${Math.round(e+14)}px, ${Math.round(r+14)}px)`)}_keyboardDropTargets(){const e=M(this._items),r=E(this._items),t=[],i=(s,o)=>{var l;(r.get(z(s,o))||[]).forEach(n=>{const d=e.get(n);!d||d.hidden||(t.push({listId:s,parentId:o,beforeId:n,mode:"before",label:`Before ${d.label}`}),this.getAttribute("allow-nesting")!=="false"&&t.push({listId:s,parentId:n,beforeId:null,mode:"inside",label:`Nest inside ${d.label}`}),i(s,n))}),t.push({listId:s,parentId:o,beforeId:null,mode:"before",label:o?"After children":`End of ${((l=this._lists.find(n=>n.id===s))==null?void 0:l.label)||s}`})};return this._lists.forEach(s=>i(s.id,null)),t.filter(s=>{var o;return this._canDrop(s,((o=this._dragState)==null?void 0:o.movedRootIds)||[])})}_initialKeyboardDropTarget(e){const r=this._items.find(t=>t.id===e);return r?{listId:r.listId,parentId:r.parentId,beforeId:e,mode:"before"}:null}_moveKeyboardDropTarget(e){if(!this._dragState)return;const r=this._keyboardDropTargets();if(!r.length)return;const t=Math.max(0,r.findIndex(s=>{var o,a,l,n,d,c,g,m;return s.listId===((a=(o=this._dragState)==null?void 0:o.dropTarget)==null?void 0:a.listId)&&s.parentId===((n=(l=this._dragState)==null?void 0:l.dropTarget)==null?void 0:n.parentId)&&s.beforeId===((c=(d=this._dragState)==null?void 0:d.dropTarget)==null?void 0:c.beforeId)&&s.mode===((m=(g=this._dragState)==null?void 0:g.dropTarget)==null?void 0:m.mode)})),i=Math.max(0,Math.min(r.length-1,t+e));this._setDropTarget(r[i],{announceLabel:r[i].label})}}typeof customElements<"u"&&!customElements.get("ui-sortable")&&customElements.define("ui-sortable",Z);exports.UISortable=Z;
855
+ `}_onClick(e){const r=e.composedPath(),t=r.find(o=>o instanceof HTMLElement&&o.classList?.contains("toolbar")),i=this._dragActivatorFromPath(r),s=r.find(o=>o instanceof HTMLElement&&o.classList.contains("item"));if(i&&i.kind!=="item")return;if(!s)return t&&!(e.target instanceof HTMLButtonElement),void 0;const a=s.getAttribute("data-id");if(!a)return;const n=this._items.find(o=>o.id===a);if(!n||n.disabled)return;const d=e;if(d.shiftKey?this._selectRangeTo(a):d.metaKey||d.ctrlKey?this._toggleSelection(a):this._setSelection([a],"pointer"),this._focusedId=a,this._rangeAnchorId=a,this._pendingFocusId=a,this._hasCustomItemRendering()){this._syncSelectionVisualState(),this._restorePendingFocus();return}this.requestRender()}_onFocusIn(e){const t=e.composedPath().find(i=>i instanceof HTMLElement&&i.classList.contains("item"))?.getAttribute("data-id");t&&(this._focusedId=t,this._syncSelectionVisualState())}_onKeyDown(e){const r=this._visibleItemIds();if(!r.length)return;const t=this._focusedId&&r.includes(this._focusedId)?this._focusedId:r[0],i=r.indexOf(t),s=this._items.find(d=>d.id===t),n=(s?this._lists.find(d=>d.id===s.listId):null)?.orientation==="horizontal";if(!this._dragState?.keyboard){if(e.key==="ArrowDown"&&!n||e.key==="ArrowRight"&&n){e.preventDefault(),this._moveFocusBy(r,i,1);return}if(e.key==="ArrowUp"&&!n||e.key==="ArrowLeft"&&n){e.preventDefault(),this._moveFocusBy(r,i,-1);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"){e.preventDefault(),this._setSelection(r,"keyboard"),this._announce(`${r.length} items selected.`);return}if(e.key==="Enter"){e.preventDefault(),this._setSelection([t],"keyboard");return}if(e.key===" "||e.code==="Space"){if(e.preventDefault(),this._isDragLocked()){this._announce("Dragging is disabled right now.");return}const d=this._selectedRootIds(t);if(!d.length)return;const o=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map(A),movedRootIds:d,originId:t,clone:o,keyboard:!0,dropTarget:this._initialKeyboardDropTarget(t),committed:!1};const u=d.length===1?`Lifted ${s?.label||"item"}.`:`Lifted ${d.length} items.`;this._announce(`${u} Use arrow keys to choose a destination.`),this.requestRender();return}if(e.key==="Escape"){this._setSelection([],"keyboard");return}return}if(e.key==="Escape"){e.preventDefault(),this._cancelDrag(!0);return}if(e.key==="Enter"||e.key===" "||e.code==="Space"){e.preventDefault();const d=this._dragState.dropTarget;if(!d)return;this._commitMove(d,this._dragState.movedRootIds,this._dragState.clone,"keyboard");return}if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const d=e.key==="ArrowDown"||e.key==="ArrowRight"?1:-1;this._moveKeyboardDropTarget(d)}}_moveFocusBy(e,r,t){const i=Math.max(0,Math.min(e.length-1,r+t)),s=e[i];this._focusedId=s,this._pendingFocusId=s,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender()}_onDragStart(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r?.id;if(!r||!t){e.preventDefault();return}if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(n=>n.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._selection.includes(t)||this._setSelection([t],"pointer");const a=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map(A),movedRootIds:s,originId:t,clone:a,keyboard:!1,dropTarget:null,committed:!1},e.dataTransfer&&(e.dataTransfer.effectAllowed=a?"copyMove":"move",e.dataTransfer.setData("text/plain",s.join(",")),this._applyDragImage(e.dataTransfer,s.length)),this._announce(a?`Dragging ${s.length===1?i.label:`${s.length} items`} as a copy.`:`Dragging ${s.length===1?i.label:`${s.length} items`}.`),this.requestRender()}_onDragOver(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}e.preventDefault(),this._queueDropTarget(r,e.timeStamp),e.dataTransfer&&(e.dataTransfer.dropEffect=this._dragState.clone?"copy":"move")}_onDrop(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);!r||!this._canDrop(r,this._dragState.movedRootIds)||(e.preventDefault(),this._commitMove(r,this._dragState.movedRootIds,this._dragState.clone,"pointer"))}_onDocumentKeyDown(e){e.key==="Escape"&&(!this._dragState||this._dragState.keyboard||(e.preventDefault(),this._cancelDrag(!0)))}_onDragEnd(){!this._dragState||this._dragState.keyboard||this._dragState.committed||(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this._announce("Drag cancelled."),this.requestRender())}_dropTargetFromEvent(e){return this._dropTargetFromPath(e.composedPath(),e.clientX,e.clientY)}_dropTargetFromPath(e,r,t){const i=e.find(h=>h instanceof HTMLElement&&h.classList.contains("dropzone"));if(i){const h={listId:i.getAttribute("data-list-id")||"",parentId:i.getAttribute("data-parent-id")||null,beforeId:i.getAttribute("data-before-id")||null,mode:i.getAttribute("data-mode")==="inside"?"inside":"before"};if(h.listId)return h}const s=e.find(h=>h instanceof HTMLElement&&h.classList.contains("item"));if(!s)return null;const a=s.getAttribute("data-id");if(!a)return null;const n=this._items.find(h=>h.id===a);if(!n)return null;const d=this._lists.find(h=>h.id===n.listId),o=s.getBoundingClientRect(),u=d?.orientation==="horizontal",p=u?o.left:o.top,m=u?o.right:o.bottom,_=u?r:t,f=Math.max(1,m-p),v=(_-p)/f,b=this.getAttribute("allow-nesting")!=="false"&&!n.disabled;if(v<=.34)return{listId:n.listId,parentId:n.parentId,beforeId:n.id,mode:"before"};if(b&&v>=.34&&v<=.74)return{listId:n.listId,parentId:n.id,beforeId:null,mode:"inside"};const x=P(this._items).get(D(n.listId,n.parentId))||[],z=x.indexOf(n.id),k=z>=0&&x[z+1]||null;return{listId:n.listId,parentId:n.parentId,beforeId:k,mode:"before"}}_dropTargetFromPoint(e,r){return this._dropTargetFromPath(this._pathFromPoint(e,r),e,r)}_beginPointerDrag(e,r){if(!this._pointerGesture||this._dragState)return;const t=this._items.find(i=>i.id===this._pointerGesture?.originId);t&&(this._dragState={snapshot:this._items.map(A),movedRootIds:[...this._pointerGesture.movedRootIds],originId:this._pointerGesture.originId,clone:this._pointerGesture.clone,keyboard:!1,dropTarget:null,committed:!1},this._pendingDropTarget=null,this._applyPointerPreview(e,r,this._dragState.movedRootIds.length,this._dragState.clone),this._setDraggingVisualState(this._draggingIds(),!0),this._announce(this._dragState.clone?`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`} as a copy.`:`Dragging ${this._dragState.movedRootIds.length===1?t.label:`${this._dragState.movedRootIds.length} items`}.`))}_onPointerDown(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r?.id;if(!r||!t)return;if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(a=>a.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}e.preventDefault();try{r.element.setPointerCapture?.(e.pointerId)}catch{}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._pointerGesture={pointerId:e.pointerId,pointerType:e.pointerType,originId:t,movedRootIds:s,clone:this._itemClonesOnDrag(t),startX:e.clientX,startY:e.clientY,moved:!1,captureTarget:r.element}}_onPointerMove(e){if(!(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)){if(e.preventDefault(),!this._pointerGesture.moved){if(Math.hypot(e.clientX-this._pointerGesture.startX,e.clientY-this._pointerGesture.startY)<6)return;this._pointerGesture.moved=!0,this._beginPointerDrag(e.clientX,e.clientY)}if(!(!this._dragState||this._dragState.keyboard)&&(this._movePointerPreview(e.clientX,e.clientY),!this._dragState.committed)){const r=this._dropTargetFromPoint(e.clientX,e.clientY);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}this._queueDropTarget(r,e.timeStamp)}}}_onPointerUp(e){if(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)return;e.preventDefault();try{this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId)}catch{}const r=this._pointerGesture;if(this._pointerGesture=null,!this._dragState||this._dragState.keyboard)return;const t=r.moved?this._releaseDropTarget(e.clientX,e.clientY):null;if(r.moved&&t){this._commitMove(t,this._dragState.movedRootIds,this._dragState.clone,"pointer");return}r.moved?this._cancelDrag(!0):(this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this.requestRender())}_onPointerCancel(e){!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId||(this._pointerGesture=null,this._dragState&&this._cancelDrag(!0))}_setSelection(e,r){const t=new Set(this._items.map(n=>n.id)),i=Array.from(new Set(e.filter(n=>t.has(n)))),s=[...this._selection];this._selection=i,this._rangeAnchorId=i[i.length-1]||null,this._focusedId=i[i.length-1]||this._focusedId;const a=U(i);if(this.getAttribute("selection")!==a){this._lastSelectionAttr=a,this._suppressAttributeRender=!0;try{i.length?this.setAttribute("selection",a):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}if(this.dispatchEvent(new CustomEvent("selection-change",{detail:{selection:[...i],previousSelection:s},bubbles:!0,composed:!0})),r!=="restore"){if(this._applyInteractiveStateInPlace({restoreFocus:!0}))return;this.requestRender()}}_toggleSelection(e){const r=this._selection.includes(e)?this._selection.filter(t=>t!==e):[...this._selection,e];this._setSelection(r,"pointer"),this._announce(`${r.length} items selected.`)}_selectRangeTo(e){const r=this._visibleItemIds(),t=this._rangeAnchorId||this._focusedId||e,i=r.indexOf(t),s=r.indexOf(e);if(i<0||s<0){this._setSelection([e],"pointer");return}const[a,n]=i<=s?[i,s]:[s,i];this._setSelection(r.slice(a,n+1),"pointer"),this._announce(`${n-a+1} items selected.`)}_visibleItemIds(){const e=Q(this._items,new Set(this._selection),new Set(this._draggingIds()),this.filterQuery,this.sort);return Array.from(e.values()).flat().filter(r=>!r.disabled).map(r=>r.id)}_selectedRootIds(e){const r=this._selection.length?[...this._selection]:e?[e]:[],t=$(this._items),i=new Set(r);return r.filter(s=>{const a=t.get(s);if(!a)return!1;let n=a.parentId;for(;n;){if(i.has(n))return!1;n=t.get(n)?.parentId??null}return!a.disabled})}_draggingIds(){if(!this._dragState)return[];const e=$(this._items),r=P(this._items),t=[],i=s=>{t.push(s);const a=e.get(s);if(!a)return;(r.get(D(a.listId,s))||[]).forEach(i)};return this._dragState.movedRootIds.forEach(i),t}_itemClonesOnDrag(e){const r=this._items.find(i=>i.id===e);return r?r.cloneOnDrag?!0:!!this._lists.find(i=>i.id===r.listId)?.cloneOnDrag:!1}_isDragLocked(){return!!(this.hasAttribute("disabled")||this.sort!=="manual"||this.filterQuery&&!this.hasAttribute("allow-filtered-drag"))}_canDrop(e,r){if(this._isDragLocked())return!1;const t=this._lists.find(o=>o.id===e.listId);if(!t||t.disabled)return!1;const i=$(this._items),s=new Set,a=P(this._items),n=o=>{s.add(o);const u=i.get(o);u&&(a.get(D(u.listId,o))||[]).forEach(n)};if(r.forEach(n),e.parentId&&s.has(e.parentId)||e.beforeId&&s.has(e.beforeId))return!1;const d=Array.from(new Set(r.map(o=>i.get(o)?.listId).filter(Boolean)));return!(t.accepts?.length&&d.some(o=>!t.accepts?.includes(o))||e.mode==="inside"&&this.getAttribute("allow-nesting")==="false")}_commitMove(e,r,t,i){if(!this._canDrop(e,r))return;const s=$(this._items),a=P(this._items),n=new Set,d=[],o=c=>{const w=s.get(c);!w||n.has(c)||(n.add(c),d.push(c),(a.get(D(w.listId,c))||[]).forEach(o))};r.forEach(o);const u=this._items.map(A),p=u.filter(c=>n.has(c.id)),m=t?u.map(A):u.filter(c=>!n.has(c.id)),_=t?p.map(c=>this._cloneSubtreeItem(c,d)):p.map(A),f=new Map,v=new Map;t&&p.forEach((c,w)=>{f.set(c.id,_[w].id),v.set(_[w].id,c.id)}),_.forEach(c=>{const w=t?v.get(c.id):c.id,C=w?s.get(w):null;C&&(t&&(c.parentId=C.parentId&&f.has(C.parentId)&&f.get(C.parentId)||null),c.listId=e.listId)});const b=r.map(c=>f.get(c)||c),y=[...m,..._],x=P(m),z=D(e.listId,e.parentId),k=[...x.get(z)||[]],h=e.beforeId?k.indexOf(e.beforeId):k.length,E=h>=0?h:k.length;k.splice(E,0,...b),x.set(z,k),P(_).forEach((c,w)=>{const[,C]=w.split("::");(C||"")!=="__root__"&&x.set(w,[...c])});const L=$(y);b.forEach(c=>{const w=L.get(c);w&&(w.parentId=e.parentId,w.listId=e.listId)});const F=[],M=new Set,O=(c,w)=>{(x.get(D(c,w))||[]).forEach((N,ee)=>{const G=L.get(N);!G||M.has(N)||(M.add(N),G.listId=c,G.parentId=w,G.order=ee,F.push(G),O(c,N))})};this._lists.forEach(c=>O(c.id,null)),y.forEach(c=>{M.has(c.id)||(c.parentId=null,F.push(c))}),this._dragState&&(this._dragState.committed=!0),this._items=F.map(A),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage();const q=[...b],g=[...this._selection];this._selection=q,this._focusedId=q[0]||null,this._pendingFocusId=this._focusedId,this._syncAttributesFromState();const S=J(this._items);this._persistSnapshot(S);const T=r.map(c=>s.get(c)).filter(c=>!!c),R=t?"clone":e.mode==="inside"?"nest":T.some(c=>c.listId!==e.listId)?"transfer":"reorder",K={items:this.items,lists:this.lists,selection:[...q],previousSelection:g,movedIds:[...b],source:i,operation:R,persistence:S};this.dispatchEvent(new CustomEvent("change",{detail:K,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("persist-request",{detail:K,bubbles:!0,composed:!0})),this._announce(this._messageForMove(R,b.length,e)),this.requestRender()}_syncAttributesFromState(){const e=ce(this._lists),r=le(this._items),t=U(this._selection);this._lastListsAttr=e,this._lastItemsAttr=r,this._lastSelectionAttr=t,this._suppressAttributeRender=!0;try{this.setAttribute("lists",e),this.setAttribute("items",r),this._selection.length?this.setAttribute("selection",t):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}_cloneSubtreeItem(e,r){const i=`copy-${this._cloneSeed++}`,a=`${e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id}--${i}`;return{...e,id:a,label:r[0]===e.id?`${e.label} copy`:e.label}}_messageForMove(e,r,t){const s=this._lists.find(a=>a.id===t.listId)?.label||t.listId;return e==="clone"?`${r===1?"Item copied":`${r} items copied`} into ${s}.`:e==="nest"?`${r===1?"Item nested":`${r} items nested`} in ${s}.`:e==="transfer"?`${r===1?"Item moved":`${r} items moved`} to ${s}.`:`${r===1?"Item reordered":`${r} items reordered`} in ${s}.`}_persistSnapshot(e){const r=this.getAttribute("persist-key");if(r)try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}}_announce(e){this._liveMessage=e,this._applyLiveMessage()}_cancelDrag(e){this._dragState&&(this._pendingDropTarget=null,this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._items=this._dragState.snapshot.map(A),this._dragState=null,this._pointerGesture=null,this._removeDragImage(),e&&this._announce("Drag cancelled."),this._syncAttributesFromState(),this.requestRender())}_applyDragImage(e,r){this._removeDragImage();const t=document.createElement("div");t.textContent=r===1?"Dragging item":`Dragging ${r} items`,t.style.position="fixed",t.style.top="-999px",t.style.left="-999px",t.style.padding="8px 12px",t.style.borderRadius="999px",t.style.background="rgba(15, 23, 42, 0.92)",t.style.color="#f8fafc",t.style.font="600 12px/1 Inter, sans-serif",t.style.pointerEvents="none",document.body.appendChild(t),e.setDragImage(t,12,12),this._dragImage=t}_removeDragImage(){this._dragImage?.remove(),this._dragImage=null}_removeDragPreviewOverlay(){this._dragPreviewOverlay?.remove(),this._dragPreviewOverlay=null}_applyPointerPreview(e,r,t,i){this._removeDragImage();const s=document.createElement("div");s.textContent=i?t===1?"Copying item":`Copying ${t} items`:t===1?"Moving item":`Moving ${t} items`,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.zIndex="2147483647",s.style.padding="8px 12px",s.style.borderRadius="999px",s.style.background="rgba(15, 23, 42, 0.92)",s.style.color="#f8fafc",s.style.font="600 12px/1 Inter, sans-serif",s.style.pointerEvents="none",s.style.boxShadow="0 12px 28px rgba(15, 23, 42, 0.22)",document.body.appendChild(s),this._dragImage=s,this._movePointerPreview(e,r)}_movePointerPreview(e,r){this._dragImage&&(this._dragImage.style.transform=`translate(${Math.round(e+14)}px, ${Math.round(r+14)}px)`)}_keyboardDropTargets(){const e=$(this._items),r=P(this._items),t=[],i=(s,a)=>{(r.get(D(s,a))||[]).forEach(d=>{const o=e.get(d);!o||o.hidden||(t.push({listId:s,parentId:a,beforeId:d,mode:"before",label:`Before ${o.label}`}),this.getAttribute("allow-nesting")!=="false"&&t.push({listId:s,parentId:d,beforeId:null,mode:"inside",label:`Nest inside ${o.label}`}),i(s,d))}),t.push({listId:s,parentId:a,beforeId:null,mode:"before",label:a?"After children":`End of ${this._lists.find(d=>d.id===s)?.label||s}`})};return this._lists.forEach(s=>i(s.id,null)),t.filter(s=>this._canDrop(s,this._dragState?.movedRootIds||[]))}_initialKeyboardDropTarget(e){const r=this._items.find(t=>t.id===e);return r?{listId:r.listId,parentId:r.parentId,beforeId:e,mode:"before"}:null}_moveKeyboardDropTarget(e){if(!this._dragState)return;const r=this._keyboardDropTargets();if(!r.length)return;const t=Math.max(0,r.findIndex(s=>s.listId===this._dragState?.dropTarget?.listId&&s.parentId===this._dragState?.dropTarget?.parentId&&s.beforeId===this._dragState?.dropTarget?.beforeId&&s.mode===this._dragState?.dropTarget?.mode)),i=Math.max(0,Math.min(r.length-1,t+e));this._setDropTarget(r[i],{announceLabel:r[i].label})}}typeof customElements<"u"&&!customElements.get("ui-sortable")&&customElements.define("ui-sortable",Z);exports.UISortable=Z;