@emailmaker/emailmaker 1.0.107-dev.3 → 1.0.107-dev.5

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 (325) hide show
  1. package/README.md +1 -1
  2. package/cli/dist/lib/cli/project.js +2 -16
  3. package/cli/dist/lib/config.js +20 -29
  4. package/cli/dist/lib/local-test.js +3 -19
  5. package/cli/dist/lib/paths.js +11 -0
  6. package/cli/dist/lib/resolveNpmSpawn.d.ts +20 -0
  7. package/cli/dist/lib/resolveNpmSpawn.js +71 -0
  8. package/cli/dist/lib/template-engine/context/pluginPackageJsonData.js +21 -19
  9. package/cli/dist/lib/template-engine/context/standVitePackageJsonData.js +7 -8
  10. package/cli/dist/lib/template-engine/resolveVariantDir.d.ts +5 -1
  11. package/cli/dist/lib/template-engine/resolveVariantDir.js +22 -0
  12. package/cli/dist/lib/templates/shared/i18n.js +2 -2
  13. package/cli/dist/lib/templates/shared/paths.js +3 -4
  14. package/cli/dist/lib/types/package-config.d.ts +1 -0
  15. package/cli/lib/cli/project.ts +2 -18
  16. package/cli/lib/config.ts +19 -30
  17. package/cli/lib/local-test.ts +3 -22
  18. package/cli/lib/paths.ts +15 -0
  19. package/cli/lib/resolveNpmSpawn.ts +72 -0
  20. package/cli/lib/template-engine/buildStandIndexHtml.test.ts +1 -0
  21. package/cli/lib/template-engine/context/pluginPackageJsonData.ts +23 -23
  22. package/cli/lib/template-engine/context/standVitePackageJsonData.ts +7 -12
  23. package/cli/lib/template-engine/pluginEtaParity.test.ts +1 -0
  24. package/cli/lib/template-engine/resolveVariantDir.ts +22 -0
  25. package/cli/lib/template-engine/standAdvancedViteDevHostEta.test.ts +4 -3
  26. package/cli/lib/template-engine/standWebpackDevHostEta.test.ts +7 -6
  27. package/cli/lib/templates/shared/i18n.ts +2 -2
  28. package/cli/lib/templates/shared/paths.ts +3 -4
  29. package/cli/lib/types/package-config.ts +1 -0
  30. package/cli/package.json +1 -1
  31. package/cli/project-templates/plugin/assets/vite/{plugin-build.config.mjs → plugin-build.config.ts} +7 -5
  32. package/cli/project-templates/plugin/assets/vite/{sandbox-build.config.mjs → sandbox-build.config.ts} +7 -5
  33. package/cli/project-templates/plugin/assets/webpack/{plugin-build.legacy.module.cjs → plugin-build.legacy.module.ts} +20 -7
  34. package/cli/project-templates/plugin/assets/webpack/{plugin-build.legacy.umd.cjs → plugin-build.legacy.umd.ts} +20 -7
  35. package/cli/project-templates/plugin/assets/webpack/{plugin-build.modern.module.cjs → plugin-build.modern.module.ts} +9 -4
  36. package/cli/project-templates/plugin/assets/webpack/{plugin-build.modern.umd.cjs → plugin-build.modern.umd.ts} +9 -4
  37. package/cli/project-templates/plugin/assets/webpack/{sandbox-build.config.cjs → sandbox-build.config.ts} +13 -3
  38. package/cli/project-templates/plugin/bundler-vite/release.html.eta +1 -0
  39. package/cli/project-templates/plugin/bundler-webpack/public/release.html.eta +1 -0
  40. package/cli/project-templates/plugin/shared-base/public/demo/product-1.svg +10 -0
  41. package/cli/project-templates/plugin/shared-base/public/demo/product-2.svg +10 -0
  42. package/cli/project-templates/plugin/shared-base/scripts/build-runner.ts +22 -0
  43. package/cli/project-templates/plugin/shared-base/scripts/build-types.ts +17 -0
  44. package/cli/project-templates/plugin/shared-base/scripts/clean.ts +16 -0
  45. package/cli/project-templates/plugin/shared-base/scripts/dev-runner.ts +52 -0
  46. package/cli/project-templates/plugin/shared-base/scripts/npmRun.ts +61 -0
  47. package/cli/project-templates/plugin/shared-base/scripts/release-runner.ts +18 -0
  48. package/cli/project-templates/plugin/shared-base/scripts/scriptRuntime.ts +10 -0
  49. package/cli/project-templates/plugin/shared-base/src/dev/hostApp.tsx.eta +1 -0
  50. package/cli/project-templates/plugin/shared-base/src/dev-release.tsx.eta +1 -0
  51. package/cli/project-templates/plugin/shared-base/src/dev.tsx.eta +1 -1
  52. package/cli/project-templates/shared/partials/plugin-dev-host-app-advanced.eta +93 -0
  53. package/cli/project-templates/shared/partials/plugin-dev-host-app-minimal.eta +54 -0
  54. package/cli/project-templates/shared/partials/plugin-dev-tsx-advanced.eta +3 -2
  55. package/cli/project-templates/shared/partials/plugin-dev-tsx-debug.eta +18 -0
  56. package/cli/project-templates/shared/partials/plugin-dev-tsx-release.eta +33 -0
  57. package/cli/project-templates/shared/partials/plugin-dev-tsx-runtime-helpers.eta +8 -8
  58. package/cli/project-templates/shared/partials/plugin-index-ts.eta +0 -1
  59. package/cli/project-templates/shared/partials/plugin-vite-dev-host.eta +9 -5
  60. package/cli/project-templates/shared/partials/plugin-vite-plugin-build.eta +7 -5
  61. package/cli/project-templates/shared/partials/plugin-vite-release-html.eta +12 -0
  62. package/cli/project-templates/shared/partials/plugin-vite-sandbox-build.eta +7 -5
  63. package/cli/project-templates/shared/partials/plugin-webpack-dev-host-legacy.eta +12 -5
  64. package/cli/project-templates/shared/partials/plugin-webpack-dev-host-modern.eta +13 -6
  65. package/cli/project-templates/shared/partials/plugin-webpack-release-html.eta +12 -0
  66. package/cli/project-templates/shared/partials/plugin-webpack-sandbox-build.eta +13 -3
  67. package/cli/project-templates/shared/partials/plugin-wp-legacy-module.eta +28 -10
  68. package/cli/project-templates/shared/partials/plugin-wp-legacy-umd.eta +28 -10
  69. package/cli/project-templates/shared/partials/plugin-wp-modern-module.eta +9 -4
  70. package/cli/project-templates/shared/partials/plugin-wp-modern-umd.eta +9 -4
  71. package/cli/project-templates/shared/partials/stand-dev-host-vite-memory.eta +3 -3
  72. package/cli/project-templates/shared/partials/stand-dev-host-vite-subpath.eta +8 -4
  73. package/cli/project-templates/shared/partials/stand-dev-host-vite-umd.eta +5 -5
  74. package/cli/project-templates/shared/partials/stand-dev-host-vite.eta +3 -3
  75. package/cli/project-templates/shared/partials/stand-dev-host-webpack-subpath.eta +8 -4
  76. package/cli/project-templates/shared/partials/stand-dev-host-webpack-umd.eta +9 -3
  77. package/cli/project-templates/shared/partials/stand-dev-host-webpack.eta +8 -4
  78. package/cli/project-templates/shared/partials/stand-dev-storage-middleware.eta +370 -0
  79. package/cli/project-templates/shared/stand-vite-base/config/lib/createViteStandConfig.ts +80 -0
  80. package/cli/project-templates/shared/stand-vite-base/scripts/devStorageMiddleware.ts.eta +1 -0
  81. package/cli/project-templates/shared/stand-webpack-base/config/lib/{createWebpackStandConfig.cjs → createWebpackStandConfig.ts} +31 -19
  82. package/cli/project-templates/{stand/advanced/umd/vite/config/lib/umdServeMiddleware.mjs → shared/stand-webpack-base/config/lib/umdServeMiddleware.ts} +19 -11
  83. package/cli/project-templates/shared/stand-webpack-base/scripts/devStorageMiddleware.ts.eta +1 -0
  84. package/cli/project-templates/stand/advanced/memory-usage/vite/config/lib/{createMemoryUsageStandConfig.mjs → createMemoryUsageStandConfig.ts} +25 -20
  85. package/cli/project-templates/stand/advanced/umd/vite/config/lib/umdServeMiddleware.ts +68 -0
  86. package/cli/project-templates/stand/react-adapter/webpack/README.md.eta +1 -0
  87. package/cli/project-templates/stand/react-adapter/webpack/config/dev-host.ts.eta +1 -0
  88. package/cli/project-templates/stand/react-adapter/webpack/package.json.eta +1 -0
  89. package/cli/project-templates/stand/react-adapter/webpack/public/index.html.eta +1 -0
  90. package/cli/project-templates/stand/react-adapter/webpack/src/dev/editorConfig.ts.eta +1 -0
  91. package/cli/project-templates/stand/react-adapter/webpack/src/dev/email.html.eta +1 -0
  92. package/cli/project-templates/stand/react-adapter/webpack/src/dev/getAuthToken.ts.eta +1 -0
  93. package/cli/project-templates/stand/react-adapter/webpack/src/dev/oauthCredentials.ts +9 -0
  94. package/cli/project-templates/stand/react-adapter/webpack/src/dev/storageProvider.ts.eta +1 -0
  95. package/cli/project-templates/stand/react-adapter/webpack/src/index.tsx.eta +1 -0
  96. package/cli/scripts/cli-matrix-smoke.ts +19 -10
  97. package/cli/scripts/verify-global-cli.ts +1 -1
  98. package/cli/scripts/vite-plugin-version-matrix.ts +299 -0
  99. package/cli/tsconfig.json +2 -2
  100. package/emailmaker-core.ed344c04.js +1 -0
  101. package/emailmaker-esm.js +788 -153
  102. package/emailmaker.d.ts +32 -0
  103. package/emailmaker.js +4 -4
  104. package/iframe/js/amp.BGJMqoms.js +1 -1
  105. package/iframe/js/chunk.oX6nCJbK.js +1 -1
  106. package/iframe/js/iframe-eblock.js +1 -1
  107. package/iframe/js/iframe.js +1 -1
  108. package/iframe/js/rules.BSaCN7eK.js +1 -1
  109. package/iframe/js/sanitize-html.Dy7Uwo8P.js +1 -1
  110. package/images/integrations/activecampaign.svg +4 -0
  111. package/images/integrations/bento.svg +9 -0
  112. package/images/integrations/brevo.svg +7 -0
  113. package/images/integrations/campaign_monitor.svg +10 -0
  114. package/images/integrations/constant_contact.svg +24 -0
  115. package/images/integrations/dotdigital.svg +144 -0
  116. package/images/integrations/getresponse.svg +23 -0
  117. package/images/integrations/hubspot.svg +3 -0
  118. package/images/integrations/klaviyo.svg +10 -0
  119. package/images/integrations/mailchimp.svg +9 -0
  120. package/images/integrations/salesforce.svg +20 -0
  121. package/js/browser-image-compression.js +9 -0
  122. package/package.json +2 -5
  123. package/runtime/@ant-design/cssinjs/index.js +1 -1
  124. package/runtime/@ant-design/icons/index.js +1 -1
  125. package/runtime/@ant-design/pro-layout/index.js +1 -1
  126. package/runtime/README.md +13 -13
  127. package/runtime/antd/index.js +1 -1
  128. package/runtime/app-core/index.js +1 -2
  129. package/runtime/classnames/index.js +1 -1
  130. package/runtime/core/index.js +6 -6
  131. package/runtime/dayjs/index.js +1 -1
  132. package/runtime/di/index.js +1 -2
  133. package/runtime/disposable/index.js +1 -2
  134. package/runtime/errors-runtime/index.js +1 -2
  135. package/runtime/guid/index.js +1 -2
  136. package/runtime/index.js +2 -4
  137. package/runtime/package.json +2 -3
  138. package/runtime/prop-types/index.js +1 -1
  139. package/runtime/react/index.js +1 -1
  140. package/runtime/react/jsx-dev-runtime/index.js +1 -1
  141. package/runtime/react/jsx-runtime/index.js +1 -1
  142. package/runtime/react-dom/client/index.js +1 -1
  143. package/runtime/react-dom/index.js +1 -1
  144. package/runtime/react-router-dom/index.js +1 -1
  145. package/runtime/uuid/index.js +1 -1
  146. package/static/amd/{8fc2a596.js → 19aeb269.js} +88 -88
  147. package/static/core/192ec827.js +1 -0
  148. package/static/core/22c1de2e2.js +1 -0
  149. package/static/core/24faedf0.js +1 -0
  150. package/static/core/29231645.js +1 -0
  151. package/static/core/2a3177fc2.js +1 -0
  152. package/static/core/346aabd2.js +3 -0
  153. package/static/core/3b800ed6.js +1 -0
  154. package/static/core/3e840e90.js +1 -0
  155. package/static/core/40cc9fd7.js +1 -0
  156. package/static/core/421bdec22.js +1 -0
  157. package/static/core/50ff48bc.js +4 -0
  158. package/static/core/5282795d2.js +6 -0
  159. package/static/core/555e2e2f2.js +903 -0
  160. package/static/core/563a283d.js +1 -0
  161. package/static/core/5d47e095.js +47 -0
  162. package/static/core/5f574386.js +1 -0
  163. package/static/core/67a41193.js +1 -0
  164. package/static/core/698dace4.js +7 -0
  165. package/static/core/6b648e2d.js +1 -0
  166. package/static/core/7629adfd.js +1 -0
  167. package/static/core/7717f2932.js +3 -0
  168. package/static/core/776cb34a.js +1 -0
  169. package/static/core/78a1e31e.js +1 -0
  170. package/static/core/7d56d643.js +1 -0
  171. package/static/core/841752212.js +40 -0
  172. package/static/core/8477e97e.js +1 -0
  173. package/static/core/8756d562.js +1 -0
  174. package/static/core/91d328d8.js +1 -0
  175. package/static/core/9270dbb6.js +6 -0
  176. package/static/core/96371334.js +566 -0
  177. package/static/core/9b9ddaef2.js +168 -0
  178. package/static/core/af1da4b4.js +1 -0
  179. package/static/core/b5096b152.js +471 -0
  180. package/static/core/bde6775a.js +1 -0
  181. package/static/core/bf1b888c.js +4 -0
  182. package/static/core/c3747df72.js +598 -0
  183. package/static/core/cec8d739.js +11 -0
  184. package/static/core/cfac3d32.js +1 -0
  185. package/static/core/d21c95cf2.js +1 -0
  186. package/static/core/dbd9ca52.js +1 -0
  187. package/static/core/dc590181.js +1 -0
  188. package/static/core/e0039d55.js +1 -0
  189. package/static/core/e4071c1a.js +4 -0
  190. package/static/core/ef87b75c.js +41 -0
  191. package/static/core/f47701f32.js +20 -0
  192. package/static/core/f83d7ac42.js +3 -0
  193. package/static/core/fcc67e6b.js +1 -0
  194. package/static/core/fd40d85c.js +1 -0
  195. package/static/core/fe638847.js +1 -0
  196. package/static/esm/{e8401d17.js → 203c9644.js} +3 -3
  197. package/static/esm/4b679053.js +27 -0
  198. package/static/esm/{b273a6c2.js → f31a26c6.js} +1 -1
  199. package/static/runtime/disposable-CD74igiJ.js +1 -0
  200. package/static/runtime/guid-C0wuVR8v.js +1 -0
  201. package/vite/index.d.ts +17 -6
  202. package/vite/index.js +315 -270
  203. package/vite/pluginDev/index.d.ts +10 -19
  204. package/vite/pluginDev/index.js +251 -204
  205. package/webpack/index.d.ts +24 -5
  206. package/webpack/index.js +168 -144
  207. package/webpack/pluginDev/index.d.ts +21 -22
  208. package/webpack/pluginDev/index.js +242 -177
  209. package/cli/dist/lib/template-engine/buildStandIndexHtml.test.d.ts +0 -2
  210. package/cli/dist/lib/template-engine/buildStandIndexHtml.test.js +0 -89
  211. package/cli/dist/lib/template-engine/emitEtaTree.test.d.ts +0 -2
  212. package/cli/dist/lib/template-engine/emitEtaTree.test.js +0 -34
  213. package/cli/dist/lib/template-engine/pluginEtaParity.test.d.ts +0 -2
  214. package/cli/dist/lib/template-engine/pluginEtaParity.test.js +0 -105
  215. package/cli/dist/lib/template-engine/resolveVariantDir.test.d.ts +0 -2
  216. package/cli/dist/lib/template-engine/resolveVariantDir.test.js +0 -52
  217. package/cli/dist/lib/template-engine/standAdvancedViteDevHostEta.test.d.ts +0 -2
  218. package/cli/dist/lib/template-engine/standAdvancedViteDevHostEta.test.js +0 -67
  219. package/cli/dist/lib/template-engine/standWebpackDevHostEta.test.d.ts +0 -2
  220. package/cli/dist/lib/template-engine/standWebpackDevHostEta.test.js +0 -83
  221. package/cli/dist/lib/template-engine/storageProviderEta.test.d.ts +0 -2
  222. package/cli/dist/lib/template-engine/storageProviderEta.test.js +0 -26
  223. package/cli/project-templates/plugin/shared-base/scripts/build-types.cjs +0 -8
  224. package/cli/project-templates/plugin/shared-base/scripts/clean.cjs +0 -6
  225. package/cli/project-templates/plugin/shared-base/scripts/dev-runner.cjs +0 -48
  226. package/cli/project-templates/plugin/shared-base/scripts/release-runner.cjs +0 -63
  227. package/cli/project-templates/shared/stand-vite-base/config/lib/createViteStandConfig.mjs +0 -80
  228. package/cli/project-templates/shared/stand-vite-base/scripts/devStorageMiddleware.cjs +0 -235
  229. package/cli/project-templates/shared/stand-webpack-base/config/lib/umdServeMiddleware.cjs +0 -38
  230. package/cli/project-templates/shared/stand-webpack-base/scripts/devStorageMiddleware.cjs +0 -235
  231. package/emailmaker-core.80d62b88.js +0 -569
  232. package/runtime/_core/app-core/index.js +0 -1
  233. package/runtime/_core/chunks/app-core-DphKKh8f.js +0 -1
  234. package/runtime/_core/chunks/chunk-oqAt0Dze.js +0 -1
  235. package/runtime/_core/chunks/di-BHUzE57z.js +0 -1
  236. package/runtime/_core/chunks/disposable-PhM3rJkj.js +0 -1
  237. package/runtime/_core/chunks/errors-runtime-VjCOXaQX.js +0 -1
  238. package/runtime/_core/chunks/guid-D2-FTZQG.js +0 -1
  239. package/runtime/_core/di/index.js +0 -1
  240. package/runtime/_core/disposable/index.js +0 -1
  241. package/runtime/_core/errors-runtime/index.js +0 -1
  242. package/runtime/_core/guid/index.js +0 -1
  243. package/runtime/_core/index.js +0 -1
  244. package/shared/hostBootstrap.js +0 -47
  245. package/shared/pluginDevOptions.js +0 -31
  246. package/shared/runtimeManifest.js +0 -72
  247. package/shared/stringCase.js +0 -16
  248. package/static/core/2360f32a.js +0 -3
  249. package/static/core/2687db56.js +0 -3
  250. package/static/core/2b250af6.js +0 -1261
  251. package/static/core/3469930c.js +0 -302
  252. package/static/core/34ce9042.js +0 -201
  253. package/static/core/4091ba5b.js +0 -25
  254. package/static/core/41ce3a6a.js +0 -173
  255. package/static/core/4ac4908c.js +0 -2213
  256. package/static/core/519096c1.js +0 -2597
  257. package/static/core/5fa1772b.js +0 -116550
  258. package/static/core/61312909.js +0 -3
  259. package/static/core/62a98c07.js +0 -75301
  260. package/static/core/6309c0f2.js +0 -3
  261. package/static/core/68d9f440.js +0 -3
  262. package/static/core/73b645ab.js +0 -2
  263. package/static/core/81019351.js +0 -280
  264. package/static/core/835b37ef.js +0 -591
  265. package/static/core/91242fb3.js +0 -3
  266. package/static/core/972b15b0.js +0 -92399
  267. package/static/core/974ef468.js +0 -493
  268. package/static/core/a17614422.js +0 -38078
  269. package/static/core/a2fa7b5b.js +0 -4232
  270. package/static/core/a513adfd.js +0 -89857
  271. package/static/core/a7c73a9b.js +0 -3813
  272. package/static/core/b64c7c90.js +0 -228
  273. package/static/core/cdc9ba92.js +0 -4711
  274. package/static/core/d1db685d.js +0 -2193
  275. package/static/core/d661febc.js +0 -3
  276. package/static/core/d6d2d2d0.js +0 -23
  277. package/static/core/df1a1225.js +0 -607
  278. package/static/core/e5bff179.js +0 -1302
  279. package/static/core/e5d602f5.js +0 -2
  280. package/static/core/eb029366.js +0 -1532
  281. package/static/core/f46c035a.js +0 -2
  282. package/static/core/f8b9d89a.js +0 -461
  283. package/static/core/fd897ad7.js +0 -3
  284. package/static/core/fdd890c7.js +0 -6168
  285. package/static/esm/29eb18ff.js +0 -164
  286. package/vite/mime-types.js +0 -179
  287. package/vite/utils.js +0 -44
  288. /package/cli/project-templates/plugin/bundler-vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  289. /package/cli/project-templates/plugin/bundler-vite/config/{plugin-build.mjs.eta → plugin-build.ts.eta} +0 -0
  290. /package/cli/project-templates/plugin/bundler-vite/config/{sandbox-build.mjs.eta → sandbox-build.ts.eta} +0 -0
  291. /package/cli/project-templates/plugin/bundler-webpack/config/{dev-host.cjs.eta → dev-host.ts.eta} +0 -0
  292. /package/cli/project-templates/plugin/bundler-webpack/config/{plugin-build.cjs.eta → plugin-build.ts.eta} +0 -0
  293. /package/cli/project-templates/plugin/bundler-webpack/config/{sandbox-build.cjs.eta → sandbox-build.ts.eta} +0 -0
  294. /package/cli/project-templates/stand/advanced/memory-usage/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  295. /package/cli/project-templates/stand/advanced/shadow-dom/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  296. /package/cli/project-templates/stand/advanced/shadow-dom/webpack/config/{dev-host.cjs.eta → dev-host.ts.eta} +0 -0
  297. /package/cli/project-templates/stand/advanced/subpath/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  298. /package/cli/project-templates/stand/advanced/subpath/webpack/config/{dev-host.cjs.eta → dev-host.ts.eta} +0 -0
  299. /package/cli/project-templates/stand/advanced/umd/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  300. /package/cli/project-templates/stand/advanced/umd/webpack/config/{dev-host.cjs.eta → dev-host.ts.eta} +0 -0
  301. /package/cli/project-templates/stand/closed-loop/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  302. /package/cli/project-templates/stand/closed-loop/webpack/config/{dev-host.cjs.eta → dev-host.ts.eta} +0 -0
  303. /package/cli/project-templates/stand/oauth/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  304. /package/cli/project-templates/stand/oauth/webpack/config/{dev-host.cjs.eta → dev-host.ts.eta} +0 -0
  305. /package/cli/project-templates/stand/react-adapter/vite/config/{dev-host.mjs.eta → dev-host.ts.eta} +0 -0
  306. /package/iframe/{iframe-eblock.80d62b88.html → iframe-eblock.ed344c04.html} +0 -0
  307. /package/iframe/{iframe.80d62b88.html → iframe.ed344c04.html} +0 -0
  308. /package/{runtime/chunks → static/runtime}/DownloadOutlined-a2ZUz7zB.js +0 -0
  309. /package/{runtime/chunks → static/runtime}/chunk-D-iEO58U.js +0 -0
  310. /package/{runtime/chunks → static/runtime}/classnames-DBEldvch.js +0 -0
  311. /package/{runtime/chunks → static/runtime}/client-5XqXGmAI.js +0 -0
  312. /package/{runtime/chunks → static/runtime}/dayjs.min-CO3mzOeV.js +0 -0
  313. /package/{runtime/_core/chunks/defineProperty-BGJFuFMq.js → static/runtime/defineProperty-CGNmw-jw.js} +0 -0
  314. /package/{runtime/chunks → static/runtime}/dist-Cns8cA2n.js +0 -0
  315. /package/{runtime/chunks → static/runtime}/dist-Ct0xRt3Y.js +0 -0
  316. /package/{runtime/chunks → static/runtime}/es-0FFT3fCz.js +0 -0
  317. /package/{runtime/chunks → static/runtime}/es-BwJ3eGbx.js +0 -0
  318. /package/{runtime/chunks → static/runtime}/es-D8EsVtRL.js +0 -0
  319. /package/{runtime/chunks → static/runtime}/es-Da4O25Kw.js +0 -0
  320. /package/{runtime/chunks → static/runtime}/jsx-dev-runtime-V4_MuHNS.js +0 -0
  321. /package/{runtime/chunks → static/runtime}/jsx-runtime-DBeCoE0b.js +0 -0
  322. /package/{runtime/chunks → static/runtime}/objectWithoutProperties-Bk0EDksJ.js +0 -0
  323. /package/{runtime/chunks → static/runtime}/prop-types-DxD5wgQ0.js +0 -0
  324. /package/{runtime/chunks → static/runtime}/react-TEeeBWTl.js +0 -0
  325. /package/{runtime/chunks → static/runtime}/react-dom-BKKa1g6U.js +0 -0
@@ -1,2597 +0,0 @@
1
- (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.blocks-app .ant-modal.file-manager{z-index:12;justify-content:center;align-items:center;width:100vw;max-width:none;height:100vh;padding:10px;display:flex;top:0}.blocks-app .ant-modal.file-manager>div,.blocks-app .ant-modal.file-manager .ant-modal-body,.blocks-app .ant-modal.file-manager .ant-spin-nested-loading,.blocks-app .ant-modal.file-manager .ant-spin-container{height:100%}.blocks-app .ant-modal.file-manager>div>.ant-modal-content,.blocks-app .ant-modal.file-manager>.ant-modal-content{border-radius:calc(var(--borderRadiusXL) * 1px);width:100%;max-width:1560px;height:100%;max-height:1020px;padding:0}.blocks-app .ant-modal.file-manager>div>.ant-modal-content .file-manager-layout,.blocks-app .ant-modal.file-manager>.ant-modal-content .file-manager-layout{border-top-right-radius:calc(var(--borderRadiusXL) * 1px);border-top-left-radius:calc(var(--borderRadiusXL) * 1px)}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();import { s as e, t } from "./d6d2d2d0.js";
2
- import "./4091ba5b.js";
3
- import { B as n, Bt as r, Ft as i, Nt as a } from "./cdc9ba92.js";
4
- import { I as o, Rt as s } from "./4ac4908c.js";
5
- import { S as c, x as l } from "./a513adfd.js";
6
- import { a as u, i as d, r as f } from "./a2fa7b5b.js";
7
- import { d as p, l as m, o as h, s as g, u as _ } from "./972b15b0.js";
8
- import "./5fa1772b.js";
9
- import { C as v, _ as y, at as b, b as ee, h as x, i as te, v as ne, x as re, xt as S } from "./df1a1225.js";
10
- import { C as ie, O as ae, f as C, h as oe, l as w, o as se, r as ce, s as le, t as ue, u as de, v as fe } from "./3469930c.js";
11
- import { a as pe, i as me, n as he, o as T, s as ge, t as E } from "./41ce3a6a.js";
12
- //#region src/modules/components/FileManager/TreeCache.ts
13
- var _e = /* @__PURE__ */ e(_()), ve = S(), D = /* @__PURE__ */ e(p());
14
- c();
15
- var O = /* @__PURE__ */ e(r()), k = "";
16
- function A(e) {
17
- return e == null || e === "" ? k : e;
18
- }
19
- function j(e) {
20
- if (e == null) return Infinity;
21
- let t = Number(e);
22
- return Number.isFinite(t) && t >= 0 ? t : Infinity;
23
- }
24
- function M(e) {
25
- if (!e) return null;
26
- let t = e.folderId;
27
- return t == null ? null : String(t);
28
- }
29
- function N(e) {
30
- return !!e && e.isFolder;
31
- }
32
- function P() {
33
- if (typeof globalThis?.crypto?.randomUUID == "function") return globalThis.crypto.randomUUID();
34
- try {
35
- let e = globalThis.crypto || globalThis.msCrypto;
36
- if (e && typeof e.getRandomValues == "function") {
37
- let t = new Uint8Array(16);
38
- e.getRandomValues(t);
39
- let n = "";
40
- for (let e = 0; e < t.length; e++) n += t[e].toString(16).padStart(2, "0");
41
- return `id_${n}`;
42
- }
43
- } catch {}
44
- return `id_fallback_${Date.now().toString(36)}_${Math.floor(Math.random() * (2 ** 53 - 1)).toString(36).slice(0, 8)}`;
45
- }
46
- function F(e) {
47
- if (!e || typeof e != "object") return !1;
48
- let t = e;
49
- return t.code === "path_folder_not_found" || t.data?.code === "path_folder_not_found" || t.status === 404 || t.data?.data?.status === 404;
50
- }
51
- function ye(e) {
52
- let t = 2166136261;
53
- for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = t + ((t << 1) + (t << 4) + (t << 7) + (t << 8) + (t << 24)) >>> 0;
54
- return t.toString(36);
55
- }
56
- function I(e) {
57
- if (!e || typeof e != "object") return String(e ?? "");
58
- let t = e, n = [], r = {}, i = [
59
- "page",
60
- "pageSize",
61
- "sortBy",
62
- "sortOrder",
63
- "search",
64
- "itemType",
65
- "limit"
66
- ];
67
- for (let e of Object.keys(t).sort()) {
68
- let a = t[e];
69
- i.includes(e) ? n.push(`${e}=${String(a ?? "")}`) : r[e] = a;
70
- }
71
- let a = Object.keys(r).length ? JSON.stringify(r) : "", o = n.join("|"), s = a ? ye(a) : "";
72
- return `${o}${s ? `|${s}` : ""}`;
73
- }
74
- var L = class e {
75
- entities = /* @__PURE__ */ new Map();
76
- childrenByParent = /* @__PURE__ */ new Map();
77
- maxCacheSize = 1e4;
78
- now() {
79
- return Date.now();
80
- }
81
- checkCacheSize() {
82
- if (this.entities.size > this.maxCacheSize) {
83
- let e = Array.from(this.entities.entries()).sort((e, t) => e[1].updatedAt - t[1].updatedAt), t = Math.floor(this.maxCacheSize * .1);
84
- for (let n = 0; n < t && n < e.length; n++) {
85
- let [t, r] = e[n];
86
- this.deleteEntityById(t);
87
- }
88
- }
89
- }
90
- getEntity(e) {
91
- return this.entities.get(e)?.value;
92
- }
93
- getRecord(e) {
94
- return this.entities.get(e);
95
- }
96
- getFileSystemItem(e) {
97
- let t = this.getEntity(e);
98
- return t && !N(t) ? t : void 0;
99
- }
100
- getFolder(e) {
101
- let t = this.getEntity(e);
102
- return t && N(t) ? t : void 0;
103
- }
104
- getChildrenIds(e, t = {}) {
105
- let n = A(e), r = this.childrenByParent.get(n);
106
- return r ? t.onlyFileSystemItems ? Array.from(r.files) : t.onlyFolders ? Array.from(r.folders) : [...Array.from(r.folders), ...Array.from(r.files)] : [];
107
- }
108
- searchByUrl(e) {
109
- for (let t of this.entities.values()) if (t.value.url === e) return t.value;
110
- return null;
111
- }
112
- upsertEntity(e) {
113
- let t = this.entities.get(e.id) ?? null, n = t ? t.value : null, r = n ? M(n) : null, i = M(e), a = n ? N(n) : !1, o = N(e), s;
114
- if (n && N(n) && o) {
115
- let t = n.childrenCount, r = e.childrenCount;
116
- t !== void 0 && r === void 0 && (s = t);
117
- }
118
- if (n && (r !== i || a !== o)) {
119
- let t = A(r), n = this.childrenByParent.get(t);
120
- n && (a ? n.folders.delete(e.id) : n.files.delete(e.id), n.files.size === 0 && n.folders.size === 0 && this.childrenByParent.delete(t));
121
- }
122
- let c = e;
123
- s !== void 0 && (c = {
124
- ...e,
125
- childrenCount: s
126
- }), this.entities.set(e.id, {
127
- value: { ...c },
128
- updatedAt: this.now()
129
- }), this.checkCacheSize();
130
- let l = A(i), u = this.childrenByParent.get(l);
131
- u || (u = {
132
- files: /* @__PURE__ */ new Set(),
133
- folders: /* @__PURE__ */ new Set()
134
- }, this.childrenByParent.set(l, u)), o ? u.folders.add(e.id) : u.files.add(e.id);
135
- }
136
- updateServerChildrenCount(e, t) {
137
- if (e == null || t == null || Number.isNaN(t)) return;
138
- let n = this.entities.get(e);
139
- if (!n || !N(n.value)) return;
140
- let r = {
141
- ...n.value,
142
- childrenCount: t
143
- };
144
- this.entities.set(e, {
145
- value: r,
146
- updatedAt: this.now()
147
- });
148
- }
149
- deleteEntityById(e) {
150
- let t = this.entities.get(e) ?? null;
151
- if (!t) return {
152
- entity: null,
153
- parentId: null
154
- };
155
- let n = t.value, r = M(n), i = A(r), a = this.childrenByParent.get(i);
156
- return a && (N(n) ? a.folders.delete(e) : a.files.delete(e), a.files.size === 0 && a.folders.size === 0 && this.childrenByParent.delete(i)), this.entities.delete(e), {
157
- entity: { ...n },
158
- parentId: r
159
- };
160
- }
161
- deleteFolderRecursive(e) {
162
- let t = this.entities.get(e);
163
- if (!t || !N(t.value)) return {
164
- deletedFolderRecords: [],
165
- deletedFileSystemItemRecords: []
166
- };
167
- let n = [{
168
- id: e,
169
- parentId: M(t.value)
170
- }], r = [], i = [];
171
- for (; n.length;) {
172
- let e = n.shift();
173
- r.push(e);
174
- let t = this.childrenByParent.get(A(e.id));
175
- if (t) {
176
- for (let e of Array.from(t.folders)) {
177
- let t = this.entities.get(e);
178
- t && n.push({
179
- id: e,
180
- parentId: M(t.value)
181
- });
182
- }
183
- for (let e of Array.from(t.files)) i.push(e);
184
- }
185
- }
186
- let a = [];
187
- for (let e of i) {
188
- let t = this.entities.get(e);
189
- if (!t) continue;
190
- let n = t.value, r = A(M(n)), i = this.childrenByParent.get(r);
191
- i && (i.files.delete(e), i.files.size === 0 && i.folders.size === 0 && this.childrenByParent.delete(r)), this.entities.delete(e), a.push({ ...n });
192
- }
193
- let o = [];
194
- for (let e = r.length - 1; e >= 0; e--) {
195
- let { id: t, parentId: n } = r[e], i = this.entities.get(t);
196
- if (!i) continue;
197
- let a = i.value, s = A(a.id);
198
- this.childrenByParent.delete(s);
199
- let c = A(n), l = this.childrenByParent.get(c);
200
- l && (l.folders.delete(t), l.files.size === 0 && l.folders.size === 0 && this.childrenByParent.delete(c)), this.entities.delete(t), o.push({ ...a });
201
- }
202
- return {
203
- deletedFolderRecords: o,
204
- deletedFileSystemItemRecords: a
205
- };
206
- }
207
- moveEntityById(e, t) {
208
- let n = this.entities.get(e) ?? null;
209
- if (!n) return null;
210
- let r = n.value, i = A(M(r)), a = this.childrenByParent.get(i);
211
- a && (N(r) ? a.folders.delete(e) : a.files.delete(e), a.files.size === 0 && a.folders.size === 0 && this.childrenByParent.delete(i));
212
- let o = {
213
- ...r,
214
- folderId: t
215
- };
216
- if (N(r) && N(o)) {
217
- let e = r.childrenCount;
218
- e !== void 0 && (o.childrenCount = e);
219
- }
220
- this.entities.set(e, {
221
- value: o,
222
- updatedAt: this.now()
223
- });
224
- let s = A(t), c = this.childrenByParent.get(s);
225
- return c || (c = {
226
- files: /* @__PURE__ */ new Set(),
227
- folders: /* @__PURE__ */ new Set()
228
- }, this.childrenByParent.set(s, c)), N(o) ? c.folders.add(e) : c.files.add(e), { ...o };
229
- }
230
- copyFileSystemItem(e, t, n) {
231
- let r = this.entities.get(e) ?? null;
232
- if (!r || N(r.value)) return null;
233
- let i = {
234
- ...r.value,
235
- id: t,
236
- folderId: n
237
- };
238
- return this.upsertEntity(i), { ...i };
239
- }
240
- copyFolderShallow(e, t, n) {
241
- let r = this.entities.get(e) ?? null;
242
- if (!r || !N(r.value)) return null;
243
- let i = {
244
- ...r.value,
245
- id: t,
246
- folderId: n
247
- };
248
- return this.upsertEntity(i), { ...i };
249
- }
250
- isEntityStale(e, t) {
251
- let n = this.entities.get(e) ?? null;
252
- return n ? t === Infinity ? !1 : this.now() - n.updatedAt > t : !0;
253
- }
254
- touch(e, t) {
255
- let n = this.entities.get(e);
256
- n && (n.updatedAt = t ?? this.now());
257
- }
258
- getEntitiesByIds(e) {
259
- return e.map((e) => this.entities.get(e)?.value ?? null);
260
- }
261
- searchByName(e, t) {
262
- if (!e || e.trim() === "") return [];
263
- let n = t?.parentId, r = t?.recursive ?? !1, i = t?.itemType ?? "all", a = t?.caseSensitive ?? !1, o = t?.limit ?? Infinity, s = a ? e.trim() : e.trim().toLowerCase(), c = [], l = null;
264
- if (n !== void 0) {
265
- l = /* @__PURE__ */ new Set();
266
- let e = A(n);
267
- if (l.add(e), r) {
268
- let t = [e], n = /* @__PURE__ */ new Set();
269
- for (; t.length > 0;) {
270
- let e = t.shift();
271
- if (n.has(e)) continue;
272
- n.add(e);
273
- let r = this.childrenByParent.get(e);
274
- if (r) for (let e of r.folders) l.add(e), t.push(e);
275
- }
276
- }
277
- }
278
- for (let [, e] of this.entities) {
279
- if (c.length >= o) break;
280
- let t = e.value;
281
- if (l !== null) {
282
- let e = A(M(t));
283
- if (!l.has(e)) continue;
284
- }
285
- if (i === "file" && N(t) || i === "folder" && !N(t)) continue;
286
- let n = t.name ?? "";
287
- (a ? n : n.toLowerCase()).includes(s) && c.push({ ...t });
288
- }
289
- return c;
290
- }
291
- toJSON() {
292
- return {
293
- entities: Array.from(this.entities.entries()),
294
- childrenByParent: Array.from(this.childrenByParent.entries()).map(([e, t]) => [e, {
295
- files: Array.from(t.files),
296
- folders: Array.from(t.folders)
297
- }])
298
- };
299
- }
300
- static fromJSON(t) {
301
- let n = new e();
302
- for (let [e, r] of t.entities ?? []) n.entities.set(e, {
303
- value: r.value,
304
- updatedAt: r.updatedAt
305
- });
306
- for (let [e, r] of t.childrenByParent ?? []) n.childrenByParent.set(e, {
307
- files: new Set(r.files),
308
- folders: new Set(r.folders)
309
- });
310
- return n;
311
- }
312
- }, R = class e {
313
- views = /* @__PURE__ */ new Map();
314
- strategy;
315
- ttl;
316
- errorTtl;
317
- entityTtl;
318
- serverChildrenCountHandler;
319
- childrenCountInvalidator;
320
- maxViewsPerParent = 50;
321
- constructor(e = {}, t = 3e5, n = 3e4, r) {
322
- this.strategy = {
323
- allowSortedInsert: e.allowSortedInsert ?? !0,
324
- allowSearchInsert: e.allowSearchInsert ?? !0,
325
- invalidateOnPaginationFull: e.invalidateOnPaginationFull ?? !0,
326
- preloadPagesBefore: e.preloadPagesBefore ?? 0,
327
- preloadPagesAfter: e.preloadPagesAfter ?? 1,
328
- comparator: e.comparator,
329
- filterMatch: e.filterMatch
330
- }, this.ttl = t, this.errorTtl = n, this.entityTtl = r ?? t;
331
- }
332
- setServerChildrenCountHandler(e) {
333
- this.serverChildrenCountHandler = e;
334
- }
335
- setChildrenCountInvalidator(e) {
336
- this.childrenCountInvalidator = e;
337
- }
338
- now() {
339
- return Date.now();
340
- }
341
- parentKey(e) {
342
- return A(e ?? null);
343
- }
344
- isExpired(e) {
345
- return e == null ? !0 : this.ttl === Infinity ? !1 : this.now() - e > this.ttl;
346
- }
347
- isErrorExpired(e) {
348
- return e == null ? !0 : this.errorTtl === Infinity ? !1 : this.now() - e > this.errorTtl;
349
- }
350
- areEntitiesStale(e, t) {
351
- return e ? e.some((e) => !t.getEntity(e) || t.isEntityStale(e, this.entityTtl)) : !0;
352
- }
353
- isEntityTypeCompatible(e, t) {
354
- return !!(!t || t === "all" || t === "file" && !N(e) || t === "folder" && N(e));
355
- }
356
- cleanupOldViews(e) {
357
- if (e.size <= this.maxViewsPerParent) return;
358
- let t = Array.from(e.entries()).sort((e, t) => (t[1].view.updatedAt || 0) - (e[1].view.updatedAt || 0));
359
- for (; e.size > this.maxViewsPerParent && t.length > 0;) {
360
- let [n] = t.pop();
361
- e.delete(n);
362
- }
363
- }
364
- async getOrCreateChildren(e, t, n, r) {
365
- let i = this.parentKey(e), a = I(t ?? {}), o = this.views.get(i);
366
- o || (o = /* @__PURE__ */ new Map(), this.views.set(i, o));
367
- let s = o.get(a);
368
- if (s || (s = {
369
- params: t,
370
- view: {
371
- promise: null,
372
- value: void 0,
373
- meta: void 0,
374
- error: void 0,
375
- updatedAt: 0,
376
- loadId: null
377
- }
378
- }, o.set(a, s), this.cleanupOldViews(o)), s.view.error && !this.isErrorExpired(s.view.updatedAt)) throw s.view.error;
379
- if (s.view.value && !this.isExpired(s.view.updatedAt) && !this.areEntitiesStale(s.view.value, r) && !s.view.meta?.stale) {
380
- let e = s.view.value.map((e) => r.getEntity(e)).filter(Boolean), t = s.params?.itemType || "all";
381
- return {
382
- items: e.filter((e) => this.isEntityTypeCompatible(e, t)),
383
- ...s.view.meta ?? {}
384
- };
385
- }
386
- if (s.view.promise) return s.view.promise;
387
- let c = P();
388
- s.view.loadId = c;
389
- let l = (async () => {
390
- try {
391
- let a = await n(e, t), o = this.views.get(i)?.get(I(t));
392
- if (!o || o.view.loadId !== c) {
393
- let e = /* @__PURE__ */ Error("StaleLoad");
394
- throw e.name = "StaleLoad", e;
395
- }
396
- for (let e of a.items) r.upsertEntity(e);
397
- s.view.value = a.items.map((e) => e.id);
398
- let { items: l, ...u } = a, d = { ...u };
399
- s.view.meta = d, s.view.meta.stale = !1, s.view.error = null, s.view.updatedAt = this.now(), typeof d.total == "number" && (this.serverChildrenCountHandler ? this.serverChildrenCountHandler(e ?? null, d.total, r) : r.updateServerChildrenCount(e, d.total));
400
- let f = this.strategy.preloadPagesAfter ?? 0, p = this.strategy.preloadPagesBefore ?? 0, m = j(t?.pageSize);
401
- if ((f > 0 || p > 0) && Number.isFinite(m)) {
402
- let i = e, a = { ...t }, o = typeof d.totalPages == "number" ? d.totalPages : 1, s = t?.page ?? 1, l = m, u = n, h = c;
403
- setTimeout(() => {
404
- this.preloadPagesAsync(i, a, s, o, l, f, p, r, d, u, h);
405
- }, 0);
406
- }
407
- return a;
408
- } catch (e) {
409
- if (e?.name === "StaleLoad") throw s.view.error = null, s.view.value = void 0, s.view.updatedAt = this.now(), e;
410
- let t = e, n = t?.status ?? t?.data?.status, r = t?.code ?? t?.data?.code;
411
- if (n === 404 || r === "FileNotFound" || r === "FolderNotFound" || r === "path_folder_not_found") return s.view.error = null, s.view.value = [], s.view.meta = {
412
- total: 0,
413
- totalPages: 0
414
- }, s.view.updatedAt = this.now(), {
415
- items: [],
416
- total: 0,
417
- totalPages: 0
418
- };
419
- throw s.view.error = e, s.view.value = void 0, s.view.updatedAt = this.now(), e;
420
- } finally {
421
- s.view.promise = null;
422
- }
423
- })();
424
- return s.view.promise = l, l;
425
- }
426
- async preloadPagesAsync(e, t, n, r, i, a, o, s, c, l, u) {
427
- try {
428
- let i = this.parentKey(e), c = this.views.get(i);
429
- if (!c) return;
430
- let d = c.get(I(t));
431
- if (!d || u != null && d.view.loadId !== u) return;
432
- let f = c.get(I(t));
433
- if (!f?.view.meta) return;
434
- let p = typeof f.view.meta.totalPages == "number" ? f.view.meta.totalPages : 1;
435
- if (p !== r) return;
436
- let m = async (n) => {
437
- let r = {
438
- ...t,
439
- page: n
440
- };
441
- try {
442
- let a = await l(e, r), o = this.views.get(i);
443
- if (!o) return;
444
- let c = o.get(I(t));
445
- if (!c || u != null && c.view.loadId !== u || c.view.loadId !== u) return;
446
- for (let e of a.items) s.upsertEntity(e);
447
- let d = I(r), f = o.get(d);
448
- if (f || (f = {
449
- params: r,
450
- view: {
451
- promise: null,
452
- value: void 0,
453
- meta: void 0,
454
- error: void 0,
455
- updatedAt: 0,
456
- loadId: c.view.loadId
457
- }
458
- }, o.set(d, f), this.cleanupOldViews(o)), !f.view.value || this.isExpired(f.view.updatedAt)) {
459
- f.view.value = a.items.map((e) => e.id);
460
- let { items: e, ...t } = a;
461
- f.view.meta = {
462
- ...t,
463
- page: n,
464
- totalPages: p
465
- }, f.view.updatedAt = this.now();
466
- }
467
- } catch {}
468
- };
469
- if (a > 0 && n < p) for (let e = 1; e <= Math.min(a, p - n); e++) {
470
- let r = n + e, i = I({
471
- ...t,
472
- page: r
473
- }), a = c.get(i);
474
- (!a?.view.value || this.isExpired(a.view.updatedAt)) && m(r);
475
- }
476
- if (o > 0 && n > 1) for (let e = 1; e <= Math.min(o, n - 1); e++) {
477
- let r = n - e, i = I({
478
- ...t,
479
- page: r
480
- }), a = c.get(i);
481
- (!a?.view.value || this.isExpired(a.view.updatedAt)) && m(r);
482
- }
483
- } catch {}
484
- }
485
- removeEmptyPageIfNeeded(e, t, n, r, i) {
486
- if (t.view.value && t.view.value.length === 0 && n < r) {
487
- let t = I({
488
- ...i,
489
- page: n
490
- });
491
- e.delete(t);
492
- }
493
- }
494
- updateTotalPagesForAllViews(e, t) {
495
- for (let [, n] of e) n.view.meta && (n.view.meta.totalPages = t);
496
- }
497
- isParamsSame(e, t) {
498
- let n = Object.keys(e ?? {}).filter((e) => e !== "page").sort(), r = Object.keys(t ?? {}).filter((e) => e !== "page").sort();
499
- if (n.length !== r.length) return !1;
500
- for (let i = 0; i < n.length; i++) {
501
- let a = n[i];
502
- if (a !== r[i] || e[a] !== t[a]) return !1;
503
- }
504
- return !0;
505
- }
506
- syncTotalsInSameViews(e, t) {
507
- let n = t.view.meta;
508
- if (!n || typeof n.total != "number") return;
509
- let r = Number(n.total), i = j(t.params?.pageSize), a = Number.isFinite(i) && i > 0 ? Math.max(1, Math.ceil(r / i)) : void 0;
510
- for (let [, n] of e) this.isParamsSame(n.params ?? {}, t.params ?? {}) && (n.view.meta || (n.view.meta = {}), n.view.meta.total = r, a !== void 0 && (n.view.meta.totalPages = a));
511
- }
512
- canSafelyModifySortedView(e) {
513
- return !!(!e.sortBy && !e.sortOrder || this.strategy.comparator);
514
- }
515
- cascadeShiftPages(e, t, n, r, i, a, o) {
516
- let s = t, c = n, l = !1, u = 0;
517
- for (; s.view.value && s.view.value.length < r && c < i && u < 100;) {
518
- u++;
519
- let t = I({
520
- ...o,
521
- page: c + 1
522
- }), n = e.get(t);
523
- if (!n?.view.value || this.isExpired(n.view.updatedAt)) {
524
- s.view.meta = {
525
- ...s.view.meta ?? {},
526
- stale: !0
527
- };
528
- break;
529
- }
530
- let i = r - s.view.value.length, d = n.view.value.slice(0, i).filter((e) => a.getEntity(e));
531
- if (d.length === 0) {
532
- s.view.meta = {
533
- ...s.view.meta ?? {},
534
- stale: !0
535
- };
536
- break;
537
- }
538
- if (s.view.value = [...s.view.value, ...d], s.view.updatedAt = Date.now(), n.view.value = n.view.value.slice(d.length), n.view.updatedAt = Date.now(), n.view.value.length === 0) {
539
- let t = c + 1, r = n.view.meta;
540
- if (t < (r && typeof r.totalPages == "number" ? r.totalPages : 1)) {
541
- let n = I({
542
- ...o,
543
- page: t
544
- });
545
- e.delete(n), l = !0;
546
- }
547
- break;
548
- }
549
- s = n, c++;
550
- }
551
- return (!s.view.value || s.view.value.length < r) && c >= i && (s.view.meta = {
552
- ...s.view.meta ?? {},
553
- stale: !0
554
- }), l;
555
- }
556
- cascadeShiftToNextPage(e, t, n, r, i, a, o) {
557
- if (!t.view.value || t.view.value.length <= r) return !1;
558
- if (n - (o.page || 1) >= 10) return t.view.meta = {
559
- ...t.view.meta ?? {},
560
- stale: !0
561
- }, !1;
562
- let s = {
563
- ...o,
564
- page: n + 1
565
- }, c = I(s), l = e.get(c), u = !1;
566
- if (!l?.view.value || this.isExpired(l.view.updatedAt)) if (n >= i) {
567
- l = {
568
- params: s,
569
- view: {
570
- promise: null,
571
- value: void 0,
572
- meta: void 0,
573
- error: void 0,
574
- updatedAt: 0,
575
- loadId: null
576
- }
577
- }, e.set(c, l), this.cleanupOldViews(e);
578
- let r = t.view.meta;
579
- r && (l.view.meta = {
580
- ...r,
581
- page: n + 1
582
- }), u = !0;
583
- } else return t.view.meta = {
584
- ...t.view.meta ?? {},
585
- stale: !0
586
- }, !1;
587
- let d = t.view.value.slice(r).filter((e) => a.getEntity(e));
588
- if (d.length === 0) return u && e.delete(c), !1;
589
- t.view.value = t.view.value.slice(0, r), t.view.updatedAt = Date.now(), l.view.value = [...d, ...l.view.value ?? []], l.view.updatedAt = Date.now();
590
- let f = l.view.meta && typeof l.view.meta.totalPages == "number" ? l.view.meta.totalPages : i;
591
- if (!u && this.cascadeShiftToNextPage(e, l, n + 1, r, f, a, o)) return !0;
592
- if (!l.view.value || l.view.value.length === 0) {
593
- let t = n + 1, r = l.view.meta, i = r && typeof r.totalPages == "number" ? r.totalPages : 1;
594
- this.removeEmptyPageIfNeeded(e, l, t, i, o);
595
- }
596
- return u;
597
- }
598
- tryInsertSorted(e, t, n) {
599
- let r = this.strategy.comparator;
600
- if (!r || !e.view.value) return !1;
601
- let i = e.params?.itemType || "all";
602
- if (!this.isEntityTypeCompatible(t, i)) return !1;
603
- let a = e.view.value.map((e) => n.getEntity(e));
604
- if (a.some((e) => !e)) return !1;
605
- let o = 0, s = a.length;
606
- for (; o < s;) {
607
- let n = Math.floor((o + s) / 2), i = r(t, a[n], e.params);
608
- if (typeof i != "number" || Number.isNaN(i)) return !1;
609
- i >= 0 ? o = n + 1 : s = n;
610
- }
611
- return e.view.value.includes(t.id) ? (e.view.updatedAt = this.now(), !0) : (e.view.value = [
612
- ...e.view.value.slice(0, o),
613
- t.id,
614
- ...e.view.value.slice(o)
615
- ], e.view.updatedAt = this.now(), e.view.meta && typeof e.view.meta.total == "number" && (e.view.meta.total = Number(e.view.meta.total) + 1), !0);
616
- }
617
- updateChildrenCountForOperation(e, t, n, r) {
618
- let i = M(t);
619
- switch (e) {
620
- case "delete":
621
- this.adjustChildrenCount(r, i, -1), this.childrenCountInvalidator?.(i);
622
- break;
623
- case "insert":
624
- case "copy":
625
- this.adjustChildrenCount(r, i, 1), this.childrenCountInvalidator?.(i);
626
- break;
627
- case "move":
628
- this.adjustChildrenCount(r, n, -1), this.adjustChildrenCount(r, i, 1), this.childrenCountInvalidator?.(n), this.childrenCountInvalidator?.(i);
629
- break;
630
- }
631
- }
632
- adjustChildrenCount(e, t, n) {
633
- if (!t) return;
634
- let r = e.getFolder(t);
635
- if (r && typeof r.childrenCount == "number") {
636
- let i = Math.max(0, r.childrenCount + n);
637
- e.updateServerChildrenCount(t, i);
638
- }
639
- }
640
- smartInvalidateChildrenViews(e, t, n, r, i, a) {
641
- if (!t) return;
642
- this.updateChildrenCountForOperation(n, t, i, r);
643
- let o = this.parentKey(e), s = this.views.get(o);
644
- if (s) for (let [, e] of s) {
645
- let a = e.params ?? {}, o = a?.page ?? 1, c = j(a?.pageSize), l = Number.isFinite(c), u = !!(a?.sortBy || a?.sortOrder), d = !!a?.search, f = a?.itemType || "all";
646
- if (this.isEntityTypeCompatible(t, f)) {
647
- if (d && this.strategy.filterMatch && !this.strategy.filterMatch(t, e.params)) {
648
- e.view.value?.includes(t.id) && (e.view.value = e.view.value.filter((e) => e !== t.id), e.view.meta && typeof e.view.meta.total == "number" && (e.view.meta.total = Math.max(0, e.view.meta.total - 1)), e.view.updatedAt = Date.now());
649
- continue;
650
- }
651
- if (!e.view.value) {
652
- e.view.meta && (e.view.meta.stale = !0), e.view.loadId = P(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
653
- continue;
654
- }
655
- if (e.view.value.includes(t.id), this.shouldInvalidateCompletely(e, n, t, u, l, o)) {
656
- e.view.meta = {
657
- ...e.view.meta ?? {},
658
- stale: !0
659
- }, e.view.loadId = P(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
660
- continue;
661
- }
662
- switch (n) {
663
- case "delete":
664
- this.handleDelete(s, e, o, c, l, t, r);
665
- break;
666
- case "insert":
667
- case "copy":
668
- this.handleInsert(s, e, o, c, l, u, t, r);
669
- break;
670
- case "update":
671
- this.handleUpdate(s, e, o, c, l, u, d, t, r);
672
- break;
673
- case "move":
674
- this.handleMove(s, e, o, c, l, u, t, i, r);
675
- break;
676
- }
677
- }
678
- }
679
- }
680
- shouldInvalidateCompletely(e, t, n, r, i, a) {
681
- return !!(i && a > 1 && (t === "insert" || t === "delete" || t === "move") || r && !this.strategy.comparator && (t === "insert" || t === "move") || this.isExpired(e.view.updatedAt));
682
- }
683
- tryReinsertEntity(e, t, n, r, i) {
684
- let a = e.params?.itemType || "all";
685
- if (!this.isEntityTypeCompatible(t, a)) return !1;
686
- if (this.strategy.comparator && this.strategy.filterMatch) {
687
- if (!this.strategy.filterMatch(t, e.params)) return !1;
688
- if (this.tryInsertSorted(e, t, n)) return !0;
689
- }
690
- let o = e.params ?? {};
691
- return (o.sortBy || o.sortOrder) && !this.canSafelyModifySortedView(o) ? !1 : !r || e.view.value.length < i ? (e.view.value.push(t.id), !0) : !1;
692
- }
693
- handleDelete(e, t, n, r, i, a, o) {
694
- let s = t.view.value.includes(a.id);
695
- if (s && (t.view.value = t.view.value.filter((e) => e !== a.id)), t.view.meta && typeof t.view.meta.total == "number") {
696
- if (t.view.meta.total = Math.max(0, t.view.meta.total - 1), i && Number.isFinite(r) && typeof t.view.meta.total == "number") {
697
- let e = r;
698
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
699
- }
700
- this.syncTotalsInSameViews(e, t);
701
- }
702
- if (t.view.updatedAt = Date.now(), s && i && t.view.value.length < r && o) {
703
- let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
704
- if (this.cascadeShiftPages(e, t, n, r, a, o, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
705
- let n = Math.max(1, t.view.meta.totalPages - 1);
706
- t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
707
- }
708
- }
709
- t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
710
- }
711
- handleInsert(e, t, n, r, i, a, o, s) {
712
- if (!t.view.value.includes(o.id)) {
713
- if (a && this.strategy.allowSortedInsert && this.strategy.comparator && s) {
714
- if (this.tryInsertSorted(t, o, s) && t.view.meta && typeof t.view.meta.total == "number") {
715
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
716
- let e = r;
717
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
718
- }
719
- this.syncTotalsInSameViews(e, t);
720
- }
721
- if (i && t.view.value.length > r && s) {
722
- let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
723
- if (this.cascadeShiftToNextPage(e, t, n, r, a, s, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
724
- let n = t.view.meta.totalPages + 1;
725
- t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
726
- }
727
- }
728
- } else if (!i || t.view.value.length < r) {
729
- if (t.view.value.push(o.id), t.view.meta && typeof t.view.meta.total == "number") {
730
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
731
- let e = r;
732
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
733
- }
734
- this.syncTotalsInSameViews(e, t);
735
- }
736
- t.view.updatedAt = Date.now();
737
- } else t.view.meta = {
738
- ...t.view.meta ?? {},
739
- stale: !0
740
- };
741
- t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
742
- }
743
- }
744
- handleUpdate(e, t, n, r, i, a, o, s, c) {
745
- let l = t.view.value.includes(s.id), u = this.isEntityTypeCompatible(s, t.params?.itemType || "all");
746
- if (l && !u) {
747
- if (t.view.value = t.view.value.filter((e) => e !== s.id), t.view.meta && typeof t.view.meta.total == "number" && (t.view.meta.total = Math.max(0, t.view.meta.total - 1), i && Number.isFinite(r) && typeof t.view.meta.total == "number")) {
748
- let e = r;
749
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
750
- }
751
- if (t.view.updatedAt = Date.now(), i && t.view.value.length < r && c) {
752
- let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
753
- if (this.cascadeShiftPages(e, t, n, r, a, c, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
754
- let n = Math.max(1, t.view.meta.totalPages - 1);
755
- t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
756
- }
757
- }
758
- t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
759
- return;
760
- }
761
- if (l && (a || o)) {
762
- if (t.view.value = t.view.value.filter((e) => e !== s.id), !this.tryReinsertEntity(t, s, c, i, r)) {
763
- if (t.view.meta && typeof t.view.meta.total == "number") {
764
- if (t.view.meta.total = Math.max(0, t.view.meta.total - 1), i && Number.isFinite(r) && typeof t.view.meta.total == "number") {
765
- let e = r;
766
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
767
- }
768
- this.syncTotalsInSameViews(e, t);
769
- }
770
- if (i && t.view.value.length < r && c) {
771
- let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
772
- if (this.cascadeShiftPages(e, t, n, r, a, c, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
773
- let n = Math.max(1, t.view.meta.totalPages - 1);
774
- t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
775
- }
776
- }
777
- } else if (t.view.meta && typeof t.view.meta.total == "number") {
778
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
779
- let e = r;
780
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
781
- }
782
- this.syncTotalsInSameViews(e, t);
783
- }
784
- t.view.updatedAt = Date.now(), t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
785
- return;
786
- }
787
- if (l) {
788
- t.view.updatedAt = Date.now(), t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
789
- return;
790
- }
791
- if (u && !o) {
792
- if (a && this.strategy.allowSortedInsert && this.strategy.comparator && c) {
793
- if (this.tryInsertSorted(t, s, c) && t.view.meta && typeof t.view.meta.total == "number") {
794
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
795
- let e = r;
796
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
797
- }
798
- this.syncTotalsInSameViews(e, t);
799
- }
800
- } else if (!i || t.view.value.length < r) {
801
- if (t.view.value.push(s.id), t.view.meta && typeof t.view.meta.total == "number") {
802
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
803
- let e = r;
804
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
805
- }
806
- this.syncTotalsInSameViews(e, t);
807
- }
808
- t.view.updatedAt = Date.now();
809
- } else t.view.meta = {
810
- ...t.view.meta ?? {},
811
- stale: !0
812
- };
813
- t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
814
- }
815
- }
816
- handleMove(e, t, n, r, i, a, o, s, c) {
817
- if (t.view.value.includes(o.id)) {
818
- if (t.view.value = t.view.value.filter((e) => e !== o.id), t.view.meta && typeof t.view.meta.total == "number" && (t.view.meta.total = Math.max(0, t.view.meta.total - 1), i && Number.isFinite(r) && typeof t.view.meta.total == "number")) {
819
- let e = r;
820
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
821
- }
822
- if (t.view.updatedAt = Date.now(), i && t.view.value.length < r && c) {
823
- let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
824
- if (this.cascadeShiftPages(e, t, n, r, a, c, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
825
- let n = Math.max(1, t.view.meta.totalPages - 1);
826
- t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
827
- }
828
- }
829
- this.syncTotalsInSameViews(e, t);
830
- }
831
- t.view.loadId = P(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
832
- }
833
- forceInvalidateChildrenViews(e) {
834
- let t = this.parentKey(e ?? null), n = this.views.get(t);
835
- if (n) for (let [, e] of n) e.view.value = void 0, e.view.error = null, e.view.meta = void 0, e.view.promise = null, e.view.updatedAt = 0, e.view.loadId = P(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
836
- }
837
- getKnownTotal(e) {
838
- let t = this.parentKey(e ?? null), n = this.views.get(t);
839
- if (!n) return;
840
- let r = null;
841
- for (let [, e] of n) {
842
- let t = e.view.meta;
843
- t && typeof t.total == "number" && (!r || (e.view.updatedAt ?? 0) > r.updatedAt) && (r = {
844
- total: Number(t.total),
845
- updatedAt: e.view.updatedAt ?? 0
846
- });
847
- }
848
- return r ? r.total : void 0;
849
- }
850
- toJSON() {
851
- return {
852
- views: Array.from(this.views.entries()).map(([e, t]) => [e, Array.from(t.entries())]),
853
- ttl: this.ttl,
854
- errorTtl: this.errorTtl,
855
- entityTtl: this.entityTtl,
856
- strategy: {
857
- allowSortedInsert: this.strategy.allowSortedInsert,
858
- allowSearchInsert: this.strategy.allowSearchInsert,
859
- invalidateOnPaginationFull: this.strategy.invalidateOnPaginationFull,
860
- preloadPagesBefore: this.strategy.preloadPagesBefore,
861
- preloadPagesAfter: this.strategy.preloadPagesAfter
862
- }
863
- };
864
- }
865
- static fromJSON(t) {
866
- let n = new e();
867
- for (let [e, r] of t.views ?? []) {
868
- let t = /* @__PURE__ */ new Map();
869
- for (let [e, n] of r) t.set(e, n);
870
- n.views.set(e, t);
871
- }
872
- return n;
873
- }
874
- }, z = class e {
875
- entities;
876
- views;
877
- ttl;
878
- errorTtl;
879
- childrenCountPromises = /* @__PURE__ */ new Map();
880
- invalidateChildrenCountCache(e) {
881
- let t = A(e ?? "");
882
- this.childrenCountPromises.delete(t);
883
- }
884
- constructor(e = {}, t = 3e5, n = 3e4) {
885
- this.ttl = t, this.errorTtl = n, this.entities = new L(), this.views = new R(e, t, n), this.views.setServerChildrenCountHandler((e, t, n) => {
886
- this.handleServerReportedChildrenCount(e, t, n ?? this.entities);
887
- }), this.views.setChildrenCountInvalidator((e) => {
888
- this.invalidateChildrenCountCache(e);
889
- });
890
- }
891
- getEntity(e) {
892
- return this.entities.getEntity(e) ?? null;
893
- }
894
- getFileSystemItem(e) {
895
- return this.entities.getFileSystemItem(e) ?? null;
896
- }
897
- getFolder(e) {
898
- return this.entities.getFolder(e) ?? null;
899
- }
900
- async getOrCreateChildren(e, t, n) {
901
- return this.views.getOrCreateChildren(e, t, n, this.entities);
902
- }
903
- upsertEntity(e) {
904
- let t = this.entities.getEntity(e.id), n = t ? M(t) : null, r = M(e), i = t ? N(t) : !1, a = N(e);
905
- if (this.entities.upsertEntity(e), t) {
906
- if (n !== r || i !== a) {
907
- this.views.smartInvalidateChildrenViews(n, t, "delete", this.entities), this.views.smartInvalidateChildrenViews(r, e, "insert", this.entities);
908
- return;
909
- }
910
- this.views.smartInvalidateChildrenViews(r, e, "update", this.entities, void 0, t);
911
- } else this.views.smartInvalidateChildrenViews(r, e, "insert", this.entities);
912
- }
913
- isAncestor(e, t) {
914
- let n = t, r = /* @__PURE__ */ new Set();
915
- for (; n && !r.has(n);) {
916
- if (r.add(n), A(n) === A(e)) return !0;
917
- let t = this.entities.getEntity(n);
918
- if (!t) break;
919
- n = M(t), n === null && (n = k);
920
- }
921
- return !1;
922
- }
923
- moveEntity(e, t) {
924
- let n = this.entities.getEntity(e);
925
- if (!n || N(n) && t !== null && this.isAncestor(e, t)) return null;
926
- let r = M(n), i = this.entities.moveEntityById(e, t);
927
- return i ? (this.views.smartInvalidateChildrenViews(r, n, "delete", this.entities), this.views.smartInvalidateChildrenViews(t, i, "insert", this.entities), i) : null;
928
- }
929
- copyEntity(e, t, n, r) {
930
- let i = this.entities.getEntity(e);
931
- if (!i) return null;
932
- let a = null;
933
- if (N(i)) {
934
- let n = [e], i = [];
935
- for (; n.length;) {
936
- let e = n.shift();
937
- i.push(e);
938
- let t = this.entities.getChildrenIds(e, { onlyFolders: !0 });
939
- for (let e of t) n.push(e);
940
- }
941
- let o = /* @__PURE__ */ new Map();
942
- for (let e of i) o.set(e, P());
943
- for (let n of i) {
944
- let i = this.entities.getFolder(n), a = o.get(n), s = M(i), c = s === null ? t : o.get(s) ?? null, l = {
945
- ...i,
946
- ...n === e ? r : void 0,
947
- id: a,
948
- folderId: (n === e ? r?.folderId : void 0) ?? c
949
- };
950
- this.entities.upsertEntity(l);
951
- }
952
- for (let e of i) {
953
- let t = o.get(e), n = this.entities.getChildrenIds(e, { onlyFileSystemItems: !0 });
954
- for (let e of n) {
955
- let n = this.entities.getFileSystemItem(e);
956
- if (!n) continue;
957
- let r = P(), i = {
958
- ...n,
959
- id: r,
960
- folderId: t
961
- };
962
- this.entities.upsertEntity(i);
963
- }
964
- }
965
- a = this.entities.getEntity(o.get(e)) ?? null;
966
- } else {
967
- let i = n ?? P();
968
- if (a = this.entities.copyFileSystemItem(e, i, t ?? null), a && r) {
969
- let e = {
970
- ...a,
971
- ...r,
972
- id: i,
973
- folderId: r.folderId ?? t ?? null
974
- };
975
- this.entities.upsertEntity(e), a = e;
976
- }
977
- }
978
- return a && this.views.smartInvalidateChildrenViews(t, a, "copy", this.entities), a;
979
- }
980
- searchByUrl(e) {
981
- return this.entities.searchByUrl(e) ?? null;
982
- }
983
- deleteEntity(e) {
984
- let t = this.entities.getEntity(e);
985
- if (!t) return null;
986
- if (N(t)) {
987
- let { deletedFolderRecords: n, deletedFileSystemItemRecords: r } = this.entities.deleteFolderRecursive(e);
988
- for (let e of r) this.views.smartInvalidateChildrenViews(e.folderId, e, "delete", this.entities);
989
- for (let e of n) this.views.smartInvalidateChildrenViews(e.folderId, e, "delete", this.entities);
990
- for (let e of n) this.views.forceInvalidateChildrenViews(e.id);
991
- return t;
992
- } else {
993
- let { entity: t, parentId: n } = this.entities.deleteEntityById(e);
994
- return t && this.views.smartInvalidateChildrenViews(n, t, "delete", this.entities), t;
995
- }
996
- }
997
- deleteFolderRecursive(e) {
998
- let { deletedFolderRecords: t, deletedFileSystemItemRecords: n } = this.entities.deleteFolderRecursive(e);
999
- for (let e of n) this.views.smartInvalidateChildrenViews(e.folderId, e, "delete", this.entities);
1000
- for (let e of t) this.views.smartInvalidateChildrenViews(e.folderId, e, "delete", this.entities);
1001
- for (let e of t) this.views.forceInvalidateChildrenViews(e.id);
1002
- return {
1003
- deletedFileSystemItemIds: n.map((e) => e.id),
1004
- deletedFolderIds: t.map((e) => e.id)
1005
- };
1006
- }
1007
- forceInvalidate(e) {
1008
- let t = this.entities.getEntity(e);
1009
- if (!t) return;
1010
- let n = /* @__PURE__ */ new Set();
1011
- if (N(t)) {
1012
- let t = [e];
1013
- for (; t.length;) {
1014
- let e = t.pop();
1015
- if (n.has(e)) continue;
1016
- n.add(e), this.views.forceInvalidateChildrenViews(e);
1017
- let r = this.entities.getChildrenIds(e, { onlyFolders: !0 });
1018
- for (let e of r) t.push(e);
1019
- }
1020
- } else {
1021
- let e = t.folderId ?? null;
1022
- this.views.forceInvalidateChildrenViews(e);
1023
- }
1024
- }
1025
- getChildrenIds(e) {
1026
- return this.entities.getChildrenIds(e);
1027
- }
1028
- searchByName(e, t) {
1029
- return this.entities.searchByName(e, t);
1030
- }
1031
- async getChildrenCount(e = "", t) {
1032
- let n = A(e), r = this.childrenCountPromises.get(n);
1033
- if (r) return r;
1034
- let i = (async () => {
1035
- try {
1036
- let n = this.entities.getFolder(e);
1037
- if (n && typeof n.childrenCount == "number") return n.childrenCount;
1038
- let r = this.views.getKnownTotal(e);
1039
- if (typeof r == "number") return n && this.handleServerReportedChildrenCount(e, r, this.entities), r;
1040
- if (t) {
1041
- let n = await t(e);
1042
- return this.entities.getFolder(e) && this.handleServerReportedChildrenCount(e, n, this.entities), n;
1043
- }
1044
- return this.entities.getChildrenIds(e).length;
1045
- } catch (e) {
1046
- if (this.childrenCountPromises.delete(n), F(e)) return 0;
1047
- throw e;
1048
- } finally {
1049
- this.childrenCountPromises.delete(n);
1050
- }
1051
- })();
1052
- return this.childrenCountPromises.set(n, i), i;
1053
- }
1054
- toJSON() {
1055
- return {
1056
- entities: this.entities.toJSON(),
1057
- views: this.views.toJSON(),
1058
- ttl: this.ttl,
1059
- errorTtl: this.errorTtl
1060
- };
1061
- }
1062
- static fromJSON(t, n) {
1063
- let r = new e(n ?? {}, t?.ttl ?? 3e5, t?.errorTtl ?? 3e4), i = L.fromJSON(t?.entities ?? {}), a = R.fromJSON(t?.views ?? {});
1064
- return n && (a.strategy = {
1065
- allowSortedInsert: n.allowSortedInsert ?? !0,
1066
- allowSearchInsert: n.allowSearchInsert ?? !0,
1067
- invalidateOnPaginationFull: n.invalidateOnPaginationFull ?? !0,
1068
- preloadPagesBefore: n.preloadPagesBefore ?? 0,
1069
- preloadPagesAfter: n.preloadPagesAfter ?? 1,
1070
- comparator: n.comparator,
1071
- filterMatch: n.filterMatch
1072
- }), r.entities = i, r.views = a, a.setServerChildrenCountHandler((e, t, n) => {
1073
- r.handleServerReportedChildrenCount(e, t, n ?? i);
1074
- }), a.setChildrenCountInvalidator((e) => {
1075
- r.invalidateChildrenCountCache(e);
1076
- }), r;
1077
- }
1078
- handleServerReportedChildrenCount(e, t, n) {
1079
- this.checkAndResolveChildrenCountConflict(e, t, n), this.invalidateChildrenCountCache(e);
1080
- }
1081
- checkAndResolveChildrenCountConflict(e, t, n) {
1082
- if (!n || t === void 0) return;
1083
- let r = e ?? null;
1084
- if (!r) {
1085
- n.updateServerChildrenCount(r, t);
1086
- return;
1087
- }
1088
- let i = n.getFolder(r)?.childrenCount;
1089
- i !== void 0 && i !== t && (`${r}${i}${t}`, this.views.forceInvalidateChildrenViews(r)), n.updateServerChildrenCount(r, t);
1090
- }
1091
- }, B = "", V = "Trash", be = "Edited", H = 1e3, U = 10;
1092
- function W(e, t) {
1093
- let n = e ?? {}, r = Array.isArray(n.detailed) ? n.detailed.map((e) => ({
1094
- requestId: e.requestId ?? e.id,
1095
- success: !!e.success,
1096
- data: t(e.data),
1097
- error: e.error
1098
- })) : void 0;
1099
- return {
1100
- success: !!n.success,
1101
- error: n.error,
1102
- detailed: r
1103
- };
1104
- }
1105
- function G(e) {
1106
- return e ? e.replaceAll("\\", "/").split("/").filter(Boolean) : [];
1107
- }
1108
- function K(e) {
1109
- let t = Object.getPrototypeOf(e);
1110
- for (let n of Object.getOwnPropertyNames(t)) n !== "constructor" && typeof Object.getOwnPropertyDescriptor(t, n)?.value == "function" && (e[n] = e[n].bind(e));
1111
- }
1112
- var xe = class {
1113
- _cache;
1114
- _rootId;
1115
- _useSoftDelete;
1116
- _enableTrash;
1117
- _validateDuplicates;
1118
- async _findOrCreateFolderByPath(e) {
1119
- let { __: t } = this.i18n, n = G(e);
1120
- if (n.length > U) throw new T(t("Path depth exceeds maximum limit of %s").replace("%s", String(U)), "ValidationError");
1121
- let r;
1122
- for (let i of n) {
1123
- let { files: n } = await this.getFiles({
1124
- folderId: r?.id || "",
1125
- itemType: "folder"
1126
- }), a = n.find((e) => e.name === i);
1127
- if (a) {
1128
- if (!a.isFolder) throw new T(t("Path component '%s' in '%s' is not a folder").replace("%s", i).replace("%s", e), "ValidationError");
1129
- r = {
1130
- id: a.id,
1131
- name: a.name,
1132
- parentId: a.folderId
1133
- };
1134
- } else {
1135
- if (!this._dataProvider.createFolder) throw new T(t("Create folder operation is not supported by data provider"), "UnsupportedOperation");
1136
- r = await this.createFolder({
1137
- name: i,
1138
- parentId: r?.id
1139
- });
1140
- }
1141
- }
1142
- return r;
1143
- }
1144
- getTrashFolder() {
1145
- return this._findOrCreateFolderByPath(this._pathOptions.trashPath || V);
1146
- }
1147
- getTempFolder() {
1148
- return this._findOrCreateFolderByPath(this._pathOptions.tempPath || be);
1149
- }
1150
- constructor(e, t = {}, n, r = y) {
1151
- this._dataProvider = e, this._options = t, this._pathOptions = n, this.i18n = r, K(this), this._useSoftDelete = this._pathOptions.useSoftDelete, this._rootId = this._pathOptions.rootId || B, this._enableTrash = this._options.enableTrash === void 0 ? !0 : this._options.enableTrash, this._validateDuplicates = this._dataProvider.validateDuplicates, this._cache = new z(t.cacheStrategy || {}, t.cacheStrategy?.ttl, t.cacheStrategy?.errorTtl), this.setController({
1152
- invalidateItemCache: (e) => {
1153
- this._cache.forceInvalidate(e);
1154
- },
1155
- getCachedItem: (e) => this._cache.getEntity(e)
1156
- }), this._dataProvider.clearCache || (this.clearCache = void 0);
1157
- }
1158
- setController(e) {
1159
- this._dataProvider.setController?.(e);
1160
- }
1161
- async clearCache(e) {
1162
- if (!this._dataProvider.clearCache) {
1163
- let { __: e } = this.i18n;
1164
- throw new T(e("Clear cache is not supported by data provider"), "UnsupportedOperation");
1165
- }
1166
- this._cache.forceInvalidate(this._rootId), await this._dataProvider.clearCache(e);
1167
- }
1168
- normalizeId(e) {
1169
- return !e || e === "root" || e === "folders" ? this._rootId : e;
1170
- }
1171
- _validateName(e, t = !1) {
1172
- if (!e || e.trim().length === 0) {
1173
- let e = t ? "FolderInvalidName" : "FileInvalidName", { __: n } = this.i18n;
1174
- throw new T(n(t ? "Folder name cannot be empty" : "File name cannot be empty"), e);
1175
- }
1176
- if (/[\/\\:*?"<>|]/.test(e)) {
1177
- let { __: n } = this.i18n, r = t ? "FolderInvalidName" : "FileInvalidName";
1178
- throw new T(t ? n("Folder name contains invalid characters: %s").replace("%s", e) : n("File name contains invalid characters: %s").replace("%s", e), r);
1179
- }
1180
- }
1181
- _validateTargetFolderType(e) {
1182
- let t = this.normalizeId(e);
1183
- if (t === this._rootId) return;
1184
- let n = this._cache.getEntity(t);
1185
- if (n && !n.isFolder) {
1186
- let { __: t } = this.i18n;
1187
- throw new T(t("Target item with id '%s' is not a folder").replace("%s", e), "ValidationError");
1188
- }
1189
- }
1190
- _checkNameExistsInCache(e, t, n, r) {
1191
- let i = this.normalizeId(e), a = this._cache.getChildrenIds(i);
1192
- for (let e of a) {
1193
- let i = this._cache.getEntity(e);
1194
- if (i && i.name === t && !!i.isFolder === n && (!r || i.id !== r)) return !0;
1195
- }
1196
- return !1;
1197
- }
1198
- async _getUrl(e) {
1199
- if (e.url) return e.url;
1200
- try {
1201
- return this._dataProvider?.getUrl(e) || "";
1202
- } catch {}
1203
- return "";
1204
- }
1205
- async _getThumbnailUrl(e) {
1206
- if (e.thumbnailUrl) return e.thumbnailUrl;
1207
- try {
1208
- return this._dataProvider?.getThumbnailUrl(e) || "";
1209
- } catch {}
1210
- return "";
1211
- }
1212
- _mapItem = async ({ childrenCount: e, ...t }) => {
1213
- if (t.isFolder) return {
1214
- ...t,
1215
- childCount: e,
1216
- url: "",
1217
- thumbnailUrl: ""
1218
- };
1219
- let [n, r] = await Promise.all([this._getUrl(t), this._getThumbnailUrl(t)]);
1220
- return {
1221
- ...t,
1222
- childCount: 0,
1223
- url: n,
1224
- thumbnailUrl: r
1225
- };
1226
- };
1227
- _isAncestor(e, t) {
1228
- if (!t) return !1;
1229
- let n = this.normalizeId(t), r = this.normalizeId(e);
1230
- if (n === r) return !0;
1231
- let i = this._cache.getEntity(n), a = /* @__PURE__ */ new Set();
1232
- for (; i && i.folderId && !a.has(i.id);) {
1233
- a.add(i.id);
1234
- let e = this.normalizeId(i.folderId);
1235
- if (e === r) return !0;
1236
- if (i = this._cache.getEntity(e), !i || !i.isFolder) break;
1237
- }
1238
- return !1;
1239
- }
1240
- async getFile(e, t) {
1241
- return this._cache.searchByName(t, {
1242
- parentId: this.normalizeId(e),
1243
- caseSensitive: !0,
1244
- recursive: !1,
1245
- itemType: "file"
1246
- })[0] || (await this.getFiles({
1247
- folderId: e,
1248
- itemType: "file",
1249
- search: t
1250
- })).files[0];
1251
- }
1252
- async getFileUrl(e, t) {
1253
- let n = await this.getFile(e, t);
1254
- return await this._getUrl(n) || await this._getThumbnailUrl(n) || n.thumbnail;
1255
- }
1256
- async getFiles({ folderId: e, search: t, sortBy: n, sortOrder: r, page: i, limit: a, itemType: o = "all" }) {
1257
- let s = this.normalizeId(e ?? this._rootId), c = this._options.enablePagination === !1, l = c ? 1 : i, u = c ? H : a, d = this._options.clientSideFilter, f = this._options.clientSideSorting, p = this._options.clientSidePaging, m = {
1258
- folderId: s,
1259
- itemType: o
1260
- };
1261
- d || (m.search = t), f || (m.sortBy = n ?? (o === "folder" ? void 0 : "date"), m.sortOrder = r ?? (o === "folder" ? void 0 : "desc")), p || (m.page = l, m.limit = u);
1262
- let h = {
1263
- folderId: s,
1264
- itemType: o,
1265
- search: d ? void 0 : t,
1266
- sortBy: f ? void 0 : m.sortBy,
1267
- sortOrder: f ? void 0 : m.sortOrder,
1268
- page: p ? void 0 : l,
1269
- pageSize: p ? void 0 : u
1270
- }, g = await this._cache.getOrCreateChildren(s, h, async (e, t) => {
1271
- let n = await this._dataProvider.getItems({
1272
- ...t,
1273
- folderId: e,
1274
- limit: Number(t.pageSize)
1275
- });
1276
- return {
1277
- items: n.items,
1278
- ...n.pagination
1279
- };
1280
- }), _ = g.items;
1281
- if (d) {
1282
- if (typeof this._options.clientSideFilter == "function") _ = this._options.clientSideFilter(_, t);
1283
- else if (t) {
1284
- let e = t.toLowerCase();
1285
- _ = _.filter((t) => t.name?.toLowerCase().includes(e));
1286
- }
1287
- }
1288
- f && (_ = typeof this._options.clientSideSorting == "function" ? this._options.clientSideSorting(_, n, r) : this._defaultClientSideSort(_, n, r));
1289
- let v;
1290
- v = p || d ? _.length : g.total;
1291
- let y = _;
1292
- if (p && i && a) if (typeof this._options.clientSidePaging == "function") y = this._options.clientSidePaging(_, i, a);
1293
- else {
1294
- let e = (i - 1) * a, t = e + a;
1295
- y = _.slice(e, t);
1296
- }
1297
- if (this._dataProvider.getUrl || this._dataProvider.getThumbnailUrl) {
1298
- let e = y.map(async (e) => {
1299
- if (e.isFolder) return e;
1300
- let [t, n] = await Promise.all([e.url ? Promise.resolve(e.url) : this._dataProvider.getUrl ? this._dataProvider.getUrl(e) : Promise.resolve(void 0), e.thumbnailUrl ? Promise.resolve(e.thumbnailUrl) : this._dataProvider.getThumbnailUrl ? this._dataProvider.getThumbnailUrl(e) : Promise.resolve(void 0)]);
1301
- return {
1302
- ...e,
1303
- url: t,
1304
- thumbnailUrl: n
1305
- };
1306
- });
1307
- y = await Promise.all(e);
1308
- }
1309
- let b = {
1310
- page: l,
1311
- limit: u,
1312
- total: v,
1313
- ...!p && g.totalPages && { totalPages: g.totalPages },
1314
- ...!p && g.hasNextPage && { hasNextPage: g.hasNextPage }
1315
- };
1316
- return {
1317
- files: await Promise.all(y.map(this._mapItem)),
1318
- pagination: b
1319
- };
1320
- }
1321
- _defaultClientSideSort(e, t, n) {
1322
- return e.sort((e, r) => {
1323
- let i = 0;
1324
- switch (t) {
1325
- case "name":
1326
- i = (e.name || "").localeCompare(r.name || "");
1327
- break;
1328
- case "date":
1329
- i = new Date(e.date || 0).getTime() - new Date(r.date || 0).getTime();
1330
- break;
1331
- case "size":
1332
- i = (Number(e.size) || 0) - (Number(r.size) || 0);
1333
- break;
1334
- default: i = (e.name || "").localeCompare(r.name || "");
1335
- }
1336
- return n === "desc" ? -i : i;
1337
- });
1338
- }
1339
- async getFileData(e) {
1340
- let t = this.normalizeId(typeof e == "string" ? e : e.id), n = this._cache.getEntity(t) || (typeof e == "string" ? {
1341
- id: t,
1342
- name: "",
1343
- folderId: this._rootId,
1344
- isFolder: !1
1345
- } : {
1346
- ...e,
1347
- childrenCount: e.childCount
1348
- });
1349
- if (this._dataProvider.getFileData) return await this._dataProvider.getFileData(n);
1350
- let { __: r } = this.i18n;
1351
- if (!n.url && !this._dataProvider.getUrl) throw new T(r("Cannot read file"), "FileReadError");
1352
- let i = n.url || await this._dataProvider.getUrl(n);
1353
- if (i) return (await fetch(i)).blob();
1354
- throw new T(r("Unable to get file data"), "FileReadError");
1355
- }
1356
- async findFileByUrl(e) {
1357
- let t = this._cache.searchByUrl(e);
1358
- if (t) return t;
1359
- if (this._dataProvider.findFileByUrl) try {
1360
- let t = await this._dataProvider.findFileByUrl(e);
1361
- if (t) return this._cache.upsertEntity(t), t;
1362
- } catch {}
1363
- return null;
1364
- }
1365
- async getChildrenCount(e) {
1366
- if (!e) return 0;
1367
- let t = this.normalizeId(e ?? this._rootId);
1368
- return this._cache.getChildrenCount(t, async () => {
1369
- try {
1370
- let e = await this._dataProvider.getItems({
1371
- folderId: t,
1372
- limit: 0,
1373
- itemType: "all"
1374
- });
1375
- return e.pagination === void 0 ? this._options.enablePagination === !1 ? e.items.length : 0 : e.pagination.total || 0;
1376
- } catch (e) {
1377
- if (this._isPathFolderNotFoundError(e)) return 0;
1378
- throw e;
1379
- }
1380
- });
1381
- }
1382
- _isPathFolderNotFoundError(e) {
1383
- if (!e || typeof e != "object") return !1;
1384
- let t = e;
1385
- return t.code === "path_folder_not_found" || t.data?.code === "path_folder_not_found" || t.status === 404 || t.data?.data?.status === 404;
1386
- }
1387
- async _uploadFile(e) {
1388
- let t = this.normalizeId(e.folderId ?? this._rootId);
1389
- if (this._validateName(e.name, !1), this._validateDuplicates && this._checkNameExistsInCache(t, e.name, !1)) {
1390
- let { __: t } = this.i18n;
1391
- throw new T(t("File '%s' already exists in target folder").replace("%s", e.name), "FileAlreadyExists");
1392
- }
1393
- let n = this._cache.getEntity(t), r = await this._dataProvider.uploadFile({
1394
- ...e,
1395
- folderId: t
1396
- }), i = {
1397
- ...n,
1398
- ...r,
1399
- folderId: t
1400
- };
1401
- return this._cache.upsertEntity(i), i;
1402
- }
1403
- async uploadFiles(e) {
1404
- let t = await this.getTempFolder();
1405
- e = {
1406
- ...e,
1407
- items: e.items?.map((e) => ({
1408
- ...e,
1409
- folderId: e.noFolder ? t?.id : e.folderId
1410
- }))
1411
- };
1412
- let n = e.items || [], r = e.folderId ?? this._rootId, i = this.normalizeId(r);
1413
- if (this._validateDuplicates) {
1414
- for (let e of n) if (e.name) {
1415
- this._validateName(e.name, !1);
1416
- let t = this.normalizeId(e.folderId ?? i);
1417
- if (this._checkNameExistsInCache(t, e.name, !1)) {
1418
- let { __: t } = this.i18n;
1419
- throw new T(t("File '%s' already exists in target folder").replace("%s", e.name), "FileAlreadyExists");
1420
- }
1421
- }
1422
- }
1423
- let a = this._cache.getEntity(i), o = {
1424
- detailed: Array(n.length),
1425
- success: !0
1426
- };
1427
- if (this._dataProvider.uploadFiles) {
1428
- let e = n.map((e) => ({
1429
- ...e,
1430
- folderId: this.normalizeId(e.folderId ?? i)
1431
- }));
1432
- if (o = W(await this._dataProvider.uploadFiles({
1433
- folderId: i,
1434
- items: e
1435
- }), (e) => {
1436
- if (e) return {
1437
- id: e.id,
1438
- name: e.name,
1439
- folderId: e.folderId
1440
- };
1441
- }), o.detailed && o.detailed.length) {
1442
- for (let e = 0; e < o.detailed.length; e++) {
1443
- let t = o.detailed[e];
1444
- if (t && t.success) {
1445
- let e = t.data, n = e?.id ?? t.requestId, r = {
1446
- ...a,
1447
- ...e,
1448
- folderId: e?.folderId ?? i
1449
- };
1450
- this._cache.upsertEntity(r), t.requestId = n;
1451
- }
1452
- }
1453
- o.success === void 0 && (o.success = !o.detailed.some((e) => !e.success));
1454
- } else o.success = o.error ? !1 : !!o.success;
1455
- } else if (this._dataProvider.uploadFile) o.detailed = await Promise.all(n.map(async (e) => {
1456
- let t = this.normalizeId(e.folderId ?? i);
1457
- try {
1458
- let n = await this._uploadFile({
1459
- ...e,
1460
- folderId: t
1461
- });
1462
- return {
1463
- requestId: n.id,
1464
- data: n,
1465
- success: !0
1466
- };
1467
- } catch (t) {
1468
- return {
1469
- requestId: e?.id,
1470
- success: !1,
1471
- error: t
1472
- };
1473
- }
1474
- })), o.success = !o.detailed.some((e) => !e.success);
1475
- else throw new T("Upload files is not supported by data provider", "UnsupportedOperation");
1476
- if (o.success && this._enableTrash) try {
1477
- this._cache.forceInvalidate(i);
1478
- } catch {}
1479
- return o;
1480
- }
1481
- async deleteFile(e) {
1482
- let t = this.normalizeId(e);
1483
- if (this._useSoftDelete && this._enableTrash) {
1484
- let e = await this.getTrashFolder();
1485
- return await this.moveItem({
1486
- itemId: t,
1487
- targetFolderId: e.id,
1488
- isFolder: !1
1489
- });
1490
- }
1491
- return await this.hardDeleteItem(t);
1492
- }
1493
- async deleteItems(e, t) {
1494
- if (this._useSoftDelete && this._enableTrash && t.permanent !== !0) {
1495
- let t = await this.getTrashFolder();
1496
- return await this.moveItems(t.id, e);
1497
- }
1498
- return await this.hardDeleteItems(e, t);
1499
- }
1500
- async hardDeleteItems(e, t) {
1501
- let n = {
1502
- success: !0,
1503
- detailed: []
1504
- }, r = t.permanent ? null : await this.getTrashFolder();
1505
- if (this._dataProvider.deleteItems) {
1506
- if (n = W(await this._dataProvider.deleteItems(e.map((e) => this._cache.getEntity(e)), t), (e) => e), n.success) {
1507
- let t = n.detailed || e.map((e) => ({
1508
- requestId: e,
1509
- success: !0,
1510
- error: void 0
1511
- }));
1512
- for (let e of t) e.success && (r ? this._cache.moveEntity(e.requestId, r.id) : this._cache.deleteEntity(e.requestId));
1513
- }
1514
- } else this._dataProvider.deleteItem && (n.detailed = await Promise.all(e.map(async (e) => {
1515
- let n = this._cache.getEntity(e);
1516
- if (!n) {
1517
- let { __: t } = this.i18n;
1518
- return {
1519
- requestId: e,
1520
- success: !1,
1521
- error: new T(t("Item with id '%s' not found").replace("%s", e), "FileNotFound")
1522
- };
1523
- }
1524
- try {
1525
- return await this._dataProvider.deleteItem(n, t), r ? this._cache.moveEntity(e, r.id) : this._cache.deleteEntity(e), {
1526
- requestId: e,
1527
- success: !0
1528
- };
1529
- } catch (t) {
1530
- return {
1531
- requestId: e,
1532
- error: t,
1533
- success: !1
1534
- };
1535
- }
1536
- })), n.success = !n.detailed.some((e) => !e.success));
1537
- if (n.success && r) try {
1538
- this._cache.forceInvalidate(r.id);
1539
- } catch {}
1540
- return n;
1541
- }
1542
- async hardDeleteItem(e) {
1543
- let t = this._cache.getEntity(e);
1544
- if (!t) {
1545
- let { __: t } = this.i18n;
1546
- throw new T(t("Item with id '%s' not found in cache").replace("%s", e), "FileNotFound");
1547
- }
1548
- if (await this._dataProvider.deleteItem(t, { permanent: !0 }), this._cache.deleteEntity(e), this._enableTrash) try {
1549
- let e = await this.getTrashFolder();
1550
- e && this._cache.forceInvalidate(e.id);
1551
- } catch {}
1552
- return !0;
1553
- }
1554
- async cleanTrash() {
1555
- let { __: e } = this.i18n;
1556
- if (!this._enableTrash) throw new T(e("Trash is not enabled"), "UnsupportedOperation");
1557
- if (this._dataProvider.cleanTrash) {
1558
- let e = await this._dataProvider.cleanTrash();
1559
- try {
1560
- let e = await this.getTrashFolder();
1561
- e && this._cache.forceInvalidate(e.id);
1562
- } catch {}
1563
- return e;
1564
- }
1565
- throw new T(e("Clean trash is not supported by data provider"), "UnsupportedOperation");
1566
- }
1567
- async createFolder({ name: e, parentId: t, is_force_create: n }) {
1568
- let r = this.normalizeId(t ?? this._rootId);
1569
- if (this._validateName(e, !0), this._validateDuplicates && this._checkNameExistsInCache(r, e, !0)) {
1570
- let { __: t } = this.i18n;
1571
- throw new T(t("Folder '%s' already exists in parent folder").replace("%s", e), "FolderAlreadyExists");
1572
- }
1573
- let i = await this._dataProvider.createFolder(e, r, n);
1574
- return this._cache.upsertEntity({
1575
- id: i.id,
1576
- folderId: r,
1577
- name: i.name,
1578
- isFolder: !0,
1579
- childrenCount: i.childrenCount
1580
- }), i;
1581
- }
1582
- async deleteFolder(e) {
1583
- let t = this.normalizeId(e);
1584
- if (this._useSoftDelete && this._enableTrash) try {
1585
- let e = await this.getTrashFolder();
1586
- return await this.moveItem({
1587
- itemId: t,
1588
- targetFolderId: e.id,
1589
- isFolder: !0
1590
- }) ? (this._cache.deleteFolderRecursive(t), !0) : !1;
1591
- } catch (e) {
1592
- return console.error("Error moving folder to trash:", e), await this.hardDeleteItem(t);
1593
- }
1594
- return await this.hardDeleteItem(t);
1595
- }
1596
- async renameFolder(e, t) {
1597
- let { __: n } = this.i18n;
1598
- if (!this._dataProvider.renameItem) throw new T(n("Rename folder is not supported"), "RenameNotAllowed");
1599
- let r = this.normalizeId(e), i = this._cache.getEntity(r);
1600
- if (!i) throw new T(n("Folder with id '%s' not found in cache").replace("%s", e), "FolderNotFound");
1601
- if (this._validateName(t, !0), this._validateDuplicates) {
1602
- let e = this.normalizeId(i.folderId);
1603
- if (this._checkNameExistsInCache(e, t, !0, r)) throw new T(n("Folder '%s' already exists in parent folder").replace("%s", t), "FolderAlreadyExists");
1604
- }
1605
- let a = await this._dataProvider.renameItem(i, t);
1606
- return this._cache.upsertEntity({
1607
- ...this._cache.getEntity(a.id),
1608
- ...a
1609
- }), this._cache.getEntity(a.id);
1610
- }
1611
- async renameFile(e, t) {
1612
- let { __: n } = this.i18n;
1613
- if (!this._dataProvider.renameItem) throw new T(n("Rename file is not supported"), "RenameNotAllowed");
1614
- let r = this._cache.getEntity(e);
1615
- if (!r) throw new T(n("File with id '%s' not found in cache").replace("%s", e), "FileNotFound");
1616
- let i = this.normalizeId(e);
1617
- if (this._validateName(t, !1), this._validateDuplicates) {
1618
- let e = this.normalizeId(r.folderId);
1619
- if (this._checkNameExistsInCache(e, t, !1, i)) throw new T(n("File '%s' already exists in parent folder").replace("%s", t), "FileAlreadyExists");
1620
- }
1621
- let a = await this._dataProvider.renameItem(r, t);
1622
- return a && this._cache.upsertEntity({
1623
- ...this._cache.getEntity(i),
1624
- ...a
1625
- }), this._cache.getEntity(i);
1626
- }
1627
- async moveItem({ itemId: e, targetFolderId: t, isFolder: n }) {
1628
- let r = this.normalizeId(t);
1629
- this._validateTargetFolderType(t);
1630
- let i = this._cache.getEntity(e);
1631
- if (!i) {
1632
- let t = await this._dataProvider.moveItem({
1633
- id: e,
1634
- folderId: r,
1635
- isFolder: n
1636
- }, r);
1637
- if (t.id === e) this._cache.upsertEntity({
1638
- ...t,
1639
- folderId: r
1640
- });
1641
- else {
1642
- try {
1643
- this._cache.deleteEntity(e);
1644
- } catch {}
1645
- this._cache.upsertEntity({
1646
- ...t,
1647
- folderId: r
1648
- });
1649
- }
1650
- return !0;
1651
- }
1652
- let { __: a } = this.i18n;
1653
- if (i.isFolder) {
1654
- if (e === r) throw new T(a("Cannot move folder into itself"), "MoveIntoSelf");
1655
- if (this._isAncestor(e, r)) throw new T(a("Cannot move folder into its descendant"), "MoveIntoDescendant");
1656
- }
1657
- if (this._validateDuplicates && r !== this.normalizeId(i.folderId) && i.name && this._checkNameExistsInCache(r, i.name, !!i.isFolder, e)) {
1658
- let e = i.isFolder ? "FolderAlreadyExists" : "FileAlreadyExists";
1659
- throw new T(`${i.isFolder ? "Folder" : "File"} '${i.name}' already exists in target folder`, e);
1660
- }
1661
- let o = await this._dataProvider.moveItem(i, r);
1662
- if (o.id === e) {
1663
- let t = this._cache.moveEntity(e, r);
1664
- return this._cache.upsertEntity({
1665
- ...t,
1666
- ...o
1667
- }), !0;
1668
- } else {
1669
- let t = this._cache.deleteEntity(e);
1670
- return this._cache.upsertEntity({
1671
- ...t,
1672
- ...o,
1673
- folderId: r
1674
- }), !0;
1675
- }
1676
- }
1677
- async moveItems(e, t) {
1678
- let n = this.normalizeId(e);
1679
- this._validateTargetFolderType(e);
1680
- let r = t.map((e) => this._cache.getEntity(e));
1681
- for (let e of r) if (e) {
1682
- if (e.isFolder) {
1683
- let { __: t } = this.i18n;
1684
- if (e.id === n) throw new T(t("Cannot move folder '%s' into itself").replace("%s", e.name), "MoveIntoSelf");
1685
- if (this._isAncestor(e.id, n)) throw new T(t("Cannot move folder '%s' into its descendant").replace("%s", e.name), "MoveIntoDescendant");
1686
- }
1687
- if (this._validateDuplicates && n !== this.normalizeId(e.folderId) && e.name && this._checkNameExistsInCache(n, e.name, !!e.isFolder, e.id)) {
1688
- let t = e.isFolder ? "FolderAlreadyExists" : "FileAlreadyExists";
1689
- throw new T(`${e.isFolder ? "Folder" : "File"} '${e.name}' already exists in target folder`, t);
1690
- }
1691
- }
1692
- let i = {
1693
- detailed: Array(r.length),
1694
- success: !0
1695
- };
1696
- if (this._dataProvider.moveItems) i = W(await this._dataProvider.moveItems(r, n), (e) => e);
1697
- else if (this._dataProvider.moveItem) i.detailed = await Promise.all(t.map(async (e, t) => {
1698
- let i = r[t] || {
1699
- id: e,
1700
- folderId: null,
1701
- isFolder: !1,
1702
- name: e
1703
- };
1704
- try {
1705
- return {
1706
- requestId: e,
1707
- data: await this._dataProvider.moveItem(i, n),
1708
- success: !0
1709
- };
1710
- } catch (t) {
1711
- return {
1712
- requestId: e,
1713
- success: !1,
1714
- error: t
1715
- };
1716
- }
1717
- }));
1718
- else throw new T("Move items is not supported", "MoveNotAllowed");
1719
- if (i.success) {
1720
- let e = i.detailed || t.map((e) => ({
1721
- requestId: e,
1722
- success: !0,
1723
- data: void 0
1724
- }));
1725
- for (let t of e) if (t.success) if (!t.data || t.data.id === t.requestId) this._cache.moveEntity(t.requestId, n), t.data && this._cache.upsertEntity({
1726
- ...this._cache.getEntity(t.requestId),
1727
- ...t.data,
1728
- folderId: n
1729
- });
1730
- else {
1731
- let e = this._cache.deleteEntity(t.requestId);
1732
- this._cache.upsertEntity({
1733
- ...e,
1734
- ...t.data,
1735
- folderId: n
1736
- });
1737
- }
1738
- return i;
1739
- } else {
1740
- let { __: e } = this.i18n;
1741
- return {
1742
- success: !1,
1743
- error: i.error || new T(e("Move items failed"), "MoveNotAllowed")
1744
- };
1745
- }
1746
- }
1747
- async copyItem({ itemId: e, targetFolderId: t }) {
1748
- if (!this._dataProvider.copyItem) {
1749
- let { __: e } = this.i18n;
1750
- throw new T(e("Copy item is not supported"), "CopyNotAllowed");
1751
- }
1752
- let n = this.normalizeId(t);
1753
- this._validateTargetFolderType(t);
1754
- let r = this._cache.getEntity(e);
1755
- if (!r) {
1756
- let t = await this._dataProvider.copyItem({
1757
- id: e,
1758
- folderId: n
1759
- }, n);
1760
- return this._cache.copyEntity(e, n, t.id), this._cache.upsertEntity({
1761
- ...t,
1762
- folderId: n
1763
- }), !0;
1764
- }
1765
- if (this._validateDuplicates && r.name) {
1766
- let t = n === this.normalizeId(r.folderId) ? e : void 0;
1767
- if (this._checkNameExistsInCache(n, r.name, !!r.isFolder, t)) {
1768
- let e = r.isFolder ? "FolderAlreadyExists" : "FileAlreadyExists";
1769
- throw new T(`${r.isFolder ? "Folder" : "File"} '${r.name}' already exists in target folder`, e);
1770
- }
1771
- }
1772
- let i = await this._dataProvider.copyItem(r, n);
1773
- return this._cache.copyEntity(e, n, i.id, {
1774
- ...i,
1775
- folderId: n
1776
- }) || this._cache.upsertEntity({
1777
- ...i,
1778
- folderId: n
1779
- }), !0;
1780
- }
1781
- async copyItems(e, t) {
1782
- let n = this.normalizeId(e);
1783
- this._validateTargetFolderType(e);
1784
- let r = t.map((e) => typeof e == "string" ? { id: e } : e), i = r.map((e) => e.id), a = i.map((e, t) => {
1785
- let n = this._cache.getEntity(e), i = r[t]?.newName;
1786
- return n ? i ? {
1787
- ...n,
1788
- name: i
1789
- } : n : void 0;
1790
- });
1791
- if (this._validateDuplicates) for (let e = 0; e < a.length; e++) {
1792
- let t = a[e];
1793
- if (t && t.name) {
1794
- let r = n === this.normalizeId(t.folderId) ? i[e] : void 0;
1795
- if (this._checkNameExistsInCache(n, t.name, !!t.isFolder, r)) {
1796
- let e = t.isFolder ? "FolderAlreadyExists" : "FileAlreadyExists";
1797
- throw new T(`${t.isFolder ? "Folder" : "File"} '${t.name}' already exists in target folder`, e);
1798
- }
1799
- }
1800
- }
1801
- let o = {
1802
- detailed: Array(a.length),
1803
- success: !0
1804
- };
1805
- if (this._dataProvider.copyItems) o = W(await this._dataProvider.copyItems(a, n), (e) => e);
1806
- else if (this._dataProvider.copyItem) o.detailed = await Promise.all(i.map(async (e, t) => {
1807
- let r = a[t] || {
1808
- id: e,
1809
- folderId: null,
1810
- isFolder: !1
1811
- };
1812
- try {
1813
- return {
1814
- requestId: e,
1815
- data: await this._dataProvider.copyItem(r, n),
1816
- success: !0
1817
- };
1818
- } catch (t) {
1819
- return {
1820
- requestId: e,
1821
- success: !1,
1822
- error: t
1823
- };
1824
- }
1825
- }));
1826
- else {
1827
- let { __: e } = this.i18n;
1828
- throw new T(e("Copy items is not supported"), "CopyNotAllowed");
1829
- }
1830
- if (o.success && o.detailed) for (let e = 0, t = o.detailed.length; e < t; e++) {
1831
- let t = o.detailed[e];
1832
- if (t.success) if (t.data?.id) {
1833
- let e = t.data.folderId || n;
1834
- !this._cache.copyEntity(t.requestId, e, t.data.id, {
1835
- ...t.data,
1836
- folderId: e
1837
- }) && t.data && this._cache.upsertEntity({
1838
- ...t.data,
1839
- folderId: e
1840
- });
1841
- } else console.error("batchResult in copy method must have ids");
1842
- }
1843
- else if (!o.detailed) throw new T("batchResult in copy method must have detailed results", "ValidationError");
1844
- return o;
1845
- }
1846
- async uploadFileByUrl(e) {
1847
- if (e.noFolder) {
1848
- let t = await this.getTempFolder();
1849
- e = {
1850
- ...e,
1851
- folderId: t.id
1852
- };
1853
- }
1854
- let t = this.normalizeId(e.folderId ?? this._rootId);
1855
- try {
1856
- let n = await this._dataProvider.uploadFileByUrl(e.url, t, { eventSource: e.eventSource });
1857
- return this._cache.upsertEntity({
1858
- ...n,
1859
- folderId: t
1860
- }), n;
1861
- } catch (e) {
1862
- throw console.error("uploadFileByUrl error:", e), e;
1863
- }
1864
- }
1865
- async updateFile(e, t) {
1866
- let { __: n } = this.i18n;
1867
- if (!this._dataProvider.updateFile) throw new T(n("Update file is not supported"), "UnsupportedOperation");
1868
- let r = this.normalizeId(e), i = this._cache.getEntity(r);
1869
- if (!i) throw new T(n("File with id '%s' not found in cache").replace("%s", e), "FileNotFound");
1870
- if (t.name && t.name !== i.name && this._validateName(t.name, !1), this._validateDuplicates && t.name && t.name !== i.name) {
1871
- let e = this.normalizeId(i.folderId);
1872
- if (this._checkNameExistsInCache(e, t.name, !1, r)) throw new T(n("File '%s' already exists in parent folder").replace("%s", t.name), "FileAlreadyExists");
1873
- }
1874
- let a = await this._dataProvider.updateFile(i, { ...t });
1875
- return this._cache.upsertEntity({
1876
- ...this._cache.getEntity(r),
1877
- ...a,
1878
- ...t
1879
- }), this._cache.getEntity(r);
1880
- }
1881
- }, q = (/* @__PURE__ */ t(((e) => {
1882
- var t = window.__emailmaker__.modules.Uuid;
1883
- Object.keys(t).forEach(function(n) {
1884
- n !== "default" && n !== "__esModule" && (e[n] = t[n]);
1885
- }), e.__esModule = !0, e.default = t.default === void 0 ? t : t.default;
1886
- })))(), J = "", Y = "Trash", X = "Trash", Se = class {
1887
- _pathToId = /* @__PURE__ */ new Map();
1888
- _idToPath = /* @__PURE__ */ new Map();
1889
- getUrl;
1890
- getThumbnailUrl;
1891
- validateDuplicates;
1892
- constructor(e, t = J, n = X, r = Y, i = !0, a = y) {
1893
- this._inner = e, this.rootPath = t, this.trashId = n, this.trashPath = r, this.ensureFolderTrailingSlash = i, this.i18n = a, this.validateDuplicates = this._inner.validateDuplicates, e.getUrl && (this.getUrl = (t) => e.getUrl({
1894
- ...t,
1895
- id: this.pathForId(t.id, !1),
1896
- folderId: t.folderId ? this.pathForId(t.folderId, !0) : this.rootPath
1897
- })), e.getThumbnailUrl && (this.getThumbnailUrl = (t) => e.getThumbnailUrl({
1898
- ...t,
1899
- id: this.pathForId(t.id, !1),
1900
- folderId: t.folderId ? this.pathForId(t.folderId, !0) : this.rootPath
1901
- })), this._inner.deleteItems || (this.deleteItems = void 0), this._inner.deleteItem || (this.deleteItem = void 0), this._inner.moveItems ? this.moveItem = void 0 : this.moveItems = void 0, this._inner.copyItems ? this.copyItem = void 0 : this.copyItems = void 0, this._inner.uploadFiles ? this.uploadFile = void 0 : this.uploadFiles = void 0, this._inner.clearCache || (this.clearCache = void 0), this._getOrGenerateId(this.rootPath);
1902
- }
1903
- setController(e) {
1904
- this._inner.setController?.({
1905
- invalidateItemCache: (t) => {
1906
- let n = t.replace(/^\/+|\/+$/g, ""), r = this._pathToId.get(n);
1907
- r && e.invalidateItemCache(r);
1908
- },
1909
- getCachedItem: (t) => {
1910
- let n = t.replace(/^\/+|\/+$/g, ""), r = this._pathToId.get(n);
1911
- if (r) {
1912
- let t = e.getCachedItem(r);
1913
- if (t) return {
1914
- ...t,
1915
- id: this.pathForId(t.id, t.isFolder),
1916
- folderId: this.pathForId(t.folderId, t.isFolder)
1917
- };
1918
- }
1919
- }
1920
- });
1921
- }
1922
- clearCache(e) {
1923
- if (this._inner.clearCache) return this._inner.clearCache(e);
1924
- }
1925
- _getOrGenerateId(e) {
1926
- if (e === this.rootPath) return;
1927
- let t = e.replaceAll(/^\/+|\/+$/g, "");
1928
- if (t === this.trashPath.replaceAll(/^\/+|\/+$/g, "")) return this.trashId;
1929
- if (this._pathToId.has(t)) return this._pathToId.get(t);
1930
- let n = (0, q.v4)();
1931
- return this._pathToId.set(t, n), this._idToPath.set(n, t), n;
1932
- }
1933
- pathForId(e, t, n) {
1934
- let { __: r } = this.i18n;
1935
- if (e === "" || e === void 0) return this.rootPath;
1936
- if (e === this.trashId) return this.trashPath;
1937
- let i = this._idToPath.get(e);
1938
- if (!i) {
1939
- if (n) return `unknown folder ${e}`;
1940
- throw new T(r ? r(`Path for id '${e}' not found in mapping`) : `Path for id '${e}' not found in mapping`, "FileNotFound");
1941
- }
1942
- let a = 0;
1943
- for (; a < this.rootPath.length && this.rootPath[a] === "/";) a++;
1944
- if (a) {
1945
- let e = 0;
1946
- for (; e < i.length && i[e] === "/";) e++;
1947
- let t = i.slice(e);
1948
- i = "/".repeat(a) + t;
1949
- }
1950
- return t && this.ensureFolderTrailingSlash && !i.endsWith("/") && (i += "/"), i;
1951
- }
1952
- _updateIdMapping(e, t) {
1953
- let n = t.replace(/^\/+|\/+$/g, ""), r = this._idToPath.get(e);
1954
- r && this._pathToId.delete(r), this._idToPath.set(e, n), this._pathToId.set(n, e);
1955
- }
1956
- async getItems(e) {
1957
- let t = e.folderId ? this.pathForId(e.folderId, !0) : this.rootPath, n = await this._inner.getItems({
1958
- ...e,
1959
- folderId: t
1960
- }), r = n.items.map((e) => {
1961
- let t = this._getOrGenerateId(e.id), n = e.folderId ? this._getOrGenerateId(e.folderId) : this._getOrGenerateId(this.rootPath);
1962
- return {
1963
- ...e,
1964
- id: t,
1965
- folderId: n
1966
- };
1967
- });
1968
- return {
1969
- ...n,
1970
- items: r
1971
- };
1972
- }
1973
- async createFolder(e, t, n) {
1974
- let r = t ? this.pathForId(t, !0) : this.rootPath, i = await this._inner.createFolder(e, r, n), a = this._getOrGenerateId(i.id), o = i.folderId ? this._getOrGenerateId(i.folderId) : this._getOrGenerateId(this.rootPath);
1975
- return {
1976
- ...i,
1977
- id: a,
1978
- folderId: o
1979
- };
1980
- }
1981
- async renameItem(e, t) {
1982
- let { __: n } = this.i18n;
1983
- if (!this._inner.renameItem) throw new T(n ? n("Rename item is not supported by inner storage") : "Rename item is not supported by inner storage", "RenameNotAllowed");
1984
- let r = this.pathForId(e.id, e.isFolder), i = r, { ...a } = await this._inner.renameItem({
1985
- ...e,
1986
- id: r,
1987
- folderId: this.pathForId(e.folderId, !0)
1988
- }, t);
1989
- return this._updateIdMapping(e.id, a.id), e.isFolder && this.remapCachedFolderContents(e.id, i, a.id), a.folderId && (a = {
1990
- ...a,
1991
- folderId: this._getOrGenerateId(a.folderId)
1992
- }), {
1993
- ...a,
1994
- id: this._getOrGenerateId(a.id)
1995
- };
1996
- }
1997
- async deleteItem(e, t) {
1998
- let n = this.pathForId(e.id, e.isFolder);
1999
- await this._inner.deleteItem({
2000
- ...e,
2001
- id: n,
2002
- folderId: this.pathForId(e.folderId, !0)
2003
- }, t), this.recursivelyRemoveMappings(e.id, n);
2004
- }
2005
- async uploadFile(e) {
2006
- let t = e.folderId ? this.pathForId(e.folderId, !0) : this.rootPath, n = await this._inner.uploadFile({
2007
- ...e,
2008
- folderId: t
2009
- }), r = this._getOrGenerateId(n.id), i = n.folderId ? this._getOrGenerateId(n.folderId) : this._getOrGenerateId(this.rootPath);
2010
- return {
2011
- ...n,
2012
- id: r,
2013
- folderId: i
2014
- };
2015
- }
2016
- async uploadFiles(e) {
2017
- let t = e.folderId, n = e.items?.map((e) => e.folderId) ?? [], r = e.folderId ? this.pathForId(e.folderId, !0) : this.rootPath, i = {
2018
- ...e,
2019
- folderId: r,
2020
- items: e.items?.map((e) => ({
2021
- ...e,
2022
- folderId: e.folderId ? this.pathForId(e.folderId, !0) : r
2023
- })) ?? []
2024
- }, a = await this._inner.uploadFiles(i);
2025
- return {
2026
- ...a,
2027
- detailed: a.detailed?.map((e, r) => {
2028
- if (!e?.data) return e;
2029
- let i = e.data.id ? this._getOrGenerateId(e.data.id) : void 0, a = e.data.folderId ? this._getOrGenerateId(e.data.folderId) : n[r] ?? t ?? this._getOrGenerateId(this.rootPath);
2030
- return {
2031
- ...e,
2032
- data: {
2033
- ...e.data,
2034
- id: i,
2035
- folderId: a
2036
- }
2037
- };
2038
- })
2039
- };
2040
- }
2041
- async findFileByUrl(e, t) {
2042
- let n = t ? this.pathForId(t, !0) : this.rootPath;
2043
- if (this._inner.findFileByUrl) {
2044
- let t = await this._inner.findFileByUrl(e, n);
2045
- if (!t) return;
2046
- let r = this._getOrGenerateId(t.id), i = t.folderId ? this._getOrGenerateId(t.folderId) : this._getOrGenerateId(this.rootPath);
2047
- return {
2048
- ...t,
2049
- id: r,
2050
- folderId: i
2051
- };
2052
- }
2053
- }
2054
- async uploadFileByUrl(e, t, n) {
2055
- let r = t ? this.pathForId(t, !0) : this.rootPath, i = await this._inner.uploadFileByUrl(e, r, n), a = this._getOrGenerateId(i.id), o = i.folderId ? this._getOrGenerateId(i.folderId) : this._getOrGenerateId(this.rootPath);
2056
- return {
2057
- ...i,
2058
- id: a,
2059
- folderId: o
2060
- };
2061
- }
2062
- async moveItem(e, t) {
2063
- let n = this.pathForId(e.id, e.isFolder), r = this.pathForId(t, !0), i = await this._inner.moveItem({
2064
- ...e,
2065
- id: n,
2066
- folderId: this.pathForId(e.folderId, !0)
2067
- }, r);
2068
- this._updateIdMapping(e.id, i.id), e.isFolder && this.remapCachedFolderContents(e.id, n, i.id);
2069
- let a = this._getOrGenerateId(i.id), o = i.folderId ? this._getOrGenerateId(i.folderId) : t;
2070
- return {
2071
- ...i,
2072
- id: a,
2073
- folderId: o
2074
- };
2075
- }
2076
- async moveItems(e, t) {
2077
- let { __: n } = this.i18n;
2078
- if (!this._inner.moveItems) throw new T(n ? n("Move items is not supported by inner storage") : "Move items is not supported by inner storage", "MoveNotAllowed");
2079
- let r = t ? this.pathForId(t, !0) : this.rootPath, i = e.map((e) => ({
2080
- ...e,
2081
- id: this.pathForId(e.id, e.isFolder),
2082
- folderId: e.folderId ? this.pathForId(e.folderId, !0) : this.rootPath
2083
- })), a = await this._inner.moveItems(i, r), o = [];
2084
- if (a.detailed && a.detailed.length > 0) {
2085
- let r = /* @__PURE__ */ new Map();
2086
- for (let t = 0; t < a.detailed.length; t++) {
2087
- let n = a.detailed[t], i = n.requestId || (t < e.length ? e[t].id : void 0);
2088
- i && r.set(i, n);
2089
- }
2090
- for (let i of e) {
2091
- let s = r.get(i.id) || (a.detailed.length === e.length ? a.detailed[e.indexOf(i)] : void 0);
2092
- if (s?.success && s.data) {
2093
- if (this._updateIdMapping(i.id, s.data.id), i.isFolder) {
2094
- let e = this.pathForId(i.id, i.isFolder);
2095
- this.remapCachedFolderContents(i.id, e, s.data.id);
2096
- }
2097
- o.push({
2098
- requestId: i.id,
2099
- success: !0,
2100
- data: {
2101
- ...s.data,
2102
- id: this._getOrGenerateId(s.data.id),
2103
- folderId: s.data.folderId ? this._getOrGenerateId(s.data.folderId) : t || this._getOrGenerateId(this.rootPath)
2104
- }
2105
- });
2106
- } else {
2107
- let e = n ? n("Move operation failed - no detailed result") : "Move operation failed - no detailed result";
2108
- o.push({
2109
- requestId: i.id,
2110
- success: !1,
2111
- error: s?.error || {
2112
- message: e,
2113
- code: "MoveNotAllowed"
2114
- }
2115
- });
2116
- }
2117
- }
2118
- } else for (let t of e) {
2119
- let e = n ? n("Move operation failed - no detailed results") : "Move operation failed - no detailed results";
2120
- o.push({
2121
- requestId: t.id,
2122
- success: !1,
2123
- error: {
2124
- message: e,
2125
- code: "MoveNotAllowed"
2126
- }
2127
- });
2128
- }
2129
- return {
2130
- success: a.success,
2131
- detailed: o,
2132
- error: a.error
2133
- };
2134
- }
2135
- async copyItems(e, t) {
2136
- let { __: n } = this.i18n;
2137
- if (!this._inner.copyItems) throw new T(n ? n("Copy items is not supported by inner storage") : "Copy items is not supported by inner storage", "CopyNotAllowed");
2138
- let r = t ? this.pathForId(t, !0) : this.rootPath, i = e.map((e) => ({
2139
- ...e,
2140
- id: this.pathForId(e.id, e.isFolder),
2141
- folderId: e.folderId ? this.pathForId(e.folderId, !0) : this.rootPath
2142
- })), a = await this._inner.copyItems(i, r), o = [];
2143
- if (a.detailed && a.detailed.length > 0) {
2144
- let r = /* @__PURE__ */ new Map();
2145
- for (let t = 0; t < a.detailed.length; t++) {
2146
- let n = a.detailed[t], i = n.requestId || (t < e.length ? e[t].id : void 0);
2147
- i && r.set(i, n);
2148
- }
2149
- for (let i of e) {
2150
- let s = r.get(i.id) || (a.detailed.length === e.length ? a.detailed[e.indexOf(i)] : void 0);
2151
- if (s?.success && s.data?.id) {
2152
- let e = this._getOrGenerateId(s.data.id);
2153
- o.push({
2154
- requestId: i.id,
2155
- success: !0,
2156
- data: {
2157
- ...s.data,
2158
- id: e,
2159
- folderId: s.data.folderId ? this._getOrGenerateId(s.data.folderId) : t || this._getOrGenerateId(this.rootPath)
2160
- }
2161
- });
2162
- } else {
2163
- let e = s ? s.success ? s.data ? s.data.id ? {
2164
- message: n ? n("Unknown copy error") : "Unknown copy error",
2165
- code: "CopyNotAllowed"
2166
- } : {
2167
- message: n ? n("No ID in copied item data") : "No ID in copied item data",
2168
- code: "CopyNotAllowed"
2169
- } : {
2170
- message: n ? n("No data returned from copy operation") : "No data returned from copy operation",
2171
- code: "CopyNotAllowed"
2172
- } : s.error || {
2173
- message: n ? n("Copy operation failed") : "Copy operation failed",
2174
- code: "CopyNotAllowed"
2175
- } : {
2176
- message: n ? n("No detailed result from copy operation") : "No detailed result from copy operation",
2177
- code: "CopyNotAllowed"
2178
- };
2179
- o.push({
2180
- requestId: i.id,
2181
- success: !1,
2182
- error: e
2183
- });
2184
- }
2185
- }
2186
- } else for (let t of e) {
2187
- let e = n ? n("No detailed results from copy operation") : "No detailed results from copy operation";
2188
- o.push({
2189
- requestId: t.id,
2190
- success: !1,
2191
- error: {
2192
- message: e,
2193
- code: "CopyNotAllowed"
2194
- }
2195
- });
2196
- }
2197
- let s = o.every((e) => e.success), c = n ? n("Copy operation completed with errors") : "Copy operation completed with errors";
2198
- return {
2199
- success: s,
2200
- detailed: o,
2201
- error: s ? void 0 : a.error || {
2202
- message: c,
2203
- code: "CopyNotAllowed"
2204
- }
2205
- };
2206
- }
2207
- async deleteItems(e, t) {
2208
- let { __: n } = this.i18n;
2209
- if (!this._inner.deleteItems) throw new T(n ? n("Delete items is not supported by inner storage") : "Delete items is not supported by inner storage", "DeleteNotAllowed");
2210
- let r = e.map((e) => ({
2211
- ...e,
2212
- id: this.pathForId(e.id, e.isFolder),
2213
- folderId: e.folderId ? this.pathForId(e.folderId, !0) : this.rootPath
2214
- })), i = await this._inner.deleteItems(r, t), a = [];
2215
- if (i.detailed && i.detailed.length > 0) {
2216
- let r = /* @__PURE__ */ new Map();
2217
- for (let t = 0; t < i.detailed.length; t++) {
2218
- let n = i.detailed[t], a = n.requestId || (t < e.length ? e[t].id : void 0);
2219
- a && r.set(a, n);
2220
- }
2221
- for (let o of e) {
2222
- let s = r.get(o.id) || (i.detailed.length === e.length ? i.detailed[e.indexOf(o)] : void 0);
2223
- if (s?.success) {
2224
- let e = this.pathForId(o.id, o.isFolder);
2225
- if (t.permanent) this.recursivelyRemoveMappings(o.id, e);
2226
- else if (this._updateIdMapping(o.id, this.trashPath + "/" + e + (o.isFolder ? "/" : "")), o.isFolder) {
2227
- let t = this.pathForId(o.id, o.isFolder);
2228
- this.remapCachedFolderContents(o.id, t, this.trashPath + "/" + e + (o.isFolder ? "/" : ""));
2229
- }
2230
- a.push({
2231
- requestId: o.id,
2232
- success: !0
2233
- });
2234
- } else {
2235
- let e = n ? n("Delete operation failed") : "Delete operation failed";
2236
- a.push({
2237
- requestId: o.id,
2238
- success: !1,
2239
- error: s?.error || {
2240
- message: e,
2241
- code: "DeleteNotAllowed"
2242
- }
2243
- });
2244
- }
2245
- }
2246
- } else for (let r of e) if (i.success) {
2247
- let e = this.pathForId(r.id, r.isFolder);
2248
- if (t.permanent) this.recursivelyRemoveMappings(r.id, e);
2249
- else if (this._updateIdMapping(r.id, this.trashPath + "/" + e + (r.isFolder ? "/" : "")), r.isFolder) {
2250
- let t = this.pathForId(r.id, r.isFolder);
2251
- this.remapCachedFolderContents(r.id, t, this.trashPath + "/" + e + (r.isFolder ? "/" : ""));
2252
- }
2253
- a.push({
2254
- requestId: r.id,
2255
- success: !0
2256
- });
2257
- } else {
2258
- let e = n ? n("Delete operation failed") : "Delete operation failed";
2259
- a.push({
2260
- requestId: r.id,
2261
- success: !1,
2262
- error: i.error || {
2263
- message: e,
2264
- code: "DeleteNotAllowed"
2265
- }
2266
- });
2267
- }
2268
- let o = a.every((e) => e.success), s = n ? n("Some items failed to delete") : "Some items failed to delete";
2269
- return {
2270
- success: o,
2271
- detailed: a,
2272
- error: o ? void 0 : i.error || {
2273
- message: s,
2274
- code: "DeleteNotAllowed"
2275
- }
2276
- };
2277
- }
2278
- remapCachedFolderContents(e, t, n) {
2279
- let r = t.replace(/\/+$/, ""), i = n.replace(/\/+$/, ""), a = [];
2280
- for (let [e, t] of this._idToPath.entries()) {
2281
- let n = t.replace(/\/+$/, "");
2282
- n !== r && n.startsWith(r + "/") && a.push({
2283
- id: e,
2284
- oldPath: n
2285
- });
2286
- }
2287
- for (let { id: e, oldPath: t } of a) {
2288
- let n = i + t.substring(r.length);
2289
- this._updateIdMapping(e, n);
2290
- }
2291
- }
2292
- recursivelyRemoveMappings(e, t) {
2293
- let n = t.replace(/\/+$/, ""), r = [], i = [];
2294
- for (let [e, t] of this._idToPath.entries()) {
2295
- let a = t.replace(/\/+$/, "");
2296
- (a === n || a.startsWith(n + "/")) && (r.push(e), i.push(a));
2297
- }
2298
- for (let e = 0; e < r.length; e++) this._idToPath.delete(r[e]), this._pathToId.delete(i[e]);
2299
- }
2300
- async copyItem(e, t) {
2301
- let n = this.pathForId(e.id, e.isFolder), r = this.pathForId(t, !0), i = await this._inner.copyItem({
2302
- ...e,
2303
- id: n,
2304
- folderId: this.pathForId(e.folderId, !0)
2305
- }, r), a = this._getOrGenerateId(i.id), o = i.folderId ? this._getOrGenerateId(i.folderId) : t;
2306
- return {
2307
- ...i,
2308
- id: a,
2309
- folderId: o
2310
- };
2311
- }
2312
- async updateFile(e, t) {
2313
- let { __: n } = this.i18n;
2314
- if (!this._inner.updateFile) throw new T(n ? n("Update file is not supported by inner storage") : "Update file is not supported by inner storage", "UnsupportedOperation");
2315
- let r = this.pathForId(e.id, !1), { ...i } = await this._inner.updateFile({
2316
- ...e,
2317
- id: r,
2318
- folderId: this.pathForId(e.folderId, !0)
2319
- }, t);
2320
- return this._updateIdMapping(e.id, i.id), i.folderId && (i = {
2321
- ...i,
2322
- folderId: this._getOrGenerateId(i.folderId)
2323
- }), {
2324
- ...i,
2325
- id: this._getOrGenerateId(i.id)
2326
- };
2327
- }
2328
- async getFileData(e) {
2329
- let { __: t } = this.i18n, n = this.pathForId(e.id, !1);
2330
- if (this._inner.getFileData) return this._inner.getFileData({
2331
- ...e,
2332
- id: n,
2333
- folderId: this.pathForId(e.folderId, !0)
2334
- });
2335
- let r = e.url || this.getUrl && await this.getUrl(e);
2336
- if (!r) throw new T(t ? t("Cannot get file data: no url and no inner.getFileData") : "Cannot get file data: no url and no inner.getFileData", "FileReadError");
2337
- return fetch(r).then((e) => e.blob());
2338
- }
2339
- async cleanTrash() {
2340
- let { __: e } = this.i18n;
2341
- if (!this._inner.cleanTrash) throw new T(e ? e("Clean trash is not supported by inner storage") : "Clean trash is not supported by inner storage", "UnsupportedOperation");
2342
- return await this._inner.cleanTrash();
2343
- }
2344
- }, Ce = "a_T7zSNUXtMfhVWQbIOMpXIPqzLQ8hm5Wfclm2nU98PtlSVxcft8FSn5InbD04056fYCpKXP20jJSySRLu", we = "https://api-b2b.backenster.com/b1/api/v3", Te = {
2345
- ru: "ru_RU",
2346
- en: "en_GB",
2347
- uk: "uk_UA",
2348
- de: "de_DE",
2349
- fr: "fr_FR",
2350
- es: "es_ES",
2351
- it: "it_IT",
2352
- pt: "pt_PT",
2353
- pl: "pl_PL",
2354
- zh: "zh-Hans_CN",
2355
- ja: "ja_JP"
2356
- }, Ee = (e) => e ? Te[e.toLowerCase().split(/[-_]/)[0]] || "auto" : "en_GB";
2357
- async function Z(e, t = {}) {
2358
- let n = e.trim();
2359
- if (!n) return n;
2360
- let r = Ee(t.locale);
2361
- if (t.locale && r === "en_GB") return n;
2362
- try {
2363
- let e = {
2364
- from: t.locale ? r : "auto",
2365
- to: "en_GB",
2366
- data: n,
2367
- platform: "api"
2368
- }, i = await fetch(`${we}/translate`, {
2369
- method: "POST",
2370
- headers: {
2371
- "Content-Type": "application/json",
2372
- Authorization: `Bearer ${Ce}`
2373
- },
2374
- body: JSON.stringify(e)
2375
- });
2376
- if (!i.ok) return console.error("Lingvanex API request failed:", i.status, i.statusText), n;
2377
- let a = await i.json();
2378
- if (a.err) return console.error("Lingvanex API error:", a.err), n;
2379
- let o = a.result;
2380
- return typeof o == "string" && o.trim() ? o.trim() : n;
2381
- } catch (e) {
2382
- return console.error("translateToEnglish: request failed", e), n;
2383
- }
2384
- }
2385
- //#endregion
2386
- //#region src/hooks/useTranslateToEnglish.ts
2387
- function De(e) {
2388
- for (let t of e) if (typeof t == "string" && t.trim().length > 0) return t.trim();
2389
- return null;
2390
- }
2391
- function Oe() {
2392
- let e = u(), t = f(v), n = x(i.ON_TRANSLATE_ID);
2393
- return (0, O.useCallback)(async (r, i = {}) => {
2394
- let o = r.trim();
2395
- if (!o) return o;
2396
- let c = i.locale ?? (typeof t == "string" ? t : void 0), l = s.getInstance(e, a) !== void 0;
2397
- try {
2398
- let e = await n.fire({
2399
- input: o,
2400
- locale: c
2401
- }), t = De(Array.isArray(e) ? e : [e]);
2402
- if (t) return t;
2403
- } catch (e) {
2404
- console.error("ON_TRANSLATE_ID: fire failed", e);
2405
- }
2406
- return l ? o : Z(o, { locale: c }).catch(() => o);
2407
- }, [
2408
- t,
2409
- e,
2410
- n
2411
- ]);
2412
- }
2413
- //#endregion
2414
- //#region src/modules/components/FileManager/FileManager.tsx
2415
- var Q = m(), ke = (0, O.memo)(h), Ae = (0, O.memo)(g), { useToken: je } = D.theme, $ = ({ storageProvider: e }) => {
2416
- let t = o(), { projectId: r, emailId: a, blockId: s } = (0, ve.useParams)(), c = ne(), { __: p } = c, { token: m } = je(), { error: h, notify: g } = te(), _ = d(), v = f(re), y = f(ee), S = f(fe), T = f(se), k = f(b), A = f(le), j = Oe(), [M, N] = (0, O.useState)(""), [P, F] = (0, O.useState)("my_files"), [ye, I] = (0, O.useState)(!1), [L, R] = (0, O.useState)(0), [z, B] = (0, O.useState)(""), [V, be] = (0, O.useState)(() => []), H = () => {
2417
- _(C()), setTimeout(() => N(""), 600);
2418
- }, U = !(v || y.id?.toString() !== k?.members?.owner.ID), W = (0, O.useMemo)(() => ({
2419
- img: A,
2420
- background: T
2421
- }), [A, T]);
2422
- (0, O.useEffect)(() => {
2423
- S.includes("UPLOAD_BACKGROUND_MODAL") ? (N("background"), W.background && B(W.background)) : S.includes("UPLOAD_IMAGE_MODAL") && (N("img"), W.img && B(W.img)), S === n.UPLOAD_IMAGE_MODAL || S === n.UPLOAD_BACKGROUND_MODAL ? F("editor") : S === n.UPLOAD_IMAGE_MODAL_AI || S === n.UPLOAD_BACKGROUND_MODAL_AI ? U ? (I(!0), R(2)) : F("ai") : S === n.UPLOAD_IMAGE_MODAL_UPLOAD || S === n.UPLOAD_BACKGROUND_MODAL_UPLOAD ? F("my_files") : S === n.UPLOAD_IMAGE_MODAL_STOCK || S === n.UPLOAD_BACKGROUND_MODAL_STOCK ? U ? (I(!0), R(3)) : F("stock_images") : S === n.UPLOAD_IMAGE_MODAL_GIF || S === n.UPLOAD_BACKGROUND_MODAL_GIF ? U ? (I(!0), R(3)) : F("gif") : S === n.UPLOAD_IMAGE_MODAL_EDIT || S === n.UPLOAD_BACKGROUND_MODAL_EDIT ? (U ? (I(!0), R(5)) : F("editor"), _(oe(n.IMAGE_EDITOR_MODAL))) : F("my_files");
2424
- }, [
2425
- S,
2426
- _,
2427
- U,
2428
- W
2429
- ]);
2430
- let G = !U && !!P && (S.includes("UPLOAD_IMAGE_") || S.includes("UPLOAD_BACKGROUND_"));
2431
- (0, O.useEffect)(() => {
2432
- let e = document.querySelector("#carrotquest-messenger-collapsed-container");
2433
- e && (G ? e.style.display = "none" : e.style.display = "");
2434
- }, [G]);
2435
- let K = (0, O.useMemo)(() => e ? e.pathMode ? new Se(e, e.rootId, "Trash", e.trashPath, !0, c) : null : (h(p("Error when initializing file manager")), null), [
2436
- e,
2437
- h,
2438
- c
2439
- ]), q = (0, O.useMemo)(() => new xe(K ?? e, t.fileManager, {
2440
- ...e,
2441
- trashPath: e.pathMode ? "trash" : e.trashPath,
2442
- rootId: e.pathMode ? "" : e.rootId
2443
- }, c), [
2444
- e,
2445
- K,
2446
- t.fileManager,
2447
- c
2448
- ]), J = (0, O.useCallback)((e) => g(pe(e, q, K), !0), [
2449
- q,
2450
- K,
2451
- g
2452
- ]), Y = x(i.FILE_PROXY_EVENT_ID), X = (0, O.useCallback)(async (e) => {
2453
- let t = await (await Y.fire({
2454
- url: e,
2455
- project: r
2456
- })).find((e) => e);
2457
- if (!t) try {
2458
- {
2459
- let t = new URL(e), n = "https://px0.racs.rest".replace(/\/$/, ""), r = new URLSearchParams(t.searchParams);
2460
- r.set("proxy_url", t.origin), e = `${n}/${t.pathname.replace(/^\//, "")}?${r}${t.hash}`;
2461
- }
2462
- t = await (await fetch(e)).blob();
2463
- } catch (e) {
2464
- return console.error("Error fetching file for proxy:", e), null;
2465
- }
2466
- return t;
2467
- }, [
2468
- Y,
2469
- r,
2470
- ue(),
2471
- u()
2472
- ]), Ce = /* @__PURE__ */ (0, Q.jsx)(_e.LoadingOutlined, {
2473
- style: {
2474
- fontSize: 32,
2475
- margin: -16
2476
- },
2477
- spin: !0
2478
- }), we = (0, O.useCallback)((e) => {
2479
- ge.isEqual(e, V) || be(e);
2480
- }, [V]), [Te] = ae(), Ee = (0, O.useCallback)(async () => {
2481
- if (q) {
2482
- let e = V[0];
2483
- if (e) {
2484
- let t = e.url || e.thumbnailUrl || e.thumbnail;
2485
- M === "img" ? _(de(t)) : M === "background" && _(w(t));
2486
- }
2487
- }
2488
- H();
2489
- }, [
2490
- q,
2491
- _,
2492
- C,
2493
- V,
2494
- M
2495
- ]), Z = (0, O.useCallback)(async (e) => {
2496
- let t = e.url;
2497
- !t && q && (t = await q.getFileUrl(e.folderId, e.name)), t && (M === "img" ? _(de(t)) : M === "background" && _(w(t))), H();
2498
- }, [
2499
- q,
2500
- _,
2501
- C,
2502
- M
2503
- ]), De = (0, O.useCallback)(async () => {
2504
- H();
2505
- }, [_, C]), [$, { data: Me = [] }] = ie(), Ne = t?.handleLimitUsageEmitter || x(i.ON_LIMIT_ID), Pe = (0, O.useCallback)(async function(e) {
2506
- try {
2507
- await $(e).unwrap();
2508
- } catch (e) {
2509
- console.error("Ошибка запроса:", e);
2510
- }
2511
- }, [$]), Fe = (0, O.useMemo)(() => {
2512
- let e = t?.icons || {};
2513
- if (!(!e || Object.keys(e).length === 0)) return me(e);
2514
- }, [t?.icons]), Ie = (0, O.useCallback)(async (e, t = {}) => await j(e, t), [j]), Le = x(i.PROXY_URL_EVENT_ID), Re = (0, O.useCallback)(async (e) => (await Le.fire({
2515
- url: e,
2516
- project: r
2517
- })).findLast((t) => t && t !== e) || he(e), [Le, r]);
2518
- return M && q ? /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [!U && /* @__PURE__ */ (0, Q.jsx)(D.Modal, {
2519
- className: "file-manager",
2520
- closable: !0,
2521
- footer: null,
2522
- open: G,
2523
- width: "100vw",
2524
- onOk: Ee,
2525
- onCancel: H,
2526
- children: /* @__PURE__ */ (0, Q.jsx)(D.Spin, {
2527
- spinning: !q,
2528
- indicator: Ce,
2529
- children: q && (P === "editor" ? /* @__PURE__ */ (0, Q.jsx)(Ae, {
2530
- onSave: Z,
2531
- onClose: De,
2532
- dataProviders: q,
2533
- handleFileProxy: X,
2534
- theme: y.theme,
2535
- file: z,
2536
- handleNotify: J,
2537
- assetsUrl: E("", "static/media/image-editor"),
2538
- locale: y.locale.split("-")[0].split("_")[0]
2539
- }) : /* @__PURE__ */ (0, Q.jsx)(ke, {
2540
- dataProviders: q,
2541
- onChangeSelection: we,
2542
- onEditorOk: Z,
2543
- handleNotify: J,
2544
- customIcons: Fe,
2545
- config: {
2546
- assetsUrl: E("", "static/media/image-editor"),
2547
- onClose: H,
2548
- handleProxyUrl: Re,
2549
- handleFileProxy: X,
2550
- expandRootFolderOnInit: t.fileManager?.expandRootFolderOnInit !== !1,
2551
- activeLibraryItem: P,
2552
- REACT_APP_GIPHY_KEY: "Nh77eBlPeMn1ed9MBAvL542NUGeNO26F",
2553
- UNSPLASH_KEY: "HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",
2554
- APP_NAME_UNSPLASH: "Nh77eBlPeMn1ed9MBAvL542NUGeNO26F",
2555
- UNSLASH_PROXY_URL: "https://api.emailmaker.ru/services/agent",
2556
- STREAMLINE_API_KEY: l.env.REACT_APP_STREAMLINE_API_KEY,
2557
- fileForEdit: z,
2558
- projectId: r,
2559
- elementId: a || s,
2560
- pushToGTM: t?.pushToGTM,
2561
- handleLimitUsageEmitter: Ne,
2562
- sseQuery: Pe,
2563
- messages: Me,
2564
- sendAIImageRequest: t?.sendAIImageRequest || Te,
2565
- locale: y.locale.split("-")[0].split("_")[0],
2566
- theme: y.theme,
2567
- customTheme: m,
2568
- enableTrashFolder: t.fileManager?.enableTrash,
2569
- showNotifications: t.fileManager?.showNotifications,
2570
- handleTranslate: Ie,
2571
- features: {
2572
- enableRenameFile: t.fileManager?.enableRenameFile !== !1,
2573
- enableRenameFolder: t.fileManager?.enableRenameFolder !== !1,
2574
- enableUpdateFile: t.fileManager?.enableUpdateFile !== !1,
2575
- enableCopyItem: t.fileManager?.enableCopyFile !== !1,
2576
- enableCopyFolder: t.fileManager?.enableCopyFolder !== !1,
2577
- enableDelete: t.fileManager?.enableDelete !== !1,
2578
- enableEdit: t.fileManager?.enableEdit !== !1,
2579
- enableMoveItem: t.fileManager?.enableMoveFile !== !1,
2580
- enableMoveFolder: t.fileManager?.enableMoveFolder !== !1
2581
- },
2582
- disablePagination: t.fileManager?.enablePagination === !1,
2583
- multiSelect: t.fileManager?.multiSelect !== !1,
2584
- defaultFolderName: t.fileManager?.defaultFolderName,
2585
- availableImageExtensions: t.fileManager?.availableImageExtensions
2586
- }
2587
- }))
2588
- })
2589
- }), /* @__PURE__ */ (0, Q.jsx)(ce, {
2590
- open: ye,
2591
- onCancel: () => I(!1),
2592
- initialSlide: L,
2593
- sideOnOk: void 0
2594
- })] }) : null;
2595
- };
2596
- //#endregion
2597
- export { $ as default };