chaipro 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (392) hide show
  1. package/README.md +36 -0
  2. package/dist/IconPicker-I7VNLYZ4.js +5 -0
  3. package/dist/actions-DM00SIUk.d.cts +899 -0
  4. package/dist/actions-DM00SIUk.d.ts +899 -0
  5. package/dist/actions-registery-SEJTZE5Q.js +1 -0
  6. package/dist/active-in-another-tab-SONDAONP.js +1 -0
  7. package/dist/add-new-language-page-TI6DUYYX.js +1 -0
  8. package/dist/add-new-page-LBHXICXO.js +1 -0
  9. package/dist/ai-block-floating-prompt-input-ESY5GQLZ.js +1 -0
  10. package/dist/ai-panel-content-62I6FDQF.css +1 -0
  11. package/dist/ai-panel-content-UZJZ463W.js +1 -0
  12. package/dist/ai-panel-default-lang-2ZXZYQRT.js +6 -0
  13. package/dist/ai-panel-default-lang-ETFOFFEF.css +1 -0
  14. package/dist/ai-panel-for-image-LADQP6VY.js +1 -0
  15. package/dist/ai-panel-other-lang-WDLC3M2M.js +1 -0
  16. package/dist/ai-panel-page-chat-7ZISZWY4.js +4 -0
  17. package/dist/ai-panel-page-chat-N4YFJGAM.css +1 -0
  18. package/dist/ai-prompt-input-CPT5ETQ4.js +1 -0
  19. package/dist/ai-theme-generator-7PS4BX52.js +1 -0
  20. package/dist/ai-translation-prompt-3VE2ECGR.js +1 -0
  21. package/dist/blocks-CMvgDlxw.d.ts +72 -0
  22. package/dist/blocks-CP-Pngaz.d.cts +72 -0
  23. package/dist/build-config-CCERdThN.d.ts +80 -0
  24. package/dist/build-config-DrerOPd9.d.cts +80 -0
  25. package/dist/builder.cjs +243 -0
  26. package/dist/builder.css +1 -0
  27. package/dist/builder.d.cts +352 -0
  28. package/dist/builder.d.ts +352 -0
  29. package/dist/builder.js +1 -0
  30. package/dist/chaibuilder-instance-DNz3Q-dY.d.cts +579 -0
  31. package/dist/chaibuilder-instance-qroszVwI.d.ts +579 -0
  32. package/dist/change-password-modal-NJL7ZLTY.js +1 -0
  33. package/dist/chunk-2AFM6557.js +3 -0
  34. package/dist/chunk-2N4IJZOR.js +1 -0
  35. package/dist/chunk-2NYUIXUX.js +1 -0
  36. package/dist/chunk-2PJZUYIZ.js +1 -0
  37. package/dist/chunk-32HH35VD.js +1 -0
  38. package/dist/chunk-346H4FEX.js +1 -0
  39. package/dist/chunk-34HIOUTE.js +1 -0
  40. package/dist/chunk-374QEK4F.js +1 -0
  41. package/dist/chunk-3E72DJSP.js +1 -0
  42. package/dist/chunk-3IT7IIAV.js +1 -0
  43. package/dist/chunk-3UEPBBE4.js +11 -0
  44. package/dist/chunk-3XSKJBPH.js +1 -0
  45. package/dist/chunk-45ELAD2J.js +1 -0
  46. package/dist/chunk-4JBHWPMO.js +1 -0
  47. package/dist/chunk-4P25MV5E.js +1 -0
  48. package/dist/chunk-4PQNBY3V.js +1 -0
  49. package/dist/chunk-4VNLL2IA.js +1 -0
  50. package/dist/chunk-55SU3QPU.js +1 -0
  51. package/dist/chunk-5ZC65NB6.js +1 -0
  52. package/dist/chunk-6M7V7BOM.js +1 -0
  53. package/dist/chunk-6TXCHU4K.js +1 -0
  54. package/dist/chunk-777N6WHB.js +1 -0
  55. package/dist/chunk-7C4EQOAR.js +12 -0
  56. package/dist/chunk-7EXZXKW2.js +1 -0
  57. package/dist/chunk-7QWMLDCG.js +1 -0
  58. package/dist/chunk-AOJE5WI3.js +1 -0
  59. package/dist/chunk-ATLMLDBS.js +1 -0
  60. package/dist/chunk-AVGF3YLU.js +17 -0
  61. package/dist/chunk-BQSLQHLD.js +1 -0
  62. package/dist/chunk-BWORNCTE.js +1 -0
  63. package/dist/chunk-BYGD5CDT.js +1 -0
  64. package/dist/chunk-CA5PVX24.js +1 -0
  65. package/dist/chunk-CFNOB42V.js +1 -0
  66. package/dist/chunk-CJP3BQH2.js +1 -0
  67. package/dist/chunk-CRJENCPR.js +1 -0
  68. package/dist/chunk-D5SKCKSB.js +1 -0
  69. package/dist/chunk-DZ72OHTD.js +1 -0
  70. package/dist/chunk-EPGOG22Q.js +0 -0
  71. package/dist/chunk-ERCY63ZW.js +1 -0
  72. package/dist/chunk-ESCX7KEH.js +1 -0
  73. package/dist/chunk-F2V4N3LT.js +156 -0
  74. package/dist/chunk-F7YMHPEA.js +1 -0
  75. package/dist/chunk-FERH2TPR.js +1 -0
  76. package/dist/chunk-FLSV2QGU.js +1 -0
  77. package/dist/chunk-FOKGOT6B.js +1 -0
  78. package/dist/chunk-GJOOCKUE.js +1 -0
  79. package/dist/chunk-HA7LF3RV.js +1 -0
  80. package/dist/chunk-HAKJOMCL.js +1 -0
  81. package/dist/chunk-HEKCKC7N.js +1 -0
  82. package/dist/chunk-HELRVKD2.js +3 -0
  83. package/dist/chunk-I7ODKVVX.js +1 -0
  84. package/dist/chunk-IAKCX2WB.js +1 -0
  85. package/dist/chunk-IB2C3TWH.js +1 -0
  86. package/dist/chunk-IH562KSP.js +1 -0
  87. package/dist/chunk-IP4JBQOX.js +1 -0
  88. package/dist/chunk-ITX7QWN6.js +1 -0
  89. package/dist/chunk-IUACZ3E6.js +6 -0
  90. package/dist/chunk-J7Q62EP7.js +1 -0
  91. package/dist/chunk-JBB5IJFA.js +1 -0
  92. package/dist/chunk-JPJRO4NU.js +1 -0
  93. package/dist/chunk-JUIS55JT.js +1 -0
  94. package/dist/chunk-JYBTQ3YX.js +5 -0
  95. package/dist/chunk-K5YWQY4U.js +1 -0
  96. package/dist/chunk-K6RHR4HT.js +1 -0
  97. package/dist/chunk-LNV5MRGV.js +1 -0
  98. package/dist/chunk-LRJREWRD.js +1 -0
  99. package/dist/chunk-LWYDGDPW.js +1 -0
  100. package/dist/chunk-MDMGXS5B.js +1 -0
  101. package/dist/chunk-MEROMQQX.js +1 -0
  102. package/dist/chunk-N7Z4RFFI.js +1 -0
  103. package/dist/chunk-NSQEQYEM.js +1 -0
  104. package/dist/chunk-OD3K76M6.js +1 -0
  105. package/dist/chunk-ODSL3KXG.js +1 -0
  106. package/dist/chunk-OJJDRACB.js +1 -0
  107. package/dist/chunk-ONSZ462E.js +1 -0
  108. package/dist/chunk-OQZ4EPOM.js +1 -0
  109. package/dist/chunk-OR7KKUYT.js +1 -0
  110. package/dist/chunk-OSGXFZTA.js +1 -0
  111. package/dist/chunk-PM3JNOZH.js +1 -0
  112. package/dist/chunk-PQHFT4TE.js +1 -0
  113. package/dist/chunk-QGVCH2NI.js +1 -0
  114. package/dist/chunk-QIGSSVEY.js +1 -0
  115. package/dist/chunk-R5ZTCDFD.js +1 -0
  116. package/dist/chunk-RBDZDQZR.js +1 -0
  117. package/dist/chunk-ROQRBSK6.js +1 -0
  118. package/dist/chunk-SSENH35Y.js +1 -0
  119. package/dist/chunk-SYPALJAE.js +1 -0
  120. package/dist/chunk-T2YYNX6Z.js +1 -0
  121. package/dist/chunk-T32TW3XV.js +1 -0
  122. package/dist/chunk-T56KQBE2.js +1 -0
  123. package/dist/chunk-TEL5ACJE.js +1 -0
  124. package/dist/chunk-TGJQC6VC.js +1 -0
  125. package/dist/chunk-TQ34DGOT.js +1 -0
  126. package/dist/chunk-TVF77C53.js +1 -0
  127. package/dist/chunk-UIDBBTCZ.js +3 -0
  128. package/dist/chunk-VKSRWZCO.js +1 -0
  129. package/dist/chunk-VL5WBPVV.js +1 -0
  130. package/dist/chunk-VUWHFLT7.js +22 -0
  131. package/dist/chunk-WEVKAJMV.js +1 -0
  132. package/dist/chunk-WHPIYGCY.js +1 -0
  133. package/dist/chunk-WNESLH23.js +1 -0
  134. package/dist/chunk-WOT6VMZA.js +1 -0
  135. package/dist/chunk-WSQ5SQBD.js +1 -0
  136. package/dist/chunk-XY4UJKHE.js +1 -0
  137. package/dist/chunk-Y2BHO7OO.js +1 -0
  138. package/dist/chunk-YDOQEFOK.js +1 -0
  139. package/dist/chunk-YEFMD4DS.js +1 -0
  140. package/dist/chunk-YQ5QQCRD.js +1 -0
  141. package/dist/chunk-YQPOFRXU.js +1 -0
  142. package/dist/chunk-YTPQSO7V.js +801 -0
  143. package/dist/chunk-ZAU65LBG.js +1 -0
  144. package/dist/chunk-ZRFCEMYU.js +1 -0
  145. package/dist/chunk-ZU2B5YT6.js +1 -0
  146. package/dist/chunk-ZXKKBKGV.js +1 -0
  147. package/dist/code-display-7346IUCO.js +1 -0
  148. package/dist/code-editor-UBGTTX2L.js +1 -0
  149. package/dist/components/ui/accordion.cjs +1 -0
  150. package/dist/components/ui/accordion.d.cts +9 -0
  151. package/dist/components/ui/accordion.d.ts +9 -0
  152. package/dist/components/ui/accordion.js +1 -0
  153. package/dist/components/ui/alert-dialog.cjs +1 -0
  154. package/dist/components/ui/alert-dialog.d.cts +23 -0
  155. package/dist/components/ui/alert-dialog.d.ts +23 -0
  156. package/dist/components/ui/alert-dialog.js +1 -0
  157. package/dist/components/ui/alert.cjs +1 -0
  158. package/dist/components/ui/alert.d.cts +11 -0
  159. package/dist/components/ui/alert.d.ts +11 -0
  160. package/dist/components/ui/alert.js +1 -0
  161. package/dist/components/ui/avatar.cjs +1 -0
  162. package/dist/components/ui/avatar.d.cts +8 -0
  163. package/dist/components/ui/avatar.d.ts +8 -0
  164. package/dist/components/ui/avatar.js +1 -0
  165. package/dist/components/ui/badge.cjs +1 -0
  166. package/dist/components/ui/badge.d.cts +13 -0
  167. package/dist/components/ui/badge.d.ts +13 -0
  168. package/dist/components/ui/badge.js +1 -0
  169. package/dist/components/ui/button.cjs +1 -0
  170. package/dist/components/ui/button.d.cts +15 -0
  171. package/dist/components/ui/button.d.ts +15 -0
  172. package/dist/components/ui/button.js +1 -0
  173. package/dist/components/ui/card.cjs +1 -0
  174. package/dist/components/ui/card.d.cts +10 -0
  175. package/dist/components/ui/card.d.ts +10 -0
  176. package/dist/components/ui/card.js +1 -0
  177. package/dist/components/ui/checkbox.cjs +1 -0
  178. package/dist/components/ui/checkbox.d.cts +6 -0
  179. package/dist/components/ui/checkbox.d.ts +6 -0
  180. package/dist/components/ui/checkbox.js +1 -0
  181. package/dist/components/ui/command.cjs +1 -0
  182. package/dist/components/ui/command.d.cts +83 -0
  183. package/dist/components/ui/command.d.ts +83 -0
  184. package/dist/components/ui/command.js +1 -0
  185. package/dist/components/ui/context-menu.cjs +1 -0
  186. package/dist/components/ui/context-menu.d.cts +30 -0
  187. package/dist/components/ui/context-menu.d.ts +30 -0
  188. package/dist/components/ui/context-menu.js +1 -0
  189. package/dist/components/ui/dialog.cjs +1 -0
  190. package/dist/components/ui/dialog.d.cts +22 -0
  191. package/dist/components/ui/dialog.d.ts +22 -0
  192. package/dist/components/ui/dialog.js +1 -0
  193. package/dist/components/ui/dropdown-menu.cjs +1 -0
  194. package/dist/components/ui/dropdown-menu.d.cts +30 -0
  195. package/dist/components/ui/dropdown-menu.d.ts +30 -0
  196. package/dist/components/ui/dropdown-menu.js +1 -0
  197. package/dist/components/ui/hover-card.cjs +1 -0
  198. package/dist/components/ui/hover-card.d.cts +8 -0
  199. package/dist/components/ui/hover-card.d.ts +8 -0
  200. package/dist/components/ui/hover-card.js +1 -0
  201. package/dist/components/ui/input.cjs +1 -0
  202. package/dist/components/ui/input.d.cts +5 -0
  203. package/dist/components/ui/input.d.ts +5 -0
  204. package/dist/components/ui/input.js +1 -0
  205. package/dist/components/ui/label.cjs +1 -0
  206. package/dist/components/ui/label.d.cts +8 -0
  207. package/dist/components/ui/label.d.ts +8 -0
  208. package/dist/components/ui/label.js +1 -0
  209. package/dist/components/ui/loader.cjs +1 -0
  210. package/dist/components/ui/loader.d.cts +12 -0
  211. package/dist/components/ui/loader.d.ts +12 -0
  212. package/dist/components/ui/loader.js +1 -0
  213. package/dist/components/ui/navigation-menu.cjs +1 -0
  214. package/dist/components/ui/navigation-menu.d.cts +15 -0
  215. package/dist/components/ui/navigation-menu.d.ts +15 -0
  216. package/dist/components/ui/navigation-menu.js +1 -0
  217. package/dist/components/ui/popover.cjs +1 -0
  218. package/dist/components/ui/popover.d.cts +9 -0
  219. package/dist/components/ui/popover.d.ts +9 -0
  220. package/dist/components/ui/popover.js +1 -0
  221. package/dist/components/ui/progress.cjs +1 -0
  222. package/dist/components/ui/progress.d.cts +8 -0
  223. package/dist/components/ui/progress.d.ts +8 -0
  224. package/dist/components/ui/progress.js +1 -0
  225. package/dist/components/ui/scroll-area.cjs +1 -0
  226. package/dist/components/ui/scroll-area.d.cts +7 -0
  227. package/dist/components/ui/scroll-area.d.ts +7 -0
  228. package/dist/components/ui/scroll-area.js +1 -0
  229. package/dist/components/ui/select.cjs +1 -0
  230. package/dist/components/ui/select.d.cts +15 -0
  231. package/dist/components/ui/select.d.ts +15 -0
  232. package/dist/components/ui/select.js +1 -0
  233. package/dist/components/ui/separator.cjs +1 -0
  234. package/dist/components/ui/separator.d.cts +6 -0
  235. package/dist/components/ui/separator.d.ts +6 -0
  236. package/dist/components/ui/separator.js +1 -0
  237. package/dist/components/ui/sheet.cjs +1 -0
  238. package/dist/components/ui/sheet.d.cts +29 -0
  239. package/dist/components/ui/sheet.d.ts +29 -0
  240. package/dist/components/ui/sheet.js +1 -0
  241. package/dist/components/ui/skeleton.cjs +1 -0
  242. package/dist/components/ui/skeleton.d.cts +5 -0
  243. package/dist/components/ui/skeleton.d.ts +5 -0
  244. package/dist/components/ui/skeleton.js +1 -0
  245. package/dist/components/ui/slider.cjs +1 -0
  246. package/dist/components/ui/slider.d.cts +6 -0
  247. package/dist/components/ui/slider.d.ts +6 -0
  248. package/dist/components/ui/slider.js +1 -0
  249. package/dist/components/ui/switch.cjs +1 -0
  250. package/dist/components/ui/switch.d.cts +9 -0
  251. package/dist/components/ui/switch.d.ts +9 -0
  252. package/dist/components/ui/switch.js +1 -0
  253. package/dist/components/ui/tabs.cjs +1 -0
  254. package/dist/components/ui/tabs.d.cts +9 -0
  255. package/dist/components/ui/tabs.d.ts +9 -0
  256. package/dist/components/ui/tabs.js +1 -0
  257. package/dist/components/ui/textarea.cjs +1 -0
  258. package/dist/components/ui/textarea.d.cts +5 -0
  259. package/dist/components/ui/textarea.d.ts +5 -0
  260. package/dist/components/ui/textarea.js +1 -0
  261. package/dist/components/ui/toggle.cjs +1 -0
  262. package/dist/components/ui/toggle.d.cts +15 -0
  263. package/dist/components/ui/toggle.d.ts +15 -0
  264. package/dist/components/ui/toggle.js +1 -0
  265. package/dist/components/ui/tooltip.cjs +1 -0
  266. package/dist/components/ui/tooltip.d.cts +9 -0
  267. package/dist/components/ui/tooltip.d.ts +9 -0
  268. package/dist/components/ui/tooltip.js +1 -0
  269. package/dist/config-registry-RSJCAKY5.js +1 -0
  270. package/dist/continue-editing-in-this-client-QBMOFRLL.js +1 -0
  271. package/dist/core-BNe4bA6z.d.cts +5455 -0
  272. package/dist/core-BNe4bA6z.d.ts +5455 -0
  273. package/dist/css-import-modal-NMFRQGCY.js +13 -0
  274. package/dist/db/better-sqlite3.cjs +1 -0
  275. package/dist/db/better-sqlite3.d.cts +16 -0
  276. package/dist/db/better-sqlite3.d.ts +16 -0
  277. package/dist/db/better-sqlite3.js +1 -0
  278. package/dist/db/d1.cjs +1 -0
  279. package/dist/db/d1.d.cts +17 -0
  280. package/dist/db/d1.d.ts +17 -0
  281. package/dist/db/d1.js +1 -0
  282. package/dist/db/libsql.cjs +1 -0
  283. package/dist/db/libsql.d.cts +23 -0
  284. package/dist/db/libsql.d.ts +23 -0
  285. package/dist/db/libsql.js +1 -0
  286. package/dist/db/node-pg.cjs +1 -0
  287. package/dist/db/node-pg.d.cts +21 -0
  288. package/dist/db/node-pg.d.ts +21 -0
  289. package/dist/db/node-pg.js +1 -0
  290. package/dist/db/postgres.cjs +1 -0
  291. package/dist/db/postgres.d.cts +28 -0
  292. package/dist/db/postgres.d.ts +28 -0
  293. package/dist/db/postgres.js +1 -0
  294. package/dist/delete-page-CGR6VXZC.css +1 -0
  295. package/dist/delete-page-FQYTEMBN.js +1 -0
  296. package/dist/digital-asset-manager-PIZMJEMX.js +1 -0
  297. package/dist/digital-asset-manager-PSTDGMY2.css +1 -0
  298. package/dist/dispatch-action-3IV56BNY.js +1 -0
  299. package/dist/duplicate-page-HPPMQRL3.js +1 -0
  300. package/dist/dynamic-page-selector-LFHJQLYY.js +1 -0
  301. package/dist/dynamic-page-selector-SXJQAIGL.css +1 -0
  302. package/dist/edit-url-panel-Q3NJCV55.js +1 -0
  303. package/dist/get-blocks-styles-SLZ5NDUF.js +1 -0
  304. package/dist/get-page-styles-Q4FWW5LX.js +1 -0
  305. package/dist/image-editor-PLXDYVKE.css +1 -0
  306. package/dist/image-editor-RSEHWRGV.js +1 -0
  307. package/dist/json-diff-viewer-FQYK2FUX.js +8 -0
  308. package/dist/lang-panel-57UGEL6B.css +1 -0
  309. package/dist/lang-panel-HH5LEOF4.js +1 -0
  310. package/dist/license-overlay-4Q525E53.js +1 -0
  311. package/dist/log-ai-request-LHPKU2C5.js +1 -0
  312. package/dist/manage-design-tokens-264H25A2.js +1 -0
  313. package/dist/manage-design-tokens-modal-OIWIZ53K.js +1 -0
  314. package/dist/mark-as-template-7TCCEMGC.js +1 -0
  315. package/dist/nested-path-selector-content-N4XN7QUS.js +1 -0
  316. package/dist/nextjs/render-client.cjs +1 -0
  317. package/dist/nextjs/render-client.css +1 -0
  318. package/dist/nextjs/render-client.d.cts +14 -0
  319. package/dist/nextjs/render-client.d.ts +14 -0
  320. package/dist/nextjs/render-client.js +1 -0
  321. package/dist/nextjs/render.cjs +829 -0
  322. package/dist/nextjs/render.d.cts +78 -0
  323. package/dist/nextjs/render.d.ts +78 -0
  324. package/dist/nextjs/render.js +1 -0
  325. package/dist/nextjs/server.cjs +807 -0
  326. package/dist/nextjs/server.d.cts +329 -0
  327. package/dist/nextjs/server.d.ts +329 -0
  328. package/dist/nextjs/server.js +1 -0
  329. package/dist/nextjs.cjs +1 -0
  330. package/dist/nextjs.d.cts +17 -0
  331. package/dist/nextjs.d.ts +17 -0
  332. package/dist/nextjs.js +1 -0
  333. package/dist/no-language-page-content-NQIROTIL.js +1 -0
  334. package/dist/no-language-page-dialog-CWG5PI7N.js +1 -0
  335. package/dist/page-creator-2L6L6EFV.js +1 -0
  336. package/dist/page-lock-7HMG34UJ.js +1 -0
  337. package/dist/page-locked-dialog-ACMWVAZX.js +1 -0
  338. package/dist/page-manager-new-SCZFNGKO.js +1 -0
  339. package/dist/page-manager-new-VWRASZTI.css +1 -0
  340. package/dist/page-manager-search-and-filter-7CHPYAPV.js +1 -0
  341. package/dist/page-manager-sheet-KZZBKQ6M.js +1 -0
  342. package/dist/page-manager-sheet-U5YEB5CS.css +1 -0
  343. package/dist/page-revisions-content-DHPEQ4CA.js +1 -0
  344. package/dist/page-revisions-trigger-XGC4HOTL.js +1 -0
  345. package/dist/pages-DlMX1Lj2.d.cts +21 -0
  346. package/dist/pages-Dol4CXrN.d.ts +21 -0
  347. package/dist/payload/builder.cjs +243 -0
  348. package/dist/payload/builder.css +1 -0
  349. package/dist/payload/builder.d.cts +13 -0
  350. package/dist/payload/builder.d.ts +13 -0
  351. package/dist/payload/builder.js +1 -0
  352. package/dist/payload.cjs +807 -0
  353. package/dist/payload.d.cts +603 -0
  354. package/dist/payload.d.ts +603 -0
  355. package/dist/payload.js +1 -0
  356. package/dist/preview-banner-SDDZGGRW.js +1 -0
  357. package/dist/publish-pages-content-3AZ45DYH.js +1 -0
  358. package/dist/registry.cjs +11 -0
  359. package/dist/registry.d.cts +74 -0
  360. package/dist/registry.d.ts +74 -0
  361. package/dist/registry.js +1 -0
  362. package/dist/relations-DDBTFCMR.js +1 -0
  363. package/dist/revalidate-G2DEOH4Z.js +1 -0
  364. package/dist/rte-widget-modal-7RXFEYHK.js +1 -0
  365. package/dist/save-to-lib-65EGTZE5.js +1 -0
  366. package/dist/schema-IVNMPI4V.js +1 -0
  367. package/dist/schema.sqlite-CYBLikNv.d.cts +5852 -0
  368. package/dist/schema.sqlite-CYBLikNv.d.ts +5852 -0
  369. package/dist/seo-panel-WQ47FNP4.css +1 -0
  370. package/dist/seo-panel-Z6OBXHQ4.js +2 -0
  371. package/dist/server-config-b29G6_aQ.d.cts +116 -0
  372. package/dist/server-config-oPlt3V1X.d.ts +116 -0
  373. package/dist/state-RAP56WXS.js +1 -0
  374. package/dist/take-over-request-EB464ZGU.js +1 -0
  375. package/dist/translation-warning-modal-EES6I2QV.js +1 -0
  376. package/dist/types.cjs +1 -0
  377. package/dist/types.d.cts +38 -0
  378. package/dist/types.d.ts +38 -0
  379. package/dist/types.js +1 -0
  380. package/dist/unmark-as-template-6STMTBP5.js +1 -0
  381. package/dist/unpublish-page-CE3CJK5C.js +1 -0
  382. package/dist/unpublished-partials-modal-OZBWBCLN.js +1 -0
  383. package/dist/utils.cjs +1 -0
  384. package/dist/utils.d.cts +168 -0
  385. package/dist/utils.d.ts +168 -0
  386. package/dist/utils.js +1 -0
  387. package/dist/web-blocks.cjs +1 -0
  388. package/dist/web-blocks.d.cts +3 -0
  389. package/dist/web-blocks.d.ts +3 -0
  390. package/dist/web-blocks.js +1 -0
  391. package/dist/web-preview-EIWOXGPY.js +1 -0
  392. package/package.json +322 -0
@@ -0,0 +1,243 @@
1
+ "use strict";var UY=Object.create;var nC=Object.defineProperty;var GY=Object.getOwnPropertyDescriptor;var $Y=Object.getOwnPropertyNames;var VY=Object.getPrototypeOf,zY=Object.prototype.hasOwnProperty;var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var et=(e,t)=>{for(var o in t)nC(e,o,{get:t[o],enumerable:!0})},kR=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $Y(t))!zY.call(e,n)&&n!==o&&nC(e,n,{get:()=>t[n],enumerable:!(r=GY(t,n))||r.enumerable});return e};var K=(e,t,o)=>(o=e!=null?UY(VY(e)):{},kR(t||!e||!e.__esModule?nC(o,"default",{value:e,enumerable:!0}):o,e)),WY=e=>kR(nC({},"__esModule",{value:!0}),e);function G(...e){return(0,wR.twMerge)((0,SR.clsx)(e))}var SR,wR,st=x(()=>{"use strict";SR=require("cnfast"),wR=require("cnfast")});var PR,hb,Pn,wt,lf,Oo=x(()=>{"use strict";PR=require("lucide-react");st();hb=require("react/jsx-runtime"),Pn=({children:e=null,className:t=""})=>(0,hb.jsx)("div",{className:G("fixed bottom-0 left-0 right-0 top-[40px] z-[20] flex w-screen flex-col items-center justify-center bg-gradient-to-b from-background/70 to-background/40 backdrop-blur transition-all",t),children:e}),wt=({className:e=""})=>(0,hb.jsx)(PR.Loader,{className:G("h-5 w-5 animate-spin text-foreground/90",e)}),lf=()=>(0,hb.jsx)("div",{className:"bg-surface fixed inset-0 z-[20] flex w-screen flex-col items-center justify-center transition-all",children:(0,hb.jsx)(wt,{})})});var TR,NR,ER,cf,yb,E,J=x(()=>{"use strict";TR=require("@radix-ui/react-slot"),NR=require("class-variance-authority"),ER=K(require("react"),1);Oo();st();cf=require("react/jsx-runtime"),yb=(0,NR.cva)("group/button cursor-pointer duration-300 inline-flex shrink-0 items-center justify-center rounded border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary hover:bg-primary/80 text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted/30 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-4 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}}),E=ER.forwardRef(({className:e,variant:t,size:o,asChild:r=!1,loading:n=!1,children:a,disabled:s,...i},l)=>{let c=r?TR.Slot:"button";return r?(0,cf.jsx)(c,{className:G(yb({variant:t,size:o,className:e})),ref:l,...i,children:a}):(0,cf.jsxs)(c,{className:G(yb({variant:t,size:o,className:e})),ref:l,disabled:s||n,...i,children:[n&&(0,cf.jsx)(wt,{className:"absolute h-4 w-4 text-primary-foreground"}),n?(0,cf.jsx)("span",{className:"opacity-0",children:a}):a]})});E.displayName="Button"});var _l,WT,aC,en,$r,Vr,Rs=x(()=>{"use strict";_l=K(require("@radix-ui/react-popover"),1),WT=K(require("react"),1);st();aC=require("react/jsx-runtime"),en=_l.Root,$r=WT.forwardRef(({className:e,...t},o)=>(0,aC.jsx)(_l.Trigger,{ref:o,className:G("outline-none focus:outline-none focus:ring-0",e),...t}));$r.displayName=_l.Trigger.displayName;Vr=WT.forwardRef(({className:e,align:t="center",sideOffset:o=4,...r},n)=>(0,aC.jsx)(_l.Portal,{children:(0,aC.jsx)(_l.Content,{ref:n,align:t,sideOffset:o,className:G("z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-md border bg-popover p-2 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));Vr.displayName=_l.Content.displayName});var Ll,AR,jT,df,Fo,Ho,Bo,rs=x(()=>{"use strict";Ll=K(require("@radix-ui/react-tooltip"),1),AR=K(require("react"),1);st();jT=require("react/jsx-runtime"),df=Ll.Provider,Fo=Ll.Root,Ho=Ll.Trigger,Bo=AR.forwardRef(({className:e,sideOffset:t=4,alignOffset:o=0,...r},n)=>(0,jT.jsx)(Ll.Portal,{children:(0,jT.jsx)(Ll.Content,{ref:n,alignOffset:o,sideOffset:t,className:G("z-50 origin-[--radix-tooltip-content-transform-origin] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-xl animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),side:r.side||"top",children:r.children})}));Bo.displayName=Ll.Content.displayName});var _n,IR,bb,mi,Te,pf,jY,BR,we,Oe,co,Ie,Dt,qt=x(()=>{"use strict";"use client";_n=K(require("@radix-ui/react-dialog"),1),IR=require("@radix-ui/react-icons"),bb=K(require("react"),1);st();mi=require("react/jsx-runtime"),Te=_n.Root,pf=_n.Trigger,jY=_n.Portal,BR=bb.forwardRef(({className:e,...t},o)=>(0,mi.jsx)(_n.Overlay,{ref:o,className:G("fixed inset-0 z-50 bg-muted/30 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 dark:bg-accent/5",e),...t}));BR.displayName=_n.Overlay.displayName;we=bb.forwardRef(({className:e,children:t,...o},r)=>(0,mi.jsxs)(jY,{children:[(0,mi.jsx)(BR,{}),(0,mi.jsxs)(_n.Content,{ref:r,className:G("bg-surface fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 overflow-hidden border border-border p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...o,children:[t,(0,mi.jsxs)(_n.Close,{className:"ring-offset-surface absolute right-4 top-4 rounded-sm text-foreground opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,mi.jsx)(IR.Cross1Icon,{className:"h-4 w-4"}),(0,mi.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));we.displayName=_n.Content.displayName;Oe=({className:e,...t})=>(0,mi.jsx)("div",{className:G("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Oe.displayName="DialogHeader";co=({className:e,...t})=>(0,mi.jsx)("div",{className:G("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});co.displayName="DialogFooter";Ie=bb.forwardRef(({className:e,...t},o)=>(0,mi.jsx)(_n.Title,{ref:o,className:G("text-lg font-semibold leading-none tracking-tight text-foreground",e),...t}));Ie.displayName=_n.Title.displayName;Dt=bb.forwardRef(({className:e,...t},o)=>(0,mi.jsx)(_n.Description,{ref:o,className:G("text-sm font-light text-muted-foreground",e),...t}));Dt.displayName=_n.Description.displayName});var RR,ns,zp,Ki,Yi,Md,Ji,Ml,Wp,qT,as,DR,jp=x(()=>{"use strict";RR=require("@radix-ui/react-icons"),ns=require("cmdk"),zp=K(require("react"),1);qt();st();Ki=require("react/jsx-runtime"),Yi=zp.forwardRef(({className:e,...t},o)=>(0,Ki.jsx)(ns.Command,{ref:o,className:G("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Yi.displayName=ns.Command.displayName;Md=zp.forwardRef(({className:e,...t},o)=>(0,Ki.jsxs)("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[(0,Ki.jsx)(ns.Command.Input,{ref:o,className:G("flex h-8 w-full rounded-md border border-input bg-transparent px-0 py-1 text-xs text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...t}),(0,Ki.jsx)(RR.MagnifyingGlassIcon,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"})]}));Md.displayName=ns.Command.Input.displayName;Ji=zp.forwardRef(({className:e,...t},o)=>(0,Ki.jsx)(ns.Command.List,{ref:o,className:G("overflow-y-auto overflow-x-hidden",e),...t}));Ji.displayName=ns.Command.List.displayName;Ml=zp.forwardRef((e,t)=>(0,Ki.jsx)(ns.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Ml.displayName=ns.Command.Empty.displayName;Wp=zp.forwardRef(({className:e,...t},o)=>(0,Ki.jsx)(ns.Command.Group,{ref:o,className:G("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Wp.displayName=ns.Command.Group.displayName;qT=zp.forwardRef(({className:e,...t},o)=>(0,Ki.jsx)(ns.Command.Separator,{ref:o,className:G("-mx-1 h-px bg-border",e),...t}));qT.displayName=ns.Command.Separator.displayName;as=zp.forwardRef(({className:e,...t},o)=>(0,Ki.jsx)(ns.Command.Item,{ref:o,className:G("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1 text-sm font-light outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));as.displayName=ns.Command.Item.displayName;DR=({className:e,...t})=>(0,Ki.jsx)("span",{className:G("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});DR.displayName="CommandShortcut"});var MR={};et(MR,{default:()=>LR});function LR({data:e,onSelect:t,dataType:o="value",open:r,setOpen:n}){let{t:a}=(0,_R.useTranslation)(),[s,i]=Tc.useState([]),[l,c]=Tc.useState(e);Tc.useEffect(()=>{r||i([]),c(e)},[e,r]);let d=g=>Array.isArray(g)?"array":typeof g=="object"&&g!==null?"object":"value",p=Tc.useCallback(g=>{let h=f=>o==="value"?f==="value"||f==="object":o==="array"?f==="array":f===o;g.type==="object"?(i(f=>[...f,g.key]),c(g.value)):h(g.type)&&(t([...s,g.key].join(".")),n(!1))},[o,t,s,n]),u=Tc.useCallback(()=>{if(s.length>0){let g=s.slice(0,-1);i(g),c(g.reduce((h,f)=>h[f],e))}},[s,e]),m=Tc.useMemo(()=>Object.entries(l).map(([g,h])=>({key:g,value:h,type:d(h)})).filter(g=>o==="value"?g.type==="value"||g.type==="object":o==="array"?g.type==="array"||g.type==="object":o==="object"?g.type==="object":!0),[l,o]);return(0,La.jsx)(Vr,{className:"z-[9999] w-[200px] p-0",children:(0,La.jsxs)(Yi,{children:[(0,La.jsx)(Md,{className:"border-none",placeholder:"Search..."}),(0,La.jsxs)(Ji,{onWheel:g=>{try{g.preventDefault();let h=g.currentTarget;h.scrollTop+=g.deltaY}catch(h){g.preventDefault()}},children:[(0,La.jsx)(Ml,{className:"flex h-24 items-center justify-center text-xs text-muted",children:a("No option found.")}),(0,La.jsxs)(Wp,{children:[s.length>0&&(0,La.jsxs)(as,{onSelect:u,className:"flex items-center gap-2 text-xs text-muted",children:[(0,La.jsx)(sC.ChevronLeftIcon,{className:"!h-3 !w-3"}),a("Back")]}),m.map(g=>(0,La.jsxs)(as,{onSelect:()=>p(g),className:"flex items-center justify-between text-xs",children:[(0,La.jsxs)("span",{className:"flex items-center gap-2",children:[(0,La.jsx)("div",{className:"h-px w-3 rounded-full border-b border-b-foreground bg-transparent font-light opacity-10"}),g.key]}),(0,La.jsxs)("div",{className:"flex items-center gap-2",children:[o==="object"&&g.type==="object"&&(0,La.jsx)(E,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:h=>{h.stopPropagation(),t([...s,g.key].join(".")),n(!1)},children:"Select"}),(g.type==="object"||g.type==="array")&&(0,La.jsx)(sC.ChevronRight,{className:"h-3 w-3 opacity-50"})]})]},g.key))]})]})]})})}var sC,Tc,_R,La,OR=x(()=>{"use strict";"use client";sC=require("lucide-react"),Tc=K(require("react"),1),_R=require("react-i18next");J();jp();Rs();La=require("react/jsx-runtime")});function Nc({data:e,onSelect:t,dataType:o="value",disabled:r=!1}){let[n,a]=mf.useState(!1);return(0,Qi.jsxs)(en,{open:n,onOpenChange:a,children:[(0,Qi.jsxs)(Fo,{children:[(0,Qi.jsx)(Ho,{asChild:!0,children:(0,Qi.jsx)($r,{asChild:!0,children:(0,Qi.jsx)(E,{size:"icon-xs",variant:"ghost",role:"combobox","aria-expanded":n,disabled:r,children:(0,Qi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:(0,Qi.jsx)("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),(0,Qi.jsx)(Bo,{children:"Add field"})]}),n&&(0,Qi.jsx)(mf.Suspense,{children:(0,Qi.jsx)(qY,{data:e,onSelect:t,dataType:o,open:n,setOpen:a})})]})}var mf,Qi,qY,KT=x(()=>{"use strict";"use client";mf=K(require("react"),1);J();Rs();rs();Qi=require("react/jsx-runtime"),qY=mf.lazy(()=>Promise.resolve().then(()=>(OR(),MR)))});var lr,Ru,Tn=x(()=>{"use strict";lr="#styles:",Ru="__ADD_BLOCK_INTERNAL_ROOT"});function Uo(e=6){return(0,UR.nanoid)(e)}var FR,HR,UR,GR,iC,Co,pn=x(()=>{"use strict";FR=require("cnfast"),HR=require("lodash-es"),UR=require("nanoid"),GR=require("cnfast");iC=e=>e>=1536?"2XL":e>=1280?"XL":e>=1024?"LG":e>=768?"MD":e>=640?"SM":"XS",Co=(...e)=>(0,GR.twMerge)((0,FR.clsx)(e))});function VR(e,t,o){let r=(0,ui.filter)(e,a=>a._parent===t),n=[];for(let a=0;a<r.length;a++)if((0,ui.filter)(e,{_parent:r[a]._id}).length>0){let s=Uo();n.push({...r[a],oldId:r[a]._id,_id:s,_parent:o}),n.push((0,ui.flatten)(VR(e,r[a]._id,s)))}else n.push({...r[a],oldId:r[a]._id,_id:Uo(),_parent:o});return(0,ui.flatten)(n)}function cC(e){let t={};e.forEach(r=>{t[r._id]={...r,children:[]}});let o=[];return e.forEach(r=>{if(r._parent){let n=t[r._parent];n&&n.children.push(t[r._id])}else o.push(t[r._id])}),o}var ui,lC,$R,xb,uf=x(()=>{"use strict";ui=require("lodash-es");pn();lC=e=>{let t=new Map;return e.forEach(o=>{if(!(0,ui.has)(o,"_id"))return;let r=o._parent||null,n=t.get(r);n||(n=[],t.set(r,n)),n.push({_id:o._id,_type:o._type})}),t},$R=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let[o,r]of e){let n=t.get(o);if(!n||n.length!==r.length)return!1;for(let a=0;a<r.length;a++)if(r[a]._id!==n[a]._id||r[a]._type!==n[a]._type)return!1}return!0};xb=(e,t,o=null)=>{let r=(0,ui.find)(e,{_id:t});r={...r,oldId:r._id,_id:Uo()},o!==(r==null?void 0:r._parent)&&(r={...r,_parent:o});let n=[r];return(0,ui.filter)(e,{_parent:t}).length>0&&n.push((0,ui.flatten)(VR(e,t,r._id))),(0,ui.flatten)(n)}});var Ma,vb,qp,Ot,KY,zR,YT,Kp,Yp,JT,QT,YY,JY,WR,QY,Ec,Du,_u,Lu,XT,ZT,e0,zr=x(()=>{"use strict";Ma=require("jotai"),vb=require("jotai/utils"),qp=require("lodash-es");uf();Ot=(0,Ma.atom)([]);Ot.debugLabel="presentBlocksAtom";KY=["_id","_parent","_type","_name","tag","_show","_libBlockId"],zR=(0,vb.selectAtom)(Ot,e=>e.map(t=>(0,qp.pick)(t,KY)),(e,t)=>e.length===t.length&&e.every((o,r)=>(0,qp.isEqual)(o,t[r])));zR.debugLabel="outlineBlocksAtom";YT=(0,Ma.atom)(e=>cC(e(zR)));YT.debugLabel="treeDSBlocks";Kp=(0,vb.splitAtom)(Ot);Kp.debugLabel="pageBlocksAtomsAtom";Yp=(0,Ma.atom)(e=>{let t=e(Ot),o=e(Kp),r=new Map;return t.forEach((n,a)=>r.set(n._id,o[a])),r});Yp.debugLabel="blockAtomsMapAtom";JT=(0,vb.selectAtom)(Ot,lC,$R);JT.debugLabel="blockChildrenMapAtom";QT=(0,Ma.atom)(e=>e(Ot).length>0);QT.debugLabel="hasPageBlocksAtom";YY=(0,Ma.atom)("");YY.debugLabel="builderActivePageAtom";JY=(0,Ma.atom)(-1);JY.debugLabel="destinationDropIndexAtom";WR=(0,Ma.atom)([]);WR.debugLabel="buildingBlocksAtom";QY=(0,Ma.atom)(e=>{let t=e(WR);return(0,qp.filter)(t,o=>(0,qp.has)(o,"blockId"))});QY.debugLabel="globalBlocksAtom";Ec=(0,Ma.atom)([]);Ec.debugLabel="structureErrorsAtom";Du=(0,Ma.atom)(!0);Du.debugLabel="structureValidationValidAtom";_u=(0,Ma.atom)(!1);_u.debugLabel="hasStructureErrorsAtom";Lu=(0,Ma.atom)(!1);Lu.debugLabel="hasStructureWarningsAtom";XT=(0,Ma.atom)(e=>e(Ec).filter(o=>o.severity==="error").length);XT.debugLabel="structureErrorCountAtom";ZT=(0,Ma.atom)(e=>e(Ec).filter(o=>o.severity==="warning").length);ZT.debugLabel="structureWarningCountAtom";e0=(0,Ma.atom)(e=>{let t=e(Ec),o={};return t.forEach(r=>{r.blockId&&(o[r.blockId]||(o[r.blockId]=[]),o[r.blockId].push(r))}),o});e0.debugLabel="structureErrorsByBlockAtom"});var jR,be,Od,Jn=x(()=>{"use strict";jR=require("jotai");zr();be=(0,jR.getDefaultStore)(),Od=()=>be.get(Ot)});var dC,Ol,Xi,Jp,Mu,Fd,Ac=x(()=>{"use strict";dC=require("jotai"),Ol=(0,dC.atom)(null),Xi=(0,dC.atom)({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0}),Jp=!1,Mu=e=>{Jp=e},Fd=(0,dC.atom)(0)});var t0,gf,pC=x(()=>{"use strict";t0={fontFamily:{"font-heading":"Arial","font-body":"Arial"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},gf={fontFamily:{heading:"Arial",body:"Arial"},borderRadius:"0.5rem",colors:{background:["#FFFFFF","#242424"],foreground:["#0A0A0B","#FAFAFA"],primary:["#155DFC","#155DFC"],"primary-foreground":["#FAFAFA","#FFFFFF"],secondary:["#F4F4F5","#202020"],"secondary-foreground":["#18181B","#FAFAFA"],muted:["#F4F4F5","#929292"],"muted-foreground":["#71717A","#A3A3A3"],accent:["#F4F4F5","#333333"],"accent-foreground":["#18181B","#FAFAFA"],destructive:["#EF4444","#8c3434"],"destructive-foreground":["#FAFAFA","#FAFAFA"],border:["#E4E4E7","#333333"],input:["#E4E4E7","#333333"],ring:["#18181B","#1E90FF"],card:["#FFFFFF","#242424"],"card-foreground":["#0A0A0B","#FAFAFA"],popover:["#FFFFFF","#242424"],"popover-foreground":["#0A0A0B","#FAFAFA"]}}});var Sa,mC,XY,ZY,Qie,eJ,tJ,oJ,gi,rJ,o0,nJ,Cb,aJ,r0,sJ,iJ,lJ,kb,Sb,qR,Oa=x(()=>{"use strict";Sa=require("jotai"),mC=require("jotai/utils");pC();XY=(0,Sa.atom)(!1);XY.debugLabel="readOnlyModeAtom";ZY=(0,Sa.atom)("online");ZY.debugLabel="networkModeAtom";Qie=(0,Sa.atom)(""),eJ=(0,Sa.atom)(!1);eJ.debugLabel="editLayerNameAtom";tJ=(0,Sa.atom)("");tJ.debugLabel="activeLanguageAtom";oJ=(0,Sa.atom)("");oJ.debugLabel="primaryLanguageAtom";gi=(0,Sa.atom)(null);gi.debugLabel="canvasIframeAtom";rJ=(0,Sa.atom)("outline");rJ.debugLabel="activePanelAtom";o0=(0,Sa.atom)("");o0.debugLabel="showPredefinedBlockCategoryAtom";nJ=(0,Sa.atom)(!1);nJ.debugLabel="draggingFlagAtom";Cb=(0,Sa.atom)(null);Cb.debugLabel="treeRefAtom";aJ=(0,Sa.atom)({});aJ.debugLabel="canvasSettingsAtom";r0=(0,Sa.atom)(!1);r0.debugLabel="aiAssistantActiveAtom";sJ=(0,Sa.atom)(!1);sJ.debugLabel="codeEditorOpenAtom";iJ=(0,mC.atomWithStorage)("codeEditorHeight",500);iJ.debugLabel="codeEditorHeightAtom";lJ=(0,Sa.atom)([]);lJ.debugLabel="xShowBlocksAtom";kb=(0,mC.atomWithStorage)("_selectedLibrary",null);kb.debugLabel="selectedLibraryAtom";Sb=(0,Sa.atom)(!0);Sb.debugLabel="dataBindingActiveAtom";qR=(0,mC.atomWithStorage)("chai-builder-theme",gf)});var fi,cJ,dJ,n0,Ic,uC=x(()=>{"use strict";fi=e=>{let t=e.closest('[data-block-type="PartialBlock"]');return(t==null?void 0:t.getAttribute("data-block-id"))||void 0},cJ=[{name:"no-nested-div-in-p",description:"Prevents div elements from being nested inside paragraph elements",validate:e=>{let t=[];return e.querySelectorAll('p [data-block-type="Box"]').forEach(r=>{let n=r.getAttribute("data-block-id");n&&t.push({id:`div-in-paragraph-${n}`,message:"Box (div) cannot be nested inside Paragraph elements",severity:"error",blockId:n,partialBlockId:fi(r)})}),t}},{name:"no-interactive-nesting",description:"Prevents interactive elements (links, buttons with href) from being nested inside other interactive elements",validate:e=>{let t=[];return e.querySelectorAll('[data-block-type="Link"] [data-block-type="Link"]').forEach(n=>{let a=n.getAttribute("data-block-id");a&&t.push({id:`nested-interactive-link-${a}`,message:"Link cannot be nested inside another interactive element (link or button with link)",severity:"error",blockId:a,partialBlockId:fi(n)})}),e.querySelectorAll('button [data-block-type="Link"]').forEach(n=>{let a=n.getAttribute("data-block-id");a&&t.push({id:`nested-interactive-link-in-button-${a}`,message:"Link cannot be nested inside another interactive element (link or button with link)",severity:"error",blockId:a,partialBlockId:fi(n)})}),t}},{name:"listitem-in-list",description:"Ensures ListItems are only inside List containers",validate:e=>{let t=[];return e.querySelectorAll('li[data-block-type="ListItem"]').forEach(r=>{if(!r.closest("ul, ol")){let a=r.getAttribute("data-block-id");a&&t.push({id:`listitem-outside-list-${a}`,message:"List Item must be inside a List container",severity:"error",blockId:a,partialBlockId:fi(r)})}}),t}},{name:"table-cell-structure",description:"Validates proper table hierarchy (TableCell -> TableRow -> TableHead/Body -> Table)",validate:e=>{let t=[];return e.querySelectorAll('td[data-block-type="TableCell"], th[data-block-type="TableCell"]').forEach(a=>{let s=a.closest("tr")!==null,i=a.closest("thead, tbody")!==null,l=a.closest("table")!==null;if(!s||!i||!l){let c=a.getAttribute("data-block-id");c&&t.push({id:`table-cell-structure-${c}`,message:"Table Cell must be inside a Table Row, which must be inside Table Head/Body, which must be inside a Table",severity:"error",blockId:c,partialBlockId:fi(a)})}}),e.querySelectorAll('tr[data-block-type="TableRow"]').forEach(a=>{if(!(a.closest("table")!==null)){let i=a.getAttribute("data-block-id");i&&t.push({id:`table-row-outside-table-${i}`,message:"Table Row must be inside a Table (Table Head or Table Body)",severity:"error",blockId:i,partialBlockId:fi(a)})}}),e.querySelectorAll('thead[data-block-type="TableHead"], tbody[data-block-type="TableBody"]').forEach(a=>{if(!(a.closest("table")!==null)){let i=a.getAttribute("data-block-id");i&&t.push({id:`table-section-outside-table-${i}`,message:"Table Head/Body must be inside a Table",severity:"error",blockId:i,partialBlockId:fi(a)})}}),t}},{name:"no-nested-buttons",description:"Prevents buttons from being nested inside other buttons",validate:e=>{let t=[];return e.querySelectorAll('button button[data-block-type="Button"]').forEach(r=>{let n=r.getAttribute("data-block-id");n&&t.push({id:`nested-button-${n}`,message:"Button cannot be nested inside another button",severity:"error",blockId:n,partialBlockId:fi(r)})}),t}},{name:"no-nested-forms",description:"Prevents forms from being nested inside other forms",validate:e=>{let t=[];return e.querySelectorAll('[data-block-type="Form"] [data-block-type="Form"]').forEach(r=>{let n=r.getAttribute("data-block-id");n&&t.push({id:`nested-form-${n}`,message:"Form cannot be nested inside another form",severity:"error",blockId:n,partialBlockId:fi(r)})}),t}},{name:"no-nested-paragraphs",description:"Prevents paragraph elements from being nested inside other paragraph elements at any level",validate:e=>{let t=[];return e.querySelectorAll('p p[data-block-type="Paragraph"]').forEach(r=>{let n=r.getAttribute("data-block-id");n&&t.push({id:`nested-paragraph-${n}`,message:"Paragraph cannot be nested inside another paragraph",severity:"error",blockId:n,partialBlockId:fi(r)})}),t}},{name:"heading-structure",description:"Checks for proper heading hierarchy and warns about skipped levels",validate:e=>{let t=[],o=[];e.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(n=>{if(n.getAttribute("data-block-type")==="Heading"){let s=n.tagName.toLowerCase(),i=parseInt(s.replace("h",""))||2,l=n.getAttribute("data-block-id");l&&o.push({level:i,blockId:l,element:n})}});for(let n=1;n<o.length;n++){let a=o[n],s=o[n-1];a.level>s.level+1&&t.push({id:`heading-level-skip-${a.blockId}`,message:`Heading level skipped: h${s.level} followed by h${a.level}. Consider using h${s.level+1}`,severity:"warning",blockId:a.blockId,partialBlockId:fi(a.element)})}return t}}],dJ=[{name:"image-alt-text",description:"Warns if images are missing alt text",validate:e=>{let t=[];return e.querySelectorAll('img[data-block-type="Image"]').forEach(r=>{let n=r.getAttribute("alt");if(!n||n.trim()===""){let a=r.getAttribute("data-block-id");a&&t.push({id:`image-missing-alt-${a}`,message:"Image should have alt text for accessibility",severity:"warning",blockId:a,partialBlockId:fi(r)})}}),t}},{name:"button-accessibility",description:"Ensures buttons have accessible labels",validate:e=>{let t=[];return e.querySelectorAll('button[data-block-type="Button"]').forEach(r=>{let n=r.textContent&&r.textContent.trim()!=="",a=r.children.length>0,s=(()=>{let l=r.getAttribute("aria-label");return l!==null&&l.trim()!==""})(),i=r.hasAttribute("aria-labelledby");if(!n&&!a&&!s&&!i){let l=r.getAttribute("data-block-id");l&&t.push({id:`button-no-label-${l}`,message:"Button should have accessible content (text or icon)",severity:"warning",blockId:l,partialBlockId:fi(r)})}}),t}}],n0=class{constructor(){this.rules=[...cJ]}addRule(t){this.rules.push(t)}removeRule(t){let o=this.rules.findIndex(r=>r.name===t);return o>-1?(this.rules.splice(o,1),!0):!1}getRules(){return[...this.rules]}enableAccessibilityRules(){this.rules.push(...dJ)}getRuleNames(){return this.rules.map(t=>t.name)}},Ic=new n0});var KR,Ou,YR,gC,JR,fC=x(()=>{"use strict";KR=require("@react-hookz/web"),Ou=require("jotai"),YR=require("react");zr();Oa();Ke();uC();uC();gC=(e={})=>{let t=q("flags.validateStructure",!0),o=(0,Ou.useAtomValue)(gi),r=(0,Ou.useSetAtom)(Ec),n=(0,Ou.useSetAtom)(Du),a=(0,Ou.useSetAtom)(_u),s=(0,Ou.useSetAtom)(Lu),i=(0,YR.useCallback)(()=>{var h;if(!t||!o)return;let c=o.contentDocument||((h=o.contentWindow)==null?void 0:h.document);if(!c)return;let d=[],p=Ic.getRules();e.enableAccessibilityRules&&(Ic.enableAccessibilityRules(),p=Ic.getRules()),e.customRules&&e.customRules.length>0&&p.push(...e.customRules),p.forEach(f=>{try{let b=f.validate(c);d.push(...b)}catch(b){console.error(`Error running structure rule "${f.name}":`,b)}});let u=d.filter(f=>f.severity==="error").length>0,m=d.filter(f=>f.severity==="warning").length>0,g=!u;r(d),n(g),a(u),s(m)},[t,o,e,r,n,a,s]);return(0,KR.useDebouncedCallback)(i,[t,o,e,r,n,a,s],500)},JR=(e,t={})=>{if(!e)return[];let o=[],r=Ic.getRules();return t.enableAccessibilityRules&&(Ic.enableAccessibilityRules(),r=Ic.getRules()),t.customRules&&t.customRules.length>0&&r.push(...t.customRules),r.forEach(n=>{try{let a=n.validate(e);o.push(...a)}catch(a){console.error(`Error running structure rule "${n.name}":`,a)}}),o}});var hC,pJ,QR,XR=x(()=>{"use strict";hC=require("jotai"),pJ=(0,hC.atom)(null),QR=()=>({currentPage:(0,hC.useAtomValue)(pJ)})});var cr,mJ,Bc,Fu,Ct,yC,Fl,uJ,ZR,eD,bC,gJ,fJ,hi,hJ,_t,a0,tD=x(()=>{"use strict";cr=require("lodash-es"),mJ=require("react"),Bc={},Fu=()=>Bc,Ct=e=>(0,cr.get)(Bc,e),yC=e=>{let t=(0,cr.memoize)(e),o=(r=>(0,cr.has)(Bc,r)?t(r):e(r));return o.cache=t.cache,o},Fl=yC(e=>{var a,s;let t=(0,cr.get)(Bc,e),o=(s=(a=t==null?void 0:t.props)==null?void 0:a.schema)!=null?s:{},r=(0,cr.get)(o,"properties",{}),n={};return(0,cr.each)(r,(i,l)=>{(0,cr.has)(i,"block")||(0,cr.set)(n,l,i.default)}),n}),uJ=yC(e=>(0,cr.get)(Bc,`${e}.i18nProps`,[])),ZR=yC(e=>(0,cr.get)(Bc,`${e}.aiProps`,[])),eD=yC(e=>{var l,c,d,p;let t=Ct(e);if(!t)return;let o=(c=(l=t.props)==null?void 0:l.schema)!=null?c:{},r=(p=(d=t.props)==null?void 0:d.uiSchema)!=null?p:{},n=(0,cr.cloneDeep)(o),a=(0,cr.get)(n,"properties",{}),s=(0,cr.omitBy)(a,u=>(u==null?void 0:u.styles)===!0);return(0,cr.set)(n,"properties",s),{schema:n,uiSchema:r||{}}}),bC=e=>{let t=eD(e);if(t)return{schema:(0,cr.cloneDeep)(t.schema),uiSchema:(0,cr.cloneDeep)(t.uiSchema)}},gJ=[Fl,uJ,ZR,eD],fJ=e=>{for(let t of gJ)t.cache.delete(e)},hi=e=>e.map(t=>(0,cr.has)(Bc,t._type)?{...Fl(t._type),...t}:t),hJ=(e,t)=>{let o=(0,cr.get)(Bc,t.type);o?(0,cr.set)(Bc,t.type,{...o,component:e,...t}):(0,cr.set)(Bc,t.type,{component:e,...t}),fJ(t.type)},_t=(e,t)=>{hJ(e,{...t,category:t.category||"core"})},a0=(e,t)=>({type:"null",block:e,prop:t,default:null,runtime:!0,ui:{"ui:widget":"hidden"}})});var wb,oD=x(()=>{"use strict";wb=require("lodash-es");Ne()});var rD,ff,hf,nD=x(()=>{"use strict";oD();rD=[{family:"Arial",fallback:"Helvetica, sans-serif"},{family:"Times New Roman",fallback:"Georgia, serif"},{family:"Courier New",fallback:"Courier, monospace"}],ff=()=>rD,hf=()=>rD});var aD=x(()=>{"use strict";tD();nD()});var wa,Be,Re,Ne=x(()=>{"use strict";wa=require("lodash-es");Tn();aD();Be=e=>{let t=["_type","_id","_parent","_bindings","_name"],o=["$loading","blockProps","inBuilder","lang","draft","pageProps","pageData","children"],r=(0,wa.keys)(e.properties);if((0,wa.intersection)(r,t).length>0)throw new Error(`Reserved props are not allowed: ${(0,wa.intersection)(r,t).join(", ")}`);if((0,wa.intersection)(r,o).length>0)throw new Error(`Runtime props are not allowed in schema: ${(0,wa.intersection)(r,o).join(", ")}`);let n=(0,wa.get)(e,"properties",{}),a={};return(0,wa.each)(n,(s,i)=>{(0,wa.isEmpty)(s.ui)||(a[i]={...s.ui},delete n[i].ui)}),{schema:(0,wa.isEmpty)(n)?{}:{...(0,wa.omit)(e,["ui"])},uiSchema:{...(0,wa.get)(e,"ui",{}),...a}}},Re=(e="")=>({type:"string",styles:!0,default:`${lr},${e}`,ui:{"ui:widget":"hidden"}})});var Zi,sD,yJ,yf,xC=x(()=>{"use strict";Zi=require("lodash-es"),sD=require("react");ko();XR();Ne();yJ=(0,Zi.memoize)(e=>{let t=Ct(e),o=(0,Zi.get)(t,"schema.properties",{});return(0,Zi.compact)(Object.keys(o).map(r=>(0,Zi.get)(o[r],"builderProp",!1)||(0,Zi.get)(o[r],"runtime",!1)?r:null))}),yf=()=>{let{currentPage:e}=QR(),[t]=Pt();return(0,sD.useCallback)(()=>{let o=(0,Zi.map)(t,r=>(0,Zi.omit)(r,yJ(r._type)));return{currentPage:e,blocks:o}},[e,t])}});var vC,Pb,iD,CC=x(()=>{"use strict";vC=require("jotai"),Pb=(0,vC.atom)(!1),iD=()=>(0,vC.useAtom)(Pb)});function bJ(e){let t=e.indexOf(":");return t===-1?e:e.slice(0,t)}var lD,kt,mn=x(()=>{"use strict";lD=require("react");Ke();kt=()=>{let e=q("permissions",null);return{hasPermission:(0,lD.useCallback)(o=>e?e.length===0?!1:e.includes("*")||e.includes(o)?!0:e.includes(`${bJ(o)}:*`):!0,[e])}}});var Qp,xJ,bf,vJ,CJ,s0=x(()=>{"use strict";Qp={},xJ=(e,t)=>{Qp[e]||(Qp[e]=[]),Qp[e].push(t)},bf=async(e,t,o)=>{let r=Qp[e]||[],n=t;for(let a of r)try{let s=await a(n,o);s!==void 0&&(n=s)}catch(s){console.error(`[ChaiBuilder] Error in hook "${e}":`,s)}return n},vJ=e=>Qp[e]||[],CJ=e=>{e?delete Qp[e]:Object.keys(Qp).forEach(t=>{delete Qp[t]})}});var Tb,cD=x(()=>{"use strict";Tb={BEFORE_SAVE_PAGE:"before:save:page",AFTER_SAVE_PAGE:"after:save:page"}});var i0,Rc,kC,xf=x(()=>{"use strict";i0=require("jotai"),Rc=(0,i0.atom)({}),kC=(0,i0.atom)({})});function Eb(e,t,o,r=new Set){if(e===t)return!0;if(r.has(t))return!1;r.add(t);let n=o[t]||[];for(let a of n)if(a===e||Eb(e,a,o,r))return!0;return!1}function Cf(e,t,o=new Set){if(o.has(e))return 0;o.add(e);let r=t[e]||[];return r.length===0?1:1+Math.max(...r.map(n=>Cf(n,t,new Set(o))))}var Nb,vf,SC=x(()=>{"use strict";Nb=require("lodash-es"),vf=e=>(0,Nb.filter)(e.map(t=>t._type==="PartialBlock"||t._type==="GlobalBlock"?(t==null?void 0:t._show)===!1||(t==null?void 0:t._show)==="false"?null:(0,Nb.get)(t,"partialBlockId",(0,Nb.get)(t,"globalBlock","")):null),Boolean)});var dD,Hu,kf,pD=x(()=>{"use strict";dD=require("jotai"),Hu=require("react");Ke();xf();kf=()=>{let[e,t]=(0,Hu.useState)(!1),[o,r]=(0,Hu.useState)(null),[n,a]=(0,dD.useAtom)(kC),s=q("getPartialBlocks",async()=>({})),i=(0,Hu.useCallback)(async()=>{t(!0),r(null);try{let l=await s();a(l),t(!1)}catch(l){r(l instanceof Error?l.message:"Failed to fetch partial blocks"),t(!1)}},[s,a]);return(0,Hu.useEffect)(()=>{i()},[]),{data:n,isLoading:e,refetch:i,error:o}}});var mD,uD,l0,Dc,gD=x(()=>{"use strict";mD=require("jotai"),uD=require("lodash-es"),l0=require("react");xf();Dc=()=>{let[e,t]=(0,mD.useAtom)(Rc),o=(0,l0.useCallback)(n=>(0,uD.get)(e,`${n}.blocks`,[]),[e]),r=(0,l0.useCallback)(()=>t({}),[t]);return{getPartialBlocks:o,reset:r}}});var c0=x(()=>{"use strict"});var fD,wC,d0,Sf,hD=x(()=>{"use strict";fD=require("jotai"),wC=require("react");Ke();c0();xf();SC();d0=()=>{let[e]=(0,fD.useAtom)(Rc);return(0,wC.useMemo)(()=>{let t={};return Object.entries(e).forEach(([o,r])=>{t[o]=r.dependencies}),t},[e])},Sf=()=>{let e=q("pageId",""),t=d0();return(0,wC.useCallback)(o=>{if(!e)return{canAdd:!0};if(e===o)return{canAdd:!1,reason:"Cannot add a partial inside itself"};if(Eb(e,o,t))return{canAdd:!1,reason:"Adding this partial would create a circular reference"};let r=Cf(e,t),n=Cf(o,t);return Math.max(r,1+n)>4?{canAdd:!1,reason:`Maximum nesting depth (${4} levels) would be exceeded`}:{canAdd:!0}},[e,t])}});var yD,p0,Xp,PC,bD=x(()=>{"use strict";yD=require("jotai"),p0=require("lodash-es"),Xp=require("react");ko();Ke();xf();SC();PC=()=>{let[e]=Pt(),[t,o]=(0,yD.useAtom)(Rc),r=q("getPartialBlockBlocks",async l=>[]),n=(0,Xp.useRef)(new Set),a=(0,Xp.useMemo)(()=>e.filter(l=>l._type==="PartialBlock"||l._type==="GlobalBlock").map(l=>(0,p0.get)(l,"partialBlockId",(0,p0.get)(l,"globalBlock",""))).filter(Boolean),[e]),s=(0,Xp.useMemo)(()=>{let l=[];return Object.values(t).forEach(c=>{c.status==="loaded"&&l.push(...c.dependencies)}),l},[t]),i=(0,Xp.useMemo)(()=>[...new Set([...a,...s])],[a,s]);(0,Xp.useEffect)(()=>{let l=i.filter(c=>{let d=t[c],p=n.current.has(c);return(!d||d.status==="idle")&&!p});l.length!==0&&(l.forEach(c=>n.current.add(c)),o(c=>{let d={};return l.forEach(p=>{d[p]={blocks:[],dependencies:[],status:"loading"}}),{...c,...d}}),Promise.all(l.map(async c=>{try{let d=await r(c),p=vf(d);o(u=>({...u,[c]:{blocks:d,dependencies:p,status:"loaded"}}))}catch(d){o(p=>({...p,[c]:{blocks:[],dependencies:[],status:"error",error:d instanceof Error?d.message:"Failed to fetch"}}))}finally{n.current.delete(c)}})))},[i,t,o,r])}});var m0=x(()=>{"use strict";xf();SC();pD();gD();hD();bD()});var xD,yi,Zp,TC,em,SJ,to,Nn=x(()=>{"use strict";xD=require("@react-hookz/web"),yi=require("jotai"),Zp=require("lodash-es"),TC=require("react");zr();Wr();Oa();Ke();fC();xC();CC();Tt();mn();s0();cD();Ne();m0();em=(0,yi.atom)("SAVED");em.debugLabel="builderSaveStateAtom";SJ=(e,t)=>t?e.some(o=>{var r;if(!(o!=null&&o._type)||o._type==="PartialBlock")return!1;try{let n=Ct(o._type);return n?((0,Zp.has)(n,"i18nProps")?(r=n.i18nProps)!=null?r:[]:[]).some(s=>{let i=`${s}-${t}`;return!o[i]||(0,Zp.isEmpty)(o[i])}):!1}catch(n){return console.warn(`Failed to get block definition for type: ${o._type}`,n),!1}}):!1,to=()=>{let[e,t]=(0,yi.useAtom)(em),o=q("onSave",async I=>{}),r=q("onSaveStateChange",Zp.noop),n=yf(),{hasPermission:a}=kt(),{selectedLang:s,fallbackLang:i}=fe(),[l]=iD(),c=(0,yi.useAtomValue)(Rc),d=(0,yi.useAtomValue)(gi),p=(0,yi.useSetAtom)(Uu),u=(0,yi.useSetAtom)(Ec),m=(0,yi.useSetAtom)(Du),g=(0,yi.useSetAtom)(_u),h=(0,yi.useSetAtom)(Lu),f=()=>{let I=n();return!s||s===i?!1:SJ(I.blocks||[],s)},b=(0,TC.useCallback)(I=>{let C=new Set,P=vf(I);for(;P.length>0;){let B=P.shift();if(C.has(B))continue;C.add(B);let T=c[B];(T==null?void 0:T.status)==="loaded"&&T.dependencies.length>0&&P.push(...T.dependencies)}return[...C]},[c]),y=(0,TC.useCallback)(I=>{let C=/pageType:[^:]+:([a-f0-9-]{36})/gi,P=/dt#[^ "]+/g,B=new Set,T={};for(let v of I){let S=JSON.stringify(v),A;for(;(A=C.exec(S))!==null;)A[1]&&B.add(A[1]);for(;(A=P.exec(S))!==null;)if(A[0]){let D=A[0];T[D]||(T[D]={}),T[D][v._id]=v._name||v._type}}return{linkPageIds:(0,Zp.compact)([...B]),designTokens:T}},[]),k=(0,TC.useCallback)(I=>!I&&(!a("save_page")||!l)||!I&&e==="SAVED",[a,l,e]);return{savePage:(0,xD.useThrottledCallback)(async(I=!1,C=!1)=>{var A,D,R;if(k(C))return;let P=n();if(d){let H=d.contentDocument||((A=d.contentWindow)==null?void 0:A.document);if(H){let M=JR(H),L=M.some(_=>_.severity==="error"),z=M.some(_=>_.severity==="warning");u(M),m(!L),g(L),h(z)}}let B=await bf(Tb.BEFORE_SAVE_PAGE,P.blocks,{pageId:(D=P.currentPage)==null?void 0:D.id,operation:"update"});if(!Array.isArray(B)){console.error("[ChaiBuilder] BEFORE_SAVE_PAGE hook did not return a valid array. Aborting save.");return}let T=B;t("SAVING"),r("SAVING"),p(0);let{linkPageIds:v,designTokens:S}=y(T||[]);return await o({autoSave:I,blocks:T,needTranslations:f(),partialIds:b(T||[]),linkPageIds:v,designTokens:S}),await bf(Tb.AFTER_SAVE_PAGE,{pageId:(R=P.currentPage)==null?void 0:R.id,blocks:T},{operation:"update"}),setTimeout(()=>{t("SAVED"),r("SAVED")},100),!0},[k,n,t,p,o,r,l,d,b,y,u,m,g,h],3e3),savePageAsync:async(I=!1)=>{var v,S;if(k(I))return;let C=n(),P=await bf(Tb.BEFORE_SAVE_PAGE,C.blocks,{pageId:(v=C.currentPage)==null?void 0:v.id,operation:"update"});t("SAVING"),r("SAVING"),p(0);let{linkPageIds:B,designTokens:T}=y(P||[]);return await o({autoSave:!0,blocks:P,needTranslations:f(),partialIds:b(P||[]),linkPageIds:B,designTokens:T}),await bf(Tb.AFTER_SAVE_PAGE,{pageId:(S=C.currentPage)==null?void 0:S.id,blocks:P},{operation:"update"}),setTimeout(()=>{t("SAVED"),r("SAVED")},100),!0},saveState:e,setSaveState:t,needTranslations:f}}});var Ib,NC,vD,EC,AC=x(()=>{"use strict";Ib=require("jotai"),NC=require("react");Wr();Ke();Nn();vD=()=>{let{savePage:e,saveState:t}=to(),o=q("autoSave",!0),r=q("autoSaveActionsCount",10),[n]=(0,Ib.useAtom)(Uu);(0,NC.useEffect)(()=>{o&&(t==="SAVED"||t==="SAVING"||n>=r&&e(!0))},[o,e,t,n,r])},EC=()=>{let e=(0,Ib.useSetAtom)(Uu),t=(0,Ib.useSetAtom)(em);return(0,NC.useCallback)(()=>{e(o=>o+1),t(o=>o!=="UNSAVED"?"UNSAVED":o)},[e,t])}});function u0(e,t,o,r){let n=[...t],a=[...e];if(o){let c=e.find(d=>d._id===o);if(c&&c.content!==void 0&&c.content!==""&&!e.some(p=>p._parent===o)){let u={_id:Uo(),_parent:o,_type:"Text",content:c.content};Object.keys(c).forEach(m=>{m.startsWith("content-")&&(u[m]=c[m])}),n.unshift(u),a=a.map(m=>{if(m._id===o){let g={...m,content:""};return Object.keys(g).forEach(h=>{h.startsWith("content-")&&(g[h]="")}),g}return m})}}let s=a.filter(c=>!c._parent);o&&(s=a.filter(c=>c._parent===o));let i=r!==void 0&&!isNaN(r)&&r>-1?Math.min(r,s.length):s.length,l=a.length;for(let c=0,d=0;c<a.length;c++)if(o!==void 0?a[c]._parent===o:!a[c]._parent){if(d===i){l=c;break}d++}return!o&&r!==void 0&&r>=s.length&&(l=a.length),[...a.slice(0,l),...n,...a.slice(l)]}var CD=x(()=>{"use strict";pn()});function kD(e){return cC(e)}var SD=x(()=>{"use strict";uf()});function wJ(e){let t=[];return e.walk(o=>(delete o.model.children,t.push(o.model),!0)),t}function wD(e,t){return e.first(o=>o.model._id===t)||null}function PJ(e,t,o,r){var c,d;let n=wD(e,t),a=wD(e,o);if(!n||!a)return!1;a.children||(a.model.children=[]);let s=(c=a==null?void 0:a.children)==null?void 0:c.findIndex(p=>p.model._id===t);n.drop(),s=Math.max(s,0);let l=(((d=n==null?void 0:n.model)==null?void 0:d._parent)||"root")===o&&s<=r?r-1:r;try{a.addChildAtIndex(n,l)}catch(p){return console.error("Error adding child to parent:",p),!1}return!0}function TJ(e,t){if(!t||!t._parent)return e;let o=t._parent,r=e.find(a=>a._id===o);if(!r)return e;let n=e.filter(a=>a._parent===o);if(n.length===2){let a=n.find(s=>s._id!==t._id);if(a&&a._type==="Text"&&"content"in r)return e.map(i=>{if(i._id===o){let l={...i,content:a.content};return Object.keys(a).forEach(c=>{c.startsWith("content-")&&(l[c]=a[c])}),l}return i}).filter(i=>i._id!==a._id)}return e}function NJ(e,t,o){if(!o||o==="root")return e;let r=e.find(n=>n._id===o);if(!r)return e;if(r.content!==void 0&&r.content!==""&&!e.some(a=>a._parent===o&&a._id!==t._id)){let s={_id:Uo(),_parent:o,_type:"Text",content:r.content};Object.keys(r).forEach(c=>{c.startsWith("content-")&&(s[c]=r[c])});let i=e.map(c=>{if(c._id===o){let d={...c,content:""};return Object.keys(d).forEach(p=>{p.startsWith("content-")&&(d[p]="")}),d}return c}),l=i.findIndex(c=>c._id===t._id);return l!==-1?[...i.slice(0,l),s,...i.slice(l)]:[s,...i]}return e}function IC(e,t,o,r){if(!t)return e;let n=e.find(c=>c._id===t);if(!n)return e;let a=TJ(e,n),s=o||"root",l=new PD.default().parse({_id:"root",children:kD(a)});if(PJ(l,t,s,r)){let c=wJ(l),d=c.find(p=>p._id===t);return d&&(d._parent=s==="root"?null:s),c.shift(),o&&(c=NJ(c,n,o)),c}return a}var PD,g0=x(()=>{"use strict";PD=K(require("tree-model"),1);pn();SD()});var TD,ND,Bb,BC,ED,f0=x(()=>{"use strict";TD=require("@react-hookz/web"),ND=require("react");h0();ko();Ke();Bb=new BroadcastChannel("chaibuilder"),BC=()=>{let e=q("pageId","chaibuilder_page");return{postMessage:(0,TD.useDebouncedCallback)(o=>Bb.postMessage({...o,pageId:e}),[e],200)}},ED=()=>{let[,e]=Pt(),t=q("pageId","chaibuilder_page"),{updateBlocksProps:o}=RC();(0,ND.useEffect)(()=>(Bb.onmessageerror=r=>{console.log("error",r)},Bb.onmessage=r=>{r.data.type==="blocks-updated"&&r.data.pageId===t&&e(r.data.blocks),r.data.type==="blocks-props-updated"&&r.data.pageId===t&&o(r.data.blocks)},()=>{Bb.onmessage=null,Bb.onmessageerror=null}),[e,t,o])}});var ss,AD,Ds,ID,Gu,DC,y0,tm,_e,EJ,AJ,IJ,BJ,Rb,b0,RJ,BD,Pe,Ge=x(()=>{"use strict";ss=require("jotai"),AD=require("jotai/utils"),Ds=require("lodash-es"),ID=require("react");zr();Gu=(0,ss.atom)([]);Gu.debugLabel="selectedBlockIdsAtom";DC=(0,ss.atom)(e=>{let t=e(Ot),o={};return t.forEach(r=>{o[r._id]=r}),o});DC.debugLabel="blocksByIdAtom";y0=(0,ss.atom)(e=>{let t=e(DC),o=e(Gu);return(0,Ds.compact)((0,Ds.map)(o,r=>t[r]))});y0.debugLabel="selectedBlocksAtom";tm=(0,ss.atom)(e=>{let t=e(y0);if(t.length!==0&&t.length===1)return t[0]});tm.debugLabel="selectedBlockAtom";_e=()=>(0,ss.useAtomValue)(tm),EJ=e=>(0,Ds.get)(e,"_parent",null),AJ=(0,ss.atom)(e=>{let t=e(y0),o=e(DC),r=[...new Set((0,Ds.map)(t,EJ))];return(0,Ds.compact)((0,Ds.map)(r,n=>n?o[n]:void 0))});AJ.debugLabel="selectedBlocksParentsAtom";IJ=(0,ss.atom)(()=>!1);IJ.debugLabel="selectedBlockFlexChildAtom";BJ=(0,ss.atom)(()=>!1);BJ.debugLabel="selectedBlockGridChildAtom";Rb=(0,ss.atom)("");Rb.debugLabel="styleStateAtom";b0=(0,AD.atomWithStorage)("styleBreakpoint","xs");b0.debugLabel="styleBreakpointAtom";RJ=(0,ss.atom)(e=>{let t=e(tm),o=e(DC),r=t,n=[t];do{let a=r!=null&&r._parent?o[r._parent]:void 0;r=a,a&&n.push(a)}while(r!=null&&r._parent);return n}),BD=()=>(0,Ds.compact)((0,ss.useAtomValue)(RJ)),Pe=()=>{let[e,t]=(0,ss.useAtom)(Gu),o=(0,ID.useCallback)(r=>{t(n=>(0,Ds.includes)(n,r)?(0,Ds.without)(n,r):[...n,r])},[t]);return[e,t,o]}});var xe,Oce,tn=x(()=>{"use strict";xe={"app:read":"app:read","app:update":"app:update","app:publish":"app:publish","app:settings":"app:settings","app:publish_theme":"app:publish_theme","pages:create":"pages:create","pages:read":"pages:read","pages:update":"pages:update","pages:delete":"pages:delete","pages:publish":"pages:publish","pages:unpublish":"pages:unpublish","pages:change_type":"pages:change_type","pages:force_takeover":"pages:force_takeover","pages:edit_seo":"pages:edit_seo","partials:create":"partials:create","partials:read":"partials:read","partials:update":"partials:update","partials:delete":"partials:delete","partials:publish":"partials:publish","partials:unpublish":"partials:unpublish","revisions:read":"revisions:read","revisions:restore":"revisions:restore","revisions:delete":"revisions:delete","assets:create":"assets:create","assets:read":"assets:read","assets:update":"assets:update","assets:delete":"assets:delete","library:create":"library:create","library:read":"library:read","library:update":"library:update","library:delete":"library:delete","ai:use":"ai:use","ai:read":"ai:read","ai:generate_image":"ai:generate_image","ai:generate_theme":"ai:generate_theme","theme:edit":"theme:edit","theme:publish":"theme:publish","design_tokens:read":"design_tokens:read","design_tokens:create":"design_tokens:create","design_tokens:edit":"design_tokens:edit","design_tokens:delete":"design_tokens:delete","design_tokens:publish":"design_tokens:publish","settings:edit":"settings:edit","domains:read":"domains:read","domains:manage":"domains:manage","users:read":"users:read","users:invite":"users:invite","users:update_role":"users:update_role","users:remove":"users:remove","roles:read":"roles:read","roles:create":"roles:create","roles:update":"roles:update","roles:delete":"roles:delete","trash:read":"trash:read","trash:restore":"trash:restore","trash:delete_permanently":"trash:delete_permanently"},Oce=Object.keys(xe)});var Hd,RD,$u,_c,om=x(()=>{"use strict";Hd=require("lodash-es"),RD=require("react");ko();mn();Ge();tn();$u=(e,t)=>{let o=[...e],r=[];t.forEach(i=>{let l=o.find(p=>p._id===i);if(!l||!l._parent)return;let c=l._parent,d=o.filter(p=>p._parent===c);if(d.length===2){let p=d.find(u=>u._id!==i);if(p&&p._type==="Text"){let u=o.find(m=>m._id===c);u&&"content"in u&&(o=o.map(m=>{if(m._id===c){let g={...m,content:p.content};return Object.keys(p).forEach(h=>{h.startsWith("content-")&&(g[h]=p[h])}),g}return m}),r.push(p._id))}}});let n=[...t,...r],a=[],s=(0,Hd.filter)(o,i=>(0,Hd.includes)(n,i._id)||(0,Hd.includes)(n,i._parent)?(a.push(i._id),!1):!0);return(0,Hd.isEmpty)(a)?s:$u(s,a)},_c=()=>{let[e]=Pt(),[,t]=Pe(),{setNewBlocks:o}=Ft(),{hasPermission:r}=kt();return(0,RD.useCallback)(n=>{var s;if(!r(xe["pages:update"]))return;let a=((s=(0,Hd.find)(e,{_id:n[0]}))==null?void 0:s._parent)||null;o($u(e,n)),setTimeout(()=>t(a?[a]:[]),200)},[r,e,o,t])}});var _C,_D,LD,MD,DD,DJ,_J,OD,x0,v0=x(()=>{"use strict";_C=require("jotai"),_D=require("jotai/utils"),LD=require("lodash-es"),MD=require("react");zr();Jn();DD=new WeakMap,DJ=(e,t)=>{if(t===Kp)return e(Yp);let o=e(t),r=DD.get(o);if(!r){r=new Map;for(let n of o)r.set(e(n)._id,n);DD.set(o,r)}return r},_J=(0,_C.atom)(null,(e,t,{id:o,props:r})=>{let n=e(Yp).get(o);return n?t(n,{...e(n),...r}):null}),OD=()=>(0,_C.useSetAtom)(_J),x0=e=>(0,_D.useAtomCallback)((0,MD.useCallback)((t,o,r)=>{let n=(0,LD.isString)(r)?r:t(r)._id,a=DJ(t,e).get(n);return a||(console.warn(`Block with id ${n} not found`),null)},[e]),{store:be})});var FD,wf,RC,h0=x(()=>{"use strict";FD=require("jotai"),wf=require("lodash-es");zr();AC();CD();g0();f0();fC();om();v0();RC=()=>{let e=(0,FD.useSetAtom)(Ot),{postMessage:t}=BC(),o=OD(),r=gC(),n=EC();return{setNewBlocks:a=>{e(a),t({type:"blocks-updated",blocks:a})},addBlocks:(a,s,i)=>{e(l=>{let c=u0(l,a,s,i);return t({type:"blocks-updated",blocks:c}),r(),n(),c})},removeBlocks:a=>{e(s=>{let i=$u(s,a);return t({type:"blocks-updated",blocks:i}),r(),n(),i})},moveBlocks:(a,s,i)=>{e(l=>{let c=[...l];for(let d=0;d<a.length;d++)c=IC(c,a[d],s,i);return(0,wf.each)(a,d=>{let p=(0,wf.find)(c,u=>u._id===d);p&&o({id:d,props:{_parent:p._parent||null}})}),t({type:"blocks-updated",blocks:c}),r(),n(),c})},updateBlocksProps:a=>{a.forEach(s=>{let i=(0,wf.omit)(s,"_id");o({id:s._id,props:i})}),t({type:"blocks-props-updated",blocks:a}),r(),n()},replaceBlocks:(a,s,i,l)=>{e(c=>{let d=$u(c,a);return d=u0(d,s,i,l),t({type:"blocks-updated",blocks:d}),r(),n(),d})}}}});var Vu,C0,Lc,HD,_s,UD,GD,Mc,Pf=x(()=>{"use strict";Vu=require("jotai"),C0=require("lodash-es"),Lc=require("react"),HD=K(require("undo-manager"),1);Ke();Nn();_s=new HD.default;_s.setLimit(50);UD=(0,Vu.atom)({canUndo:!1,canRedo:!1}),GD=()=>(0,Vu.useAtomValue)(UD),Mc=()=>{let e=(0,Vu.useSetAtom)(em),t=(0,Vu.useSetAtom)(UD),o=q("onSaveStateChange",C0.noop),r=(0,Lc.useCallback)(()=>{let l={canUndo:_s.hasUndo(),canRedo:_s.hasRedo()};t(l),e("UNSAVED"),o("UNSAVED")},[t,e,o]);(0,Lc.useEffect)(()=>(_s.setCallback(r),()=>{_s.setCallback(C0.noop)}),[r]);let n=(0,Lc.useCallback)(l=>{_s.add(l),r()},[r]),a=(0,Lc.useCallback)(()=>{_s.undo(),r()},[r]),s=(0,Lc.useCallback)(()=>{_s.redo(),r()},[r]),i=(0,Lc.useCallback)(()=>{_s.clear(),t({canUndo:!1,canRedo:!1})},[t]);return(0,Lc.useMemo)(()=>({add:n,undo:a,redo:s,hasUndo:()=>_s.hasUndo(),hasRedo:()=>_s.hasRedo(),clear:i}),[n,a,s,i])}});var $D,En,Pt,Oc,Ft,ko=x(()=>{"use strict";$D=require("jotai"),En=require("lodash-es");zr();Jn();Ac();h0();Pf();Pt=()=>(0,$D.useAtom)(Ot),Oc=()=>be.set(Fd,e=>e+1),Ft=()=>{let{add:e}=Mc(),{setNewBlocks:t,addBlocks:o,removeBlocks:r,moveBlocks:n,replaceBlocks:a,updateBlocksProps:s}=RC();return{moveBlocks:(h,f,b)=>{let y=be.get(Ot),k=y.find(N=>N._id===h[0]);if(k){let N=k._parent||null,I=y.filter(C=>N?C._parent===N:!C._parent).map(C=>C._id);if(N===(f!=null?f:null)&&I.indexOf(h[0])===b)return}n(h,f!=null?f:null,b);let w=be.get(Ot);e({undo:()=>{t(y),Oc()},redo:()=>{t(w),Oc()}})},addBlocks:(h,f,b)=>{o(h,f,b),e({undo:()=>{r((0,En.map)(h,"_id")),Oc()},redo:()=>{o(h,f,b),Oc()}})},removeBlocks:h=>{var w;let f=be.get(Ot),b=(w=(0,En.first)(h))==null?void 0:w._parent,k=f.filter(N=>b?N._parent===b:!N._parent).indexOf((0,En.first)(h));r((0,En.map)(h,"_id")),e({undo:()=>{o(h,b!=null?b:void 0,k),Oc()},redo:()=>{r((0,En.map)(h,"_id")),Oc()}})},replaceBlocks:(h,f,b,y)=>{let k=(0,En.map)(h,"_id");a(k,f,b,y),e({undo:()=>{a((0,En.map)(f,"_id"),h,b,y),Oc()},redo:()=>{a(k,f,b,y),Oc()}})},updateBlocks:(h,f,b)=>{let y=be.get(Ot),k=[];if(b)k=(0,En.map)(h,w=>({_id:w,...b}));else{let w=(0,En.keys)(f),N=new Map(y.map(I=>[I._id,I]));k=(0,En.map)(h,I=>{let C=N.get(I),P={_id:I};return(0,En.each)(w,B=>P[B]=C[B]),P})}s((0,En.map)(h,w=>({_id:w,...f}))),e({undo:()=>s(k),redo:()=>s((0,En.map)(h,w=>({_id:w,...f})))})},updateBlocksRuntime:(h,f)=>{s((0,En.map)(h,b=>({_id:b,...f})))},setNewBlocks:h=>{let f=be.get(Ot);t(h),e({undo:()=>{t(f),Oc()},redo:()=>{t(h),Oc()}})},updateMultipleBlocksProps:h=>{let f=be.get(Ot),b=new Map(f.map(k=>[k._id,k])),y=[];y=(0,En.map)(h,k=>{let w=(0,En.keys)(k),N=b.get(k._id),I={_id:k._id};return(0,En.each)(w,C=>I[C]=N==null?void 0:N[C]),I}),s(h),e({undo:()=>s(y),redo:()=>s(h)})}}}});var un,Db,VD,br,LJ,LC,Fc,Ln=x(()=>{"use strict";un=require("lodash-es"),Db=require("react");Jn();ko();Tt();Ge();Ne();VD=(e,t,o)=>{let r=Ct((0,un.get)(o,"_type",""));if(!r)return e;let n={...e};return(0,un.forEach)((0,un.keys)(e),a=>{if((0,un.includes)((0,un.get)(r,"i18nProps",[]),a)&&!(0,un.isEmpty)(t)){let s=`${a}-${t}`;(0,un.set)(n,s,e[a]),(0,un.unset)(n,a)}}),n},br=()=>{let{updateBlocks:e}=Ft(),{selectedLang:t}=fe();return(0,Db.useCallback)((o,r,n)=>{let a=be.get(tm),s=VD(r,t,a);e(o,s,n)},[t,e])},LJ=()=>{let{updateBlocksRuntime:e}=Ft();return(0,Db.useCallback)(async(t,o,r=30)=>{let n=(0,un.keys)((0,un.omit)(o,["_id"]));for(let a of n){let s=o[a];if((0,un.isString)(s)){let i=(0,un.chunk)(s.split(""),12),l="";e([t],{[a]:""});for(let c=0;c<i.length;c++)l+=i[c].join(""),e([t],{[a]:l}),await new Promise(d=>setTimeout(d,r))}}},[e])},LC=()=>{let{updateMultipleBlocksProps:e}=Ft(),t=LJ();return(0,Db.useCallback)(async o=>{for(let r of o)await t(r._id,r);e(o)},[t,e])},Fc=()=>{let{updateBlocksRuntime:e}=Ft(),{selectedLang:t}=fe();return(0,Db.useCallback)((o,r)=>{let n=be.get(tm),a=VD(r,t,n);e(o,a)},[t,e])}});var k0,Tf,is,Ud,S0,MC,zD,OC=x(()=>{"use strict";Ke();Tn();k0=require("@rjsf/utils"),Tf=require("jotai"),is=require("lodash-es"),Ud=require("react");Ln();S0=(0,Tf.atom)({});S0.debugLabel="blockRepeaterDataAtom";MC=()=>(0,Tf.useAtom)(S0),zD=(e,t,o,r)=>{let n=Fc(),a=q("getBlockAsyncProps",async f=>({})),s=(0,Tf.useSetAtom)(S0),i=JSON.stringify([e==null?void 0:e._id,...(0,is.values)((0,is.pick)(e,o!=null?o:[]))]),l=(e==null?void 0:e._type)==="Repeater"&&(0,is.startsWith)(e.repeaterItems,`{{${"#"}`),c=(e==null?void 0:e._type)!=="Repeater"&&t==="live",d=t==="mock"&&(0,is.isFunction)(r)||t==="live"&&(l||c),[p,u]=(0,Ud.useState)({status:d?"loading":"idle",props:{},error:void 0}),m=(0,Ud.useRef)(e);(0,Ud.useEffect)(()=>{m.current=e},[e]);let g=(0,Ud.useRef)(n);return(0,Ud.useEffect)(()=>{g.current=n},[n]),(0,Ud.useEffect)(()=>{if(t==="mock"){(0,is.isFunction)(r)&&Promise.resolve().then(()=>{let f=r({block:m.current});if(!(0,k0.isObject)(f))throw new Error("mockDataProvider should return an object");u({status:"loaded",props:f})});return}t==="live"&&(!l&&!c||a({block:m.current}).then((f={})=>{l?(s(b=>({...b,[m.current._id]:{status:"loaded",props:(0,is.get)(f,"items",[]),repeaterItems:m.current.repeaterItems}})),u({status:"loaded",props:{totalItems:(0,is.get)(f,"totalItems")}}),g.current([m.current._id],{totalItems:(0,is.get)(f,"totalItems")})):u({status:"loaded",props:(0,k0.isObject)(f)?f:{}})}).catch(f=>{l?(s(b=>({...b,[m.current._id]:{status:"error",error:f,props:[]}})),u({status:"error",error:f,props:{}})):u({status:"error",error:f,props:{}})}))},[i,l,c,r,t,a,s]),{$loading:(0,is.get)(p,"status")==="loading",...e?(0,is.get)(p,"props",{}):{}}}});var bi,w0,_b,MJ,OJ,FJ,HJ,FC,ls,la,Uu,HC,UC,Wr=x(()=>{"use strict";bi=require("jotai"),w0=require("react");OC();_b=(0,bi.atom)(null);_b.debugLabel="chaiBuilderPropsAtom";MJ=(0,bi.atom)({});MJ.debugLabel="chaiExternalDataAtom";OJ=(0,bi.atom)({});OJ.debugLabel="chaiRjsfFieldsAtom";FJ=(0,bi.atom)({});FJ.debugLabel="chaiRjsfWidgetsAtom";HJ=(0,bi.atom)({});HJ.debugLabel="chaiRjsfTemplatesAtom";FC=(0,bi.atom)({});FC.debugLabel="chaiPageExternalDataAtom";ls=(0,bi.atom)({});ls.debugLabel="chaiDesignTokensAtom";la=()=>{let[e]=MC(),t=(0,w0.useMemo)(()=>{let r={};return Object.entries(e).forEach(([n,a])=>{a.status==="loaded"&&a.repeaterItems&&(r[a.repeaterItems.replace("}}",`/${n}`).replace("{{","")]=a.props)}),r},[e]),o=(0,bi.useAtomValue)(FC);return(0,w0.useMemo)(()=>({...o,...t}),[o,t])},Uu=(0,bi.atom)(0),HC=(0,bi.atom)({isOpen:!1,blockId:null}),UC=(0,bi.atom)({isOpen:!1,blockId:null})});var WD,jD,qD,q,Ke=x(()=>{"use strict";WD=require("jotai"),jD=require("lodash-es"),qD=require("react");Wr();q=(e,t)=>{let o=(0,WD.useAtomValue)(_b);return(0,qD.useMemo)(()=>(0,jD.get)(o,e,t),[o,e,t])}});var GC,KD,fe,Tt=x(()=>{"use strict";GC=require("jotai");Ke();KD=(0,GC.atom)("");KD.debugLabel="selectedLanguageAtom";fe=()=>{let e=q("languages",[]),t=q("fallbackLang","en"),[o,r]=(0,GC.useAtom)(KD),n=a=>{r(t===a?"":a)};return{languages:e==null?void 0:e.filter(a=>a!==t),fallbackLang:t,selectedLang:o,setSelectedLang:n}}});var $C,UJ,el,zu=x(()=>{"use strict";$C=require("jotai"),UJ=(0,$C.atom)({}),el=()=>(0,$C.useAtom)(UJ)});var YD,P0,Nt,GJ,Hc,le,T0,rt=x(()=>{"use strict";YD=require("lodash-es"),P0=require("react");zu();Nt=(e,t)=>{let[o]=el();return(0,P0.useMemo)(()=>(0,YD.get)(o,e,t),[o,e,t])},GJ="google/gemini-3-flash",Hc=(e,t)=>{let o=Nt("ai.actionModels",{});return(0,P0.useMemo)(()=>{let r=e.toUpperCase();for(let[n,a]of Object.entries(o))if(a.some(i=>i.toUpperCase()===r))return n;return t||GJ},[o,e,t])},le=()=>Nt("apiUrl","/chai/api"),T0=()=>Nt("websocket",null)});var $,St=x(()=>{"use strict";$={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",AI_GENERATE_SEO_FIELD:"AI_GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",AI_EDIT_PAGE:"AI_EDIT_PAGE",AI_EDIT_BLOCK:"AI_EDIT_BLOCK",AI_EDIT_LANG_PAGE:"AI_EDIT_LANG_PAGE",AI_GENERATE_IMAGE:"AI_GENERATE_IMAGE",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_FIELDS:"UPDATE_WEBSITE_FIELDS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",CHANGE_PASSWORD:"CHANGE_PASSWORD",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_SITE_GLOBAL_DATA:"GET_SITE_GLOBAL_DATA",GET_PAGE_ALL_DATA:"GET_PAGE_ALL_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",UI_LIBRARIES:"UI_LIBRARIES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",CREATE_ASSET:"CREATE_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET",SEARCH_IMAGES:"SEARCH_IMAGES",DOWNLOAD_SEARCH_IMAGE:"DOWNLOAD_SEARCH_IMAGE",AI_GENERATE_THEME:"AI_GENERATE_THEME",AI_ENHANCE_CONTEXT:"AI_ENHANCE_CONTEXT",AI_SAVE_CONTEXT:"AI_SAVE_CONTEXT",AI_GET_CONTEXT:"AI_GET_CONTEXT",AI_GENERATE_IMAGE_DESCRIPTION:"AI_GENERATE_IMAGE_DESCRIPTION",TRASH_ENTITY:"TRASH_ENTITY",GET_TRASHED_ITEMS:"GET_TRASHED_ITEMS",RESTORE_TRASHED_ITEM:"RESTORE_TRASHED_ITEM",DELETE_PERMANENTLY:"DELETE_PERMANENTLY"}});var JD,VC,N0=x(()=>{"use strict";JD=require("jotai"),VC=(0,JD.atom)(null)});var zC,E0=x(()=>{"use strict";zC=async(e,t,o={},r)=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...o},body:JSON.stringify(t),...(r==null?void 0:r.signal)instanceof AbortSignal?{signal:r.signal}:{}})});function XD(e){let t="";for(let o=0;o<e.length;o++)t+=String.fromCharCode(e.charCodeAt(o)^92);return t}function $J(e){return btoa(XD(String(e)))}function VJ(e){try{let t=Number(XD(atob(e)));return Number.isFinite(t)&&t>0?t:null}catch(t){return null}}function ZD(){if(typeof window=="undefined")return null;try{let e=window.localStorage.getItem(QD);return e?VJ(e):null}catch(e){return null}}function e1(e){if(typeof window!="undefined")try{window.localStorage.setItem(QD,$J(e))}catch(t){}}var QD,t1=x(()=>{"use strict";QD="_cb_lx"});function ju(e){return!!(e&&typeof e=="object"&&"ok"in e&&e.ok===!1)}function WC(e,t){if(e&&typeof e=="object"&&"ok"in e){let o=e;if(!o.ok)throw new Wu(o.error.message,o.error.code,o.error.status,o.error.metadata);return o.data}throw new Wu("Invalid action response","INVALID_RESPONSE",t)}var Wu,A0=x(()=>{"use strict";Wu=class extends Error{constructor(t,o,r,n){super(t),this.name="ChaiHttpActionRequestError",this.code=o,this.status=r,this.metadata=n}}});var o1,qu,I0,Ls,he,Kt=x(()=>{"use strict";o1=require("jotai"),qu=require("lodash-es"),I0=require("react");N0();rt();E0();t1();A0();Ls=()=>{let e=he(),t=le();return(0,I0.useCallback)(async({body:o,headers:r={},url:n=t,streamResponse:a=!1,options:s})=>e(n,o,r,a,s),[e,t])},he=()=>{let e=Nt("onLogout",qu.noop),t=Nt("getAccessToken",qu.noop),o=Nt("beforeRequest",qu.noop),r=le(),n=(0,o1.useSetAtom)(VC);return(0,I0.useCallback)(async(a=r,s,i={},l=!1,c)=>{let d=s;if(o)try{let m=await o({action:s.action,data:s.data});if(m===null)return console.log("Request cancelled by beforeRequest hook:",s.action),null;m&&typeof m=="object"&&"action"in m&&(d={action:m.action,data:m.data})}catch(m){console.error("Error in beforeRequest hook:",m)}let p=await t(),u=ZD();try{let m=(0,qu.get)(d,"action","").toLowerCase(),g=await zC(a+(m?`?action=${m}`:""),d,{...i,Authorization:`Bearer ${p}`,...u?{"x-chai-license-check":String(u)}:{}},c);if(l)return g;let h=await g.json(),f=(0,qu.get)(h,"license");if(f&&(n(f),f.refreshed&&e1(Date.now())),g.status===401||ju(h)&&h.error.status===401)return console.log("401 Response",h),await e("SESSION_EXPIRED"),null;if(!g.ok||ju(h))throw ju(h)?new Wu(h.error.message,h.error.code,h.error.status,h.error.metadata):new Wu("Something went wrong.","INTERNAL_ERROR",g.status||500);return WC(h,g.status)}catch(m){throw console.error("API request failed:",d,m),m}},[e,t,o,r,n])}});var r1,ca,Uc=x(()=>{"use strict";r1=require("@tanstack/react-query");pC();St();Kt();rt();ca=()=>{let e=le(),t=he();return(0,r1.useQuery)({queryKey:[$.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:gf,appKey:"",fallbackLang:"",settings:{},designTokens:{}},queryFn:async()=>await t(e,{action:$.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})}});var n1,Mn,Hl=x(()=>{"use strict";n1=require("react");Uc();Mn=()=>{let{data:e}=ca();return(0,n1.useMemo)(()=>(e==null?void 0:e.fallbackLang)||"en",[e])}});var B0,jC,on,qC,Ul=x(()=>{"use strict";B0=require("@tanstack/react-query"),jC=require("lodash-es");St();rt();Hl();Kt();on=()=>{let e=he(),t=le();return(0,B0.useQuery)({queryKey:[$.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>await e(t,{action:$.GET_WEBSITE_PAGES})||[],placeholderData:o=>o||[]})},qC=e=>{let t=he(),o=le(),r=Mn();return(0,B0.useQuery)({queryKey:[$.GET_WEBSITE_PAGES,e,r],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(r===e)return{};let n=await t(o,{action:$.GET_WEBSITE_PAGES,data:{lang:e}})||[];return(0,jC.keyBy)((0,jC.map)(n,a=>({...a,lang:e})),"primaryPage")},placeholderData:n=>n||{}})}});var a1,KC,Ht,Nf,s1,An=x(()=>{"use strict";a1=require("@tanstack/react-query"),KC=require("react");St();Ul();Kt();rt();Ht=()=>{let e=le(),t=he();return(0,a1.useQuery)({queryKey:[$.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:$.GET_PAGE_TYPES})})},Nf=e=>{let{data:t}=Ht();return(0,KC.useMemo)(()=>t==null?void 0:t.find(o=>o.key===e),[t,e])},s1=()=>{let{data:e}=on();return{searchPages:(0,KC.useCallback)(async(o,r)=>{if(!e||!r)return[];if(Array.isArray(r))return e.filter(a=>r.includes(a.id));let n=r.toLowerCase();return e.filter(a=>a.slug&&!a.dynamic&&(a.id===r||(a.name||"").toLowerCase().includes(n)||(a.slug||"").toLowerCase().includes(n)))},[e])}}});function Go(){let[e,t]=(0,YC.useState)(new URLSearchParams(window.location.search));return(0,YC.useEffect)(()=>{let o=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",o),()=>{window.removeEventListener("popstate",o)}},[]),[e,t]}var YC,cs=x(()=>{"use strict";YC=require("react")});function R0(e,t){return e||t}function i1(){return typeof window=="undefined"?null:new URLSearchParams(window.location.search).get("slug")}function D0(e){if(typeof window=="undefined")return;let t=new URL(window.location.href);e?t.searchParams.set("slug",e):t.searchParams.delete("slug"),window.history.replaceState({},"",t.toString())}var l1=x(()=>{"use strict"});function WJ(e,t){let[o,r]=(0,ds.useState)(e);return(0,ds.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),o}var _0,JC,ds,zJ,c1,Ku,jJ,QC,Ef=x(()=>{"use strict";_0=require("@tanstack/react-query"),JC=require("jotai"),ds=require("react");Tt();St();rt();Kt();er();l1();zJ=(0,JC.atom)(null),c1=()=>(0,JC.useAtom)(zJ),Ku=()=>{let[e]=c1();return(e==null?void 0:e.slug)||""};jJ=({query:e,slug:t,enabled:o=!0})=>{let{selectedLang:r,fallbackLang:n}=fe(),{data:a}=xt(),s=a==null?void 0:a.pageType,i=le(),l=he(),c=R0(r,n),{data:d,isFetching:p}=(0,_0.useQuery)({queryKey:[$.GET_DYNAMIC_PAGES,e,t,s,c],staleTime:3600*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:$.GET_DYNAMIC_PAGES,data:{query:e,slug:t,pageType:s,lang:c}})||[],enabled:!!s&&o});return{allLangPages:d,data:d,isFetching:p}},QC=()=>{var T;let{selectedLang:e,fallbackLang:t}=fe(),[o,r]=c1(),n=le(),a=he(),{data:s}=xt(),i=s==null?void 0:s.pageType,l=s==null?void 0:s.dynamic,[c,d]=(0,ds.useState)(""),p=WJ(c,500),[u,m]=(0,ds.useState)(()=>i1()),[g,h]=(0,ds.useState)(!1),f=(T=o==null?void 0:o.slug)!=null?T:null,b=R0(e,t),{allLangPages:y,data:k,isFetching:w}=jJ({query:p}),N=(0,ds.useRef)(e);(0,ds.useEffect)(()=>{N.current!==e&&(N.current=e,f&&(m(f),r(null),h(!1)))},[e,f,r]);let{data:I,isSuccess:C}=(0,_0.useQuery)({queryKey:[$.GET_DYNAMIC_PAGES,"active",u,b,i],enabled:!!i&&!!l&&(!!u||!!y&&y.length>0&&!f),queryFn:async()=>{if(u){let v=await a(n,{action:$.GET_DYNAMIC_PAGES,data:{query:"",slug:u,lang:b,pageType:i}});return(v==null?void 0:v[0])||null}return(y==null?void 0:y[0])||null}});(0,ds.useEffect)(()=>{C&&(I?(r(I),m(null),D0(I.slug),h(!1)):u&&(h(!0),m(null)))},[C,I,u,r]),(0,ds.useEffect)(()=>{if(!o||!y)return;let v=y.find(S=>S.id===o.id);v&&v.name!==o.name&&r(v)},[y,o,r]);let P=(0,ds.useCallback)(v=>{r(v),h(!1),D0((v==null?void 0:v.slug)||null)},[r]),B=(0,ds.useCallback)(v=>d(v),[]);return{isFetching:w,dynamicPage:o,searchQuery:c,selectedLang:e,dynamicPages:k,allLangPages:y,isLangMissing:g,updateDynamicPage:P,updateSearchQuery:B}}});var d1,XC,gn,Gc=x(()=>{"use strict";d1=require("@tanstack/react-query"),XC=require("lodash-es");Tt();St();rt();Kt();cs();gn=e=>{let t=le(),[o]=Go(),r=e!=null?e:o.get("page"),n=he(),{languages:a}=fe();return(0,d1.useQuery)({queryKey:[$.GET_LANGUAGE_PAGES,r],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!r)return null;let s=await n(t,{action:$.GET_LANGUAGE_PAGES,data:{id:r}});return(0,XC.reverse)((0,XC.sortBy)(s,"primaryPage"))},enabled:!!r&&!!(a!=null&&a.length)})}});var Lb,ZC,$c,qJ,p1,m1,xt,dr,Epe,u1,g1,f1,er=x(()=>{"use strict";Lb=require("jotai"),ZC=require("lodash-es"),$c=require("react");Tt();rt();An();cs();Ef();Gc();Ul();qJ=(0,Lb.atom)({lastSaved:void 0}),p1=()=>(0,Lb.useAtom)(qJ),m1=()=>{let[e]=Go(),t=e.get("page"),{data:o,isFetching:r}=gn();return{data:(0,$c.useMemo)(()=>{let a=o==null?void 0:o.find(s=>s.id===t);return a?{...a}:{}},[o,t]),isFetching:r}},xt=()=>{let[e]=Go(),t=e.get("page"),{data:o,isFetching:r}=on();return{data:(0,$c.useMemo)(()=>{let a=o==null?void 0:o.find(s=>s.id===t);return a?{...a}:{}},[o,t]),isFetching:r}},dr=()=>{var l;let[e]=Go(),t=(l=e.get("lang"))!=null?l:"",o=e.get("page"),{data:r,isFetching:n}=qC(t),{data:a}=on(),{data:s}=Ht();return{data:(0,$c.useMemo)(()=>{let c=a==null?void 0:a.find(m=>m.id===o),d=(0,ZC.find)(s,{key:c==null?void 0:c.pageType});if((d==null?void 0:d.hasSlug)===!1||t=="")return c?{...c}:{};let u=r?Object.values(r).find(m=>m.lang===t&&m.primaryPage===o):void 0;return u?{...u}:{}},[r,a,t,o,s]),isFetching:n}},Epe=(0,Lb.atom)({}),u1=(e,t)=>{if(!t)return e;let o=e.endsWith("/")?"":"/",r=t.startsWith("/")?t.slice(1):t;return e+o+r},g1=()=>{let{selectedLang:e,fallbackLang:t}=fe(),{data:o}=dr(),{data:r}=xt(),{data:n}=Ht(),a=Ku(),s=Nt("getLiveUrl",c=>c),i=(0,$c.useCallback)(c=>{var d;return(d=(0,ZC.find)(n,{key:c}))==null?void 0:d.hasSlug},[n]),l=e===t?"":e;return(0,$c.useMemo)(()=>{let c=!i(r==null?void 0:r.pageType),d=o==null?void 0:o.slug,p=s(c?`/_partial/${l!==""?l+"/":""}${r==null?void 0:r.id}`:d||"/");return o!=null&&o.dynamic&&a?u1(p,a):p},[s,o,r,i,l,a])},f1=()=>{let{selectedLang:e,fallbackLang:t}=fe(),o=Nt("getPreviewUrl",d=>d),{data:r}=xt(),{data:n}=gn(),{data:a}=Ht(),s=Ku(),i=(0,$c.useMemo)(()=>{var d;return(d=n==null?void 0:n.find(p=>(p==null?void 0:p.lang)===e))==null?void 0:d.slug},[e,n]),l=(0,$c.useCallback)(d=>{var p;return(p=(0,ZC.find)(a,{key:d}))==null?void 0:p.hasSlug},[a]),c=e===t?"":e;return(0,$c.useMemo)(()=>{if(typeof o!="function")return"";let d=!l(r==null?void 0:r.pageType),p=o(d?`/_partial/${c!==""?c+"/":""}${r==null?void 0:r.id}`:i||"");return p&&(r!=null&&r.dynamic)&&s?u1(p,s):p},[o,i,r==null?void 0:r.pageType,l,r==null?void 0:r.id,c,s,r==null?void 0:r.dynamic])}});var ek,tk,L0=x(()=>{"use strict";ek=require("@tanstack/react-query");St();er();rt();Hl();Kt();cs();Ef();tk=()=>{let[e]=Go(),t=e.get("page"),o=le(),r=he(),n=(0,ek.useQueryClient)(),{data:a}=xt(),{data:s}=dr(),i=Mn(),l=Ku();return(0,ek.useQuery)({queryKey:[$.GET_PAGE_ALL_DATA,t,s==null?void 0:s.id,l],staleTime:1/0,gcTime:0,queryFn:async()=>{let c=await r(o,{action:$.GET_PAGE_ALL_DATA,data:{id:t,lang:(s==null?void 0:s.lang)||i,pageType:a==null?void 0:a.pageType,pageProps:{slug:(s==null?void 0:s.slug)+(l?`/${l}`:""),searchParams:{},pageType:s==null?void 0:s.pageType,fallbackLang:i,lastSaved:s==null?void 0:s.lastSaved,pageId:a==null?void 0:a.id,primaryPageId:(s==null?void 0:s.primaryPage)||(a==null?void 0:a.id),pageBaseSlug:s==null?void 0:s.slug,dynamic:a==null?void 0:a.dynamic,languagePageId:s==null?void 0:s.id,metadata:(a==null?void 0:a.metadata)||{}}}});return n.setQueryData([$.GET_BUILDER_PAGE_DATA,s==null?void 0:s.id,l],c.builderPageData),n.setQueryData([$.GET_LANGUAGE_PAGES,t],c.languagePages),n.setQueryData([$.GET_SITE_GLOBAL_DATA,(s==null?void 0:s.lang)||i],c.siteGlobalData),c},enabled:!!t&&!!(a!=null&&a.pageType)&&!!(s!=null&&s.id)})}});var h1,Af,ok=x(()=>{"use strict";h1=require("@tanstack/react-query");St();er();rt();Hl();Kt();Ef();Af=()=>{let{data:e}=xt(),{data:t}=dr(),o=le(),r=he(),n=Mn(),a=Ku();return(0,h1.useQuery)({queryKey:[$.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,placeholderData:s=>s,queryFn:async()=>r(o,{action:$.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||n,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+(a?`/${a}`:""),searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:n,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})}});var y1,If,rk=x(()=>{"use strict";y1=require("@tanstack/react-query");St();rt();Hl();Kt();er();If=()=>{let{data:e}=dr(),t=le(),o=he(),r=Mn(),n=(e==null?void 0:e.lang)||r;return(0,y1.useQuery)({queryKey:[$.GET_SITE_GLOBAL_DATA,n],staleTime:1/0,gcTime:0,placeholderData:a=>a,queryFn:async()=>o(t,{action:$.GET_SITE_GLOBAL_DATA,data:{lang:n}}),enabled:!!n})}});var b1,Bf,nk=x(()=>{"use strict";b1=require("react");cs();Bf=()=>{let[,e]=Go();return(0,b1.useCallback)((t,o)=>{let n=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});n&&a.set("lang",n),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),o==null||o()},[e])}});var x1,ak,M0=x(()=>{"use strict";x1=require("react");nk();ak=()=>{let e=Bf();return(0,x1.useCallback)(({pageId:t})=>{e(t)},[e])}});var rm,O0,sk,KJ,F0,Yu,nm,YJ,Mb,JJ,ik,Vc=x(()=>{"use strict";rm=require("jotai"),O0=require("lodash-es"),sk=require("react");pC();Ke();KJ=(e=t0)=>{let t=gf;return e.fontFamily&&(t.fontFamily=Object.entries(e.fontFamily).reduce((o,[r,n])=>({...o,[r.replace("font-","")]:n}),t.fontFamily)),t.borderRadius=e.borderRadius,e.colors&&(t.colors=e.colors.reduce((o,r)=>(Object.entries(r.items).forEach(([n,a])=>{n in o&&(o[n]=a)}),o),t.colors)),t},F0=(0,rm.atom)({}),Yu=()=>{let e=nm(),t=(0,sk.useMemo)(()=>KJ(e),[e]),o=q("theme",{}),[r,n]=(0,rm.useAtom)(F0);return[(0,sk.useMemo)(()=>({...t,...!(0,O0.isEmpty)(o)&&o,...!(0,O0.isEmpty)(r)&&r}),[t,o,r]),n]},nm=()=>{let e=q("themeOptions",o=>o);return(0,sk.useMemo)(()=>e(t0),[e])},YJ=(0,rm.atom)("block"),Mb=()=>(0,rm.useAtom)(YJ),JJ=(0,rm.atom)("settings"),ik=()=>(0,rm.useAtom)(JJ)});var k1,H0,U0,S1,G0,QJ,XJ,ZJ,eQ,tQ,oQ,rQ,nQ,v1,aQ,sQ,C1,iQ,lQ,cQ,Gd,Ob=x(()=>{"use strict";k1=require("@tanstack/react-query"),H0=require("jotai"),U0=require("react"),S1=require("react-i18next"),G0=require("sonner");Wr();ps();St();Vc();QJ=(e,t,o)=>((e.includes("THEME")||(t==null?void 0:t.theme)!==void 0)&&(e.push("THEME"),o&&(t!=null&&t.theme)&&o(t.theme)),e),XJ=(e,t,o)=>((e.includes("DESIGN_TOKENS")||(t==null?void 0:t.designTokens)!==void 0)&&(e.push("DESIGN_TOKENS"),o&&t.designTokens&&o(t.designTokens)),e),ZJ=(e,t,o,r)=>{let n=(e==null?void 0:e.appChanges)||[];return n=QJ(n,t,o),n=XJ(n,t,r),e?{...e,...t,appChanges:n}:t},eQ=({queryClient:e,queryKey:t,data:o,setTheme:r,setDesignTokens:n})=>{e.setQueryData(t,a=>ZJ(a,o,r,n))},tQ=(e,t,o,r,n)=>e.id===t?{...e,designTokens:o,links:r,partialBlocks:n,changes:[{type:"Page"}]}:e,oQ=({queryClient:e,pageId:t,designTokens:o,linkPageIds:r,partialIds:n})=>{e.setQueryData([$.GET_WEBSITE_PAGES],a=>{if(!a||!Array.isArray(a))return a;let s=r.join(" | "),i=n.join(" | ");return a.map(l=>tQ(l,t,o,s,i))})},rQ=(e,t,o,r,n,a,s)=>{t.settings&&(eQ({queryClient:e,queryKey:[$.GET_WEBSITE_DRAFT_SETTINGS],data:t.settings,setTheme:a,setDesignTokens:s}),!o&&r&&(t.settings.theme!==void 0&&G0.toast.success(n("Theme Updated"),{description:n("{{userName}} updated the theme",{userName:r}),position:"bottom-left"}),t.settings.designTokens!==void 0&&G0.toast.success(n("Design Tokens Updated"),{description:n("{{userName}} updated the design tokens",{userName:r}),position:"bottom-left"})))},nQ=(e,t)=>{t.pageId&&t.designTokens&&t.linkPageIds&&t.partialIds&&oQ({queryClient:e,pageId:t.pageId,designTokens:t.designTokens,linkPageIds:t.linkPageIds,partialIds:t.partialIds})},v1=(e,t)=>t.includes(e.id)?{...e,changes:[],online:!0}:e,aQ=(e,t)=>{if(!e)return e;let r=(e.appChanges||[]).filter(n=>!t.includes(n));return{...e,appChanges:r}},sQ=({queryClient:e,ids:t})=>{e.setQueryData([$.GET_WEBSITE_PAGES],o=>!o||!Array.isArray(o)?o:o.map(r=>v1(r,t))),e.setQueryData([$.GET_LANGUAGE_PAGES],o=>!o||!Array.isArray(o)?o:o.map(r=>v1(r,t))),(t.includes("THEME")||t.includes("DESIGN_TOKENS"))&&e.setQueryData([$.GET_WEBSITE_DRAFT_SETTINGS],o=>aQ(o,t)),e.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"})},C1=(e,t)=>e.id===t?{...e,online:!1}:e,iQ=({queryClient:e,pageId:t,primaryPage:o})=>{o?e.setQueryData([$.GET_LANGUAGE_PAGES,o],r=>!r||!Array.isArray(r)?r:r.map(n=>C1(n,t))):e.setQueryData([$.GET_WEBSITE_PAGES],r=>!r||!Array.isArray(r)?r:r.map(n=>C1(n,t))),e.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"})},lQ=(e,t,o,r)=>{e&&t(o,{data:r})},cQ=(e,t,o,r,n)=>{let{type:a,data:s,sync:i=!1,userName:l}=e;switch(a){case"UPDATE_WEBSITE_DATA":rQ(t,s,i,l,n,o,r);break;case"UPDATE_PAGE_DATA":nQ(t,s);break;case"PUBLISH_CHANGES":s.ids&&sQ({queryClient:t,ids:s.ids,sync:i});break;case"UNPUBLISH_PAGE":s.pageId&&iQ({queryClient:t,pageId:s.pageId,primaryPage:s.primaryPage});break;default:console.log(n("Unknown sync type"),a)}return i},Gd=()=>{let e=(0,k1.useQueryClient)(),t=$d(),[o,r]=(0,H0.useAtom)(F0),[,n]=(0,H0.useAtom)(ls),{t:a}=(0,S1.useTranslation)(),s=(0,U0.useCallback)(l=>{n(l)},[n]);return{handleQuerySync:(0,U0.useCallback)(l=>{let c=cQ(l,e,r,s,a);lQ(c,t,l.type,l.data)},[e,t,r,s,a])}}});var am,Fb=x(()=>{"use strict";rt();am=()=>{let e=Nt("currentUser"),t=Nt("onLogout");return{isLoggedIn:!!e,user:e,logout:t}}});var Hb,zc,go,Et,w1,P1,lk,T1,$0,N1,E1,A1,V0,tl,I1,sm,Vd=x(()=>{"use strict";Hb=require("jotai"),zc=require("lodash-es");er();Uc();Fb();go={LOCKED:"LOCKED",EDITING:"EDITING",CHECKING:"CHECKING",TAKE_OVER_REQUESTED:"TAKE_OVER_REQUESTED",ACTIVE_IN_ANOTHER_TAB:"ACTIVE_IN_ANOTHER_TAB",FORCE_TAKE_OVER:"FORCE_TAKE_OVER",CONNECTION_LOST:"CONNECTION_LOST"},Et={FORCE_TAKE_OVER:"FORCE_TAKE_OVER",TAKE_OVER_REQUEST:"TAKE_OVER_REQUEST",TAKE_OVER_APPROVED:"TAKE_OVER_APPROVED",TAKE_OVER_REJECTED:"TAKE_OVER_REJECTED",FORCE_TAKE_OVER_REQUEST:"FORCE_TAKE_OVER_REQUEST",CONTINUE_EDITING_IN_THIS_CLIENT:"CONTINUE_EDITING_IN_THIS_CLIENT",CONTINUE_EDITING_IN_THIS_TAB_REQUEST:"CONTINUE_EDITING_IN_THIS_TAB_REQUEST",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",UPDATE_PAGE_DATA:"UPDATE_PAGE_DATA",PUBLISH_CHANGES:"PUBLISH_CHANGES",UNPUBLISH_PAGE:"UNPUBLISH_PAGE"},w1=["sync","join","leave"],P1=[Et.FORCE_TAKE_OVER,Et.TAKE_OVER_REQUEST,Et.TAKE_OVER_APPROVED,Et.TAKE_OVER_REJECTED,Et.FORCE_TAKE_OVER_REQUEST,Et.CONTINUE_EDITING_IN_THIS_CLIENT,Et.CONTINUE_EDITING_IN_THIS_TAB_REQUEST,Et.UPDATE_WEBSITE_DATA,Et.UPDATE_PAGE_DATA,Et.PUBLISH_CHANGES,Et.UNPUBLISH_PAGE],lk={hasYieldedToTakeover:!1},T1=(0,Hb.atom)({}),$0=(0,Hb.atom)(null),N1=(0,Hb.atom)(go.CHECKING),E1=(0,Hb.atom)({}),A1=e=>{let t={},o=(0,zc.groupBy)((0,zc.values)(e).map(zc.last).filter(Boolean),"pageId");return Object.entries(o).forEach(([r,n])=>{let a=n;a.sort((s,i)=>s.onlineAt===i.onlineAt?s.clientId.localeCompare(i.clientId):s.onlineAt-i.onlineAt),t[r]=a[0]}),t},V0=(e,t)=>{let o=(0,zc.values)(e).map(zc.last).filter(Boolean),r=o.filter(s=>s.pageId===t),n=r.length>0?r:o,a=(0,zc.minBy)(n,"onlineAt");return a?a.onlineAt-100:+new Date-1e3*60*60*4},tl=()=>{let{user:e}=am();return e==null?void 0:e.id},I1=()=>{let{data:e}=ca();return`WEBSITE:${e==null?void 0:e.appKey}`},sm=()=>{let{data:e}=xt();return e==null?void 0:e.id}});var Rf,B1,xr,Gl,z0,Ub,dQ,pQ,mQ,Df,rn,Wc,W0,Gb,uQ,$d,gQ,R1,D1,_1,ps=x(()=>{"use strict";Rf=require("jotai"),B1=require("nanoid"),xr=require("react");Nn();Ob();rt();Vd();Fb();Gl=(0,B1.nanoid)(24),z0=null,Ub=10,dQ=1e3,pQ=2,mQ=16e3,Df=()=>{let[e,t]=(0,Rf.useAtom)(T1);return{pageToUser:e,setPageToUser:t}},rn=()=>{let[e,t]=(0,Rf.useAtom)(N1),o=[go.LOCKED,go.ACTIVE_IN_ANOTHER_TAB,go.CHECKING].includes(e),r=[go.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:o,isEditing:r}},Wc=()=>{let[e,t]=(0,Rf.useAtom)(E1);return{pageLockMeta:e,setPageLockMeta:t}},W0=()=>{let e=sm(),{pageToUser:t}=Df();return(0,xr.useMemo)(()=>t[e],[t,e])},Gb=()=>{let e=T0(),{setPageStatus:t}=rn(),[o]=(0,Rf.useAtom)($0);return(0,xr.useEffect)(()=>{if(clearTimeout(z0),!e)return z0=setTimeout(()=>{e||t(go.EDITING)},500),()=>clearTimeout(z0)},[e,t]),o},uQ=()=>{let e=sm(),t=tl(),o=Gb(),{setPageToUser:r}=Df(),{setPageStatus:n,pageStatus:a}=rn(),s=(0,xr.useRef)(e);return s.current=e,(0,xr.useCallback)(i=>{let l=i||o;if(!l)return[];let c=l==null?void 0:l.presenceState(),d=A1(c);r(d);let p=d[s.current];if(!p)n(go.CHECKING);else if(!t)n(go.CHECKING);else if(p.userId===t&&p.clientId===Gl){if(a===go.TAKE_OVER_REQUESTED)return;lk.hasYieldedToTakeover=!1,n(go.EDITING)}else p.userId===t&&p.clientId!==Gl?n(go.ACTIVE_IN_ANOTHER_TAB):n(go.LOCKED)},[o,r,n,t,a])},$d=()=>{let e=tl(),t=sm(),o=Gb(),{user:r}=am(),n=W0(),{setPageLockMeta:a}=Wc(),s=(0,xr.useRef)(t);return s.current=t,(0,xr.useCallback)(async(i,l)=>{if(!o)return;let c=l||{};c.userId=e,c.userName=(r==null?void 0:r.name)||(r==null?void 0:r.email)||"Unknown user",c.pageId=s.current,c.senderClientId=Gl,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(n==null?void 0:n.clientId),await o.send({event:i,payload:c,type:"broadcast"}),a({})},[o,e,n,a,r])},gQ=()=>{let e=tl(),t=sm(),o=Gb(),{setPageStatus:r}=rn(),{setPageLockMeta:n}=Wc(),a=$d(),s=(0,xr.useRef)(t),{savePageAsync:i}=to(),{handleQuerySync:l}=Gd();return s.current=t,(0,xr.useCallback)(c=>async({payload:d})=>{let p=d||{};if(c===Et.UPDATE_WEBSITE_DATA||c===Et.UPDATE_PAGE_DATA||c===Et.PUBLISH_CHANGES||c===Et.UNPUBLISH_PAGE){l({type:c,data:p==null?void 0:p.data,sync:!1,userName:p==null?void 0:p.userName});return}if(!(!(p!=null&&p.pageId)||(p==null?void 0:p.pageId)!==s.current||(p==null?void 0:p.receiverClientId)!==Gl))switch(n({}),c){case Et.FORCE_TAKE_OVER_REQUEST:case Et.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await i(!0)}catch(u){console.error("Failed to save page before releasing lock:",u)}await(o==null?void 0:o.track({onlineAt:+new Date+1e4,pageId:s.current,userId:e,clientId:Gl})),await a(Et.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:p==null?void 0:p.senderClientId}),setTimeout(()=>n({type:c}),0);break}case Et.TAKE_OVER_REQUEST:{n({requestingUserId:p==null?void 0:p.userId,requestingClientId:p==null?void 0:p.senderClientId}),r(go.TAKE_OVER_REQUESTED);break}case Et.CONTINUE_EDITING_IN_THIS_CLIENT:{let u=(o==null?void 0:o.presenceState())||{},m=V0(u,s.current);await(o==null?void 0:o.track({onlineAt:m,pageId:s.current,userId:e,clientId:Gl}));break}case Et.TAKE_OVER_REJECTED:{n({type:Et.TAKE_OVER_REJECTED});break}default:break}},[a,n,r,o,e,i])},R1=()=>{let e=Gb(),t=tl(),o=sm();return(0,xr.useCallback)(async()=>{!e||!t||!o||await e.track({onlineAt:+new Date+1e4,pageId:o,userId:t,clientId:Gl})},[e,t,o])},D1=()=>{let e=Gb(),t=tl(),o=sm();return(0,xr.useCallback)(async()=>{if(!e||!t||!o)return;let r=V0(e.presenceState(),o);await e.track({onlineAt:r,pageId:o,userId:t,clientId:Gl})},[e,t,o])},_1=()=>{let e=T0(),t=tl(),o=sm(),r=I1(),[n,a]=(0,Rf.useAtom)($0),{setPageStatus:s}=rn(),i=gQ(),l=uQ(),c=(0,xr.useRef)(i),d=(0,xr.useRef)(l),p=(0,xr.useRef)(null),u=(0,xr.useRef)(!1),m=(0,xr.useRef)(0),g=(0,xr.useRef)(n);(0,xr.useEffect)(()=>{c.current=i,d.current=l,g.current=n},[i,l,n]);let h=(0,xr.useCallback)(b=>{P1.forEach(y=>{b.on("broadcast",{event:y},k=>{c.current(y)(k)})}),w1.forEach(y=>{b.on("presence",{event:y},()=>{d.current(b)})})},[]),f=(0,xr.useCallback)(()=>{if(u.current||!e||!t||!r)return;if(m.current>=Ub){console.error(`Maximum reconnection attempts (${Ub}) reached. Stopping reconnection attempts.`),s(go.CONNECTION_LOST);return}u.current=!0,m.current+=1,console.log(`Attempting to reconnect realtime channel (attempt ${m.current}/${Ub})`),p.current&&(clearTimeout(p.current),p.current=null),g.current&&(e.removeChannel(g.current),a(null),g.current=null);let b=Math.min(dQ*Math.pow(pQ,m.current-1),mQ);p.current=setTimeout(()=>{let y=e.channel(r,{config:{presence:{key:Gl}}});h(y),y.subscribe(async k=>{k==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(y),g.current=y,m.current=0,u.current=!1):k==="CHANNEL_ERROR"||k==="TIMED_OUT"?(console.log(`Realtime connection failed: ${k}. Attempt ${m.current}/${Ub}`),m.current<Ub?setTimeout(()=>{u.current=!1,f()},500):(console.error("Maximum reconnection attempts reached"),u.current=!1,s(go.CONNECTION_LOST))):k==="CLOSED"&&(console.log("Realtime connection closed"),u.current=!1)})},b)},[e,t,r,a,h,s]);(0,xr.useEffect)(()=>{if(!e||!t||!r||n&&n.topic===r)return;m.current=0,u.current=!1;let b=e.channel(r,{config:{presence:{key:Gl}}});return h(b),b.subscribe(async y=>{y==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(b),g.current=b,m.current=0):y==="CHANNEL_ERROR"||y==="TIMED_OUT"?(console.log(`Realtime connection failed: ${y}. Will attempt to reconnect...`),u.current||f()):y==="CLOSED"&&console.log("Realtime connection closed")}),()=>{p.current&&(clearTimeout(p.current),p.current=null),u.current=!1,m.current=0,g.current===b&&(g.current=null),a(null),e.removeChannel(b)}},[e,t,r,a,f,h]),(0,xr.useEffect)(()=>{let b=()=>{if(document.visibilityState==="visible"){if(console.log("Tab became visible, checking realtime connection..."),!e||!t||!r){console.log("Required dependencies not available, skipping reconnection");return}if(u.current){console.log("Reconnection already in progress, skipping visibility change reconnect");return}if(g.current){let y=g.current.state;y!=="joined"&&(console.log(`Channel state is ${y}, reconnecting...`),f())}else console.log("No active channel found, reconnecting..."),f()}};return document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b)}},[e,t,r,f]),(0,xr.useEffect)(()=>(n&&o&&t&&n.track({pageId:o,userId:t,clientId:Gl,onlineAt:+new Date}),()=>{n&&o&&n.untrack()}),[n,o,t])}});var j0,q0,L1,M1,O1=x(()=>{"use strict";j0=require("@tanstack/react-query"),q0=require("react");Nn();ps();St();L1=()=>{let{savePageAsync:e}=to(),t=(0,j0.useQueryClient)(),{isLocked:o}=rn();return(0,q0.useCallback)(async()=>{o||await e(),t.invalidateQueries({queryKey:[$.GET_PAGE_ALL_DATA]}),t.invalidateQueries({queryKey:[$.GET_BUILDER_PAGE_DATA]})},[e,t,o])},M1=()=>{let e=(0,j0.useQueryClient)();return(0,q0.useCallback)(()=>{e.clear()},[e])}});var ck,F1,H1=x(()=>{"use strict";ck=require("@tanstack/react-query");St();er();rt();Kt();F1=()=>{let e=le(),t=he(),{data:o}=dr(),r=(0,ck.useQueryClient)();return(0,ck.useMutation)({mutationFn:async n=>{if(!(o!=null&&o.id))throw new Error("No active page found");return await t(`${e}`,{action:$.UPDATE_PAGE_METADATA,data:{id:o.id,metadata:n}})},onSuccess:()=>{r.invalidateQueries({queryKey:[$.GET_BUILDER_PAGE_DATA]}),r.invalidateQueries({queryKey:[$.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})}});var G1,U1=x(()=>{G1={"Add block":"Add Block","Add Block":"Add Block","Add blocks":"Add blocks","Add inside":"Add inside","Add before":"Add before","Add after":"Add after","Add block inside":"Add block inside","Add field":"Add field","Enter or paste TailwindCSS HTML snippet":"Enter or paste TailwindCSS HTML snippet","Click to add block to page":"Click to add block to page",Core:"Core","Custom Blocks":"Custom Blocks","UI Library":"UI Library",Import:"Import","Use HTML snippets from Tailwind CSS component libraries":"Use HTML snippets from Tailwind CSS component libraries","Tailwind HTML snippet":"Tailwind HTML snippet","Enter your code snippet here":"Enter your code snippet here","Import HTML":"Import HTML","Imported HTML Note":"NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.","Dark Mode":"Dark Mode","Pannable Canvas":"Pannable Canvas","Hand tool":"Hand tool","Toggle pannable canvas":"Toggle pannable canvas","Select / Hand tool":"Select / Hand tool","Zoom in":"Zoom in","Zoom out":"Zoom out","Reset zoom":"Reset zoom","This page has no blocks. Add a block by clicking the + button":"This page has no blocks. Add a block by clicking the + button","This page is empty":"This page is empty","Please select a block to edit settings or styles":"Please select a block to edit settings or styles","Please select a block to Ask AI":"Please select a block to ask AI","Please select a styling block":"Please select a styling block","Drop your block here":"Drop your block here","Use setting":"Use setting","Mobile (XS)":"Mobile (XS)","Styles set here are applied to all screen unless edited at higher breakpoint":"Styles set here are applied to all screen unless edited at higher breakpoint","Mobile landscape (SM)":"Mobile landscape (SM)","Styles set here are applied at 640px and up unless edited at higher breakpoint":"Styles set here are applied at 640px and up unless edited at higher breakpoint","Tablet (MD)":"Tablet (MD)","Styles set here are applied at 768px and up":"Styles set here are applied at 768px and up","Tablet Landscape (LG)":"Tablet Landscape (LG)","Styles set here are applied at 1024px and up unless edited at higher breakpoint":"Styles set here are applied at 1024px and up unless edited at higher breakpoint","Desktop (XL)":"Desktop (XL)","Styles set here are applied at 1280px and up unless edited at higher breakpoint":"Styles set here are applied at 1280px and up unless edited at higher breakpoint","Large Desktop (2XL)":"Large Desktop (2XL)","Styles set here are applied at 1536px and up":"Styles set here are applied at 1536px and up",Breakpoints:"Breakpoints",Clear:"Clear","Clear whole canvas?":"Clear whole canvas?","Are you sure you want to clear the whole canvas?":"Are you sure you want to clear the whole canvas?",Cancel:"Cancel",Yes:"Yes",Preview:"Preview",Settings:"Settings",Styling:"Style",SVG_code:"Enter SVG code here","Paste SVG_code":"Choose icon or paste SVG code","Enter Key":"Enter Key","Data Provider":"Data Provider","Remove Provider Confirmation":"Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?","Your data provider will be removed from this page and all added data binding will be not visible on blocks.":"Your data provider will be removed from this page and all added data binding will be not visible on blocks.",Remove:"Remove","You have no data providers registered. Please add a data provider to your project.":"You have no data providers registered. Please add a data provider to your project.","Learn more":"Learn more","Add data providers:":"Add data providers:","Select a provider":"Select a provider",Choose:"Choose","Page data providers:":"Page data providers:","View Data":"View Data","Mark as Global":"Mark as Global","Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.":"Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.","Global blocks are indicated with":"Global blocks are indicated with","Global blocks are available under 'Global' category":"Global blocks are available under 'Global' category","Enter global block name":"Enter global block name","Eg: Header, Footer":"Eg: Header, Footer","{length} blocks selected.":"{length} blocks selected.",Cut:"Cut",Copy:"Copy",Paste:"Paste",Delete:"Delete","Clear Selection":"Clear Selection","This is dev mode. Visit":"This is dev mode. Visit","to see page preview":"to see page preview",classes:"classes",Theme:"Theme",Outline:"Outline","Not supported":"Not supported","Please use Chrome, Firefox or Safari":"Please use Chrome, Firefox or Safari","Download Complete":"Download complete",Copied:"Copied","Enter Classes":"Add classes or design tokens (space-separated)","Ask AI":"Ask AI","Edit with AI":"Edit with AI","Generating... Please wait...":"Generating... Please wait...","Saving... Please wait...":"Saving... Please wait...","Deleting... Please wait...":"Deleting... Please wait...",Stop:"Stop","E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI":"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.","Ask AI to edit styles":"Ask AI to edit styles","Ask AI to edit content":"Ask AI to edit content","AI Context":"AI Context","Select Block for AI":"Select a block to edit with AI","Select Block to Edit":"Please select a block to edit",Edit:"Edit","Describe this page. E.g.: This page is about...":"Describe this page. E.g.: This page is about...",Tag:"Tag",Value:"Value","Background Image":"Background Image","Enter image URL":"Enter image URL","Enter URL":"Enter URL",URL:"URL","Replace image":"Replace image","Choose image":"Choose image",Images:"Images",Library:"Library",Blocks:"Blocks",Basic:"Basic",Media:"Media",Advanced:"Advanced",Form:"Form","Choose Icon or SVG":"Choose an icon or enter SVG",Groups:"Groups","UI Libraries":"UI Libraries",Accordions:"Accordions",Buttons:"Buttons",Layouts:"Layouts","Choose Library":"Choose library","No Library Found":"No library found.",FAQ:"FAQ",Hero:"Hero",Features:"Features",Footer:"Footer",Navbar:"Navbar",Icons:"Icons",Testimonials:"Testimonials",Blog:"Blog","Remove context":"Remove context","Yes, Delete":"Yes, Delete","AI Context Updated":"AI Context Updated","You can now ask AI to edit your content.":"You can now ask AI to edit your content.",Saved:"Saved",Unsaved:"Unsaved","Saving...":"Saving...","Improve writing":"Improve writing","Replace placeholder content":"Replace placeholder content","Discard current placeholder content and replace with meaningful relevant content.":"Discard current placeholder content and replace with meaningful relevant content.","Fix grammar":"Fix grammar","Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.":"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.","Make longer":"Make longer","Make all text elements longer.":"Make all text elements longer.","Make shorter":"Make shorter","Make all text elements shorter.":"Make all text elements shorter.","Add emojis":"Add emojis","Add emojis to text elements if relevant.":"Add emojis to text elements if relevant.",Randomize:"Randomize","Randomize all text elements.":"Randomize all text elements.","Edit Block":"Edit Block","AI Assistant":"AI Assistant","Generate with AI":"Generate with AI","Theme Config":{"Heading Font":"Heading Font","Body Font":"Body Font","Rounded Corner":"Rounded Corners",Primary:"Primary",Secondary:"Secondary",Background:"Background","Text Color":"Text Color","Background Dark Mode":"Background (Dark Mode)","Text Color Dark Mode":"Text Color (Dark Mode)","Reset styles":"Reset styles"},"Copy classes to clipboard":"Copy classes to clipboard","Classes copied to clipboard":"Classes copied to clipboard",Classes:"Classes",All:"All","Enter classes separated by space":"Add classes (space-separated)","Enter classes separated by space or design tokens":"Add classes or design tokens (space-separated)","Show hidden blocks":"Show hidden blocks","Expand all":"Expand all","Collapse all":"Collapse all","Choose library":"Choose library","Close Preview":"Close Preview",Error:"Error","Failed to copy template":"Failed to copy template","Total tokens used":"Total tokens used","Updated AI Context":"Updated AI Context","You can now Ask AI to edit your content":"You can now Ask AI to edit your content","Tell about this page eg this page is about":"Tell about this page eg this page is about..","Delete Context":"Delete Context","Keyboard shortcuts":"Keyboard shortcuts",Undo:"Undo",Redo:"Redo",Duplicate:"Duplicate","Deselect blocks":"Deselect blocks","Delete block":"Delete block","Save page":"Save page","Scripts will be only executed in preview and live mode.":"Scripts will be only executed in preview and live mode.","HTML Code Editor |":"HTML Code Editor |",Close:"Close","Coming soon":"Coming soon",Selected:"Selected",Select:"Select","Choose Builder Layout":"Choose Builder Layout","Single side panel":"Single side panel","Suitable for smaller screens. Bigger canvas size.":"Suitable for smaller screens. Bigger canvas size.","Dual side panel":"Dual side panel","Suitable for larger screens. Smaller canvas size.":"Suitable for larger screens. Smaller canvas size.","Dual side panel advanced":"Dual side panel advanced","Suitable for heavy styling & block editing. Setting are always visible.":"Suitable for heavy styling & block editing. Setting are always visible.","Block Settings":"Block Settings","Visibility settings":"Visibility settings","Show on canvas":"Show on canvas",Attributes:"Attributes","Apply Presets":"Apply Presets",apply:"apply",presets:"presets","Global presets":"Global presets",Orientation:"Orientation",Color:"Color","Please select an image":"Please select an image","click to upload":"click to upload","SVG, PNG, JPG or GIF (Max. 2mb)":"SVG, PNG, JPG or GIF (Max. 2mb)","Uploading...":"Uploading...",Upload:"Upload","Something went wrong":"Something went wrong","Fetching...":"Fetching...","No images found":"No images found","It looks like you haven't uploaded any images yet. Start by clicking the upload button above.":"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.","Open Code Editor":"Open Code Editor","Open publish menu":"Open publish menu","Publish changes":"Publish changes","Select the pages you want to publish. Click publish when you're done.":"Select the pages you want to publish. Click publish when you're done.",Updated:"Updated",Offline:"Offline","No changes found":"No changes found","Publish Selected":"Publish Selected","is editing this page":"is editing this page",Name:"Name",Type:"Type",Status:"Status",Page:"Page",Pages:"Pages","Clear search":"Clear search","No results found for":"No results found for","Search {{pageTypeName}}":"Search {{pageTypeName}}","Goto Page":"Goto Page","Open URL":"Open URL","Compose Email":"Compose Email","Call Phone":"Call Phone","Scroll to element":"Scroll to element","#ElementID":"#ElementID","Enter details":"Enter details","Open in new tab":"Open in new tab",Apply:"Apply",Back:"Back",Insert:"Insert",Rename:"Rename","Unlink from library":"Unlink from library","Save to Library":"Save to Library","No blocks found in this group":"No blocks found in this group","No blocks found matching":"No blocks found matching","No matching blocks found":"No matching blocks found","Search blocks...":"Search blocks...",Partials:"Partials",Happy:"Happy",Sad:"Sad","Importing...":"Importing...","Failed to load the UI library. Try again":"Failed to load the UI library. Try again",Retry:"Retry","Oops! Something went wrong.":"Oops! Something went wrong.","Please try again.":"Please try again.","No option found.":"No option found.","Clipboard not supported":"Clipboard not supported","Are you sure you want to clear the page?":"Are you sure you want to clear the page?",canvas_empty:"Canvas is empty",Presets:"Presets","Reset style":"Reset style","Reset styles":"Reset styles","Clear styles":"Clear styles","Open code editor":"Open code editor","Style element":"Style element","Repeater Data":"Repeater Data","Toggle Data Binding":"Toggle Data Binding",No:"No",Saving:"Saving","Screen sizes":"Screen sizes","Theme Settings":"Theme Settings","Import CSS Theme":"Import CSS Theme","Import theme":"Import theme","Import Theme":"Import Theme","CSS Variables":"CSS Variables","You don't have permission to edit settings or styles":"You don't have permission to edit settings or styles","Please contact your administrator to get access":"Please contact your administrator to get access","flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config:{heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},web_blocks:{box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},"Export Code":"Export Code","Exporting {{count}} blocks":"Exporting {{count}} blocks","Exporting all blocks":"Exporting all blocks","Export code copied!":"Export code copied!","Failed to copy export code":"Failed to copy export code","Export code downloaded successfully!":"Export code downloaded successfully!","Failed to generate export HTML":"Failed to generate export HTML","Enter value":"Enter value","Attribute keys cannot start with @":"Attribute keys cannot start with @","Enter key":"Enter key",Add:"Add",Save:"Save",Screen:"Screen"}});var K0,$1,$b,dk=x(()=>{"use strict";K0=K(require("i18next"),1),$1=require("react-i18next");U1();K0.default.use($1.initReactI18next).init({resources:{en:{translation:G1}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});$b=K0.default});var V1,_f,im,pk=x(()=>{"use strict";V1=require("react-i18next"),_f=require("react/jsx-runtime"),im=()=>{let{t:e}=(0,V1.useTranslation)();return(0,_f.jsx)("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:(0,_f.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[(0,_f.jsx)("p",{className:"font-semibold",children:e("Oops! Something went wrong.")}),(0,_f.jsx)("p",{children:e("Please try again.")})]})})}});var mk,hQ,z1,W1=x(()=>{"use strict";mk=require("jotai"),hQ=(0,mk.atom)(!1),z1=()=>{let[e,t]=(0,mk.useAtom)(hQ);return[e,t]}});function da({className:e,...t}){return(0,j1.jsx)("div",{className:G("animate-pulse rounded-md bg-primary/10",e),...t})}var j1,Lf=x(()=>{"use strict";st();j1=require("react/jsx-runtime")});var q1,uk,K1,zd,Y1,J1=x(()=>{"use strict";q1=require("@radix-ui/react-icons"),uk=K(require("react"),1),K1=require("react-i18next");pn();Ke();W1();J();Lf();zd=require("react/jsx-runtime"),Y1=()=>{let[e,t]=z1(),{t:o}=(0,K1.useTranslation)(),r=q("previewComponent",null);return e?(0,zd.jsxs)("div",{className:Co("bg-surface fixed inset-0 z-[999]",e?"block":"hidden"),children:[(0,zd.jsxs)(E,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>t(!1),children:[(0,zd.jsx)(q1.EyeClosedIcon,{}),(0,zd.jsx)("span",{children:o("Close Preview")})]}),(0,zd.jsx)("div",{children:r?(0,zd.jsx)(uk.Suspense,{fallback:(0,zd.jsx)(da,{className:"h-96 w-full"}),children:uk.default.createElement(r)}):null})]}):null}});var jo,lm=x(()=>{"use strict";jo={TOPBAR_LEFT:"topbar-left",TOPBAR_CENTER:"topbar-center",TOPBAR_RIGHT:"topbar-right",MEDIA_MANAGER:"media-manager",TOP_BAR:"top-bar",BEFORE_OUTLINE:"before-outline",AFTER_BLOCK_OPTIONS:"after-block-options",AFTER_BODY_BLOCK_OPTIONS:"after-body-block-options",AFTER_BUILDER:"after-builder",AFTER_PAGE_MORE_OPTIONS:"after-page-more-options",SEO_PANEL:{TRIGGER:"after-seo-panel-tabs-triggers",CONTENT:"after-seo-panel-tabs-content"},BLOCK_STYLING_ELEMENTS:"block-styling-elements"}});var Vb,yQ,bQ,xQ,zb,Q1=x(()=>{"use strict";Vb={},yQ=(e,t)=>{Vb[e]={id:e,component:t,type:"widget"}},bQ=(e,t)=>{Vb[e]={id:e,component:t,type:"field"}},xQ=(e,t)=>{Vb[e]={id:e,component:t,type:"template"}},zb=e=>Object.values(Vb).filter(t=>t.type===e).reduce((t,o)=>(t[o.id]=o.component,t),{})});var Mf,X1,gk,vQ,Y0,Z1=x(()=>{"use strict";Mf=require("lodash-es"),X1=require("react"),gk={},vQ=(e,t)=>{(0,Mf.has)(gk,e)&&console.warn(`Add block tab with id ${e} already registered`),(0,Mf.set)(gk,e,{id:e,...t})},Y0=()=>(0,X1.useMemo)(()=>(0,Mf.values)(gk),[])});var J0,e_,fk,Wb,CQ,Q0,t_,Of,X0,kQ,o_=x(()=>{"use strict";J0=require("jotai"),e_=require("jotai/utils"),fk={},Wb=(e,t)=>{fk[e]&&console.warn(`Flag ${e} already exists`),fk[e]={key:e,value:!1,...t}},CQ=e=>{Object.entries(e).forEach(([t,o])=>{fk[t]&&console.warn(`Flag ${t} already exists`),Wb(t,o)})},Q0=()=>fk,t_=(0,e_.atomWithStorage)("chai-feature-flags",[]),Of=e=>{let[t]=(0,J0.useAtom)(t_);return t.includes(e)},X0=e=>{let[t,o]=(0,J0.useAtom)(t_);return()=>{t.includes(e)?o(t.filter(n=>n!==e)):o([...t,e])}},kQ=({flagKey:e,children:t})=>Of(e)?t:null});var r_,Z0,eN,SQ,jb,n_=x(()=>{"use strict";r_=require("lodash-es"),Z0={},eN=(e,t)=>{Z0[e]={...t,id:e}},SQ=e=>Z0[e],jb=()=>(0,r_.values)(Z0)});var a_,wQ,tN,s_=x(()=>{"use strict";a_=async e=>e,wQ=e=>{a_=e},tN=async e=>await a_(e)});var i_,Ff,oN,rN,PQ,nN=x(()=>{"use strict";i_=require("react"),Ff=null,oN=e=>{Ff=e},rN=()=>(0,i_.useMemo)(()=>Ff,[]),PQ=()=>{Ff=null}});var cm,l_,hk,ol,yk,c_=x(()=>{"use strict";cm=require("lodash-es"),l_=require("react"),hk={},ol=(e,t)=>{(0,cm.has)(hk,e)&&console.warn(`Panel ${e} already registered. Overriding...`),(0,cm.set)(hk,e,{id:e,...t})},yk=e=>(0,l_.useMemo)(()=>(0,cm.filter)((0,cm.values)(hk),t=>t.position===e),[e])});var bk,d_,dm,qb,xk,p_,TQ,Br,aN=x(()=>{"use strict";bk=require("react"),d_=require("react-error-boundary"),dm=require("react/jsx-runtime"),qb={},xk=(e,t)=>{qb[e]||(qb[e]=[]),qb[e].push(t)},p_=e=>(0,bk.useMemo)(()=>{var t;return(t=qb[e])!=null?t:[]},[e]),TQ=e=>e&&typeof e=="object"&&"$$typeof"in e,Br=({slotId:e,context:t={},multiple:o=!0,defaultComponent:r,fallback:n=null})=>{let a=p_(e);if(a.length===0)return r?(0,dm.jsx)(r,{...t}):null;let s=o?a:[a[a.length-1]],i=s.some(c=>TQ(c)),l=(0,dm.jsx)(dm.Fragment,{children:s.map((c,d)=>(0,dm.jsx)(d_.ErrorBoundary,{fallback:null,onError:p=>{console.error(`[ChaiBuilder] Error in slot "${e}" component #${d}:`,p)},children:(0,dm.jsx)(c,{...t})},`${e}-${d}`))});return i?(0,dm.jsx)(bk.Suspense,{fallback:n,children:l}):l}});var NQ,m_=x(()=>{"use strict";uC();NQ=e=>{Ic.addRule(e)}});var Rr=x(()=>{"use strict";lm();Q1();Z1();o_();s0();n_();s_();nN();c_();aN();m_()});var u_,g_,Ce,fo=x(()=>{"use strict";u_=K(require("react"),1);st();g_=require("react/jsx-runtime"),Ce=u_.forwardRef(({className:e,type:t,...o},r)=>(0,g_.jsx)("input",{type:t,className:G("flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-xs text-foreground transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...o}));Ce.displayName="Input"});var Kb,f_,sN,On,Wd=x(()=>{"use strict";Kb=K(require("@radix-ui/react-switch"),1),f_=K(require("react"),1);st();sN=require("react/jsx-runtime"),On=f_.forwardRef(({className:e,thumbClassName:t,...o},r)=>(0,sN.jsx)(Kb.Root,{className:G("peer inline-flex h-4 w-[25px] cursor-pointer items-center rounded-full bg-muted transition-colors focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary dark:data-[state=unchecked]:bg-background",e),ref:r,...o,children:(0,sN.jsx)(Kb.Thumb,{className:G("pointer-events-none block h-3 w-3 rounded-full bg-secondary shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0.5",t)})}));On.displayName=Kb.Root.displayName});var Hf,h_,y_,pm,b_,vr,EQ,AQ,IQ,x_,v_=x(()=>{"use strict";Hf=require("@radix-ui/react-icons"),h_=require("jotai"),y_=require("jotai/utils"),pm=require("react"),b_=require("react-hotkeys-hook");Rr();J();fo();Wd();vr=require("react/jsx-runtime"),EQ=({featureKey:e,options:t})=>{let o=X0(e),r=Of(e);return(0,vr.jsxs)("div",{className:"flex items-center space-x-3 rounded-md p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",children:[(0,vr.jsx)(On,{checked:r,onCheckedChange:o}),(0,vr.jsxs)("div",{className:"flex-1",children:[(0,vr.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t.key}),t.description&&(0,vr.jsx)("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:t.description})]})]})},AQ=(0,y_.atomWithStorage)("show-feature-flag",null),IQ=({close:e,position:t,updatePosition:o})=>{let r=Q0(),[n,a]=(0,pm.useState)(""),[s,i]=(0,pm.useState)(!1),[l,c]=(0,pm.useState)({x:0,y:0}),d=(0,pm.useMemo)(()=>{if(!n.trim())return r;let g=n.toLowerCase();return Object.fromEntries(Object.entries(r).filter(([h,f])=>{var b;return(h==null?void 0:h.toLowerCase().includes(g))||((b=f==null?void 0:f.description)==null?void 0:b.toLowerCase().includes(g))}))},[r,n]),p=g=>{i(!0),c({x:g.clientX-t.x,y:g.clientY-t.y})},u=g=>{if(!s)return;let h=g.clientX-l.x,f=g.clientY-l.y,b=g.currentTarget,y=b.offsetWidth,k=b.offsetHeight,w=window.innerWidth-y,N=window.innerHeight-k,I=Math.max(0,Math.min(h,w)),C=Math.max(0,Math.min(f,N));o(I,C)},m=()=>{i(!1)};return(0,pm.useEffect)(()=>{let g=()=>{s&&i(!1)};return window.addEventListener("mouseup",g),()=>window.removeEventListener("mouseup",g)},[s]),!t||t.x<0||t.y<0?null:(0,vr.jsxs)("div",{onMouseDown:p,onMouseMove:u,onMouseUp:m,className:"fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",style:{left:t.x,top:t.y,cursor:s?"grabbing":"grab",userSelect:"none"},children:[(0,vr.jsxs)("div",{className:"relative sticky top-0 rounded-t-lg bg-white",children:[(0,vr.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,vr.jsxs)("div",{children:[(0,vr.jsxs)("h3",{className:"flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100",children:[(0,vr.jsx)(Hf.DragHandleDots2Icon,{})," Feature Flags"]}),(0,vr.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400",children:["Toggle experimental features (",(0,vr.jsx)("span",{className:"font-mono",children:"Ctrl+Shift+1"})," to toggle)"]})]}),(0,vr.jsx)(E,{variant:"ghost",size:"sm",onClick:e,className:"absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:(0,vr.jsx)(Hf.Cross1Icon,{className:"h-4 w-4"})})]}),(0,vr.jsxs)("div",{className:"relative",children:[(0,vr.jsx)(Hf.MagnifyingGlassIcon,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),(0,vr.jsx)(Ce,{type:"search",placeholder:"Search features...",className:"w-full pl-8",value:n,onChange:g=>a(g.target.value),autoFocus:!0})]})]}),(0,vr.jsx)("div",{className:"max-h-96 overflow-y-auto py-2",children:Object.keys(d).length>0?(0,vr.jsx)("div",{className:"space-y-1",children:Object.entries(d).map(([g,h])=>(0,vr.jsx)(EQ,{featureKey:g,options:h},g))}):(0,vr.jsx)("div",{className:"py-8 text-center",children:(0,vr.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:['No features found matching "',n,'"']})})})]})},x_=()=>{let[e,t]=(0,h_.useAtom)(AQ);return(0,b_.useHotkeys)("ctrl+shift+1,meta+shift+1",()=>t(o=>o?{...o,show:!o.show}:{x:0,y:0,show:!0}),{enableOnFormTags:!0}),e!=null&&e.show?(0,vr.jsx)(IQ,{position:e,close:()=>t(o=>o?{...o,show:!1}:null),updatePosition:(o,r)=>t(n=>n?{...n,x:o,y:r,show:n.show}:{x:o,y:r,show:!0})}):null}});var BQ,C_,k_=x(()=>{"use strict";BQ=!1,C_=e=>{BQ=e}});var dt,Qn=x(()=>{"use strict";dt={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS",GOTO_BLOCK_SETTINGS:"GOTO_BLOCK_SETTINGS",OPEN_AI_PANEL:"OPEN_AI_PANEL",CLEAR_CANVAS_SELECTION:"CLEAR_CANVAS_SELECTION",CANVAS_BLOCK_SELECTED:"CANVAS_BLOCK_SELECTED",CANVAS_BLOCK_STYLE_SELECTED:"CANVAS_BLOCK_STYLE_SELECTED",OPEN_EXPORT_CODE:"OPEN_EXPORT_CODE"}});var iN,In,jc,vk,Yb,Uf,S_,Ha=x(()=>{"use strict";iN=require("lodash-es");Ne();In=(e,t)=>{if(!e)return!0;let o=Ct(e);return o&&o.canAcceptBlock?o.canAcceptBlock(t):!1},jc=e=>{let t=Ct(e);return t?(0,iN.has)(t,"canAcceptBlock"):!1},vk=(e,t)=>{let o=Ct(t);return o&&o.canBeNested?o.canBeNested(e):!0},Yb=e=>{let t=Ct(e);return t&&t.canDuplicate?t.canDuplicate():!0},Uf=e=>{let t=Ct(e);return t&&t.canDelete?t.canDelete():!0},S_=(e,t)=>{let o=e==null?void 0:e.pageTypes;return!Array.isArray(o)||o.length===0?!0:o.includes(t)}});var w_,rl,Ju=x(()=>{"use strict";w_=require("jotai");Oa();rl=()=>(0,w_.useAtom)(gi)});var Sk,Ck,P_,RQ,DQ,T_,kk,Qu,Jb=x(()=>{"use strict";Sk=require("himalaya"),Ck=require("lodash-es"),P_=require("react");Jn();Ha();Ju();Ne();RQ=["data-block-index","draggable","data-drop","data-style-id","data-block-parent","data-style-prop","data-highlighted"],DQ=["Box","Button","Checkbox","Divider","EmptyBox","Form","FormButton","Heading","Input","Label","LineBreak","Link","List","ListItem","Paragraph","Radio","RichText","Select","Span","Text","TextArea","Video"],T_=e=>e.type==="element"&&["script","style","link"].includes(e.tagName||"")||e.type==="comment"?null:e.type==="text"?e:e.type==="element"&&e.attributes&&e.attributes.find(t=>t.key==="id"&&t.value==="add-block-bottom")?null:(e.type==="element"&&e.attributes&&(e.attributes=e.attributes.filter(t=>!RQ.includes(t.key))),e.children&&(e.children=e.children.map(T_).filter(t=>t!==null)),e),kk=(e,t,o={})=>{var a,s,i,l,c,d,p,u;if(e.type!=="element"||!e.attributes)return e;if(e.tagName==="span"&&e.attributes.find(g=>g.key==="role"&&g.value==="link")){e.tagName="a",e.attributes=e.attributes.filter(f=>f.key!=="role");let g=(a=e.attributes.find(f=>f.key==="data-block-id"))==null?void 0:a.value,h=t==null?void 0:t.find(f=>(f==null?void 0:f._id)===g);if(h!=null&&h.link&&((i=(s=h==null?void 0:h.link)==null?void 0:s.href)==null?void 0:i.length)>0){let f=(l=h==null?void 0:h.link)==null?void 0:l.href,b=(c=h==null?void 0:h.link)==null?void 0:c.target;e.attributes.push({key:"href",value:f}),typeof b=="string"&&b.length>0&&e.attributes.push({key:"target",value:b})}}let r=e.attributes.find(m=>m.key==="data-block-type"),n=e.attributes.find(m=>m.key==="data-block-id");if(r){let m=r.value;if(DQ.includes(m)||(d=o==null?void 0:o.additionalCoreBlocks)!=null&&d.includes(m))e.attributes=e.attributes.filter(g=>g.key!=="data-block-type"),e.children&&(e.children=e.children.map(g=>kk(g,t,o)));else{let g=`chai-${(0,Ck.kebabCase)(m)}`;e.tagName=g,e.attributes=[],e.attributes.push({key:"chai-type",value:m});let h=Ct(m),f=t.find(b=>b._id===(n==null?void 0:n.value));if(f&&e.attributes.push(...Object.entries(f).filter(([b])=>!["_id","_type","_parent","_index"].includes(b)).map(([b,y])=>({key:b.startsWith("_")?"_"+(0,Ck.kebabCase)(b.slice(1)):(0,Ck.kebabCase)(b),value:typeof y=="string"?y:JSON.stringify(y)}))),h&&(h!=null&&h.description)&&e.attributes.push({key:"about-this-component",value:h.description}),h){if(h.canMove){let b=typeof h.canMove=="function"?h.canMove():h.canMove;e.attributes.push({key:"can-move",value:String(b)})}if(h.canDelete){let b=typeof h.canDelete=="function"?h.canDelete():h.canDelete;e.attributes.push({key:"can-delete",value:String(b)})}}if(m==="Icon"){let b=e.attributes.find(w=>w.key==="icon"),y=(p=b==null?void 0:b.value)!=null?p:"",k=y.includes("chai-default-svg");if(e.attributes=e.attributes.filter(w=>w.key!=="icon"),!k){let w=y.match(/\blucide-([\w-]+)\b/g);if(w){let N=w.map(C=>C.replace("lucide-","")),I=(u=N.find(C=>!C.endsWith("-icon")))!=null?u:N[0].replace(/-icon$/,"");e.attributes.push({key:"icon-name",value:I})}}}jc(m)?e.children&&(e.children=e.children.map(b=>kk(b,t,o))):e.children=[]}}else e.children&&(e.children=e.children.map(m=>kk(m,t,o)));return n&&e.attributes.push({key:"bid",value:n.value}),e.attributes=e.attributes.filter(m=>m.key!=="data-block-type"&&m.key!=="data-block-id"),e},Qu=()=>{let[e]=rl();return(0,P_.useCallback)(t=>{var c,d;if(!e)return"";let o=t!=null&&t.blockId?`[data-block-id="${t.blockId}"]`:"#canvas",r=(d=(c=e.contentDocument)==null?void 0:c.querySelector(o))==null?void 0:d[o==="#canvas"?"innerHTML":"outerHTML"];if(!r)return"";let a=(0,Sk.parse)(r).map(T_).filter(p=>p!==null),s=Od(),i=a.map(p=>kk(p,s,t)),l=(0,Sk.stringify)(i);return l=l.replace(/#styles:,/g,"#styles:"),l.replace(/\s+/g," ").trim()},[e])}});var wk,_Q,Pk,lN=x(()=>{"use strict";wk=require("jotai"),_Q=(0,wk.atom)("edit"),Pk=()=>{let[e,t]=(0,wk.useAtom)(_Q);return{mode:e,setMode:t}}});var cN,Gt,Pa=x(()=>{"use strict";cN=class{constructor(){this.subscribers=new Map}subscribe(t,o){return this.subscribers.has(t)||this.subscribers.set(t,new Set),this.subscribers.get(t).add(o),()=>{let r=this.subscribers.get(t);r&&(r.delete(o),r.size===0&&this.subscribers.delete(t))}}publish(t,o){let r=this.subscribers.get(t);r&&r.forEach(n=>n(o))}},Gt=new cN});function jd(e,t){(0,N_.useEffect)(()=>{let o=Gt.subscribe(e,t);return()=>o()},[e,t])}var N_,Tk=x(()=>{"use strict";N_=require("react");Pa()});var $l,Nk,Ek,Dr,Cr,ut,kr,xi=x(()=>{"use strict";$l=K(require("@radix-ui/react-tabs"),1),Nk=K(require("react"),1);st();Ek=require("react/jsx-runtime"),Dr=$l.Root,Cr=Nk.forwardRef(({className:e,...t},o)=>(0,Ek.jsx)($l.List,{ref:o,className:G("bg-gray inline-flex h-max items-center justify-center rounded-md border bg-accent/50 p-0.5 text-muted-foreground dark:bg-secondary/50",e),...t}));Cr.displayName=$l.List.displayName;ut=Nk.forwardRef(({className:e,...t},o)=>(0,Ek.jsx)($l.Trigger,{ref:o,className:G("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm px-1 py-1 text-xs text-foreground/80 transition-all hover:text-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:shadow-sm",e),...t}));ut.displayName=$l.Trigger.displayName;kr=Nk.forwardRef(({className:e,...t},o)=>(0,Ek.jsx)($l.Content,{ref:o,className:G("mt-1.5",e),...t}));kr.displayName=$l.Content.displayName});function E_(){return{textColor:{DEFAULT:"hsl(var(--foreground))"},colors:{border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",surface:"hsl(var(--surface))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},accent:{DEFAULT:"hsl(var(--accent))",foreground:"hsl(var(--accent-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"},success:{DEFAULT:"hsl(var(--success))",foreground:"hsl(var(--success-foreground))"},warning:{DEFAULT:"hsl(var(--warning))",foreground:"hsl(var(--warning-foreground))"},info:{DEFAULT:"hsl(var(--info))",foreground:"hsl(var(--info-foreground))"},purple:{DEFAULT:"hsl(var(--purple))",foreground:"hsl(var(--purple-foreground))"},orange:{DEFAULT:"hsl(var(--orange))",foreground:"hsl(var(--orange-foreground))"},aqua:{DEFAULT:"hsl(var(--aqua))",foreground:"hsl(var(--aqua-foreground))"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},borderColor:{DEFAULT:"hsl(var(--border))"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}}var LQ,MQ,OQ,A_=x(()=>{"use strict";LQ=K(require("@tailwindcss/container-queries"),1),MQ=K(require("@tailwindcss/forms"),1),OQ=K(require("@tailwindcss/typography"),1)});function I_(e){let t={class:"className",for:"htmlFor",tabindex:"tabIndex",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",novalidate:"noValidate",crossorigin:"crossOrigin",datetime:"dateTime",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",allowfullscreen:"allowFullScreen"};if(t[e.toLowerCase()])return t[e.toLowerCase()];let o={"accent-height":"accentHeight","alignment-baseline":"alignmentBaseline","arabic-form":"arabicForm","baseline-shift":"baselineShift","cap-height":"capHeight","clip-path":"clipPath","clip-rule":"clipRule","color-interpolation":"colorInterpolation","color-interpolation-filters":"colorInterpolationFilters","color-profile":"colorProfile","color-rendering":"colorRendering","dominant-baseline":"dominantBaseline","enable-background":"enableBackground","fill-opacity":"fillOpacity","fill-rule":"fillRule","flood-color":"floodColor","flood-opacity":"floodOpacity","font-family":"fontFamily","font-size":"fontSize","font-size-adjust":"fontSizeAdjust","font-stretch":"fontStretch","font-style":"fontStyle","font-variant":"fontVariant","font-weight":"fontWeight","glyph-name":"glyphName","glyph-orientation-horizontal":"glyphOrientationHorizontal","glyph-orientation-vertical":"glyphOrientationVertical","horiz-adv-x":"horizAdvX","horiz-origin-x":"horizOriginX","image-rendering":"imageRendering","letter-spacing":"letterSpacing","lighting-color":"lightingColor","marker-end":"markerEnd","marker-mid":"markerMid","marker-start":"markerStart","overline-position":"overlinePosition","overline-thickness":"overlineThickness","paint-order":"paintOrder","panose-1":"panose1","pointer-events":"pointerEvents","rendering-intent":"renderingIntent","shape-rendering":"shapeRendering","stop-color":"stopColor","stop-opacity":"stopOpacity","strikethrough-position":"strikethroughPosition","strikethrough-thickness":"strikethroughThickness","stroke-dasharray":"strokeDasharray","stroke-dashoffset":"strokeDashoffset","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","stroke-miterlimit":"strokeMiterlimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-anchor":"textAnchor","text-decoration":"textDecoration","text-rendering":"textRendering","underline-position":"underlinePosition","underline-thickness":"underlineThickness","unicode-bidi":"unicodeBidi","unicode-range":"unicodeRange","units-per-em":"unitsPerEm","v-alphabetic":"vAlphabetic","v-hanging":"vHanging","v-ideographic":"vIdeographic","v-mathematical":"vMathematical","vector-effect":"vectorEffect","vert-adv-y":"vertAdvY","vert-origin-x":"vertOriginX","vert-origin-y":"vertOriginY","word-spacing":"wordSpacing","writing-mode":"writingMode","x-height":"xHeight"};return o[e]?o[e]:e}function Qb(e,t=0){var c;if(Array.isArray(e)){if(e.length===0)return"";if(e.length===1)return Qb(e[0],t);let d=" ".repeat(t),p=`${d}<>
2
+ `;for(let u of e)p+=Qb(u,t+1);return p+=`${d}</>
3
+ `,p}let o=" ".repeat(t);if(e.nodeType===Node.TEXT_NODE){let d=(c=e.textContent)==null?void 0:c.trim();return d?`${o}${d}
4
+ `:""}if(e.nodeType!==Node.ELEMENT_NODE)return"";let r=e.tagName.toLowerCase();if(["img","br","hr","input","meta","link","area","base","col","embed","source","track","wbr"].includes(r)){let d=[];for(let u of e.attributes)if(u.name.startsWith("on")&&u.name!=="on"){let m=u.name.toLowerCase().replace(/on(\w)/,(g,h)=>"on"+h.toUpperCase());d.push(`${m}={${u.value}}`)}else if(u.name==="style"&&u.value){let m=u.value.split(";").reduce((g,h)=>{let[f,b]=h.split(":").map(y=>y.trim());if(f&&b){let y=f.replace(/-([a-z])/g,k=>k[1].toUpperCase());g[y]=b.replace(/['"]/g,"")}return g},{});d.push(`style={${JSON.stringify(m)}}`)}else{let m=I_(u.name);d.push(`${m}="${u.value}"`)}let p=d.length>0?` ${d.join(" ")}`:"";return`${o}<${r}${p} />
5
+ `}let a=`${o}<${r}`,s=[];for(let d of e.attributes)if(d.name.startsWith("on")&&d.name!=="on"){let p=d.name.toLowerCase().replace(/on(\w)/,(u,m)=>"on"+m.toUpperCase());s.push(`${p}={${d.value}}`)}else if(d.name==="style"&&d.value){let p=d.value.split(";").reduce((u,m)=>{let[g,h]=m.split(":").map(f=>f.trim());if(g&&h){let f=g.replace(/-([a-z])/g,b=>b[1].toUpperCase());u[f]=h.replace(/['"]/g,"")}return u},{});s.push(`style={${JSON.stringify(p)}}`)}else{let p=I_(d.name);s.push(`${p}="${d.value}"`)}s.length>0&&(a+=" "+s.join(" "));let i=Array.from(e.childNodes);if(!i.some(d=>{var p;return d.nodeType===Node.TEXT_NODE?(p=d.textContent)==null?void 0:p.trim():!0}))a+=` />
6
+ `;else{a+=`>
7
+ `;for(let d of i)a+=Qb(d,t+1);a+=`${o}</${r}>
8
+ `}return a}function Gf(e){if(!e)return"";let t="",o=0,r=" ";return e=e.replace(/>\s+</g,"><").trim(),e.split(/(<\/?[^>]+>)/g).filter(a=>a.trim()).forEach(a=>{a.match(/^<\/\w/)?(o=Math.max(0,o-1),t+=r.repeat(o)+a+`
9
+ `):a.match(/\/>$/)?t+=r.repeat(o)+a+`
10
+ `:a.match(/^<\w[^>]*[^\/]>$/)?(t+=r.repeat(o)+a+`
11
+ `,o++):a.trim()&&(t+=r.repeat(o)+a.trim()+`
12
+ `)}),t.trim()}var Ak=x(()=>{"use strict"});var Ik,B_,R_=x(()=>{"use strict";Ik=require("react"),B_=()=>{let[e,t]=(0,Ik.useState)("light");return(0,Ik.useEffect)(()=>{let o=window.document.documentElement,r=window.document.body,n=()=>{let s=o.classList.contains("dark")||r.classList.contains("dark");t(s?"dark":"light")};n();let a=new MutationObserver(s=>{s.forEach(i=>{i.attributeName==="class"&&n()})});return a.observe(o,{attributes:!0,attributeFilter:["class"]}),a.observe(r,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),{isDarkMode:e==="dark"}}});var L_={};et(L_,{default:()=>__});function __({code:e,onCopy:t,language:o="javascript",onDownload:r,downloadText:n="Download"}){let[a,s]=(0,dN.useState)(!1),[i,l]=(0,dN.useState)(e),{isDarkMode:c}=B_();return(0,Vl.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,Vl.jsx)("div",{className:"h-[500px] max-h-full overflow-hidden rounded-md border py-2",children:(0,Vl.jsx)(D_.default,{height:"100%",defaultLanguage:o,language:o,value:i,onChange:u=>l(u||""),theme:c?"vs-dark":"light",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"off",roundedSelection:!1,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,insertSpaces:!0,wordWrap:"on",bracketPairColorization:{enabled:!0},suggest:{showKeywords:!1,showSnippets:!1}}})}),(0,Vl.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,Vl.jsxs)(E,{type:"button",variant:"outline",onClick:()=>{t(i),s(!0),setTimeout(()=>{s(!1)},2e3)},children:[a?(0,Vl.jsx)($f.CheckIcon,{className:"text-green-500"}):(0,Vl.jsx)($f.CopyIcon,{})," ",a?"Copied":"Copy"]}),(0,Vl.jsxs)(E,{type:"button",variant:"default",onClick:()=>{r(i)},children:[(0,Vl.jsx)($f.DownloadIcon,{})," ",n]})]})]})}var D_,$f,dN,Vl,M_=x(()=>{"use strict";D_=K(require("@monaco-editor/react"),1),$f=require("@radix-ui/react-icons"),dN=require("react");R_();J();Vl=require("react/jsx-runtime")});async function HQ(e){try{let t=document.createElement("div");t.innerHTML=e;let o=Array.from(t.children);return{jsx:Qb(o.length===1?o[0]:o),html:t.innerHTML}}catch(t){return{html:e,jsx:e}}}var O_,Ta,F_,pN,Xb,nn,FQ,UQ,GQ,H_,U_=x(()=>{"use strict";O_=require("lodash-es"),Ta=require("react"),F_=require("react-error-boundary"),pN=require("react-i18next"),Xb=require("sonner");Qn();Jb();lN();Tk();Ge();qt();xi();A_();Ak();nn=require("react/jsx-runtime"),FQ=(0,Ta.lazy)(()=>Promise.resolve().then(()=>(M_(),L_)));UQ=async({selectedBlock:e,html:t,isTypeScript:o=!1})=>{let r=(e==null?void 0:e._name)||(e==null?void 0:e._type)||"Component";r=(0,O_.camelCase)(r).replace(/^./,d=>d.toUpperCase());let n=" ",{jsx:a,html:s}=await HQ(t),i=a==null?void 0:a.split(`
13
+ `).join(`
14
+ ${n}${n}`);return i=`${o?`import React from 'react';
15
+
16
+ `:""}export const ${r}${o?": React.FC":""} = () => {
17
+ ${n}return (
18
+ ${n}${n}${i==null?void 0:i.trimEnd()}
19
+ ${n})
20
+ }`,{jsx:i,html:Gf(s),componentName:r}},GQ=({tab:e})=>{var f;let{t}=(0,pN.useTranslation)(),[o,r]=(0,Ta.useState)({html:"",jsx:""}),n=_e(),a=Qu(),[s,i]=(0,Ta.useState)(""),[l,c]=(0,Ta.useState)(!1),d=()=>{switch(e){case"js":return`${s}.jsx`;case"ts":return`${s}.tsx`;case"html":return`${s}.html`;case"tailwind":return"tailwind.config.js"}},p=()=>{switch(e){case"js":case"ts":return"javascript";case"html":return"HTML";case"tailwind":return"JSON"}};(0,Ta.useEffect)(()=>{(async()=>{let y=n!=null?n:{_name:"Body",_type:"Body"};try{c(!1);let k=a(n?{blockId:n._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});k=k.replace(/\s*bid=["'][^"']*["']/g,"");let w=e==="ts",{jsx:N,html:I,componentName:C}=await UQ({selectedBlock:y,html:k,isTypeScript:w});r({html:I||"",jsx:N}),i(C),c(!0)}catch(k){let w="<div>Export failed. Close the modal and try again.</div>";r({html:w,jsx:w}),Xb.toast.error(t("Failed to generate export HTML"))}})()},[t,e,n,a]);let u=(0,Ta.useCallback)(async b=>{try{navigator.clipboard.writeText(b),Xb.toast.success(t("Export code copied!"))}catch(y){Xb.toast.error(t("Failed to copy export code"))}},[t]),m=b=>{var N;let y=new Blob([b],{type:"text/jsx"}),k=URL.createObjectURL(y),w=document.createElement("a");w.href=k,w.download=(N=d())!=null?N:"",document.body.appendChild(w),w.click(),URL.revokeObjectURL(k),document.body.removeChild(w),Xb.toast.success(t("Export code downloaded successfully!"))},g=(0,nn.jsxs)("span",{children:["Download ",(0,nn.jsx)("span",{className:"font-mono text-xs font-light text-foreground",children:d()})]}),h=(0,Ta.useMemo)(()=>{let b={extend:E_()},y=JSON.stringify(b,null,2);return`{
21
+ // Your tailwind config ...
22
+
23
+ "theme": ${y==null?void 0:y.split(`
24
+ `).join(`
25
+ `)},
26
+ }`},[]);return((f=o==null?void 0:o.jsx)==null?void 0:f.length)>0&&l?(0,nn.jsx)(FQ,{onCopy:u,code:e==="tailwind"?h:e==="html"?o.html:o.jsx,language:p()||"",downloadText:g,onDownload:m},e):(0,nn.jsx)("div",{className:"flex h-[620px] w-full items-center justify-center p-4",children:"Generating code..."})},H_=()=>{let{t:e}=(0,pN.useTranslation)(),[t,o]=(0,Ta.useState)(!1),{setMode:r}=Pk(),[n,a]=(0,Ta.useState)("js"),s=(0,Ta.useCallback)(async()=>{a("js"),r("view"),o(!0)},[a,r,o]);return jd(dt.OPEN_EXPORT_CODE,s),(0,nn.jsx)(Te,{open:t,onOpenChange:async()=>{r("edit"),await new Promise(l=>setTimeout(l,300)),o(!1)},children:(0,nn.jsxs)(we,{className:"max-w-5xl overflow-hidden border-border",children:[(0,nn.jsxs)(Oe,{className:"flex flex-row items-center justify-between",children:[(0,nn.jsx)(Ie,{className:"text-foreground",children:e("Export Code")}),(0,nn.jsx)(Dr,{defaultValue:"js",onValueChange:a,children:(0,nn.jsxs)(Cr,{children:[(0,nn.jsx)(ut,{value:"js",className:"px-2 text-xs",children:"Javascript"}),(0,nn.jsx)(ut,{value:"ts",className:"px-2 text-xs",children:"Typescript"}),(0,nn.jsx)(ut,{value:"html",className:"px-2 text-xs",children:"HTML"}),(0,nn.jsx)(ut,{value:"tailwind",className:"px-2 text-xs",children:"Tailwind config"})]})}),(0,nn.jsx)("div",{})]}),(0,nn.jsx)("div",{className:"flex min-h-[400px] flex-col gap-4",children:t&&(0,nn.jsx)(Ta.Suspense,{fallback:(0,nn.jsx)("div",{className:"flex h-[400px] items-center justify-center text-muted-foreground",children:"Loading code editor..."}),children:(0,nn.jsx)(F_.ErrorBoundary,{fallback:(0,nn.jsx)("div",{children:"Something went wrong"}),children:(0,nn.jsx)(GQ,{tab:n})})})})]})})}});var G_,Ms,$_,V_=x(()=>{"use strict";G_=K(require("react"),1);Ke();Ms=require("react/jsx-runtime"),$_=()=>{let e=q("smallScreenComponent",null);return(0,Ms.jsx)("section",{className:"fixed inset-0 z-[99999] flex h-screen w-screen items-center justify-center bg-white xl:hidden",children:e?G_.default.createElement(e):(0,Ms.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-[linear-gradient(to_right,#f3f4f6_1px,transparent_1px),linear-gradient(to_bottom,#f3f4f6_1px,transparent_1px)] bg-[size:10px_10px] py-12 sm:py-16 lg:py-20",children:(0,Ms.jsx)("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:(0,Ms.jsxs)("div",{className:"mx-auto max-w-md space-y-6 text-center",children:[(0,Ms.jsxs)("div",{className:"space-y-4",children:[(0,Ms.jsx)("h2",{className:"text-5xl font-bold tracking-tight text-gray-900",children:"Screen too small"}),(0,Ms.jsxs)("p",{className:"mx-auto max-w-sm text-sm leading-7 text-gray-600",children:["Please view this page on greater than ",(0,Ms.jsx)("strong",{className:"font-medium",children:"1280px"})," screen width for the best experience."]})]}),(0,Ms.jsx)("div",{className:"pt-4",children:(0,Ms.jsxs)("div",{className:"inline-flex items-center rounded-full bg-gray-100 px-4 py-2 text-sm text-gray-700",children:[(0,Ms.jsx)("svg",{className:"mr-2 h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Ms.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),"Minimum width: 1280px"]})})]})})})})}});function $Q(){return new URLSearchParams(window.location.search).get(uN)}function z_(e){let t=new URL(window.location.href);e?t.searchParams.set(uN,e):t.searchParams.delete(uN),window.history.replaceState({},"",t.toString())}var mN,W_,Zb,uN,j_,q_=x(()=>{"use strict";mN=require("jotai"),W_=require("lodash-es"),Zb=require("react");zr();CC();Ge();uN="bid";j_=()=>{let[e,t]=Pe(),o=(0,mN.useAtomValue)(Ot),r=(0,mN.useAtomValue)(Pb),n=(0,Zb.useRef)(!1);(0,Zb.useEffect)(()=>{if(!r||n.current||o.length===0)return;n.current=!0;let a=$Q();if(!a)return;o.some(i=>i._id===a)?t([a]):z_(null)},[r,o,t]),(0,Zb.useEffect)(()=>{if(!n.current)return;let a=(0,W_.first)(e)||null;z_(a)},[e])}});var K_,ex,qd,pa,Kd=x(()=>{"use strict";K_=require("jotai"),ex=require("react");Oa();qd=null,pa=()=>{let[e]=(0,K_.useAtom)(gi),t=(0,ex.useMemo)(()=>{var n;return(e==null?void 0:e.contentDocument)||((n=e==null?void 0:e.contentWindow)==null?void 0:n.document)},[e]),o=(0,ex.useCallback)(n=>{if(t)if(qd&&qd.removeAttribute("data-highlighted"),typeof n!="string")n.setAttribute("data-highlighted","true"),qd=n;else if(typeof n=="string"){let a=t.querySelector(`[data-block-id="${n}"]`);a&&(a.setAttribute("data-highlighted","true"),qd=a)}else qd=null},[t]),r=(0,ex.useCallback)(()=>{qd&&(qd.removeAttribute("data-highlighted"),qd=null)},[]);return{highlightBlock:o,clearHighlight:r,lastHighlighted:qd}}});var Yd=x(()=>{"use strict";m0()});var Bk,mm,ao,fn=x(()=>{"use strict";Bk=require("jotai"),mm=(0,Bk.atom)([]);mm.debugLabel="selectedStylingBlocksAtom";ao=()=>(0,Bk.useAtom)(mm)});var gN,Y_,J_=x(()=>{"use strict";gN=require("jotai");Wr();Oa();OC();Pf();Kd();Yd();Nn();Ge();fn();Y_=()=>{let{clear:e}=Mc(),[,t]=Pe(),{clearHighlight:o}=pa(),[,r]=ao(),[,n]=(0,gN.useAtom)(r0),{reset:a}=Dc(),{setSaveState:s}=to(),[,i]=MC(),[,l]=(0,gN.useAtom)(Uu);return()=>{i({}),t([]),r([]),o(),e(),n(!1),a(),s("SAVED"),l(0)}}});var Vf,Os,Q_,VQ,zQ,X_,Z_=x(()=>{"use strict";Vf=require("jotai"),Os=require("lodash-es"),Q_=require("react");zr();Ge();VQ=(e,t)=>{let o=[],r=(0,Os.find)(e,{_id:t}),n=(0,Os.get)(r,"_parent","");for(;(0,Os.isString)(n)&&!(0,Os.isEmpty)(n);)o.push(r==null?void 0:r._parent),r=(0,Os.find)(e,{_id:n}),n=r==null?void 0:r._parent;return(0,Os.flatten)(o)},zQ=(0,Vf.atom)([]),X_=()=>{let[e]=Pe(),t=(0,Vf.useAtomValue)(Ot),[,o]=(0,Vf.useAtom)(zQ);(0,Q_.useEffect)(()=>{let r=[],n=(0,Os.first)(e);(0,Os.isString)(n)&&(r=[n,...VQ(t,n)]),o(r)},[e,t,o])}});var WQ,eL,tL,oL=x(()=>{"use strict";WQ=new Set(["text","search","url","tel","email","password","number","date","datetime-local","month","week","time"]),eL=e=>{let t=e.target;if(!(t instanceof Element))return!1;if(t.tagName==="TEXTAREA")return!0;if(t.tagName==="INPUT"){let o=t.type||"text";return WQ.has(o)}return!!(t.isContentEditable||t.closest('[contenteditable="true"]'))},tL=e=>{let t=e.target;return t instanceof Element&&t.tagName==="IFRAME"}});var zf,rL,fN,um,Wf=x(()=>{"use strict";zf=require("jotai"),rL=require("react");Rk();fN=(0,zf.atom)([]),um=()=>{let[e,t]=(0,zf.useAtom)(fN),o=(0,zf.useSetAtom)(hN),r=(0,rL.useCallback)(n=>{t(n),o([])},[t,o]);return[e,r]}});var jf,tx,yN,Dk,hN,_k,Rk=x(()=>{"use strict";jf=require("jotai"),tx=require("lodash-es"),yN=require("react"),Dk=require("sonner");uf();ko();Ke();Wf();Yd();hN=(0,jf.atom)([]),_k=()=>{let[e]=Pt(),[t,o]=(0,jf.useAtom)(hN),r=(0,jf.useSetAtom)(fN),{getPartialBlocks:n}=Dc(),a=q("flags.copyPaste",!0),s=(0,yN.useCallback)(l=>l.some(c=>xb(e,c,null).some(p=>p._type==="PartialBlock"||p._type==="GlobalBlock")),[e]),i=(0,yN.useCallback)(async(l,c=!1)=>{try{if((0,tx.isEmpty)(l))return;o(l),r([]);let d={_chai_copied_blocks:l.flatMap(p=>{let u=xb(e,p,null);if(!c)return u;let m=[];for(let g of u)if(g._type==="PartialBlock"||g._type==="GlobalBlock"){let h=n(g.partialBlockId);g._parent&&(h==null?void 0:h.length)>0&&(h=h.map(f=>((0,tx.isEmpty)(f._parent)&&(0,tx.set)(f,"_parent",g._parent),f))),m=[...m,...h]}else m.push(g);return m})};if(!a)return;if(!navigator.clipboard){Dk.toast.error("Clipboard not available.");return}Dk.toast.promise(navigator.clipboard.writeText(JSON.stringify(d)),{success:"Blocks copied successfully",error:"Failed to copy blocks to clipboard"})}catch(d){Dk.toast.error("Failed to copy blocks to clipboard"),console.error("Failed to copy blocks to clipboard:",d)}},[o,r,a,e,n]);return[t,i,s]}});var gm,nL,qf,Lk=x(()=>{"use strict";gm=require("lodash-es"),nL=require("react");uf();ko();Ge();qf=()=>{let[e]=Pt(),[,t]=Pe(),{addBlocks:o}=Ft();return(0,nL.useCallback)((r,n=null)=>{let a=[];(0,gm.each)(r,s=>{var u;let i=e.find(m=>m._id===s);n?n==="root"&&(n=null):n=(u=i==null?void 0:i._parent)!=null?u:null;let d=(0,gm.filter)(e,m=>(0,gm.isString)(n)?m._parent===n:!m._parent).indexOf(i)+1,p=xb(e,s,n);o(p,n!=null?n:void 0,d),a.push((0,gm.get)(p,"0._id",""))}),t(a)},[o,e,t])}});var ms,Mk,jQ,qQ,Xn,zl=x(()=>{"use strict";ms=require("lodash-es"),Mk=require("react");Ha();pn();ko();Ge();Ne();jQ=100,qQ=(e,t,o,r,n)=>{let a=n,s=r||(0,ms.first)(o),i,l=null;for(;s;){let c=(0,ms.find)(t,{_id:s});if(!c)break;if(In(c._type,e)&&vk(c._type,e)){if(i=c._id,l&&n===void 0){let p=(0,ms.filter)(t,{_parent:i}).findIndex(u=>u._id===l);p!==-1&&(a=p+1)}break}else l=s,s=c==null?void 0:c._parent}if(!i&&l&&n===void 0){let d=(0,ms.filter)(t,p=>!p._parent).findIndex(p=>p._id===l);d!==-1&&(a=d+1)}return{parentBlockId:i,insertPosition:a}},Xn=()=>{let[e]=Pt(),[t,o]=Pe(),{addBlocks:r}=Ft(),n=(0,Mk.useCallback)((i,l,c)=>qQ(i,e,t,l,c),[e,t]),a=(0,Mk.useCallback)((i,l,c)=>{for(let m=0;m<i.length;m++){let{_id:g}=i[m];i[m]._id=Uo();let h=(0,ms.filter)(i,{_parent:g});for(let f=0;f<h.length;f++)h[f]._parent=i[m]._id}let d=(0,ms.first)(i),{parentBlockId:p,insertPosition:u}=n(d._type,l,c);return i[0]._parent=p,(0,ms.forEach)(i,m=>{m!=null&&m._parent||(m._parent=p)}),r(i,p,u),o([d._id]),d},[r,n,o]);return{addCoreBlock:(0,Mk.useCallback)((i,l,c)=>{if((0,ms.has)(i,"blocks")){let f=i.blocks;return a(f,l!=null?l:void 0,c)}let d=Uo(),p=Fl(i.type),u={_type:i.type,_id:d,...p,...(0,ms.has)(i,"_name")&&{_name:i._name},...(0,ms.has)(i,"partialBlockId")&&{partialBlockId:i.partialBlockId}},{parentBlockId:m,insertPosition:g}=n(u._type,l,c);return u._parent=m,r([u],m,g),setTimeout(()=>o([u._id]),jQ),u},[r,a,n,o]),addPredefinedBlock:a}}});var aL,qc,Ok,Kf,bN,KQ,YQ,Yf,Fk=x(()=>{"use strict";aL=require("jotai"),qc=require("lodash-es"),Ok=require("react"),Kf=require("sonner");zr();Ha();ko();zl();Wf();bN=()=>navigator.userAgent.toLowerCase().includes("firefox"),KQ=()=>{let[e]=Pt();return(t,o)=>{var a;let r=((a=(0,qc.find)(e,{_id:o}))==null?void 0:a._type)||null,n=(0,qc.first)(t.map(s=>{var i;return(i=(0,qc.find)(e,{_id:s}))==null?void 0:i._type}));return In(r,n)}},YQ=()=>{let e=(0,aL.useAtomValue)(Ot),{moveBlocks:t}=Ft();return(0,Ok.useCallback)((o,r)=>{let n=Array.isArray(r)?r[0]:r;if(r==="root"){let a=e==null?void 0:e.filter(s=>!s._parent);t(o,void 0,(a==null?void 0:a.length)||0)}else{let a=e==null?void 0:e.filter(s=>s._parent===n);t(o,n,(a==null?void 0:a.length)||0)}},[t,e])},Yf=()=>{let[e,t]=um(),o=YQ(),{addPredefinedBlock:r}=Xn(),n=KQ();return{canPaste:(0,Ok.useCallback)(async s=>{if(e.length>0)return n(e,s);if(bN())return!1;try{let i=await navigator.clipboard.readText();if(i){let l=JSON.parse(i);return(0,qc.has)(l,"_chai_copied_blocks")}}catch(i){return!1}return!1},[n,e]),pasteBlocks:(0,Ok.useCallback)(async s=>{let i=Array.isArray(s)?s[0]:s;if(!(0,qc.isEmpty)(e)){o(e,s),t([]),bN()||await navigator.clipboard.writeText("");return}if(bN()){Kf.toast.error("Paste is not supported in Firefox");return}if(!(navigator!=null&&navigator.permissions)){Kf.toast.error("Cannot check clipboard permissions.");return}try{if((await navigator.permissions.query({name:"clipboard-read"})).state==="denied"){Kf.toast.error("Clipboard paste permission denied. Please allow clipboard access.");return}}catch(l){Kf.toast.error("Failed to check clipboard permissions. Please allow clipboard access.");return}Kf.toast.promise(async()=>{let l=await navigator.clipboard.readText();if(l){let c=JSON.parse(l);if((0,qc.has)(c,"_chai_copied_blocks"))r(c._chai_copied_blocks,i==="root"?null:i);else throw new Error("Nothing to paste")}else throw new Error("Nothing to paste")},{success:()=>"Blocks pasted successfully",error:()=>"Nothing to paste"})},[e,o,t,r])}}});var ox,iL,Kc,sL,Hk,xN=x(()=>{"use strict";ox=require("lodash-es"),iL=require("react"),Kc=require("react-hotkeys-hook");Ha();Pf();oL();Rk();Wf();Lk();Fk();om();Nn();Ge();sL=e=>{var n,a,s;let t=e.target,o=(s=(a=(n=e.view)==null?void 0:n.getSelection)==null?void 0:a.call(n))!=null?s:window.getSelection();return!!o&&!o.isCollapsed?!0:!!(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable||t.closest('[contenteditable="true"], [data-allow-native-copy="true"]')))},Hk=e=>{let[t,o]=Pe(),r=_e(),n=_c(),a=qf(),{undo:s,redo:i}=Mc(),[,l]=um(),[,c]=_k(),{canPaste:d,pasteBlocks:p}=Yf(),{savePage:u}=to(),m=(0,iL.useCallback)(({checkForEnabled:g,preventDefault:h,ignoreTextEntry:f=!0,enableOnContentEditable:b=!1})=>{let y={enableOnFormTags:!0,enableOnContentEditable:b,ignoreEventWhen:k=>tL(k)||f&&eL(k)};return e&&(y.document=e),g&&(y.enabled=!(0,ox.isEmpty)(t)),h&&(y.preventDefault=!0),y},[e,t]);(0,Kc.useHotkeys)("ctrl+z,meta+z",g=>{g.preventDefault(),_s.hasUndo()&&s()},m({checkForEnabled:!1,preventDefault:!0}),[e,s]),(0,Kc.useHotkeys)("ctrl+y,meta+y,ctrl+shift+z,meta+shift+z",g=>{g.preventDefault(),_s.hasRedo()&&i()},m({checkForEnabled:!1,preventDefault:!0}),[e,i]),(0,Kc.useHotkeys)("ctrl+x,meta+x",g=>{sL(g)||(g.preventDefault(),(0,ox.isEmpty)(t)||l(t))},m({checkForEnabled:!0,preventDefault:!1}),[e,l,t]),(0,Kc.useHotkeys)("ctrl+c,meta+c",g=>{sL(g)||(g.preventDefault(),c(t))},m({checkForEnabled:!0,preventDefault:!1}),[e,c,t]),(0,Kc.useHotkeys)("ctrl+v,meta+v",async()=>{await d(t[0])&&p(t)},m({checkForEnabled:!0,preventDefault:!1}),[e,d,t,p]),(0,Kc.useHotkeys)("esc",()=>{var h;let g=(h=(e!=null?e:document).activeElement)!=null?h:null;if(g&&(g.matches("input, textarea, select")||g.isContentEditable)){g.blur();return}o([])},m({checkForEnabled:!1,preventDefault:!1,ignoreTextEntry:!1,enableOnContentEditable:!0}),[e,o]),(0,Kc.useHotkeys)("ctrl+d,meta+d",()=>{a(t)},m({checkForEnabled:!0,preventDefault:!0}),[e,t,a]),(0,Kc.useHotkeys)("del, backspace",()=>{Uf((0,ox.get)(r,"_type",""))&&n(t)},m({checkForEnabled:!1,preventDefault:!0}),[e,t,n]),(0,Kc.useHotkeys)("mod+s",()=>{u()},m({checkForEnabled:!1,preventDefault:!0,ignoreTextEntry:!1,enableOnContentEditable:!0}),[e,u])}});var lL,vN,CN,kN=x(()=>{"use strict";lL=require("lodash-es"),vN=require("react/jsx-runtime"),CN=({className:e="h-full w-full",onClick:t=lL.noop})=>(0,vN.jsx)("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor",onClick:t,children:(0,vN.jsx)("path",{d:"m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8"})})});var Ut,Jf,Yc,Fn,Yt,$t,Uk,Gk,$k,rx,nx,Vt,ye,Jc,JQ,Ua,Hn,QQ,Sr=x(()=>{"use strict";Ut=K(require("@radix-ui/react-dropdown-menu"),1),Jf=require("@radix-ui/react-icons"),Yc=K(require("react"),1);st();Fn=require("react/jsx-runtime"),Yt=Ut.Root,$t=Yc.forwardRef(({className:e,...t},o)=>(0,Fn.jsx)(Ut.Trigger,{ref:o,className:G("outline-none focus:outline-none focus:ring-0 focus-visible:outline-none focus-visible:ring-0 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",e),...t}));$t.displayName=Ut.Trigger.displayName;Uk=Ut.Group,Gk=Ut.Portal,$k=Ut.Sub,rx=Yc.forwardRef(({className:e,inset:t,children:o,...r},n)=>(0,Fn.jsxs)(Ut.SubTrigger,{ref:n,className:G("flex cursor-default select-none items-center gap-1.5 rounded-sm px-2 py-1 text-xs outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0",t&&"pl-7",e),...r,children:[o,(0,Fn.jsx)(Jf.ChevronRightIcon,{className:"ml-auto h-3 w-3"})]}));rx.displayName=Ut.SubTrigger.displayName;nx=Yc.forwardRef(({className:e,...t},o)=>(0,Fn.jsx)(Ut.SubContent,{ref:o,className:G("z-50 min-w-[7rem] origin-[--radix-dropdown-menu-content-transform-origin] overflow-hidden rounded-md border bg-popover p-0.5 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));nx.displayName=Ut.SubContent.displayName;Vt=Yc.forwardRef(({className:e,sideOffset:t=4,...o},r)=>(0,Fn.jsx)(Ut.Portal,{children:(0,Fn.jsx)(Ut.Content,{ref:r,sideOffset:t,className:G("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[7rem] overflow-y-auto overflow-x-hidden rounded-sm border border-foreground/10 bg-popover text-popover-foreground shadow-2xl shadow-foreground/10","origin-[--radix-dropdown-menu-content-transform-origin] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));Vt.displayName=Ut.Content.displayName;ye=Yc.forwardRef(({className:e,inset:t,...o},r)=>(0,Fn.jsx)(Ut.Item,{ref:r,className:G("relative flex cursor-pointer select-none items-center gap-1.5 px-2 py-1 text-xs font-light outline-none transition-colors duration-300 hover:bg-accent focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-3.5 [&>svg]:shrink-0",t&&"pl-8",e),...o}));ye.displayName=Ut.Item.displayName;Jc=Yc.forwardRef(({className:e,children:t,checked:o,...r},n)=>(0,Fn.jsxs)(Ut.CheckboxItem,{ref:n,className:G("relative flex cursor-pointer select-none items-center gap-1.5 py-1 pl-6 pr-2 text-xs font-light outline-none transition-colors duration-300 hover:bg-accent focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-3.5 [&>svg]:shrink-0",e),checked:o,...r,children:[(0,Fn.jsx)("span",{className:"absolute left-1.5 flex h-3 w-3 items-center justify-center",children:(0,Fn.jsx)(Ut.ItemIndicator,{children:(0,Fn.jsx)(Jf.CheckIcon,{className:"h-3 w-3"})})}),t]}));Jc.displayName=Ut.CheckboxItem.displayName;JQ=Yc.forwardRef(({className:e,children:t,...o},r)=>(0,Fn.jsxs)(Ut.RadioItem,{ref:r,className:G("relative flex cursor-default select-none items-center rounded-sm py-1 pl-7 pr-2 text-xs outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[(0,Fn.jsx)("span",{className:"absolute left-1.5 flex h-3 w-3 items-center justify-center",children:(0,Fn.jsx)(Ut.ItemIndicator,{children:(0,Fn.jsx)(Jf.CircleIcon,{className:"h-1.5 w-1.5 fill-current"})})}),t]}));JQ.displayName=Ut.RadioItem.displayName;Ua=Yc.forwardRef(({className:e,inset:t,...o},r)=>(0,Fn.jsx)(Ut.Label,{ref:r,className:G("border-none px-2 py-1 text-xs font-light text-foreground/50",t&&"pl-7",e),...o}));Ua.displayName=Ut.Label.displayName;Hn=Yc.forwardRef(({className:e,...t},o)=>(0,Fn.jsx)(Ut.Separator,{ref:o,className:G("-mx-0.5 my-0.5 h-px border-b border-border",e),...t}));Hn.displayName=Ut.Separator.displayName;QQ=({className:e,...t})=>(0,Fn.jsx)("span",{className:G("ml-auto text-xs tracking-widest opacity-60",e),...t});QQ.displayName="DropdownMenuShortcut"});var Qc,cL,fm,XQ,dL,pL=x(()=>{"use strict";Qc=require("lodash-es"),cL=require("react-i18next");zr();Jn();Qn();Ha();Pa();mn();Sr();tn();fm=require("react/jsx-runtime"),XQ=({block:e,children:t})=>{let{t:o}=(0,cL.useTranslation)(),{hasPermission:r}=kt(),n=(0,Qc.get)(e,"_id"),a=(0,Qc.get)(e,"_parent"),s=jc((0,Qc.get)(e,"_type","")),i=l=>{if(l==="CHILD")Gt.publish(dt.OPEN_ADD_BLOCK,e);else{let c=be.get(Ot),d=(0,Qc.filter)(c,m=>a?(0,Qc.get)(m,"_parent")===a:!(0,Qc.get)(m,"_parent")),p=(0,Qc.findIndex)(d,{_id:n}),u={_id:a||"",position:d==null?void 0:d.length};l==="BEFORE"?u.position=Math.max(p,0):l==="AFTER"&&(u.position=p+1),Gt.publish(dt.OPEN_ADD_BLOCK,u)}};return r(xe["pages:update"])?(0,fm.jsxs)(Yt,{children:[(0,fm.jsx)($t,{children:t}),(0,fm.jsxs)(Vt,{className:"border border-blue-500 bg-primary text-white shadow-2xl",children:[s&&(0,fm.jsx)(ye,{className:"cursor-pointer text-xs",onClick:()=>i("CHILD"),children:o("Add inside")}),(0,fm.jsx)(ye,{className:"cursor-pointer text-xs",onClick:()=>i("BEFORE"),children:o("Add before")}),(0,fm.jsx)(ye,{className:"cursor-pointer text-xs",onClick:()=>i("AFTER"),children:o("Add after")})]})]}):null},dL=XQ});function ZQ(e,t){let o=e.getAttribute("data-block-name"),r=e.getAttribute("data-block-type"),n=o||r||"Container",a=t.createElement("div");return a.className="chai-drag-parent-label",a.textContent=n,a.className="absolute top-0 -left-0.5 -translate-x-0.5 -translate-y-full -mt-1 bg-green-500/95 text-white px-2 py-1 text-xs font-semibold font-sans leading-tight whitespace-nowrap shadow-lg z-[999999] pointer-events-none select-none",a}function SN(){Jd&&Jd.parentNode&&(Jd.parentNode.removeChild(Jd),Jd=null)}var ax,jr,Jd,Xu,sx=x(()=>{"use strict";ax=require("react");Ju();jr=null,Jd=null;Xu=()=>{let[e]=rl(),t=(0,ax.useMemo)(()=>{var n;return(e==null?void 0:e.contentDocument)||((n=e==null?void 0:e.contentWindow)==null?void 0:n.document)},[e]),o=(0,ax.useCallback)(n=>{if(!t)return;let a=null;if(!n){jr&&(jr.style.outline="",jr.style.outlineOffset="",jr.style.backgroundColor="",jr.style.position="",jr=null),SN();return}typeof n!="string"?a=n:a=t.querySelector(`[data-block-id="${n}"]`),!(a===jr&&Jd&&Jd.parentNode)&&(jr&&jr!==a&&(jr.style.outline="",jr.style.outlineOffset="",jr.style.backgroundColor="",jr.style.position=""),SN(),a?(a.style.outline="2px dashed rgba(34, 197, 94, 1)",a.style.outlineOffset="2px",a.style.backgroundColor="rgba(34, 197, 94, 0.05)",window.getComputedStyle(a).position==="static"&&(a.style.position="relative"),Jd=ZQ(a,t),a.appendChild(Jd),jr=a):jr=null)},[t]),r=(0,ax.useCallback)(()=>{jr&&(jr.style.outline="",jr.style.outlineOffset="",jr.style.backgroundColor="",window.getComputedStyle(jr).position==="relative"&&jr.style.position==="relative"&&(jr.style.position=""),jr=null),SN()},[]);return{highlightParent:o,clearParentHighlight:r,lastDragHighlighted:jr}}});function eX(e){if(!e)return;e.querySelectorAll("[data-drop-target]").forEach(o=>o.removeAttribute("data-drop-target"))}var Vk,mL,wN,PN=x(()=>{"use strict";Vk=require("jotai"),mL=require("react");Ac();sx();Ju();wN=()=>{let[,e]=(0,Vk.useAtom)(Ol),[,t]=(0,Vk.useAtom)(Xi),[o]=rl(),{clearParentHighlight:r}=Xu(),[n,a]=(0,Vk.useAtom)(Fd),s=o==null?void 0:o.contentDocument;return(0,mL.useCallback)(()=>{e(null),t({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0}),eX(s),r(),s&&s.querySelectorAll("[data-dragging]").forEach(l=>{l.removeAttribute("data-dragging")}),Mu(!1),a(n+1)},[e,t,s,r,n,a])}});function jl(e,t=null){let o=Wl(e),r=t?Wl(t):null,n=o.display,a=r?r.display:null;if(n==="flex"||n==="inline-flex"){let s=o.flexDirection;return s==="column"||s==="column-reverse"?"vertical":"horizontal"}else if(n==="grid"){let s=o.gridAutoFlow,i=o.gridTemplateColumns;return s.includes("column")||i&&i!=="none"&&i!==""&&!i.includes("calc")&&i.split(" ").length<=1?"vertical":"horizontal"}else if(a==="inline-block"||a==="inline")return"horizontal";return"vertical"}var Wl,ix=x(()=>{"use strict";Wl=e=>{var t;return((t=e.ownerDocument.defaultView)!=null?t:window).getComputedStyle(e)}});function oX(e){try{return tX.includes(e)}catch(t){return!1}}function rX(){TN=new WeakMap}function pr(e){let t=TN.get(e);return t||(t=e.getBoundingClientRect(),TN.set(e,t)),t}function uL(e){try{if(e<Xc.MIN_SIZE_FOR_EDGE_ZONES)return 0;let t=e*Xc.EDGE_ZONE_PERCENTAGE;return Math.max(Xc.MIN_EDGE_ZONE,Math.min(Xc.MAX_EDGE_ZONE,t))}catch(t){return Xc.MIN_EDGE_ZONE}}function hm(e){try{let t=[],o=e.children;for(let r=0;r<o.length;r++){let n=o[r];n.hasAttribute("data-block-id")&&t.push(n)}return t}catch(t){return[]}}function zk(e){try{return hm(e).length>0}catch(t){return!1}}function nX(e,t,o,r){try{let n=hm(e);if(n.length<2)return null;let a=iX(n,t,o,r);if(a){let s=NN(n,a,r);s.sort((i,l)=>{let c=pr(i),d=pr(l);return r==="vertical"?c.top-d.top:c.left-d.left});for(let i=0;i<s.length-1;i++){let l=s[i],c=s[i+1],d=pr(l),p=pr(c);if(r==="vertical"){let u=d.bottom,m=p.top,g=m-u,h=o>=u&&o<=m,f=t>=Math.min(d.left,p.left)&&t<=Math.max(d.right,p.right);if(h&&f&&g>=Xc.GAP_THRESHOLD)return{before:l,after:c}}else{let u=d.right,m=p.left,g=m-u,h=t>=u&&t<=m,f=o>=Math.min(d.top,p.top)&&o<=Math.max(d.bottom,p.bottom);if(h&&f&&g>=Xc.GAP_THRESHOLD)return{before:l,after:c}}}}for(let s=0;s<n.length-1;s++){let i=n[s],l=n[s+1],c=pr(i),d=pr(l);if(r==="vertical"){let p=c.bottom,u=d.top,m=u-p,g=o>=p&&o<=u,h=t>=Math.min(c.left,d.left)&&t<=Math.max(c.right,d.right);if(g&&h&&m>=Xc.GAP_THRESHOLD)return{before:i,after:l}}else{let p=c.right,u=d.left,m=u-p,g=t>=p&&t<=u,h=o>=Math.min(c.top,d.top)&&o<=Math.max(c.bottom,d.bottom);if(g&&h&&m>=Xc.GAP_THRESHOLD)return{before:i,after:l}}}return null}catch(n){return null}}function aX(e,t,o,r){try{let n=pr(e),a=Xc.PARENT_EDGE_PROXIMITY;if(r==="vertical"){if(o<=n.top+a)return"start";if(o>=n.bottom-a)return"end"}else{if(t<=n.left+a)return"start";if(t>=n.right-a)return"end"}return null}catch(n){return null}}function sX(e,t,o,r,n){let a=pr(e);if(n==="vertical"){let i=(o-a.top)/a.height,l=uL(a.height),c=l/a.height;return r?l>0&&i<c?{position:"before",confidence:1-i/c}:l>0&&i>1-c?{position:"after",confidence:(i-(1-c))/c}:{position:"inside",confidence:1-Math.abs(i-.5)*2}:i<.5?{position:"before",confidence:1-i*2}:{position:"after",confidence:(i-.5)*2}}else{let i=(t-a.left)/a.width,l=uL(a.width),c=l/a.width;return r?l>0&&i<c?{position:"before",confidence:1-i/c}:l>0&&i>1-c?{position:"after",confidence:(i-(1-c))/c}:{position:"inside",confidence:1-Math.abs(i-.5)*2}:i<.5?{position:"before",confidence:1-i*2}:{position:"after",confidence:(i-.5)*2}}}function gL(e,t,o,r,n){var k,w,N,I;rX();let a=e.getAttribute("data-block-id"),s=e.getAttribute("data-block-type")||"Box";if(!a)return null;let i=e.parentElement;for(;i&&!i.hasAttribute("data-block-id");)i=i.parentElement;let l=a==="canvas"?a:i==null?void 0:i.getAttribute("data-block-id"),c=i?jl(i):"vertical",d=jl(e),p=oX(s),u=!p&&In(s,r),m=((k=n.defaultView)==null?void 0:k.scrollY)||0,g=((w=n.defaultView)==null?void 0:w.scrollX)||0;if(a==="canvas"&&zk(e)){let C=hm(e),P=C[C.length-1];if(P){let B=pr(P),T=pr(e),v=Wl(e),S=parseFloat(v.paddingLeft)||0,A=parseFloat(v.paddingRight)||0,D=T.width-S-A,R=T.left+g+S;return{position:"after",placeholderOrientation:"horizontal",rect:{top:B.bottom+m,left:R,width:D,height:4},targetElement:P,targetBlockId:P.getAttribute("data-block-id"),targetParentId:"canvas",isEmpty:!1,confidence:1}}}if(u&&!p&&zk(e)){let C=nX(e,t,o,d);if(C){let P=pr(C.before),B=pr(C.after),T=pr(e),v=Wl(e),S=parseFloat(v.paddingLeft)||0,A=parseFloat(v.paddingRight)||0,D=hm(e),R=NN(D,C.before,d),H=0;if(R.forEach(M=>{let L=pr(M);L.height>H&&(H=L.height)}),d==="vertical"){let M=T.width-S-A,L=T.left+g+S;return{position:"after",placeholderOrientation:"horizontal",rect:{top:P.bottom+m,left:L,width:M,height:4},targetElement:C.before,targetBlockId:C.before.getAttribute("data-block-id"),targetParentId:a,isGapZone:!0,confidence:1}}else{let M=P.top+m,L=H>0?H:Math.max(P.height,B.height);return{position:"after",placeholderOrientation:"vertical",rect:{top:M,left:P.right+g,width:4,height:L},targetElement:C.before,targetBlockId:C.before.getAttribute("data-block-id"),targetParentId:a,isGapZone:!0,confidence:1}}}}if(i&&l){let C=aX(i,t,o,c);if(C){let P=pr(i),B=Wl(i),T=parseFloat(B.paddingLeft)||0,v=parseFloat(B.paddingRight)||0,S=parseFloat(B.paddingTop)||0,A=parseFloat(B.paddingBottom)||0,D=((N=n.defaultView)==null?void 0:N.scrollY)||0,R=((I=n.defaultView)==null?void 0:I.scrollX)||0,H=c==="vertical"?"horizontal":"vertical",M=fL(i);if(C==="start"){let L=hm(i)[0];if(L){let z=pr(L);if(c==="vertical"){let _=P.width-T-v,F=P.left+R+T;return{position:"before",placeholderOrientation:H,rect:{top:z.top+D-2,left:F,width:_,height:4},targetElement:L,targetBlockId:L.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}else{let _=P.top+D+S,F=M.maxHeight>0?M.maxHeight:P.height-S-A;return{position:"before",placeholderOrientation:H,rect:{top:_,left:z.left+R-2,width:4,height:F},targetElement:L,targetBlockId:L.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}}}else{let L=hm(i),z=L[L.length-1];if(z){let _=pr(z);if(c==="vertical"){let F=P.width-T-v,O=P.left+R+T;return{position:"after",placeholderOrientation:H,rect:{top:_.bottom+D-2,left:O,width:F,height:4},targetElement:z,targetBlockId:z.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}else{let F=P.top+D+S,O=M.maxHeight>0?M.maxHeight:P.height-S-A;return{position:"after",placeholderOrientation:H,rect:{top:F,left:_.right+R-2,width:4,height:O},targetElement:z,targetBlockId:z.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}}}}}let h=sX(e,t,o,u,c);if(p&&h.position==="inside"){let C=pr(e);c==="vertical"?h={position:(o-C.top)/C.height<.5?"before":"after",confidence:h.confidence}:h={position:(t-C.left)/C.width<.5?"before":"after",confidence:h.confidence}}let f;h.position==="inside"?f=d==="vertical"?"horizontal":"vertical":f=c==="vertical"?"horizontal":"vertical";let b=lX(e,i,h.position,f,n),y=h.position==="inside"?a:l;return{position:h.position,placeholderOrientation:f,rect:b,targetElement:e,targetBlockId:a,targetParentId:y!=null?y:"",isEmpty:h.position==="inside"&&!zk(e),confidence:h.confidence}}function iX(e,t,o,r){if(e.length===0)return null;let n=e.filter(i=>{let l=pr(i);return r==="vertical"?o>=l.top&&o<=l.bottom:t>=l.left&&t<=l.right});if(n.length===0){let i=new Map;e.forEach(d=>{let p=pr(d),u=Math.round(r==="vertical"?p.top:p.left);i.has(u)||i.set(u,[]),i.get(u).push(d)});let l=null,c=1/0;i.forEach((d,p)=>{let u=Math.abs(r==="vertical"?o-p:t-p);u<c&&(c=u,l=d)}),l&&n.push(l)}if(n.length===0)return null;let a=n[0],s=1/0;return n.forEach(i=>{let l=pr(i),c=l.left+l.width/2,d=l.top+l.height/2,p=Math.sqrt(Math.pow(t-c,2)+Math.pow(o-d,2));p<s&&(s=p,a=i)}),a}function fL(e){let t=hm(e);if(t.length===0)return{maxWidth:0,maxHeight:0};let o=0,r=0;return t.forEach(n=>{let a=pr(n);a.width>o&&(o=a.width),a.height>r&&(r=a.height)}),{maxWidth:o,maxHeight:r}}function NN(e,t,o){let r=pr(t),n=5;return e.filter(a=>{let s=pr(a);return o==="vertical"?Math.abs(s.top-r.top)<=n:Math.abs(s.left-r.left)<=n})}function lX(e,t,o,r,n){var S,A;let a=pr(e),s=Wl(e),i=((S=n.defaultView)==null?void 0:S.scrollY)||0,l=((A=n.defaultView)==null?void 0:A.scrollX)||0,c=parseFloat(s.marginTop)||0,d=parseFloat(s.marginBottom)||0,p=parseFloat(s.marginLeft)||0,u=parseFloat(s.marginRight)||0,m=parseFloat(s.paddingTop)||0,g=parseFloat(s.paddingBottom)||0,h=parseFloat(s.paddingLeft)||0,f=parseFloat(s.paddingRight)||0,b=t?pr(t):void 0,y=t&&parseFloat(Wl(t).paddingLeft)||0,k=t&&parseFloat(Wl(t).paddingRight)||0,w=t&&parseFloat(Wl(t).paddingTop)||0,N=t&&parseFloat(Wl(t).paddingBottom)||0,I=t?fL(t):{maxWidth:0,maxHeight:0},C=t?jl(t):"vertical",P=t?hm(t):[],B=NN(P,e,C),T=0,v=0;if(B.forEach(D=>{let R=pr(D);R.height>T&&(T=R.height),R.width>v&&(v=R.width)}),o==="before")if(r==="horizontal"){let D=b?b.width-y-k:a.width,R=b?b.left+l+y:a.left+l;return{top:a.top+i-c-2,left:R,width:D,height:4}}else{let D=a.top+i,R=C==="horizontal"&&T>0?T:I.maxHeight>0?I.maxHeight:b?b.height-w-N:a.height;return{top:D,left:a.left+l-p-2,width:4,height:R}}else if(o==="after")if(r==="horizontal"){let D=b?b.width-y-k:a.width,R=b?b.left+l+y:a.left+l;return{top:a.bottom+i+d-2,left:R,width:D,height:4}}else{let D=a.top+i,R=C==="horizontal"&&T>0?T:I.maxHeight>0?I.maxHeight:b?b.height-w-N:a.height;return{top:D,left:a.right+l+u-2,width:4,height:R}}else return zk(e)?jl(e)==="vertical"?{top:a.bottom+i-g-2,left:a.left+l+h,width:a.width-h-f,height:4}:{top:a.top+i+m,left:a.right+l-f-2,width:4,height:a.height-m-g}:{top:a.top+i+m,left:a.left+l+h,width:a.width-h-f,height:Math.max(a.height-m-g,20)}}var tX,Xc,TN,hL=x(()=>{"use strict";ix();Ha();tX=["Heading","Text","Image","Paragraph","Icon","Input","Radio","Checkbox","Select","CustomHTML","TextArea","Divider","Repeater","Video"];Xc={MIN_EDGE_ZONE:10,MAX_EDGE_ZONE:30,EDGE_ZONE_PERCENTAGE:.2,GAP_THRESHOLD:8,MIN_SIZE_FOR_EDGE_ZONES:50,PARENT_EDGE_PROXIMITY:20},TN=new WeakMap});function cX(e,t,o,r,n){var a,s;try{if(t===o&&((a=n==null?void 0:n.blocks)==null?void 0:a.length)===1&&(0,Fs.get)(n,"blocks.0._type")==="Image"&&((s=(0,Fs.find)(e,{_id:t}))==null?void 0:s._type)==="Image")return{parentId:"",index:-1,replaceImageUrl:!0};if(t==="canvas"||r==="inside"&&t==="canvas")return{parentId:null,index:(0,Fs.filter)(e,m=>!(m!=null&&m._parent)).length};if(r==="inside"){let u=(0,Fs.filter)(e,{_parent:t});return{parentId:t,index:u.length}}let i=!o||o==="canvas",l=i?void 0:o,c=(0,Fs.filter)(e,u=>i?!(u!=null&&u._parent):(u==null?void 0:u._parent)===l),d=c.findIndex(u=>u._id===t);if(d===-1)return{parentId:i?null:o,index:c.length};let p=r==="before"?d:d+1;return{parentId:i?null:o,index:p}}catch(i){return{parentId:null,index:(0,Fs.filter)(e,c=>!(c!=null&&c._parent)).length}}}function yL(e){if(!e)return;e.querySelectorAll("[data-drop-target]").forEach(o=>o.removeAttribute("data-drop-target"))}function dX(e){if(!e)return;e.querySelectorAll("[data-dragging]").forEach(o=>{o.removeAttribute("data-dragging")})}var lx,Fs,bL,xL,EN,AN,Wk=x(()=>{"use strict";lx=require("jotai"),Fs=require("lodash-es"),bL=require("react"),xL=require("sonner");Ac();sx();zr();Jn();ko();zl();Kd();Ju();Yd();Ge();fn();Ln();Ne();EN=()=>{let[e,t]=(0,lx.useAtom)(Ol),o=(0,lx.useSetAtom)(Xi),[r]=rl(),{addCoreBlock:n}=Xn(),{moveBlocks:a}=Ft(),[,s]=Pe(),[,i]=ao(),{clearHighlight:l}=pa(),{clearParentHighlight:c}=Xu(),[d,p]=(0,lx.useAtom)(Fd),u=br(),m=Sf(),g=r==null?void 0:r.contentDocument;return(0,bL.useCallback)(h=>{h.preventDefault(),h.stopPropagation();let f=be.get(Xi);if(Mu(!1),dX(g),yL(g),c(),o({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0}),setTimeout(()=>{c(),yL(g),o({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0})},50),!e)return;if(!f.isValid||!f.targetBlockId){c();return}t(null);let b=f.targetBlockId,y=f.targetParentId;if(!b)return;let k=be.get(Ot),{parentId:w,index:N,replaceImageUrl:I}=cX(k,b,y,f.position,e),C=e._id!==void 0;if(I&&AN(e)){u([b],{image:(0,Fs.get)(e,"blocks.0.image")}),setTimeout(()=>{p(d+1)},50);return}if(C)a([e._id],w===null?void 0:w,N),l(),i([]),s([e._id]);else{let P=e._type||e.type,B=e!=null&&e.blocks?(0,Fs.isFunction)(e==null?void 0:e.blocks)?hi(e==null?void 0:e.blocks()):e==null?void 0:e.blocks:null;if(P==="PartialBlock"){let T=e.partialBlockId||"",{canAdd:v,reason:S}=m(T);if(!v){xL.toast.error(S||"Cannot add this partial block");return}n({blocks:[{_type:P,_id:"partial-block",partialBlockId:e.partialBlockId}]},w,N)}else n((B==null?void 0:B.length)>0?{blocks:[...B]}:{type:P},w,N)}setTimeout(()=>{p(d+1)},50)},[e,g,n,a,t,o,c,l,s,i,d,p,u,m])},AN=e=>{var a,s;let t=(0,Fs.has)(e,"blocks"),o=e==null?void 0:e.blocks,r=(o==null?void 0:o.length)===1&&((a=o==null?void 0:o[0])==null?void 0:a._type)==="Image",n=!((s=o==null?void 0:o[0])!=null&&s._id);return t&&r&&n}});function IN(e,t,o){if(!e||!t)return!1;if(e===t)return!0;let r=o.find(a=>a._id===e);if(!r)return!1;let n=r;for(;n._parent;){if(n._parent===t)return!0;let a=o.find(s=>s._id===n._parent);if(!a)break;n=a}return!1}function BN(e,t,o){return!e||!t?!0:!IN(t,e,o)}function vL(e,t,o){if(!e)return!0;let r=o.find(a=>a._id===t);if(!r)return!0;let n=r._parent;return BN(e,n,o)}var CL=x(()=>{"use strict"});function mX(e){let t=e;for(;t&&!t.hasAttribute("data-block-id");)t=t.parentElement;if(!t)return{element:null,targetBlockId:null,targetBlockType:null,targetParentId:null,targetParentType:null,orientation:"vertical"};let o=t.getAttribute("data-block-id"),r=t.getAttribute("data-block-type")||"Box",n=t.parentElement;for(;n&&!n.hasAttribute("data-block-id");)n=n.parentElement;let a=(n==null?void 0:n.getAttribute("data-block-id"))||null,s=(n==null?void 0:n.getAttribute("data-block-type"))||"Box",i=jl(t);return{element:t,targetBlockId:o,targetBlockType:r,targetParentId:a,targetParentType:s,orientation:i}}function uX(e){jk!==e&&(jk&&jk.removeAttribute("data-drop-target"),e.setAttribute("data-drop-target","true"),jk=e)}var RN,Hs,pX,ym,DN,jk,_N=x(()=>{"use strict";RN=require("jotai"),Hs=require("react");hL();Wk();Ac();sx();CL();ix();zr();Jn();Ha();Ju();pX=["Heading","Text","Image","Paragraph","Icon","Input","Radio","Checkbox","Select","CustomHTML","TextArea","Divider","Repeater","Video"],ym={EDGE_ZONE:50,MAX_SCROLL_SPEED:10,MIN_SCROLL_SPEED:10},DN=()=>{let[e]=(0,RN.useAtom)(Ol),[t]=rl(),[,o]=(0,RN.useAtom)(Xi),{clearParentHighlight:r,highlightParent:n}=Xu(),a=t==null?void 0:t.contentDocument,s=(0,Hs.useRef)(null),i=(0,Hs.useRef)(0),l=(0,Hs.useCallback)(m=>{if(!(a!=null&&a.defaultView))return;let g=a.defaultView,h=g.innerHeight,f=g.scrollY,b=a.documentElement.scrollHeight;i.current=m;let y=m,k=h-m,w=!1,N=null,I=0;if(y<ym.EDGE_ZONE&&f>0?(w=!0,N="up",I=y):k<ym.EDGE_ZONE&&f+h<b&&(w=!0,N="down",I=k),!w&&s.current!==null){cancelAnimationFrame(s.current),s.current=null;return}if(w&&N){let C=1-I/ym.EDGE_ZONE,P=ym.MIN_SCROLL_SPEED+(ym.MAX_SCROLL_SPEED-ym.MIN_SCROLL_SPEED)*C,B=()=>{if(!Jp||!g){s.current=null;return}let T=N==="up"?-P:P;g.scrollBy(0,T);let v=g.scrollY,S=v>0,A=v+h<b,D=i.current,R=h-i.current;N==="up"&&S&&D<ym.EDGE_ZONE||N==="down"&&A&&R<ym.EDGE_ZONE?s.current=requestAnimationFrame(B):s.current=null};s.current===null&&(s.current=requestAnimationFrame(B))}},[a]);(0,Hs.useEffect)(()=>()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)},[]),(0,Hs.useEffect)(()=>{!Jp&&s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)},[]);let c=(0,Hs.useCallback)(m=>{var S,A,D;if(!Jp||!e)return;r();let g=mX(m.target),{element:h,targetBlockId:f,targetParentId:b}=g;if(!h||!f)return;let y=e._id,k=be.get(Ot);if(y&&(f===y||IN(f,y,k)))return;let w=e._type||e.type;if(!w)return;let N=m.clientX,I=m.clientY;if(l(I),!a)return;let C=gL(h,N,I,w,a);if(!C)return;let P=h.getAttribute("data-block-type")||"Box",B=!1,T=pX.includes(P);if(P==="Image"&&w==="Image"&&AN(e)){n(f);let R=((S=a.defaultView)==null?void 0:S.scrollY)||0,H=((A=a.defaultView)==null?void 0:A.scrollX)||0,M=h.getBoundingClientRect();o({isVisible:!0,isValid:!0,position:C.position,placeholderOrientation:C.placeholderOrientation,isEmpty:!0,top:M.top+R,left:M.left+H,width:M.width,height:M.height,targetBlockId:C.targetBlockId,targetParentId:C.targetBlockId});return}if(C.position==="inside"){if(T||y&&!BN(y,f,k))return;B=In(P,w)}else{let R=h.parentElement,H="Box";for(;R&&!R.hasAttribute("data-block-id");)R=R.parentElement;if(R&&(H=R.getAttribute("data-block-type")||"Box"),y&&!vL(y,f,k))return;B=In(H,w)}if(!B)return;n(C.targetParentId);let v=C.targetParentId||b||void 0;o({isVisible:!0,isValid:!0,position:C.position,placeholderOrientation:C.placeholderOrientation,isEmpty:(D=C.isEmpty)!=null?D:!1,top:C.rect.top,left:C.rect.left,width:C.rect.width,height:C.rect.height,targetBlockId:C.targetBlockId,targetParentId:v}),uX(C.targetElement)},[a,e,o,r,n,l]),d=(0,Hs.useRef)(c);d.current=c;let p=(0,Hs.useRef)(null),u=(0,Hs.useRef)(null);return(0,Hs.useEffect)(()=>()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)},[]),(0,Hs.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),p.current={target:m.target,clientX:m.clientX,clientY:m.clientY},u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null;let g=p.current;p.current=null,g&&d.current(g)}))},[])};jk=null});function kL(e){var a;let t=document.createElement("div");t.className="absolute -top-[1000px] -left-[1000px] pl-3 pr-1 py-1 bg-white/60 border border-blue-400/30 rounded shadow-md flex items-center gap-1.5 font-sans pointer-events-none z-[9999] scale-90";let o=e.type||e._type||"Box",r=document.createElement("div");r.className="w-3 h-3 flex items-center justify-center text-blue-600";try{o==="Image"?r.innerHTML='<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 0.72 0.72"><path d="M.57.12H.15a.09.09 0 0 0-.09.09v.3A.09.09 0 0 0 .15.6h.42A.09.09 0 0 0 .66.51v-.3A.09.09 0 0 0 .57.12M.15.54A.03.03 0 0 1 .12.51V.437L.219.338a.03.03 0 0 1 .042 0L.462.54ZM.6.51a.03.03 0 0 1-.03.03H.547L.433.425.459.399a.03.03 0 0 1 .042 0L.6.498Zm0-.097L.544.357a.09.09 0 0 0-.127 0L.391.383.305.297a.09.09 0 0 0-.127 0L.12.353V.21A.03.03 0 0 1 .15.18h.42A.03.03 0 0 1 .6.21Z"/></svg>':r.innerHTML=((a=document.querySelector(`[data-add-core-block-icon="${o}"]`))==null?void 0:a.outerHTML)||'<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path d="M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4z"/></svg>'}catch(s){r.textContent=""}let n=document.createElement("span");return n.className="text-[10px] font-medium text-blue-600 whitespace-nowrap",n.textContent=e.label||e.type||e._name||e._type||"Block",t.appendChild(r),t.appendChild(n),document.body.appendChild(t),t}function LN(e){e&&e.parentNode&&e.parentNode.removeChild(e)}var SL=x(()=>{"use strict"});var MN,wL,qk,ON,FN=x(()=>{"use strict";MN=require("jotai"),wL=require("lodash-es"),qk=require("react");SL();Ac();ix();Qn();Pa();Kd();Ge();fn();ON=()=>{let[,e]=Pe(),[,t]=ao(),{clearHighlight:o}=pa(),[,r]=(0,MN.useAtom)(Ol),[,n]=(0,MN.useAtom)(Xi),a=(0,qk.useRef)(null);return(0,qk.useCallback)((s,i,l=!0)=>{var d;a.current&&(LN(a.current),a.current=null);let c=l?(0,wL.pick)(i,["type","blocks","partialBlockId"]):i;if(r(c),s.dataTransfer.setData("text/plain",JSON.stringify({block:c})),s.dataTransfer.effectAllowed="move",!l&&i._id){let p=(d=document.getElementById("canvas-iframe"))==null?void 0:d.contentDocument;if(p){let u=p.querySelector(`[data-block-id="${i._id}"]`);u&&setTimeout(()=>{if(u&&u.parentElement){let g=u.getBoundingClientRect().height;(u.parentElement&&jl(u.parentElement))==="vertical"&&g>200&&(u.style.height="max-content",u.style.maxHeight="max-content",u.style.minHeight="0",u.style.overflow="hidden",u.innerHTML="<div class='flex items-center justify-center w-full h-full outline-[1px] outline-dashed font-medium outline-gray-500 bg-gray-500/10 py-4 text-transparent'>-</div>",u.style.opacity="0.4"),u.style.opacity="0.4",u.setAttribute("data-dragging","true")}},0)}}if(i!=null&&i._type||i!=null&&i.type){let p=kL(i);a.current=p,s.dataTransfer.setDragImage(p,0,0),setTimeout(()=>{a.current&&(LN(a.current),a.current=null)},50)}e([]),o(),t([]),Gt.publish(dt.CLOSE_ADD_BLOCK),Mu(!0),n({isVisible:!0,isValid:!0,position:"inside",placeholderOrientation:"horizontal",isEmpty:!0,top:0,left:0,width:0,height:0,targetBlockId:"canvas",targetParentId:void 0})},[r,e,o,t,n])}});var PL,nl,TL,Zn,al=x(()=>{"use strict";PL=require("jotai");PN();_N();FN();Wk();Ac();Ke();PN();_N();FN();Wk();sx();Ac();nl=()=>{let e=ON(),t=DN(),o=EN(),r=wN();return{onDragStart:e,onDragOver:t,onDrop:o,onDragEnd:r,isDragging:Jp}},TL=()=>{let[e]=(0,PL.useAtom)(Xi);return e},Zn=()=>{let{dragAndDrop:e}=q("flags",{dragAndDrop:!0});return e}});var HN,NL,EL,UN,Un,AL,gX,Qf=x(()=>{"use strict";HN=K(require("react"),1);typeof document!="undefined"&&(NL=document);typeof window!="undefined"&&(EL=window);UN=HN.default.createContext({document:NL,window:EL}),Un=()=>HN.default.useContext(UN),{Provider:AL,Consumer:gX}=UN});var bm,Qd,IL,cx,fX,hX,BL,yX,bX,RL,DL=x(()=>{"use strict";bm=require("@radix-ui/react-icons"),Qd=require("lodash-es"),IL=require("react");ix();Qf();ko();cx=require("react/jsx-runtime"),fX=[{ControlIcon:bm.PinTopIcon,dir:"VERTICAL",key:"UP"},{ControlIcon:bm.PinBottomIcon,dir:"VERTICAL",key:"DOWN"},{ControlIcon:bm.PinLeftIcon,dir:"HORIZONTAL",key:"LEFT"},{ControlIcon:bm.PinRightIcon,dir:"HORIZONTAL",key:"RIGHT"}],hX=(e,t,o)=>{try{if(!e||!o)return"VERTICAL";let r=`[data-block-id='${e}']`,n=o==null?void 0:o.querySelector(r);if(n){let a=o==null?void 0:o.querySelector(`[data-block-id='${t}']`);return jl(n,a).toUpperCase()}return"VERTICAL"}catch(r){return"VERTICAL"}},BL=(e,t,o)=>!!(e&&(o==="UP"||o==="LEFT")||t&&(o==="DOWN"||o==="RIGHT")),yX=(e,t)=>{let[o]=Pt(),{document:r}=Un(),{moveBlocks:n}=Ft(),a=(0,Qd.get)(e,"_id"),s=(0,Qd.get)(e,"_parent"),i=(0,Qd.filter)(o,g=>s?(0,Qd.get)(g,"_parent")===s:!(0,Qd.get)(g,"_parent")),l=(i==null?void 0:i.length)<=1,c=(0,Qd.findIndex)(i,{_id:a}),d=c<=0,p=c+1===(i==null?void 0:i.length),u=hX(s,a,r),m=(0,IL.useCallback)(g=>{BL(d,p,g)||l||(g==="UP"||g==="LEFT"?n([a],s||void 0,c-1):(g==="DOWN"||g==="RIGHT")&&n([a],s||void 0,c+2),t())},[d,p,l,t,n,a,s,c]);return{isOnlyChild:l,isFirstBlock:d,isLastBlock:p,moveBlock:m,orientation:u}},bX=({block:e,updateFloatingBar:t})=>{let{isOnlyChild:o,isFirstBlock:r,isLastBlock:n,moveBlock:a,orientation:s}=yX(e,t);return o?null:(0,cx.jsx)(cx.Fragment,{children:fX.map(({ControlIcon:i,dir:l,key:c})=>s!==l||BL(r,n,c)?null:(0,cx.jsx)(i,{onClick:()=>a(c),className:"rounded p-px hover:bg-white hover:text-blue-500"},c))})},RL=bX});var Kk,xX,Yk,GN=x(()=>{"use strict";Kk=require("jotai"),xX=(0,Kk.atom)(""),Yk=()=>(0,Kk.useAtom)(xX)});var VN,$N,_L,LL,us,Zu=x(()=>{"use strict";VN=require("jotai"),$N=require("jotai"),_L=(0,VN.atom)("");_L.debugLabel="inlineEditingActiveAtom";LL=(0,VN.atom)(0);LL.debugLabel="inlineEditingItemIndexAtom";us=()=>{let[e,t]=(0,$N.useAtom)(_L),[o,r]=(0,$N.useAtom)(LL);return{editingBlockId:e,editingItemIndex:o,setEditingBlockId:t,setEditingItemIndex:r}}});var sl,ML,Jk,xm,vm,Xd,eg,Zd,Xf=x(()=>{"use strict";sl=K(require("@radix-ui/react-accordion"),1),ML=require("@radix-ui/react-icons"),Jk=K(require("react"),1);st();xm=require("react/jsx-runtime"),vm=sl.Root,Xd=Jk.forwardRef(({className:e,...t},o)=>(0,xm.jsx)(sl.Item,{ref:o,className:G("border-b",e),...t}));Xd.displayName="AccordionItem";eg=Jk.forwardRef(({className:e,children:t,...o},r)=>(0,xm.jsx)(sl.Header,{className:"flex",children:(0,xm.jsxs)(sl.Trigger,{ref:r,className:G("flex flex-1 items-center justify-between py-4 text-left text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...o,children:[t,(0,xm.jsx)(ML.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));eg.displayName=sl.Trigger.displayName;Zd=Jk.forwardRef(({className:e,children:t,...o},r)=>(0,xm.jsx)(sl.Content,{ref:r,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...o,children:(0,xm.jsx)("div",{className:G("pb-4 pt-0",e),children:t})}));Zd.displayName=sl.Content.displayName});function Cm(){let{data:e}=dr(),t=Ls();return(0,OL.useQuery)({queryKey:[zN,e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return null;let o=await t({body:{action:$.AI_GET_CONTEXT,data:{pageId:e.id}}});if(o!=null&&o.success&&o.aiData){let{app:r,page:n}=o.aiData;return{site:r,page:n}}return null},enabled:!!(e!=null&&e.id),staleTime:1/0,gcTime:1/0})}var OL,zN,dx=x(()=>{"use strict";OL=require("@tanstack/react-query");St();er();Kt();zN="AI_CONTEXT"});var Qk,FL,ma,Zc=x(()=>{"use strict";Qk=require("jotai"),FL=(0,Qk.atom)("outline");FL.debugLabel="sidebarActivePanelAtom";ma=()=>(0,Qk.useAtom)(FL)});var WN,px,HL,vX,qo,UL=x(()=>{"use strict";"use client";WN=require("lodash-es"),px=K(require("react"),1),HL=require("react/jsx-runtime"),vX="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",qo=({src:e,alt:t="",fallbackSrc:o=vX,onError:r,onLoad:n,loading:a="lazy",className:s,...i})=>{let[l,c]=(0,px.useState)(e||o),[d,p]=(0,px.useState)(!1),u=g=>{d||(p(!0),c(o),r==null||r(g))},m=g=>{p(!1),n==null||n(g)};return px.default.useEffect(()=>{e&&e!==l&&!d&&c(e)},[e,l,d]),(0,WN.isEmpty)(e)&&(0,WN.isEmpty)(o)?null:(0,HL.jsx)("img",{...i,src:l,alt:t,loading:a,onError:u,onLoad:m,className:s})}});var Us=x(()=>{"use strict";UL()});var GL,$L,Ro,gs=x(()=>{"use strict";GL=K(require("react"),1);st();$L=require("react/jsx-runtime"),Ro=GL.forwardRef(({className:e,...t},o)=>(0,$L.jsx)("textarea",{className:G("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-xs text-foreground shadow-sm placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...t}));Ro.displayName="Textarea"});function VL({className:e,...t}){return(0,mx.jsx)("div",{"data-slot":"input-group",role:"group",className:G("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/20","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...t})}function qN({className:e,align:t="inline-start",...o}){return(0,mx.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:G(CX({align:t}),e),onClick:r=>{var n,a;r.target.closest("button")||(a=(n=r.currentTarget.parentElement)==null?void 0:n.querySelector("input"))==null||a.focus()},...o})}function KN({className:e,type:t="button",variant:o="ghost",size:r="xs",...n}){return(0,mx.jsx)(E,{type:t,"data-size":r,variant:o,className:G(kX({size:r}),e),...n})}function zL({className:e,...t}){return(0,mx.jsx)(Ro,{"data-slot":"input-group-control",className:G("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",e),...t})}var jN,mx,CX,kX,WL=x(()=>{"use strict";jN=require("class-variance-authority");J();fo();gs();st();mx=require("react/jsx-runtime");CX=(0,jN.cva)("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});kX=(0,jN.cva)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}})});var tg,jL,qL,Zf,eh,og,Xk=x(()=>{"use strict";tg=K(require("@radix-ui/react-hover-card"),1),jL=K(require("react"),1);st();qL=require("react/jsx-runtime"),Zf=tg.Root,eh=tg.Trigger,og=jL.forwardRef(({className:e,align:t="center",sideOffset:o=4,...r},n)=>(0,qL.jsx)(tg.Content,{ref:n,align:t,sideOffset:o,className:G("z-50 w-64 origin-[--radix-hover-card-content-transform-origin] rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));og.displayName=tg.Content.displayName});var rg,oo,km,Bn,So,ed,Do,ho,KL,YL,yo,ql,gt,SX,Gs=x(()=>{"use strict";rg=require("@radix-ui/react-icons"),oo=K(require("@radix-ui/react-select"),1),km=K(require("react"),1);st();Bn=require("react/jsx-runtime"),So=oo.Root,ed=oo.Group,Do=oo.Value,ho=km.forwardRef(({className:e,children:t,...o},r)=>(0,Bn.jsxs)(oo.Trigger,{ref:r,className:G("ring-offset-surface flex h-8 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-xs text-foreground shadow-sm focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1",e),...o,children:[t,(0,Bn.jsx)(oo.Icon,{asChild:!0,children:(0,Bn.jsx)(rg.ChevronDownIcon,{className:"h-4 w-4 opacity-50"})})]}));ho.displayName=oo.Trigger.displayName;KL=km.forwardRef(({className:e,...t},o)=>(0,Bn.jsx)(oo.ScrollUpButton,{ref:o,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:(0,Bn.jsx)(rg.ChevronUpIcon,{className:"h-4 w-4"})}));KL.displayName=oo.ScrollUpButton.displayName;YL=km.forwardRef(({className:e,...t},o)=>(0,Bn.jsx)(oo.ScrollDownButton,{ref:o,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:(0,Bn.jsx)(rg.ChevronDownIcon,{className:"h-4 w-4"})}));YL.displayName=oo.ScrollDownButton.displayName;yo=km.forwardRef(({className:e,children:t,position:o="popper",...r},n)=>(0,Bn.jsx)(oo.Portal,{children:(0,Bn.jsxs)(oo.Content,{ref:n,className:G("no-scrollbar relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:o,...r,children:[(0,Bn.jsx)(KL,{}),(0,Bn.jsx)(oo.Viewport,{className:G("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),(0,Bn.jsx)(YL,{})]})}));yo.displayName=oo.Content.displayName;ql=km.forwardRef(({className:e,...t},o)=>(0,Bn.jsx)(oo.Label,{ref:o,className:G("px-2 py-1.5 text-xs text-muted",e),...t}));ql.displayName=oo.Label.displayName;gt=km.forwardRef(({className:e,children:t,...o},r)=>(0,Bn.jsxs)(oo.Item,{ref:r,className:G("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[(0,Bn.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Bn.jsx)(oo.ItemIndicator,{children:(0,Bn.jsx)(rg.CheckIcon,{className:"h-4 w-4"})})}),(0,Bn.jsx)(oo.ItemText,{children:t})]}));gt.displayName=oo.Item.displayName;SX=km.forwardRef(({className:e,...t},o)=>(0,Bn.jsx)(oo.Separator,{ref:o,className:G("-mx-1 my-1 h-px bg-muted",e),...t}));SX.displayName=oo.Separator.displayName});function eM({data:e,className:t,...o}){var l;let r=Zk(),n=e.filename||"",s=((l=e.mediaType)!=null&&l.startsWith("image/")&&e.url?"image":"file")==="image",i=n||(s?"Image":"Attachment");return(0,$e.jsxs)(NX,{children:[(0,$e.jsx)(eh,{asChild:!0,className:"max-w-36",children:(0,$e.jsxs)("div",{className:G("group relative flex h-6 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",t),...o,children:[(0,$e.jsxs)("div",{className:"relative size-4 shrink-0",children:[(0,$e.jsx)("div",{className:"bg-surface absolute inset-0 flex size-4 items-center justify-center overflow-hidden rounded transition-opacity group-hover:opacity-0",children:s?(0,$e.jsx)(qo,{alt:n||"attachment",className:"size-4 object-cover",height:16,src:e.url,width:16}):(0,$e.jsx)("div",{className:"flex size-4 items-center justify-center text-muted-foreground",children:(0,$e.jsx)(Na.PaperclipIcon,{className:"size-3"})})}),(0,$e.jsxs)(E,{"aria-label":"Remove attachment",className:"absolute inset-0 size-4 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:c=>{c.stopPropagation(),r.remove(e.id)},type:"button",variant:"ghost",children:[(0,$e.jsx)(Na.XIcon,{}),(0,$e.jsx)("span",{className:"sr-only",children:"Remove"})]})]}),(0,$e.jsx)("span",{className:"flex-1 truncate",children:i})]},e.id)}),(0,$e.jsx)(EX,{className:"w-auto p-2",children:(0,$e.jsxs)("div",{className:"w-auto space-y-3",children:[s&&(0,$e.jsx)("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:(0,$e.jsx)(qo,{alt:n||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:e.url,width:448})}),(0,$e.jsx)("div",{className:"flex items-center gap-2.5",children:(0,$e.jsxs)("div",{className:"min-w-0 max-w-lg flex-1 space-y-1 px-0.5",children:[(0,$e.jsx)("h4",{className:"truncate text-sm font-semibold leading-none",children:n||(s?"Image":"Attachment")}),e.mediaType&&(0,$e.jsx)("p",{className:"truncate font-mono text-xs text-muted-foreground",children:e.mediaType})]})})]})})]})}function tM({children:e,className:t,...o}){let r=Zk();return r.files.length?(0,$e.jsx)("div",{className:G("flex flex-wrap items-center gap-2 p-3",t),...o,children:r.files.map(n=>(0,$e.jsx)(ft.Fragment,{children:e(n)},n.id))}):null}var Na,JL,ft,QL,$e,wX,PX,XL,TX,ZL,Zk,YN,eS,tS,oM,oS,rM,ux,nM,aM,sM,rS,gx,NX,EX,nS=x(()=>{"use strict";"use client";Na=require("lucide-react"),JL=require("nanoid"),ft=require("react"),QL=require("react-i18next");Us();WL();J();jp();Sr();Xk();Oo();Gs();st();$e=require("react/jsx-runtime"),wX=(0,ft.createContext)(null),PX=(0,ft.createContext)(null),XL=()=>(0,ft.useContext)(wX),TX=()=>(0,ft.useContext)(PX),ZL=(0,ft.createContext)(null),Zk=()=>{let e=TX(),t=(0,ft.useContext)(ZL),o=e!=null?e:t;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o};YN=({label:e="Add photos or files",accept:t,...o})=>{let r=Zk();return(0,$e.jsxs)(ye,{...o,onSelect:n=>{n.preventDefault(),r.openFileDialog(t)},children:[o.children||(0,$e.jsx)(Na.ImageIcon,{className:"mr-2 size-4"}),e]})},eS=({className:e,accept:t,multiple:o,globalDrop:r,maxFiles:n,maxFileSize:a,maxCombinedSize:s,onError:i,onSubmit:l,children:c,...d})=>{let p=XL(),u=!!p,m=(0,ft.useRef)(null),g=(0,ft.useRef)(null),h=(0,ft.useRef)(null);(0,ft.useEffect)(()=>{var M;let H=(M=g.current)==null?void 0:M.closest("form");H instanceof HTMLFormElement&&(h.current=H)},[]);let[f,b]=(0,ft.useState)([]),y=u&&p?p.attachments.files:f,k=(0,ft.useCallback)(H=>{var M;H&&m.current?m.current.accept=H:m.current&&(m.current.accept=t||""),(M=m.current)==null||M.click()},[t]),w=(0,ft.useCallback)(H=>!t||t.trim()===""?!0:t.split(",").map(L=>L.trim()).some(L=>L.endsWith("/*")?H.type.startsWith(L.slice(0,-1)):H.type===L),[t]),N=(0,ft.useCallback)(H=>{let M=Array.from(H),L=M.filter(pe=>w(pe));if(M.length&&L.length===0){i==null||i({code:"accept",message:"No files match the accepted types."});return}let z=pe=>a?pe.size<=a:!0,_=L.filter(z);if(L.length>0&&_.length===0){i==null||i({code:"max_file_size",message:"All files exceed the maximum size."});return}let F=y.reduce((pe,ve)=>pe+(ve.size||0),0),O=_;if(s){let pe=[],ve=!1;for(let Ve of _)if(F+Ve.size<=s)pe.push(Ve),F+=Ve.size;else{ve=!0;break}ve&&(i==null||i({code:"max_combined_size",message:`Combined file size exceeds the limit. Max allowed size is ${Math.round(s/1024/1024)}MB`})),O=pe}let U=typeof n=="number"?Math.max(0,n-y.length):void 0,j=typeof U=="number"?O.slice(0,U):O;if(typeof U=="number"&&O.length>U&&(i==null||i({code:"max_files",message:"Too many files. Some were not added."})),j.length===0)return;let ce=[];for(let pe of j)ce.push({id:(0,JL.nanoid)(),type:"file",url:URL.createObjectURL(pe),mediaType:pe.type,filename:pe.name,size:pe.size});b(pe=>pe.concat(ce))},[w,n,a,s,i,y]),I=(0,ft.useMemo)(()=>u&&p?H=>p.attachments.add(H):N,[u,p,N]),C=(0,ft.useMemo)(()=>u&&p?H=>p.attachments.remove(H):H=>b(M=>{let L=M.find(z=>z.id===H);return L!=null&&L.url&&URL.revokeObjectURL(L.url),M.filter(z=>z.id!==H)}),[u,p,b]),P=(0,ft.useMemo)(()=>u&&p?()=>p.attachments.clear():()=>b(H=>{for(let M of H)M.url&&URL.revokeObjectURL(M.url);return[]}),[u,p,b]),B=(0,ft.useMemo)(()=>u&&p?()=>p.attachments.openFileDialog():k,[u,p,k]);(0,ft.useEffect)(()=>{!u||!p||p.__registerFileInput(m,()=>{var H;return(H=m.current)==null?void 0:H.click()})},[u,p]),(0,ft.useEffect)(()=>{m.current&&y.length===0&&(m.current.value="")},[y]),(0,ft.useEffect)(()=>{let H=h.current;if(!H)return;let M=z=>{var _,F;(F=(_=z.dataTransfer)==null?void 0:_.types)!=null&&F.includes("Files")&&z.preventDefault()},L=z=>{var _,F,O;(F=(_=z.dataTransfer)==null?void 0:_.types)!=null&&F.includes("Files")&&z.preventDefault(),(O=z.dataTransfer)!=null&&O.files&&z.dataTransfer.files.length>0&&I(z.dataTransfer.files)};return H.addEventListener("dragover",M),H.addEventListener("drop",L),()=>{H.removeEventListener("dragover",M),H.removeEventListener("drop",L)}},[I]),(0,ft.useEffect)(()=>{if(!r)return;let H=L=>{var z,_;(_=(z=L.dataTransfer)==null?void 0:z.types)!=null&&_.includes("Files")&&L.preventDefault()},M=L=>{var z,_,F;(_=(z=L.dataTransfer)==null?void 0:z.types)!=null&&_.includes("Files")&&L.preventDefault(),(F=L.dataTransfer)!=null&&F.files&&L.dataTransfer.files.length>0&&I(L.dataTransfer.files)};return document.addEventListener("dragover",H),document.addEventListener("drop",M),()=>{document.removeEventListener("dragover",H),document.removeEventListener("drop",M)}},[I,r]);let T=(0,ft.useRef)(void 0);(0,ft.useEffect)(()=>{T.current=()=>{var H;if(!u)for(let M of y)(H=M.url)!=null&&H.startsWith("blob:")&&URL.revokeObjectURL(M.url)}},[y,u]),(0,ft.useEffect)(()=>()=>{var H;(H=T.current)==null||H.call(T)},[u]);let v=H=>{H.currentTarget.files&&I(H.currentTarget.files)},S=async H=>{let L=await(await fetch(H)).blob();return new Promise((z,_)=>{let F=new FileReader;F.onloadend=()=>z(F.result),F.onerror=_,F.readAsDataURL(L)})},A=(0,ft.useMemo)(()=>({files:y.map(H=>({...H,id:H.id})),add:I,remove:C,clear:P,openFileDialog:B,fileInputRef:m}),[y,I,C,P,B]),D=H=>{H.preventDefault();let M=H.currentTarget,L=u&&p?p.textInput.value:new FormData(M).get("message")||"";u||M.reset(),Promise.all(y.map(async({...z})=>z.url&&z.url.startsWith("blob:")?{...z,url:await S(z.url)}:z)).then(z=>{try{let _=l({text:L,files:z},H);_ instanceof Promise?_.then(()=>{P(),u&&p&&p.textInput.clear()}).catch(()=>{}):(P(),u&&p&&p.textInput.clear())}catch(_){}})},R=(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)("span",{"aria-hidden":"true",className:"hidden",ref:g}),(0,$e.jsx)("input",{accept:t,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:v,ref:m,title:"Upload files",type:"file"}),(0,$e.jsx)("form",{className:G("w-full",e),onSubmit:D,...d,children:(0,$e.jsx)(VL,{className:"overflow-hidden",children:c})})]});return u?R:(0,$e.jsx)(ZL.Provider,{value:A,children:R})},tS=({onChange:e,className:t,placeholder:o="What would you like to know?",...r})=>{let n=XL(),a=Zk(),[s,i]=(0,ft.useState)(!1),l=p=>{if(p.key==="Enter"){if(s||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();let u=p.currentTarget.form,m=u==null?void 0:u.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;u==null||u.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&a.files.length>0){p.preventDefault();let u=a.files.at(-1);u&&a.remove(u.id)}},c=p=>{var g;let u=(g=p.clipboardData)==null?void 0:g.items;if(!u)return;let m=[];for(let h of u)if(h.kind==="file"){let f=h.getAsFile();f&&m.push(f)}m.length>0&&(p.preventDefault(),a.add(m))},d=n?{value:n.textInput.value,onChange:p=>{n.textInput.setInput(p.currentTarget.value),e==null||e(p)}}:{onChange:e};return(0,$e.jsx)(zL,{className:G("field-sizing-content max-h-48 min-h-16",t),name:"message",onCompositionEnd:()=>i(!1),onCompositionStart:()=>i(!0),onKeyDown:l,onPaste:c,placeholder:o,...r,...d})},oM=({className:e,...t})=>(0,$e.jsx)(qN,{align:"block-end",className:G("order-first flex-wrap gap-1",e),...t}),oS=({className:e,...t})=>(0,$e.jsx)(qN,{align:"block-end",className:G("justify-between gap-1",e),...t}),rM=({className:e,...t})=>(0,$e.jsx)("div",{className:G("flex items-center gap-1",e),...t}),ux=({variant:e="ghost",className:t,size:o,...r})=>{let n=o!=null?o:ft.Children.count(r.children)>1?"sm":"icon-sm";return(0,$e.jsx)(KN,{className:G(t),size:n,type:"button",variant:e,...r})},nM=e=>(0,$e.jsx)(Yt,{...e}),aM=({className:e,children:t,...o})=>(0,$e.jsx)($t,{asChild:!0,children:(0,$e.jsx)(ux,{className:e,...o,children:t!=null?t:(0,$e.jsx)(Na.PlusIcon,{className:"size-4"})})}),sM=({className:e,...t})=>(0,$e.jsx)(Vt,{align:"start",className:G(e),...t}),rS=({className:e,variant:t="default",size:o="icon-sm",status:r,children:n,...a})=>{let s=(0,$e.jsx)(Na.CornerDownLeftIcon,{className:"size-4"});return r==="submitted"?s=(0,$e.jsx)(wt,{className:"h-4 w-4"}):r==="streaming"?s=(0,$e.jsx)(Na.SquareIcon,{className:"size-4"}):r==="error"&&(s=(0,$e.jsx)(Na.XIcon,{className:"size-4"})),(0,$e.jsx)(KN,{"aria-label":"Submit",className:G(e),size:o,type:"submit",variant:t,...a,children:n!=null?n:s})},gx=({className:e,textareaRef:t,onTranscriptionChange:o,...r})=>{let{t:n}=(0,QL.useTranslation)(),[a,s]=(0,ft.useState)(!1),[i,l]=(0,ft.useState)(null),c=(0,ft.useRef)(null);(0,ft.useEffect)(()=>{if(typeof window!="undefined"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){let p=window.SpeechRecognition||window.webkitSpeechRecognition,u=new p;u.continuous=!0,u.interimResults=!0,u.lang="en-US",u.onstart=()=>{s(!0)},u.onend=()=>{s(!1)},u.onresult=m=>{var h,f;let g="";for(let b=m.resultIndex;b<m.results.length;b++){let y=m.results[b];y.isFinal&&(g+=(f=(h=y[0])==null?void 0:h.transcript)!=null?f:"")}if(g&&(t!=null&&t.current)){let b=t.current,y=b.value,k=y+(y?" ":"")+g;b.value=k,b.dispatchEvent(new Event("input",{bubbles:!0})),o==null||o(k)}},u.onerror=m=>{console.error("Speech recognition error:",m.error),s(!1)},c.current=u,(0,ft.startTransition)(()=>l(u))}return()=>{c.current&&c.current.stop()}},[t,o]);let d=(0,ft.useCallback)(()=>{i&&(a?i.stop():i.start())},[i,a]);return(0,$e.jsxs)("div",{className:"relative",children:[a&&(0,$e.jsxs)("div",{className:"absolute -top-0 left-0 z-10 flex items-center gap-x-1 rounded-md border-b bg-background p-1 shadow-xl",children:[(0,$e.jsxs)("div",{className:"flex items-center gap-x-0.5 pl-1",children:[(0,$e.jsx)("div",{className:"h-2 w-0.5 animate-[pulse_0.8s_ease-in-out_infinite] rounded-full bg-primary"}),(0,$e.jsx)("div",{className:"h-2.5 w-0.5 animate-[pulse_0.8s_ease-in-out_infinite_0.1s] rounded-full bg-primary"}),(0,$e.jsx)("div",{className:"h-1.5 w-0.5 animate-[pulse_0.8s_ease-in-out_infinite_0.2s] rounded-full bg-primary"}),(0,$e.jsx)("div",{className:"h-3 w-0.5 animate-[pulse_0.8s_ease-in-out_infinite_0.3s] rounded-full bg-primary"}),(0,$e.jsx)("div",{className:"h-2 w-0.5 animate-[pulse_0.8s_ease-in-out_infinite_0.4s] rounded-full bg-primary"}),(0,$e.jsx)("div",{className:"h-2.5 w-0.5 animate-[pulse_0.8s_ease-in-out_infinite_0.5s] rounded-full bg-primary"})]}),(0,$e.jsx)(ux,{onClick:d,className:"ml-2 h-4 w-4 p-0",variant:"default",size:"icon-xs",title:n("Done recording"),children:(0,$e.jsx)(Na.Check,{className:"!h-3.5 !w-3.5"})})]}),(0,$e.jsx)(ux,{className:G("relative h-6 w-6 p-0 transition-all duration-200",a&&"bg-primary text-primary-foreground",e),disabled:!i,onClick:d,"aria-label":r["aria-label"]||n("Start voice input"),title:r.title||n("Start voice input"),...r,children:(0,$e.jsx)(Na.MicIcon,{className:"!h-3.5 !w-3.5"})})]})},NX=({openDelay:e=0,closeDelay:t=0,...o})=>(0,$e.jsx)(Zf,{closeDelay:t,openDelay:e,...o}),EX=({align:e="start",...t})=>(0,$e.jsx)(og,{align:e,...t})});function lM(){let e=Ls();return(0,iM.useQuery)({queryKey:[il],queryFn:async()=>{let t=await e({body:{action:"AI_GET_CREDITS",data:{}}});return t!=null&&t.success&&t.credits?t.credits:null},staleTime:3e4,gcTime:6e4})}var iM,il,ng=x(()=>{"use strict";iM=require("@tanstack/react-query");Kt();il="AI_CREDITS"});var aS,ua,AX,ll,IX,cM,th=x(()=>{"use strict";"use client";aS=require("lucide-react");J();ua=require("react/jsx-runtime"),AX=()=>(0,ua.jsxs)("div",{className:"bg-surface flex h-[600px] flex-col space-y-4",children:[(0,ua.jsx)("div",{className:"grid grid-cols-1 gap-4 pb-4 md:grid-cols-3",children:[{id:"basic",name:"Basic Credits",credits:1e4,price:"$10",description:"Good for starting with AI features."},{id:"pro",name:"Pro Credits",credits:5e4,price:"$40",description:"Perfect for heavy AI content generation."},{id:"enterprise",name:"Enterprise Credits",credits:2e5,price:"$150",description:"Best for teams and large projects."}].map(t=>(0,ua.jsxs)("div",{className:"group relative overflow-hidden rounded-xl border p-4 transition-colors hover:border-primary/50",children:[(0,ua.jsxs)("div",{className:"mb-2 flex items-start justify-between",children:[(0,ua.jsx)("h3",{className:"text-sm font-semibold",children:t.name}),(0,ua.jsx)("span",{className:"text-sm font-bold text-primary",children:t.price})]}),(0,ua.jsx)("p",{className:"mb-4 text-xs text-muted-foreground",children:t.description}),(0,ua.jsxs)("div",{className:"mt-auto flex items-center justify-between border-t border-dashed pt-2",children:[(0,ua.jsxs)("span",{className:"flex items-center gap-1 text-xs font-semibold",children:[(0,ua.jsx)(aS.Sparkles,{className:"h-3 w-3 text-primary"}),t.credits.toLocaleString()," Credits"]}),(0,ua.jsx)(E,{size:"sm",className:"h-7 px-4 text-xs",children:"Buy Now"})]})]},t.id))}),(0,ua.jsx)("div",{className:"rounded-xl bg-muted/30 p-4",children:(0,ua.jsxs)("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,ua.jsx)(aS.Check,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-emerald-500"}),(0,ua.jsxs)("span",{children:[(0,ua.jsx)("b",{children:"No Expiration:"})," Add-on credits are added instantly to your account and never expire. They are used only after your monthly credits are exhausted."]})]})})]}),ll="ai-addon-credits",IX=()=>null,cM={id:ll,label:"Purchase Credits",panel:AX,button:IX,position:"top",width:800,view:"modal"}});var JN,dM,pM,mM,BX,Q,No=x(()=>{"use strict";JN=K(require("@radix-ui/react-label"),1),dM=require("class-variance-authority"),pM=K(require("react"),1);st();mM=require("react/jsx-runtime"),BX=(0,dM.cva)("text-xs font-light leading-none text-foreground/80 dark:text-foreground/60 peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Q=pM.forwardRef(({className:e,...t},o)=>(0,mM.jsx)(JN.Root,{ref:o,className:G(BX(),e),...t}));Q.displayName=JN.Root.displayName});var uM,ag,$s,sS,vi,ke,RX,DX,_X,LX,MX,OX,FX,oh,iS=x(()=>{"use strict";"use client";uM=require("@tanstack/react-query"),ag=require("lucide-react"),$s=require("react"),sS=require("react-i18next"),vi=require("sonner");lS();Zc();nS();St();dx();ng();rt();th();J();qt();fo();No();Oo();Gs();xi();gs();ke=require("react/jsx-runtime"),RX="e.g. TechFlow is a software company for project management. We help creative agencies collaborate faster with AI-driven scheduling...",DX="e.g. This is the Services page targeting 'custom web design' and 'responsive UI'. Goal is to showcase our design process...",_X=["Modern","Minimalist","Corporate","Elegant","Bold","Playful","Futuristic","Vintage","Luxury","Technical","Organic","Vibrant","Classic","Contemporary","Industrial","Artistic","Clean","Sophisticated","Creative","Professional","Trendy","Retro","Sleek","Warm","Cool","Dramatic","Subtle","Edgy","Refined","Dynamic"],LX=["Professional","Friendly","Informative","Persuasive","Humorous","Conversational","Authoritative","Casual","Formal","Enthusiastic","Empathetic","Confident","Inspiring","Educational","Witty","Serious"],MX=({data:e,onChange:t,isEnhancing:o,onEnhance:r})=>{let{t:n}=(0,sS.useTranslation)(),a=e.site||{},s=a.siteContext||"",i=(0,$s.useRef)(null);return(0,ke.jsxs)("div",{className:"space-y-1",children:[(0,ke.jsx)("div",{className:"space-y-1",children:(0,ke.jsxs)("p",{className:"rounded border border-border bg-accent/50 p-2 text-[11px] font-light leading-relaxed text-foreground/80",children:[(0,ke.jsx)("span",{className:"font-semibold",children:n("Include: ")}),n("Business name & industry (e.g. TechFlow is a project management"),n("company"),(0,ke.jsx)("br",{}),n("Target audience (e.g. creative agencies)"),(0,ke.jsx)("br",{}),n("Unique value proposition (e.g. AI-driven scheduling)"),(0,ke.jsx)("br",{}),n("Key products/services (e.g. AI-driven scheduling)")]})}),(0,ke.jsx)("div",{className:"h-2"}),(0,ke.jsx)(Q,{htmlFor:"site-context-textarea",children:n("Enter Site Context:")}),(0,ke.jsxs)("div",{className:"bg-surface overflow-hidden rounded-lg border border-border shadow-sm transition-all",children:[(0,ke.jsx)(Ro,{id:"site-context-textarea",ref:i,value:s,onChange:l=>t({site:{...a,siteContext:l.target.value}}),placeholder:RX,className:"no-scrollbar min-h-[150px] resize-none border-0 text-xs shadow-none",disabled:o}),(0,ke.jsxs)("div",{className:"flex items-center justify-start gap-3 px-3 py-2",children:[(0,ke.jsxs)(E,{size:"xs",variant:"outline",onClick:r,loading:o,className:"h-6 px-3 font-light",disabled:o||!s.trim(),children:[(0,ke.jsx)(ag.Wand2Icon,{className:"text-orange !h-3 !w-3"}),n("Enhance with AI")]}),(0,ke.jsx)(gx,{textareaRef:i,onTranscriptionChange:l=>t({site:{...a,siteContext:l}}),disabled:o,"aria-label":n("Start voice input"),title:n("Start voice input")})]})]}),(0,ke.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,ke.jsxs)("div",{className:"space-y-1",children:[(0,ke.jsx)(Q,{htmlFor:"look-select",children:n("Look")}),(0,ke.jsxs)(So,{value:a.look||"",onValueChange:l=>t({site:{...a,look:l}}),children:[(0,ke.jsx)(ho,{id:"look-select",children:(0,ke.jsx)(Do,{placeholder:"Select look"})}),(0,ke.jsx)(yo,{children:_X.map(l=>(0,ke.jsx)(gt,{value:l,children:l},l))})]})]}),(0,ke.jsxs)("div",{className:"space-y-1",children:[(0,ke.jsx)(Q,{htmlFor:"tone-select",children:n("Tone")}),(0,ke.jsxs)(So,{value:a.tone||"",onValueChange:l=>t({site:{...a,tone:l}}),children:[(0,ke.jsx)(ho,{id:"tone-select",children:(0,ke.jsx)(Do,{placeholder:"Select tone"})}),(0,ke.jsx)(yo,{children:LX.map(l=>(0,ke.jsx)(gt,{value:l,children:l},l))})]})]})]}),(0,ke.jsxs)("div",{className:"space-y-1 pt-2",children:[(0,ke.jsx)(Q,{htmlFor:"banned-words-input",children:n("Banned Words")}),(0,ke.jsx)(Ce,{id:"banned-words-input",value:a.bannedWords||"",onChange:l=>t({site:{...a,bannedWords:l.target.value}}),placeholder:"e.g. word1, word2, word3"}),(0,ke.jsxs)("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[(0,ke.jsx)("span",{className:"font-medium",children:"Note:"})," These words will be avoided by AI. Enter them as a comma-separated list."]})]})]})},OX=({data:e,onChange:t,isEnhancing:o,onEnhance:r})=>{let{t:n}=(0,sS.useTranslation)(),a=e.page||{},s=a.pageContext||"",i=(0,$s.useRef)(null);return(0,ke.jsxs)("div",{className:"space-y-1",children:[(0,ke.jsx)("div",{className:"space-y-1",children:(0,ke.jsxs)("p",{className:"rounded border border-border bg-accent/50 p-2 text-[11px] font-light leading-relaxed text-foreground/80",children:[(0,ke.jsx)("span",{className:"font-medium",children:n("Include: ")}),n("Page purpose (e.g. This is the Services page targeting "),(0,ke.jsx)("code",{children:n("custom web design")}),"\xA0",")",(0,ke.jsx)("br",{}),n("Target keywords (e.g. custom web design)"),(0,ke.jsx)("br",{}),n("Primary H1 goal (e.g. Showcase our design process)")]})}),(0,ke.jsx)("div",{className:"h-2"}),(0,ke.jsx)(Q,{htmlFor:"page-context-textarea",children:n("Enter Page Context:")}),(0,ke.jsxs)("div",{className:"bg-surface overflow-hidden rounded-lg border border-border shadow-sm transition-all",children:[(0,ke.jsx)(Ro,{id:"page-context-textarea",ref:i,value:s,onChange:l=>t({page:{...a,pageContext:l.target.value}}),placeholder:DX,className:"no-scrollbar min-h-[180px] resize-none border-0 text-xs shadow-none",disabled:o}),(0,ke.jsxs)("div",{className:"flex items-center justify-start gap-3 px-3 py-2",children:[(0,ke.jsxs)(E,{size:"xs",variant:"outline",onClick:r,loading:o,className:"h-6 px-3 font-light",disabled:o||!s.trim(),children:[(0,ke.jsx)(ag.Wand2Icon,{className:"text-orange !h-3 !w-3"}),n("Enhance with AI")]}),(0,ke.jsx)(gx,{textareaRef:i,onTranscriptionChange:l=>t({page:{...a,pageContext:l}}),disabled:o,"aria-label":n("Start voice input"),title:n("Start voice input")})]})]})]})},FX=({open:e,onOpenChange:t,defaultTab:o="page"})=>{let{data:r}=dr(),n=Ls(),a=Hc("AI_ENHANCE_CONTEXT"),[,s]=ma(),{t:i}=(0,sS.useTranslation)(),[l,c]=(0,$s.useState)(!1),[d,p]=(0,$s.useState)(!1),[u,m]=(0,$s.useState)(!1),[g,h]=(0,$s.useState)(o),[f,b]=(0,$s.useState)({site:{},page:{}}),[y,k]=(0,$s.useState)(null),w=y?JSON.stringify(f)!==JSON.stringify(y):!1,{data:N,isLoading:I}=Cm(),C=(0,uM.useQueryClient)();(0,$s.useEffect)(()=>{if(!e)return;let A=N||{site:{},page:{}};b(A),k(A),h(o)},[e,N,o]);let P=I&&e,B=(0,$s.useCallback)(A=>{b(D=>({...D,...A}))},[]),T=async()=>{var D;let A=((D=f.site)==null?void 0:D.siteContext)||"";if(!A.trim()){vi.toast.error(i("Please enter some site context to enhance"));return}p(!0);try{let R=await n({body:{action:$.AI_ENHANCE_CONTEXT,data:{type:"site",content:A,model:a}}});R!=null&&R.enhancedContent?(b(H=>({...H,site:{...H.site||{},siteContext:R.enhancedContent}})),vi.toast.success(i("Site context enhanced with AI!")),C.invalidateQueries({queryKey:[il]})):vi.toast.error(i("AI enhancement failed. Please try again."))}catch(R){console.error("Enhance site error:",R),R!=null&&R.canBuyCredits?vi.toast.error((0,ke.jsx)("p",{className:"font-medium",children:R.message||i("Failed to enhance with AI")}),{action:{label:"Buy Credits",onClick:()=>s(ll)},duration:8e3}):vi.toast.error((R==null?void 0:R.message)||"Failed to enhance with AI")}finally{p(!1)}},v=async()=>{var D;let A=((D=f.page)==null?void 0:D.pageContext)||"";if(!A.trim()){vi.toast.error(i("Please enter some page context to enhance"));return}m(!0);try{let R=await n({body:{action:$.AI_ENHANCE_CONTEXT,data:{type:"page",content:A,siteContext:JSON.stringify(f.site),model:a}}});R!=null&&R.enhancedContent?(b(H=>({...H,page:{...H.page||{},pageContext:R.enhancedContent}})),vi.toast.success(i("Page context enhanced with AI!")),C.invalidateQueries({queryKey:[il]})):vi.toast.error(i("AI enhancement failed. Please try again."))}catch(R){console.error("Enhance page error:",R),R!=null&&R.canBuyCredits?vi.toast.error((0,ke.jsx)("p",{className:"font-medium",children:R.message||"Failed to enhance with AI"}),{action:{label:"Buy Credits",onClick:()=>s(ll)},duration:8e3}):vi.toast.error((R==null?void 0:R.message)||i("Failed to enhance with AI"))}finally{m(!1)}},S=async()=>{c(!0);try{let A=f.site||{};if(await n({body:{action:$.AI_SAVE_CONTEXT,data:{type:"app",aiData:A}}}),r!=null&&r.id){let D=f.page||{};await n({body:{action:$.AI_SAVE_CONTEXT,data:{type:"page",pageId:r.id,aiData:D}}})}k({...f}),C.invalidateQueries({queryKey:[zN,r==null?void 0:r.id]}),vi.toast.success(i("AI context saved successfully!"))}catch(A){console.error("Save AI context error:",A),vi.toast.error((A==null?void 0:A.message)||i("Failed to save AI context"))}finally{c(!1)}};return(0,ke.jsx)(Te,{open:e,onOpenChange:t,children:(0,ke.jsxs)(we,{className:"gap-0 overflow-hidden p-0 sm:max-w-[560px]","aria-describedby":"ai-context-description",children:[(0,ke.jsxs)(Oe,{className:"px-5 pb-2 pt-3",children:[(0,ke.jsx)(Ie,{className:"py-0 text-sm leading-none",children:i("Manage Context")}),(0,ke.jsxs)(Dt,{id:"ai-context-description",className:"py-0 text-xs leading-none text-muted-foreground",children:[i("Configure site and page context to help AI generate better, more"),"relevant content."]})]}),(0,ke.jsxs)(Dr,{value:g,onValueChange:h,className:"flex-1 pt-1",children:[(0,ke.jsx)("div",{className:"px-5",children:(0,ke.jsxs)(Cr,{children:[(0,ke.jsxs)(ut,{value:"page",className:"px-3",children:[(0,ke.jsx)(ag.FileText,{className:"h-3.5 w-3.5"}),i("Current Page")]}),(0,ke.jsxs)(ut,{value:"site",className:"px-3",children:[(0,ke.jsx)(ag.BookOpen,{className:"h-3.5 w-3.5"}),i("Website")]})]})}),(0,ke.jsxs)("div",{className:"no-scrollbar relative max-h-[400px] min-h-[400px] overflow-y-auto px-5 py-4",children:[P?(0,ke.jsx)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm",children:(0,ke.jsx)(wt,{})}):null,(0,ke.jsx)(kr,{value:"page",children:(0,ke.jsx)(OX,{data:f,onChange:B,isEnhancing:u,onEnhance:v})}),(0,ke.jsx)(kr,{value:"site",children:(0,ke.jsx)(MX,{data:f,onChange:B,isEnhancing:d,onEnhance:T})})]})]}),(0,ke.jsx)("div",{className:"bg-surface flex justify-end border-t px-5 py-3",children:(0,ke.jsx)(E,{size:"sm",loading:l,onClick:S,disabled:d||u||!w,className:"min-w-[80px]",children:i("Save")})})]})})},oh=FX});var gM,QN,fM,hM,XN,ZN,yM=x(()=>{"use strict";gM="ai-conversations",QN=()=>({defaultLang:{chats:[]},imageGeneration:{chats:[]}}),fM=()=>{if(typeof window=="undefined")return QN();try{let e=sessionStorage.getItem(gM);return e?JSON.parse(e):QN()}catch(e){return QN()}},hM=e=>{var o;return((o=fM()[e])==null?void 0:o.chats)||[]},XN=(e,t)=>{if(typeof window!="undefined")try{let o=fM();o[e]={chats:t},sessionStorage.setItem(gM,JSON.stringify(o))}catch(o){}},ZN=e=>{XN(e,[])}});var bM,eE,tE,xM=x(()=>{"use strict";"use client";bM=K(require("react"),1);st();eE=require("react/jsx-runtime"),tE=bM.forwardRef(({className:e,value:t=0,...o},r)=>(0,eE.jsx)("div",{ref:r,className:G("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...o,children:(0,eE.jsx)("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,t))}%`}})}));tE.displayName="Progress"});function cS({isExpanded:e=!1,onToggle:t,compactOnly:o=!1}={}){let{data:r}=lM(),[,n]=ma(),{t:a}=(0,CM.useTranslation)();if(!r)return null;let s=r.monthly.limit+r.addon.total,i=(r.monthly.used+r.addon.used).toFixed(2).replace(/\.00$/,""),l=s>0?Math.min(100,(r.monthly.used+r.addon.used)/s*100):0;return o?(0,ht.jsxs)("button",{type:"button",onClick:()=>t==null?void 0:t(!e),className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground",children:[(0,ht.jsxs)("span",{children:[i," / ",s]}),e?(0,ht.jsx)(rh.ChevronUp,{className:"h-3 w-3"}):(0,ht.jsx)(rh.ChevronDown,{className:"h-3 w-3"})]}):(0,ht.jsx)("div",{className:"group rounded-md border bg-muted/10 p-2",children:(0,ht.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,ht.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ht.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ht.jsx)(rh.Sparkles,{className:"h-3 w-3 text-primary"}),(0,ht.jsxs)(en,{children:[(0,ht.jsx)($r,{asChild:!0,children:(0,ht.jsxs)("button",{type:"button",className:"cursor-pointer text-[10px] text-muted-foreground hover:text-foreground",children:[i," / ",s]})}),(0,ht.jsx)(Vr,{className:"w-56 p-3",side:"top",align:"start",children:(0,ht.jsxs)("div",{className:"space-y-3",children:[(0,ht.jsxs)("div",{className:"space-y-1",children:[(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,ht.jsx)("span",{className:"font-medium text-foreground",children:r.billingPeriod?a("Monthly Credits"):a("Lifetime Credits")}),r.billingPeriod&&(0,ht.jsxs)("span",{className:"text-muted-foreground",children:[vM(r.billingPeriod.start)," - ",vM(r.billingPeriod.end)]})]}),(0,ht.jsxs)("div",{className:"flex items-center justify-between pt-1 text-[10px]",children:[(0,ht.jsx)("span",{className:"text-muted-foreground",children:"Used"}),(0,ht.jsx)("span",{className:"font-medium",children:r.monthly.used})]}),(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,ht.jsx)("span",{className:"text-muted-foreground",children:"Remaining"}),(0,ht.jsx)("span",{className:"text-success font-medium",children:r.monthly.remaining})]})]}),r.addon.total>0&&(0,ht.jsxs)("div",{className:"space-y-1.5 border-t pt-1",children:[(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,ht.jsx)("span",{className:"font-medium text-foreground",children:a("Add-on Credits")}),(0,ht.jsx)("span",{className:"text-muted-foreground",children:a("Never expire")})]}),(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,ht.jsx)("span",{className:"text-muted-foreground",children:a("Total purchased")}),(0,ht.jsx)("span",{className:"font-medium",children:r.addon.total})]}),(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,ht.jsx)("span",{className:"text-muted-foreground",children:"Used"}),(0,ht.jsx)("span",{className:"font-medium",children:r.addon.used})]}),(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,ht.jsx)("span",{className:"text-muted-foreground",children:a("Remaining")}),(0,ht.jsx)("span",{className:"text-success font-medium",children:r.addon.remaining})]})]}),(0,ht.jsx)("div",{className:"border-t pt-2",children:(0,ht.jsxs)("div",{className:"flex items-center justify-between text-[10px] font-medium",children:[(0,ht.jsx)("span",{className:"text-foreground",children:a("Total Available")}),(0,ht.jsx)("span",{className:"text-success",children:r.totalAvailable})]})})]})})]})]}),r.canBuyCredits&&(0,ht.jsx)(E,{variant:"link",size:"xs",onClick:()=>n(ll),children:a("Buy Credits")})]}),(0,ht.jsx)(tE,{value:l,className:"h-1"})]})})}var rh,CM,ht,vM,kM=x(()=>{"use strict";rh=require("lucide-react"),CM=require("react-i18next");Zc();ng();J();Rs();xM();th();ht=require("react/jsx-runtime"),vM=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})});var dS,HX,Ga,ep=x(()=>{"use strict";dS=[{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"0.5x Credits",multiplier:.5},{id:"google/gemini-2.5-pro",name:"Gemini 2.5 Pro",provider:"google",description:"1.25x Credits",multiplier:1.25},{id:"google/gemini-3-flash",name:"Gemini 3 Flash",provider:"google",description:"1x Credits",multiplier:1},{id:"google/gemini-3-pro",name:"Gemini 3 Pro",provider:"google",description:"2.5x Credits",multiplier:2.5},{id:"openai/gpt-5",name:"GPT-5",provider:"openai",description:"2x Credits",multiplier:2},{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",provider:"anthropic",description:"1x Credits",multiplier:1},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"anthropic",description:"3x Credits",multiplier:3},{id:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",provider:"anthropic",description:"3x Credits",multiplier:3},{id:"openai/gpt-4.1",name:"GPT-4.1",provider:"openai",description:"2x Credits",multiplier:2}],HX="google/gemini-3-flash",Ga=()=>dS.find(e=>e.id===HX)||dS[0]});var pS,PM,SM,wM,Kl,cl,tp=x(()=>{"use strict";"use client";pS=require("react");rt();ep();PM=require("react/jsx-runtime"),SM=(0,pS.createContext)(void 0),wM=({children:e,config:t})=>{let o={...t,models:(t==null?void 0:t.models)||dS};return(0,PM.jsx)(SM.Provider,{value:o,children:e})},Kl=()=>{let e=(0,pS.useContext)(SM);if(e===void 0)throw new Error("useAIConfig must be used within AIConfigProvider");return e},cl=()=>{let e=Kl(),t=Nt("ai.models",[]);return{models:t.length>0?t:e.models}}});var TM,NM,fx,Vs,nh,ah,Sm,mS,hx=x(()=>{"use strict";"use client";TM=require("lucide-react"),NM=require("react"),fx=require("use-stick-to-bottom");J();st();Vs=require("react/jsx-runtime"),nh=({className:e,...t})=>(0,Vs.jsx)(fx.StickToBottom,{className:G("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),ah=({className:e,...t})=>(0,Vs.jsx)(fx.StickToBottom.Content,{className:G("flex flex-col gap-8 p-4",e),...t}),Sm=({className:e,title:t="No messages yet",description:o="Start a conversation to see messages here",icon:r,children:n,...a})=>(0,Vs.jsx)("div",{className:G("flex size-full flex-col items-center justify-center gap-3 px-3 py-12 text-center",e),...a,children:n!=null?n:(0,Vs.jsxs)(Vs.Fragment,{children:[r&&(0,Vs.jsx)("div",{className:"text-foreground/70",children:r}),(0,Vs.jsxs)("div",{className:"space-y-1",children:[(0,Vs.jsx)("div",{className:"text-sm text-foreground",children:t}),o&&(0,Vs.jsx)("p",{className:"text-xs font-light text-foreground/50",children:o})]})]})}),mS=({className:e,...t})=>{let{isAtBottom:o,scrollToBottom:r}=(0,fx.useStickToBottomContext)(),n=(0,NM.useCallback)(()=>{r()},[r]);return!o&&(0,Vs.jsx)(E,{className:G("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:n,size:"icon",type:"button",variant:"outline",...t,children:(0,Vs.jsx)(TM.ArrowDownIcon,{className:"size-4"})})}});var oE,EM,AM,sh,rE=x(()=>{"use strict";oE=K(require("@radix-ui/react-separator"),1),EM=K(require("react"),1);st();AM=require("react/jsx-runtime"),sh=EM.forwardRef(({className:e,orientation:t="horizontal",decorative:o=!0,...r},n)=>(0,AM.jsx)(oE.Root,{ref:n,decorative:o,orientation:t,className:G("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sh.displayName=oE.Root.displayName});var UX,IM,GX,lbe,BM=x(()=>{"use strict";UX=require("@radix-ui/react-slot"),IM=require("class-variance-authority");rE();st();GX=require("react/jsx-runtime"),lbe=(0,IM.cva)("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})});var ih,RM,_M,DM,LM=x(()=>{"use strict";"use client";ih=K(require("@radix-ui/react-tooltip"),1),RM=K(require("react"),1);st();_M=require("react/jsx-runtime"),DM=RM.forwardRef(({className:e,sideOffset:t=4,...o},r)=>(0,_M.jsx)(ih.Content,{ref:r,sideOffset:t,className:G("z-50 origin-[--radix-tooltip-content-transform-origin] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o}));DM.displayName=ih.Content.displayName});var uS,wm,MM,lh,Yl,Jl,kbe,Pm,yx=x(()=>{"use strict";"use client";uS=require("lucide-react"),wm=require("react"),MM=require("streamdown");Us();BM();LM();J();st();lh=require("react/jsx-runtime"),Yl=({className:e,from:t,...o})=>(0,lh.jsx)("div",{className:G("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...o}),Jl=({children:e,className:t,...o})=>(0,lh.jsx)("div",{className:G("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...o,children:e}),kbe=(0,wm.createContext)(null),Pm=(0,wm.memo)(({className:e,...t})=>(0,lh.jsx)(MM.Streamdown,{className:G("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Pm.displayName="MessageResponse"});var ch,OM,FM,HM,UM=x(()=>{"use strict";ch=K(require("@radix-ui/react-collapsible"),1),OM=ch.Root,FM=ch.CollapsibleTrigger,HM=ch.CollapsibleContent});var td,gS,$M,GM,$X,dh,fS=x(()=>{"use strict";"use client";td=require("motion/react"),gS=require("react");st();$M=require("react/jsx-runtime"),GM={p:td.motion.p,span:td.motion.span,div:td.motion.div,h1:td.motion.h1,h2:td.motion.h2,h3:td.motion.h3,h4:td.motion.h4,h5:td.motion.h5,h6:td.motion.h6},$X=({children:e,as:t="p",className:o,duration:r=2,spread:n=2})=>{let a=(0,gS.useMemo)(()=>{var l;return((l=e==null?void 0:e.length)!=null?l:0)*n},[e,n]),s=typeof t=="string"&&t in GM?t:"p",i=GM[s];return(0,$M.jsx)(i,{animate:{backgroundPosition:"0% center"},className:G("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-surface),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",o),initial:{backgroundPosition:"100% center"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:r,ease:"linear"},children:e})},dh=(0,gS.memo)($X)});var aE,hS,Gn,VM,fs,zM,WM,VX,nE,sg,zX,ig,WX,lg,yS=x(()=>{"use strict";"use client";aE=require("@radix-ui/react-use-controllable-state"),hS=require("lucide-react"),Gn=require("react"),VM=require("streamdown");UM();st();fS();fs=require("react/jsx-runtime"),zM=(0,Gn.createContext)(null),WM=()=>{let e=(0,Gn.useContext)(zM);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},VX=1e3,nE=1e3,sg=(0,Gn.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:r=!0,onOpenChange:n,duration:a,children:s,...i})=>{let[l,c]=(0,aE.useControllableState)({prop:o,defaultProp:r,onChange:n}),[d,p]=(0,aE.useControllableState)({prop:a,defaultProp:void 0}),[u,m]=(0,Gn.useState)(!1),[g,h]=(0,Gn.useState)(null),[f,b]=(0,Gn.useState)(0);(0,Gn.useEffect)(()=>{t?g===null&&(0,Gn.startTransition)(()=>h(Date.now())):g!==null&&(p(Math.ceil((Date.now()-g)/nE)),(0,Gn.startTransition)(()=>{h(null),b(0)}))},[t,g,p]),(0,Gn.useEffect)(()=>{if(!t||g===null)return;let k=setInterval(()=>{(0,Gn.startTransition)(()=>{b(Math.floor((Date.now()-g)/nE))})},nE);return()=>clearInterval(k)},[t,g]),(0,Gn.useEffect)(()=>{if(r&&!t&&l&&!u){let k=setTimeout(()=>{c(!1),m(!0)},VX);return()=>clearTimeout(k)}},[t,l,r,c,u]);let y=k=>{c(k)};return(0,fs.jsx)(zM.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:c,duration:d,elapsedSeconds:f},children:(0,fs.jsx)(OM,{className:G("not-prose mb-1.5",e),onOpenChange:y,open:l,...i,children:s})})}),zX=(e,t,o)=>{if(e){let r=o&&o>0?`Thinking... ${o}s`:"Thinking...";return(0,fs.jsx)(dh,{duration:1,children:r})}return t===void 0||t===0?(0,fs.jsx)("p",{children:"Thought for a few seconds"}):(0,fs.jsxs)("p",{children:["Thought for ",t," seconds"]})},ig=(0,Gn.memo)(({className:e,children:t,...o})=>{let{isStreaming:r,isOpen:n,duration:a,elapsedSeconds:s}=WM();return(0,fs.jsx)(FM,{className:G("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...o,children:t!=null?t:(0,fs.jsxs)(fs.Fragment,{children:[(0,fs.jsx)(hS.BrainIcon,{className:"size-4"}),zX(r,a,s),(0,fs.jsx)(hS.ChevronDownIcon,{className:G("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),WX=(e,t)=>{if(!e)return"";let o=e.split(`
27
+ `).filter(r=>r.trim());return o.length<=t?e:o.slice(-t).join(`
28
+ `)},lg=(0,Gn.memo)(({className:e,children:t,showLastLinesOnly:o,...r})=>{let{isStreaming:n}=WM(),a=n&&o?WX(t,o):t;return(0,fs.jsx)(HM,{className:G("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...r,children:(0,fs.jsx)(VM.Streamdown,{children:a})})});sg.displayName="Reasoning";ig.displayName="ReasoningTrigger";lg.displayName="ReasoningContent"});var cg,sE=x(()=>{"use strict";cg=e=>e?e.replace(/```[\s\S]*?```/g,"").replace(/```[\s\S]*$/g,"").replace(/`[^`]*`/g,"").replace(/<\/?[a-zA-Z][^>]*>/g,"").replace(/&lt;\/?[a-zA-Z][\s\S]*?&gt;/g,"").replace(/\n{3,}/g,`
29
+
30
+ `).trim():""});var Tm,ph,bS=x(()=>{"use strict";"use client";st();fS();Tm=require("react/jsx-runtime"),ph=({className:e,content:t,isLoading:o=!1,...r})=>(0,Tm.jsx)("div",{className:G("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...r,children:(0,Tm.jsx)("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:(0,Tm.jsx)("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:(0,Tm.jsxs)("div",{className:"flex flex-1 items-center gap-2",children:[o&&(0,Tm.jsx)(dh,{duration:1.5,children:t}),!o&&(0,Tm.jsx)("div",{className:"text-xs text-muted-foreground/80",children:t})]})})})})});function jM(e){if(!e)throw new Error("Empty AI response");let t=e.trim(),o=t.match(/```json\s*([\s\S]*?)\s*```/i);if(o)t=o[1];else{let r=t.match(/```\s*([\s\S]*?)\s*```/i);r&&(t=r[1])}if(t=t.replace(/^--START--/gi,"").replace(/--END--$/gi,"").trim(),!t)throw new Error("Empty AI response");try{return JSON.parse(t)}catch(r){throw new Error("Invalid JSON response from AI")}}function od(e){let t=e instanceof Error?e.message:String(e),o=t.toLowerCase();return o.includes("failed to fetch")||o.includes("networkerror")?"Unable to connect to the AI service. Please check your internet connection and try again.":o.includes("timeout")||o.includes("timed out")?"The request took too long to complete. Please try again with a simpler request.":o.includes("rate limit")||o.includes("too many requests")||o.includes("429")?"You've made too many requests. Please wait a moment before trying again.":o.includes("unauthorized")||o.includes("401")||o.includes("authentication")?"Your session has expired. Please refresh the page and try again.":o.includes("500")||o.includes("internal server error")?"The AI service is temporarily unavailable. Please try again in a few moments.":o.includes("503")||o.includes("service unavailable")?"The AI service is currently under maintenance. Please try again later.":o.includes("too long")||o.includes("token limit")||o.includes("context length")?"The content is too long for the AI to process. Please try with a smaller selection.":o.includes("quota")||o.includes("limit exceeded")||o.includes("credits")?"Your AI usage limit has been reached. Please upgrade your plan or wait for the limit to reset.":o.includes("invalid")||o.includes("parse")||o.includes("json")?"Received an unexpected response from the AI. Please try again.":o.includes("aborted")||o.includes("cancelled")?"The request was cancelled.":t.length<100?`Something went wrong: ${t}`:"Sorry, something went wrong. Please try again."}var qM,mh,uh=x(()=>{"use strict";qM=e=>{if(!e||typeof e!="string")return!1;if(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+)?;base64,([A-Za-z0-9+/=]+)$/.test(e))return!0;if(!/^[A-Za-z0-9+/=]+$/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch(r){return!1}},mh=({clean:e=!1}={})=>{try{let t="AI_AUTO_MODE",o=document.cookie.match(new RegExp("(^| )"+t+"=([^;]+)")),r=o?decodeURIComponent(o[2]):null;if(!r)return null;let n=JSON.parse(r);return e&&(document.cookie=`${t}=; path=/; max-age=0;`),n}catch(t){return null}}});function Ye({children:e,content:t,side:o="bottom",delayDuration:r=700,showTooltip:n=!0,onClick:a=()=>{},align:s=void 0,className:i=""}){return n?(0,dg.jsx)(df,{children:(0,dg.jsxs)(Fo,{delayDuration:r,children:[(0,dg.jsx)(Ho,{asChild:!0,onClick:a,children:e}),(0,dg.jsx)(Bo,{side:o,align:s,className:G("bg-background",i),children:(0,dg.jsx)("p",{children:t})})]})}):e}var dg,ea=x(()=>{"use strict";rs();st();dg=require("react/jsx-runtime")});var op,KM,YM,$o,xS,iE=x(()=>{"use strict";op=require("lucide-react"),KM=require("react"),YM=require("react-i18next");Ge();ea();J();$o=require("react/jsx-runtime"),xS=({onRemove:e,onManageContext:t,isLoading:o=!1})=>{let{t:r}=(0,YM.useTranslation)(),n=_e(),a=(n==null?void 0:n._type)||"Unknown",s=(n==null?void 0:n._name)||a,[i,l]=(0,KM.useState)(!1);return(0,$o.jsx)("div",{className:"relative mx-auto w-[95%] pb-1",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:(0,$o.jsxs)("div",{className:"relative -mb-1 pt-2",children:[(0,$o.jsx)("div",{className:"relative transition-all duration-300 ease-out",style:{zIndex:3},children:(0,$o.jsxs)("div",{className:"bg-surface flex items-center justify-between rounded-t-lg border border-b-0 border-border px-3 py-1.5",children:[(0,$o.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,$o.jsx)("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-primary text-[10px] font-semibold text-primary-foreground",children:"@"}),(0,$o.jsx)("span",{className:"truncate text-[11px] text-foreground",children:n?s:r("Entire Page")})]}),n&&(0,$o.jsx)(Ye,{content:r("Remove block from context"),side:"right",children:(0,$o.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:e,disabled:o,title:"Remove block from context",children:(0,$o.jsx)(op.X,{className:"!h-3 !w-3"})})})]})}),(0,$o.jsx)("div",{className:`absolute left-0 right-0 transition-all duration-300 ease-out ${i?"-top-6 scale-100":"top-px scale-[0.97]"}`,style:{zIndex:2},children:(0,$o.jsxs)("div",{className:"bg-surface flex items-center justify-between rounded-t-lg border border-border px-3 pb-1.5 pt-1 shadow-sm",children:[(0,$o.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,$o.jsx)("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-secondary text-[10px] font-semibold text-foreground",children:(0,$o.jsx)(op.FileText,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})}),(0,$o.jsx)("span",{className:"truncate text-[11px] text-foreground",children:r("Page context")})]}),(0,$o.jsx)(Ye,{content:r("Edit page context"),side:"right",children:(0,$o.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:()=>t("page"),disabled:o,tabIndex:i?0:-1,"aria-hidden":!i,children:(0,$o.jsx)(op.Edit,{className:"!h-3.5 !w-3.5"})})})]})}),(0,$o.jsx)("div",{className:`absolute left-0 right-0 transition-all duration-300 ease-out ${i?"-top-14 scale-100":"-top-[6px] scale-[0.94]"}`,style:{zIndex:1},children:(0,$o.jsxs)("div",{className:"bg-surface flex items-center justify-between rounded-t-lg border border-border px-3 pb-1.5 pt-1 shadow-sm",children:[(0,$o.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,$o.jsx)("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-secondary text-[10px] font-semibold text-foreground",children:(0,$o.jsx)(op.Globe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})}),(0,$o.jsx)("span",{className:"truncate text-[11px] text-foreground",children:r("Website context")})]}),(0,$o.jsx)(Ye,{content:r("Edit website context"),side:"right",children:(0,$o.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:()=>t("site"),disabled:o,tabIndex:i?0:-1,"aria-hidden":!i,children:(0,$o.jsx)(op.Edit,{className:"!h-3.5 !w-3.5"})})})]})})]})})}});var Jt,zs=x(()=>{"use strict";Jt={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokm\xE5l",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"P\u0101li",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volap\xFCk",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"}});function JM({userInput:e,language:t="en",currentHtml:o}){let r=Jt[t]||"English";if(o&&o.trim().length>0){let s=o.includes('data-ai-selected="true"')?`
31
+ NOTE: The element with data-ai-selected="true" is the user's current focus. While you have the full page context, prioritize changes to this selected element unless the user request explicitly requires broader changes.`:"";return`
32
+ MODE: EDIT
33
+ CURRENT HTML:
34
+ ${o}
35
+
36
+ USER REQUEST: ${e}
37
+ Use ${r} language.${s}
38
+ `.trim()}return`
39
+ USER REQUEST: ${e}
40
+ Use ${r} language.
41
+ `.trim()}function QM({fallbackLang:e,language:t,blocks:o=[],userInput:r}){let n=Jt[t]||"English";return`
42
+ USER REQUEST: ${r||"Translate the content"}
43
+ LANGUAGE TO TRANSLATE: ${n}
44
+ REQUESTED TRANSLATION LANGUAGE CODE: ${t}
45
+ FALLBACK LANGUAGE: ${Jt[e]}
46
+ BLOCKS: ${JSON.stringify(o)}`.trim()}var lE=x(()=>{"use strict";zs()});var XM,ZM,e2=x(()=>{"use strict";XM=require("react");pn();zl();Ne();ZM=()=>{let{addPredefinedBlock:e}=Xn();return(0,XM.useCallback)(async(t,o,r,n)=>{if(!Ct(t)){console.warn(`[useAddCustomBlock] Unknown block type: "${t}". Skipping.`);return}let s={_id:Uo(),_type:t,...n};await e([s],o,r)},[e])}});var t2,vS,cE=x(()=>{"use strict";t2=require("react");Ln();vS=()=>{let e=br();return(0,t2.useCallback)((t,o,r)=>{e([t],{[o]:r})},[e])}});var Nm,o2=x(()=>{"use strict";Nm=e=>{let t=e.trim();return t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():e}});var r2,n2,a2,jX,bx,CS=x(()=>{"use strict";r2=require("lodash-es"),n2=require("react");zr();Jn();ko();mn();Ge();tn();a2=(e,t)=>{let o=e.filter(a=>a._parent===t),r=o.map(a=>a._id),n=o.flatMap(a=>a2(e,a._id));return[...r,...n]},jX=(e,t,o)=>{let r=(0,r2.find)(e,{_id:t});if(!r)return e;let n=e.findIndex(p=>p._id===t),a=a2(e,t),s=new Set([t,...a]),i=e.filter(p=>!s.has(p._id)),l=new Set(o.map(p=>p._id)),c=o.map(p=>!p._parent||!l.has(p._parent)?{...p,_parent:r._parent}:p);return[...i.slice(0,n),...c,...i.slice(n)]},bx=()=>{let[,e]=Pe(),{setNewBlocks:t}=Ft(),{hasPermission:o}=kt();return(0,n2.useCallback)((r,n)=>{if(!o(xe["pages:update"]))return;let a=be.get(Ot),s=r?jX(a,r,n):n;t(s),n.length>0&&setTimeout(()=>e([n[0]._id]),200)},[e,t,o])}});var s2,i2,l2,c2=x(()=>{"use strict";s2=require("lodash-es"),i2=e=>{let t=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,o=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return t.test(e)||o.test(e)},l2=e=>{if((0,s2.isEmpty)(e))return e;let t=/<video[^>]+src=['"]([^'">]+)['"]/,o=/<iframe[^>]+src=['"]([^'">]+)['"]/,r=e.match(t),n=e.match(o),a=r?r[1]:n?n[1]:null,s=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,i=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return a&&(s.test(a)||i.test(a))?a:e}});var pg,oe,dE,kS,qX,KX,YX,JX,QX,pE,xx,p2,d2,XX,ZX,mE,eZ,tZ,$a,Em=x(()=>{"use strict";pg=require("himalaya"),oe=require("lodash-es");Ha();pn();Tn();st();Ne();c2();dE=["chai-name","data-chai-name"],kS=null,qX=()=>(kS||(kS=import("@iconify-json/lucide/icons.json").then(e=>{var t,o,r;return(r=(o=(t=e.default)==null?void 0:t.icons)!=null?o:e.icons)!=null?r:{}}).catch(()=>(kS=null,{}))),kS),KX=async e=>{let t=e.filter(r=>r._iconName);if(t.length===0)return e;let o=await qX();for(let r of t){let n=r._iconName.trim().toLowerCase(),a=o[n];if(a!=null&&a.body){let s=a.width||24,i=a.height||24;r.icon=`<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-${n}" width="${s}" height="${i}" viewBox="0 0 ${s} ${i}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${a.body}</svg>`}delete r._iconName}return e},YX={partialblockid:"partialBlockId"},JX={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},QX=(e,t)=>{var o;return((o=e.children)==null?void 0:o.length)===1&&(0,oe.includes)(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],t._type)},pE=e=>e.map(t=>t.type==="text"?(0,oe.get)(t,"content",""):(0,oe.isEmpty)(t.children)?"":pE(t.children||[])).join(""),xx=e=>e===null?"":e,p2=e=>{let t=(0,oe.compact)((0,oe.map)(e.split(/\s+/),oe.trim)),o=(0,oe.find)(t,i=>/^w-/.test(i)),r=(0,oe.find)(t,i=>/^h-/.test(i));if(!r||!o)return{height:"",width:""};let n=i=>{if(!i)return;let l=i.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!l)return;if(l[1])return l[1];let c=l[2];return/^\d+(\.\d+)?$/.test(c)?`${Number(c)*4}px`:c==="auto"||(0,oe.includes)(c,"%")?c:"16px"},a=n(o),s=n(r);return{width:(0,oe.includes)(a,"px")?a:"16px",height:(0,oe.includes)(s,"px")?s:"16px"}},d2=e=>{if(e.tagName==="svg")return{};let t={},o=JX[e.tagName||""]||{},r=e.attributes||[];return(0,oe.forEach)(r,({key:n,value:a})=>{var s;if(!(0,oe.includes)(dE,n))if(n==="bid"&&(t._bid=xx(a)),o[n]){if(e.tagName==="img"&&n==="src"&&!a.startsWith("http")){let i=(0,oe.find)(e.attributes,{key:"width"}),l=(0,oe.find)(e.attributes,{key:"height"});i&&l?a=`https://picsum.photos/${i==null?void 0:i.value}x${l==null?void 0:l.value}`:a="https://picsum.photos/150x150"}else if(e.tagName==="a"){let i=(0,oe.find)(e.attributes,{key:"href"});i&&typeof(i==null?void 0:i.value)=="string"&&((s=i==null?void 0:i.value)!=null&&s.startsWith("pageType:"))&&(0,oe.set)(t,"link.type","pageType")}(0,oe.set)(t,o[n],xx(a))}else(0,oe.includes)(["style","class","srcset","bid"],n)||(t.styles_attrs=t.styles_attrs||{},(0,oe.startsWith)(n,"@")&&(n=n.replace("@","x-on:")),t.styles_attrs[`${n}`]=xx(a))}),delete t.class,t},XX=(e,t="styles")=>{if(!e.attributes)return{[t]:`${lr},`};let o=(0,oe.find)(e.attributes,{key:"class"});if(o){let r=o.value;return{[t]:`${lr},${r}`}}return{[t]:`${lr},`}},ZX=e=>{var c;let t=(0,oe.get)(e,"attributes",[]),o=t.find(d=>d.key==="data-chai-richtext"||d.key==="chai-richtext"),r=t.find(d=>d.key==="data-chai-lightbox"||d.key==="chai-lightbox"),n=t.find(d=>d.key==="data-chai-dropdown"||d.key==="chai-dropdown"),a=t.find(d=>d.key==="data-chai-dropdown-button"||d.key==="chai-dropdown-button"),s=t.find(d=>d.key==="data-chai-dropdown-content"||d.key==="chai-dropdown-content"),i=t.find(d=>d.key==="class"),l=i&&i.value.split(/\s+/).includes("rte");if(n)return{_type:"Dropdown"};if(a)return{_type:"DropdownButton"};if(s)return{_type:"DropdownContent"};if(o||l)return{_type:"Paragraph"};if(r)return{_type:"LightBoxLink"};switch(e.tagName){case"img":return{_type:"Image"};case"input":return(0,oe.get)((0,oe.find)(e.attributes,{key:"type"}),"value","").toLowerCase()==="submit"?{_type:"FormButton"}:{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:e.tagName,_listType:e.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:e.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:e.tagName};case"strong":return{_type:"Span",tag:e.tagName,styles:"#styles:,font-bold"};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:((c=(0,oe.find)(e.attributes,{key:"type"}))==null?void 0:c.value)==="submit"?"FormButton":"Button"};case"code":return{_type:"Box",_name:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:e.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:e.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{let d=(0,oe.get)(e,"children",[]).length>0?"Box":"EmptyBox";return{_type:d,tag:e.tagName,_name:d=="EmptyBox"||e.tagName==="div"?d:(0,oe.capitalize)(e.tagName)}}}},mE=(e,t=null)=>(0,oe.flatMapDeep)(e,o=>{var m,g,h,f,b,y,k,w,N,I;if(o.type==="comment")return[];let r={_id:Uo()};if(t&&(r._parent=t.block._id),o.type==="text")return(0,oe.isEmpty)((0,oe.get)(o,"content",""))?[]:t&&QX(t.node,t.block)?((0,oe.set)(t,"block.content",(0,oe.get)(o,"content","")),[]):{...r,_type:"Text",content:(0,oe.get)(o,"content","")};if((0,oe.startsWith)(o.tagName,"chai-")){let C=o.attributes||[],P=(0,oe.find)(C,{key:"chai-type"}),B=(P==null?void 0:P.value)||(0,oe.startCase)((0,oe.camelCase)(o.tagName||"")).replace(/ /g,"").replace(/\s+/g,"");if(r._type=B,(0,oe.forEach)(C,({key:T,value:v})=>{var D;if(T==="about-this-component"||T==="chai-type"||T==="can-move"||T==="can-delete")return;if(T==="id"){r._id=v;return}if(T==="bid"){r._bid=xx(v);return}if((0,oe.includes)(dE,T)){r._name=v;return}if(T==="icon-name"&&o.tagName==="chai-icon"){r._iconName=v;return}let S;if((0,oe.startsWith)(T,"_"))S="_"+(0,oe.camelCase)(T.slice(1));else{let R=(0,oe.camelCase)(T);S=(D=YX[R])!=null?D:R}let A=xx(v);typeof A=="string"&&(0,oe.startsWith)(A,"#styles:")&&(A=A.replace("#styles:","#styles:,")),r[S]=A}),jc(B)){let T=mE(o.children||[],{block:r,node:o});return[r,...T]}return[r]}let n=(0,oe.get)(o,"attributes",[]),a=o.tagName==="p"||n.find(C=>C.key==="data-chai-richtext"||C.key==="chai-richtext"),s=n.find(C=>C.key==="class"),i=s&&s.value.split(/\s+/).includes("rte"),l=n.find(C=>C.key==="data-chai-lightbox"||C.key==="chai-lightbox"),c=n.find(C=>C.key==="data-chai-dropdown"||C.key==="chai-dropdown"),d=n.find(C=>C.key==="data-chai-dropdown-button"||C.key==="chai-dropdown-button"),p=n.find(C=>C.key==="data-chai-dropdown-content"||C.key==="chai-dropdown-content");if(r={...r,...ZX(o),...d2(o),...XX(o)},o.attributes){let C=o.attributes.find(P=>(0,oe.includes)(dE,P.key));C&&(r._name=C.value)}if(a||i){let C=(0,pg.stringify)(o.children||[]);return r.content=o.tagName==="p"?`<p>${C}</p>`:`${C}`,(0,oe.has)(r,"styles_attrs.data-chai-richtext")&&delete r.styles_attrs["data-chai-richtext"],(0,oe.has)(r,"styles_attrs.chai-richtext")&&delete r.styles_attrs["chai-richtext"],[r]}if(l){let C=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];r={...r,href:((m=n.find(P=>P.key==="href"))==null?void 0:m.value)||"",hrefType:((g=n.find(P=>P.key==="data-vbtype"))==null?void 0:g.value)||"video",autoplay:((h=n.find(P=>P.key==="data-autoplay"))==null?void 0:h.value)==="true"?"true":"false",maxWidth:((b=(f=n.find(P=>P.key==="data-maxwidth"))==null?void 0:f.value)==null?void 0:b.replace("px",""))||"",backdropColor:((y=n.find(P=>P.key==="data-overlay"))==null?void 0:y.value)||"",galleryName:((k=n.find(P=>P.key==="data-gall"))==null?void 0:k.value)||""},(0,oe.forEach)(C,P=>{(0,oe.has)(r,`styles_attrs.${P}`)&&delete r.styles_attrs[P]})}if(c&&(delete r.styles_attrs,r.showDropdown=!1),p&&delete r.styles_attrs,d){delete r.styles_attrs;let C=(0,oe.filter)(o.children||[],B=>(B==null?void 0:B.tagName)!=="span");r.content=pE(C);let P=(0,oe.find)(o.children||[],B=>(B==null?void 0:B.tagName)==="span"&&(0,oe.some)(B.children||[],T=>(T==null?void 0:T.tagName)==="svg"));if(P){let B=(0,oe.find)(P.children||[],T=>(T==null?void 0:T.tagName)==="svg");if(B){r.icon=(0,pg.stringify)([B]);let{height:T,width:v}=eZ(B,"16px","16px");r.iconHeight=T,r.iconWidth=v}}return[r]}if(r._type==="Input"){let C=r.inputType||"text";C==="checkbox"?(0,oe.set)(r,"_type","Checkbox"):C==="radio"&&(0,oe.set)(r,"_type","Radio"),(0,oe.set)(r,"label","")}else if(o.tagName==="video"||o.tagName==="iframe"){let C=(0,pg.stringify)([o]);return i2(C)&&((0,oe.set)(r,"_type","Video"),(0,oe.set)(r,"url",l2(C)),(0,oe.set)(r,"styles",`${lr},`),(0,oe.set)(r,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),r.content=C,[r]}else if(o.tagName==="svg"){let C=(0,oe.get)((0,oe.find)(o.attributes,{key:"class"}),"value",""),{height:P,width:B}=p2(C);if(P&&B)r.styles=`${lr}, ${G(`w-${B} h-${P}`,C)}`.trim(),r.height=P==null?void 0:P.replace("px",""),r.width=B==null?void 0:B.replace("px","");else{let T=(w=(0,oe.find)(o.attributes,{key:"height"}))==null?void 0:w.value,v=(N=(0,oe.find)(o.attributes,{key:"width"}))==null?void 0:N.value;T&&v?(r.styles=`${lr}, ${G(`w-[${v}px] h-[${T}px]`,C)}`.trim(),r.height=T,r.width=v):r.styles=`${lr}, ${G("w-full h-full",C)}`.trim()}return o.attributes=(0,oe.filter)(o.attributes,T=>!(0,oe.includes)(["style","width","height","class"],T.key)),r.icon=(0,pg.stringify)([o]),[r]}else{if(o.tagName=="option"&&t&&((I=t.block)==null?void 0:I._type)==="Select")return t.block.options.push({label:pE(o.children||[]),...d2(o)}),[];r._type==="Select"&&((0,oe.set)(r,"inputStyles",(0,oe.get)(r,"styles","")),(0,oe.unset)(r,"styles"),(0,oe.set)(r,"label",""))}let u=mE(o.children||[],{block:r,node:o});return[r,...u]}),eZ=(e,t,o)=>{var l,c;let r=(0,oe.get)(e,"attributes",[]),{height:n,width:a}=p2((0,oe.get)((0,oe.find)(r,{key:"class"}),"value",""));if(n&&a)return{height:`[${n}px]`,width:`[${a}px]`};let s=(l=(0,oe.find)(r,{key:"height"}))==null?void 0:l.value,i=(c=(0,oe.find)(r,{key:"width"}))==null?void 0:c.value;return{height:s?`[${s}px]`:o,width:i?`[${i}px]`:t}},tZ=e=>{e=e.replace(/([\w-]+)=\\?"(.*?)\\?"/g,(r,n,a)=>{let s=a.replace(/\\"/g,'"');return s=s.replace(/{([^}]+)}/g,i=>i.replace(/"/g,'\\"')),`${n}="${s.replace(/\\"/g,'"')}"`}),e=e.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),e=e.replace(/\$name="[^"]*"/g,"");let t=e.match(/<body[^>]*>([\s\S]*?)<\/body>/);return(t?t[1]:e).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},$a=async e=>{let t=(0,pg.parse)(tZ(e));if((0,oe.isEmpty)(e))return[];let o=(0,oe.flatten)(mE(t));return await KX(hi(o))}});function u2(e){let t=e.indexOf(":");if(t===-1)throw new Error("Invalid data stream part: no colon separator");let o=e.substring(0,t),r=e.substring(t+1),n;try{n=JSON.parse(r)}catch(a){n=r}switch(o){case"0":return{type:"text",value:n};case"9":return{type:"tool_call",toolCallId:n.toolCallId,toolName:n.toolName,args:n.args};case"a":return{type:"tool_result",toolCallId:n.toolCallId,value:n.result};case"d":return{type:"finish_message",value:n};case"3":return{type:"error",value:n};default:return{type:"other",value:n}}}function g2(e){let t=e.trim();if(!t.startsWith("data:"))return null;let o=t.slice(t.indexOf(":")+1).trim();if(!o||o==="[DONE]")return{type:"done"};try{return JSON.parse(o)}catch(r){return null}}function oZ(e){let t=e.trim();if(g2(t))return"ui-message-sse";try{return u2(t),"legacy-data"}catch(o){return"legacy-text"}}var m2,Am,f2,h2=x(()=>{"use strict";m2=require("@tanstack/react-query");e2();cE();Am=require("react");o2();zl();om();CS();ng();Em();f2=()=>{let{addPredefinedBlock:e}=Xn(),t=bx(),o=_c(),r=(0,m2.useQueryClient)(),n=ZM(),a=vS(),s=(0,Am.useCallback)(async(f,b)=>{if(!b)return;let y=await $a(b);await e(y,f.parentId,f.position)},[e]),i=(0,Am.useCallback)(async(f,b)=>{if(!f.blockId||!b)return;let y=await $a(b);await t(f.blockId,y)},[t]),l=(0,Am.useCallback)(async f=>{!f.ids||f.ids.length===0||await o(f.ids)},[o]),c=(f,b)=>{let y=document.getElementById("canvas-iframe");if(!y)return null;let k=y==null?void 0:y.contentDocument;if(!k)return null;k.querySelectorAll("[data-stream-canvas]").forEach(C=>C.remove());let N=null;if(f&&f!=="undefined"&&(N=k.querySelector(`[data-block-id="${f}"]`)),N||(N=k.querySelector('[data-block-id="canvas"]')),!N)return null;let I=k.createElement("div");if(I.setAttribute("data-stream-canvas","true"),b!==void 0&&b>=0&&N.children){let C=Math.min(b,N.children.length);C<N.children.length?N.insertBefore(I,N.children[C]):N.appendChild(I)}else N.appendChild(I);return I},d=f=>{var I;let b=document.getElementById("canvas-iframe");if(!b)return null;let y=b==null?void 0:b.contentDocument;if(!y)return null;y.querySelectorAll("[data-stream-canvas]").forEach(C=>C.remove());let w=y.querySelector(`[data-block-id="${f}"]`);if(!w)return null;let N=y.createElement("div");return N.setAttribute("data-stream-canvas","true"),(I=w.parentNode)==null||I.insertBefore(N,w.nextSibling),w.style.display="none",N},p=f=>{let b=document.getElementById("canvas-iframe");b!=null&&b.contentWindow&&f.scrollIntoView({behavior:"smooth",block:"end"})},u=(0,Am.useCallback)((f,b,y)=>{let k=c(b,y);k&&(k.innerHTML=f,p(k))},[]),m=(0,Am.useCallback)((f,b)=>{let y=d(b);y&&(y.innerHTML=f,p(y))},[]),g=f=>{let b=f.match(/^--ACTION=(.+)--$/);if(!b)return null;let k=b[1].replace(/--/g,"").split("|"),N={type:k[0]};return k.forEach(I=>{let C=I.trim();if(C.startsWith("PARENT=")){let P=Nm(C.substring(7));N.parentId=P==="undefined"?void 0:P}else C.startsWith("POS=")?N.position=parseInt(Nm(C.substring(4))):C.startsWith("ID=")?N.blockId=Nm(C.substring(3)):C.startsWith("IDS=")&&(N.ids=Nm(C.substring(4)).split(",").map(P=>P.trim()))}),N},h=(0,Am.useCallback)(async(f,b,y)=>{var k;switch(f){case"remove_blocks":b.ids&&b.ids.length>0&&(await o(b.ids),b.reason&&y(w=>[...w,{id:Date.now().toString(),role:"assistant",content:b.reason}]));break;case"add_custom_block":await n(b.type,b.parentId,b.position,(k=b.props)!=null?k:{}),b.reason&&y(w=>[...w,{id:Date.now().toString(),role:"assistant",content:b.reason}]);break;case"bind_prop":a(b.blockId,b.propName,b.bindingPath),b.reason&&y(w=>[...w,{id:Date.now().toString(),role:"assistant",content:b.reason}]);break;case"get_partial_blocks":break;default:console.warn(`[useProcessAiStream] Unknown tool call: ${f}`)}},[o,n,a]);return(0,Am.useCallback)(async(f,b)=>{var H;let y=new TextDecoder,k="",w=!1,N=null,I="",C=null,P=[],B=async()=>{for(let M of P.splice(0)){let L;try{L=JSON.parse(M.args)}catch(z){L={}}await h(M.name,L,b)}},T=async M=>{var z;if(!M)return;k+=M;let L=k.split(`
47
+ `);k=(z=L.pop())!=null?z:"";for(let _ of L)await S(_)},v={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},S=async M=>{var z;let L=M.trim();if(L==="--START--"){w=!0;return}if(w){if(L==="--END--"){v.currentAction&&(v.htmlBuffer||v.currentAction.type==="REMOVE")&&await A(v.currentAction,v.htmlBuffer);let _=document.getElementById("canvas-iframe"),F=(z=_==null?void 0:_.contentDocument)==null?void 0:z.querySelectorAll("[data-stream-canvas]");F==null||F.forEach(O=>O.remove());return}if(L.startsWith("--THINKING=")){let _=Nm(L.substring(11));b(F=>{let O=[...F],U=O[O.length-1];if(U&&U.role==="assistant"&&U.isReasoning)U.content=_,U.isStreaming=!1;else{let j={id:Date.now().toString(),role:"assistant",content:_,isReasoning:!0,isStreaming:!1};O.push(j)}return O});return}if(L.startsWith("--TASK=")){let _=L.substring(7),F=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,O={id:F,role:"assistant",content:Nm(_.replace(/--$/,"")),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};N=F,b(U=>[...U,O]);return}if(L.startsWith("--MSG=")){let _=L.substring(6),F={id:Date.now().toString(),role:"assistant",content:Nm(_.replace(/--$/g,"")),isReasoning:!1,isStreaming:!1};b(O=>[...O.filter(j=>!(j.isReasoning&&j.isStreaming)),F]);return}if(L.startsWith("--ACTION=")){v.currentAction&&(v.htmlBuffer||v.currentAction.type==="REMOVE")&&await A(v.currentAction,v.htmlBuffer),v.currentAction=g(L),v.htmlBuffer="",v.isInAction=!0;return}if(L==="--ENDACTION--"){v.currentAction&&(v.htmlBuffer||v.currentAction.type==="REMOVE")&&await A(v.currentAction,v.htmlBuffer),N&&(b(_=>_.map(F=>F.isTask?{...F,isTaskCompleted:!0}:F)),N=null),v.currentAction=null,v.htmlBuffer="",v.isInAction=!1;return}if(L==="--HTML--"){v.isCapturingHtml=!0;return}if(L==="--ENDHTML--"){v.isCapturingHtml=!1;return}if(L.startsWith("--HTML--")&&L.includes("--ENDHTML--")){let _=L.match(/^--HTML--(.+?)--ENDHTML--$/);if(_&&v.currentAction){let F=_[1];v.htmlBuffer+=F,v.currentAction.type==="ADD"?u(v.htmlBuffer,v.currentAction.parentId,v.currentAction.position):v.currentAction.type==="EDIT"&&v.currentAction.blockId&&m(v.htmlBuffer,v.currentAction.blockId)}return}if(v.isCapturingHtml&&v.currentAction){v.htmlBuffer+=M+`
48
+ `,v.currentAction.type==="ADD"?u(v.htmlBuffer,v.currentAction.parentId,v.currentAction.position):v.currentAction.type==="EDIT"&&v.currentAction.blockId&&m(v.htmlBuffer,v.currentAction.blockId);return}if(!L.startsWith("--")&&L.length>0){if(/^<\/?[a-zA-Z]/.test(L))return;I+=M+`
49
+ `,b(_=>{let F=[..._],O=F[F.length-1];return O&&O.role==="assistant"&&O.isReasoning&&O.isStreaming&&(O.content=I),F})}}},A=async(M,L)=>{try{switch(M.type){case"ADD":await s(M,L);break;case"EDIT":await i(M,L);break;case"REMOVE":await l(M);break}b(z=>z.filter(_=>!_.isTask))}catch(z){console.log(z)}},D=async M=>{var z,_;if(!M.trim())return;let L;try{L=u2(M)}catch(F){return}switch(L.type){case"text":await T((z=L.value)!=null?z:"");break;case"tool_call":P.push({id:L.toolCallId,name:L.toolName,args:JSON.stringify((_=L.args)!=null?_:{})});break;case"tool_result":break;case"finish_message":await B();break;case"error":{let F={id:Date.now().toString(),role:"assistant",content:String(L.value)};b(O=>[...O,F]);break}}},R=async M=>{var z,_,F,O,U;let L=g2(M);if(L)switch(L.type){case"text-delta":await T((z=L.delta)!=null?z:"");break;case"tool-input-available":P.push({id:(_=L.toolCallId)!=null?_:"",name:(F=L.toolName)!=null?F:"",args:JSON.stringify((O=L.input)!=null?O:{})});break;case"tool-result":case"tool-output-available":break;case"finish":case"finish-step":await B();break;case"error":{let j={id:Date.now().toString(),role:"assistant",content:(U=L.errorText)!=null?U:"An error occurred while streaming the AI response."};b(ce=>[...ce,j]);break}case"done":case"start-step":case"start":case"text-start":case"text-end":case"finish_message":break}};try{let M="";for(;;){let{done:L,value:z}=await f.read();if(L)break;if(M+=y.decode(z,{stream:!0}),C===null){let F=M.indexOf(`
50
+ `);if(F===-1)continue;let O=M.slice(0,F).trim();if(!O){M=M.slice(F+1);continue}C=oZ(O)}let _=M.split(`
51
+ `);if(M=(H=_.pop())!=null?H:"",C==="ui-message-sse")for(let F of _)await R(F);else if(C==="legacy-data")for(let F of _)await D(F);else for(let F of _){let O=F.trim();O.startsWith("9:")||O.startsWith("d:")||O.startsWith("3:")?await D(F):await S(F)}}if(M.trim())if(C==="ui-message-sse")await R(M);else if(C==="legacy-data")await D(M);else{let L=M.trim();L.startsWith("9:")||L.startsWith("d:")||L.startsWith("3:")?await D(M):await S(M)}k.trim()&&(await S(k),k=""),await B(),r.invalidateQueries({queryKey:[il]})}catch(M){console.log(M)}},[s,i,l,h,r,u,m])}});var dl,y2,b2,x2,v2,C2,k2,S2,w2,P2=x(()=>{"use strict";Us();jp();Rs();st();dl=require("react/jsx-runtime"),y2=e=>(0,dl.jsx)(en,{...e}),b2=e=>(0,dl.jsx)($r,{...e}),x2=({className:e,children:t,title:o="Model Selector",...r})=>(0,dl.jsx)(Vr,{"aria-labelledby":"model-selector-title",className:G("w-[400px] p-0",e),...r,children:(0,dl.jsxs)(Yi,{className:"**:data-[slot=command-input-wrapper]:h-auto relative",children:[(0,dl.jsx)("div",{id:"model-selector-title",className:"sr-only",children:o}),t]})}),v2=e=>(0,dl.jsx)(Ji,{...e}),C2=e=>(0,dl.jsx)(Wp,{...e}),k2=e=>(0,dl.jsx)(as,{...e}),S2=({provider:e,className:t,...o})=>(0,dl.jsx)(qo,{...o,alt:`${e} logo`,className:G("size-5 rounded-full bg-background p-0.5 dark:bg-gray-500",t),height:20,src:`https://models.dev/logos/${e}.svg`,width:20}),w2=({className:e,...t})=>(0,dl.jsx)("span",{className:G("line-clamp-1 flex-1 text-left",e),...t})});var SS,T2,_r,N2,E2=x(()=>{"use strict";"use client";SS=require("lucide-react"),T2=require("react");P2();ea();J();tp();_r=require("react/jsx-runtime"),N2=({selectedModel:e,onModelChange:t,disabled:o=!1})=>{let[r,n]=(0,T2.useState)(!1),{models:a}=cl(),s=a.find(c=>c.id===e)||a[0],i=a.reduce((c,d)=>(c[d.provider]||(c[d.provider]=[]),c[d.provider].push(d),c),{}),l=c=>{t(c),n(!1)};return(0,_r.jsxs)(y2,{open:r,onOpenChange:n,children:[(0,_r.jsx)(Ye,{content:s.name,side:"top",children:(0,_r.jsx)(b2,{asChild:!0,className:"bg-transparent",children:(0,_r.jsxs)(E,{variant:"outline",size:"xs",disabled:o,className:"h-[22px] max-w-[120px] gap-1 px-2 font-light",children:[(0,_r.jsx)(SS.Cpu,{className:"!h-3 !w-3"}),(0,_r.jsx)("span",{className:"max-w-20 truncate text-[11px]",children:s.name})]})})}),(0,_r.jsxs)(x2,{className:"max-w-72 p-0",align:"start",children:[(0,_r.jsx)("h3",{className:"px-3 pb-0 pt-2 text-xs font-medium text-foreground",children:"Models"}),(0,_r.jsx)(v2,{className:"no-scrollbar",children:Object.entries(i).map(([c,d])=>(0,_r.jsx)(C2,{heading:c.charAt(0).toUpperCase()+c.slice(1),children:d.map(p=>(0,_r.jsxs)(k2,{value:p.id,onSelect:()=>l(p.id),className:`relative flex cursor-pointer items-start pb-1 pt-1.5 ${e===p.id?"bg-accent":"hover:bg-accent/50"}`,children:[e===p.id?(0,_r.jsx)(SS.Check,{className:"mt-0.5 size-5 rounded-full bg-primary stroke-[4px] p-0.5 text-primary-foreground"}):(0,_r.jsx)(S2,{provider:p.provider}),(0,_r.jsx)(Ye,{content:(0,_r.jsxs)(_r.Fragment,{children:[(0,_r.jsx)("b",{children:p.name}),": ",p.description]}),side:"top",align:"start",className:"w-44",children:(0,_r.jsxs)("div",{className:"flex w-full flex-col",children:[(0,_r.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,_r.jsx)(w2,{className:"text-xs leading-none",children:p.name}),(p==null?void 0:p.multiplier)>0?(0,_r.jsxs)("div",{className:"text-[10px] italic text-muted-foreground",children:[p==null?void 0:p.multiplier,"x Credits"]}):null]}),(0,_r.jsx)("div",{className:"line-clamp-1 text-[10px] italic leading-4 text-muted-foreground",children:p.description})]})})]},p.id))},c))})]})]})}});var vx={};et(vx,{default:()=>nZ});var Ql,rd,A2,I2,mr,uE,rZ,nZ,Cx=x(()=>{"use strict";"use client";Ql=require("lucide-react"),rd=require("react"),A2=require("react-i18next"),I2=require("sonner");nS();J();tp();E2();ep();mr=require("react/jsx-runtime"),uE="chai-ai-selected-model",rZ=({input:e,setInput:t,onSend:o,onStop:r,isLoading:n,disabled:a,selectedLang:s,selectedModel:i,onModelChange:l,isGenerateImagePanel:c=!1})=>{var C;let{t:d}=(0,A2.useTranslation)(),{models:p}=cl(),u=p.find(P=>{var B;return P.id===((B=Ga())==null?void 0:B.id)})||p[0],[m,g]=(0,rd.useState)(i||u.id),h=(0,rd.useRef)(null),[f,b]=(0,rd.useState)(!1),y=p.find(P=>P.id===m)||u,k=["image/*","application/pdf","text/plain","text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],w=y!=null&&y.allowedFileTypes?(C=y==null?void 0:y.allowedFileTypes)==null?void 0:C.join(","):k.join(","),N=w.length>0;return(0,rd.useEffect)(()=>{if(!s){let P=localStorage.getItem(uE);P&&p.find(B=>B.id===P)?(0,rd.startTransition)(()=>{g(P),l==null||l(P)}):(P&&localStorage.removeItem(uE),(0,rd.startTransition)(()=>{g(u.id),l==null||l(u.id)}))}},[s,l,u.id,p]),(0,mr.jsx)("div",{className:"relative",children:(0,mr.jsx)("div",{className:"rounded-lg",children:(0,mr.jsxs)(eS,{onSubmit:P=>{var v;let B=P.files.filter(S=>{var A;return(A=S.mediaType)==null?void 0:A.startsWith("image/")}),T=P.files.filter(S=>{var A;return!((A=S.mediaType)!=null&&A.startsWith("image/"))});o((v=P.text)==null?void 0:v.trim(),void 0,B,s?u.id:m,T)},accept:w,onError:P=>I2.toast.error(d(P.message)),className:"flex h-auto w-full flex-col rounded-lg",children:[(0,mr.jsx)(oM,{className:"p-0",children:(0,mr.jsx)(tM,{className:"gap-0.5 px-1 pb-0 pt-1",children:P=>(0,mr.jsx)(eM,{className:"max-w-sm text-xs",data:P})})}),(0,mr.jsx)(tS,{ref:h,value:e,onChange:P=>t(P.target.value),placeholder:d(c?"Describe the image you want to generate":s?"Ask to update content":"Ask anything..."),disabled:n,autoFocus:!0,className:"max-h-[200px] min-h-[60px] w-full p-2",rows:3}),(0,mr.jsxs)(oS,{className:"p-2",children:[(0,mr.jsxs)(rM,{children:[!s&&!c&&N&&(0,mr.jsxs)(nM,{children:[(0,mr.jsx)(aM,{disabled:n,className:"h-6 w-6",children:(0,mr.jsx)(Ql.Paperclip,{className:"!h-3 !w-3"})}),(0,mr.jsxs)(sM,{children:[(0,mr.jsx)(YN,{label:d("Add image"),accept:"image/*",className:"text-xs",onClick:P=>P.stopPropagation(),children:(0,mr.jsx)(Ql.ImageIcon,{className:"mr-2 size-4"})}),(0,mr.jsx)(YN,{label:d("Add file"),accept:"application/pdf,text/plain,text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",className:"text-xs",onClick:P=>P.stopPropagation(),children:(0,mr.jsx)(Ql.Paperclip,{className:"mr-2 size-4"})})]})]}),(0,mr.jsx)(gx,{textareaRef:h,onTranscriptionChange:t,disabled:n,"aria-label":d("Start voice input"),title:d("Start voice input")}),!s&&!c&&(0,mr.jsx)(N2,{selectedModel:m,onModelChange:P=>{g(P),l==null||l(P),localStorage.setItem(uE,P)},disabled:n}),(0,mr.jsx)(ux,{className:"hidden h-6 w-6",size:"sm",onClick:()=>b(!f),variant:f?"default":"ghost",children:(0,mr.jsx)(Ql.GlobeIcon,{className:"!h-3 !w-3"})})]}),n?(0,mr.jsxs)(E,{onClick:r,size:"xs",variant:"destructive",title:d("Stop generation"),children:[(0,mr.jsx)(Ql.Square,{className:"!h-3 !w-3"})," Stop"]}):(0,mr.jsx)(rS,{disabled:!e.trim()||a,className:"h-6 w-6",children:(0,mr.jsx)(Ql.ArrowUp,{className:"!h-3 !w-3 stroke-[3]"})})]})]})})})},nZ=rZ});var gE={};et(gE,{default:()=>sZ});var wS,B2,R2,nd,aZ,sZ,fE=x(()=>{"use strict";wS=require("lucide-react"),B2=require("react"),R2=require("react-i18next");J();ep();nd=require("react/jsx-runtime"),aZ=({selectedLang:e,isLoading:t,onSend:o})=>{let r=Ga(),{t:n}=(0,R2.useTranslation)(),[a,s]=(0,B2.useState)("");return(0,nd.jsxs)("div",{className:"overflow-hidden",children:[(0,nd.jsxs)("div",{className:"flex items-center justify-between border-b pr-1",children:[(0,nd.jsx)("input",{value:a,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&a.trim()&&(i.preventDefault(),o(a.trim(),void 0,[],r.id))},placeholder:n(e?"Ask to update content":"Ask anything..."),disabled:t,autoFocus:!0,className:"w-full resize-none rounded-none border-none p-2 text-xs text-black outline-none focus:outline-none focus:ring-0"}),(0,nd.jsx)(E,{onClick:()=>o(a.trim(),void 0,[],r.id),size:"xs",children:(0,nd.jsx)(wS.ArrowRight,{className:"!h-3 !w-3"})})]}),(0,nd.jsx)("div",{className:"max-h-24 overflow-y-auto",children:[...e?["Translate"]:[],"Make longer","Make shorter","Fix grammar"].map(i=>(0,nd.jsxs)("button",{"aria-label":i,onClick:()=>o(i,void 0,[],r.id),className:"h-6 w-full cursor-pointer overflow-hidden truncate px-2 py-1 text-left text-xs font-medium leading-none text-black hover:bg-gray-200 hover:text-blue-500",children:[(0,nd.jsx)(wS.Sparkles,{className:"mr-1 inline h-3 w-3"})," ",i]},i))})]})},sZ=aZ});var L2={};et(L2,{default:()=>pZ});function hE(e,t="",o=0,r=3){if(o>=r)return t?[t]:[];let n=[];for(let a of Object.keys(e!=null?e:{})){let s=t?`${t}.${a}`:a,i=e[a];Array.isArray(i)?n.push(s):i&&typeof i=="object"?n.push(...hE(i,s,o+1,r)):n.push(s)}return n}function cZ(e){let{global:t,...o}=e;return{global:hE(t!=null?t:{},"global"),page:hE(o,"")}}var D2,_2,Va,Ko,iZ,lZ,dZ,pZ,M2=x(()=>{"use strict";"use client";D2=require("jotai"),_2=require("lucide-react"),Va=require("react");Wr();Jb();Wr();er();Ke();xC();Nn();Ge();hx();yx();yS();sE();bS();St();iS();tp();uh();iE();ep();lE();h2();Ko=require("react/jsx-runtime"),iZ=(0,Va.lazy)(()=>Promise.resolve().then(()=>(Cx(),vx))),lZ=(0,Va.lazy)(()=>Promise.resolve().then(()=>(fE(),gE)));dZ=({t:e,fetch:t,input:o,messages:r,setInput:n,isLoading:a,setMessages:s,handleStop:i,setIsLoading:l,currentBlock:c,fallbackLang:d,setCurrentBlock:p,setAbortController:u,selectedModel:m,onModelChange:g,isFloatingPanel:h})=>{let f=q("flags.animation",!1),{models:b}=cl(),y=Kl(),k=b.find(_=>{var F;return _.id===((F=Ga())==null?void 0:F.id)})||b[0],w=m||k.id,N=_e(),[,I]=Pe(),C=Qu(),[P,B]=(0,Va.useState)(!1),[T,v]=(0,Va.useState)("page"),S=q("loading",!1),{savePageAsync:A}=to(),D=yf(),R=(0,D2.useAtomValue)(ls),H=la(),{data:M}=xt(),L=f2(),z=async(_,F,O,U,j,ce)=>{var W,ie,Y;if(!_||a)return;p(N);let pe=C({blockId:h?N==null?void 0:N._id:void 0}),ve={id:Date.now().toString(),role:"user",content:JM({language:d,userInput:F||_,currentHtml:pe}),userMessage:_},Ve={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};s(Ze=>[...Ze,ve,Ve]),l(!0);let ze=new AbortController;u(ze);let bt=U||w;(W=y.onAIEvent)==null||W.call(y,{type:"stream_start",model:bt,timestamp:Date.now()});try{let Ze={messages:[ve].map(ge=>({role:ge.role,content:ge.content})),model:U||w,context:y.context,designTokens:R,options:{animation:f,dataBindingPaths:cZ(H),pageType:(ie=M==null?void 0:M.pageType)!=null?ie:void 0}};O&&O.length>0&&(Ze.images=O.map(({url:ge})=>ge)),j&&j.length>0&&(Ze.attachments=j.map(({url:ge,mediaType:Rt,filename:sr})=>({url:ge,mediaType:Rt,filename:sr})));let te=h||!!(N!=null&&N._id),Qe=await t({body:{action:te?$.AI_EDIT_BLOCK:$.AI_EDIT_PAGE,data:Ze},streamResponse:!0,options:{signal:ze.signal}});if(!Qe.ok)throw new Error(e("Failed to get AI response"));let Z=(Y=Qe.body)==null?void 0:Y.getReader();if(!Z)throw new Error(e("Response body is not readable"));await L(Z,s),s(ge=>((0,Va.startTransition)(()=>{var ue,We,Zo,Ir;let Rt=ge.filter(pi=>pi.role==="assistant"&&!pi.isReasoning&&!pi.isTask),sr=((ue=Rt[Rt.length-1])==null?void 0:ue.content)||"",ir=Date.now();(We=y.onSuccess)==null||We.call(y,{content:sr,model:bt,timestamp:ir}),(Zo=y.onComplete)==null||Zo.call(y,{success:!0,content:sr,model:bt,timestamp:ir}),(Ir=y.onAIEvent)==null||Ir.call(y,{type:"completion",content:sr,model:bt,timestamp:ir})}),ge)),ce&&await A(!0)}catch(Ze){if(Ze.name!=="AbortError"){let te=od(Ze),Qe={id:(Date.now()+1).toString(),role:"assistant",content:te};s(Z=>[...Z.filter(Rt=>!(Rt.isReasoning&&Rt.isStreaming)),Qe]),(0,Va.startTransition)(()=>{var Rt,sr,ir;let Z=Ze instanceof Error?Ze.message:String(Ze),ge=Date.now();(Rt=y.onError)==null||Rt.call(y,{error:Z,model:bt,timestamp:ge}),(sr=y.onComplete)==null||sr.call(y,{success:!1,error:Z,model:bt,timestamp:ge}),(ir=y.onAIEvent)==null||ir.call(y,{type:"error",error:Z,model:bt,timestamp:ge})})}}finally{n(""),l(!1),p(null),u(null)}};return(0,Va.useEffect)(()=>{if(S)return;let{blocks:_}=D();if(_&&(_==null?void 0:_.filter(U=>U._type!=="GlobalBlock").length)>0)return;let F=mh({clean:!0});if(!F)return;let O=F==null?void 0:F.homePagePrompt;n(O||""),O&&setTimeout(()=>{var U;z(O,void 0,void 0,(U=Ga())==null?void 0:U.id,void 0,!0)},1e3)},[S]),h?(0,Ko.jsx)(Va.Suspense,{children:(0,Ko.jsx)(lZ,{selectedLang:"",isLoading:a,onSend:z})}):(0,Ko.jsxs)(Ko.Fragment,{children:[(0,Ko.jsxs)(nh,{className:"no-scrollbar !-mx-2 px-0",children:[(0,Ko.jsxs)(ah,{className:"no-scrollbar gap-4 px-0",children:[r.length===0&&(0,Ko.jsx)(Sm,{icon:(0,Ko.jsx)(_2.BrainCog,{size:30,className:"text-foreground/50"}),title:"Start a conversation",description:e("Start a conversation with the AI assistant to add/edit current page")}),r.map(_=>{var F,O,U;return _.role!=="system"&&(0,Ko.jsx)(Va.Fragment,{children:_.isReasoning?(0,Ko.jsxs)(sg,{isStreaming:_.isStreaming,defaultOpen:!0,className:"gap-0 space-y-0",children:[(0,Ko.jsx)(ig,{className:"text-xs [&_p]:text-muted-foreground"}),(0,Ko.jsx)(lg,{className:"p-0 text-xs",showLastLinesOnly:2,children:cg((F=_.content)!=null?F:"")})]}):_.isTask&&!_.isTaskCompleted?(0,Ko.jsx)(ph,{content:_.content,isLoading:_.isTaskLoading}):_.role==="assistant"?cg((O=_.content)!=null?O:"")?(0,Ko.jsx)(Yl,{from:_.role,children:(0,Ko.jsx)(Jl,{className:"!p-0",children:(0,Ko.jsx)(Pm,{className:"p-0 text-xs",children:cg((U=_.content)!=null?U:"")})})}):null:(0,Ko.jsx)(Yl,{from:_.role,children:(0,Ko.jsx)(Jl,{className:"!p-0",children:(0,Ko.jsx)("div",{className:"rounded-sm bg-accent p-2 text-xs",children:_.userMessage||_.content})})})},_.id)})]}),(0,Ko.jsx)(mS,{})]}),(0,Ko.jsxs)("div",{className:"border-border pb-2",children:[(0,Ko.jsx)(xS,{onRemove:()=>I([]),onManageContext:_=>{_&&v(_),B(!0)},isLoading:a}),(0,Ko.jsx)(oh,{open:P,onOpenChange:B,defaultTab:T}),(0,Ko.jsx)(Va.Suspense,{fallback:(0,Ko.jsx)("div",{children:"Loading..."}),children:(0,Ko.jsx)(iZ,{input:o,setInput:n,onSend:z,onStop:i,isLoading:a,selectedLang:"",currentBlock:N||c,disabled:(o==null?void 0:o.length)===0,selectedModel:w,onModelChange:g})})]})]})},pZ=dZ});var PS,ga,mZ,uZ,gZ,O2,F2=x(()=>{"use strict";"use client";PS=require("lucide-react");st();fS();ga=require("react/jsx-runtime"),mZ={edit_block:{active:"Updating section\u2026",done:"Updated section"},add_blocks:{active:"Adding new content\u2026",done:"Added new content"},remove_blocks:{active:"Removing content\u2026",done:"Removed content"},add_custom_block:{active:"Adding block\u2026",done:"Added block"},bind_prop:{active:"Connecting data\u2026",done:"Connected data"},read_block_html:{active:"Reviewing the page\u2026",done:"Reviewed the page"},get_partial_blocks:{active:"Checking shared sections\u2026",done:"Checked shared sections"}},uZ=e=>e.replace(/^tool-/,""),gZ=e=>{var s;let t=uZ(e.type),o=(s=e.input)!=null?s:{},r=e.state==="output-available"||e.state==="output-error",n=typeof o.task=="string"&&o.task.trim().length>0?o.task:null;if(n)return r?n:`${n}\u2026`;let a=mZ[t];return a?r?a.done:a.active:r?"Done":"Working\u2026"},O2=({part:e,className:t})=>{var l;let o=e.output,r=e.state==="output-error"||(o==null?void 0:o.ok)===!1,n=e.state==="output-available"&&!r,a=!n&&!r,s=gZ(e),i=(l=e.errorText)!=null?l:o==null?void 0:o.error;return(0,ga.jsx)("div",{className:G("is-assistant flex w-full max-w-[80%] flex-col gap-2",t),children:(0,ga.jsx)("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:(0,ga.jsx)("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-2.5",children:(0,ga.jsxs)("div",{className:"flex flex-1 items-center gap-2",children:[a&&(0,ga.jsx)(dh,{duration:1.5,children:s}),n&&(0,ga.jsxs)(ga.Fragment,{children:[(0,ga.jsx)(PS.Check,{className:"h-3 w-3 shrink-0 text-green-600"}),(0,ga.jsx)("div",{className:"text-xs text-muted-foreground/80",children:s})]}),r&&(0,ga.jsxs)(ga.Fragment,{children:[(0,ga.jsx)(PS.AlertCircle,{className:"h-3 w-3 shrink-0 text-destructive"}),(0,ga.jsxs)("div",{className:"flex flex-col",children:[(0,ga.jsx)("div",{className:"text-xs text-muted-foreground/80",children:s}),i&&(0,ga.jsx)("div",{className:"text-[11px] text-destructive/80",children:i})]})]})]})})})})}});var NS,TS,ES,yE,H2,fZ,hZ,U2,G2,$2,gh,V2=x(()=>{"use strict";NS=()=>{var t;let e=document.getElementById("canvas-iframe");return(t=e==null?void 0:e.contentDocument)!=null?t:null},TS=new Set,ES=null,yE=e=>{e.querySelectorAll("[data-stream-canvas]").forEach(t=>t.remove())},H2=e=>{e.scrollIntoView({behavior:"smooth",block:"end"})},fZ=(e,t)=>{let o=NS();if(!o)return null;yE(o);let r=null;if(e&&e!=="undefined"&&(r=o.querySelector(`[data-block-id="${e}"]`)),r||(r=o.querySelector('[data-block-id="canvas"]')),!r)return null;let n=o.createElement("div");if(n.setAttribute("data-stream-canvas","true"),t!==void 0&&t>=0&&r.children){let a=Math.min(t,r.children.length);a<r.children.length?r.insertBefore(n,r.children[a]):r.appendChild(n)}else r.appendChild(n);return n},hZ=e=>{var n;let t=NS();if(!t)return null;yE(t);let o=t.querySelector(`[data-block-id="${e}"]`);if(!o)return null;let r=t.createElement("div");return r.setAttribute("data-stream-canvas","true"),(n=o.parentNode)==null||n.insertBefore(r,o.nextSibling),o.style.display="none",TS.add(e),r},U2=e=>{if(ES!==e)return null;let t=NS(),o=t==null?void 0:t.querySelector("[data-stream-canvas]");return o&&o.isConnected?o:null},G2=(e,t,o,r="add")=>{var a;let n=(a=U2(r))!=null?a:fZ(t,o);n&&(ES=r,n.innerHTML=e,H2(n))},$2=(e,t,o="edit")=>{var n;let r=(n=U2(o))!=null?n:hZ(t);r&&(ES=o,r.innerHTML=e,H2(r))},gh=()=>{ES=null;let e=NS();if(!e){TS.clear();return}yE(e),TS.forEach(t=>{let o=e.querySelector(`[data-block-id="${t}"]`);o&&(o.style.display="")}),TS.clear()}});function bE(e,t="",o=0,r=3){if(o>=r)return t?[t]:[];let n=[];for(let a of Object.keys(e!=null?e:{})){let s=t?`${t}.${a}`:a,i=e[a];Array.isArray(i)?n.push(s):i&&typeof i=="object"?n.push(...bE(i,s,o+1,r)):n.push(s)}return n}function j2(e){let{global:t,...o}=e!=null?e:{};return{global:bE(t!=null?t:{},"global"),page:bE(o,"")}}var yZ,z2,bZ,W2,q2=x(()=>{"use strict";yZ=["content","text","title","label","heading"],z2=60,bZ=e=>{for(let t of yZ){let o=e[t];if(typeof o=="string"&&o.trim().length>0){let r=o.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();if(r)return r.length>z2?`${r.slice(0,z2)}\u2026`:r}}return""},W2=e=>{var n;if(!e||e.length===0)return"";let t=new Map;for(let a of e){let s=(n=a._parent)!=null?n:null,i=t.get(s);i?i.push(a):t.set(s,[a])}let o=[],r=(a,s)=>{var l;let i=(l=t.get(a))!=null?l:[];for(let c of i){let d=[c._id,c._type],p=c._name&&c._name!==c._type?c._name:"",u=bZ(c);p&&d.push(p),u&&d.push(`"${u}"`),c._type==="PartialBlock"&&c.partialBlockId&&d.push(`partial-id=${c.partialBlockId} (edit on its own page)`),o.push(`${" ".repeat(s)}${d.join(" | ")}`),r(c._id,s+1)}};return r(null,0),o.join(`
52
+ `)}});var Y2,J2,hh,Q2,fh,ta,xZ,vZ,K2,xE,vE,CE,X2,Z2=x(()=>{"use strict";Y2=require("@ai-sdk/react"),J2=require("@tanstack/react-query"),hh=require("ai"),Q2=require("jotai"),fh=require("lodash-es"),ta=require("react");Wr();Jn();pn();ko();cE();Jb();Ke();om();CS();Nn();ng();er();rt();Ne();Em();St();tp();V2();q2();xZ=5,vZ=120,K2=e=>e&&typeof e=="object"?e:{},xE=e=>typeof e=="string"&&e.length>0&&e!=="undefined"?e:void 0,vE=e=>typeof e=="number"?e:void 0,CE=e=>{if(!e)return null;try{let t=JSON.parse(e.message);if(t&&t.ok===!1&&t.error)return{message:t.error.message,code:t.error.code,status:t.error.status,metadata:t.error.metadata}}catch(t){}return{message:e.message}},X2=({onFinish:e,onError:t}={})=>{let o=le(),r=Nt("getAccessToken",fh.noop),n=Nt("beforeRequest",fh.noop),a=Nt("onLogout",fh.noop),s=Kl(),i=q("flags.animation",!1),l=(0,Q2.useAtomValue)(ls),c=la(),{data:d}=xt(),p=Qu(),u=(0,J2.useQueryClient)(),{savePageAsync:m}=to(),{addBlocks:g,setNewBlocks:h}=Ft(),f=bx(),b=_c(),y=vS(),k=(0,ta.useCallback)((_,F,O)=>{_.forEach(U=>{U._parent||(U._parent=F)}),g(_,F,O)},[g]),w=(0,ta.useRef)({model:"",isAutoMode:!1,buildData:()=>({})});w.current.buildData=()=>{var _;return{model:w.current.model||void 0,context:s.context,designTokens:l,pageHtml:p({}),pageOutline:W2(Od()),options:{animation:i,dataBindingPaths:j2(c),pageType:(_=d==null?void 0:d.pageType)!=null?_:void 0}}};let N=(0,ta.useRef)(0),I=(0,ta.useRef)(null),C=(0,ta.useRef)(!1),P=(0,ta.useRef)(null),B=(0,ta.useMemo)(()=>new hh.DefaultChatTransport({api:o,prepareSendMessagesRequest:async({messages:_,api:F})=>{await new Promise(j=>setTimeout(j,vZ));let O={messages:_,...w.current.buildData()};if(n)try{let j=await n({action:$.AI_EDIT_PAGE,data:O});j&&typeof j=="object"&&"data"in j&&(O=j.data)}catch(j){console.error("Error in beforeRequest hook:",j)}let U=await r();return{api:`${F}?action=${$.AI_EDIT_PAGE.toLowerCase()}`,headers:{Authorization:`Bearer ${U}`},body:{action:$.AI_EDIT_PAGE,data:O}}}}),[o]),T=(0,ta.useRef)(fh.noop),v=(0,ta.useCallback)(async(_,F)=>{var O;switch(_){case"edit_block":{let{blockId:U,html:j}=F;if(!U||!j)return{ok:!1,error:"edit_block requires blockId and html"};if(!Od().some(ve=>ve._id===U))return{ok:!1,error:`No block with bid "${U}" \u2014 check the page outline for valid bids.`};let pe=await $a(j);return await f(U,pe),gh(),{ok:!0,newBlockIds:pe.map(ve=>ve._id)}}case"add_blocks":{let{html:U}=F;if(!U)return{ok:!1,error:"add_blocks requires html"};let j=await $a(U);return j.length===0?{ok:!1,error:"html produced no blocks"}:(k(j,xE(F.parentId),vE(F.position)),gh(),{ok:!0,newBlockIds:j.map(ce=>ce._id)})}case"remove_blocks":{let U=(O=F.ids)!=null?O:[];return U.length===0?{ok:!1,error:"remove_blocks requires at least one id"}:(await b(U),{ok:!0})}case"add_custom_block":{let{type:U,props:j}=F;if(!U)return{ok:!1,error:"add_custom_block requires a type"};if(!Ct(U))return{ok:!1,error:`Unknown block type "${U}" \u2014 use a type from the custom block catalog.`};let ce={_id:Uo(),_type:U,...j!=null?j:{}};return k([ce],xE(F.parentId),vE(F.position)),{ok:!0,newBlockIds:[ce._id]}}case"bind_prop":{let{blockId:U,propName:j,bindingPath:ce}=F;return!U||!j||!ce?{ok:!1,error:"bind_prop requires blockId, propName and bindingPath"}:(y(U,j,ce),{ok:!0})}default:return{ok:!1,error:`Unknown client tool: ${_}`}}},[f,k,b,y]),S=(0,ta.useRef)(v);S.current=v;let A=(0,ta.useRef)(e);A.current=e;let D=(0,ta.useRef)(t);D.current=t;let R=(0,Y2.useChat)({transport:B,experimental_throttle:50,sendAutomaticallyWhen:_=>C.current||!(0,hh.lastAssistantMessageIsCompleteWithToolCalls)(_)||N.current>=xZ?!1:(N.current+=1,!0),onToolCall:async({toolCall:_})=>{if(C.current)return;let F=(async()=>{let O=_.toolName,U=K2(_.input),j;try{j=await S.current(O,U)}catch(ce){j={ok:!1,error:ce instanceof Error?ce.message:String(ce)}}C.current||T.current({tool:O,toolCallId:_.toolCallId,output:j})})();P.current=F;try{await F}finally{P.current===F&&(P.current=null)}},onFinish:({message:_,isAbort:F,isError:O})=>{var U;gh(),u.invalidateQueries({queryKey:[il]}),!F&&!O&&w.current.isAutoMode&&(w.current.isAutoMode=!1,m(!0).catch(fh.noop)),(U=A.current)==null||U.call(A,{message:_,isAbort:F,isError:O})},onError:_=>{var O;gh();let F=CE(_);(F==null?void 0:F.status)===401&&a("SESSION_EXPIRED"),(O=D.current)==null||O.call(D,_)}});T.current=({tool:_,toolCallId:F,output:O})=>R.addToolOutput({state:"output-available",tool:_,toolCallId:F,output:O});let{messages:H,status:M}=R;(0,ta.useEffect)(()=>{if(M!=="streaming"&&M!=="submitted")return;let _=H[H.length-1];if(!(!_||_.role!=="assistant"))for(let F=_.parts.length-1;F>=0;F--){let O=_.parts[F];if(!(0,hh.isToolUIPart)(O))continue;if(O.state!=="input-streaming")return;let U=K2(O.input);if(typeof U.html!="string")return;O.type==="tool-edit_block"&&U.blockId?$2(U.html,U.blockId,O.toolCallId):O.type==="tool-add_blocks"&&G2(U.html,xE(U.parentId),vE(U.position),O.toolCallId);return}},[H,M]);let L=(0,ta.useCallback)(async(_,{model:F,files:O,isAutoMode:U,selectedBlockId:j,displayText:ce})=>{w.current.model=F,w.current.isAutoMode=!!U,N.current=0,C.current=!1,I.current=Od();let pe=j||ce?{selectedBlockId:j,displayText:ce}:void 0;await R.sendMessage({text:_,...O&&O.length>0?{files:O}:{},...pe?{metadata:pe}:{}})},[R.sendMessage]),z=(0,ta.useCallback)(async()=>{C.current=!0,await R.stop();try{await P.current}catch(O){}gh();let _=I.current;I.current=null;let F=_!==null&&Od()!==_;return F&&h(_),{reverted:F}},[R.stop,h]);return{...R,sendPrompt:L,stop:z,isLoading:R.status==="submitted"||R.status==="streaming"}}});var oO={};et(oO,{default:()=>wZ});var eO,oa,tO,Vo,CZ,kZ,SZ,wZ,rO=x(()=>{"use strict";"use client";eO=require("lucide-react"),oa=require("react"),tO=require("sonner");pn();Ke();xC();Ge();hx();yx();yS();sE();iS();tp();uh();iE();ep();F2();Z2();Vo=require("react/jsx-runtime"),CZ=(0,oa.lazy)(()=>Promise.resolve().then(()=>(Cx(),vx))),kZ=e=>{let t=e.metadata;return t!=null&&t.displayText?t.displayText:e.parts.filter(o=>o.type==="text").map(o=>o.text).join(`
53
+ `)},SZ=({t:e,setIsLoading:t,selectedModel:o,onModelChange:r,onMessagesCountChange:n})=>{let{models:a}=cl(),s=Kl(),i=a.find(D=>{var R;return D.id===((R=Ga())==null?void 0:R.id)})||a[0],l=o||i.id,[c,d]=(0,oa.useState)(""),p=_e(),[,u]=Pe(),[m,g]=(0,oa.useState)(!1),[h,f]=(0,oa.useState)("page"),b=q("loading",!1),y=yf(),k=(0,oa.useRef)(l),{messages:w,setMessages:N,sendPrompt:I,stop:C,isLoading:P,error:B,clearError:T}=X2({onFinish:({message:D,isAbort:R,isError:H})=>{R||H||(0,oa.startTransition)(()=>{var _,F,O;let M=D.parts.filter(U=>U.type==="text").map(U=>U.text).join(`
54
+ `),L=Date.now(),z=k.current;(_=s.onSuccess)==null||_.call(s,{content:M,model:z,timestamp:L}),(F=s.onComplete)==null||F.call(s,{success:!0,content:M,model:z,timestamp:L}),(O=s.onAIEvent)==null||O.call(s,{type:"completion",content:M,model:z,timestamp:L})})},onError:D=>{(0,oa.startTransition)(()=>{var L,z,_;let R=D instanceof Error?D.message:String(D),H=Date.now(),M=k.current;(L=s.onError)==null||L.call(s,{error:R,model:M,timestamp:H}),(z=s.onComplete)==null||z.call(s,{success:!1,error:R,model:M,timestamp:H}),(_=s.onAIEvent)==null||_.call(s,{type:"error",error:R,model:M,timestamp:H})})}});(0,oa.useEffect)(()=>{t(P)},[P,t]),(0,oa.useEffect)(()=>{n==null||n(w.length)},[w.length,n]);let v=async(D,R,H,M,L,z)=>{var U;if(!D||P)return;T(),d("");let _=M||l;k.current=_,(U=s.onAIEvent)==null||U.call(s,{type:"stream_start",model:_,timestamp:Date.now()});let F=[...H!=null?H:[],...L!=null?L:[]],O=a.find(j=>j.id===_);F.length>0&&(O!=null&&O.allowedFileTypes)&&O.allowedFileTypes.length===0&&(F=[],tO.toast.warning(e("{{model}} can't read images or files. Attachments were not sent \u2014 switch models to use them.",{model:O.name}))),await I(R||D,{model:_,files:F,isAutoMode:z,selectedBlockId:p==null?void 0:p._id,displayText:R&&R!==D?D:void 0})},S=async()=>{let{reverted:D}=await C(),R=e(D?"Generation stopped. The page was restored to how it was before this prompt.":"Generation stopped.");N(H=>[...H,{id:Uo(),role:"assistant",parts:[{type:"text",text:R}]}])};(0,oa.useEffect)(()=>{if(b)return;let{blocks:D}=y();if(D&&(D==null?void 0:D.filter(M=>M._type!=="GlobalBlock").length)>0)return;let R=mh({clean:!0});if(!R)return;let H=R==null?void 0:R.homePagePrompt;d(H||""),H&&setTimeout(()=>{var M;v(H,void 0,void 0,(M=Ga())==null?void 0:M.id,void 0,!0)},1e3)},[b]);let A=CE(B);return(0,Vo.jsxs)(Vo.Fragment,{children:[(0,Vo.jsxs)(nh,{className:"no-scrollbar !-mx-2 px-0",children:[(0,Vo.jsxs)(ah,{className:"no-scrollbar gap-4 px-0",children:[w.length===0&&(0,Vo.jsx)(Sm,{icon:(0,Vo.jsx)(eO.BrainCog,{size:30,className:"text-foreground/50"}),title:"Start a conversation",description:e("Start a conversation with the AI assistant to add/edit current page")}),w.map(D=>(0,Vo.jsx)(oa.Fragment,{children:D.role==="user"?(0,Vo.jsx)(Yl,{from:"user",children:(0,Vo.jsx)(Jl,{className:"!p-0",children:(0,Vo.jsx)("div",{className:"rounded-sm bg-accent p-2 text-xs",children:kZ(D)})})}):D.parts.map((R,H)=>{var L,z,_;let M=`${D.id}-${H}`;if(R.type==="reasoning")return(0,Vo.jsxs)(sg,{isStreaming:R.state==="streaming",defaultOpen:!0,className:"gap-0 space-y-0",children:[(0,Vo.jsx)(ig,{className:"text-xs [&_p]:text-muted-foreground"}),(0,Vo.jsx)(lg,{className:"p-0 text-xs",showLastLinesOnly:2,children:cg((L=R.text)!=null?L:"")})]},M);if(R.type==="text"){let F=cg((z=R.text)!=null?z:"");return F?(0,Vo.jsx)(Yl,{from:"assistant",children:(0,Vo.jsx)(Jl,{className:"!p-0",children:(0,Vo.jsx)(Pm,{className:"p-0 text-xs",children:F})})},M):null}return(_=R.type)!=null&&_.startsWith("tool-")?(0,Vo.jsx)(O2,{part:R},M):null})},D.id)),A&&(0,Vo.jsx)(Yl,{from:"assistant",children:(0,Vo.jsx)(Jl,{className:"!p-0",children:(0,Vo.jsx)(Pm,{className:"p-0 text-xs",children:od(new Error(A.message))})})})]}),(0,Vo.jsx)(mS,{})]}),(0,Vo.jsxs)("div",{className:`border-border pb-2 ${P?"relative z-50":""}`,children:[(0,Vo.jsx)(xS,{onRemove:()=>u([]),onManageContext:D=>{D&&f(D),g(!0)},isLoading:P}),(0,Vo.jsx)(oh,{open:m,onOpenChange:g,defaultTab:h}),(0,Vo.jsx)(oa.Suspense,{fallback:(0,Vo.jsx)("div",{children:"Loading..."}),children:(0,Vo.jsx)(CZ,{input:c,setInput:d,onSend:v,onStop:S,isLoading:P,selectedLang:"",currentBlock:p,disabled:(c==null?void 0:c.length)===0,selectedModel:l,onModelChange:r})})]})]})},wZ=SZ});var nO,aO,sO=x(()=>{"use strict";nO=(e,t)=>{let o=e.filter(n=>n._parent===t),r=o.flatMap(n=>nO(e,n._id));return[...o,...r]},aO=(e,t)=>{let o=t.find(n=>n._id===e);if(!o)return[];let r=nO(t,e);return[o,...r]}});var rp,iO,kE,SE=x(()=>{"use strict";rp=require("lodash-es"),iO=require("react");ko();Ge();Ne();sO();kE=()=>{let e=_e(),[t]=Pt();return(0,iO.useCallback)((o="")=>{let r=e!=null&&e._id?aO(e._id,t):t;return r?(0,rp.compact)(r.map(n=>{var c;let a=Ct(n._type);if(!a)return null;let s=(c=a==null?void 0:a.i18nProps)!=null?c:[];if(s.length===0)return null;let i=o==="ALL"?Object.keys(n).filter(d=>s.find(p=>d.startsWith(p))):s.map(d=>o?`${d}-${o}`:d),l=(0,rp.pick)(n,["_id"]);return(0,rp.each)(i,d=>{l[d]=(0,rp.get)(n,d,(0,rp.get)(n,d.replace(`-${o}`,"")))}),l})):[]},[e,t])}});var lO,cO,Xl,dO,pO=x(()=>{"use strict";Ge();J();lO=require("lucide-react"),cO=require("react-i18next");ea();Xl=require("react/jsx-runtime"),dO=({onRemove:e,isLoading:t=!1})=>{let{t:o}=(0,cO.useTranslation)(),r=_e(),n=(r==null?void 0:r._type)||"Unknown",a=(r==null?void 0:r._name)||n;return(0,Xl.jsx)("div",{className:"relative mx-auto w-[95%]",children:(0,Xl.jsx)("div",{className:"relative transition-all duration-300 ease-out",style:{zIndex:3},children:(0,Xl.jsxs)("div",{className:"bg-surface flex items-center justify-between rounded-t-lg border border-b-0 border-border px-3 py-1",children:[(0,Xl.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,Xl.jsx)("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-primary text-[10px] font-semibold text-primary-foreground",children:"@"}),(0,Xl.jsx)("span",{className:"truncate text-[11px] text-foreground",children:r?a:o("Entire Page")})]}),r&&(0,Xl.jsx)(Ye,{content:o("Remove block from context"),side:"right",children:(0,Xl.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:e,disabled:t,title:"Remove block from context",children:(0,Xl.jsx)(lO.X,{className:"!h-3 !w-3"})})})]})})})}});var gO={};et(gO,{default:()=>TZ});var mO,uO,np,PZ,TZ,fO=x(()=>{"use strict";"use client";mO=require("lucide-react"),uO=require("react-i18next");zs();J();np=require("react/jsx-runtime"),PZ=({selectedLang:e,isLoading:t,selectedBlock:o,onClick:r})=>{let{t:n}=(0,uO.useTranslation)();return(0,np.jsx)("div",{className:"flex flex-col gap-2",children:(0,np.jsx)("div",{className:`flex flex-col gap-2 ${t?"pointer-events-none opacity-50":""}`,children:o?(0,np.jsx)(E,{variant:"outline",className:"h-auto justify-start px-3 py-2",size:"sm",onClick:()=>r("TRANSLATE"),children:(0,np.jsxs)("div",{className:"flex flex-col",children:[(0,np.jsx)("p",{className:"text-left text-xs font-thin italic",children:n("Quick Action:")}),(0,np.jsxs)("span",{className:"flex items-center gap-x-2 text-xs font-light",children:[n("Translate Content")," ",n("to")," ",Jt[e]," ",(0,np.jsx)(mO.ArrowRight,{className:"!h-3 !w-3"})]})]})}):null})})},TZ=PZ});var bO={};et(bO,{default:()=>BZ});var hO,Ea,yO,Yo,NZ,EZ,AZ,IZ,BZ,xO=x(()=>{"use strict";"use client";hO=require("lucide-react"),Ea=require("react"),yO=require("react-i18next");SE();Ge();Ln();hx();yx();yS();bS();St();tp();uh();ep();lE();pO();Yo=require("react/jsx-runtime"),NZ=(0,Ea.lazy)(()=>Promise.resolve().then(()=>(fO(),gO))),EZ=(0,Ea.lazy)(()=>Promise.resolve().then(()=>(Cx(),vx))),AZ=(0,Ea.lazy)(()=>Promise.resolve().then(()=>(fE(),gE))),IZ=({fetch:e,input:t,messages:o,setInput:r,isLoading:n,handleStop:a,setMessages:s,setIsLoading:i,selectedLang:l,currentBlock:c,fallbackLang:d,setAbortController:p,setCurrentBlock:u,selectedModel:m,onModelChange:g,isFloatingPanel:h=!1})=>{let{t:f}=(0,yO.useTranslation)(),{models:b}=cl(),y=Kl(),k=b.find(S=>{var A;return S.id===((A=Ga())==null?void 0:A.id)})||b[0],w=m||k.id,N=(0,Ea.useRef)(null),I=_e(),[,C]=Pe(),P=kE(),B=LC(),T=()=>{var S;(S=N.current)==null||S.scrollIntoView({behavior:"smooth"})};(0,Ea.useEffect)(()=>{T()},[o,n]);let v=async(S,A,D,R)=>{var F,O;I&&u(I);let H=(S==null?void 0:S.toLowerCase())==="translate",M={id:Date.now().toString(),role:"user",content:QM({fallbackLang:d,userInput:A||S,language:l,blocks:H?P():P(l)}),userMessage:A||S||f("Translate the content")},L={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};i(!0);let z=new AbortController;p(z),s(U=>[...U,M,L]),i(!0);let _=R||w;(F=y.onAIEvent)==null||F.call(y,{type:"stream_start",model:_,timestamp:Date.now()});try{let U={messages:[M],initiator:H?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:_,context:y.context},j=await e({body:{action:$.AI_EDIT_LANG_PAGE,data:U},streamResponse:!0,options:{signal:z.signal}});if(!j.ok)throw new Error(f("Failed to get AI response"));let ce=(O=j.body)==null?void 0:O.getReader(),pe=new TextDecoder,ve="";if(!ce)throw new Error(f("Response body is not readable"));for(;;){let{done:ze,value:bt}=await ce.read();if(ze)break;let W=pe.decode(bt,{stream:!0});ve+=W}let Ve=jM(ve);B(Ve),s(ze=>[...ze.filter(W=>W.id!==L.id),{id:Date.now().toString(),role:"assistant",content:f("Content updated successfully.")}]),(0,Ea.startTransition)(()=>{var bt,W,ie;let ze=Date.now();(bt=y.onSuccess)==null||bt.call(y,{content:ve,model:_,timestamp:ze}),(W=y.onComplete)==null||W.call(y,{success:!0,content:ve,model:_,timestamp:ze}),(ie=y.onAIEvent)==null||ie.call(y,{type:"completion",content:ve,model:_,timestamp:ze})})}catch(U){if(U.name!=="AbortError"){let j=od(U),ce={id:(Date.now()+1).toString(),role:"assistant",content:j};s(pe=>[...pe.filter(Ve=>!(Ve.isReasoning&&Ve.isStreaming)),ce]),(0,Ea.startTransition)(()=>{var Ve,ze,bt;let pe=U instanceof Error?U.message:String(U),ve=Date.now();(Ve=y.onError)==null||Ve.call(y,{error:pe,model:_,timestamp:ve}),(ze=y.onComplete)==null||ze.call(y,{success:!1,error:pe,model:_,timestamp:ve}),(bt=y.onAIEvent)==null||bt.call(y,{type:"error",error:pe,model:_,timestamp:ve})})}}finally{i(!1),r(""),u(null)}};return h?(0,Yo.jsx)(Ea.Suspense,{children:(0,Yo.jsx)(AZ,{selectedLang:l,isLoading:n,onSend:v})}):(0,Yo.jsxs)(Yo.Fragment,{children:[(0,Yo.jsx)("div",{className:"py-2",children:(0,Yo.jsx)(Ea.Suspense,{fallback:(0,Yo.jsx)("div",{children:f("Loading...")}),children:(0,Yo.jsx)(NZ,{isLoading:n,selectedBlock:I,selectedLang:l,onClick:v})})}),(0,Yo.jsx)(nh,{className:"no-scrollbar !-mx-2 px-0",children:(0,Yo.jsxs)(ah,{className:"gap-4 px-0",children:[o.length===0&&(0,Yo.jsx)(Sm,{icon:(0,Yo.jsx)(hO.BrainCog,{size:30,className:"text-foreground/50"}),title:f("Start a conversation with the AI assistant to translate/edit your content"),description:f("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),o.map(S=>S.role!=="system"&&(0,Yo.jsx)(Ea.Fragment,{children:S.isReasoning?(0,Yo.jsxs)(sg,{isStreaming:S.isStreaming,defaultOpen:!0,className:"gap-0 space-y-0",children:[(0,Yo.jsx)(ig,{className:"text-xs [&_p]:text-muted-foreground"}),(0,Yo.jsx)(lg,{className:"p-0 text-xs",showLastLinesOnly:2,children:S.content})]}):S.isTask&&!S.isTaskCompleted?(0,Yo.jsx)(ph,{content:S.content,isLoading:S.isTaskLoading}):(0,Yo.jsx)(Yl,{from:S.role,children:(0,Yo.jsx)(Jl,{className:"!p-0",children:S.role==="assistant"?(0,Yo.jsx)(Pm,{className:"p-0 text-xs",children:S.content}):(0,Yo.jsx)("div",{className:"rounded-sm bg-accent p-2 text-xs",children:S.userMessage||S.content})})})},S.id))]})}),(0,Yo.jsxs)("div",{className:"border-border pb-2",children:[(0,Yo.jsx)(dO,{onRemove:()=>C([]),isLoading:n}),(0,Yo.jsx)(Ea.Suspense,{fallback:(0,Yo.jsx)("div",{children:f("Loading...")}),children:(0,Yo.jsx)(EZ,{input:t,setInput:r,onSend:v,onStop:a,isLoading:n,selectedLang:l,currentBlock:I||c,disabled:(t==null?void 0:t.length)===0,selectedModel:w,onModelChange:g})})]})]})},BZ=IZ});var CO={};et(CO,{default:()=>_Z});var yh,za,vO,Je,RZ,DZ,_Z,kO=x(()=>{"use strict";"use client";yh=require("lucide-react"),za=require("react"),vO=require("react-i18next");hx();yx();bS();St();J();No();Oo();Rs();Gs();rt();tp();uh();ep();Je=require("react/jsx-runtime"),RZ=(0,za.lazy)(()=>Promise.resolve().then(()=>(Cx(),vx))),DZ=({fetch:e,input:t,messages:o,setInput:r,isLoading:n,handleStop:a,setMessages:s,setIsLoading:i,selectedLang:l,setAbortController:c,setCurrentBlock:d,selectedModel:p,onModelChange:u,onImageGenerate:m=h=>{},isGenerateImagePanel:g=!1})=>{let{t:h}=(0,vO.useTranslation)(),{models:f}=cl(),b=Kl(),y=f.find(S=>{var A;return S.id===((A=Ga())==null?void 0:A.id)})||f[0],k=p||y.id,w=(0,za.useRef)(null),[N,I]=(0,za.useState)("16:9"),[C,P]=(0,za.useState)(80),B=()=>{var S;(S=w.current)==null||S.scrollIntoView({behavior:"smooth"})};(0,za.useEffect)(()=>{B()},[o,n]);let T=Hc("AI_GENERATE_IMAGE","google/gemini-2.5-flash-image"),v=async(S,A,D,R)=>{var z,_;let H=[...o].reverse().find(F=>{var O;return F.role==="assistant"&&((O=F.content)==null?void 0:O.startsWith("data:image"))}),M={id:Date.now().toString(),role:"user",content:A||S||h("Generate image"),userMessage:A||S||h("Generate image")};i(!0);let L=new AbortController;c(L),s(F=>[...F,M]),(z=b.onAIEvent)==null||z.call(b,{type:"stream_start",model:T,timestamp:Date.now()});try{let F={messages:[M],initiator:"GENERATE_IMAGE",model:T,context:b.context,image:{lastImage:H==null?void 0:H.content,aspectRatio:N,quality:C}},O=await e({body:{action:$.AI_GENERATE_IMAGE,data:F},streamResponse:!0,options:{signal:L.signal}});if(!O.ok)throw new Error(h("Failed to get AI response"));let U=(_=O.body)==null?void 0:_.getReader(),j=new TextDecoder,ce="";if(!U)throw new Error(h("Response body is not readable"));for(;;){let{done:pe,value:ve}=await U.read();if(pe)break;let Ve=j.decode(ve,{stream:!0});ce+=Ve}s(pe=>[...pe,{id:(Date.now()+2).toString(),role:"assistant",content:ce}]),m&&m(ce),(0,za.startTransition)(()=>{var ve,Ve,ze;let pe=Date.now();(ve=b.onSuccess)==null||ve.call(b,{content:ce,model:T,timestamp:pe}),(Ve=b.onComplete)==null||Ve.call(b,{success:!0,content:ce,model:T,timestamp:pe}),(ze=b.onAIEvent)==null||ze.call(b,{type:"completion",content:ce,model:T,timestamp:pe})})}catch(F){if(F.name!=="AbortError"){let O=od(F),U={id:(Date.now()+1).toString(),role:"assistant",content:O};s(j=>[...j.filter(pe=>!(pe.isReasoning&&pe.isStreaming)),U]),(0,za.startTransition)(()=>{var pe,ve,Ve;let j=F instanceof Error?F.message:String(F),ce=Date.now();(pe=b.onError)==null||pe.call(b,{error:j,model:T,timestamp:ce}),(ve=b.onComplete)==null||ve.call(b,{success:!1,error:j,model:T,timestamp:ce}),(Ve=b.onAIEvent)==null||Ve.call(b,{type:"error",error:j,model:T,timestamp:ce})})}}finally{i(!1),r(""),d(null)}};return(0,Je.jsxs)("div",{className:"relative flex h-full w-full flex-col",children:[o.length===0?(0,Je.jsx)("div",{className:"flex h-full items-center justify-center p-3",children:(0,Je.jsx)(Sm,{icon:(0,Je.jsx)(yh.BrainCog,{size:24,className:"text-foreground/50"}),title:h("Generate images with AI"),description:h("Describe the image you want to generate.")})}):(0,Je.jsxs)("div",{className:"flex-1 space-y-2 overflow-y-auto py-2",children:[o.map(S=>S.role!=="system"&&(0,Je.jsx)(za.Fragment,{children:S.isTask&&!S.isTaskCompleted?(0,Je.jsx)(ph,{content:S.content,isLoading:S.isTaskLoading}):(0,Je.jsx)(Yl,{from:S.role,children:(0,Je.jsx)(Jl,{className:"!p-0",children:S.role==="assistant"?qM(S.content)?(0,Je.jsxs)("div",{className:"group relative",children:[(0,Je.jsx)("img",{src:S.content,alt:"AI generated image",className:"max-h-32 w-full cursor-pointer rounded object-contain object-left hover:opacity-70",onClick:()=>m(S.content)}),(0,Je.jsxs)(E,{variant:"default",size:"xs",onClick:()=>m(S.content),className:"absolute bottom-1 left-1 font-light opacity-0 group-hover:opacity-100",children:[(0,Je.jsx)(yh.ArrowRight,{className:"h-3 w-3"})," ",h("View")]})]}):(0,Je.jsx)("div",{className:"rounded-sm bg-destructive/10 px-2 py-1 text-xs text-destructive/80",children:od(S.content).includes("--")?h("Image generation failed. Try again"):od(S.content)}):(0,Je.jsx)("div",{className:"rounded-sm bg-accent px-2 py-1 text-xs",children:S.userMessage||S.content})})})},S.id)),n&&(0,Je.jsx)("div",{className:"mt-2 flex h-32 w-32 animate-pulse items-center justify-center gap-1 rounded-md bg-primary/10 p-2 text-xs text-primary",children:(0,Je.jsx)(wt,{className:"h-3 w-3 text-primary"})}),(0,Je.jsx)("div",{ref:w})]}),(0,Je.jsxs)("div",{className:"flex-shrink-0 space-y-0",children:[(0,Je.jsxs)("div",{className:"mx-auto flex w-[96%] items-center justify-between gap-x-1 rounded-t-md border border-b-0 bg-accent/50 pl-2 text-center text-[11px] font-light text-foreground dark:bg-accent",children:[(0,Je.jsxs)("div",{children:[(0,Je.jsxs)("span",{children:[h("Aspect ratio"),": ",N]})," ",(0,Je.jsx)("span",{className:"px-2 text-muted-foreground",children:"|"})," ",(0,Je.jsxs)("span",{children:[h("Quality"),": ",C>80?h("High"):C>60?h("Medium"):h("Low")]})," "]}),(0,Je.jsxs)(en,{children:[(0,Je.jsx)($r,{asChild:!0,children:(0,Je.jsx)(E,{size:"icon-xs",variant:"ghost",children:(0,Je.jsx)(yh.Settings,{className:"!h-3 !w-3"})})}),(0,Je.jsxs)(Vr,{className:"w-44",align:"start",side:"right",children:[(0,Je.jsx)("div",{className:"text-xs font-medium",children:h("Image configuration")}),(0,Je.jsxs)("div",{children:[(0,Je.jsx)(Q,{children:h("Aspect ratio")}),(0,Je.jsxs)(So,{value:N,onValueChange:S=>I(S),children:[(0,Je.jsx)(ho,{children:(0,Je.jsx)(Do,{placeholder:h("Ratio")})}),(0,Je.jsxs)(yo,{children:[(0,Je.jsx)(gt,{value:"1:1",children:"1:1"}),(0,Je.jsx)(gt,{value:"3:4",children:"3:4"}),(0,Je.jsx)(gt,{value:"4:3",children:"4:3"}),(0,Je.jsx)(gt,{value:"9:16",children:"9:16"}),(0,Je.jsx)(gt,{value:"16:9",children:"16:9"})]})]})]}),(0,Je.jsxs)("div",{children:[(0,Je.jsx)(Q,{children:h("Quality")}),(0,Je.jsxs)(So,{value:String(C),onValueChange:S=>P(Number(S)),children:[(0,Je.jsx)(ho,{children:(0,Je.jsx)(Do,{placeholder:h("Quality")})}),(0,Je.jsxs)(yo,{children:[(0,Je.jsx)(gt,{value:"60",children:h("Low")}),(0,Je.jsx)(gt,{value:"80",children:h("Medium")}),(0,Je.jsx)(gt,{value:"100",children:h("High")})]})]})]})]})]})]}),(0,Je.jsx)(za.Suspense,{fallback:(0,Je.jsx)("div",{className:"w-full animate-pulse rounded-md bg-accent"}),children:(0,Je.jsx)(RZ,{input:t,setInput:r,onSend:v,onStop:a,isLoading:n,selectedLang:l,currentBlock:void 0,disabled:(t==null?void 0:t.length)===0,selectedModel:k,onModelChange:u,isGenerateImagePanel:g})})]})]})},_Z=DZ});var IS={};et(IS,{AiPanelContent:()=>AS,default:()=>UZ});var SO,wO,tr,PO,TO,Lr,LZ,MZ,OZ,FZ,HZ,AS,UZ,kx=x(()=>{"use strict";"use client";SO=require("lodash-es"),wO=require("lucide-react"),tr=require("react"),PO=require("react-i18next"),TO=require("sonner");Ke();Tt();dx();Kt();cs();J();iS();yM();kM();tp();ep();Lr=require("react/jsx-runtime"),LZ=(0,tr.lazy)(()=>Promise.resolve().then(()=>(M2(),L2))),MZ=(0,tr.lazy)(()=>Promise.resolve().then(()=>(rO(),oO))),OZ=(0,tr.lazy)(()=>Promise.resolve().then(()=>(xO(),bO))),FZ=(0,tr.lazy)(()=>Promise.resolve().then(()=>(kO(),CO))),HZ=({type:e="default",updateLoadingState:t,onImageGenerate:o})=>{let{t:r}=(0,PO.useTranslation)(),[n,a]=(0,tr.useState)(""),[s,i]=(0,tr.useState)([]),[l,c]=(0,tr.useState)(!1),[d,p]=(0,tr.useState)(null),[u,m]=(0,tr.useState)(null),[g,h]=(0,tr.useState)(Ga().id),[f,b]=(0,tr.useState)(!1),[y,k]=(0,tr.useState)(!1),{selectedLang:w,fallbackLang:N}=fe(),I=q("flags.aiCredits",!0),C=Ls(),[P]=Go(),B=P.get("page"),[T,v]=(0,tr.useState)(0),[S,A]=(0,tr.useState)(0),D=(s==null?void 0:s.filter(j=>j.role==="user").length)>=4,R=(s==null?void 0:s.filter(j=>j.role==="user").length)>=10,H=e==="floating",M=e==="generate-image",L=!H&&!M&&!w;(0,tr.useEffect)(()=>{v(j=>j+1),A(0)},[B]);let z=!H&&!w&&(e==="default"||M),_=z?M?"imageGeneration":"defaultLang":null;(0,tr.useEffect)(()=>{if(_)if(_==="defaultLang")ZN(_),(0,tr.startTransition)(()=>i([]));else{let j=hM(_);j.length>0&&(0,tr.startTransition)(()=>i(j))}},[_,B]),(0,tr.useEffect)(()=>{if(_&&s.length>0){let j=s.filter(ce=>!ce.isStreaming).slice(-10);XN(_,j)}},[s,_]),(0,tr.useEffect)(()=>{z||(0,tr.startTransition)(()=>i([]))},[w,B,z]);let F=()=>{i([]),a(""),m(null),p(null),c(!1),L&&(v(j=>j+1),A(0)),_&&ZN(_)},O=()=>{d&&(d.abort(),p(null)),c(!1),a(""),m(null),i(j=>{let ce=j[j.length-1];return ce&&ce.role==="assistant"&&ce.isReasoning&&ce.isStreaming?j.slice(0,-1):j}),TO.toast.info(r("Generation stopped"))};(0,tr.useEffect)(()=>{t==null||t(l)},[l,t]);let U={t:r,fetch:C,input:n,messages:s,setInput:a,isLoading:l,handleStop:O,handleReset:F,setMessages:i,setIsLoading:c,currentBlock:u,fallbackLang:N,abortController:d,isFloatingPanel:H,setCurrentBlock:m,setAbortController:p,forceNewConversation:R,isGenerateImagePanel:M,suggestNewConversation:D,selectedModel:g,onModelChange:h};return(0,Lr.jsxs)(Lr.Fragment,{children:[l&&!M&&(0,Lr.jsx)("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),(0,Lr.jsxs)("div",{className:"flex h-full w-full flex-col",children:[!H&&(0,Lr.jsxs)(Lr.Fragment,{children:[(0,Lr.jsxs)("div",{className:M?"-mx-1 flex h-max items-center justify-between border-b bg-accent/10 px-2 pb-1":"relative h-0 max-h-0",children:[M&&(0,Lr.jsx)("div",{className:"text-xs font-medium text-foreground",children:r("Generate image with AI")}),(0,Lr.jsxs)("div",{className:M?"space-x-2":"absolute -top-8 right-0 flex items-center justify-between gap-2",children:[I?(0,Lr.jsx)(cS,{isExpanded:y,onToggle:k,compactOnly:!0}):null,(0,Lr.jsx)(E,{variant:"outline",size:"icon-xs",className:`h-5 w-5 ${(L?S>0:(s==null?void 0:s.length)>0)?"":"pointer-events-none w-0 overflow-hidden opacity-0"}`,onClick:F,disabled:l,children:(0,Lr.jsx)(wO.Plus,{className:"!h-3 !w-3"})})]})]}),y&&I&&(0,Lr.jsx)(cS,{}),(0,Lr.jsx)(oh,{open:f,onOpenChange:b})]}),(0,Lr.jsx)(tr.Suspense,{fallback:(0,Lr.jsx)("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:M?(0,Lr.jsx)(FZ,{...U,selectedLang:"",onImageGenerate:o}):w?(0,Lr.jsx)(OZ,{...U,selectedLang:w}):L?(0,Lr.jsx)(MZ,{t:r,isLoading:l,setIsLoading:c,selectedModel:g,onModelChange:h,onMessagesCountChange:A},T):(0,Lr.jsx)(LZ,{...U})})]})]})},AS=({type:e,models:t,onAIEvent:o,onSuccess:r,onError:n,onComplete:a,context:s,updateLoadingState:i,onImageGenerate:l,...c})=>{var m;let{data:d}=Cm(),p=(m=s!=null?s:d)!=null?m:{},u={models:t,onAIEvent:o,onSuccess:r,onError:n,onComplete:a,context:p,...c};return(0,Lr.jsx)(wM,{config:u,children:(0,Lr.jsx)(HZ,{type:e,updateLoadingState:i||SO.noop,onImageGenerate:l})})},UZ=AS});var BS,bh,GZ,$Z,NO,EO=x(()=>{"use strict";"use client";BS=require("react");Xf();bh=require("react/jsx-runtime"),GZ=(0,BS.lazy)(()=>Promise.resolve().then(()=>(kx(),IS))),$Z=({isOpen:e,isLoading:t,updateLoadingState:o})=>e?(0,bh.jsx)(vm,{className:`absolute top-6 overflow-hidden rounded-b border-2 border-t-0 border-blue-500 ${e?"":"hidden"}`,value:e?"ai":"",type:"single",collapsible:!0,children:(0,bh.jsx)(Xd,{value:"ai",className:"border-none",children:(0,bh.jsx)(Zd,{id:"canvas-block-floating-ai-prompt-input",className:`z-[1001] w-full rounded-b bg-white ${t?"sr-only h-0 w-0 overflow-hidden opacity-0":"h-auto pb-0"}`,onClick:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),children:(0,bh.jsx)(BS.Suspense,{fallback:null,children:(0,bh.jsx)(GZ,{type:"floating",onSuccess:console.log,onError:console.log,onComplete:console.log,updateLoadingState:o})})})})}):null,NO=$Z});var AO,BO,IO,RO=x(()=>{"use strict";AO=require("@radix-ui/react-icons");Qn();Pa();BO=require("react/jsx-runtime"),IO=({blockId:e,className:t})=>(0,BO.jsx)(AO.GearIcon,{className:t,onClick:()=>{e&&Gt.publish(dt.GOTO_BLOCK_SETTINGS,e)}})});function RS(e){if(e.getAttribute("data-block-id")==="canvas")return null;if(e.getAttribute("data-block-id")||e.getAttribute("data-block-parent"))return e;let t=e.closest("[data-block-id]");return(t==null?void 0:t.getAttribute("data-block-id"))==="canvas"?null:t}var DO,_O,Sx,OO,VZ,zZ,WZ,LO,jZ,qZ,KZ,YZ,JZ,MO,xh,DS=x(()=>{"use strict";DO=require("@react-hookz/web"),_O=require("lodash-es"),Sx=require("react");Qn();Pa();Kd();Zu();fn();OO=require("react/jsx-runtime");VZ=["Heading","Paragraph","Text","Link","Span","Button"],zZ=e=>{var t;return(e==null?void 0:e.getAttribute("data-block-type"))==="RichText"||((t=e==null?void 0:e.parentElement)==null?void 0:t.getAttribute("data-block-type"))==="RichText"},WZ=()=>{let{editingBlockId:e}=us();return(0,Sx.useCallback)(t=>{if(e||t.button!==0)return;let o=RS(t.target);o&&o!=null&&o.getAttribute("data-block-id")&&(o==null||o.getAttribute("data-block-id"))},[e])},LO=e=>e?(0,_O.some)(e.children,t=>{let o=t;return o.hasAttribute("data-block-id")||LO(o)}):!1,jZ=(e,t)=>{if(t&&e)return!1;if(zZ(e))return!0;let o=t||(e==null?void 0:e.getAttribute("data-block-type"));return o?VZ.includes(o):!1},qZ=()=>{let{editingBlockId:e,setEditingBlockId:t,setEditingItemIndex:o}=us();return(0,Sx.useCallback)(r=>{var i;if(r==null||r.preventDefault(),r==null||r.stopPropagation(),e)return;let n=RS(r.target);if(!n||!jZ(n)||LO(n))return;let a=n.getAttribute("data-block-id");if(!a)return;let s=n.closest('[data-block-type="Repeater"]');s?(i=s==null?void 0:s.childNodes)==null||i.forEach((l,c)=>{l.contains(n)&&o(c)}):o(-1),t(a)},[e,t,o])},KZ=()=>{let{editingBlockId:e}=us(),{clearHighlight:t}=pa(),[,o]=ao();return(0,Sx.useCallback)(r=>{if(e)return;r.stopPropagation();let n=RS(r.target);if(!n){t(),o([]),Gt.publish(dt.CANVAS_BLOCK_SELECTED,[]);return}if(!(r.detail>=2)){if(n!=null&&n.getAttribute("data-block-id")&&(n==null?void 0:n.getAttribute("data-block-id"))==="container"){Gt.publish(dt.CLEAR_CANVAS_SELECTION);return}if(n!=null&&n.getAttribute("data-block-parent")){let a=n.getAttribute("data-style-prop"),s=n.getAttribute("data-style-id"),i=n.getAttribute("data-block-parent");Gt.publish(dt.CANVAS_BLOCK_STYLE_SELECTED,{blockId:i,styleId:s,styleProp:a})}else if(n!=null&&n.getAttribute("data-block-id")){let a=n.getAttribute("data-block-id");Gt.publish(dt.CANVAS_BLOCK_SELECTED,a==="canvas"?[]:[a])}t()}},[e,t,o])},YZ=()=>{let{editingBlockId:e}=us(),{highlightBlock:t}=pa();return(0,DO.useThrottledCallback)(o=>{if(e)return;let r=RS(o.target);if(r){if(r.getAttribute("data-highlighted")==="true")return;t(r)}},[e,t],150)},JZ=()=>{let{clearHighlight:e}=pa();return(0,Sx.useCallback)(()=>e(),[e])},MO=({children:e})=>{let t=qZ(),o=WZ(),r=KZ(),n=YZ(),a=JZ();return(0,OO.jsx)("div",{"data-block-id":"canvas",id:"canvas",onMouseDown:o,onClick:r,onDoubleClick:t,onMouseMove:n,onMouseLeave:a,className:"relative h-full max-w-full",children:e})},xh=(e,t)=>e.querySelector(`[data-block-id="${t}"]`)});var vh,_S,ad,wE,ap,an,qr,FO,QZ,HO,XZ,ZZ,eee,UO,GO=x(()=>{"use strict";vh=require("@floating-ui/dom"),_S=require("@floating-ui/react-dom"),ad=require("@radix-ui/react-icons"),wE=require("@react-hookz/web"),ap=require("lodash-es"),an=require("react");kN();pL();al();DL();Qf();Ha();Ke();Lk();GN();Zu();mn();om();Ge();fn();Oo();tn();EO();RO();DS();qr=require("react/jsx-runtime"),FO="AI_OVERLAY_BLOCK_ID",QZ=(e,t)=>{if(HO(e),!xh(e,t))return;let r=e.createElement("div");r.setAttribute("data-block-id",FO),r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.width=e.body.clientWidth+"px",r.style.height=e.body.scrollHeight+"px",r.style.backgroundColor="rgba(0, 0, 0, 0.05)",r.style.zIndex="9999",e.body.appendChild(r)},HO=e=>{let t=xh(e,FO);t&&(t.style.display="none",t.remove())},XZ=()=>{let e=_e(),{document:t}=Un(),{onDragStart:o,onDragEnd:r,isDragging:n}=nl(),[a,s]=(0,an.useState)(null),i=Zn(),l=(0,an.useMemo)(()=>{if(!(e!=null&&e._id)||e.type==="Multiple"||!t)return[];let p=xh(t,e._id);return p?[p]:[]},[e,t]);(0,an.useEffect)(()=>{var u;let p=l[0];if(p){let{top:m}=p.getBoundingClientRect();m>=0&&m<=window.innerHeight||(u=t==null?void 0:t.defaultView)==null||u.scrollTo({top:p.offsetTop,behavior:"smooth"})}},[l,t]);let c=(0,an.useCallback)(p=>{s(l==null?void 0:l[0]),o(p,e,!1)},[l,o,e]),d=(0,an.useCallback)(()=>{s(null),r()},[r]);return{selectedBlock:e,selectedElements:l,dragging:a,isDragging:n,isDragAndDropEnabled:i,handleDragStart:c,handleDragEnd:d}},ZZ=({block:e,isDragging:t,selectedBlockElement:o})=>{let r=_c(),n=qf(),[,a]=Pe(),[,s]=Yk(),[,i]=ao(),{hasPermission:l}=kt(),{editingBlockId:c}=us(),{document:d}=Un(),[p,u]=(0,an.useState)(null),m=Zn(),g=q("flags.gotoSettings",!1),h=q("flags.ai",!1),f=p===e._id,[b,y]=(0,an.useState)(!1),{floatingStyles:k,refs:w,update:N}=(0,_S.useFloating)({placement:"top-start",middleware:[(0,_S.shift)({boundary:d==null?void 0:d.body,limiter:(0,vh.limitShift)({offset:8,mainAxis:!0,crossAxis:!0})}),(0,vh.flip)({boundary:d==null?void 0:d.body,fallbackPlacements:["bottom-start","top-end","bottom-end","inside"]}),(0,vh.size)({boundary:d==null?void 0:d.body,apply({availableWidth:L,availableHeight:z,elements:_}){Object.assign(_.floating.style,{maxWidth:`${Math.max(200,L)}px`,maxHeight:`${Math.max(100,z)}px`})}})],elements:{reference:o}});(0,wE.useResizeObserver)(o,()=>N(),o!==null),(0,wE.useResizeObserver)(d==null?void 0:d.body,()=>N(),(d==null?void 0:d.body)!==null);let I=(0,ap.get)(e,"_parent",null),C=(0,ap.isEmpty)((0,ap.get)(e,"_name",""))?(0,ap.get)(e,"_type",""):(0,ap.get)(e,"_name","");(0,an.useEffect)(()=>{u(null)},[o]),(0,an.useEffect)(()=>{let L=null,z=null;if(!o){N();return}return L=requestAnimationFrame(()=>{z=requestAnimationFrame(()=>{N()})}),()=>{L!==null&&cancelAnimationFrame(L),z!==null&&cancelAnimationFrame(z)}},[o,u,e._id,N]);let P=(0,an.useCallback)(L=>{w.setFloating(L)},[w]),B=(0,an.useCallback)(()=>{I&&(i([]),a([I]))},[I,i,a]),T=(0,an.useCallback)(L=>{L.stopPropagation(),s("")},[s]),v=(0,an.useCallback)(L=>{L.stopPropagation(),L.preventDefault()},[]),S=(0,an.useCallback)(L=>{L.stopPropagation()},[]),A=(0,an.useCallback)(()=>{n([e==null?void 0:e._id])},[n,e._id]),D=(0,an.useCallback)(()=>{r([e==null?void 0:e._id])},[r,e._id]),R=(0,an.useCallback)(()=>{u(L=>{var F;if(L===e._id)return null;let z=(((F=o==null?void 0:o.getBoundingClientRect())==null?void 0:F.top)||0)+220;return z>=0&&z<=window.innerHeight||setTimeout(()=>{let O=d==null?void 0:d.getElementById("canvas-block-floating-ai-prompt-input");O==null||O.scrollIntoView({behavior:"smooth",block:"center"})},200),e._id})},[d,e._id,o]),H=(0,an.useCallback)(L=>{y(z=>(z&&!L?u(null):L&&p&&d&&QZ(d,p),L))},[d,p]);return(0,an.useEffect)(()=>{!p&&d&&HO(d)},[d,p]),{floatingStyles:k,setFloatingRef:P,label:C,parentId:I,isDragAndDropEnabled:m,gotoSettingsEnabled:g,isAiEnabled:h,isAiPromptOpen:f,hasPermission:l,shouldRender:t||o&&e&&!c,block:e,update:N,isAiLoading:b,handlers:{handleParentSelect:B,handleMouseEnter:T,handleClick:v,handleKeyDown:S,handleDuplicate:A,handleDelete:D,handleOpenAiPanel:R,handleAiLoading:H}}},eee=({block:e,isDragging:t,selectedBlockElement:o})=>{let{floatingStyles:r,setFloatingRef:n,label:a,parentId:s,isDragAndDropEnabled:i,gotoSettingsEnabled:l,isAiEnabled:c,isAiPromptOpen:d,hasPermission:p,shouldRender:u,update:m,handlers:g,isAiLoading:h}=ZZ({block:e,isDragging:t,selectedBlockElement:o});return u?(0,qr.jsx)(qr.Fragment,{children:(0,qr.jsxs)("div",{role:"button",tabIndex:0,ref:n,style:r,onClick:g.handleClick,onMouseEnter:g.handleMouseEnter,onKeyDown:g.handleKeyDown,className:`relative z-[999] text-xs text-white ${t?"opacity-0":""}`,children:[(0,qr.jsxs)("div",{className:"isolate flex h-6 scale-100 items-center justify-between bg-blue-500 py-2",children:[(0,qr.jsxs)("div",{className:"flex items-center",children:[i&&(0,qr.jsx)(ad.DragHandleDots2Icon,{className:"flex-shrink-0 cursor-grab rounded p-0.5 hover:bg-white/20 active:cursor-grabbing"}),s&&(0,qr.jsx)(ad.ArrowUpIcon,{className:"flex-shrink-0 rounded p-0.5 hover:bg-white/20",onClick:g.handleParentSelect})]}),(0,qr.jsx)("div",{className:`w-full ${i?"cursor-grab active:cursor-grabbing":""}`,children:(0,qr.jsx)("div",{className:"mr-10 w-full items-center space-x-1 px-1 leading-tight",children:a})}),(0,qr.jsxs)("div",{className:`flex items-center gap-1 pl-1 pr-1.5 ${h?"pointer-events-none opacity-75":""}`,children:[p(xe["pages:update"])&&c&&(h?(0,qr.jsx)(wt,{className:"h-4 w-4 animate-spin text-white"}):(0,qr.jsx)(CN,{className:`h-4 w-4 rounded hover:bg-white hover:text-blue-500 ${d?"bg-white text-primary":""}`,onClick:()=>g.handleOpenAiPanel()})),l&&(0,qr.jsx)(IO,{blockId:e==null?void 0:e._id,className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500"}),!i&&(0,qr.jsx)(dL,{block:e,children:(0,qr.jsx)(ad.PlusIcon,{className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500"})}),Yb((0,ap.get)(e,"_type",""))&&p(xe["pages:update"])?(0,qr.jsx)(ad.CopyIcon,{className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",onClick:g.handleDuplicate}):null,Uf((0,ap.get)(e,"_type",""))&&p(xe["pages:update"])?(0,qr.jsx)(ad.TrashIcon,{className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",onClick:g.handleDelete}):null,p(xe["pages:update"])&&(0,qr.jsx)(RL,{block:e,updateFloatingBar:m})]})]}),(0,qr.jsx)(NO,{isOpen:d,isLoading:h,updateLoadingState:g.handleAiLoading})]})}):null},UO=()=>{let{selectedBlock:e,selectedElements:t,dragging:o,isDragging:r,isDragAndDropEnabled:n,handleDragStart:a,handleDragEnd:s}=XZ();return(0,qr.jsx)("div",{onDragEnd:s,draggable:n&&!!e,onDragStart:a,children:e&&(0,qr.jsx)(eee,{block:e,isDragging:r&&!!o,selectedBlockElement:t[0]||(r?o:null)})})}});var $O,VO=x(()=>{"use strict";$O=`<!doctype html>
55
+ <html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
56
+ <head>
57
+ <meta charset="UTF-8">
58
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
59
+ <script src="https://cdn.tailwindcss.com/3.4.17?plugins=forms@0.5.9,typography@0.5.15,aspect-ratio@0.4.2"></script>
60
+ <style>
61
+ html { height: 100%; overflow:auto; }
62
+ body { height: 100%; }
63
+ .air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
64
+ .air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
65
+ body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
66
+ -moz-user-select: none;-ms-user-select: none; user-select: none; }
67
+ html{
68
+ -ms-overflow-style: none; /* IE and Edge */
69
+ scrollbar-width: none; /* Firefox */
70
+ }
71
+ /** IMPORTANT: Make fields content editable in SAFARI */
72
+ [contenteditable] {-webkit-user-select: text;user-select: text;}
73
+
74
+ html::-webkit-scrollbar { width: 0 !important }
75
+ .aspect-auto{aspect-ratio: auto;}
76
+ .aspect-square{aspect-ratio: 1/1;}
77
+ .aspect-video{aspect-ratio: 16/9;}
78
+ .dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
79
+ .dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
80
+ a{ pointer-events: none !important; }
81
+ [contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
82
+ [contenteditable="true"] {
83
+ outline: none;
84
+ box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
85
+ -webkit-user-select: text;
86
+ -moz-user-select: text;
87
+ user-select: text;
88
+ }
89
+ .frame-root .frame-content { height: 100%; }
90
+ [data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
91
+ [data-dnd="yes"] { pointer-events: auto !important}
92
+ [data-dnd="no"],[data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] > * { pointer-events: none !important; }
93
+ [data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] { position: relative !important;display: inherit !important; }
94
+ .partial-overlay { pointer-events: auto !important; }
95
+ [data-dnd-dragged="yes"] { opacity: 0.6; pointer-events: none; }
96
+ [data-dnd-dragged="no"] { opacity: 1; pointer-events: auto !important; }
97
+ [force-show] { display: block !important; }
98
+ [data-cut-block="yes"] { pointer-events: none !important; display: none !important; }
99
+ </style>
100
+ <style id="highlighted-block">
101
+ [data-highlighted]{
102
+ outline: 1px solid #42a1fc !important; outline-offset: -1px;
103
+ }
104
+ </style>
105
+ <style>
106
+ .react-colorful {
107
+ height: 120px !important;
108
+ width: 180px !important;
109
+ }
110
+ .react-colorful > div {
111
+ margin-bottom: 4px;
112
+ }
113
+ .react-colorful__saturation {
114
+ border-radius: 4px !important;
115
+ }
116
+ .react-colorful__hue,
117
+ .react-colorful__alpha {
118
+ height: 12px !important;
119
+ border-radius: 4px !important;
120
+ }
121
+ .react-colorful__pointer {
122
+ width: 16px !important;
123
+ height: 16px !important;
124
+ border: 1.5px solid #fff !important;
125
+ cursor: pointer !important;
126
+ z-index: 10002 !important;
127
+ }
128
+ #active-inline-editing-element{outline: 2px solid #00c951;}
129
+ </style>
130
+ <style type="text/tailwindcss">
131
+ @layer base {
132
+ * {
133
+ @apply border-border;
134
+ }
135
+ }
136
+ @layer utilities {
137
+ .rte {
138
+ h1 {
139
+ @apply text-2xl;
140
+ }
141
+ h2 {
142
+ @apply text-xl;
143
+ }
144
+ h3 {
145
+ @apply text-lg;
146
+ }
147
+ h4 {
148
+ @apply text-base;
149
+ }
150
+ h5 {
151
+ @apply text-sm;
152
+ }
153
+ h6 {
154
+ @apply text-xs;
155
+ }
156
+ p {
157
+ &:empty {
158
+ @apply h-4;
159
+ }
160
+ }
161
+ ul {
162
+ @apply list-disc pl-6 text-base;
163
+ }
164
+ ol {
165
+ @apply list-decimal pl-6 text-base;
166
+ }
167
+ li > p {
168
+ @apply m-0;
169
+ }
170
+ blockquote {
171
+ @apply pl-4 text-base;
172
+ p {
173
+ @apply pl-4 text-base;
174
+ }
175
+ }
176
+ }
177
+ }
178
+ </style>
179
+ </head>
180
+ <body class="font-body antialiased h-full">
181
+ <div class="frame-root h-full"></div>
182
+ </body>
183
+ </html>`});var LS,wx,zO=x(()=>{"use strict";LS=require("react"),wx=class extends LS.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return LS.Children.only(this.props.children)}}});var Px,PE,Ch,MS,TE,WO=x(()=>{"use strict";Px=K(require("react"),1),PE=K(require("react-dom"),1);zO();Qf();Ch=require("react/jsx-runtime"),MS=class extends Px.Component{constructor(o){super(o);this._isMounted=!1;this.nodeRef=Px.default.createRef();this.setRef=o=>{this.nodeRef.current=o;let{forwardedRef:r}=this.props;typeof r=="function"?r(o):r&&(r.current=o)};this.handleLoad=()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})};this.startLoadCheck=()=>{this.loadCheck=setInterval(()=>{this.handleLoad()},500)};this.state={iframeLoaded:!1}}componentDidMount(){var r;this._isMounted=!0,this.getDoc()&&this.nodeRef.current&&((r=this.nodeRef.current.contentWindow)==null||r.addEventListener("DOMContentLoaded",this.handleLoad))}componentWillUnmount(){var o;this._isMounted=!1,(o=this.nodeRef.current)==null||o.removeEventListener("DOMContentLoaded",this.handleLoad),clearInterval(this.loadCheck)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){let o=this.getDoc();return o?this.props.mountTarget?o.querySelector(this.props.mountTarget):o.body.children[0]:null}renderFrameContents(){if(!this._isMounted)return null;let o=this.getDoc();if(!o)return null;let r=this.props.contentDidMount,n=this.props.contentDidUpdate,a=o.defaultView||o.parentView,s=(0,Ch.jsx)(wx,{contentDidMount:r,contentDidUpdate:n,children:(0,Ch.jsx)(AL,{value:{document:o,window:a},children:(0,Ch.jsx)("div",{className:"frame-content",children:this.props.children})})}),i=this.getMountTarget();return!i||!o.head?null:[PE.default.createPortal(this.props.head,o.head),PE.default.createPortal(s,i)]}render(){let{...o}=this.props,r={...o,srcDoc:this.props.initialContent,children:void 0};return delete r.head,delete r.initialContent,delete r.mountTarget,delete r.contentDidMount,delete r.contentDidUpdate,delete r.forwardedRef,(0,Ch.jsx)("iframe",{...r,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}};MS.defaultProps={style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'};TE=Px.default.forwardRef((e,t)=>(0,Ch.jsx)(MS,{...e,forwardedRef:t}))});var mg=x(()=>{"use strict";WO();Qf()});var jO,qO=x(()=>{"use strict";mg();xN();jO=()=>{let{document:e}=Un();return Hk(e),null}});var KO,YO,Zl,JO,QO=x(()=>{"use strict";KO=require("@radix-ui/react-icons"),YO=require("react-i18next");al();Qn();Pa();mn();tn();Zl=require("react/jsx-runtime"),JO=()=>{let{t:e}=(0,YO.useTranslation)(),{hasPermission:t}=kt(),o=t(xe["pages:update"]),r=Zn();return o?(0,Zl.jsxs)("div",{id:"add-block-bottom",className:"group relative w-full cursor-pointer py-2",children:[(0,Zl.jsx)("br",{}),!r&&(0,Zl.jsx)("div",{role:"button",onClick:()=>Gt.publish(dt.OPEN_ADD_BLOCK),className:"block h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",children:(0,Zl.jsxs)("div",{className:"absolute left-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-xs leading-tight text-white hover:bg-primary",children:[(0,Zl.jsx)(KO.PlusIcon,{className:"size-2.5 stroke-[3]"})," ",e("Add block")]})}),(0,Zl.jsx)("br",{}),(0,Zl.jsx)("br",{}),(0,Zl.jsx)("br",{}),(0,Zl.jsx)("br",{})]}):null}});function XO(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),o=parseInt(t[1],16),r=parseInt(t[2],16),n=parseInt(t[3],16);o/=255,r/=255,n/=255;let a=Math.max(o,r,n),s=Math.min(o,r,n),i=0,l=0,c=(a+s)/2;if(a==s)i=l=0;else{let d=a-s;switch(l=c>.5?d/(2-a-s):d/(a+s),a){case o:i=(r-n)/d+(r<n?6:0);break;case r:i=(n-o)/d+2;break;case n:i=(o-r)/d+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(c*100)}%`}var sp,ZO,tee,eF,tF,oF,NE=x(()=>{"use strict";sp=require("lodash-es");Ne();ZO=e=>({fontFamily:e.fontFamily?(0,sp.keys)(e.fontFamily).reduce((o,r)=>({...o,[r.replace("font-","")]:`var(--${r})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?(0,sp.flatten)(e.colors.map(o=>Object.entries(o.items))).reduce((o,[r])=>({...o,[r]:`hsl(var(--${r}))`}),{}):{}});tee=e=>{let o=hf().find(r=>r.family===e);return`"${e}", ${(0,sp.get)(o,"fallback","")}`},eF=({theme:e})=>{let t=e;return`:root {
184
+ ${e.fontFamily?Object.entries(e.fontFamily).map(([o,r])=>`--font-${o}: ${tee(r)};`).join(`
185
+ `):""}
186
+ ${t.borderRadius?`--radius: ${t.borderRadius};`:""}
187
+ ${t.colors?Object.entries(t.colors).map(([o,r])=>`--${o}: ${XO(r[0])};`).join(`
188
+ `):""}
189
+ }
190
+ .dark {
191
+ ${t.colors?Object.entries(t.colors).map(([o,r])=>`--${o}: ${XO(r[1])};`).join(`
192
+ `):""}
193
+ }`},tF=e=>!e||e.length===0?[]:(0,sp.uniqBy)(e,"family").map(t=>t.url),oF=e=>!e||e.length===0?"":(0,sp.uniqBy)(e,"family").map(t=>t.src.map(o=>`@font-face {
194
+ font-family: "${t.family}";
195
+ src: url("${o.url}") format("${o.format}");
196
+ font-display: swap;
197
+ ${o.fontWeight?`font-weight: ${o.fontWeight};`:""}
198
+ ${o.fontStyle?`font-style: ${o.fontStyle};`:""}
199
+ ${o.fontStretch?`font-stretch: ${o.fontStretch};`:""}
200
+ }`).join(`
201
+ `)).join(`
202
+ `)});var rF,aF,oee,nF,sF=x(()=>{"use strict";rF=require("react");NE();aF=require("react/jsx-runtime"),oee=e=>(0,rF.useMemo)(()=>eF({theme:e}),[e]),nF=({theme:e})=>{let t=oee(e);return(0,aF.jsx)("style",{id:"chai-theme",dangerouslySetInnerHTML:{__html:t}})}});var iF,lF,EE,ec,Im=x(()=>{"use strict";iF=require("jotai"),lF=require("jotai/utils"),EE=(0,lF.atomWithStorage)("darkMode",!1),ec=()=>{let[e,t]=(0,iF.useAtom)(EE);return[e,t]}});var cF,dF,pF,pl,ip,mF,hs,ree,nee,aee,see,iee,lee,cee,dee,uF,gF=x(()=>{"use strict";cF=K(require("@tailwindcss/container-queries"),1),dF=K(require("@tailwindcss/forms"),1),pF=K(require("@tailwindcss/typography"),1),pl=require("lodash-es"),ip=require("react"),mF=K(require("tailwindcss/plugin"),1);NE();sF();mg();Im();Ge();fn();Vc();Ne();hs=require("react/jsx-runtime"),ree=(e,t)=>{(0,ip.useEffect)(()=>{e?t==null||t.documentElement.classList.add("dark"):t==null||t.documentElement.classList.remove("dark")},[e,t])},nee=(e,t,o)=>{(0,ip.useEffect)(()=>{let r=o;if(!r||!r.tailwind)return;let n={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...ZO(t)}},plugins:[pF.default,dF.default,cF.default,(0,mF.default)(function({addBase:a,theme:s}){a({"h1,h2,h3,h4,h5,h6":{fontFamily:s("fontFamily.heading")},body:{fontFamily:s("fontFamily.body"),color:s("colors.foreground"),backgroundColor:s("colors.background")}})})]};Object.assign(r.tailwind.config,n)},[e,t,o])},aee=()=>{let[e]=ao(),[t]=Pe();return(0,ip.useMemo)(()=>`${(0,pl.map)(e,({id:o})=>`[data-style-id="${o}"]`).join(",")}{
203
+ outline: 1px solid ${t.length>0?"#42a1fc":"#de8f09"} !important; outline-offset: -1px;
204
+ }`,[e,t])},see=()=>{let[e]=Pe();return(0,ip.useMemo)(()=>`${(0,pl.map)(e,t=>`[data-block-id="${t}"]`).join(",")}{
205
+ outline: 1px solid #42a1fc !important; outline-offset: -1px;
206
+ }`,[e])},iee=()=>{let[e]=Yu(),t=ff(),o=(0,ip.useMemo)(()=>{let{heading:a,body:s}={heading:(0,pl.get)(e,"fontFamily.heading"),body:(0,pl.get)(e,"fontFamily.body")};return t.filter(i=>i.family===a||i.family===s)},[e,t]),r=(0,ip.useMemo)(()=>tF((0,pl.filter)(o,a=>(0,pl.has)(a,"url"))),[o]),n=(0,ip.useMemo)(()=>oF((0,pl.filter)(o,a=>(0,pl.has)(a,"src"))),[o]);return{fonts:r,customFonts:n}},lee=()=>{let e=aee();return(0,hs.jsx)("style",{id:"selected-styling-blocks",dangerouslySetInnerHTML:{__html:e}})},cee=()=>{let e=see();return(0,hs.jsx)("style",{id:"selected-blocks",dangerouslySetInnerHTML:{__html:e}})},dee=()=>{let{fonts:e,customFonts:t}=iee();return(0,hs.jsxs)(hs.Fragment,{children:[e.map((o,r)=>(0,hs.jsx)("link",{rel:"stylesheet",href:o},`google-font-${r}`)),(0,hs.jsx)("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:t}})]})},uF=()=>{let[e]=Yu(),t=nm(),[o]=ec(),{document:r,window:n}=Un();return ree(o,r),nee(e,t,n),(0,hs.jsxs)(hs.Fragment,{children:[(0,hs.jsx)(nF,{theme:e}),(0,hs.jsx)(dee,{}),(0,hs.jsx)(cee,{}),(0,hs.jsx)(lee,{})]})}});var fF,hF,Ci,kh,Sh=x(()=>{"use strict";fF=require("jotai/utils"),hF=require("jotai"),Ci=(0,fF.atomWithStorage)("canvasZoom",100),kh=()=>(0,hF.useAtom)(Ci)});var yF,bF,xF=x(()=>{"use strict";yF=require("jotai");Ge();bF=()=>(0,yF.useAtom)(b0)});var ug,AE,vF,CF,OS,IE,Tx,Bm,Rm=x(()=>{"use strict";ug=require("jotai"),AE=require("jotai/utils"),vF=require("react");pn();xF();CF=(0,AE.atomWithStorage)("canvasWidth",800),OS=(0,AE.atomWithStorage)("canvasDisplayWidth",800),IE=(0,ug.atom)(e=>{let t=e(CF);return iC(t).toLowerCase()}),Tx=()=>{let[e,t]=(0,ug.useAtom)(CF),o=(0,ug.useAtomValue)(IE),[r,n]=bF();return(0,vF.useEffect)(()=>{r!=="xs"&&n(o)},[o,r,n]),[e,o,t]},Bm=()=>{let[e,t]=(0,ug.useAtom)(OS);return[e,t]}});var ul,SF,BE,Dm,ml,_m,lp,FS,pee,mee,RE,kF,cp,gg,HS,wF,Lm,US,PF,DE,TF,GS,wh,Mm,$S,NF,EF,AF,Om=x(()=>{"use strict";ul=require("jotai"),SF=require("jotai/utils");Jn();Sh();Rm();BE=(0,SF.atomWithStorage)("pannableCanvas",!1),Dm=(0,ul.atom)("select"),ml=(0,ul.atom)({x:0,y:0}),_m=(0,ul.atom)(!1),lp=(0,ul.atom)({width:0,height:0}),FS=(0,ul.atom)(800),pee=25,mee=400,RE=24,kF=48,cp=e=>Math.min(mee,Math.max(pee,e)),gg=(e,t,o)=>{let r=kF-t,n=o-kF;return Math.min(Math.max(e,r),n)},HS=(e,t)=>gg((t-e)/2,e,t),wF=e=>{let t=cp(e)/100;return{width:be.get(OS)*t,height:be.get(FS)*t}},Lm=(e,t)=>{let o=be.get(lp),r=wF(be.get(Ci)),n=be.get(ml);be.set(ml,{x:gg(n.x+e,r.width,o.width),y:gg(n.y+t,r.height,o.height)})},US=(e,t,o)=>{let r=be.get(Ci),n=cp(e);if(r===n)return;let a=be.get(lp),s=wF(n),i=be.get(ml),l=n/r;be.set(ml,{x:gg(t-(t-i.x)*l,s.width,a.width),y:gg(o-(o-i.y)*l,s.height,a.height)}),be.set(Ci,n)},PF=(e,t,o)=>{let r=be.get(Ci)/100,n=be.get(ml);US(e,n.x+r*t,n.y+r*o)},DE=e=>{let t=be.get(lp);US(e,t.width/2,t.height/2)},TF=()=>{let e=be.get(lp),t=be.get(OS);be.set(Ci,100),be.set(ml,{x:HS(t,e.width),y:RE})},GS=()=>{be.set(BE,!be.get(BE))},wh=e=>{var o;let t=e;return!t||typeof t.tagName!="string"?!1:t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||!!t.isContentEditable||!!((o=t.closest)!=null&&o.call(t,'[contenteditable="true"]'))},Mm=()=>(0,ul.useAtom)(BE),$S=()=>(0,ul.useAtom)(Dm),NF=()=>(0,ul.useAtom)(ml),EF=()=>(0,ul.useAtom)(_m),AF=()=>(0,ul.useAtom)(FS)});var IF,VS,RF,uee,BF,DF=x(()=>{"use strict";IF=require("jotai"),VS=require("react");Jn();mg();Sh();Zu();Om();RF=require("react/jsx-runtime"),uee=3e4,BF=({pannable:e})=>{let{document:t}=Un(),{editingBlockId:o}=us(),r=(0,IF.useAtomValue)(lp).height;if((0,VS.useEffect)(()=>{if(!e||!(t!=null&&t.documentElement))return;let a,s=()=>{let l=t.documentElement.scrollHeight;be.set(FS,Math.min(Math.max(l,100),uee))},i=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(s,150)});return i.observe(t.documentElement),s(),()=>{clearTimeout(a),i.disconnect()}},[e,t]),(0,VS.useEffect)(()=>{if(!t)return;let a=s=>{s.ctrlKey||s.metaKey||s.altKey||s.key!=="p"&&s.key!=="P"||o||wh(s.target)||GS()};return t.addEventListener("keydown",a),()=>t.removeEventListener("keydown",a)},[t,o]),(0,VS.useEffect)(()=>{if(!e||!t)return;let a=g=>{if(g.preventDefault(),g.ctrlKey||g.metaKey){let b=cp(be.get(Ci)*Math.exp(-g.deltaY*.01));PF(b,g.clientX,g.clientY);return}let h=g.deltaX,f=g.deltaY;g.shiftKey&&h===0&&(h=f,f=0),Lm(-h,-f)},s=g=>{if(!(o||wh(g.target))){if(g.code==="Space"){g.repeat||(g.preventDefault(),be.set(_m,!0));return}g.ctrlKey||g.metaKey||g.altKey||((g.key==="v"||g.key==="V"||g.key==="Escape")&&be.set(Dm,"select"),(g.key==="h"||g.key==="H")&&be.set(Dm,"hand"))}},i=g=>{g.code==="Space"&&be.set(_m,!1)},l=!1,c=0,d=0,p=g=>{g.button===1&&(g.preventDefault(),l=!0,c=g.screenX,d=g.screenY)},u=g=>{l&&(Lm(g.screenX-c,g.screenY-d),c=g.screenX,d=g.screenY)},m=()=>{l=!1};return t.addEventListener("wheel",a,{passive:!1}),t.addEventListener("keydown",s),t.addEventListener("keyup",i),t.addEventListener("mousedown",p),t.addEventListener("mousemove",u),t.addEventListener("mouseup",m),t.addEventListener("mouseleave",m),()=>{t.removeEventListener("wheel",a),t.removeEventListener("keydown",s),t.removeEventListener("keyup",i),t.removeEventListener("mousedown",p),t.removeEventListener("mousemove",u),t.removeEventListener("mouseup",m),t.removeEventListener("mouseleave",m)}},[e,t,o]),!e)return null;let n=Math.round(Math.max(r,400));return(0,RF.jsx)("style",{children:`
207
+ html { height: auto !important; overflow: hidden !important; }
208
+ body { height: auto !important; }
209
+ [class*="min-h-screen"], [class*="min-h-dvh"] { min-height: ${n}px !important; }
210
+ [class*="max-h-screen"], [class*="max-h-dvh"] { max-height: ${n}px !important; }
211
+ [class*="h-screen"]:not([class*="min-h-screen"]):not([class*="max-h-screen"]),
212
+ [class*="h-dvh"]:not([class*="min-h-dvh"]):not([class*="max-h-dvh"]) { height: ${n}px !important; }
213
+ `})}});var zS,LF,_F,MF=x(()=>{"use strict";zS=require("react");Om();LF=require("react/jsx-runtime"),_F=()=>{let[e]=$S(),[t]=EF(),o=(0,zS.useRef)(!1);return(0,zS.useEffect)(()=>{let r=a=>{o.current&&Lm(a.movementX,a.movementY)},n=()=>{o.current=!1};return document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n)}},[]),e!=="hand"&&!t?null:(0,LF.jsx)("div",{className:"absolute inset-0 z-40 cursor-grab active:cursor-grabbing",onMouseDown:r=>{r.preventDefault(),r.stopPropagation(),o.current=!0},onClick:r=>r.stopPropagation()})}});var WS,Ph,FF,OF,HF=x(()=>{"use strict";WS=require("@react-hookz/web"),Ph=require("react");Ge();fn();FF=require("react/jsx-runtime"),OF=({children:e,onMount:t,onResize:o})=>{let[,r]=Pe(),[,n]=ao(),a=(0,Ph.useRef)(null),s=(0,WS.useDebouncedCallback)(()=>{let{clientWidth:l}=a.current;o(l)},[o],100);(0,WS.useResizeObserver)(a,s),(0,Ph.useEffect)(()=>{let{clientWidth:l}=a.current;t(l)},[]);let i=(0,Ph.useCallback)(()=>{r([]),n([])},[r,n]);return(0,FF.jsx)("div",{id:"main-content",onClick:i,className:"h-full w-full border-x-[24px] border-transparent bg-black/50 pb-0 [background-image:radial-gradient(#444_1px,transparent_1px)] [background-size:20px_20px] dark:bg-background/80",ref:a,children:e})}});var UF,GF,Fm,$F,VF=x(()=>{"use strict";UF=require("jotai"),GF=require("lodash-es"),Fm=require("react");zr();Jn();Ge();al();$F=()=>{let e=(0,UF.useSetAtom)(Gu),{onDragStart:t,onDragEnd:o}=nl(),r=(0,Fm.useRef)(null),n=(0,Fm.useCallback)(i=>{var d;if(i.button!==0||i.detail>=2)return;let c=(d=i.target.closest("[data-block-id]"))==null?void 0:d.getAttribute("data-block-id");!c||c==="canvas"||(e(p=>p.length===1&&p[0]===c?p:[c]),r.current=c)},[e]),a=(0,Fm.useCallback)(i=>{var p,u,m,g,h;i.stopPropagation();let l=(h=(g=r.current)!=null?g:(m=(u=(p=i.target).closest)==null?void 0:u.call(p,"[data-block-id]"))==null?void 0:m.getAttribute("data-block-id"))!=null?h:null;if(!l||l==="canvas")return;let c=be.get(Ot),d=(0,GF.find)(c,{_id:l});d&&t(i,d,!1)},[t]),s=(0,Fm.useCallback)(()=>{o(),r.current=null},[o]);return(0,Fm.useMemo)(()=>({onMouseDown:n,onDragStart:a,onDragEnd:s}),[n,a,s])}});var ys,dp=x(()=>{"use strict";Tn();ys=e=>{if(e=e.replace(lr,""),!e)return{baseClasses:"",classes:""};let t=e.split(/,(?![^\[]*\])/);if(t.length===1)return{baseClasses:"",classes:t[0].trim()};let[o,...r]=t;return{baseClasses:o.trim(),classes:r.join(",").trim().replace(/ +(?= )/g,"")}}});var ki,jS=x(()=>{"use strict";st();ki={"dt#btn":{name:"Button",description:"Base button styles",value:G("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0","h-9 px-4 py-2")},"dt#btn-primary":{name:"Button-Primary",description:"Primary button style",value:"bg-primary text-primary-foreground shadow hover:bg-primary/90"},"dt#btn-destructive":{name:"Button-Destructive",description:"Destructive button style",value:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90"},"dt#btn-outline":{name:"Button-Outline",description:"Outline button style",value:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground"},"dt#btn-secondary":{name:"Button-Secondary",description:"Secondary button style",value:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80"},"dt#btn-ghost":{name:"Button-Ghost",description:"Ghost button style",value:"hover:bg-accent hover:text-accent-foreground"},"dt#btn-link":{name:"Button-Link",description:"Link button style",value:"text-primary underline-offset-4 hover:underline"},"dt#btn-icon":{name:"Button-Icon",description:"Icon button style",value:"h-9 w-9"},"dt#btn-sm":{name:"Button-Small",description:"Small button style",value:"h-8 rounded-md px-3 text-xs"},"dt#btn-lg":{name:"Button-Large",description:"Large button style",value:"h-10 rounded-md px-8"},"dt#input":{name:"Input",description:"Base input field style",value:"flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-xs text-foreground transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"},"dt#input-sm":{name:"Input-Small",description:"Small input field style",value:"h-7 text-xs"},"dt#input-lg":{name:"Input-Large",description:"Large input field style",value:"h-10 text-sm"},"dt#textarea":{name:"Textarea",description:"Base textarea style",value:"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-xs text-foreground shadow-sm placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"},"dt#textarea-sm":{name:"Textarea-Small",description:"Small textarea style",value:"min-h-[40px] text-xs"},"dt#textarea-lg":{name:"Textarea-Large",description:"Large textarea style",value:"min-h-[80px] text-sm"},"dt#badge":{name:"Badge",description:"Base badge style",value:G("inline-flex leading-tight items-center gap-1 text-[11px] cursor-pointer rounded-md border px-2.5 py-0.5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80")},"dt#badge-secondary":{name:"Badge-Secondary",description:"Secondary badge style",value:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80"},"dt#badge-destructive":{name:"Badge-Destructive",description:"Destructive badge style",value:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80"},"dt#badge-outline":{name:"Badge-Outline",description:"Outline badge style",value:"text-foreground"},"dt#badge-active":{name:"Badge-Active",description:"Active badge style",value:"text-primary-foreground border-primary bg-primary px-2 py-px font-light"},"dt#badge-inactive":{name:"Badge-Inactive",description:"Inactive badge style",value:"text-foreground border-border bg-secondary hover:bg-accent px-2 py-px font-light"},"dt#alert":{name:"Alert",description:"Base alert style",value:G("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7","bg-surface text-foreground")},"dt#alert-destructive":{name:"Alert-Destructive",description:"Destructive alert style",value:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"},"dt#alert-title":{name:"Alert-Title",description:"Alert title style",value:"mb-1 font-medium leading-none tracking-tight"},"dt#alert-description":{name:"Alert-Description",description:"Alert description style",value:"text-sm [&_p]:leading-relaxed"},"dt#card":{name:"Card",description:"Base card style",value:"rounded-xl border bg-card text-card-foreground shadow"},"dt#card-header":{name:"Card-Header",description:"Card header style",value:"flex flex-col space-y-1.5 p-6"},"dt#card-title":{name:"Card-Title",description:"Card title style",value:"font-semibold leading-none tracking-tight"},"dt#card-description":{name:"Card-Description",description:"Card description style",value:"text-sm text-muted-foreground"},"dt#card-content":{name:"Card-Content",description:"Card content style",value:"p-6 pt-0"},"dt#card-footer":{name:"Card-Footer",description:"Card footer style",value:"flex items-center p-6 pt-0"},"dt#toggle":{name:"Toggle",description:"Base toggle style",value:G("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0","bg-transparent h-9 px-2 min-w-9")},"dt#toggle-outline":{name:"Toggle-Outline",description:"Outline toggle style",value:"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"},"dt#toggle-sm":{name:"Toggle-Small",description:"Small toggle style",value:"h-8 px-1.5 min-w-8"},"dt#toggle-lg":{name:"Toggle-Large",description:"Large toggle style",value:"h-10 px-2.5 min-w-10"},"dt#label":{name:"Label",description:"Form label style",value:"text-xs font-light leading-none text-foreground/80 dark:text-foreground/60 peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},"dt#checkbox":{name:"Checkbox",description:"Checkbox style",value:"peer h-4 w-4 shrink-0 cursor-pointer rounded-sm border border-border hover:border-foreground/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground"},"dt#switch":{name:"Switch",description:"Switch toggle style",value:"peer inline-flex h-4 w-[25px] cursor-pointer items-center rounded-full bg-muted transition-colors focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary dark:data-[state=unchecked]:bg-background"},"dt#switch-thumb":{name:"Switch-Thumb",description:"Switch thumb style",value:"pointer-events-none block h-3 w-3 rounded-full bg-secondary shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0.5"},"dt#skeleton":{name:"Skeleton",description:"Loading skeleton style",value:"animate-pulse rounded-md bg-primary/10"},"dt#separator":{name:"Separator",description:"Horizontal separator style",value:"shrink-0 bg-border h-[1px] w-full"},"dt#separator-vertical":{name:"Separator-Vertical",description:"Vertical separator style",value:"shrink-0 bg-border h-full w-[1px]"},"dt#progress":{name:"Progress",description:"Progress bar container style",value:"relative h-2 w-full overflow-hidden rounded-full bg-primary/20"},"dt#progress-indicator":{name:"Progress-Indicator",description:"Progress bar indicator style",value:"h-full bg-primary transition-all duration-300"}}});var _E,Nx,Ex,gee,fee,hee,yee,bee,xee,LE,vee,Cee,kee,See,wee,zF,Pee,Tee,ME,WF,qS=x(()=>{"use strict";_E=require("eta/core"),Nx=require("lodash-es"),Ex=/\{\{(.*?)\}\}/g,gee=/^[\w$][\w$.]*$/,fee=/[\[\]():?+\-*/%=&|<>!,'"\\`]/u,hee=/[\[\]():?+*%=&|<>!,'"\\`]/u,yee=new Set(["content","htmlCode","icon"]),bee=new _E.Eta({tags:["{{","}}"],autoEscape:!0,autoTrim:!1,useWith:!0,parse:{interpolate:"",exec:"~",raw:"~"},functionHeader:'const safeGet = (obj, path) => { const parts = path.split("."); let val = obj; for (const p of parts) { if (val == null) return undefined; val = val[p]; } return val; };'}),xee=new _E.Eta({tags:["{{","}}"],autoEscape:!1,autoTrim:!1,useWith:!0,parse:{interpolate:"",exec:"~",raw:"~"},functionHeader:'const safeGet = (obj, path) => { const parts = path.split("."); let val = obj; for (const p of parts) { if (val == null) return undefined; val = val[p]; } return val; };'}),LE=e=>(Ex.lastIndex=0,Ex.test(e)),vee=e=>e.split(".").map(t=>t.trim()).join("."),Cee=(e,t)=>{let o=t.split("."),r=e;for(let n of o){if(r==null)return;r=r[n]}return r},kee=e=>gee.test(e)?!0:e.includes(".")?e.split(".").map(o=>o.trim()).every(o=>o.length>0&&!fee.test(o)):!hee.test(e)&&(e.startsWith("#")||e.includes("/")),See=(e,t,o)=>{let r=o.slice(2,-2).trim();return t!==-1&&(0,Nx.startsWith)(e,"$index.")?`${r}.${t}.${e.slice(7)}`:t!==-1&&(0,Nx.startsWith)(e,"$index")?`${r}.${t}`:e},wee=(e,t,o)=>{if(t===-1||!o)return e;let r=o.slice(2,-2).trim();return e.replace(/\$index\./g,`safeGet(it, "${r}.${t}").`).replace(/\$index/g,`safeGet(it, "${r}.${t}")`)},zF=(e,t,o)=>kee(e)?vee(See(e,t,o)):null,Pee=(e,t,o)=>e.replace(Ex,(r,n)=>{let a=n.trim();if(!a)return'{{""}}';let s=zF(a,t,o);return s?`{{safeGet(it, ${JSON.stringify(s)}) ?? ""}}`:`{{${wee(a,t,o)}}}`}),Tee=(e,t,o,r,n)=>{try{return(n!=null&&n.renderRaw?xee:bee).renderString(Pee(e,o,r),t)}catch(a){return""}},ME=(e,t,o,r,n)=>{Ex.lastIndex=0;let a=e.match(Ex);if(!a)return e;let s=n==="image"||n==="mobileImage",i=n!==void 0&&yee.has(n);for(let l of a){let c=l.slice(2,-2).trim(),d=zF(c,o,r);if(!d)continue;let p=Cee(t,d);if((0,Nx.isArray)(p)||s&&p!==void 0)return p}return Tee(e,t,o,r,{renderRaw:i})},WF=(e,t)=>ME(e,t,-1,"")});var Aa,OE,Ax,KS=x(()=>{"use strict";Aa=require("lodash-es");Tn();qS();OE=(e,t,{index:o,key:r},n)=>{if((0,Aa.isString)(e))return ME(e,t,o,r,n);if((0,Aa.isArray)(e))return e.map(a=>OE(a,t,{index:o,key:r},n));if(e&&typeof e=="object"){let a={};return(0,Aa.forEach)((0,Aa.keys)(e),s=>{!(0,Aa.startsWith)(s,"_")&&s!=="$repeaterItemsKey"?a[s]=OE(e[s],t,{index:o,key:r},s):a[s]=e[s]}),a}return e},Ax=(e,t,{index:o,key:r})=>{let n=(0,Aa.cloneDeep)(e);if(n.repeaterItems){let a=n.repeaterItems;if(n.$repeaterItemsKey=n.repeaterItems,(0,Aa.startsWith)(n.repeaterItems,`{{${"#"}`)&&(n.$repeaterItemsKey=n.repeaterItems=`${n.repeaterItems.replace("}}",`/${n._id}}}`)}`),!(0,Aa.isEmpty)(n.repeaterItems)&&n.pagination){let s=`${a.replace("}}",`/${n._id}/totalItems}}`)}`,i=(0,Aa.get)(t,s.slice(2,-2));n.repeaterTotalItems=i,n.totalItems=i}}return OE(n,t,{index:o,key:r})}});var jF=x(()=>{"use strict";KS()});function FE(e,t,o){let r=(0,Jo.get)(o,"i18nProps",[]);if((0,Jo.isEmpty)(t)||!(0,Jo.isArray)(r)||(0,Jo.isEmpty)(r))return e;let n=null;return r.forEach(a=>{if(!(0,Jo.isString)(a)||(0,Jo.isEmpty)(a)||!Object.prototype.hasOwnProperty.call(e,a))return;let s=(0,Jo.get)(e,a),i=(0,Jo.get)(e,`${a}-${t}`,""),l=(0,Jo.isString)(s)?(0,Jo.isString)(i)&&!(0,Jo.isEmpty)(i.trim())&&i.trimStart()||s:(0,Jo.isEmpty)(i)?s:i;l!==s&&(n||(n={...e}),n[a]=l)}),n||e}function Ree(e,t){return(0,Jo.get)(e,`${t}_attrs`,{})}function QF(e,t=!0,o={}){let r=KF.get(e);r||(r=new WeakMap,KF.set(e,r));let n=r.get(o);n||(n={},r.set(o,n));let a=t?"inBuilder":"inRenderer",s=n[a];if(s)return s;let i={};return Object.keys(e).forEach(l=>{if((0,Jo.isString)(e[l])&&e[l].startsWith(lr)){let c=Iee(e[l],o),d=Ree(e,l);i[l]={...!(0,Jo.isEmpty)(c)&&{className:c},...d,...t?{"data-style-prop":l,"data-block-parent":e._id,"data-style-id":`${l}-${e._id}`}:{}}}}),n[a]=i,i}var Jo,YF,JF,Nee,qF,KF,Eee,Aee,Iee,Bee,XF,ZF,e5=x(()=>{"use strict";Jo=require("lodash-es"),YF=require("cnfast");dp();jS();Tn();Ne();jF();JF=(e,t,o)=>e?e.split(" ").map(r=>{var n;return r.startsWith("dt#")?o.has(r)?"":(o.add(r),JF((n=t[r])==null?void 0:n.value,t,o)):r}).filter(Boolean).join(" "):"",Nee=(0,Jo.memoize)(e=>({...ki,...e})),qF=new WeakMap,KF=new WeakMap,Eee=5e3,Aee=e=>{for(;e.size>Eee;){let t=e.keys().next().value;if(!t)return;e.delete(t)}},Iee=(e,t)=>{let o=qF.get(t);o||(o=new Map,qF.set(t,o));let r=o.get(e);if(r!==void 0)return r;let n=Bee(e,t);return o.set(e,n),Aee(o),n},Bee=(e,t)=>{let o=Nee(t),{baseClasses:r,classes:n}=ys(e),s=n.split(" ").filter(l=>l.startsWith("dt#")).map(l=>{var c;return JF((c=o[l])==null?void 0:c.value,o,new Set([l]))}),i=n.split(" ").filter(l=>!l.startsWith("dt#")).join(" ");return YF.twMerge.apply(null,[r,...s,i])};XF=(0,Jo.memoize)(e=>{var n,a;let t=Ct(e),o=(a=(n=t==null?void 0:t.props)==null?void 0:n.schema)!=null?a:{},r=(0,Jo.get)(o,"properties",{});return Object.fromEntries(Object.entries(r).filter(([,s])=>(0,Jo.get)(s,"runtime",!1)))}),ZF=(e,t)=>{if(!(0,Jo.isArray)(e))return e;let o=e,r;return typeof t.limit=="number"&&t.limit>0&&(r=t.limit),r!==void 0&&(o=o.slice(0,r)),o}});var HE,Th,Dee,_ee,Ix,Lee,Mee,Oee,t5,o5=x(()=>{"use strict";HE=require("jotai"),Th=require("lodash-es");zr();Dee=(0,HE.atom)({}),_ee=5e3,Ix=new Map,Lee=()=>{for(;Ix.size>_ee;){let e=Ix.keys().next().value;if(!e)return;Ix.delete(e)}},Mee=(e,t)=>{let o=Object.keys(e);return o.length!==Object.keys(t).length?!1:o.every(r=>Object.is(e[r],t[r]))},Oee=(e,t)=>{let o=null;return(0,HE.atom)(r=>{let n=r(Yp),a=[],s=n.get(e);for(;s;){let l=r(s);a.push(l),s=l._parent?n.get(l._parent):void 0}let i=Object.entries(t).reduce((l,[c,d])=>{let p=a.find(u=>u._type===(0,Th.get)(d,"block"));return p&&(l[c]=(0,Th.get)(p,(0,Th.get)(d,"prop"),null)),l},{});return o&&Mee(o,i)?o:(o=i,i)})},t5=(e,t)=>{if((0,Th.isEmpty)(t))return Dee;let o=Ix.get(e);if(o&&o.runtimeProps===t)return o.atom;let r=Oee(e,t);return Ix.set(e,{runtimeProps:t,atom:r}),Lee(),r}});var r5,n5,YS,UE=x(()=>{"use strict";r5=require("jotai"),n5=require("react");Wr();jS();YS=()=>{let e=(0,r5.useAtomValue)(ls);return(0,n5.useMemo)(()=>({...ki,...e}),[e])}});var Bx,a5,s5=x(()=>{"use strict";Bx=require("lodash-es"),a5=(e,t)=>{let o=null;for(let r of Object.keys(e))(0,Bx.isString)(e[r])&&(0,Bx.startsWith)(r,"content")&&(o||(o={...e}),o[r]=`${e[r].trim()}${t?" ":""}`);return o!=null?o:e}});var JS,i5,l5,c5=x(()=>{"use strict";JS=require("lodash-es"),i5=require("react");OC();Ne();l5=({children:e,block:t})=>{let o=(0,i5.useMemo)(()=>Ct(t._type),[t._type]),r=(0,JS.get)(o,"dataProviderDependencies"),n=(0,JS.get)(o,"dataProvider"),a=(0,JS.get)(o,"dataProviderMode","mock"),s=zD(t,a,r,n);return e(s)}});var p5,d5,m5=x(()=>{"use strict";p5=require("react/jsx-runtime"),d5=()=>(0,p5.jsx)("div",{className:"flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500",children:"Something went wrong."})});function Mr(...e){return(0,g5.twMerge)((0,u5.clsx)(e))}var u5,g5,QS=x(()=>{"use strict";u5=require("cnfast"),g5=require("cnfast")});var pp,f5,Si,Fee,Rx,GE=x(()=>{"use strict";pp=require("react"),f5=require("react-dom");mg();Sr();Si=require("react/jsx-runtime"),Fee=({editor:e,trigger:t,content:o,from:r,menuRef:n})=>{let{document:a}=Un(),[s,i]=(0,pp.useState)({left:void 0,right:void 0,top:void 0,bottom:void 0}),[l,c]=(0,pp.useState)(!1),d=(0,pp.useRef)(null),p=(0,pp.useCallback)(()=>{var y,k;let u=(y=d.current)==null?void 0:y.getBoundingClientRect();if(!u||!a)return;let m=(k=n.current)==null?void 0:k.getBoundingClientRect();if(!m)return;let g=u.left,h=u.bottom+4,f,b;(m==null?void 0:m.left)+(m==null?void 0:m.width)+50>=a.body.offsetWidth&&(g=void 0,f=a.body.offsetWidth-(u==null?void 0:u.right)),h+202>=a.body.clientHeight&&(h=void 0,b=a.body.clientHeight-u.bottom+m.height),i({left:g,top:h,right:f,bottom:b})},[a,n]);if((0,pp.useEffect)(()=>{l&&requestAnimationFrame(p)},[l,p]),r==="canvas"){let u=()=>{c(!1),e&&(e==null||e.view.focus(),e==null||e.chain().focus().run())};return(0,Si.jsxs)(Si.Fragment,{children:[(0,Si.jsx)("div",{ref:d,onClick:()=>c(m=>!m),className:"cursor-pointer",children:t}),l&&(s.left!==void 0||s.top!==void 0||s.right!==void 0||s.bottom!==void 0)&&(0,f5.createPortal)((0,Si.jsx)("div",{id:"chaibuilder-rte-dropdown-menu-content",onClick:u,className:"fixed inset-0 left-0 top-0 z-[10001] h-full w-screen",children:(0,Si.jsx)("div",{onClick:m=>m.stopPropagation(),className:`absolute rounded-md border border-border bg-background p-1.5 text-xs shadow-2xl ${r==="canvas"?"bg-background text-white":"bg-surface text-foreground"}`,style:Object.assign({},{left:s.left,top:s.top,right:s.right,bottom:s.bottom}),children:typeof o=="function"?o(u):o})}),a.body,"chaibuilder-rte-dropdown-menu")]})}return(0,Si.jsx)(Si.Fragment,{children:(0,Si.jsxs)(Yt,{open:l,onOpenChange:c,children:[(0,Si.jsx)($t,{className:"relative outline-none",asChild:!0,children:t}),(0,Si.jsx)(Vt,{className:"z-50 rounded-md border border-border bg-popover p-1 text-xs text-popover-foreground shadow-xl",children:l&&(typeof o=="function"?o(()=>c(!1)):o)})]})})},Rx=Fee});var XS,$E,y5,ZS,fg,b5,wr,Hee,h5,Uee,Gee,x5,v5=x(()=>{"use strict";XS=require("@radix-ui/react-icons"),$E=require("@react-hookz/web"),y5=require("jotai"),ZS=require("lodash-es"),fg=require("react"),b5=require("react-colorful");Oa();QS();Im();J();fo();xi();GE();wr=require("react/jsx-runtime"),Hee=(e,t,o)=>{let r=o==="settings",n=typeof t=="boolean"?t:t.some(a=>e.isActive(a));return{"rounded p-1":!0,"hover:bg-primary/90 hover:text-primary-foreground":!n&&!r,"hover:bg-accent hover:text-accent-foreground":!n&&r,"bg-primary text-primary-foreground":n&&r,"bg-primary-foreground text-primary":n&&!r}},h5=({themeColors:e,onClose:t,color:o,onChange:r,onRemove:n})=>(0,wr.jsxs)(wr.Fragment,{children:[(0,wr.jsx)("div",{className:"flex w-[180px] flex-wrap gap-1 pb-2",children:(e==null?void 0:e.length)>0&&(0,ZS.uniq)(e).map(a=>{var s;return(0,wr.jsx)("button",{className:Mr("h-3 w-3 cursor-pointer rounded-full border border-foreground/20 shadow duration-300 hover:scale-110 hover:shadow-xl",{"border-2 border-foreground":a===o}),style:{backgroundColor:a},onClick:()=>{r(a),t()},title:(s=a||"#000000")==null?void 0:s.toUpperCase()},a)})}),(0,wr.jsx)(b5.HexAlphaColorPicker,{color:o,onChange:r,style:{width:"200px",height:"200px"}}),(0,wr.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-1",children:[(0,wr.jsx)(Ce,{type:"text",value:o||"#000000f2",onChange:a=>r(a.target.value,!0),placeholder:"#000000",className:"h-6 !w-[90px] text-center"}),(0,wr.jsx)(E,{onClick:()=>{n(),t()},size:"icon-sm",variant:"ghost",className:"h-5 w-5 bg-transparent",title:"Remove",children:(0,wr.jsx)(XS.Cross1Icon,{className:"h-3 w-3"})})]})]}),Uee=({textColor:e,highlightColor:t,onChangeTextColor:o,onChangeHighlightColor:r,onRemoveTextColor:n,onRemoveHighlightColor:a,onClose:s})=>{let[i]=ec(),[l]=(0,y5.useAtom)(qR),c=(l==null?void 0:l.colors)||{},d=Object.values(c).map(m=>(0,ZS.get)(m,i?"1":"0")),[p,u]=(0,fg.useState)("TEXT");return(0,wr.jsx)("div",{id:"rte-widget-color-picker",className:"px-1",children:(0,wr.jsxs)(Dr,{value:p,onValueChange:u,className:"w-full",children:[(0,wr.jsxs)(Cr,{className:"mb-2",children:[(0,wr.jsx)(ut,{value:"TEXT",className:"h-5 px-2 text-[10px]",children:"Text Color"}),(0,wr.jsx)(ut,{value:"HIGHLIGHT",className:"h-5 px-2 text-[10px]",children:"Highlight Color"})]}),(0,wr.jsx)(kr,{value:"TEXT",className:"mt-0",children:(0,wr.jsx)(h5,{themeColors:d,onClose:s,onChange:o,color:e,onRemove:n})}),(0,wr.jsx)(kr,{value:"HIGHLIGHT",className:"mt-0",children:(0,wr.jsx)(h5,{themeColors:d,onClose:s,onChange:r,color:t,onRemove:a})})]})})},Gee=({editor:e,from:t,menuRef:o})=>{var y,k;let r=(y=e==null?void 0:e.getAttributes("textStyle"))==null?void 0:y.color,n=(k=e==null?void 0:e.getAttributes("highlight"))==null?void 0:k.color,[a,s]=(0,fg.useState)(r||"#000000F2"),[i,l]=(0,fg.useState)(n||"#00000057"),[c,d]=(0,$E.useDebouncedState)(a,150),[p,u]=(0,$E.useDebouncedState)(i,150),m=(w,N)=>{N?(s(w),d(w)):(e==null||e.chain().setColor(w).run(),s(w))},g=(w,N)=>{N?(l(w),u(w)):(e==null||e.chain().setHighlight({color:w}).run(),l(w))},h=()=>{e==null||e.chain().unsetColor().run(),s("#000000F2")},f=()=>{e==null||e.chain().unsetHighlight().run()};return(0,fg.useEffect)(()=>{p!=null&&p.includes("#")&&(p==null?void 0:p.length)>=3&&(e==null||e.chain().setHighlight({color:p}).run())},[p,e]),(0,fg.useEffect)(()=>{c!=null&&c.includes("#")&&(c==null?void 0:c.length)>=3&&(e==null||e.chain().setColor(c).run())},[c,e]),(0,wr.jsx)(Rx,{editor:e,from:t,menuRef:o,trigger:(0,wr.jsxs)("div",{className:Mr("relative flex items-center",Hee(e,!!r,t)),title:"Text Color",children:[(0,wr.jsx)("div",{className:"h-4 w-4 rounded-full border",style:{backgroundColor:r||(t==="canvas"?"#FFFFFF":"#000000")}}),(0,wr.jsx)(XS.CaretDownIcon,{className:"h-3 w-3 opacity-50"})]}),content:w=>(0,wr.jsx)(Uee,{textColor:a,highlightColor:i,onChangeTextColor:m,onChangeHighlightColor:g,onRemoveTextColor:h,onRemoveHighlightColor:f,onClose:w})})},x5=Gee});var _o,C5,lt,Ws,$ee,ew,VE=x(()=>{"use strict";_o=require("@radix-ui/react-icons"),C5=require("react");QS();v5();GE();lt=require("react/jsx-runtime"),Ws=(e,t,o)=>{let r=o==="settings",n=typeof t=="boolean"?t:t.some(a=>e.isActive(a));return{"rounded p-1":!0,"hover:bg-primary/90 hover:text-primary-foreground":!n&&!r,"hover:bg-accent hover:text-accent-foreground":!n&&r,"bg-primary text-primary-foreground":n&&r,"bg-primary-foreground text-primary":n&&!r}},$ee=({editor:e,from:t="settings",onExpand:o})=>{let r=(0,C5.useRef)(null);if(!e)return null;let n=()=>{let s=window.prompt("URL");s&&e.chain().focus().extendMarkRange("link").setLink({href:s}).run()},a=()=>{e.chain().focus().unsetLink().run()};return(0,lt.jsxs)("div",{ref:r,id:"chai-rich-text-menu-bar",className:Mr("mb-1 flex flex-wrap gap-0.5 rounded-t-md border-b border-border bg-secondary p-1 text-foreground",{"mb-0 rounded-md border-none bg-background bg-primary text-primary-foreground":t==="canvas"}),children:[(0,lt.jsx)("button",{type:"button",onClick:()=>e.chain().focus().toggleBold().run(),className:Mr("",Ws(e,["bold"],t)),title:"Bold",children:(0,lt.jsx)(_o.FontBoldIcon,{className:"h-4 w-4"})}),(0,lt.jsx)("button",{type:"button",onClick:()=>e.chain().focus().toggleItalic().run(),className:Mr("",Ws(e,["italic"],t)),title:"Italic",children:(0,lt.jsx)(_o.FontItalicIcon,{className:"h-4 w-4"})}),(0,lt.jsx)("button",{type:"button",onClick:()=>e.chain().focus().toggleUnderline().run(),className:Mr("",Ws(e,["underline"],t)),title:"Underline",children:(0,lt.jsx)(_o.UnderlineIcon,{className:"h-4 w-4"})}),(0,lt.jsx)("button",{type:"button",onClick:()=>e.chain().focus().toggleStrike().run(),className:Mr("",Ws(e,["strike"],t)),title:"Strike",children:(0,lt.jsx)(_o.StrikethroughIcon,{className:"h-4 w-4"})}),(0,lt.jsx)("div",{className:"h-5 w-px border-l bg-transparent"}),(0,lt.jsx)(x5,{editor:e,from:t,menuRef:r}),(0,lt.jsx)("div",{className:"h-5 w-px border-l bg-transparent"}),(0,lt.jsx)(Rx,{editor:e,menuRef:r,from:t,trigger:(0,lt.jsxs)("button",{type:"button",className:Mr("flex items-center",Ws(e,["bulletList","orderedList"],t)),title:"Bullet List",children:[(0,lt.jsx)(_o.ListBulletIcon,{className:"h-4 w-4"}),(0,lt.jsx)(_o.CaretDownIcon,{className:"h-3 w-3 opacity-50"})]}),content:s=>(0,lt.jsxs)(lt.Fragment,{children:[(0,lt.jsxs)("div",{onClick:()=>{e.chain().focus().toggleBulletList().run(),s()},className:Mr("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",Ws(e,["bulletList"],t)),children:[(0,lt.jsx)(_o.ListBulletIcon,{className:"h-4 w-4"})," Unordered List"]}),(0,lt.jsxs)("div",{onClick:()=>{e.chain().focus().toggleOrderedList().run(),s()},className:Mr("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",Ws(e,["orderedList"],t)),children:[(0,lt.jsx)(_o.ValueIcon,{className:"h-4 w-4"}),"Ordered List"]})]})}),(0,lt.jsx)(Rx,{editor:e,menuRef:r,from:t,trigger:(0,lt.jsxs)("button",{type:"button",className:Mr("flex items-center",Ws(e,e.isActive({textAlign:"center"})||e.isActive({textAlign:"right"}),t)),title:"Text Alignment",children:[e.isActive({textAlign:"center"})?(0,lt.jsx)(_o.TextAlignCenterIcon,{className:"h-4 w-4"}):e.isActive({textAlign:"right"})?(0,lt.jsx)(_o.TextAlignRightIcon,{className:"h-4 w-4"}):(0,lt.jsx)(_o.TextAlignLeftIcon,{className:"h-4 w-4"}),(0,lt.jsx)(_o.CaretDownIcon,{className:"h-3 w-3 opacity-50"})]}),content:s=>(0,lt.jsxs)(lt.Fragment,{children:[(0,lt.jsxs)("div",{onClick:()=>{e.chain().focus().setTextAlign("left").run(),s()},className:Mr("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",Ws(e,e.isActive({textAlign:"left"}),t)),children:[(0,lt.jsx)(_o.TextAlignLeftIcon,{className:"h-4 w-4"})," Align Left"]}),(0,lt.jsxs)("div",{onClick:()=>{e.chain().focus().setTextAlign("center").run(),s()},className:Mr("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",Ws(e,e.isActive({textAlign:"center"}),t)),children:[(0,lt.jsx)(_o.TextAlignCenterIcon,{className:"h-4 w-4"})," Align Center"]}),(0,lt.jsxs)("div",{onClick:()=>{e.chain().focus().setTextAlign("right").run(),s()},className:Mr("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",Ws(e,e.isActive({textAlign:"right"}),t)),children:[(0,lt.jsx)(_o.TextAlignRightIcon,{className:"h-4 w-4"})," Align Right"]})]})}),e.isActive("link")?(0,lt.jsx)("button",{type:"button",onClick:a,className:Mr("",Ws(e,["link"],t)),title:"Remove Link",disabled:!e.isActive("link"),children:(0,lt.jsx)(_o.LinkBreak2Icon,{className:"h-3.5 w-3.5"})}):(0,lt.jsx)("button",{type:"button",onClick:n,className:Mr("",Ws(e,["link"],t)),title:"Add Link",children:(0,lt.jsx)(_o.Link2Icon,{className:"h-3.5 w-3.5"})}),o&&(0,lt.jsxs)(lt.Fragment,{children:[(0,lt.jsx)("div",{className:"h-5 w-px border-l bg-transparent"}),(0,lt.jsx)("button",{type:"button",onClick:o,className:Mr("",Ws(e,!1,t)),title:"Open in full screen mode",children:(0,lt.jsx)(_o.EnterFullScreenIcon,{className:"h-3.5 w-3.5"})})]})]})},ew=$ee});var k5,S5,w5,P5,T5,N5,E5,A5,I5,tw,zE=x(()=>{"use strict";k5=K(require("@tiptap/extension-color"),1),S5=K(require("@tiptap/extension-highlight"),1),w5=K(require("@tiptap/extension-link"),1),P5=K(require("@tiptap/extension-placeholder"),1),T5=K(require("@tiptap/extension-text-align"),1),N5=K(require("@tiptap/extension-text-style"),1),E5=K(require("@tiptap/extension-underline"),1),A5=require("@tiptap/react"),I5=K(require("@tiptap/starter-kit"),1),tw=({blockId:e,value:t="",onUpdate:o=()=>{},onBlur:r=()=>{},placeholder:n="",from:a="settings",style:s={}})=>(0,A5.useEditor)({extensions:[I5.default,N5.default,k5.default.configure({types:["textStyle"]}),S5.default.configure({multicolor:!0}),w5.default.configure({openOnClick:!1,HTMLAttributes:{class:"underline"}}),T5.default.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),E5.default,P5.default.configure({placeholder:n||"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],content:t||"",onUpdate:o,onBlur:r,editorProps:{attributes:{...s?{style:s}:{},class:a!=="canvas"?"text-sm p-1 px-2 rte":"rte"}}},[e])});function Vee(e){let t=e;for(;t;){if(t.style&&t.style.textAlign)return t.style.textAlign;let o=window.getComputedStyle(t).textAlign;if(o&&o!=="start"&&o!=="initial"&&o!=="inherit")return o;t=t.parentElement}return null}var B5,ow,Nh,or,wi,R5,D5,_5,L5,M5=x(()=>{"use strict";B5=require("@react-hookz/web"),ow=require("@tiptap/react"),Nh=require("lodash-es"),or=require("react");Qf();VE();zE();Kd();Zu();Tt();Ge();Ln();Ne();wi=require("react/jsx-runtime");R5=(0,or.memo)(({blockContent:e,editingElement:t,onClose:o,onChange:r,onEscape:n})=>{let{document:a}=Un(),s=tw({value:e,blockId:"active-inline-editing-element",placeholder:"Enter text here",onUpdate:({editor:c})=>r((c==null?void 0:c.getHTML())||""),onBlur:({editor:c,event:d})=>{if(!a)return;let p=d==null?void 0:d.relatedTarget,u=a.querySelector(".ProseMirror"),m=a.querySelector(".tippy-box"),g=a.querySelector("#chai-rich-text-menu-bar"),h=u==null?void 0:u.contains(p),f=m==null?void 0:m.contains(p),b=g==null?void 0:g.contains(p),y=window.document.getElementById("rte-widget-color-picker");if(!h&&!f&&!b&&!y){let k=(c==null?void 0:c.getHTML())||"";o(k)}},from:"canvas"});(0,or.useEffect)(()=>{var d,p;let c=Vee(t);c&&((d=s==null?void 0:s.commands)==null||d.setTextAlign(c)),(p=s==null?void 0:s.commands)==null||p.focus(),s==null||s.emit("focus",{editor:s,event:new FocusEvent("focus"),transaction:[]})},[t,s]);let i=(0,or.useMemo)(()=>{var p;let c="max-w-none shadow-none outline outline-[2px] [&_*]:shadow-none";if(!t)return c;let d=((p=t==null?void 0:t.className)==null?void 0:p.replace("sr-only",""))||"";return`${c} ${d}`},[t]),l=c=>{c.key==="Escape"&&n(c)};return s&&(0,wi.jsxs)("div",{onKeyDown:l,onClick:c=>c.stopPropagation(),className:"relative",children:[(0,wi.jsx)(ow.BubbleMenu,{editor:s,shouldShow:()=>s&&(s==null?void 0:s.isFocused),tippyOptions:{duration:100,arrow:!0,hideOnClick:!1},className:"w-max",children:(0,wi.jsx)(ew,{editor:s,from:"canvas"})}),(0,wi.jsx)(ow.EditorContent,{id:"active-inline-editing-element",onKeyDown:l,value:e,editor:s,className:i})]})});R5.displayName="RichTextEditor";D5=(0,or.memo)(({editingElement:e,blockContent:t,onClose:o,editorRef:r,onChange:n,onEscape:a})=>{let{document:s,window:i}=Un();(0,or.useEffect)(()=>{if(!(!s||!i))if(r.current){r.current.innerHTML=t,r.current.focus();let u=s.createRange(),m=i.getSelection();u.selectNodeContents(r.current),u.collapse(!1),m==null||m.removeAllRanges(),m==null||m.addRange(u),r.current.focus()}else o()},[t,s,r,o,i]);let l=(0,or.useMemo)(()=>{var m;let u=((m=e==null?void 0:e.tagName)==null?void 0:m.toLowerCase())||"div";return u==="button"?"div":u},[e]),c=(0,or.useCallback)(u=>{(u.key==="Enter"||u.key==="Escape")&&a(u)},[a]),d=(0,or.useCallback)(()=>{o()},[o]),p=(0,or.useMemo)(()=>{var u;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((u=e==null?void 0:e.className)==null?void 0:u.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:(0,Nh.cloneDeep)(e==null?void 0:e.style)||{},onInput:m=>{let g=m.target;g&&(g.innerText.trim()===""?(g.setAttribute("data-placeholder","Enter text here"),g.children.length>0&&g.children[0].remove()):m.target.removeAttribute("data-placeholder"),n(m.target.innerText))},onClick:m=>{m.stopPropagation(),m.preventDefault()}}},[e==null?void 0:e.className,e==null?void 0:e.style,n]);return(0,wi.jsx)(wi.Fragment,{children:(0,or.createElement)(l,{ref:r,onBlur:d,onKeyDown:c,...p})})});D5.displayName="MemoizedEditor";_5=(0,or.memo)(({block:e,children:t})=>{let o="content",{document:r}=Un(),{editingBlockId:n,editingItemIndex:a,setEditingBlockId:s,setEditingItemIndex:i}=us(),[l,c]=(0,or.useState)(null),d=(0,or.useRef)(null),{clearHighlight:p}=pa(),u=br(),{selectedLang:m}=fe(),[,g]=Pe(),h=(0,or.useRef)(null),f=n,{blockContent:b,blockType:y}=(0,or.useMemo)(()=>{var v;let C=e._type,P=e[o],B=Ct(e._type);return m&&((v=B==null?void 0:B.i18nProps)!=null&&v.includes(o))&&(0,Nh.has)(e,`${o}-${m}`)&&(P=(0,Nh.get)(e,`${o}-${m}`)),{blockContent:P,blockType:C}},[e,m]),k=(0,or.useCallback)(C=>{var B;let P=C||((B=d.current)==null?void 0:B.innerText);u([f],{[o]:P}),c(null),s(""),i(-1),g([]),f&&setTimeout(()=>g([f]),100)},[u,f,s,i,g]),w=(0,B5.useDebouncedCallback)(C=>{u([f],{[o]:C})},[f,e,u,m],1e3),N=(0,or.useCallback)(C=>{C.preventDefault(),f&&(h.current=f),k(),setTimeout(()=>{let P=h.current;h.current=null,P&&g([P])},100)},[f,k,g]);(0,or.useEffect)(()=>{var T;if(!f||!r)return;let C=`[data-block-id="${f}"]`,P=a>=0?`[data-block-index="${a}"]`:"",B=r.querySelector(`${C}${P}`);B&&((T=B==null?void 0:B.classList)==null||T.add("sr-only"),(0,or.startTransition)(()=>c(B)))},[f,y,r,a]);let I=(0,or.useMemo)(()=>l?(p(),["RichText","Paragraph"].includes(y)?(0,wi.jsx)(R5,{blockContent:b,editingElement:l,onChange:w,onClose:k,onEscape:N}):(0,wi.jsx)(D5,{editorRef:d,blockContent:b,editingElement:l,onClose:k,onChange:w,onEscape:N})):null,[l,p,y,b,k,w,N]);return(0,wi.jsxs)(wi.Fragment,{children:[I,t]})},(e,t)=>e.block._id===t.block._id&&e.block.content===t.block.content);_5.displayName="WithBlockTextEditor";L5=_5});var id,F5,js,bo,H5,U5,Eo,G5,O5,$5,zee,Dx,Wee,jee,qee,Kee,Yee,Jee,Qee,V5,Xee,rw,z5,W5=x(()=>{"use strict";id=require("jotai"),F5=require("jotai/utils"),js=require("lodash-es"),bo=require("react"),H5=require("react-error-boundary"),U5=require("sonner");zr();Wr();Jn();Oa();al();VF();e5();o5();UE();uf();Ke();lN();Zu();Tt();Yd();Nn();v0();c0();Ne();KS();qS();s5();c5();m5();M5();Eo=require("react/jsx-runtime"),G5=(0,bo.createContext)({index:-1,key:""}),O5=(0,bo.createContext)(0),$5=(0,bo.createContext)({inPartialBlock:!1}),zee={inPartialBlock:!0},Dx=(0,bo.createContext)(null),Wee=[],jee=["Heading","Paragraph","Link"],qee=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],Kee=({asyncProps:e,block:t,children:o})=>{let{editingBlockId:r,editingItemIndex:n}=us(),a=(0,bo.useMemo)(()=>Ct(t._type),[t._type]),{selectedLang:s,fallbackLang:i}=fe(),l=la(),[c]=(0,id.useAtom)(Sb),d=(0,js.get)(a,"component",null),{index:p,key:u}=(0,bo.useContext)(G5),{mode:m}=Pk(),g=YS(),{inPartialBlock:h}=(0,bo.useContext)($5),f=Zn(),b=m==="edit",{onMouseDown:y,onDragStart:k,onDragEnd:w}=$F(),N=(0,bo.useMemo)(()=>c?Ax(FE(t,s,a),l,{index:p,key:u}):FE(t,s,a),[t,s,a,l,c,p,u]),I=(0,bo.useMemo)(()=>QF(t,!0,g),[t,g]),C=(0,bo.useMemo)(()=>t5(t._id,XF(t._type)),[t._id,t._type]),[P]=(0,id.useAtom)(C),B=(0,bo.useMemo)(()=>{let R={"data-block-id":t._id,"data-block-type":t._type,"data-block-index":p};return b&&f?{...R,draggable:!r,onMouseDown:y,onDragStart:k,onDragEnd:w}:R},[t._id,t._type,p,b,f,y,k,w,r]),T=(0,bo.useMemo)(()=>({blockProps:B,inBuilder:m==="edit",inPartialBlock:h,lang:s||i,pageData:l,...N,...I,...P,...e}),[B,m,s,h,i,l,N,I,P,e]),v=(0,bo.useMemo)(()=>!qee.includes(t._type),[t._type]),S=(0,bo.useMemo)(()=>{let R=(0,js.get)(t,"_show",!0);return(0,js.isString)(R)?c?WF(R,l)!=="false":!0:R},[t,c,l]);if((0,js.isNull)(d)||!S)return null;let A=(0,Eo.jsx)(bo.Suspense,{children:(0,bo.createElement)(d,T,o({_id:t._id,_type:t._type,...(0,js.isArray)(N.repeaterItems)?{repeaterItems:ZF(N.repeaterItems,t),$repeaterItemsKey:N.$repeaterItemsKey}:{},...t.partialBlockId?{partialBlockId:t.partialBlockId}:"",...t.globalBlock?{partialBlockId:t.globalBlock}:""}))}),D=r===t._id&&(n===p||p<0)?(0,Eo.jsx)(L5,{block:t,children:A}):A;return v?(0,Eo.jsx)(H5.ErrorBoundary,{fallbackRender:d5,children:D}):D},Yee=({children:e,partialBlockId:t})=>{let o=q("gotoPage",js.noop),{saveState:r}=to(),{selectedLang:n,fallbackLang:a}=fe(),s=(0,bo.useCallback)(i=>{if(i.stopPropagation(),r!=="SAVED"){U5.toast.error("You have unsaved changes. Please save the page first.");return}o({pageId:t,lang:n||a})},[r,o,t,n,a]);return(0,Eo.jsxs)(Eo.Fragment,{children:[e,(0,Eo.jsx)("div",{className:"partial-overlay group absolute inset-0 z-50",children:(0,Eo.jsx)("div",{onDoubleClick:s,className:"flex h-full w-full items-center justify-center bg-background/10 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 group-hover:backdrop-opacity-85",children:(0,Eo.jsx)("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})]})},Jee=()=>(0,Eo.jsx)("div",{className:"flex items-center justify-center rounded-md border border-destructive bg-destructive/10 p-4 text-center text-sm text-destructive",children:(0,Eo.jsxs)("p",{children:["Maximum partial nesting depth (",4," levels) exceeded"]})}),Qee=({partialBlockId:e})=>{let{getPartialBlocks:t}=Dc(),o=(0,bo.useContext)(O5),r=(0,bo.useMemo)(()=>t(e),[t,e]),n=(0,bo.useMemo)(()=>(0,F5.splitAtom)((0,id.atom)(r)),[r]),a=x0(n),s=(0,bo.useMemo)(()=>({childrenMap:lC(r!=null?r:[]),getBlockAtom:a}),[r,a]);return o>=4?(0,Eo.jsx)(Jee,{}):(0,js.isEmpty)(r)?null:(0,Eo.jsx)(O5.Provider,{value:o+1,children:(0,Eo.jsx)($5.Provider,{value:zee,children:(0,Eo.jsx)(Yee,{partialBlockId:e,children:(0,Eo.jsx)(Dx.Provider,{value:s,children:(0,Eo.jsx)(rw,{type:"PartialBlock"})})})})})},V5=(0,bo.memo)(({id:e,contentSpacing:t})=>{var n;let o=(0,bo.useContext)(Dx),r=(n=o==null?void 0:o.getBlockAtom(e))!=null?n:null;return r?(0,Eo.jsx)(Xee,{blockAtom:r,contentSpacing:t}):null});V5.displayName="BlockSubtree";Xee=({blockAtom:e,contentSpacing:t})=>{var s;let o=(0,bo.useContext)(Dx),[r]=(0,id.useAtom)(e),n=(0,bo.useMemo)(()=>t?a5(r,t==="trail"):r,[r,t]),a=(s=o==null?void 0:o.childrenMap.has(n._id))!=null?s:!1;return(0,Eo.jsx)(l5,{block:n,children:i=>(0,Eo.jsx)(Kee,{block:n,asyncProps:i,children:({_id:l,_type:c,partialBlockId:d,repeaterItems:p,$repeaterItemsKey:u})=>c==="Repeater"?(0,js.isArray)(p)&&p.map((m,g)=>(0,Eo.jsx)(G5.Provider,{value:{index:g,key:u},children:(0,Eo.jsx)(rw,{parent:l,type:c})},`${l}-${g}`)):c==="GlobalBlock"||c==="PartialBlock"?(0,Eo.jsx)(id.Provider,{store:be,children:(0,Eo.jsx)(Qee,{partialBlockId:d})}):a?(0,Eo.jsx)(rw,{parent:l,type:c}):null})})},rw=({parent:e=null,type:t=""})=>{var a;let o=(0,bo.useContext)(Dx),r=(a=o==null?void 0:o.childrenMap.get(e||null))!=null?a:Wee,n=jee.includes(t);return(0,Eo.jsx)(Eo.Fragment,{children:r.map((s,i)=>(0,Eo.jsx)(V5,{id:s._id,contentSpacing:n?i===r.length-1?"trim":"trail":void 0},s._id))})},z5=()=>{let e=(0,id.useAtomValue)(JT),t=x0(Kp),o=(0,bo.useMemo)(()=>({childrenMap:e,getBlockAtom:t}),[e,t]);return(0,Eo.jsx)(Dx.Provider,{value:o,children:(0,Eo.jsx)(rw,{})})}});var nw,_x,j5,q5=x(()=>{"use strict";nw=require("jotai");zr();Ac();W5();_x=require("react/jsx-runtime"),j5=()=>{let e=(0,nw.useAtomValue)(QT),[t]=(0,nw.useAtom)(Fd);return(0,_x.jsx)(_x.Fragment,{children:e?(0,_x.jsx)(z5,{},t):null})}});var aw,K5,Y5=x(()=>{"use strict";aw=require("react");Ke();Sh();Rm();K5=(e,t)=>{var i;let o=(i=t==null?void 0:t.disabled)!=null?i:!1,[r]=Bm(),[,n]=kh(),a=q("htmlDir","ltr"),s=(0,aw.useMemo)(()=>{if(o)return{};let{width:l,height:c}=e;if(l>0&&l<r){let d=parseFloat((l/r).toFixed(2).toString()),p={},u=c*d,m=l*d;return c&&(p={height:100+(c-u)/u*100+"%",width:100+(l-m)/m*100+"%"}),{position:"relative",top:0,transform:`scale(${d})`,transformOrigin:a==="rtl"?"top right":"top left",...p,maxWidth:"none"}}return{}},[r,e,a,o]);return(0,aw.useEffect)(()=>{if(o)return;let{width:l}=e;if(l)if(l<r){let c=parseFloat((l/r).toFixed(2).toString());n(c*100)}else n(100)},[r,e,n,o]),s}});var tc,J5,Q5=x(()=>{"use strict";tc=require("react");Jn();Sh();Om();Rm();J5=({dimension:e,wrapperRef:t})=>{let[o]=Mm(),[r]=Bm(),[n]=kh(),[a]=NF(),[s]=AF(),i=(0,tc.useRef)(o);(0,tc.useEffect)(()=>{let c=t.current;c&&be.set(lp,{width:c.clientWidth,height:c.clientHeight})},[e,t]),(0,tc.useEffect)(()=>{var c,d;if(o&&!i.current){let p=(d=(c=t.current)==null?void 0:c.clientWidth)!=null?d:0,u=cp(be.get(Ci))/100;be.set(ml,{x:HS(r*u,p),y:RE})}else!o&&i.current&&(be.set(ml,{x:0,y:0}),be.set(Dm,"select"),be.set(_m,!1));i.current=o},[o]),(0,tc.useEffect)(()=>{if(!o)return;let c=be.get(lp),d=cp(be.get(Ci))/100,p=be.get(ml);be.set(ml,{x:HS(r*d,c.width),y:gg(p.y,s*d,c.height)})},[r]),(0,tc.useEffect)(()=>{o&&Lm(0,0)},[o,e,s]),(0,tc.useEffect)(()=>{let c=d=>{d.ctrlKey||d.metaKey||d.altKey||d.key!=="p"&&d.key!=="P"||wh(d.target)||GS()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[]),(0,tc.useEffect)(()=>{if(!o)return;let c=t.current;if(!c)return;let d=m=>{if(m.preventDefault(),m.ctrlKey||m.metaKey){let f=c.getBoundingClientRect(),b=cp(be.get(Ci)*Math.exp(-m.deltaY*.01));US(b,m.clientX-f.left,m.clientY-f.top);return}let g=m.deltaX,h=m.deltaY;m.shiftKey&&g===0&&(g=h,h=0),Lm(-g,-h)},p=m=>{if(!wh(m.target)){if(m.code==="Space"){m.repeat||(m.preventDefault(),be.set(_m,!0));return}m.ctrlKey||m.metaKey||m.altKey||((m.key==="v"||m.key==="V"||m.key==="Escape")&&be.set(Dm,"select"),(m.key==="h"||m.key==="H")&&be.set(Dm,"hand"))}},u=m=>{m.code==="Space"&&be.set(_m,!1)};return c.addEventListener("wheel",d,{passive:!1}),document.addEventListener("keydown",p),document.addEventListener("keyup",u),()=>{c.removeEventListener("wheel",d),document.removeEventListener("keydown",p),document.removeEventListener("keyup",u)}},[o,t]);let l=(0,tc.useMemo)(()=>{if(!o)return null;let c=cp(n)/100;return{position:"absolute",top:0,left:0,width:`${r}px`,height:`${Math.max(s,100)}px`,maxWidth:"none",margin:0,transform:`translate(${a.x}px, ${a.y}px) scale(${c})`,transformOrigin:"0 0"}},[o,n,a,r,s]);return{enabled:o,style:l}}});var Eh,WE,Zee,X5,Z5=x(()=>{"use strict";Eh=require("lodash-es"),WE=require("react");Qn();mg();Kd();Tk();Ge();fn();DS();Zee=(e,t)=>e.length===t.length&&e.every((o,r)=>o===t[r]),X5=()=>{let[e,t]=Pe(),[o,r]=ao(),{document:n}=Un(),{clearHighlight:a}=pa();return(0,WE.useEffect)(()=>{if((0,Eh.isEmpty)(e)||!(0,Eh.isEmpty)(o))return;let s=requestAnimationFrame(()=>{if(!(0,Eh.isEmpty)(o))return;let i=xh(n,(0,Eh.first)(e));if(i){let l=i.getAttribute("data-style-prop");if(l){let c=i.getAttribute("data-style-id"),d=i.getAttribute("data-block-parent");r([{id:c,prop:l,blockId:d}])}}});return()=>cancelAnimationFrame(s)},[n,e,r,o]),(0,WE.useEffect)(()=>()=>a(),[a]),jd(dt.CANVAS_BLOCK_SELECTED,s=>{s&&t(i=>Zee(i,s)?i:s)}),jd(dt.CANVAS_BLOCK_STYLE_SELECTED,s=>{if(!s)return;let{blockId:i,styleId:l,styleProp:c}=s;i&&(r([{id:l,prop:c,blockId:i}]),t(d=>d.length===1&&d[0]===i?d:[i]))}),jd(dt.CLEAR_CANVAS_SELECTION,()=>{a(),t([]),r([])}),null}});var eH,oc,tH,Rn,ete,oH,rH=x(()=>{"use strict";eH=require("lodash-es"),oc=require("react"),tH=require("react-wrap-balancer");GO();al();VO();qO();QO();DS();gF();DF();MF();HF();q5();Y5();Q5();mg();Ke();Ju();GN();Om();Rm();Lf();Z5();Rn=require("react/jsx-runtime"),ete=()=>{let[e]=Bm(),[,t]=Yk(),o=(0,oc.useRef)(null),r=(0,oc.useRef)(null),[n,a]=(0,oc.useState)({width:0,height:0}),[s]=Mm(),i=K5(n,{disabled:s}),{style:l}=J5({dimension:n,wrapperRef:r}),[,c]=rl(),d=q("loading",!1),p=q("htmlDir","ltr"),{onDragOver:u,onDrop:m,onDragEnd:g}=nl(),h=TL(),f=(0,oc.useCallback)(y=>{a(k=>({...k,width:y}))},[a]);(0,oc.useEffect)(()=>{if(!r.current)return;let{clientWidth:y,clientHeight:k}=r.current;a({width:y,height:k})},[r,e]);let b=(0,oc.useMemo)(()=>{let y=$O;return y=y.replace("__HTML_DIR__",p),y},[p]);return(0,Rn.jsx)(OF,{onMount:f,onResize:f,children:(0,Rn.jsxs)("div",{onMouseLeave:()=>setTimeout(()=>t(""),300),className:"relative mx-auto h-full w-full overflow-hidden pt-6",onDragOver:u,onDrop:m,onDragEnd:g,ref:r,children:[(0,Rn.jsxs)(TE,{contentDidMount:()=>c(o.current),ref:o,id:"canvas-iframe",style:s?l!=null?l:{}:{...i,...(0,eH.isEmpty)(i)?{width:`${e}px`}:{}},className:`relative mx-auto box-content h-full w-full max-w-full ${s?"shadow-lg":"transition-all duration-300 ease-linear"}`,initialContent:b,children:[(0,Rn.jsx)(jO,{}),(0,Rn.jsx)(BF,{pannable:s}),(0,Rn.jsx)(UO,{}),(0,Rn.jsx)(uF,{}),(0,Rn.jsxs)(tH.Provider,{children:[(0,Rn.jsxs)(MO,{children:[d?(0,Rn.jsx)("div",{className:"h-full p-4",children:(0,Rn.jsx)(da,{className:"h-full"})}):(0,Rn.jsx)(j5,{}),(0,Rn.jsx)(JO,{})]}),(0,Rn.jsx)(X5,{})]}),(0,Rn.jsx)(Rn.Fragment,{children:h.isVisible&&(0,Rn.jsx)("div",{id:"placeholder",className:`pointer-events-none absolute z-[99999] max-w-full ${h.isEmpty?"bg-purple-500/10 outline-dashed outline-2 -outline-offset-4 outline-purple-500":"rounded-full bg-green-500"}`,style:{top:h.top,left:h.left,width:h.width,height:h.height}})})]}),s&&(0,Rn.jsx)(_F,{})]})})},oH=ete});var sw,tte,Ah,iw=x(()=>{"use strict";sw=require("jotai"),tte=(0,sw.atom)(null),Ah=()=>(0,sw.useAtom)(tte)});var jE,lw,nH,mp,aH,sH=x(()=>{"use strict";jE=require("lodash-es"),lw=require("lucide-react"),nH=require("react-i18next");Sh();Om();J();mp=require("react/jsx-runtime"),aH=()=>{let[e]=kh(),[t]=Mm(),{t:o}=(0,nH.useTranslation)();return t?(0,mp.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,mp.jsx)(E,{size:"sm",variant:"ghost",className:"size-2 h-6 w-6 rounded-md p-1","aria-label":o("Zoom out"),title:o("Zoom out"),onClick:()=>DE(e/1.2),children:(0,mp.jsx)(lw.Minus,{className:"h-3 w-3"})}),(0,mp.jsxs)("button",{type:"button",className:"w-10 px-1 text-center text-xs text-foreground/50 hover:text-foreground",title:o("Reset zoom"),onClick:TF,children:[(0,jE.round)(e,0),"%"]}),(0,mp.jsx)(E,{size:"sm",variant:"ghost",className:"size-2 h-6 w-6 rounded-md p-1","aria-label":o("Zoom in"),title:o("Zoom in"),onClick:()=>DE(e*1.2),children:(0,mp.jsx)(lw.Plus,{className:"h-3 w-3"})})]}):(0,mp.jsxs)("div",{className:"px-2 text-xs text-foreground/50",children:[(0,jE.round)(e,0),"%"]})}});var cw,iH,hg,lH,cH=x(()=>{"use strict";cw=require("lucide-react"),iH=require("react-i18next");Om();J();hg=require("react/jsx-runtime"),lH=()=>{let[e,t]=$S(),{t:o}=(0,iH.useTranslation)();return(0,hg.jsxs)("div",{className:"flex items-center gap-0.5 rounded-md border border-border bg-muted/40 p-0.5",children:[(0,hg.jsx)(E,{size:"sm","aria-label":o("Select"),variant:e==="select"?"secondary":"ghost",className:`h-6 w-6 rounded-sm p-1 ${e==="select"?"bg-orange text-orange-foreground hover:bg-orange/90":"text-foreground/50"}`,title:`${o("Select")} (V)`,onClick:()=>t("select"),children:(0,hg.jsx)(cw.MousePointer2,{className:"h-3.5 w-3.5"})}),(0,hg.jsx)(E,{size:"sm","aria-label":o("Hand tool"),variant:e==="hand"?"secondary":"ghost",className:`h-6 w-6 rounded-sm p-1 ${e==="hand"?"bg-orange text-orange-foreground hover:bg-orange/90":"text-foreground/50"}`,title:`${o("Hand tool")} (H)`,onClick:()=>t("hand"),children:(0,hg.jsx)(cw.Hand,{className:"h-3.5 w-3.5"})})]})}});var dH,pH,ote,mH,uH=x(()=>{"use strict";dH=require("jotai"),pH=require("jotai/utils"),ote=(0,pH.atomWithStorage)("selectedBreakpoints",["XS","MD","XL"]),mH=()=>{let[e,t]=(0,dH.useAtom)(ote);return[e,t]}});var fH,rc,ld,KE,ur,qE,rte,gH,YE,JE=x(()=>{"use strict";fH=require("@radix-ui/react-icons"),rc=require("lodash-es"),ld=require("lucide-react"),KE=require("react-i18next");pn();Ke();Rm();uH();J();Sr();Xk();ur=require("react/jsx-runtime"),qE=require("react"),rte=[{title:"Mobile (Base)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:(0,ur.jsx)(ld.Smartphone,{}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:(0,ur.jsx)(ld.Smartphone,{className:"rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:(0,ur.jsx)(ld.Tablet,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:(0,ur.jsx)(ld.Tablet,{className:"rotate-90"}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:(0,ur.jsx)(ld.Laptop,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:(0,ur.jsx)(ld.Monitor,{}),width:1920}],gH=({openDelay:e=400,tooltip:t=!0,title:o,currentBreakpoint:r,breakpoint:n,width:a,icon:s,content:i="",onClick:l})=>{let{t:c}=(0,KE.useTranslation)(),d=n===r;return t?(0,ur.jsxs)(Zf,{openDelay:e,children:[(0,ur.jsx)(eh,{asChild:!0,children:(0,ur.jsx)(E,{onClick:()=>l(a),size:"icon-sm",variant:"ghost",className:`border-none text-foreground shadow-none hover:bg-accent ${d?"bg-accent":""}`,children:s})}),(0,ur.jsx)(og,{side:"bottom",className:"w-auto max-w-52",children:(0,ur.jsxs)("div",{className:"space-y-1",children:[(0,ur.jsx)("h4",{className:"text-xs font-semibold",children:c(o)}),(0,ur.jsx)("p",{className:"text-xs text-muted-foreground",children:c(i)})]})})]}):(0,ur.jsx)(E,{onClick:()=>l(a),size:"icon-sm",variant:d?"outline":"ghost",children:s})},YE=({openDelay:e=400,canvas:t=!1,tooltip:o=!0,buttonClass:r="",activeButtonClass:n=""})=>{let[a,,s]=Tx(),[i,l]=Bm(),[c,d]=mH(),p=c,u=d,{t:m}=(0,KE.useTranslation)(),g=q("breakpoints",rte),h=y=>{p.includes(y)?p.length>2&&u(p.filter(k=>k!==y)):u(k=>[...k,y])},f=y=>{t||s(y),l(y)},b=iC(t?i:a).toLowerCase();return g.length<4?(0,ur.jsx)("div",{className:"flex items-center rounded-md",children:(0,rc.map)(g,y=>(0,qE.createElement)(gH,{canvas:t,...y,onClick:f,key:y.breakpoint,currentBreakpoint:b,activeButtonClass:"bg-gray-700"}))}):(0,ur.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,ur.jsx)("div",{className:"flex items-center gap-px",children:(0,rc.map)(g.filter(y=>(0,rc.includes)(p,(0,rc.toUpper)(y.breakpoint))),y=>(0,qE.createElement)(gH,{canvas:t,openDelay:e,tooltip:o,...y,onClick:f,key:y.breakpoint,currentBreakpoint:b,buttonClass:r,activeButtonClass:n}))}),(0,ur.jsxs)(Yt,{children:[(0,ur.jsx)($t,{asChild:!0,children:(0,ur.jsx)(E,{size:"icon-sm",variant:"ghost",className:"mx-px h-6 w-6 outline-none",children:(0,ur.jsx)(fH.ChevronDownIcon,{className:"h-3 w-3"})})}),(0,ur.jsxs)(Vt,{align:"end",className:"w-48",children:[(0,ur.jsx)(Ua,{children:m("Screen sizes")}),(0,ur.jsx)(Hn,{}),(0,rc.map)(g,y=>(0,ur.jsx)(Jc,{disabled:y.breakpoint==="xs",onCheckedChange:()=>h((0,rc.toUpper)(y.breakpoint)),checked:(0,rc.includes)(p,(0,rc.toUpper)(y.breakpoint)),onSelect:k=>k.preventDefault(),children:m(y.title)},y.breakpoint))]})]})]})}});var Kr,yg,gl,cd,dw,nte,hH,nc,up,bg,ac,gp,fp,hp,Ih=x(()=>{"use strict";Kr=K(require("@radix-ui/react-alert-dialog"),1),yg=K(require("react"),1);J();st();gl=require("react/jsx-runtime"),cd=Kr.Root,dw=Kr.Trigger,nte=Kr.Portal,hH=yg.forwardRef(({className:e,...t},o)=>(0,gl.jsx)(Kr.Overlay,{className:G("fixed inset-0 z-50 bg-background/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:o}));hH.displayName=Kr.Overlay.displayName;nc=yg.forwardRef(({className:e,...t},o)=>(0,gl.jsxs)(nte,{children:[(0,gl.jsx)(hH,{}),(0,gl.jsx)(Kr.Content,{ref:o,className:G("bg-surface fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));nc.displayName=Kr.Content.displayName;up=({className:e,...t})=>(0,gl.jsx)("div",{className:G("flex flex-col space-y-2 text-center sm:text-left",e),...t});up.displayName="AlertDialogHeader";bg=({className:e,...t})=>(0,gl.jsx)("div",{className:G("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});bg.displayName="AlertDialogFooter";ac=yg.forwardRef(({className:e,...t},o)=>(0,gl.jsx)(Kr.Title,{ref:o,className:G("text-lg font-semibold text-foreground",e),...t}));ac.displayName=Kr.Title.displayName;gp=yg.forwardRef(({className:e,...t},o)=>(0,gl.jsx)(Kr.Description,{ref:o,className:G("text-sm text-muted-foreground",e),...t}));gp.displayName=Kr.Description.displayName;fp=yg.forwardRef(({className:e,...t},o)=>(0,gl.jsx)(Kr.Action,{ref:o,className:G(yb(),e),...t}));fp.displayName=Kr.Action.displayName;hp=yg.forwardRef(({className:e,...t},o)=>(0,gl.jsx)(Kr.Cancel,{ref:o,className:G(yb({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));hp.displayName=Kr.Cancel.displayName});var yH,bH,xH,Pi,pw,QE=x(()=>{"use strict";yH=require("@radix-ui/react-icons"),bH=require("react"),xH=require("react-i18next");ko();Ge();fn();Ih();J();Pi=require("react/jsx-runtime"),pw=({children:e})=>{let{t}=(0,xH.useTranslation)(),{setNewBlocks:o}=Ft(),[,r]=Pe(),[,n]=ao(),a=(0,bH.useCallback)(()=>{o([]),r([]),n([])},[o,r,n]);return(0,Pi.jsxs)(cd,{children:[(0,Pi.jsx)(dw,{asChild:!0,children:e||(0,Pi.jsx)(E,{size:"sm",variant:"ghost",className:"flex items-center",children:(0,Pi.jsx)(yH.EraserIcon,{})})}),(0,Pi.jsxs)(nc,{className:"border-border",children:[(0,Pi.jsxs)(up,{children:[(0,Pi.jsx)(ac,{className:"text-foreground",children:t("Clear whole canvas?")}),(0,Pi.jsx)(gp,{children:t("Are you sure you want to clear the page?")})]}),(0,Pi.jsxs)(bg,{children:[(0,Pi.jsx)(hp,{className:"text-foreground",children:t("Cancel")}),(0,Pi.jsx)(fp,{onClick:a,children:t("Yes")})]})]})]})}});var mw,xg,XE,ZE=x(()=>{"use strict";mw=require("lucide-react");Pf();J();xg=require("react/jsx-runtime"),XE=()=>{let{undo:e,redo:t}=Mc(),{canUndo:o,canRedo:r}=GD();return(0,xg.jsxs)("div",{className:"flex items-center gap-px px-px",children:[(0,xg.jsx)(E,{disabled:!o,size:"icon-sm",onClick:e,variant:"ghost",children:(0,xg.jsx)(mw.Undo2,{})}),(0,xg.jsx)(E,{disabled:!r,onClick:t,size:"icon-sm",variant:"ghost",children:(0,xg.jsx)(mw.Redo2,{})})]})}});var vH,uw,CH,Bh,kH,po,SH,wH=x(()=>{"use strict";vH=require("@radix-ui/react-dropdown-menu"),uw=require("@radix-ui/react-icons"),CH=require("jotai"),Bh=require("lucide-react"),kH=require("react-i18next");Oa();sH();cH();JE();QE();ZE();Ke();Im();Om();J();Sr();Wd();po=require("react/jsx-runtime"),SH=()=>{let e=q("flags.darkMode",!1),t=q("flags.dataBinding",!0),[o,r]=(0,CH.useAtom)(Sb),{t:n}=(0,kH.useTranslation)(),a=e,s=t,[i,l]=ec(),[c,d]=Mm();return(0,po.jsxs)("div",{className:"flex h-10 items-center justify-between px-2",children:[(0,po.jsx)("div",{className:"flex items-center",children:(0,po.jsxs)("div",{className:"flex items-center",children:[(0,po.jsx)(YE,{canvas:!0,openDelay:400,activeButtonClass:"bg-gray-200"}),(0,po.jsx)("div",{className:"h-4 w-px border-l bg-transparent"}),(0,po.jsx)(aH,{}),(0,po.jsx)("div",{className:"h-4 w-px border-l bg-transparent"}),(0,po.jsx)(XE,{})]})}),(0,po.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,po.jsx)(lH,{}):null,(0,po.jsxs)(Yt,{children:[(0,po.jsx)($t,{asChild:!0,children:(0,po.jsx)(E,{size:"sm",variant:"ghost",className:"size-2 h-7 w-7 rounded-md p-1",children:(0,po.jsx)(Bh.MoreVertical,{className:"h-2 w-2"})})}),(0,po.jsxs)(Vt,{className:"w-44 border-border text-xs",side:"bottom",align:"end",children:[(0,po.jsx)(Uk,{className:"px-2 py-1 font-light text-foreground/50",children:n("ACTIONS")}),(0,po.jsx)(ye,{disabled:!1,onClick:p=>p.preventDefault(),className:"flex items-center gap-x-2 text-xs",children:(0,po.jsx)(pw,{children:(0,po.jsxs)("div",{className:"flex items-center gap-x-2 text-xs",children:[(0,po.jsx)(uw.EraserIcon,{})," ",n("Clear canvas")]})})}),(0,po.jsx)(vH.DropdownMenuSeparator,{className:"my-1 h-px bg-accent"}),a?(0,po.jsxs)(ye,{onSelect:p=>p.preventDefault(),className:"py-1.5",children:[(0,po.jsx)(Bh.SunMoon,{}),(0,po.jsx)("span",{className:"flex-1",children:n("Dark Mode")}),(0,po.jsx)(On,{checked:i,onCheckedChange:()=>l(!i)})]}):null,s?(0,po.jsxs)(ye,{onSelect:p=>p.preventDefault(),className:"py-1.5",children:[(0,po.jsx)(uw.LightningBoltIcon,{}),(0,po.jsx)("span",{className:"flex-1",children:n("Data Binding")}),(0,po.jsx)(On,{checked:o,onCheckedChange:()=>r(!o)})]}):null,(0,po.jsxs)(ye,{onSelect:p=>p.preventDefault(),className:"py-1.5",children:[(0,po.jsx)(Bh.Hand,{}),(0,po.jsx)("span",{className:"flex-1",children:n("Pannable Canvas")}),(0,po.jsx)(On,{checked:c,onCheckedChange:()=>d(!c)})]})]})]})]})]})}});var Wa,yp=x(()=>{"use strict";Wa={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokm\xE5l",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"P\u0101li",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volap\xFCk",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"}});var IH={};et(IH,{default:()=>AH});function AH(){let{t:e}=(0,EH.useTranslation)(),[t,o]=(0,bp.useState)(!1),[r,n]=Ah(),[a,s]=(0,bp.useState)((r==null?void 0:r.initialCode)||""),[i]=Pe(),l=br(),c=Fc(),{selectedLang:d}=fe(),p=(0,bp.useMemo)(()=>(0,NH.get)(Wa,d,d),[d]),u=(0,TH.useThrottledCallback)(h=>{if(!r)return;let f=PH(h);c([r.blockId],{[r.blockProp]:f})},[],300),m=(0,bp.useCallback)(()=>{if(t&&r){let h=PH(a);l([r.blockId],{[r.blockProp]:h})}},[t,r,a,l]);return(0,bp.useEffect)(()=>{r&&!i.includes(r.blockId)&&(m(),n(null))},[i,r,m,n]),(0,Ti.jsx)(Te,{open:!0,onOpenChange:()=>{m(),n(null)},children:(0,Ti.jsxs)(we,{className:"flex max-w-5xl flex-col gap-0 space-y-0 p-0",children:[(0,Ti.jsx)(Oe,{className:"shrink-0 border-b border-border px-4 py-2",children:(0,Ti.jsx)(Ie,{className:"flex items-center justify-between",children:(0,Ti.jsxs)("div",{children:[(0,Ti.jsx)("h3",{className:"text-sm font-semibold",children:e("HTML Code Editor")}),(0,Ti.jsxs)("div",{className:"flex items-center space-x-2 text-xs font-light text-muted-foreground",children:[p&&(0,Ti.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5",children:p}),(0,Ti.jsx)("span",{children:e("Scripts will be only executed in preview and live mode.")})]})]})})}),(0,Ti.jsx)("div",{className:"flex-1 overflow-hidden p-0 text-foreground",children:(0,Ti.jsx)(Ro,{value:r?Gf(a):"",onChange:h=>{let f=h.target.value;o(!0),s(f),u(f)},className:"min-h-[450px] border-none font-extralight",placeholder:"<!-- Enter your HTML code here -->"})})]})})}var TH,NH,bp,EH,Ti,PH,BH=x(()=>{"use strict";TH=require("@react-hookz/web"),NH=require("lodash-es"),bp=require("react"),EH=require("react-i18next");Ak();iw();Tt();Ge();Ln();qt();gs();yp();Ti=require("react/jsx-runtime"),PH=e=>{let t=document.createElement("div");return t.innerHTML=e,t.innerHTML}});var RH,Lx,DH,Ni,ate,ste,eA,tA=x(()=>{"use strict";RH=require("lodash-es"),Lx=K(require("react"),1),DH=require("react-error-boundary");rH();pk();Ke();iw();Lf();wH();Ni=require("react/jsx-runtime"),ate=Lx.default.lazy(()=>Promise.resolve().then(()=>(BH(),IH))),ste=()=>{let[e]=Ah(),t=q("onError",RH.noop);return(0,Ni.jsx)("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:(0,Ni.jsxs)("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden",children:[(0,Ni.jsx)(SH,{}),(0,Ni.jsx)(Lx.Suspense,{fallback:(0,Ni.jsx)(da,{className:"h-full"}),children:(0,Ni.jsx)(DH.ErrorBoundary,{fallback:(0,Ni.jsx)(im,{}),onError:t,children:(0,Ni.jsx)(oH,{})})}),e?(0,Ni.jsx)(Lx.Suspense,{fallback:(0,Ni.jsx)(da,{className:"h-full"}),children:(0,Ni.jsx)(ate,{})}):null]})})},eA=ste});var _H,Hm,LH,MH,sc,OH,FH=x(()=>{"use strict";_H=require("@radix-ui/react-icons"),Hm=require("lodash-es"),LH=require("react"),MH=require("react-i18next");al();Qn();Pa();zl();J();rs();Ne();sc=require("react/jsx-runtime"),OH=({block:e,disabled:t,parentId:o,position:r})=>{let{type:n,icon:a,label:s,disabledReason:i}=e,l=t||e.disabled,{addCoreBlock:c,addPredefinedBlock:d}=Xn(),p=()=>{if((0,Hm.has)(e,"blocks")){let f=(0,Hm.isFunction)(e.blocks)?e.blocks():e.blocks;d(hi(f),o||null,r)}else c(e,o||null,r);Gt.publish(dt.CLOSE_ADD_BLOCK)},u=Zn(),{t:m}=(0,MH.useTranslation)(),{onDragStart:g,onDragEnd:h}=nl();return(0,sc.jsx)(sc.Fragment,{children:(0,sc.jsxs)(Fo,{delayDuration:1e3,children:[(0,sc.jsx)(Ho,{asChild:!0,children:(0,sc.jsxs)(E,{variant:"outline",disabled:l,onClick:p,onDragStart:f=>!l&&g(f,{...e,label:s,icon:a}),onDragEnd:h,draggable:u&&!l,className:`group flex h-fit flex-col items-center justify-center gap-1 whitespace-normal py-2 ${(0,Hm.kebabCase)(`chai-block-${n}`)}`,children:[(0,LH.createElement)(a||_H.BoxIcon,{className:"w-4 h-4 mx-auto group-hover:scale-95 transition-transform","data-add-core-block-icon":n}),(0,sc.jsx)("p",{className:"max-w-full line-clamp-1 truncate hyphens-auto break-words text-center text-xs font-light leading-tight",children:(0,Hm.capitalize)(m(s||n))})]})}),(0,sc.jsx)(Bo,{children:(0,sc.jsx)("p",{children:l&&i?i:m(s||n)})})]},s)})}});var Um,HH,oA,rA=x(()=>{"use strict";Um=require("lodash-es");Mx();Ha();er();Ne();HH=require("react/jsx-runtime"),oA=({parentId:e,position:t,gridCols:o="grid-cols-2",disableBlockGroupsSidebar:r=!1})=>{let n=Fu(),{data:a}=xt(),s=(a==null?void 0:a.pageType)||"page",i=(0,Um.groupBy)(n,"category"),l=(0,Um.filter)(i.core,d=>S_(d,s)),c=(0,Um.uniq)((0,Um.map)(l,"group"));return(0,HH.jsx)(gw,{gridCols:o,parentId:e,position:t,groups:c,blocks:l,disableBlockGroupsSidebar:r})}});var UH,nA,GH,Ei,ite,aA,sA=x(()=>{"use strict";UH=require("@radix-ui/react-icons"),nA=require("react"),GH=require("react-i18next");Qn();Pa();zl();Rr();J();No();gs();Em();Ei=require("react/jsx-runtime"),ite=({parentId:e,position:t,fromSidebar:o})=>{let{t:r}=(0,GH.useTranslation)(),[n,a]=(0,nA.useState)(""),{addPredefinedBlock:s}=Xn(),[i,l]=(0,nA.useState)(!1),c=async()=>{l(!0);let d=await tN(n),p=await $a(d);s([...p],e,t),a(""),l(!1),Gt.publish(dt.CLOSE_ADD_BLOCK)};return(0,Ei.jsxs)("div",{className:`space-y-4 py-4 ${o?"w-full":"max-w-full"}`,children:[(0,Ei.jsx)("p",{className:`text-muted-foreground ${o?"text-xs":"text-sm"}`,children:r("Use HTML snippets from Tailwind CSS component libraries")}),(0,Ei.jsxs)("div",{className:"space-y-2",children:[(0,Ei.jsx)(Q,{children:r("Tailwind HTML snippet")}),(0,Ei.jsx)(Ro,{onChange:d=>a(d.target.value),rows:12,value:n,placeholder:r("Enter your code snippet here"),className:"resize-none overflow-x-auto whitespace-pre text-xs font-extralight"})]}),(0,Ei.jsx)("div",{className:"flex justify-end",children:(0,Ei.jsx)(E,{disabled:n.trim()===""||i,onClick:()=>c(),size:"sm",className:"w-fit",children:i?(0,Ei.jsxs)(Ei.Fragment,{children:[(0,Ei.jsx)(UH.CircleIcon,{className:"mr-2 h-4 w-4 animate-spin"})," ",r("Importing...")]}):r("Import HTML")})})]})},aA=ite});var hw,fw,Gm,iA,yw,bw=x(()=>{"use strict";hw=require("jotai"),fw=require("lodash-es"),Gm=require("react"),iA=(0,hw.atom)({}),yw=e=>{let[t,o]=(0,hw.useAtom)(iA),r=(0,Gm.useMemo)(()=>(e==null?void 0:e.getBlocksList)||(()=>[]),[e]),n=(0,fw.get)(t,`${e==null?void 0:e.id}.blocks`,null),a=(0,fw.get)(t,`${e==null?void 0:e.id}.loading`,"idle"),s=(0,fw.get)(t,`${e==null?void 0:e.id}.error`,!1),i=(0,Gm.useRef)("idle");(0,Gm.useEffect)(()=>{(async()=>{if(e&&!(a==="complete"||i.current==="loading")){i.current="loading",o(c=>({...c,[e==null?void 0:e.id]:{loading:"loading",blocks:[],error:!1}}));try{let c=await r(e);i.current="idle",o(d=>({...d,[e==null?void 0:e.id]:{loading:"complete",blocks:c||[],error:!1}}))}catch(c){i.current="idle",o(d=>({...d,[e==null?void 0:e.id]:{loading:"complete",blocks:[],error:!0}}))}}})()},[e,n,a,i,o,r]);let l=(0,Gm.useCallback)(c=>{o(d=>({...d,[c]:{loading:"idle",blocks:[],error:!1}}))},[o]);return{data:n||[],isLoading:a==="loading",isError:s,resetLibrary:l}}});var $H,VH,zH=x(()=>{"use strict";$H=require("jotai");Oa();VH=()=>(0,$H.useAtom)(kb)});var fl,lA,$m,qs,WH,Rh=x(()=>{"use strict";fl=K(require("@radix-ui/react-scroll-area"),1),lA=K(require("react"),1);st();$m=require("react/jsx-runtime"),qs=lA.forwardRef(({className:e,children:t,...o},r)=>(0,$m.jsxs)(fl.Root,{ref:r,className:G("relative overflow-hidden",e),...o,children:[(0,$m.jsx)(fl.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),(0,$m.jsx)(WH,{}),(0,$m.jsx)(fl.Corner,{})]}));qs.displayName=fl.Root.displayName;WH=lA.forwardRef(({className:e,orientation:t="vertical",...o},r)=>(0,$m.jsx)(fl.ScrollAreaScrollbar,{ref:r,orientation:t,className:G("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-1.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-1.5 flex-col border-t border-t-transparent p-[1px]",e),...o,children:(0,$m.jsx)(fl.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-muted-foreground/25 hover:bg-muted-foreground/40"})}));WH.displayName=fl.ScrollAreaScrollbar.displayName});var Vm,jH,Ox,xw=x(()=>{"use strict";Vm=require("lodash-es");al();Kd();Ge();Em();jH=require("react/jsx-runtime"),Ox=({block:e,html:t,blocks:o,children:r,onDragStart:n,onDragEnd:a,draggable:s,className:i="",type:l="Box"})=>{let{onDragStart:c,onDragEnd:d}=nl(),p=Zn(),[,u]=Pe(),{clearHighlight:m}=pa(),g=s!==void 0?s:p;return(0,jH.jsx)("div",{draggable:g,onDragStart:async b=>{try{if(n){n(b);return}let y=null;if(l==="Image"){if(!(e!=null&&e.image))return;y={type:"Image",blocks:[{_type:"Image",styles:"#styles:,w-full h-full object-cover",image:e==null?void 0:e.image,alt:(e==null?void 0:e.alt)||"",_name:(e==null?void 0:e.name)||"Image"}]}}else if(t){let k=typeof t=="function"?await t():t,w=await $a(k);if((0,Vm.isEmpty)(w))return;y={type:"Box",blocks:w,name:(0,Vm.get)(w,"0._type","Block")}}else if(o){let k=typeof o=="function"?await o():o;if((0,Vm.isEmpty)(k))return;y={type:"Box",blocks:k,name:(0,Vm.get)(k,"0._type","Block")}}else if(e){let k=typeof e=="function"?await e():e;y=typeof k=="object"?(0,Vm.omit)(k,["component","icon"]):k}if(!y)return;c(b,y,!0),setTimeout(()=>{u([]),m()},200)}catch(y){console.error("Error in ChaiDraggableBlock drag start:",y)}},onDragEnd:b=>{a?a(b):d()},className:`${g?"cursor-grab active:cursor-grabbing":""} ${i}`.trim(),children:r})}});function Yr({value:e,setValue:t,placeholder:o,onKeyDown:r,autoFocus:n=!1,disabled:a=!1,className:s="",autoComplete:i="on"}){let{t:l}=(0,qH.useTranslation)();return(0,xp.jsx)("div",{className:"relative w-full",children:(0,xp.jsxs)("div",{className:"relative",children:[(0,xp.jsx)(Ce,{placeholder:l(o||"Search blocks..."),value:e,onChange:c=>t(c.target.value),onKeyDown:r,autoFocus:n,disabled:a,name:"search-input",autoComplete:i,className:G("h-8 w-full pr-8",s)}),e?(0,xp.jsx)(E,{variant:"ghost",size:"icon-sm",onClick:()=>t(""),disabled:a,className:"absolute right-1 top-1/2 -translate-y-1/2 p-0 hover:bg-transparent hover:text-destructive",children:(0,xp.jsx)(vw.Cross1Icon,{className:"h-2.5 w-2.5 text-muted-foreground"})}):(0,xp.jsx)(E,{variant:"ghost",size:"icon-sm",className:"pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer p-0 hover:bg-transparent hover:text-destructive",children:(0,xp.jsx)(vw.MagnifyingGlassIcon,{className:"h-2.5 w-2.5 text-muted-foreground hover:text-foreground"})})]})})}var vw,qH,xp,hl=x(()=>{"use strict";vw=require("@radix-ui/react-icons"),qH=require("react-i18next");J();fo();st();xp=require("react/jsx-runtime")});var Fx,YH,JH,QH,Ao,ja,XH,Ee,KH,lte,cte,cA,dA=x(()=>{"use strict";Fx=require("@radix-ui/react-icons"),YH=require("cnfast"),JH=K(require("fuse.js"),1),QH=require("jotai"),Ao=require("lodash-es"),ja=require("react"),XH=require("react-i18next");al();Ac();Us();Qn();Pa();zl();bw();zH();Rr();J();No();Rh();Gs();rs();st();Ne();Em();xw();hl();Ee=require("react/jsx-runtime"),KH=({block:e,library:t,parentId:o=void 0,position:r=-1})=>{let[n,a]=(0,ja.useState)(!1),s=(0,ja.useMemo)(()=>(t==null?void 0:t.getBlock)||(()=>[]),[t]),{addCoreBlock:i,addPredefinedBlock:l}=Xn(),c=(0,Ao.get)(e,"name",(0,Ao.get)(e,"label")),d=(0,Ao.get)(e,"description",""),{onDragStart:p,onDragEnd:u}=nl(),m=Zn(),g=(0,QH.useSetAtom)(Ol),h=(0,ja.useCallback)(async b=>{if(b.stopPropagation(),(0,Ao.has)(e,"component")){i(e,o,r),Gt.publish(dt.CLOSE_ADD_BLOCK);return}a(!0);let y=await s({library:t,block:e});typeof y=="string"&&(y=await $a(y)),(0,Ao.isEmpty)(y)||l(hi(y),o,r),Gt.publish(dt.CLOSE_ADD_BLOCK),setTimeout(()=>a(!1),1e3)},[i,l,e,s,t,o,r]);return(0,Ee.jsxs)(Fo,{children:[(0,Ee.jsx)(Ho,{asChild:!0,children:(0,Ee.jsx)(Ox,{draggable:m,onDragStart:b=>{m&&(p(b,{type:"Box",name:c},!0),s({library:t,block:e}).then(async y=>{typeof y=="string"&&(y=await $a(y)),g(k=>k&&{...k,blocks:y})}))},onDragEnd:u,children:(0,Ee.jsxs)("div",{onClick:n?()=>{}:h,className:(0,YH.clsx)("relative mt-2 overflow-hidden rounded-md border border-border duration-200 hover:border-blue-500 hover:shadow-xl",m?"":"cursor-pointer"),children:[n&&(0,Ee.jsxs)("div",{className:"absolute flex h-full w-full items-center justify-center bg-background/70",children:[(0,Ee.jsx)(Fx.ReloadIcon,{className:"h-4 w-4 animate-spin text-white"}),(0,Ee.jsx)("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),e.preview?(0,Ee.jsx)(qo,{src:e.preview,className:"min-h-[45px] w-full rounded-md",alt:c}):(0,Ee.jsxs)("div",{className:"flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center",children:[(0,Ee.jsx)("p",{className:"font-medium text-gray-800",children:c}),d&&(0,Ee.jsx)("p",{className:"text-sm text-gray-600",children:d})]})]})})}),(0,Ee.jsx)(Bo,{children:(0,Ee.jsx)("div",{className:"max-w-xs",children:(0,Ee.jsx)("p",{className:"font-medium",children:c})})})]})},lte=({parentId:e,position:t,fromSidebar:o})=>{let[r,n]=VH(),a=jb(),s=a.find(S=>S.id===r)||(0,Ao.first)(a),{data:i,isLoading:l,isError:c,resetLibrary:d}=yw(s),[p,u]=(0,ja.useState)(""),m=(0,ja.useMemo)(()=>i&&Array.isArray(i)&&i.length>0?new JH.default(i,{keys:["name","label","description","group"],threshold:.4,ignoreLocation:!0}):null,[i]),g=(0,ja.useMemo)(()=>!p.trim()||!m?[]:m.search(p).map(S=>S.item),[p,m]),h=p.trim()&&!(0,Ao.isEmpty)(g)?g:i||[],f=(0,Ao.groupBy)(h,"group"),[b,y]=(0,ja.useState)(null),k=(0,ja.useMemo)(()=>(0,Ao.isEmpty)((0,Ao.keys)(f))?null:b&&f[b]?b:(0,Ao.first)((0,Ao.keys)(f))||null,[f,b]),w=(0,Ao.get)(f,k||"",[]),N=(0,ja.useRef)(null),{t:I}=(0,XH.useTranslation)(),C=(0,ja.useRef)(null);(0,ja.useEffect)(()=>{var A;let S=(A=C.current)==null?void 0:A.querySelector("[data-radix-scroll-area-viewport]");S&&S.scrollTo({top:0,behavior:"smooth"})},[s,k]);let P=S=>{N.current&&(clearTimeout(N.current),N.current=null),N.current=setTimeout(()=>{N.current&&y(S)},400)},B=()=>{s!=null&&s.id&&d(s.id)};if(l)return(0,Ee.jsxs)("div",{className:"flex animate-pulse flex-col space-y-1 py-2",children:[(0,Ee.jsx)("div",{className:"h-7 w-full rounded-md bg-accent"}),(0,Ee.jsx)("div",{className:"h-7 w-full rounded-md bg-accent"}),(0,Ee.jsx)("div",{className:"h-7 w-full rounded-md bg-accent"}),(0,Ee.jsx)("div",{className:"h-3"}),(0,Ee.jsx)("div",{className:"h-36 w-full rounded-md bg-accent"}),(0,Ee.jsx)("div",{className:"h-36 w-full rounded-md bg-accent"}),(0,Ee.jsx)("div",{className:"h-36 w-full rounded-md bg-accent"})]});let T=(0,Ao.filter)(w,(S,A)=>A%2===0),v=(0,Ao.filter)(w,(S,A)=>A%2===1);return(0,Ee.jsx)(Ee.Fragment,{children:(0,Ee.jsx)("div",{className:"flex h-full max-h-full flex-col py-2",children:(0,Ee.jsx)("div",{className:"bg-surface relative flex h-full max-h-full flex-1 overflow-hidden",children:(0,Ee.jsxs)("div",{className:`flex h-full flex-1 ${o?"flex-col":""}`,children:[(0,Ee.jsxs)("div",{className:`flex max-h-full min-w-60 flex-col gap-1 ${o?"pb-2":"w-60 max-w-60 px-1 pr-2"}`,children:[(0,Ee.jsx)("div",{className:"space-y-0",children:(0,Ee.jsxs)(So,{value:s==null?void 0:s.id,onValueChange:n,children:[(0,Ee.jsx)(ho,{className:"w-full",children:(0,Ee.jsx)(Do,{placeholder:I("Select library"),children:s==null?void 0:s.name})}),(0,Ee.jsx)(yo,{children:a.map(S=>(0,Ee.jsx)(gt,{value:S.id,children:S.name},S.id))})]})}),(0,Ee.jsxs)("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:[!o&&(0,Ee.jsx)("hr",{className:"mt-1 border-border"}),(0,Ee.jsx)("div",{className:`no-scrollbar h-full max-h-full flex-1 overflow-y-auto ${o?"":"pb-20"}`,children:(0,Ao.isEmpty)(f)?(0,Ee.jsx)("div",{className:"mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center",children:p?(0,Ee.jsx)("p",{className:"text-sm",children:I("No matching blocks found")}):c?(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)("p",{className:"text-sm",children:I("Failed to load the UI library. Try again")}),(0,Ee.jsxs)(E,{onClick:B,variant:"outline",size:"sm",className:"gap-2",children:[(0,Ee.jsx)(Fx.ReloadIcon,{className:"h-4 w-4"}),I("Retry")]})]}):(0,Ee.jsx)(Q,{children:I("This library is empty")})}):o?(0,Ee.jsxs)(So,{value:k!=null?k:"",onValueChange:y,children:[(0,Ee.jsx)(ho,{className:"w-full",children:(0,Ee.jsx)(Do,{placeholder:I("Select a group")})}),(0,Ee.jsx)(yo,{children:(0,Ao.map)(f,(S,A)=>(0,Ee.jsx)(gt,{value:A,children:(0,Ao.capitalize)(I(A.toLowerCase()))},A))})]}):(0,Ao.map)(f,(S,A)=>(0,Ee.jsxs)("div",{onMouseEnter:()=>P(A),onMouseLeave:()=>N.current&&clearTimeout(N.current),role:"button",onClick:()=>y(A),className:G("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",A===k?"bg-primary text-primary-foreground hover:bg-primary/80":""),children:[(0,Ee.jsx)("span",{children:(0,Ao.capitalize)(I(A.toLowerCase()))}),(0,Ee.jsx)(Fx.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},A))})]}),!(0,Ao.isEmpty)(f)&&(0,Ee.jsx)(Yr,{value:p,setValue:u})]}),(0,Ee.jsx)("div",{className:`flex h-full max-h-full w-full flex-col border-border ${o?"":"border-l"}`,children:(0,Ee.jsxs)(qs,{ref:C,onMouseEnter:()=>N.current&&clearTimeout(N.current),className:"z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",children:[(0,Ao.isEmpty)(w)&&!(0,Ao.isEmpty)(f)?(0,Ee.jsx)("div",{className:"flex h-full flex-col items-center justify-center p-6 text-center",children:(0,Ee.jsx)("p",{className:"text-sm",children:I("No blocks found in this group")})}):(0,Ee.jsxs)("div",{className:`grid w-full gap-2 ${o?"grid-cols-1 pb-20":"grid-cols-2 px-2"}`,children:[(0,Ee.jsx)("div",{className:"flex flex-col gap-1",children:T.map((S,A)=>(0,Ee.jsx)(KH,{parentId:e,position:t,block:S,library:s},`block-${A}`))}),(0,Ee.jsx)("div",{className:"flex flex-col gap-1",children:v.map((S,A)=>(0,Ee.jsx)(KH,{parentId:e,position:t,block:S,library:s},`block-second-${A}`))})]}),(0,Ee.jsx)("br",{}),(0,Ee.jsx)("br",{}),(0,Ee.jsx)("br",{})]})})]})})})})},cte=({parentId:e,position:t,fromSidebar:o})=>(0,Ee.jsx)(lte,{parentId:e,position:t,fromSidebar:o}),cA=cte});var e4,Dh,Cw,kw,vg,dte,pte,ZH,t4,o4=x(()=>{"use strict";e4=require("@radix-ui/react-icons"),Dh=require("jotai"),Cw=require("lodash-es"),kw=require("react");Mx();Yd();vg=require("react/jsx-runtime"),dte=(0,Dh.atom)({blocks:[],groups:[],isLoading:!0,error:null}),pte=(0,Dh.atom)(!1),ZH=e=>{if(!e)return"";let t=e.replace(/[-_]/g," ");return t=t.replace(/([a-z])([A-Z])/g,"$1 $2"),t.split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")},t4=({parentId:e,position:t,gridCols:o="grid-cols-2",disableBlockGroupsSidebar:r=!1})=>{let{data:n,isLoading:a,refetch:s,error:i}=kf(),[l,c]=(0,Dh.useAtom)(dte),[d,p]=(0,Dh.useAtom)(pte),u=Sf();(0,kw.useEffect)(()=>{if(!d||Object.keys(l.blocks).length===0)if(i)c({blocks:[],groups:[],isLoading:!1,error:i}),p(!0);else if(!a&&Object.keys(n||{}).length>0){let h=Object.entries(n).map(([b,y])=>{let k=y,w=k.type||"partial",N=ZH(w);return{type:"PartialBlock",label:ZH(k.name||b),description:k.description||"",icon:e4.FrameIcon,group:N,category:"partial",partialBlockId:b,_name:k.name}}),f=(0,Cw.uniq)((0,Cw.map)(h,"group"));c({blocks:h,groups:f,isLoading:!1,error:null}),p(!0)}else a?c(h=>({...h,isLoading:!0,error:null})):!a&&Object.keys(n||{}).length===0&&(c({blocks:[],groups:[],isLoading:!1,error:"No partial blocks available"}),p(!0))},[a,n,d,p,c,l.blocks,i]);let m=()=>{c(h=>({...h,isLoading:!0,error:null})),p(!1),s()},g=(0,kw.useMemo)(()=>l.blocks.map(h=>{let{canAdd:f,reason:b}=u(h.partialBlockId);return{...h,disabled:!f,disabledReason:b}}),[l.blocks,u]);return l.isLoading?(0,vg.jsx)("div",{className:"flex items-center justify-center p-8 text-center text-muted-foreground",children:"Loading partial blocks..."}):l.error||l.blocks.length===0?(0,vg.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground",children:[(0,vg.jsx)("p",{children:l.error||"No partial blocks available"}),(0,vg.jsx)("button",{onClick:m,className:"rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",children:"Refresh"})]}):(0,vg.jsx)(gw,{gridCols:o,parentId:e,position:t,groups:l.groups,blocks:g,disableBlockGroupsSidebar:r})}});var Sw,n4,gr,Ks,fr,pA,Xe,r4,gw,a4,mte,Hx,Mx=x(()=>{"use strict";Sw=require("jotai"),n4=require("jotai/utils"),gr=require("lodash-es"),Ks=require("lucide-react"),fr=K(require("react"),1),pA=require("react-i18next");Oa();FH();rA();sA();dA();o4();Qn();Ha();zm();Pa();ko();Ke();Yd();mn();Rr();J();No();Rh();xi();tn();hl();Xe=require("react/jsx-runtime"),r4=[{name:"basic",icon:(0,Xe.jsx)(Ks.PanelTop,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-primary text-primary-foreground"},{name:"typography",icon:(0,Xe.jsx)(Ks.Type,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-success text-success-foreground"},{name:"media",icon:(0,Xe.jsx)(Ks.TvMinimalPlay,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-warning text-warning-foreground"},{name:"layout",icon:(0,Xe.jsx)(Ks.PanelTop,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-info text-info-foreground"},{name:"form",icon:(0,Xe.jsx)(Ks.BookText,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-purple text-purple-foreground"},{name:"advanced",icon:(0,Xe.jsx)(Ks.LayoutPanelLeft,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-orange text-orange-foreground"},{name:"other",icon:(0,Xe.jsx)(Ks.BrickWall,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-aqua text-aqua-foreground"}],gw=({groups:e,blocks:t,parentId:o,position:r,gridCols:n="grid-cols-4",disableBlockGroupsSidebar:a})=>{var v;let{t:s}=(0,pA.useTranslation)(),[i]=Pt(),[l,c]=(0,fr.useState)(""),d=(0,fr.useRef)(null),[p]=(0,Sw.useAtom)(a4),u=(v=(0,gr.find)(i,S=>S._id===o))==null?void 0:v._type,[m,g]=(0,fr.useState)("all"),[,h]=(0,fr.useState)(null),f=(0,fr.useRef)(null),b=q("flags.dragAndDrop",!0);(0,fr.useEffect)(()=>{let S=setTimeout(()=>{var A;(A=d.current)==null||A.focus()},0);return()=>clearTimeout(S)},[p]);let y=(0,fr.useCallback)(S=>{c(S),S&&(g("all"),h(null))},[]);(0,fr.useEffect)(()=>(f.current=(0,gr.debounce)(S=>{g(S)},500),()=>{f.current&&f.current.cancel()}),[]);let k=(0,fr.useCallback)(S=>{h(S),f.current&&f.current(S)},[]),w=(0,fr.useCallback)(()=>{h(null),f.current&&f.current.cancel()},[]),N=(0,fr.useCallback)(S=>{f.current&&f.current.cancel(),g(S),h(null)},[]),I=(0,fr.useMemo)(()=>l?(0,gr.values)(t).filter(S=>{var A,D;return(((A=S.label)==null?void 0:A.toLowerCase())+" "+((D=S.type)==null?void 0:D.toLowerCase())).includes(l.toLowerCase())}):t,[t,l]),C=(0,fr.useMemo)(()=>l?e.filter(S=>(0,gr.reject)((0,gr.filter)((0,gr.values)(I),{group:S}),{hidden:!0}).length>0):e.filter(S=>(0,gr.reject)((0,gr.filter)((0,gr.values)(t),{group:S}),{hidden:!0}).length>0),[t,I,e,l]),P=(0,fr.useMemo)(()=>(0,gr.sortBy)(C,S=>{let A=r4.findIndex(D=>D.name===S);return A===-1?99:A}),[C]),B=(0,fr.useMemo)(()=>m==="all"?I:(0,gr.filter)((0,gr.values)(I),{group:m}),[I,m]),T=(0,fr.useMemo)(()=>m==="all"?P:[m],[P,m]);return(0,Xe.jsxs)("div",{className:"mx-auto flex h-full w-full flex-col py-2",children:[(0,Xe.jsx)(Yr,{value:l,setValue:y}),(0,Xe.jsxs)("div",{className:"sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2",children:[!a&&P.length>0&&(0,Xe.jsx)("div",{className:"w-1/4 min-w-[120px] border-r border-border",children:(0,Xe.jsx)(qs,{className:"h-full",children:(0,Xe.jsxs)("div",{className:"space-y-1 pr-2",children:[(0,Xe.jsx)(E,{variant:m==="all"?"secondary":"ghost",size:"sm",onClick:()=>N("all"),onMouseEnter:()=>k("all"),onMouseLeave:w,className:"w-full justify-start font-medium",children:s("All")},"sidebar-all"),P.map(S=>(0,Xe.jsx)(E,{variant:m===S?"secondary":"ghost",size:"sm",onClick:()=>N(S),onMouseEnter:()=>k(S),onMouseLeave:w,className:"w-full justify-start font-medium",children:(0,gr.capitalize)(s(S.toLowerCase()))},`sidebar-${S}`))]})})}),(0,Xe.jsx)("div",{className:`h-full flex-1 overflow-hidden ${!a&&P.length>0?"w-3/4":"w-full"}`,children:(0,Xe.jsx)(qs,{id:"add-blocks-scroll-area",className:"no-scrollbar h-full",children:C.length===0&&l?(0,Xe.jsx)("div",{className:"flex flex-col items-center justify-center p-8 text-center text-muted-foreground",children:(0,Xe.jsxs)("p",{children:[s("No blocks found matching"),' "',l,'"']})}):(0,Xe.jsx)("div",{className:`${a?"p-0":"p-4"} space-y-6 pt-2`,children:T.map((S,A)=>{let D=r4.find(R=>R.name===S);return(0,Xe.jsxs)("div",{className:"space-y-3",children:[(0,Xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xe.jsx)("div",{className:`flex h-6 w-6 items-center justify-center rounded-full ${(D==null?void 0:D.bg)||"bg-primary text-primary-foreground"}`,children:(D==null?void 0:D.icon)||(0,Xe.jsx)(Ks.PanelTop,{className:"h-4 w-4"})}),(0,Xe.jsx)(Q,{className:"text-xs uppercase text-primary-foreground",children:s(S.toLowerCase())})]}),(0,Xe.jsx)("div",{className:"grid gap-2 "+n,children:(0,gr.reject)(m==="all"?(0,gr.filter)((0,gr.values)(B),{group:S}):(0,gr.values)(B),{hidden:!0}).map((R,H)=>(0,Xe.jsx)(OH,{parentId:o,position:r,block:R,disabled:!b&&(!In(u,R.type)||!vk(u,R.type))},R.type+"-"+A+"-"+H))})]},S)})})})})]})]})},a4=(0,n4.atomWithStorage)("__add_block_tab","library"),mte=({className:e,showHeading:t=!0,parentId:o=void 0,position:r=-1,fromSidebar:n=!1})=>{let{t:a}=(0,pA.useTranslation)(),[s,i]=(0,Sw.useAtom)(a4),[,l]=(0,Sw.useAtom)(o0),c=q("flags.importHtml",!0),{data:d}=kf(),p=Object.keys(d||{}).length>0,{hasPermission:u}=kt();(0,fr.useEffect)(()=>{s==="partials"&&!p&&i("library")},[s,p,i]);let m=(0,fr.useCallback)(()=>{Gt.publish(dt.CLOSE_ADD_BLOCK)},[]),g=Y0(),h=c&&u(xe["pages:update"]),b=jb().length>0;return(0,fr.useEffect)(()=>{s==="library"&&!b&&i("core")},[s,b,i]),(0,Xe.jsxs)("div",{className:Co("flex h-full w-full flex-col overflow-hidden",e),children:[t?(0,Xe.jsxs)("div",{className:"mb-2 flex flex-col justify-between rounded-md px-2 py-1",children:[(0,Xe.jsx)("h1",{className:"flex flex-col items-baseline text-xl font-semibold text-foreground xl:flex-col",children:a("Add block")}),(0,Xe.jsx)("span",{className:"text-xs font-light leading-3 text-muted-foreground",children:a(s==="html"?"Enter or paste TailwindCSS HTML snippet":"Click to add block to page")})]}):null,(0,Xe.jsxs)(Dr,{onValueChange:y=>{l(""),i(y)},value:s,className:"flex h-full max-h-full flex-col overflow-hidden",children:[(0,Xe.jsxs)(Cr,{className:`flex items-center ${n?"h-max w-max justify-start":"w-full"}`,children:[b&&(0,Xe.jsx)(ut,{value:"library",className:n?"h-5 px-2 text-xs":"",children:a("Library")}),(0,Xe.jsx)(ut,{value:"core",className:n?"h-5 px-2 text-xs":"",children:a("Blocks")}),p&&(0,Xe.jsx)(ut,{value:"partials",className:n?"h-5 px-2 text-xs":"",children:a("Partials")}),h?(0,Xe.jsx)(ut,{value:"html",className:n?"h-5 px-2 text-xs":"",children:a("Import")}):null,(0,gr.map)(g,y=>(0,Xe.jsx)(ut,{value:y.id,className:n?"h-5 px-2 text-xs":"",children:fr.default.createElement(y.tab)},`tab-add-block-${y.id}`))]}),(0,Xe.jsx)(kr,{value:"core",className:"h-full max-h-full flex-1 pb-20",children:(0,Xe.jsx)("div",{className:"h-full max-h-full overflow-hidden",children:(0,Xe.jsx)("div",{className:"h-full w-full",children:(0,Xe.jsx)(oA,{gridCols:n?"grid-cols-2":"grid-cols-4",parentId:o,position:r,disableBlockGroupsSidebar:n})})})}),b&&(0,Xe.jsx)(kr,{value:"library",className:"h-full max-h-full flex-1 pb-8",children:(0,Xe.jsx)(cA,{fromSidebar:n,parentId:o,position:r})}),p&&(0,Xe.jsx)(kr,{value:"partials",className:"h-full max-h-full flex-1 pb-20",children:(0,Xe.jsx)("div",{className:"h-full max-h-full overflow-hidden",children:(0,Xe.jsx)("div",{className:"h-full w-full",children:(0,Xe.jsx)(t4,{gridCols:n?"grid-cols-2":"grid-cols-4",parentId:o,position:r,disableBlockGroupsSidebar:n})})})}),h?(0,Xe.jsx)(kr,{value:"html",className:"h-full max-h-full flex-1 pb-20 ",children:(0,Xe.jsx)(aA,{parentId:o,position:r,fromSidebar:n})}):null,(0,gr.map)(g,y=>(0,Xe.jsx)(kr,{value:y.id,children:fr.default.createElement(y.tabContent,{close:m,parentId:o,position:r})},`panel-add-block-${y.id}`))]})]})},Hx=mte});var s4,Cg,i4,dd,ute,mA,uA=x(()=>{"use strict";s4=require("@radix-ui/react-icons"),Cg=require("react"),i4=require("react-i18next");al();Mx();Qn();Tk();Zc();Ih();dd=require("react/jsx-runtime"),ute=()=>{let[e,t]=(0,Cg.useState)(null),[o,r]=(0,Cg.useState)(-1),[n,a]=(0,Cg.useState)(!1),s=Zn(),[,i]=ma(),l=(0,Cg.useCallback)(d=>{var p,u;s?i("add-block"):(t((p=d==null?void 0:d._id)!=null?p:null),r((u=d==null?void 0:d.position)!=null?u:-1),a(!0))},[s,i]),c=(0,Cg.useCallback)(()=>{t(null),r(-1),a(!1)},[]);return jd(dt.OPEN_ADD_BLOCK,l),jd(dt.CLOSE_ADD_BLOCK,c),{parentId:e,position:o,open:n,handleClose:c}},mA=()=>{let{t:e}=(0,i4.useTranslation)(),{parentId:t,position:o,open:r,handleClose:n}=ute();return(0,dd.jsx)(cd,{open:r,onOpenChange:n,children:(0,dd.jsxs)(nc,{className:"max-w-5xl overflow-hidden border-border",children:[(0,dd.jsxs)(up,{className:"flex flex-row items-center justify-between",children:[(0,dd.jsx)(ac,{className:"text-foreground",children:e("Add blocks")}),(0,dd.jsx)("button",{type:"button",onClick:n,"aria-label":e("Close dialog"),className:"text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:(0,dd.jsx)(s4.Cross2Icon,{className:"h-6 w-6"})})]}),(0,dd.jsx)("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:(0,dd.jsx)(Hx,{parentId:t!=null?t:"",position:o,showHeading:!1})})]})})}});var kg,l4=x(()=>{"use strict";kg=()=>null});var _h,c4,d4,Sg,p4,m4=x(()=>{"use strict";_h=require("lodash-es"),c4=require("react"),d4=require("react-i18next");iw();Tt();Ge();J();No();gs();yp();Ne();Ak();Sg=require("react/jsx-runtime"),p4=({id:e,placeholder:t})=>{let{t:o}=(0,d4.useTranslation)(),[,r]=Ah(),{selectedLang:n}=fe(),a=_e(),s=e.replace("root.",""),i=Ct(a==null?void 0:a._type),c=(0,_h.includes)((0,_h.get)(i,"i18nProps",[]),s)&&n?`${s}-${n}`:s,d=(0,_h.get)(a,c,""),p=(0,c4.useMemo)(()=>(0,_h.get)(Wa,n,n),[n]),u=()=>{let m=a==null?void 0:a._id;r({blockId:m,blockProp:c,placeholder:t,initialCode:d})};return(0,Sg.jsxs)("div",{className:"mt-2 flex flex-col gap-y-1",children:[(0,Sg.jsxs)(Q,{htmlFor:e,children:["HTML Code",p&&(0,Sg.jsxs)("small",{className:"text-[9px] text-zinc-400",children:["\xA0",p]})]}),(0,Sg.jsx)(Ro,{value:Gf(d),onClick:u,readOnly:!0,className:"w-64 break-before-all",placeholder:t||"Eg: <script>console.log('Hello, world!');</script>"}),(0,Sg.jsx)(E,{onClick:u,size:"sm",variant:"outline",className:"w-fit",children:o("Open code editor")})]})}});var Ux,Lh,u4,g4=x(()=>{"use strict";Ux=require("lodash-es");Ke();Ge();Tn();Lh=require("react/jsx-runtime"),u4=({id:e,value:t,onChange:o,onBlur:r})=>{let n=q("collections",[]),a=_e(),s=(0,Ux.get)(a,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1").replace("#",""),i=(0,Ux.find)(n,{id:s}),c=(0,Ux.get)(i,e==="root.filter"?"filters":"sorts",[]);return(0,Lh.jsx)("div",{children:(0,Lh.jsxs)("select",{className:"flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-xs shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",value:t,onChange:d=>o(d.target.value),onBlur:d=>r(e,d.target.value),children:[(0,Lh.jsx)("option",{value:"",children:"Select"}),c.map(d=>(0,Lh.jsx)("option",{value:d.id,children:d.name},d.id))]})})}});var b4={};et(b4,{IconPicker:()=>gte});var f4,h4,y4,wg,Ys,gte,x4=x(()=>{"use strict";f4=K(require("@iconify-json/lucide/icons.json"),1),h4=require("@radix-ui/react-icons"),y4=K(require("fuse.js"),1),wg=require("react");J();fo();Rs();Ys=require("react/jsx-runtime"),gte=({onSelectIcon:e})=>{let[t,o]=(0,wg.useState)(!1),[r,n]=(0,wg.useState)(""),a=(0,wg.useMemo)(()=>Object.entries(f4.default.icons||{}).map(([d,p])=>{let u=p.body||"",m=p.width||24,g=p.height||24,h=`<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-${d}"
214
+ width="${m}" height="${g}" viewBox="0 0 ${m} ${g}"
215
+ fill="none" stroke="currentColor"
216
+ stroke-width="2" stroke-linecap="round"
217
+ stroke-linejoin="round">${u}</svg>`;return{name:d,svg:h,body:u}}),[]),s=(0,wg.useMemo)(()=>new y4.default(a,{keys:["name"],threshold:.3,includeScore:!0}),[a]),i=(0,wg.useMemo)(()=>r.trim()?s.search(r).map(d=>d.item).slice(0,100):a.slice(0,100),[a,r,s]),l=c=>{e(c),o(!1),n("")};return(0,Ys.jsxs)(en,{open:t,onOpenChange:o,children:[(0,Ys.jsx)($r,{asChild:!0,children:(0,Ys.jsxs)(E,{variant:"outline",size:"sm",children:[(0,Ys.jsx)(h4.MagnifyingGlassIcon,{className:"h-4 w-4"}),"Pick Icon"]})}),(0,Ys.jsx)(Vr,{className:"w-[250px] p-0",align:"end",children:(0,Ys.jsxs)("div",{className:"flex flex-col",children:[(0,Ys.jsx)("div",{className:"border-b p-3",children:(0,Ys.jsx)(Ce,{placeholder:"Search icons...",value:r,onChange:c=>n(c.target.value),className:"h-8",autoFocus:!0})}),(0,Ys.jsx)("div",{className:"max-h-[300px] overflow-y-auto p-2",children:i.length>0?(0,Ys.jsx)("div",{className:"grid grid-cols-5 gap-1",children:i.map(c=>(0,Ys.jsx)("button",{onClick:()=>l(c.svg),title:c.name,className:"flex size-8 items-center justify-center rounded-md p-0 hover:bg-accent [&_svg]:size-[18px]",dangerouslySetInnerHTML:{__html:c.svg}},c.name))}):(0,Ys.jsx)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No icons found"})})]})})]})}});var Mh,v4,Ai,fte,hte,C4,k4=x(()=>{"use strict";Mh=require("react"),v4=require("react-i18next"),Ai=require("react/jsx-runtime"),fte=(0,Mh.lazy)(()=>Promise.resolve().then(()=>(x4(),b4)).then(e=>({default:e.IconPicker}))),hte=e=>{try{let t=e.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>");return t=t.replace(/>\s+</g,"><"),t=t.replace(/\n/g,"").replace(/\s{2,}/g," "),t=t.replace(/\s+=/g,"=").replace(/=\s+/g,"="),t=t.replace(/<!--[\s\S]*?-->/g,""),t.trim()}catch(t){return e}},C4=({value:e,onChange:t,id:o})=>{let{t:r}=(0,v4.useTranslation)(),[n,a]=(0,Mh.useState)(e||""),s=i=>{a(i);let l=hte(i);t(l)};return(0,Ai.jsxs)("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[(0,Ai.jsxs)("div",{className:"flex items-start gap-x-2",children:[(0,Ai.jsx)("div",{className:"bg-surface/50 flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input p-2 text-muted-foreground",children:n?(0,Ai.jsx)("div",{className:"h-8 w-8 [&>svg]:h-full [&>svg]:w-full",dangerouslySetInnerHTML:{__html:n}}):(0,Ai.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"SVG"})}),(0,Ai.jsx)("textarea",{id:o,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:n,onChange:i=>s(i.target.value),placeholder:r("Paste SVG code here"),rows:3,className:"no-scrollbar flex-1 resize-none rounded-md border border-input bg-transparent px-3 py-2 text-xs text-foreground shadow-sm transition-colors placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,Ai.jsx)("div",{className:"flex items-center justify-between",children:(0,Ai.jsx)("div",{className:"flex items-center gap-2",children:(0,Ai.jsx)(Mh.Suspense,{fallback:(0,Ai.jsx)("div",{className:"text-xs text-muted-foreground",children:"Loading..."}),children:(0,Ai.jsx)(fte,{onSelectIcon:s})})})})]})}});var S4,ww,Pw,yte,pd,bte,Gx,$x=x(()=>{"use strict";S4=require("class-variance-authority"),ww=K(require("react"),1);st();Pw=require("react/jsx-runtime"),yte=(0,S4.cva)("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-surface text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),pd=ww.forwardRef(({className:e,variant:t,...o},r)=>(0,Pw.jsx)("div",{ref:r,role:"alert",className:G(yte({variant:t}),e),...o}));pd.displayName="Alert";bte=ww.forwardRef(({className:e,...t},o)=>(0,Pw.jsx)("h5",{ref:o,className:G("mb-1 font-medium leading-none tracking-tight",e),...t}));bte.displayName="AlertTitle";Gx=ww.forwardRef(({className:e,...t},o)=>(0,Pw.jsx)("div",{ref:o,className:G("text-sm [&_p]:leading-relaxed",e),...t}));Gx.displayName="AlertDescription"});var w4,Vx,P4,yl,T4,N4=x(()=>{"use strict";w4=require("@radix-ui/react-icons"),Vx=require("react"),P4=require("react-i18next");$x();J();fo();yl=require("react/jsx-runtime"),T4=({close:e,onSelect:t,mode:o="image"})=>{let[r,n]=(0,Vx.useState)(""),[a,s]=(0,Vx.useState)(!1),[i,l]=(0,Vx.useState)(!1),[c,d]=(0,Vx.useState)(null),p=async m=>{if(!m.trim()){l(!1),d("Please enter a URL");return}try{s(!0),d(null),l(!0),d(null)}catch(g){l(!1),d("Error validating URL")}finally{s(!1)}},{t:u}=(0,P4.useTranslation)();return(0,yl.jsxs)("div",{className:"flex w-96 flex-col gap-4 p-4",children:[(0,yl.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:u(`${o.charAt(0).toUpperCase()+o.slice(1)} Manager`)}),c&&(0,yl.jsxs)(pd,{variant:"destructive",children:[(0,yl.jsx)(w4.ExclamationTriangleIcon,{className:"h-4 w-4"}),(0,yl.jsx)(Gx,{children:c})]}),(0,yl.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,yl.jsx)(Ce,{placeholder:u(`Enter ${o} URL`),value:r,onChange:m=>n(m.target.value),onKeyUp:()=>p(r)}),(0,yl.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,yl.jsx)(E,{variant:"outline",onClick:e,children:u("Cancel")}),(0,yl.jsx)(E,{onClick:()=>t({id:"dam-id",url:r,width:600,height:400,description:{en:"This is image description"}}),disabled:!i||a,children:u("Insert")})]})]})]})}});var E4,Wm,A4,jm,Tw=x(()=>{"use strict";E4=require("react");N4();Rr();qt();lm();Wm=require("react/jsx-runtime"),A4=({assetId:e,children:t,onSelect:o,mode:r="image",multiple:n=!1,open:a,onOpenChange:s})=>{let[i,l]=(0,E4.useState)(!1),c=a!==void 0,d=c?a:i,p=m=>{c||l(m),s==null||s(m)},u=(...m)=>{o.call(void 0,...m),p(!1)};return(0,Wm.jsxs)(Te,{open:d,onOpenChange:m=>p(m),children:[t?(0,Wm.jsx)(pf,{asChild:!0,children:t}):null,(0,Wm.jsxs)(we,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:[(0,Wm.jsx)(Ie,{className:"sr-only",children:"Media Manager"}),(0,Wm.jsx)("div",{className:"h-full w-full",children:(0,Wm.jsx)(Br,{slotId:jo.MEDIA_MANAGER,context:{close:()=>p(!1),onSelect:u,mode:r,assetId:e,multiple:n},multiple:!1,defaultComponent:T4})})]})]})};A4.displayName="MediaManagerModal";jm=A4});function I4(e,t,o){if(!e)return e;let{baseClasses:r,classes:n}=ys(e),a=l=>l.split(" ").filter(c=>c&&!(t&&c==="w-full")&&!(o&&c==="h-full")).join(" "),s=a(r),i=a(n);return`${lr}${s},${i}`}var B4=x(()=>{"use strict";dp();Tn()});var Ew,sn,Aw,R4,hn,Nw,xte,D4,_4=x(()=>{"use strict";Ew=require("@radix-ui/react-icons"),sn=require("lodash-es"),Aw=require("react"),R4=require("react-i18next");Wr();Us();Tw();B4();ko();Tt();Ge();J();fo();KS();Ne();hn=require("react/jsx-runtime"),Nw="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",xte=e=>{var n;if(!e||(0,sn.startsWith)(e,"data"))return"";let t=((n=e.split("/").pop())==null?void 0:n.split("?")[0])||"";return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico",".avif"].some(a=>t.toLowerCase().endsWith(a))?t:""},D4=({value:e,onChange:t,id:o,onBlur:r,uiSchema:n})=>{let{t:a}=(0,R4.useTranslation)(),{selectedLang:s,fallbackLang:i}=fe(),l=_e(),{updateBlocks:c}=Ft(),d=la(),p=!0,u=(n==null?void 0:n["ui:allowEmpty"])===!0,m=o.split(".").pop()||"",g=s?`_${m}Id-${s}`:`_${m}Id`,h=(0,sn.isEmpty)(s)&&(l==null?void 0:l._type)==="Image"&&(0,sn.has)(l,"assetId"),f=(0,sn.get)(l,g,h?l==null?void 0:l.assetId:""),b=(0,Aw.useMemo)(()=>{if(!e||!l||!/\{\{.*?\}\}/.test(e))return e;let C={...l,[m]:e},P=Ax(C,d,{index:-1,key:""});return(0,sn.get)(P,m,e)},[e,l,d,m]),y=!!f||b!==Nw&&b!=="",k=I=>{let C=(0,sn.isArray)(I)?(0,sn.first)(I):I;if(C){t(C==null?void 0:C.url);let P=C==null?void 0:C.width,B=C==null?void 0:C.height,T=g.includes("mobile");if(l!=null&&l._id){let v={};if(typeof C.description=="string")try{let A=JSON.parse(C.description);typeof A=="object"&&A!==null&&!Array.isArray(A)?v=Object.fromEntries(Object.entries(A).filter(([,D])=>typeof D=="string").map(([D,R])=>[D,R])):v={[i]:C.description}}catch(A){v={[i]:C.description}}else v=C.description||{};let S={...P&&{[T?"mobileWidth":"width"]:P},...B&&{[T?"mobileHeight":"height"]:B}};if(Object.keys(v).forEach(A=>{let D=v[A];D&&(A===i?(0,sn.set)(S,"alt",D):(0,sn.set)(S,`alt-${A}`,D))}),(0,sn.set)(S,g,C.id),(P||B)&&(l!=null&&l._type)&&(l!=null&&l.styles)){let A=Fl(l._type),D=(0,sn.get)(A,"styles","");l.styles===D&&(S.styles=I4(l.styles,P,B))}if((0,sn.isEmpty)(S))return;c([l._id],S)}}},w=(0,Aw.useCallback)(()=>{if(t(u?"":Nw),l!=null&&l._id){let C={},P=g.includes("mobile");(0,sn.set)(C,g,""),(0,sn.set)(C,P?"mobileWidth":"width",""),(0,sn.set)(C,P?"mobileHeight":"height",""),c([l._id],C)}},[l,t,c,g,u]),N=xte(b);return(0,hn.jsxs)("div",{className:"mt-1.5 flex items-start gap-x-3",children:[b?(0,hn.jsxs)("div",{className:"group relative",children:[(0,hn.jsx)("div",{className:"h-[72px] w-[72px] overflow-hidden",children:(0,hn.jsx)(qo,{src:b,className:"h-[72px] w-[72px] overflow-hidden rounded-md border border-border object-cover transition duration-200 "+(f&&f!==""?"cursor-pointer group-hover:scale-105 group-hover:opacity-50":""),alt:""})}),y&&(0,hn.jsx)(E,{type:"button",onClick:w,size:"icon-xs",variant:"destructive",className:"absolute -right-2 -top-2 z-20 h-5 w-5 rounded-full p-1",children:(0,hn.jsx)(Ew.Cross1Icon,{className:"!h-3 !w-3"})}),f&&f!==""&&(0,hn.jsx)(jm,{onSelect:k,assetId:f,children:(0,hn.jsx)(E,{size:"icon-xs",variant:"ghost",type:"button",className:"absolute inset-0 left-1/2 top-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center opacity-0 transition duration-200 group-hover:opacity-100",children:(0,hn.jsx)(Ew.Pencil2Icon,{className:"h-4 w-4 text-foreground"})})})]}):(0,hn.jsx)(jm,{onSelect:k,mode:"image",assetId:f,children:(0,hn.jsx)("div",{className:"h-[72px] w-[72px] cursor-pointer rounded-md border border-border bg-[radial-gradient(hsl(var(--muted-foreground)),transparent_1px)] duration-300 [background-size:10px_10px]"})}),(0,hn.jsxs)("div",{className:"flex w-3/5 flex-col",children:[p&&(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsx)("p",{className:"sr-only max-w-[250px] truncate pr-2 text-xs text-muted-foreground",children:N}),(0,hn.jsx)(jm,{onSelect:k,assetId:"",children:(0,hn.jsx)(E,{variant:"outline",size:"sm",children:!(0,sn.isEmpty)(b)&&b!==Nw?a("Replace image"):a("Choose image")})}),(0,hn.jsx)("div",{className:"text-center text-[10px] italic text-muted-foreground",children:"OR"})]}),(0,hn.jsx)(Ce,{id:o,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"!h-7 rounded-sm px-2 py-px text-xs",placeholder:a("Enter image URL"),value:e===Nw?"":e,onBlur:({target:{value:I}})=>r(o,I),onChange:I=>t(I.target.value)})]})]})}});function bl({className:e,variant:t,...o}){return(0,M4.jsx)("div",{className:G(vte({variant:t}),e),...o})}var L4,M4,vte,Oh=x(()=>{"use strict";L4=require("class-variance-authority");st();M4=require("react/jsx-runtime"),vte=(0,L4.cva)("inline-flex leading-tight items-center gap-1 text-[11px] cursor-pointer rounded-md border px-2.5 py-0.5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",active:"text-primary-foreground border-primary bg-primary px-2 py-px font-light",inactive:"text-foreground border-border bg-secondary hover:bg-accent px-2 py-px font-light"}},defaultVariants:{variant:"default"}})});var O4,F4,H4=x(()=>{"use strict";O4=require("lodash-es"),F4=e=>!!(!e||(0,O4.startsWith)(e,"data:image/svg+xml;base64")||e.includes("placehold.co"))});var Iw,U4,G4,gA,zx,$4,V4=x(()=>{"use strict";Iw=require("@tanstack/react-query"),U4=require("lucide-react"),G4=require("react-i18next"),gA=require("sonner");H4();ko();Tt();Ge();Zc();St();ng();rt();Kt();th();J();Oo();zx=require("react/jsx-runtime"),$4=({sourceProp:e,targetProp:t})=>{let{t:o}=(0,G4.useTranslation)(),r=he(),n=le(),a=Hc("AI_GENERATE_IMAGE_DESCRIPTION"),s=_e(),{updateBlocks:i}=Ft(),{languages:l,fallbackLang:c}=fe(),d=(0,Iw.useQueryClient)(),[,p]=ma(),u=s?s[e]:"",m=!u||F4(u),{mutate:g,isPending:h}=(0,Iw.useMutation)({mutationFn:async({blockId:f,url:b})=>{let y=[c,...l||[]];return{...await r(n,{action:$.AI_GENERATE_IMAGE_DESCRIPTION,data:{url:b,languages:y,model:a}}),blockId:f}},onSuccess:f=>{if(!f.translations)return;let b={};Object.entries(f.translations).forEach(([y,k])=>{y===c?b[t]=k:b[`${t}-${y}`]=k}),i([f.blockId],b),d.invalidateQueries({queryKey:[il]})},onError:f=>{f!=null&&f.canBuyCredits?gA.toast.error((0,zx.jsx)("p",{className:"font-medium",children:f.message||o("Failed to generate alt text")}),{action:{label:o("Buy Credits"),onClick:()=>p(ll)},duration:8e3}):gA.toast.error((f==null?void 0:f.message)||o("Failed to generate alt text"))}});return s?(0,zx.jsx)(E,{disabled:h||m,type:"button",variant:"ghost",size:"icon-xs",className:"h-5 w-5","aria-label":o(m?"Cannot generate for placeholder image":"Generate alt text with AI"),onClick:()=>g({blockId:s._id,url:u}),title:o(m?"Cannot generate for placeholder image":"Generate with AI"),children:h?(0,zx.jsx)(wt,{className:"text-orange !h-3 !w-3"}):(0,zx.jsx)(U4.Wand2Icon,{className:`text-orange !h-3 !w-3 ${m?"opacity-30":""}`})}):null}});function Gh({data:e,onSelect:t,dataType:o="value"}){let[r,n]=qm.default.useState(!1),a=q("collections",[]),s=qm.default.useMemo(()=>o==="array"?{...a.map(l=>l.id).reduce((l,c)=>({...l,["#"+c]:[]}),{}),...e}:e,[e,a,o]);return(0,hr.jsxs)(en,{open:r,onOpenChange:n,children:[(0,hr.jsxs)(Fo,{children:[(0,hr.jsx)(Ho,{asChild:!0,children:(0,hr.jsx)($r,{asChild:!0,children:(0,hr.jsx)(E,{size:"xs",variant:"ghost",className:"text-muted-foreground",role:"combobox","aria-expanded":r,children:(0,hr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:(0,hr.jsx)("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),(0,hr.jsx)(Bo,{children:(0,Hh.t)("Add field")})]}),(0,hr.jsx)(Vr,{className:"z-[1000]! relative w-60 p-0",align:"end",children:(0,hr.jsx)(Cte,{data:s,onSelect:(i,l)=>{t(i,l),n(!1)},dataType:o})})]})}var Km,Hh,Fh,qm,hr,Cte,Bw=x(()=>{"use strict";Km=require("@radix-ui/react-icons"),Hh=require("i18next"),Fh=require("lodash-es"),qm=K(require("react"),1);Ke();J();jp();Rs();rs();Tn();hr=require("react/jsx-runtime"),Cte=({data:e,onSelect:t,dataType:o})=>{let[r,n]=qm.default.useState([]),[a,s]=qm.default.useState(e),i=p=>Array.isArray(p)?"array":typeof p=="object"&&p!==null?"object":"value",l=qm.default.useCallback(p=>{let u=m=>o==="value"?m==="value"||m==="object":o==="array"?m==="array":m===o;p.type==="object"?(n(m=>[...m,p.key]),s(p.value)):u(p.type)&&t([...r,p.key].join("."),o)},[r,t,o]),c=qm.default.useCallback(()=>{if(r.length>0){let p=r.slice(0,-1);n(p),s(p.reduce((u,m)=>u[m],e))}},[r,e]),d=qm.default.useMemo(()=>a?Object.entries(a).map(([p,u])=>({key:p,value:u,type:i(u)})).filter(p=>!(0,Fh.startsWith)(p.key,"@")&&p.key.includes("/")?!1:o==="value"?p.type==="value"||p.type==="object":o==="array"?p.type==="array"||p.type==="object":o==="object"?p.type==="object":!0):[],[a,o]);return(0,hr.jsxs)(Yi,{className:"fields-command",children:[(0,hr.jsx)(Md,{className:"border-none",placeholder:"Search..."}),(0,hr.jsxs)(Ji,{children:[(0,hr.jsx)(Ml,{className:"flex h-24 items-center justify-center text-xs text-muted",children:(0,Hh.t)("No option found.")}),(0,hr.jsxs)(Wp,{children:[r.length>0&&(0,hr.jsxs)(as,{onSelect:c,className:"flex items-center gap-2 text-xs text-muted",children:[(0,hr.jsx)(Km.ChevronLeftIcon,{className:"!h-3 !w-3"}),(0,Hh.t)("Back")]}),d.map(p=>(0,hr.jsxs)(as,{value:p.key,disabled:!1,onSelect:()=>l(p),className:"flex items-center justify-between text-xs",children:[(0,hr.jsxs)("span",{className:"flex items-center gap-x-2",children:[(0,Fh.startsWith)(p.key,"@")?(0,hr.jsx)(Km.LoopIcon,{className:"h-3 w-3"}):(0,Fh.startsWith)(p.key,"#")?(0,hr.jsx)(Km.IdCardIcon,{className:"h-3 w-3"}):(0,hr.jsx)("div",{className:"h-px w-3 rounded-full border-b border-b-foreground bg-transparent font-light opacity-10"}),(0,Fh.startsWith)(p.key,"@")?(0,Hh.t)("Repeater Data"):(0,Fh.startsWith)(p.key,"#")?p.key.replace("#",""):p.key]}),(0,hr.jsxs)("div",{className:"flex items-center gap-2",children:[o==="object"&&p.type==="object"&&(0,hr.jsx)(E,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:u=>{u.stopPropagation(),t([...r,p.key].join("."),o)},children:(0,Hh.t)("Select")}),p.type==="object"&&(0,hr.jsx)(Km.ChevronRightIcon,{className:"h-3 w-3 opacity-50"})]})]},p.key))]})]})]})}});var vp,Wx,z4,Rw,fA=x(()=>{"use strict";vp=require("lodash-es"),Wx=require("react");Wr();Bw();Ke();Ge();Tn();z4=require("react/jsx-runtime"),Rw=({schema:e,onChange:t,id:o})=>{let r=la(),n=q("flags.dataBinding",!0),a=BD(),s=(0,Wx.useMemo)(()=>{if(a.length===1)return"";let c=a.find(u=>u._type==="Repeater"),p=(0,vp.get)(c,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${"@"}${(0,vp.startsWith)(p,"#")?`${p}/${c==null?void 0:c._id}`:p}`},[a]),i=(0,Wx.useMemo)(()=>(0,vp.first)((0,vp.get)(r,s.replace("@",""),[])),[s,r]),l=(0,Wx.useCallback)((c,d)=>{if(c=(0,vp.isEmpty)(s)?c:c.replace(`${s}`,"$index"),d==="array"||d==="object"){t(`{{${c}}}`,{},o);return}let p=h=>/[.,!?;:]/.test(h),u=(h,f,b)=>{let y="",k="",w=f>0?h[f-1]:"",N=f<h.length?h[f]:"";return f>0&&(w==="."||!p(w)&&w!==" ")&&(y=" "),f<h.length&&!p(N)&&N!==" "&&(k=" "),{text:y+b+k,prefixLength:y.length,suffixLength:k.length}},m=document.getElementById(o);if(!m)return;let g=document.getElementById(`chai-rte-${o}`)||document.getElementById(`chai-rte-modal-${o}`);if(g&&(g.querySelector(".ProseMirror")||g.__chaiRTE)){let h=g.__chaiRTE;if(h){let f=`{{${c}}}`;h.commands.focus();let{from:b,to:y}=h.state.selection;if(b!==y)h.chain().deleteSelection().insertContent(f).run();else{let{state:w}=h,N=w.selection.from,I=w.doc.textBetween(Math.max(0,N-1),N),C=w.doc.textBetween(N,Math.min(N+1,w.doc.content.size)),P="";N>0&&I!==" "&&!p(I)&&(P=" ");let B="";C&&C!==" "&&!p(C)&&(B=" "),h.chain().insertContent(P+f+B).run()}setTimeout(()=>t(h.getHTML(),{},o),100);return}}else{let h=m,f=h.selectionStart||0,b=h.value||"",y=h.selectionEnd||f;if(y>f){let C=`{{${c}}}`,{text:P}=u(b,f,C),B=b.slice(0,f)+P+b.slice(y);t(B,{},o);return}let w=`{{${c}}}`,{text:N}=u(b,f,w),I=b.slice(0,f)+N+b.slice(f);t(I,{},o)}},[o,t,s]);return n?(0,z4.jsx)(Gh,{data:{...i&&{[s]:i},...r},onSelect:l,dataType:e.binding==="array"?"array":"value"}):null}});var Cp,Ym,$h,so,kte,hA,yA=x(()=>{"use strict";Cp=require("@radix-ui/react-icons"),Ym=require("lodash-es"),$h=require("react");Wr();Tt();Ge();ea();Oh();No();yp();Ne();V4();fA();so=require("react/jsx-runtime"),kte=e=>{let{id:t,classNames:o,label:r,children:n,errors:a,help:s,hidden:i,required:l,schema:c,formData:d,onChange:p}=e,{selectedLang:u,fallbackLang:m,languages:g}=fe(),h=(0,$h.useMemo)(()=>(0,Ym.isEmpty)(g)?"":(0,Ym.isEmpty)(u)?m:u,[g,u,m]),f=(0,$h.useMemo)(()=>(0,Ym.get)(Wa,h,h),[h]),b=la(),y=_e(),k=Fu(),w=(0,$h.useMemo)(()=>y!=null&&y._type?(0,Ym.get)(k,[y._type,"i18nProps"],[]):[],[k,y]),[N,I]=(0,$h.useState)(null);if(i)return null;if(c.type==="boolean")return(0,so.jsx)("div",{className:o,children:n});let P=w==null?void 0:w.includes(t.replace("root.",""));if(c.type==="array"){let v=N===t;return(0,so.jsxs)("div",{className:`${o} relative`,children:[c.title&&(0,so.jsx)("div",{className:"flex items-center justify-between gap-1",children:(0,so.jsxs)("label",{htmlFor:t,onClick:()=>I(v?null:t),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[v?(0,so.jsx)(Cp.ChevronDownIcon,{className:"h-3 w-3"}):(0,so.jsx)(Cp.ChevronRightIcon,{className:"h-3 w-3"}),(0,so.jsx)(Cp.ListBulletIcon,{className:"h-3 w-3"}),(0,so.jsx)("span",{className:"text-xs font-light leading-tight",children:r}),"\xA0",(0,so.jsx)(bl,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:(0,so.jsx)("span",{className:"text-[9px] font-medium text-slate-600",children:d==null?void 0:d.length})}),c.description&&(0,so.jsx)(Ye,{content:c.description,side:"right",children:(0,so.jsx)(Cp.InfoCircledIcon,{className:"h-3 w-3 text-muted-foreground/70",onClick:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation()})})]})}),(d==null?void 0:d.length)===0?(0,so.jsx)("div",{className:"h-0 overflow-hidden",children:n}):(0,so.jsxs)("div",{className:`${v?"pt-0.5":"h-0 overflow-hidden"}`,children:[n,a,s]})]})}let B=t.replace("root.",""),T=w.includes(B)&&!(0,Ym.isEmpty)(u)&&(0,Ym.isEmpty)(d);return(0,so.jsxs)("div",{className:o,children:[c.title&&(0,so.jsxs)("div",{className:"flex items-center justify-between",children:[(0,so.jsxs)("div",{className:"flex items-center gap-2",children:[(0,so.jsxs)(Q,{htmlFor:t,className:c.type==="object"?"pb-2":"",children:[r," ",P&&(0,so.jsxs)("small",{className:"text-[9px] text-zinc-400",children:[" ",f]}),l&&c.type!=="object"?" *":null]}),c.description&&(0,so.jsx)(Ye,{content:c.description,side:"right",children:(0,so.jsx)(Cp.InfoCircledIcon,{className:"h-3 w-3 text-muted-foreground/70"})})]}),(0,so.jsxs)("div",{className:"flex items-center gap-1",children:[B==="alt"&&(y==null?void 0:y._type)==="Image"&&(0,so.jsx)($4,{sourceProp:"image",targetProp:"alt"}),!c.enum&&!c.oneOf&&b&&(0,so.jsxs)("span",{className:"flex items-center space-x-1",children:[T?(0,so.jsx)(Ye,{content:(0,so.jsxs)(so.Fragment,{children:["No translation provided. ",(0,so.jsx)("br",{}),"Using default language value."]}),side:"left",children:(0,so.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-triangle-alert-icon lucide-triangle-alert h-3 w-3 text-orange-400",children:[(0,so.jsx)("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),(0,so.jsx)("path",{d:"M12 9v4"}),(0,so.jsx)("path",{d:"M12 17h.01"})]})}):null,(0,so.jsx)(Rw,{schema:c,onChange:v=>{p(v,d,t)},id:t,formData:d})]})]})]}),n,a,s]})},hA=kte});var jx,W4,j4,Dw,Ia,Pg=x(()=>{"use strict";jx=K(require("@radix-ui/react-checkbox"),1),W4=require("@radix-ui/react-icons"),j4=K(require("react"),1);st();Dw=require("react/jsx-runtime"),Ia=j4.forwardRef(({className:e,...t},o)=>(0,Dw.jsx)(jx.Root,{ref:o,className:G("peer h-4 w-4 shrink-0 cursor-pointer rounded-sm border border-border hover:border-foreground/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:(0,Dw.jsx)(jx.Indicator,{className:G("flex items-center justify-center text-current"),children:(0,Dw.jsx)(W4.CheckIcon,{className:"h-4 w-4"})})}));Ia.displayName=jx.Root.displayName});var q4,K4,yn,Js,bA,zo,Ste,Y4,J4=x(()=>{"use strict";q4=require("@radix-ui/react-icons"),K4=require("@react-hookz/web"),yn=require("lodash-es"),Js=require("react"),bA=require("react-i18next");Ke();Tt();Pg();fo();No();yp();fA();zo=require("react/jsx-runtime"),Ste=({href:e,onChange:t})=>{let{t:o}=(0,bA.useTranslation)(),r=q("searchPageTypeItems",(w,N)=>[]),[n,a]=(0,Js.useState)(!1),[s,i]=(0,Js.useState)(!1),[l,c]=(0,Js.useState)(""),[d,p]=(0,Js.useState)([]),[u,m]=(0,Js.useState)(-1),g=(0,Js.useRef)(null);(0,Js.useEffect)(()=>{if(c(""),p([]),m(-1),i(!1),!e||n||!(0,yn.startsWith)(e,"pageType:"))return;let w=(0,yn.split)(e,":");(async()=>{let N=await r("",[(0,yn.get)(w,2,"page")]);N&&Array.isArray(N)&&c((0,yn.get)(N,[0,"name"],""))})()},[e]);let h=(0,K4.useDebouncedCallback)(async w=>{if((0,yn.isEmpty)(w))p([]);else{let N=await r("",w);p(N)}a(!1),m(-1)},[],300),f=w=>{var I;let N=["pageType",w.pageType||"page",(I=w.primaryPage)!=null?I:w.id];N[1]&&(t(N.join(":")),c(w.name),i(!1),p([]),m(-1))},b=w=>{switch(w.key){case"ArrowDown":w.preventDefault(),m(N=>N<d.length-1?N+1:N);break;case"ArrowUp":w.preventDefault(),m(N=>N>0?N-1:N);break;case"Enter":if(w.preventDefault(),d.length===0)return;u>=0&&f(d[u]);break;case"Escape":w.preventDefault(),y();break}};(0,Js.useEffect)(()=>{if(u>=0&&g.current){let w=g.current.children[u];w==null||w.scrollIntoView({block:"nearest"})}},[u]);let y=()=>{c(""),p([]),m(-1),i(!1),t("")},k=w=>{c(w),i(!(0,yn.isEmpty)(w)),a(!0),h(w)};return(0,zo.jsxs)("div",{children:[(0,zo.jsxs)("div",{className:"group relative flex items-center",children:[(0,zo.jsx)(Ce,{type:"text",value:l,onChange:w=>k(w.target.value),onKeyDown:b,placeholder:o("Search pages"),className:"pr-8"}),(0,zo.jsx)("div",{className:"absolute bottom-2 right-2 top-2 flex items-center gap-1.5",children:l&&(0,zo.jsx)("button",{onClick:y,className:"text-muted-foreground hover:text-foreground",title:o("Clear search"),children:(0,zo.jsx)(q4.Cross1Icon,{className:"h-4 w-4"})})})]}),(n||!(0,yn.isEmpty)(d)||s&&(0,yn.isEmpty)(d))&&(0,zo.jsx)("div",{className:"bg-surface absolute z-40 mt-0.5 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border shadow-lg",children:n?(0,zo.jsxs)("div",{className:"space-y-1 p-2",children:[(0,zo.jsx)("div",{className:"h-6 w-full animate-pulse rounded bg-muted/10"}),(0,zo.jsx)("div",{className:"h-6 w-full animate-pulse rounded bg-muted/10"})]}):s&&(0,yn.isEmpty)(d)?(0,zo.jsxs)("div",{className:"flex items-center justify-center p-4 text-xs text-muted-foreground",children:[o("No results found for"),' "',l,'"']}):(0,zo.jsx)("ul",{ref:g,children:(0,yn.map)(d==null?void 0:d.slice(0,20),(w,N)=>(0,zo.jsxs)("li",{onClick:()=>f(w),className:`cursor-pointer px-2 py-1 text-xs ${e!=null&&e.includes(w.id)?"bg-primary/20":N===u?"bg-accent":"hover:bg-accent"}`,children:[w.name," ",w.slug&&(0,zo.jsxs)("small",{className:"font-light text-muted-foreground",children:["( ",w.slug," )"]}),w.lang&&(0,zo.jsx)("small",{className:"ml-1 rounded bg-muted px-1 py-0.5 text-[10px] font-medium text-muted-foreground",children:w.lang})]},w.id))})})]})},Y4=({schema:e,formData:t,onChange:o,name:r})=>{var h;let{t:n}=(0,bA.useTranslation)(),{type:a="pageType",href:s="",target:i="self"}=t!=null?t:{},l=q("pageTypes",[]),{selectedLang:c,fallbackLang:d,languages:p}=fe(),u=(0,Js.useMemo)(()=>(0,yn.isEmpty)(p)?"":(0,yn.isEmpty)(c)?d:c,[p,c,d]),m=(0,Js.useMemo)(()=>(0,yn.get)(Wa,u,u),[u]),g=a==="pageType"&&(0,yn.isEmpty)(l)?"url":a;return(0,zo.jsxs)("div",{children:[(0,zo.jsxs)("div",{className:"mb-1.5 flex items-center justify-between gap-x-2",children:[(0,zo.jsxs)(Q,{children:[(h=e==null?void 0:e.title)!=null?h:"Link",(0,zo.jsx)("span",{className:"pl-1 text-[9px] text-muted-foreground",children:m})]}),(0,zo.jsx)(Rw,{schema:e,onChange:f=>{o({...t,href:f,...g==="pageType"?{type:"url"}:{}})},id:`root.${r}.href`,formData:t})]}),(0,zo.jsxs)("div",{className:"flex flex-col gap-y-2.5",children:[(0,zo.jsx)("select",{className:"flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-xs shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",name:"type",value:a,onChange:f=>o({...t,type:f.target.value}),children:(0,yn.map)([...(0,yn.isEmpty)(l)?[]:[{const:"pageType",title:n("Goto Page")}],{const:"url",title:n("Open URL")},{const:"email",title:n("Compose Email")},{const:"telephone",title:n("Call Phone")},{const:"scroll",title:n("Scroll to element")}],f=>(0,zo.jsx)("option",{value:f.const,children:f.title},f.const))}),g==="pageType"&&!(0,yn.isEmpty)(l)?(0,zo.jsx)(Ste,{href:s,onChange:f=>o({...t,href:f})}):null,(0,zo.jsx)(Ce,{id:`root.${r}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:g==="pageType"?"!hidden":"",value:s,onChange:f=>o({...t,href:f.target.value}),placeholder:n(a==="url"?"Enter URL":a==="scroll"?"#ElementID":"Enter details")}),g==="url"&&(0,zo.jsxs)("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[(0,zo.jsx)(Ia,{id:`root.${r}.target`,checked:i==="_blank",onCheckedChange:f=>o({...t,target:f?"_blank":"_self"})}),(0,zo.jsx)(Q,{htmlFor:`root.${r}.target`,children:n("Open in new tab")})]})]})]})}});var Jm,_w,Qm,kp,Q4,zt,X4,Z4=x(()=>{"use strict";Jm=require("@radix-ui/react-icons"),_w=require("lodash-es"),Qm=require("lucide-react"),kp=require("react"),Q4=require("react-i18next");Tw();Tt();J();No();yp();zt=require("react/jsx-runtime"),X4=({formData:e,onChange:t})=>{let{t:o}=(0,Q4.useTranslation)(),{selectedLang:r,fallbackLang:n}=fe(),[a,s]=(0,kp.useState)(null),[i,l]=(0,kp.useState)(!0),c=r||n,d=(0,kp.useMemo)(()=>Array.isArray(e)?e:[],[e]),p=f=>{let b=Array.isArray(f)?f:[f],y=w=>typeof w=="number"&&Number.isFinite(w)&&w>0,k=b.map(w=>{let N=y(w.height),I=y(w.width);return{id:w.id,url:w.url,height:N?w.height:I?w.width:100,width:I?w.width:N?w.height:100,description:typeof w.description=="string"?{[n]:w.description}:w.description||{}}});t([...d,...k])},u=(0,kp.useCallback)(f=>{let b=[...d];b.splice(f,1),t(b)},[d,t]),m=(0,kp.useCallback)(f=>{if(f===0)return;let b=[...d],y=b[f];b[f]=b[f-1],b[f-1]=y,t(b)},[d,t]),g=(0,kp.useCallback)(f=>{if(f===d.length-1)return;let b=[...d],y=b[f];b[f]=b[f+1],b[f+1]=y,t(b)},[d,t]),h=f=>f!=null&&f.description?typeof f.description=="string"?f.description:(0,_w.get)(f.description,r||n,"")||"":"";return(0,zt.jsxs)("div",{className:"flex flex-col gap-y-2",children:[d.length>0&&(0,zt.jsxs)("div",{className:"rounded border",children:[(0,zt.jsxs)("div",{role:"button",onClick:()=>l(!i),className:"flex min-h-7 cursor-pointer items-center justify-between rounded-t p-1 hover:bg-accent/80",children:[(0,zt.jsxs)("div",{className:"flex items-center gap-x-1",children:[i?(0,zt.jsx)(Qm.ChevronDown,{className:"h-4 w-4"}):(0,zt.jsx)(Qm.ChevronRight,{className:"h-4 w-4"}),(0,zt.jsx)("h3",{className:"text-xs font-medium",children:o("Images")})]}),(0,zt.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," ",o("selected")]})]}),i&&(0,zt.jsx)("div",{className:"flex flex-col gap-y-1 p-1",children:d.map((f,b)=>{var y;return(0,zt.jsxs)("div",{className:"bg-surface group relative flex items-center gap-x-2 rounded-md border p-1.5",children:[(0,zt.jsx)("div",{className:"h-12 w-12 rounded bg-background/10",children:(0,zt.jsx)("img",{src:f.url,alt:h(f),width:48,height:48,className:"h-12 min-w-12 max-w-12 rounded object-cover"})}),(0,zt.jsxs)("div",{className:"flex w-full flex-col justify-start py-0",children:[(0,zt.jsxs)("div",{className:"flex items-start justify-start text-[12px] text-muted-foreground",children:[(0,zt.jsxs)(Q,{children:[o("Alt text")," ",(0,zt.jsx)("span",{className:"text-[9px] text-muted-foreground/70",children:Wa[c]||c})]}),(0,zt.jsx)(E,{variant:"ghost",size:"icon-xs",className:"ml-1 h-4 w-4",onClick:()=>s(b),children:(0,zt.jsx)(Jm.Pencil1Icon,{className:"!h-3 !w-3"})})]}),a===b?(0,zt.jsx)("input",{type:"text",autoFocus:!0,className:"!h-6 !w-[104%] !rounded-sm !px-2 !py-0",placeholder:o("Enter alt text"),defaultValue:h(f),onChange:k=>{let w=k.target.value,N=[...d],I=N[b].description;typeof I=="string"?N[b].description={[c]:w}:N[b].description={...I||{},[c]:w},t(N)},onBlur:()=>s(null),onKeyDown:k=>{k.key==="Enter"&&k.currentTarget.blur()}}):(0,zt.jsx)("span",{className:"flex-1 truncate text-xs text-foreground",children:(0,_w.truncate)(h(f),{length:30})||(0,zt.jsx)("span",{className:"italic text-muted-foreground",children:o("No description")})})]}),(0,zt.jsx)("div",{className:"flex items-center gap-x-1",children:a!==b?(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsxs)("div",{className:"absolute right-0 top-0 flex flex-col items-center justify-center rounded border-b border-l",children:[(0,zt.jsx)(E,{type:"button",onClick:()=>m(b),disabled:b===0,size:"icon-xs",variant:"ghost",className:"flex h-5 w-5 items-center justify-center","aria-label":o("Move image up"),children:(0,zt.jsx)(Jm.ArrowUpIcon,{className:"h-3 w-3"})}),(0,zt.jsx)(E,{type:"button",size:"icon-xs",variant:"ghost",onClick:()=>g(b),disabled:b===d.length-1,className:"flex h-5 w-5 items-center justify-center","aria-label":o("Move image down"),children:(0,zt.jsx)(Jm.ArrowDownIcon,{className:"h-3 w-3"})})]}),(0,zt.jsx)(E,{type:"button",size:"icon-xs",variant:"ghost",onClick:()=>u(b),className:"absolute bottom-0 right-0 hidden h-5 w-5 items-center justify-center text-destructive hover:bg-destructive/10 group-hover:flex","aria-label":o("Remove image"),children:(0,zt.jsx)(Jm.Cross1Icon,{className:"h-3 w-3"})})]}):(0,zt.jsx)(E,{type:"button",size:"icon-xs",onClick:()=>u(b),className:"absolute right-1 top-1 hidden rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/90 group-hover:block","aria-label":o("Remove image"),children:(0,zt.jsx)(Qm.Check,{className:"h-3 w-3"})})})]},(y=f.id)!=null?y:b)})})]}),(0,zt.jsx)(jm,{multiple:!0,onSelect:p,mode:"image",children:(0,zt.jsxs)("button",{type:"button",className:"flex w-full items-center justify-center gap-x-2 rounded-md border border-dashed border-border py-1 text-xs text-muted-foreground hover:bg-accent",children:[(0,zt.jsx)(Qm.Images,{className:"!h-3.5 !w-3.5"}),o("Choose images")]})})]})}});var Vh,Ba,e3,t3=x(()=>{"use strict";Vh=require("@radix-ui/react-icons");J();rs();Tn();Ba=require("react/jsx-runtime"),e3=({value:e,onChange:t})=>{var a;if(!e)return(0,Ba.jsxs)("div",{className:"mt-1 flex h-8 items-center gap-2 rounded-md border border-input bg-muted/50 px-2 py-1 text-xs text-muted-foreground",children:[(0,Ba.jsx)(Vh.FileIcon,{className:"h-3.5 w-3.5"})," Choose a collection"]});let o=`{{${"#"}`,r=e==null?void 0:e.startsWith(o),n=e;return r&&(n=(a=e==null?void 0:e.replace(o,""))==null?void 0:a.replace("}}","")),(0,Ba.jsx)("div",{className:"mt-1 flex flex-col gap-1",children:(0,Ba.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-xs text-blue-700",children:[(0,Ba.jsxs)("span",{className:"flex max-w-[200px] items-center gap-2",children:[" ",r?(0,Ba.jsx)(Vh.IdCardIcon,{className:"h-3 min-h-3 w-3 min-w-3"}):null,(0,Ba.jsxs)(Fo,{delayDuration:500,children:[(0,Ba.jsx)(Ho,{asChild:!0,children:(0,Ba.jsx)("span",{className:"cursor-default truncate",children:n})}),(0,Ba.jsx)(Bo,{side:"left",hidden:n.length<50,children:n})]})]}),(0,Ba.jsxs)(Fo,{children:[(0,Ba.jsx)(Ho,{asChild:!0,children:(0,Ba.jsx)(E,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-full bg-gray-200 text-gray-900 hover:bg-gray-300",onClick:()=>t(""),children:(0,Ba.jsx)(Vh.Cross1Icon,{className:"h-4 w-4"})})}),(0,Ba.jsx)(Bo,{side:"left",children:"Remove binding"})]})]})})}});var Lw,xA,o3,zh,Mw=x(()=>{"use strict";Lw=require("jotai"),xA=require("lodash-es");zr();Ge();Ne();o3=(0,Lw.atom)(e=>{var s;let t=e(Ot),o=e(Gu),r=o.length===1?o[0]:null;if(!r)return null;let n=(0,xA.find)(t,{_id:r});if(!n)return null;let a=n._parent;for(;a;){let i=(0,xA.find)(t,{_id:a});if(!i)return null;if((s=Ct(i._type))!=null&&s.wrapper)return i;a=i._parent}return null});o3.debugLabel="wrapperBlockAtom";zh=()=>(0,Lw.useAtomValue)(o3)});var r3,qx,n3,a3=x(()=>{"use strict";r3=require("@radix-ui/react-icons");zl();Ge();Mw();J();qx=require("react/jsx-runtime"),n3=()=>{let e=_e(),t=zh(),{addCoreBlock:o}=Xn();if(!e&&!t)return null;let r=(e==null?void 0:e._type)==="Row"?e:t;return(0,qx.jsx)("div",{className:"pt-1",children:(0,qx.jsxs)(E,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>o({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[(0,qx.jsx)(r3.PlusIcon,{className:"mr-1 h-3 w-3"})," Add Column"]})})}});var s3={};et(s3,{default:()=>Pte});var Ii,wte,Pte,i3=x(()=>{"use strict";Wr();Bw();J();qt();Ii=require("react/jsx-runtime"),wte=({isOpen:e,onClose:t,editor:o,rteElement:r})=>{let n=la(),a=s=>{if(!o)return;let i=`{{${s}}}`;o.commands.focus();let{from:l,to:c}=o.state.selection;if(l!==c)o.chain().deleteSelection().insertContent(i).run();else{let{state:p}=o,u=p.selection.from,m=p.doc.textBetween(Math.max(0,u-1),u),g=p.doc.textBetween(u,Math.min(u+1,p.doc.content.size)),h="";u>0&&m!==" "&&!/[.,!?;:]/.test(m)&&(h=" ");let f="";g&&g!==" "&&!/[.,!?;:]/.test(g)&&(f=" "),o.chain().insertContent(h+i+f).run()}};return(0,Ii.jsx)(Te,{open:e,onOpenChange:s=>!s&&t(),children:(0,Ii.jsxs)(we,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[(0,Ii.jsx)(Oe,{children:(0,Ii.jsxs)(Ie,{className:"flex items-center justify-between pr-8",children:[(0,Ii.jsx)("span",{children:"Rich Text Editor"}),n&&Object.keys(n).length>0&&(0,Ii.jsxs)("div",{className:"flex items-center",children:[(0,Ii.jsx)("span",{className:"mr-2 text-xs text-foreground/50",children:"Add field:"}),(0,Ii.jsx)("div",{className:"rte-path-selector",children:(0,Ii.jsx)(Gh,{data:n,onSelect:a})})]})]})}),r,(0,Ii.jsx)("div",{className:"mt-4 flex justify-end",children:(0,Ii.jsx)(E,{onClick:t,children:"Done"})})]})})},Pte=wte});var l3,xl,Qs,Tte,Nte,c3,d3=x(()=>{"use strict";l3=require("@tiptap/react"),xl=K(require("react"),1);zE();Zu();Ge();VE();Qs=require("react/jsx-runtime"),Tte=xl.default.lazy(()=>Promise.resolve().then(()=>(i3(),s3))),Nte=({blockId:e,id:t,placeholder:o,value:r,onChange:n,onBlur:a})=>{let s=(0,xl.useRef)(null),[i,l]=(0,xl.useState)(!1),c=tw({blockId:e,value:r,placeholder:o,onBlur:({editor:u})=>{let m=u==null?void 0:u.getHTML();a(t,m)},onUpdate:({editor:u})=>{let m=u==null?void 0:u.getHTML();n(m)}});(0,xl.useEffect)(()=>{s.current&&c&&(s.current.__chaiRTE=c)},[e,c]);let d=()=>{l(!1)},p=(0,Qs.jsxs)("div",{id:`chai-rte-${t}`,ref:s,className:"mt-1 rounded-md border border-input",children:[(0,Qs.jsx)(ew,{editor:c,onExpand:()=>l(!0)}),(0,Qs.jsx)(l3.EditorContent,{editor:c,id:t,placeholder:o,className:`-mt-1 overflow-auto placeholder:font-light ${i?"max-h-[500px] min-h-[400px] rounded-b-md bg-background text-foreground":"max-h-[200px] min-h-[100px] rounded-b-md bg-background text-foreground"}`},t)]});return(0,Qs.jsxs)(Qs.Fragment,{children:[i&&(0,Qs.jsx)(xl.Suspense,{fallback:(0,Qs.jsx)("div",{children:"Loading..."}),children:(0,Qs.jsx)(Tte,{isOpen:i,onClose:d,editor:c,rteElement:p})}),i?(0,Qs.jsx)("div",{children:"Open in modal"}):(0,Qs.jsx)("div",{className:"relative",children:p})]})},c3=e=>{let{editingBlockId:t}=us(),[o,r]=(0,xl.useState)(null),n=_e(),a=n==null?void 0:n._id;return(0,xl.useEffect)(()=>{r(a)},[a]),o&&o!==t?(0,Qs.jsx)(Nte,{...e,blockId:o},o):null}});var Wh,Xs,vA,rr,p3,m3=x(()=>{"use strict";Wh=require("@radix-ui/react-icons"),Xs=require("lodash-es"),vA=require("react");ko();zl();Ge();Mw();Pg();fo();No();rr=require("react/jsx-runtime"),p3=({formData:e,onChange:t})=>{let[o]=Pt(),r=_e(),n=zh(),{addCoreBlock:a}=Xn(),[,s]=Pe(),i=(r==null?void 0:r._type)==="Slider"?r:n,l=(0,Xs.find)(o,{_parent:i==null?void 0:i._id,_type:"Slides"}),c=(0,Xs.filter)(o,{_parent:l==null?void 0:l._id,_type:"Slide"}),d=(e==null?void 0:e.currentSlide)||(0,Xs.get)(c,"0._id");if((0,vA.useEffect)(()=>{(r==null?void 0:r._type)==="Slide"&&(e==null?void 0:e.currentSlide)!==(r==null?void 0:r._id)&&t({...e,currentSlide:r==null?void 0:r._id})},[e,t,r]),(0,vA.useEffect)(()=>{c!=null&&c.length&&!(0,Xs.find)(c,{_id:e==null?void 0:e.currentSlide})&&t({...e,currentSlide:(0,Xs.get)(c,"0._id")})},[e,c,t]),!r&&!n||!l)return null;let p=()=>{let g=(0,Xs.findIndex)(c,{_id:d});if(g>-1){let h=(g+1)%c.length,f=(0,Xs.get)(c,[h,"_id"]);if(!f)return;t({...e,currentSlide:f}),s([f])}},u=()=>{let g=(0,Xs.findIndex)(c,{_id:d});if(g>-1){let h=(g-1+c.length)%c.length,f=(0,Xs.get)(c,[h,"_id"]);if(!f)return;t({...e,currentSlide:f}),s([f])}},m=()=>{let g=a({styles:"#styles:,h-full w-full min-w-full",type:"Slide"},l==null?void 0:l._id),h=g==null?void 0:g._id;h&&(t({...e,currentSlide:h}),s([h]))};return(0,rr.jsxs)("div",{className:"space-y-1.5 px-2",children:[(0,rr.jsxs)("div",{className:"flex items-center gap-x-2 pb-2 text-[12px]",children:[(0,rr.jsx)("button",{onClick:u,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:(0,rr.jsx)(Wh.ChevronLeftIcon,{className:"h-3 w-3"})}),(0,rr.jsx)("div",{className:"whitespace-nowrap text-center text-[10px] text-slate-500",children:d?(0,rr.jsxs)("span",{className:"",children:[(0,rr.jsxs)("b",{className:"text-[12px]",children:[" ",(0,Xs.findIndex)(c,{_id:d})+1]}),"/",c.length]}):"-"}),(0,rr.jsx)("button",{onClick:p,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:(0,rr.jsx)(Wh.ChevronRightIcon,{className:"h-3 w-3"})}),(0,rr.jsxs)("button",{onClick:m,className:"flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",children:[(0,rr.jsx)(Wh.PlusCircledIcon,{className:"h-3 w-3"}),"Add Slide"]})]}),(0,rr.jsxs)("div",{className:"flex items-center gap-x-2 leading-tight",children:[(0,rr.jsx)(Ia,{checked:!!(e!=null&&e.showSlideButton),onCheckedChange:g=>t({...e,showSlideButton:!!g}),className:"h-3.5 w-3.5 cursor-pointer",id:"showSlideButton"}),(0,rr.jsx)(Q,{htmlFor:"showSlideButton",className:"mb-0 mt-0.5 cursor-pointer",children:"Show Slide Buttons"})]}),(0,rr.jsxs)("div",{className:"flex items-center gap-x-2 leading-tight",children:[(0,rr.jsx)(Ia,{checked:!!(e!=null&&e.showSlideNavbar),onCheckedChange:g=>t({...e,showSlideNavbar:!!g}),className:"h-3.5 w-3.5 cursor-pointer",id:"showSlideNavbar"}),(0,rr.jsx)(Q,{htmlFor:"showSlideNavbar",className:"mb-0 mt-0.5 cursor-pointer",children:"Show Slide Navbar"})]}),(0,rr.jsx)("div",{children:(0,rr.jsxs)("div",{className:"flex flex-col",children:[(0,rr.jsxs)("div",{className:"flex items-center gap-x-2 leading-tight",children:[(0,rr.jsx)(Ia,{checked:!!(e!=null&&e.autoplay),onCheckedChange:g=>t({...e,autoplay:!!g}),className:"h-3.5 w-3.5 cursor-pointer",id:"autoplay"}),(0,rr.jsx)(Q,{htmlFor:"autoplay",className:"mb-0 mt-0.5 cursor-pointer",children:"Autoplay slides"})]}),(e==null?void 0:e.autoplay)&&(0,rr.jsxs)("div",{className:"pt-0.5 leading-tight",children:[(0,rr.jsxs)(Q,{htmlFor:"interval",className:"mb-1 block",children:["Autoplay Interval ",(0,rr.jsx)("span",{className:"font-light opacity-80",children:"(in seconds)"})]}),(0,rr.jsx)(Ce,{type:"number",id:"interval",name:"interval",placeholder:"0",value:e==null?void 0:e.autoplayInterval,className:"h-7 text-xs",pattern:"[0-9]*",onChange:g=>{let h=g.target.value;h.length&&(h=h.replace("-","")),t({...e,autoplayInterval:h})}})]})]})})]})}});var Ow,Sp,fa,u3,g3=x(()=>{"use strict";Ow=require("@radix-ui/react-icons"),Sp=require("lodash-es");fo();No();fa=require("react/jsx-runtime"),u3=({formData:e,onChange:t})=>{let o=(0,Sp.get)(e,"srcsets",[])||[],r=(s,i)=>{let l=s.target.name,c=s.target.value;t({srcsets:(0,Sp.map)(o,(d,p)=>p===i?{...d,[l]:c}:d)})},n=()=>{t({srcsets:[...o,{}]})},a=s=>{t({srcsets:(0,Sp.reject)(o,(i,l)=>parseInt(l)===s)})};return(0,fa.jsxs)("div",{children:[(0,fa.jsxs)("div",{className:"flex items-center justify-between pb-2",children:[(0,fa.jsx)(Q,{children:"Responsive Video (optional)"}),(0,fa.jsx)("button",{type:"button",onClick:n,className:"flex items-center gap-x-1 rounded-md border border-blue-500 bg-blue-100 px-2 py-px text-xs text-blue-600 hover:opacity-80",children:(0,fa.jsx)(Ow.PlusIcon,{className:"h-3 w-3"})})]}),(0,fa.jsx)("div",{className:"space-y-2",children:o.length===0?(0,fa.jsx)("div",{className:"rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500",children:"Add additional sources to create responsive videos"}):(0,Sp.map)(o,(s,i)=>(0,fa.jsxs)("div",{className:"group relative space-y-1.5 rounded border border-gray-200 p-2 pb-1.5",children:[(0,fa.jsx)("button",{type:"button",onClick:()=>a(i),className:"absolute -right-2 -top-2 translate-y-0 rounded-full bg-destructive p-1 opacity-0 hover:bg-destructive/90 group-hover:opacity-100",children:(0,fa.jsx)(Ow.Cross1Icon,{className:"h-2.5 w-2.5 text-white"})}),(0,fa.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,fa.jsx)(Q,{className:"mb-0 flex h-8 w-1/4 items-center justify-start",children:"Width"}),(0,fa.jsx)(Ce,{name:"width",placeholder:"Enter width (in px)",type:"number",value:(0,Sp.get)(s,"width"),onChange:l=>r(l,i),className:"h-8 text-xs"})]}),(0,fa.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,fa.jsx)(Q,{className:"mb-0 flex h-8 w-1/4 items-center justify-start",children:"URL"}),(0,fa.jsx)(Ce,{name:"url",placeholder:"Enter url",className:"h-8 text-xs",value:(0,Sp.get)(s,"url",""),onChange:l=>r(l,i)})]})]},i))})]})}});var f3,h3,y3,b3,jh,$n,Xm,Ete,Ate,Ite,Fw,x3=x(()=>{"use strict";f3=require("@radix-ui/react-icons"),h3=require("@react-hookz/web"),y3=K(require("@rjsf/core"),1),b3=K(require("@rjsf/validator-ajv8"),1),jh=require("lodash-es"),$n=require("react");m4();g4();k4();_4();yA();J4();Z4();t3();a3();d3();m3();g3();Tt();Rr();Xm=require("react/jsx-runtime"),Ete=()=>{let e=zb("widget"),t=zb("field"),o=zb("template"),r=(0,$n.useMemo)(()=>({richtext:c3,icon:C4,image:D4,code:p4,colCount:n3,collectionSelect:u4,repeaterBinding:e3,...e}),[e]),n=(0,$n.useMemo)(()=>({link:Y4,slider:p3,sources:u3,images:X4,...t}),[t]),a=(0,$n.useMemo)(()=>({FieldTemplate:hA,ButtonTemplates:{AddButton:Ate},...o}),[o]);return{widgets:r,fields:n,templates:a}},Ate=e=>(0,Xm.jsx)("button",{...e,className:"duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500",children:(0,Xm.jsxs)("div",{className:"flex items-center gap-x-0.5 text-[11px] leading-tight",children:[(0,Xm.jsx)(f3.PlusIcon,{className:"h-3 w-3"})," ",(0,Xm.jsx)("span",{children:"Add"})]})}),Ite=({formRef:e,blockId:t,formData:o,selectedLang:r,uiSchemaCopy:n,schemaCopy:a,onChange:s})=>{let{widgets:i,fields:l,templates:c}=Ete(),d=(0,$n.useCallback)((p,u)=>{let{formData:m}=p;if(!u||t!==(m==null?void 0:m._id))return;let g=(0,jh.take)(u.split("."),2).join(".").replace("root.","");(0,jh.get)(m,g)===void 0&&(0,jh.set)(m,g,""),s({formData:m},g)},[t,s]);return(0,Xm.jsx)(y3.default,{ref:e,widgets:i,fields:l,templates:c,idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator:b3.default,uiSchema:n,schema:a,formData:o,onChange:d},`json-form-${t}-${r}`)},Fw=(0,$n.memo)(({blockId:e,schema:t,uiSchema:o,formData:r,onChange:n})=>{let{selectedLang:a}=fe(),s=(0,$n.useRef)(r),i=(0,$n.useRef)(null);s.current=r;let[l,c]=(0,$n.useState)(r),[d,p]=(0,$n.useState)(!1),[{schema:u,uiSchema:m}]=(0,$n.useState)({schema:t,uiSchema:o});(0,$n.useEffect)(()=>{var k,w;let f=(w=(k=i==null?void 0:i.current)==null?void 0:k.formElement)==null?void 0:w.current;if(!f)return;let b=()=>p(!1),y=()=>p(!0);return f.addEventListener("focusout",b),f.addEventListener("focusin",y),()=>{f.removeEventListener("focusout",b),f.removeEventListener("focusin",y)}},[]),(0,$n.useEffect)(()=>{e&&d&&c(s.current)},[e,d]),(0,$n.useEffect)(()=>{e&&!d&&c(r)},[e,d,r]);let g=(0,h3.useThrottledCallback)(async({formData:f},b)=>{n({formData:f},b)},[a],800);return(0,$n.useMemo)(()=>(0,Xm.jsx)(Ite,{blockId:e,formRef:i,formData:l,selectedLang:a,uiSchemaCopy:m,schemaCopy:u,onChange:(f,b)=>{c(f.formData),g(f,b)}}),[e,l,a,m,u,g])});Fw.displayName="JSONForm"});var v3,Zm,ra,C3,qa,Bte,Rte,k3,CA,Kx,S3,w3=x(()=>{"use strict";v3=require("eta/core"),Zm=require("lodash-es"),ra=require("react"),C3=require("react-i18next");fo();qa=require("react/jsx-runtime"),Bte=new v3.Eta({tags:["{{","}}"],autoEscape:!0,autoTrim:!1,useWith:!0,parse:{interpolate:"",exec:"~",raw:"~"}}),Rte=[/\b(?:window|document|globalThis|process|Function|eval|import|fetch|XMLHttpRequest|WebSocket|localStorage|sessionStorage)\b/,/(^|[^=!<>])=([^=]|$)/,/\b(?:while|for|try|catch|class|new)\b/],k3=e=>(0,Zm.isArray)(e)?"array":e===null?"null":(0,Zm.isObject)(e)?"JSON":typeof e,CA=(e,t)=>{let o=t?(0,Zm.get)(e,t):e;return!(0,Zm.isObject)(o)||o===null||(0,Zm.isArray)(o)?[]:Object.entries(o).filter(([r])=>!r.startsWith("#")).map(([r,n])=>({path:t?`${t}.${r}`:r,type:k3(n)}))},Kx=e=>{let t=e.trim();if(!t)return null;if(Rte.some(r=>r.test(t)))return"Unsafe expression detected";try{return Bte.compile(`{{${t}}}`),null}catch(r){return"Invalid expression syntax"}},S3=({currentExpression:e,externalData:t,isOpen:o,onSave:r})=>{let n=(0,ra.useRef)(null),a=(0,ra.useRef)(null),s=(0,ra.useRef)(r),i=(0,ra.useRef)(e),l=Kx(e),c=(0,ra.useRef)(l),d=(0,ra.useRef)(o),[p,u]=(0,ra.useState)(e),[m,g]=(0,ra.useState)(l),[h,f]=(0,ra.useState)(0),[b,y]=(0,ra.useState)(null),{t:k}=(0,C3.useTranslation)();(0,ra.useEffect)(()=>{u(e),g(Kx(e)),y(null),f(0)},[e]),(0,ra.useEffect)(()=>{s.current=r,i.current=p,c.current=m,d.current=o},[r,p,m,o]),(0,ra.useEffect)(()=>()=>{var P;if(d.current)return;let C=(P=i.current)==null?void 0:P.trim();c.current||s.current(C)},[]);let w=(0,ra.useMemo)(()=>Object.entries(t!=null?t:{}).filter(([C])=>!C.startsWith("#")).map(([C,P])=>({key:C,type:k3(P)})),[t]),N=(C,P)=>{let T=C.slice(0,P).match(/[A-Za-z_$][\w$.]*\.?$/);if(!T){y(null);return}let v=T[0],S;if(v.endsWith(".")){let A=v.slice(0,-1);S=CA(t,A)}else{let A=v.lastIndexOf(".");if(A===-1)S=CA(t,"").filter(D=>D.path.toLowerCase().startsWith(v.toLowerCase()));else{let D=v.slice(0,A),R=v.slice(A+1).toLowerCase();S=CA(t,D).filter(H=>H.path.slice(H.path.lastIndexOf(".")+1).toLowerCase().startsWith(R))}}if(S=S.slice(0,8),!S.length){y(null),f(0);return}y({start:P-v.length,end:P,options:S}),f(0)},I=(C,P)=>{if(!b)return;let B=P==="JSON"?`${C}.`:C,T=p.slice(0,b.start)+B+p.slice(b.end);u(T),g(Kx(T)),y(null),f(0),requestAnimationFrame(()=>{var S,A;let v=b.start+B.length;(S=n.current)==null||S.focus(),(A=n.current)==null||A.setSelectionRange(v,v),N(T,v)})};return(0,ra.useEffect)(()=>{if(!b||!a.current)return;let C=a.current.children[h];C==null||C.scrollIntoView({block:"nearest"})},[h,b]),(0,qa.jsxs)("div",{className:"grid gap-2",children:[(0,qa.jsxs)("div",{children:[(0,qa.jsx)("p",{className:"mb-1 text-[10px] font-medium text-muted-foreground",children:k("Available databindings:")}),(0,qa.jsx)("div",{className:"flex flex-wrap gap-1",children:w.map(C=>(0,qa.jsxs)("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px]",children:[(0,qa.jsx)("span",{className:"font-medium",children:C.key}),(0,qa.jsxs)("span",{className:"ml-0.5 text-muted-foreground",children:[": ",C.type]})]},C.key))})]}),(0,qa.jsxs)("div",{className:"relative",children:[(0,qa.jsx)(Ce,{ref:n,id:"expression",value:p,className:`h-8 text-xs ${m?"border-red-500":""}`,onChange:C=>{var v;let P=C.target.value,B=(v=C.target.selectionStart)!=null?v:P.length;u(P);let T=Kx(P);g(T),N(P,B)},onKeyDown:C=>{if(b&&b.options.length){if(C.key==="ArrowDown"){C.preventDefault(),f(P=>P>=b.options.length-1?0:P+1);return}if(C.key==="ArrowUp"){C.preventDefault(),f(P=>P<=0?b.options.length-1:P-1);return}if(C.key==="Enter"||C.key==="Tab"){C.preventDefault();let P=b.options[h];P&&I(P.path,P.type);return}if(C.key==="Escape"){C.preventDefault(),y(null),f(0);return}}if(C.key==="Enter"){C.preventDefault();let P=Kx(p);g(P),P||r(p.trim())}},placeholder:"name === 'x'",autoComplete:"off"}),b&&(0,qa.jsx)("div",{ref:a,className:"absolute z-20 mt-1 max-h-36 w-full overflow-auto rounded border bg-background p-1 shadow",children:b.options.map((C,P)=>(0,qa.jsxs)("button",{type:"button",className:`block w-full rounded px-2 py-1 text-left text-[10px] hover:bg-muted ${P===h?"bg-muted":""}`,onMouseDown:B=>{B.preventDefault(),I(C.path,C.type)},children:[(0,qa.jsx)("span",{className:"font-medium",children:C.path.slice(C.path.lastIndexOf(".")+1)}),(0,qa.jsxs)("span",{className:"ml-1 text-muted-foreground",children:[": ",C.type]})]},C.path))})]}),m&&(0,qa.jsx)("p",{className:"text-[10px] text-red-500",children:m})]})}});var P3,eu,T3,Tg,N3,ln,E3,A3=x(()=>{"use strict";P3=require("@radix-ui/react-icons"),eu=require("lodash-es"),T3=require("lucide-react"),Tg=require("react"),N3=require("react-i18next");Wr();w3();Ge();Ln();J();Rs();Wd();ln=require("react/jsx-runtime"),E3=()=>{let{t:e}=(0,N3.useTranslation)(),t=_e(),o=la(),r=br(),[n,a]=(0,Tg.useState)(!1),[s,i]=(0,Tg.useState)(!1),l=(0,Tg.useRef)(null);(0,Tg.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let c=h=>{if(t){if(!h||h.trim()===""){(0,eu.isString)(t._show)&&r([t._id],{_show:!0});return}r([t._id],{_show:`{{${h.trim()}}}`})}},d=h=>{a(h)},p=()=>{if(!t)return;let h=(0,eu.has)(t,"_show")?t._show:!0;r([t._id],{_show:!h})},u=()=>{t&&(r([t._id],{_show:!0}),i(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{i(!1)},200),a(!1))};if(!t)return null;let m=(0,eu.isString)(t._show),g=m?t._show.startsWith("{{")&&t._show.endsWith("}}")?t._show.slice(2,-2).trim():t._show:"";return(0,ln.jsxs)("div",{className:"my-2 mb-4 flex items-center justify-between",children:[(0,ln.jsxs)("div",{className:"mr-2 flex min-w-0 flex-1 flex-col items-start space-y-0 leading-none",children:[(0,ln.jsxs)("div",{className:"flex items-baseline gap-1 text-xs text-gray-500",children:[e("Visibility"),(0,eu.isString)(t._show)&&(0,ln.jsx)("span",{className:"text-[9px] italic text-gray-400",children:e("visible when true")})]}),(0,eu.isString)(t._show)&&(0,ln.jsx)("code",{className:"mt-0.5 block max-w-full break-words rounded bg-primary/10 px-1.5 py-0.5 text-[9px] leading-relaxed text-primary",children:g})]}),(0,ln.jsxs)("div",{className:"group relative",children:[(0,ln.jsxs)(en,{open:n,onOpenChange:d,children:[(0,ln.jsx)($r,{asChild:!0,children:(0,ln.jsx)("button",{type:"button","aria-label":e("Open visibility settings"),className:"absolute -left-2 -top-1.5 z-10 cursor-pointer rounded-full border border-blue-500 bg-background p-0.5 text-blue-500 transition-all hover:scale-125",children:(0,ln.jsx)(T3.Settings,{className:"h-2.5 w-2.5","aria-hidden":"true"})})}),(0,ln.jsx)(Vr,{side:"left",align:"start",className:"max-w-92 p-3",children:(0,ln.jsxs)("div",{className:"grid gap-2",children:[(0,ln.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ln.jsxs)("div",{className:"space-y-1",children:[(0,ln.jsx)("h4",{className:"text-xs font-medium leading-none",children:e("Conditional Visibility")}),(0,ln.jsx)("p",{className:"text-[10px] text-muted-foreground",children:e("Enter a javascript expression. Block will be visible when expression evaluates to true.")})]}),m&&(0,ln.jsx)(E,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-500 hover:text-red-500",onClick:u,children:(0,ln.jsx)(P3.TrashIcon,{className:"h-3.5 w-3.5"})})]}),(0,ln.jsx)("div",{className:"relative",children:(0,ln.jsx)(S3,{currentExpression:g,externalData:o,isOpen:n,onSave:h=>{s||(c(h),a(!1))}})})]})})]}),(0,ln.jsx)(On,{checked:m?!0:(0,eu.has)(t,"_show")?t._show:!0,onCheckedChange:p,disabled:m})]})]})}});function Yx(){let{selectedLang:e}=fe(),t=_e(),o=Fc(),r=br(),n=Ct(t==null?void 0:t._type),a=(0,ic.useMemo)(()=>I3(t,e,n),[t,e,n]),[s,i]=(0,ic.useState)(a),[l,c]=(0,ic.useState)(!1),d=zh(),p=Ct(d==null?void 0:d._type),u=(0,ic.useMemo)(()=>I3(d,e,p),[d,e,p]),m=(0,ic.useCallback)(({formData:N},I,C)=>{I&&(s==null?void 0:s._id)===t._id&&r([t._id],{[I]:(0,wo.get)(N,I)},C)},[s==null?void 0:s._id,t._id,r]),g=(0,ic.useMemo)(()=>(0,wo.debounce)(({formData:N},I,C)=>{m({formData:N},I,C),i(N)},1500),[m]),h=({formData:N},I)=>{I&&(o([t._id],{[I]:(0,wo.get)(N,I)}),g({formData:N},I,{[I]:(0,wo.get)(s,I)}))},f=({formData:N},I)=>{I&&(o([d._id],{[I]:(0,wo.get)(N,I)}),g({formData:N},I,{[I]:(0,wo.get)(s,I)}))},{schema:b,uiSchema:y}=(0,ic.useMemo)(()=>{let N=t==null?void 0:t._type;if(!N)return{schema:{},uiSchema:{}};try{let{schema:I,uiSchema:C}=bC(N);if(N==="Repeater"){let P=(0,wo.get)(t,"repeaterItems","");(0,wo.startsWith)(P,`{{${"#"}`)?((0,wo.set)(C,"filter",{"ui:widget":"collectionSelect"}),(0,wo.set)(C,"sort",{"ui:widget":"collectionSelect"})):((0,wo.set)(C,"filter",{"ui:widget":"hidden"}),(0,wo.set)(C,"sort",{"ui:widget":"hidden"}))}return{schema:I,uiSchema:C}}catch(I){return{schema:{},uiSchema:{}}}},[t]),{wrapperSchema:k,wrapperUiSchema:w}=(0,ic.useMemo)(()=>{if(!d||!(d!=null&&d._type))return{wrapperSchema:{},wrapperUiSchema:{}};let N=d==null?void 0:d._type,{schema:I={},uiSchema:C={}}=bC(N);return{wrapperSchema:I,wrapperUiSchema:C}},[d]);return(0,vl.jsxs)("div",{className:"no-scrollbar overflow-x-hidden px-px",children:[(0,vl.jsx)(E3,{}),!(0,wo.isEmpty)(d)&&(0,vl.jsxs)("div",{className:"mb-4 rounded border px-1",children:[(0,vl.jsxs)("div",{onClick:()=>c(N=>!N),className:"flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",children:[l?(0,vl.jsx)(Hw.ChevronDownIcon,{className:"h-4 w-4 text-slate-400"}):(0,vl.jsx)(Hw.ChevronRightIcon,{className:"h-4 w-4 text-slate-400"}),(0,wo.startCase)(d._type)," settings"," ",d._name&&(0,vl.jsxs)("span",{className:"text-[11px] font-light text-slate-400",children:["(",d._name,")"]})]}),(0,vl.jsx)("div",{className:l?"h-auto":"invisible h-0",children:(0,vl.jsx)(Fw,{blockId:d==null?void 0:d._id,onChange:f,formData:u,schema:k,uiSchema:w})})]}),(0,wo.isEmpty)(b)?null:(0,vl.jsx)(Fw,{blockId:t==null?void 0:t._id,onChange:h,formData:a,schema:b,uiSchema:y})]})}var Hw,wo,ic,vl,I3,kA=x(()=>{"use strict";Hw=require("@radix-ui/react-icons"),wo=require("lodash-es"),ic=require("react");x3();Tt();Ge();Ln();Mw();Tn();Ne();A3();vl=require("react/jsx-runtime"),I3=(e,t,o)=>{let r=(0,wo.get)(o,"i18nProps",[]);if((0,wo.isEmpty)(t)||(0,wo.isEmpty)(r))return e;let n=(0,wo.cloneDeep)(e);return(0,wo.forEach)((0,wo.keys)(e),a=>{(0,wo.includes)(r,a)&&(n[a]=(0,wo.get)(e,`${a}-${t}`))}),n}});var Uw,bs,SA,Dte,_te,B3,qh,Jx=x(()=>{"use strict";Uw=require("jotai"),bs=require("lodash-es"),SA=require("react");zr();dp();ko();fn();Tn();Dte=(0,Uw.atom)(null,(e,t,{blockIds:o,fullClasses:r})=>{let n=(0,bs.first)(e(mm)),a=e(Yp),s=(0,bs.compact)((0,bs.map)(o,i=>a.get(i)));return(0,bs.map)(s,i=>{let l=e(i),c=r,{classes:d,baseClasses:p}=ys((0,bs.get)(l,n.prop,`${lr},`));return(0,bs.each)(c,u=>{let m=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`(^|\\s)${m}(?=\\s|$)`,"g");d=d.replace(g," ").replace(/\s+/g," ").trim();let h=(0,bs.first)(u.split(":"));(0,bs.includes)(["2xl","xl","lg","md","sm"],h)&&c.push(u.split(":").pop().trim())}),(0,bs.each)(c,u=>{let m=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`(^|\\s)${m}(?=\\s|$)`,"g");p=p.replace(g," ").replace(/\s+/g," ").trim()}),{ids:[l._id],props:{[n.prop]:`${lr}${p},${d}`}}})}),_te=e=>{let t=Object.keys(e).filter(r=>typeof e[r]=="string"&&e[r].startsWith(lr)),o={};return t.forEach(r=>{o[r]=`${lr},`}),{ids:[e._id],props:o}},B3=()=>{let{updateBlocks:e,updateBlocksRuntime:t}=Ft();return(0,SA.useCallback)((o,r=!1)=>{let{ids:n,props:a}=_te(o);r?e(n,a):t(n,a)},[e,t])},qh=()=>{let{updateBlocks:e,updateBlocksRuntime:t}=Ft(),o=(0,Uw.useSetAtom)(Dte);return(0,SA.useCallback)((r,n,a=!1)=>{let s=o({blockIds:r,fullClasses:n});a?e(r,s[0].props):t(r,s[0].props)},[o,e,t])}});var R3,Qx,Gw,wA=x(()=>{"use strict";R3=require("lodash-es"),Qx=require("react");Ge();Ln();Ne();Gw=()=>{let e=_e(),t=br(),o=(0,Qx.useCallback)(s=>Fl(s)||{},[]),r=(0,Qx.useCallback)(s=>Object.keys(s).filter(i=>typeof s[i]=="string"&&s[i].startsWith("#styles:")),[]),n=(0,Qx.useCallback)(s=>{var c;if(!e)return;let l=(c=o(e._type)[s])!=null?c:"#styles:,";t([e._id],{[s]:l})},[e,o,t]);return{resetAll:(0,Qx.useCallback)(()=>{if(!e)return;let s=r(e);if(s.length===0)return;let i=o(e._type),l=(0,R3.pick)(i,s);t([e._id],l)},[e,r,o,t]),reset:n}}});var $w,PA,D3,_3,Bi,L3,M3=x(()=>{"use strict";$w=require("@radix-ui/react-icons"),PA=require("lodash-es"),D3=require("react"),_3=require("react-i18next");J();jp();Rs();st();Bi=require("react/jsx-runtime"),L3=({value:e,options:t,onValueChange:o})=>{let[r,n]=(0,D3.useState)(!1),{t:a}=(0,_3.useTranslation)();return(0,Bi.jsxs)(en,{open:r,onOpenChange:n,children:[(0,Bi.jsx)($r,{asChild:!0,children:(0,Bi.jsxs)(E,{variant:"outline",size:"xs",role:"combobox","aria-expanded":r,className:"w-full justify-between text-xs font-normal",children:[e?(0,PA.startCase)(e):a("Select element"),(0,Bi.jsx)($w.ChevronDownIcon,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),(0,Bi.jsx)(Vr,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:(0,Bi.jsxs)(Yi,{children:[(0,Bi.jsx)(Md,{placeholder:a("Search element..."),className:"h-8"}),(0,Bi.jsxs)(Ji,{children:[(0,Bi.jsx)(Ml,{children:a("No element found.")}),t.map(s=>(0,Bi.jsxs)(as,{value:s,onSelect:i=>{o(i),n(!1)},children:[(0,Bi.jsx)($w.CheckIcon,{className:G("mr-1 h-3 w-3",e===s?"opacity-100":"opacity-0")}),(0,PA.startCase)(s)]},s))]})]})})]})}});var O3,Ri,F3,H3,bn,U3,G3=x(()=>{"use strict";O3=require("@radix-ui/react-icons"),Ri=require("lodash-es"),F3=require("react"),H3=require("react-i18next");dp();Jx();wA();Ge();fn();Rr();Oh();J();Sr();M3();bn=require("react/jsx-runtime"),U3=()=>{var f,b;let e=_e(),[t,o]=ao(),r=qh(),[n]=Pe(),{t:a}=(0,H3.useTranslation)(),{reset:s}=Gw(),[i,l]=(0,F3.useState)(null);if(!e)return null;let c=Object.keys(e).filter(y=>typeof e[y]=="string"&&e[y].startsWith("#styles:"));if(!(!(0,Ri.isEmpty)(c)&&c.length>1))return null;let p=(0,Ri.get)(e,(f=t[0])==null?void 0:f.prop,""),{classes:u=""}=ys(p)||{},m=u?u.split(" ").filter(y=>!(0,Ri.isEmpty)(y)):[],g=y=>(0,Ri.find)(t,k=>k.prop===y),h=((b=t[0])==null?void 0:b.prop)||c[0];return(0,bn.jsxs)(bn.Fragment,{children:[(0,bn.jsxs)("div",{className:"flex items-center justify-between",children:[(0,bn.jsxs)(bl,{variant:"inactive",className:"group relative mt-1 rounded-sm border-none bg-transparent px-0 pr-2 text-xs font-medium hover:bg-transparent",children:[a("Style Elements"),":"]}),(0,bn.jsx)("span",{children:(0,bn.jsx)(Br,{slotId:jo.BLOCK_STYLING_ELEMENTS})})]}),(0,bn.jsx)("div",{className:"flex flex-wrap gap-1 pb-2 pt-1",children:c.length<=2?(0,Ri.map)(c,y=>{let k=g(y);return(0,bn.jsxs)(bl,{variant:k?"active":"inactive",className:"group relative rounded-sm py-0 pl-2 pr-0",onClick:()=>{o([{id:`${y}-${e._id}`,blockId:e._id,prop:y}])},children:[(0,Ri.startCase)(y),(0,bn.jsxs)(Yt,{open:i===y,onOpenChange:w=>l(w?y:null),children:[(0,bn.jsx)($t,{asChild:!0,children:(0,bn.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:w=>w.stopPropagation(),className:`h-full w-max rounded rounded-l-none border-l px-0.5 duration-300 ${k?"bg-primary/10 text-primary-foreground hover:bg-primary":"bg-background/20 hover:bg-background"}`,children:(0,bn.jsx)(O3.DotsVerticalIcon,{className:"!h-3 !w-3"})})}),(0,bn.jsxs)(Vt,{side:"bottom",align:"end",children:[(0,bn.jsx)(Uk,{className:"line-clamp-1 max-w-32 px-2 py-1 text-xs text-muted","aria-label":(0,Ri.startCase)(y),children:(0,Ri.startCase)(y)}),(0,bn.jsx)(Hn,{}),(0,bn.jsx)(ye,{className:"text-xs",onClick:()=>{s(y),l(null)},children:a("Reset style")}),(0,bn.jsx)(ye,{className:"text-xs",onClick:()=>{r(n,m,!0),l(null)},children:a("Clear styles")})]})]})]},y)}):(0,bn.jsx)(L3,{value:h,options:c,onValueChange:y=>{o([{id:`${y}-${e._id}`,blockId:e._id,prop:y}])}})}),(0,bn.jsx)("div",{className:"mt-2 h-px w-full border-b bg-transparent"})]})}});var $3,Vw,TA=x(()=>{"use strict";$3=K(require("react"),1),Vw=$3.default.createContext({setDragData:()=>{}})});var V3,NA,z3=x(()=>{"use strict";V3=require("lodash-es"),NA=(e,t)=>{e=e.toLowerCase();let o=e.trim().replace(/ |\+/g,"");if((o==="auto"||o==="none")&&t.includes(o))return{value:"",unit:o};let r=t.length?new RegExp(t.join("|"),"g"):/XXXXXX/g;o=o.replace(r,"");let n=e.match(r),a=n&&n.length>1,s=!(0,V3.isEmpty)(o)&&Number.isNaN(Number(o));return a||s?{error:"Invalid value"}:n&&(n[0]==="auto"||n[0]==="none")?{value:n[0],unit:""}:{value:o,unit:n?n[0]:""}}});var Or,Lte,EA,Mte,W3=x(()=>{"use strict";Or=require("lodash-es"),Lte=e=>{let t=e.startsWith("-")?"-":"",o=e.split("-").pop();if(["auto","none"].includes(o))return{value:"",unit:o};if(o==="px")return{value:"1",unit:"px"};if(o==="screen")return{value:"100",unit:e.indexOf("w-")!==-1?"vw":"vh"};if(o==="full")return{value:"100",unit:"%"};if((0,Or.includes)(e,"skew-"))return{value:`${t}${o}`,unit:"deg"};if((0,Or.includes)(e,"rotate-"))return{value:`${t}${o}`,unit:"deg"};if((0,Or.includes)(e,"opacity-"))return{value:`${o/100}`,unit:"-"};if((0,Or.includes)(e,"duration-")||(0,Or.includes)(e,"delay-"))return{value:`${o}`,unit:"ms"};if((0,Or.includes)(e,"translate-")&&!o.includes("/"))return{value:`${t}${`${o/4}`}`,unit:"rem"};if((0,Or.includes)(e,"scale-"))return{value:`${t}${`${o/100}`}`,unit:"-"};if((0,Or.startsWith)(e,"border")){let r=e.match(/border-?(x|y|t|r|b|l)?\d+/g);if(r)return{value:r[0].split("-").pop(),unit:"px"};if(e.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if((0,Or.startsWith)(e,"max-w-")){if(e==="max-w-screen-sm")return{value:"640",unit:"px"};if(e==="max-w-screen-md")return{value:"768",unit:"px"};if(e==="max-w-screen-lg")return{value:"1024",unit:"px"};if(e==="max-w-screen-xl")return{value:"1280",unit:"px"};if(e==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(o==="xs")return{value:"320",unit:"px"};if(o==="sm")return{value:"384",unit:"px"};if(o==="md")return{value:"448",unit:"px"};if(o==="lg")return{value:"512",unit:"px"};if(o==="xl")return{value:"576",unit:"px"};if(o==="2xl")return{value:"672",unit:"px"};if(o==="3xl")return{value:"768",unit:"px"};if(o==="4xl")return{value:"896",unit:"px"};if(o==="5xl")return{value:"1024",unit:"px"};if(o==="6xl")return{value:"1152",unit:"px"};if(o==="7xl")return{value:"1280",unit:"px"};if(o==="prose")return{value:"65",unit:"ch"}}if((0,Or.startsWith)(e,"text-")){if(o==="xs")return{value:"12",unit:"px"};if(o==="sm")return{value:"14",unit:"px"};if(o==="base")return{value:"16",unit:"px"};if(o==="lg")return{value:"18",unit:"px"};if(o==="xl")return{value:"20",unit:"px"};if(o==="2xl")return{value:"24",unit:"px"};if(o==="3xl")return{value:"30",unit:"px"};if(o==="4xl")return{value:"36",unit:"px"};if(o==="5xl")return{value:"48",unit:"px"};if(o==="6xl")return{value:"60",unit:"px"};if(o==="7xl")return{value:"72",unit:"px"};if(o==="8xl")return{value:"96",unit:"px"};if(o==="9xl")return{value:"128",unit:"px"}}if((0,Or.startsWith)(e,"leading-")){if(o==="none")return{value:"1",unit:"-"};if(o==="tight")return{value:"1.25",unit:"-"};if(o==="snug")return{value:"1.375",unit:"-"};if(o==="normal")return{value:"1.5",unit:"-"};if(o==="relaxed")return{value:"1.625",unit:"-"};if(o==="loose")return{value:"2",unit:"-"}}if((0,Or.startsWith)(e,"tracking-")){if(o==="tighter")return{value:"-0.05",unit:"em"};if(o==="tight")return{value:"-0.025",unit:"em"};if(o==="normal")return{value:"0",unit:"em"};if(o==="wide")return{value:"0.025",unit:"em"};if(o==="wider")return{value:"0.05",unit:"em"};if(o==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(o))return{value:e,unit:"class"};if(o.includes("/")){let[r,n]=(0,Or.map)(o.split("/"),a=>parseInt(a,10));return{value:t+(r/n*100).toFixed(2).replace(".00",""),unit:"%"}}return(0,Or.isNumber)(parseFloat(o))?{value:`${t+parseFloat(o)*4}`,unit:"px"}:{value:o,unit:"class"}},EA=e=>{if((0,Or.isEmpty)(e))return{value:"",unit:""};let t=e.match(/\[.*\]/g);if(t===null)return Mte(e);let o=(0,Or.get)(t,"0","").replace(/\[|\]/g,""),r=e.startsWith("-")?"-":"",n=(0,Or.first)(o.match(/\d+.\d+|\d+/g));return{value:`${r}${n}`,unit:o.replace(n,"")}},Mte=e=>(0,Or.isEmpty)(e)?{value:"",unit:""}:Lte(e)});var Kh,AA,Fr,xs,nr,Ote,Fte,j3,Hte,q3,K3=x(()=>{"use strict";Kh=require("@radix-ui/react-icons"),AA=require("@react-hookz/web"),Fr=require("lodash-es"),xs=require("react");TA();z3();W3();J();rs();nr=require("react/jsx-runtime"),Ote=({unit:e,currentValue:t,onDrag:o,onDragEnd:r,onDragStart:n,negative:a,cssProperty:s})=>{let{setDragData:i}=(0,xs.useContext)(Vw);return(0,nr.jsx)("button",{type:"button",onMouseDown:l=>{let c={onDrag:o,onDragEnd:r,dragging:!0,dragStartY:l.pageY,dragStartValue:`${t}`,dragUnit:e,negative:a,cssProperty:s};n(c),i(c)},color:void 0,className:"bg-surface/70 relative z-50 ml-1 hidden h-6 cursor-row-resize rounded px-2 group-hover:inline",children:(0,nr.jsx)(Kh.RowSpacingIcon,{})})},Fte=({onSelect:e,current:t,units:o})=>(0,nr.jsx)("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:o.map(r=>(0,nr.jsx)(E,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:t===r?"primary":void 0,size:"sm",onClick:n=>{n.stopPropagation(),e(r)},children:r},r))}),j3=50,Hte=(e,t,o)=>{let{value:r,unit:n}=EA(e);return n===""?{value:r,unit:t!=null&&t.toLowerCase().includes("width")?"%":(0,Fr.first)(o)}:{value:n==="class"||(0,Fr.isEmpty)(r)?"":r,unit:n}},q3=e=>{let{currentClass:t,onChange:o,classPrefix:r,cssProperty:n,units:a,negative:s}=e,i=Hte(t,n,a),[l,c]=(0,xs.useState)(!1),[d,p]=(0,xs.useState)(i.value),[u,m]=(0,xs.useState)(i.unit),[g,h]=(0,xs.useState)(!1),[f,b]=(0,xs.useState)(""),[y,k]=(0,xs.useState)(!1),[w,N]=(0,xs.useState)(!1);(0,xs.useEffect)(()=>{let{value:T,unit:v}=EA(t);queueMicrotask(()=>{if(v===""){let S=n!=null&&n.toLowerCase().includes("width")?"%":(0,Fr.first)(a);p(T),m(S);return}m(v),p(v==="class"||(0,Fr.isEmpty)(T)?"":T)})},[t,n,a]);let I=(0,AA.useThrottledCallback)(T=>o(T),[o],j3),C=(0,AA.useThrottledCallback)(T=>o(T,!1),[o],j3),P=(0,xs.useCallback)((T=!1)=>{let v=NA(`${d}`,a);if((0,Fr.get)(v,"error",!1)){h(!0);return}let S=(0,Fr.get)(v,"unit")!==""?(0,Fr.get)(v,"unit"):u;if(S==="auto"||S==="none"){I(`${r}${S}`);return}if((0,Fr.get)(v,"value")==="")return;let D=`${(0,Fr.get)(v,"value","").startsWith("-")?"-":""}${r}[${(0,Fr.get)(v,"value","").replace("-","")}${S==="-"?"":S}]`;T?C(D):I(D)},[I,C,d,u,r,a]),B=(0,xs.useCallback)(T=>{let v=NA(`${d}`,a);if((0,Fr.get)(v,"error",!1)){h(!0);return}if(T==="auto"||T==="none"){I(`${r}${T}`);return}if((0,Fr.get)(v,"value")==="")return;let S=(0,Fr.get)(v,"unit")!==""?(0,Fr.get)(v,"unit"):T,D=`${(0,Fr.get)(v,"value","").startsWith("-")?"-":""}${r}[${(0,Fr.get)(v,"value","").replace("-","")}${S==="-"?"":S}]`;I(D)},[I,d,r,a]);return(0,nr.jsx)("div",{className:"flex w-full flex-col",children:(0,nr.jsx)("div",{className:"flex items-center justify-start",children:u==="class"?(0,nr.jsxs)(nr.Fragment,{children:[(0,nr.jsx)("input",{className:"bg-surface h-6 w-24 rounded border border-foreground/20 px-2 py-0.5 text-sm focus-visible:outline-0",readOnly:!0,value:t}),(0,nr.jsxs)(Fo,{children:[(0,nr.jsx)(Ho,{asChild:!0,children:(0,nr.jsx)("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:(0,nr.jsx)(Kh.InfoCircledIcon,{})})}),(0,nr.jsx)(Bo,{children:"Current value is using a Tailwind preset class."})]})]}):(0,nr.jsxs)("div",{className:`group relative flex items-center ${y?"z-auto":""}`,children:[(0,nr.jsxs)("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(u)!==-1?null:(0,nr.jsx)("input",{readOnly:u==="class",onKeyPress:T=>{T.key==="Enter"&&P()},onKeyDown:T=>{if(T.keyCode!==38&&T.keyCode!==40)return;T.preventDefault(),N(!0);let v=(0,Fr.parseInt)(T.target.value),S=(0,Fr.isNaN)(v)?0:v;T.keyCode===38&&(S+=1),T.keyCode===40&&(S-=1);let A=`${S}`,R=`${A.startsWith("-")?"-":""}${r}[${A.replace("-","")}${u==="-"?"":u}]`;C(R)},onKeyUp:T=>{w&&(T.preventDefault(),N(!1))},onBlur:()=>P(),onChange:T=>{h(!1),p(T.target.value)},onClick:T=>{var v;(v=T==null?void 0:T.target)==null||v.select(),c(!1)},value:y?f:d,className:"bg-surface h-6 w-14 rounded rounded-r-none border border-transparent pl-2 text-sm focus-visible:outline-0".concat(" ",g?"border-red-500 text-red-500":"border-foreground/20")}),(0,nr.jsxs)(Fo,{open:l,delayDuration:100,children:[(0,nr.jsx)(Ho,{asChild:!0,children:(0,nr.jsxs)("button",{type:"button",onClick:()=>c(!l),className:"bg-surface flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none p-px px-1 text-[11px] uppercase",children:[(0,nr.jsx)("span",{className:`inline-block ${a.length===1?"px-2 font-semibold":""}`,children:u}),a.length>1?(0,nr.jsx)(Kh.TriangleDownIcon,{}):null]})}),(0,nr.jsx)(Bo,{className:"bg-surface",children:(0,nr.jsx)(Fte,{units:a,current:u,onSelect:T=>{c(!1),m(T),B(T)}})})]})]}),["none","auto"].indexOf(u)!==-1||y?null:(0,nr.jsx)(Ote,{onDragStart:()=>k(!0),onDragEnd:()=>{let T=f;if(b(()=>""),k(!1),(0,Fr.isEmpty)(T))return;let v=`${T}`,A=`${v.startsWith("-")?"-":""}${r}[${v.replace("-","")}${u==="-"?"":u}]`;I(A)},onDrag:T=>{if((0,Fr.isEmpty)(T))return;b(T);let v=`${T}`,A=`${v.startsWith("-")?"-":""}${r}[${v.replace("-","")}${u==="-"?"":u}]`;C(A)},currentValue:d,unit:u,negative:s,cssProperty:n})]})})})}});var Y3,Q3,wp,J3,Yh=x(()=>{"use strict";Y3=require("react"),Q3=require("react/jsx-runtime"),wp=(0,Y3.createContext)({canReset:!1,canChange:!0}),J3=({children:e,canReset:t=!1,canChange:o=!0})=>(0,Q3.jsx)(wp.Provider,{value:{canReset:t,canChange:o},children:e})});var Pp,IA,me,X3=x(()=>{"use strict";Pp=require("lodash-es"),IA=[0,1,2,3,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],me={columns:[...(0,Pp.range)(1,13),"auto","3xs","2xs","xs","sm","md","lg","xl",...(0,Pp.map)((0,Pp.range)(2,8),e=>`${e}xl`)],breakAfter:["auto","avoid","all","avoid-page","page","left","right","column"],breakInside:["auto","avoid","avoid-page","avoid-column"],display:["block","flex","grid","inline-block","inline","hidden"],objectFit:["contain","cover","fill","none","scale-down"],objectPosition:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],overflow:["auto","hidden","clip","visible","scroll"],overscroll:["auto","contain","none"],trbl:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...(0,Pp.range)(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"auto","1/2","1/3","2/3","1/4","2/4","3/4","full"],flexBasis:[...IA,"auto","px","0.5","1.5","2.5","3.5","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12","full"],padding:[...IA,"px","0.5","1.5","2.5","3.5"],margin:["auto",...IA,"px","0.5","1.5","2.5","3.5"],scale:[0,50,75,90,95,100,105,110,125,150],origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left"],blendEffect:["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],borderWidth:[0,2,4,8],borderRadius:["global","none","sm","md","lg","xl","2xl","3xl","full"],indent:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...(0,Pp.range)(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],maxHeight:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...(0,Pp.range)(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"full","screen","min","max","fit"],space:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...(0,Pp.range)(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"px","reverse"],width:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12"],maxWidth:["0","none","xs","sm","md","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","full","min","max","fit","prose","screen-sm","screen-md","screen-lg","screen-xl","screen-2xl"],height:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","full","screen","min","max","fit"]}});var Z3,V,Eg,Ng,Ute,Gte,$te,Vte,BA,zte,Wte,eU,tu,Ag=x(()=>{"use strict";Z3=K(require("fuse.js"),1),V=require("lodash-es"),Eg=require("react");Vc();X3();Ng={textColor:{classes:[],regExp:"text-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:(0,V.map)(me.columns,e=>`columns-${e}`),regExp:"columns-(auto|[0-9]xl|[0-9]xs|xs|sm|md|lg|xl|\\d+)"},breakAfter:{classes:(0,V.map)(me.breakAfter,e=>`break-after-${e}`),regExp:"break-after-\\S+"},breakBefore:{classes:(0,V.map)(me.breakAfter,e=>`break-before-${e}`),regExp:"break-before-\\S+"},breakInside:{classes:(0,V.map)(me.breakInside,e=>`break-inside-${e}`),regExp:"break-inside-\\S+"},boxDecoration:{classes:["box-decoration-clone","box-decoration-slice"],regExp:"box-decoration-\\S+"},boxSizing:{classes:["box-border","box-content"],regExp:"box-(border|content)"},flexDirection:{classes:["flex-row","flex-row-reverse","flex-col","flex-col-reverse"],regExp:"flex-(row|row-reverse|col|col-reverse)"},flexWrap:{classes:["flex-wrap","flex-wrap-reverse","flex-nowrap"],regExp:"flex-(wrap|wrap-reverse|nowrap)"},flexGrowShrink:{classes:["flex-1","flex-auto","flex-initial","flex-none"],regExp:"flex-1|flex-auto|flex-initial|flex-none"},gridColumns:{classes:(0,V.map)([...(0,V.range)(0,13),"none"],e=>`grid-cols-${e}`),regExp:"grid-cols-(\\d+|none)"},gridFlow:{classes:["grid-flow-row","grid-flow-col","grid-flow-row-dense","grid-flow-col-dense"],regExp:"grid-flow-(row|col|row-dense|col-dense)"},outlineStyle:{classes:(0,V.map)(["none","dashed","dotted","double","hidden"],e=>`outline-${e}`),regExp:"outline-(none|dashed|dotted|double|hidden)"},borderStyle:{classes:(0,V.map)(["solid","dashed","dotted","double","hidden","none"],e=>`border-${e}`),regExp:"border-(solid|dashed|dotted|double|hidden|none)"},overflow:{classes:(0,V.map)(me.overflow,e=>`overflow-${e}`),regExp:`overflow-(${me.overflow.join("|")})`},overflowX:{classes:(0,V.map)(me.overflow,e=>`overflow-x-${e}`),regExp:`overflow-x-(${me.overflow.join("|")})`},overflowY:{classes:(0,V.map)(me.overflow,e=>`overflow-y-${e}`),regExp:`overflow-y-(${me.overflow.join("|")})`},gridRows:{classes:(0,V.map)([1,2,3,4,5,6,"none"],e=>`grid-rows-${e}`),regExp:"grid-rows-(\\d|none)"},display:{classes:(0,V.map)(me.display,e=>e.toString()),regExp:`(${me.display.join("|")})`},float:{classes:["float-right","float-left","float-none"],regExp:"float-\\S+"},clear:{classes:["clear-right","clear-left","clear-none","clear-both"],regExp:"clear-\\S+"},isolation:{classes:["isolate","isolation-auto"],regExp:"isolate|isolation-auto"},objectFit:{classes:(0,V.map)(me.objectFit,e=>`object-${e}`),regExp:"object-(contain|cover|fill|none|scale-down)"},objectPosition:{classes:(0,V.map)(me.objectPosition,e=>`object-${e}`),regExp:`object-(${me.objectPosition.join("|")})`},overscroll:{classes:(0,V.map)(me.overscroll,e=>`overscroll-${e}`),regExp:`overscroll-(${me.overscroll.join("|")})`},overscrollX:{classes:(0,V.map)(me.overscroll,e=>`overscroll-x-${e}`),regExp:`overscroll-x-(${me.overscroll.join("|")})`},overscrollY:{classes:(0,V.map)(me.overscroll,e=>`overscroll-y-${e}`),regExp:`overscroll-y-(${me.overscroll.join("|")})`},inset:{classes:(0,V.map)(me.trbl,e=>`inset-${e}`),regExp:"-?inset-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetX:{classes:(0,V.map)(me.trbl,e=>`inset-x-${e}`),regExp:"-?inset-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetY:{classes:(0,V.map)(me.trbl,e=>`inset-y-${e}`),regExp:"-?inset-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},top:{classes:(0,V.map)(me.trbl,e=>`top-${e}`),regExp:"-?top-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topX:{classes:(0,V.map)(me.trbl,e=>`top-x-${e}`),regExp:"-?top-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topY:{classes:(0,V.map)(me.trbl,e=>`top-y-${e}`),regExp:"-?top-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},right:{classes:(0,V.map)(me.trbl,e=>`right-${e}`),regExp:"-?right-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightX:{classes:(0,V.map)(me.trbl,e=>`right-x-${e}`),regExp:"-?right-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightY:{classes:(0,V.map)(me.trbl,e=>`right-y-${e}`),regExp:"-?right-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottom:{classes:(0,V.map)(me.trbl,e=>`bottom-${e}`),regExp:"-?bottom-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomX:{classes:(0,V.map)(me.trbl,e=>`bottom-x-${e}`),regExp:"-?bottom-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomY:{classes:(0,V.map)(me.trbl,e=>`bottom-y-${e}`),regExp:"-?bottom-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},left:{classes:(0,V.map)(me.trbl,e=>`left-${e}`),regExp:"-?left-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftX:{classes:(0,V.map)(me.trbl,e=>`left-x-${e}`),regExp:"-?left-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftY:{classes:(0,V.map)(me.trbl,e=>`left-y-${e}`),regExp:"-?left-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},visibility:{classes:["visible","invisible"],regExp:"invisible|visible"},zIndex:{classes:(0,V.map)(["0",10,20,30,40,50,"auto"],e=>`z-${e}`),regExp:"-?z-(\\d+|auto|\\[.*\\])"},flexBasis:{classes:(0,V.map)(me.flexBasis,e=>`basis-${e}`),regExp:"basis-(\\d+|\\S+)"},flexGrow:{classes:["grow","grow-0"],regExp:"grow(-0)?"},flexShrink:{classes:["shrink","shrink-0"],regExp:"shrink(-0)?"},gridColSpan:{classes:["col-auto",...(0,V.map)((0,V.range)(1,13),e=>`col-span-${e}`),"col-span-full"],regExp:"col-(auto|span-(\\d+|full))"},gridColStart:{classes:[...(0,V.map)((0,V.range)(1,14),e=>`col-start-${e}`),"col-start-auto"],regExp:"col-start-(\\d+|auto)"},gridColEnd:{classes:[...(0,V.map)((0,V.range)(1,14),e=>`col-end-${e}`),"col-end-auto"],regExp:"col-end-(\\d+|auto)"},gridRowSpan:{classes:["row-auto",...(0,V.map)((0,V.range)(1,7),e=>`row-span-${e}`),"row-span-full"],regExp:"row-(auto|span-(\\d+|full))"},gridRowStart:{classes:[...(0,V.map)((0,V.range)(1,8),e=>`row-start-${e}`),"row-start-auto"],regExp:"row-start-(\\d+|auto)"},gridRowEnd:{classes:[...(0,V.map)((0,V.range)(1,8),e=>`row-end-${e}`),"row-end-auto"],regExp:"row-end-(\\d+|auto)"},gridAutoColumns:{classes:["auto-cols-auto","auto-cols-min","auto-cols-max","auto-cols-fr"],regExp:"auto-cols-(auto|min|max|fr)"},gridAutoRows:{classes:["auto-rows-auto","auto-rows-min","auto-rows-max","auto-rows-fr"],regExp:"auto-rows-(auto|min|max|fr)"},gap:{classes:(0,V.map)(me.indent,e=>`gap-${e}`),regExp:"gap-(px|\\d.\\d|\\d|\\[.*\\])"},gapX:{classes:(0,V.map)(me.indent,e=>`gap-x-${e}`),regExp:"gap-x-(px|\\d.\\d|\\d|\\[.*\\])"},gapY:{classes:(0,V.map)(me.indent,e=>`gap-y-${e}`),regExp:"gap-y-(px|\\d.\\d|\\d|\\[.*\\])"},justifyContent:{classes:["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"],regExp:"justify-(start|end|center|between|around|evenly)"},justifyItems:{classes:["justify-items-start","justify-items-end","justify-items-center","justify-items-stretch"],regExp:"justify-items-(start|end|center|stretch)"},justifySelf:{classes:["justify-self-auto","justify-self-start","justify-self-end","justify-self-center","justify-self-stretch"],regExp:"justify-self-(auto|start|end|center|stretch)"},placeContent:{classes:["place-content-center","place-content-start","place-content-end","place-content-between","place-content-around","place-content-evenly","place-content-stretch"],regExp:"place-content-(center|start|end|between|around|evenly|stretch)"},placeItems:{classes:["place-items-start","place-items-end","place-items-center","place-items-stretch"],regExp:"place-items-(start|end|center|stretch)"},placeSelf:{classes:["place-self-auto","place-self-start","place-self-end","place-self-center","place-self-stretch"],regExp:"place-self-(auto|start|end|center|stretch)"},alignContent:{classes:["content-center","content-start","content-end","content-between","content-around","content-evenly"],regExp:"content-(center|start|end|between|around|evenly)"},alignItems:{classes:["items-start","items-end","items-center","items-baseline","items-stretch"],regExp:"items-(start|end|center|baseline|stretch)"},alignSelf:{classes:["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"],regExp:"self-(auto|start|end|center|stretch|baseline)"},backgroundClip:{classes:["bg-clip-border","bg-clip-padding","bg-clip-content","bg-clip-text"],regExp:"bg-clip-(border|padding|content|text)"},dropShadow:{classes:(0,V.map)(["sm","md","lg","xl","2xl","none"],e=>`drop-shadow-${e}`),regExp:"drop-shadow-(sm|md|lg|xl|2xl|none)"},backdropBlur:{classes:(0,V.map)(["none","sm","md","lg","xl","2xl","3xl"],e=>`backdrop-blur-${e}`),regExp:"backdrop-blur-(none|sm|md|lg|xl|2xl|3xl)"},backdropBrightness:{classes:(0,V.map)([0,50,75,90,95,100,105,110,125,150,200],e=>`backdrop-brightness-${e}`),regExp:"backdrop-brightness-(\\d+)"},backdropContrast:{classes:(0,V.map)([0,50,75,100,125,150,200],e=>`backdrop-contrast-${e}`),regExp:"backdrop-contrast-(\\d+)"},backdropGrayScale:{classes:["backdrop-grayscale-0","backdrop-grayscale"],regExp:"backdrop-grayscale(-0)?"},backdropHueRotate:{classes:(0,V.map)([0,15,30,60,90,180],e=>`backdrop-hue-rotate-${e}`),regExp:"-?backdrop-hue-rotate-(\\d+)"},backdropInvert:{classes:["backdrop-invert-0","backdrop-invert"],regExp:"backdrop-invert(-0)?"},backdropOpacity:{classes:(0,V.map)([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],e=>`backdrop-opacity-${e}`),regExp:"backdrop-opacity-(\\d+)"},backdropSaturate:{classes:(0,V.map)([0,50,100,150,200],e=>`backdrop-saturate-${e}`),regExp:"backdrop-saturate-(\\d+)"},backdropSepia:{classes:["backdrop-sepia-0, backdrop-sepia"],regExp:"backdrop-sepia(-0)?"},backgroundOrigin:{classes:["bg-origin-border","bg-origin-padding","bg-origin-content"],regExp:"bg-origin-(border|padding|content)"},transformOrigin:{classes:(0,V.map)(me.origin,e=>`origin-${e}`),regExp:"origin-(\\d+|\\S+)"},padding:{classes:(0,V.map)(me.padding,e=>`p-${e}`),regExp:"p-(\\d+|\\S+|\\[.*\\])"},paddingX:{classes:(0,V.map)(me.padding,e=>`px-${e}`),regExp:"px-(\\d+|\\S+|\\[.*\\])"},paddingY:{classes:(0,V.map)(me.padding,e=>`py-${e}`),regExp:"py-(\\d+|\\S+|\\[.*\\])"},paddingTop:{classes:(0,V.map)(me.padding,e=>`pt-${e}`),regExp:"pt-(\\d+|\\S+|\\[.*\\])"},paddingRight:{classes:(0,V.map)(me.padding,e=>`pr-${e}`),regExp:"pr-(\\d+|\\S+|\\[.*\\])"},paddingBottom:{classes:(0,V.map)(me.padding,e=>`pb-${e}`),regExp:"pb-(\\d+|\\S+|\\[.*\\])"},paddingLeft:{classes:(0,V.map)(me.padding,e=>`pl-${e}`),regExp:"pl-(\\d+|\\S+|\\[.*\\])"},textDecorationStyle:{classes:["decoration-solid","decoration-double","decoration-dotted","decoration-dashed","decoration-wavy"],regExp:"decoration-(solid|double|dotted|dashed|wavy)"},textDecorationThickness:{classes:(0,V.map)(["auto","from-font","0",1,2,4,8],e=>`decoration-${e}`),regExp:"decoration-(auto|from-font|\\d+|\\S+)"},fromColor:{classes:[],regExp:"from-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},margin:{classes:(0,V.map)(me.margin,e=>`m-${e}`),regExp:"-?m-(\\d+|\\S+|\\[.*\\])"},marginX:{classes:(0,V.map)(me.margin,e=>`mx-${e}`),regExp:"-?mx-(\\d+|\\S+|\\[.*\\])"},marginY:{classes:(0,V.map)(me.margin,e=>`my-${e}`),regExp:"-?my-(\\d+|\\S+|\\[.*\\])"},marginTop:{classes:(0,V.map)(me.margin,e=>`mt-${e}`),regExp:"-?mt-(\\d+|\\S+|\\[.*\\])"},marginRight:{classes:(0,V.map)(me.margin,e=>`mr-${e}`),regExp:"-?mr-(\\d+|\\S+|\\[.*\\])"},marginBottom:{classes:(0,V.map)(me.margin,e=>`mb-${e}`),regExp:"-?mb-(\\d+|\\S+|\\[.*\\])"},marginLeft:{classes:(0,V.map)(me.margin,e=>`ml-${e}`),regExp:"-?ml-(\\d+|\\S+|\\[.*\\])"},spaceX:{classes:(0,V.map)(me.space,e=>`space-x-${e}`),regExp:"-?space-x-(\\d+|\\S+|\\[.*\\])"},spaceY:{classes:(0,V.map)(me.space,e=>`space-y-${e}`),regExp:"-?space-y-(\\d+|\\S+|\\[.*\\])"},boxShadow:{classes:(0,V.map)(["sm","md","lg","xl","2xl","inner","none"],e=>`shadow-${e}`),regExp:"shadow-(sm|md|lg|xl|2xl|inner|none)"},minWidth:{classes:["min-w-0","min-w-full","min-w-min","min-w-max","min-w-fit"],regExp:"min-w-(\\d+|\\S+|\\[.*\\])"},maxWidth:{classes:(0,V.map)(me.maxWidth,e=>`max-w-${e}`),regExp:"max-w-(\\d+|\\S+|\\[.*\\])"},width:{classes:(0,V.map)([...me.width,"full","screen","min","max","fit"],e=>`w-${e}`),regExp:"w-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])$"},minHeight:{classes:["min-h-0","min-h-full","min-h-screen","min-h-min","min-h-max","min-h-fit"],regExp:"min-h-(\\d+|\\S+|\\[.*\\])"},maxHeight:{classes:(0,V.map)(me.maxHeight,e=>`max-h-${e}`),regExp:"max-h-(\\d+|\\S+|\\[.*\\])"},height:{classes:(0,V.map)(me.height,e=>`h-${e}`),regExp:"h-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])"},fontFamily:{classes:["font-heading","font-body","font-sans","font-serif","font-mono"],regExp:"font-(heading|body|sans|serif|mono)"},textAlign:{classes:["text-left","text-center","text-right","text-justify"],regExp:"text-(left|center|right|justify)"},textOverflow:{classes:["truncate","text-ellipsis","text-clip"],regExp:"truncate|text-ellipsis|text-clip"},verticalAlign:{classes:["align-baseline","align-top","align-middle","align-bottom","align-text-top","align-text-bottom","align-sub","align-super"],regExp:"align-(baseline|top|middle|bottom|text-top|text-bottom|sub|super)"},fontSize:{classes:["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"],regExp:"text-(\\d+|\\S+|\\[.*\\])"},fontSmoothing:{classes:["antialiased","subpixel-antialiased"],regExp:"antialiased|subpixel-antialiased"},fontStyle:{classes:["italic","not-italic"],regExp:"not-italic|italic"},fontWeight:{classes:["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"],regExp:"font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)"},fontVariantNum:{classes:["normal-nums","ordinal","diagonal-fractions","stacked-fractions","tabular-nums","oldstyle-nums","proportional-nums","lining-nums","slashed-zero"],regExp:"normal-nums|ordinal|diagonal-fractions|stacked-fractions|tabular-nums|oldstyle-nums|proportional-nums|lining-nums|slashed-zero"},letterSpacing:{classes:["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"],regExp:"-?tracking-(tighter|tight|normal|wide|wider|widest|\\[.*\\])"},lineHeight:{classes:["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"],regExp:"leading-(none|tight|snug|normal|relaxed|loose|\\[.*\\]|\\d+)"},listStyleType:{classes:["list-none","list-disc","list-decimal"],regExp:"list-(none|disc|decimal)"},listStylePosition:{classes:["list-inside","list-outside"],regExp:"list-(inside|outside)"},textUnderlineOffset:{classes:["underline-offset-auto","underline-offset-0","underline-offset-1","underline-offset-2","underline-offset-4","underline-offset-8"],regExp:"underline-offset-(auto|\\d+|\\S+)"},textDecoration:{classes:["underline","overline","line-through","no-underline"],regExp:"underline|overline|line-through|no-underline"},textDecorationColor:{classes:[],regExp:"decoration-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:(0,V.map)(me.indent,e=>`indent-${e}`),regExp:"-?indent-(\\d+|\\S+)"},whitespace:{classes:["whitespace-normal","whitespace-nowrap","whitespace-pre","whitespace-pre-line","whitespace-pre-wrap"],regExp:"whitespace-(normal|nowrap|pre|pre-line|pre-wrap)"},wordBreak:{classes:["break-normal","break-words","break-all"],regExp:"break-(normal|words|all)"},content:{classes:["content-none"],regExp:"content-none"},backgroundAttachment:{classes:(0,V.map)(["fixed","local","scroll"],e=>`bg-${e}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...(0,V.map)(me.borderRadius,e=>`rounded-tl-${e}`)],regExp:"rounded-tl-?(\\d+|\\S+)?"},borderRadiusTopRight:{classes:["rounded-tr",...(0,V.map)(me.borderRadius,e=>`rounded-tr-${e}`)],regExp:"rounded-tr-?(\\d+|\\S+)?"},borderRadiusBottomRight:{classes:["rounded-br",...(0,V.map)(me.borderRadius,e=>`rounded-br-${e}`)],regExp:"rounded-br-?(\\d+|\\S+)?"},borderRadiusBottomLeft:{classes:["rounded-bl",...(0,V.map)(me.borderRadius,e=>`rounded-bl-${e}`)],regExp:"rounded-bl-?(\\d+|\\S+)?"},borderRadiusTop:{classes:["rounded-t",...(0,V.map)(me.borderRadius,e=>`rounded-t-${e}`)],regExp:"rounded-t-?(\\d+|\\S+)?"},borderRadiusRight:{classes:["rounded-r",...(0,V.map)(me.borderRadius,e=>`rounded-r-${e}`)],regExp:"rounded-r-?(\\d+|\\S+)?"},borderRadiusBottom:{classes:["rounded-b",...(0,V.map)(me.borderRadius,e=>`rounded-b-${e}`)],regExp:"rounded-b-?(\\d+|\\S+)?"},borderRadiusLeft:{classes:["rounded-l",...(0,V.map)(me.borderRadius,e=>`rounded-l-${e}`)],regExp:`(rounded-l-(${me.borderRadius.join("|")})|rounded-l$)`},borderRadius:{classes:["rounded",...(0,V.map)(me.borderRadius,e=>`rounded-${e}`)],regExp:`(rounded-(${me.borderRadius.join("|")}$)|rounded)`},borderX:{classes:["border-x",...(0,V.map)(me.borderWidth,e=>`border-x-${e}`)],regExp:"border-x-?(\\d+|\\S+|\\[.*\\])?"},borderY:{classes:["border-y",...(0,V.map)(me.borderWidth,e=>`border-y-${e}`)],regExp:"border-y-?(\\d+|\\S+|\\[.*\\])?"},borderTop:{classes:["border-t",...(0,V.map)(me.borderWidth,e=>`border-t-${e}`)],regExp:"border-t-?(\\d+|\\S+|\\[.*\\])?"},borderRight:{classes:["border-r",...(0,V.map)(me.borderWidth,e=>`border-r-${e}`)],regExp:"border-r-?(\\d+|\\S+|\\[.*\\])?"},borderBottom:{classes:["border-b",...(0,V.map)(me.borderWidth,e=>`border-b-${e}`)],regExp:"border-b-?(\\d+|\\S+|\\[.*\\])?"},borderLeft:{classes:["border-l",...(0,V.map)(me.borderWidth,e=>`border-l-${e}`)],regExp:"border-l-?(\\d+|\\S+|\\[.*\\])?"},borderColor:{classes:[],regExp:"^border-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...(0,V.map)(me.borderWidth,e=>`border-${e}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},order:{classes:(0,V.map)([...(0,V.range)(0,13),"first","last","none"],e=>`order-${e}`),regExp:"-?order-(\\d+|first|last|none)"},divideXWidth:{classes:(0,V.map)(["0",2,4,8],e=>`divide-x-${e}`),regExp:"divide-x-(\\d+|\\[.*\\])"},divideYWidth:{classes:(0,V.map)(["0",2,4,8],e=>`divide-y-${e}`),regExp:"divide-y-(\\d+|\\[.*\\])"},divideColor:{classes:[],regExp:"divide-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},divideStyle:{classes:(0,V.map)(["solid","dashed","dotted","double","none"],e=>`divide-${e}`),regExp:"divide-(solid|dashed|dotted|double|none)"},outlineWidth:{classes:(0,V.map)([0,1,2,4,8],e=>`outline-${e}`),regExp:"outline-(\\d+)"},outlineOffset:{classes:(0,V.map)([0,1,2,4,8],e=>`outline-offset-${e}`),regExp:"outline-offset-(\\d+)"},outlineColor:{classes:[],regExp:"outline-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringWidth:{classes:(0,V.map)([0,1,2,4,8,"inset"],e=>`ring-${e}`),regExp:"ring-(\\d+|inset)"},ringOffsetWidth:{classes:(0,V.map)([0,1,2,4,8],e=>`ring-offset-${e}`),regExp:"ring-offset-(\\d+)"},ringOffsetColor:{classes:[],regExp:"ring-offset-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:(0,V.map)([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],e=>`opacity-${e}`),regExp:"opacity-(\\d+|\\[.*\\])"},mixBlendMode:{classes:(0,V.map)(me.blendEffect,e=>`mix-blend-${e}`),regExp:"mix-blend-(\\d+|\\S+)"},bgBlendMode:{classes:(0,V.map)(me.blendEffect,e=>`bg-blend-${e}`),regExp:"bg-blend-(\\d+|\\S+)"},blur:{classes:(0,V.map)(["none","sm","md","lg","xl","2xl","3xl"],e=>`blur-${e}`),regExp:"blur-(none|sm|md|lg|xl|2xl|3xl)"},brightness:{classes:(0,V.map)([0,50,75,90,95,100,105,110,125,150,200],e=>`brightness-${e}`),regExp:"brightness-(\\d+)"},contrast:{classes:(0,V.map)([0,50,75,100,125,150,200],e=>`contrast-${e}`),regExp:"contrast-(\\d+)"},grayScale:{classes:["grayscale-0","grayscale"],regExp:"grayscale(-0)?"},hueRotate:{classes:(0,V.map)([0,15,30,60,90,180],e=>`hue-rotate-${e}`),regExp:"-?hue-rotate-(\\d+)"},invert:{classes:["invert-0","invert"],regExp:"invert(-0)?"},saturate:{classes:(0,V.map)([0,50,100,150,200],e=>`saturate-${e}`),regExp:"saturate-(\\d+)"},sepia:{classes:["sepia-0","sepia"],regExp:"sepia(-0)?"},transition:{classes:["transition-none","transition-all","transition-colors","transition-opacity","transition-shadow","transition-transform"],regExp:"transition-(none|all|colors|opacity|shadow|transform)"},duration:{classes:(0,V.map)([75,100,150,200,300,500,700,1e3],e=>`duration-${e}`),regExp:"duration-(\\d+|\\[.*\\])"},transitionEase:{classes:["ease-linear","ease-in","ease-out","ease-in-out"],regExp:"eas(e-linear|e-in|e-out|e-in-out)"},transitionDelay:{classes:(0,V.map)([75,100,150,200,300,500,700,1e3],e=>`delay-${e}`),regExp:"delay-(\\d+|\\[.*\\])"},animation:{classes:["animate-none","animate-spin","animate-ping"],regExp:"animate-(none|spin|ping)"},scaleX:{classes:(0,V.map)(me.scale,e=>`scale-x-${e}`),regExp:"-?scale-x-(\\d+|\\S+|\\[.*\\])"},scaleY:{classes:(0,V.map)(me.scale,e=>`scale-y-${e}`),regExp:"-?scale-y-(\\d+|\\S+|\\[.*\\])"},scale:{classes:(0,V.map)(me.scale,e=>`scale-${e}`),regExp:"-?scale-(\\d+|\\S+|\\[.*\\])"},rotate:{classes:(0,V.map)([0,1,2,3,6,12,45,90,180],e=>`rotate-${e}`),regExp:"-?rotate-(\\d+|\\S+|\\[.*\\])"},translateX:{classes:(0,V.map)([0,"px","0.5",1],e=>`translate-x-${e}`),regExp:"-?translate-x-(\\d+|\\S+|\\[.*\\])"},translateY:{classes:(0,V.map)([0,"px","0.5",1],e=>`translate-y-${e}`),regExp:"-?translate-y-(\\d+|\\S+|\\[.*\\])"},skewX:{classes:(0,V.map)([0,1,2,3,6,12],e=>`skew-x-${e}`),regExp:"-?skew-x-(\\d+|\\S+|\\[.*\\])"},skewY:{classes:(0,V.map)([0,1,2,3,6,12],e=>`skew-y-${e}`),regExp:"-?skew-y-(\\d+|\\S+|\\[.*\\])"},accentColor:{classes:[],regExp:"accent-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},Ute={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},Gte=["current","inherit","transparent","black","white"],$te=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],Vte=["50","100","200","300","400","500","600","700","800","900"],BA=(0,V.map)((0,V.values)(Ute),e=>e),zte=(0,V.flattenDeep)([...(0,V.map)(Gte,e=>(0,V.flatten)((0,V.map)(BA,t=>`${t}-${e}`))),...(0,V.map)($te,e=>(0,V.flattenDeep)((0,V.map)(BA,t=>(0,V.flattenDeep)((0,V.map)(Vte,o=>`${t}-${e}-${o}`)))))]),Wte=(0,V.map)((0,V.flattenDeep)((0,V.values)(Ng).map(e=>e.classes).concat(zte)),e=>({name:e})),eU=()=>{let e=nm(),t=(0,Eg.useMemo)(()=>{let o=[];if(e.colors){let r=(0,V.flattenDeep)((0,V.map)(e.colors,({items:n})=>(0,V.keys)(n)));o=(0,V.flattenDeep)((0,V.map)(r,n=>(0,V.flatten)((0,V.map)(BA,a=>`${a}-${n}`))))}return e.fontFamily&&(o=[...o,...(0,V.map)((0,V.keys)(e.fontFamily),r=>`${r}`)]),(0,V.map)(o,r=>({name:r}))},[e]);return(0,Eg.useMemo)(()=>new Z3.default([...Wte,...t],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[t])},tu=()=>{let e=nm(),t=(0,Eg.useMemo)(()=>{if(e.colors){let n=(0,V.flattenDeep)((0,V.map)(e.colors,({items:a})=>(0,V.keys)(a)));(0,V.each)(Ng,(a,s)=>{(0,V.set)(Ng,`${s}.regExp`,a.regExp.replace("__THEME_COLORS_REGEXP__",n.join("|")))})}return Ng},[e]),o=(0,Eg.useCallback)((n,a)=>{let s=(0,V.get)(t,`${n}.regExp`,"");return a.match(new RegExp(s))},[t]),r=(0,Eg.useCallback)((n,a=[])=>(0,V.get)(t,`${n}.classes`,a),[t]);return{match:o,getClasses:r}}});function jw({selected:e,onChange:t,rounded:o=!1,options:r,disabled:n=!1}){let a=e.replace(/.*:/g,"").trim(),{undo:s,redo:i}=Mc();return(0,Zs.jsxs)("select",{disabled:!r.length||n,className:`${o?"rounded-md border border-border":"border-0"} bg-surface h-full w-full truncate rounded px-2 py-1 text-xs outline-none disabled:cursor-not-allowed disabled:bg-gray-500`,onChange:l=>t(l.target.value),onKeyDown:l=>{l.ctrlKey&&(l.key==="z"&&s(),l.key==="y"&&i())},value:a,children:[(0,Zs.jsx)("option",{className:"bg-transparent",value:""}),r.map((l,c)=>(0,Zs.jsx)("option",{className:"bg-transparent",value:l,children:l},`option-${c}`))]})}var tU,oU,zw,Zs,Ww,qw=x(()=>{"use strict";tU=require("@radix-ui/react-icons"),oU=require("lodash-es"),zw=require("react");Ig();Yh();Pf();fo();rs();Ag();Zs=require("react/jsx-runtime"),Ww=({label:e,property:t,onChange:o})=>{let{getClasses:r}=tu(),n=r(t),a=Tp(t),s=(0,zw.useMemo)(()=>(0,oU.get)(a,"cls",""),[a]),{canChange:i}=(0,zw.useContext)(wp),l=/\[.*\]/g.test(s);return(0,Zs.jsx)("div",{className:e?"w-full rounded":"grow",children:l?(0,Zs.jsxs)("div",{className:"flex items-center",children:[(0,Zs.jsx)(Ce,{className:"w-[70%] rounded py-1",readOnly:!0,value:s}),(0,Zs.jsxs)(Fo,{delayDuration:100,children:[(0,Zs.jsx)(Ho,{asChild:!0,children:(0,Zs.jsx)("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:(0,Zs.jsx)(tU.InfoCircledIcon,{})})}),(0,Zs.jsx)(Bo,{children:"Current value is using a Tailwind arbitrary value."})]})]}):(0,Zs.jsx)(jw,{rounded:e,onChange:c=>o(c,t),selected:s,options:n,disabled:!i})})}});var Xx,Cl,Bg,jte,rU,nU=x(()=>{"use strict";Xx=require("lodash-es"),Cl=require("react");Ig();qw();Yh();Ag();Bg=require("react/jsx-runtime"),jte={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},rU=({property:e,onChange:t})=>{let o=Tp(e),r=(0,Cl.useMemo)(()=>(0,Xx.get)(o,"cls",""),[o]),{canChange:n}=(0,Cl.useContext)(wp),a=r.split("-"),s=(0,Xx.get)(a,"1",""),i=(0,Xx.get)(a,"2",""),[l,c]=(0,Cl.useState)({color:"",shade:""}),d=(0,Cl.useMemo)(()=>{let g=l.color||s;return["current","inherit","transparent","black","white"].includes(g)?[]:["50","100","200","300","400","500","600","700","800","900"]},[l.color,s]),p=(0,Cl.useCallback)(g=>{["current","inherit","transparent","black","white"].includes(g)?c({color:g}):c(h=>({...h,color:g,shade:h.shade?h.shade:"500"}))},[]),u=(0,Cl.useCallback)(g=>{c({color:s,shade:g})},[s]),{match:m}=tu();return(0,Cl.useEffect)(()=>{let h=`${(0,Xx.get)(jte,e,"")}-${l.color}${l.shade?`-${l.shade}`:""}`;m(e,h)&&t(h,e)},[m,l,t,e]),(0,Bg.jsxs)("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[(0,Bg.jsx)("div",{className:"grow text-center",children:(0,Bg.jsx)(jw,{disabled:!n,rounded:!0,selected:s,onChange:p,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),(0,Bg.jsx)("button",{type:"button",className:"grow text-center",children:(0,Bg.jsx)(jw,{rounded:!0,selected:i,disabled:!s||!n,onChange:u,options:d})})]})}});var re,Jr,Kw,RA=x(()=>{"use strict";re=require("@radix-ui/react-icons"),Jr=require("react/jsx-runtime"),Kw={"not-italic":()=>(0,Jr.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Jr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:re.EyeOpenIcon,invisible:re.EyeClosedIcon,hidden:re.EyeClosedIcon,gap:re.BorderAllIcon,gapX:re.WidthIcon,gapY:re.HeightIcon,spaceX:re.WidthIcon,spaceY:re.HeightIcon,overscroll:re.BorderAllIcon,overscrollX:re.WidthIcon,overscrollY:re.HeightIcon,overflow:re.BorderAllIcon,overflowX:re.WidthIcon,overflowY:re.HeightIcon,top:re.ArrowUpIcon,right:re.ArrowRightIcon,bottom:re.ArrowDownIcon,left:re.ArrowLeftIcon,inset:re.BorderAllIcon,insetX:re.WidthIcon,insetY:re.HeightIcon,border:re.BorderAllIcon,borderX:re.WidthIcon,borderY:re.HeightIcon,borderTop:re.ArrowUpIcon,borderRight:re.ArrowRightIcon,borderBottom:re.ArrowDownIcon,borderLeft:re.ArrowLeftIcon,borderRadius:re.BorderAllIcon,borderRadiusX:re.WidthIcon,borderRadiusY:re.HeightIcon,borderRadiusTop:re.ArrowUpIcon,borderRadiusRight:re.ArrowRightIcon,borderRadiusBottom:re.ArrowDownIcon,borderRadiusLeft:re.ArrowLeftIcon,borderRadiusTopLeft:re.ArrowTopLeftIcon,borderRadiusTopRight:re.ArrowTopRightIcon,borderRadiusBottomRight:re.ArrowBottomRightIcon,borderRadiusBottomLeft:re.ArrowBottomLeftIcon,divideXWidth:re.WidthIcon,divideYWidth:re.HeightIcon,scale:re.BorderAllIcon,scaleX:re.WidthIcon,scaleY:re.HeightIcon,skewX:re.WidthIcon,skewY:re.HeightIcon,translateX:re.WidthIcon,translateY:re.HeightIcon,padding:re.BorderAllIcon,paddingX:re.WidthIcon,paddingY:re.HeightIcon,paddingTop:re.ArrowUpIcon,paddingRight:re.ArrowRightIcon,paddingBottom:re.ArrowDownIcon,paddingLeft:re.ArrowLeftIcon,margin:re.BorderAllIcon,marginX:re.WidthIcon,marginY:re.HeightIcon,marginTop:re.ArrowUpIcon,marginRight:re.ArrowRightIcon,marginBottom:re.ArrowDownIcon,marginLeft:re.ArrowLeftIcon,textLeft:re.AlignLeftIcon,textCenter:re.AlignCenterHorizontallyIcon,textRight:re.AlignRightIcon,textJustify:re.StretchHorizontallyIcon,italic:re.FontItalicIcon,underline:re.UnderlineIcon,overline:re.OverlineIcon,uppercase:re.LetterCaseUppercaseIcon,block:()=>(0,Jr.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Jr.jsx)("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),(0,Jr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>(0,Jr.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Jr.jsx)("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),(0,Jr.jsx)("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>(0,Jr.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Jr.jsx)("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),(0,Jr.jsx)("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":re.Cross2Icon,fixed:()=>(0,Jr.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Jr.jsx)("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),(0,Jr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>(0,Jr.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Jr.jsx)("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),(0,Jr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>(0,Jr.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Jr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>(0,Jr.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Jr.jsx)("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),(0,Jr.jsx)("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:re.Cross1Icon}});var aU,Np,Jh,Rg,sU,iU=x(()=>{"use strict";aU=require("@radix-ui/react-icons"),Np=require("lodash-es"),Jh=K(require("react"),1);Ig();Yh();rs();Ag();RA();Rg=require("react/jsx-runtime"),sU=({property:e,onChange:t})=>{let{getClasses:o}=tu(),r=o(e),{canChange:n}=(0,Jh.useContext)(wp),a=Tp(e),s=(0,Jh.useMemo)(()=>(0,Np.get)(a,"cls",""),[a]);return(0,Rg.jsx)("div",{className:"flex grow flex-wrap gap-1",children:(0,Np.map)(r,i=>(0,Rg.jsxs)(Fo,{children:[(0,Rg.jsx)(Ho,{asChild:!0,children:(0,Rg.jsx)("button",{type:"button",disabled:!n,onClick:()=>t(i,e),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${s===i?"bg-primary text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:Jh.default.createElement((0,Np.get)(Kw,i,aU.BoxIcon))})}),(0,Rg.jsx)(Bo,{children:(0,Np.startCase)((0,Np.toLower)(i))})]}))})}});var Yw,Zx,Jw,vs,lU,cU=x(()=>{"use strict";Yw=require("@radix-ui/react-icons"),Zx=require("lodash-es"),Jw=require("react");Ig();qw();Yh();Ag();vs=require("react/jsx-runtime"),lU=({property:e,onChange:t})=>{let{canReset:o,canChange:r}=(0,Jw.useContext)(wp),n=Tp(e),a=(0,Jw.useMemo)(()=>(0,Zx.get)(n,"cls",""),[n]),{getClasses:s}=tu(),i=s(e,[""]),l=i.indexOf(a)>-1?i.indexOf(a):0,c=/\[.*\]/g.test(a);return(0,vs.jsx)("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:c?(0,vs.jsx)("div",{className:"px-2 py-[5px]",children:a}):(0,vs.jsxs)(vs.Fragment,{children:[(0,vs.jsx)("button",{type:"button",className:"hover:bg-bg-gray-700 bg-surface box-border w-2/12 rounded-bl rounded-tl px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!r&&(!o||l-1<0),onClick:()=>t((0,Zx.nth)(i,l-1),e),children:(0,vs.jsx)("span",{className:"flex items-center justify-center",children:(0,vs.jsx)(Yw.MinusIcon,{className:!r&&(!o||l-1<0)?"text-gray-500":"text-background/60 dark:text-white/60"})})}),(0,vs.jsx)("div",{className:"w-8/12 text-center",children:(0,vs.jsx)(Ww,{label:!1,property:e,onChange:t})}),(0,vs.jsx)("button",{type:"button",className:"hover:bg-bg-gray-700 bg-surface w-2/12 rounded-br rounded-tr px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!r&&(!o||l+1>=i.length),onClick:()=>t((0,Zx.nth)(i,l+1),e),children:(0,vs.jsx)("span",{className:"flex items-center justify-center",children:(0,vs.jsx)(Yw.PlusIcon,{className:!r&&(!o||l+1>=i.length)?"text-gray-500":"text-background/60 dark:text-white/60"})})})]})})}});var dU,pU=x(()=>{"use strict";dU=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","hs-collapse-open","hs-accordion-active"]});function qte(e){if((0,kl.isEmpty)(e.trim()))return"";let t=e.match(/sm:|md:|lg:|xl:|2xl:/g);return(0,kl.get)(t,0,"xs").replace(":","")}function Kte(e){let t=(0,kl.map)(dU,r=>`${r}:`).join("|"),o=new RegExp(t,"g");return(0,kl.get)(o.exec(e.trim()),0,"").replace(":","")}function Yte(e){return e.trim().split(":").pop()||""}function Jte(e){if((0,kl.isEmpty)(e))return"";if(DA[e])return DA[e];let t="";for(let o in Ng){let r=(0,kl.get)(Ng,`${o}.regExp`,"");if(new RegExp(r,"g").test(e)){t=o,DA[e]=t;break}}return t}function ou(e){return(0,kl.isEmpty)(e)?null:{dark:(0,kl.startsWith)(e,"dark:"),mq:qte(e),mod:Kte(e),cls:Yte(e),fullCls:e,property:Jte(e)}}function mU(e){let t="";return e.dark&&(t+="dark:"),e.mq.toLowerCase()!=="xs"&&(t+=`${e.mq}:`),e.mod&&(t+=`${e.mod}:`),t+=e.cls,t}var kl,DA,Qh=x(()=>{"use strict";kl=require("lodash-es");Ag();pU();DA={}});function Qw(e){e=e.replace(/\s+/g," ");let t=e.split(" ").map(ou).filter(r=>r!==null),o=["xs","sm","md","lg","xl","2xl"];return t.sort((r,n)=>o.indexOf(r.mq)-o.indexOf(n.mq)).map(r=>r.fullCls).join(" ")}var _A=x(()=>{"use strict";Qh()});function Xw(e){if(e=e.replace(/\s+/g," "),!e)return"";let t=["xs","sm","md","lg","xl","2xl"],o=e.split(" ").map(ou).filter(n=>n!==null),r=e;if(o.length===1)return o[0].fullCls;for(let n of o){let a=n.property,s=t.indexOf(n.mq);for(let i=s+1;i<t.length;i++){let l=t[i],c=o.find(d=>d.property===a&&d.mq===l);if(c&&c.cls===n.cls)r=r.replace(c.fullCls,"");else if(c&&c.cls!==n.cls)break}}return r.replace(/\s+/g," ").trim()}var LA=x(()=>{"use strict";Qh()});var Zw,ru,uU,gU,Qte,eP,MA=x(()=>{"use strict";Zw=require("jotai"),ru=require("lodash-es"),uU=require("react"),gU=require("cnfast");zr();_A();LA();dp();ko();fn();Tn();Qte=(0,Zw.atom)(null,(e,t,{blockIds:o,newClasses:r})=>{let n=(0,ru.filter)(e(Kp),s=>o.includes(e(s)._id)),a=(0,ru.first)(e(mm));return(0,ru.map)(n,s=>{let i=e(s),l=(0,ru.get)(i,a.prop,`${lr},`),{classes:c}=ys(l);return{ids:[i._id],props:{[a.prop]:`${lr},${Qw(Xw((0,gU.twMerge)(c,r)))}`}}})}),eP=()=>{let e=(0,Zw.useSetAtom)(Qte),{updateBlocks:t,updateBlocksRuntime:o}=Ft();return(0,uU.useCallback)((r,n,a=!1)=>{let s=e({blockIds:r,newClasses:n});if(!a){o(r,s[0].props);return}t(r,s[0].props)},[e,t,o])}});var fU,hU=x(()=>{"use strict";fU=e=>{let t=["xs","sm","md","lg","xl","2xl"],o=t.indexOf(e);return o===-1?["xs"]:t.slice(0,o+1)}});var ev,Ka,Xte,yU,Zte,Dg,tP=x(()=>{"use strict";ev=require("jotai"),Ka=require("lodash-es");Qh();hU();dp();Im();Rm();Ge();fn();Tn();Xte=(0,ev.atom)(e=>{let t=(0,Ka.first)(e(mm)),o=e(tm);if(!t||t.blockId!==(0,Ka.get)(o,"_id",null))return[];let r=(0,Ka.get)(o,t.prop,`${lr},`),{classes:n}=ys(r);return(0,Ka.filter)((0,Ka.map)(n.trim().split(" "),ou),a=>!(0,Ka.isNull)(a))}),yU={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},Zte=(0,ev.atom)(e=>{let t=e(IE),o=e(Rb),r=e(EE),n=fU(t),a=(0,Ka.filter)(e(Xte),{mod:o});return(0,Ka.startsWith)(o,"_")||(a=(0,Ka.filter)(a,s=>n.includes(s.mq))),a=a.sort((s,i)=>yU[s.mq]-yU[i.mq]),r||(a=(0,Ka.filter)(a,{dark:!1})),a}),Dg=()=>(0,ev.useAtomValue)(Zte)});var bU,xU,vU=x(()=>{"use strict";bU=require("jotai");Ge();xU=()=>(0,bU.useAtom)(Rb)});var oP,Di,Ep,kU,Pr,Tp,eoe,toe,CU,ooe,Xh,Ig=x(()=>{"use strict";oP=require("@radix-ui/react-icons"),Di=require("lodash-es"),Ep=require("react"),kU=require("react-i18next");K3();nU();qw();iU();cU();Yh();Qh();MA();Im();Jx();Rm();tP();Ge();vU();rs();Pr=require("react/jsx-runtime"),Tp=e=>{let t=Dg();return(0,Di.findLast)(t,{property:e})},eoe=(e,t)=>{let o={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return o[(0,Di.get)(e,"mq","xs")]<=o[t]},toe={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},CU={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},ooe=e=>`${e.toUpperCase()} ${CU[e]?`(${CU[e]} & up)`:""}`,Xh=e=>{let{t}=(0,kU.useTranslation)(),{type:o="icons",label:r,property:n,onEmitChange:a=()=>{},units:s,negative:i=!1}=e,[l]=ec(),[c]=xU(),[,d]=Tx(),p=Tp(n),u=eP(),m=qh(),[g]=Pe(),h=(0,Ep.useMemo)(()=>(0,Di.get)(p,"fullCls",""),[p]),f=(0,Ep.useCallback)((I,C=!0)=>{let P={dark:l,mq:d,mod:c,cls:I,property:n,fullCls:""};(l||c!=="")&&(P.mq="xs");let B=mU(P);u(g,[B],C)},[g,l,d,c,n,u]),b=(0,Ep.useCallback)(()=>{m(g,[h],!0)},[g,h,m]),y=(0,Ep.useMemo)(()=>eoe(p,d),[p,d]);(0,Ep.useEffect)(()=>{a(y,p)},[y,a,p]);let[,,k]=Tx(),w=(0,Ep.useCallback)(I=>{k({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[I])},[k]),N=(0,Di.get)(p,"dark",null)===l&&(0,Di.get)(p,"mod",null)===c&&(0,Di.get)(p,"mq",null)===d;return(0,Pr.jsx)(J3,{canChange:y,canReset:p&&N,children:(0,Pr.jsxs)("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[(0,Pr.jsx)("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:(0,Pr.jsx)("span",{className:`text-[11px] ${p&&!N?"text-foreground":""}`,children:t(r)})}),(0,Pr.jsxs)("div",{className:"flex flex-row items-center",children:[(0,Pr.jsxs)("div",{className:"w-[150px]",children:[o==="arbitrary"?(0,Pr.jsx)(q3,{currentClass:(0,Di.get)(p,"cls",""),classPrefix:(0,Di.get)(toe,n,""),units:s||[],onChange:f,negative:i,cssProperty:n}):null,o==="icons"&&(0,Pr.jsx)(sU,{property:n,onChange:f}),o==="range"&&(0,Pr.jsx)(lU,{property:n,onChange:f}),o==="color"&&(0,Pr.jsx)(rU,{property:n,onChange:f}),o==="dropdown"&&(0,Pr.jsx)(Ww,{label:r,property:n,onChange:f})]}),(0,Pr.jsx)("div",{className:`w-[30px] cursor-pointer ${h?"visible":"invisible"}`,children:N?(0,Pr.jsx)("button",{type:"button",onClick:()=>b(),title:"Reset",className:"flex px-1.5 text-xs",children:(0,Pr.jsx)(oP.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):y&&p?(0,Pr.jsxs)(Fo,{delayDuration:100,children:[(0,Pr.jsx)(Ho,{asChild:!0,children:(0,Pr.jsx)("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-primary text-white group-hover:visible",children:(0,Pr.jsx)(oP.InfoCircledIcon,{})})}),(0,Pr.jsx)(Bo,{children:(0,Pr.jsx)("div",{className:"text-right",children:(0,Pr.jsxs)("div",{children:["Current style is set at \xA0",(0,Pr.jsxs)("span",{className:"font-bold",children:[ooe((0,Di.get)(p,"mq")),l&&!p.dark?"(Light mode)":""]}),(0,Pr.jsx)("br",{}),(0,Pr.jsxs)("button",{type:"button",onClick:()=>w((0,Di.get)(p,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",(0,Di.get)(p,"mq").toUpperCase()]})]})})})]}):null})]})]})})}});var SU,nu,_g,wU,_i,roe,rP,PU=x(()=>{"use strict";SU=require("@radix-ui/react-icons"),nu=require("lodash-es"),_g=K(require("react"),1),wU=require("react-i18next");Ig();tP();rs();RA();_i=require("react/jsx-runtime"),roe=["px","%","em","rem","ch","vh","vw"],rP=({label:e,options:t,borderB:o=!1,borderT:r=!1,type:n="arbitrary",units:a=roe,negative:s=!1})=>{let{t:i}=(0,wU.useTranslation)(),[l,c]=(0,_g.useState)(t[0].key),d=Dg(),p=(0,_g.useCallback)(u=>(0,nu.map)(d,"property").includes(u),[d]);return(0,_i.jsxs)("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${o?"border-b":""} ${r?"border-t":""}`,children:[(0,_i.jsxs)("div",{className:"flex flex-row text-xs",children:[e&&(0,_i.jsx)("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:i(e)}),(0,_i.jsx)("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:t.map(({label:u,key:m},g)=>(0,_i.jsx)("div",{className:"first:rounded-l last:rounded-r",children:(0,_i.jsxs)(Fo,{children:[(0,_i.jsx)(Ho,{asChild:!0,children:(0,_i.jsxs)("button",{type:"button",onClick:()=>c(m),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${m===l?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[_g.default.createElement("div",{className:p(m)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),_g.default.createElement((0,nu.get)(Kw,m,SU.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),(0,_i.jsx)(Bo,{children:(0,nu.startCase)((0,nu.toLower)(u))})]})},`option-${g}`))})]}),(0,_i.jsx)("div",{className:"mt-0 flex items-center",children:(0,_i.jsx)(Xh,{type:n,units:[...a],label:"",property:l,negative:s})})]})}});var ha,md,OA,xn,TU,noe,NU,EU=x(()=>{"use strict";ha=require("lodash-es"),md=K(require("react"),1),OA=require("react-i18next");Ig();PU();tP();Xf();xn=require("react/jsx-runtime"),TU=({heading:e,items:t})=>{let{t:o}=(0,OA.useTranslation)(),r=Dg(),n=(0,md.useMemo)(()=>{let a=l=>(0,ha.flatten)(l.map(c=>c.styleType==="multiple"?(0,ha.map)(c.options,"key"):c.property)),s=(0,ha.flatten)(t.map(l=>l.styleType==="accordion"?a(l.items):l.styleType==="multiple"?(0,ha.map)(l.options,"key"):l.property)),i=(0,ha.map)(r,"property");return(0,ha.intersection)(s,i).length>0},[r,t]);return(0,xn.jsxs)("details",{children:[(0,xn.jsx)("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:(0,xn.jsxs)("div",{className:"inline",children:[(0,ha.startCase)(o(e.toLowerCase())),n?(0,xn.jsx)("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${n?"bg-primary":"bg-gray-300"}`}):null]})}),(0,xn.jsx)("div",{className:"p-2",children:t.map(a=>a.styleType==="multiple"?(0,xn.jsx)(rP,{...a},a.label):(0,xn.jsx)(Xh,{...a},a.label))})]})},noe=(0,md.createContext)({}),NU=({section:e,showAccordian:t})=>{let{t:o}=(0,OA.useTranslation)(),r=Dg(),n=(0,md.useCallback)((s=[])=>{let i={};for(let c=0;c<r.length;c++)i[r[c].property]=r[c].cls;let l=!0;for(let c in s)if(!(0,ha.has)(i,c)||i[c]!==s[c]){l=!1;break}return l},[r]),a=(0,md.useMemo)(()=>({}),[]);return(0,xn.jsx)(noe.Provider,{value:a,children:t?(0,xn.jsxs)(Xd,{value:e.heading,className:"border-none",children:[(0,xn.jsx)(eg,{className:"border-slate-150 border-t py-2 text-xs",children:(0,xn.jsx)("div",{className:"flex items-center py-2",children:(0,xn.jsx)("div",{className:"flex items-center gap-x-2 text-xs font-medium",children:(0,ha.startCase)(o(e.heading))})})}),(0,xn.jsx)(Zd,{className:"py-2",children:e.items.map((s,i)=>(0,ha.has)(s,"component")?md.default.createElement(s.component,{key:s.label||`component-${i}`}):(0,ha.has)(s,"styleType")?s.styleType==="multiple"?(0,xn.jsx)(rP,{...s},s.label+"multiple-choices"+i):s.styleType==="accordion"&&n(s==null?void 0:s.conditions)?(0,xn.jsx)(TU,{...s},s.label+"nested-options"+i):null:(0,xn.jsx)(Xh,{...s},s.label+"block-style"+i))})]}):(0,xn.jsx)("div",{className:"py-0",children:e.items.map((s,i)=>(0,ha.has)(s,"component")?md.default.createElement(s.component,{key:s.label||`component-${i}`}):(0,ha.has)(s,"styleType")?s.styleType==="multiple"?(0,xn.jsx)(rP,{...s},s.label+"multiple-choices"+i):s.styleType==="accordion"&&n(s==null?void 0:s.conditions)?(0,xn.jsx)(TU,{...s},s.label+"nested-options"+i):null:(0,xn.jsx)(Xh,{...s},s.label+"block-style"+i))})})}});var AU,BU,IU,RU=x(()=>{"use strict";AU=require("@radix-ui/react-icons"),BU=require("react/jsx-runtime"),IU=({className:e=""})=>(0,BU.jsx)(AU.TokensIcon,{className:e})});function lc(e){var a;let{i18n:t}=(0,_U.useTranslation)(),o=q("labels",void 0),r=q("locale","en"),n=(a=o==null?void 0:o.features)==null?void 0:a[e];if(n){if(typeof n=="string")return n;if(typeof n=="object")return n[r]||n[t.language]||n.en||n[Object.keys(n)[0]]||DU[e]}return DU[e]}var _U,DU,Zh=x(()=>{"use strict";_U=require("react-i18next");Ke();DU={designTokens:"Design Tokens",trash:"Trash",dataBinding:"Data Binding",ai:"AI"}});function aoe({children:e,leftLabel:t,rightLabel:o,defaultOpen:r=!0,value:n="",itemClassName:a=""}){let{t:s}=(0,MU.useTranslation)(),[i,l]=(0,LU.useState)(r?n:void 0);return(0,au.jsx)(vm,{type:"single",value:i||"",onValueChange:c=>l(c||void 0),collapsible:!0,children:(0,au.jsxs)(Xd,{value:n,className:G("border-b-0 border-t",a),children:[(0,au.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,au.jsx)(eg,{className:"flex-1 py-2.5 text-xs font-medium hover:no-underline",children:(0,FA.isFunction)(t)?t(i):t||s("Panel name")}),o&&(0,au.jsx)("div",{className:"shrink-0 pr-1",children:(0,FA.isFunction)(o)?o(i):o})]}),(0,au.jsx)(Zd,{className:"pb-2",children:e})]})})}var FA,LU,MU,au,ey,nP=x(()=>{"use strict";FA=require("lodash-es"),LU=require("react"),MU=require("react-i18next");Xf();st();au=require("react/jsx-runtime");ey=aoe});var ud,tv,OU,FU=x(()=>{"use strict";ud=require("lodash-es");Qh();tv=["xs","sm","md","lg","xl","2xl"],OU=e=>{if(e=e.trim().replace(/ +(?= )/g,""),(0,ud.isEmpty)(e))return"";let t=(0,ud.map)(e.split(" "),ou),o=[];for(let r of t){let n=r.mq;if(!o.includes(r.fullCls))for(let a=tv.indexOf(n)+1;a<tv.length;a++){let s=(0,ud.find)(t,{property:r.property,mq:tv[a]});if(s&&s.cls!==r.cls)break;(0,ud.find)(t,{cls:r.cls,mq:tv[a]})&&o.push(`${tv[a]}:${r.cls}`)}}return(0,ud.filter)((0,ud.map)(t,r=>o.includes(r.fullCls)?null:r.fullCls),r=>r!==null).join(" ")}});var HU,HA,UA,UU=x(()=>{"use strict";HU=require("react-i18next");FU();HA=require("react/jsx-runtime"),UA=({activeToken:e})=>{let{t}=(0,HU.useTranslation)(),o=e!=null&&e.value?OU(e.value):"";return(0,HA.jsx)("div",{className:"max-h-2/5 flex h-2/5 w-full items-start justify-center overflow-auto rounded-md border-transparent bg-background/80 p-2",children:(0,HA.jsx)("div",{className:o||void 0,children:t("Sample text with token styles applied")})})}});var Ap,aP,GU=x(()=>{"use strict";st();Ap=require("react/jsx-runtime"),aP=({title:e,items:t,emptyLabel:o,onSelect:r,icon:n})=>(0,Ap.jsxs)("div",{className:"space-y-1",children:[(0,Ap.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:e}),t.length>0?(0,Ap.jsx)("div",{className:"space-y-1 overflow-y-auto",children:t.map(a=>(0,Ap.jsx)("button",{type:"button",onClick:()=>r(a.id),className:G("group flex w-full items-center justify-between rounded-md border px-3 py-1 text-left text-xs transition","text-foreground hover:border-muted-foreground/20 hover:bg-muted/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",a.isSelected&&"border-primary/40 bg-primary/10 text-primary"),children:(0,Ap.jsxs)("span",{className:"flex items-center space-x-2",children:[n&&n,(0,Ap.jsx)("span",{className:"truncate",children:a.label})]})},a.id))}):(0,Ap.jsx)("div",{className:"rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground",children:o})]})});var ov,$U,su,VU,Ya,soe,ioe,loe,coe,zU,WU=x(()=>{"use strict";ov=require("@radix-ui/react-icons"),$U=require("lodash-es"),su=require("react"),VU=require("react-i18next");GU();ko();Ke();Tt();Nn();Ge();xi();Ya=require("react/jsx-runtime"),soe="#styles:",ioe=e=>{let o=[typeof e._name=="string"?e._name:void 0,typeof e._type=="string"?e._type:void 0].filter(Boolean).find(r=>r.trim().length>0);return o?o.length>40?`${o.slice(0,37)}...`:o:e._id},loe=(e,t)=>{let o=`${t}`;return e.filter(r=>Object.values(r).some(n=>typeof n!="string"||!n.startsWith(soe)?!1:n.includes(o))).map(r=>({id:r._id,label:ioe(r)}))},coe=({tokenId:e,tokenName:t,children:o})=>{let{t:r}=(0,VU.useTranslation)(),[n]=Pt(),[a,s]=Pe(),i=q("pageId",""),l=q("siteWideUsage",{}),c=(0,su.useMemo)(()=>loe(n,e),[n,e]),d=(0,su.useMemo)(()=>c.map(w=>({id:w.id,label:w.label,isSelected:a.includes(w.id)})),[c,a]),p=(0,su.useMemo)(()=>l?Object.entries(l).reduce((w,[N,I])=>(N===i||!(I!=null&&I.designTokens)||!Object.keys(I.designTokens).some(P=>typeof P!="string"?!1:P===e)||w.push({id:N,name:I.name||N,isPartial:!!I.isPartial}),w),[]):[],[l,e,i]),u=(0,su.useMemo)(()=>p.filter(w=>!w.isPartial).map(w=>({id:w.id,label:w.name})),[p]),m=(0,su.useMemo)(()=>p.filter(w=>w.isPartial).map(w=>({id:w.id,label:w.name})),[p]),g=(0,su.useCallback)(w=>{s([w])},[s]),h=q("gotoPage",$U.noop),{selectedLang:f,fallbackLang:b}=fe(),{savePageAsync:y}=to(),k=async w=>{w&&(await y(!0),h({pageId:w,lang:f||b}))};return(0,Ya.jsxs)(Dr,{defaultValue:"this-page",children:[(0,Ya.jsxs)(Cr,{children:[(0,Ya.jsx)(ut,{value:"this-page",className:"px-2 text-[11px]",children:r("Affected on this page")}),(0,Ya.jsx)(ut,{value:"other-pages",className:"px-2 text-[11px]",children:r("Affected on other pages")}),(0,Ya.jsx)(ut,{value:"partial-pages",className:"px-2 text-[11px]",children:r("Affected on partial blocks")})]}),(0,Ya.jsx)(kr,{value:"this-page",children:(0,Ya.jsx)(aP,{title:r("Blocks affected on this page"),items:d,emptyLabel:r("None"),onSelect:g,icon:(0,Ya.jsx)(ov.ArrowRightIcon,{fontSize:4})})}),(0,Ya.jsx)(kr,{value:"other-pages",children:(0,Ya.jsx)(aP,{title:r("Blocks affected on other pages"),items:u,emptyLabel:r("None"),onSelect:k,icon:(0,Ya.jsx)(ov.FileIcon,{fontSize:8})})}),(0,Ya.jsx)(kr,{value:"partial-pages",children:(0,Ya.jsx)(aP,{title:r("Blocks affected on partial blocks"),items:m,emptyLabel:r("None"),onSelect:k,icon:(0,Ya.jsx)(ov.FileIcon,{fontSize:8})})})]})},zU=coe});var GA,ty,sP,$A=x(()=>{"use strict";GA=require("@react-hookz/web"),ty=require("react");Wr();Jn();Ke();Vc();sP=()=>{let e=q("onSaveWebsiteData",async l=>{}),[t]=Yu(),o=(0,ty.useRef)(!1),r=(0,ty.useCallback)(async l=>{if(!o.current){o.current=!0;try{await e(l)}finally{o.current=!1}}},[e]),n=(0,ty.useCallback)(async l=>{await r({type:"THEME",data:l!=null?l:t})},[r,t]),a=(0,ty.useCallback)(async l=>{let c=l!=null?l:be.get(ls);await r({type:"DESIGN_TOKENS",data:c})},[r]),s=(0,GA.useDebouncedCallback)(n,[n],1e3),i=(0,GA.useDebouncedCallback)(a,[a],1e3);return{saveWebsiteData:r,saveTheme:n,saveDesignTokens:a,debouncedSaveTheme:s,debouncedSaveDesignTokens:i}}});var zA,VA,jU,qU,KU=x(()=>{"use strict";zA=e=>{let t=e.trim();return t.length===0||t.length>VA?!1:/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(t)},VA=75,jU=(e,t,o,r=!1,n)=>{let a=e.trim();return a.length===0?"":a.length>VA?o("Token name must be {{max}} characters or less",{max:VA}):/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(a)?Object.entries(t).find(([l,c])=>c.name===a&&(!r||l!==n))?o("Token name already exists"):"":o("Only alphanumeric characters and hyphens allowed")},qU=e=>e.replace(/\s+/g,"-")});var YU,JU,At,QU,gd,XU,tG,ZU,eG,iu,iP=x(()=>{"use strict";YU=require("jotai"),JU=require("nanoid"),At=require("react"),QU=require("react-i18next"),gd=require("sonner"),XU=require("cnfast");Wr();AC();_A();LA();Ke();$A();Tn();jS();KU();tG=require("react/jsx-runtime"),ZU=(0,At.createContext)(null),eG=({children:e,onActiveTokenChange:t,onDirtyStateChange:o,setCreatePreview:r})=>{let{t:n}=(0,QU.useTranslation)(),[a,s]=(0,YU.useAtom)(ls),i=EC(),{saveDesignTokens:l,debouncedSaveDesignTokens:c}=sP(),d=q("pageId",""),p=q("siteWideUsage",{}),[u,m]=(0,At.useState)("builtin"),[g,h]=(0,At.useState)("view"),[f,b]=(0,At.useState)(null),[y,k]=(0,At.useState)(null),[w,N]=(0,At.useState)(""),[I,C]=(0,At.useState)(""),[P,B]=(0,At.useState)(""),[T,v]=(0,At.useState)(""),[S,A]=(0,At.useState)(!1),D=(0,At.useRef)(null),R=(0,At.useMemo)(()=>f?f in ki:!1,[f]),H=(0,At.useCallback)(Z=>!(Z in ki)||!(Z in a)?!1:a[Z].value!==ki[Z].value,[a]),M=(0,At.useMemo)(()=>Object.entries(ki).map(([ge,Rt])=>{let sr=a[ge];return[ge,sr||Rt]}),[a]),L=(0,At.useMemo)(()=>Object.entries(a).filter(([Z])=>!(Z in ki)),[a]),z=(0,At.useCallback)(Z=>{if(!p)return{pageCount:0,partialCount:0};let ge=0,Rt=0;return Object.entries(p).forEach(([sr,ir])=>{if(sr===d||!(ir!=null&&ir.designTokens))return;Object.keys(ir.designTokens).some(We=>We===Z)&&(ir.isPartial?Rt++:ge++)}),{pageCount:ge,partialCount:Rt}},[p,d]),_=(0,At.useMemo)(()=>{if(g==="edit"||g==="add")return w&&I?{name:w,value:I,id:f||void 0}:null;if(g==="view"&&y){let Z=a[y]||ki[y];if(Z)return{name:Z.name,value:Z.value,id:y}}return null},[g,w,I,f,y,a]);(0,At.useEffect)(()=>{t&&t(_)},[_,t]),(0,At.useEffect)(()=>{if(!o)return;let Z=g==="add"&&(w&&w.trim().length>0||I&&I.trim().length>0);o(Z)},[g,w,I,o]);let F=(0,At.useCallback)(()=>{b(null),N(""),C(""),B(""),A(!1),h("view"),r==null||r(null)},[r]),O=(0,At.useCallback)((Z,ge)=>{!f||g!=="edit"||!Z.trim()||!ge.trim()||!zA(Z)||Object.entries(a).find(([sr,ir])=>ir.name===Z.trim()&&sr!==f)||(A(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{let sr={...a,[f]:{name:Z.trim(),value:ge.trim()}};s(sr),i(),c(),A(!1),gd.toast.success(n("Token updated successfully")),F()},10))},[f,g,a,s,i,c,n,F]),U=(0,At.useCallback)(Z=>{let ge=a[Z]||ki[Z];ge&&(b(Z),N(ge.name),C(ge.value),B(""),h("edit"))},[a]),j=(0,At.useCallback)(()=>{b(null),N(""),C(""),B(""),h("add"),r==null||r({name:"",value:""})},[r]),ce=(0,At.useCallback)(()=>{F()},[F]),pe=(0,At.useCallback)(()=>{if(!w.trim()||!I.trim()){gd.toast.error(n("Please fill in both token name and classes"));return}if(!zA(w)){gd.toast.error(n("Invalid design token name format"));return}if(Object.entries(a).find(([ge,Rt])=>Rt.name===w.trim()&&ge!==f)){gd.toast.error(n("Token already exists"));return}if(g==="edit"&&f)O(w,I);else if(g==="add"){let ge=`${"dt#"}${(0,JU.nanoid)(12)}`,Rt={...a,[ge]:{name:w.trim(),value:I.trim()}};s(Rt),i(),l(),gd.toast.success(n("Token added successfully")),F()}},[w,I,a,f,g,n,O,s,i,l,F]),ve=(0,At.useCallback)(Z=>{if(!(Z in ki))return;let ge={...a};delete ge[Z],s(ge),i(),l(),gd.toast.success(n("Token reset to built-in")),F()},[a,s,i,l,n,F]),Ve=(0,At.useCallback)(Z=>{let ge={...a,[Z]:{...a[Z],archived:!0}};s(ge),i(),l(),gd.toast.success(n("Token archived successfully"))},[a,s,i,l,n]),ze=(0,At.useCallback)(Z=>{let ge={...a,[Z]:{name:a[Z].name,value:a[Z].value}};s(ge),i(),l(),gd.toast.success(n("Token unarchived successfully"))},[a,s,i,l,n]),bt=(0,At.useCallback)(Z=>{let ge={...a};delete ge[Z],s(ge),i(),l(),gd.toast.success(n("Token deleted successfully"))},[a,s,i,l,n]),W=(0,At.useCallback)(Z=>{k(Z)},[]),ie=(0,At.useCallback)(Z=>{let ge=qU(Z);N(ge);let Rt=jU(ge,a,n,g==="edit",f||void 0);B(Rt),g==="add"&&r&&r(sr=>({...sr,name:Z}))},[a,n,g,f,r]),Y=(0,At.useCallback)(Z=>{C(Z),g==="add"&&r&&r(ge=>({...ge,value:Z}))},[g,r]),Ze=(0,At.useCallback)(Z=>{let ge=Qw(Xw((0,XU.twMerge)(I,Z)));Y(ge)},[I,Y]),te=(0,At.useCallback)(Z=>{let ge=I.split(" ").filter(Rt=>Rt!==Z).join(" ");Y(ge)},[I,Y]),Qe={designTokens:a,activeTab:u,viewMode:g,editingTokenId:f,selectedTokenId:y,activeToken:_,searchQuery:T,tokenName:w,classes:I,tokenNameError:P,isSaving:S,isEditingBuiltIn:R,builtInTokens:M,customTokens:L,setActiveTab:m,setSearchQuery:v,startEdit:U,startAdd:j,cancelEdit:ce,saveToken:pe,resetToBuiltIn:ve,archiveToken:Ve,unarchiveToken:ze,deleteToken:bt,selectToken:W,handleTokenNameChange:ie,handleClassesChange:Y,handleAddClass:Ze,handleRemoveClass:te,isTokenEdited:H,getTokenUsageCount:z};return(0,tG.jsx)(ZU.Provider,{value:Qe,children:e})},iu=()=>{let e=(0,At.useContext)(ZU);if(!e)throw new Error("useDesignTokensContext must be used within DesignTokensProvider");return e}});var oG,rG,vn,WA,nG=x(()=>{"use strict";oG=require("@radix-ui/react-icons"),rG=require("react-i18next");jA();Zh();J();fo();No();iP();vn=require("react/jsx-runtime"),WA=()=>{let{t:e}=(0,rG.useTranslation)(),t=lc("designTokens"),{viewMode:o,isEditingBuiltIn:r,tokenName:n,classes:a,tokenNameError:s,isSaving:i,editingTokenId:l,handleTokenNameChange:c,handleAddClass:d,handleRemoveClass:p,cancelEdit:u,saveToken:m,resetToBuiltIn:g}=iu(),h=o==="edit",f=t.toLowerCase().endsWith("s")?t.slice(0,-1):t,b=h?`${e("Edit")} ${f}`:`${e("Add")} ${f}`,y=h?`${e("Update")} ${f.toLowerCase()}`:`${e("Create a reusable")} ${f.toLowerCase()}`;return(0,vn.jsxs)("div",{className:"flex h-full flex-col",children:[(0,vn.jsxs)("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-border/50 bg-accent p-1.5",children:[(0,vn.jsx)(E,{variant:"ghost",size:"icon-xs",className:"hover:bg-secondary",onClick:u,children:(0,vn.jsx)(oG.ArrowLeftIcon,{className:"h-3 w-3"})}),(0,vn.jsxs)("div",{className:"flex-1",children:[(0,vn.jsx)("h3",{className:"text-xs font-semibold text-foreground",children:b}),(0,vn.jsx)("p",{className:"text-[10px] font-light text-muted-foreground",children:y})]}),h&&i&&(0,vn.jsx)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:(0,vn.jsx)("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"})})]}),(0,vn.jsxs)("div",{className:"flex-1 space-y-3 overflow-y-auto",children:[(0,vn.jsxs)("div",{className:"space-y-1.5",children:[(0,vn.jsx)(Q,{htmlFor:"token-name",children:e("Token Name")}),(0,vn.jsx)(Ce,{id:"token-name",placeholder:"Button-Primary",value:n,onChange:k=>c(k.target.value),className:"h-7 text-xs",disabled:r,readOnly:r}),s?(0,vn.jsx)("span",{className:"text-[10px] text-destructive",children:s}):(0,vn.jsx)("span",{className:"text-[10px] font-light text-muted-foreground",children:r?`${e("Built-in")} ${f.toLowerCase()} ${e("names cannot be changed")}`:e("Button-Primary, Card-Header, Text-Large etc.")})]}),(0,vn.jsx)(rv,{from:"designToken",classFromProps:a,onAddNew:d,onRemove:p,showDesignTokenSuggestions:!1}),(0,vn.jsxs)("div",{className:"mt-3 flex items-center justify-end gap-2 pt-3",children:[(0,vn.jsx)(E,{variant:"ghost",onClick:u,size:"sm",children:e("Cancel")}),h&&r&&(0,vn.jsx)(E,{variant:"outline",onClick:()=>l&&g(l),size:"sm",className:"border-primary/50 text-primary hover:bg-primary/10",children:e("Reset to Built-in")}),(0,vn.jsx)(E,{onClick:m,disabled:!n.trim()||!a.trim()||!!s,size:"sm",children:e(h?"Save":"Add")})]})]})]})}});var Mg,Lg,cP,lP,Le,qA,KA,aG,sG,iG=x(()=>{"use strict";Mg=require("@radix-ui/react-icons"),Lg=require("react"),cP=require("react-i18next"),lP=require("cnfast");hl();Zh();mn();Ih();Oh();J();tn();iP();Le=require("react/jsx-runtime"),qA=({tokenId:e,token:t,isBuiltIn:o,isEdited:r,isSelected:n,isArchived:a=!1})=>{let{t:s}=(0,cP.useTranslation)(),{selectToken:i,startEdit:l,unarchiveToken:c,deleteToken:d}=iu(),{hasPermission:p}=kt(),u=p(xe["design_tokens:edit"]),m=p(xe["design_tokens:delete"]);return(0,Le.jsxs)("div",{onClick:()=>i(e),className:(0,lP.twMerge)("group relative flex w-full cursor-pointer items-center justify-between rounded border p-1.5 transition-all",a?"border-muted bg-muted/30 opacity-60":n?"bg-accent/70":"hover:bg-muted/5"),children:[(0,Le.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Le.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Le.jsx)("div",{className:(0,lP.twMerge)("truncate text-xs font-medium text-foreground/80",a&&"text-muted-foreground"),children:t.name}),r&&o&&!a&&(0,Le.jsx)(bl,{variant:"active",className:"h-4 px-1 py-0 text-[9px] font-normal",children:s("Edited")})]}),(0,Le.jsx)("div",{className:(0,lP.twMerge)("line-clamp-1 w-[90%] text-[10px] font-light text-foreground/30",a&&"opacity-70"),children:t.value})]}),(0,Le.jsx)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100",children:a?(0,Le.jsxs)(Le.Fragment,{children:[u&&(0,Le.jsx)(E,{variant:"ghost",size:"sm",onClick:g=>{g.stopPropagation(),c(e)},children:(0,Le.jsx)("span",{className:"text-[10px]",children:"Restore"})}),m&&(0,Le.jsx)(E,{variant:"ghost",size:"sm",onClick:g=>{g.stopPropagation(),d(e)},className:"text-destructive hover:text-destructive",children:(0,Le.jsx)("span",{className:"text-[10px]",children:"Delete"})})]}):u&&(0,Le.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:g=>{g.stopPropagation(),l(e)},children:(0,Le.jsx)(Mg.Pencil1Icon,{className:"!h-3 !w-3"})})})]})},KA=({icon:e,message:t,actionLabel:o,onAction:r})=>(0,Le.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 py-6 text-center",children:[e||(0,Le.jsx)(Mg.MagnifyingGlassIcon,{className:"h-8 w-8 text-muted-foreground"}),(0,Le.jsx)("p",{className:"text-xs text-muted-foreground",children:t}),o&&r&&(0,Le.jsxs)(E,{variant:"default",onClick:r,size:"sm",className:"mt-4 h-7 text-xs leading-tight",children:[(0,Le.jsx)(Mg.PlusIcon,{className:"mr-1 h-3 w-3"}),o]})]}),aG=()=>{let{t:e}=(0,cP.useTranslation)(),t=lc("designTokens"),{builtInTokens:o,searchQuery:r,setSearchQuery:n,selectedTokenId:a,isTokenEdited:s}=iu(),i=(0,Lg.useMemo)(()=>o.filter(([,l])=>l.name.toLowerCase().includes(r.toLowerCase())||l.value.toLowerCase().includes(r.toLowerCase())),[o,r]);return(0,Le.jsxs)("div",{className:"flex h-full flex-col gap-2",children:[(0,Le.jsx)("div",{className:"flex-shrink-0",children:(0,Le.jsx)(Yr,{value:r,setValue:n,placeholder:e("Search built-in {{label}}",{label:t})})}),(0,Le.jsx)("div",{className:"max-h-[550px] min-h-0 flex-1 overflow-y-auto",children:(0,Le.jsxs)("div",{className:"space-y-1 pr-4",children:[i.length===0?(0,Le.jsx)(KA,{message:e("No tokens match your search")}):(0,Le.jsx)(Le.Fragment,{children:i.map(([l,c])=>(0,Le.jsx)(qA,{token:c,tokenId:l,isSelected:a===l,isBuiltIn:!0,isEdited:s(l),isArchived:!1},l))}),(0,Le.jsx)("div",{className:"h-4"})]})})]})},sG=()=>{let{t:e}=(0,cP.useTranslation)(),t=lc("designTokens"),{customTokens:o,searchQuery:r,setSearchQuery:n,selectedTokenId:a,startAdd:s,archiveToken:i,getTokenUsageCount:l}=iu(),{hasPermission:c}=kt(),d=c(xe["design_tokens:create"]),p=c(xe["design_tokens:edit"]),[u,m]=(0,Lg.useState)({isOpen:!1,tokenId:null,tokenName:"",pageCount:0,partialCount:0}),g=(0,Lg.useMemo)(()=>o.filter(([,k])=>k.name.toLowerCase().includes(r.toLowerCase())||k.value.toLowerCase().includes(r.toLowerCase())),[o,r]),h=(0,Lg.useMemo)(()=>g.filter(([,k])=>!k.archived),[g]),f=(0,Lg.useMemo)(()=>g.filter(([,k])=>k.archived),[g]),b=(k,w)=>{let{pageCount:N,partialCount:I}=l(k);m({isOpen:!0,tokenId:k,tokenName:w,pageCount:N,partialCount:I})},y=()=>{u.tokenId&&i(u.tokenId),m({isOpen:!1,tokenId:null,tokenName:"",pageCount:0,partialCount:0})};return(0,Le.jsxs)("div",{className:"flex h-full flex-col gap-2",children:[o.length>0&&(0,Le.jsx)("div",{className:"flex-shrink-0",children:(0,Le.jsxs)("div",{className:"flex items-center justify-between gap-x-2",children:[(0,Le.jsx)(Yr,{value:r,setValue:n,placeholder:e("Search tokens")}),d&&(0,Le.jsxs)(E,{variant:"outline",onClick:s,size:"sm",className:"h-8",children:[(0,Le.jsx)(Mg.PlusIcon,{}),e("Add")]})]})}),(0,Le.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,Le.jsxs)("div",{className:"space-y-1 pr-4",children:[o.length===0?(0,Le.jsx)(KA,{message:`${e("No custom")} ${t.toLowerCase()} ${e("yet")}`,actionLabel:d?e("Add custom {{items}}",{items:t.toLowerCase()}):void 0,onAction:d?s:void 0}):g.length===0?(0,Le.jsx)(KA,{message:e("No tokens match your search")}):(0,Le.jsxs)(Le.Fragment,{children:[h.length>0&&(0,Le.jsx)("div",{className:"space-y-1",children:h.map(([k,w])=>(0,Le.jsxs)("div",{className:"group relative",children:[(0,Le.jsx)(qA,{token:w,tokenId:k,isSelected:a===k,isBuiltIn:!1,isEdited:!1,isArchived:!1}),p&&(0,Le.jsx)(E,{variant:"ghost",size:"icon-xs",className:"absolute right-8 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100",onClick:N=>{N.stopPropagation(),b(k,w.name)},children:(0,Le.jsx)("span",{className:"text-[10px]",children:"Archive"})})]},k))}),f.length>0&&(0,Le.jsxs)("div",{className:"mt-4 space-y-1",children:[(0,Le.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold text-muted-foreground",children:e("Archived")}),f.map(([k,w])=>(0,Le.jsx)(qA,{token:w,tokenId:k,isSelected:a===k,isBuiltIn:!1,isEdited:!1,isArchived:!0},k))]})]}),(0,Le.jsx)("div",{className:"h-4"})]})}),(0,Le.jsx)(cd,{open:u.isOpen,onOpenChange:k=>{k||m({isOpen:!1,tokenId:null,tokenName:"",pageCount:0,partialCount:0})},children:(0,Le.jsxs)(nc,{children:[(0,Le.jsx)(ac,{children:e("Archive Design Token")}),(0,Le.jsxs)(gp,{className:"space-y-3",children:[(0,Le.jsxs)("p",{children:[e("This token is used on")," ",(0,Le.jsx)("span",{className:"font-semibold",children:u.pageCount})," ",e("pages"),u.partialCount>0&&(0,Le.jsxs)(Le.Fragment,{children:[" ",e("and")," ",(0,Le.jsx)("span",{className:"font-semibold",children:u.partialCount})," ",e("partials")]}),"."]}),(0,Le.jsx)("p",{className:"text-sm text-destructive",children:e("Archiving this token will remove the styling for those blocks.")}),(0,Le.jsx)("p",{children:e("Do you wish to continue?")})]}),(0,Le.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,Le.jsx)(hp,{children:e("Cancel")}),(0,Le.jsx)(fp,{onClick:y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:e("Archive")})]})]})})]})}});var cG={};et(cG,{default:()=>YA});var lG,Cs,doe,poe,YA,JA=x(()=>{"use strict";lG=require("react-i18next");Zh();xi();iP();nG();iG();Cs=require("react/jsx-runtime"),doe=()=>{let{t:e}=(0,lG.useTranslation)(),t=lc("designTokens"),{activeTab:o,setActiveTab:r,viewMode:n}=iu();return(0,Cs.jsx)("div",{className:"flex h-full w-full flex-col",children:(0,Cs.jsxs)(Dr,{value:o,onValueChange:a=>r(a),children:[(0,Cs.jsxs)(Cr,{className:"mb-3 w-full",children:[(0,Cs.jsxs)(ut,{value:"builtin",className:"flex-1",children:[e("Built-in")," ",t]}),(0,Cs.jsxs)(ut,{value:"custom",className:"flex-1",children:[e("Custom")," ",t]})]}),(0,Cs.jsx)(kr,{value:"builtin",className:"mt-0 flex-1",children:n==="view"?(0,Cs.jsx)(aG,{}):(0,Cs.jsx)(WA,{})}),(0,Cs.jsx)(kr,{value:"custom",className:"mt-0 flex-1",children:n==="view"?(0,Cs.jsx)(sG,{}):(0,Cs.jsx)(WA,{})})]})})},poe=({onActiveTokenChange:e,onDirtyStateChange:t,setCreatePreview:o})=>(0,Cs.jsx)(eG,{onActiveTokenChange:e,onDirtyStateChange:t,setCreatePreview:o,children:(0,Cs.jsx)(doe,{})}),YA=poe});var mG={};et(mG,{default:()=>uoe});var dG,fd,pG,io,moe,uoe,uG=x(()=>{"use strict";dG=require("@radix-ui/react-icons"),fd=require("react"),pG=require("react-i18next");Zh();Ih();J();qt();UU();WU();JA();io=require("react/jsx-runtime"),moe=({open:e,onOpenChange:t})=>{let{t:o}=(0,pG.useTranslation)(),r=lc("designTokens"),[n,a]=(0,fd.useState)(null),[s,i]=(0,fd.useState)(!1),[l,c]=(0,fd.useState)(!1),[d,p]=(0,fd.useState)(null),u=(0,fd.useCallback)(g=>{if(!g&&s){c(!0);return}t(g)},[s,t]),m=(0,fd.useCallback)(()=>{c(!1),i(!1),t(!1)},[t]);return(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)(Te,{open:e,onOpenChange:u,children:(0,io.jsxs)(we,{className:"min-w-[900px] gap-0 space-y-0 p-0",children:[(0,io.jsx)(Oe,{className:"border-b p-3",children:(0,io.jsxs)(Ie,{children:[(0,io.jsx)("h2",{className:"text-sm font-semibold",children:r}),(0,io.jsxs)("p",{className:"text-xs font-light text-muted-foreground",children:[o("Create and manage reusable")," ",r.toLowerCase()]})]})}),(0,io.jsxs)("div",{className:"flex max-h-[70vh] min-h-[450px] flex-1 overflow-hidden",children:[(0,io.jsx)("div",{className:"flex w-1/2 flex-col border-r p-3",children:(0,io.jsx)(YA,{onActiveTokenChange:a,onDirtyStateChange:i,setCreatePreview:p})}),(0,io.jsx)("div",{className:"flex w-1/2 flex-col gap-2 p-3",children:n!=null&&n.id?(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)("div",{className:"text-xs text-foreground/80",children:o("Preview")}),(0,io.jsx)(UA,{activeToken:n}),(0,io.jsx)(fd.Suspense,{fallback:null,children:(0,io.jsx)(zU,{tokenId:n==null?void 0:n.id,tokenName:n==null?void 0:n.name,children:(0,io.jsx)(E,{variant:"ghost",size:"icon-xs",children:(0,io.jsx)(dG.EyeOpenIcon,{className:"!h-3 !w-3"})})})})]}):d?(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)("div",{className:"text-xs text-foreground/80",children:o("Preview")}),(0,io.jsx)(UA,{activeToken:d})]}):(0,io.jsx)("div",{className:"flex h-full w-full items-center justify-center text-xs text-muted",children:o("Select a token to preview")})})]})]})}),(0,io.jsx)(cd,{open:l,onOpenChange:c,children:(0,io.jsxs)(nc,{children:[(0,io.jsxs)(up,{children:[(0,io.jsx)(ac,{children:o("Unsaved Changes")}),(0,io.jsx)(gp,{children:o("You have unsaved changes. Are you sure you want to close? Your changes will be lost.")})]}),(0,io.jsxs)(bg,{children:[(0,io.jsx)(hp,{children:o("Continue Editing")}),(0,io.jsx)(fp,{onClick:m,children:o("Discard Changes")})]})]})})]})},uoe=moe});function rv({from:e="default",classFromProps:t,onAddNew:o,onRemove:r,showDesignTokenSuggestions:n=!0}){var Ze;let a=(0,Vn.useRef)(null),[s,i]=(0,Vn.useState)(""),[l,c]=(0,Vn.useState)(!1),[d,p]=(0,Vn.useState)(-1),u=(0,Vn.useRef)(!1),[m,g]=(0,Vn.useState)(!1),{hasPermission:h}=kt(),f=h(xe["design_tokens:read"]),b=eU(),{t:y}=(0,gG.useTranslation)(),k=lc("designTokens"),[w]=ao(),N=_e(),I=eP(),C=qh(),[P]=Pe(),[B,T]=(0,Vn.useState)(""),v=YS(),S=(Ze=(0,ei.first)(w))==null?void 0:Ze.prop,{classes:A}=ys((0,ei.get)(N,S,"")),R=(e==="default"?A:t!=null?t:"").split(" ").filter(te=>!(0,ei.isEmpty)(te)),H=(0,Vn.useMemo)(()=>[...R].sort((te,Qe)=>{let Z=te.startsWith("dt#"),ge=Qe.startsWith("dt#");return Z&&!ge?-1:!Z&&ge?1:0}),[R]),M=q("flags.copyPaste",!0),L=te=>{let Qe=te.startsWith("dt#"),Z=(0,pt.jsx)("div",{className:"group relative flex max-w-[260px] items-center",children:(0,pt.jsxs)("button",{onDoubleClick:()=>{T(z(te)),e==="default"?C(P,[te],!0):((0,ei.isFunction)(r)&&r(te),T(te)),setTimeout(()=>{a.current&&a.current.focus()},10)},className:`group flex h-max cursor-default items-center gap-x-1 truncate break-words rounded py-px pl-0.5 pr-1 text-xs text-foreground/80 ${Qe?"bg-primary/20":"bg-muted/30 dark:bg-muted/10"}`,children:[(0,pt.jsx)(dP.X,{onClick:()=>{e==="default"?C(P,[te],!0):(0,ei.isFunction)(r)&&r(te)},className:"hidden h-3.5 w-3.5 cursor-pointer text-foreground/50 duration-300 hover:text-foreground group-hover:block"}),Qe?(0,pt.jsx)(dP.Component,{onClick:()=>{e==="default"?C(P,[te],!0):(0,ei.isFunction)(r)&&r(te)},className:"block h-3.5 w-3.5 rotate-45 cursor-pointer text-foreground duration-300 hover:text-foreground group-hover:hidden"}):(0,pt.jsxs)("svg",{className:"block h-3.5 w-3.5 cursor-pointer fill-foreground/60 duration-300 hover:fill-foreground group-hover:hidden",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,pt.jsx)("g",{strokeWidth:"0"}),(0,pt.jsx)("g",{strokeLinecap:"round",strokeLinejoin:"round"}),(0,pt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6.036q-4 0-5 3.976 1.5-1.987 3.5-1.491c.761.189 1.305.738 1.906 1.345C13.387 10.855 14.522 12 17 12q4 0 5-3.976-1.5 1.987-3.5 1.491c-.761-.189-1.305-.738-1.907-1.345-.98-.99-2.114-2.134-4.593-2.134M7 12q-4 0-5 3.976 1.5-1.988 3.5-1.491c.761.189 1.305.738 1.907 1.345.98.989 2.115 2.134 4.594 2.134q4 0 5-3.976-1.5 1.987-3.5 1.491c-.761-.189-1.305-.738-1.906-1.345C10.613 13.145 9.478 12 7 12"})]}),(0,pt.jsx)("div",{className:"font-light",children:z(te)})]})},te);return Qe&&v[te]?(0,pt.jsx)(Ye,{content:v[te].value,children:Z}):Z},z=te=>{if(te.startsWith("dt#")){let Qe=v[te];return Qe?Qe.name:te}return te},_=(0,Vn.useCallback)(te=>{let Qe=Object.entries(v).find(([,Z])=>Z.name===te);return Qe?`${Qe[0]}`:te},[v]),F=(0,Vn.useCallback)(()=>{let te=B.trim().replace(/ +(?= )/g,"").split(" ").map(_);e==="designToken"?(0,ei.isFunction)(o)&&o(te):I(P,te,!0),T("")},[B,e,o,I,P,_]),[O,U]=(0,Vn.useState)([]),j=q("flags.designTokens",!0),ce=({value:te})=>{let Qe=te.trim().toLowerCase(),Z=Qe.match(/.+:/g),ge=[],Rt=[];if(j&&n&&(Qe===""?Rt=Object.entries(v).map(([ir,ue])=>({name:ue.name,id:`${ir}`,isDesignToken:!0})):Rt=Object.entries(v).filter(([,ir])=>ir.name.toLowerCase().includes(Qe)).map(([ir,ue])=>({name:ue.name,id:`${ir}`,isDesignToken:!0}))),Z&&Z.length>0){let[ir]=Z,ue=Qe.replace(ir,"");ge=b.search(ue).map(Zo=>({...Zo,item:{...Zo.item,name:ir+Zo.item.name}}))}else ge=b.search(Qe);let sr=[...Rt,...(0,ei.map)(ge,"item")];return U(sr)},pe=()=>{U([])},ve=te=>te.name,Ve=te=>(0,pt.jsxs)("div",{className:"flex items-center gap-2 rounded-md p-1",children:[te.isDesignToken&&(0,pt.jsx)(IU,{className:"h-4 w-4 text-gray-600"}),(0,pt.jsx)("span",{children:te.name})]}),ze=(0,Vn.useMemo)(()=>({ref:a,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:y(n?"Enter classes separated by space or design tokens":"Enter classes separated by space"),value:B,onFocus:te=>{setTimeout(()=>{te.target&&te.target.select()},0)},onKeyDown:te=>{if(te.key==="Enter"&&B.trim()!==""){if(u.current){u.current=!1;return}te.preventDefault(),F()}if(te.key==="Tab"&&O.length>0){te.preventDefault();let Qe=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,bubbles:!0});te.target.dispatchEvent(Qe)}},onChange:(te,{newValue:Qe})=>T(Qe),className:`flex h-7 w-full rounded-md border border-input bg-transparent px-2 py-0 text-xs text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 ${e==="default"?"":"py-1.5"}`}),[n,y,B,e,O.length,F,k]),bt=te=>{let Qe=s.trim().replace(/ +(?= )/g,"").split(" ").map(_);C(P,[te],!0),I(P,Qe,!0),i(""),p(-1)},W=()=>{if(navigator.clipboard===void 0){XA.toast.error(y("Clipboard not supported"));return}navigator.clipboard.writeText(R.join(" ")),XA.toast.success(y("Classes copied to clipboard"),{duration:2e3}),c(!0),setTimeout(()=>c(!1),2e3)},ie=()=>(0,pt.jsx)(Ye,{content:y("Copy classes to clipboard"),children:l?(0,pt.jsx)(Og.CheckIcon,{className:"h-3 w-3 rounded border border-success bg-success/10 text-success"}):(0,pt.jsx)(Og.CopyIcon,{onClick:te=>{te.stopPropagation(),W()},className:"h-3 w-3 cursor-pointer"})}),Y=()=>(0,pt.jsx)("div",{className:"flex max-h-[50vh] w-full flex-wrap gap-1 overflow-y-auto overflow-x-hidden",children:H.map((te,Qe)=>d===Qe?(0,pt.jsx)("input",{ref:a,value:s,onChange:Z=>i(Z.target.value),onBlur:()=>{bt(te)},onKeyDown:Z=>{Z.key==="Enter"&&bt(te)},onFocus:Z=>{setTimeout(()=>{Z.target.select()},0)},className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"},te):L(te))});return e==="default"?(0,pt.jsxs)(pt.Fragment,{children:[(0,pt.jsx)(ey,{value:"manual-classes",defaultOpen:!0,itemClassName:"border-0",leftLabel:te=>(0,pt.jsxs)("div",{className:"flex items-center gap-x-1",children:[y("Classes")," ",M&&te&&ie()]}),rightLabel:()=>f?(0,pt.jsx)(E,{variant:"link",size:"xs",onClick:te=>{te.stopPropagation(),g(!0)},children:k}):null,children:(0,pt.jsxs)("div",{className:"flex w-full flex-col gap-y-1.5 pb-3",children:[(0,pt.jsxs)("div",{className:"relative flex items-center gap-x-1",children:[(0,pt.jsx)("div",{className:"relative flex w-full items-center gap-x-1",children:(0,pt.jsx)(QA.default,{suggestions:O,onSuggestionsFetchRequested:ce,onSuggestionsClearRequested:pe,getSuggestionValue:ve,renderSuggestion:Ve,inputProps:ze,onSuggestionSelected:(te,{suggestionValue:Qe})=>{u.current=!0;let ge=[_(Qe)];I(P,ge,!0),T("")},containerProps:{className:"relative h-7 w-full border-border text-xs"},theme:{suggestion:"bg-transparent text-foreground",suggestionHighlighted:"!bg-accent cursor-pointer",suggestionsContainerOpen:"absolute bg-surface no-scrollbar z-50 max-h-[220px] overflow-y-auto w-full border border-foreground/10 rounded-md"}})}),(0,pt.jsx)(E,{variant:"outline",onClick:F,disabled:B.trim()==="",size:"icon-sm",className:"h-7 w-7",children:(0,pt.jsx)(Og.PlusIcon,{})})]}),Y()]})}),(0,pt.jsx)(Vn.Suspense,{fallback:null,children:(0,pt.jsx)(goe,{open:m,onOpenChange:g})})]}):(0,pt.jsxs)("div",{className:`flex w-full flex-col gap-y-1.5 pb-3 ${e==="designToken"?"border-none":""}`,children:[(0,pt.jsx)("div",{className:"flex items-center justify-between gap-x-2",children:(0,pt.jsx)("div",{className:"flex w-full items-center justify-between gap-x-2 text-muted-foreground",children:(0,pt.jsxs)("span",{className:"flex items-center gap-x-1",children:[(0,pt.jsx)("span",{children:e==="designToken"?(0,pt.jsx)(Q,{children:y("Token Classes")}):(0,pt.jsx)("div",{className:"text-xs font-medium text-foreground",children:y("Classes")})}),M&&ie()]})})}),(0,pt.jsxs)("div",{className:"relative flex items-center gap-x-1",children:[(0,pt.jsx)("div",{className:"relative flex w-full items-center gap-x-1",children:(0,pt.jsx)(QA.default,{suggestions:O,onSuggestionsFetchRequested:ce,onSuggestionsClearRequested:pe,getSuggestionValue:ve,renderSuggestion:Ve,inputProps:ze,onSuggestionSelected:(te,{suggestionValue:Qe})=>{u.current=!0;let ge=[_(Qe)];e==="designToken"?(0,ei.isFunction)(o)&&o(ge):I(P,ge,!0),T("")},containerProps:{className:"relative h-7 w-full border-border text-xs"},theme:{suggestion:"bg-transparent text-foreground",suggestionHighlighted:"!bg-accent cursor-pointer",suggestionsContainerOpen:"absolute bg-surface no-scrollbar z-50 max-h-[220px] overflow-y-auto w-full border border-foreground/10 rounded-md"}})}),(0,pt.jsx)(E,{variant:"outline",onClick:F,disabled:B.trim()==="",size:"icon-sm",className:"h-7 w-7",children:(0,pt.jsx)(Og.PlusIcon,{})})]}),Y()]})}var Og,ei,dP,Vn,QA,gG,XA,pt,goe,jA=x(()=>{"use strict";Og=require("@radix-ui/react-icons"),ei=require("lodash-es"),dP=require("lucide-react"),Vn=require("react"),QA=K(require("react-autosuggest"),1),gG=require("react-i18next"),XA=require("sonner");RU();UE();dp();MA();Ke();Zh();mn();Jx();Ge();fn();ea();J();No();Ag();tn();Tn();nP();pt=require("react/jsx-runtime"),goe=(0,Vn.lazy)(()=>Promise.resolve().then(()=>(uG(),mG)))});var cc,fG,Y1e,hG=x(()=>{"use strict";jA();cc=["px","%","em","rem","ch","vh","vw"],fG=[{heading:"Styles",items:[{component:rv}]}],Y1e=[{heading:"layout.heading",items:[{type:"arbitrary",label:"layout.width",units:cc.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:cc.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...cc,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"multiple",label:"layout.space_bt",options:[{key:"spaceX",label:"layout.space_lr"},{key:"spaceY",label:"layout.space_tb"}]}]},{heading:"size.heading",items:[{styleType:"accordion",heading:"size.min_width_height",items:[{type:"arbitrary",label:"size.min_width",units:cc.concat("auto"),property:"minWidth"},{type:"arbitrary",label:"size.min_height",units:cc.concat("auto"),property:"minHeight"}]},{styleType:"accordion",heading:"size.max_width_height",items:[{type:"arbitrary",label:"size.max_width",units:cc.concat("auto"),property:"maxWidth"},{type:"arbitrary",label:"size.max_height",units:cc.concat("auto"),property:"maxHeight"}]},{styleType:"accordion",heading:"size.object_options_aspect_ratio",items:[{type:"dropdown",label:"size.aspect",property:"aspectRatio"},{type:"dropdown",label:"size.fit",property:"objectFit"},{type:"dropdown",label:"size.position",property:"objectPosition"}]}]},{heading:"display.heading",items:[{type:"dropdown",label:"display.display",property:"display",units:cc},{styleType:"accordion",heading:"display.flex_options",items:[{type:"dropdown",label:"display.flex_direction",property:"flexDirection"},{type:"dropdown",label:"display.flex_wrap",property:"flexWrap"},{type:"dropdown",label:"display.justify_content",property:"justifyContent"},{type:"dropdown",label:"display.align_content",property:"alignContent"},{type:"dropdown",label:"display.align_items",property:"alignItems"},{styleType:"multiple",label:"display.gap",options:[{key:"gap",label:"display.gap_all"},{key:"gapX",label:"display.gap_lr"},{key:"gapY",label:"display.gap_tb"}]}],conditions:{display:"flex"}},{styleType:"accordion",heading:"display.grid_options",items:[{type:"range",label:"display.grid_columns",property:"gridColumns"},{type:"range",label:"display.grid_rows",property:"gridRows"},{type:"dropdown",label:"display.grid_auto_flow",property:"gridAutoFlow"},{type:"dropdown",label:"display.grid_auto_cols",property:"gridAutoColumns"},{type:"dropdown",label:"display.grid_auto_rows",property:"gridAutoRows"},{type:"dropdown",label:"display.justify_content",property:"justifyContent"},{type:"dropdown",label:"display.align_content",property:"alignContent"},{type:"dropdown",label:"display.align_items",property:"alignItems"},{styleType:"multiple",label:"display.gap",units:["px","rem"],options:[{key:"gap",label:"display.gap_all"},{key:"gapX",label:"display.gap_lr"},{key:"gapY",label:"display.gap_tb"}]}],conditions:{display:"grid"}},{styleType:"accordion",heading:"display.visibility_opacity",items:[{type:"dropdown",label:"display.visibility",property:"visibility",units:cc},{type:"arbitrary",label:"display.opacity",property:"opacity",units:["-"]}]}]},{heading:"position.heading",items:[{type:"icons",label:"position.position",property:"position"},{styleType:"accordion",heading:"position.options",items:[{styleType:"multiple",label:"position.direction",options:[{key:"top",label:"position.top"},{key:"right",label:"position.right"},{key:"bottom",label:"position.bottom"},{key:"left",label:"position.left"}]},{styleType:"multiple",label:"position.inset",options:[{key:"inset",label:"position.all"},{key:"insetX",label:"position.lr"},{key:"insetY",label:"position.tb"}]},{type:"arbitrary",label:"position.z_index",units:["-","auto"],property:"zIndex"}]},{styleType:"accordion",heading:"position.float_clear",items:[{type:"icons",label:"position.float",property:"float"},{type:"dropdown",label:"position.clear",property:"clear"}]},{styleType:"accordion",heading:"position.overflow_overscroll",items:[{styleType:"multiple",type:"dropdown",label:"position.overflow",options:[{key:"overflow",label:"position.all"},{key:"overflowX",label:"position.lr"},{key:"overflowY",label:"position.tb"}]},{styleType:"multiple",type:"dropdown",label:"position.overscroll",options:[{key:"overscroll",label:"position.all"},{key:"overscrollX",label:"position.lr"},{key:"overscrollY",label:"position.tb"}]}]}]},{heading:"typography.heading",items:[{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:cc},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:cc.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"},{styleType:"accordion",heading:"typography.alignments",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"verticalAlign",label:"typography.valign"}]},{styleType:"accordion",heading:"typography.spacing_decoration_more",items:[{type:"dropdown",property:"letterSpacing",label:"typography.spacing"},{type:"dropdown",property:"textDecoration",label:"typography.decoration"},{type:"range",property:"textDecorationThickness",label:"typography.thickness"},{type:"dropdown",property:"textTransform",label:"typography.transform"}]},{styleType:"accordion",heading:"typography.whitespace_breaks",items:[{type:"dropdown",property:"whitespace",label:"typography.whitespace"},{type:"dropdown",property:"wordbreak",label:"typography.wordbreak"}]}]},{heading:"background.heading",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{styleType:"accordion",heading:"background.position_size_more",items:[{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]},{type:"dropdown",label:"background.gradient",property:"backgroundGradient"},{styleType:"accordion",heading:"background.gradient_colors",items:[{type:"color",label:"background.from_color",property:"fromColor"},{type:"color",label:"background.via_color",property:"viaColor"},{type:"color",label:"background.to_color",property:"toColor"}]}]},{heading:"border.heading",items:[{styleType:"multiple",type:"dropdown",label:"border.width",options:[{key:"border",label:"border.all"},{key:"borderX",label:"border.lr"},{key:"borderY",label:"border.tb"},{key:"borderTop",label:"border.top"},{key:"borderRight",label:"border.right"},{key:"borderBottom",label:"border.bottom"},{key:"borderLeft",label:"border.left"}]},{styleType:"multiple",type:"dropdown",label:"border.corners",options:[{key:"borderRadius",label:"border.all"},{key:"borderRadiusTop",label:"border.top"},{key:"borderRadiusRight",label:"border.right"},{key:"borderRadiusBottom",label:"border.bottom"},{key:"borderRadiusLeft",label:"border.left"},{key:"borderRadiusTopLeft",label:"border.top_left"},{key:"borderRadiusTopRight",label:"border.top_right"},{key:"borderRadiusBottomRight",label:"border.bottom_right"},{key:"borderRadiusBottomLeft",label:"border.bottom_left"}]},{type:"color",label:"border.color",property:"borderColor"},{type:"dropdown",label:"border.style",property:"borderStyle"},{styleType:"accordion",heading:"border.divide_options",items:[{styleType:"multiple",type:"range",label:"border.width",options:[{key:"divideXWidth",label:"border.lr"},{key:"divideYWidth",label:"border.tb"}]},{type:"color",label:"border.divide_color",property:"divideColor"},{type:"dropdown",label:"border.divide_style",property:"divideStyle"}]},{styleType:"accordion",heading:"border.outline_styling",items:[{type:"range",label:"border.outline_width",property:"outlineWidth"},{type:"range",label:"border.outline_offset",property:"outlineOffset"},{type:"dropdown",label:"border.outline_style",property:"outlineStyle"}]},{styleType:"accordion",heading:"border.ring_options",items:[{type:"range",label:"border.ring_width",property:"ringWidth"},{type:"color",label:"border.ring_color",property:"ringColor"},{type:"range",label:"border.ring_offset_width",property:"ringOffsetWidth"},{type:"color",label:"border.ring_offset_color",property:"ringOffsetColor"}]}]},{heading:"effect.heading",items:[{type:"range",label:"effect.shadow",property:"boxShadow"},{type:"color",label:"effect.color",property:"boxShadowColor"},{type:"dropdown",label:"effect.cursor",property:"cursor"},{styleType:"accordion",heading:"effect.blend_cursor",items:[{type:"dropdown",label:"effect.mix_blend",property:"mixBlendMode"},{type:"dropdown",label:"effect.bg_blend",property:"bgBlendMode"}]},{styleType:"accordion",heading:"effect.transform",items:[{type:"dropdown",label:"effect.origin",property:"transformOrigin"},{styleType:"multiple",label:"effect.scale",units:["-"],options:[{key:"scale",label:"effect.all"},{key:"scaleX",label:"effect.lr"},{key:"scaleY",label:"effect.tb"}]},{styleType:"multiple",label:"effect.skew",units:["deg"],options:[{key:"skewX",label:"effect.lr"},{key:"skewY",label:"effect.tb"}]},{styleType:"multiple",label:"effect.translate",negative:!0,options:[{key:"translateX",label:"effect.lr"},{key:"translateY",label:"effect.tb"}]},{type:"arbitrary",units:["deg"],negative:!0,label:"effect.rotate",property:"rotate"}]},{styleType:"accordion",heading:"effect.animation",items:[{type:"dropdown",label:"effect.animation",property:"animation"},{type:"dropdown",label:"effect.transition",property:"transition"},{type:"dropdown",label:"effect.easing",property:"transitionEase"},{type:"arbitrary",units:["ms"],label:"effect.duration",property:"duration"},{type:"arbitrary",units:["ms"],label:"effect.delay",property:"delay"}]}]},{heading:"classes.heading",items:[{component:rv}]}]});function av(){let[e]=ao(),[t,o]=nv.default.useState(""),[r,n]=nv.default.useState({onDrag:i=>i,onDragEnd:i=>i,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),a=(0,yG.useThrottledCallback)(i=>{let l=!(0,Fg.get)(r,"negative",!1),c=(0,Fg.get)(r,"cssProperty",""),d=parseFloat(r.dragStartValue);d=isNaN(d)?0:d;let p=foe[r.dragUnit];((0,Fg.startsWith)(c,"scale")||c==="opacity")&&(p=10);let m=(r.dragStartY-i.pageY)/p+d;l&&m<0&&(m=0),c==="opacity"&&m>1&&(m=1),r.onDrag(`${m}`),o(`${m}`)},[r],50),s=(0,nv.useCallback)(()=>{setTimeout(()=>r.onDragEnd(`${t}`),100),n({onDrag:i=>i,onDragEnd:i=>i,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[r,t,n]);return(0,Fg.isEmpty)(e)?null:(0,lu.jsxs)(Vw.Provider,{value:{setDragData:n},children:[r.dragging?(0,lu.jsx)("div",{onMouseMove:a,onMouseUp:()=>s(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,(0,lu.jsxs)("div",{className:"flex flex-col",children:[(0,lu.jsx)(U3,{}),(0,lu.jsx)(vm,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:fG.map(i=>(0,lu.jsx)(NU,{section:i,showAccordian:!1},i.heading))})]})]})}var yG,Fg,nv,lu,foe,ZA=x(()=>{"use strict";yG=require("@react-hookz/web"),Fg=require("lodash-es"),nv=K(require("react"),1);G3();EU();TA();fn();Xf();hG();lu=require("react/jsx-runtime"),foe={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1}});var pP,bG,mP,Ja,xG,It,vG,CG=x(()=>{"use strict";"use client";pP=require("@radix-ui/react-icons"),bG=require("lodash-es"),mP=require("lucide-react"),Ja=K(require("react"),1),xG=require("react-i18next");Wr();Bw();J();fo();No();Rs();gs();nP();It=require("react/jsx-runtime"),vG=Ja.default.memo(function({preloadedAttributes:t=[],onAttributesChange:o}){let[r,n]=(0,Ja.useState)([]),[a,s]=(0,Ja.useState)(""),[i,l]=(0,Ja.useState)(""),[c,d]=(0,Ja.useState)(null),[p,u]=(0,Ja.useState)(""),m=(0,Ja.useRef)(null),g=(0,Ja.useRef)(null),[h,f]=(0,Ja.useState)(!1),b=la(),{t:y}=(0,xG.useTranslation)();(0,Ja.useEffect)(()=>{n(t)},[t]);let k=()=>{if(a.startsWith("@")){u(y("Attribute keys cannot start with @"));return}if(a){let T=[...r,{key:a,value:i}];o==null||o(T),n(T),s(""),l(""),u(""),f(!1)}},w=T=>{let v=r.filter((S,A)=>A!==T);o==null||o(v),n(v)},N=T=>{d(T),s(r[T].key),l(r[T].value),f(!0)},I=()=>{if(a.startsWith("@")){u(y("Attribute keys cannot start with @"));return}if(c!==null&&a){let T=[...r];T[c]={key:a,value:i},o==null||o(T),n(T),d(null),s(""),l(""),u(""),f(!1)}},C=T=>{T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),c!==null?I():k())},P=(0,Ja.useCallback)(T=>{let v=D=>/[.,!?;:]/.test(D),S=(D,R,H)=>{let M="",L="",z=R>0?D[R-1]:"",_=R<D.length?D[R]:"";return R>0&&(z==="."||!v(z)&&z!==" ")&&(M=" "),R<D.length&&!v(_)&&_!==" "&&(L=" "),{text:M+H+L,prefixLength:M.length,suffixLength:L.length}},A=g.current;if(A){let D=A.selectionStart||0,R=A.value||"",H=A.selectionEnd||D;if(H>D){let F=`{{${T}}}`,{text:O}=S(R,D,F),U=R.slice(0,D)+O+R.slice(H);l(U);return}let L=`{{${T}}}`,{text:z}=S(R,D,L),_=R.slice(0,D)+z+R.slice(D);l(_)}},[]),B=()=>{s(""),l(""),u(""),d(null),f(!1)};return(0,It.jsx)(ey,{value:"attribute-manager",defaultOpen:!1,leftLabel:y("Attributes"),rightLabel:T=>(0,It.jsx)(E,{variant:"link",size:"xs",onClick:v=>{T&&(v.stopPropagation(),f(!0))},children:T?(0,It.jsxs)(It.Fragment,{children:[(0,It.jsx)(mP.Plus,{className:"!h-2.5 !w-2.5"})," ",y("Add Attribute")]}):y("View Attribute")}),children:(0,It.jsxs)("div",{className:"relative flex max-h-full flex-1 flex-col",children:[(0,It.jsx)("div",{className:"flex items-center p-0",children:(0,It.jsxs)(en,{open:h,onOpenChange:T=>T?f(!0):B(),children:[(0,It.jsx)($r,{asChild:!0,children:(0,It.jsx)("div",{})}),(0,It.jsx)(Vr,{className:"w-52 p-3",side:"left",align:"start",children:(0,It.jsxs)("form",{onSubmit:T=>{T.preventDefault(),c!==null?I():k()},className:"space-y-1",children:[(0,It.jsxs)("div",{className:"flex items-center justify-between",children:[(0,It.jsx)("div",{className:"text-xs font-medium",children:y(c!==null?"Edit attribute":"Add attribute")}),(0,It.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,It.jsx)(E,{type:"submit",disabled:!a.length,variant:"default",size:"xs",className:"px-2",children:y(c!==null?"Save":"Add")}),(0,It.jsx)(E,{type:"button",variant:"ghost",size:"xs",onClick:B,className:"font-light",children:(0,It.jsx)(mP.X,{})})]})]}),(0,It.jsxs)("div",{className:"space-y-2",children:[(0,It.jsxs)("div",{className:"space-y-px",children:[(0,It.jsx)(Q,{htmlFor:"attrKey",children:y("Key")}),(0,It.jsx)(Ce,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:m,value:a,onChange:T=>s(T.target.value),placeholder:y("Enter key"),className:"h-7 text-xs",autoFocus:!0})]}),(0,It.jsxs)("div",{className:"space-y-px",children:[(0,It.jsxs)("div",{className:"flex items-center justify-between",children:[(0,It.jsx)(Q,{htmlFor:"attrValue",children:y("Value")}),!(0,bG.isEmpty)(b)&&(0,It.jsx)(Gh,{data:b,onSelect:P})]}),(0,It.jsx)(Ro,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",ref:g,value:i,onChange:T=>l(T.target.value),onKeyDown:C,placeholder:y("Enter value"),rows:2,className:"resize-none text-xs"})]})]}),p&&(0,It.jsx)("p",{className:"text-[10px] text-destructive",children:p})]})})]})}),r.length>0?(0,It.jsx)("div",{className:"max-h-[40vh] space-y-1 overflow-y-auto pb-2",children:r.map((T,v)=>(0,It.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/10 px-2 py-1 text-sm",children:[(0,It.jsxs)("div",{className:"flex flex-col gap-0.5 text-xs leading-tight",children:[(0,It.jsx)("span",{className:"truncate text-[10px] font-medium leading-none text-muted-foreground",children:T.key}),(0,It.jsx)("span",{className:"max-w-[200px] text-wrap text-xs font-normal leading-none text-foreground",children:T.value.toString()})]}),(0,It.jsxs)("div",{className:"flex flex-shrink-0 gap-0.5",children:[(0,It.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:()=>N(v),className:"hover:bg-surface",children:(0,It.jsx)(pP.Pencil2Icon,{className:"!h-3 !w-3"})}),(0,It.jsx)(E,{variant:"ghost",size:"icon-xs",className:"hover:bg-destructive/30 hover:text-foreground",onClick:()=>w(v),children:(0,It.jsx)(pP.Cross1Icon,{className:"!h-3 !w-3"})})]})]},v))}):(0,It.jsx)(Q,{children:y("No attributes added yet")})]})})})});function SG(e){if(!e||typeof e!="string")return null;let t=e.split(kG);return t.length!==5?null:{animation:t[0],easing:t[1],duration:t[2],delay:t[3],time:t[4]}}function eI(e){return[e.animation,e.easing,e.duration,e.delay,e.time].join(kG)}function wG(){return eI(hoe)}function sv(e){return(0,uP.startCase)((0,uP.toLower)(e.replace(/-/g," ")))}function PG(e){let t=boe[e]||"";return`${yoe}
218
+ ${t}`}var uP,kG,hoe,yoe,boe,TG=x(()=>{"use strict";uP=require("lodash-es"),kG="|",hoe={animation:"slide-up",easing:"linear",duration:"300",delay:"100",time:"once"};yoe=".chai-animate { animation-fill-mode: both; visibility: visible; }",boe={"fade-in":"@keyframes chai-fade-in { from { opacity: 0; } to { opacity: 1; } } .chai-animate-fade-in { animation-name: chai-fade-in; }","slide-up":"@keyframes chai-slide-up { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } .chai-animate-slide-up { animation-name: chai-slide-up; }","slide-down":"@keyframes chai-slide-down { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } } .chai-animate-slide-down { animation-name: chai-slide-down; }","slide-left":"@keyframes chai-slide-left { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } } .chai-animate-slide-left { animation-name: chai-slide-left; }","slide-right":"@keyframes chai-slide-right { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } } .chai-animate-slide-right { animation-name: chai-slide-right; }","zoom-in":"@keyframes chai-zoom-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } } .chai-animate-zoom-in { animation-name: chai-zoom-in; }","zoom-out":"@keyframes chai-zoom-out { from { opacity: 0; transform: scale(1.1); } to { opacity: 1; transform: scale(1); } } .chai-animate-zoom-out { animation-name: chai-zoom-out; }","flip-x":"@keyframes chai-flip-x { from { opacity: 0; transform: perspective(400px) rotateX(90deg); } to { opacity: 1; transform: perspective(400px) rotateX(0deg); } } .chai-animate-flip-x { animation-name: chai-flip-x; backface-visibility: visible !important; }","flip-y":"@keyframes chai-flip-y { from { opacity: 0; transform: perspective(400px) rotateY(90deg); } to { opacity: 1; transform: perspective(400px) rotateY(0deg); } } .chai-animate-flip-y { animation-name: chai-flip-y; backface-visibility: visible !important; }","rotate-in":"@keyframes chai-rotate-in { from { opacity: 0; transform: rotate(-90deg); } to { opacity: 1; transform: rotate(0); } } .chai-animate-rotate-in { animation-name: chai-rotate-in; }"}});var oy,ry,Hg,EG,AG,tt,xoe,voe,NG,tI,IG=x(()=>{"use strict";oy=require("lodash-es"),ry=require("lucide-react"),Hg=K(require("react"),1),EG=require("react-i18next");J();Pg();No();Gs();Ke();Ge();fn();Ln();nP();TG();AG=require("jotai");Oa();ea();tt=require("react/jsx-runtime"),xoe=["fade-in","slide-up","slide-down","slide-left","slide-right","zoom-in","zoom-out","flip-x","flip-y","rotate-in"],voe=["linear","ease-in","ease-out","ease-in-out"],NG=["100","200","300","400","500","600","700","800","900","1000"],tI=Hg.default.memo(()=>{let e=q("flags.animation",!1),t=_e(),[o]=ao(),r=br(),{t:n}=(0,EG.useTranslation)(),a=`${(0,oy.get)(o,"0.prop")}_attrs`,s=(0,oy.get)(t,a,{}),i=s["data-animation"]||"",l=SG(i),[c]=(0,AG.useAtom)(gi),d=(0,Hg.useCallback)(h=>{if(!t)return;let f={...s};h?f["data-animation"]=h:delete f["data-animation"],r([(0,oy.get)(t,"_id")],{[a]:(0,oy.isEmpty)(f)?void 0:f})},[t,s,r,a]),p=h=>{if(!l)return;let f={...l,...h};d(eI(f))},u=(0,Hg.useCallback)(()=>{d(wG())},[d]),m=(0,Hg.useCallback)(()=>{d(void 0)},[d]),g=(0,Hg.useCallback)(()=>{var y;if(!t||!l||!c)return;let h=(c==null?void 0:c.contentDocument)||((y=c==null?void 0:c.contentWindow)==null?void 0:y.document);if(!h)return;let f=t._id+"-CHAI_ANIMATION_CSS_ELEMENT";if(!h.getElementById(f)){let k=h.createElement("style");k.id=f,k.innerHTML=PG(l.animation),h.head.appendChild(k)}let b=h.querySelector(`[data-block-id="${t._id}"]`);if(b){b.classList.remove("chai-animate",`chai-animate-${l.animation}`),b.offsetWidth,b.style.animationDuration=`${l.duration}ms`,b.style.animationDelay=`${l.delay}ms`,b.style.animationTimingFunction=l.easing,b.style.animationIterationCount="1";let k=()=>{b.classList.remove("chai-animate",`chai-animate-${l.animation}`),b.style.animationDuration="",b.style.animationDelay="",b.style.animationTimingFunction="",b.style.animationIterationCount="";let w=h.getElementById(f);w&&w.remove()};b.addEventListener("animationend",k,{once:!0}),b.classList.add("chai-animate",`chai-animate-${l.animation}`)}},[t,l,c]);return e?(0,tt.jsx)(ey,{value:"animations-manager",defaultOpen:!1,leftLabel:n("Animations"),rightLabel:h=>l?l&&(0,tt.jsxs)("span",{className:"text-[10px] font-light text-muted",children:[sv((l==null?void 0:l.animation)||"")," \u2022 ",sv((l==null?void 0:l.easing)||"")]}):(0,tt.jsxs)(E,{variant:"link",size:"xs",onClick:f=>{h&&f.stopPropagation(),u()},children:[(0,tt.jsx)(ry.Plus,{className:"!h-2.5 !w-2.5"})," ",n("Add Animation")]}),children:(0,tt.jsx)("div",{children:l?(0,tt.jsxs)("div",{className:"relative flex flex-col gap-y-1.5 rounded-md border border-border bg-muted/5 px-2 pb-1 pt-0",children:[(0,tt.jsxs)("div",{children:[(0,tt.jsx)(Q,{className:"text-[10px] uppercase text-muted-foreground",children:n("Animation")}),(0,tt.jsxs)(So,{value:l.animation,onValueChange:h=>p({animation:h}),children:[(0,tt.jsx)(ho,{className:"h-7 text-xs",children:(0,tt.jsx)(Do,{})}),(0,tt.jsx)(yo,{children:xoe.map(h=>(0,tt.jsx)(gt,{value:h,className:"text-xs",children:sv(h)},h))})]})]}),(0,tt.jsxs)("div",{children:[(0,tt.jsx)(Q,{className:"text-[10px] uppercase text-muted-foreground",children:n("Easing")}),(0,tt.jsxs)(So,{value:l.easing,onValueChange:h=>p({easing:h}),children:[(0,tt.jsx)(ho,{className:"h-7 text-xs",children:(0,tt.jsx)(Do,{})}),(0,tt.jsx)(yo,{children:voe.map(h=>(0,tt.jsx)(gt,{value:h,className:"text-xs",children:sv(h)},h))})]})]}),(0,tt.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,tt.jsxs)("div",{children:[(0,tt.jsx)(Q,{className:"text-[10px] uppercase text-muted-foreground",children:n("Duration (ms)")}),(0,tt.jsxs)(So,{value:l.duration,onValueChange:h=>p({duration:h}),children:[(0,tt.jsx)(ho,{className:"h-7 text-xs",children:(0,tt.jsx)(Do,{})}),(0,tt.jsx)(yo,{children:NG.map(h=>(0,tt.jsxs)(gt,{value:h,className:"text-xs",children:[h," ms"]},h))})]})]}),(0,tt.jsxs)("div",{children:[(0,tt.jsx)(Q,{className:"text-[10px] uppercase text-muted-foreground",children:n("Delay (ms)")}),(0,tt.jsxs)(So,{value:l.delay,onValueChange:h=>p({delay:h}),children:[(0,tt.jsx)(ho,{className:"h-7 text-xs",children:(0,tt.jsx)(Do,{})}),(0,tt.jsx)(yo,{children:NG.map(h=>(0,tt.jsxs)(gt,{value:h,className:"text-xs",children:[h," ms"]},h))})]})]})]}),(0,tt.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[(0,tt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,tt.jsxs)("div",{className:"flex items-center gap-1",children:[(0,tt.jsx)(Ia,{id:"once",checked:l.time!=="infinite",onCheckedChange:h=>p({time:h?"once":"infinite"})}),(0,tt.jsx)(Q,{htmlFor:"once",className:"text-xs font-normal",children:n("Once")})]}),(0,tt.jsxs)("div",{className:"flex items-center gap-1",children:[(0,tt.jsx)(Ia,{id:"infinite",checked:l.time==="infinite",onCheckedChange:h=>p({time:h?"infinite":"once"})}),(0,tt.jsx)(Q,{htmlFor:"infinite",className:"text-xs font-normal",children:n("Infinite")})]})]}),(0,tt.jsxs)("div",{className:"flex gap-1",children:[(0,tt.jsx)(Ye,{side:"top",className:"max-w-44",content:n("Preview animation"),children:(0,tt.jsxs)(E,{variant:"outline",size:"xs",onClick:g,children:[(0,tt.jsx)(ry.Play,{className:"!h-3 !w-3"})," ",n("Play")]})}),(0,tt.jsx)(E,{variant:"outline",size:"icon-xs",className:"hover:bg-destructive hover:text-destructive-foreground",onClick:m,children:(0,tt.jsx)(ry.Trash,{className:"!h-3 !w-3"})})]})]})]}):(0,tt.jsx)("div",{className:"py-2 text-center text-xs text-muted-foreground",children:n("No animation added to this element")})})}):null});tI.displayName="BlockAnimationsEditor"});var Ra,ny,BG,Ug,gP,oI=x(()=>{"use strict";Ra=require("lodash-es"),ny=K(require("react"),1),BG=require("react");CG();Ge();fn();Ln();IG();Ug=require("react/jsx-runtime"),gP=ny.memo(()=>{let e=_e(),[t,o]=(0,BG.useState)([]),[r]=ao(),n=br(),a=`${(0,Ra.get)(r,"0.prop")}_attrs`;ny.useEffect(()=>{let i=(0,Ra.map)((0,Ra.omit)((0,Ra.get)(e,a),["data-animation"]),(l,c)=>({key:c,value:l}));(0,Ra.isEmpty)(i)?o([]):o(i)},[(0,Ra.get)(e,a)]);let s=ny.useCallback((i=[])=>{if(!e)return;let l={},c=(0,Ra.get)(e,a,{})["data-animation"];c&&(l["data-animation"]=c),(0,Ra.forEach)(i,d=>{(0,Ra.isEmpty)(d.key)||(0,Ra.set)(l,d.key,d.value)}),n([(0,Ra.get)(e,"_id")],{[a]:l})},[e,n,a]);return(0,Ug.jsxs)(Ug.Fragment,{children:[(0,Ug.jsx)(vG,{preloadedAttributes:t,onAttributesChange:s}),(0,Ug.jsx)(tI,{})]})});gP.displayName="BlockAttributesEditor"});var ay,RG,DG,dc,rI,_G=x(()=>{"use strict";ay=require("@radix-ui/react-icons"),RG=require("lodash-es"),DG=require("react-i18next");Jx();wA();Ge();fn();Sr();dc=require("react/jsx-runtime"),rI=()=>{let{resetAll:e}=Gw(),t=_e(),[o]=ao(),r=B3(),{t:n}=(0,DG.useTranslation)();return!t||(0,RG.isEmpty)(o)?null:(0,dc.jsxs)(Yt,{children:[(0,dc.jsx)($t,{asChild:!0,children:(0,dc.jsx)("div",{className:"inline-flex rounded-sm p-0.5 hover:bg-gray-300",onClick:a=>a.stopPropagation(),children:(0,dc.jsx)(ay.DotsVerticalIcon,{className:"h-3 w-3"})})}),(0,dc.jsxs)(Vt,{side:"bottom",className:"border-border text-xs",children:[(0,dc.jsxs)(ye,{className:"flex items-center gap-1 text-xs",onClick:()=>{e()},children:[(0,dc.jsx)(ay.ResetIcon,{className:"h-3 w-3"}),n("Reset styles")]}),(0,dc.jsxs)(ye,{className:"text-xs",onClick:()=>{t&&r(t,!0)},children:[(0,dc.jsx)(ay.Cross2Icon,{className:"h-3 w-3"}),n("Clear styles")]})]})]})}});function LG(){let[e]=ao();return(0,iv.isEmpty)(e)?null:(0,je.jsx)(gP,{})}var nI,iv,MG,fP,aI,OG,je,Coe,koe,FG,HG=x(()=>{"use strict";nI=require("@radix-ui/react-icons"),iv=require("lodash-es"),MG=require("react"),fP=require("react-error-boundary"),aI=require("react-i18next"),OG=require("sonner");pk();kA();ZA();oI();Ke();Tt();mn();Nn();Ge();fn();Vc();xi();tn();_G();je=require("react/jsx-runtime");Coe=({partialBlockId:e})=>{let{t}=(0,aI.useTranslation)(),o=q("gotoPage",iv.noop),{saveState:r}=to(),{selectedLang:n,fallbackLang:a}=fe(),s=(0,MG.useCallback)(i=>{if(i.stopPropagation(),r!=="SAVED"){OG.toast.error("You have unsaved changes. Please save the page first.");return}o({pageId:e,lang:n||a})},[r,o,e,n,a]);return(0,je.jsx)(je.Fragment,{children:(0,je.jsx)("div",{className:"hidden",children:(0,je.jsx)("div",{onDoubleClick:s,className:"h-full w-full items-center justify-center",children:(0,je.jsx)("p",{className:"rounded-md px-2 py-1 text-xs",children:t("Partial block. Double click to edit.")})})})})},koe=()=>{let e=_e(),{t}=(0,aI.useTranslation)(),o=q("onError",iv.noop),{hasPermission:r}=kt(),n=!r(xe["pages:update"]),a=!r(xe["pages:update"]),[s,i]=ik();return e&&e._type==="PartialBlock"?(0,je.jsx)(Coe,{partialBlockId:e.partialBlockId}):e?n&&a?(0,je.jsx)("div",{className:"p-4 text-center",children:(0,je.jsxs)("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[(0,je.jsx)(nI.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),(0,je.jsx)("h1",{children:t("You don't have permission to edit settings or styles")}),(0,je.jsx)("p",{children:t("Please contact your administrator to get access")})]})}):a?(0,je.jsx)(fP.ErrorBoundary,{fallback:(0,je.jsx)(im,{}),onError:o,children:(0,je.jsxs)("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto",children:[(0,je.jsx)(Yx,{},e==null?void 0:e._id),(0,je.jsx)("br",{}),(0,je.jsx)("br",{})]})}):n?(0,je.jsx)(fP.ErrorBoundary,{fallback:(0,je.jsx)(im,{}),onError:o,children:(0,je.jsxs)("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden",children:[(0,je.jsx)("div",{className:"flex w-full items-center justify-end",children:(0,je.jsx)(rI,{})}),(0,je.jsx)(av,{}),(0,je.jsx)(LG,{}),(0,je.jsx)("br",{}),(0,je.jsx)("br",{}),(0,je.jsx)("br",{})]})}):(0,je.jsx)(fP.ErrorBoundary,{fallback:(0,je.jsx)(im,{}),onError:o,children:(0,je.jsxs)(Dr,{value:s,onValueChange:d=>{(d==="settings"||d==="styles")&&i(d)},className:"flex flex-1 flex-col",children:[(0,je.jsx)("div",{className:"flex items-center justify-between",children:(0,je.jsxs)(Cr,{className:"grid h-auto w-full grid-cols-2",children:[(0,je.jsx)(ut,{value:"settings",className:"text-xs",children:t("Settings")}),(0,je.jsx)(ut,{value:"styles",className:"text-xs",children:(0,je.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,je.jsx)("span",{className:"w-[90%] text-center",children:t("Styling")}),(0,je.jsx)("span",{className:"w-[10%]",children:(0,je.jsx)(rI,{})})]})})]})}),(0,je.jsxs)(kr,{value:"settings",className:"no-scrollbar h-full max-h-min overflow-y-auto",children:[(0,je.jsx)(Yx,{},e==null?void 0:e._id),(0,je.jsx)("br",{}),(0,je.jsx)("br",{})]}),(0,je.jsxs)(kr,{value:"styles",className:"no-scrollbar h-full max-h-min max-w-full overflow-y-auto overflow-x-hidden",children:[(0,je.jsx)(av,{}),(0,je.jsx)(LG,{}),(0,je.jsx)("br",{}),(0,je.jsx)("br",{}),(0,je.jsx)("br",{})]})]})}):(0,je.jsx)("div",{className:"h-full",children:(0,je.jsxs)("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center text-muted-foreground",children:[(0,je.jsx)(nI.MixerHorizontalIcon,{className:"mx-auto h-5 w-5"}),(0,je.jsx)("div",{className:"text-sm font-light",children:t("Please select a block to edit settings or styles")})]})})},FG=koe});var Ip,UG,sy,sI,GG=x(()=>{"use strict";Ip=K(require("@radix-ui/react-slider"),1),UG=K(require("react"),1);st();sy=require("react/jsx-runtime"),sI=UG.forwardRef(({className:e,...t},o)=>(0,sy.jsxs)(Ip.Root,{ref:o,className:G("relative flex w-full touch-none select-none items-center",e),...t,children:[(0,sy.jsx)(Ip.Track,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-muted",children:(0,sy.jsx)(Ip.Range,{className:"absolute h-full bg-primary"})}),(0,sy.jsx)(Ip.Thumb,{className:"block h-3 w-3 rounded-full border border-primary bg-primary shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));sI.displayName=Ip.Root.displayName});var $G,hP,VG,Soe,iI,zG=x(()=>{"use strict";$G=require("@react-hookz/web"),hP=require("react");GG();VG=require("react/jsx-runtime"),Soe=({value:e,onChange:t,disabled:o})=>{let[r,n]=(0,hP.useState)(e);(0,hP.useEffect)(()=>{n(e)},[e]);let a=(0,$G.useThrottledCallback)(t,[e],200,!0);return(0,VG.jsx)(sI,{min:0,step:1,max:50,disabled:o,value:[Number(r.replace("px",""))||0],onValueChange:s=>{n(s[0].toString()+"px"),a(s[0].toString())},className:"flex-1 cursor-pointer"})},iI=Soe});var WG,lI,woe,cI,jG=x(()=>{"use strict";WG=require("lodash-es"),lI=require("react/jsx-runtime"),woe=({value:e,onChange:t})=>{let o=(0,WG.debounce)(r=>t(r),200);return(0,lI.jsx)("div",{className:"relative flex h-5 w-5 cursor-pointer rounded-md border border-border",style:{backgroundColor:e},children:(0,lI.jsx)("input",{type:"color",value:e.startsWith("#")?e:"#000000",onChange:r=>{let n=r.target.value;/^#[0-9A-F]{6}$/i.test(n)&&o(n)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},cI=woe});var qG,KG,YG,Bp,Poe,dI,JG=x(()=>{"use strict";qG=require("lodash-es"),KG=require("react"),YG=require("react-i18next");No();Gs();Ne();Bp=require("react/jsx-runtime"),Poe=({label:e,value:t,onChange:o})=>{let r=ff(),{t:n}=(0,YG.useTranslation)();return(0,KG.useEffect)(()=>{r.some(a=>a.family===t)||o(r[0].family)},[t,o,r]),(0,Bp.jsxs)("div",{className:"space-y-0.5",children:[(0,Bp.jsx)(Q,{className:"mb-1 block text-xs text-muted-foreground",children:n((0,qG.startCase)(e))}),(0,Bp.jsxs)(So,{value:t,onValueChange:o,children:[(0,Bp.jsx)(ho,{className:"h-8 w-full text-xs text-foreground",children:(0,Bp.jsx)(Do,{placeholder:n("Select font")})}),(0,Bp.jsx)(yo,{children:r.map(a=>(0,Bp.jsx)(gt,{value:a.family,children:a.family},a.family))})]})]})},dI=Poe});var QG=x(()=>{"use strict";zG();jG();JG()});var XG,ZG,e$,t$,o$,r$=x(()=>{"use strict";XG={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#ffffff","#0a0a0a"],foreground:["#0a0a0a","#fafafa"],primary:["#171717","#e5e5e5"],"primary-foreground":["#fafafa","#171717"],secondary:["#f5f5f5","#262626"],"secondary-foreground":["#171717","#fafafa"],muted:["#f5f5f5","#262626"],"muted-foreground":["#737373","#a1a1a1"],accent:["#f5f5f5","#404040"],"accent-foreground":["#171717","#fafafa"],destructive:["#e7000b","#ff6467"],"destructive-foreground":["#ffffff","#fafafa"],border:["#e5e5e5","#282828"],input:["#e5e5e5","#343434"],ring:["#a1a1a1","#737373"],card:["#ffffff","#171717"],"card-foreground":["#0a0a0a","#fafafa"],popover:["#ffffff","#262626"],"popover-foreground":["#0a0a0a","#fafafa"]}},ZG={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"4px",colors:{background:["#ffffff","#000000"],foreground:["#0f1419","#e7e9ea"],primary:["#1e9df1","#1c9cf0"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#0f1419","#f0f3f4"],"secondary-foreground":["#ffffff","#0f1419"],muted:["#e5e5e6","#181818"],"muted-foreground":["#0f1419","#72767a"],accent:["#e3ecf6","#061622"],"accent-foreground":["#1e9df1","#1c9cf0"],destructive:["#f4212e","#f4212e"],"destructive-foreground":["#ffffff","#ffffff"],border:["#e1eaef","#242628"],input:["#f7f9fa","#22303c"],ring:["#1da1f2","#1da1f2"],card:["#f7f8f8","#17181c"],"card-foreground":["#0f1419","#d9d9d9"],popover:["#ffffff","#000000"],"popover-foreground":["#0f1419","#e7e9ea"]}},e$={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"4px",colors:{background:["#fdf6e3","#002b36"],foreground:["#073642","#93a1a1"],primary:["#d33682","#d33682"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#2aa198","#2aa198"],"secondary-foreground":["#ffffff","#ffffff"],muted:["#93a1a1","#586e75"],"muted-foreground":["#073642","#93a1a1"],accent:["#cb4b16","#cb4b16"],"accent-foreground":["#ffffff","#ffffff"],destructive:["#dc322f","#dc322f"],"destructive-foreground":["#ffffff","#ffffff"],border:["#839496","#586e75"],input:["#839496","#586e75"],ring:["#d33682","#d33682"],card:["#eee8d5","#073642"],"card-foreground":["#073642","#93a1a1"],popover:["#eee8d5","#073642"],"popover-foreground":["#073642","#93a1a1"]}},t$={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#faf9f5","#262624"],foreground:["#3d3929","#c3c0b6"],primary:["#c96442","#d97757"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#e9e6dc","#faf9f5"],"secondary-foreground":["#535146","#30302e"],muted:["#ede9de","#1b1b19"],"muted-foreground":["#83827d","#b7b5a9"],accent:["#e9e6dc","#1a1915"],"accent-foreground":["#28261b","#f5f4ee"],destructive:["#141413","#ef4444"],"destructive-foreground":["#ffffff","#ffffff"],border:["#dad9d4","#3e3e38"],input:["#b4b2a7","#52514a"],ring:["#c96442","#d97757"],card:["#faf9f5","#262624"],"card-foreground":["#141413","#faf9f5"],popover:["#ffffff","#30302e"],"popover-foreground":["#28261b","#e5e5e2"]}},o$={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#fff9f5","#2a2024"],foreground:["#3d3436","#f2e9e4"],primary:["#ff7e5f","#ff7e5f"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#ffedea","#463a41"],"secondary-foreground":["#b35340","#f2e9e4"],muted:["#fff0eb","#392f35"],"muted-foreground":["#78716c","#d7c6bc"],accent:["#feb47b","#feb47b"],"accent-foreground":["#3d3436","#2a2024"],destructive:["#e63946","#e63946"],"destructive-foreground":["#ffffff","#ffffff"],border:["#ffe0d6","#463a41"],input:["#ffe0d6","#463a41"],ring:["#ff7e5f","#ff7e5f"],card:["#ffffff","#392f35"],"card-foreground":["#3d3436","#f2e9e4"],popover:["#ffffff","#392f35"],"popover-foreground":["#3d3436","#f2e9e4"]}}});var Dp,Rp,Toe,Noe,iy,n$=x(()=>{"use strict";Dp=K(require("culori"),1),Rp=e=>e?e%1===0?e:e.toFixed(4):"0",Toe=e=>`hsl(${Rp(e.h)} ${Rp(e.s*100)}% ${Rp(e.l*100)}%)`,Noe=(e,t="hsl",o="4")=>{try{let r=Dp.parse(e);if(!r)throw new Error("Invalid color input");switch(t){case"hsl":{let n=Dp.converter("hsl")(r);return o==="4"?Toe(n):`${Rp(n.h)} ${Rp(n.s*100)}% ${Rp(n.l*100)}%`}case"rgb":return Dp.formatRgb(r);case"oklch":{let n=Dp.converter("oklch")(r);return`oklch(${Rp(n.l)} ${Rp(n.c)} ${Rp(n.h)})`}case"hex":return Dp.formatHex(r);default:return e}}catch(r){return console.error(`Failed to convert color: ${e}`,r),e}},iy=e=>Noe(e,"hex")});var yP,a$,cu,s$,Eoe,Aoe,i$,l$,bP,lv,pI=x(()=>{"use strict";Ne();n$();yP=e=>{let t={fontFamily:{heading:"",body:""},borderRadius:"",colors:{}};try{let o=lv(e);if(!o.isValid)return console.warn("CSS validation failed:",o.error),i$();let r=a$(e,":root"),n=a$(e,".dark"),a=cu(r,"--font-sans")||cu(r,"--font-family")||cu(r,"--font-heading")||cu(r,"--font-body"),s=Eoe(a);t.fontFamily={heading:s,body:s};let i=cu(r,"--radius")||cu(r,"--border-radius")||"0.5rem";t.borderRadius=Aoe(i),["background","foreground","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","destructive","destructive-foreground","border","input","ring","card","card-foreground","popover","popover-foreground"].forEach(c=>{let d=cu(r,`--${c}`),p=cu(n,`--${c}`);if(d||p){let u=d?s$(d):"#000000",m=p?s$(p):u;t.colors[c]=[u,m]}})}catch(o){return console.error("Error parsing CSS to ChaiThemeValues:",o),i$()}return t},a$=(e,t)=>{var r,n;let o=new RegExp(`${l$(t)}\\s*{([^}]+)}`);return((n=(r=e.match(o))==null?void 0:r[1])==null?void 0:n.trim())||null},cu=(e,t)=>{var n;if(!e)return null;let o=new RegExp(`${l$(t)}\\s*:\\s*([^;]+)`),r=e.match(o);return((n=r==null?void 0:r[1])==null?void 0:n.trim())||null},s$=e=>{if(!e||typeof e!="string")return"#000000";try{let t=e.replace(/var\([^)]+\)/g,"").trim();if(!t)return"#000000";if(/^[a-z]+$/i.test(t))return iy(t)||"#000000";if(/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(t.replace(/#/g,""))){let r=t.startsWith("#")?t:`#${t}`;return r.length<=5?`#${r.slice(1).split("").map(n=>n+n).join("")}`.slice(0,7):r.length>7?r.slice(0,7):r}if(/^(rgb|hsl|oklch)a?\(/i.test(t))return iy(t)||"#000000";let o=t.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);if(o){let[,r,n,a]=o,s=`hsl(${r} ${n}% ${a}%)`;return iy(s)||"#000000"}if(/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(t)){let r=t.split(/[\s,]+/).filter(Boolean);if(r.length>=3){let a=r.some(s=>s.includes("%"))?`hsl(${r[0]} ${r[1]} ${r[2]})`:`rgb(${r[0]}, ${r[1]}, ${r[2]})`;return iy(a)||"#000000"}}return iy(t)||"#000000"}catch(t){return console.warn("Failed to process color:",e,t),"#000000"}},Eoe=e=>{let t=hf();if(!e)return"ui-sans-serif, system-ui, sans-serif";try{let r=e.replace(/["']/g,"").trim().split(",")[0].trim(),n=t.find(a=>a.family.toLowerCase()===r.toLowerCase());return(n==null?void 0:n.family)||"ui-sans-serif, system-ui, sans-serif"}catch(o){return console.warn("Error processing font family:",e,o),"ui-sans-serif, system-ui, sans-serif"}},Aoe=e=>{if(!e)return"8px";try{let t=e.trim();if(t.endsWith("px"))return t;if(t.endsWith("rem")){let r=parseFloat(t.replace("rem",""));if(!isNaN(r))return`${Math.round(r*16)}px`}if(t.endsWith("em")){let r=parseFloat(t.replace("em",""));if(!isNaN(r))return`${Math.round(r*16)}px`}let o=parseFloat(t);return isNaN(o)?"8px":`${Math.round(o)}px`}catch(t){return console.warn("Error converting border radius to px:",e,t),"8px"}},i$=()=>({fontFamily:{heading:"ui-sans-serif, system-ui, sans-serif",body:"ui-sans-serif, system-ui, sans-serif"},borderRadius:"8px",colors:{background:["#ffffff","#000000"],foreground:["#000000","#ffffff"],primary:["#3b82f6","#60a5fa"],"primary-foreground":["#ffffff","#1e293b"],secondary:["#f1f5f9","#334155"],"secondary-foreground":["#0f172a","#f8fafc"],muted:["#f8fafc","#1e293b"],"muted-foreground":["#64748b","#94a3b8"],accent:["#f1f5f9","#334155"],"accent-foreground":["#0f172a","#f8fafc"],destructive:["#ef4444","#f87171"],"destructive-foreground":["#ffffff","#1e293b"],border:["#e2e8f0","#475569"],input:["#e2e8f0","#475569"],ring:["#3b82f6","#60a5fa"],card:["#ffffff","#0f172a"],"card-foreground":["#000000","#f8fafc"],popover:["#ffffff","#0f172a"],"popover-foreground":["#000000","#f8fafc"]}}),l$=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),bP=e=>["background","foreground","primary","primary-foreground"].every(r=>e.colors[r]&&Array.isArray(e.colors[r])&&(e.colors[r]||[]).length>=2)&&!!e.fontFamily.heading&&!!e.fontFamily.body&&!!e.borderRadius,lv=e=>{if(!e||typeof e!="string")return{isValid:!1,error:"Please enter valid CSS content"};let t=e.trim();if(!t)return{isValid:!1,error:"Please enter CSS content"};try{if(!t.includes("{")||!t.includes("}"))return{isValid:!1,error:"Invalid CSS format. CSS should contain proper block structure with { }"};let o=(t.match(/{/g)||[]).length,r=(t.match(/}/g)||[]).length;return o!==r?{isValid:!1,error:"Invalid CSS format. Unmatched braces detected"}:!t.includes("--")||!t.includes(":")?{isValid:!1,error:"Invalid CSS format. CSS should contain variable definitions like --primary: #color"}:!t.includes(":root")&&!t.includes(".dark")?{isValid:!1,error:"CSS should contain at least :root or .dark selector with theme variables"}:{isValid:!0}}catch(o){return console.error("CSS validation error:",o),{isValid:!1,error:"Failed to parse CSS. Please check your syntax."}}}});var d$={};et(d$,{CssImportModal:()=>Boe});var xP,c$,Dn,Ioe,Boe,p$=x(()=>{"use strict";xP=K(require("react"),1),c$=require("react-i18next");pI();J();qt();No();gs();Dn=require("react/jsx-runtime"),Ioe=`:root {
219
+ --background: 0 0% 100%;
220
+ --foreground: oklch(0.52 0.13 144.17);
221
+ --primary: #3e2723;
222
+ --primary-foreground: #ffffff;
223
+ }
224
+
225
+ .dark {
226
+ --background: 222.2 84% 4.9%;
227
+ --foreground: hsl(37.50 36.36% 95.69%);
228
+ --primary: rgb(46, 125, 50);
229
+ --primary-foreground: #ffffff;
230
+ }`,Boe=({open:e,onOpenChange:t,onImport:o})=>{let[r,n]=xP.useState(""),[a,s]=xP.useState(null),[i,l]=xP.useState(!1),{t:c}=(0,c$.useTranslation)(),d=async()=>{l(!0),s(null);try{let u=lv(r);if(!u.isValid){s(u.error||c("Invalid CSS format")),setTimeout(()=>{s(null)},5e3),l(!1);return}let m=yP(r);if(!bP(m)){s(c("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors.")),setTimeout(()=>{s(null)},5e3),l(!1);return}o(m),n(""),s(null),t(!1)}catch(u){console.error("Error importing CSS:",u),s(c("Failed to parse CSS. Please check your syntax and try again.")),setTimeout(()=>{s(null)},5e3)}finally{l(!1)}},p=()=>{n(""),s(null),t(!1)};return(0,Dn.jsx)(Te,{open:e,onOpenChange:t,children:(0,Dn.jsxs)(we,{className:"flex max-h-[80vh] max-w-2xl flex-col",children:[(0,Dn.jsxs)(Oe,{children:[(0,Dn.jsx)(Ie,{className:"text-base",children:c("Import CSS Theme")}),(0,Dn.jsxs)(Dt,{className:"space-y-2 text-xs font-light",children:[c("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties."),(0,Dn.jsxs)("div",{className:"flex items-center pt-2",children:[(0,Dn.jsx)("p",{className:"font-medium text-foreground/80",children:"Get theme resources:"}),(0,Dn.jsx)(E,{variant:"link",size:"xs",onClick:()=>window.open("https://tweakcn.com/","_blank"),children:"TweakCN"}),(0,Dn.jsx)(E,{variant:"link",size:"xs",onClick:()=>window.open("https://ui.shadcn.com/themes#themes","_blank"),children:"shadcn/ui Themes"}),(0,Dn.jsx)(E,{variant:"link",size:"xs",onClick:()=>window.open("https://zippystarter.com/tools/shadcn-ui-theme-generator","_blank"),children:"ZippyStarter"})]})]})]}),(0,Dn.jsxs)("div",{className:"flex-1 space-y-4 overflow-hidden",children:[(0,Dn.jsxs)("div",{className:"space-y-2",children:[(0,Dn.jsx)(Q,{htmlFor:"css-input",children:c("CSS Variables")}),(0,Dn.jsx)(Ro,{id:"css-input",placeholder:Ioe,value:r,onChange:u=>n(u.target.value),className:"min-h-[300px] resize-none text-xs",disabled:i})]}),a&&(0,Dn.jsx)("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3",children:(0,Dn.jsx)("p",{className:"text-sm text-destructive",children:a})})]}),(0,Dn.jsxs)(co,{children:[(0,Dn.jsx)(E,{variant:"outline",size:"sm",onClick:p,disabled:i,children:c("Cancel")}),(0,Dn.jsx)(E,{loading:i,size:"sm",onClick:d,disabled:!r.trim(),children:c("Import Theme")})]})]})})}});var u$={};et(u$,{AiThemeGenerator:()=>Roe});var vP,ti,m$,Li,Roe,g$=x(()=>{"use strict";vP=require("lucide-react"),ti=require("react"),m$=require("react-i18next");pI();nS();St();dx();rt();Kt();J();Oo();Ne();Li=require("react/jsx-runtime"),Roe=({onThemeGenerated:e})=>{let{t}=(0,m$.useTranslation)(),o=Ls(),{data:r}=Cm(),n=Hc("AI_GENERATE_THEME"),a=(0,ti.useRef)(null),[s,i]=(0,ti.useState)(!1),[l,c]=(0,ti.useState)(""),[d,p]=(0,ti.useState)(!1),[u,m]=(0,ti.useState)(null);(0,ti.useEffect)(()=>{s&&setTimeout(()=>{var y;return(y=a.current)==null?void 0:y.focus()},100)},[s]);let g=(0,ti.useCallback)(y=>{m(y),setTimeout(()=>m(null),8e3)},[]),h=(0,ti.useCallback)(async()=>{var k,w;let y=l.trim();if(!(!y||d)){p(!0),m(null);try{let N=hf().map(B=>B.family),I=await o({body:{action:$.AI_GENERATE_THEME,data:{prompt:y,availableFonts:N,branding:(k=r==null?void 0:r.site)!=null&&k.look||(w=r==null?void 0:r.site)!=null&&w.tone?{look:r.site.look,tone:r.site.tone}:void 0,model:n}}});if(!(I!=null&&I.css)){g(t("Failed to generate theme. Please try again."));return}let C=lv(I.css);if(!C.isValid){g(C.error||t("AI generated invalid CSS. Please try a different description."));return}let P=yP(I.css);if(!bP(P)){g(t("AI generated an incomplete theme. Missing required colors. Please try a different description."));return}e(P),c(""),i(!1)}catch(N){console.error("AI Theme Generation Error:",N),g((N==null?void 0:N.message)||t("Failed to generate theme with AI. Please try again."))}finally{p(!1)}}},[l,d,o,t,e,g,r]),f=(0,ti.useCallback)(y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),h()),y.key==="Escape"&&(y.preventDefault(),d||(i(!1),c(""),m(null)))},[h,d]),b=(0,ti.useCallback)(()=>{d||(i(y=>!y),s&&(c(""),m(null)))},[s,d]);return(0,Li.jsxs)("div",{className:"relative",children:[(0,Li.jsx)(E,{variant:"ghost",size:"icon-sm",onClick:b,disabled:d,"aria-label":t("Generate theme with AI"),title:t("Generate theme with AI"),children:(0,Li.jsx)(vP.Wand2Icon,{className:"text-orange h-3 w-3"})}),s&&(0,Li.jsxs)("div",{className:"absolute right-0 top-full z-50 w-[256px] overflow-hidden rounded-md border bg-background shadow-lg",children:[(0,Li.jsxs)(eS,{onSubmit:h,className:"flex flex-col",children:[(0,Li.jsx)(tS,{ref:a,placeholder:t("Describe the look you want"),value:l,onChange:y=>c(y.target.value),onKeyDown:f,disabled:d,className:"w-full resize-none border-0 text-xs",rows:5}),(0,Li.jsx)(oS,{className:"absolute bottom-0 right-0 justify-end",children:(0,Li.jsx)(rS,{disabled:!l.trim()||d,className:"h-7 w-7 shrink-0",children:d?(0,Li.jsx)(wt,{className:"!h-3 !w-3"}):(0,Li.jsx)(vP.ArrowRight,{className:"!h-3 !w-3"})})})]}),u&&(0,Li.jsx)("p",{className:"border-t p-2 text-[10px] leading-tight text-destructive",children:u})]})]})}});var yd,mI,du,hd,f$,uI,h$,ly,De,Doe,_oe,y$,Loe,Moe,Ooe,b$,gI,fI=x(()=>{"use strict";yd=require("@radix-ui/react-icons"),mI=require("@react-hookz/web"),du=require("lodash-es"),hd=K(require("react"),1),f$=require("react-i18next"),uI=require("sonner");QG();pn();Ke();Im();mn();$A();Vc();J();fo();No();Gs();rE();Wd();tn();h$=require("lucide-react"),ly=require("react");r$();Ne();De=require("react/jsx-runtime"),Doe=(0,ly.lazy)(()=>Promise.resolve().then(()=>(p$(),d$)).then(e=>({default:e.CssImportModal}))),_oe=(0,ly.lazy)(()=>Promise.resolve().then(()=>(g$(),u$)).then(e=>({default:e.AiThemeGenerator}))),y$="chai-builder-previous-theme",Loe=[{shadcn_default:XG},{twitter_theme:ZG},{solarized_theme:e$},{claude_theme:t$},{supabase_theme:o$}],Moe=e=>{if(typeof window!="undefined")try{localStorage.setItem(y$,JSON.stringify(e))}catch(t){console.warn("Failed to save previous theme to localStorage:",t)}},Ooe=()=>{if(typeof window!="undefined")try{localStorage.removeItem(y$)}catch(e){console.warn("Failed to clear previous theme from localStorage:",e)}},b$=hd.memo(({className:e=""})=>{let[t,o]=ec(),[r,n]=hd.useState(""),[a,s]=hd.useState(!1),i=q("themePresets",{}),{hasPermission:l}=kt(),{debouncedSaveTheme:c}=sP(),d=q("flags.importTheme",!0),p=q("flags.darkMode",!1),u=ff(),m=q("flags.ai",!1);(!i||i.length===0)&&Loe.map(v=>{i.push(v)});let[g,h]=Yu(),f=nm(),{t:b}=(0,f$.useTranslation)(),y=hd.useCallback(v=>{let S={...g};Moe(S),h(v),c(),uI.toast.success("Theme updated",{action:{label:(0,De.jsxs)("span",{className:"flex items-center gap-2",children:[(0,De.jsx)(yd.ResetIcon,{className:"h-4 w-4"})," Undo"]}),onClick:()=>{h(S),Ooe(),uI.toast.dismiss()}},closeButton:!0,duration:15e3})},[g,h,c]),k=()=>{let v=i.find(D=>Object.keys(D)[0]===r);if(!v){console.error("Preset not found:",r);return}let S=Object.values(v)[0];S&&typeof S=="object"&&"fontFamily"in S&&"borderRadius"in S&&"colors"in S?(y(S),n("")):console.error("Invalid preset structure:",S)},w=v=>{y(v),n("")},N=hd.useCallback(v=>{y(v),n("")},[y]),I=(0,mI.useDebouncedCallback)((v,S)=>{h(()=>({...g,fontFamily:{...g.fontFamily,[v.replace(/font-/g,"")]:S}})),c()},[g,c],200),C=hd.useCallback(v=>{let S=v===""?"0":v,A=parseInt(S);isNaN(A)||A<0||A>50?S="0":S=A.toString(),h(D=>({...D,borderRadius:`${S}px`})),c()},[h,c]),P=hd.useCallback(v=>{h(S=>({...S,borderRadius:`${v}px`})),c()},[h,c]),B=(0,mI.useDebouncedCallback)((v,S)=>{h(()=>{let A=(0,du.get)(g,`colors.${v}`);return t?(0,du.set)(A,1,S):(0,du.set)(A,0,S),{...g,colors:{...g.colors,[v]:A}}}),c()},[g,c],200),T=v=>(0,De.jsx)("div",{className:"grid grid-cols-1",children:Object.entries(v.items).map(([S])=>{let A=(0,du.get)(g,`colors.${S}.${t?1:0}`);return A?(0,De.jsxs)("div",{id:`theme-${S}`,className:"flex items-center gap-x-2 py-0.5",children:[(0,De.jsx)(cI,{value:A,onChange:D=>B(S,D)}),(0,De.jsx)(Q,{className:"text-xs font-light leading-tight text-foreground",children:S.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(D=>D.charAt(0).toUpperCase()+D.slice(1)).join(" ")+(!S.toLowerCase().includes("foreground")&&!S.toLowerCase().includes("border")&&!S.toLowerCase().includes("input")&&!S.toLowerCase().includes("ring")&&!S.toLowerCase().includes("background")?" Background":"")})]},S):null})});return l(xe["theme:edit"])?(0,De.jsx)("div",{className:"relative w-full",children:(0,De.jsxs)("div",{className:Co("no-scrollbar h-full w-full overflow-y-auto",e),children:[i.length>0&&(0,De.jsxs)("div",{className:"space-y-2 py-2",children:[(0,De.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,De.jsx)(Q,{className:"text-xs font-medium text-foreground",children:b("Presets")}),(0,De.jsxs)("div",{className:"flex items-center gap-1",children:[d&&(0,De.jsx)(E,{variant:"link",size:"xs",onClick:()=>s(!0),children:b("Import theme")}),m&&(0,De.jsx)(ly.Suspense,{fallback:(0,De.jsx)("div",{className:"h-6 animate-pulse rounded-md bg-muted/20"}),children:(0,De.jsx)(_oe,{onThemeGenerated:N})})]})]}),(0,De.jsxs)("div",{className:"flex items-center gap-2",children:[(0,De.jsxs)(So,{value:r,onValueChange:n,children:[(0,De.jsx)(ho,{className:"h-8 flex-1 text-xs",children:(0,De.jsx)(Do,{placeholder:b("Select preset")})}),(0,De.jsx)(yo,{children:Array.isArray(i)&&i.map(v=>{let S=Object.keys(v)[0],A=S.replaceAll("_"," ");return(0,De.jsx)(gt,{value:S,className:"text-xs",children:(0,du.capitalize)(A)},S)})})]}),(0,De.jsx)(E,{size:"sm",disabled:!r,onClick:k,children:b("Apply")})]})]}),(0,De.jsx)(sh,{}),(0,De.jsxs)("div",{className:Co("space-y-3 py-2",e),children:[u.length>0?(0,De.jsxs)(De.Fragment,{children:[(0,De.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,De.jsx)(yd.TextIcon,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,De.jsx)("span",{className:"text-xs font-medium text-foreground",children:b("Typography")})]}),(f==null?void 0:f.fontFamily)&&(0,De.jsx)("div",{className:"space-y-2",children:Object.entries(f.fontFamily).map(([v,S])=>(0,De.jsx)(dI,{label:v,value:g.fontFamily[v.replace(/font-/g,"")]||S[Object.keys(S)[0]],onChange:A=>I(v,A)},v))}),(0,De.jsx)(sh,{})]}):"",(f==null?void 0:f.borderRadius)&&(0,De.jsxs)("div",{className:"space-y-2",children:[(0,De.jsxs)("div",{className:"flex items-center justify-between",children:[(0,De.jsxs)("div",{className:"flex items-center gap-2",children:[(0,De.jsx)(h$.SquareRoundCorner,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,De.jsx)("span",{className:"text-xs font-medium text-foreground",children:b("Border Radius")})]}),(0,De.jsxs)("div",{className:"relative flex items-center",children:[(0,De.jsx)(Ce,{type:"number",min:0,max:50,className:"h-6 w-14 rounded-sm border-input bg-muted/20 pr-5 text-right text-[10px] font-light [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",value:g.borderRadius.replace("px",""),onChange:v=>C(v.target.value)}),(0,De.jsx)("span",{className:"pointer-events-none absolute right-1 text-[10px] font-light text-foreground",children:"px"})]})]}),(0,De.jsx)("div",{className:"py-1",children:(0,De.jsx)(iI,{value:g.borderRadius,onChange:P})})]}),(0,De.jsx)(sh,{}),(f==null?void 0:f.colors)&&(0,De.jsxs)("div",{className:"space-y-3",children:[(0,De.jsxs)("div",{className:"flex items-center justify-between",children:[(0,De.jsxs)("div",{className:"flex items-center gap-2",children:[(0,De.jsx)(yd.MixerHorizontalIcon,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,De.jsx)("span",{className:"text-xs font-medium text-foreground",children:b("Colors")})]}),p&&(0,De.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,De.jsx)(yd.SunIcon,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,De.jsx)(On,{checked:t,onCheckedChange:v=>o(v),"aria-label":b("Toggle dark mode")}),(0,De.jsx)(yd.MoonIcon,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),(0,De.jsx)("div",{className:"space-y-1.5",children:f.colors.map(v=>(0,De.jsx)("div",{children:T(v)},v.group))})]}),(0,De.jsx)(ly.Suspense,{fallback:(0,De.jsx)("div",{}),children:a&&d&&(0,De.jsx)(Doe,{open:a,onOpenChange:s,onImport:w})})]}),(0,De.jsx)("br",{}),(0,De.jsx)("br",{}),(0,De.jsx)("br",{}),(0,De.jsx)("br",{})]})}):(0,De.jsx)("div",{className:"relative w-full",children:(0,De.jsx)("div",{className:Co("no-scrollbar flex h-full w-full items-center justify-center overflow-y-auto text-center",e),children:(0,De.jsx)("div",{className:"space-y-2 px-4 text-muted-foreground",children:(0,De.jsx)("p",{className:"text-xs font-light leading-relaxed",children:b("You don't have permission to edit the theme. Please contact your administrator to get access.")})})})})});b$.displayName="ThemeConfigPanel";gI=b$});var na,x$,v$,cv,Mi,cy,Foe,C$,Hoe,Gg,$g,Uoe,Vg,hI,dv=x(()=>{"use strict";na=K(require("@radix-ui/react-dialog"),1),x$=require("@radix-ui/react-icons"),v$=require("class-variance-authority"),cv=K(require("react"),1);st();Mi=require("react/jsx-runtime"),cy=na.Root,Foe=na.Portal,C$=cv.forwardRef(({className:e,...t},o)=>(0,Mi.jsx)(na.Overlay,{className:G("fixed inset-0 z-50 bg-background/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:o}));C$.displayName=na.Overlay.displayName;Hoe=(0,v$.cva)("fixed z-50 gap-4 bg-surface p-4 shadow-lg transition ease-in-out focus:outline-none data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Gg=cv.forwardRef(({side:e="right",className:t,children:o,...r},n)=>(0,Mi.jsxs)(Foe,{children:[(0,Mi.jsx)(C$,{}),(0,Mi.jsxs)(na.Content,{ref:n,className:G(Hoe({side:e}),t),...r,children:[(0,Mi.jsxs)(na.Close,{className:"ring-offset-surface absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,Mi.jsx)(x$.Cross1Icon,{className:"h-4 w-4 text-foreground"}),(0,Mi.jsx)("span",{className:"sr-only",children:"Close"})]}),o]})]}));Gg.displayName=na.Content.displayName;$g=({className:e,...t})=>(0,Mi.jsx)("div",{className:G("flex flex-col space-y-2 text-center sm:text-left",e),...t});$g.displayName="SheetHeader";Uoe=({className:e,...t})=>(0,Mi.jsx)("div",{className:G("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Uoe.displayName="SheetFooter";Vg=cv.forwardRef(({className:e,...t},o)=>(0,Mi.jsx)(na.Title,{ref:o,className:G("text-sm font-medium leading-tight text-foreground",e),...t}));Vg.displayName=na.Title.displayName;hI=cv.forwardRef(({className:e,...t},o)=>(0,Mi.jsx)(na.Description,{ref:o,className:G("text-sm text-muted-foreground",e),...t}));hI.displayName=na.Description.displayName});var k$,S$=x(()=>{"use strict";k$=()=>process.env.NODE_ENV==="development"});var dy,mv,Qt,py,ro,w$,ae,Goe,pv,P$,T$=x(()=>{"use strict";dy=require("@radix-ui/react-icons"),mv=require("framer-motion"),Qt=require("lodash-es"),py=require("lucide-react"),ro=K(require("react"),1),w$=require("react-i18next");tA();uA();l4();HG();fI();Ke();Zc();Vc();uh();ea();Rr();aN();J();qt();dv();rs();lm();S$();ae=require("react/jsx-runtime"),Goe=ro.default.lazy(()=>Promise.resolve().then(()=>(JA(),cG))),pv=280,P$=()=>{var S;let[e,t]=ma(),[o,r]=(0,ro.useState)("outline"),[n,a]=(0,ro.useState)(!1),[s,i]=(0,ro.useState)(!1),[l,c]=Mb(),[,d]=ik(),p=yk("top"),u=yk("bottom"),m=(0,Qt.reverse)([...u!=null?u:[]]),g=(0,ro.useCallback)(A=>{k$()||A.preventDefault()},[]),h=(0,ro.useMemo)(()=>[p].flat(),[p]),{t:f}=(0,w$.useTranslation)(),b=(0,ro.useMemo)(()=>[...p,...u],[p,u]),y=q("htmlDir","ltr"),k=(S=(0,Qt.find)(b,{id:e}))!=null?S:(0,Qt.first)(b),w=(0,Qt.get)(k,"width",pv);(0,ro.useEffect)(()=>{let A=(0,Qt.find)(b,{id:e}),D=A&&(0,Qt.get)(A,"view","standard")==="standard";e!==null&&D&&r(e)},[e,b]);let N=(0,ro.useMemo)(()=>{if(o){let A=(0,Qt.find)(b,{id:o});if(A)return(0,Qt.get)(A,"width",pv)}return pv},[o,b]),I=(0,ro.useMemo)(()=>{if(e===null||n)return 0;let A=(0,Qt.find)(b,{id:e}),D=(0,Qt.get)(A,"view","standard")==="standard",R=(0,Qt.get)(A,"width",pv);return D?R:N},[e,N,b,n]),C=(0,ro.useMemo)(()=>s||e==="ai"?0:pv,[s,e]),P=(0,ro.useCallback)(A=>{if((0,Qt.get)((0,Qt.find)(b,{id:A}),"view","standard")==="standard")if(e===A){a(R=>!R);return}else n&&a(!1);t(e===A?null:A)},[b,e,t,n]),B=(0,ro.useCallback)(()=>{t(o!=null?o:"outline")},[t,o]),T=(0,ro.useCallback)(()=>{t("outline")},[t]);(0,ro.useEffect)(()=>{e!==null&&!(0,Qt.find)(b,{id:e})&&t("outline");let A;return mh()&&e!=="chai-chat-panel"&&(A=setTimeout(()=>t("chai-chat-panel"),1e3)),()=>{A!==void 0&&clearTimeout(A)}},[e,b,t]);let v=(0,ro.useCallback)(A=>{P(A)},[P]);return(0,ae.jsx)("div",{dir:y,className:"bg-surface h-screen max-h-full w-screen overflow-x-hidden text-foreground",children:(0,ae.jsxs)(df,{children:[(0,ae.jsxs)("div",{onContextMenu:g,className:"flex h-full max-h-full flex-col",children:[(0,ae.jsx)("div",{className:"flex h-max w-screen items-center border-b",children:(0,ae.jsx)(ro.Suspense,{children:(0,ae.jsx)(Br,{slotId:jo.TOP_BAR,multiple:!1,defaultComponent:null})})}),(0,ae.jsxs)("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[(0,ae.jsxs)("div",{id:"sidebar",className:"flex w-10 flex-col items-center justify-between bg-background py-1.5",children:[(0,ae.jsx)("div",{className:"flex flex-col justify-between gap-y-0.5",children:h.map((A,D)=>(0,ae.jsx)(Ye,{content:f(A.label),side:"right",children:(0,ae.jsx)("div",{id:"panel-btn-"+A.id,children:(0,ro.createElement)((0,Qt.get)(A,"button",kg),{position:"top",panelId:A.id,isActive:e===A.id,show:()=>v(A.id)})})},"button-top-"+D))}),(0,ae.jsx)("div",{className:"flex flex-col space-y-0.5"}),(0,ae.jsx)("div",{className:"flex flex-col",children:m==null?void 0:m.map((A,D)=>(0,ae.jsx)(Ye,{content:f(A.label),side:"right",children:(0,ae.jsx)("div",{id:"panel-btn-"+A.id,children:(0,ro.createElement)((0,Qt.get)(A,"button",kg),{position:"bottom",panelId:A.id,isActive:e===A.id,show:()=>v(A.id)})})},"button-bottom-"+D))})]}),(0,ae.jsxs)(mv.motion.div,{id:"left-panel",className:`relative h-full max-h-full ${n?"border-l":"border-l dark:border-none"}`,initial:{width:I},animate:{width:I},transition:{duration:.3,ease:"easeInOut"},children:[e!==null&&(0,Qt.get)(k,"view","standard")==="standard"&&!n&&(0,ae.jsxs)("div",{className:"no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2",children:[(0,Qt.get)(k,"label","")!==""?(0,ae.jsx)("div",{className:`absolute top-2 flex h-8 items-center space-x-1 text-sm font-medium uppercase ${(0,Qt.get)(k,"isInternal",!1)?"":"w-64 max-w-64 truncate"}`,children:(0,ae.jsx)("span",{children:f((0,Qt.get)(k,"label",""))})}):null,(0,ae.jsx)("div",{className:"no-scrollbar h-full max-h-full overflow-y-auto "+((0,Qt.get)(k,"label","")!==""?"pt-10":""),children:(0,ae.jsx)(ro.Suspense,{fallback:(0,ae.jsx)("div",{className:"h-full w-full animate-pulse rounded-md bg-muted/10"}),children:ro.default.createElement((0,Qt.get)(k,"panel",kg),{})})})]}),e!==null&&(0,ae.jsx)(Ye,{content:f(n?"Expand":"Collapse"),side:"right",children:(0,ae.jsx)(E,{variant:"ghost",size:"icon",className:`absolute -right-4 top-10 z-10 h-7 w-4 rounded-none rounded-r-md border-none p-0 hover:bg-accent ${n?"bg-orange hover:bg-orange/80":"bg-surface"}`,onClick:()=>a(A=>!A),children:n?(0,ae.jsx)(py.ChevronRight,{className:"h-4 w-4"}):(0,ae.jsx)(py.ChevronLeft,{className:"h-4 w-4"})})})]}),(0,ae.jsx)("div",{id:"canvas-container",className:"flex h-full max-h-full flex-1 flex-col",children:(0,ae.jsx)(ro.Suspense,{children:(0,ae.jsx)(eA,{})})}),(0,ae.jsxs)(mv.motion.div,{id:"right-panel",className:`relative h-full max-h-full ${s?"border-r":""}`,initial:{width:C},animate:{width:C},transition:{duration:.3,ease:"easeInOut"},children:[(0,ae.jsx)(Ye,{content:f(s?"Expand":"Collapse"),side:"left",children:(0,ae.jsx)(E,{variant:"ghost",size:"icon",className:`absolute -left-4 top-10 z-10 h-7 w-4 rounded-none rounded-l-md border-none p-0 hover:bg-accent ${s?"bg-orange hover:bg-orange/80":"bg-surface"}`,onClick:()=>i(A=>!A),children:s?(0,ae.jsx)(py.ChevronLeft,{className:"h-4 w-4"}):(0,ae.jsx)(py.ChevronRight,{className:"h-4 w-4"})})}),(0,ae.jsx)("div",{className:"no-scrollbar overflow h-full max-h-full overflow-hidden",children:(0,ae.jsxs)("div",{className:"flex h-full max-h-full flex-col overflow-hidden p-3",children:[(0,ae.jsx)("h2",{className:"-mt-1 flex items-center space-x-1 text-base font-bold",children:(0,ae.jsx)("div",{className:"flex grow items-center gap-2",children:(0,ae.jsx)("div",{className:"flex w-full items-center justify-between gap-2",children:l==="ai"?(0,ae.jsx)(ae.Fragment,{children:(0,ae.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ae.jsx)(dy.LightningBoltIcon,{className:"rtl:ml-2"})," ",f("AI Assistant")]})}):l==="design-tokens"?(0,ae.jsxs)("div",{className:"flex w-full items-center justify-between gap-2",children:[(0,ae.jsx)("div",{className:"flex h-8 items-center space-x-1 truncate text-sm font-medium uppercase",children:f("Design Tokens")}),(0,ae.jsx)(E,{onClick:()=>{d("styles"),c("block")},variant:"ghost",size:"icon-xs",className:"text-xs",children:(0,ae.jsx)(dy.Cross1Icon,{className:"h-3 w-3 rtl:ml-2"})})]}):l==="theme"?(0,ae.jsxs)("div",{className:"flex w-full items-center justify-between gap-2",children:[(0,ae.jsx)("div",{className:"flex h-8 items-center space-x-1 truncate text-sm font-medium uppercase",children:f("Theme Settings")}),(0,ae.jsx)(E,{onClick:()=>c("block"),variant:"ghost",size:"icon-xs",className:"text-xs",children:(0,ae.jsx)(dy.Cross1Icon,{className:"h-3 w-3 rtl:ml-2"})})]}):null})})}),(0,ae.jsx)("div",{className:"flex h-full max-h-full w-full",children:(0,ae.jsx)(ro.Suspense,{fallback:(0,ae.jsx)("div",{className:"h-full w-full animate-pulse rounded-md bg-muted/10"}),children:l==="design-tokens"?(0,ae.jsx)(ro.default.Suspense,{fallback:(0,ae.jsx)("div",{className:"h-1/2 w-full animate-pulse"}),children:(0,ae.jsx)(Goe,{})}):l==="theme"?(0,ae.jsx)(gI,{}):(0,ae.jsx)(FG,{})})})]})})]})]})]}),(0,ae.jsx)(mA,{}),e!==null&&(0,Qt.get)(k,"view")==="drawer"&&(0,ae.jsx)(cy,{open:!0,onOpenChange:()=>B(),children:(0,ae.jsxs)(Gg,{side:"left",className:"flex flex-col gap-0 p-0 sm:max-w-full",style:{width:`${w}px`},children:[(0,ae.jsx)($g,{className:"border-b border-border px-2 py-2.5",children:(0,ae.jsxs)(Vg,{className:"flex items-center gap-2",children:[(0,ae.jsx)("span",{className:"inline-block",children:(0,Qt.get)(k,"icon",null)}),(0,ae.jsx)("span",{children:f((0,Qt.get)(k,"label",""))})]})}),(0,ae.jsx)("div",{className:"h-full max-h-full overflow-y-auto p-4",children:(0,ae.jsx)(ro.Suspense,{fallback:(0,ae.jsx)("div",{}),children:ro.default.createElement((0,Qt.get)(k,"panel",kg),{close:T})})})]})})," ",e!==null&&(0,Qt.get)(k,"view")==="modal"&&(0,ae.jsx)(Te,{open:!0,onOpenChange:()=>B(),children:(0,ae.jsxs)(we,{className:"gap-0 p-0",style:{maxWidth:`${w}px`},children:[(0,ae.jsx)(Oe,{className:"border-b border-border px-2 py-3.5",children:(0,ae.jsxs)(Ie,{className:"flex items-center gap-2",children:[(0,ae.jsx)("span",{className:"inline-block",children:(0,Qt.get)(k,"icon",null)}),(0,ae.jsx)("span",{children:f((0,Qt.get)(k,"label",""))})]})}),(0,ae.jsx)("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:(0,ae.jsx)(ro.Suspense,{fallback:(0,ae.jsx)("div",{}),children:ro.default.createElement((0,Qt.get)(k,"panel",kg),{close:T})})})]})}),e!==null&&(0,Qt.get)(k,"view")==="overlay"&&(0,ae.jsx)(mv.motion.div,{className:"absolute bottom-0 left-12 right-0 top-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:(0,ae.jsx)("div",{className:"h-full w-full",children:(0,ae.jsxs)(mv.motion.div,{className:"bg-surface flex h-full w-full flex-col",initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.3,delay:.1},children:[(0,ae.jsxs)("div",{className:"flex h-[50px] items-center justify-between border-b border-border p-4",children:[(0,ae.jsxs)("div",{className:"-ml-2 flex items-center gap-2 text-lg font-bold",children:[(0,ae.jsx)("span",{className:"rtl:ml-2 rtl:inline-block",children:(0,Qt.get)(k,"icon",null)}),(0,ae.jsx)("span",{children:f((0,Qt.get)(k,"label",""))})]}),(0,ae.jsx)(E,{onClick:()=>B(),variant:"ghost",size:"icon",className:"",children:(0,ae.jsx)(dy.Cross1Icon,{className:"h-5 w-5"})})]}),(0,ae.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,ae.jsx)(ro.Suspense,{fallback:(0,ae.jsx)("div",{}),children:ro.default.createElement((0,Qt.get)(k,"panel",kg),{close:T})})})]})})})]})})}});var CP,my,pc,N$,E$,Da,$oe,Voe,kP,yI=x(()=>{"use strict";CP=require("jotai"),my=require("lodash-es"),pc=require("react"),N$=require("react-error-boundary"),E$=require("sonner");Wr();Jn();Oa();pk();J1();AC();v_();k_();dk();U_();V_();ko();q_();f0();Ke();J_();fC();Z_();CC();xN();Yd();Nn();Rr();Ne();T$();Da=require("react/jsx-runtime"),$oe=e=>{let[,t]=Pt(),o=Y_(),[r]=(0,CP.useAtom)(em);(0,CP.useAtom)(kb),Hk(),X_(),j_(),vD(),PC(),ED();let{postMessage:n}=BC(),[,a]=(0,CP.useAtom)(Pb),s=gC();return(0,pc.useEffect)(()=>{be.set(_b,(0,my.omit)(e,["blocks","translations","pageExternalData","globalStyles"]))},[e]),(0,pc.useEffect)(()=>{be.set(FC,e.pageExternalData||{})},[e.pageExternalData]),(0,pc.useEffect)(()=>{be.set(ls,e.designTokens||{})},[e.designTokens]),(0,pc.useEffect)(()=>{a(!1),setTimeout(()=>{let i=hi(e.blocks||[]);t(i),i&&i.length>0&&n({type:"blocks-updated",blocks:i}),o(),a(!0),s()},400)},[e.blocks]),(0,pc.useEffect)(()=>{$b.changeLanguage(e.locale||"en")},[e.locale]),(0,pc.useEffect)(()=>{var i;C_((i=e.debugLogs)!=null?i:!1)},[e.debugLogs]),(0,pc.useEffect)(()=>{e.translations&&(0,my.each)(e.translations,(i,l)=>{$b.addResourceBundle(l,"translation",i,!0,!0)})},[e.translations]),(0,pc.useEffect)(()=>(r!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[r]),null},Voe=e=>{let t=(0,pc.useMemo)(()=>e.layout||P$,[e.layout]),o=q("flags.exportCode",!1);return(0,Da.jsxs)(Da.Fragment,{children:[e.children,(0,Da.jsx)(t,{}),o&&(0,Da.jsx)(H_,{}),(0,Da.jsx)(Br,{slotId:jo.AFTER_BUILDER})]})},kP=e=>{let t=e.onError||my.noop;return(0,Da.jsx)("div",{className:"h-screen w-screen",children:(0,Da.jsxs)(N$.ErrorBoundary,{fallback:(0,Da.jsx)(im,{}),onError:t,children:[(0,Da.jsx)($_,{}),(0,Da.jsx)(Voe,{...e}),(0,Da.jsx)($oe,{...e}),(0,Da.jsx)(Y1,{}),(0,Da.jsx)(E$.Toaster,{richColors:!0}),(0,Da.jsx)(x_,{})]})})}});var bI,A$=x(()=>{"use strict";bI=({baseUrl:e="https://chaibuilder-sdk.vercel.app"}={})=>({name:"Chai Library",description:"",getBlocksList:async t=>{try{let o=await fetch(`${e}/library-blocks/blocks-list.json`);return o.ok?(await o.json()).map(n=>{var a;return{...n,preview:(a=n.preview)!=null&&a.startsWith("http")?n.preview:`${e}${n.preview}`}}):(console.error("Failed to fetch blocks list:",o.status,o.statusText),[])}catch(o){return console.error("Error fetching blocks list:",o),[]}},getBlock:async({block:t})=>{try{let o=await fetch(`${e}/${t.id}.html?raw`);return o.ok?await o.text():(console.error(`Failed to fetch block "${t.id}" from "${e}/${t.id}.html?raw": ${o.status} ${o.statusText}`),`<!-- Error loading block "${t.id}": ${o.status} ${o.statusText} -->`)}catch(o){return console.error(`Error fetching block "${t.id}" from "${e}/${t.id}.html?raw":`,o),`<!-- Error loading block "${t.id}" -->`}}})});var uv,zoe,I$=x(()=>{"use strict";uv=require("lodash-es"),zoe=require("react");ko();Ne();Em()});var gv,zm=x(()=>{"use strict";dk();yI();xw();pn();A$();gv=require("react-i18next");zl();Jb();I$();SE();Tt();CS();Nn();Ge();Ln()});var B$,bd,fv=x(()=>{"use strict";B$=require("jotai"),bd=(0,B$.atom)(null)});var Woe,joe,aa,zg=x(()=>{"use strict";Woe={sidebarButton:"Trash",panelTitle:"Trash",moveToAction:"Move to Trash",restoreAction:"Restore",deleteAction:"Delete Permanently",emptyMessage:"Trash is empty",confirmMoveTitle:"Move to Trash?",confirmDeleteTitle:"Delete Permanently?",panelId:"trash-panel",panelLabel:"Trash",byLabel:"Trashed by",onLabel:"Trashed on",warning:"Trashing"},joe={...Woe},aa=()=>joe});var R$,xd,D$,_$,zn,SP,xI=x(()=>{"use strict";R$=require("lodash-es"),xd=require("lucide-react"),D$=require("react"),_$=require("react-i18next");mn();zg();rt();An();Rr();Sr();tn();zn=require("react/jsx-runtime"),SP=({page:e,setDuplicatePage:t,setAddEditPage:o,setUnpublishPage:r,setDeletePage:n,children:a,isLanguagePage:s})=>{let{t:i}=(0,_$.useTranslation)(),{hasPermission:l}=kt(),c=Nt("flags",{}),{data:d}=Ht(),p=(0,D$.useMemo)(()=>(0,R$.find)(d,{key:e.pageType}),[d,e.pageType]);return!l(xe["pages:update"])&&!l(xe["pages:delete"])&&!l(xe["pages:unpublish"])||!e?null:(0,zn.jsxs)(Yt,{children:[(0,zn.jsx)($t,{asChild:!0,onClick:m=>m.stopPropagation(),children:a}),(0,zn.jsxs)(Vt,{align:"start",className:"text-sm",children:[l(xe["pages:create"])&&!s&&(0,zn.jsxs)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:m=>{m.stopPropagation(),t(e)},children:[(0,zn.jsx)(xd.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),l(xe["pages:update"])&&(0,zn.jsxs)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:m=>{m.stopPropagation(),o({...e,global:!(p!=null&&p.hasSlug)})},children:[(0,zn.jsx)(xd.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&l(xe["pages:unpublish"])&&(0,zn.jsxs)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:m=>{m.stopPropagation(),r(e)},children:[(0,zn.jsx)(xd.Power,{className:"size-3"}),i("Unpublish")]}),l(xe["pages:delete"])&&(0,zn.jsx)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:m=>{m.stopPropagation(),n(e)},children:c!=null&&c.trash?(0,zn.jsxs)(zn.Fragment,{children:[(0,zn.jsx)(xd.Archive,{className:"size-3"}),i(aa().sidebarButton)]}):(0,zn.jsxs)(zn.Fragment,{children:[(0,zn.jsx)(xd.Trash,{className:"size-3"}),i("Delete")]})}),(0,zn.jsx)(Br,{slotId:jo.AFTER_PAGE_MORE_OPTIONS,context:{page:e}})]})]})}});var uy,qoe,L$,M$=x(()=>{"use strict";Oo();uy=require("react/jsx-runtime"),qoe=({hasDynamicPage:e,isLangMissing:t=!1})=>(0,uy.jsx)(Pn,{children:(0,uy.jsxs)("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-surface p-4 shadow-lg",children:[(0,uy.jsx)("h1",{className:"text-lg font-medium",children:t?"Language content missing":e?"Select a page":"No pages found"}),(0,uy.jsx)("p",{className:"pt-2 text-center text-sm font-light text-muted-foreground",children:t?"No translated version found for the selected page. Choose a different page or create content in your CMS.":e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),L$=qoe});function O$({value:e,onChange:t,placeholder:o="Enter custom slug part",dynamicPattern:r,onValidationChange:n}){let[a,s]=(0,jg.useState)(null),i=(0,jg.useRef)(null),[l,c]=(0,jg.useState)(r+e);(0,jg.useEffect)(()=>{c(r+e)},[e,r]);let d=m=>{let g=m.target.value;if(!g.startsWith(r)){let w=g.replace(r,""),N=r+w;c(N),t(w);return}let f=g.substring(r.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),b=(f.match(/\./g)||[]).length,y=b<=1;b>1?s("Invalid slug. Only one dot (.) is allowed in the slug"):s(null),n&&n(y);let k=r+f;c(k),t(f)},p=()=>{if(i.current){let m=i.current;setTimeout(()=>{let g=r.length;m.setSelectionRange(g,g)},0)}},u=m=>{let g=m.currentTarget;(g.selectionStart||0)<=r.length&&setTimeout(()=>{let f=r.length;g.setSelectionRange(f,f)},0)};return(0,Wg.jsx)("div",{children:(0,Wg.jsxs)("div",{className:"relative",children:[(0,Wg.jsxs)("p",{className:"mb-2 text-xs text-gray-500",children:[`${r}`," is a dynamic segment of slug"]}),(0,Wg.jsx)(Ce,{ref:i,value:l,onChange:d,onFocus:p,onClick:u,placeholder:o,className:a?"border-red-500":""}),a&&(0,Wg.jsx)("div",{className:"mt-1 text-xs text-red-500",children:a})]})})}var jg,Wg,F$=x(()=>{"use strict";"use client";jg=require("react");fo();Wg=require("react/jsx-runtime")});function H$(e,t){let o=(e||"").split("/").filter(Boolean),r="",n=!0;if(t.slug==="/"){let a=o.pop()||"";if(Wa[a])n=!0;else{r=a;let s=o.pop()||"";n=!!Wa[s]}}else if(t.parent)o.length&&(r=o.pop()||"");else if(o.length){r=o.pop()||"";let a=o.pop()||"";n=!!Wa[a]}return{initSlug:r,prefix:n}}var Koe,_p,U$,vI,hv=x(()=>{"use strict";yp();Koe=e=>{if(!e)return{base:e,extension:null};let t=e.lastIndexOf(".");if(t<=0)return{base:e,extension:null};let o=e.substring(t);return{base:e.substring(0,t),extension:o}},_p=e=>{if(!e)return e;let{base:t}=Koe(e);return t};U$=e=>e&&_p(e),vI=(e,t)=>{let o=_p(e||"");return!o||o==="/"?`/${t}`:`${o}/${t}`}});var $$,Yoe,G$,V$=x(()=>{"use strict";jp();$$=require("react/jsx-runtime"),Yoe=({children:e,onWheel:t,...o})=>(0,$$.jsx)(Ji,{...o,onWheel:n=>{try{n.preventDefault();let a=n.currentTarget;a.scrollTop+=n.deltaY}catch(a){n.preventDefault()}t&&t(n)},children:e}),G$=Yoe});function q$({pages:e,selectedParentId:t,onChange:o,className:r,id:n="parentPage"}){let{t:a}=(0,W$.useTranslation)(),[s,i]=(0,gy.useState)(!1),[l,c]=(0,gy.useState)("");Of("enable-add-page-dropdown")||(r="flex h-8 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-xs text-foreground shadow-sm ring-offset-surface focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1");let p=(0,gy.useMemo)(()=>!e||e.length===0?[]:e.filter(b=>!(0,z$.isEmpty)(b.slug)).filter(b=>b.slug!=="/").sort((b,y)=>b.slug.localeCompare(y.slug)),[e]),u=(0,gy.useMemo)(()=>{if(!l.trim())return p;let f=l.toLowerCase();return p.filter(b=>b.name.toLowerCase().includes(f)||b.slug.toLowerCase().includes(f))},[p,l]),m=f=>Math.max(0,(f.match(/\//g)||[]).length-1),g=f=>{if(f==="/")return"/";let b=f.split("/").filter(Boolean);return b.length===0?"":_p(b[b.length-1])},h=()=>{if(!t||t==="none")return a("None");let f=p.find(b=>b.id===t);return f?`${f.name} (${g(f.slug)})`:a("None")};return(0,Io.jsxs)("div",{className:"space-y-0.5",children:[(0,Io.jsx)(Q,{htmlFor:n,children:"Parent"}),(0,Io.jsxs)(Te,{open:s,onOpenChange:i,children:[(0,Io.jsx)(pf,{asChild:!0,children:(0,Io.jsxs)(E,{id:n,variant:"outline",role:"combobox",className:wP("w-full justify-between !bg-transparent font-normal hover:bg-transparent",r),"data-testid":"parent-page-selector",children:[h(),(0,Io.jsx)(j$.ChevronDownIcon,{className:"h-4 w-4 opacity-50"})]})}),(0,Io.jsxs)(we,{className:"flex max-h-[70vh] min-h-[500px] flex-col gap-0 overflow-hidden border p-0 sm:max-w-[425px]",children:[(0,Io.jsx)(Oe,{className:"border-b border-border px-2 py-3.5",children:(0,Io.jsx)(Ie,{className:"flex items-center gap-2 text-sm font-normal",children:a("Select parent page")})}),(0,Io.jsxs)(Yi,{shouldFilter:!1,className:"flex max-h-full w-full flex-1 flex-col",children:[(0,Io.jsx)("div",{className:"border-b p-2",children:(0,Io.jsx)(Yr,{value:l,setValue:c,placeholder:a("Search page..."),autoFocus:!0})}),(0,Io.jsxs)(G$,{className:"h-full flex-1 overflow-y-auto p-1",children:[(0,Io.jsx)(Ml,{className:"flex min-h-[300px] items-center justify-center py-6 text-center text-xs text-muted-foreground",children:"No pages found."}),(0,Io.jsxs)("div",{className:"flex flex-col",children:[t&&t!=="none"&&(!l||"none".includes(l.toLowerCase()))&&(0,Io.jsxs)(as,{value:"none",onSelect:()=>{o("none"),i(!1),c("")},style:{paddingLeft:"12px"},className:"relative flex min-h-[28px] cursor-pointer items-center justify-start overflow-hidden whitespace-nowrap rounded py-0 pr-2 border-b border-border/40 bg-muted/10 text-muted-foreground",children:[(0,Io.jsx)("div",{className:"relative z-10 mr-2 flex flex-1 items-center overflow-hidden text-[10px] font-medium",children:a("Select none")}),(0,Io.jsx)(CI.Check,{className:wP("ml-auto h-4 w-4 shrink-0",!t||t==="none"?"opacity-100":"opacity-0")})]}),u.map(f=>{let b=m(f.slug),y=g(f.slug),k=b*14+12;return(0,Io.jsxs)(as,{value:f.id,onSelect:()=>{o(f.id),i(!1),c("")},style:{paddingLeft:`${k}px`},className:"relative flex min-h-[28px] cursor-pointer items-center justify-start overflow-hidden whitespace-nowrap rounded py-0 pr-2",children:[!l&&(0,Io.jsx)("div",{className:"pointer-events-none absolute inset-0",children:Array.from({length:b}).map((w,N)=>{let I=N===b-1,C=N*14+14;return(0,Io.jsxs)("div",{children:[(0,Io.jsx)("div",{className:wP("absolute border-l border-border/50",I?"top-0 h-1/2":"top-0 h-full"),style:{left:`${C}px`}}),I&&(0,Io.jsx)("div",{className:"absolute top-1/2 border-t border-border/50",style:{left:`${C}px`,width:"10px"}})]},N)})}),(0,Io.jsx)(Ye,{content:(0,Io.jsxs)("span",{children:[f.name," ",(0,Io.jsxs)("i",{className:"text-gray-500",children:["(",f.slug,")"]})]}),side:"right",delayDuration:400,className:"max-w-[300px] break-words text-xs",children:(0,Io.jsxs)("div",{className:"relative z-10 mr-2 flex flex-1 items-center overflow-hidden text-[10px]",children:[(0,Io.jsx)("span",{className:"truncate",children:f.name}),(0,Io.jsxs)("span",{className:"ml-1 shrink-0 truncate font-extralight text-muted-foreground",children:["(",y,")"]})]})}),(0,Io.jsx)(CI.Check,{className:wP("ml-auto h-4 w-4 shrink-0",t===f.id?"opacity-100":"opacity-0")})]},f.id)})]})]})]})]})]})]})}var z$,CI,gy,W$,j$,Io,wP,K$=x(()=>{"use strict";"use client";z$=require("lodash-es"),CI=require("lucide-react"),gy=require("react");hl();hv();Rr();J();jp();ea();No();qt();V$();W$=require("react-i18next"),j$=require("@radix-ui/react-icons"),Io=require("react/jsx-runtime"),wP=(...e)=>e.filter(Boolean).join(" ")});function fy({value:e,onChange:t,placeholder:o,parentSlug:r,onValidationChange:n,disabled:a=!1,fullSlug:s}){let[i,l]=(0,yv.useState)(e),[c,d]=(0,yv.useState)(null);(0,yv.useEffect)(()=>{l(e)},[e]);let p=u=>{let g=u.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),h=(g.match(/\./g)||[]).length,f=h<=1;h>1?d("Invalid slug. Only one dot (.) is allowed in the slug"):d(null),n&&n(f),l(g),t(g)};return(0,Sl.jsxs)("div",{children:[r&&(0,Sl.jsx)("div",{className:"mb-1 flex items-center",children:(0,Sl.jsxs)("span",{className:"text-xs text-muted/70",children:["Parent: ",(0,Sl.jsx)("span",{className:"font-mono text-foreground/70",children:U$(r)})]})}),(0,Sl.jsxs)("div",{className:"relative",children:[(0,Sl.jsx)(Ce,{disabled:a,value:i,onChange:p,placeholder:o,className:c?"border-destructive":""}),c&&(0,Sl.jsx)("div",{className:"mt-1 text-xs text-destructive",children:c})]}),s&&s!=="undefined"&&(0,Sl.jsx)("div",{className:"mt-1 flex items-center",children:(0,Sl.jsxs)("span",{className:"text-xs text-muted/70",children:["Complete Slug: ",(0,Sl.jsx)("span",{className:"font-mono text-foreground/70",children:s})]})})]})}var yv,Sl,PP=x(()=>{"use strict";"use client";yv=require("react");hv();fo();Sl=require("react/jsx-runtime")});var Y$,J$=x(()=>{"use strict";Y$={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."}});var TP,kI=x(()=>{"use strict";zu();TP=()=>{var t,o;let[e]=el();return(o=(t=e==null?void 0:e.flags)==null?void 0:t.revisions)!=null?o:!1}});var Qa,vd,ks,hy,yy,by,Q$,X$,NP,Z$,eV,tV,wl=x(()=>{"use strict";Qa=require("@tanstack/react-query"),vd=require("lodash-es"),ks=require("sonner");Ob();Nn();St();J$();er();rt();An();kI();Kt();zu();hy=(e,t)=>e?e.hasSlug?"page":typeof e.name=="string"?e.name:t:t,yy=()=>{let e=le(),t=(0,Qa.useQueryClient)(),o=he(),{data:r}=Ht();return(0,Qa.useMutation)({mutationFn:async n=>await o(e,{action:$.CREATE_PAGE,data:n}),onSuccess:(n,a)=>{a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[$.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),t.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"});let s=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+hy((0,vd.find)(r,{key:a.pageType}),"item")+" added successfully":"New page added successfully";ks.toast.success(s)},onError:(n,a)=>{let s=(0,vd.find)(r,{key:a.pageType});ks.toast.error(`Failed to add new ${hy(s,"item")}.`,{description:(0,vd.get)(Y$,n.message,n.message)})}})},by=()=>{let e=le(),t=(0,Qa.useQueryClient)(),o=he(),{data:r}=dr(),{data:n}=Ht(),[a]=el();return(0,Qa.useMutation)({mutationFn:async s=>await o(e,{action:$.UPDATE_PAGE,data:{...s||{},addInRevision:(0,vd.get)(a,"flags.draftsInRevisions",!1)}}),onSuccess:(s,i)=>{(r==null?void 0:r.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[$.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[$.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),t.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"})},onError:(s,i)=>{let l=(0,vd.find)(n,{key:i.pageType});ks.toast.error(`Failed to update ${hy(l,"page")}.`,{description:s.message})}})},Q$=()=>{let e=le(),t=(0,Qa.useQueryClient)(),o=he(),{data:r}=Ht(),n=Nt("flags",{});return(0,Qa.useMutation)({mutationFn:async a=>{let s=n!=null&&n.trash?$.TRASH_ENTITY:$.DELETE_PAGE,i=n!=null&&n.trash?{entityType:"page",ids:[a==null?void 0:a.id]}:{id:a==null?void 0:a.id};return o(e,{action:s,data:i})},onSuccess:(a,s)=>{if((a==null?void 0:a.code)==="PAGE_LOCKED"){ks.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}s&&(s!=null&&s.primaryPage)?(t.invalidateQueries({queryKey:[$.GET_LANGUAGE_PAGES,s==null?void 0:s.primaryPage]}),t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),t.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"})},onError:(a,s)=>{let i=(0,vd.find)(r,{key:s.pageType});ks.toast.error(`Failed to delete ${hy(i,"page")}.`,{description:a.message})}})},X$=()=>{let e=le(),t=he(),{data:o}=Ht(),{handleQuerySync:r}=Gd();return(0,Qa.useMutation)({mutationFn:async n=>t(e,{action:$.TAKE_OFFLINE,data:{id:n==null?void 0:n.id}}),onSuccess:(n,a)=>{r({type:"UNPUBLISH_PAGE",data:{pageId:a==null?void 0:a.id,primaryPage:a==null?void 0:a.primaryPage},sync:!0});let s=(0,vd.find)(o,{key:a.pageType});ks.toast.success(s!=null&&s.hasSlug?"Page unpublished successfully.":"New "+hy(s,"item")+" added successfully.")},onError:(n,a)=>{let s=(0,vd.find)(o,{key:a.pageType});ks.toast.error(`Failed to take offline ${hy(s,"page")}.`,{description:n.message})}})},NP=()=>{let e=le(),t=he(),{savePageAsync:o}=to(),r=TP(),{handleQuerySync:n}=Gd();return(0,Qa.useMutation)({mutationFn:async({ids:a})=>(await o(),t(e,{action:$.PUBLISH_CHANGES,data:{ids:a,revisions:r}})),onSuccess:(a,{ids:s})=>{n({type:"PUBLISH_CHANGES",data:{ids:s},sync:!0})},onError:a=>{console.log(a),ks.toast.error("Failed to publish pages.")}})},Z$=()=>{let e=le(),t=he(),o=(0,Qa.useQueryClient)();return(0,Qa.useMutation)({mutationFn:async r=>{var n;return t(e,{action:$.MARK_AS_TEMPLATE,data:{id:(n=r.page)==null?void 0:n.id,name:r.name,description:r.description,pageType:r.pageType,previewImage:r.previewImage}})},onSuccess:()=>{o.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),ks.toast.success("Page marked as template successfully.")},onError:()=>{ks.toast.error("Failed to mark page as template.")}})},eV=()=>{let e=le(),t=he(),o=(0,Qa.useQueryClient)();return(0,Qa.useMutation)({mutationFn:async r=>t(e,{action:$.UNMARK_AS_TEMPLATE,data:{id:r==null?void 0:r.id}}),onSuccess:()=>{o.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),ks.toast.success("Page unmarked as template successfully.")},onError:()=>{ks.toast.error("Failed to unmark page as template.")}})},tV=()=>{let e=le(),t=he(),o=(0,Qa.useQueryClient)();return(0,Qa.useMutation)({mutationFn:async({id:r,slug:n})=>t(e,{action:$.CHANGE_SLUG,data:{id:r,slug:n}}),onSuccess:(r,{primaryPage:n})=>{ks.toast.success("Slug changed successfully."),n?o.invalidateQueries({queryKey:[$.GET_LANGUAGE_PAGES,n]}):o.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),o.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"})},onError:()=>{ks.toast.error("Failed to change slug")}})}});var Oi,qg,SI=x(()=>{"use strict";Oi=require("lodash-es"),qg=(e,t)=>{let o={seo:{keyword:"",title:"",description:"",noIndex:!1,noFollow:!1,canonicalUrl:"",ogTitle:"",ogDescription:"",jsonLD:"",metaOther:""},jsonLD:{},metaOther:{}};e!=null&&e.defaultSeo&&((0,Oi.has)(e.defaultSeo,t)&&(0,Oi.isObject)(e.defaultSeo[t])?o.seo={...o.seo,...e.defaultSeo[t]}:o.seo={...o.seo,...e.defaultSeo});let r={};e!=null&&e.defaultJSONLD&&((0,Oi.has)(e.defaultJSONLD,t)&&(0,Oi.isObject)(e.defaultJSONLD[t])?(r=e.defaultJSONLD[t],(0,Oi.set)(o,"seo.jsonLD",JSON.stringify(r))):(r=e.defaultJSONLD,(0,Oi.set)(o,"seo.jsonLD",JSON.stringify(r))));let n={};return e!=null&&e.defaultMetaTags&&((0,Oi.has)(e.defaultMetaTags,t)&&(0,Oi.isObject)(e.defaultMetaTags[t])?(n=e.defaultMetaTags[t],(0,Oi.set)(o,"seo.metaOther",JSON.stringify(n))):(n=e.defaultMetaTags,(0,Oi.set)(o,"seo.metaOther",JSON.stringify(n)))),{seo:o.seo,jsonLD:o.jsonLD,metaOther:n}}});var rV={};et(rV,{default:()=>oV});function oV({addEditPage:e,close:t,closePanel:o}){var uR,gR,fR,hR,yR,bR,xR,vR,CR;let{data:r}=Ht(),n=(0,Hr.useMemo)(()=>r!=null?r:[],[r]),a=Bf(),s=!!(e!=null&&e.id),{data:i}=on(),{mutate:l,isPending:c}=yy(),{mutate:d,isPending:p}=by(),[u,m]=(0,Hr.useState)(null),[g,h]=(0,Hr.useState)(!0),[f,b]=(0,Hr.useState)((uR=e==null?void 0:e.pageType)!=null?uR:"page"),{hasPermission:y}=kt(),k=y(xe["pages:change_type"]),[w,N]=(0,Hr.useState)(!1),[I,C]=(0,Hr.useState)(""),{selectedLang:P,fallbackLang:B}=fe(),T=P||B,[v,S]=(0,Hr.useState)((gR=e==null?void 0:e.parent)!=null?gR:""),[A,D]=(0,Hr.useState)((fR=e==null?void 0:e.name)!=null?fR:""),[R,H]=(0,Hr.useState)(typeof((hR=e==null?void 0:e.metadata)==null?void 0:hR.description)=="string"?(yR=e==null?void 0:e.metadata)==null?void 0:yR.description:""),[M,L]=(0,Hr.useState)((bR=e==null?void 0:e.dynamic)!=null?bR:!1),[z,_]=(0,Hr.useState)(M?"":((xR=e==null?void 0:e.slug)!=null?xR:"").split("/").pop()||""),[F,O]=(0,Hr.useState)((vR=e==null?void 0:e.dynamicSlugCustom)!=null?vR:""),[U,j]=(0,Hr.useState)(!0),[ce,pe]=(0,Hr.useState)(!1),[ve,Ve]=(0,Hr.useState)(""),ze=c||p,bt=(0,Hr.useMemo)(()=>!s||!(e!=null&&e.id)||!i?null:i.find(Ue=>Ue.id===e.id),[s,e,i]),W=(bt==null?void 0:bt.online)||!1,ie=(0,Hr.useMemo)(()=>!s||!(e!=null&&e.id)||!i?!1:i.some(Ue=>Ue.parent===e.id),[s,e,i]),Y=n.find(Ue=>Ue.key===f),Ze=Ue=>{if(s&&f!==Ue){C(Ue),N(!0);return}b(Ue)},te=()=>{b(I),N(!1),L(!1)},Qe=Ue=>{L(Ue),Ue?_(""):O("")},Z=Ue=>{if(S(Ue),Ue&&Ue!=="none"){let vo=i==null?void 0:i.find(Bs=>Bs.id===Ue),Rl=(vo==null?void 0:vo.slug)||"";if(z.startsWith(Rl)){let Bs=z.slice(Rl.length).replace(/^\/+/,"");_(Bs)}else _(z.replace(/^\/+/,""))}else _(z?`${z}`:"")},ge=()=>A.trim()?M&&!(0,Pl.isEmpty)(z)?(m("Slug must be empty when using dynamic slug"),!1):M&&!U?(m("Dynamic slug is invalid"),!1):!0:(bv.toast.error("Name is required"),!1),Rt=()=>{let Ue={pageType:Y==null?void 0:Y.key,name:A,slug:"",hasSlug:!1,description:R};s?d({id:e==null?void 0:e.id,name:A,description:R},{onSuccess:()=>{bv.toast.success((Y==null?void 0:Y.name)+" updated successfully"),t()}}):l(Ue,{onSuccess:vo=>{t(),a(vo.page.id,o)}})},sr=(Ue,vo)=>{if(!Ue.trim()&&!M)return m("Child page slug is required"),!1;let Rl=_p(vo),Bs=vI(Rl,Ue);return Object.keys(Jt).some(rC=>Bs===`/${rC}`||(Bs==null?void 0:Bs.startsWith(`/${rC}/`)))?(m("Slugs cannot start with a language code for primary page"),!1):!0},ir=(Ue,vo)=>{let Rl=_p(vo),Bs=vI(Rl,Ue),qi={pageType:f,name:A,slug:Bs.replace(/\/$/,""),parent:v,dynamic:M,hasSlug:!0,template:ve||void 0,tracking:{},seo:{},jsonLD:{}};if(M&&(qi.dynamicSlugCustom=F),s){let Dl=(0,Pl.pick)(qi,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);d({id:e==null?void 0:e.id,...Dl},{onSuccess:()=>{bv.toast.success("Page updated successfully"),t()}})}else{let Dl=(0,Pl.find)(n,{key:f});Dl!=null&&Dl.trackingDefault&&(qi.tracking=Dl.trackingDefault);let{seo:rC,jsonLD:FY}=qg(Dl,T);(0,Pl.set)(qi,"seo",rC),(0,Pl.set)(qi,"jsonLD",FY),l(qi,{onSuccess:HY=>{t(),a(HY.page.id,o)}})}},ue=()=>{let Ue={pageType:f,name:A,slug:z===""?"/":`/${z.replace(/\/$/,"")}`,template:ve||void 0,parent:null,tracking:{}};if(s)d({id:e==null?void 0:e.id,...Ue},{onSuccess:()=>{bv.toast.success("Page updated successfully"),t()}});else{let vo=(0,Pl.find)(n,{key:f});vo!=null&&vo.trackingDefault&&(Ue.tracking=vo.trackingDefault);let{seo:Rl,jsonLD:Bs}=qg(vo,T);(0,Pl.set)(Ue,"seo",Rl),(0,Pl.set)(Ue,"jsonLD",Bs),l(Ue,{onSuccess:qi=>{var Dl;(Dl=qi==null?void 0:qi.page)!=null&&Dl.id&&a(qi.page.id,o),t()}})}},We=Ue=>{if(Ue.preventDefault(),m(null),!!ge()){if(!(Y!=null&&Y.hasSlug)){Rt();return}if(v&&v!=="none"){let vo=i==null?void 0:i.find(Bs=>Bs.id===v),Rl=(vo==null?void 0:vo.slug)||"";if(!sr(z,Rl))return;ir(z,Rl)}else ue()}},Zo=(0,Hr.useMemo)(()=>n.filter(Ue=>Ue.hasSlug===!1),[n]),Ir=(0,Hr.useMemo)(()=>n.filter(Ue=>Ue.hasSlug!==!1),[n]);(0,Hr.useEffect)(()=>{!s&&Ir.length===1&&f!==Ir[0].key&&(0,Hr.startTransition)(()=>b(Ir[0].key))},[s,Ir,f]);let pi=Ir.length>1;if(!(Y!=null&&Y.hasSlug)){let Ue=Zo.length>1;return(0,Ae.jsxs)("form",{onSubmit:We,className:"mx-auto w-full max-w-md space-y-4",children:[Ue&&(0,Ae.jsxs)("div",{className:"space-y-0.5",children:[(0,Ae.jsx)(Q,{htmlFor:"pageType",children:"Type"}),(0,Ae.jsxs)(So,{value:f,disabled:s&&!k,onValueChange:Ze,children:[(0,Ae.jsx)(ho,{className:"w-full",children:(0,Ae.jsx)(Do,{placeholder:"Select partial type"})}),(0,Ae.jsx)(yo,{children:(0,Ae.jsxs)(ed,{children:[(0,Ae.jsx)(ql,{children:"Partials"}),Zo.map(vo=>(0,Ae.jsx)(gt,{value:vo.key,children:vo.name},vo.key))]})})]}),w&&(0,Ae.jsxs)("div",{className:"mt-2 rounded-md border border-foreground/10 bg-surface p-3",children:[(0,Ae.jsx)("p",{className:"text-sm text-orange",children:"Changing the type may impact the data. Are you sure you want to proceed?"}),(0,Ae.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,Ae.jsx)(E,{variant:"outline",size:"sm",onClick:()=>N(!1),children:"Cancel"}),(0,Ae.jsx)(E,{variant:"default",size:"sm",onClick:te,children:"Confirm"})]})]}),(0,Ae.jsx)("p",{className:"text-xs font-extralight italic text-muted-foreground",children:Y==null?void 0:Y.helpText})]}),(0,Ae.jsxs)("div",{className:"space-y-0.5",children:[(0,Ae.jsx)(Q,{htmlFor:"name",children:"Name"}),(0,Ae.jsx)(Ce,{id:"name",value:A,onChange:vo=>D(vo.target.value),required:!0,"aria-required":"true"})]}),(0,Ae.jsxs)("div",{className:"space-y-0.5",children:[(0,Ae.jsx)(Q,{htmlFor:"description",children:"Description"}),(0,Ae.jsx)(Ro,{id:"description",value:R,onChange:vo=>H(vo.target.value),rows:3,placeholder:"Describe what this partial is for. Used by AI to understand when to use it."})]}),(0,Ae.jsx)(E,{loading:ze,type:"submit",className:"w-full",children:s?"Update "+(Y==null?void 0:Y.name):"Create "+(Y==null?void 0:Y.name)})]})}return(0,Ae.jsxs)("form",{onSubmit:We,className:"mx-auto w-full max-w-md space-y-4",children:[pi&&(0,Ae.jsxs)("div",{className:"space-y-0.5",children:[(0,Ae.jsxs)(So,{value:f,disabled:s&&!k,onValueChange:Ze,children:[(0,Ae.jsx)(ho,{className:"w-full",children:(0,Ae.jsx)(Do,{placeholder:"Select page type"})}),(0,Ae.jsx)(yo,{children:s?Y!=null&&Y.hasSlug?(0,Ae.jsxs)(ed,{children:[(0,Ae.jsx)(ql,{children:"Pages"}),Ir.map(Ue=>(0,Ae.jsx)(gt,{value:Ue.key,children:Ue.name},Ue.key))]}):(0,Ae.jsxs)(ed,{children:[(0,Ae.jsx)(ql,{children:"Partials"}),Zo.map(Ue=>(0,Ae.jsx)(gt,{value:Ue.key,children:Ue.name},Ue.key))]}):(0,Ae.jsxs)(ed,{children:[(0,Ae.jsx)(ql,{children:"Pages"}),Ir.map(Ue=>(0,Ae.jsx)(gt,{value:Ue.key,children:Ue.name},Ue.key))]})})]}),w&&(0,Ae.jsxs)("div",{className:"mt-2 rounded-md border border-foreground/10 bg-surface p-3",children:[(0,Ae.jsx)("p",{className:"text-sm text-foreground",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),(0,Ae.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,Ae.jsx)(E,{variant:"outline",size:"sm",onClick:()=>N(!1),children:"Cancel"}),(0,Ae.jsx)(E,{variant:"default",size:"sm",onClick:te,children:"Confirm"})]})]})]}),(0,Ae.jsxs)("div",{className:"space-y-0.5",children:[(0,Ae.jsx)(Q,{htmlFor:"name",children:"Name"}),(0,Ae.jsx)(Ce,{id:"name",value:A,onChange:Ue=>D(Ue.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(0,Ae.jsx)(q$,{pages:i==null?void 0:i.map(Ue=>{var vo;return{id:Ue.id,name:Ue.name,slug:Ue.slug,parent:(vo=Ue.parent)!=null?vo:void 0}}),selectedParentId:v,onChange:Z,currentPage:e}),(Y==null?void 0:Y.dynamicSegments)&&v&&v!=="none"&&(0,Ae.jsxs)("div",{className:"space-y-2",children:[(0,Ae.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,Ae.jsx)(Ia,{id:"useDynamicSlug",checked:M,onCheckedChange:Ue=>Qe(Ue)}),(0,Ae.jsx)(Q,{htmlFor:"useDynamicSlug",children:"Use Dynamic Slug"})]}),M&&(0,Ae.jsx)("div",{className:"space-y-2",children:(0,Ae.jsx)("div",{className:"space-y-0.5",children:(0,Ae.jsx)(O$,{value:F,onChange:O,dynamicPattern:(Y==null?void 0:Y.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:j})})})]}),(!(Y!=null&&Y.dynamicSegments)||!M)&&(0,Ae.jsxs)("div",{className:"space-y-0.5",children:[(0,Ae.jsx)(Q,{htmlFor:"slug",children:"Slug"}),(0,Ae.jsx)(fy,{value:z,onChange:Ue=>{var vo;_(Ue),s&&Ue!==(((vo=e==null?void 0:e.slug)==null?void 0:vo.split("/").pop())||"")?pe(!!(W||ie)):pe(!1)},placeholder:v&&v!=="none"?"Enter page slug":f==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:v&&v!=="none"?(CR=i==null?void 0:i.find(Ue=>Ue.id===v))==null?void 0:CR.slug:void 0,onValidationChange:h}),u&&(0,Ae.jsx)("p",{className:"text-xs text-red-500",children:u}),ce&&(0,Ae.jsx)("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:(0,Ae.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,Ae.jsx)("div",{className:"flex-shrink-0",children:(0,Ae.jsx)("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,Ae.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),(0,Ae.jsxs)("div",{className:"flex-1",children:[(0,Ae.jsx)("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),(0,Ae.jsx)("div",{className:"mt-1 text-sm text-amber-700",children:(0,Ae.jsx)("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),(0,Ae.jsx)(E,{loading:ze,disabled:ze||!g&&(!(Y!=null&&Y.dynamicSegments)||!M)||M&&!U,type:"submit",className:"w-full",children:s?"Update page":"Create Page"})]})}var Pl,Hr,bv,Ae,nV=x(()=>{"use strict";"use client";Pl=require("lodash-es"),Hr=require("react"),bv=require("sonner");Tt();mn();F$();K$();PP();zs();wl();Ul();An();nk();hv();J();Pg();fo();No();gs();Gs();tn();SI();Ae=require("react/jsx-runtime")});var wI={};et(wI,{default:()=>Xoe});var EP,aV,Cd,Joe,Qoe,Xoe,PI=x(()=>{"use strict";EP=require("react"),aV=require("react-i18next");qt();Cd=require("react/jsx-runtime"),Joe=(0,EP.lazy)(()=>Promise.resolve().then(()=>(nV(),rV))),Qoe=({addEditPage:e,setAddEditPage:t,closePanel:o})=>{let{t:r}=(0,aV.useTranslation)(),n=!!(e!=null&&e.id),a=!!e;return(0,Cd.jsx)(Te,{open:a,onOpenChange:()=>t(void 0),children:a&&(0,Cd.jsxs)(we,{className:"sm:max-w-[425px]",children:[(0,Cd.jsxs)(Oe,{children:[(0,Cd.jsxs)(Ie,{children:[r(n?"Edit":"Add New")," "]}),(0,Cd.jsx)(Dt,{children:r(n?"Update your page name":"Enter details to create a new page")})]}),(0,Cd.jsx)(EP.Suspense,{fallback:(0,Cd.jsx)("div",{className:"min-h-40"}),children:(0,Cd.jsx)(Joe,{closePanel:o,addEditPage:e,close:()=>t(void 0)})})]})})},Xoe=Qoe});function Zoe(e){var o;let t={};for(let r of e)t[r.id]={name:r.name,isPartial:(0,sV.isEmpty)(r.slug),partialBlocks:r.partialBlocks?r.partialBlocks.split("|").filter(Boolean):[],links:r.links?r.links.split("|").filter(Boolean):[],designTokens:(o=r.designTokens)!=null?o:{}};return t}var sV,iV,AP,TI=x(()=>{"use strict";sV=require("lodash-es"),iV=require("react");lS();AP=()=>{let{data:e}=on();return{data:(0,iV.useMemo)(()=>Zoe(e!=null?e:[]),[e])}}});var BP={};et(BP,{default:()=>tre});function ere({page:e,onClose:t}){var k;let{t:o}=(0,lV.useTranslation)(),[,r]=Go(),{mutate:n,isPending:a}=Q$(),{data:s=[]}=on(),{setSelectedLang:i,fallbackLang:l}=fe(),[,c]=ma(),d=!(e!=null&&e.primaryPage),{data:p=[]}=gn(d?e==null?void 0:e.id:void 0),{data:u}=AP(),m=Nt("flags",{}),g=(0,xv.useMemo)(()=>(0,IP.isEmpty)(e==null?void 0:e.slug),[e==null?void 0:e.slug]),h=(0,xv.useMemo)(()=>{if(!g||!(e!=null&&e.id)||!u)return[];let w=[];return Object.entries(u).forEach(([N,I])=>{I.partialBlocks.includes(e.id)&&!I.isPartial&&w.push({id:N,name:I.name})}),w},[g,e.id,u]),f=(0,xv.useMemo)(()=>!d||!p?0:p.filter(w=>w.id!==e.id).length,[d,p,e.id]),b=(0,xv.useMemo)(()=>{if(!(e!=null&&e.id)||!s.length)return 0;let w=NI(e.id,s);return d&&p&&p.length>0&&p.forEach(N=>{N.id!==e.id&&(w+=NI(N.id,s))}),w},[e.id,s,d,p]),y=()=>{a||n(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),r(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"",window.location.pathname),r(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),i(l),c("outline"),t()}})};return(0,Ur.jsx)(Te,{open:!!e,onOpenChange:t,children:(0,Ur.jsxs)(we,{children:[(0,Ur.jsx)(Oe,{children:(0,Ur.jsx)(Ie,{children:m!=null&&m.trash?o(aa().confirmMoveTitle):o("Delete Page")})}),(0,Ur.jsxs)("div",{className:"rounded-md",children:[(0,Ur.jsxs)("div",{className:"mb-2 text-sm font-light text-foreground/90",children:[m!=null&&m.trash?o("Are you sure you want to move"):o("Are you sure you want to delete")," ",(0,Ur.jsx)("b",{children:(k=e==null?void 0:e.name)!=null?k:e==null?void 0:e.slug})," ",m!=null&&m.trash?o("to archive?"):o("? This action cannot be undone.")]}),d&&(f>0||b>0)&&(0,Ur.jsxs)("div",{className:"mt-3 rounded-md border p-3 text-sm",children:[(0,Ur.jsxs)("div",{className:"font-semibold text-destructive",children:[o(`Warning: ${m!=null&&m.trash?aa().warning:"Deleting"} this primary page will also remove`),":"]}),(0,Ur.jsxs)("ul",{className:"mt-2 list-inside list-disc space-y-1 text-destructive",children:[b>0&&(0,Ur.jsxs)("li",{children:[(0,Ur.jsx)("span",{className:"font-medium",children:b})," ",o(b===1?"nested child page":"nested child pages")]}),f>0&&(0,Ur.jsx)("li",{children:o("All associated language pages")})]})]}),g&&h.length>0&&(0,Ur.jsxs)("div",{className:"mt-3 rounded-md bg-destructive/10 p-3 text-sm",children:[(0,Ur.jsxs)("div",{className:"font-semibold text-destructive",children:[o("Warning: This partial is currently used in the following pages"),":"]}),(0,Ur.jsx)("ul",{className:"mt-2 list-inside list-disc space-y-1 text-destructive",children:h.map(({id:w,name:N})=>(0,Ur.jsx)("li",{children:(0,Ur.jsx)("span",{className:"font-medium",children:N})},w))})]}),e.lang&&(0,Ur.jsxs)("div",{className:"py-2 text-sm font-light text-foreground",children:[o("Language"),": ",(0,Ur.jsx)("span",{className:"font-medium",children:(0,IP.get)(Jt,e.lang,e.lang)})]})]}),(0,Ur.jsxs)(co,{children:[(0,Ur.jsx)(E,{variant:"outline",onClick:t,disabled:a,children:o("Cancel")}),(0,Ur.jsx)(E,{loading:a,variant:"destructive",onClick:y,children:m!=null&&m.trash?o(aa().moveToAction):o("Delete")})]})]})})}var IP,xv,lV,Ur,NI,tre,RP=x(()=>{"use strict";IP=require("lodash-es"),xv=require("react"),lV=require("react-i18next");Tt();Zc();zs();zg();wl();Gc();Ul();rt();TI();cs();J();qt();Ur=require("react/jsx-runtime"),NI=(e,t)=>{let o=t.filter(n=>n.parent===e);if(o.length===0)return 0;let r=o.length;return o.forEach(n=>{r+=NI(n.id,t)}),r};tre=ere});var DP,EI,cV,dV=x(()=>{"use strict";DP=require("@tanstack/react-query"),EI=require("sonner");St();rt();Kt();cV=()=>{let e=le(),t=(0,DP.useQueryClient)(),o=he();return(0,DP.useMutation)({mutationFn:async({pageId:r,name:n,slug:a})=>{let s={pageId:r,name:n};return a&&(s.slug=a),await o(e,{action:"DUPLICATE_PAGE",data:s})},onSuccess:()=>{t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),t.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"}),EI.toast.success("Page duplicated successfully")},onError:r=>{EI.toast.error("Failed to duplicate page",{description:r.message||"An error occurred while duplicating the page"})}})}});var AI={};et(AI,{default:()=>rre});var _P,pV,vv,mV,Po,ore,rre,II=x(()=>{"use strict";_P=require("lodash-es"),pV=require("lucide-react"),vv=require("react"),mV=require("react-i18next");dV();nk();J();qt();fo();No();PP();Po=require("react/jsx-runtime"),ore=({page:e,onClose:t,closePanel:o=()=>{}})=>{let{t:r}=(0,mV.useTranslation)(),{mutate:n,isPending:a}=cV(),[s,i]=(0,vv.useState)(null),[l,c]=(0,vv.useState)(`${e.name} (Copy)`),d=Bf(),p=(0,_P.isEmpty)(e.slug),[u,m]=(0,vv.useState)(p?"":`${e.slug.split("/").pop()}-copy`),g=p?"":(0,_P.initial)(e.slug.split("/")).join("/"),[h,f]=(0,vv.useState)(!1),b=y=>{if(y.preventDefault(),!l.trim()){i(r("Name is required"));return}if(!p&&!u.trim()){i(r("Slug is required"));return}i(null),f(!0);let k={pageId:e.id,name:l};p||(k.slug=`${g}/${u}`),n(k,{onSuccess:w=>{f(!1),t(),d(w.id,o)},onError:w=>{f(!1),w.code==="SLUG_EXISTS"?i(r("A page with this slug already exists. Please choose a different slug.")):w.code==="INVALID_SLUG"?i(r("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):w.code==="PERMISSION_DENIED"?i(r("You don't have permission to duplicate this page.")):i(w.message||r("Failed to duplicate page. Please try again later."))}})};return(0,Po.jsx)(Te,{open:!!e,onOpenChange:t,children:(0,Po.jsxs)(we,{className:"sm:max-w-[425px]",children:[(0,Po.jsxs)(Oe,{children:[(0,Po.jsx)(Ie,{children:r("Duplicate Page")}),(0,Po.jsx)(Dt,{children:r("Create a copy of the page with a new name and slug")})]}),(0,Po.jsxs)("div",{className:"space-y-3 rounded-lg border bg-gradient-to-br from-accent/50 to-accent/30 px-3 py-2 shadow-sm",children:[(0,Po.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Po.jsx)("div",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-primary/10",children:(0,Po.jsx)(pV.File,{className:"h-3 w-3 text-primary"})}),(0,Po.jsx)("div",{className:"text-xs text-foreground",children:r("Current Page Details")})]}),(0,Po.jsxs)("div",{className:"space-y-2",children:[(0,Po.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Po.jsxs)("span",{className:"min-w-[45px] text-xs font-medium text-muted-foreground",children:[r("Name"),":"]}),(0,Po.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground",children:e.name})]}),!p&&(0,Po.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Po.jsxs)("span",{className:"min-w-[45px] text-xs font-medium text-muted-foreground",children:[r("Slug"),":"]}),(0,Po.jsx)("code",{className:"flex-1 font-mono text-xs text-foreground",children:e.slug})]}),(0,Po.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Po.jsxs)("span",{className:"min-w-[45px] text-xs font-medium text-muted-foreground",children:[r("Type"),":"]}),(0,Po.jsx)("span",{className:"inline-flex items-center rounded-full text-xs text-foreground",children:e.pageType})]})]})]}),(0,Po.jsxs)("form",{onSubmit:b,className:"space-y-4",children:[(0,Po.jsxs)("div",{className:"space-y-1",children:[(0,Po.jsx)(Q,{htmlFor:"name",children:r("Name")}),(0,Po.jsx)(Ce,{id:"name",value:l,onChange:y=>c(y.target.value),required:!0})]}),!p&&(0,Po.jsxs)("div",{className:"space-y-`",children:[(0,Po.jsx)(Q,{htmlFor:"slug",children:r("Slug")}),(0,Po.jsx)(fy,{value:u,onChange:y=>m(y),parentSlug:g,onValidationChange:y=>{i(y?null:r("Invalid slug"))}})]}),s&&(0,Po.jsx)("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:s}),(0,Po.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,Po.jsx)(E,{type:"button",variant:"outline",onClick:t,disabled:a,children:r("Cancel")}),(0,Po.jsx)(E,{loading:a||h,type:"submit",disabled:!l.trim()||!p&&!u.trim(),children:r("Duplicate")})]})]})]})})},rre=ore});var DI={};et(DI,{default:()=>sre});var BI,pu,Lp,uV,RI,Wt,nre,are,sre,_I=x(()=>{"use strict";BI=require("lodash-es"),pu=require("lucide-react"),Lp=require("react"),uV=require("react-i18next"),RI=require("sonner");Us();wl();An();J();qt();fo();No();gs();Wt=require("react/jsx-runtime"),nre=1*1024*1024,are=({page:e,onClose:t})=>{let{t:o}=(0,uV.useTranslation)(),[r,n]=(0,Lp.useState)(!1),[a,s]=(0,Lp.useState)(""),[i,l]=(0,Lp.useState)(""),[c,d]=(0,Lp.useState)(!1),p=(0,Lp.useRef)(null),u=Z$(),{data:m}=Ht(),g=m==null?void 0:m.find(w=>w.key===e.pageType),h=(g==null?void 0:g.name)||(0,BI.startCase)(e.pageType),f=(0,Lp.useCallback)(w=>{var I;let N=(I=w.target.files)==null?void 0:I[0];if(N){if(N.size>nre){RI.toast.error(o("File too large"),{description:`${o("Maximum file size is 1MB. Selected file is")} ${(N.size/1024).toFixed(2)}KB.`}),p.current&&(p.current.value="");return}try{d(!0);let C=new FileReader;C.onloadend=()=>{l(C.result),d(!1)},C.readAsDataURL(N)}catch(C){console.error("Error reading file:",C),d(!1),RI.toast.error(o("Failed to process image"),{description:C instanceof Error?C.message:o("Unknown error")})}}},[o]),b=()=>{l(""),p.current&&(p.current.value="")},y=()=>{var w;(w=p.current)==null||w.click()},k=()=>{n(!0),u.mutate({page:e,name:e.name,description:a.trim()||void 0,pageType:e.pageType,...i?{previewImage:i}:{}},{onSuccess:()=>{n(!1),t()},onError:()=>{n(!1)}})};return(0,Wt.jsx)(Te,{open:!0,onOpenChange:t,children:(0,Wt.jsxs)(we,{children:[(0,Wt.jsxs)(Oe,{children:[(0,Wt.jsx)(Ie,{children:o("Mark as template")}),(0,Wt.jsxs)(Dt,{className:"space-y-1 py-1 text-xs text-muted-foreground",children:[o("Are you sure you want to mark this page as a template?"),(0,Wt.jsx)("br",{}),o("Templates can be used to create new pages with the same content.")]})]}),(0,Wt.jsxs)("div",{className:"mb-4 space-y-4 text-xs",children:[(0,Wt.jsxs)("div",{className:"space-y-3 rounded border bg-muted/50 p-4",children:[(0,Wt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Wt.jsx)(pu.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,Wt.jsxs)("span",{className:"font-medium text-muted-foreground",children:[o("Page Name"),":"]}),(0,Wt.jsx)("span",{className:"font-semibold",children:(0,BI.startCase)(e.name)})]}),(0,Wt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Wt.jsx)(pu.File,{className:"h-4 w-4 text-muted-foreground"}),(0,Wt.jsxs)("span",{className:"font-medium text-muted-foreground",children:[o("Type"),":"]}),(0,Wt.jsx)("span",{className:"font-semibold",children:h})]})]}),(0,Wt.jsxs)("div",{children:[(0,Wt.jsx)(Q,{htmlFor:"description",children:o("Description (Optional)")}),(0,Wt.jsx)(Ro,{id:"description",placeholder:o("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:a,onChange:w=>s(w.target.value)})]}),(0,Wt.jsxs)("div",{className:"space-y-2",children:[(0,Wt.jsx)(Q,{htmlFor:"previewImage",children:o("Preview Image (Optional)")}),(0,Wt.jsxs)("div",{className:"space-y-2",children:[(0,Wt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Wt.jsx)(Ce,{type:"file",id:"previewImage",ref:p,onChange:f,accept:"image/*",className:"hidden"}),(0,Wt.jsx)(E,{type:"button",variant:"outline",onClick:y,disabled:c,className:"w-full",children:c?(0,Wt.jsxs)("span",{className:"flex items-center gap-2",children:[(0,Wt.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),o("Uploading...")]}):(0,Wt.jsxs)("span",{className:"flex items-center gap-2",children:[(0,Wt.jsx)(pu.ImageIcon,{className:"h-4 w-4"}),o("Select image")]})}),i&&(0,Wt.jsx)(E,{type:"button",variant:"outline",size:"icon",onClick:b,children:(0,Wt.jsx)(pu.X,{className:"h-4 w-4"})})]}),i&&(0,Wt.jsx)("div",{className:"aspect-video overflow-hidden rounded-md border",children:(0,Wt.jsx)(qo,{src:i,alt:o("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),(0,Wt.jsx)("p",{className:"text-xs text-muted-foreground",children:o("max 1mb")})]})]})]}),(0,Wt.jsxs)(co,{className:r?"pointer-events-none":"",children:[(0,Wt.jsx)(E,{variant:"outline",size:"sm",disabled:r,onClick:w=>{w.stopPropagation(),t()},children:o("Cancel")}),(0,Wt.jsx)(E,{variant:"default",size:"sm",disabled:r,onClick:k,children:o("Mark as template")})]})]})})},sre=are});var LI={};et(LI,{default:()=>lre});var gV,fV,kd,ire,lre,MI=x(()=>{"use strict";gV=require("react"),fV=require("react-i18next");wl();J();qt();kd=require("react/jsx-runtime"),ire=({page:e,onClose:t})=>{let{t:o}=(0,fV.useTranslation)(),[r,n]=(0,gV.useState)(!1),a=eV(),s=()=>{n(!0),a.mutate(e,{onSuccess:()=>{n(!1),t()},onError:()=>{n(!1)}})};return(0,kd.jsx)(Te,{open:!0,onOpenChange:t,children:(0,kd.jsxs)(we,{children:[(0,kd.jsxs)(Oe,{children:[(0,kd.jsx)(Ie,{children:o("Unmark as template")}),(0,kd.jsx)(Dt,{className:"space-y-1 py-2 text-xs text-muted-foreground",children:o("Are you sure you want to unmark this page as a template?")})]}),(0,kd.jsxs)(co,{className:r?"pointer-events-none":"",children:[(0,kd.jsx)(E,{variant:"outline",size:"sm",disabled:r,onClick:i=>{i.stopPropagation(),t()},children:o("Cancel")}),(0,kd.jsx)(E,{variant:"default",size:"sm",disabled:r,onClick:s,children:o("Unmark as template")})]})]})})},lre=ire});var Cv={};et(Cv,{default:()=>dre});var hV,mc,cre,dre,kv=x(()=>{"use strict";hV=require("react-i18next");wl();J();qt();mc=require("react/jsx-runtime"),cre=({page:e,onClose:t})=>{var s;let{t:o}=(0,hV.useTranslation)(),{mutate:r,isPending:n}=X$(),a=async()=>{r(e,{onSuccess:t})};return(0,mc.jsx)(Te,{open:!!e,onOpenChange:t,children:(0,mc.jsxs)(we,{children:[(0,mc.jsxs)(Oe,{children:[(0,mc.jsx)(Ie,{children:o("Confirm action")}),(0,mc.jsxs)(Dt,{children:[o("Are you sure you want to unpublish")," ",(0,mc.jsx)("b",{children:(s=e==null?void 0:e.name)!=null?s:e==null?void 0:e.slug}),"?"]})]}),(0,mc.jsxs)(co,{children:[(0,mc.jsx)(E,{variant:"outline",onClick:t,children:o("Cancel")}),(0,mc.jsx)(E,{variant:"destructive",disabled:n,onClick:a,children:o(n?"Updating...":"Unpublish")})]})]})})},dre=cre});function xy(e,t){t.debug&&console.log(`[Parent IFrame] ${e}`)}function mre(e,t,o,r={}){return{onCmsReady:()=>{xy("CMS ready signal received",r)},hideCmsOverlay:()=>{xy("Hiding CMS overlay",r),e(!1)},onCmsNavigate:n=>{xy(`CMS navigated to: ${n}`,r),t==null||t(n)},onCmsAction:n=>{xy(`CMS action: ${n.type} ${n.collection}`,r),o==null||o(n)}}}function yV(e,t,o={}){let r={...pre,...o.config};xy("Starting connection...",r);let n=mre(t,o.onNavigate,o.onAction,r),a=new MP.WindowMessenger({remoteWindow:e.contentWindow}),s=(0,MP.connect)({messenger:a,methods:n,timeout:r.timeout}),i={connection:s,child:null,state:"connecting"};return LP.set(e,i),s.promise.then(l=>{xy("Connected successfully",r),i.child=l,i.state="connected"}).catch(l=>{console.error("[Parent IFrame] Connection failed:",l),i.state="error"}),s}async function bV(e){let t=LP.get(e);if(!t||t.state!=="connected"||!t.child)return!0;try{return await t.child.requestClose()}catch(o){return console.error("[Parent IFrame] Failed to request close from child:",o),!0}}function xV(e){let t=LP.get(e);t&&(t.connection.destroy(),LP.delete(e))}var MP,LP,pre,vV=x(()=>{"use strict";MP=require("penpal"),LP=new WeakMap,pre={timeout:3e4,debug:!1}});function OI(e,t){var r;if(t.length===0)return;console.log("handleCmsAction",t);let o=new Set;for(let n of t){if(n.actionType==="invalidate"&&((r=n.keys)!=null&&r.length))for(let a of n.keys)o.add(a);if((n.type==="create"||n.type==="update")&&n.data){let a=n.data.slug;a&&ure(a)}}if(o.size>0)for(let n of o)e.invalidateQueries({queryKey:[n],refetchType:"all"})}function ure(e){if(typeof window=="undefined")return;let t=new URL(window.location.href);t.searchParams.set("slug",e),window.history.replaceState({},"",t.toString())}var CV=x(()=>{"use strict"});var kV,SV,oi,vy,wV,PV=x(()=>{"use strict";"use client";kV=require("@tanstack/react-query"),SV=require("lucide-react"),oi=require("react");vV();CV();vy=require("react/jsx-runtime"),wV=(0,oi.forwardRef)(function({src:t="/admin",className:o="",hidden:r=!1,deferInvalidation:n=!1,...a},s){var m;let i=(0,oi.useRef)(null),l=(0,oi.useRef)([]),c=(0,kV.useQueryClient)(),[d,p]=(0,oi.useState)(!0),u=(0,oi.useCallback)(()=>p(!1),[]);return(0,oi.useImperativeHandle)(s,()=>({requestClose:async()=>{let g=i.current;return g?bV(g):!0}}),[]),(0,oi.useEffect)(()=>{p(!0)},[t]),(0,oi.useEffect)(()=>{let g=i.current;return g?(yV(g,f=>{console.log("[ChaiIFrameWindow] setOverlayVisible called:",f)},{onAction:f=>{if(n){l.current.push(f);return}OI(c,[f])},onNavigate:f=>{},config:{debug:!0}}),()=>{n&&l.current.length>0&&(OI(c,l.current),l.current=[]),xV(g)}):void 0},[c,n]),(0,vy.jsxs)("div",{className:`chai-iframe-container ${o} ${r?"hidden":""}`,children:[d&&(0,vy.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-surface text-[13px] text-gray-500",children:(0,vy.jsx)(SV.Loader,{className:"animate-spin h-6 w-6 text-primary"})}),(0,vy.jsx)("iframe",{...a,ref:i,src:t,sandbox:(m=a.sandbox)!=null?m:"allow-same-origin allow-scripts allow-forms",onLoad:u,style:{width:"100%",height:"100%",border:"none",display:"block",...a.style}})]})})});var TV={};et(TV,{EditUrlPanel:()=>hre,resolveEditUrl:()=>gre});function gre(e,t){return e.replace(/\{\{ID\}\}/g,t)}function fre(e){try{return new URL(e,window.location.href).origin===window.location.origin}catch(t){return!1}}function hre({url:e,label:t,onClose:o}){let r=(0,Mp.useMemo)(()=>fre(e),[e]),[n,a]=(0,Mp.useState)(!0),s=(0,Mp.useRef)(null),i=(0,Mp.useRef)(!1),l=(0,Mp.useCallback)(async c=>{var p,u;if(c){a(!0);return}if(i.current)return;if(!r){a(!1),o();return}i.current=!0;let d=(u=await((p=s.current)==null?void 0:p.requestClose()))!=null?u:!0;i.current=!1,d&&(a(!1),o())},[r,o]);return(0,Fi.jsx)(Te,{open:n,onOpenChange:l,children:(0,Fi.jsxs)(we,{className:"flex max-h-[80vh] min-h-[70vh] min-w-[80%] flex-col gap-0 overflow-hidden p-0",onInteractOutside:c=>c.preventDefault(),onPointerDownOutside:c=>c.preventDefault(),children:[(0,Fi.jsx)(Oe,{className:"flex flex-row items-center justify-between border-b px-4 py-2.5 pr-10",children:(0,Fi.jsx)(Ie,{className:"text-xs font-medium",children:t!=null?t:"Edit"})}),(0,Fi.jsx)("div",{className:"relative flex-1 overflow-hidden",style:{height:"calc(80vh - 48px)"},children:r?(0,Fi.jsx)(wV,{ref:s,src:e,deferInvalidation:!0,className:"absolute inset-0 h-full w-full border-0",title:t!=null?t:"Edit",sandbox:"allow-same-origin allow-scripts allow-forms"}):(0,Fi.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground",children:[(0,Fi.jsx)("p",{className:"font-medium text-destructive",children:"Cross-origin URL blocked"}),(0,Fi.jsxs)("p",{className:"max-w-xs text-xs",children:["Only same-domain URLs are allowed in the edit panel.",(0,Fi.jsx)("br",{}),(0,Fi.jsx)("span",{className:"mt-1 block break-all font-mono text-[10px] opacity-70",children:e})]})]})})]})})}var Mp,Fi,NV=x(()=>{"use strict";"use client";Mp=require("react");qt();PV();Fi=require("react/jsx-runtime")});var AV={};et(AV,{default:()=>vre});var Sv,Cy,mu,Bt,yre,bre,EV,xre,vre,IV=x(()=>{"use strict";Sv=require("lodash-es"),Cy=require("lucide-react"),mu=require("react");lS();hl();Tt();er();Ef();An();J();Sr();Oo();Bt=require("react/jsx-runtime"),yre=({page:e,isSelected:t,icon:o,onClick:r})=>(0,Bt.jsx)(ye,{onClick:r,className:`no-scrollbar flex cursor-pointer flex-col justify-start overflow-x-auto whitespace-nowrap ${t?"bg-muted-foreground/20":"hover:bg-muted/20"}`,children:(0,Bt.jsx)("div",{className:"w-full whitespace-nowrap px-1 text-xs",children:(0,Bt.jsxs)("div",{className:"flex items-center gap-x-2",children:[o&&(0,Bt.jsx)("div",{className:"h-3 w-3 flex-shrink-0 opacity-60 [&>svg]:h-full [&>svg]:w-full",dangerouslySetInnerHTML:{__html:o}}),(0,Bt.jsx)("span",{title:e.name,className:"truncate text-xs font-medium",children:e.name})]})})},e.id),bre=({dynamicPage:e,setDynamicPage:t,searchQuery:o,setSearchQuery:r,dynamicPages:n,icon:a,pageTypeName:s,isLoadingPages:i,createUrl:l,onCreateClick:c})=>{var b,y;let{selectedLang:d}=fe(),p=(d==null?void 0:d.length)===0,{data:u,isFetching:m}=dr(),{data:g}=gn(),{t:h}=(0,gv.useTranslation)(),f=g==null?void 0:g.find(k=>k.lang===d);return(0,Bt.jsxs)(Yt,{children:[(0,Bt.jsx)($t,{asChild:!0,children:m?(0,Bt.jsx)(wt,{className:"h-4 w-4 text-muted-foreground"}):(0,Bt.jsxs)(E,{variant:"outline",size:"sm",className:"flex max-w-[150px] items-center justify-between gap-x-2 truncate rounded px-1 text-xs font-medium",children:[(0,Bt.jsxs)("div",{className:"flex items-center gap-2 truncate",children:[a&&(0,Bt.jsx)("div",{dangerouslySetInnerHTML:{__html:a}}),(0,Bt.jsx)("span",{title:e?(0,Sv.get)(e,"name"):(b=(0,Sv.get)(f||u,"name"))!=null?b:"Select Page",className:"max-w-[145px] truncate text-start",children:e?(0,Sv.get)(e,"name"):(y=(0,Sv.get)(f||u,"name"))!=null?y:"Select Page"})]}),(0,Bt.jsx)(Cy.ChevronDown,{className:"!h-3 !w-3"})]})}),(0,Bt.jsxs)(Vt,{className:"ml-10 max-h-[350px] w-80 divide-y p-0.5 pb-3 shadow-xl",children:[(0,Bt.jsxs)("div",{className:"flex items-center gap-x-1 overflow-hidden whitespace-nowrap p-2 text-xs font-light text-muted-foreground",children:[(0,Bt.jsx)("span",{className:"flex-shrink-0",children:h("Current Page")}),e&&(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)("span",{className:"flex-shrink-0",children:">"}),(0,Bt.jsx)("span",{title:e.name,className:"mr-2 truncate font-medium text-foreground",children:e.name})]})]}),(0,Bt.jsxs)("div",{className:"mb-2 flex items-center gap-1 border-none px-1",children:[(0,Bt.jsx)(Yr,{value:p?o:"",setValue:r,placeholder:p?`Search ${s}`:"To search select default language",disabled:!p,onKeyDown:k=>k.stopPropagation(),autoFocus:!0}),l&&c&&(0,Bt.jsxs)(E,{variant:"ghost",size:"sm",className:"flex-shrink-0 text-primary",title:`Add new ${s}`,onClick:k=>{k.stopPropagation(),c()},children:[(0,Bt.jsx)(Cy.Plus,{className:"h-3.5 w-3.5"})," Add"]})]}),(0,Bt.jsx)("div",{className:"no-scrollbar max-h-[200px] overflow-y-auto pb-1",children:i?(0,Bt.jsx)("div",{className:"flex h-24 items-center justify-center",children:(0,Bt.jsx)(wt,{className:"h-4 w-4"})}):(n==null?void 0:n.length)===0?(0,Bt.jsx)("div",{className:"flex h-24 items-center justify-center text-xs text-muted-foreground",children:"No pages found"}):n==null?void 0:n.map(k=>(0,Bt.jsx)(yre,{page:k,isSelected:k.id===(e==null?void 0:e.id),icon:a,onClick:()=>t(k)},k.id))})]})]})},EV=(0,mu.lazy)(()=>Promise.resolve().then(()=>(NV(),TV)).then(e=>({default:e.EditUrlPanel}))),xre=()=>{let{dynamicPage:e,allLangPages:t,searchQuery:o,updateDynamicPage:r,updateSearchQuery:n,isFetching:a}=QC(),{data:s}=xt(),i=Nf(s==null?void 0:s.pageType),l=i==null?void 0:i.icon,[c,d]=(0,mu.useState)(!1),[p,u]=(0,mu.useState)(!1),m=i!=null&&i.editUrl&&(e!=null&&e.id)?i==null?void 0:i.editUrl.replace("{{ID}}",e.id):null,g=typeof(i==null?void 0:i.pluralName)=="string"?i.pluralName:typeof(i==null?void 0:i.name)=="string"?i.name:"Pages";return(0,Bt.jsxs)("div",{className:"relative flex items-center gap-1",children:[(0,Bt.jsx)(bre,{dynamicPage:e,setDynamicPage:r,searchQuery:o,setSearchQuery:n,dynamicPages:t!=null?t:[],icon:l,pageTypeName:g,isLoadingPages:a,createUrl:i==null?void 0:i.createUrl,onCreateClick:()=>u(!0)}),m&&e&&(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(E,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:`Edit ${e.name}`,onClick:()=>d(!0),children:(0,Bt.jsx)(Cy.Pencil,{className:"!h-3 !w-3"})}),c&&(0,Bt.jsx)(mu.Suspense,{children:(0,Bt.jsx)(EV,{url:m,label:`Edit: ${e.name}`,onClose:()=>d(!1)})})]}),p&&(i==null?void 0:i.createUrl)&&(0,Bt.jsx)(mu.Suspense,{children:(0,Bt.jsx)(EV,{url:i.createUrl,label:`Add new ${(i==null?void 0:i.name)||""}`,onClose:()=>u(!1)})})]})},vre=xre});var BV,FI,Kg,cn,To,Cre,kre,Sre,wre,Pre,Tre,Nre,Ere,RV,DV=x(()=>{"use strict";BV=require("jotai"),FI=require("lodash-es"),Kg=require("lucide-react"),cn=require("react");Tt();fv();er();Ef();Gc();J();Oo();xI();ps();M$();To=require("react/jsx-runtime"),Cre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(PI(),wI))),kre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(RP(),BP))),Sre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(II(),AI))),wre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(_I(),DI))),Pre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(MI(),LI))),Tre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(kv(),Cv))),Nre=(0,cn.lazy)(()=>Promise.resolve().then(()=>(IV(),AV))),Ere=()=>{var n;let{dynamicPage:e,allLangPages:t,isLangMissing:o}=QC(),r=((n=t==null?void 0:t.length)!=null?n:0)>0;return(0,To.jsxs)("div",{className:"relative",children:[(!e||o)&&(0,To.jsx)(L$,{hasDynamicPage:r,isLangMissing:o}),(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(Nre,{})})]})},RV=()=>{var C;let[e,t]=(0,cn.useState)(null),[o,r]=(0,cn.useState)(null),[n,a]=(0,cn.useState)(null),[s,i]=(0,cn.useState)(null),[l,c]=(0,cn.useState)(null),[d,p]=(0,cn.useState)(null),{data:u,isFetching:m}=dr(),{selectedLang:g,fallbackLang:h}=fe(),{data:f}=gn(),b=f==null?void 0:f.find(P=>P.lang===g),{isLocked:y}=rn(),k=!(u!=null&&u.slug),w=(0,BV.useSetAtom)(bd),N=(0,FI.get)(u,"dynamic",!1);if(!u)return null;let I=P=>{g.length>0&&g!==h?w({edit:!0,id:P==null?void 0:P.id,primaryPage:P==null?void 0:P.primaryPage}):p(P)};return(0,To.jsxs)(To.Fragment,{children:[(0,To.jsxs)("div",{className:"flex items-center justify-between gap-1 rounded px-[2px] transition-colors duration-200",children:[!N&&(0,To.jsx)("p",{className:"flex h-7 max-w-[200px] items-center truncate rounded px-1 text-xs font-medium",children:m?(0,To.jsx)(wt,{className:"h-4 w-4 text-muted-foreground"}):(0,To.jsxs)(E,{variant:"ghost",size:"sm",className:"px-0 hover:bg-transparent",children:[k?(0,To.jsx)(Kg.Hash,{className:"!h-3.5 !w-3.5"}):(0,To.jsx)(Kg.File,{className:"!h-3.5 !w-3.5"}),(C=(0,FI.get)(b||u,"name"))!=null?C:""]})}),N&&(0,To.jsx)(Ere,{}),!N&&(y?(0,To.jsx)(E,{variant:"ghost",size:"icon-xs",children:(0,To.jsx)(Kg.MoreVertical,{className:"!h-3.5 !w-3.5"})}):(0,To.jsx)(SP,{page:u,setDuplicatePage:P=>c(P),setAddEditPage:P=>I(P),setUnpublishPage:P=>r(P),setDeletePage:P=>t(P),isLanguagePage:g.length>0&&g!==h,children:(0,To.jsx)(E,{variant:"ghost",size:"icon-xs",children:(0,To.jsx)(Kg.MoreVertical,{className:"!h-3.5 !w-3.5"})})}))]}),d&&(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(Cre,{closePanel:()=>p(null),editPage:()=>{},addEditPage:d,setAddEditPage:p})}),e&&(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(kre,{page:e,onClose:()=>t(null)})}),o&&(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(Tre,{page:o,onClose:()=>r(null)})}),n&&(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(wre,{page:n,onClose:()=>a(null)})}),s&&(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(Pre,{page:s,onClose:()=>i(null)})}),l&&(0,To.jsx)(cn.Suspense,{children:(0,To.jsx)(Sre,{page:l,onClose:()=>c(null),closePanel:()=>p(null)})})]})}});function OP(e,t,o=!1){let r=e.toString()?`?${e.toString()}`:"/";o?window.history.replaceState(null,"",r):window.history.pushState({},"",r),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}var HI=x(()=>{"use strict"});var OV={};et(OV,{default:()=>Dre});var ky,ri,Sy,ct,_V,LV,Are,MV,Ire,Bre,Rre,Dre,FV=x(()=>{"use strict";ky=require("lodash-es"),ri=require("react"),Sy=require("react-i18next");Tt();Zc();PP();zs();wl();Gc();Ul();An();Uc();Hl();cs();hv();$x();J();qt();fo();No();Oo();ct=require("react/jsx-runtime"),_V=({edit:e,lang:t,languages:o,name:r,setLang:n,setName:a,primaryPageObject:s})=>{let{t:i}=(0,Sy.useTranslation)();return(0,ct.jsxs)("div",{className:"space-y-1",children:[(0,ct.jsx)(Q,{htmlFor:"lang",children:i("Language")}),(0,ct.jsxs)("select",{value:e?"":t,disabled:e||!o.length,onChange:l=>{let c=l.target.value;n(c),!e&&((0,ky.startsWith)(r,s==null?void 0:s.name)||r.length===0)&&a(`${s==null?void 0:s.name} - ${Jt[c]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-surface px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[(0,ct.jsx)("option",{value:"",disabled:!0,children:e?Jt[t]||t:o.length?i("Choose language"):i("All available language page is created.")}),o.map(l=>(0,ct.jsx)("option",{value:l,children:Jt[l]||l},l))]})]})},LV=({lang:e,name:t,setName:o,parentHasSelectedLanguagePage:r})=>{let{t:n}=(0,Sy.useTranslation)();return(0,ct.jsxs)("div",{className:"space-y-1",children:[(0,ct.jsx)(Q,{htmlFor:"name",children:n("Page Name")}),(0,ct.jsx)(Ce,{id:"name",value:e?t:"",onChange:a=>o(a.target.value),required:!0,placeholder:n(e?"Enter page name":"Choose language to add slug"),disabled:!r||!e})]})},Are=({dynamic:e,isNonSlugPageType:t,isRootPage:o,lang:r,useLanguagePrefix:n,setUseLanguagePrefix:a,isHomePage:s,parentSlug:i,parentHasSelectedLanguagePage:l,slug:c,setSlug:d,setIsSlugValid:p,getSlug:u})=>{let{t:m}=(0,Sy.useTranslation)();return t?null:(0,ct.jsxs)("div",{className:"space-y-1",children:[o&&r&&(0,ct.jsxs)("div",{className:"flex items-center space-x-2 pb-1",children:[(0,ct.jsx)("input",{type:"checkbox",id:"useLanguagePrefix",checked:n,onChange:g=>a(g.target.checked),className:"rounded border-gray-300"}),(0,ct.jsxs)(Q,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",(0,ct.jsxs)("span",{className:"font-mono text-foreground",children:["/",r]}),") as slug prefix"]})]}),(0,ct.jsx)(Q,{htmlFor:"slug",children:m("Slug")}),e?(0,ct.jsx)(pd,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:m("This page will use dynamic slug as defined in primary page")}):(0,ct.jsx)(fy,{disabled:!r||!l,value:c,onChange:d,placeholder:m(r?s&&n?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:i,onValidationChange:p,fullSlug:u()})]})},MV=({parentHasSelectedLanguagePage:e,name:t,lang:o,slug:r,edit:n,id:a,primaryPageObject:s,pages:i,isNonSlugPageType:l,isHomePage:c,useLanguagePrefix:d,isSlugValid:p,isPending:u})=>{let{t:m}=(0,Sy.useTranslation)(),g=u||!t||!o||i.some(h=>(n?h.id!==a:!0)&&h.parent===(s==null?void 0:s.id)&&h.lang===o)||!l&&!(c&&d)&&(!p||!r);return(0,ct.jsx)(co,{children:e?(0,ct.jsxs)(ct.Fragment,{children:[(0,ct.jsx)(E,{loading:u,type:"submit",size:"sm",disabled:g&&!s.dynamic,children:m(n?"Update":"Add new language page")}),i.some(h=>(n?h.id!==a:!0)&&h.parent===(s==null?void 0:s.id)&&h.lang===o)&&(0,ct.jsx)("p",{className:"mt-2 text-xs text-red-500",children:m("A page for this language already exists.")})]}):o&&(0,ct.jsx)(pd,{variant:"destructive",children:(0,ct.jsxs)("p",{className:"mx-auto w-5/6 text-center",children:[m("You need to create the")," ",(0,ct.jsx)("span",{className:"font-medium",children:Jt[o]})," ",m("page in the parent to add here.")]})})})},Ire=({onSubmit:e,edit:t,lang:o,languages:r,name:n,setLang:a,setName:s,primaryPageObject:i,parentHasSelectedLanguagePage:l,id:c,pages:d,isNonSlugPageType:p,isHomePage:u,useLanguagePrefix:m,slug:g,isSlugValid:h,isPending:f})=>(0,ct.jsxs)("form",{onSubmit:e,children:[(0,ct.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,ct.jsx)(_V,{edit:t,lang:o,languages:r,name:n,setLang:a,setName:s,primaryPageObject:i}),(0,ct.jsx)(LV,{lang:o,name:n,setName:s,parentHasSelectedLanguagePage:l})]}),(0,ct.jsx)(MV,{parentHasSelectedLanguagePage:l,name:n,lang:o,slug:g,edit:t,id:c,primaryPageObject:i,pages:d,isNonSlugPageType:p,isHomePage:u,useLanguagePrefix:m,isSlugValid:h,isPending:f})]}),Bre=({loading:e,onSubmit:t,edit:o,lang:r,languages:n,name:a,setLang:s,setName:i,primaryPageObject:l,parentHasSelectedLanguagePage:c,isNonSlugPageType:d,isRootPage:p,useLanguagePrefix:u,setUseLanguagePrefix:m,isHomePage:g,parentSlug:h,slug:f,setSlug:b,isSlugValid:y,setIsSlugValid:k,getSlug:w,isPending:N,id:I,pages:C})=>e?(0,ct.jsx)("div",{className:"flex h-80 items-center justify-center",children:(0,ct.jsx)(wt,{})}):d?(0,ct.jsx)(Ire,{onSubmit:t,edit:o,lang:r,languages:n,name:a,setLang:s,setName:i,primaryPageObject:l,parentHasSelectedLanguagePage:c,id:I,pages:C,isNonSlugPageType:d,isHomePage:g,useLanguagePrefix:u,slug:f,isSlugValid:y,isPending:N}):(0,ct.jsxs)("form",{onSubmit:t,children:[(0,ct.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,ct.jsx)(_V,{edit:o,lang:r,languages:n,name:a,setLang:s,setName:i,primaryPageObject:l}),(0,ct.jsx)(LV,{lang:r,name:a,setName:i,parentHasSelectedLanguagePage:c}),(0,ct.jsx)(Are,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:p,lang:r,useLanguagePrefix:u,setUseLanguagePrefix:m,isHomePage:g,parentSlug:h,parentHasSelectedLanguagePage:c,slug:f,setSlug:b,isSlugValid:y,setIsSlugValid:k,getSlug:w})]}),(0,ct.jsx)(MV,{parentHasSelectedLanguagePage:c,name:a,lang:r,slug:f,edit:o,id:I,primaryPageObject:l,pages:C,isNonSlugPageType:d,isHomePage:g,useLanguagePrefix:u,isSlugValid:y,isPending:N})]}),Rre=({id:e,isOpen:t,onClose:o,primaryPage:r,edit:n=!1,preselectedLang:a})=>{let{data:s=[]}=on(),i=(0,ri.useMemo)(()=>s.find(Y=>Y.id===r),[s,r]),{data:l,isFetching:c}=ca(),d=Mn(),{data:p,isFetching:u}=gn(r),{data:m=[],isFetching:g}=gn(i==null?void 0:i.parent),{data:h=[],isFetching:f}=Ht(),{setSelectedLang:b}=fe(),{t:y}=(0,Sy.useTranslation)(),[,k]=Go(),[,w]=ma(),N=c||u||g||f,I=(0,ri.useMemo)(()=>(0,ky.filter)(l==null?void 0:l.languages,Y=>!(0,ky.find)(p,{lang:Y})),[l,p]),C=(0,ri.useMemo)(()=>{if(n&&p&&e){let Y=p.find(Ze=>Ze.id===e);if(Y&&i){let Ze=Y.slug||"",{initSlug:te,prefix:Qe}=H$(Ze,i);return{name:Y.name,lang:Y.lang,slug:te,useLanguagePrefix:Qe}}}if(!n&&i){if(a)return{name:`${i.name} - ${Jt[a]}`,lang:a,slug:"",useLanguagePrefix:!0};if((I==null?void 0:I.length)===1){let Y=I[0];if(Y&&Jt[Y])return{name:`${i.name} - ${Jt[Y]}`,lang:Y,slug:"",useLanguagePrefix:!0}}}return{name:"",lang:"",slug:"",useLanguagePrefix:!0}},[n,p,e,i,a,I]),[P,B]=(0,ri.useState)(()=>C.name),[T,v]=(0,ri.useState)(()=>C.lang),[S,A]=(0,ri.useState)(()=>C.slug),[D,R]=(0,ri.useState)(!0),[H,M]=(0,ri.useState)(()=>C.useLanguagePrefix),{mutate:L,isPending:z}=yy(),{mutate:_,isPending:F}=by(),O=z||F,U=(0,ri.useMemo)(()=>h.find(Y=>Y.key===(i==null?void 0:i.pageType)),[h,i==null?void 0:i.pageType]),j=!(U!=null&&U.hasSlug),ce=(i==null?void 0:i.slug)==="/",pe=(0,ri.useMemo)(()=>`${n?"edit":"new"}-${e||r}-${a||""}-${t}`,[n,e,r,a,t]),{parentSlug:ve,isRootPage:Ve}=(0,ri.useMemo)(()=>{if(ce||!T)return{parentSlug:void 0,isRootPage:!(i!=null&&i.parent)};if(!(i!=null&&i.parent))return{parentSlug:H?`/${T}`:void 0,isRootPage:!0};let Y=m==null?void 0:m.find(Ze=>Ze.lang===T);return{parentSlug:Y==null?void 0:Y.slug,isRootPage:!1}},[i==null?void 0:i.parent,m,H,T,ce]),ze=(0,ri.useMemo)(()=>Ve?!0:!!(m!=null&&m.some(Y=>(Y==null?void 0:Y.lang)===T)),[T,m,Ve]),bt=()=>{let Y="";return Ve?Y=`/${H?[T,S].filter(Boolean).join("/"):S}`:Y=`${_p(ve)}/${S}`,Y.replace(/\/{2,}/g,"/").replace(/\/$/,"")},W=Y=>{let Ze=new URLSearchParams(window.location.search);d&&Y===d?Ze.delete("lang"):Ze.set("lang",Y),k(Ze),window.dispatchEvent(new PopStateEvent("popstate"))},ie=Y=>{Y.preventDefault();let Ze={name:P,lang:T,primaryPage:i==null?void 0:i.id,slug:j?"":bt(),pageType:i==null?void 0:i.pageType,...n&&{id:e}},te=()=>{!n&&T&&(b(T),W(T)),w("outline"),o()};n?_(Ze,{onSuccess:te}):L(Ze,{onSuccess:te})};return(0,ct.jsx)(Te,{open:t,onOpenChange:o,children:t&&(0,ct.jsxs)(we,{className:"text-foreground sm:max-w-[425px]",children:[(0,ct.jsxs)(Oe,{children:[(0,ct.jsx)(Ie,{children:y(n?"Edit language":"Add new language page")}),(0,ct.jsx)(Dt,{className:"font-light",children:y("Enter the details for the language")})]}),(0,ct.jsx)(Bre,{id:e,pages:s,loading:N,onSubmit:ie,edit:n,lang:T,languages:I,name:P,setLang:v,setName:B,primaryPageObject:i,parentHasSelectedLanguagePage:ze,isNonSlugPageType:j,isRootPage:Ve,useLanguagePrefix:H,setUseLanguagePrefix:M,isHomePage:ce,parentSlug:ve,slug:S,setSlug:A,isSlugValid:D,setIsSlugValid:R,getSlug:bt,isPending:O},pe)]})})},Dre=Rre});var uu,HV,UV,GV,$V,Qr,VV,zV=x(()=>{"use strict";uu=require("lodash-es"),HV=require("lucide-react"),UV=require("react"),GV=require("react-i18next"),$V=require("sonner");zs();wl();An();$x();J();qt();fo();No();Qr=require("react/jsx-runtime"),VV=({page:e,onClose:t})=>{let{t:o}=(0,GV.useTranslation)(),[r,n]=(0,UV.useState)(e.slug||""),{mutate:a,isPending:s}=tV(),{data:i}=Ht(),l=(0,uu.find)(i,{key:e==null?void 0:e.pageType}),c=p=>{if(p.preventDefault(),!(e!=null&&e.primaryPage)&&Object.keys(Jt).some(g=>r===`/${g}`||(0,uu.startsWith)(r,`/${g}/`))){$V.toast.error(o("Error"),{description:o("Slugs cannot start with a language code for primary page")});return}a({...e,slug:r},{onSuccess:t})},d=(e==null?void 0:e.lang)||"";return(0,Qr.jsx)(Te,{open:!!e,onOpenChange:t,children:(0,Qr.jsxs)(we,{children:[(0,Qr.jsxs)(Oe,{children:[(0,Qr.jsx)(Ie,{children:o("Change Slug")}),(0,Qr.jsx)(Dt,{className:"text-xs",children:(0,Qr.jsxs)(pd,{variant:"destructive",className:"mt-2",children:[(0,Qr.jsx)(HV.AlertCircle,{className:"h-4 w-4"}),o("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),(0,Qr.jsxs)("form",{onSubmit:c,children:[(0,Qr.jsxs)("div",{className:"space-y-4 py-4 text-sm",children:[(0,Qr.jsxs)("div",{className:"space-y-1",children:[(0,Qr.jsxs)("div",{children:[(0,Qr.jsxs)("span",{children:[o("Type"),":"]}),(0,Qr.jsxs)("span",{className:"font-medium text-gray-600",children:[" ",(l==null?void 0:l.name)||(e==null?void 0:e.pageType)]})]}),(0,Qr.jsxs)("div",{children:[(0,Qr.jsxs)("span",{children:[o("Name"),":"]}),(0,Qr.jsxs)("span",{className:"font-medium text-gray-600",children:[" ",e.name]})]})]}),(0,Qr.jsxs)("div",{className:"space-y-1",children:[(0,Qr.jsxs)(Q,{htmlFor:"slug",className:"text-right",children:[o("Slug")," ",(0,Qr.jsxs)("small",{className:"font-light text-gray-500",children:[o("Slug should start with")," /",d]})]}),(0,Qr.jsx)(Ce,{id:"slug",value:r,onChange:p=>{let u=p.target.value;(0,uu.startsWith)(u,`/${d}`)&&n(u)},className:"col-span-3",required:!0,pattern:"^/.*",title:o("Slug must start with /"),placeholder:o("Enter page slug")})]})]}),(0,Qr.jsx)(co,{children:(0,Qr.jsx)(E,{type:"submit",disabled:s||!(0,uu.startsWith)(r,`/${d}`)||(0,uu.isEqual)(e==null?void 0:e.slug,r),children:o(s?"Changing...":"Change Slug")})})]})]})})}});var UI,ni,wv=x(()=>{"use strict";mn();UI=({permission:e,permissions:t,children:o,fallback:r=null})=>{let{hasPermission:n}=kt();return e&&!n(e)||t&&!t.some(a=>n(a))?r:o},ni=UI});var qV={};et(qV,{default:()=>Ore});var WV,Hi,Tl,ai,jV,yt,_re,Lre,Mre,Ore,KV=x(()=>{"use strict";WV=require("jotai"),Hi=require("lodash-es"),Tl=require("lucide-react"),ai=require("react"),jV=require("react-i18next");Tt();fv();zV();wv();zs();er();Gc();An();Uc();J();Sr();tn();yt=require("react/jsx-runtime"),_re=(0,ai.lazy)(()=>Promise.resolve().then(()=>(RP(),BP))),Lre=(0,ai.lazy)(()=>Promise.resolve().then(()=>(kv(),Cv))),Mre=()=>{let{t:e}=(0,jV.useTranslation)(),t=(0,WV.useSetAtom)(bd),{selectedLang:o,fallbackLang:r,setSelectedLang:n}=fe(),{data:a,isFetching:s}=gn(),{data:i}=xt(),{data:l}=Ht(),c=(0,ai.useMemo)(()=>{let k=l==null?void 0:l.find(w=>w.key===(i==null?void 0:i.pageType));return i!=null&&i.dynamic?k==null?void 0:k.dynamicSlug:""},[l,i==null?void 0:i.pageType,i==null?void 0:i.dynamic]),[d,p]=(0,ai.useState)(null),[u,m]=(0,ai.useState)(null),[g,h]=(0,ai.useState)(null),f=(0,ai.useMemo)(()=>{let k=(0,Hi.find)(l,{key:i==null?void 0:i.pageType});return(k==null?void 0:k.hasSlug)===!1},[i==null?void 0:i.pageType,l]),{data:b}=ca(),y=(0,Hi.filter)((0,Hi.get)(b,"languages")||["en"],k=>!(0,Hi.find)(a,{lang:k})&&k!==(0,Hi.get)(b,"fallbackLang"));return(0,yt.jsxs)("div",{className:"space-y-1",children:[(0,yt.jsx)("ul",{className:"space-y-1",children:s?(0,yt.jsxs)("div",{className:"w-full space-y-3 py-4",children:[(0,yt.jsx)("div",{className:"h-8 w-full animate-pulse rounded bg-accent"}),(0,yt.jsx)("div",{className:"h-8 w-full animate-pulse rounded bg-accent"}),(0,yt.jsx)("div",{className:"h-8 w-full animate-pulse rounded bg-accent"})]}):(0,Hi.map)(a,k=>{let w=k.lang,N=k.slug,I=!k.primaryPage;return(0,yt.jsxs)("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-muted-foreground ${w===o?"bg-primary/10":"border hover:bg-accent"}`,onClick:()=>n(w),children:[(0,yt.jsxs)("div",{className:"flex-1 gap-x-3",children:[(0,yt.jsxs)("div",{className:"flex items-center gap-x-2 text-[13px] text-foreground",children:[(0,yt.jsx)("div",{className:`h-2.5 w-2.5 rounded-full ${k.online?"bg-success":"bg-muted"}`}),(0,Hi.get)(Jt,I?r:w,w)]}),(0,yt.jsxs)("div",{children:[(0,yt.jsxs)("div",{className:"text-[11px] font-light text-muted-foreground",children:["Name:",(0,yt.jsxs)("b",{children:[" ",k.name," "]})]}),N&&(0,yt.jsxs)("div",{className:"text-[11px] font-light text-muted-foreground",children:["Slug: ",(0,yt.jsx)("b",{className:"font-mono",children:c?`${N}/${c}`:N})]})]})]}),I?(0,yt.jsxs)("div",{className:"flex items-center gap-x-1 text-[11px] text-primary",children:[(0,yt.jsx)(Tl.StarIcon,{className:"h-3 w-3 fill-primary"}),"Default"]}):(0,yt.jsx)("div",{className:"flex items-center gap-x-3",children:(0,yt.jsx)(ni,{permissions:[xe["pages:update"],xe["pages:delete"],xe["pages:unpublish"]],children:(0,yt.jsxs)(Yt,{children:[(0,yt.jsx)($t,{asChild:!0,onClick:P=>P.stopPropagation(),children:(0,yt.jsx)(E,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:(0,yt.jsx)(Tl.MoreHorizontal,{className:"h-4 w-4"})})}),(0,yt.jsxs)(Vt,{align:"end",className:"z-[9999] text-sm",children:[(0,yt.jsx)(ni,{permissions:[xe["pages:update"]],children:(0,yt.jsxs)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),t({edit:!0,id:k.id,primaryPage:k.primaryPage})},children:[(0,yt.jsx)(Tl.PencilIcon,{className:"size-3"}),e("Edit")]})}),(0,yt.jsx)(ni,{permissions:[xe["pages:unpublish"]],children:(k==null?void 0:k.online)&&(0,yt.jsxs)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),m(k)},children:[(0,yt.jsx)(Tl.Power,{className:"size-3"}),e("Unpublish")]})}),(0,yt.jsx)(ni,{permissions:[xe["pages:delete"]],children:(0,yt.jsxs)(ye,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),p(k)},children:[(0,yt.jsx)(Tl.TrashIcon,{className:"size-3"}),e("Delete")]})})]})]})})})]},k.id)})}),!f&&(0,yt.jsx)(ni,{permissions:[xe["pages:create"]],children:(0,yt.jsx)("div",{className:"flex w-full justify-center pt-2",children:(0,yt.jsxs)(E,{variant:"outline",size:"sm",disabled:(0,Hi.isEmpty)(y),onClick:()=>{t({primaryPage:i==null?void 0:i.id,edit:!1})},children:[(0,yt.jsx)(Tl.Plus,{}),e("Add new language page")]})})}),d&&(0,yt.jsx)(ai.Suspense,{children:(0,yt.jsx)(_re,{page:d,onClose:()=>p(null)})}),u&&(0,yt.jsx)(ai.Suspense,{children:(0,yt.jsx)(Lre,{page:u,onClose:()=>m(null)})}),g&&(0,yt.jsx)(ai.Suspense,{children:(0,yt.jsx)(VV,{page:g,onClose:()=>h(null)})})]})},Ore=Mre});function GI(){let e=(0,Pv.useAtomValue)(bd),t=(0,Pv.useSetAtom)(bd);return(0,no.jsxs)("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[(0,no.jsx)(Br,{slotId:jo.TOPBAR_LEFT}),e&&(0,no.jsx)(Ui.Suspense,{children:(0,no.jsx)(Fre,{isOpen:!0,id:e==null?void 0:e.id,edit:!!(e!=null&&e.id),primaryPage:e==null?void 0:e.primaryPage,preselectedLang:e==null?void 0:e.preselectedLang,onClose:()=>t(null)})})]})}var Pv,ya,Op,Ui,YV,no,Fre,Hre,wy,Tv=x(()=>{"use strict";Pv=require("jotai"),ya=require("lodash-es"),Op=require("lucide-react"),Ui=K(require("react"),1),YV=require("react-i18next");Tt();fv();zs();er();Gc();An();Uc();cs();HI();Rr();J();qt();Sr();lm();ps();no=require("react/jsx-runtime"),Fre=(0,Ui.lazy)(()=>Promise.resolve().then(()=>(FV(),OV))),Hre=(0,Ui.lazy)(()=>Promise.resolve().then(()=>(KV(),qV))),wy=({showAdd:e=!0,goToDefaultLang:t=!1})=>{let{fallbackLang:o,languages:r,selectedLang:n,setSelectedLang:a}=fe(),s=(0,ya.isEmpty)(n)?o:n,[,i]=Go(),{isLocked:l}=rn(),{t:c}=(0,YV.useTranslation)(),[d,p]=Ui.default.useState(!1);(0,Ui.useEffect)(()=>{let N=new URLSearchParams(window.location.search),I=N.get("lang");I&&(r.includes(I)?a(I):(N.delete("lang"),i(N),a("")))},[r,i,a]);let u=(0,Pv.useSetAtom)(bd),{data:m}=xt(),{data:g}=ca(),{data:h}=gn(),{data:f}=Ht(),b=(0,Ui.useMemo)(()=>{let N=(0,ya.find)(f,{key:m==null?void 0:m.pageType});return(N==null?void 0:N.hasSlug)===!1},[m==null?void 0:m.pageType,f]),y=(0,Ui.useMemo)(()=>{let N=(0,ya.compact)((0,ya.map)((0,ya.get)(g,"languages"),I=>{let C=(0,ya.find)(h,{lang:I});return{key:I,value:(0,ya.get)(Jt,I,I),isLangPageAdded:!!C}})).filter(Boolean);return[{key:o,value:(0,ya.get)(Jt,o),isLangPageAdded:!0},...N]},[o,h,g]),k=N=>{if(document.querySelector('[data-panel-id="seo"]')){let C=new CustomEvent("seo-language-switch-check",{detail:{fromLang:s,toLang:N,switchHandler:()=>w(N)}});window.dispatchEvent(C);return}w(N)},w=N=>{a(N);let I=new URLSearchParams(window.location.search);N===o?I.delete("lang"):I.set("lang",N),OP(I,i)};return(0,ya.isEmpty)(r)?null:l?(0,no.jsxs)(E,{disabled:!0,variant:"ghost",size:"sm",className:"h-6 cursor-not-allowed opacity-70",children:[(0,no.jsx)(Op.Languages,{className:"!h-3.5 !w-3.5"}),(0,ya.get)(Jt,s,s),(0,no.jsx)(Op.ChevronDown,{className:"h-3 w-3"})]}):t?(0,no.jsx)(E,{onClick:()=>w(o),variant:"link",size:"xs",children:c("Switch to default language")}):(0,no.jsx)(no.Fragment,{children:(0,no.jsxs)(Yt,{children:[(0,no.jsx)($t,{asChild:!0,className:"focus:outline-none",children:(0,no.jsxs)(E,{disabled:l,variant:"ghost",size:"sm",className:"h-6 text-[12px] font-light opacity-90 hover:opacity-100",children:[(0,no.jsx)(Op.Languages,{className:"!h-3.5 !w-3.5 !stroke-[1px]"}),(0,ya.get)(Jt,s,s),(0,no.jsx)(Op.ChevronDown,{className:"!h-3.5 !w-3.5 !stroke-[1px]"})]})}),(0,no.jsxs)(Vt,{align:"start",children:[(0,ya.map)(y.filter(N=>N.isLangPageAdded||b),N=>(0,no.jsxs)(Jc,{checked:N.key===s,onClick:()=>k(N.key),children:[(0,no.jsx)("span",{children:N.value}),N.key===o&&(0,no.jsx)("span",{className:"flex items-center gap-x-0.5 pl-1 text-[9px] leading-none text-primary",children:"Default"})]},N.value)),e&&!b&&(0,no.jsx)(Hn,{}),e&&!b&&!(0,ya.isEmpty)(y.filter(N=>!N.isLangPageAdded))&&(0,no.jsx)(no.Fragment,{children:(0,no.jsxs)(ye,{onClick:()=>{m&&u({edit:!1,primaryPage:m.id})},children:[(0,no.jsx)(Op.Plus,{className:"!h-2.5 !w-2.5 !stroke-[1px]"}),c("Add language")]})}),e&&!b&&(0,no.jsxs)(Te,{open:d,onOpenChange:p,children:[(0,no.jsx)(pf,{asChild:!0,children:(0,no.jsxs)(ye,{onSelect:N=>N.preventDefault(),children:[(0,no.jsx)(Op.Languages,{className:"!h-2.5 !w-2.5 !stroke-[1px]"}),c("View languages")]})}),d&&(0,no.jsxs)(we,{className:"max-w-sm p-3",children:[(0,no.jsx)(Oe,{children:(0,no.jsx)(Ie,{className:"text-sm",children:c("Manage Languages")})}),(0,no.jsx)(Ui.Suspense,{fallback:(0,no.jsx)("div",{className:"p-4 text-center text-sm text-muted-foreground",children:c("Loading...")}),children:(0,no.jsx)(Hre,{})})]})]})]})]})})}});var QV,XV,$I,Xr,VI,JV,ZV=x(()=>{"use strict";QV=require("@radix-ui/react-icons"),XV=require("lucide-react"),$I=require("react-i18next");Ke();Tt();Ge();J();qt();Xr=require("react/jsx-runtime"),VI=({isOpen:e,onClose:t,onContinue:o,errors:r,actionLabel:n})=>{let{t:a}=(0,$I.useTranslation)(),[,s]=Pe(),i=q("gotoPage",g=>{}),{selectedLang:l,fallbackLang:c}=fe(),d=r.filter(g=>g.severity==="error"),p=r.filter(g=>g.severity==="warning"),u=g=>{g.blockId&&(s([g.blockId]),t())},m=g=>{g.partialBlockId&&(i({pageId:g.partialBlockId,lang:l||c}),t())};return(0,Xr.jsx)(Te,{open:e,onOpenChange:g=>!g&&t(),children:(0,Xr.jsxs)(we,{className:"sm:max-w-md",children:[(0,Xr.jsxs)(Oe,{children:[(0,Xr.jsxs)(Ie,{className:"flex items-center gap-2",children:[(0,Xr.jsx)(QV.ExclamationTriangleIcon,{className:"h-5 w-5 text-orange-500"}),a("Page Validation Issues")]}),(0,Xr.jsx)(Dt,{children:a("The following issues were found on this page. You can fix them or continue anyway.")})]}),(0,Xr.jsxs)("div",{className:"max-h-64 space-y-2 overflow-y-auto",children:[d.length>0&&(0,Xr.jsxs)("div",{className:"space-y-1",children:[(0,Xr.jsxs)("h4",{className:"text-xs font-semibold text-red-600",children:[a("Errors")," (",d.length,")"]}),d.map(g=>(0,Xr.jsx)(JV,{error:g,onNavigate:u,onOpenPartial:m},g.id))]}),p.length>0&&(0,Xr.jsxs)("div",{className:"space-y-1",children:[(0,Xr.jsxs)("h4",{className:"text-xs font-semibold text-orange-600",children:[a("Warnings")," (",p.length,")"]}),p.map(g=>(0,Xr.jsx)(JV,{error:g,onNavigate:u,onOpenPartial:m},g.id))]})]}),(0,Xr.jsxs)(co,{className:"gap-2 sm:gap-0",children:[(0,Xr.jsx)(E,{variant:"outline",size:"sm",onClick:t,children:a("Cancel")}),(0,Xr.jsx)(E,{size:"sm",onClick:o,children:n})]})]})})},JV=({error:e,onNavigate:t,onOpenPartial:o})=>{let{t:r}=(0,$I.useTranslation)(),n=e.severity==="error",a=!!e.partialBlockId;return(0,Xr.jsxs)("div",{className:`rounded p-2 text-xs ${n?"border border-red-200 bg-red-50 text-red-700":"border border-orange-200 bg-orange-50 text-orange-700"}`,children:[(0,Xr.jsx)("div",{className:"mb-1",children:e.message}),(0,Xr.jsxs)("div",{className:"flex items-center gap-2",children:[e.blockId&&!a&&(0,Xr.jsx)("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs font-medium underline hover:no-underline",children:r("Go to block")}),a&&(0,Xr.jsxs)("button",{type:"button",onClick:()=>o(e),className:"inline-flex items-center gap-1 text-xs font-medium underline hover:no-underline",children:[(0,Xr.jsx)(XV.ExternalLink,{className:"h-3 w-3"}),r("Open partial block")]})]})]})}});var gu,fu,FP=x(()=>{"use strict";gu=require("jotai");zr();fu=()=>{let[e]=(0,gu.useAtom)(Ec),[t]=(0,gu.useAtom)(Du),[o]=(0,gu.useAtom)(_u),[r]=(0,gu.useAtom)(Lu),[n]=(0,gu.useAtom)(XT),[a]=(0,gu.useAtom)(ZT),[s]=(0,gu.useAtom)(e0);return{errors:e,isValid:t,hasErrors:o,hasWarnings:r,errorCount:n,warningCount:a,errorsByBlock:s,getBlockErrors:i=>s[i]||[],getErrorsBySeverity:i=>e.filter(l=>l.severity===i),getErrorMessages:()=>e.map(i=>i.message),getErrorMessagesBySeverity:i=>e.filter(l=>l.severity===i).map(l=>l.message),getAllErrorMessages:()=>({errors:e.filter(i=>i.severity==="error").map(i=>i.message),warnings:e.filter(i=>i.severity==="warning").map(i=>i.message)})}}});var HP,UP,GP,$P,ez,tz,VP=x(()=>{"use strict";HP=require("lodash-es"),UP=require("react"),GP=require("react-i18next");An();$P=()=>{let{t:e}=(0,GP.useTranslation)(),{data:t}=Ht(),o=(0,UP.useMemo)(()=>(0,HP.filter)(t,r=>r.hasSlug===!1),[t]);return(o==null?void 0:o.length)===1?e("Create {{name}}",{name:o[0].name}):e("Create Partial Block")},ez=(e="pages")=>{let{t}=(0,GP.useTranslation)(),{data:o}=Ht(),r=(0,UP.useMemo)(()=>(0,HP.filter)(o,n=>n.hasSlug===!1),[o]);return e==="pages"?t("Search Pages"):(r==null?void 0:r.length)===1?t("Search {{name}}",{name:r[0].name}):t("Search Partials")},tz=()=>{let{t:e}=(0,GP.useTranslation)(),{data:t}=Ht(),o=(0,UP.useMemo)(()=>(0,HP.filter)(t,r=>r.hasSlug===!1),[t]);return(o==null?void 0:o.length)===1?e("{{name}}s",{name:o[0].name}):e("Partials")}});var oz,rz,Py,dn,Ure,zI,Gre,nz,$re,Fp,Nv=x(()=>{"use strict";oz=require("jotai"),rz=require("jotai/utils"),Py=require("react"),dn=require("lodash-es"),Ure=(0,rz.atomWithStorage)("expandedPagesState",[]),zI=e=>(0,dn.flatMap)(e,t=>[t,...t.children?zI(t.children):[]]),Gre=(e,t)=>{let o=(r,n=[])=>{for(let a of r){let s=[...n,a.id];if(a.id===t)return s;if(a.children&&a.children.length>0){let i=o(a.children,s);if(i)return i}}return null};return o(e)||[]},nz=(e,t)=>{if(!t)return[];let o=zI(e),r=(0,dn.find)(o,n=>n.id===t);if(r){if(r.parent)return[...nz(e,r.parent),t];let n=Gre(e,t);if(!(0,dn.isEmpty)(n))return n}return[t]},$re=e=>{let t=new Set,o=(r,n=[])=>{r.forEach(a=>{let s=[...n,a.id];a.shouldExpandOnSearch&&s.forEach(i=>t.add(i)),a.children&&!(0,dn.isEmpty)(a.children)&&o(a.children,s)})};return o(e),Array.from(t)},Fp=e=>{let[t,o]=(0,oz.useAtom)(Ure),r=e?(0,dn.includes)(t,e):!1,n=(0,Py.useCallback)(()=>{o(c=>r?(0,dn.filter)(c,d=>d!==e):[...c,e])},[o,r,e]),a=(0,Py.useCallback)((c,d)=>{if(!d||(0,dn.isEmpty)(c))return;let p=zI(c),u=nz(p,d);if(!Array.isArray(u)||(0,dn.isEmpty)(u))return;let m=u.slice(0,-1);(0,dn.isEmpty)(m)||o(g=>(0,dn.uniq)([...g,...m]))},[o]),s=(0,Py.useCallback)(c=>{if((0,dn.isEmpty)(c))return;let d=$re(c);(0,dn.isEmpty)(d)||o(p=>(0,dn.union)(p,d))},[o]),i=(0,Py.useCallback)(c=>{if((0,dn.isEmpty)(c))return;let d=(0,dn.flatMap)(c,p=>{let u=m=>[m.id,...m.children?(0,dn.flatMap)(m.children,u):[]];return u(p)});o(d)},[o]),l=(0,Py.useCallback)(()=>{o([])},[o]);return{isExpanded:r,toggleExpanded:n,updateForSelectedPage:a,expandedPages:t,expandPagesOnSearch:s,setExpandedPages:o,expandAll:i,collapseAll:l}}});var sz={};et(sz,{LanguageSelector:()=>zP,default:()=>qre});var az,Tr,ba,Ty,Ev,Fe,Vre,zre,zP,Wre,jre,qre,WI=x(()=>{"use strict";az=require("@tanstack/react-query"),Tr=require("lodash-es"),ba=require("lucide-react"),Ty=require("react"),Ev=require("react-i18next");hl();VP();St();zs();An();Hl();Nv();J();fo();Gs();xi();rs();Fe=require("react/jsx-runtime"),Vre=({selectedPageType:e,setSelectedPageType:t,category:o})=>{let{t:r}=(0,Ev.useTranslation)(),[n,a]=(0,Ty.useState)(""),{data:s}=Ht(),i=!0,l=(0,Ty.useMemo)(()=>s==null?void 0:s.some(p=>!["page","global"].includes((0,Tr.get)(p,"key",""))),[s]);if((0,Ty.useEffect)(()=>{!l&&e!=="all"&&t("all")},[l,e,t]),!l)return null;let c=p=>{if(!n)return!0;let u=n.toLowerCase(),m=g=>String((0,Tr.get)(p,g,"")).toLowerCase().includes(u);return m("name")||m("key")},d=s==null?void 0:s.find(p=>p.key===e);return(0,Fe.jsxs)(So,{onValueChange:t,value:e,children:[(0,Fe.jsx)(ho,{className:`${e==="all"?"bg-muted/30 hover:bg-muted":"gap-x-1 border bg-muted/30 hover:bg-muted"} h-8 w-max min-w-[80px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-muted-foreground shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:(0,Fe.jsxs)("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[(0,Fe.jsx)("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(d==null?void 0:d.name)||r("All")}),(0,Fe.jsx)(ba.ListFilter,{className:`${e!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),(0,Fe.jsxs)(yo,{children:[i&&(0,Fe.jsx)("div",{className:"sticky top-0 z-10 bg-surface pb-2",children:(0,Fe.jsxs)("div",{className:"relative",children:[(0,Fe.jsx)(ba.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),(0,Fe.jsx)(Ce,{placeholder:r("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:n,onChange:p=>a(p.target.value),onKeyDown:p=>p.stopPropagation()})]})}),(0,Fe.jsx)(gt,{value:"all",children:r("All")}),o==="pages"&&!(0,Tr.isEmpty)((0,Tr.filter)(s,p=>p.hasSlug&&c(p)))&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-muted-foreground",children:r("Pages")}),(0,Tr.map)([...(0,Tr.filter)(s,p=>p.hasSlug&&c(p))].sort((p,u)=>(0,Tr.get)(p,"name","").localeCompare((0,Tr.get)(u,"name",""))),p=>(0,Fe.jsx)(gt,{value:(0,Tr.get)(p,"key"),children:(0,Tr.get)(p,"name","")},(0,Tr.get)(p,"key")))]}),o==="partials"&&!(0,Tr.isEmpty)((0,Tr.filter)(s,p=>!p.hasSlug&&c(p)))&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-muted-foreground",children:r("Partials")}),(0,Tr.map)([...(0,Tr.filter)(s,p=>!p.hasSlug&&c(p))].sort((p,u)=>(0,Tr.get)(p,"name","").localeCompare((0,Tr.get)(u,"name",""))),p=>(0,Fe.jsx)(gt,{value:(0,Tr.get)(p,"key"),children:(0,Tr.get)(p,"name","")},(0,Tr.get)(p,"key")))]}),(0,Tr.isEmpty)((0,Tr.filter)(s,c))&&(0,Fe.jsx)("div",{className:"px-3 py-2 text-center text-sm text-muted-foreground",children:r("No matching page types found")})]})]})},zre=({pages:e})=>{let{t}=(0,Ev.useTranslation)(),{expandAll:o,collapseAll:r,expandedPages:n}=Fp(null),a=n.length>0;return(0,Fe.jsx)("div",{className:"flex gap-1",children:(0,Fe.jsxs)(Fo,{children:[(0,Fe.jsx)(Ho,{asChild:!0,children:(0,Fe.jsx)(E,{variant:"outline",size:"icon-sm",onClick:()=>a?r():o(e),children:a?(0,Fe.jsx)(ba.ChevronsDownUp,{}):(0,Fe.jsx)(ba.ChevronsUpDown,{})})}),(0,Fe.jsx)(Bo,{children:t(a?"Collapse All":"Expand All")})]})})},zP=({languages:e,selectedLanguage:t,setSelectedLanguage:o})=>{let r=Mn();return(0,Fe.jsx)(Dr,{onValueChange:n=>o(n.toLowerCase()),value:t,className:"flex h-7 max-h-full flex-col overflow-x-auto overflow-y-hidden",children:(0,Fe.jsx)(Cr,{className:"flex w-full items-center",children:e.map(n=>(0,Fe.jsxs)(ut,{value:n,className:"h-5 px-3 text-xs",children:[n===r&&(0,Fe.jsx)("span",{children:(0,Fe.jsx)(ba.Star,{className:"h-2.5 w-2.5"})}),Jt[n]||""]},n))})})},Wre=()=>{let{t:e}=(0,Ev.useTranslation)(),t=(0,az.useQueryClient)();return(0,Fe.jsxs)(Fo,{children:[(0,Fe.jsx)(Ho,{asChild:!0,children:(0,Fe.jsx)(E,{size:"icon-sm",variant:"outline",onClick:()=>t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),children:(0,Fe.jsx)(ba.RefreshCw,{})})}),(0,Fe.jsx)(Bo,{side:"top",children:e("Refresh pages list")})]})},jre=({pages:e,search:t,setSearch:o,languages:r,onAddPage:n,selectedLanguage:a,setSelectedLanguage:s,selectedPageType:i,setSelectedPageType:l,showUntranslatedPages:c,setShowUntranslatedPages:d,category:p,setCategory:u})=>{let{t:m}=(0,Ev.useTranslation)(),g=tz(),h=r.length>1;return(0,Fe.jsx)(df,{children:(0,Fe.jsxs)("div",{className:"space-y-3 border-b border-b-border px-4 pb-1",children:[(0,Fe.jsx)(Dr,{onValueChange:u,value:p,className:"flex h-8 w-48 items-center justify-center p-0",children:(0,Fe.jsxs)(Cr,{className:"grid h-8 w-full grid-cols-2 items-center justify-center rounded bg-muted/50 p-0 px-0.5",children:[(0,Fe.jsx)(ut,{value:"pages",className:"h-7 rounded-sm px-2 py-0.5 text-xs",children:m("Pages")}),(0,Fe.jsx)(ut,{value:"partials",className:"h-7 rounded-sm px-2 py-0.5 text-xs",children:g})]})}),(0,Fe.jsxs)("div",{className:"grid grid-cols-3",children:[(0,Fe.jsxs)("div",{className:"col-span-2 flex items-center gap-1",children:[(0,Fe.jsx)(Vre,{category:p,selectedPageType:i,setSelectedPageType:l}),(0,Fe.jsx)(Yr,{value:t,setValue:o,placeholder:ez(p)})]}),(0,Fe.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,Fe.jsx)(Wre,{}),(0,Fe.jsx)(zre,{pages:e}),p==="pages"&&(0,Fe.jsxs)(E,{variant:"default",onClick:n,size:"sm",children:[(0,Fe.jsx)(ba.Plus,{}),(0,Fe.jsx)("span",{children:m("Add Page")})]})]})]}),p==="pages"&&h?(0,Fe.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,Fe.jsx)(zP,{languages:r,selectedLanguage:a,setSelectedLanguage:f=>{s(f),d(c&&(r==null?void 0:r[0])!==a)}}),(0,Fe.jsx)("div",{className:"flex items-center gap-x-2",children:(r==null?void 0:r[0])!==a&&(0,Fe.jsxs)(Fo,{children:[(0,Fe.jsx)(Ho,{asChild:!0,children:(0,Fe.jsx)(E,{variant:"ghost",size:"icon-sm",onClick:()=>d(!c),children:c?(0,Fe.jsx)(ba.FilterXIcon,{}):(0,Fe.jsx)(ba.Filter,{})})}),(0,Fe.jsx)(Bo,{side:"bottom",children:m("Toggle Untranslated Pages")})]})})]}):(0,Fe.jsx)("div",{className:"flex items-center justify-between gap-2"})]})})},qre=jre});var iz,lz,cz=x(()=>{"use strict";iz=require("@tanstack/react-query");St();rt();Kt();lz=()=>{let e=le(),t=he();return(0,iz.useQuery)({queryKey:[$.GET_CHANGES],queryFn:async()=>t(e,{action:$.GET_CHANGES})})}});var dz,pz,xa,Hp=x(()=>{"use strict";dz=require("@tanstack/react-query"),pz=require("lodash-es");St();rt();Kt();xa=e=>{let t=le(),o=he();return(0,dz.useQuery)({queryKey:[$.GET_CHAI_USER,e],queryFn:async()=>{let r=await o(t,{action:$.GET_CHAI_USER,data:{userId:e}}),n=(r==null?void 0:r.data)||{};return{id:n.id,name:n.name||n.email,email:n.email,avatar:n.avatar}},enabled:!(0,pz.isEmpty)(e),staleTime:"static"})}});var Kre,Yre,Jre,Yg,jI=x(()=>{"use strict";Kre={particleCount:350,spread:120,origin:{y:.6},angle:90},Yre={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Jre=async()=>{let{default:e}=await import("canvas-confetti");return e},Yg=e=>{let t=Yre[e];t||(t={});let o={...Kre,...t};Jre().then(r=>r(o))}});var mz={};et(mz,{default:()=>Zre});var mt,hu,_a,qI,ot,Qre,Xre,Zre,uz=x(()=>{"use strict";"use client";mt=require("lodash-es"),hu=require("lucide-react"),_a=require("react"),qI=require("react-i18next");ps();Vd();WI();cz();An();Hl();Hp();jI();ea();J();qt();ot=require("react/jsx-runtime"),Qre=({page:e,selectedPages:t,handleCheckboxChange:o,getPageType:r,hasSlug:n,currentOwnerId:a})=>{let{t:s}=(0,qI.useTranslation)(),i=tl(),{data:l}=xa(a),c=a===i?null:l==null?void 0:l.name;return(0,ot.jsxs)("tr",{className:"group relative hover:bg-muted/10",children:[(0,ot.jsxs)("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-foreground ${c?"opacity-50":""}`,children:[c?(0,ot.jsx)(hu.Lock,{className:"h-4 w-4 fill-destructive/20 text-destructive"}):(0,ot.jsx)("input",{checked:(0,mt.includes)(t,e==null?void 0:e.id),onClick:d=>{d.stopPropagation(),o(e==null?void 0:e.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"}),"\xA0",n(e.pageType)?(0,ot.jsx)(hu.File,{className:"h-4 w-4"}):(0,ot.jsx)(hu.GlobeIcon,{className:"h-4 w-4"}),(0,ot.jsx)(Ye,{content:e.name,side:"top",showTooltip:e.name.length>25,children:(0,ot.jsx)("span",{className:"max-w-[200px] truncate font-medium",children:e.name})}),e.slug&&(0,ot.jsx)(Ye,{content:e.slug,side:"top",showTooltip:e.slug.length>25,children:(0,ot.jsx)("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:e.slug})})]}),(0,ot.jsx)("td",{className:"px-2",children:r(e==null?void 0:e.pageType)}),(0,ot.jsx)("td",{className:"px-4 text-right",children:(0,mt.first)(e.changes)||""}),(0,ot.jsx)(ot.Fragment,{children:c&&(0,ot.jsxs)("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-destructive/10 px-2 py-0.5 text-xs font-light text-destructive opacity-0 group-hover:opacity-100",children:[(0,ot.jsx)(hu.Edit,{size:12,className:"stroke-[3]"})," ",(0,ot.jsx)("span",{className:"font-medium",children:c})," ",s("is editing this page")]})})]},e==null?void 0:e.id)},Xre=({onClose:e=()=>{},isPending:t,publishPage:o})=>{let{t:r}=(0,qI.useTranslation)(),n=tl(),{pageToUser:a}=Df(),[s,i]=(0,_a.useState)([]),l=Mn(),[c,d]=(0,_a.useState)(l),{data:p,isFetching:u}=lz(),{data:m}=Ht(),g=(0,_a.useCallback)(v=>{var S;return(S=(0,mt.find)(m,{key:v}))==null?void 0:S.hasSlug},[m]),h=(0,_a.useMemo)(()=>(0,mt.filter)(m,v=>!g(v.key)).map(v=>v.key),[g,m]),b=(0,mt.uniq)((0,mt.map)(p,"lang")).filter(Boolean),y=(0,_a.useMemo)(()=>(0,mt.filter)(p,v=>v.pageType==="theme"||v.pageType==="design_tokens"?!1:c===l?v.lang===c||v.lang==="":v.lang===c),[p,c,l]),k=(0,_a.useMemo)(()=>(0,mt.filter)(y,v=>!h.includes(v.pageType)),[y,h]),w=(0,_a.useMemo)(()=>(0,mt.filter)(y,v=>h.includes(v.pageType)),[y,h]);(0,_a.useEffect)(()=>{let v=(0,mt.map)((0,mt.filter)(y,{online:!0}),"id");(0,_a.startTransition)(()=>i(v))},[y]),(0,_a.useEffect)(()=>{let v=(0,mt.filter)((0,mt.keys)(a),S=>(0,mt.get)(a,[S,"userId"])!==n);(0,_a.startTransition)(()=>i(S=>(0,mt.filter)(S,A=>!(0,mt.includes)(v,A))))},[a,n]);let N=(y==null?void 0:y.length)>0&&s.length===(y==null?void 0:y.length),I=v=>{i(S=>(0,mt.includes)(S,v)?(0,mt.filter)(S,A=>A!==v):(0,mt.concat)(S,v))},C=()=>{i(N?[]:(0,mt.map)(y,"id"))},P=()=>{o({ids:(0,mt.uniq)(s)},{onSuccess:()=>{e(),Yg("CENTER_CENTER"),d(l)}})},B=v=>{if(v==="theme")return r("Theme");let S=(0,mt.find)(m,{key:v});return S?S==null?void 0:S.name:v},T=(0,_a.useMemo)(()=>{let v=[...(0,mt.orderBy)((0,mt.filter)(k,{online:!0}),"pageType"),...(0,mt.orderBy)((0,mt.filter)(w,{online:!0}),"pageType")].filter(R=>R.pageType!=="theme"&&R.pageType!=="design_tokens"),S=[...(0,mt.orderBy)((0,mt.filter)(k,{online:!1}),"pageType"),...(0,mt.orderBy)((0,mt.filter)(w,{online:!1}),"pageType")],A=v.length>0?[{label:r("Updated"),top:"pt-2"},...v]:[],D=S.length>0?[{label:r("Offline"),top:"pt-6"},...S]:[];return[...A,...D]},[k,w,r]);return(0,ot.jsxs)(we,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[(0,ot.jsxs)(Oe,{children:[(0,ot.jsx)(Ie,{children:r("Publish changes")}),(0,ot.jsx)(Dt,{className:"text-xs",children:r("Select the pages you want to publish. Click publish when you're done.")})]}),b.length>0&&(0,ot.jsx)("div",{className:"my-[2px] mt-0 w-fit",children:(0,ot.jsx)(zP,{languages:[l,...b],selectedLanguage:c,setSelectedLanguage:d})}),(0,ot.jsx)("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:u?(0,ot.jsxs)("div",{className:"space-y-2 px-1",children:[(0,ot.jsx)("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-muted"}),(0,ot.jsx)("div",{className:"h-6 w-full animate-pulse rounded bg-muted"}),(0,ot.jsx)("div",{className:"h-6 w-full animate-pulse rounded bg-muted"}),(0,ot.jsx)("div",{className:"h-6 w-full animate-pulse rounded bg-muted"})]}):(0,ot.jsxs)("table",{className:"w-full text-left text-xs text-muted-foreground rtl:text-right",children:[(0,ot.jsx)("thead",{className:"sticky top-0 z-10 border-b bg-surface text-muted-foreground",children:(0,ot.jsxs)("tr",{children:[(0,ot.jsxs)("th",{scope:"col",className:"w-[150px] flex items-center gap-x-2 px-6 py-3",children:[!(0,mt.isEmpty)(T)&&(0,ot.jsx)("input",{checked:N,onClick:v=>{v.stopPropagation(),C()},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"}),r("Name")]}),(0,ot.jsx)("th",{scope:"col",className:"w-[150px] px-2 py-3",children:r("Type")}),(0,ot.jsx)("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:r("Status")})]})}),(0,ot.jsx)("tbody",{children:(0,mt.isEmpty)(T)?(0,ot.jsx)("tr",{children:(0,ot.jsx)("td",{colSpan:3,className:"pt-10 text-center text-sm text-muted-foreground",children:r("No changes found")})}):(0,mt.map)(T,v=>v.label?(0,ot.jsx)("tr",{children:(0,ot.jsx)("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-foreground ${v.top}`,children:(0,ot.jsxs)("div",{className:"flex w-full items-center",children:[(0,ot.jsx)("span",{className:"pr-2",children:v.label}),(0,ot.jsx)("div",{className:"flex-1 border-t border-border"})]})})},`separator-${v.label}`):(0,ot.jsx)(Qre,{page:v,selectedPages:s,handleCheckboxChange:I,getPageType:B,hasSlug:g,currentOwnerId:(0,mt.get)(a,[(v==null?void 0:v.primaryPage)||(v==null?void 0:v.id),"userId"])},v.id))})]})}),(0,ot.jsxs)(co,{className:"mt-10 flex items-center justify-center",children:[s.length>0&&(0,ot.jsxs)("span",{className:"text-center text-sm text-muted-foreground",children:[s.length," ",s.length!==1?r("Pages"):r("Page")," ",r("Selected")]}),(0,ot.jsx)(E,{disabled:t,variant:"outline",className:"text-muted-foreground",onClick:e,children:r("Cancel")}),(0,ot.jsx)(E,{loading:t,disabled:u||(0,mt.isEmpty)(s),onClick:P,children:r("Publish Selected")})]})]})},Zre=Xre});function KI({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){let{mutate:o,isPending:r}=NP();return(0,Av.jsx)(Te,{open:e,onOpenChange:r?()=>{}:t,children:e&&(0,Av.jsx)(WP.Suspense,{fallback:(0,Av.jsx)("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:(0,Av.jsx)(ene,{onClose:t,isPending:r,publishPage:o})})})}var WP,Av,ene,gz=x(()=>{"use strict";WP=require("react");wl();qt();Av=require("react/jsx-runtime"),ene=(0,WP.lazy)(()=>Promise.resolve().then(()=>(uz(),mz)))});var Gi,fz,hz,yz=x(()=>{"use strict";Gi=require("lodash-es"),fz=require("react");ko();Ul();hz=()=>{let[e]=Pt(),{data:t}=on();return(0,fz.useCallback)(()=>{if(!t)return{ids:[],names:[],partialBlocksInfo:[]};let r=(0,Gi.filter)(e,l=>l._type==="PartialBlock"),n=(0,Gi.uniq)((0,Gi.compact)(r.map(l=>(0,Gi.get)(l,"partialBlockId","")))),a=(0,Gi.compact)(n.map(l=>{let c=(0,Gi.find)(t,{id:l});if(!c)return null;if(c.online){if(!(0,Gi.isEmpty)(c.changes))return{id:c.id,name:c.name||c.slug||c.id,status:"unpublished_changes"}}else return{id:c.id,name:c.name||c.slug||c.id,status:"unpublished"};return null})),s=a.map(l=>l.id),i=a.map(l=>l.name);return{ids:s,names:i,partialBlocksInfo:a}},[e,t])}});var Ny,YI,JI,Ey,jP=x(()=>{"use strict";Ny=require("lodash-es"),YI=require("lodash-es"),JI=require("react");Tt();er();Gc();An();Uc();Ey=e=>{let{fallbackLang:t}=fe(),{data:o}=ca(),{data:r,isFetching:n}=gn(),a=(0,JI.useMemo)(()=>{let c={[t]:!0};return(0,Ny.each)((0,Ny.get)(o,"languages"),d=>{let p=(0,YI.find)(r,{lang:d});c[d]=!!p}),c},[t,r,o]),{data:s}=Ht(),{data:i}=xt(),l=(0,JI.useMemo)(()=>{let c=(0,YI.find)(s,{key:i==null?void 0:i.pageType});return(c==null?void 0:c.hasSlug)===!1},[i==null?void 0:i.pageType,s]);return n||l||(0,Ny.isEmpty)(e)||e&&a[e]}});var bz,xz=x(()=>{"use strict";Uc();bz=()=>{let{data:e,isLoading:t}=ca(),o=e==null?void 0:e.appChanges,r=o==null?void 0:o.includes("THEME"),n=o==null?void 0:o.includes("DESIGN_TOKENS");return{hasUnpublishedSettings:r||n,hasUnpublishedTheme:r,hasUnpublishedDesignToken:n,isLoading:t}}});var vz={};et(vz,{default:()=>one});var Sd,tne,one,Cz=x(()=>{"use strict";J();qt();Sd=require("react/jsx-runtime"),tne=({isOpen:e,onClose:t,onContinue:o,isPending:r=!1,title:n="Translation Warning",description:a="Some blocks need translations before publishing. Do you want to continue anyway?"})=>(0,Sd.jsx)(Te,{open:e,onOpenChange:t,children:e&&(0,Sd.jsxs)(we,{className:"sm:max-w-[425px]",children:[(0,Sd.jsxs)(Oe,{children:[(0,Sd.jsx)(Ie,{children:n}),(0,Sd.jsx)(Dt,{children:a})]}),(0,Sd.jsxs)(co,{className:"flex gap-2",children:[(0,Sd.jsx)(E,{variant:"outline",onClick:()=>{t()},disabled:r,children:"Cancel"}),(0,Sd.jsx)(E,{loading:r,onClick:()=>{o()},children:"Continue Anyway"})]})]})}),one=tne});var Sz={};et(Sz,{default:()=>nne});var kz,Cn,rne,nne,wz=x(()=>{"use strict";kz=require("react-i18next");Oh();J();qt();Cn=require("react/jsx-runtime"),rne=({isOpen:e,onClose:t,onContinue:o,onViewChanges:r,isPending:n=!1,partialBlocksInfo:a=[]})=>{let{t:s}=(0,kz.useTranslation)();return(0,Cn.jsx)(Te,{open:e,onOpenChange:t,children:e&&(0,Cn.jsxs)(we,{className:"sm:max-w-[425px]",children:[(0,Cn.jsxs)(Oe,{children:[(0,Cn.jsx)(Ie,{children:s("You have some unpublished changes")}),(0,Cn.jsx)(Dt,{children:s("The following partials are either unpublished or have unpublished changes.")})]}),(a==null?void 0:a.length)>0&&(0,Cn.jsx)("div",{className:"max-h-32 overflow-y-auto rounded-md border bg-accent p-2",children:(0,Cn.jsx)("ul",{className:"space-y-1 text-sm",children:a.map(i=>(0,Cn.jsxs)("li",{className:"flex items-center justify-between text-muted-foreground",children:[(0,Cn.jsxs)("span",{className:"flex items-center gap-2 text-foreground",children:[(0,Cn.jsx)("p",{className:`h-2 w-2 rounded-full ${(i==null?void 0:i.status)==="unpublished_changes"?"bg-success":"bg-muted"}`})," ",i==null?void 0:i.name]}),(0,Cn.jsxs)("span",{className:"flex items-center gap-1",children:[(i==null?void 0:i.status)==="unpublished_changes"&&(0,Cn.jsxs)(Cn.Fragment,{children:[(0,Cn.jsx)(bl,{className:"bg-success/10 text-success hover:bg-success/10 px-1.5 py-0 text-[10px]",children:s("Published")}),r&&(0,Cn.jsx)(E,{variant:"link",title:s("View Changes"),size:"xs",className:"text-[10px]",onClick:()=>r(i.id,i.name),children:s("View Changes")})]}),(i==null?void 0:i.status)==="unpublished"&&(0,Cn.jsx)(bl,{className:"bg-orange/10 text-orange hover:bg-orange/10 px-1.5 py-0 text-[10px] font-light",children:s("Unpublished")})]})]},i==null?void 0:i.id))})}),(0,Cn.jsxs)(co,{children:[(0,Cn.jsx)(E,{variant:"outline",size:"sm",onClick:t,disabled:n,children:s("Cancel")}),(0,Cn.jsx)(E,{loading:n,size:"sm",onClick:o,children:s("Publish Partials & Page")})]})]})})},nne=rne});function Tz(e,t){var i,l,c,d;let o=le(),r=he(),n=[e.uid,t.uid].some(p=>(0,Iv.startsWith)(p,"draft:")||(0,Iv.startsWith)(p,"live:")),a=(l=(i=e==null?void 0:e.item)==null?void 0:i.createdAt)!=null?l:null,s=(d=(c=t==null?void 0:t.item)==null?void 0:c.createdAt)!=null?d:null;return(0,Pz.useQuery)({queryKey:["revision-comparison",e.uid,a,t.uid,s],queryFn:async()=>{if(!e.uid||!t.uid)throw new Error("Both revision IDs are required for comparison");let p=g=>g==="draft"||g==="live"?g:"revision",u=g=>(0,Iv.replace)(g.uid,`${g.label}:`,"");return await r(o,{action:$.GET_COMPARE_DATA,data:{versions:{version1:{type:p(e.label),id:u(e)},version2:{type:p(t.label),id:u(t)}}}})},enabled:!!e.uid&&!!t.uid,staleTime:n?0:1/0,refetchOnMount:n?"always":!1,gcTime:n?0:void 0})}var Pz,Iv,Nz=x(()=>{"use strict";Pz=require("@tanstack/react-query"),Iv=require("lodash-es");St();rt();Kt()});var QI={};et(QI,{default:()=>Iz});function sne(e,t,o="data.json"){let r=JSON.stringify(e,null,2),n=JSON.stringify(t,null,2),a=r.split(`
231
+ `),s=n.split(`
232
+ `),i=`--- a/${o}
233
+ `;i+=`+++ b/${o}
234
+ `;let l=[],c=0,d=0;for(;c<a.length||d<s.length;){let m=a[c]||"",g=s[d]||"";if(m===g)l.push(` ${m}`),c++,d++;else{let h=-1,f=-1;for(let b=c+1;b<a.length;b++)if(s[d]===a[b]){h=b;break}for(let b=d+1;b<s.length;b++)if(a[c]===s[b]){f=b;break}if(h!==-1&&(f===-1||h-c<=f-d)){for(let b=c;b<h;b++)l.push(`-${a[b]}`);c=h}else if(f!==-1){for(let b=d;b<f;b++)l.push(`+${s[b]}`);d=f}else m&&l.push(`-${m}`),g&&l.push(`+${g}`),c++,d++}}let p=a.length,u=s.length;return i+=`@@ -1,${p} +1,${u} @@
235
+ `,i+=l.join(`
236
+ `)+`
237
+ `,i}function Bv(e,t=!0,o=!1){if((0,Ss.isString)(e)){let r=(0,Ss.trim)(e);if((0,Ss.startsWith)(r,"{")||(0,Ss.startsWith)(r,"[")||t&&(r==="true"||r==="false"||r==="null"||/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)))try{let a=JSON.parse(r);return Bv(a,t,o)}catch(a){if(o)throw new Error(`Invalid JSON string: ${r}`);return{}}return e}return(0,Ss.isArray)(e)?(0,Ss.map)(e,r=>Bv(r,t,o)):(0,Ss.isPlainObject)(e)?(0,Ss.mapValues)(e,r=>Bv(r,t,o)):e}function Iz({open:e,compare:t,onOpenChange:o}){let r=t[0],n=t[1],[a,s]=(0,uc.useState)(null),[i,l]=(0,uc.useState)("split"),[c,d]=(0,uc.useState)(!1),[p,u]=(0,uc.useState)(!0),[m,g]=(0,uc.useState)("blocks"),{data:h,isLoading:f}=Tz(r,n),{leftData:b,rightData:y,options:k}=(0,uc.useMemo)(()=>{var D,R;let B=(D=h==null?void 0:h.version1)==null?void 0:D[m],T=(R=h==null?void 0:h.version2)==null?void 0:R[m],v=Bv(B),S=Bv(T),A=lne(h==null?void 0:h.version1,h==null?void 0:h.version2);return{leftData:v,rightData:S,options:A}},[h,m]),w=(0,uc.useMemo)(()=>!b||!y?"":sne(b,y),[b,y]),N=(0,uc.useMemo)(()=>{if(!w)return[];try{return(0,Ay.parseDiff)(w)}catch(B){return console.error("Failed to parse diff:",B),[]}},[w]),I=(0,uc.useMemo)(()=>N.some(B=>{var T;return(T=B.hunks)==null?void 0:T.some(v=>{var S;return(S=v.changes)==null?void 0:S.some(A=>A.type!=="normal")})}),[N]),C=async(B,T)=>{try{await navigator.clipboard.writeText(JSON.stringify(B,null,2)),s(T),setTimeout(()=>s(null),2e3)}catch(v){console.error("Failed to copy:",v)}},P=B=>JSON.stringify(B,null,2);return(0,He.jsx)(Te,{open:e,onOpenChange:o,children:(0,He.jsxs)(we,{className:"flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-0",children:[(0,He.jsx)(Oe,{className:"border-b px-3 py-2",children:(0,He.jsxs)(Ie,{className:"flex items-center justify-between gap-2 leading-none",children:[(0,He.jsxs)("div",{className:"flex items-center gap-2",children:["Compare","",(0,He.jsx)(Dr,{value:m,onValueChange:g,children:(0,He.jsx)(Cr,{children:k.map(B=>(0,He.jsx)(ut,{value:B.key,className:"px-3 text-xs",children:B.label},B.key))})})]}),(0,He.jsx)("div",{className:"flex flex-1 items-center justify-end pr-8",children:(0,He.jsxs)("div",{className:"flex w-max items-center justify-end gap-2 divide-x-2 rounded-md border p-1.5",children:[(0,He.jsxs)("div",{className:"flex items-center gap-2 px-2",children:[(0,He.jsx)(On,{disabled:c,checked:c?!0:i==="split",onCheckedChange:B=>l(B?"split":"unified")}),(0,He.jsx)("label",{className:"text-xs font-normal",children:"Split View"})]}),(0,He.jsxs)("div",{className:"flex items-center gap-2 px-2",children:[(0,He.jsx)(On,{checked:c,onCheckedChange:B=>d(B)}),(0,He.jsx)("label",{className:"text-xs font-normal",children:"Show Raw Data"})]}),(0,He.jsxs)("div",{className:"flex items-center gap-2 px-2",children:[(0,He.jsx)(On,{checked:p,onCheckedChange:B=>u(B)}),(0,He.jsx)("label",{className:"text-xs font-normal",children:"Hide Common Data"})]})]})})]})}),f?(0,He.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,He.jsx)(wt,{className:"h-4 w-4"})}):(0,He.jsx)("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:(0,He.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,He.jsxs)("div",{className:"absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2",children:[(0,He.jsx)("div",{className:"flex w-1/2 items-center justify-center gap-2",children:(0,He.jsx)(Ez,{version:r})}),(0,He.jsx)("div",{className:"flex w-1/2 items-center justify-center gap-2",children:(0,He.jsx)(Ez,{version:n})})]}),c?(0,He.jsxs)("div",{className:"grid h-full grid-cols-2 gap-3 rounded-lg border",children:[(0,He.jsxs)("div",{className:"relative flex min-h-0 flex-col border-r",children:[(0,He.jsx)("div",{className:"absolute -top-4 right-4 z-50",children:(0,He.jsxs)(E,{variant:"outline",size:"sm",onClick:()=>C(b,"left"),children:[a==="left"?(0,He.jsx)(yu.Check,{className:"text-green-500"}):(0,He.jsx)(yu.Copy,{}),"Copy"]})}),(0,He.jsx)(qs,{className:"flex-1 rounded-lg bg-surface p-2 text-foreground",children:(0,He.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:P(b)})})]}),(0,He.jsxs)("div",{className:"relative flex min-h-0 flex-col",children:[(0,He.jsx)("div",{className:"absolute -top-4 right-4 z-50",children:(0,He.jsxs)(E,{variant:"outline",size:"sm",onClick:()=>C(y,"right"),children:[a==="right"?(0,He.jsx)(yu.Check,{className:"text-green-500"}):(0,He.jsx)(yu.Copy,{}),"Copy"]})}),(0,He.jsx)(qs,{className:"flex-1 rounded-lg bg-surface p-2 text-foreground",children:(0,He.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:P(y)})})]})]}):(0,He.jsx)(qs,{className:"h-full overflow-y-auto rounded-lg border bg-white",children:N.length===0||!I?(0,He.jsx)("div",{className:"flex h-full min-h-80 items-center justify-center p-6",children:(0,He.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,He.jsx)(yu.FileJson,{className:"mx-auto mb-2 h-8 w-8 opacity-50"}),(0,He.jsx)("p",{children:N.length===0?"No differences found or unable to parse diff":"These versions are identical \u2014 no differences found"})]})}):(0,He.jsx)("div",{children:N.map((B,T)=>(0,He.jsx)("div",{className:"relative mb-4",children:(0,He.jsx)(Ay.Diff,{viewType:i,diffType:B.type,hunks:B.hunks,className:"rounded-lg text-xs",children:v=>v.map((S,A)=>{let D=p?cne(S.changes):S.changes;return(D==null?void 0:D.length)===0?null:(0,He.jsx)(Ay.Hunk,{hunk:{...S,changes:D}},A)}).filter(S=>S!==null)},p?"hide-common-data":"show-common-data")},T))})})]})})]})})}var Az,Ss,yu,uc,Ay,He,ane,Ez,ine,lne,cne,XI=x(()=>{"use strict";"use client";Az=require("date-fns"),Ss=require("lodash-es"),yu=require("lucide-react"),uc=require("react"),Ay=require("react-diff-view");Nz();Hp();Oh();J();qt();Oo();Rh();Wd();xi();He=require("react/jsx-runtime"),ane=({version:e})=>{let t=e==null?void 0:e.item,{data:o}=xa(t==null?void 0:t.currentEditor),r=e.label==="live",n=e.label==="draft";return(0,He.jsxs)("span",{className:"flex min-h-8 items-center gap-x-2 rounded border bg-surface px-2 text-xs text-foreground shadow-lg",children:[(0,He.jsx)("div",{className:"h-full items-center rounded px-1.5 py-0.5 capitalize"+(r?" bg-success":n?" bg-warning":" bg-purple"),children:e.label}),(0,He.jsxs)("div",{className:"py-1 text-xs font-light leading-none",children:[(0,He.jsxs)("div",{children:[(0,He.jsx)("span",{className:"font-light",children:n?"Currently editing":"Published by"}),!n&&(0,He.jsx)("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),(t==null?void 0:t.createdAt)&&(0,He.jsx)("div",{className:"pt-0.5 text-[10px] font-light leading-tight text-muted",children:(0,Az.formatDate)(t.createdAt,"dd MMM yyyy, h:mm a")})]})]})},Ez=({version:e})=>(0,He.jsx)(ane,{version:e});ine=e=>{switch(e){case"blocks":return"Blocks";case"seo":return"SEO";case"tracking":return"Tracking";default:return e}},lne=(e,t)=>{if(!e||!t)return[{key:"blocks",label:"Blocks"}];let o=Object.keys(e),r=Object.keys(t);return o.filter(s=>r.includes(s)).map(s=>({key:s,label:ine(s)})).filter(s=>s.key.length>0)},cne=(e,t=3)=>{let o=new Set;e.map((s,i)=>({change:s,index:i})).filter(({change:s})=>s.type!=="normal").map(({index:s})=>s).forEach(s=>{let i=Math.max(0,s-t),l=Math.min(e.length-1,s+t);for(let c=i;c<=l;c++)o.add(c)});let n=[],a=-1;return e.forEach((s,i)=>{if(o.has(i)){if(a!==-1&&i-a>1){let l=e[a].lineNumber!=null?e[a].lineNumber+1:a+2,c=e[i].lineNumber!=null?e[i].lineNumber-1:i;n.push({lineNumber:-(n.length+1),content:(0,He.jsx)(bl,{className:"pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none",children:(0,He.jsxs)("span",{className:"rounded border border-border bg-surface px-3 py-1 text-[11px] font-light leading-none text-muted-foreground",children:["No changes from ",(0,He.jsx)("span",{className:"font-mono",children:l})," to"," ",(0,He.jsx)("span",{className:"font-mono",children:c})]})})})}n.push(s),a=i}}),n}});function Bz(e){let t=le(),o=he();return(0,bu.useQuery)({queryKey:[$.GET_PAGE_REVISIONS,e],queryFn:async()=>await o(t,{action:$.GET_PAGE_REVISIONS,data:{pageId:e}}),enabled:!!e,refetchOnMount:!0})}var bu,Rz,Dz,_z=x(()=>{"use strict";bu=require("@tanstack/react-query");St();rt();Kt();Rz=()=>{let e=le(),t=he(),o=(0,bu.useQueryClient)();return(0,bu.useMutation)({mutationFn:async r=>await t(e,{action:$.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{o.invalidateQueries({queryKey:[$.GET_PAGE_REVISIONS]})}})},Dz=()=>{let e=le(),t=he(),o=(0,bu.useQueryClient)();return(0,bu.useMutation)({mutationFn:async({revisionId:r,discardCurrent:n,pageId:a})=>await t(e,{action:$.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:n,...a&&{pageId:a}}}),onSuccess:()=>{o.invalidateQueries({queryKey:[$.GET_PAGE_ALL_DATA]}),o.invalidateQueries({queryKey:[$.GET_PAGE_REVISIONS]})}})}});var Hz={};et(Hz,{default:()=>Fz});function mne(){return(0,se.jsx)("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>(0,se.jsxs)("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[(0,se.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,se.jsx)("div",{className:"h-4 w-3/4 animate-pulse rounded bg-muted/30"}),(0,se.jsx)("div",{className:"h-3 w-1/2 animate-pulse rounded bg-muted/30"}),(0,se.jsx)("div",{className:"mt-1 h-5 w-20 animate-pulse rounded bg-muted/30"})]}),(0,se.jsx)("div",{className:"h-8 w-8 animate-pulse rounded-full bg-muted/30"})]},t))})}function une({revision:e,isLatest:t,onRestore:o,onDelete:r,revisionNumber:n,compare:a,setCompare:s,pageId:i}){let{data:l}=xa(e.currentEditor),c=(l==null?void 0:l.name)||"Unknown",d=!!a.find(u=>{var m;return t?(m=u==null?void 0:u.uid)==null?void 0:m.startsWith("live"):(u==null?void 0:u.uid)===e.uid}),p=a.length>=2&&!d;return(0,se.jsxs)("div",{className:"relative flex items-start gap-3 rounded-md border p-2 text-foreground",children:[(0,se.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,se.jsx)("div",{className:"flex items-center justify-between",children:(0,se.jsxs)("p",{className:"flex items-center gap-1 text-[11px] font-light leading-none",children:[(0,se.jsx)(Oz,{tag:t?"live":`#${n}`}),e.type==="published"?"Published":"Draft","\xA0by ",(0,se.jsx)("span",{className:"font-normal",children:c})]})}),(0,se.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,se.jsx)("div",{className:"flex items-center gap-1 font-medium opacity-80",children:e.type==="published"?(0,se.jsx)("span",{className:"text-[11px] leading-tight text-success",children:"Published"}):(0,se.jsx)("span",{className:"text-[11px] leading-tight text-warning",children:"Draft"})}),(0,se.jsx)("div",{className:"flex items-center text-[10px] text-muted-foreground",children:(0,se.jsx)("span",{className:"font-light leading-tight",children:pne(e.createdAt)})})]})]}),(0,se.jsx)("div",{className:"flex items-center gap-2",children:(0,se.jsx)(ni,{permissions:[xe["revisions:restore"],xe["revisions:delete"]],children:(0,se.jsx)(hne,{revision:e,onRestore:o,onDelete:r})})}),(0,se.jsx)(fne,{checked:d,disabled:p,onChange:()=>{s(d?a.filter(u=>t?u.uid!==`live:${i}`:u.uid!==e.uid):[...a,{uid:t?`live:${i}`:e.uid,label:t?"live":`#${n}`,item:e}].sort((u,m)=>new Date(u.item.createdAt).getTime()-new Date(m.item.createdAt).getTime()))}})]})}function Lz({tab:e,onRemove:t}){return(0,se.jsxs)("span",{className:"flex items-center justify-between gap-x-px rounded border bg-secondary p-0 pl-[2px] font-medium",children:[(0,se.jsx)(Oz,{tag:e.label,className:"rounded-sm"}),(0,se.jsx)(E,{variant:"link",size:"icon-xs",onClick:()=>t(e.uid),"aria-label":"Remove selection",className:"text-foreground/50 hover:text-foreground",children:(0,se.jsx)(xu.X,{className:"h-2.5 w-2.5"})})]})}function gne({compare:e,setCompare:t,pageId:o}){let[r,n]=(0,gc.useState)(!1),[a,s]=e;if(e.length===0)return null;let i=l=>t(e.filter(c=>c.uid!==l));return(0,se.jsxs)("div",{className:"flex w-full max-w-md flex-col gap-2 rounded border bg-accent/60 px-2 pb-2 pt-1 shadow-sm",children:[(0,se.jsxs)("div",{className:"flex items-center gap-x-2 text-xs",children:[(0,se.jsx)("span",{className:"font-medium leading-tight text-muted-foreground",children:"Compare"}),a&&(0,se.jsx)(Lz,{tab:a,onRemove:i}),(0,se.jsx)("span",{className:"font-medium leading-tight text-muted-foreground",children:"with"}),s?(0,se.jsx)(Lz,{tab:s,onRemove:i}):(0,se.jsx)("span",{className:"rounded border px-2 py-1 text-xs italic text-muted-foreground",children:"Choose another"})]}),(0,se.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,se.jsx)(E,{size:"xs",variant:"ghost",className:"px-3 py-1",onClick:()=>t([]),children:"Clear"}),(0,se.jsx)(E,{size:"xs",variant:"default",className:"px-3 py-1",onClick:()=>n(!0),disabled:e.length<2,children:"Show Diff (JSON)"})]}),r&&(e==null?void 0:e.length)>1&&o&&(0,se.jsx)(gc.Suspense,{fallback:null,children:(0,se.jsx)(dne,{open:r,onOpenChange:n,compare:e})})]})}function fne({checked:e,disabled:t,onChange:o,label:r="Compare"}){return(0,se.jsx)("div",{className:"absolute bottom-2 right-2",children:(0,se.jsxs)(Q,{className:"flex items-center gap-x-1",children:[(0,se.jsx)(Ia,{checked:e,disabled:t,onCheckedChange:o}),r]})})}function hne({revision:e,onRestore:t,onDelete:o}){return(0,se.jsxs)(Yt,{children:[(0,se.jsx)($t,{asChild:!0,children:(0,se.jsxs)(E,{variant:"ghost",size:"icon-xs",className:"-mr-1 -mt-0.5",children:[(0,se.jsx)(xu.MoreHorizontal,{}),(0,se.jsx)("span",{className:"sr-only",children:"More options"})]})}),(0,se.jsxs)(Vt,{align:"end",className:"text-xs",children:[(0,se.jsx)(ni,{permission:xe["revisions:restore"],children:(0,se.jsxs)(ye,{onClick:t,children:[(0,se.jsx)(xu.RotateCcw,{className:"h-4 w-4"}),"Restore this version"]})}),e.uid!=="current"&&(0,se.jsx)(Hn,{}),e.uid!=="current"&&(0,se.jsx)(ni,{permission:xe["revisions:delete"],children:(0,se.jsxs)(ye,{onClick:o,className:"text-destructive",children:[(0,se.jsx)(xu.Trash,{className:"h-3.5 w-3.5"}),"Delete this version"]})})]})]})}function yne({open:e,onOpenChange:t,revision:o,onRestore:r,isRestoring:n}){let{data:a}=xa((o==null?void 0:o.currentEditor)||""),s=(a==null?void 0:a.name)||"Unknown";return o?(0,se.jsx)(Te,{open:e,onOpenChange:i=>{n||t(i)},children:(0,se.jsxs)(we,{className:"sm:max-w-md",children:[(0,se.jsxs)(Oe,{children:[(0,se.jsx)(Ie,{children:"Restore Revision"}),(0,se.jsxs)(Dt,{children:["You are about to restore to revision ",o.uid.substring(0,8)," from"," ",(0,Dv.format)(o.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",s]})]}),(0,se.jsx)("div",{className:"py-2",children:(0,se.jsx)("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),(0,se.jsxs)(co,{className:"flex items-center justify-end gap-x-1",children:[(0,se.jsx)(E,{variant:"outline",size:"sm",loading:n,onClick:()=>r(!1),children:"Save as draft"}),(0,se.jsx)(E,{variant:"default",size:"sm",loading:n,onClick:()=>r(!0),children:"Discard current"})]})]})}):null}function bne({open:e,onOpenChange:t,revision:o,onDelete:r,isDeleting:n}){let{data:a}=xa((o==null?void 0:o.currentEditor)||""),s=(a==null?void 0:a.name)||"Unknown";return o?(0,se.jsx)(Te,{open:e,onOpenChange:i=>{n||t(i)},children:(0,se.jsxs)(we,{className:"sm:max-w-md",children:[(0,se.jsxs)(Oe,{children:[(0,se.jsx)(Ie,{children:"Delete Revision"}),(0,se.jsxs)(Dt,{children:["You are about to delete revision ",o.uid.substring(0,8)," from"," ",(0,Dv.format)(o.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",s]})]}),(0,se.jsx)("div",{className:"py-2",children:(0,se.jsx)("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),(0,se.jsxs)(co,{className:"flex items-center justify-end gap-x-1",children:[(0,se.jsx)(E,{variant:"outline",size:"sm",onClick:()=>t(!1),disabled:n,children:"Cancel"}),(0,se.jsx)(E,{variant:"destructive",size:"sm",loading:n,onClick:r,children:"Delete"})]})]})}):null}function Fz({isOpen:e}){let[t,o]=Rv.useState([]),[r,n]=Rv.useState(null),[a,s]=Rv.useState(!1),[i,l]=Rv.useState(!1),{data:c}=xt(),{data:d,isFetching:p,error:u,refetch:m}=Bz(c==null?void 0:c.id),{mutate:g,isPending:h}=Rz(),{mutate:f,isPending:b}=Dz(),y=(0,Mz.useQueryClient)(),{selectedLang:k,fallbackLang:w}=fe(),N=k||w;(0,gc.useEffect)(()=>{(0,gc.startTransition)(()=>o([]))},[c==null?void 0:c.id]);let I=T=>{r&&f({revisionId:r.uid,discardCurrent:T,...r.uid==="current"&&(c==null?void 0:c.id)&&{pageId:c.id}},{onSuccess:()=>{s(!1),n(null),y.invalidateQueries({queryKey:[$.GET_PAGE_ALL_DATA]})}})},C=T=>{n(T),s(!0)},P=T=>{n(T),l(!0)},B=()=>{r&&g(r.uid,{onSuccess:()=>{l(!1),n(null)}})};return(0,gc.useEffect)(()=>{e&&m()},[e,m]),(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)($g,{children:[(0,se.jsx)(Vg,{children:"Revision History"}),(c==null?void 0:c.createdAt)&&(0,se.jsxs)("p",{className:"text-xs font-light leading-none text-muted",children:["Page created on ",(0,Dv.format)(new Date(c.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),p?(0,se.jsx)(mne,{}):u?(0,se.jsx)("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):(0,se.jsxs)("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[(0,se.jsx)(gne,{lang:N,compare:t,setCompare:o,pageId:c==null?void 0:c.id}),(0,se.jsx)(qs,{className:"min-h-0 flex-1",children:(0,se.jsx)("div",{className:"space-y-2",children:[...d!=null?d:[]].sort((T,v)=>new Date(v.createdAt).getTime()-new Date(T.createdAt).getTime()).map((T,v)=>(0,se.jsx)(une,{pageId:c==null?void 0:c.id,revision:T,isLatest:T.uid==="current",onRestore:()=>C(T),onDelete:()=>P(T),revisionNumber:v+1,compare:t,setCompare:o},T.uid))})})]}),(0,se.jsx)(yne,{open:a,onOpenChange:s,revision:r,onRestore:I,isRestoring:b}),(0,se.jsx)(bne,{open:i,onOpenChange:l,revision:r,onDelete:B,isDeleting:h})]})}var Mz,Dv,xu,Rv,gc,se,dne,pne,Oz,Uz=x(()=>{"use strict";"use client";Mz=require("@tanstack/react-query"),Dv=require("date-fns"),xu=require("lucide-react"),Rv=K(require("react"),1),gc=require("react");Tt();wv();St();er();_z();Hp();J();Pg();qt();Sr();No();Rh();dv();tn();st();se=require("react/jsx-runtime"),dne=(0,gc.lazy)(()=>Promise.resolve().then(()=>(XI(),QI))),pne=e=>{let t=new Date(e),o=t.getTime();if(Number.isNaN(o))return"Unknown date";let r=Math.max(0,Math.floor((Date.now()-o)/1e3));if(r<60)return`${r} second${r===1?"":"s"} ago`;let n=Math.floor(r/60);return n<60?`${n} minute${n===1?"":"s"} ago`:(0,Dv.format)(t,"MMM d, yyyy, h:mm a")},Oz=({tag:e,className:t=""})=>(0,se.jsx)("span",{className:G("flex items-center justify-center rounded-sm bg-muted/10 px-1.5 py-0.5 text-center font-sans text-xs capitalize text-foreground",t),children:e})});var zz={};et(zz,{default:()=>Vz});function xne(){return(0,si.jsx)("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>(0,si.jsxs)("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[(0,si.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,si.jsx)(da,{className:"h-4 w-3/4"}),(0,si.jsx)(da,{className:"h-3 w-1/2"}),(0,si.jsx)(da,{className:"mt-1 h-5 w-20"})]}),(0,si.jsx)(da,{className:"h-8 w-8 rounded-full"})]},t))})}function Vz({isOpen:e,setIsOpen:t}){return(0,si.jsx)(cy,{open:e,onOpenChange:t,children:(0,si.jsx)(Gg,{className:"flex h-[100vh] w-96 flex-col",children:e&&(0,si.jsx)($z.Suspense,{fallback:(0,si.jsx)(xne,{}),children:(0,si.jsx)(vne,{isOpen:e})})})})}var Gz,$z,si,vne,Wz=x(()=>{"use strict";Gz=K(require("react"),1),$z=require("react");dv();Lf();si=require("react/jsx-runtime");vne=Gz.lazy(()=>Promise.resolve().then(()=>(Uz(),Hz)))});function ZI(){let{isLocked:e}=rn(),[t]=Go(),o=t.get("lang"),r=Ey(o);return e||!r?(0,de.jsx)("div",{}):(0,de.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,de.jsx)(ni,{permission:xe["theme:edit"],children:(0,de.jsx)(Tne,{})}),(0,de.jsx)(Pne,{}),(0,de.jsx)(ni,{permission:xe["pages:update"],children:(0,de.jsx)(Nne,{})}),(0,de.jsx)(ni,{permission:xe["pages:publish"],children:(0,de.jsx)(Ene,{})}),(0,de.jsx)(Ane,{}),(0,de.jsx)(Br,{slotId:jo.TOPBAR_RIGHT})]})}var vu,kn,jt,Iy,de,Cne,kne,Sne,jz,wne,Pne,Tne,Nne,Ene,Ane,qz=x(()=>{"use strict";vu=require("lodash-es"),kn=require("lucide-react"),jt=require("react"),Iy=require("react-i18next");ZV();Tt();Nn();FP();Vc();wv();gz();wl();er();yz();jP();rt();xz();kI();cs();jI();ea();Rr();J();Sr();Oo();lm();tn();ps();de=require("react/jsx-runtime"),Cne=(0,jt.lazy)(()=>Promise.resolve().then(()=>(kv(),Cv))),kne=(0,jt.lazy)(()=>Promise.resolve().then(()=>(Cz(),vz))),Sne=(0,jt.lazy)(()=>Promise.resolve().then(()=>(wz(),Sz))),jz=(0,jt.lazy)(()=>Promise.resolve().then(()=>(XI(),QI))),wne=(0,jt.lazy)(()=>Promise.resolve().then(()=>(Wz(),zz))),Pne=()=>{let{t:e}=(0,Iy.useTranslation)(),t=f1();return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(Ye,{content:e("Open preview in new tab"),delayDuration:0,children:(0,de.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,de.jsx)(E,{variant:"ghost",size:"icon-sm",children:(0,de.jsx)(kn.CirclePlay,{className:"h-4 w-4"})})})}),(0,de.jsx)("div",{className:"h-4 w-px border-l bg-transparent"})]})},Tne=()=>{let{t:e}=(0,Iy.useTranslation)(),[t,o]=Mb();return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(Ye,{content:e("Theme"),delayDuration:0,children:(0,de.jsx)(E,{variant:t==="theme"?"outline":"ghost",size:"icon-sm",onClick:()=>o(t==="theme"?"block":"theme"),children:(0,de.jsx)(kn.Palette,{className:"h-4 w-4"})})}),(0,de.jsx)("div",{className:"h-4 w-px border-l bg-transparent"})]})},Nne=()=>{let{t:e}=(0,Iy.useTranslation)(),[t,o]=(0,jt.useState)(!1),{isLocked:r}=rn(),{savePageAsync:n,saveState:a}=to(),{errors:s,hasErrors:i,hasWarnings:l}=fu(),[c,d]=(0,jt.useState)(!1);(0,jt.useEffect)(()=>{let b=y=>{a==="UNSAVED"&&(y.preventDefault(),y.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",b),()=>{window.removeEventListener("beforeunload",b)}},[a]);let p=(0,jt.useCallback)(async()=>{if(!t){o(!0);try{await n()}finally{o(!1)}}},[n,t]),u=(0,jt.useCallback)(async()=>{if(i||l){d(!0);return}await p()},[i,l,p]),m=(0,jt.useCallback)(async()=>{d(!1),await p()},[p]),{buttonIcon:g,buttonClass:h,tooltipContent:f}=(0,jt.useMemo)(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:(0,de.jsx)(kn.Save,{className:"h-4 w-4"}),buttonClass:"bg-accent"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:(0,de.jsx)(wt,{className:"h-4 w-4"}),buttonClass:""};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:(0,de.jsx)(kn.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-success bg-success/10 hover:bg-success/10 hover:text-success"}}},[a,e]);return r?null:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(Ye,{content:f,children:(0,de.jsx)(E,{size:"icon-sm",variant:"ghost",onClick:u,className:`${h}`,children:g})}),(0,de.jsx)(VI,{isOpen:c,onClose:()=>d(!1),onContinue:m,errors:s,actionLabel:e("Save anyway")})]})},Ene=()=>{let{t:e}=(0,Iy.useTranslation)(),t=Nt("flags.bulkPublish",!1),{selectedLang:o}=fe(),{data:r}=dr(),n=hz(),[a,s]=(0,jt.useState)(!1),[,i]=(0,jt.useState)(!1),[l,c]=(0,jt.useState)(null),[d,p]=(0,jt.useState)(!1),{savePageAsync:u}=to(),[m,g]=(0,jt.useState)(!1),{hasUnpublishedSettings:h,hasUnpublishedTheme:f,hasUnpublishedDesignToken:b}=bz(),[y,k]=(0,jt.useState)(!1),[w,N]=(0,jt.useState)([]),[I,C]=(0,jt.useState)([]),[P,B]=(0,jt.useState)(null),{errors:T,hasErrors:v,hasWarnings:S}=fu(),[A,D]=(0,jt.useState)(!1),R=TP(),[H,M]=(0,jt.useState)(!1),{data:L}=xt(),{mutate:z,isPending:_}=NP(),{needTranslations:F}=to(),O=F(),{buttonText:U,buttonClassName:j,isPublished:ce,hasUnpublishedChanges:pe}=(0,jt.useMemo)(()=>{let Z=L&&(L==null?void 0:L.online),ge=!(0,vu.isEmpty)(L==null?void 0:L.changes),Rt=Z?"hover:bg-success/80 bg-success":"",sr=e(Z?"Published":"Publish");return Z&&ge&&(Rt="hover:bg-blue-600 bg-blue-500",sr=e("Publish")),{buttonClassName:Rt,isPublished:Z,hasUnpublishedChanges:ge,buttonText:sr}},[L,e]),ve=(0,jt.useCallback)(Z=>{let{ids:ge,partialBlocksInfo:Rt}=n();ge.length>0?(N(ge),C(Rt),k(!0)):z({ids:(0,vu.compact)(Z)},{onSuccess:()=>Yg("TOP_RIGHT")})},[n,z]),Ve=(0,jt.useCallback)(()=>{if(O){g(!0);return}ve([r==null?void 0:r.id,r==null?void 0:r.primaryPage])},[O,ve,r]),ze=async()=>{if(v||S){D(!0);return}Ve()},bt=()=>{D(!1),Ve()},W=Z=>{let ge=[r==null?void 0:r.id,r==null?void 0:r.primaryPage,...Array.isArray(Z)?Z:[]];z({ids:(0,vu.compact)(ge)},{onSuccess:()=>Yg("TOP_RIGHT")})},ie=()=>{k(!1),W(w),N([]),C([])},Y=()=>{k(!1),N([]),C([])},Ze=(0,jt.useCallback)((Z,ge)=>{B({id:Z,name:ge})},[]),te=()=>{g(!1),ve([r==null?void 0:r.id,r==null?void 0:r.primaryPage])},Qe=async()=>{g(!1),await u()};return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("div",{className:"flex pl-0.5",children:[(0,de.jsxs)(E,{size:"sm",onClick:ze,loading:_,disabled:_||!(L!=null&&L.id),className:`rounded-r-none duration-300 ${j}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[U,o?`(${(0,vu.upperCase)(o)})`:""]}),(0,de.jsxs)(Yt,{children:[(0,de.jsx)($t,{asChild:!0,children:(0,de.jsxs)(E,{size:"sm",disabled:_||!(L!=null&&L.id),className:`relative rounded-l-none border-l-[0.5px] border-border px-1.5 text-foreground ${h?"bg-muted/60 hover:bg-muted/90":j}`,children:[(0,de.jsx)(kn.ChevronDown,{className:"h-3 w-3 text-current"}),h&&(0,de.jsx)("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-warning"})]})}),(0,de.jsxs)(Vt,{align:"end",className:"w-max",children:[(0,de.jsx)(Ua,{children:e("Page")}),ce&&pe&&(0,de.jsxs)(ye,{onClick:()=>p(!0),className:"cursor-pointer text-xs",children:[(0,de.jsx)(kn.Eye,{className:"h-3 w-3"}),e("View Unpublished changes")]}),!ce&&(0,de.jsxs)(ye,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>ve([L==null?void 0:L.id]),children:[(0,de.jsx)(kn.Send,{className:"mr-0.5 h-3 w-3"}),e("Publish")," page"]}),t&&(0,de.jsxs)(ye,{onClick:()=>s(!0),className:"cursor-pointer text-xs",children:[(0,de.jsx)(kn.Layers,{className:"mr-0.5 h-3 w-3"}),e("Open publish menu")]}),ce&&(0,de.jsxs)(ye,{onClick:()=>c(r),className:"cursor-pointer text-xs",children:[(0,de.jsx)(kn.TriangleAlert,{className:"mr-0.5 h-3 w-3"}),e("Unpublish")," page ",o?`(${(0,vu.upperCase)(o)})`:""]}),h&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(Hn,{className:"bg-border"}),(0,de.jsx)(Ua,{children:e("Unpublished website settings")})]}),f&&(0,de.jsx)(ye,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>z({ids:["THEME"]},{onSuccess:()=>Yg("TOP_RIGHT")}),children:(0,de.jsxs)("span",{className:"flex h-full w-full items-center gap-2",children:[(0,de.jsx)("span",{className:"mt-0.5 h-1 w-1 animate-pulse rounded-full bg-orange-500"}),e("Publish")," theme"]})}),b&&(0,de.jsx)(ye,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>z({ids:["DESIGN_TOKENS"]},{onSuccess:()=>Yg("TOP_RIGHT")}),children:(0,de.jsxs)("span",{className:"flex h-full w-full items-center gap-2",children:[(0,de.jsx)("span",{className:"mt-0.5 h-1 w-1 animate-pulse rounded-full bg-orange-500"}),e("Publish")," design token"]})}),R&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(Hn,{className:"bg-border"}),(0,de.jsx)(Ua,{children:e("Revisions")}),(0,de.jsxs)(ye,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>M(!0),children:[(0,de.jsx)(kn.RotateCcw,{className:"h-3 w-3"}),e("View revisions")]})]})]})]})]}),(0,de.jsx)(KI,{showModal:a,onClose:()=>s(!1)}),l&&(0,de.jsx)(jt.Suspense,{children:(0,de.jsx)(Cne,{page:l,onClose:()=>c(null)})}),d&&(0,de.jsx)(jt.Suspense,{children:(0,de.jsx)(jz,{open:d,onOpenChange:p,compare:[{label:"live",uid:`live:${L==null?void 0:L.id}`,item:{}},{label:"draft",uid:`draft:${L==null?void 0:L.id}`,item:L}]})}),m&&(0,de.jsx)(jt.Suspense,{children:(0,de.jsx)(kne,{isOpen:m,onClose:Qe,onContinue:te,isPending:_})}),y&&(0,de.jsx)(jt.Suspense,{children:(0,de.jsx)(Sne,{isOpen:y,onClose:Y,onContinue:ie,onViewChanges:Ze,isPending:_,partialBlocksInfo:I})}),P&&(0,de.jsx)(jt.Suspense,{children:(0,de.jsx)(jz,{open:!!P,onOpenChange:Z=>{Z||(B(null),k(!0))},compare:[{label:"live",uid:`live:${P.id}`,item:{}},{label:"draft",uid:`draft:${P.id}`,item:{}}]})}),H&&(0,de.jsx)(jt.Suspense,{children:(0,de.jsx)(wne,{isOpen:H,setIsOpen:M})}),(0,de.jsx)(VI,{isOpen:A,onClose:()=>D(!1),onContinue:bt,errors:T,actionLabel:e("Publish anyway")})]})},Ane=()=>{let{t:e}=(0,Iy.useTranslation)(),{data:t}=xt(),o=g1();return(t==null?void 0:t.online)?(0,de.jsx)(Ye,{content:e("Open live page"),delayDuration:0,children:(0,de.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,de.jsx)(E,{variant:"ghost",size:"icon-sm",children:(0,de.jsx)(kn.ExternalLink,{className:"h-4 w-4"})})})}):null}});var By,eB,Kz,Yz,tB=x(()=>{"use strict";By=require("jotai"),eB=(0,By.atom)(!1);eB.debugLabel="pageManagerOpenAtom";Kz=()=>(0,By.useAtom)(eB),Yz=()=>(0,By.useSetAtom)(eB)});var Jz,Qz,_v,Ine,Xz,Zz=x(()=>{"use strict";Jz=require("lucide-react"),Qz=require("react-i18next");Nn();tB();ps();ea();J();_v=require("react/jsx-runtime"),Ine=({children:e})=>{let{t}=(0,Qz.useTranslation)(),o=Yz(),{savePage:r}=to(),{isLocked:n}=rn();return(0,_v.jsx)(Ye,{content:t("Open pages manager"),onClick:()=>{n||r(),o(!0)},children:e||(0,_v.jsxs)(E,{variant:"ghost",size:"sm",children:[(0,_v.jsx)(Jz.Files,{}),t("Pages")]})})},Xz=Ine});var oB,Sn,Bne,eW,tW=x(()=>{"use strict";oB=require("lucide-react");zm();Ke();DV();Tv();qz();er();Rr();lm();Zz();Tv();Tt();Sn=require("react/jsx-runtime"),Bne=()=>{let{isFetching:e}=dr(),{isFetching:t}=xt(),o=e||t,r=q("flags.pagesManager",!0),{languages:n}=fe(),a=n&&n.length>0;return(0,Sn.jsx)("div",{className:"relative flex items-center",children:(0,Sn.jsxs)("div",{className:"flex items-center",children:[a&&(0,Sn.jsxs)(Sn.Fragment,{children:[(0,Sn.jsx)(wy,{}),(0,Sn.jsx)(oB.ChevronRight,{"data-testid":"pages-manager-chevron",className:"mx-px h-4 w-4 flex-shrink-0 text-foreground/60"})]}),r&&(0,Sn.jsx)("div",{className:Co("flex h-7 items-center",o&&"max-w-0 overflow-hidden opacity-0"),children:(0,Sn.jsx)(Xz,{})}),r&&(0,Sn.jsx)(oB.ChevronRight,{"data-testid":"pages-manager-chevron",className:"mx-px h-4 w-4 flex-shrink-0 text-foreground/60"}),(0,Sn.jsx)("div",{className:Co("flex h-7 items-center",o&&"max-w-0 overflow-hidden opacity-0"),children:(0,Sn.jsx)(RV,{})})]})})},eW=()=>(0,Sn.jsxs)("div",{className:"grid h-full w-full grid-cols-3 py-1 items-center bg-background px-2",children:[(0,Sn.jsx)("div",{className:"flex justify-start",children:(0,Sn.jsx)(GI,{})}),(0,Sn.jsxs)("div",{className:"flex justify-center",children:[(0,Sn.jsx)(Bne,{}),(0,Sn.jsx)(Br,{slotId:jo.TOPBAR_CENTER})]}),(0,Sn.jsx)("div",{className:"flex items-center justify-end",children:(0,Sn.jsx)(ZI,{})})]})});var Ry,oW,rW,nW=x(()=>{"use strict";Ry=require("lodash-es"),oW=require("react");Ne();rW=e=>(0,oW.useMemo)(()=>{if(!e||(0,Ry.isEmpty)(e))return{blocks:[]};let t=(0,Ry.filter)(e,o=>!(0,Ry.includes)(o==null?void 0:o._type,"@chai/"));return{blocks:hi(t)}},[e])});var aW,sW,iW,lW=x(()=>{"use strict";aW=require("@tanstack/react-query"),sW=require("sonner");Ob();St();Kt();rt();iW=()=>{let e=le(),t=he(),{handleQuerySync:o}=Gd();return(0,aW.useMutation)({mutationFn:async r=>t(e,{action:$.UPDATE_WEBSITE_FIELDS,data:r}),onSuccess:(r,n)=>{o({type:"UPDATE_WEBSITE_DATA",data:n,sync:!0})},onError:r=>{sW.toast.error("Failed to update website settings",{description:r.message})}})}});var cW,dW,rB,Lv,nB=x(()=>{"use strict";cW=require("@tanstack/react-query"),dW=require("lodash-es"),rB=require("sonner");A0();E0();rt();Lv=(e=300)=>{let t=Nt("onLogout",dW.noop),o=Nt("getAccessToken"),r=le();return(0,cW.useQuery)({queryKey:["check-user-access"],queryFn:async()=>{let n=await o(),a="check_user_access",s=await zC(r+(a?`?action=${a}`:""),{action:"CHECK_USER_ACCESS"},{Authorization:`Bearer ${n}`}),i=await s.json();if(s.status===401||ju(i)&&i.error.status===401)throw rB.toast.error("You do not have access to edit this website. Please contact administrator"),await t("UNAUTHORIZED"),new Error("Unauthorized");if(!s.ok||ju(i))throw rB.toast.error("You do not have access to edit this website. Please contact administrator"),await t("UNAUTHORIZED"),new Error("Unauthorized");return WC(i,s.status)},refetchInterval:e*1e3,refetchIntervalInBackground:!0,retry:!1})}});var pW,mW,uW,gW=x(()=>{"use strict";pW=require("@tanstack/react-query");Ob();St();er();rt();Kt();zu();mW=require("lodash-es"),uW=()=>{let e=le(),t=he(),[,o]=p1(),r=(0,pW.useQueryClient)(),{handleQuerySync:n}=Gd(),[a]=el(),s=(0,mW.get)(a,"flags.draftsInRevisions",!1);return{onSave:async({page:l,blocks:c,needTranslations:d,partialIds:p,linkPageIds:u,designTokens:m})=>{try{let g=await t(e,{action:"UPDATE_PAGE",data:{id:l,blocks:c,needTranslations:d,partialIds:p,linkPageIds:u,designTokens:m,addInRevision:s}});return g.code==="PAGE_LOCKED"?!0:(o(h=>({...h,lastSaved:new Date().toISOString()})),r.invalidateQueries({queryKey:[$.GET_CHANGES],refetchType:"all"}),r.setQueryData([$.GET_LANGUAGE_PAGES,l],h=>h&&(h==null?void 0:h.map(f=>(f==null?void 0:f.id)===l?{...f,changes:["Page"]}:f))),n({type:"UPDATE_PAGE_DATA",data:{pageId:l,partialIds:p,linkPageIds:u,designTokens:m},sync:!0}),g)}catch(g){return console.error(g),new Error("Failed to save blocks")}}}}});var Cu,aB,fW,hW=x(()=>{"use strict";Cu=require("lodash-es"),aB=require("react");Ul();rt();Kt();fW=()=>{let{data:e}=on(),t=le(),o=he();return{getPartialBlocks:(0,aB.useCallback)(async()=>{var n,a;let r={};for(let s of e!=null?e:[])(0,Cu.isEmpty)(s==null?void 0:s.slug)&&(r[s.id]={type:s.pageType,name:(0,Cu.startCase)((n=s.name)!=null?n:s.slug),description:typeof((a=s.metadata)==null?void 0:a.description)=="string"?s.metadata.description:""});return r},[e]),getPartialBlockBlocks:(0,aB.useCallback)(async r=>{if(!r)return[];try{let n=await o(t,{action:"GET_DRAFT_PAGE",data:{id:r,draft:!0,editor:!1,mergePartials:!0}});return(0,Cu.filter)(n.blocks,a=>(0,Cu.has)(a,"_id"))}catch(n){return console.error(n),[]}},[o,t])}}});var yW,Mv,Rne,bW,xW=x(()=>{"use strict";yW=K(require("react"),1),Mv=require("react/jsx-runtime"),Rne={display:"flex",alignItems:"center",zIndex:1},bW=yW.default.memo(function({top:t,left:o,indent:r}){let n={position:"absolute",pointerEvents:"none",top:t-1+"px",left:"0px",right:0,paddingLeft:o+r+"px"};return(0,Mv.jsxs)("div",{style:{...Rne,...n},children:[(0,Mv.jsx)("div",{className:"bg-success h-1 w-1 rounded-full"}),(0,Mv.jsx)("div",{className:"border-success h-[1px] flex-1 rounded-[1px] border-t"})]})})});function CW(e){e.firstNode&&e.select(e.firstNode.id)}function kW(e){e.lastNode&&e.select(e.lastNode.id)}function SW(e){let t=e.selectedNodes[0].next||e.firstNode;e.select(t.id)}function wW(e){let t=e.selectedNodes[0].prev||e.lastNode;e.select(t.id)}var vW,PW,TW,NW,EW=x(()=>{"use strict";vW=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];PW=(e,t)=>{let o=e.selectedNodes[0],r=(o==null?void 0:o.parent)||null;r&&t&&e.select(r.id)},TW=(e,t)=>{let o=e.selectedNodes[0];o.isInternal&&t&&o.open()},NW=(e,t)=>{let o=e.selectedNodes[0];o.isInternal&&t&&o.close()}});var AW,fc,$i,IW,qP,Nr,BW,RW,DW=x(()=>{"use strict";AW=require("jotai"),fc=require("lodash-es"),$i=require("react"),IW=require("react-i18next"),qP=require("sonner");Wr();pn();ko();Ke();VP();Nn();wl();An();J();qt();fo();No();gs();Gs();Nr=require("react/jsx-runtime"),BW=(e,t)=>{let o=(0,fc.filter)(e,{_parent:t});if(o.length===0)return[];let r=[...o];return o.forEach(n=>{r.push(...BW(e,n==null?void 0:n._id))}),r},RW=()=>{let{t:e}=(0,IW.useTranslation)(),t=$P(),[o,r]=(0,AW.useAtom)(UC),[n]=Pt(),{replaceBlocks:a}=Ft(),{data:s}=Ht(),{mutateAsync:i,isPending:l}=yy(),{savePageAsync:c}=to(),d=q("gotoPage",fc.noop),[p,u]=(0,$i.useState)(""),[m,g]=(0,$i.useState)(""),[h,f]=(0,$i.useState)(""),[b,y]=(0,$i.useState)(null),k=(0,$i.useMemo)(()=>(0,fc.filter)(s,C=>C.hasSlug===!1),[s]),w=(0,$i.useRef)(null);(0,$i.useEffect)(()=>{if(!o.isOpen||!o.blockId||w.current===o.blockId)return;let C=(0,fc.find)(n,{_id:o.blockId});C&&(u(C._name||C._type||""),w.current=o.blockId)},[o.isOpen,o.blockId,n]),(0,$i.useEffect)(()=>{o.isOpen&&!(0,fc.isEmpty)(k)&&!h&&f(k[0].key)},[o.isOpen,k,h]);let N=()=>{r({isOpen:!1,blockId:null}),u(""),g(""),f(""),y(null),w.current=null};(0,$i.useEffect)(()=>{if(!b)return;(async()=>{await c(!0),qP.toast.success(e("Partial created successfully")),N(),d({pageId:b})})().catch(P=>console.error("Error saving partial block:",P))},[b]);let I=async()=>{var C;if(!p.trim()){qP.toast.error(e("Name is required"));return}if(!h){qP.toast.error(e("Page type is required"));return}try{await c(!0);let P=(0,fc.find)(n,{_id:o.blockId});if(!P)return;let B=[P,...BW(n,P._id)],T=B.map(S=>S._id===P._id?{...S,_parent:null}:{...S}),v=await i({name:p,description:m,pageType:h,slug:"",hasSlug:!1,blocks:T});if((C=v==null?void 0:v.page)!=null&&C.id){let S={_id:Uo(),_type:"PartialBlock",_name:p,_parent:P._parent||null,partialBlockId:v.page.id},D=(0,fc.filter)(n,R=>P._parent?R._parent===P._parent:!R._parent).findIndex(R=>R._id===P._id);a(B,[S],P._parent||void 0,D),y(v.page.id)}}catch(P){console.error("Error creating partial block:",P)}};return(0,Nr.jsx)(Te,{open:o.isOpen,onOpenChange:C=>!C&&N(),children:(0,Nr.jsxs)(we,{className:"sm:max-w-[425px]",children:[(0,Nr.jsxs)(Oe,{children:[(0,Nr.jsx)(Ie,{children:t}),(0,Nr.jsx)(Dt,{className:"text-xs text-muted-foreground",children:e("Convert this section into a partial block that can be reused across pages.")})]}),(0,Nr.jsxs)("div",{className:"grid gap-3 py-3",children:[k.length>1?(0,Nr.jsxs)("div",{className:"grid gap-2",children:[(0,Nr.jsx)(Q,{htmlFor:"pageType",children:e("Type")}),(0,Nr.jsxs)(So,{value:h,onValueChange:f,children:[(0,Nr.jsx)(ho,{id:"pageType",children:(0,Nr.jsx)(Do,{placeholder:e("Select partial type")})}),(0,Nr.jsx)(yo,{children:(0,Nr.jsxs)(ed,{children:[(0,Nr.jsx)(ql,{children:e("Partials")}),k.map(C=>(0,Nr.jsx)(gt,{value:C.key,children:typeof C.name=="string"?C.name:C.key},C.key))]})})]})]}):null,(0,Nr.jsxs)("div",{className:"grid gap-2",children:[(0,Nr.jsx)(Q,{htmlFor:"name",children:e("Name")}),(0,Nr.jsx)(Ce,{id:"name",value:p,onChange:C=>u(C.target.value),placeholder:e("Enter partial name")})]}),(0,Nr.jsxs)("div",{className:"grid gap-2",children:[(0,Nr.jsx)(Q,{htmlFor:"description",children:e("Description")}),(0,Nr.jsx)(Ro,{id:"description",value:m,onChange:C=>g(C.target.value),rows:3,placeholder:e("Describe what this partial is for. Used by AI to understand when to use it.")})]})]}),(0,Nr.jsxs)(co,{children:[(0,Nr.jsx)(E,{variant:"outline",size:"sm",onClick:N,children:e("Cancel")}),(0,Nr.jsx)(E,{size:"sm",onClick:I,loading:l||!!b,children:t})]})]})})}});var LW,MW,OW,FW,_W,Ov,KP=x(()=>{"use strict";LW=require("@radix-ui/react-icons"),MW=require("lodash-es"),OW=K(require("react"),1);Ne();FW=require("react/jsx-runtime"),_W="h-3 w-3 flex-shrink-0",Ov=e=>{let t=Fu(),o=(0,MW.get)(t,[e.type,"icon"]);return o?OW.default.createElement(o,{className:_W}):(0,FW.jsx)(LW.BoxIcon,{className:_W})}});var HW,UW,GW,YP,$W,VW=x(()=>{"use strict";HW=require("jotai"),UW=require("lucide-react"),GW=require("react-i18next");Wr();Ge();Rr();Sr();YP=require("react/jsx-runtime"),$W=({MenuItem:e=ye})=>{let t=_e(),{t:o}=(0,GW.useTranslation)(),[,r]=(0,HW.useAtom)(HC),n=rN(),a=()=>{t&&r({isOpen:!0,blockId:t._id})};return n?(0,YP.jsxs)(e,{className:"flex items-center gap-x-2 text-xs",onClick:a,children:[(0,YP.jsx)(UW.SquareLibrary,{className:"h-4 w-4"})," ",t!=null&&t._libBlockId?o("Update library block"):o("Save to library")]}):null}});var zW,WW,JP,jW,qW=x(()=>{"use strict";zW=require("@radix-ui/react-icons"),WW=require("react-i18next");Ge();Ln();Sr();JP=require("react/jsx-runtime"),jW=({MenuItem:e=ye})=>{let{t}=(0,WW.useTranslation)(),o=_e(),r=br();return(0,JP.jsxs)(e,{onClick:()=>{o&&r([o._id],{_libBlockId:null})},className:"flex items-center gap-x-2 text-xs",children:[(0,JP.jsx)(zW.LinkBreak2Icon,{className:"h-4 w-4"})," ",t("Unlink from library")]})}});var Xt,Dy,wd,Wn,KW,sB,YW,iB,lB,cB,_y,Dne,_ne,dB,pB,Lne,mB=x(()=>{"use strict";Xt=K(require("@radix-ui/react-context-menu"),1),Dy=require("@radix-ui/react-icons"),wd=K(require("react"),1);st();Wn=require("react/jsx-runtime"),KW=Xt.Root,sB=wd.forwardRef(({className:e,...t},o)=>(0,Wn.jsx)(Xt.Trigger,{ref:o,className:G("outline-none focus:outline-none focus:ring-0 focus-visible:outline-none focus-visible:ring-0",e),...t}));sB.displayName=Xt.Trigger.displayName;YW=Xt.Sub,iB=wd.forwardRef(({className:e,inset:t,children:o,...r},n)=>(0,Wn.jsxs)(Xt.SubTrigger,{ref:n,className:G("flex cursor-default select-none items-center gap-1.5 rounded-sm px-2 py-1 text-xs outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0",t&&"pl-7",e),...r,children:[o,(0,Wn.jsx)(Dy.ChevronRightIcon,{className:"ml-auto h-3 w-3"})]}));iB.displayName=Xt.SubTrigger.displayName;lB=wd.forwardRef(({className:e,...t},o)=>(0,Wn.jsx)(Xt.SubContent,{ref:o,className:G("z-50 max-h-[--radix-context-menu-content-available-height] min-w-[7rem] overflow-y-auto overflow-x-hidden rounded-sm border border-foreground/10 bg-popover text-popover-foreground shadow-2xl shadow-foreground/10","origin-[--radix-context-menu-content-transform-origin] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));lB.displayName=Xt.SubContent.displayName;cB=wd.forwardRef(({className:e,...t},o)=>(0,Wn.jsx)(Xt.Portal,{children:(0,Wn.jsx)(Xt.Content,{ref:o,className:G("z-50 max-h-[--radix-context-menu-content-available-height] min-w-[7rem] overflow-y-auto overflow-x-hidden rounded-sm border border-foreground/10 bg-popover text-popover-foreground shadow-2xl shadow-foreground/10","origin-[--radix-context-menu-content-transform-origin] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})}));cB.displayName=Xt.Content.displayName;_y=wd.forwardRef(({className:e,inset:t,...o},r)=>(0,Wn.jsx)(Xt.Item,{ref:r,className:G("relative flex cursor-pointer select-none items-center gap-1.5 px-2 py-1 text-xs font-light outline-none transition-colors duration-300 hover:bg-accent focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-3.5 [&>svg]:shrink-0",t&&"pl-8",e),...o}));_y.displayName=Xt.Item.displayName;Dne=wd.forwardRef(({className:e,children:t,checked:o,...r},n)=>(0,Wn.jsxs)(Xt.CheckboxItem,{ref:n,className:G("relative flex cursor-pointer select-none items-center gap-1.5 py-1 pl-6 pr-2 text-xs font-light outline-none transition-colors duration-300 hover:bg-accent focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-3.5 [&>svg]:shrink-0",e),checked:o,...r,children:[(0,Wn.jsx)("span",{className:"absolute left-1.5 flex h-3 w-3 items-center justify-center",children:(0,Wn.jsx)(Xt.ItemIndicator,{children:(0,Wn.jsx)(Dy.CheckIcon,{className:"h-3 w-3"})})}),t]}));Dne.displayName=Xt.CheckboxItem.displayName;_ne=wd.forwardRef(({className:e,children:t,...o},r)=>(0,Wn.jsxs)(Xt.RadioItem,{ref:r,className:G("relative flex cursor-default select-none items-center rounded-sm py-1 pl-7 pr-2 text-xs outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[(0,Wn.jsx)("span",{className:"absolute left-1.5 flex h-3 w-3 items-center justify-center",children:(0,Wn.jsx)(Xt.ItemIndicator,{children:(0,Wn.jsx)(Dy.CircleIcon,{className:"h-1.5 w-1.5 fill-current"})})}),t]}));_ne.displayName=Xt.RadioItem.displayName;dB=wd.forwardRef(({className:e,inset:t,...o},r)=>(0,Wn.jsx)(Xt.Label,{ref:r,className:G("border-none px-2 py-1 text-xs font-light text-foreground/50",t&&"pl-7",e),...o}));dB.displayName=Xt.Label.displayName;pB=wd.forwardRef(({className:e,...t},o)=>(0,Wn.jsx)(Xt.Separator,{ref:o,className:G("-mx-0.5 my-0.5 h-px border-b border-border",e),...t}));pB.displayName=Xt.Separator.displayName;Lne=({className:e,...t})=>(0,Wn.jsx)("span",{className:G("ml-auto text-xs tracking-widest opacity-60",e),...t});Lne.displayName="ContextMenuShortcut"});var JW,QW,QP,uB,XW=x(()=>{"use strict";JW=require("@radix-ui/react-icons"),QW=require("react-i18next");Qn();Pa();Ke();Ge();Sr();QP=require("react/jsx-runtime"),uB=({MenuItem:e=ye})=>{let{t}=(0,QW.useTranslation)(),[o]=Pe();return q("flags.exportCode",!1)?(0,QP.jsxs)(e,{className:"flex items-center gap-x-2 text-xs",onClick:()=>Gt.publish(dt.OPEN_EXPORT_CODE,o),children:[(0,QP.jsx)(JW.DownloadIcon,{})," ",t("Export")]}):null}});var ZW,e6,t6,XP,Mne,o6,r6=x(()=>{"use strict";ZW=require("lucide-react"),e6=require("react"),t6=require("react-i18next");g0();ko();om();Ge();Sr();XP=require("react/jsx-runtime"),Mne=()=>{let e=_e(),[,t]=Pe(),{setNewBlocks:o}=Ft(),[r]=Pt(),n=(0,e6.useCallback)(()=>{if(!e)return;let s=r.filter(p=>p._parent===e._id),i=e._parent,c=r.filter(p=>i?p._parent===i:!p._parent).findIndex(p=>p._id===e._id),d=[...r];if(s.length>0){let p=s.map(u=>u._id);for(let u=0;u<p.length;u++)d=IC(d,p[u],i!=null?i:void 0,c+u)}d=$u(d,[e._id]),o(d),s.length>0?setTimeout(()=>{t([s[0]._id])},100):t([])},[e,r,o,t]),a=!!e&&e._type==="Box";return{unwrapBlock:n,canUnwrap:a,shouldRender:a}},o6=({MenuItem:e=ye})=>{let{t}=(0,t6.useTranslation)(),{unwrapBlock:o,shouldRender:r}=Mne();return r?(0,XP.jsxs)(e,{onClick:o,className:"flex items-center gap-x-2 text-xs",children:[(0,XP.jsx)(ZW.PackageOpen,{className:"h-3.5 w-3.5"})," ",t("Unwrap")]}):null}});var Ly,n6,gB,ZP,a6,jn,One,s6,i6=x(()=>{"use strict";Ly=require("@radix-ui/react-icons"),n6=require("lodash-es"),gB=require("lucide-react"),ZP=require("react"),a6=require("react-i18next");Ha();pn();ko();Ge();mB();Sr();Ne();jn=require("react/jsx-runtime"),One=()=>{var p,u;let e=_e(),[,t]=Pe(),{moveBlocks:o,addBlocks:r}=Ft(),[n]=Pt(),a=(0,ZP.useCallback)(m=>{if(!e)return;let g=e._parent,f=n.filter(w=>g?w._parent===g:!w._parent).findIndex(w=>w._id===e._id),b=Fl(m);(0,n6.has)(b,"content")&&(b.content="");let y=Uo(),k={_id:y,_type:m,_parent:g!=null?g:null,_name:m,...b};r([k],g!=null?g:void 0,f!==-1?f:void 0),setTimeout(()=>{o([e._id],y,0),t([y])},100)},[r,o,e,n,t]),s=e!=null&&e._parent&&((p=n.find(m=>m._id===e._parent))==null?void 0:p._type)||"",i=!!e&&e._type!=="BODY",l=(u=e==null?void 0:e._type)!=null?u:"",c=i&&In("Box",l)&&In(s,"Box"),d=i&&In("Link",l)&&In(s,"Link");return{canWrapInBox:c,canWrapInLink:d,wrapInBlock:a,shouldRender:c||d}},s6=({type:e})=>{let{t}=(0,a6.useTranslation)(),[o,r]=(0,ZP.useState)(!1),{canWrapInBox:n,canWrapInLink:a,wrapInBlock:s,shouldRender:i}=One();return i?e==="context"?(0,jn.jsx)("div",{onMouseLeave:()=>r(!1),onMouseEnter:()=>r(!0),children:(0,jn.jsxs)(YW,{open:o,children:[(0,jn.jsxs)(iB,{onClick:c=>{c.stopPropagation()},className:"flex cursor-pointer items-center gap-x-2 text-xs",children:[(0,jn.jsx)(gB.Package,{className:"h-3.5 w-3.5"})," ",t("Wrap In")]}),(0,jn.jsxs)(lB,{children:[n&&(0,jn.jsxs)(_y,{onClick:()=>s("Box"),className:"flex cursor-pointer items-center gap-x-2 px-2 py-1 text-xs hover:bg-accent",children:[(0,jn.jsx)(Ly.BoxIcon,{className:"h-3.5 w-3.5"})," ",t("Box")]}),a&&(0,jn.jsxs)(_y,{onClick:()=>s("Link"),className:"flex cursor-pointer items-center gap-x-2 px-2 py-1 text-xs hover:bg-accent",children:[(0,jn.jsx)(Ly.Link2Icon,{className:"h-3.5 w-3.5"})," ",t("Link")]})]})]})}):(0,jn.jsxs)($k,{children:[(0,jn.jsxs)(rx,{className:"flex items-center gap-x-2 text-xs font-light",children:[(0,jn.jsx)(gB.Package,{className:"h-3.5 w-3.5"})," ",t("Wrap with")]}),(0,jn.jsx)(Gk,{children:(0,jn.jsxs)(nx,{className:"isolate w-32 rounded-md border-border text-xs shadow-lg",children:[n&&(0,jn.jsxs)(ye,{onClick:()=>s("Box"),className:"flex items-center gap-x-2 text-xs",children:[(0,jn.jsx)(Ly.BoxIcon,{className:"h-3.5 w-3.5"})," ",t("Box")]}),a&&(0,jn.jsxs)(ye,{onClick:()=>s("Link"),className:"flex items-center gap-x-2 text-xs",children:[(0,jn.jsx)(Ly.Link2Icon,{className:"h-3.5 w-3.5"})," ",t("Link")]})]})})]}):null}});var va,fB,Hv,Fv,My,Jg,eT,Se,Fne,l6,Hne,Une,Gne,$ne,c6,tT,hB=x(()=>{"use strict";va=require("@radix-ui/react-icons"),fB=require("jotai"),Hv=require("lodash-es"),Fv=require("lucide-react"),My=require("react"),Jg=require("react-i18next"),eT=require("sonner");Wr();Oa();QE();VW();qW();Qn();Ha();Pa();ko();Ke();Rk();VP();Wf();Lk();Fk();mn();om();Ge();Ln();Rr();mB();Sr();tn();XW();r6();i6();Se=require("react/jsx-runtime"),Fne=({MenuItem:e=ye})=>{let t=_e(),[,o]=(0,fB.useAtom)(UC),r=$P();return(t==null?void 0:t._type)==="BODY"||(t==null?void 0:t._type)==="PartialBlock"?null:(0,Se.jsxs)(e,{onClick:()=>o({isOpen:!0,blockId:(t==null?void 0:t._id)||null}),className:"flex items-center gap-x-2 text-xs",children:[(0,Se.jsx)(Fv.FrameIcon,{className:"h-3.5 w-3.5"})," ",r]})},l6=({isFromBody:e=!1,MenuItem:t=ye})=>{let[o]=Pt(),[r]=Pe(),{pasteBlocks:n}=Yf(),[,a,s]=_k(),{t:i}=(0,Jg.useTranslation)(),l=_e(),c=q("flags.copyPaste",!0),d=(0,My.useCallback)(()=>{var m;let u=(e?(m=o==null?void 0:o.filter(g=>!(g!=null&&g._parent)))==null?void 0:m.map(g=>g==null?void 0:g._id):r).map(g=>{let h=o.find(f=>f._id===g);return{id:g,data:h}});s(u.map(g=>g.id))?eT.toast.warning("Partial blocks detected. Clone partial blocks?",{cancel:{label:i("No"),onClick:()=>{a(u.map(g=>g.id)),eT.toast.dismiss()}},action:{label:i("Yes"),onClick:()=>{a(u.map(g=>g.id),!0),eT.toast.dismiss()}},position:"top-center"}):a(u.map(g=>g.id))},[e,o,r,s,i,a]);return(0,Se.jsxs)(Se.Fragment,{children:[c&&(0,Se.jsxs)(t,{disabled:l!=null&&l._type?!Yb(l._type):!0,onClick:d,className:"flex items-center gap-x-2 text-xs",children:[(0,Se.jsx)(va.CopyIcon,{})," ",i("Copy")]}),c&&(0,Se.jsxs)(t,{className:"flex items-center gap-x-2 text-xs",onClick:()=>{n(r)},children:[(0,Se.jsx)(va.CardStackIcon,{})," ",i("Paste")]})]})},Hne=({MenuItem:e=ye})=>{let[t]=Pe(),[,o]=um(),{t:r}=(0,Jg.useTranslation)(),n=q("flags.copyPaste",!0);return(0,Se.jsx)(Se.Fragment,{children:n&&(0,Se.jsxs)(e,{className:"flex items-center gap-x-2 text-xs",onClick:()=>o(t),children:[(0,Se.jsx)(va.ScissorsIcon,{})," ",r("Cut")]})})},Une=({MenuItem:e=ye})=>{let[t]=Pe(),o=_c(),r=_e(),{t:n}=(0,Jg.useTranslation)();return(0,Se.jsxs)(e,{disabled:!Uf(r==null?void 0:r._type),className:"flex items-center gap-x-2 text-xs",onClick:()=>o(t),children:[(0,Se.jsx)(va.TrashIcon,{})," ",n("Remove")]})},Gne=({node:e,MenuItem:t=ye})=>{let{t:o}=(0,Jg.useTranslation)();return(0,Se.jsxs)(t,{onClick:r=>{r.stopPropagation(),setTimeout(()=>{e.edit()},200)},className:"flex items-center gap-x-2 text-xs",children:[(0,Se.jsx)(va.Pencil2Icon,{className:"h-4 w-4"})," ",o("Rename")]})},$ne=({MenuItem:e=ye})=>{let{t}=(0,Jg.useTranslation)(),o=_e(),r=br(),[n]=(0,fB.useAtom)(Cb),a=(0,Hv.has)(o,"_show")?o._show:!0,s=!a,i=(0,My.useCallback)(()=>{if(o){if(a&&n){let l=n.get(o._id);l!=null&&l.isOpen&&l.close()}r([o._id],{_show:!a})}},[o,a,r,n]);return(0,Se.jsx)(e,{onClick:i,className:"flex items-center gap-x-2 text-xs",children:s?(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(va.EyeOpenIcon,{className:"h-4 w-4"})," ",t("Show block")]}):(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(va.EyeClosedIcon,{className:"h-4 w-4"})," ",t("Hide block")]})})},c6=({node:e,MenuItem:t=ye,type:o})=>{let{t:r}=(0,Jg.useTranslation)(),[n,a]=Pe(),s=qf(),i=_e(),{hasPermission:l}=kt(),{librarySite:c}=q("flags",{librarySite:!1}),d=(0,My.useCallback)(()=>{s(n)},[n,s]),p=(0,My.useMemo)(()=>(0,Hv.has)(i,"_libBlockId")&&!(0,Hv.isEmpty)(i._libBlockId),[i]);return e==="BODY"?(0,Se.jsx)(Se.Fragment,{children:l(xe["pages:update"])&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsxs)(t,{disabled:!1,className:"flex items-center gap-x-2 text-xs",onClick:u=>{u.stopPropagation(),a([]),Gt.publish(dt.OPEN_ADD_BLOCK,i)},children:[(0,Se.jsx)(Fv.SquarePlus,{className:"h-3.5 w-3.5"})," ",r("Add block")]}),l(xe["pages:update"])&&(0,Se.jsx)(l6,{isFromBody:!0,MenuItem:t}),(0,Se.jsx)(uB,{MenuItem:t}),(0,Se.jsx)(t,{disabled:!1,onClick:u=>u.preventDefault(),className:"flex items-center gap-x-2 text-xs",children:(0,Se.jsx)(pw,{children:(0,Se.jsxs)("div",{className:"flex items-center gap-x-2 text-xs",children:[(0,Se.jsx)(va.EraserIcon,{})," ",r("Clear canvas")]})})}),(0,Se.jsx)(Br,{slotId:jo.AFTER_BODY_BLOCK_OPTIONS,context:{MenuItem:t}})]})}):(0,Se.jsxs)(Se.Fragment,{children:[l(xe["pages:update"])&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(s6,{type:o}),(0,Se.jsx)(o6,{MenuItem:t}),(0,Se.jsx)(Hn,{})]}),(0,Se.jsx)(Fne,{MenuItem:t}),l(xe["library:create"])&&c&&(0,Se.jsx)($W,{MenuItem:t}),(0,Se.jsx)($ne,{MenuItem:t}),(0,Se.jsx)(Hn,{}),l(xe["pages:update"])&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsxs)(t,{className:"flex items-center gap-x-2 text-xs",disabled:i!=null&&i._type?!jc(i._type):!0,onClick:u=>{u.stopPropagation(),a([e.data._id]),Gt.publish(dt.OPEN_ADD_BLOCK,e.data)},children:[(0,Se.jsx)(Fv.SquarePlus,{className:"h-3.5 w-3.5"})," ",r("Add block")]}),(0,Se.jsxs)(t,{disabled:i!=null&&i._type?!Yb(i._type):!0,className:"flex items-center gap-x-2 text-xs",onClick:u=>{u.stopPropagation(),d()},children:[(0,Se.jsx)(va.CardStackPlusIcon,{})," ",r("Duplicate")]})]}),(0,Se.jsx)(Gne,{node:e,MenuItem:t}),l(xe["pages:update"])&&(0,Se.jsx)(Hne,{MenuItem:t}),l(xe["pages:update"])&&(0,Se.jsx)(l6,{MenuItem:t}),p&&c&&(0,Se.jsx)(jW,{MenuItem:t}),(0,Se.jsx)(uB,{MenuItem:t}),l(xe["pages:update"])&&(0,Se.jsx)(Une,{MenuItem:t}),(0,Se.jsx)(Br,{slotId:jo.AFTER_BLOCK_OPTIONS,context:{MenuItem:t}})]})},tT=({children:e,id:t,node:o,type:r="option"})=>{let[,n]=Pe();return r==="context"?(0,Se.jsxs)(KW,{children:[(0,Se.jsx)(sB,{className:"m-0 h-full p-0",children:e}),(0,Se.jsxs)(cB,{children:[(0,Se.jsx)(dB,{className:"leading-none",children:"ACTIONS"}),(0,Se.jsx)(pB,{}),(0,Se.jsx)(c6,{type:r,node:o,MenuItem:_y})]})]}):(0,Se.jsx)(Se.Fragment,{children:(0,Se.jsxs)(Yt,{onOpenChange:a=>{a&&n([t])},children:[(0,Se.jsx)($t,{children:e}),(0,Se.jsx)(Vt,{side:"bottom",align:"start",children:(0,Se.jsx)(c6,{node:o,type:r,MenuItem:ye})})]})})}});var ku,Uv,Pd,d6,ws,bB,lo,Vne,zne,yB,Wne,xB,p6=x(()=>{"use strict";ku=require("@radix-ui/react-icons"),Uv=require("jotai"),Pd=require("lodash-es"),d6=require("lucide-react"),ws=require("react"),bB=require("react-i18next");Oa();al();KP();Qn();Ha();Pa();QS();Kd();Ke();mn();FP();Ln();ea();tn();Tn();hB();lo=require("react/jsx-runtime"),Vne=({node:e})=>{var o,r;let{t}=(0,bB.useTranslation)();return(0,lo.jsx)("input",{autoFocus:!0,className:Mr("ml-1 !h-5 w-full rounded-none border border-primary bg-surface px-1 text-[11px] leading-tight outline-none",e.isSelected?"text-foreground":""),type:"text",defaultValue:((o=e.data)==null?void 0:o._name)||((r=e.data)==null?void 0:r._type),onFocus:n=>n.currentTarget.select(),onBlur:n=>e.submit(n.currentTarget.value),onKeyDown:n=>{n.key==="Enter"&&e.submit(n.currentTarget.value)},placeholder:t("Block name")})},zne=(0,Uv.atom)(null),yB=e=>{var t;return e!=null&&e._name?e._name:(e==null?void 0:e._type)==="Box"&&(e!=null&&e.tag)&&(e==null?void 0:e.tag)!=="div"?(0,Pd.startCase)(e.tag):((t=e==null?void 0:e._type)==null?void 0:t.split("/").pop())||""},Wne=(e,t)=>e.length>t?e.substring(0,t)+"...":e,xB=(0,ws.memo)(({node:e,style:t,dragHandle:o})=>{var F,O;let{t:r}=(0,bB.useTranslation)(),n=br(),[a]=(0,Uv.useAtom)(gi),s=(0,ws.useRef)(null),i=(0,ws.useRef)(null),{hasPermission:l}=kt();(0,ws.useEffect)(()=>{s.current=a},[a]);let c=e.children&&e.children.length>0,{highlightBlock:d,clearHighlight:p}=pa(),u=Zn(),{id:m,data:g,isSelected:h,willReceiveDrop:f,isDragging:b,isEditing:y,handleClick:k}=e,w=fu(),N=(0,ws.useMemo)(()=>w.getBlockErrors(m),[w,m]),I=(0,Pd.get)(g,"_show",!0),C=U=>{U.stopPropagation(),!(!I&&!e.isOpen)&&e.toggle()},P=U=>{U.isInternal&&(i.current=U.isOpen,U.isOpen&&U.close())},B=U=>{U.isInternal&&i.current!==null&&(i.current?U.open():U.close(),i.current=null)},[T,v]=(0,Uv.useAtom)(zne),S=()=>{var U,j;A(),(U=e.parent)!=null&&U.isSelected||v((j=e==null?void 0:e.parent)==null?void 0:j.id)},A=()=>{v(null)},D=U=>{A(),U.stopPropagation(),!e.isOpen&&I&&e.toggle(),k(U)};(0,ws.useEffect)(()=>{let U=setTimeout(()=>{f&&!e.isOpen&&!b&&I&&e.toggle()},500);return()=>clearTimeout(U)},[f,e,b,I]);let R=(0,ws.useCallback)((U,j)=>{var W;let ce=s.current;if(!ce)return;let pe=ce.contentDocument||((W=ce.contentWindow)==null?void 0:W.document),ve=pe==null?void 0:pe.querySelector(`[data-block-id="${U}"]`);ve&&ve.setAttribute("data-drop",j);let Ve=ve.getBoundingClientRect(),ze=ce.getBoundingClientRect();if(!(Ve.top>=ze.top&&Ve.left>=ze.left&&Ve.bottom<=ze.bottom&&Ve.right<=ze.right)&&(pe!=null&&pe.documentElement)){let ie=ve.offsetTop-ze.top;requestAnimationFrame(()=>{pe!=null&&pe.documentElement&&(pe.documentElement.scrollTop=ie)})}},[]),H=U=>{A();let j=(0,Pd.get)(e,"parent.id");j!=="__REACT_ARBORIST_INTERNAL_ROOT__"?Gt.publish(dt.OPEN_ADD_BLOCK,{_id:j,position:U}):Gt.publish(dt.OPEN_ADD_BLOCK,{position:U})},{librarySite:M}=q("flags",{librarySite:!1}),L=(0,ws.useMemo)(()=>M&&(0,Pd.has)(g,"_libBlockId")&&!(0,Pd.isEmpty)(g._libBlockId)&&(l(xe["library:create"])||l(xe["library:update"])),[g,l,M]),z=(0,ws.useMemo)(()=>(g==null?void 0:g._type)==="PartialBlock"||(g==null?void 0:g._type)==="GlobalBlock",[g]),_=(0,ws.useMemo)(()=>({...t,width:"max-content",minWidth:"var(--tree-scroll-width, 100%)"}),[t]);return m===Ru?null:(0,lo.jsx)(tT,{node:e,id:m,type:"context",children:(0,lo.jsx)("div",{ref:o,style:_,"data-node-id":m,className:Mr("relative flex h-full items-center justify-start py-1 pr-8 outline-none",h?"bg-primary/20":T?"":"hover:bg-accent"),onMouseEnter:()=>d(m),onMouseLeave:()=>p(),onClick:D,onDragStart:()=>P(e),onDragEnd:()=>B(e),onDragOver:U=>{U.preventDefault(),R(m,"yes")},onDragLeave:U=>{U.preventDefault(),R(m,"no")},onDrop:U=>{U.preventDefault(),R(m,"no")},children:(0,lo.jsxs)("div",{className:"flex h-full w-full min-w-max items-center",children:[e.level>0&&(0,lo.jsx)("div",{className:"pointer-events-none absolute left-0 top-0 h-full",children:Array.from({length:e.level}).map((U,j)=>(0,lo.jsx)("div",{className:"absolute top-0 h-full border-l-[0.5px] border-border transition-colors duration-100 group-hover/parent:border-foreground/20",style:{left:`${j*14+10}px`}},j))}),l(xe["pages:update"])&&!u&&(e==null?void 0:e.rowIndex)!==null&&(e==null?void 0:e.rowIndex)!==void 0&&(e==null?void 0:e.rowIndex)>0&&(((F=e.parent)==null?void 0:F.isOpen)&&jc((0,Pd.get)(e,"parent.data._type"))||((O=e==null?void 0:e.parent)==null?void 0:O.id)==="__REACT_ARBORIST_INTERNAL_ROOT__")&&(0,lo.jsx)("div",{className:"group absolute -top-0.5 left-0 h-1 w-full rounded opacity-0 transition-colors duration-100 ease-in-out hover:opacity-100",children:(0,lo.jsx)("div",{onClick:U=>{U.stopPropagation(),H(e.childIndex)},onMouseEnter:S,onMouseLeave:A,className:"h-0.5 w-full rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",children:(0,lo.jsx)("div",{className:"absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer items-center justify-center rounded-full bg-primary/90 p-1 outline outline-2 outline-primary-foreground hover:bg-primary",children:(0,lo.jsx)(ku.PlusIcon,{className:"h-2 w-2 stroke-[2] text-primary-foreground"})})})}),(0,lo.jsx)("div",{className:"absolute left-0 right-0 top-0 -z-10 h-full",children:(0,lo.jsx)("div",{className:Mr("h-full transition-colors",f&&In(g._type,"Icon")?"bg-success/20":"",(e==null?void 0:e.id)===T?"bg-secondary/10 dark:bg-info/10":"")})}),(0,lo.jsx)("div",{className:Mr("group/type-icon relative flex w-full items-center justify-between space-x-2 px-1 outline-none",b&&"opacity-20",I?"":"line-through opacity-50",L&&h&&"text-primary"),children:(0,lo.jsxs)("div",{className:"flex items-center",children:[(0,lo.jsx)("div",{className:`flex h-4 w-4 shrink-0 rotate-0 transform items-center justify-center transition-transform duration-100 ${e.isOpen?"rotate-90":""} ${c?"cursor-pointer":""}`,children:c&&(0,lo.jsx)("button",{onClick:C,type:"button",children:(0,lo.jsx)(ku.ChevronRightIcon,{className:"h-3 w-3"})})}),(0,lo.jsxs)("div",{className:Mr("flex w-full items-center leading-tight",L&&"text-orange/90",L&&h&&"text-orange",z&&"text-purple/90",z&&h&&"text-purple"),children:[(0,lo.jsx)("div",{children:N.length>0||I?(0,lo.jsxs)(lo.Fragment,{children:[N.length>0?(0,lo.jsx)("div",{className:"text-destructive group-hover/type-icon:hidden",children:(0,lo.jsx)(ku.ExclamationTriangleIcon,{className:"h-3 w-3"})}):(0,lo.jsx)("div",{className:"group-hover/type-icon:hidden",children:(0,lo.jsx)(Ov,{type:g==null?void 0:g._type})}),(0,lo.jsx)("div",{className:"hidden delay-75 duration-200 group-hover/type-icon:block",children:(0,lo.jsx)(Ye,{content:r("It will hide block from canvas"),side:"right",children:(0,lo.jsx)(d6.EyeOff,{onClick:U=>{U.stopPropagation(),n([m],{_show:!I}),e.isOpen&&e.toggle()},className:"h-3 w-3 cursor-pointer rounded bg-transparent hover:text-foreground"})})})]}):(0,lo.jsx)(Ye,{content:r("It will make block visible in canvas"),side:"right",children:(0,lo.jsx)(ku.EyeOpenIcon,{onClick:U=>{U.stopPropagation(),n([m],{_show:!I}),e.isOpen&&e.toggle()},className:"h-3 w-3 cursor-pointer rounded bg-transparent hover:text-foreground"})})}),y?(0,lo.jsx)(Vne,{node:e}):(0,lo.jsx)("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",onDoubleClick:U=>{U.stopPropagation(),e.edit()},children:(0,lo.jsx)("span",{className:"font-light",title:yB(g).length>26?yB(g):"",children:Wne(yB(g),26)})})]})]})})]})})})});xB.displayName="Node"});var u6,Oy,g6,f6,Qg,h6,m6,y6,b6=x(()=>{"use strict";u6=require("jotai"),Oy=require("lodash-es"),g6=require("react"),f6=require("react-i18next");Wr();ko();Rr();qt();Qg=require("react/jsx-runtime"),h6=(e,t)=>{let o=(0,Oy.filter)(e,{_parent:t});if(o.length===0)return[];let r=[...o];return o.forEach(n=>{r.push(...h6(e,n==null?void 0:n._id))}),r},m6=Ff,y6=()=>{let[e,t]=(0,u6.useAtom)(HC),{t:o}=(0,f6.useTranslation)(),[r]=Pt(),n=()=>t({isOpen:!1,blockId:null}),a=(0,g6.useMemo)(()=>{if(!e.blockId)return[];let s=(0,Oy.find)(r,{_id:e.blockId});return s==null||delete s._parent,[s,...h6(r,s==null?void 0:s._id)]},[e.blockId,r]);return(0,Qg.jsx)(Te,{open:e.isOpen,onOpenChange:s=>!s&&n(),children:(0,Qg.jsxs)(we,{className:"p-4 sm:max-w-[450px]",children:[(0,Qg.jsx)(Oe,{className:"pb-2",children:(0,Qg.jsx)(Ie,{children:o("Save to Library")})}),m6&&!(0,Oy.isEmpty)(e.blockId)&&(0,Qg.jsx)(m6,{blockId:e.blockId,blocks:a,close:n})]})})}});var x6,v6,C6,k6,Nl,S6,w6=x(()=>{"use strict";Sr();x6=require("@radix-ui/react-icons"),v6=require("lucide-react"),C6=require("react"),k6=require("react-i18next");Qn();Pa();Ke();Fk();mn();Sr();tn();Nl=require("react/jsx-runtime"),S6=({parentContext:e,setParentContext:t})=>{let{t:o}=(0,k6.useTranslation)(),{hasPermission:r}=kt(),{canPaste:n,pasteBlocks:a}=Yf(),s=q("flags.copyPaste",!0);return(0,C6.useEffect)(()=>{n("root")||t(null)},[n,t]),!e||!n("root")||!s?null:(0,Nl.jsx)("div",{className:"absolute inset-0",children:(0,Nl.jsxs)(Yt,{open:!0,onOpenChange:()=>t(null),children:[(0,Nl.jsx)($t,{className:"hidden"}),(0,Nl.jsxs)(Vt,{className:"absolute w-28 p-1 text-xs",style:{top:e.y,left:e.x},children:[(0,Nl.jsx)(Ua,{children:o("ACTIONS")}),(0,Nl.jsx)(Hn,{}),r(xe["pages:update"])&&(0,Nl.jsxs)(ye,{className:"flex items-center gap-x-2 text-xs",onClick:()=>Gt.publish(dt.OPEN_ADD_BLOCK,null),children:[(0,Nl.jsx)(v6.PlusIcon,{className:"h-3.5 w-3.5"})," ",o("Add block")]}),(0,Nl.jsxs)(ye,{className:"flex items-center gap-x-2 text-xs",onClick:()=>{a("root"),t(null)},children:[(0,Nl.jsx)(x6.CardStackIcon,{})," ",o("Paste")]})]})]})})}});function qne(e,t,o){if(!o)return!1;let r=o(e._type);if(!(r!=null&&r.length))return!1;for(let[n,a]of Object.entries(e)){if(typeof a!="string"||!r.some(l=>n===l||n.startsWith(l+"-")))continue;if(a.replace(jne," ").toLowerCase().includes(t))return!0}return!1}function Kne(e){return"_show"in e&&e._show!==!0}function Yne(e){for(let[t,o]of Object.entries(e))if(!t.startsWith("_")){if(typeof o=="string"){if(LE(o))return!0}else if(o!==null&&typeof o=="object"&&LE(JSON.stringify(o)))return!0}return!1}function Jne(e){for(let[t,o]of Object.entries(e))if(t.endsWith("_attrs")&&o&&typeof o=="object"&&!Array.isArray(o)&&o["data-animation"])return!0;return!1}function P6(e,{term:t,types:o,conditionalOnly:r,bindingsOnly:n,animationsOnly:a,fullBlocks:s,getContentProps:i}){if(!t.trim()&&o.length===0&&!r&&!n&&!a)return null;let l=t.toLowerCase(),c=[],d=p=>{var u,m,g;for(let h of p){let f=(u=s==null?void 0:s.get(h._id))!=null?u:h,b=!0,y=!0,k=!0,w=!0,N=!0;t.trim()&&(b=((m=h._name)==null?void 0:m.toLowerCase().includes(l))||((g=h._type)==null?void 0:g.toLowerCase().includes(l))||qne(f,l,i)),o.length>0&&(y=o.includes(h._type)),r&&(k=Kne(f)),n&&(w=Yne(f)),a&&(N=Jne(f)),b&&y&&k&&w&&N&&c.push(h),h.children&&d(h.children)}};return d(e),c}var jne,T6=x(()=>{"use strict";qS();jne=/<[^>]*>/g});var N6,oT,Ps,E6,Lt,A6,I6=x(()=>{"use strict";N6=require("@react-hookz/web"),oT=require("lucide-react"),Ps=require("react"),E6=require("react-i18next");Jn();pn();Ge();fn();J();Sr();Ne();hl();KP();T6();Lt=require("react/jsx-runtime"),A6=({treeData:e})=>{let{t}=(0,E6.useTranslation)(),[o,r]=(0,Ps.useState)(""),[n,a]=(0,Ps.useState)(null),[s,i]=(0,Ps.useState)([]),[l,c]=(0,Ps.useState)(!1),[d,p]=(0,Ps.useState)(!1),[u,m]=(0,Ps.useState)(!1),[g,h]=Pe(),[,f]=ao(),b=(0,Ps.useRef)(null),[y,k]=(0,Ps.useState)(80);(0,Ps.useEffect)(()=>{if(b.current){let P=b.current.firstElementChild;P&&k(P.getBoundingClientRect().height+P.offsetTop)}},[n]);let w=s.length>0||l||d||u,N=(0,Ps.useMemo)(()=>{let P=new Set,B=T=>{for(let v of T)v._type&&P.add(v._type),v.children&&B(v.children)};return B(e),Array.from(P).sort()},[e]),I=()=>{r(""),i([]),c(!1),p(!1),m(!1)},C=(0,N6.useDebouncedCallback)(({term:P,types:B,conditionalOnly:T,bindingsOnly:v,animationsOnly:S})=>{if(!P.trim()&&B.length===0&&!T&&!v&&!S){a(null);return}let A=new Map(Od().map(D=>[D._id,D]));a(P6(e,{term:P,types:B,conditionalOnly:T,bindingsOnly:v,animationsOnly:S,fullBlocks:A,getContentProps:D=>{var R,H;return(H=(R=Ct(D))==null?void 0:R.i18nProps)!=null?H:[]}}))},[e,a],300);return(0,Ps.useEffect)(()=>{C({term:o,types:s,conditionalOnly:l,bindingsOnly:d,animationsOnly:u})},[o,s,l,d,u,C]),(0,Lt.jsxs)("div",{ref:b,children:[(0,Lt.jsxs)("div",{className:"flex items-center gap-1 py-2",onClick:P=>P.stopPropagation(),children:[(0,Lt.jsx)(Yr,{value:o,setValue:r,autoComplete:"off"}),(0,Lt.jsxs)(Yt,{children:[(0,Lt.jsx)($t,{asChild:!0,children:(0,Lt.jsxs)(E,{size:"icon-xs",variant:"outline","aria-label":t("FILTERS"),title:t("FILTERS"),className:Co("relative h-8 w-8",w&&"bg-accent"),children:[(0,Lt.jsx)(oT.Filter,{className:"h-4 w-4"}),w&&(0,Lt.jsx)("span",{className:"absolute right-1.5 top-1.5 flex h-2 w-2 rounded-full bg-primary"})]})}),(0,Lt.jsxs)(Vt,{align:"start",className:"w-56",children:[(0,Lt.jsx)(Ua,{children:t("FILTERS")}),(0,Lt.jsx)(Hn,{}),(0,Lt.jsxs)($k,{children:[(0,Lt.jsxs)(rx,{children:[(0,Lt.jsx)("span",{children:t("Block types")}),s.length>0&&(0,Lt.jsx)("span",{className:"ml-auto flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] text-primary-foreground",children:s.length})]}),(0,Lt.jsx)(Gk,{children:(0,Lt.jsxs)(nx,{children:[(0,Lt.jsx)(Ua,{children:t("BLOCK TYPES")}),(0,Lt.jsx)("div",{className:"max-h-64 w-36 overflow-y-auto",children:N.map(P=>(0,Lt.jsxs)(Jc,{className:"pl-2 pr-6 [&>span]:left-auto [&>span]:right-2",checked:s.includes(P),onCheckedChange:B=>{i(T=>B===!0?T.includes(P)?T:[...T,P]:T.filter(v=>v!==P))},children:[(0,Lt.jsx)(Ov,{type:P})," ",P]},P))})]})})]}),(0,Lt.jsx)(Jc,{className:"pl-2 pr-6 [&>span]:left-auto [&>span]:right-2",checked:l,onCheckedChange:P=>c(P===!0),children:t("Conditional")}),(0,Lt.jsx)(Jc,{className:"pl-2 pr-6 [&>span]:left-auto [&>span]:right-2",checked:d,onCheckedChange:P=>p(P===!0),children:t("Data binding")}),(0,Lt.jsx)(Jc,{className:"pl-2 pr-6 [&>span]:left-auto [&>span]:right-2",checked:u,onCheckedChange:P=>m(P===!0),children:t("Animations")}),w&&(0,Lt.jsxs)(Lt.Fragment,{children:[(0,Lt.jsx)(Hn,{}),(0,Lt.jsx)(ye,{onClick:I,className:"text-destructive focus:bg-destructive/10 focus:text-destructive",children:t("Clear filters")})]})]})]})]}),n!==null&&(0,Lt.jsxs)("div",{className:"absolute inset-x-0 bottom-0 z-50 flex flex-col border-t border-border bg-background py-2",style:{top:`${y}px`},onClick:P=>P.stopPropagation(),children:[(0,Lt.jsxs)("div",{className:"mb-2 flex items-center justify-between text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:[(0,Lt.jsxs)("span",{className:"pl-1",children:[t("Search results"),n.length>0?` (${n.length})`:""]}),(0,Lt.jsxs)(E,{variant:"ghost",size:"xs",onClick:I,className:"text-[10px]",title:t("Clear filters"),children:[(0,Lt.jsx)(oT.X,{className:"h-3 w-3"})," ",t("Clear filters")]})]}),n.length>0?(0,Lt.jsx)("div",{className:"flex flex-1 flex-col overflow-y-auto",style:{scrollbarGutter:"stable"},children:n.map(P=>(0,Lt.jsxs)("button",{type:"button",onClick:()=>{f([]),h([P._id])},className:Co("flex w-full items-center justify-between space-x-2 rounded-sm px-1 py-1 text-left",g.includes(P._id)?"bg-primary/20":"hover:bg-accent/50 dark:hover:bg-accent"),children:[(0,Lt.jsx)("span",{className:"truncate text-xs",children:P._name||P._type}),(0,Lt.jsx)("span",{className:"h-max rounded bg-muted p-1 text-[9px] leading-none",children:P._type})]},P._id))}):(0,Lt.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:t("No matching blocks")})]})]})}});var Fy,B6,vB,Xg,rT,yr,R6,D6,Zt,Qne,Xne,Zne,CB,_6=x(()=>{"use strict";Fy=require("@radix-ui/react-icons"),B6=require("@react-hookz/web"),vB=require("jotai"),Xg=require("lodash-es"),rT=require("lucide-react"),yr=require("react"),R6=require("react-arborist"),D6=require("react-i18next");zr();Jn();Oa();xW();EW();DW();p6();b6();Qn();Ha();pn();Pa();ko();Wf();mn();Ge();fn();Ln();Rr();J();rs();tn();Tn();hB();w6();I6();Zt=require("react/jsx-runtime"),Qne=()=>(0,yr.useCallback)((e,t)=>{let o=be.get(Ot),r=new Map(o.map(s=>[s._id,s])),n=(0,Xg.first)(e.map(s=>{var i;return(i=r.get(s))==null?void 0:i._type}));if(!t)return!!n;let a=r.get(t);return!a||!n?!1:In(a._type,n)},[]),Xne=e=>{let t=(0,yr.useRef)(null),o=(0,yr.useCallback)(()=>{let n=document.querySelector('[role="tree"]');if(!n)return;let a=(0,Xg.get)(n,"children[0].scrollWidth",0);n.style.setProperty("--tree-scroll-width",`${a}px`)},[]),r=(0,yr.useCallback)(()=>{t.current!==null&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{o(),t.current=null})},[o]);(0,yr.useEffect)(()=>{o()},[e,o]),(0,yr.useLayoutEffect)(()=>{let n=document.querySelector('[role="tree"]');if(!n)return;o();let a=new ResizeObserver(r);a.observe(n);let s=new MutationObserver(r);return s.observe(n,{childList:!0,subtree:!0}),()=>{t.current!==null&&cancelAnimationFrame(t.current),a.disconnect(),s.disconnect()}},[o,r])},Zne=()=>{let[e]=(0,vB.useAtom)(YT),[t,o]=Pe(),[r]=um(),n=br(),[,a]=ao(),{moveBlocks:s}=Ft(),i=Qne(),l=(0,yr.useRef)(null),[,c]=(0,vB.useAtom)(Cb),{t:d}=(0,D6.useTranslation)(),[p,u]=(0,yr.useState)(!1);Xne(e);let[m,g]=(0,yr.useState)(null),h=(0,yr.useCallback)(()=>{o([]),a([])},[o,a]),f=(0,yr.useMemo)(()=>{let v=(A,D)=>A.filter(R=>!D.includes(R._id)).map(R=>({...R,children:R.children?v(R.children,D):[]}));return[...(0,Xg.isEmpty)(r)?e:v(e,r),{_type:Ru,_id:Ru,children:[]}]},[e,r]),b=(0,yr.useCallback)(({id:v,name:S,node:A})=>{n([v],{_name:S},A.data._name)},[n]),y=(0,yr.useCallback)(({dragIds:v,parentId:S,index:A})=>{i(v,S)&&s(v,S!=null?S:void 0,A)},[i,s]),k=(0,yr.useCallback)(v=>{if(v.length===0)return;let S=v[0]?v[0].id:"";a([]),o([S])},[a,o]),w=(0,yr.useCallback)(()=>{var v;if(l.current){let S=((v=l.current.visibleNodes)==null?void 0:v.some(A=>A.isOpen))||!1;u(S)}},[]),N=(0,yr.useCallback)(v=>{var D;v.preventDefault(),m&&g(null);let S=v.target,A=S.getAttribute("data-node-id")||((D=S.closest("[data-node-id]"))==null?void 0:D.getAttribute("data-node-id"));A?(a([]),o([A])):(a([]),o([]),g({x:v.clientX,y:v.clientY}))},[m,a,o]),I=(0,B6.useDebouncedCallback)(({parentNode:v,dragNodes:S})=>{var A;return(v==null?void 0:v.data._type)===Ru||!In(v==null?void 0:v.data._type,(A=S[0])==null?void 0:A.data._type)},[],300),C=(0,yr.useCallback)((v,S)=>{if(!v)return!0;let A={isLeaf:!S.isInternal,isClosed:!S.isOpen,isOpen:S.isOpen};try{let D=v;return Object.keys(A).forEach(R=>{let H=new RegExp(`\\b${R}\\b`,"g");D=D.replace(H,String(A[R]))}),new Function(`return ${D}`)()}catch(D){return console.warn("Invalid condition expression:",v),!1}},[]),P=(0,yr.useCallback)(v=>{if(!l.current)return;let S=l.current,A=S.selectedNodes[0];if(!A)return;o([A.id]),a([]);let D=!A.isInternal,R=!A.isOpen,H=A.isOpen,M=vW.find(L=>L.key===v.key&&(!L.when||C(L.when,A)));if(M)switch(v.preventDefault(),M.command){case"selectNext":SW(S);break;case"selectPrev":wW(S);break;case"selectParent":PW(S,D||R);break;case"close":NW(S,H);break;case"open":TW(S,R);break;case"selectFirst":CW(S);break;case"selectLast":kW(S);break;default:break}},[o,a,C]),B=(0,yr.useCallback)(v=>{l.current=v!=null?v:null,v&&c(v)},[c]),{hasPermission:T}=kt();return(0,Xg.isEmpty)(e)?(0,Zt.jsx)("div",{children:(0,Zt.jsx)("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8",children:(0,Zt.jsxs)("div",{className:"flex flex-col items-center space-y-6 text-center",children:[(0,Zt.jsx)("div",{className:"rounded-full bg-accent p-6",children:(0,Zt.jsx)(Fy.StackIcon,{className:"h-12 w-12 text-accent-foreground"})}),(0,Zt.jsxs)("div",{className:"space-y-2",children:[(0,Zt.jsx)("p",{children:d("This page is empty")}),(0,Zt.jsx)("p",{className:"max-w-sm text-xs text-muted-foreground",children:d("Get started by adding your first block to begin building your page")})]}),T(xe["pages:update"])&&(0,Zt.jsxs)(E,{onClick:()=>Gt.publish(dt.OPEN_ADD_BLOCK),size:"sm",variant:"outline",className:"px-3",children:[(0,Zt.jsx)(Fy.PlusIcon,{}),d("Add Block")]})]})})}):(0,Zt.jsxs)(Zt.Fragment,{children:[(0,Zt.jsx)("div",{className:Co("chai-outline group/parent parent-group flex h-full select-none flex-col space-y-1"),onClick:()=>h(),children:(0,Zt.jsxs)("div",{id:"outline-view",className:"no-scrollbar h-full overflow-hidden text-sm relative",onKeyDown:v=>{l.current&&!l.current.isEditing&&P(v)},children:[(0,Zt.jsxs)("div",{className:"flex items-center justify-between gap-x-1 text-sm text-muted-foreground",children:[(0,Zt.jsx)("h3",{className:"font-medium uppercase text-foreground",children:d("Outline")}),(0,Zt.jsxs)(Fo,{children:[(0,Zt.jsx)(Ho,{asChild:!0,children:(0,Zt.jsx)(E,{className:"h-6 w-6 hover:bg-accent",onClick:()=>{var v,S;if(p){(v=l==null?void 0:l.current)==null||v.closeAll(),u(!1);let A=document.querySelector('[role="tree"]');if(!A)return;A.style.setProperty("--tree-scroll-width",`${A.clientWidth}px`)}else(S=l==null?void 0:l.current)==null||S.openAll(),u(!0)},variant:"ghost",size:"icon-sm",children:p?(0,Zt.jsx)(rT.ChevronsDownUp,{className:"h-3 w-3"}):(0,Zt.jsx)(rT.ChevronsUpDown,{className:"h-3 w-3"})})}),(0,Zt.jsx)(Bo,{className:"isolate z-[9999]",children:d(p?"Collapse all":"Expand all")})]})]}),(0,Zt.jsx)(Br,{slotId:jo.BEFORE_OUTLINE}),(0,Zt.jsx)(A6,{treeData:f.filter(v=>v._id!==Ru)}),(0,Zt.jsx)("div",{className:"mt-2",children:(0,Zt.jsx)(tT,{node:"BODY",id:"BODY",type:"context",children:(0,Zt.jsx)("div",{role:"treeitem","aria-level":0,"aria-selected":!0,"aria-expanded":!1,onClick:()=>o([]),className:"flex min-h-[25px] items-center",children:(0,Zt.jsx)("div",{className:Co("group flex h-[25px] w-full cursor-pointer items-center justify-between space-x-px px-2 py-0 outline-none",t.length===0?"bg-primary/20":"hover:bg-accent"),children:(0,Zt.jsxs)("div",{className:"flex items-center",children:[(0,Zt.jsx)(Fy.CardStackIcon,{className:"h-3 w-3 flex-shrink-0 rotate-180"}),(0,Zt.jsx)("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px] font-light",children:"Body"})]})})})})}),(0,Zt.jsx)(R6.Tree,{ref:B,height:window.innerHeight-120,className:"!h-full max-w-full !overflow-x-auto !overflow-y-auto pl-px [&_*]:outline-none",rowClassName:"flex items-center h-full w-full outline-none",selection:t[0]||"",onRename:b,openByDefault:!1,onMove:y,data:f,renderCursor:bW,onSelect:k,onToggle:w,childrenAccessor:v=>v.children,width:"100%",rowHeight:25,renderDragPreview:()=>null,indent:14,onContextMenu:N,disableDrop:I,idAccessor:"_id",children:xB})]})}),(0,Zt.jsx)(y6,{}),(0,Zt.jsx)(RW,{}),(0,Zt.jsx)(S6,{parentContext:m,setParentContext:g})]})},CB=(0,yr.memo)(Zne)});var kB,El,L6,tVe,SB=x(()=>{"use strict";kB=require("jotai"),El=require("lodash-es"),L6=require("react");dp();ko();Ke();Tt();Vc();Ln();yp();Tn();Ne();tVe=(0,kB.atom)(!1)});var Su,tae,oae,M6,O6=x(()=>{"use strict";Su=require("@radix-ui/react-icons"),tae=require("lodash-es"),oae=require("react-i18next");SB();Tt();Rs();yp();M6=require("react/jsx-runtime")});var wB,rae,PB,nae,F6,H6=x(()=>{"use strict";wB=require("@radix-ui/react-icons"),rae=require("lodash-es"),PB=require("react"),nae=require("react-i18next");O6();SB();Ge();J();gs();kN();KP();F6=require("react/jsx-runtime")});var U6,G6,$6=x(()=>{"use strict";U6=require("@radix-ui/react-icons");Im();Wd();G6=require("react/jsx-runtime")});var V6=x(()=>{"use strict"});var z6=x(()=>{"use strict"});var W6=x(()=>{"use strict"});var j6=x(()=>{"use strict"});var q6=x(()=>{"use strict"});var K6=x(()=>{"use strict"});var Y6=x(()=>{"use strict"});var J6=x(()=>{"use strict"});var Q6=x(()=>{"use strict"});var X6=x(()=>{"use strict"});var Z6=x(()=>{"use strict"});var e8=x(()=>{"use strict"});var t8=x(()=>{"use strict"});var o8=x(()=>{"use strict"});var r8=x(()=>{"use strict"});var n8=x(()=>{"use strict"});var a8=x(()=>{"use strict";V6();z6();W6();j6();q6();K6();Y6();J6();Q6();X6();Z6();e8();t8();o8();r8();n8()});var s8=x(()=>{"use strict";tA();kA();ZA();Mx();sA();dA();_6();fI();dk();H6();JE();$6();ZE();yI();uA();oI();rA();yA();a8()});var i8,l8,Hy,aae,Gv,sae,iae,c8,TB=x(()=>{"use strict";i8=require("lucide-react"),l8=require("react");Ke();J();Hy=require("react/jsx-runtime"),aae=(0,l8.lazy)(()=>Promise.resolve().then(()=>(kx(),IS))),Gv="chai-chat-panel",sae=({className:e=""})=>(0,Hy.jsx)(i8.BrainCog,{className:e}),iae=({isActive:e,show:t})=>q("flags.ai",!1)?(0,Hy.jsx)(E,{variant:"ghost",size:"icon",onClick:t,className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,Hy.jsx)(sae,{})}):null,c8={id:Gv,label:"AI Assistant",button:iae,panel:()=>(0,Hy.jsx)("div",{className:"h-full",children:(0,Hy.jsx)(aae,{})}),position:"top"}});var NB,m8,EB,Ts,d8,p8,lae,Zg,u8,cae,dae,pae,mae,g8,f8=x(()=>{"use strict";NB=require("@radix-ui/react-icons"),m8=require("react"),EB=require("react-i18next");J();Ts=require("react/jsx-runtime"),lae=typeof navigator!="undefined"&&/Mac|iP(hone|od|ad)/.test((p8=(d8=navigator.userAgentData)==null?void 0:d8.platform)!=null?p8:navigator.platform),Zg=lae?"\u2318":"Ctrl",u8="help",cae=({isActive:e,show:t})=>{let{t:o}=(0,EB.useTranslation)();return(0,Ts.jsx)(E,{variant:"ghost",size:"icon",onClick:t,"aria-label":o("Keyboard shortcuts"),title:o("Keyboard shortcuts"),className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,Ts.jsx)(NB.KeyboardIcon,{className:"size-4"})})},dae=({children:e})=>(0,Ts.jsx)("kbd",{className:"inline-flex h-6 min-w-6 items-center justify-center rounded-md border border-border bg-muted px-1.5 font-sans text-[11px] font-medium leading-none text-foreground shadow-sm",children:e}),pae=({keys:e,label:t})=>(0,Ts.jsxs)("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[(0,Ts.jsx)("span",{className:"text-sm text-muted-foreground",children:t}),(0,Ts.jsx)("span",{className:"flex shrink-0 items-center gap-1",children:e.map((o,r)=>(0,Ts.jsxs)(m8.Fragment,{children:[r>0&&(0,Ts.jsx)("span",{className:"text-[11px] text-muted-foreground/60",children:"+"}),(0,Ts.jsx)(dae,{children:o})]},r))})]}),mae=()=>{let{t:e}=(0,EB.useTranslation)(),t=[[{keys:[Zg,"Z"],label:e("Undo")},{keys:[Zg,"Shift","Z"],label:e("Redo")},{keys:[Zg,"D"],label:e("Duplicate")},{keys:[Zg,"C"],label:e("Copy")},{keys:[Zg,"X"],label:e("Cut")},{keys:[Zg,"V"],label:e("Paste")}],[{keys:[Zg,"S"],label:e("Save page")},{keys:["Esc"],label:e("Blur field / deselect blocks")},{keys:["Del"],label:e("Delete block")},{keys:["V / H"],label:e("Select / Hand tool")}]];return(0,Ts.jsx)("div",{className:"grid grid-cols-1 gap-x-8 sm:grid-cols-2",children:t.map((o,r)=>(0,Ts.jsx)("div",{className:"flex flex-col divide-y divide-border/60 sm:[&:not(:last-child)]:border-r sm:[&:not(:last-child)]:border-border sm:[&:not(:last-child)]:pr-8",children:o.map(n=>(0,Ts.jsx)(pae,{...n},n.label))},r))})},g8={button:cae,label:"Keyboard shortcuts",position:"bottom",view:"modal",width:560,icon:(0,Ts.jsx)(NB.KeyboardIcon,{className:"size-4"}),panel:mae}});function nT(e){let t=isNaN(e)?0:typeof e=="number"?e:parseInt(e);return!t||t<0?"0 B":t<1024?`${t.toFixed(2)} B`:t<1024*1024?`${(t/1024).toFixed(2)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function Uy(e){return new Promise((t,o)=>{if(e.size<=h8){t(e);return}new y8.default(e,{quality:.9,maxWidth:2048,maxHeight:2048,convertSize:h8,success(r){t(r)},error(r){b8.toast.error(`Failed to compress image. Image size is ${nT(e.size)}, which exceeds the maximum allowed size of ${nT(uae)}.`),o(r)}})})}var y8,b8,h8,uae,$v=x(()=>{"use strict";y8=K(require("compressorjs"),1),b8=require("sonner"),h8=.5*1024*1024,uae=10*1024*1024});var wu,ef,Gy,aT,sT,iT=x(()=>{"use strict";wu=require("@tanstack/react-query"),ef=require("sonner");St();rt();Kt();Gy=()=>{let e=le(),t=(0,wu.useQueryClient)(),o=he();return(0,wu.useMutation)({mutationFn:async r=>{let n=r.map(async s=>o(e,{action:$.CREATE_ASSET,data:s}));return await Promise.all(n)},onSuccess:r=>{var n;if(r!=null&&r.some(a=>a.error))throw new Error(((n=r==null?void 0:r.find(a=>a.error))==null?void 0:n.error)||"Failed to upload asset");{t.invalidateQueries({queryKey:[$.GET_ASSETS]});let a=r==null?void 0:r.length;ef.toast.success(`${a===1?"Asset":a+" Assets"} uploaded successfully`)}},onError:()=>{ef.toast.error("Failed to upload asset")}})},aT=()=>{let e=le(),t=(0,wu.useQueryClient)(),o=he(),r=Nt("flags",{});return(0,wu.useMutation)({mutationFn:async n=>{let a=Array.isArray(n)?n:[n],s=r!=null&&r.trash?$.TRASH_ENTITY:$.DELETE_ASSET,i=r!=null&&r.trash?{entityType:"asset",ids:a}:{ids:a};return o(e,{action:s,data:i})},onSuccess:(n,a)=>{if(n!=null&&n.error)throw new Error(n==null?void 0:n.error);{let s=Array.isArray(a)&&a.length>1;t.invalidateQueries({queryKey:[$.GET_ASSETS]}),ef.toast.success((s?"Assets":"Asset")+" "+(r!=null&&r.trash?"moved to trash":"deleted successfully"))}},onError:()=>{ef.toast.error("Failed to delete asset")}})},sT=()=>{let e=le(),t=(0,wu.useQueryClient)(),o=he();return(0,wu.useMutation)({mutationFn:async r=>o(e,{action:$.UPDATE_ASSET,data:r}),onSuccess:r=>{if(r!=null&&r.error)throw new Error(r==null?void 0:r.error);t.invalidateQueries({queryKey:[$.GET_ASSETS]}),r!=null&&r.id&&t.invalidateQueries({queryKey:[$.GET_ASSET,r.id]}),ef.toast.success("Asset updated successfully")},onError:()=>{ef.toast.error("Failed to update asset")}})}});var AB,lT,x8,cT=x(()=>{"use strict";AB=require("@tanstack/react-query");St();rt();Kt();lT=(e={})=>{let t=le(),o=he(),{search:r,page:n=1,limit:a=30}=e;return(0,AB.useQuery)({queryKey:[$.GET_ASSETS,r,n,a],queryFn:async()=>{let s=await o(t,{action:$.GET_ASSETS,data:{search:r,page:n,limit:a}});return s.page=n,s.limit=a,s},staleTime:1/0,retry:1})},x8=e=>{let t=le(),o=he();return(0,AB.useQuery)({queryKey:[$.GET_ASSET,e],queryFn:async()=>e?await o(t,{action:$.GET_ASSET,data:{id:e}}):null,staleTime:1/0,retry:1})}});var v8=x(()=>{});var IB={};et(IB,{default:()=>gae});var C8,dT,sa,k8,S8,$y,w8,gae,BB=x(()=>{"use strict";C8=require("lodash-es"),dT=require("lucide-react"),sa=K(require("react"),1),k8=K(require("react-filerobot-image-editor"),1),S8=require("react-i18next");qt();Oo();v8();$y=require("react/jsx-runtime");typeof window!="undefined"&&(window.React=sa.default);w8=(0,sa.memo)(({imageUrl:e,onSave:t,onClose:o,defaultSavedImageName:r,isEditing:n=!1})=>{let{t:a}=(0,S8.useTranslation)(),[s,i]=(0,sa.useState)(!1),[l,c]=(0,sa.useState)(!0),[d,p]=(0,sa.useState)(!1);(0,sa.useEffect)(()=>{let y=new Image;return y.src=e,y.onload=()=>p(!0),()=>{y.onload=null}},[e]),(0,sa.useEffect)(()=>{let y=k=>{k.key==="Escape"&&l&&(k.preventDefault(),k.stopPropagation(),k.stopImmediatePropagation())};return document.addEventListener("keydown",y,!0),()=>{document.removeEventListener("keydown",y,!0)}},[l]);let u=(0,sa.useMemo)(()=>(0,C8.debounce)(async(y,k=!1)=>{i(!0);let w=y.imageBase64;await t(w,k),c(!1),i(!1)},300),[t]),m=(0,sa.useCallback)((y,k=!1)=>{u(y,k)},[u]),g=(0,sa.useCallback)(()=>{c(!1),o()},[o]),h=(0,sa.useMemo)(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),f=(0,sa.useMemo)(()=>({colors:{primary:"#1f8fff",secondary:"#212121",tertiary:"#000000"}}),[]),b=(0,sa.useMemo)(()=>n?[{label:a("Update this file"),onClick:(y,k)=>k((...w)=>{i(!0),m(w[0],!1)}),icon:dT.Save},{label:a("Save as new file"),onClick:(y,k)=>k((...w)=>{i(!0),m(w[0],!0)}),icon:dT.Copy}]:[],[n,m,a]);return(0,$y.jsx)(Te,{open:!0,onOpenChange:y=>!y&&g(),children:(0,$y.jsxs)(we,{id:"chai-image-editor-container",className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",children:[s&&(0,$y.jsx)(lf,{}),l&&d&&(0,$y.jsx)(k8.default,{theme:f,source:e,onSave:m,onClose:g,Text:{text:a("Add text here")},Rotate:{angle:90,componentType:"slider"},tabsIds:h.tabsIds,defaultTabId:h.defaultTabId,defaultToolId:h.defaultToolId,savingPixelRatio:20,previewPixelRatio:6,defaultSavedImageName:r,moreSaveOptions:b,useZoomPresetsMenu:!0})]})})});w8.displayName="ImageEditor";gae=w8});var Up,Gr,T8,RB,pT,at,fae,N8,hae,P8,yae,bae,E8,A8=x(()=>{"use strict";Up=require("lucide-react"),Gr=K(require("react"),1),T8=require("react-dropzone"),RB=require("react-i18next"),pT=require("sonner");zm();Us();xw();hl();Tw();J();Wd();Sr();Oo();$v();ea();iT();cT();at=require("react/jsx-runtime"),fae=Gr.default.lazy(()=>Promise.resolve().then(()=>(BB(),IB))),N8="images",hae=25*1024*1024,P8=30,yae=({isActive:e,show:t})=>{let{t:o}=(0,RB.useTranslation)();return(0,at.jsx)(E,{variant:"ghost",size:"icon",onClick:t,"aria-label":o("Images"),title:o("Images"),className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,at.jsx)(Up.ImageIcon,{className:"h-5 w-5"})})},bae=()=>{var _,F;let{t:e}=(0,RB.useTranslation)(),[t,o]=(0,Gr.useState)(()=>localStorage.getItem("chai_optimize_images")!=="false");(0,Gr.useEffect)(()=>{localStorage.setItem("chai_optimize_images",t.toString())},[t]);let[r,n]=(0,Gr.useState)(""),[a,s]=(0,Gr.useState)("");(0,Gr.useEffect)(()=>{let O=setTimeout(()=>s(r),300);return()=>clearTimeout(O)},[r]);let[i,l]=(0,Gr.useState)(1),[c,d]=(0,Gr.useState)([]);(0,Gr.useEffect)(()=>{l(1),d([])},[a]);let{data:p,isLoading:u,isFetching:m}=lT({search:a.toLowerCase().trim(),page:i,limit:P8});(0,Gr.useEffect)(()=>{p!=null&&p.assets&&d(O=>{let U=new Map(O.map(j=>[j.id,j]));for(let j of p.assets)j.type==="image"&&U.set(j.id,j);return Array.from(U.values())})},[p]);let g=(0,Gr.useMemo)(()=>c,[c]),f=((F=(_=p==null?void 0:p.assets)==null?void 0:_.length)!=null?F:0)===P8,b=m&&i>1,{mutateAsync:y,isPending:k}=Gy(),{mutateAsync:w}=aT(),{mutateAsync:N}=sT(),[I,C]=(0,Gr.useState)([]),[P,B]=(0,Gr.useState)(null),[T,v]=(0,Gr.useState)(null),S=(0,Gr.useCallback)(O=>{navigator.clipboard.writeText(O.url),pT.toast.success(e("Asset URL copied to clipboard"))},[e]),A=(0,Gr.useCallback)(async O=>{C(U=>[...U,O.id]);try{await w(O.id),d(U=>U.filter(j=>j.id!==O.id))}finally{C(U=>U.filter(j=>j!==O.id))}},[w]),D=(0,Gr.useCallback)(async(O,U)=>{if(T)try{U?await y([{file:O,folderId:void 0,name:T.name,optimize:t}]):await N({id:T.id,file:O})}finally{v(null)}},[T,y,N,t]),R=(0,Gr.useCallback)(async O=>{if(O.length===0)return;let U=[],j=0;for(let ce of O)ce.type.startsWith("image/")&&(ce.size>hae?j++:U.push(ce));if(j>0&&pT.toast.error(e("Some files exceed the maximum size limit of 25MB.")),U.length===0){j===0&&pT.toast.error(e("Invalid file type. Please upload an image."));return}try{let ce=await Promise.all(U.map(async pe=>{let ve=t?await Uy(pe):pe;return{file:await new Promise((ze,bt)=>{let W=new FileReader;W.onload=()=>ze(W.result),W.onerror=()=>bt(W.error),W.readAsDataURL(ve)}),folderId:void 0,name:pe.name,optimize:t}}));await y(ce),l(1),d([])}catch(ce){}},[y,t,e]),{getRootProps:H,getInputProps:M,open:L,isDragActive:z}=(0,T8.useDropzone)({onDrop:R,accept:{"image/*":[]},multiple:!0,noClick:!0,noKeyboard:!0,disabled:k});return(0,at.jsxs)("div",{...H({className:"relative flex h-full flex-col gap-y-3 py-3"}),children:[(0,at.jsx)("input",{...M()}),(0,at.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,at.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5",children:[(0,at.jsx)(On,{checked:t,onCheckedChange:o}),(0,at.jsx)("span",{className:"text-xs text-foreground",children:e("Optimize")})]}),(0,at.jsxs)(E,{variant:"outline",size:"sm",onClick:L,disabled:k,loading:k,children:[(0,at.jsx)(Up.Upload,{className:"h-3.5 w-3.5"}),e("Upload")]})]}),(0,at.jsx)(Yr,{setValue:n,value:r,placeholder:e("Search images...")}),(0,at.jsx)("div",{className:"flex-1 overflow-y-auto",children:u&&i===1?(0,at.jsx)("div",{className:"grid grid-cols-2 gap-2 px-0",children:Array.from({length:8}).map((O,U)=>(0,at.jsx)("div",{className:"aspect-square animate-pulse bg-accent"},U))}):g.length===0&&!f?(0,at.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-y-2 px-4 text-center",children:[(0,at.jsx)(Up.Upload,{className:"h-8 w-8 text-muted-foreground"}),(0,at.jsx)("p",{className:"text-xs text-muted-foreground",children:a.length>0?e("No images found"):e("Drop images here or use the Upload button to add them.")})]}):(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)("div",{className:"grid grid-cols-2 gap-2",children:g.map(O=>(0,at.jsxs)("div",{className:Co("group relative overflow-hidden border border-transparent transition-colors hover:border-foreground/20",I.includes(O.id)?"pointer-events-none opacity-50":""),children:[(0,at.jsx)(Ox,{type:"Image",block:{image:O.url,alt:O.name,name:O.name},className:"block",children:(0,at.jsx)(Ye,{content:O.name,children:(0,at.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden bg-muted",children:(0,at.jsx)(qo,{src:O.thumbnailUrl||O.url,alt:O.name,className:"max-h-full max-w-full object-contain"})})})}),(0,at.jsx)("div",{className:"absolute right-1 top-1 opacity-0 transition-opacity group-hover:opacity-100 has-[[data-state=open]]:opacity-100",children:(0,at.jsxs)(Yt,{children:[(0,at.jsx)($t,{asChild:!0,children:(0,at.jsx)(E,{variant:"secondary",size:"icon-sm","aria-label":e("More actions"),title:e("More actions"),className:"h-6 w-6 rounded-sm opacity-90 hover:opacity-100",children:(0,at.jsx)(Up.MoreVertical,{className:"h-3.5 w-3.5"})})}),(0,at.jsxs)(Vt,{align:"end",side:"bottom",className:"w-36",children:[(0,at.jsx)(Ua,{children:e("ACTIONS")}),(0,at.jsx)(ye,{onClick:()=>S(O),children:e("Copy URL")}),(0,at.jsx)(ye,{onClick:()=>B(O.id),children:e("View Details")}),(0,at.jsx)(ye,{onClick:()=>v({id:O.id,url:O.url,name:O.name}),children:e("Edit Image")}),(0,at.jsx)(ye,{onClick:()=>A(O),children:e("Delete")})]})]})})]},O.id))}),f&&(0,at.jsx)("div",{className:"pt-3",children:(0,at.jsx)(E,{variant:"outline",size:"sm",className:"w-full",onClick:()=>l(O=>O+1),disabled:b,loading:b,children:e("Load more")})})]})}),(z||k)&&(0,at.jsxs)("div",{className:Co("pointer-events-none absolute inset-2 z-50 flex flex-col items-center justify-center gap-y-2 rounded-lg border-2 border-dashed bg-background/90 text-center",z?"border-primary":"border-border"),children:[(0,at.jsx)(Up.Upload,{className:"h-8 w-8 text-primary"}),(0,at.jsx)("p",{className:"text-sm font-medium text-foreground",children:e(k?"Uploading...":"Drop images to upload")})]}),(0,at.jsx)(jm,{mode:"image",assetId:P!=null?P:void 0,open:!!P,onOpenChange:O=>!O&&B(null),onSelect:()=>B(null)}),T&&(0,at.jsx)(Gr.Suspense,{fallback:(0,at.jsx)(Pn,{className:"top-0"}),children:(0,at.jsx)(fae,{imageUrl:T.url,defaultSavedImageName:T.name,isEditing:!0,onSave:D,onClose:()=>v(null)})})]})},E8={button:yae,label:"Images",position:"top",width:280,icon:(0,at.jsx)(Up.ImageIcon,{className:"h-5 w-5"}),panel:bae}});var I8,tf,B8,Qo,DB,xae,vae,R8,D8=x(()=>{"use strict";I8=require("lodash-es"),tf=require("lucide-react"),B8=require("react-i18next");Ke();Tt();Nn();Ge();FP();J();Qo=require("react/jsx-runtime"),DB="page-errors",xae=({isActive:e,show:t})=>{let{errorCount:o,warningCount:r}=fu(),n=o+r;return(0,Qo.jsxs)(E,{variant:"ghost",size:"icon",onClick:t,className:`relative h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:[(0,Qo.jsx)(tf.AlertTriangle,{className:"h-5 w-5"}),n>0&&(0,Qo.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:n>99?"99+":n})]})},vae=()=>{let{errors:e,errorCount:t,warningCount:o}=fu(),[,r]=Pe(),n=q("gotoPage",I8.noop),{saveState:a}=to(),{selectedLang:s,fallbackLang:i}=fe(),{t:l}=(0,B8.useTranslation)(),c=(u,m)=>{if(m){if(a!=="SAVED")return;n({pageId:m,lang:s||i});return}u&&r([u])};if(e.length===0)return(0,Qo.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[(0,Qo.jsx)(tf.CheckCircle2,{className:"h-10 w-10 text-green-500"}),(0,Qo.jsxs)("div",{children:[(0,Qo.jsx)("p",{className:"text-sm font-medium",children:l("No issues found")}),(0,Qo.jsx)("p",{className:"text-xs text-muted-foreground",children:l("This page has no validation errors or warnings.")})]})]});let d=e.filter(u=>u.severity==="error"),p=e.filter(u=>u.severity==="warning");return(0,Qo.jsxs)("div",{className:"space-y-3",children:[(0,Qo.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t>0&&(0,Qo.jsxs)("span",{className:"text-red-500",children:[t," ",l(t===1?"error":"errors")]}),t>0&&o>0&&(0,Qo.jsx)("span",{children:"\xB7"}),o>0&&(0,Qo.jsxs)("span",{className:"text-orange-500",children:[o," ",l(o===1?"warning":"warnings")]})]}),d.length>0&&(0,Qo.jsx)("div",{className:"space-y-1.5",children:d.map(u=>(0,Qo.jsx)("button",{type:"button","aria-label":`Navigate to error: ${u.message}`,className:"w-full cursor-pointer rounded-md border border-red-200 bg-red-50 p-2 text-left text-xs transition-colors hover:bg-red-100 dark:border-red-900 dark:bg-red-950/30 dark:hover:bg-red-950/50",onClick:()=>c(u.blockId,u.partialBlockId),children:(0,Qo.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,Qo.jsxs)("div",{className:"flex-1",children:[(0,Qo.jsxs)("span",{className:"font-medium text-red-700 dark:text-red-400",children:[l("Error"),": "]}),(0,Qo.jsx)("span",{className:"text-red-600 dark:text-red-300",children:u.message})]}),u.partialBlockId?(0,Qo.jsx)(tf.ExternalLink,{className:"mt-0.5 h-3 w-3 shrink-0 text-red-400"}):null]})},u.id))}),p.length>0&&(0,Qo.jsx)("div",{className:"space-y-1.5",children:p.map(u=>(0,Qo.jsx)("button",{type:"button","aria-label":`Navigate to warning: ${u.message}`,className:"w-full cursor-pointer rounded-md border border-orange-200 bg-orange-50 p-2 text-left text-xs transition-colors hover:bg-orange-100 dark:border-orange-900 dark:bg-orange-950/30 dark:hover:bg-orange-950/50",onClick:()=>c(u.blockId,u.partialBlockId),children:(0,Qo.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,Qo.jsxs)("div",{className:"flex-1",children:[(0,Qo.jsxs)("span",{className:"font-medium text-orange-700 dark:text-orange-400",children:[l("Warning"),": "]}),(0,Qo.jsx)("span",{className:"text-orange-600 dark:text-orange-300",children:u.message})]}),u.partialBlockId?(0,Qo.jsx)(tf.ExternalLink,{className:"mt-0.5 h-3 w-3 shrink-0 text-orange-400"}):null]})},u.id))})]})},R8={id:DB,label:"Errors",panel:vae,button:xae,position:"top",width:280,view:"standard"}});var _8,L8,Vy,M8,O8,ia,Cae,kae,F8,H8=x(()=>{"use strict";_8=require("lodash-es"),L8=require("lucide-react"),Vy=require("react"),M8=require("react-i18next"),O8=require("sonner");J();iT();ia=require("react/jsx-runtime"),Cae=(0,Vy.lazy)(()=>Promise.resolve().then(()=>(kx(),IS))),kae=e=>{let{t}=(0,M8.useTranslation)(),[o,r]=(0,Vy.useState)(null),{mutateAsync:n,isPending:a}=Gy(),s=async()=>{let l={name:"ai-generated-image-"+Date.now()+".webp",description:"AI generated image"},c=await n([{file:o,name:l.name,description:{en:l.description},optimize:!0}]);return{...(0,_8.first)(c)||{},description:l.description}},i=async()=>{try{if(o){let l=await s();e.onSelect(e!=null&&e.multiple?[l]:l),e.close()}}catch(l){O8.toast.error("Error in adding image to website assets")}};return(0,ia.jsxs)("div",{className:"flex h-full w-full gap-1 overflow-hidden",children:[(0,ia.jsx)("div",{className:`h-full w-[300px] overflow-hidden rounded-md border border-border p-1 ${o?"pb-7":""}`,children:(0,ia.jsx)(Vy.Suspense,{fallback:(0,ia.jsx)("div",{className:"h-full w-full animate-pulse bg-accent"}),children:(0,ia.jsx)(Cae,{type:"generate-image",onSuccess:console.log,onError:console.log,onComplete:console.log,onImageGenerate:l=>r(l)})})}),(0,ia.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden rounded-md border border-dashed",children:[(0,ia.jsx)("div",{className:"flex-1 overflow-hidden p-2",children:o?(0,ia.jsx)("img",{src:o,alt:"Generated",className:"h-full w-full object-contain"}):(0,ia.jsxs)("div",{className:"flex h-full flex-1 flex-col items-center justify-center gap-4 rounded-md bg-accent/10",children:[(0,ia.jsx)("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-muted/30",children:(0,ia.jsx)(L8.ImageIcon,{className:"h-8 w-8 text-muted-foreground"})}),(0,ia.jsxs)("div",{className:"space-y-1 text-center",children:[(0,ia.jsx)("p",{className:"text-sm font-medium text-foreground",children:t("No image generated yet")}),(0,ia.jsx)("p",{className:"text-xs text-muted-foreground",children:t("Use the AI panel on the left to generate an image")})]})]})}),o&&(0,ia.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-center gap-3 border-t border-dashed px-4 py-3",children:[(0,ia.jsx)(E,{disabled:a,loading:a,variant:"outline",size:"sm",onClick:async()=>{var l;await s(),(l=e==null?void 0:e.setActiveTab)==null||l.call(e,"site")},children:"Add to website assets"}),(0,ia.jsx)(E,{disabled:a,loading:a,variant:"default",size:"sm",onClick:i,children:"Use image"})]})]})]})},F8=kae});function gT({currentPage:e,totalPages:t,onPageChange:o,pageRangeDisplayed:r=3,showPageInput:n=!0,className:a=""}){let[s,i]=(0,uT.useState)(String(e)),l=(0,uT.useMemo)(()=>{let g=Math.floor(r/2),h=Math.max(1,e-g),f=Math.min(t,e+g);f-h+1<r&&(h===1?f=Math.min(t,h+r-1):f===t&&(h=Math.max(1,f-r+1)));let b=[];h>1&&(b.push(1),h>2&&b.push("..."));for(let y=h;y<=f;y++)b.push(y);return f<t&&(f<t-1&&b.push("..."),b.push(t)),b},[e,t,r]),c=g=>{g!==e&&g>=1&&g<=t&&(o(g),i(String(g)))},d=()=>{e>1&&c(e-1)},p=()=>{e<t&&c(e+1)},u=()=>{let g=Number(s);!isNaN(g)&&g>=1&&g<=t&&c(g)},m=g=>{g.key==="Enter"&&u()};return t<=1?null:(0,Ns.jsxs)("div",{className:`flex flex-wrap items-center justify-center gap-3 ${a}`,children:[(0,Ns.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Ns.jsxs)(E,{variant:"outline",size:"sm",onClick:d,disabled:e===1,className:"px-2 py-1 text-sm hover:bg-muted",children:[(0,Ns.jsx)(mT.ChevronLeft,{className:"h-4 w-4"}),"Previous"]}),(0,Ns.jsx)("div",{className:"flex items-center gap-2",children:l.map((g,h)=>{if(g==="...")return(0,Ns.jsx)("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${h}`);let f=g,b=f===e;return(0,Ns.jsx)(E,{variant:b?"default":"outline",size:"sm",onClick:()=>c(f),className:b?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-muted hover:text-foreground",children:f},f)})}),(0,Ns.jsxs)(E,{variant:"outline",size:"sm",onClick:p,disabled:e===t,className:"px-2 py-1 text-sm hover:bg-muted",children:["Next",(0,Ns.jsx)(mT.ChevronRight,{className:"h-4 w-4"})]})]}),n&&(0,Ns.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Ns.jsx)("span",{className:"text-sm text-muted-foreground",children:"Go to"}),(0,Ns.jsx)(Ce,{type:"number",min:1,max:t,value:s,onChange:g=>{let h=g.target.value.replace(/[^\d]/g,"");i(h)},onKeyDown:m,className:"h-8 w-16 px-2 py-1"}),(0,Ns.jsx)(E,{variant:"outline",size:"sm",onClick:u,disabled:s===""||Number(s)<1||Number(s)>t,children:"Go"})]})]})}var mT,uT,Ns,_B=x(()=>{"use strict";mT=require("lucide-react"),uT=require("react");J();fo();Ns=require("react/jsx-runtime")});var Td,G8,$8,V8,U8,LB,z8,fT,MB=x(()=>{"use strict";Td=require("@tanstack/react-query"),G8=require("react"),$8=require("sonner");St();rt();Kt();V8=e=>{let t=le(),o=he(),{query:r,provider:n,filters:a={},page:s=1,limit:i=20}=e,l=Object.fromEntries(Object.entries(a).filter(([c,d])=>d!=="default"&&d!=="all"));return(0,Td.useQuery)({queryKey:[$.SEARCH_IMAGES,r,n,l,s,i],queryFn:async()=>await o(t,{action:$.SEARCH_IMAGES,data:{query:r,provider:n,filters:l,page:s,limit:i}}),enabled:!!r,staleTime:1/0,placeholderData:Td.keepPreviousData})},U8={query:"",provider:"",filters:{},page:1},LB=["DAM_SEARCH_STATE"],z8=()=>{let e=(0,Td.useQueryClient)(),{data:t}=(0,Td.useQuery)({queryKey:LB,queryFn:()=>{var r;return(r=e.getQueryData(LB))!=null?r:U8},staleTime:1/0,gcTime:1/0,initialData:U8}),o=(0,G8.useCallback)(r=>{e.setQueryData(LB,n=>({...n,...r}))},[e]);return{searchState:t,updateSearchState:o}},fT=()=>{let e=le(),t=he(),o=(0,Td.useQueryClient)();return(0,Td.useMutation)({mutationFn:async r=>t(e,{action:$.DOWNLOAD_SEARCH_IMAGE,data:{url:r.url,name:r.name,description:r.description||{en:r.name}}}),onSuccess:()=>{o.invalidateQueries({queryKey:[$.GET_ASSETS]})},onError:r=>{$8.toast.error(r.message||"Something went wrong. Please try again")}})}});var Pu,Tu,Es,W8,OB,Me,Sae,wae,Pae,j8,q8=x(()=>{"use strict";Pu=require("lodash-es"),Tu=require("lucide-react"),Es=require("react"),W8=require("react-i18next"),OB=require("sonner");Us();hl();J();qt();No();Gs();rt();_B();MB();Me=require("react/jsx-runtime"),Sae=["id","url","thumbnailUrl","width","height","description","provider","authorName","authorUrl","authorThumbnailUrl","providerUrl","providerLogoUrl"],wae={orientation:["default","landscape","portrait","squarish"]},Pae=({onSelect:e,multiple:t,close:o})=>{var D;let{t:r}=(0,W8.useTranslation)(),n=Nt("dam"),a=(0,Es.useMemo)(()=>{var R;return((R=n==null?void 0:n.searchImages)==null?void 0:R.providers)||[]},[n]),{searchState:s,updateSearchState:i}=z8(),[l,c]=(0,Es.useState)(s.query||""),[d,p]=(0,Es.useState)(null),[u,m]=(0,Es.useState)(null);(0,Es.useEffect)(()=>{c(s.query)},[s.query]);let{query:g,provider:h,page:f,filters:b}=s,y=h||((D=a[0])==null?void 0:D.id),k=(0,Es.useMemo)(()=>a.find(R=>R.id===y),[a,y]),w=(0,Es.useMemo)(()=>(k==null?void 0:k.filters)||wae,[k]),{data:N,isLoading:I,isFetching:C,isError:P}=V8({query:g,provider:y,filters:b,page:f}),B=(N==null?void 0:N.total)||0,T=Math.ceil(B/20),{mutateAsync:v}=fT();(0,Es.useEffect)(()=>{P&&OB.toast.error(r("Something went wrong. Please try again"))},[P,r]),(0,Es.useEffect)(()=>{let R={...b},H=!1;Object.entries(w).forEach(([M,L])=>{let z=L;!R[M]&&!z.includes("default")&&z.length>0&&(R[M]=z[0],H=!0)}),H&&i({filters:R})},[w,b,i]);let S=(0,Es.useCallback)(()=>{l.trim()&&i({query:l,page:1})},[l,i]),A=(0,Es.useCallback)(async R=>{p(R.id);try{let H=R.description||R.alt||R.name,M=await v({...R,name:R.name||H,description:{en:H}}),L={...(0,Pu.pick)(M,Sae),description:R.description||R.alt||R.name};e(t?[L]:L),o()}catch(H){console.error(H),OB.toast.error(r("Something went wrong. Please try again"))}finally{p(null)}},[o,v,t,e,r]);return{state:{providers:a,selectedProvider:y,searchInputValue:l,dbSearchQuery:g,currentPage:f,filters:b,isProcessing:d,availableFilters:w,data:N,isLoading:I||C,totalPages:T,previewImage:u},setters:{setSelectedProvider:R=>i({provider:R,page:1}),setSearchInputValue:c,setFilters:R=>{let H=typeof R=="function"?R(b):R;i({filters:H,page:1})},setCurrentPage:R=>i({page:R}),setPreviewImage:m},handlers:{handleSearch:S,handleUseImage:A},t:r}},j8=({onSelect:e,multiple:t,close:o})=>{var T,v;let{state:r,setters:n,handlers:a,t:s}=Pae({onSelect:e,multiple:t,close:o}),{providers:i,selectedProvider:l,searchInputValue:c,dbSearchQuery:d,currentPage:p,filters:u,isProcessing:m,availableFilters:g,data:h,isLoading:f,totalPages:b,previewImage:y}=r,{setSelectedProvider:k,setSearchInputValue:w,setFilters:N,setCurrentPage:I,setPreviewImage:C}=n,{handleSearch:P,handleUseImage:B}=a;return(0,Me.jsxs)("div",{className:"flex flex-1 flex-col gap-4 overflow-hidden",children:[(0,Me.jsx)("div",{className:"flex flex-col gap-3 p-1",children:(0,Me.jsxs)("div",{className:"flex items-end gap-2",children:[i.length>1&&(0,Me.jsxs)("div",{className:"flex min-w-40 flex-col gap-1",children:[(0,Me.jsx)(Q,{className:"text-[8px] font-medium uppercase text-muted-foreground",children:s("Provider")}),(0,Me.jsxs)(So,{value:l,onValueChange:k,children:[(0,Me.jsx)(ho,{className:"h-8",children:(0,Me.jsx)(Do,{placeholder:s("Provider")})}),(0,Me.jsx)(yo,{children:i.map(S=>(0,Me.jsx)(gt,{value:S.id,children:(0,Pu.startCase)(S.id)},S.id))})]})]}),(0,Me.jsxs)("div",{className:"relative flex-1",children:[(0,Me.jsx)(Q,{className:"text-[8px] font-medium uppercase text-muted-foreground",children:s("Search")}),(0,Me.jsx)(Yr,{value:c,setValue:w,placeholder:s("eg. bakery shop"),autoFocus:!0,onKeyDown:S=>{S.key==="Enter"&&P()}})]}),(0,Me.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.entries(g).map(([S,A])=>(0,Me.jsxs)("div",{className:"flex min-w-32 flex-col gap-1",children:[(0,Me.jsx)(Q,{className:"text-[8px] font-medium uppercase text-muted-foreground",children:s((0,Pu.startCase)(S))}),(0,Me.jsxs)(So,{value:u[S]||"default",onValueChange:D=>N(R=>({...R,[S]:D})),children:[(0,Me.jsx)(ho,{className:"h-8 text-xs",children:(0,Me.jsx)(Do,{placeholder:s((0,Pu.startCase)(S))})}),(0,Me.jsx)(yo,{children:A.map(D=>(0,Me.jsx)(gt,{value:D,children:D==="default"||D==="all"?`${s("All")} ${s((0,Pu.startCase)(S))}`:(0,Pu.startCase)(D)},D))})]})]},S))}),(0,Me.jsx)(E,{onClick:P,disabled:!c.trim(),children:s("Search")})]})}),(0,Me.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:d?f?(0,Me.jsx)("div",{className:"grid grid-cols-2 gap-3 p-1 md:grid-cols-4 lg:grid-cols-5",children:[...Array(10)].map((S,A)=>(0,Me.jsx)("div",{className:"aspect-square h-52 w-full animate-pulse rounded-lg bg-accent"},A))}):(0,Me.jsxs)(Me.Fragment,{children:[(0,Me.jsx)("div",{className:"grid grid-cols-2 gap-3 p-1 pb-16 md:grid-cols-4 lg:grid-cols-5",children:(T=h==null?void 0:h.assets)==null?void 0:T.map(S=>(0,Me.jsx)("div",{className:"group relative flex flex-col overflow-hidden rounded-lg border border-border hover:border-primary/50",children:(0,Me.jsxs)("div",{className:"aspect-square relative flex-1 cursor-pointer overflow-hidden",onClick:()=>C(S),children:[(0,Me.jsx)(qo,{src:S.thumbnailUrl,alt:S.name,className:"h-full w-full object-cover transition-transform group-hover:scale-105"}),(0,Me.jsxs)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex items-start justify-between p-2",children:[S.authorName&&(0,Me.jsxs)("a",{href:S.authorUrl,target:"_blank",rel:"noopener noreferrer",className:"pointer-events-auto cursor-pointer rounded-md bg-black/40 px-1.5 py-0.5 text-[9px] font-medium text-white backdrop-blur-sm hover:bg-black/60",onClick:A=>A.stopPropagation(),children:["@",S.authorName]}),S.providerUrl&&(0,Me.jsx)("a",{href:S.providerUrl,target:"_blank",rel:"noopener noreferrer",className:"pointer-events-auto cursor-pointer rounded-md bg-black/40 px-1.5 py-0.5 text-[9px] text-white",onClick:A=>A.stopPropagation(),children:S.providerLogoUrl?(0,Me.jsx)("img",{src:S.providerLogoUrl,className:"h-3.5 object-contain",alt:S.provider}):S.provider.toUpperCase()})]}),(0,Me.jsx)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100",children:(0,Me.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Me.jsx)(E,{size:"sm",onClick:A=>{A.stopPropagation(),B(S)},disabled:!!m,loading:m===S.id,children:s("Use Image")}),(0,Me.jsx)(E,{size:"sm",variant:"outline",onClick:A=>{A.stopPropagation(),C(S)},children:(0,Me.jsx)(Tu.Eye,{className:"h-4 w-4"})})]})})]})},S.id))}),(!(h!=null&&h.assets)||((v=h==null?void 0:h.assets)==null?void 0:v.length)===0)&&(0,Me.jsxs)("div",{className:"flex h-[60%] flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,Me.jsx)(Tu.FileImage,{className:"h-6 w-6"}),(0,Me.jsx)("p",{className:"text-sm",children:s("No images found for your search")})]})]}):(0,Me.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,Me.jsx)(Tu.FileSearch,{className:"h-6 w-6"}),(0,Me.jsx)("p",{className:"text-sm",children:s("Search for images to get started")})]})}),!!d&&b>1&&(0,Me.jsx)("div",{className:"bg-surface border-t p-4",children:(0,Me.jsx)(gT,{currentPage:p,totalPages:b,onPageChange:I,pageRangeDisplayed:3,showPageInput:!0})}),(0,Me.jsx)(Te,{open:!!y,onOpenChange:S=>!S&&C(null),children:(0,Me.jsxs)(we,{className:"max-w-3xl overflow-hidden p-3",children:[(0,Me.jsx)(Ie,{children:s("Preview Image")}),(0,Me.jsxs)("div",{className:"flex flex-col",children:[(0,Me.jsxs)("div",{className:"relative bg-black/5",children:[(0,Me.jsx)(qo,{src:(y==null?void 0:y.url)||(y==null?void 0:y.thumbnailUrl),alt:y==null?void 0:y.name,className:"h-full max-h-[70vh] w-full object-contain"}),(0,Me.jsxs)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex items-start justify-between p-4",children:[(y==null?void 0:y.authorName)&&(0,Me.jsxs)("a",{href:y.authorUrl,target:"_blank",rel:"noopener noreferrer",className:"pointer-events-auto cursor-pointer rounded-md bg-black/40 px-2 py-1 text-xs font-medium text-white backdrop-blur-sm hover:bg-black/60",children:[s("@"),y.authorName]}),(y==null?void 0:y.providerUrl)&&(0,Me.jsx)("a",{href:y.providerUrl,target:"_blank",rel:"noopener noreferrer",className:"pointer-events-auto cursor-pointer rounded-md bg-black/40 px-2 py-1 text-[10px] text-white",children:y.providerLogoUrl?(0,Me.jsx)("img",{src:y.providerLogoUrl,className:"h-5 object-contain",alt:y.provider}):s((y==null?void 0:y.provider)||"")})]})]}),(0,Me.jsxs)("div",{className:"flex p-2",children:[(0,Me.jsx)(Oe,{className:"flex-1"}),(0,Me.jsxs)("div",{className:"flex w-full items-center justify-end gap-2",children:[(0,Me.jsxs)("div",{className:"flex items-start gap-2 rounded-lg bg-primary/5 p-2 text-sm text-primary",children:[(0,Me.jsx)(Tu.Info,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,Me.jsx)("p",{className:"text-xs leading-relaxed",children:s("This image will be added to your website assets")})]}),(0,Me.jsx)(E,{variant:"default",onClick:()=>{B(y)},disabled:!!m,loading:m===(y==null?void 0:y.id),children:s("Use Image")})]})]})]})]})})]})}});function Tae(e){let t=isNaN(e)?0:typeof e=="number"?e:parseInt(e);return t?t<1024?`${t.toFixed(2)} B`:t<1024*1024?`${(t/1024).toFixed(2)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`:"0 B"}function K8(e){if(!e)return"N/A";let t=new Date(e);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}function Nae(e,t,o="en"){let r=e||{},n=typeof(t==null?void 0:t.description)=="string"?{[o]:t.description}:(t==null?void 0:t.description)||{},a=Object.keys(r),s=Object.keys(n),i=new Set([...a,...s]);for(let l of i){let c=r[l]||"",d=n[l]||"";if(c!==d)return!0}return!1}var hc,Gp,Y8,zy,qe,J8,Q8=x(()=>{"use strict";hc=require("lucide-react"),Gp=K(require("react"),1),Y8=require("react-i18next"),zy=require("sonner");Us();Ke();Tt();St();Kt();J();No();Oo();Gs();gs();zs();cT();qe=require("react/jsx-runtime");J8=({assetId:e,onBack:t,onEdit:o,onSave:r,isSaving:n})=>{var B;let{t:a}=(0,Y8.useTranslation)(),{data:s,isLoading:i,isError:l}=x8(e||""),[c,d]=(0,Gp.useState)({}),[p,u]=(0,Gp.useState)(!1),{languages:m,fallbackLang:g,selectedLang:h}=fe(),[f,b]=(0,Gp.useState)(h||g),[y,k]=(0,Gp.useState)(!1),w=q("flags.ai",!1),N=Ls(),I=[g,...m||[]];(0,Gp.useEffect)(()=>{let T=new Image;return T.src=(s==null?void 0:s.url)||"",T.onload=()=>u(!0),()=>{T.onload=null}},[s]);let C=async(T,v)=>{try{await navigator.clipboard.writeText(T),zy.toast.success(a("{{type}} copied to clipboard",{type:v}))}catch(S){zy.toast.error(a("Failed to copy {{type}}",{type:v}),{description:S==null?void 0:S.message})}},P=async()=>{if(s!=null&&s.url){k(!0);try{let T=await N({body:{action:$.AI_GENERATE_IMAGE_DESCRIPTION,data:{url:s.url,languages:I}}});T!=null&&T.translations?(d(T.translations),zy.toast.success(a("Image description generated successfully. Please save to apply."))):zy.toast.error(a("Failed to generate image description"))}catch(T){zy.toast.error(a("Failed to generate image description"),{description:T==null?void 0:T.message})}finally{k(!1)}}};return Gp.default.useEffect(()=>{if(s!=null&&s.description)if(typeof s.description=="string")try{let T=JSON.parse(s.description);d(typeof T=="object"&&T!==null?T:{[g]:s.description})}catch(T){d({[g]:s.description})}else d(s.description);else d({})},[s,g]),i||!p?(0,qe.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,qe.jsx)(wt,{})}):l||!(s!=null&&s.id)?(0,qe.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,qe.jsxs)("div",{className:"mx-auto max-w-md p-6 text-center",children:[(0,qe.jsx)("div",{className:"mb-4 flex justify-center",children:(0,qe.jsx)(hc.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),(0,qe.jsx)("h3",{className:"mb-2 text-lg font-medium text-foreground",children:a("No Asset Found")}),(0,qe.jsx)("p",{className:"mb-6 text-sm text-muted-foreground",children:a(l?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed.")}),(0,qe.jsxs)("div",{className:"flex justify-center gap-4",children:[(0,qe.jsx)(E,{variant:"outline",onClick:t,children:a("Back to Assets")}),l&&(0,qe.jsx)(E,{variant:"default",onClick:()=>window.location.reload(),children:a("Try Again")})]})]})}):(0,qe.jsxs)("div",{className:"flex flex-1 flex-col gap-y-4 overflow-hidden",children:[(0,qe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,qe.jsxs)(E,{variant:"outline",size:"sm",onClick:t,disabled:n||y,children:[(0,qe.jsx)(hc.ChevronLeft,{className:"h-4 w-4"}),a("Back to Assets")]}),(0,qe.jsxs)("div",{className:"flex gap-2",children:[(0,qe.jsx)(E,{variant:"outline",onClick:t,disabled:n||y,children:a("Cancel")}),(0,qe.jsxs)(E,{variant:"outline",onClick:()=>C(s.url,a("Asset URL")),disabled:n||y,children:[(0,qe.jsx)(hc.Copy,{className:"mr-2 h-4 w-4"}),a("Copy URL")]}),(0,qe.jsxs)(E,{variant:"default",onClick:()=>o(s),disabled:n||y,children:[(0,qe.jsx)(hc.Pencil,{className:"h-4 w-4"}),a("Edit Image")]})]})]}),(0,qe.jsxs)("div",{className:"grid flex-1 grid-cols-2 items-start gap-6 overflow-hidden",children:[(0,qe.jsx)("div",{className:"relative flex h-[calc(80vh-200px)] w-full items-start justify-center",children:(0,qe.jsx)(qo,{src:s.url,alt:s.name,className:"h-full max-h-max w-full max-w-max rounded-lg object-contain"})}),(0,qe.jsxs)("div",{className:"space-y-2 overflow-y-auto",children:[(0,qe.jsxs)("div",{className:"grid gap-4 rounded-xl border bg-accent p-3",children:[(0,qe.jsx)(Q,{className:"text-sm font-medium text-foreground/80",children:a("Details")}),(0,qe.jsx)("div",{className:"space-y-4",children:[{label:a("Name"),value:s.name,fullWidth:!0},{label:a("Type"),value:s.type,capitalize:!0},{label:a("Format"),value:(s==null?void 0:s.format)||s.type,capitalize:!0},{label:a("Size"),value:Tae(s.size)},{label:a("Dimensions"),value:`${s.width||0} \xD7 ${s.height||0}`},{label:a("Created"),value:K8(s.createdAt)},{label:a("Updated"),value:K8(((B=s.metadata)==null?void 0:B.updatedAt)||(s==null?void 0:s.updatedAt)||s.createdAt)},{label:a("URL"),value:(()=>{try{let T=new URL(s.url),v=T.pathname.split("/"),S=v.indexOf("dam-assets");return S!==-1?`${v.slice(S+1).join("/")}`:T.pathname}catch(T){return s.url}})(),copyable:!0,fullValue:s.url,fullWidth:!0}].reduce((T,v)=>{if(v.fullWidth)T.push([v]);else{let S=T[T.length-1];S&&S.length===1&&!S[0].fullWidth?S.push(v):T.push([v])}return T},[]).map((T,v)=>(0,qe.jsx)("div",{className:"grid grid-cols-2 gap-4",children:T.map(S=>(0,qe.jsxs)("div",{className:S.fullWidth?"col-span-2":"col-span-1",children:[(0,qe.jsx)(Q,{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70",children:S.label}),(0,qe.jsxs)("div",{className:"flex items-start gap-2",children:[(0,qe.jsx)("div",{className:"text-sm font-light leading-relaxed text-foreground "+(S.capitalize?" capitalize ":" ")+(S.fullWidth?" line-clamp-2 break-all":" truncate"),title:S.fullValue||S.value,children:S.value}),S.copyable&&(0,qe.jsx)(E,{variant:"ghost",size:"icon-xs",onClick:()=>C(S.fullValue||S.value,S.label),children:(0,qe.jsx)(hc.Copy,{className:"h-3 w-3"})})]})]},S.label))},v))})]}),s.usedOn&&s.usedOn.length>0&&(0,qe.jsxs)("div",{className:"grid gap-3",children:[(0,qe.jsx)(Q,{className:"text-base font-semibold text-foreground/80",children:a("Used On")}),(0,qe.jsx)("div",{className:"grid grid-cols-1 gap-2 rounded-xl border bg-muted/20 p-3 text-sm",children:s.usedOn.map((T,v)=>(0,qe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,qe.jsx)("div",{className:"w-max text-left font-medium text-foreground",children:T.name}),(0,qe.jsxs)("div",{className:"text-muted-foreground/70",children:["(",T.slug,")"]})]},v))})]}),(0,qe.jsxs)("div",{className:"relative grid gap-1 rounded-xl border bg-accent p-3",children:[(0,qe.jsxs)("div",{className:"flex items-center justify-between gap-x-3",children:[(0,qe.jsx)(Q,{className:"flex items-center gap-1 text-sm font-medium text-foreground/80",children:a("Description")}),(m==null?void 0:m.length)>0&&(0,qe.jsxs)(So,{value:f,onValueChange:b,children:[(0,qe.jsx)(ho,{className:"bg-surface h-6 w-max gap-x-2 pr-1 text-xs ring-offset-background focus:ring-1 focus:ring-ring",children:(0,qe.jsx)(Do,{})}),(0,qe.jsx)(yo,{children:I.map(T=>(0,qe.jsx)(gt,{value:T,className:"text-xs",children:Jt[T]||T},T))})]}),w&&(0,qe.jsx)(E,{size:"xs",variant:"outline",className:"ml-auto h-6",onClick:P,disabled:y||n,"aria-label":a("Generate description with AI"),title:a("Generate description with AI"),children:y?(0,qe.jsx)(wt,{className:"!h-3 !w-3"}):(0,qe.jsx)(hc.Wand2Icon,{className:"text-orange h-3 w-3"})}),(0,qe.jsx)(E,{size:"xs",className:"h-6 px-3",loading:n,onClick:()=>r(c),disabled:n||!Nae(c,s,g),children:a("Save")})]}),(0,qe.jsx)(Ro,{id:"description",value:c[f]||"",placeholder:a("Enter a description for the asset"),onChange:T=>d(v=>({...v,[f]:T.target.value})),rows:2,disabled:n||y,className:"bg-surface mt-1 resize-none text-sm transition-all focus-visible:ring-1"})]})]})]})]})}});var X8,Wy,Nd,Z8,zv,Vv,Mt,Eae,Aae,Iae,Bae,ej,tj=x(()=>{"use strict";"use client";X8=require("lodash-es"),Wy=require("lucide-react"),Nd=require("react"),Z8=require("react-dropzone"),zv=require("react-i18next"),Vv=require("sonner");zm();$v();ea();J();fo();Wd();Oo();MB();Mt=require("react/jsx-runtime"),Eae=25*1024*1024,Aae=({isUpdatingAsset:e})=>{let{t}=(0,zv.useTranslation)();return(0,Mt.jsx)("div",{className:"flex flex-col items-center px-6",children:(0,Mt.jsxs)("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[(0,Mt.jsx)("div",{className:"flex items-center justify-center rounded-full border border-muted-foreground/30 bg-muted/30 p-2",children:(0,Mt.jsx)(wt,{})}),(0,Mt.jsxs)("div",{className:"text-left",children:[(0,Mt.jsx)("div",{className:"text-sm font-medium text-foreground",children:t(e?"Updating file...":"Uploading file...")}),(0,Mt.jsxs)("div",{className:"text-xs font-light text-muted-foreground",children:[t("Please wait while we")," ",t(e?"update":"upload")," ",t("your file...")]})]})]})})},Iae=({allowedTypes:e,optimizeImages:t,setOptimizeImages:o,onSwitchToUrl:r})=>{let{t:n}=(0,zv.useTranslation)();return(0,Mt.jsxs)("div",{className:"flex w-full items-center justify-between px-6",children:[(0,Mt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Mt.jsx)("div",{className:"flex items-center justify-center rounded-full border border-muted-foreground/30 bg-muted/30 p-2",children:(0,Mt.jsx)(Wy.Upload,{className:"h-4 w-4 text-muted-foreground"})}),(0,Mt.jsxs)("div",{className:"text-left",children:[(0,Mt.jsxs)("div",{className:"flex items-center gap-1.5 text-sm",children:[(0,Mt.jsx)("span",{className:"text-muted-foreground",children:n("Drop your file here or")}),(0,Mt.jsx)("span",{className:"cursor-pointer font-medium text-primary underline-offset-4 transition-colors hover:text-primary/80 hover:underline",children:n("Browse")}),(0,Mt.jsx)("span",{className:"mx-0.5 h-3.5 w-[1px] bg-border","aria-hidden":"true"}),(0,Mt.jsx)("span",{role:"button",tabIndex:0,className:"cursor-pointer font-medium text-primary underline-offset-4 transition-colors hover:text-primary/80 hover:underline",onClick:a=>{a.stopPropagation(),r()},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.stopPropagation(),r())},children:n("Upload via URL")})]}),(0,Mt.jsxs)("div",{className:"text-xs font-light text-muted-foreground",children:[n("Accepted file types:")," ",(0,Mt.jsx)("span",{className:"capitalize text-foreground/80",children:e.join(", ")})]})]})]}),(0,Mt.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Mt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Mt.jsx)("span",{className:"text-xs text-foreground",children:n("Image Optimization")}),(0,Mt.jsx)(On,{checked:t,onCheckedChange:a=>o(a),onClick:a=>a.stopPropagation()})]}),(0,Mt.jsx)(Ye,{content:n("Warning: Unoptimized images may affect performance and page load times"),side:"top",showTooltip:!t,children:(0,Mt.jsx)("span",{className:Co("text-warning cursor-help items-center transition-opacity",t?"hidden":"flex"),children:(0,Mt.jsx)(Wy.AlertTriangle,{className:"h-4 w-4"})})})]})]})},Bae=({urlInputValue:e,setUrlInputValue:t,isUploading:o,onUpload:r,onSwitchToFile:n})=>{let{t:a}=(0,zv.useTranslation)();return(0,Mt.jsxs)("div",{className:"flex w-full items-center gap-4 px-6",children:[(0,Mt.jsx)("div",{className:"flex shrink-0 items-center justify-center rounded-full border border-muted-foreground/30 bg-muted/30 p-2",children:(0,Mt.jsx)(Wy.Link,{className:"h-4 w-4 text-muted-foreground"})}),(0,Mt.jsxs)("div",{className:"flex flex-1 items-center gap-2",children:[(0,Mt.jsx)(Ce,{type:"url",placeholder:a("Paste direct image URL here (jpg, png, webp, etc.)..."),value:e,onChange:s=>t(s.target.value),onKeyDown:s=>{s.key==="Enter"&&r()},className:"h-8 flex-1 text-xs",disabled:o}),(0,Mt.jsx)(E,{size:"sm",onClick:r,disabled:!e.trim()||o,loading:o,children:a("Upload")}),(0,Mt.jsx)(E,{variant:"outline",size:"sm",onClick:n,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&n()},children:a("Cancel")})]})]})},ej=({isUpdatingAsset:e,allowedTypes:t,uploadAssets:o,isUploadingAsset:r,onUploaded:n})=>{let{t:a}=(0,zv.useTranslation)(),[s,i]=(0,Nd.useState)("file"),[l,c]=(0,Nd.useState)(()=>{let C=localStorage.getItem("chai_optimize_images");return C!==null?C==="true":!0}),[d,p]=(0,Nd.useState)(""),[u,m]=(0,Nd.useState)(!1),{mutateAsync:g}=fT();(0,Nd.useEffect)(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);let h=e||r,f=(0,Nd.useCallback)(async C=>{try{if(!C.every(v=>v.type.startsWith("image/")))return Vv.toast.error(a("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));let P=C.map(async v=>{let S=v;return v.type.startsWith("image/")&&l&&(S=await Uy(v)),new Promise((A,D)=>{let R=new FileReader;R.readAsDataURL(S),R.onload=()=>A({file:R.result,folderId:void 0,name:v.name,optimize:l}),R.onerror=()=>D(null)})}),B=await Promise.all(P),T=await o(B);return(T==null?void 0:T.length)===1&&n(T[0]),T}catch(P){return Promise.reject(P)}},[o,l,n,a]),b=C=>{let P=[],B=0;return C.forEach(T=>{T.size>Eae?B++:P.push(T)}),B>0&&Vv.toast.error(`${B===1&&C.length===1?a("File"):B+a(B===1?" file":" files")} ${a("exceed the maximum size limit of 25MB.")}`),(0,X8.isEmpty)(P)?[]:f(P)};async function y(C){return new Promise(P=>{let B=new Image;B.onload=()=>P(!0),B.onerror=()=>P(!1),B.src=C})}let k=(0,Nd.useCallback)(async()=>{var B;let C=d.trim();if(!C)return;if(!await y(d)){Vv.toast.error(a("Please enter a valid image URL (http or https)."));return}m(!0);try{let T=(B=C.split("/").pop())==null?void 0:B.split("?")[0],v=T&&T.length>0?T:"untitled-image.jpg",S=await g({id:C,url:C,name:v,thumbnailUrl:C,type:"image",provider:"url",description:{en:v}});n(S),p("")}catch(T){Vv.toast.error(a("Failed to upload image from URL. Please check that the URL points to a valid image."))}finally{m(!1)}},[d,g,n,a]),{getRootProps:w,getInputProps:N,isDragActive:I}=(0,Z8.useDropzone)({onDrop:b,accept:{"image/*":t.includes("image")?[]:[]},disabled:e||r,multiple:!0});return(0,Mt.jsx)("div",{className:Co("flex h-[60px] w-full flex-col items-center justify-center rounded-lg border p-0 py-2 transition-colors",h||u?"pointer-events-none border-border bg-muted/50 opacity-90":I?"border-muted-foreground/50":"border-border bg-muted/10 hover:bg-background/50",s==="url"&&"bg-background/50"),children:s==="file"?(0,Mt.jsxs)("div",{...w(),className:Co("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",h?"items-start":"items-center"),children:[(0,Mt.jsx)("input",{...N()}),h?(0,Mt.jsx)(Aae,{isUpdatingAsset:e}):(0,Mt.jsx)(Iae,{allowedTypes:t,optimizeImages:l,setOptimizeImages:c,onSwitchToUrl:()=>i("url")})]}):(0,Mt.jsx)(Bae,{urlInputValue:d,setUrlInputValue:p,isUploading:u,onUpload:k,onSwitchToFile:()=>i("file")})})}});var FB={};et(FB,{default:()=>sj});function sj({close:e,onSelect:t,mode:o="image",assetId:r,multiple:n=!1}){let{t:a}=(0,nj.useTranslation)(),s=10,i=(0,Lo.useMemo)(()=>[o],[o]),[l,c]=(0,Lo.useState)(null),[d,p]=(0,Lo.useState)(null),[u,m]=(0,Lo.useState)([]),[g,h]=(0,Lo.useState)({show:!1,file:""}),[f,b]=(0,Lo.useState)(!1),[y,k]=(0,Lo.useState)(r?"details":"grid"),[w,N]=(0,Lo.useState)(""),[I,C]=(0,Lo.useState)(""),[P,B]=(0,Lo.useState)(1),[T]=(0,Lo.useState)(30),[v,S]=(0,Lo.useState)([]),[A,D]=(0,Lo.useState)("site"),R=q("flags.dam.searchImages",!1),H=q("flags.dam.genAI",!1);(0,Lo.useEffect)(()=>{r&&(c(r),k("details"))},[r]),(0,Lo.useEffect)(()=>{let ue=setTimeout(()=>{N(I),B(1)},300);return()=>clearTimeout(ue)},[I]);let{data:M,isLoading:L,refetch:z}=lT({search:w.toLowerCase().trim(),page:P,limit:T}),_=(0,Lo.useMemo)(()=>(M==null?void 0:M.assets)||[],[M==null?void 0:M.assets]),F=(M==null?void 0:M.total)||0,O=Math.ceil(F/T);(0,Lo.useEffect)(()=>{L||O<=0||B(ue=>ue>O?O:ue<1?1:ue)},[L,O]);let U=(_==null?void 0:_.length)>0,{mutateAsync:j}=aT(),{mutateAsync:ce,isPending:pe}=Gy(),{mutateAsync:ve,isPending:Ve}=sT(),ze=Nt("flags",{}),bt=(0,Lo.useCallback)(ue=>{let We=Math.min(Math.max(1,ue),Math.max(1,O));We!==P&&B(We)},[O,P]),W=(0,Lo.useCallback)((ue,We=!1)=>{S(Zo=>{let Ir=(0,Vi.find)(Zo,{id:ue.id});return n||We?Ir?Zo.filter(pi=>pi.id!==ue.id):[...Zo,ue]:Ir?[]:[ue]})},[n]),ie=(0,Lo.useCallback)(()=>{S([])},[]),Y=ue=>{let We=ue!=null?ue:v;(We==null?void 0:We.length)!==0&&t(n?(0,Vi.map)(We,Zo=>(0,Vi.pick)(Zo,oj)):(0,Vi.pick)((0,Vi.first)(We),oj))},Ze=async ue=>{p([ue])},te=async()=>{if(!d||d.length===0)return;let ue=d.map(We=>We.id);m(ue),await j(ue,{onSuccess:()=>{m([]),p(null),S(We=>We.filter(Zo=>!ue.includes(Zo.id)))},onError:()=>{m([])}}),p(null)},Qe=(0,Lo.useMemo)(()=>{if(!U)return!1;let ue=new Set(v.map(We=>We.id));return _.every(We=>ue.has(We.id))},[_,v,U]),Z=()=>{if(Qe){let ue=new Set(_.map(We=>We.id));S(We=>We.filter(Zo=>!ue.has(Zo.id)))}else S(ue=>{let We=new Set(ue.map(Ir=>Ir.id)),Zo=_.filter(Ir=>!We.has(Ir.id));return[...ue,...Zo]})},ge=ue=>{c(ue.id),k("details")},Rt=async(ue,We)=>{try{let Zo=localStorage.getItem("chai_optimize_images")!=="false";if(We){let Ir=await ce([{file:ue,folderId:void 0,name:g.name||"",optimize:Zo}]);if((Ir==null?void 0:Ir.length)>0){let pi=Ir[0];t({...(0,Vi.pick)(pi,["id","width","height","description"]),url:pi.url})}}else{let Ir=await ve({id:g.id||"",file:ue});if(Ir){let pi=Ir;t({...(0,Vi.pick)(pi,["id","width","height","description"]),url:pi.url})}}h({show:!1,file:""}),e()}catch(Zo){console.error(a("Error saving edited image:"),Zo)}},sr=(0,Lo.useCallback)(ue=>{S([ue])},[]),ir=(0,Lo.useCallback)(ue=>{bt(ue)},[bt]);return(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[(0,ee.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,ee.jsx)("div",{children:(0,ee.jsx)("h1",{className:"text-lg font-medium text-foreground",children:a("Digital Asset Manager")})}),(R||H)&&y==="grid"&&(0,ee.jsx)(Dr,{value:A,onValueChange:ue=>D(ue),children:(0,ee.jsxs)(Cr,{children:[(0,ee.jsxs)(ut,{value:"site",className:"px-3",children:[(0,ee.jsx)(Ca.Images,{className:"h-3 w-3"})," ",a("Website Assets")]}),H&&(0,ee.jsxs)(ut,{value:"ai",className:"px-3",children:[(0,ee.jsx)(Ca.BrainCog,{className:"h-3 w-3"})," ",a("Generate with AI")]}),R&&(0,ee.jsxs)(ut,{value:"search",className:"px-3",children:[(0,ee.jsx)(Ca.Search,{className:"h-3 w-3"})," ",a("Search Images")]})]})})]}),y==="grid"?A==="site"?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)(ej,{maxFileSize:s,allowedTypes:i,uploadAssets:ce,isUpdatingAsset:Ve,isUploadingAsset:pe,onUploaded:sr}),(0,ee.jsxs)("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[(0,ee.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ee.jsx)("div",{className:"relative w-80",children:(0,ee.jsx)(Yr,{setValue:C,value:I,placeholder:a("Search assets...")})}),(0,ee.jsxs)("div",{className:"flex items-center gap-x-2",children:[v.length>0?(0,ee.jsx)("div",{className:"flex items-center justify-between",children:(0,ee.jsxs)("div",{className:"flex items-center gap-2",children:[v.length>1&&(0,ee.jsx)(E,{variant:"outline",size:"sm",onClick:Z,children:a(Qe?"Deselect all":"Select all")}),v.length>0&&(0,ee.jsx)(ee.Fragment,{children:(0,ee.jsx)(E,{variant:"outline",size:"sm",onClick:()=>ie(),title:a("Clear selection"),children:a("Clear")})}),v.length>1&&(0,ee.jsx)(E,{variant:"destructive",size:"sm",onClick:()=>p(v),children:a("Delete selected")}),!n&&v.length<=1||n?(0,ee.jsx)(E,{size:"sm",onClick:()=>Y(v),disabled:v.length===0,children:n?a("Select {{count}} Assets",{count:v.length}):a("Select Asset")}):null]})}):null,(0,ee.jsx)(E,{variant:"outline",size:"icon-sm",onClick:()=>z(),children:(0,ee.jsx)(Ca.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),(0,ee.jsx)("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:L?(0,ee.jsxs)("div",{className:"flex flex-wrap gap-3 p-1",children:[(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"}),(0,ee.jsx)("div",{className:"h-[180px] w-[180px] animate-pulse rounded bg-accent"})]}):!L&&!U?(0,ee.jsxs)("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[(0,ee.jsx)("div",{className:"text-muted-foreground",children:(0,ee.jsx)(Ca.Archive,{className:"h-9 w-9 text-muted-foreground"})}),(0,ee.jsx)("div",{className:"text-lg text-muted-foreground",children:a("No assets found")}),(0,ee.jsx)("div",{className:"text-sm text-muted-foreground",children:w.length>0?a("No assets found for your search: {{query}}",{query:w}):a("Start uploading assets to get started")}),(0,ee.jsx)("br",{})]}):(0,ee.jsx)("div",{className:"flex flex-wrap gap-3 p-1",children:_==null?void 0:_.map(ue=>(0,ee.jsxs)("div",{className:Co("group relative flex max-h-[180px] min-h-[180px] max-w-[180px] cursor-pointer flex-col items-center justify-between overflow-hidden rounded-lg border transition-all",v.some(We=>We.id===ue.id)?"border-primary":"hover:border-foreground/20",u.includes(ue.id)?"pointer-events-none opacity-50":""),onClick:We=>W(ue,We.ctrlKey||We.metaKey),onDoubleClick:()=>Y([ue]),children:[(0,ee.jsxs)("div",{className:"aspect-square flex-1 overflow-hidden",children:[u.includes(ue.id)?(0,ee.jsx)("div",{className:"bg-surface/80 absolute inset-0 flex items-center justify-center",children:(0,ee.jsx)(wt,{})}):null,ue.type==="image"?(0,ee.jsx)(qo,{src:`${ue.thumbnailUrl}`,alt:ue.name,className:`h-full min-h-full w-full object-contain duration-300 group-hover:scale-105 ${v.some(We=>We.id===ue.id)?"":"group-hover:contrast-50"}`}):(0,ee.jsxs)("div",{className:"flex h-full items-center justify-center",children:[(0,ee.jsx)(Ca.Film,{className:"h-12 w-12 text-muted-foreground"}),ue.thumbnailUrl&&(0,ee.jsx)(qo,{src:`${ue.thumbnailUrl}`,alt:ue.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),(0,ee.jsxs)("div",{className:"bg-surface flex w-full flex-shrink-0 items-center justify-between gap-1.5 border-t border-border px-2 py-1.5 text-foreground",children:[(0,ee.jsx)(Ye,{content:ue.name,children:(0,ee.jsx)("p",{className:"z-50 flex-1 truncate text-[11px] font-medium leading-tight",children:ue.name})}),(0,ee.jsx)("div",{className:"shrink-0 whitespace-nowrap text-[9px] font-medium text-muted-foreground/80",children:nT((ue==null?void 0:ue.size)||0)})]}),!v.some(We=>We.id===ue.id)&&(0,ee.jsxs)("div",{className:"absolute inset-0 flex items-center justify-center overflow-hidden rounded-md bg-background/20 opacity-0 transition-opacity group-hover:opacity-100 has-[[data-state=open]]:opacity-100",children:[(0,ee.jsx)(Ye,{content:a("View Details"),children:(0,ee.jsxs)(E,{variant:"secondary",size:"sm",onClick:We=>{We.stopPropagation(),ge(ue)},children:[(0,ee.jsx)(Ca.ImageIcon,{className:"h-4 w-4"}),a("View")]})}),(0,ee.jsx)("div",{className:"absolute right-1.5 top-1.5",children:(0,ee.jsxs)(Yt,{children:[(0,ee.jsx)($t,{asChild:!0,children:(0,ee.jsx)(E,{variant:"secondary",size:"icon-sm",className:"h-7 w-7 rounded-sm opacity-80 focus-within:opacity-100 hover:opacity-100 focus:opacity-100 focus-visible:bg-muted",onClick:We=>We.stopPropagation(),children:(0,ee.jsx)(Ca.MoreVertical,{className:"h-4 w-4"})})}),(0,ee.jsxs)(Vt,{align:"end",side:"bottom",className:"w-36",onClick:We=>We.stopPropagation(),children:[(0,ee.jsx)(Ua,{children:a("ACTIONS")}),(0,ee.jsx)(ye,{onClick:We=>{We.stopPropagation(),navigator.clipboard.writeText(ue.url),aj.toast.success(a("Asset URL copied to clipboard"))},children:a("Copy URL")}),(0,ee.jsx)(ye,{onClick:We=>{We.stopPropagation(),h({id:ue.id,show:!0,file:ue.url,name:ue.name})},children:a("Edit Image")}),(0,ee.jsx)(ye,{onClick:We=>{We.stopPropagation(),Ze(ue)},children:ze!=null&&ze.trash?a(aa().sidebarButton):a("Delete")})]})]})})]}),v.some(We=>We.id===ue.id)&&(0,ee.jsx)("div",{className:"absolute left-0 top-0 h-max rounded-br-lg bg-primary p-1",children:(0,ee.jsx)(Ca.Check,{className:"h-3 w-3 text-foreground",strokeWidth:5})})]},ue.id))})}),O>1&&(0,ee.jsx)("div",{className:"bg-surface absolute bottom-0 left-0 right-0 z-50 border-t p-4",children:(0,ee.jsx)(rj.ErrorBoundary,{fallback:(0,ee.jsx)("div",{className:"text-destructive",children:a("Error loading pagination")}),children:(0,ee.jsx)(gT,{currentPage:P,totalPages:O,onPageChange:ir,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):A==="search"?(0,ee.jsx)(j8,{onSelect:t,multiple:n,close:e}):(0,ee.jsx)(F8,{onSelect:t,multiple:n,close:e,setActiveTab:D}):(0,ee.jsx)(J8,{assetId:l||r||"",onBack:()=>{k("grid"),c(null)},onEdit:ue=>{h({id:ue.id,show:!0,file:ue.url,name:ue.name})},onSave:async ue=>{if(l){b(!0);try{let We=_.find(Zo=>Zo.id===l);We&&await ve((0,Vi.merge)(We,{description:ue}))}finally{b(!1)}}},isSaving:f})]}),g.show&&(0,ee.jsx)(Lo.Suspense,{fallback:(0,ee.jsx)(Pn,{className:"top-0"}),children:(0,ee.jsx)(Rae,{imageUrl:g.file,onSave:Rt,onClose:()=>h({show:!1,file:""}),defaultSavedImageName:g.name,isEditing:!!g.id})}),d&&d.length>0&&(0,ee.jsx)(Te,{open:!!d,onOpenChange:()=>p(null),children:(0,ee.jsxs)(we,{children:[(0,ee.jsxs)(Oe,{children:[(0,ee.jsx)(Ie,{children:ze!=null&&ze.trash?a(aa().confirmMoveTitle):a("Delete Asset(s)")}),(0,ee.jsx)(Dt,{children:ze!=null&&ze.trash?d.length===1?a('Are you sure you want to move "{{name}}" to archive?',{name:d[0].name}):a("Are you sure you want to move {{count}} assets to archive?",{count:d.length}):d.length===1?a('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:d[0].name}):a("Are you sure you want to delete {{count}} assets? This action cannot be undone.",{count:d.length})})]}),(0,ee.jsxs)(co,{className:"gap-2 sm:gap-0",children:[(0,ee.jsx)(E,{variant:"outline",onClick:()=>p(null),disabled:u.length>0,children:a("Cancel")}),(0,ee.jsx)(E,{variant:"destructive",onClick:te,loading:u.length>0,children:ze!=null&&ze.trash?a(aa().moveToAction):a("Delete")})]})]})})]})}var Vi,Ca,Lo,rj,nj,aj,ee,Rae,oj,HB=x(()=>{"use strict";"use client";Vi=require("lodash-es"),Ca=require("lucide-react"),Lo=K(require("react"),1),rj=require("react-error-boundary"),nj=require("react-i18next"),aj=require("sonner");Us();hl();zm();Ke();$v();ea();J();qt();Sr();xi();Oo();zg();rt();H8();iT();_B();q8();Q8();tj();cT();ee=require("react/jsx-runtime"),Rae=Lo.default.lazy(()=>Promise.resolve().then(()=>(BB(),IB))),oj=["id","url","width","height","description"]});var ij,Nu,jy,lj,Er,Dae,Wv,UB=x(()=>{"use strict";"use client";ij=require("lodash-es"),Nu=require("lucide-react"),jy=require("react"),lj=require("react-i18next");Us();J();qt();Er=require("react/jsx-runtime"),Dae=(0,jy.lazy)(()=>Promise.resolve().then(()=>(HB(),FB))),Wv=({assetId:e,assetUrl:t,onChange:o,className:r="",placeholder:n="Select an image",disabled:a=!1})=>{let{t:s}=(0,lj.useTranslation)(),[i,l]=(0,jy.useState)(!1),c=()=>{a||l(!0)},d=()=>{l(!1)},p=g=>{let h=Array.isArray(g)?g[0]:g;h!=null&&h.url&&o((0,ij.pick)(h,["url","id"])),l(!1)},u=()=>{o({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return(0,Er.jsxs)("div",{className:`w-full ${r}`,children:[t?(0,Er.jsxs)("div",{className:"relative overflow-hidden rounded-md border",children:[m?(0,Er.jsx)("div",{className:"flex h-12 items-center bg-muted/10 px-4",children:(0,Er.jsx)("p",{className:"text-xs text-foreground/80",children:t})}):(0,Er.jsx)(qo,{onClick:c,src:t,alt:s("Selected image"),className:"h-auto max-h-[100px] w-full bg-muted/10 object-contain"}),(0,Er.jsxs)("div",{className:"absolute right-2 top-2 flex gap-2",children:[(0,Er.jsx)(E,{type:"button",variant:"outline",size:"icon",className:"bg-surface h-8 w-8 rounded-full text-foreground",onClick:u,disabled:a,children:m?(0,Er.jsx)(Nu.X,{className:"h-4 w-4"}):(0,Er.jsx)(Nu.Trash2,{className:"h-4 w-4"})}),!m&&(0,Er.jsx)(E,{type:"button",variant:"outline",size:"icon",className:"bg-surface h-8 w-8 rounded-full text-foreground",onClick:c,disabled:a,children:(0,Er.jsx)(Nu.ImageIcon,{className:"h-4 w-4"})})]})]}):(0,Er.jsx)("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-4 ${a?"cursor-not-allowed opacity-50":"duration-300 hover:border-foreground/20"}`,onClick:c,children:(0,Er.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Er.jsx)(Nu.ImageIcon,{className:"h-5 w-5 text-muted-foreground"}),(0,Er.jsx)("p",{className:"text-xs font-light text-muted-foreground",children:n})]})}),(0,Er.jsx)(Te,{open:i,onOpenChange:l,children:(0,Er.jsxs)(we,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[(0,Er.jsxs)(Oe,{className:"hidden border-b px-4 py-2",children:[(0,Er.jsx)(Ie,{children:s("Select Image")}),(0,Er.jsx)(E,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,children:(0,Er.jsx)(Nu.X,{className:"h-4 w-4"})})]}),(0,Er.jsx)("div",{className:"h-full flex-1 p-4",children:(0,Er.jsx)(jy.Suspense,{children:(0,Er.jsx)(Dae,{close:d,onSelect:p,mode:"image",assetId:e})})})]})})]})}});var cj=x(()=>{"use strict";UB()});var dj,pj,mj,uj=x(()=>{"use strict";dj=require("lodash-es"),pj=require("react");Tt();Gc();mj=()=>{let{selectedLang:e}=fe(),{data:t,isFetching:o}=gn();return{data:(0,pj.useMemo)(()=>(0,dj.find)(t,{lang:e||""})||{},[t,e]),isFetching:o}}});var yT,gj,hT,_ae,qy,fj=x(()=>{"use strict";yT=require("@tanstack/react-query"),gj=require("lucide-react");Tt();St();dx();ng();rt();Kt();J();Oo();hT=require("react/jsx-runtime"),_ae=()=>{var s;let t=(s=document.getElementById("canvas-iframe").contentDocument)==null?void 0:s.body.innerHTML;if(!t)return null;let r=new DOMParser().parseFromString(t,"text/html");r.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(i=>i.remove()),r.querySelectorAll("*").forEach(i=>{Array.from(i.attributes).forEach(l=>i.removeAttribute(l.name))});let n=r.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(n).map(i=>`<${i.tagName.toLowerCase()}>${i.innerHTML}</${i.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},qy=({keyword:e,onComplete:t,field:o})=>{let r=he(),n=le(),a=Hc($.AI_GENERATE_SEO_FIELD),{selectedLang:s,fallbackLang:i}=fe(),{data:l}=Cm(),c=(0,yT.useQueryClient)(),{mutate:d,isPending:p}=(0,yT.useMutation)({mutationFn:async()=>{let u=_ae();return await r(n,{action:$.AI_GENERATE_SEO_FIELD,data:{context:l||{},dynamic:!1,field:o,lang:s||i,pageContent:u,keyword:e,model:a}})},onSuccess:u=>{c.invalidateQueries({queryKey:[il]}),t({fieldValue:u.field})},onError:u=>{var m;t({fieldValue:null,error:u.message,canBuyCredits:(m=u.canBuyCredits)!=null?m:!1})}});return(0,hT.jsx)(E,{disabled:p,type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(),children:p?(0,hT.jsx)(wt,{className:"text-orange !h-3 !w-3"}):(0,hT.jsx)(gj.Wand2Icon,{className:"text-orange !h-3 !w-3"})})}});var bT,of,zi,hj,yj,bj=x(()=>{"use strict";"use client";bT=require("lucide-react"),of=require("react");J();fo();zi=require("react/jsx-runtime"),hj=e=>{try{let t=JSON.parse(e||"{}"),o=Object.entries(t).map(([r,n])=>({key:r,value:String(n)}));return o.length>0?o:[{key:"",value:""}]}catch(t){return[{key:"",value:""}]}},yj=({value:e,onChange:t,disabled:o=!1})=>{let r=(0,of.useRef)(e),[n,a]=(0,of.useState)(e),[s,i]=(0,of.useState)(()=>hj(e));e!==n&&(a(e),i(hj(e)));let l=(0,of.useCallback)(u=>{let m={};u.forEach(h=>{h.key.trim()&&(m[h.key.trim()]=h.value)});let g=JSON.stringify(m);r.current=g,t(g)},[t]),c=()=>{let u=[...s,{key:"",value:""}];i(u)},d=u=>{let m=s.filter((h,f)=>f!==u),g=m.length>0?m:[{key:"",value:""}];i(g),l(g)},p=(u,m,g)=>{let h=[...s];h[u]={...h[u],[m]:g},i(h),l(h)};return(0,zi.jsxs)("div",{className:"bg-surface space-y-2",children:[s.map((u,m)=>(0,zi.jsxs)("div",{className:"group flex items-center gap-2 transition-all duration-200",children:[(0,zi.jsxs)("div",{className:"grid flex-1 grid-cols-2 gap-2",children:[(0,zi.jsx)(Ce,{placeholder:`Tag ${m+1}`,value:u.key,onChange:g=>p(m,"key",g.target.value),disabled:o}),(0,zi.jsx)(Ce,{placeholder:`Content ${m+1}`,value:u.value,onChange:g=>p(m,"value",g.target.value),disabled:o})]}),(0,zi.jsx)(E,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>d(m),disabled:o,className:"h-7 w-7 text-muted-foreground transition-colors duration-300 hover:bg-destructive/5 hover:text-destructive",children:(0,zi.jsx)(bT.Trash2,{className:"h-3.5 w-3.5"})})]},m)),(0,zi.jsxs)("div",{className:"flex items-center justify-between border-t border-border pt-1",children:[(0,zi.jsx)("span",{className:"text-[9px] font-normal uppercase tracking-widest text-muted-foreground",children:"Meta Tags List"}),(0,zi.jsxs)(E,{type:"button",variant:"outline",size:"sm",onClick:c,disabled:o,className:"h-6 font-light",children:[(0,zi.jsx)(bT.Plus,{}),"Add Meta Tag"]})]})]})}});var xj,vj=x(()=>{"use strict";xj=(e,t)=>{if(!e)return{success:!1,error:"Empty response from AI"};try{let o=e;if(typeof o=="string"&&(/^".*"$/.test(o)&&(o=o.replace(/^"(.*)"$/,"$1"),o=o.replace(/\\\\/g,"___DOUBLE_BACKSLASH___").replace(/\\n/g,`
238
+ `).replace(/\\"/g,'"').replace(/___DOUBLE_BACKSLASH___/g,"\\")),t==="jsonLD"||t==="metaOther")){o.includes("```")&&(o=o.replace(/^```json\s*/i,"").replace(/^```\s*/,"").replace(/\s*```$/m,"")),o=o.trim();try{JSON.parse(o)}catch(n){return{success:!1,error:"The AI response is not valid JSON. Please try again or edit manually."}}}return{success:!0,value:o}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error occurred"}}}});var Ed,Cj,kj=x(()=>{"use strict";zs();J();qt();Ed=require("react/jsx-runtime"),Cj=({isOpen:e,onClose:t,onSave:o,onDiscard:r,isSaving:n=!1,fromLanguage:a,toLanguage:s})=>{let i=Jt[a]||a,l=Jt[s]||s;return(0,Ed.jsx)(Te,{open:e,onOpenChange:t,children:(0,Ed.jsxs)(we,{className:"sm:max-w-[425px]",children:[(0,Ed.jsxs)(Oe,{children:[(0,Ed.jsx)(Ie,{children:"Unsaved SEO Changes"}),(0,Ed.jsxs)(Dt,{children:["You have unsaved changes in the SEO for '",i,"' version. Do you want to save these changes before switching to '",l,"' version?"]})]}),(0,Ed.jsxs)("div",{className:"flex justify-end gap-3 pt-4",children:[(0,Ed.jsx)(E,{variant:"outline",onClick:r,disabled:n,children:"Discard Changes"}),(0,Ed.jsx)(E,{loading:n,onClick:o,children:"Save & Switch"})]})]})})}});var Sj,Lae,GB,wj,Pj,Tj=x(()=>{"use strict";Sj=require("lodash-es"),Lae=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),GB=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};let t=/{{([^{}]+)}}/g,o=[],r=e,n;for(;(n=t.exec(e))!==null;){let a=n[0],s=n.index,i=s>0?e[s-1]:"",l=s+a.length<e.length?e[s+a.length]:"",c=i==='"'&&l==='"';if(!c)try{JSON.parse(e)}catch(p){let u=p,m=u.message.match(/position (\d+)/),g=m?parseInt(m[1]):void 0,h,f;if(g!==void 0){let b=e.substring(0,g).split(`
239
+ `);h=b.length,f=b[b.length-1].length+1}return{isValid:!1,parsed:null,placeholders:[],error:{message:u.message,line:h,column:f,position:g}}}let d=c?`__placeholder_${o.length}__`:`"__placeholder_${o.length}__"`;o.push({original:a,replaced:d,position:s}),r=r.replaceAll(a,d)}try{return{isValid:!0,parsed:JSON.parse(r),error:null,placeholders:o}}catch(a){let s=a,i=s.message.match(/position (\d+)/),l=i?parseInt(i[1]):void 0,c,d;if(l!==void 0){let p=r.substring(0,l).split(`
240
+ `);c=p.length,d=p[p.length-1].length+1}return{isValid:!1,parsed:null,placeholders:o,error:{message:s.message,line:c,column:d,position:l}}}},wj=(e,t)=>{let r=JSON.stringify(e,null,2);return t.forEach(({original:n},a)=>{let s=`"__placeholder_${a}__"`,i=`"${n}"`,l=new RegExp(Lae(s),"g");r=r.replace(l,i)}),r},Pj=(e,t)=>{if(!e)return"";let o=JSON.stringify(e,null,2),r=/{{([^{}]+)}}/g,n;for(;(n=r.exec(o))!==null;){let a=n[1],s=(0,Sj.get)(t,a,null);o=o.replace(n[0],s)}return o}});var Eu,Al,Nj,Wo,xT,$B=x(()=>{"use strict";Eu=require("lucide-react"),Al=require("react"),Nj=require("react-error-boundary");Tj();ea();J();xi();gs();Wo=require("react/jsx-runtime"),xT=({value:e,onChange:t,disabled:o=!1,readOnly:r=!1,placeholder:n="Enter JSON",rows:a=6,id:s="json-input",pageData:i={},hasJsonLdForSelectedLang:l,copyJsonLDFromDefaultPage:c,topRightComponent:d=null})=>{let[p,u]=(0,Al.useState)("edit"),[m,g]=(0,Al.useState)(null),[h,f]=(0,Al.useState)(""),b=(0,Al.useRef)(null),y=s==="jsonLD"&&!l&&!!c;(0,Al.useEffect)(()=>{e.trim()===""&&t("{}")},[e,t]);let k=C=>{if(r)return;let P=C.target.value;t(P)},w=C=>{if(C.key==="Tab"){C.preventDefault();let P=C.currentTarget,B=P.selectionStart,T=P.selectionEnd;if(B!==T){let S=e.substring(B,T).split(`
241
+ `);if(C.shiftKey){let D=S.map(H=>H.startsWith(" ")?H.substring(2):H).join(`
242
+ `),R=e.substring(0,B)+D+e.substring(T);t(R),setTimeout(()=>{P.selectionStart=B,P.selectionEnd=B+D.length},0)}else{let D=S.map(H=>` ${H}`).join(`
243
+ `),R=e.substring(0,B)+D+e.substring(T);t(R),setTimeout(()=>{P.selectionStart=B,P.selectionEnd=B+D.length},0)}}else{let v=e.substring(0,B)+" "+e.substring(T);t(v),setTimeout(()=>{P.selectionStart=P.selectionEnd=B+2},0)}}};(0,Al.useEffect)(()=>{let C=GB(e);C.isValid?(0,Al.startTransition)(()=>{if(g(null),C.parsed){let P=Pj(C.parsed,i);f(P)}else f("")}):(0,Al.startTransition)(()=>{g(C.error),f("")})},[e,i]);let N=()=>{let C=GB(e);if(C.isValid&&C.parsed){let P=wj(C.parsed,C.placeholders);t(P)}},I=()=>{m!=null&&m.position&&b.current&&(b.current.focus(),b.current.setSelectionRange(m.position,m.position+1))};return(0,Wo.jsx)(Nj.ErrorBoundary,{fallback:(0,Wo.jsx)("div",{children:"Some error"}),children:(0,Wo.jsx)("div",{className:"space-y-2",children:(0,Wo.jsxs)(Dr,{value:p,onValueChange:u,className:"w-full",children:[(0,Wo.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,Wo.jsxs)(Cr,{className:"w-max",children:[(0,Wo.jsxs)(ut,{value:"edit",className:"px-3",children:[(0,Wo.jsx)(Eu.Code,{className:"h-4 w-4"}),(0,Wo.jsx)("span",{children:"Edit"})]}),(0,Wo.jsxs)(ut,{value:"preview",className:"px-3",disabled:!e.trim()||m!==null,children:[(0,Wo.jsx)(Eu.Eye,{className:"h-4 w-4"}),(0,Wo.jsx)("span",{children:"Preview"})]})]}),d]}),(0,Wo.jsxs)(kr,{value:"edit",className:"relative mt-0",children:[!y&&p==="edit"&&(0,Wo.jsx)(Ye,{content:"Format JSON",side:"right",showTooltip:!o&&!m,children:(0,Wo.jsx)(E,{type:"button",variant:"outline",size:"icon",onClick:N,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||o||m!==null,children:(0,Wo.jsx)(Eu.FileCode2,{})})}),y?(0,Wo.jsx)("div",{className:"flex h-40 items-center justify-center rounded-md bg-muted/10",children:(0,Wo.jsxs)("div",{className:"rounded-m flex max-w-[400px] flex-col items-center gap-3 p-4",children:[(0,Wo.jsx)("div",{className:"max-w-xl text-center text-xs text-muted",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),(0,Wo.jsx)(E,{type:"button",variant:"default",size:"sm",onClick:c,children:"Copy & Edit from default language"})]})}):(0,Wo.jsx)(Ro,{ref:b,id:s,name:s,className:`${m?"border-destructive":""}`,onChange:k,onKeyDown:w,value:e,placeholder:n,rows:a,disabled:o,readOnly:r}),m&&(0,Wo.jsxs)("div",{className:"mt-2 flex items-center gap-2 rounded-md bg-destructive/10 p-2 text-xs text-destructive",children:[(0,Wo.jsx)(Eu.AlertTriangle,{className:"h-4 w-4"}),(0,Wo.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,Wo.jsx)("span",{children:`${m.message}`}),(0,Wo.jsx)(E,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",onClick:I,children:"Show"})]})]})]}),(0,Wo.jsx)(kr,{value:"preview",className:"mt-0",children:(0,Wo.jsx)(Ro,{rows:a,value:h,readOnly:!0,className:"cursor-default bg-muted/10 font-mono font-light text-foreground/70"})})]})})})}});var Bj={};et(Bj,{default:()=>Fae});var Ej,wn,Xa,Aj,Wi,X,Mae,Oae,Ij,Fae,Rj=x(()=>{"use strict";Ej=require("@react-hookz/web"),wn=require("lodash-es"),Xa=require("react"),Aj=require("react-i18next"),Wi=require("sonner");Tt();mn();Zc();KT();cj();wl();uj();er();ok();rk();An();zu();th();Rr();$x();J();Pg();fo();No();xi();gs();tn();fj();SI();bj();vj();kj();$B();Tv();X=require("react/jsx-runtime"),Mae=e=>{if(!e)return!0;try{return JSON.parse(e),!0}catch(t){return!1}},Oae=(e,t)=>{let o=e.selectionStart||0,r=e.selectionEnd||0,n=e.value,a=n.substring(0,o),s=n.substring(r),i=!1,l=!1,c=i?" ":"",d=l?" ":"",p=`{{${t}}}`,u=a+(i?c:"")+p+(l?d:"")+s,m=o+(i?1:0)+p.length;return{value:u,newCursorPos:m}},Ij=()=>{let{t:e}=(0,Aj.useTranslation)(),[,t]=ma(),{data:o}=xt(),{data:r}=Af(),{data:n}=If(),{data:a,isFetching:s}=mj(),i={...r!=null?r:{},global:n!=null?n:{}},l=a==null?void 0:a.seo,c=(0,Xa.useRef)(null),[d,p]=(0,Xa.useState)("seo"),u=o==null?void 0:o.id,m=o==null?void 0:o.pageType,g=Nf(m),{selectedLang:h,fallbackLang:f}=fe(),b=h||f,[y,k]=(0,Xa.useState)(!1),[w,N]=(0,Xa.useState)(!1),[I,C]=(0,Xa.useState)(!1),[P,B]=(0,Xa.useState)(null),[T,v]=(0,Xa.useState)({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...l}),S=(0,Xa.useRef)({}),{mutate:A,isPending:D}=by(),R=D||y||w,{hasPermission:H}=kt(),M=H(xe["pages:edit_seo"]),[L]=el(),z=(0,wn.get)(L,"flags.resetSeoToDefault",!1),_=!h||T.jsonLD!=="{}";(0,Xa.useEffect)(()=>{if(!s&&l&&u){let W={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...l};v(W),S.current[b]=W}},[s,l,b,u]),(0,Xa.useEffect)(()=>{let W=ie=>{let{fromLang:Y,toLang:Ze,switchHandler:te}=ie.detail,Qe=S.current[b];(Qe?!(0,wn.isEqual)(Qe,T):!1)?(B({fromLang:Y,toLang:Ze,switchHandler:te}),C(!0)):te()};return window.addEventListener("seo-language-switch-check",W),()=>{window.removeEventListener("seo-language-switch-check",W)}},[u,T,b]);let F=async()=>{if(!(!g||!b))try{k(!0);let W=qg(g,b),ie={...T,keyword:(0,wn.get)(W,"seo.keyword",""),title:(0,wn.get)(W,"seo.title",""),description:(0,wn.get)(W,"seo.description",""),cononicalUrl:(0,wn.get)(W,"seo.canonicalUrl",""),noIndex:(0,wn.get)(W,"seo.noIndex",!1),noFollow:(0,wn.get)(W,"seo.noFollow",!1),ogTitle:(0,wn.get)(W,"seo.ogTitle",""),ogDescription:(0,wn.get)(W,"seo.ogDescription","")};v(ie),Wi.toast.success(e("SEO fields reset to defaults"))}catch(W){Wi.toast.error(e("Failed to reset SEO fields")),console.error("Reset SEO error:",W)}finally{k(!1)}},O=async()=>{if(!(!g||!b))try{N(!0);let W=qg(g,b),ie={...T,jsonLD:(0,wn.get)(W,"seo.jsonLD","")};v(ie),Wi.toast.success(e("JSON-LD reset to default"))}catch(W){Wi.toast.error(e("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",W)}finally{N(!1)}},U=async()=>{if(!(!g||!b))try{k(!0);let W=qg(g,b),ie={...T,ogTitle:(0,wn.get)(W,"seo.ogTitle",""),ogDescription:(0,wn.get)(W,"seo.ogDescription",""),ogImage:(0,wn.get)(W,"seo.ogImage",""),ogImageId:(0,wn.get)(W,"seo.ogImageId",""),metaOther:(0,wn.get)(W,"seo.metaOther","{}")};v(ie),Wi.toast.success(e("Meta Tag fields reset to defaults"))}catch(W){Wi.toast.error(e("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",W)}finally{k(!1)}},j=async()=>{A({id:a==null?void 0:a.id,seo:T,primaryPage:u},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",T),S.current[b]=T,Wi.toast.success(e("SEO & JSON-LD updated successfully"))}})},ce=(0,Xa.useCallback)((W,ie,Y,Ze)=>{(0,wn.isEqual)(S.current[Ze],W)||Mae(W==null?void 0:W.jsonLD)&&A({id:ie,seo:W,primaryPage:Y},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",W)},onError:()=>{Wi.toast.error(e("Failed to update SEO & JSON-LD"))}})},[A,e]),pe=(0,Ej.useDebouncedCallback)(ce,[ce],1500);(0,Xa.useEffect)(()=>{a!=null&&a.id&&u&&b&&!s&&pe(T,a.id,u,b)},[T,a==null?void 0:a.id,u,b,s,pe]);let ve=(W,ie)=>{let Y=document.getElementById(ie);if(Y){let{value:Ze,newCursorPos:te}=Oae(Y,W);c.current={id:ie,position:te},Y.tagName.toLowerCase()==="input"?(Y.value=Ze,v(ge=>({...ge,[Y.name]:Ze})),Y.focus(),Y.setSelectionRange(te,te),[0,10,50,100,200].forEach(ge=>{setTimeout(()=>{let Rt=document.getElementById(ie);Rt&&(Rt.focus(),Rt.setSelectionRange(te,te))},ge)})):(v(Z=>({...Z,[Y.name]:Ze})),requestAnimationFrame(()=>{let Z=document.getElementById(ie);Z&&(Z.focus(),Z.setSelectionRange(te,te),setTimeout(()=>{let ge=document.getElementById(ie);ge&&(ge.focus(),ge.setSelectionRange(te,te))},50))}))}},Ve=W=>{let ie={...T,[W.target.name]:W.target.name==="noIndex"||W.target.name==="noFollow"?W.target.checked:W.target.value};v(ie)},ze=W=>ie=>{if(!(0,wn.isEmpty)(ie.fieldValue)){let Y=xj(ie.fieldValue,W);Y.success?Ve({target:{name:W,value:Y.value}}):Wi.toast.error((0,X.jsxs)("div",{children:[(0,X.jsx)("h2",{children:"Failed to process AI response:"}),(0,X.jsx)("p",{children:Y.error})]}))}ie.error&&(ie.canBuyCredits?Wi.toast.error((0,X.jsx)("div",{children:(0,X.jsx)("p",{className:"z-[999] text-xs font-normal",children:ie.error})}),{action:{label:"Buy Credits",onClick:()=>t(ll)},duration:8e3}):Wi.toast.error((0,X.jsxs)("div",{children:[(0,X.jsx)("h2",{children:"Failed to generate:"}),(0,X.jsx)("p",{children:ie.error})]})))},bt=()=>{let W=(0,wn.get)(o,"seo.jsonLD","{}");if((W==null?void 0:W.trim())==="{}"){Wi.toast.error(e("Default page JSON-LD is empty"));return}Ve({target:{name:"jsonLD",value:W}})};return(0,X.jsxs)("div",{className:"relative flex h-full max-h-[500px] min-h-[500px] flex-col overflow-hidden text-foreground","data-panel-id":"seo",children:[!M&&(0,X.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:(0,X.jsx)(pd,{variant:"default",className:"w-[80%] max-w-md text-xs",children:(0,X.jsx)(Gx,{children:e("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),(0,X.jsx)("div",{className:"flex-shrink-0 px-2 pb-4",children:(0,X.jsxs)("div",{className:"flex w-full items-center justify-between rounded-md bg-muted/10 px-3 py-2 text-left text-sm",children:[(0,X.jsxs)("span",{className:"inline-flex items-center gap-x-2",children:[(0,X.jsx)("div",{className:"text-sm leading-none",children:a==null?void 0:a.name}),(0,X.jsx)("span",{className:"text-xs font-light leading-none text-muted-foreground",children:a==null?void 0:a.slug})]}),(0,X.jsx)(wy,{showAdd:!1})]})}),(0,X.jsx)("div",{className:"flex-shrink-0 px-2",children:(0,X.jsx)(Dr,{value:d,onValueChange:p,children:(0,X.jsxs)(Cr,{className:"mb-2",children:[(0,X.jsx)(ut,{value:"seo",className:"px-5",children:e("SEO")}),(0,X.jsx)(ut,{value:"opengraph",className:"px-5",children:e("Meta Tags")}),(0,X.jsx)(ut,{value:"jsonld",className:"px-5",children:e("JSON-LD")}),(0,X.jsx)(Br,{slotId:jo.SEO_PANEL.TRIGGER,context:{setTab:p}})]})})}),(0,X.jsx)("div",{className:"flex-1 overflow-hidden px-2 pb-2",children:(0,X.jsxs)("form",{className:"h-full",children:[(0,X.jsx)("div",{className:d==="seo"?"h-full overflow-y-auto pb-4 pr-2":"sr-only",children:(0,X.jsxs)("div",{className:"space-y-4",children:[(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"keyword",children:e("Keyword")}),M&&(0,X.jsx)(Nc,{dataType:"value",data:i,onSelect:W=>ve(W,"keyword")})]}),(0,X.jsx)(Ce,{type:"text",id:"keyword",name:"keyword",value:T.keyword,onChange:Ve,disabled:!M,placeholder:e("Enter keyword"),readOnly:!M})]}),(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"title",children:e("SEO Title")}),(0,X.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,X.jsx)(qy,{keyword:T.keyword,onComplete:ze("title"),field:"title"}),M&&(0,X.jsx)(Nc,{dataType:"value",data:i,onSelect:W=>ve(W,"title")})]})]}),(0,X.jsx)(Ce,{type:"text",id:"title",name:"title",value:T.title,onChange:Ve,disabled:!M,placeholder:e("Enter SEO title"),readOnly:!M})]}),(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"description",children:e("SEO Description")}),(0,X.jsxs)("div",{className:"flex items-center gap-1",children:[(0,X.jsx)(qy,{keyword:T.keyword,onComplete:ze("description"),field:"description"}),M&&(0,X.jsx)(Nc,{data:i,onSelect:W=>ve(W,"description")})]})]}),(0,X.jsx)(Ro,{id:"description",name:"description",rows:5,value:T.description,onChange:Ve,disabled:!M,placeholder:e("Enter SEO description"),readOnly:!M})]}),(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"title",children:e("Canonical URL")}),M&&(0,X.jsx)(Nc,{dataType:"value",data:i,onSelect:W=>ve(W,"canonicalUrl")})]}),(0,X.jsx)(Ce,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:T.canonicalUrl,onChange:Ve,disabled:!M,placeholder:e("Enter Canonical URL"),readOnly:!M})]}),(0,X.jsxs)("div",{className:"grid grid-cols-2 items-center justify-between",children:[(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,X.jsx)(Ia,{id:"noIndex",checked:T.noIndex,onCheckedChange:W=>Ve({target:{name:"noIndex",checked:!!W}}),disabled:!M}),(0,X.jsx)(Q,{htmlFor:"noIndex",children:e("No Index")})]}),(0,X.jsx)("p",{className:"mt-1 text-[11px] font-light leading-4 text-muted-foreground/80",children:e("Check this if you don't want search engines to index this page.")})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,X.jsx)(Ia,{id:"noFollow",checked:T.noFollow,onCheckedChange:W=>Ve({target:{name:"noFollow",checked:!!W}}),disabled:!M}),(0,X.jsx)(Q,{htmlFor:"noFollow",children:e("No Follow")})]}),(0,X.jsx)("p",{className:"mt-1 text-[11px] font-light text-muted-foreground/80",children:e("Check this if you don't want search engines to follow links on this page.")})]})]})]})}),(0,X.jsx)("div",{className:d==="opengraph"?"h-full overflow-y-auto pb-4 pr-2":"sr-only",children:(0,X.jsx)("div",{className:"space-y-4",children:(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"py-3 text-xs font-light",children:e("Open Graph")}),(0,X.jsxs)("div",{className:"space-y-4",children:[(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"ogTitle",children:e("OG Title")}),(0,X.jsxs)("div",{className:"flex items-center gap-1",children:[(0,X.jsx)(qy,{keyword:T.keyword,onComplete:ze("ogTitle"),field:"ogTitle"}),M&&(0,X.jsx)(Nc,{dataType:"value",data:i,onSelect:W=>ve(W,"ogTitle")})]})]}),(0,X.jsx)(Ce,{type:"text",id:"ogTitle",name:"ogTitle",value:T.ogTitle,onChange:Ve,disabled:!M,placeholder:e("Enter OG title"),readOnly:!M})]}),(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"ogDescription",children:e("OG Description")}),(0,X.jsxs)("div",{className:"flex items-center gap-1",children:[(0,X.jsx)(qy,{keyword:T.keyword,onComplete:ze("ogDescription"),field:"ogDescription"}),M&&(0,X.jsx)(Nc,{dataType:"value",data:i,onSelect:W=>ve(W,"ogDescription")})]})]}),(0,X.jsx)(Ro,{id:"ogDescription",name:"ogDescription",rows:5,value:T.ogDescription,onChange:Ve,disabled:!M,placeholder:e("Enter OG description"),readOnly:!M})]}),(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"ogImage",children:e("OG Image")}),M&&(0,X.jsx)(Nc,{dataType:"value",data:i,onSelect:W=>{v({...T,ogImage:`{{${W}}}`,ogImageId:""})}})]}),(0,X.jsx)(Wv,{assetId:T.ogImageId,assetUrl:T.ogImage,onChange:W=>{v({...T,ogImage:W.url,ogImageId:W.id})},disabled:!M,placeholder:e("Select OG image"),className:"mb-2"})]}),(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsx)(Q,{className:"text-xs",htmlFor:"metaOther",children:e("Meta Tags")}),(0,X.jsx)(yj,{value:T.metaOther,onChange:W=>{Ve({target:{name:"metaOther",value:W}})},disabled:!M})]})]})]})})}),(0,X.jsx)("div",{className:d==="jsonld"?"h-full overflow-y-auto pb-4 pr-2":"sr-only",children:(0,X.jsx)("div",{className:"space-y-4",children:(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsx)("div",{className:"hidden",children:JSON.stringify(i)}),(0,X.jsx)(xT,{id:"jsonLD",value:T.jsonLD,onChange:W=>{Ve({target:{name:"jsonLD",value:W}})},placeholder:e("Enter JSON-LD"),disabled:!M,readOnly:!M,pageData:i,rows:20,handleFieldInsert:ve,hasJsonLdForSelectedLang:_,copyJsonLDFromDefaultPage:bt,topRightComponent:_&&(0,X.jsx)("div",{className:"flex items-center gap-1",children:(0,X.jsx)(qy,{keyword:T.keyword,onComplete:ze("jsonLD"),field:"jsonLD"})})})]})})}),(0,X.jsx)(Br,{slotId:jo.SEO_PANEL.CONTENT,context:{tab:d}})]})}),M&&(0,X.jsx)(X.Fragment,{children:z?(0,X.jsx)("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-surface p-4",children:(0,X.jsx)(E,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d==="jsonld"?O():d==="opengraph"?U():F()},disabled:R||!M||!g,children:e(y?"Resetting...":`Reset to ${d==="jsonld"?"Default JSON-LD":d==="opengraph"?"Default Open Graph":"Default SEO"}`)})}):(0,X.jsx)("div",{})}),(0,X.jsx)(Cj,{isOpen:I,onClose:()=>{C(!1),B(null)},onSave:async()=>{P&&(await j(),P.switchHandler(),C(!1),B(null))},onDiscard:()=>{if(P){let W=S.current[b];W&&v(W),P.switchHandler(),C(!1),B(null)}},isSaving:D,fromLanguage:(P==null?void 0:P.fromLang)||b,toLanguage:(P==null?void 0:P.toLang)||""})]})};Ij.displayName="SeoPanel";Fae=Ij});var Dj,_j,Au,Hae,VB,Uae,Lj,Mj=x(()=>{"use strict";Dj=require("lodash-es"),_j=require("react");er();An();J();Au=require("react/jsx-runtime"),Hae=(0,_j.lazy)(()=>Promise.resolve().then(()=>(Rj(),Bj))),VB="seo",Uae=({isActive:e,show:t})=>{let{data:o}=xt(),r=Nf(o==null?void 0:o.pageType);return!(0,Dj.has)(r,"hasSlug")||!r.hasSlug?null:(0,Au.jsx)(E,{variant:"ghost",size:"icon",onClick:t,className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,Au.jsxs)("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Au.jsx)("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),(0,Au.jsx)("path",{d:"M14 16h-4v-8h4"}),(0,Au.jsx)("path",{d:"M11 12h2"}),(0,Au.jsx)("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Lj={id:VB,label:"SEO",panel:Hae,button:Uae,position:"top",width:600,view:"modal"}});var Yy,Ky,Oj,Fj,Hj=x(()=>{"use strict";Yy=require("@tanstack/react-query"),Ky=require("sonner");St();zg();rt();Kt();Oj=()=>{let e=le(),t=(0,Yy.useQueryClient)(),o=he();return(0,Yy.useMutation)({mutationFn:async r=>o(e,{action:$.RESTORE_TRASHED_ITEM,data:{id:r}}),onSuccess:r=>{t.invalidateQueries({queryKey:[$.GET_TRASHED_ITEMS]}),t.invalidateQueries({queryKey:[$.GET_WEBSITE_PAGES]}),t.invalidateQueries({queryKey:[$.GET_ASSETS]});let n=aa();Ky.toast.success(n.restoreAction+" successful"),r!=null&&r.resolvedConflict&&Ky.toast.info(`Restored with new slug: ${r.newSlug}`)},onError:r=>{Ky.toast.error(`Restore failed: ${r.message||"Unknown error"}`)}})},Fj=()=>{let e=le(),t=(0,Yy.useQueryClient)(),o=he();return(0,Yy.useMutation)({mutationFn:async r=>o(e,{action:$.DELETE_PERMANENTLY,data:{id:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:[$.GET_TRASHED_ITEMS]}),Ky.toast.success(aa().deleteAction+" successful")},onError:r=>{Ky.toast.error(`Delete failed: ${r.message||"Unknown error"}`)}})}});var Uj,Gj,$j=x(()=>{"use strict";Uj=require("@tanstack/react-query");St();rt();Kt();Gj=({page:e=1,limit:t=20,search:o="",entityType:r=""})=>{let n=le(),a=he();return(0,Uj.useQuery)({queryKey:[$.GET_TRASHED_ITEMS,e,t,o,r],queryFn:async()=>await a(n,{action:$.GET_TRASHED_ITEMS,data:{page:e,limit:t,search:o,entityType:r}}),refetchOnWindowFocus:!1,refetchOnMount:"always"})}});var Vj,Il,jv,zj,ne,Gae,Wj,jj=x(()=>{"use strict";Vj=require("date-fns"),Il=require("lucide-react"),jv=require("react"),zj=require("react-i18next");Us();hl();zg();Hp();J();qt();Sr();Rs();Rh();Lf();Hj();$j();ne=require("react/jsx-runtime"),Gae=({userId:e})=>{let{data:t}=xa(e);return(0,ne.jsx)("span",{title:(t==null?void 0:t.name)||(t==null?void 0:t.email)||e,children:(t==null?void 0:t.name)||(t==null?void 0:t.email)||e})},Wj=()=>{var C,P,B,T,v,S;let{t:e}=(0,zj.useTranslation)(),t=aa(),[o,r]=(0,jv.useState)(""),[n,a]=(0,jv.useState)(1),[s,i]=(0,jv.useState)(null),[l,c]=(0,jv.useState)(null),d=20,{data:p,isLoading:u}=Gj({page:n,limit:d,search:o}),m=(C=p==null?void 0:p.total)!=null?C:0,g=Math.max(1,Math.ceil(m/d)),{mutate:h,isPending:f}=Oj(),{mutate:b,isPending:y}=Fj(),k=()=>{l&&h(l.id,{onSuccess:()=>c(null)})},w=()=>{s&&b(s.id,{onSuccess:()=>i(null)})},N=A=>{r(A),a(1)},I=((B=(P=p==null?void 0:p.items)==null?void 0:P.length)!=null?B:0)>0;return(0,ne.jsxs)("div",{className:"flex h-full flex-col",children:[(0,ne.jsx)("div",{className:"flex items-center gap-4 pb-4",children:(0,ne.jsx)("div",{className:"w-64",children:(0,ne.jsx)(Yr,{value:o,setValue:N,placeholder:e(`Search ${t.panelLabel.toLowerCase()}...`)})})}),(0,ne.jsx)(qs,{className:"min-h-[50vh] flex-1",children:u?(0,ne.jsx)("div",{className:"w-full",children:(0,ne.jsxs)("table",{className:"w-full table-fixed caption-bottom text-sm text-foreground",children:[(0,ne.jsx)("thead",{children:(0,ne.jsxs)("tr",{className:"border-b bg-accent/50 text-xs font-light",children:[(0,ne.jsx)("th",{className:"w-[40%] rounded-tl-md p-2 text-left font-medium",children:e("Title")}),(0,ne.jsx)("th",{className:"w-[15%] p-2 text-left font-medium",children:e("Type")}),(0,ne.jsx)("th",{className:"w-[20%] p-2 text-left font-medium",children:e(t.byLabel)}),(0,ne.jsx)("th",{className:"w-[20%] p-2 text-left font-medium",children:e(t.onLabel)}),(0,ne.jsx)("th",{className:"w-[5%] rounded-tr-md p-2 text-left font-medium"})]})}),(0,ne.jsx)("tbody",{children:Array.from({length:5}).map((A,D)=>(0,ne.jsxs)("tr",{className:"border-b text-xs font-light",children:[(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsx)(da,{className:"h-4 w-3/4"})}),(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsx)(da,{className:"h-4 w-1/2"})}),(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsx)(da,{className:"h-4 w-1/2"})}),(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsx)(da,{className:"h-4 w-3/4"})}),(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsx)(da,{className:"ml-auto h-6 w-6 rounded-full"})})]},D))})]})}):I?(0,ne.jsx)("div",{className:"w-full",children:(0,ne.jsxs)("table",{className:"w-full table-fixed caption-bottom text-sm text-foreground",children:[(0,ne.jsx)("thead",{className:"sticky top-0 z-10 bg-background",children:(0,ne.jsxs)("tr",{className:"border-b bg-accent/50 text-xs font-light",children:[(0,ne.jsx)("th",{className:"w-[40%] rounded-tl-md p-2 text-left font-medium",children:e("Title")}),(0,ne.jsx)("th",{className:"w-[15%] p-2 text-left font-medium",children:e("Type")}),(0,ne.jsx)("th",{className:"w-[20%] p-2 text-left font-medium",children:e(t.byLabel)}),(0,ne.jsx)("th",{className:"w-[20%] p-2 text-left font-medium",children:e(t.onLabel)}),(0,ne.jsx)("th",{className:"w-[5%] rounded-tr-md p-2 text-left font-medium"})]})}),(0,ne.jsx)("tbody",{className:"[&_tr:last-child]:border-0",children:(T=p==null?void 0:p.items)==null?void 0:T.map(A=>{var D,R,H,M,L,z;return(0,ne.jsxs)("tr",{className:"border-b text-xs font-light",children:[(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsxs)("div",{className:"flex items-center gap-x-2",children:[A.entityType==="page"&&(0,ne.jsx)(Il.File,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),A.entityType==="asset"&&(0,ne.jsx)(Il.Image,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,ne.jsxs)("span",{className:"min-w-0 flex-1 cursor-default truncate",title:((D=A.metadata)==null?void 0:D.name)||A.name,children:[((R=A.metadata)==null?void 0:R.name)||A.name,A.entityType==="page"&&((H=A.metadata)==null?void 0:H.slug)&&(0,ne.jsxs)("span",{className:"ml-1 text-muted-foreground",children:["(",A.metadata.slug,")"]})]}),A.entityType==="asset"&&((M=A.metadata)==null?void 0:M.url)&&(0,ne.jsxs)(en,{children:[(0,ne.jsx)($r,{asChild:!0,children:(0,ne.jsx)(E,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",children:(0,ne.jsx)(Il.Eye,{className:"h-3.5 w-3.5"})})}),(0,ne.jsx)(Vr,{className:"w-auto max-w-[300px] p-2",children:(0,ne.jsx)(qo,{src:A.metadata.url,alt:A.metadata.name||A.name,className:"max-h-[300px] max-w-[300px] rounded object-contain"})})]})]})}),(0,ne.jsxs)("td",{className:"p-2 capitalize",children:[A.entityType==="page"?"Page":A.entityType,A.entityType==="page"&&((L=A==null?void 0:A.metadata)==null?void 0:L.pageType)&&A.metadata.pageType!=="page"&&(0,ne.jsxs)("small",{className:"ml-1 italic text-muted-foreground",children:["(",(z=A==null?void 0:A.metadata)==null?void 0:z.pageType,")"]})]}),(0,ne.jsx)("td",{className:"truncate whitespace-nowrap p-2",children:A.deletedBy?(0,ne.jsx)(Gae,{userId:A.deletedBy}):"-"}),(0,ne.jsx)("td",{className:"whitespace-nowrap p-2 font-extralight italic",children:(0,Vj.format)(new Date(A.deletedAt),"PPp")}),(0,ne.jsx)("td",{className:"p-2",children:(0,ne.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,ne.jsxs)(Yt,{children:[(0,ne.jsx)($t,{asChild:!0,children:(0,ne.jsx)(E,{variant:"ghost",size:"icon",disabled:f||y,children:(0,ne.jsx)(Il.MoreHorizontal,{className:"h-4 w-4"})})}),(0,ne.jsxs)(Vt,{align:"end",children:[(0,ne.jsx)(ye,{onClick:()=>c(A),children:e("Restore")}),(0,ne.jsx)(ye,{onClick:()=>i(A),className:"text-destructive",children:e("Delete Permanently")})]})]})})})]},A.id)})})]})}):(0,ne.jsx)("div",{className:"flex h-96 items-center justify-center p-8 text-sm text-muted-foreground",children:e(t.emptyMessage)})}),!u&&g>1&&(0,ne.jsxs)("div",{className:"flex items-center justify-between border-t pt-3 text-xs text-muted-foreground",children:[(0,ne.jsxs)("span",{children:[e("Page")," ",n," ",e("of")," ",g]}),(0,ne.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ne.jsx)(E,{variant:"ghost",size:"icon",onClick:()=>a(A=>Math.max(1,A-1)),disabled:n<=1,children:(0,ne.jsx)(Il.ChevronLeft,{className:"h-4 w-4"})}),(0,ne.jsx)(E,{variant:"ghost",size:"icon",onClick:()=>a(A=>Math.min(g,A+1)),disabled:n>=g,children:(0,ne.jsx)(Il.ChevronRight,{className:"h-4 w-4"})})]})]}),(0,ne.jsx)(Te,{open:!!s,onOpenChange:A=>!A&&i(null),children:(0,ne.jsxs)(we,{children:[(0,ne.jsxs)(Oe,{children:[(0,ne.jsx)(Ie,{children:e(t.confirmDeleteTitle)}),(0,ne.jsx)(Dt,{asChild:!0,children:(0,ne.jsxs)("div",{className:"py-4 text-sm",children:[e("Are you sure you want to permanently delete")," ",(0,ne.jsx)("span",{className:"font-semibold",children:((v=s==null?void 0:s.metadata)==null?void 0:v.name)||(s==null?void 0:s.name)}),"?"," ",e("This action cannot be undone.")]})})]}),(0,ne.jsxs)(co,{children:[(0,ne.jsx)(E,{variant:"outline",onClick:()=>i(null),disabled:y,children:e("Cancel")}),(0,ne.jsx)(E,{variant:"destructive",onClick:w,loading:y,children:e("Delete Permanently")})]})]})}),(0,ne.jsx)(Te,{open:!!l,onOpenChange:A=>!A&&c(null),children:(0,ne.jsxs)(we,{children:[(0,ne.jsxs)(Oe,{children:[(0,ne.jsx)(Ie,{children:e("Restore Item")}),(0,ne.jsx)(Dt,{asChild:!0,children:(0,ne.jsxs)("div",{className:"py-4 text-sm",children:[e("Are you sure you want to restore")," ",(0,ne.jsx)("span",{className:"font-semibold",children:((S=l==null?void 0:l.metadata)==null?void 0:S.name)||(l==null?void 0:l.name)}),"?"]})})]}),(0,ne.jsxs)(co,{children:[(0,ne.jsx)(E,{variant:"outline",onClick:()=>c(null),disabled:f,children:e("Cancel")}),(0,ne.jsx)(E,{onClick:k,loading:f,children:e("Restore")})]})]})})]})}});var vT,qj,Kj=x(()=>{"use strict";jj();vT=require("react/jsx-runtime"),qj=()=>(0,vT.jsx)("div",{className:"flex h-full flex-col overflow-hidden",children:(0,vT.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,vT.jsx)(Wj,{})})})});var Yj,Jj,CT,Qj,$ae,Xj,Zj=x(()=>{"use strict";Yj=require("lucide-react"),Jj=require("react-i18next");zg();rt();J();Kj();CT=require("react/jsx-runtime"),Qj=aa().panelId,$ae=({isActive:e,show:t})=>{let{t:o}=(0,Jj.useTranslation)(),r=aa(),n=Nt("flags",{});return n!=null&&n.trash?(0,CT.jsx)(E,{variant:"ghost",size:"icon",onClick:t,title:o(r.sidebarButton),className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,CT.jsx)(Yj.Trash2,{className:"h-5 w-5"})}):null},Xj={button:$ae,label:aa().panelLabel,position:"bottom",view:"modal",width:1100,panel:()=>(0,CT.jsx)(qj,{})}});var e9,t9,o9=x(()=>{"use strict";e9=require("@tanstack/react-query");St();rt();Kt();t9=()=>{let e=le(),t=he();return(0,e9.useMutation)({mutationKey:[$.CHANGE_PASSWORD],mutationFn:async o=>{let r=await t(e,{action:$.CHANGE_PASSWORD,data:o});return r==null?void 0:r.data}})}});var n9={};et(n9,{ChangePasswordModal:()=>zae});var Ad,r9,qv,Mo,Vae,zae,a9=x(()=>{"use strict";Ad=require("react"),r9=require("react-i18next"),qv=require("zod");rt();o9();J();qt();fo();No();Oo();Mo=require("react/jsx-runtime"),Vae=e=>qv.z.object({oldPassword:qv.z.string().min(1,e("Current password is required")),newPassword:qv.z.string().min(8,e("Password must be at least 8 characters")).max(128,e("Password must be less than 128 characters")).regex(/[A-Z]/,e("Password must contain at least one uppercase letter")).regex(/[a-z]/,e("Password must contain at least one lowercase letter")).regex(/[0-9]/,e("Password must contain at least one number")).regex(/[!@#$%^&*(),.?":{}|<>]/,e("Password must contain at least one special character")),confirmPassword:qv.z.string().min(1,e("Confirm password is required"))}).refine(t=>t.newPassword===t.confirmPassword,{message:e("New password and confirm password do not match"),path:["confirmPassword"]}).refine(t=>t.oldPassword!==t.newPassword,{message:e("New password must be different from current password"),path:["newPassword"]}),zae=({open:e,onOpenChange:t})=>{let{t:o}=(0,r9.useTranslation)(),r=Nt("currentUser",null),{mutate:n,isPending:a,isSuccess:s,reset:i}=t9(),[l,c]=(0,Ad.useState)(""),[d,p]=(0,Ad.useState)(""),[u,m]=(0,Ad.useState)(""),[g,h]=(0,Ad.useState)(null),f=(0,Ad.useCallback)(()=>{c(""),p(""),m(""),h(null),i()},[i]),b=(0,Ad.useCallback)(k=>{t(k),k||f()},[t,f]);(0,Ad.useEffect)(()=>{if(s){let k=setTimeout(()=>{b(!1)},2e3);return()=>clearTimeout(k)}},[s,b]);let y=()=>{var I;h(null);let k={oldPassword:l.trim(),newPassword:d.trim(),confirmPassword:u.trim()},N=Vae(o).safeParse(k);if(!N.success){h(((I=N.error.issues[0])==null?void 0:I.message)||o("Validation failed"));return}if(!(r!=null&&r.email)){h(o("User email not found"));return}n({email:r.email,oldPassword:N.data.oldPassword,newPassword:N.data.newPassword,confirmPassword:N.data.confirmPassword},{onError:C=>{h((C==null?void 0:C.message)||o("Failed to change password"))}})};return(0,Mo.jsx)(Te,{open:e,onOpenChange:b,children:(0,Mo.jsx)(we,{className:"sm:max-w-[425px]",children:a?(0,Mo.jsx)("div",{className:"flex h-[340px] items-center justify-center",children:(0,Mo.jsx)(wt,{})}):s?(0,Mo.jsxs)("div",{className:"flex h-[340px] flex-col items-center justify-center gap-2",children:[(0,Mo.jsx)("div",{className:"rounded-full bg-green-100 p-3",children:(0,Mo.jsx)("svg",{className:"text-success h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,Mo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,Mo.jsx)("p",{className:"text-lg font-medium",children:o("Password updated successfully")})]}):(0,Mo.jsxs)(Mo.Fragment,{children:[(0,Mo.jsxs)(Oe,{children:[(0,Mo.jsx)(Ie,{children:o("Change Password")}),(0,Mo.jsx)(Dt,{children:o("Enter your current password and a new password.")})]}),(0,Mo.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,Mo.jsxs)("div",{className:"grid gap-1",children:[(0,Mo.jsx)(Q,{htmlFor:"old-password",children:o("Current Password")}),(0,Mo.jsx)(Ce,{id:"old-password",type:"password",value:l,onChange:k=>c(k.target.value),placeholder:o("Enter current password")})]}),(0,Mo.jsxs)("div",{className:"grid gap-1",children:[(0,Mo.jsx)(Q,{htmlFor:"new-password",children:o("New Password")}),(0,Mo.jsx)(Ce,{id:"new-password",type:"password",value:d,onChange:k=>p(k.target.value),placeholder:o("Enter new password")})]}),(0,Mo.jsxs)("div",{className:"grid gap-1",children:[(0,Mo.jsx)(Q,{htmlFor:"confirm-password",children:o("Confirm Password")}),(0,Mo.jsx)(Ce,{id:"confirm-password",type:"password",value:u,onChange:k=>m(k.target.value),placeholder:o("Confirm new password")})]}),g&&(0,Mo.jsx)("p",{className:"text-sm text-destructive",children:g})]}),(0,Mo.jsxs)(co,{children:[(0,Mo.jsx)(E,{variant:"outline",onClick:()=>b(!1),disabled:a,children:o("Cancel")}),(0,Mo.jsx)(E,{onClick:y,disabled:a,children:o("Change Password")})]})]})})})}});var kT,s9,Jy,i9,Ar,Wae,zB,jae,l9,c9=x(()=>{"use strict";kT=require("lodash-es"),s9=require("lucide-react"),Jy=require("react"),i9=require("react-i18next");rt();Fb();Ih();J();qt();Xk();Oo();Ar=require("react/jsx-runtime"),Wae=(0,Jy.lazy)(()=>Promise.resolve().then(()=>(a9(),n9)).then(e=>({default:e.ChangePasswordModal}))),zB="user-info",jae=()=>{var s;let{t:e}=(0,i9.useTranslation)(),{user:t,logout:o}=am(),r=Nt("onLogout",kT.noop),[n,a]=(0,Jy.useState)(!1);return t?(0,Ar.jsxs)(Zf,{children:[(0,Ar.jsx)(eh,{asChild:!0,children:(0,Ar.jsx)(E,{variant:"ghost",size:"icon",className:"h-8 w-8 focus-within:bg-primary/30 hover:bg-primary/30 focus:bg-primary/30 active:bg-primary/30",children:(0,Ar.jsx)(s9.CircleUser,{className:"h-5 w-5"})})}),(0,Ar.jsxs)(og,{className:"w-auto space-y-2 p-4",children:[(0,Ar.jsx)("div",{className:"text-sm font-medium",children:(s=t.name)!=null?s:t.email}),(0,Ar.jsx)("div",{className:"text-xs text-muted-foreground",children:t.email}),(0,Ar.jsx)(E,{variant:"outline",size:"sm",className:"w-full",onClick:()=>a(!0),children:e("Change Password")}),n&&(0,Ar.jsx)(Jy.Suspense,{fallback:(0,Ar.jsx)(Te,{open:n,onOpenChange:a,children:(0,Ar.jsx)(we,{className:"sm:max-w-[425px]",children:(0,Ar.jsx)("div",{className:"flex h-[340px] items-center justify-center",children:(0,Ar.jsx)(wt,{})})})}),children:(0,Ar.jsx)(Wae,{open:n,onOpenChange:a})}),(0,Ar.jsxs)(cd,{children:[(0,Ar.jsx)(dw,{asChild:!0,children:(0,Ar.jsx)(E,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),(0,Ar.jsxs)(nc,{children:[(0,Ar.jsxs)(up,{children:[(0,Ar.jsx)(ac,{children:e("Are you sure you want to logout?")}),(0,Ar.jsx)(gp,{children:e("You will be redirected to the login page.")})]}),(0,Ar.jsxs)(bg,{children:[(0,Ar.jsx)(hp,{children:e("Cancel")}),(0,Ar.jsx)(fp,{onClick:()=>{o(),(0,kT.isFunction)(r)&&r()},children:e("Logout")})]})]})]})]})]}):null},l9={id:zB,label:"User Info",button:jae,position:"bottom"}});var ST,Qy,d9,qae,Kae,p9,m9=x(()=>{"use strict";ST=require("lucide-react");s8();al();Rr();J();th();TB();f8();A8();D8();Mj();Zj();c9();Qy=require("react/jsx-runtime"),d9=280,qae=({isActive:e,show:t})=>(0,Qy.jsx)(E,{variant:"ghost",size:"icon",onClick:t,className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,Qy.jsx)(ST.Layers,{className:"h-5 w-5"})}),Kae=({isActive:e,show:t})=>Zn()&&(0,Qy.jsx)(E,{variant:"ghost",size:"icon",onClick:t,className:`h-8 w-8 ${e?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""}`,children:(0,Qy.jsx)(ST.SquarePlus,{className:"h-5 w-5"})}),p9=()=>{ol(Gv,c8),ol("add-block",{button:Kae,label:"Add Blocks",position:"top",isInternal:!0,width:d9,panel:()=>(0,Qy.jsx)(Hx,{showHeading:!1,fromSidebar:!0,parentId:void 0,position:-1})}),ol("outline",{button:qae,label:"",position:"top",isInternal:!0,width:d9,panel:CB}),ol(VB,Lj),ol(DB,R8),ol(zB,l9),ol(ll,cM),ol(Qj,Xj),ol(u8,g8),ol(N8,E8)}});var wT,Yae,Za,rf=x(()=>{"use strict";pn();wT=require("react/jsx-runtime"),Yae=({className:e="",inBuilder:t})=>t?(0,wT.jsx)("div",{className:Co("pointer-events-none flex h-20 flex-col items-center justify-center p-2",e),children:(0,wT.jsx)("div",{className:"h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800",children:(0,wT.jsx)("div",{className:"flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700"})})}):null,Za=Yae});var u9,h9,g9,f9,y9=x(()=>{"use strict";u9=K(require("react"),1);Ne();rf();h9=require("react/jsx-runtime"),g9=e=>{let{blockProps:t,inBuilder:o,backgroundImage:r,children:n,tag:a="div",styles:s}=e,i=n;n||(i=(0,h9.jsx)(Za,{inBuilder:o}));let l={};return r&&(l={backgroundImage:`url(${r})`}),u9.createElement(a,{...t,...s,style:l},i)},f9={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",props:Be({properties:{styles:Re(""),tag:{type:"string",default:"div",title:"Tag",oneOf:[{const:"div",title:"div"},{const:"header",title:"header"},{const:"footer",title:"footer"},{const:"section",title:"section"},{const:"article",title:"article"},{const:"aside",title:"aside"},{const:"main",title:"main"},{const:"nav",title:"nav"},{const:"figure",title:"figure"},{const:"details",title:"details"},{const:"summary",title:"summary"},{const:"dialog",title:"dialog"},{const:"strike",title:"strike"},{const:"caption",title:"caption"},{const:"legend",title:"legend"},{const:"figcaption",title:"figcaption"},{const:"mark",title:"mark"}]},backgroundImage:{type:"string",default:"",title:"Background Image",ui:{"ui:widget":"image","ui:allowEmpty":!0}}}}),canAcceptBlock:()=>!0}});var b9,Xy,x9,$p,v9,C9,k9=x(()=>{"use strict";b9=require("@radix-ui/react-icons"),Xy=require("lodash-es"),x9=require("react");Ne();$p=require("react/jsx-runtime"),v9=e=>{let{blockProps:t,iconSize:o,icon:r,content:n,styles:a,children:s,iconPos:i,link:l,inBuilder:c}=e,d=r,p=s||(0,$p.jsxs)($p.Fragment,{children:[n&&(0,$p.jsx)("span",{children:n}),d&&(0,$p.jsx)("div",{style:{width:o+"px"},className:i+" "+(n?i==="order-first"?"mr-2":"ml-2":"")||"",dangerouslySetInnerHTML:{__html:d}})]}),u=(0,x9.createElement)("button",{...t,...a,type:"button","aria-label":n},p);return(0,Xy.isEmpty)((0,Xy.get)(l,"href"))?u:c?(0,$p.jsx)("span",{children:u}):(0,$p.jsx)("a",{"aria-label":n,href:(0,Xy.get)(l,"href")||"/",target:(0,Xy.get)(l,"target","_self"),children:u})},C9={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:b9.ButtonIcon,group:"basic",props:Be({properties:{styles:Re("dt#btn dt#btn-primary"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:16},iconPos:{type:"string",title:"Icon position",default:"order-last",enum:["order-first","order-last"],enumNames:["Left","Right"]},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}},prefetchLink:{type:"boolean",default:!0,title:"Prefetch Link"}}}),i18nProps:["content","link"],aiProps:["content"]}});var S9,WB,PT,Jae,w9,P9,T9=x(()=>{"use strict";S9=require("@radix-ui/react-icons"),WB=K(require("react"),1);Ne();PT=require("react/jsx-runtime"),Jae=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,w9=e=>{let{blockProps:t,styles:o,htmlCode:r,inBuilder:n}=e;return n?(0,PT.jsxs)("div",{className:"relative",...t,children:[n?(0,PT.jsx)("div",{...o,className:"absolute z-20 h-full w-full"}):null,WB.createElement("div",{...o,dangerouslySetInnerHTML:{__html:r.replace(Jae,"")}})]}):WB.createElement("div",{...t,...o,dangerouslySetInnerHTML:{__html:r}})},P9={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:S9.CodeIcon,group:"advanced",props:Be({properties:{styles:Re(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}}),i18nProps:["htmlCode"]}});var N9,Zy,E9,A9,I9=x(()=>{"use strict";pn();Ne();N9=require("@radix-ui/react-icons"),Zy=require("react/jsx-runtime"),E9=e=>{let{scripts:t,inBuilder:o,blockProps:r}=e;return o?(0,Zy.jsx)("div",{...r,children:(0,Zy.jsx)("div",{className:Co("pointer-events-none flex flex-col items-center justify-center p-2",""),children:(0,Zy.jsx)("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:(0,Zy.jsx)("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):(0,Zy.jsx)("div",{dangerouslySetInnerHTML:{__html:t}})},A9={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:N9.CodeIcon,hidden:!0,group:"advanced",props:Be({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');</script>"}}})}});var B9,R9,Kv,D9,_9,L9=x(()=>{"use strict";B9=require("@radix-ui/react-icons"),R9=K(require("react"),1);Ne();Kv=require("react/jsx-runtime"),D9=e=>{let{blockProps:t,inBuilder:o,children:r,globalBlock:n}=e;return o&&!n?(0,Kv.jsxs)("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...t,children:[(0,Kv.jsxs)("h1",{children:["Global Block - ",n]}),(0,Kv.jsx)("p",{children:"Choose a block from the sidebar to add it to this page."})]}):R9.createElement("span",{...t},r)},_9={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:B9.FrameIcon,category:"core",group:"basic",hidden:!0,props:Be({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})}});var eb,TT=x(()=>{"use strict";pn();eb=(e,...t)=>({...e,className:Co(e.className,...t)})});var M9,O9,F9,G9,H9,U9,$9=x(()=>{"use strict";M9=require("@radix-ui/react-icons"),O9=require("lodash-es"),F9=K(require("react"),1);Ne();rf();TT();G9=require("react/jsx-runtime"),H9=e=>{let{blockProps:t,icon:o,styles:r,width:n,inBuilder:a,height:s}=e,i=eb(r,"");if((0,O9.isEmpty)(o))return(0,G9.jsx)(Za,{inBuilder:a,className:"h-8 w-14"});let l=o.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return F9.createElement("span",{...t,...i,style:{width:n?`${n}px`:"auto",height:s?`${s}px`:"auto"},dangerouslySetInnerHTML:{__html:l}})},U9={type:"Icon",label:"web_blocks.icon",category:"core",description:"Icon block is used to display an icon/svg.",icon:M9.SketchLogoIcon,group:"media",props:Be({properties:{styles:Re(""),icon:{type:"string",title:"Icon",default:'<svg xmlns="http://www.w3.org/2000/svg" class="chai-default-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-diamond-icon lucide-diamond"><path d="M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z"/></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})}});var V9,z9,Yv,W9,j9,q9=x(()=>{"use strict";V9=require("@radix-ui/react-icons"),z9=K(require("react"),1);Ne();Yv=require("react/jsx-runtime"),W9=e=>{let{blockProps:t,inBuilder:o,children:r,partialBlockId:n}=e;return o&&!n?(0,Yv.jsxs)("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...t,children:[(0,Yv.jsxs)("h1",{children:["Partial Block - ",n]}),(0,Yv.jsx)("p",{children:"Choose a block from the sidebar to add it to this page."})]}):z9.createElement("span",{...t},r)},j9={type:"PartialBlock",description:"A partial block component. Partial blocks are global blocks that can be used in multiple pages.",label:"Partial Block",icon:V9.FrameIcon,category:"core",group:"basic",hidden:!0,props:Be({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})}});var NT,K9=x(()=>{"use strict";NT={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}}});var AT,tb,ET,Y9,J9,Q9,X9,Z9=x(()=>{"use strict";AT=require("@radix-ui/react-icons"),tb=require("lodash-es");K9();Ne();ET=require("react/jsx-runtime"),Y9=e=>{let{blockProps:t,children:o,styles:r,colSpan:n,tabletColSpan:a,desktopColSpan:s}=e,l={className:[(0,tb.get)(r,"className",""),(0,tb.get)(NT,["SMALL",isNaN(n)||!n?6:n],""),a?(0,tb.get)(NT,["MEDIUM",a||n],""):"",s?(0,tb.get)(NT,["LARGE",a||n],""):""].join(" ")};return(0,ET.jsx)("div",{...t,...r,...l,children:o||(0,ET.jsx)("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},J9={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:AT.LayoutIcon,wrapper:!0,hidden:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",props:Be({properties:{styles:Re(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},Q9=e=>{let{blockProps:t,children:o,styles:r,gutter:n}=e,s={className:[(0,tb.get)(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"&&r.style!==null?s.style={...r.style,gap:`${n}px`}:s.style={gap:`${n}px`},(0,ET.jsx)("div",{...t,...r,...s,children:o})},X9={type:"Row",description:"A row component",label:"Row",group:"basic",icon:AT.RowsIcon,hidden:!0,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",props:Be({properties:{styles:Re(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})}});var eq,tq,oq,rq,nq=x(()=>{"use strict";eq=require("@radix-ui/react-icons"),tq=require("react");Ne();oq=e=>{let{blockProps:t,styles:o}=e;return(0,tq.createElement)("hr",{...o,...t})},rq={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:eq.DividerHorizontalIcon,group:"basic",props:Be({properties:{styles:Re("dt#separator")}})}});var aq,sq,iq,lq=x(()=>{"use strict";aq=K(require("react"),1);Ne();sq=e=>{let{blockProps:t,styles:o,backgroundImage:r}=e,n={};return r&&(n={backgroundImage:`url(${r})`}),aq.createElement("div",{...t,...o,style:n})},iq={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",props:Be({properties:{styles:Re(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image","ui:allowEmpty":!0}}}})}});var cq,ob,dq,pq,mq=x(()=>{"use strict";cq=require("@radix-ui/react-icons");Ne();ob=require("react/jsx-runtime"),dq=e=>{let{blockProps:t,fieldName:o,label:r,styles:n,inputStyles:a,required:s,checked:i,showLabel:l=!0}=e;return l?(0,ob.jsxs)("div",{...n,...t,children:[(0,ob.jsx)("input",{...a,id:o,name:o,type:"checkbox",required:s,defaultChecked:i}),r&&(0,ob.jsx)("label",{htmlFor:o,children:r})]}):(0,ob.jsx)("input",{name:o,...t,...a,...n,type:"checkbox",required:s,defaultChecked:i})},pq={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:cq.CheckboxIcon,group:"form",props:Be({properties:{styles:Re("flex items-center gap-x-2"),inputStyles:Re("dt#checkbox"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]}});var uq,Jv,gq,fq,hq=x(()=>{"use strict";uq=require("@radix-ui/react-icons");Ne();rf();Jv=require("react/jsx-runtime"),gq=e=>{let{children:t,blockProps:o,errorMessage:r,successMessage:n,action:a,styles:s,inBuilder:i}=e,l=t;return t||(l=(0,Jv.jsx)(Za,{inBuilder:i})),(0,Jv.jsxs)("form",{...{"x-data":"{}","x-on:submit.prevent":"post"},"data-error":r,"data-success":n,method:"post",action:a,...o,...s,children:[(0,Jv.jsx)("div",{...{"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"}}),l]})},fq={type:"Form",label:"Form",category:"core",icon:uq.FileTextIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],props:Be({properties:{styles:Re(""),action:{type:"string",title:"Submit URL",default:"/api/form"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0}});var yq,IT,bq,xq,vq=x(()=>{"use strict";yq=require("@radix-ui/react-icons");Ne();IT=require("react/jsx-runtime"),bq=e=>{let{blockProps:t,inBuilder:o,label:r,styles:n,icon:a,iconSize:s,iconPos:i}=e;return(0,IT.jsxs)("button",{...n,...t||{},type:o?"button":"submit","aria-label":r,children:[r,a&&(0,IT.jsx)("div",{style:{width:s+"px"},className:i+" "+(i==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},xq={type:"FormButton",label:"Submit Button",category:"core",icon:yq.ButtonIcon,group:"form",props:Be({properties:{styles:Re("dt#btn dt#btn-primary"),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]}});var Cq,rb,Qae,kq,Sq,wq=x(()=>{"use strict";Cq=require("@radix-ui/react-icons");Ne();rb=require("react/jsx-runtime"),Qae=e=>{let t={type:"text",autoComplete:"on"};return e?["text","password","number","hidden","range","color","date","time"].includes(e)?{type:e,autoComplete:"on"}:e==="email"?{type:"email",autoComplete:"email"}:e==="tel"?{type:"tel",autoComplete:"tel"}:e==="url"?{type:"url",autoComplete:"url"}:{off:{type:"text",autoComplete:"off"},on:{type:"text",autoComplete:"on"},name:{type:"text",autoComplete:"name"},"honorific-prefix":{type:"text",autoComplete:"honorific-prefix"},"given-name":{type:"text",autoComplete:"given-name"},"additional-name":{type:"text",autoComplete:"additional-name"},"family-name":{type:"text",autoComplete:"family-name"},"honorific-suffix":{type:"text",autoComplete:"honorific-suffix"},nickname:{type:"text",autoComplete:"nickname"},firstName:{type:"text",autoComplete:"given-name"},lastName:{type:"text",autoComplete:"family-name"},email:{type:"email",autoComplete:"email"},tel:{type:"tel",autoComplete:"tel"},"tel-country-code":{type:"tel",autoComplete:"tel-country-code"},"tel-national":{type:"tel",autoComplete:"tel-national"},"tel-area-code":{type:"tel",autoComplete:"tel-area-code"},"tel-local":{type:"tel",autoComplete:"tel-local"},"tel-extension":{type:"tel",autoComplete:"tel-extension"},"street-address":{type:"text",autoComplete:"street-address"},"address-line1":{type:"text",autoComplete:"address-line1"},"address-line2":{type:"text",autoComplete:"address-line2"},"address-line3":{type:"text",autoComplete:"address-line3"},"address-level1":{type:"text",autoComplete:"address-level1"},"address-level2":{type:"text",autoComplete:"address-level2"},"address-level3":{type:"text",autoComplete:"address-level3"},"address-level4":{type:"text",autoComplete:"address-level4"},country:{type:"text",autoComplete:"country"},"country-name":{type:"text",autoComplete:"country-name"},"postal-code":{type:"text",autoComplete:"postal-code"},"cc-name":{type:"text",autoComplete:"cc-name"},"cc-given-name":{type:"text",autoComplete:"cc-given-name"},"cc-additional-name":{type:"text",autoComplete:"cc-additional-name"},"cc-family-name":{type:"text",autoComplete:"cc-family-name"},"cc-number":{type:"text",autoComplete:"cc-number"},"cc-exp":{type:"text",autoComplete:"cc-exp"},"cc-exp-month":{type:"number",autoComplete:"cc-exp-month"},"cc-exp-year":{type:"number",autoComplete:"cc-exp-year"},"cc-csc":{type:"text",autoComplete:"cc-csc"},"cc-type":{type:"text",autoComplete:"cc-type"},bday:{type:"date",autoComplete:"bday"},"bday-day":{type:"number",autoComplete:"bday-day"},"bday-month":{type:"number",autoComplete:"bday-month"},"bday-year":{type:"number",autoComplete:"bday-year"},username:{type:"text",autoComplete:"username"},"new-password":{type:"password",autoComplete:"new-password"},"current-password":{type:"password",autoComplete:"current-password"},"one-time-code":{type:"text",autoComplete:"one-time-code"},"transaction-currency":{type:"text",autoComplete:"transaction-currency"},"transaction-amount":{type:"number",autoComplete:"transaction-amount"},url:{type:"url",autoComplete:"url"},photo:{type:"url",autoComplete:"photo"},sex:{type:"text",autoComplete:"sex"},"organization-title":{type:"text",autoComplete:"organization-title"},organization:{type:"text",autoComplete:"organization"},language:{type:"text",autoComplete:"language"}}[e]||t:t},kq=e=>{let{blockProps:t,fieldName:o,label:r,placeholder:n,styles:a,inputStyles:s,showLabel:i,required:l,inputType:c,defaultValue:d}=e,{type:p,autoComplete:u}=Qae(c);return i?(0,rb.jsxs)("div",{...a,...t,children:[i&&(0,rb.jsx)("label",{htmlFor:o,children:r}),(0,rb.jsx)("input",{id:o,name:o,...s,type:p,placeholder:n,required:l,autoComplete:u,...p==="hidden"?{value:d,readOnly:!0}:{defaultValue:d}})]}):(0,rb.jsx)("input",{name:o,...t,...s,...a,type:p,placeholder:n,required:l,autoComplete:u,...p==="hidden"?{value:d,readOnly:!0}:{defaultValue:d}})},Sq={type:"Input",label:"web_blocks.input",category:"core",icon:Cq.InputIcon,group:"form",props:Be({properties:{styles:Re(""),inputStyles:Re("dt#input"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},inputType:{type:"string",title:"Type",default:"email",oneOf:[{const:"text",title:"Text"},{const:"email",title:"Email"},{const:"password",title:"Password"},{const:"number",title:"Number"},{const:"tel",title:"Telephone"},{const:"hidden",title:"Hidden"},{const:"range",title:"Range"},{const:"color",title:"Color"},{const:"date",title:"Date"},{const:"time",title:"Time"},{const:"url",title:"URL"},{const:"name",title:"Name"},{const:"firstName",title:"First Name"},{const:"lastName",title:"Last Name"},{const:"tel-country-code",title:"Telephone Country Code"},{const:"tel-national",title:"Telephone National"},{const:"tel-area-code",title:"Telephone Area Code"},{const:"tel-local",title:"Telephone Local"},{const:"tel-extension",title:"Telephone Extension"},{const:"street-address",title:"Street Address"},{const:"address-line1",title:"Address Line 1"},{const:"address-line2",title:"Address Line 2"},{const:"address-line3",title:"Address Line 3"},{const:"address-level1",title:"Address Level 1"},{const:"address-level2",title:"Address Level 2"},{const:"address-level3",title:"Address Level 3"},{const:"address-level4",title:"Address Level 4"},{const:"country",title:"Country"},{const:"country-name",title:"Country Name"},{const:"postal-code",title:"Postal Code"},{const:"cc-name",title:"Credit Card Name"},{const:"cc-number",title:"Credit Card Number"},{const:"cc-exp",title:"Credit Card Expiry"},{const:"cc-exp-month",title:"Credit Card Expiry Month"},{const:"cc-exp-year",title:"Credit Card Expiry Year"},{const:"cc-csc",title:"Credit Card CSC"},{const:"cc-type",title:"Credit Card Type"},{const:"bday",title:"Birthday"},{const:"bday-day",title:"Birthday Day"},{const:"bday-month",title:"Birthday Month"},{const:"bday-year",title:"Birthday Year"},{const:"username",title:"Username"},{const:"new-password",title:"New Password"},{const:"current-password",title:"Current Password"},{const:"one-time-code",title:"One Time Code"},{const:"transaction-currency",title:"Transaction Currency"},{const:"transaction-amount",title:"Transaction Amount"},{const:"url",title:"URL"},{const:"photo",title:"Photo"},{const:"sex",title:"Sex"},{const:"organization-title",title:"Organization Title"},{const:"organization",title:"Organization"},{const:"language",title:"Language"}]},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},defaultValue:{type:"string",title:"Default Value",default:""}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]}});var Pq,jB,Tq,Nq,Eq=x(()=>{"use strict";Pq=require("@radix-ui/react-icons"),jB=K(require("react"),1);Ne();Tq=e=>{let{blockProps:t,content:o,styles:r,children:n}=e,a={...r,...t};return n?jB.createElement("label",a,n):jB.createElement("label",{...a,dangerouslySetInnerHTML:{__html:o}})},Nq={type:"Label",label:"Label",category:"core",icon:Pq.LetterCaseToggleIcon,group:"form",props:Be({properties:{styles:Re("dt#label"),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]}});var Aq,nb,Iq,Bq,Rq=x(()=>{"use strict";Aq=require("@radix-ui/react-icons");Ne();nb=require("react/jsx-runtime"),Iq=e=>{let{blockProps:t,fieldName:o,label:r,styles:n,inputStyles:a,required:s,checked:i,showLabel:l=!0}=e;return l?(0,nb.jsxs)("div",{...n,...t,children:[(0,nb.jsx)("input",{...a,name:o,type:"radio",required:s,defaultChecked:i}),r&&(0,nb.jsx)("label",{htmlFor:o,children:r})]}):(0,nb.jsx)("input",{name:o,...t,...a,...n,type:"radio",required:s,checked:i})},Bq={type:"Radio",label:"web_blocks.radio",category:"core",icon:Aq.RadiobuttonIcon,group:"form",props:Be({properties:{styles:Re("flex items-center gap-x-2"),inputStyles:Re(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]}});var Dq,qB,Id,_q,Lq,Mq=x(()=>{"use strict";Dq=require("@radix-ui/react-icons"),qB=require("lodash-es");Ne();Id=require("react/jsx-runtime"),_q=e=>{let{blockProps:t,fieldName:o,label:r,placeholder:n,styles:a,inputStyles:s,required:i,showLabel:l,_multiple:c,options:d,defaultValue:p}=e,u=c&&p?p.split(",").map(m=>m.trim()):p||"";return l?(0,Id.jsxs)("div",{...a,...t,children:[l&&(0,Id.jsx)("label",{htmlFor:o,children:r}),(0,Id.jsxs)("select",{...s,required:i,multiple:c,name:o,defaultValue:u,children:[(0,Id.jsx)("option",{value:"",disabled:!0,hidden:!0,children:n}),(0,qB.map)(d,m=>(0,Id.jsx)("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):(0,Id.jsxs)("select",{...a,...t,required:i,multiple:c,name:o,defaultValue:u,children:[(0,Id.jsx)("option",{value:"",disabled:!0,hidden:!0,children:n}),(0,qB.map)(d,m=>(0,Id.jsx)("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},Lq={type:"Select",label:"web_blocks.select",category:"core",icon:Dq.DropdownMenuIcon,group:"form",props:Be({properties:{styles:Re(""),inputStyles:Re("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},defaultValue:{type:"string",title:"Default Value",default:""},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),i18nProps:["label","placeholder","options"]}});var Oq,ab,Fq,Hq,Uq=x(()=>{"use strict";Oq=require("@radix-ui/react-icons");Ne();ab=require("react/jsx-runtime"),Fq=e=>{let{blockProps:t,fieldName:o,label:r,placeholder:n,styles:a,inputStyles:s,rows:i,showLabel:l,required:c,defaultValue:d}=e;return l?(0,ab.jsxs)("div",{...a,...t,children:[l&&(0,ab.jsx)("label",{htmlFor:o,children:r}),(0,ab.jsx)("textarea",{name:o,...s,placeholder:n,rows:i,required:c,defaultValue:d})]}):(0,ab.jsx)("textarea",{name:o,...t,...s,...a,placeholder:n,rows:i,required:c,defaultValue:d})},Hq={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:Oq.InputIcon,group:"form",props:Be({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:Re(""),inputStyles:Re("dt#textarea"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},rows:{type:"number",title:"Rows",default:3},required:{type:"boolean",title:"Required",default:!1},defaultValue:{type:"string",title:"Default Value",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]}});var Gq,KB,$q,Vq,zq=x(()=>{"use strict";Gq=require("@radix-ui/react-icons"),KB=K(require("react"),1);Ne();$q=e=>{let{blockProps:t,styles:o,content:r,tag:n="h1",children:a=null}=e;return a?KB.createElement(n,{...o,...t},a):KB.createElement(n,{...o,...t,dangerouslySetInnerHTML:{__html:r}})},Vq={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:Gq.HeadingIcon,group:"typography",props:Be({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:Re("text-3xl"),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea","ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0}});var Wq,jq,qq,Kq=x(()=>{"use strict";Wq=require("react");Ne();jq=e=>{let{blockProps:t,styles:o}=e;return(0,Wq.createElement)("br",{...t,...o})},qq={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,props:Be({properties:{styles:Re("")}})}});function Qv(e){let t=(a,s)=>({_id:Uo(),_parent:a,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+s}`}),o=a=>{let s=Uo(),i={_type:"TableRow",_id:s,styles:"#styles:,border-b"};return a&&(i._parent=a),[i,t(s,"1"),t(s,"2"),t(s,"3")]},r=a=>{let s=Uo(),i={_id:s,_type:"TableHead",styles:"#styles:,font-medium"};return a&&(i._parent=a),[i,...o(s)]},n=a=>{let s=Uo(),i={_id:s,_type:"TableBody",styles:"#styles:,"};return a&&(i._parent=a),[i,...o(s),...o(s)]};if(e==="Table"){let a=Uo();return[{_id:a,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(a),...n(a)]}return e==="TableRow"?o():e==="TableHead"?r():e==="TableBody"?n():[]}var Bd,Yq,nf,sb,Xae,Zae,ese,tse,ose,Jq=x(()=>{"use strict";Bd=require("@radix-ui/react-icons"),Yq=require("lodash-es"),nf=require("react");pn();Ne();rf();sb=require("react/jsx-runtime"),Xae=e=>{let{blockProps:t,children:o,styles:r}=e;return o?(0,nf.createElement)("table",{...t,...r},o):(0,sb.jsx)(Za,{})},Zae=e=>{let{blockProps:t,children:o,styles:r}=e;return o?(0,nf.createElement)("thead",{...t,...r},o):(0,sb.jsx)(Za,{})},ese=e=>{let{blockProps:t,children:o,styles:r}=e;return o?(0,nf.createElement)("tbody",{...t,...r},o):(0,sb.jsx)(Za,{})},tse=e=>{let{blockProps:t,children:o,styles:r}=e;return o?(0,nf.createElement)("tr",{...t,...r},o):(0,sb.jsx)(Za,{})},ose=e=>{let{blockProps:t,children:o,content:r,styles:n}=e;return!o&&(0,Yq.isEmpty)(r)?(0,sb.jsx)(Za,{}):o?(0,nf.createElement)("td",{...t,...n},o):(0,nf.createElement)("td",{...t,...n,dangerouslySetInnerHTML:{__html:r}})};_t(Xae,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:Bd.TableIcon,props:Be({properties:{styles:Re("")}}),blocks:Qv("Table")});_t(Zae,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:Bd.BorderTopIcon,props:Be({properties:{styles:Re("")}}),blocks:Qv("TableHead")});_t(ese,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:Bd.BorderAllIcon,props:Be({properties:{styles:Re("")}}),blocks:Qv("TableBody")});_t(tse,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:Bd.ViewHorizontalIcon,props:Be({properties:{styles:Re("")}}),blocks:Qv("TableRow")});_t(ose,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:Bd.DragHandleHorizontalIcon,props:Be({properties:{styles:Re(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:Qv("TableCell"),i18nProps:["content"],aiProps:["content"]})});var Qq,Xq,ib,rse,Zq,eK,tK=x(()=>{"use strict";Qq=require("@radix-ui/react-icons"),Xq=require("lodash-es");Ne();rf();ib=require("react/jsx-runtime"),rse="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",Zq=e=>{let{blockProps:t,image:o,mobileImage:r,styles:n,alt:a,height:s,width:i,lazyLoading:l,mobileWidth:c,mobileHeight:d}=e;return(0,Xq.isEmpty)(o)?(0,ib.jsx)(Za,{className:"h-36"}):(0,ib.jsxs)("picture",{children:[r&&(0,ib.jsx)("source",{srcSet:r,media:"(max-width: 480px)",width:c,height:d}),(0,ib.jsx)("img",{...t,...n,src:o,alt:a,loading:l?"lazy":"eager",width:i,height:s})]})},eK={type:"Image",description:"A image component",label:"Image",category:"core",icon:Qq.ImageIcon,group:"media",props:Be({properties:{styles:Re("w-full h-full object-cover"),image:{type:"string",title:"Image",default:rse,ui:{"ui:widget":"image"}},width:{type:"string",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"string",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}},mobileWidth:{type:"string",title:"Mobile Width",default:"",ui:{"ui:placeholder":"Enter width"}},mobileHeight:{type:"string",title:"Mobile Height",default:"",ui:{"ui:placeholder":"Enter height"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0}}}),aiProps:["alt"],i18nProps:["alt","image","_imageId","mobileImage","_mobileImageId"]}});var oK,rK,YB,JB,nK,aK,sK=x(()=>{"use strict";oK=require("@radix-ui/react-icons"),rK=require("lodash-es"),YB=require("react");Ne();JB=require("react/jsx-runtime"),nK=e=>{let{blockProps:t,link:o,children:r,styles:n,inBuilder:a,content:s}=e,i={};return!r&&(0,rK.isEmpty)(s)&&(i={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),a?r?(0,JB.jsx)("span",{role:"link",...t,style:i,...n,children:r}):(0,YB.createElement)("span",{...t,...n,style:i,role:"link"},s):r?(0,JB.jsx)("a",{"aria-label":s,href:(o==null?void 0:o.href)||"#/",target:o==null?void 0:o.target,...t,...n,children:r}):(0,YB.createElement)("a",{...t,...n,href:(o==null?void 0:o.href)||"#",target:(o==null?void 0:o.target)||"_self","aria-label":s},s)},aK={type:"Link",description:"A link component",label:"Link",category:"core",icon:oK.Link1Icon,group:"basic",props:Be({properties:{styles:Re("block"),content:{type:"string",default:"Link text goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),aiProps:["content"],i18nProps:["content","link"],canAcceptBlock:e=>e!=="Link"}});var iK,lK,cK,mK,dK,pK,uK=x(()=>{"use strict";iK=require("@radix-ui/react-icons"),lK=require("lodash-es"),cK=K(require("react"),1);Ne();rf();mK=require("react/jsx-runtime"),dK=e=>{let{blockProps:t,children:o,styles:r,tag:n,inBuilder:a}=e;return!o&&(0,lK.isEmpty)(r==null?void 0:r.className)?(0,mK.jsx)(Za,{inBuilder:a}):cK.createElement(n||"ul",{...t,...r},o)},pK={type:"List",description:"A list component",label:"List",icon:iK.RowsIcon,category:"core",group:"basic",props:Be({properties:{styles:Re("")}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]}});var gK,QB,fK,hK,yK=x(()=>{"use strict";gK=require("@radix-ui/react-icons"),QB=K(require("react"),1);Ne();fK=e=>{let{blockProps:t,content:o,styles:r,children:n,tag:a}=e;return n?QB.createElement(a||"li",{...r,...t},n):QB.createElement(a||"li",{...r,...t,dangerouslySetInnerHTML:{__html:o}})},hK={type:"ListItem",description:"A list item component",label:"List Item",icon:gK.ColumnsIcon,category:"core",group:"basic",props:Be({properties:{styles:Re(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"||e==="Repeater"}});var bK,xK,XB,vK,CK,kK=x(()=>{"use strict";bK=require("@radix-ui/react-icons"),xK=require("lodash-es"),XB=K(require("react"),1);Ne();TT();vK=e=>{let{blockProps:t,styles:o,content:r}=e;if(!(0,xK.isNull)(e.children))return XB.createElement("p",{...o,...t},e.children);let n=eb(o,"rte");return XB.createElement("div",{...n,...t,dangerouslySetInnerHTML:{__html:r}})},CK={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:bK.TextIcon,group:"typography",props:Be({properties:{styles:Re(""),content:{type:"string",title:"Content",default:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.",ui:{"ui:widget":"richtext","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"}});var SK,TK,wK,PK,NK=x(()=>{"use strict";SK=require("@radix-ui/react-icons");Ne();TT();TK=require("react/jsx-runtime"),wK=e=>{let{blockProps:t,content:o,styles:r}=e,n=eb(r,"rte");return(0,TK.jsx)("div",{...t,...n,dangerouslySetInnerHTML:{__html:o}})},PK={type:"RichText",description:"A rich text block",label:"Rich Text",hidden:!0,category:"core",icon:SK.CursorTextIcon,group:"typography",props:Be({properties:{styles:Re(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]}});var ZB,EK,AK,IK=x(()=>{"use strict";ZB=K(require("react"),1);Ne();EK=e=>{let{blockProps:t,styles:o,content:r,children:n=null,tag:a}=e;return n?ZB.createElement("span",{...o,...t},n):ZB.createElement(a||"span",{...o,...t,dangerouslySetInnerHTML:{__html:r||""}})},AK={type:"Span",description:"A span component",label:"Span",category:"core",group:"basic",props:Be({properties:{styles:Re(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0}});var BK,_K,RK,DK,LK=x(()=>{"use strict";BK=require("@radix-ui/react-icons");Ne();_K=require("react/jsx-runtime"),RK=e=>e.inBuilder||e.forceWrapper?(0,_K.jsx)("span",{...e.blockProps,children:e.content}):`${e.content}`,DK={type:"Text",description:"A text component with no styling",label:"Text",category:"core",group:"typography",blocks:()=>[{_id:"a",_type:"Text",_name:"Text",content:""}],icon:BK.SpaceBetweenVerticallyIcon,props:Be({properties:{styles:Re("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]}});var FK,qn,yc,GK,eR,MK,OK,nse,ase,sse,HK,UK,$K=x(()=>{"use strict";FK=require("@radix-ui/react-icons"),qn=require("lodash-es");Ne();yc=require("react/jsx-runtime"),GK=require("react"),eR={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}},MK=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,OK=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,nse=(e,t)=>{let o=(0,qn.get)(t,"autoplay",!1),r=(0,qn.get)(t,"controls",!1),n=(0,qn.get)(t,"loop",!1),a=o||(0,qn.get)(t,"muted",!0);if(MK.test(e)){let s=e.match(MK);if(s){let i=s[4],l=`https://www.youtube.com/embed/${i}`,c=[];return o&&c.push("autoplay=1"),n&&c.push("loop=1",`playlist=${i}`),a&&c.push("mute=1","muted=1"),c.push(r?"controls=1":"controls=0"),`${l}?${c.join("&")}`}}if(OK.test(e)){let s=e.match(OK);if(s){let i=s[1],l=[];return o&&l.push("autoplay=1"),l.push(r?"controls=1":"controls=0"),a&&l.push("muted=1"),n&&l.push("loop=1"),`https://player.vimeo.com/video/${i}?${l.join("&")}`}}return null},ase=e=>{let{url:t,blockProps:o,styles:r,controls:n,videoSource:a,inBuilder:s,title:i}=e,l=nse(t,n);return(0,yc.jsxs)("div",{...(0,qn.omit)(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!l&&s?(0,yc.jsx)("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:(0,qn.isEmpty)(t)?`Provided ${a} video link in settings Video URL.`:`Provided ${a} video link is invalid.`}):(0,yc.jsx)("iframe",{className:`absolute left-0 top-0 h-full w-full ${(0,qn.pick)(r,"className").className||""}`,src:l!=null?l:"",title:i||"Video player",loading:"lazy",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}),s&&(0,yc.jsx)("div",{...o,className:"absolute top-0 h-full w-full"})]})},sse=e=>{let{url:t,styles:o,controls:r,sources:n,poster:a,blockProps:s,title:i}=e,l=a,c=[...(0,qn.get)(n,"srcsets",[])||[]];t&&typeof t=="string"&&c.push({url:t,width:9999});let d=c.sort((u,m)=>u.width-m.width).filter(u=>!(0,qn.isEmpty)(u.url)&&!(0,qn.isEmpty)(u.width));d.length===0&&!l&&(l="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");let p=(0,qn.get)(r,"autoplay",!1)||(0,qn.get)(r,"muted",!0);return(l||!(0,qn.isEmpty)(d))&&(0,yc.jsx)("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:(0,GK.createElement)("video",{...o,...s,title:i||"Video player",key:JSON.stringify(d),controls:(0,qn.get)(r,"controls",!1),autoPlay:(0,qn.get)(r,"autoplay",!1),loop:(0,qn.get)(r,"loop",!1),poster:l,...p?{muted:!0}:{}},d.map(u=>{if(!u.url||u.url.length<4||isNaN(u.width))return null;let m=`(max-width: ${u.width}px)`;return(0,yc.jsx)("source",{src:u.url,media:m,type:u.type},u.url)}),"Your browser does not support the video tag.")})},HK=e=>{let{videoSource:t}=e;return t==="Custom"?(0,yc.jsx)(sse,{...e}):t==="Youtube"||t==="Vimeo"?(0,yc.jsx)(ase,{...e}):(0,yc.jsxs)("div",{children:["Invalid video source : ",t]})},UK={type:"Video",label:"Video",category:"core",icon:FK.VideoIcon,group:"media",props:Be({properties:{styles:Re("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"},title:{type:"string",title:"Video Title",default:"Video player"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...eR}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""},controls:{...eR}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""},controls:{...eR}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url","title"]}});var BT,VK,zK,As,WK,jK=x(()=>{"use strict";BT=require("@radix-ui/react-icons"),VK=require("lodash-es"),zK=K(require("react"),1);Ne();As=require("react/jsx-runtime"),WK=e=>{let{paginationStyles:t}=e,o=Ct("Pagination");return(0,As.jsx)("div",{...t,children:o?zK.createElement(o.component,{...(0,VK.omit)(e,["paginationStyles"]),blockProps:{}}):(0,As.jsxs)(As.Fragment,{children:[(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-gray-300 bg-white hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",disabled:!0,children:(0,As.jsx)(BT.ChevronLeftIcon,{className:"h-4 w-4"})}),(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-blue-500 bg-blue-500 font-medium text-white",children:"1"}),(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-gray-300 bg-white font-medium text-gray-700 hover:bg-gray-50",children:"2"}),(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-gray-300 bg-white font-medium text-gray-700 hover:bg-gray-50",children:"3"}),(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-gray-300 bg-white font-medium text-gray-700 hover:bg-gray-50",children:"4"}),(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-gray-300 bg-white font-medium text-gray-700 hover:bg-gray-50",children:"5"}),(0,As.jsx)("button",{className:"flex h-9 w-9 items-center justify-center rounded-md border border-gray-300 bg-white hover:bg-gray-50",children:(0,As.jsx)(BT.ChevronRightIcon,{className:"h-4 w-4"})})]})})}});var tR,RT,Xv,ii,qK,KK,YK,JK,QK,XK,ZK=x(()=>{"use strict";tR=require("@radix-ui/react-icons"),RT=require("lodash-es"),Xv=K(require("react"),1);Ne();jK();ii=require("react/jsx-runtime"),qK=e=>{let{children:t,tag:o,styles:r,blockProps:n,$loading:a}=e,{pagination:s,inBuilder:i}=e,l=t;return(0,RT.isEmpty)(l)&&i&&(l=(0,ii.jsx)("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),o==="none"?a&&i?Array.from({length:2}).map((c,d)=>(0,ii.jsxs)("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[(0,ii.jsx)("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),(0,ii.jsx)("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},d)):l:(0,ii.jsxs)(ii.Fragment,{children:[Xv.createElement(o,{...n,...r},a&&i?Array.from({length:2}).map((c,d)=>(0,ii.jsxs)("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[(0,ii.jsx)("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),(0,ii.jsx)("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},d)):l),s&&(0,ii.jsx)(WK,{...(0,RT.pick)(e,["limit","totalItems","paginationStrategy","inBuilder","draft","lang","paginationStyles"])})]})},KK={type:"Repeater",label:"Repeater",icon:tR.LoopIcon,group:"basic",description:"Repeater block is used to display a list of items based on data binding in repeaterItems",dataProviderMode:"live",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],props:Be({properties:{styles:Re("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),paginationStyles:Re("flex items-center justify-center gap-2 p-4"),repeaterItems:{title:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["none","div","ul","ol"]},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},pagination:{title:"Pagination",type:"boolean",default:!1}},allOf:[{if:{properties:{pagination:{const:!0}}},then:{properties:{paginationStrategy:{type:"string",title:"Pagination Strategy",default:"segment",enum:["query","segment"]},limit:{type:"number",title:"Items Per Page",default:10,minimum:1}}}},{if:{properties:{pagination:{const:!1}}},then:{properties:{limit:{type:"number",title:"Max items",default:10,minimum:1}}}}]}),canAcceptBlock:e=>e==="Pagination"},YK=({children:e,blockProps:t,styles:o,parentTag:r,inBuilder:n})=>{let a="li";switch(r){case"ul":a="li";break;case"ol":a="li";break;default:a="div"}return!e&&n?Xv.createElement(a,{...t,...o},(0,ii.jsx)("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):Xv.createElement(a,{...t,...o},e)},JK={type:"RepeaterItem",label:"Repeater Item",icon:tR.LoopIcon,hidden:!0,group:"basic",props:Be({properties:{styles:Re(""),parentTag:a0("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},QK=({children:e,blockProps:t,styles:o})=>Xv.createElement("div",{...t,...o},e),XK={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",props:Be({properties:{styles:Re("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1}});var e7,t7=x(()=>{"use strict";Ne();y9();k9();T9();I9();L9();$9();q9();Z9();nq();lq();mq();hq();vq();wq();Eq();Rq();Mq();Uq();zq();Kq();Jq();tK();sK();uK();yK();kK();NK();IK();LK();$K();ZK();e7=()=>{_t(g9,f9),_t(sq,iq),_t(v9,C9),_t($q,Vq),_t(vK,CK),_t(EK,AK),_t(wK,PK),_t(nK,aK),_t(dK,pK),_t(fK,hK),_t(H9,U9),_t(Zq,eK),_t(HK,UK),_t(w9,P9),_t(E9,A9),_t(RK,DK),_t(gq,fq),_t(bq,xq),_t(kq,Sq),_t(dq,pq),_t(Iq,Bq),_t(_q,Lq),_t(Fq,Hq),_t(Tq,Nq),_t(jq,qq),_t(oq,rq),_t(D9,_9),_t(W9,j9),_t(Q9,X9),_t(Y9,J9),_t(qK,KK),_t(YK,JK),_t(QK,XK)}});var o7,DT,oR=x(()=>{"use strict";o7=require("jotai"),DT=(0,o7.atom)("")});var r7,n7=x(()=>{"use strict";Rr();r7=()=>{Wb("dynamic-page-selector",{description:"Dynamic page selector"}),Wb("enable-add-page-dropdown",{description:"Enable add page dropdown"})}});var _T,Zv,rR=x(()=>{"use strict";_T=require("@tanstack/react-query");St();rt();Kt();Zv=()=>{let e=he(),t=le(),o=(0,_T.useQueryClient)();return(0,_T.useQuery)({queryKey:[$.GET_WEBSITE_DATA],staleTime:300*1e3,queryFn:async()=>{let r=await e(t,{action:$.GET_WEBSITE_DATA});return o.setQueryData([$.GET_WEBSITE_DRAFT_SETTINGS],r.websiteSettings),o.setQueryData([$.GET_WEBSITE_PAGES],r.websitePages),o.setQueryData([$.GET_PAGE_TYPES],r.pageTypes),o.setQueryData([$.GET_LIBRARIES],r.libraries),o.setQueryData([$.GET_COLLECTIONS],r.collections),r}})}});var s7,eC,a7,i7,l7=x(()=>{"use strict";s7=require("@tanstack/react-query"),eC=require("lodash-es");St();Rr();Em();rR();Kt();rt();a7={async getUILibraryBlock(e,t,o){let r=await t(o,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),n=(0,eC.get)(r,"html",""),a=(0,eC.get)(r,"blocks",[]);return(0,eC.isArray)(a)?a:await $a(n)},async getUILibraryBlocks(e,t,o){return(await t(o,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(n=>({...n}))}},i7=()=>{let e=he(),t=le(),{data:o}=Zv(),r=o==null?void 0:o.libraries;return(0,s7.useQuery)({queryKey:[$.UI_LIBRARIES],staleTime:"static",queryFn:async()=>{let n=r.map(a=>({...a}));return n.forEach(a=>{eN(a.id,{name:a.isSiteLibrary?a.name+" (Current Site) ":a.name,description:a.description,getBlocksList:s=>a7.getUILibraryBlocks(s,e,t),getBlock:({block:s})=>a7.getUILibraryBlock(s,e,t)})}),n}})}});var nR,LT,c7,d7=x(()=>{"use strict";nR=require("@tanstack/react-query"),LT=require("react");St();er();rt();Uc();Kt();c7=()=>{let{data:e}=xt(),{data:t}=dr(),{data:o}=ca(),r=le(),n=he(),a=(0,LT.useMemo)(()=>(o==null?void 0:o.fallbackLang)||"en",[o==null?void 0:o.fallbackLang]),s=(0,LT.useRef)(new Map);return(0,nR.useMutation)({mutationFn:async({block:i})=>{let l=i._id,c=(t==null?void 0:t.lang)||a,d=`${l}:${c}`;if(s.current.has(d))return s.current.get(d);let p=n(r,{action:$.GET_BLOCK_ASYNC_PROPS,data:{block:i,lang:c,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}});return s.current.set(d,p),p.finally(()=>{s.current.delete(d)}),p}})}});var af,sf,bc,xc,vc,ise,Cc,kc,lb=x(()=>{"use strict";af=K(require("react"),1);st();sf=require("react/jsx-runtime"),bc=af.forwardRef(({className:e,...t},o)=>(0,sf.jsx)("div",{ref:o,className:G("rounded-xl border bg-card text-card-foreground shadow",e),...t}));bc.displayName="Card";xc=af.forwardRef(({className:e,...t},o)=>(0,sf.jsx)("div",{ref:o,className:G("flex flex-col space-y-1.5 p-6",e),...t}));xc.displayName="CardHeader";vc=af.forwardRef(({className:e,...t},o)=>(0,sf.jsx)("div",{ref:o,className:G("font-semibold leading-none tracking-tight",e),...t}));vc.displayName="CardTitle";ise=af.forwardRef(({className:e,...t},o)=>(0,sf.jsx)("div",{ref:o,className:G("text-sm text-muted-foreground",e),...t}));ise.displayName="CardDescription";Cc=af.forwardRef(({className:e,...t},o)=>(0,sf.jsx)("div",{ref:o,className:G("p-6 pt-0",e),...t}));Cc.displayName="CardContent";kc=af.forwardRef(({className:e,...t},o)=>(0,sf.jsx)("div",{ref:o,className:G("flex items-center p-6 pt-0",e),...t}));kc.displayName="CardFooter"});var u7={};et(u7,{default:()=>cse});var Iu,p7,m7,Zr,lse,cse,g7=x(()=>{"use strict";J();lb();Iu=require("lucide-react"),p7=require("react"),m7=require("react-i18next");Nn();Oo();Hp();ps();Vd();Zr=require("react/jsx-runtime"),lse=()=>{let e=$d(),{pageLockMeta:t}=Wc(),{setPageStatus:o}=rn(),{savePageAsync:r}=to(),n=t==null?void 0:t.requestingUserId,{data:a,isFetching:s}=xa(n||""),i=s?"Fetching user...":(a==null?void 0:a.name)||"Current editor",[l,c]=(0,p7.useState)(!1),d=R1(),p=async()=>{c(!0),await r(),lk.hasYieldedToTakeover=!0,await d(),e(Et.CONTINUE_EDITING_IN_THIS_CLIENT,t),o(go.CHECKING),setTimeout(()=>c(!1),2e3)},u=()=>{c(!0),e(Et.TAKE_OVER_REJECTED,t),o(go.EDITING),setTimeout(()=>c(!1),2e3)},{t:m}=(0,m7.useTranslation)();return(0,Zr.jsx)(Pn,{children:(0,Zr.jsxs)(bc,{className:"mx-auto h-fit w-full max-w-md",children:[(0,Zr.jsx)(xc,{className:"space-y-1",children:(0,Zr.jsxs)(vc,{className:"flex items-center gap-2 text-xl",children:[(0,Zr.jsx)(Iu.AlertCircle,{className:"h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500"}),m("Take Over Requested")]})}),(0,Zr.jsxs)(Cc,{className:"space-y-4",children:[(0,Zr.jsxs)("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[(0,Zr.jsx)("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Requested by"}),(0,Zr.jsxs)("div",{className:"flex items-center space-x-4 p-1",children:[a!=null&&a.avatar?(0,Zr.jsx)("img",{src:a.avatar,alt:a.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-0.5 text-white"}):(0,Zr.jsx)(Iu.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),(0,Zr.jsxs)("div",{className:"flex-1 space-y-0",children:[(0,Zr.jsx)("div",{className:"truncate font-medium leading-tight text-black",children:i}),(a==null?void 0:a.email)&&(0,Zr.jsx)("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:a.email})]})]})]}),(0,Zr.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,Zr.jsx)("span",{className:"font-medium text-gray-700",children:i})," ",m("has requested to")," ",(0,Zr.jsx)("span",{className:"font-medium text-gray-500",children:"take over"})," ",m("editing this page."),"."," ",m("Do you want to allow them to continue?")]})]}),(0,Zr.jsxs)(kc,{className:"flex gap-2",children:[(0,Zr.jsxs)(E,{disabled:l,variant:"default",onClick:p,className:"flex-1 gap-2",children:[(0,Zr.jsx)(Iu.Check,{className:"h-4 w-4"}),m("Accept")]}),(0,Zr.jsxs)(E,{disabled:l,variant:"outline",onClick:u,className:"flex-1 gap-2",children:[(0,Zr.jsx)(Iu.X,{className:"h-4 w-4"}),m("Reject")]})]})]})})},cse=lse});var h7={};et(h7,{default:()=>pse});var ji,Rd,f7,nt,dse,pse,y7=x(()=>{"use strict";Xf();J();lb();ji=require("lucide-react"),Rd=require("react"),f7=require("react-i18next");Oo();Hp();ps();Vd();mn();tn();nt=require("react/jsx-runtime"),dse=()=>{let e=W0(),t=$d(),{setPageStatus:o}=rn(),{data:r,isFetching:n}=xa((e==null?void 0:e.userId)||""),{pageLockMeta:a,setPageLockMeta:s}=Wc(),{t:i}=(0,f7.useTranslation)(),{hasPermission:l}=kt(),c=l(xe["pages:force_takeover"]),[d,p]=(0,Rd.useState)(""),[u,m]=(0,Rd.useState)({}),[g,h]=(0,Rd.useState)(!1),f=(0,Rd.useRef)(null);(0,Rd.useEffect)(()=>{a!=null&&a.type&&(f.current&&clearTimeout(f.current),(0,Rd.startTransition)(()=>{m(a),s({}),p("")}))},[a,s]);let b=()=>{d!==Et.TAKE_OVER_REQUEST&&(p(Et.TAKE_OVER_REQUEST),t(Et.TAKE_OVER_REQUEST),f.current=setTimeout(()=>p(""),2e4))},y=()=>{d!==Et.FORCE_TAKE_OVER_REQUEST&&(p(Et.FORCE_TAKE_OVER_REQUEST),t(Et.FORCE_TAKE_OVER_REQUEST),o(go.CHECKING),f.current=setTimeout(()=>p(""),2e4))},k=()=>{m({}),f.current&&clearTimeout(f.current),p("")},w=n?"Loading...":(r==null?void 0:r.name)||"Current editor",N=d===Et.TAKE_OVER_REQUEST,I=d===Et.FORCE_TAKE_OVER_REQUEST;return(0,nt.jsx)(Pn,{children:(0,nt.jsxs)(bc,{className:"mx-auto h-fit w-full max-w-md",children:[(0,nt.jsx)(xc,{className:"space-y-1 border-b pb-3",children:(0,nt.jsxs)(vc,{className:"flex items-center gap-2 text-xl",children:[(0,nt.jsx)(ji.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),(0,nt.jsx)("span",{children:i("Page Locked for Editing")})]})}),(0,nt.jsxs)(Cc,{className:"space-y-4 p-4",children:[(0,nt.jsxs)("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[(0,nt.jsx)("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),(0,nt.jsxs)("div",{className:"flex items-center space-x-4 p-1",children:[r!=null&&r.avatar?(0,nt.jsx)("img",{src:r.avatar,alt:r.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-0.5 text-white"}):(0,nt.jsx)(ji.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),(0,nt.jsxs)("div",{className:"flex-1 space-y-0",children:[(0,nt.jsx)("div",{className:"truncate font-medium leading-tight text-black",children:w}),(r==null?void 0:r.email)&&(0,nt.jsx)("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:r.email})]})]})]}),((u==null?void 0:u.type)===Et.TAKE_OVER_REJECTED||(u==null?void 0:u.type)===Et.FORCE_TAKE_OVER_REQUEST)&&(0,nt.jsx)("section",{className:"space-y-2",children:(0,nt.jsxs)("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[(0,nt.jsxs)("div",{className:"flex items-start gap-x-2",children:[(0,nt.jsx)(ji.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),(0,nt.jsxs)("div",{className:"font-light leading-tight",children:[(0,nt.jsx)("span",{className:"font-medium",children:(r==null?void 0:r.name)||"The current editor"}),(u==null?void 0:u.type)===Et.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),(0,nt.jsx)(E,{size:"icon",variant:"ghost",onClick:k,className:"flex-shrink-0",children:(0,nt.jsx)(ji.X,{className:"h-4 w-4"})})]})})]}),(0,nt.jsx)(kc,{className:"flex flex-col gap-3 border-t pt-3",children:(0,nt.jsxs)("section",{className:"space-y-2",children:[(0,nt.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:i("Take Over Options")}),(0,nt.jsxs)("div",{className:"rounded-md border bg-muted/40 p-3",children:[(0,nt.jsxs)("div",{className:"mb-2",children:[(0,nt.jsx)("p",{className:"text-sm font-medium",children:i("Take Over Request:")}),(0,nt.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:i("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:w})})]}),(0,nt.jsxs)(E,{disabled:N,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[(0,nt.jsx)(ji.Edit,{className:"h-4 w-4"}),N?"Take over request sent":"Send Take Over Request"]}),N&&(0,nt.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:i("Request sent. If no response, try again or use force take over.")})]}),c&&(0,nt.jsx)(vm,{type:"single",collapsible:!0,className:"w-full",children:(0,nt.jsxs)(Xd,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[(0,nt.jsx)(eg,{className:"px-3 py-2 hover:no-underline",children:(0,nt.jsx)("div",{className:"flex items-center gap-2 text-left",children:(0,nt.jsxs)("div",{children:[(0,nt.jsxs)("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[(0,nt.jsx)(ji.ShieldAlert,{className:"h-4 w-4 text-destructive"}),i("Force Take Over")]}),(0,nt.jsx)("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:i("Immediately take control (use with caution)")})]})})}),(0,nt.jsx)(Zd,{className:"px-3 pb-3",children:(0,nt.jsxs)("div",{className:"space-y-3",children:[(0,nt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[(0,nt.jsx)("input",{type:"checkbox",id:"force-takeover",checked:g,onChange:C=>h(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),(0,nt.jsx)("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:i("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:w})})]}),(0,nt.jsxs)(E,{disabled:!g||I,variant:"destructive",onClick:y,className:"w-full gap-2",children:[(0,nt.jsx)(ji.ShieldAlert,{className:"h-4 w-4"}),i(I?"Take over page...":"Force Take Over")]}),I&&(0,nt.jsx)("p",{className:"text-xs text-muted-foreground",children:i("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})},pse=dse});var x7={};et(x7,{default:()=>use});var cb,b7,db,li,mse,use,v7=x(()=>{"use strict";J();lb();cb=require("lucide-react"),b7=require("react-i18next");Oo();ps();Vd();db=require("react"),li=require("react/jsx-runtime"),mse=()=>{let e=$d(),t=D1(),{t:o}=(0,b7.useTranslation)(),[r,n]=(0,db.useState)(!1),a=(0,db.useRef)(null);return(0,db.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),(0,li.jsx)(Pn,{children:(0,li.jsxs)(bc,{className:"mx-auto h-fit w-full max-w-md",children:[(0,li.jsx)(xc,{className:"space-y-1",children:(0,li.jsxs)(vc,{className:"flex items-center gap-2 text-xl font-medium",children:[(0,li.jsx)(cb.TableIcon,{className:"h-6 w-6 text-green-500"}),(0,li.jsx)("span",{children:o("Active in Another Tab")})]})}),(0,li.jsx)(Cc,{className:"space-y-4",children:(0,li.jsx)("p",{className:"text-sm text-muted-foreground",children:o("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),(0,li.jsx)(kc,{className:"flex justify-end gap-2",children:(0,li.jsxs)(E,{variant:"default",disabled:r,onClick:()=>{n(!0),e(Et.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{t(),n(!1)},5e3)},className:"gap-2",children:[r?(0,li.jsx)(cb.Loader2,{className:"h-4 w-4 animate-spin"}):(0,li.jsx)(cb.Edit,{className:"h-4 w-4"}),o("Continue Editing Here")]})})]})})},use=mse});var k7={};et(k7,{default:()=>fse});var MT,C7,Bl,gse,fse,S7=x(()=>{"use strict";J();lb();MT=require("lucide-react"),C7=require("react-i18next");Oo();ps();Bl=require("react/jsx-runtime"),gse=()=>{let{setPageLockMeta:e}=Wc(),{t}=(0,C7.useTranslation)(),o=async()=>{e({})};return(0,Bl.jsx)(Pn,{children:(0,Bl.jsxs)(bc,{className:"mx-auto h-fit w-full max-w-md",children:[(0,Bl.jsx)(xc,{className:"space-y-1",children:(0,Bl.jsxs)(vc,{className:"flex items-center gap-2 text-xl",children:[(0,Bl.jsx)(MT.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),(0,Bl.jsx)(Cc,{className:"space-y-4",children:(0,Bl.jsx)("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),(0,Bl.jsx)(kc,{className:"flex gap-2",children:(0,Bl.jsxs)(E,{variant:"default",onClick:o,className:"flex-1 gap-2",children:[(0,Bl.jsx)(MT.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})},fse=gse});var P7={};et(P7,{default:()=>Cse});var w7,Sc,FT,hse,yse,bse,xse,OT,vse,Cse,T7=x(()=>{"use strict";w7=require("@tanstack/react-query"),Sc=require("react");Oo();St();ps();Vd();FT=require("react/jsx-runtime"),hse=(0,Sc.lazy)(()=>Promise.resolve().then(()=>(g7(),u7))),yse=(0,Sc.lazy)(()=>Promise.resolve().then(()=>(y7(),h7))),bse=(0,Sc.lazy)(()=>Promise.resolve().then(()=>(v7(),x7))),xse=(0,Sc.lazy)(()=>Promise.resolve().then(()=>(S7(),k7))),OT=e=>(0,FT.jsx)(Sc.Suspense,{children:(0,FT.jsx)(e,{})}),vse=({isFetchingPageData:e})=>{_1();let{pageStatus:t}=rn(),{pageLockMeta:o}=Wc(),r=(0,w7.useQueryClient)(),n=(0,Sc.useRef)(t);if((0,Sc.useEffect)(()=>{t===go.EDITING&&n.current!==go.TAKE_OVER_REQUESTED&&r.invalidateQueries({queryKey:[$.GET_DRAFT_PAGE]}),n.current=t},[t,r]),e)return null;switch(t){case go.EDITING:case go.CHECKING:case go.FORCE_TAKE_OVER:return o.type===Et.CONTINUE_EDITING_IN_THIS_CLIENT?OT(xse):null;case go.LOCKED:return OT(yse);case go.TAKE_OVER_REQUESTED:return OT(hse);case go.ACTIVE_IN_ANOTHER_TAB:return OT(bse);case go.CONNECTION_LOST:return(0,FT.jsx)(Pn,{children:null});default:return null}},Cse=vse});var I7={};et(I7,{LicenseOverlay:()=>A7,default:()=>Tse});function Sse(e){if(!e)return null;let t=Date.parse(e)-Date.now();return Number.isNaN(t)?null:Math.max(0,Math.floor(t/(1440*60*1e3)))}function wse(e){try{return new URL(e).origin}catch(t){return null}}function Pse(e){if(!wse(N7))return null;try{let t=new URL(N7),o=typeof document!="undefined"&&document.documentElement.classList.contains("dark")?"dark":"light";return t.searchParams.set("state",e.state),e.status&&t.searchParams.set("status",e.status),e.trialEndsAt&&t.searchParams.set("trialEndsAt",e.trialEndsAt),e.updatesUntil&&t.searchParams.set("updatesUntil",e.updatesUntil),t.searchParams.set("version",e.version),t.searchParams.set("licenseUrl",kse),t.searchParams.set("theme",o),t.toString()}catch(t){return null}}var E7,pb,Vp,Kn,kse,N7,A7,Tse,B7=x(()=>{"use strict";E7=require("jotai"),pb=require("lucide-react"),Vp=require("react");N0();J();Kn=require("react/jsx-runtime"),kse="https://chaibuilder.com/redirect/pro-license",N7="https://chaibuilder.com/pro/license-overlay";A7=()=>{let e=(0,E7.useAtomValue)(VC),t=(0,Vp.useRef)(null),[o,r]=(0,Vp.useState)(!1),[n,a]=(0,Vp.useState)(!1),s=(e==null?void 0:e.state)==="expired"||(e==null?void 0:e.state)==="version_blocked"||(e==null?void 0:e.state)==="limit_reached"||(e==null?void 0:e.state)==="invalid",i=s||n,l=(0,Vp.useMemo)(()=>e&&i?Pse(e):null,[e,i]);if((0,Vp.useEffect)(()=>{var d;i&&((d=t.current)==null||d.focus())},[i,l]),!e)return null;if(i&&l){let d=e.state==="version_blocked"?"Update not covered by your license":e.state==="limit_reached"?"Domain limit reached":e.state==="invalid"?"Invalid license key":"ChaiBuilder Pro license required";return(0,Kn.jsx)("div",{ref:t,role:"dialog","aria-modal":"true","aria-label":d,tabIndex:-1,onClick:s?void 0:p=>p.target===p.currentTarget&&a(!1),onKeyDown:s?void 0:p=>p.key==="Escape"&&a(!1),className:"fixed inset-0 z-[999999] flex items-center justify-center bg-background/80 p-6 outline-none backdrop-blur-sm",children:(0,Kn.jsxs)("div",{className:"relative h-[80%] w-[70%]",children:[!s&&(0,Kn.jsx)("button",{type:"button","aria-label":"Close",onClick:()=>a(!1),className:"absolute -right-3 -top-3 z-10 flex h-7 w-7 items-center justify-center rounded-full border border-border bg-surface text-foreground/70 shadow-md hover:text-foreground",children:(0,Kn.jsx)(pb.X,{className:"h-4 w-4"})}),(0,Kn.jsx)("iframe",{title:"ChaiBuilder Pro license",src:l,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-forms",className:"h-full w-full rounded-lg border border-border bg-surface shadow-xl"})]})})}let c=Sse(e.trialEndsAt);if(e.status==="trial"&&c!==null){let d=c<=3,p=c===0?"Ends today":`${c} ${c===1?"day":"days"} left`,u=(0,Kn.jsx)("span",{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${d?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":"true"});return o?(0,Kn.jsxs)("div",{className:"fixed bottom-4 right-4 z-[999998] flex items-center gap-2 rounded-full border border-border bg-surface px-3 py-1.5 text-xs shadow-lg",children:[u,(0,Kn.jsx)("span",{className:"text-foreground/80",children:p}),(0,Kn.jsx)("button",{type:"button",onClick:()=>a(!0),className:"font-medium text-primary underline underline-offset-2",children:"Buy"}),(0,Kn.jsx)("button",{type:"button","aria-label":"Expand trial status",onClick:()=>r(!1),className:"text-foreground/50 hover:text-foreground",children:(0,Kn.jsx)(pb.ChevronUp,{className:"h-3.5 w-3.5"})})]}):(0,Kn.jsxs)("div",{className:"fixed bottom-4 right-4 z-[999998] flex w-64 flex-col gap-2 rounded-lg border border-border bg-surface p-3 text-sm shadow-lg",children:[(0,Kn.jsxs)("div",{className:"flex items-center gap-2",children:[u,(0,Kn.jsx)("span",{className:"font-medium text-foreground",children:"ChaiBuilder Pro trial"}),(0,Kn.jsx)("button",{type:"button","aria-label":"Minimize trial status",onClick:()=>r(!0),className:"ml-auto text-foreground/50 hover:text-foreground",children:(0,Kn.jsx)(pb.Minus,{className:"h-3.5 w-3.5"})})]}),(0,Kn.jsx)("span",{className:"text-foreground/70",children:p}),(0,Kn.jsx)(E,{size:"sm",className:"w-full",onClick:()=>a(!0),children:"Buy License Key"})]})}return null},Tse=A7});var L7={};et(L7,{default:()=>Ese});var R7,D7,_7,ci,Nse,Ese,M7=x(()=>{"use strict";R7=require("lodash-es"),D7=require("lucide-react"),_7=require("react-i18next");Tt();zs();jP();cs();J();lb();Oo();ci=require("react/jsx-runtime"),Nse=()=>{let{t:e}=(0,_7.useTranslation)(),[t,o]=Go(),r=t.get("lang"),n=Ey(r),{setSelectedLang:a}=fe(),s=()=>{let l=new URLSearchParams(window.location.search);l.delete("lang");let c=l.toString(),d=`${window.location.pathname}${c?`?${c}`:""}`;window.history.pushState({},"",d),o(l),a(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(n)return null;let i=(0,R7.get)(Jt,r);return(0,ci.jsx)(Pn,{children:(0,ci.jsxs)(bc,{className:"mx-auto w-full max-w-md",children:[(0,ci.jsx)(xc,{className:"space-y-1",children:(0,ci.jsxs)(vc,{className:"flex items-center gap-2 text-2xl",children:[(0,ci.jsx)(D7.LockIcon,{className:"h-6 w-6 text-yellow-500"}),e("Page missing for")," \xA0",(0,ci.jsx)("code",{children:i}),"\xA0",e("language"),"."]})}),(0,ci.jsx)(Cc,{className:"grid gap-4",children:(0,ci.jsxs)("div",{children:[e("Page is not available in the")," \xA0",(0,ci.jsx)("code",{children:i}),"\xA0",e("language. Either create the page in the")," \xA0",(0,ci.jsx)("code",{children:i}),"\xA0",e("language or switch to the base language.")]})}),(0,ci.jsx)(kc,{children:(0,ci.jsx)(E,{onClick:s,className:"w-full",variant:"destructive",children:e("Switch to default language")})})]})})},Ese=Nse});var O7={};et(O7,{default:()=>Bse});var HT,aR,Ase,Ise,Bse,F7=x(()=>{"use strict";HT=require("react");jP();cs();aR=require("react/jsx-runtime"),Ase=(0,HT.lazy)(()=>Promise.resolve().then(()=>(M7(),L7))),Ise=()=>{let[e]=Go(),t=e.get("lang");return Ey(t)?null:(0,aR.jsx)(HT.Suspense,{children:(0,aR.jsx)(Ase,{})})},Bse=Ise});var oC,H7,tC,U7,G7,$7,sR=x(()=>{"use strict";oC=require("@tanstack/react-query"),H7=require("jotai"),tC=require("sonner");bw();St();Kt();rt();U7=e=>{let t=le(),o=he();return(0,oC.useMutation)({mutationFn:async r=>o(t,{action:$.UPSERT_LIBRARY_ITEM,data:r}),onSuccess:r=>{e?e(r):tC.toast.success("Block saved successfully")},onError:r=>{console.error("Error saving block:",r),tC.toast.error("Failed to save block",{description:r instanceof Error?r.message:"Unknown error"})}})},G7=e=>{let t=le(),o=he();return(0,oC.useQuery)({staleTime:"static",queryKey:[$.GET_LIBRARY_ITEM,e],enabled:!!e,queryFn:async()=>{if(!e)return null;try{return await o(t,{action:$.GET_LIBRARY_ITEM,data:{id:e}})}catch(r){throw console.error(r),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},$7=e=>{let t=le(),o=he(),r=(0,H7.useSetAtom)(iA);return(0,oC.useMutation)({mutationFn:async n=>o(t,{action:$.DELETE_LIBRARY_ITEM,data:{id:n}}),onSuccess:()=>{r(n=>{let a={...n};return Object.keys(a).forEach(s=>{a[s]={loading:"idle",blocks:[],error:!1}}),a}),e?e():tC.toast.success("Block deleted successfully")},onError:n=>{console.error("Error deleting block:",n),tC.toast.error("Failed to delete block",{description:n instanceof Error?n.message:"Unknown error"})}})}});var iR,lR,V7,ka,Rse,z7,W7=x(()=>{"use strict";iR=require("lucide-react"),lR=require("react"),V7=require("sonner");Ln();sR();J();Rs();ka=require("react/jsx-runtime"),Rse=({blockId:e,libBlockId:t,isOpen:o,onClose:r,blockName:n,trigger:a})=>{let[s,i]=(0,lR.useState)(!1),l=Fc(),c=$7(()=>{l([e],{_libBlockId:void 0}),V7.toast.success("Block deleted successfully"),i(!1),r()});return(0,ka.jsxs)(en,{open:o,onOpenChange:u=>!u&&r(),children:[(0,ka.jsx)($r,{asChild:!0,children:a||(0,ka.jsxs)(E,{type:"button",variant:"destructive",size:"sm",onClick:u=>u.preventDefault(),disabled:s,children:[(0,ka.jsx)(iR.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})}),(0,ka.jsx)(Vr,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:(0,ka.jsxs)("div",{className:"space-y-3",children:[(0,ka.jsx)("h4",{className:"font-medium",children:"Delete Block"}),(0,ka.jsxs)("p",{className:"text-sm",children:["Are you sure you want to delete the block",(0,ka.jsxs)("span",{className:"font-medium",children:[' "',n,'"']}),"?"]}),(0,ka.jsx)("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),(0,ka.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,ka.jsx)(E,{type:"button",variant:"outline",size:"sm",onClick:r,disabled:s,children:"Cancel"}),(0,ka.jsx)(E,{type:"button",variant:"destructive",size:"sm",loading:s,onClick:()=>{i(!0),c.mutate(t)},children:"Delete"})]})]})})]})},z7=({blockId:e,libBlockId:t,blockName:o,size:r="sm",className:n="",close:a})=>{let[s,i]=(0,lR.useState)(!1);return(0,ka.jsx)(Rse,{blockId:e,libBlockId:t,isOpen:s,onClose:()=>{i(!1),a()},blockName:o,trigger:(0,ka.jsxs)(E,{type:"button",variant:"destructive",size:r,className:n,onClick:()=>i(!0),children:[(0,ka.jsx)(iR.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})}});var mb,cR,j7,q7=x(()=>{"use strict";mb=require("@tanstack/react-query"),cR=require("sonner");Kt();rt();j7=()=>{let e=le(),t=he(),o=(0,mb.useQueryClient)(),{data:r=[],isLoading:n,error:a}=(0,mb.useQuery)({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await t(e,{action:"GET_LIBRARY_GROUPS"})||[]}catch(l){return console.error("Error fetching library groups:",l),[]}}}),{mutateAsync:s,isPending:i}=(0,mb.useMutation)({mutationFn:async l=>{if(!l.trim())throw new Error("Group name is required");return t(e,{action:"CREATE_BLOCK_GROUP",data:{name:l}})},onSuccess:()=>{o.invalidateQueries({queryKey:["library-groups"]}),cR.toast.success("Group created successfully")},onError:l=>{console.error("Error creating group:",l),cR.toast.error("Failed to create group",{description:l instanceof Error?l.message:"Unknown error"})}});return{groups:r,isLoading:n,error:a,createGroup:s,isCreating:i}}});var K7,wc,Yn,Y7,J7=x(()=>{"use strict";K7=require("lucide-react"),wc=require("react");q7();J();fo();Gs();Yn=require("react/jsx-runtime"),Y7=({value:e,onChange:t})=>{let[o,r]=(0,wc.useState)(!1),[n,a]=(0,wc.useState)(""),s=(0,wc.useRef)(null),{groups:i}=j7(),[l,c]=(0,wc.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"}]),d=(0,wc.useMemo)(()=>[...i,...l.filter(m=>!i.some(g=>g.id===m.id))],[i,l]),p=()=>{let m=n.trim();if(!m)return;let g={id:m,name:m};c(h=>[...h,g]),t(g.id),a(""),r(!1)};(0,wc.useEffect)(()=>{o&&s.current&&s.current.focus()},[o]);let u=m=>{m.key==="Enter"&&(m.preventDefault(),p())};return(0,wc.useEffect)(()=>{e&&!d.some(m=>m.id===e)&&t("")},[e,d,t]),o?(0,Yn.jsxs)("div",{className:"space-y-2",children:[(0,Yn.jsx)(Ce,{ref:s,placeholder:"Enter new group name",value:n,onChange:m=>a(m.target.value),onKeyDown:u}),(0,Yn.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,Yn.jsx)(E,{variant:"outline",size:"sm",onClick:()=>r(!1),children:"Cancel"}),(0,Yn.jsx)(E,{size:"sm",onClick:p,children:"Create"})]})]}):(0,Yn.jsxs)("div",{className:"flex gap-2",children:[(0,Yn.jsxs)(So,{value:e,onValueChange:t,children:[(0,Yn.jsx)(ho,{className:"w-full",children:(0,Yn.jsx)(Do,{placeholder:"Select a group"})}),(0,Yn.jsxs)(yo,{children:[i.length>0&&(0,Yn.jsxs)(ed,{children:[(0,Yn.jsx)(ql,{children:"Library Groups"}),i.map(m=>(0,Yn.jsx)(gt,{value:m.id,children:m.name},`lib-${m.id}`))]}),l.length>0&&(0,Yn.jsxs)(ed,{children:[(0,Yn.jsx)(ql,{children:"Predefined Groups"}),l.filter(m=>!i.some(g=>g.id===m.id)).map(m=>(0,Yn.jsx)(gt,{value:m.id,children:m.name},`local-${m.id}`))]})]})]}),(0,Yn.jsx)(E,{type:"button",size:"icon",variant:"outline",onClick:()=>r(!0),children:(0,Yn.jsx)(K7.Plus,{className:"h-4 w-4"})})]})}});var UT,ub,Q7,di,X7,Z7=x(()=>{"use strict";UT=require("lucide-react"),ub=require("react"),Q7=require("sonner");Us();$v();J();fo();di=require("react/jsx-runtime"),X7=({value:e,onChange:t})=>{let[o,r]=(0,ub.useState)(!1),n=(0,ub.useRef)(null),a=(0,ub.useCallback)(async l=>{var d;let c=(d=l.target.files)==null?void 0:d[0];if(c)try{r(!0);let p=c;c.type.startsWith("image/")&&(p=await Uy(c));let u=new FileReader;u.onloadend=()=>{t(u.result),r(!1)},u.readAsDataURL(p)}catch(p){console.error("Error reading file:",p),r(!1),Q7.toast.error("Failed to process image",{description:p instanceof Error?p.message:"Unknown error"})}},[t]);return(0,di.jsxs)("div",{className:"space-y-2",children:[(0,di.jsxs)("div",{className:"flex items-center gap-2",children:[(0,di.jsx)(Ce,{type:"file",ref:n,onChange:a,accept:"image/*",className:"hidden"}),(0,di.jsx)(E,{type:"button",variant:"outline",onClick:()=>{var l;(l=n.current)==null||l.click()},disabled:o,className:"w-full",children:o?(0,di.jsxs)("span",{className:"flex items-center gap-2",children:[(0,di.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):(0,di.jsxs)("span",{className:"flex items-center gap-2 text-sm text-foreground/80",children:[(0,di.jsx)(UT.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),e&&(0,di.jsx)(E,{type:"button",variant:"outline",size:"icon",onClick:()=>{t(""),n.current&&(n.current.value="")},children:(0,di.jsx)(UT.X,{className:"h-4 w-4"})})]}),e&&(0,di.jsx)("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:(0,di.jsx)(qo,{src:e,alt:"Preview",className:"h-full w-full object-contain"})})]})}});var tY={};et(tY,{default:()=>_se});var gb,eY,es,dR,mo,Dse,_se,oY=x(()=>{"use strict";gb=require("lodash-es"),eY=require("lucide-react"),es=require("react"),dR=require("sonner");bw();Yd();mn();Ln();W7();J7();Z7();sR();J();fo();No();tn();mo=require("react/jsx-runtime"),Dse=e=>{let{blocks:t,close:o,blockId:r}=e,{getPartialBlocks:n}=Dc(),a=t.find(O=>O._id===r),s=a==null?void 0:a._libBlockId,i=!!s,l=(0,es.useMemo)(()=>t.some(O=>O._type==="PartialBlock"||O._type==="GlobalBlock"),[t]),c=(0,es.useMemo)(()=>{let O=[];for(let U of t)if(U._type==="PartialBlock"||U._type==="GlobalBlock"){let j=n(U.partialBlockId);U._parent&&(j==null?void 0:j.length)>0&&(j=j.map(ce=>((0,gb.isEmpty)(ce._parent)&&(0,gb.set)(ce,"_parent",U._parent),ce))),O=[...O,...j]}else O.push(U);return O},[t,n]),[d,p]=(0,es.useState)(""),[u,m]=(0,es.useState)(""),[g,h]=(0,es.useState)(""),[f,b]=(0,es.useState)(""),[y,k]=(0,es.useState)({}),[w,N]=(0,es.useState)(!1),[I,C]=(0,es.useState)(i),[P,B]=(0,es.useState)(!1),{hasPermission:T}=kt(),v=T(xe["library:delete"]),S=Fc(),A=()=>{S([r],{_libBlockId:void 0}),dR.toast.success("Block delinked from library"),o()},{data:D,isLoading:R,isError:H}=G7(s);(0,es.useEffect)(()=>{H&&i&&(B(!0),C(!1))},[H,i]),(0,es.useEffect)(()=>{D&&!R&&(p(D.name||""),m(D.group||""),h(D.description||""),b(D.preview||""),C(!1))},[D,R]),(0,es.useEffect)(()=>{let O=d.trim().length>=2,U=u.trim()!=="";N(O&&U)},[d,u]);let M=()=>{let O={};return d.trim()?d.length<2&&(O.name="Name must be at least 2 characters"):O.name="Name is required",u||(O.group="Group is required"),k(O),Object.keys(O).length===0},{resetLibrary:L}=yw({id:""}),z=U7(O=>{i||S([r],{_libBlockId:O.id}),dR.toast.success(`Block ${i?"updated":"saved"} successfully`),L(O.library),o()}),_=async O=>{if(O.preventDefault(),!M())return;let U=c.map(j=>((0,gb.has)(j,"_libBlockId")&&delete j._libBlockId,j));z.mutate({name:d.trim(),group:u,blocks:U,description:g.trim(),...f&&f.startsWith("data:")?{previewImage:f}:{},...i?{id:s}:{}})},F=z.isPending;return I||R?(0,mo.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,mo.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):P?(0,mo.jsxs)("div",{className:"space-y-4",children:[(0,mo.jsx)("div",{className:"text-sm font-medium text-destructive",children:"Block Not Found"}),(0,mo.jsx)("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),(0,mo.jsxs)("div",{className:"flex justify-end gap-2 pt-4",children:[(0,mo.jsx)(E,{type:"button",size:"sm",variant:"outline",onClick:o,children:"Cancel"}),(0,mo.jsx)(E,{size:"sm",onClick:A,variant:"destructive",children:"Delink Block"})]})]}):(0,mo.jsxs)("div",{children:[l&&(0,mo.jsxs)("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[(0,mo.jsx)(eY.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),(0,mo.jsxs)("div",{children:[(0,mo.jsx)("p",{className:"font-medium",children:"Partial Blocks Detected"}),(0,mo.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"})]})]}),(0,mo.jsxs)("form",{onSubmit:_,className:"space-y-4",children:[(0,mo.jsxs)("div",{className:"space-y-1",children:[(0,mo.jsx)(Q,{htmlFor:"name",className:y.name?"text-destructive":"",children:"Name"}),(0,mo.jsx)(Ce,{id:"name",placeholder:"Enter block name",value:d,onChange:O=>p(O.target.value),className:y.name?"border-destructive":""}),y.name&&(0,mo.jsx)("p",{className:"text-xs text-destructive",children:y.name})]}),(0,mo.jsxs)("div",{className:"space-y-1",children:[(0,mo.jsx)(Q,{htmlFor:"group",className:y.group?"text-destructive":"",children:"Group"}),(0,mo.jsx)(Y7,{value:u,onChange:m}),y.group&&(0,mo.jsx)("p",{className:"text-xs text-destructive",children:y.group})]}),(0,mo.jsxs)("div",{className:"space-y-1",children:[(0,mo.jsx)(Q,{htmlFor:"description",children:"Description (optional)"}),(0,mo.jsx)(Ce,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:g,onChange:O=>h(O.target.value)})]}),(0,mo.jsxs)("div",{className:"space-y-1",children:[(0,mo.jsx)(Q,{htmlFor:"previewImage",children:"Preview Image (optional)"}),(0,mo.jsx)(X7,{value:f,onChange:b})]}),(0,mo.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[i&&v&&(0,mo.jsx)(z7,{blockId:r,libBlockId:s,blockName:d,className:"mr-auto",close:o}),(0,mo.jsx)(E,{type:"button",size:"sm",variant:"outline",onClick:o,disabled:F,children:"Cancel"}),(0,mo.jsx)(E,{loading:F,size:"sm",type:"submit",disabled:!w,children:i?"Update Block":"Save Block"})]})]})]})},_se=Dse});var sY={};et(sY,{default:()=>Fse});var rY,nY,Bu,aY,Is,iY,Lse,Mse,Ose,Fse,lY=x(()=>{"use strict";rY=require("jotai"),nY=require("lodash-es"),Bu=require("lucide-react"),aY=require("react");oR();ea();J();Is=require("react/jsx-runtime"),iY=require("react"),Lse=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:(0,Is.jsx)(Bu.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:(0,Is.jsx)(Bu.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:(0,Is.jsx)(Bu.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:(0,Is.jsx)(Bu.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],Mse=({currentWidth:e,width:t,icon:o,setIframeWidth:r})=>(0,Is.jsx)(E,{className:"px-3 py-3",onClick:()=>r(t),variant:t===e?"default":"ghost",children:o}),Ose=()=>{let[e,t]=(0,aY.useState)(1200),o=s=>t(s),[r,n]=(0,rY.useAtom)(DT);if(!r)return null;let a=()=>{n("")};return(0,Is.jsxs)("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[(0,Is.jsxs)("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[(0,Is.jsx)("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:(0,nY.map)(Lse,s=>(0,iY.createElement)(Mse,{...s,setIframeWidth:o,key:s.title,currentWidth:e}))}),"\xA0",(0,Is.jsx)(Ye,{content:"Exit Preview",delayDuration:0,children:(0,Is.jsx)(E,{variant:"destructive",size:"sm",onClick:a,children:(0,Is.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Is.jsx)("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),(0,Is.jsx)("iframe",{style:{width:`${e}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:r})]})},Fse=Ose});var xo,cY,Hse,pR,Use,dY,pY,mY=x(()=>{"use strict";xo=require("lodash-es"),cY=(e,t)=>!e||!Array.isArray(e)?[]:(0,xo.isEmpty)(t)?e:(0,xo.compact)((0,xo.filter)(e,o=>{let r=(0,xo.toLower)(t);return(0,xo.includes)((0,xo.toLower)((o==null?void 0:o.name)||""),r)||(0,xo.includes)((0,xo.toLower)((o==null?void 0:o.slug)||""),r)})),Hse=(e,t)=>{let o=new Set,r=(0,xo.keyBy)(e,"id");return t.forEach(n=>{let a=n;for(;a.parent&&r[a.parent];)o.add(a.parent),a=r[a.parent]}),Array.from(o).map(n=>r[n])},pR=(e,t,o)=>(0,xo.isEmpty)(t)?e:e.map(r=>{if(!o(r.pageType))return{...r,shouldExpandOnSearch:!0,children:r.children?pR(r.children,t,o):[]};let n=r.children&&r.children.some(a=>(0,xo.includes)((0,xo.toLower)(a.name||""),(0,xo.toLower)(t))||(0,xo.includes)((0,xo.toLower)(a.slug||""),(0,xo.toLower)(t)));return{...r,shouldExpandOnSearch:n,children:r.children?pR(r.children,t,o):[]}}),Use=e=>{if(!e||!e.length)return[];let t={};e.forEach(r=>{t[r.id]={...r,children:[]}});let o=[];return Object.values(t).forEach(r=>{r.parent&&t[r.parent]?t[r.parent].children.push(r):o.push(r)}),o},dY=e=>!e||!e.length?[]:[...e].sort((o,r)=>(o.name||"").localeCompare(r.name||"")).map(o=>({...o,children:o.children?dY(o.children):[]})),pY=(e,t,o,r)=>{if(!e||!e.length)return[];let n=e;if(o!=="all"&&(n=(0,xo.compact)((0,xo.filter)(e,{pageType:o}))),(0,xo.isEmpty)(t))n=cY(n,t);else{let d=cY(n,t),p=Hse(e,d);n=(0,xo.uniqBy)([...d,...p],"id")}let a=dY(Use(n)),s=pR(a,t,r),i=(0,xo.filter)(s,d=>r(d.pageType)).sort((d,p)=>(d.name||"").localeCompare(p.name||"")),l=(0,xo.filter)(s,d=>!r(d.pageType)),c=[];if(o==="all"){let d=(0,xo.keyBy)(l,"pageType");Object.keys(d).length>1?c=Object.values((0,xo.mapValues)(d,(p,u)=>({...p,id:u,name:(0,xo.startCase)(u),isPartialGroup:!0,children:s.filter(m=>m.pageType===u)}))).sort((p,u)=>(p.name||"").localeCompare(u.name||"")):c=l.sort((p,u)=>(p.name||"").localeCompare(u.name||""))}else c=l.sort((d,p)=>(d.name||"").localeCompare(p.name||""));return[...i,...c]}});var uY,gY,fY=x(()=>{"use strict";uY=require("jotai"),gY=(0,uY.atom)({pageId:null,position:{x:0,y:0}})});var hY,yY,GT,Dd,bY,xY=x(()=>{"use strict";hY=require("jotai"),yY=require("lucide-react"),GT=require("react");J();fY();Dd=require("react/jsx-runtime"),bY=({pageId:e,children:t})=>{let[o,r]=(0,hY.useAtom)(gY),n=(0,GT.useRef)(null),a=o.pageId===e;(0,GT.useEffect)(()=>{let l=()=>r({pageId:null,position:{x:0,y:0}});if(a)return document.addEventListener("click",l),()=>document.removeEventListener("click",l)},[a,r]);let s=l=>{l.preventDefault(),l.stopPropagation(),r({pageId:e,position:{x:l.clientX,y:l.clientY}})},i=()=>{let l=`${window.location.pathname}?page=${e}`;window.open(l,"_blank"),r({pageId:null,position:{x:0,y:0}})};return(0,Dd.jsxs)(Dd.Fragment,{children:[(0,Dd.jsx)("span",{onContextMenu:s,children:t}),a&&(0,Dd.jsx)("div",{ref:n,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:o.position.y,left:o.position.x},children:(0,Dd.jsx)("div",{className:"",children:(0,Dd.jsxs)(E,{variant:"ghost",onClick:i,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[(0,Dd.jsx)(yY.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})}});var _d,ts,$T,eo,Gse,$se,Vse,zse,vY,CY=x(()=>{"use strict";_d=require("lodash-es"),ts=require("lucide-react"),$T=require("react");xI();ps();Vd();zs();Hl();Hp();Nv();ea();J();xY();eo=require("react/jsx-runtime"),Gse=({page:e})=>{var r;let{isExpanded:t,toggleExpanded:o}=Fp(e==null?void 0:e.id);return(0,eo.jsx)(E,{size:"icon-sm",variant:"ghost",className:`h-6 w-6 hover:bg-secondary ${(r=e==null?void 0:e.children)!=null&&r.length?"":"opacity-0"}`,onClick:n=>{n.stopPropagation(),o()},children:(0,eo.jsx)(ts.ChevronRight,{className:`duration-200 ${t?"rotate-90":""}`})})},$se=({page:e,pageType:t})=>(0,eo.jsx)("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?(0,eo.jsx)(ts.StarsIcon,{size:12,className:"text-yellow-400"}):t!=null&&t.icon?(0,eo.jsx)("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-muted-foreground",dangerouslySetInnerHTML:{__html:t.icon}}):t!=null&&t.hasSlug?(0,eo.jsx)(ts.File,{size:12,className:"stroke-[1] text-muted-foreground"}):(0,eo.jsx)(ts.Hash,{size:12,className:"stroke-[1] text-muted-foreground"})}),Vse=({isOnline:e})=>(0,eo.jsx)("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-500":"bg-muted-foreground/30"}`}),zse=({page:e,pageTypes:t,currentPage:o,onClickAction:r,languagePages:n,selectedLanguage:a,showUntranslatedPages:s})=>{let i=tl(),{pageToUser:l}=Df(),c=(0,_d.get)(l,[e==null?void 0:e.id,"userId"]),{data:d}=xa(c),p=d&&i!==c?d==null?void 0:d.name:null,{toggleExpanded:u}=Fp(e==null?void 0:e.id),m=Mn(),g=o===e.id,h=(0,$T.useMemo)(()=>(0,_d.find)(t,{key:e.pageType}),[t,e.pageType]),f=(0,_d.get)(n,e==null?void 0:e.id);f=(0,_d.get)(f,"lang")===a?f:null;let b=a===m||!!f,y=(f==null?void 0:f.name)||(e==null?void 0:e.name)||"No name",k=(f==null?void 0:f.slug)||(e==null?void 0:e.slug)||"",w=k+(e!=null&&e.dynamic?`/${h==null?void 0:h.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!s){let C=k.split("/").pop();k=k.endsWith(C)&&e.dynamic?"":`/${C}`}let N=(0,$T.useMemo)(()=>{let C="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",P=`${g?"border-primary/30 bg-primary/5":"border-transparent hover:border-border hover:bg-accent"}`;return b?`${C} ${P} ${p?"opacity-60":""}`:`${C} bg-muted/30 opacity-50 group-hover:border-border border-transparent group-hover:bg-accent`},[b,g,p]),I=(0,$T.useMemo)(()=>{if(e.isPartialGroup)return!1;if(f){if(!f.online||(0,_d.isEmpty)(f.changes))return!1}else if(e&&(!e.online||(0,_d.isEmpty)(e.changes)))return!1;return!0},[f,e]);return(0,eo.jsxs)("div",{className:"group relative",children:[(0,eo.jsx)(bY,{pageId:e.id,children:(0,eo.jsxs)("div",{onClick:()=>e.isPartialGroup?u():b&&r("select",e==null?void 0:e.id),className:N,children:[((h==null?void 0:h.hasSlug)!==!1||e.isPartialGroup)&&(0,eo.jsx)(Gse,{page:e}),!e.isPartialGroup&&(0,eo.jsx)(Vse,{isOnline:f?f.online:e.online}),!e.isPartialGroup&&(0,eo.jsx)($se,{page:e,pageType:h}),(0,eo.jsx)(Ye,{content:y,side:"top",showTooltip:y.length>35,children:(0,eo.jsx)("span",{className:"max-w-[40%] truncate font-medium text-foreground",children:y})}),(k||e.dynamic)&&(0,eo.jsx)(Ye,{content:w,side:"top",showTooltip:!0,children:(0,eo.jsxs)("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,e.dynamic&&(h==null?void 0:h.dynamicSlug)&&(0,eo.jsxs)("span",{className:"text-xs text-muted-foreground",children:["/",h==null?void 0:h.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&(0,eo.jsx)(Ye,{content:"Has unpublished changes",side:"top",children:(0,eo.jsx)("span",{className:"text-warning",children:(0,eo.jsx)(ts.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&b&&!p?(0,eo.jsx)("div",{className:"duration absolute right-0.5 top-[3px]",children:(0,eo.jsx)(SP,{isLanguagePage:!!f,page:f||e,setDuplicatePage:C=>r("duplicate",C),setAddEditPage:C=>r("edit",f||C),setUnpublishPage:C=>r("unpublish",C),setDeletePage:C=>r("delete",f||C),children:(0,eo.jsx)("div",{className:"hover:bg-surface m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-border",children:(0,eo.jsx)(ts.MoreHorizontal,{className:"h-4 w-4 text-muted-foreground",onClick:C=>C.stopPropagation()})})})}):p?(0,eo.jsxs)("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-destructive",children:[(0,eo.jsx)(ts.Lock,{className:"h-3 w-3 fill-destructive/20 text-destructive"}),(0,eo.jsx)(Ye,{content:`${p} is editing this page`,children:(0,eo.jsx)("span",{className:"font-bold",children:p})})]}):null]})}),(0,eo.jsx)(eo.Fragment,{children:!b&&!e.isPartialGroup&&!p&&(0,eo.jsxs)("button",{onClick:C=>{C.stopPropagation(),r("addLanguagePage",{language:a,page:e})},className:"absolute right-0 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-primary px-2 py-0.5 text-xs text-primary-foreground opacity-0 duration-200 hover:bg-primary/90 group-hover:opacity-100",children:[(0,eo.jsx)(ts.Plus,{size:12,className:"stroke-[3]"})," ",(0,eo.jsxs)("span",{className:"text-[10px]",children:["Add ",(0,_d.get)(Jt,a)," Page"]})]})})]})},vY=zse});var kY,fb,SY,wY,PY=x(()=>{"use strict";kY=require("react/jsx-runtime");Nv();CY();fb=require("react/jsx-runtime"),SY=({pages:e,tier:t,pageTypes:o,currentPage:r,onClickAction:n,languagePages:a,selectedLanguage:s,showUntranslatedPages:i})=>{let{expandedPages:l}=Fp();return(0,fb.jsx)("div",{className:"space-y-px",style:{paddingLeft:`${t*10}px`},children:e.map(c=>(0,fb.jsxs)(kY.Fragment,{children:[(0,fb.jsx)(vY,{page:c,pageTypes:o,currentPage:r,onClickAction:n,languagePages:a,selectedLanguage:s,showUntranslatedPages:i}),c.children&&c.children.length>0&&(l==null?void 0:l.includes(c.id))&&(0,fb.jsx)(SY,{pages:c.children,tier:t+1,pageTypes:o,currentPage:r,onClickAction:n,languagePages:a,selectedLanguage:s,showUntranslatedPages:i})]},c.id))})},wY=SY});var AY={};et(AY,{default:()=>Zse});var TY,os,NY,vt,EY,uo,Wse,jse,qse,Kse,Yse,Jse,Qse,Xse,Zse,IY=x(()=>{"use strict";TY=require("jotai"),os=require("lodash-es"),NY=require("lucide-react"),vt=require("react"),EY=require("react-i18next");Tt();fv();Ul();An();Hl();Nv();cs();HI();mY();PY();uo=require("react/jsx-runtime"),Wse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(WI(),sz))),jse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(PI(),wI))),qse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(RP(),BP))),Kse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(II(),AI))),Yse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(_I(),DI))),Jse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(MI(),LI))),Qse=(0,vt.lazy)(()=>Promise.resolve().then(()=>(kv(),Cv))),Xse=({close:e})=>{let{t}=(0,EY.useTranslation)(),{languages:o,setSelectedLang:r}=fe(),{data:n}=Ht(),{data:a,isFetching:s}=on(),[i,l]=Go(),{updateForSelectedPage:c,expandPagesOnSearch:d}=Fp(null),p=Mn(),u=i.get("page"),[m,g]=(0,vt.useState)(""),[h,f]=(0,vt.useState)(null),[b,y]=(0,vt.useState)(null),[k,w]=(0,vt.useState)(null),[N,I]=(0,vt.useState)(null),[C,P]=(0,vt.useState)(()=>sessionStorage.getItem("pageTypeFilter")||"all"),[B,T]=(0,vt.useState)(()=>sessionStorage.getItem("pageCategoryFilter")||"pages"),[v,S]=(0,vt.useState)(null),[A,D]=(0,vt.useState)(null),[R,H]=(0,vt.useState)(p),[M,L]=(0,vt.useState)(!1),z=(0,TY.useSetAtom)(bd),_=M&&R!==p,{data:F,isFetching:O}=qC(R),U=(0,vt.useCallback)(W=>{T(W),sessionStorage.setItem("pageCategoryFilter",W),P("all"),W==="partials"&&H(p)},[p]),j=(0,vt.useMemo)(()=>!(0,os.isEmpty)(n)&&C&&C!=="all"&&!(0,os.find)(n,{key:C})?"all":C,[n,C]),ce=(0,vt.useCallback)(W=>{P(W)},[]),pe=(0,vt.useCallback)(W=>{var ie;return((ie=(0,os.find)(n,{key:W}))==null?void 0:ie.hasSlug)!==!1},[n]),ve=(0,vt.useMemo)(()=>{if(!a)return[];let W=a;if(R!==p&&(W=(0,os.filter)(a,Y=>pe(Y.pageType)!==!1)),_)return(0,os.filter)(W,Y=>!(F!=null&&F[Y.id]));let ie=pY(W,m,j,pe);return(0,os.filter)(ie,Y=>B==="pages"?pe(Y.pageType):!pe(Y.pageType))},[a,pe,m,j,F,_,R,p,B]);(0,vt.useEffect)(()=>{r(p)},[p,r]),(0,vt.useEffect)(()=>{var ie;let W=i.get("lang");if(W){let Y=o,Ze=(ie=o[0])!=null?ie:p,te=Y.includes(W);(0,vt.startTransition)(()=>{te&&R!==W?H(W):!te&&R!==Ze&&H(Ze)})}},[]),(0,vt.useEffect)(()=>{if(u&&!s&&!(0,os.find)(a,{id:u})){let ie=new URLSearchParams(i.toString());if(ie.delete("page"),[...ie.keys()].length>0){if(typeof window!="undefined"&&window.history&&window.location){let Y=ie.toString(),Ze=window.location.hash||"",te=window.location.pathname,Qe=Y?`${te}?${Y}${Ze}`:`${te}${Ze}`;window.history.replaceState(window.history.state,"",Qe)}l(ie)}else typeof window!="undefined"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),l(ie)}},[a,u,s,l,i]),(0,vt.useEffect)(()=>{u&&!s&&!(0,os.isEmpty)(ve)&&c(ve,u)},[u,s,ve,c]),(0,vt.useEffect)(()=>{!(0,os.isEmpty)(m)&&!(0,os.isEmpty)(ve)&&d(ve)},[m,ve,d]);let{setSelectedLang:Ve}=fe(),ze=(0,vt.useCallback)(W=>{let ie=new URLSearchParams({page:W});R!==p?(ie.set("lang",R),Ve(R)):Ve(""),OP(ie,l),e()},[e,l,Ve,R,p]),bt=(W,ie)=>{var Y;if(ie)switch(W){case"add":y(ie);break;case"select":ze(ie);break;case"edit":R!==p?z({edit:!0,id:ie==null?void 0:ie.id,primaryPage:ie==null?void 0:ie.primaryPage}):y(ie);break;case"delete":f(ie);break;case"unpublish":w(ie);break;case"markAsTemplate":I(ie);break;case"unmarkAsTemplate":D(ie);break;case"duplicate":S(ie);break;case"addLanguagePage":z({edit:!1,primaryPage:((Y=ie==null?void 0:ie.page)==null?void 0:Y.id)||"",preselectedLang:(ie==null?void 0:ie.language)||R});break}};return(0,uo.jsxs)(uo.Fragment,{children:[(0,uo.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(Wse,{pages:ve,search:m,setSearch:g,languages:[p,...o],selectedLanguage:R,setSelectedLanguage:H,selectedPageType:j,setSelectedPageType:ce,onAddPage:W=>bt("add",W),showUntranslatedPages:_,setShowUntranslatedPages:L,category:B,setCategory:U})}),(0,uo.jsx)("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:s||O?(0,uo.jsx)("div",{className:"space-y-2",children:(0,os.map)([...Array(15).keys()],W=>(0,uo.jsx)("div",{className:"h-7 w-full animate-pulse rounded border border-border bg-accent"},W))}):(0,os.isEmpty)(ve)?(0,uo.jsxs)("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-center text-sm font-medium text-muted-foreground",children:[(0,uo.jsx)(NY.File,{className:"h-6 w-6 stroke-[1]"}),m?(0,uo.jsxs)(uo.Fragment,{children:[t("No results found"),(0,uo.jsx)("span",{className:"font-light",children:t("Try adjusting your search to find what you're looking for.")})]}):B==="partials"?(0,uo.jsx)(uo.Fragment,{children:(0,uo.jsx)("span",{className:"max-w-[300px] font-light",children:t("Create reusable blocks to maintain consistency and design faster.")})}):(0,uo.jsx)(uo.Fragment,{children:(0,uo.jsx)("span",{className:"font-light",children:t("Add new page to start")})})]}):(0,uo.jsx)(wY,{tier:0,pages:ve,pageTypes:n,currentPage:u||"",onClickAction:bt,languagePages:F,selectedLanguage:R,showUntranslatedPages:_})})]}),b&&(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(jse,{closePanel:e,editPage:ze,addEditPage:b,setAddEditPage:y})}),h&&(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(qse,{page:h,onClose:()=>f(null)})}),k&&(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(Qse,{page:k,onClose:()=>w(null)})}),N&&(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(Yse,{page:N,onClose:()=>I(null)})}),A&&(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(Jse,{page:A,onClose:()=>D(null)})}),v&&(0,uo.jsx)(vt.Suspense,{children:(0,uo.jsx)(Kse,{page:v,onClose:()=>S(null),closePanel:e})})]})},Zse=Xse});var RY={};et(RY,{default:()=>oie});var mR,VT,BY,Ld,eie,tie,oie,DY=x(()=>{"use strict";mR=require("lodash-es"),VT=require("react"),BY=require("react-i18next");tB();er();Ul();cs();dv();Ld=require("react/jsx-runtime"),eie=(0,VT.lazy)(()=>Promise.resolve().then(()=>(IY(),AY))),tie=()=>{let{t:e}=(0,BY.useTranslation)(),[t]=Go(),o=t.get("page"),{data:r,isFetching:n}=xt(),{data:a,isFetching:s}=on(),[i,l]=Kz(),c=!!o&&!(0,mR.isEmpty)(r),d=s||!a,p=!d&&!o,u=!d&&!n&&(0,mR.isEmpty)(r),m=i||p||u;return(0,Ld.jsx)(cy,{open:m,onOpenChange:g=>!g&&c&&l(!1),children:(0,Ld.jsxs)(Gg,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[600px] !max-w-[600px] border-border p-0 ${c?"":"sheet-hide-close-btn"}`,children:[(0,Ld.jsxs)($g,{className:"p-3 px-4",children:[(0,Ld.jsx)(Vg,{children:e("Pages Manager")}),(0,Ld.jsx)(hI,{className:"sr-only",children:e("Manage your site structure")})]}),(0,Ld.jsx)("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:m&&(0,Ld.jsx)(VT.Suspense,{children:(0,Ld.jsx)(eie,{close:()=>l(!1)})})})]})})},oie=tie});var zT,LY,Pc,ar,Xo,rie,nie,aie,sie,iie,lie,cie,die,_Y,pie,mie,uie,MY,OY=x(()=>{"use strict";zT=require("@tanstack/react-query"),LY=require("jotai"),Pc=require("lodash-es"),ar=require("react");Qn();zm();Pa();Zc();tW();er();nW();L0();lW();An();nB();gW();zu();hW();cs();m9();Rr();nN();J();Oo();lm();t7();Oo();oR();ps();Vd();n7();ok();rk();l7();d7();M0();TI();rR();TB();Xo=require("react/jsx-runtime"),rie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(T7(),P7))),nie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(B7(),I7))),aie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(F7(),O7))),sie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(HB(),FB))),iie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(oY(),tY))),lie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(lY(),sY))),cie=(0,ar.lazy)(()=>Promise.resolve().then(()=>(DY(),RY)));r7();e7();p9();xk(jo.TOP_BAR,eW);xk(jo.MEDIA_MANAGER,sie);oN(iie);die={role:"admin",permissions:null},_Y=e=>{let{isLoading:t}=Lv();return t?(0,Xo.jsx)(lf,{}):(0,Xo.jsx)(pie,{...e})},pie=e=>{let{data:t,isFetching:o,isError:r}=Zv();return!t||o?(0,Xo.jsx)(lf,{}):r?(0,Xo.jsxs)(Pn,{className:"fixed inset-0 bg-surface text-foreground",children:[(0,Xo.jsx)("p",{children:"Failed to load website data"}),(0,Xo.jsx)(E,{onClick:()=>window.location.reload(),children:"Retry"})]}):(0,Xo.jsx)(mie,{...e})},mie=({...e})=>{var j,ce,pe,ve,Ve,ze,bt;let{data:t}=Zv(),{data:o}=AP(),{data:r}=i7(),{collections:n,pageTypes:a,websiteSettings:s}=t,i=(0,ar.useMemo)(()=>(s==null?void 0:s.fallbackLang)||"en",[s]),{data:l,isFetching:c}=Lv(),d=l||die,[p]=Go(),u=p.get("page"),{data:m}=xt(),{data:g,isFetching:h}=tk(),{data:f}=If(),{data:b}=Af(),{blocks:y}=rW((ce=(j=g==null?void 0:g.draftPage)==null?void 0:j.blocks)!=null?ce:[]),{pageStatus:k}=rn(),{mutateAsync:w}=c7(),{onSave:N}=uW(),{getPartialBlocks:I,getPartialBlockBlocks:C}=fW(),{searchPages:P}=s1(),{mutateAsync:B}=iW(),T=ak(),[v,S]=(0,ar.useState)(!1),A=(0,ar.useRef)([]),D=(0,ar.useMemo)(()=>(0,Pc.get)(s,"theme",{})||{},[s]),R=(0,ar.useMemo)(()=>(0,Pc.get)(s,"languages",[])||[],[s]),H=(0,ar.useMemo)(()=>(0,Pc.get)(s,"designTokens",{})||{},[s]),M=k===go.EDITING,L=k===go.CHECKING,z=h||L,[,_]=ma();(0,ar.useEffect)(()=>{A.current=y},[y]),(0,ar.useEffect)(()=>{let W=Gt.subscribe(dt.OPEN_AI_PANEL,()=>{_(Gv)});return()=>W()},[_]);let[F]=(0,LY.useAtom)(DT);(0,ar.useEffect)(()=>{let W=()=>{document.hidden?S(!0):S(!1)};return window.addEventListener("visibilitychange",W),()=>window.removeEventListener("visibilitychange",W)},[]);let O=(0,ar.useMemo)(()=>{let W={};return d&&(W.permissions=(0,Pc.get)(d,"permissions",null),W.role=(0,Pc.get)(d,"role","user")),W.pageExternalData={...b!=null?b:{},global:f!=null?f:{}},W},[d,b,f]),U=(0,ar.useMemo)(()=>r==null?void 0:r.some(W=>W.isSiteLibrary),[r]);return(0,Xo.jsxs)(Xo.Fragment,{children:[h&&(0,Xo.jsx)(Pn,{children:(0,Xo.jsx)(wt,{className:`transition-all ${c?"h-6 w-6":"h-5 w-5"}`})}),F&&(0,Xo.jsx)(ar.Suspense,{fallback:(0,Xo.jsx)("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:(0,Xo.jsx)(wt,{className:"h-6 w-6 text-primary"})}),children:(0,Xo.jsx)(lie,{})}),(0,Xo.jsx)(kP,{siteWideUsage:o!=null?o:{},flags:e.flags?{...e.flags,librarySite:U}:{librarySite:U},gotoPage:T,collections:n!=null?n:[],getBlockAsyncProps:w,themePresets:(pe=e.themePresets)!=null?pe:[],pageId:m==null?void 0:m.id,loading:z,fallbackLang:i,languages:R,brandingOptions:D,designTokens:H,translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!v&&M&&((ve=e.autoSave)!=null?ve:!0),autoSaveActionsCount:(Ve=e.autoSaveActionsCount)!=null?Ve:10,onError:e.onError||console.error,getPartialBlockBlocks:C,getPartialBlocks:I,blocks:h?[]:y,theme:(0,Pc.cloneDeep)(D),pageTypes:a,searchPageTypeItems:P,labels:e.labels,onSave:async({blocks:W,needTranslations:ie,partialIds:Y,linkPageIds:Ze,designTokens:te})=>{if(!u)return!0;A.current=W;let Qe=[...W];return await N({page:u,blocks:Qe,needTranslations:ie,partialIds:Y,linkPageIds:Ze,designTokens:te}),A.current=Qe,!0},onSaveWebsiteData:async({type:W,data:ie})=>(W==="THEME"?await B({settings:{theme:ie}}):W==="DESIGN_TOKENS"&&await B({settings:{designTokens:ie}}),!0),...O,children:(0,Xo.jsx)(rie,{isFetchingPageData:h})}),((bt=(ze=e.flags)==null?void 0:ze.pagesManager)!=null?bt:!0)&&(0,Xo.jsx)(cie,{}),(0,Xo.jsx)("div",{children:(0,Xo.jsx)(aie,{})}),(0,Xo.jsx)(ar.Suspense,{fallback:null,children:(0,Xo.jsx)(nie,{})})]})},uie=new zT.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),MY=e=>{let[,t]=el(),[o,r]=(0,ar.useState)(!1);return(0,ar.useEffect)(()=>(t((0,Pc.pick)(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","onLogout","getAccessToken","websocket","getLoggedInUser","flags","currentUser","ai","beforeRequest","dam","labels"])),setTimeout(()=>{r(!0)},200),()=>{r(!1),t({})}),[e,t]),o?(0,Pc.get)(e,"hasReactQueryProvider",!1)===!0?(0,Xo.jsx)(_Y,{...e}):(0,Xo.jsx)(zT.QueryClientProvider,{client:uie,children:(0,Xo.jsx)(_Y,{...e})}):(0,Xo.jsx)(lf,{})}});var gie={};et(gie,{ADD_BLOCK_TABS:()=>gk,CHAI_BUILDER_PANELS:()=>hk,CHAI_SLOT_IDS:()=>jo,ChaiAiPanel:()=>AS,ChaiJsonInput:()=>xT,ChaiSlot:()=>Br,ChaiWebsiteBuilder:()=>MY,IfChaiFeatureFlag:()=>kQ,ImagePicker:()=>Wv,LanguageSwitcher:()=>wy,NestedPathSelector:()=>Nc,PermissionChecker:()=>UI,RJSF_EXTENSIONS:()=>Vb,SAVE_TO_LIB_COMPONENT:()=>Ff,SLOT_REGISTRY:()=>qb,clearHooks:()=>CJ,defaultChaiLibrary:()=>bI,executeChaiHooks:()=>bf,getChaiLibrary:()=>SQ,getPreImportHTML:()=>tN,getRegisteredHooks:()=>vJ,registerChaiAddBlockTab:()=>vQ,registerChaiBlockSettingField:()=>bQ,registerChaiBlockSettingTemplate:()=>xQ,registerChaiBlockSettingWidget:()=>yQ,registerChaiFeatureFlag:()=>Wb,registerChaiFeatureFlags:()=>CQ,registerChaiHook:()=>xJ,registerChaiLibrary:()=>eN,registerChaiPreImportHTMLHook:()=>wQ,registerChaiSaveToLibrary:()=>oN,registerChaiSidebarPanel:()=>ol,registerChaiSlot:()=>xk,registerChaiStructureCheckRule:()=>NQ,resetSaveToLibrary:()=>PQ,useActivePage:()=>dr,useApiUrl:()=>le,useBuilderFetch:()=>Ls,useBuilderPageData:()=>Af,useChaiAddBlockTabs:()=>Y0,useChaiAuth:()=>am,useChaiBlockSettingComponents:()=>zb,useChaiCurrentPage:()=>m1,useChaiFeatureFlag:()=>Of,useChaiFeatureFlags:()=>Q0,useChaiLibraries:()=>jb,useChaiPrimaryPage:()=>xt,useChaiSidebarPanels:()=>yk,useChaiSlot:()=>p_,useChaiUserInfo:()=>xa,useClearAll:()=>M1,useFallbackLang:()=>Mn,useFetch:()=>he,useGotoPage:()=>ak,useLanguagePages:()=>gn,usePageAllData:()=>tk,usePageTypes:()=>Ht,useReloadPage:()=>L1,useSavePage:()=>to,useSaveToLibraryComponent:()=>rN,useSiteGlobalData:()=>If,useToggleChaiFeatureFlag:()=>X0,useTranslation:()=>gv.useTranslation,useUpdateActivePageMetadata:()=>F1,useUserPermissions:()=>Lv,useWebsitePages:()=>on,useWebsiteSetting:()=>ca});module.exports=WY(gie);var lS=x(()=>{KT();er();L0();ok();rk();An();Hl();M0();O1();H1();zm();Nn();OY();wv();$B();Tv();UB();kx();er();Gc();Ul();rt();Uc();Fb();nB();Hp();Kt();Rr();if(typeof window=="undefined")throw new Error("@chaibuilder/pro is not available on the server")});lS();0&&(module.exports={ADD_BLOCK_TABS,CHAI_BUILDER_PANELS,CHAI_SLOT_IDS,ChaiAiPanel,ChaiJsonInput,ChaiSlot,ChaiWebsiteBuilder,IfChaiFeatureFlag,ImagePicker,LanguageSwitcher,NestedPathSelector,PermissionChecker,RJSF_EXTENSIONS,SAVE_TO_LIB_COMPONENT,SLOT_REGISTRY,clearHooks,defaultChaiLibrary,executeChaiHooks,getChaiLibrary,getPreImportHTML,getRegisteredHooks,registerChaiAddBlockTab,registerChaiBlockSettingField,registerChaiBlockSettingTemplate,registerChaiBlockSettingWidget,registerChaiFeatureFlag,registerChaiFeatureFlags,registerChaiHook,registerChaiLibrary,registerChaiPreImportHTMLHook,registerChaiSaveToLibrary,registerChaiSidebarPanel,registerChaiSlot,registerChaiStructureCheckRule,resetSaveToLibrary,useActivePage,useApiUrl,useBuilderFetch,useBuilderPageData,useChaiAddBlockTabs,useChaiAuth,useChaiBlockSettingComponents,useChaiCurrentPage,useChaiFeatureFlag,useChaiFeatureFlags,useChaiLibraries,useChaiPrimaryPage,useChaiSidebarPanels,useChaiSlot,useChaiUserInfo,useClearAll,useFallbackLang,useFetch,useGotoPage,useLanguagePages,usePageAllData,usePageTypes,useReloadPage,useSavePage,useSaveToLibraryComponent,useSiteGlobalData,useToggleChaiFeatureFlag,useTranslation,useUpdateActivePageMetadata,useUserPermissions,useWebsitePages,useWebsiteSetting});