@uploadcare/file-uploader 1.28.0-alpha.0 → 1.28.0-alpha.1

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 (466) hide show
  1. package/dist/ActivityHeader-R6Mlx-dA.js +9 -0
  2. package/dist/ActivityHeader.css +23 -0
  3. package/dist/ActivityHeader.layered.css +24 -0
  4. package/dist/{CameraSource-DbyO6GoK.js → CameraSource-DDwj1jCV.js} +106 -76
  5. package/dist/CameraSource-n1tun2Df.js +10 -0
  6. package/dist/CameraSource.css +180 -0
  7. package/dist/CameraSource.layered.css +209 -0
  8. package/dist/{CloudImageEditor-BIxf1V4M.js → CloudImageEditor-DcVoIRb3.js} +66 -65
  9. package/dist/{CloudImageEditorActivity-d4DpK6fQ.js → CloudImageEditorActivity-Csij4nlC.js} +4 -4
  10. package/dist/{CloudImageEditorActivity-CJxP5N0S.js → CloudImageEditorActivity-DD4NdU0P.js} +4 -4
  11. package/dist/CloudImageEditorActivity.css +14 -0
  12. package/dist/CloudImageEditorActivity.layered.css +15 -0
  13. package/dist/{Config-DuWre5p3.js → Config-DKOromHY.js} +27 -27
  14. package/dist/Config.css +4 -0
  15. package/dist/Config.layered.css +5 -0
  16. package/dist/ExternalSource-6MSUgxqy.js +10 -0
  17. package/dist/{ExternalSource-BKTFp95O.js → ExternalSource-DVEjSkPB.js} +56 -51
  18. package/dist/ExternalSource.css +98 -0
  19. package/dist/ExternalSource.layered.css +116 -0
  20. package/dist/{Icon-CqTVC82Q.js → Icon-tXRTvEF2.js} +7 -8
  21. package/dist/Icon.css +14 -0
  22. package/dist/Icon.layered.css +15 -0
  23. package/dist/{LitUploaderBlock-BA34rzeU.js → LitUploaderBlock-LxeOZ0ya.js} +65 -65
  24. package/dist/{UrlSource-DZK5EBwT.js → UrlSource-BkyX00I2.js} +5 -5
  25. package/dist/UrlSource-RI8TSD48.js +10 -0
  26. package/dist/UrlSource.css +17 -0
  27. package/dist/UrlSource.layered.css +18 -0
  28. package/dist/abstract/loadFileUploaderFrom.js +3 -3
  29. package/dist/cameraPlugin-weRKO7eG.js +8 -0
  30. package/dist/{cloud-image-editor-fNswWrI4.js → cloud-image-editor-hhbyNWLG.js} +6 -6
  31. package/dist/cloud-image-editor.css +1380 -0
  32. package/dist/cloud-image-editor.layered.css +1549 -0
  33. package/dist/cloudImageEditorPlugin-FjUgbMK3.js +8 -0
  34. package/dist/{en-DNCwRJsB.js → en-8OWEmZim.js} +2 -2
  35. package/dist/env-mM-ksNPq.js +8 -0
  36. package/dist/env.js +3 -3
  37. package/dist/externalSourcesPlugin-CMBmLT8S.js +8 -0
  38. package/dist/imageShrinkPlugin-BN6loiP2.js +8 -0
  39. package/dist/index-base.css +2497 -0
  40. package/dist/index-base.layered.css +2837 -0
  41. package/dist/index.css +9 -3964
  42. package/dist/index.d.ts +13 -0
  43. package/dist/index.js +827 -42
  44. package/dist/index.layered.css +9 -4478
  45. package/dist/instagramPlugin-CXRm8MGL.js +8 -0
  46. package/dist/{loadFileUploaderFrom-BWJM43Yq.js → loadFileUploaderFrom-Bfz8L3VB.js} +3 -3
  47. package/dist/locales/file-uploader/ar.js +2 -2
  48. package/dist/locales/file-uploader/az.js +2 -2
  49. package/dist/locales/file-uploader/ca.js +2 -2
  50. package/dist/locales/file-uploader/cs.js +2 -2
  51. package/dist/locales/file-uploader/da.js +2 -2
  52. package/dist/locales/file-uploader/de.js +2 -2
  53. package/dist/locales/file-uploader/el.js +2 -2
  54. package/dist/locales/file-uploader/en.js +3 -3
  55. package/dist/locales/file-uploader/es.js +2 -2
  56. package/dist/locales/file-uploader/et.js +2 -2
  57. package/dist/locales/file-uploader/fi.js +2 -2
  58. package/dist/locales/file-uploader/fr.js +2 -2
  59. package/dist/locales/file-uploader/he.js +2 -2
  60. package/dist/locales/file-uploader/hy.js +2 -2
  61. package/dist/locales/file-uploader/is.js +2 -2
  62. package/dist/locales/file-uploader/it.js +2 -2
  63. package/dist/locales/file-uploader/ja.js +2 -2
  64. package/dist/locales/file-uploader/ka.js +2 -2
  65. package/dist/locales/file-uploader/kk.js +2 -2
  66. package/dist/locales/file-uploader/ko.js +2 -2
  67. package/dist/locales/file-uploader/lv.js +2 -2
  68. package/dist/locales/file-uploader/nb.js +2 -2
  69. package/dist/locales/file-uploader/nl.js +2 -2
  70. package/dist/locales/file-uploader/pl.js +2 -2
  71. package/dist/locales/file-uploader/pt.js +2 -2
  72. package/dist/locales/file-uploader/ro.js +2 -2
  73. package/dist/locales/file-uploader/ru.js +2 -2
  74. package/dist/locales/file-uploader/sk.js +2 -2
  75. package/dist/locales/file-uploader/sr.js +2 -2
  76. package/dist/locales/file-uploader/sv.js +2 -2
  77. package/dist/locales/file-uploader/tr.js +2 -2
  78. package/dist/locales/file-uploader/uk.js +2 -2
  79. package/dist/locales/file-uploader/vi.js +2 -2
  80. package/dist/locales/file-uploader/zh-TW.js +2 -2
  81. package/dist/locales/file-uploader/zh.js +2 -2
  82. package/dist/{plugins-DxjsQUa8.js → plugins-CGUls7EV.js} +6 -6
  83. package/dist/urlSourcePlugin-_WdbEhq2.js +8 -0
  84. package/package.json +1 -1
  85. package/web/ActivityHeader-BFdTdVfD.js +9 -0
  86. package/web/ActivityHeader-DQy6rII1.js +9 -0
  87. package/web/ActivityHeader-DvzMl0uj.js +9 -0
  88. package/web/ActivityHeader-i4x6_Fne.js +9 -0
  89. package/web/CameraSource-BAWIA4Wm.js +508 -0
  90. package/web/CameraSource-BqZCQcij.js +11 -0
  91. package/web/CameraSource-Brxr4tz4.js +508 -0
  92. package/web/CameraSource-BvBJ5Uzy.js +508 -0
  93. package/web/CameraSource-CkHzIE-h.js +11 -0
  94. package/web/CameraSource-D964yPLu.js +508 -0
  95. package/web/CameraSource-DE48Az-f.js +11 -0
  96. package/web/CameraSource-DyPebtRF.js +478 -0
  97. package/web/CameraSource-pj7Xo81m.js +11 -0
  98. package/web/CloudImageEditor-CTgUWB07.js +2192 -0
  99. package/web/CloudImageEditor-CxqV9Lwm.js +2192 -0
  100. package/web/CloudImageEditor-DoLWHpqV.js +2192 -0
  101. package/web/CloudImageEditor-Drywn265.js +2192 -0
  102. package/web/CloudImageEditor-MXcaDtMx.js +2187 -0
  103. package/web/CloudImageEditorActivity-BPzmfaJV.js +85 -0
  104. package/web/CloudImageEditorActivity-Br8pU5gd.js +11 -0
  105. package/web/CloudImageEditorActivity-Cw8b2CEz.js +11 -0
  106. package/web/CloudImageEditorActivity-Df1ySGq0.js +86 -0
  107. package/web/CloudImageEditorActivity-DinG5r0y.js +11 -0
  108. package/web/CloudImageEditorActivity-DmnLLINR.js +85 -0
  109. package/web/CloudImageEditorActivity-U90BGCek.js +85 -0
  110. package/web/CloudImageEditorActivity-dNLQZRZI.js +11 -0
  111. package/web/CloudImageEditorActivity-ur-hQ-6p.js +85 -0
  112. package/web/Config-8hlBNhvs.js +455 -0
  113. package/web/Config-BDZhPIyz.js +455 -0
  114. package/web/Config-CJVNrrjj.js +455 -0
  115. package/web/Config-DvkVtlQ7.js +455 -0
  116. package/web/ExternalSource-B9ycBFiD.js +10 -0
  117. package/web/ExternalSource-BE7HX47E.js +250 -0
  118. package/web/ExternalSource-BL5GSlol.js +250 -0
  119. package/web/ExternalSource-BXQY6Dlc.js +10 -0
  120. package/web/ExternalSource-BXxH3JCD.js +250 -0
  121. package/web/ExternalSource-BYSS-PPV.js +245 -0
  122. package/web/ExternalSource-C57a61QN.js +10 -0
  123. package/web/ExternalSource-CKfMtOgU.js +250 -0
  124. package/web/ExternalSource-DP6q8ylB.js +10 -0
  125. package/web/LitUploaderBlock-AX6jOdAS.js +996 -0
  126. package/web/LitUploaderBlock-BjAaoLl2.js +996 -0
  127. package/web/LitUploaderBlock-D8E5HuwH.js +996 -0
  128. package/web/LitUploaderBlock-Dl3ce0Tc.js +996 -0
  129. package/web/LitUploaderBlock-Oi33U0uf.js +996 -0
  130. package/web/UrlSource-B9SX3K0L.js +10 -0
  131. package/web/UrlSource-C3zB1rCb.js +70 -0
  132. package/web/UrlSource-C7bEU6Xv.js +10 -0
  133. package/web/UrlSource-CE389CBz.js +70 -0
  134. package/web/UrlSource-CnvAJ58Y.js +10 -0
  135. package/web/UrlSource-CqF0h6B-.js +10 -0
  136. package/web/UrlSource-D-971Nut.js +70 -0
  137. package/web/UrlSource-DhI3YCt5.js +70 -0
  138. package/web/UrlSource-hWV7jtB2.js +70 -0
  139. package/web/abstract/CTX.d.ts +40 -0
  140. package/web/abstract/TypedCollection.d.ts +47 -0
  141. package/web/abstract/TypedCollection.test.d.ts +1 -0
  142. package/web/abstract/TypedData.d.ts +12 -0
  143. package/web/abstract/TypedData.test.d.ts +1 -0
  144. package/web/abstract/UploaderPublicApi.d.ts +41 -0
  145. package/web/abstract/buildOutputCollectionState.d.ts +3 -0
  146. package/web/abstract/customConfigOptions.d.ts +65 -0
  147. package/web/abstract/defineComponents.d.ts +1 -0
  148. package/web/abstract/features/ClipboardLayer.d.ts +12 -0
  149. package/web/abstract/loadFileUploaderFrom.d.ts +13 -0
  150. package/web/abstract/localeRegistry.d.ts +5 -0
  151. package/web/abstract/managers/LocaleManager.d.ts +10 -0
  152. package/web/abstract/managers/ModalManager.d.ts +53 -0
  153. package/web/abstract/managers/SecureUploadsManager.d.ts +7 -0
  154. package/web/abstract/managers/TelemetryManager.d.ts +41 -0
  155. package/web/abstract/managers/ValidationManager.d.ts +34 -0
  156. package/web/abstract/managers/__tests__/ModalManager.test.d.ts +13 -0
  157. package/web/abstract/managers/__tests__/SecureUploadsManager.test.d.ts +1 -0
  158. package/web/abstract/managers/a11y.d.ts +9 -0
  159. package/web/abstract/managers/plugin/PluginManager.d.ts +25 -0
  160. package/web/abstract/managers/plugin/PluginTypes.d.ts +146 -0
  161. package/web/abstract/managers/plugin/index.d.ts +2 -0
  162. package/web/abstract/sharedConfigKey.d.ts +2 -0
  163. package/web/abstract/uploadEntrySchema.d.ts +34 -0
  164. package/web/blocks/ActivityHeader/ActivityHeader.d.ts +8 -0
  165. package/web/blocks/CameraSource/CameraSource.d.ts +121 -0
  166. package/web/blocks/CameraSource/__tests__/calcCameraModes.test.d.ts +1 -0
  167. package/web/blocks/CameraSource/calcCameraModes.d.ts +5 -0
  168. package/web/blocks/CameraSource/constants.d.ts +15 -0
  169. package/web/blocks/CloudImageEditor/index.d.ts +1 -0
  170. package/web/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts +60 -0
  171. package/web/blocks/CloudImageEditor/src/CropFrame.d.ts +56 -0
  172. package/web/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts +24 -0
  173. package/web/blocks/CloudImageEditor/src/EditorButtonControl.d.ts +14 -0
  174. package/web/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts +13 -0
  175. package/web/blocks/CloudImageEditor/src/EditorFilterControl.d.ts +35 -0
  176. package/web/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +56 -0
  177. package/web/blocks/CloudImageEditor/src/EditorImageFader.d.ts +63 -0
  178. package/web/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +15 -0
  179. package/web/blocks/CloudImageEditor/src/EditorScroller.d.ts +15 -0
  180. package/web/blocks/CloudImageEditor/src/EditorSlider.d.ts +33 -0
  181. package/web/blocks/CloudImageEditor/src/EditorToolbar.d.ts +68 -0
  182. package/web/blocks/CloudImageEditor/src/crop-utils.d.ts +36 -0
  183. package/web/blocks/CloudImageEditor/src/crop-utils.test.d.ts +1 -0
  184. package/web/blocks/CloudImageEditor/src/cropper-constants.d.ts +10 -0
  185. package/web/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts +31 -0
  186. package/web/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts +19 -0
  187. package/web/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts +27 -0
  188. package/web/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts +38 -0
  189. package/web/blocks/CloudImageEditor/src/index.d.ts +15 -0
  190. package/web/blocks/CloudImageEditor/src/lib/classNames.d.ts +5 -0
  191. package/web/blocks/CloudImageEditor/src/lib/classNames.test.d.ts +1 -0
  192. package/web/blocks/CloudImageEditor/src/lib/linspace.d.ts +1 -0
  193. package/web/blocks/CloudImageEditor/src/lib/linspace.test.d.ts +1 -0
  194. package/web/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +4 -0
  195. package/web/blocks/CloudImageEditor/src/lib/parseCropPreset.test.d.ts +1 -0
  196. package/web/blocks/CloudImageEditor/src/lib/parseTabs.d.ts +2 -0
  197. package/web/blocks/CloudImageEditor/src/lib/pick.d.ts +1 -0
  198. package/web/blocks/CloudImageEditor/src/lib/pick.test.d.ts +1 -0
  199. package/web/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +7 -0
  200. package/web/blocks/CloudImageEditor/src/state.d.ts +20 -0
  201. package/web/blocks/CloudImageEditor/src/svg-sprite.d.ts +2 -0
  202. package/web/blocks/CloudImageEditor/src/toolbar-constants.d.ts +61 -0
  203. package/web/blocks/CloudImageEditor/src/types.d.ts +60 -0
  204. package/web/blocks/CloudImageEditor/src/util.d.ts +2 -0
  205. package/web/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts +7 -0
  206. package/web/blocks/CloudImageEditor/src/utils/parseFilterValue.test.d.ts +1 -0
  207. package/web/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +25 -0
  208. package/web/blocks/Config/Config.d.ts +60 -0
  209. package/web/blocks/Config/assertions.d.ts +5 -0
  210. package/web/blocks/Config/computed-properties.d.ts +24 -0
  211. package/web/blocks/Config/computed-properties.test.d.ts +1 -0
  212. package/web/blocks/Config/initialConfig.d.ts +6 -0
  213. package/web/blocks/Config/normalizeConfigValue.d.ts +2 -0
  214. package/web/blocks/Config/validatorsType.d.ts +18 -0
  215. package/web/blocks/Copyright/Copyright.d.ts +10 -0
  216. package/web/blocks/DropArea/DropArea.d.ts +47 -0
  217. package/web/blocks/DropArea/addDropzone.d.ts +17 -0
  218. package/web/blocks/DropArea/getDropItems.d.ts +12 -0
  219. package/web/blocks/ExternalSource/ExternalSource.d.ts +45 -0
  220. package/web/blocks/ExternalSource/MessageBridge.d.ts +11 -0
  221. package/web/blocks/ExternalSource/buildThemeDefinition.d.ts +4 -0
  222. package/web/blocks/ExternalSource/query-string.d.ts +1 -0
  223. package/web/blocks/ExternalSource/types.d.ts +105 -0
  224. package/web/blocks/FileItem/FileItem.d.ts +50 -0
  225. package/web/blocks/FileItem/FileItemConfig.d.ts +10 -0
  226. package/web/blocks/FormInput/FormInput.d.ts +18 -0
  227. package/web/blocks/Icon/Icon.d.ts +19 -0
  228. package/web/blocks/Img/Img.d.ts +14 -0
  229. package/web/blocks/Img/ImgBase.d.ts +29 -0
  230. package/web/blocks/Img/ImgConfig.d.ts +28 -0
  231. package/web/blocks/Img/configurations.d.ts +11 -0
  232. package/web/blocks/Img/props-map.d.ts +28 -0
  233. package/web/blocks/Img/utils/parseObjectToString.d.ts +2 -0
  234. package/web/blocks/Modal/Modal.d.ts +34 -0
  235. package/web/blocks/PluginActivityRenderer/PluginActivityRenderer.d.ts +32 -0
  236. package/web/blocks/PluginActivityRenderer/index.d.ts +1 -0
  237. package/web/blocks/ProgressBar/ProgressBar.d.ts +21 -0
  238. package/web/blocks/ProgressBarCommon/ProgressBarCommon.d.ts +17 -0
  239. package/web/blocks/Select/Select.d.ts +18 -0
  240. package/web/blocks/SimpleBtn/SimpleBtn.d.ts +15 -0
  241. package/web/blocks/SourceBtn/SourceBtn.d.ts +23 -0
  242. package/web/blocks/SourceList/SourceList.d.ts +24 -0
  243. package/web/blocks/Spinner/Spinner.d.ts +9 -0
  244. package/web/blocks/StartFrom/StartFrom.d.ts +12 -0
  245. package/web/blocks/Thumb/Thumb.d.ts +35 -0
  246. package/web/blocks/UploadCtxProvider/EventEmitter.d.ts +70 -0
  247. package/web/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +44 -0
  248. package/web/blocks/UploadList/UploadList.d.ts +39 -0
  249. package/web/blocks/UrlSource/UrlSource.d.ts +14 -0
  250. package/web/blocks/svg-backgrounds/svg-backgrounds.d.ts +3 -0
  251. package/web/blocks/themes/uc-basic/svg-sprite.d.ts +2 -0
  252. package/web/cameraPlugin-DeedXMWV.js +8 -0
  253. package/web/cameraPlugin-Duy1QwjB.js +8 -0
  254. package/web/cameraPlugin-QS9SUOtO.js +8 -0
  255. package/web/cameraPlugin-bq8ggY04.js +8 -0
  256. package/web/cameraPlugin-cel9YgP_.js +8 -0
  257. package/web/cloud-image-editor-8DrVRZ7E.js +12 -0
  258. package/web/cloud-image-editor-BX50EK1U.js +12 -0
  259. package/web/cloud-image-editor-DSW3oWq-.js +12 -0
  260. package/web/cloud-image-editor-DuI2Lx4M.js +12 -0
  261. package/web/cloudImageEditorPlugin-5my6aD36.js +8 -0
  262. package/web/cloudImageEditorPlugin-Bk19DmJv.js +8 -0
  263. package/web/cloudImageEditorPlugin-CcdnmtBW.js +8 -0
  264. package/web/cloudImageEditorPlugin-DQJmDl03.js +8 -0
  265. package/web/cloudImageEditorPlugin-kojghfqw.js +8 -0
  266. package/web/constants-BCfCF0cJ.js +4025 -0
  267. package/web/core.d.ts +42 -0
  268. package/web/env.d.ts +2 -0
  269. package/web/externalSourcesPlugin-BTeRm5C0.js +8 -0
  270. package/web/externalSourcesPlugin-BXgVeojg.js +8 -0
  271. package/web/externalSourcesPlugin-BgLpuIK9.js +8 -0
  272. package/web/externalSourcesPlugin-DMc9zs4T.js +8 -0
  273. package/web/externalSourcesPlugin-Dm9vnTBv.js +8 -0
  274. package/web/file-uploader.iife.min.js +697 -0
  275. package/web/file-uploader.min.js +1859 -0
  276. package/web/imageShrinkPlugin-BdHgEGZH.js +8 -0
  277. package/web/imageShrinkPlugin-BjkMGfvT.js +8 -0
  278. package/web/imageShrinkPlugin-CCkGHL2w.js +8 -0
  279. package/web/imageShrinkPlugin-D4WjaRGo.js +8 -0
  280. package/web/imageShrinkPlugin-DqYGutVx.js +8 -0
  281. package/web/index.d.ts +42 -0
  282. package/web/instagramPlugin-BTMz0K2a.js +8 -0
  283. package/web/instagramPlugin-BbIKgTH7.js +8 -0
  284. package/web/instagramPlugin-CQQhsEJa.js +8 -0
  285. package/web/instagramPlugin-Cm7lWKae.js +8 -0
  286. package/web/instagramPlugin-DcclxM_d.js +8 -0
  287. package/web/lit/BaseComponent.d.ts +12 -0
  288. package/web/lit/Constructor.d.ts +1 -0
  289. package/web/lit/CssDataMixin.d.ts +7 -0
  290. package/web/lit/LightDomMixin.d.ts +8 -0
  291. package/web/lit/LitActivityBlock.d.ts +53 -0
  292. package/web/lit/LitBlock.d.ts +83 -0
  293. package/web/lit/LitSolutionBlock.d.ts +21 -0
  294. package/web/lit/LitUploaderBlock.d.ts +53 -0
  295. package/web/lit/PubSubCompat.d.ts +18 -0
  296. package/web/lit/RegisterableElementMixin.d.ts +7 -0
  297. package/web/lit/SharedState.d.ts +119 -0
  298. package/web/lit/SymbioteCompatMixin.d.ts +40 -0
  299. package/web/lit/TestModeController.d.ts +16 -0
  300. package/web/lit/Uid.d.ts +3 -0
  301. package/web/lit/activity-constants.d.ts +11 -0
  302. package/web/lit/createDebugPrinter.d.ts +3 -0
  303. package/web/lit/findBlockInCtx.d.ts +3 -0
  304. package/web/lit/getOutputData.d.ts +2 -0
  305. package/web/lit/hasBlockInCtx.d.ts +3 -0
  306. package/web/lit/l10n.d.ts +5 -0
  307. package/web/lit/parseCssPropertyValue.d.ts +1 -0
  308. package/web/lit/shared-instances.d.ts +65 -0
  309. package/web/locales/file-uploader/ar.d.ts +137 -0
  310. package/web/locales/file-uploader/az.d.ts +129 -0
  311. package/web/locales/file-uploader/ca.d.ts +131 -0
  312. package/web/locales/file-uploader/cs.d.ts +133 -0
  313. package/web/locales/file-uploader/da.d.ts +129 -0
  314. package/web/locales/file-uploader/de.d.ts +129 -0
  315. package/web/locales/file-uploader/el.d.ts +129 -0
  316. package/web/locales/file-uploader/en.d.ts +129 -0
  317. package/web/locales/file-uploader/es.d.ts +131 -0
  318. package/web/locales/file-uploader/et.d.ts +129 -0
  319. package/web/locales/file-uploader/fi.d.ts +129 -0
  320. package/web/locales/file-uploader/fr.d.ts +131 -0
  321. package/web/locales/file-uploader/he.d.ts +131 -0
  322. package/web/locales/file-uploader/hy.d.ts +129 -0
  323. package/web/locales/file-uploader/is.d.ts +129 -0
  324. package/web/locales/file-uploader/it.d.ts +131 -0
  325. package/web/locales/file-uploader/ja.d.ts +129 -0
  326. package/web/locales/file-uploader/ka.d.ts +129 -0
  327. package/web/locales/file-uploader/kk.d.ts +129 -0
  328. package/web/locales/file-uploader/ko.d.ts +129 -0
  329. package/web/locales/file-uploader/lv.d.ts +131 -0
  330. package/web/locales/file-uploader/nb.d.ts +129 -0
  331. package/web/locales/file-uploader/nl.d.ts +129 -0
  332. package/web/locales/file-uploader/pl.d.ts +133 -0
  333. package/web/locales/file-uploader/pt.d.ts +131 -0
  334. package/web/locales/file-uploader/ro.d.ts +131 -0
  335. package/web/locales/file-uploader/ru.d.ts +133 -0
  336. package/web/locales/file-uploader/sk.d.ts +133 -0
  337. package/web/locales/file-uploader/sr.d.ts +131 -0
  338. package/web/locales/file-uploader/sv.d.ts +129 -0
  339. package/web/locales/file-uploader/tr.d.ts +129 -0
  340. package/web/locales/file-uploader/uk.d.ts +133 -0
  341. package/web/locales/file-uploader/vi.d.ts +129 -0
  342. package/web/locales/file-uploader/zh-TW.d.ts +129 -0
  343. package/web/locales/file-uploader/zh.d.ts +129 -0
  344. package/web/plugins/cameraPlugin.d.ts +2 -0
  345. package/web/plugins/cloudImageEditorPlugin.d.ts +2 -0
  346. package/web/plugins/externalSourcesPlugin.d.ts +2 -0
  347. package/web/plugins/imageShrinkPlugin.d.ts +2 -0
  348. package/web/plugins/instagramPlugin.d.ts +2 -0
  349. package/web/plugins/unsplashPlugin.d.ts +16 -0
  350. package/web/plugins/urlSourcePlugin.d.ts +2 -0
  351. package/web/plugins-Bt7FXHKx.js +562 -0
  352. package/web/plugins-CaaolyMk.js +562 -0
  353. package/web/plugins-Cjgw5oWg.js +562 -0
  354. package/web/plugins-CzNtrVQB.js +562 -0
  355. package/web/plugins-DS0hIs2V.js +563 -0
  356. package/web/ref-BOnG19ns.js +4040 -0
  357. package/web/ref-BejJFG7m.js +4040 -0
  358. package/web/ref-DcRg7zo9.js +4040 -0
  359. package/web/ref-ZWPcLQB9.js +4040 -0
  360. package/web/solutions/adaptive-image/index.d.ts +2 -0
  361. package/web/solutions/cloud-image-editor/CloudImageEditor.d.ts +11 -0
  362. package/web/solutions/cloud-image-editor/index.d.ts +5 -0
  363. package/web/solutions/file-uploader/inline/FileUploaderInline.d.ts +20 -0
  364. package/web/solutions/file-uploader/inline/index.d.ts +1 -0
  365. package/web/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +23 -0
  366. package/web/solutions/file-uploader/minimal/index.d.ts +1 -0
  367. package/web/solutions/file-uploader/regular/FileUploaderRegular.d.ts +17 -0
  368. package/web/solutions/file-uploader/regular/index.d.ts +1 -0
  369. package/web/style-map-BmZdux7T.js +37 -0
  370. package/web/style-map-CZ6fSV6e.js +37 -0
  371. package/web/style-map-Dk7mLCrB.js +37 -0
  372. package/web/style-map-HkHnu9oA.js +37 -0
  373. package/web/style-map-tw1yUEaj.js +37 -0
  374. package/web/types/dom.d.ts +1 -0
  375. package/web/types/events.d.ts +4 -0
  376. package/web/types/exported.d.ts +492 -0
  377. package/web/types/index.d.ts +5 -0
  378. package/web/uc-basic.layered.min.css +6046 -0
  379. package/web/uc-basic.min.css +5487 -0
  380. package/web/uc-cloud-image-editor.layered.min.css +1884 -0
  381. package/web/uc-cloud-image-editor.min.css +1675 -0
  382. package/web/uc-cloud-image-editor.min.js +457 -0
  383. package/web/uc-file-uploader-inline.layered.min.css +4352 -0
  384. package/web/uc-file-uploader-inline.min.css +3836 -0
  385. package/web/uc-file-uploader-inline.min.js +1859 -0
  386. package/web/uc-file-uploader-minimal.layered.min.css +4352 -0
  387. package/web/uc-file-uploader-minimal.min.css +3836 -0
  388. package/web/uc-file-uploader-minimal.min.js +1859 -0
  389. package/web/uc-file-uploader-regular.layered.min.css +4352 -0
  390. package/web/uc-file-uploader-regular.min.css +3836 -0
  391. package/web/uc-file-uploader-regular.min.js +1859 -0
  392. package/web/uc-img.min.js +895 -0
  393. package/web/urlSourcePlugin-9lhcr02f.js +8 -0
  394. package/web/urlSourcePlugin-C-sLGhGb.js +8 -0
  395. package/web/urlSourcePlugin-DNXDpnRD.js +8 -0
  396. package/web/urlSourcePlugin-JnD0cnxb.js +8 -0
  397. package/web/urlSourcePlugin-hcMU2K6T.js +8 -0
  398. package/web/utils/UID.d.ts +5 -0
  399. package/web/utils/UID.test.d.ts +1 -0
  400. package/web/utils/UploadSource.d.ts +37 -0
  401. package/web/utils/WindowHeightTracker.d.ts +9 -0
  402. package/web/utils/abilities.d.ts +1 -0
  403. package/web/utils/applyStyles.d.ts +1 -0
  404. package/web/utils/browser-info.d.ts +12 -0
  405. package/web/utils/browser-info.test.d.ts +1 -0
  406. package/web/utils/cdn-utils.d.ts +53 -0
  407. package/web/utils/cdn-utils.test.d.ts +1 -0
  408. package/web/utils/comma-separated.d.ts +2 -0
  409. package/web/utils/debounce.d.ts +3 -0
  410. package/web/utils/delay.d.ts +1 -0
  411. package/web/utils/fileTypes.d.ts +11 -0
  412. package/web/utils/fileTypes.test.d.ts +1 -0
  413. package/web/utils/get-top-level-origin.d.ts +1 -0
  414. package/web/utils/get-top-level-origin.test.d.ts +1 -0
  415. package/web/utils/getLocaleDirection.d.ts +1 -0
  416. package/web/utils/getPluralForm.d.ts +1 -0
  417. package/web/utils/getPluralForm.test.d.ts +1 -0
  418. package/web/utils/isPromiseLike.d.ts +1 -0
  419. package/web/utils/isPromiseLike.test.d.ts +1 -0
  420. package/web/utils/isSecureTokenExpired.d.ts +8 -0
  421. package/web/utils/isSecureTokenExpired.test.d.ts +1 -0
  422. package/web/utils/memoize.d.ts +1 -0
  423. package/web/utils/memoize.test.d.ts +1 -0
  424. package/web/utils/mixinClass.d.ts +8 -0
  425. package/web/utils/parseCdnUrl.d.ts +11 -0
  426. package/web/utils/parseCdnUrl.test.d.ts +1 -0
  427. package/web/utils/parseShrink.d.ts +7 -0
  428. package/web/utils/parseShrink.test.d.ts +1 -0
  429. package/web/utils/preloadImage.d.ts +10 -0
  430. package/web/utils/prettyBytes.d.ts +11 -0
  431. package/web/utils/prettyBytes.test.d.ts +1 -0
  432. package/web/utils/resizeImage.d.ts +1 -0
  433. package/web/utils/stringToArray.d.ts +1 -0
  434. package/web/utils/stringToArray.test.d.ts +1 -0
  435. package/web/utils/template-utils.d.ts +16 -0
  436. package/web/utils/template-utils.test.d.ts +1 -0
  437. package/web/utils/throttle.d.ts +3 -0
  438. package/web/utils/toKebabCase.d.ts +2 -0
  439. package/web/utils/toKebabCase.test.d.ts +1 -0
  440. package/web/utils/transparentPixelSrc.d.ts +1 -0
  441. package/web/utils/uniqueArray.d.ts +1 -0
  442. package/web/utils/uniqueArray.test.d.ts +1 -0
  443. package/web/utils/userAgent.d.ts +2 -0
  444. package/web/utils/validators/collection/index.d.ts +2 -0
  445. package/web/utils/validators/collection/validateCollectionUploadError.d.ts +2 -0
  446. package/web/utils/validators/collection/validateMultiple.d.ts +2 -0
  447. package/web/utils/validators/file/index.d.ts +4 -0
  448. package/web/utils/validators/file/validateFileType.d.ts +2 -0
  449. package/web/utils/validators/file/validateIsImage.d.ts +2 -0
  450. package/web/utils/validators/file/validateMaxSizeLimit.d.ts +2 -0
  451. package/web/utils/validators/file/validateUploadError.d.ts +2 -0
  452. package/web/utils/warnOnce.d.ts +1 -0
  453. package/web/utils/wildcardRegexp.d.ts +1 -0
  454. package/web/utils/wildcardRegexp.test.d.ts +1 -0
  455. package/web/utils/withResolvers.d.ts +5 -0
  456. package/web/utils/withResolvers.test.d.ts +1 -0
  457. package/dist/CameraSource-px4BzEMI.js +0 -9
  458. package/dist/ExternalSource-CR5DG0Jv.js +0 -9
  459. package/dist/UrlSource-BxVL9Pve.js +0 -9
  460. package/dist/cameraPlugin-dGash48Q.js +0 -8
  461. package/dist/cloudImageEditorPlugin-2EU0Pm_j.js +0 -8
  462. package/dist/env-B1nfXy9i.js +0 -8
  463. package/dist/externalSourcesPlugin-DKQqk3AC.js +0 -8
  464. package/dist/imageShrinkPlugin-DAx8eRen.js +0 -8
  465. package/dist/instagramPlugin-k67tMAo3.js +0 -8
  466. package/dist/urlSourcePlugin-9xdB7Pvw.js +0 -8
@@ -0,0 +1,2187 @@
1
+ /**
2
+ * @license
3
+ * Package: @uploadcare/file-uploader@1.28.0-alpha.1 (MIT)
4
+ * License: https://github.com/uploadcare/blob/main/LICENSE
5
+ * Built: 2026-03-02T20:26:12.501Z
6
+ */
7
+ import { $ as transformationsToOperations, A as parseCropPreset, C as MIN_CROP_SIZE, Ct as E, D as THUMB_STROKE_WIDTH, E as THUMB_SIDE_SIZE, F as debounce, G as ALL_COLOR_OPERATIONS, J as ALL_TABS, K as ALL_CROP_OPERATIONS, L as UID, M as __decorate, Q as operationsToTransformations, R as PACKAGE_NAME, S as MAX_INTERACTION_SIZE, St as A, T as THUMB_CORNER_SIZE, V as InternalEventType, X as TabId, Y as COLOR_OPERATIONS_CONFIG, Z as COMMON_OPERATIONS, _ as sidePath, _t as e$2, a as clamp, at as extractUuid, b as GUIDE_STROKE_WIDTH, bt as r, c as createSvgNode, d as moveRect, f as rectContainsPoint, g as setSvgNodeAttrs, gt as n$1, h as roundRect, ht as e, it as extractOperations, j as LitBlock, k as getClosestAspectRatio, l as isRectInsideRect, m as rotateSize, mt as o, nt as createCdnUrlModifiers, o as constraintRect, p as resizeRect, q as ALL_FILTERS, rt as createOriginalUrl, s as cornerPath, tt as createCdnUrl, u as isRectMatchesAspectRatio, v as thumbCursor, vt as i, w as MIN_INTERACTION_SIZE, wt as b, x as GUIDE_THIRD, xt as n, y as CROP_PADDING, yt as t, z as PACKAGE_VERSION } from "./constants-BCfCF0cJ.js";
8
+ import { f as deserializeCsv, p as serializeCsv } from "./plugins-DS0hIs2V.js";
9
+ import { t as o$1 } from "./style-map-tw1yUEaj.js";
10
+ /**
11
+ * @license
12
+ * Copyright 2021 Google LLC
13
+ * SPDX-License-Identifier: BSD-3-Clause
14
+ */
15
+ function n$2(p, B, V) {
16
+ return p ? B(p) : V?.(p);
17
+ }
18
+ const TRANSPARENT_PIXEL_SRC = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
19
+ function normalize(...p) {
20
+ return p.reduce((p, B) => {
21
+ if (typeof B == "string") return p[B] = !0, p;
22
+ for (let V of Object.keys(B)) p[V] = B[V];
23
+ return p;
24
+ }, {});
25
+ }
26
+ function classNames(...p) {
27
+ let B = normalize(...p);
28
+ return Object.keys(B).reduce((p, V) => (B[V] && p.push(V), p), []).join(" ");
29
+ }
30
+ function applyClassNames(p, ...B) {
31
+ let V = normalize(...B);
32
+ for (let B of Object.keys(V)) p.classList.toggle(B, !!V[B]);
33
+ }
34
+ var isTabIdValue = (p) => ALL_TABS.includes(p);
35
+ const parseTabs = (p) => {
36
+ if (!p) return ALL_TABS;
37
+ let B = deserializeCsv(p).filter(isTabIdValue);
38
+ return B.length === 0 ? ALL_TABS : B;
39
+ };
40
+ function initState(B) {
41
+ return {
42
+ "*originalUrl": null,
43
+ "*loadingOperations": /* @__PURE__ */ new Map(),
44
+ "*faderEl": null,
45
+ "*cropperEl": null,
46
+ "*imgEl": null,
47
+ "*imgContainerEl": null,
48
+ "*networkProblems": !1,
49
+ "*imageSize": null,
50
+ "*editorTransformations": {},
51
+ "*cropPresetList": [],
52
+ "*currentAspectRatio": null,
53
+ "*tabList": ALL_TABS,
54
+ "*tabId": TabId.CROP,
55
+ "*on.retryNetwork": () => {
56
+ let p = B.querySelectorAll("img");
57
+ for (let B of p) {
58
+ let p = B.src;
59
+ B.src = TRANSPARENT_PIXEL_SRC, B.src = p;
60
+ }
61
+ B.$["*networkProblems"] = !1;
62
+ },
63
+ "*on.apply": (V) => {
64
+ if (!V) return;
65
+ let H = B.$["*originalUrl"];
66
+ if (!H) {
67
+ console.warn("Original URL is null, cannot apply transformations");
68
+ return;
69
+ }
70
+ let U = createCdnUrlModifiers(transformationsToOperations(V), "preview"), W = {
71
+ originalUrl: H,
72
+ cdnUrlModifiers: U,
73
+ cdnUrl: createCdnUrl(H, U),
74
+ transformations: V
75
+ };
76
+ B.dispatchEvent(new CustomEvent("apply", {
77
+ detail: W,
78
+ bubbles: !0,
79
+ composed: !0
80
+ })), B.remove();
81
+ },
82
+ "*on.cancel": () => {
83
+ B.remove(), B.dispatchEvent(new CustomEvent("cancel", {
84
+ bubbles: !0,
85
+ composed: !0
86
+ }));
87
+ }
88
+ };
89
+ }
90
+ var svg_sprite_default = "<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='ruc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#uuc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#uuc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#uuc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#uuc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#uuc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#uuc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#uuc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>", DEFAULT_STYLE = {
91
+ transition: "uc-transition",
92
+ visible: "uc-visible",
93
+ hidden: "uc-hidden"
94
+ }, PresenceToggle = class extends LitBlock {
95
+ constructor(...p) {
96
+ super(...p), this._visible = !1, this._styles = DEFAULT_STYLE, this._visibleStyle = DEFAULT_STYLE.visible, this._hiddenStyle = DEFAULT_STYLE.hidden, this._externalTransitions = !1, this._initialRenderComplete = !1;
97
+ }
98
+ set visible(p) {
99
+ this._visible = p, this._handleVisible();
100
+ }
101
+ get visible() {
102
+ return this._visible;
103
+ }
104
+ set styles(p) {
105
+ this._styles = p, this._externalTransitions = !0, this._visibleStyle = p.visible ?? DEFAULT_STYLE.visible, this._hiddenStyle = p.hidden ?? DEFAULT_STYLE.hidden;
106
+ }
107
+ get styles() {
108
+ return this._styles;
109
+ }
110
+ _handleVisible() {
111
+ this.style.visibility = this._visible ? "inherit" : "hidden", applyClassNames(this, {
112
+ [DEFAULT_STYLE.transition]: !this._externalTransitions,
113
+ [this._visibleStyle]: this._visible,
114
+ [this._hiddenStyle]: !this._visible
115
+ }), this.toggleAttribute("inert", !this._visible);
116
+ }
117
+ _dispatchInitialRenderEvent() {
118
+ this._initialRenderComplete || (this._initialRenderComplete = !0, this.dispatchEvent(new CustomEvent("initial-render", {
119
+ bubbles: !0,
120
+ composed: !0
121
+ })));
122
+ }
123
+ initCallback() {
124
+ super.initCallback(), this.classList.toggle("uc-initial", !0), this._externalTransitions || this.classList.add(DEFAULT_STYLE.transition), this._handleVisible(), setTimeout(() => {
125
+ this.classList.toggle("uc-initial", !1), this._dispatchInitialRenderEvent();
126
+ }, 0);
127
+ }
128
+ };
129
+ __decorate([n({ type: Boolean })], PresenceToggle.prototype, "visible", null), __decorate([n({ attribute: !1 })], PresenceToggle.prototype, "styles", null);
130
+ var LineLoaderUi = class extends LitBlock {
131
+ constructor(...p) {
132
+ super(...p), this.active = !1, this._lineRef = e(), this._isAnimating = !1, this._handleTransitionEndRight = () => {
133
+ let p = this._lineRef.value;
134
+ p && (this._resetLine(p), this._isAnimating && this.active && this._start());
135
+ };
136
+ }
137
+ firstUpdated(p) {
138
+ super.firstUpdated(p), this.active && this._start();
139
+ }
140
+ updated(p) {
141
+ super.updated(p), p.has("active") && (this.active ? this._start() : this._stop());
142
+ }
143
+ _start() {
144
+ let p = this._lineRef.value;
145
+ if (!p) return;
146
+ this._isAnimating = !0;
147
+ let { width: B } = this.getBoundingClientRect();
148
+ p.removeEventListener("transitionend", this._handleTransitionEndRight), p.style.transition = "transform 1s", p.style.opacity = "1", p.style.transform = `translateX(${B}px)`, p.addEventListener("transitionend", this._handleTransitionEndRight, { once: !0 });
149
+ }
150
+ _stop() {
151
+ let p = this._lineRef.value;
152
+ p && (this._isAnimating = !1, p.removeEventListener("transitionend", this._handleTransitionEndRight), this._resetLine(p));
153
+ }
154
+ _resetLine(p) {
155
+ p.style.transition = "initial", p.style.opacity = "0", p.style.transform = "translateX(-101%)";
156
+ }
157
+ render() {
158
+ return b`
159
+ <div class="uc-inner">
160
+ <div class="uc-line" ${n$1(this._lineRef)}></div>
161
+ </div>
162
+ `;
163
+ }
164
+ };
165
+ __decorate([n({
166
+ type: Boolean,
167
+ reflect: !0
168
+ })], LineLoaderUi.prototype, "active", void 0);
169
+ /**
170
+ * @license
171
+ * Copyright 2018 Google LLC
172
+ * SPDX-License-Identifier: BSD-3-Clause
173
+ */ var e$1 = e$2(class extends i {
174
+ constructor(p) {
175
+ if (super(p), p.type !== t.ATTRIBUTE || p.name !== "class" || p.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
176
+ }
177
+ render(p) {
178
+ return " " + Object.keys(p).filter((B) => p[B]).join(" ") + " ";
179
+ }
180
+ update(p, [B]) {
181
+ if (this.st === void 0) {
182
+ for (let V in this.st = /* @__PURE__ */ new Set(), p.strings !== void 0 && (this.nt = new Set(p.strings.join(" ").split(/\s/).filter((p) => p !== ""))), B) B[V] && !this.nt?.has(V) && this.st.add(V);
183
+ return this.render(B);
184
+ }
185
+ let V = p.element.classList;
186
+ for (let p of this.st) p in B || (V.remove(p), this.st.delete(p));
187
+ for (let p in B) {
188
+ let H = !!B[p];
189
+ H === this.st.has(p) || this.nt?.has(p) || (H ? (V.add(p), this.st.add(p)) : (V.remove(p), this.st.delete(p)));
190
+ }
191
+ return E;
192
+ }
193
+ }), o$2 = (p) => p ?? A, BtnUi = class extends LitBlock {
194
+ constructor(...p) {
195
+ super(...p), this.text = "", this.icon = "", this.reverse = !1, this.theme = "default", this.ariaRole = void 0, this.ariaControls = "", this.titleProp = "", this.active = !1;
196
+ }
197
+ firstUpdated(p) {
198
+ super.firstUpdated(p), this._applyReverse(), this._applyThemeClass();
199
+ }
200
+ updated(p) {
201
+ super.updated(p), p.has("reverse") && this._applyReverse(), p.has("theme") && this._applyThemeClass();
202
+ }
203
+ _applyReverse() {
204
+ this.style.flexDirection = this.reverse ? "row-reverse" : "";
205
+ }
206
+ _applyThemeClass() {
207
+ this.theme && this.theme !== "custom" && (this.className = `uc-${this.theme}`);
208
+ }
209
+ get _iconClassMap() {
210
+ let p = this._computedIconHidden;
211
+ return {
212
+ "uc-icon": !0,
213
+ "uc-icon_left": !this.reverse,
214
+ "uc-icon_right": this.reverse,
215
+ "uc-icon_hidden": p,
216
+ "uc-icon_single": this._computedIconSingle
217
+ };
218
+ }
219
+ get _computedIconHidden() {
220
+ return !this.icon;
221
+ }
222
+ get _computedIconSingle() {
223
+ return !this.text && !this._computedIconHidden;
224
+ }
225
+ render() {
226
+ return b`
227
+ <button
228
+ type="button"
229
+ role=${o$2(this.ariaRole || void 0)}
230
+ aria-controls=${o$2(this.ariaControls || void 0)}
231
+ aria-label=${o$2(this.l10n(this.titleProp))}
232
+ title=${o$2(this.l10n(this.titleProp))}
233
+ >
234
+ <uc-icon
235
+ class=${e$1(this._iconClassMap)}
236
+ name=${o$2(this.icon || void 0)}
237
+ ?hidden=${this._computedIconHidden}
238
+ ></uc-icon>
239
+ <div class="uc-text">${this.text}</div>
240
+ </button>
241
+ `;
242
+ }
243
+ };
244
+ __decorate([n({ type: String })], BtnUi.prototype, "text", void 0), __decorate([n({ type: String })], BtnUi.prototype, "icon", void 0), __decorate([n({
245
+ type: Boolean,
246
+ reflect: !0
247
+ })], BtnUi.prototype, "reverse", void 0), __decorate([n({
248
+ type: String,
249
+ reflect: !0
250
+ })], BtnUi.prototype, "theme", void 0), __decorate([n({ attribute: "aria-role" })], BtnUi.prototype, "ariaRole", void 0), __decorate([n({ attribute: "aria-controls" })], BtnUi.prototype, "ariaControls", void 0), __decorate([n({ attribute: "title-prop" })], BtnUi.prototype, "titleProp", void 0), __decorate([n({
251
+ type: Boolean,
252
+ noAccessor: !0
253
+ })], BtnUi.prototype, "active", void 0);
254
+ function preloadImage(p) {
255
+ let B = new Image();
256
+ return {
257
+ promise: new Promise((V, H) => {
258
+ B.src = p, B.onload = () => V(), B.onerror = (p) => H(p);
259
+ }),
260
+ image: B,
261
+ cancel: () => {
262
+ B.naturalWidth === 0 && (B.src = TRANSPARENT_PIXEL_SRC);
263
+ }
264
+ };
265
+ }
266
+ function batchPreloadImages(p) {
267
+ let B = [];
268
+ for (let V of p) {
269
+ let p = preloadImage(V);
270
+ B.push(p);
271
+ }
272
+ let V = B.map((p) => p.image);
273
+ return {
274
+ promise: Promise.allSettled(B.map((p) => p.promise)),
275
+ images: V,
276
+ cancel: () => {
277
+ B.forEach((p) => {
278
+ p.cancel();
279
+ });
280
+ }
281
+ };
282
+ }
283
+ const throttle = (p, B) => {
284
+ let V = !1, H, U = 0, W = ((...W) => {
285
+ V ? (H && clearTimeout(H), H = setTimeout(() => {
286
+ Date.now() - U >= B && (p(...W), U = Date.now());
287
+ }, Math.max(B - (Date.now() - U), 0))) : (p(...W), U = Date.now(), V = !0);
288
+ });
289
+ return Object.defineProperty(W, "cancel", {
290
+ configurable: !1,
291
+ writable: !1,
292
+ enumerable: !1,
293
+ value: () => {
294
+ H && clearTimeout(H);
295
+ }
296
+ }), W;
297
+ };
298
+ function pick(p, B) {
299
+ let V = {};
300
+ for (let H of B) {
301
+ let B = p[H];
302
+ (Object.hasOwn(p, H) || B !== void 0) && (V[H] = B);
303
+ }
304
+ return V;
305
+ }
306
+ function viewerImageSrc(B, V, H) {
307
+ let U = window.devicePixelRatio, W = Math.min(Math.ceil(V * U), 3e3), G = U >= 2 ? "lightest" : "normal";
308
+ return createCdnUrl(B, createCdnUrlModifiers(COMMON_OPERATIONS, transformationsToOperations(H), `quality/${G}`, `stretch/off/-/resize/${W}x`, `@clib/${PACKAGE_NAME}/${PACKAGE_VERSION}/uc-cloud-image-editor/`));
309
+ }
310
+ var CropFrame = class extends LitBlock {
311
+ constructor(...p) {
312
+ super(...p), this._backdropMaskId = `uc-backdrop-mask-${UID.generateFastUid()}`, this._guidesHidden = !1, this._draggingValue = !1, this._svgRef = e(), this._svgReady = !1, this._pendingMaskHref = null, this._handlePointerUp = (p) => {
313
+ this._updateCursor(), this._dragging &&= (p.stopPropagation(), p.preventDefault(), !1);
314
+ }, this._handlePointerMove = (p) => {
315
+ if (!this._dragging || !this._dragStartPoint || !this._draggingThumb) return;
316
+ p.stopPropagation(), p.preventDefault();
317
+ let B = this._svgElement;
318
+ if (!B) return;
319
+ let { x: V, y: H } = B.getBoundingClientRect(), U = p.x - V, W = p.y - H, G = U - this._dragStartPoint[0], K = W - this._dragStartPoint[1], { direction: q } = this._draggingThumb, J = this._calcCropBox(q, [G, K]);
320
+ J && (this.$["*cropBox"] = J);
321
+ }, this._handleSvgPointerMove = (p) => {
322
+ this._frameThumbs && (this._hoverThumb = Object.values(this._frameThumbs).find((B) => {
323
+ if (!B || this._shouldThumbBeDisabled(B.direction)) return !1;
324
+ let V = B.interactionNode.getBoundingClientRect();
325
+ return rectContainsPoint({
326
+ x: V.x,
327
+ y: V.y,
328
+ width: V.width,
329
+ height: V.height
330
+ }, [p.x, p.y]);
331
+ }), this._updateCursor());
332
+ };
333
+ }
334
+ get _svgElement() {
335
+ return this._svgRef.value ?? null;
336
+ }
337
+ get _dragging() {
338
+ return this._draggingValue;
339
+ }
340
+ set _dragging(p) {
341
+ this._draggingValue !== p && (this._draggingValue = p, this._applyGuidesDragState());
342
+ }
343
+ _applyGuidesDragState() {
344
+ this._frameGuides && this._frameGuides.setAttribute("class", classNames({
345
+ "uc-guides--hidden": this._guidesHidden,
346
+ "uc-guides--visible": !this._guidesHidden && this._draggingValue,
347
+ "uc-guides--semi-hidden": !this._guidesHidden && !this._draggingValue
348
+ }));
349
+ }
350
+ _shouldThumbBeDisabled(p) {
351
+ let B = this.$["*imageBox"];
352
+ if (!B) return !1;
353
+ if (p === "" && B.height <= 1 && B.width <= 1) return !0;
354
+ let V = B.height <= 1 && (p.includes("n") || p.includes("s")), H = B.width <= 1 && (p.includes("e") || p.includes("w"));
355
+ return V || H;
356
+ }
357
+ _createBackdrop() {
358
+ let p = this.$["*cropBox"];
359
+ if (!p) return;
360
+ let { x: B, y: V, width: H, height: U } = p, W = this._svgElement;
361
+ if (!W) return;
362
+ let G = createSvgNode("mask", { id: this._backdropMaskId }), K = createSvgNode("rect", {
363
+ x: 0,
364
+ y: 0,
365
+ width: "100%",
366
+ height: "100%",
367
+ fill: "white"
368
+ }), q = createSvgNode("rect", {
369
+ x: B,
370
+ y: V,
371
+ width: H,
372
+ height: U,
373
+ fill: "black"
374
+ });
375
+ G.appendChild(K), G.appendChild(q);
376
+ let J = createSvgNode("rect", {
377
+ x: 0,
378
+ y: 0,
379
+ width: "100%",
380
+ height: "100%",
381
+ fill: "var(--color-image-background)",
382
+ "fill-opacity": .85,
383
+ mask: `url(#${this._backdropMaskId})`
384
+ });
385
+ W.appendChild(J), W.appendChild(G), this._backdropMask = G, this._backdropMaskInner = q;
386
+ }
387
+ _resizeBackdrop() {
388
+ this._backdropMask && (this._backdropMask.style.display = "none", window.requestAnimationFrame(() => {
389
+ this._backdropMask && (this._backdropMask.style.display = "block");
390
+ }));
391
+ }
392
+ _updateBackdrop() {
393
+ let p = this.$["*cropBox"];
394
+ if (!p) return;
395
+ let { x: B, y: V, width: H, height: U } = p;
396
+ this._backdropMaskInner && setSvgNodeAttrs(this._backdropMaskInner, {
397
+ x: B,
398
+ y: V,
399
+ width: H,
400
+ height: U
401
+ });
402
+ }
403
+ _updateFrame() {
404
+ let p = this.$["*cropBox"];
405
+ if (!(!p || !this._frameGuides || !this._frameThumbs)) {
406
+ for (let B of Object.values(this._frameThumbs)) {
407
+ if (!B) continue;
408
+ let { direction: V, pathNode: H, interactionNode: U, groupNode: W } = B, G = V === "", K = V.length === 2, { x: q, y: J, width: Y, height: X } = p;
409
+ if (G) setSvgNodeAttrs(U, {
410
+ x: q,
411
+ y: J,
412
+ width: Y,
413
+ height: X
414
+ });
415
+ else {
416
+ let B = clamp(Math.min(Y, X) / 82 / 2, 0, 1), W = K ? cornerPath(p, V, B) : sidePath(p, V, B), G = W.center;
417
+ if (!G) continue;
418
+ let q = Math.max(24 * clamp(Math.min(Y, X) / 24 / 3, 0, 1), 6);
419
+ setSvgNodeAttrs(U, {
420
+ x: G[0] - q,
421
+ y: G[1] - q,
422
+ width: q * 2,
423
+ height: q * 2
424
+ }), setSvgNodeAttrs(H, { d: W.d });
425
+ }
426
+ let Z = this._shouldThumbBeDisabled(V);
427
+ W.setAttribute("class", classNames("uc-thumb", {
428
+ "uc-thumb--hidden": Z,
429
+ "uc-thumb--visible": !Z
430
+ }));
431
+ }
432
+ setSvgNodeAttrs(this._frameGuides, {
433
+ x: p.x - 1 * .5,
434
+ y: p.y - 1 * .5,
435
+ width: p.width + 1,
436
+ height: p.height + 1
437
+ });
438
+ }
439
+ }
440
+ _createThumb(p, B) {
441
+ let V = createSvgNode("g");
442
+ V.classList.add("uc-thumb"), V.setAttribute("with-effects", "");
443
+ let H = createSvgNode("rect", { fill: "transparent" }), U = createSvgNode("path", {
444
+ stroke: "currentColor",
445
+ fill: "none",
446
+ "stroke-width": 3
447
+ });
448
+ V.appendChild(U), V.appendChild(H), p[B] = {
449
+ direction: B,
450
+ pathNode: U,
451
+ interactionNode: H,
452
+ groupNode: V
453
+ }, B === "" && (V.style.cursor = "move"), H.addEventListener("pointerdown", this._handlePointerDown.bind(this, B));
454
+ }
455
+ _createThumbs() {
456
+ let p = {};
457
+ for (let B = 0; B < 3; B++) for (let V = 0; V < 3; V++) {
458
+ let H = `${[
459
+ "n",
460
+ "",
461
+ "s"
462
+ ][B]}${[
463
+ "w",
464
+ "",
465
+ "e"
466
+ ][V]}`;
467
+ H !== "" && this._createThumb(p, H);
468
+ }
469
+ return this._createThumb(p, ""), p;
470
+ }
471
+ _createGuides() {
472
+ let p = createSvgNode("svg"), B = createSvgNode("rect", {
473
+ x: 0,
474
+ y: 0,
475
+ width: "100%",
476
+ height: "100%",
477
+ fill: "none",
478
+ stroke: "currentColor",
479
+ "stroke-width": 1,
480
+ "stroke-opacity": .5
481
+ });
482
+ p.appendChild(B);
483
+ for (let B = 1; B <= 2; B++) {
484
+ let V = createSvgNode("line", {
485
+ x1: `${GUIDE_THIRD * B}%`,
486
+ y1: "0%",
487
+ x2: `${GUIDE_THIRD * B}%`,
488
+ y2: "100%",
489
+ stroke: "currentColor",
490
+ "stroke-width": 1,
491
+ "stroke-opacity": .3
492
+ });
493
+ p.appendChild(V);
494
+ }
495
+ for (let B = 1; B <= 2; B++) {
496
+ let V = createSvgNode("line", {
497
+ x1: "0%",
498
+ y1: `${GUIDE_THIRD * B}%`,
499
+ x2: "100%",
500
+ y2: `${GUIDE_THIRD * B}%`,
501
+ stroke: "currentColor",
502
+ "stroke-width": 1,
503
+ "stroke-opacity": .3
504
+ });
505
+ p.appendChild(V);
506
+ }
507
+ return p.classList.add("uc-guides", "uc-guides--semi-hidden"), p;
508
+ }
509
+ _createFrame() {
510
+ let p = this._svgElement;
511
+ if (!p) return;
512
+ let B = document.createDocumentFragment(), V = this._createGuides();
513
+ B.appendChild(V);
514
+ let H = this._createThumbs();
515
+ for (let { groupNode: p } of Object.values(H)) B.appendChild(p);
516
+ p.appendChild(B), this._frameThumbs = H, this._frameGuides = V, this._applyGuidesDragState();
517
+ }
518
+ _handlePointerDown(p, B) {
519
+ if (!this._frameThumbs) return;
520
+ let V = this._frameThumbs[p];
521
+ if (!V || this._shouldThumbBeDisabled(p)) return;
522
+ let H = this.$["*cropBox"], U = this._svgElement;
523
+ if (!U) return;
524
+ let { x: W, y: G } = U.getBoundingClientRect(), K = B.x - W, q = B.y - G;
525
+ this._dragging = !0, this._draggingThumb = V, this._dragStartPoint = [K, q], this._dragStartCrop = { ...H };
526
+ }
527
+ _calcCropBox(p, B) {
528
+ let [V, H] = B, U = this.$["*imageBox"], W = this._dragStartCrop ?? this.$["*cropBox"], G = this.$["*currentAspectRatio"], K = G ? G.width / G.height : void 0;
529
+ if (W = p === "" ? moveRect({
530
+ rect: W,
531
+ delta: [V, H],
532
+ imageBox: U
533
+ }) : resizeRect({
534
+ rect: W,
535
+ delta: [V, H],
536
+ direction: p,
537
+ aspectRatio: K,
538
+ imageBox: U
539
+ }), !Object.values(W).every((p) => Number.isFinite(p) && p >= 0)) {
540
+ console.error("CropFrame is trying to create invalid rectangle", { payload: W });
541
+ return;
542
+ }
543
+ return constraintRect(roundRect(W), U);
544
+ }
545
+ _updateCursor() {
546
+ let p = this._hoverThumb, B = this._svgElement;
547
+ B && (B.style.cursor = p ? thumbCursor(p.direction) : "initial");
548
+ }
549
+ _createMask(p) {
550
+ if (this._frameImage) {
551
+ this._frameImage.setAttribute("href", p);
552
+ return;
553
+ }
554
+ let B = this._svgElement;
555
+ if (!B) {
556
+ this._pendingMaskHref = p;
557
+ return;
558
+ }
559
+ this._pendingMaskHref = null;
560
+ let V = document.createDocumentFragment(), H = createSvgNode("image", { href: p });
561
+ H.setAttribute("class", "uc-cloud-mask"), V.appendChild(H), B.appendChild(V), this._frameImage = H;
562
+ }
563
+ _updateMask() {
564
+ let p = this.$["*cropBox"];
565
+ if (!p || !this._frameImage) return;
566
+ let { x: B, y: V, width: H, height: U } = p;
567
+ setSvgNodeAttrs(this._frameImage, {
568
+ x: B,
569
+ y: V,
570
+ height: U,
571
+ width: H
572
+ });
573
+ }
574
+ _render() {
575
+ this._svgReady && (this._updateBackdrop(), this._updateFrame(), this._updateMask());
576
+ }
577
+ toggleThumbs(p) {
578
+ if (this._frameThumbs) for (let B of Object.values(this._frameThumbs)) {
579
+ if (!B) continue;
580
+ let { groupNode: V } = B;
581
+ V.setAttribute("class", classNames("uc-thumb", {
582
+ "uc-thumb--hidden": !p,
583
+ "uc-thumb--visible": p
584
+ }));
585
+ }
586
+ }
587
+ initCallback() {
588
+ super.initCallback(), this.sub("*imageBox", () => {
589
+ this._resizeBackdrop(), this._svgReady && window.requestAnimationFrame(() => {
590
+ this._render();
591
+ });
592
+ }), this.sub("*cropBox", (p) => {
593
+ p && (this._guidesHidden = p.height <= 1 || p.width <= 1, this._applyGuidesDragState(), this._svgReady && window.requestAnimationFrame(() => {
594
+ this._render();
595
+ }));
596
+ }), this.subConfigValue("cloudImageEditorMaskHref", (p) => {
597
+ p && this._createMask(p);
598
+ }), document.addEventListener("pointermove", this._handlePointerMove, !0), document.addEventListener("pointerup", this._handlePointerUp, !0);
599
+ }
600
+ firstUpdated(p) {
601
+ super.firstUpdated(p), this._initializeSvg();
602
+ }
603
+ _initializeSvg() {
604
+ let p = this._svgElement;
605
+ if (!(!p || this._svgReady)) {
606
+ if (this._createBackdrop(), this._createFrame(), this._svgReady = !0, p.addEventListener("pointermove", this._handleSvgPointerMove, !0), this._pendingMaskHref) {
607
+ let p = this._pendingMaskHref;
608
+ this._pendingMaskHref = null, this._createMask(p);
609
+ }
610
+ this._render();
611
+ }
612
+ }
613
+ disconnectedCallback() {
614
+ super.disconnectedCallback(), this._svgElement?.removeEventListener("pointermove", this._handleSvgPointerMove, !0), document.removeEventListener("pointermove", this._handlePointerMove, !0), document.removeEventListener("pointerup", this._handlePointerUp, !0);
615
+ }
616
+ render() {
617
+ return b`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${n$1(this._svgRef)}></svg>`;
618
+ }
619
+ };
620
+ __decorate([r()], CropFrame.prototype, "_draggingValue", void 0);
621
+ function validateCrop(p) {
622
+ return p ? [({ dimensions: p, coords: B }) => [...p, ...B].every((p) => Number.isInteger(p) && Number.isFinite(p)), ({ dimensions: p, coords: B }) => p.every((p) => p > 0) && B.every((p) => p >= 0)].every((B) => B(p)) : !0;
623
+ }
624
+ var EditorImageCropper = class extends LitBlock {
625
+ constructor() {
626
+ super(), this.ctxOwner = !0, this._imageSize = {
627
+ width: 0,
628
+ height: 0
629
+ }, this._ctx = null, this._isActive = !1, this._image = null, this._canvasRef = e(), this._frameRef = e(), this.init$ = {
630
+ ...this.init$,
631
+ "*padding": 20,
632
+ "*operations": {
633
+ rotate: 0,
634
+ mirror: !1,
635
+ flip: !1
636
+ },
637
+ "*imageBox": {
638
+ x: 0,
639
+ y: 0,
640
+ width: 0,
641
+ height: 0
642
+ },
643
+ "*cropBox": {
644
+ x: 0,
645
+ y: 0,
646
+ width: 0,
647
+ height: 0
648
+ }
649
+ }, this._commitDebounced = debounce(this._commit.bind(this), 300), this._handleResizeThrottled = throttle(() => {
650
+ !this.isConnected || !this._isActive || (this._initCanvas(), this._syncTransformations(), this._alignImage(), this._alignCrop(), this._draw());
651
+ }, 100);
652
+ }
653
+ firstUpdated(p) {
654
+ super.firstUpdated(p), this._initCanvas();
655
+ }
656
+ _syncTransformations() {
657
+ let p = this.$["*editorTransformations"], B = pick(p, Object.keys(this.$["*operations"])), V = {
658
+ ...this.$["*operations"],
659
+ ...B
660
+ };
661
+ this.$["*operations"] = V;
662
+ }
663
+ _initCanvas() {
664
+ let p = this._canvasRef.value;
665
+ if (!p) return;
666
+ let B = p.getContext("2d"), V = this.offsetWidth, H = this.offsetHeight, U = window.devicePixelRatio;
667
+ p.style.width = `${V}px`, p.style.height = `${H}px`, p.width = V * U, p.height = H * U, B?.scale(U, U), this._canvas = p, this._ctx = B;
668
+ }
669
+ _alignImage() {
670
+ if (!this._isActive || !this._image) return;
671
+ let p = this._image, B = this.$["*padding"], { rotate: V } = this.$["*operations"], H = {
672
+ width: this.offsetWidth,
673
+ height: this.offsetHeight
674
+ }, U = rotateSize({
675
+ width: p.naturalWidth,
676
+ height: p.naturalHeight
677
+ }, V), W;
678
+ if (U.width > H.width - B * 2 || U.height > H.height - B * 2) {
679
+ let p = U.width / U.height;
680
+ if (p > H.width / H.height) {
681
+ let V = H.width - B * 2, U = V / p;
682
+ W = {
683
+ x: 0 + B,
684
+ y: B + (H.height - B * 2) / 2 - U / 2,
685
+ width: V,
686
+ height: U
687
+ };
688
+ } else {
689
+ let V = H.height - B * 2, U = V * p;
690
+ W = {
691
+ x: B + (H.width - B * 2) / 2 - U / 2,
692
+ y: 0 + B,
693
+ width: U,
694
+ height: V
695
+ };
696
+ }
697
+ } else {
698
+ let { width: p, height: V } = U;
699
+ W = {
700
+ x: B + (H.width - B * 2) / 2 - p / 2,
701
+ y: B + (H.height - B * 2) / 2 - V / 2,
702
+ width: p,
703
+ height: V
704
+ };
705
+ }
706
+ this.$["*imageBox"] = roundRect(W);
707
+ }
708
+ _alignCrop() {
709
+ let p = this.$["*cropBox"], B = this.$["*imageBox"], { rotate: V } = this.$["*operations"], H = this.$["*editorTransformations"].crop, { width: U, x: W, y: G } = B;
710
+ if (H) {
711
+ let { dimensions: [K, q], coords: [J, Y] } = H, { width: X } = rotateSize(this._imageSize, V), Z = U / X;
712
+ p = constraintRect(roundRect({
713
+ x: W + J * Z,
714
+ y: G + Y * Z,
715
+ width: K * Z,
716
+ height: q * Z
717
+ }), B);
718
+ }
719
+ let K = this.$["*currentAspectRatio"], q = K ? K.width / K.height : void 0;
720
+ if (!isRectInsideRect(p, B) || q && !isRectMatchesAspectRatio(p, q)) {
721
+ let V = B.width / B.height, H = B.width, U = B.height;
722
+ q && (V > q ? H = Math.min(B.height * q, B.width) : U = Math.min(B.width / q, B.height)), p = {
723
+ x: B.x + B.width / 2 - H / 2,
724
+ y: B.y + B.height / 2 - U / 2,
725
+ width: H,
726
+ height: U
727
+ };
728
+ }
729
+ this.$["*cropBox"] = constraintRect(roundRect(p), B);
730
+ }
731
+ _drawImage() {
732
+ let p = this._ctx;
733
+ if (!p) return;
734
+ let B = this._image;
735
+ if (!B) return;
736
+ let V = this.$["*imageBox"], { mirror: H, flip: U, rotate: W } = this.$["*operations"], G = rotateSize({
737
+ width: V.width,
738
+ height: V.height
739
+ }, W);
740
+ p.save(), p.translate(V.x + V.width / 2, V.y + V.height / 2), p.rotate(W * Math.PI * -1 / 180), p.scale(H ? -1 : 1, U ? -1 : 1), p.drawImage(B, -G.width / 2, -G.height / 2, G.width, G.height), p.restore();
741
+ }
742
+ _draw() {
743
+ if (!this._isActive || !this._image || !this._canvas || !this._ctx) return;
744
+ let p = this._canvas;
745
+ this._ctx.clearRect(0, 0, p.width, p.height), this._drawImage();
746
+ }
747
+ _animateIn({ fromViewer: p }) {
748
+ this._image && (this._frameRef.value?.toggleThumbs(!0), this._transitionToImage(), setTimeout(() => {
749
+ this.className = classNames({
750
+ "uc-active_from_viewer": p,
751
+ "uc-active_from_editor": !p,
752
+ "uc-inactive_to_editor": !1
753
+ });
754
+ }));
755
+ }
756
+ _getCropDimensions() {
757
+ let p = this.$["*cropBox"], B = this.$["*imageBox"], { rotate: V } = this.$["*operations"], { width: H, height: U } = B, { width: W, height: G } = rotateSize(this._imageSize, V), { width: K, height: q } = p, J = H / W, Y = U / G;
758
+ return [clamp(Math.round(K / J), 1, W), clamp(Math.round(q / Y), 1, G)];
759
+ }
760
+ _getCropTransformation() {
761
+ let p = this.$["*cropBox"], B = this.$["*imageBox"], { rotate: V } = this.$["*operations"], { width: H, height: U, x: W, y: G } = B, { width: K, height: q } = rotateSize(this._imageSize, V), { x: J, y: Y } = p, X = H / K, Z = U / q, Q = this._getCropDimensions(), $ = {
762
+ dimensions: Q,
763
+ coords: [clamp(Math.round((J - W) / X), 0, K - Q[0]), clamp(Math.round((Y - G) / Z), 0, q - Q[1])]
764
+ };
765
+ if (!validateCrop($)) {
766
+ console.error("Cropper is trying to create invalid crop object", { payload: $ });
767
+ return;
768
+ }
769
+ if (!(Q[0] === K && Q[1] === q)) return $;
770
+ }
771
+ _commit() {
772
+ if (!this.isConnected || !this._imageSize) return;
773
+ let { rotate: p, mirror: B, flip: V } = this.$["*operations"], H = this._getCropTransformation(), U = {
774
+ ...this.$["*editorTransformations"],
775
+ crop: H,
776
+ rotate: p,
777
+ mirror: B,
778
+ flip: V
779
+ };
780
+ this.$["*editorTransformations"] = U;
781
+ }
782
+ setValue(p, B) {
783
+ this.$["*operations"] = {
784
+ ...this.$["*operations"],
785
+ [p]: B
786
+ }, this._isActive && (this._alignImage(), this._alignCrop(), this._draw());
787
+ }
788
+ getValue(p) {
789
+ return this.$["*operations"][p];
790
+ }
791
+ async activate(p, { fromViewer: B } = {}) {
792
+ if (!this._isActive) {
793
+ this._isActive = !0, await this.updateComplete, this._initCanvas(), this._imageSize = p, this.removeEventListener("transitionend", this._reset);
794
+ try {
795
+ let p = this.$["*originalUrl"], V = this.$["*editorTransformations"];
796
+ this._image = await this._waitForImage(p, V), this._syncTransformations(), this._handleResizeThrottled(), this._animateIn({ fromViewer: B });
797
+ } catch (p) {
798
+ console.error("Failed to activate cropper", { error: p }), this.telemetryManager.sendEventError(p, "cloud editor image. Failed to activate cropper");
799
+ }
800
+ this._observer = new ResizeObserver((p) => {
801
+ let [B] = p;
802
+ B && B.contentRect.width > 0 && B.contentRect.height > 0 && this._isActive && this._image && this._handleResizeThrottled();
803
+ }), this._observer.observe(this);
804
+ }
805
+ }
806
+ deactivate({ reset: p = !1 } = {}) {
807
+ this._isActive && (!p && this._commit(), this._isActive = !1, this._transitionToCrop(), this.className = classNames({
808
+ "uc-active_from_viewer": !1,
809
+ "uc-active_from_editor": !1,
810
+ "uc-inactive_to_editor": !0
811
+ }), this._frameRef.value?.toggleThumbs(!1), this.addEventListener("transitionend", this._reset, { once: !0 }), this._observer?.disconnect());
812
+ }
813
+ _transitionToCrop() {
814
+ let p = this._getCropDimensions(), B = this.$["*cropBox"], V = Math.min(this.offsetWidth, p[0]) / B.width, H = Math.min(this.offsetHeight, p[1]) / B.height, U = Math.min(V, H), W = B.x + B.width / 2, G = B.y + B.height / 2;
815
+ this.style.transform = `scale(${U}) translate(${(this.offsetWidth / 2 - W) / U}px, ${(this.offsetHeight / 2 - G) / U}px)`, this.style.transformOrigin = `${W}px ${G}px`;
816
+ }
817
+ _transitionToImage() {
818
+ let p = this.$["*cropBox"], B = p.x + p.width / 2, V = p.y + p.height / 2;
819
+ this.style.transform = "scale(1)", this.style.transformOrigin = `${B}px ${V}px`;
820
+ }
821
+ _reset() {
822
+ this._isActive || (this._image = null);
823
+ }
824
+ async _waitForImage(p, B) {
825
+ let V = this.offsetWidth;
826
+ B = {
827
+ ...B,
828
+ crop: void 0,
829
+ rotate: void 0,
830
+ flip: void 0,
831
+ mirror: void 0
832
+ };
833
+ let H = await this.proxyUrl(viewerImageSrc(p, V, B)), { promise: U, cancel: W, image: G } = preloadImage(H), K = this._handleImageLoading(H);
834
+ return G.addEventListener("load", K, { once: !0 }), G.addEventListener("error", K, { once: !0 }), this._cancelPreload?.(), this._cancelPreload = W, U.then(() => G).catch((p) => (console.error("Failed to load image", { error: p }), this.$["*networkProblems"] = !0, G));
835
+ }
836
+ _handleImageLoading(p) {
837
+ let B = "crop", V = this.$["*loadingOperations"], H = V.get(B);
838
+ return H || (H = /* @__PURE__ */ new Map(), V.set(B, H)), H.get(p) || (H.set(p, !0), this.$["*loadingOperations"] = V), () => {
839
+ let H = V.get(B);
840
+ H?.has(p) && (H.delete(p), this.$["*loadingOperations"] = V);
841
+ };
842
+ }
843
+ initCallback() {
844
+ super.initCallback(), this.sub("*imageBox", () => {
845
+ this._draw();
846
+ }), this.sub("*cropBox", () => {
847
+ this._image && this._commitDebounced();
848
+ }), this.sub("*currentAspectRatio", () => {
849
+ this._alignCrop();
850
+ }), setTimeout(() => {
851
+ this.sub("*networkProblems", (p) => {
852
+ p || this._isActive && this._imageSize && this.activate(this._imageSize, { fromViewer: !1 });
853
+ });
854
+ }, 0);
855
+ }
856
+ disconnectedCallback() {
857
+ super.disconnectedCallback(), this._observer?.disconnect(), this._image &&= null;
858
+ }
859
+ render() {
860
+ return b`
861
+ <canvas class="uc-canvas" ${n$1(this._canvasRef)}></canvas>
862
+ <uc-crop-frame ${n$1(this._frameRef)}></uc-crop-frame>
863
+ `;
864
+ }
865
+ };
866
+ __decorate([r()], EditorImageCropper.prototype, "_image", void 0);
867
+ function linspace(p, B, V) {
868
+ let H = V, U = V - 1, W = Array(H);
869
+ for (let V = U; V >= 0; --V) W[V] = Math.ceil((V * B + (U - V) * p) / U);
870
+ return W;
871
+ }
872
+ function isOperationKey(p) {
873
+ return typeof p == "string" && p in COLOR_OPERATIONS_CONFIG;
874
+ }
875
+ function splitBySections(p) {
876
+ let B = [];
877
+ for (let V = 0; V < p.length - 1; V += 1) {
878
+ let H = p[V], U = p[V + 1];
879
+ typeof H == "number" && typeof U == "number" && B.push([H, U]);
880
+ }
881
+ return B;
882
+ }
883
+ function calculateOpacities(p, B, V) {
884
+ let H = splitBySections(p).find(([p, V]) => p <= B && B <= V);
885
+ if (!H) return p.map(() => 0);
886
+ let [U, W] = H;
887
+ return p.map((p) => {
888
+ let H = Math.abs(U - W) || 1, G = Math.abs(B - U) / H;
889
+ return U === p ? B > V ? 1 : 1 - G : W === p ? B >= V ? G : 1 : 0;
890
+ });
891
+ }
892
+ function calculateZIndices(p, B) {
893
+ return p.map((V, H) => V < B ? p.length - H : H);
894
+ }
895
+ function keypointsRange(p, B) {
896
+ let V = COLOR_OPERATIONS_CONFIG[p].keypointsNumber, { range: H, zero: U } = COLOR_OPERATIONS_CONFIG[p];
897
+ return [...new Set([
898
+ ...linspace(H[0], U, V + 1),
899
+ ...linspace(U, H[1], V + 1),
900
+ U,
901
+ B
902
+ ])].sort((p, B) => p - B);
903
+ }
904
+ var EditorImageFader = class extends LitBlock {
905
+ constructor() {
906
+ super(), this._isActive = !1, this._hidden = !0, this._operation = "initial", this._transformations = {}, this._keypoints = [], this._raf = 0, this._previewHostRef = e(), this._layersHostRef = e(), this.classList.add("uc-inactive_to_cropper"), this._addKeypointDebounced = debounce(async (p, B, V) => {
907
+ let H = () => !this._isSame(p, B) || this._value !== V || !!this._keypoints.find((p) => p.value === V);
908
+ if (H()) return;
909
+ let U = await this._constructKeypoint(p, V), W = new Image();
910
+ W.src = U.src;
911
+ let G = this._handleImageLoading(U.src);
912
+ W.addEventListener("load", G, { once: !0 }), W.addEventListener("error", G, { once: !0 }), U.image = W, W.classList.add("uc-fader-image"), W.addEventListener("load", () => {
913
+ if (H()) return;
914
+ let B = this._keypoints, G = B.findIndex((p) => p.value > V);
915
+ G === -1 && (G = B.length);
916
+ let K = B[G]?.image, q = this._layersHostRef.value;
917
+ !q || K && !q.contains(K) || (B.splice(G, 0, U), K ? q.insertBefore(W, K) : q.appendChild(W), this._update(p, V));
918
+ }, { once: !0 }), W.addEventListener("error", () => {
919
+ this.$["*networkProblems"] = !0;
920
+ }, { once: !0 });
921
+ }, 600);
922
+ }
923
+ _handleImageLoading(p) {
924
+ let B = this._operation, V = this.$["*loadingOperations"];
925
+ V.has(B) || V.set(B, /* @__PURE__ */ new Map());
926
+ let H = V.get(B);
927
+ return H && !H.get(p) && (H.set(p, !0), this.$["*loadingOperations"] = V), () => {
928
+ let H = V.get(B);
929
+ H?.has(p) && (H.delete(p), this.$["*loadingOperations"] = V);
930
+ };
931
+ }
932
+ _flush() {
933
+ window.cancelAnimationFrame(this._raf), this._raf = window.requestAnimationFrame(() => {
934
+ for (let p of this._keypoints) {
935
+ let { image: B } = p;
936
+ B && (B.style.opacity = p.opacity.toString(), B.style.zIndex = p.zIndex.toString());
937
+ }
938
+ });
939
+ }
940
+ _imageSrc({ url: p = this._url, filter: B = this._filter ?? void 0, operation: V, value: H } = {}) {
941
+ if (!p) throw Error("URL is not defined");
942
+ let U = { ...this._transformations };
943
+ V && (V === "filter" ? B && typeof H == "number" && (U.filter = {
944
+ name: B,
945
+ amount: H
946
+ }) : typeof H == "number" && (U[V] = H));
947
+ let W = this.offsetWidth;
948
+ return this.proxyUrl(viewerImageSrc(p, W, U));
949
+ }
950
+ async _constructKeypoint(p, B) {
951
+ return {
952
+ src: await this._imageSrc({
953
+ operation: p,
954
+ value: B
955
+ }),
956
+ image: void 0,
957
+ opacity: 0,
958
+ zIndex: 0,
959
+ value: B
960
+ };
961
+ }
962
+ _isSame(p, B) {
963
+ return this._operation === p && this._filter === B;
964
+ }
965
+ set(p) {
966
+ let B = typeof p == "string" ? parseInt(p, 10) : p;
967
+ !isOperationKey(this._operation) || !Number.isFinite(B) || (this._update(this._operation, B), this._addKeypointDebounced(this._operation, this._filter, B));
968
+ }
969
+ _update(p, B) {
970
+ this._operation = p, this._value = B;
971
+ let { zero: V } = COLOR_OPERATIONS_CONFIG[p], H = this._keypoints.map((p) => p.value), U = calculateOpacities(H, B, V), W = calculateZIndices(H, V);
972
+ this._keypoints.forEach((p, B) => {
973
+ let V = U[B], H = W[B];
974
+ typeof V == "number" && (p.opacity = V), typeof H == "number" && (p.zIndex = H);
975
+ }), this._flush();
976
+ }
977
+ _createPreviewImage() {
978
+ let p = new Image();
979
+ return p.classList.add("uc-fader-image", "uc-fader-image--preview"), p.style.opacity = "0", p;
980
+ }
981
+ async _initNodes() {
982
+ this._previewImage = this._previewImage || this._createPreviewImage();
983
+ let p = this._previewImage;
984
+ p && this._ensurePreviewAttached(p);
985
+ let { images: B, promise: V, cancel: H } = batchPreloadImages(this._keypoints.map((p) => p.src));
986
+ B.forEach((p) => {
987
+ let B = this._handleImageLoading(p.src);
988
+ p.addEventListener("load", B), p.addEventListener("error", B);
989
+ }), this._cancelLastImages = () => {
990
+ H(), this._cancelLastImages = void 0;
991
+ };
992
+ let U = this._operation, W = this._filter;
993
+ if (await V, this._isActive && this._isSame(U, W)) {
994
+ let p = this._layersHostRef.value;
995
+ if (!p) return;
996
+ p.replaceChildren(), this._keypoints.forEach((V, H) => {
997
+ let U = B[H];
998
+ U && (U.classList.add("uc-fader-image"), V.image = U, p.appendChild(U));
999
+ }), this._flush();
1000
+ }
1001
+ }
1002
+ async setTransformations(p) {
1003
+ if (this._transformations = p, this._previewImage) {
1004
+ let p = await this._imageSrc(), B = this._handleImageLoading(p);
1005
+ this._previewImage.src = p, this._previewImage.addEventListener("load", B, { once: !0 }), this._previewImage.addEventListener("error", B, { once: !0 }), this._previewImage.style.opacity = "1", this._previewImage.addEventListener("error", () => {
1006
+ this.$["*networkProblems"] = !0;
1007
+ }, { once: !0 });
1008
+ }
1009
+ }
1010
+ async preload({ url: p, filter: B, operation: V, value: H }) {
1011
+ if (!V || typeof H != "number") return;
1012
+ this._cancelBatchPreload?.();
1013
+ let U = keypointsRange(V, H), { cancel: W } = batchPreloadImages(await Promise.all(U.map((H) => this._imageSrc({
1014
+ url: p,
1015
+ filter: B,
1016
+ operation: V,
1017
+ value: H
1018
+ }))));
1019
+ this._cancelBatchPreload = W;
1020
+ }
1021
+ _setOriginalSrc(p) {
1022
+ let B = this._previewImage || this._createPreviewImage();
1023
+ if (this._ensurePreviewAttached(B), this._previewImage = B, B.src === p) {
1024
+ B.style.opacity = "1", B.style.transform = "scale(1)", this.className = classNames({
1025
+ "uc-active_from_viewer": this._fromViewer,
1026
+ "uc-active_from_cropper": !this._fromViewer,
1027
+ "uc-inactive_to_cropper": !1
1028
+ });
1029
+ return;
1030
+ }
1031
+ B.style.opacity = "0";
1032
+ let V = this._handleImageLoading(p);
1033
+ B.addEventListener("error", V, { once: !0 }), B.src = p, B.addEventListener("load", () => {
1034
+ V(), B && (B.style.opacity = "1", B.style.transform = "scale(1)", this.className = classNames({
1035
+ "uc-active_from_viewer": this._fromViewer,
1036
+ "uc-active_from_cropper": !this._fromViewer,
1037
+ "uc-inactive_to_cropper": !1
1038
+ }));
1039
+ }, { once: !0 }), B.addEventListener("error", () => {
1040
+ this.$["*networkProblems"] = !0;
1041
+ }, { once: !0 });
1042
+ }
1043
+ async activate({ url: p, operation: B, value: V, filter: H, fromViewer: U }) {
1044
+ if (this._isActive = !0, this._hidden = !1, await this.updateComplete, this._url = p, this._operation = B ?? "initial", this._value = V, this._filter = H, this._fromViewer = U, typeof V != "number" && !H) {
1045
+ let p = await this._imageSrc({
1046
+ operation: B,
1047
+ value: V
1048
+ });
1049
+ this._setOriginalSrc(p), this._clearLayersHost();
1050
+ return;
1051
+ }
1052
+ !B || typeof V != "number" || (this._keypoints = await Promise.all(keypointsRange(B, V).map((p) => this._constructKeypoint(B, p))), this._update(B, V), this._initNodes());
1053
+ }
1054
+ deactivate({ hide: p = !0 } = {}) {
1055
+ this._isActive = !1, this._cancelLastImages?.(), this._cancelBatchPreload?.(), p && !this._hidden ? (this._hidden = !0, this._previewImage && (this._previewImage.style.transform = "scale(1)"), this.className = classNames({
1056
+ "uc-active_from_viewer": !1,
1057
+ "uc-active_from_cropper": !1,
1058
+ "uc-inactive_to_cropper": !0
1059
+ }), this.addEventListener("transitionend", () => {
1060
+ this._clearLayersHost();
1061
+ }, { once: !0 })) : this._clearLayersHost();
1062
+ }
1063
+ _ensurePreviewAttached(p) {
1064
+ let B = this._previewHostRef.value;
1065
+ B && (B.contains(p) || B.appendChild(p));
1066
+ }
1067
+ _clearLayersHost() {
1068
+ this._layersHostRef.value?.replaceChildren();
1069
+ }
1070
+ render() {
1071
+ return b`
1072
+ <div class="uc-fader-preview-host" ${n$1(this._previewHostRef)}></div>
1073
+ <div class="uc-fader-layers-host" ${n$1(this._layersHostRef)}></div>
1074
+ `;
1075
+ }
1076
+ }, SliderUi = class extends LitBlock {
1077
+ constructor() {
1078
+ super(), this._thumbSize = 0, this._inputRef = e(), this._thumbRef = e(), this._stepsRef = e(), this.disabled = !1, this.min = 0, this.max = 100, this.defaultValue = 0, this.zero = 0, this._currentValue = 0, this._handleSliderInput = (p) => {
1079
+ p.stopPropagation();
1080
+ let B = this._extractEventValue(p);
1081
+ B !== null && (this._setCurrentValue(B), this._emitSliderEvent("slider-input", B));
1082
+ }, this._handleSliderChange = (p) => {
1083
+ p.stopPropagation();
1084
+ let B = this._extractEventValue(p);
1085
+ B !== null && this._setCurrentValue(B);
1086
+ }, this._handleInputFocus = () => {
1087
+ this.style.setProperty("--color-effect", "var(--hover-color-rgb)");
1088
+ }, this._handleInputBlur = () => {
1089
+ this.style.setProperty("--color-effect", "var(--idle-color-rgb)");
1090
+ }, this.setAttribute("with-effects", "");
1091
+ }
1092
+ _emitSliderEvent(p, B) {
1093
+ this.dispatchEvent(new CustomEvent(p, {
1094
+ detail: { value: B },
1095
+ bubbles: !0,
1096
+ composed: !0
1097
+ }));
1098
+ }
1099
+ firstUpdated(p) {
1100
+ super.firstUpdated(p), this._thumbSize = Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"), 10) || 0, this._syncInputValue(this._currentValue), this._updateSteps(), this._observer = new ResizeObserver(() => {
1101
+ this._updateSteps(), this._updateValue(this._currentValue);
1102
+ }), this._observer.observe(this);
1103
+ let B = this._inputRef.value;
1104
+ B?.addEventListener("focus", this._handleInputFocus), B?.addEventListener("blur", this._handleInputBlur), window.setTimeout(() => {
1105
+ this._updateValue(this._currentValue);
1106
+ }, 0);
1107
+ }
1108
+ willUpdate(p) {
1109
+ super.willUpdate(p), p.has("defaultValue") && this.defaultValue !== this._currentValue && this._setCurrentValue(this.defaultValue), (p.has("min") || p.has("max")) && this.hasUpdated && (this._updateSteps(), this._updateValue(this._currentValue)), p.has("zero") && this.hasUpdated && this._updateZeroDot(this._currentValue);
1110
+ }
1111
+ _updateValue(p) {
1112
+ this._updateZeroDot(p);
1113
+ let B = this.max - this.min;
1114
+ if (B === 0) return;
1115
+ let { width: V } = this.getBoundingClientRect(), H = 100 / B * (p - this.min) * (V - this._thumbSize) / 100;
1116
+ window.requestAnimationFrame(() => {
1117
+ let p = this._thumbRef.value;
1118
+ p && (p.style.transform = `translateX(${H}px)`);
1119
+ });
1120
+ }
1121
+ _updateZeroDot(p) {
1122
+ if (!this._zeroDotEl) return;
1123
+ let B = this.max - this.min;
1124
+ if (B === 0) return;
1125
+ this._zeroDotEl.style.opacity = p === this.zero ? "0" : "1";
1126
+ let { width: V } = this.getBoundingClientRect(), H = 100 / B * (this.zero - this.min) * (V - this._thumbSize) / 100;
1127
+ window.requestAnimationFrame(() => {
1128
+ this._zeroDotEl && (this._zeroDotEl.style.transform = `translateX(${H}px)`);
1129
+ });
1130
+ }
1131
+ _updateSteps() {
1132
+ let p = this._stepsRef.value;
1133
+ if (!p) return;
1134
+ let { width: B } = p.getBoundingClientRect(), V = Math.ceil(B / 2), H = Math.ceil(V / 15) - 2;
1135
+ if (this._stepsCount === H) return;
1136
+ let U = document.createDocumentFragment(), W = document.createElement("div"), G = document.createElement("div");
1137
+ W.className = "uc-minor-step", G.className = "uc-border-step", U.appendChild(G);
1138
+ for (let p = 0; p < H; p += 1) U.appendChild(W.cloneNode());
1139
+ U.appendChild(G.cloneNode());
1140
+ for (let p = 0; p < H; p += 1) U.appendChild(W.cloneNode());
1141
+ U.appendChild(G.cloneNode());
1142
+ let K = document.createElement("div");
1143
+ K.className = "uc-zero-dot", U.appendChild(K), this._zeroDotEl = K, p.innerHTML = "", p.appendChild(U), this._stepsCount = H;
1144
+ }
1145
+ disconnectedCallback() {
1146
+ super.disconnectedCallback();
1147
+ let p = this._inputRef.value;
1148
+ p?.removeEventListener("focus", this._handleInputFocus), p?.removeEventListener("blur", this._handleInputBlur), this._observer?.disconnect(), this._observer = void 0;
1149
+ }
1150
+ _setCurrentValue(p) {
1151
+ Number.isFinite(p) && (this._currentValue = p, this.hasUpdated && (this._syncInputValue(p), this._updateValue(p)));
1152
+ }
1153
+ _syncInputValue(p) {
1154
+ let B = this._inputRef.value;
1155
+ B && (B.value = String(p));
1156
+ }
1157
+ _extractEventValue(p) {
1158
+ let B = p.currentTarget;
1159
+ if (!B) return null;
1160
+ let V = Number.parseInt(B.value, 10);
1161
+ return Number.isFinite(V) ? V : null;
1162
+ }
1163
+ render() {
1164
+ return b`
1165
+ <div class="uc-steps" ${n$1(this._stepsRef)}></div>
1166
+ <div class="uc-thumb" ${n$1(this._thumbRef)}></div>
1167
+ <input
1168
+ class="uc-input"
1169
+ type="range"
1170
+ ${n$1(this._inputRef)}
1171
+ .min=${String(this.min)}
1172
+ .max=${String(this.max)}
1173
+ .value=${String(this._currentValue)}
1174
+ ?disabled=${this.disabled}
1175
+ @input=${this._handleSliderInput}
1176
+ @change=${this._handleSliderChange}
1177
+ />
1178
+ `;
1179
+ }
1180
+ };
1181
+ __decorate([n({
1182
+ type: Boolean,
1183
+ reflect: !0
1184
+ })], SliderUi.prototype, "disabled", void 0), __decorate([n({ type: Number })], SliderUi.prototype, "min", void 0), __decorate([n({ type: Number })], SliderUi.prototype, "max", void 0), __decorate([n({
1185
+ type: Number,
1186
+ attribute: !1
1187
+ })], SliderUi.prototype, "defaultValue", void 0), __decorate([n({ type: Number })], SliderUi.prototype, "zero", void 0), __decorate([r()], SliderUi.prototype, "_currentValue", void 0);
1188
+ const FAKE_ORIGINAL_FILTER = "original";
1189
+ var EditorSlider = class extends LitBlock {
1190
+ constructor(...p) {
1191
+ super(...p), this.state = {
1192
+ operation: "filter",
1193
+ filter: void 0,
1194
+ originalUrl: "",
1195
+ disabled: !1,
1196
+ min: 0,
1197
+ max: 100,
1198
+ value: 0,
1199
+ defaultValue: 0,
1200
+ zero: 0
1201
+ }, this._handleInput = (p) => {
1202
+ let { value: B } = p.detail;
1203
+ this.$["*faderEl"]?.set(B), this.state = {
1204
+ ...this.state,
1205
+ value: B
1206
+ };
1207
+ };
1208
+ }
1209
+ setOperation(p, B) {
1210
+ this.state = {
1211
+ ...this.state,
1212
+ operation: p,
1213
+ filter: B
1214
+ }, this._initializeValues();
1215
+ let V = this.$["*faderEl"], H = this.state.originalUrl || this.$["*originalUrl"];
1216
+ V && H && V.activate({
1217
+ url: H,
1218
+ operation: this.state.operation,
1219
+ value: this.state.filter === "original" ? void 0 : this.state.value,
1220
+ filter: this.state.filter === "original" ? void 0 : this.state.filter,
1221
+ fromViewer: !1
1222
+ });
1223
+ }
1224
+ _initializeValues() {
1225
+ let p = this.state.operation, { range: B, zero: V } = COLOR_OPERATIONS_CONFIG[p], [H, U] = B;
1226
+ this.state = {
1227
+ ...this.state,
1228
+ min: H,
1229
+ max: U,
1230
+ zero: V
1231
+ };
1232
+ let W = this.$["*editorTransformations"][p];
1233
+ if (p === "filter") {
1234
+ let p = Number(U), B = W;
1235
+ if (B) {
1236
+ let { name: V, amount: H } = B;
1237
+ p = V === this.state.filter ? H : U;
1238
+ }
1239
+ this.state = {
1240
+ ...this.state,
1241
+ value: p,
1242
+ defaultValue: p
1243
+ };
1244
+ return;
1245
+ }
1246
+ let G = W === void 0 ? V : W;
1247
+ this.state = {
1248
+ ...this.state,
1249
+ value: G,
1250
+ defaultValue: G
1251
+ };
1252
+ }
1253
+ apply() {
1254
+ let p = { ...this.$["*editorTransformations"] };
1255
+ this.state.operation === "filter" ? !this.state.filter || this.state.filter === "original" ? delete p.filter : p.filter = {
1256
+ name: this.state.filter,
1257
+ amount: this.state.value
1258
+ } : p[this.state.operation] = this.state.value, this.$["*editorTransformations"] = p;
1259
+ }
1260
+ cancel() {
1261
+ this.$["*faderEl"]?.deactivate({ hide: !1 });
1262
+ }
1263
+ initCallback() {
1264
+ super.initCallback(), this.sub("*originalUrl", (p) => {
1265
+ p && (this.state = {
1266
+ ...this.state,
1267
+ originalUrl: p
1268
+ });
1269
+ });
1270
+ }
1271
+ updated(p) {
1272
+ if (super.updated(p), p.has("state")) {
1273
+ let p = `${this.state.filter ?? this.state.operation} ${this.state.value}`;
1274
+ this.$["*operationTooltip"] = p;
1275
+ }
1276
+ }
1277
+ render() {
1278
+ return b`
1279
+ <uc-slider-ui
1280
+ .disabled=${this.state.disabled}
1281
+ .min=${this.state.min}
1282
+ .max=${this.state.max}
1283
+ .defaultValue=${this.state.defaultValue}
1284
+ .zero=${this.state.zero}
1285
+ @slider-input=${this._handleInput}
1286
+ ></uc-slider-ui>
1287
+ `;
1288
+ }
1289
+ };
1290
+ __decorate([r()], EditorSlider.prototype, "state", void 0);
1291
+ function parseFilterValue(p) {
1292
+ if (!p) return null;
1293
+ let B = p.match(/^([A-Za-z]+)\s+(\d+)$/);
1294
+ if (!B) return null;
1295
+ let [, V, H] = B;
1296
+ return !V || H === void 0 ? null : {
1297
+ filter: V,
1298
+ value: Number(H)
1299
+ };
1300
+ }
1301
+ var EditorButtonControl = class extends LitBlock {
1302
+ constructor(...p) {
1303
+ super(...p), this.active = !1, this.title = "", this.icon = "", this.titleProp = "";
1304
+ }
1305
+ get buttonClasses() {
1306
+ let p = this.active;
1307
+ return {
1308
+ "uc-active": p,
1309
+ "uc-not_active": !p
1310
+ };
1311
+ }
1312
+ _updateHostStateClasses() {
1313
+ let p = this.buttonClasses;
1314
+ for (let [B, V] of Object.entries(p)) this.classList.toggle(B, V);
1315
+ }
1316
+ onClick(p) {}
1317
+ connectedCallback() {
1318
+ super.connectedCallback(), this._updateHostStateClasses();
1319
+ }
1320
+ updated(p) {
1321
+ super.updated(p), p.has("active") && this._updateHostStateClasses();
1322
+ }
1323
+ render() {
1324
+ let p = this.onClick, B = this.title;
1325
+ return b`
1326
+ <button
1327
+ role="option"
1328
+ type="button"
1329
+ aria-label=${o$2(this.titleProp)}
1330
+ title=${o$2(this.titleProp)}
1331
+ @click=${p}
1332
+ >
1333
+ <uc-icon name=${this.icon}></uc-icon>
1334
+ <div class="uc-title" ?hidden=${!B}>${B}</div>
1335
+ </button>
1336
+ `;
1337
+ }
1338
+ };
1339
+ __decorate([r()], EditorButtonControl.prototype, "active", void 0), __decorate([r()], EditorButtonControl.prototype, "title", void 0), __decorate([r()], EditorButtonControl.prototype, "icon", void 0), __decorate([r()], EditorButtonControl.prototype, "titleProp", void 0);
1340
+ var SIZE_RECT_FIXED = 12, SIZE_SVG_WRAPPER = 16, getAdjustResolutions = (p) => {
1341
+ let B = 12, V = 12;
1342
+ return p.width / p.height >= 1 ? (B = SIZE_RECT_FIXED, V = Math.round(SIZE_RECT_FIXED * p.height / p.width)) : (V = SIZE_RECT_FIXED, B = Math.round(SIZE_RECT_FIXED * p.width / p.height)), {
1343
+ width: B,
1344
+ height: V
1345
+ };
1346
+ }, EditorFreeformButtonControl = class extends EditorButtonControl {
1347
+ initCallback() {
1348
+ super.initCallback(), this.icon = "arrow-dropdown", this.sub("*currentAspectRatio", (p) => {
1349
+ let B = this._computeTitle(p);
1350
+ this.title = B, this.titleProp = B;
1351
+ });
1352
+ }
1353
+ onClick() {
1354
+ this.$["*showListAspectRatio"] = !0;
1355
+ }
1356
+ _computeTitle(p) {
1357
+ return p ? p.hasFreeform ? this.l10n("freeform-crop") : this.l10n("crop-to-shape", { value: `${p.width}:${p.height}` }) : "";
1358
+ }
1359
+ render() {
1360
+ let p = this.onClick, B = this.title;
1361
+ return b`
1362
+ <button
1363
+ role="option"
1364
+ type="button"
1365
+ class=${e$1(this.buttonClasses)}
1366
+ aria-label=${o$2(this.titleProp)}
1367
+ title=${o$2(this.titleProp)}
1368
+ @click=${p}
1369
+ >
1370
+ <div class="uc-title" ?hidden=${!B}>${B}</div>
1371
+ <uc-icon name=${this.icon}></uc-icon>
1372
+ </button>
1373
+ `;
1374
+ }
1375
+ }, EditorAspectRatioButtonControl = class extends EditorButtonControl {
1376
+ constructor(...p) {
1377
+ super(...p), this._aspectRatio = null;
1378
+ }
1379
+ get aspectRatio() {
1380
+ return this._aspectRatio;
1381
+ }
1382
+ set aspectRatio(p) {
1383
+ if (this._aspectRatio === p) return;
1384
+ let B = this._aspectRatio;
1385
+ this._aspectRatio = p, this.requestUpdate("aspectRatio", B), p ? this._updateAspectRatioPresentation(p) : (this.removeAttribute("uc-aspect-ratio-freeform"), this.title = "", this.titleProp = "");
1386
+ }
1387
+ initCallback() {
1388
+ super.initCallback(), this._aspectRatio && this._updateAspectRatioPresentation(this._aspectRatio), this.sub("*currentAspectRatio", (p) => {
1389
+ this.active = p && p.id === this._aspectRatio?.id || p?.width === this._aspectRatio?.width && p?.height === this._aspectRatio?.height;
1390
+ });
1391
+ }
1392
+ onClick() {
1393
+ this.$["*currentAspectRatio"]?.id !== this._aspectRatio?.id && (this.$["*currentAspectRatio"] = this._aspectRatio);
1394
+ }
1395
+ _updateAspectRatioPresentation(p) {
1396
+ if (!this.isConnected) return;
1397
+ let B = !!p.hasFreeform;
1398
+ this.toggleAttribute("uc-aspect-ratio-freeform", B), (() => {
1399
+ let V = B ? this.l10n("custom") : `${p.width}:${p.height}`;
1400
+ return this.title = V, V;
1401
+ })(), (() => {
1402
+ let V = this.l10n("a11y-cloud-editor-apply-aspect-ratio", {
1403
+ name: B ? this.l10n("custom").toLowerCase() : this.l10n("crop-to-shape", { value: `${p.width}:${p.height}` }).toLowerCase(),
1404
+ value: ""
1405
+ });
1406
+ return this.titleProp = V, V;
1407
+ })(), B || this.requestUpdate();
1408
+ }
1409
+ _renderIcon() {
1410
+ let p = this._aspectRatio;
1411
+ if (!p || p.hasFreeform) return b`<uc-icon name=${this.icon}></uc-icon>`;
1412
+ let { width: B, height: V } = getAdjustResolutions(p);
1413
+ return b`
1414
+ <uc-icon>
1415
+ <svg
1416
+ viewBox="0 0 ${SIZE_SVG_WRAPPER} ${SIZE_SVG_WRAPPER}"
1417
+ aria-hidden="true"
1418
+ focusable="false"
1419
+ >
1420
+ <rect
1421
+ x=${(SIZE_SVG_WRAPPER - B) / 2}
1422
+ y=${(SIZE_SVG_WRAPPER - V) / 2}
1423
+ width=${B}
1424
+ height=${V}
1425
+ rx="2"
1426
+ fill="none"
1427
+ stroke="currentColor"
1428
+ stroke-width="1.2"
1429
+ stroke-linejoin="round"
1430
+ ></rect>
1431
+ </svg>
1432
+ </uc-icon>
1433
+ `;
1434
+ }
1435
+ render() {
1436
+ let p = this.onClick, B = this.title;
1437
+ return b`
1438
+ <button
1439
+ role="option"
1440
+ type="button"
1441
+ class=${e$1(this.buttonClasses)}
1442
+ aria-label=${o$2(this.titleProp)}
1443
+ title=${o$2(this.titleProp)}
1444
+ @click=${p}
1445
+ >
1446
+ ${this._renderIcon()}
1447
+ <div class="uc-title" ?hidden=${!B}>${B}</div>
1448
+ </button>
1449
+ `;
1450
+ }
1451
+ };
1452
+ __decorate([n({ attribute: !1 })], EditorAspectRatioButtonControl.prototype, "aspectRatio", null);
1453
+ function nextAngle(p) {
1454
+ let B = p + 90;
1455
+ return B = B >= 360 ? 0 : B, B;
1456
+ }
1457
+ function nextValue(p, B) {
1458
+ if (p === "rotate") return nextAngle(typeof B == "number" ? B : 0);
1459
+ if (p === "mirror" || p === "flip") return !B;
1460
+ throw Error(`Unsupported operation: ${p}`);
1461
+ }
1462
+ var EditorCropButtonControl = class extends EditorButtonControl {
1463
+ constructor(...p) {
1464
+ super(...p), this.operation = void 0;
1465
+ }
1466
+ willUpdate(p) {
1467
+ super.willUpdate(p), this.operation ? (this.titleProp = this.l10n("a11y-cloud-editor-apply-crop", { name: this.l10n(this.operation).toLowerCase() }), this.icon = this.operation) : (this.icon = "", this.titleProp = "");
1468
+ }
1469
+ onClick(p) {
1470
+ if (!this.operation) return;
1471
+ let B = this.$["*cropperEl"], V = B.getValue(this.operation), H = nextValue(this.operation, V);
1472
+ this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], {
1473
+ operation: this.operation,
1474
+ next: H,
1475
+ prev: V
1476
+ }), B.setValue(this.operation, H);
1477
+ }
1478
+ };
1479
+ __decorate([n({ type: String })], EditorCropButtonControl.prototype, "operation", void 0);
1480
+ var EditorFilterControl = class extends EditorButtonControl {
1481
+ constructor(...p) {
1482
+ super(...p), this._operation = "", this._filter = "", this._originalUrl = "", this._lastPreviewRequestId = 0, this._previewImage = null, this._previewLoaded = !1, this.isOriginal = !1, this._iconSize = 20;
1483
+ }
1484
+ get filter() {
1485
+ return this._filter;
1486
+ }
1487
+ set filter(p) {
1488
+ let B = p ?? "";
1489
+ if (this._filter === B) return;
1490
+ let V = this._filter;
1491
+ this._filter = B, this._operation = "filter", this.isOriginal = B === FAKE_ORIGINAL_FILTER, this.icon = this.isOriginal ? "original" : "slider", this._iconSize = this.isOriginal ? 40 : 20, this.requestUpdate("filter", V), this.isConnected && this._updateFilterLabels(B);
1492
+ }
1493
+ onClick(p) {
1494
+ if (this.active) this.isOriginal || (this.$["*sliderEl"].setOperation(this._operation, this._filter), this.$["*showSlider"] = !0);
1495
+ else {
1496
+ let p = this.$["*sliderEl"];
1497
+ p.setOperation(this._operation, this._filter), p.apply();
1498
+ }
1499
+ this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], { operation: parseFilterValue(this.$["*operationTooltip"]) }), this.$["*currentFilter"] = this._filter;
1500
+ }
1501
+ _previewSrc() {
1502
+ let B = parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"), 10), V = Number.isFinite(B) && B > 0 ? B : this._iconSize || 32, H = window.devicePixelRatio, U = Math.ceil(H * V), W = H >= 2 ? "lightest" : "normal", G = { ...this.$["*editorTransformations"] };
1503
+ return G[this._operation] = this._filter === "original" ? void 0 : {
1504
+ name: this._filter,
1505
+ amount: 100
1506
+ }, createCdnUrl(this._originalUrl, createCdnUrlModifiers(COMMON_OPERATIONS, transformationsToOperations(G), `quality/${W}`, `scale_crop/${U}x${U}/center`, `@clib/${PACKAGE_NAME}/${PACKAGE_VERSION}/uc-cloud-image-editor/`));
1507
+ }
1508
+ async _observerCallback(p, B) {
1509
+ p[0]?.isIntersecting ? await this._loadPreview(B) : this._cancelPreload?.();
1510
+ }
1511
+ initCallback() {
1512
+ super.initCallback(), this._observer = new window.IntersectionObserver(this._observerCallback.bind(this), { threshold: [0, 1] }), this._originalUrl = this.$["*originalUrl"] ?? "", this.sub("*originalUrl", (p) => {
1513
+ this._originalUrl = p ?? "", !this.isOriginal && this._originalUrl && this.isConnected && !this._previewImage && (this._observer?.observe(this), this._schedulePreviewVisibilityCheck());
1514
+ }), this.isOriginal || (this._observer?.observe(this), this._schedulePreviewVisibilityCheck()), this._filter && this._updateFilterLabels(this._filter), this.sub("*currentFilter", (p) => {
1515
+ this.active = !!(p && p === this._filter);
1516
+ }), this.sub("*networkProblems", async (p) => {
1517
+ p || (this._previewImage ? await this._loadPreview() : this._schedulePreviewVisibilityCheck());
1518
+ });
1519
+ }
1520
+ disconnectedCallback() {
1521
+ super.disconnectedCallback(), this._observer?.disconnect(), this._cancelPreload?.(), this._clearPreviewVisibilityChecks();
1522
+ }
1523
+ updated(p) {
1524
+ super.updated(p), p.has("isOriginal") && (this.isOriginal ? this._observer?.unobserve(this) : (this._observer?.observe(this), this._schedulePreviewVisibilityCheck()));
1525
+ }
1526
+ _updateFilterLabels(p) {
1527
+ if (!p) {
1528
+ this.titleProp = "";
1529
+ return;
1530
+ }
1531
+ this.titleProp = this.l10n("a11y-cloud-editor-apply-filter", { name: p.toLowerCase() });
1532
+ }
1533
+ async _loadPreview(p) {
1534
+ if (!this.isConnected) {
1535
+ p?.unobserve(this), this._cancelPreload?.(), this._cancelPreload = void 0;
1536
+ return;
1537
+ }
1538
+ if (!this._originalUrl) {
1539
+ !this._previewVisibilityCheckTimeout && !this._previewVisibilityCheckRaf && this._schedulePreviewVisibilityCheck();
1540
+ return;
1541
+ }
1542
+ let B = ++this._lastPreviewRequestId, V = "";
1543
+ try {
1544
+ V = await this.proxyUrl(this._previewSrc());
1545
+ } catch (p) {
1546
+ this.$["*networkProblems"] = !0, console.error("Failed to resolve preview URL", { error: p });
1547
+ return;
1548
+ }
1549
+ this._previewLoaded = !1, this._cancelPreload?.();
1550
+ let { promise: H, cancel: U } = preloadImage(V);
1551
+ this._cancelPreload = () => {
1552
+ U(), this._lastPreviewRequestId === B && (this._cancelPreload = void 0);
1553
+ };
1554
+ try {
1555
+ if (await H, this._lastPreviewRequestId !== B || !this.isConnected) return;
1556
+ this._previewImage = V, this._previewLoaded = !0, this._clearPreviewVisibilityChecks(), (p ?? this._observer)?.unobserve(this);
1557
+ } catch (p) {
1558
+ this.$["*networkProblems"] = !0, console.error("Failed to load image", { error: p }), this._schedulePreviewVisibilityCheck();
1559
+ } finally {
1560
+ this._lastPreviewRequestId === B && (this._cancelPreload = void 0);
1561
+ }
1562
+ }
1563
+ _schedulePreviewVisibilityCheck() {
1564
+ if (!this.isConnected || this._previewImage || this._previewLoaded || this.isOriginal || this.$["*networkProblems"]) {
1565
+ this._clearPreviewVisibilityChecks();
1566
+ return;
1567
+ }
1568
+ this._previewVisibilityCheckRaf && cancelAnimationFrame(this._previewVisibilityCheckRaf), this._previewVisibilityCheckRaf = requestAnimationFrame(() => {
1569
+ if (this._previewVisibilityCheckRaf = void 0, !this.isConnected || this._previewImage || this._previewLoaded || this.isOriginal) {
1570
+ this._clearPreviewVisibilityChecks();
1571
+ return;
1572
+ }
1573
+ let p = this.getBoundingClientRect(), B = p.width > 0 && p.height > 0, V = window.innerWidth || document.documentElement.clientWidth, H = window.innerHeight || document.documentElement.clientHeight;
1574
+ if (B && p.bottom > 0 && p.right > 0 && p.top < H && p.left < V) {
1575
+ this._loadPreview();
1576
+ return;
1577
+ }
1578
+ this._previewVisibilityCheckTimeout = window.setTimeout(() => {
1579
+ this._previewVisibilityCheckTimeout = void 0, this._schedulePreviewVisibilityCheck();
1580
+ }, 500);
1581
+ });
1582
+ }
1583
+ _clearPreviewVisibilityChecks() {
1584
+ this._previewVisibilityCheckRaf &&= (cancelAnimationFrame(this._previewVisibilityCheckRaf), void 0), this._previewVisibilityCheckTimeout &&= (window.clearTimeout(this._previewVisibilityCheckTimeout), void 0);
1585
+ }
1586
+ get _shouldShowPreview() {
1587
+ return !!(this._previewLoaded && !this.active && !this.isOriginal);
1588
+ }
1589
+ render() {
1590
+ let p = this.onClick, B = { opacity: this._shouldShowPreview ? "1" : "0" };
1591
+ this._previewImage && (B.backgroundImage = `url(${this._previewImage})`);
1592
+ let V = { opacity: this.active || this.isOriginal ? "1" : "0" };
1593
+ return b`
1594
+ <button
1595
+ role="option"
1596
+ type="button"
1597
+ class=${e$1(this.buttonClasses)}
1598
+ aria-label=${o$2(this.titleProp)}
1599
+ title=${o$2(this.titleProp)}
1600
+ @click=${p}
1601
+ >
1602
+ <div class="uc-preview" ?data-loaded=${this._previewLoaded} style=${o$1(B)}></div>
1603
+ <uc-icon
1604
+ class=${e$1({ "uc-original-icon": this.isOriginal })}
1605
+ name=${this.icon}
1606
+ style=${o$1(V)}
1607
+ ></uc-icon>
1608
+ </button>
1609
+ `;
1610
+ }
1611
+ };
1612
+ __decorate([r()], EditorFilterControl.prototype, "_previewImage", void 0), __decorate([r()], EditorFilterControl.prototype, "_previewLoaded", void 0), __decorate([r()], EditorFilterControl.prototype, "isOriginal", void 0), __decorate([r()], EditorFilterControl.prototype, "_iconSize", void 0), __decorate([n({ type: String })], EditorFilterControl.prototype, "filter", null);
1613
+ var EditorOperationControl = class extends EditorButtonControl {
1614
+ constructor(...p) {
1615
+ super(...p), this._operation = "";
1616
+ }
1617
+ get operation() {
1618
+ return this._operation;
1619
+ }
1620
+ set operation(p) {
1621
+ let B = p ?? "";
1622
+ if (this._operation === B) return;
1623
+ let V = this._operation;
1624
+ this._operation = B, this.requestUpdate("operation", V), this.isConnected && B && this._updateOperationMetadata(B);
1625
+ }
1626
+ _updateOperationMetadata(p) {
1627
+ this.icon = p, (() => {
1628
+ let B = this.l10n("a11y-cloud-editor-apply-tuning", { name: this.l10n(p).toLowerCase() });
1629
+ return this.titleProp = B, B;
1630
+ })(), (() => {
1631
+ let B = this.l10n(p);
1632
+ return this.title = B, B;
1633
+ })();
1634
+ }
1635
+ initCallback() {
1636
+ super.initCallback(), this._operation && this._updateOperationMetadata(this._operation), this.sub("*editorTransformations", (p) => {
1637
+ if (!this._operation) return;
1638
+ let { zero: B } = COLOR_OPERATIONS_CONFIG[this._operation], V = p[this._operation];
1639
+ this.active = V === void 0 ? !1 : V !== B;
1640
+ });
1641
+ }
1642
+ onClick(p) {
1643
+ this.$["*sliderEl"]?.setOperation(this._operation), this.$["*showSlider"] = !0, this.$["*currentOperation"] = this._operation, this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], { operation: parseFilterValue(this.$["*operationTooltip"]) });
1644
+ }
1645
+ };
1646
+ __decorate([n({ type: String })], EditorOperationControl.prototype, "operation", null);
1647
+ var X_THRESHOLD = 1, noopScrollListener = () => {}, EditorScroller = class extends LitBlock {
1648
+ constructor(...p) {
1649
+ super(...p), this.hiddenScrollbar = !1, this._handleWheel = (p) => {
1650
+ p.preventDefault();
1651
+ let { deltaY: B, deltaX: V } = p;
1652
+ if (Math.abs(V) > X_THRESHOLD) {
1653
+ this.scrollLeft += V;
1654
+ return;
1655
+ }
1656
+ this.scrollLeft += B;
1657
+ };
1658
+ }
1659
+ connectedCallback() {
1660
+ super.connectedCallback(), this.addEventListener("wheel", this._handleWheel, { passive: !1 }), this.addEventListener("scroll", noopScrollListener, { passive: !0 });
1661
+ }
1662
+ disconnectedCallback() {
1663
+ this.removeEventListener("wheel", this._handleWheel), this.removeEventListener("scroll", noopScrollListener), super.disconnectedCallback();
1664
+ }
1665
+ };
1666
+ __decorate([n({
1667
+ type: Boolean,
1668
+ noAccessor: !0,
1669
+ attribute: "hidden-scrollbar"
1670
+ })], EditorScroller.prototype, "hiddenScrollbar", void 0);
1671
+ var EditorToolbar = class extends LitBlock {
1672
+ constructor(...p) {
1673
+ super(...p), this._showLoader = !1, this.showMainToolbar = !0, this.showSubToolbar = !1, this._showTabToggles = !0, this.tabList = [...ALL_TABS], this.activeTab = TabId.CROP, this._useSliderPanel = !0, this._tooltipVisible = !1, this._operationTooltip = null, this._tabIndicatorOffset = 0, this._tabIndicatorWidth = 0, this._sliderRef = e(), this._tabIndicatorRef = e(), this.tabToggleRefs = {
1674
+ [TabId.CROP]: e(),
1675
+ [TabId.TUNING]: e(),
1676
+ [TabId.FILTERS]: e()
1677
+ }, this._handleWindowResize = () => {
1678
+ this._syncTabIndicator();
1679
+ }, this._cropPresets = [], this._debouncedShowLoader = debounce((p) => {
1680
+ this._showLoader = p;
1681
+ }, 500), this._updateInfoTooltip = debounce(() => {
1682
+ let p = this.$["*editorTransformations"], B = this.$["*currentOperation"], V = "", H = !1;
1683
+ if (this.$["*tabId"] === TabId.FILTERS) if (H = !0, this.$["*currentFilter"] && p?.filter?.name === this.$["*currentFilter"]) {
1684
+ let B = p?.filter?.amount || 100;
1685
+ V = `${this.$["*currentFilter"]} ${B}`;
1686
+ } else V = this.l10n(FAKE_ORIGINAL_FILTER);
1687
+ else if (this.showSubToolbar && this.$["*tabId"] === TabId.TUNING && B) {
1688
+ H = !0;
1689
+ let U = p?.[B] || COLOR_OPERATIONS_CONFIG[B].zero;
1690
+ V = `${this.l10n(B)} ${U}`;
1691
+ }
1692
+ H && (this.$["*operationTooltip"] = V), this._tooltipVisible = H;
1693
+ }, 0), this._subTopToolbarStyles = {
1694
+ hidden: "uc-sub-toolbar--top-hidden",
1695
+ visible: "uc-sub-toolbar--visible"
1696
+ }, this._subBottomToolbarStyles = {
1697
+ hidden: "uc-sub-toolbar--bottom-hidden",
1698
+ visible: "uc-sub-toolbar--visible"
1699
+ }, this._tabToggleStyles = {
1700
+ hidden: "uc-tab-toggle--hidden",
1701
+ visible: "uc-tab-toggle--visible"
1702
+ }, this._tabTogglesStyles = {
1703
+ hidden: "uc-tab-toggles--hidden",
1704
+ visible: "uc-tab-toggles--visible"
1705
+ }, this.init$ = {
1706
+ ...this.init$,
1707
+ "*sliderEl": null,
1708
+ "*showSlider": !1,
1709
+ "*showListAspectRatio": !1,
1710
+ "*currentFilter": FAKE_ORIGINAL_FILTER,
1711
+ "*currentOperation": null,
1712
+ "*operationTooltip": null
1713
+ }, this._handleCancel = (p) => {
1714
+ this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], { action: "cancel" }), this._cancelPreload?.();
1715
+ let B = this.$["*on.cancel"];
1716
+ B?.();
1717
+ }, this._handleApply = (p) => {
1718
+ this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], { action: "apply" });
1719
+ let B = this.$["*on.apply"];
1720
+ B?.(this.$["*editorTransformations"]);
1721
+ }, this._handleApplySlider = (p) => {
1722
+ this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], {
1723
+ action: "apply-slider",
1724
+ operation: parseFilterValue(this.$["*operationTooltip"])
1725
+ }), this._sliderRef.value?.apply(), this._onSliderClose();
1726
+ }, this._handleCancelSlider = (p) => {
1727
+ this.telemetryManager.sendEventCloudImageEditor(p, this.$["*tabId"], { action: "cancel-slider" }), this._sliderRef.value?.cancel(), this._onSliderClose();
1728
+ }, this._handleTabClick = (p) => {
1729
+ let B = p.currentTarget?.getAttribute("data-id");
1730
+ B && (this.telemetryManager.sendEventCloudImageEditor(p, B), this._activateTab(B, { fromViewer: !1 }));
1731
+ };
1732
+ }
1733
+ _onSliderClose() {
1734
+ this.$["*showSlider"] = !1, this.$["*tabId"] === TabId.CROP && (this.$["*showListAspectRatio"] = !1), this.$["*tabId"] === TabId.TUNING && (this._tooltipVisible = !1);
1735
+ }
1736
+ _activateTab(p, { fromViewer: B = !1, force: V = !1 } = {}) {
1737
+ this.$["*tabId"] !== p && (this.$["*tabId"] = p), this._applyTabState(p, {
1738
+ fromViewer: B,
1739
+ force: V
1740
+ });
1741
+ }
1742
+ _applyTabState(p, { fromViewer: B, force: V = !1 }) {
1743
+ if (!V && this.activeTab === p) {
1744
+ this._syncTabIndicator();
1745
+ return;
1746
+ }
1747
+ this.activeTab = p;
1748
+ let H = this.$["*faderEl"], U = this.$["*cropperEl"];
1749
+ p === TabId.CROP ? (H?.deactivate(), this.$["*imageSize"] && U?.activate(this.$["*imageSize"], { fromViewer: B })) : (H?.activate({
1750
+ url: this.$["*originalUrl"],
1751
+ fromViewer: B
1752
+ }), U?.deactivate());
1753
+ for (let B of ALL_TABS) {
1754
+ let V = B === p, H = this.tabToggleRefs[B]?.value;
1755
+ H && (H.active = V), V && this._syncTabIndicator();
1756
+ }
1757
+ }
1758
+ _syncTabIndicator() {
1759
+ let p = this.tabToggleRefs[this.activeTab]?.value, B = this._tabIndicatorRef.value;
1760
+ if (!p || !B) return;
1761
+ let V = p.offsetLeft, H = p.offsetWidth || Number(getComputedStyle(p).width.replace("px", ""));
1762
+ (this._tabIndicatorOffset !== V || this._tabIndicatorWidth !== H) && (this._tabIndicatorOffset = V, this._tabIndicatorWidth = H, B.style.transform = `translateX(${V}px)`, B.style.width = `${H}px`);
1763
+ }
1764
+ get _hasAspectRatioPicker() {
1765
+ return this._cropPresets.length >= 3;
1766
+ }
1767
+ _renderControlsByTab(p) {
1768
+ switch (p) {
1769
+ case TabId.CROP: return this._renderCropTabControls();
1770
+ case TabId.FILTERS: return this._renderFilterTabControls();
1771
+ case TabId.TUNING: return this._renderTuningTabControls();
1772
+ default: return [];
1773
+ }
1774
+ }
1775
+ _renderCropTabControls() {
1776
+ let p = [];
1777
+ if (this._hasAspectRatioPicker) p.push(() => this._renderFreeformControl());
1778
+ else for (let B of this._cropPresets) p.push(() => this._renderAspectRatioControl(B));
1779
+ for (let B of ALL_CROP_OPERATIONS) p.push(() => this._renderCropOperationControl(B));
1780
+ return this._renderControlGroup(p);
1781
+ }
1782
+ _renderFilterTabControls() {
1783
+ let p = [FAKE_ORIGINAL_FILTER, ...ALL_FILTERS].map((p) => () => this._renderFilterControl(p));
1784
+ return this._renderControlGroup(p);
1785
+ }
1786
+ _renderTuningTabControls() {
1787
+ let p = ALL_COLOR_OPERATIONS.map((p) => () => this._renderOperationControl(p));
1788
+ return this._renderControlGroup(p);
1789
+ }
1790
+ _renderControlGroup(p) {
1791
+ return p.length ? p.map((p) => p()) : [];
1792
+ }
1793
+ _renderFreeformControl() {
1794
+ return b`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`;
1795
+ }
1796
+ _renderAspectRatioControl(p) {
1797
+ return b`<uc-editor-aspect-ratio-button-control .aspectRatio=${p}></uc-editor-aspect-ratio-button-control>`;
1798
+ }
1799
+ _renderCropOperationControl(p) {
1800
+ return b`<uc-editor-crop-button-control .operation=${p}></uc-editor-crop-button-control>`;
1801
+ }
1802
+ _renderFilterControl(p) {
1803
+ return b`<uc-editor-filter-control .filter=${p}></uc-editor-filter-control>`;
1804
+ }
1805
+ _renderOperationControl(p) {
1806
+ return b`<uc-editor-operation-control .operation=${p}></uc-editor-operation-control>`;
1807
+ }
1808
+ _renderAspectRatioList() {
1809
+ return this._hasAspectRatioPicker ? this._cropPresets.map((p) => this._renderAspectRatioControl(p)) : [];
1810
+ }
1811
+ async _preloadEditedImage() {
1812
+ if (this.$["*imgContainerEl"] && this.$["*originalUrl"]) {
1813
+ let p = this.$["*imgContainerEl"].offsetWidth, B = await this.proxyUrl(viewerImageSrc(this.$["*originalUrl"], p, this.$["*editorTransformations"]));
1814
+ this._cancelPreload?.();
1815
+ let { cancel: V } = batchPreloadImages([B]);
1816
+ this._cancelPreload = () => {
1817
+ V(), this._cancelPreload = void 0;
1818
+ };
1819
+ }
1820
+ }
1821
+ initCallback() {
1822
+ super.initCallback(), this._cropPresets = [...this.$["*cropPresetList"] ?? []], this.sub("*cropPresetList", (p) => {
1823
+ this._cropPresets = [...p ?? []];
1824
+ }), this.sub("*imageSize", (p) => {
1825
+ p && setTimeout(() => {
1826
+ this._activateTab(this.$["*tabId"], { fromViewer: !0 });
1827
+ }, 0);
1828
+ }), this.sub("*editorTransformations", (p) => {
1829
+ let B = p?.filter?.name;
1830
+ this.$["*currentFilter"] !== B && (this.$["*currentFilter"] = B ?? "");
1831
+ }), this.sub("*currentFilter", () => {
1832
+ this._updateInfoTooltip();
1833
+ }), this.sub("*currentOperation", () => {
1834
+ this._updateInfoTooltip();
1835
+ }), this.sub("*tabId", (p) => {
1836
+ this._applyTabState(p, {
1837
+ fromViewer: !1,
1838
+ force: !0
1839
+ }), this._updateInfoTooltip();
1840
+ }), this.sub("*originalUrl", () => {
1841
+ this.$["*faderEl"]?.deactivate();
1842
+ }), this.sub("*editorTransformations", (p) => {
1843
+ this._preloadEditedImage(), this.$["*faderEl"]?.setTransformations(p);
1844
+ }), this.sub("*loadingOperations", (p) => {
1845
+ let B = !1;
1846
+ for (let [, V] of p.entries()) {
1847
+ if (B) break;
1848
+ for (let [, p] of V.entries()) if (p) {
1849
+ B = !0;
1850
+ break;
1851
+ }
1852
+ }
1853
+ this._debouncedShowLoader(B);
1854
+ }), this.sub("*showSlider", (p) => {
1855
+ p ? (this.showSubToolbar = !0, this.showMainToolbar = !1, this._useSliderPanel = !0) : this.$["*showListAspectRatio"] || (this.showSubToolbar = !1, this.showMainToolbar = !0);
1856
+ }), this.sub("*showListAspectRatio", (p) => {
1857
+ p ? (this.showSubToolbar = !0, this.showMainToolbar = !1, this._useSliderPanel = !1) : this.$["*showSlider"] || (this.showSubToolbar = !1, this.showMainToolbar = !0);
1858
+ }), this.sub("*tabList", (p) => {
1859
+ if (this.tabList = p, this._showTabToggles = p.length > 1, !p.includes(this.$["*tabId"]) && p.length > 0) {
1860
+ let [B] = p;
1861
+ B && this._activateTab(B, { fromViewer: !1 });
1862
+ return;
1863
+ }
1864
+ this._syncTabIndicator();
1865
+ }), this.sub("*operationTooltip", (p) => {
1866
+ this._operationTooltip = p;
1867
+ }), this._updateInfoTooltip();
1868
+ }
1869
+ connectedCallback() {
1870
+ super.connectedCallback(), window.addEventListener("resize", this._handleWindowResize);
1871
+ }
1872
+ firstUpdated(p) {
1873
+ super.firstUpdated(p), this._assignSharedElements(), this._syncTabIndicator();
1874
+ }
1875
+ updated(p) {
1876
+ super.updated(p), (p.has("activeTab") || p.has("tabList")) && this.updateComplete.then(() => this._syncTabIndicator()), (p.has("showSubToolbar") || p.has("showMainToolbar")) && this._assignSharedElements();
1877
+ }
1878
+ disconnectedCallback() {
1879
+ window.removeEventListener("resize", this._handleWindowResize), super.disconnectedCallback(), this.$["*showSlider"] = !1, this.$["*showListAspectRatio"] = !1;
1880
+ }
1881
+ _assignSharedElements() {
1882
+ let p = this._sliderRef.value;
1883
+ p && (this.$["*sliderEl"] = p);
1884
+ }
1885
+ _renderTabToggle(p) {
1886
+ let B = this.tabList.includes(p), V = this.activeTab === p, H = this.tabList.indexOf(p), U = H >= 0 ? o$1({ gridColumn: `${H + 1}` }) : A;
1887
+ return b`
1888
+ <uc-presence-toggle class="uc-tab-toggle" .visible=${B} .styles=${this._tabToggleStyles}>
1889
+ <uc-btn-ui
1890
+ theme="tab"
1891
+ data-id=${p}
1892
+ icon=${p}
1893
+ role="tab"
1894
+ aria-controls=${`tab_${p}`}
1895
+ aria-selected=${V ? "true" : "false"}
1896
+ title-prop=${`a11y-editor-tab-${p}`}
1897
+ .active=${V}
1898
+ style=${U}
1899
+ @click=${this._handleTabClick}
1900
+ ${n$1(this.tabToggleRefs[p])}
1901
+ ></uc-btn-ui>
1902
+ </uc-presence-toggle>
1903
+ `;
1904
+ }
1905
+ _renderTabContent(p) {
1906
+ let B = this._renderControlsByTab(p);
1907
+ return b`
1908
+ <div
1909
+ id=${`tab_${p}`}
1910
+ class="uc-tab-content"
1911
+ >
1912
+ <uc-editor-scroller hidden-scrollbar>
1913
+ <div class="uc-controls-list_align">
1914
+ <div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner">
1915
+ ${B.length ? B : A}
1916
+ </div>
1917
+ </div>
1918
+ </uc-editor-scroller>
1919
+ </div>
1920
+ `;
1921
+ }
1922
+ render() {
1923
+ let p = ["uc-info-tooltip", this._tooltipVisible ? "uc-info-tooltip_visible" : "uc-info-tooltip_hidden"].join(" "), B = this._hasAspectRatioPicker;
1924
+ return b`
1925
+ <uc-line-loader-ui .active=${this._showLoader}></uc-line-loader-ui>
1926
+ <div class="uc-info-tooltip_container">
1927
+ <div class="uc-info-tooltip_wrapper">
1928
+ <div class=${p}>${this._operationTooltip ?? ""}</div>
1929
+ </div>
1930
+ </div>
1931
+ <div class="uc-toolbar-container">
1932
+ <uc-presence-toggle
1933
+ role="tablist"
1934
+ class="uc-sub-toolbar"
1935
+ .visible=${this.showMainToolbar}
1936
+ .styles=${this._subTopToolbarStyles}
1937
+ >
1938
+ <div class="uc-tab-content-row">
1939
+ ${ALL_TABS.map((p) => n$2(this.activeTab === p, () => this._renderTabContent(p)))}
1940
+ </div>
1941
+ <div class="uc-controls-row">
1942
+ <uc-presence-toggle
1943
+ class="uc-tab-toggles"
1944
+ .visible=${this._showTabToggles}
1945
+ .styles=${this._tabTogglesStyles}
1946
+ @initial-render=${() => this._syncTabIndicator()}
1947
+ >
1948
+ <div
1949
+ class="uc-tab-toggles_indicator"
1950
+ ${n$1(this._tabIndicatorRef)}
1951
+ ></div>
1952
+ ${ALL_TABS.map((p) => this._renderTabToggle(p))}
1953
+ </uc-presence-toggle>
1954
+ <uc-btn-ui
1955
+ style="order: -1"
1956
+ theme="secondary-icon"
1957
+ icon="closeMax"
1958
+ title-prop="cancel"
1959
+ @click=${this._handleCancel}
1960
+ ></uc-btn-ui>
1961
+ <uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this._handleApply}></uc-btn-ui>
1962
+ </div>
1963
+ </uc-presence-toggle>
1964
+ <uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this._subBottomToolbarStyles}>
1965
+ <div class="uc-slider" ?hidden=${!this._useSliderPanel}>
1966
+ <uc-editor-slider ${n$1(this._sliderRef)}></uc-editor-slider>
1967
+ </div>
1968
+
1969
+ <div class="uc-list-aspect-ratio-container" ?hidden=${this._useSliderPanel || !B}>
1970
+ ${B ? b`<div class="uc-list-aspect-ratio">${this._renderAspectRatioList()}</div>` : A}
1971
+ </div>
1972
+ <div class="uc-controls-row">
1973
+ <uc-btn-ui theme="secondary" @click=${this._handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui>
1974
+ <uc-btn-ui theme="primary" @click=${this._handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui>
1975
+ </div>
1976
+ </uc-presence-toggle>
1977
+ </div>
1978
+ `;
1979
+ }
1980
+ };
1981
+ __decorate([r()], EditorToolbar.prototype, "_showLoader", void 0), __decorate([r()], EditorToolbar.prototype, "showMainToolbar", void 0), __decorate([r()], EditorToolbar.prototype, "showSubToolbar", void 0), __decorate([r()], EditorToolbar.prototype, "_showTabToggles", void 0), __decorate([r()], EditorToolbar.prototype, "tabList", void 0), __decorate([r()], EditorToolbar.prototype, "activeTab", void 0), __decorate([r()], EditorToolbar.prototype, "_useSliderPanel", void 0), __decorate([r()], EditorToolbar.prototype, "_tooltipVisible", void 0), __decorate([r()], EditorToolbar.prototype, "_operationTooltip", void 0), __decorate([r()], EditorToolbar.prototype, "_cropPresets", void 0);
1982
+ var DEFAULT_TABS = serializeCsv([...ALL_TABS]), CloudImageEditorBlock = class extends LitBlock {
1983
+ constructor(...p) {
1984
+ super(...p), this.ctxOwner = !0, this._statusMessage = "", this._imageSrc = TRANSPARENT_PIXEL_SRC, this._fileType = "", this._showLoader = !1, this.uuid = null, this.cdnUrl = null, this.cropPreset = "", this.tabs = DEFAULT_TABS, this._hasNetworkProblems = !1, this._isInitialized = !1, this._pendingInitUpdate = null, this._debouncedShowLoader = debounce((p) => {
1985
+ this._showLoader = p;
1986
+ }, 300), this._imgRef = e(), this._cropperRef = e(), this._faderRef = e(), this._imgContainerRef = e(), this._handleImageLoad = () => {
1987
+ this._debouncedShowLoader(!1), this._imageSrc !== "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" && (this.$["*networkProblems"] = !1);
1988
+ }, this._handleImageError = () => {
1989
+ this._debouncedShowLoader(!1), this.$["*networkProblems"] = !0;
1990
+ }, this._handleRetryNetwork = () => {
1991
+ let p = this.$["*on.retryNetwork"];
1992
+ p?.();
1993
+ }, this.init$ = {
1994
+ ...this.init$,
1995
+ ...initState(this)
1996
+ };
1997
+ }
1998
+ static {
1999
+ this.styleAttrs = ["uc-cloud-image-editor"];
2000
+ }
2001
+ _scheduleInitialization() {
2002
+ this._isInitialized || this._pendingInitUpdate || (this._pendingInitUpdate = this.updateComplete.then(() => {
2003
+ this._pendingInitUpdate = null, this._isInitialized = !0;
2004
+ }));
2005
+ }
2006
+ initCallback() {
2007
+ super.initCallback(), this._syncTabListFromProp(), this._syncCropPresetState();
2008
+ }
2009
+ _assignSharedElements() {
2010
+ let p = this._faderRef.value;
2011
+ p && (this.$["*faderEl"] = p);
2012
+ let B = this._cropperRef.value;
2013
+ B && (this.$["*cropperEl"] = B);
2014
+ let V = this._imgContainerRef.value;
2015
+ V && (this.$["*imgContainerEl"] = V);
2016
+ let H = this._imgRef.value;
2017
+ H && (this.$["*imgEl"] = H);
2018
+ }
2019
+ _attachImageListeners() {
2020
+ let p = this._imgRef.value;
2021
+ p && (p.addEventListener("load", this._handleImageLoad), p.addEventListener("error", this._handleImageError));
2022
+ }
2023
+ _detachImageListeners() {
2024
+ let p = this._imgRef.value;
2025
+ p && (p.removeEventListener("load", this._handleImageLoad), p.removeEventListener("error", this._handleImageError));
2026
+ }
2027
+ get _imageClassName() {
2028
+ let p = this.$["*tabId"];
2029
+ return classNames("uc-image", {
2030
+ "uc-image_hidden_to_cropper": p === TabId.CROP,
2031
+ "uc-image_hidden_effects": p !== TabId.CROP
2032
+ });
2033
+ }
2034
+ _waitForSize() {
2035
+ return new Promise((p, B) => {
2036
+ let V = window.setTimeout(() => {
2037
+ B(/* @__PURE__ */ Error("[cloud-image-editor] timeout waiting for non-zero container size"));
2038
+ }, 3e3), H = new ResizeObserver((B) => {
2039
+ let [U] = B;
2040
+ U && U.contentRect.width > 0 && U.contentRect.height > 0 && (window.clearTimeout(V), H.disconnect(), window.setTimeout(() => p(), 0));
2041
+ });
2042
+ H.observe(this);
2043
+ });
2044
+ }
2045
+ firstUpdated(p) {
2046
+ super.firstUpdated(p), this._assignSharedElements(), this._attachImageListeners(), this.initEditor();
2047
+ let B = !!(this.uuid || this.cdnUrl), V = p.has("uuid") || p.has("cdnUrl");
2048
+ B && !V && this.updateImage();
2049
+ }
2050
+ disconnectedCallback() {
2051
+ this._detachImageListeners(), super.disconnectedCallback();
2052
+ }
2053
+ render() {
2054
+ let p = this._fileType ?? "", B = this._statusMessage ?? "", V = this._imageSrc || "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=", H = this._showLoader, U = this._hasNetworkProblems;
2055
+ return b`
2056
+ ${o(svg_sprite_default)}
2057
+ <div class="uc-wrapper uc-wrapper_desktop">
2058
+ <uc-presence-toggle class="uc-network_problems_splash" .visible=${U}>
2059
+ <div class="uc-network_problems_content">
2060
+ <div class="uc-network_problems_icon">
2061
+ <uc-icon name="sad"></uc-icon>
2062
+ </div>
2063
+ <div class="uc-network_problems_text">Network error</div>
2064
+ </div>
2065
+ <div class="uc-network_problems_footer">
2066
+ <uc-btn-ui theme="primary" text="Retry" @click=${this._handleRetryNetwork}></uc-btn-ui>
2067
+ </div>
2068
+ </uc-presence-toggle>
2069
+ <div class="uc-viewport">
2070
+ <div class="uc-file_type_outer">
2071
+ <div class="uc-file_type">${p}</div>
2072
+ </div>
2073
+ <div class="uc-image_container" ${n$1(this._imgContainerRef)}>
2074
+ <img src=${V} class=${this._imageClassName} ${n$1(this._imgRef)} />
2075
+ ${n$2(this._isInitialized, () => b`<uc-editor-image-cropper ${n$1(this._cropperRef)}></uc-editor-image-cropper>`)}
2076
+ <uc-editor-image-fader ${n$1(this._faderRef)}></uc-editor-image-fader>
2077
+ </div>
2078
+ <div class="uc-info_pan">${B}</div>
2079
+ </div>
2080
+ <div class="uc-toolbar">
2081
+ <uc-line-loader-ui .active=${H}></uc-line-loader-ui>
2082
+ <div class="uc-toolbar_content uc-toolbar_content__editor">
2083
+ ${n$2(this._isInitialized, () => b`<uc-editor-toolbar></uc-editor-toolbar>`)}
2084
+ </div>
2085
+ </div>
2086
+ </div>
2087
+ `;
2088
+ }
2089
+ updated(p) {
2090
+ super.updated(p), p.has("uuid") && this.uuid && this.updateImage(), p.has("cdnUrl") && this.cdnUrl && this.updateImage(), p.has("tabs") && this._syncTabListFromProp(), (p.has("cropPreset") || p.has("cdnUrl")) && this._syncCropPresetState();
2091
+ }
2092
+ _syncTabListFromProp() {
2093
+ let p = this.tabs || DEFAULT_TABS;
2094
+ this.$["*tabList"] = parseTabs(p);
2095
+ }
2096
+ _syncCropPresetState() {
2097
+ let p = parseCropPreset(this.cropPreset ?? ""), V = null;
2098
+ if (this.cdnUrl) {
2099
+ let B = operationsToTransformations(extractOperations(this.cdnUrl));
2100
+ if (Array.isArray(B?.crop?.dimensions)) {
2101
+ let [H, U] = B.crop.dimensions;
2102
+ V = getClosestAspectRatio(H, U, p, .1);
2103
+ }
2104
+ }
2105
+ this.$["*cropPresetList"] = p, this.$["*currentAspectRatio"] = V ?? p?.[0] ?? null;
2106
+ }
2107
+ async updateImage() {
2108
+ if (this.isConnected) {
2109
+ if (await this._waitForSize(), this.cdnUrl) {
2110
+ let p = this.cdnUrl, B = createOriginalUrl(p, extractUuid(p));
2111
+ if (B === this.$["*originalUrl"]) return;
2112
+ this.$["*originalUrl"] = B;
2113
+ let V = operationsToTransformations(extractOperations(p));
2114
+ this.$["*editorTransformations"] = V;
2115
+ } else if (this.uuid) {
2116
+ let p = createOriginalUrl(this.cfg.cdnCname, this.uuid);
2117
+ if (p === this.$["*originalUrl"]) return;
2118
+ this.$["*originalUrl"] = p, Object.keys(this.$["*editorTransformations"]).length > 0 && (this.$["*editorTransformations"] = {});
2119
+ } else throw Error("No UUID nor CDN URL provided");
2120
+ this.$["*tabId"] === TabId.CROP ? this.$["*cropperEl"]?.deactivate({ reset: !0 }) : this.$["*faderEl"]?.deactivate();
2121
+ try {
2122
+ let p = this.$["*originalUrl"], B = await this.proxyUrl(createCdnUrl(p, createCdnUrlModifiers("json"))), { width: V, height: H } = await fetch(B).then((p) => p.json());
2123
+ this.$["*imageSize"] = {
2124
+ width: V,
2125
+ height: H
2126
+ }, this.$["*tabId"] === TabId.CROP ? this.$["*cropperEl"]?.activate(this.$["*imageSize"]) : this.$["*faderEl"]?.activate({ url: p });
2127
+ } catch (p) {
2128
+ p && (this.telemetryManager.sendEventError(p, "cloud editor image. Failed to load image info"), console.error("Failed to load image info", p));
2129
+ }
2130
+ this._scheduleInitialization();
2131
+ }
2132
+ }
2133
+ async initEditor() {
2134
+ try {
2135
+ await this._waitForSize();
2136
+ } catch (p) {
2137
+ this.isConnected && console.error(p.message);
2138
+ return;
2139
+ }
2140
+ this.classList.add("uc-editor_ON"), this.sub("*networkProblems", (p) => {
2141
+ this._hasNetworkProblems = !!p;
2142
+ }), this.sub("*editorTransformations", (B) => {
2143
+ if (Object.keys(B).length === 0) return;
2144
+ let V = this.$["*originalUrl"], H = createCdnUrlModifiers(transformationsToOperations(B), "preview"), U = {
2145
+ originalUrl: V,
2146
+ cdnUrlModifiers: H,
2147
+ cdnUrl: createCdnUrl(V, H),
2148
+ transformations: B
2149
+ };
2150
+ this.dispatchEvent(new CustomEvent("change", {
2151
+ detail: U,
2152
+ bubbles: !0,
2153
+ composed: !0
2154
+ }));
2155
+ }, !1);
2156
+ }
2157
+ };
2158
+ __decorate([r()], CloudImageEditorBlock.prototype, "_statusMessage", void 0), __decorate([r()], CloudImageEditorBlock.prototype, "_imageSrc", void 0), __decorate([r()], CloudImageEditorBlock.prototype, "_fileType", void 0), __decorate([r()], CloudImageEditorBlock.prototype, "_showLoader", void 0), __decorate([n({
2159
+ type: String,
2160
+ reflect: !0
2161
+ })], CloudImageEditorBlock.prototype, "uuid", void 0), __decorate([n({
2162
+ type: String,
2163
+ attribute: "cdn-url",
2164
+ reflect: !0
2165
+ })], CloudImageEditorBlock.prototype, "cdnUrl", void 0), __decorate([n({
2166
+ type: String,
2167
+ attribute: "crop-preset",
2168
+ reflect: !0
2169
+ })], CloudImageEditorBlock.prototype, "cropPreset", void 0), __decorate([n({
2170
+ type: String,
2171
+ reflect: !0
2172
+ })], CloudImageEditorBlock.prototype, "tabs", void 0), __decorate([r()], CloudImageEditorBlock.prototype, "_hasNetworkProblems", void 0), __decorate([r()], CloudImageEditorBlock.prototype, "_isInitialized", void 0);
2173
+ var CloudImageEditor = class extends CloudImageEditorBlock {
2174
+ static {
2175
+ this.styleAttrs = [...super.styleAttrs, "uc-wgt-common"];
2176
+ }
2177
+ constructor() {
2178
+ super(), this.init$ = {
2179
+ ...this.init$,
2180
+ "*solution": this.tagName
2181
+ };
2182
+ }
2183
+ initCallback() {
2184
+ super.initCallback(), this.telemetryManager.sendEvent({ eventType: InternalEventType.INIT_SOLUTION }), this.a11y?.registerBlock(this);
2185
+ }
2186
+ };
2187
+ export { LineLoaderUi as _, EditorOperationControl as a, EditorAspectRatioButtonControl as c, SliderUi as d, EditorImageFader as f, o$2 as g, BtnUi as h, EditorScroller as i, EditorFreeformButtonControl as l, CropFrame as m, CloudImageEditorBlock as n, EditorFilterControl as o, EditorImageCropper as p, EditorToolbar as r, EditorCropButtonControl as s, CloudImageEditor as t, EditorSlider as u, PresenceToggle as v };