@chaibuilder/sdk 4.0.0-beta.48 → 4.0.0-beta.49
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.
- package/dist/{2SSKDMRQ-DqwAKdGS.cjs → 2SSKDMRQ-CjvuNdPo.cjs} +1 -1
- package/dist/{2SSKDMRQ-CLLNh3td.js → 2SSKDMRQ-Dvf9zadl.js} +2 -2
- package/dist/{AP7HFJJL-BA2SSB20.cjs → AP7HFJJL-DYFttFoI.cjs} +1 -1
- package/dist/{AP7HFJJL-wgsmCJDJ.js → AP7HFJJL-q4dJdyFs.js} +1 -1
- package/dist/{IconPicker-DsT0ONLh.js → IconPicker-Bf163F7t.js} +1 -1
- package/dist/{IconPicker-BQy4V5jA.cjs → IconPicker-JWhYq2Gp.cjs} +1 -1
- package/dist/{WDYDFRGG-DyEYv-Y5.cjs → WDYDFRGG-BEksfGMC.cjs} +1 -1
- package/dist/{WDYDFRGG-EEb06kwn.js → WDYDFRGG-O9GIrtX0.js} +2 -2
- package/dist/{actions-registery-2natwC9b.cjs → actions-registery-BHbZHkE3.cjs} +10 -2
- package/dist/{actions-registery-wRY05tEE.js → actions-registery-gJb_wq2F.js} +24 -12
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +10 -3
- package/dist/actions.js +6 -4
- package/dist/{active-in-another-tab-DE2fn30l.js → active-in-another-tab-B4Ur0JP7.js} +2 -2
- package/dist/{active-in-another-tab-p0hkvIFc.cjs → active-in-another-tab-BPdx4lWh.cjs} +1 -1
- package/dist/{add-new-language-page-f2wam593.cjs → add-new-language-page-BfUp5Ua2.cjs} +1 -1
- package/dist/{add-new-language-page-CH7GtcqC.js → add-new-language-page-CRR93tLq.js} +3 -3
- package/dist/{add-new-page-CV7A1XJQ.cjs → add-new-page-B8NGK6WS.cjs} +1 -1
- package/dist/{add-new-page-8d0Nn-zI.js → add-new-page-Ppy5-y5j.js} +2 -2
- package/dist/{ai-panel-default-lang-Dcm4e1o8.js → ai-panel-default-lang-BXYQye3N.js} +6 -5
- package/dist/{ai-panel-default-lang-BJLeTdw3.cjs → ai-panel-default-lang-VhgmHFoQ.cjs} +3 -3
- package/dist/{ai-panel-other-lang-B48Y5C8z.js → ai-panel-other-lang-DaCf-cq4.js} +36 -35
- package/dist/ai-panel-other-lang-Ds0EXeUC.cjs +1 -0
- package/dist/{ai-prompt-input-DhVfzVhy.js → ai-prompt-input-7iWk72w5.js} +2 -2
- package/dist/{ai-prompt-input-C1yoNntS.cjs → ai-prompt-input-nZ5_Dm7X.cjs} +1 -1
- package/dist/{ai-translation-prompt-CUYVv2jG.js → ai-translation-prompt-1OUs1P7n.js} +1 -1
- package/dist/{ai-translation-prompt-mj26BpgQ.cjs → ai-translation-prompt-B16cK-1Q.cjs} +1 -1
- package/dist/{change-password-modal-DiEQWZez.js → change-password-modal-CdvJR1Ln.js} +2 -2
- package/dist/{change-password-modal-DFupkIGx.cjs → change-password-modal-D5eXjiYq.cjs} +1 -1
- package/dist/{code-editor-CazbxsDv.js → code-editor-CyLjDiEp.js} +1 -1
- package/dist/{code-editor-BiLiryYr.cjs → code-editor-SWbfFj1E.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-CpKDDW6u.js → continue-editing-in-this-client-BrSvK-Ay.js} +2 -2
- package/dist/{continue-editing-in-this-client-C3NoncEN.cjs → continue-editing-in-this-client-Cmi-GkYZ.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-DFdZ471B.cjs → css-import-modal-Bdwgd05S.cjs} +1 -1
- package/dist/{css-import-modal-BOQr_e6S.js → css-import-modal-Be47CBJn.js} +1 -1
- package/dist/{delete-page-DIZhbU2t.js → delete-page-C99K2qzS.js} +2 -2
- package/dist/{delete-page-D8Vr-1aC.cjs → delete-page-DLohaU-U.cjs} +1 -1
- package/dist/{design-token-usage-Co5Lj1HN.js → design-token-usage-D1lWCJ3L.js} +1 -1
- package/dist/{design-token-usage-N5DLBdWf.cjs → design-token-usage-eY2wQ0l3.cjs} +1 -1
- package/dist/{digital-asset-manager-CObQa_0R.js → digital-asset-manager-BZMb6sC7.js} +3 -3
- package/dist/{digital-asset-manager-uXP27Dou.cjs → digital-asset-manager-Z5aJxkq0.cjs} +1 -1
- package/dist/{duplicate-page-xpV-pRVU.js → duplicate-page-CDc2X0eW.js} +3 -3
- package/dist/{duplicate-page-DomSAvnp.cjs → duplicate-page-D5Gtvqdv.cjs} +1 -1
- package/dist/{dynamic-page-selector-CYZv-SlK.cjs → dynamic-page-selector-DZHhX008.cjs} +1 -1
- package/dist/{dynamic-page-selector-Bl5kYPWG.js → dynamic-page-selector-DvNBXo6o.js} +2 -2
- package/dist/{image-editor-CDFnNWAz.js → image-editor-BBvvi9Vm.js} +1 -1
- package/dist/{image-editor-pOsT95KQ.cjs → image-editor-DwhTYkVR.cjs} +1 -1
- package/dist/{index-j-XsKW-V.cjs → index-BVwFJWDq.cjs} +3 -3
- package/dist/{index-DonDtb8f.cjs → index-DCJDQs1a.cjs} +8 -8
- package/dist/{index-Cyz_Iww4.js → index-LBTm1Jmk.js} +35 -26
- package/dist/{index-BbkBlCE2.js → index-OuHV9Ann.js} +7 -6
- package/dist/{json-diff-viewer-CoEViavL.cjs → json-diff-viewer-Cb1CmRqP.cjs} +1 -1
- package/dist/{json-diff-viewer-amjoEZ5K.js → json-diff-viewer-DG6qMOBS.js} +2 -2
- package/dist/{lang-panel-DPpIXFl4.js → lang-panel-B3USOxGq.js} +3 -3
- package/dist/{lang-panel-BzWstLZ-.cjs → lang-panel-DxoJ0v4y.cjs} +1 -1
- package/dist/{manage-design-tokens-BVfEFOrN.js → manage-design-tokens-6YGIctip.js} +2 -2
- package/dist/{manage-design-tokens-modal-m3D2luIa.cjs → manage-design-tokens-modal-BSSCXH8Y.cjs} +1 -1
- package/dist/{manage-design-tokens-modal-CBOw_Dg6.js → manage-design-tokens-modal-CzsnN49F.js} +2 -2
- package/dist/{manage-design-tokens-CIiwBv2v.cjs → manage-design-tokens-udLBvkHA.cjs} +1 -1
- package/dist/{mark-as-template-C2-S_aA2.cjs → mark-as-template-B9yLcasI.cjs} +1 -1
- package/dist/{mark-as-template-CQjchLk7.js → mark-as-template-CP_F9ZQ4.js} +2 -2
- package/dist/{nested-path-selector-content-BtsI3H0i.js → nested-path-selector-content-DmtCI3q9.js} +1 -1
- package/dist/{nested-path-selector-content-Dd3NzUE0.cjs → nested-path-selector-content-aTdu-o0e.cjs} +1 -1
- package/dist/{no-language-page-content-CggJC14_.cjs → no-language-page-content-C-MCdPXt.cjs} +1 -1
- package/dist/{no-language-page-content-BrDAjkdi.js → no-language-page-content-D8t5dfgh.js} +2 -2
- package/dist/{no-language-page-dialog-DSbcLM8f.js → no-language-page-dialog-C_fHI2zI.js} +2 -2
- package/dist/{no-language-page-dialog-Dkxdu99i.cjs → no-language-page-dialog-D4QIAHnE.cjs} +1 -1
- package/dist/{page-creator-DqKFL1sB.cjs → page-creator-Cz_ah-qE.cjs} +1 -1
- package/dist/{page-creator-CR-FbJ7C.js → page-creator-DKEkuGCO.js} +3 -3
- package/dist/{page-lock-CwzMBdD-.js → page-lock-CwZKJ4IE.js} +2 -2
- package/dist/{page-lock-D4Anxwpy.cjs → page-lock-DdCvtA-I.cjs} +1 -1
- package/dist/{page-locked-dialog-UrTgnXd6.cjs → page-locked-dialog-CrTDBoC4.cjs} +1 -1
- package/dist/{page-locked-dialog-Dv_unUwx.js → page-locked-dialog-DqLlooUz.js} +2 -2
- package/dist/{page-manager-new-DuqhyqMY.cjs → page-manager-new-ah6QYar2.cjs} +1 -1
- package/dist/{page-manager-new-DpCTazS0.js → page-manager-new-ttsrxdW9.js} +3 -3
- package/dist/{page-manager-search-and-filter-Yt0pjK_r.cjs → page-manager-search-and-filter-D7AupT6_.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-B6F-ZvdQ.js → page-manager-search-and-filter-bsqZ6wnI.js} +2 -2
- package/dist/{page-revisions-content-C2VMkAt4.cjs → page-revisions-content-B6hsIla7.cjs} +1 -1
- package/dist/{page-revisions-content-CUPsMEVU.js → page-revisions-content-C5O8_Fms.js} +3 -3
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +16 -10
- package/dist/pages.js +1 -1
- package/dist/{publish-pages-content-BrjDksNY.cjs → publish-pages-content-BrajJUcP.cjs} +1 -1
- package/dist/{publish-pages-content-CK0ahL2t.js → publish-pages-content-KZVMHT6V.js} +3 -3
- package/dist/{rte-widget-modal-Dktetdg4.cjs → rte-widget-modal-CiTwsXTr.cjs} +1 -1
- package/dist/{rte-widget-modal-DgEF73WC.js → rte-widget-modal-IU8JzPuZ.js} +1 -1
- package/dist/{save-to-lib-Bs6-wr2u.js → save-to-lib-DMnv7ENo.js} +2 -2
- package/dist/{save-to-lib-CuVYPtm-.cjs → save-to-lib-Dc700Aop.cjs} +1 -1
- package/dist/{selected-block-display-BCcwnFzJ.cjs → selected-block-display-CAFEOrLV.cjs} +1 -1
- package/dist/{selected-block-display-D-lzXUfE.js → selected-block-display-CidmQ-wz.js} +2 -2
- package/dist/{seo-panel-By-TlhHK.js → seo-panel-Br8gxDxu.js} +155 -165
- package/dist/{seo-panel-DTqsu3I0.cjs → seo-panel-CMY-adM-.cjs} +2 -2
- package/dist/{shared-json-ld-C_vaAxgT.cjs → shared-json-ld-CMH-eRUq.cjs} +1 -1
- package/dist/{shared-json-ld-CMCwFEI0.js → shared-json-ld-uvMmwCYp.js} +2 -2
- package/dist/{slug-input-DCmvuN69.cjs → slug-input-CiHC5l3r.cjs} +1 -1
- package/dist/{slug-input-bhZSv9VS.js → slug-input-DLWTMTsO.js} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-BGvKpN5m.cjs → take-over-request-IRLgF1dG.cjs} +1 -1
- package/dist/{take-over-request-f0dbfkLe.js → take-over-request-KdR1_h_K.js} +2 -2
- package/dist/{translation-warning-modal-_0YmCcU8.cjs → translation-warning-modal-CLZ9tC1F.cjs} +1 -1
- package/dist/{translation-warning-modal-D0-WNJnG.js → translation-warning-modal-CzNt6LDO.js} +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/{unmark-as-template-WE3WJ-RJ.js → unmark-as-template-C5ovsEBP.js} +2 -2
- package/dist/{unmark-as-template-BE1BO8Z0.cjs → unmark-as-template-F7TdgWjI.cjs} +1 -1
- package/dist/{unpublish-page-B4A-GQEz.js → unpublish-page-0fR1o0b7.js} +2 -2
- package/dist/{unpublish-page-DrZnWLVM.cjs → unpublish-page-CUr8Xub6.cjs} +1 -1
- package/dist/{unpublished-partials-modal-CGK-4WJ3.js → unpublished-partials-modal-BhNAub_z.js} +1 -1
- package/dist/{unpublished-partials-modal-KFXm1fG4.cjs → unpublished-partials-modal-Cv5R9-hi.cjs} +1 -1
- package/dist/{web-preview-ClV1a6hl.cjs → web-preview-CuMYekVJ.cjs} +1 -1
- package/dist/{web-preview-BSmef-RL.js → web-preview-D9pXonAv.js} +1 -1
- package/package.json +1 -1
- package/dist/ai-panel-other-lang-Ch0RHXqZ.cjs +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { jsxs as g, Fragment as L, jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { r as ee, a as te, s as se, t as oe } from "./index-
|
|
3
|
-
import { C as ne, a as re, b as ae, R as le, c as ce, d as ie, T as de, M as me, e as ue, f as he, S as pe, g as
|
|
4
|
-
import { Bot as
|
|
2
|
+
import { r as ee, a as te, s as se, t as oe } from "./index-OuHV9Ann.js";
|
|
3
|
+
import { C as ne, a as re, b as ae, R as le, c as ce, d as ie, T as de, M as me, e as ue, f as he, S as pe, g as Se } from "./selected-block-display-CidmQ-wz.js";
|
|
4
|
+
import { Bot as ye } from "lucide-react";
|
|
5
5
|
import { useRef as Te, useEffect as ke, Suspense as P, lazy as _, Fragment as ge, startTransition as F } from "react";
|
|
6
6
|
import { useTranslation as fe } from "react-i18next";
|
|
7
|
-
import { l as we, m as
|
|
8
|
-
const
|
|
7
|
+
import { l as we, m as xe } from "./index-LBTm1Jmk.js";
|
|
8
|
+
const Ae = _(() => import("./ai-translation-prompt-1OUs1P7n.js")), Me = _(() => import("./ai-prompt-input-7iWk72w5.js")), Ce = ({
|
|
9
9
|
fetch: j,
|
|
10
10
|
input: m,
|
|
11
11
|
messages: f,
|
|
12
|
-
setInput:
|
|
12
|
+
setInput: A,
|
|
13
13
|
isLoading: u,
|
|
14
|
-
handleStop:
|
|
15
|
-
setMessages:
|
|
14
|
+
handleStop: z,
|
|
15
|
+
setMessages: M,
|
|
16
16
|
setIsLoading: w,
|
|
17
17
|
selectedLang: h,
|
|
18
|
-
currentBlock:
|
|
19
|
-
fallbackLang:
|
|
20
|
-
abortController:
|
|
18
|
+
currentBlock: U,
|
|
19
|
+
fallbackLang: q,
|
|
20
|
+
abortController: x,
|
|
21
21
|
setAbortController: J,
|
|
22
|
-
setCurrentBlock:
|
|
22
|
+
setCurrentBlock: N,
|
|
23
23
|
selectedModel: K,
|
|
24
24
|
onModelChange: V
|
|
25
25
|
}) => {
|
|
26
|
-
const { t: r } = fe(), { models:
|
|
26
|
+
const { t: r } = fe(), { models: b } = we(), t = xe(), W = b.find((e) => e.id === "google/gemini-3-flash") || b[0], E = K || W.id, $ = Te(null), p = ee(), [, G] = te(), R = se(), H = oe(), Q = () => {
|
|
27
27
|
var e;
|
|
28
28
|
(e = $.current) == null || e.scrollIntoView({ behavior: "smooth" });
|
|
29
29
|
};
|
|
@@ -32,12 +32,12 @@ const Me = _(() => import("./ai-translation-prompt-CUYVv2jG.js")), Ne = _(() =>
|
|
|
32
32
|
}, [f, u]);
|
|
33
33
|
const v = async (e, B, X) => {
|
|
34
34
|
var D, O;
|
|
35
|
-
p &&
|
|
35
|
+
p && N(p);
|
|
36
36
|
const I = (e == null ? void 0 : e.toLowerCase()) === "translate", C = {
|
|
37
37
|
id: Date.now().toString(),
|
|
38
38
|
role: "user",
|
|
39
|
-
content:
|
|
40
|
-
fallbackLang:
|
|
39
|
+
content: Se({
|
|
40
|
+
fallbackLang: q,
|
|
41
41
|
userInput: B || e,
|
|
42
42
|
language: h,
|
|
43
43
|
blocks: I ? R() : R(h)
|
|
@@ -52,29 +52,30 @@ const Me = _(() => import("./ai-translation-prompt-CUYVv2jG.js")), Ne = _(() =>
|
|
|
52
52
|
};
|
|
53
53
|
w(!0);
|
|
54
54
|
const Z = new AbortController();
|
|
55
|
-
J(Z),
|
|
55
|
+
J(Z), M((a) => [...a, C, Y]), w(!0);
|
|
56
56
|
const n = X || E;
|
|
57
57
|
(D = t.onAIEvent) == null || D.call(t, { type: "stream_start", model: n, timestamp: Date.now() });
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
59
|
+
const a = {
|
|
60
60
|
messages: [C],
|
|
61
61
|
initiator: I ? "TRANSLATE_CONTENT" : "UPDATE_CONTENT",
|
|
62
|
-
model: n
|
|
63
|
-
|
|
62
|
+
model: n,
|
|
63
|
+
context: t.context
|
|
64
|
+
}, l = await j({ body: { action: "ASK_AI", data: a }, streamResponse: !0 });
|
|
64
65
|
if (!l.ok)
|
|
65
66
|
throw new Error(r("Failed to get AI response"));
|
|
66
|
-
const c = (O = l.body) == null ? void 0 : O.getReader(),
|
|
67
|
+
const c = (O = l.body) == null ? void 0 : O.getReader(), S = new TextDecoder();
|
|
67
68
|
let o = "";
|
|
68
69
|
if (!c) throw new Error(r("Response body is not readable"));
|
|
69
70
|
for (; ; ) {
|
|
70
71
|
const { done: d, value: T } = await c.read();
|
|
71
72
|
if (d)
|
|
72
73
|
break;
|
|
73
|
-
const k =
|
|
74
|
-
o += k,
|
|
74
|
+
const k = S.decode(T, { stream: !0 });
|
|
75
|
+
o += k, M((i) => (i[i.length - 1].content = o, [...i]));
|
|
75
76
|
}
|
|
76
|
-
const
|
|
77
|
-
H(
|
|
77
|
+
const y = JSON.parse(o == null ? void 0 : o.replace("```json", "").replace("```", ""));
|
|
78
|
+
H(y), F(() => {
|
|
78
79
|
var T, k, i;
|
|
79
80
|
const d = Date.now();
|
|
80
81
|
(T = t.onSuccess) == null || T.call(t, { content: o, model: n, timestamp: d }), (k = t.onComplete) == null || k.call(t, { success: !0, content: o, model: n, timestamp: d }), (i = t.onAIEvent) == null || i.call(t, {
|
|
@@ -85,18 +86,18 @@ const Me = _(() => import("./ai-translation-prompt-CUYVv2jG.js")), Ne = _(() =>
|
|
|
85
86
|
});
|
|
86
87
|
});
|
|
87
88
|
} catch (a) {
|
|
88
|
-
|
|
89
|
-
var
|
|
89
|
+
x == null || x.abort(), F(() => {
|
|
90
|
+
var S, o, y;
|
|
90
91
|
const l = a instanceof Error ? a.message : String(a), c = Date.now();
|
|
91
|
-
(
|
|
92
|
+
(S = t.onError) == null || S.call(t, { error: l, model: n, timestamp: c }), (o = t.onComplete) == null || o.call(t, { success: !1, error: l, model: n, timestamp: c }), (y = t.onAIEvent) == null || y.call(t, { type: "error", error: l, model: n, timestamp: c });
|
|
92
93
|
});
|
|
93
94
|
} finally {
|
|
94
|
-
w(!1),
|
|
95
|
+
w(!1), A(""), N(null);
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
98
|
return /* @__PURE__ */ g(L, { children: [
|
|
98
99
|
/* @__PURE__ */ s("div", { className: "py-2", children: /* @__PURE__ */ s(P, { fallback: /* @__PURE__ */ s("div", { children: r("Loading...") }), children: /* @__PURE__ */ s(
|
|
99
|
-
|
|
100
|
+
Ae,
|
|
100
101
|
{
|
|
101
102
|
isLoading: u,
|
|
102
103
|
selectedBlock: p,
|
|
@@ -108,7 +109,7 @@ const Me = _(() => import("./ai-translation-prompt-CUYVv2jG.js")), Ne = _(() =>
|
|
|
108
109
|
f.length === 0 && /* @__PURE__ */ s(
|
|
109
110
|
ae,
|
|
110
111
|
{
|
|
111
|
-
icon: /* @__PURE__ */ s(
|
|
112
|
+
icon: /* @__PURE__ */ s(ye, { size: 48, className: "text-gray-300" }),
|
|
112
113
|
title: r("Start a conversation with the AI assistant to translate/edit your content"),
|
|
113
114
|
description: r(
|
|
114
115
|
"Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language."
|
|
@@ -125,15 +126,15 @@ const Me = _(() => import("./ai-translation-prompt-CUYVv2jG.js")), Ne = _(() =>
|
|
|
125
126
|
/* @__PURE__ */ g("div", { className: "border-gray-200 pb-2", children: [
|
|
126
127
|
/* @__PURE__ */ s(pe, { onRemove: () => G([]), isLoading: u }),
|
|
127
128
|
/* @__PURE__ */ s(P, { fallback: /* @__PURE__ */ s("div", { children: r("Loading...") }), children: /* @__PURE__ */ s(
|
|
128
|
-
|
|
129
|
+
Me,
|
|
129
130
|
{
|
|
130
131
|
input: m,
|
|
131
|
-
setInput:
|
|
132
|
+
setInput: A,
|
|
132
133
|
onSend: v,
|
|
133
|
-
onStop:
|
|
134
|
+
onStop: z,
|
|
134
135
|
isLoading: u,
|
|
135
136
|
selectedLang: h,
|
|
136
|
-
currentBlock: p ||
|
|
137
|
+
currentBlock: p || U,
|
|
137
138
|
disabled: (m == null ? void 0 : m.length) === 0,
|
|
138
139
|
selectedModel: E,
|
|
139
140
|
onModelChange: V
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("./index-DCJDQs1a.cjs"),n=require("./selected-block-display-CAFEOrLV.cjs"),L=require("lucide-react"),r=require("react"),ee=require("react-i18next"),O=require("./index-BVwFJWDq.cjs"),te=r.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-B16cK-1Q.cjs"))),se=r.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-nZ5_Dm7X.cjs"))),ne=({fetch:_,input:x,messages:w,setInput:b,isLoading:m,handleStop:F,setMessages:A,setIsLoading:v,selectedLang:j,currentBlock:z,fallbackLang:U,abortController:R,setAbortController:J,setCurrentBlock:M,selectedModel:K,onModelChange:V})=>{const{t:l}=ee.useTranslation(),{models:N}=O.useAIModels(),s=O.useAIConfig(),W=N.find(e=>e.id==="google/gemini-3-flash")||N[0],E=K||W.id,G=r.useRef(null),p=g.useSelectedBlock(),[,H]=g.useSelectedBlockIds(),B=g.useI18nBlocks(),Q=g.useStreamMultipleBlocksProps(),X=()=>{var e;(e=G.current)==null||e.scrollIntoView({behavior:"smooth"})};r.useEffect(()=>{X()},[w,m]);const I=async(e,f,Y)=>{var C,D;p&&M(p);const q=(e==null?void 0:e.toLowerCase())==="translate",P={id:Date.now().toString(),role:"user",content:n.getTranslationUserPrompt({fallbackLang:U,userInput:f||e,language:j,blocks:q?B():B(j)}),userMessage:f||e||l("Translate the content")},Z={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};v(!0);const $=new AbortController;J($),A(c=>[...c,P,Z]),v(!0);const a=Y||E;(C=s.onAIEvent)==null||C.call(s,{type:"stream_start",model:a,timestamp:Date.now()});try{const c={messages:[P],initiator:q?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:a,context:s.context},i=await _({body:{action:"ASK_AI",data:c},streamResponse:!0});if(!i.ok)throw new Error(l("Failed to get AI response"));const d=(D=i.body)==null?void 0:D.getReader(),y=new TextDecoder;let o="";if(!d)throw new Error(l("Response body is not readable"));for(;;){const{done:h,value:T}=await d.read();if(h)break;const k=y.decode(T,{stream:!0});o+=k,A(u=>(u[u.length-1].content=o,[...u]))}const S=JSON.parse(o==null?void 0:o.replace("```json","").replace("```",""));Q(S),r.startTransition(()=>{var T,k,u;const h=Date.now();(T=s.onSuccess)==null||T.call(s,{content:o,model:a,timestamp:h}),(k=s.onComplete)==null||k.call(s,{success:!0,content:o,model:a,timestamp:h}),(u=s.onAIEvent)==null||u.call(s,{type:"completion",content:o,model:a,timestamp:h})})}catch(c){R==null||R.abort(),r.startTransition(()=>{var y,o,S;const i=c instanceof Error?c.message:String(c),d=Date.now();(y=s.onError)==null||y.call(s,{error:i,model:a,timestamp:d}),(o=s.onComplete)==null||o.call(s,{success:!1,error:i,model:a,timestamp:d}),(S=s.onAIEvent)==null||S.call(s,{type:"error",error:i,model:a,timestamp:d})})}finally{v(!1),b(""),M(null)}};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"py-2",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{children:l("Loading...")}),children:t.jsx(te,{isLoading:m,selectedBlock:p,selectedLang:j,onClick:I})})}),t.jsx(n.Conversation,{children:t.jsxs(n.ConversationContent,{className:"gap-4 px-0",children:[w.length===0&&t.jsx(n.ConversationEmptyState,{icon:t.jsx(L.Bot,{size:48,className:"text-gray-300"}),title:l("Start a conversation with the AI assistant to translate/edit your content"),description:l("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),w.map(e=>e.role!=="system"&&t.jsx(r.Fragment,{children:e.isReasoning?t.jsxs(n.Reasoning,{isStreaming:e.isStreaming,defaultOpen:!0,children:[t.jsx(n.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),t.jsx(n.ReasoningContent,{className:"p-0 text-xs",children:e.content})]}):e.isTask?t.jsx(n.TaskMessage,{content:e.content,isLoading:e.isTaskLoading}):t.jsx(n.Message,{from:e.role,children:t.jsx(n.MessageContent,{className:"p-0",children:e.role==="assistant"?t.jsx(n.MessageResponse,{className:"p-0 text-xs",children:e.content}):t.jsx("div",{className:"p-0 text-xs",children:e.userMessage||e.content})})})},e.id))]})}),t.jsxs("div",{className:"border-gray-200 pb-2",children:[t.jsx(n.SelectedBlockDisplay,{onRemove:()=>H([]),isLoading:m}),t.jsx(r.Suspense,{fallback:t.jsx("div",{children:l("Loading...")}),children:t.jsx(se,{input:x,setInput:b,onSend:I,onStop:F,isLoading:m,selectedLang:j,currentBlock:p||z,disabled:(x==null?void 0:x.length)===0,selectedModel:E,onModelChange:V})})]})]})};exports.default=ne;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as e, jsxs as N, Fragment as ie } from "react/jsx-runtime";
|
|
2
2
|
import { E as y, B as E } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { T as le, aB as ce, v as ue, w as de, x as me, y as pe, aC as fe, aD as he, D as ge, aE as ve, e as be, g as xe, C as we, j as Ne, l as ye, m as Ie } from "./index-
|
|
3
|
+
import { T as le, aB as ce, v as ue, w as de, x as me, y as pe, aC as fe, aD as he, D as ge, aE as ve, e as be, g as xe, C as we, j as Ne, l as ye, m as Ie } from "./index-OuHV9Ann.js";
|
|
4
4
|
import { cva as X } from "class-variance-authority";
|
|
5
5
|
import { PaperclipIcon as Se, XIcon as Y, PlusIcon as ke, ImageIcon as ze, MicIcon as De, CornerDownLeftIcon as Pe, Loader2Icon as Te, SquareIcon as Ae, Cpu as Le, Paperclip as Ce, GlobeIcon as Re, Square as je, Send as Me } from "lucide-react";
|
|
6
6
|
import { nanoid as Ue } from "nanoid";
|
|
7
7
|
import { useContext as W, useRef as F, useEffect as A, useState as L, useCallback as O, useMemo as Fe, createContext as _, Fragment as Oe, startTransition as Ge, Children as Be } from "react";
|
|
8
8
|
import { useTranslation as Ee } from "react-i18next";
|
|
9
|
-
import { l as J } from "./index-
|
|
9
|
+
import { l as J } from "./index-LBTm1Jmk.js";
|
|
10
10
|
function We({ className: t, ...n }) {
|
|
11
11
|
return /* @__PURE__ */ e(
|
|
12
12
|
"div",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),y=require("./index-DonDtb8f.cjs"),W=require("class-variance-authority"),k=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),_=require("./index-j-XsKW-V.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const re=W.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,p;l.target.closest("button")||(p=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||p.focus()},...a})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(y.Textarea,{"data-slot":"input-group-control",className:b.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var h;const l=q(),o=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",g=o||(d?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(y.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...a,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:o||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:m=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:g})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:o||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(y.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:p,maxFileSize:d,onError:g,onSubmit:h,children:m,...I})=>{const n=X(),i=!!n,x=c.useRef(null),T=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{var v;const r=(v=T.current)==null?void 0:v.closest("form");r instanceof HTMLFormElement&&(S.current=r)},[]);const[P,z]=c.useState([]),D=i?n.attachments.files:P,O=c.useCallback(()=>{var r;(r=x.current)==null||r.click()},[]),N=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),L=c.useCallback(r=>{const v=Array.from(r),f=v.filter(w=>N(w));if(v.length&&f.length===0){g==null||g({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,j=f.filter(u);if(f.length>0&&j.length===0){g==null||g({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof p=="number"?Math.max(0,p-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(g==null||g({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const E of ee)B.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(B)})},[N,p,d,g]),A=i?r=>n.attachments.add(r):L,M=i?r=>n.attachments.remove(r):r=>z(v=>{const f=v.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),v.filter(u=>u.id!==r)}),R=i?()=>n.attachments.clear():()=>z(r=>{for(const v of r)v.url&&URL.revokeObjectURL(v.url);return[]}),U=i?()=>n.attachments.openFileDialog():O;c.useEffect(()=>{i&&n.__registerFileInput(x,()=>{var r;return(r=x.current)==null?void 0:r.click()})},[i,n]),c.useEffect(()=>{o&&x.current&&D.length===0&&(x.current.value="")},[D,o]),c.useEffect(()=>{const r=S.current;if(!r)return;const v=u=>{var j,w;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var j,w,C;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault(),(C=u.dataTransfer)!=null&&C.files&&u.dataTransfer.files.length>0&&A(u.dataTransfer.files)};return r.addEventListener("dragover",v),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",v),r.removeEventListener("drop",f)}},[A]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,j;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault()},v=f=>{var u,j,w;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&A(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",v)}},[A,l]),c.useEffect(()=>()=>{if(!i)for(const r of D)r.url&&URL.revokeObjectURL(r.url)},[i,D]);const Y=r=>{r.currentTarget.files&&A(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,j)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=j,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:D.map(r=>({...r,id:r.id})),add:A,remove:M,clear:R,openFileDialog:U,fileInputRef:x}),[D,A,M,R,U]),Z=r=>{r.preventDefault();const v=r.currentTarget,f=i?n.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(D.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const j=h({text:f,files:u},r);j instanceof Promise?j.then(()=>{R(),i&&n.textInput.clear()}).catch(()=>{}):(R(),i&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:T}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:Y,ref:x,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...I,children:e.jsx(ne,{className:"overflow-hidden",children:m})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),p=q(),[d,g]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const i=n.currentTarget.form,x=i==null?void 0:i.querySelector('button[type="submit"]');if(x!=null&&x.disabled)return;i==null||i.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&p.files.length>0){n.preventDefault();const i=p.files.at(-1);i&&p.remove(i.id)}},m=n=>{var T;const i=(T=n.clipboardData)==null?void 0:T.items;if(!i)return;const x=[];for(const S of i)if(S.kind==="file"){const P=S.getAsFile();P&&x.push(P)}x.length>0&&(n.preventDefault(),p.add(x))},I=o?{value:o.textInput.value,onChange:n=>{o.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>g(!1),onCompositionStart:()=>g(!0),onKeyDown:h,onPaste:m,placeholder:a,...l,...I})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(y.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(y.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(y.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...p})=>{let d=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...p,children:o??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,p]=c.useState(!1),[d,g]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const I=window.SpeechRecognition||window.webkitSpeechRecognition,n=new I;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{p(!0)},n.onend=()=>{p(!1)},n.onresult=i=>{var T;let x="";for(let S=i.resultIndex;S<i.results.length;S++){const P=i.results[S];P.isFinal&&(x+=((T=P[0])==null?void 0:T.transcript)??"")}if(x&&(s!=null&&s.current)){const S=s.current,P=S.value,z=P+(P?" ":"")+x;S.value=z,S.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},n.onerror=i=>{console.error("Speech recognition error:",i.error),p(!1)},h.current=n,c.startTransition(()=>g(n))}return()=>{h.current&&h.current.stop()}},[s,a]);const m=c.useCallback(()=>{d&&(o?d.stop():d.start())},[d,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:m,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(y.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(y.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(y.Dialog,{...t}),ke=t=>e.jsx(y.DialogTrigger,{...t}),Pe=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(y.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(y.DialogTitle,{className:"sr-only",children:a}),e.jsx(y.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Te=t=>e.jsx(y.CommandList,{...t}),ze=t=>e.jsx(y.CommandGroup,{...t}),De=t=>e.jsx(y.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),{models:p}=_.useAIModels(),d=p.find(m=>m.id===t)||p[0],g=p.reduce((m,I)=>(m[I.provider]||(m[I.provider]=[]),m[I.provider].push(I),m),{}),h=m=>{s(m),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:d.name})]})}),e.jsxs(Pe,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Te,{children:Object.entries(g).map(([m,I])=>e.jsx(ze,{heading:m.charAt(0).toUpperCase()+m.slice(1),children:I.map(n=>e.jsxs(De,{value:n.id,onSelect:()=>h(n.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:n.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.description})]}),t===n.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},n.id))},m))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:p,selectedLang:d,selectedModel:g,onModelChange:h})=>{const{t:m}=se.useTranslation(),{models:I}=_.useAIModels(),n=I.find(N=>N.id==="google/gemini-3-flash")||I[0],[i,x]=c.useState(g||n.id),[T,S]=c.useState(null),P=c.useRef(null),[z,D]=c.useState(!1);c.useEffect(()=>{if(!d){const N=localStorage.getItem(V);N?(x(N),h==null||h(N)):(x(n.id),h==null||h(n.id))}},[d,h,n.id]);const O=N=>{var M;const L=N.files.find(R=>{var U;return(U=R.mediaType)==null?void 0:U.startsWith("image/")}),A=(L==null?void 0:L.url)||T;a((M=N.text)==null?void 0:M.trim(),void 0,A,i),S(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:O,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:N=>e.jsx(ue,{className:"text-xs",data:N})})}),e.jsx(fe,{ref:P,value:t,onChange:N=>s(N.target.value),placeholder:m(d?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:i,onModelChange:N=>{x(N),h==null||h(N),localStorage.setItem(V,N)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!z),variant:z?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:m("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||p,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),y=require("./index-DCJDQs1a.cjs"),W=require("class-variance-authority"),k=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),_=require("./index-BVwFJWDq.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const re=W.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,p;l.target.closest("button")||(p=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||p.focus()},...a})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(y.Textarea,{"data-slot":"input-group-control",className:b.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var h;const l=q(),o=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",g=o||(d?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(y.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...a,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:o||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:m=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:g})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:o||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(y.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:p,maxFileSize:d,onError:g,onSubmit:h,children:m,...I})=>{const n=X(),i=!!n,x=c.useRef(null),T=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{var v;const r=(v=T.current)==null?void 0:v.closest("form");r instanceof HTMLFormElement&&(S.current=r)},[]);const[P,z]=c.useState([]),D=i?n.attachments.files:P,O=c.useCallback(()=>{var r;(r=x.current)==null||r.click()},[]),N=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),L=c.useCallback(r=>{const v=Array.from(r),f=v.filter(w=>N(w));if(v.length&&f.length===0){g==null||g({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,j=f.filter(u);if(f.length>0&&j.length===0){g==null||g({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof p=="number"?Math.max(0,p-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(g==null||g({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const E of ee)B.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(B)})},[N,p,d,g]),A=i?r=>n.attachments.add(r):L,M=i?r=>n.attachments.remove(r):r=>z(v=>{const f=v.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),v.filter(u=>u.id!==r)}),R=i?()=>n.attachments.clear():()=>z(r=>{for(const v of r)v.url&&URL.revokeObjectURL(v.url);return[]}),U=i?()=>n.attachments.openFileDialog():O;c.useEffect(()=>{i&&n.__registerFileInput(x,()=>{var r;return(r=x.current)==null?void 0:r.click()})},[i,n]),c.useEffect(()=>{o&&x.current&&D.length===0&&(x.current.value="")},[D,o]),c.useEffect(()=>{const r=S.current;if(!r)return;const v=u=>{var j,w;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var j,w,C;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault(),(C=u.dataTransfer)!=null&&C.files&&u.dataTransfer.files.length>0&&A(u.dataTransfer.files)};return r.addEventListener("dragover",v),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",v),r.removeEventListener("drop",f)}},[A]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,j;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault()},v=f=>{var u,j,w;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&A(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",v)}},[A,l]),c.useEffect(()=>()=>{if(!i)for(const r of D)r.url&&URL.revokeObjectURL(r.url)},[i,D]);const Y=r=>{r.currentTarget.files&&A(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,j)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=j,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:D.map(r=>({...r,id:r.id})),add:A,remove:M,clear:R,openFileDialog:U,fileInputRef:x}),[D,A,M,R,U]),Z=r=>{r.preventDefault();const v=r.currentTarget,f=i?n.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(D.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const j=h({text:f,files:u},r);j instanceof Promise?j.then(()=>{R(),i&&n.textInput.clear()}).catch(()=>{}):(R(),i&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:T}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:Y,ref:x,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...I,children:e.jsx(ne,{className:"overflow-hidden",children:m})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),p=q(),[d,g]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const i=n.currentTarget.form,x=i==null?void 0:i.querySelector('button[type="submit"]');if(x!=null&&x.disabled)return;i==null||i.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&p.files.length>0){n.preventDefault();const i=p.files.at(-1);i&&p.remove(i.id)}},m=n=>{var T;const i=(T=n.clipboardData)==null?void 0:T.items;if(!i)return;const x=[];for(const S of i)if(S.kind==="file"){const P=S.getAsFile();P&&x.push(P)}x.length>0&&(n.preventDefault(),p.add(x))},I=o?{value:o.textInput.value,onChange:n=>{o.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>g(!1),onCompositionStart:()=>g(!0),onKeyDown:h,onPaste:m,placeholder:a,...l,...I})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(y.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(y.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(y.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...p})=>{let d=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...p,children:o??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,p]=c.useState(!1),[d,g]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const I=window.SpeechRecognition||window.webkitSpeechRecognition,n=new I;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{p(!0)},n.onend=()=>{p(!1)},n.onresult=i=>{var T;let x="";for(let S=i.resultIndex;S<i.results.length;S++){const P=i.results[S];P.isFinal&&(x+=((T=P[0])==null?void 0:T.transcript)??"")}if(x&&(s!=null&&s.current)){const S=s.current,P=S.value,z=P+(P?" ":"")+x;S.value=z,S.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},n.onerror=i=>{console.error("Speech recognition error:",i.error),p(!1)},h.current=n,c.startTransition(()=>g(n))}return()=>{h.current&&h.current.stop()}},[s,a]);const m=c.useCallback(()=>{d&&(o?d.stop():d.start())},[d,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:m,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(y.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(y.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(y.Dialog,{...t}),ke=t=>e.jsx(y.DialogTrigger,{...t}),Pe=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(y.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(y.DialogTitle,{className:"sr-only",children:a}),e.jsx(y.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Te=t=>e.jsx(y.CommandList,{...t}),ze=t=>e.jsx(y.CommandGroup,{...t}),De=t=>e.jsx(y.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),{models:p}=_.useAIModels(),d=p.find(m=>m.id===t)||p[0],g=p.reduce((m,I)=>(m[I.provider]||(m[I.provider]=[]),m[I.provider].push(I),m),{}),h=m=>{s(m),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:d.name})]})}),e.jsxs(Pe,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Te,{children:Object.entries(g).map(([m,I])=>e.jsx(ze,{heading:m.charAt(0).toUpperCase()+m.slice(1),children:I.map(n=>e.jsxs(De,{value:n.id,onSelect:()=>h(n.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:n.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.description})]}),t===n.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},n.id))},m))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:p,selectedLang:d,selectedModel:g,onModelChange:h})=>{const{t:m}=se.useTranslation(),{models:I}=_.useAIModels(),n=I.find(N=>N.id==="google/gemini-3-flash")||I[0],[i,x]=c.useState(g||n.id),[T,S]=c.useState(null),P=c.useRef(null),[z,D]=c.useState(!1);c.useEffect(()=>{if(!d){const N=localStorage.getItem(V);N?(x(N),h==null||h(N)):(x(n.id),h==null||h(n.id))}},[d,h,n.id]);const O=N=>{var M;const L=N.files.find(R=>{var U;return(U=R.mediaType)==null?void 0:U.startsWith("image/")}),A=(L==null?void 0:L.url)||T;a((M=N.text)==null?void 0:M.trim(),void 0,A,i),S(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:O,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:N=>e.jsx(ue,{className:"text-xs",data:N})})}),e.jsx(fe,{ref:P,value:t,onChange:N=>s(N.target.value),placeholder:m(d?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:i,onModelChange:N=>{x(N),h==null||h(N),localStorage.setItem(V,N)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!z),variant:z?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:m("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||p,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { L as i } from "./index-
|
|
3
|
+
import { L as i } from "./index-LBTm1Jmk.js";
|
|
4
4
|
import { ArrowRight as c } from "lucide-react";
|
|
5
5
|
import { useTranslation as m } from "react-i18next";
|
|
6
6
|
const u = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-BVwFJWDq.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{const{t}=o.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, jsxs as t, Fragment as L } from "react/jsx-runtime";
|
|
2
2
|
import { z as h, B as F } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { D as T, e as q, f as O, g as z, o as B, p as f, q as H } from "./index-
|
|
4
|
-
import { aq as I, ar as M, A as E, ay as R } from "./index-
|
|
3
|
+
import { D as T, e as q, f as O, g as z, o as B, p as f, q as H } from "./index-OuHV9Ann.js";
|
|
4
|
+
import { aq as I, ar as M, A as E, ay as R } from "./index-LBTm1Jmk.js";
|
|
5
5
|
import { useMutation as U } from "@tanstack/react-query";
|
|
6
6
|
import { Loader2 as W } from "lucide-react";
|
|
7
7
|
import { useState as c, useCallback as S, useEffect as G } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),u=require("./index-BVwFJWDq.cjs"),A=require("@tanstack/react-query"),F=require("lucide-react"),d=require("react"),k=require("react-i18next"),m=require("zod"),E=()=>{const r=u.useApiUrl(),o=u.useFetch();return A.useMutation({mutationKey:[u.ACTIONS.CHANGE_PASSWORD],mutationFn:async e=>{const t=await o(r,{action:u.ACTIONS.CHANGE_PASSWORD,data:e});return t==null?void 0:t.data}})},L=r=>m.z.object({oldPassword:m.z.string().min(1,r("Current password is required")),newPassword:m.z.string().min(8,r("Password must be at least 8 characters")).max(128,r("Password must be less than 128 characters")).regex(/[A-Z]/,r("Password must contain at least one uppercase letter")).regex(/[a-z]/,r("Password must contain at least one lowercase letter")).regex(/[0-9]/,r("Password must contain at least one number")).regex(/[!@#$%^&*(),.?":{}|<>]/,r("Password must contain at least one special character")),confirmPassword:m.z.string().min(1,r("Confirm password is required"))}).refine(o=>o.newPassword===o.confirmPassword,{message:r("New password and confirm password do not match"),path:["confirmPassword"]}).refine(o=>o.oldPassword!==o.newPassword,{message:r("New password must be different from current password"),path:["newPassword"]}),T=({open:r,onOpenChange:o})=>{const{t:e}=k.useTranslation(),t=u.usePagesProp("currentUser",null),{mutate:q,isPending:h,isSuccess:p,reset:P}=E(),[x,f]=d.useState(""),[j,C]=d.useState(""),[N,v]=d.useState(""),[b,i]=d.useState(null),S=d.useCallback(()=>{f(""),C(""),v(""),i(null),P()},[P]),w=d.useCallback(a=>{o(a),a||S()},[o,S]);d.useEffect(()=>{if(p){const a=setTimeout(()=>{w(!1)},2e3);return()=>clearTimeout(a)}},[p,w]);const D=()=>{var y;i(null);const a={oldPassword:x.trim(),newPassword:j.trim(),confirmPassword:N.trim()},c=L(e).safeParse(a);if(!c.success){i(((y=c.error.issues[0])==null?void 0:y.message)||e("Validation failed"));return}if(!(t!=null&&t.email)){i(e("User email not found"));return}q({email:t.email,oldPassword:c.data.oldPassword,newPassword:c.data.newPassword,confirmPassword:c.data.confirmPassword},{onError:g=>{i((g==null?void 0:g.message)||e("Failed to change password"))}})};return s.jsx(n.Dialog,{open:r,onOpenChange:w,children:s.jsx(n.DialogContent,{className:"sm:max-w-[425px]",children:h?s.jsx("div",{className:"flex h-[340px] items-center justify-center",children:s.jsx(F.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):p?s.jsxs("div",{className:"flex h-[340px] flex-col items-center justify-center gap-2",children:[s.jsx("div",{className:"rounded-full bg-green-100 p-3",children:s.jsx("svg",{className:"h-6 w-6 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("p",{className:"text-lg font-medium",children:e("Password updated successfully")})]}):s.jsxs(s.Fragment,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:e("Change Password")}),s.jsx(n.DialogDescription,{children:e("Enter your current password and a new password.")})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"old-password",children:e("Current Password")}),s.jsx(l.Input,{id:"old-password",type:"password",value:x,onChange:a=>f(a.target.value),placeholder:e("Enter current password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"new-password",children:e("New Password")}),s.jsx(l.Input,{id:"new-password",type:"password",value:j,onChange:a=>C(a.target.value),placeholder:e("Enter new password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"confirm-password",children:e("Confirm Password")}),s.jsx(l.Input,{id:"confirm-password",type:"password",value:N,onChange:a=>v(a.target.value),placeholder:e("Confirm new password")})]}),b&&s.jsx("p",{className:"text-sm text-destructive",children:b})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(l.Button,{variant:"outline",onClick:()=>w(!1),disabled:h,children:e("Cancel")}),s.jsx(l.Button,{onClick:D,disabled:h,children:e("Change Password")})]})]})})})};exports.ChangePasswordModal=T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { u as k, a as v, b as T, c as E, d as L, L as N, D as y, e as w, f as D, g as H, T as M } from "./index-
|
|
2
|
+
import { u as k, a as v, b as T, c as E, d as L, L as N, D as y, e as w, f as D, g as H, T as M } from "./index-OuHV9Ann.js";
|
|
3
3
|
import { useThrottledCallback as P } from "@react-hookz/web";
|
|
4
4
|
import { get as B } from "lodash-es";
|
|
5
5
|
import { useState as p, useMemo as I, useCallback as S, useEffect as j } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./index-DCJDQs1a.cjs"),j=require("@react-hookz/web"),v=require("lodash-es"),l=require("react"),T=require("react-i18next"),h=c=>{const o=document.createElement("div");return o.innerHTML=c,o.innerHTML};function y(){const{t:c}=T.useTranslation(),[o,p]=l.useState(!1),[r,f]=l.useState(""),[e,d]=t.useCodeEditor(),[u]=t.useSelectedBlockIds(),g=t.useUpdateBlocksProps(),b=t.useUpdateBlocksPropsRealtime(),{selectedLang:i}=t.useLanguages(),x=l.useMemo(()=>v.get(t.LANGUAGES,i,i),[i]),C=j.useThrottledCallback(n=>{if(!e)return;const a=h(n);b([e.blockId],{[e.blockProp]:a})},[],300),m=l.useCallback(()=>{if(o&&e){const n=h(r);g([e.blockId],{[e.blockProp]:n})}},[o,r,e]);l.useEffect(()=>{e&&!u.includes(e.blockId)&&(m(),d(null))},[u,e]);const k=()=>{m(),d(null)};return s.jsx(t.Dialog,{open:!0,onOpenChange:k,children:s.jsxs(t.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[s.jsx(t.DialogHeader,{className:"shrink-0 pb-3",children:s.jsx(t.DialogTitle,{className:"flex items-center justify-between text-black",children:s.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[s.jsx("span",{children:c("HTML Code Editor")}),x&&s.jsxs("span",{className:"text-xs text-gray-400",children:["(",x,")"]}),s.jsx("span",{className:"text-xs text-gray-400",children:c("Scripts will be only executed in preview and live mode.")})]})})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(t.Textarea,{className:"h-full w-full resize-none font-mono md:text-xs",value:e?r||e.initialCode:"",onChange:n=>{const a=n.target.value;p(!0),f(a),C(a)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=y;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { J as o, K as c, M as i, O as l, Q as m } from "./index-
|
|
4
|
-
import { b as d, B as h } from "./index-
|
|
3
|
+
import { J as o, K as c, M as i, O as l, Q as m } from "./index-OuHV9Ann.js";
|
|
4
|
+
import { b as d, B as h } from "./index-LBTm1Jmk.js";
|
|
5
5
|
import { CheckCircle as u, Check as p } from "lucide-react";
|
|
6
6
|
import { useTranslation as C } from "react-i18next";
|
|
7
7
|
const y = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DyW9GPzV.cjs"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DyW9GPzV.cjs"),s=require("./index-DCJDQs1a.cjs"),a=require("./index-BVwFJWDq.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};return e.jsx(a.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DCJDQs1a.cjs"),r=require("./common-functions-B3a4xKt_.cjs"),i=require("./apply-binding-CBSjMYSk.cjs"),a=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("react-i18next"),o=require("i18next");exports.ChaiAddBlocksDialog=e.AddBlocksDialog;exports.ChaiAddBlocksPanel=e.AddBlocksPanel;exports.ChaiAskAiUserPrompt=e.AIUserPrompt;exports.ChaiBlockAttributesEditor=e.BlockAttributesEditor;exports.ChaiBlockPropsEditor=e.BlockSettings;exports.ChaiBlockStyleEditor=e.BlockStyling;exports.ChaiBuilderCanvas=e.CanvasArea;exports.ChaiBuilderEditor=e.ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=e.DarkMode;exports.ChaiDefaultBlocks=e.DefaultChaiBlocks;exports.ChaiDraggableBlock=e.ChaiDraggableBlock;exports.ChaiExportCodeModal=e.ExportCodeModal;exports.ChaiImportHTML=e.ImportHTML;exports.ChaiOutline=e.ListTree;exports.ChaiScreenSizes=e.Breakpoints;exports.ChaiThemeConfigPanel=e.ThemeConfigPanel;exports.ChaiUILibrariesPanel=e.UILibrariesPanel;exports.ChaiUndoRedo=e.UndoRedo;exports.PERMISSIONS=e.PERMISSIONS;exports.defaultChaiLibrary=e.defaultChaiLibrary;exports.getClassValueAndUnit=e.getClassValueAndUnit;exports.useAddBlock=e.useAddBlock;exports.useBlocksHtmlForAi=e.useBlocksHtmlForAi;exports.useHtmlToBlocks=e.useHtmlToBlocks;exports.useI18nBlocks=e.useI18nBlocks;exports.useLanguages=e.useLanguages;exports.useReplaceBlock=e.useReplaceBlock;exports.useSavePage=e.useSavePage;exports.useSelectedBlock=e.useSelectedBlock;exports.useStreamMultipleBlocksProps=e.useStreamMultipleBlocksProps;exports.generateBlockId=r.generateUUID;exports.mergeClasses=r.cn;exports.convertHTMLToChaiBlocks=i.getBlocksFromHTML;exports.getBlocksFromHTML=i.getBlocksFromHTML;exports.ADD_BLOCK_TABS=a.ADD_BLOCK_TABS;exports.CHAI_BUILDER_PANELS=a.CHAI_BUILDER_PANELS;exports.IfChaiFeatureFlag=a.IfChaiFeatureFlag;exports.RJSF_EXTENSIONS=a.RJSF_EXTENSIONS;exports.getChaiLibrary=a.getChaiLibrary;exports.getPreImportHTML=a.getPreImportHTML;exports.registerChaiAddBlockTab=a.registerChaiAddBlockTab;exports.registerChaiBlockSettingField=a.registerChaiBlockSettingField;exports.registerChaiBlockSettingTemplate=a.registerChaiBlockSettingTemplate;exports.registerChaiBlockSettingWidget=a.registerChaiBlockSettingWidget;exports.registerChaiFeatureFlag=a.registerChaiFeatureFlag;exports.registerChaiFeatureFlags=a.registerChaiFeatureFlags;exports.registerChaiLibrary=a.registerChaiLibrary;exports.registerChaiMediaManager=a.registerChaiMediaManager;exports.registerChaiPreImportHTMLHook=a.registerChaiPreImportHTMLHook;exports.registerChaiSaveToLibrary=a.registerChaiSaveToLibrary;exports.registerChaiSidebarPanel=a.registerChaiSidebarPanel;exports.registerChaiTopBar=a.registerChaiTopBar;exports.resetSaveToLibrary=a.resetSaveToLibrary;exports.useChaiAddBlockTabs=a.useChaiAddBlockTabs;exports.useChaiBlockSettingComponents=a.useChaiBlockSettingComponents;exports.useChaiFeatureFlag=a.useChaiFeatureFlag;exports.useChaiFeatureFlags=a.useChaiFeatureFlags;exports.useChaiLibraries=a.useChaiLibraries;exports.useChaiSidebarPanels=a.useChaiSidebarPanels;exports.useMediaManagerComponent=a.useMediaManagerComponent;exports.useSaveToLibraryComponent=a.useSaveToLibraryComponent;exports.useToggleChaiFeatureFlag=a.useToggleChaiFeatureFlag;exports.useTopBarComponent=a.useTopBarComponent;Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:()=>t.useTranslation});exports.i18n=o;
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b6 as s, aZ as r, b5 as i, b7 as o, a_ as t, a$ as l, b0 as C, aX as g, aK as h, b8 as u, b9 as d, ba as n, b1 as c, b2 as b, aL as B, b3 as k, b4 as S, aM as p, aO as m, bc as T, bb as L, ab as F, ae as A, bd as I, s as M, d as P, ac as f, I as E, r as H, t as x } from "./index-
|
|
1
|
+
import { b6 as s, aZ as r, b5 as i, b7 as o, a_ as t, a$ as l, b0 as C, aX as g, aK as h, b8 as u, b9 as d, ba as n, b1 as c, b2 as b, aL as B, b3 as k, b4 as S, aM as p, aO as m, bc as T, bb as L, ab as F, ae as A, bd as I, s as M, d as P, ac as f, I as E, r as H, t as x } from "./index-OuHV9Ann.js";
|
|
2
2
|
import { g as v, c as D } from "./common-functions-D2lMFR6K.js";
|
|
3
3
|
import { g as _, g as O } from "./apply-binding-vAuN-TGV.js";
|
|
4
4
|
import { A as N, C as w, I as K, R as X, k as j, o as q, c as z, a as J, b as V, r as W, e as Z, f as $, j as G, m as Q, p as Y, q as aa, v as ea, x as sa, t as ra, d as ia, u as oa, h as ta, g as la, l as Ca, w as ga, n as ha, s as ua, i as da, y as na } from "./register-chai-top-bar-D6GjnauV.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("./register-chai-top-bar-DyW9GPzV.cjs"),f=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("./register-chai-top-bar-DyW9GPzV.cjs"),f=require("./index-DCJDQs1a.cjs");require("lodash-es");const T=require("culori"),V=require("./fonts-D5fTqvSS.cjs"),N=require("react"),R=require("react-i18next");function j(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 b=j(T),C=j(N),d=e=>e?e%1===0?e:e.toFixed(4):"0",q=e=>`hsl(${d(e.h)} ${d(e.s*100)}% ${d(e.l*100)}%)`,E=(e,o="hsl",t="4")=>{try{const r=b.parse(e);if(!r)throw new Error("Invalid color input");switch(o){case"hsl":{const s=b.converter("hsl")(r);return t==="4"?q(s):`${d(s.h)} ${d(s.s*100)}% ${d(s.l*100)}%`}case"rgb":return b.formatRgb(r);case"oklch":{const s=b.converter("oklch")(r);return`oklch(${d(s.l)} ${d(s.c)} ${d(s.h)})`}case"hex":return b.formatHex(r);default:return e}}catch(r){return console.error(`Failed to convert color: ${e}`,r),e}},x=e=>E(e,"hex"),I=e=>{const o={fontFamily:{heading:"",body:""},borderRadius:"",colors:{}};try{const t=w(e);if(!t.isValid)return console.warn("CSS validation failed:",t.error),$();const r=v(e,":root"),s=v(e,".dark"),c=u(r,"--font-sans")||u(r,"--font-family")||u(r,"--font-heading")||u(r,"--font-body"),a=D(c);o.fontFamily={heading:a,body:a};const h=u(r,"--radius")||u(r,"--border-radius")||"0.5rem";o.borderRadius=P(h),["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 l=p?k(p):"#000000",S=g?k(g):l;o.colors[i]=[l,S]}})}catch(t){return console.error("Error parsing CSS to ChaiThemeValues:",t),$()}return o},v=(e,o)=>{var r,s;const t=new RegExp(`${F(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(`${F(o)}\\s*:\\s*([^;]+)`),r=e.match(t);return((s=r==null?void 0:r[1])==null?void 0:s.trim())||null},k=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 x(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 x(o)||"#000000";const t=o.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);if(t){const[,r,s,c]=t,a=`hsl(${r} ${s}% ${c}%)`;return x(a)||"#000000"}if(/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(o)){const r=o.split(/[\s,]+/).filter(Boolean);if(r.length>=3){const c=r.some(a=>a.includes("%"))?`hsl(${r[0]} ${r[1]} ${r[2]})`:`rgb(${r[0]}, ${r[1]}, ${r[2]})`;return x(c)||"#000000"}}return x(o)||"#000000"}catch(o){return console.warn("Failed to process color:",e,o),"#000000"}},D=e=>{const o=V.getAllRegisteredFonts();if(!e)return"ui-sans-serif, system-ui, sans-serif";try{const r=e.replace(/["']/g,"").trim().split(",")[0].trim(),s=o.find(c=>c.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"}},P=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"}},$=()=>({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"]}}),F=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),B=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,w=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
2
|
--background: 0 0% 100%;
|
|
3
3
|
--foreground: oklch(0.52 0.13 144.17);
|
|
4
4
|
--primary: #3e2723;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as i, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import { B as y } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { D as T, e as V, f as N, g as R, o as E, p as D, T as I, q as A } from "./index-
|
|
3
|
+
import { D as T, e as V, f as N, g as R, o as E, p as D, T as I, q as A } from "./index-OuHV9Ann.js";
|
|
4
4
|
import "lodash-es";
|
|
5
5
|
import * as b from "culori";
|
|
6
6
|
import { a as P } from "./fonts-B3UYxuJI.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as L } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { d as k, n as U, D as W, e as g, f as B, g as q, o as G, q as R } from "./index-
|
|
4
|
-
import { c as j, o as F, k as H, e as M, j as Q, q as T, L as $ } from "./index-
|
|
3
|
+
import { d as k, n as U, D as W, e as g, f as B, g as q, o as G, q as R } from "./index-OuHV9Ann.js";
|
|
4
|
+
import { c as j, o as F, k as H, e as M, j as Q, q as T, L as $ } from "./index-LBTm1Jmk.js";
|
|
5
5
|
import { isEmpty as z, get as I } from "lodash-es";
|
|
6
6
|
import { useMemo as f } from "react";
|
|
7
7
|
import { useTranslation as J } from "react-i18next";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),l=require("./index-BVwFJWDq.cjs"),C=require("lodash-es"),f=require("react"),g=require("react-i18next"),S=(e,d)=>{const t=d.filter(m=>m.parent===e);if(t.length===0)return 0;let u=t.length;return t.forEach(m=>{u+=S(m.id,d)}),u};function U({page:e,onClose:d}){const{t}=g.useTranslation(),[,u]=l.useSearchParams(),{mutate:m,isPending:P}=l.useDeletePage(),{data:j}=l.usePageTypes(),{data:h=[]}=l.useWebsitePrimaryPages(),{setSelectedLang:E,fallbackLang:L}=n.useLanguages(),[,q]=n.useSidebarActivePanel(),c=!(e!=null&&e.primaryPage),{data:r=[]}=l.useLanguagePages(c?e==null?void 0:e.id:void 0),{data:y}=l.useSiteWideUsage(),v=f.useMemo(()=>C.isEmpty(e==null?void 0:e.slug),[e==null?void 0:e.slug]),w=f.useMemo(()=>{if(!v||!(e!=null&&e.id)||!y)return[];const i=[];return Object.entries(y).forEach(([o,D])=>{D.partialBlocks.includes(e.id)&&!D.isPartial&&i.push({id:o,name:D.name})}),i},[v,e.id,y]),N=f.useMemo(()=>!c||!r?0:r.filter(i=>i.id!==e.id).length,[c,r,e.id]),x=f.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let i=S(e.id,h);return c&&r&&r.length>0&&r.forEach(o=>{o.id!==e.id&&(i+=S(o.id,h))}),i},[e.id,h,c,r]),A=()=>{P||m(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),u(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),u(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),E(L),q("outline"),d()}})},a=j==null?void 0:j.find(i=>i.key===(e==null?void 0:e.pageType));return s.jsx(n.Dialog,{open:!!e,onOpenChange:d,children:s.jsxs(n.DialogContent,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:t("Confirm Deletion")}),s.jsxs(n.DialogDescription,{className:"py-4 text-slate-500",children:[s.jsxs("div",{children:[t("Are you sure you want to remove")," ",s.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",a!=null&&a.hasSlug?(a==null?void 0:a.name)+"?":t("page?")]}),c&&(N>0||x>0)&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: Deleting this primary page will also delete"),":"]}),s.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[x>0&&s.jsxs("li",{children:[s.jsx("span",{className:"font-medium",children:x})," ",t(x===1?"nested child page":"nested child pages")]}),N>0&&s.jsx("li",{children:t("All associated language pages")})]})]}),v&&w.length>0&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: This partial is currently used in the following pages"),":"]}),s.jsx("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:w.map(({id:i,name:o})=>s.jsx("li",{children:s.jsx("span",{className:"font-medium",children:o})},i))})]}),e.lang&&s.jsxs("div",{className:"py-2 text-sm",children:[t("Language"),":"," ",s.jsx("span",{className:"font-medium text-gray-500",children:C.get(l.LANGUAGES,e.lang,e.lang)})]})]})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(b.Button,{variant:"outline",onClick:d,children:t("Cancel")}),s.jsx(b.Button,{variant:"destructive",disabled:P,onClick:A,children:t(P?"Deleting...":"Delete")})]})]})})}exports.default=U;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { ak as I, a as _, a0 as p, d as j, I as C, X as O, Y as z, P as E } from "./index-
|
|
2
|
+
import { ak as I, a as _, a0 as p, d as j, I as C, X as O, Y as z, P as E } from "./index-OuHV9Ann.js";
|
|
3
3
|
import { E as W } from "./register-chai-top-bar-D6GjnauV.js";
|
|
4
4
|
import { ArrowRightIcon as A, FileIcon as F, GlobeIcon as M } from "@radix-ui/react-icons";
|
|
5
5
|
import { noop as R } from "lodash-es";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("./index-DCJDQs1a.cjs"),L=require("./register-chai-top-bar-DyW9GPzV.cjs"),p=require("@radix-ui/react-icons"),q=require("lodash-es"),d=require("react"),w=require("react-i18next"),x=({title:n,items:a,emptyLabel:r,onSelect:t,icon:i})=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n}),a.length>0?s.jsx("div",{className:"space-y-1",children:a.map(l=>s.jsx("button",{type:"button",onClick:()=>t(l.id),className:L.cn("group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition","hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",l.isSelected&&"border-primary/40 bg-primary/10 text-primary"),children:s.jsxs("span",{className:"flex items-center space-x-2",children:[i&&i,s.jsx("span",{className:"truncate",children:l.label})]})},l.id))}):s.jsx("div",{className:"rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground",children:r})]}),C="#styles:",M=n=>{const r=[typeof n._name=="string"?n._name:void 0,typeof n._type=="string"?n._type:void 0].filter(Boolean).find(t=>t.trim().length>0);return r?r.length>40?`${r.slice(0,37)}...`:r:n._id},_=(n,a)=>{const r=`${a}`;return n.filter(t=>Object.values(t).some(i=>typeof i!="string"||!i.startsWith(C)?!1:i.includes(r))).map(t=>({id:t._id,label:M(t)}))},O=({tokenId:n,tokenName:a,children:r})=>{const{t}=w.useTranslation(),[i]=o.useBlocksStore(),[l,b]=o.useSelectedBlockIds(),g=o.useBuilderProp("pageId",""),m=o.useBuilderProp("siteWideUsage",{}),h=d.useMemo(()=>_(i,n),[i,n]),P=d.useMemo(()=>h.map(e=>({id:e.id,label:e.label,isSelected:l.includes(e.id)})),[h,l]),u=d.useMemo(()=>m?Object.entries(m).reduce((e,[f,c])=>(f===g||!(c!=null&&c.designTokens)||!Object.keys(c.designTokens).some(j=>typeof j!="string"?!1:j===n)||e.push({id:f,name:c.name||f,isPartial:!!c.isPartial}),e),[]):[],[m,a,n,g]),S=d.useMemo(()=>u.filter(e=>!e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),k=d.useMemo(()=>u.filter(e=>e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),v=d.useCallback(e=>{b([e])},[b]),B=o.useBuilderProp("gotoPage",q.noop),{selectedLang:N,fallbackLang:T}=o.useLanguages(),{savePageAsync:I}=o.useSavePage(),y=async e=>{e&&(await I(!0),B({pageId:e,lang:N||T}))};return s.jsxs(o.Popover,{children:[s.jsx(o.PopoverTrigger,{asChild:!0,children:r}),s.jsxs(o.PopoverContent,{side:"bottom",align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"space-y-1 px-4 py-3",children:[s.jsx("p",{className:"text-xs font-semibold",children:a}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("Usage summary for this design token across your site.")})]}),s.jsxs("div",{className:"no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4",children:[s.jsx(x,{title:t("Blocks affected on this page"),items:P,emptyLabel:t("None"),onSelect:v,icon:s.jsx(p.ArrowRightIcon,{fontSize:4})}),s.jsx(x,{title:t("Blocks affected on other pages"),items:S,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.FileIcon,{fontSize:8})}),s.jsx(x,{title:t("Blocks affected on partial blocks"),items:k,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.GlobeIcon,{fontSize:8})})]})]})]})};exports.default=O;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as r, jsx as e, Fragment as H } from "react/jsx-runtime";
|
|
2
2
|
import { B as p, z as me } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { p as V, T as Fe, aw as _, z as q, A as P, E as G, D as Ue, e as Le, f as $e, g as Me, o as _e, q as qe, af as Pe } from "./index-
|
|
3
|
+
import { p as V, T as Fe, aw as _, z as q, A as P, E as G, D as Ue, e as Le, f as $e, g as Me, o as _e, q as qe, af as Pe } from "./index-OuHV9Ann.js";
|
|
4
4
|
import { f as Ge, c as Oe } from "./image-compression-DPFITwOL.js";
|
|
5
5
|
import { find as Be, merge as Ke, pick as Y, first as Qe, isEmpty as Re } from "lodash-es";
|
|
6
6
|
import { ChevronLeft as ue, ChevronRight as We, Loader as B, AlertCircle as Ve, Copy as he, Pencil as He, Link as Xe, Search as Ze, RefreshCwIcon as Je, Archive as Ye, Film as et, ImageIcon as tt, Edit as it, Trash2 as at, Check as lt, Upload as rt, AlertTriangle as nt } from "lucide-react";
|
|
@@ -10,7 +10,7 @@ import { ErrorBoundary as ot } from "react-error-boundary";
|
|
|
10
10
|
import { useTranslation as ee } from "react-i18next";
|
|
11
11
|
import { toast as A } from "sonner";
|
|
12
12
|
import { useQueryClient as te, useMutation as ie, useQuery as ge } from "@tanstack/react-query";
|
|
13
|
-
import { aq as K, ar as Q, A as b } from "./index-
|
|
13
|
+
import { aq as K, ar as Q, A as b } from "./index-LBTm1Jmk.js";
|
|
14
14
|
import { c as xe } from "./common-functions-D2lMFR6K.js";
|
|
15
15
|
const dt = () => {
|
|
16
16
|
const s = K(), n = te(), h = Q();
|
|
@@ -385,7 +385,7 @@ const xt = ({ assetId: s, onBack: n, onEdit: h, onSave: a, isSaving: c }) => {
|
|
|
385
385
|
] })
|
|
386
386
|
] })
|
|
387
387
|
] });
|
|
388
|
-
}, vt = fe.lazy(() => import("./image-editor-
|
|
388
|
+
}, vt = fe.lazy(() => import("./image-editor-BBvvi9Vm.js")), yt = 25 * 1024 * 1024, Nt = ({ isUpdatingAsset: s, allowedTypes: n, uploadAssets: h, isUploadingAsset: a, onUploaded: c }) => {
|
|
389
389
|
const { t: i } = ee(), [l, I] = y(() => {
|
|
390
390
|
const o = localStorage.getItem("chai_optimize_images");
|
|
391
391
|
return o !== null ? o === "true" : !0;
|