@adminide-stack/yantra-mobile 12.0.142-alpha.0 → 12.0.144

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 (118) hide show
  1. package/lib/features/attachments/displayUserMessageText.js +2 -2
  2. package/lib/features/attachments/displayUserMessageText.js.map +1 -1
  3. package/lib/features/devices/bodyComposition.js +116 -0
  4. package/lib/features/devices/bodyComposition.js.map +1 -0
  5. package/lib/features/devices/readings.js.map +1 -1
  6. package/lib/features/devices/session.js +22 -2
  7. package/lib/features/devices/session.js.map +1 -1
  8. package/lib/features/notion/NotionAgentPanel.js +987 -0
  9. package/lib/features/notion/NotionAgentPanel.js.map +1 -0
  10. package/lib/features/notion/NotionAskAiSheet.js +362 -0
  11. package/lib/features/notion/NotionAskAiSheet.js.map +1 -0
  12. package/lib/features/notion/NotionBlockView.js +4 -3
  13. package/lib/features/notion/NotionBlockView.js.map +1 -1
  14. package/lib/features/notion/NotionConnectionsSheet.js +47 -13
  15. package/lib/features/notion/NotionConnectionsSheet.js.map +1 -1
  16. package/lib/features/notion/NotionPageView.js +68 -8
  17. package/lib/features/notion/NotionPageView.js.map +1 -1
  18. package/lib/features/notion/NotionSidebarSections.js +1 -1
  19. package/lib/features/notion/NotionSidebarSections.js.map +1 -1
  20. package/lib/features/notion/NotionWorkspaceView.js +14 -9
  21. package/lib/features/notion/NotionWorkspaceView.js.map +1 -1
  22. package/lib/features/notion/database/DatabaseCells.js +3 -1
  23. package/lib/features/notion/database/DatabaseCells.js.map +1 -1
  24. package/lib/features/notion/database/DatabaseDateLayouts.js +1 -1
  25. package/lib/features/notion/database/DatabaseDateLayouts.js.map +1 -1
  26. package/lib/features/notion/database/NotionDatabaseView.js +1 -1
  27. package/lib/features/notion/database/NotionDatabaseView.js.map +1 -1
  28. package/lib/features/notion/notionAgentRunStatus.js +2 -2
  29. package/lib/features/notion/notionAgentRunStatus.js.map +1 -1
  30. package/lib/features/notion/notionAgentRuns.js +57 -0
  31. package/lib/features/notion/notionAgentRuns.js.map +1 -0
  32. package/lib/features/notion/notionAiContext.js +91 -0
  33. package/lib/features/notion/notionAiContext.js.map +1 -0
  34. package/lib/features/notion/notionConnections.js +42 -4
  35. package/lib/features/notion/notionConnections.js.map +1 -1
  36. package/lib/features/notion/notionDocuments.js +61 -1
  37. package/lib/features/notion/notionDocuments.js.map +1 -1
  38. package/lib/features/notion/notionNotesAgent.js +173 -3
  39. package/lib/features/notion/notionNotesAgent.js.map +1 -1
  40. package/lib/features/notion/notionPageKinds.js +1 -1
  41. package/lib/features/webbuilder/WebBuilderExperience.js +229 -97
  42. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  43. package/lib/features/webbuilder/buildFragments.js +33 -7
  44. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  45. package/lib/features/webbuilder/buildJob.js +2 -2
  46. package/lib/features/webbuilder/buildJob.js.map +1 -1
  47. package/lib/features/webbuilder/codeFiles.js +18 -1
  48. package/lib/features/webbuilder/codeFiles.js.map +1 -1
  49. package/lib/features/webbuilder/components/BottomTabs.js.map +1 -1
  50. package/lib/features/webbuilder/components/CodeView.js +134 -56
  51. package/lib/features/webbuilder/components/CodeView.js.map +1 -1
  52. package/lib/features/webbuilder/components/Composer.js +2 -2
  53. package/lib/features/webbuilder/components/Composer.js.map +1 -1
  54. package/lib/features/webbuilder/components/PreviewFrame.js +19 -3
  55. package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
  56. package/lib/features/webbuilder/components/PreviewScreen.js +310 -46
  57. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  58. package/lib/features/webbuilder/components/ProjectChat.js +141 -12
  59. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  60. package/lib/features/webbuilder/components/ProjectSheets.js +792 -0
  61. package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -0
  62. package/lib/features/webbuilder/components/ProjectsScreen.js +14 -2
  63. package/lib/features/webbuilder/components/ProjectsScreen.js.map +1 -1
  64. package/lib/features/webbuilder/components/PublishSheet.js +914 -58
  65. package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
  66. package/lib/features/webbuilder/components/TemplateCard.js +9 -6
  67. package/lib/features/webbuilder/components/TemplateCard.js.map +1 -1
  68. package/lib/features/webbuilder/components/TemplatesSheet.js +5 -17
  69. package/lib/features/webbuilder/components/TemplatesSheet.js.map +1 -1
  70. package/lib/features/webbuilder/connectorTemplates.js +171 -0
  71. package/lib/features/webbuilder/connectorTemplates.js.map +1 -0
  72. package/lib/features/webbuilder/fileTree.js +163 -0
  73. package/lib/features/webbuilder/fileTree.js.map +1 -0
  74. package/lib/features/webbuilder/followUps.js +67 -0
  75. package/lib/features/webbuilder/followUps.js.map +1 -0
  76. package/lib/features/webbuilder/previewProbe.js +49 -0
  77. package/lib/features/webbuilder/previewProbe.js.map +1 -0
  78. package/lib/features/webbuilder/previewRoutes.js +156 -0
  79. package/lib/features/webbuilder/previewRoutes.js.map +1 -0
  80. package/lib/features/webbuilder/projectTools.js +341 -0
  81. package/lib/features/webbuilder/projectTools.js.map +1 -0
  82. package/lib/features/webbuilder/publishTools.js +475 -0
  83. package/lib/features/webbuilder/publishTools.js.map +1 -0
  84. package/lib/features/webbuilder/sleepNotice.js +13 -0
  85. package/lib/features/webbuilder/sleepNotice.js.map +1 -0
  86. package/lib/features/webbuilder/stepLabels.js +37 -7
  87. package/lib/features/webbuilder/stepLabels.js.map +1 -1
  88. package/lib/features/webbuilder/studioCatalog.js +5 -1
  89. package/lib/features/webbuilder/studioCatalog.js.map +1 -1
  90. package/lib/features/webbuilder/templateCatalog.js +140 -0
  91. package/lib/features/webbuilder/templateCatalog.js.map +1 -0
  92. package/lib/features/webbuilder/webbuilderPrompts.js +31 -5
  93. package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
  94. package/lib/features/webbuilder/workflow.js +8 -4
  95. package/lib/features/webbuilder/workflow.js.map +1 -1
  96. package/lib/screens/Devices/index.js +205 -3
  97. package/lib/screens/Devices/index.js.map +1 -1
  98. package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +9 -6
  99. package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -1
  100. package/lib/screens/WebBuilderNative/index.js +1 -1
  101. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  102. package/lib/screens/WebBuilderNative/keepAlive.js +53 -3
  103. package/lib/screens/WebBuilderNative/keepAlive.js.map +1 -1
  104. package/lib/screens/WebBuilderNative/unreachableRetry.js +23 -0
  105. package/lib/screens/WebBuilderNative/unreachableRetry.js.map +1 -0
  106. package/lib/screens/WebBuilderNative/useConnectorTemplates.js +37 -0
  107. package/lib/screens/WebBuilderNative/useConnectorTemplates.js.map +1 -0
  108. package/lib/screens/WebBuilderNative/useSandboxKeepAlive.js +6 -0
  109. package/lib/screens/WebBuilderNative/useSandboxKeepAlive.js.map +1 -1
  110. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +302 -40
  111. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  112. package/lib/screens/WebBuilderNative/useWebBuilderJobs.js +2 -2
  113. package/lib/screens/WebBuilderNative/useWebBuilderJobs.js.map +1 -1
  114. package/lib/screens/WebBuilderNative/versionUndo.js +1 -1
  115. package/lib/screens/WebBuilderNative/versionUndo.js.map +1 -1
  116. package/lib/screens/WebBuilderNative/webbuilderTransport.js +147 -77
  117. package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
  118. package/package.json +4 -4
@@ -0,0 +1,792 @@
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useState,useEffect,useMemo}from'react';import {StyleSheet,ScrollView,View,Text,TextInput,ActivityIndicator,Alert,Image}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {Tap,DIM}from'../../inbox/components/Tap.js';import {parseProjectSettings,PROJECT_KNOWLEDGE_MAX,DEFAULT_SYNC_BRANCH,repoSlug,isValidRepoName,normalizeBranch,groupCatalog,importTurn,normalizeProjectTitle,normalizeProjectKnowledge,readSettingsUpdateReply,githubSyncPatch,parseCatalog,withIntegration,aiRequest,integrationRequest,parseRepoInput,readRepoCheck}from'../projectTools.js';import {Sheet,PrimaryButton,SecondaryButton}from'./ui.js';function Row({
2
+ item,
3
+ onPick,
4
+ open,
5
+ onToggle,
6
+ theme
7
+ }) {
8
+ var _a;
9
+ const parent = Boolean((_a = item.children) == null ? void 0 : _a.length);
10
+ let trailing = null;
11
+ if (parent) trailing = open ? "chevron-down" : "chevron-right";
12
+ return /* @__PURE__ */ jsxs(Tap, { onPress: parent ? onToggle != null ? onToggle : (() => void 0) : () => onPick(item), accessibilityRole: "button", accessibilityLabel: item.hint ? `${item.label}. ${item.hint}` : item.label, accessibilityState: parent ? {
13
+ expanded: Boolean(open)
14
+ } : void 0, style: styles.row, pressedStyle: DIM, testID: `webbuilder-menu-${item.key}`, children: [
15
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: item.icon, size: 20, color: theme.muted }),
16
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
17
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
18
+ color: theme.ink
19
+ }], children: item.label }),
20
+ item.hint ? /* @__PURE__ */ jsx(Text, { style: [styles.rowHint, {
21
+ color: theme.muted
22
+ }], children: item.hint }) : null
23
+ ] }),
24
+ trailing ? /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: trailing, size: 20, color: theme.faint }) : null
25
+ ] });
26
+ }
27
+ function ProjectMenuSheet({
28
+ visible,
29
+ title,
30
+ sections,
31
+ onClose,
32
+ theme
33
+ }) {
34
+ const [openKey, setOpenKey] = useState(null);
35
+ useEffect(() => {
36
+ if (!visible) setOpenKey(null);
37
+ }, [visible]);
38
+ const pick = (item) => {
39
+ onClose();
40
+ setTimeout(item.run, 300);
41
+ };
42
+ return /* @__PURE__ */ jsx(Sheet, { visible, title, onClose, theme, testID: "webbuilder-project-menu", children: /* @__PURE__ */ jsx(ScrollView, { style: styles.scroll, contentContainerStyle: styles.menuBody, children: sections.filter((s) => s.items.length).map((section, i) => {
43
+ var _a;
44
+ return /* @__PURE__ */ jsxs(View, { children: [
45
+ i > 0 ? /* @__PURE__ */ jsx(View, { style: [styles.divider, {
46
+ backgroundColor: theme.border
47
+ }] }) : null,
48
+ section.title ? /* @__PURE__ */ jsx(Text, { style: [styles.section, {
49
+ color: theme.muted
50
+ }], children: section.title }) : null,
51
+ section.items.map((item) => {
52
+ var _a2;
53
+ return /* @__PURE__ */ jsxs(View, { children: [
54
+ /* @__PURE__ */ jsx(Row, { item, onPick: pick, open: openKey === item.key, onToggle: () => setOpenKey(openKey === item.key ? null : item.key), theme }),
55
+ openKey === item.key && ((_a2 = item.children) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(View, { style: [styles.sub, {
56
+ borderLeftColor: theme.border
57
+ }], children: item.children.map((child) => /* @__PURE__ */ jsx(Row, { item: child, onPick: pick, theme }, child.key)) }) : null
58
+ ] }, item.key);
59
+ })
60
+ ] }, (_a = section.title) != null ? _a : `s${i}`);
61
+ }) }) });
62
+ }
63
+ function ProjectSettingsSheet({
64
+ visible,
65
+ mode,
66
+ channelId,
67
+ title,
68
+ tools,
69
+ aiBusy,
70
+ onSaved,
71
+ onDeleted,
72
+ onClose,
73
+ theme
74
+ }) {
75
+ const [name, setName] = useState(title);
76
+ const [knowledge, setKnowledge] = useState("");
77
+ const [loaded, setLoaded] = useState(null);
78
+ const [loading, setLoading] = useState(false);
79
+ const [saving, setSaving] = useState(false);
80
+ const [deleting, setDeleting] = useState(false);
81
+ const [error, setError] = useState(null);
82
+ useEffect(() => {
83
+ if (!visible) return void 0;
84
+ setName(title);
85
+ setError(null);
86
+ if (!channelId) return void 0;
87
+ let alive = true;
88
+ setLoading(true);
89
+ tools.loadSettings(channelId).then((raw) => {
90
+ const s = parseProjectSettings(raw);
91
+ if (!alive || !s) return;
92
+ setLoaded(s);
93
+ if (s.title) setName((prev) => prev === title ? s.title || prev : prev);
94
+ setKnowledge((prev) => prev || s.instructions);
95
+ }).catch(() => void 0).finally(() => {
96
+ if (alive) setLoading(false);
97
+ });
98
+ return () => {
99
+ alive = false;
100
+ };
101
+ }, [visible, channelId]);
102
+ const save = async () => {
103
+ var _a;
104
+ if (!channelId) return;
105
+ const t = normalizeProjectTitle(name);
106
+ if (!t) {
107
+ setError("Give the project a name.");
108
+ return;
109
+ }
110
+ const patch = {};
111
+ if (t !== title) patch.title = t;
112
+ const instructions = normalizeProjectKnowledge(knowledge);
113
+ if (mode === "settings" && instructions !== ((_a = loaded == null ? void 0 : loaded.instructions) != null ? _a : "")) patch.instructions = instructions;
114
+ if (!Object.keys(patch).length) {
115
+ onClose();
116
+ return;
117
+ }
118
+ setSaving(true);
119
+ setError(null);
120
+ try {
121
+ const reply = readSettingsUpdateReply(await tools.updateSettings(channelId, patch));
122
+ if (!reply.ok) {
123
+ setError(reply.error || "Couldn't save the settings.");
124
+ return;
125
+ }
126
+ onSaved({
127
+ title: t,
128
+ instructions
129
+ });
130
+ onClose();
131
+ } catch (e) {
132
+ setError("Couldn't save the settings. Check your connection and try again.");
133
+ } finally {
134
+ setSaving(false);
135
+ }
136
+ };
137
+ const remove = () => {
138
+ if (!channelId) return;
139
+ if (aiBusy) {
140
+ setError("Wait for the AI to finish before deleting this project.");
141
+ return;
142
+ }
143
+ Alert.alert(`Delete "${title}"?`, "Its chat, builds and settings are removed. This cannot be undone.", [{
144
+ text: "Cancel",
145
+ style: "cancel"
146
+ }, {
147
+ text: "Delete project",
148
+ style: "destructive",
149
+ onPress: () => {
150
+ setDeleting(true);
151
+ setError(null);
152
+ tools.deleteProject(channelId).then((r) => {
153
+ if (!r.ok) {
154
+ setError(r.error || "The project could not be deleted.");
155
+ return;
156
+ }
157
+ onClose();
158
+ onDeleted();
159
+ }).catch(() => setError("The project could not be deleted. Try again.")).finally(() => setDeleting(false));
160
+ }
161
+ }]);
162
+ };
163
+ const count = knowledge.length;
164
+ return /* @__PURE__ */ jsx(Sheet, { visible, title: mode === "rename" ? "Rename" : "Project settings", onClose, theme, testID: "webbuilder-project-settings", children: /* @__PURE__ */ jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.body, keyboardShouldPersistTaps: "handled", children: [
165
+ /* @__PURE__ */ jsx(Text, { style: [styles.label, {
166
+ color: theme.ink
167
+ }], children: "Name" }),
168
+ /* @__PURE__ */ jsx(TextInput, { value: name, onChangeText: setName, autoFocus: mode === "rename", returnKeyType: "done", onSubmitEditing: mode === "rename" ? () => save().catch(() => void 0) : void 0, style: [styles.input, {
169
+ color: theme.ink,
170
+ borderColor: theme.border,
171
+ backgroundColor: theme.screen
172
+ }], accessibilityLabel: "Project name", testID: "webbuilder-project-name" }),
173
+ mode === "settings" ? /* @__PURE__ */ jsxs(Fragment, { children: [
174
+ /* @__PURE__ */ jsxs(View, { style: styles.labelRow, children: [
175
+ /* @__PURE__ */ jsx(Text, { style: [styles.label, {
176
+ color: theme.ink
177
+ }], children: "Project instructions" }),
178
+ /* @__PURE__ */ jsxs(Text, { style: [styles.rowHint, {
179
+ color: theme.muted
180
+ }], children: [
181
+ count,
182
+ " / ",
183
+ PROJECT_KNOWLEDGE_MAX
184
+ ] })
185
+ ] }),
186
+ /* @__PURE__ */ jsx(TextInput, { value: knowledge, onChangeText: (t) => setKnowledge(t.slice(0, PROJECT_KNOWLEDGE_MAX)), multiline: true, placeholder: "Rules the AI always follows for this project, e.g.\n- Brand colour #0f766e, font Inter\n- Write in British English\n- Never add a login page", placeholderTextColor: theme.faint, textAlignVertical: "top", style: [styles.input, styles.area, {
187
+ color: theme.ink,
188
+ borderColor: theme.accent,
189
+ backgroundColor: theme.screen
190
+ }], accessibilityLabel: "Project instructions", testID: "webbuilder-project-instructions" }),
191
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, {
192
+ color: theme.muted
193
+ }], children: "Sent to the AI with every build, edit and fix of this project. Saved with the project." })
194
+ ] }) : null,
195
+ loading ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }) : null,
196
+ error ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
197
+ color: theme.crit
198
+ }], children: error }) : null,
199
+ /* @__PURE__ */ jsx(PrimaryButton, { label: "Save", onPress: () => {
200
+ save().catch(() => void 0);
201
+ }, theme, busy: saving, disabled: !channelId, testID: "webbuilder-project-save" }),
202
+ mode === "settings" ? /* @__PURE__ */ jsxs(Tap, { onPress: remove, disabled: deleting, accessibilityRole: "button", accessibilityLabel: "Delete project", style: styles.danger, pressedStyle: DIM, testID: "webbuilder-project-delete", children: [
203
+ deleting ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.crit }) : /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "trash-can-outline", size: 18, color: theme.crit }),
204
+ /* @__PURE__ */ jsx(Text, { style: [styles.dangerText, {
205
+ color: theme.crit
206
+ }], children: "Delete project" })
207
+ ] }) : null
208
+ ] }) });
209
+ }
210
+ function GithubPushSheet({
211
+ visible,
212
+ build,
213
+ channelId,
214
+ title,
215
+ tools,
216
+ onStarted,
217
+ onClose,
218
+ theme
219
+ }) {
220
+ const [repo, setRepo] = useState("");
221
+ const [sync, setSync] = useState(true);
222
+ const [branch, setBranch] = useState(DEFAULT_SYNC_BRANCH);
223
+ const [repoUrl, setRepoUrl] = useState("");
224
+ const [working, setWorking] = useState(false);
225
+ const [error, setError] = useState(null);
226
+ useEffect(() => {
227
+ if (!visible) return void 0;
228
+ setError(null);
229
+ setRepo(repoSlug(title));
230
+ if (!channelId) return void 0;
231
+ let alive = true;
232
+ tools.loadSettings(channelId).then((raw) => {
233
+ var _a;
234
+ const gh = (_a = parseProjectSettings(raw)) == null ? void 0 : _a.github;
235
+ if (!alive || !gh) return;
236
+ if (gh.repoUrl) {
237
+ setRepoUrl(gh.repoUrl);
238
+ setRepo(gh.repoUrl.split("/").pop() || repoSlug(title));
239
+ }
240
+ if (gh.branch) setBranch(gh.branch);
241
+ setSync(gh.sync !== false);
242
+ }).catch(() => void 0);
243
+ return () => {
244
+ alive = false;
245
+ };
246
+ }, [visible, channelId]);
247
+ const name = repo.trim();
248
+ const canSubmit = Boolean(build == null ? void 0 : build.sandboxId) && isValidRepoName(name) && (!sync || Boolean(normalizeBranch(branch)));
249
+ const push = async () => {
250
+ if (!build || !canSubmit) return;
251
+ setWorking(true);
252
+ setError(null);
253
+ try {
254
+ if (channelId) {
255
+ const patch = githubSyncPatch(repoUrl, branch, sync);
256
+ if (patch) await tools.updateSettings(channelId, {
257
+ github: patch
258
+ }).catch(() => null);
259
+ }
260
+ const r = await tools.pushToGithub(build, name);
261
+ if (!r.ok) {
262
+ setError(r.message || "The push didn't start. Try again.");
263
+ return;
264
+ }
265
+ onClose();
266
+ onStarted(r.message || "Push started. Follow along in the chat.");
267
+ } catch (e) {
268
+ setError("The push didn't start. Check your connection and try again.");
269
+ } finally {
270
+ setWorking(false);
271
+ }
272
+ };
273
+ return /* @__PURE__ */ jsx(Sheet, { visible, title: "Push to GitHub", onClose, theme, testID: "webbuilder-github-push", children: /* @__PURE__ */ jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.body, keyboardShouldPersistTaps: "handled", children: [
274
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, {
275
+ color: theme.muted
276
+ }], children: "Repository name for this build - kept for this project." }),
277
+ /* @__PURE__ */ jsx(TextInput, { value: repo, onChangeText: (t) => setRepo(t.replace(/[^A-Za-z0-9._-]/g, "-").slice(0, 100)), autoCapitalize: "none", autoCorrect: false, style: [styles.input, {
278
+ color: theme.ink,
279
+ borderColor: theme.accent,
280
+ backgroundColor: theme.screen
281
+ }], accessibilityLabel: "Repository name", testID: "webbuilder-github-repo" }),
282
+ /* @__PURE__ */ jsxs(View, { style: [styles.card, {
283
+ borderColor: theme.border
284
+ }], children: [
285
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => setSync((v) => !v), accessibilityRole: "checkbox", accessibilityState: {
286
+ checked: sync
287
+ }, style: styles.checkRow, pressedStyle: DIM, testID: "webbuilder-github-sync", children: [
288
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: sync ? "checkbox-marked" : "checkbox-blank-outline", size: 22, color: sync ? theme.info : theme.muted }),
289
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
290
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
291
+ color: theme.ink
292
+ }], children: "Keep in sync automatically" }),
293
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowHint, {
294
+ color: theme.muted
295
+ }], children: "Every change is pushed as a commit, and changes made on GitHub come back before the next edit. If both sides changed, we ask which version to keep." })
296
+ ] })
297
+ ] }),
298
+ sync ? /* @__PURE__ */ jsxs(Fragment, { children: [
299
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowHint, {
300
+ color: theme.muted
301
+ }], children: "Branch" }),
302
+ /* @__PURE__ */ jsx(TextInput, { value: branch, onChangeText: setBranch, autoCapitalize: "none", autoCorrect: false, style: [styles.input, {
303
+ color: theme.ink,
304
+ borderColor: theme.border,
305
+ backgroundColor: theme.card
306
+ }], accessibilityLabel: "Branch" })
307
+ ] }) : null
308
+ ] }),
309
+ !(build == null ? void 0 : build.sandboxId) ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
310
+ color: theme.muted
311
+ }], children: "Wake the preview to push to GitHub." }) : null,
312
+ error ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
313
+ color: theme.crit
314
+ }], children: error }) : null,
315
+ /* @__PURE__ */ jsx(PrimaryButton, { label: repoUrl ? "Push" : "Create & Push", icon: "github", onPress: () => {
316
+ push().catch(() => void 0);
317
+ }, theme, busy: working, disabled: !canSubmit, testID: "webbuilder-github-submit" })
318
+ ] }) });
319
+ }
320
+ function EntryRow({
321
+ entry,
322
+ onPress,
323
+ theme
324
+ }) {
325
+ return /* @__PURE__ */ jsxs(Tap, { onPress, accessibilityRole: "button", accessibilityLabel: entry.title, style: styles.row, pressedStyle: DIM, children: [
326
+ entry.logo ? /* @__PURE__ */ jsx(Image, { source: {
327
+ uri: entry.logo
328
+ }, style: styles.logo, resizeMode: "contain" }) : /* @__PURE__ */ jsx(View, { style: [styles.logo, styles.logoBlank, {
329
+ backgroundColor: theme.chip
330
+ }], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "power-plug-outline", size: 18, color: theme.muted }) }),
331
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
332
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
333
+ color: theme.ink
334
+ }], children: entry.title }),
335
+ entry.description ? /* @__PURE__ */ jsx(Text, { style: [styles.rowHint, {
336
+ color: theme.muted
337
+ }], numberOfLines: 2, children: entry.description }) : null
338
+ ] }),
339
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-right", size: 20, color: theme.faint })
340
+ ] });
341
+ }
342
+ function IntegrationsSheet({
343
+ visible,
344
+ channelId,
345
+ tools,
346
+ aiBusy,
347
+ onRequest,
348
+ onClose,
349
+ theme
350
+ }) {
351
+ const [search, setSearch] = useState("");
352
+ const [catalog, setCatalog] = useState([]);
353
+ const [loading, setLoading] = useState(false);
354
+ const [failed, setFailed] = useState(false);
355
+ const [picked, setPicked] = useState(null);
356
+ const [purpose, setPurpose] = useState("");
357
+ const [working, setWorking] = useState(false);
358
+ const [error, setError] = useState(null);
359
+ const load = () => {
360
+ setLoading(true);
361
+ setFailed(false);
362
+ tools.integrations().then((raw) => setCatalog(parseCatalog(raw))).catch(() => setFailed(true)).finally(() => setLoading(false));
363
+ };
364
+ useEffect(() => {
365
+ if (!visible) return;
366
+ setPicked(null);
367
+ setSearch("");
368
+ setError(null);
369
+ load();
370
+ }, [visible]);
371
+ const {
372
+ featured,
373
+ groups
374
+ } = useMemo(() => groupCatalog(catalog, search), [catalog, search]);
375
+ const showAi = !search.trim() || /ai|assistant|chat|search|writ/i.test(search);
376
+ const add = async () => {
377
+ var _a;
378
+ if (!picked) return;
379
+ if (aiBusy) {
380
+ setError("Wait for the AI to finish, then add it.");
381
+ return;
382
+ }
383
+ setWorking(true);
384
+ setError(null);
385
+ try {
386
+ if (picked.kind === "connector" && channelId) {
387
+ const current = parseProjectSettings(await tools.loadSettings(channelId).catch(() => null));
388
+ const list = withIntegration((_a = current == null ? void 0 : current.integrations) != null ? _a : [], picked.entry, purpose);
389
+ const reply = readSettingsUpdateReply(await tools.updateSettings(channelId, {
390
+ integrations: list
391
+ }));
392
+ if (!reply.ok) {
393
+ setError(reply.error || "Couldn't save the integration.");
394
+ return;
395
+ }
396
+ }
397
+ onClose();
398
+ onRequest(picked.kind === "ai" ? aiRequest(purpose) : integrationRequest(picked.entry, purpose));
399
+ } catch (err) {
400
+ setError(err instanceof Error ? err.message : "Couldn't add it. Try again.");
401
+ } finally {
402
+ setWorking(false);
403
+ }
404
+ };
405
+ let body;
406
+ if (picked) {
407
+ const ai = picked.kind === "ai";
408
+ body = /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
409
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => setPicked(null), accessibilityRole: "button", accessibilityLabel: "Back to Integrations", style: styles.back, pressedStyle: DIM, children: [
410
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-left", size: 22, color: theme.ink }),
411
+ /* @__PURE__ */ jsx(Text, { style: [styles.backText, {
412
+ color: theme.ink
413
+ }], children: "Integrations" })
414
+ ] }),
415
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, {
416
+ color: theme.muted
417
+ }], children: ai ? "A chat assistant, smart search, writing help - runs on your site's server." : picked.entry.description || `Add ${picked.entry.title} to your site.` }),
418
+ /* @__PURE__ */ jsx(Text, { style: [styles.label, {
419
+ color: theme.ink
420
+ }], children: "What should it do? (optional)" }),
421
+ /* @__PURE__ */ jsx(TextInput, { value: purpose, onChangeText: setPurpose, placeholder: ai ? "An assistant that answers visitors' questions" : "e.g. the products on my site", placeholderTextColor: theme.faint, style: [styles.input, {
422
+ color: theme.ink,
423
+ borderColor: theme.border,
424
+ backgroundColor: theme.screen
425
+ }], accessibilityLabel: "What it should do" }),
426
+ error ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
427
+ color: theme.crit
428
+ }], children: error }) : null,
429
+ /* @__PURE__ */ jsx(PrimaryButton, { label: "Add to my site", icon: "plus", onPress: () => {
430
+ add().catch(() => void 0);
431
+ }, theme, busy: working, disabled: aiBusy, testID: "webbuilder-integration-add" })
432
+ ] });
433
+ } else {
434
+ body = /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
435
+ /* @__PURE__ */ jsxs(View, { style: [styles.search, {
436
+ borderColor: theme.accent,
437
+ backgroundColor: theme.screen
438
+ }], children: [
439
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "magnify", size: 18, color: theme.muted }),
440
+ /* @__PURE__ */ jsx(TextInput, { value: search, onChangeText: setSearch, placeholder: "Search integrations", placeholderTextColor: theme.faint, autoCapitalize: "none", autoCorrect: false, style: [styles.searchInput, {
441
+ color: theme.ink
442
+ }], accessibilityLabel: "Search integrations", testID: "webbuilder-integrations-search" })
443
+ ] }),
444
+ /* @__PURE__ */ jsxs(ScrollView, { style: styles.list, keyboardShouldPersistTaps: "handled", children: [
445
+ showAi ? /* @__PURE__ */ jsxs(Tap, { onPress: () => {
446
+ setPurpose("");
447
+ setPicked({
448
+ kind: "ai"
449
+ });
450
+ }, accessibilityRole: "button", accessibilityLabel: "Add AI to my site", style: [styles.aiCard, {
451
+ backgroundColor: theme.chip,
452
+ borderColor: theme.border
453
+ }], pressedStyle: DIM, testID: "webbuilder-integration-ai", children: [
454
+ /* @__PURE__ */ jsx(View, { style: [styles.logo, styles.logoBlank, {
455
+ backgroundColor: theme.accentSoft
456
+ }], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "creation", size: 18, color: theme.accent }) }),
457
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
458
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
459
+ color: theme.ink
460
+ }], children: "Add AI to my site" }),
461
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowHint, {
462
+ color: theme.muted
463
+ }], children: "A chat assistant, smart search, writing help - runs on your site's server." })
464
+ ] })
465
+ ] }) : null,
466
+ loading ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent, style: styles.spin }) : null,
467
+ !loading && failed ? /* @__PURE__ */ jsxs(View, { style: styles.empty, children: [
468
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, {
469
+ color: theme.muted
470
+ }], children: "Couldn't load the integrations." }),
471
+ /* @__PURE__ */ jsx(SecondaryButton, { label: "Try again", icon: "refresh", onPress: load, theme })
472
+ ] }) : null,
473
+ !loading && !failed && featured.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
474
+ /* @__PURE__ */ jsx(Text, { style: [styles.section, {
475
+ color: theme.muted
476
+ }], children: "POPULAR" }),
477
+ featured.map((e) => /* @__PURE__ */ jsx(EntryRow, { entry: e, onPress: () => {
478
+ setPurpose("");
479
+ setPicked({
480
+ kind: "connector",
481
+ entry: e
482
+ });
483
+ }, theme }, e.id))
484
+ ] }) : null,
485
+ !loading && !failed ? groups.map((g) => /* @__PURE__ */ jsxs(View, { children: [
486
+ /* @__PURE__ */ jsx(Text, { style: [styles.section, {
487
+ color: theme.muted
488
+ }], children: g.category.toUpperCase() }),
489
+ g.entries.map((e) => /* @__PURE__ */ jsx(EntryRow, { entry: e, onPress: () => {
490
+ setPurpose("");
491
+ setPicked({
492
+ kind: "connector",
493
+ entry: e
494
+ });
495
+ }, theme }, e.id))
496
+ ] }, g.category)) : null,
497
+ !loading && !failed && !featured.length && !groups.length ? /* @__PURE__ */ jsxs(View, { style: styles.empty, children: [
498
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "power-plug-outline", size: 24, color: theme.muted }),
499
+ /* @__PURE__ */ jsx(Text, { style: [styles.emptyTitle, {
500
+ color: theme.ink
501
+ }], children: search.trim() ? "No integrations match" : "No other integrations yet" }),
502
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, styles.center, {
503
+ color: theme.muted
504
+ }], children: "More integrations show up here when your organization adds them." })
505
+ ] }) : null
506
+ ] })
507
+ ] });
508
+ }
509
+ return /* @__PURE__ */ jsx(Sheet, { visible, title: (picked == null ? void 0 : picked.kind) === "ai" ? "Add AI to my site" : (picked == null ? void 0 : picked.entry.title) || "Integrations", onClose, theme, testID: "webbuilder-integrations", children: body });
510
+ }
511
+ function ImportProjectSheet({
512
+ visible,
513
+ onImport,
514
+ onClose,
515
+ theme,
516
+ fetchImpl = fetch
517
+ }) {
518
+ const [input, setInput] = useState("");
519
+ const [checking, setChecking] = useState(false);
520
+ const [result, setResult] = useState(null);
521
+ useEffect(() => {
522
+ if (!visible) return;
523
+ setInput("");
524
+ setResult(null);
525
+ }, [visible]);
526
+ const check = async () => {
527
+ const parsed = parseRepoInput(input);
528
+ if (!parsed.ok) {
529
+ setResult({
530
+ ok: false,
531
+ message: parsed.error
532
+ });
533
+ return;
534
+ }
535
+ setChecking(true);
536
+ try {
537
+ const res = await fetchImpl(`https://api.github.com/repos/${parsed.ref.owner}/${parsed.ref.repo}`, {
538
+ headers: {
539
+ Accept: "application/vnd.github+json"
540
+ }
541
+ });
542
+ const body = await res.json().catch(() => null);
543
+ setResult(readRepoCheck(parsed.ref, res.status, body));
544
+ } catch (e) {
545
+ setResult({
546
+ ok: false,
547
+ message: "Couldn't reach GitHub. Check your connection, then try again."
548
+ });
549
+ } finally {
550
+ setChecking(false);
551
+ }
552
+ };
553
+ return /* @__PURE__ */ jsx(Sheet, { visible, title: "Import a project", onClose, theme, testID: "webbuilder-import", children: /* @__PURE__ */ jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.body, keyboardShouldPersistTaps: "handled", children: [
554
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, {
555
+ color: theme.muted
556
+ }], children: "Bring an app you built elsewhere - Vite or Next.js - with its code and history." }),
557
+ /* @__PURE__ */ jsx(Text, { style: [styles.label, {
558
+ color: theme.ink
559
+ }], children: "GitHub repository" }),
560
+ /* @__PURE__ */ jsxs(View, { style: styles.inline, children: [
561
+ /* @__PURE__ */ jsxs(View, { style: [styles.search, styles.grow, {
562
+ borderColor: theme.accent,
563
+ backgroundColor: theme.screen
564
+ }], children: [
565
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "github", size: 18, color: theme.muted }),
566
+ /* @__PURE__ */ jsx(TextInput, { value: input, onChangeText: (t) => {
567
+ setInput(t);
568
+ setResult(null);
569
+ }, placeholder: "https://github.com/you/your-app", placeholderTextColor: theme.faint, autoCapitalize: "none", autoCorrect: false, keyboardType: "url", returnKeyType: "go", onSubmitEditing: () => {
570
+ check().catch(() => void 0);
571
+ }, style: [styles.searchInput, {
572
+ color: theme.ink
573
+ }], accessibilityLabel: "GitHub repository", testID: "webbuilder-import-repo" })
574
+ ] }),
575
+ /* @__PURE__ */ jsx(Tap, { onPress: () => {
576
+ check().catch(() => void 0);
577
+ }, disabled: !input.trim() || checking, accessibilityRole: "button", accessibilityLabel: "Check", style: [styles.checkBtn, {
578
+ backgroundColor: theme.accent
579
+ }, (!input.trim() || checking) && styles.disabled], pressedStyle: DIM, testID: "webbuilder-import-check", children: checking ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accentInk }) : /* @__PURE__ */ jsx(Text, { style: [styles.checkText, {
580
+ color: theme.accentInk
581
+ }], children: "Check" }) })
582
+ ] }),
583
+ /* @__PURE__ */ jsx(Text, { style: [styles.help, {
584
+ color: theme.muted
585
+ }], children: "From another app builder: use its GitHub sync to put your app on GitHub, then paste the repository's address here." }),
586
+ result && !result.ok ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
587
+ color: theme.crit
588
+ }], children: result.message }) : null,
589
+ (result == null ? void 0 : result.ok) ? /* @__PURE__ */ jsxs(View, { style: [styles.card, {
590
+ borderColor: theme.border
591
+ }], testID: "webbuilder-import-found", children: [
592
+ /* @__PURE__ */ jsxs(View, { style: styles.checkRow, children: [
593
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "source-repository", size: 22, color: theme.good }),
594
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
595
+ /* @__PURE__ */ jsxs(Text, { style: [styles.rowLabel, {
596
+ color: theme.ink
597
+ }], children: [
598
+ result.ref.owner,
599
+ "/",
600
+ result.name
601
+ ] }),
602
+ /* @__PURE__ */ jsxs(Text, { style: [styles.rowHint, {
603
+ color: theme.muted
604
+ }], children: [
605
+ "Branch ",
606
+ result.ref.branch,
607
+ result.description ? ` \xB7 ${result.description}` : ""
608
+ ] })
609
+ ] })
610
+ ] }),
611
+ /* @__PURE__ */ jsx(PrimaryButton, { label: "Import", icon: "download", onPress: () => {
612
+ onClose();
613
+ onImport(importTurn(result.ref));
614
+ }, theme, testID: "webbuilder-import-start" })
615
+ ] }) : null
616
+ ] }) });
617
+ }
618
+ const styles = StyleSheet.create({
619
+ scroll: {
620
+ flexGrow: 0
621
+ },
622
+ menuBody: {
623
+ paddingBottom: 12
624
+ },
625
+ body: {
626
+ gap: 12,
627
+ paddingBottom: 12
628
+ },
629
+ row: {
630
+ flexDirection: "row",
631
+ alignItems: "center",
632
+ gap: 12,
633
+ paddingVertical: 12,
634
+ minHeight: 52
635
+ },
636
+ rowText: {
637
+ flex: 1
638
+ },
639
+ rowLabel: {
640
+ fontSize: 16,
641
+ fontWeight: "500"
642
+ },
643
+ rowHint: {
644
+ fontSize: 13,
645
+ marginTop: 2,
646
+ lineHeight: 18
647
+ },
648
+ sub: {
649
+ marginLeft: 10,
650
+ paddingLeft: 12,
651
+ borderLeftWidth: StyleSheet.hairlineWidth
652
+ },
653
+ divider: {
654
+ height: StyleSheet.hairlineWidth,
655
+ marginVertical: 6
656
+ },
657
+ section: {
658
+ fontSize: 12,
659
+ fontWeight: "700",
660
+ letterSpacing: 0.6,
661
+ paddingTop: 10,
662
+ paddingBottom: 2
663
+ },
664
+ label: {
665
+ fontSize: 14,
666
+ fontWeight: "600"
667
+ },
668
+ labelRow: {
669
+ flexDirection: "row",
670
+ alignItems: "center",
671
+ justifyContent: "space-between"
672
+ },
673
+ input: {
674
+ borderWidth: 1.5,
675
+ borderRadius: 12,
676
+ paddingHorizontal: 14,
677
+ paddingVertical: 12,
678
+ fontSize: 16
679
+ },
680
+ area: {
681
+ minHeight: 160
682
+ },
683
+ help: {
684
+ fontSize: 13,
685
+ lineHeight: 18
686
+ },
687
+ center: {
688
+ textAlign: "center"
689
+ },
690
+ danger: {
691
+ flexDirection: "row",
692
+ alignItems: "center",
693
+ gap: 8,
694
+ alignSelf: "flex-start",
695
+ paddingVertical: 8
696
+ },
697
+ dangerText: {
698
+ fontSize: 15,
699
+ fontWeight: "600"
700
+ },
701
+ card: {
702
+ gap: 10,
703
+ padding: 12,
704
+ borderRadius: 12,
705
+ borderWidth: StyleSheet.hairlineWidth
706
+ },
707
+ checkRow: {
708
+ flexDirection: "row",
709
+ alignItems: "flex-start",
710
+ gap: 10
711
+ },
712
+ back: {
713
+ flexDirection: "row",
714
+ alignItems: "center",
715
+ gap: 2,
716
+ alignSelf: "flex-start",
717
+ paddingVertical: 4
718
+ },
719
+ backText: {
720
+ fontSize: 15,
721
+ fontWeight: "600"
722
+ },
723
+ search: {
724
+ flexDirection: "row",
725
+ alignItems: "center",
726
+ gap: 8,
727
+ borderWidth: 1.5,
728
+ borderRadius: 12,
729
+ paddingHorizontal: 12,
730
+ minHeight: 48
731
+ },
732
+ searchInput: {
733
+ flex: 1,
734
+ fontSize: 16,
735
+ paddingVertical: 10
736
+ },
737
+ list: {
738
+ maxHeight: 420
739
+ },
740
+ aiCard: {
741
+ flexDirection: "row",
742
+ alignItems: "center",
743
+ gap: 12,
744
+ padding: 12,
745
+ borderRadius: 12,
746
+ borderWidth: StyleSheet.hairlineWidth,
747
+ marginBottom: 4
748
+ },
749
+ logo: {
750
+ width: 34,
751
+ height: 34,
752
+ borderRadius: 8
753
+ },
754
+ logoBlank: {
755
+ alignItems: "center",
756
+ justifyContent: "center"
757
+ },
758
+ spin: {
759
+ paddingVertical: 20
760
+ },
761
+ empty: {
762
+ alignItems: "center",
763
+ gap: 8,
764
+ paddingVertical: 24
765
+ },
766
+ emptyTitle: {
767
+ fontSize: 16,
768
+ fontWeight: "700"
769
+ },
770
+ inline: {
771
+ flexDirection: "row",
772
+ alignItems: "center",
773
+ gap: 8
774
+ },
775
+ grow: {
776
+ flex: 1
777
+ },
778
+ checkBtn: {
779
+ minHeight: 48,
780
+ paddingHorizontal: 16,
781
+ borderRadius: 12,
782
+ alignItems: "center",
783
+ justifyContent: "center"
784
+ },
785
+ checkText: {
786
+ fontSize: 15,
787
+ fontWeight: "700"
788
+ },
789
+ disabled: {
790
+ opacity: 0.5
791
+ }
792
+ });export{GithubPushSheet,ImportProjectSheet,IntegrationsSheet,ProjectMenuSheet,ProjectSettingsSheet};//# sourceMappingURL=ProjectSheets.js.map