@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.30

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 (245) hide show
  1. package/README.md +72 -50
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-B5Tzwoh4.js} +2 -2
  3. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-Dub3pRV1.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CfmdXP9M.js} +1 -1
  5. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-Dt6MglIr.cjs} +1 -1
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Cn8Z42-Z.js} +8 -7
  7. package/dist/IconPicker-DLqOB-ri.cjs +1 -0
  8. package/dist/STRINGS-BExFecZW.js +8 -0
  9. package/dist/STRINGS-FNnfjF5H.cjs +1 -0
  10. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-BOpmZGHS.js} +2 -2
  11. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-Dfj1ikzw.cjs} +1 -1
  12. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-Bj-j1k5i.js} +2668 -2585
  13. package/dist/actions-registery-Cy1lqUVI.cjs +481 -0
  14. package/dist/actions.cjs +1 -1
  15. package/dist/actions.d.ts +0 -158
  16. package/dist/actions.js +3 -3
  17. package/dist/active-in-another-tab-CEWvA8SG.js +35 -0
  18. package/dist/active-in-another-tab-DV83cJ_v.cjs +1 -0
  19. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-B3wK94-S.js} +54 -53
  20. package/dist/add-new-language-page-C3Uu92KN.cjs +1 -0
  21. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-BOE-xwBc.cjs} +1 -1
  22. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-DsvGVrR8.js} +2 -2
  23. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-BBSzHZG6.js} +12 -11
  24. package/dist/ai-panel-content-DBlnfRRi.cjs +1 -0
  25. package/dist/ai-panel-default-lang-BVBuwnyU.js +317 -0
  26. package/dist/ai-panel-default-lang-DJJWAtN0.cjs +3 -0
  27. package/dist/ai-panel-other-lang-fIEZkmRy.js +132 -0
  28. package/dist/ai-panel-other-lang-v8Yd5ggR.cjs +1 -0
  29. package/dist/ai-prompt-input-C7ha_0Cn.cjs +1 -0
  30. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-CmSfGxTN.js} +70 -73
  31. package/dist/ai-translation-prompt-BzTGAS3W.cjs +1 -0
  32. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-CtBmvsRy.js} +2 -2
  33. package/dist/apply-binding-9XSrYzAE.cjs +1 -0
  34. package/dist/{apply-binding-6iwlED02.js → apply-binding-chfbBKi2.js} +238 -225
  35. package/dist/change-password-modal-CdOwtCWN.cjs +1 -0
  36. package/dist/change-password-modal-DxkhBI5d.js +137 -0
  37. package/dist/code-display-BR-gij5j.cjs +1 -0
  38. package/dist/{code-display-DhD_RBcg.js → code-display-DdWcOQ_i.js} +1 -1
  39. package/dist/code-editor-Bpn8z2fo.js +57 -0
  40. package/dist/code-editor-fL3s6Hk7.cjs +1 -0
  41. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-DDB816CQ.js} +10 -9
  42. package/dist/continue-editing-in-this-client-DjxpjsA8.cjs +1 -0
  43. package/dist/core-BWQrViOY.cjs +1 -0
  44. package/dist/core-QlWEXm1d.js +53 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +272 -105
  47. package/dist/core.js +64 -33
  48. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-CL8SIC3K.js} +11 -9
  49. package/dist/css-import-modal-CRC7bK1c.cjs +13 -0
  50. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B0md8qUi.js} +1 -1
  51. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C94IgWdi.cjs} +1 -1
  52. package/dist/delete-page-41tvYcEw.js +71 -0
  53. package/dist/delete-page-BHPlx8ec.cjs +1 -0
  54. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-CyOY4Pni.js} +19 -18
  55. package/dist/design-token-usage-DtdjTCn3.cjs +1 -0
  56. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-C_ru4Zes.js} +6 -5
  57. package/dist/digital-asset-manager-DSLQz8qk.cjs +1 -0
  58. package/dist/duplicate-page-BvggF83O.cjs +1 -0
  59. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-DMmDdmfS.js} +20 -19
  60. package/dist/dynamic-page-selector-C5agz2Ze.cjs +1 -0
  61. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-D2z51nLi.js} +12 -11
  62. package/dist/fonts/bungee/Bungee-Regular.woff2 +0 -0
  63. package/dist/fonts/dm_sans/dm-sans-variable.woff2 +0 -0
  64. package/dist/fonts/geist/Geist-VariableFont_wght.ttf +0 -0
  65. package/dist/fonts/geist/Geist-VariableFont_wght.woff2 +0 -0
  66. package/dist/fonts/geist/geist-variable.woff2 +0 -0
  67. package/dist/fonts/geist-mono/GeistMono-VariableFont_wght.woff2 +0 -0
  68. package/dist/fonts/inter/inter-latin.woff2 +0 -0
  69. package/dist/fonts/inter/inter-variable.woff2 +1449 -0
  70. package/dist/fonts/lato/lato-variable.woff2 +0 -0
  71. package/dist/fonts/lavishly_yours/lavishly-yours.woff2 +11 -0
  72. package/dist/fonts/merriweather/merriweather-variable.woff2 +11 -0
  73. package/dist/fonts/montserrat/montserrat-variable.woff2 +0 -0
  74. package/dist/fonts/nunito_sans/nunito-sans-variable.woff2 +11 -0
  75. package/dist/fonts/open_sans/open-sans-variable.woff2 +0 -0
  76. package/dist/fonts/oswald/oswald-variable.woff2 +0 -0
  77. package/dist/fonts/playfair_display/playfair-display-variable.woff2 +11 -0
  78. package/dist/fonts/poppins/poppins-variable.woff2 +0 -0
  79. package/dist/fonts/raleway/raleway-variable.woff2 +0 -0
  80. package/dist/fonts/roboto/roboto-variable.woff2 +11 -0
  81. package/dist/fonts/source_sans_3/source-sans-3-variable.woff2 +11 -0
  82. package/dist/fonts/ubuntu/ubuntu-variable.woff2 +0 -0
  83. package/dist/fonts-B3UYxuJI.js +25 -0
  84. package/dist/fonts-D5fTqvSS.cjs +1 -0
  85. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  86. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  87. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-B5RkBTsB.cjs} +1 -1
  88. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-BSUcPs5t.js} +1 -1
  89. package/dist/{image-editor-G-K28aTS.cjs → image-editor-DFmlG348.cjs} +1 -1
  90. package/dist/{image-editor-DV8kUKhl.js → image-editor-sKvOFo-S.js} +1 -1
  91. package/dist/{index-Ct7ElCGK.js → index-BFnMzGe6.js} +5381 -5895
  92. package/dist/index-Bzn_gpaK.cjs +5 -0
  93. package/dist/index-CA1OwKJX.js +4887 -0
  94. package/dist/index-D30xvFa5.cjs +160 -0
  95. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-B5wAR5GY.js} +82 -79
  96. package/dist/json-diff-viewer-DRQSNhaS.cjs +8 -0
  97. package/dist/lang-panel-BZsICcBR.cjs +1 -0
  98. package/dist/{lang-panel-BwIewMyw.js → lang-panel-q04hEq5o.js} +15 -14
  99. package/dist/library-blocks/blocks-list.json +16 -0
  100. package/dist/library-blocks/hero-1/hero-1.html +74 -0
  101. package/dist/library-blocks/hero-1/hero-1.webp +0 -0
  102. package/dist/library-blocks/hero-2/hero-2.html +95 -0
  103. package/dist/library-blocks/hero-2/hero-2.webp +0 -0
  104. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-Cene3KEu.js} +16 -15
  105. package/dist/manage-design-tokens-Di5C6nTj.cjs +1 -0
  106. package/dist/mark-as-template-CT-hLGIW.cjs +1 -0
  107. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-raTtKmQ9.js} +17 -16
  108. package/dist/nested-path-selector-content-CSUHTj9G.cjs +1 -0
  109. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-CzQ2Lorl.js} +24 -23
  110. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-Bg6VjMVY.js} +8 -7
  111. package/dist/no-language-page-content-Bkj8JpEY.cjs +1 -0
  112. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CRPMr9YT.js} +2 -2
  113. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-TffLjvJn.cjs} +1 -1
  114. package/dist/{page-creator-DiOITEMw.js → page-creator-CQhE1tgn.js} +147 -146
  115. package/dist/page-creator-RrUhy8uH.cjs +1 -0
  116. package/dist/{page-lock-BdYmCks0.cjs → page-lock-D9h5pgxn.cjs} +1 -1
  117. package/dist/{page-lock-Bfbs6RgL.js → page-lock-Dye1JZBB.js} +2 -2
  118. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-BMjPVyHF.js} +19 -16
  119. package/dist/page-locked-dialog-b2_f-A7a.cjs +1 -0
  120. package/dist/page-manager-new-2mDjnSqc.cjs +1 -0
  121. package/dist/page-manager-new-DP1b_dXt.js +411 -0
  122. package/dist/page-manager-search-and-filter-D0ZXojiu.cjs +1 -0
  123. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-DCcYyoPO.js} +20 -19
  124. package/dist/page-revisions-content-BX8ZWebc.cjs +1 -0
  125. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-mDwvH6J-.js} +134 -120
  126. package/dist/pages.cjs +1 -1
  127. package/dist/pages.d.ts +297 -97
  128. package/dist/pages.js +22 -19
  129. package/dist/plugin-DHpuZZXz.cjs +22 -0
  130. package/dist/plugin-Dkmjb2_e.js +248 -0
  131. package/dist/publish-pages-content-CR4e9inX.cjs +1 -0
  132. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-M_Kb8b-F.js} +71 -70
  133. package/dist/register-chai-top-bar-D6GjnauV.js +237 -0
  134. package/dist/register-chai-top-bar-DyW9GPzV.cjs +1 -0
  135. package/dist/render.cjs +2 -2
  136. package/dist/render.d.ts +21 -20
  137. package/dist/render.js +127 -120
  138. package/dist/rte-widget-modal-BRSm1Lnp.cjs +1 -0
  139. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-CVZDktXI.js} +10 -9
  140. package/dist/runtime-client.cjs +1 -0
  141. package/dist/runtime-client.d.ts +158 -0
  142. package/dist/runtime-client.js +32 -0
  143. package/dist/runtime.cjs +11 -1
  144. package/dist/runtime.d.ts +158 -114
  145. package/dist/runtime.js +107 -42
  146. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-B1ccNhR2.js} +152 -145
  147. package/dist/save-to-lib-CYEAWxL9.cjs +1 -0
  148. package/dist/sdk.css +1 -1
  149. package/dist/selected-block-display-MyU0rS4q.cjs +16 -0
  150. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-aGR7p5JC.js} +36 -35
  151. package/dist/seo-panel-B5mDwpaT.cjs +2 -0
  152. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-P9uixkoZ.js} +149 -148
  153. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Ba9GcvLr.js} +72 -71
  154. package/dist/shared-json-ld-DhQJh_mT.cjs +1 -0
  155. package/dist/slug-input-BdMnlYKT.cjs +1 -0
  156. package/dist/{slug-input-AwNJs9im.js → slug-input-CAfGHqMW.js} +9 -8
  157. package/dist/supabase-actions.cjs +1 -1
  158. package/dist/supabase-actions.d.ts +40 -1
  159. package/dist/supabase-actions.js +231 -192
  160. package/dist/take-over-request-BeHTL28z.cjs +1 -0
  161. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-CXjaDliJ.js} +18 -17
  162. package/dist/theme-panel-footer-BkwhuXM7.js +26 -0
  163. package/dist/theme-panel-footer-D_gxD0j4.cjs +1 -0
  164. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-CTfArsb1.js} +11 -10
  165. package/dist/translation-warning-modal-D_vt37fW.cjs +1 -0
  166. package/dist/types.cjs +1 -0
  167. package/dist/types.d.ts +740 -0
  168. package/dist/types.js +1 -0
  169. package/dist/unmark-as-template-D2bvjGKt.cjs +1 -0
  170. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-vFgMIdxN.js} +12 -11
  171. package/dist/unpublish-page-CPjHmtSM.cjs +1 -0
  172. package/dist/unpublish-page-CxkjTzBB.js +28 -0
  173. package/dist/utils.cjs +1 -1
  174. package/dist/utils.d.ts +8 -5
  175. package/dist/utils.js +2 -2
  176. package/dist/web-blocks.cjs +1 -1
  177. package/dist/web-blocks.js +341 -332
  178. package/dist/{web-preview-Djy6WIyj.js → web-preview--by73Vvr.js} +2 -2
  179. package/dist/web-preview-C3AMe_BB.cjs +1 -0
  180. package/package.json +36 -31
  181. package/dist/IconPicker-DREyo007.cjs +0 -1
  182. package/dist/actions-registery-YnFmU21O.cjs +0 -418
  183. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  184. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  185. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  186. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  187. package/dist/ai-panel-default-lang-COYaxNwn.cjs +0 -3
  188. package/dist/ai-panel-default-lang-DnElspF0.js +0 -341
  189. package/dist/ai-panel-other-lang-CkynNlAU.cjs +0 -1
  190. package/dist/ai-panel-other-lang-Dp0E9_Hx.js +0 -162
  191. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  192. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  193. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  194. package/dist/code-display-BnqzqzoP.cjs +0 -1
  195. package/dist/code-editor-DRIAnNbb.js +0 -50
  196. package/dist/code-editor-o3___nu2.cjs +0 -1
  197. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  198. package/dist/core-BoRDjj4h.cjs +0 -1
  199. package/dist/core-yvI6kCyw.js +0 -56
  200. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  201. package/dist/delete-page-BzyX9TN-.js +0 -70
  202. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  203. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  204. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  205. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  206. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  207. package/dist/fonts/GeistMonoVF.woff +0 -0
  208. package/dist/fonts/GeistVF.woff +0 -0
  209. package/dist/fonts-B-Xt29pe.cjs +0 -1
  210. package/dist/fonts-DRly3Wzd.js +0 -78
  211. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  212. package/dist/index-B-rSiAp_.cjs +0 -1
  213. package/dist/index-DF5DEvqb.cjs +0 -160
  214. package/dist/index-Dxfyt4d4.js +0 -39
  215. package/dist/index-WQwzsC7A.cjs +0 -5
  216. package/dist/index-ZuacEL1j.js +0 -4732
  217. package/dist/json-diff-viewer-D7z4zNvv.cjs +0 -8
  218. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  219. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  220. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  221. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  222. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  223. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  224. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  225. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  226. package/dist/page-manager-new-CzX22g2n.js +0 -394
  227. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  228. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  229. package/dist/plugin-3ZKK6RXm.js +0 -245
  230. package/dist/plugin-C6rgJDNQ.cjs +0 -22
  231. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  232. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  233. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  234. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  235. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  236. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  237. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  238. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  239. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  240. package/dist/theme-panel-footer-uBQqSJXm.js +0 -25
  241. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  242. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  243. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  244. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  245. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -1,15 +1,17 @@
1
1
  import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
- import { B as b, c as z, a9 as se, aa as ie, P as oe, I as L, aE as le, am as ce, aF as de, L as P } from "./index-Ct7ElCGK.js";
3
- import { ar as D, as as G, A as _, ay as ue } from "./index-ZuacEL1j.js";
4
- import { useQuery as K, useMutation as U, useQueryClient as me } from "@tanstack/react-query";
2
+ import { B as b, z as L } from "./register-chai-top-bar-D6GjnauV.js";
3
+ import { ax as ne, c as M, aa as ie, ab as oe, P as le, ay as ce, ap as de, az as ue, q as P } from "./index-BFnMzGe6.js";
4
+ import { ar as D, as as G, A as _, ay as me } from "./index-CA1OwKJX.js";
5
+ import { useQuery as K, useMutation as A, useQueryClient as pe } from "@tanstack/react-query";
6
+ import { useSetAtom as fe } from "jotai";
5
7
  import { toast as N } from "sonner";
6
- import { Trash2 as Y, Plus as pe, ImageIcon as he, X as fe, AlertCircle as ge } from "lucide-react";
7
- import { useState as f, useRef as V, useMemo as S, useEffect as w, useCallback as be } from "react";
8
+ import { Trash2 as Y, Plus as he, ImageIcon as ge, X as be, AlertCircle as ye } from "lucide-react";
9
+ import { useState as h, useRef as V, useMemo as S, useEffect as w, useCallback as ke } from "react";
8
10
  import { c as ve } from "./image-compression-DsZ1oqpb.js";
9
- import { isEmpty as ye, set as ke, has as Ne } from "lodash-es";
10
- const Be = (r) => {
11
+ import { isEmpty as Ne, set as Be, has as Ce } from "lodash-es";
12
+ const Ie = (r) => {
11
13
  const a = D(), o = G();
12
- return U({
14
+ return A({
13
15
  mutationFn: async (t) => o(a, {
14
16
  action: _.UPSERT_LIBRARY_ITEM,
15
17
  data: t
@@ -23,7 +25,7 @@ const Be = (r) => {
23
25
  });
24
26
  }
25
27
  });
26
- }, Ce = (r) => {
28
+ }, we = (r) => {
27
29
  const a = D(), o = G();
28
30
  return K({
29
31
  staleTime: "static",
@@ -43,40 +45,45 @@ const Be = (r) => {
43
45
  },
44
46
  retry: !1
45
47
  });
46
- }, Ie = (r) => {
47
- const a = D(), o = G();
48
- return U({
49
- mutationFn: async (t) => o(a, {
48
+ }, Ee = (r) => {
49
+ const a = D(), o = G(), t = fe(ne);
50
+ return A({
51
+ mutationFn: async (l) => o(a, {
50
52
  action: _.DELETE_LIBRARY_ITEM,
51
- data: { id: t }
53
+ data: { id: l }
52
54
  }),
53
55
  onSuccess: () => {
54
- r ? r() : N.success("Block deleted successfully");
56
+ t((l) => {
57
+ const m = { ...l };
58
+ return Object.keys(m).forEach((u) => {
59
+ m[u] = { loading: "idle", blocks: [], error: !1 };
60
+ }), m;
61
+ }), r ? r() : N.success("Block deleted successfully");
55
62
  },
56
- onError: (t) => {
57
- console.error("Error deleting block:", t), N.error("Failed to delete block", {
58
- description: t instanceof Error ? t.message : "Unknown error"
63
+ onError: (l) => {
64
+ console.error("Error deleting block:", l), N.error("Failed to delete block", {
65
+ description: l instanceof Error ? l.message : "Unknown error"
59
66
  });
60
67
  }
61
68
  });
62
- }, we = ({
69
+ }, xe = ({
63
70
  blockId: r,
64
71
  libBlockId: a,
65
72
  isOpen: o,
66
73
  onClose: t,
67
- blockName: u,
68
- trigger: p
74
+ blockName: l,
75
+ trigger: m
69
76
  }) => {
70
- const [d, l] = f(!1), c = z(), v = Ie(() => {
71
- c([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), l(!1), t();
77
+ const [u, c] = h(!1), d = M(), y = Ee(() => {
78
+ d([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), c(!1), t();
72
79
  });
73
- return /* @__PURE__ */ i(se, { open: o, onOpenChange: (m) => !m && t(), children: [
74
- /* @__PURE__ */ e(ie, { asChild: !0, children: p || /* @__PURE__ */ i(b, { type: "button", variant: "destructive", size: "sm", onClick: (m) => m.preventDefault(), disabled: d, children: [
80
+ return /* @__PURE__ */ i(ie, { open: o, onOpenChange: (p) => !p && t(), children: [
81
+ /* @__PURE__ */ e(oe, { asChild: !0, children: m || /* @__PURE__ */ i(b, { type: "button", variant: "destructive", size: "sm", onClick: (p) => p.preventDefault(), disabled: u, children: [
75
82
  /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
76
83
  "Delete"
77
84
  ] }) }),
78
85
  /* @__PURE__ */ e(
79
- oe,
86
+ le,
80
87
  {
81
88
  className: "z-[9999] w-72 p-4",
82
89
  sideOffset: 5,
@@ -87,39 +94,39 @@ const Be = (r) => {
87
94
  "Are you sure you want to delete the block",
88
95
  /* @__PURE__ */ i("span", { className: "font-medium", children: [
89
96
  ' "',
90
- u,
97
+ l,
91
98
  '"'
92
99
  ] }),
93
100
  "?"
94
101
  ] }),
95
102
  /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "This block will be permanently removed from the library. This action cannot be undone." }),
96
103
  /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
97
- /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled: d, children: "Cancel" }),
104
+ /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled: u, children: "Cancel" }),
98
105
  /* @__PURE__ */ e(b, { type: "button", variant: "destructive", size: "sm", onClick: () => {
99
- l(!0), v.mutate(a);
100
- }, disabled: d, children: d ? "Deleting..." : "Delete" })
106
+ c(!0), y.mutate(a);
107
+ }, disabled: u, children: u ? "Deleting..." : "Delete" })
101
108
  ] })
102
109
  ] })
103
110
  }
104
111
  )
105
112
  ] });
106
- }, Ee = ({
113
+ }, Pe = ({
107
114
  blockId: r,
108
115
  libBlockId: a,
109
116
  blockName: o,
110
117
  size: t = "sm",
111
- className: u = "",
112
- close: p
118
+ className: l = "",
119
+ close: m
113
120
  }) => {
114
- const [d, l] = f(!1);
121
+ const [u, c] = h(!1);
115
122
  return /* @__PURE__ */ e(
116
- we,
123
+ xe,
117
124
  {
118
125
  blockId: r,
119
126
  libBlockId: a,
120
- isOpen: d,
127
+ isOpen: u,
121
128
  onClose: () => {
122
- l(!1), p();
129
+ c(!1), m();
123
130
  },
124
131
  blockName: o,
125
132
  trigger: /* @__PURE__ */ i(
@@ -128,8 +135,8 @@ const Be = (r) => {
128
135
  type: "button",
129
136
  variant: "destructive",
130
137
  size: t,
131
- className: u,
132
- onClick: () => l(!0),
138
+ className: l,
139
+ onClick: () => c(!0),
133
140
  children: [
134
141
  /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
135
142
  "Delete"
@@ -138,11 +145,11 @@ const Be = (r) => {
138
145
  )
139
146
  }
140
147
  );
141
- }, xe = () => {
142
- const r = D(), a = G(), o = me(), {
148
+ }, Le = () => {
149
+ const r = D(), a = G(), o = pe(), {
143
150
  data: t = [],
144
- isLoading: u,
145
- error: p
151
+ isLoading: l,
152
+ error: m
146
153
  } = K({
147
154
  queryKey: ["library-groups"],
148
155
  staleTime: "static",
@@ -152,17 +159,17 @@ const Be = (r) => {
152
159
  return await a(r, {
153
160
  action: "GET_LIBRARY_GROUPS"
154
161
  }) || [];
155
- } catch (c) {
156
- return console.error("Error fetching library groups:", c), [];
162
+ } catch (d) {
163
+ return console.error("Error fetching library groups:", d), [];
157
164
  }
158
165
  }
159
- }), { mutateAsync: d, isPending: l } = U({
160
- mutationFn: async (c) => {
161
- if (!c.trim())
166
+ }), { mutateAsync: u, isPending: c } = A({
167
+ mutationFn: async (d) => {
168
+ if (!d.trim())
162
169
  throw new Error("Group name is required");
163
170
  return a(r, {
164
171
  action: "CREATE_BLOCK_GROUP",
165
- data: { name: c }
172
+ data: { name: d }
166
173
  });
167
174
  },
168
175
  onSuccess: () => {
@@ -170,21 +177,21 @@ const Be = (r) => {
170
177
  queryKey: ["library-groups"]
171
178
  }), N.success("Group created successfully");
172
179
  },
173
- onError: (c) => {
174
- console.error("Error creating group:", c), N.error("Failed to create group", {
175
- description: c instanceof Error ? c.message : "Unknown error"
180
+ onError: (d) => {
181
+ console.error("Error creating group:", d), N.error("Failed to create group", {
182
+ description: d instanceof Error ? d.message : "Unknown error"
176
183
  });
177
184
  }
178
185
  });
179
186
  return {
180
187
  groups: t,
181
- isLoading: u,
182
- error: p,
183
- createGroup: d,
184
- isCreating: l
188
+ isLoading: l,
189
+ error: m,
190
+ createGroup: u,
191
+ isCreating: c
185
192
  };
186
- }, Pe = ({ value: r, onChange: a }) => {
187
- const [o, t] = f(!1), [u, p] = f(""), d = V(null), { groups: l } = xe(), [c, v] = f([
193
+ }, _e = ({ value: r, onChange: a }) => {
194
+ const [o, t] = h(!1), [l, m] = h(""), u = V(null), { groups: c } = Le(), [d, y] = h([
188
195
  { id: "hero", name: "Hero" },
189
196
  { id: "feature", name: "Feature" },
190
197
  { id: "footer", name: "Footer" },
@@ -212,35 +219,35 @@ const Be = (r) => {
212
219
  { id: "stats", name: "Stats" },
213
220
  { id: "team", name: "Team" },
214
221
  { id: "timeline", name: "Timeline" }
215
- ]), h = S(
222
+ ]), f = S(
216
223
  () => [
217
- ...l,
218
- ...c.filter((n) => !l.some((B) => B.id === n.id))
224
+ ...c,
225
+ ...d.filter((s) => !c.some((B) => B.id === s.id))
219
226
  ],
220
- [l, c]
227
+ [c, d]
221
228
  ), g = () => {
222
- const n = u.trim();
223
- if (!n) return;
224
- const B = { id: n, name: n };
225
- v((E) => [...E, B]), a(B.id), p(""), t(!1);
229
+ const s = l.trim();
230
+ if (!s) return;
231
+ const B = { id: s, name: s };
232
+ y((E) => [...E, B]), a(B.id), m(""), t(!1);
226
233
  };
227
234
  w(() => {
228
- o && d.current && d.current.focus();
235
+ o && u.current && u.current.focus();
229
236
  }, [o]);
230
- const m = (n) => {
231
- n.key === "Enter" && (n.preventDefault(), g());
237
+ const p = (s) => {
238
+ s.key === "Enter" && (s.preventDefault(), g());
232
239
  };
233
240
  return w(() => {
234
- r && !h.some((n) => n.id === r) && a("");
235
- }, [r, h, a]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
241
+ r && !f.some((s) => s.id === r) && a("");
242
+ }, [r, f, a]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
236
243
  /* @__PURE__ */ e(
237
244
  L,
238
245
  {
239
- ref: d,
246
+ ref: u,
240
247
  placeholder: "Enter new group name",
241
- value: u,
242
- onChange: (n) => p(n.target.value),
243
- onKeyDown: m
248
+ value: l,
249
+ onChange: (s) => m(s.target.value),
250
+ onKeyDown: p
244
251
  }
245
252
  ),
246
253
  /* @__PURE__ */ i("div", { className: "flex justify-end gap-2", children: [
@@ -253,30 +260,30 @@ const Be = (r) => {
253
260
  {
254
261
  className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
255
262
  value: r,
256
- onChange: (n) => a(n.target.value),
263
+ onChange: (s) => a(s.target.value),
257
264
  children: [
258
265
  /* @__PURE__ */ e("option", { value: "", children: "Select a group" }),
259
- l.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Library Groups", children: l.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, `lib-${n.id}`)) }),
260
- c.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Predefined Groups", children: c.filter((n) => !l.some((B) => B.id === n.id)).map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, `local-${n.id}`)) })
266
+ c.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Library Groups", children: c.map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, `lib-${s.id}`)) }),
267
+ d.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Predefined Groups", children: d.filter((s) => !c.some((B) => B.id === s.id)).map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, `local-${s.id}`)) })
261
268
  ]
262
269
  }
263
270
  ),
264
- /* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(pe, { className: "h-4 w-4" }) })
271
+ /* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) })
265
272
  ] });
266
- }, Le = ({ value: r, onChange: a }) => {
267
- const [o, t] = f(!1), u = V(null), p = be(
268
- async (c) => {
269
- var h;
270
- const v = (h = c.target.files) == null ? void 0 : h[0];
271
- if (v)
273
+ }, De = ({ value: r, onChange: a }) => {
274
+ const [o, t] = h(!1), l = V(null), m = ke(
275
+ async (d) => {
276
+ var f;
277
+ const y = (f = d.target.files) == null ? void 0 : f[0];
278
+ if (y)
272
279
  try {
273
280
  t(!0);
274
- let g = v;
275
- v.type.startsWith("image/") && (g = await ve(v));
276
- const m = new FileReader();
277
- m.onloadend = () => {
278
- a(m.result), t(!1);
279
- }, m.readAsDataURL(g);
281
+ let g = y;
282
+ y.type.startsWith("image/") && (g = await ve(y));
283
+ const p = new FileReader();
284
+ p.onloadend = () => {
285
+ a(p.result), t(!1);
286
+ }, p.readAsDataURL(g);
280
287
  } catch (g) {
281
288
  console.error("Error reading file:", g), t(!1), N.error("Failed to process image", {
282
289
  description: g instanceof Error ? g.message : "Unknown error"
@@ -287,68 +294,68 @@ const Be = (r) => {
287
294
  );
288
295
  return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
289
296
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
290
- /* @__PURE__ */ e(L, { type: "file", ref: u, onChange: p, accept: "image/*", className: "hidden" }),
297
+ /* @__PURE__ */ e(L, { type: "file", ref: l, onChange: m, accept: "image/*", className: "hidden" }),
291
298
  /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: () => {
292
- var c;
293
- (c = u.current) == null || c.click();
299
+ var d;
300
+ (d = l.current) == null || d.click();
294
301
  }, disabled: o, className: "w-full", children: o ? /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
295
302
  /* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
296
303
  "Uploading..."
297
304
  ] }) : /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
298
- /* @__PURE__ */ e(he, { className: "h-4 w-4" }),
305
+ /* @__PURE__ */ e(ge, { className: "h-4 w-4" }),
299
306
  "Select image"
300
307
  ] }) }),
301
308
  r && /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "icon", onClick: () => {
302
- a(""), u.current && (u.current.value = "");
303
- }, children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" }) })
309
+ a(""), l.current && (l.current.value = "");
310
+ }, children: /* @__PURE__ */ e(be, { className: "h-4 w-4" }) })
304
311
  ] }),
305
312
  r && /* @__PURE__ */ e("div", { className: "aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: r, alt: "Preview", className: "h-full w-full object-contain" }) })
306
313
  ] });
307
- }, qe = (r) => {
308
- const { blocks: a, close: o, blockId: t } = r, { getPartailBlocks: u } = le(), p = a.find((s) => s._id === t), d = p == null ? void 0 : p._libBlockId, l = !!d, c = S(() => a.some((s) => s._type === "PartialBlock" || s._type === "GlobalBlock"), [a]), v = S(() => {
309
- let s = [];
310
- for (const y of a)
311
- if (y._type === "PartialBlock" || y._type === "GlobalBlock") {
312
- let k = u(y.partialBlockId);
313
- y._parent && (k == null ? void 0 : k.length) > 0 && (k = k.map((R) => (ye(R._parent) && ke(R, "_parent", y._parent), R))), s = [...s, ...k];
314
+ }, Me = (r) => {
315
+ const { blocks: a, close: o, blockId: t } = r, { getPartailBlocks: l } = ce(), m = a.find((n) => n._id === t), u = m == null ? void 0 : m._libBlockId, c = !!u, d = S(() => a.some((n) => n._type === "PartialBlock" || n._type === "GlobalBlock"), [a]), y = S(() => {
316
+ let n = [];
317
+ for (const k of a)
318
+ if (k._type === "PartialBlock" || k._type === "GlobalBlock") {
319
+ let v = l(k.partialBlockId);
320
+ k._parent && (v == null ? void 0 : v.length) > 0 && (v = v.map((R) => (Ne(R._parent) && Be(R, "_parent", k._parent), R))), n = [...n, ...v];
314
321
  } else
315
- s.push(y);
316
- return s;
317
- }, [a, u]), [h, g] = f(""), [m, n] = f(""), [B, E] = f(""), [x, A] = f(""), [C, W] = f({}), [Q, $] = f(!1), [H, q] = f(l), [X, J] = f(!1), { hasPermission: Z } = ce(), ee = Z(ue.DELETE_LIBRARY_BLOCK), M = z(), te = () => {
318
- M([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), o();
322
+ n.push(k);
323
+ return n;
324
+ }, [a, l]), [f, g] = h(""), [p, s] = h(""), [B, E] = h(""), [x, U] = h(""), [C, W] = h({}), [Q, $] = h(!1), [H, q] = h(c), [X, J] = h(!1), { hasPermission: Z } = de(), ee = Z(me.DELETE_LIBRARY_BLOCK), z = M(), te = () => {
325
+ z([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), o();
319
326
  }, {
320
327
  data: I,
321
- isLoading: F,
328
+ isLoading: T,
322
329
  isError: O
323
- } = Ce(d);
330
+ } = we(u);
324
331
  w(() => {
325
- O && l && (J(!0), q(!1));
326
- }, [O, l]), w(() => {
327
- I && !F && (g(I.name || ""), n(I.group || ""), E(I.description || ""), A(I.preview || ""), q(!1));
328
- }, [I, F]), w(() => {
329
- const s = h.trim().length >= 2, y = m.trim() !== "";
330
- $(s && y);
331
- }, [h, m]);
332
+ O && c && (J(!0), q(!1));
333
+ }, [O, c]), w(() => {
334
+ I && !T && (g(I.name || ""), s(I.group || ""), E(I.description || ""), U(I.preview || ""), q(!1));
335
+ }, [I, T]), w(() => {
336
+ const n = f.trim().length >= 2, k = p.trim() !== "";
337
+ $(n && k);
338
+ }, [f, p]);
332
339
  const re = () => {
333
- const s = {};
334
- return h.trim() ? h.length < 2 && (s.name = "Name must be at least 2 characters") : s.name = "Name is required", m || (s.group = "Group is required"), W(s), Object.keys(s).length === 0;
335
- }, { resetLibrary: ae } = de({ id: "" }), j = Be((s) => {
336
- l || M([t], { _libBlockId: s.id }), N.success(`Block ${l ? "updated" : "saved"} successfully`), ae(s.library), o();
337
- }), ne = async (s) => {
338
- if (s.preventDefault(), !re()) return;
339
- const y = v.map((k) => (Ne(k, "_libBlockId") && delete k._libBlockId, k));
340
+ const n = {};
341
+ return f.trim() ? f.length < 2 && (n.name = "Name must be at least 2 characters") : n.name = "Name is required", p || (n.group = "Group is required"), W(n), Object.keys(n).length === 0;
342
+ }, { resetLibrary: ae } = ue({ id: "" }), j = Ie((n) => {
343
+ c || z([t], { _libBlockId: n.id }), N.success(`Block ${c ? "updated" : "saved"} successfully`), ae(n.library), o();
344
+ }), se = async (n) => {
345
+ if (n.preventDefault(), !re()) return;
346
+ const k = y.map((v) => (Ce(v, "_libBlockId") && delete v._libBlockId, v));
340
347
  j.mutate({
341
- name: h.trim(),
342
- group: m,
343
- blocks: y,
348
+ name: f.trim(),
349
+ group: p,
350
+ blocks: k,
344
351
  description: B.trim(),
345
352
  // Only include previewImage if it exists and is a base64 image
346
353
  ...x && x.startsWith("data:") ? { previewImage: x } : {},
347
354
  // Include id if in edit mode
348
- ...l ? { id: d } : {}
355
+ ...c ? { id: u } : {}
349
356
  });
350
- }, T = j.isPending;
351
- return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ i("div", { className: "space-y-4 p-6", children: [
357
+ }, F = j.isPending;
358
+ return H || T ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ i("div", { className: "space-y-4 p-6", children: [
352
359
  /* @__PURE__ */ e("div", { className: "font-medium text-destructive", children: "Block Not Found" }),
353
360
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This block could not be found on the server. It may have been deleted." }),
354
361
  /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-4", children: [
@@ -356,14 +363,14 @@ const Be = (r) => {
356
363
  /* @__PURE__ */ e(b, { onClick: te, variant: "destructive", children: "Delink Block" })
357
364
  ] })
358
365
  ] }) : /* @__PURE__ */ i("div", { children: [
359
- c && /* @__PURE__ */ i("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
360
- /* @__PURE__ */ e(ge, { className: "mt-0.5 h-5 w-5 flex-shrink-0" }),
366
+ d && /* @__PURE__ */ i("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
367
+ /* @__PURE__ */ e(ye, { className: "mt-0.5 h-5 w-5 flex-shrink-0" }),
361
368
  /* @__PURE__ */ i("div", { children: [
362
369
  /* @__PURE__ */ e("p", { className: "font-medium", children: "Partial Blocks Detected" }),
363
370
  /* @__PURE__ */ e("p", { className: "mt-1 text-xs", children: "This block contains one or more Partial Blocks. Partial blocks will be merged into the library block" })
364
371
  ] })
365
372
  ] }),
366
- /* @__PURE__ */ i("form", { onSubmit: ne, className: "space-y-4", children: [
373
+ /* @__PURE__ */ i("form", { onSubmit: se, className: "space-y-4", children: [
367
374
  /* @__PURE__ */ i("div", { className: "space-y-2", children: [
368
375
  /* @__PURE__ */ e(P, { htmlFor: "name", className: C.name ? "text-destructive" : "", children: "Name" }),
369
376
  /* @__PURE__ */ e(
@@ -371,8 +378,8 @@ const Be = (r) => {
371
378
  {
372
379
  id: "name",
373
380
  placeholder: "Enter block name",
374
- value: h,
375
- onChange: (s) => g(s.target.value),
381
+ value: f,
382
+ onChange: (n) => g(n.target.value),
376
383
  className: C.name ? "border-destructive" : ""
377
384
  }
378
385
  ),
@@ -380,7 +387,7 @@ const Be = (r) => {
380
387
  ] }),
381
388
  /* @__PURE__ */ i("div", { className: "space-y-2", children: [
382
389
  /* @__PURE__ */ e(P, { htmlFor: "group", className: C.group ? "text-destructive" : "", children: "Group" }),
383
- /* @__PURE__ */ e(Pe, { value: m, onChange: n }),
390
+ /* @__PURE__ */ e(_e, { value: p, onChange: s }),
384
391
  C.group && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.group })
385
392
  ] }),
386
393
  /* @__PURE__ */ i("div", { className: "space-y-2", children: [
@@ -392,31 +399,31 @@ const Be = (r) => {
392
399
  placeholder: "Enter a brief description",
393
400
  className: "resize-none",
394
401
  value: B,
395
- onChange: (s) => E(s.target.value)
402
+ onChange: (n) => E(n.target.value)
396
403
  }
397
404
  )
398
405
  ] }),
399
406
  /* @__PURE__ */ i("div", { className: "space-y-2", children: [
400
407
  /* @__PURE__ */ e(P, { htmlFor: "previewImage", children: "Preview Image (optional)" }),
401
- /* @__PURE__ */ e(Le, { value: x, onChange: A })
408
+ /* @__PURE__ */ e(De, { value: x, onChange: U })
402
409
  ] }),
403
410
  /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
404
- l && ee && /* @__PURE__ */ e(
405
- Ee,
411
+ c && ee && /* @__PURE__ */ e(
412
+ Pe,
406
413
  {
407
414
  blockId: t,
408
- libBlockId: d,
409
- blockName: h,
415
+ libBlockId: u,
416
+ blockName: f,
410
417
  className: "mr-auto",
411
418
  close: o
412
419
  }
413
420
  ),
414
- /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled: T, children: "Cancel" }),
415
- /* @__PURE__ */ e(b, { type: "submit", disabled: T || !Q, children: T ? "Saving..." : l ? "Update Block" : "Save Block" })
421
+ /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled: F, children: "Cancel" }),
422
+ /* @__PURE__ */ e(b, { type: "submit", disabled: F || !Q, children: F ? "Saving..." : c ? "Update Block" : "Save Block" })
416
423
  ] })
417
424
  ] })
418
425
  ] });
419
426
  };
420
427
  export {
421
- qe as default
428
+ Me as default
422
429
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-D30xvFa5.cjs"),b=require("./index-Bzn_gpaK.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;