@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,987 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';import {useMemo,useRef,useCallback,useState,useEffect}from'react';import {View,StyleSheet,Pressable,Text,Switch,ActivityIndicator,Modal,ScrollView,TextInput}from'react-native';import {Ionicons}from'@expo/vector-icons';import {useApolloClient,useQuery}from'@apollo/client/index.js';import {NATIVE_NOTES_RUNTIME_STATUS,NATIVE_NOTION_AGENT_RUNS,NATIVE_NOTION_QUERY_DATABASE,NATIVE_NOTION_AGENT_APPROVAL,NATIVE_NOTION_APPROVE_AGENT,NATIVE_NOTION_START_AGENT_RUN,NATIVE_NOTION_CANCEL_AGENT_RUN,NATIVE_NOTION_SEARCH_HITS}from'./notionDocuments.js';import {normalizeAgentConfig,agentPropertiesPatch,latestRuns,parseRunRow,cronToSchedule,triggerLabel,removeTrigger,triggerKey,YANTRA_NOTION_TOOL,toggleConnectorTool,toggleScopeItem,upsertTrigger,DEFAULT_SCHEDULE,scheduleTrigger,buildAgentRunPrompt,scheduleLabel,SCHEDULE_FREQUENCIES,WEEKDAY_NAMES,MAX_MONTH_DAY}from'./notionNotesAgent.js';import {effectiveRunStatus,AGENT_RUN_LABEL}from'./notionAgentRunStatus.js';import {TILE_COLOR_NAMES}from'./notionPageKinds.js';import {serverRunToRow,isMissingOperationError,SERVER_RUNS_POLL_MS,runDoneMessage}from'./notionAgentRuns.js';import {connectorDisplayName,fetchConnectorCatalog,cdeConnectorCatalogUrl}from'./notionConnections.js';import {serverErrorText}from'./notionPageActions.js';import {tile,RUN_DOT}from'./NotionSidebarSections.js';import {ui,SheetHeader}from'./notionUi.js';import {ChoiceSheet}from'./database/DatabaseSheets.js';import {config}from'../../config/env-config.js';import {useObtainSystemToken}from'../../hooks/useObtainSystemToken.js';var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const MODEL_TIERS = [{
21
+ value: "yantra/small",
22
+ label: "Small"
23
+ }, {
24
+ value: "yantra/medium",
25
+ label: "Medium"
26
+ }, {
27
+ value: "yantra/complex",
28
+ label: "Complex"
29
+ }];
30
+ function ago(ms) {
31
+ if (!ms) return "";
32
+ const s = Math.max(0, Math.round((Date.now() - ms) / 1e3));
33
+ if (s < 60) return "just now";
34
+ const m = Math.round(s / 60);
35
+ if (m < 60) return `${m}m ago`;
36
+ const h = Math.round(m / 60);
37
+ if (h < 24) return `${h}h ago`;
38
+ const d = Math.round(h / 24);
39
+ return d < 30 ? `${d}d ago` : new Date(ms).toLocaleDateString();
40
+ }
41
+ function NotionAgentPanel({
42
+ pageId,
43
+ workspaceId,
44
+ name,
45
+ properties,
46
+ instructions,
47
+ isDark,
48
+ palette,
49
+ onPatch,
50
+ onRunInChat,
51
+ onToast
52
+ }) {
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
54
+ const client = useApolloClient();
55
+ const agent = useMemo(() => normalizeAgentConfig(properties.agent), [properties.agent]);
56
+ const propsRef = useRef(properties);
57
+ propsRef.current = properties;
58
+ const write = useCallback((patch) => onPatch(agentPropertiesPatch(propsRef.current, patch)), [onPatch]);
59
+ const configNow = () => normalizeAgentConfig(propsRef.current.agent);
60
+ const [sheet, setSheet] = useState(null);
61
+ const thenOpen = (next) => {
62
+ setSheet(null);
63
+ setTimeout(() => setSheet(next), 450);
64
+ };
65
+ const [pendingDb, setPendingDb] = useState(null);
66
+ const runtime = useQuery(NATIVE_NOTES_RUNTIME_STATUS, {
67
+ fetchPolicy: "cache-first",
68
+ errorPolicy: "all"
69
+ });
70
+ const [serverUnsupported, setServerUnsupported] = useState(false);
71
+ const serverRuns = !serverUnsupported && Boolean((_b = (_a = runtime.data) == null ? void 0 : _a.notesRuntimeStatus) == null ? void 0 : _b.agentRuntimeEnabled);
72
+ const schedulerLive = Boolean((_d = (_c = runtime.data) == null ? void 0 : _c.notesRuntimeStatus) == null ? void 0 : _d.schedulerEnabled) && Boolean((_f = (_e = runtime.data) == null ? void 0 : _e.notesRuntimeStatus) == null ? void 0 : _f.agentRuntimeEnabled);
73
+ const [rows, setRows] = useState([]);
74
+ const [runsLoading, setRunsLoading] = useState(false);
75
+ const [runsError, setRunsError] = useState(null);
76
+ const [starting, setStarting] = useState(false);
77
+ const watchRun = useRef(null);
78
+ const reloadRuns = useCallback(async () => {
79
+ var _a2, _b2, _c2, _d2, _e2, _f2;
80
+ setRunsLoading(true);
81
+ try {
82
+ if (serverRuns) {
83
+ const res = await client.query({
84
+ query: NATIVE_NOTION_AGENT_RUNS,
85
+ variables: {
86
+ agentId: pageId,
87
+ limit: 10
88
+ },
89
+ fetchPolicy: "network-only"
90
+ });
91
+ const runs = (_c2 = (_b2 = (_a2 = res.data) == null ? void 0 : _a2.notionAgentRuns) == null ? void 0 : _b2.runs) != null ? _c2 : [];
92
+ setRows(runs.map(serverRunToRow));
93
+ } else if (agent.runsDatabaseId) {
94
+ const res = await client.query({
95
+ query: NATIVE_NOTION_QUERY_DATABASE,
96
+ variables: {
97
+ input: {
98
+ databaseId: agent.runsDatabaseId,
99
+ pageSize: 50
100
+ }
101
+ },
102
+ fetchPolicy: "network-only"
103
+ });
104
+ const list = (_f2 = (_e2 = (_d2 = res.data) == null ? void 0 : _d2.queryDatabase) == null ? void 0 : _e2.results) != null ? _f2 : [];
105
+ setRows(latestRuns(list.map(parseRunRow).filter((r) => Boolean(r))));
106
+ } else {
107
+ setRows([]);
108
+ }
109
+ setRunsError(null);
110
+ } catch (err) {
111
+ if (serverRuns && isMissingOperationError(err)) setServerUnsupported(true);
112
+ else setRunsError(serverErrorText(err));
113
+ } finally {
114
+ setRunsLoading(false);
115
+ }
116
+ }, [agent.runsDatabaseId, client, pageId, serverRuns]);
117
+ useEffect(() => {
118
+ reloadRuns();
119
+ }, [reloadRuns]);
120
+ const active = rows.some((r) => "active" in r && r.active);
121
+ useEffect(() => {
122
+ if (!serverRuns || !active) return void 0;
123
+ const timer = setInterval(reloadRuns, SERVER_RUNS_POLL_MS);
124
+ return () => clearInterval(timer);
125
+ }, [active, reloadRuns, serverRuns]);
126
+ useEffect(() => {
127
+ const id = watchRun.current;
128
+ if (!id) return;
129
+ const run = rows.find((r) => r.id === id);
130
+ if (!run || run.active) return;
131
+ watchRun.current = null;
132
+ onToast(runDoneMessage(run.serverStatus, name || "Untitled agent", run.summary));
133
+ }, [name, onToast, rows]);
134
+ const runNow = async () => {
135
+ var _a2;
136
+ if (serverRuns) {
137
+ setStarting(true);
138
+ try {
139
+ const res = await client.mutate({
140
+ mutation: NATIVE_NOTION_START_AGENT_RUN,
141
+ variables: {
142
+ agentId: pageId
143
+ }
144
+ });
145
+ const run = (_a2 = res.data) == null ? void 0 : _a2.startNotionAgentRun;
146
+ if (run == null ? void 0 : run.id) {
147
+ watchRun.current = run.id;
148
+ setRows((prev) => [serverRunToRow(run), ...prev.filter((r) => r.id !== run.id)]);
149
+ }
150
+ onToast(`Running \u201C${name || "Untitled agent"}\u201D\u2026`);
151
+ reloadRuns();
152
+ } catch (err) {
153
+ if (isMissingOperationError(err)) setServerUnsupported(true);
154
+ onToast(`Couldn't start the run. ${serverErrorText(err)}`);
155
+ } finally {
156
+ setStarting(false);
157
+ }
158
+ return;
159
+ }
160
+ const prompt = buildAgentRunPrompt({
161
+ agentId: pageId,
162
+ name: name || "Untitled agent",
163
+ instructions: instructions(),
164
+ config: configNow(),
165
+ trigger: {
166
+ type: "manual"
167
+ }
168
+ });
169
+ onRunInChat(prompt);
170
+ };
171
+ const cancelRun = async (runId) => {
172
+ var _a2;
173
+ try {
174
+ const res = await client.mutate({
175
+ mutation: NATIVE_NOTION_CANCEL_AGENT_RUN,
176
+ variables: {
177
+ runId
178
+ }
179
+ });
180
+ const run = (_a2 = res.data) == null ? void 0 : _a2.cancelNotionAgentRun;
181
+ if (run) setRows((prev) => prev.map((r) => r.id === runId ? serverRunToRow(run) : r));
182
+ reloadRuns();
183
+ } catch (err) {
184
+ onToast(`Couldn't cancel the run. ${serverErrorText(err)}`);
185
+ }
186
+ };
187
+ const hasAuto = agent.triggers.some((t) => t.type !== "manual");
188
+ const approval = useQuery(NATIVE_NOTION_AGENT_APPROVAL, {
189
+ variables: {
190
+ agentId: pageId
191
+ },
192
+ skip: !(hasAuto && schedulerLive && agent.enabled),
193
+ fetchPolicy: "network-only",
194
+ errorPolicy: "all"
195
+ });
196
+ const approveState = (_g = approval.data) == null ? void 0 : _g.notionAgentApproval;
197
+ const [approving, setApproving] = useState(false);
198
+ const approve = async () => {
199
+ setApproving(true);
200
+ try {
201
+ await client.mutate({
202
+ mutation: NATIVE_NOTION_APPROVE_AGENT,
203
+ variables: {
204
+ agentId: pageId
205
+ }
206
+ });
207
+ await approval.refetch();
208
+ } catch (err) {
209
+ onToast(`Couldn't approve. ${serverErrorText(err)}`);
210
+ } finally {
211
+ setApproving(false);
212
+ }
213
+ };
214
+ const lastStatus = agent.lastRun ? effectiveRunStatus(agent.lastRun.status, agent.lastRun.at) : void 0;
215
+ const busy = starting || active || lastStatus === "running";
216
+ const scheduleOf = (t) => t.type === "schedule" ? cronToSchedule(t.cron) : null;
217
+ const existingSchedule = (_h = agent.triggers.map(scheduleOf).find(Boolean)) != null ? _h : null;
218
+ return /* @__PURE__ */ jsxs(View, { style: [styles.panel, {
219
+ backgroundColor: palette.card,
220
+ borderColor: palette.hairline
221
+ }], children: [
222
+ /* @__PURE__ */ jsxs(View, { style: styles.head, children: [
223
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Tile colour", onPress: () => setSheet("color"), style: [styles.tile, {
224
+ backgroundColor: tile(agent.color, "solid", isDark)
225
+ }], children: /* @__PURE__ */ jsx(Ionicons, { name: "flash", size: 16, color: "#fff" }) }),
226
+ /* @__PURE__ */ jsxs(View, { style: ui.flex, children: [
227
+ /* @__PURE__ */ jsx(Text, { style: [styles.headTitle, {
228
+ color: palette.text
229
+ }], children: "Agent" }),
230
+ /* @__PURE__ */ jsx(Text, { style: [styles.headSub, {
231
+ color: palette.textMuted
232
+ }], children: agent.lastRun ? `Last run ${ago(Date.parse(agent.lastRun.at))} \xB7 ${AGENT_RUN_LABEL[lastStatus != null ? lastStatus : agent.lastRun.status]}` : "Never run" })
233
+ ] }),
234
+ /* @__PURE__ */ jsx(Switch, { accessibilityLabel: "Agent enabled", value: agent.enabled, onValueChange: (enabled) => write({
235
+ enabled
236
+ }) })
237
+ ] }),
238
+ /* @__PURE__ */ jsxs(Section, { palette, icon: "flash-outline", label: "Triggers", children: [
239
+ /* @__PURE__ */ jsxs(View, { style: styles.chips, children: [
240
+ agent.triggers.map((t) => /* @__PURE__ */ jsx(Chip, { palette, label: triggerLabel(t), onRemove: t.type === "manual" ? void 0 : () => write({
241
+ triggers: removeTrigger(configNow().triggers, triggerKey(t))
242
+ }) }, triggerKey(t))),
243
+ /* @__PURE__ */ jsx(AddChip, { palette, label: "Add trigger", onPress: () => setSheet("addTrigger") })
244
+ ] }),
245
+ hasAuto ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
246
+ color: palette.textMuted
247
+ }], children: schedulerLive ? agent.enabled ? "Runs automatically on the server when these triggers fire." : "Turn the agent on to run it automatically on the server when these triggers fire." : "Runs automatically once server scheduling ships. Until then, use Run now." }) : null,
248
+ approveState && approveState.approved === false ? /* @__PURE__ */ jsxs(View, { style: [styles.approval, {
249
+ backgroundColor: palette.primarySoft
250
+ }], children: [
251
+ /* @__PURE__ */ jsx(Ionicons, { name: "shield-checkmark-outline", size: 16, color: palette.primary }),
252
+ /* @__PURE__ */ jsx(Text, { style: [styles.approvalText, {
253
+ color: palette.text
254
+ }], children: "Changes need the owner's approval before the agent runs automatically." }),
255
+ approveState.canApprove ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: approve, disabled: approving, hitSlop: 6, children: /* @__PURE__ */ jsx(Text, { style: [styles.link, {
256
+ color: palette.primary
257
+ }], children: approving ? "Approving\u2026" : "Approve" }) }) : null
258
+ ] }) : null
259
+ ] }),
260
+ /* @__PURE__ */ jsx(Section, { palette, icon: "construct-outline", label: "Tools", children: /* @__PURE__ */ jsxs(View, { style: styles.chips, children: [
261
+ /* @__PURE__ */ jsx(Chip, { palette, label: "Yantra Notion" }),
262
+ agent.tools.filter((t) => t.connector !== YANTRA_NOTION_TOOL.connector).map((t) => /* @__PURE__ */ jsx(Chip, { palette, label: t.label || connectorDisplayName(t.connector), onRemove: () => write({
263
+ tools: toggleConnectorTool(configNow().tools, t.connector)
264
+ }) }, t.connector)),
265
+ /* @__PURE__ */ jsx(AddChip, { palette, label: "Add tool", onPress: () => setSheet("tools") })
266
+ ] }) }),
267
+ /* @__PURE__ */ jsx(Section, { palette, icon: "scan-outline", label: "Scope", children: /* @__PURE__ */ jsxs(View, { style: styles.chips, children: [
268
+ [...agent.scope.pageIds.map((id) => ({
269
+ id,
270
+ type: "page"
271
+ })), ...agent.scope.databaseIds.map((id) => ({
272
+ id,
273
+ type: "database"
274
+ }))].map((item) => {
275
+ var _a2;
276
+ return /* @__PURE__ */ jsx(Chip, { palette, icon: item.type === "database" ? "grid-outline" : "document-text-outline", label: ((_a2 = agent.scope.titles) == null ? void 0 : _a2[item.id]) || "Untitled", onRemove: () => write({
277
+ scope: toggleScopeItem(configNow().scope, item)
278
+ }) }, item.id);
279
+ }),
280
+ !agent.scope.pageIds.length && !agent.scope.databaseIds.length ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
281
+ color: palette.textMuted
282
+ }], children: "Whole workspace" }) : null,
283
+ /* @__PURE__ */ jsx(AddChip, { palette, label: "Add to scope", onPress: () => setSheet("scope") })
284
+ ] }) }),
285
+ /* @__PURE__ */ jsx(Section, { palette, icon: "sparkles-outline", label: "Model", children: /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", onPress: () => setSheet("model"), style: [styles.select, {
286
+ backgroundColor: palette.fill
287
+ }], children: [
288
+ /* @__PURE__ */ jsx(Text, { style: [styles.selectText, {
289
+ color: palette.text
290
+ }], children: MODEL_TIERS.find((m) => m.value === agent.model) ? `Yantra ${MODEL_TIERS.find((m) => m.value === agent.model).label}` : "Default" }),
291
+ /* @__PURE__ */ jsx(Ionicons, { name: "chevron-down", size: 14, color: palette.textMuted })
292
+ ] }) }),
293
+ /* @__PURE__ */ jsx(Section, { palette, icon: "lock-closed-outline", label: "Mode", children: /* @__PURE__ */ jsx(View, { style: [styles.segmented, {
294
+ backgroundColor: palette.fill
295
+ }], children: [[true, "Ask before acting"], [false, "Act automatically"]].map(([ask, label]) => {
296
+ const on = Boolean(agent.requireApproval) === ask;
297
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityState: {
298
+ selected: on
299
+ }, onPress: () => !on && write({
300
+ requireApproval: ask
301
+ }), style: [styles.segment, on && {
302
+ backgroundColor: palette.card
303
+ }], children: /* @__PURE__ */ jsx(Text, { style: [styles.segmentText, {
304
+ color: on ? palette.text : palette.textMuted
305
+ }], children: label }) }, label);
306
+ }) }) }),
307
+ /* @__PURE__ */ jsxs(View, { style: [styles.runs, {
308
+ borderTopColor: palette.hairline
309
+ }], children: [
310
+ /* @__PURE__ */ jsxs(View, { style: styles.runsHead, children: [
311
+ /* @__PURE__ */ jsx(Text, { style: [styles.runsTitle, {
312
+ color: palette.textMuted
313
+ }], children: "Runs" }),
314
+ /* @__PURE__ */ jsx(Pressable, { accessibilityLabel: "Refresh runs", onPress: reloadRuns, hitSlop: 8, children: runsLoading ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: palette.textMuted }) : /* @__PURE__ */ jsx(Ionicons, { name: "refresh", size: 17, color: palette.textMuted }) }),
315
+ /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", onPress: runNow, disabled: busy, style: [styles.runNow, {
316
+ backgroundColor: palette.primary,
317
+ opacity: busy ? 0.6 : 1
318
+ }], children: [
319
+ busy ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: palette.onPrimary }) : /* @__PURE__ */ jsx(Ionicons, { name: "play", size: 14, color: palette.onPrimary }),
320
+ /* @__PURE__ */ jsx(Text, { style: [styles.runNowText, {
321
+ color: palette.onPrimary
322
+ }], children: busy ? "Running" : "Run now" })
323
+ ] })
324
+ ] }),
325
+ !serverRuns ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
326
+ color: palette.textMuted
327
+ }], children: "Runs in your chat on this device (the server agent runtime is off)." }) : null,
328
+ runsError ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
329
+ color: palette.danger
330
+ }], children: runsError }) : null,
331
+ rows.length ? rows.map((r) => {
332
+ var _a2;
333
+ return /* @__PURE__ */ jsxs(View, { style: [styles.runRow, {
334
+ borderTopColor: palette.hairline
335
+ }], children: [
336
+ /* @__PURE__ */ jsx(View, { style: [styles.dot, {
337
+ backgroundColor: (_a2 = RUN_DOT[r.status]) != null ? _a2 : palette.textFaint
338
+ }] }),
339
+ /* @__PURE__ */ jsxs(View, { style: ui.flex, children: [
340
+ /* @__PURE__ */ jsx(Text, { style: [styles.runLabel, {
341
+ color: palette.text
342
+ }], children: `${"serverStatus" in r && r.serverStatus === "cancelled" ? "Cancelled" : AGENT_RUN_LABEL[r.status]} \xB7 ${r.trigger}` }),
343
+ r.summary ? /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: [styles.runSummary, {
344
+ color: palette.textMuted
345
+ }], children: r.summary }) : null
346
+ ] }),
347
+ /* @__PURE__ */ jsx(Text, { style: [styles.runAt, {
348
+ color: palette.textFaint
349
+ }], children: ago(r.startedAt) }),
350
+ "active" in r && r.active ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => cancelRun(r.id), hitSlop: 6, children: /* @__PURE__ */ jsx(Text, { style: [styles.link, {
351
+ color: palette.danger
352
+ }], children: "Cancel" }) }) : null
353
+ ] }, r.id);
354
+ }) : !runsLoading ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
355
+ color: palette.textMuted
356
+ }], children: "No runs yet." }) : null
357
+ ] }),
358
+ /* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "color", title: "Tile colour", palette, value: (_i = agent.color) != null ? _i : null, choices: TILE_COLOR_NAMES.map((c) => ({
359
+ value: c,
360
+ label: c[0].toUpperCase() + c.slice(1)
361
+ })), onClose: () => setSheet(null), onPick: (color) => {
362
+ setSheet(null);
363
+ write({
364
+ color
365
+ });
366
+ } }),
367
+ /* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "addTrigger", title: "Add trigger", palette, choices: [{
368
+ value: "schedule",
369
+ label: "On a schedule\u2026",
370
+ icon: "time-outline"
371
+ }, {
372
+ value: "database",
373
+ label: "When a database row changes\u2026",
374
+ icon: "grid-outline"
375
+ }, {
376
+ value: "comment_mention",
377
+ label: "When @mentioned in a comment",
378
+ icon: "chatbubble-outline"
379
+ }, {
380
+ value: "meeting_ended",
381
+ label: "When a meeting ends",
382
+ icon: "mic-outline"
383
+ }], onClose: () => setSheet(null), onPick: (kind) => {
384
+ if (kind === "schedule" || kind === "database") {
385
+ thenOpen(kind);
386
+ return;
387
+ }
388
+ setSheet(null);
389
+ write({
390
+ triggers: upsertTrigger(configNow().triggers, {
391
+ type: kind
392
+ })
393
+ });
394
+ } }),
395
+ /* @__PURE__ */ jsx(ScheduleSheet, { visible: sheet === "schedule", palette, initial: existingSchedule != null ? existingSchedule : DEFAULT_SCHEDULE, onClose: () => setSheet(null), onSave: (s) => {
396
+ setSheet(null);
397
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
398
+ write({
399
+ triggers: upsertTrigger(configNow().triggers, scheduleTrigger(s, timezone))
400
+ });
401
+ } }),
402
+ /* @__PURE__ */ jsx(BlockPickerSheet, { visible: sheet === "database", title: "Which database?", palette, workspaceId, types: ["database"], onClose: () => setSheet(null), onPick: (item) => {
403
+ setPendingDb({
404
+ id: item.id,
405
+ title: item.title
406
+ });
407
+ thenOpen("dbEvent");
408
+ } }),
409
+ /* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "dbEvent", title: pendingDb ? `When a row in \u201C${pendingDb.title}\u201D\u2026` : "When a row\u2026", palette, choices: [{
410
+ value: "created",
411
+ label: "is created"
412
+ }, {
413
+ value: "updated",
414
+ label: "is updated"
415
+ }], onClose: () => setSheet(null), onPick: (on) => {
416
+ setSheet(null);
417
+ if (!pendingDb) return;
418
+ write({
419
+ triggers: upsertTrigger(configNow().triggers, {
420
+ type: "database_row",
421
+ databaseId: pendingDb.id,
422
+ on,
423
+ databaseTitle: pendingDb.title
424
+ })
425
+ });
426
+ } }),
427
+ /* @__PURE__ */ jsx(ToolPickerSheet, { visible: sheet === "tools", palette, selected: agent.tools.map((t) => t.connector), onClose: () => setSheet(null), onToggle: (app) => write({
428
+ tools: toggleConnectorTool(configNow().tools, app.id, app.title)
429
+ }) }),
430
+ /* @__PURE__ */ jsx(BlockPickerSheet, { visible: sheet === "scope", title: "Add to scope", palette, workspaceId, types: ["page", "database"], selected: [...agent.scope.pageIds, ...agent.scope.databaseIds], onClose: () => setSheet(null), onPick: (item) => write({
431
+ scope: toggleScopeItem(configNow().scope, {
432
+ id: item.id,
433
+ type: item.type === "database" ? "database" : "page",
434
+ title: item.title
435
+ })
436
+ }) }),
437
+ /* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "model", title: "Model", palette, value: (_j = agent.model) != null ? _j : "", choices: [{
438
+ value: "",
439
+ label: "Default"
440
+ }, ...MODEL_TIERS.map((m) => ({
441
+ value: m.value,
442
+ label: `Yantra ${m.label}`
443
+ }))], onClose: () => setSheet(null), onPick: (model) => {
444
+ setSheet(null);
445
+ write({
446
+ model: model || void 0
447
+ });
448
+ } })
449
+ ] });
450
+ }
451
+ function Section({
452
+ palette,
453
+ icon,
454
+ label,
455
+ children
456
+ }) {
457
+ return /* @__PURE__ */ jsxs(View, { style: [styles.section, {
458
+ borderTopColor: palette.hairline
459
+ }], children: [
460
+ /* @__PURE__ */ jsxs(View, { style: styles.sectionHead, children: [
461
+ /* @__PURE__ */ jsx(Ionicons, { name: icon, size: 15, color: palette.textMuted }),
462
+ /* @__PURE__ */ jsx(Text, { style: [styles.sectionLabel, {
463
+ color: palette.textMuted
464
+ }], children: label })
465
+ ] }),
466
+ children
467
+ ] });
468
+ }
469
+ function Chip({
470
+ palette,
471
+ label,
472
+ icon,
473
+ onRemove
474
+ }) {
475
+ return /* @__PURE__ */ jsxs(View, { style: [styles.chip, {
476
+ backgroundColor: palette.fill
477
+ }], children: [
478
+ icon ? /* @__PURE__ */ jsx(Ionicons, { name: icon, size: 13, color: palette.textMuted }) : null,
479
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.chipText, {
480
+ color: palette.text
481
+ }], children: label }),
482
+ onRemove ? /* @__PURE__ */ jsx(Pressable, { accessibilityLabel: `Remove ${label}`, onPress: onRemove, hitSlop: 8, children: /* @__PURE__ */ jsx(Ionicons, { name: "close", size: 14, color: palette.textMuted }) }) : null
483
+ ] });
484
+ }
485
+ function AddChip({
486
+ palette,
487
+ label,
488
+ onPress
489
+ }) {
490
+ return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", onPress, style: [styles.chip, styles.addChip, {
491
+ borderColor: palette.hairline
492
+ }], children: [
493
+ /* @__PURE__ */ jsx(Ionicons, { name: "add", size: 14, color: palette.primary }),
494
+ /* @__PURE__ */ jsx(Text, { style: [styles.chipText, {
495
+ color: palette.primary
496
+ }], children: label })
497
+ ] });
498
+ }
499
+ function Stepper({
500
+ palette,
501
+ value,
502
+ label,
503
+ onChange
504
+ }) {
505
+ return /* @__PURE__ */ jsxs(View, { style: styles.stepper, children: [
506
+ /* @__PURE__ */ jsx(Text, { style: [styles.stepLabel, {
507
+ color: palette.textMuted
508
+ }], children: label }),
509
+ /* @__PURE__ */ jsxs(View, { style: [styles.stepBox, {
510
+ backgroundColor: palette.fill
511
+ }], children: [
512
+ /* @__PURE__ */ jsx(Pressable, { accessibilityLabel: `Less ${label}`, onPress: () => onChange(-1), hitSlop: 6, children: /* @__PURE__ */ jsx(Ionicons, { name: "remove", size: 18, color: palette.text }) }),
513
+ /* @__PURE__ */ jsx(Text, { style: [styles.stepValue, {
514
+ color: palette.text
515
+ }], children: value }),
516
+ /* @__PURE__ */ jsx(Pressable, { accessibilityLabel: `More ${label}`, onPress: () => onChange(1), hitSlop: 6, children: /* @__PURE__ */ jsx(Ionicons, { name: "add", size: 18, color: palette.text }) })
517
+ ] })
518
+ ] });
519
+ }
520
+ function ScheduleSheet({
521
+ visible,
522
+ palette,
523
+ initial,
524
+ onClose,
525
+ onSave
526
+ }) {
527
+ var _a;
528
+ const [s, setS] = useState(initial);
529
+ useEffect(() => {
530
+ if (visible) setS(initial);
531
+ }, [visible]);
532
+ const wrap = (v, max) => (v % max + max) % max;
533
+ return /* @__PURE__ */ jsx(Modal, { visible, animationType: "slide", presentationStyle: "pageSheet", onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: [ui.flex, {
534
+ backgroundColor: palette.bg
535
+ }], children: [
536
+ /* @__PURE__ */ jsx(SheetHeader, { title: "Schedule", onDone: onClose, palette, left: {
537
+ label: "Save",
538
+ onPress: () => onSave(s)
539
+ } }),
540
+ /* @__PURE__ */ jsxs(ScrollView, { contentContainerStyle: styles.sheetBody, children: [
541
+ /* @__PURE__ */ jsx(Text, { style: [styles.preview, {
542
+ color: palette.text
543
+ }], children: scheduleLabel(s) }),
544
+ /* @__PURE__ */ jsx(View, { style: styles.chips, children: SCHEDULE_FREQUENCIES.map((f) => {
545
+ const on = f.id === s.frequency;
546
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityState: {
547
+ selected: on
548
+ }, onPress: () => setS((p) => __spreadProps(__spreadValues({}, p), {
549
+ frequency: f.id
550
+ })), style: [styles.pick, {
551
+ backgroundColor: on ? palette.primary : palette.fill
552
+ }], children: /* @__PURE__ */ jsx(Text, { style: [styles.pickText, {
553
+ color: on ? palette.onPrimary : palette.text
554
+ }], children: f.label }) }, f.id);
555
+ }) }),
556
+ s.frequency === "weekly" ? /* @__PURE__ */ jsx(View, { style: styles.chips, children: WEEKDAY_NAMES.map((d, i) => {
557
+ var _a2;
558
+ const on = ((_a2 = s.weekday) != null ? _a2 : 1) === i;
559
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => setS((p) => __spreadProps(__spreadValues({}, p), {
560
+ weekday: i
561
+ })), style: [styles.pick, {
562
+ backgroundColor: on ? palette.primary : palette.fill
563
+ }], children: /* @__PURE__ */ jsx(Text, { style: [styles.pickText, {
564
+ color: on ? palette.onPrimary : palette.text
565
+ }], children: d.slice(0, 3) }) }, d);
566
+ }) }) : null,
567
+ /* @__PURE__ */ jsxs(View, { style: styles.steppers, children: [
568
+ s.frequency === "monthly" ? /* @__PURE__ */ jsx(Stepper, { palette, label: "Day", value: String((_a = s.dayOfMonth) != null ? _a : 1), onChange: (d) => setS((p) => {
569
+ var _a2;
570
+ return __spreadProps(__spreadValues({}, p), {
571
+ dayOfMonth: wrap(((_a2 = p.dayOfMonth) != null ? _a2 : 1) - 1 + d, MAX_MONTH_DAY) + 1
572
+ });
573
+ }) }) : null,
574
+ s.frequency !== "hourly" ? /* @__PURE__ */ jsx(Stepper, { palette, label: "Hour", value: String(s.hour).padStart(2, "0"), onChange: (d) => setS((p) => __spreadProps(__spreadValues({}, p), {
575
+ hour: wrap(p.hour + d, 24)
576
+ })) }) : null,
577
+ /* @__PURE__ */ jsx(Stepper, { palette, label: "Minute", value: String(s.minute).padStart(2, "0"), onChange: (d) => setS((p) => __spreadProps(__spreadValues({}, p), {
578
+ minute: wrap(p.minute + d * 5, 60)
579
+ })) })
580
+ ] })
581
+ ] })
582
+ ] }) });
583
+ }
584
+ function BlockPickerSheet({
585
+ visible,
586
+ title,
587
+ palette,
588
+ workspaceId,
589
+ types,
590
+ selected = [],
591
+ onClose,
592
+ onPick
593
+ }) {
594
+ const client = useApolloClient();
595
+ const [query, setQuery] = useState("");
596
+ const [items, setItems] = useState([]);
597
+ const [loading, setLoading] = useState(false);
598
+ const typesKey = types.join(",");
599
+ useEffect(() => {
600
+ if (!visible) return void 0;
601
+ let live = true;
602
+ setLoading(true);
603
+ const t = setTimeout(() => {
604
+ client.query({
605
+ query: NATIVE_NOTION_SEARCH_HITS,
606
+ variables: {
607
+ input: __spreadValues({
608
+ query: query.trim(),
609
+ pageSize: 30,
610
+ types: typesKey.split(",")
611
+ }, workspaceId ? {
612
+ workspaceId
613
+ } : {})
614
+ },
615
+ fetchPolicy: "network-only"
616
+ }).then((res) => {
617
+ var _a, _b, _c;
618
+ if (!live) return;
619
+ const hits = (_c = (_b = (_a = res.data) == null ? void 0 : _a.searchBlocks) == null ? void 0 : _b.hits) != null ? _c : [];
620
+ const seen = /* @__PURE__ */ new Set();
621
+ setItems(hits.map((h) => h.block).filter((b) => Boolean(b == null ? void 0 : b.id) && !b.inTrash && !seen.has(b.id) && Boolean(seen.add(b.id))).map((b) => ({
622
+ id: b.id,
623
+ type: b.type,
624
+ title: titleOf(b.properties) || "Untitled"
625
+ })));
626
+ }).catch(() => live && setItems([])).finally(() => live && setLoading(false));
627
+ }, 250);
628
+ return () => {
629
+ live = false;
630
+ clearTimeout(t);
631
+ };
632
+ }, [client, query, typesKey, visible, workspaceId]);
633
+ return /* @__PURE__ */ jsx(Modal, { visible, animationType: "slide", presentationStyle: "pageSheet", onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: [ui.flex, {
634
+ backgroundColor: palette.bg
635
+ }], children: [
636
+ /* @__PURE__ */ jsx(SheetHeader, { title, onDone: onClose, palette }),
637
+ /* @__PURE__ */ jsxs(View, { style: [styles.search, {
638
+ backgroundColor: palette.fill
639
+ }], children: [
640
+ /* @__PURE__ */ jsx(Ionicons, { name: "search", size: 16, color: palette.textMuted }),
641
+ /* @__PURE__ */ jsx(TextInput, { value: query, onChangeText: setQuery, placeholder: "Search", placeholderTextColor: palette.textFaint, autoCorrect: false, style: [styles.searchInput, {
642
+ color: palette.text
643
+ }] }),
644
+ loading ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: palette.textMuted }) : null
645
+ ] }),
646
+ /* @__PURE__ */ jsxs(ScrollView, { contentContainerStyle: styles.sheetBody, keyboardShouldPersistTaps: "handled", children: [
647
+ items.map((it) => {
648
+ const on = selected.includes(it.id);
649
+ return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityState: {
650
+ selected: on
651
+ }, onPress: () => onPick(it), style: ({
652
+ pressed
653
+ }) => [styles.pickRow, {
654
+ backgroundColor: pressed ? palette.pressed : palette.card
655
+ }], children: [
656
+ /* @__PURE__ */ jsx(Ionicons, { name: it.type === "database" ? "grid-outline" : "document-text-outline", size: 17, color: palette.textMuted }),
657
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.pickRowText, {
658
+ color: palette.text
659
+ }], children: it.title }),
660
+ on ? /* @__PURE__ */ jsx(Ionicons, { name: "checkmark", size: 19, color: palette.primary }) : null
661
+ ] }, it.id);
662
+ }),
663
+ !loading && !items.length ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
664
+ color: palette.textMuted
665
+ }], children: "Nothing found." }) : null
666
+ ] })
667
+ ] }) });
668
+ }
669
+ function titleOf(properties) {
670
+ const t = properties == null ? void 0 : properties.title;
671
+ if (typeof t === "string") return t;
672
+ if (Array.isArray(t)) return t.map((r) => {
673
+ var _a, _b, _c;
674
+ return (_c = (_b = r == null ? void 0 : r.plainText) != null ? _b : (_a = r == null ? void 0 : r.text) == null ? void 0 : _a.content) != null ? _c : "";
675
+ }).join("");
676
+ return "";
677
+ }
678
+ function ToolPickerSheet({
679
+ visible,
680
+ palette,
681
+ selected,
682
+ onClose,
683
+ onToggle
684
+ }) {
685
+ const {
686
+ obtainSystemToken,
687
+ getLastError
688
+ } = useObtainSystemToken(visible);
689
+ const [apps, setApps] = useState(null);
690
+ const [error, setError] = useState(null);
691
+ const [query, setQuery] = useState("");
692
+ useEffect(() => {
693
+ if (!visible || apps) return;
694
+ (async () => {
695
+ try {
696
+ const token = await obtainSystemToken();
697
+ if (!token) throw new Error(getLastError() || "Could not sign in to the connector catalog.");
698
+ const list = await fetchConnectorCatalog(cdeConnectorCatalogUrl(config.BACKEND_URL || config.GRAPHQL_URL), token);
699
+ setApps(list.filter((a) => a.id !== "yantra-notion"));
700
+ setError(null);
701
+ } catch (err) {
702
+ setError(serverErrorText(err));
703
+ }
704
+ })();
705
+ }, [visible]);
706
+ const q = query.trim().toLowerCase();
707
+ const shown = (apps != null ? apps : []).filter((a) => !q || `${a.title} ${a.id}`.toLowerCase().includes(q));
708
+ return /* @__PURE__ */ jsx(Modal, { visible, animationType: "slide", presentationStyle: "pageSheet", onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: [ui.flex, {
709
+ backgroundColor: palette.bg
710
+ }], children: [
711
+ /* @__PURE__ */ jsx(SheetHeader, { title: "Tools", onDone: onClose, palette }),
712
+ /* @__PURE__ */ jsxs(View, { style: [styles.search, {
713
+ backgroundColor: palette.fill
714
+ }], children: [
715
+ /* @__PURE__ */ jsx(Ionicons, { name: "search", size: 16, color: palette.textMuted }),
716
+ /* @__PURE__ */ jsx(TextInput, { value: query, onChangeText: setQuery, placeholder: "Find a connector", placeholderTextColor: palette.textFaint, autoCapitalize: "none", autoCorrect: false, style: [styles.searchInput, {
717
+ color: palette.text
718
+ }] })
719
+ ] }),
720
+ /* @__PURE__ */ jsxs(ScrollView, { contentContainerStyle: styles.sheetBody, keyboardShouldPersistTaps: "handled", children: [
721
+ error ? /* @__PURE__ */ jsx(Text, { style: [styles.note, {
722
+ color: palette.danger
723
+ }], children: error }) : null,
724
+ !apps && !error ? /* @__PURE__ */ jsx(ActivityIndicator, { color: palette.textMuted }) : null,
725
+ shown.map((a) => {
726
+ const on = selected.includes(a.id);
727
+ return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityState: {
728
+ selected: on
729
+ }, onPress: () => onToggle(a), style: ({
730
+ pressed
731
+ }) => [styles.pickRow, {
732
+ backgroundColor: pressed ? palette.pressed : palette.card
733
+ }], children: [
734
+ /* @__PURE__ */ jsx(Ionicons, { name: "extension-puzzle-outline", size: 17, color: palette.textMuted }),
735
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.pickRowText, {
736
+ color: palette.text
737
+ }], children: a.title && a.title !== a.id ? a.title : connectorDisplayName(a.id) }),
738
+ on ? /* @__PURE__ */ jsx(Ionicons, { name: "checkmark", size: 19, color: palette.primary }) : null
739
+ ] }, a.id);
740
+ })
741
+ ] })
742
+ ] }) });
743
+ }
744
+ const styles = StyleSheet.create({
745
+ panel: {
746
+ borderRadius: 16,
747
+ borderWidth: StyleSheet.hairlineWidth,
748
+ marginBottom: 14,
749
+ overflow: "hidden"
750
+ },
751
+ head: {
752
+ flexDirection: "row",
753
+ alignItems: "center",
754
+ gap: 12,
755
+ padding: 12
756
+ },
757
+ tile: {
758
+ width: 34,
759
+ height: 34,
760
+ borderRadius: 10,
761
+ alignItems: "center",
762
+ justifyContent: "center"
763
+ },
764
+ headTitle: {
765
+ fontSize: 16,
766
+ fontWeight: "700"
767
+ },
768
+ headSub: {
769
+ fontSize: 12,
770
+ marginTop: 1
771
+ },
772
+ section: {
773
+ paddingHorizontal: 12,
774
+ paddingVertical: 10,
775
+ gap: 8,
776
+ borderTopWidth: StyleSheet.hairlineWidth
777
+ },
778
+ sectionHead: {
779
+ flexDirection: "row",
780
+ alignItems: "center",
781
+ gap: 6
782
+ },
783
+ sectionLabel: {
784
+ fontSize: 12,
785
+ fontWeight: "700",
786
+ textTransform: "uppercase",
787
+ letterSpacing: 0.4
788
+ },
789
+ chips: {
790
+ flexDirection: "row",
791
+ flexWrap: "wrap",
792
+ gap: 6,
793
+ alignItems: "center"
794
+ },
795
+ chip: {
796
+ flexDirection: "row",
797
+ alignItems: "center",
798
+ gap: 5,
799
+ paddingHorizontal: 9,
800
+ height: 28,
801
+ borderRadius: 8,
802
+ maxWidth: 240
803
+ },
804
+ addChip: {
805
+ borderWidth: 1,
806
+ borderStyle: "dashed"
807
+ },
808
+ chipText: {
809
+ fontSize: 13,
810
+ fontWeight: "600",
811
+ flexShrink: 1
812
+ },
813
+ note: {
814
+ fontSize: 12,
815
+ lineHeight: 17
816
+ },
817
+ approval: {
818
+ flexDirection: "row",
819
+ alignItems: "center",
820
+ gap: 8,
821
+ padding: 10,
822
+ borderRadius: 10
823
+ },
824
+ approvalText: {
825
+ flex: 1,
826
+ fontSize: 12,
827
+ lineHeight: 17
828
+ },
829
+ link: {
830
+ fontSize: 14,
831
+ fontWeight: "700"
832
+ },
833
+ select: {
834
+ flexDirection: "row",
835
+ alignItems: "center",
836
+ gap: 6,
837
+ alignSelf: "flex-start",
838
+ paddingHorizontal: 10,
839
+ height: 32,
840
+ borderRadius: 9
841
+ },
842
+ selectText: {
843
+ fontSize: 14,
844
+ fontWeight: "600"
845
+ },
846
+ segmented: {
847
+ flexDirection: "row",
848
+ alignSelf: "flex-start",
849
+ borderRadius: 10,
850
+ padding: 2
851
+ },
852
+ segment: {
853
+ paddingHorizontal: 10,
854
+ height: 30,
855
+ borderRadius: 8,
856
+ justifyContent: "center"
857
+ },
858
+ segmentText: {
859
+ fontSize: 13,
860
+ fontWeight: "600"
861
+ },
862
+ runs: {
863
+ padding: 12,
864
+ gap: 8,
865
+ borderTopWidth: StyleSheet.hairlineWidth
866
+ },
867
+ runsHead: {
868
+ flexDirection: "row",
869
+ alignItems: "center",
870
+ gap: 10
871
+ },
872
+ runsTitle: {
873
+ flex: 1,
874
+ fontSize: 12,
875
+ fontWeight: "700",
876
+ textTransform: "uppercase",
877
+ letterSpacing: 0.4
878
+ },
879
+ runNow: {
880
+ flexDirection: "row",
881
+ alignItems: "center",
882
+ gap: 6,
883
+ paddingHorizontal: 12,
884
+ height: 32,
885
+ borderRadius: 10
886
+ },
887
+ runNowText: {
888
+ fontSize: 14,
889
+ fontWeight: "700"
890
+ },
891
+ runRow: {
892
+ flexDirection: "row",
893
+ alignItems: "center",
894
+ gap: 10,
895
+ paddingTop: 8,
896
+ borderTopWidth: StyleSheet.hairlineWidth
897
+ },
898
+ dot: {
899
+ width: 8,
900
+ height: 8,
901
+ borderRadius: 4
902
+ },
903
+ runLabel: {
904
+ fontSize: 14,
905
+ fontWeight: "600"
906
+ },
907
+ runSummary: {
908
+ fontSize: 12,
909
+ marginTop: 2
910
+ },
911
+ runAt: {
912
+ fontSize: 12
913
+ },
914
+ sheetBody: {
915
+ padding: 16,
916
+ gap: 10,
917
+ paddingBottom: 48
918
+ },
919
+ preview: {
920
+ fontSize: 20,
921
+ fontWeight: "800"
922
+ },
923
+ pick: {
924
+ paddingHorizontal: 12,
925
+ paddingVertical: 8,
926
+ borderRadius: 999
927
+ },
928
+ pickText: {
929
+ fontSize: 14,
930
+ fontWeight: "600"
931
+ },
932
+ steppers: {
933
+ flexDirection: "row",
934
+ gap: 16,
935
+ flexWrap: "wrap"
936
+ },
937
+ stepper: {
938
+ gap: 6
939
+ },
940
+ stepLabel: {
941
+ fontSize: 12,
942
+ fontWeight: "700"
943
+ },
944
+ stepBox: {
945
+ flexDirection: "row",
946
+ alignItems: "center",
947
+ gap: 14,
948
+ paddingHorizontal: 12,
949
+ height: 40,
950
+ borderRadius: 10
951
+ },
952
+ stepValue: {
953
+ fontSize: 17,
954
+ fontWeight: "700",
955
+ minWidth: 28,
956
+ textAlign: "center",
957
+ fontVariant: ["tabular-nums"]
958
+ },
959
+ search: {
960
+ flexDirection: "row",
961
+ alignItems: "center",
962
+ gap: 8,
963
+ margin: 16,
964
+ marginBottom: 0,
965
+ paddingHorizontal: 12,
966
+ height: 42,
967
+ borderRadius: 12
968
+ },
969
+ searchInput: {
970
+ flex: 1,
971
+ height: 42,
972
+ fontSize: 16,
973
+ paddingVertical: 0
974
+ },
975
+ pickRow: {
976
+ flexDirection: "row",
977
+ alignItems: "center",
978
+ gap: 10,
979
+ paddingHorizontal: 14,
980
+ minHeight: 50,
981
+ borderRadius: 12
982
+ },
983
+ pickRowText: {
984
+ flex: 1,
985
+ fontSize: 15
986
+ }
987
+ });export{NotionAgentPanel};//# sourceMappingURL=NotionAgentPanel.js.map