@chaibuilder/sdk 4.0.0-beta.8 → 4.0.0-beta.9

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 (139) hide show
  1. package/README.md +4 -5
  2. package/dist/{2SSKDMRQ-DewwiCoQ.js → 2SSKDMRQ-CdFBQR2o.js} +2 -2
  3. package/dist/{2SSKDMRQ-DHv4u_0i.cjs → 2SSKDMRQ-CuQ42ST6.cjs} +1 -1
  4. package/dist/{AP7HFJJL-cz754qhG.cjs → AP7HFJJL-DcnEb4BE.cjs} +1 -1
  5. package/dist/{AP7HFJJL-ComnZw7J.js → AP7HFJJL-bDlWX5Yx.js} +1 -1
  6. package/dist/{IconPicker-2H9IGKMS.js → IconPicker-CNwplOGy.js} +1 -1
  7. package/dist/{IconPicker-U0Z2dWeR.cjs → IconPicker-FpyYsxOf.cjs} +1 -1
  8. package/dist/STRINGS-BExFecZW.js +8 -0
  9. package/dist/STRINGS-FNnfjF5H.cjs +1 -0
  10. package/dist/{WDYDFRGG-BfRX3M58.cjs → WDYDFRGG-BxLmjulP.cjs} +1 -1
  11. package/dist/{WDYDFRGG-vy7nMYD4.js → WDYDFRGG-CWq7H6Qk.js} +2 -2
  12. package/dist/{actions-registery-CtQSSexG.cjs → actions-registery-BRgseJas.cjs} +16 -16
  13. package/dist/{actions-registery-DqrFhSMp.js → actions-registery-DRV8xywr.js} +180 -181
  14. package/dist/actions.cjs +1 -1
  15. package/dist/actions.d.ts +112 -51
  16. package/dist/actions.js +2 -2
  17. package/dist/{active-in-another-tab-5hn17Jeq.js → active-in-another-tab-C392ZWQc.js} +2 -2
  18. package/dist/{active-in-another-tab-ijahI5qu.cjs → active-in-another-tab-DEWOFgY5.cjs} +1 -1
  19. package/dist/{add-new-language-page-DmOyPy0u.js → add-new-language-page-BL2F_Cu7.js} +3 -3
  20. package/dist/{add-new-language-page-vmNKNx-e.cjs → add-new-language-page-DBWd0wDY.cjs} +1 -1
  21. package/dist/{add-new-page-XDuCkOyb.cjs → add-new-page-DYrQeKCi.cjs} +1 -1
  22. package/dist/{add-new-page-NHScAQn8.js → add-new-page-QVlyJhn9.js} +2 -2
  23. package/dist/{ai-panel-content-CHJ0JcQI.js → ai-panel-content-CCOluPtK.js} +3 -3
  24. package/dist/{ai-panel-content-BDqW16AW.cjs → ai-panel-content-DCZRBa6s.cjs} +1 -1
  25. package/dist/{ai-panel-default-lang-HeYWpbMu.cjs → ai-panel-default-lang-C3t0elrO.cjs} +2 -2
  26. package/dist/{ai-panel-default-lang-BIomgsN0.js → ai-panel-default-lang-Crz7QAxl.js} +4 -4
  27. package/dist/{ai-panel-other-lang-BMelEs3p.cjs → ai-panel-other-lang-BRkr4Te3.cjs} +1 -1
  28. package/dist/{ai-panel-other-lang-CbAgG-qX.js → ai-panel-other-lang-DIF8PYLh.js} +4 -4
  29. package/dist/{ai-prompt-input-BH8LOVT4.js → ai-prompt-input-D4dqy8L2.js} +1 -1
  30. package/dist/{ai-prompt-input-C_GG6nwq.cjs → ai-prompt-input-Ybgvrvd6.cjs} +1 -1
  31. package/dist/{ai-translation-prompt-CkHaFv5I.cjs → ai-translation-prompt-Ck12Bfl6.cjs} +1 -1
  32. package/dist/{ai-translation-prompt-DxsNw8YR.js → ai-translation-prompt-eZ4Sllva.js} +1 -1
  33. package/dist/{apply-binding-BvWfJCSZ.js → apply-binding-CLU6Xp4K.js} +77 -81
  34. package/dist/apply-binding-NvZX_rJe.cjs +1 -0
  35. package/dist/{code-editor-CGBAc-A6.js → code-editor-D45h29W1.js} +1 -1
  36. package/dist/{code-editor-GV8ibQ4h.cjs → code-editor-DH8eU4WL.cjs} +1 -1
  37. package/dist/{continue-editing-in-this-client-Da8ab_9d.js → continue-editing-in-this-client-BRrIvSrl.js} +2 -2
  38. package/dist/{continue-editing-in-this-client-DKHP0pq8.cjs → continue-editing-in-this-client-DgZ9Q18G.cjs} +1 -1
  39. package/dist/core-8lkXy4lC.cjs +1 -0
  40. package/dist/core-BvsZwF26.js +52 -0
  41. package/dist/core.cjs +1 -1
  42. package/dist/core.d.ts +147 -87
  43. package/dist/core.js +2 -2
  44. package/dist/{css-import-modal-CcZVLsF9.js → css-import-modal-BhLPzQH8.js} +1 -1
  45. package/dist/{css-import-modal-B4j26_cO.cjs → css-import-modal-C2-oVwFv.cjs} +1 -1
  46. package/dist/{delete-design-token-DzINIVtO.js → delete-design-token-D4Q5-Xql.js} +1 -1
  47. package/dist/{delete-design-token-3-WwqXMO.cjs → delete-design-token-DJSQluQ6.cjs} +1 -1
  48. package/dist/{delete-page-B7ODELqM.cjs → delete-page-BxbsKhY5.cjs} +1 -1
  49. package/dist/{delete-page-DwZDMwfI.js → delete-page-xHdZT-7c.js} +2 -2
  50. package/dist/{design-token-usage-DQf180Lg.js → design-token-usage-7wgmVSWI.js} +1 -1
  51. package/dist/{design-token-usage-Dy08kcIc.cjs → design-token-usage-KZ4pilLm.cjs} +1 -1
  52. package/dist/{digital-asset-manager-CDy9kHZO.js → digital-asset-manager-BmbVU7fX.js} +3 -3
  53. package/dist/{digital-asset-manager-C7subULa.cjs → digital-asset-manager-a1fqrQVH.cjs} +1 -1
  54. package/dist/{duplicate-page-DTnSztlr.js → duplicate-page-5uIno9Yh.js} +3 -3
  55. package/dist/{duplicate-page-CWQ9aMd9.cjs → duplicate-page-BBTxn_o1.cjs} +1 -1
  56. package/dist/{dynamic-page-selector-DJuxLcsM.cjs → dynamic-page-selector-C1ef0i2I.cjs} +1 -1
  57. package/dist/{dynamic-page-selector-DYW3ov_u.js → dynamic-page-selector-rhvhg7ol.js} +2 -2
  58. package/dist/{image-editor-DLeSST0K.js → image-editor-BXYZDa0s.js} +1 -1
  59. package/dist/{image-editor-C4H3AkZK.cjs → image-editor-rqUgAO8V.cjs} +1 -1
  60. package/dist/{index-D5d4QDq7.js → index-Be9lAaD7.js} +420 -422
  61. package/dist/index-BhqugjzS.cjs +160 -0
  62. package/dist/index-CNEEEgTV.cjs +5 -0
  63. package/dist/{index-BK0xWO1z.js → index-mjuSGlPU.js} +440 -447
  64. package/dist/{json-diff-viewer-g6SY62bl.cjs → json-diff-viewer-C9qmLiaq.cjs} +1 -1
  65. package/dist/{json-diff-viewer-BYHieVod.js → json-diff-viewer-aVwY7_hZ.js} +2 -2
  66. package/dist/{lang-panel-BG1GMn-1.js → lang-panel-BTWk23Mw.js} +3 -3
  67. package/dist/{lang-panel-Dm1eOO2J.cjs → lang-panel-Bo1ZWYfu.cjs} +1 -1
  68. package/dist/{manage-design-tokens-BdWQUHhw.js → manage-design-tokens-id8bylgO.js} +3 -3
  69. package/dist/manage-design-tokens-lUMCgjdS.cjs +1 -0
  70. package/dist/{mark-as-template-DUFnfVM3.cjs → mark-as-template-BYXBDXMv.cjs} +1 -1
  71. package/dist/{mark-as-template-D2XxagVO.js → mark-as-template-hv3WD852.js} +2 -2
  72. package/dist/{nested-path-selector-content-Wd6-Eql0.js → nested-path-selector-content-B8z90MFF.js} +1 -1
  73. package/dist/{nested-path-selector-content-CQOx2L9C.cjs → nested-path-selector-content-DgFFXcTD.cjs} +1 -1
  74. package/dist/{no-language-page-content-C11uF6hs.cjs → no-language-page-content-6Kk8UjFX.cjs} +1 -1
  75. package/dist/{no-language-page-content-BOv6TZIk.js → no-language-page-content-DMACzysm.js} +2 -2
  76. package/dist/{no-language-page-dialog-DIXyKRJq.js → no-language-page-dialog-D4n_XYUq.js} +2 -2
  77. package/dist/{no-language-page-dialog-CY5XhXsC.cjs → no-language-page-dialog-mBH-fthh.cjs} +1 -1
  78. package/dist/{page-creator-zSUFF4eT.cjs → page-creator-CGglYnYg.cjs} +1 -1
  79. package/dist/{page-creator-WX9lMrJY.js → page-creator-CgsOF0Eg.js} +3 -3
  80. package/dist/{page-lock-D9miLZjm.js → page-lock-CUCEBnJb.js} +2 -2
  81. package/dist/{page-lock-DGhR_url.cjs → page-lock-Hsi61Mk5.cjs} +1 -1
  82. package/dist/{page-locked-dialog-DTLnbfuP.cjs → page-locked-dialog-DSxbAMpt.cjs} +1 -1
  83. package/dist/{page-locked-dialog-CNCUCcvH.js → page-locked-dialog-bHvbFllT.js} +2 -2
  84. package/dist/{page-manager-new-Dd2c-Q_O.cjs → page-manager-new-CBfFl5rL.cjs} +1 -1
  85. package/dist/{page-manager-new-BFFOLh-l.js → page-manager-new-Cifc526h.js} +7 -7
  86. package/dist/{page-manager-search-and-filter-C1IWF_4d.js → page-manager-search-and-filter-CLJss6pV.js} +2 -2
  87. package/dist/{page-manager-search-and-filter-BKdQUJ2W.cjs → page-manager-search-and-filter-mEKl-UKh.cjs} +1 -1
  88. package/dist/{page-revisions-content-D0cflnj1.cjs → page-revisions-content-C95dQJyx.cjs} +1 -1
  89. package/dist/{page-revisions-content-DHapiLck.js → page-revisions-content-DvL4ya9g.js} +3 -3
  90. package/dist/pages.cjs +1 -1
  91. package/dist/pages.d.ts +146 -93
  92. package/dist/pages.js +1 -1
  93. package/dist/{publish-pages-content-BqLcnKry.cjs → publish-pages-content-B-6vSkql.cjs} +1 -1
  94. package/dist/{publish-pages-content-Bd2zJHtK.js → publish-pages-content-B8-IZW_U.js} +3 -3
  95. package/dist/render.cjs +1 -1
  96. package/dist/render.d.ts +12 -14
  97. package/dist/render.js +3 -3
  98. package/dist/{rte-widget-modal-RS8PMKOn.js → rte-widget-modal-1SbY5bcQ.js} +1 -1
  99. package/dist/{rte-widget-modal-DiB5BjH1.cjs → rte-widget-modal-CyKwtbOG.cjs} +1 -1
  100. package/dist/runtime.cjs +1 -1
  101. package/dist/runtime.d.ts +91 -77
  102. package/dist/runtime.js +57 -56
  103. package/dist/{save-to-lib--6ZXHEbC.js → save-to-lib-BKcBfjfi.js} +2 -2
  104. package/dist/{save-to-lib-BXJvaC1N.cjs → save-to-lib-BmPh_Vns.cjs} +1 -1
  105. package/dist/{selected-block-display-CUnCqXQw.js → selected-block-display-B3hHlcLA.js} +2 -2
  106. package/dist/{selected-block-display-BfpJda4h.cjs → selected-block-display-BCvTNcp2.cjs} +1 -1
  107. package/dist/{seo-panel-Bs-FcY1A.js → seo-panel-D3EyOYij.js} +2 -2
  108. package/dist/{seo-panel-CQITMfZ6.cjs → seo-panel-DVClgzX9.cjs} +1 -1
  109. package/dist/{shared-json-ld-DDXXi-Mj.cjs → shared-json-ld-BRgJTv0m.cjs} +1 -1
  110. package/dist/{shared-json-ld-7EujD341.js → shared-json-ld-DSPadwbY.js} +2 -2
  111. package/dist/{slug-input-CsVJAr7r.cjs → slug-input-B39SPBdP.cjs} +1 -1
  112. package/dist/{slug-input-DoEIq5rs.js → slug-input-C3UrwSkt.js} +1 -1
  113. package/dist/supabase-actions.cjs +1 -1
  114. package/dist/supabase-actions.js +1 -1
  115. package/dist/{take-over-request-C14kJ356.js → take-over-request-DfAlPvpE.js} +2 -2
  116. package/dist/{take-over-request-D5Oo3MPo.cjs → take-over-request-Tq9-gOCV.cjs} +1 -1
  117. package/dist/{theme-panel-footer-Dvknelm8.js → theme-panel-footer-DIy4baYU.js} +2 -2
  118. package/dist/{theme-panel-footer-Eeibz2JA.cjs → theme-panel-footer-DQzjVBBP.cjs} +1 -1
  119. package/dist/{translation-warning-modal-YlzP2XoO.js → translation-warning-modal-BHwLZZOw.js} +1 -1
  120. package/dist/{translation-warning-modal-CPzdHzqq.cjs → translation-warning-modal-Ckwt5Skc.cjs} +1 -1
  121. package/dist/types.cjs +1 -0
  122. package/dist/types.d.ts +598 -0
  123. package/dist/types.js +1 -0
  124. package/dist/{unmark-as-template-BGDwuCnv.cjs → unmark-as-template-BKA-sNZr.cjs} +1 -1
  125. package/dist/{unmark-as-template-CPJvQk7L.js → unmark-as-template-CbgifSbI.js} +2 -2
  126. package/dist/{unpublish-page-BMowW5wT.cjs → unpublish-page-BqzvOD76.cjs} +1 -1
  127. package/dist/{unpublish-page-DlFHLlmI.js → unpublish-page-DXQpAkvc.js} +2 -2
  128. package/dist/utils.d.ts +5 -5
  129. package/dist/web-blocks.cjs +1 -1
  130. package/dist/web-blocks.js +237 -237
  131. package/dist/{web-preview-BUnv3jIc.js → web-preview-DH7Yv-jg.js} +1 -1
  132. package/dist/{web-preview-D8GQHCjs.cjs → web-preview-DShy13AM.cjs} +1 -1
  133. package/package.json +6 -1
  134. package/dist/apply-binding-IsUf6UWJ.cjs +0 -1
  135. package/dist/core-Dr7QYemB.js +0 -56
  136. package/dist/core-Y0lXLwkq.cjs +0 -1
  137. package/dist/index-BRJCj7c_.cjs +0 -5
  138. package/dist/index-Bm8iS2OH.cjs +0 -160
  139. package/dist/manage-design-tokens-XWs_B6jo.cjs +0 -1
package/dist/render.d.ts CHANGED
@@ -2,7 +2,7 @@ import { JSX } from 'react/jsx-runtime';
2
2
 
3
3
  export declare const applyChaiDataBinding: (block: Record<string, string>, pageExternalData: Record<string, any>) => Record<string, string>;
4
4
 
5
- export declare const applyDesignTokens: (blocks: ChaiBlock[], designTokens: DesignTokens) => ChaiBlock[];
5
+ export declare const applyDesignTokens: (blocks: ChaiBlock[], designTokens: ChaiDesignTokens) => ChaiBlock[];
6
6
 
7
7
  export declare function AsyncRenderChaiBlocks(props: RenderChaiBlocksProps): Promise<JSX.Element | null>;
8
8
 
@@ -15,19 +15,25 @@ declare type ChaiBlock<T = Record<string, any>> = {
15
15
  partialBlockId?: string;
16
16
  } & T;
17
17
 
18
+ declare interface ChaiDesignTokens {
19
+ [uniqueId: string]: {
20
+ name: string;
21
+ value: string;
22
+ };
23
+ }
24
+
18
25
  declare type ChaiFontViaUrl = {
19
26
  family: string;
20
27
  url: string;
21
28
  fallback: string;
22
29
  };
23
30
 
24
- declare interface ChaiPageProps {
31
+ declare type ChaiPageProps<T = Record<string, any>> = {
25
32
  slug: string;
26
33
  searchParams?: Record<string, string>;
27
- [key: string]: any;
28
- }
34
+ } & T;
29
35
 
30
- declare type ChaiThemeValues = {
36
+ declare type ChaiTheme = {
31
37
  fontFamily: {
32
38
  heading: string;
33
39
  body: string;
@@ -53,7 +59,6 @@ declare type ChaiThemeValues = {
53
59
  "card-foreground": [HexColor, HexColor];
54
60
  popover: [HexColor, HexColor];
55
61
  "popover-foreground": [HexColor, HexColor];
56
- [key: string]: [HexColor, HexColor];
57
62
  };
58
63
  };
59
64
 
@@ -70,14 +75,7 @@ export declare const convertHTMLToChaiBlocks: (html: string) => ChaiBlock[];
70
75
  */
71
76
  export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[];
72
77
 
73
- declare interface DesignTokens {
74
- [uniqueId: string]: {
75
- name: string;
76
- value: string;
77
- };
78
- }
79
-
80
- export declare const getChaiThemeCssVariables: (chaiTheme: ChaiThemeValues) => string;
78
+ export declare const getChaiThemeCssVariables: (chaiTheme: ChaiTheme) => string;
81
79
 
82
80
  export declare function getMergedPartialBlocks(blocks: ChaiBlock[], partials: Record<string, ChaiBlock[]>): ChaiBlock[];
83
81
 
package/dist/render.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { a as Le, b as De, c as Ke } from "./plugin-C-ht41UZ.js";
2
- import { a as O, b as N, c as E, d as J, e as C, f as j } from "./apply-binding-BvWfJCSZ.js";
3
- import { h as Ae, i as Fe, g as Me } from "./apply-binding-BvWfJCSZ.js";
2
+ import { a as O, b as N, c as E, d as J, e as C, f as j } from "./apply-binding-CLU6Xp4K.js";
3
+ import { h as Ae, i as Fe, g as Me } from "./apply-binding-CLU6Xp4K.js";
4
4
  import { jsx as m } from "react/jsx-runtime";
5
5
  import { has as P, isFunction as w, omit as q, get as d, isNull as H, isArray as B, uniqBy as W, filter as $, isEmpty as h, map as U, find as R, cloneDeep as z } from "lodash-es";
6
6
  import { Suspense as A, createElement as g } from "react";
7
- import { e as S } from "./core-Dr7QYemB.js";
7
+ import { e as S } from "./core-BvsZwF26.js";
8
8
  import { createTailwindcss as X } from "@mhsdesign/jit-browser-tailwindcss";
9
9
  import Y from "@tailwindcss/aspect-ratio";
10
10
  import Z from "@tailwindcss/container-queries";
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
- import { g as D, D as N, d as S, e as j, f as v, N as w } from "./index-BK0xWO1z.js";
2
+ import { g as D, D as N, d as S, e as j, f as v, N as w } from "./index-mjuSGlPU.js";
3
3
  import { B } from "./register-chai-top-bar-CX_JkRJn.js";
4
4
  const M = ({
5
5
  isOpen: f,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Bm8iS2OH.cjs"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BhqugjzS.cjs"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
package/dist/runtime.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("lodash-es"),r=require("./register-partial-type-ig9fUWIJ.cjs"),t=require("./core-Y0lXLwkq.cjs"),s=require("./fonts-B-Xt29pe.cjs"),C=t.setChaiServerBlockDataProvider,l="#styles:",p=e=>{const n=["_type","_id","_parent","_bindings","_name"],g=["$loading","blockProps","inBuilder","lang","draft","pageProps","pageData","children"],o=i.keys(e.properties);if(i.intersection(o,n).length>0)throw new Error(`Reserved props are not allowed: ${i.intersection(o,n).join(", ")}`);if(i.intersection(o,g).length>0)throw new Error(`Runtime props are not allowed in schema: ${i.intersection(o,g).join(", ")}`);const a=i.get(e,"properties",{}),c={};return i.each(a,(h,u)=>{i.isEmpty(h.ui)||(c[u]={...h.ui},delete a[u].ui)}),{schema:i.isEmpty(a)?{}:{...i.omit(e,["ui"])},uiSchema:{...i.get(e,"ui",{}),...c}}},d=(e="")=>({type:"string",styles:!0,default:`${l},${e}`,ui:{"ui:widget":"hidden"}}),P=(e="")=>({type:"string",styles:!0,default:`${l},${e}`,ui:{"ui:widget":"hidden"}}),B=e=>(console.warn("runtimeProp is deprecated, use builderProp instead"),{runtime:!0,...e}),k=e=>({builderProp:!0,...e}),y=e=>`${l},${e}`;Object.defineProperty(exports,"CHAI_GLOBAL_DATA_PROVIDER",{enumerable:!0,get:()=>r.CHAI_GLOBAL_DATA_PROVIDER});exports.COLLECTIONS=r.COLLECTIONS;exports.PAGE_TYPES=r.PAGE_TYPES;exports.getChaiCollection=r.getChaiCollection;exports.getChaiCollections=r.getChaiCollections;exports.getChaiGlobalData=r.getChaiGlobalData;exports.getChaiPageType=r.getChaiPageType;exports.getChaiPageTypes=r.getChaiPageTypes;exports.registerChaiCollection=r.registerChaiCollection;exports.registerChaiGlobalDataProvider=r.registerChaiGlobalDataProvider;exports.registerChaiPageType=r.registerChaiPageType;exports.registerChaiPartialType=r.registerChaiPartialType;exports.closestBlockProp=t.closestBlockProp;exports.getAIBlockProps=t.getAIBlockProps;exports.getBlockFormSchemas=t.getBlockFormSchemas;exports.getDefaultBlockProps=t.getDefaultBlockProps;exports.getI18nBlockProps=t.getI18nBlockProps;exports.getRegisteredChaiBlock=t.getRegisteredChaiBlock;exports.registerChaiBlock=t.registerChaiBlock;exports.registerChaiServerBlock=t.registerChaiServerBlock;exports.setChaiBlockComponent=t.setChaiBlockComponent;exports.setChaiServerBlockDataProvider=t.setChaiServerBlockDataProvider;exports.syncBlocksWithDefaults=t.syncBlocksWithDefaults;exports.useRegisteredChaiBlock=t.useRegisteredChaiBlock;exports.useRegisteredChaiBlocks=t.useRegisteredChaiBlocks;exports.getAllRegisteredFonts=s.getAllRegisteredFonts;exports.getRegisteredFont=s.getRegisteredFont;exports.registerChaiFont=s.registerChaiFont;exports.useRegisteredFonts=s.useRegisteredFonts;exports.StylesProp=d;exports.builderProp=k;exports.defaultChaiStyles=y;exports.registerChaiBlockSchema=p;exports.runtimeProp=B;exports.setChaiBlockDataProvider=C;exports.stylesProp=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./STRINGS-FNnfjF5H.cjs"),i=require("lodash-es"),r=require("./register-partial-type-ig9fUWIJ.cjs"),t=require("./core-8lkXy4lC.cjs"),s=require("./fonts-B-Xt29pe.cjs"),p=t.setChaiServerBlockDataProvider,C=e=>{const n=["_type","_id","_parent","_bindings","_name"],c=["$loading","blockProps","inBuilder","lang","draft","pageProps","pageData","children"],o=i.keys(e.properties);if(i.intersection(o,n).length>0)throw new Error(`Reserved props are not allowed: ${i.intersection(o,n).join(", ")}`);if(i.intersection(o,c).length>0)throw new Error(`Runtime props are not allowed in schema: ${i.intersection(o,c).join(", ")}`);const a=i.get(e,"properties",{}),g={};return i.each(a,(h,u)=>{i.isEmpty(h.ui)||(g[u]={...h.ui},delete a[u].ui)}),{schema:i.isEmpty(a)?{}:{...i.omit(e,["ui"])},uiSchema:{...i.get(e,"ui",{}),...g}}},d=(e="")=>(console.warn("StylesProp is deprecated, use stylesProp instead"),{type:"string",styles:!0,default:`${l.STYLES_KEY},${e}`,ui:{"ui:widget":"hidden"}}),P=(e="")=>({type:"string",styles:!0,default:`${l.STYLES_KEY},${e}`,ui:{"ui:widget":"hidden"}}),B=e=>(console.warn("runtimeProp is deprecated, use builderProp instead"),{runtime:!0,...e}),y=e=>({builderProp:!0,...e}),k=e=>`${l.STYLES_KEY},${e}`;Object.defineProperty(exports,"CHAI_GLOBAL_DATA_PROVIDER",{enumerable:!0,get:()=>r.CHAI_GLOBAL_DATA_PROVIDER});exports.COLLECTIONS=r.COLLECTIONS;exports.PAGE_TYPES=r.PAGE_TYPES;exports.getChaiCollection=r.getChaiCollection;exports.getChaiCollections=r.getChaiCollections;exports.getChaiGlobalData=r.getChaiGlobalData;exports.getChaiPageType=r.getChaiPageType;exports.getChaiPageTypes=r.getChaiPageTypes;exports.registerChaiCollection=r.registerChaiCollection;exports.registerChaiGlobalDataProvider=r.registerChaiGlobalDataProvider;exports.registerChaiPageType=r.registerChaiPageType;exports.registerChaiPartialType=r.registerChaiPartialType;exports.closestBlockProp=t.closestBlockProp;exports.getAIBlockProps=t.getAIBlockProps;exports.getBlockFormSchemas=t.getBlockFormSchemas;exports.getDefaultBlockProps=t.getDefaultBlockProps;exports.getI18nBlockProps=t.getI18nBlockProps;exports.getRegisteredChaiBlock=t.getRegisteredChaiBlock;exports.registerChaiBlock=t.registerChaiBlock;exports.registerChaiServerBlock=t.registerChaiServerBlock;exports.setChaiBlockComponent=t.setChaiBlockComponent;exports.setChaiServerBlockDataProvider=t.setChaiServerBlockDataProvider;exports.syncBlocksWithDefaults=t.syncBlocksWithDefaults;exports.useRegisteredChaiBlock=t.useRegisteredChaiBlock;exports.useRegisteredChaiBlocks=t.useRegisteredChaiBlocks;exports.getAllRegisteredFonts=s.getAllRegisteredFonts;exports.getRegisteredFont=s.getRegisteredFont;exports.registerChaiFont=s.registerChaiFont;exports.useRegisteredFonts=s.useRegisteredFonts;exports.StylesProp=d;exports.builderProp=y;exports.defaultChaiStyles=k;exports.registerChaiBlockSchema=C;exports.runtimeProp=B;exports.setChaiBlockDataProvider=p;exports.stylesProp=P;
package/dist/runtime.d.ts CHANGED
@@ -10,8 +10,6 @@ export declare let CHAI_GLOBAL_DATA_PROVIDER: (args: {
10
10
  inBuilder: boolean;
11
11
  }) => Promise<any>;
12
12
 
13
- export declare type ChaiAsyncProp<T> = T | undefined;
14
-
15
13
  declare type ChaiBlock<T = Record<string, any>> = {
16
14
  _id: string;
17
15
  _name?: string;
@@ -21,7 +19,7 @@ declare type ChaiBlock<T = Record<string, any>> = {
21
19
  partialBlockId?: string;
22
20
  } & T;
23
21
 
24
- export declare type ChaiBlockComponentProps<BlockProps, PageData = Record<string, unknown>> = ChaiBlock<BlockProps> & {
22
+ declare type ChaiBlockComponentProps<BlockProps, PageData = Record<string, unknown>> = ChaiBlock<BlockProps> & {
25
23
  $loading?: boolean;
26
24
  blockProps: Record<string, string>;
27
25
  inBuilder: boolean;
@@ -32,7 +30,7 @@ export declare type ChaiBlockComponentProps<BlockProps, PageData = Record<string
32
30
  children?: default_2.ReactNode;
33
31
  };
34
32
 
35
- export declare interface ChaiBlockDefinition<T = Record<string, any>, K = Record<string, any>> {
33
+ declare interface ChaiBlockDefinition<T = Record<string, any>, K = Record<string, any>> {
36
34
  component: default_2.ComponentType<ChaiBlockComponentProps<T>>;
37
35
  type: string;
38
36
  label: string;
@@ -66,34 +64,97 @@ export declare interface ChaiBlockDefinition<T = Record<string, any>, K = Record
66
64
 
67
65
  declare type ChaiBlockDefinitionOptions<T, K> = Omit<ChaiBlockDefinition<T, K>, "component">;
68
66
 
69
- export declare type ChaiBlockPropSchema = RJSFSchema & {
67
+ declare type ChaiBlockPropSchema = RJSFSchema & {
70
68
  ui?: ChaiBlockUiSchema;
71
69
  default: any;
72
70
  };
73
71
 
74
- export declare type ChaiBlockSchema = {
72
+ declare type ChaiBlockSchema = {
75
73
  properties?: Record<string, ChaiBlockPropSchema>;
76
74
  allOf?: any[];
77
75
  oneOf?: any[];
78
76
  } & Partial<Pick<ChaiBlockPropSchema, "required" | "dependencies" | "ui" | "title" | "description" | "default">>;
79
77
 
80
- export declare type ChaiBlockSchemas = {
78
+ declare type ChaiBlockSchemas = {
81
79
  schema: object | Omit<ChaiBlockSchema, "ui">;
82
80
  uiSchema?: ChaiBlockUiSchema;
83
81
  };
84
82
 
85
- export declare type ChaiBlockUiSchema = UiSchema;
83
+ declare type ChaiBlockUiSchema = UiSchema;
84
+
85
+ declare interface ChaiDesignTokens {
86
+ [uniqueId: string]: {
87
+ name: string;
88
+ value: string;
89
+ };
90
+ }
91
+
92
+ declare type ChaiFont = ChaiFontViaUrl | ChaiFontViaSrc;
93
+
94
+ declare type ChaiFontViaSrc = {
95
+ family: string;
96
+ src: {
97
+ url: string;
98
+ format: string;
99
+ fontWeight?: string;
100
+ fontStyle?: string;
101
+ fontDisplay?: string;
102
+ fontStretch?: string;
103
+ }[];
104
+ fallback: string;
105
+ };
86
106
 
87
- declare type ChaiBuilderPage = {
107
+ declare type ChaiFontViaUrl = {
108
+ family: string;
109
+ url: string;
110
+ fallback: string;
111
+ };
112
+
113
+ declare type ChaiPage = {
88
114
  id: string;
89
115
  slug: string;
90
- name: string;
91
116
  lang: string;
117
+ name: string;
118
+ pageType: string;
119
+ blocks: ChaiBlock[];
120
+ createdAt: string;
121
+ lastSaved: string;
122
+ dynamic: boolean;
92
123
  online: boolean;
93
- seo: Record<string, any>;
124
+ seo: ChaiPageSeo;
125
+ app: string;
126
+ primaryPage?: string | null;
127
+ currentEditor?: string | null;
128
+ changes: object[];
129
+ parent?: string | null;
130
+ libRefId?: string | null;
131
+ dynamicSlugCustom?: string | null;
132
+ metadata?: object;
133
+ jsonld?: object;
134
+ globalJsonLds?: string[];
135
+ links?: string;
136
+ partialBlocks?: string;
137
+ designTokens?: ChaiDesignTokens;
94
138
  };
95
139
 
96
- declare type ChaiBuilderPageType = {
140
+ declare type ChaiPageProps<T = Record<string, any>> = {
141
+ slug: string;
142
+ searchParams?: Record<string, string>;
143
+ } & T;
144
+
145
+ declare type ChaiPageSeo = {
146
+ title?: string;
147
+ description?: string;
148
+ ogTitle?: string;
149
+ ogDescription?: string;
150
+ ogImage?: string;
151
+ canonicalUrl?: string;
152
+ noIndex?: boolean;
153
+ noFollow?: boolean;
154
+ jsonLD?: string;
155
+ };
156
+
157
+ declare type ChaiPageType = {
97
158
  key: string;
98
159
  helpText?: string;
99
160
  icon?: string;
@@ -101,68 +162,31 @@ declare type ChaiBuilderPageType = {
101
162
  name: string | (() => Promise<string>);
102
163
  dynamicSegments?: string;
103
164
  dynamicSlug?: string;
104
- getDynamicPages?: ({ query, uuid }: {
165
+ getDynamicPages?: ({ query, uuid, }: {
105
166
  query?: string;
106
167
  uuid?: string;
107
- }) => Promise<ChaiDynamicPage[]>;
108
- search?: (query: string) => Promise<PageTypeSearchResult[] | Error>;
168
+ }) => Promise<Pick<ChaiPage, "id" | "name" | "slug" | "primaryPage">[]>;
169
+ search?: (query: string) => Promise<Pick<ChaiPage, "id" | "name" | "slug">[] | Error>;
109
170
  resolveLink?: (id: string, draft?: boolean, lang?: string) => Promise<string>;
110
- onCreate?: (data: Omit<ChaiBuilderPage, "seo">) => Promise<void>;
111
- onUpdate?: (data: ChaiBuilderPage) => Promise<void>;
112
- onDelete?: (data: Pick<ChaiBuilderPage, "id">) => Promise<void>;
171
+ onCreate?: (data: Partial<ChaiPage> & {
172
+ id: string;
173
+ }) => Promise<void>;
174
+ onUpdate?: (data: Partial<ChaiPage> & {
175
+ id: string;
176
+ }) => Promise<void>;
177
+ onDelete?: (data: Pick<ChaiPage, "id">) => Promise<void>;
113
178
  dataProvider?: (args: {
114
179
  lang: string;
115
180
  draft: boolean;
116
181
  inBuilder: boolean;
117
182
  pageProps: ChaiPageProps;
118
183
  }) => Promise<Record<string, any>>;
119
- defaultTrackingInfo?: () => Record<string, any>;
120
184
  defaultSeo?: () => Record<string, any>;
121
185
  defaultJSONLD?: () => Record<string, any>;
122
186
  defaultMetaTags?: () => Record<string, string>;
123
187
  };
124
188
 
125
- export declare type ChaiDataProviderArgs<T = Record<string, any>, K = Record<string, any>> = {
126
- block: ChaiBlock<T>;
127
- } & K;
128
-
129
- declare type ChaiDynamicPage = {
130
- id: string;
131
- slug: string;
132
- name: string;
133
- primaryPage?: string;
134
- };
135
-
136
- export declare type ChaiFont = ChaiFontViaUrl | ChaiFontViaSrc;
137
-
138
- export declare type ChaiFontViaSrc = {
139
- family: string;
140
- src: {
141
- url: string;
142
- format: string;
143
- fontWeight?: string;
144
- fontStyle?: string;
145
- fontDisplay?: string;
146
- fontStretch?: string;
147
- }[];
148
- fallback: string;
149
- };
150
-
151
- export declare type ChaiFontViaUrl = {
152
- family: string;
153
- url: string;
154
- fallback: string;
155
- };
156
-
157
- export declare interface ChaiPageProps {
158
- slug: string;
159
- searchParams?: Record<string, string>;
160
- [key: string]: any;
161
- }
162
-
163
- export declare type ChaiRuntimeProp<T> = T | undefined;
164
-
165
- export declare interface ChaiServerBlockDefinition<T = Record<string, any>, K = Record<string, any>> {
189
+ declare interface ChaiServerBlockDefinition<T = Record<string, any>, K = Record<string, any>> {
166
190
  component: default_2.ComponentType<ChaiBlockComponentProps<T>>;
167
191
  type: string;
168
192
  dataProvider?: (args: {
@@ -175,10 +199,6 @@ export declare interface ChaiServerBlockDefinition<T = Record<string, any>, K =
175
199
  suspenseFallback?: default_2.ComponentType<any>;
176
200
  }
177
201
 
178
- export declare type ChaiStyles = {
179
- [key: string]: string;
180
- };
181
-
182
202
  export declare const closestBlockProp: (blockType: keyof typeof REGISTERED_CHAI_BLOCKS, prop: string) => ChaiBlockPropSchema;
183
203
 
184
204
  declare interface CollectionConfig<T> {
@@ -215,7 +235,7 @@ export declare const COLLECTIONS: Record<string, CollectionConfig<any>>;
215
235
 
216
236
  export declare const defaultChaiStyles: (classes: string) => string;
217
237
 
218
- export declare const getAIBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>> | never[];
238
+ export declare const getAIBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => never[] | ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>>;
219
239
 
220
240
  export declare const getAllRegisteredFonts: () => ChaiFont[];
221
241
 
@@ -234,25 +254,19 @@ export declare const getChaiGlobalData: (args: {
234
254
  inBuilder: boolean;
235
255
  }) => Promise<any>;
236
256
 
237
- export declare const getChaiPageType: (key: keyof typeof PAGE_TYPES) => ChaiBuilderPageType;
257
+ export declare const getChaiPageType: (key: keyof typeof PAGE_TYPES) => ChaiPageType;
238
258
 
239
- export declare const getChaiPageTypes: () => ChaiBuilderPageType[];
259
+ export declare const getChaiPageTypes: () => ChaiPageType[];
240
260
 
241
261
  export declare const getDefaultBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => Record<string, any>;
242
262
 
243
- export declare const getI18nBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>> | never[];
263
+ export declare const getI18nBlockProps: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => never[] | ChaiBlockDefinition<Record<string, any>, Record<string, any>> | ChaiServerBlockDefinition<Record<string, any>, Record<string, any>>;
244
264
 
245
265
  export declare const getRegisteredChaiBlock: (type: keyof typeof REGISTERED_CHAI_BLOCKS) => ChaiBlockDefinition | null;
246
266
 
247
267
  export declare const getRegisteredFont: (family: string) => ChaiFont | undefined;
248
268
 
249
- export declare const PAGE_TYPES: Record<string, ChaiBuilderPageType>;
250
-
251
- declare type PageTypeSearchResult = {
252
- id: string;
253
- name: string;
254
- slug?: string;
255
- };
269
+ export declare const PAGE_TYPES: Record<string, ChaiPageType>;
256
270
 
257
271
  export declare const registerChaiBlock: <T extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(component: default_2.ComponentType<ChaiBlockComponentProps<T>>, options: ChaiBlockDefinitionOptions<T, K>) => void;
258
272
 
@@ -268,9 +282,9 @@ export declare const registerChaiGlobalDataProvider: <T>(globalDataProvider: (ar
268
282
  inBuilder: boolean;
269
283
  }) => Promise<T>) => void;
270
284
 
271
- export declare const registerChaiPageType: (key: string, pageTypeOptions: Omit<ChaiBuilderPageType, "key" | "hasSlug">) => void;
285
+ export declare const registerChaiPageType: (key: string, pageTypeOptions: Omit<ChaiPageType, "key" | "hasSlug">) => void;
272
286
 
273
- export declare const registerChaiPartialType: (key: string, pageTypeOptions: Omit<ChaiBuilderPageType, "key">) => void;
287
+ export declare const registerChaiPartialType: (key: string, pageTypeOptions: Omit<ChaiPageType, "key">) => void;
274
288
 
275
289
  export declare const registerChaiServerBlock: <T extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(component: default_2.ComponentType<ChaiBlockComponentProps<T>>, options: Pick<ChaiBlockDefinition<T, K>, "type" | "dataProvider" | "i18nProps" | "aiProps">) => void;
276
290
 
package/dist/runtime.js CHANGED
@@ -1,73 +1,74 @@
1
- import { keys as u, intersection as r, get as c, each as d, isEmpty as p, omit as h } from "lodash-es";
2
- import { b as S, C as $, P as T, a as v, g as A, d as b, f as F, e as I, r as L, c as x, h as G, i as O } from "./register-partial-type-BjtdfKHE.js";
3
- import { s as C } from "./core-Dr7QYemB.js";
4
- import { c as Y, g as K, a as H, b as N, d as V, e as W, r as q, f as z, h as J, i as M, u as Q, j as U } from "./core-Dr7QYemB.js";
5
- import { a as Z, g as ee, r as te, u as re } from "./fonts-DRly3Wzd.js";
6
- const B = C, a = "#styles:", f = (e) => {
7
- const i = ["_type", "_id", "_parent", "_bindings", "_name"], o = ["$loading", "blockProps", "inBuilder", "lang", "draft", "pageProps", "pageData", "children"], t = u(e.properties);
8
- if (r(t, i).length > 0)
9
- throw new Error(`Reserved props are not allowed: ${r(t, i).join(", ")}`);
10
- if (r(t, o).length > 0)
11
- throw new Error(`Runtime props are not allowed in schema: ${r(t, o).join(", ")}`);
12
- const s = c(e, "properties", {}), n = {};
13
- return d(s, (l, g) => {
14
- p(l.ui) || (n[g] = { ...l.ui }, delete s[g].ui);
1
+ import { S as a } from "./STRINGS-BExFecZW.js";
2
+ import { keys as u, intersection as s, get as g, each as d, isEmpty as c, omit as h } from "lodash-es";
3
+ import { b as $, C as T, P as v, a as A, g as b, d as F, f as I, e as L, r as x, c as G, h as O, i as j } from "./register-partial-type-BjtdfKHE.js";
4
+ import { s as C } from "./core-BvsZwF26.js";
5
+ import { c as K, g as H, a as N, b as V, d as W, e as q, r as z, f as J, h as M, i as Q, u as U, j as X } from "./core-BvsZwF26.js";
6
+ import { a as ee, g as re, r as se, u as te } from "./fonts-DRly3Wzd.js";
7
+ const y = C, B = (e) => {
8
+ const i = ["_type", "_id", "_parent", "_bindings", "_name"], o = ["$loading", "blockProps", "inBuilder", "lang", "draft", "pageProps", "pageData", "children"], r = u(e.properties);
9
+ if (s(r, i).length > 0)
10
+ throw new Error(`Reserved props are not allowed: ${s(r, i).join(", ")}`);
11
+ if (s(r, o).length > 0)
12
+ throw new Error(`Runtime props are not allowed in schema: ${s(r, o).join(", ")}`);
13
+ const t = g(e, "properties", {}), n = {};
14
+ return d(t, (l, p) => {
15
+ c(l.ui) || (n[p] = { ...l.ui }, delete t[p].ui);
15
16
  }), {
16
- schema: p(s) ? {} : { ...h(e, ["ui"]) },
17
- uiSchema: { ...c(e, "ui", {}), ...n }
17
+ schema: c(t) ? {} : { ...h(e, ["ui"]) },
18
+ uiSchema: { ...g(e, "ui", {}), ...n }
18
19
  };
19
- }, y = (e = "") => ({
20
+ }, k = (e = "") => (console.warn("StylesProp is deprecated, use stylesProp instead"), {
20
21
  type: "string",
21
22
  styles: !0,
22
23
  default: `${a},${e}`,
23
24
  ui: { "ui:widget": "hidden" }
24
- }), k = (e = "") => ({
25
+ }), S = (e = "") => ({
25
26
  type: "string",
26
27
  styles: !0,
27
28
  default: `${a},${e}`,
28
29
  ui: { "ui:widget": "hidden" }
29
- }), R = (e) => (console.warn("runtimeProp is deprecated, use builderProp instead"), {
30
+ }), w = (e) => (console.warn("runtimeProp is deprecated, use builderProp instead"), {
30
31
  runtime: !0,
31
32
  ...e
32
- }), _ = (e) => ({
33
+ }), R = (e) => ({
33
34
  builderProp: !0,
34
35
  ...e
35
- }), w = (e) => `${a},${e}`;
36
+ }), _ = (e) => `${a},${e}`;
36
37
  export {
37
- S as CHAI_GLOBAL_DATA_PROVIDER,
38
- $ as COLLECTIONS,
39
- T as PAGE_TYPES,
40
- y as StylesProp,
41
- _ as builderProp,
42
- Y as closestBlockProp,
43
- w as defaultChaiStyles,
44
- K as getAIBlockProps,
45
- Z as getAllRegisteredFonts,
46
- H as getBlockFormSchemas,
47
- v as getChaiCollection,
48
- A as getChaiCollections,
49
- b as getChaiGlobalData,
50
- F as getChaiPageType,
51
- I as getChaiPageTypes,
52
- N as getDefaultBlockProps,
53
- V as getI18nBlockProps,
54
- W as getRegisteredChaiBlock,
55
- ee as getRegisteredFont,
56
- q as registerChaiBlock,
57
- f as registerChaiBlockSchema,
58
- L as registerChaiCollection,
59
- te as registerChaiFont,
60
- x as registerChaiGlobalDataProvider,
61
- G as registerChaiPageType,
62
- O as registerChaiPartialType,
63
- z as registerChaiServerBlock,
64
- R as runtimeProp,
65
- J as setChaiBlockComponent,
66
- B as setChaiBlockDataProvider,
38
+ $ as CHAI_GLOBAL_DATA_PROVIDER,
39
+ T as COLLECTIONS,
40
+ v as PAGE_TYPES,
41
+ k as StylesProp,
42
+ R as builderProp,
43
+ K as closestBlockProp,
44
+ _ as defaultChaiStyles,
45
+ H as getAIBlockProps,
46
+ ee as getAllRegisteredFonts,
47
+ N as getBlockFormSchemas,
48
+ A as getChaiCollection,
49
+ b as getChaiCollections,
50
+ F as getChaiGlobalData,
51
+ I as getChaiPageType,
52
+ L as getChaiPageTypes,
53
+ V as getDefaultBlockProps,
54
+ W as getI18nBlockProps,
55
+ q as getRegisteredChaiBlock,
56
+ re as getRegisteredFont,
57
+ z as registerChaiBlock,
58
+ B as registerChaiBlockSchema,
59
+ x as registerChaiCollection,
60
+ se as registerChaiFont,
61
+ G as registerChaiGlobalDataProvider,
62
+ O as registerChaiPageType,
63
+ j as registerChaiPartialType,
64
+ J as registerChaiServerBlock,
65
+ w as runtimeProp,
66
+ M as setChaiBlockComponent,
67
+ y as setChaiBlockDataProvider,
67
68
  C as setChaiServerBlockDataProvider,
68
- k as stylesProp,
69
- M as syncBlocksWithDefaults,
70
- Q as useRegisteredChaiBlock,
71
- U as useRegisteredChaiBlocks,
72
- re as useRegisteredFonts
69
+ S as stylesProp,
70
+ Q as syncBlocksWithDefaults,
71
+ U as useRegisteredChaiBlock,
72
+ X as useRegisteredChaiBlocks,
73
+ te as useRegisteredFonts
73
74
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  import { B as b, z as L } from "./register-chai-top-bar-CX_JkRJn.js";
3
- import { c as j, a6 as se, a7 as ie, P as oe, az as le, ai as ce, aA as de, L as P } from "./index-BK0xWO1z.js";
4
- import { ar as D, as as G, A as _, ay as ue } from "./index-D5d4QDq7.js";
3
+ import { c as j, a6 as se, a7 as ie, P as oe, az as le, ai as ce, aA as de, L as P } from "./index-mjuSGlPU.js";
4
+ import { ar as D, as as G, A as _, ay as ue } from "./index-Be9lAaD7.js";
5
5
  import { useQuery as K, useMutation as U, useQueryClient as me } from "@tanstack/react-query";
6
6
  import { toast as N } from "sonner";
7
7
  import { Trash2 as Y, Plus as pe, ImageIcon as fe, X as he, AlertCircle as ge } from "lucide-react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./register-chai-top-bar-DWTuRU53.cjs"),b=require("./index-Bm8iS2OH.cjs"),x=require("./index-BRJCj7c_.cjs"),C=require("@tanstack/react-query"),j=require("sonner"),E=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{s?s():j.toast.success("Block deleted successfully")},onError:t=>{console.error("Error deleting block:",t),j.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[d,o]=i.useState(!1),c=b.useUpdateBlocksPropsRealtime(),y=ee(()=>{c([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),y.mutate(r)},g=e.jsxs(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:d,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(b.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(b.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(b.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(u.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:d,children:"Cancel"}),e.jsx(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:d,children:d?"Deleting...":"Delete"})]})]})})]})},se=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:m="",close:f})=>{const[d,o]=i.useState(!1);return e.jsx(te,{blockId:s,libBlockId:r,isOpen:d,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(u.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},re=()=>{const s=x.useApiUrl(),r=x.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:m,error:f}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(c){return console.error("Error fetching library groups:",c),[]}}}),{mutateAsync:d,isPending:o}=C.useMutation({mutationFn:async c=>{if(!c.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:c}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:c=>{console.error("Error creating group:",c),j.toast.error("Failed to create group",{description:c instanceof Error?c.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:d,isCreating:o}},ne=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),d=i.useRef(null),{groups:o}=re(),[c,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...c.filter(n=>!o.some(B=>B.id===n.id))],[o,c]),g=()=>{const n=m.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),f(""),t(!1)};i.useEffect(()=>{l&&d.current&&d.current.focus()},[l]);const h=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!p.some(n=>n.id===s)&&r("")},[s,p,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(u.Input,{ref:d,placeholder:"Enter new group name",value:m,onChange:n=>f(n.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(u.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),c.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:c.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(u.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async c=>{var p;const y=(p=c.target.files)==null?void 0:p[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(y));const h=new FileReader;h.onloadend=()=>{r(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),d=()=>{r(""),m.current&&(m.current.value="")},o=()=>{var c;(c=m.current)==null||c.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(u.Button,{type:"button",variant:"outline",size:"icon",onClick:d,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:m}=b.usePartialBlocksStore(),f=r.find(a=>a._id===t),d=f==null?void 0:f._libBlockId,o=!!d,c=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const v of r)if(v._type==="PartialBlock"||v._type==="GlobalBlock"){let k=m(v.partialBlockId);v._parent&&(k==null?void 0:k.length)>0&&(k=k.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",v._parent),T))),a=[...a,...k]}else a.push(v);return a},[r,m]),[p,g]=i.useState(""),[h,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=b.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=b.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=Z(d);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=p.trim().length>=2,v=h.trim()!=="";M(a&&v)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=b.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const v=y.map(k=>(R.has(k,"_libBlockId")&&delete k._libBlockId,k));U.mutate({name:p.trim(),group:h,blocks:v,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:d}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(u.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[c&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(u.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(u.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:d,blockName:p,className:"mr-auto",close:l}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(u.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./register-chai-top-bar-DWTuRU53.cjs"),b=require("./index-BhqugjzS.cjs"),x=require("./index-CNEEEgTV.cjs"),C=require("@tanstack/react-query"),j=require("sonner"),E=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{s?s():j.toast.success("Block deleted successfully")},onError:t=>{console.error("Error deleting block:",t),j.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[d,o]=i.useState(!1),c=b.useUpdateBlocksPropsRealtime(),y=ee(()=>{c([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),y.mutate(r)},g=e.jsxs(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:d,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(b.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(b.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(b.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(u.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:d,children:"Cancel"}),e.jsx(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:d,children:d?"Deleting...":"Delete"})]})]})})]})},se=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:m="",close:f})=>{const[d,o]=i.useState(!1);return e.jsx(te,{blockId:s,libBlockId:r,isOpen:d,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(u.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},re=()=>{const s=x.useApiUrl(),r=x.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:m,error:f}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(c){return console.error("Error fetching library groups:",c),[]}}}),{mutateAsync:d,isPending:o}=C.useMutation({mutationFn:async c=>{if(!c.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:c}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:c=>{console.error("Error creating group:",c),j.toast.error("Failed to create group",{description:c instanceof Error?c.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:d,isCreating:o}},ne=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),d=i.useRef(null),{groups:o}=re(),[c,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...c.filter(n=>!o.some(B=>B.id===n.id))],[o,c]),g=()=>{const n=m.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),f(""),t(!1)};i.useEffect(()=>{l&&d.current&&d.current.focus()},[l]);const h=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!p.some(n=>n.id===s)&&r("")},[s,p,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(u.Input,{ref:d,placeholder:"Enter new group name",value:m,onChange:n=>f(n.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(u.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),c.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:c.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(u.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async c=>{var p;const y=(p=c.target.files)==null?void 0:p[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(y));const h=new FileReader;h.onloadend=()=>{r(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),d=()=>{r(""),m.current&&(m.current.value="")},o=()=>{var c;(c=m.current)==null||c.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(u.Button,{type:"button",variant:"outline",size:"icon",onClick:d,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:m}=b.usePartialBlocksStore(),f=r.find(a=>a._id===t),d=f==null?void 0:f._libBlockId,o=!!d,c=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const v of r)if(v._type==="PartialBlock"||v._type==="GlobalBlock"){let k=m(v.partialBlockId);v._parent&&(k==null?void 0:k.length)>0&&(k=k.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",v._parent),T))),a=[...a,...k]}else a.push(v);return a},[r,m]),[p,g]=i.useState(""),[h,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=b.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=b.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=Z(d);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=p.trim().length>=2,v=h.trim()!=="";M(a&&v)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=b.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const v=y.map(k=>(R.has(k,"_libBlockId")&&delete k._libBlockId,k));U.mutate({name:p.trim(),group:h,blocks:v,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:d}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(u.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[c&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(u.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(u.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:d,blockName:p,className:"mr-auto",close:l}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(u.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
@@ -7,14 +7,14 @@ import { StickToBottom as R, useStickToBottomContext as Q } from "use-stick-to-b
7
7
  import { Streamdown as y } from "streamdown";
8
8
  import "@radix-ui/react-slot";
9
9
  import { cva as F } from "class-variance-authority";
10
- import { ao as K } from "./index-BK0xWO1z.js";
10
+ import { ao as K } from "./index-mjuSGlPU.js";
11
11
  import "clsx";
12
12
  import "tailwind-merge";
13
13
  import * as A from "@radix-ui/react-tooltip";
14
14
  import { useControllableState as w } from "@radix-ui/react-use-controllable-state";
15
15
  import * as x from "@radix-ui/react-collapsible";
16
16
  import { motion as V } from "framer-motion";
17
- import { L as h } from "./index-D5d4QDq7.js";
17
+ import { L as h } from "./index-Be9lAaD7.js";
18
18
  import { useTranslation as Y } from "react-i18next";
19
19
  const Te = ({ className: e, ...t }) => /* @__PURE__ */ o(
20
20
  R,