@chaibuilder/sdk 4.0.0-beta.1 → 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 +27 -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-6iwlED02.js +833 -0
  34. package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
  35. package/dist/{code-display-337R7Dev.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/common-functions-B3a4xKt_.cjs +1 -0
  40. package/dist/common-functions-D2lMFR6K.js +13 -0
  41. package/dist/continue-editing-in-this-client-BllU94XG.js +24 -0
  42. package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +1 -0
  43. package/dist/core-BoRDjj4h.cjs +1 -0
  44. package/dist/core-yvI6kCyw.js +56 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +51 -383
  47. package/dist/core.js +39 -106
  48. package/dist/css-import-modal-BSMGKA2T.cjs +13 -0
  49. package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-D72a-16X.js} +39 -38
  50. package/dist/delete-design-token-Cd1ZDtqT.js +40 -0
  51. package/dist/delete-design-token-D_TLlO3I.cjs +1 -0
  52. package/dist/delete-page-ByQwBupJ.cjs +1 -0
  53. package/dist/delete-page-DC8pzvWW.js +70 -0
  54. package/dist/design-token-usage-BqZeR1sT.cjs +1 -0
  55. package/dist/design-token-usage-DE4XCDdn.js +113 -0
  56. package/dist/digital-asset-manager-BYLKFEYi.cjs +1 -0
  57. package/dist/digital-asset-manager-C_gL_0YY.js +876 -0
  58. package/dist/duplicate-page-BoVhko2q.js +133 -0
  59. package/dist/duplicate-page-vdvwLQLo.cjs +1 -0
  60. package/dist/dynamic-page-selector-CSndg2-y.js +85 -0
  61. package/dist/dynamic-page-selector-DdnbCuQZ.cjs +1 -0
  62. package/dist/fonts-B-Xt29pe.cjs +1 -0
  63. package/dist/fonts-DRly3Wzd.js +78 -0
  64. package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
  65. package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
  66. package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
  67. package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
  68. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  69. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  70. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  71. package/dist/image-compression-DsZ1oqpb.js +37 -0
  72. package/dist/image-editor-DTspjj_c.cjs +1 -0
  73. package/dist/image-editor-oypq8asR.js +108 -0
  74. package/dist/index-B-rSiAp_.cjs +1 -0
  75. package/dist/index-BDnwJqMw.js +4732 -0
  76. package/dist/index-CbwxUFy_.cjs +5 -0
  77. package/dist/index-CnSjWE1P.cjs +160 -0
  78. package/dist/index-Dxfyt4d4.js +39 -0
  79. package/dist/index-S8ibZk9Q.js +19069 -0
  80. package/dist/json-diff-viewer-B5dr-Y_L.js +258 -0
  81. package/dist/json-diff-viewer-XX1pgabt.cjs +8 -0
  82. package/dist/lang-panel-BPxex-M2.cjs +1 -0
  83. package/dist/lang-panel-Cn83SRzd.js +215 -0
  84. package/dist/manage-design-tokens-ConiyuPr.cjs +1 -0
  85. package/dist/manage-design-tokens-lP4HLS0P.js +240 -0
  86. package/dist/mark-as-template-DYRxre1f.cjs +1 -0
  87. package/dist/mark-as-template-jncsjfHm.js +156 -0
  88. package/dist/models-5gOsRC56.cjs +1 -0
  89. package/dist/models-D95ZYr_x.js +70 -0
  90. package/dist/nested-path-selector-content-B-8LqhXI.js +87 -0
  91. package/dist/nested-path-selector-content-BYtLi7mC.cjs +1 -0
  92. package/dist/no-language-page-content-DAbLq0gX.cjs +1 -0
  93. package/dist/no-language-page-content-D_zd9Rb0.js +42 -0
  94. package/dist/no-language-page-dialog-C5Ps6YYL.js +10 -0
  95. package/dist/no-language-page-dialog-fXmbQO7L.cjs +1 -0
  96. package/dist/page-creator-VWIB2VAs.cjs +1 -0
  97. package/dist/page-creator-wCMtlE6Z.js +795 -0
  98. package/dist/page-lock-BPCxfv9J.js +30 -0
  99. package/dist/page-lock-DweiYy1w.cjs +1 -0
  100. package/dist/page-locked-dialog-BlbgvaG2.cjs +1 -0
  101. package/dist/page-locked-dialog-ByGl18_m.js +133 -0
  102. package/dist/page-manager-new-BWFE-S-O.js +394 -0
  103. package/dist/page-manager-new-D0lGfNnS.cjs +1 -0
  104. package/dist/page-manager-search-and-filter-DpGMoOII.cjs +1 -0
  105. package/dist/page-manager-search-and-filter-kNJFWJ86.js +201 -0
  106. package/dist/page-revisions-content-DYxXZqmh.cjs +1 -0
  107. package/dist/page-revisions-content-Ulr8slUN.js +445 -0
  108. package/dist/pages.cjs +1 -0
  109. package/dist/pages.d.ts +492 -0
  110. package/dist/pages.js +27 -0
  111. package/dist/plugin-3ZKK6RXm.js +245 -0
  112. package/dist/plugin-C6rgJDNQ.cjs +22 -0
  113. package/dist/publish-pages-content-BTPzt_m4.js +178 -0
  114. package/dist/publish-pages-content-D6g8GAsd.cjs +1 -0
  115. package/dist/register-partial-type-BjtdfKHE.js +36 -0
  116. package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
  117. package/dist/render.cjs +2 -2
  118. package/dist/render.d.ts +26 -13
  119. package/dist/render.js +130 -124
  120. package/dist/rte-widget-modal-DrMzWWjw.cjs +1 -0
  121. package/dist/rte-widget-modal-Rk_NW3KU.js +38 -0
  122. package/dist/runtime.cjs +1 -1
  123. package/dist/runtime.d.ts +306 -7
  124. package/dist/runtime.js +44 -1
  125. package/dist/save-to-lib-BK3uTFss.js +422 -0
  126. package/dist/save-to-lib-DHHUO12i.cjs +1 -0
  127. package/dist/sdk.css +1 -1
  128. package/dist/selected-block-display-CU3TwIMA.js +319 -0
  129. package/dist/selected-block-display-DSFhddPj.cjs +16 -0
  130. package/dist/seo-panel-Dl0IDV09.cjs +2 -0
  131. package/dist/seo-panel-jbzxFioc.js +798 -0
  132. package/dist/shared-json-ld-BL_dv3_q.js +565 -0
  133. package/dist/shared-json-ld-DPNkqDC1.cjs +1 -0
  134. package/dist/slug-input-1qwKkXhA.js +86 -0
  135. package/dist/slug-input-YVLjtTI3.cjs +1 -0
  136. package/dist/supabase-actions.cjs +1 -0
  137. package/dist/supabase-actions.d.ts +284 -0
  138. package/dist/supabase-actions.js +524 -0
  139. package/dist/take-over-request-DKvKi3mM.js +63 -0
  140. package/dist/take-over-request-DvMIg_cZ.cjs +1 -0
  141. package/dist/theme-panel-footer-BMOaPLWc.cjs +1 -0
  142. package/dist/theme-panel-footer-DbMDLYGI.js +25 -0
  143. package/dist/translation-warning-modal-9wTwIy_9.js +26 -0
  144. package/dist/translation-warning-modal-DjTwz75c.cjs +1 -0
  145. package/dist/unmark-as-template-CdqIJJER.cjs +1 -0
  146. package/dist/unmark-as-template-Dulvf7Zw.js +39 -0
  147. package/dist/unpublish-page-BwSVBf0_.cjs +1 -0
  148. package/dist/unpublish-page-Degu5Cy9.js +27 -0
  149. package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
  150. package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
  151. package/dist/{tailwind.cjs → utils.cjs} +1 -1
  152. package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
  153. package/dist/utils.js +7 -0
  154. package/dist/web-blocks.cjs +1 -1
  155. package/dist/web-blocks.d.ts +0 -6
  156. package/dist/web-blocks.js +258 -251
  157. package/dist/web-preview-DXE4Jnf5.js +73 -0
  158. package/dist/web-preview-YzKxyXft.cjs +1 -0
  159. package/package.json +175 -105
  160. package/dist/IconPicker-CGWn9C4u.cjs +0 -1
  161. package/dist/IconPicker-QvxJ-4Ez.js +0 -64
  162. package/dist/apply-binding-DCno1xQL.js +0 -711
  163. package/dist/apply-binding-DvHNFLQD.cjs +0 -1
  164. package/dist/code-display-BZ1x7SqI.cjs +0 -1
  165. package/dist/code-editor-B28LoECM.cjs +0 -1
  166. package/dist/code-editor-CfG2FhJ-.js +0 -58
  167. package/dist/common-functions-BGzDsf1z.js +0 -14
  168. package/dist/common-functions-BZmyleS1.cjs +0 -1
  169. package/dist/css-import-modal-CENUYvcl.cjs +0 -13
  170. package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
  171. package/dist/index-CaGNHF7f.js +0 -12209
  172. package/dist/index-Gn6pJt2v.cjs +0 -166
  173. package/dist/mockServiceWorker.js +0 -307
  174. package/dist/plugin-B5627hMN.js +0 -195
  175. package/dist/plugin-UxTRfDum.cjs +0 -22
  176. package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
  177. package/dist/rte-widget-modal-Dte0od04.js +0 -41
  178. package/dist/tailwind.js +0 -7
  179. package/dist/tooltip-A4qGk781.cjs +0 -1
  180. package/dist/tooltip-tLiIOgjq.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
@@ -0,0 +1,319 @@
1
+ import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
+ import { ag as r, B as E, as as O } from "./index-S8ibZk9Q.js";
3
+ import { ArrowDownIcon as D, BrainIcon as P, ChevronDownIcon as $, X as B } from "lucide-react";
4
+ import * as _ from "react";
5
+ import { useCallback as G, memo as d, createContext as S, useMemo as j, useState as C, useEffect as T, useContext as Q } from "react";
6
+ import { StickToBottom as R, useStickToBottomContext as F } from "use-stick-to-bottom";
7
+ import { Streamdown as y } from "streamdown";
8
+ import "@radix-ui/react-slot";
9
+ import { cva as K } from "class-variance-authority";
10
+ import "clsx";
11
+ import "tailwind-merge";
12
+ import * as A from "@radix-ui/react-tooltip";
13
+ import { useControllableState as w } from "@radix-ui/react-use-controllable-state";
14
+ import * as x from "@radix-ui/react-collapsible";
15
+ import { motion as V } from "framer-motion";
16
+ import { L as h } from "./index-BDnwJqMw.js";
17
+ import { useTranslation as Y } from "react-i18next";
18
+ const Ce = ({ className: e, ...t }) => /* @__PURE__ */ o(
19
+ R,
20
+ {
21
+ className: r("relative flex-1 overflow-y-hidden", e),
22
+ initial: "smooth",
23
+ resize: "smooth",
24
+ role: "log",
25
+ ...t
26
+ }
27
+ ), Te = ({ className: e, ...t }) => /* @__PURE__ */ o(R.Content, { className: r("flex flex-col gap-8 p-4", e), ...t }), we = ({
28
+ className: e,
29
+ title: t = "No messages yet",
30
+ description: s = "Start a conversation to see messages here",
31
+ icon: n,
32
+ children: a,
33
+ ...i
34
+ }) => /* @__PURE__ */ o(
35
+ "div",
36
+ {
37
+ className: r("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
38
+ ...i,
39
+ children: a ?? /* @__PURE__ */ l(f, { children: [
40
+ n && /* @__PURE__ */ o("div", { className: "text-muted-foreground", children: n }),
41
+ /* @__PURE__ */ l("div", { className: "space-y-1", children: [
42
+ /* @__PURE__ */ o("h3", { className: "text-sm font-medium", children: t }),
43
+ s && /* @__PURE__ */ o("p", { className: "text-sm text-muted-foreground", children: s })
44
+ ] })
45
+ ] })
46
+ }
47
+ ), Ee = ({ className: e, ...t }) => {
48
+ const { isAtBottom: s, scrollToBottom: n } = F(), a = G(() => {
49
+ n();
50
+ }, [n]);
51
+ return !s && /* @__PURE__ */ o(
52
+ E,
53
+ {
54
+ className: r("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
55
+ onClick: a,
56
+ size: "icon",
57
+ type: "button",
58
+ variant: "outline",
59
+ ...t,
60
+ children: /* @__PURE__ */ o(D, { className: "size-4" })
61
+ }
62
+ );
63
+ };
64
+ K(
65
+ "flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
66
+ {
67
+ variants: {
68
+ orientation: {
69
+ horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
70
+ vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
71
+ }
72
+ },
73
+ defaultVariants: {
74
+ orientation: "horizontal"
75
+ }
76
+ }
77
+ );
78
+ const J = _.forwardRef(({ className: e, sideOffset: t = 4, ...s }, n) => /* @__PURE__ */ o(
79
+ A.Content,
80
+ {
81
+ ref: n,
82
+ sideOffset: t,
83
+ className: r(
84
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
85
+ e
86
+ ),
87
+ ...s
88
+ }
89
+ ));
90
+ J.displayName = A.Content.displayName;
91
+ const Se = ({ className: e, from: t, ...s }) => /* @__PURE__ */ o(
92
+ "div",
93
+ {
94
+ className: r(
95
+ "group flex w-full max-w-[80%] flex-col gap-2",
96
+ t === "user" ? "is-user ml-auto justify-end" : "is-assistant",
97
+ e
98
+ ),
99
+ ...s
100
+ }
101
+ ), Re = ({ children: e, className: t, ...s }) => /* @__PURE__ */ o(
102
+ "div",
103
+ {
104
+ className: r(
105
+ "is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm",
106
+ "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground",
107
+ "group-[.is-assistant]:text-foreground",
108
+ t
109
+ ),
110
+ ...s,
111
+ children: e
112
+ }
113
+ );
114
+ S(null);
115
+ const X = d(
116
+ ({ className: e, ...t }) => /* @__PURE__ */ o(y, { className: r("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e), ...t }),
117
+ (e, t) => e.children === t.children
118
+ );
119
+ X.displayName = "MessageResponse";
120
+ const q = x.Root, H = x.CollapsibleTrigger, W = x.CollapsibleContent, Z = ({
121
+ children: e,
122
+ as: t = "p",
123
+ className: s,
124
+ duration: n = 2,
125
+ spread: a = 2
126
+ }) => {
127
+ const i = V.create(
128
+ t
129
+ ), g = j(
130
+ () => ((e == null ? void 0 : e.length) ?? 0) * a,
131
+ [e, a]
132
+ );
133
+ return /* @__PURE__ */ o(
134
+ i,
135
+ {
136
+ animate: { backgroundPosition: "0% center" },
137
+ className: r(
138
+ "relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent",
139
+ "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",
140
+ s
141
+ ),
142
+ initial: { backgroundPosition: "100% center" },
143
+ style: {
144
+ "--spread": `${g}px`,
145
+ backgroundImage: "var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"
146
+ },
147
+ transition: {
148
+ repeat: Number.POSITIVE_INFINITY,
149
+ duration: n,
150
+ ease: "linear"
151
+ },
152
+ children: e
153
+ }
154
+ );
155
+ }, k = d(Z), U = S(null), ee = () => {
156
+ const e = Q(U);
157
+ if (!e)
158
+ throw new Error("Reasoning components must be used within Reasoning");
159
+ return e;
160
+ }, te = 1e3, oe = 1e3, se = d(
161
+ ({
162
+ className: e,
163
+ isStreaming: t = !1,
164
+ open: s,
165
+ defaultOpen: n = !0,
166
+ onOpenChange: a,
167
+ duration: i,
168
+ children: g,
169
+ ...z
170
+ }) => {
171
+ const [c, m] = w({
172
+ prop: s,
173
+ defaultProp: n,
174
+ onChange: a
175
+ }), [M, b] = w({
176
+ prop: i,
177
+ defaultProp: void 0
178
+ }), [N, I] = C(!1), [u, v] = C(null);
179
+ T(() => {
180
+ t ? u === null && v(Date.now()) : u !== null && (b(Math.ceil((Date.now() - u) / oe)), v(null));
181
+ }, [t, u, b]), T(() => {
182
+ if (n && !t && c && !N) {
183
+ const p = setTimeout(() => {
184
+ m(!1), I(!0);
185
+ }, te);
186
+ return () => clearTimeout(p);
187
+ }
188
+ }, [t, c, n, m, N]);
189
+ const L = (p) => {
190
+ m(p);
191
+ };
192
+ return /* @__PURE__ */ o(U.Provider, { value: { isStreaming: t, isOpen: c, setIsOpen: m, duration: M }, children: /* @__PURE__ */ o(
193
+ q,
194
+ {
195
+ className: r("not-prose mb-4", e),
196
+ onOpenChange: L,
197
+ open: c,
198
+ ...z,
199
+ children: g
200
+ }
201
+ ) });
202
+ }
203
+ ), ne = (e, t) => e || t === 0 ? /* @__PURE__ */ o(k, { duration: 1, children: "Thinking..." }) : t === void 0 ? /* @__PURE__ */ o("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ l("p", { children: [
204
+ "Thought for ",
205
+ t,
206
+ " seconds"
207
+ ] }), ae = d(({ className: e, children: t, ...s }) => {
208
+ const { isStreaming: n, isOpen: a, duration: i } = ee();
209
+ return /* @__PURE__ */ o(
210
+ H,
211
+ {
212
+ className: r(
213
+ "flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",
214
+ e
215
+ ),
216
+ ...s,
217
+ children: t ?? /* @__PURE__ */ l(f, { children: [
218
+ /* @__PURE__ */ o(P, { className: "size-4" }),
219
+ ne(n, i),
220
+ /* @__PURE__ */ o($, { className: r("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
221
+ ] })
222
+ }
223
+ );
224
+ }), re = d(({ className: e, children: t, ...s }) => /* @__PURE__ */ o(
225
+ W,
226
+ {
227
+ className: r(
228
+ "mt-4 text-sm",
229
+ "text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",
230
+ e
231
+ ),
232
+ ...s,
233
+ children: /* @__PURE__ */ o(y, { ...s, children: t })
234
+ }
235
+ ));
236
+ se.displayName = "Reasoning";
237
+ ae.displayName = "ReasoningTrigger";
238
+ re.displayName = "ReasoningContent";
239
+ const ye = ({ className: e, content: t, isLoading: s = !1, ...n }) => /* @__PURE__ */ o("div", { className: r("is-assistant flex w-full max-w-[80%] flex-col gap-2", e), ...n, children: /* @__PURE__ */ o("div", { className: "flex w-fit flex-col gap-2 overflow-hidden text-sm", children: /* @__PURE__ */ o("div", { className: "flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3", children: /* @__PURE__ */ l("div", { className: "flex flex-1 items-center gap-2", children: [
240
+ s && /* @__PURE__ */ o(k, { duration: 1.5, children: t }),
241
+ !s && /* @__PURE__ */ o("div", { className: "text-xs text-muted-foreground", children: t })
242
+ ] }) }) }) });
243
+ function Ae({
244
+ userInput: e,
245
+ language: t = "en",
246
+ currentHtml: s
247
+ }) {
248
+ const n = h[t] || "English";
249
+ return s && s.trim().length > 0 ? `
250
+ MODE: EDIT
251
+ CURRENT HTML:
252
+ ${s}
253
+
254
+ USER REQUEST: ${e}
255
+ Use ${n} language.
256
+ `.trim() : `
257
+ USER REQUEST: ${e}
258
+ Use ${n} language.
259
+ `.trim();
260
+ }
261
+ function ke({
262
+ fallbackLang: e,
263
+ language: t,
264
+ blocks: s = [],
265
+ userInput: n
266
+ }) {
267
+ const a = h[t] || "English";
268
+ return `
269
+ USER REQUEST: ${n || "Translate the content"}
270
+ LANGUAGE TO TRANSLATE: ${a}
271
+ REQUESTED TRANSLATION LANGUAGE CODE: ${t}
272
+ FALLBACK LANGUAGE: ${h[e]}
273
+ BLOCKS: ${JSON.stringify(s)}`.trim();
274
+ }
275
+ const Ue = ({ onRemove: e, isLoading: t = !1 }) => {
276
+ const { t: s } = Y(), n = O(), a = (n == null ? void 0 : n._type) || "Unknown", i = (n == null ? void 0 : n._name) || a;
277
+ return /* @__PURE__ */ o(f, { children: /* @__PURE__ */ l("div", { className: "mx-auto flex w-[95%] items-center justify-between rounded-t-md border border-b-0 border-blue-200 bg-blue-50", children: [
278
+ /* @__PURE__ */ l("div", { className: "flex items-center", children: [
279
+ /* @__PURE__ */ o("div", { className: "flex h-6 w-6 items-center justify-center rounded-l rounded-bl-none bg-blue-500 text-xs font-semibold text-white", children: "@" }),
280
+ /* @__PURE__ */ o("div", { className: "flex w-[95%] flex-col", children: n ? /* @__PURE__ */ o(f, { children: /* @__PURE__ */ l("span", { className: "truncate text-xs font-medium text-blue-900", children: [
281
+ " ",
282
+ s("Context: "),
283
+ " ",
284
+ i
285
+ ] }) }) : /* @__PURE__ */ l("span", { className: "text-xs font-medium text-blue-900", children: [
286
+ " ",
287
+ s("Context: Entire Page")
288
+ ] }) })
289
+ ] }),
290
+ n && /* @__PURE__ */ o(
291
+ E,
292
+ {
293
+ variant: "ghost",
294
+ size: "icon",
295
+ onClick: e,
296
+ disabled: t,
297
+ className: "h-6 w-6 text-blue-600 hover:bg-blue-100 hover:text-blue-800",
298
+ title: "Remove block from context",
299
+ children: /* @__PURE__ */ o(B, { size: 14 })
300
+ }
301
+ )
302
+ ] }) });
303
+ };
304
+ export {
305
+ Ce as C,
306
+ Se as M,
307
+ se as R,
308
+ Ue as S,
309
+ ye as T,
310
+ Te as a,
311
+ we as b,
312
+ ae as c,
313
+ re as d,
314
+ Re as e,
315
+ X as f,
316
+ Ee as g,
317
+ Ae as h,
318
+ ke as i
319
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";const o=require("react/jsx-runtime"),r=require("./index-CnSjWE1P.cjs"),m=require("lucide-react"),i=require("react"),p=require("use-stick-to-bottom"),T=require("streamdown");require("@radix-ui/react-slot");const _=require("class-variance-authority");require("clsx");require("tailwind-merge");const q=require("@radix-ui/react-tooltip"),j=require("@radix-ui/react-use-controllable-state"),z=require("@radix-ui/react-collapsible"),B=require("framer-motion"),f=require("./index-CbwxUFy_.cjs"),D=require("react-i18next");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const I=h(i),S=h(q),b=h(z),L=({className:e,...t})=>o.jsx(p.StickToBottom,{className:r.cn("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),G=({className:e,...t})=>o.jsx(p.StickToBottom.Content,{className:r.cn("flex flex-col gap-8 p-4",e),...t}),$=({className:e,title:t="No messages yet",description:s="Start a conversation to see messages here",icon:n,children:a,...l})=>o.jsx("div",{className:r.cn("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",e),...l,children:a??o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{className:"text-muted-foreground",children:n}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-sm font-medium",children:t}),s&&o.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]})}),F=({className:e,...t})=>{const{isAtBottom:s,scrollToBottom:n}=p.useStickToBottomContext(),a=i.useCallback(()=>{n()},[n]);return!s&&o.jsx(r.Button,{className:r.cn("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:o.jsx(m.ArrowDownIcon,{className:"size-4"})})};_.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});const Q=I.forwardRef(({className:e,sideOffset:t=4,...s},n)=>o.jsx(S.Content,{ref:n,sideOffset:t,className:r.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s}));Q.displayName=S.Content.displayName;const V=({className:e,from:t,...s})=>o.jsx("div",{className:r.cn("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...s}),K=({children:e,className:t,...s})=>o.jsx("div",{className:r.cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...s,children:e});i.createContext(null);const w=i.memo(({className:e,...t})=>o.jsx(T.Streamdown,{className:r.cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);w.displayName="MessageResponse";const Y=b.Root,J=b.CollapsibleTrigger,X=b.CollapsibleContent,H=({children:e,as:t="p",className:s,duration:n=2,spread:a=2})=>{const l=B.motion.create(t),g=i.useMemo(()=>((e==null?void 0:e.length)??0)*a,[e,a]);return o.jsx(l,{animate:{backgroundPosition:"0% center"},className:r.cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${g}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:n,ease:"linear"},children:e})},E=i.memo(H),R=i.createContext(null),W=()=>{const e=i.useContext(R);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Z=1e3,ee=1e3,y=i.memo(({className:e,isStreaming:t=!1,open:s,defaultOpen:n=!0,onOpenChange:a,duration:l,children:g,...U})=>{const[c,d]=j.useControllableState({prop:s,defaultProp:n,onChange:a}),[M,v]=j.useControllableState({prop:l,defaultProp:void 0}),[N,O]=i.useState(!1),[u,C]=i.useState(null);i.useEffect(()=>{t?u===null&&C(Date.now()):u!==null&&(v(Math.ceil((Date.now()-u)/ee)),C(null))},[t,u,v]),i.useEffect(()=>{if(n&&!t&&c&&!N){const x=setTimeout(()=>{d(!1),O(!0)},Z);return()=>clearTimeout(x)}},[t,c,n,d,N]);const P=x=>{d(x)};return o.jsx(R.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:d,duration:M},children:o.jsx(Y,{className:r.cn("not-prose mb-4",e),onOpenChange:P,open:c,...U,children:g})})}),te=(e,t)=>e||t===0?o.jsx(E,{duration:1,children:"Thinking..."}):t===void 0?o.jsx("p",{children:"Thought for a few seconds"}):o.jsxs("p",{children:["Thought for ",t," seconds"]}),A=i.memo(({className:e,children:t,...s})=>{const{isStreaming:n,isOpen:a,duration:l}=W();return o.jsx(J,{className:r.cn("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...s,children:t??o.jsxs(o.Fragment,{children:[o.jsx(m.BrainIcon,{className:"size-4"}),te(n,l),o.jsx(m.ChevronDownIcon,{className:r.cn("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),k=i.memo(({className:e,children:t,...s})=>o.jsx(X,{className:r.cn("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...s,children:o.jsx(T.Streamdown,{...s,children:t})}));y.displayName="Reasoning";A.displayName="ReasoningTrigger";k.displayName="ReasoningContent";const oe=({className:e,content:t,isLoading:s=!1,...n})=>o.jsx("div",{className:r.cn("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...n,children:o.jsx("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:o.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:o.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s&&o.jsx(E,{duration:1.5,children:t}),!s&&o.jsx("div",{className:"text-xs text-muted-foreground",children:t})]})})})});function se({userInput:e,language:t="en",currentHtml:s}){const n=f.LANGUAGES[t]||"English";return s&&s.trim().length>0?`
2
+ MODE: EDIT
3
+ CURRENT HTML:
4
+ ${s}
5
+
6
+ USER REQUEST: ${e}
7
+ Use ${n} language.
8
+ `.trim():`
9
+ USER REQUEST: ${e}
10
+ Use ${n} language.
11
+ `.trim()}function ne({fallbackLang:e,language:t,blocks:s=[],userInput:n}){const a=f.LANGUAGES[t]||"English";return`
12
+ USER REQUEST: ${n||"Translate the content"}
13
+ LANGUAGE TO TRANSLATE: ${a}
14
+ REQUESTED TRANSLATION LANGUAGE CODE: ${t}
15
+ FALLBACK LANGUAGE: ${f.LANGUAGES[e]}
16
+ BLOCKS: ${JSON.stringify(s)}`.trim()}const re=({onRemove:e,isLoading:t=!1})=>{const{t:s}=D.useTranslation(),n=r.useSelectedBlock(),a=(n==null?void 0:n._type)||"Unknown",l=(n==null?void 0:n._name)||a;return o.jsx(o.Fragment,{children:o.jsxs("div",{className:"mx-auto flex w-[95%] items-center justify-between rounded-t-md border border-b-0 border-blue-200 bg-blue-50",children:[o.jsxs("div",{className:"flex items-center",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-l rounded-bl-none bg-blue-500 text-xs font-semibold text-white",children:"@"}),o.jsx("div",{className:"flex w-[95%] flex-col",children:n?o.jsx(o.Fragment,{children:o.jsxs("span",{className:"truncate text-xs font-medium text-blue-900",children:[" ",s("Context: ")," ",l]})}):o.jsxs("span",{className:"text-xs font-medium text-blue-900",children:[" ",s("Context: Entire Page")]})})]}),n&&o.jsx(r.Button,{variant:"ghost",size:"icon",onClick:e,disabled:t,className:"h-6 w-6 text-blue-600 hover:bg-blue-100 hover:text-blue-800",title:"Remove block from context",children:o.jsx(m.X,{size:14})})]})})};exports.Conversation=L;exports.ConversationContent=G;exports.ConversationEmptyState=$;exports.ConversationScrollButton=F;exports.Message=V;exports.MessageContent=K;exports.MessageResponse=w;exports.Reasoning=y;exports.ReasoningContent=k;exports.ReasoningTrigger=A;exports.SelectedBlockDisplay=re;exports.TaskMessage=oe;exports.getTranslationUserPrompt=ne;exports.getUserPrompt=se;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-CbwxUFy_.cjs"),n=require("./index-CnSjWE1P.cjs"),u=require("lodash-es"),N=require("react"),ce=require("react-i18next"),D=require("sonner"),ie=require("@tanstack/react-query"),z=require("lucide-react"),V=require("./get-seo-defaults-Cw7vFt-B.cjs"),de=()=>{const{selectedLang:t}=n.useLanguages(),{data:p,isFetching:o}=i.useLanguagePages();return{data:N.useMemo(()=>u.find(p,{lang:t||""})||{},[p,t]),isFetching:o}},ue=()=>{var x;const p=(x=document.getElementById("canvas-iframe").contentDocument)==null?void 0:x.body.innerHTML;if(!p)return null;const d=new DOMParser().parseFromString(p,"text/html");d.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(h=>h.remove()),d.querySelectorAll("*").forEach(h=>{Array.from(h.attributes).forEach(m=>h.removeAttribute(m.name))});const l=d.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(l).map(h=>`<${h.tagName.toLowerCase()}>${h.innerHTML}</${h.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},C=({keyword:t,onComplete:p,field:o})=>{const d=i.useFetch(),l=i.useApiUrl(),{selectedLang:v,fallbackLang:x}=n.useLanguages(),{mutate:h,isPending:m}=ie.useMutation({mutationFn:async()=>{const O=ue();return await d(l,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:o,lang:v||x,pageContent:O,keyword:t}})},onSuccess:O=>{p({fieldValue:O.field})},onError:O=>{p({fieldValue:null,error:O.message})}});return e.jsx(n.Button,{disabled:m,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>h(),children:m?e.jsx(z.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(z.Wand2Icon,{className:"text-yellow-500"})})},pe=(t,p)=>{if(!t)return{success:!1,error:"Empty response from AI"};try{let o=t;if(typeof o=="string"&&(/^".*"$/.test(o)&&(o=o.replace(/^"(.*)"$/,"$1"),o=o.replace(/\\\\/g,"___DOUBLE_BACKSLASH___").replace(/\\n/g,`
2
+ `).replace(/\\"/g,'"').replace(/___DOUBLE_BACKSLASH___/g,"\\")),p==="jsonLD"||p==="metaOther")){o.includes("```")&&(o=o.replace(/^```json\s*/i,"").replace(/^```\s*/,"").replace(/\s*```$/m,"")),o=o.trim();try{JSON.parse(o)}catch{return{success:!1,error:"The AI response is not valid JSON. Please try again or edit manually."}}}return{success:!0,value:o}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error occurred"}}},he=({isOpen:t,onClose:p,onSave:o,onDiscard:d,isSaving:l=!1,fromLanguage:v,toLanguage:x})=>{const h=i.LANGUAGES[v]||v,m=i.LANGUAGES[x]||x;return e.jsx(n.Dialog,{open:t,onOpenChange:p,children:e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsx(n.DialogTitle,{children:"Unsaved SEO Changes"}),e.jsxs(n.DialogDescription,{children:['You have unsaved changes in the SEO for "',h,'" version. Do you want to save these changes before switching to "',m,'" version?']})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(n.Button,{variant:"outline",onClick:d,disabled:l,children:"Discard Changes"}),e.jsx(n.Button,{onClick:o,disabled:l,children:l?"Saving...":"Save & Switch"})]})]})})},me=t=>{if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},ge=(t,p)=>{const o=t.selectionStart||0,d=t.selectionEnd||0,l=t.value,v=l.substring(0,o),x=l.substring(d),h=`{{${p}}}`,m=v+""+h+x,O=o+0+h.length;return{value:m,newCursorPos:O}},K=()=>{const{t}=ce.useTranslation(),[,p]=n.useSidebarActivePanel(),{data:o}=i.useChaiCurrentPage(),{data:d}=i.useBuilderPageData(),{data:l,isFetching:v}=de(),x=l==null?void 0:l.seo,h=N.useRef(null),[m,O]=N.useState("seo"),R=o==null?void 0:o.id,Q=o==null?void 0:o.pageType,L=i.usePageType(Q),{selectedLang:G,fallbackLang:Y}=n.useLanguages(),g=G||Y,[M,J]=N.useState(!1),[X,H]=N.useState(!1),[Z,P]=N.useState(!1),[w,q]=N.useState(null),[a,b]=N.useState({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...x}),T=N.useRef({}),{mutate:ee,isPending:B}=i.useUpdatePage(),f=B||M||X,{hasPermission:se}=n.usePermissions(),r=se(i.PAGES_PERMISSIONS.EDIT_SEO),[te]=i.usePagesProps(),ne=u.get(te,"features.canResetSeoToDefault",!1),$=!G||a.jsonLD!=="{}";N.useEffect(()=>{if(!v&&x&&R){const s={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...x};b(s),T.current[g]=s}},[v,x,g,R]),N.useEffect(()=>{const s=c=>{const{fromLang:j,toLang:F,switchHandler:S}=c.detail,U=T.current[g];(U?!u.isEqual(U,a):!1)?(q({fromLang:j,toLang:F,switchHandler:S}),P(!0)):S()};return window.addEventListener("seo-language-switch-check",s),()=>{window.removeEventListener("seo-language-switch-check",s)}},[R,a,g]);const oe=async()=>{if(!(!L||!g))try{J(!0);const s=V.getSeoDefaults(L,g),c={...a,keyword:u.get(s,"seo.keyword",""),title:u.get(s,"seo.title",""),description:u.get(s,"seo.description",""),cononicalUrl:u.get(s,"seo.canonicalUrl",""),noIndex:u.get(s,"seo.noIndex",!1),noFollow:u.get(s,"seo.noFollow",!1),ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription","")};b(c),D.toast.success(t("SEO fields reset to defaults"))}catch(s){D.toast.error(t("Failed to reset SEO fields")),console.error("Reset SEO error:",s)}finally{J(!1)}},ae=async()=>{if(!(!L||!g))try{H(!0);const s=V.getSeoDefaults(L,g),c={...a,jsonLD:u.get(s,"seo.jsonLD","")};b(c),D.toast.success(t("JSON-LD reset to default"))}catch(s){D.toast.error(t("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",s)}finally{H(!1)}},re=async()=>{if(!(!L||!g))try{J(!0);const s=V.getSeoDefaults(L,g),c={...a,ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription",""),ogImage:u.get(s,"seo.ogImage",""),ogImageId:u.get(s,"seo.ogImageId",""),metaOther:u.get(s,"seo.metaOther","{}")};b(c),D.toast.success(t("Meta Tag fields reset to defaults"))}catch(s){D.toast.error(t("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",s)}finally{J(!1)}},W=async()=>{ee({id:l==null?void 0:l.id,seo:a,primaryPage:R},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",a),T.current[g]=a,D.toast.success("SEO & JSON-LD updated successfully")}})},I=(s,c)=>{const j=document.getElementById(c);if(j){const{value:F,newCursorPos:S}=ge(j,s);h.current={id:c,position:S},j.tagName.toLowerCase()==="input"?(j.value=F,b(k=>({...k,[j.name]:F})),j.focus(),j.setSelectionRange(S,S),[0,10,50,100,200].forEach(k=>{setTimeout(()=>{const _=document.getElementById(c);_&&(_.focus(),_.setSelectionRange(S,S))},k)})):(b(E=>({...E,[j.name]:F})),requestAnimationFrame(()=>{const E=document.getElementById(c);E&&(E.focus(),E.setSelectionRange(S,S),setTimeout(()=>{const k=document.getElementById(c);k&&(k.focus(),k.setSelectionRange(S,S))},50))}))}},y=s=>{const c={...a,[s.target.name]:s.target.name==="noIndex"||s.target.name==="noFollow"?s.target.checked:s.target.value};b(c)},A=s=>c=>{if(!u.isEmpty(c.fieldValue)){const j=pe(c.fieldValue,s);j.success?y({target:{name:s,value:j.value}}):D.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to process AI response:"}),e.jsx("p",{children:j.error})]}))}c.error&&D.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to generate:"}),e.jsx("p",{children:c.error})]}))},le=()=>{const s=u.get(o,"seo.jsonLD","{}");if((s==null?void 0:s.trim())==="{}"){D.toast.error("Default page JSON-LD is empty");return}y({target:{name:"jsonLD",value:s}})};return e.jsxs("div",{className:"relative flex h-full flex-col","data-panel-id":"seo",children:[!r&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:e.jsx(n.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:e.jsx(n.AlertDescription,{children:t("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),e.jsxs("div",{className:"no-scrollbar flex-grow overflow-y-auto px-2 pb-20",children:[e.jsxs("div",{className:"mb-4 flex w-full items-center justify-between rounded-md bg-gray-100 px-2 py-1 text-left text-sm",children:[e.jsxs("span",{children:[e.jsx("div",{className:"font-medium",children:l==null?void 0:l.name}),e.jsx("span",{className:"font-mono text-xs leading-tight text-gray-500",children:l==null?void 0:l.slug})]}),e.jsx(i.LanguageSwitcher,{variant:"outline",showAdd:!1})]}),e.jsx("form",{className:"space-y-8",children:e.jsxs(n.Tabs,{value:m,onValueChange:O,className:"w-full",children:[e.jsxs(n.TabsList,{className:"mb-4 grid w-full grid-cols-3",children:[e.jsx(n.TabsTrigger,{value:"seo",children:t("SEO")}),e.jsx(n.TabsTrigger,{value:"opengraph",children:t("Meta Tags")}),e.jsx(n.TabsTrigger,{value:"jsonld",children:t("JSON-LD")})]}),e.jsx("div",{className:m==="seo"?"":"sr-only",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"keyword",children:t("Keyword")}),r&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>I(s,"keyword")})]}),e.jsx(n.Input,{type:"text",id:"keyword",name:"keyword",value:a.keyword,onChange:y,disabled:f||!r,placeholder:t("Enter keyword"),readOnly:!r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"title",children:t("SEO Title")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(C,{keyword:a.keyword,onComplete:A("title"),field:"title"}),r&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>I(s,"title")})]})]}),e.jsx(n.Input,{type:"text",id:"title",name:"title",value:a.title,onChange:y,disabled:f||!r,placeholder:t("Enter SEO title"),readOnly:!r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"description",children:t("SEO Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{keyword:a.keyword,onComplete:A("description"),field:"description"}),r&&e.jsx(i.NestedPathSelector,{data:d??{},onSelect:s=>I(s,"description")})]})]}),e.jsx(n.Textarea,{id:"description",name:"description",rows:5,value:a.description,onChange:y,disabled:f||!r,placeholder:t("Enter SEO description"),readOnly:!r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"title",children:t("Canonical URL")}),r&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>I(s,"canonicalUrl")})]}),e.jsx(n.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:a.canonicalUrl,onChange:y,disabled:f||!r,placeholder:t("Enter Canonical URL"),readOnly:!r})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(n.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:a.noIndex,onChange:y,disabled:f||!r,className:"h-4 w-4"}),e.jsx(n.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Index")})]}),e.jsx("p",{className:"mt-0 text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to index this page.")})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(n.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:a.noFollow,onChange:y,disabled:f||!r,className:"h-4 w-4"}),e.jsx(n.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Follow")})]}),e.jsx("p",{className:"text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to follow links on this page.")})]})]})}),e.jsx("div",{className:m==="opengraph"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 font-semibold text-slate-700",children:t("Open Graph")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"ogTitle",children:t("OG Title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{keyword:a.keyword,onComplete:A("ogTitle"),field:"ogTitle"}),r&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>I(s,"ogTitle")})]})]}),e.jsx(n.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:a.ogTitle,onChange:y,disabled:f||!r,placeholder:t("Enter OG title"),readOnly:!r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"ogDescription",children:t("OG Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{keyword:a.keyword,onComplete:A("ogDescription"),field:"ogDescription"}),r&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>I(s,"ogDescription")})]})]}),e.jsx(n.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:a.ogDescription,onChange:y,disabled:f||!r,placeholder:t("Enter OG description"),readOnly:!r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"ogImage",children:t("OG Image")}),r&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>{b({...a,ogImage:`{{${s}}}`,ogImageId:""})}})]}),e.jsx(i.ImagePicker,{assetId:a.ogImageId,assetUrl:a.ogImage,onChange:s=>{b({...a,ogImage:s.url,ogImageId:s.id})},disabled:f||!r,placeholder:t("Select OG image"),className:"mb-2"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"metaOther",children:t("Meta Tags")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(C,{keyword:a.keyword,onComplete:A("metaOther"),field:"metaOther"})})]}),e.jsx(i.SmartJsonInput,{id:"metaOther",value:a.metaOther,onChange:s=>{y({target:{name:"metaOther",value:s}})},placeholder:t("Enter Meta Tags JSON"),disabled:f||!r,readOnly:!r,pageData:d||{},rows:8,handleFieldInsert:I})]})]})]})})}),e.jsx("div",{className:m==="jsonld"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n.Label,{className:"text-xs",htmlFor:"jsonLD",children:t("JSON-LD")}),$&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(C,{keyword:a.keyword,onComplete:A("jsonLD"),field:"jsonLD"})})]}),e.jsx("div",{className:"hidden",children:JSON.stringify(d)}),e.jsx(i.SmartJsonInput,{id:"jsonLD",value:a.jsonLD,onChange:s=>{y({target:{name:"jsonLD",value:s}})},placeholder:t("Enter JSON-LD"),disabled:f||!r,readOnly:!r,pageData:d||{},rows:12,handleFieldInsert:I,hasJsonLdForSelectedLang:$,copyJsonLDFromDefaultPage:le})]})})})]})})]}),r&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-background p-4",children:[ne?e.jsx(n.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{m==="jsonld"?ae():m==="opengraph"?re():oe()},disabled:f||!r||!L,children:t(M?"Resetting...":`Reset to ${m==="jsonld"?"Default JSON-LD":m==="opengraph"?"Default Open Graph":"Default SEO"}`)}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(n.Button,{onClick:W,disabled:!me(a==null?void 0:a.jsonLD)||(T.current[g]?u.isEqual(T.current[g],a):!1)||f||!r,children:t(B?"Saving...":"Save")}),e.jsx(n.Button,{variant:"link",className:"text-gray-500 hover:text-gray-700",onClick:()=>p("outline"),children:t("Cancel")})]})]}),e.jsx(he,{isOpen:Z,onClose:()=>{P(!1),q(null)},onSave:async()=>{w&&(await W(),w.switchHandler(),P(!1),q(null))},onDiscard:()=>{if(w){const s=T.current[g];s&&b(s),w.switchHandler(),P(!1),q(null)}},isSaving:B,fromLanguage:(w==null?void 0:w.fromLang)||g,toLanguage:(w==null?void 0:w.toLang)||""})]})};K.displayName="SeoPanel";exports.default=K;