@adminide-stack/yantra-mobile 12.0.94 → 12.0.95-alpha.1

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 (151) hide show
  1. package/lib/compute.js +113 -1
  2. package/lib/compute.js.map +1 -1
  3. package/lib/features/agent-chat/NativeAgentChat.js +1 -1
  4. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  5. package/lib/features/apps/AppsCatalog.js +20 -0
  6. package/lib/features/apps/AppsCatalog.js.map +1 -1
  7. package/lib/features/apps/appArt.js +3 -1
  8. package/lib/features/apps/appArt.js.map +1 -1
  9. package/lib/features/apps/appFavorites.js +8 -2
  10. package/lib/features/apps/appFavorites.js.map +1 -1
  11. package/lib/features/apps/mobileAppCatalog.js +27 -1
  12. package/lib/features/apps/mobileAppCatalog.js.map +1 -1
  13. package/lib/features/canvas/VideoGeneratorExperience.js +1 -0
  14. package/lib/features/canvas/VideoGeneratorExperience.js.map +1 -1
  15. package/lib/features/canvas/sessionIdentity.js +8 -1
  16. package/lib/features/canvas/sessionIdentity.js.map +1 -1
  17. package/lib/features/canvas/useCanvasSession.js +1 -0
  18. package/lib/features/canvas/useCanvasSession.js.map +1 -1
  19. package/lib/features/canvas/videoEditor/remoteMediaClient.js +51 -24
  20. package/lib/features/canvas/videoEditor/remoteMediaClient.js.map +1 -1
  21. package/lib/features/chat/connectorConnect.js +1 -1
  22. package/lib/features/inbox/InboxAgentChatPane.js +64 -0
  23. package/lib/features/inbox/InboxAgentChatPane.js.map +1 -0
  24. package/lib/features/inbox/InboxExperience.js +631 -0
  25. package/lib/features/inbox/InboxExperience.js.map +1 -0
  26. package/lib/features/inbox/components/BottomSheet.js +111 -0
  27. package/lib/features/inbox/components/BottomSheet.js.map +1 -0
  28. package/lib/features/inbox/components/ComposeSheet.js +298 -0
  29. package/lib/features/inbox/components/ComposeSheet.js.map +1 -0
  30. package/lib/features/inbox/components/InboxStates.js +182 -0
  31. package/lib/features/inbox/components/InboxStates.js.map +1 -0
  32. package/lib/features/inbox/components/MailBody.js +103 -0
  33. package/lib/features/inbox/components/MailBody.js.map +1 -0
  34. package/lib/features/inbox/components/MessageReader.js +396 -0
  35. package/lib/features/inbox/components/MessageReader.js.map +1 -0
  36. package/lib/features/inbox/components/MessageRow.js +153 -0
  37. package/lib/features/inbox/components/MessageRow.js.map +1 -0
  38. package/lib/features/inbox/components/SenderAvatar.js +24 -0
  39. package/lib/features/inbox/components/SenderAvatar.js.map +1 -0
  40. package/lib/features/inbox/components/Tap.js +55 -0
  41. package/lib/features/inbox/components/Tap.js.map +1 -0
  42. package/lib/features/inbox/composeDraft.js +89 -0
  43. package/lib/features/inbox/composeDraft.js.map +1 -0
  44. package/lib/features/inbox/formatMailDate.js +60 -0
  45. package/lib/features/inbox/formatMailDate.js.map +1 -0
  46. package/lib/features/inbox/inboxAccounts.js +110 -0
  47. package/lib/features/inbox/inboxAccounts.js.map +1 -0
  48. package/lib/features/inbox/inboxClient.js +293 -0
  49. package/lib/features/inbox/inboxClient.js.map +1 -0
  50. package/lib/features/inbox/inboxContext.js +27 -0
  51. package/lib/features/inbox/inboxContext.js.map +1 -0
  52. package/lib/features/inbox/inboxFolders.js +47 -0
  53. package/lib/features/inbox/inboxFolders.js.map +1 -0
  54. package/lib/features/inbox/inboxNormalize.js +144 -0
  55. package/lib/features/inbox/inboxNormalize.js.map +1 -0
  56. package/lib/features/inbox/inboxPreference.js +20 -0
  57. package/lib/features/inbox/inboxPreference.js.map +1 -0
  58. package/lib/features/inbox/inboxTheme.js +54 -0
  59. package/lib/features/inbox/inboxTheme.js.map +1 -0
  60. package/lib/features/inbox/nativeInboxRegistry.js +15 -0
  61. package/lib/features/inbox/nativeInboxRegistry.js.map +1 -0
  62. package/lib/features/inbox/openAttachment.js +43 -0
  63. package/lib/features/inbox/openAttachment.js.map +1 -0
  64. package/lib/features/inbox/useInboxMailbox.js +250 -0
  65. package/lib/features/inbox/useInboxMailbox.js.map +1 -0
  66. package/lib/features/inbox/useMailMessage.js +101 -0
  67. package/lib/features/inbox/useMailMessage.js.map +1 -0
  68. package/lib/features/shopping/OrdersPanel.js +2 -2
  69. package/lib/features/shopping/OrdersPanel.js.map +1 -1
  70. package/lib/features/shopping/ProductCard.js +3 -3
  71. package/lib/features/shopping/ProductCard.js.map +1 -1
  72. package/lib/features/shopping/ProductDetailSheet.js +2 -2
  73. package/lib/features/shopping/ProductDetailSheet.js.map +1 -1
  74. package/lib/features/shopping/SavedPanel.js +2 -2
  75. package/lib/features/shopping/SavedPanel.js.map +1 -1
  76. package/lib/features/shopping/ShoppingExperience.js +46 -13
  77. package/lib/features/shopping/ShoppingExperience.js.map +1 -1
  78. package/lib/features/shopping/cartCloudSync.js +73 -0
  79. package/lib/features/shopping/cartCloudSync.js.map +1 -0
  80. package/lib/features/shopping/catalog.js +5 -1
  81. package/lib/features/shopping/catalog.js.map +1 -1
  82. package/lib/features/shopping/services/cartCloud.js +118 -0
  83. package/lib/features/shopping/services/cartCloud.js.map +1 -0
  84. package/lib/features/shopping/shoppingCart.js +17 -1
  85. package/lib/features/shopping/shoppingCart.js.map +1 -1
  86. package/lib/features/shopping/useCartCloudSync.js +33 -0
  87. package/lib/features/shopping/useCartCloudSync.js.map +1 -0
  88. package/lib/features/study/StudyAgentChatPane.js +67 -0
  89. package/lib/features/study/StudyAgentChatPane.js.map +1 -0
  90. package/lib/features/study/StudyExperience.js +586 -0
  91. package/lib/features/study/StudyExperience.js.map +1 -0
  92. package/lib/features/study/components/CellView.js +133 -0
  93. package/lib/features/study/components/CellView.js.map +1 -0
  94. package/lib/features/study/components/IntakeCard.js +203 -0
  95. package/lib/features/study/components/IntakeCard.js.map +1 -0
  96. package/lib/features/study/components/NotebookSwitcher.js +74 -0
  97. package/lib/features/study/components/NotebookSwitcher.js.map +1 -0
  98. package/lib/features/study/components/SourceStrip.js +69 -0
  99. package/lib/features/study/components/SourceStrip.js.map +1 -0
  100. package/lib/features/study/components/StudyComposer.js +118 -0
  101. package/lib/features/study/components/StudyComposer.js.map +1 -0
  102. package/lib/features/study/components/StudyOnboarding.js +477 -0
  103. package/lib/features/study/components/StudyOnboarding.js.map +1 -0
  104. package/lib/features/study/components/StudySheet.js +120 -0
  105. package/lib/features/study/components/StudySheet.js.map +1 -0
  106. package/lib/features/study/components/StudyStates.js +148 -0
  107. package/lib/features/study/components/StudyStates.js.map +1 -0
  108. package/lib/features/study/components/TextEntrySheet.js +111 -0
  109. package/lib/features/study/components/TextEntrySheet.js.map +1 -0
  110. package/lib/features/study/nativeStudyRegistry.js +15 -0
  111. package/lib/features/study/nativeStudyRegistry.js.map +1 -0
  112. package/lib/features/study/shareExport.js +38 -0
  113. package/lib/features/study/shareExport.js.map +1 -0
  114. package/lib/features/study/studyClient.js +278 -0
  115. package/lib/features/study/studyClient.js.map +1 -0
  116. package/lib/features/study/studyContext.js +25 -0
  117. package/lib/features/study/studyContext.js.map +1 -0
  118. package/lib/features/study/studyFiles.js +140 -0
  119. package/lib/features/study/studyFiles.js.map +1 -0
  120. package/lib/features/study/studyNormalize.js +116 -0
  121. package/lib/features/study/studyNormalize.js.map +1 -0
  122. package/lib/features/study/studyPreference.js +24 -0
  123. package/lib/features/study/studyPreference.js.map +1 -0
  124. package/lib/features/study/studyProfile.js +233 -0
  125. package/lib/features/study/studyProfile.js.map +1 -0
  126. package/lib/features/study/studyPrompts.js +78 -0
  127. package/lib/features/study/studyPrompts.js.map +1 -0
  128. package/lib/features/study/studyTheme.js +47 -0
  129. package/lib/features/study/studyTheme.js.map +1 -0
  130. package/lib/features/study/useStudyWorkspace.js +401 -0
  131. package/lib/features/study/useStudyWorkspace.js.map +1 -0
  132. package/lib/index.js +1 -1
  133. package/lib/index.js.map +1 -1
  134. package/lib/routes.json +108 -0
  135. package/lib/screens/InboxNative/index.js +77 -0
  136. package/lib/screens/InboxNative/index.js.map +1 -0
  137. package/lib/screens/InboxNative/useConnectMailbox.js +42 -0
  138. package/lib/screens/InboxNative/useConnectMailbox.js.map +1 -0
  139. package/lib/screens/InboxNative/useInboxHostChat.js +62 -0
  140. package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -0
  141. package/lib/screens/InboxNative/useMailAccounts.js +54 -0
  142. package/lib/screens/InboxNative/useMailAccounts.js.map +1 -0
  143. package/lib/screens/ShoppingNative/index.js +2 -1
  144. package/lib/screens/ShoppingNative/index.js.map +1 -1
  145. package/lib/screens/StudyNative/index.js +80 -0
  146. package/lib/screens/StudyNative/index.js.map +1 -0
  147. package/lib/screens/StudyNative/useStudyHostChat.js +62 -0
  148. package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -0
  149. package/lib/utils/authUserDisplay.js +11 -1
  150. package/lib/utils/authUserDisplay.js.map +1 -1
  151. package/package.json +4 -4
@@ -0,0 +1,586 @@
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMemo,useState,useEffect,useRef,useCallback}from'react';import {StyleSheet,BackHandler,View,ActivityIndicator,Text,KeyboardAvoidingView,FlatList,ScrollView,Platform,Clipboard,Linking,Keyboard}from'react-native';import {GestureHandlerRootView}from'react-native-gesture-handler';import {MaterialCommunityIcons}from'@expo/vector-icons';import ThinkingIndicator from'../../components/ThinkingIndicator.js';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {createRemoteConnectorExec}from'../canvas/videoEditor/remoteMediaClient.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {Tap,DIM}from'../inbox/components/Tap.js';import {StudyAgentChatPane}from'./StudyAgentChatPane.js';import {shareExport}from'./shareExport.js';import {createStudyClient}from'./studyClient.js';import {uploadStudyFile,pickStudyFiles}from'./studyFiles.js';import {useStudyProfile,buildTutorGreeting,buildProfilePromptSuffix}from'./studyProfile.js';import {TUTOR_SHORTCUTS,cellRole}from'./studyPrompts.js';import {DISPLAY_FONT,studyTheme}from'./studyTheme.js';import {useStudyWorkspace}from'./useStudyWorkspace.js';import {CellView,QuestionBubble}from'./components/CellView.js';import {IntakeCard}from'./components/IntakeCard.js';import {NotebookSwitcher}from'./components/NotebookSwitcher.js';import {SourceStrip,sourceIcon}from'./components/SourceStrip.js';import {StudyOnboarding,REVIEW_STEP}from'./components/StudyOnboarding.js';import {StudySheet,SheetRow}from'./components/StudySheet.js';import {StudyComposer}from'./components/StudyComposer.js';import {CenteredState,Toast,NoticeStrip}from'./components/StudyStates.js';import {TextEntrySheet}from'./components/TextEntrySheet.js';const TOAST_MS = 2600;
2
+ const TOP_ROW_HEIGHT = 48;
3
+ const CELL_SHEET_TITLE = {
4
+ ask: "Tutor answer",
5
+ note: "Note",
6
+ source: "Source"
7
+ };
8
+ const SOURCE_KIND_LABEL = {
9
+ url: "Web page",
10
+ document: "Document",
11
+ media: "Recording (transcribed)",
12
+ text: "Pasted text"
13
+ };
14
+ function countLine(sources, cells) {
15
+ const parts = [];
16
+ if (sources) parts.push(sources === 1 ? "1 source" : `${sources} sources`);
17
+ if (cells) parts.push(cells === 1 ? "1 entry" : `${cells} entries`);
18
+ return parts.join(" \xB7 ");
19
+ }
20
+ function sourcesToast(outcome) {
21
+ if (outcome.added.length === 1) return `Added ${outcome.added[0]}`;
22
+ if (outcome.added.length > 1) return `Added ${outcome.added.length} sources`;
23
+ return null;
24
+ }
25
+ function PendingTurn({
26
+ work,
27
+ theme
28
+ }) {
29
+ let label;
30
+ if (work.kind === "source") label = `Reading ${work.label}\u2026`;
31
+ else if (work.kind === "summarize") label = "Summarizing your notebook\u2026";
32
+ else if (work.kind === "create") label = "Starting your notebook\u2026";
33
+ else if (work.kind !== "ask") return null;
34
+ return /* @__PURE__ */ jsxs(View, { style: styles.pending, testID: "study-pending", children: [
35
+ work.kind === "ask" ? /* @__PURE__ */ jsx(QuestionBubble, { text: work.prompt, theme }) : null,
36
+ /* @__PURE__ */ jsx(ThinkingIndicator, { variant: "awaiting", color: theme.muted, isDark: theme.isDark, label })
37
+ ] });
38
+ }
39
+ function Greeting({
40
+ text,
41
+ theme
42
+ }) {
43
+ return /* @__PURE__ */ jsxs(View, { style: styles.greeting, children: [
44
+ /* @__PURE__ */ jsxs(View, { style: styles.answerHead, children: [
45
+ /* @__PURE__ */ jsx(Text, { style: styles.tutorEmoji, children: "\u{1F9D1}\u200D\u{1F3EB}" }),
46
+ /* @__PURE__ */ jsx(Text, { style: [styles.tutorLabel, {
47
+ color: theme.muted
48
+ }], children: "Your tutor" })
49
+ ] }),
50
+ /* @__PURE__ */ jsx(Text, { style: [styles.greetingText, {
51
+ color: theme.ink
52
+ }], children: text })
53
+ ] });
54
+ }
55
+ function StudyExperience({
56
+ isDark: hostIsDark,
57
+ token,
58
+ indexUrl,
59
+ sessionError,
60
+ onRetrySession,
61
+ orgName,
62
+ userFirstName,
63
+ onExit,
64
+ hostChat,
65
+ initialAgentSeed = null
66
+ }) {
67
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
68
+ const appTheme = useAppTheme();
69
+ const isDark = hostIsDark != null ? hostIsDark : appTheme.isDark;
70
+ const theme = useMemo(() => studyTheme(isDark), [isDark]);
71
+ const insets = useSafeInsets();
72
+ const scope = orgName != null ? orgName : "";
73
+ const client = useMemo(() => token ? createStudyClient(createRemoteConnectorExec(token, indexUrl)) : null, [token, indexUrl]);
74
+ const uploadFile = useMemo(() => token ? (file) => uploadStudyFile(token, indexUrl, file) : null, [token, indexUrl]);
75
+ const {
76
+ profile,
77
+ loaded: profileLoaded,
78
+ update: updateProfile
79
+ } = useStudyProfile(scope);
80
+ const [editingSetup, setEditingSetup] = useState(false);
81
+ useEffect(() => {
82
+ if (profileLoaded && !profile.onboardedAt && !profile.preferredName && userFirstName) {
83
+ updateProfile({
84
+ preferredName: userFirstName
85
+ });
86
+ }
87
+ }, [profileLoaded, profile.onboardedAt, profile.preferredName, userFirstName, updateProfile]);
88
+ const greeting = useMemo(() => buildTutorGreeting(profile), [profile]);
89
+ const promptSuffix = useMemo(() => buildProfilePromptSuffix(profile), [profile]);
90
+ const ws = useStudyWorkspace({
91
+ client,
92
+ scope,
93
+ uploadFile,
94
+ promptSuffix
95
+ });
96
+ const {
97
+ notebook,
98
+ work
99
+ } = ws;
100
+ const busy = work !== null;
101
+ const [switcherOpen, setSwitcherOpen] = useState(false);
102
+ const [addOpen, setAddOpen] = useState(false);
103
+ const [menuOpen, setMenuOpen] = useState(false);
104
+ const [confirmDelete, setConfirmDelete] = useState(false);
105
+ const [cellMenu, setCellMenu] = useState(null);
106
+ const [sourceMenu, setSourceMenu] = useState(null);
107
+ const [entry, setEntry] = useState(null);
108
+ const [agentOpen, setAgentOpen] = useState(Boolean(initialAgentSeed));
109
+ const [agentSeed, setAgentSeed] = useState(initialAgentSeed ? {
110
+ id: "initial",
111
+ text: initialAgentSeed.text
112
+ } : null);
113
+ const [notice, setNotice] = useState(null);
114
+ const [toast, setToast] = useState(null);
115
+ const toastTimer = useRef(null);
116
+ const showToast = useCallback((message) => {
117
+ if (toastTimer.current) clearTimeout(toastTimer.current);
118
+ setToast(message);
119
+ toastTimer.current = setTimeout(() => setToast(null), TOAST_MS);
120
+ }, []);
121
+ useEffect(() => () => {
122
+ if (toastTimer.current) clearTimeout(toastTimer.current);
123
+ }, []);
124
+ const askAgent = (text) => {
125
+ Keyboard.dismiss();
126
+ setAgentSeed({
127
+ id: `${Date.now()}`,
128
+ text
129
+ });
130
+ setAgentOpen(true);
131
+ };
132
+ const upload = async () => {
133
+ setAddOpen(false);
134
+ setNotice(null);
135
+ let files;
136
+ try {
137
+ files = await pickStudyFiles();
138
+ } catch (err) {
139
+ setNotice(err instanceof Error ? err.message : String(err));
140
+ return;
141
+ }
142
+ const outcome = await ws.addFiles(files);
143
+ if (!outcome) return;
144
+ if (outcome.failed.length) setNotice(outcome.failed.map((item) => item.reason).join("\n"));
145
+ const message = sourcesToast(outcome);
146
+ if (message) showToast(message);
147
+ };
148
+ const addLink = async (url) => {
149
+ setNotice(null);
150
+ const hadNotebook = Boolean(notebook);
151
+ const ok = await ws.addLink(url);
152
+ if (ok && hadNotebook) showToast("Added the page");
153
+ return ok;
154
+ };
155
+ const addText = async (text) => {
156
+ setNotice(null);
157
+ const hadNotebook = Boolean(notebook);
158
+ const ok = await ws.addText(text);
159
+ if (ok && hadNotebook) showToast("Added your text");
160
+ return ok;
161
+ };
162
+ const openEntry = (kind) => {
163
+ setAddOpen(false);
164
+ setNotice(null);
165
+ ws.dismissError();
166
+ if (kind === "link") {
167
+ setEntry({
168
+ title: "Add a link",
169
+ placeholder: "https://example.com/article",
170
+ submitLabel: "Add",
171
+ multiline: false,
172
+ keyboardType: "url",
173
+ onSubmit: addLink
174
+ });
175
+ } else if (kind === "text") {
176
+ setEntry({
177
+ title: "Paste text",
178
+ placeholder: "Paste your content here\u2026",
179
+ submitLabel: "Add",
180
+ onSubmit: addText
181
+ });
182
+ } else {
183
+ setEntry({
184
+ title: "Write a note",
185
+ placeholder: "A note in your own words (Markdown works)\u2026",
186
+ submitLabel: "Save",
187
+ onSubmit: ws.addNote
188
+ });
189
+ }
190
+ };
191
+ const runShortcut = (shortcut) => {
192
+ if (shortcut.kind === "summarize") void ws.summarize();
193
+ else void ws.ask(shortcut.prompt);
194
+ };
195
+ const exportPage = async () => {
196
+ setMenuOpen(false);
197
+ const page = await ws.exportNotebook();
198
+ if (!page) return;
199
+ try {
200
+ const outcome = await shareExport(page);
201
+ if (outcome === "saved") showToast("Saved the page");
202
+ } catch (err) {
203
+ setNotice(err instanceof Error ? err.message : "Could not share the page.");
204
+ }
205
+ };
206
+ const listRef = useRef(null);
207
+ const scrollIntent = useRef(null);
208
+ const seen = useRef({
209
+ id: null,
210
+ count: 0
211
+ });
212
+ const notebookId = (_a = notebook == null ? void 0 : notebook.id) != null ? _a : null;
213
+ const cellCount = (_b = notebook == null ? void 0 : notebook.cells.length) != null ? _b : 0;
214
+ useEffect(() => {
215
+ const prev = seen.current;
216
+ seen.current = {
217
+ id: notebookId,
218
+ count: cellCount
219
+ };
220
+ if (notebookId !== prev.id) scrollIntent.current = {
221
+ to: "end",
222
+ until: Date.now() + 1500
223
+ };
224
+ else if (cellCount > prev.count) scrollIntent.current = {
225
+ to: "index",
226
+ index: cellCount - 1
227
+ };
228
+ }, [notebookId, cellCount]);
229
+ useEffect(() => {
230
+ if (work) scrollIntent.current = {
231
+ to: "end",
232
+ until: Date.now() + 800
233
+ };
234
+ }, [work]);
235
+ const followScroll = () => {
236
+ const intent = scrollIntent.current;
237
+ const list = listRef.current;
238
+ if (!intent || !list) return;
239
+ if (intent.to === "end") {
240
+ if (Date.now() > intent.until) scrollIntent.current = null;
241
+ else list.scrollToEnd({
242
+ animated: false
243
+ });
244
+ return;
245
+ }
246
+ scrollIntent.current = null;
247
+ requestAnimationFrame(() => list.scrollToIndex({
248
+ index: intent.index,
249
+ viewPosition: 0,
250
+ animated: true
251
+ }));
252
+ };
253
+ useEffect(() => {
254
+ const sub = BackHandler.addEventListener("hardwareBackPress", () => {
255
+ if (entry) return false;
256
+ if (agentOpen) {
257
+ setAgentOpen(false);
258
+ return true;
259
+ }
260
+ if (editingSetup) {
261
+ setEditingSetup(false);
262
+ return true;
263
+ }
264
+ return false;
265
+ });
266
+ return () => sub.remove();
267
+ }, [entry, agentOpen, editingSetup]);
268
+ if (!profileLoaded) {
269
+ return /* @__PURE__ */ jsx(View, { style: [styles.fill, styles.loading, {
270
+ backgroundColor: theme.screen
271
+ }], testID: "study-panel", children: /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.muted }) });
272
+ }
273
+ if (!profile.onboardedAt || editingSetup) {
274
+ return /* @__PURE__ */ jsx(GestureHandlerRootView, { style: [styles.fill, {
275
+ backgroundColor: theme.screen
276
+ }], testID: "study-panel", children: /* @__PURE__ */ jsx(StudyOnboarding, { profile, theme, onChange: updateProfile, initialStep: editingSetup ? REVIEW_STEP : 1, onClose: editingSetup ? () => setEditingSetup(false) : void 0, onExit: editingSetup ? void 0 : onExit, onComplete: () => {
277
+ if (!profile.onboardedAt) updateProfile({
278
+ onboardedAt: (/* @__PURE__ */ new Date()).toISOString()
279
+ });
280
+ setEditingSetup(false);
281
+ } }) });
282
+ }
283
+ const hasMaterial = Boolean(notebook && (notebook.cells.length > 0 || notebook.sources.length > 0));
284
+ const waiting = !token || !ws.restored || ws.notebookPhase === "opening";
285
+ const errorText = (_d = notice != null ? notice : (_c = ws.error) == null ? void 0 : _c.message) != null ? _d : null;
286
+ const canRetry = !notice && Boolean(ws.retry) && ((_e = ws.error) == null ? void 0 : _e.kind) !== "timeout";
287
+ const noticeStrip = errorText ? /* @__PURE__ */ jsx(NoticeStrip, { message: errorText, theme, action: canRetry ? {
288
+ label: "Try again",
289
+ onPress: () => void ws.retryLast()
290
+ } : void 0, onDismiss: () => {
291
+ setNotice(null);
292
+ ws.dismissError();
293
+ } }) : null;
294
+ const titleText = (_f = notebook == null ? void 0 : notebook.title) != null ? _f : "Study";
295
+ let subtitle = null;
296
+ if (notebook) subtitle = countLine(notebook.sources.length, notebook.cells.length) || "New notebook";
297
+ else if (ws.notebooks.length) subtitle = "Pick a notebook or start one";
298
+ const body = (() => {
299
+ var _a2;
300
+ if (sessionError) {
301
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "cloud-alert", title: "Study could not sign in", body: sessionError, theme, primary: onRetrySession ? {
302
+ label: "Try again",
303
+ onPress: onRetrySession
304
+ } : void 0 });
305
+ }
306
+ if (waiting) {
307
+ return /* @__PURE__ */ jsx(View, { style: [styles.fill, styles.loading], children: /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.muted }) });
308
+ }
309
+ if (ws.notebookPhase === "error" && !notebook) {
310
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "notebook-remove-outline", title: "Could not open the notebook", body: (_a2 = ws.error) == null ? void 0 : _a2.message, theme, primary: {
311
+ label: "Start a new one",
312
+ onPress: ws.startNew
313
+ } });
314
+ }
315
+ return null;
316
+ })();
317
+ const composerPad = Math.max(insets.bottom, 10);
318
+ return /* @__PURE__ */ jsxs(GestureHandlerRootView, { style: [styles.fill, {
319
+ backgroundColor: theme.screen
320
+ }], testID: "study-panel", children: [
321
+ /* @__PURE__ */ jsxs(View, { style: [styles.topBar, {
322
+ paddingTop: insets.top + 4,
323
+ borderBottomColor: theme.border
324
+ }], children: [
325
+ /* @__PURE__ */ jsx(Tap, { onPress: onExit, hitSlop: 8, accessibilityRole: "button", accessibilityLabel: "Back", style: styles.iconButton, pressedStyle: DIM, testID: "study-exit", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-left", size: 30, color: theme.ink }) }),
326
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => setSwitcherOpen(true), disabled: busy || Boolean(sessionError), accessibilityRole: "button", accessibilityLabel: `${titleText}. Switch notebook`, style: styles.titleButton, pressedStyle: DIM, testID: "study-switcher-button", children: [
327
+ /* @__PURE__ */ jsxs(View, { style: styles.titleLine, children: [
328
+ /* @__PURE__ */ jsx(Text, { style: [styles.title, {
329
+ color: theme.ink
330
+ }], numberOfLines: 1, children: titleText }),
331
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-down", size: 18, color: theme.muted })
332
+ ] }),
333
+ subtitle ? /* @__PURE__ */ jsx(Text, { style: [styles.subtitle, {
334
+ color: theme.muted
335
+ }], numberOfLines: 1, children: subtitle }) : null
336
+ ] }),
337
+ /* @__PURE__ */ jsx(Tap, { onPress: () => setMenuOpen(true), hitSlop: 6, accessibilityRole: "button", accessibilityLabel: "Notebook options", style: [styles.ghostButton, {
338
+ backgroundColor: theme.chip
339
+ }], pressedStyle: DIM, testID: "study-menu", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "dots-horizontal", size: 20, color: theme.ink }) }),
340
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => {
341
+ setAgentSeed(null);
342
+ setAgentOpen(true);
343
+ }, accessibilityRole: "button", accessibilityLabel: "Open Study agent", style: [styles.agentChip, {
344
+ backgroundColor: theme.accent
345
+ }], pressedStyle: DIM, testID: "study-agent", children: [
346
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "creation", size: 17, color: theme.accentInk }),
347
+ /* @__PURE__ */ jsx(Text, { style: [styles.agentLabel, {
348
+ color: theme.accentInk
349
+ }], children: "Agent" })
350
+ ] })
351
+ ] }),
352
+ body != null ? body : /* @__PURE__ */ jsx(KeyboardAvoidingView, { style: styles.fill, behavior: Platform.OS === "ios" ? "padding" : void 0, keyboardVerticalOffset: 0, children: hasMaterial && notebook ? /* @__PURE__ */ jsxs(Fragment, { children: [
353
+ /* @__PURE__ */ jsx(SourceStrip, { sources: notebook.sources, theme, onOpen: setSourceMenu, onAdd: () => setAddOpen(true), disabled: busy }),
354
+ noticeStrip,
355
+ /* @__PURE__ */ jsx(FlatList, { ref: listRef, data: notebook.cells, keyExtractor: (cell) => cell.id, renderItem: ({
356
+ item
357
+ }) => /* @__PURE__ */ jsx(CellView, { cell: item, theme, onLongPress: setCellMenu }), ListHeaderComponent: /* @__PURE__ */ jsx(Greeting, { text: greeting, theme }), ListFooterComponent: work ? /* @__PURE__ */ jsx(PendingTurn, { work, theme }) : null, ItemSeparatorComponent: () => /* @__PURE__ */ jsx(View, { style: styles.separator }), contentContainerStyle: styles.feed, onContentSizeChange: followScroll, onScrollToIndexFailed: (info) => {
358
+ var _a2;
359
+ (_a2 = listRef.current) == null ? void 0 : _a2.scrollToOffset({
360
+ offset: info.averageItemLength * info.index,
361
+ animated: false
362
+ });
363
+ setTimeout(() => {
364
+ var _a3;
365
+ return (_a3 = listRef.current) == null ? void 0 : _a3.scrollToIndex({
366
+ index: info.index,
367
+ viewPosition: 0,
368
+ animated: true
369
+ });
370
+ }, 120);
371
+ }, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "interactive", initialNumToRender: 8, windowSize: 11, testID: "study-feed" }),
372
+ /* @__PURE__ */ jsx(StudyComposer, { theme, busy, shortcuts: busy ? [] : TUTOR_SHORTCUTS, placeholder: "Ask your tutor\u2026", bottomPad: composerPad, onAsk: ws.ask, onShortcut: runShortcut, onAdd: () => setAddOpen(true) })
373
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
374
+ /* @__PURE__ */ jsxs(ScrollView, { contentContainerStyle: styles.intakeScroll, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "on-drag", children: [
375
+ noticeStrip,
376
+ /* @__PURE__ */ jsx(Greeting, { text: greeting, theme }),
377
+ /* @__PURE__ */ jsx(IntakeCard, { theme, busy, busyLabel: (work == null ? void 0 : work.kind) === "source" ? work.label : null, onUpload: () => void upload(), onLink: addLink, onText: addText }),
378
+ (work == null ? void 0 : work.kind) === "ask" ? /* @__PURE__ */ jsx(PendingTurn, { work, theme }) : null
379
+ ] }),
380
+ /* @__PURE__ */ jsx(StudyComposer, { theme, busy, shortcuts: [], placeholder: "Or just ask your tutor anything\u2026", bottomPad: composerPad, onAsk: ws.ask, onShortcut: runShortcut, onAdd: () => setAddOpen(true) })
381
+ ] }) }),
382
+ toast ? /* @__PURE__ */ jsx(Toast, { message: toast, theme, bottom: composerPad + 120 }) : null,
383
+ /* @__PURE__ */ jsx(NotebookSwitcher, { visible: switcherOpen, notebooks: ws.notebooks, activeId: (_g = notebook == null ? void 0 : notebook.id) != null ? _g : null, loading: ws.libraryPhase === "loading", error: (_i = (_h = ws.libraryError) == null ? void 0 : _h.message) != null ? _i : null, theme, onPick: (id) => {
384
+ setSwitcherOpen(false);
385
+ setNotice(null);
386
+ if (id !== (notebook == null ? void 0 : notebook.id)) void ws.open(id);
387
+ }, onNew: () => {
388
+ setSwitcherOpen(false);
389
+ setNotice(null);
390
+ ws.startNew();
391
+ }, onRetry: () => void ws.refresh(), onClose: () => setSwitcherOpen(false) }),
392
+ /* @__PURE__ */ jsxs(StudySheet, { visible: addOpen, title: "Add to notebook", subtitle: "Your tutor answers from everything you add.", theme, onClose: () => setAddOpen(false), testID: "study-add-sheet", children: [
393
+ /* @__PURE__ */ jsx(SheetRow, { icon: "tray-arrow-up", label: "Upload files", detail: "PDF, Word, text, audio or video", onPress: () => void upload(), theme, testID: "study-add-upload" }),
394
+ /* @__PURE__ */ jsx(SheetRow, { icon: "link-variant", label: "Add a link", detail: "A web page or a hosted file", onPress: () => openEntry("link"), theme, testID: "study-add-link" }),
395
+ /* @__PURE__ */ jsx(SheetRow, { icon: "text-box-plus-outline", label: "Paste text", detail: "Notes, a chapter, a transcript", onPress: () => openEntry("text"), theme, testID: "study-add-text" }),
396
+ /* @__PURE__ */ jsx(SheetRow, { icon: "pencil-outline", label: "Write a note", detail: "Kept as your own words", onPress: () => openEntry("note"), theme, testID: "study-add-note" })
397
+ ] }),
398
+ /* @__PURE__ */ jsxs(StudySheet, { visible: menuOpen, title: (_j = notebook == null ? void 0 : notebook.title) != null ? _j : "Study", theme, onClose: () => setMenuOpen(false), testID: "study-menu-sheet", children: [
399
+ notebook ? /* @__PURE__ */ jsx(SheetRow, { icon: "export-variant", label: "Share as a page", detail: "The whole notebook as one web page", disabled: busy || !hasMaterial, onPress: () => void exportPage(), theme, testID: "study-export" }) : null,
400
+ notebook ? /* @__PURE__ */ jsx(SheetRow, { icon: "notebook-plus-outline", label: "New notebook", disabled: busy, onPress: () => {
401
+ setMenuOpen(false);
402
+ ws.startNew();
403
+ }, theme }) : null,
404
+ /* @__PURE__ */ jsx(SheetRow, { icon: "account-cog-outline", label: "Tutor setup", detail: "Name, study time, teaching style", onPress: () => {
405
+ setMenuOpen(false);
406
+ setEditingSetup(true);
407
+ }, theme, testID: "study-setup-edit" }),
408
+ notebook ? /* @__PURE__ */ jsx(SheetRow, { icon: "trash-can-outline", label: "Delete notebook", destructive: true, disabled: busy, onPress: () => {
409
+ setMenuOpen(false);
410
+ setConfirmDelete(true);
411
+ }, theme, testID: "study-delete" }) : null
412
+ ] }),
413
+ /* @__PURE__ */ jsxs(StudySheet, { visible: confirmDelete, title: notebook ? `Delete \u201C${notebook.title}\u201D?` : "", subtitle: "It disappears from Study everywhere you use it. This can't be undone.", theme, onClose: () => setConfirmDelete(false), testID: "study-confirm-delete", children: [
414
+ /* @__PURE__ */ jsx(SheetRow, { icon: "trash-can-outline", label: "Delete notebook", destructive: true, onPress: () => {
415
+ setConfirmDelete(false);
416
+ if (!notebook) return;
417
+ void ws.deleteNotebook(notebook.id).then((ok) => ok && showToast("Notebook deleted"));
418
+ }, theme, testID: "study-confirm-delete-yes" }),
419
+ /* @__PURE__ */ jsx(SheetRow, { icon: "close", label: "Keep it", onPress: () => setConfirmDelete(false), theme })
420
+ ] }),
421
+ /* @__PURE__ */ jsx(StudySheet, { visible: Boolean(cellMenu), title: cellMenu ? CELL_SHEET_TITLE[cellRole(cellMenu)] : "", theme, onClose: () => setCellMenu(null), testID: "study-cell-sheet", children: cellMenu ? /* @__PURE__ */ jsxs(Fragment, { children: [
422
+ /* @__PURE__ */ jsx(SheetRow, { icon: "content-copy", label: "Copy text", onPress: () => {
423
+ Clipboard.setString(cellMenu.content);
424
+ setCellMenu(null);
425
+ showToast("Copied");
426
+ }, theme }),
427
+ /* @__PURE__ */ jsx(SheetRow, { icon: "pencil-outline", label: "Edit", disabled: busy, onPress: () => {
428
+ const cell = cellMenu;
429
+ setCellMenu(null);
430
+ ws.dismissError();
431
+ setEntry({
432
+ title: "Edit",
433
+ placeholder: "Markdown works here\u2026",
434
+ submitLabel: "Save",
435
+ initial: cell.content,
436
+ onSubmit: (text) => ws.editCell(cell.id, text)
437
+ });
438
+ }, theme }),
439
+ /* @__PURE__ */ jsx(SheetRow, { icon: "creation", label: "Ask the agent about this", onPress: () => {
440
+ const excerpt = cellMenu.content.trim().slice(0, 1200);
441
+ setCellMenu(null);
442
+ askAgent(`Help me understand this part of my notebook:
443
+
444
+ ${excerpt}`);
445
+ }, theme }),
446
+ /* @__PURE__ */ jsx(SheetRow, { icon: "trash-can-outline", label: "Delete", destructive: true, disabled: busy, onPress: () => {
447
+ const cell = cellMenu;
448
+ setCellMenu(null);
449
+ void ws.deleteCell(cell.id).then((ok) => ok && showToast("Deleted"));
450
+ }, theme })
451
+ ] }) : null }),
452
+ /* @__PURE__ */ jsx(StudySheet, { visible: Boolean(sourceMenu), title: sourceMenu == null ? void 0 : sourceMenu.title, subtitle: sourceMenu ? [SOURCE_KIND_LABEL[sourceMenu.kind], sourceMenu.charCount ? `${sourceMenu.charCount.toLocaleString()} characters read` : "", sourceMenu.truncated ? "only the first part was kept" : ""].filter(Boolean).join(" \xB7 ") : void 0, theme, onClose: () => setSourceMenu(null), testID: "study-source-sheet", children: sourceMenu ? /* @__PURE__ */ jsxs(Fragment, { children: [
453
+ sourceMenu.kind === "url" && sourceMenu.origin ? /* @__PURE__ */ jsx(SheetRow, { icon: "open-in-new", label: "Open the page", detail: sourceMenu.origin, onPress: () => {
454
+ const {
455
+ origin
456
+ } = sourceMenu;
457
+ setSourceMenu(null);
458
+ if (origin) void Linking.openURL(origin).catch(() => void 0);
459
+ }, theme }) : null,
460
+ /* @__PURE__ */ jsx(SheetRow, { icon: sourceIcon(sourceMenu.kind), label: "Ask the tutor about it", disabled: busy, onPress: () => {
461
+ const {
462
+ title
463
+ } = sourceMenu;
464
+ setSourceMenu(null);
465
+ void ws.ask(`What are the key ideas in "${title}"? Give me the main points to master.`);
466
+ }, theme }),
467
+ /* @__PURE__ */ jsx(SheetRow, { icon: "trash-can-outline", label: "Remove source", detail: "Your tutor stops answering from it", destructive: true, disabled: busy, onPress: () => {
468
+ const source = sourceMenu;
469
+ setSourceMenu(null);
470
+ void ws.deleteSource(source.id).then((ok) => ok && showToast("Source removed"));
471
+ }, theme })
472
+ ] }) : null }),
473
+ entry ? /* @__PURE__ */ jsx(TextEntrySheet, { request: entry, theme, error: (_l = (_k = ws.error) == null ? void 0 : _k.message) != null ? _l : null, onClose: () => {
474
+ setEntry(null);
475
+ ws.dismissError();
476
+ } }) : null,
477
+ /* @__PURE__ */ jsx(StudyAgentChatPane, { visible: agentOpen, onClose: () => {
478
+ setAgentOpen(false);
479
+ setAgentSeed(null);
480
+ }, hostChat, notebook, orgName, seed: agentSeed, theme })
481
+ ] });
482
+ }
483
+ const styles = StyleSheet.create({
484
+ fill: {
485
+ flex: 1
486
+ },
487
+ loading: {
488
+ alignItems: "center",
489
+ justifyContent: "center"
490
+ },
491
+ topBar: {
492
+ flexDirection: "row",
493
+ alignItems: "center",
494
+ gap: 8,
495
+ paddingLeft: 4,
496
+ paddingRight: 12,
497
+ paddingBottom: 8,
498
+ minHeight: 52,
499
+ borderBottomWidth: StyleSheet.hairlineWidth
500
+ },
501
+ iconButton: {
502
+ width: 40,
503
+ height: 44,
504
+ alignItems: "center",
505
+ justifyContent: "center"
506
+ },
507
+ titleButton: {
508
+ flex: 1,
509
+ minWidth: 0,
510
+ height: TOP_ROW_HEIGHT,
511
+ justifyContent: "center"
512
+ },
513
+ titleLine: {
514
+ flexDirection: "row",
515
+ alignItems: "center",
516
+ gap: 2
517
+ },
518
+ title: {
519
+ flexShrink: 1,
520
+ fontSize: 21,
521
+ fontWeight: "600",
522
+ fontFamily: DISPLAY_FONT,
523
+ letterSpacing: -0.2
524
+ },
525
+ subtitle: {
526
+ fontSize: 13,
527
+ marginTop: 1
528
+ },
529
+ ghostButton: {
530
+ width: 38,
531
+ height: 38,
532
+ borderRadius: 19,
533
+ alignItems: "center",
534
+ justifyContent: "center"
535
+ },
536
+ agentChip: {
537
+ flexDirection: "row",
538
+ alignItems: "center",
539
+ gap: 6,
540
+ height: 38,
541
+ paddingHorizontal: 13,
542
+ borderRadius: 19
543
+ },
544
+ agentLabel: {
545
+ fontSize: 14,
546
+ fontWeight: "600"
547
+ },
548
+ feed: {
549
+ paddingHorizontal: 16,
550
+ paddingTop: 8,
551
+ paddingBottom: 20
552
+ },
553
+ separator: {
554
+ height: 18
555
+ },
556
+ greeting: {
557
+ paddingBottom: 18
558
+ },
559
+ answerHead: {
560
+ flexDirection: "row",
561
+ alignItems: "center",
562
+ gap: 6,
563
+ marginBottom: 4
564
+ },
565
+ tutorEmoji: {
566
+ fontSize: 14
567
+ },
568
+ tutorLabel: {
569
+ fontSize: 12,
570
+ fontWeight: "600",
571
+ letterSpacing: 0.3
572
+ },
573
+ greetingText: {
574
+ fontSize: 15,
575
+ lineHeight: 22
576
+ },
577
+ pending: {
578
+ gap: 10,
579
+ paddingTop: 18
580
+ },
581
+ intakeScroll: {
582
+ paddingHorizontal: 16,
583
+ paddingTop: 16,
584
+ paddingBottom: 24
585
+ }
586
+ });export{StudyExperience,StudyExperience as default};//# sourceMappingURL=StudyExperience.js.map