@chaibuilder/sdk 3.2.8 → 4.0.0-beta.2

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 (184) hide show
  1. package/README.md +25 -20
  2. package/dist/2SSKDMRQ-C4VFVd-q.cjs +1 -0
  3. package/dist/2SSKDMRQ-DSnzF_1o.js +42 -0
  4. package/dist/AP7HFJJL-B7YYCY9q.cjs +1228 -0
  5. package/dist/AP7HFJJL-Cxwj01Aq.js +9214 -0
  6. package/dist/IconPicker-C9-ieDWm.cjs +1 -0
  7. package/dist/IconPicker-RqVvq6G2.js +59 -0
  8. package/dist/WDYDFRGG-C7aSUcjs.js +33 -0
  9. package/dist/WDYDFRGG-b3T2SQbz.cjs +1 -0
  10. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  11. package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
  12. package/dist/actions-registery-CZ1w0NKa.js +15545 -0
  13. package/dist/actions-registery-YnFmU21O.cjs +418 -0
  14. package/dist/actions.cjs +1 -0
  15. package/dist/actions.d.ts +3202 -0
  16. package/dist/actions.js +216 -0
  17. package/dist/active-in-another-tab-Clng6zpY.cjs +1 -0
  18. package/dist/active-in-another-tab-wb8qolB8.js +34 -0
  19. package/dist/add-new-language-page-C4BuMTaN.cjs +1 -0
  20. package/dist/add-new-language-page-D7NDABl1.js +401 -0
  21. package/dist/add-new-page-B4hc0B-g.js +31 -0
  22. package/dist/add-new-page-BNfwKjRd.cjs +1 -0
  23. package/dist/ai-panel-content-BnbURb7j.js +61 -0
  24. package/dist/ai-panel-content-DPy2jgKw.cjs +1 -0
  25. package/dist/ai-panel-default-lang-3tCHzab5.cjs +3 -0
  26. package/dist/ai-panel-default-lang-oVk4TDeb.js +341 -0
  27. package/dist/ai-panel-other-lang-BBHCCSen.cjs +1 -0
  28. package/dist/ai-panel-other-lang-DmQ3QMDD.js +162 -0
  29. package/dist/ai-prompt-input-DaTyfib-.js +655 -0
  30. package/dist/ai-prompt-input-b5ty81RB.cjs +1 -0
  31. package/dist/ai-translation-prompt-DJPe2O-n.js +28 -0
  32. package/dist/ai-translation-prompt-c0Q3zkT2.cjs +1 -0
  33. package/dist/{apply-binding-DLaiD20q.js → apply-binding-6iwlED02.js} +156 -166
  34. package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
  35. package/dist/{code-display-DuH-UOhl.js → code-display-BzBq5xSn.js} +1 -1
  36. package/dist/code-display-Q3_sK_Ta.cjs +1 -0
  37. package/dist/code-editor-BQZi6-FB.cjs +1 -0
  38. package/dist/code-editor-DWWnphW9.js +50 -0
  39. package/dist/continue-editing-in-this-client-BllU94XG.js +24 -0
  40. package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +1 -0
  41. package/dist/core-BoRDjj4h.cjs +1 -0
  42. package/dist/core-yvI6kCyw.js +56 -0
  43. package/dist/core.cjs +1 -1
  44. package/dist/core.d.ts +2 -393
  45. package/dist/core.js +37 -105
  46. package/dist/css-import-modal-BSMGKA2T.cjs +13 -0
  47. package/dist/{css-import-modal-CFB2YjDT.js → css-import-modal-D72a-16X.js} +39 -38
  48. package/dist/{delete-design-token-BjMakV-b.js → delete-design-token-Cd1ZDtqT.js} +3 -3
  49. package/dist/delete-design-token-D_TLlO3I.cjs +1 -0
  50. package/dist/delete-page-ByQwBupJ.cjs +1 -0
  51. package/dist/delete-page-DC8pzvWW.js +70 -0
  52. package/dist/design-token-usage-BqZeR1sT.cjs +1 -0
  53. package/dist/design-token-usage-DE4XCDdn.js +113 -0
  54. package/dist/digital-asset-manager-BYLKFEYi.cjs +1 -0
  55. package/dist/digital-asset-manager-C_gL_0YY.js +876 -0
  56. package/dist/duplicate-page-BoVhko2q.js +133 -0
  57. package/dist/duplicate-page-vdvwLQLo.cjs +1 -0
  58. package/dist/dynamic-page-selector-CSndg2-y.js +85 -0
  59. package/dist/dynamic-page-selector-DdnbCuQZ.cjs +1 -0
  60. package/dist/fonts-B-Xt29pe.cjs +1 -0
  61. package/dist/fonts-DRly3Wzd.js +78 -0
  62. package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
  63. package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
  64. package/dist/get-chai-builder-theme-BYtp20KD.js +24 -0
  65. package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
  66. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  67. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  68. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  69. package/dist/image-compression-DsZ1oqpb.js +37 -0
  70. package/dist/image-editor-DTspjj_c.cjs +1 -0
  71. package/dist/image-editor-oypq8asR.js +108 -0
  72. package/dist/index-B-rSiAp_.cjs +1 -0
  73. package/dist/index-BDnwJqMw.js +4732 -0
  74. package/dist/index-CbwxUFy_.cjs +5 -0
  75. package/dist/index-CnSjWE1P.cjs +160 -0
  76. package/dist/index-Dxfyt4d4.js +39 -0
  77. package/dist/index-S8ibZk9Q.js +19069 -0
  78. package/dist/json-diff-viewer-B5dr-Y_L.js +258 -0
  79. package/dist/json-diff-viewer-XX1pgabt.cjs +8 -0
  80. package/dist/lang-panel-BPxex-M2.cjs +1 -0
  81. package/dist/lang-panel-Cn83SRzd.js +215 -0
  82. package/dist/manage-design-tokens-ConiyuPr.cjs +1 -0
  83. package/dist/{manage-design-tokens-DUoMdCBl.js → manage-design-tokens-lP4HLS0P.js} +31 -32
  84. package/dist/mark-as-template-DYRxre1f.cjs +1 -0
  85. package/dist/mark-as-template-jncsjfHm.js +156 -0
  86. package/dist/models-5gOsRC56.cjs +1 -0
  87. package/dist/models-D95ZYr_x.js +70 -0
  88. package/dist/nested-path-selector-content-B-8LqhXI.js +87 -0
  89. package/dist/nested-path-selector-content-BYtLi7mC.cjs +1 -0
  90. package/dist/no-language-page-content-DAbLq0gX.cjs +1 -0
  91. package/dist/no-language-page-content-D_zd9Rb0.js +42 -0
  92. package/dist/no-language-page-dialog-C5Ps6YYL.js +10 -0
  93. package/dist/no-language-page-dialog-fXmbQO7L.cjs +1 -0
  94. package/dist/page-creator-VWIB2VAs.cjs +1 -0
  95. package/dist/page-creator-wCMtlE6Z.js +795 -0
  96. package/dist/page-lock-BPCxfv9J.js +30 -0
  97. package/dist/page-lock-DweiYy1w.cjs +1 -0
  98. package/dist/page-locked-dialog-BlbgvaG2.cjs +1 -0
  99. package/dist/page-locked-dialog-ByGl18_m.js +133 -0
  100. package/dist/page-manager-new-BWFE-S-O.js +394 -0
  101. package/dist/page-manager-new-D0lGfNnS.cjs +1 -0
  102. package/dist/page-manager-search-and-filter-DpGMoOII.cjs +1 -0
  103. package/dist/page-manager-search-and-filter-kNJFWJ86.js +201 -0
  104. package/dist/page-revisions-content-DYxXZqmh.cjs +1 -0
  105. package/dist/page-revisions-content-Ulr8slUN.js +445 -0
  106. package/dist/pages.cjs +1 -0
  107. package/dist/pages.d.ts +492 -0
  108. package/dist/pages.js +27 -0
  109. package/dist/{plugin-BOcGV_IY.js → plugin-3ZKK6RXm.js} +30 -44
  110. package/dist/plugin-C6rgJDNQ.cjs +22 -0
  111. package/dist/publish-pages-content-BTPzt_m4.js +178 -0
  112. package/dist/publish-pages-content-D6g8GAsd.cjs +1 -0
  113. package/dist/register-partial-type-BjtdfKHE.js +36 -0
  114. package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
  115. package/dist/render.cjs +2 -2
  116. package/dist/render.d.ts +12 -9
  117. package/dist/render.js +97 -99
  118. package/dist/rte-widget-modal-DrMzWWjw.cjs +1 -0
  119. package/dist/rte-widget-modal-Rk_NW3KU.js +38 -0
  120. package/dist/runtime.cjs +1 -1
  121. package/dist/runtime.d.ts +306 -7
  122. package/dist/runtime.js +44 -1
  123. package/dist/save-to-lib-BK3uTFss.js +422 -0
  124. package/dist/save-to-lib-DHHUO12i.cjs +1 -0
  125. package/dist/sdk.css +1 -1
  126. package/dist/selected-block-display-CU3TwIMA.js +319 -0
  127. package/dist/selected-block-display-DSFhddPj.cjs +16 -0
  128. package/dist/seo-panel-Dl0IDV09.cjs +2 -0
  129. package/dist/seo-panel-jbzxFioc.js +798 -0
  130. package/dist/shared-json-ld-BL_dv3_q.js +565 -0
  131. package/dist/shared-json-ld-DPNkqDC1.cjs +1 -0
  132. package/dist/slug-input-1qwKkXhA.js +86 -0
  133. package/dist/slug-input-YVLjtTI3.cjs +1 -0
  134. package/dist/supabase-actions.cjs +1 -0
  135. package/dist/supabase-actions.d.ts +284 -0
  136. package/dist/supabase-actions.js +524 -0
  137. package/dist/take-over-request-DKvKi3mM.js +63 -0
  138. package/dist/take-over-request-DvMIg_cZ.cjs +1 -0
  139. package/dist/theme-panel-footer-BMOaPLWc.cjs +1 -0
  140. package/dist/theme-panel-footer-DbMDLYGI.js +25 -0
  141. package/dist/translation-warning-modal-9wTwIy_9.js +26 -0
  142. package/dist/translation-warning-modal-DjTwz75c.cjs +1 -0
  143. package/dist/unmark-as-template-CdqIJJER.cjs +1 -0
  144. package/dist/unmark-as-template-Dulvf7Zw.js +39 -0
  145. package/dist/unpublish-page-BwSVBf0_.cjs +1 -0
  146. package/dist/unpublish-page-Degu5Cy9.js +27 -0
  147. package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
  148. package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
  149. package/dist/utils.cjs +1 -0
  150. package/dist/{tailwind.d.ts → utils.d.ts} +4 -7
  151. package/dist/utils.js +7 -0
  152. package/dist/web-blocks.cjs +1 -1
  153. package/dist/web-blocks.d.ts +0 -6
  154. package/dist/web-blocks.js +48 -47
  155. package/dist/web-preview-DXE4Jnf5.js +73 -0
  156. package/dist/web-preview-YzKxyXft.cjs +1 -0
  157. package/package.json +159 -89
  158. package/dist/IconPicker-6JSublJp.js +0 -64
  159. package/dist/IconPicker-DpQQDK_Q.cjs +0 -1
  160. package/dist/apply-binding-Bn1KC8uC.cjs +0 -1
  161. package/dist/code-display-Dw1tAwiJ.cjs +0 -1
  162. package/dist/code-editor-cnBzYLxk.cjs +0 -1
  163. package/dist/code-editor-vpbOSO05.js +0 -59
  164. package/dist/css-import-modal-bGWZSlqv.cjs +0 -13
  165. package/dist/delete-design-token-Bzxspf8D.cjs +0 -1
  166. package/dist/design-token-usage-BDArZ38H.js +0 -120
  167. package/dist/design-token-usage-CCv4XltM.cjs +0 -1
  168. package/dist/get-chai-builder-theme-B1tr_NJB.cjs +0 -1
  169. package/dist/get-chai-builder-theme-BarMkcGH.js +0 -12
  170. package/dist/index-CuANr9iH.cjs +0 -160
  171. package/dist/index-DvdOXKUE.js +0 -18338
  172. package/dist/manage-design-tokens-DpC46NAy.cjs +0 -1
  173. package/dist/mockServiceWorker.js +0 -349
  174. package/dist/plugin-CSgw-f78.cjs +0 -22
  175. package/dist/rte-widget-modal-CXbmmhcb.js +0 -41
  176. package/dist/rte-widget-modal-DDjf0xui.cjs +0 -1
  177. package/dist/tailwind.cjs +0 -1
  178. package/dist/tailwind.js +0 -8
  179. package/dist/tooltip-Ba1-8jmj.cjs +0 -1
  180. package/dist/tooltip-DUosa-uC.js +0 -1067
  181. package/dist/ui.cjs +0 -1
  182. package/dist/ui.d.ts +0 -415
  183. package/dist/ui.js +0 -129
  184. package/dist/vite.svg +0 -1
package/dist/core.d.ts CHANGED
@@ -5,15 +5,6 @@ import { DragEvent as DragEvent_2 } from 'react';
5
5
  import { default as i18n } from 'i18next';
6
6
  import { JSX } from 'react/jsx-runtime';
7
7
  import * as React_2 from 'react';
8
- import { ReactNode } from 'react';
9
- import { RESET } from 'jotai/utils';
10
- import { ThrottledFunction } from '@react-hookz/web';
11
- import { useTranslation } from 'react-i18next';
12
-
13
- declare type AddBlocks = {
14
- addCoreBlock: any;
15
- addPredefinedBlock: any;
16
- };
17
8
 
18
9
  declare type AddBlockTab = {
19
10
  id: string;
@@ -41,8 +32,6 @@ declare type Breakpoint = {
41
32
  width: number;
42
33
  };
43
34
 
44
- export declare type BreakpointName = "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
45
-
46
35
  export declare const ChaiAddBlocksDialog: () => JSX.Element;
47
36
 
48
37
  export declare const ChaiAddBlocksPanel: ({ className, showHeading, parentId, position, fromSidebar, }: {
@@ -70,7 +59,6 @@ export declare type ChaiBlock<T = Record<string, any>> = {
70
59
  _id: string;
71
60
  _name?: string;
72
61
  _parent?: string | null | undefined;
73
- _bindings?: Record<string, string>;
74
62
  _type: string;
75
63
  _libBlock?: string;
76
64
  } & T;
@@ -78,11 +66,10 @@ export declare type ChaiBlock<T = Record<string, any>> = {
78
66
  declare type ChaiBlock_2<T = Record<string, any>> = {
79
67
  _id: string;
80
68
  _name?: string;
81
- _parent?: string | null | undefined;
82
- _bindings?: Record<string, string>;
69
+ _parent?: string;
83
70
  _libBlock?: string;
84
71
  _type: string;
85
- _partialBlockId?: string;
72
+ partialBlockId?: string;
86
73
  } & T;
87
74
 
88
75
  export declare const ChaiBlockAttributesEditor: React_2.MemoExoticComponent<() => JSX.Element>;
@@ -358,12 +345,6 @@ declare type ChaiDraggableBlockProps = {
358
345
 
359
346
  export declare const ChaiExportCodeModal: () => JSX.Element;
360
347
 
361
- declare type ChaiFlagOptions = {
362
- key: string;
363
- value?: any;
364
- description?: string;
365
- };
366
-
367
348
  export declare const ChaiImportHTML: ({ parentId, position, fromSidebar, }: {
368
349
  parentId?: string;
369
350
  position?: number;
@@ -464,26 +445,6 @@ export declare const ChaiUILibrariesPanel: ({ parentId, position, fromSidebar, }
464
445
 
465
446
  export declare const ChaiUndoRedo: () => JSX.Element;
466
447
 
467
- declare type ClassDerivedObject = {
468
- cls: string;
469
- dark: boolean;
470
- fullCls: string;
471
- mod: string;
472
- mq: string;
473
- property: string;
474
- };
475
-
476
- declare type CodeEditorProps = {
477
- blockId: string;
478
- blockProp: string;
479
- initialCode: string;
480
- placeholder?: string;
481
- };
482
-
483
- declare type CopiedValue = string | null;
484
-
485
- declare type CopyFn = (text: string) => Promise<boolean>;
486
-
487
448
  declare interface DesignTokens {
488
449
  [uniqueId: string]: {
489
450
  name: string;
@@ -491,8 +452,6 @@ declare interface DesignTokens {
491
452
  };
492
453
  }
493
454
 
494
- declare type ExcludedBuilderProps = "blocks" | "subPages" | "brandingOptions" | "dataProviders";
495
-
496
455
  declare type FilterOptions = {
497
456
  id: string;
498
457
  name: string;
@@ -530,11 +489,6 @@ declare type HTMLString = string;
530
489
 
531
490
  export { i18n }
532
491
 
533
- export declare const IfChaiFeatureFlag: ({ flagKey, children }: {
534
- flagKey: string;
535
- children: React.ReactNode;
536
- }) => ReactNode;
537
-
538
492
  declare type MediaManagerProps = {
539
493
  assetId?: string;
540
494
  close: () => void;
@@ -544,11 +498,6 @@ declare type MediaManagerProps = {
544
498
 
545
499
  export declare const mergeClasses: (...inputs: ClassValue[]) => string;
546
500
 
547
- declare type Options = {
548
- blockId?: string;
549
- additionalCoreBlocks?: string[];
550
- };
551
-
552
501
  declare type PageType = {
553
502
  key: string;
554
503
  name: string;
@@ -560,12 +509,6 @@ declare type PageTypeItem = {
560
509
  slug?: string;
561
510
  };
562
511
 
563
- declare type PartialBlockList = Record<string, {
564
- name?: string;
565
- description?: string;
566
- type?: string;
567
- }>;
568
-
569
512
  export declare const PERMISSIONS: {
570
513
  ADD_BLOCK: string;
571
514
  DELETE_BLOCK: string;
@@ -591,10 +534,6 @@ export declare const registerBlockSettingWidget: (id: string, component: React.C
591
534
 
592
535
  export declare const registerChaiAddBlockTab: (id: string, tab: Omit<AddBlockTab, "id">) => void;
593
536
 
594
- export declare const registerChaiFeatureFlag: (key: string, flagOptions: Omit<ChaiFlagOptions, "key">) => void;
595
-
596
- export declare const registerChaiFeatureFlags: (flags: Record<string, Omit<ChaiFlagOptions, "key">>) => void;
597
-
598
537
  export declare const registerChaiLibrary: <T extends Record<string, any> = Record<string, any>>(id: string, library: Omit<ChaiLibraryConfig<T>, "id">) => void;
599
538
 
600
539
  export declare const registerChaiMediaManager: (component: React.ComponentType<MediaManagerProps>) => void;
@@ -654,338 +593,8 @@ declare interface ThemeConfigProps {
654
593
  className?: string;
655
594
  }
656
595
 
657
- declare type TStyleBlock = {
658
- blockId: string;
659
- id: string;
660
- prop: string;
661
- };
662
-
663
- export declare const useActiveSettingsTab: () => ["styles" | "settings", (args_0: "styles" | "settings" | ((prev: "styles" | "settings") => "styles" | "settings")) => void];
664
-
665
- export declare const useAddBlock: () => AddBlocks;
666
-
667
- export declare const useAddClassesToBlocks: () => (blockIds: Array<string>, newClasses: Array<string>, undo?: boolean) => void;
668
-
669
- export declare const useAskAi: () => {
670
- askAi: (type: "styles" | "content", blockId: string, prompt: string, onComplete?: (response?: AskAiResponse) => void) => Promise<void>;
671
- loading: boolean;
672
- error: any;
673
- };
674
-
675
- export declare const useBlockHighlight: () => {
676
- highlightBlock: (elementOrID: HTMLElement | string) => void;
677
- clearHighlight: () => void;
678
- lastHighlighted: HTMLElement;
679
- };
680
-
681
- export declare const useBlocksHtmlForAi: () => (options?: Options) => any;
682
-
683
- export declare const useBlocksStore: () => [any[], (args_0: any[] | ((prev: any[]) => any[])) => void];
684
-
685
- export declare const useBlocksStoreUndoableActions: () => {
686
- moveBlocks: (blockIds: string[], parent: string | undefined, position: number) => void;
687
- addBlocks: (newBlocks: ChaiBlock[], parent?: string, position?: number) => void;
688
- removeBlocks: (blocks: ChaiBlock[]) => void;
689
- updateBlocks: (blockIds: string[], props: Partial<ChaiBlock>, oldPropsState?: Partial<ChaiBlock>) => void;
690
- updateBlocksRuntime: (blockIds: string[], props: Record<string, any>) => void;
691
- setNewBlocks: (newBlocks: ChaiBlock[]) => void;
692
- updateMultipleBlocksProps: (blocks: Array<{
693
- _id: string;
694
- } & Partial<ChaiBlock>>) => void;
695
- };
696
-
697
- /**
698
- * Wrapper around useAtom
699
- */
700
- export declare const useBrandingOptions: () => readonly [{
701
- bodyFont: string;
702
- headingFont: string;
703
- roundedCorners: number;
704
- primaryColor: string;
705
- secondaryColor: string;
706
- bodyBgDarkColor: string;
707
- bodyBgLightColor: string;
708
- bodyTextDarkColor: string;
709
- bodyTextLightColor: string;
710
- }, (args_0: any) => void];
711
-
712
- export declare const useBuilderProp: <T>(propKey: keyof Omit<ChaiBuilderEditorProps, ExcludedBuilderProps> | "languages" | string, defaultValue?: T) => T;
713
-
714
- export declare const useBuilderReset: () => () => void;
715
-
716
- export declare const useCanvasDisplayWidth: () => readonly [number, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
717
-
718
- export declare const useCanvasWidth: () => readonly [number, BreakpointName];
719
-
720
- /**
721
- * Wrapper hook around useAtom
722
- */
723
- export declare const useCanvasZoom: () => [number, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
724
-
725
- export declare const useChaiFeatureFlag: (flagKey: string) => boolean;
726
-
727
- export declare const useChaiFeatureFlags: () => Record<string, ChaiFlagOptions>;
728
-
729
- /**
730
- * Custom hook to access the current state of the code editor.
731
- * @category Hooks
732
- * @returns The current state of the code editor from the `codeEditorAtom`.
733
- */
734
- export declare const useCodeEditor: () => [CodeEditorProps, never];
735
-
736
- export declare const useCopyBlockIds: () => [Array<string>, (blockIds: Array<string>, clonePartialBlocks?: boolean) => void, (blockIds: Array<string>) => boolean];
737
-
738
- export declare const useCopyToClipboard: () => [CopiedValue, CopyFn];
739
-
740
- export declare const useCurrentPage: () => {
741
- currentPage: unknown;
742
- };
743
-
744
- export declare const useCutBlockIds: () => [Array<string>, Function];
745
-
746
- /**
747
- * Wrapper hook around useAtom
748
- */
749
- export declare const useDarkMode: () => [boolean, Function];
750
-
751
- /**
752
- * useDuplicateBlock
753
- */
754
- export declare const useDuplicateBlocks: () => Function;
755
-
756
- /**
757
- *
758
- */
759
- export declare const useHighlightBlockId: () => [string, Function];
760
-
761
- export declare const useHtmlToBlocks: () => (html: string) => ChaiBlock[];
762
-
763
- export declare const useI18nBlocks: () => (lang?: string | "ALL") => Pick<any, "_id">[];
764
-
765
- export declare const useInlineEditing: () => {
766
- editingBlockId: string;
767
- editingItemIndex: number;
768
- setEditingBlockId: (args_0: string | ((prev: string) => string)) => void;
769
- setEditingItemIndex: (args_0: number | ((prev: number) => number)) => void;
770
- };
771
-
772
- export declare const useIsPageLoaded: () => [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
773
-
774
- export declare const useLanguages: () => {
775
- languages: any[];
776
- fallbackLang: string;
777
- selectedLang: string;
778
- setSelectedLang: (lang: string) => void;
779
- };
780
-
781
- export declare const useLibraryBlocks: (library?: Partial<ChaiLibrary> & {
782
- id: string;
783
- }) => {
784
- data: any;
785
- isLoading: boolean;
786
- resetLibrary: (libraryId: string) => void;
787
- };
788
-
789
596
  export declare const useMediaManagerComponent: () => ComponentType<MediaManagerProps>;
790
597
 
791
- export declare const usePartailBlocksStore: () => {
792
- getPartailBlocks: (partailBlock: string) => any[] | ChaiBlock[];
793
- reset: () => void;
794
- };
795
-
796
- export declare const usePartialBlocksList: () => {
797
- data: PartialBlockList;
798
- isLoading: boolean;
799
- refetch: () => Promise<void>;
800
- error: string;
801
- };
802
-
803
- export declare const usePasteBlocks: () => {
804
- canPaste: (newParentId: string) => Promise<boolean>;
805
- pasteBlocks: (newParentId: string | string[]) => Promise<void>;
806
- };
807
-
808
- export declare const usePermissions: () => {
809
- hasPermission: (permission: string) => any;
810
- };
811
-
812
- /**
813
- *
814
- */
815
- export declare const usePreviewMode: () => [boolean, Function];
816
-
817
- export declare function usePubSub<T>(eventName: string, callback: (data?: T) => void): void;
818
-
819
- export declare const useRemoveAllClassesForBlock: () => (block: ChaiBlock, undo?: boolean) => void;
820
-
821
- export declare const useRemoveBlocks: () => (blockIds: Array<string>) => void;
822
-
823
- export declare const useRemoveClassesFromBlocks: () => Function;
824
-
825
- export declare const useReplaceBlock: () => (blockId: string | undefined, replacementBlocks: ChaiBlock[]) => void;
826
-
827
- /**
828
- * useResetBlockStyles
829
- *
830
- * Provides helper functions to reset style props of the currently selected block.
831
- *
832
- * resetAll(): resets every style prop of the current block back to its default value.
833
- * reset(styleId): resets a single style prop back to its default value.
834
- */
835
- export declare const useResetBlockStyles: () => {
836
- readonly resetAll: () => void;
837
- readonly reset: (styleId: string) => void;
838
- };
839
-
840
- export declare const useRightPanel: () => ["block" | "theme" | "ai" | "settings" | "design-tokens", (args_0: "block" | "theme" | "ai" | "settings" | "design-tokens" | ((prev: "block" | "theme" | "ai" | "settings" | "design-tokens") => "block" | "theme" | "ai" | "settings" | "design-tokens")) => void];
841
-
842
- export declare const useSavePage: () => {
843
- savePage: ThrottledFunction<(autoSave?: boolean, force?: boolean) => Promise<boolean>>;
844
- savePageAsync: (force?: boolean) => Promise<boolean>;
845
- saveState: "SAVED" | "SAVING" | "UNSAVED";
846
- setSaveState: (args_0: "SAVED" | "SAVING" | "UNSAVED" | ((prev: "SAVED" | "SAVING" | "UNSAVED") => "SAVED" | "SAVING" | "UNSAVED")) => void;
847
- needTranslations: () => boolean;
848
- };
849
-
850
- /**
851
- *
852
- */
853
- export declare const useScreenSizeWidth: () => readonly [number, string, (args_0: number | RESET | ((prev: number) => number | RESET)) => void];
854
-
855
- /**
856
- * useSelectedBlock hook
857
- */
858
- export declare const useSelectedBlock: () => ChaiBlock;
859
-
860
- export declare const useSelectedBlockAllClasses: () => Array<ClassDerivedObject>;
861
-
862
- export declare const useSelectedBlockCurrentClasses: () => Array<ClassDerivedObject>;
863
-
864
- /**
865
- *
866
- */
867
- export declare const useSelectedBlockIds: () => readonly [string[], (args_0: string[] | ((prev: string[]) => string[])) => void, (blockId: string) => void];
868
-
869
- /**
870
- * Hook to get selected block ids
871
- */
872
- export declare const useSelectedBlocksDisplayChild: () => {
873
- flexChild: boolean;
874
- gridChild: boolean;
875
- };
876
-
877
- export declare const useSelectedBreakpoints: () => [string[], Function];
878
-
879
- /**
880
- * Hook to get and set the selected UI library
881
- * @returns {[string, (library: string) => void]} A tuple containing the selected library ID and a function to set the selected library
882
- */
883
- export declare const useSelectedLibrary: () => [string, (args_0: string | RESET | ((prev: string) => string | RESET)) => void];
884
-
885
- /**
886
- * @group Hooks
887
- * @returns {TStyleBlock[]} selected styling blocks
888
- */
889
- export declare const useSelectedStylingBlocks: () => [TStyleBlock[], (args_0: TStyleBlock[] | ((prev: TStyleBlock[]) => TStyleBlock[])) => void];
890
-
891
- export declare const useSidebarActivePanel: () => [string, (args_0: string | ((prev: string) => string)) => void];
892
-
893
- export declare const useStreamMultipleBlocksProps: () => (blocks: Array<{
894
- _id: string;
895
- } & Partial<ChaiBlock>>) => Promise<void>;
896
-
897
- export declare const useStylingBreakpoint: () => [string, (args_0: string | RESET | ((prev: string) => string | RESET)) => void];
898
-
899
- export declare const useStylingState: () => [unknown, (...args: unknown[]) => unknown];
900
-
901
- export declare const useTheme: () => readonly [{
902
- fontFamily: {
903
- heading: string;
904
- body: string;
905
- };
906
- borderRadius: string;
907
- colors: {
908
- background: [string, string];
909
- foreground: [string, string];
910
- primary: [string, string];
911
- "primary-foreground": [string, string];
912
- secondary: [string, string];
913
- "secondary-foreground": [string, string];
914
- muted: [string, string];
915
- "muted-foreground": [string, string];
916
- accent: [string, string];
917
- "accent-foreground": [string, string];
918
- destructive: [string, string];
919
- "destructive-foreground": [string, string];
920
- border: [string, string];
921
- input: [string, string];
922
- ring: [string, string];
923
- card: [string, string];
924
- "card-foreground": [string, string];
925
- popover: [string, string];
926
- "popover-foreground": [string, string];
927
- [key: string]: [string, string];
928
- };
929
- } | {
930
- fontFamily: {
931
- heading: string;
932
- body: string;
933
- };
934
- borderRadius: string;
935
- colors: {
936
- background: [string, string];
937
- foreground: [string, string];
938
- primary: [string, string];
939
- "primary-foreground": [string, string];
940
- secondary: [string, string];
941
- "secondary-foreground": [string, string];
942
- muted: [string, string];
943
- "muted-foreground": [string, string];
944
- accent: [string, string];
945
- "accent-foreground": [string, string];
946
- destructive: [string, string];
947
- "destructive-foreground": [string, string];
948
- border: [string, string];
949
- input: [string, string];
950
- ring: [string, string];
951
- card: [string, string];
952
- "card-foreground": [string, string];
953
- popover: [string, string];
954
- "popover-foreground": [string, string];
955
- [key: string]: [string, string];
956
- };
957
- }, (args_0: ChaiThemeValues | Partial<ChaiThemeValues> | ((prev: ChaiThemeValues | Partial<ChaiThemeValues>) => ChaiThemeValues | Partial<ChaiThemeValues>)) => void];
958
-
959
- export declare const useThemeOptions: () => ChaiBuilderThemeOptions;
960
-
961
- export declare const useToggleChaiFeatureFlag: (flagKey: string) => () => void;
962
-
963
- export { useTranslation }
964
-
965
- export declare const useUndoManager: () => {
966
- add: (action: any) => void;
967
- undo: () => void;
968
- redo: () => void;
969
- hasUndo: () => boolean;
970
- hasRedo: () => boolean;
971
- clear: () => void;
972
- };
973
-
974
- /**
975
- *
976
- */
977
- export declare const useUpdateBlocksProps: () => (blockIds: Array<string>, props: Record<string, any>, prevPropsState?: Record<string, any>) => void;
978
-
979
- export declare const useUpdateBlocksPropsRealtime: () => (blockIds: Array<string>, props: Record<string, any>) => void;
980
-
981
- export declare const useWrapperBlock: () => ChaiBlock;
982
-
983
598
  declare type VariableKey = string;
984
599
 
985
600
  export { }
986
-
987
- declare global {
988
- interface Window {
989
- clarity: any;
990
- }
991
- }
package/dist/core.js CHANGED
@@ -1,110 +1,42 @@
1
- import { q as e, A as i, l as o, s as l, B as r, k as t, C as u, p as c, D as d, t as C, v as B, E as g, I as k, L as n, m as h, T as S, U as p, n as m, Q as P, Z as A, w as F, y as T, z as b, F as I, x as M, R as v, S as y, H as L, J as H, G as R, K as f, O as D, P as E, _ as U, $ as x, a0 as W, a1 as O, a2 as w, a3 as z, g as j, aI as q, a4 as G, h as J, a5 as K, aK as N, aJ as V, a6 as Z, V as Q, W as X, u as Y, a7 as _, a8 as $, a9 as aa, aa as sa, ab as ea, ac as ia, ad as oa, ae as la, af as ra, ag as ta, ah as ua, i as ca, ai as da, Y as Ca, aj as Ba, ak as ga, al as ka, am as na, an as ha, ao as Sa, ap as pa, aq as ma, ar as Pa, as as Aa, at as Fa, au as Ta, j as ba, aL as Ia, av as Ma, aw as va, ax as ya, a as La, ay as Ha, az as Ra, aM as fa, aA as Da, aN as Ea, aB as Ua, aC as xa, aD as Wa, aE as Oa, aF as wa, X as za, aG as ja, b as qa, c as Ga, aH as Ja } from "./index-DvdOXKUE.js";
2
- import { g as Na, c as Va } from "./common-functions-D2lMFR6K.js";
3
- import { h as Qa, h as Xa } from "./apply-binding-DLaiD20q.js";
4
- import { useTranslation as _a } from "react-i18next";
5
- import { default as as } from "i18next";
1
+ import { b6 as s, aW as i, b2 as r, b7 as o, aX as t, aY as l, aZ as C, aT as h, b4 as g, b8 as b, b9 as d, ba as n, a_ as c, a$ as k, b3 as B, b0 as S, b1 as m, b5 as p, an as M, bb as T, bd as P, be as f, bf as u, bc as A, aO as L, aR as E, bg as I, aS as x, aP as H, aU as U, bh as D } from "./index-S8ibZk9Q.js";
2
+ import { g as y, c as O } from "./common-functions-D2lMFR6K.js";
3
+ import { g as F, g as W } from "./apply-binding-6iwlED02.js";
4
+ import { default as z } from "i18next";
6
5
  export {
7
- e as ChaiAddBlocksDialog,
6
+ s as ChaiAddBlocksDialog,
8
7
  i as ChaiAddBlocksPanel,
9
- o as ChaiAskAiUserPrompt,
10
- l as ChaiBlockAttributesEditor,
11
- r as ChaiBlockPropsEditor,
12
- t as ChaiBlockStyleEditor,
13
- u as ChaiBuilderCanvas,
14
- c as ChaiBuilderEditor,
15
- d as ChaiDarkModeSwitcher,
16
- C as ChaiDefaultBlocks,
17
- B as ChaiDraggableBlock,
18
- g as ChaiExportCodeModal,
19
- k as ChaiImportHTML,
20
- n as ChaiOutline,
21
- h as ChaiScreenSizes,
8
+ r as ChaiAskAiUserPrompt,
9
+ o as ChaiBlockAttributesEditor,
10
+ t as ChaiBlockPropsEditor,
11
+ l as ChaiBlockStyleEditor,
12
+ C as ChaiBuilderCanvas,
13
+ h as ChaiBuilderEditor,
14
+ g as ChaiDarkModeSwitcher,
15
+ b as ChaiDefaultBlocks,
16
+ d as ChaiDraggableBlock,
17
+ n as ChaiExportCodeModal,
18
+ c as ChaiImportHTML,
19
+ k as ChaiOutline,
20
+ B as ChaiScreenSizes,
22
21
  S as ChaiThemeConfigPanel,
23
- p as ChaiUILibrariesPanel,
24
- m as ChaiUndoRedo,
25
- P as IfChaiFeatureFlag,
26
- A as PERMISSIONS,
27
- Qa as convertHTMLToChaiBlocks,
28
- Na as generateBlockId,
29
- Xa as getBlocksFromHTML,
30
- F as getClassValueAndUnit,
31
- as as i18n,
32
- Va as mergeClasses,
33
- T as registerBlockSettingField,
34
- b as registerBlockSettingTemplate,
35
- I as registerBlockSettingWidget,
36
- M as registerChaiAddBlockTab,
37
- v as registerChaiFeatureFlag,
38
- y as registerChaiFeatureFlags,
22
+ m as ChaiUILibrariesPanel,
23
+ p as ChaiUndoRedo,
24
+ M as PERMISSIONS,
25
+ F as convertHTMLToChaiBlocks,
26
+ y as generateBlockId,
27
+ W as getBlocksFromHTML,
28
+ T as getClassValueAndUnit,
29
+ z as i18n,
30
+ O as mergeClasses,
31
+ P as registerBlockSettingField,
32
+ f as registerBlockSettingTemplate,
33
+ u as registerBlockSettingWidget,
34
+ A as registerChaiAddBlockTab,
39
35
  L as registerChaiLibrary,
40
- H as registerChaiMediaManager,
41
- R as registerChaiPreImportHTMLHook,
42
- f as registerChaiSaveToLibrary,
43
- D as registerChaiSidebarPanel,
44
- E as registerChaiTopBar,
45
- U as useActiveSettingsTab,
46
- x as useAddBlock,
47
- W as useAddClassesToBlocks,
48
- O as useAskAi,
49
- w as useBlockHighlight,
50
- z as useBlocksHtmlForAi,
51
- j as useBlocksStore,
52
- q as useBlocksStoreUndoableActions,
53
- G as useBrandingOptions,
54
- J as useBuilderProp,
55
- K as useBuilderReset,
56
- N as useCanvasDisplayWidth,
57
- V as useCanvasWidth,
58
- Z as useCanvasZoom,
59
- Q as useChaiFeatureFlag,
60
- X as useChaiFeatureFlags,
61
- Y as useCodeEditor,
62
- _ as useCopyBlockIds,
63
- $ as useCopyToClipboard,
64
- aa as useCurrentPage,
65
- sa as useCutBlockIds,
66
- ea as useDarkMode,
67
- ia as useDuplicateBlocks,
68
- oa as useHighlightBlockId,
69
- la as useHtmlToBlocks,
70
- ra as useI18nBlocks,
71
- ta as useInlineEditing,
72
- ua as useIsPageLoaded,
73
- ca as useLanguages,
74
- da as useLibraryBlocks,
75
- Ca as useMediaManagerComponent,
76
- Ba as usePartailBlocksStore,
77
- ga as usePartialBlocksList,
78
- ka as usePasteBlocks,
79
- na as usePermissions,
80
- ha as usePreviewMode,
81
- Sa as usePubSub,
82
- pa as useRemoveAllClassesForBlock,
83
- ma as useRemoveBlocks,
84
- Pa as useRemoveClassesFromBlocks,
85
- Aa as useReplaceBlock,
86
- Fa as useResetBlockStyles,
87
- Ta as useRightPanel,
88
- ba as useSavePage,
89
- Ia as useScreenSizeWidth,
90
- Ma as useSelectedBlock,
91
- va as useSelectedBlockAllClasses,
92
- ya as useSelectedBlockCurrentClasses,
93
- La as useSelectedBlockIds,
94
- Ha as useSelectedBlocksDisplayChild,
95
- Ra as useSelectedBreakpoints,
96
- fa as useSelectedLibrary,
97
- Da as useSelectedStylingBlocks,
98
- Ea as useSidebarActivePanel,
99
- Ua as useStreamMultipleBlocksProps,
100
- xa as useStylingBreakpoint,
101
- Wa as useStylingState,
102
- Oa as useTheme,
103
- wa as useThemeOptions,
104
- za as useToggleChaiFeatureFlag,
105
- _a as useTranslation,
106
- ja as useUndoManager,
107
- qa as useUpdateBlocksProps,
108
- Ga as useUpdateBlocksPropsRealtime,
109
- Ja as useWrapperBlock
36
+ E as registerChaiMediaManager,
37
+ I as registerChaiPreImportHTMLHook,
38
+ x as registerChaiSaveToLibrary,
39
+ H as registerChaiSidebarPanel,
40
+ U as registerChaiTopBar,
41
+ D as useMediaManagerComponent
110
42
  };
@@ -0,0 +1,13 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),c=require("./index-CnSjWE1P.cjs");require("lodash-es");const w=require("culori"),T=require("./fonts-B-Xt29pe.cjs"),V=require("react"),N=require("react-i18next");function $(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const y=$(w),S=$(V),f=e=>e?e%1===0?e:e.toFixed(4):"0",R=e=>`hsl(${f(e.h)} ${f(e.s*100)}% ${f(e.l*100)}%)`,E=(e,o="hsl",t="4")=>{try{const r=y.parse(e);if(!r)throw new Error("Invalid color input");switch(o){case"hsl":{const s=y.converter("hsl")(r);return t==="4"?R(s):`${f(s.h)} ${f(s.s*100)}% ${f(s.l*100)}%`}case"rgb":return y.formatRgb(r);case"oklch":{const s=y.converter("oklch")(r);return`oklch(${f(s.l)} ${f(s.c)} ${f(s.h)})`}case"hex":return y.formatHex(r);default:return e}}catch(r){return console.error(`Failed to convert color: ${e}`,r),e}},b=e=>E(e,"hex"),I=e=>{const o={fontFamily:{heading:"",body:""},borderRadius:"",colors:{}};try{const t=F(e);if(!t.isValid)return console.warn("CSS validation failed:",t.error),k();const r=C(e,":root"),s=C(e,".dark"),l=u(r,"--font-sans")||u(r,"--font-family")||u(r,"--font-heading")||u(r,"--font-body"),a=q(l);o.fontFamily={heading:a,body:a};const m=u(r,"--radius")||u(r,"--border-radius")||"0.5rem";o.borderRadius=D(m),["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(i=>{const p=u(r,`--${i}`),g=u(s,`--${i}`);if(p||g){const d=p?v(p):"#000000",x=g?v(g):d;o.colors[i]=[d,x]}})}catch(t){return console.error("Error parsing CSS to ChaiThemeValues:",t),k()}return o},C=(e,o)=>{var r,s;const t=new RegExp(`${j(o)}\\s*{([^}]+)}`);return((s=(r=e.match(t))==null?void 0:r[1])==null?void 0:s.trim())||null},u=(e,o)=>{var s;if(!e)return null;const t=new RegExp(`${j(o)}\\s*:\\s*([^;]+)`),r=e.match(t);return((s=r==null?void 0:r[1])==null?void 0:s.trim())||null},v=e=>{if(!e||typeof e!="string")return"#000000";try{const o=e.replace(/var\([^)]+\)/g,"").trim();if(!o)return"#000000";if(/^[a-z]+$/i.test(o))return b(o)||"#000000";if(/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(o.replace(/#/g,""))){const r=o.startsWith("#")?o:`#${o}`;return r.length<=5?`#${r.slice(1).split("").map(s=>s+s).join("")}`.slice(0,7):r.length>7?r.slice(0,7):r}if(/^(rgb|hsl|oklch)a?\(/i.test(o))return b(o)||"#000000";const t=o.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);if(t){const[,r,s,l]=t,a=`hsl(${r} ${s}% ${l}%)`;return b(a)||"#000000"}if(/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(o)){const r=o.split(/[\s,]+/).filter(Boolean);if(r.length>=3){const l=r.some(a=>a.includes("%"))?`hsl(${r[0]} ${r[1]} ${r[2]})`:`rgb(${r[0]}, ${r[1]}, ${r[2]})`;return b(l)||"#000000"}}return b(o)||"#000000"}catch(o){return console.warn("Failed to process color:",e,o),"#000000"}},q=e=>{const o=T.getAllRegisteredFonts();if(!e)return"ui-sans-serif, system-ui, sans-serif";try{const r=e.replace(/["']/g,"").trim().split(",")[0].trim(),s=o.find(l=>l.family.toLowerCase()===r.toLowerCase());return(s==null?void 0:s.family)||"ui-sans-serif, system-ui, sans-serif"}catch(t){return console.warn("Error processing font family:",e,t),"ui-sans-serif, system-ui, sans-serif"}},D=e=>{try{const o=e.trim();if(o.endsWith("px"))return o;if(o.endsWith("rem")){const r=parseFloat(o.replace("rem",""));if(!isNaN(r))return`${Math.round(r*16)}px`}if(o.endsWith("em")){const r=parseFloat(o.replace("em",""));if(!isNaN(r))return`${Math.round(r*16)}px`}const t=parseFloat(o);return isNaN(t)?"8px":`${Math.round(t)}px`}catch(o){return console.warn("Error converting border radius to px:",e,o),"8px"}},k=()=>({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"]}}),j=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=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,F=e=>{if(!e||typeof e!="string")return{isValid:!1,error:"Please enter valid CSS content"};const o=e.trim();if(!o)return{isValid:!1,error:"Please enter CSS content"};try{if(!o.includes("{")||!o.includes("}"))return{isValid:!1,error:"Invalid CSS format. CSS should contain proper block structure with { }"};const t=(o.match(/{/g)||[]).length,r=(o.match(/}/g)||[]).length;return t!==r?{isValid:!1,error:"Invalid CSS format. Unmatched braces detected"}:!o.includes("--")||!o.includes(":")?{isValid:!1,error:"Invalid CSS format. CSS should contain variable definitions like --primary: #color"}:!o.includes(":root")&&!o.includes(".dark")?{isValid:!1,error:"CSS should contain at least :root or .dark selector with theme variables"}:{isValid:!0}}catch(t){return console.error("CSS validation error:",t),{isValid:!1,error:"Failed to parse CSS. Please check your syntax."}}},M=`:root {
2
+ --background: 0 0% 100%;
3
+ --foreground: oklch(0.52 0.13 144.17);
4
+ --primary: #3e2723;
5
+ --primary-foreground: #ffffff;
6
+ }
7
+
8
+ .dark {
9
+ --background: 222.2 84% 4.9%;
10
+ --foreground: hsl(37.50 36.36% 95.69%);
11
+ --primary: rgb(46, 125, 50);
12
+ --primary-foreground: #ffffff;
13
+ }`,B=({open:e,onOpenChange:o,onImport:t})=>{const[r,s]=S.useState(""),[l,a]=S.useState(null),[m,h]=S.useState(!1),{t:i}=N.useTranslation(),p=async()=>{h(!0),a(null);try{const d=F(r);if(!d.isValid){a(d.error||i("Invalid CSS format")),setTimeout(()=>{a(null)},5e3),h(!1);return}const x=I(r);if(!P(x)){a(i("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors.")),setTimeout(()=>{a(null)},5e3),h(!1);return}t(x),s(""),a(null),o(!1)}catch(d){console.error("Error importing CSS:",d),a(i("Failed to parse CSS. Please check your syntax and try again.")),setTimeout(()=>{a(null)},5e3)}finally{h(!1)}},g=()=>{s(""),a(null),o(!1)};return n.jsx(c.Dialog,{open:e,onOpenChange:o,children:n.jsxs(c.DialogContent,{className:"flex max-h-[80vh] max-w-2xl flex-col",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:i("Import CSS Theme")}),n.jsxs(c.DialogDescription,{className:"space-y-2",children:[n.jsx("p",{children:i("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.")}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("p",{className:"font-bold",children:"Get theme resources:"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://tweakcn.com/","_blank"),children:"TweakCN"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://ui.shadcn.com/themes#themes","_blank"),children:"shadcn/ui Themes"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://zippystarter.com/tools/shadcn-ui-theme-generator","_blank"),children:"ZippyStarter"})]})]})]}),n.jsxs("div",{className:"flex-1 space-y-4 overflow-hidden",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(c.Label,{htmlFor:"css-input",children:i("CSS Variables")}),n.jsx(c.Textarea,{id:"css-input",placeholder:M,value:r,onChange:d=>s(d.target.value),className:"min-h-[300px] resize-none font-mono text-sm",disabled:m})]}),l&&n.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3",children:n.jsx("p",{className:"text-sm text-red-600",children:l})})]}),n.jsxs(c.DialogFooter,{className:"gap-2",children:[n.jsx(c.Button,{variant:"outline",onClick:g,disabled:m,children:i("Cancel")}),n.jsx(c.Button,{onClick:p,disabled:!r.trim()||m,children:i(m?"Importing...":"Import Theme")})]})]})})};exports.CssImportModal=B;