@adminide-stack/yantra-mobile 12.0.98 → 12.0.99-alpha.0

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 (173) hide show
  1. package/lib/bridge/handlers/SurfaceHostBridgeHandler.js +9 -2
  2. package/lib/bridge/handlers/SurfaceHostBridgeHandler.js.map +1 -1
  3. package/lib/compute.js +109 -1
  4. package/lib/compute.js.map +1 -1
  5. package/lib/config/env-config.js +11 -1
  6. package/lib/config/env-config.js.map +1 -1
  7. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  8. package/lib/features/apps/AppsCatalog.js +10 -0
  9. package/lib/features/apps/AppsCatalog.js.map +1 -1
  10. package/lib/features/apps/appArt.js +2 -1
  11. package/lib/features/apps/appArt.js.map +1 -1
  12. package/lib/features/apps/mobileAppCatalog.js +10 -0
  13. package/lib/features/apps/mobileAppCatalog.js.map +1 -1
  14. package/lib/features/apps/nativeAppHandoff.js +2 -1
  15. package/lib/features/apps/nativeAppHandoff.js.map +1 -1
  16. package/lib/features/apps/resolveSurfaceUrl.js +1 -2
  17. package/lib/features/apps/resolveSurfaceUrl.js.map +1 -1
  18. package/lib/features/attachments/useImageAttachments.js +8 -5
  19. package/lib/features/attachments/useImageAttachments.js.map +1 -1
  20. package/lib/features/chat/AssistantMarkdown.js +7 -6
  21. package/lib/features/chat/AssistantMarkdown.js.map +1 -1
  22. package/lib/features/chat/ChatTranscript.js +12 -2
  23. package/lib/features/chat/ChatTranscript.js.map +1 -1
  24. package/lib/features/devices/bleTransport.js +141 -0
  25. package/lib/features/devices/bleTransport.js.map +1 -0
  26. package/lib/features/devices/catalog.js +59 -0
  27. package/lib/features/devices/catalog.js.map +1 -0
  28. package/lib/features/devices/deviceStore.js +292 -0
  29. package/lib/features/devices/deviceStore.js.map +1 -0
  30. package/lib/features/devices/devices.js +68 -0
  31. package/lib/features/devices/devices.js.map +1 -0
  32. package/lib/features/devices/drivers.js +378 -0
  33. package/lib/features/devices/drivers.js.map +1 -0
  34. package/lib/features/devices/gatt/bytes.js +103 -0
  35. package/lib/features/devices/gatt/bytes.js.map +1 -0
  36. package/lib/features/devices/gatt/dateTime.js +23 -0
  37. package/lib/features/devices/gatt/dateTime.js.map +1 -0
  38. package/lib/features/devices/gatt/measurements.js +210 -0
  39. package/lib/features/devices/gatt/measurements.js.map +1 -0
  40. package/lib/features/devices/gatt/userData.js +57 -0
  41. package/lib/features/devices/gatt/userData.js.map +1 -0
  42. package/lib/features/devices/gatt/uuids.js +41 -0
  43. package/lib/features/devices/gatt/uuids.js.map +1 -0
  44. package/lib/features/devices/link.js +8 -0
  45. package/lib/features/devices/link.js.map +1 -0
  46. package/lib/features/devices/readings.js +158 -0
  47. package/lib/features/devices/readings.js.map +1 -0
  48. package/lib/features/devices/session.js +334 -0
  49. package/lib/features/devices/session.js.map +1 -0
  50. package/lib/features/expenses/ExpensesAgentChatPane.js +50 -0
  51. package/lib/features/expenses/ExpensesAgentChatPane.js.map +1 -0
  52. package/lib/features/expenses/ExpensesExperience.js +646 -0
  53. package/lib/features/expenses/ExpensesExperience.js.map +1 -0
  54. package/lib/features/expenses/claimFilters.js +94 -0
  55. package/lib/features/expenses/claimFilters.js.map +1 -0
  56. package/lib/features/expenses/components/AccountsPanel.js +464 -0
  57. package/lib/features/expenses/components/AccountsPanel.js.map +1 -0
  58. package/lib/features/expenses/components/BudgetsPanel.js +320 -0
  59. package/lib/features/expenses/components/BudgetsPanel.js.map +1 -0
  60. package/lib/features/expenses/components/CategoriesSheet.js +181 -0
  61. package/lib/features/expenses/components/CategoriesSheet.js.map +1 -0
  62. package/lib/features/expenses/components/ClaimDetail.js +309 -0
  63. package/lib/features/expenses/components/ClaimDetail.js.map +1 -0
  64. package/lib/features/expenses/components/ClaimForm.js +375 -0
  65. package/lib/features/expenses/components/ClaimForm.js.map +1 -0
  66. package/lib/features/expenses/components/ClaimRow.js +77 -0
  67. package/lib/features/expenses/components/ClaimRow.js.map +1 -0
  68. package/lib/features/expenses/components/ClaimsPanel.js +388 -0
  69. package/lib/features/expenses/components/ClaimsPanel.js.map +1 -0
  70. package/lib/features/expenses/components/DateSheet.js +214 -0
  71. package/lib/features/expenses/components/DateSheet.js.map +1 -0
  72. package/lib/features/expenses/components/ExpensesStates.js +274 -0
  73. package/lib/features/expenses/components/ExpensesStates.js.map +1 -0
  74. package/lib/features/expenses/components/ExpensesTabBar.js +83 -0
  75. package/lib/features/expenses/components/ExpensesTabBar.js.map +1 -0
  76. package/lib/features/expenses/components/FiltersSheet.js +137 -0
  77. package/lib/features/expenses/components/FiltersSheet.js.map +1 -0
  78. package/lib/features/expenses/components/InsightsPanel.js +362 -0
  79. package/lib/features/expenses/components/InsightsPanel.js.map +1 -0
  80. package/lib/features/expenses/components/RecurringPanel.js +370 -0
  81. package/lib/features/expenses/components/RecurringPanel.js.map +1 -0
  82. package/lib/features/expenses/components/Sheets.js +220 -0
  83. package/lib/features/expenses/components/Sheets.js.map +1 -0
  84. package/lib/features/expenses/components/ui.js +496 -0
  85. package/lib/features/expenses/components/ui.js.map +1 -0
  86. package/lib/features/expenses/expensesClient.js +398 -0
  87. package/lib/features/expenses/expensesClient.js.map +1 -0
  88. package/lib/features/expenses/expensesContext.js +30 -0
  89. package/lib/features/expenses/expensesContext.js.map +1 -0
  90. package/lib/features/expenses/expensesEndpoint.js +12 -0
  91. package/lib/features/expenses/expensesEndpoint.js.map +1 -0
  92. package/lib/features/expenses/expensesFormat.js +360 -0
  93. package/lib/features/expenses/expensesFormat.js.map +1 -0
  94. package/lib/features/expenses/expensesOperations.js +136 -0
  95. package/lib/features/expenses/expensesOperations.js.map +1 -0
  96. package/lib/features/expenses/expensesPrompts.js +81 -0
  97. package/lib/features/expenses/expensesPrompts.js.map +1 -0
  98. package/lib/features/expenses/expensesTheme.js +107 -0
  99. package/lib/features/expenses/expensesTheme.js.map +1 -0
  100. package/lib/features/expenses/nativeExpensesRegistry.js +15 -0
  101. package/lib/features/expenses/nativeExpensesRegistry.js.map +1 -0
  102. package/lib/features/expenses/receiptScan.js +242 -0
  103. package/lib/features/expenses/receiptScan.js.map +1 -0
  104. package/lib/features/expenses/useClaimsList.js +159 -0
  105. package/lib/features/expenses/useClaimsList.js.map +1 -0
  106. package/lib/features/expenses/useExpensesResource.js +68 -0
  107. package/lib/features/expenses/useExpensesResource.js.map +1 -0
  108. package/lib/features/health/HealthSyncRunner.js +24 -10
  109. package/lib/features/health/HealthSyncRunner.js.map +1 -1
  110. package/lib/features/health/buildDays.js +52 -5
  111. package/lib/features/health/buildDays.js.map +1 -1
  112. package/lib/features/health/fitnessClient.js +30 -3
  113. package/lib/features/health/fitnessClient.js.map +1 -1
  114. package/lib/features/health/healthConnectMapping.js +65 -2
  115. package/lib/features/health/healthConnectMapping.js.map +1 -1
  116. package/lib/features/health/healthConnectReader.js +23 -5
  117. package/lib/features/health/healthConnectReader.js.map +1 -1
  118. package/lib/features/health/healthConnectWriter.js +49 -0
  119. package/lib/features/health/healthConnectWriter.js.map +1 -0
  120. package/lib/features/health/healthkitMapping.js +58 -2
  121. package/lib/features/health/healthkitMapping.js.map +1 -1
  122. package/lib/features/health/healthkitReader.js +29 -7
  123. package/lib/features/health/healthkitReader.js.map +1 -1
  124. package/lib/features/health/healthkitWriter.js +55 -0
  125. package/lib/features/health/healthkitWriter.js.map +1 -0
  126. package/lib/features/health/model.js +8 -1
  127. package/lib/features/health/model.js.map +1 -1
  128. package/lib/features/health/ownSource.js +6 -0
  129. package/lib/features/health/ownSource.js.map +1 -0
  130. package/lib/features/health/reader.js +21 -0
  131. package/lib/features/health/reader.js.map +1 -1
  132. package/lib/features/health/types.js +15 -3
  133. package/lib/features/health/types.js.map +1 -1
  134. package/lib/features/health/writeMapping.js +218 -0
  135. package/lib/features/health/writeMapping.js.map +1 -0
  136. package/lib/features/links/ChatLinkOpenerProvider.js +56 -0
  137. package/lib/features/links/ChatLinkOpenerProvider.js.map +1 -0
  138. package/lib/features/links/chatLinkOpener.js +8 -0
  139. package/lib/features/links/chatLinkOpener.js.map +1 -0
  140. package/lib/features/links/openInApp.js +25 -0
  141. package/lib/features/links/openInApp.js.map +1 -0
  142. package/lib/features/messaging/ChatComponents.js +25 -6
  143. package/lib/features/messaging/ChatComponents.js.map +1 -1
  144. package/lib/features/messaging/LinkPreviewCard.js +103 -0
  145. package/lib/features/messaging/LinkPreviewCard.js.map +1 -0
  146. package/lib/features/messaging/NativeChatExperience.js +20 -7
  147. package/lib/features/messaging/NativeChatExperience.js.map +1 -1
  148. package/lib/features/messaging/ThreadScreen.js +4 -2
  149. package/lib/features/messaging/ThreadScreen.js.map +1 -1
  150. package/lib/features/messaging/chatLinks.js +64 -0
  151. package/lib/features/messaging/chatLinks.js.map +1 -0
  152. package/lib/features/messaging/linkPreview.js +64 -0
  153. package/lib/features/messaging/linkPreview.js.map +1 -0
  154. package/lib/index.js +1 -1
  155. package/lib/index.js.map +1 -1
  156. package/lib/routes.json +54 -0
  157. package/lib/screens/Account/index.js +39 -14
  158. package/lib/screens/Account/index.js.map +1 -1
  159. package/lib/screens/Chat/index.js +4 -3
  160. package/lib/screens/Chat/index.js.map +1 -1
  161. package/lib/screens/Devices/index.js +1055 -0
  162. package/lib/screens/Devices/index.js.map +1 -0
  163. package/lib/screens/ExpensesNative/index.js +98 -0
  164. package/lib/screens/ExpensesNative/index.js.map +1 -0
  165. package/lib/screens/ExpensesNative/useExpensesHostChat.js +63 -0
  166. package/lib/screens/ExpensesNative/useExpensesHostChat.js.map +1 -0
  167. package/lib/screens/Health/index.js +40 -7
  168. package/lib/screens/Health/index.js.map +1 -1
  169. package/lib/screens/WebBuilder/index.js +20 -0
  170. package/lib/screens/WebBuilder/index.js.map +1 -1
  171. package/lib/utils/hasNativeModule.js +9 -0
  172. package/lib/utils/hasNativeModule.js.map +1 -0
  173. package/package.json +5 -4
@@ -1,6 +1,7 @@
1
1
  import {classifyIntentViaBrain}from'../../services/brainQuickReply.js';const NATIVE_APP_ROUTES = {
2
2
  "local-services": "MainStack.LocalServicesNative",
3
- movies: "MainStack.MoviesNative"
3
+ movies: "MainStack.MoviesNative",
4
+ expenses: "MainStack.ExpensesNative"
4
5
  };
5
6
  const HANDOFF_MIN_CONFIDENCE = 0.8;
6
7
  const FOLLOWUP_HANDOFF_MIN_CONFIDENCE = 0.95;
@@ -1 +1 @@
1
- {"version":3,"file":"nativeAppHandoff.js","sources":["../../../src/features/apps/nativeAppHandoff.ts"],"sourcesContent":["/**\n * A typed ask the brain routes to an app that has a native screen here opens\n * that screen, with the ask handed to its agent.\n *\n * The decision is the brain's: the same `yantra-brain` classify the web chat\n * runs (`/resources/yantra-brain-classify`, whose intent ids are the web\n * registry's app ids), gated the way the web intent router gates it - a first\n * turn needs the app's ordinary bar, a follow-up in a conversation needs\n * near-certainty. Nothing here reads the words of the ask. Opening the screen\n * is nativeAppNavigation's job, kept apart so this stays free of navigation.\n */\nimport { classifyIntentViaBrain, type BrainIntent } from '../../services/brainQuickReply';\n\n/** Brain intent (web registry app id) -> the native screen that serves it on the phone. */\nexport const NATIVE_APP_ROUTES: Readonly<Record<string, string>> = {\n 'local-services': 'MainStack.LocalServicesNative',\n movies: 'MainStack.MoviesNative',\n};\n\n/** The web router's DEFAULT_MIN_CONFIDENCE and FOLLOWUP_MIN_CONFIDENCE (services/intentRouter.ts). */\nexport const HANDOFF_MIN_CONFIDENCE = 0.8;\nexport const FOLLOWUP_HANDOFF_MIN_CONFIDENCE = 0.95;\n\nconst CLASSIFY_TIMEOUT_MS = 2000;\nconst SHARED_FOR_MS = 30_000;\n\n/** The native route a classification opens, or null when it names no native app or is not sure enough. */\nexport function nativeHandoffRoute(intent: BrainIntent | null, opts: { followUp?: boolean } = {}): string | null {\n if (!intent) return null;\n const route = NATIVE_APP_ROUTES[intent.intent];\n if (!route || typeof intent.confidence !== 'number') return null;\n const bar = opts.followUp ? FOLLOWUP_HANDOFF_MIN_CONFIDENCE : HANDOFF_MIN_CONFIDENCE;\n return intent.confidence >= bar ? route : null;\n}\n\nconst shared = new Map<string, { at: number; verdict: Promise<BrainIntent | null> }>();\n\n/**\n * One brain classification per typed ask, shared by every hand-off check that\n * turn (Shop's and this one), so asking twice costs one request.\n */\nexport function classifyTypedAsk(text: string, now = Date.now()): Promise<BrainIntent | null> {\n const key = text.trim();\n if (!key) return Promise.resolve(null);\n for (const [k, entry] of shared) if (now - entry.at > SHARED_FOR_MS) shared.delete(k);\n const hit = shared.get(key);\n if (hit) return hit.verdict;\n const verdict = classifyIntentViaBrain(key, { timeoutMs: CLASSIFY_TIMEOUT_MS }).catch(() => null);\n const entry = { at: now, verdict };\n shared.set(key, entry);\n // A timeout or a failed call is not a verdict: the next check asks again.\n void verdict.then((answer) => {\n if (!answer && shared.get(key) === entry) shared.delete(key);\n });\n return verdict;\n}\n\n/** TEST-ONLY */\nexport function __resetTypedAskCache(): void {\n shared.clear();\n}\n\n/**\n * The native screen a typed ask belongs on, or null to keep it in chat. Build\n * and deep-search turns are modes the person chose, so they never leave chat.\n */\nexport async function resolveNativeHandoff(\n text: string,\n opts: { mode: 'chat' | 'deep-search' | 'build'; followUp?: boolean },\n): Promise<string | null> {\n if (opts.mode !== 'chat' || !text.trim()) return null;\n try {\n return nativeHandoffRoute(await classifyTypedAsk(text), { followUp: opts.followUp });\n } catch {\n return null;\n }\n}\n"],"names":["entry"],"mappings":"uEAcO,MAAM,iBAAsD,GAAA;AAAA,EACjE,gBAAkB,EAAA,+BAAA;AAAA,EAClB,MAAQ,EAAA;AACV;AAGO,MAAM,sBAAyB,GAAA;AAC/B,MAAM,+BAAkC,GAAA;AAC/C,MAAM,mBAAsB,GAAA,GAAA;AAC5B,MAAM,aAAgB,GAAA,GAAA;AAGf,SAAS,kBAAmB,CAAA,MAAA,EAA4B,IAE3D,GAAA,EAAmB,EAAA;AACrB,EAAI,IAAA,CAAC,QAAe,OAAA,IAAA;AACpB,EAAM,MAAA,KAAA,GAAQ,iBAAkB,CAAA,MAAA,CAAO,MAAM,CAAA;AAC7C,EAAA,IAAI,CAAC,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;AAWsB,eAAA,oBAAA,CAAqB,MAAc,IAG9B,EAAA;AACzB,EAAA,IAAI,KAAK,IAAS,KAAA,MAAA,IAAU,CAAC,IAAK,CAAA,IAAA,IAAe,OAAA,IAAA;AACjD,EAAI,IAAA;AACF,IAAA,OAAO,kBAAmB,CAAA,MAAM,gBAAiB,CAAA,IAAI,CAAG,EAAA;AAAA,MACtD,UAAU,IAAK,CAAA;AAAA,KAChB,CAAA;AAAA,GACK,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,IAAA;AAAA;AAEX"}
1
+ {"version":3,"file":"nativeAppHandoff.js","sources":["../../../src/features/apps/nativeAppHandoff.ts"],"sourcesContent":["/**\n * A typed ask the brain routes to an app that has a native screen here opens\n * that screen, with the ask handed to its agent.\n *\n * The decision is the brain's: the same `yantra-brain` classify the web chat\n * runs (`/resources/yantra-brain-classify`, whose intent ids are the web\n * registry's app ids), gated the way the web intent router gates it - a first\n * turn needs the app's ordinary bar, a follow-up in a conversation needs\n * near-certainty. Nothing here reads the words of the ask. Opening the screen\n * is nativeAppNavigation's job, kept apart so this stays free of navigation.\n */\nimport { classifyIntentViaBrain, type BrainIntent } from '../../services/brainQuickReply';\n\n/** Brain intent (web registry app id) -> the native screen that serves it on the phone. */\nexport const NATIVE_APP_ROUTES: Readonly<Record<string, string>> = {\n 'local-services': 'MainStack.LocalServicesNative',\n movies: 'MainStack.MoviesNative',\n expenses: 'MainStack.ExpensesNative',\n};\n\n/** The web router's DEFAULT_MIN_CONFIDENCE and FOLLOWUP_MIN_CONFIDENCE (services/intentRouter.ts). */\nexport const HANDOFF_MIN_CONFIDENCE = 0.8;\nexport const FOLLOWUP_HANDOFF_MIN_CONFIDENCE = 0.95;\n\nconst CLASSIFY_TIMEOUT_MS = 2000;\nconst SHARED_FOR_MS = 30_000;\n\n/** The native route a classification opens, or null when it names no native app or is not sure enough. */\nexport function nativeHandoffRoute(intent: BrainIntent | null, opts: { followUp?: boolean } = {}): string | null {\n if (!intent) return null;\n const route = NATIVE_APP_ROUTES[intent.intent];\n if (!route || typeof intent.confidence !== 'number') return null;\n const bar = opts.followUp ? FOLLOWUP_HANDOFF_MIN_CONFIDENCE : HANDOFF_MIN_CONFIDENCE;\n return intent.confidence >= bar ? route : null;\n}\n\nconst shared = new Map<string, { at: number; verdict: Promise<BrainIntent | null> }>();\n\n/**\n * One brain classification per typed ask, shared by every hand-off check that\n * turn (Shop's and this one), so asking twice costs one request.\n */\nexport function classifyTypedAsk(text: string, now = Date.now()): Promise<BrainIntent | null> {\n const key = text.trim();\n if (!key) return Promise.resolve(null);\n for (const [k, entry] of shared) if (now - entry.at > SHARED_FOR_MS) shared.delete(k);\n const hit = shared.get(key);\n if (hit) return hit.verdict;\n const verdict = classifyIntentViaBrain(key, { timeoutMs: CLASSIFY_TIMEOUT_MS }).catch(() => null);\n const entry = { at: now, verdict };\n shared.set(key, entry);\n // A timeout or a failed call is not a verdict: the next check asks again.\n void verdict.then((answer) => {\n if (!answer && shared.get(key) === entry) shared.delete(key);\n });\n return verdict;\n}\n\n/** TEST-ONLY */\nexport function __resetTypedAskCache(): void {\n shared.clear();\n}\n\n/**\n * The native screen a typed ask belongs on, or null to keep it in chat. Build\n * and deep-search turns are modes the person chose, so they never leave chat.\n */\nexport async function resolveNativeHandoff(\n text: string,\n opts: { mode: 'chat' | 'deep-search' | 'build'; followUp?: boolean },\n): Promise<string | null> {\n if (opts.mode !== 'chat' || !text.trim()) return null;\n try {\n return nativeHandoffRoute(await classifyTypedAsk(text), { followUp: opts.followUp });\n } catch {\n return null;\n }\n}\n"],"names":["entry"],"mappings":"uEAcO,MAAM,iBAAsD,GAAA;AAAA,EACjE,gBAAkB,EAAA,+BAAA;AAAA,EAClB,MAAQ,EAAA,wBAAA;AAAA,EACR,QAAU,EAAA;AACZ;AAGO,MAAM,sBAAyB,GAAA;AAC/B,MAAM,+BAAkC,GAAA;AAC/C,MAAM,mBAAsB,GAAA,GAAA;AAC5B,MAAM,aAAgB,GAAA,GAAA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OAAA,CAAQ,KAAK,CAAU,MAAA,KAAA;AAC1B,IAAI,IAAA,CAAC,UAAU,MAAO,CAAA,GAAA,CAAI,GAAG,CAAM,KAAA,KAAA,EAAc,MAAA,CAAA,MAAA,CAAO,GAAG,CAAA;AAAA,GAC5D,CAAA;AACD,EAAO,OAAA,OAAA;AACT;AAWsB,eAAA,oBAAA,CAAqB,MAAc,IAG9B,EAAA;AACzB,EAAA,IAAI,KAAK,IAAS,KAAA,MAAA,IAAU,CAAC,IAAK,CAAA,IAAA,IAAe,OAAA,IAAA;AACjD,EAAI,IAAA;AACF,IAAA,OAAO,kBAAmB,CAAA,MAAM,gBAAiB,CAAA,IAAI,CAAG,EAAA;AAAA,MACtD,UAAU,IAAK,CAAA;AAAA,KAChB,CAAA;AAAA,GACK,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,IAAA;AAAA;AAEX"}
@@ -25,8 +25,7 @@ function resolveAppTitleFromSurfaceUrl(url, config) {
25
25
  if (!needle) return null;
26
26
  for (const app of MOBILE_APP_CATALOG) {
27
27
  const surface = resolveSurfaceUrl(app, config);
28
- if (!surface) continue;
29
- if (originKey(surface) === needle) return app.label;
28
+ if (surface && originKey(surface) === needle) return app.label;
30
29
  }
31
30
  return null;
32
31
  }export{resolveAppTitleFromSurfaceUrl,resolveSurfaceUrl};//# sourceMappingURL=resolveSurfaceUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveSurfaceUrl.js","sources":["../../../src/features/apps/resolveSurfaceUrl.ts"],"sourcesContent":["/**\n * Which URL the shared WebView surface shell should open for a launcher tile.\n *\n * Explicit env key wins (the surfaces with a dedicated var, which are the\n * ones run locally), then the `{slug}` template that covers every deployed\n * surface. Returning undefined means \"no surface\" — the caller falls back to\n * seeding the tile's chat prompt, which is what every tile did before.\n */\nimport type { MobileAppItem } from './mobileAppCatalog';\nimport { MOBILE_APP_CATALOG } from './mobileAppCatalog';\n\nexport interface SurfaceUrlConfig {\n WEB_BUILDER_URL?: string;\n CANVAS_SURFACE_URL?: string;\n DESIGN_SURFACE_URL?: string;\n SURFACE_URL_TEMPLATE?: string;\n}\n\nexport function resolveSurfaceUrl(app: MobileAppItem, config: SurfaceUrlConfig): string | undefined {\n // Only the shared WebView shell needs a URL - a tile with its own native\n // screen (nativeRoute 'canvas-native') resolves nothing by design.\n if (app.nativeRoute !== 'webbuilder') return undefined;\n\n if (app.surfaceUrlKey) {\n const explicit = config[app.surfaceUrlKey]?.trim();\n\n if (explicit) return explicit;\n }\n\n const template = config.SURFACE_URL_TEMPLATE?.trim();\n\n if (!template || !app.surfaceSlug) return undefined;\n // A template without the placeholder would silently point every surface at\n // the same origin, which is worse than opening none.\n if (!template.includes('{slug}')) return undefined;\n\n return template.replace(/\\{slug\\}/g, app.surfaceSlug);\n}\n\nfunction originKey(url: string): string | null {\n try {\n const parsed = new URL(url);\n return `${parsed.protocol}//${parsed.host}`.toLowerCase();\n } catch {\n const trimmed = url.trim().replace(/\\/+$/, '');\n return trimmed ? trimmed.toLowerCase() : null;\n }\n}\n\n/**\n * Header title for the shared WebView shell. Matches the launcher tile whose\n * surface URL is this origin (Canvas, Design, …) instead of always \"Web Builder\".\n */\nexport function resolveAppTitleFromSurfaceUrl(url: string | null | undefined, config: SurfaceUrlConfig): string | null {\n if (typeof url !== 'string' || !url.trim()) return null;\n const needle = originKey(url);\n if (!needle) return null;\n\n for (const app of MOBILE_APP_CATALOG) {\n const surface = resolveSurfaceUrl(app, config);\n if (!surface) continue;\n if (originKey(surface) === needle) return app.label;\n }\n return null;\n}\n"],"names":[],"mappings":"uDAgBgB,SAAA,iBAAA,CAAkB,KAAoB,MAA8C,EAAA;AAhBpG,EAAA,IAAA,EAAA,EAAA,EAAA;AAmBE,EAAI,IAAA,GAAA,CAAI,WAAgB,KAAA,YAAA,EAAqB,OAAA,MAAA;AAC7C,EAAA,IAAI,IAAI,aAAe,EAAA;AACrB,IAAA,MAAM,QAAW,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,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A,IAAI,CAAC,OAAS,EAAA;AACd,IAAA,IAAI,SAAU,CAAA,OAAO,CAAM,KAAA,MAAA,SAAe,GAAI,CAAA,KAAA;AAAA;AAEhD,EAAO,OAAA,IAAA;AACT"}
1
+ {"version":3,"file":"resolveSurfaceUrl.js","sources":["../../../src/features/apps/resolveSurfaceUrl.ts"],"sourcesContent":["/**\n * Which URL the shared WebView surface shell should open for a launcher tile.\n *\n * Explicit env key wins (the surfaces with a dedicated var, which are the\n * ones run locally), then the `{slug}` template that covers every deployed\n * surface. Returning undefined means \"no surface\" — the caller falls back to\n * seeding the tile's chat prompt, which is what every tile did before.\n */\nimport type { MobileAppItem } from './mobileAppCatalog';\nimport { MOBILE_APP_CATALOG } from './mobileAppCatalog';\n\nexport interface SurfaceUrlConfig {\n WEB_BUILDER_URL?: string;\n CANVAS_SURFACE_URL?: string;\n DESIGN_SURFACE_URL?: string;\n SURFACE_URL_TEMPLATE?: string;\n}\n\nexport function resolveSurfaceUrl(app: MobileAppItem, config: SurfaceUrlConfig): string | undefined {\n // Only the shared WebView shell needs a URL - a tile with its own native\n // screen (nativeRoute 'canvas-native') resolves nothing by design.\n if (app.nativeRoute !== 'webbuilder') return undefined;\n\n if (app.surfaceUrlKey) {\n const explicit = config[app.surfaceUrlKey]?.trim();\n\n if (explicit) return explicit;\n }\n\n const template = config.SURFACE_URL_TEMPLATE?.trim();\n\n if (!template || !app.surfaceSlug) return undefined;\n // A template without the placeholder would silently point every surface at\n // the same origin, which is worse than opening none.\n if (!template.includes('{slug}')) return undefined;\n\n return template.replace(/\\{slug\\}/g, app.surfaceSlug);\n}\n\nfunction originKey(url: string): string | null {\n try {\n const parsed = new URL(url);\n return `${parsed.protocol}//${parsed.host}`.toLowerCase();\n } catch {\n const trimmed = url.trim().replace(/\\/+$/, '');\n return trimmed ? trimmed.toLowerCase() : null;\n }\n}\n\n/**\n * Header title for the shared WebView shell. Matches the launcher tile whose\n * surface URL is this origin (Canvas, Design, …) instead of always \"Web Builder\".\n */\nexport function resolveAppTitleFromSurfaceUrl(url: string | null | undefined, config: SurfaceUrlConfig): string | null {\n if (typeof url !== 'string' || !url.trim()) return null;\n const needle = originKey(url);\n if (!needle) return null;\n\n for (const app of MOBILE_APP_CATALOG) {\n const surface = resolveSurfaceUrl(app, config);\n if (surface && originKey(surface) === needle) return app.label;\n }\n return null;\n}\n"],"names":[],"mappings":"uDAgBgB,SAAA,iBAAA,CAAkB,KAAoB,MAA8C,EAAA;AAhBpG,EAAA,IAAA,EAAA,EAAA,EAAA;AAmBE,EAAI,IAAA,GAAA,CAAI,WAAgB,KAAA,YAAA,EAAqB,OAAA,MAAA;AAC7C,EAAA,IAAI,IAAI,aAAe,EAAA;AACrB,IAAA,MAAM,QAAW,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,GAAI,CAAA,aAAa,MAAxB,IAA2B,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,EAAA;AAC5C,IAAA,IAAI,UAAiB,OAAA,QAAA;AAAA;AAEvB,EAAM,MAAA,QAAA,GAAA,CAAW,EAAO,GAAA,MAAA,CAAA,oBAAA,KAAP,IAA6B,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,EAAA;AAC9C,EAAA,IAAI,CAAC,QAAA,IAAY,CAAC,GAAA,CAAI,aAAoB,OAAA,MAAA;AAG1C,EAAA,IAAI,CAAC,QAAA,CAAS,QAAS,CAAA,QAAQ,GAAU,OAAA,MAAA;AACzC,EAAA,OAAO,QAAS,CAAA,OAAA,CAAQ,WAAa,EAAA,GAAA,CAAI,WAAW,CAAA;AACtD;AACA,SAAS,UAAU,GAA4B,EAAA;AAC7C,EAAI,IAAA;AACF,IAAM,MAAA,MAAA,GAAS,IAAI,GAAA,CAAI,GAAG,CAAA;AAC1B,IAAA,OAAO,GAAG,MAAO,CAAA,QAAQ,KAAK,MAAO,CAAA,IAAI,GAAG,WAAY,EAAA;AAAA,GAClD,CAAA,OAAA,CAAA,EAAA;AACN,IAAA,MAAM,UAAU,GAAI,CAAA,IAAA,EAAO,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAC7C,IAAO,OAAA,OAAA,GAAU,OAAQ,CAAA,WAAA,EAAgB,GAAA,IAAA;AAAA;AAE7C;AAMgB,SAAA,6BAAA,CAA8B,KAAgC,MAAyC,EAAA;AACrH,EAAA,IAAI,OAAO,GAAQ,KAAA,QAAA,IAAY,CAAC,GAAI,CAAA,IAAA,IAAe,OAAA,IAAA;AACnD,EAAM,MAAA,MAAA,GAAS,UAAU,GAAG,CAAA;AAC5B,EAAI,IAAA,CAAC,QAAe,OAAA,IAAA;AACpB,EAAA,KAAA,MAAW,OAAO,kBAAoB,EAAA;AACpC,IAAM,MAAA,OAAA,GAAU,iBAAkB,CAAA,GAAA,EAAK,MAAM,CAAA;AAC7C,IAAA,IAAI,WAAW,SAAU,CAAA,OAAO,CAAM,KAAA,MAAA,SAAe,GAAI,CAAA,KAAA;AAAA;AAE3D,EAAO,OAAA,IAAA;AACT"}
@@ -1,4 +1,4 @@
1
- import {useState,useCallback,useMemo}from'react';var __defProp = Object.defineProperty;
1
+ import {useState,useCallback,useMemo}from'react';import {hasNativeModule}from'../../utils/hasNativeModule.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -38,7 +38,9 @@ const SHRINK_PASSES = [{
38
38
  const MAX_PENDING_BYTES = 32 * 1024 * 1024;
39
39
  const MIN_BYTES = 64;
40
40
  function base64Bytes(base64) {
41
- const padding = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0;
41
+ let padding = 0;
42
+ if (base64.endsWith("==")) padding = 2;
43
+ else if (base64.endsWith("=")) padding = 1;
42
44
  return Math.floor(base64.length * 3 / 4) - padding;
43
45
  }
44
46
  function isJpegRepresentationError(err) {
@@ -62,6 +64,9 @@ function guessImageMime(asset) {
62
64
  if (/\.(heic|heif)(\?|$)/i.test(name)) return "image/heic";
63
65
  return "image/jpeg";
64
66
  }
67
+ function loadFileSystem() {
68
+ return require("expo-file-system");
69
+ }
65
70
  async function readUriBase64(uri) {
66
71
  var _a, _b;
67
72
  const fs = loadFileSystem();
@@ -73,6 +78,7 @@ async function readUriBase64(uri) {
73
78
  return base64 || null;
74
79
  }
75
80
  function loadImageManipulator() {
81
+ if (!hasNativeModule("ExpoImageManipulator")) return null;
76
82
  try {
77
83
  return require("expo-image-manipulator");
78
84
  } catch (e) {
@@ -271,9 +277,6 @@ function loadDocumentPicker() {
271
277
  throw err;
272
278
  }
273
279
  }
274
- function loadFileSystem() {
275
- return require("expo-file-system");
276
- }
277
280
  const DOCUMENT_MIME_TYPES = ["application/pdf", "text/plain", "text/markdown", "text/csv", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "image/*"];
278
281
  const MAX_FILES = 8;
279
282
  const MAX_DOCUMENT_BYTES = 25 * 1024 * 1024;
@@ -1 +1 @@
1
- {"version":3,"file":"useImageAttachments.js","sources":["../../../src/features/attachments/useImageAttachments.ts"],"sourcesContent":["/**\n * Image attachments for the native composer.\n *\n * The transport was already there — `useChatStream.sendMessage(content,\n * attachments)` carries `MessageAttachment[]` and the gateway media lane is\n * covered by `aiwork/e2e-tests/gateway-media-upload.spec.ts`. What was missing\n * was any way to produce one on a phone: the composer shipped with\n * `image`/`camera`/`attach` hard-disabled, and nothing in the mobile package\n * touched `expo-image-picker` even though it is a dependency and the photo and\n * camera permission strings are already declared in `app.json`.\n *\n * Payload size is the whole game here. A modern iPhone photo is ~3-5 MB and\n * ~4000px wide; base64 inflates that by a third, and it travels inline on the\n * chat message. Camera captures can be JPEG-compressed via `quality`. Library\n * picks must NOT pass `quality`: that asks iOS for `public.jpeg` and fails on\n * HEIC / iCloud photos with \"Cannot load representation of type public.jpeg\".\n * The canvas picker already uses `Current` for that reason.\n *\n * `MAX_EDGE` is not our invention, it is the resize the models apply anyway.\n * Claude keeps 2576px on the long edge (4.7+ high-resolution tier, 1568px on\n * older models) and downscales everything above it before it ever sees the\n * image; OpenAI caps the long edge at 2000px. So a 4032px capture spends 3x\n * the bytes on pixels that are thrown away upstream. Downscaling on the device\n * is free fidelity-wise and is what keeps us clear of every byte ceiling in\n * the chain: measured on real 12MP iPhone photos, 2.9MB -> 1.4MB.\n *\n * The resize is therefore what decides whether a photo can be attached at all,\n * not the byte ceiling - so it triggers on bytes as well as pixels (a 2000px\n * PNG screenshot is inside `MAX_EDGE` and can still be 12MB) and keeps\n * tightening until it fits rather than giving up.\n *\n * The contract this file owes a person: hand it anything a phone can produce,\n * up to `MAX_SOURCE_BYTES`, and sizing is our problem, not theirs. Nobody\n * should be told to go find a smaller photo. That means shrinking is attempted\n * before any ceiling is consulted, and the only refusals left are \"bigger than\n * we will even open\" and \"this build has no resizer and the raw bytes cannot\n * fit inline\" - the second disappears once `expo-image-manipulator` is in the\n * binary.\n */\nimport { useCallback, useMemo, useState } from 'react';\nimport type { MessageAttachment } from '../../hooks/useChatStream';\n\n/** Longest edge, in px, we send. Matches Claude's high-resolution tier ceiling. */\nconst MAX_EDGE = 2576;\n/**\n * Long edge for a second, tighter pass when one resize still will not fit.\n * Claude's standard tier, so every model keeps all of it.\n */\nconst FALLBACK_EDGE = 1568;\n/** JPEG quality handed to the picker for a camera capture (0-1). */\nconst PICKER_QUALITY = 0.7;\n/**\n * JPEG quality for our own re-encode. Higher than the picker's: a 2576px frame\n * is already small, and the camera's headline use per `app.json` is \"a photo of\n * a document you want help with\" - text is the first thing heavy JPEG\n * compression destroys.\n */\nconst RESIZE_QUALITY = 0.8;\n/** Harder compress for the second pass. Still readable; the point is to fit. */\nconst FALLBACK_QUALITY = 0.6;\n/**\n * What one image should weigh by the time it is on the wire. This is not our\n * number: an image turn always takes the inline-bytes lane (`useChatStream`\n * sends `buildGatewayMedia(..., includeData)` whenever any attachment is an\n * image), and cdecli's resolver drops anything heavier - `chat_media.go`\n * `defaultChatMediaLimits` is 5MB per image and 8 images, tunable with\n * `CDECLI_CHAT_MAX_IMAGE_BYTES` / `CDECLI_CHAT_MAX_IMAGES`. Raising the number\n * here alone would not make a bigger photo arrive.\n */\nconst TARGET_BYTES = 5 * 1024 * 1024;\n/**\n * Absolute ceiling for bytes travelling inline, which is every image turn and\n * any document sharing one. `buildGatewayMedia`'s inline cap is 14e6 base64\n * chars, so ~10MB decoded is the most that can survive the trip. Only reached\n * when nothing shrank the image.\n */\nconst MAX_INLINE_BYTES = 10 * 1024 * 1024;\n/**\n * What a person is allowed to hand us. Deliberately far above anything a phone\n * camera produces (a 48MP JPEG is ~10MB, an iPhone ProRAW ~25MB) so that taking\n * a picture and attaching it never involves thinking about bytes. Everything up\n * to here is ours to shrink. Above it we refuse rather than pull the file into\n * a JS string, because that is how a memory-tight phone loses the app mid-pick.\n */\nconst MAX_SOURCE_BYTES = 50 * 1024 * 1024;\n/**\n * Tried in order until one lands under `TARGET_BYTES`. Three passes take even a\n * 50MB panorama well under it; the last is deliberately small because arriving\n * readable beats not arriving.\n */\nconst SHRINK_PASSES: Array<{ edge: number; quality: number }> = [\n { edge: MAX_EDGE, quality: RESIZE_QUALITY },\n { edge: FALLBACK_EDGE, quality: FALLBACK_QUALITY },\n { edge: 1024, quality: 0.5 },\n];\n/**\n * Ceiling on everything staged at once. Per-file limits do not bound the peak -\n * `MAX_FILES` of them do - and this is the number that decides whether the\n * composer can push the process into the range iOS reclaims from.\n */\nconst MAX_PENDING_BYTES = 32 * 1024 * 1024;\n/** Nothing sensible is this small; treat as a failed decode. */\nconst MIN_BYTES = 64;\n\nexport type AttachmentBusyKind = 'camera' | 'library' | 'documents' | null;\n\nexport interface ImageAttachmentsApi {\n /** Attachments staged for the next send. */\n pending: MessageAttachment[];\n /** True while any picker/encode is in flight. */\n busy: boolean;\n /** Which toolbar control is waiting — only that one should spin. */\n busyKind: AttachmentBusyKind;\n /** Human-readable failure for the composer's error banner, or null. */\n error: string | null;\n pickFromLibrary: () => Promise<void>;\n captureFromCamera: () => Promise<void>;\n pickDocuments: () => Promise<void>;\n remove: (id: string) => void;\n clear: () => void;\n /** Pass to `sendMessage` — undefined when empty, which is what it expects. */\n forSend: () => MessageAttachment[] | undefined;\n}\n\ntype PickedAsset = {\n uri?: string | null;\n base64?: string | null;\n mimeType?: string | null;\n fileName?: string | null;\n fileSize?: number | null;\n width?: number | null;\n height?: number | null;\n};\n\n/** Base64 decodes to 3 bytes per 4 chars, minus `=` padding. */\nfunction base64Bytes(base64: string): number {\n const padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0;\n return Math.floor((base64.length * 3) / 4) - padding;\n}\n\nfunction isJpegRepresentationError(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err ?? '');\n return /public\\.jpeg|Failed to read picked image/i.test(msg);\n}\n\nfunction attachErrorMessage(err: unknown): string {\n if (isJpegRepresentationError(err)) {\n return 'Could not read that photo. Try another one, or save it to Recents first.';\n }\n return err instanceof Error ? err.message : 'Could not attach that image.';\n}\n\nfunction guessImageMime(asset: PickedAsset): string {\n const mime = asset.mimeType?.trim();\n if (mime) return mime;\n const name = `${asset.fileName ?? ''} ${asset.uri ?? ''}`;\n if (/\\.png(\\?|$)/i.test(name)) return 'image/png';\n if (/\\.gif(\\?|$)/i.test(name)) return 'image/gif';\n if (/\\.webp(\\?|$)/i.test(name)) return 'image/webp';\n if (/\\.(heic|heif)(\\?|$)/i.test(name)) return 'image/heic';\n return 'image/jpeg';\n}\n\nasync function readUriBase64(uri: string): Promise<string | null> {\n const fs = loadFileSystem() as {\n readAsStringAsync?: (uri: string, options?: { encoding?: string }) => Promise<string>;\n EncodingType?: { Base64?: string };\n };\n if (typeof fs.readAsStringAsync !== 'function') return null;\n const encoding = fs.EncodingType?.Base64 ?? 'base64';\n const base64 = (await fs.readAsStringAsync(uri, { encoding })).trim();\n return base64 || null;\n}\n\n/**\n * Lazily required like the pickers. A binary built before this module became a\n * dependency has no native side, so a miss is expected, not exceptional - the\n * caller falls back to sending the original bytes under `MAX_INLINE_BYTES`.\n */\nfunction loadImageManipulator(): {\n manipulateAsync?: (\n uri: string,\n actions: Array<{ resize: { width?: number; height?: number } }>,\n options: { compress?: number; format?: unknown; base64?: boolean },\n ) => Promise<{ uri?: string; base64?: string | null }>;\n SaveFormat?: { JPEG?: string };\n} | null {\n try {\n // import/no-unresolved: optional by design - the require is allowed to\n // miss on a binary that predates the dependency, which is the whole\n // reason this is a lazy require rather than a top-level import.\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require, import/no-unresolved\n return require('expo-image-manipulator');\n } catch {\n return null;\n }\n}\n\ntype Resized = { base64: string; uri: string; mimeType: string };\n\n/**\n * Shrink until the image fits the wire. Null means \"send the original as-is\":\n * either the module is missing or the photo is already small enough, both of\n * which are fine. Re-encoding also transcodes HEIC, so a resized pick stops\n * depending on the agent understanding `image/heic`.\n *\n * `knownBytes` is 0 when the picker reported neither a size nor inline bytes;\n * pixels alone then decide, which is the pre-existing behaviour.\n */\nasync function shrinkForTransport(asset: PickedAsset, knownBytes: number): Promise<Resized | null> {\n const uri = asset.uri?.trim();\n if (!uri) return null;\n\n const width = asset.width ?? 0;\n const height = asset.height ?? 0;\n const longEdge = Math.max(width, height);\n if (longEdge <= MAX_EDGE && knownBytes <= TARGET_BYTES) return null;\n\n const manipulator = loadImageManipulator();\n const manipulate = manipulator?.manipulateAsync;\n if (typeof manipulate !== 'function') return null;\n\n // Constrain the long edge only, so the other one follows the aspect ratio.\n // Never above the source: when it is bytes rather than pixels that put us\n // here, the re-encode is there to compress, not to invent resolution.\n const encode = async (edge: number, quality: number): Promise<Resized | null> => {\n const capped = longEdge > 0 ? Math.min(edge, longEdge) : edge;\n const resize = height > width ? { height: capped } : { width: capped };\n const out = await manipulate(uri, [{ resize }], {\n compress: quality,\n format: manipulator?.SaveFormat?.JPEG ?? 'jpeg',\n base64: true,\n });\n const base64 = out.base64?.trim() || (out.uri ? await readUriBase64(out.uri) : null);\n return base64 ? { base64, uri: out.uri || uri, mimeType: 'image/jpeg' } : null;\n };\n\n // Keep tightening until it fits. Refusing a photo we could obviously have\n // carried is the one outcome this function exists to prevent.\n let best: Resized | null = null;\n let bestBytes = Number.POSITIVE_INFINITY;\n for (const pass of SHRINK_PASSES) {\n // Sequential on purpose: each pass exists only because the previous one\n // came back too heavy, and running them together would encode a 50MB\n // photo three times over on a phone.\n const out = await encode(pass.edge, pass.quality);\n if (out) {\n const bytes = base64Bytes(out.base64);\n if (bytes < bestBytes) {\n best = out;\n bestBytes = bytes;\n }\n if (bytes <= TARGET_BYTES) break;\n }\n }\n return best;\n}\n\n/**\n * Why an asset did not become an attachment. The composer used to collapse all\n * of these into \"too large\", which sent people hunting for a smaller photo when\n * the bytes were never the problem.\n */\n// A string discriminant, not a boolean: this repo compiles without\n// `strictNullChecks`, and TS only narrows boolean discriminants under it.\ntype AttachFailure = {\n status: 'failed';\n reason: 'unreadable' | 'empty' | 'oversize' | 'unshrunk';\n bytes: number;\n limit: number;\n};\ntype AttachOutcome = { status: 'ok'; attachment: MessageAttachment } | AttachFailure;\n\nfunction mb(bytes: number): string {\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/** Bytes already staged, so a pick cannot walk the process into eviction range. */\nfunction stagedBytes(attachments: MessageAttachment[]): number {\n return attachments.reduce((total, a) => total + (a.size ?? 0), 0);\n}\n\n/**\n * Take attachments while they fit the shared budget. Whatever does not fit is\n * reported rather than silently dropped.\n */\nfunction withinPendingBudget(\n existing: MessageAttachment[],\n incoming: MessageAttachment[],\n): { accepted: MessageAttachment[]; rejected: MessageAttachment[] } {\n let used = stagedBytes(existing);\n const accepted: MessageAttachment[] = [];\n const rejected: MessageAttachment[] = [];\n for (const attachment of incoming) {\n const size = attachment.size ?? 0;\n if (used + size > MAX_PENDING_BYTES) {\n rejected.push(attachment);\n } else {\n used += size;\n accepted.push(attachment);\n }\n }\n return { accepted, rejected };\n}\n\nfunction failureMessage(failures: AttachFailure[], noun: 'image' | 'file'): string {\n // Not the person's fault and not about their photo: this build simply has no\n // resizer, so say that instead of sending them hunting for a smaller one.\n const unshrunk = failures.find((f) => f.reason === 'unshrunk');\n if (unshrunk) {\n return `This app version cannot resize a ${mb(unshrunk.bytes)} ${noun} before sending. Update the app, or attach a smaller one.`;\n }\n const oversize = failures.find((f) => f.reason === 'oversize');\n if (oversize) {\n return `That ${noun} is ${mb(oversize.bytes)} and the limit is ${mb(oversize.limit)}. Try a smaller one.`;\n }\n if (noun === 'image') {\n return 'Could not read that photo. Try another one, or save it to Recents first.';\n }\n return 'Could not read that file. Try another one.';\n}\n\nasync function assetToAttachment(\n asset: PickedAsset,\n index: number,\n kind: MessageAttachment['type'] = 'file',\n): Promise<AttachOutcome> {\n let mimeType = guessImageMime(asset);\n let uri = asset.uri?.trim() || undefined;\n let base64 = '';\n let resized = false;\n\n const inline = asset.base64?.trim() || '';\n // Feed the shrink decision whatever the picker already told us, so size can\n // trigger it even when the pixel count looks innocent.\n const knownBytes = inline ? base64Bytes(inline) : (asset.fileSize ?? 0);\n\n if (knownBytes > MAX_SOURCE_BYTES) {\n return { status: 'failed', reason: 'oversize', bytes: knownBytes, limit: MAX_SOURCE_BYTES };\n }\n\n try {\n const smaller = await shrinkForTransport(asset, knownBytes);\n if (smaller) {\n ({ base64, uri, mimeType } = smaller);\n resized = true;\n }\n } catch {\n // A manipulator failure is never fatal - the original bytes still send.\n }\n\n // Nothing shrank it, so the original has to travel as-is. That is the only\n // case where the inline ceiling is the person's problem, and it goes away\n // once the binary carries a resizer.\n const limit = resized ? MAX_SOURCE_BYTES : MAX_INLINE_BYTES;\n if (!resized && !inline && knownBytes > limit) {\n return { status: 'failed', reason: 'unshrunk', bytes: knownBytes, limit };\n }\n\n if (!base64) base64 = inline;\n if (!base64 && uri) base64 = (await readUriBase64(uri)) || '';\n\n if (!base64) return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n const size = base64Bytes(base64);\n if (size < MIN_BYTES) return { status: 'failed', reason: 'empty', bytes: size, limit };\n if (size > limit) return { status: 'failed', reason: 'oversize', bytes: size, limit };\n\n const picked = asset.fileName?.trim() || `image-${Date.now()}-${index}.jpg`;\n // A resized asset is JPEG now, so a carried-over .HEIC name would lie.\n const name = resized ? picked.replace(/\\.(heic|heif|png|webp)$/i, '.jpg') : picked;\n return {\n status: 'ok',\n attachment: {\n id: `img-${Date.now()}-${index}`,\n name,\n type: kind,\n mimeType,\n dataUrl: `data:${mimeType};base64,${base64}`,\n url: uri,\n size,\n },\n };\n}\n\ntype PickedDocument = {\n uri?: string | null;\n name?: string | null;\n mimeType?: string | null;\n size?: number | null;\n};\n\n/**\n * Lazily required so a unit test or a non-Expo bundle importing this hook does\n * not hard-fail on the native module.\n */\nfunction loadPicker() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n return require('expo-image-picker') as typeof import('expo-image-picker');\n}\n\nfunction loadDocumentPicker(): {\n getDocumentAsync: (options: {\n type?: string | string[];\n multiple?: boolean;\n copyToCacheDirectory?: boolean;\n }) => Promise<{\n canceled?: boolean;\n type?: string;\n uri?: string;\n name?: string;\n mimeType?: string;\n size?: number;\n assets?: PickedDocument[];\n }>;\n} {\n // Staging/dev-client binaries only include modules that are dependencies +\n // autolinked at EAS/prebuild time. Expo Go already ships ExpoDocumentPicker,\n // which is why paperclip works locally without that native rebuild.\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n const core = require('expo-modules-core') as {\n requireOptionalNativeModule?: (name: string) => { getDocumentAsync?: Function } | null;\n };\n const native = core.requireOptionalNativeModule?.('ExpoDocumentPicker');\n if (native?.getDocumentAsync) {\n return {\n getDocumentAsync: (options) =>\n native.getDocumentAsync({\n type: Array.isArray(options.type) ? options.type : [options.type ?? '*/*'],\n multiple: options.multiple ?? false,\n copyToCacheDirectory: options.copyToCacheDirectory ?? true,\n }) as Promise<{\n canceled?: boolean;\n type?: string;\n uri?: string;\n name?: string;\n mimeType?: string;\n size?: number;\n assets?: PickedDocument[];\n }>,\n };\n }\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n return require('expo-document-picker') as typeof import('expo-document-picker');\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err ?? '');\n if (/Cannot find native module|ExpoDocumentPicker|Cannot find module/i.test(msg)) {\n throw new Error(\n 'File picker is not included in this app build. Use Photos, or install a staging build that includes expo-document-picker.',\n );\n }\n throw err;\n }\n}\n\nfunction loadFileSystem() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n return require('expo-file-system') as typeof import('expo-file-system');\n}\n\n/** Web `ACCEPTED_FILE_TYPES` — docs + images. */\nconst DOCUMENT_MIME_TYPES = [\n 'application/pdf',\n 'text/plain',\n 'text/markdown',\n 'text/csv',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'image/*',\n];\n/** Matches cdecli's `chat_media.go` `maxImages`, so every slot can reach the model. */\nconst MAX_FILES = 8;\n/**\n * Lower than a photo's `MAX_SOURCE_BYTES`, and deliberately so: a photo is\n * shrunk to ~1.4MB before anything retains it, while a document has nothing to\n * shrink and is held whole as a base64 string. At 50MB x `MAX_FILES` that is\n * ~500MB resident on a phone that iOS is already evicting for its footprint\n * ([[mobile-app-terminated-on-background]]). 25MB per file, bounded by\n * `MAX_PENDING_BYTES` in total, is the most this lane can actually carry.\n */\nconst MAX_DOCUMENT_BYTES = 25 * 1024 * 1024;\n\nfunction normalizeDocumentAssets(result: {\n canceled?: boolean;\n type?: string;\n uri?: string;\n name?: string;\n mimeType?: string;\n size?: number;\n assets?: PickedDocument[];\n}): PickedDocument[] {\n if (!result || result.canceled || result.type === 'cancel') return [];\n if (Array.isArray(result.assets) && result.assets.length > 0) return result.assets;\n if (result.uri) {\n return [{ uri: result.uri, name: result.name, mimeType: result.mimeType, size: result.size }];\n }\n return [];\n}\n\nasync function documentToAttachment(asset: PickedDocument, index: number): Promise<AttachOutcome> {\n const limit = MAX_DOCUMENT_BYTES;\n const uri = asset.uri?.trim();\n if (!uri) return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n if (typeof asset.size === 'number' && asset.size > limit) {\n return { status: 'failed', reason: 'oversize', bytes: asset.size, limit };\n }\n\n const fs = loadFileSystem() as {\n readAsStringAsync?: (uri: string, options?: { encoding?: string }) => Promise<string>;\n EncodingType?: { Base64?: string };\n };\n const encoding = fs.EncodingType?.Base64 ?? 'base64';\n if (typeof fs.readAsStringAsync !== 'function') return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n const base64 = (await fs.readAsStringAsync(uri, { encoding })).trim();\n if (!base64) return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n const size = typeof asset.size === 'number' && asset.size > 0 ? asset.size : base64Bytes(base64);\n if (size < MIN_BYTES) return { status: 'failed', reason: 'empty', bytes: size, limit };\n if (size > limit) return { status: 'failed', reason: 'oversize', bytes: size, limit };\n const mimeType = asset.mimeType?.trim() || 'application/octet-stream';\n const name = asset.name?.trim() || `file-${Date.now()}-${index}`;\n return {\n status: 'ok',\n attachment: {\n id: `file-${Date.now()}-${index}`,\n name,\n type: 'file',\n mimeType,\n dataUrl: `data:${mimeType};base64,${base64}`,\n url: uri,\n size,\n },\n };\n}\n\nexport function useImageAttachments(): ImageAttachmentsApi {\n const [pending, setPending] = useState<MessageAttachment[]>([]);\n const [busyKind, setBusyKind] = useState<AttachmentBusyKind>(null);\n const [error, setError] = useState<string | null>(null);\n\n const run = useCallback(async (mode: 'library' | 'camera') => {\n setError(null);\n try {\n const picker = loadPicker();\n\n const permission =\n mode === 'camera'\n ? await picker.requestCameraPermissionsAsync()\n : await picker.requestMediaLibraryPermissionsAsync();\n if (!permission.granted) {\n setError(\n mode === 'camera'\n ? 'Camera access is off for Yantra. Turn it on in Settings to attach a photo.'\n : 'Photo access is off for Yantra. Turn it on in Settings to attach an image.',\n );\n return;\n }\n\n // Spin only the control that was tapped, and only after permission\n // so the iOS prompt does not turn camera+gallery+attach into loaders.\n setBusyKind(mode);\n const representation =\n picker.UIImagePickerPreferredAssetRepresentationMode?.Current ?? ('current' as never);\n // Asking the picker for base64 materialises the WHOLE original as a\n // JS string - ~67MB for a 50MB pick, before anything has shrunk it.\n // When we can resize we only need the URI; the manipulator reads the\n // file natively and hands back base64 of the small result instead.\n const canShrink = typeof loadImageManipulator()?.manipulateAsync === 'function';\n const options: import('expo-image-picker').ImagePickerOptions = {\n base64: !canShrink,\n allowsMultipleSelection: mode === 'library',\n mediaTypes: ['images'],\n selectionLimit: MAX_FILES,\n exif: false,\n ...(picker.UIImagePickerPresentationStyle?.OVER_FULL_SCREEN\n ? { presentationStyle: picker.UIImagePickerPresentationStyle.OVER_FULL_SCREEN }\n : {}),\n ...(mode === 'camera' ? { quality: PICKER_QUALITY } : {}),\n ...(mode === 'library' ? { preferredAssetRepresentationMode: representation } : {}),\n };\n\n let result: import('expo-image-picker').ImagePickerResult;\n try {\n result =\n mode === 'camera'\n ? await picker.launchCameraAsync({ ...options, allowsMultipleSelection: false })\n : await picker.launchImageLibraryAsync(options);\n } catch (e) {\n if (mode !== 'library' || !isJpegRepresentationError(e)) throw e;\n result = await picker.launchImageLibraryAsync({ ...options, base64: false });\n }\n\n if (result.canceled) return;\n\n const picked = result.assets ?? [];\n const mapped: MessageAttachment[] = [];\n const failures: AttachFailure[] = [];\n for (let i = 0; i < picked.length; i += 1) {\n const next = await assetToAttachment(\n picked[i] as PickedAsset,\n i,\n mode === 'camera' ? 'screenshot' : 'file',\n );\n if (next.status === 'ok') mapped.push(next.attachment);\n else failures.push(next);\n }\n\n if (mapped.length === 0) {\n setError(failureMessage(failures, 'image'));\n return;\n }\n setPending((prev) => {\n const { accepted, rejected } = withinPendingBudget(prev, mapped);\n if (rejected.length > 0) {\n setError(\n `Only ${mb(MAX_PENDING_BYTES)} of attachments can be staged at once. ${rejected.length} left off.`,\n );\n }\n return [...prev, ...accepted].slice(0, MAX_FILES);\n });\n } catch (e) {\n setError(attachErrorMessage(e));\n } finally {\n setBusyKind(null);\n }\n }, []);\n\n const pickFromLibrary = useCallback(() => run('library'), [run]);\n const captureFromCamera = useCallback(() => run('camera'), [run]);\n const pickDocuments = useCallback(async () => {\n setError(null);\n try {\n const picker = loadDocumentPicker();\n setBusyKind('documents');\n const result = await picker.getDocumentAsync({\n type: DOCUMENT_MIME_TYPES,\n multiple: true,\n copyToCacheDirectory: true,\n });\n const assets = normalizeDocumentAssets(result as Parameters<typeof normalizeDocumentAssets>[0]);\n if (assets.length === 0) return;\n\n const mapped: MessageAttachment[] = [];\n const failures: AttachFailure[] = [];\n for (let i = 0; i < assets.length; i += 1) {\n const next = await documentToAttachment(assets[i], i);\n if (next.status === 'ok') mapped.push(next.attachment);\n else failures.push(next);\n }\n if (mapped.length === 0) {\n setError(failureMessage(failures, 'file'));\n return;\n }\n setPending((prev) => {\n const { accepted, rejected } = withinPendingBudget(prev, mapped);\n if (rejected.length > 0) {\n setError(\n `Only ${mb(MAX_PENDING_BYTES)} of attachments can be staged at once. ${rejected.length} left off.`,\n );\n }\n return [...prev, ...accepted].slice(0, MAX_FILES);\n });\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Could not attach that file.');\n } finally {\n setBusyKind(null);\n }\n }, []);\n const remove = useCallback((id: string) => setPending((prev) => prev.filter((a) => a.id !== id)), []);\n const clear = useCallback(() => setPending([]), []);\n const forSend = useCallback(() => (pending.length > 0 ? pending.map((a) => ({ ...a })) : undefined), [pending]);\n const busy = busyKind !== null;\n\n return useMemo(\n () => ({\n pending,\n busy,\n busyKind,\n error,\n pickFromLibrary,\n captureFromCamera,\n pickDocuments,\n remove,\n clear,\n forSend,\n }),\n [pending, busy, busyKind, error, pickFromLibrary, captureFromCamera, pickDocuments, remove, clear, forSend],\n );\n}\n\nexport const IMAGE_ATTACHMENT_LIMITS = {\n MAX_EDGE,\n FALLBACK_EDGE,\n SHRINK_PASSES,\n MAX_SOURCE_BYTES,\n MAX_PENDING_BYTES,\n TARGET_BYTES,\n MAX_INLINE_BYTES,\n MAX_DOCUMENT_BYTES,\n MAX_FILES,\n PICKER_QUALITY,\n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,OAAU,GAAA,WAAA,CAAY,MAAM,OAAA,CAAQ,SAAS,CAAI,GAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,CAAA,KAAM,mBACpE,CACH,CAAA,CAAA,GAAI,MAAW,EAAA,CAAC,OAAO,CAAC,CAAA;AAC1B,EAAA,MAAM,OAAO,QAAa,KAAA,IAAA;AAC1B,EAAA,OAAO,QAAQ,OAAO;AAAA,IACpB,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACE,CAAA,EAAA,CAAC,OAAS,EAAA,IAAA,EAAM,QAAU,EAAA,KAAA,EAAO,eAAiB,EAAA,iBAAA,EAAmB,aAAe,EAAA,MAAA,EAAQ,KAAO,EAAA,OAAO,CAAC,CAAA;AACjH"}
1
+ {"version":3,"file":"useImageAttachments.js","sources":["../../../src/features/attachments/useImageAttachments.ts"],"sourcesContent":["/**\n * Image attachments for the native composer.\n *\n * The transport was already there — `useChatStream.sendMessage(content,\n * attachments)` carries `MessageAttachment[]` and the gateway media lane is\n * covered by `aiwork/e2e-tests/gateway-media-upload.spec.ts`. What was missing\n * was any way to produce one on a phone: the composer shipped with\n * `image`/`camera`/`attach` hard-disabled, and nothing in the mobile package\n * touched `expo-image-picker` even though it is a dependency and the photo and\n * camera permission strings are already declared in `app.json`.\n *\n * Payload size is the whole game here. A modern iPhone photo is ~3-5 MB and\n * ~4000px wide; base64 inflates that by a third, and it travels inline on the\n * chat message. Camera captures can be JPEG-compressed via `quality`. Library\n * picks must NOT pass `quality`: that asks iOS for `public.jpeg` and fails on\n * HEIC / iCloud photos with \"Cannot load representation of type public.jpeg\".\n * The canvas picker already uses `Current` for that reason.\n *\n * `MAX_EDGE` is not our invention, it is the resize the models apply anyway.\n * Claude keeps 2576px on the long edge (4.7+ high-resolution tier, 1568px on\n * older models) and downscales everything above it before it ever sees the\n * image; OpenAI caps the long edge at 2000px. So a 4032px capture spends 3x\n * the bytes on pixels that are thrown away upstream. Downscaling on the device\n * is free fidelity-wise and is what keeps us clear of every byte ceiling in\n * the chain: measured on real 12MP iPhone photos, 2.9MB -> 1.4MB.\n *\n * The resize is therefore what decides whether a photo can be attached at all,\n * not the byte ceiling - so it triggers on bytes as well as pixels (a 2000px\n * PNG screenshot is inside `MAX_EDGE` and can still be 12MB) and keeps\n * tightening until it fits rather than giving up.\n *\n * The contract this file owes a person: hand it anything a phone can produce,\n * up to `MAX_SOURCE_BYTES`, and sizing is our problem, not theirs. Nobody\n * should be told to go find a smaller photo. That means shrinking is attempted\n * before any ceiling is consulted, and the only refusals left are \"bigger than\n * we will even open\" and \"this build has no resizer and the raw bytes cannot\n * fit inline\" - the second disappears once `expo-image-manipulator` is in the\n * binary.\n */\nimport { useCallback, useMemo, useState } from 'react';\nimport type { MessageAttachment } from '../../hooks/useChatStream';\nimport { hasNativeModule } from '../../utils/hasNativeModule';\n\n/** Longest edge, in px, we send. Matches Claude's high-resolution tier ceiling. */\nconst MAX_EDGE = 2576;\n/**\n * Long edge for a second, tighter pass when one resize still will not fit.\n * Claude's standard tier, so every model keeps all of it.\n */\nconst FALLBACK_EDGE = 1568;\n/** JPEG quality handed to the picker for a camera capture (0-1). */\nconst PICKER_QUALITY = 0.7;\n/**\n * JPEG quality for our own re-encode. Higher than the picker's: a 2576px frame\n * is already small, and the camera's headline use per `app.json` is \"a photo of\n * a document you want help with\" - text is the first thing heavy JPEG\n * compression destroys.\n */\nconst RESIZE_QUALITY = 0.8;\n/** Harder compress for the second pass. Still readable; the point is to fit. */\nconst FALLBACK_QUALITY = 0.6;\n/**\n * What one image should weigh by the time it is on the wire. This is not our\n * number: an image turn always takes the inline-bytes lane (`useChatStream`\n * sends `buildGatewayMedia(..., includeData)` whenever any attachment is an\n * image), and cdecli's resolver drops anything heavier - `chat_media.go`\n * `defaultChatMediaLimits` is 5MB per image and 8 images, tunable with\n * `CDECLI_CHAT_MAX_IMAGE_BYTES` / `CDECLI_CHAT_MAX_IMAGES`. Raising the number\n * here alone would not make a bigger photo arrive.\n */\nconst TARGET_BYTES = 5 * 1024 * 1024;\n/**\n * Absolute ceiling for bytes travelling inline, which is every image turn and\n * any document sharing one. `buildGatewayMedia`'s inline cap is 14e6 base64\n * chars, so ~10MB decoded is the most that can survive the trip. Only reached\n * when nothing shrank the image.\n */\nconst MAX_INLINE_BYTES = 10 * 1024 * 1024;\n/**\n * What a person is allowed to hand us. Deliberately far above anything a phone\n * camera produces (a 48MP JPEG is ~10MB, an iPhone ProRAW ~25MB) so that taking\n * a picture and attaching it never involves thinking about bytes. Everything up\n * to here is ours to shrink. Above it we refuse rather than pull the file into\n * a JS string, because that is how a memory-tight phone loses the app mid-pick.\n */\nconst MAX_SOURCE_BYTES = 50 * 1024 * 1024;\n/**\n * Tried in order until one lands under `TARGET_BYTES`. Three passes take even a\n * 50MB panorama well under it; the last is deliberately small because arriving\n * readable beats not arriving.\n */\nconst SHRINK_PASSES: Array<{ edge: number; quality: number }> = [\n { edge: MAX_EDGE, quality: RESIZE_QUALITY },\n { edge: FALLBACK_EDGE, quality: FALLBACK_QUALITY },\n { edge: 1024, quality: 0.5 },\n];\n/**\n * Ceiling on everything staged at once. Per-file limits do not bound the peak -\n * `MAX_FILES` of them do - and this is the number that decides whether the\n * composer can push the process into the range iOS reclaims from.\n */\nconst MAX_PENDING_BYTES = 32 * 1024 * 1024;\n/** Nothing sensible is this small; treat as a failed decode. */\nconst MIN_BYTES = 64;\n\nexport type AttachmentBusyKind = 'camera' | 'library' | 'documents' | null;\n\nexport interface ImageAttachmentsApi {\n /** Attachments staged for the next send. */\n pending: MessageAttachment[];\n /** True while any picker/encode is in flight. */\n busy: boolean;\n /** Which toolbar control is waiting — only that one should spin. */\n busyKind: AttachmentBusyKind;\n /** Human-readable failure for the composer's error banner, or null. */\n error: string | null;\n pickFromLibrary: () => Promise<void>;\n captureFromCamera: () => Promise<void>;\n pickDocuments: () => Promise<void>;\n remove: (id: string) => void;\n clear: () => void;\n /** Pass to `sendMessage` — undefined when empty, which is what it expects. */\n forSend: () => MessageAttachment[] | undefined;\n}\n\ntype PickedAsset = {\n uri?: string | null;\n base64?: string | null;\n mimeType?: string | null;\n fileName?: string | null;\n fileSize?: number | null;\n width?: number | null;\n height?: number | null;\n};\n\n/** Base64 decodes to 3 bytes per 4 chars, minus `=` padding. */\nfunction base64Bytes(base64: string): number {\n let padding = 0;\n if (base64.endsWith('==')) padding = 2;\n else if (base64.endsWith('=')) padding = 1;\n return Math.floor((base64.length * 3) / 4) - padding;\n}\n\nfunction isJpegRepresentationError(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err ?? '');\n return /public\\.jpeg|Failed to read picked image/i.test(msg);\n}\n\nfunction attachErrorMessage(err: unknown): string {\n if (isJpegRepresentationError(err)) {\n return 'Could not read that photo. Try another one, or save it to Recents first.';\n }\n return err instanceof Error ? err.message : 'Could not attach that image.';\n}\n\nfunction guessImageMime(asset: PickedAsset): string {\n const mime = asset.mimeType?.trim();\n if (mime) return mime;\n const name = `${asset.fileName ?? ''} ${asset.uri ?? ''}`;\n if (/\\.png(\\?|$)/i.test(name)) return 'image/png';\n if (/\\.gif(\\?|$)/i.test(name)) return 'image/gif';\n if (/\\.webp(\\?|$)/i.test(name)) return 'image/webp';\n if (/\\.(heic|heif)(\\?|$)/i.test(name)) return 'image/heic';\n return 'image/jpeg';\n}\n\nfunction loadFileSystem() {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require\n return require('expo-file-system') as typeof import('expo-file-system');\n}\n\nasync function readUriBase64(uri: string): Promise<string | null> {\n const fs = loadFileSystem() as {\n readAsStringAsync?: (uri: string, options?: { encoding?: string }) => Promise<string>;\n EncodingType?: { Base64?: string };\n };\n if (typeof fs.readAsStringAsync !== 'function') return null;\n const encoding = fs.EncodingType?.Base64 ?? 'base64';\n const base64 = (await fs.readAsStringAsync(uri, { encoding })).trim();\n return base64 || null;\n}\n\n/**\n * Lazily required like the pickers. A binary built before this module became a\n * dependency has no native side, so a miss is expected, not exceptional - the\n * caller falls back to sending the original bytes under `MAX_INLINE_BYTES`.\n */\nfunction loadImageManipulator(): {\n manipulateAsync?: (\n uri: string,\n actions: Array<{ resize: { width?: number; height?: number } }>,\n options: { compress?: number; format?: unknown; base64?: boolean },\n ) => Promise<{ uri?: string; base64?: string | null }>;\n SaveFormat?: { JPEG?: string };\n} | null {\n // Asked first: on a binary without the native module, the require below would\n // crash a release build before the catch runs (see hasNativeModule).\n if (!hasNativeModule('ExpoImageManipulator')) return null;\n try {\n // import/no-unresolved: optional by design - the require is allowed to\n // miss on a binary that predates the dependency, which is the whole\n // reason this is a lazy require rather than a top-level import.\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require, import/no-unresolved\n return require('expo-image-manipulator');\n } catch {\n return null;\n }\n}\n\ntype Resized = { base64: string; uri: string; mimeType: string };\n\n/**\n * Shrink until the image fits the wire. Null means \"send the original as-is\":\n * either the module is missing or the photo is already small enough, both of\n * which are fine. Re-encoding also transcodes HEIC, so a resized pick stops\n * depending on the agent understanding `image/heic`.\n *\n * `knownBytes` is 0 when the picker reported neither a size nor inline bytes;\n * pixels alone then decide, which is the pre-existing behaviour.\n */\nasync function shrinkForTransport(asset: PickedAsset, knownBytes: number): Promise<Resized | null> {\n const uri = asset.uri?.trim();\n if (!uri) return null;\n\n const width = asset.width ?? 0;\n const height = asset.height ?? 0;\n const longEdge = Math.max(width, height);\n if (longEdge <= MAX_EDGE && knownBytes <= TARGET_BYTES) return null;\n\n const manipulator = loadImageManipulator();\n const manipulate = manipulator?.manipulateAsync;\n if (typeof manipulate !== 'function') return null;\n\n // Constrain the long edge only, so the other one follows the aspect ratio.\n // Never above the source: when it is bytes rather than pixels that put us\n // here, the re-encode is there to compress, not to invent resolution.\n const encode = async (edge: number, quality: number): Promise<Resized | null> => {\n const capped = longEdge > 0 ? Math.min(edge, longEdge) : edge;\n const resize = height > width ? { height: capped } : { width: capped };\n const out = await manipulate(uri, [{ resize }], {\n compress: quality,\n format: manipulator?.SaveFormat?.JPEG ?? 'jpeg',\n base64: true,\n });\n const base64 = out.base64?.trim() || (out.uri ? await readUriBase64(out.uri) : null);\n return base64 ? { base64, uri: out.uri || uri, mimeType: 'image/jpeg' } : null;\n };\n\n // Keep tightening until it fits. Refusing a photo we could obviously have\n // carried is the one outcome this function exists to prevent.\n let best: Resized | null = null;\n let bestBytes = Number.POSITIVE_INFINITY;\n for (const pass of SHRINK_PASSES) {\n // Sequential on purpose: each pass exists only because the previous one\n // came back too heavy, and running them together would encode a 50MB\n // photo three times over on a phone.\n const out = await encode(pass.edge, pass.quality);\n if (out) {\n const bytes = base64Bytes(out.base64);\n if (bytes < bestBytes) {\n best = out;\n bestBytes = bytes;\n }\n if (bytes <= TARGET_BYTES) break;\n }\n }\n return best;\n}\n\n/**\n * Why an asset did not become an attachment. The composer used to collapse all\n * of these into \"too large\", which sent people hunting for a smaller photo when\n * the bytes were never the problem.\n */\n// A string discriminant, not a boolean: this repo compiles without\n// `strictNullChecks`, and TS only narrows boolean discriminants under it.\ntype AttachFailure = {\n status: 'failed';\n reason: 'unreadable' | 'empty' | 'oversize' | 'unshrunk';\n bytes: number;\n limit: number;\n};\ntype AttachOutcome = { status: 'ok'; attachment: MessageAttachment } | AttachFailure;\n\nfunction mb(bytes: number): string {\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/** Bytes already staged, so a pick cannot walk the process into eviction range. */\nfunction stagedBytes(attachments: MessageAttachment[]): number {\n return attachments.reduce((total, a) => total + (a.size ?? 0), 0);\n}\n\n/**\n * Take attachments while they fit the shared budget. Whatever does not fit is\n * reported rather than silently dropped.\n */\nfunction withinPendingBudget(\n existing: MessageAttachment[],\n incoming: MessageAttachment[],\n): { accepted: MessageAttachment[]; rejected: MessageAttachment[] } {\n let used = stagedBytes(existing);\n const accepted: MessageAttachment[] = [];\n const rejected: MessageAttachment[] = [];\n for (const attachment of incoming) {\n const size = attachment.size ?? 0;\n if (used + size > MAX_PENDING_BYTES) {\n rejected.push(attachment);\n } else {\n used += size;\n accepted.push(attachment);\n }\n }\n return { accepted, rejected };\n}\n\nfunction failureMessage(failures: AttachFailure[], noun: 'image' | 'file'): string {\n // Not the person's fault and not about their photo: this build simply has no\n // resizer, so say that instead of sending them hunting for a smaller one.\n const unshrunk = failures.find((f) => f.reason === 'unshrunk');\n if (unshrunk) {\n return `This app version cannot resize a ${mb(unshrunk.bytes)} ${noun} before sending. Update the app, or attach a smaller one.`;\n }\n const oversize = failures.find((f) => f.reason === 'oversize');\n if (oversize) {\n return `That ${noun} is ${mb(oversize.bytes)} and the limit is ${mb(oversize.limit)}. Try a smaller one.`;\n }\n if (noun === 'image') {\n return 'Could not read that photo. Try another one, or save it to Recents first.';\n }\n return 'Could not read that file. Try another one.';\n}\n\nasync function assetToAttachment(\n asset: PickedAsset,\n index: number,\n kind: MessageAttachment['type'] = 'file',\n): Promise<AttachOutcome> {\n let mimeType = guessImageMime(asset);\n let uri = asset.uri?.trim() || undefined;\n let base64 = '';\n let resized = false;\n\n const inline = asset.base64?.trim() || '';\n // Feed the shrink decision whatever the picker already told us, so size can\n // trigger it even when the pixel count looks innocent.\n const knownBytes = inline ? base64Bytes(inline) : (asset.fileSize ?? 0);\n\n if (knownBytes > MAX_SOURCE_BYTES) {\n return { status: 'failed', reason: 'oversize', bytes: knownBytes, limit: MAX_SOURCE_BYTES };\n }\n\n try {\n const smaller = await shrinkForTransport(asset, knownBytes);\n if (smaller) {\n ({ base64, uri, mimeType } = smaller);\n resized = true;\n }\n } catch {\n // A manipulator failure is never fatal - the original bytes still send.\n }\n\n // Nothing shrank it, so the original has to travel as-is. That is the only\n // case where the inline ceiling is the person's problem, and it goes away\n // once the binary carries a resizer.\n const limit = resized ? MAX_SOURCE_BYTES : MAX_INLINE_BYTES;\n if (!resized && !inline && knownBytes > limit) {\n return { status: 'failed', reason: 'unshrunk', bytes: knownBytes, limit };\n }\n\n if (!base64) base64 = inline;\n if (!base64 && uri) base64 = (await readUriBase64(uri)) || '';\n\n if (!base64) return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n const size = base64Bytes(base64);\n if (size < MIN_BYTES) return { status: 'failed', reason: 'empty', bytes: size, limit };\n if (size > limit) return { status: 'failed', reason: 'oversize', bytes: size, limit };\n\n const picked = asset.fileName?.trim() || `image-${Date.now()}-${index}.jpg`;\n // A resized asset is JPEG now, so a carried-over .HEIC name would lie.\n const name = resized ? picked.replace(/\\.(heic|heif|png|webp)$/i, '.jpg') : picked;\n return {\n status: 'ok',\n attachment: {\n id: `img-${Date.now()}-${index}`,\n name,\n type: kind,\n mimeType,\n dataUrl: `data:${mimeType};base64,${base64}`,\n url: uri,\n size,\n },\n };\n}\n\ntype PickedDocument = {\n uri?: string | null;\n name?: string | null;\n mimeType?: string | null;\n size?: number | null;\n};\n\n/**\n * Lazily required so a unit test or a non-Expo bundle importing this hook does\n * not hard-fail on the native module.\n */\nfunction loadPicker() {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require\n return require('expo-image-picker') as typeof import('expo-image-picker');\n}\n\nfunction loadDocumentPicker(): {\n getDocumentAsync: (options: {\n type?: string | string[];\n multiple?: boolean;\n copyToCacheDirectory?: boolean;\n }) => Promise<{\n canceled?: boolean;\n type?: string;\n uri?: string;\n name?: string;\n mimeType?: string;\n size?: number;\n assets?: PickedDocument[];\n }>;\n} {\n // Staging/dev-client binaries only include modules that are dependencies +\n // autolinked at EAS/prebuild time. Expo Go already ships ExpoDocumentPicker,\n // which is why paperclip works locally without that native rebuild.\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require\n const core = require('expo-modules-core') as {\n requireOptionalNativeModule?: (\n name: string,\n ) => { getDocumentAsync?: (options: Record<string, unknown>) => Promise<unknown> } | null;\n };\n const native = core.requireOptionalNativeModule?.('ExpoDocumentPicker');\n if (native?.getDocumentAsync) {\n return {\n getDocumentAsync: (options) =>\n native.getDocumentAsync({\n type: Array.isArray(options.type) ? options.type : [options.type ?? '*/*'],\n multiple: options.multiple ?? false,\n copyToCacheDirectory: options.copyToCacheDirectory ?? true,\n }) as Promise<{\n canceled?: boolean;\n type?: string;\n uri?: string;\n name?: string;\n mimeType?: string;\n size?: number;\n assets?: PickedDocument[];\n }>,\n };\n }\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require\n return require('expo-document-picker') as typeof import('expo-document-picker');\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err ?? '');\n if (/Cannot find native module|ExpoDocumentPicker|Cannot find module/i.test(msg)) {\n throw new Error(\n 'File picker is not included in this app build. Use Photos, or install a staging build that includes expo-document-picker.',\n );\n }\n throw err;\n }\n}\n\n/** Web `ACCEPTED_FILE_TYPES` — docs + images. */\nconst DOCUMENT_MIME_TYPES = [\n 'application/pdf',\n 'text/plain',\n 'text/markdown',\n 'text/csv',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'image/*',\n];\n/** Matches cdecli's `chat_media.go` `maxImages`, so every slot can reach the model. */\nconst MAX_FILES = 8;\n/**\n * Lower than a photo's `MAX_SOURCE_BYTES`, and deliberately so: a photo is\n * shrunk to ~1.4MB before anything retains it, while a document has nothing to\n * shrink and is held whole as a base64 string. At 50MB x `MAX_FILES` that is\n * ~500MB resident on a phone that iOS is already evicting for its footprint\n * ([[mobile-app-terminated-on-background]]). 25MB per file, bounded by\n * `MAX_PENDING_BYTES` in total, is the most this lane can actually carry.\n */\nconst MAX_DOCUMENT_BYTES = 25 * 1024 * 1024;\n\nfunction normalizeDocumentAssets(result: {\n canceled?: boolean;\n type?: string;\n uri?: string;\n name?: string;\n mimeType?: string;\n size?: number;\n assets?: PickedDocument[];\n}): PickedDocument[] {\n if (!result || result.canceled || result.type === 'cancel') return [];\n if (Array.isArray(result.assets) && result.assets.length > 0) return result.assets;\n if (result.uri) {\n return [{ uri: result.uri, name: result.name, mimeType: result.mimeType, size: result.size }];\n }\n return [];\n}\n\nasync function documentToAttachment(asset: PickedDocument, index: number): Promise<AttachOutcome> {\n const limit = MAX_DOCUMENT_BYTES;\n const uri = asset.uri?.trim();\n if (!uri) return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n if (typeof asset.size === 'number' && asset.size > limit) {\n return { status: 'failed', reason: 'oversize', bytes: asset.size, limit };\n }\n\n const fs = loadFileSystem() as {\n readAsStringAsync?: (uri: string, options?: { encoding?: string }) => Promise<string>;\n EncodingType?: { Base64?: string };\n };\n const encoding = fs.EncodingType?.Base64 ?? 'base64';\n if (typeof fs.readAsStringAsync !== 'function') return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n const base64 = (await fs.readAsStringAsync(uri, { encoding })).trim();\n if (!base64) return { status: 'failed', reason: 'unreadable', bytes: 0, limit };\n const size = typeof asset.size === 'number' && asset.size > 0 ? asset.size : base64Bytes(base64);\n if (size < MIN_BYTES) return { status: 'failed', reason: 'empty', bytes: size, limit };\n if (size > limit) return { status: 'failed', reason: 'oversize', bytes: size, limit };\n const mimeType = asset.mimeType?.trim() || 'application/octet-stream';\n const name = asset.name?.trim() || `file-${Date.now()}-${index}`;\n return {\n status: 'ok',\n attachment: {\n id: `file-${Date.now()}-${index}`,\n name,\n type: 'file',\n mimeType,\n dataUrl: `data:${mimeType};base64,${base64}`,\n url: uri,\n size,\n },\n };\n}\n\nexport function useImageAttachments(): ImageAttachmentsApi {\n const [pending, setPending] = useState<MessageAttachment[]>([]);\n const [busyKind, setBusyKind] = useState<AttachmentBusyKind>(null);\n const [error, setError] = useState<string | null>(null);\n\n const run = useCallback(async (mode: 'library' | 'camera') => {\n setError(null);\n try {\n const picker = loadPicker();\n\n const permission =\n mode === 'camera'\n ? await picker.requestCameraPermissionsAsync()\n : await picker.requestMediaLibraryPermissionsAsync();\n if (!permission.granted) {\n setError(\n mode === 'camera'\n ? 'Camera access is off for Yantra. Turn it on in Settings to attach a photo.'\n : 'Photo access is off for Yantra. Turn it on in Settings to attach an image.',\n );\n return;\n }\n\n // Spin only the control that was tapped, and only after permission\n // so the iOS prompt does not turn camera+gallery+attach into loaders.\n setBusyKind(mode);\n const representation =\n picker.UIImagePickerPreferredAssetRepresentationMode?.Current ?? ('current' as never);\n // Asking the picker for base64 materialises the WHOLE original as a\n // JS string - ~67MB for a 50MB pick, before anything has shrunk it.\n // When we can resize we only need the URI; the manipulator reads the\n // file natively and hands back base64 of the small result instead.\n const canShrink = typeof loadImageManipulator()?.manipulateAsync === 'function';\n const options: import('expo-image-picker').ImagePickerOptions = {\n base64: !canShrink,\n allowsMultipleSelection: mode === 'library',\n mediaTypes: ['images'],\n selectionLimit: MAX_FILES,\n exif: false,\n ...(picker.UIImagePickerPresentationStyle?.OVER_FULL_SCREEN\n ? { presentationStyle: picker.UIImagePickerPresentationStyle.OVER_FULL_SCREEN }\n : {}),\n ...(mode === 'camera' ? { quality: PICKER_QUALITY } : {}),\n ...(mode === 'library' ? { preferredAssetRepresentationMode: representation } : {}),\n };\n\n let result: import('expo-image-picker').ImagePickerResult;\n try {\n result =\n mode === 'camera'\n ? await picker.launchCameraAsync({ ...options, allowsMultipleSelection: false })\n : await picker.launchImageLibraryAsync(options);\n } catch (e) {\n if (mode !== 'library' || !isJpegRepresentationError(e)) throw e;\n result = await picker.launchImageLibraryAsync({ ...options, base64: false });\n }\n\n if (result.canceled) return;\n\n const picked = result.assets ?? [];\n const mapped: MessageAttachment[] = [];\n const failures: AttachFailure[] = [];\n for (let i = 0; i < picked.length; i += 1) {\n const next = await assetToAttachment(\n picked[i] as PickedAsset,\n i,\n mode === 'camera' ? 'screenshot' : 'file',\n );\n if (next.status === 'ok') mapped.push(next.attachment);\n else failures.push(next);\n }\n\n if (mapped.length === 0) {\n setError(failureMessage(failures, 'image'));\n return;\n }\n setPending((prev) => {\n const { accepted, rejected } = withinPendingBudget(prev, mapped);\n if (rejected.length > 0) {\n setError(\n `Only ${mb(MAX_PENDING_BYTES)} of attachments can be staged at once. ${rejected.length} left off.`,\n );\n }\n return [...prev, ...accepted].slice(0, MAX_FILES);\n });\n } catch (e) {\n setError(attachErrorMessage(e));\n } finally {\n setBusyKind(null);\n }\n }, []);\n\n const pickFromLibrary = useCallback(() => run('library'), [run]);\n const captureFromCamera = useCallback(() => run('camera'), [run]);\n const pickDocuments = useCallback(async () => {\n setError(null);\n try {\n const picker = loadDocumentPicker();\n setBusyKind('documents');\n const result = await picker.getDocumentAsync({\n type: DOCUMENT_MIME_TYPES,\n multiple: true,\n copyToCacheDirectory: true,\n });\n const assets = normalizeDocumentAssets(result as Parameters<typeof normalizeDocumentAssets>[0]);\n if (assets.length === 0) return;\n\n const mapped: MessageAttachment[] = [];\n const failures: AttachFailure[] = [];\n for (let i = 0; i < assets.length; i += 1) {\n const next = await documentToAttachment(assets[i], i);\n if (next.status === 'ok') mapped.push(next.attachment);\n else failures.push(next);\n }\n if (mapped.length === 0) {\n setError(failureMessage(failures, 'file'));\n return;\n }\n setPending((prev) => {\n const { accepted, rejected } = withinPendingBudget(prev, mapped);\n if (rejected.length > 0) {\n setError(\n `Only ${mb(MAX_PENDING_BYTES)} of attachments can be staged at once. ${rejected.length} left off.`,\n );\n }\n return [...prev, ...accepted].slice(0, MAX_FILES);\n });\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Could not attach that file.');\n } finally {\n setBusyKind(null);\n }\n }, []);\n const remove = useCallback((id: string) => setPending((prev) => prev.filter((a) => a.id !== id)), []);\n const clear = useCallback(() => setPending([]), []);\n const forSend = useCallback(() => (pending.length > 0 ? pending.map((a) => ({ ...a })) : undefined), [pending]);\n const busy = busyKind !== null;\n\n return useMemo(\n () => ({\n pending,\n busy,\n busyKind,\n error,\n pickFromLibrary,\n captureFromCamera,\n pickDocuments,\n remove,\n clear,\n forSend,\n }),\n [pending, busy, busyKind, error, pickFromLibrary, captureFromCamera, pickDocuments, remove, clear, forSend],\n );\n}\n\nexport const IMAGE_ATTACHMENT_LIMITS = {\n MAX_EDGE,\n FALLBACK_EDGE,\n SHRINK_PAS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A,WAAA,CAAY,CAAC,EAAA,KAAe,WAAW,CAAQ,IAAA,KAAA,IAAA,CAAK,MAAO,CAAA,CAAA,CAAA,KAAK,EAAE,EAAO,KAAA,EAAE,CAAC,CAAA,EAAG,EAAE,CAAA;AAChG,EAAM,MAAA,KAAA,GAAQ,YAAY,MAAM,UAAA,CAAW,EAAE,CAAA,EAAG,EAAE,CAAA;AAClD,EAAA,MAAM,OAAU,GAAA,WAAA,CAAY,MAAM,OAAA,CAAQ,SAAS,CAAI,GAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,CAAA,KAAM,mBACpE,CACH,CAAA,CAAA,GAAI,MAAW,EAAA,CAAC,OAAO,CAAC,CAAA;AAC1B,EAAA,MAAM,OAAO,QAAa,KAAA,IAAA;AAC1B,EAAA,OAAO,QAAQ,OAAO;AAAA,IACpB,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACE,CAAA,EAAA,CAAC,OAAS,EAAA,IAAA,EAAM,QAAU,EAAA,KAAA,EAAO,eAAiB,EAAA,iBAAA,EAAmB,aAAe,EAAA,MAAA,EAAQ,KAAO,EAAA,OAAO,CAAC,CAAA;AACjH"}
@@ -1,4 +1,4 @@
1
- import {jsx,jsxs}from'react/jsx-runtime';import {memo,useMemo}from'react';import {Platform,StyleSheet,ScrollView,View,Text,Linking}from'react-native';import Markdown,{MarkdownIt,hasParents}from'react-native-markdown-display';import {ChatCodeBlock}from'./ChatCodeBlock.js';import {ChatImage}from'./ChatImage.js';import {prepareAssistantMarkdown}from'./streamingMarkdown.js';const ASSISTANT_MARKDOWN_IT = MarkdownIt({
1
+ import {jsx,jsxs}from'react/jsx-runtime';import React__default,{memo,useMemo}from'react';import {Platform,StyleSheet,ScrollView,View,Text}from'react-native';import Markdown,{MarkdownIt,hasParents}from'react-native-markdown-display';import {ChatCodeBlock}from'./ChatCodeBlock.js';import {ChatImage}from'./ChatImage.js';import {prepareAssistantMarkdown}from'./streamingMarkdown.js';import {useChatLinkOpener}from'../links/chatLinkOpener.js';const ASSISTANT_MARKDOWN_IT = MarkdownIt({
2
2
  html: false,
3
3
  breaks: true,
4
4
  linkify: true,
@@ -20,10 +20,6 @@ function fenceNodeContent(node) {
20
20
  code: raw.replace(/\n$/, "")
21
21
  };
22
22
  }
23
- function openMarkdownLink(url) {
24
- void Linking.openURL(url);
25
- return false;
26
- }
27
23
  const AssistantMarkdown = memo(function AssistantMarkdown2({
28
24
  text,
29
25
  streaming = false,
@@ -32,8 +28,13 @@ const AssistantMarkdown = memo(function AssistantMarkdown2({
32
28
  const source = useMemo(() => prepareAssistantMarkdown(text, streaming), [text, streaming]);
33
29
  const style = useMemo(() => assistantMarkdownStyle(isDark), [isDark]);
34
30
  const rules = useMemo(() => assistantMarkdownRules(isDark), [isDark]);
31
+ const openLink = useChatLinkOpener();
32
+ const onLinkPress = React__default.useCallback((url) => {
33
+ openLink(url);
34
+ return false;
35
+ }, [openLink]);
35
36
  if (!source.trim()) return null;
36
- return /* @__PURE__ */ jsx(Markdown, { markdownit: ASSISTANT_MARKDOWN_IT, style, rules, onLinkPress: openMarkdownLink, children: source });
37
+ return /* @__PURE__ */ jsx(Markdown, { markdownit: ASSISTANT_MARKDOWN_IT, style, rules, onLinkPress, children: source });
37
38
  });
38
39
  function holdsImage(node) {
39
40
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantMarkdown.js","sources":["../../../src/features/chat/AssistantMarkdown.tsx"],"sourcesContent":["/**\n * Native stand-in for browser `FormattedMessageContent` (remark-gfm +\n * CodeBlockWithActions). Same GFM surface: headings, lists, tables, quotes,\n * autolinks, orange inline code, wrapping fenced cards.\n */\nimport React, { memo, useMemo } from 'react';\nimport { Linking, Platform, ScrollView, StyleSheet, Text as RNText, View } from 'react-native';\nimport Markdown, { MarkdownIt, hasParents } from 'react-native-markdown-display';\nimport { ChatCodeBlock } from './ChatCodeBlock';\nimport { ChatImage } from './ChatImage';\nimport { prepareAssistantMarkdown } from './streamingMarkdown';\n\nconst ASSISTANT_MARKDOWN_IT = MarkdownIt({\n html: false,\n breaks: true,\n linkify: true,\n typographer: true,\n});\n\ntype MarkdownNode = {\n key?: string;\n type?: string;\n attributes?: { src?: string; alt?: string };\n children?: MarkdownNode[];\n};\n\ntype FenceNode = {\n key?: string;\n content?: string;\n sourceInfo?: string;\n children?: Array<{ content?: string; children?: FenceNode['children'] }>;\n};\n\nfunction flattenNodeText(node: { content?: string; children?: FenceNode['children'] } | undefined): string {\n if (!node) return '';\n const own = typeof node.content === 'string' ? node.content : '';\n const kids = (node.children ?? []).map(flattenNodeText).join('');\n return own + kids;\n}\n\nfunction fenceNodeContent(node: FenceNode): { language: string; code: string } {\n const language = (node.sourceInfo || '').trim() || 'code';\n const raw = String(node.content ?? '').trim() ? String(node.content ?? '') : flattenNodeText(node);\n return { language, code: raw.replace(/\\n$/, '') };\n}\n\nfunction openMarkdownLink(url: string) {\n void Linking.openURL(url);\n return false;\n}\n\nexport const AssistantMarkdown = memo(function AssistantMarkdown({\n text,\n streaming = false,\n isDark = false,\n}: {\n text: string;\n streaming?: boolean;\n isDark?: boolean;\n}) {\n const source = useMemo(() => prepareAssistantMarkdown(text, streaming), [text, streaming]);\n const style = useMemo(() => assistantMarkdownStyle(isDark), [isDark]);\n const rules = useMemo(() => assistantMarkdownRules(isDark), [isDark]);\n if (!source.trim()) return null;\n return (\n <Markdown markdownit={ASSISTANT_MARKDOWN_IT} style={style} rules={rules} onLinkPress={openMarkdownLink}>\n {source}\n </Markdown>\n );\n});\n\n/** Whether a paragraph carries an image - it then has to lay out as a block, not a line of text. */\nfunction holdsImage(node: MarkdownNode): boolean {\n return (node.children ?? []).some((child) => child.type === 'image' || holdsImage(child));\n}\n\nexport function assistantMarkdownRules(isDark: boolean) {\n const ink = isDark ? '#f3f5f8' : '#121926';\n const muted = isDark ? '#aab3c2' : '#667085';\n return {\n fence: (node: FenceNode) => {\n const { language, code } = fenceNodeContent(node);\n return <ChatCodeBlock key={node.key} language={language} code={code} isDark={isDark} />;\n },\n code_block: (node: FenceNode) => {\n const { language, code } = fenceNodeContent(node);\n return (\n <ChatCodeBlock\n key={node.key}\n language={language}\n code={code || flattenNodeText(node)}\n isDark={isDark}\n />\n );\n },\n html_inline: (node: { key?: string; content?: string }) => <RNText key={node.key}>{node.content}</RNText>,\n html_block: (node: { key?: string; content?: string }) => <RNText key={node.key}>{node.content}</RNText>,\n // View + flexWrap rows clip mixed inline code and inflate list gaps.\n // Render copy as Text (same as web <p>) so lines wrap - except around\n // an image: an image inside Text gets no width to size itself from and\n // renders as nothing.\n paragraph: (node: MarkdownNode, children: React.ReactNode[], parent: unknown[]) => {\n const inList = hasParents(parent, 'list_item');\n if (holdsImage(node)) {\n return (\n <View key={node.key} style={inList ? [local.pBlock, local.pInList] : local.pBlock}>\n {children}\n </View>\n );\n }\n return (\n <RNText\n key={node.key}\n style={inList ? [local.p, local.pInList, { color: ink }] : [local.p, { color: ink }]}\n >\n {children}\n </RNText>\n );\n },\n image: (node: MarkdownNode) =>\n node.attributes?.src ? (\n <ChatImage key={node.key} src={node.attributes.src} alt={node.attributes.alt} isDark={isDark} />\n ) : null,\n hardbreak: (node: { key?: string }) => <RNText key={node.key}>{'\\n'}</RNText>,\n softbreak: (node: { key?: string }) => <RNText key={node.key}> </RNText>,\n list_item: (\n node: { key?: string; index?: number; markup?: string },\n children: React.ReactNode[],\n parent: unknown[],\n ) => {\n if (hasParents(parent, 'bullet_list')) {\n return (\n <View key={node.key} style={local.li}>\n <RNText style={[local.bullet, { color: muted }]} accessible={false}>\n {'\\u2022'}\n </RNText>\n <View style={local.liBody}>{children}</View>\n </View>\n );\n }\n if (hasParents(parent, 'ordered_list')) {\n const ordered = [...parent].reverse().find((el: { type?: string }) => el?.type === 'ordered_list') as\n | { attributes?: { start?: number } }\n | undefined;\n const start = ordered?.attributes?.start ?? 1;\n const n = start + (node.index ?? 0);\n return (\n <View key={node.key} style={local.li}>\n <RNText style={[local.olMarker, { color: muted }]}>{n}.</RNText>\n <View style={local.liBody}>{children}</View>\n </View>\n );\n }\n return (\n <View key={node.key} style={local.li}>\n {children}\n </View>\n );\n },\n table: (\n node: { key?: string },\n children: React.ReactNode[],\n _parent: unknown,\n styles: Record<string, unknown>,\n ) => (\n <ScrollView\n key={node.key}\n horizontal\n nestedScrollEnabled\n showsHorizontalScrollIndicator={false}\n style={local.tableScroll}\n contentContainerStyle={local.tableScrollContent}\n >\n <View style={styles._VIEW_SAFE_table as object}>{children}</View>\n </ScrollView>\n ),\n };\n}\n\nfunction assistantMarkdownStyle(isDark: boolean) {\n const ink = isDark ? '#f3f5f8' : '#121926';\n const muted = isDark ? '#aab3c2' : '#667085';\n const border = isDark ? '#2a3240' : '#e3e7ee';\n const borderStrong = isDark ? '#364052' : '#cfd7e3';\n const surface = isDark ? '#171a20' : '#f6f7f8';\n const inlineBg = isDark ? 'rgba(251, 146, 60, 0.14)' : 'rgba(249, 115, 22, 0.1)';\n const inlineFg = isDark ? '#ffb36b' : '#d96b00';\n const mono = Platform.OS === 'ios' ? 'Menlo' : 'monospace';\n\n return {\n body: {\n color: ink,\n fontSize: 16,\n lineHeight: 26,\n },\n heading1: {\n flexDirection: 'row' as const,\n fontSize: 22,\n fontWeight: '600' as const,\n letterSpacing: -0.3,\n marginTop: 22,\n marginBottom: 12,\n color: ink,\n },\n heading2: {\n flexDirection: 'row' as const,\n fontSize: 20,\n fontWeight: '600' as const,\n letterSpacing: -0.3,\n marginTop: 20,\n marginBottom: 10,\n color: ink,\n },\n heading3: {\n flexDirection: 'row' as const,\n fontSize: 18,\n fontWeight: '600' as const,\n marginTop: 16,\n marginBottom: 8,\n color: ink,\n },\n heading4: {\n flexDirection: 'row' as const,\n fontSize: 16,\n fontWeight: '600' as const,\n marginTop: 14,\n marginBottom: 6,\n color: ink,\n },\n heading5: {\n flexDirection: 'row' as const,\n fontSize: 15,\n fontWeight: '600' as const,\n marginTop: 12,\n marginBottom: 6,\n color: ink,\n },\n heading6: {\n flexDirection: 'row' as const,\n fontSize: 14,\n fontWeight: '600' as const,\n marginTop: 12,\n marginBottom: 6,\n color: ink,\n },\n hr: {\n backgroundColor: border,\n height: StyleSheet.hairlineWidth,\n marginVertical: 20,\n },\n strong: { fontWeight: '600' as const, color: ink },\n em: { fontStyle: 'italic' as const, color: muted },\n s: { textDecorationLine: 'line-through' as const },\n paragraph: {\n marginTop: 0,\n marginBottom: 0,\n color: ink,\n },\n text: { color: ink },\n blockquote: {\n backgroundColor: 'transparent',\n borderColor: borderStrong,\n borderLeftWidth: 2,\n marginLeft: 0,\n marginVertical: 16,\n paddingHorizontal: 16,\n paddingVertical: 4,\n },\n bullet_list: { marginTop: 4, marginBottom: 16 },\n ordered_list: { marginTop: 4, marginBottom: 16 },\n list_item: {\n marginVertical: 0,\n flexDirection: 'row' as const,\n alignItems: 'flex-start' as const,\n },\n bullet_list_icon: { color: muted },\n ordered_list_icon: { color: muted },\n bullet_list_content: { flexGrow: 0, flexShrink: 1, minWidth: 0 },\n ordered_list_content: { flexGrow: 0, flexShrink: 1, minWidth: 0 },\n code_inline: {\n borderWidth: 0,\n padding: 0,\n paddingHorizontal: 6,\n paddingVertical: 2,\n borderRadius: 5,\n backgroundColor: inlineBg,\n color: inlineFg,\n fontSize: 14,\n fontFamily: mono,\n },\n table: {\n borderWidth: 1,\n borderColor: border,\n borderRadius: 12,\n marginVertical: 12,\n overflow: 'hidden' as const,\n },\n thead: { backgroundColor: surface },\n th: {\n flex: 1,\n paddingVertical: 10,\n paddingHorizontal: 12,\n fontWeight: '600' as const,\n fontSize: 12,\n color: muted,\n },\n td: {\n flex: 1,\n paddingVertical: 10,\n paddingHorizontal: 12,\n color: ink,\n },\n tr: {\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderColor: border,\n flexDirection: 'row' as const,\n },\n link: {\n color: ink,\n textDecorationLine: 'underline' as const,\n },\n };\n}\n\nconst local = StyleSheet.create({\n p: {\n fontSize: 16,\n lineHeight: 26,\n marginBottom: 16,\n },\n pInList: {\n marginBottom: 0,\n },\n // A paragraph holding an image: a block, spaced like a text paragraph.\n pBlock: {\n width: '100%',\n marginBottom: 16,\n },\n li: {\n flexDirection: 'row',\n alignItems: 'flex-start',\n width: '100%',\n marginVertical: 5,\n flexGrow: 0,\n },\n liBody: {\n flex: 1,\n minWidth: 0,\n flexShrink: 1,\n flexGrow: 1,\n },\n bullet: {\n width: 18,\n fontSize: 16,\n lineHeight: 26,\n marginRight: 6,\n },\n olMarker: {\n minWidth: 22,\n fontSize: 16,\n lineHeight: 26,\n marginRight: 8,\n },\n tableScroll: { flexGrow: 0, marginVertical: 8 },\n tableScrollContent: { flexGrow: 0 },\n});\n"],"names":["AssistantMarkdown","RNText"],"mappings":"qXAWA,MAAM,wBAAwB,UAAW,CAAA;AAAA,EACvC,IAAM,EAAA,KAAA;AAAA,EACN,MAAQ,EAAA,IAAA;AAAA,EACR,OAAS,EAAA,IAAA;AAAA,EACT,WAAa,EAAA;AACf,CAAC,CAAA;AAmBD,SAAS,gBAAgB,IAGF,EAAA;AAtCvB,EAAA,IAAA,EAAA;AAuCE,EAAI,IAAA,CAAC,MAAa,OAAA,EAAA;AAClB,EAAA,MAAM,MAAM,OAAO,IAAA,CAAK,OAAY,KAAA,QAAA,GAAW,KAAK,OAAU,GAAA,EAAA;AAC9D,EAAM,MAAA,IAAA,GAAA,CAAA,CAAQ,EAAK,GAAA,IAAA,CAAA,QAAA,KAAL,IAAiB,GAAA,EAAA,GAAA,IAAI,GAAI,CAAA,eAAe,CAAE,CAAA,IAAA,CAAK,EAAE,CAAA;AAC/D,EAAA,OAAO,GAAM,GAAA,IAAA;AACf;AACA,SAAS,iBAAiB,IAGxB,EAAA;AA/CF,EAAA,IAAA,EAAA,EAAA,EAAA;AAgDE,EAAA,MAAM,QAAY,GAAA,CAAA,IAAA,CAAK,UAAc,IAAA,EA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AU,EAAA,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,WAAa,EAAA;AAAA,GACf;AAAA,EACA,WAAa,EAAA;AAAA,IACX,QAAU,EAAA,CAAA;AAAA,IACV,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,kBAAoB,EAAA;AAAA,IAClB,QAAU,EAAA;AAAA;AAEd,CAAC,CAAA"}
1
+ {"version":3,"file":"AssistantMarkdown.js","sources":["../../../src/features/chat/AssistantMarkdown.tsx"],"sourcesContent":["/**\n * Native stand-in for browser `FormattedMessageContent` (remark-gfm +\n * CodeBlockWithActions). Same GFM surface: headings, lists, tables, quotes,\n * autolinks, orange inline code, wrapping fenced cards.\n */\nimport React, { memo, useMemo } from 'react';\nimport { Platform, ScrollView, StyleSheet, Text as RNText, View } from 'react-native';\nimport Markdown, { MarkdownIt, hasParents } from 'react-native-markdown-display';\nimport { ChatCodeBlock } from './ChatCodeBlock';\nimport { ChatImage } from './ChatImage';\nimport { prepareAssistantMarkdown } from './streamingMarkdown';\nimport { useChatLinkOpener } from '../links/chatLinkOpener';\n\nconst ASSISTANT_MARKDOWN_IT = MarkdownIt({\n html: false,\n breaks: true,\n linkify: true,\n typographer: true,\n});\n\ntype MarkdownNode = {\n key?: string;\n type?: string;\n attributes?: { src?: string; alt?: string };\n children?: MarkdownNode[];\n};\n\ntype FenceNode = {\n key?: string;\n content?: string;\n sourceInfo?: string;\n children?: Array<{ content?: string; children?: FenceNode['children'] }>;\n};\n\nfunction flattenNodeText(node: { content?: string; children?: FenceNode['children'] } | undefined): string {\n if (!node) return '';\n const own = typeof node.content === 'string' ? node.content : '';\n const kids = (node.children ?? []).map(flattenNodeText).join('');\n return own + kids;\n}\n\nfunction fenceNodeContent(node: FenceNode): { language: string; code: string } {\n const language = (node.sourceInfo || '').trim() || 'code';\n const raw = String(node.content ?? '').trim() ? String(node.content ?? '') : flattenNodeText(node);\n return { language, code: raw.replace(/\\n$/, '') };\n}\n\nexport const AssistantMarkdown = memo(function AssistantMarkdown({\n text,\n streaming = false,\n isDark = false,\n}: {\n text: string;\n streaming?: boolean;\n isDark?: boolean;\n}) {\n const source = useMemo(() => prepareAssistantMarkdown(text, streaming), [text, streaming]);\n const style = useMemo(() => assistantMarkdownStyle(isDark), [isDark]);\n const rules = useMemo(() => assistantMarkdownRules(isDark), [isDark]);\n // In the app on its surface when the link belongs there, else a browser sheet.\n const openLink = useChatLinkOpener();\n const onLinkPress = React.useCallback(\n (url: string) => {\n openLink(url);\n // Handled here: false keeps the library from also handing it to Linking.\n return false;\n },\n [openLink],\n );\n if (!source.trim()) return null;\n return (\n <Markdown markdownit={ASSISTANT_MARKDOWN_IT} style={style} rules={rules} onLinkPress={onLinkPress}>\n {source}\n </Markdown>\n );\n});\n\n/** Whether a paragraph carries an image - it then has to lay out as a block, not a line of text. */\nfunction holdsImage(node: MarkdownNode): boolean {\n return (node.children ?? []).some((child) => child.type === 'image' || holdsImage(child));\n}\n\nexport function assistantMarkdownRules(isDark: boolean) {\n const ink = isDark ? '#f3f5f8' : '#121926';\n const muted = isDark ? '#aab3c2' : '#667085';\n return {\n fence: (node: FenceNode) => {\n const { language, code } = fenceNodeContent(node);\n return <ChatCodeBlock key={node.key} language={language} code={code} isDark={isDark} />;\n },\n code_block: (node: FenceNode) => {\n const { language, code } = fenceNodeContent(node);\n return (\n <ChatCodeBlock\n key={node.key}\n language={language}\n code={code || flattenNodeText(node)}\n isDark={isDark}\n />\n );\n },\n html_inline: (node: { key?: string; content?: string }) => <RNText key={node.key}>{node.content}</RNText>,\n html_block: (node: { key?: string; content?: string }) => <RNText key={node.key}>{node.content}</RNText>,\n // View + flexWrap rows clip mixed inline code and inflate list gaps.\n // Render copy as Text (same as web <p>) so lines wrap - except around\n // an image: an image inside Text gets no width to size itself from and\n // renders as nothing.\n paragraph: (node: MarkdownNode, children: React.ReactNode[], parent: unknown[]) => {\n const inList = hasParents(parent, 'list_item');\n if (holdsImage(node)) {\n return (\n <View key={node.key} style={inList ? [local.pBlock, local.pInList] : local.pBlock}>\n {children}\n </View>\n );\n }\n return (\n <RNText\n key={node.key}\n style={inList ? [local.p, local.pInList, { color: ink }] : [local.p, { color: ink }]}\n >\n {children}\n </RNText>\n );\n },\n image: (node: MarkdownNode) =>\n node.attributes?.src ? (\n <ChatImage key={node.key} src={node.attributes.src} alt={node.attributes.alt} isDark={isDark} />\n ) : null,\n hardbreak: (node: { key?: string }) => <RNText key={node.key}>{'\\n'}</RNText>,\n softbreak: (node: { key?: string }) => <RNText key={node.key}> </RNText>,\n list_item: (\n node: { key?: string; index?: number; markup?: string },\n children: React.ReactNode[],\n parent: unknown[],\n ) => {\n if (hasParents(parent, 'bullet_list')) {\n return (\n <View key={node.key} style={local.li}>\n <RNText style={[local.bullet, { color: muted }]} accessible={false}>\n {'\\u2022'}\n </RNText>\n <View style={local.liBody}>{children}</View>\n </View>\n );\n }\n if (hasParents(parent, 'ordered_list')) {\n const ordered = [...parent].reverse().find((el: { type?: string }) => el?.type === 'ordered_list') as\n | { attributes?: { start?: number } }\n | undefined;\n const start = ordered?.attributes?.start ?? 1;\n const n = start + (node.index ?? 0);\n return (\n <View key={node.key} style={local.li}>\n <RNText style={[local.olMarker, { color: muted }]}>{n}.</RNText>\n <View style={local.liBody}>{children}</View>\n </View>\n );\n }\n return (\n <View key={node.key} style={local.li}>\n {children}\n </View>\n );\n },\n table: (\n node: { key?: string },\n children: React.ReactNode[],\n _parent: unknown,\n styles: Record<string, unknown>,\n ) => (\n <ScrollView\n key={node.key}\n horizontal\n nestedScrollEnabled\n showsHorizontalScrollIndicator={false}\n style={local.tableScroll}\n contentContainerStyle={local.tableScrollContent}\n >\n <View style={styles._VIEW_SAFE_table as object}>{children}</View>\n </ScrollView>\n ),\n };\n}\n\nfunction assistantMarkdownStyle(isDark: boolean) {\n const ink = isDark ? '#f3f5f8' : '#121926';\n const muted = isDark ? '#aab3c2' : '#667085';\n const border = isDark ? '#2a3240' : '#e3e7ee';\n const borderStrong = isDark ? '#364052' : '#cfd7e3';\n const surface = isDark ? '#171a20' : '#f6f7f8';\n const inlineBg = isDark ? 'rgba(251, 146, 60, 0.14)' : 'rgba(249, 115, 22, 0.1)';\n const inlineFg = isDark ? '#ffb36b' : '#d96b00';\n const mono = Platform.OS === 'ios' ? 'Menlo' : 'monospace';\n\n return {\n body: {\n color: ink,\n fontSize: 16,\n lineHeight: 26,\n },\n heading1: {\n flexDirection: 'row' as const,\n fontSize: 22,\n fontWeight: '600' as const,\n letterSpacing: -0.3,\n marginTop: 22,\n marginBottom: 12,\n color: ink,\n },\n heading2: {\n flexDirection: 'row' as const,\n fontSize: 20,\n fontWeight: '600' as const,\n letterSpacing: -0.3,\n marginTop: 20,\n marginBottom: 10,\n color: ink,\n },\n heading3: {\n flexDirection: 'row' as const,\n fontSize: 18,\n fontWeight: '600' as const,\n marginTop: 16,\n marginBottom: 8,\n color: ink,\n },\n heading4: {\n flexDirection: 'row' as const,\n fontSize: 16,\n fontWeight: '600' as const,\n marginTop: 14,\n marginBottom: 6,\n color: ink,\n },\n heading5: {\n flexDirection: 'row' as const,\n fontSize: 15,\n fontWeight: '600' as const,\n marginTop: 12,\n marginBottom: 6,\n color: ink,\n },\n heading6: {\n flexDirection: 'row' as const,\n fontSize: 14,\n fontWeight: '600' as const,\n marginTop: 12,\n marginBottom: 6,\n color: ink,\n },\n hr: {\n backgroundColor: border,\n height: StyleSheet.hairlineWidth,\n marginVertical: 20,\n },\n strong: { fontWeight: '600' as const, color: ink },\n em: { fontStyle: 'italic' as const, color: muted },\n s: { textDecorationLine: 'line-through' as const },\n paragraph: {\n marginTop: 0,\n marginBottom: 0,\n color: ink,\n },\n text: { color: ink },\n blockquote: {\n backgroundColor: 'transparent',\n borderColor: borderStrong,\n borderLeftWidth: 2,\n marginLeft: 0,\n marginVertical: 16,\n paddingHorizontal: 16,\n paddingVertical: 4,\n },\n bullet_list: { marginTop: 4, marginBottom: 16 },\n ordered_list: { marginTop: 4, marginBottom: 16 },\n list_item: {\n marginVertical: 0,\n flexDirection: 'row' as const,\n alignItems: 'flex-start' as const,\n },\n bullet_list_icon: { color: muted },\n ordered_list_icon: { color: muted },\n bullet_list_content: { flexGrow: 0, flexShrink: 1, minWidth: 0 },\n ordered_list_content: { flexGrow: 0, flexShrink: 1, minWidth: 0 },\n code_inline: {\n borderWidth: 0,\n padding: 0,\n paddingHorizontal: 6,\n paddingVertical: 2,\n borderRadius: 5,\n backgroundColor: inlineBg,\n color: inlineFg,\n fontSize: 14,\n fontFamily: mono,\n },\n table: {\n borderWidth: 1,\n borderColor: border,\n borderRadius: 12,\n marginVertical: 12,\n overflow: 'hidden' as const,\n },\n thead: { backgroundColor: surface },\n th: {\n flex: 1,\n paddingVertical: 10,\n paddingHorizontal: 12,\n fontWeight: '600' as const,\n fontSize: 12,\n color: muted,\n },\n td: {\n flex: 1,\n paddingVertical: 10,\n paddingHorizontal: 12,\n color: ink,\n },\n tr: {\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderColor: border,\n flexDirection: 'row' as const,\n },\n link: {\n color: ink,\n textDecorationLine: 'underline' as const,\n },\n };\n}\n\nconst local = StyleSheet.create({\n p: {\n fontSize: 16,\n lineHeight: 26,\n marginBottom: 16,\n },\n pInList: {\n marginBottom: 0,\n },\n // A paragraph holding an image: a block, spaced like a text paragraph.\n pBlock: {\n width: '100%',\n marginBottom: 16,\n },\n li: {\n flexDirection: 'row',\n alignItems: 'flex-start',\n width: '100%',\n marginVertical: 5,\n flexGrow: 0,\n },\n liBody: {\n flex: 1,\n minWidth: 0,\n flexShrink: 1,\n flexGrow: 1,\n },\n bullet: {\n width: 18,\n fontSize: 16,\n lineHeight: 26,\n marginRight: 6,\n },\n olMarker: {\n minWidth: 22,\n fontSize: 16,\n lineHeight: 26,\n marginRight: 8,\n },\n tableScroll: { flexGrow: 0, marginVertical: 8 },\n tableScrollContent: { flexGrow: 0 },\n});\n"],"names":["AssistantMarkdown","React","RNText"],"mappings":"ubAYA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,CAAA;AAAA,EAC9B,CAAG,EAAA;AAAA,IACD,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,OAAS,EAAA;AAAA,IACP,YAAc,EAAA;AAAA,GAChB;AAAA;AAAA,EAEA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,MAAA;AAAA,IACP,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,YAAA;AAAA,IACZ,KAAO,EAAA,MAAA;AAAA,IACP,cAAgB,EAAA,CAAA;AAAA,IAChB,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,CAAA;AAAA,IACN,QAAU,EAAA,CAAA;AAAA,IACV,UAAY,EAAA,CAAA;AAAA,IACZ,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,EAAA;AAAA,IACP,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,WAAa,EAAA;AAAA,GACf;AAAA,EACA,QAAU,EAAA;AAAA,IACR,QAAU,EAAA,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,WAAa,EAAA;AAAA,GACf;AAAA,EACA,WAAa,EAAA;AAAA,IACX,QAAU,EAAA,CAAA;AAAA,IACV,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,kBAAoB,EAAA;AAAA,IAClB,QAAU,EAAA;AAAA;AAEd,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
- import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {useRef,useMemo,useCallback,useEffect,memo}from'react';import {View,StyleSheet,FlatList,Platform,Pressable,Text}from'react-native';import {dismissKeyboard}from'../../utils/keyboardController.js';import {useKeyboardLiftHeight}from'../../components/KeyboardComposerDock.js';import Markdown from'react-native-markdown-display';import {shouldRenderUserTranscriptTurn,displayUserMessageText}from'../attachments/displayUserMessageText.js';import {MessageAttachmentPreviews}from'../attachments/MessageAttachmentPreviews.js';import {ToolTimeline}from'./ToolTimeline.js';import {ChatWidgetCard}from'./ChatWidgetCard.js';import {splitChatWidgets}from'./chatWidgets.js';import {parseToolActivity}from'./toolActivity.js';import {parseAskUser,displayAskUserAssistantText,stripAskUser}from'./askUser.js';import {collapseDuplicateUserRows,groupConsecutiveRoleRows}from'./transcriptGroups.js';import {AssistantMarkdown}from'./AssistantMarkdown.js';import {PreResponseStrip}from'./PreResponseStrip.js';import {splitPreResponse}from'./preResponse.js';var __defProp = Object.defineProperty;
1
+ import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {useRef,useMemo,useCallback,useEffect,memo}from'react';import {View,StyleSheet,FlatList,Platform,Pressable,Text}from'react-native';import {dismissKeyboard}from'../../utils/keyboardController.js';import {useKeyboardLiftHeight}from'../../components/KeyboardComposerDock.js';import Markdown from'react-native-markdown-display';import {shouldRenderUserTranscriptTurn,displayUserMessageText}from'../attachments/displayUserMessageText.js';import {MessageAttachmentPreviews}from'../attachments/MessageAttachmentPreviews.js';import {ToolTimeline}from'./ToolTimeline.js';import {ChatWidgetCard}from'./ChatWidgetCard.js';import {splitChatWidgets}from'./chatWidgets.js';import {parseToolActivity}from'./toolActivity.js';import {parseAskUser,displayAskUserAssistantText,stripAskUser}from'./askUser.js';import {collapseDuplicateUserRows,groupConsecutiveRoleRows}from'./transcriptGroups.js';import {AssistantMarkdown}from'./AssistantMarkdown.js';import {useChatLinkOpener}from'../links/chatLinkOpener.js';import {autolinkBareUrls}from'../messaging/chatLinks.js';import {PreResponseStrip}from'./PreResponseStrip.js';import {splitPreResponse}from'./preResponse.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -165,6 +165,11 @@ const TranscriptGroupView = memo(function TranscriptGroupView2({
165
165
  isDark,
166
166
  renderMessageActions
167
167
  }) {
168
+ const openLink = useChatLinkOpener();
169
+ const onLinkPress = useCallback((url) => {
170
+ openLink(url);
171
+ return false;
172
+ }, [openLink]);
168
173
  if (group.role === "user") {
169
174
  return /* @__PURE__ */ jsx(Pressable, { style: styles.userCol, onPress: dismissKeyboard, accessible: false, children: group.items.map((item, index) => {
170
175
  var _a, _b;
@@ -173,7 +178,7 @@ const TranscriptGroupView = memo(function TranscriptGroupView2({
173
178
  if (!text && attachments.length === 0) return null;
174
179
  return /* @__PURE__ */ jsxs(View, { style: [styles.userTurn, index > 0 && styles.userFollow], children: [
175
180
  attachments.length > 0 ? /* @__PURE__ */ jsx(MessageAttachmentPreviews, { attachments, align: "end", isDark }) : null,
176
- text ? /* @__PURE__ */ jsx(View, { style: [styles.userBubble, item.queued && styles.userBubbleQueued], children: /* @__PURE__ */ jsx(Markdown, { style: USER_MARKDOWN, children: text }) }) : null,
181
+ text ? /* @__PURE__ */ jsx(View, { style: [styles.userBubble, item.queued && styles.userBubbleQueued], children: /* @__PURE__ */ jsx(Markdown, { style: USER_MARKDOWN, onLinkPress, children: autolinkBareUrls(text) }) }) : null,
177
182
  item.queued ? /* @__PURE__ */ jsx(Text, { style: [styles.queuedCaption, {
178
183
  color: isDark ? "#94a3b8" : "#64748b"
179
184
  }], children: "Queued \xB7 sends when the gateway connects" }) : null
@@ -218,6 +223,11 @@ const USER_MARKDOWN = {
218
223
  fontSize: 15,
219
224
  lineHeight: 22
220
225
  },
226
+ // White and underlined: the bubble is blue, so the usual blue link would vanish.
227
+ link: {
228
+ color: "#ffffff",
229
+ textDecorationLine: "underline"
230
+ },
221
231
  paragraph: {
222
232
  marginTop: 4,
223
233
  marginBottom: 4,