spell-ui 0.8.15 → 0.8.17

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 (285) hide show
  1. package/README-components.md +4 -2
  2. package/README-runtime.md +26 -1
  3. package/README.md +2 -1
  4. package/dist/SliderScale-DunjyaDW.js +67 -0
  5. package/dist/SliderScale-DunjyaDW.js.map +1 -0
  6. package/dist/{ThemeDraft-CyX3YA_L.js → ThemeDraft-spaNC2dD.js} +2 -2
  7. package/dist/{ThemeDraft-CyX3YA_L.js.map → ThemeDraft-spaNC2dD.js.map} +1 -1
  8. package/dist/{UIInput-B3K0w4ow.js → UIInput-8s1aiaw1.js} +2 -2
  9. package/dist/UIInput-8s1aiaw1.js.map +1 -0
  10. package/dist/{UIRuntime-DCv4sy30.js → UIRuntime-BaokNnwk.js} +900 -158
  11. package/dist/UIRuntime-BaokNnwk.js.map +1 -0
  12. package/dist/_spell-element/UIComponent.d.ts +7 -0
  13. package/dist/_spell-element/elements.types.d.ts +6 -0
  14. package/dist/_spell-element/vocabulary.types.d.ts +27 -0
  15. package/dist/_util/dom.d.ts +7 -0
  16. package/dist/components/components.es.d.ts +1 -0
  17. package/dist/components/ui-dial/DialArc.d.ts +43 -0
  18. package/dist/components/ui-dial/UIDial.d.ts +263 -0
  19. package/dist/components/ui-dial/UIDial.en.d.ts +149 -0
  20. package/dist/components/ui-dial/UIDial.es.d.ts +25 -0
  21. package/dist/components/ui-dial/UIDial.fallback.d.ts +167 -0
  22. package/dist/components/ui-dial/UIDial.types.d.ts +11 -0
  23. package/dist/components/ui-dial/index.d.ts +3 -0
  24. package/dist/components/ui-graph/UIGraph.d.ts +17 -0
  25. package/dist/components/ui-graph/UIGraph.en.d.ts +17 -0
  26. package/dist/components/ui-graph/UIGraph.es.d.ts +6 -0
  27. package/dist/components/ui-input/UIInput.d.ts +46 -3
  28. package/dist/components/ui-input/UIInput.en.d.ts +6 -1
  29. package/dist/components/ui-input/UIInput.es.d.ts +1 -0
  30. package/dist/components/ui-input/UIInput.fallback.d.ts +6 -1
  31. package/dist/components/ui-json/UIJson.d.ts +5 -4
  32. package/dist/components/ui-modal/ChoiceRows.d.ts +61 -0
  33. package/dist/components/ui-modal/ModalDialogs.d.ts +15 -1
  34. package/dist/components/ui-modal/UIModal.d.ts +6 -2
  35. package/dist/components/ui-modal/UIModal.en.d.ts +6 -2
  36. package/dist/components/ui-modal/UIModal.es.d.ts +1 -0
  37. package/dist/components/ui-page-layout/UIPageLayout.d.ts +141 -8
  38. package/dist/components/ui-page-layout/UIPageLayout.en.d.ts +51 -2
  39. package/dist/components/ui-page-layout/UIPageLayout.es.d.ts +3 -0
  40. package/dist/components/ui-property-editor/UIProperty.d.ts +2 -2
  41. package/dist/components/ui-site-links/UISiteLinks.d.ts +124 -0
  42. package/dist/components/ui-site-links/UISiteLinks.en.d.ts +60 -0
  43. package/dist/components/ui-site-links/UISiteLinks.es.d.ts +26 -0
  44. package/dist/components/ui-site-links/index.d.ts +1 -0
  45. package/dist/components/ui-site-nav-button/UISiteNavButton.d.ts +12 -5
  46. package/dist/components/ui-site-nav-button/UISiteNavButton.en.d.ts +32 -12
  47. package/dist/components/ui-site-nav-button/UISiteNavButton.es.d.ts +3 -0
  48. package/dist/components/ui-site-tabs/UISiteTabs.d.ts +13 -0
  49. package/dist/components/ui-site-tabs/UISiteTabs.en.d.ts +9 -0
  50. package/dist/components/ui-slider/SliderScale.d.ts +26 -2
  51. package/dist/components/ui-slider/UISlider.d.ts +0 -2
  52. package/dist/components/ui-statistic/UIStatistic.d.ts +1 -0
  53. package/dist/components/ui-statistic/UIStatistic.en.d.ts +1 -0
  54. package/dist/components/ui-toc/TocIndex.d.ts +16 -1
  55. package/dist/components/ui-toc/UIToc.d.ts +27 -3
  56. package/dist/components/ui-toc/UIToc.en.d.ts +1 -1
  57. package/dist/components/ui-toc/UIToc.types.d.ts +5 -0
  58. package/dist/components/ui-tree/UITree.d.ts +38 -2
  59. package/dist/components/ui-tree/UITree.en.d.ts +9 -0
  60. package/dist/components/ui-tree/UITree.es.d.ts +4 -0
  61. package/dist/components/ui-uploader/UIUploader.d.ts +721 -0
  62. package/dist/components/ui-uploader/UIUploader.en.d.ts +394 -0
  63. package/dist/components/ui-uploader/UIUploader.es.d.ts +112 -0
  64. package/dist/components/ui-uploader/index.d.ts +1 -0
  65. package/dist/{components.es-DilRG1VO.js → components.es-jY2nBwuP.js} +249 -65
  66. package/dist/components.es-jY2nBwuP.js.map +1 -0
  67. package/dist/core.js +605 -571
  68. package/dist/core.js.map +1 -1
  69. package/dist/docs-components/docs-components.types.d.ts +2 -0
  70. package/dist/index.d.ts +3 -0
  71. package/dist/index.js +101 -97
  72. package/dist/jsx.d.ts +1138 -21
  73. package/dist/runtime/DataTooltips.d.ts +10 -0
  74. package/dist/runtime/Modals.d.ts +7 -2
  75. package/dist/runtime/Styles.d.ts +7 -1
  76. package/dist/runtime/UIRuntime.d.ts +6 -0
  77. package/dist/runtime/runtime.types.d.ts +26 -1
  78. package/dist/sound-library/back.ogg +0 -0
  79. package/dist/sound-library/beep.ogg +0 -0
  80. package/dist/sound-library/bell.ogg +0 -0
  81. package/dist/sound-library/big-punch.ogg +0 -0
  82. package/dist/sound-library/bong.ogg +0 -0
  83. package/dist/sound-library/book-close.ogg +0 -0
  84. package/dist/sound-library/book-down.ogg +0 -0
  85. package/dist/sound-library/book-open.ogg +0 -0
  86. package/dist/sound-library/card-fan-2.ogg +0 -0
  87. package/dist/sound-library/card-fan.ogg +0 -0
  88. package/dist/sound-library/card-place-2.ogg +0 -0
  89. package/dist/sound-library/card-place-3.ogg +0 -0
  90. package/dist/sound-library/card-place.ogg +0 -0
  91. package/dist/sound-library/card-shove-2.ogg +0 -0
  92. package/dist/sound-library/card-shove.ogg +0 -0
  93. package/dist/sound-library/card-slide-2.ogg +0 -0
  94. package/dist/sound-library/card-slide-3.ogg +0 -0
  95. package/dist/sound-library/card-slide-4.ogg +0 -0
  96. package/dist/sound-library/card-slide.ogg +0 -0
  97. package/dist/sound-library/chip-down-2.ogg +0 -0
  98. package/dist/sound-library/chip-down.ogg +0 -0
  99. package/dist/sound-library/chips-collide.ogg +0 -0
  100. package/dist/sound-library/chips-handle.ogg +0 -0
  101. package/dist/sound-library/chips-stack-2.ogg +0 -0
  102. package/dist/sound-library/chips-stack.ogg +0 -0
  103. package/dist/sound-library/chop.ogg +0 -0
  104. package/dist/sound-library/click-2.ogg +0 -0
  105. package/dist/sound-library/click-3.ogg +0 -0
  106. package/dist/sound-library/click.ogg +0 -0
  107. package/dist/sound-library/close.ogg +0 -0
  108. package/dist/sound-library/cloth.ogg +0 -0
  109. package/dist/sound-library/coins-2.ogg +0 -0
  110. package/dist/sound-library/coins.ogg +0 -0
  111. package/dist/sound-library/confirm-2.ogg +0 -0
  112. package/dist/sound-library/confirm.ogg +0 -0
  113. package/dist/sound-library/creak.ogg +0 -0
  114. package/dist/sound-library/deck-open.ogg +0 -0
  115. package/dist/sound-library/deck-take-out.ogg +0 -0
  116. package/dist/sound-library/dice-grab.ogg +0 -0
  117. package/dist/sound-library/dice-shake-2.ogg +0 -0
  118. package/dist/sound-library/dice-shake.ogg +0 -0
  119. package/dist/sound-library/dice-throw-2.ogg +0 -0
  120. package/dist/sound-library/dice-throw.ogg +0 -0
  121. package/dist/sound-library/die-throw-2.ogg +0 -0
  122. package/dist/sound-library/die-throw.ogg +0 -0
  123. package/dist/sound-library/door-close.ogg +0 -0
  124. package/dist/sound-library/door-open.ogg +0 -0
  125. package/dist/sound-library/drop.ogg +0 -0
  126. package/dist/sound-library/error-2.ogg +0 -0
  127. package/dist/sound-library/error.ogg +0 -0
  128. package/dist/sound-library/fail.ogg +0 -0
  129. package/dist/sound-library/fall.ogg +0 -0
  130. package/dist/sound-library/glass-break.ogg +0 -0
  131. package/dist/sound-library/glass-clink.ogg +0 -0
  132. package/dist/sound-library/glass-tap.ogg +0 -0
  133. package/dist/sound-library/glass.ogg +0 -0
  134. package/dist/sound-library/glitch.ogg +0 -0
  135. package/dist/sound-library/grow.ogg +0 -0
  136. package/dist/sound-library/high-up.ogg +0 -0
  137. package/dist/sound-library/hover-2.ogg +0 -0
  138. package/dist/sound-library/hover.ogg +0 -0
  139. package/dist/sound-library/jingle-2.ogg +0 -0
  140. package/dist/sound-library/jingle-3.ogg +0 -0
  141. package/dist/sound-library/jingle-4.ogg +0 -0
  142. package/dist/sound-library/jingle.ogg +0 -0
  143. package/dist/sound-library/jump.ogg +0 -0
  144. package/dist/sound-library/knife-draw.ogg +0 -0
  145. package/dist/sound-library/knife-slice.ogg +0 -0
  146. package/dist/sound-library/laser-2.ogg +0 -0
  147. package/dist/sound-library/laser.ogg +0 -0
  148. package/dist/sound-library/latch.ogg +0 -0
  149. package/dist/sound-library/level-up.ogg +0 -0
  150. package/dist/sound-library/lose-2.ogg +0 -0
  151. package/dist/sound-library/lose-3.ogg +0 -0
  152. package/dist/sound-library/lose-4.ogg +0 -0
  153. package/dist/sound-library/lose.ogg +0 -0
  154. package/dist/sound-library/low-down.ogg +0 -0
  155. package/dist/sound-library/metal-clang.ogg +0 -0
  156. package/dist/sound-library/metal-click.ogg +0 -0
  157. package/dist/sound-library/metal-crash.ogg +0 -0
  158. package/dist/sound-library/metal-tap.ogg +0 -0
  159. package/dist/sound-library/mouse-click.ogg +0 -0
  160. package/dist/sound-library/mouse-release.ogg +0 -0
  161. package/dist/sound-library/open.ogg +0 -0
  162. package/dist/sound-library/orchestra-hit-2.ogg +0 -0
  163. package/dist/sound-library/orchestra-hit.ogg +0 -0
  164. package/dist/sound-library/page-turn-2.ogg +0 -0
  165. package/dist/sound-library/page-turn.ogg +0 -0
  166. package/dist/sound-library/pickaxe.ogg +0 -0
  167. package/dist/sound-library/piece-down-2.ogg +0 -0
  168. package/dist/sound-library/piece-down-3.ogg +0 -0
  169. package/dist/sound-library/piece-down.ogg +0 -0
  170. package/dist/sound-library/piece-take-2.ogg +0 -0
  171. package/dist/sound-library/piece-take.ogg +0 -0
  172. package/dist/sound-library/piece-tap-2.ogg +0 -0
  173. package/dist/sound-library/piece-tap.ogg +0 -0
  174. package/dist/sound-library/plank.ogg +0 -0
  175. package/dist/sound-library/plate.ogg +0 -0
  176. package/dist/sound-library/pluck.ogg +0 -0
  177. package/dist/sound-library/pot.ogg +0 -0
  178. package/dist/sound-library/power-up-2.ogg +0 -0
  179. package/dist/sound-library/power-up-3.ogg +0 -0
  180. package/dist/sound-library/power-up.ogg +0 -0
  181. package/dist/sound-library/punch.ogg +0 -0
  182. package/dist/sound-library/question.ogg +0 -0
  183. package/dist/sound-library/rise.ogg +0 -0
  184. package/dist/sound-library/scratch.ogg +0 -0
  185. package/dist/sound-library/scroll.ogg +0 -0
  186. package/dist/sound-library/select-2.ogg +0 -0
  187. package/dist/sound-library/select.ogg +0 -0
  188. package/dist/sound-library/shrink.ogg +0 -0
  189. package/dist/sound-library/shuffle.ogg +0 -0
  190. package/dist/sound-library/soft-thud-2.ogg +0 -0
  191. package/dist/sound-library/soft-thud.ogg +0 -0
  192. package/dist/sound-library/space-junk.ogg +0 -0
  193. package/dist/sound-library/step-2.ogg +0 -0
  194. package/dist/sound-library/step-on-carpet.ogg +0 -0
  195. package/dist/sound-library/step-on-grass.ogg +0 -0
  196. package/dist/sound-library/step-on-snow.ogg +0 -0
  197. package/dist/sound-library/step-on-stone.ogg +0 -0
  198. package/dist/sound-library/step-on-wood.ogg +0 -0
  199. package/dist/sound-library/step.ogg +0 -0
  200. package/dist/sound-library/switch-2.ogg +0 -0
  201. package/dist/sound-library/switch.ogg +0 -0
  202. package/dist/sound-library/tap-2.ogg +0 -0
  203. package/dist/sound-library/tap.ogg +0 -0
  204. package/dist/sound-library/three-tones.ogg +0 -0
  205. package/dist/sound-library/tick-2.ogg +0 -0
  206. package/dist/sound-library/tick.ogg +0 -0
  207. package/dist/sound-library/tin.ogg +0 -0
  208. package/dist/sound-library/toggle-2.ogg +0 -0
  209. package/dist/sound-library/toggle.ogg +0 -0
  210. package/dist/sound-library/two-tones.ogg +0 -0
  211. package/dist/sound-library/win-2.ogg +0 -0
  212. package/dist/sound-library/win-3.ogg +0 -0
  213. package/dist/sound-library/win-4.ogg +0 -0
  214. package/dist/sound-library/win.ogg +0 -0
  215. package/dist/sound-library/wood-thud.ogg +0 -0
  216. package/dist/sound-library/zap.ogg +0 -0
  217. package/dist/sounds/BuiltInSounds.d.ts +41 -0
  218. package/dist/sounds/index.d.ts +9 -0
  219. package/dist/sounds/sounds.types.d.ts +22 -0
  220. package/dist/ui-calendar.js +1 -1
  221. package/dist/ui-dial.editor-CjjdKi5L.js +5 -0
  222. package/dist/ui-dial.editor-CjjdKi5L.js.map +1 -0
  223. package/dist/ui-dial.js +467 -0
  224. package/dist/ui-dial.js.map +1 -0
  225. package/dist/ui-graph.js +22 -0
  226. package/dist/ui-graph.js.map +1 -1
  227. package/dist/{ui-input.editor-budoNoB0.js → ui-input.editor-D11iRgXR.js} +2 -2
  228. package/dist/ui-input.editor-D11iRgXR.js.map +1 -0
  229. package/dist/ui-input.js +84 -54
  230. package/dist/ui-input.js.map +1 -1
  231. package/dist/ui-json.js +8 -8
  232. package/dist/ui-json.js.map +1 -1
  233. package/dist/ui-modal.js +183 -97
  234. package/dist/ui-modal.js.map +1 -1
  235. package/dist/ui-page-layout.editor-IgDEveUY.js +5 -0
  236. package/dist/ui-page-layout.editor-IgDEveUY.js.map +1 -0
  237. package/dist/ui-page-layout.js +217 -72
  238. package/dist/ui-page-layout.js.map +1 -1
  239. package/dist/ui-popup.js +34 -34
  240. package/dist/ui-popup.js.map +1 -1
  241. package/dist/ui-property-editor.js +7 -4
  242. package/dist/ui-property-editor.js.map +1 -1
  243. package/dist/ui-root.js +71 -5
  244. package/dist/ui-root.js.map +1 -1
  245. package/dist/ui-search.js +1 -1
  246. package/dist/ui-section.js +97 -96
  247. package/dist/ui-section.js.map +1 -1
  248. package/dist/ui-site-links.editor-BME3sw5H.js +5 -0
  249. package/dist/ui-site-links.editor-BME3sw5H.js.map +1 -0
  250. package/dist/ui-site-links.js +150 -0
  251. package/dist/ui-site-links.js.map +1 -0
  252. package/dist/ui-site-nav-button.editor-ChY4xe1U.js +5 -0
  253. package/dist/ui-site-nav-button.editor-ChY4xe1U.js.map +1 -0
  254. package/dist/ui-site-nav-button.js +57 -18
  255. package/dist/ui-site-nav-button.js.map +1 -1
  256. package/dist/{ui-site-tabs.editor-DDvQfH6S.js → ui-site-tabs.editor-CdMIw4jw.js} +2 -2
  257. package/dist/ui-site-tabs.editor-CdMIw4jw.js.map +1 -0
  258. package/dist/ui-site-tabs.js +30 -14
  259. package/dist/ui-site-tabs.js.map +1 -1
  260. package/dist/ui-slider.js +75 -124
  261. package/dist/ui-slider.js.map +1 -1
  262. package/dist/ui-statistic.js +1 -0
  263. package/dist/ui-statistic.js.map +1 -1
  264. package/dist/ui-theme-editor.js +2 -2
  265. package/dist/{ui-theme-menu-BZYUMrHe.js → ui-theme-menu-BEBu6dyq.js} +3 -3
  266. package/dist/{ui-theme-menu-BZYUMrHe.js.map → ui-theme-menu-BEBu6dyq.js.map} +1 -1
  267. package/dist/ui-toc.js +159 -122
  268. package/dist/ui-toc.js.map +1 -1
  269. package/dist/ui-tree.js +142 -87
  270. package/dist/ui-tree.js.map +1 -1
  271. package/dist/ui-uploader.editor-DrE80KjL.js +5 -0
  272. package/dist/ui-uploader.editor-DrE80KjL.js.map +1 -0
  273. package/dist/ui-uploader.js +1442 -0
  274. package/dist/ui-uploader.js.map +1 -0
  275. package/dist/vocabulary/hooks.generated.d.ts +7 -0
  276. package/package.json +1 -1
  277. package/dist/UIInput-B3K0w4ow.js.map +0 -1
  278. package/dist/UIRuntime-DCv4sy30.js.map +0 -1
  279. package/dist/components.es-DilRG1VO.js.map +0 -1
  280. package/dist/ui-input.editor-budoNoB0.js.map +0 -1
  281. package/dist/ui-page-layout.editor-xtQW0FZk.js +0 -5
  282. package/dist/ui-page-layout.editor-xtQW0FZk.js.map +0 -1
  283. package/dist/ui-site-nav-button.editor-6J-zJLtZ.js +0 -5
  284. package/dist/ui-site-nav-button.editor-6J-zJLtZ.js.map +0 -1
  285. package/dist/ui-site-tabs.editor-DDvQfH6S.js.map +0 -1
@@ -0,0 +1,1442 @@
1
+ import "./rolldown-runtime-c6e9CmGy.js";
2
+ import { ApiError as e, DOMElement as t, Gt as n, Jt as r, Kt as i, UI as a, UIComponent as o, Ut as s, Warnings as c, Wt as l, Yt as u, after as ee, byDocumentOrder as te, closestAcrossShadow as ne, commaList as re, on as ie, onChange as d, proto as ae, protoMerged as oe, qt as f, state as p, untracked as m } from "./core.js";
3
+ import "./ui-button.js";
4
+ import "./ui-icon.js";
5
+ import "./ui-input.js";
6
+ import "./ui-list.js";
7
+ import "./ui-popup.js";
8
+ import "./ui-progress.js";
9
+ import "./ui-segment.js";
10
+ import "./ui-text.js";
11
+ import { For as se, Show as h } from "solid-js";
12
+ import { addEvent as g, className as ce, createComponent as _, delegateEvents as le, effect as v, getOwner as y, insert as b, isServer as x, memo as S, readShallow as ue, ref as C, setAttribute as w, setStyleProperty as T, template as E } from "@solidjs/web";
13
+ // src/components/ui-uploader/UIUploader.en.ts
14
+ var de = "{ file: File, name: string, path: string, size: number, type: string, lastModified: number, via: \"dialog\" | \"drop\" | \"zone\", reason?: string, entry?: FileSystemEntry, handle?: FileSystemHandle }", fe = "{ name: string, path: string, files: File[], via: \"dialog\" | \"drop\" | \"zone\", reason?: string, entry?: FileSystemEntry, handle?: FileSystemHandle }", D = "{ count: number, kinds: string[], via: \"drop\" | \"zone\" }", pe = {
15
+ tag: "ui-uploader",
16
+ icon: "cloud upload",
17
+ snippet: "<ui-uploader extensions=\"json\" multiple></ui-uploader>",
18
+ topics: [
19
+ "forms",
20
+ "inputs",
21
+ "controls",
22
+ "progress"
23
+ ],
24
+ aka: [
25
+ "file upload",
26
+ "file uploader",
27
+ "upload",
28
+ "dropzone",
29
+ "drop zone",
30
+ "file drop",
31
+ "file picker",
32
+ "drag and drop",
33
+ "attachment"
34
+ ],
35
+ noun: "uploader",
36
+ partOfSpeech: "action",
37
+ description: "An uploader takes files someone picks or drops on it, or whole folders, then posts them to its `destination`, or hands them to its `action`.",
38
+ skeleton: "18 x 9",
39
+ attributes: [
40
+ {
41
+ name: "appearance",
42
+ group: "appearance",
43
+ kind: "enum",
44
+ values: [
45
+ "hero",
46
+ "button",
47
+ "input",
48
+ "compact"
49
+ ],
50
+ default: "hero",
51
+ description: "How it looks: `hero` -- a big drop area with an icon, a line of help and a Choose files button, a row per file under it; `button` -- just a button, its files in a popup from it; `input` -- a form field with a Browse button, its files listed under it; `compact` -- a one-line drop area, one line of status and one progress bar. All four take the same attributes and send the same events."
52
+ },
53
+ {
54
+ name: "destination",
55
+ group: "behaviour",
56
+ kind: "string",
57
+ description: "A URL each file is posted to, as form data (`file`, its path as its file name), one request per file. `action` wins when both are set."
58
+ },
59
+ {
60
+ name: "action",
61
+ group: "behaviour",
62
+ kind: "json",
63
+ description: "A function called with the files kept, `(files: File[]) => unknown`, instead of posting them: in Spell, an action (`action={read the netlist}`). Not a URL, as a form's `action` is: that's `destination`."
64
+ },
65
+ {
66
+ name: "extensions",
67
+ group: "behaviour",
68
+ kind: "string",
69
+ description: "The kinds of file it takes, a comma list of extensions (`json, csv`); any other is turned away. None: any file."
70
+ },
71
+ {
72
+ name: "multiple",
73
+ group: "behaviour",
74
+ kind: "boolean",
75
+ description: "Takes more than one file at a time."
76
+ },
77
+ {
78
+ name: "folder",
79
+ group: "behaviour",
80
+ kind: "boolean",
81
+ description: "Takes folders instead of files, each with its files and their paths in it; its events are `ui-folder-*` for the drag and the folder itself, then `ui-file-dropped` for each file. A plain file dropped on it is turned away."
82
+ },
83
+ {
84
+ name: "max-size",
85
+ group: "behaviour",
86
+ kind: "string",
87
+ description: "The largest file it takes: `2 MB`, `500 KB`, `1.5 GB`, or a number of bytes."
88
+ },
89
+ {
90
+ name: "max-files",
91
+ group: "behaviour",
92
+ kind: "number",
93
+ description: "The most files it takes in one go; the rest are turned away."
94
+ },
95
+ {
96
+ name: "drop-zone",
97
+ group: "behaviour",
98
+ kind: "json",
99
+ description: "Where else a drop counts as a drop on it: `page` -- anywhere on the page; a selector (`#editor`, `ui-section`), looked for first among the elements around it, then on the page; or, as a property, the element itself. The zone shows `drop-message` while files are dragged over it."
100
+ },
101
+ {
102
+ name: "message",
103
+ group: "content",
104
+ kind: "string",
105
+ description: "Its line of help (`Drop .json files here, or`); a `button` uploader's label. None: its own, naming the kinds it takes. The `message` slot wins over it."
106
+ },
107
+ {
108
+ name: "drop-message",
109
+ group: "content",
110
+ kind: "string",
111
+ description: "What it says while files are dragged over it: `{count}` is how many. None: `Drop to add {count} files`."
112
+ },
113
+ {
114
+ name: "uploading-message",
115
+ group: "content",
116
+ kind: "string",
117
+ description: "What it says while it posts: `{done}` is how many are done, `{count}` how many in all. None: `Uploading {done} of {count}`."
118
+ },
119
+ {
120
+ name: "done-message",
121
+ group: "content",
122
+ kind: "string",
123
+ description: "What it says once they're all posted: `{count}` is how many. None: `{count} files uploaded`."
124
+ }
125
+ ],
126
+ events: [
127
+ {
128
+ name: "ui-file-dragged-over",
129
+ detail: D,
130
+ description: "Files are dragged over it, or over its `drop-zone`: how many, and their kinds."
131
+ },
132
+ {
133
+ name: "ui-file-dragged-out",
134
+ detail: D,
135
+ description: "The files dragged over it left without being dropped."
136
+ },
137
+ {
138
+ name: "ui-folder-dragged-over",
139
+ detail: D,
140
+ description: "With `folder`: `ui-file-dragged-over`'s twin. While dragging, a browser can't tell a folder from a file."
141
+ },
142
+ {
143
+ name: "ui-folder-dragged-out",
144
+ detail: D,
145
+ description: "With `folder`: `ui-file-dragged-out`'s twin."
146
+ },
147
+ {
148
+ name: "ui-file-dropping",
149
+ cancelable: !0,
150
+ detail: de,
151
+ description: "A file picked or dropped is about to be taken: cancel it to leave it out. `reason` says why it'll be turned away, when it will be."
152
+ },
153
+ {
154
+ name: "ui-file-dropped",
155
+ detail: de,
156
+ description: "A file was taken, kept or turned away (`reason`), the same for a pick (`via: \"dialog\"`) as for a drop. `file.text()` reads it. `entry` and `handle` are there when the browser gives them: an entry on any drop, a handle on a drop in Chrome and Edge."
157
+ },
158
+ {
159
+ name: "ui-folder-dropping",
160
+ cancelable: !0,
161
+ detail: fe,
162
+ description: "With `folder`: a folder is about to be taken, with its files: cancel it to leave it all out."
163
+ },
164
+ {
165
+ name: "ui-folder-dropped",
166
+ detail: fe,
167
+ description: "With `folder`: a folder was taken; a `ui-file-dropped` follows for each file in it."
168
+ },
169
+ {
170
+ name: "ui-uploading",
171
+ cancelable: !0,
172
+ detail: "{ files: File[] }",
173
+ description: "The files kept are about to be posted to `destination`, or handed to `action`: cancel it to take the upload over, and nothing is posted or called."
174
+ },
175
+ {
176
+ name: "ui-upload-progress",
177
+ detail: "{ file: File, sent: number, size: number }",
178
+ description: "While a file posts: how many bytes have gone, of its size."
179
+ },
180
+ {
181
+ name: "ui-uploaded",
182
+ detail: "{ file: File, response: unknown }",
183
+ description: "A file was posted: `response` is the server's answer, as JSON when it says so, else text; with `action`, what the action returned."
184
+ },
185
+ {
186
+ name: "ui-upload-failed",
187
+ detail: "{ file: File, error: Error }",
188
+ description: "A file couldn't be posted, or the `action` threw: `error` says why."
189
+ }
190
+ ],
191
+ slots: [
192
+ {
193
+ name: "icon",
194
+ description: "Its icon, in place of its own cloud."
195
+ },
196
+ {
197
+ name: "message",
198
+ description: "Its line of help, in place of `message`."
199
+ },
200
+ {
201
+ name: "button",
202
+ description: "Its button (Choose files, Browse), in place of its own: a click opens the file dialog."
203
+ }
204
+ ],
205
+ parts: [
206
+ {
207
+ name: "drop-area",
208
+ description: "The area files are dropped on: the hero's and compact's dashed box."
209
+ },
210
+ {
211
+ name: "button",
212
+ description: "The button that opens the file dialog: a `<ui-button>`."
213
+ },
214
+ {
215
+ name: "input",
216
+ description: "With `appearance=\"input\"`: the field, a `<ui-input>`."
217
+ },
218
+ {
219
+ name: "files",
220
+ description: "The list of files taken."
221
+ },
222
+ {
223
+ name: "file",
224
+ description: "A file's row."
225
+ },
226
+ {
227
+ name: "name",
228
+ description: "A file's name."
229
+ },
230
+ {
231
+ name: "size",
232
+ description: "A file's size."
233
+ },
234
+ {
235
+ name: "progress",
236
+ description: "A file's progress bar, a `<ui-progress>`; compact's one bar for all."
237
+ },
238
+ {
239
+ name: "status",
240
+ description: "A file's status: a tick, or the reason it failed; compact's line of status."
241
+ },
242
+ {
243
+ name: "remove",
244
+ description: "A file's Remove button."
245
+ },
246
+ {
247
+ name: "popup",
248
+ description: "With `appearance=\"button\"`: the popup of file rows, a `<ui-popup>`."
249
+ },
250
+ {
251
+ name: "zone",
252
+ description: "The light overlay over its `drop-zone` while files are dragged over it."
253
+ }
254
+ ],
255
+ states: [
256
+ {
257
+ name: "dragged-over",
258
+ description: "Files are dragged over it, or its `drop-zone`."
259
+ },
260
+ {
261
+ name: "uploading",
262
+ description: "It's posting files, or its `action` is running."
263
+ },
264
+ {
265
+ name: "hero",
266
+ description: "It's `appearance=\"hero\"`."
267
+ },
268
+ {
269
+ name: "button",
270
+ description: "It's `appearance=\"button\"`."
271
+ },
272
+ {
273
+ name: "input",
274
+ description: "It's `appearance=\"input\"`."
275
+ },
276
+ {
277
+ name: "compact",
278
+ description: "It's `appearance=\"compact\"`."
279
+ }
280
+ ],
281
+ texts: [
282
+ {
283
+ key: "message",
284
+ text: "Drop {kinds} files here, or",
285
+ description: "The hero's line of help: `{kinds}`, `.json`."
286
+ },
287
+ {
288
+ key: "messageAny",
289
+ text: "Drop files here, or",
290
+ description: "The hero's line of help, taking any file."
291
+ },
292
+ {
293
+ key: "messageFolders",
294
+ text: "Drop folders here, or",
295
+ description: "The hero's line of help, with `folder`."
296
+ },
297
+ {
298
+ key: "compactMessage",
299
+ text: "Drop {kinds} files, or",
300
+ description: "compact's line of help."
301
+ },
302
+ {
303
+ key: "compactMessageAny",
304
+ text: "Drop files, or",
305
+ description: "compact's line of help, taking any file."
306
+ },
307
+ {
308
+ key: "compactMessageFolders",
309
+ text: "Drop folders, or",
310
+ description: "compact's line of help, with `folder`."
311
+ },
312
+ {
313
+ key: "buttonLabel",
314
+ text: "Upload {kinds} files",
315
+ description: "A `button` uploader's label."
316
+ },
317
+ {
318
+ key: "buttonLabelAny",
319
+ text: "Upload files",
320
+ description: "A `button` uploader's label, taking any file."
321
+ },
322
+ {
323
+ key: "buttonLabelFolders",
324
+ text: "Upload folders",
325
+ description: "A `button` uploader's label, with `folder`."
326
+ },
327
+ {
328
+ key: "choose",
329
+ text: "Choose files…",
330
+ description: "The hero's button."
331
+ },
332
+ {
333
+ key: "chooseFolders",
334
+ text: "Choose folders…",
335
+ description: "The hero's button, with `folder`."
336
+ },
337
+ {
338
+ key: "chooseShort",
339
+ text: "Choose",
340
+ description: "compact's small button."
341
+ },
342
+ {
343
+ key: "browse",
344
+ text: "Browse…",
345
+ description: "The `input` look's button."
346
+ },
347
+ {
348
+ key: "noFiles",
349
+ text: "No files chosen",
350
+ description: "The `input` look's field, empty."
351
+ },
352
+ {
353
+ key: "fileCount",
354
+ text: "{count} files",
355
+ description: "The `input` look's field: how many files."
356
+ },
357
+ {
358
+ key: "fileCountDone",
359
+ text: "{count} files: {done} uploaded",
360
+ description: "The `input` look's field, once some are up."
361
+ },
362
+ {
363
+ key: "dropMessage",
364
+ text: "Drop to add {count} files",
365
+ description: "While files are dragged over it."
366
+ },
367
+ {
368
+ key: "dropMessageOne",
369
+ text: "Drop to add 1 file",
370
+ description: "While one file is dragged over it."
371
+ },
372
+ {
373
+ key: "uploadingMessage",
374
+ text: "Uploading {done} of {count}",
375
+ description: "While it posts."
376
+ },
377
+ {
378
+ key: "doneMessage",
379
+ text: "{count} files uploaded",
380
+ description: "Once they're all posted."
381
+ },
382
+ {
383
+ key: "doneMessageOne",
384
+ text: "1 file uploaded",
385
+ description: "Once the one file is posted."
386
+ },
387
+ {
388
+ key: "limitsFiles",
389
+ text: "Up to {count} files",
390
+ description: "Its limits: the count."
391
+ },
392
+ {
393
+ key: "limitsBoth",
394
+ text: "Up to {count} files, {size} each",
395
+ description: "Its limits: the count and the size."
396
+ },
397
+ {
398
+ key: "limitsSizeOnly",
399
+ text: "Up to {size}",
400
+ description: "Its limits: the size alone."
401
+ },
402
+ {
403
+ key: "turnedAway",
404
+ text: "{count} files not added",
405
+ description: "How many were turned away."
406
+ },
407
+ {
408
+ key: "turnedAwayOne",
409
+ text: "1 file not added",
410
+ description: "One was turned away."
411
+ },
412
+ {
413
+ key: "uploaded",
414
+ text: "Uploaded",
415
+ description: "A row's status, posted."
416
+ },
417
+ {
418
+ key: "taken",
419
+ text: "Done",
420
+ description: "A row's status, handed to the `action`."
421
+ },
422
+ {
423
+ key: "held",
424
+ text: "Ready",
425
+ description: "A row's status, held: no `destination` or `action`."
426
+ },
427
+ {
428
+ key: "uploading",
429
+ text: "Uploading",
430
+ description: "What a screen reader calls a row's progress bar."
431
+ },
432
+ {
433
+ key: "failed",
434
+ text: "Failed: {reason}",
435
+ description: "A row's status, failed."
436
+ },
437
+ {
438
+ key: "serverError",
439
+ text: "server error {status}",
440
+ description: "Why a post failed: the server's answer."
441
+ },
442
+ {
443
+ key: "noConnection",
444
+ text: "no connection",
445
+ description: "Why a post failed: nothing answered."
446
+ },
447
+ {
448
+ key: "tooBig",
449
+ text: "Too big",
450
+ description: "Why a file was turned away: its size, in its row."
451
+ },
452
+ {
453
+ key: "tooBigLong",
454
+ text: "This file is too big, so it wasn't added. Choose a file that's {size} or smaller.",
455
+ description: "Why a file was turned away: its size, in full (its row's tooltip)."
456
+ },
457
+ {
458
+ key: "wrongKind",
459
+ text: "Not a {kinds} file",
460
+ description: "Why a file was turned away: its kind, in its row."
461
+ },
462
+ {
463
+ key: "wrongKindLong",
464
+ text: "Only {kinds} files can be uploaded. Choose a file that ends in {kinds}.",
465
+ description: "Why a file was turned away: its kind, in full (its row's tooltip)."
466
+ },
467
+ {
468
+ key: "tooMany",
469
+ text: "Too many files",
470
+ description: "Why a file was turned away: the count, in its row."
471
+ },
472
+ {
473
+ key: "tooManyLong",
474
+ text: "This file wasn't added: up to {count} files can be added at once. Remove one, then add this file again.",
475
+ description: "Why a file was turned away: the count, in full (its row's tooltip)."
476
+ },
477
+ {
478
+ key: "oneOnly",
479
+ text: "Only one file",
480
+ description: "Why a second file was turned away, without `multiple`, in its row."
481
+ },
482
+ {
483
+ key: "oneOnlyLong",
484
+ text: "This file wasn't added: one file can be added at a time. Remove the other file, then add this one again.",
485
+ description: "Why a second file was turned away, without `multiple`, in full (its row's tooltip)."
486
+ },
487
+ {
488
+ key: "notAFolder",
489
+ text: "Not a folder",
490
+ description: "Why a plain file was turned away by a `folder` uploader, in its row."
491
+ },
492
+ {
493
+ key: "notAFolderLong",
494
+ text: "Only folders can be added here. Choose a folder.",
495
+ description: "Why a plain file was turned away by a `folder` uploader, in full (its row's tooltip)."
496
+ },
497
+ {
498
+ key: "aFolder",
499
+ text: "A folder",
500
+ description: "Why a folder was turned away by a plain uploader, in its row."
501
+ },
502
+ {
503
+ key: "aFolderLong",
504
+ text: "Folders can't be added here. Choose files instead.",
505
+ description: "Why a folder was turned away by a plain uploader, in full (its row's tooltip)."
506
+ },
507
+ {
508
+ key: "remove",
509
+ text: "Remove",
510
+ description: "A row's Remove button's name and tooltip."
511
+ },
512
+ {
513
+ key: "files",
514
+ text: "Files",
515
+ description: "What a screen reader calls the list of files."
516
+ }
517
+ ]
518
+ }, me = "@layer ui.components.uploader.types{:host{--_ui-uploader-border-width:var(--ui-uploader-border-width,2px);--_ui-uploader-border-style:var(--ui-uploader-border-style,dashed);--_ui-uploader-border-color:var(--ui-uploader-border-color,var(--ui-border-color,oklch(from var(--ui-ink) l c h / .2)));--_ui-uploader-background:var(--ui-uploader-background,transparent);--_ui-uploader-lit-color:var(--ui-uploader-lit-color,var(--ui-blue));--_ui-uploader-radius:var(--ui-uploader-radius,var(--ui-radius-l,8px));--_ui-uploader-padding:var(--ui-uploader-padding,24px 16px);--_ui-uploader-icon-color:var(--ui-uploader-icon-color,var(--ui-text-muted));--_ui-uploader-row-height:var(--ui-uploader-row-height,44px);--_ui-uploader-row-gap:var(--ui-uploader-row-gap,8px);--_ui-uploader-popup-width:var(--ui-uploader-popup-width,360px);display:block}:host(:state(button)){display:inline-block}.drop-area{margin:0;display:block}.drop-area::part(segment){min-height:0;padding:var(--_ui-uploader-padding);border:var(--_ui-uploader-border-width) var(--_ui-uploader-border-style) var(--_ui-uploader-border-color);border-radius:var(--_ui-uploader-radius);background:var(--_ui-uploader-background);box-shadow:none;margin:0;transition:border-color .12s,background-color .12s}.hero{text-align:center;justify-items:center;gap:8px;display:grid}.icon{color:var(--_ui-uploader-icon-color);display:inline-flex}.choose-slot{display:contents}:host(:state(compact)) .drop-area::part(segment){border-width:1px;padding:8px 12px}.line{flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;display:flex}.line .choose{margin:0}.summary{gap:4px;margin-top:8px;font-size:.9em;display:grid}.files::part(list){gap:var(--_ui-uploader-row-gap);margin:12px 0 0;padding:0;display:grid}.file::part(item){min-height:var(--_ui-uploader-row-height);box-sizing:border-box;border-radius:var(--ui-radius-l,8px);box-shadow:0 0 0 1px var(--ui-border-color,oklch(from var(--ui-ink) l c h / .12));grid-template-columns:20px minmax(0,1fr) 72px minmax(96px,220px) 32px;align-items:center;gap:12px;margin:0;padding:4px 4px 4px 12px;display:grid}.file::part(item):after{content:none}.glyph{color:var(--ui-text-muted)}.name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.size::part(text){text-align:end;font-variant-numeric:tabular-nums}.status{--_ui-icon-owner-display:inline-flex;--_ui-icon-owner-margin:0 4px 0 0;--_ui-icon-owner-align:-.125em}.status::part(text){min-width:0}.file ui-progress,.summary ui-progress{margin:0;display:block}.file ui-progress::part(progress),.summary ui-progress::part(progress),.remove{margin:0}.remove::part(button){box-sizing:border-box;border-radius:var(--ui-radius-s,4px);width:28px;height:28px;box-shadow:none;background:0 0;justify-content:center;margin:0;padding:0}.remove::part(button):hover{background:oklch(from var(--ui-ink) l c h / .08)}.files.small{font-size:.9em}.files.small::part(list){gap:4px;margin-top:8px}.files.popup::part(list){gap:6px;margin:0}.files.small .file::part(item),.files.popup .file::part(item){min-height:0;box-shadow:none;grid-template-columns:minmax(0,1fr) 64px minmax(120px,max-content) 28px;padding:0}.files.popup .file::part(item){grid-template-columns:minmax(0,1fr) 64px minmax(120px,max-content)}ui-popup{position-visibility:anchors-visible}.popup-rows{min-width:min(var(--_ui-uploader-popup-width), calc(100vw - 32px));gap:6px;display:grid}:host(:state(button)) .choose{margin:0}.zone{box-sizing:border-box;pointer-events:none;background:0 0;border:none;margin:0;padding:8px;position:fixed;inset:auto;overflow:hidden}.zone:not(:popover-open){display:none}.zone ui-segment{height:100%;margin:0;display:block}.zone ui-segment::part(segment){box-sizing:border-box;border:var(--_ui-uploader-border-width) var(--_ui-uploader-border-style) var(--_ui-uploader-lit-color);border-radius:var(--_ui-uploader-radius);background:color-mix(in oklab, var(--_ui-uploader-lit-color) 12%, var(--ui-background,Canvas));height:100%;min-height:0;box-shadow:none;align-items:center;gap:8px;margin:0}.zone ui-icon{color:var(--_ui-uploader-lit-color)}@media (width<768px){.file::part(item){grid-template-columns:20px minmax(0,1fr) auto 32px;row-gap:2px}.file>.status::part(text),.file>ui-progress{grid-area:2/2/auto/4}.files.small::part(list),.files.popup::part(list){gap:12px}.files.small .file::part(item),.files.popup .file::part(item){grid-template-columns:minmax(0,1fr) auto 28px}.files.small .file>.status::part(text),.files.small .file>ui-progress,.files.popup .file>.status::part(text),.files.popup .file>ui-progress{grid-column:1/3}}}@layer ui.components.uploader.states{:host(:state(dragged-over)) .drop-area::part(segment){border-color:var(--_ui-uploader-lit-color);background:color-mix(in oklab, var(--_ui-uploader-lit-color) 10%, transparent)}:host(:state(dragged-over)) .icon{color:var(--_ui-uploader-lit-color)}}", he = /* @__PURE__ */ E("<ui-input class=picker type=file hidden tabindex=-1 aria-hidden=true>", 1), ge = /* @__PURE__ */ E("<div class=zone popover=manual><ui-segment appearance=placeholder color=blue><ui-icon name=\"cloud upload\"size=big></ui-icon><ui-text bold>", 1), _e = /* @__PURE__ */ E("<span class=message><slot>"), ve = /* @__PURE__ */ E("<ui-text class=limits color=grey size=small>", 1), ye = /* @__PURE__ */ E("<ui-segment class=drop-area appearance=placeholder><div class=hero><span class=icon><slot><ui-icon size=big></ui-icon></slot></span><!><!>", 1), be = /* @__PURE__ */ E("<ui-text class=message bold>", 1), xe = /* @__PURE__ */ E("<ui-segment class=drop-area appearance=placeholder padding=compact><div class=line><span class=icon><slot><ui-icon>", 1), Se = /* @__PURE__ */ E("<ui-progress size=tiny color=blue>", 1), Ce = /* @__PURE__ */ E("<div class=summary role=status><span><!><ui-text class=turned-away-count state=error>", 1), we = /* @__PURE__ */ E("<slot><ui-button class=choose>", 1), Te = /* @__PURE__ */ E("<ui-popup open-on=hover position=\"bottom left\"flowing><div class=popup-rows><ui-text class=popup-summary color=grey size=small><!><!><!>", 1), Ee = /* @__PURE__ */ E("<ui-input class=field readonly fluid><ui-button slot=action class=choose>", 1), De = /* @__PURE__ */ E("<span class=choose-slot><slot><ui-button class=choose>", 1), Oe = /* @__PURE__ */ E("<ui-list>", 1), ke = /* @__PURE__ */ E("<ui-icon class=glyph name=\"file outline\">", 1), Ae = /* @__PURE__ */ E("<ui-button class=remove icon=close size=mini appearance=basic>", 1), je = /* @__PURE__ */ E("<ui-item><span class=name></span><ui-text class=size color=grey></ui-text><!><!>", 1), Me = /* @__PURE__ */ E("<ui-icon>", 1), Ne = /* @__PURE__ */ E("<ui-text class=status><!><!>", 1), Pe, O, k, Fe, Ie, A, Le, Re, ze, Be, Ve, He, Ue, We, Ge, Ke, qe, Je, Ye, Xe, Ze, j, M, N, P, F, I, L = class _DOMUploaderElement extends (O = t, Pe = [m], O) {
519
+ constructor() {
520
+ super(...arguments), u(k, 5, this);
521
+ }
522
+ get files() {
523
+ return this.component?.rows.map((e) => e.file) ?? [];
524
+ }
525
+ open() {
526
+ this.component?.openDialog();
527
+ }
528
+ clear() {
529
+ this.component?.clear();
530
+ }
531
+ };
532
+ k = n(O), s(k, 2, "files", Pe, L), l(k, L), i(L, "DOMUploaderElement");
533
+ var Qe = L, R = class _UIUploader extends (j = o, Ze = [ae], Xe = [oe], Ye = [p], Je = [m], qe = [m], Ke = [m], Ge = [m], We = [m], Ue = [p], He = [p], Ve = [p], Be = [ie("dragover")], ze = [ie("drop")], Re = [m], Le = [m], A = [d("isConnected", "dropZone")], Ie = [d("isOverZone", "isReady")], Fe = [d("isUploading")], j) {
534
+ constructor() {
535
+ super(...arguments), u(M, 5, this), f(this, N, u(M, 8, this, [])), u(M, 11, this), r(this, "requests", /* @__PURE__ */ new Map()), r(this, "warnedBoth", !1), r(this, "fileInput"), r(this, "fileInputDrawn", /* @__PURE__ */ i((e) => {
536
+ this.fileInput = e, e.addEventListener("ui-changed", this.onPicked);
537
+ }, "fileInputDrawn")), r(this, "onButtonClick", /* @__PURE__ */ i((e) => {
538
+ e.preventDefault(), this.openDialog();
539
+ }, "onButtonClick")), r(this, "onPicked", u(M, 32, this, /* @__PURE__ */ i((e) => {
540
+ e.stopPropagation();
541
+ let t = e.currentTarget, n = [...t.files];
542
+ n.length && (t.value = "", this.take(_UIUploader.arrivalFromDialog(n, !!this.folder)).catch((e) => c.warn("<ui-uploader>", "couldn't take the files picked", e)));
543
+ }, "onPicked"))), u(M, 35, this), f(this, P, u(M, 12, this, !1)), u(M, 15, this), f(this, F, u(M, 16, this, 0)), u(M, 19, this), f(this, I, u(M, 20, this, !1)), u(M, 23, this), r(this, "dragEnd"), r(this, "zoneOverlay"), r(this, "popupElement"), r(this, "popupHide");
544
+ }
545
+ get look() {
546
+ let e = this.appearance;
547
+ return e && $e.includes(e) ? e : B;
548
+ }
549
+ cssStates() {
550
+ return {
551
+ hero: this.look === B,
552
+ button: this.look === V,
553
+ input: this.look === et,
554
+ compact: this.look === H,
555
+ "dragged-over": this.isDraggedOver,
556
+ uploading: this.isUploading
557
+ };
558
+ }
559
+ get kinds() {
560
+ return re(this.extensions).map((e) => e.replace(/^\./, "").toLowerCase());
561
+ }
562
+ get kindsText() {
563
+ return this.kinds.map((e) => `.${e}`).join(", ");
564
+ }
565
+ get accept() {
566
+ return this.kinds.length ? this.kinds.map((e) => `.${e}`).join(",") : void 0;
567
+ }
568
+ get largest() {
569
+ return _UIUploader.bytesFor(this.maxSize);
570
+ }
571
+ reasonFor(e) {
572
+ let { kinds: t, largest: n } = this, r = /\.([^./]+)$/.exec(e.name)?.[1]?.toLowerCase();
573
+ if (t.length && (!r || !t.includes(r))) return this.refusal("wrongKind", "wrongKindLong", { kinds: this.kindsText });
574
+ if (n !== void 0 && e.size > n) return this.refusal("tooBig", "tooBigLong", { size: this.maxSizeText });
575
+ }
576
+ refusal(e, t, n) {
577
+ return {
578
+ reason: this.translationForKey(e, n),
579
+ why: this.translationForKey(t, n)
580
+ };
581
+ }
582
+ get maxSizeText() {
583
+ let { largest: e } = this;
584
+ return e === void 0 ? "" : this.sizeText(e);
585
+ }
586
+ get limitsText() {
587
+ let e = this.maxFiles, t = this.maxSizeText;
588
+ return e && t ? this.translationForKey("limitsBoth", {
589
+ count: e,
590
+ size: t
591
+ }) : e ? this.translationForKey("limitsFiles", { count: e }) : t ? this.translationForKey("limitsSizeOnly", { size: t }) : "";
592
+ }
593
+ sizeText(e) {
594
+ let [t, n] = e >= Z ? ["MB", Z] : e >= X ? ["KB", X] : ["B", 1], r = +(t === "MB" && e / n < 10);
595
+ return `${a.i18n.formatNumber(e / n, { maximumFractionDigits: r })} ${t}`;
596
+ }
597
+ get keptRows() {
598
+ return this.rows.filter((e) => e.status !== Y);
599
+ }
600
+ get doneCount() {
601
+ return this.rows.filter((e) => e.status === K || e.status === q).length;
602
+ }
603
+ get turnedAwayCount() {
604
+ return this.rows.filter((e) => e.status === Y).length;
605
+ }
606
+ get isUploading() {
607
+ return this.rows.some((e) => e.status === W || e.status === G);
608
+ }
609
+ get overallPercent() {
610
+ let e = this.keptRows, t = e.reduce((e, t) => e + t.file.size, 0);
611
+ if (!t) return this.isUploading ? 0 : 100;
612
+ let n = e.reduce((e, t) => e + (t.status === G ? t.sent : at.has(t.status) ? t.file.size : 0), 0);
613
+ return Math.round(100 * n / t);
614
+ }
615
+ changeRow(e, t) {
616
+ this.rows = this.rows.map((n) => n.id === e ? {
617
+ ...n,
618
+ ...t
619
+ } : n);
620
+ }
621
+ rowFor(e) {
622
+ return this.rows.find((t) => t.id === e);
623
+ }
624
+ remove(e) {
625
+ this.requests.get(e)?.abort(), this.requests.delete(e), this.rows = this.rows.filter((t) => t.id !== e);
626
+ }
627
+ clear() {
628
+ for (let e of this.requests.values()) e.abort();
629
+ this.requests.clear(), this.rows = [];
630
+ }
631
+ async take(e) {
632
+ if (this.isDisabled) return;
633
+ let { via: t } = e, n = !!this.folder;
634
+ this.multiple || this.clear();
635
+ let r = /* @__PURE__ */ i((e, t) => ({
636
+ ...e,
637
+ ...t
638
+ }), "turnedAway"), a = n ? e.folders : [], o = [];
639
+ for (let t of n ? e.files : e.folders.map(_UIUploader.folderAsFile)) {
640
+ let e = n ? this.refusal("notAFolder", "notAFolderLong") : this.refusal("aFolder", "aFolderLong");
641
+ o.push(r(t, e));
642
+ }
643
+ n || o.unshift(...e.files);
644
+ let s = this.keptRows.length, c = /* @__PURE__ */ i((e) => {
645
+ if (e.reason) return e;
646
+ let t = this.reasonFor(e.file);
647
+ return t ? r(e, t) : !this.multiple && !n && s >= 1 ? r(e, this.refusal("oneOnly", "oneOnlyLong")) : this.maxFiles && s >= this.maxFiles ? r(e, this.refusal("tooMany", "tooManyLong", { count: this.maxFiles })) : (s++, e);
648
+ }, "checked"), l = [];
649
+ for (let [e, n] of a.entries()) {
650
+ let i = { ..._UIUploader.folderDetail(n, t) };
651
+ if (!this.multiple && e > 0) {
652
+ let e = this.refusal("oneOnly", "oneOnlyLong");
653
+ i.reason = e.reason;
654
+ for (let t of n.files) l.push(r(t, e));
655
+ } else this.send("ui-folder-dropping", i) && (this.send("ui-folder-dropped", i), l.push(...n.files.map(c)));
656
+ }
657
+ l.push(...o.map(c));
658
+ let u = [];
659
+ for (let e of l) {
660
+ let n = _UIUploader.fileDetail(e, t);
661
+ this.send("ui-file-dropping", n) ? (this.send("ui-file-dropped", n), u.push({
662
+ id: ++ft,
663
+ file: e.file,
664
+ path: e.path,
665
+ status: e.reason ? Y : W,
666
+ sent: 0,
667
+ reason: e.reason,
668
+ why: e.why
669
+ })) : e.reason || s--;
670
+ }
671
+ u.length && (this.rows = [...this.rows, ...u], await this.upload(u.filter((e) => e.status === W)));
672
+ }
673
+ static folderAsFile(e) {
674
+ return {
675
+ file: new File([], e.name),
676
+ path: e.path,
677
+ entry: e.entry,
678
+ handle: e.handle
679
+ };
680
+ }
681
+ static fileDetail({ file: e, path: t, entry: n, handle: r, reason: i }, a) {
682
+ let { name: o, size: s, type: c, lastModified: l } = e;
683
+ return {
684
+ file: e,
685
+ name: o,
686
+ path: t,
687
+ size: s,
688
+ type: c,
689
+ lastModified: l,
690
+ via: a,
691
+ reason: i,
692
+ entry: n,
693
+ handle: r
694
+ };
695
+ }
696
+ static folderDetail({ name: e, path: t, files: n, entry: r, handle: i }, a) {
697
+ return {
698
+ name: e,
699
+ path: t,
700
+ files: n.map((e) => e.file),
701
+ via: a,
702
+ reason: void 0,
703
+ entry: r,
704
+ handle: i
705
+ };
706
+ }
707
+ async upload(e) {
708
+ if (!e.length) return;
709
+ let t = e.map((e) => e.file), n = typeof this.action == "function" ? this.action : void 0, { destination: r } = this;
710
+ if (!this.send("ui-uploading", { files: t }) || !n && !r) for (let t of e) this.changeRow(t.id, { status: it });
711
+ else {
712
+ if (n && r && !this.warnedBoth && (this.warnedBoth = !0, c.warn("<ui-uploader>", "both `action` and `destination` are set: the action takes the files", this.domElement)), n) return this.callAction(n, e);
713
+ await Promise.all(e.map((e) => this.post(e, r)));
714
+ }
715
+ }
716
+ async callAction(e, t) {
717
+ for (let e of t) this.changeRow(e.id, { status: G });
718
+ try {
719
+ let n = await e(t.map((e) => e.file));
720
+ for (let e of t) this.rowFor(e.id) && (this.changeRow(e.id, { status: q }), this.send("ui-uploaded", {
721
+ file: e.file,
722
+ response: n
723
+ }));
724
+ } catch (e) {
725
+ let n = e instanceof Error ? e : Error(String(e));
726
+ for (let e of t) this.rowFor(e.id) && (this.changeRow(e.id, {
727
+ status: J,
728
+ reason: n.message
729
+ }), this.send("ui-upload-failed", {
730
+ file: e.file,
731
+ error: n
732
+ }));
733
+ }
734
+ }
735
+ post(e, t) {
736
+ let { file: n, id: r } = e, i = new XMLHttpRequest();
737
+ return this.requests.set(r, i), this.changeRow(r, { status: G }), new Promise((a) => {
738
+ i.upload.addEventListener("progress", (e) => {
739
+ this.rowFor(r) && (this.changeRow(r, { sent: e.loaded }), this.send("ui-upload-progress", {
740
+ file: n,
741
+ sent: e.loaded,
742
+ size: e.total || n.size
743
+ }));
744
+ }), i.addEventListener("loadend", () => {
745
+ this.requests.delete(r), this.rowFor(r) && i.readyState === XMLHttpRequest.DONE && i.status !== 0 ? this.posted(e, i, t) : this.rowFor(r) && this.failed(e, /* @__PURE__ */ Error(`<ui-uploader>: couldn't reach ${t}`), this.translationForKey("noConnection")), a();
746
+ });
747
+ let o = new FormData();
748
+ o.append(ct, n, e.path || n.name), i.open("POST", t), i.send(o);
749
+ });
750
+ }
751
+ posted(t, n, r) {
752
+ let { status: i } = n, a = n.getResponseHeader("content-type") ?? "";
753
+ if (i >= 200 && i < 300) {
754
+ this.changeRow(t.id, {
755
+ status: K,
756
+ sent: t.file.size
757
+ }), this.send("ui-uploaded", {
758
+ file: t.file,
759
+ response: _UIUploader.answerOf(n.responseText, a)
760
+ });
761
+ return;
762
+ }
763
+ let o = new Response(n.responseText, {
764
+ status: i,
765
+ statusText: n.statusText,
766
+ headers: { "content-type": a }
767
+ }), s = new e(`<ui-uploader>: POST ${r} answered ${i} ${n.statusText}`.trim(), { cause: { response: o } });
768
+ this.failed(t, s, this.translationForKey("serverError", { status: i }));
769
+ }
770
+ failed(e, t, n) {
771
+ this.changeRow(e.id, {
772
+ status: J,
773
+ reason: n
774
+ }), this.send("ui-upload-failed", {
775
+ file: e.file,
776
+ error: t
777
+ });
778
+ }
779
+ static answerOf(e, t) {
780
+ if (!/json/i.test(t)) return e;
781
+ try {
782
+ return JSON.parse(e);
783
+ } catch {
784
+ return e;
785
+ }
786
+ }
787
+ openDialog() {
788
+ if (!this.isDisabled) try {
789
+ this.fileInput?.showPicker();
790
+ } catch (e) {
791
+ c.warn("<ui-uploader>", "the browser wouldn't open the file dialog", e);
792
+ }
793
+ }
794
+ static arrivalFromDialog(e, t) {
795
+ if (!t) return {
796
+ via: tt,
797
+ files: e.map((e) => ({
798
+ file: e,
799
+ path: e.name
800
+ })),
801
+ folders: []
802
+ };
803
+ let n = /* @__PURE__ */ new Map();
804
+ for (let t of e) {
805
+ let e = t.webkitRelativePath || t.name, r = e.split("/")[0], i = n.get(r);
806
+ i || n.set(r, i = {
807
+ name: r,
808
+ path: r,
809
+ files: []
810
+ }), i.files.push({
811
+ file: t,
812
+ path: e
813
+ });
814
+ }
815
+ return {
816
+ via: tt,
817
+ files: [],
818
+ folders: [...n.values()]
819
+ };
820
+ }
821
+ onDragOver(e) {
822
+ _UIUploader.hasFiles(e) && !this.isDisabled && (Q.add(e), this.draggedOver(e, nt));
823
+ }
824
+ onDrop(e) {
825
+ _UIUploader.hasFiles(e) && !this.isDisabled && (Q.add(e), this.dropped(e, nt));
826
+ }
827
+ draggedOver(e, t) {
828
+ if (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), this.dragEnd?.cancel(), this.dragEnd = ee(lt, () => this.dragOver(t)), this.isOverZone = t === U, this.isDraggedOver) return;
829
+ let n = _UIUploader.dragDetail(e, t);
830
+ this.isDraggedOver = !0, this.draggedCount = n.count, this.send(this.folder ? "ui-folder-dragged-over" : "ui-file-dragged-over", n);
831
+ }
832
+ dragOver(e, t = !1) {
833
+ if (this.dragEnd?.cancel(), this.dragEnd = void 0, !this.isDraggedOver) return;
834
+ let n = this.draggedCount;
835
+ this.isDraggedOver = !1, this.isOverZone = !1, this.draggedCount = 0, t || this.send(this.folder ? "ui-folder-dragged-out" : "ui-file-dragged-out", {
836
+ count: n,
837
+ kinds: [],
838
+ via: e
839
+ });
840
+ }
841
+ dropped(e, t) {
842
+ e.preventDefault(), this.dragOver(t, !0);
843
+ let n = _UIUploader.itemsOf(e.dataTransfer);
844
+ _UIUploader.arrivalFromDrop(n, t).then((e) => this.take(e)).catch((e) => c.warn("<ui-uploader>", "couldn't read what was dropped", e));
845
+ }
846
+ static hasFiles(e) {
847
+ return !!e.dataTransfer?.types.includes("Files");
848
+ }
849
+ static dragDetail(e, t) {
850
+ let n = [...e.dataTransfer?.items ?? []].filter((e) => e.kind === "file");
851
+ return {
852
+ count: n.length,
853
+ kinds: n.map((e) => e.type),
854
+ via: t
855
+ };
856
+ }
857
+ static itemsOf(e) {
858
+ if (!e) return [];
859
+ let t = [...e.items].filter((e) => e.kind === "file");
860
+ return t.length ? t.map((e) => {
861
+ let t = e;
862
+ return {
863
+ file: e.getAsFile() ?? void 0,
864
+ entry: e.webkitGetAsEntry?.() ?? void 0,
865
+ handle: t.getAsFileSystemHandle?.().catch(() => null)
866
+ };
867
+ }) : [...e.files].map((e) => ({ file: e }));
868
+ }
869
+ static async arrivalFromDrop(e, t) {
870
+ let n = {
871
+ via: t,
872
+ files: [],
873
+ folders: []
874
+ };
875
+ for (let t of e) {
876
+ let e = await t.handle ?? void 0, { entry: r } = t;
877
+ if (r?.isDirectory) {
878
+ let t = await _UIUploader.filesIn(r);
879
+ n.folders.push({
880
+ name: r.name,
881
+ path: r.name,
882
+ files: t,
883
+ entry: r,
884
+ handle: e
885
+ });
886
+ } else t.file && n.files.push({
887
+ file: t.file,
888
+ path: t.file.name,
889
+ entry: r,
890
+ handle: e
891
+ });
892
+ }
893
+ return n;
894
+ }
895
+ static async filesIn(e) {
896
+ let t = [], n = e.createReader();
897
+ for (;;) {
898
+ let e = await new Promise((e, t) => n.readEntries(e, t));
899
+ if (!e.length) break;
900
+ for (let n of e) if (n.isDirectory) t.push(...await _UIUploader.filesIn(n));
901
+ else {
902
+ let e = await new Promise((e, t) => n.file(e, t));
903
+ t.push({
904
+ file: e,
905
+ path: n.fullPath.replace(/^\//, ""),
906
+ entry: n
907
+ });
908
+ }
909
+ }
910
+ return t;
911
+ }
912
+ get zoneElement() {
913
+ if (x) return;
914
+ let e = this.dropZone;
915
+ if (e) {
916
+ if (typeof e == "object" && e.nodeType === Node.ELEMENT_NODE) return e;
917
+ if (typeof e == "string") {
918
+ if (e === rt) return document.documentElement;
919
+ try {
920
+ return ne(this.domElement, e) || (this.domElement.getRootNode().querySelector(e) ?? document.querySelector(e) ?? void 0);
921
+ } catch {
922
+ c.warn("<ui-uploader drop-zone>", `${JSON.stringify(e)} is no selector: write \`page\`, or a selector`);
923
+ return;
924
+ }
925
+ }
926
+ }
927
+ }
928
+ onZoneChanged(e) {
929
+ if (!e || x) return;
930
+ let t = this.zoneElement;
931
+ if (t) return $.add(t, this), () => $.remove(t, this);
932
+ }
933
+ get zoneBox() {
934
+ let e = this.isOverZone ? this.zoneElement : void 0;
935
+ return !e || e === document.documentElement ? {
936
+ top: 0,
937
+ left: 0,
938
+ width: innerWidth,
939
+ height: innerHeight
940
+ } : _UIUploader.boxOf(e);
941
+ }
942
+ static boxOf(e) {
943
+ let t = e.getBoundingClientRect();
944
+ if (t.width || t.height) return {
945
+ top: t.top,
946
+ left: t.left,
947
+ width: t.width,
948
+ height: t.height
949
+ };
950
+ let n = [...e.shadowRoot?.children ?? e.children].map((e) => e.getBoundingClientRect()).filter((e) => e.width || e.height);
951
+ if (!n.length) return {
952
+ top: t.top,
953
+ left: t.left,
954
+ width: 0,
955
+ height: 0
956
+ };
957
+ let r = Math.min(...n.map((e) => e.top)), i = Math.min(...n.map((e) => e.left)), a = Math.max(...n.map((e) => e.bottom));
958
+ return {
959
+ top: r,
960
+ left: i,
961
+ width: Math.max(...n.map((e) => e.right)) - i,
962
+ height: a - r
963
+ };
964
+ }
965
+ zoneOverlayDrawn(e) {
966
+ !x && e.showPopover && (this.isOverZone && !e.matches(":popover-open") ? e.showPopover() : !this.isOverZone && e.matches(":popover-open") && e.hidePopover());
967
+ }
968
+ onOverZoneChanged() {
969
+ this.zoneOverlay && this.zoneOverlayDrawn(this.zoneOverlay);
970
+ }
971
+ static filled(e, t) {
972
+ return e.replace(/\{(\w+)\}/g, (e, n) => String(t[n] ?? e));
973
+ }
974
+ get messageText() {
975
+ if (this.message) return this.message;
976
+ let e = this.kindsText, [t, n, r] = this.look === H ? [
977
+ "compactMessage",
978
+ "compactMessageAny",
979
+ "compactMessageFolders"
980
+ ] : this.look === V ? [
981
+ "buttonLabel",
982
+ "buttonLabelAny",
983
+ "buttonLabelFolders"
984
+ ] : [
985
+ "message",
986
+ "messageAny",
987
+ "messageFolders"
988
+ ];
989
+ return this.folder ? this.translationForKey(r) : e ? this.translationForKey(t, { kinds: e }) : this.translationForKey(n);
990
+ }
991
+ get dropText() {
992
+ let e = this.draggedCount;
993
+ return this.dropMessage ? _UIUploader.filled(this.dropMessage, { count: e }) : e === 1 ? this.translationForKey("dropMessageOne") : this.translationForKey("dropMessage", { count: e });
994
+ }
995
+ get statusText() {
996
+ let e = this.keptRows.length, t = this.doneCount;
997
+ return this.isUploading ? this.uploadingMessage ? _UIUploader.filled(this.uploadingMessage, {
998
+ done: t,
999
+ count: e
1000
+ }) : this.translationForKey("uploadingMessage", {
1001
+ done: t,
1002
+ count: e
1003
+ }) : t ? this.doneMessage ? _UIUploader.filled(this.doneMessage, { count: t }) : t === 1 ? this.translationForKey("doneMessageOne") : this.translationForKey("doneMessage", { count: t }) : "";
1004
+ }
1005
+ get turnedAwayText() {
1006
+ let e = this.turnedAwayCount;
1007
+ return e ? e === 1 ? this.translationForKey("turnedAwayOne") : this.translationForKey("turnedAway", { count: e }) : "";
1008
+ }
1009
+ statusOf(e) {
1010
+ return e.status === K ? this.translationForKey("uploaded") : e.status === q ? this.translationForKey("taken") : e.status === it ? this.translationForKey("held") : e.status === J ? this.translationForKey("failed", { reason: e.reason ?? "" }) : e.reason ?? "";
1011
+ }
1012
+ get buttonText() {
1013
+ return this.isDraggedOver ? this.dropText : this.isUploading ? this.statusText : this.messageText;
1014
+ }
1015
+ get fieldText() {
1016
+ let e = this.rows.length;
1017
+ if (!e || this.isDraggedOver) return "";
1018
+ let t = this.doneCount;
1019
+ return t ? this.translationForKey("fileCountDone", {
1020
+ count: e,
1021
+ done: t
1022
+ }) : this.translationForKey("fileCount", { count: e });
1023
+ }
1024
+ popupDrawn(e, t) {
1025
+ this.popupElement = e, t && (e.target = t), this.isUploading && this.glimpse(e);
1026
+ }
1027
+ onUploadingChanged(e) {
1028
+ let t = this.popupElement;
1029
+ this.look === V && t && e && this.glimpse(t);
1030
+ }
1031
+ glimpse(e) {
1032
+ this.popupHide?.cancel(), e.hidden = !1, this.popupHide = ee(ut, () => {
1033
+ this.domElement.matches(":hover, :focus-within") || (e.hidden = !0);
1034
+ });
1035
+ }
1036
+ render() {
1037
+ let e = this;
1038
+ return [
1039
+ (() => {
1040
+ var t = he(), n = e.fileInputDrawn;
1041
+ return typeof n == "function" || Array.isArray(n) ? C(() => n, t) : e.fileInputDrawn = t, t._$owner = y(), v(() => ({
1042
+ e: e.folder ? void 0 : e.accept,
1043
+ t: !!e.multiple || !!e.folder,
1044
+ a: !!e.folder
1045
+ }), ({ e, t: n, a: r }, i) => {
1046
+ e !== i?.e && w(t, "accept", e), n !== i?.t && w(t, "multiple", n), r !== i?.a && w(t, "folder", r);
1047
+ }), t;
1048
+ })(),
1049
+ _(h, {
1050
+ get when() {
1051
+ return e.look === V;
1052
+ },
1053
+ get children() {
1054
+ return e.buttonLook();
1055
+ }
1056
+ }),
1057
+ _(h, {
1058
+ get when() {
1059
+ return e.look === et;
1060
+ },
1061
+ get children() {
1062
+ return e.inputLook();
1063
+ }
1064
+ }),
1065
+ _(h, {
1066
+ get when() {
1067
+ return e.look === H;
1068
+ },
1069
+ get children() {
1070
+ return e.compactLook();
1071
+ }
1072
+ }),
1073
+ _(h, {
1074
+ get when() {
1075
+ return e.look === B;
1076
+ },
1077
+ get children() {
1078
+ return e.heroLook();
1079
+ }
1080
+ }),
1081
+ _(h, {
1082
+ get when() {
1083
+ return e.dropZone;
1084
+ },
1085
+ get children() {
1086
+ return e.zoneOverlayBox();
1087
+ }
1088
+ })
1089
+ ];
1090
+ }
1091
+ zoneOverlayBox() {
1092
+ let e = this;
1093
+ return (() => {
1094
+ var t = ge(), n = t.firstChild, r = n.firstChild, i = r.nextSibling;
1095
+ return C(() => (t) => {
1096
+ e.zoneOverlay = t, e.zoneOverlayDrawn(t);
1097
+ }, t), n._$owner = y(), r._$owner = y(), i._$owner = y(), b(i, () => e.dropText), v(() => ({
1098
+ e: e.partForName("zone"),
1099
+ t: `${e.zoneBox.top}px`,
1100
+ a: `${e.zoneBox.left}px`,
1101
+ o: `${e.zoneBox.width}px`,
1102
+ i: `${e.zoneBox.height}px`
1103
+ }), ({ e, t: n, a: r, o: i, i: a }, o) => {
1104
+ e !== o?.e && w(t, "part", e), n !== o?.t && T(t, "top", n), r !== o?.a && T(t, "left", r), i !== o?.o && T(t, "width", i), a !== o?.i && T(t, "height", a);
1105
+ }), t;
1106
+ })();
1107
+ }
1108
+ heroLook() {
1109
+ let e = this;
1110
+ return [(() => {
1111
+ var t = ye(), n = t.firstChild, r = n.firstChild, i = r.firstChild, a = i.firstChild, o = r.nextSibling, s = o.nextSibling;
1112
+ return t._$owner = y(), i._$owner = y(), a._$owner = y(), b(n, _(h, {
1113
+ get when() {
1114
+ return !e.isDraggedOver;
1115
+ },
1116
+ get fallback() {
1117
+ var t = be();
1118
+ return t._$owner = y(), b(t, () => e.dropText), t;
1119
+ },
1120
+ get children() {
1121
+ return [(() => {
1122
+ var t = _e(), n = t.firstChild;
1123
+ return n._$owner = y(), b(n, () => e.messageText), v(() => e.slotForName("message"), (e) => {
1124
+ w(n, "name", e);
1125
+ }), t;
1126
+ })(), S(() => e.chooseButton(e.translationForKey(e.folder ? "chooseFolders" : "choose")))];
1127
+ }
1128
+ }), o), b(n, _(h, {
1129
+ get when() {
1130
+ return e.limitsText;
1131
+ },
1132
+ get children() {
1133
+ var t = ve();
1134
+ return t._$owner = y(), b(t, () => e.limitsText), t;
1135
+ }
1136
+ }), s), v(() => ({
1137
+ e: e.partForName("drop-area"),
1138
+ t: e.isDraggedOver && !e.isOverZone ? "blue" : void 0,
1139
+ a: e.slotForName("icon"),
1140
+ o: e.folder ? "folder outline" : "cloud upload"
1141
+ }), ({ e, t: n, a: r, o }, s) => {
1142
+ e !== s?.e && w(t, "part", e), n !== s?.t && w(t, "color", n), r !== s?.a && w(i, "name", r), o !== s?.o && w(a, "name", o);
1143
+ }), t;
1144
+ })(), S(() => e.fileRows())];
1145
+ }
1146
+ compactLook() {
1147
+ let e = this;
1148
+ return [(() => {
1149
+ var t = xe(), n = t.firstChild, r = n.firstChild.firstChild, i = r.firstChild;
1150
+ return t._$owner = y(), r._$owner = y(), i._$owner = y(), b(n, _(h, {
1151
+ get when() {
1152
+ return !e.isDraggedOver;
1153
+ },
1154
+ get fallback() {
1155
+ var t = be();
1156
+ return t._$owner = y(), b(t, () => e.dropText), t;
1157
+ },
1158
+ get children() {
1159
+ return [(() => {
1160
+ var t = _e(), n = t.firstChild;
1161
+ return n._$owner = y(), b(n, () => e.messageText), v(() => e.slotForName("message"), (e) => {
1162
+ w(n, "name", e);
1163
+ }), t;
1164
+ })(), S(() => e.chooseButton(e.translationForKey("chooseShort"), "mini"))];
1165
+ }
1166
+ }), null), v(() => ({
1167
+ e: e.partForName("drop-area"),
1168
+ t: e.isDraggedOver && !e.isOverZone ? "blue" : void 0,
1169
+ a: e.slotForName("icon"),
1170
+ o: e.folder ? "folder outline" : "cloud upload"
1171
+ }), ({ e, t: n, a, o }, s) => {
1172
+ e !== s?.e && w(t, "part", e), n !== s?.t && w(t, "color", n), a !== s?.a && w(r, "name", a), o !== s?.o && w(i, "name", o);
1173
+ }), t;
1174
+ })(), _(h, {
1175
+ get when() {
1176
+ return e.rows.length;
1177
+ },
1178
+ get children() {
1179
+ var t = Ce(), n = t.firstChild, r = n.firstChild, i = r.nextSibling;
1180
+ return b(n, _(h, {
1181
+ get when() {
1182
+ return e.statusText;
1183
+ },
1184
+ get children() {
1185
+ return e.statusText;
1186
+ }
1187
+ }), r), b(n, _(h, {
1188
+ get when() {
1189
+ return S(() => !!e.statusText)() ? e.turnedAwayText : e.statusText;
1190
+ },
1191
+ children: " · "
1192
+ }), i), i._$owner = y(), b(i, () => e.turnedAwayText), b(t, _(h, {
1193
+ get when() {
1194
+ return e.isUploading;
1195
+ },
1196
+ get children() {
1197
+ var t = Se();
1198
+ return t._$owner = y(), v(() => ({
1199
+ e: e.partForName("progress"),
1200
+ t: String(e.overallPercent),
1201
+ a: e.translationForKey("uploading")
1202
+ }), ({ e, t: n, a: r }, i) => {
1203
+ e !== i?.e && w(t, "part", e), n !== i?.t && w(t, "value", n), r !== i?.a && w(t, "aria-label", r);
1204
+ }), t;
1205
+ }
1206
+ }), null), v(() => e.partForName("status"), (e) => {
1207
+ w(t, "part", e);
1208
+ }), t;
1209
+ }
1210
+ })];
1211
+ }
1212
+ buttonLook() {
1213
+ let e, t = this;
1214
+ return [(() => {
1215
+ var n = we(), r = n.firstChild;
1216
+ return g(n, "click", t.onButtonClick, !0), n._$owner = y(), C(() => (t) => e = t, r), r._$owner = y(), b(r, () => t.buttonText), v(() => ({
1217
+ e: t.slotForName("button"),
1218
+ t: t.partForName("button"),
1219
+ a: t.folder ? "folder outline" : "cloud upload",
1220
+ o: t.isDraggedOver || t.isUploading ? "blue" : void 0,
1221
+ i: t.isUploading ? "basic" : void 0,
1222
+ n: t.isDisabled ? "" : void 0,
1223
+ s: t.limitsText || void 0
1224
+ }), ({ e, t, a: i, o: a, i: o, n: s, s: c }, l) => {
1225
+ e !== l?.e && w(n, "name", e), t !== l?.t && w(r, "part", t), i !== l?.a && w(r, "icon", i), a !== l?.o && w(r, "color", a), o !== l?.i && w(r, "appearance", o), s !== l?.n && w(r, "disabled", s), c !== l?.s && w(r, "data-tooltip", c);
1226
+ }), n;
1227
+ })(), _(h, {
1228
+ get when() {
1229
+ return t.rows.length;
1230
+ },
1231
+ get children() {
1232
+ var n = Te(), r = n.firstChild, i = r.firstChild, a = i.firstChild, o = a.nextSibling, s = o.nextSibling;
1233
+ return C(() => (n) => t.popupDrawn(n, e), n), n._$owner = y(), i._$owner = y(), b(i, _(h, {
1234
+ get when() {
1235
+ return t.statusText;
1236
+ },
1237
+ get children() {
1238
+ return t.statusText;
1239
+ }
1240
+ }), a), b(i, _(h, {
1241
+ get when() {
1242
+ return S(() => !!t.statusText)() ? t.turnedAwayText : t.statusText;
1243
+ },
1244
+ children: ". "
1245
+ }), o), b(i, () => t.turnedAwayText, s), b(r, () => t.fileRows("popup"), null), v(() => t.partForName("popup"), (e) => {
1246
+ w(n, "part", e);
1247
+ }), n;
1248
+ }
1249
+ })];
1250
+ }
1251
+ inputLook() {
1252
+ let e = this;
1253
+ return [(() => {
1254
+ var t = Ee(), n = t.firstChild;
1255
+ return g(t, "click", e.onButtonClick, !0), t._$owner = y(), n._$owner = y(), b(n, () => e.translationForKey("browse")), v(() => ({
1256
+ e: e.partForName("input"),
1257
+ t: e.fieldText,
1258
+ a: e.isDraggedOver ? e.dropText : e.translationForKey("noFiles"),
1259
+ o: e.isDraggedOver ? "info" : void 0,
1260
+ i: e.attributes["aria-label"] ?? e.messageText,
1261
+ n: e.partForName("button"),
1262
+ s: e.isDraggedOver ? "blue" : void 0
1263
+ }), ({ e, t: r, a: i, o: a, i: o, n: s, s: c }, l) => {
1264
+ e !== l?.e && w(t, "part", e), r !== l?.t && w(t, "value", r), i !== l?.a && w(t, "placeholder", i), a !== l?.o && w(t, "state", a), o !== l?.i && w(t, "aria-label", o), s !== l?.n && w(n, "part", s), c !== l?.s && w(n, "color", c);
1265
+ }), t;
1266
+ })(), S(() => e.fileRows("small"))];
1267
+ }
1268
+ chooseButton(e, t) {
1269
+ let n = this;
1270
+ var r = De(), i = r.firstChild, a = i.firstChild;
1271
+ return g(r, "click", n.onButtonClick, !0), i._$owner = y(), w(a, "size", t), a._$owner = y(), b(a, e), v(() => ({
1272
+ e: n.slotForName("button"),
1273
+ t: n.partForName("button")
1274
+ }), ({ e, t }, n) => {
1275
+ e !== n?.e && w(i, "name", e), t !== n?.t && w(a, "part", t);
1276
+ }), r;
1277
+ }
1278
+ fileRows(e) {
1279
+ let t = this;
1280
+ return _(h, {
1281
+ get when() {
1282
+ return t.rows.length;
1283
+ },
1284
+ get children() {
1285
+ var n = Oe();
1286
+ return n._$owner = y(), b(n, _(se, {
1287
+ get each() {
1288
+ return t.rows;
1289
+ },
1290
+ keyed: (e) => e.id,
1291
+ children: (n) => (() => {
1292
+ var r = je(), i = r.firstChild, a = i.nextSibling, o = a.nextSibling, s = o.nextSibling;
1293
+ return r._$owner = y(), b(r, _(h, {
1294
+ when: !e,
1295
+ get children() {
1296
+ var e = ke();
1297
+ return e._$owner = y(), e;
1298
+ }
1299
+ }), i), b(i, () => n().file.name), a._$owner = y(), b(a, () => t.sizeText(n().file.size)), b(r, _(h, {
1300
+ get when() {
1301
+ return n().status === G;
1302
+ },
1303
+ get fallback() {
1304
+ var e = Ne(), r = e.firstChild, i = r.nextSibling;
1305
+ return e._$owner = y(), b(e, _(h, {
1306
+ get when() {
1307
+ return ot[n().status];
1308
+ },
1309
+ get children() {
1310
+ var e = Me();
1311
+ return e._$owner = y(), v(() => ot[n().status], (t) => {
1312
+ w(e, "name", t);
1313
+ }), e;
1314
+ }
1315
+ }), r), b(e, () => t.statusOf(n()), i), v(() => ({
1316
+ e: t.partForName("status"),
1317
+ t: st[n().status]?.state,
1318
+ a: st[n().status]?.color,
1319
+ o: n().why
1320
+ }), ({ e: t, t: n, a: r, o: i }, a) => {
1321
+ t !== a?.e && w(e, "part", t), n !== a?.t && w(e, "state", n), r !== a?.a && w(e, "color", r), i !== a?.o && w(e, "data-tooltip", i);
1322
+ }), e;
1323
+ },
1324
+ get children() {
1325
+ var e = Se();
1326
+ return e._$owner = y(), v(() => ({
1327
+ e: t.partForName("progress"),
1328
+ t: String(n().file.size ? Math.round(100 * n().sent / n().file.size) : 0),
1329
+ a: t.translationForKey("uploading")
1330
+ }), ({ e: t, t: n, a: r }, i) => {
1331
+ t !== i?.e && w(e, "part", t), n !== i?.t && w(e, "value", n), r !== i?.a && w(e, "aria-label", r);
1332
+ }), e;
1333
+ }
1334
+ }), o), b(r, _(h, {
1335
+ when: e !== "popup",
1336
+ get children() {
1337
+ var e = Ae();
1338
+ return e._$$click = () => t.remove(n().id), e._$owner = y(), v(() => ({
1339
+ e: t.partForName("remove"),
1340
+ t: t.translationForKey("remove"),
1341
+ a: t.translationForKey("remove")
1342
+ }), ({ e: t, t: n, a: r }, i) => {
1343
+ t !== i?.e && w(e, "part", t), n !== i?.t && w(e, "aria-label", n), r !== i?.a && w(e, "data-tooltip", r);
1344
+ }), e;
1345
+ }
1346
+ }), s), v(() => ({
1347
+ e: ue(["file", n().status.replace(" ", "-")]),
1348
+ t: t.partForName("file"),
1349
+ a: t.partForName("name"),
1350
+ o: n().path === n().file.name ? void 0 : n().path,
1351
+ i: t.partForName("size")
1352
+ }), ({ e, t, a: n, o, i: s }, c) => {
1353
+ ce(r, e, c?.e), t !== c?.t && w(r, "part", t), n !== c?.a && w(i, "part", n), o !== c?.o && w(i, "data-tooltip", o), s !== c?.i && w(a, "part", s);
1354
+ }), r;
1355
+ })()
1356
+ })), v(() => ({
1357
+ e: ue(["files", e]),
1358
+ t: t.partForName("files"),
1359
+ a: t.translationForKey("files")
1360
+ }), ({ e, t, a: r }, i) => {
1361
+ ce(n, e, i?.e), t !== i?.t && w(n, "part", t), r !== i?.a && w(n, "aria-label", r);
1362
+ }), n;
1363
+ }
1364
+ });
1365
+ }
1366
+ static bytesFor(e) {
1367
+ if (!e) return;
1368
+ let t = /^\s*([\d.]+)\s*(b|bytes?|kb|mb|gb)?\s*$/i.exec(e);
1369
+ if (!t) {
1370
+ c.warn("<ui-uploader max-size>", `can't read ${JSON.stringify(e)}: write \`2 MB\`, \`500 KB\` or bytes`);
1371
+ return;
1372
+ }
1373
+ let n = (t[2] ?? "b").toLowerCase();
1374
+ return Math.round(Number(t[1]) * (dt[n[0]] ?? 1));
1375
+ }
1376
+ };
1377
+ M = n(j), N = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), s(M, 4, "rows", Ye, R, N), s(M, 1, "remove", Je, R), s(M, 1, "clear", qe, R), s(M, 1, "take", Ke, R), s(M, 1, "openDialog", Ge, R), s(M, 4, "isDraggedOver", Ue, R, P), s(M, 4, "draggedCount", He, R, F), s(M, 4, "isOverZone", Ve, R, I), s(M, 1, "onDragOver", Be, R), s(M, 1, "onDrop", ze, R), s(M, 1, "draggedOver", Re, R), s(M, 1, "dropped", Le, R), s(M, 1, "onZoneChanged", A, R), s(M, 1, "onOverZoneChanged", Ie, R), s(M, 1, "onUploadingChanged", Fe, R), s(M, 13, "vocabulary", Ze, R), s(M, 13, "elementSetup", Xe, R), s(M, 5, "onPicked", We, R), l(M, R), i(R, "UIUploader"), r(R, "vocabulary", u(M, 24, R, pe)), u(M, 27, R), r(R, "elementSetup", u(M, 28, R, {
1378
+ styleSheets: { uploader: me },
1379
+ DOMElement: Qe
1380
+ })), u(M, 31, R);
1381
+ var z = R, $e = [
1382
+ "hero",
1383
+ "button",
1384
+ "input",
1385
+ "compact"
1386
+ ], [B, V, et, H] = $e, tt = "dialog", nt = "drop", U = "zone", rt = "page", [W, G, K, q, it, J, Y] = [
1387
+ "waiting",
1388
+ "uploading",
1389
+ "uploaded",
1390
+ "taken",
1391
+ "held",
1392
+ "failed",
1393
+ "turned away"
1394
+ ], at = /* @__PURE__ */ new Set([K, q]), ot = {
1395
+ held: "circle outline",
1396
+ uploaded: "check circle",
1397
+ taken: "check circle",
1398
+ failed: "exclamation triangle",
1399
+ "turned away": "exclamation circle"
1400
+ }, st = {
1401
+ held: { color: "grey" },
1402
+ uploaded: { state: "success" },
1403
+ taken: { state: "success" },
1404
+ failed: { state: "error" },
1405
+ "turned away": { state: "error" }
1406
+ }, ct = "file", lt = .25, ut = 2, X = 1024, Z = X * X, dt = {
1407
+ b: 1,
1408
+ k: X,
1409
+ m: Z,
1410
+ g: Z * X
1411
+ }, Q = /* @__PURE__ */ new WeakSet(), ft = 0, $ = class DropZones {
1412
+ static {
1413
+ i(this, "DropZones");
1414
+ }
1415
+ static zones = /* @__PURE__ */ new Map();
1416
+ static isListening = !1;
1417
+ static add(e, t) {
1418
+ let n = DropZones.zones.get(e) ?? [];
1419
+ n.length && c.warn("<ui-uploader drop-zone>", "two uploaders share a drop zone: the first on the page takes the drops", n[0].domElement, t.domElement), DropZones.zones.set(e, [...n, t].sort((e, t) => te(e.domElement, t.domElement))), DropZones.listen();
1420
+ }
1421
+ static remove(e, t) {
1422
+ let n = DropZones.zones.get(e)?.filter((e) => e !== t) ?? [];
1423
+ n.length ? DropZones.zones.set(e, n) : DropZones.zones.delete(e);
1424
+ }
1425
+ static reset() {
1426
+ DropZones.zones.clear();
1427
+ }
1428
+ static uploaderFor(e) {
1429
+ if (!Q.has(e) && z.hasFiles(e)) for (let t of e.composedPath()) {
1430
+ let e = DropZones.zones.get(t)?.[0];
1431
+ if (e && !e.isDisabled) return e;
1432
+ }
1433
+ }
1434
+ static listen() {
1435
+ DropZones.isListening || x || (DropZones.isListening = !0, document.addEventListener("dragover", (e) => DropZones.uploaderFor(e)?.draggedOver(e, U)), document.addEventListener("drop", (e) => DropZones.uploaderFor(e)?.dropped(e, U)));
1436
+ }
1437
+ };
1438
+ // src/components/ui-uploader/index.ts
1439
+ le(["click"]), z.define();
1440
+ export { Qe as DOMUploaderElement, $ as DropZones, z as UIUploader };
1441
+
1442
+ //# sourceMappingURL=ui-uploader.js.map