@softistx/material 3.248.0 → 3.250.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 (228) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +8 -4
  3. package/dist/adopt-styles-C3MfGnxE.js +20 -0
  4. package/dist/{async-slice-C5HfFq1M.js → async-slice-DdEr7vFx.js} +1 -1
  5. package/dist/{audio-player-2kKst8lH.js → audio-player-DMYszRGT.js} +3 -3
  6. package/dist/{audio-player-viewer-D9DsYBcy.js → audio-player-viewer-z13yCjo4.js} +2 -2
  7. package/dist/{autocomplete-JuRCjl48.js → autocomplete-Bgf_AJ6U.js} +11 -11
  8. package/dist/{avatar-CvvdaBu4.js → avatar-WvTropuJ.js} +1 -1
  9. package/dist/blank-placeholder-DZIFJ0DG.js +17 -0
  10. package/dist/{breadcrumb-DacRqg91.js → breadcrumb-DYa6pVsq.js} +5 -5
  11. package/dist/{button-CpUMPIdk.js → button-RsWgka2v.js} +1 -1
  12. package/dist/{calculator-BYgFgWHL.js → calculator-DPHCuAZy.js} +11 -11
  13. package/dist/calculator-field.js +6 -6
  14. package/dist/{calculator-segment-DCHWZy6b.js → calculator-segment-Ckn9Fua9.js} +1 -1
  15. package/dist/calculator.js +1 -1
  16. package/dist/canvas-BShNj4yp.js +144 -0
  17. package/dist/capture-outputs-qcYUPW6K.js +174 -0
  18. package/dist/capture-toolbar.css +2 -0
  19. package/dist/capture-toolbar.js +858 -0
  20. package/dist/capture.js +53 -139
  21. package/dist/charts.js +3 -3
  22. package/dist/{chip-CjJPmAYO.js → chip-tyDM0lpO.js} +2 -2
  23. package/dist/{code-editor-nNcxtslA.js → code-editor-gHHXEwF-.js} +6 -6
  24. package/dist/code-editor.js +6 -6
  25. package/dist/{code-file-viewer-CcESl49v.js → code-file-viewer-CYQcskvt.js} +4 -4
  26. package/dist/{code-language-items-CW8_Si05.js → code-language-items-DDFuDf_E.js} +2 -2
  27. package/dist/{components-BdMaUeOm.js → components-DUvKQIBi.js} +16714 -20832
  28. package/dist/components.js +83 -79
  29. package/dist/{confirm-dialog-B2eonW2X.js → confirm-dialog-IHvPA3O2.js} +4 -4
  30. package/dist/{conversion-variant-DZm_xgUK.js → conversion-variant-MWTjnFnG.js} +5 -5
  31. package/dist/{currency-field-UIkYAlvP.js → currency-field-Bd9od1Ee.js} +5 -5
  32. package/dist/{detail-panel-header-CL2_tUG0.js → detail-panel-header-D2a63Sk3.js} +1 -1
  33. package/dist/{details-content-CPzj3vUr.js → details-content-CnN_ukTA.js} +6 -6
  34. package/dist/{details-header-band-D-CyB_Xx.js → details-header-band-wcgmC7qC.js} +5 -5
  35. package/dist/{details-host-BvYgFIWx.js → details-host-DKEaGH4P.js} +1 -1
  36. package/dist/{details-sheet-D4PTV_jR.js → details-sheet-CtNM4oDU.js} +2 -2
  37. package/dist/{details-shell-D4XoPRBu.js → details-shell-DZ80h6mN.js} +1 -1
  38. package/dist/{dialog-CleLsHkZ.js → dialog-DwUxG2-o.js} +1 -1
  39. package/dist/{dialog-app-bar-CLC990e6.js → dialog-app-bar-BsJ4UwKb.js} +2 -2
  40. package/dist/dist-Cb17ixQs.js +16 -0
  41. package/dist/dist-CyqFzDZ6.js +11 -0
  42. package/dist/dnd.js +1 -1
  43. package/dist/draw.js +1 -1
  44. package/dist/{drop-overlay-BTkVfscF.js → drop-overlay-B26hx0-T.js} +2 -2
  45. package/dist/{dropdown-menu-BoJC2DEH.js → dropdown-menu-D-PRbHaP.js} +1 -1
  46. package/dist/{editable-section-CTRGfbLJ.js → editable-section-DPmF1flG.js} +3 -3
  47. package/dist/editor.js +14 -14
  48. package/dist/embed-chunks/{avatar-GlGqPU7B.js → avatar-CSDtFCum.js} +1 -1
  49. package/dist/embed-chunks/{dist-BrYZYfsJ.js → dist-BVPJSDov.js} +2 -2
  50. package/dist/embed-chunks/{emoji-picker-BSYBi_C8.js → emoji-picker-CrIXB9pF.js} +23 -23
  51. package/dist/embed-chunks/{mention-list-NW43QcRq.js → mention-list-9hwOYNND.js} +3 -3
  52. package/dist/embed-chunks/{nxgt-theme-provider-B1aeqDja.js → nxgt-theme-provider-Cjl7Eb8v.js} +703 -592
  53. package/dist/embed-chunks/switch-control-BrwJRN_V.js +207 -0
  54. package/dist/embed-chunks/{tabs-root-CY-uLp1C.js → tabs-root-BvPc1aaV.js} +6 -6
  55. package/dist/embed-chunks/{use-shape-morph-NrJQMv7i.js → use-shape-morph-D1MOoQ4T.js} +110 -2
  56. package/dist/embed-chunks/{useLatest-B57qw3XH.js → useLatest-CbcU5ozz.js} +323 -323
  57. package/dist/embed.css +2 -2
  58. package/dist/embed.js +1280 -741
  59. package/dist/{emoji-picker-DZbTd3Fr.js → emoji-picker-DabgsEVQ.js} +7 -7
  60. package/dist/{empty-state-DBSJDLKL.js → empty-state-BylD7RYH.js} +1 -1
  61. package/dist/{error-state-kauz4If4.js → error-state-BTe_NzTC.js} +2 -2
  62. package/dist/fab-DUnGwNE7.js +41 -0
  63. package/dist/fab-dock-By2pLVh7.js +49 -0
  64. package/dist/{feature-popup-CcXMGFES.js → feature-popup-CW7VS2fx.js} +1 -1
  65. package/dist/{blank-placeholder-DeDn5Xor.js → field-box-BXN-uyrv.js} +1 -16
  66. package/dist/{field-group-BpV74Ttu.js → field-group-B2Ozd5Jn.js} +1 -1
  67. package/dist/{file-dialogs-CbdvmY__.js → file-dialogs-CgEXaCev.js} +7 -7
  68. package/dist/{file-manager-shell-DLaJ5Z_L.js → file-manager-shell-Tqduf5lh.js} +21 -21
  69. package/dist/{file-preview-host-RhZvGGqC.js → file-preview-host-CM4pV3ZD.js} +2367 -2384
  70. package/dist/{file-viewer-body-DM3RkXGn.js → file-viewer-body-DrWFmnp4.js} +3 -3
  71. package/dist/{file-viewer-dialog-impl-ei5EYj8k.js → file-viewer-dialog-impl-DZpuZZ7x.js} +2 -2
  72. package/dist/files-drop.js +1 -1
  73. package/dist/files-picker.js +8 -8
  74. package/dist/files.js +3 -3
  75. package/dist/{financial-variant-BNdOqzA5.js → financial-variant-ljdP0JL4.js} +5 -5
  76. package/dist/{flow-diagram-BBB6r8--.js → flow-diagram-DwUnyl0u.js} +1 -1
  77. package/dist/{gallery-CIIJHpmj.js → gallery-DfN2KE4Y.js} +11 -11
  78. package/dist/{gallery-file-viewer-DkshswFr.js → gallery-file-viewer-BfFWfLIF.js} +3 -3
  79. package/dist/{gl-markers-abqcNuYT.js → gl-markers-CBNFeWIk.js} +3 -3
  80. package/dist/{hooks-D6lOSXA5.js → hooks-DiAhgchz.js} +3 -3
  81. package/dist/hooks.js +3 -3
  82. package/dist/i18n.js +3 -3
  83. package/dist/{icon-button-GKYj7uC4.js → icon-button-D-gi4Plg.js} +1 -1
  84. package/dist/image-editor-mmhbsqs-.js +4423 -0
  85. package/dist/image-editor.css +1 -1
  86. package/dist/image-editor.js +1157 -996
  87. package/dist/image-markup-editor-D-QkZWKf.js +24 -0
  88. package/dist/input-CWf3Apid.js +18 -0
  89. package/dist/input-box-moFuoMt0.js +15 -0
  90. package/dist/{input-group-CKO68Pyi.js → input-group-Bb8sAFRF.js} +3 -2
  91. package/dist/{item-details-l_-rk3Hj.js → item-details-BWdHMfsS.js} +7 -7
  92. package/dist/keypad.js +2 -2
  93. package/dist/lib/capture/engine/canvas.d.ts +17 -0
  94. package/dist/lib/capture/engine/capture.d.ts +19 -0
  95. package/dist/lib/capture/engine/filters.d.ts +27 -0
  96. package/dist/lib/capture/engine/rect.d.ts +26 -0
  97. package/dist/lib/capture/engine/types.d.ts +66 -0
  98. package/dist/lib/capture/index.d.ts +16 -0
  99. package/dist/lib/capture/modes/capture-mode.d.ts +24 -0
  100. package/dist/lib/capture/modes/countdown.d.ts +16 -0
  101. package/dist/lib/capture/modes/full-page.d.ts +14 -0
  102. package/dist/lib/capture/modes/pick-element.d.ts +22 -0
  103. package/dist/lib/capture/modes/scroller.d.ts +13 -0
  104. package/dist/lib/capture/modes/visible.d.ts +3 -0
  105. package/dist/lib/capture-toolbar/index.d.ts +25 -0
  106. package/dist/lib/capture-toolbar/lazy-capture-outputs.d.ts +2 -0
  107. package/dist/lib/capture-toolbar/outputs-encode.d.ts +25 -0
  108. package/dist/lib/capture-toolbar/outputs.d.ts +38 -0
  109. package/dist/lib/capture-toolbar/partials/capture-editor.d.ts +11 -0
  110. package/dist/lib/capture-toolbar/partials/capture-outputs.d.ts +16 -0
  111. package/dist/lib/capture-toolbar/region-overlay.d.ts +15 -0
  112. package/dist/lib/capture-toolbar/screen-capture-toolbar.d.ts +31 -0
  113. package/dist/lib/capture-toolbar/types.d.ts +117 -0
  114. package/dist/lib/capture-toolbar/use-screen-capture.d.ts +16 -0
  115. package/dist/lib/components/ui/layout/account-frame/account-frame.d.ts +2 -2
  116. package/dist/lib/components/ui/media/attachment-list/attachment-list.d.ts +2 -2
  117. package/dist/lib/components/ui/media/image-editor/image-markup-editor.d.ts +11 -3
  118. package/dist/lib/components/ui/media/image-editor/types-edits.d.ts +7 -0
  119. package/dist/lib/components/ui/media/image-editor/types-session.d.ts +1 -1
  120. package/dist/lib/components/ui/media/image-editor/types.d.ts +8 -0
  121. package/dist/lib/embed/index.d.ts +6 -1
  122. package/dist/lib/i18n/resources/resources.d.ts +108 -0
  123. package/dist/lib/i18n/translator.d.ts +1 -1
  124. package/dist/lib/image-editor/index.d.ts +1 -1
  125. package/dist/lib.js +38 -56
  126. package/dist/{list-sheet-D22J9I-K.js → list-sheet-CejfrKJr.js} +1 -1
  127. package/dist/{loading-indicator-sDzxZg8f.js → loading-indicator-BBjOF25N.js} +1 -1
  128. package/dist/main.js +103 -98
  129. package/dist/{map-draw-DfbfT0eJ.js → map-draw-DyRy9SSV.js} +2 -2
  130. package/dist/map-draw.js +5 -5
  131. package/dist/map-static.js +1 -1
  132. package/dist/{map-view-DAx2zvV-.js → map-view-YfuYD3zS.js} +9 -9
  133. package/dist/map-zone-events.js +1 -1
  134. package/dist/map-zone-field.js +7 -7
  135. package/dist/map.js +10 -10
  136. package/dist/{marker-button-D7hEvEZD.js → marker-button-CXBaToHp.js} +1 -1
  137. package/dist/{marker-count-image-CWS3G-k8.js → marker-count-image-DHuzSev9.js} +1 -1
  138. package/dist/material.css +1 -1
  139. package/dist/{measure-manual-Bfvu8B_R.js → measure-manual-CcESmV1d.js} +3 -3
  140. package/dist/{measurement-B-OeWv7j.js → measurement-D2or6yM_.js} +1 -1
  141. package/dist/{media-player-DGXmWK7W.js → media-player-qW9RXFuO.js} +451 -567
  142. package/dist/{media-player-viewer-C3vXYcd8.js → media-player-viewer-DozPiF6T.js} +2 -2
  143. package/dist/{media-surface-BySonDjv.js → media-surface-BJsdNynm.js} +6 -6
  144. package/dist/{mention-list-BpoZHwO6.js → mention-list-z1wnlJgs.js} +2 -2
  145. package/dist/{native-select-Dg4bc7aC.js → native-select-BnDOVnER.js} +1 -1
  146. package/dist/{nxgt-theme-Ob-uFqU_.js → nxgt-theme-EYZ5aFHi.js} +6 -15
  147. package/dist/nxgt-theme-provider-BPXd3h82.js +40 -0
  148. package/dist/outputs-DF-aVqUO.js +81 -0
  149. package/dist/passkey.js +1 -1
  150. package/dist/{pdf-form-filler-DgH52W2Q.js → pdf-form-filler-Ct4eexhZ.js} +34 -34
  151. package/dist/pdf-form.js +2 -2
  152. package/dist/{pdf-reader-Bilz5foK.js → pdf-reader-khpMMEjU.js} +16 -16
  153. package/dist/{pdf-reader-viewer-DwQP2IpV.js → pdf-reader-viewer-B3_TdFOn.js} +2 -2
  154. package/dist/pdf-reader.js +2 -2
  155. package/dist/{percent-field-Ldc7K2wC.js → percent-field-Bu-PmCNR.js} +2 -2
  156. package/dist/{picker-surface-DZQbBgvA.js → picker-surface-THexE1OU.js} +3 -3
  157. package/dist/{popover-DwsaHFrK.js → popover-osl5duoA.js} +1 -1
  158. package/dist/portal-container-provider-fZFUk-ZB.js +11 -0
  159. package/dist/{pos-types-CKDG7pZA.js → pos-types-BPPae99i.js} +1 -1
  160. package/dist/{pos-variant-9nhz-ZzW.js → pos-variant-D6bDUqwV.js} +4 -4
  161. package/dist/print.js +1 -1
  162. package/dist/{programmer-variant-BzwfeMGC.js → programmer-variant-CDlFE24o.js} +2 -2
  163. package/dist/{progress-BBfp7sMi.js → progress-DjHnanxA.js} +2 -2
  164. package/dist/{progress-linear-BOJbHnzd.js → progress-linear-CTJ_U6kY.js} +1 -1
  165. package/dist/{public-I8nb8pCC.js → public-u9u2Osmx.js} +6 -6
  166. package/dist/{rendition-stage-A1nHXYrA.js → rendition-stage-BXjQpfKK.js} +2 -2
  167. package/dist/{rich-code-block-BJERY3N3.js → rich-code-block-DWSzyQRw.js} +5 -5
  168. package/dist/{scientific-variant-st2NBm1K.js → scientific-variant-DCgApH87.js} +2 -2
  169. package/dist/{scroll-area-B3XstZU2.js → scroll-area-BxKiT4Dn.js} +155 -164
  170. package/dist/{search-field-D3AOJr7s.js → search-field-Cgqa2bQf.js} +2 -2
  171. package/dist/{select-DhfzCkun.js → select-BGhRlBh4.js} +166 -179
  172. package/dist/{sheet-B8cO1T5K.js → sheet-BvNVroog.js} +1 -1
  173. package/dist/{signature-dialog-BNLMPgao.js → signature-dialog-x--_QWRB.js} +5 -5
  174. package/dist/signature.js +1 -1
  175. package/dist/{site-footer-cta-Cx7zsvkq.js → site-footer-cta-B3Kfqpep.js} +4 -4
  176. package/dist/{site-footer-link-Di8IMIw0.js → site-footer-link-SFHrO4ld.js} +1 -1
  177. package/dist/{size-slot-D1cKqb09.js → size-slot-Cb-W2Zm4.js} +1 -1
  178. package/dist/{sortable-provider-DrLnoygf.js → sortable-provider-KRScvvYx.js} +2 -2
  179. package/dist/{spinner-BpH9tE8R.js → spinner-DpB6XvJJ.js} +1 -1
  180. package/dist/switch-c_6OtXzW.js +125 -0
  181. package/dist/{tabs-root-BUnIfDah.js → tabs-root-C2n3K_Yv.js} +1 -1
  182. package/dist/{tags-form-BwqR4UVj.js → tags-form-BKB9fP03.js} +5 -5
  183. package/dist/{text-field-CFCHo07X.js → text-field-Dl7xTxZe.js} +2 -2
  184. package/dist/{textarea-B_iMDYgM.js → textarea-C3BGZELU.js} +1 -1
  185. package/dist/{textarea-field-DIOGxyUd.js → textarea-field-mqWhhbis.js} +2 -2
  186. package/dist/theme-picker.js +5 -4
  187. package/dist/{theme-toggle-CsBe64lm.js → theme-toggle-K-n5eq0T.js} +3 -3
  188. package/dist/theme-value-CD2nDrj_.js +12 -0
  189. package/dist/themes.js +15 -48
  190. package/dist/{toasts-McZnLRHP.js → toasts-DFLecXh0.js} +5 -5
  191. package/dist/{toggle-group-DKN1XLBS.js → toggle-group-DMDjNJWx.js} +1 -1
  192. package/dist/{toolbar-group-BmzGP_JO.js → toolbar-group-bttMdvg4.js} +1 -1
  193. package/dist/{toolbar-item-slot-BnqQLkVd.js → toolbar-item-slot-CBn3YjeE.js} +1 -1
  194. package/dist/{toolbar-items-C9uasXZ2.js → toolbar-items-zL5TYLf2.js} +4 -4
  195. package/dist/{toolbar-keep-focus-Vc5V-dX2.js → toolbar-keep-focus-C6bnzvpE.js} +2 -2
  196. package/dist/{tracked-layer-CjCXB_O6.js → tracked-layer-CYdLWRK-.js} +4 -4
  197. package/dist/{translate-material-C-qVvGLn.js → translate-material-DZNgWjYu.js} +1 -1
  198. package/dist/{translator-BrzI307E.js → translator-CrIFDzAz.js} +110 -2
  199. package/dist/{tree-DOAs456A.js → tree-CFXDccIe.js} +1 -1
  200. package/dist/{upload-host-ZpSSql8v.js → upload-host-DDktVohu.js} +9 -8
  201. package/dist/{use-calculator-keyboard-Ss25SRoM.js → use-calculator-keyboard-BWkYuIw5.js} +1 -1
  202. package/dist/{use-chat-composer-DopDN-zP.js → use-chat-composer-C1Qlnw2i.js} +20 -20
  203. package/dist/{use-file-meta-DyJX0JVs.js → use-file-meta-DcfQCh52.js} +1 -1
  204. package/dist/{use-heading-spy-CA2IAqMe.js → use-heading-spy-B9xEMHbZ.js} +2 -2
  205. package/dist/use-image-preview-BNq_RQm5.js +20 -0
  206. package/dist/{use-item-entries-CYbS5otl.js → use-item-entries-BKQHcWFx.js} +1 -1
  207. package/dist/{use-material-translation-eYySryw3.js → use-material-translation-ZEUtduro.js} +1 -1
  208. package/dist/{use-media-viewer-DoNdrzhN.js → use-media-viewer-DViJNx75.js} +1 -1
  209. package/dist/{use-text-preview-BQE4U9cT.js → use-text-preview-Ci97JKKo.js} +2 -2
  210. package/dist/{use-unsaved-guard-CSfDvdxd.js → use-unsaved-guard-CWlHEvjN.js} +2 -2
  211. package/dist/{viewer-CXF1dAv0.js → viewer-DDPJOxBt.js} +5 -5
  212. package/dist/{viewer-stage-class-CpyA8o-M.js → viewer-stage-class-DJ1uod4l.js} +4 -4
  213. package/dist/{viewer-states-BXyCdNhE.js → viewer-states-DkaPBkK4.js} +3 -3
  214. package/dist/{virtual-layer-rows-DHy8vAup.js → virtual-layer-rows-DKejQ_Jd.js} +1 -1
  215. package/dist/visible-B-IFZ4Nv.js +475 -0
  216. package/docs/components/media-and-files.md +1 -1
  217. package/docs/components/navigation-and-layout.md +2 -2
  218. package/docs/guides/capture.md +248 -0
  219. package/docs/guides/csp.md +1 -1
  220. package/docs/guides/embed.md +94 -2
  221. package/docs/roadmap.md +2 -1
  222. package/docs/troubleshooting.md +56 -0
  223. package/package.json +18 -1
  224. package/dist/embed-chunks/bubble-input-yXAeW84_.js +0 -29
  225. package/dist/embed-chunks/switch-control-ChcowM3u.js +0 -181
  226. package/dist/fab-dock-DqwbI-5n.js +0 -86
  227. package/dist/input-BaBE_MR_.js +0 -27
  228. /package/dist/{dist-B1qFabLJ.js → dist-B1qFabLJ2.js} +0 -0
@@ -0,0 +1,4423 @@
1
+ import { t as e } from "./utils-BLfntITJ.js";
2
+ import { o as t } from "./dist-DVRQkaTK.js";
3
+ import { a as n, i as r, n as i } from "./dist-BpL4VNX6.js";
4
+ import { t as a } from "./spinner-DpB6XvJJ.js";
5
+ import { n as o } from "./dist-xkPAZeNa.js";
6
+ import { i as s } from "./dist-OpI7-DJp.js";
7
+ import { t as c } from "./dist-Dz8aLbbp.js";
8
+ import { t as l } from "./dist-OcT2kY6L.js";
9
+ import { c as u, d, f, i as p, n as m, o as h, t as g, u as _ } from "./dropdown-menu-D-PRbHaP.js";
10
+ import { t as v } from "./dist-Cb17ixQs.js";
11
+ import { t as y } from "./dist-CyqFzDZ6.js";
12
+ import { t as b } from "./button-RsWgka2v.js";
13
+ import { t as x } from "./use-material-translation-ZEUtduro.js";
14
+ import { t as S } from "./icon-button-D-gi4Plg.js";
15
+ import { t as ee } from "./typography-CtD9SJHo.js";
16
+ import { t as te } from "./browser-only-DQ94lWF8.js";
17
+ import { t as C } from "./useLatest-C2PnQEeD.js";
18
+ import { t as ne } from "./separator-CAwh2D9n.js";
19
+ import { n as w } from "./use-slice-reducer-BGkeGtML.js";
20
+ import { t as T } from "./switch-c_6OtXzW.js";
21
+ import { l as re, n as ie, o as ae, r as oe, t as se } from "./dialog-DwUxG2-o.js";
22
+ import { t as E } from "./use-image-preview-BNq_RQm5.js";
23
+ import { n as ce, t as le } from "./toggle-group-DMDjNJWx.js";
24
+ import * as D from "react";
25
+ import { Fragment as ue, createContext as de, useCallback as O, useContext as fe, useEffect as k, useId as A, useLayoutEffect as pe, useMemo as j, useRef as M, useState as N } from "react";
26
+ import { Fragment as P, jsx as F, jsxs as I } from "react/jsx-runtime";
27
+ import { ArrowUpRight as me, BringToFront as he, Check as ge, ChevronsLeftRight as _e, Circle as ve, Columns2 as ye, Copy as be, Crop as xe, Download as Se, Eraser as Ce, Eye as we, FlipHorizontal2 as Te, FlipVertical2 as Ee, Highlighter as De, ImageOff as Oe, Keyboard as ke, MousePointer2 as Ae, Pen as je, PencilLine as Me, Pin as Ne, Plus as Pe, Redo2 as Fe, RotateCcw as Ie, RotateCw as Le, Settings2 as Re, Slash as ze, SlidersHorizontal as Be, Sparkles as Ve, Square as He, SquareAsterisk as Ue, Trash2 as We, Type as Ge, Undo2 as Ke, WandSparkles as qe, X as Je, ZoomIn as Ye, ZoomOut as Xe } from "lucide-react";
28
+ import { createSlice as Ze, current as Qe, isDraft as $e } from "@reduxjs/toolkit";
29
+ import { tickValues as et } from "@softistx/material-core/slider-ticks";
30
+ //#region ../../node_modules/@radix-ui/react-slider/dist/index.mjs
31
+ var tt = Object.defineProperty, L = (e, t) => tt(e, "name", {
32
+ value: t,
33
+ configurable: !0
34
+ }), nt = ["PageUp", "PageDown"], rt = [
35
+ "ArrowUp",
36
+ "ArrowDown",
37
+ "ArrowLeft",
38
+ "ArrowRight"
39
+ ], it = {
40
+ "from-left": [
41
+ "Home",
42
+ "PageDown",
43
+ "ArrowDown",
44
+ "ArrowLeft"
45
+ ],
46
+ "from-right": [
47
+ "Home",
48
+ "PageDown",
49
+ "ArrowDown",
50
+ "ArrowRight"
51
+ ],
52
+ "from-bottom": [
53
+ "Home",
54
+ "PageDown",
55
+ "ArrowDown",
56
+ "ArrowLeft"
57
+ ],
58
+ "from-top": [
59
+ "Home",
60
+ "PageDown",
61
+ "ArrowUp",
62
+ "ArrowLeft"
63
+ ]
64
+ }, at = "Slider", [ot, st, ct] = s(at), [lt, ut] = o(at, [ct]), [dt, R] = lt(at), ft = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, n) {
65
+ let { name: a, min: o = 0, max: s = 100, step: c = 1, orientation: l = "horizontal", disabled: u = !1, minStepsBetweenThumbs: d = 0, defaultValue: f = [o], value: p, onValueChange: m = /* @__PURE__ */ L(() => {}, "onValueChange"), onValueCommit: h = /* @__PURE__ */ L(() => {}, "onValueCommit"), inverted: g = !1, form: _, ...v } = e, b = D.useRef(/* @__PURE__ */ new Set()), x = D.useRef(0), S = D.useRef(!1), ee = l === "horizontal" ? ht : gt, [te, C] = D.useState(null), ne = t(n, C), [w = [], T] = i({
66
+ prop: p,
67
+ defaultProp: f,
68
+ onChange: /* @__PURE__ */ L((e) => {
69
+ [...b.current][x.current]?.focus({
70
+ preventScroll: !0,
71
+ focusVisible: S.current
72
+ }), S.current = !1, m(e);
73
+ }, "onChange")
74
+ }), re = D.useRef(w), ie = D.useRef(w);
75
+ D.useEffect(() => {
76
+ let e = _ ? te?.ownerDocument.getElementById(_) : te?.closest("form");
77
+ if (e instanceof HTMLFormElement) {
78
+ let t = /* @__PURE__ */ L(() => T(ie.current), "reset");
79
+ return e.addEventListener("reset", t), () => e.removeEventListener("reset", t);
80
+ }
81
+ }, [
82
+ te,
83
+ _,
84
+ T
85
+ ]);
86
+ function ae(e) {
87
+ E(e, Pt(w, e));
88
+ }
89
+ L(ae, "handleSlideStart");
90
+ function oe(e) {
91
+ E(e, x.current);
92
+ }
93
+ L(oe, "handleSlideMove");
94
+ function se() {
95
+ String(w) !== String(re.current) && h(w);
96
+ }
97
+ L(se, "handleSlideEnd");
98
+ function E(e, t, { commit: n } = { commit: !1 }) {
99
+ let r = zt(c), i = y(Bt(Math.round((e - o) / c) * c + o, r), [o, s]);
100
+ T((e = []) => {
101
+ let r = jt(e, i, t);
102
+ if (Lt(r, d * c)) {
103
+ x.current = r.indexOf(i);
104
+ let t = String(r) !== String(e);
105
+ return t && n && h(r), t ? r : e;
106
+ } else return e;
107
+ });
108
+ }
109
+ return L(E, "updateValues"), /* @__PURE__ */ F(dt, {
110
+ scope: e.__scopeSlider,
111
+ name: a,
112
+ disabled: u,
113
+ min: o,
114
+ max: s,
115
+ valueIndexToChangeRef: x,
116
+ thumbs: b.current,
117
+ values: w,
118
+ orientation: l,
119
+ form: _,
120
+ children: /* @__PURE__ */ F(ot.Provider, {
121
+ scope: e.__scopeSlider,
122
+ children: /* @__PURE__ */ F(ot.Slot, {
123
+ scope: e.__scopeSlider,
124
+ children: /* @__PURE__ */ F(ee, {
125
+ "aria-disabled": u,
126
+ "data-disabled": u ? "" : void 0,
127
+ ...v,
128
+ ref: ne,
129
+ onPointerDown: r(v.onPointerDown, () => {
130
+ u || (re.current = w, S.current = !1);
131
+ }),
132
+ min: o,
133
+ max: s,
134
+ inverted: g,
135
+ onSlideStart: u ? void 0 : ae,
136
+ onSlideMove: u ? void 0 : oe,
137
+ onSlideEnd: u ? void 0 : se,
138
+ onHomeKeyDown: () => {
139
+ u || (S.current = !0, E(o, 0, { commit: !0 }));
140
+ },
141
+ onEndKeyDown: () => {
142
+ u || (S.current = !0, E(s, w.length - 1, { commit: !0 }));
143
+ },
144
+ onStepKeyDown: ({ event: e, direction: t }) => {
145
+ if (!u) {
146
+ S.current = !0;
147
+ let n = nt.includes(e.key) || e.shiftKey && rt.includes(e.key) ? 10 : 1, r = x.current, i = w[r];
148
+ E(Vt(i, {
149
+ min: o,
150
+ step: c,
151
+ direction: t,
152
+ multiplier: n
153
+ }), r, { commit: !0 });
154
+ }
155
+ }
156
+ })
157
+ })
158
+ })
159
+ });
160
+ }, "Slider")), [pt, mt] = lt(at, {
161
+ startEdge: "left",
162
+ endEdge: "right",
163
+ size: "width",
164
+ direction: 1
165
+ }), ht = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, n) {
166
+ let { min: r, max: i, dir: a, inverted: o, onSlideStart: s, onSlideMove: l, onSlideEnd: u, onStepKeyDown: d, ...f } = e, [p, m] = D.useState(null), h = t(n, m), g = D.useRef(void 0), _ = c(a), v = _ === "ltr", y = v && !o || !v && o;
167
+ function b(e) {
168
+ let t = g.current || p.getBoundingClientRect(), n = Rt([0, t.width], y ? [r, i] : [i, r]);
169
+ return g.current = t, n(e - t.left);
170
+ }
171
+ return L(b, "getValueFromPointer"), /* @__PURE__ */ F(pt, {
172
+ scope: e.__scopeSlider,
173
+ startEdge: y ? "left" : "right",
174
+ endEdge: y ? "right" : "left",
175
+ direction: y ? 1 : -1,
176
+ size: "width",
177
+ children: /* @__PURE__ */ F(_t, {
178
+ dir: _,
179
+ "data-orientation": "horizontal",
180
+ ...f,
181
+ ref: h,
182
+ style: {
183
+ ...f.style,
184
+ "--radix-slider-thumb-transform": "translateX(-50%)"
185
+ },
186
+ onSlideStart: (e) => {
187
+ let t = b(e.clientX);
188
+ s?.(t);
189
+ },
190
+ onSlideMove: (e) => {
191
+ let t = b(e.clientX);
192
+ l?.(t);
193
+ },
194
+ onSlideEnd: () => {
195
+ g.current = void 0, u?.();
196
+ },
197
+ onStepKeyDown: (e) => {
198
+ let t = it[y ? "from-left" : "from-right"].includes(e.key);
199
+ d?.({
200
+ event: e,
201
+ direction: t ? -1 : 1
202
+ });
203
+ }
204
+ })
205
+ });
206
+ }, "SliderHorizontal")), gt = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, n) {
207
+ let { min: r, max: i, inverted: a, onSlideStart: o, onSlideMove: s, onSlideEnd: c, onStepKeyDown: l, ...u } = e, d = D.useRef(null), f = t(n, d), p = D.useRef(void 0), m = !a;
208
+ function h(e) {
209
+ let t = p.current || d.current.getBoundingClientRect(), n = Rt([0, t.height], m ? [i, r] : [r, i]);
210
+ return p.current = t, n(e - t.top);
211
+ }
212
+ return L(h, "getValueFromPointer"), /* @__PURE__ */ F(pt, {
213
+ scope: e.__scopeSlider,
214
+ startEdge: m ? "bottom" : "top",
215
+ endEdge: m ? "top" : "bottom",
216
+ size: "height",
217
+ direction: m ? 1 : -1,
218
+ children: /* @__PURE__ */ F(_t, {
219
+ "data-orientation": "vertical",
220
+ ...u,
221
+ ref: f,
222
+ style: {
223
+ ...u.style,
224
+ "--radix-slider-thumb-transform": "translateY(50%)"
225
+ },
226
+ onSlideStart: (e) => {
227
+ let t = h(e.clientY);
228
+ o?.(t);
229
+ },
230
+ onSlideMove: (e) => {
231
+ let t = h(e.clientY);
232
+ s?.(t);
233
+ },
234
+ onSlideEnd: () => {
235
+ p.current = void 0, c?.();
236
+ },
237
+ onStepKeyDown: (e) => {
238
+ let t = it[m ? "from-bottom" : "from-top"].includes(e.key);
239
+ l?.({
240
+ event: e,
241
+ direction: t ? -1 : 1
242
+ });
243
+ }
244
+ })
245
+ });
246
+ }, "SliderVertical")), _t = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, t) {
247
+ let { __scopeSlider: i, onSlideStart: a, onSlideMove: o, onSlideEnd: s, onHomeKeyDown: c, onEndKeyDown: l, onStepKeyDown: u, ...d } = e, f = R(at, i);
248
+ return /* @__PURE__ */ F(n.span, {
249
+ ...d,
250
+ ref: t,
251
+ onKeyDown: r(e.onKeyDown, (e) => {
252
+ e.key === "Home" ? (c(e), e.preventDefault()) : e.key === "End" ? (l(e), e.preventDefault()) : nt.concat(rt).includes(e.key) && (u(e), e.preventDefault());
253
+ }),
254
+ onPointerDown: r(e.onPointerDown, (e) => {
255
+ let t = e.target;
256
+ t.setPointerCapture(e.pointerId), e.preventDefault(), f.thumbs.has(t) ? t.focus({
257
+ preventScroll: !0,
258
+ focusVisible: !1
259
+ }) : a(e);
260
+ }),
261
+ onPointerMove: r(e.onPointerMove, (e) => {
262
+ e.target.hasPointerCapture(e.pointerId) && o(e);
263
+ }),
264
+ onPointerUp: r(e.onPointerUp, (e) => {
265
+ let t = e.target;
266
+ t.hasPointerCapture(e.pointerId) && (t.releasePointerCapture(e.pointerId), s(e));
267
+ })
268
+ });
269
+ }, "SliderImpl")), vt = "SliderTrack", yt = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, t) {
270
+ let { __scopeSlider: r, ...i } = e, a = R(vt, r);
271
+ return /* @__PURE__ */ F(n.span, {
272
+ "data-disabled": a.disabled ? "" : void 0,
273
+ "data-orientation": a.orientation,
274
+ ...i,
275
+ ref: t
276
+ });
277
+ }, "SliderTrack")), bt = "SliderRange", xt = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, r) {
278
+ let { __scopeSlider: i, ...a } = e, o = R(bt, i), s = mt(bt, i), c = t(r, D.useRef(null)), l = o.values.length, u = o.values.map((e) => Mt(e, o.min, o.max)), d = l > 1 ? Math.min(...u) : 0, f = 100 - Math.max(...u);
279
+ return /* @__PURE__ */ F(n.span, {
280
+ "data-orientation": o.orientation,
281
+ "data-disabled": o.disabled ? "" : void 0,
282
+ ...a,
283
+ ref: c,
284
+ style: {
285
+ ...e.style,
286
+ [s.startEdge]: d + "%",
287
+ [s.endEdge]: f + "%"
288
+ }
289
+ });
290
+ }, "SliderRange")), [St, Ct] = lt("SliderThumb"), wt = "SliderThumbProvider";
291
+ function Tt(e) {
292
+ let { __scopeSlider: t, name: n, children: r, internal_do_not_use_render: i } = e, a = R(wt, t), o = st(t), [s, c] = D.useState(null), u = D.useMemo(() => s ? o().findIndex((e) => e.ref.current === s) : -1, [o, s]), d = l(s), f = !s || !!a.form || !!s.closest("form"), p = a.values[u], m = n ?? (a.name ? a.name + (a.values.length > 1 ? "[]" : "") : void 0), h = p === void 0 ? 0 : Mt(p, a.min, a.max);
293
+ D.useEffect(() => {
294
+ if (s) return a.thumbs.add(s), () => {
295
+ a.thumbs.delete(s);
296
+ };
297
+ }, [s, a.thumbs]);
298
+ let g = {
299
+ value: p,
300
+ name: m,
301
+ form: a.form,
302
+ isFormControl: f,
303
+ index: u,
304
+ thumb: s,
305
+ onThumbChange: c,
306
+ percent: h,
307
+ size: d
308
+ };
309
+ return /* @__PURE__ */ F(St, {
310
+ scope: t,
311
+ ...g,
312
+ children: Ht(i) ? i(g) : r
313
+ });
314
+ }
315
+ L(Tt, "SliderThumbProvider");
316
+ var Et = "SliderThumbTrigger", Dt = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, i) {
317
+ let { __scopeSlider: a, ...o } = e, s = R(Et, a), c = mt(Et, a), { index: l, value: u, percent: d, size: f, onThumbChange: p } = Ct(Et, a), m = t(i, p), h = Nt(l, s.values.length), g = f?.[c.size], _ = g ? Ft(g, d, c.direction) : 0;
318
+ return /* @__PURE__ */ F("span", {
319
+ style: {
320
+ transform: "var(--radix-slider-thumb-transform)",
321
+ position: "absolute",
322
+ [c.startEdge]: `calc(${d}% + ${_}px)`
323
+ },
324
+ children: /* @__PURE__ */ F(ot.ItemSlot, {
325
+ scope: a,
326
+ children: /* @__PURE__ */ F(n.span, {
327
+ role: "slider",
328
+ "aria-label": e["aria-label"] || h,
329
+ "aria-valuemin": s.min,
330
+ "aria-valuenow": u,
331
+ "aria-valuemax": s.max,
332
+ "aria-orientation": s.orientation,
333
+ "data-orientation": s.orientation,
334
+ "data-disabled": s.disabled ? "" : void 0,
335
+ tabIndex: s.disabled ? void 0 : 0,
336
+ ...o,
337
+ ref: m,
338
+ style: u === void 0 ? { display: "none" } : e.style,
339
+ onFocus: r(e.onFocus, () => {
340
+ s.valueIndexToChangeRef.current = l;
341
+ })
342
+ })
343
+ })
344
+ });
345
+ }, "SliderThumbTrigger")), Ot = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function(e, t) {
346
+ let { __scopeSlider: n, name: r, ...i } = e;
347
+ return /* @__PURE__ */ F(Tt, {
348
+ __scopeSlider: n,
349
+ name: r,
350
+ internal_do_not_use_render: ({ index: e, isFormControl: r }) => /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(Dt, {
351
+ ...i,
352
+ ref: t,
353
+ __scopeSlider: n
354
+ }), r ? /* @__PURE__ */ F(At, { __scopeSlider: n }, e) : null] })
355
+ });
356
+ }, "SliderThumb")), kt = "SliderBubbleInput", At = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ L(function({ __scopeSlider: e, ...r }, i) {
357
+ let { value: a, name: o, form: s } = Ct(kt, e), c = D.useRef(null), l = t(c, i), u = v(a);
358
+ return D.useEffect(() => {
359
+ let e = c.current;
360
+ if (!e) return;
361
+ let t = window.HTMLInputElement.prototype, n = Object.getOwnPropertyDescriptor(t, "value").set;
362
+ if (u !== a && n) {
363
+ let t = new Event("input", { bubbles: !0 });
364
+ n.call(e, a), e.dispatchEvent(t);
365
+ }
366
+ }, [u, a]), /* @__PURE__ */ F(n.input, {
367
+ style: { display: "none" },
368
+ name: o,
369
+ form: s,
370
+ ...r,
371
+ ref: l,
372
+ defaultValue: a
373
+ });
374
+ }, "SliderBubbleInput"));
375
+ function jt(e = [], t, n) {
376
+ let r = [...e];
377
+ return r[n] = t, r.sort((e, t) => e - t);
378
+ }
379
+ L(jt, "getNextSortedValues");
380
+ function Mt(e, t, n) {
381
+ return y(100 / (n - t) * (e - t), [0, 100]);
382
+ }
383
+ L(Mt, "convertValueToPercentage");
384
+ function Nt(e, t) {
385
+ if (t > 2) return `Value ${e + 1} of ${t}`;
386
+ if (t === 2) return ["Minimum", "Maximum"][e];
387
+ }
388
+ L(Nt, "getLabel");
389
+ function Pt(e, t) {
390
+ if (e.length === 1) return 0;
391
+ let n = e.map((e) => Math.abs(e - t)), r = Math.min(...n);
392
+ return n.indexOf(r);
393
+ }
394
+ L(Pt, "getClosestValueIndex");
395
+ function Ft(e, t, n) {
396
+ let r = e / 2;
397
+ return (r - Rt([0, 50], [0, r])(t) * n) * n;
398
+ }
399
+ L(Ft, "getThumbInBoundsOffset");
400
+ function It(e) {
401
+ return e.slice(0, -1).map((t, n) => e[n + 1] - t);
402
+ }
403
+ L(It, "getStepsBetweenValues");
404
+ function Lt(e, t) {
405
+ if (t > 0) {
406
+ let n = It(e);
407
+ return Math.min(...n) >= t;
408
+ }
409
+ return !0;
410
+ }
411
+ L(Lt, "hasMinStepsBetweenValues");
412
+ function Rt(e, t) {
413
+ return (n) => {
414
+ if (e[0] === e[1] || t[0] === t[1]) return t[0];
415
+ let r = (t[1] - t[0]) / (e[1] - e[0]);
416
+ return t[0] + r * (n - e[0]);
417
+ };
418
+ }
419
+ L(Rt, "linearScale");
420
+ function zt(e) {
421
+ if (!Number.isFinite(e)) return 0;
422
+ let t = e.toString();
423
+ if (t.includes("e")) {
424
+ let [e, n] = t.split("e"), r = e.split(".")[1] || "", i = Number(n);
425
+ return Math.max(0, r.length - i);
426
+ }
427
+ let n = t.split(".")[1];
428
+ return n ? n.length : 0;
429
+ }
430
+ L(zt, "getDecimalCount");
431
+ function Bt(e, t) {
432
+ let n = 10 ** t;
433
+ return Math.round(e * n) / n;
434
+ }
435
+ L(Bt, "roundValue");
436
+ function Vt(e, { min: t, step: n, direction: r, multiplier: i }) {
437
+ let a = zt(n), o = (e - t) / n, s = Math.round(o), c = Bt(s * n + t, a) === Bt(e, a), l;
438
+ return l = c ? s + i * r : r > 0 ? Math.ceil(o) : Math.floor(o), Bt(l * n + t, a);
439
+ }
440
+ L(Vt, "getNextStepValue");
441
+ function Ht(e) {
442
+ return typeof e == "function";
443
+ }
444
+ L(Ht, "isFunction");
445
+ //#endregion
446
+ //#region ../../node_modules/react-use/esm/useFirstMountState.js
447
+ function Ut() {
448
+ var e = M(!0);
449
+ return e.current ? (e.current = !1, !0) : e.current;
450
+ }
451
+ //#endregion
452
+ //#region ../../node_modules/react-use/esm/useUpdateEffect.js
453
+ var Wt = function(e, t) {
454
+ var n = Ut();
455
+ k(function() {
456
+ if (!n) return e();
457
+ }, t);
458
+ };
459
+ //#endregion
460
+ //#region lib/components/ui/fields/slider/slider-math.ts
461
+ function Gt(e, t, n) {
462
+ let r = n - t || 1;
463
+ return Math.min(100, Math.max(0, (e - t) / r * 100));
464
+ }
465
+ function Kt(e, t) {
466
+ return Array.isArray(e) ? e : [t];
467
+ }
468
+ function qt({ thumbs: e, min: t, origin: n, vertical: r }) {
469
+ let i = e[0] ?? t, a = e[e.length - 1] ?? t, o = n !== void 0 && e.length === 1 && !r, [s, c] = o ? [Math.min(n, i), Math.max(n, i)] : [e.length > 1 ? i : t, a];
470
+ return {
471
+ fromOrigin: o,
472
+ from: s,
473
+ to: c
474
+ };
475
+ }
476
+ function Jt(e, t) {
477
+ return t ? 100 - e : e;
478
+ }
479
+ //#endregion
480
+ //#region lib/components/ui/fields/slider/slider-thumb.tsx
481
+ function Yt({ index: e, bubble: t, ...n }) {
482
+ return /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(Ot, {
483
+ "data-slot": "slider-thumb",
484
+ "data-index": e,
485
+ "data-nxgt-state-layer": "",
486
+ ...n
487
+ }), t && /* @__PURE__ */ F("span", {
488
+ "aria-hidden": "true",
489
+ "data-slot": "slider-bubble",
490
+ ref: (e) => e?.style.setProperty("--nxgt-sl-at", String(t.at)),
491
+ children: t.text
492
+ })] });
493
+ }
494
+ //#endregion
495
+ //#region lib/components/ui/fields/slider/slider-thumbs.tsx
496
+ var Xt = "block shrink-0 cursor-pointer forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-[Highlight]";
497
+ function Zt({ thumbs: e, min: t, max: n, inverted: r, shown: i, valueBubble: a, formatValue: o, thumbId: s, nameIds: c, name: l, required: u, invalid: d, describedBy: f }) {
498
+ return e.map((p, m) => /* @__PURE__ */ F(Yt, {
499
+ index: m,
500
+ bubble: a && i === m ? {
501
+ at: Jt(Gt(p, t, n), r),
502
+ text: o(p)
503
+ } : null,
504
+ id: `${s}-${m}`,
505
+ "aria-labelledby": c && e.length > 1 ? `${c} ${s}-${m}` : c,
506
+ "aria-required": u || void 0,
507
+ "aria-invalid": d || void 0,
508
+ "aria-describedby": f,
509
+ "data-pw": l ? `${l}-thumb-${m}` : "slider-thumb",
510
+ className: Xt
511
+ }, `item-${m.toString()}`));
512
+ }
513
+ //#endregion
514
+ //#region lib/components/ui/fields/slider/slider-icon.tsx
515
+ function Qt({ children: e }) {
516
+ return /* @__PURE__ */ F("span", {
517
+ "data-slot": "slider-icon-area",
518
+ "aria-hidden": "true",
519
+ children: /* @__PURE__ */ F("span", {
520
+ "data-slot": "slider-icon",
521
+ children: e
522
+ })
523
+ });
524
+ }
525
+ //#endregion
526
+ //#region lib/components/ui/fields/slider/slider-origin-range.tsx
527
+ function $t({ from: e, to: t }) {
528
+ return /* @__PURE__ */ F(te, {
529
+ reason: "The origin range is placed by an inline style",
530
+ children: /* @__PURE__ */ F("span", {
531
+ "data-slot": "slider-range",
532
+ "data-origin": "",
533
+ className: "absolute",
534
+ style: {
535
+ "--nxgt-sl-from": e,
536
+ "--nxgt-sl-to": t
537
+ }
538
+ })
539
+ });
540
+ }
541
+ //#endregion
542
+ //#region lib/components/ui/fields/slider/slider-stops.tsx
543
+ function en({ marks: e, isOn: t }) {
544
+ return /* @__PURE__ */ F("span", {
545
+ "data-slot": "slider-stops",
546
+ "aria-hidden": "true",
547
+ children: e.map((e, n) => /* @__PURE__ */ F("span", {
548
+ "data-slot": "slider-stop",
549
+ "data-on": t(e) || void 0
550
+ }, `${e}-${n.toString()}`))
551
+ });
552
+ }
553
+ //#endregion
554
+ //#region lib/components/ui/fields/slider/slider-track.tsx
555
+ function tn({ className: t, min: n, max: r, fill: i, marks: a, icon: o }) {
556
+ let { fromOrigin: s, from: c, to: l } = i;
557
+ return /* @__PURE__ */ I(yt, {
558
+ "data-slot": "slider-track",
559
+ className: e("relative grow cursor-pointer", t),
560
+ children: [
561
+ /* @__PURE__ */ F(xt, {
562
+ "data-slot": "slider-range",
563
+ className: e("absolute", s && "hidden")
564
+ }),
565
+ s && /* @__PURE__ */ F($t, {
566
+ from: Gt(c, n, r),
567
+ to: Gt(l, n, r)
568
+ }),
569
+ o != null && /* @__PURE__ */ F(Qt, { children: o }),
570
+ a.length > 0 && /* @__PURE__ */ F(en, {
571
+ marks: a,
572
+ isOn: (e) => e >= c && e <= l
573
+ })
574
+ ]
575
+ });
576
+ }
577
+ //#endregion
578
+ //#region lib/components/ui/fields/slider/slider-thumb-names.ts
579
+ function nn({ thumbId: e, labelId: t, ariaLabel: n, ariaLabelledBy: r, hiddenLabel: i }) {
580
+ let a = r ? void 0 : n || i, o = a ? `${e}-name` : void 0;
581
+ return {
582
+ nameIds: r || o || t,
583
+ nameText: a,
584
+ nameTextId: o
585
+ };
586
+ }
587
+ //#endregion
588
+ //#region lib/components/ui/fields/slider/split-slider-props.ts
589
+ function rn({ defaultValue: e, value: t, min: n = 0, max: r = 100, step: i, ticks: a = !1, required: o, labelId: s, hiddenLabel: c, origin: l, trackClassName: u, formatValue: d = String, valueBubble: f = !0, size: p = "default", icon: m, inverted: h = !1, onValueChange: g, className: _, "aria-label": v, "aria-labelledby": y, "aria-invalid": b, "aria-describedby": x, onPointerDown: S, onFocus: ee, onBlur: te, ...C }) {
590
+ return {
591
+ own: {
592
+ defaultValue: e,
593
+ value: t,
594
+ min: n,
595
+ max: r,
596
+ step: i,
597
+ ticks: a,
598
+ required: o,
599
+ labelId: s,
600
+ hiddenLabel: c,
601
+ origin: l,
602
+ trackClassName: u,
603
+ formatValue: d,
604
+ valueBubble: f,
605
+ size: p,
606
+ icon: m,
607
+ inverted: h,
608
+ onValueChange: g,
609
+ className: _
610
+ },
611
+ aria: {
612
+ label: v,
613
+ labelledBy: y,
614
+ invalid: b,
615
+ describedBy: x
616
+ },
617
+ handlers: {
618
+ onPointerDown: S,
619
+ onFocus: ee,
620
+ onBlur: te
621
+ },
622
+ rest: C
623
+ };
624
+ }
625
+ //#endregion
626
+ //#region lib/components/ui/fields/slider/use-slider-chrome.ts
627
+ function an({ percents: e, disabled: t, handlers: n }) {
628
+ let r = M(null), [i, a] = N(!1), [o, s] = N(null), c = e.join(",");
629
+ pe(() => {
630
+ let e = r.current;
631
+ if (!e) return;
632
+ let t = c.split(",").map(Number), n = (t, n) => n === void 0 ? e.style.removeProperty(t) : e.style.setProperty(t, String(n));
633
+ n("--nxgt-sl-lo", t.length > 1 ? t[0] : void 0), n("--nxgt-sl-hi", t[t.length - 1]), e.dataset.measured = "";
634
+ }, [c]), k(() => {
635
+ if (!i) return;
636
+ let e = () => a(!1);
637
+ return window.addEventListener("pointerup", e), window.addEventListener("pointercancel", e), () => {
638
+ window.removeEventListener("pointerup", e), window.removeEventListener("pointercancel", e);
639
+ };
640
+ }, [i]);
641
+ let l = {
642
+ onPointerDown: (e) => {
643
+ n.onPointerDown?.(e), !t && e.button === 0 && a(!0);
644
+ },
645
+ onFocus: (e) => {
646
+ n.onFocus?.(e);
647
+ let t = e.target, r = Number(t.dataset.index);
648
+ t.dataset.slot !== "slider-thumb" || Number.isNaN(r) || s({
649
+ index: r,
650
+ visible: t.matches(":focus-visible")
651
+ });
652
+ },
653
+ onBlur: (e) => {
654
+ n.onBlur?.(e), s(null);
655
+ }
656
+ }, u = i || o?.visible ? o?.index ?? null : null;
657
+ return {
658
+ wrap: r,
659
+ rootProps: l,
660
+ pressed: i,
661
+ shown: t ? null : u
662
+ };
663
+ }
664
+ //#endregion
665
+ //#region lib/components/ui/fields/slider/use-slider-model.ts
666
+ function on({ defaultValue: e, value: t, min: n, max: r, step: i, ticks: a, origin: o, vertical: s, disabled: c, handlers: l, onValueChange: u }) {
667
+ let [d, f] = N(() => Kt(e, n)), p = Array.isArray(t) ? t : d;
668
+ return {
669
+ thumbs: p,
670
+ chrome: an({
671
+ percents: p.map((e) => Gt(e, n, r)),
672
+ disabled: c,
673
+ handlers: l
674
+ }),
675
+ marks: et(n, r, a, i),
676
+ fill: qt({
677
+ thumbs: p,
678
+ min: n,
679
+ origin: o,
680
+ vertical: s
681
+ }),
682
+ change: (e) => {
683
+ f(e), u?.(e);
684
+ }
685
+ };
686
+ }
687
+ //#endregion
688
+ //#region lib/components/ui/fields/slider/use-slider-control.ts
689
+ function sn(e) {
690
+ let { own: t, aria: n, handlers: r, rest: i } = rn(e), { min: a, max: o, inverted: s } = t, c = A(), l = nn({
691
+ thumbId: c,
692
+ labelId: t.labelId,
693
+ ariaLabel: n.label,
694
+ ariaLabelledBy: n.labelledBy,
695
+ hiddenLabel: t.hiddenLabel
696
+ }), u = on({
697
+ ...t,
698
+ step: typeof t.step == "number" ? t.step : void 0,
699
+ vertical: i.orientation === "vertical",
700
+ disabled: i.disabled,
701
+ handlers: r
702
+ }), { chrome: d } = u;
703
+ return {
704
+ wrap: d.wrap,
705
+ nameText: l.nameText,
706
+ nameTextId: l.nameTextId,
707
+ rootProps: {
708
+ "data-pressed": d.pressed || void 0,
709
+ "data-size": t.size === "large" ? "large" : void 0,
710
+ "data-inverted": s || void 0,
711
+ "data-pw": i.name ?? "slider",
712
+ defaultValue: t.defaultValue,
713
+ value: t.value,
714
+ inverted: s,
715
+ onValueChange: u.change,
716
+ min: a,
717
+ max: o,
718
+ step: t.step,
719
+ className: t.className,
720
+ ...i,
721
+ ...d.rootProps
722
+ },
723
+ trackProps: {
724
+ className: t.trackClassName,
725
+ min: a,
726
+ max: o,
727
+ fill: u.fill,
728
+ marks: u.marks,
729
+ icon: t.size === "large" && i.orientation !== "vertical" && !u.fill.fromOrigin && u.thumbs.length === 1 ? t.icon : void 0
730
+ },
731
+ thumbsProps: {
732
+ thumbs: u.thumbs,
733
+ min: a,
734
+ max: o,
735
+ inverted: s,
736
+ shown: d.shown,
737
+ valueBubble: t.valueBubble,
738
+ formatValue: t.formatValue,
739
+ thumbId: c,
740
+ nameIds: l.nameIds,
741
+ name: i.name,
742
+ required: t.required,
743
+ invalid: n.invalid,
744
+ describedBy: n.describedBy
745
+ }
746
+ };
747
+ }
748
+ //#endregion
749
+ //#region lib/components/ui/fields/slider/slider-control.tsx
750
+ var cn = "relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col";
751
+ function ln(t) {
752
+ let { wrap: n, nameText: r, nameTextId: i, rootProps: a, trackProps: o, thumbsProps: s } = sn(t), { className: c, ...l } = a;
753
+ return /* @__PURE__ */ I("div", {
754
+ ref: n,
755
+ className: "grid w-full gap-1",
756
+ "data-slot": "slider-wrap",
757
+ children: [/* @__PURE__ */ I(ft, {
758
+ "data-slot": "slider",
759
+ className: e(cn, c),
760
+ ...l,
761
+ children: [/* @__PURE__ */ F(tn, { ...o }), /* @__PURE__ */ F(Zt, { ...s })]
762
+ }), r && /* @__PURE__ */ F("span", {
763
+ id: i,
764
+ hidden: !0,
765
+ children: r
766
+ })]
767
+ });
768
+ }
769
+ //#endregion
770
+ //#region lib/components/ui/selection/color-swatches/color-swatches.utils.ts
771
+ function un(e) {
772
+ let t = e.trim().replace("#", ""), n = t.length === 3 ? t.replace(/./g, (e) => e + e) : t;
773
+ if (!/^[0-9a-f]{6}/i.test(n)) return !1;
774
+ let r = Number.parseInt(n.slice(0, 6), 16), i = r >> 16 & 255, a = r >> 8 & 255, o = r & 255;
775
+ return .299 * i + .587 * a + .114 * o > 160;
776
+ }
777
+ function dn(e) {
778
+ return e.label ?? e.value;
779
+ }
780
+ function fn(e, t) {
781
+ return !!(e && t && e.toLowerCase() === t.toLowerCase());
782
+ }
783
+ function pn(e) {
784
+ return e && /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000";
785
+ }
786
+ //#endregion
787
+ //#region lib/components/ui/media/compare-slider/partials/compare-slider-handle.tsx
788
+ function mn({ current: e, onKeyDown: t }) {
789
+ let { t: n } = x();
790
+ return /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F("div", {
791
+ "aria-hidden": "true",
792
+ className: "pointer-events-none absolute inset-y-0 left-(--compare-at) w-0.5 -translate-x-1/2 bg-white shadow-[0_0_0_1px_rgb(0_0_0/0.25),0_0_12px_rgb(0_0_0/0.35)]"
793
+ }), /* @__PURE__ */ F("div", {
794
+ role: "slider",
795
+ tabIndex: 0,
796
+ "aria-label": n("material.compare-slider.label", "Before and after"),
797
+ "aria-valuemin": 0,
798
+ "aria-valuemax": 100,
799
+ "aria-valuenow": Math.round(e),
800
+ "aria-valuetext": `${Math.round(e)}%`,
801
+ "aria-orientation": "horizontal",
802
+ "data-slot": "compare-slider-handle",
803
+ onKeyDown: t,
804
+ className: "absolute top-1/2 left-(--compare-at) flex size-10 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize items-center justify-center rounded-full border border-white/70 bg-white/85 text-black shadow-lg outline-none backdrop-blur-md transition-transform hover:scale-110 focus-visible:ring-[3px] focus-visible:ring-ring/70 motion-reduce:transition-none",
805
+ children: /* @__PURE__ */ F(_e, {
806
+ className: "size-5",
807
+ "aria-hidden": "true"
808
+ })
809
+ })] });
810
+ }
811
+ //#endregion
812
+ //#region lib/components/ui/media/compare-slider/compare-slider.utils.ts
813
+ function z(e) {
814
+ return Number.isNaN(e) ? 50 : Math.min(100, Math.max(0, e));
815
+ }
816
+ function hn(e, t, n) {
817
+ let r = n ? 10 : 1;
818
+ switch (e) {
819
+ case "ArrowLeft":
820
+ case "ArrowDown": return z(t - r);
821
+ case "ArrowRight":
822
+ case "ArrowUp": return z(t + r);
823
+ case "PageDown": return z(t - 10);
824
+ case "PageUp": return z(t + 10);
825
+ case "Home": return 0;
826
+ case "End": return 100;
827
+ default: return null;
828
+ }
829
+ }
830
+ //#endregion
831
+ //#region lib/components/ui/media/compare-slider/use-compare-slider.ts
832
+ function gn({ position: e, defaultPosition: t, onPositionChange: n }) {
833
+ let r = M(null), i = M(!1), [a, o] = N(t), s = z(e ?? a);
834
+ pe(() => {
835
+ r.current?.style.setProperty("--compare-at", `${s}%`);
836
+ }, [s]);
837
+ let c = (t) => {
838
+ let r = z(t);
839
+ e === void 0 && o(r), n?.(r);
840
+ }, l = (e) => {
841
+ let t = r.current?.getBoundingClientRect();
842
+ !t || t.width === 0 || c((e.clientX - t.left) / t.width * 100);
843
+ };
844
+ return {
845
+ rootRef: r,
846
+ current: s,
847
+ onKeyDown: (e) => {
848
+ let t = hn(e.key, s, e.shiftKey);
849
+ t !== null && (e.preventDefault(), c(t));
850
+ },
851
+ rootHandlers: {
852
+ onPointerDown: (e) => {
853
+ e.button === 0 && (i.current = !0, e.currentTarget.setPointerCapture?.(e.pointerId), l(e));
854
+ },
855
+ onPointerMove: (e) => {
856
+ i.current && l(e);
857
+ },
858
+ onPointerUp: () => {
859
+ i.current = !1;
860
+ },
861
+ onPointerCancel: () => {
862
+ i.current = !1;
863
+ }
864
+ }
865
+ };
866
+ }
867
+ //#endregion
868
+ //#region lib/components/ui/media/compare-slider/compare-slider.tsx
869
+ var _n = "pointer-events-none absolute top-3 rounded-full bg-black/55 px-2.5 py-1 font-medium text-white text-xs backdrop-blur-md";
870
+ function vn({ before: t, after: n, position: r, defaultPosition: i = 50, onPositionChange: a, beforeLabel: o, afterLabel: s, showLabels: c = !0, className: l }) {
871
+ let { t: u } = x(), { rootRef: d, current: f, onKeyDown: p, rootHandlers: m } = gn({
872
+ position: r,
873
+ defaultPosition: i,
874
+ onPositionChange: a
875
+ });
876
+ return /* @__PURE__ */ I("div", {
877
+ ref: d,
878
+ "data-slot": "compare-slider",
879
+ className: e("relative isolate touch-none select-none overflow-hidden [--compare-at:50%]", l),
880
+ ...m,
881
+ children: [
882
+ /* @__PURE__ */ F("div", {
883
+ "data-slot": "compare-slider-after",
884
+ className: "size-full",
885
+ children: n
886
+ }),
887
+ /* @__PURE__ */ F("div", {
888
+ "data-slot": "compare-slider-before",
889
+ className: "absolute inset-0 [clip-path:inset(0_calc(100%-var(--compare-at))_0_0)]",
890
+ children: t
891
+ }),
892
+ c && /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F("span", {
893
+ className: e(_n, "left-3"),
894
+ children: o ?? u("material.compare-slider.before", "Before")
895
+ }), /* @__PURE__ */ F("span", {
896
+ className: e(_n, "right-3"),
897
+ children: s ?? u("material.compare-slider.after", "After")
898
+ })] }),
899
+ /* @__PURE__ */ F(mn, {
900
+ current: f,
901
+ onKeyDown: p
902
+ })
903
+ ]
904
+ });
905
+ }
906
+ //#endregion
907
+ //#region lib/components/ui/media/image-cropper/crop-image.ts
908
+ function yn(e) {
909
+ return e * Math.PI / 180;
910
+ }
911
+ function bn(e, t, n) {
912
+ let r = yn(n);
913
+ return {
914
+ width: Math.abs(Math.cos(r) * e) + Math.abs(Math.sin(r) * t),
915
+ height: Math.abs(Math.sin(r) * e) + Math.abs(Math.cos(r) * t)
916
+ };
917
+ }
918
+ function xn(e) {
919
+ return new Promise((t, n) => {
920
+ let r = new Image();
921
+ r.addEventListener("load", () => t(r)), r.addEventListener("error", () => n(/* @__PURE__ */ Error("Could not load image"))), r.crossOrigin = "anonymous", r.src = e;
922
+ });
923
+ }
924
+ function Sn(e, t, n) {
925
+ let r = Math.max(e, t);
926
+ if (!n || n <= 0 || r <= n) return {
927
+ width: e,
928
+ height: t
929
+ };
930
+ let i = n / r;
931
+ return {
932
+ width: Math.max(1, Math.round(e * i)),
933
+ height: Math.max(1, Math.round(t * i))
934
+ };
935
+ }
936
+ var Cn = {
937
+ "image/png": "png",
938
+ "image/webp": "webp",
939
+ "image/avif": "avif"
940
+ };
941
+ async function wn(e, t, n) {
942
+ let r = n?.rotation ?? 0, i = n?.mimeType ?? "image/jpeg", a = await xn(e), o = document.createElement("canvas"), s = o.getContext("2d");
943
+ if (!s) throw Error("Canvas is not available");
944
+ let { width: c, height: l } = bn(a.width, a.height, r);
945
+ o.width = c, o.height = l, s.translate(c / 2, l / 2), s.rotate(yn(r)), s.translate(-a.width / 2, -a.height / 2), s.drawImage(a, 0, 0);
946
+ let u = document.createElement("canvas"), d = u.getContext("2d");
947
+ if (!d) throw Error("Canvas is not available");
948
+ let f = Sn(t.width, t.height, n?.outputSize);
949
+ u.width = f.width, u.height = f.height, d.drawImage(o, t.x, t.y, t.width, t.height, 0, 0, f.width, f.height);
950
+ let p = await new Promise((e, t) => {
951
+ u.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("Crop failed")), i, n?.quality ?? .92);
952
+ }), m = p.type || i, h = Cn[m] ?? "jpg";
953
+ return new File([p], n?.fileName ?? `crop.${h}`, { type: m });
954
+ }
955
+ //#endregion
956
+ //#region lib/components/ui/media/image-editor/image-editor-provider.tsx
957
+ var Tn = de(null);
958
+ function En({ value: e, children: t }) {
959
+ return /* @__PURE__ */ F(Tn.Provider, {
960
+ value: e,
961
+ children: t
962
+ });
963
+ }
964
+ function B() {
965
+ let e = fe(Tn);
966
+ if (!e) throw Error("ImageEditor parts must be used inside <ImageEditor>");
967
+ return e;
968
+ }
969
+ var Dn = (e, t, n) => .2126 * e + .7152 * t + .0722 * n;
970
+ function On(e, t = 64) {
971
+ let n = Array(t).fill(0), { data: r } = e;
972
+ for (let e = 0; e < r.length; e += 4) {
973
+ if ((r[e + 3] ?? 0) < 8) continue;
974
+ let i = Dn(r[e] ?? 0, r[e + 1] ?? 0, r[e + 2] ?? 0), a = Math.min(t - 1, Math.floor(i / 256 * t));
975
+ n[a] = (n[a] ?? 0) + 1;
976
+ }
977
+ return n;
978
+ }
979
+ function kn(e, t) {
980
+ let n = e.reduce((e, t) => e + t, 0);
981
+ if (n === 0) return .5;
982
+ let r = 0;
983
+ for (let i = 0; i < e.length; i++) if (r += e[i] ?? 0, r / n >= t) return (i + .5) / e.length;
984
+ return 1;
985
+ }
986
+ function An(e) {
987
+ let { data: t } = e, n = 0, r = 0;
988
+ for (let e = 0; e < t.length; e += 4) {
989
+ let i = t[e] ?? 0, a = t[e + 1] ?? 0, o = t[e + 2] ?? 0, s = Math.max(i, a, o);
990
+ s !== 0 && (n += (s - Math.min(i, a, o)) / s, r++);
991
+ }
992
+ return r ? n / r : 0;
993
+ }
994
+ var jn = (e, t, n) => Math.round(Math.min(n, Math.max(t, e)));
995
+ function Mn(e) {
996
+ let t = On(e, 128), n = kn(t, .02), r = kn(t, .98), i = kn(t, .5), a = {}, o = jn((.5 - i) * 110, -40, 40);
997
+ Math.abs(o) >= 4 && (a.exposure = o);
998
+ let s = r - n;
999
+ s < .88 && (a.contrast = jn((.92 - s) * 90, 0, 35)), r > .97 && (a.highlights = -jn((r - .94) * 500, 0, 30)), n < .03 && (a.shadows = jn((.06 - n) * 400, 0, 30));
1000
+ let c = An(e);
1001
+ return c < .35 && (a.vibrance = jn((.4 - c) * 90, 0, 35)), a;
1002
+ }
1003
+ //#endregion
1004
+ //#region lib/components/ui/media/image-editor/image-editor.consts.ts
1005
+ var Nn = [
1006
+ "adjust",
1007
+ "filters",
1008
+ "crop",
1009
+ "markup"
1010
+ ], V = {
1011
+ exposure: 0,
1012
+ brightness: 0,
1013
+ contrast: 0,
1014
+ highlights: 0,
1015
+ shadows: 0,
1016
+ saturation: 0,
1017
+ vibrance: 0,
1018
+ warmth: 0,
1019
+ tint: 0,
1020
+ hue: 0,
1021
+ fade: 0,
1022
+ sepia: 0,
1023
+ vignette: 0,
1024
+ grain: 0,
1025
+ blur: 0
1026
+ }, H = (e, t) => ({
1027
+ key: e,
1028
+ min: -100,
1029
+ max: 100,
1030
+ label: t
1031
+ }), Pn = (e, t) => ({
1032
+ key: e,
1033
+ min: 0,
1034
+ max: 100,
1035
+ label: t
1036
+ }), Fn = [
1037
+ {
1038
+ id: "light",
1039
+ label: "Light",
1040
+ items: [
1041
+ H("exposure", "Exposure"),
1042
+ H("brightness", "Brightness"),
1043
+ H("contrast", "Contrast"),
1044
+ H("highlights", "Highlights"),
1045
+ H("shadows", "Shadows")
1046
+ ]
1047
+ },
1048
+ {
1049
+ id: "color",
1050
+ label: "Colour",
1051
+ items: [
1052
+ H("saturation", "Saturation"),
1053
+ H("vibrance", "Vibrance"),
1054
+ H("warmth", "Warmth"),
1055
+ H("tint", "Tint"),
1056
+ {
1057
+ key: "hue",
1058
+ min: -180,
1059
+ max: 180,
1060
+ label: "Hue"
1061
+ }
1062
+ ]
1063
+ },
1064
+ {
1065
+ id: "effects",
1066
+ label: "Effects",
1067
+ items: [
1068
+ Pn("fade", "Fade"),
1069
+ Pn("sepia", "Sepia"),
1070
+ Pn("vignette", "Vignette"),
1071
+ Pn("grain", "Grain"),
1072
+ Pn("blur", "Blur")
1073
+ ]
1074
+ }
1075
+ ];
1076
+ Fn.flatMap((e) => e.items);
1077
+ var U = {
1078
+ x: 0,
1079
+ y: 0,
1080
+ w: 1,
1081
+ h: 1
1082
+ }, W = {
1083
+ adjustments: V,
1084
+ filter: "none",
1085
+ filterIntensity: 100,
1086
+ transform: {
1087
+ quarterTurns: 0,
1088
+ flipX: !1,
1089
+ flipY: !1,
1090
+ straighten: 0
1091
+ },
1092
+ crop: U,
1093
+ annotations: []
1094
+ }, In = [
1095
+ {
1096
+ id: "free",
1097
+ label: "Free",
1098
+ value: null
1099
+ },
1100
+ {
1101
+ id: "original",
1102
+ label: "Original",
1103
+ value: "original"
1104
+ },
1105
+ {
1106
+ id: "1:1",
1107
+ label: "1:1",
1108
+ value: 1
1109
+ },
1110
+ {
1111
+ id: "4:5",
1112
+ label: "4:5",
1113
+ value: 4 / 5
1114
+ },
1115
+ {
1116
+ id: "4:3",
1117
+ label: "4:3",
1118
+ value: 4 / 3
1119
+ },
1120
+ {
1121
+ id: "3:2",
1122
+ label: "3:2",
1123
+ value: 3 / 2
1124
+ },
1125
+ {
1126
+ id: "16:9",
1127
+ label: "16:9",
1128
+ value: 16 / 9
1129
+ },
1130
+ {
1131
+ id: "9:16",
1132
+ label: "9:16",
1133
+ value: 9 / 16
1134
+ }
1135
+ ], Ln = [
1136
+ "#ffffff",
1137
+ "#111827",
1138
+ "#ef4444",
1139
+ "#f97316",
1140
+ "#facc15",
1141
+ "#22c55e",
1142
+ "#06b6d4",
1143
+ "#3b82f6",
1144
+ "#8b5cf6",
1145
+ "#ec4899"
1146
+ ], Rn = {
1147
+ color: "#ef4444",
1148
+ size: .012,
1149
+ fill: !1,
1150
+ background: !0,
1151
+ redactMode: "solid"
1152
+ }, zn = .002, Bn = .06, Vn = {
1153
+ format: "image/png",
1154
+ quality: .92,
1155
+ scale: 1
1156
+ }, Hn = .1, Un = [
1157
+ .1,
1158
+ .25,
1159
+ .5,
1160
+ .75,
1161
+ 1,
1162
+ 1.5,
1163
+ 2,
1164
+ 3,
1165
+ 4,
1166
+ 6,
1167
+ 8
1168
+ ], Wn = 1600, G = .04, Gn = (e) => $e(e) ? Qe(e) : e;
1169
+ function K(e, t, n) {
1170
+ (t === null || t !== e.historyGroup) && (e.past.push(Gn(e.edits)), e.past.length > 60 && e.past.shift(), e.future = []), e.historyGroup = t, n(e.edits);
1171
+ }
1172
+ function Kn(e) {
1173
+ e.selectedId && !e.edits.annotations.some((t) => t.id === e.selectedId) && (e.selectedId = null);
1174
+ }
1175
+ function qn(e) {
1176
+ let t = e.past.pop();
1177
+ t && (e.future.unshift(Gn(e.edits)), e.edits = t, e.historyGroup = null, Kn(e));
1178
+ }
1179
+ function Jn(e) {
1180
+ let t = e.future.shift();
1181
+ t && (e.past.push(Gn(e.edits)), e.edits = t, e.historyGroup = null, Kn(e));
1182
+ }
1183
+ //#endregion
1184
+ //#region lib/components/ui/media/image-editor/image-editor.geometry.ts
1185
+ function q(e, t) {
1186
+ return t % 2 == 0 ? {
1187
+ width: e.width,
1188
+ height: e.height
1189
+ } : {
1190
+ width: e.height,
1191
+ height: e.width
1192
+ };
1193
+ }
1194
+ function Yn(e, t, n) {
1195
+ let r = Math.abs(n * Math.PI / 180), i = Math.cos(r), a = Math.sin(r);
1196
+ return Math.max((e * i + t * a) / e, (e * a + t * i) / t);
1197
+ }
1198
+ function Xn(e, t, n) {
1199
+ return n === 1 ? [1 - t, e] : [t, 1 - e];
1200
+ }
1201
+ function Zn(e, t) {
1202
+ let [n, r] = Xn(e.x, e.y, t), [i, a] = Xn(e.x + e.w, e.y + e.h, t);
1203
+ return $n(n, r, i, a);
1204
+ }
1205
+ function Qn(e, t) {
1206
+ return t === "x" ? {
1207
+ ...e,
1208
+ x: 1 - e.x - e.w
1209
+ } : {
1210
+ ...e,
1211
+ y: 1 - e.y - e.h
1212
+ };
1213
+ }
1214
+ function $n(e, t, n, r) {
1215
+ return {
1216
+ x: Math.min(e, n),
1217
+ y: Math.min(t, r),
1218
+ w: Math.abs(n - e),
1219
+ h: Math.abs(r - t)
1220
+ };
1221
+ }
1222
+ var J = (e, t, n) => Math.min(n, Math.max(t, e));
1223
+ function er(e) {
1224
+ let t = J(e.w, G, 1), n = J(e.h, G, 1);
1225
+ return {
1226
+ x: J(e.x, 0, 1 - t),
1227
+ y: J(e.y, 0, 1 - n),
1228
+ w: t,
1229
+ h: n
1230
+ };
1231
+ }
1232
+ function tr(e, t, n) {
1233
+ let r = t / (n.width / n.height), i = Math.max(e.w, G), a = i / r;
1234
+ a > 1 && (a = 1, i = a * r), i > 1 && (i = 1, a = i / r);
1235
+ let o = e.x + e.w / 2, s = e.y + e.h / 2;
1236
+ return {
1237
+ x: J(o - i / 2, 0, 1 - i),
1238
+ y: J(s - a / 2, 0, 1 - a),
1239
+ w: i,
1240
+ h: a
1241
+ };
1242
+ }
1243
+ function nr(e, t, n) {
1244
+ return {
1245
+ ...e,
1246
+ x: J(e.x + t, 0, 1 - e.w),
1247
+ y: J(e.y + n, 0, 1 - e.h)
1248
+ };
1249
+ }
1250
+ function rr(e, t, n, r, i, a) {
1251
+ if (t === "move") return nr(e, n, r);
1252
+ let o = e.x, s = e.y, c = e.x + e.w, l = e.y + e.h;
1253
+ t.includes("w") && (o = J(o + n, 0, c - G)), t.includes("e") && (c = J(c + n, o + G, 1)), t.includes("n") && (s = J(s + r, 0, l - G)), t.includes("s") && (l = J(l + r, s + G, 1));
1254
+ let u = {
1255
+ x: o,
1256
+ y: s,
1257
+ w: c - o,
1258
+ h: l - s
1259
+ };
1260
+ return i ? ir(u, t, i, a) : u;
1261
+ }
1262
+ function ir(e, t, n, r) {
1263
+ let i = n / (r.width / r.height), a = t === "n" || t === "s", o = a ? e.h * i : e.w, s = a ? e.h : e.w / i, c = e.x + e.w, l = e.y + e.h, u = t.includes("w") ? c : 1 - e.x, d = t.includes("n") ? l : 1 - e.y, f = Math.min(1, u / o, d / s);
1264
+ o *= f, s *= f;
1265
+ let p = t.includes("w") ? c - o : a ? e.x + (e.w - o) / 2 : e.x, m = t.includes("n") ? l - s : e.y;
1266
+ return {
1267
+ x: J(p, 0, 1 - o),
1268
+ y: J(m, 0, 1 - s),
1269
+ w: o,
1270
+ h: s
1271
+ };
1272
+ }
1273
+ function ar(e) {
1274
+ return e.quarterTurns === 0 && !e.flipX && !e.flipY && e.straighten === 0;
1275
+ }
1276
+ //#endregion
1277
+ //#region lib/components/ui/media/image-editor/image-editor.steps.ts
1278
+ var or = (e, t) => Math.max(22, t.stepFloor ?? 0, e * Math.min(t.width, t.height) * 5);
1279
+ function sr(e) {
1280
+ let t = e.flatMap((e) => e.kind === "step" ? [e] : []);
1281
+ t.sort((e, t) => e.n - t.n), t.forEach((e, t) => {
1282
+ e.n = t + 1;
1283
+ });
1284
+ }
1285
+ //#endregion
1286
+ //#region lib/components/ui/media/image-editor/image-editor.annotations.ts
1287
+ function Y(e, t) {
1288
+ switch (e.kind) {
1289
+ case "pen":
1290
+ case "highlighter": {
1291
+ let n = [];
1292
+ for (let r = 0; r < e.points.length; r += 2) n.push(...t(e.points[r] ?? 0, e.points[r + 1] ?? 0));
1293
+ return {
1294
+ ...e,
1295
+ points: n
1296
+ };
1297
+ }
1298
+ case "line":
1299
+ case "arrow": {
1300
+ let [n, r] = t(e.x1, e.y1), [i, a] = t(e.x2, e.y2);
1301
+ return {
1302
+ ...e,
1303
+ x1: n,
1304
+ y1: r,
1305
+ x2: i,
1306
+ y2: a
1307
+ };
1308
+ }
1309
+ case "text":
1310
+ case "step": {
1311
+ let [n, r] = t(e.x, e.y);
1312
+ return {
1313
+ ...e,
1314
+ x: n,
1315
+ y: r
1316
+ };
1317
+ }
1318
+ default: {
1319
+ let [n, r] = t(e.x, e.y), [i, a] = t(e.x + e.w, e.y + e.h);
1320
+ return {
1321
+ ...e,
1322
+ ...$n(n, r, i, a)
1323
+ };
1324
+ }
1325
+ }
1326
+ }
1327
+ function cr(e, t, n) {
1328
+ return Y(e, (e, r) => [e + t, r + n]);
1329
+ }
1330
+ var lr = (e, t) => Math.max(8, e * Math.min(t.width, t.height) * 3.2);
1331
+ function ur(e, t) {
1332
+ switch (e.kind) {
1333
+ case "pen":
1334
+ case "highlighter": {
1335
+ let t = e.points.filter((e, t) => t % 2 == 0), n = e.points.filter((e, t) => t % 2 == 1);
1336
+ return $n(Math.min(...t), Math.min(...n), Math.max(...t), Math.max(...n));
1337
+ }
1338
+ case "line":
1339
+ case "arrow": return $n(e.x1, e.y1, e.x2, e.y2);
1340
+ case "step": {
1341
+ let n = or(e.size, t), r = n / t.width, i = n / t.height;
1342
+ return {
1343
+ x: e.x - r / 2,
1344
+ y: e.y - i / 2,
1345
+ w: r,
1346
+ h: i
1347
+ };
1348
+ }
1349
+ case "text": {
1350
+ let n = lr(e.size, t), r = e.text.split("\n"), i = (Math.max(...r.map((e) => e.length), 1) * n * .56 + n * .8) / t.width, a = (r.length * n * 1.25 + n * .4) / t.height;
1351
+ return {
1352
+ x: e.x,
1353
+ y: e.y,
1354
+ w: i,
1355
+ h: a
1356
+ };
1357
+ }
1358
+ default: return {
1359
+ x: e.x,
1360
+ y: e.y,
1361
+ w: e.w,
1362
+ h: e.h
1363
+ };
1364
+ }
1365
+ }
1366
+ function dr(e, t, n, r, i, a) {
1367
+ let o = i - n, s = a - r, c = o * o + s * s, l = c === 0 ? 0 : Math.max(0, Math.min(1, ((e - n) * o + (t - r) * s) / c));
1368
+ return Math.hypot(e - (n + l * o), t - (r + l * s));
1369
+ }
1370
+ function fr(e, t, n, r, i = 6) {
1371
+ let a = t * r.width, o = n * r.height, s = e.size * Math.min(r.width, r.height) / 2 + i, c = (e, t) => [e * r.width, t * r.height];
1372
+ if (e.kind === "pen" || e.kind === "highlighter") {
1373
+ let t = Math.floor(e.points.length / 2);
1374
+ for (let n = 0; n < Math.max(1, t - 1); n++) {
1375
+ let r = Math.min(n + 1, t - 1), [i, l] = c(e.points[n * 2] ?? 0, e.points[n * 2 + 1] ?? 0), [u, d] = c(e.points[r * 2] ?? 0, e.points[r * 2 + 1] ?? 0);
1376
+ if (dr(a, o, i, l, u, d) <= s) return !0;
1377
+ }
1378
+ return !1;
1379
+ }
1380
+ if (e.kind === "line" || e.kind === "arrow") {
1381
+ let [t, n] = c(e.x1, e.y1), [r, i] = c(e.x2, e.y2);
1382
+ return dr(a, o, t, n, r, i) <= s;
1383
+ }
1384
+ if (e.kind === "step") {
1385
+ let t = or(e.size, r) / 2 + i;
1386
+ return Math.hypot(a - e.x * r.width, o - e.y * r.height) <= t;
1387
+ }
1388
+ let l = ur(e, r), u = i / Math.min(r.width, r.height);
1389
+ return t >= l.x - u && t <= l.x + l.w + u && n >= l.y - u && n <= l.y + l.h + u;
1390
+ }
1391
+ function X(e, t, n, r) {
1392
+ for (let i = e.length - 1; i >= 0; i--) {
1393
+ let a = e[i];
1394
+ if (a && fr(a, t, n, r)) return a;
1395
+ }
1396
+ }
1397
+ var pr = 0;
1398
+ function mr() {
1399
+ return pr += 1, `mark-${Date.now().toString(36)}-${pr.toString(36)}`;
1400
+ }
1401
+ function hr(e, t) {
1402
+ return t ? e.filter((e) => e.id !== t) : e;
1403
+ }
1404
+ //#endregion
1405
+ //#region lib/components/ui/media/image-editor/image-editor.markup-reducers.ts
1406
+ var Z = (e, t) => e.edits.annotations.findIndex((e) => e.id === t);
1407
+ function gr(e, t) {
1408
+ t.color !== void 0 && (e.color = t.color), t.size !== void 0 && (e.size = t.size), t.fill !== void 0 && (e.kind === "rect" || e.kind === "ellipse") && (e.fill = t.fill), t.redactMode !== void 0 && e.kind === "redact" && (e.mode = t.redactMode), t.background !== void 0 && e.kind === "text" && (e.background = t.background);
1409
+ }
1410
+ var _r = {
1411
+ addAnnotation: (e, t) => {
1412
+ let n = { ...t.payload };
1413
+ K(e, null, (t) => {
1414
+ n.kind === "step" && (n.n = t.annotations.filter((e) => e.kind === "step").length + 1, e.selectedId = n.id), t.annotations.push(n);
1415
+ });
1416
+ },
1417
+ updateAnnotation: (e, t) => {
1418
+ let n = Z(e, t.payload.annotation.id);
1419
+ n < 0 || K(e, t.payload.gesture ?? null, (e) => {
1420
+ e.annotations[n] = t.payload.annotation;
1421
+ });
1422
+ },
1423
+ moveAnnotation: (e, t) => {
1424
+ let { id: n, dx: r, dy: i, gesture: a } = t.payload, o = Z(e, n), s = e.edits.annotations[o];
1425
+ s && K(e, a, (e) => {
1426
+ e.annotations[o] = cr(s, r, i);
1427
+ });
1428
+ },
1429
+ removeAnnotation: (e, t) => {
1430
+ let n = Z(e, t.payload);
1431
+ n < 0 || (K(e, null, (e) => {
1432
+ e.annotations.splice(n, 1), sr(e.annotations);
1433
+ }), e.selectedId === t.payload && (e.selectedId = null));
1434
+ },
1435
+ duplicateAnnotation: (e, t) => {
1436
+ let n = e.edits.annotations[Z(e, t.payload)];
1437
+ if (!n) return;
1438
+ let r = {
1439
+ ...cr(n, .03, .03),
1440
+ id: mr()
1441
+ };
1442
+ K(e, null, (e) => {
1443
+ r.kind === "step" && (r.n = e.annotations.filter((e) => e.kind === "step").length + 1), e.annotations.push(r);
1444
+ }), e.selectedId = r.id;
1445
+ },
1446
+ bringToFront: (e, t) => {
1447
+ let n = Z(e, t.payload);
1448
+ n < 0 || n === e.edits.annotations.length - 1 || K(e, null, (e) => {
1449
+ let [t] = e.annotations.splice(n, 1);
1450
+ t && e.annotations.push(t);
1451
+ });
1452
+ },
1453
+ clearAnnotations: (e) => {
1454
+ e.edits.annotations.length !== 0 && (K(e, null, (e) => {
1455
+ e.annotations = [];
1456
+ }), e.selectedId = null);
1457
+ },
1458
+ selectAnnotation: (e, t) => {
1459
+ e.selectedId = t.payload, e.historyGroup = null;
1460
+ },
1461
+ setBrush: (e, t) => {
1462
+ Object.assign(e.brush, t.payload);
1463
+ let n = e.selectedId ? Z(e, e.selectedId) : -1;
1464
+ n < 0 || K(e, `style:${e.selectedId}`, (e) => {
1465
+ let r = e.annotations[n];
1466
+ r && gr(r, t.payload);
1467
+ });
1468
+ }
1469
+ }, vr = {
1470
+ turn: (e, t) => {
1471
+ let n = t.payload;
1472
+ K(e, null, (e) => {
1473
+ let { transform: t } = e, r = t.flipX === t.flipY ? n : -n;
1474
+ t.quarterTurns = ((t.quarterTurns + r) % 4 + 4) % 4, e.crop = Zn(e.crop, n), e.annotations = e.annotations.map((e) => Y(e, (e, t) => Xn(e, t, n)));
1475
+ }), e.aspect !== null && e.aspect !== "original" && (e.aspect = 1 / e.aspect);
1476
+ },
1477
+ flip: (e, t) => {
1478
+ let n = t.payload;
1479
+ K(e, null, (e) => {
1480
+ n === "x" ? e.transform.flipX = !e.transform.flipX : e.transform.flipY = !e.transform.flipY, e.crop = Qn(e.crop, n), e.annotations = e.annotations.map((e) => Y(e, (e, t) => n === "x" ? [1 - e, t] : [e, 1 - t]));
1481
+ });
1482
+ },
1483
+ setStraighten: (e, t) => {
1484
+ let n = Math.min(45, Math.max(-45, t.payload));
1485
+ e.edits.transform.straighten !== n && K(e, "straighten", (e) => {
1486
+ e.transform.straighten = n;
1487
+ });
1488
+ },
1489
+ setCrop: (e, t) => {
1490
+ let n = er(t.payload.rect);
1491
+ K(e, t.payload.gesture ?? null, (e) => {
1492
+ e.crop = n;
1493
+ });
1494
+ },
1495
+ resetTransform: (e) => {
1496
+ let { transform: t } = e.edits, n = t.quarterTurns === 0 && !t.flipX && !t.flipY && t.straighten === 0, r = e.edits.crop;
1497
+ n && r.x === 0 && r.y === 0 && r.w === 1 && r.h === 1 || (K(e, null, (e) => {
1498
+ e.annotations = e.annotations.map((t) => yr(t, e.transform)), e.transform = W.transform, e.crop = W.crop;
1499
+ }), e.aspect = null);
1500
+ }
1501
+ };
1502
+ function yr(e, t) {
1503
+ let n = e;
1504
+ t.flipX && (n = Y(n, (e, t) => [1 - e, t])), t.flipY && (n = Y(n, (e, t) => [e, 1 - t]));
1505
+ for (let e = 0; e < t.quarterTurns; e++) n = Y(n, (e, t) => Xn(e, t, -1));
1506
+ return n;
1507
+ }
1508
+ //#endregion
1509
+ //#region lib/components/ui/media/image-editor/image-editor.slice.ts
1510
+ function br(e) {
1511
+ return {
1512
+ ...W,
1513
+ ...e,
1514
+ adjustments: {
1515
+ ...V,
1516
+ ...e?.adjustments
1517
+ },
1518
+ transform: {
1519
+ ...W.transform,
1520
+ ...e?.transform
1521
+ },
1522
+ crop: {
1523
+ ...W.crop,
1524
+ ...e?.crop
1525
+ },
1526
+ annotations: e?.annotations ?? []
1527
+ };
1528
+ }
1529
+ var xr = Ze({
1530
+ name: "imageEditor",
1531
+ initialState: ((e) => ({
1532
+ edits: W,
1533
+ past: [],
1534
+ future: [],
1535
+ historyGroup: null,
1536
+ tool: "adjust",
1537
+ markupTool: "pen",
1538
+ brush: Rn,
1539
+ selectedId: null,
1540
+ zoom: null,
1541
+ comparing: !1,
1542
+ split: !1,
1543
+ aspect: null,
1544
+ exportOptions: Vn,
1545
+ editingId: null,
1546
+ shortcutsOpen: !1,
1547
+ ...e
1548
+ }))(),
1549
+ reducers: {
1550
+ setTool: (e, t) => {
1551
+ e.tool = t.payload, e.historyGroup = null, t.payload !== "markup" && (e.selectedId = null);
1552
+ },
1553
+ setMarkupTool: (e, t) => {
1554
+ e.markupTool = t.payload, t.payload !== "select" && (e.selectedId = null);
1555
+ },
1556
+ setAdjustment: (e, t) => {
1557
+ let { key: n, value: r } = t.payload;
1558
+ e.edits.adjustments[n] !== r && K(e, `adjust:${n}`, (e) => {
1559
+ e.adjustments[n] = r;
1560
+ });
1561
+ },
1562
+ applyAdjustments: (e, t) => {
1563
+ K(e, null, (e) => {
1564
+ Object.assign(e.adjustments, t.payload);
1565
+ });
1566
+ },
1567
+ resetAdjustments: (e) => {
1568
+ K(e, null, (e) => {
1569
+ e.adjustments = V;
1570
+ });
1571
+ },
1572
+ setFilter: (e, t) => {
1573
+ e.edits.filter !== t.payload && K(e, null, (e) => {
1574
+ e.filter = t.payload, e.filterIntensity = 100;
1575
+ });
1576
+ },
1577
+ setFilterIntensity: (e, t) => {
1578
+ e.edits.filterIntensity !== t.payload && K(e, "filter-intensity", (e) => {
1579
+ e.filterIntensity = t.payload;
1580
+ });
1581
+ },
1582
+ setAspect: (e, t) => {
1583
+ e.aspect = t.payload;
1584
+ },
1585
+ ...vr,
1586
+ ..._r,
1587
+ resetAll: (e) => {
1588
+ K(e, null, (e) => Object.assign(e, W)), e.selectedId = null;
1589
+ },
1590
+ endGesture: (e) => {
1591
+ e.historyGroup = null;
1592
+ },
1593
+ undo: qn,
1594
+ redo: Jn,
1595
+ clearHistory: (e) => {
1596
+ e.past = [], e.future = [], e.historyGroup = null;
1597
+ },
1598
+ setZoom: (e, t) => {
1599
+ e.zoom = t.payload === null ? null : Math.min(8, Math.max(Hn, t.payload));
1600
+ },
1601
+ setComparing: (e, t) => {
1602
+ e.comparing = t.payload;
1603
+ },
1604
+ setSplit: (e, t) => {
1605
+ e.split = t.payload, t.payload && (e.selectedId = null);
1606
+ },
1607
+ setEditingId: (e, t) => {
1608
+ e.editingId = t.payload;
1609
+ },
1610
+ setShortcutsOpen: (e, t) => {
1611
+ e.shortcutsOpen = t.payload;
1612
+ },
1613
+ setExportOptions: (e, t) => {
1614
+ Object.assign(e.exportOptions, t.payload);
1615
+ }
1616
+ }
1617
+ });
1618
+ xr.actions;
1619
+ var Sr = {
1620
+ selectCanUndo: (e) => e.past.length > 0,
1621
+ selectCanRedo: (e) => e.future.length > 0,
1622
+ selectSelected: (e) => e.edits.annotations.find((t) => t.id === e.selectedId),
1623
+ selectIsDirty: (e) => e.past.length > 0,
1624
+ selectAdjustedCount: (e) => Object.values(e.edits.adjustments).filter((e) => e !== 0).length
1625
+ }, Cr = ["solid", "pixelate"];
1626
+ function wr(e) {
1627
+ let t = Cr.filter((t) => e?.includes(t));
1628
+ return t.length ? t : Cr;
1629
+ }
1630
+ function Tr(e, t) {
1631
+ let n = wr(e);
1632
+ return t && n.includes(t) ? t : n.includes("solid") ? "solid" : n[0] ?? "solid";
1633
+ }
1634
+ function Er(e, t) {
1635
+ let n = wr(t), r = (e) => e.kind === "redact" && !n.includes(e.mode ?? "solid");
1636
+ return e.annotations.some(r) ? {
1637
+ ...e,
1638
+ annotations: e.annotations.map((e) => e.kind === "redact" && r(e) ? {
1639
+ ...e,
1640
+ mode: Tr(n, e.mode)
1641
+ } : e)
1642
+ } : e;
1643
+ }
1644
+ function Dr(e) {
1645
+ return /^#[0-9a-f]{6}$/i.test(e) || /^#[0-9a-f]{3}$/i.test(e) ? e : "#000000";
1646
+ }
1647
+ function Or(e, t, n) {
1648
+ let r = e.getTransform(), i = r.transformPoint({
1649
+ x: t.x * n.width,
1650
+ y: t.y * n.height
1651
+ }), a = r.transformPoint({
1652
+ x: (t.x + t.w) * n.width,
1653
+ y: (t.y + t.h) * n.height
1654
+ }), o = Math.min(i.x, a.x), s = Math.min(i.y, a.y), c = Math.max(i.x, a.x), l = Math.max(i.y, a.y), u = t.mode !== "pixelate", [d, f] = u ? [Math.floor, Math.ceil] : [Math.round, Math.round], p = d(o), m = d(s), h = f(c) - p, g = f(l) - m;
1655
+ if (h < 1 || g < 1) return;
1656
+ if (u) {
1657
+ e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = 1, e.globalCompositeOperation = "source-over", e.fillStyle = Dr(t.color), e.fillRect(p, m, h, g), e.restore();
1658
+ return;
1659
+ }
1660
+ let _ = Math.max(6, Math.round(Math.min(e.canvas.width, e.canvas.height) / 48)), v = document.createElement("canvas");
1661
+ v.width = Math.max(1, Math.ceil(h / _)), v.height = Math.max(1, Math.ceil(g / _)), v.getContext("2d")?.drawImage(e.canvas, p, m, h, g, 0, 0, v.width, v.height), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.imageSmoothingEnabled = !1, e.drawImage(v, 0, 0, v.width, v.height, p, m, h, g), e.restore();
1662
+ }
1663
+ //#endregion
1664
+ //#region lib/components/ui/media/image-editor/image-editor.draw.ts
1665
+ var kr = "600 {size}px Inter, \"Segoe UI\", system-ui, sans-serif";
1666
+ function Ar(e) {
1667
+ let t = e.replace("#", ""), n = t.length === 3 ? t.replace(/./g, (e) => e + e) : t, r = Number.parseInt(n.slice(0, 6), 16);
1668
+ if (Number.isNaN(r)) return !1;
1669
+ let i = r >> 16 & 255, a = r >> 8 & 255, o = r & 255;
1670
+ return .299 * i + .587 * a + .114 * o > 160;
1671
+ }
1672
+ function jr(e, t, n) {
1673
+ let r = (e) => [(t[e * 2] ?? 0) * n.width, (t[e * 2 + 1] ?? 0) * n.height], i = Math.floor(t.length / 2), [a, o] = r(0);
1674
+ e.beginPath(), e.moveTo(a, o), i === 1 && e.lineTo(a + .01, o);
1675
+ for (let t = 1; t < i - 1; t++) {
1676
+ let [n, i] = r(t), [a, o] = r(t + 1);
1677
+ e.quadraticCurveTo(n, i, (n + a) / 2, (i + o) / 2);
1678
+ }
1679
+ i > 1 && e.lineTo(...r(i - 1)), e.stroke();
1680
+ }
1681
+ function Mr(e, t, n, r, i, a) {
1682
+ let o = Math.atan2(i - n, r - t), s = Math.max(a * 3.6, 12);
1683
+ e.beginPath(), e.moveTo(r, i), e.lineTo(r - s * Math.cos(o - .45), i - s * Math.sin(o - .45)), e.lineTo(r - s * Math.cos(o + .45), i - s * Math.sin(o + .45)), e.closePath(), e.fill();
1684
+ }
1685
+ function Nr(e, t, n) {
1686
+ let r = lr(t.size, n), i = ur(t, n), a = t.x * n.width, o = t.y * n.height;
1687
+ e.font = kr.replace("{size}", String(r)), e.textBaseline = "top", t.background && (e.fillStyle = Ar(t.color) ? "rgba(17,24,39,0.82)" : "rgba(255,255,255,0.9)", e.beginPath(), e.roundRect(a, o, i.w * n.width, i.h * n.height, r * .3), e.fill()), e.fillStyle = t.color, t.text.split("\n").forEach((t, n) => {
1688
+ e.fillText(t, a + r * .4, o + r * .2 + n * r * 1.25);
1689
+ });
1690
+ }
1691
+ function Pr(e, t, n) {
1692
+ let r = or(t.size, n), i = Ar(t.color), a = t.x * n.width, o = t.y * n.height;
1693
+ e.beginPath(), e.arc(a, o, r / 2, 0, Math.PI * 2), e.fillStyle = t.color, e.fill(), e.lineWidth = Math.max(1.5, r * .07), e.strokeStyle = i ? "rgba(17,24,39,0.85)" : "rgba(255,255,255,0.95)", e.stroke(), e.font = kr.replace("{size}", String(r * (t.n > 9 ? .45 : .55))), e.textAlign = "center", e.textBaseline = "middle", e.fillStyle = i ? "#111827" : "#ffffff", e.fillText(String(t.n), a, o + r * .03);
1694
+ }
1695
+ function Fr(e, t, n) {
1696
+ let r = t.size * Math.min(n.width, n.height);
1697
+ switch (e.save(), e.lineCap = "round", e.lineJoin = "round", e.strokeStyle = t.color, e.fillStyle = t.color, e.lineWidth = r, t.kind) {
1698
+ case "pen":
1699
+ jr(e, t.points, n);
1700
+ break;
1701
+ case "highlighter":
1702
+ e.globalAlpha = .42, e.lineCap = "square", e.lineWidth = r * 2.6, jr(e, t.points, n);
1703
+ break;
1704
+ case "line":
1705
+ case "arrow": {
1706
+ let [i, a, o, s] = [
1707
+ t.x1 * n.width,
1708
+ t.y1 * n.height,
1709
+ t.x2 * n.width,
1710
+ t.y2 * n.height
1711
+ ];
1712
+ e.beginPath(), e.moveTo(i, a), e.lineTo(o, s), e.stroke(), t.kind === "arrow" && Mr(e, i, a, o, s, r);
1713
+ break;
1714
+ }
1715
+ case "rect":
1716
+ case "ellipse": {
1717
+ let [i, a, o, s] = [
1718
+ t.x * n.width,
1719
+ t.y * n.height,
1720
+ t.w * n.width,
1721
+ t.h * n.height
1722
+ ];
1723
+ e.beginPath(), t.kind === "rect" ? e.roundRect(i, a, o, s, Math.min(r * 1.5, o / 2, s / 2)) : e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2), t.fill && e.fill(), e.stroke();
1724
+ break;
1725
+ }
1726
+ case "text":
1727
+ Nr(e, t, n);
1728
+ break;
1729
+ case "step":
1730
+ Pr(e, t, n);
1731
+ break;
1732
+ case "redact":
1733
+ Or(e, t, n);
1734
+ break;
1735
+ }
1736
+ e.restore();
1737
+ }
1738
+ //#endregion
1739
+ //#region lib/components/ui/media/image-editor/image-editor.filters.ts
1740
+ var Ir = [
1741
+ {
1742
+ id: "none",
1743
+ label: "Original",
1744
+ adjustments: {}
1745
+ },
1746
+ {
1747
+ id: "vivid",
1748
+ label: "Vivid",
1749
+ adjustments: {
1750
+ contrast: 12,
1751
+ saturation: 22,
1752
+ vibrance: 30
1753
+ }
1754
+ },
1755
+ {
1756
+ id: "golden",
1757
+ label: "Golden",
1758
+ adjustments: {
1759
+ warmth: 38,
1760
+ tint: 6,
1761
+ saturation: 10,
1762
+ fade: 8,
1763
+ highlights: -10
1764
+ }
1765
+ },
1766
+ {
1767
+ id: "arctic",
1768
+ label: "Arctic",
1769
+ adjustments: {
1770
+ warmth: -40,
1771
+ tint: -6,
1772
+ brightness: 6,
1773
+ saturation: -12
1774
+ }
1775
+ },
1776
+ {
1777
+ id: "cinema",
1778
+ label: "Cinema",
1779
+ adjustments: {
1780
+ contrast: 22,
1781
+ saturation: -14,
1782
+ warmth: -12,
1783
+ tint: -8,
1784
+ shadows: -12,
1785
+ vignette: 28
1786
+ }
1787
+ },
1788
+ {
1789
+ id: "dramatic",
1790
+ label: "Dramatic",
1791
+ adjustments: {
1792
+ contrast: 38,
1793
+ highlights: -24,
1794
+ shadows: -18,
1795
+ vibrance: 24,
1796
+ vignette: 36
1797
+ }
1798
+ },
1799
+ {
1800
+ id: "vintage",
1801
+ label: "Vintage",
1802
+ adjustments: {
1803
+ sepia: 38,
1804
+ fade: 28,
1805
+ warmth: 14,
1806
+ contrast: -8,
1807
+ vignette: 30,
1808
+ grain: 18
1809
+ }
1810
+ },
1811
+ {
1812
+ id: "matte",
1813
+ label: "Matte",
1814
+ adjustments: {
1815
+ fade: 42,
1816
+ contrast: -14,
1817
+ saturation: -10,
1818
+ shadows: 10
1819
+ }
1820
+ },
1821
+ {
1822
+ id: "lomo",
1823
+ label: "Lomo",
1824
+ adjustments: {
1825
+ contrast: 32,
1826
+ saturation: 28,
1827
+ vignette: 62,
1828
+ warmth: 6
1829
+ }
1830
+ },
1831
+ {
1832
+ id: "chrome",
1833
+ label: "Chrome",
1834
+ adjustments: {
1835
+ contrast: 18,
1836
+ saturation: 16,
1837
+ highlights: -12,
1838
+ tint: 4
1839
+ }
1840
+ },
1841
+ {
1842
+ id: "noir",
1843
+ label: "Noir",
1844
+ adjustments: {
1845
+ saturation: -100,
1846
+ contrast: 36,
1847
+ shadows: -14,
1848
+ vignette: 30,
1849
+ grain: 14
1850
+ }
1851
+ },
1852
+ {
1853
+ id: "mono",
1854
+ label: "Mono",
1855
+ adjustments: {
1856
+ saturation: -100,
1857
+ contrast: 6
1858
+ }
1859
+ },
1860
+ {
1861
+ id: "polaroid",
1862
+ label: "Polaroid",
1863
+ adjustments: {
1864
+ fade: 30,
1865
+ warmth: 12,
1866
+ sepia: 12,
1867
+ contrast: -10,
1868
+ highlights: 10
1869
+ }
1870
+ }
1871
+ ], Lr = {
1872
+ hue: [-180, 180],
1873
+ fade: [0, 100],
1874
+ sepia: [0, 100],
1875
+ vignette: [0, 100],
1876
+ grain: [0, 100],
1877
+ blur: [0, 100]
1878
+ };
1879
+ function Rr(e, t) {
1880
+ let [n, r] = Lr[e] ?? [-100, 100];
1881
+ return Math.min(r, Math.max(n, t));
1882
+ }
1883
+ function zr(e) {
1884
+ return Ir.find((t) => t.id === e);
1885
+ }
1886
+ function Br(e, t = e.filter) {
1887
+ let n = zr(t)?.adjustments ?? {}, r = Math.min(1, Math.max(0, e.filterIntensity / 100)), i = { ...V };
1888
+ for (let t of Object.keys(i)) i[t] = Rr(t, e.adjustments[t] + (n[t] ?? 0) * r);
1889
+ return i;
1890
+ }
1891
+ function Vr(e) {
1892
+ return Object.values(e).every((e) => e === 0);
1893
+ }
1894
+ //#endregion
1895
+ //#region lib/components/ui/media/image-editor/image-editor.pixels.ts
1896
+ var Hr = (e) => e < 0 ? 0 : e > 255 ? 255 : e;
1897
+ function Ur(e) {
1898
+ let t = /* @__PURE__ */ new Uint8ClampedArray(256), n = 2 ** (e.exposure / 100), r = e.brightness / 100 * 96, i = e.contrast * 2.55, a = 259 * (i + 255) / (255 * (259 - i)), o = e.fade / 100 * .32;
1899
+ for (let e = 0; e < 256; e++) {
1900
+ let i = e * n + r;
1901
+ i = a * (i - 128) + 128, i = i * (1 - o) + 255 * o * .42, t[e] = Hr(i);
1902
+ }
1903
+ return t;
1904
+ }
1905
+ function Wr(e) {
1906
+ let t = e * Math.PI / 180, n = Math.cos(t), r = Math.sin(t);
1907
+ return [
1908
+ .213 + n * .787 - r * .213,
1909
+ .715 - n * .715 - r * .715,
1910
+ .072 - n * .072 + r * .928,
1911
+ .213 - n * .213 + r * .143,
1912
+ .715 + n * .285 + r * .14,
1913
+ .072 - n * .072 - r * .283,
1914
+ .213 - n * .213 - r * .787,
1915
+ .715 - n * .715 + r * .715,
1916
+ .072 + n * .928 + r * .072
1917
+ ];
1918
+ }
1919
+ function Gr(e) {
1920
+ let t = e + 2654435769 | 0;
1921
+ return t = Math.imul(t ^ t >>> 16, 2246822507), t = Math.imul(t ^ t >>> 13, 3266489909), t ^= t >>> 16, (t >>> 0) / 4294967296 - .5;
1922
+ }
1923
+ var Kr = (e, t, n) => .2126 * e + .7152 * t + .0722 * n;
1924
+ function qr(e, t, n) {
1925
+ if (t === 0 && n === 0) return;
1926
+ let r = Kr(e[0], e[1], e[2]) / 255, i = n / 100 * 110 * (1 - r) ** 2 + t / 100 * 110 * r ** 2;
1927
+ e[0] += i, e[1] += i, e[2] += i;
1928
+ }
1929
+ function Jr(e, t, n) {
1930
+ if (t.warmth !== 0 && (e[0] += t.warmth / 100 * 38, e[1] += t.warmth / 100 * 8, e[2] -= t.warmth / 100 * 38), t.tint !== 0 && (e[0] += t.tint / 100 * 18, e[1] -= t.tint / 100 * 32, e[2] += t.tint / 100 * 18), n) {
1931
+ let [t, r, i] = e;
1932
+ e[0] = n[0] * t + n[1] * r + n[2] * i, e[1] = n[3] * t + n[4] * r + n[5] * i, e[2] = n[6] * t + n[7] * r + n[8] * i;
1933
+ }
1934
+ }
1935
+ function Yr(e, t) {
1936
+ if (t.saturation === 0 && t.vibrance === 0) return;
1937
+ let n = Kr(e[0], e[1], e[2]), r = Math.max(e[0], e[1], e[2]), i = Math.min(e[0], e[1], e[2]), a = r <= 0 ? 0 : (r - i) / Math.max(r, 1), o = t.vibrance / 100 * (1 - a) * 1.4, s = Math.max(0, 1 + t.saturation / 100 + o);
1938
+ e[0] = n + (e[0] - n) * s, e[1] = n + (e[1] - n) * s, e[2] = n + (e[2] - n) * s;
1939
+ }
1940
+ function Xr(e, t) {
1941
+ if (t === 0) return;
1942
+ let n = t / 100, [r, i, a] = e;
1943
+ e[0] = r * (1 - n) + n * (.393 * r + .769 * i + .189 * a), e[1] = i * (1 - n) + n * (.349 * r + .686 * i + .168 * a), e[2] = a * (1 - n) + n * (.272 * r + .534 * i + .131 * a);
1944
+ }
1945
+ function Zr(e, t, n, r, i) {
1946
+ let a = ((e + .5) / n - .5) * 2, o = ((t + .5) / r - .5) * 2, s = Math.sqrt(a * a + o * o) / Math.SQRT2, c = Math.min(1, Math.max(0, (s - .3) / .75));
1947
+ return 1 - i / 100 * .85 * c * c * (3 - 2 * c);
1948
+ }
1949
+ function Qr(e, t) {
1950
+ let { data: n, width: r, height: i } = e, a = Ur(t), o = t.hue === 0 ? null : Wr(t.hue), s = t.grain / 100 * 70, c = [
1951
+ 0,
1952
+ 0,
1953
+ 0
1954
+ ];
1955
+ for (let e = 0, l = 0; l < n.length; l += 4, e++) {
1956
+ c[0] = a[n[l] ?? 0] ?? 0, c[1] = a[n[l + 1] ?? 0] ?? 0, c[2] = a[n[l + 2] ?? 0] ?? 0, qr(c, t.highlights, t.shadows), Jr(c, t, o), Yr(c, t), Xr(c, t.sepia);
1957
+ let u = 1;
1958
+ t.vignette > 0 && (u = Zr(e % r, Math.floor(e / r), r, i, t.vignette));
1959
+ let d = s > 0 ? Gr(e) * s : 0;
1960
+ n[l] = Hr(c[0] * u + d), n[l + 1] = Hr(c[1] * u + d), n[l + 2] = Hr(c[2] * u + d);
1961
+ }
1962
+ }
1963
+ //#endregion
1964
+ //#region lib/components/ui/media/image-editor/image-editor.render.ts
1965
+ function $r(e, t, n) {
1966
+ let r = q(t, n.quarterTurns), i = Yn(r.width, r.height, n.straighten);
1967
+ e.translate(r.width / 2, r.height / 2), e.rotate(n.straighten * Math.PI / 180), e.scale(i * (n.flipX ? -1 : 1), i * (n.flipY ? -1 : 1)), e.rotate(n.quarterTurns * Math.PI / 2), e.drawImage(t.image, -t.width / 2, -t.height / 2, t.width, t.height);
1968
+ }
1969
+ var ei = {
1970
+ x: 0,
1971
+ y: 0,
1972
+ w: 1,
1973
+ h: 1
1974
+ };
1975
+ function ti(e, t, n) {
1976
+ let r = q(e, t.transform.quarterTurns), i = n.region === "crop" ? t.crop : ei;
1977
+ return {
1978
+ width: Math.max(1, Math.round(i.w * r.width * n.scale)),
1979
+ height: Math.max(1, Math.round(i.h * r.height * n.scale))
1980
+ };
1981
+ }
1982
+ function ni(e, t) {
1983
+ let { width: n, height: r } = e.canvas, i = e.getImageData(0, 0, n, r);
1984
+ Qr(i, t), e.putImageData(i, 0, 0);
1985
+ }
1986
+ function ri(e, t, n, r) {
1987
+ let i = q(t, n.transform.quarterTurns), a = r.region === "crop" ? n.crop : ei;
1988
+ return e.setTransform(r.scale, 0, 0, r.scale, 0, 0), e.translate(-a.x * i.width, -a.y * i.height), i;
1989
+ }
1990
+ function ii(e, t, n, r) {
1991
+ if (n.annotations.length === 0) return;
1992
+ e.save();
1993
+ let i = {
1994
+ ...ri(e, t, n, r),
1995
+ stepFloor: r.stepFloor
1996
+ };
1997
+ for (let t of n.annotations) Fr(e, t, i);
1998
+ e.restore();
1999
+ }
2000
+ function ai(e, t, n) {
2001
+ let r = n.edited ?? !0, i = ti(e, t, n), a = n.target ?? document.createElement("canvas");
2002
+ a.width = i.width, a.height = i.height;
2003
+ let o = a.getContext("2d", { willReadFrequently: !0 });
2004
+ if (!o) return a;
2005
+ let s = Br(t, n.filter);
2006
+ if (o.save(), o.imageSmoothingQuality = "high", ri(o, e, t, n), r && s.blur > 0 && "filter" in o) {
2007
+ let e = Math.min(i.width, i.height);
2008
+ o.filter = `blur(${(s.blur / 100 * .012 * e).toFixed(2)}px)`;
2009
+ }
2010
+ return $r(o, e, t.transform), o.restore(), r && !Vr({
2011
+ ...s,
2012
+ blur: 0
2013
+ }) && ni(o, s), r && (n.marks ?? !0) && ii(o, e, t, n), a;
2014
+ }
2015
+ function oi(e, t) {
2016
+ let n = Math.min(1, t / Math.max(e.width, e.height));
2017
+ if (n === 1) return e;
2018
+ let r = document.createElement("canvas");
2019
+ r.width = Math.max(1, Math.round(e.width * n)), r.height = Math.max(1, Math.round(e.height * n));
2020
+ let i = r.getContext("2d");
2021
+ return i && (i.imageSmoothingQuality = "high", i.drawImage(e.image, 0, 0, r.width, r.height)), {
2022
+ image: r,
2023
+ width: r.width,
2024
+ height: r.height
2025
+ };
2026
+ }
2027
+ function si(e) {
2028
+ try {
2029
+ let t = document.createElement("canvas");
2030
+ t.width = 1, t.height = 1;
2031
+ let n = t.getContext("2d");
2032
+ return n?.drawImage(e.image, 0, 0, 1, 1), n?.getImageData(0, 0, 1, 1), !0;
2033
+ } catch {
2034
+ return !1;
2035
+ }
2036
+ }
2037
+ //#endregion
2038
+ //#region lib/components/ui/media/image-editor/use-sample-pixels.ts
2039
+ var ci = 200;
2040
+ function li(e) {
2041
+ return j(() => e ? oi(e, ci) : null, [e]);
2042
+ }
2043
+ function ui(e, t, n = !0) {
2044
+ let r = ai(e, t, {
2045
+ scale: 1,
2046
+ region: "crop",
2047
+ edited: n,
2048
+ marks: !1
2049
+ }), i = r.getContext("2d", { willReadFrequently: !0 });
2050
+ return i ? i.getImageData(0, 0, r.width, r.height) : null;
2051
+ }
2052
+ function di(e, t) {
2053
+ let [n, r] = N(null);
2054
+ return k(() => {
2055
+ if (!e) return;
2056
+ let n = requestAnimationFrame(() => r(ui(e, t)));
2057
+ return () => cancelAnimationFrame(n);
2058
+ }, [e, t]), n;
2059
+ }
2060
+ //#endregion
2061
+ //#region lib/components/ui/media/image-editor/partials/adjust-tracks.ts
2062
+ var Q = "[&>[data-slot=slider-range]]:hidden", fi = {
2063
+ exposure: `bg-linear-to-r from-zinc-900 via-zinc-500 to-zinc-50 ${Q}`,
2064
+ brightness: `bg-linear-to-r from-zinc-800 via-zinc-500 to-zinc-100 ${Q}`,
2065
+ warmth: `bg-linear-to-r from-sky-500 via-zinc-300 to-amber-400 ${Q}`,
2066
+ tint: `bg-linear-to-r from-green-500 via-zinc-300 to-fuchsia-500 ${Q}`,
2067
+ saturation: `bg-linear-to-r from-zinc-400 via-rose-300 to-rose-600 ${Q}`,
2068
+ vibrance: `bg-linear-to-r from-zinc-400 via-violet-300 to-violet-600 ${Q}`,
2069
+ hue: `bg-[linear-gradient(to_right,#06b6d4,#3b82f6,#a855f7,#ef4444,#f59e0b,#84cc16,#06b6d4)] ${Q}`
2070
+ };
2071
+ //#endregion
2072
+ //#region lib/components/ui/media/image-editor/partials/editor-slider.tsx
2073
+ function pi({ label: t, value: n, min: r, max: i, step: a = 1, origin: o = r, format: s = String, trackClassName: c, onChange: l, onCommit: u, onReset: d, ...f }) {
2074
+ let p = A(), m = n !== o;
2075
+ return /* @__PURE__ */ I("div", {
2076
+ "data-slot": f["data-slot"] ?? "image-editor-slider",
2077
+ "data-changed": m || void 0,
2078
+ className: "grid gap-2 rounded-lg px-1 py-1",
2079
+ onDoubleClick: () => m && d?.(),
2080
+ children: [/* @__PURE__ */ I("div", {
2081
+ className: "flex items-center justify-between text-sm",
2082
+ children: [/* @__PURE__ */ F("span", {
2083
+ id: p,
2084
+ className: "text-foreground/80",
2085
+ children: t
2086
+ }), /* @__PURE__ */ F("span", {
2087
+ "aria-hidden": "true",
2088
+ className: e("min-w-9 rounded-full px-2 py-0.5 text-right text-xs tabular-nums transition-colors", m ? "bg-primary/15 font-semibold text-primary-text" : "text-muted-foreground"),
2089
+ children: s(n)
2090
+ })]
2091
+ }), /* @__PURE__ */ F(ln, {
2092
+ labelId: p,
2093
+ min: r,
2094
+ max: i,
2095
+ step: a,
2096
+ origin: o,
2097
+ value: [n],
2098
+ trackClassName: e("data-[orientation=horizontal]:h-2", c),
2099
+ onValueChange: ([e]) => l(e ?? o),
2100
+ onValueCommit: u
2101
+ })]
2102
+ });
2103
+ }
2104
+ var mi = (e) => e > 0 ? `+${e}` : String(e);
2105
+ //#endregion
2106
+ //#region lib/components/ui/media/image-editor/partials/editor-adjust-row.tsx
2107
+ function hi({ spec: e }) {
2108
+ let { state: t, actions: n } = B(), { t: r } = x(), i = e.min < 0 ? 0 : e.min;
2109
+ return /* @__PURE__ */ F(pi, {
2110
+ "data-slot": "image-editor-adjust-row",
2111
+ label: r(`material.image-editor.adjust.${e.key}`, e.label),
2112
+ value: t.edits.adjustments[e.key],
2113
+ min: e.min,
2114
+ max: e.max,
2115
+ origin: i,
2116
+ format: mi,
2117
+ trackClassName: fi[e.key],
2118
+ onChange: (t) => n.setAdjustment({
2119
+ key: e.key,
2120
+ value: t
2121
+ }),
2122
+ onCommit: () => n.endGesture(),
2123
+ onReset: () => {
2124
+ n.endGesture(), n.setAdjustment({
2125
+ key: e.key,
2126
+ value: i
2127
+ }), n.endGesture();
2128
+ }
2129
+ });
2130
+ }
2131
+ //#endregion
2132
+ //#region lib/components/ui/media/image-editor/partials/editor-histogram.tsx
2133
+ var gi = 256, $ = 64;
2134
+ function _i(e) {
2135
+ let t = Math.sqrt(Math.max(1, ...e)), n = gi / Math.max(1, e.length - 1);
2136
+ return `M0,${$} L${e.map((e, r) => {
2137
+ let i = $ - Math.sqrt(e) / t * ($ - 4);
2138
+ return `${(r * n).toFixed(1)},${i.toFixed(1)}`;
2139
+ }).join(" L")} L${gi},${$} Z`;
2140
+ }
2141
+ function vi({ pixels: e }) {
2142
+ let { t } = x(), n = A(), r = j(() => e ? _i(On(e)) : null, [e]);
2143
+ return /* @__PURE__ */ F("div", {
2144
+ "data-slot": "image-editor-histogram",
2145
+ className: "relative overflow-hidden rounded-xl border bg-linear-to-b from-muted/40 to-muted/10 p-2",
2146
+ children: /* @__PURE__ */ I("svg", {
2147
+ role: "img",
2148
+ "aria-label": t("material.image-editor.adjust.histogram", "Histogram"),
2149
+ viewBox: `0 0 ${gi} ${$}`,
2150
+ preserveAspectRatio: "none",
2151
+ className: "block h-16 w-full",
2152
+ children: [
2153
+ /* @__PURE__ */ F("defs", { children: /* @__PURE__ */ I("linearGradient", {
2154
+ id: n,
2155
+ x1: "0",
2156
+ x2: "1",
2157
+ y1: "0",
2158
+ y2: "0",
2159
+ children: [/* @__PURE__ */ F("stop", {
2160
+ offset: "0%",
2161
+ stopColor: "var(--color-primary)",
2162
+ stopOpacity: "0.35"
2163
+ }), /* @__PURE__ */ F("stop", {
2164
+ offset: "100%",
2165
+ stopColor: "var(--color-primary)",
2166
+ stopOpacity: "0.85"
2167
+ })]
2168
+ }) }),
2169
+ [
2170
+ .25,
2171
+ .5,
2172
+ .75
2173
+ ].map((e) => /* @__PURE__ */ F("line", {
2174
+ x1: e * gi,
2175
+ x2: e * gi,
2176
+ y1: 0,
2177
+ y2: $,
2178
+ stroke: "currentColor",
2179
+ strokeOpacity: "0.08"
2180
+ }, e)),
2181
+ r && /* @__PURE__ */ F("path", {
2182
+ d: r,
2183
+ fill: `url(#${n})`,
2184
+ stroke: "var(--color-primary)",
2185
+ strokeWidth: "1",
2186
+ vectorEffect: "non-scaling-stroke",
2187
+ className: "transition-[d] duration-200 motion-reduce:transition-none"
2188
+ })
2189
+ ]
2190
+ })
2191
+ });
2192
+ }
2193
+ //#endregion
2194
+ //#region lib/components/ui/media/image-editor/partials/editor-adjust-panel.tsx
2195
+ function yi() {
2196
+ let { state: e, actions: t, source: n } = B(), { t: r } = x(), i = li(n.status === "ready" ? n.preview : null), a = di(i, e.edits), o = Sr.selectAdjustedCount(e) > 0;
2197
+ return /* @__PURE__ */ I(P, { children: [
2198
+ /* @__PURE__ */ F(vi, { pixels: a }),
2199
+ /* @__PURE__ */ I("div", {
2200
+ className: "flex gap-2",
2201
+ children: [/* @__PURE__ */ I(b, {
2202
+ variant: "tonal",
2203
+ color: "primary",
2204
+ size: "sm",
2205
+ className: "flex-1",
2206
+ disabled: !i,
2207
+ onClick: () => {
2208
+ if (!i) return;
2209
+ let n = ui(i, e.edits, !1);
2210
+ n && (t.endGesture(), t.applyAdjustments({
2211
+ exposure: 0,
2212
+ contrast: 0,
2213
+ highlights: 0,
2214
+ shadows: 0,
2215
+ vibrance: 0,
2216
+ ...Mn(n)
2217
+ }));
2218
+ },
2219
+ children: [/* @__PURE__ */ F(qe, { "aria-hidden": "true" }), r("material.image-editor.adjust.auto", "Auto")]
2220
+ }), /* @__PURE__ */ I(b, {
2221
+ variant: "ghost",
2222
+ color: "default",
2223
+ size: "sm",
2224
+ disabled: !o,
2225
+ onClick: () => t.resetAdjustments(),
2226
+ children: [/* @__PURE__ */ F(Ie, { "aria-hidden": "true" }), r("material.image-editor.adjust.reset", "Reset")]
2227
+ })]
2228
+ }),
2229
+ Fn.map((e) => /* @__PURE__ */ F(Wi, {
2230
+ title: r(`material.image-editor.adjust.group.${e.id}`, e.label),
2231
+ children: /* @__PURE__ */ F("div", {
2232
+ className: "grid gap-1",
2233
+ children: e.items.map((e) => /* @__PURE__ */ F(hi, { spec: e }, e.key))
2234
+ })
2235
+ }, e.id))
2236
+ ] });
2237
+ }
2238
+ //#endregion
2239
+ //#region lib/components/ui/media/image-editor/partials/aspect-glyph.tsx
2240
+ var bi = 14;
2241
+ function xi({ ratio: t, className: n }) {
2242
+ let r = t === null, i = r ? 1 : t, a = i >= 1 ? bi : bi * i, o = i >= 1 ? bi / i : bi;
2243
+ return /* @__PURE__ */ F("span", {
2244
+ "aria-hidden": "true",
2245
+ "data-slot": "image-editor-aspect-glyph",
2246
+ className: e("inline-block shrink-0 rounded-[2px] border-[1.5px] border-current opacity-70", r && "border-dashed", n),
2247
+ style: {
2248
+ width: a,
2249
+ height: o
2250
+ }
2251
+ });
2252
+ }
2253
+ //#endregion
2254
+ //#region lib/components/ui/media/image-editor/partials/markup-tools.ts
2255
+ var Si = [
2256
+ {
2257
+ tool: "select",
2258
+ icon: Ae,
2259
+ label: "Select"
2260
+ },
2261
+ {
2262
+ tool: "pen",
2263
+ icon: je,
2264
+ label: "Pen"
2265
+ },
2266
+ {
2267
+ tool: "highlighter",
2268
+ icon: De,
2269
+ label: "Highlighter"
2270
+ },
2271
+ {
2272
+ tool: "eraser",
2273
+ icon: Ce,
2274
+ label: "Eraser"
2275
+ },
2276
+ {
2277
+ tool: "text",
2278
+ icon: Ge,
2279
+ label: "Text"
2280
+ },
2281
+ {
2282
+ tool: "step",
2283
+ icon: Ne,
2284
+ label: "Step marker"
2285
+ },
2286
+ {
2287
+ tool: "line",
2288
+ icon: ze,
2289
+ label: "Line"
2290
+ },
2291
+ {
2292
+ tool: "arrow",
2293
+ icon: me,
2294
+ label: "Arrow"
2295
+ },
2296
+ {
2297
+ tool: "rect",
2298
+ icon: He,
2299
+ label: "Rectangle"
2300
+ },
2301
+ {
2302
+ tool: "ellipse",
2303
+ icon: ve,
2304
+ label: "Ellipse"
2305
+ },
2306
+ {
2307
+ tool: "redact",
2308
+ icon: Ue,
2309
+ label: "Redact"
2310
+ }
2311
+ ], Ci = "before:hidden data-[state=on]:bg-primary data-[state=on]:text-primary-foreground data-[state=on]:hover:bg-primary/90";
2312
+ //#endregion
2313
+ //#region lib/components/ui/media/image-editor/partials/crop-aspect-picker.tsx
2314
+ function wi({ compact: t = !1 }) {
2315
+ let { state: n, actions: r, base: i, aspectPresets: a, lockedAspect: o } = B(), { t: s } = x(), c = n.edits.crop, l = a.find((e) => e.value === n.aspect)?.id ?? "", u = (e) => {
2316
+ let t = a.find((t) => t.id === e);
2317
+ if (!t || !i) return;
2318
+ let n = t.value;
2319
+ r.setAspect(n);
2320
+ let o = n === "original" ? i.width / i.height : n;
2321
+ o && r.setCrop({ rect: tr(c, o, i) });
2322
+ };
2323
+ if (o !== void 0 || a.length === 0) return null;
2324
+ let d = /* @__PURE__ */ F(le, {
2325
+ type: "single",
2326
+ variant: "separate",
2327
+ size: "sm",
2328
+ value: l,
2329
+ onValueChange: (e) => e && u(e),
2330
+ "aria-label": s("material.image-editor.crop.aspect", "Aspect ratio"),
2331
+ className: e("justify-start", t ? "flex-nowrap overflow-x-auto" : "flex-wrap"),
2332
+ children: a.map((t) => /* @__PURE__ */ I(ce, {
2333
+ value: t.id,
2334
+ className: e(Ci, "gap-1.5"),
2335
+ children: [/* @__PURE__ */ F(xi, { ratio: t.value === "original" ? i ? i.width / i.height : 4 / 3 : t.value }), t.id === "free" || t.id === "original" ? s(`material.image-editor.crop.aspect-${t.id}`, t.label) : t.label]
2336
+ }, t.id))
2337
+ });
2338
+ return t ? d : /* @__PURE__ */ F(Wi, {
2339
+ title: s("material.image-editor.crop.aspect", "Aspect ratio"),
2340
+ children: d
2341
+ });
2342
+ }
2343
+ //#endregion
2344
+ //#region lib/components/ui/media/image-editor/partials/crop-orientation.tsx
2345
+ function Ti(e, t, n) {
2346
+ return /* @__PURE__ */ F(S, {
2347
+ variant: "tonal",
2348
+ color: "default",
2349
+ tooltip: e,
2350
+ onClick: n,
2351
+ children: t
2352
+ });
2353
+ }
2354
+ function Ei({ compact: e = !1 }) {
2355
+ let { state: t, actions: n } = B(), { t: r } = x(), { transform: i } = t.edits, a = /* @__PURE__ */ I("div", {
2356
+ className: "flex flex-wrap gap-2",
2357
+ children: [
2358
+ Ti(r("material.image-editor.crop.rotate-left", "Rotate left"), /* @__PURE__ */ F(Ie, {}), () => n.turn(-1)),
2359
+ Ti(r("material.image-editor.crop.rotate-right", "Rotate right"), /* @__PURE__ */ F(Le, {}), () => n.turn(1)),
2360
+ Ti(r("material.image-editor.crop.flip-horizontal", "Flip horizontally"), /* @__PURE__ */ F(Te, {}), () => n.flip("x")),
2361
+ Ti(r("material.image-editor.crop.flip-vertical", "Flip vertically"), /* @__PURE__ */ F(Ee, {}), () => n.flip("y"))
2362
+ ]
2363
+ }), o = /* @__PURE__ */ F(pi, {
2364
+ label: r("material.image-editor.crop.straighten", "Straighten"),
2365
+ min: -45,
2366
+ max: 45,
2367
+ step: .5,
2368
+ origin: 0,
2369
+ value: i.straighten,
2370
+ format: (e) => `${e > 0 ? "+" : ""}${e}°`,
2371
+ onChange: (e) => n.setStraighten(e),
2372
+ onCommit: () => n.endGesture(),
2373
+ onReset: () => {
2374
+ n.endGesture(), n.setStraighten(0), n.endGesture();
2375
+ }
2376
+ });
2377
+ return e ? /* @__PURE__ */ I(P, { children: [a, /* @__PURE__ */ F("div", {
2378
+ className: "min-w-40 flex-1",
2379
+ children: o
2380
+ })] }) : /* @__PURE__ */ I(Wi, {
2381
+ title: r("material.image-editor.crop.orientation", "Rotate & flip"),
2382
+ children: [a, o]
2383
+ });
2384
+ }
2385
+ //#endregion
2386
+ //#region lib/components/ui/media/image-editor/partials/editor-crop-panel.tsx
2387
+ function Di() {
2388
+ let { state: e, actions: t } = B(), { t: n } = x(), { transform: r, crop: i } = e.edits, a = i.x === U.x && i.y === U.y && i.w === U.w && i.h === U.h, o = ar(r) && a;
2389
+ return /* @__PURE__ */ I(P, { children: [
2390
+ /* @__PURE__ */ F(Ei, {}),
2391
+ /* @__PURE__ */ F(wi, {}),
2392
+ /* @__PURE__ */ F(b, {
2393
+ variant: "tonal",
2394
+ color: "default",
2395
+ size: "sm",
2396
+ className: "self-start",
2397
+ disabled: o,
2398
+ onClick: () => t.resetTransform(),
2399
+ children: n("material.image-editor.crop.reset", "Reset crop & rotation")
2400
+ })
2401
+ ] });
2402
+ }
2403
+ //#endregion
2404
+ //#region lib/components/ui/media/image-editor/partials/editor-filters-panel.tsx
2405
+ function Oi() {
2406
+ let { state: e, actions: t, source: n } = B(), { t: r } = x(), i = n.status === "ready" ? n.preview : null, a = j(() => i ? oi(i, 224) : null, [i]), { filter: o, filterIntensity: s } = e.edits, c = j(() => ({
2407
+ ...e.edits,
2408
+ filterIntensity: 100,
2409
+ annotations: []
2410
+ }), [e.edits]);
2411
+ return /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F("div", {
2412
+ role: "group",
2413
+ "aria-label": r("material.image-editor.panel.filters", "Filters"),
2414
+ className: "-mx-4 flex snap-x gap-2 overflow-x-auto px-4 pb-1 [scrollbar-width:none] @3xl/image-editor:mx-0 @3xl/image-editor:grid @3xl/image-editor:grid-cols-2 @3xl/image-editor:overflow-visible @3xl/image-editor:px-0",
2415
+ children: Ir.map((e) => /* @__PURE__ */ F(ki, {
2416
+ preset: e,
2417
+ source: a,
2418
+ edits: c,
2419
+ checked: o === e.id,
2420
+ label: r(`material.image-editor.filter.${e.id}`, e.label),
2421
+ onSelect: () => t.setFilter(e.id)
2422
+ }, e.id))
2423
+ }), o !== "none" && /* @__PURE__ */ F(pi, {
2424
+ label: r("material.image-editor.filter-intensity", "Intensity"),
2425
+ min: 0,
2426
+ max: 100,
2427
+ origin: 100,
2428
+ value: s,
2429
+ format: (e) => `${e}%`,
2430
+ onChange: (e) => t.setFilterIntensity(e),
2431
+ onCommit: () => t.endGesture(),
2432
+ onReset: () => t.setFilterIntensity(100)
2433
+ })] });
2434
+ }
2435
+ function ki({ preset: t, source: n, edits: r, checked: i, label: a, onSelect: o }) {
2436
+ let s = M(null);
2437
+ return k(() => {
2438
+ let e = s.current;
2439
+ if (!n || !e) return;
2440
+ let i = requestAnimationFrame(() => {
2441
+ ai(n, r, {
2442
+ scale: 1,
2443
+ region: "crop",
2444
+ filter: t.id,
2445
+ target: e
2446
+ });
2447
+ });
2448
+ return () => cancelAnimationFrame(i);
2449
+ }, [
2450
+ n,
2451
+ r,
2452
+ t.id
2453
+ ]), /* @__PURE__ */ I("button", {
2454
+ type: "button",
2455
+ "aria-pressed": i,
2456
+ "data-filter": t.id,
2457
+ onClick: o,
2458
+ className: "group flex w-22 shrink-0 cursor-pointer snap-start flex-col items-center gap-1.5 rounded-xl p-1 text-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 @3xl/image-editor:w-auto",
2459
+ children: [/* @__PURE__ */ F("span", {
2460
+ className: e("nxgt-image-editor-thumb block aspect-square w-full overflow-hidden rounded-xl bg-muted shadow-sm ring-2 ring-transparent ring-offset-2 ring-offset-card transition-[box-shadow,transform] duration-200 group-hover:-translate-y-0.5 group-hover:ring-foreground/20 motion-reduce:transition-none motion-reduce:group-hover:translate-y-0", i && "ring-primary-indicator group-hover:ring-primary-indicator"),
2461
+ children: /* @__PURE__ */ F("canvas", {
2462
+ ref: s,
2463
+ "aria-hidden": "true"
2464
+ })
2465
+ }), /* @__PURE__ */ F("span", {
2466
+ className: e("max-w-full truncate text-muted-foreground", i && "font-medium text-foreground"),
2467
+ children: a
2468
+ })]
2469
+ });
2470
+ }
2471
+ //#endregion
2472
+ //#region lib/components/ui/media/image-editor/partials/editor-markup-selection.tsx
2473
+ function Ai() {
2474
+ let { selected: e, actions: t } = B(), { t: n } = x();
2475
+ if (!e) return null;
2476
+ let r = e.id;
2477
+ return /* @__PURE__ */ F(Wi, {
2478
+ title: n("material.image-editor.markup.selection", "Selected mark"),
2479
+ children: /* @__PURE__ */ I("div", {
2480
+ className: "flex gap-2",
2481
+ children: [
2482
+ /* @__PURE__ */ F(S, {
2483
+ variant: "tonal",
2484
+ color: "default",
2485
+ tooltip: n("material.image-editor.markup.duplicate", "Duplicate"),
2486
+ onClick: () => t.duplicateAnnotation(r),
2487
+ children: /* @__PURE__ */ F(be, {})
2488
+ }),
2489
+ /* @__PURE__ */ F(S, {
2490
+ variant: "tonal",
2491
+ color: "default",
2492
+ tooltip: n("material.image-editor.markup.to-front", "Bring to front"),
2493
+ onClick: () => t.bringToFront(r),
2494
+ children: /* @__PURE__ */ F(he, {})
2495
+ }),
2496
+ /* @__PURE__ */ F(S, {
2497
+ variant: "tonal",
2498
+ color: "error",
2499
+ tooltip: n("material.image-editor.markup.delete", "Delete"),
2500
+ onClick: () => t.removeAnnotation(r),
2501
+ children: /* @__PURE__ */ F(We, {})
2502
+ })
2503
+ ]
2504
+ })
2505
+ });
2506
+ }
2507
+ //#endregion
2508
+ //#region lib/components/ui/selection/color-swatches/partials/color-swatch-styles.ts
2509
+ var ji = {
2510
+ xs: "size-5 [&_svg]:size-3",
2511
+ sm: "size-7 [&_svg]:size-3.5",
2512
+ md: "size-9 [&_svg]:size-4",
2513
+ lg: "size-11 [&_svg]:size-5"
2514
+ }, Mi = "relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full border border-foreground/15 bg-(--swatch) shadow-xs outline-none transition-[box-shadow,transform] duration-200 hover:scale-110 focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none motion-reduce:hover:scale-100";
2515
+ //#endregion
2516
+ //#region lib/components/ui/selection/color-swatches/partials/color-swatch-button.tsx
2517
+ function Ni({ item: t, size: n, pressed: r, onChoose: i }) {
2518
+ return /* @__PURE__ */ F("button", {
2519
+ type: "button",
2520
+ "aria-pressed": r,
2521
+ "aria-label": dn(t),
2522
+ title: dn(t),
2523
+ "data-color": t.value,
2524
+ ref: (e) => e?.style.setProperty("--swatch", t.value),
2525
+ onClick: () => i(t.value),
2526
+ className: e(Mi, ji[n], r && "ring-2 ring-foreground/80 ring-offset-2 ring-offset-background"),
2527
+ children: r && /* @__PURE__ */ F(ge, {
2528
+ "aria-hidden": "true",
2529
+ strokeWidth: 3,
2530
+ className: un(t.value) ? "text-black/80" : "text-white"
2531
+ })
2532
+ });
2533
+ }
2534
+ //#endregion
2535
+ //#region lib/components/ui/selection/color-swatches/partials/custom-color-swatch.tsx
2536
+ function Pi({ size: t, current: n, listed: r, onChoose: i }) {
2537
+ let { t: a } = x();
2538
+ return /* @__PURE__ */ I("label", {
2539
+ title: a("material.color-swatches.custom", "Custom colour"),
2540
+ className: e(Mi, ji[t], "bg-[conic-gradient(from_90deg,#ef4444,#facc15,#22c55e,#06b6d4,#3b82f6,#8b5cf6,#ec4899,#ef4444)] has-focus-visible:ring-[3px] has-focus-visible:ring-ring/50", n && !r && "ring-2 ring-foreground/80 ring-offset-2 ring-offset-background"),
2541
+ children: [/* @__PURE__ */ F(Pe, {
2542
+ "aria-hidden": "true",
2543
+ strokeWidth: 3,
2544
+ className: "text-white drop-shadow"
2545
+ }), /* @__PURE__ */ F("input", {
2546
+ type: "color",
2547
+ className: "sr-only",
2548
+ "aria-label": a("material.color-swatches.custom", "Custom colour"),
2549
+ value: pn(n),
2550
+ onChange: (e) => i(e.target.value)
2551
+ })]
2552
+ });
2553
+ }
2554
+ //#endregion
2555
+ //#region lib/components/ui/selection/color-swatches/color-swatches.tsx
2556
+ function Fi({ colors: t, value: n, defaultValue: r, onChange: i, label: a, showLabel: o = !1, size: s = "md", custom: c = !1, disabled: l, className: u }) {
2557
+ let { t: d } = x(), [f, p] = N(r), m = n ?? f, h = (e) => {
2558
+ n === void 0 && p(e), i?.(e);
2559
+ }, g = t.map((e) => typeof e == "string" ? { value: e } : e), _ = g.some((e) => fn(e.value, m));
2560
+ return /* @__PURE__ */ I("fieldset", {
2561
+ "data-slot": "color-swatches",
2562
+ "data-size": s,
2563
+ disabled: l,
2564
+ className: e("m-0 min-w-0 border-0 p-0", u),
2565
+ children: [/* @__PURE__ */ F("legend", {
2566
+ className: e(o ? "mb-2 font-medium text-sm" : "sr-only"),
2567
+ children: a ?? d("material.color-swatches.label", "Colour")
2568
+ }), /* @__PURE__ */ I("div", {
2569
+ className: "flex flex-wrap gap-2",
2570
+ children: [g.map((e) => /* @__PURE__ */ F(Ni, {
2571
+ item: e,
2572
+ size: s,
2573
+ pressed: fn(e.value, m),
2574
+ onChoose: h
2575
+ }, e.value)), c && /* @__PURE__ */ F(Pi, {
2576
+ size: s,
2577
+ current: m,
2578
+ listed: _,
2579
+ onChoose: h
2580
+ })]
2581
+ })]
2582
+ });
2583
+ }
2584
+ //#endregion
2585
+ //#region lib/components/ui/media/image-editor/partials/markup-brush-section.tsx
2586
+ var Ii = (e) => Math.round((e - zn) / (Bn - zn) * 99 + 1), Li = (e) => zn + (e - 1) / 99 * (Bn - zn);
2587
+ function Ri() {
2588
+ let { state: e, actions: t, colors: n, selected: r, redactModes: i } = B(), { t: a } = x(), { brush: o, markupTool: s } = e, c = r?.kind ?? s, l = c === "rect" || c === "ellipse";
2589
+ return /* @__PURE__ */ I(Wi, {
2590
+ title: a("material.image-editor.markup.color", "Colour"),
2591
+ children: [
2592
+ /* @__PURE__ */ F(Fi, {
2593
+ colors: n,
2594
+ size: "sm",
2595
+ custom: !0,
2596
+ label: a("material.image-editor.markup.color", "Colour"),
2597
+ value: o.color,
2598
+ onChange: (e) => t.setBrush({ color: e })
2599
+ }),
2600
+ /* @__PURE__ */ F(pi, {
2601
+ label: a("material.image-editor.markup.size", "Size"),
2602
+ min: 1,
2603
+ max: 100,
2604
+ value: Ii(o.size),
2605
+ onChange: (e) => t.setBrush({ size: Li(e) }),
2606
+ onCommit: () => t.endGesture()
2607
+ }),
2608
+ l && /* @__PURE__ */ F(T, {
2609
+ label: a("material.image-editor.markup.fill", "Filled"),
2610
+ checked: o.fill,
2611
+ onCheckedChange: (e) => t.setBrush({ fill: e })
2612
+ }),
2613
+ c === "redact" && i.length > 1 && /* @__PURE__ */ F(T, {
2614
+ label: a("material.image-editor.markup.pixelate", "Pixelate (less safe)"),
2615
+ checked: o.redactMode === "pixelate",
2616
+ onCheckedChange: (e) => t.setBrush({ redactMode: e ? "pixelate" : "solid" })
2617
+ }),
2618
+ c === "text" && /* @__PURE__ */ F(T, {
2619
+ label: a("material.image-editor.markup.background", "Background"),
2620
+ checked: o.background,
2621
+ onCheckedChange: (e) => t.setBrush({ background: e })
2622
+ })
2623
+ ]
2624
+ });
2625
+ }
2626
+ //#endregion
2627
+ //#region lib/components/ui/media/image-editor/partials/markup-tool-picker.tsx
2628
+ function zi() {
2629
+ let { state: e, actions: t, markupTools: n } = B(), { t: r } = x(), { markupTool: i } = e, a = (e, t) => r(`material.image-editor.markup.tool.${e}`, t), o = n ? n.flatMap((e) => Si.filter((t) => t.tool === e)) : Si;
2630
+ return /* @__PURE__ */ F(le, {
2631
+ type: "single",
2632
+ variant: "separate",
2633
+ "aria-label": r("material.image-editor.markup.tools", "Drawing tools"),
2634
+ value: i,
2635
+ onValueChange: (e) => e && t.setMarkupTool(e),
2636
+ className: "grid grid-cols-5 gap-1",
2637
+ children: o.map(({ tool: e, icon: t, label: n }) => /* @__PURE__ */ F(ce, {
2638
+ value: e,
2639
+ "aria-label": a(e, n),
2640
+ title: a(e, n),
2641
+ className: Ci,
2642
+ children: /* @__PURE__ */ F(t, { "aria-hidden": "true" })
2643
+ }, e))
2644
+ });
2645
+ }
2646
+ //#endregion
2647
+ //#region lib/components/ui/media/image-editor/partials/editor-markup-panel.tsx
2648
+ function Bi() {
2649
+ let { state: e, actions: t } = B(), { t: n } = x();
2650
+ return /* @__PURE__ */ I(P, { children: [
2651
+ /* @__PURE__ */ F(zi, {}),
2652
+ /* @__PURE__ */ F(Ri, {}),
2653
+ /* @__PURE__ */ F(Ai, {}),
2654
+ /* @__PURE__ */ F(b, {
2655
+ variant: "tonal",
2656
+ color: "error",
2657
+ size: "sm",
2658
+ className: "self-start",
2659
+ disabled: e.edits.annotations.length === 0,
2660
+ onClick: () => t.clearAnnotations(),
2661
+ children: n("material.image-editor.markup.clear", "Remove all marks")
2662
+ })
2663
+ ] });
2664
+ }
2665
+ //#endregion
2666
+ //#region lib/components/ui/media/image-editor/partials/editor-panel.tsx
2667
+ var Vi = {
2668
+ adjust: "Adjust",
2669
+ filters: "Filters",
2670
+ crop: "Crop & rotate",
2671
+ markup: "Markup"
2672
+ }, Hi = {
2673
+ adjust: yi,
2674
+ filters: Oi,
2675
+ crop: Di,
2676
+ markup: Bi
2677
+ };
2678
+ function Ui() {
2679
+ let { state: e, source: t } = B(), { t: n } = x(), r = A();
2680
+ if (t.status !== "ready") return null;
2681
+ let i = Hi[e.tool];
2682
+ return /* @__PURE__ */ I("section", {
2683
+ "aria-labelledby": r,
2684
+ "data-slot": "image-editor-panel",
2685
+ "data-tool": e.tool,
2686
+ className: "flex max-h-[42%] min-h-0 shrink-0 flex-col overflow-y-auto border-t bg-card @3xl/image-editor:max-h-none @3xl/image-editor:w-80 @3xl/image-editor:border-t-0 @3xl/image-editor:border-l",
2687
+ children: [/* @__PURE__ */ F(ee, {
2688
+ id: r,
2689
+ variant: "title-small",
2690
+ className: "sticky top-0 z-10 bg-card px-4 pt-3 pb-2",
2691
+ children: n(`material.image-editor.panel.${e.tool}`, Vi[e.tool])
2692
+ }), /* @__PURE__ */ F("div", {
2693
+ className: "flex flex-col gap-5 px-4 pb-4",
2694
+ children: /* @__PURE__ */ F(i, {})
2695
+ })]
2696
+ });
2697
+ }
2698
+ function Wi({ title: e, action: t, children: n }) {
2699
+ let r = A();
2700
+ return /* @__PURE__ */ I("section", {
2701
+ "aria-labelledby": r,
2702
+ className: "flex flex-col gap-3",
2703
+ children: [/* @__PURE__ */ I("div", {
2704
+ className: "flex min-h-8 items-center justify-between gap-2",
2705
+ children: [/* @__PURE__ */ F(ee, {
2706
+ id: r,
2707
+ variant: "body-small",
2708
+ className: "font-medium text-muted-foreground uppercase tracking-wide",
2709
+ children: e
2710
+ }), t]
2711
+ }), n]
2712
+ });
2713
+ }
2714
+ //#endregion
2715
+ //#region lib/components/ui/media/image-editor/use-stage-fit.ts
2716
+ var Gi = (e) => e === "crop" ? "full" : "crop", Ki = {
2717
+ x: 0,
2718
+ y: 0,
2719
+ w: 1,
2720
+ h: 1
2721
+ }, qi = (e, t) => Gi(e) === "crop" ? t : Ki, Ji = 24, Yi = 80, Xi = 216, Zi = 2;
2722
+ function Qi(e, t, n, r, i = !1) {
2723
+ let [a, o] = N(null);
2724
+ k(() => {
2725
+ let t = e.current;
2726
+ if (!t) return;
2727
+ let n = i ? Xi : Yi;
2728
+ t.style.setProperty("--stage-dock", `${n}px`);
2729
+ let r = () => o({
2730
+ width: Math.max(1, t.clientWidth - Ji * 2),
2731
+ height: Math.max(1, t.clientHeight - Ji - n)
2732
+ });
2733
+ r();
2734
+ let a = new ResizeObserver(r);
2735
+ return a.observe(t), () => a.disconnect();
2736
+ }, [e, i]);
2737
+ let s = a && t && t.width > 0 && t.height > 0 ? Math.min(Zi, a.width / t.width, a.height / t.height) : 1;
2738
+ r.fitRef.current = s;
2739
+ let c = C(r.zoomBy);
2740
+ return k(() => {
2741
+ let t = e.current;
2742
+ if (!t) return;
2743
+ let n = (e) => {
2744
+ !e.ctrlKey && !e.metaKey || (e.preventDefault(), c.current(Math.exp(-e.deltaY * .01)));
2745
+ };
2746
+ return t.addEventListener("wheel", n, { passive: !1 }), () => t.removeEventListener("wheel", n);
2747
+ }, [e, c]), n ?? s;
2748
+ }
2749
+ //#endregion
2750
+ //#region lib/components/ui/media/image-editor/image-editor.stage-paint.ts
2751
+ var $i = 4096;
2752
+ function ea(e, t, n, r) {
2753
+ let i = q(e, t.transform.quarterTurns), a = n === "crop" ? t.crop : {
2754
+ w: 1,
2755
+ h: 1
2756
+ }, o = a.w * i.width, s = Math.max(o, a.h * i.height), c = r * (typeof window > "u" ? 1 : window.devicePixelRatio || 1) / o;
2757
+ return Math.max(.01, Math.min(1, c, $i / s));
2758
+ }
2759
+ function ta(e, t, n, r) {
2760
+ if (r <= 0) return 0;
2761
+ let i = q(e, t.transform.quarterTurns);
2762
+ return 24 * ((n === "crop" ? t.crop.w : 1) * i.width) / r;
2763
+ }
2764
+ function na(e, t, n) {
2765
+ let r = ur(t, n), i = 6 / e.getTransform().a;
2766
+ e.save(), e.lineWidth = 1.5 / e.getTransform().a, e.setLineDash([6 / e.getTransform().a, 4 / e.getTransform().a]), e.strokeStyle = "#ffffff", e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 3, e.strokeRect(r.x * n.width - i, r.y * n.height - i, r.w * n.width + i * 2, r.h * n.height + i * 2), e.restore();
2767
+ }
2768
+ function ra(e, t, n, r, i) {
2769
+ let { source: a, edits: o, region: s, scale: c, comparing: l, hiddenId: u, selectedId: d, stepFloor: f } = r;
2770
+ if (e.width !== t.width && (e.width = t.width), e.height !== t.height && (e.height = t.height), n.setTransform(1, 0, 0, 1, 0, 0), n.clearRect(0, 0, e.width, e.height), n.drawImage(t, 0, 0), l) return;
2771
+ let p = hr(o.annotations, u), m = i ? [...p.filter((e) => e.id !== i.id), i] : p;
2772
+ ii(n, a, {
2773
+ ...o,
2774
+ annotations: m
2775
+ }, {
2776
+ scale: c,
2777
+ region: s,
2778
+ stepFloor: f
2779
+ });
2780
+ let h = p.find((e) => e.id === d);
2781
+ if (!h) return;
2782
+ let g = {
2783
+ ...q(a, o.transform.quarterTurns),
2784
+ stepFloor: f
2785
+ }, _ = s === "crop" ? o.crop : {
2786
+ x: 0,
2787
+ y: 0
2788
+ };
2789
+ n.setTransform(c, 0, 0, c, -_.x * g.width * c, -_.y * g.height * c), na(n, h, g);
2790
+ }
2791
+ //#endregion
2792
+ //#region lib/components/ui/media/image-editor/use-stage-layer-key.ts
2793
+ function ia(e, t, n, r) {
2794
+ let { adjustments: i, filter: a, filterIntensity: o, transform: s, crop: c } = e;
2795
+ return j(() => JSON.stringify([
2796
+ i,
2797
+ a,
2798
+ o,
2799
+ s,
2800
+ t === "crop" ? c : null,
2801
+ t,
2802
+ n.toFixed(4),
2803
+ r
2804
+ ]), [
2805
+ i,
2806
+ a,
2807
+ o,
2808
+ s,
2809
+ c,
2810
+ t,
2811
+ n,
2812
+ r
2813
+ ]);
2814
+ }
2815
+ //#endregion
2816
+ //#region lib/components/ui/media/image-editor/use-stage-render.ts
2817
+ function aa({ canvasRef: e, source: t, edits: n, region: r, displayWidth: i, comparing: a, selectedId: o, hiddenId: s = null, active: c = !0, mountKey: l }) {
2818
+ let u = M(null), d = M(0), f = ea(t, n, r, i), p = ta(t, n, r, i), m = ia(n, r, f, a), h = O((i) => {
2819
+ let c = e.current, l = u.current, d = c?.getContext("2d");
2820
+ !c || !l || !d || ra(c, l, d, {
2821
+ source: t,
2822
+ edits: n,
2823
+ region: r,
2824
+ scale: f,
2825
+ comparing: a,
2826
+ hiddenId: s,
2827
+ selectedId: o,
2828
+ stepFloor: p
2829
+ }, i);
2830
+ }, [
2831
+ e,
2832
+ a,
2833
+ n,
2834
+ p,
2835
+ s,
2836
+ r,
2837
+ f,
2838
+ o,
2839
+ t
2840
+ ]);
2841
+ return k(() => {
2842
+ if (cancelAnimationFrame(d.current), c) return d.current = requestAnimationFrame(() => {
2843
+ u.current = ai(t, n, {
2844
+ scale: f,
2845
+ region: r,
2846
+ edited: !a,
2847
+ marks: !1,
2848
+ target: u.current ?? void 0
2849
+ }), h();
2850
+ }), () => cancelAnimationFrame(d.current);
2851
+ }, [
2852
+ m,
2853
+ t,
2854
+ c
2855
+ ]), k(() => {
2856
+ c && h();
2857
+ }, [
2858
+ h,
2859
+ c,
2860
+ l
2861
+ ]), {
2862
+ paint: h,
2863
+ scale: f
2864
+ };
2865
+ }
2866
+ //#endregion
2867
+ //#region lib/components/ui/media/image-editor/use-crop-frame.ts
2868
+ function oa({ crop: e, base: t, ratio: n, actions: r }) {
2869
+ let i = M(null), a = M(null), [o, s] = N(!1), [c, l] = N(!1), u = M(void 0);
2870
+ return k(() => () => clearTimeout(u.current), []), {
2871
+ layerRef: i,
2872
+ dragging: o,
2873
+ keying: c,
2874
+ setKeying: l,
2875
+ begin: (t) => (n) => {
2876
+ n.button === 0 && (n.stopPropagation(), n.currentTarget.setPointerCapture?.(n.pointerId), a.current = {
2877
+ handle: t,
2878
+ x: n.clientX,
2879
+ y: n.clientY,
2880
+ crop: e,
2881
+ gesture: `crop:${Date.now()}`
2882
+ }, s(!0));
2883
+ },
2884
+ onPointerMove: (e) => {
2885
+ let o = a.current, s = i.current?.getBoundingClientRect();
2886
+ if (!o || !s) return;
2887
+ let c = (e.clientX - o.x) / Math.max(1, s.width), l = (e.clientY - o.y) / Math.max(1, s.height), u = rr(o.crop, o.handle, c, l, n, t);
2888
+ r.setCrop({
2889
+ rect: u,
2890
+ gesture: o.gesture
2891
+ });
2892
+ },
2893
+ end: () => {
2894
+ a.current && (a.current = null, s(!1), r.endGesture());
2895
+ },
2896
+ onKeyDown: (i) => {
2897
+ let a = .01, o = {
2898
+ ArrowLeft: [-.01, 0],
2899
+ ArrowRight: [a, 0],
2900
+ ArrowUp: [0, -.01],
2901
+ ArrowDown: [0, a]
2902
+ }[i.key];
2903
+ if (!o) return;
2904
+ i.preventDefault(), l(!0), clearTimeout(u.current), u.current = setTimeout(() => l(!1), 800);
2905
+ let s = i.shiftKey ? "se" : "move", c = rr(e, s, o[0], o[1], n, t);
2906
+ r.setCrop({
2907
+ rect: c,
2908
+ gesture: `crop-key:${s}`
2909
+ });
2910
+ }
2911
+ };
2912
+ }
2913
+ //#endregion
2914
+ //#region lib/components/ui/media/image-editor/partials/crop-handles.ts
2915
+ var sa = [
2916
+ {
2917
+ handle: "nw",
2918
+ className: "top-0 left-0 cursor-nwse-resize rounded-tl-[3px] border-t-[3px] border-l-[3px]"
2919
+ },
2920
+ {
2921
+ handle: "ne",
2922
+ className: "top-0 right-0 cursor-nesw-resize rounded-tr-[3px] border-t-[3px] border-r-[3px]"
2923
+ },
2924
+ {
2925
+ handle: "sw",
2926
+ className: "bottom-0 left-0 cursor-nesw-resize rounded-bl-[3px] border-b-[3px] border-l-[3px]"
2927
+ },
2928
+ {
2929
+ handle: "se",
2930
+ className: "right-0 bottom-0 cursor-nwse-resize rounded-br-[3px] border-r-[3px] border-b-[3px]"
2931
+ },
2932
+ {
2933
+ handle: "n",
2934
+ className: "top-0 left-1/2 h-[3px] w-6 -translate-x-1/2 cursor-ns-resize rounded-full bg-white"
2935
+ },
2936
+ {
2937
+ handle: "s",
2938
+ className: "bottom-0 left-1/2 h-[3px] w-6 -translate-x-1/2 cursor-ns-resize rounded-full bg-white"
2939
+ },
2940
+ {
2941
+ handle: "w",
2942
+ className: "top-1/2 left-0 h-6 w-[3px] -translate-y-1/2 cursor-ew-resize rounded-full bg-white"
2943
+ },
2944
+ {
2945
+ handle: "e",
2946
+ className: "top-1/2 right-0 h-6 w-[3px] -translate-y-1/2 cursor-ew-resize rounded-full bg-white"
2947
+ }
2948
+ ];
2949
+ //#endregion
2950
+ //#region lib/components/ui/media/image-editor/partials/crop-readout.tsx
2951
+ function ca({ crop: e, base: t, polite: n }) {
2952
+ return /* @__PURE__ */ I("output", {
2953
+ "data-slot": "image-editor-crop-readout",
2954
+ "aria-live": n ? "polite" : "off",
2955
+ className: "nxgt-image-editor-glass pointer-events-none absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 whitespace-nowrap rounded-full px-2.5 py-1 font-medium text-xs tabular-nums",
2956
+ children: [
2957
+ Math.round(e.w * t.width),
2958
+ " × ",
2959
+ Math.round(e.h * t.height)
2960
+ ]
2961
+ });
2962
+ }
2963
+ //#endregion
2964
+ //#region lib/components/ui/media/image-editor/partials/editor-crop-overlay.tsx
2965
+ var la = (e) => `${e * 100}%`;
2966
+ function ua() {
2967
+ let { base: e } = B();
2968
+ return e ? /* @__PURE__ */ F(da, { base: e }) : null;
2969
+ }
2970
+ function da({ base: t }) {
2971
+ let { state: n, actions: r, lockedAspect: i } = B(), { t: a } = x(), o = A(), s = n.edits.crop, c = i ?? n.aspect, { layerRef: l, dragging: u, keying: d, setKeying: f, begin: p, onPointerMove: m, end: h, onKeyDown: g } = oa({
2972
+ crop: s,
2973
+ base: t,
2974
+ ratio: c === "original" ? t.width / t.height : c ?? null,
2975
+ actions: r
2976
+ });
2977
+ return /* @__PURE__ */ F("div", {
2978
+ ref: l,
2979
+ "data-slot": "image-editor-crop-layer",
2980
+ className: "absolute inset-0 overflow-hidden",
2981
+ onPointerMove: m,
2982
+ onPointerUp: h,
2983
+ onPointerCancel: h,
2984
+ children: /* @__PURE__ */ I("div", {
2985
+ role: "group",
2986
+ tabIndex: 0,
2987
+ "aria-label": a("material.image-editor.crop.frame", "Crop area"),
2988
+ "aria-describedby": o,
2989
+ "data-slot": "image-editor-crop",
2990
+ "data-dragging": u || void 0,
2991
+ className: "nxgt-image-editor-crop absolute cursor-move outline-offset-2 focus-visible:outline-[3px] focus-visible:outline-ring/60",
2992
+ style: {
2993
+ left: la(s.x),
2994
+ top: la(s.y),
2995
+ width: la(s.w),
2996
+ height: la(s.h)
2997
+ },
2998
+ onPointerDown: p("move"),
2999
+ onKeyDown: g,
3000
+ onKeyUp: () => f(!1),
3001
+ onBlur: () => {
3002
+ f(!1), r.endGesture();
3003
+ },
3004
+ children: [
3005
+ /* @__PURE__ */ F("span", {
3006
+ id: o,
3007
+ className: "sr-only",
3008
+ children: a("material.image-editor.crop.frame-hint", "Arrows move it, Shift + arrows resize it")
3009
+ }),
3010
+ /* @__PURE__ */ F("div", { className: "nxgt-image-editor-crop-grid pointer-events-none absolute inset-0" }),
3011
+ (u || d) && /* @__PURE__ */ F(ca, {
3012
+ crop: s,
3013
+ base: t,
3014
+ polite: d && !u
3015
+ }),
3016
+ sa.map(({ handle: t, className: n }) => /* @__PURE__ */ F("span", {
3017
+ "aria-hidden": "true",
3018
+ "data-handle": t,
3019
+ onPointerDown: p(t),
3020
+ className: e("absolute border-white drop-shadow-[0_0_2px_rgb(0_0_0/0.45)] before:absolute before:-inset-3 before:content-['']", t.length === 2 && "size-5", n)
3021
+ }, t))
3022
+ ]
3023
+ })
3024
+ });
3025
+ }
3026
+ //#endregion
3027
+ //#region lib/components/ui/media/image-editor/partials/editor-crop-strip.tsx
3028
+ function fa() {
3029
+ let { state: e, actions: t, lockedAspect: n, aspectPresets: r } = B(), { t: i } = x(), { transform: a, crop: o } = e.edits, s = o.x === U.x && o.y === U.y && o.w === U.w && o.h === U.h, c = n === void 0 && r.length > 0;
3030
+ return /* @__PURE__ */ I("section", {
3031
+ "aria-label": i("material.image-editor.panel.crop", "Crop & rotate"),
3032
+ "data-slot": "image-editor-crop-card",
3033
+ className: "pointer-events-auto flex w-full max-w-3xl flex-col gap-2 rounded-2xl border bg-card p-2 shadow-lg",
3034
+ children: [/* @__PURE__ */ I("div", {
3035
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1",
3036
+ children: [/* @__PURE__ */ F(Ei, { compact: !0 }), /* @__PURE__ */ F(S, {
3037
+ variant: "tonal",
3038
+ color: "default",
3039
+ tooltip: i("material.image-editor.crop.reset", "Reset crop & rotation"),
3040
+ disabled: ar(a) && s,
3041
+ onClick: () => t.resetTransform(),
3042
+ children: /* @__PURE__ */ F(Ie, {})
3043
+ })]
3044
+ }), c && /* @__PURE__ */ F("div", {
3045
+ className: "hidden @md:block",
3046
+ children: /* @__PURE__ */ F(wi, { compact: !0 })
3047
+ })]
3048
+ });
3049
+ }
3050
+ //#endregion
3051
+ //#region lib/components/ui/media/image-editor/partials/use-scroll-edges.ts
3052
+ function pa(e) {
3053
+ let [t, n] = N({
3054
+ start: !1,
3055
+ end: !1
3056
+ });
3057
+ return k(() => {
3058
+ let t = e.current;
3059
+ if (!t) return;
3060
+ let r = () => {
3061
+ let e = t.scrollLeft > 1, r = t.scrollLeft + t.clientWidth < t.scrollWidth - 1;
3062
+ n((t) => t.start === e && t.end === r ? t : {
3063
+ start: e,
3064
+ end: r
3065
+ });
3066
+ };
3067
+ r(), t.addEventListener("scroll", r, { passive: !0 });
3068
+ let i = new ResizeObserver(r);
3069
+ i.observe(t);
3070
+ for (let e of Array.from(t.children)) i.observe(e);
3071
+ return () => {
3072
+ t.removeEventListener("scroll", r), i.disconnect();
3073
+ };
3074
+ }, [e]), t;
3075
+ }
3076
+ function ma({ start: e, end: t }) {
3077
+ if (!e && !t) return;
3078
+ let n = `linear-gradient(to right, ${e ? "transparent" : "#000"}, #000 28px, #000 calc(100% - 28px), ${t ? "transparent" : "#000"})`;
3079
+ return {
3080
+ maskImage: n,
3081
+ WebkitMaskImage: n
3082
+ };
3083
+ }
3084
+ //#endregion
3085
+ //#region lib/components/ui/media/image-editor/partials/editor-floating-toolbar.tsx
3086
+ function ha({ label: t, icon: n, showLabel: r, className: i, ...a }) {
3087
+ return /* @__PURE__ */ I("button", {
3088
+ type: "button",
3089
+ "aria-label": t,
3090
+ title: t,
3091
+ className: e("inline-flex h-10 min-w-10 shrink-0 cursor-pointer items-center justify-center gap-2 rounded-full text-white/85 outline-none transition-[background-color,color,padding] hover:bg-white/10 hover:text-white focus-visible:ring-[3px] focus-visible:ring-white/50 disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-primary aria-pressed:text-primary-foreground [&_svg]:size-[18px]", r ? "px-4" : "px-0", i),
3092
+ ...a,
3093
+ children: [n, r && /* @__PURE__ */ F("span", {
3094
+ "aria-hidden": "true",
3095
+ className: "font-medium text-sm",
3096
+ children: t
3097
+ })]
3098
+ });
3099
+ }
3100
+ var ga = () => /* @__PURE__ */ F("span", {
3101
+ "aria-hidden": "true",
3102
+ className: "mx-1 h-5 w-px shrink-0 bg-white/15"
3103
+ });
3104
+ function _a() {
3105
+ let { state: e, actions: t, tools: n, markupTools: r } = B(), { t: i } = x(), a = r ? r.flatMap((e) => Si.filter((t) => t.tool === e)) : Si;
3106
+ return /* @__PURE__ */ I(P, { children: [n.includes("crop") && /* @__PURE__ */ F(ha, {
3107
+ label: i("material.image-editor.tool.crop", "Crop"),
3108
+ icon: /* @__PURE__ */ F(xe, { "aria-hidden": "true" }),
3109
+ showLabel: e.tool === "crop",
3110
+ "aria-pressed": e.tool === "crop",
3111
+ onClick: () => t.setTool("crop")
3112
+ }), n.includes("markup") && a.map(({ tool: n, icon: r, label: a }) => {
3113
+ let o = e.tool === "markup" && e.markupTool === n;
3114
+ return /* @__PURE__ */ F(ha, {
3115
+ label: i(`material.image-editor.markup.tool.${n}`, a),
3116
+ icon: /* @__PURE__ */ F(r, { "aria-hidden": "true" }),
3117
+ showLabel: o,
3118
+ "aria-pressed": o,
3119
+ onClick: () => {
3120
+ t.setTool("markup"), t.setMarkupTool(n);
3121
+ }
3122
+ }, n);
3123
+ })] });
3124
+ }
3125
+ function va() {
3126
+ let { actions: e, selected: t, canUndo: n, canRedo: r } = B(), { t: i } = x();
3127
+ return /* @__PURE__ */ I(P, { children: [
3128
+ t && /* @__PURE__ */ F(ha, {
3129
+ label: i("material.image-editor.markup.delete", "Delete"),
3130
+ icon: /* @__PURE__ */ F(We, { "aria-hidden": "true" }),
3131
+ onClick: () => e.removeAnnotation(t.id)
3132
+ }),
3133
+ /* @__PURE__ */ F(ha, {
3134
+ label: i("material.image-editor.undo", "Undo"),
3135
+ icon: /* @__PURE__ */ F(Ke, { "aria-hidden": "true" }),
3136
+ disabled: !n,
3137
+ onClick: () => e.undo()
3138
+ }),
3139
+ /* @__PURE__ */ F(ha, {
3140
+ label: i("material.image-editor.redo", "Redo"),
3141
+ icon: /* @__PURE__ */ F(Fe, { "aria-hidden": "true" }),
3142
+ disabled: !r,
3143
+ onClick: () => e.redo()
3144
+ })
3145
+ ] });
3146
+ }
3147
+ function ya() {
3148
+ let { source: e } = B();
3149
+ return e.status === "ready" ? /* @__PURE__ */ F(ba, {}) : null;
3150
+ }
3151
+ function ba() {
3152
+ let { state: e, actions: t, tools: n, colors: r } = B(), { t: i } = x(), a = M(null), o = pa(a);
3153
+ return /* @__PURE__ */ I("div", {
3154
+ ref: a,
3155
+ role: "toolbar",
3156
+ "aria-label": i("material.image-editor.floating-tools", "Editing tools"),
3157
+ style: ma(o),
3158
+ "data-slot": "image-editor-floating-toolbar",
3159
+ className: "nxgt-image-editor-glass dark pointer-events-auto flex max-w-full items-center gap-1 overflow-x-auto rounded-full p-1.5",
3160
+ children: [
3161
+ /* @__PURE__ */ F(_a, {}),
3162
+ n.includes("markup") && /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(ga, {}), /* @__PURE__ */ F(Fi, {
3163
+ colors: r.slice(0, 5),
3164
+ size: "xs",
3165
+ custom: !0,
3166
+ className: "shrink-0 px-1",
3167
+ label: i("material.image-editor.markup.color", "Colour"),
3168
+ value: e.brush.color,
3169
+ onChange: (e) => t.setBrush({ color: e })
3170
+ })] }),
3171
+ /* @__PURE__ */ F(ga, {}),
3172
+ /* @__PURE__ */ F(va, {})
3173
+ ]
3174
+ });
3175
+ }
3176
+ //#endregion
3177
+ //#region lib/components/ui/media/image-editor/use-markup-text.ts
3178
+ function xa() {
3179
+ let { state: e, actions: t } = B(), [n, r] = N(null), { brush: i, edits: a } = e, o = n?.id ?? null, { setEditingId: s } = t;
3180
+ return k(() => (s(o), () => s(null)), [o, s]), {
3181
+ draft: n,
3182
+ setDraft: r,
3183
+ commitText: (e) => {
3184
+ let o = n;
3185
+ if (r(null), !o) return;
3186
+ let s = a.annotations.find((e) => e.id === o.id);
3187
+ e.trim() ? s?.kind === "text" ? s.text !== e && t.updateAnnotation({ annotation: {
3188
+ ...s,
3189
+ text: e
3190
+ } }) : t.addAnnotation({
3191
+ id: mr(),
3192
+ kind: "text",
3193
+ x: o.x,
3194
+ y: o.y,
3195
+ text: e,
3196
+ color: i.color,
3197
+ size: i.size,
3198
+ background: i.background
3199
+ }) : s && t.removeAnnotation(s.id);
3200
+ }
3201
+ };
3202
+ }
3203
+ //#endregion
3204
+ //#region lib/components/ui/media/image-editor/image-editor.stage-gestures.ts
3205
+ function Sa(e, t, n) {
3206
+ let r = {
3207
+ id: mr(),
3208
+ color: n.color,
3209
+ size: n.size
3210
+ };
3211
+ return e === "pen" || e === "highlighter" ? {
3212
+ ...r,
3213
+ kind: e,
3214
+ points: [t.x, t.y]
3215
+ } : e === "line" || e === "arrow" ? {
3216
+ ...r,
3217
+ kind: e,
3218
+ x1: t.x,
3219
+ y1: t.y,
3220
+ x2: t.x,
3221
+ y2: t.y
3222
+ } : e === "rect" || e === "ellipse" ? {
3223
+ ...r,
3224
+ kind: e,
3225
+ x: t.x,
3226
+ y: t.y,
3227
+ w: 0,
3228
+ h: 0,
3229
+ fill: n.fill
3230
+ } : e === "redact" ? {
3231
+ ...r,
3232
+ color: "#000000",
3233
+ kind: "redact",
3234
+ mode: n.redactMode,
3235
+ x: t.x,
3236
+ y: t.y,
3237
+ w: 0,
3238
+ h: 0
3239
+ } : null;
3240
+ }
3241
+ function Ca(e, t) {
3242
+ return {
3243
+ id: mr(),
3244
+ kind: "step",
3245
+ color: t.color,
3246
+ size: t.size,
3247
+ x: e.x,
3248
+ y: e.y,
3249
+ n: 0
3250
+ };
3251
+ }
3252
+ function wa(e, t, n) {
3253
+ switch (e.kind) {
3254
+ case "pen":
3255
+ case "highlighter": return {
3256
+ ...e,
3257
+ points: [
3258
+ ...e.points,
3259
+ n.x,
3260
+ n.y
3261
+ ]
3262
+ };
3263
+ case "line":
3264
+ case "arrow": return {
3265
+ ...e,
3266
+ x2: n.x,
3267
+ y2: n.y
3268
+ };
3269
+ case "rect":
3270
+ case "ellipse":
3271
+ case "redact": return {
3272
+ ...e,
3273
+ ...$n(t.x, t.y, n.x, n.y)
3274
+ };
3275
+ default: return e;
3276
+ }
3277
+ }
3278
+ function Ta(e) {
3279
+ return e.kind === "line" || e.kind === "arrow" ? Math.hypot(e.x2 - e.x1, e.y2 - e.y1) > .005 : e.kind === "rect" || e.kind === "ellipse" || e.kind === "redact" ? e.w > .005 && e.h > .005 : !0;
3280
+ }
3281
+ function Ea(e, t) {
3282
+ if (e.tool === "select") {
3283
+ let n = X(e.annotations, t.x, t.y, e.base);
3284
+ return e.select(n?.id ?? null), n ? {
3285
+ kind: "move",
3286
+ id: n.id,
3287
+ last: t,
3288
+ gesture: `move:${n.id}:${Date.now()}`
3289
+ } : null;
3290
+ }
3291
+ if (e.tool === "eraser") {
3292
+ let n = X(e.annotations, t.x, t.y, e.base);
3293
+ return n && e.remove(n.id), { kind: "erase" };
3294
+ }
3295
+ if (e.tool === "text") {
3296
+ let n = X(e.annotations, t.x, t.y, e.base);
3297
+ return {
3298
+ kind: "text",
3299
+ at: t,
3300
+ mark: n?.kind === "text" ? n : void 0
3301
+ };
3302
+ }
3303
+ if (e.tool === "step") {
3304
+ let n = X(e.annotations, t.x, t.y, e.base);
3305
+ return n?.kind === "step" ? (e.select(n.id), {
3306
+ kind: "move",
3307
+ id: n.id,
3308
+ last: t,
3309
+ gesture: `move:${n.id}:${Date.now()}`
3310
+ }) : (e.add(Ca(t, e.brush)), { kind: "place" });
3311
+ }
3312
+ let n = Sa(e.tool, t, e.brush);
3313
+ return n ? {
3314
+ kind: "draw",
3315
+ mark: n,
3316
+ start: t
3317
+ } : null;
3318
+ }
3319
+ //#endregion
3320
+ //#region lib/components/ui/media/image-editor/use-stage-pointer.ts
3321
+ function Da(e) {
3322
+ let t = M(null), n = e, r = (e) => {
3323
+ let t = e.currentTarget.getBoundingClientRect(), r = (e.clientX - t.left) / Math.max(1, t.width), i = (e.clientY - t.top) / Math.max(1, t.height);
3324
+ return {
3325
+ x: n.view.x + r * n.view.w,
3326
+ y: n.view.y + i * n.view.h
3327
+ };
3328
+ }, i = (e) => {
3329
+ let t = X(n.annotations, e.x, e.y, n.base);
3330
+ t && n.remove(t.id);
3331
+ }, a = (e) => {
3332
+ if (e.button !== 0) return;
3333
+ let i = r(e);
3334
+ e.currentTarget.setPointerCapture?.(e.pointerId), t.current = Ea(n, i);
3335
+ }, o = (e) => {
3336
+ let a = t.current;
3337
+ if (!a || a.kind === "text" || a.kind === "place") return;
3338
+ let o = r(e);
3339
+ a.kind === "erase" ? i(o) : a.kind === "move" ? (n.move(a.id, o.x - a.last.x, o.y - a.last.y, a.gesture), a.last = o) : (a.mark = wa(a.mark, a.start, o), n.paint(a.mark));
3340
+ }, s = (e) => {
3341
+ let r = t.current;
3342
+ t.current = null, r?.kind === "text" && e.type === "pointerup" && n.editText(r.at, r.mark), r?.kind === "draw" && Ta(r.mark) ? n.add(r.mark) : r?.kind === "draw" && n.paint(), r?.kind === "move" && n.endGesture();
3343
+ };
3344
+ return {
3345
+ onPointerDown: a,
3346
+ onPointerMove: o,
3347
+ onPointerUp: s,
3348
+ onPointerCancel: s,
3349
+ onDoubleClick: (e) => {
3350
+ if (n.tool !== "select") return;
3351
+ let t = r(e), i = X(n.annotations, t.x, t.y, n.base);
3352
+ i?.kind === "text" && n.editText({
3353
+ x: i.x,
3354
+ y: i.y
3355
+ }, i);
3356
+ }
3357
+ };
3358
+ }
3359
+ //#endregion
3360
+ //#region lib/components/ui/media/image-editor/partials/editor-text-box.tsx
3361
+ var Oa = (e) => `${e * 100}%`;
3362
+ function ka({ draft: t, view: n, base: r, scale: i, onCommit: a, onCancel: o }) {
3363
+ let { t: s } = x(), [c, l] = N(t.text), u = M(null), d = M(!1), f = lr(t.size, r) * i, p = c.split("\n");
3364
+ k(() => {
3365
+ u.current?.focus();
3366
+ }, []);
3367
+ let m = () => {
3368
+ d.current || (d.current = !0, a(c));
3369
+ };
3370
+ return /* @__PURE__ */ F("textarea", {
3371
+ ref: u,
3372
+ "data-slot": "image-editor-text-box",
3373
+ "aria-label": s("material.image-editor.markup.text-field", "Text"),
3374
+ value: c,
3375
+ rows: p.length,
3376
+ cols: Math.max(4, ...p.map((e) => e.length + 1)),
3377
+ onChange: (e) => l(e.target.value),
3378
+ onPointerDown: (e) => e.stopPropagation(),
3379
+ onBlur: m,
3380
+ onKeyDown: (e) => {
3381
+ e.stopPropagation(), e.key === "Escape" ? (d.current = !0, o()) : e.key === "Enter" && !e.shiftKey && (e.preventDefault(), m());
3382
+ },
3383
+ className: e("absolute z-10 resize-none overflow-hidden rounded-sm border border-white/80 border-dashed p-0 font-semibold leading-tight outline-none ring-2 ring-black/40", Ar(t.color) ? "bg-black/55" : "bg-white/85"),
3384
+ style: {
3385
+ left: Oa((t.x - n.x) / n.w),
3386
+ top: Oa((t.y - n.y) / n.h),
3387
+ color: t.color,
3388
+ fontSize: f,
3389
+ fontFamily: "Inter, \"Segoe UI\", system-ui, sans-serif"
3390
+ }
3391
+ });
3392
+ }
3393
+ //#endregion
3394
+ //#region lib/components/ui/media/image-editor/partials/editor-markup-layer.tsx
3395
+ var Aa = {
3396
+ select: "cursor-default",
3397
+ pen: "cursor-crosshair",
3398
+ highlighter: "cursor-crosshair",
3399
+ eraser: "cursor-cell",
3400
+ line: "cursor-crosshair",
3401
+ arrow: "cursor-crosshair",
3402
+ rect: "cursor-crosshair",
3403
+ ellipse: "cursor-crosshair",
3404
+ text: "cursor-text",
3405
+ step: "cursor-crosshair",
3406
+ redact: "cursor-crosshair"
3407
+ }, ja = "[data-slot=\"image-editor-text-box\"]";
3408
+ function Ma({ paint: t }) {
3409
+ let { state: n, actions: r, base: i, view: a, scale: o } = B(), { draft: s, setDraft: c, commitText: l } = xa(), u = M(null), { brush: d, markupTool: f, edits: p } = n, m = Da({
3410
+ tool: f,
3411
+ brush: d,
3412
+ base: {
3413
+ ...i ?? {
3414
+ width: 1,
3415
+ height: 1
3416
+ },
3417
+ stepFloor: 24 / o
3418
+ },
3419
+ view: a,
3420
+ annotations: p.annotations,
3421
+ paint: t,
3422
+ add: r.addAnnotation,
3423
+ remove: r.removeAnnotation,
3424
+ move: (e, t, n, i) => r.moveAnnotation({
3425
+ id: e,
3426
+ dx: t,
3427
+ dy: n,
3428
+ gesture: i
3429
+ }),
3430
+ select: r.selectAnnotation,
3431
+ endGesture: r.endGesture,
3432
+ editText: (e, t) => c(t?.kind === "text" ? {
3433
+ ...t,
3434
+ id: t.id
3435
+ } : {
3436
+ ...e,
3437
+ text: "",
3438
+ color: d.color,
3439
+ size: d.size
3440
+ })
3441
+ });
3442
+ return i ? /* @__PURE__ */ F("div", {
3443
+ ref: u,
3444
+ "data-slot": "image-editor-markup-layer",
3445
+ "data-tool": f,
3446
+ className: e("absolute inset-0 touch-none", Aa[f]),
3447
+ ...m,
3448
+ onPointerDown: (e) => {
3449
+ s && e.target === e.currentTarget && u.current?.querySelector(ja)?.blur(), m.onPointerDown(e);
3450
+ },
3451
+ onMouseDown: (e) => {
3452
+ f === "text" && e.target === e.currentTarget && e.preventDefault();
3453
+ },
3454
+ children: s && /* @__PURE__ */ F(ka, {
3455
+ draft: s,
3456
+ view: a,
3457
+ base: i,
3458
+ scale: o,
3459
+ onCommit: l,
3460
+ onCancel: () => c(null)
3461
+ }, s.id ?? `${s.x}:${s.y}`)
3462
+ }) : null;
3463
+ }
3464
+ //#endregion
3465
+ //#region lib/components/ui/media/image-editor/partials/editor-stage-dock.tsx
3466
+ function Na({ label: t, children: n, className: r, ...i }) {
3467
+ return /* @__PURE__ */ F("button", {
3468
+ type: "button",
3469
+ "aria-label": t,
3470
+ title: t,
3471
+ className: e("inline-flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-white/85 outline-none transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-[3px] focus-visible:ring-white/50 disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-white aria-pressed:text-black [&_svg]:size-[18px]", r),
3472
+ ...i,
3473
+ children: n
3474
+ });
3475
+ }
3476
+ function Pa() {
3477
+ let { state: e, actions: t, zoom: n, scale: r, source: i, canUndo: a } = B(), { t: o } = x();
3478
+ if (i.status !== "ready") return null;
3479
+ let s = Math.round(r * 100), c = e.zoom === null, l = () => t.setComparing(!1);
3480
+ return /* @__PURE__ */ I("div", {
3481
+ role: "toolbar",
3482
+ "aria-label": o("material.image-editor.view", "View"),
3483
+ "data-slot": "image-editor-dock",
3484
+ className: "nxgt-image-editor-glass pointer-events-auto flex items-center gap-0.5 rounded-full p-1",
3485
+ children: [
3486
+ /* @__PURE__ */ F(Na, {
3487
+ label: o("material.image-editor.zoom-out", "Zoom out"),
3488
+ disabled: r <= Hn,
3489
+ onClick: () => n.zoomOut(),
3490
+ children: /* @__PURE__ */ F(Xe, { "aria-hidden": "true" })
3491
+ }),
3492
+ /* @__PURE__ */ F("button", {
3493
+ type: "button",
3494
+ "aria-label": `${c ? o("material.image-editor.zoom-actual", "Actual size") : o("material.image-editor.zoom-fit", "Fit to screen")}, ${s}%`,
3495
+ onClick: () => c ? n.zoomToActual() : n.zoomToFit(),
3496
+ className: "h-9 min-w-14 cursor-pointer rounded-full px-2 font-medium text-white text-xs tabular-nums outline-none transition-colors hover:bg-white/10 focus-visible:ring-[3px] focus-visible:ring-white/50",
3497
+ children: /* @__PURE__ */ I("span", {
3498
+ "aria-hidden": "true",
3499
+ children: [s, "%"]
3500
+ })
3501
+ }),
3502
+ /* @__PURE__ */ F(Na, {
3503
+ label: o("material.image-editor.zoom-in", "Zoom in"),
3504
+ disabled: r >= 8,
3505
+ onClick: () => n.zoomIn(),
3506
+ children: /* @__PURE__ */ F(Ye, { "aria-hidden": "true" })
3507
+ }),
3508
+ /* @__PURE__ */ F("span", {
3509
+ "aria-hidden": "true",
3510
+ className: "mx-1 h-5 w-px bg-white/15"
3511
+ }),
3512
+ /* @__PURE__ */ F(Na, {
3513
+ label: o("material.image-editor.split", "Before and after"),
3514
+ "aria-pressed": e.split,
3515
+ disabled: !a && !e.split,
3516
+ onClick: () => t.setSplit(!e.split),
3517
+ children: /* @__PURE__ */ F(ye, { "aria-hidden": "true" })
3518
+ }),
3519
+ /* @__PURE__ */ F(Na, {
3520
+ label: o("material.image-editor.compare", "Hold to compare"),
3521
+ "aria-pressed": e.comparing,
3522
+ disabled: !a || e.split,
3523
+ onPointerDown: () => t.setComparing(!0),
3524
+ onPointerUp: l,
3525
+ onPointerLeave: l,
3526
+ onKeyDown: (e) => {
3527
+ (e.key === " " || e.key === "Enter") && t.setComparing(!0);
3528
+ },
3529
+ onKeyUp: l,
3530
+ onBlur: l,
3531
+ children: /* @__PURE__ */ F(we, { "aria-hidden": "true" })
3532
+ })
3533
+ ]
3534
+ });
3535
+ }
3536
+ //#endregion
3537
+ //#region lib/components/ui/media/image-editor/partials/editor-stage.tsx
3538
+ function Fa() {
3539
+ let { source: e, stageRef: t, state: n, toolbar: r } = B(), i = r === "floating", { t: o } = x();
3540
+ return /* @__PURE__ */ I("div", {
3541
+ className: "relative flex min-h-48 min-w-0 flex-1 flex-col",
3542
+ children: [/* @__PURE__ */ F("section", {
3543
+ ref: t,
3544
+ tabIndex: 0,
3545
+ "aria-label": o("material.image-editor.stage", "Image"),
3546
+ "aria-busy": e.status === "loading" || void 0,
3547
+ "data-slot": "image-editor-stage",
3548
+ "data-tool": n.tool,
3549
+ className: "nxgt-image-editor-stage relative min-h-0 flex-1 overflow-auto outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset",
3550
+ children: e.status === "ready" ? /* @__PURE__ */ F(Ia, { preview: e.preview }) : /* @__PURE__ */ F("div", {
3551
+ className: "absolute inset-0 flex flex-col items-center justify-center gap-3 p-6 text-center text-sm text-white/70",
3552
+ children: e.status === "loading" ? /* @__PURE__ */ F(a, { "aria-label": o("material.image-editor.loading", "Loading the image") }) : /* @__PURE__ */ I("div", {
3553
+ role: "alert",
3554
+ className: "flex max-w-sm flex-col items-center gap-2",
3555
+ children: [/* @__PURE__ */ F(Oe, {
3556
+ className: "size-8",
3557
+ "aria-hidden": "true"
3558
+ }), o("material.image-editor.error", "This image cannot be edited. It may be missing, or served from another site without CORS.")]
3559
+ })
3560
+ })
3561
+ }), /* @__PURE__ */ I("div", {
3562
+ className: "@container pointer-events-none absolute inset-x-0 bottom-3 flex flex-col items-center gap-2 px-3",
3563
+ children: [i && n.tool === "crop" && e.status === "ready" && /* @__PURE__ */ F(fa, {}), F(i ? ya : Pa, {})]
3564
+ })]
3565
+ });
3566
+ }
3567
+ function Ia({ preview: e }) {
3568
+ let { state: t, base: n, view: r, scale: i } = B(), { t: a } = x(), o = M(null), s = M(null), { tool: c, edits: l, comparing: u, selectedId: d, split: f } = t, p = n ? r.w * n.width * i : 0, m = n ? r.h * n.height * i : 0, h = {
3569
+ source: e,
3570
+ edits: l,
3571
+ region: Gi(c),
3572
+ displayWidth: p
3573
+ }, { paint: g } = aa({
3574
+ ...h,
3575
+ canvasRef: o,
3576
+ comparing: u,
3577
+ selectedId: c === "markup" && !f ? d : null,
3578
+ hiddenId: t.editingId,
3579
+ mountKey: f
3580
+ });
3581
+ aa({
3582
+ ...h,
3583
+ canvasRef: s,
3584
+ comparing: !0,
3585
+ selectedId: null,
3586
+ active: f,
3587
+ mountKey: f
3588
+ });
3589
+ let _ = (e) => /* @__PURE__ */ F("canvas", {
3590
+ ref: e,
3591
+ className: "nxgt-image-editor-canvas block size-full",
3592
+ "data-pixelated": i >= 3 || void 0,
3593
+ "aria-hidden": "true"
3594
+ });
3595
+ return /* @__PURE__ */ F("div", {
3596
+ className: "flex min-h-full w-max min-w-full items-center justify-center px-6 pt-6 pb-[var(--stage-dock,5rem)]",
3597
+ children: /* @__PURE__ */ I("div", {
3598
+ "data-slot": "image-editor-canvas",
3599
+ className: "nxgt-image-editor-checker relative shrink-0",
3600
+ style: {
3601
+ width: p,
3602
+ height: m
3603
+ },
3604
+ children: [
3605
+ f ? /* @__PURE__ */ F(vn, {
3606
+ className: "size-full",
3607
+ before: _(s),
3608
+ after: _(o),
3609
+ beforeLabel: a("material.image-editor.before", "Original"),
3610
+ afterLabel: a("material.image-editor.after", "Edited")
3611
+ }) : _(o),
3612
+ c === "crop" && !f && /* @__PURE__ */ F(ua, {}),
3613
+ c === "markup" && !u && !f && /* @__PURE__ */ F(Ma, { paint: g })
3614
+ ]
3615
+ })
3616
+ });
3617
+ }
3618
+ //#endregion
3619
+ //#region lib/components/ui/media/image-editor/image-editor.changes.ts
3620
+ function La(e) {
3621
+ let t = /* @__PURE__ */ new Set(), { adjustments: n, crop: r } = e;
3622
+ return Object.keys(V).some((e) => n[e] !== V[e]) && t.add("adjust"), e.filter !== "none" && t.add("filters"), (!(r.x === U.x && r.y === U.y && r.w === U.w && r.h === U.h) || !ar(e.transform)) && t.add("crop"), e.annotations.length > 0 && t.add("markup"), t;
3623
+ }
3624
+ //#endregion
3625
+ //#region lib/components/ui/media/image-editor/partials/editor-tool-rail.tsx
3626
+ var Ra = {
3627
+ adjust: {
3628
+ icon: Be,
3629
+ label: "Adjust"
3630
+ },
3631
+ filters: {
3632
+ icon: Ve,
3633
+ label: "Filters"
3634
+ },
3635
+ crop: {
3636
+ icon: xe,
3637
+ label: "Crop"
3638
+ },
3639
+ markup: {
3640
+ icon: Me,
3641
+ label: "Markup"
3642
+ }
3643
+ };
3644
+ function za() {
3645
+ let { tools: t, state: n, actions: r, source: i } = B(), { t: a } = x(), o = A();
3646
+ if (t.length < 2) return null;
3647
+ let s = La(n.edits);
3648
+ return /* @__PURE__ */ F("div", {
3649
+ role: "toolbar",
3650
+ "aria-label": a("material.image-editor.tools", "Tools"),
3651
+ "data-slot": "image-editor-tool-rail",
3652
+ className: "flex shrink-0 justify-around gap-1 border-t bg-card px-2 py-1.5 @3xl/image-editor:order-first @3xl/image-editor:flex-col @3xl/image-editor:justify-start @3xl/image-editor:gap-2 @3xl/image-editor:border-t-0 @3xl/image-editor:border-r @3xl/image-editor:px-1.5 @3xl/image-editor:py-3",
3653
+ children: t.map((t) => {
3654
+ let { icon: c, label: l } = Ra[t], u = n.tool === t, d = s.has(t);
3655
+ return /* @__PURE__ */ I(ue, { children: [/* @__PURE__ */ I("button", {
3656
+ type: "button",
3657
+ "aria-pressed": u,
3658
+ disabled: i.status !== "ready",
3659
+ "data-edited": d || void 0,
3660
+ "aria-describedby": d ? `${o}-${t}` : void 0,
3661
+ "data-tool": t,
3662
+ onClick: () => r.setTool(t),
3663
+ className: "group flex min-w-16 cursor-pointer flex-col items-center gap-1 rounded-xl px-1 py-1 text-muted-foreground text-xs outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-pressed:text-foreground",
3664
+ children: [/* @__PURE__ */ I("span", {
3665
+ className: e("relative flex h-8 w-14 items-center justify-center rounded-full transition-all duration-300 group-hover:bg-foreground/5", u && "bg-primary/15 text-primary-text group-hover:bg-primary/20"),
3666
+ children: [/* @__PURE__ */ F(c, {
3667
+ className: "size-5",
3668
+ "aria-hidden": "true"
3669
+ }), d && /* @__PURE__ */ F("span", {
3670
+ "aria-hidden": "true",
3671
+ "data-slot": "image-editor-tool-dot",
3672
+ className: "absolute top-1 right-3.5 size-2 rounded-full bg-primary-text ring-2 ring-card"
3673
+ })]
3674
+ }), /* @__PURE__ */ F("span", {
3675
+ className: e("font-medium", u && "text-foreground"),
3676
+ children: a(`material.image-editor.tool.${t}`, l)
3677
+ })]
3678
+ }), d && /* @__PURE__ */ F("span", {
3679
+ id: `${o}-${t}`,
3680
+ className: "sr-only",
3681
+ children: a("material.image-editor.tool.edited", "Has changes")
3682
+ })] }, t);
3683
+ })
3684
+ });
3685
+ }
3686
+ //#endregion
3687
+ //#region lib/components/ui/media/image-editor/partials/editor-export-options.tsx
3688
+ var Ba = [
3689
+ {
3690
+ value: "image/png",
3691
+ label: "PNG"
3692
+ },
3693
+ {
3694
+ value: "image/jpeg",
3695
+ label: "JPEG"
3696
+ },
3697
+ {
3698
+ value: "image/webp",
3699
+ label: "WebP"
3700
+ }
3701
+ ], Va = [
3702
+ {
3703
+ value: .92,
3704
+ id: "high",
3705
+ label: "High"
3706
+ },
3707
+ {
3708
+ value: .8,
3709
+ id: "medium",
3710
+ label: "Medium"
3711
+ },
3712
+ {
3713
+ value: .6,
3714
+ id: "low",
3715
+ label: "Low"
3716
+ }
3717
+ ], Ha = [
3718
+ 1,
3719
+ .75,
3720
+ .5,
3721
+ .25
3722
+ ];
3723
+ function Ua() {
3724
+ let { state: e, actions: t } = B(), { t: n } = x(), r = e.exportOptions, i = r.format !== "image/png";
3725
+ return /* @__PURE__ */ I(P, { children: [
3726
+ /* @__PURE__ */ F(p, { children: n("material.image-editor.export.format", "Format") }),
3727
+ /* @__PURE__ */ F(d, {
3728
+ value: r.format,
3729
+ onValueChange: (e) => t.setExportOptions({ format: e }),
3730
+ children: Ba.map((e) => /* @__PURE__ */ F(f, {
3731
+ value: e.value,
3732
+ children: e.label
3733
+ }, e.value))
3734
+ }),
3735
+ i && /* @__PURE__ */ I(P, { children: [
3736
+ /* @__PURE__ */ F(h, {}),
3737
+ /* @__PURE__ */ F(p, { children: n("material.image-editor.export.quality", "Quality") }),
3738
+ /* @__PURE__ */ F(d, {
3739
+ value: String(r.quality),
3740
+ onValueChange: (e) => t.setExportOptions({ quality: Number(e) }),
3741
+ children: Va.map((e) => /* @__PURE__ */ F(f, {
3742
+ value: String(e.value),
3743
+ children: n(`material.image-editor.export.quality-${e.id}`, e.label)
3744
+ }, e.id))
3745
+ })
3746
+ ] }),
3747
+ /* @__PURE__ */ F(h, {}),
3748
+ /* @__PURE__ */ F(p, { children: n("material.image-editor.export.size", "Size") }),
3749
+ /* @__PURE__ */ F(d, {
3750
+ value: String(r.scale),
3751
+ onValueChange: (e) => t.setExportOptions({ scale: Number(e) }),
3752
+ children: Ha.map((e) => /* @__PURE__ */ F(f, {
3753
+ value: String(e),
3754
+ children: `${e * 100}%`
3755
+ }, e))
3756
+ })
3757
+ ] });
3758
+ }
3759
+ //#endregion
3760
+ //#region lib/components/ui/media/image-editor/partials/editor-export-menu.tsx
3761
+ function Wa() {
3762
+ let { source: e, exporting: t, hideDownload: n, onSave: r } = B(), { t: i } = x();
3763
+ return n && !r ? null : /* @__PURE__ */ I(g, { children: [/* @__PURE__ */ F(u, {
3764
+ asChild: !0,
3765
+ children: /* @__PURE__ */ F(S, {
3766
+ variant: "ghost",
3767
+ color: "default",
3768
+ "aria-label": i("material.image-editor.export.label", "Export"),
3769
+ disabled: e.status !== "ready" || t.busy !== null,
3770
+ "data-slot": "image-editor-export",
3771
+ children: F(n ? Re : Se, {})
3772
+ })
3773
+ }), /* @__PURE__ */ I(m, {
3774
+ align: "end",
3775
+ className: "min-w-52",
3776
+ children: [/* @__PURE__ */ F(Ua, {}), !n && /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(h, {}), /* @__PURE__ */ I(_, {
3777
+ onSelect: () => void t.download(),
3778
+ children: [/* @__PURE__ */ F(Se, { "aria-hidden": "true" }), i("material.image-editor.export.download", "Download")]
3779
+ })] })]
3780
+ })] });
3781
+ }
3782
+ //#endregion
3783
+ //#region lib/components/ui/media/image-editor/partials/editor-file-info.tsx
3784
+ function Ga() {
3785
+ let { source: e, fileName: t } = B(), { t: n } = x();
3786
+ return /* @__PURE__ */ F("div", {
3787
+ className: "flex min-w-0 flex-1 justify-center",
3788
+ children: e.status === "ready" && /* @__PURE__ */ I("span", {
3789
+ role: "note",
3790
+ "aria-label": n("material.image-editor.size", "Original size"),
3791
+ title: n("material.image-editor.size", "Original size"),
3792
+ "data-slot": "image-editor-info",
3793
+ className: "hidden max-w-full items-center gap-1.5 truncate rounded-full bg-muted/60 px-2.5 py-1 text-muted-foreground text-xs tabular-nums @xl/image-editor:inline-flex",
3794
+ children: [
3795
+ t && /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F("span", {
3796
+ className: "truncate font-medium text-foreground/80",
3797
+ children: t
3798
+ }), /* @__PURE__ */ F("span", {
3799
+ "aria-hidden": "true",
3800
+ children: "·"
3801
+ })] }),
3802
+ e.original.width,
3803
+ " × ",
3804
+ e.original.height
3805
+ ]
3806
+ })
3807
+ });
3808
+ }
3809
+ //#endregion
3810
+ //#region lib/components/ui/media/image-editor/partials/editor-history-buttons.tsx
3811
+ function Ka() {
3812
+ let { actions: e, canUndo: t, canRedo: n } = B(), { t: r } = x();
3813
+ return /* @__PURE__ */ I(P, { children: [
3814
+ /* @__PURE__ */ F(S, {
3815
+ variant: "ghost",
3816
+ color: "default",
3817
+ tooltip: r("material.image-editor.undo", "Undo"),
3818
+ disabled: !t,
3819
+ onClick: () => e.undo(),
3820
+ children: /* @__PURE__ */ F(Ke, {})
3821
+ }),
3822
+ /* @__PURE__ */ F(S, {
3823
+ variant: "ghost",
3824
+ color: "default",
3825
+ tooltip: r("material.image-editor.redo", "Redo"),
3826
+ disabled: !n,
3827
+ onClick: () => e.redo(),
3828
+ children: /* @__PURE__ */ F(Fe, {})
3829
+ }),
3830
+ /* @__PURE__ */ F(S, {
3831
+ variant: "ghost",
3832
+ color: "default",
3833
+ tooltip: r("material.image-editor.reset", "Reset all"),
3834
+ disabled: !t,
3835
+ onClick: () => e.resetAll(),
3836
+ children: /* @__PURE__ */ F(Ie, {})
3837
+ })
3838
+ ] });
3839
+ }
3840
+ //#endregion
3841
+ //#region lib/components/ui/media/image-editor/image-editor.shortcuts.ts
3842
+ var qa = {
3843
+ ctrl: "Ctrl/⌘",
3844
+ shift: "Shift",
3845
+ delete: "Delete",
3846
+ esc: "Esc",
3847
+ enter: "Enter"
3848
+ }, Ja = "ctrl", Ya = [
3849
+ "←",
3850
+ "↑",
3851
+ "→",
3852
+ "↓"
3853
+ ], Xa = [
3854
+ {
3855
+ id: "general",
3856
+ label: "Editing",
3857
+ items: [
3858
+ {
3859
+ id: "undo",
3860
+ keys: [Ja, "Z"],
3861
+ label: "Undo"
3862
+ },
3863
+ {
3864
+ id: "redo",
3865
+ keys: [
3866
+ Ja,
3867
+ "shift",
3868
+ "Z"
3869
+ ],
3870
+ label: "Redo"
3871
+ },
3872
+ {
3873
+ id: "help",
3874
+ keys: ["?"],
3875
+ label: "Show this list"
3876
+ }
3877
+ ]
3878
+ },
3879
+ {
3880
+ id: "view",
3881
+ label: "View",
3882
+ items: [
3883
+ {
3884
+ id: "zoom-in",
3885
+ keys: ["+"],
3886
+ label: "Zoom in"
3887
+ },
3888
+ {
3889
+ id: "zoom-out",
3890
+ keys: ["-"],
3891
+ label: "Zoom out"
3892
+ },
3893
+ {
3894
+ id: "zoom-fit",
3895
+ keys: ["0"],
3896
+ label: "Fit to screen"
3897
+ },
3898
+ {
3899
+ id: "zoom-actual",
3900
+ keys: ["1"],
3901
+ label: "Actual size"
3902
+ }
3903
+ ]
3904
+ },
3905
+ {
3906
+ id: "mark",
3907
+ label: "Selected mark",
3908
+ items: [
3909
+ {
3910
+ id: "mark-delete",
3911
+ keys: ["delete"],
3912
+ label: "Delete the mark"
3913
+ },
3914
+ {
3915
+ id: "mark-duplicate",
3916
+ keys: [Ja, "D"],
3917
+ label: "Duplicate the mark"
3918
+ },
3919
+ {
3920
+ id: "mark-nudge",
3921
+ keys: Ya,
3922
+ label: "Nudge the mark"
3923
+ },
3924
+ {
3925
+ id: "mark-move",
3926
+ keys: ["shift", ...Ya],
3927
+ label: "Nudge it further"
3928
+ },
3929
+ {
3930
+ id: "mark-drop",
3931
+ keys: ["esc"],
3932
+ label: "Deselect"
3933
+ },
3934
+ {
3935
+ id: "mark-step",
3936
+ keys: ["enter"],
3937
+ label: "Place a step marker (Step tool)"
3938
+ }
3939
+ ]
3940
+ },
3941
+ {
3942
+ id: "crop",
3943
+ label: "Crop frame",
3944
+ items: [{
3945
+ id: "crop-move",
3946
+ keys: Ya,
3947
+ label: "Move the frame"
3948
+ }, {
3949
+ id: "crop-resize",
3950
+ keys: ["shift", ...Ya],
3951
+ label: "Resize the frame"
3952
+ }]
3953
+ }
3954
+ ];
3955
+ //#endregion
3956
+ //#region lib/components/ui/media/image-editor/partials/editor-shortcuts.tsx
3957
+ function Za() {
3958
+ let { state: e, actions: t } = B(), { t: n } = x(), r = n("material.image-editor.shortcuts.title", "Keyboard shortcuts");
3959
+ return /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(S, {
3960
+ variant: "ghost",
3961
+ color: "default",
3962
+ tooltip: r,
3963
+ "aria-keyshortcuts": "?",
3964
+ onClick: () => t.setShortcutsOpen(!0),
3965
+ children: /* @__PURE__ */ F(ke, {})
3966
+ }), /* @__PURE__ */ F(se, {
3967
+ open: e.shortcutsOpen,
3968
+ onOpenChange: t.setShortcutsOpen,
3969
+ children: /* @__PURE__ */ I(oe, {
3970
+ "data-slot": "image-editor-shortcuts",
3971
+ className: "max-h-[calc(100dvh-2rem)] gap-4 overflow-y-auto sm:max-w-md",
3972
+ children: [
3973
+ /* @__PURE__ */ F(ie, {}),
3974
+ /* @__PURE__ */ F(re, {
3975
+ className: "text-lg/6",
3976
+ children: r
3977
+ }),
3978
+ /* @__PURE__ */ F(ae, { children: n("material.image-editor.shortcuts.description", "Keys work while the image or a panel has focus.") }),
3979
+ Xa.map((e) => /* @__PURE__ */ I("section", {
3980
+ className: "flex flex-col gap-1.5",
3981
+ children: [/* @__PURE__ */ F("h3", {
3982
+ className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
3983
+ children: n(`material.image-editor.shortcuts.group.${e.id}`, e.label)
3984
+ }), /* @__PURE__ */ F("dl", {
3985
+ className: "flex flex-col divide-y rounded-lg border",
3986
+ children: e.items.map((e) => /* @__PURE__ */ I("div", {
3987
+ className: "flex items-center justify-between gap-3 px-3 py-1.5 text-sm",
3988
+ children: [/* @__PURE__ */ F("dt", {
3989
+ className: "font-normal",
3990
+ children: n(`material.image-editor.shortcuts.${e.id}`, e.label)
3991
+ }), /* @__PURE__ */ F("dd", {
3992
+ className: "flex shrink-0 gap-1",
3993
+ children: e.keys.map((e) => /* @__PURE__ */ F("kbd", {
3994
+ className: "min-w-6 rounded-md border bg-muted/60 px-1.5 py-0.5 text-center font-sans font-medium text-muted-foreground text-xs",
3995
+ children: qa[e] ? n(`material.image-editor.shortcuts.key.${e}`, qa[e]) : e
3996
+ }, e))
3997
+ })]
3998
+ }, e.id))
3999
+ })]
4000
+ }, e.id))
4001
+ ]
4002
+ })
4003
+ })] });
4004
+ }
4005
+ //#endregion
4006
+ //#region lib/components/ui/media/image-editor/partials/editor-top-bar.tsx
4007
+ function Qa() {
4008
+ let e = B(), { source: t, exporting: n } = e, { t: r } = x(), i = t.status === "ready", a = e.toolbar === "floating";
4009
+ return /* @__PURE__ */ I("div", {
4010
+ "data-slot": "image-editor-top-bar",
4011
+ className: "flex shrink-0 items-center gap-1 border-b bg-card px-2 py-1.5 sm:gap-2 sm:px-3",
4012
+ children: [
4013
+ a && e.onCancel && /* @__PURE__ */ F(b, {
4014
+ variant: "tonal",
4015
+ color: "default",
4016
+ size: "sm",
4017
+ className: "px-4",
4018
+ onClick: e.onCancel,
4019
+ children: r("material.image-editor.cancel", "Cancel")
4020
+ }),
4021
+ !a && e.onCancel && /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(S, {
4022
+ variant: "ghost",
4023
+ color: "default",
4024
+ tooltip: r("material.image-editor.cancel", "Cancel"),
4025
+ onClick: e.onCancel,
4026
+ children: /* @__PURE__ */ F(Je, {})
4027
+ }), /* @__PURE__ */ F(ne, {
4028
+ orientation: "vertical",
4029
+ className: "h-6!"
4030
+ })] }),
4031
+ !a && /* @__PURE__ */ F(Ka, {}),
4032
+ /* @__PURE__ */ F(Ga, {}),
4033
+ /* @__PURE__ */ F(Za, {}),
4034
+ /* @__PURE__ */ F(Wa, {}),
4035
+ e.onSave && /* @__PURE__ */ F(b, {
4036
+ variant: "filled",
4037
+ color: "primary",
4038
+ size: "sm",
4039
+ className: "px-4",
4040
+ disabled: !i || n.busy !== null,
4041
+ loading: n.busy === "save",
4042
+ onClick: () => void n.save(),
4043
+ children: e.saveLabel ?? (a ? r("material.image-editor.done", "Done") : r("material.image-editor.save", "Save"))
4044
+ })
4045
+ ]
4046
+ });
4047
+ }
4048
+ //#endregion
4049
+ //#region lib/components/ui/media/image-editor/image-editor.export.ts
4050
+ var $a = {
4051
+ "image/png": "png",
4052
+ "image/jpeg": "jpg",
4053
+ "image/webp": "webp"
4054
+ };
4055
+ function eo(e, t) {
4056
+ return `${e.replace(/\.(png|jpe?g|webp|gif|avif|bmp)$/i, "").replace(/[/\\?%*:|"<>]/g, "-").trim() || "image"}.${$a[t]}`;
4057
+ }
4058
+ function to(e, t, n, r) {
4059
+ let i = ti(e, t, {
4060
+ scale: n.scale,
4061
+ region: "crop"
4062
+ }), a = Math.max(i.width, i.height), o = r && a > r ? r / a : 1;
4063
+ return n.scale * o;
4064
+ }
4065
+ function no(e, t, n) {
4066
+ return new Promise((r, i) => {
4067
+ e.toBlob((e) => e ? r(e) : i(/* @__PURE__ */ Error("Could not encode the image")), t, n);
4068
+ });
4069
+ }
4070
+ async function ro(e, t, n, { fileName: r, maxSize: i }) {
4071
+ let a = ai(e, t, {
4072
+ scale: to(e, t, n, i),
4073
+ region: "crop"
4074
+ });
4075
+ if (n.format === "image/jpeg") {
4076
+ let e = document.createElement("canvas");
4077
+ e.width = a.width, e.height = a.height;
4078
+ let t = e.getContext("2d");
4079
+ t && (t.fillStyle = "#ffffff", t.fillRect(0, 0, e.width, e.height), t.drawImage(a, 0, 0), a = e);
4080
+ }
4081
+ let o = await no(a, n.format, n.quality);
4082
+ return {
4083
+ blob: o,
4084
+ file: new File([o], eo(r, n.format), { type: o.type || n.format }),
4085
+ width: a.width,
4086
+ height: a.height,
4087
+ edits: t
4088
+ };
4089
+ }
4090
+ function io(e) {
4091
+ let t = URL.createObjectURL(e), n = document.createElement("a");
4092
+ n.href = t, n.download = e.name, n.rel = "noopener", n.click(), setTimeout(() => URL.revokeObjectURL(t), 1e3);
4093
+ }
4094
+ //#endregion
4095
+ //#region lib/components/ui/media/image-editor/use-image-editor-export.ts
4096
+ function ao({ source: e, edits: t, options: n, fileName: r, maxSize: i, onSave: a }) {
4097
+ let [o, s] = N(null), [c, l] = N(!1), u = O(async (a, o) => {
4098
+ if (e.status === "ready") {
4099
+ s(a), l(!1);
4100
+ try {
4101
+ await new Promise((e) => setTimeout(e, 16)), await o(await ro(e.original, t, n, {
4102
+ fileName: r,
4103
+ maxSize: i
4104
+ }));
4105
+ } catch {
4106
+ l(!0);
4107
+ } finally {
4108
+ s(null);
4109
+ }
4110
+ }
4111
+ }, [
4112
+ t,
4113
+ r,
4114
+ i,
4115
+ n,
4116
+ e
4117
+ ]);
4118
+ return {
4119
+ busy: o,
4120
+ failed: c,
4121
+ save: O(() => u("save", (e) => a?.(e)), [a, u]),
4122
+ download: O(() => u("download", (e) => io(e.file)), [u])
4123
+ };
4124
+ }
4125
+ //#endregion
4126
+ //#region lib/components/ui/media/image-editor/use-image-editor-init.ts
4127
+ function oo(e, t, n) {
4128
+ return {
4129
+ brush: {
4130
+ ...Rn,
4131
+ redactMode: Tr(n, Rn.redactMode)
4132
+ },
4133
+ markupTool: e.markupTools?.[0] ?? "pen",
4134
+ tool: e.defaultTool && t.includes(e.defaultTool) ? e.defaultTool : t[0],
4135
+ edits: Er(br(e.defaultEdits), n),
4136
+ aspect: e.aspect ?? null,
4137
+ exportOptions: {
4138
+ ...Vn,
4139
+ ...e.defaultExportOptions
4140
+ }
4141
+ };
4142
+ }
4143
+ function so(e) {
4144
+ let t = e.tools?.length ? e.tools : Nn;
4145
+ if (e.toolbar !== "floating") return t;
4146
+ let n = t.filter((e) => e === "markup" || e === "crop");
4147
+ return n.length ? n : ["markup"];
4148
+ }
4149
+ //#endregion
4150
+ //#region lib/components/ui/media/image-editor/image-editor.keyboard.ts
4151
+ function co(e, t) {
4152
+ let n = e;
4153
+ return typeof n?.closest == "function" && !!n.closest(t);
4154
+ }
4155
+ var lo = "input, textarea, select, [contenteditable=\"true\"], [role=\"slider\"], [role=\"radio\"], [role=\"menuitem\"], [role=\"option\"]", uo = {
4156
+ ArrowLeft: [-1, 0],
4157
+ ArrowRight: [1, 0],
4158
+ ArrowUp: [0, -1],
4159
+ ArrowDown: [0, 1]
4160
+ };
4161
+ function fo(e, t) {
4162
+ let n = t.selection;
4163
+ if (!co(e.target, "[data-slot=\"image-editor-stage\"]")) return !1;
4164
+ if (e.key === "Enter" && t.placeStep) return t.placeStep(), !0;
4165
+ if (!n) return !1;
4166
+ let r = e.ctrlKey || e.metaKey, i = uo[e.key];
4167
+ if (e.key === "Delete" || e.key === "Backspace") n.remove();
4168
+ else if (e.key === "Escape") n.deselect();
4169
+ else if (r && e.key.toLowerCase() === "d") n.duplicate();
4170
+ else if (i && !r) {
4171
+ let t = e.shiftKey ? .05 : .005;
4172
+ n.nudge(i[0] * t, i[1] * t);
4173
+ } else return !1;
4174
+ return !0;
4175
+ }
4176
+ function po(e, t) {
4177
+ let n = e.ctrlKey || e.metaKey, r = e.key.toLowerCase();
4178
+ if (n && r === "z") (e.shiftKey ? t.redo : t.undo)();
4179
+ else if (n && r === "y") t.redo();
4180
+ else if (n || e.altKey) return !1;
4181
+ else if (e.key === "+" || e.key === "=") t.zoomIn();
4182
+ else if (e.key === "-" || e.key === "_") t.zoomOut();
4183
+ else if (e.key === "0") t.zoomToFit();
4184
+ else if (e.key === "1") t.zoomToActual();
4185
+ else if (e.key === "?" && t.showShortcuts) t.showShortcuts();
4186
+ else return !1;
4187
+ return !0;
4188
+ }
4189
+ function mo(e, t) {
4190
+ if (co(e.target, `${lo}, [data-slot="image-editor-shortcuts"]`)) return !1;
4191
+ let n = fo(e, t) || po(e, t);
4192
+ return n && e.preventDefault(), n;
4193
+ }
4194
+ //#endregion
4195
+ //#region lib/components/ui/media/image-editor/use-image-editor-keys.ts
4196
+ function ho(e, t, n, r) {
4197
+ return O((i) => {
4198
+ let a = t?.id;
4199
+ mo(i, {
4200
+ undo: e.undo,
4201
+ redo: e.redo,
4202
+ ...n,
4203
+ placeStep: r,
4204
+ showShortcuts: () => e.setShortcutsOpen(!0),
4205
+ selection: a ? {
4206
+ remove: () => e.removeAnnotation(a),
4207
+ duplicate: () => e.duplicateAnnotation(a),
4208
+ deselect: () => e.selectAnnotation(null),
4209
+ nudge: (t, n) => e.moveAnnotation({
4210
+ id: a,
4211
+ dx: t,
4212
+ dy: n,
4213
+ gesture: `nudge:${a}`
4214
+ })
4215
+ } : void 0
4216
+ });
4217
+ }, [
4218
+ e,
4219
+ t?.id,
4220
+ n,
4221
+ r
4222
+ ]);
4223
+ }
4224
+ //#endregion
4225
+ //#region lib/components/ui/media/image-editor/use-image-editor-zoom.ts
4226
+ function go(e, t) {
4227
+ let n = t === 1 ? Un : [...Un].reverse();
4228
+ return n.find((n) => t === 1 ? n > e * 1.01 : n < e * .99) ?? n[n.length - 1];
4229
+ }
4230
+ function _o(e, t) {
4231
+ let n = M(1), r = O((e) => e ?? n.current, []);
4232
+ return j(() => {
4233
+ let i = () => e ?? n.current;
4234
+ return {
4235
+ fitRef: n,
4236
+ scaleOf: r,
4237
+ zoomIn: () => t(go(i(), 1)),
4238
+ zoomOut: () => t(go(i(), -1)),
4239
+ zoomToFit: () => t(null),
4240
+ zoomToActual: () => t(1),
4241
+ zoomBy: (e) => t(i() * e)
4242
+ };
4243
+ }, [
4244
+ e,
4245
+ r,
4246
+ t
4247
+ ]);
4248
+ }
4249
+ //#endregion
4250
+ //#region lib/components/ui/media/image-editor/use-image-source.ts
4251
+ async function vo(e) {
4252
+ let t = e;
4253
+ if (typeof e == "string") {
4254
+ let n = await fetch(e);
4255
+ if (!n.ok) throw Error("Could not load image");
4256
+ t = await n.blob();
4257
+ }
4258
+ return createImageBitmap(t);
4259
+ }
4260
+ function yo(e) {
4261
+ e && "close" in e && e.close();
4262
+ }
4263
+ function bo(e, t = "image") {
4264
+ let n = t === "bitmap", r = E(typeof e == "string" || n ? void 0 : e), i = typeof e == "string" ? e : r, [a, o] = N({ status: "loading" }), s = n ? e : i;
4265
+ return k(() => {
4266
+ if (!s) return;
4267
+ let e = !0, t;
4268
+ return o({ status: "loading" }), (n ? vo(s) : xn(s)).then((n) => {
4269
+ if (t = n, !e) return yo(t);
4270
+ let r = {
4271
+ image: n,
4272
+ width: "naturalWidth" in n ? n.naturalWidth : n.width,
4273
+ height: "naturalHeight" in n ? n.naturalHeight : n.height
4274
+ };
4275
+ if (!(r.width > 0 && r.height > 0) || !si(r)) throw Error("The image cannot be edited");
4276
+ o({
4277
+ status: "ready",
4278
+ original: r,
4279
+ preview: oi(r, Wn)
4280
+ });
4281
+ }).catch(() => {
4282
+ e && o({ status: "error" });
4283
+ }), () => {
4284
+ e = !1, yo(t);
4285
+ };
4286
+ }, [s, n]), a;
4287
+ }
4288
+ //#endregion
4289
+ //#region lib/components/ui/media/image-editor/use-place-step.ts
4290
+ var xo = (e, t, n) => Math.min(n, Math.max(t, e));
4291
+ function So(e, t) {
4292
+ let n = t % 6 * .03;
4293
+ return {
4294
+ x: xo(e.x + e.w / 2 + n, Math.max(0, e.x), Math.min(1, e.x + e.w)),
4295
+ y: xo(e.y + e.h / 2 + n, Math.max(0, e.y), Math.min(1, e.y + e.h))
4296
+ };
4297
+ }
4298
+ function Co(e, t, n, r) {
4299
+ let i = e.tool === "markup" && e.markupTool === "step" && r !== null, a = e.edits.annotations.filter((e) => e.kind === "step").length, o = e.brush, { addAnnotation: s } = t, c = O(() => s(Ca(So(n, a), o)), [
4300
+ s,
4301
+ n,
4302
+ a,
4303
+ o
4304
+ ]);
4305
+ return i ? c : void 0;
4306
+ }
4307
+ //#endregion
4308
+ //#region lib/components/ui/media/image-editor/use-redact-modes.ts
4309
+ function wo(e) {
4310
+ return j(() => wr(e), [wr(e).join()]);
4311
+ }
4312
+ function To(e, t) {
4313
+ return j(() => {
4314
+ let n = (e) => Tr(t, e), r = (e) => e.kind === "redact" ? {
4315
+ ...e,
4316
+ mode: n(e.mode ?? "solid")
4317
+ } : e;
4318
+ return {
4319
+ ...e,
4320
+ setBrush: (t) => e.setBrush(t.redactMode ? {
4321
+ ...t,
4322
+ redactMode: n(t.redactMode)
4323
+ } : t),
4324
+ addAnnotation: (t) => e.addAnnotation(r(t)),
4325
+ updateAnnotation: (t) => e.updateAnnotation({
4326
+ ...t,
4327
+ annotation: r(t.annotation)
4328
+ })
4329
+ };
4330
+ }, [e, t]);
4331
+ }
4332
+ //#endregion
4333
+ //#region lib/components/ui/media/image-editor/use-image-editor.ts
4334
+ var Eo = (e) => w(xr, e);
4335
+ function Do(e) {
4336
+ let t = so(e), n = wo(e.redactModes), [r, i] = Eo(oo(e, t, n)), a = To(i, n), o = bo(e.src, e.decode), s = o.status === "ready" ? q(o.original, r.edits.transform.quarterTurns) : null, c = C(e.onEditsChange);
4337
+ Wt(() => {
4338
+ c.current?.(r.edits);
4339
+ }, [r.edits]), Oo(e.defaultEdits?.crop ? void 0 : e.aspect, o.status === "ready" ? o.original : null, e.defaultEdits?.transform?.quarterTurns ?? 0, a);
4340
+ let l = _o(r.zoom, a.setZoom), u = M(null), d = qi(r.tool, r.edits.crop), f = Qi(u, s && {
4341
+ width: d.w * s.width,
4342
+ height: d.h * s.height
4343
+ }, r.zoom, l, e.toolbar === "floating" && r.tool === "crop"), p = ao({
4344
+ source: o,
4345
+ edits: r.edits,
4346
+ options: r.exportOptions,
4347
+ fileName: e.fileName ?? "image",
4348
+ maxSize: e.maxExportSize,
4349
+ onSave: e.onSave
4350
+ }), m = Sr.selectSelected(r), h = ho(a, m, l, Co(r, a, d, s));
4351
+ return {
4352
+ state: r,
4353
+ actions: a,
4354
+ source: o,
4355
+ base: s,
4356
+ tools: t,
4357
+ colors: e.colors?.length ? e.colors : Ln,
4358
+ markupTools: e.markupTools?.length ? e.markupTools : void 0,
4359
+ redactModes: n,
4360
+ aspectPresets: e.aspectPresets ?? In,
4361
+ lockedAspect: e.aspect,
4362
+ canUndo: Sr.selectCanUndo(r),
4363
+ canRedo: Sr.selectCanRedo(r),
4364
+ selected: m,
4365
+ zoom: l,
4366
+ stageRef: u,
4367
+ view: d,
4368
+ scale: f,
4369
+ exporting: p,
4370
+ onSave: e.onSave,
4371
+ onCancel: e.onCancel,
4372
+ saveLabel: e.saveLabel,
4373
+ hideDownload: e.hideDownload ?? !1,
4374
+ toolbar: e.toolbar ?? "panel",
4375
+ fileName: e.fileName,
4376
+ onKeyDown: h
4377
+ };
4378
+ }
4379
+ function Oo(e, t, n, r) {
4380
+ let i = C(n);
4381
+ k(() => {
4382
+ if (!e || !t) return;
4383
+ let n = q(t, i.current);
4384
+ r.setCrop({ rect: tr({
4385
+ x: 0,
4386
+ y: 0,
4387
+ w: 1,
4388
+ h: 1
4389
+ }, e, n) }), r.clearHistory();
4390
+ }, [
4391
+ r,
4392
+ e,
4393
+ t,
4394
+ i
4395
+ ]);
4396
+ }
4397
+ //#endregion
4398
+ //#region lib/components/ui/media/image-editor/image-editor.tsx
4399
+ function ko(t) {
4400
+ let n = Do(t), { t: r } = x();
4401
+ return /* @__PURE__ */ F(En, {
4402
+ value: n,
4403
+ children: /* @__PURE__ */ I("div", {
4404
+ "data-slot": "image-editor",
4405
+ className: e("@container/image-editor flex h-[600px] min-h-0 flex-col overflow-hidden rounded-xl border bg-background text-foreground", t.className),
4406
+ onKeyDown: n.onKeyDown,
4407
+ children: [
4408
+ /* @__PURE__ */ F(Qa, {}),
4409
+ n.exporting.failed && /* @__PURE__ */ F("div", {
4410
+ role: "alert",
4411
+ className: "shrink-0 bg-error/10 px-4 py-2 text-error-text text-sm",
4412
+ children: r("material.image-editor.export.error", "The image could not be saved. Try again, or pick another format.")
4413
+ }),
4414
+ /* @__PURE__ */ I("div", {
4415
+ className: "flex min-h-0 flex-1 flex-col @3xl/image-editor:flex-row",
4416
+ children: [/* @__PURE__ */ F(Fa, {}), n.toolbar === "panel" && /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(Ui, {}), /* @__PURE__ */ F(za, {})] })]
4417
+ })
4418
+ ]
4419
+ })
4420
+ });
4421
+ }
4422
+ //#endregion
4423
+ export { wn as a, bn as c, ln as d, In as i, vn as l, Fi as n, Sn as o, Ir as r, yn as s, ko as t, un as u };