@eightshift/ui-components 6.3.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (973) hide show
  1. package/dist/Button-h6xF_WrP.js +225 -0
  2. package/dist/Dialog-i5VLQw1o.js +2488 -0
  3. package/dist/Disclosure-NYWFw9RJ.js +188 -0
  4. package/dist/FieldError-BWDbP5Db.js +213 -0
  5. package/dist/FocusScope-CgwbGOBB.js +746 -0
  6. package/dist/Form-DTMkbrQY.js +5 -0
  7. package/dist/Heading-Hol-wS_B.js +16 -0
  8. package/dist/Hidden-8TB37dpK.js +51 -0
  9. package/dist/Input-BURqyJXW.js +161 -0
  10. package/dist/Label-DFXXxMKY.js +17 -0
  11. package/dist/List-CMK5qsNF.js +506 -0
  12. package/dist/ListBox-B21SgugS.js +601 -0
  13. package/dist/NumberFormatter-m5VW6MTK.js +122 -0
  14. package/dist/OverlayArrow-BoloUPQM.js +573 -0
  15. package/dist/PortalProvider-DinZZCKX.js +14 -0
  16. package/dist/RSPContexts-C_z0bI8W.js +12 -0
  17. package/dist/RadioGroup-BwlGtCja.js +329 -0
  18. package/dist/SearchField-DR_I4_yn.js +765 -0
  19. package/dist/SelectionIndicator-31L6EI9F.js +13 -0
  20. package/dist/SelectionManager-B8lLv6Ue.js +2176 -0
  21. package/dist/Slider-DW1RuMVp.js +827 -0
  22. package/dist/Text-O6VBBDlP.js +16 -0
  23. package/dist/VisuallyHidden-CfsnJHZb.js +43 -0
  24. package/dist/animation-Bd2peown.js +62 -0
  25. package/dist/assets/style-admin.css +197 -200
  26. package/dist/assets/style-editor.css +197 -200
  27. package/dist/assets/style.css +197 -200
  28. package/dist/build-module-sxK3nxOK.js +855 -0
  29. package/dist/button-COTeluL8.js +524 -0
  30. package/dist/checkbox-D0AWkLhp.js +338 -0
  31. package/dist/clsx-BUU5J41u.js +16 -0
  32. package/dist/color-swatch-CBYsO_Zs.js +2572 -0
  33. package/dist/components/animated-visibility/animated-visibility.js +87 -111
  34. package/dist/components/base-control/base-control.js +73 -86
  35. package/dist/components/base-control/container.js +199 -227
  36. package/dist/components/breakpoint-preview/breakpoint-preview.js +162 -158
  37. package/dist/components/button/button.js +3 -580
  38. package/dist/components/checkbox/checkbox.js +2 -391
  39. package/dist/components/color-pickers/color-picker.js +172 -276
  40. package/dist/components/color-pickers/color-swatch.js +3 -7
  41. package/dist/components/color-pickers/gradient-editor.js +4 -552
  42. package/dist/components/color-pickers/solid-color-picker.js +3 -1710
  43. package/dist/components/component-toggle/component-toggle.js +107 -160
  44. package/dist/components/container-panel/container-panel.js +94 -151
  45. package/dist/components/draggable/draggable-context.js +4 -4
  46. package/dist/components/draggable/draggable-handle.js +27 -43
  47. package/dist/components/draggable/draggable.js +3 -7638
  48. package/dist/components/draggable-list/draggable-list-context.js +4 -4
  49. package/dist/components/draggable-list/draggable-list-item.js +63 -80
  50. package/dist/components/draggable-list/draggable-list.js +115 -142
  51. package/dist/components/expandable/expandable.js +105 -407
  52. package/dist/components/index.js +30 -106
  53. package/dist/components/input-field/input-field.js +2 -326
  54. package/dist/components/item-collection/item-collection.js +50 -56
  55. package/dist/components/layout/hstack.js +27 -29
  56. package/dist/components/layout/vstack.js +27 -29
  57. package/dist/components/link-input/link-input.js +3 -1943
  58. package/dist/components/matrix-align/matrix-align.js +127 -161
  59. package/dist/components/menu/menu.js +253 -356
  60. package/dist/components/modal/modal.js +3 -399
  61. package/dist/components/notice/notice.js +99 -139
  62. package/dist/components/number-picker/number-picker.js +3 -344
  63. package/dist/components/option-select/option-select.js +226 -404
  64. package/dist/components/options-panel/options-panel.js +138 -175
  65. package/dist/components/placeholders/file-picker-shell.js +91 -141
  66. package/dist/components/placeholders/file-placeholder.js +41 -53
  67. package/dist/components/placeholders/image-placeholder.js +65 -96
  68. package/dist/components/placeholders/media-placeholder.js +65 -68
  69. package/dist/components/popover/popover.js +147 -221
  70. package/dist/components/portal-provider/portal-provider.js +23 -21
  71. package/dist/components/radio/radio.js +246 -294
  72. package/dist/components/repeater/repeater-context.js +4 -4
  73. package/dist/components/repeater/repeater-item.js +95 -114
  74. package/dist/components/repeater/repeater.js +221 -278
  75. package/dist/components/responsive/mini-responsive.js +403 -495
  76. package/dist/components/responsive/responsive-legacy.js +271 -336
  77. package/dist/components/responsive/responsive.js +445 -562
  78. package/dist/components/responsive-preview/responsive-preview.js +94 -117
  79. package/dist/components/rich-label/rich-label.js +80 -75
  80. package/dist/components/select/async-multi-select.js +360 -589
  81. package/dist/components/select/async-select.js +284 -492
  82. package/dist/components/select/multi-select.js +340 -552
  83. package/dist/components/select/shared.js +3 -17
  84. package/dist/components/select/single-select.js +278 -475
  85. package/dist/components/select/styles.js +84 -0
  86. package/dist/components/slider/column-config-slider.js +170 -301
  87. package/dist/components/slider/slider.js +258 -405
  88. package/dist/components/slider/utils.js +77 -121
  89. package/dist/components/smart-image/image-analysis-worker.js +128 -0
  90. package/dist/components/smart-image/smart-image.js +3 -205
  91. package/dist/components/smart-image/worker-inline.js +4 -4
  92. package/dist/components/spacer/spacer.js +80 -94
  93. package/dist/components/tabs/tabs.js +3 -1051
  94. package/dist/components/toggle/switch.js +2 -295
  95. package/dist/components/toggle/toggle.js +54 -64
  96. package/dist/components/toggle-button/toggle-button.js +2 -451
  97. package/dist/components/tooltip/tooltip.js +2 -535
  98. package/dist/context-C-XNeJ_l.js +93 -0
  99. package/dist/debounce-throttle-DXxSAKpq.js +120 -0
  100. package/dist/dist-DIK9pFxO.js +55 -0
  101. package/dist/draggable-CYQyD9gG.js +6961 -0
  102. package/dist/es-dash-HqXWZZ3_.js +303 -0
  103. package/dist/filterDOMProps-_2_3GD-K.js +69 -0
  104. package/dist/general-D-7dwhuF.js +4277 -0
  105. package/dist/gradient-editor-DbH8NU2p.js +604 -0
  106. package/dist/icons/block-icon.js +34 -39
  107. package/dist/icons/generated-icon-loaders.js +759 -0
  108. package/dist/icons/generic-color-swatch.js +81 -111
  109. package/dist/icons/icon.js +67 -0
  110. package/dist/icons/icons.js +218 -3656
  111. package/dist/icons/index.js +756 -10
  112. package/dist/icons/internal.js +758 -0
  113. package/dist/icons/jsx-svg.js +2 -94
  114. package/dist/icons/spinner.js +16 -18
  115. package/dist/icons/ui-icons/a11y-warning.js +34 -0
  116. package/dist/icons/ui-icons/a11y.js +29 -0
  117. package/dist/icons/ui-icons/accelerometer.js +51 -0
  118. package/dist/icons/ui-icons/activity-log.js +53 -0
  119. package/dist/icons/ui-icons/add.js +20 -0
  120. package/dist/icons/ui-icons/alert.js +31 -0
  121. package/dist/icons/ui-icons/align-horizontal-vertical-alt.js +37 -0
  122. package/dist/icons/ui-icons/align-horizontal-vertical-alt2.js +36 -0
  123. package/dist/icons/ui-icons/align-horizontal-vertical.js +34 -0
  124. package/dist/icons/ui-icons/alt-text-generic-alt.js +19 -0
  125. package/dist/icons/ui-icons/alt-text-generic.js +25 -0
  126. package/dist/icons/ui-icons/alt-text.js +36 -0
  127. package/dist/icons/ui-icons/anchor-page.js +44 -0
  128. package/dist/icons/ui-icons/anchor.js +28 -0
  129. package/dist/icons/ui-icons/angle.js +24 -0
  130. package/dist/icons/ui-icons/animation-file.js +66 -0
  131. package/dist/icons/ui-icons/animation-generic.js +36 -0
  132. package/dist/icons/ui-icons/animation-list-generic.js +41 -0
  133. package/dist/icons/ui-icons/animation-settings-generic.js +41 -0
  134. package/dist/icons/ui-icons/animation.js +55 -0
  135. package/dist/icons/ui-icons/archive-file.js +24 -0
  136. package/dist/icons/ui-icons/archive.js +39 -0
  137. package/dist/icons/ui-icons/aria-label.js +42 -0
  138. package/dist/icons/ui-icons/arrow-down-circle-alt.js +28 -0
  139. package/dist/icons/ui-icons/arrow-down-circle.js +28 -0
  140. package/dist/icons/ui-icons/arrow-down-square-alt.js +28 -0
  141. package/dist/icons/ui-icons/arrow-down-square.js +28 -0
  142. package/dist/icons/ui-icons/arrow-down.js +20 -0
  143. package/dist/icons/ui-icons/arrow-left-circle-alt.js +28 -0
  144. package/dist/icons/ui-icons/arrow-left-circle.js +28 -0
  145. package/dist/icons/ui-icons/arrow-left-square-alt.js +28 -0
  146. package/dist/icons/ui-icons/arrow-left-square.js +28 -0
  147. package/dist/icons/ui-icons/arrow-left.js +20 -0
  148. package/dist/icons/ui-icons/arrow-right-circle-alt.js +28 -0
  149. package/dist/icons/ui-icons/arrow-right-circle.js +28 -0
  150. package/dist/icons/ui-icons/arrow-right-square-alt.js +28 -0
  151. package/dist/icons/ui-icons/arrow-right-square.js +28 -0
  152. package/dist/icons/ui-icons/arrow-right.js +20 -0
  153. package/dist/icons/ui-icons/arrow-up-circle-alt.js +28 -0
  154. package/dist/icons/ui-icons/arrow-up-circle.js +28 -0
  155. package/dist/icons/ui-icons/arrow-up-square-alt.js +28 -0
  156. package/dist/icons/ui-icons/arrow-up-square.js +28 -0
  157. package/dist/icons/ui-icons/arrow-up.js +20 -0
  158. package/dist/icons/ui-icons/arrows-down.js +38 -0
  159. package/dist/icons/ui-icons/arrows-horizontal.js +20 -0
  160. package/dist/icons/ui-icons/arrows-left-diagonal.js +20 -0
  161. package/dist/icons/ui-icons/arrows-left.js +38 -0
  162. package/dist/icons/ui-icons/arrows-right-diagonal.js +20 -0
  163. package/dist/icons/ui-icons/arrows-right.js +38 -0
  164. package/dist/icons/ui-icons/arrows-up.js +38 -0
  165. package/dist/icons/ui-icons/arrows-vertical.js +20 -0
  166. package/dist/icons/ui-icons/aspect-ratio-auto.js +38 -0
  167. package/dist/icons/ui-icons/aspect-ratio-nine-sixteen.js +28 -0
  168. package/dist/icons/ui-icons/aspect-ratio-sixteen-nine.js +28 -0
  169. package/dist/icons/ui-icons/aspect-ratio-square.js +28 -0
  170. package/dist/icons/ui-icons/aspect-ratio-three-two.js +28 -0
  171. package/dist/icons/ui-icons/aspect-ratio-twenty-one-nine.js +28 -0
  172. package/dist/icons/ui-icons/aspect-ratio.js +27 -0
  173. package/dist/icons/ui-icons/attachment.js +19 -0
  174. package/dist/icons/ui-icons/auto-close.js +26 -0
  175. package/dist/icons/ui-icons/auto-pause-scroll.js +39 -0
  176. package/dist/icons/ui-icons/auto-pause.js +26 -0
  177. package/dist/icons/ui-icons/automatic-alt.js +19 -0
  178. package/dist/icons/ui-icons/automatic.js +20 -0
  179. package/dist/icons/ui-icons/autoplay-alt.js +34 -0
  180. package/dist/icons/ui-icons/autoplay-alt2.js +23 -0
  181. package/dist/icons/ui-icons/autoplay.js +36 -0
  182. package/dist/icons/ui-icons/award.js +39 -0
  183. package/dist/icons/ui-icons/background-blur.js +66 -0
  184. package/dist/icons/ui-icons/background-color-swatch.js +48 -0
  185. package/dist/icons/ui-icons/background-image.js +41 -0
  186. package/dist/icons/ui-icons/background-repeat.js +95 -0
  187. package/dist/icons/ui-icons/background-type-alt.js +38 -0
  188. package/dist/icons/ui-icons/background-type-alt2.js +27 -0
  189. package/dist/icons/ui-icons/background-type.js +27 -0
  190. package/dist/icons/ui-icons/block-parts.js +54 -0
  191. package/dist/icons/ui-icons/bold.js +21 -0
  192. package/dist/icons/ui-icons/book.js +40 -0
  193. package/dist/icons/ui-icons/bookmark.js +18 -0
  194. package/dist/icons/ui-icons/boolean-exclude.js +24 -0
  195. package/dist/icons/ui-icons/boolean-intersect.js +31 -0
  196. package/dist/icons/ui-icons/boolean-subtract.js +27 -0
  197. package/dist/icons/ui-icons/boolean-union.js +33 -0
  198. package/dist/icons/ui-icons/border-color.js +79 -0
  199. package/dist/icons/ui-icons/border.js +60 -0
  200. package/dist/icons/ui-icons/bot-deny.js +61 -0
  201. package/dist/icons/ui-icons/bot.js +47 -0
  202. package/dist/icons/ui-icons/box.js +35 -0
  203. package/dist/icons/ui-icons/brain.js +20 -0
  204. package/dist/icons/ui-icons/branch-fork.js +46 -0
  205. package/dist/icons/ui-icons/branch.js +46 -0
  206. package/dist/icons/ui-icons/briefcase.js +26 -0
  207. package/dist/icons/ui-icons/browser.js +60 -0
  208. package/dist/icons/ui-icons/button-disabled.js +30 -0
  209. package/dist/icons/ui-icons/button-filled.js +19 -0
  210. package/dist/icons/ui-icons/button-ghost.js +28 -0
  211. package/dist/icons/ui-icons/button-outline.js +27 -0
  212. package/dist/icons/ui-icons/calculator.js +139 -0
  213. package/dist/icons/ui-icons/calendar-add.js +51 -0
  214. package/dist/icons/ui-icons/calendar-download.js +62 -0
  215. package/dist/icons/ui-icons/calendar-remove.js +51 -0
  216. package/dist/icons/ui-icons/calendar.js +34 -0
  217. package/dist/icons/ui-icons/caption-generic.js +25 -0
  218. package/dist/icons/ui-icons/card-featured.js +28 -0
  219. package/dist/icons/ui-icons/caret-down-fill.js +19 -0
  220. package/dist/icons/ui-icons/caret-down.js +19 -0
  221. package/dist/icons/ui-icons/caret-left-fill.js +19 -0
  222. package/dist/icons/ui-icons/caret-left.js +19 -0
  223. package/dist/icons/ui-icons/caret-right-fill.js +19 -0
  224. package/dist/icons/ui-icons/caret-right.js +19 -0
  225. package/dist/icons/ui-icons/caret-up-fill.js +19 -0
  226. package/dist/icons/ui-icons/caret-up.js +19 -0
  227. package/dist/icons/ui-icons/center-point.js +25 -0
  228. package/dist/icons/ui-icons/chat-bubble-alt.js +25 -0
  229. package/dist/icons/ui-icons/chat-bubble.js +19 -0
  230. package/dist/icons/ui-icons/chat.js +25 -0
  231. package/dist/icons/ui-icons/check-circle-fill-transparent.js +24 -0
  232. package/dist/icons/ui-icons/check-circle-fill.js +17 -0
  233. package/dist/icons/ui-icons/check-circle.js +27 -0
  234. package/dist/icons/ui-icons/check-square.js +28 -0
  235. package/dist/icons/ui-icons/check.js +20 -0
  236. package/dist/icons/ui-icons/checks-circle.js +26 -0
  237. package/dist/icons/ui-icons/checks.js +26 -0
  238. package/dist/icons/ui-icons/chevron-down.js +20 -0
  239. package/dist/icons/ui-icons/chevron-left.js +20 -0
  240. package/dist/icons/ui-icons/chevron-right.js +20 -0
  241. package/dist/icons/ui-icons/chevron-up.js +20 -0
  242. package/dist/icons/ui-icons/clear-alt.js +25 -0
  243. package/dist/icons/ui-icons/clear.js +20 -0
  244. package/dist/icons/ui-icons/clipboard-plain.js +35 -0
  245. package/dist/icons/ui-icons/clipboard.js +43 -0
  246. package/dist/icons/ui-icons/clock.js +26 -0
  247. package/dist/icons/ui-icons/closed-captions.js +27 -0
  248. package/dist/icons/ui-icons/code-variable.js +20 -0
  249. package/dist/icons/ui-icons/code.js +20 -0
  250. package/dist/icons/ui-icons/color-alt.js +40 -0
  251. package/dist/icons/ui-icons/color-fill-swatch.js +61 -0
  252. package/dist/icons/ui-icons/color-picker-fill.js +42 -0
  253. package/dist/icons/ui-icons/color-picker-list-marker.js +41 -0
  254. package/dist/icons/ui-icons/color-picker-text-highlight.js +19 -0
  255. package/dist/icons/ui-icons/color-picker-text.js +20 -0
  256. package/dist/icons/ui-icons/color-select.js +33 -0
  257. package/dist/icons/ui-icons/color.js +22 -0
  258. package/dist/icons/ui-icons/column-gutters-lr.js +54 -0
  259. package/dist/icons/ui-icons/columns.js +42 -0
  260. package/dist/icons/ui-icons/columns3366.js +30 -0
  261. package/dist/icons/ui-icons/columns6633.js +30 -0
  262. package/dist/icons/ui-icons/component-generic.js +27 -0
  263. package/dist/icons/ui-icons/component-options.js +36 -0
  264. package/dist/icons/ui-icons/condition-h.js +20 -0
  265. package/dist/icons/ui-icons/condition-v.js +20 -0
  266. package/dist/icons/ui-icons/conditional-visibility.js +26 -0
  267. package/dist/icons/ui-icons/container-height.js +68 -0
  268. package/dist/icons/ui-icons/container-spacing-h.js +41 -0
  269. package/dist/icons/ui-icons/container-spacing.js +41 -0
  270. package/dist/icons/ui-icons/container-width.js +68 -0
  271. package/dist/icons/ui-icons/content-bottom-left.js +31 -0
  272. package/dist/icons/ui-icons/content-bottom-right.js +31 -0
  273. package/dist/icons/ui-icons/content-center.js +31 -0
  274. package/dist/icons/ui-icons/content-top-left.js +31 -0
  275. package/dist/icons/ui-icons/content-top-right.js +31 -0
  276. package/dist/icons/ui-icons/contrast-alt.js +27 -0
  277. package/dist/icons/ui-icons/contrast.js +26 -0
  278. package/dist/icons/ui-icons/cookie-alt.js +124 -0
  279. package/dist/icons/ui-icons/cookie.js +76 -0
  280. package/dist/icons/ui-icons/copy.js +26 -0
  281. package/dist/icons/ui-icons/currency.js +48 -0
  282. package/dist/icons/ui-icons/current-page.js +42 -0
  283. package/dist/icons/ui-icons/cursor-disabled.js +35 -0
  284. package/dist/icons/ui-icons/cursor-move.js +20 -0
  285. package/dist/icons/ui-icons/dark-mode.js +20 -0
  286. package/dist/icons/ui-icons/data.js +33 -0
  287. package/dist/icons/ui-icons/date-time.js +67 -0
  288. package/dist/icons/ui-icons/defer.js +26 -0
  289. package/dist/icons/ui-icons/description-link.js +40 -0
  290. package/dist/icons/ui-icons/design.js +48 -0
  291. package/dist/icons/ui-icons/dice.js +59 -0
  292. package/dist/icons/ui-icons/divider-bottom.js +23 -0
  293. package/dist/icons/ui-icons/divider-side.js +53 -0
  294. package/dist/icons/ui-icons/divider-status.js +53 -0
  295. package/dist/icons/ui-icons/divider-top.js +23 -0
  296. package/dist/icons/ui-icons/divider.js +23 -0
  297. package/dist/icons/ui-icons/door-in.js +32 -0
  298. package/dist/icons/ui-icons/door-out.js +32 -0
  299. package/dist/icons/ui-icons/door.js +27 -0
  300. package/dist/icons/ui-icons/download.js +20 -0
  301. package/dist/icons/ui-icons/dropdown-caret-alt.js +17 -0
  302. package/dist/icons/ui-icons/dropdown-caret.js +20 -0
  303. package/dist/icons/ui-icons/dropdown-close.js +52 -0
  304. package/dist/icons/ui-icons/dropdown-open.js +38 -0
  305. package/dist/icons/ui-icons/dropdown.js +38 -0
  306. package/dist/icons/ui-icons/dummy-spacer.js +17 -0
  307. package/dist/icons/ui-icons/edit-options.js +32 -0
  308. package/dist/icons/ui-icons/edit.js +22 -0
  309. package/dist/icons/ui-icons/email-remove.js +42 -0
  310. package/dist/icons/ui-icons/email.js +28 -0
  311. package/dist/icons/ui-icons/embed.js +28 -0
  312. package/dist/icons/ui-icons/empty-circle.js +23 -0
  313. package/dist/icons/ui-icons/empty-rect.js +25 -0
  314. package/dist/icons/ui-icons/equal-columns.js +25 -0
  315. package/dist/icons/ui-icons/equal-rows.js +25 -0
  316. package/dist/icons/ui-icons/equals.js +20 -0
  317. package/dist/icons/ui-icons/error-circle-fill-transparent.js +23 -0
  318. package/dist/icons/ui-icons/error-circle-fill.js +17 -0
  319. package/dist/icons/ui-icons/error-circle.js +24 -0
  320. package/dist/icons/ui-icons/exclude-item-alt.js +38 -0
  321. package/dist/icons/ui-icons/exclude-item.js +42 -0
  322. package/dist/icons/ui-icons/exclude.js +29 -0
  323. package/dist/icons/ui-icons/expand-xl.js +20 -0
  324. package/dist/icons/ui-icons/expand.js +20 -0
  325. package/dist/icons/ui-icons/experiment.js +33 -0
  326. package/dist/icons/ui-icons/external-link.js +25 -0
  327. package/dist/icons/ui-icons/extract-alt.js +25 -0
  328. package/dist/icons/ui-icons/extract.js +25 -0
  329. package/dist/icons/ui-icons/eyedropper.js +36 -0
  330. package/dist/icons/ui-icons/fast-forward.js +26 -0
  331. package/dist/icons/ui-icons/fast-reverse.js +26 -0
  332. package/dist/icons/ui-icons/field-after-text.js +54 -0
  333. package/dist/icons/ui-icons/field-before-text.js +46 -0
  334. package/dist/icons/ui-icons/field-disabled.js +35 -0
  335. package/dist/icons/ui-icons/field-help.js +46 -0
  336. package/dist/icons/ui-icons/field-label.js +38 -0
  337. package/dist/icons/ui-icons/field-name.js +45 -0
  338. package/dist/icons/ui-icons/field-placeholder.js +49 -0
  339. package/dist/icons/ui-icons/field-readonly.js +36 -0
  340. package/dist/icons/ui-icons/field-required.js +37 -0
  341. package/dist/icons/ui-icons/field-type.js +36 -0
  342. package/dist/icons/ui-icons/field-value.js +46 -0
  343. package/dist/icons/ui-icons/field-width.js +27 -0
  344. package/dist/icons/ui-icons/file-download.js +33 -0
  345. package/dist/icons/ui-icons/file-error.js +25 -0
  346. package/dist/icons/ui-icons/file-metadata.js +41 -0
  347. package/dist/icons/ui-icons/file-pdf.js +34 -0
  348. package/dist/icons/ui-icons/file-size-max.js +33 -0
  349. package/dist/icons/ui-icons/file-size-min.js +33 -0
  350. package/dist/icons/ui-icons/file-size.js +34 -0
  351. package/dist/icons/ui-icons/file-type.js +42 -0
  352. package/dist/icons/ui-icons/file-upload.js +33 -0
  353. package/dist/icons/ui-icons/file.js +24 -0
  354. package/dist/icons/ui-icons/files.js +34 -0
  355. package/dist/icons/ui-icons/fill-color.js +49 -0
  356. package/dist/icons/ui-icons/filter-alt.js +24 -0
  357. package/dist/icons/ui-icons/filter.js +20 -0
  358. package/dist/icons/ui-icons/flag-alt.js +24 -0
  359. package/dist/icons/ui-icons/flag.js +24 -0
  360. package/dist/icons/ui-icons/flip-h.js +27 -0
  361. package/dist/icons/ui-icons/flip-v.js +27 -0
  362. package/dist/icons/ui-icons/focus.js +21 -0
  363. package/dist/icons/ui-icons/folder-add.js +22 -0
  364. package/dist/icons/ui-icons/folder-open-solid.js +17 -0
  365. package/dist/icons/ui-icons/folder-open.js +19 -0
  366. package/dist/icons/ui-icons/folder-solid.js +17 -0
  367. package/dist/icons/ui-icons/folder-top-level.js +22 -0
  368. package/dist/icons/ui-icons/folder.js +19 -0
  369. package/dist/icons/ui-icons/font-family.js +24 -0
  370. package/dist/icons/ui-icons/footer.js +23 -0
  371. package/dist/icons/ui-icons/form-alt.js +71 -0
  372. package/dist/icons/ui-icons/form.js +53 -0
  373. package/dist/icons/ui-icons/four-columns.js +38 -0
  374. package/dist/icons/ui-icons/frame.js +33 -0
  375. package/dist/icons/ui-icons/full-max-shield.js +26 -0
  376. package/dist/icons/ui-icons/full-max-text.js +20 -0
  377. package/dist/icons/ui-icons/full-width-image.js +35 -0
  378. package/dist/icons/ui-icons/gears-fill.js +19 -0
  379. package/dist/icons/ui-icons/gears.js +38 -0
  380. package/dist/icons/ui-icons/generic-color-swatch.js +6 -0
  381. package/dist/icons/ui-icons/generic-shapes-alt.js +33 -0
  382. package/dist/icons/ui-icons/generic-shapes.js +38 -0
  383. package/dist/icons/ui-icons/globe-anchor.js +55 -0
  384. package/dist/icons/ui-icons/globe-hash.js +40 -0
  385. package/dist/icons/ui-icons/globe.js +37 -0
  386. package/dist/icons/ui-icons/google-tag-manager.js +36 -0
  387. package/dist/icons/ui-icons/gradient-repeat.js +41 -0
  388. package/dist/icons/ui-icons/gradient-stop.js +36 -0
  389. package/dist/icons/ui-icons/gradient.js +54 -0
  390. package/dist/icons/ui-icons/grid-alt.js +19 -0
  391. package/dist/icons/ui-icons/grid-auto-cols.js +46 -0
  392. package/dist/icons/ui-icons/grid-auto-rows.js +41 -0
  393. package/dist/icons/ui-icons/grid-col.js +22 -0
  394. package/dist/icons/ui-icons/grid-height.js +22 -0
  395. package/dist/icons/ui-icons/grid-list-toggle.js +48 -0
  396. package/dist/icons/ui-icons/grid-manual.js +18 -0
  397. package/dist/icons/ui-icons/grid-row.js +22 -0
  398. package/dist/icons/ui-icons/grid-width.js +22 -0
  399. package/dist/icons/ui-icons/group.js +33 -0
  400. package/dist/icons/ui-icons/gutter.js +28 -0
  401. package/dist/icons/ui-icons/gyroscope.js +53 -0
  402. package/dist/icons/ui-icons/h1.js +28 -0
  403. package/dist/icons/ui-icons/h2.js +28 -0
  404. package/dist/icons/ui-icons/h3.js +28 -0
  405. package/dist/icons/ui-icons/h4.js +28 -0
  406. package/dist/icons/ui-icons/h5.js +28 -0
  407. package/dist/icons/ui-icons/h6.js +28 -0
  408. package/dist/icons/ui-icons/hamburger-menu.js +19 -0
  409. package/dist/icons/ui-icons/hard-drive.js +35 -0
  410. package/dist/icons/ui-icons/header.js +23 -0
  411. package/dist/icons/ui-icons/heading-level-alt.js +28 -0
  412. package/dist/icons/ui-icons/heading-level.js +28 -0
  413. package/dist/icons/ui-icons/heading.js +20 -0
  414. package/dist/icons/ui-icons/heart-fill-transparent.js +19 -0
  415. package/dist/icons/ui-icons/heart-fill.js +18 -0
  416. package/dist/icons/ui-icons/heart.js +18 -0
  417. package/dist/icons/ui-icons/height.js +30 -0
  418. package/dist/icons/ui-icons/help-fill.js +19 -0
  419. package/dist/icons/ui-icons/help.js +38 -0
  420. package/dist/icons/ui-icons/hide.js +29 -0
  421. package/dist/icons/ui-icons/highlighted-checkmark.js +24 -0
  422. package/dist/icons/ui-icons/highlighted-exclamation-mark.js +33 -0
  423. package/dist/icons/ui-icons/history.js +26 -0
  424. package/dist/icons/ui-icons/horizontal-align-alt.js +27 -0
  425. package/dist/icons/ui-icons/horizontal-align-around.js +37 -0
  426. package/dist/icons/ui-icons/horizontal-align-between-alt.js +37 -0
  427. package/dist/icons/ui-icons/horizontal-align-between.js +46 -0
  428. package/dist/icons/ui-icons/horizontal-align-center.js +41 -0
  429. package/dist/icons/ui-icons/horizontal-align-evenly.js +37 -0
  430. package/dist/icons/ui-icons/horizontal-align-left.js +44 -0
  431. package/dist/icons/ui-icons/horizontal-align-right.js +48 -0
  432. package/dist/icons/ui-icons/horizontal-align-stretch.js +37 -0
  433. package/dist/icons/ui-icons/horizontal-align.js +35 -0
  434. package/dist/icons/ui-icons/hover-background-glow.js +61 -0
  435. package/dist/icons/ui-icons/hover-background-type.js +34 -0
  436. package/dist/icons/ui-icons/hover-invert-object.js +42 -0
  437. package/dist/icons/ui-icons/hover-invert-text.js +32 -0
  438. package/dist/icons/ui-icons/hover-rotate.js +20 -0
  439. package/dist/icons/ui-icons/hover-zoom.js +25 -0
  440. package/dist/icons/ui-icons/hyphenate-alt.js +20 -0
  441. package/dist/icons/ui-icons/hyphenate-alt2.js +20 -0
  442. package/dist/icons/ui-icons/hyphenate.js +25 -0
  443. package/dist/icons/ui-icons/icon-generic.js +23 -0
  444. package/dist/icons/ui-icons/id-card.js +45 -0
  445. package/dist/icons/ui-icons/id.js +28 -0
  446. package/dist/icons/ui-icons/image-blur.js +50 -0
  447. package/dist/icons/ui-icons/image-caption.js +36 -0
  448. package/dist/icons/ui-icons/image-error.js +36 -0
  449. package/dist/icons/ui-icons/image-file.js +40 -0
  450. package/dist/icons/ui-icons/image-lazy-load.js +52 -0
  451. package/dist/icons/ui-icons/image-opacity.js +31 -0
  452. package/dist/icons/ui-icons/image-overlay-alt.js +93 -0
  453. package/dist/icons/ui-icons/image-overlay-alt2.js +93 -0
  454. package/dist/icons/ui-icons/image-overlay.js +92 -0
  455. package/dist/icons/ui-icons/image-remove.js +46 -0
  456. package/dist/icons/ui-icons/image.js +25 -0
  457. package/dist/icons/ui-icons/index.js +753 -0
  458. package/dist/icons/ui-icons/info-circle-fill-transparent.js +21 -0
  459. package/dist/icons/ui-icons/info-circle-fill.js +17 -0
  460. package/dist/icons/ui-icons/info-circle.js +24 -0
  461. package/dist/icons/ui-icons/info.js +17 -0
  462. package/dist/icons/ui-icons/inherit.js +41 -0
  463. package/dist/icons/ui-icons/inline-gradient-format.js +62 -0
  464. package/dist/icons/ui-icons/input-field.js +27 -0
  465. package/dist/icons/ui-icons/italic.js +20 -0
  466. package/dist/icons/ui-icons/item-limit.js +35 -0
  467. package/dist/icons/ui-icons/item-select.js +33 -0
  468. package/dist/icons/ui-icons/item-wrap.js +60 -0
  469. package/dist/icons/ui-icons/items-per-page.js +48 -0
  470. package/dist/icons/ui-icons/items-per-row.js +45 -0
  471. package/dist/icons/ui-icons/key.js +25 -0
  472. package/dist/icons/ui-icons/keyboard.js +19 -0
  473. package/dist/icons/ui-icons/large.js +24 -0
  474. package/dist/icons/ui-icons/latest-posts.js +44 -0
  475. package/dist/icons/ui-icons/layer-off.js +20 -0
  476. package/dist/icons/ui-icons/layer.js +19 -0
  477. package/dist/icons/ui-icons/layers.js +33 -0
  478. package/dist/icons/ui-icons/layout-alt.js +19 -0
  479. package/dist/icons/ui-icons/layout-alt2.js +23 -0
  480. package/dist/icons/ui-icons/layout-alt3.js +19 -0
  481. package/dist/icons/ui-icons/layout-alt4.js +19 -0
  482. package/dist/icons/ui-icons/layout-bento-box.js +19 -0
  483. package/dist/icons/ui-icons/layout-masonry.js +79 -0
  484. package/dist/icons/ui-icons/layout.js +43 -0
  485. package/dist/icons/ui-icons/left-panel-alt.js +25 -0
  486. package/dist/icons/ui-icons/left-panel.js +22 -0
  487. package/dist/icons/ui-icons/light-bulb-alt.js +30 -0
  488. package/dist/icons/ui-icons/light-bulb.js +33 -0
  489. package/dist/icons/ui-icons/light-mode.js +26 -0
  490. package/dist/icons/ui-icons/limit-width.js +26 -0
  491. package/dist/icons/ui-icons/line-break-alt-off.js +26 -0
  492. package/dist/icons/ui-icons/line-break-alt.js +25 -0
  493. package/dist/icons/ui-icons/line-break-off-alt.js +35 -0
  494. package/dist/icons/ui-icons/line-break-off.js +41 -0
  495. package/dist/icons/ui-icons/line-break.js +29 -0
  496. package/dist/icons/ui-icons/line-breaks-hyphenation.js +36 -0
  497. package/dist/icons/ui-icons/link-add.js +41 -0
  498. package/dist/icons/ui-icons/link-nav.js +59 -0
  499. package/dist/icons/ui-icons/link-remove.js +41 -0
  500. package/dist/icons/ui-icons/link.js +19 -0
  501. package/dist/icons/ui-icons/list-indent.js +26 -0
  502. package/dist/icons/ui-icons/list-ordered.js +43 -0
  503. package/dist/icons/ui-icons/list-outdent.js +26 -0
  504. package/dist/icons/ui-icons/list-unordered.js +43 -0
  505. package/dist/icons/ui-icons/loader-alt.js +19 -0
  506. package/dist/icons/ui-icons/loader.js +19 -0
  507. package/dist/icons/ui-icons/location-add.js +44 -0
  508. package/dist/icons/ui-icons/location-allow.js +44 -0
  509. package/dist/icons/ui-icons/location-deny.js +44 -0
  510. package/dist/icons/ui-icons/location-settings.js +36 -0
  511. package/dist/icons/ui-icons/location.js +26 -0
  512. package/dist/icons/ui-icons/lock.js +44 -0
  513. package/dist/icons/ui-icons/loop-mode.js +20 -0
  514. package/dist/icons/ui-icons/magic-alt-fill-transparent.js +20 -0
  515. package/dist/icons/ui-icons/magic-alt-fill.js +19 -0
  516. package/dist/icons/ui-icons/magic-alt.js +19 -0
  517. package/dist/icons/ui-icons/magic-fill-transparent.js +20 -0
  518. package/dist/icons/ui-icons/magic-fill.js +19 -0
  519. package/dist/icons/ui-icons/magic.js +19 -0
  520. package/dist/icons/ui-icons/map-layer-json.js +35 -0
  521. package/dist/icons/ui-icons/map-layer-raster.js +121 -0
  522. package/dist/icons/ui-icons/map-layer-vector.js +81 -0
  523. package/dist/icons/ui-icons/map-layer.js +26 -0
  524. package/dist/icons/ui-icons/map-pin.js +41 -0
  525. package/dist/icons/ui-icons/matrix-align-control-dot-active.js +23 -0
  526. package/dist/icons/ui-icons/matrix-align-control-dot-inactive.js +21 -0
  527. package/dist/icons/ui-icons/media.js +49 -0
  528. package/dist/icons/ui-icons/medium.js +24 -0
  529. package/dist/icons/ui-icons/menu-item-check.js +20 -0
  530. package/dist/icons/ui-icons/menu-item-circle.js +19 -0
  531. package/dist/icons/ui-icons/microphone.js +23 -0
  532. package/dist/icons/ui-icons/migration-alt-v.js +20 -0
  533. package/dist/icons/ui-icons/migration-alt.js +20 -0
  534. package/dist/icons/ui-icons/migration.js +26 -0
  535. package/dist/icons/ui-icons/module.js +24 -0
  536. package/dist/icons/ui-icons/money-paper.js +58 -0
  537. package/dist/icons/ui-icons/more-h-circle.js +40 -0
  538. package/dist/icons/ui-icons/more-h.js +33 -0
  539. package/dist/icons/ui-icons/more-v-circle.js +44 -0
  540. package/dist/icons/ui-icons/more-v.js +36 -0
  541. package/dist/icons/ui-icons/mouse-cursor.js +20 -0
  542. package/dist/icons/ui-icons/mouse-wheel.js +27 -0
  543. package/dist/icons/ui-icons/multi-item-left-inset-mobile.js +58 -0
  544. package/dist/icons/ui-icons/multi-item-left-inset.js +39 -0
  545. package/dist/icons/ui-icons/multi-item-right-inset-mobile.js +55 -0
  546. package/dist/icons/ui-icons/multi-item-right-inset.js +36 -0
  547. package/dist/icons/ui-icons/multiple.js +34 -0
  548. package/dist/icons/ui-icons/music-note.js +40 -0
  549. package/dist/icons/ui-icons/mute-centered.js +20 -0
  550. package/dist/icons/ui-icons/mute.js +20 -0
  551. package/dist/icons/ui-icons/narrow-bottom.js +49 -0
  552. package/dist/icons/ui-icons/narrow-left.js +49 -0
  553. package/dist/icons/ui-icons/narrow-right.js +49 -0
  554. package/dist/icons/ui-icons/narrow-top.js +49 -0
  555. package/dist/icons/ui-icons/navigation-buttons.js +39 -0
  556. package/dist/icons/ui-icons/new-tab.js +27 -0
  557. package/dist/icons/ui-icons/newspaper.js +45 -0
  558. package/dist/icons/ui-icons/none.js +25 -0
  559. package/dist/icons/ui-icons/notebook.js +44 -0
  560. package/dist/icons/ui-icons/num0-circle-alt.js +24 -0
  561. package/dist/icons/ui-icons/num0-circle.js +24 -0
  562. package/dist/icons/ui-icons/num0-square-alt.js +26 -0
  563. package/dist/icons/ui-icons/num0-square.js +26 -0
  564. package/dist/icons/ui-icons/num1-circle-alt.js +26 -0
  565. package/dist/icons/ui-icons/num1-circle.js +26 -0
  566. package/dist/icons/ui-icons/num1-square-alt.js +28 -0
  567. package/dist/icons/ui-icons/num1-square.js +28 -0
  568. package/dist/icons/ui-icons/num2-circle-alt.js +26 -0
  569. package/dist/icons/ui-icons/num2-circle.js +26 -0
  570. package/dist/icons/ui-icons/num2-square-alt.js +28 -0
  571. package/dist/icons/ui-icons/num2-square.js +28 -0
  572. package/dist/icons/ui-icons/num3-circle-alt.js +26 -0
  573. package/dist/icons/ui-icons/num3-circle.js +26 -0
  574. package/dist/icons/ui-icons/num3-square-alt.js +28 -0
  575. package/dist/icons/ui-icons/num3-square.js +28 -0
  576. package/dist/icons/ui-icons/num4-circle-alt.js +26 -0
  577. package/dist/icons/ui-icons/num4-circle.js +26 -0
  578. package/dist/icons/ui-icons/num4-square-alt.js +28 -0
  579. package/dist/icons/ui-icons/num4-square.js +28 -0
  580. package/dist/icons/ui-icons/num5-circle-alt.js +26 -0
  581. package/dist/icons/ui-icons/num5-circle.js +26 -0
  582. package/dist/icons/ui-icons/num5-square-alt.js +28 -0
  583. package/dist/icons/ui-icons/num5-square.js +28 -0
  584. package/dist/icons/ui-icons/num6-circle-alt.js +26 -0
  585. package/dist/icons/ui-icons/num6-circle.js +26 -0
  586. package/dist/icons/ui-icons/num6-square-alt.js +28 -0
  587. package/dist/icons/ui-icons/num6-square.js +28 -0
  588. package/dist/icons/ui-icons/num7-circle-alt.js +26 -0
  589. package/dist/icons/ui-icons/num7-circle.js +26 -0
  590. package/dist/icons/ui-icons/num7-square-alt.js +28 -0
  591. package/dist/icons/ui-icons/num7-square.js +28 -0
  592. package/dist/icons/ui-icons/num8-circle-alt.js +24 -0
  593. package/dist/icons/ui-icons/num8-circle.js +24 -0
  594. package/dist/icons/ui-icons/num8-square-alt.js +26 -0
  595. package/dist/icons/ui-icons/num8-square.js +26 -0
  596. package/dist/icons/ui-icons/num9-circle-alt.js +26 -0
  597. package/dist/icons/ui-icons/num9-circle.js +26 -0
  598. package/dist/icons/ui-icons/num9-square-alt.js +28 -0
  599. package/dist/icons/ui-icons/num9-square.js +28 -0
  600. package/dist/icons/ui-icons/office-building.js +203 -0
  601. package/dist/icons/ui-icons/office-buildings.js +256 -0
  602. package/dist/icons/ui-icons/offset-auto.js +46 -0
  603. package/dist/icons/ui-icons/offset.js +39 -0
  604. package/dist/icons/ui-icons/option-list-alt.js +61 -0
  605. package/dist/icons/ui-icons/option-list.js +63 -0
  606. package/dist/icons/ui-icons/options.js +24 -0
  607. package/dist/icons/ui-icons/order.js +49 -0
  608. package/dist/icons/ui-icons/padding-bottom.js +35 -0
  609. package/dist/icons/ui-icons/padding-top.js +35 -0
  610. package/dist/icons/ui-icons/padding.js +34 -0
  611. package/dist/icons/ui-icons/pagination.js +49 -0
  612. package/dist/icons/ui-icons/palette-color.js +111 -0
  613. package/dist/icons/ui-icons/panel-collapse.js +41 -0
  614. package/dist/icons/ui-icons/panel-expand.js +41 -0
  615. package/dist/icons/ui-icons/paragraph.js +24 -0
  616. package/dist/icons/ui-icons/paste.js +52 -0
  617. package/dist/icons/ui-icons/pause.js +20 -0
  618. package/dist/icons/ui-icons/people-group.js +57 -0
  619. package/dist/icons/ui-icons/people.js +43 -0
  620. package/dist/icons/ui-icons/person.js +26 -0
  621. package/dist/icons/ui-icons/photo-camera.js +26 -0
  622. package/dist/icons/ui-icons/picture-in-picture.js +33 -0
  623. package/dist/icons/ui-icons/play-reverse.js +20 -0
  624. package/dist/icons/ui-icons/play.js +20 -0
  625. package/dist/icons/ui-icons/playback-options.js +24 -0
  626. package/dist/icons/ui-icons/plus-circle-fill-alt.js +23 -0
  627. package/dist/icons/ui-icons/plus-circle-fill.js +17 -0
  628. package/dist/icons/ui-icons/plus-circle.js +26 -0
  629. package/dist/icons/ui-icons/plus-minus-buttons-h.js +25 -0
  630. package/dist/icons/ui-icons/plus-minus-buttons-v.js +25 -0
  631. package/dist/icons/ui-icons/plus-square-fill-transparent.js +27 -0
  632. package/dist/icons/ui-icons/plus-square-fill.js +17 -0
  633. package/dist/icons/ui-icons/plus-square.js +27 -0
  634. package/dist/icons/ui-icons/pointer-hand-disabled.js +34 -0
  635. package/dist/icons/ui-icons/pointer-hand.js +20 -0
  636. package/dist/icons/ui-icons/position-arrows-h.js +26 -0
  637. package/dist/icons/ui-icons/position-arrows-inverted-h.js +26 -0
  638. package/dist/icons/ui-icons/position-arrows-inverted-v.js +26 -0
  639. package/dist/icons/ui-icons/position-arrows-inverted.js +26 -0
  640. package/dist/icons/ui-icons/position-arrows-v.js +26 -0
  641. package/dist/icons/ui-icons/position-arrows.js +26 -0
  642. package/dist/icons/ui-icons/position-h-center.js +43 -0
  643. package/dist/icons/ui-icons/position-h-end.js +43 -0
  644. package/dist/icons/ui-icons/position-h-start.js +43 -0
  645. package/dist/icons/ui-icons/position-left.js +31 -0
  646. package/dist/icons/ui-icons/position-right.js +31 -0
  647. package/dist/icons/ui-icons/position-v-center.js +43 -0
  648. package/dist/icons/ui-icons/position-v-end.js +43 -0
  649. package/dist/icons/ui-icons/position-v-start.js +43 -0
  650. package/dist/icons/ui-icons/position2x2-bottom-left.js +52 -0
  651. package/dist/icons/ui-icons/position2x2-bottom-right.js +52 -0
  652. package/dist/icons/ui-icons/position2x2-empty.js +51 -0
  653. package/dist/icons/ui-icons/position2x2-top-left.js +52 -0
  654. package/dist/icons/ui-icons/position2x2-top-right.js +52 -0
  655. package/dist/icons/ui-icons/position3x3-bottom-center.js +97 -0
  656. package/dist/icons/ui-icons/position3x3-bottom-left.js +97 -0
  657. package/dist/icons/ui-icons/position3x3-bottom-right.js +97 -0
  658. package/dist/icons/ui-icons/position3x3-center-center.js +97 -0
  659. package/dist/icons/ui-icons/position3x3-center-left.js +97 -0
  660. package/dist/icons/ui-icons/position3x3-center-right.js +97 -0
  661. package/dist/icons/ui-icons/position3x3-empty.js +96 -0
  662. package/dist/icons/ui-icons/position3x3-top-center.js +97 -0
  663. package/dist/icons/ui-icons/position3x3-top-left.js +97 -0
  664. package/dist/icons/ui-icons/position3x3-top-right.js +97 -0
  665. package/dist/icons/ui-icons/positioning-guide-alt.js +30 -0
  666. package/dist/icons/ui-icons/positioning-guide.js +30 -0
  667. package/dist/icons/ui-icons/positioning-width-guide.js +40 -0
  668. package/dist/icons/ui-icons/preload.js +44 -0
  669. package/dist/icons/ui-icons/preview-responsive.js +48 -0
  670. package/dist/icons/ui-icons/preview.js +35 -0
  671. package/dist/icons/ui-icons/progressbar-intermittent.js +26 -0
  672. package/dist/icons/ui-icons/progressbar.js +30 -0
  673. package/dist/icons/ui-icons/range-max.js +48 -0
  674. package/dist/icons/ui-icons/range-mid.js +40 -0
  675. package/dist/icons/ui-icons/range-min.js +48 -0
  676. package/dist/icons/ui-icons/range.js +61 -0
  677. package/dist/icons/ui-icons/read-only.js +25 -0
  678. package/dist/icons/ui-icons/reduce-height-bottom.js +49 -0
  679. package/dist/icons/ui-icons/reduce-height-top.js +49 -0
  680. package/dist/icons/ui-icons/regex.js +39 -0
  681. package/dist/icons/ui-icons/remove.js +20 -0
  682. package/dist/icons/ui-icons/rename.js +24 -0
  683. package/dist/icons/ui-icons/reorder-grabber-h.js +51 -0
  684. package/dist/icons/ui-icons/reorder-grabber-v.js +57 -0
  685. package/dist/icons/ui-icons/reorder.js +35 -0
  686. package/dist/icons/ui-icons/required-alt.js +20 -0
  687. package/dist/icons/ui-icons/required.js +19 -0
  688. package/dist/icons/ui-icons/reset-to-zero.js +33 -0
  689. package/dist/icons/ui-icons/reset.js +25 -0
  690. package/dist/icons/ui-icons/responsive-overrides-alt-fill.js +26 -0
  691. package/dist/icons/ui-icons/responsive-overrides-alt.js +49 -0
  692. package/dist/icons/ui-icons/responsive-overrides-alt2-fill.js +34 -0
  693. package/dist/icons/ui-icons/responsive-overrides-alt2.js +45 -0
  694. package/dist/icons/ui-icons/responsive-overrides-alt3-fill.js +33 -0
  695. package/dist/icons/ui-icons/responsive-overrides.js +39 -0
  696. package/dist/icons/ui-icons/responsive.js +33 -0
  697. package/dist/icons/ui-icons/right-panel-alt.js +23 -0
  698. package/dist/icons/ui-icons/right-panel.js +22 -0
  699. package/dist/icons/ui-icons/rotate-left.js +20 -0
  700. package/dist/icons/ui-icons/rotate-right.js +20 -0
  701. package/dist/icons/ui-icons/rounded-corners.js +19 -0
  702. package/dist/icons/ui-icons/route.js +27 -0
  703. package/dist/icons/ui-icons/row-add.js +45 -0
  704. package/dist/icons/ui-icons/row-empty.js +51 -0
  705. package/dist/icons/ui-icons/row.js +45 -0
  706. package/dist/icons/ui-icons/rows.js +42 -0
  707. package/dist/icons/ui-icons/ruler.js +28 -0
  708. package/dist/icons/ui-icons/save.js +26 -0
  709. package/dist/icons/ui-icons/screen-desktop.js +32 -0
  710. package/dist/icons/ui-icons/screen-large.js +23 -0
  711. package/dist/icons/ui-icons/screen-mobile.js +39 -0
  712. package/dist/icons/ui-icons/screen-tablet-large.js +36 -0
  713. package/dist/icons/ui-icons/screen-tablet.js +36 -0
  714. package/dist/icons/ui-icons/scrollbar-h.js +40 -0
  715. package/dist/icons/ui-icons/scrollbar-v.js +41 -0
  716. package/dist/icons/ui-icons/scrollbars.js +55 -0
  717. package/dist/icons/ui-icons/search-empty.js +37 -0
  718. package/dist/icons/ui-icons/search.js +25 -0
  719. package/dist/icons/ui-icons/separator-h.js +41 -0
  720. package/dist/icons/ui-icons/separator-v.js +39 -0
  721. package/dist/icons/ui-icons/shadow.js +61 -0
  722. package/dist/icons/ui-icons/share.js +26 -0
  723. package/dist/icons/ui-icons/shield-plus-alt.js +27 -0
  724. package/dist/icons/ui-icons/shield-plus.js +20 -0
  725. package/dist/icons/ui-icons/shield.js +20 -0
  726. package/dist/icons/ui-icons/shrink-diagonal-left-xl.js +20 -0
  727. package/dist/icons/ui-icons/shrink-diagonal-left.js +20 -0
  728. package/dist/icons/ui-icons/shrink-diagonal-right-xl.js +20 -0
  729. package/dist/icons/ui-icons/shrink-diagonal-right.js +20 -0
  730. package/dist/icons/ui-icons/shrink-xl.js +20 -0
  731. package/dist/icons/ui-icons/shrink.js +20 -0
  732. package/dist/icons/ui-icons/shuffle.js +20 -0
  733. package/dist/icons/ui-icons/sidebar-flip.js +22 -0
  734. package/dist/icons/ui-icons/sidebar.js +22 -0
  735. package/dist/icons/ui-icons/single-item-left-inset-mobile.js +48 -0
  736. package/dist/icons/ui-icons/single-item-left-inset.js +23 -0
  737. package/dist/icons/ui-icons/single-item-right-inset-mobile.js +50 -0
  738. package/dist/icons/ui-icons/single-item-right-inset.js +23 -0
  739. package/dist/icons/ui-icons/size-alt.js +33 -0
  740. package/dist/icons/ui-icons/size.js +29 -0
  741. package/dist/icons/ui-icons/slider.js +31 -0
  742. package/dist/icons/ui-icons/sliders.js +68 -0
  743. package/dist/icons/ui-icons/small.js +24 -0
  744. package/dist/icons/ui-icons/solid-circle-fill-transparent.js +22 -0
  745. package/dist/icons/ui-icons/solid-circle-filled.js +21 -0
  746. package/dist/icons/ui-icons/solid-circle-gradient.js +31 -0
  747. package/dist/icons/ui-icons/solid-circle.js +21 -0
  748. package/dist/icons/ui-icons/solid-color.js +19 -0
  749. package/dist/icons/ui-icons/solid-rect-fill-transparent.js +24 -0
  750. package/dist/icons/ui-icons/solid-rect-filled.js +23 -0
  751. package/dist/icons/ui-icons/solid-rect-gradient.js +33 -0
  752. package/dist/icons/ui-icons/solid-rect.js +23 -0
  753. package/dist/icons/ui-icons/sort-asc.js +20 -0
  754. package/dist/icons/ui-icons/sort-desc.js +20 -0
  755. package/dist/icons/ui-icons/sort-generic.js +25 -0
  756. package/dist/icons/ui-icons/spacing-bottom-in.js +23 -0
  757. package/dist/icons/ui-icons/spacing-bottom.js +23 -0
  758. package/dist/icons/ui-icons/spacing-left-in.js +23 -0
  759. package/dist/icons/ui-icons/spacing-left.js +23 -0
  760. package/dist/icons/ui-icons/spacing-right-in.js +23 -0
  761. package/dist/icons/ui-icons/spacing-right.js +23 -0
  762. package/dist/icons/ui-icons/spacing-top-in.js +23 -0
  763. package/dist/icons/ui-icons/spacing-top.js +23 -0
  764. package/dist/icons/ui-icons/speed.js +25 -0
  765. package/dist/icons/ui-icons/stagger.js +53 -0
  766. package/dist/icons/ui-icons/star.js +18 -0
  767. package/dist/icons/ui-icons/step.js +27 -0
  768. package/dist/icons/ui-icons/stop.js +20 -0
  769. package/dist/icons/ui-icons/swap.js +41 -0
  770. package/dist/icons/ui-icons/tag-alt.js +24 -0
  771. package/dist/icons/ui-icons/tag.js +26 -0
  772. package/dist/icons/ui-icons/text-abc.js +40 -0
  773. package/dist/icons/ui-icons/text-above.js +25 -0
  774. package/dist/icons/ui-icons/text-align-center.js +20 -0
  775. package/dist/icons/ui-icons/text-align-generic.js +20 -0
  776. package/dist/icons/ui-icons/text-align-justify.js +20 -0
  777. package/dist/icons/ui-icons/text-align-left.js +20 -0
  778. package/dist/icons/ui-icons/text-align-right.js +20 -0
  779. package/dist/icons/ui-icons/text-below.js +25 -0
  780. package/dist/icons/ui-icons/text-box-edit.js +35 -0
  781. package/dist/icons/ui-icons/text-color-swatch.js +40 -0
  782. package/dist/icons/ui-icons/text-highlight-color-swatch-alt.js +49 -0
  783. package/dist/icons/ui-icons/text-highlight-color-swatch.js +48 -0
  784. package/dist/icons/ui-icons/text-larger.js +23 -0
  785. package/dist/icons/ui-icons/text-length.js +20 -0
  786. package/dist/icons/ui-icons/text-size-alt.js +23 -0
  787. package/dist/icons/ui-icons/text-size.js +20 -0
  788. package/dist/icons/ui-icons/text-smaller.js +23 -0
  789. package/dist/icons/ui-icons/text-strikethrough.js +26 -0
  790. package/dist/icons/ui-icons/text-uppercase.js +25 -0
  791. package/dist/icons/ui-icons/text-write.js +39 -0
  792. package/dist/icons/ui-icons/thumbs-down.js +22 -0
  793. package/dist/icons/ui-icons/thumbs-up.js +22 -0
  794. package/dist/icons/ui-icons/title-generic.js +25 -0
  795. package/dist/icons/ui-icons/toggle-off.js +33 -0
  796. package/dist/icons/ui-icons/toggle-on-alt.js +19 -0
  797. package/dist/icons/ui-icons/toggle-on.js +31 -0
  798. package/dist/icons/ui-icons/tools.js +25 -0
  799. package/dist/icons/ui-icons/total-items.js +45 -0
  800. package/dist/icons/ui-icons/trash-alt.js +44 -0
  801. package/dist/icons/ui-icons/trash.js +33 -0
  802. package/dist/icons/ui-icons/tree-alt.js +62 -0
  803. package/dist/icons/ui-icons/tree-alt2.js +79 -0
  804. package/dist/icons/ui-icons/tree.js +70 -0
  805. package/dist/icons/ui-icons/troubleshoot-alt.js +39 -0
  806. package/dist/icons/ui-icons/two-cards-left.js +32 -0
  807. package/dist/icons/ui-icons/two-cards-right.js +32 -0
  808. package/dist/icons/ui-icons/two-columns.js +30 -0
  809. package/dist/icons/ui-icons/typography-options.js +77 -0
  810. package/dist/icons/ui-icons/typography.js +71 -0
  811. package/dist/icons/ui-icons/underline.js +19 -0
  812. package/dist/icons/ui-icons/ungroup.js +39 -0
  813. package/dist/icons/ui-icons/upload.js +20 -0
  814. package/dist/icons/ui-icons/venn-diagram-alt.js +34 -0
  815. package/dist/icons/ui-icons/venn-diagram-alt2.js +34 -0
  816. package/dist/icons/ui-icons/venn-diagram-alt3.js +34 -0
  817. package/dist/icons/ui-icons/venn-diagram-alt4.js +34 -0
  818. package/dist/icons/ui-icons/venn-diagram-alt5.js +34 -0
  819. package/dist/icons/ui-icons/venn-diagram-alt6.js +34 -0
  820. package/dist/icons/ui-icons/venn-diagram-alt7.js +39 -0
  821. package/dist/icons/ui-icons/venn-diagram.js +26 -0
  822. package/dist/icons/ui-icons/vertical-align-alt.js +27 -0
  823. package/dist/icons/ui-icons/vertical-align-around.js +39 -0
  824. package/dist/icons/ui-icons/vertical-align-between-alt.js +39 -0
  825. package/dist/icons/ui-icons/vertical-align-between.js +48 -0
  826. package/dist/icons/ui-icons/vertical-align-bottom.js +44 -0
  827. package/dist/icons/ui-icons/vertical-align-center.js +39 -0
  828. package/dist/icons/ui-icons/vertical-align-evenly.js +39 -0
  829. package/dist/icons/ui-icons/vertical-align-stretch.js +39 -0
  830. package/dist/icons/ui-icons/vertical-align-top.js +46 -0
  831. package/dist/icons/ui-icons/vertical-align.js +35 -0
  832. package/dist/icons/ui-icons/vertical-spacing.js +28 -0
  833. package/dist/icons/ui-icons/video-chapters.js +25 -0
  834. package/dist/icons/ui-icons/video-controls.js +67 -0
  835. package/dist/icons/ui-icons/video-file.js +40 -0
  836. package/dist/icons/ui-icons/video-poster-image.js +40 -0
  837. package/dist/icons/ui-icons/video-subtitle-alt.js +39 -0
  838. package/dist/icons/ui-icons/video-subtitle.js +27 -0
  839. package/dist/icons/ui-icons/video.js +36 -0
  840. package/dist/icons/ui-icons/visibility-alt.js +40 -0
  841. package/dist/icons/ui-icons/visibility-alt2.js +41 -0
  842. package/dist/icons/ui-icons/visibility.js +45 -0
  843. package/dist/icons/ui-icons/visible.js +28 -0
  844. package/dist/icons/ui-icons/volume.js +25 -0
  845. package/dist/icons/ui-icons/warning-circle-fill-transparent.js +30 -0
  846. package/dist/icons/ui-icons/warning-circle-fill.js +17 -0
  847. package/dist/icons/ui-icons/warning-circle.js +33 -0
  848. package/dist/icons/ui-icons/warning-fill-transparent.js +30 -0
  849. package/dist/icons/ui-icons/warning-fill.js +17 -0
  850. package/dist/icons/ui-icons/warning.js +30 -0
  851. package/dist/icons/ui-icons/web-video.js +63 -0
  852. package/dist/icons/ui-icons/wide-bottom.js +49 -0
  853. package/dist/icons/ui-icons/wide-left.js +49 -0
  854. package/dist/icons/ui-icons/wide-right.js +49 -0
  855. package/dist/icons/ui-icons/wide-top.js +49 -0
  856. package/dist/icons/ui-icons/width.js +29 -0
  857. package/dist/icons/ui-icons/wordpress.js +17 -0
  858. package/dist/icons/ui-icons/wrapper-alt.js +71 -0
  859. package/dist/icons/ui-icons/wrapper-config.js +41 -0
  860. package/dist/icons/ui-icons/wrapper-off-alt.js +19 -0
  861. package/dist/icons/ui-icons/wrapper-overflow.js +31 -0
  862. package/dist/icons/ui-icons/wrapper-simple-alt.js +58 -0
  863. package/dist/icons/ui-icons/wrapper-simple.js +32 -0
  864. package/dist/icons/ui-icons/wrapper.js +42 -0
  865. package/dist/icons/ui-icons/wrench.js +19 -0
  866. package/dist/icons/ui-icons/zap-fill.js +20 -0
  867. package/dist/icons/ui-icons/zap.js +19 -0
  868. package/dist/index.js +32 -108
  869. package/dist/input-field-UCZL5bqv.js +290 -0
  870. package/dist/jsx-svg-OBADs_Qs.js +11123 -0
  871. package/dist/link-input-D7iDRpOM.js +1821 -0
  872. package/dist/modal-DbVLYMkH.js +318 -0
  873. package/dist/number-ZZIxJukn.js +40 -0
  874. package/dist/number-picker-CkA1iJNZ.js +268 -0
  875. package/dist/proxy-BG7-_Ou3.js +9638 -0
  876. package/dist/shared-DFDimxvX.js +1038 -0
  877. package/dist/smart-image-CbSsEASF.js +284 -0
  878. package/dist/solid-color-picker-DbT-aoVx.js +1415 -0
  879. package/dist/style-admin.js +1 -1
  880. package/dist/style-editor.js +1 -1
  881. package/dist/style.js +1 -1
  882. package/dist/switch-L8dFSQWQ.js +274 -0
  883. package/dist/tabs-BrdyBER5.js +975 -0
  884. package/dist/textSelection-Dv6WPj0Z.js +45 -0
  885. package/dist/toggle-button-DJ8jNQ-9.js +424 -0
  886. package/dist/tooltip-BzJzYlcc.js +440 -0
  887. package/dist/useAsyncList-BNzwKoX4.js +412 -0
  888. package/dist/useButton-ra1ZSZ4z.js +57 -0
  889. package/dist/useEvent-DkZVfgsS.js +22 -0
  890. package/dist/useField-D0WrzR2F.js +32 -0
  891. package/dist/useFilter-OiMnf6sb.js +44 -0
  892. package/dist/useFocusRing-DuYL4cdO.js +98 -0
  893. package/dist/useFormReset-DdkykzAn.js +18 -0
  894. package/dist/useHover-qaMm3XFO.js +982 -0
  895. package/dist/useLabel-2EohW5l6.js +27 -0
  896. package/dist/useLabels-B2p7RXi5.js +16 -0
  897. package/dist/useListState-CD_5vfyy.js +147 -0
  898. package/dist/useLocalizedStringFormatter-Dv2diN3k.js +108 -0
  899. package/dist/useNumberField-2xbi3jRV.js +1318 -0
  900. package/dist/useNumberFormatter-C2Cm2mNj.js +10 -0
  901. package/dist/usePress-ZP1TjkFf.js +678 -0
  902. package/dist/useToggle-ecIirvIM.js +64 -0
  903. package/dist/useToggleState-IIDbiKPl.js +23 -0
  904. package/dist/utilities/array-helpers.js +38 -49
  905. package/dist/utilities/debounce-throttle.js +2 -123
  906. package/dist/utilities/es-dash.js +2 -400
  907. package/dist/utilities/general.js +2 -10
  908. package/dist/utilities/hash.js +31 -35
  909. package/dist/utilities/index.js +6 -41
  910. package/dist/utilities/text-helpers.js +96 -129
  911. package/dist/utilities/web-workers.js +61 -44
  912. package/dist/utilities-CPFDXC3B.js +7 -0
  913. package/dist/utils-B_uiqNa4.js +372 -0
  914. package/dist/workers/image-analysis.worker.js +56 -48
  915. package/package.json +30 -18
  916. package/dist/Button-DtRmB6b8.js +0 -243
  917. package/dist/Dialog-DTIxSDhz.js +0 -2790
  918. package/dist/FieldError-BPG0hKfB.js +0 -42
  919. package/dist/FocusScope-CjFQ7cbd.js +0 -832
  920. package/dist/Form-Cq3fu75_.js +0 -5
  921. package/dist/Heading-CY-_gt-U.js +0 -16
  922. package/dist/Hidden-DOH36apC.js +0 -58
  923. package/dist/Input-BG9DaxYN.js +0 -169
  924. package/dist/Label-_aSf9-8u.js +0 -18
  925. package/dist/List-CQFXnN4w.js +0 -590
  926. package/dist/ListBox-DXFyyj_r.js +0 -695
  927. package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
  928. package/dist/OverlayArrow-Fuxj-1QM.js +0 -614
  929. package/dist/PortalProvider-BQ1X8vGX.js +0 -19
  930. package/dist/RSPContexts-CJ-HBf0L.js +0 -18
  931. package/dist/RadioGroup-DCeiLxLK.js +0 -371
  932. package/dist/SearchField-B_yKFXRk.js +0 -817
  933. package/dist/SelectionIndicator-D7WMzeAW.js +0 -7
  934. package/dist/SelectionManager-B02LcxLr.js +0 -2505
  935. package/dist/SharedElementTransition-CtoWSaF0.js +0 -12
  936. package/dist/Slider-bR3fAmim.js +0 -897
  937. package/dist/Text-CjFEHSfr.js +0 -17
  938. package/dist/VisuallyHidden-DZnWrkn8.js +0 -48
  939. package/dist/animation-Dfl8uEb3.js +0 -67
  940. package/dist/clsx-DgYk2OaC.js +0 -16
  941. package/dist/color-swatch-bUFkK7ox.js +0 -2570
  942. package/dist/components/smart-image/image-analysis-worker-next.js +0 -144
  943. package/dist/components/smart-image/smart-image-next.js +0 -294
  944. package/dist/context-iUFQCK8m.js +0 -95
  945. package/dist/default-i18n-CnQeC5Pl.js +0 -731
  946. package/dist/filterDOMProps-eGTqWSTd.js +0 -71
  947. package/dist/general-BfKmjm56.js +0 -4378
  948. package/dist/index-BHpUy2Ix.js +0 -44
  949. package/dist/index-BL5gdWX4.js +0 -28323
  950. package/dist/number-7sOvrqo0.js +0 -41
  951. package/dist/proxy-CNEXmkdK.js +0 -7948
  952. package/dist/react-jsx-parser.min-DAh4myol.js +0 -11736
  953. package/dist/shared-CNH8QfV9.js +0 -1111
  954. package/dist/sprintf-DmNrJSYG.js +0 -51
  955. package/dist/textSelection-DA3VcKpG.js +0 -46
  956. package/dist/useAsyncList-DsZvQXls.js +0 -453
  957. package/dist/useButton-DyMX0EVr.js +0 -59
  958. package/dist/useEvent-Bfy68GHZ.js +0 -22
  959. package/dist/useFilter-Bg5C34XC.js +0 -50
  960. package/dist/useFocusRing-B2glEZ25.js +0 -114
  961. package/dist/useFormReset-BoxsKyJ9.js +0 -20
  962. package/dist/useFormValidation-BrbMhS2N.js +0 -232
  963. package/dist/useHover-DkmPQdGE.js +0 -1047
  964. package/dist/useLabel-DzXzKZZZ.js +0 -27
  965. package/dist/useLabels-D8O3gOdV.js +0 -23
  966. package/dist/useListState-BjnzKozj.js +0 -171
  967. package/dist/useLocalizedStringFormatter-CEDs0LsA.js +0 -121
  968. package/dist/useNumberField-CsygZKz9.js +0 -1330
  969. package/dist/useNumberFormatter-CG_IQXp9.js +0 -13
  970. package/dist/usePress-Ck5xMtDr.js +0 -701
  971. package/dist/useToggle-Ddc7N8pR.js +0 -72
  972. package/dist/useToggleState-H_lORSWO.js +0 -23
  973. package/dist/utils-Cr3pLd9c.js +0 -420
@@ -1,4378 +0,0 @@
1
- import { cyrb64Hash } from "./utilities/hash.js";
2
- var Lane = /* @__PURE__ */ ((Lane2) => {
3
- Lane2[Lane2["ALPHA"] = 0] = "ALPHA";
4
- Lane2[Lane2["BLUE"] = 1] = "BLUE";
5
- Lane2[Lane2["GREEN"] = 2] = "GREEN";
6
- Lane2[Lane2["RED"] = 3] = "RED";
7
- return Lane2;
8
- })(Lane || {});
9
- const ROT_IDS = ["rotateCW", "rotate180", "rotateCCW"];
10
- const adaptiveCanvas2d = (width, height = width, parent, opts = {}) => {
11
- const canvas = document.createElement("canvas");
12
- adaptDPI(canvas, width, height, opts.dpr);
13
- opts.pixelated && (canvas.style.imageRendering = "pixelated");
14
- return {
15
- canvas,
16
- ctx: canvas.getContext("2d", opts.ctx)
17
- };
18
- };
19
- const canvas2d = (width, height = width, parent, opts) => adaptiveCanvas2d(width, height, parent, { dpr: 1, ...opts });
20
- const adaptDPI = (canvas, width, height, dpr = window.devicePixelRatio || 1) => {
21
- if (dpr !== 1) {
22
- canvas.style.width = `${width}px`;
23
- canvas.style.height = `${height}px`;
24
- }
25
- canvas.dataset.origWidth = String(width);
26
- canvas.dataset.origHeight = String(height);
27
- canvas.dataset.dpr = String(dpr);
28
- canvas.width = width * dpr;
29
- canvas.height = height * dpr;
30
- return dpr;
31
- };
32
- const isNumber = (x) => typeof x === "number";
33
- function canvasPixels(width, height, parent, opts) {
34
- let canvas;
35
- let ctx;
36
- if (isNumber(width)) {
37
- const c2 = canvas2d(width, height, parent, opts);
38
- canvas = c2.canvas;
39
- ctx = c2.ctx;
40
- } else {
41
- canvas = width;
42
- ctx = canvas.getContext("2d");
43
- }
44
- const img = ctx.getImageData(0, 0, canvas.width, canvas.height);
45
- const data = new Uint32Array(img.data.buffer);
46
- return {
47
- canvas,
48
- ctx,
49
- img,
50
- data
51
- };
52
- }
53
- const nomixin = (_, __, descriptor) => {
54
- descriptor.configurable = false;
55
- };
56
- const mixin = (behaviour, sharedBehaviour = {}) => {
57
- const instanceKeys = Reflect.ownKeys(behaviour);
58
- const sharedKeys = Reflect.ownKeys(sharedBehaviour);
59
- const typeTag = /* @__PURE__ */ Symbol("isa");
60
- function _mixin(clazz) {
61
- for (const key of instanceKeys) {
62
- const existing = Object.getOwnPropertyDescriptor(
63
- clazz.prototype,
64
- key
65
- );
66
- if (!existing || existing.configurable) {
67
- Object.defineProperty(clazz.prototype, key, {
68
- value: behaviour[key],
69
- writable: true
70
- });
71
- }
72
- }
73
- Object.defineProperty(clazz.prototype, typeTag, { value: true });
74
- return clazz;
75
- }
76
- for (const key of sharedKeys) {
77
- Object.defineProperty(_mixin, key, {
78
- value: sharedBehaviour[key],
79
- enumerable: sharedBehaviour.propertyIsEnumerable(key)
80
- });
81
- }
82
- Object.defineProperty(_mixin, Symbol.hasInstance, {
83
- value: (x) => !!x[typeTag]
84
- });
85
- return _mixin;
86
- };
87
- mixin({
88
- order() {
89
- return [0];
90
- },
91
- includes(x) {
92
- return x >= 0 && x < this.size[0];
93
- },
94
- indexAt(x) {
95
- return this.includes(x) ? this.indexAtUnsafe(x) : -1;
96
- },
97
- indexAtUnsafe(x) {
98
- return this.offset + (x | 0) * this.stride[0];
99
- },
100
- getAt(x) {
101
- return this.includes(x) ? this.data[this.indexAtUnsafe(x)] : 0;
102
- },
103
- getAtUnsafe(x) {
104
- return this.data[this.indexAtUnsafe(x)];
105
- },
106
- setAt(x, val) {
107
- return this.includes(x) ? (this.data[this.indexAtUnsafe(x)] = val, true) : false;
108
- },
109
- setAtUnsafe(x, val) {
110
- this.data[this.indexAtUnsafe(x)] = val;
111
- return true;
112
- }
113
- });
114
- const IGrid2DMixin = mixin({
115
- order() {
116
- return Math.abs(this.stride[1]) > Math.abs(this.stride[0]) ? [1, 0] : [0, 1];
117
- },
118
- includes(x, y) {
119
- const size = this.size;
120
- return x >= 0 && x < size[0] && y >= 0 && y < size[1];
121
- },
122
- indexAt(x, y) {
123
- return this.includes(x, y) ? this.indexAtUnsafe(x, y) : -1;
124
- },
125
- indexAtUnsafe(x, y) {
126
- return this.offset + (x | 0) * this.stride[0] + (y | 0) * this.stride[1];
127
- },
128
- getAt(x, y) {
129
- return this.includes(x, y) ? this.data[this.indexAtUnsafe(x, y)] : 0;
130
- },
131
- getAtUnsafe(x, y) {
132
- return this.data[this.indexAtUnsafe(x, y)];
133
- },
134
- setAt(x, y, val) {
135
- return this.includes(x, y) ? (this.data[this.indexAtUnsafe(x, y)] = val, true) : false;
136
- },
137
- setAtUnsafe(x, y, val) {
138
- this.data[this.indexAtUnsafe(x, y)] = val;
139
- return true;
140
- }
141
- });
142
- mixin({
143
- order() {
144
- return __strideOrder(this.stride);
145
- },
146
- includes(x, y, z) {
147
- const size = this.size;
148
- return x >= 0 && x < size[0] && y >= 0 && y < size[1] && z >= 0 && z < size[2];
149
- },
150
- indexAt(x, y, z) {
151
- return this.includes(x, y, z) ? this.indexAtUnsafe(x, y, z) : -1;
152
- },
153
- indexAtUnsafe(x, y, z) {
154
- const stride = this.stride;
155
- return this.offset + (x | 0) * stride[0] + (y | 0) * stride[1] + (z | 0) * stride[2];
156
- },
157
- getAt(x, y, z) {
158
- return this.includes(x, y, z) ? this.data[this.indexAtUnsafe(x, y, z)] : 0;
159
- },
160
- getAtUnsafe(x, y, z) {
161
- return this.data[this.indexAtUnsafe(x, y, z)];
162
- },
163
- setAt(x, y, z, val) {
164
- return this.includes(x, y, z) ? (this.data[this.indexAtUnsafe(x, y, z)] = val, true) : false;
165
- },
166
- setAtUnsafe(x, y, z, val) {
167
- this.data[this.indexAtUnsafe(x, y, z)] = val;
168
- return true;
169
- }
170
- });
171
- mixin({
172
- order() {
173
- return __strideOrder(this.stride);
174
- },
175
- includes(x, y, z, w) {
176
- const size = this.size;
177
- return x >= 0 && x < size[0] && y >= 0 && y < size[1] && z >= 0 && z < size[2] && w >= 0 && w < size[3];
178
- },
179
- indexAt(x, y, z, w) {
180
- return this.includes(x, y, z, w) ? this.indexAtUnsafe(x, y, z, w) : -1;
181
- },
182
- indexAtUnsafe(x, y, z, w) {
183
- const stride = this.stride;
184
- return this.offset + (x | 0) * stride[0] + (y | 0) * stride[1] + (z | 0) * stride[2] + (w | 0) * stride[3];
185
- },
186
- getAt(x, y, z, w) {
187
- return this.includes(x, y, z, w) ? this.data[this.indexAtUnsafe(x, y, z, w)] : 0;
188
- },
189
- getAtUnsafe(x, y, z, w) {
190
- return this.data[this.indexAtUnsafe(x, y, z, w)];
191
- },
192
- setAt(x, y, z, w, val) {
193
- return this.includes(x, y, z, w) ? (this.data[this.indexAtUnsafe(x, y, z, w)] = val, true) : false;
194
- },
195
- setAtUnsafe(x, y, z, w, val) {
196
- this.data[this.indexAtUnsafe(x, y, z, w)] = val;
197
- return true;
198
- }
199
- });
200
- const __strideOrder = (strides) => [...strides].map((x, i) => [x, i]).sort((a2, b2) => Math.abs(b2[0]) - Math.abs(a2[0])).map((x) => x[1]);
201
- const isString = (x) => typeof x === "string";
202
- const defError = (prefix, suffix = (msg) => msg !== void 0 ? ": " + msg : "") => class extends Error {
203
- origMessage;
204
- constructor(msg) {
205
- super(prefix(msg) + suffix(msg));
206
- this.origMessage = msg !== void 0 ? String(msg) : "";
207
- }
208
- };
209
- const __vite_import_meta_env__ = {};
210
- const AssertionError = defError(() => "Assertion failed");
211
- const assert = (typeof process !== "undefined" && process.env !== void 0 ? process.env.NODE_ENV !== "production" || !!process.env.UMBRELLA_ASSERTS : __vite_import_meta_env__ ? false : true) ? (test, msg) => {
212
- if (typeof test === "function" && !test() || !test) {
213
- throw new AssertionError(
214
- typeof msg === "function" ? msg() : msg
215
- );
216
- }
217
- } : () => {
218
- };
219
- const clamp$1 = (x, min2, max2) => x < min2 ? min2 : x > max2 ? max2 : x;
220
- const clamp01 = (x) => x < 0 ? 0 : x > 1 ? 1 : x;
221
- const setC4$1 = (out, a2, b2, c2, d2) => (out[0] = a2, out[1] = b2, out[2] = c2, out[3] = d2, out);
222
- const premultiply = (out, src) => {
223
- const a2 = src[3];
224
- return setC4$1(src, src[0] * a2, src[1] * a2, src[2] * a2, a2);
225
- };
226
- const premultiplyInt = (src) => {
227
- const a2 = (src >>> 24) / 255;
228
- return src & 4278190080 | (src >>> 16 & 255) * a2 << 16 | (src >>> 8 & 255) * a2 << 8 | (src & 255) * a2;
229
- };
230
- const postmultiply = (out, src) => {
231
- const a2 = src[3];
232
- return a2 > 0 ? setC4$1(src, src[0] / a2, src[1] / a2, src[2] / a2, a2) : src;
233
- };
234
- const postmultiplyInt = (src) => {
235
- const a2 = (src >>> 24) / 255;
236
- return a2 > 0 ? (src & 4278190080 | Math.min(255, (src >>> 16 & 255) / a2) << 16 | Math.min(255, (src >>> 8 & 255) / a2) << 8 | Math.min(255, (src & 255) / a2)) >>> 0 : src;
237
- };
238
- const isPremultiplied = (src) => {
239
- const a2 = src[3];
240
- return src[0] <= a2 && src[1] <= a2 || src[2] <= a2;
241
- };
242
- const isPremultipliedInt = (src) => {
243
- const a2 = src >>> 24;
244
- return (src >>> 16 & 255) <= a2 && (src >>> 8 & 255) <= a2 && (src & 255) <= a2;
245
- };
246
- const ensureSize = (data, width, height, stride = 1) => assert(data.length >= width * height * stride, "pixel buffer too small");
247
- const ensureImageData = (data, width, height) => data ? (ensureImageDataSize(data, width, height), data) : new ImageData(width, height);
248
- const ensureImageDataSize = (data, width, height) => assert(
249
- data.width === width && data.height === height,
250
- "imagedata has wrong dimensions"
251
- );
252
- const ensureChannel = (fmt, id) => {
253
- const chan = fmt.channels[id];
254
- assert(chan != null, `invalid channel ID: ${id}`);
255
- return chan;
256
- };
257
- const ensureAlpha = (fmt) => assert(!!fmt.alpha, "missing alpha channel");
258
- const identity$1 = (x) => x;
259
- const __luminanceABGR = (c2) => ((c2 >>> 16 & 255) * 29 + (c2 >>> 8 & 255) * 150 + (c2 & 255) * 76) / 255;
260
- const __clampRegion = (sx, sy, w, h, maxw, maxh, dx = 0, dy = 0) => {
261
- sx |= 0;
262
- sy |= 0;
263
- w |= 0;
264
- h |= 0;
265
- sx < 0 && (w += sx, dx -= sx, sx = 0);
266
- sy < 0 && (h += sy, dy -= sy, sy = 0);
267
- return [sx, sy, clamp$1(w, 0, maxw - sx), clamp$1(h, 0, maxh - sy), dx, dy];
268
- };
269
- const __prepRegions = (src, dest, opts = {}) => {
270
- const sw = src.width;
271
- const dw = dest.width;
272
- let sx, sy;
273
- let dx, dy;
274
- let rw, rh;
275
- [sx, sy, rw, rh] = __clampRegion(
276
- opts.sx || 0,
277
- opts.sy || 0,
278
- opts.w || sw,
279
- opts.h || src.height,
280
- sw,
281
- src.height
282
- );
283
- [dx, dy, rw, rh, sx, sy] = __clampRegion(
284
- opts.dx || 0,
285
- opts.dy || 0,
286
- rw,
287
- rh,
288
- dw,
289
- dest.height,
290
- sx,
291
- sy
292
- );
293
- return { sx, sy, dx, dy, rw, rh };
294
- };
295
- const __setChannelUni = (dbuf, src, set5) => {
296
- for (let i = dbuf.length; i-- > 0; ) {
297
- dbuf[i] = set5(dbuf[i], src);
298
- }
299
- };
300
- const __setChannelSame = (dbuf, sbuf, get, set5) => {
301
- for (let i = dbuf.length; i-- > 0; ) {
302
- dbuf[i] = set5(dbuf[i], get(sbuf[i]));
303
- }
304
- };
305
- const __setChannelConvert = (dbuf, sbuf, from, sto, mask) => {
306
- const invMask = ~mask;
307
- for (let i = dbuf.length; i-- > 0; ) {
308
- dbuf[i] = dbuf[i] & invMask | from(sto(sbuf[i])) & mask;
309
- }
310
- };
311
- const __transformABGR = (pix, format, fn) => {
312
- const from = format.fromABGR;
313
- const to = format.toABGR;
314
- for (let i = pix.length; i-- > 0; ) {
315
- pix[i] = from(fn(to(pix[i])));
316
- }
317
- };
318
- const __blitCanvas = (buf, canvas, opts = {}) => (canvas instanceof HTMLCanvasElement || canvas instanceof OffscreenCanvas ? canvas.getContext("2d") : canvas).putImageData(buf.toImageData(opts.data), opts.x || 0, opts.y || 0);
319
- const defFloatFormat = (fmt) => {
320
- const chan = fmt.channels;
321
- const chanShift = chan.reduce(
322
- (acc, ch) => (acc[ch] = 3 - ch << 3, acc),
323
- {}
324
- );
325
- const res = {
326
- ...fmt,
327
- __float: true,
328
- size: chan.length,
329
- shift: chanShift,
330
- range: [0, 1],
331
- normalized: clamp01,
332
- fromNormalized: identity$1
333
- };
334
- if (fmt.convert) {
335
- Object.assign(res, fmt.convert);
336
- return res;
337
- }
338
- const to = (col, i) => (clamp01(col[i]) * 255 + 0.5 | 0) << chanShift[chan[i]];
339
- const from = (col, i) => (col >>> chanShift[chan[i]] & 255) / 255;
340
- switch (chan.length) {
341
- case 1:
342
- fmt.gray ? __defConvert1Gray(res) : __defConvert1(res, from, to);
343
- break;
344
- case 2:
345
- fmt.gray ? __defConvert2Gray(res, from) : __defConvert2(res, from, to);
346
- break;
347
- case 3:
348
- __defConvert3(res, from, to);
349
- break;
350
- case 4:
351
- __defConvert4(res, from, to);
352
- break;
353
- }
354
- return res;
355
- };
356
- const __defConvert1 = (res, from, to) => {
357
- res.toABGR = (col) => {
358
- let out = res.alpha ? 0 : 4278190080;
359
- out |= to(col, 0);
360
- return out >>> 0;
361
- };
362
- res.fromABGR = (col, out = []) => {
363
- out[0] = from(col, 0);
364
- return out;
365
- };
366
- };
367
- const __defConvert1Gray = (res) => {
368
- res.toABGR = (col) => ((clamp01(col[0]) * 255 + 0.5 | 0) * 65793 | 4278190080) >>> 0;
369
- res.fromABGR = (col, out = []) => (out[0] = __luminanceABGR(col) / 255, out);
370
- };
371
- const __defConvert2 = (res, from, to) => {
372
- res.toABGR = (col) => {
373
- let out = res.alpha ? 0 : 4278190080;
374
- out |= to(col, 0);
375
- out |= to(col, 1);
376
- return out >>> 0;
377
- };
378
- res.fromABGR = (col, out = []) => {
379
- out[0] = from(col, 0);
380
- out[1] = from(col, 1);
381
- return out;
382
- };
383
- };
384
- const __defConvert2Gray = (res, from) => {
385
- const gray = ~~(res.channels[0] === Lane.ALPHA);
386
- const alpha = gray ^ 1;
387
- res.toABGR = (col) => {
388
- let out = (clamp01(col[gray]) * 255 + 0.5 | 0) * 65793;
389
- out |= (col[alpha] * 255 + 0.5 | 0) << 24;
390
- return out >>> 0;
391
- };
392
- res.fromABGR = (col, out = []) => {
393
- out[gray] = __luminanceABGR(col) / 255;
394
- out[alpha] = from(col, alpha);
395
- return out;
396
- };
397
- };
398
- const __defConvert3 = (res, from, to) => {
399
- res.toABGR = (col) => {
400
- let out = res.alpha ? 0 : 4278190080;
401
- out |= to(col, 0);
402
- out |= to(col, 1);
403
- out |= to(col, 2);
404
- return out >>> 0;
405
- };
406
- res.fromABGR = (col, out = []) => {
407
- out[0] = from(col, 0);
408
- out[1] = from(col, 1);
409
- out[2] = from(col, 2);
410
- return out;
411
- };
412
- };
413
- const __defConvert4 = (res, from, to) => {
414
- res.toABGR = (col) => {
415
- let out = res.alpha ? 0 : 4278190080;
416
- out |= to(col, 0);
417
- out |= to(col, 1);
418
- out |= to(col, 2);
419
- out |= to(col, 3);
420
- return out >>> 0;
421
- };
422
- res.fromABGR = (col, out = []) => {
423
- out[0] = from(col, 0);
424
- out[1] = from(col, 1);
425
- out[2] = from(col, 2);
426
- out[3] = from(col, 3);
427
- return out;
428
- };
429
- };
430
- const FLOAT_GRAY = defFloatFormat({
431
- gray: true,
432
- channels: [Lane.RED]
433
- });
434
- const GL2TYPE = {
435
- [
436
- 5120
437
- /* I8 */
438
- ]: "i8",
439
- [
440
- 5121
441
- /* U8 */
442
- ]: "u8",
443
- [
444
- 5122
445
- /* I16 */
446
- ]: "i16",
447
- [
448
- 5123
449
- /* U16 */
450
- ]: "u16",
451
- [
452
- 5124
453
- /* I32 */
454
- ]: "i32",
455
- [
456
- 5125
457
- /* U32 */
458
- ]: "u32",
459
- [
460
- 5126
461
- /* F32 */
462
- ]: "f32"
463
- };
464
- const FLOAT_ARRAY_CTORS = {
465
- f32: Float32Array,
466
- f64: Float64Array
467
- };
468
- const INT_ARRAY_CTORS = {
469
- i8: Int8Array,
470
- i16: Int16Array,
471
- i32: Int32Array
472
- };
473
- const UINT_ARRAY_CTORS = {
474
- u8: Uint8Array,
475
- u8c: Uint8ClampedArray,
476
- u16: Uint16Array,
477
- u32: Uint32Array
478
- };
479
- const BIGINT_ARRAY_CTORS = {
480
- i64: BigInt64Array,
481
- u64: BigUint64Array
482
- };
483
- const TYPEDARRAY_CTORS = {
484
- ...FLOAT_ARRAY_CTORS,
485
- ...INT_ARRAY_CTORS,
486
- ...UINT_ARRAY_CTORS
487
- };
488
- const asNativeType = (type) => {
489
- const t = GL2TYPE[type];
490
- return t !== void 0 ? t : type;
491
- };
492
- function typedArray(type, ...args) {
493
- const ctor = BIGINT_ARRAY_CTORS[type];
494
- return new (ctor || TYPEDARRAY_CTORS[asNativeType(type)])(...args);
495
- }
496
- const uintTypeForBits = (x) => x > 16 ? "u32" : x > 8 ? "u16" : "u8";
497
- const __compileLShift = (x, shift) => shift > 0 ? `(${x} << ${shift})` : shift < 0 ? `(${x} >>> ${-shift})` : `${x}`;
498
- const __compileRShift = (x, shift) => __compileLShift(x, -shift);
499
- const __hex = (x) => `0x${x.toString(16)}`;
500
- const __compileGrayFromABGR = (size) => {
501
- const shift = 8 - size;
502
- const mask = (1 << size) - 1;
503
- return new Function(
504
- "luma",
505
- `return (x) => ${__compileRShift("luma(x)", shift)} & ${mask};`
506
- )(__luminanceABGR);
507
- };
508
- const __compileGrayToABGR = (size) => {
509
- let body;
510
- if (size !== 8) {
511
- const mask = (1 << size) - 1;
512
- const scale = 255 / mask;
513
- body = `(((x & ${mask}) * ${scale}) | 0)`;
514
- } else {
515
- body = "x";
516
- }
517
- return new Function("x", `return 0xff000000 | (${body} * 0x010101);`);
518
- };
519
- const __compileFromABGR = (chans) => new Function(
520
- "x",
521
- "return (" + chans.map((ch) => {
522
- const shift = ch.abgrShift + (8 - ch.size);
523
- return `(${__compileRShift("x", shift)} & ${__hex(
524
- ch.maskA
525
- )})`;
526
- }).join(" | ") + ") >>> 0;"
527
- );
528
- const __compileToABGR = (chans, hasAlpha) => {
529
- const body = chans.map((ch) => {
530
- if (ch.size !== 8) {
531
- const mask = ch.mask0;
532
- const scale = 255 / mask;
533
- const inner = __compileRShift("x", ch.shift);
534
- return __compileLShift(
535
- `((${inner} & ${mask}) * ${scale})`,
536
- 24 - ch.lane * 8
537
- );
538
- } else {
539
- return __compileLShift(
540
- `(x & ${__hex(ch.maskA)})`,
541
- ch.abgrShift
542
- );
543
- }
544
- }).join(" | ");
545
- const alpha = !hasAlpha ? `0xff000000 | ` : "";
546
- return new Function("x", `return (${alpha}${body}) >>> 0;`);
547
- };
548
- const __defChannel = (ch, idx, shift) => {
549
- const num = 1 << ch.size;
550
- const mask0 = num - 1;
551
- const maskA = mask0 << shift >>> 0;
552
- const invMask = ~maskA >>> 0;
553
- const lane = ch.lane != null ? ch.lane : idx;
554
- const int = (x) => x >>> shift & mask0;
555
- const setInt = (src, x) => src & invMask | (x & mask0) << shift;
556
- return {
557
- size: ch.size,
558
- num,
559
- abgrShift: 24 - lane * 8 - shift,
560
- lane,
561
- shift,
562
- mask0,
563
- maskA,
564
- int,
565
- setInt,
566
- float: (x) => int(x) / mask0,
567
- setFloat: (src, x) => setInt(src, clamp01(x) * mask0)
568
- };
569
- };
570
- const defIntFormat = (fmt) => {
571
- assert(fmt.channels.length > 0, "no channel specs given");
572
- const channels = fmt.channels.reduce(
573
- ([defs, shift], ch, i) => {
574
- shift -= ch.size;
575
- defs.push(__defChannel(ch, i, shift));
576
- return [defs, shift];
577
- },
578
- [[], fmt.size]
579
- )[0];
580
- return {
581
- __packed: true,
582
- type: fmt.type,
583
- size: fmt.size,
584
- alpha: fmt.alpha || 0,
585
- channels,
586
- fromABGR: fmt.fromABGR || __compileFromABGR(channels),
587
- toABGR: fmt.toABGR || __compileToABGR(channels, !!fmt.alpha)
588
- };
589
- };
590
- const ABGR8888 = defIntFormat({
591
- type: "u32",
592
- size: 32,
593
- alpha: 8,
594
- channels: [
595
- { size: 8, lane: Lane.ALPHA },
596
- { size: 8, lane: Lane.BLUE },
597
- { size: 8, lane: Lane.GREEN },
598
- { size: 8, lane: Lane.RED }
599
- ],
600
- fromABGR: identity$1,
601
- toABGR: identity$1
602
- });
603
- const PI = Math.PI;
604
- const TAU = PI * 2;
605
- const INV_TAU = 1 / TAU;
606
- let EPS = 1e-6;
607
- const mixBilinear = (a2, b2, c2, d2, u, v) => {
608
- const iu = 1 - u;
609
- const iv = 1 - v;
610
- return a2 * iu * iv + b2 * u * iv + c2 * iu * v + d2 * u * v;
611
- };
612
- const mixCubicHermiteFromPoints = (a2, b2, c2, d2, t) => {
613
- d2 *= 0.5;
614
- const aa = -0.5 * a2 + 1.5 * b2 - 1.5 * c2 + d2;
615
- const bb = a2 - 2.5 * b2 + 2 * c2 - d2;
616
- const cc = -0.5 * a2 + 0.5 * c2;
617
- const dd = b2;
618
- const t2 = t * t;
619
- return t * t2 * aa + t2 * bb + t * cc + dd;
620
- };
621
- const mixBicubic = (s00, s01, s02, s03, s10, s11, s12, s13, s20, s21, s22, s23, s30, s31, s32, s33, u, v) => mixCubicHermiteFromPoints(
622
- mixCubicHermiteFromPoints(s00, s01, s02, s03, u),
623
- mixCubicHermiteFromPoints(s10, s11, s12, s13, u),
624
- mixCubicHermiteFromPoints(s20, s21, s22, s23, u),
625
- mixCubicHermiteFromPoints(s30, s31, s32, s33, u),
626
- v
627
- );
628
- const mod = (a2, b2) => a2 - b2 * Math.floor(a2 / b2);
629
- const fract = (x) => x - Math.floor(x);
630
- const roundTo = (x, prec = 1) => Math.round(x / prec) * prec;
631
- function defSampler(src, filter = "linear", wrap = "clamp") {
632
- const isFloat = !!src.format.__float;
633
- const suffix = src.format.channels.length === 1 ? "1" : "";
634
- const id = `${filter[0]}${wrap[0]}${suffix}`;
635
- const impl = (isFloat ? {
636
- nc1: __sampleFNC,
637
- nw1: __sampleFNW,
638
- nr1: __sampleFNR,
639
- nc: __sampleFNC,
640
- nw: __sampleFNW,
641
- nr: __sampleFNR,
642
- lc1: (src2) => __bilinearGrayF(__sampleINC(src2)),
643
- lw1: (src2) => __bilinearGrayF(__sampleINW(src2)),
644
- lr1: (src2) => __bilinearGrayF(__sampleINR(src2)),
645
- lc: (src2) => __bilinearFloat(src2, __sampleFNC(src2)),
646
- lw: (src2) => __bilinearFloat(src2, __sampleFNW(src2)),
647
- lr: (src2) => __bilinearFloat(src2, __sampleFNR(src2)),
648
- cc1: (src2) => __bicubicGrayF(__sampleINC(src2)),
649
- cw1: (src2) => __bicubicGrayF(__sampleINW(src2)),
650
- cr1: (src2) => __bicubicGrayF(__sampleINR(src2)),
651
- cc: (src2) => __bicubicFloat(src2, __sampleFNC(src2)),
652
- cw: (src2) => __bicubicFloat(src2, __sampleFNW(src2)),
653
- cr: (src2) => __bicubicFloat(src2, __sampleFNR(src2))
654
- } : {
655
- nc1: __sampleINC,
656
- nw1: __sampleINW,
657
- nr1: __sampleINR,
658
- nc: __sampleINC,
659
- nw: __sampleINW,
660
- nr: __sampleINR,
661
- lc1: (src2) => __bilinearGray(__sampleINC(src2)),
662
- lw1: (src2) => __bilinearGray(__sampleINW(src2)),
663
- lr1: (src2) => __bilinearGray(__sampleINR(src2)),
664
- lc: (src2) => __bilinearABGR(src2, __sampleINC(src2)),
665
- lw: (src2) => __bilinearABGR(src2, __sampleINW(src2)),
666
- lr: (src2) => __bilinearABGR(src2, __sampleINR(src2)),
667
- cc1: (src2) => __bicubicGrayI(src2, __sampleINC(src2)),
668
- cw1: (src2) => __bicubicGrayI(src2, __sampleINW(src2)),
669
- cr1: (src2) => __bicubicGrayI(src2, __sampleINR(src2)),
670
- cc: (src2) => __bicubicABGR(src2, __sampleINC(src2)),
671
- cw: (src2) => __bicubicABGR(src2, __sampleINW(src2)),
672
- cr: (src2) => __bicubicABGR(src2, __sampleINR(src2))
673
- })[id];
674
- assert(!!impl, `missing impl for ${id}`);
675
- return impl(src);
676
- }
677
- const __sampleINC = ({ data, width, height }) => (x, y) => x >= 0 && x < width && y >= 0 && y < height ? data[(y | 0) * width + (x | 0)] : 0;
678
- const __sampleINW = ({ data, width, height }) => (x, y) => data[mod(y | 0, height) * width + mod(x | 0, width)];
679
- const __sampleINR = ({ data, width, height }) => {
680
- const w1 = width - 1;
681
- const h1 = height - 1;
682
- return (x, y) => data[clamp$1(y | 0, 0, h1) * width + clamp$1(x | 0, 0, w1)];
683
- };
684
- const __sampleFNC = ({
685
- data,
686
- width,
687
- height,
688
- stride: [stride, rowStride]
689
- }) => (x, y) => {
690
- let i;
691
- return x >= 0 && x < width && y >= 0 && y < height ? (i = (y | 0) * rowStride + (x | 0) * stride, data.slice(i, i + stride)) : [0];
692
- };
693
- const __sampleFNW = ({
694
- data,
695
- width,
696
- height,
697
- stride: [stride, rowStride]
698
- }) => (x, y) => {
699
- let i = mod(y | 0, height) * rowStride + mod(x | 0, width) * stride;
700
- return data.slice(i, i + stride);
701
- };
702
- const __sampleFNR = ({
703
- data,
704
- width,
705
- height,
706
- stride: [stride, rowStride]
707
- }) => {
708
- const w1 = width - 1;
709
- const h1 = height - 1;
710
- return (x, y) => {
711
- let i = clamp$1(y | 0, 0, h1) * rowStride + clamp$1(x | 0, 0, w1) * stride;
712
- return data.slice(i, i + stride);
713
- };
714
- };
715
- const __mixBilinearChan = (buf, u, v, i, s = 4) => mixBilinear(buf[i], buf[i + s], buf[i + 2 * s], buf[i + 3 * s], u, v);
716
- const __bilinearGray = (sample) => (x, y) => {
717
- x -= 0.5;
718
- y -= 0.5;
719
- return mixBilinear(
720
- sample(x, y),
721
- sample(x + 1, y),
722
- sample(x, y + 1),
723
- sample(x + 1, y + 1),
724
- fract(x),
725
- fract(y)
726
- );
727
- };
728
- const __bilinearGrayF = (sample) => {
729
- sample = __bilinearGray(sample);
730
- return (x, y) => [sample(x, y)];
731
- };
732
- const __bilinearABGR = (src, sample1) => {
733
- const { fromABGR, toABGR } = src.format;
734
- const u32 = new Uint32Array(4);
735
- const u8 = new Uint8Array(u32.buffer);
736
- return (x, y) => {
737
- x -= 0.5;
738
- y -= 0.5;
739
- u32[0] = toABGR(sample1(x, y));
740
- u32[1] = toABGR(sample1(x + 1, y));
741
- u32[2] = toABGR(sample1(x, y + 1));
742
- u32[3] = toABGR(sample1(x + 1, y + 1));
743
- const u = fract(x);
744
- const v = fract(y);
745
- return fromABGR(
746
- __mixBilinearChan(u8, u, v, 0) | __mixBilinearChan(u8, u, v, 1) << 8 | __mixBilinearChan(u8, u, v, 2) << 16 | __mixBilinearChan(u8, u, v, 3) << 24
747
- ) >>> 0;
748
- };
749
- };
750
- const __bilinearFloat = ({ stride: [stride] }, sample1) => {
751
- const f32 = new Float32Array(stride * 4);
752
- return (x, y) => {
753
- x -= 0.5;
754
- y -= 0.5;
755
- f32.set(sample1(x, y), 0);
756
- f32.set(sample1(x + 1, y), stride);
757
- f32.set(sample1(x, y + 1), stride * 2);
758
- f32.set(sample1(x + 1, y + 1), stride * 3);
759
- const u = fract(x);
760
- const v = fract(y);
761
- let res = [];
762
- for (let i = 0; i < stride; i++) {
763
- res.push(__mixBilinearChan(f32, u, v, i, stride));
764
- }
765
- return res;
766
- };
767
- };
768
- const __bicubicGray = (sample) => (x, y) => {
769
- x -= 0.5;
770
- y -= 0.5;
771
- const x1 = x - 1;
772
- const x2 = x + 1;
773
- const x3 = x + 2;
774
- const y1 = y - 1;
775
- const y2 = y + 1;
776
- const y3 = y + 2;
777
- return mixBicubic(
778
- sample(x1, y1),
779
- sample(x, y1),
780
- sample(x2, y1),
781
- sample(x3, y1),
782
- sample(x1, y),
783
- sample(x, y),
784
- sample(x2, y),
785
- sample(x3, y),
786
- sample(x1, y2),
787
- sample(x, y2),
788
- sample(x2, y2),
789
- sample(x3, y2),
790
- sample(x1, y3),
791
- sample(x, y3),
792
- sample(x2, y3),
793
- sample(x3, y3),
794
- fract(x),
795
- fract(y)
796
- );
797
- };
798
- const __bicubicGrayI = (src, sample) => {
799
- const max2 = src.format.channels[0].mask0;
800
- sample = __bicubicGray(sample);
801
- return (x, y) => clamp$1(sample(x, y), 0, max2);
802
- };
803
- const __bicubicGrayF = (sample) => {
804
- sample = __bicubicGray(sample);
805
- return (x, y) => [sample(x, y)];
806
- };
807
- const __mixBicubicChan = (buf, u, v, i, s = 4) => mixBicubic(
808
- buf[i],
809
- buf[i + s],
810
- buf[i + 2 * s],
811
- buf[i + 3 * s],
812
- buf[i + 4 * s],
813
- buf[i + 5 * s],
814
- buf[i + 6 * s],
815
- buf[i + 7 * s],
816
- buf[i + 8 * s],
817
- buf[i + 9 * s],
818
- buf[i + 10 * s],
819
- buf[i + 11 * s],
820
- buf[i + 12 * s],
821
- buf[i + 13 * s],
822
- buf[i + 14 * s],
823
- buf[i + 15 * s],
824
- u,
825
- v
826
- );
827
- const __mixBicubicChanClamped = (buf, u, v, i, s = 4) => clamp$1(__mixBicubicChan(buf, u, v, i, s), 0, 255);
828
- const __bicubicABGR = (src, sample) => {
829
- const { fromABGR, toABGR } = src.format;
830
- const u32 = new Uint32Array(16);
831
- const u8 = new Uint8Array(u32.buffer);
832
- return (x, y) => {
833
- x -= 0.5;
834
- y -= 0.5;
835
- const x1 = x - 1;
836
- const x2 = x + 1;
837
- const x3 = x + 2;
838
- const y1 = y - 1;
839
- const y2 = y + 1;
840
- const y3 = y + 2;
841
- const u = fract(x);
842
- const v = fract(y);
843
- u32[0] = toABGR(sample(x1, y1));
844
- u32[1] = toABGR(sample(x, y1));
845
- u32[2] = toABGR(sample(x2, y1));
846
- u32[3] = toABGR(sample(x3, y1));
847
- u32[4] = toABGR(sample(x1, y));
848
- u32[5] = toABGR(sample(x, y));
849
- u32[6] = toABGR(sample(x2, y));
850
- u32[7] = toABGR(sample(x3, y));
851
- u32[8] = toABGR(sample(x1, y2));
852
- u32[9] = toABGR(sample(x, y2));
853
- u32[10] = toABGR(sample(x2, y2));
854
- u32[11] = toABGR(sample(x3, y2));
855
- u32[12] = toABGR(sample(x1, y3));
856
- u32[13] = toABGR(sample(x, y3));
857
- u32[14] = toABGR(sample(x2, y3));
858
- u32[15] = toABGR(sample(x3, y3));
859
- return fromABGR(
860
- __mixBicubicChanClamped(u8, u, v, 0) | __mixBicubicChanClamped(u8, u, v, 1) << 8 | __mixBicubicChanClamped(u8, u, v, 2) << 16 | __mixBicubicChanClamped(u8, u, v, 3) << 24
861
- ) >>> 0;
862
- };
863
- };
864
- const __bicubicFloat = ({ stride: [stride] }, sample) => {
865
- const f32 = new Float32Array(stride * 16);
866
- return (x, y) => {
867
- x -= 0.5;
868
- y -= 0.5;
869
- const x1 = x - 1;
870
- const x2 = x + 1;
871
- const x3 = x + 2;
872
- const y1 = y - 1;
873
- const y2 = y + 1;
874
- const y3 = y + 2;
875
- const u = fract(x);
876
- const v = fract(y);
877
- f32.set(sample(x1, y1), 0);
878
- f32.set(sample(x, y1), stride);
879
- f32.set(sample(x2, y1), 2 * stride);
880
- f32.set(sample(x3, y1), 3 * stride);
881
- f32.set(sample(x1, y), 4 * stride);
882
- f32.set(sample(x, y), 5 * stride);
883
- f32.set(sample(x2, y), 6 * stride);
884
- f32.set(sample(x3, y), 7 * stride);
885
- f32.set(sample(x1, y2), 8 * stride);
886
- f32.set(sample(x, y2), 9 * stride);
887
- f32.set(sample(x2, y2), 10 * stride);
888
- f32.set(sample(x3, y2), 11 * stride);
889
- f32.set(sample(x1, y3), 12 * stride);
890
- f32.set(sample(x, y3), 13 * stride);
891
- f32.set(sample(x2, y3), 14 * stride);
892
- f32.set(sample(x3, y3), 15 * stride);
893
- let res = [];
894
- for (let i = 0; i < stride; i++) {
895
- res.push(__mixBicubicChan(f32, u, v, i, stride));
896
- }
897
- return res;
898
- };
899
- };
900
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
901
- var __decorateClass$1 = (decorators, target, key, kind) => {
902
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
903
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
904
- if (decorator = decorators[i])
905
- result = decorator(result) || result;
906
- return result;
907
- };
908
- function intBuffer(...args) {
909
- return args[0] instanceof IntBuffer ? args[0].as(args[1]) : (
910
- // @ts-ignore
911
- new IntBuffer(...args)
912
- );
913
- }
914
- const intBufferFromCanvas = (canvas, fmt = ABGR8888) => {
915
- const { data } = canvasPixels(canvas);
916
- const w = canvas.width;
917
- const h = canvas.height;
918
- let dest;
919
- if (fmt === ABGR8888) {
920
- dest = data;
921
- } else {
922
- dest = typedArray(fmt.type, w * h);
923
- const src = data;
924
- const from = fmt.fromABGR;
925
- for (let i = dest.length; i-- > 0; ) {
926
- dest[i] = from(src[i]);
927
- }
928
- }
929
- return new IntBuffer(w, h, fmt, dest);
930
- };
931
- let IntBuffer = class {
932
- size;
933
- stride;
934
- format;
935
- data;
936
- constructor(w, h, fmt = ABGR8888, data) {
937
- this.size = [w, h];
938
- this.stride = [1, w];
939
- this.format = fmt.__packed ? fmt : defIntFormat(fmt);
940
- this.data = data || typedArray(fmt.type, w * h);
941
- }
942
- /** @deprecated use `.data` instead */
943
- get pixels() {
944
- return this.data;
945
- }
946
- get width() {
947
- return this.size[0];
948
- }
949
- get height() {
950
- return this.size[1];
951
- }
952
- // TODO support custom offsets (via ctor arg)
953
- get offset() {
954
- return 0;
955
- }
956
- get dim() {
957
- return 2;
958
- }
959
- *[Symbol.iterator]() {
960
- yield* this.data;
961
- }
962
- as(fmt) {
963
- if (!fmt.__float)
964
- return this.getRegion(
965
- 0,
966
- 0,
967
- this.width,
968
- this.height,
969
- fmt
970
- );
971
- const dest = new FloatBuffer(this.width, this.height, fmt);
972
- const {
973
- data: dbuf,
974
- format: dfmt,
975
- stride: [stride]
976
- } = dest;
977
- const { data: sbuf, format: sfmt } = this;
978
- for (let i = sbuf.length; i-- > 0; ) {
979
- dbuf.set(dfmt.fromABGR(sfmt.toABGR(sbuf[i])), i * stride);
980
- }
981
- return dest;
982
- }
983
- copy() {
984
- const dest = this.empty();
985
- dest.data.set(this.data);
986
- return dest;
987
- }
988
- empty() {
989
- return new IntBuffer(this.width, this.height, this.format);
990
- }
991
- // @ts-ignore mixin
992
- order() {
993
- }
994
- // @ts-ignore mixin
995
- includes(x, y) {
996
- }
997
- // @ts-ignore mixin
998
- indexAt(x, y) {
999
- }
1000
- // @ts-ignore mixin
1001
- indexAtUnsafe(x, y) {
1002
- }
1003
- // @ts-ignore mixin
1004
- getAt(x, y) {
1005
- }
1006
- // @ts-ignore mixin
1007
- getAtUnsafe(x, y) {
1008
- }
1009
- // @ts-ignore mixin
1010
- setAt(x, y, col) {
1011
- }
1012
- // @ts-ignore mixin
1013
- setAtUnsafe(x, y, col) {
1014
- }
1015
- getChannelAt(x, y, id, normalized = false) {
1016
- const chan = ensureChannel(this.format, id);
1017
- const col = this.getAt(x, y);
1018
- return normalized ? chan.float(col) : chan.int(col);
1019
- }
1020
- setChannelAt(x, y, id, col, normalized = false) {
1021
- const chan = ensureChannel(this.format, id);
1022
- const src = this.getAt(x, y);
1023
- normalized ? chan.setFloat(src, col) : chan.setInt(src, col);
1024
- return this;
1025
- }
1026
- blend(op, dest, opts) {
1027
- let sw = this.width;
1028
- let dw = dest.width;
1029
- const { sx, sy, dx, dy, rw, rh } = __prepRegions(this, dest, opts);
1030
- if (rw < 1 || rh < 1) return dest;
1031
- const sbuf = this.data;
1032
- const dbuf = dest.data;
1033
- const sf = this.format.toABGR;
1034
- const df1 = dest.format.toABGR;
1035
- const df2 = dest.format.fromABGR;
1036
- for (let si = (sx | 0) + (sy | 0) * sw, di = (dx | 0) + (dy | 0) * dw, yy = 0; yy < rh; yy++, si += sw, di += dw) {
1037
- for (let xx = 0; xx < rw; xx++) {
1038
- dbuf[di + xx] = df2(op(sf(sbuf[si + xx]), df1(dbuf[di + xx])));
1039
- }
1040
- }
1041
- return dest;
1042
- }
1043
- blit(dest, opts) {
1044
- let sw = this.width;
1045
- let dw = dest.width;
1046
- const { sx, sy, dx, dy, rw, rh } = __prepRegions(this, dest, opts);
1047
- if (rw < 1 || rh < 1) return dest;
1048
- const sbuf = this.data;
1049
- const dbuf = dest.data;
1050
- const sf = this.format.toABGR;
1051
- const df = dest.format.fromABGR;
1052
- const blitRow = this.format !== dest.format ? (si, di) => {
1053
- for (let xx = 0; xx < rw; xx++) {
1054
- dbuf[di + xx] = df(sf(sbuf[si + xx]));
1055
- }
1056
- } : (si, di) => dbuf.set(sbuf.subarray(si, si + rw), di);
1057
- for (let si = (sx | 0) + (sy | 0) * sw, di = (dx | 0) + (dy | 0) * dw, yy = 0; yy < rh; yy++, si += sw, di += dw) {
1058
- blitRow(si, di);
1059
- }
1060
- return dest;
1061
- }
1062
- blitCanvas(canvas, opts = {}) {
1063
- __blitCanvas(this, canvas, opts);
1064
- }
1065
- setImageData(idata) {
1066
- ensureImageDataSize(idata, this.width, this.height);
1067
- const src = new Uint32Array(idata.data.buffer);
1068
- const dest = this.data;
1069
- const fmt = this.format.fromABGR;
1070
- for (let i = src.length; i-- > 0; ) {
1071
- dest[i] = fmt(src[i]);
1072
- }
1073
- return this;
1074
- }
1075
- toImageData(idata) {
1076
- idata = ensureImageData(idata, this.width, this.height);
1077
- const dest = new Uint32Array(idata.data.buffer);
1078
- const src = this.data;
1079
- const fmt = this.format.toABGR;
1080
- for (let i = dest.length; i-- > 0; ) {
1081
- dest[i] = fmt(src[i]);
1082
- }
1083
- return idata;
1084
- }
1085
- getRegion(x, y, width, height, fmt) {
1086
- const [sx, sy, w, h] = __clampRegion(
1087
- x,
1088
- y,
1089
- width,
1090
- height,
1091
- this.width,
1092
- this.height
1093
- );
1094
- if (w < 1 || h < 1) return;
1095
- return this.blit(new IntBuffer(w, h, fmt || this.format), {
1096
- sx,
1097
- sy,
1098
- w,
1099
- h
1100
- });
1101
- }
1102
- getChannel(id) {
1103
- const chan = ensureChannel(this.format, id);
1104
- const buf = new IntBuffer(this.width, this.height, {
1105
- type: uintTypeForBits(chan.size),
1106
- size: chan.size,
1107
- channels: [{ size: chan.size, lane: Lane.RED }],
1108
- fromABGR: __compileGrayFromABGR(chan.size),
1109
- toABGR: __compileGrayToABGR(chan.size)
1110
- });
1111
- const src = this.data;
1112
- const dest = buf.data;
1113
- const get = chan.int;
1114
- for (let i = src.length; i-- > 0; ) {
1115
- dest[i] = get(src[i]);
1116
- }
1117
- return buf;
1118
- }
1119
- setChannel(id, src) {
1120
- const chan = ensureChannel(this.format, id);
1121
- const dbuf = this.data;
1122
- const set5 = chan.setInt;
1123
- if (isNumber(src)) {
1124
- __setChannelUni(dbuf, src, set5);
1125
- } else {
1126
- const sbuf = src.data;
1127
- const schan = src.format.channels[0];
1128
- ensureSize(sbuf, this.width, this.height);
1129
- if (chan.size === schan.size) {
1130
- __setChannelSame(dbuf, sbuf, schan.int, set5);
1131
- } else {
1132
- __setChannelConvert(
1133
- dbuf,
1134
- sbuf,
1135
- this.format.fromABGR,
1136
- src.format.toABGR,
1137
- chan.maskA
1138
- );
1139
- }
1140
- }
1141
- return this;
1142
- }
1143
- invert() {
1144
- const { data, format } = this;
1145
- const mask = Math.pow(2, format.size - format.alpha) - 1;
1146
- for (let i = data.length; i-- > 0; ) {
1147
- data[i] ^= mask;
1148
- }
1149
- return this;
1150
- }
1151
- premultiply() {
1152
- ensureAlpha(this.format);
1153
- __transformABGR(this.data, this.format, premultiplyInt);
1154
- return this;
1155
- }
1156
- postmultiply() {
1157
- __transformABGR(this.data, this.format, postmultiplyInt);
1158
- return this;
1159
- }
1160
- isPremultiplied() {
1161
- const pix = this.data;
1162
- const to = this.format.toABGR;
1163
- for (let i = pix.length; i-- > 0; ) {
1164
- if (!isPremultipliedInt(to(pix[i]))) {
1165
- return false;
1166
- }
1167
- }
1168
- return true;
1169
- }
1170
- forEach(f) {
1171
- const pix = this.data;
1172
- for (let i = pix.length; i-- > 0; ) {
1173
- pix[i] = f(pix[i], i);
1174
- }
1175
- return this;
1176
- }
1177
- fill(x) {
1178
- this.data.fill(x);
1179
- }
1180
- /**
1181
- * Flips image horizontally.
1182
- */
1183
- flipX() {
1184
- const { data, width } = this;
1185
- for (let i = 0; i < data.length; i += width) {
1186
- data.subarray(i, i + width).reverse();
1187
- }
1188
- return this;
1189
- }
1190
- /**
1191
- * Flips image vertically.
1192
- */
1193
- flipY() {
1194
- const { data, width } = this;
1195
- const tmp = typedArray(this.format.type, width);
1196
- for (let i = 0, j = data.length - width; i < j; i += width, j -= width) {
1197
- tmp.set(data.subarray(i, i + width));
1198
- data.copyWithin(i, j, j + width);
1199
- data.set(tmp, j);
1200
- }
1201
- return this;
1202
- }
1203
- rotateByID(id) {
1204
- return id > 0 ? this[ROT_IDS[id - 1]]() : this;
1205
- }
1206
- rotateCW() {
1207
- const { width, height } = this;
1208
- const h1 = height - 1;
1209
- this._rotate((x, y) => x * height + h1 - y);
1210
- this.size[0] = height;
1211
- this.size[1] = width;
1212
- return this;
1213
- }
1214
- rotateCCW() {
1215
- const { width, height } = this;
1216
- const w1 = width - 1;
1217
- this._rotate((x, y) => (w1 - x) * height + y);
1218
- this.size[0] = height;
1219
- this.size[1] = width;
1220
- return this;
1221
- }
1222
- rotate180() {
1223
- const { width, height } = this;
1224
- const w1 = width - 1;
1225
- const h1 = height - 1;
1226
- this._rotate((x, y) => (h1 - y) * width + w1 - x);
1227
- return this;
1228
- }
1229
- /**
1230
- * Returns scaled version of this buffer using given sampler or filter
1231
- * (default: `"linear"`) for interpolation. Syntax sugar for
1232
- * {@link IntBuffer.resize}.
1233
- *
1234
- * @param scale -
1235
- */
1236
- scale(scale, sampler = "linear") {
1237
- assert(scale > 0, `scale must be > 0`);
1238
- return this.resize(this.width * scale, this.height * scale, sampler);
1239
- }
1240
- resize(w, h, sampler = "linear") {
1241
- w |= 0;
1242
- h |= 0;
1243
- assert(w > 0 && h > 0, `target width & height must be > 0`);
1244
- const dest = intBuffer(w, h, this.format);
1245
- const dpix = dest.data;
1246
- const scaleX = w > 0 ? this.width / w : 0;
1247
- const scaleY = h > 0 ? this.height / h : 0;
1248
- sampler = isString(sampler) ? defSampler(this, sampler, "repeat") : sampler;
1249
- for (let y = 0, i = 0; y < h; y++) {
1250
- const yy = y * scaleY;
1251
- for (let x = 0; x < w; x++, i++) {
1252
- dpix[i] = sampler(x * scaleX, yy);
1253
- }
1254
- }
1255
- return dest;
1256
- }
1257
- upsize() {
1258
- const { width, height, data } = this;
1259
- const dest = new IntBuffer(width * 2, height * 2, this.format);
1260
- const dpix = dest.data;
1261
- for (let y = 0, si = 0; y < height; y++) {
1262
- for (let x = 0, di = y * width * 4; x < width; x++, si++, di += 2) {
1263
- dpix[di] = data[si];
1264
- }
1265
- }
1266
- return dest;
1267
- }
1268
- _rotate(idxFn) {
1269
- const { data, format, width, height } = this;
1270
- const tmp = typedArray(format.type, width * height);
1271
- for (let y = 0; y < height; y++) {
1272
- for (let x = 0; x < width; x++) {
1273
- tmp[idxFn(x, y)] = data[y * width + x];
1274
- }
1275
- }
1276
- this.data = tmp;
1277
- }
1278
- };
1279
- IntBuffer = __decorateClass$1([
1280
- IGrid2DMixin
1281
- ], IntBuffer);
1282
- var __defProp = Object.defineProperty;
1283
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1284
- var __decorateClass = (decorators, target, key, kind) => {
1285
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
1286
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1287
- if (decorator = decorators[i])
1288
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1289
- if (kind && result) __defProp(target, key, result);
1290
- return result;
1291
- };
1292
- function floatBuffer(...args) {
1293
- return args[0] instanceof IntBuffer ? (
1294
- // @ts-ignore
1295
- floatBufferFromInt(...args)
1296
- ) : (
1297
- // @ts-ignore
1298
- new FloatBuffer(...args)
1299
- );
1300
- }
1301
- const floatBufferFromInt = (src, fmt) => {
1302
- const dest = new FloatBuffer(src.width, src.height, fmt);
1303
- const {
1304
- data: dbuf,
1305
- format: dfmt,
1306
- stride: [stride]
1307
- } = dest;
1308
- const { data: sbuf, format: sfmt } = src;
1309
- for (let i = sbuf.length; i-- > 0; ) {
1310
- dbuf.set(dfmt.fromABGR(sfmt.toABGR(sbuf[i])), i * stride);
1311
- }
1312
- return dest;
1313
- };
1314
- const floatBufferFromCanvas = (canvas, fmt = FLOAT_RGBA) => intBufferFromCanvas(canvas).as(fmt);
1315
- let FloatBuffer = class {
1316
- size;
1317
- stride;
1318
- format;
1319
- data;
1320
- __empty;
1321
- constructor(w, h, fmt = FLOAT_RGBA, data) {
1322
- this.size = [w, h];
1323
- this.format = fmt.__float ? fmt : defFloatFormat(fmt);
1324
- const stride = this.format.channels.length;
1325
- this.stride = [stride, w * stride];
1326
- this.data = data || new Float32Array(w * h * stride);
1327
- this.__empty = Object.freeze(new Array(stride).fill(0));
1328
- }
1329
- /** @deprecated use `.data` instead */
1330
- get pixels() {
1331
- return this.data;
1332
- }
1333
- get width() {
1334
- return this.size[0];
1335
- }
1336
- get height() {
1337
- return this.size[1];
1338
- }
1339
- // TODO support custom offsets (via ctor arg)
1340
- get offset() {
1341
- return 0;
1342
- }
1343
- get dim() {
1344
- return 2;
1345
- }
1346
- *[Symbol.iterator]() {
1347
- const {
1348
- data,
1349
- stride: [stride]
1350
- } = this;
1351
- for (let i = 0, n = data.length; i < n; i += stride) {
1352
- yield data.subarray(i, i + stride);
1353
- }
1354
- }
1355
- as(fmt) {
1356
- const {
1357
- width,
1358
- height,
1359
- stride: [stride],
1360
- data,
1361
- format: { size, normalized: getNormalized, toABGR }
1362
- } = this;
1363
- let i = 0, j = 0, n = data.length;
1364
- if (fmt.__float) {
1365
- const $fmt = fmt;
1366
- const dest = new FloatBuffer(width, height, $fmt);
1367
- const {
1368
- data: dpixels,
1369
- stride: [dstride]
1370
- } = dest;
1371
- if (size === 1 && $fmt.channels.length === 1) {
1372
- const setNormalized = $fmt.fromNormalized;
1373
- for (; i < n; i += stride, j += dstride) {
1374
- dpixels[j] = setNormalized(getNormalized(data[i]));
1375
- }
1376
- } else {
1377
- for (; i < n; i += stride, j += dstride) {
1378
- dpixels.set(
1379
- $fmt.fromABGR(toABGR(data.subarray(i, i + stride))),
1380
- j
1381
- );
1382
- }
1383
- }
1384
- return dest;
1385
- } else {
1386
- const $fmt = fmt;
1387
- const dest = new IntBuffer(width, height, $fmt);
1388
- const dpixels = dest.data;
1389
- if (size === 1 && $fmt.channels.length === 1) {
1390
- const setFloat = $fmt.channels[0].setFloat;
1391
- for (; i < n; i += stride, j++) {
1392
- dpixels[j] = setFloat(0, getNormalized(data[i]));
1393
- }
1394
- } else {
1395
- for (; i < n; i += stride, j++) {
1396
- dpixels[j] = $fmt.fromABGR(
1397
- toABGR(data.subarray(i, i + stride))
1398
- );
1399
- }
1400
- }
1401
- return dest;
1402
- }
1403
- }
1404
- copy() {
1405
- const dest = this.empty();
1406
- dest.data.set(this.data);
1407
- return dest;
1408
- }
1409
- empty() {
1410
- return new FloatBuffer(this.width, this.height, this.format);
1411
- }
1412
- // @ts-ignore mixin
1413
- order() {
1414
- }
1415
- // @ts-ignore mixin
1416
- includes(x, y) {
1417
- }
1418
- // @ts-ignore mixin
1419
- indexAt(x, y) {
1420
- }
1421
- // @ts-ignore mixin
1422
- indexAtUnsafe(x, y) {
1423
- }
1424
- getAt(x, y) {
1425
- return this.includes(x, y) ? this.getAtUnsafe(x, y) : this.__empty;
1426
- }
1427
- getAtUnsafe(x, y) {
1428
- const idx = this.indexAtUnsafe(x, y);
1429
- return this.data.subarray(idx, idx + this.stride[0]);
1430
- }
1431
- setAt(x, y, col) {
1432
- return this.includes(x, y) ? (this.data.set(col, this.indexAtUnsafe(x, y)), true) : false;
1433
- }
1434
- setAtUnsafe(x, y, col) {
1435
- this.data.set(col, this.indexAtUnsafe(x, y));
1436
- return true;
1437
- }
1438
- getChannelAt(x, y, id) {
1439
- ensureChannel(this.format, id);
1440
- return this.includes(x, y) ? this.data[this.indexAtUnsafe(x, y) + id] : void 0;
1441
- }
1442
- setChannelAt(x, y, id, col) {
1443
- ensureChannel(this.format, id);
1444
- this.includes(x, y) && (this.data[this.indexAtUnsafe(x, y) + id] = col);
1445
- return this;
1446
- }
1447
- getChannel(id) {
1448
- ensureChannel(this.format, id);
1449
- const {
1450
- data,
1451
- stride: [stride]
1452
- } = this;
1453
- const [min2, max2] = this.format.range;
1454
- const dest = new Float32Array(this.width * this.height);
1455
- for (let i = id, j = 0, n = data.length; i < n; i += stride, j++) {
1456
- dest[j] = clamp$1(data[i], min2, max2);
1457
- }
1458
- return new FloatBuffer(this.width, this.height, FLOAT_GRAY, dest);
1459
- }
1460
- setChannel(id, src) {
1461
- ensureChannel(this.format, id);
1462
- const {
1463
- data: dest,
1464
- stride: [stride]
1465
- } = this;
1466
- if (isNumber(src)) {
1467
- for (let i = id, n = dest.length; i < n; i += stride) {
1468
- dest[i] = src;
1469
- }
1470
- } else {
1471
- const {
1472
- data: sbuf,
1473
- stride: [sstride]
1474
- } = src;
1475
- ensureSize(sbuf, this.width, this.height, sstride);
1476
- for (let i = id, j = 0, n = dest.length; i < n; i += stride, j += sstride) {
1477
- dest[i] = sbuf[j];
1478
- }
1479
- }
1480
- return this;
1481
- }
1482
- blend(op, dest, opts) {
1483
- this.ensureFormat(dest);
1484
- const { sx, sy, dx, dy, rw, rh } = __prepRegions(this, dest, opts);
1485
- if (rw < 1 || rh < 1) return dest;
1486
- const sbuf = this.data;
1487
- const dbuf = dest.data;
1488
- const [stride, sw] = this.stride;
1489
- const dw = dest.stride[1];
1490
- for (let si = (sx | 0) * stride + (sy | 0) * sw, di = (dx | 0) * stride + (dy | 0) * dw, yy = 0; yy < rh; yy++, si += sw, di += dw) {
1491
- for (let xx = rw, sii = si, dii = di; xx-- > 0; sii += stride, dii += stride) {
1492
- const out = dbuf.subarray(dii, dii + stride);
1493
- op(out, sbuf.subarray(sii, sii + stride), out);
1494
- }
1495
- }
1496
- return dest;
1497
- }
1498
- blit(dest, opts) {
1499
- this.ensureFormat(dest);
1500
- const { sx, sy, dx, dy, rw, rh } = __prepRegions(this, dest, opts);
1501
- if (rw < 1 || rh < 1) return dest;
1502
- const sbuf = this.data;
1503
- const dbuf = dest.data;
1504
- const [stride, sw] = this.stride;
1505
- const dw = dest.stride[1];
1506
- const rww = rw * stride;
1507
- for (let si = (sx | 0) * stride + (sy | 0) * sw, di = (dx | 0) * stride + (dy | 0) * dw, yy = 0; yy < rh; yy++, si += sw, di += dw) {
1508
- dbuf.set(sbuf.subarray(si, si + rww), di);
1509
- }
1510
- return dest;
1511
- }
1512
- blitCanvas(canvas, opts = {}) {
1513
- __blitCanvas(this, canvas, opts);
1514
- }
1515
- setImageData(idata) {
1516
- ensureImageDataSize(idata, this.width, this.height);
1517
- const src = new Uint32Array(idata.data.buffer);
1518
- const {
1519
- data: dest,
1520
- format: { fromABGR },
1521
- stride: [stride]
1522
- } = this;
1523
- const tmp = [];
1524
- for (let i = src.length; i-- > 0; ) {
1525
- dest.set(fromABGR(src[i], tmp), i * stride);
1526
- }
1527
- return this;
1528
- }
1529
- toImageData(idata) {
1530
- idata = ensureImageData(idata, this.width, this.height);
1531
- const dest = new Uint32Array(idata.data.buffer);
1532
- const {
1533
- stride: [stride],
1534
- data,
1535
- format
1536
- } = this;
1537
- for (let i = 0, j = 0, n = data.length; i < n; i += stride, j++) {
1538
- dest[j] = format.toABGR(data.subarray(i, i + stride));
1539
- }
1540
- return idata;
1541
- }
1542
- getRegion(x, y, width, height) {
1543
- const [sx, sy, w, h] = __clampRegion(
1544
- x,
1545
- y,
1546
- width,
1547
- height,
1548
- this.width,
1549
- this.height
1550
- );
1551
- if (w < 1 || h < 1) return;
1552
- return this.blit(new FloatBuffer(w, h, this.format), {
1553
- sx,
1554
- sy,
1555
- w,
1556
- h
1557
- });
1558
- }
1559
- forEach(f) {
1560
- const {
1561
- data,
1562
- stride: [stride]
1563
- } = this;
1564
- for (let i = 0, j = 0, n = data.length; i < n; i += stride, j++) {
1565
- data.set(f(data.subarray(i, i + stride), j), i);
1566
- }
1567
- return this;
1568
- }
1569
- fill(x) {
1570
- assert(
1571
- x.length <= this.format.channels.length,
1572
- `fill value has too many channels`
1573
- );
1574
- const {
1575
- data,
1576
- stride: [stride]
1577
- } = this;
1578
- for (let i = 0, n = data.length; i < n; i += stride) {
1579
- data.set(x, i);
1580
- }
1581
- }
1582
- premultiply() {
1583
- this.ensureRGBA();
1584
- const {
1585
- data,
1586
- stride: [stride]
1587
- } = this;
1588
- for (let i = 0, n = data.length; i < n; i += stride) {
1589
- premultiply(null, data.subarray(i, i + stride));
1590
- }
1591
- return this;
1592
- }
1593
- postmultiply() {
1594
- this.ensureRGBA();
1595
- const {
1596
- data,
1597
- stride: [stride]
1598
- } = this;
1599
- for (let i = 0, n = data.length; i < n; i += stride) {
1600
- postmultiply(null, data.subarray(i, i + stride));
1601
- }
1602
- return this;
1603
- }
1604
- isPremultiplied() {
1605
- this.ensureRGBA();
1606
- const {
1607
- data,
1608
- stride: [stride]
1609
- } = this;
1610
- for (let i = 0, n = data.length; i < n; i += stride) {
1611
- if (!isPremultiplied(data.subarray(i, i + stride))) {
1612
- return false;
1613
- }
1614
- }
1615
- return true;
1616
- }
1617
- clamp() {
1618
- const data = this.data;
1619
- const [min2, max2] = this.format.range;
1620
- for (let i = data.length; i-- > 0; ) {
1621
- data[i] = clamp$1(data[i], min2, max2);
1622
- }
1623
- return this;
1624
- }
1625
- clampChannel(id) {
1626
- ensureChannel(this.format, id);
1627
- const {
1628
- data,
1629
- stride: [stride]
1630
- } = this;
1631
- const [min2, max2] = this.format.range;
1632
- for (let i = id, n = data.length; i < n; i += stride) {
1633
- data[i] = clamp$1(data[i], min2, max2);
1634
- }
1635
- }
1636
- flipX() {
1637
- const {
1638
- data,
1639
- width,
1640
- height,
1641
- stride: [sx, sy]
1642
- } = this;
1643
- const tmp = new Float32Array(sx);
1644
- const w1 = width - 1;
1645
- const w2 = width >>> 1;
1646
- for (let y = 0; y < height; y++) {
1647
- for (let x = 0, i = y * sy, j = i + w1 * sx; x < w2; x++, i += sx, j -= sx) {
1648
- tmp.set(data.subarray(i, i + sx));
1649
- data.copyWithin(i, j, j + sx);
1650
- data.set(tmp, j);
1651
- }
1652
- }
1653
- return this;
1654
- }
1655
- /**
1656
- * Flips image vertically.
1657
- */
1658
- flipY() {
1659
- const data = this.data;
1660
- const rowStride = this.stride[1];
1661
- const tmp = new Float32Array(rowStride);
1662
- for (let i = 0, j = data.length - rowStride; i < j; i += rowStride, j -= rowStride) {
1663
- tmp.set(data.subarray(i, i + rowStride));
1664
- data.copyWithin(i, j, j + rowStride);
1665
- data.set(tmp, j);
1666
- }
1667
- return this;
1668
- }
1669
- rotateByID(id) {
1670
- return id > 0 ? this[ROT_IDS[id - 1]]() : this;
1671
- }
1672
- rotateCW() {
1673
- const { width, height } = this;
1674
- const h1 = height - 1;
1675
- this._rotate((x, y) => x * height + h1 - y);
1676
- this.size[0] = height;
1677
- this.size[1] = width;
1678
- return this;
1679
- }
1680
- rotateCCW() {
1681
- const { width, height } = this;
1682
- const w1 = width - 1;
1683
- this._rotate((x, y) => (w1 - x) * height + y);
1684
- this.size[0] = height;
1685
- this.size[1] = width;
1686
- return this;
1687
- }
1688
- rotate180() {
1689
- const { width, height } = this;
1690
- const w1 = width - 1;
1691
- const h1 = height - 1;
1692
- this._rotate((x, y) => (h1 - y) * width + w1 - x);
1693
- return this;
1694
- }
1695
- invert() {
1696
- const {
1697
- data,
1698
- format,
1699
- stride: [stride]
1700
- } = this;
1701
- for (let i = 0, n = data.length, m = format.alpha ? stride - 1 : stride; i < n; i += stride) {
1702
- for (let j = 0; j < m; j++) data[i + j] = 1 - data[i + j];
1703
- }
1704
- return this;
1705
- }
1706
- scale(scale, sampler) {
1707
- assert(scale > 0, `scale must be > 0`);
1708
- return this.resize(this.width * scale, this.height * scale, sampler);
1709
- }
1710
- resize(w, h, sampler = "linear") {
1711
- w |= 0;
1712
- h |= 0;
1713
- assert(w > 0 && h > 0, `target width & height must be > 0`);
1714
- const dest = floatBuffer(w, h, this.format);
1715
- const dpix = dest.data;
1716
- const scaleX = w > 0 ? this.width / w : 0;
1717
- const scaleY = h > 0 ? this.height / h : 0;
1718
- const stride = this.stride[0];
1719
- sampler = isString(sampler) ? defSampler(this, sampler, "repeat") : sampler;
1720
- for (let y = 0, i = 0; y < h; y++) {
1721
- const yy = y * scaleY;
1722
- for (let x = 0; x < w; x++, i += stride) {
1723
- dpix.set(sampler(x * scaleX, yy), i);
1724
- }
1725
- }
1726
- return dest;
1727
- }
1728
- upsize() {
1729
- const {
1730
- width,
1731
- height,
1732
- data,
1733
- stride: [stride, rowStride]
1734
- } = this;
1735
- const stride2x = stride * 2;
1736
- const dest = floatBuffer(width * 2, height * 2, this.format);
1737
- const dpix = dest.data;
1738
- for (let y = 0, si = 0; y < height; y++) {
1739
- for (let x = 0, di = y * rowStride * 4; x < width; x++, si += stride, di += stride2x) {
1740
- dpix.set(data.subarray(si, si + stride), di);
1741
- }
1742
- }
1743
- return dest;
1744
- }
1745
- _rotate(idxFn) {
1746
- const {
1747
- data,
1748
- width,
1749
- height,
1750
- stride: [stride]
1751
- } = this;
1752
- const tmp = new Float32Array(width * height * stride);
1753
- for (let y = 0, i = 0; y < height; y++) {
1754
- for (let x = 0; x < width; x++, i += stride) {
1755
- tmp.set(data.subarray(i, i + stride), idxFn(x, y) * stride);
1756
- }
1757
- }
1758
- this.data = tmp;
1759
- }
1760
- ensureFormat(dest) {
1761
- assert(
1762
- dest.format === this.format,
1763
- `dest buffer format must be same as src`
1764
- );
1765
- }
1766
- ensureRGBA() {
1767
- assert(this.format === FLOAT_RGBA, "require FLOAT_RGBA format");
1768
- }
1769
- };
1770
- __decorateClass([
1771
- nomixin
1772
- ], FloatBuffer.prototype, "getAt", 1);
1773
- __decorateClass([
1774
- nomixin
1775
- ], FloatBuffer.prototype, "getAtUnsafe", 1);
1776
- __decorateClass([
1777
- nomixin
1778
- ], FloatBuffer.prototype, "setAt", 1);
1779
- __decorateClass([
1780
- nomixin
1781
- ], FloatBuffer.prototype, "setAtUnsafe", 1);
1782
- FloatBuffer = __decorateClass([
1783
- IGrid2DMixin
1784
- ], FloatBuffer);
1785
- const norm = (x, a2, b2) => (x - a2) / (b2 - a2);
1786
- const fit = (x, a2, b2, c2, d2) => c2 + (d2 - c2) * norm(x, a2, b2);
1787
- const abs$1 = Math.abs;
1788
- const min = Math.min;
1789
- const FLOAT_HSVA = defFloatFormat({
1790
- alpha: true,
1791
- channels: [Lane.RED, Lane.GREEN, Lane.BLUE, Lane.ALPHA],
1792
- convert: {
1793
- fromABGR: (x, out = []) => {
1794
- const a2 = (x >>> 24 & 255) / 255;
1795
- const b2 = (x >>> 16 & 255) / 255;
1796
- const g = (x >>> 8 & 255) / 255;
1797
- const r = (x & 255) / 255;
1798
- let p0, p1, p2, p3;
1799
- let q0, q1, q2, q3;
1800
- if (g < b2) {
1801
- p0 = b2;
1802
- p1 = g;
1803
- p2 = -1;
1804
- p3 = 2 / 3;
1805
- } else {
1806
- p0 = g;
1807
- p1 = b2;
1808
- p2 = 0;
1809
- p3 = -1 / 3;
1810
- }
1811
- if (r < p0) {
1812
- q0 = p0;
1813
- q1 = p1;
1814
- q2 = p3;
1815
- q3 = r;
1816
- } else {
1817
- q0 = r;
1818
- q1 = p1;
1819
- q2 = p2;
1820
- q3 = p0;
1821
- }
1822
- const c2 = q0 - min(q1, q3);
1823
- q0 = clamp01(q0);
1824
- out[0] = clamp01(abs$1((q3 - q1) / (6 * c2 + EPS) + q2));
1825
- out[1] = clamp01(c2 / (q0 + EPS));
1826
- out[2] = q0;
1827
- out[3] = a2;
1828
- return out;
1829
- },
1830
- toABGR: (x) => {
1831
- const h = x[0] * 6;
1832
- const s = x[1];
1833
- const v = x[2] * 255;
1834
- const a2 = x[3] * 255;
1835
- const r = ((clamp01(abs$1(h - 3) - 1) - 1) * s + 1) * v;
1836
- const g = ((clamp01(2 - abs$1(h - 2)) - 1) * s + 1) * v;
1837
- const b2 = ((clamp01(2 - abs$1(h - 4)) - 1) * s + 1) * v;
1838
- return (a2 << 24 | b2 << 16 | g << 8 | r) >>> 0;
1839
- }
1840
- }
1841
- });
1842
- const FLOAT_RGBA = defFloatFormat({
1843
- alpha: true,
1844
- channels: [Lane.RED, Lane.GREEN, Lane.BLUE, Lane.ALPHA]
1845
- });
1846
- const UnsupportedOperationError = defError(
1847
- () => "unsupported operation"
1848
- );
1849
- const unsupportedOp = (msg) => {
1850
- throw new UnsupportedOperationError(msg);
1851
- };
1852
- const vop = (dispatch = 1, fallback, ...optimized) => {
1853
- const impls = [, ,].concat(optimized);
1854
- const fn = (...args) => {
1855
- const g = impls[args[dispatch].length] || fallback;
1856
- return g ? g(...args) : unsupportedOp(`no impl for vec size ${args[dispatch].length}`);
1857
- };
1858
- fn.add = (dim, fn2) => impls[dim] = fn2;
1859
- fn.default = (fn2) => fallback = fn2;
1860
- fn.impl = (dim) => dim != null ? impls[dim] || fallback : fallback;
1861
- return fn;
1862
- };
1863
- const dot2 = (a2, b2) => a2[0] * b2[0] + a2[1] * b2[1];
1864
- const dot3 = (a2, b2) => a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2];
1865
- const dot4 = (a2, b2) => a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2] + a2[3] * b2[3];
1866
- const dot = vop(
1867
- 0,
1868
- (a2, b2) => {
1869
- let sum5 = 0;
1870
- for (let i = a2.length; i-- > 0; ) sum5 += a2[i] * b2[i];
1871
- return sum5;
1872
- },
1873
- dot2,
1874
- dot3,
1875
- dot4
1876
- );
1877
- function memoizeJ(fn, cache = /* @__PURE__ */ Object.create(null)) {
1878
- return (...args) => {
1879
- const key = JSON.stringify(args);
1880
- if (key !== void 0) {
1881
- return key in cache ? cache[key] : cache[key] = fn.apply(null, args);
1882
- }
1883
- return fn.apply(null, args);
1884
- };
1885
- }
1886
- function memoizeO(fn, cache = /* @__PURE__ */ Object.create(null)) {
1887
- return (...xs) => {
1888
- const key = xs.join("-");
1889
- return key in cache ? cache[key] : cache[key] = fn(...xs);
1890
- };
1891
- }
1892
- const repeat$1 = memoizeO((ch, n) => ch.repeat(n));
1893
- const float = memoizeJ(
1894
- (prec, special = false) => special ? (x) => __nanOrInf(x) || x.toFixed(prec) : (x) => x.toFixed(prec)
1895
- );
1896
- const __nanOrInf = (x) => isNaN(x) ? "NaN" : x === Infinity ? "+∞" : x === -Infinity ? "-∞" : void 0;
1897
- const percent = (prec = 0) => (x) => (x * 100).toFixed(prec) + "%";
1898
- const RGB_LUMINANCE_REC601 = [0.299, 0.587, 0.114];
1899
- const RGB_LUMINANCE_REC709 = [0.2126, 0.7152, 0.0722];
1900
- const XYZ_RGB_D50 = [
1901
- 3.1338561,
1902
- -0.9787684,
1903
- 0.0719453,
1904
- -1.6168667,
1905
- 1.9161415,
1906
- -0.2289914,
1907
- -0.4906146,
1908
- 0.033454,
1909
- 1.4052427
1910
- ];
1911
- const XYZ_RGB_D65 = [
1912
- 3.2404542,
1913
- -0.969266,
1914
- 0.0556434,
1915
- -1.5371385,
1916
- 1.8760108,
1917
- -0.2040259,
1918
- -0.4985314,
1919
- 0.041556,
1920
- 1.0572252
1921
- ];
1922
- const D50 = [0.96422, 1, 0.82521];
1923
- const D65 = [0.95047, 1, 1.08883];
1924
- const OKLAB_M2 = [
1925
- 0.2104542553,
1926
- 1.9779984951,
1927
- 0.0259040371,
1928
- 0.793617785,
1929
- -2.428592205,
1930
- 0.7827717662,
1931
- -0.0040720468,
1932
- 0.4505937099,
1933
- -0.808675766
1934
- ];
1935
- let FF = float(3);
1936
- let PC = percent(3);
1937
- const INV8BIT = 1 / 255;
1938
- const luminanceRgb = (rgb2, weights = RGB_LUMINANCE_REC709) => dot3(rgb2, weights);
1939
- const luminanceSrgb = (rgb2) => dot3(rgb2, RGB_LUMINANCE_REC601);
1940
- const set2 = (o, a2) => {
1941
- !o && (o = []);
1942
- o[0] = a2[0];
1943
- o[1] = a2[1];
1944
- return o;
1945
- };
1946
- const set3 = (o, a2) => {
1947
- !o && (o = []);
1948
- o[0] = a2[0];
1949
- o[1] = a2[1];
1950
- o[2] = a2[2];
1951
- return o;
1952
- };
1953
- const set4 = (o, a2) => {
1954
- !o && (o = []);
1955
- o[0] = a2[0];
1956
- o[1] = a2[1];
1957
- o[2] = a2[2];
1958
- o[3] = a2[3];
1959
- return o;
1960
- };
1961
- const set = vop(
1962
- 1,
1963
- (o, a2) => {
1964
- !o && (o = []);
1965
- for (let i = a2.length; i-- > 0; ) o[i] = a2[i];
1966
- return o;
1967
- },
1968
- set2,
1969
- set3,
1970
- set4
1971
- );
1972
- const implementsFunction = (x, fn) => typeof x?.[fn] === "function";
1973
- const isArrayLike = (x) => x != null && typeof x !== "function" && x.length !== void 0;
1974
- const IllegalArgumentError = defError(() => "illegal argument(s)");
1975
- const illegalArgs = (msg) => {
1976
- throw new IllegalArgumentError(msg);
1977
- };
1978
- const vector = memoizeJ(
1979
- (size, prec = 3, d2 = ",", pre = "[", post = "]") => {
1980
- const f = typeof prec === "number" ? float(prec) : prec;
1981
- switch (size) {
1982
- case 1:
1983
- return (v) => `${pre}${f(v[0])}${post}`;
1984
- case 2:
1985
- return (v) => `${pre}${f(v[0])}${d2}${f(v[1])}${post}`;
1986
- case 3:
1987
- return (v) => `${pre}${f(v[0])}${d2}${f(v[1])}${d2}${f(v[2])}${post}`;
1988
- case 4:
1989
- return (v) => `${pre}${f(v[0])}${d2}${f(v[1])}${d2}${f(v[2])}${d2}${f(
1990
- v[3]
1991
- )}${post}`;
1992
- default:
1993
- return (v) => {
1994
- const res = [];
1995
- for (let i = 0; i < v.length; i++) {
1996
- res.push(f(v[i]));
1997
- }
1998
- return `${pre}${res.join(d2)}${post}`;
1999
- };
2000
- }
2001
- }
2002
- );
2003
- const mapStridedBuffer = (ctor, buf, num, start, cstride, estride) => {
2004
- const res = [];
2005
- while (num-- > 0) {
2006
- res.push(new ctor(buf, start, cstride));
2007
- start += estride;
2008
- }
2009
- return res;
2010
- };
2011
- const defOpVVV = (op, dispatch = 1, outA = true) => {
2012
- const a2 = outA ? (o, a22, b22, c22) => {
2013
- !o && (o = a22);
2014
- for (let i = a22.length; i-- > 0; ) o[i] = op(a22[i], b22[i], c22[i]);
2015
- return o;
2016
- } : (o, a22, b22, c22) => {
2017
- !o && (o = c22);
2018
- for (let i = a22.length; i-- > 0; ) o[i] = op(a22[i], b22[i], c22[i]);
2019
- return o;
2020
- };
2021
- const b2 = outA ? (o, a22, b22, c22) => {
2022
- !o && (o = a22);
2023
- o[0] = op(a22[0], b22[0], c22[0]);
2024
- o[1] = op(a22[1], b22[1], c22[1]);
2025
- return o;
2026
- } : (o, a22, b22, c22) => {
2027
- !o && (o = c22);
2028
- o[0] = op(a22[0], b22[0], c22[0]);
2029
- o[1] = op(a22[1], b22[1], c22[1]);
2030
- return o;
2031
- };
2032
- const c2 = outA ? (o, a22, b22, c22) => {
2033
- !o && (o = a22);
2034
- o[0] = op(a22[0], b22[0], c22[0]);
2035
- o[1] = op(a22[1], b22[1], c22[1]);
2036
- o[2] = op(a22[2], b22[2], c22[2]);
2037
- return o;
2038
- } : (o, a22, b22, c22) => {
2039
- !o && (o = c22);
2040
- o[0] = op(a22[0], b22[0], c22[0]);
2041
- o[1] = op(a22[1], b22[1], c22[1]);
2042
- o[2] = op(a22[2], b22[2], c22[2]);
2043
- return o;
2044
- };
2045
- const d2 = outA ? (o, a22, b22, c22) => {
2046
- !o && (o = a22);
2047
- o[0] = op(a22[0], b22[0], c22[0]);
2048
- o[1] = op(a22[1], b22[1], c22[1]);
2049
- o[2] = op(a22[2], b22[2], c22[2]);
2050
- o[3] = op(a22[3], b22[3], c22[3]);
2051
- return o;
2052
- } : (o, a22, b22, c22) => {
2053
- !o && (o = c22);
2054
- o[0] = op(a22[0], b22[0], c22[0]);
2055
- o[1] = op(a22[1], b22[1], c22[1]);
2056
- o[2] = op(a22[2], b22[2], c22[2]);
2057
- o[3] = op(a22[3], b22[3], c22[3]);
2058
- return o;
2059
- };
2060
- return [
2061
- vop(dispatch, a2, b2, c2, d2),
2062
- b2,
2063
- c2,
2064
- d2
2065
- ];
2066
- };
2067
- const [a$5, b$2, c$1, d] = defOpVVV(clamp$1);
2068
- const clamp4 = d;
2069
- const declareIndex = (proto, id, idx, strided = true, defNumeric = true) => {
2070
- const get = idx > 0 ? strided ? function() {
2071
- return this.buf[this.offset + idx * this.stride];
2072
- } : function() {
2073
- return this.buf[this.offset + idx];
2074
- } : function() {
2075
- return this.buf[this.offset];
2076
- };
2077
- const set5 = idx > 0 ? strided ? function(n) {
2078
- this.buf[this.offset + idx * this.stride] = n;
2079
- } : function(n) {
2080
- this.buf[this.offset + idx] = n;
2081
- } : function(n) {
2082
- this.buf[this.offset] = n;
2083
- };
2084
- defNumeric && Object.defineProperty(proto, idx, {
2085
- get,
2086
- set: set5,
2087
- enumerable: true
2088
- });
2089
- Object.defineProperty(proto, id, {
2090
- get,
2091
- set: set5,
2092
- enumerable: true
2093
- });
2094
- };
2095
- const declareIndices = (proto, props, strided, defNumeric) => props.forEach((id, i) => declareIndex(proto, id, i, strided, defNumeric));
2096
- const abs = Math.abs;
2097
- const eqDelta = (a2, b2, eps = EPS) => abs(a2 - b2) <= eps;
2098
- const eqDelta2 = (a2, b2, eps = EPS) => {
2099
- return a2.length === b2.length && eqDelta(a2[0], b2[0], eps) && eqDelta(a2[1], b2[1], eps);
2100
- };
2101
- const eqDelta3 = (a2, b2, eps = EPS) => {
2102
- return a2.length === b2.length && eqDelta(a2[0], b2[0], eps) && eqDelta(a2[1], b2[1], eps) && eqDelta(a2[2], b2[2], eps);
2103
- };
2104
- const eqDelta4 = (a2, b2, eps = EPS) => {
2105
- return a2.length === b2.length && eqDelta(a2[0], b2[0], eps) && eqDelta(a2[1], b2[1], eps) && eqDelta(a2[2], b2[2], eps) && eqDelta(a2[3], b2[3], eps);
2106
- };
2107
- vop(
2108
- 0,
2109
- (v1, v2, eps = EPS) => {
2110
- if (implementsFunction(v1, "eqDelta")) {
2111
- return v1.eqDelta(v2, eps);
2112
- }
2113
- if (implementsFunction(v2, "eqDelta")) {
2114
- return v2.eqDelta(v1, eps);
2115
- }
2116
- return eqDeltaS(v1, v2, v1.length, eps);
2117
- },
2118
- eqDelta2,
2119
- eqDelta3,
2120
- eqDelta4
2121
- );
2122
- const eqDeltaS = (a2, b2, n, eps = EPS, ia = 0, ib = 0, sa = 1, sb = 1) => {
2123
- for (; n > 0; n--, ia += sa, ib += sb) {
2124
- if (!eqDelta(a2[ia], b2[ib], eps)) {
2125
- return false;
2126
- }
2127
- }
2128
- return true;
2129
- };
2130
- function* stridedValues(buf, num, start, stride) {
2131
- while (num-- > 0) {
2132
- yield buf[start];
2133
- start += stride;
2134
- }
2135
- }
2136
- const INV_MAX = 1 / 2 ** 32;
2137
- class ARandom {
2138
- float(norm2 = 1) {
2139
- return this.int() * INV_MAX * norm2;
2140
- }
2141
- probability(p) {
2142
- return this.float() < p;
2143
- }
2144
- norm(norm2 = 1) {
2145
- return (this.int() * INV_MAX - 0.5) * 2 * norm2;
2146
- }
2147
- normMinMax(min2, max2) {
2148
- const x = this.minmax(min2, max2);
2149
- return this.float() < 0.5 ? x : -x;
2150
- }
2151
- minmax(min2, max2) {
2152
- return this.float() * (max2 - min2) + min2;
2153
- }
2154
- minmaxInt(min2, max2) {
2155
- min2 |= 0;
2156
- const range = (max2 | 0) - min2;
2157
- return range ? min2 + this.int() % range : min2;
2158
- }
2159
- minmaxUint(min2, max2) {
2160
- min2 >>>= 0;
2161
- const range = (max2 >>> 0) - min2;
2162
- return range ? min2 + this.int() % range : min2;
2163
- }
2164
- }
2165
- class WrappedRandom extends ARandom {
2166
- constructor(rnd) {
2167
- super();
2168
- this.rnd = rnd;
2169
- }
2170
- float(norm2 = 1) {
2171
- return this.rnd() * norm2;
2172
- }
2173
- norm(norm2 = 1) {
2174
- return (this.rnd() - 0.5) * 2 * norm2;
2175
- }
2176
- int() {
2177
- return this.rnd() * 4294967296 >>> 0;
2178
- }
2179
- }
2180
- const SYSTEM = new WrappedRandom(Math.random);
2181
- const weightedRandom = (choices, weights, rnd = SYSTEM) => {
2182
- const n = choices.length;
2183
- assert(n > 0, "no choices given");
2184
- const opts = weights ? choices.map((x, i) => [weights[i] || 0, x]).sort((a2, b2) => b2[0] - a2[0]) : choices.map((x) => [1, x]);
2185
- const total = opts.reduce((acc, o) => acc + o[0], 0);
2186
- total <= 0 && console.warn("total weights <= 0");
2187
- return () => {
2188
- const r = rnd.float(total);
2189
- let sum5 = total;
2190
- for (let i = 0; i < n; i++) {
2191
- sum5 -= opts[i][0];
2192
- if (sum5 <= r) {
2193
- return opts[i][1];
2194
- }
2195
- }
2196
- return void 0;
2197
- };
2198
- };
2199
- const randMinMax = vop(
2200
- 1,
2201
- (o, a2, b2, rnd = SYSTEM) => {
2202
- !o && (o = a2);
2203
- for (let i = a2.length; i-- > 0; ) o[i] = rnd.minmax(a2[i], b2[i]);
2204
- return o;
2205
- }
2206
- );
2207
- const isArray = Array.isArray;
2208
- const CONVERSIONS = {};
2209
- const defConversions = (mode, spec) => {
2210
- for (const id in spec) {
2211
- const val = spec[id];
2212
- if (isArray(val)) {
2213
- const [a2, b2, c2, d2] = val;
2214
- spec[id] = val.length === 2 ? (out, src) => b2(out, a2(out, src)) : val.length === 3 ? (out, src) => c2(out, b2(out, a2(out, src))) : (out, src) => d2(out, c2(out, b2(out, a2(out, src))));
2215
- }
2216
- }
2217
- CONVERSIONS[mode] = { ...CONVERSIONS[mode], ...spec };
2218
- };
2219
- const convert = (res, src, destMode, srcMode) => {
2220
- const spec = CONVERSIONS[destMode];
2221
- assert(!!spec, `no conversions available for ${destMode}`);
2222
- let $convert = spec[srcMode];
2223
- return $convert ? $convert(res, src) : CONVERSIONS.rgb[srcMode] ? spec.rgb(res, CONVERSIONS.rgb[srcMode]([], src)) : unsupportedOp(`can't convert: ${srcMode} -> ${destMode}`);
2224
- };
2225
- const rotateRight = (x, n) => (x >>> n | x << 32 - n) >>> 0;
2226
- const interleave4_12_24 = (x) => (x & 3840) * 4352 | (x & 240) * 272 | (x & 15) * 17;
2227
- const interleave4_16_32 = (x) => ((x & 61440) * 69632 | (x & 3840) * 4352 | (x & 240) * 272 | (x & 15) * 17) >>> 0;
2228
- class ParsedColor {
2229
- constructor(mode, value) {
2230
- this.mode = mode;
2231
- this.value = value;
2232
- }
2233
- deref() {
2234
- return this.value;
2235
- }
2236
- }
2237
- const CSS_NAMES = {
2238
- aliceblue: "f0f8ff",
2239
- antiquewhite: "faebd7",
2240
- aqua: "0ff",
2241
- aquamarine: "7fffd4",
2242
- azure: "f0ffff",
2243
- beige: "f5f5dc",
2244
- bisque: "ffe4c4",
2245
- black: "000",
2246
- blanchedalmond: "ffebcd",
2247
- blue: "00f",
2248
- blueviolet: "8a2be2",
2249
- brown: "a52a2a",
2250
- burlywood: "deb887",
2251
- cadetblue: "5f9ea0",
2252
- chartreuse: "7fff00",
2253
- chocolate: "d2691e",
2254
- coral: "ff7f50",
2255
- cornflowerblue: "6495ed",
2256
- cornsilk: "fff8dc",
2257
- crimson: "dc143c",
2258
- cyan: "0ff",
2259
- darkblue: "00008b",
2260
- darkcyan: "008b8b",
2261
- darkgoldenrod: "b8860b",
2262
- darkgray: "a9a9a9",
2263
- darkgreen: "006400",
2264
- darkgrey: "a9a9a9",
2265
- darkkhaki: "bdb76b",
2266
- darkmagenta: "8b008b",
2267
- darkolivegreen: "556b2f",
2268
- darkorange: "ff8c00",
2269
- darkorchid: "9932cc",
2270
- darkred: "8b0000",
2271
- darksalmon: "e9967a",
2272
- darkseagreen: "8fbc8f",
2273
- darkslateblue: "483d8b",
2274
- darkslategray: "2f4f4f",
2275
- darkslategrey: "2f4f4f",
2276
- darkturquoise: "00ced1",
2277
- darkviolet: "9400d3",
2278
- deeppink: "ff1493",
2279
- deepskyblue: "00bfff",
2280
- dimgray: "696969",
2281
- dimgrey: "696969",
2282
- dodgerblue: "1e90ff",
2283
- firebrick: "b22222",
2284
- floralwhite: "fffaf0",
2285
- forestgreen: "228b22",
2286
- fuchsia: "f0f",
2287
- gainsboro: "dcdcdc",
2288
- ghostwhite: "f8f8ff",
2289
- gold: "ffd700",
2290
- goldenrod: "daa520",
2291
- gray: "808080",
2292
- grey: "808080",
2293
- green: "008000",
2294
- greenyellow: "adff2f",
2295
- honeydew: "f0fff0",
2296
- hotpink: "ff69b4",
2297
- indianred: "cd5c5c",
2298
- indigo: "4b0082",
2299
- ivory: "fffff0",
2300
- khaki: "f0e68c",
2301
- lavender: "e6e6fa",
2302
- lavenderblush: "fff0f5",
2303
- lawngreen: "7cfc00",
2304
- lemonchiffon: "fffacd",
2305
- lightblue: "add8e6",
2306
- lightcoral: "f08080",
2307
- lightcyan: "e0ffff",
2308
- lightgoldenrodyellow: "fafad2",
2309
- lightgray: "d3d3d3",
2310
- lightgreen: "90ee90",
2311
- lightgrey: "d3d3d3",
2312
- lightpink: "ffb6c1",
2313
- lightsalmon: "ffa07a",
2314
- lightseagreen: "20b2aa",
2315
- lightskyblue: "87cefa",
2316
- lightslategray: "789",
2317
- lightslategrey: "789",
2318
- lightsteelblue: "b0c4de",
2319
- lightyellow: "ffffe0",
2320
- lime: "0f0",
2321
- limegreen: "32cd32",
2322
- linen: "faf0e6",
2323
- magenta: "f0f",
2324
- maroon: "800000",
2325
- mediumaquamarine: "66cdaa",
2326
- mediumblue: "0000cd",
2327
- mediumorchid: "ba55d3",
2328
- mediumpurple: "9370db",
2329
- mediumseagreen: "3cb371",
2330
- mediumslateblue: "7b68ee",
2331
- mediumspringgreen: "00fa9a",
2332
- mediumturquoise: "48d1cc",
2333
- mediumvioletred: "c71585",
2334
- midnightblue: "191970",
2335
- mintcream: "f5fffa",
2336
- mistyrose: "ffe4e1",
2337
- moccasin: "ffe4b5",
2338
- navajowhite: "ffdead",
2339
- navy: "000080",
2340
- oldlace: "fdf5e6",
2341
- olive: "808000",
2342
- olivedrab: "6b8e23",
2343
- orange: "ffa500",
2344
- orangered: "ff4500",
2345
- orchid: "da70d6",
2346
- palegoldenrod: "eee8aa",
2347
- palegreen: "98fb98",
2348
- paleturquoise: "afeeee",
2349
- palevioletred: "db7093",
2350
- papayawhip: "ffefd5",
2351
- peachpuff: "ffdab9",
2352
- peru: "cd853f",
2353
- pink: "ffc0cb",
2354
- plum: "dda0dd",
2355
- powderblue: "b0e0e6",
2356
- purple: "800080",
2357
- red: "f00",
2358
- rosybrown: "bc8f8f",
2359
- royalblue: "4169e1",
2360
- saddlebrown: "8b4513",
2361
- salmon: "fa8072",
2362
- sandybrown: "f4a460",
2363
- seagreen: "2e8b57",
2364
- seashell: "fff5ee",
2365
- sienna: "a0522d",
2366
- silver: "c0c0c0",
2367
- skyblue: "87ceeb",
2368
- slateblue: "6a5acd",
2369
- slategray: "708090",
2370
- slategrey: "708090",
2371
- snow: "fffafa",
2372
- springgreen: "00ff7f",
2373
- steelblue: "4682b4",
2374
- tan: "d2b48c",
2375
- teal: "008080",
2376
- thistle: "d8bfd8",
2377
- tomato: "ff6347",
2378
- turquoise: "40e0d0",
2379
- violet: "ee82ee",
2380
- wheat: "f5deb3",
2381
- white: "fff",
2382
- whitesmoke: "f5f5f5",
2383
- yellow: "ff0",
2384
- yellowgreen: "9acd32",
2385
- // additions
2386
- transparent: "0000",
2387
- rebeccapurple: "639"
2388
- };
2389
- let CSS_SYSTEM_COLORS = {
2390
- canvas: "fff",
2391
- canvastext: "000",
2392
- linktext: "001ee4",
2393
- visitedtext: "4e2386",
2394
- activetext: "eb3323",
2395
- buttonface: "ddd",
2396
- buttontext: "000",
2397
- buttonborder: "000",
2398
- field: "fff",
2399
- fieldtext: "000",
2400
- highlight: "bbd5fb",
2401
- highlighttext: "000",
2402
- mark: "000",
2403
- marktext: "fff",
2404
- graytext: "808080"
2405
- };
2406
- const setC3 = (out, x, y, z) => {
2407
- !out && (out = []);
2408
- out[0] = x;
2409
- out[1] = y;
2410
- out[2] = z;
2411
- return out;
2412
- };
2413
- const setC4 = (out, x, y, z, w) => {
2414
- !out && (out = []);
2415
- out[0] = x;
2416
- out[1] = y;
2417
- out[2] = z;
2418
- out[3] = w;
2419
- return out;
2420
- };
2421
- const intArgb32Srgb = (out, src) => setC4(
2422
- out || [],
2423
- (src >>> 16 & 255) * INV8BIT,
2424
- (src >>> 8 & 255) * INV8BIT,
2425
- (src & 255) * INV8BIT,
2426
- (src >>> 24) * INV8BIT
2427
- );
2428
- const intAbgr32Srgb = (out, src) => setC4(
2429
- out || [],
2430
- (src & 255) * INV8BIT,
2431
- (src >>> 8 & 255) * INV8BIT,
2432
- (src >>> 16 & 255) * INV8BIT,
2433
- (src >>> 24) * INV8BIT
2434
- );
2435
- const parseCss = (src) => {
2436
- src = (isString(src) ? src : src.deref()).toLowerCase();
2437
- const named = CSS_NAMES[src] || CSS_SYSTEM_COLORS[src];
2438
- if (named || src[0] === "#")
2439
- return new ParsedColor(
2440
- "srgb",
2441
- intArgb32Srgb([], parseHex(named || src))
2442
- );
2443
- const parts = src.split(/[(),/ ]+/);
2444
- const [mode, a2, b2, c2, d2] = parts;
2445
- assert(parts.length === 5 || parts.length === 6, `invalid color: ${src}`);
2446
- switch (mode) {
2447
- case "rgb":
2448
- case "rgba":
2449
- return new ParsedColor("srgb", [
2450
- __numOrPercent(a2, 1, INV8BIT, true),
2451
- __numOrPercent(b2, 1, INV8BIT, true),
2452
- __numOrPercent(c2, 1, INV8BIT, true),
2453
- __alpha(d2)
2454
- ]);
2455
- case "hsl":
2456
- case "hsla":
2457
- return new ParsedColor("hsl", [
2458
- __hue(a2),
2459
- __percent(b2),
2460
- __percent(c2),
2461
- __alpha(d2)
2462
- ]);
2463
- case "lab":
2464
- return new ParsedColor("lab50", [
2465
- __numOrPercent(a2),
2466
- __numOrPercent(b2, 1.25),
2467
- __numOrPercent(c2, 1.25),
2468
- __alpha(d2)
2469
- ]);
2470
- case "lch":
2471
- return new ParsedColor(mode, [
2472
- __numOrPercent(a2),
2473
- __numOrPercent(b2, 1.5),
2474
- __hue(c2),
2475
- __alpha(d2)
2476
- ]);
2477
- case "oklab":
2478
- return new ParsedColor(mode, [
2479
- __numOrPercent(a2, 1, 1),
2480
- __numOrPercent(b2, 0.4, 1),
2481
- __numOrPercent(c2, 0.4, 1),
2482
- __alpha(d2)
2483
- ]);
2484
- case "oklch":
2485
- return new ParsedColor(mode, [
2486
- __numOrPercent(a2, 1, 1),
2487
- __numOrPercent(b2, 0.4, 1),
2488
- __hue(c2),
2489
- __alpha(d2)
2490
- ]);
2491
- default:
2492
- unsupportedOp(`color mode: ${mode}`);
2493
- }
2494
- };
2495
- const HUE_NORMS = {
2496
- rad: TAU,
2497
- grad: 400,
2498
- turn: 1,
2499
- deg: 360
2500
- };
2501
- const __hue = (x) => {
2502
- const match = /^(-?[0-9.]+)(deg|rad|grad|turn)?$/.exec(x);
2503
- assert(!!match, `expected hue, got: ${x}`);
2504
- return fract(parseFloat(match[1]) / (HUE_NORMS[match[2]] || 360));
2505
- };
2506
- const __alpha = (x) => x ? __numOrPercent(x, 1, 1, true) : 1;
2507
- const __percent = (x, clamp2 = true) => {
2508
- assert(/^([0-9.]+)%$/.test(x), `expected percentage, got: ${x}`);
2509
- const res = parseFloat(x) / 100;
2510
- return clamp2 ? clamp01(res) : res;
2511
- };
2512
- const __numOrPercent = (x, scalePerc = 1, scale = 0.01, clamp2 = false) => {
2513
- assert(/^-?[0-9.]+%?$/.test(x), `expected number or percentage, got: ${x}`);
2514
- const res = parseFloat(x) * (x.endsWith("%") ? 0.01 * scalePerc : scale);
2515
- return clamp2 ? clamp01(res) : res;
2516
- };
2517
- const parseHex = (src) => {
2518
- const match = /^#?([0-9a-f]{3,8})$/i.exec(src);
2519
- if (match) {
2520
- const hex = match[1];
2521
- const val = parseInt(hex, 16);
2522
- switch (hex.length) {
2523
- case 3:
2524
- return (interleave4_12_24(val) | 4278190080) >>> 0;
2525
- case 4:
2526
- return rotateRight(interleave4_16_32(val), 8);
2527
- case 6:
2528
- return (val | 4278190080) >>> 0;
2529
- case 8:
2530
- return rotateRight(val, 8);
2531
- }
2532
- }
2533
- return illegalArgs(`invalid hex color: "${src}"`);
2534
- };
2535
- const __ensureAlpha = (x, def = 1) => x != void 0 ? clamp01(x) : def;
2536
- const __ensureArgs = (args) => {
2537
- if (typeof args[0] === "number") {
2538
- switch (args.length) {
2539
- case 1:
2540
- return args.push(0, 0, 1), [args];
2541
- case 2:
2542
- return args.push(0, 1), [args];
2543
- case 3:
2544
- return args.push(1), [args];
2545
- default:
2546
- return [args];
2547
- }
2548
- }
2549
- return args;
2550
- };
2551
- const defColor = (spec) => {
2552
- const channels = spec.channels || {};
2553
- const order = spec.order;
2554
- const numChannels = order.length;
2555
- order.reduce((acc, id) => {
2556
- acc[id] = {
2557
- range: [0, 1],
2558
- ...channels[id]
2559
- };
2560
- return acc;
2561
- }, channels);
2562
- const min2 = Object.freeze(order.map((id) => channels[id].range[0]));
2563
- const max2 = Object.freeze(order.map((id) => channels[id].range[1]));
2564
- const minR = set4([], min2);
2565
- const maxR = set4([], max2);
2566
- minR[numChannels - 1] = 1;
2567
- const hueChanID = order.findIndex((id) => !!channels[id].hue);
2568
- const $Color = class {
2569
- constructor(buf, offset = 0, stride = 1) {
2570
- this.offset = offset;
2571
- this.stride = stride;
2572
- this.buf = buf || [0, 0, 0, 0];
2573
- this.offset = offset;
2574
- this.stride = stride;
2575
- }
2576
- buf;
2577
- get mode() {
2578
- return spec.mode;
2579
- }
2580
- get length() {
2581
- return numChannels;
2582
- }
2583
- get range() {
2584
- return [min2, max2];
2585
- }
2586
- get [Symbol.toStringTag]() {
2587
- return spec.mode;
2588
- }
2589
- get xyz() {
2590
- return [this[0], this[1], this[2]];
2591
- }
2592
- [Symbol.iterator]() {
2593
- return stridedValues(
2594
- this.buf,
2595
- this.length,
2596
- this.offset,
2597
- this.stride
2598
- );
2599
- }
2600
- copy() {
2601
- return new $Color(this.deref());
2602
- }
2603
- copyView() {
2604
- return new $Color(this.buf, this.offset, this.stride);
2605
- }
2606
- empty() {
2607
- return new $Color();
2608
- }
2609
- deref() {
2610
- return [this[0], this[1], this[2], this[3]];
2611
- }
2612
- set(src) {
2613
- return set4(this, src);
2614
- }
2615
- clamp() {
2616
- hueChanID >= 0 && (this[hueChanID] = fract(this[hueChanID]));
2617
- clamp4(null, this, min2, max2);
2618
- return this;
2619
- }
2620
- eqDelta(o, eps = EPS) {
2621
- return eqDelta4(this, o, eps);
2622
- }
2623
- randomize(rnd) {
2624
- return randMinMax(this, minR, maxR, rnd);
2625
- }
2626
- toJSON() {
2627
- return this.deref();
2628
- }
2629
- toString() {
2630
- return vector(4, 4)(this);
2631
- }
2632
- };
2633
- declareIndices($Color.prototype, order);
2634
- defConversions(spec.mode, spec.from);
2635
- defConversions("rgb", { [spec.mode]: spec.toRgb });
2636
- const fromColor = (src, mode, args) => {
2637
- const res = new $Color(...args);
2638
- return mode !== spec.mode ? convert(res, src, spec.mode, mode) : res.set(src);
2639
- };
2640
- const factory = (src, ...args) => src == null ? new $Color() : isString(src) ? factory(parseCss(src), ...args) : isArrayLike(src) ? isString(src.mode) ? fromColor(src, src.mode, args) : new $Color(src, ...args) : implementsFunction(src, "deref") ? fromColor(src.deref(), src.mode, args) : isNumber(src) ? args.length && args.every(isNumber) ? new $Color(...__ensureArgs([src, ...args])) : fromColor(intArgb32Srgb([], src), "srgb", args) : illegalArgs(`can't create a ${spec.mode} color from: ${src}`);
2641
- factory.class = $Color;
2642
- factory.range = [min2, max2];
2643
- factory.random = (rnd, buf, idx, stride) => new $Color(buf, idx, stride).randomize(rnd);
2644
- factory.mapBuffer = (buf, num = buf.length / numChannels | 0, start = 0, cstride = 1, estride = numChannels) => mapStridedBuffer($Color, buf, num, start, cstride, estride);
2645
- return factory;
2646
- };
2647
- const hueRgb = (out, hue, alpha = 1) => {
2648
- hue = fract(hue) * 6;
2649
- return setC4(
2650
- out || [],
2651
- clamp01(Math.abs(hue - 3) - 1),
2652
- clamp01(2 - Math.abs(hue - 2)),
2653
- clamp01(2 - Math.abs(hue - 4)),
2654
- alpha
2655
- );
2656
- };
2657
- const hcyRgb = (out, src) => {
2658
- const h = src[0];
2659
- let c2 = src[1];
2660
- const y = src[2];
2661
- const rgb2 = hueRgb(out || src, h, __ensureAlpha(src[3]));
2662
- const lum = luminanceRgb(rgb2);
2663
- if (y < lum) {
2664
- c2 *= y / lum;
2665
- } else if (lum < 1) {
2666
- c2 *= (1 - y) / (1 - lum);
2667
- }
2668
- return setC3(
2669
- rgb2,
2670
- clamp01((rgb2[0] - lum) * c2 + y),
2671
- clamp01((rgb2[1] - lum) * c2 + y),
2672
- clamp01((rgb2[2] - lum) * c2 + y)
2673
- );
2674
- };
2675
- const clamp = (out, src, alpha = 1) => setC4(
2676
- out || src,
2677
- clamp01(src[0]),
2678
- clamp01(src[1]),
2679
- clamp01(src[2]),
2680
- __ensureAlpha(src[3], alpha)
2681
- );
2682
- const clampH = (out, src, alpha = 1) => setC4(
2683
- out || src,
2684
- fract(src[0]),
2685
- clamp01(src[1]),
2686
- clamp01(src[2]),
2687
- __ensureAlpha(src[3], alpha)
2688
- );
2689
- const hsiRgb = (out, src) => {
2690
- out = clampH(out || src, src);
2691
- const s = out[1];
2692
- const i = out[2];
2693
- if (s < 1e-6) {
2694
- return setC3(out, i, i, i);
2695
- }
2696
- const h = out[0] * 6 % 6;
2697
- const m = i * (1 - s);
2698
- const z = 1 - Math.abs(h % 2 - 1);
2699
- let c2 = 3 * i * s / (1 + z);
2700
- const x = c2 * z + m;
2701
- c2 += m;
2702
- switch (h | 0) {
2703
- case 0:
2704
- return setC3(out, c2, x, m);
2705
- case 1:
2706
- return setC3(out, x, c2, m);
2707
- case 2:
2708
- return setC3(out, m, c2, x);
2709
- case 3:
2710
- return setC3(out, m, x, c2);
2711
- case 4:
2712
- return setC3(out, x, m, c2);
2713
- case 5:
2714
- return setC3(out, c2, m, x);
2715
- default:
2716
- return setC3(out, m, m, m);
2717
- }
2718
- };
2719
- const hslRgb = (out, src) => {
2720
- const s = clamp01(src[1]);
2721
- const l = clamp01(src[2]);
2722
- out = hueRgb(out || src, src[0], __ensureAlpha(src[3]));
2723
- const c2 = (1 - Math.abs(2 * l - 1)) * s;
2724
- return setC3(
2725
- out,
2726
- (out[0] - 0.5) * c2 + l,
2727
- (out[1] - 0.5) * c2 + l,
2728
- (out[2] - 0.5) * c2 + l
2729
- );
2730
- };
2731
- const hsvRgb = (out, src) => {
2732
- out = clampH(out || src, src);
2733
- const s = out[1];
2734
- const v = out[2];
2735
- hueRgb(out, src[0], out[3]);
2736
- return setC3(
2737
- out,
2738
- ((out[0] - 1) * s + 1) * v,
2739
- ((out[1] - 1) * s + 1) * v,
2740
- ((out[2] - 1) * s + 1) * v
2741
- );
2742
- };
2743
- const linearSrgb = (x) => x <= 31308e-7 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;
2744
- const srgbLinear = (x) => x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
2745
- const srgbRgb = (out, src) => setC4(
2746
- out || src,
2747
- srgbLinear(src[0]),
2748
- srgbLinear(src[1]),
2749
- srgbLinear(src[2]),
2750
- __ensureAlpha(src[3])
2751
- );
2752
- const intArgb32Rgb = (out, src) => srgbRgb(null, intArgb32Srgb(out, src));
2753
- const intAbgr32Rgb = (out, src) => srgbRgb(null, intAbgr32Srgb(out, src));
2754
- const cossin = (theta, n = 1) => [
2755
- Math.cos(theta) * n,
2756
- Math.sin(theta) * n
2757
- ];
2758
- const absTheta = (theta) => (theta %= TAU, theta < 0 ? TAU + theta : theta);
2759
- const atan2Abs = (y, x) => absTheta(Math.atan2(y, x));
2760
- const lchLab = (out, src) => {
2761
- let { 1: c2, 2: h } = src;
2762
- h *= TAU;
2763
- const a2 = __ensureAlpha(src[3]);
2764
- return c2 > 0 ? setC4(out || src, src[0], Math.cos(h) * c2, Math.sin(h) * c2, a2) : setC4(out || src, src[0], 0, 0, a2);
2765
- };
2766
- const __transform = (x) => {
2767
- const y = x ** 3;
2768
- return y > 8856e-6 ? y : (x - 16 / 116) / 7.787;
2769
- };
2770
- const labXyz = (out, src, white = D50) => {
2771
- const y = (src[0] + 0.16) / 1.16;
2772
- return setC4(
2773
- out || src,
2774
- __transform(src[1] / 5 + y) * white[0],
2775
- __transform(y) * white[1],
2776
- __transform(y - src[2] / 2) * white[2],
2777
- __ensureAlpha(src[3])
2778
- );
2779
- };
2780
- const labXyzD65 = (out, src) => labXyz(out, src, D65);
2781
- const dotS3 = (a2, b2, ia = 0, ib = 0, sa = 1, sb = 1) => a2[ia] * b2[ib] + a2[ia + sa] * b2[ib + sb] + a2[ia + 2 * sa] * b2[ib + 2 * sb];
2782
- const __mulV33 = (out, mat, src, clampOut = false) => {
2783
- const x = dotS3(mat, src, 0, 0, 3);
2784
- const y = dotS3(mat, src, 1, 0, 3);
2785
- const z = dotS3(mat, src, 2, 0, 3);
2786
- const a2 = __ensureAlpha(src[3]);
2787
- return clampOut ? setC4(out || src, clamp01(x), clamp01(y), clamp01(z), a2) : setC4(out || src, x, y, z, a2);
2788
- };
2789
- const xyzRgb = (out, src, mat = XYZ_RGB_D50) => __mulV33(out, mat, src);
2790
- const xyzRgbD65 = (out, src) => xyzRgb(out, src, XYZ_RGB_D65);
2791
- const labRgb = (out, src) => xyzRgb(null, labXyz(out, src));
2792
- const labRgbD65 = (out, src) => xyzRgbD65(null, labXyzD65(out, src));
2793
- const LMS_CONE = [
2794
- 4.0767416621,
2795
- -1.2684380046,
2796
- -0.0041960863,
2797
- -3.307711591,
2798
- 2.6097574011,
2799
- -0.7034186147,
2800
- 0.2309699292,
2801
- -0.3413193965,
2802
- 1.707614701
2803
- ];
2804
- const oklabRgb = (out, { 0: l, 1: a2, 2: b2, 3: alpha }) => __mulV33(out, LMS_CONE, [
2805
- (l + 0.3963377774 * a2 + 0.2158037573 * b2) ** 3,
2806
- (l - 0.1055613458 * a2 - 0.0638541728 * b2) ** 3,
2807
- (l - 0.0894841775 * a2 - 1.291485548 * b2) ** 3,
2808
- alpha
2809
- ]);
2810
- const safeDiv = (a2, b2) => b2 !== 0 ? a2 / b2 : 0;
2811
- const xyyXyz = (out, src) => {
2812
- const { 0: x, 1: y, 2: Y } = src;
2813
- return setC4(
2814
- out || src,
2815
- safeDiv(Y * x, y),
2816
- Y,
2817
- safeDiv(Y * (1 - x - y), y),
2818
- __ensureAlpha(src[3])
2819
- );
2820
- };
2821
- const yccRgb = (out, src, luma = RGB_LUMINANCE_REC709) => {
2822
- const y = src[0];
2823
- const bb = (2 - 2 * luma[2]) * src[1];
2824
- const rr = (2 - 2 * luma[0]) * src[2];
2825
- return setC4(
2826
- out || src,
2827
- y + rr,
2828
- y - luma[2] / luma[1] * bb - luma[0] / luma[1] * rr,
2829
- y + bb,
2830
- __ensureAlpha(src[3])
2831
- );
2832
- };
2833
- const rgb = defColor({
2834
- mode: "rgb",
2835
- order: ["r", "g", "b", "alpha"],
2836
- from: {
2837
- abgr32: (out, src) => intAbgr32Rgb(out, src[0]),
2838
- argb32: (out, src) => intArgb32Rgb(out, src[0]),
2839
- hcy: hcyRgb,
2840
- hsi: hsiRgb,
2841
- hsl: hslRgb,
2842
- hsv: hsvRgb,
2843
- lab50: labRgb,
2844
- lab65: labRgbD65,
2845
- lch: [lchLab, labRgb],
2846
- oklab: oklabRgb,
2847
- rgb: set4,
2848
- srgb: srgbRgb,
2849
- xyy: [xyyXyz, xyzRgbD65],
2850
- xyz50: xyzRgb,
2851
- xyz65: xyzRgbD65,
2852
- ycc: yccRgb
2853
- },
2854
- toRgb: set4
2855
- });
2856
- const contrast = (a2, b2) => {
2857
- const lumA = luminanceRgb(rgb(a2)) + 0.05;
2858
- const lumB = luminanceRgb(rgb(b2)) + 0.05;
2859
- return lumA > lumB ? lumA / lumB : lumB / lumA;
2860
- };
2861
- const ensureIterable = (x) => {
2862
- (x == null || !x[Symbol.iterator]) && illegalArgs(`value is not iterable: ${x}`);
2863
- return x;
2864
- };
2865
- const ensureArray = (x) => isArray(x) ? x : [...ensureIterable(x)];
2866
- const ensureArrayLike = (x) => isArrayLike(x) ? x : [...ensureIterable(x)];
2867
- const hslCss = (src) => {
2868
- const h = FF(fract(src[0]) * 360);
2869
- const s = PC(clamp01(src[1]));
2870
- const l = PC(clamp01(src[2]));
2871
- const a2 = __ensureAlpha(src[3]);
2872
- return a2 < 1 ? `hsla(${h},${s},${l},${FF(a2)})` : `hsl(${h},${s},${l})`;
2873
- };
2874
- const hsvHsl = (out, src) => {
2875
- out = clampH(out || src, src);
2876
- const s = out[1];
2877
- const v = out[2];
2878
- const l = (2 - s) * v / 2;
2879
- out[2] = l;
2880
- out[1] = l && l < 1 ? s * v / (l < 0.5 ? l * 2 : 2 - l * 2) : s;
2881
- return out;
2882
- };
2883
- const hsvCss = (src) => hslCss(hsvHsl([], src));
2884
- const HEX = "0123456789abcdef";
2885
- const U8 = (x) => HEX[x >>> 4 & 15] + HEX[x & 15];
2886
- const U16 = (x) => U8(x >>> 8) + U8(x & 255);
2887
- const U24$1 = (x) => U8(x >>> 16) + U16(x);
2888
- const radix = memoizeO(
2889
- (radix2, n, prefix = "") => {
2890
- const buf = repeat$1("0", n);
2891
- return (x) => {
2892
- x = (x >>> 0).toString(radix2);
2893
- return prefix + (x.length < n ? buf.substring(x.length) + x : x);
2894
- };
2895
- }
2896
- );
2897
- radix(2, 8);
2898
- radix(2, 16);
2899
- radix(2, 32);
2900
- const U24 = U24$1;
2901
- const intArgb32Css = (src) => {
2902
- const a2 = src >>> 24;
2903
- return a2 < 255 ? `rgba(${src >> 16 & 255},${src >> 8 & 255},${src & 255},${FF(
2904
- a2 * INV8BIT
2905
- )})` : `#${U24(src & 16777215)}`;
2906
- };
2907
- const swapLane13 = (x) => (x & 255) << 16 | x >> 16 & 255 | x & 4278255360;
2908
- const intAbgr32Argb32 = swapLane13;
2909
- const rgbSrgb = (out, src) => setC4(
2910
- out || src,
2911
- linearSrgb(src[0]),
2912
- linearSrgb(src[1]),
2913
- linearSrgb(src[2]),
2914
- __ensureAlpha(src[3])
2915
- );
2916
- const __scale8bit = (x, shift = 0) => (x < 0 ? 0 : x > 1 ? 1 : x) * 255 + 0.5 << shift;
2917
- const srgbCss = (src) => {
2918
- const r = __scale8bit(src[0]);
2919
- const g = __scale8bit(src[1]);
2920
- const b2 = __scale8bit(src[2]);
2921
- const a2 = __ensureAlpha(src[3]);
2922
- return a2 < 1 ? `rgba(${r},${g},${b2},${FF(a2)})` : `#${U24(r << 16 | g << 8 | b2)}`;
2923
- };
2924
- const rgbCss = (src) => srgbCss(rgbSrgb([], src));
2925
- const CSS_LEVEL3 = {
2926
- abgr32: (x) => intArgb32Css(intAbgr32Argb32(x[0])),
2927
- argb32: (x) => intArgb32Css(x[0]),
2928
- hsl: hslCss,
2929
- hsv: hsvCss,
2930
- lab50: (src) => srgbCss(rgbSrgb(null, labRgb([], src))),
2931
- lab65: (src) => srgbCss(rgbSrgb(null, labRgbD65([], src))),
2932
- lch: (src) => srgbCss(rgbSrgb(null, labRgb(null, lchLab([], src)))),
2933
- rgb: rgbCss,
2934
- srgb: srgbCss
2935
- };
2936
- ({
2937
- ...CSS_LEVEL3
2938
- });
2939
- let CSS_DEFAULT = CSS_LEVEL3;
2940
- const css = (src, cssTarget = CSS_DEFAULT) => {
2941
- let asCss;
2942
- return isString(src) ? src : isNumber(src) ? intArgb32Css(src) : src.mode ? (asCss = cssTarget[src.mode]) ? asCss(src) : cssTarget.rgb(
2943
- convert([], src, "rgb", src.mode)
2944
- ) : srgbCss(src);
2945
- };
2946
- const hslHsv = (out, src) => {
2947
- out = clampH(out || src, src);
2948
- const s = out[1];
2949
- const l = out[2];
2950
- const l2 = 2 * l;
2951
- const v = (l2 + s * (1 - Math.abs(l2 - 1))) * 0.5;
2952
- out[1] = 2 * (v - l) / v;
2953
- out[2] = v;
2954
- return out;
2955
- };
2956
- const rgbHcv = (out, src) => {
2957
- out = clamp(out || src, src);
2958
- const p = out[1] < out[2] ? [out[2], out[1], -1, 2 / 3] : [out[1], out[2], 0, -1 / 3];
2959
- const q = out[0] < p[0] ? [p[0], p[1], p[3], out[0]] : [out[0], p[1], p[2], p[0]];
2960
- const c2 = q[0] - Math.min(q[1], q[3]);
2961
- return setC3(
2962
- out,
2963
- clamp01(Math.abs((q[3] - q[1]) / (6 * c2 + EPS) + q[2])),
2964
- clamp01(c2),
2965
- clamp01(q[0])
2966
- );
2967
- };
2968
- const rgbHsv = (out, src) => {
2969
- out = rgbHcv(out, src);
2970
- out[1] /= out[2] + EPS;
2971
- return out;
2972
- };
2973
- const hsv = defColor({
2974
- mode: "hsv",
2975
- channels: { h: { hue: true } },
2976
- order: ["h", "s", "v", "alpha"],
2977
- from: {
2978
- rgb: rgbHsv,
2979
- srgb: rgbHsv,
2980
- hsl: hslHsv,
2981
- lch: [lchLab, labRgb, rgbSrgb, rgbHsv]
2982
- },
2983
- toRgb: hsvRgb
2984
- });
2985
- const defOpVN = (op, dispatch = 1) => {
2986
- const a2 = (o, a22, n) => {
2987
- !o && (o = a22);
2988
- for (let i = a22.length; i-- > 0; ) o[i] = op(a22[i], n);
2989
- return o;
2990
- };
2991
- const b2 = (o, a22, n) => {
2992
- !o && (o = a22);
2993
- o[0] = op(a22[0], n);
2994
- o[1] = op(a22[1], n);
2995
- return o;
2996
- };
2997
- const c2 = (o, a22, n) => {
2998
- !o && (o = a22);
2999
- o[0] = op(a22[0], n);
3000
- o[1] = op(a22[1], n);
3001
- o[2] = op(a22[2], n);
3002
- return o;
3003
- };
3004
- const d2 = (o, a22, n) => {
3005
- !o && (o = a22);
3006
- o[0] = op(a22[0], n);
3007
- o[1] = op(a22[1], n);
3008
- o[2] = op(a22[2], n);
3009
- o[3] = op(a22[3], n);
3010
- return o;
3011
- };
3012
- return [
3013
- vop(dispatch, a2, b2, c2, d2),
3014
- b2,
3015
- c2,
3016
- d2
3017
- ];
3018
- };
3019
- const [a$4, b$1, c] = defOpVN(Math.pow);
3020
- const powN3 = c;
3021
- const CONE_LMS = [
3022
- 0.4122214708,
3023
- 0.2119034982,
3024
- 0.0883024619,
3025
- 0.5363325363,
3026
- 0.6806995451,
3027
- 0.2817188376,
3028
- 0.0514459929,
3029
- 0.1073969566,
3030
- 0.6299787005
3031
- ];
3032
- const rgbOklab = (out, src) => __mulV33(null, OKLAB_M2, powN3(null, __mulV33(out, CONE_LMS, src), 1 / 3));
3033
- const oklabOklch = (out, src) => setC4(
3034
- out || src,
3035
- src[0],
3036
- Math.hypot(src[1], src[2]),
3037
- atan2Abs(src[2], src[1]) * INV_TAU,
3038
- __ensureAlpha(src[3])
3039
- );
3040
- const oklchOklab = (out, src) => setC4(
3041
- out || src,
3042
- src[0],
3043
- ...cossin(src[2] * TAU, src[1]),
3044
- __ensureAlpha(src[3])
3045
- );
3046
- const oklch = defColor({
3047
- mode: "oklch",
3048
- channels: {
3049
- c: { range: [0, 0.3225] }
3050
- },
3051
- order: ["l", "c", "h", "alpha"],
3052
- from: {
3053
- oklab: oklabOklch,
3054
- rgb: (out, src) => oklabOklch(null, rgbOklab(out, src))
3055
- },
3056
- toRgb: [oklchOklab, oklabRgb]
3057
- });
3058
- const srgb = defColor({
3059
- mode: "srgb",
3060
- order: ["r", "g", "b", "alpha"],
3061
- from: {
3062
- abgr32: (out, src) => intAbgr32Srgb(out, src[0]),
3063
- argb32: (out, src) => intArgb32Srgb(out, src[0]),
3064
- hcy: hcyRgb,
3065
- hsi: hsiRgb,
3066
- hsl: hslRgb,
3067
- hsv: hsvRgb,
3068
- rgb: rgbSrgb
3069
- },
3070
- toRgb: srgbRgb
3071
- });
3072
- const compare = (a2, b2) => {
3073
- if (a2 === b2) {
3074
- return 0;
3075
- }
3076
- if (a2 == null) {
3077
- return b2 == null ? 0 : -1;
3078
- }
3079
- if (b2 == null) {
3080
- return a2 == null ? 0 : 1;
3081
- }
3082
- if (typeof a2.compare === "function") {
3083
- return a2.compare(b2);
3084
- }
3085
- if (typeof b2.compare === "function") {
3086
- return -b2.compare(a2);
3087
- }
3088
- return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
3089
- };
3090
- const __key = (k) => typeof k === "function" ? k : (x) => x[k];
3091
- function compareByKey(key, cmp = compare) {
3092
- const kfn = __key(key);
3093
- return (x, y) => cmp(kfn(x), kfn(y));
3094
- }
3095
- const compareNumDesc = (a2, b2) => b2 - a2;
3096
- const defOpVV = (op, dispatch = 1, outA = true) => {
3097
- const a2 = outA ? (o, a22, b22) => {
3098
- !o && (o = a22);
3099
- for (let i = a22.length; i-- > 0; ) o[i] = op(a22[i], b22[i]);
3100
- return o;
3101
- } : (o, a22, b22) => {
3102
- !o && (o = b22);
3103
- for (let i = a22.length; i-- > 0; ) o[i] = op(a22[i], b22[i]);
3104
- return o;
3105
- };
3106
- const b2 = outA ? (o, a22, b22) => {
3107
- !o && (o = a22);
3108
- o[0] = op(a22[0], b22[0]);
3109
- o[1] = op(a22[1], b22[1]);
3110
- return o;
3111
- } : (o, a22, b22) => {
3112
- !o && (o = b22);
3113
- o[0] = op(a22[0], b22[0]);
3114
- o[1] = op(a22[1], b22[1]);
3115
- return o;
3116
- };
3117
- const c2 = outA ? (o, a22, b22) => {
3118
- !o && (o = a22);
3119
- o[0] = op(a22[0], b22[0]);
3120
- o[1] = op(a22[1], b22[1]);
3121
- o[2] = op(a22[2], b22[2]);
3122
- return o;
3123
- } : (o, a22, b22) => {
3124
- !o && (o = b22);
3125
- o[0] = op(a22[0], b22[0]);
3126
- o[1] = op(a22[1], b22[1]);
3127
- o[2] = op(a22[2], b22[2]);
3128
- return o;
3129
- };
3130
- const d2 = outA ? (o, a22, b22) => {
3131
- !o && (o = a22);
3132
- o[0] = op(a22[0], b22[0]);
3133
- o[1] = op(a22[1], b22[1]);
3134
- o[2] = op(a22[2], b22[2]);
3135
- o[3] = op(a22[3], b22[3]);
3136
- return o;
3137
- } : (o, a22, b22) => {
3138
- !o && (o = b22);
3139
- o[0] = op(a22[0], b22[0]);
3140
- o[1] = op(a22[1], b22[1]);
3141
- o[2] = op(a22[2], b22[2]);
3142
- o[3] = op(a22[3], b22[3]);
3143
- return o;
3144
- };
3145
- return [
3146
- vop(dispatch, a2, b2, c2, d2),
3147
- b2,
3148
- c2,
3149
- d2
3150
- ];
3151
- };
3152
- const $add = (a2, b2) => a2 + b2;
3153
- const $mul = (a2, b2) => a2 * b2;
3154
- const $sub = (a2, b2) => a2 - b2;
3155
- const [a$3, b] = defOpVV($add);
3156
- const add = a$3;
3157
- const add2 = b;
3158
- const ZERO2 = Object.freeze([0, 0]);
3159
- const ZERO3 = Object.freeze([0, 0, 0]);
3160
- const cos = Math.cos;
3161
- const sin = Math.sin;
3162
- const cartesian = vop(1);
3163
- cartesian.add(
3164
- 2,
3165
- (out, v, offset = ZERO2) => add2(out || v, cossin(v[1], v[0]), offset)
3166
- );
3167
- cartesian.add(3, (out, v, offset = ZERO3) => {
3168
- const r = v[0];
3169
- const theta = v[1];
3170
- const phi = v[2];
3171
- const ct = cos(theta);
3172
- return setC3(
3173
- out || v,
3174
- r * ct * cos(phi) + offset[0],
3175
- r * ct * sin(phi) + offset[1],
3176
- r * sin(theta) + offset[2]
3177
- );
3178
- });
3179
- const cartesian2FromAngles = (angles, n) => {
3180
- const polar = [];
3181
- for (const x of angles) polar.push(cossin(x, n));
3182
- return polar;
3183
- };
3184
- const __ensureInputs = (src) => assert(src.length > 0, `no inputs given`);
3185
- const [a$2] = defOpVN($mul);
3186
- const mulN = a$2;
3187
- const sum2 = (a2) => a2[0] + a2[1];
3188
- const sum3 = (a2) => a2[0] + a2[1] + a2[2];
3189
- const sum4 = (a2) => a2[0] + a2[1] + a2[2] + a2[3];
3190
- const sum = vop(
3191
- 0,
3192
- (v) => {
3193
- let res = 0;
3194
- for (let i = v.length; i-- > 0; ) res += v[i];
3195
- return res;
3196
- },
3197
- sum2,
3198
- sum3,
3199
- sum4
3200
- );
3201
- const mean = (out, src) => {
3202
- __ensureInputs(src);
3203
- out = set(out || [], src[0]);
3204
- for (let i = src.length; i-- > 1; ) {
3205
- add(out, out, src[i]);
3206
- }
3207
- return mulN(out, out, 1 / src.length);
3208
- };
3209
- const vmean = (a2) => a2.length > 0 ? sum(a2) / a2.length : 0;
3210
- const [a$1] = defOpVN($sub);
3211
- const subN = a$1;
3212
- const center = (out, a2) => subN(out, a2, vmean(a2));
3213
- const headingXY = (a2) => atan2Abs(a2[1], a2[0]);
3214
- const magSq2 = (a2) => a2[0] * a2[0] + a2[1] * a2[1];
3215
- const magSq3 = (a2) => a2[0] * a2[0] + a2[1] * a2[1] + a2[2] * a2[2];
3216
- const magSq4 = (a2) => a2[0] * a2[0] + a2[1] * a2[1] + a2[2] * a2[2] + a2[3] * a2[3];
3217
- const magSq = vop(
3218
- 0,
3219
- (a2) => {
3220
- let sum5 = 0;
3221
- for (let i = a2.length; i-- > 0; ) sum5 += a2[i] * a2[i];
3222
- return sum5;
3223
- },
3224
- magSq2,
3225
- magSq3,
3226
- magSq4
3227
- );
3228
- const variance = (a2, isCentered = false, corrected = false) => {
3229
- const k = ~~corrected;
3230
- return a2.length > k ? magSq(isCentered ? a2 : center([], a2)) / (a2.length - k) : 0;
3231
- };
3232
- const sd = (a2, isCentered = false, corrected = false) => Math.sqrt(variance(a2, isCentered, corrected));
3233
- const circularMean = (angles) => headingXY(mean([], cartesian2FromAngles(angles)));
3234
- const centerCircular = (out, angles) => {
3235
- const mean2 = circularMean(angles);
3236
- !out && (out = []);
3237
- for (let i = 0, n = angles.length; i < n; i++) {
3238
- out[i] = (angles[i] - mean2 + PI) % TAU;
3239
- }
3240
- return center(null, out);
3241
- };
3242
- const circularSD = (angles, corrected) => sd(centerCircular([], angles), true, corrected);
3243
- defOpVV(Math.max);
3244
- const vmax = (v) => {
3245
- let max5 = -Infinity;
3246
- for (let i = v.length; i-- > 0; ) max5 = Math.max(max5, v[i]);
3247
- return max5;
3248
- };
3249
- const vmedian = (a2) => {
3250
- if (!a2.length) return 0;
3251
- const n = a2.length;
3252
- const m = n >> 1;
3253
- a2 = [...a2].sort((a22, b2) => a22 - b2);
3254
- return n & 1 ? a2[m] : (a2[m - 1] + a2[m]) * 0.5;
3255
- };
3256
- defOpVV(Math.min);
3257
- const vmin = (v) => {
3258
- let min5 = Infinity;
3259
- for (let i = v.length; i-- > 0; ) min5 = Math.min(min5, v[i]);
3260
- return min5;
3261
- };
3262
- const defMetric = (values) => {
3263
- const [min2, max2] = valueRange(values);
3264
- return {
3265
- min: min2,
3266
- max: max2,
3267
- mean: vmean(values),
3268
- median: vmedian(values),
3269
- sd: sd(values)
3270
- };
3271
- };
3272
- const defWeightedMetric = (values, weights) => {
3273
- const [min2, max2] = valueRange(values);
3274
- return {
3275
- min: min2,
3276
- max: max2,
3277
- mean: vmean(values),
3278
- median: vmedian(values),
3279
- sd: sd(values),
3280
- weighted: dot(values, weights)
3281
- };
3282
- };
3283
- const defCircularMetric = (values) => {
3284
- const scaledValues = values.map((x) => x * TAU);
3285
- const mean2 = fract(circularMean(scaledValues) / TAU);
3286
- const [min2, max2] = circularRange(values, mean2);
3287
- return {
3288
- min: min2,
3289
- max: max2,
3290
- mean: mean2,
3291
- median: __circularMedian(values, min2, max2),
3292
- sd: circularSD(scaledValues) / TAU
3293
- };
3294
- };
3295
- const valueRange = (values) => [
3296
- vmin(values),
3297
- vmax(values)
3298
- ];
3299
- const circularRange = (values, mean2) => {
3300
- const range = valueRange(values);
3301
- const [min2, max2] = range;
3302
- if (mean2 < min2 || mean2 > max2) {
3303
- return [
3304
- values.reduce(
3305
- (acc, x) => {
3306
- const d2 = fract(mean2 - x);
3307
- return d2 < 0.5 && d2 > acc[1] ? [x, d2] : acc;
3308
- },
3309
- [max2, fract(mean2 - max2)]
3310
- )[0],
3311
- values.reduce(
3312
- (acc, x) => {
3313
- const d2 = fract(x - mean2);
3314
- return d2 < 0.5 && d2 > acc[1] ? [x, d2] : acc;
3315
- },
3316
- [min2, fract(min2 - mean2)]
3317
- )[0]
3318
- ];
3319
- }
3320
- return range;
3321
- };
3322
- const __circularMedian = (values, min2, max2) => {
3323
- if (min2 <= max2) return vmedian(values);
3324
- const n = values.length;
3325
- const m = n >> 1;
3326
- const sorted = [...values].sort((a2, b2) => a2 - b2);
3327
- const split = sorted.findIndex((x) => x === min2);
3328
- const reordered = sorted.slice(split).concat(sorted.slice(0, split));
3329
- return n & 1 ? reordered[m] : (reordered[m - 1] + reordered[m]) * 0.5;
3330
- };
3331
- const isFunction = (x) => typeof x === "function";
3332
- const distSq2 = (a2, b2) => {
3333
- const dx = a2[0] - b2[0];
3334
- const dy = a2[1] - b2[1];
3335
- return dx * dx + dy * dy;
3336
- };
3337
- const distSq3 = (a2, b2) => {
3338
- const dx = a2[0] - b2[0];
3339
- const dy = a2[1] - b2[1];
3340
- const dz = a2[2] - b2[2];
3341
- return dx * dx + dy * dy + dz * dz;
3342
- };
3343
- const distSq4 = (a2, b2) => {
3344
- const dx = a2[0] - b2[0];
3345
- const dy = a2[1] - b2[1];
3346
- const dz = a2[2] - b2[2];
3347
- const dw = a2[3] - b2[3];
3348
- return dx * dx + dy * dy + dz * dz + dw * dw;
3349
- };
3350
- const distSq = vop(
3351
- 0,
3352
- (a2, b2) => {
3353
- let sum5 = 0;
3354
- for (let i = a2.length; i-- > 0; ) {
3355
- const d2 = a2[i] - b2[i];
3356
- sum5 += d2 * d2;
3357
- }
3358
- return sum5;
3359
- },
3360
- distSq2,
3361
- distSq3,
3362
- distSq4
3363
- );
3364
- class Squared {
3365
- constructor(metric) {
3366
- this.metric = metric;
3367
- }
3368
- to(x) {
3369
- return x * x;
3370
- }
3371
- from(x) {
3372
- return Math.sqrt(x);
3373
- }
3374
- }
3375
- const DIST_SQ = new Squared(distSq);
3376
- const argmin = (p, samples, dist = DIST_SQ) => {
3377
- const distFn = isFunction(dist) ? dist : dist.metric;
3378
- let minD = Infinity;
3379
- let minArg = -1;
3380
- for (let i = 0, n = samples.length; i < n; i++) {
3381
- const d2 = distFn(p, samples[i]);
3382
- if (d2 < minD) {
3383
- minD = d2;
3384
- minArg = i;
3385
- }
3386
- }
3387
- return minArg;
3388
- };
3389
- const setN2 = (a2, n) => {
3390
- a2[0] = n;
3391
- a2[1] = n;
3392
- return a2;
3393
- };
3394
- const setN3 = (a2, n) => {
3395
- a2[0] = n;
3396
- a2[1] = n;
3397
- a2[2] = n;
3398
- return a2;
3399
- };
3400
- const setN4 = (a2, n) => {
3401
- a2[0] = n;
3402
- a2[1] = n;
3403
- a2[2] = n;
3404
- a2[3] = n;
3405
- return a2;
3406
- };
3407
- vop(
3408
- 0,
3409
- (a2, n) => {
3410
- for (let i = a2.length; i-- > 0; ) a2[i] = n;
3411
- return a2;
3412
- },
3413
- setN2,
3414
- setN3,
3415
- setN4
3416
- );
3417
- const zeroes = (n) => Array(n).fill(0);
3418
- const ones = (n) => Array(n).fill(1);
3419
- const kmeans = (k, samples, opts = {}) => {
3420
- let {
3421
- dim = samples[0].length,
3422
- dist = DIST_SQ,
3423
- maxIter = 32,
3424
- strategy = means,
3425
- exponent,
3426
- initial,
3427
- rnd
3428
- } = opts;
3429
- const num = samples.length;
3430
- const centroids = Array.isArray(initial) ? initial : initial ? initial(k, samples, dist, rnd) : kmeansPlusPlus(k, samples, dist, rnd, exponent);
3431
- assert(centroids.length > 0, `missing initial centroids`);
3432
- k = centroids.length;
3433
- const clusters = new Uint32Array(num).fill(k);
3434
- let update = true;
3435
- while (update && maxIter-- > 0) {
3436
- update = __assign(samples, centroids, clusters, dist);
3437
- if (!update) break;
3438
- for (let i = 0; i < k; i++) {
3439
- const impl = strategy(dim);
3440
- for (let j = 0; j < num; j++) {
3441
- i === clusters[j] && impl.update(samples[j]);
3442
- }
3443
- const centroid = impl.finish();
3444
- if (centroid) centroids[i] = centroid;
3445
- }
3446
- }
3447
- return __buildClusters(centroids, clusters);
3448
- };
3449
- const kmeansPlusPlus = (k, samples, dist = DIST_SQ, rnd = SYSTEM, exponent = 2) => {
3450
- const num = samples.length;
3451
- assert(num > 0, `missing samples`);
3452
- k = Math.min(k, num);
3453
- const centroidIDs = [rnd.int() % num];
3454
- const centroids = [samples[centroidIDs[0]]];
3455
- const indices = new Array(num).fill(0).map((_, i) => i);
3456
- const metric = dist.metric;
3457
- while (centroidIDs.length < k) {
3458
- let psum = 0;
3459
- const probs = samples.map((p) => {
3460
- const d2 = dist.from(metric(p, centroids[argmin(p, centroids, dist)])) ** exponent;
3461
- psum += d2;
3462
- return d2;
3463
- });
3464
- if (!psum) break;
3465
- let id;
3466
- do {
3467
- id = weightedRandom(indices, probs, rnd)();
3468
- } while (centroidIDs.includes(id));
3469
- centroidIDs.push(id);
3470
- centroids.push(samples[id]);
3471
- }
3472
- return centroids;
3473
- };
3474
- const __assign = (samples, centroids, assignments, dist) => {
3475
- let update = false;
3476
- for (let i = samples.length; i-- > 0; ) {
3477
- const id = argmin(samples[i], centroids, dist);
3478
- if (id !== assignments[i]) {
3479
- assignments[i] = id;
3480
- update = true;
3481
- }
3482
- }
3483
- return update;
3484
- };
3485
- const __buildClusters = (centroids, assignments) => {
3486
- const clusters = [];
3487
- for (let i = 0, n = assignments.length; i < n; i++) {
3488
- const id = assignments[i];
3489
- (clusters[id] || (clusters[id] = {
3490
- id,
3491
- centroid: centroids[id],
3492
- items: []
3493
- })).items.push(i);
3494
- }
3495
- return clusters.filter((x) => !!x);
3496
- };
3497
- const means = (dim) => {
3498
- const acc = zeroes(dim);
3499
- let n = 0;
3500
- return {
3501
- update: (p) => {
3502
- add(acc, acc, p);
3503
- n++;
3504
- },
3505
- finish: () => n ? mulN(acc, acc, 1 / n) : void 0
3506
- };
3507
- };
3508
- const filterSamples = (pred, img) => {
3509
- const samples = [];
3510
- let i = 0;
3511
- for (const p of img) {
3512
- if (pred(p, i)) samples.push(p);
3513
- i++;
3514
- }
3515
- return samples;
3516
- };
3517
- const dominantColorsKmeans = (img, num, opts) => {
3518
- const samples = opts?.filter ? filterSamples(opts.filter, img) : Array.isArray(img) ? img : [...img];
3519
- return samples.length ? kmeans(Math.min(num, samples.length), samples, opts).sort((a2, b2) => b2.items.length - a2.items.length).map(
3520
- (c2) => ({
3521
- color: [...c2.centroid],
3522
- area: c2.items.length / samples.length,
3523
- ids: c2.items
3524
- })
3525
- ) : [];
3526
- };
3527
- const isIterable = (x) => typeof x?.[Symbol.iterator] === "function";
3528
- const compR = (rfn, fn) => [rfn[0], rfn[1], fn];
3529
- const SEMAPHORE = /* @__PURE__ */ Symbol();
3530
- const NO_OP = () => {
3531
- };
3532
- const ensureTransducer = (x) => implementsFunction(x, "xform") ? x.xform() : x;
3533
- const IllegalArityError = defError(() => "illegal arity");
3534
- const illegalArity = (n) => {
3535
- throw new IllegalArityError(n);
3536
- };
3537
- class Reduced {
3538
- value;
3539
- constructor(val) {
3540
- this.value = val;
3541
- }
3542
- deref() {
3543
- return this.value;
3544
- }
3545
- }
3546
- const isReduced = (x) => x instanceof Reduced;
3547
- const ensureReduced = (x) => x instanceof Reduced ? x : new Reduced(x);
3548
- const unreduced = (x) => x instanceof Reduced ? x.deref() : x;
3549
- const __parseArgs = (args) => args.length === 2 ? [void 0, args[1]] : args.length === 3 ? [args[1], args[2]] : illegalArity(args.length);
3550
- function reduce(...args) {
3551
- const rfn = args[0];
3552
- const init = rfn[0];
3553
- const complete = rfn[1];
3554
- const reduce2 = rfn[2];
3555
- args = __parseArgs(args);
3556
- const acc = args[0] == null ? init() : args[0];
3557
- const src = args[1];
3558
- return unreduced(
3559
- complete(
3560
- implementsFunction(src, "$reduce") ? src.$reduce(reduce2, acc) : isArrayLike(src) ? __reduceArray(reduce2, acc, src) : __reduceIterable(reduce2, acc, src)
3561
- )
3562
- );
3563
- }
3564
- const __reduceArray = (rfn, acc, src) => {
3565
- for (let i = 0, n = src.length; i < n; i++) {
3566
- acc = rfn(acc, src[i]);
3567
- if (isReduced(acc)) {
3568
- acc = acc.deref();
3569
- break;
3570
- }
3571
- }
3572
- return acc;
3573
- };
3574
- const __reduceIterable = (rfn, acc, src) => {
3575
- for (const x of src) {
3576
- acc = rfn(acc, x);
3577
- if (isReduced(acc)) {
3578
- acc = acc.deref();
3579
- break;
3580
- }
3581
- }
3582
- return acc;
3583
- };
3584
- const reducer = (init, rfn) => [init, identity$1, rfn];
3585
- const $$reduce = (rfn, args) => {
3586
- const n = args.length - 1;
3587
- return isIterable(args[n]) ? args.length > 1 ? reduce(rfn.apply(null, args.slice(0, n)), args[n]) : reduce(rfn(), args[0]) : void 0;
3588
- };
3589
- function push(src) {
3590
- return src ? [...src] : reducer(
3591
- () => [],
3592
- (acc, x) => (acc.push(x), acc)
3593
- );
3594
- }
3595
- function* iterator(xform, src) {
3596
- const rfn = ensureTransducer(xform)(push());
3597
- const complete = rfn[1];
3598
- const reduce2 = rfn[2];
3599
- for (const x of src) {
3600
- const y = reduce2([], x);
3601
- if (isReduced(y)) {
3602
- yield* unreduced(complete(y.deref()));
3603
- return;
3604
- }
3605
- if (y.length) {
3606
- yield* y;
3607
- }
3608
- }
3609
- yield* unreduced(complete([]));
3610
- }
3611
- function* iterator1(xform, src) {
3612
- const reduce2 = ensureTransducer(xform)([NO_OP, NO_OP, (_, x) => x])[2];
3613
- for (const x of src) {
3614
- let y = reduce2(SEMAPHORE, x);
3615
- if (isReduced(y)) {
3616
- y = unreduced(y.deref());
3617
- if (y !== SEMAPHORE) {
3618
- yield y;
3619
- }
3620
- return;
3621
- }
3622
- if (y !== SEMAPHORE) {
3623
- yield y;
3624
- }
3625
- }
3626
- }
3627
- function map(fn, src) {
3628
- return isIterable(src) ? iterator1(map(fn), src) : (rfn) => {
3629
- const r = rfn[2];
3630
- return compR(rfn, (acc, x) => r(acc, fn(x)));
3631
- };
3632
- }
3633
- function max(src) {
3634
- return src ? reduce(max(), src) : reducer(
3635
- () => -Infinity,
3636
- (acc, x) => Math.max(acc, x)
3637
- );
3638
- }
3639
- function* permutations(...src) {
3640
- const n = src.length - 1;
3641
- if (n < 0) {
3642
- return;
3643
- }
3644
- const step = new Array(n + 1).fill(0);
3645
- const realized = src.map(ensureArrayLike);
3646
- const total = realized.reduce((acc, x) => acc * x.length, 1);
3647
- for (let i = 0; i < total; i++) {
3648
- const tuple = [];
3649
- for (let j = n; j >= 0; j--) {
3650
- const r = realized[j];
3651
- let s = step[j];
3652
- if (s === r.length) {
3653
- step[j] = s = 0;
3654
- j > 0 && step[j - 1]++;
3655
- }
3656
- tuple[j] = r[s];
3657
- }
3658
- step[n]++;
3659
- yield tuple;
3660
- }
3661
- }
3662
- function transduce(...args) {
3663
- return $transduce(transduce, reduce, args);
3664
- }
3665
- const $transduce = (tfn, rfn, args) => {
3666
- let acc, src;
3667
- switch (args.length) {
3668
- case 4:
3669
- src = args[3];
3670
- acc = args[2];
3671
- break;
3672
- case 3:
3673
- src = args[2];
3674
- break;
3675
- case 2:
3676
- return map((x) => tfn(args[0], args[1], x));
3677
- default:
3678
- illegalArity(args.length);
3679
- }
3680
- return rfn(ensureTransducer(args[0])(args[1]), acc, src);
3681
- };
3682
- const [a] = defOpVN(roundTo);
3683
- const roundN = a;
3684
- const smoothStep = (edge, edge2, x) => smoothStep01(clamp01((x - edge) / (edge2 - edge)));
3685
- const smoothStep01 = (x) => x * x * (3 - 2 * x);
3686
- function comp$1(...fns) {
3687
- let [a2, b2, c2, d2, e, f, g, h, i, j] = fns;
3688
- switch (fns.length) {
3689
- case 0:
3690
- illegalArity(0);
3691
- case 1:
3692
- return a2;
3693
- case 2:
3694
- return (...args) => a2(b2(...args));
3695
- case 3:
3696
- return (...args) => a2(b2(c2(...args)));
3697
- case 4:
3698
- return (...args) => a2(b2(c2(d2(...args))));
3699
- case 5:
3700
- return (...args) => a2(b2(c2(d2(e(...args)))));
3701
- case 6:
3702
- return (...args) => a2(b2(c2(d2(e(f(...args))))));
3703
- case 7:
3704
- return (...args) => a2(b2(c2(d2(e(f(g(...args)))))));
3705
- case 8:
3706
- return (...args) => a2(b2(c2(d2(e(f(g(h(...args))))))));
3707
- case 9:
3708
- return (...args) => a2(b2(c2(d2(e(f(g(h(i(...args)))))))));
3709
- case 10:
3710
- default:
3711
- const fn = (...args) => a2(b2(c2(d2(e(f(g(h(i(j(...args))))))))));
3712
- return fns.length === 10 ? fn : comp$1(fn, ...fns.slice(10));
3713
- }
3714
- }
3715
- function comp(...fns) {
3716
- fns = fns.map(ensureTransducer);
3717
- return comp$1.apply(null, fns);
3718
- }
3719
- function count(...args) {
3720
- const res = $$reduce(count, args);
3721
- if (res !== void 0) {
3722
- return res;
3723
- }
3724
- const [offset = 0, step = 1] = args;
3725
- return reducer(
3726
- () => offset,
3727
- (acc, _) => acc + step
3728
- );
3729
- }
3730
- const identity = (x) => x;
3731
- const __groupByOpts = (opts) => ({
3732
- key: (x) => x,
3733
- group: push(),
3734
- ...opts
3735
- });
3736
- function groupByMap(...args) {
3737
- const res = $$reduce(groupByMap, args);
3738
- if (res !== void 0) return res;
3739
- const opts = __groupByOpts(args[0]);
3740
- const [init, complete, reduce2] = opts.group;
3741
- return [
3742
- () => /* @__PURE__ */ new Map(),
3743
- (acc) => {
3744
- for (const k of acc.keys()) {
3745
- acc.set(k, complete(acc.get(k)));
3746
- }
3747
- return acc;
3748
- },
3749
- (acc, x) => {
3750
- const k = opts.key(x);
3751
- return acc.set(
3752
- k,
3753
- acc.has(k) ? reduce2(acc.get(k), x) : reduce2(init(), x)
3754
- );
3755
- }
3756
- ];
3757
- }
3758
- function frequencies(...args) {
3759
- return $$reduce(frequencies, args) || groupByMap({ key: args[0] || identity, group: count() });
3760
- }
3761
- function normFrequenciesAuto(...args) {
3762
- const res = $$reduce(normFrequenciesAuto, args);
3763
- if (res !== void 0) return res;
3764
- const [init, complete, reduce2] = frequencies(...args);
3765
- let norm2 = 0;
3766
- return [
3767
- init,
3768
- (acc) => {
3769
- acc = complete(acc);
3770
- for (const p of acc) {
3771
- acc.set(p[0], p[1] / norm2);
3772
- }
3773
- return acc;
3774
- },
3775
- (acc, x) => (norm2++, reduce2(acc, x))
3776
- ];
3777
- }
3778
- const cat = () => (rfn) => {
3779
- const r = rfn[2];
3780
- return compR(rfn, (acc, x) => {
3781
- if (x) {
3782
- for (const y of unreduced(x) || []) {
3783
- acc = r(acc, y);
3784
- if (isReduced(acc)) {
3785
- break;
3786
- }
3787
- }
3788
- }
3789
- return isReduced(x) ? ensureReduced(acc) : acc;
3790
- });
3791
- };
3792
- function mapcat(fn, src) {
3793
- return isIterable(src) ? iterator(mapcat(fn), src) : comp(map(fn), cat());
3794
- }
3795
- function* repeat(x, n = Infinity) {
3796
- while (n-- > 0) {
3797
- yield x;
3798
- }
3799
- }
3800
- const temperature = (colors, minSat = 0.2, coeffs) => {
3801
- const $colors = ensureArray(colors);
3802
- const filtered = $colors.filter((x) => x[1] >= minSat);
3803
- const area = filtered.length / $colors.length;
3804
- const hues = [
3805
- ...transduce(
3806
- map((x) => roundTo(x[0], 1 / 12) % 1),
3807
- normFrequenciesAuto(),
3808
- filtered
3809
- )
3810
- ].sort(compareByKey(0));
3811
- const angles = [
3812
- ...mapcat(([hue, num]) => {
3813
- num *= 50;
3814
- return num >= 1 ? repeat(hue * TAU, num) : null;
3815
- }, hues)
3816
- ];
3817
- if (!angles.length) {
3818
- return { hues, meanHue: 0, temp: 0, areaTemp: 0, area: 0 };
3819
- }
3820
- const meanHue = circularMean(angles) / TAU;
3821
- const temp = hueTemperature(meanHue, coeffs);
3822
- const areaTemp = temp * area;
3823
- return { hues, meanHue, temp, areaTemp, area };
3824
- };
3825
- const DEFAULT_TEMPERATURE_COEFFS = [
3826
- 0.1,
3827
- 0.6,
3828
- 0.72,
3829
- 0.92
3830
- ];
3831
- const hueTemperature = (hue, [a2, b2, c2, d2] = DEFAULT_TEMPERATURE_COEFFS) => 2 * (hue < 2 / 3 ? smoothStep(b2, a2, hue) : smoothStep(c2, d2, hue)) - 1;
3832
- const analyzeColors = (img, opts) => {
3833
- let $img = img.format !== FLOAT_RGBA ? img.as(FLOAT_RGBA) : img;
3834
- if (opts?.size) $img = __resize($img, opts.size);
3835
- const imgGray = $img.as(FLOAT_GRAY);
3836
- const imgHsv = $img.as(FLOAT_HSVA);
3837
- const colors = __dominantColors($img, opts);
3838
- const colorAreas = colors.map((x) => x.area);
3839
- const derived = deriveColorResults(
3840
- colors.map((x) => x.color),
3841
- colorAreas,
3842
- opts?.minSat,
3843
- opts?.tempCoeffs
3844
- );
3845
- const lumImg = defMetric(imgGray.data);
3846
- return {
3847
- ...derived,
3848
- img: $img,
3849
- imgGray,
3850
- imgHsv,
3851
- lumImg,
3852
- temperature: temperature(imgHsv, opts?.minSat, opts?.tempCoeffs),
3853
- contrastImg: lumImg.max - lumImg.min
3854
- };
3855
- };
3856
- const deriveColorResults = (colors, areas = ones(colors.length), minSat, tempCoeffs) => {
3857
- const dominantLuma = colors.map((x) => luminanceSrgb(x));
3858
- const dominantSrgb = colors.map((x) => srgb(x));
3859
- const dominantHsv = dominantSrgb.map((x) => hsv(x));
3860
- const dominantOklch = dominantSrgb.map((x) => oklch(x));
3861
- const dominantCss = dominantSrgb.map((x) => css(x));
3862
- const hues = dominantHsv.map((x) => x[0]);
3863
- const sats = dominantHsv.map((x) => x[1]);
3864
- const lum = defWeightedMetric(dominantLuma, areas);
3865
- return {
3866
- css: dominantCss,
3867
- srgb: dominantSrgb,
3868
- hsv: dominantHsv,
3869
- oklch: dominantOklch,
3870
- hue: defCircularMetric(hues),
3871
- sat: defWeightedMetric(sats, areas),
3872
- chroma: defWeightedMetric(
3873
- dominantOklch.map((x) => x[1]),
3874
- areas
3875
- ),
3876
- lum,
3877
- areas,
3878
- contrast: lum.max - lum.min,
3879
- colorContrast: fit(
3880
- transduce(
3881
- map((pair) => contrast(...pair)),
3882
- max(),
3883
- permutations(dominantSrgb, dominantSrgb)
3884
- ),
3885
- 1,
3886
- 21,
3887
- 0,
3888
- 1
3889
- ),
3890
- temperature: temperature(dominantHsv, minSat, tempCoeffs)
3891
- };
3892
- };
3893
- const __dominantColors = (img, {
3894
- dominantFn = dominantColorsKmeans,
3895
- numColors = 4,
3896
- prec = 1e-3
3897
- } = {}) => dominantFn(img, numColors).sort(compareByKey("area", compareNumDesc)).map((x) => (roundN(null, x.color, prec), x));
3898
- const __resize = ($img, size) => {
3899
- size = ~~size;
3900
- let w = $img.width;
3901
- let h = $img.height;
3902
- [w, h] = w > h ? [size, ~~Math.max(1, h / w * size)] : [~~Math.max(1, w / h * size), size];
3903
- return $img.resize(w, h);
3904
- };
3905
- /**
3906
- * Options for extracting colors / evaluating lightness from an image.
3907
- *
3908
- * @typedef {Object} ImageAnalysisResult
3909
- * @property {boolean} isDark - Whether the image is considered dark overall.
3910
- * @property {boolean} isTransparent - Whether the image has any transparency.
3911
- * @property {{ any: boolean, left: boolean, right: boolean, top: boolean, bottom: boolean }} transparencyInfo - More detailed transparency info.
3912
- * @property {Array<{ color: string, area: number, isDark: boolean }>} dominantColors - Dominant colors extracted from the image.
3913
- * @property {Array} dominantColors.<index>.color - The color value.
3914
- * @property {Array} dominantColors.<index>.area - The area occupied by this color (0 - 1).
3915
- * @property {Array} dominantColors.<index>.isDark - Whether this color is considered dark.
3916
- *
3917
- * @preserve
3918
- */
3919
- /**
3920
- * Options for extracting colors / evaluating lightness from an image.
3921
- *
3922
- * @typedef {Object} ImageAnalysisSettings
3923
- * @property {number} [numColors=2] - Number of dominant colors to return.
3924
- * @property {number} [lightnessThreshold=0.5] - Threshold (0.0 - 1.0) used to decide if a color is considered "light".
3925
- * @property {number} [yFrom=0.0] - Minimum Y (luminance) value (0.0 - 1.0) to include when evaluating lightness.
3926
- * @property {number} [yTo=1.0] - Maximum Y (luminance) value (0.0 - 1.0) to include when evaluating lightness.
3927
- * @property {number} [maxSize=320] - Maximum width/height to scale down the image to before analysis, for performance.
3928
- * @property {number} [alphaThreshold=30] - Threhold (0-255) below which a pixel is considered "transparent" for the purposes of analysis.
3929
- *
3930
- * @preserve
3931
- */
3932
- const defaultAnalysisSettings = {
3933
- numColors: 3,
3934
- lightnessThreshold: 0.5,
3935
- yFrom: 0,
3936
- yTo: 1,
3937
- maxSize: 320,
3938
- alphaThreshold: 30
3939
- };
3940
- /**
3941
- * Analyze an image element to determine overall luminance, dominant colors and transparency.
3942
- *
3943
- * @param {HTMLImageElement} image - Image element to check.
3944
- * @param {ImageAnalysisSettings} [settings] - Optional settings to customize the analysis.
3945
- *
3946
- * @returns {{ isDark: boolean, dominantColors: Array<{ color: string, area: number, isDark: boolean }>, isTransparent: boolean } | false}
3947
- * Returns an object on success:
3948
- * - isDark: true if the computed mean image luminance is below 0.5.
3949
- * - dominantColors: an array of up to the requested number of dominant colors. Each entry contains:
3950
- * - color: CSS color string (as produced by the analyzer).
3951
- * - area: the relative area (weight) of that color.
3952
- * - isDark: boolean indicating whether the color's lightness (oklch.l) is < 0.5.
3953
- * - isTransparent: true if any inspected pixel has alpha < 255.
3954
- * Returns false if an error occurred during analysis.
3955
- *
3956
- * @preserve
3957
- */
3958
- const analyzeImage = (image, rawSettings) => {
3959
- const settings = { ...defaultAnalysisSettings, ...rawSettings };
3960
- const { yFrom, yTo, maxSize } = settings;
3961
- const cacheKey = `es-uic-img-analysis-${cyrb64Hash(image.src)}`;
3962
- if (localStorage?.getItem(cacheKey)) {
3963
- return JSON.parse(localStorage.getItem(cacheKey));
3964
- }
3965
- try {
3966
- const fileExtension = getFileExtension(image.src);
3967
- let skipTransparencyCheck = false;
3968
- if (fileExtension) {
3969
- skipTransparencyCheck = !["png", "webp", "gif", "tiff", "svg", "avif"].includes(fileExtension);
3970
- }
3971
- let imageWidth = image.naturalWidth || image.width;
3972
- let imageHeight = image.naturalHeight || image.height;
3973
- if (!image.complete) {
3974
- throw new Error("Image not fully loaded");
3975
- }
3976
- if (!imageWidth || !imageHeight) {
3977
- return false;
3978
- }
3979
- let imageScale = 1;
3980
- if (imageWidth > maxSize || imageHeight > maxSize) {
3981
- imageScale = Math.min(maxSize / imageWidth, maxSize / imageHeight);
3982
- }
3983
- const imageWidthScaled = Math.floor(imageWidth * imageScale);
3984
- const imageHeightScaled = Math.floor(imageHeight * imageScale);
3985
- const srcX = 0;
3986
- const srcY = Math.floor(yFrom * imageHeight);
3987
- const srcW = Math.max(1, imageWidth);
3988
- const srcH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeight));
3989
- const destW = Math.max(1, imageWidthScaled);
3990
- const destH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeightScaled));
3991
- const colorCanvas = document.createElement("canvas");
3992
- colorCanvas.width = destW;
3993
- colorCanvas.height = destH;
3994
- const colorContext = colorCanvas.getContext("2d");
3995
- colorContext.drawImage(image, srcX, srcY, srcW, srcH, 0, 0, destW, destH);
3996
- const buffer = floatBufferFromCanvas(colorCanvas, FLOAT_RGBA);
3997
- let imageData = null;
3998
- if (!skipTransparencyCheck) {
3999
- const transparencyCanvas = document.createElement("canvas");
4000
- transparencyCanvas.width = imageWidthScaled;
4001
- transparencyCanvas.height = imageHeightScaled;
4002
- const transparencyContext = transparencyCanvas.getContext("2d", { willReadFrequently: true });
4003
- transparencyContext.drawImage(image, 0, 0, imageWidth, imageHeight, 0, 0, imageWidthScaled, imageHeightScaled);
4004
- imageData = transparencyContext.getImageData(0, 0, imageWidthScaled, imageHeightScaled).data;
4005
- }
4006
- const result = analyzeImageData({
4007
- buffer,
4008
- imageData,
4009
- width: imageWidthScaled,
4010
- height: imageHeightScaled,
4011
- settings,
4012
- skipTransparencyCheck,
4013
- fileName: image.src
4014
- });
4015
- localStorage?.setItem(cacheKey, JSON.stringify(result));
4016
- return result;
4017
- } catch (error) {
4018
- console.error("Error analyzing image:", error);
4019
- return false;
4020
- }
4021
- };
4022
- const analyzeImageAsync = async (imageSource, rawSettings, fbfc, fr, ac, dck, srgbFn, cssFn) => {
4023
- const defaults = {
4024
- numColors: 3,
4025
- lightnessThreshold: 0.5,
4026
- yFrom: 0,
4027
- yTo: 1,
4028
- maxSize: 600,
4029
- alphaThreshold: 50
4030
- };
4031
- const settings = Object.assign({}, defaults, rawSettings);
4032
- const numColors = settings.numColors;
4033
- const lightnessThreshold = settings.lightnessThreshold;
4034
- const yFrom = settings.yFrom;
4035
- const yTo = settings.yTo;
4036
- const maxSize = settings.maxSize;
4037
- const alphaThreshold = settings.alphaThreshold;
4038
- const getFileExt = (input) => {
4039
- try {
4040
- const url = new URL(input);
4041
- const match = url.pathname.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);
4042
- return match ? match[1].toLowerCase() : null;
4043
- } catch {
4044
- return null;
4045
- }
4046
- };
4047
- const isColorDark2 = (r, g, b2, threshold) => {
4048
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b2) / 255;
4049
- return luminance < threshold;
4050
- };
4051
- const checkTransparency2 = (imageData, w, h) => {
4052
- const transparency = { any: true, left: true, right: true, top: true, bottom: true };
4053
- let counts = { any: 0, left: 0, right: 0, top: 0, bottom: 0 };
4054
- const perimeterThresholdW = Math.floor(0.15 * w);
4055
- const perimeterThresholdH = Math.floor((h > 100 ? 0.075 : 0.75) * h);
4056
- const innerThreshold = Math.floor(w * h * 1e-3);
4057
- if (w > 0 && h > 0) {
4058
- for (let x = 0; x < w; x++) {
4059
- if (imageData[(0 * w + x) * 4 + 3] > alphaThreshold) {
4060
- counts.top++;
4061
- if (counts.top >= perimeterThresholdW) {
4062
- transparency.top = false;
4063
- break;
4064
- }
4065
- }
4066
- }
4067
- for (let x = 0; x < w; x++) {
4068
- if (imageData[((h - 1) * w + x) * 4 + 3] > alphaThreshold) {
4069
- counts.bottom++;
4070
- if (counts.bottom >= perimeterThresholdW) {
4071
- transparency.bottom = false;
4072
- break;
4073
- }
4074
- }
4075
- }
4076
- for (let y = 0; y < h; y++) {
4077
- if (imageData[(y * w + 0) * 4 + 3] > alphaThreshold) {
4078
- counts.left++;
4079
- if (counts.left >= perimeterThresholdH) {
4080
- transparency.left = false;
4081
- break;
4082
- }
4083
- }
4084
- }
4085
- for (let y = 0; y < h; y++) {
4086
- if (imageData[(y * w + (w - 1)) * 4 + 3] > alphaThreshold) {
4087
- counts.right++;
4088
- if (counts.right >= perimeterThresholdH) {
4089
- transparency.right = false;
4090
- break;
4091
- }
4092
- }
4093
- }
4094
- if (!transparency.top && !transparency.bottom && !transparency.left && !transparency.right) {
4095
- for (let i = 3; i < imageData.length; i += 4) {
4096
- if (imageData[i] > alphaThreshold) {
4097
- counts.any++;
4098
- if (counts.any >= innerThreshold) {
4099
- transparency.any = false;
4100
- break;
4101
- }
4102
- }
4103
- }
4104
- } else {
4105
- transparency.any = true;
4106
- }
4107
- }
4108
- return transparency;
4109
- };
4110
- try {
4111
- let imageBitmap;
4112
- if (typeof imageSource === "string") {
4113
- imageBitmap = await createImageBitmap(await (await fetch(imageSource)).blob());
4114
- } else if (imageSource instanceof Blob) {
4115
- imageBitmap = await createImageBitmap(imageSource);
4116
- } else if (imageSource instanceof ArrayBuffer) {
4117
- imageBitmap = await createImageBitmap(new Blob([imageSource]));
4118
- } else if (imageSource instanceof ImageBitmap) {
4119
- imageBitmap = imageSource;
4120
- } else {
4121
- throw new Error("Unsupported imageSource type");
4122
- }
4123
- const imageWidth = imageBitmap.width;
4124
- const imageHeight = imageBitmap.height;
4125
- if (!imageWidth || !imageHeight) {
4126
- return false;
4127
- }
4128
- let imageScale = 1;
4129
- if (imageWidth > maxSize || imageHeight > maxSize) {
4130
- imageScale = Math.min(maxSize / imageWidth, maxSize / imageHeight);
4131
- }
4132
- const imageWidthScaled = Math.floor(imageWidth * imageScale);
4133
- const imageHeightScaled = Math.floor(imageHeight * imageScale);
4134
- const srcX = 0;
4135
- const srcY = Math.floor(yFrom * imageHeight);
4136
- const srcW = Math.max(1, imageWidth);
4137
- const srcH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeight));
4138
- const destW = Math.max(1, imageWidthScaled);
4139
- const destH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeightScaled));
4140
- const colorCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(destW, destH) : (() => {
4141
- const c2 = document.createElement("canvas");
4142
- c2.width = destW;
4143
- c2.height = destH;
4144
- return c2;
4145
- })();
4146
- const colorContext = colorCanvas.getContext("2d");
4147
- colorContext.drawImage(imageBitmap, srcX, srcY, srcW, srcH, 0, 0, destW, destH);
4148
- const buffer = fbfc(colorCanvas, fr);
4149
- const data = ac(buffer, {
4150
- numColors,
4151
- dominantFn: (pixels, num) => dck(pixels, num, {
4152
- filter: (p) => {
4153
- const { alpha } = srgbFn(p);
4154
- return alpha > 0;
4155
- }
4156
- }),
4157
- prec: 0.01
4158
- });
4159
- const { lumImg, srgb: srgbData, areas: colorAreas } = data;
4160
- if (!Array.isArray(srgbData)) {
4161
- console.error("srgbData is not an array:", srgbData, "Full data:", data);
4162
- return false;
4163
- }
4164
- let transparencyInfo = false;
4165
- let skipTransparencyCheck = false;
4166
- if (typeof imageSource === "string") {
4167
- const fileExtension = getFileExt(imageSource);
4168
- if (fileExtension) {
4169
- skipTransparencyCheck = !["png", "webp", "gif", "tiff", "svg", "avif"].includes(fileExtension);
4170
- }
4171
- }
4172
- if (!skipTransparencyCheck) {
4173
- const transparencyCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(imageWidthScaled, imageHeightScaled) : (() => {
4174
- const c2 = document.createElement("canvas");
4175
- c2.width = imageWidthScaled;
4176
- c2.height = imageHeightScaled;
4177
- return c2;
4178
- })();
4179
- const transparencyContext = transparencyCanvas.getContext("2d");
4180
- transparencyContext.drawImage(imageBitmap, 0, 0, imageWidth, imageHeight, 0, 0, imageWidthScaled, imageHeightScaled);
4181
- const imageData = transparencyContext.getImageData(0, 0, imageWidthScaled, imageHeightScaled).data;
4182
- transparencyInfo = checkTransparency2(imageData, imageWidthScaled, imageHeightScaled);
4183
- }
4184
- return {
4185
- isDark: lumImg.mean < lightnessThreshold,
4186
- isTransparent: skipTransparencyCheck ? false : transparencyInfo?.any,
4187
- transparencyInfo: skipTransparencyCheck ? null : transparencyInfo,
4188
- dominantColors: srgbData.map(({ r, g, b: b2 }, index) => ({
4189
- color: cssFn([r, g, b2]),
4190
- area: colorAreas?.[index],
4191
- isDark: isColorDark2(r * 255, g * 255, b2 * 255, lightnessThreshold)
4192
- }))
4193
- };
4194
- } catch (error) {
4195
- console.error("Error analyzing image (async):", error);
4196
- return false;
4197
- }
4198
- };
4199
- /**
4200
- * Check image transparency by analyzing pixel alpha values.
4201
- *
4202
- * @param {Uint8ClampedArray} imageData - The image data array containing RGBA values.
4203
- * @param {number} w - The width of the image.
4204
- * @param {number} h - The height of the image.
4205
- * @param {ImageAnalysisSettings} [settings] - Optional settings to customize the transparency check.
4206
- *
4207
- * @return {{ any: boolean, left: boolean, right: boolean, top: boolean, bottom: boolean }} An object indicating transparency on different sides of the image.
4208
- *
4209
- * @preserve
4210
- */
4211
- const checkTransparency = (imageData, w, h, settings = {}) => {
4212
- const { alphaThreshold } = { ...defaultAnalysisSettings, ...settings };
4213
- const transparency = {
4214
- any: true,
4215
- left: true,
4216
- right: true,
4217
- top: true,
4218
- bottom: true
4219
- };
4220
- let counts = {
4221
- any: 0,
4222
- left: 0,
4223
- right: 0,
4224
- top: 0,
4225
- bottom: 0
4226
- };
4227
- const perimeterThresholdW = Math.floor(0.15 * w);
4228
- const perimeterThresholdH = Math.floor((h > 100 ? 0.05 : 0.5) * h);
4229
- const innerThreshold = Math.floor(w * h * 1e-3);
4230
- if (w > 0 && h > 0) {
4231
- for (let x = 0; x < w; x++) {
4232
- const idx = (0 * w + x) * 4 + 3;
4233
- if (imageData[idx] > alphaThreshold) {
4234
- counts.top++;
4235
- if (counts.top >= perimeterThresholdW) {
4236
- transparency.top = false;
4237
- break;
4238
- }
4239
- }
4240
- }
4241
- for (let x = 0; x < w; x++) {
4242
- const idx = ((h - 1) * w + x) * 4 + 3;
4243
- if (imageData[idx] > alphaThreshold) {
4244
- counts.bottom++;
4245
- if (counts.bottom >= perimeterThresholdW) {
4246
- transparency.bottom = false;
4247
- break;
4248
- }
4249
- }
4250
- }
4251
- for (let y = 0; y < h; y++) {
4252
- const idx = (y * w + 0) * 4 + 3;
4253
- if (imageData[idx] > alphaThreshold) {
4254
- counts.left++;
4255
- if (counts.left >= perimeterThresholdH) {
4256
- transparency.left = false;
4257
- break;
4258
- }
4259
- }
4260
- }
4261
- for (let y = 0; y < h; y++) {
4262
- const idx = (y * w + (w - 1)) * 4 + 3;
4263
- if (imageData[idx] > alphaThreshold) {
4264
- counts.right++;
4265
- if (counts.right >= perimeterThresholdH) {
4266
- transparency.right = false;
4267
- break;
4268
- }
4269
- }
4270
- }
4271
- if (!transparency.top && !transparency.bottom && !transparency.left && !transparency.right) {
4272
- for (let i = 3; i < imageData.length; i += 4) {
4273
- if (imageData[i] > alphaThreshold) {
4274
- counts.any++;
4275
- if (counts.any >= innerThreshold) {
4276
- transparency.any = false;
4277
- break;
4278
- }
4279
- }
4280
- }
4281
- } else {
4282
- transparency.any = true;
4283
- }
4284
- }
4285
- return transparency;
4286
- };
4287
- /**
4288
- * Get file extension from a URL string.
4289
- *
4290
- * @param {string} input - The URL string to extract the file extension from.
4291
- *
4292
- * @returns {string|null} The file extension in lowercase, or null if not found.
4293
- *
4294
- * @example
4295
- * getFileExtension('https://example.com/image.png'); // 'png'
4296
- * getFileExtension('https://example.com/archive.tar.gz'); // 'gz'
4297
- * getFileExtension('https://example.com/no-extension'); // null
4298
- *
4299
- * @preserve
4300
- */
4301
- const getFileExtension = (input) => {
4302
- const url = new URL(input);
4303
- const pathname = url.pathname;
4304
- const match = pathname.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);
4305
- return match ? match[1].toLowerCase() : null;
4306
- };
4307
- /**
4308
- * Determine if a color is considered "dark" based on its RGB values and a lightness threshold.
4309
- *
4310
- * @param {number} r - Red component (0-255).
4311
- * @param {number} g - Green component (0-255).
4312
- * @param {number} b - Blue component (0-255).
4313
- * @param {number} [threshold=0.5] - Lightness threshold (0.0 - 1.0) below which the color is considered dark.
4314
- *
4315
- * @returns {boolean} True if the color is dark, false otherwise.
4316
- *
4317
- * @example
4318
- * isColorDark(0, 0, 0); // true (black)
4319
- * isColorDark(255, 255, 255); // false (white)
4320
- * isColorDark(100, 100, 100, 0.4); // false (gray with higher threshold)
4321
- *
4322
- * @preserve
4323
- */
4324
- const isColorDark = (r, g, b2, threshold = 0.5) => {
4325
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b2) / 255;
4326
- return luminance < threshold;
4327
- };
4328
- /**
4329
- * Core analysis logic shared by both main thread and worker.
4330
- *
4331
- * @param {Object} options - Configuration options
4332
- * @prop {Float32Array} buffer - Float32Array RGBA buffer (from floatBufferFromCanvas)
4333
- * @prop {Uint8ClampedArray} imageData - Uint8ClampedArray (from getImageData)
4334
- * @prop {number} width - Image width
4335
- * @prop {number} height - Image height
4336
- * @prop {ImageAnalysisSettings} settings - Analysis settings
4337
- * @prop {boolean} skipTransparencyCheck - Boolean to skip transparency check
4338
- *
4339
- * @returns {ImageAnalysisResult}
4340
- *
4341
- * @preserve
4342
- */
4343
- const analyzeImageData = ({ buffer, imageData, width, height, settings, skipTransparencyCheck = false }) => {
4344
- const { numColors, lightnessThreshold } = settings;
4345
- const data = analyzeColors(buffer, {
4346
- numColors,
4347
- dominantFn: (pixels, num) => dominantColorsKmeans(pixels, num, {
4348
- filter: (p) => srgb(p).alpha > 0
4349
- }),
4350
- prec: 0.01
4351
- });
4352
- const { lumImg, srgb: srgbData, areas: colorAreas } = data;
4353
- let transparencyInfo = false;
4354
- if (!skipTransparencyCheck && imageData) {
4355
- transparencyInfo = checkTransparency(imageData, width, height, settings);
4356
- }
4357
- return {
4358
- isDark: lumImg.mean < lightnessThreshold,
4359
- isTransparent: skipTransparencyCheck ? false : transparencyInfo?.any,
4360
- transparencyInfo: skipTransparencyCheck ? null : transparencyInfo,
4361
- dominantColors: srgbData.map(({ r, g, b: b2 }, index) => ({
4362
- color: css([r, g, b2]),
4363
- area: colorAreas?.[index],
4364
- isDark: isColorDark(r * 255, g * 255, b2 * 255, lightnessThreshold)
4365
- }))
4366
- };
4367
- };
4368
- export {
4369
- FLOAT_RGBA as F,
4370
- analyzeImageData as a,
4371
- analyzeImage as b,
4372
- analyzeImageAsync as c,
4373
- checkTransparency as d,
4374
- floatBufferFromCanvas as f,
4375
- getFileExtension as g,
4376
- isColorDark as i,
4377
- srgb as s
4378
- };