@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-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 (376) hide show
  1. package/.claude-flow/data/pending-insights.jsonl +43 -0
  2. package/.claude-flow/sessions/session-1794323376548.json +14 -0
  3. package/CHANGELOG.md +31 -0
  4. package/jest.config.cjs +22 -0
  5. package/lib/assets/home/loop-day.jpg +0 -0
  6. package/lib/assets/home/loop-day.mp4 +0 -0
  7. package/lib/assets/home/loop-time-back.jpg +0 -0
  8. package/lib/assets/home/loop-time-back.mp4 +0 -0
  9. package/lib/assets/home/loop-where.jpg +0 -0
  10. package/lib/assets/home/loop-where.mp4 +0 -0
  11. package/lib/assets/home/reel-gym.jpg +0 -0
  12. package/lib/assets/home/reel-gym.mp4 +0 -0
  13. package/lib/assets/home/reel-internet.jpg +0 -0
  14. package/lib/assets/home/reel-internet.mp4 +0 -0
  15. package/lib/assets/icon.png +0 -0
  16. package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  17. package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
  18. package/lib/assets/lottie/lucy-mark-call.json +1470 -0
  19. package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
  20. package/lib/assets/lottie/lucy-mark-details.json +1735 -0
  21. package/lib/assets/lottie/lucy-mark-email.json +1363 -0
  22. package/lib/assets/lottie/lucy-mark-message.json +1154 -0
  23. package/lib/assets/lottie/lucy-mark-search.json +1067 -0
  24. package/lib/assets/lottie/lucy-mark-think.json +1253 -0
  25. package/lib/assets/lottie/lucy-mark-write.json +1532 -0
  26. package/lib/assets/lottie/time-back.json +16458 -0
  27. package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
  28. package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
  29. package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  30. package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  31. package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  32. package/lib/assets/sounds/hours-back.m4a +0 -0
  33. package/lib/assets/sounds/meet-lucy.m4a +0 -0
  34. package/lib/assets/sounds/power-on.m4a +0 -0
  35. package/lib/assets/sounds/wind-back.m4a +0 -0
  36. package/lib/assets/sounds/youre-in.m4a +0 -0
  37. package/lib/chat/agent.js +358 -0
  38. package/lib/chat/agent.js.map +1 -0
  39. package/lib/chat/appFront.js +32 -0
  40. package/lib/chat/appFront.js.map +1 -0
  41. package/lib/chat/auth.js +370 -0
  42. package/lib/chat/auth.js.map +1 -0
  43. package/lib/chat/chores.js +360 -0
  44. package/lib/chat/chores.js.map +1 -0
  45. package/lib/chat/connectors.js +42 -0
  46. package/lib/chat/connectors.js.map +1 -0
  47. package/lib/chat/jobs.js +223 -0
  48. package/lib/chat/jobs.js.map +1 -0
  49. package/lib/chat/lucyMotion.js +6 -0
  50. package/lib/chat/lucyMotion.js.map +1 -0
  51. package/lib/chat/protocol.js +111 -0
  52. package/lib/chat/protocol.js.map +1 -0
  53. package/lib/chat/results.js +133 -0
  54. package/lib/chat/results.js.map +1 -0
  55. package/lib/chat/store.js +81 -0
  56. package/lib/chat/store.js.map +1 -0
  57. package/lib/chat/useDictation.js +168 -0
  58. package/lib/chat/useDictation.js.map +1 -0
  59. package/lib/chat/useLucyChat.js +451 -0
  60. package/lib/chat/useLucyChat.js.map +1 -0
  61. package/lib/chat/useMyComputer.js +32 -0
  62. package/lib/chat/useMyComputer.js.map +1 -0
  63. package/lib/chat/whereLucyWorks.js +52 -0
  64. package/lib/chat/whereLucyWorks.js.map +1 -0
  65. package/lib/chat/workspace.js +124 -0
  66. package/lib/chat/workspace.js.map +1 -0
  67. package/lib/components/AreaShot.js +289 -0
  68. package/lib/components/AreaShot.js.map +1 -0
  69. package/lib/components/Backdrops.js +262 -0
  70. package/lib/components/Backdrops.js.map +1 -0
  71. package/lib/components/BottomSheet.js +61 -0
  72. package/lib/components/BottomSheet.js.map +1 -0
  73. package/lib/components/ChatSheets.js +429 -0
  74. package/lib/components/ChatSheets.js.map +1 -0
  75. package/lib/components/ConnectorLogo.js +91 -0
  76. package/lib/components/ConnectorLogo.js.map +1 -0
  77. package/lib/components/CustomDrawer.js +534 -0
  78. package/lib/components/CustomDrawer.js.map +1 -0
  79. package/lib/components/IdeasPane.js +394 -0
  80. package/lib/components/IdeasPane.js.map +1 -0
  81. package/lib/components/ImessageSheet.js +261 -0
  82. package/lib/components/ImessageSheet.js.map +1 -0
  83. package/lib/components/KeyboardAvoider.js +29 -0
  84. package/lib/components/KeyboardAvoider.js.map +1 -0
  85. package/lib/components/Logo.js +81 -0
  86. package/lib/components/Logo.js.map +1 -0
  87. package/lib/components/LucyWorking.js +67 -0
  88. package/lib/components/LucyWorking.js.map +1 -0
  89. package/lib/components/Markdown.js +260 -0
  90. package/lib/components/Markdown.js.map +1 -0
  91. package/lib/components/Media.js +93 -0
  92. package/lib/components/Media.js.map +1 -0
  93. package/lib/components/MessagesAppIcon.js +23 -0
  94. package/lib/components/MessagesAppIcon.js.map +1 -0
  95. package/lib/components/MicButton.js +71 -0
  96. package/lib/components/MicButton.js.map +1 -0
  97. package/lib/components/ResultCards.js +974 -0
  98. package/lib/components/ResultCards.js.map +1 -0
  99. package/lib/components/SignInPrompt.js +148 -0
  100. package/lib/components/SignInPrompt.js.map +1 -0
  101. package/lib/components/SignedOut.js +38 -0
  102. package/lib/components/SignedOut.js.map +1 -0
  103. package/lib/components/TalkToLucyHero.js +487 -0
  104. package/lib/components/TalkToLucyHero.js.map +1 -0
  105. package/lib/components/TalkToLucySheet.js +182 -0
  106. package/lib/components/TalkToLucySheet.js.map +1 -0
  107. package/lib/components/WhereLucyWorks.js +277 -0
  108. package/lib/components/WhereLucyWorks.js.map +1 -0
  109. package/lib/components/WorkspaceSection.js +271 -0
  110. package/lib/components/WorkspaceSection.js.map +1 -0
  111. package/lib/components/YantraMark.js +13 -0
  112. package/lib/components/YantraMark.js.map +1 -0
  113. package/lib/components/drawerHeader.js +38 -0
  114. package/lib/components/drawerHeader.js.map +1 -0
  115. package/lib/components/lottieInstalled.js +6 -0
  116. package/lib/components/lottieInstalled.js.map +1 -0
  117. package/lib/components/ui.js +550 -0
  118. package/lib/components/ui.js.map +1 -0
  119. package/lib/components/useSignOut.js +7 -0
  120. package/lib/components/useSignOut.js.map +1 -0
  121. package/lib/components/viewport.js +121 -0
  122. package/lib/components/viewport.js.map +1 -0
  123. package/lib/components/voiceDial.js +10 -0
  124. package/lib/components/voiceDial.js.map +1 -0
  125. package/lib/compute.js +157 -0
  126. package/lib/compute.js.map +1 -0
  127. package/lib/config/env-config.js +21 -0
  128. package/lib/config/env-config.js.map +1 -0
  129. package/lib/config/routes.js +15 -0
  130. package/lib/config/routes.js.map +1 -0
  131. package/lib/content.js +25 -0
  132. package/lib/content.js.map +1 -0
  133. package/lib/hooks/keyboardCover.js +39 -0
  134. package/lib/hooks/keyboardCover.js.map +1 -0
  135. package/lib/hooks/useKeyboard.js +121 -0
  136. package/lib/hooks/useKeyboard.js.map +1 -0
  137. package/lib/hooks/useReducedMotion.js +13 -0
  138. package/lib/hooks/useReducedMotion.js.map +1 -0
  139. package/lib/imessage/openMessages.js +25 -0
  140. package/lib/imessage/openMessages.js.map +1 -0
  141. package/lib/imessage/platform.js +12 -0
  142. package/lib/imessage/platform.js.map +1 -0
  143. package/lib/imessage/textLink.js +262 -0
  144. package/lib/imessage/textLink.js.map +1 -0
  145. package/lib/index.js +1 -0
  146. package/lib/index.js.map +1 -0
  147. package/lib/live/card.js +28 -0
  148. package/lib/live/card.js.map +1 -0
  149. package/lib/live/liveActivity.js +144 -0
  150. package/lib/live/liveActivity.js.map +1 -0
  151. package/lib/module.js +3 -0
  152. package/lib/module.js.map +1 -0
  153. package/lib/offer/BlackFridayOffer.js +378 -0
  154. package/lib/offer/BlackFridayOffer.js.map +1 -0
  155. package/lib/offer/blackFriday.js +78 -0
  156. package/lib/offer/blackFriday.js.map +1 -0
  157. package/lib/offer/parts.js +624 -0
  158. package/lib/offer/parts.js.map +1 -0
  159. package/lib/offer/state.js +63 -0
  160. package/lib/offer/state.js.map +1 -0
  161. package/lib/push/push.js +142 -0
  162. package/lib/push/push.js.map +1 -0
  163. package/lib/push/usePushNotifications.js +39 -0
  164. package/lib/push/usePushNotifications.js.map +1 -0
  165. package/lib/routes.json +175 -0
  166. package/lib/screens/Account/index.js +209 -0
  167. package/lib/screens/Account/index.js.map +1 -0
  168. package/lib/screens/Chat/index.js +710 -0
  169. package/lib/screens/Chat/index.js.map +1 -0
  170. package/lib/screens/Chores/index.js +18 -0
  171. package/lib/screens/Chores/index.js.map +1 -0
  172. package/lib/screens/Connectors/index.js +17 -0
  173. package/lib/screens/Connectors/index.js.map +1 -0
  174. package/lib/screens/History/index.js +380 -0
  175. package/lib/screens/History/index.js.map +1 -0
  176. package/lib/screens/Home/index.js +2711 -0
  177. package/lib/screens/Home/index.js.map +1 -0
  178. package/lib/screens/Home/media.js +25 -0
  179. package/lib/screens/Home/media.js.map +1 -0
  180. package/lib/screens/Welcome/index.js +1066 -0
  181. package/lib/screens/Welcome/index.js.map +1 -0
  182. package/lib/talk/talkToLucy.js +139 -0
  183. package/lib/talk/talkToLucy.js.map +1 -0
  184. package/lib/theme/colors.js +29 -0
  185. package/lib/theme/colors.js.map +1 -0
  186. package/lib/theme/fonts.js +17 -0
  187. package/lib/theme/fonts.js.map +1 -0
  188. package/lib/theme/muse.js +134 -0
  189. package/lib/theme/muse.js.map +1 -0
  190. package/lib/utils/links.js +54 -0
  191. package/lib/utils/links.js.map +1 -0
  192. package/lib/utils/yantraLinks.js +68 -0
  193. package/lib/utils/yantraLinks.js.map +1 -0
  194. package/lib/welcome/flow.js +375 -0
  195. package/lib/welcome/flow.js.map +1 -0
  196. package/lib/welcome/haptics.js +125 -0
  197. package/lib/welcome/haptics.js.map +1 -0
  198. package/lib/welcome/parts.js +1996 -0
  199. package/lib/welcome/parts.js.map +1 -0
  200. package/lib/welcome/powerOn.js +29 -0
  201. package/lib/welcome/powerOn.js.map +1 -0
  202. package/lib/welcome/seen.js +41 -0
  203. package/lib/welcome/seen.js.map +1 -0
  204. package/lib/welcome/sound.js +110 -0
  205. package/lib/welcome/sound.js.map +1 -0
  206. package/package.json +66 -5
  207. package/rollup.config.mjs +42 -0
  208. package/src/.claude-flow/data/pending-insights.jsonl +19 -0
  209. package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
  210. package/src/__tests__/auth.test.ts +94 -0
  211. package/src/__tests__/blackFriday.test.ts +75 -0
  212. package/src/__tests__/cardTokens.test.ts +77 -0
  213. package/src/__tests__/chores.test.ts +179 -0
  214. package/src/__tests__/choresList.test.ts +100 -0
  215. package/src/__tests__/content.test.ts +54 -0
  216. package/src/__tests__/dictation.test.ts +186 -0
  217. package/src/__tests__/haptics.test.ts +202 -0
  218. package/src/__tests__/jobs.test.ts +130 -0
  219. package/src/__tests__/keyboardCover.test.ts +84 -0
  220. package/src/__tests__/liveCard.test.ts +39 -0
  221. package/src/__tests__/lockedPhone.test.ts +355 -0
  222. package/src/__tests__/lucyMotion.test.ts +34 -0
  223. package/src/__tests__/platform.test.ts +32 -0
  224. package/src/__tests__/powerOn.test.ts +62 -0
  225. package/src/__tests__/protocol.test.ts +125 -0
  226. package/src/__tests__/push.test.ts +111 -0
  227. package/src/__tests__/results.test.ts +256 -0
  228. package/src/__tests__/sound.test.ts +248 -0
  229. package/src/__tests__/talkToLucy.test.ts +205 -0
  230. package/src/__tests__/textLink.test.ts +91 -0
  231. package/src/__tests__/voiceDial.test.ts +53 -0
  232. package/src/__tests__/welcomeFlow.test.ts +157 -0
  233. package/src/__tests__/whereLucyWorks.test.ts +81 -0
  234. package/src/__tests__/yantraLinks.test.ts +96 -0
  235. package/src/assets/home/loop-day.jpg +0 -0
  236. package/src/assets/home/loop-day.mp4 +0 -0
  237. package/src/assets/home/loop-time-back.jpg +0 -0
  238. package/src/assets/home/loop-time-back.mp4 +0 -0
  239. package/src/assets/home/loop-where.jpg +0 -0
  240. package/src/assets/home/loop-where.mp4 +0 -0
  241. package/src/assets/home/reel-gym.jpg +0 -0
  242. package/src/assets/home/reel-gym.mp4 +0 -0
  243. package/src/assets/home/reel-internet.jpg +0 -0
  244. package/src/assets/home/reel-internet.mp4 +0 -0
  245. package/src/assets/icon.png +0 -0
  246. package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  247. package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
  248. package/src/assets/lottie/lucy-mark-call.json +1470 -0
  249. package/src/assets/lottie/lucy-mark-connect.json +2552 -0
  250. package/src/assets/lottie/lucy-mark-details.json +1735 -0
  251. package/src/assets/lottie/lucy-mark-email.json +1363 -0
  252. package/src/assets/lottie/lucy-mark-message.json +1154 -0
  253. package/src/assets/lottie/lucy-mark-search.json +1067 -0
  254. package/src/assets/lottie/lucy-mark-think.json +1253 -0
  255. package/src/assets/lottie/lucy-mark-write.json +1532 -0
  256. package/src/assets/lottie/time-back.json +16458 -0
  257. package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
  258. package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
  259. package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  260. package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  261. package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  262. package/src/assets/sounds/hours-back.m4a +0 -0
  263. package/src/assets/sounds/meet-lucy.m4a +0 -0
  264. package/src/assets/sounds/power-on.m4a +0 -0
  265. package/src/assets/sounds/wind-back.m4a +0 -0
  266. package/src/assets/sounds/youre-in.m4a +0 -0
  267. package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
  268. package/src/chat/agent.ts +376 -0
  269. package/src/chat/appFront.ts +39 -0
  270. package/src/chat/auth.ts +433 -0
  271. package/src/chat/chores.ts +394 -0
  272. package/src/chat/connectors.ts +65 -0
  273. package/src/chat/jobs.ts +228 -0
  274. package/src/chat/lucyMotion.ts +33 -0
  275. package/src/chat/protocol.ts +192 -0
  276. package/src/chat/results.ts +224 -0
  277. package/src/chat/store.ts +87 -0
  278. package/src/chat/useDictation.ts +201 -0
  279. package/src/chat/useLucyChat.ts +458 -0
  280. package/src/chat/useMyComputer.ts +41 -0
  281. package/src/chat/whereLucyWorks.ts +97 -0
  282. package/src/chat/workspace.ts +127 -0
  283. package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
  284. package/src/components/AreaShot.tsx +239 -0
  285. package/src/components/Backdrops.tsx +323 -0
  286. package/src/components/BottomSheet.tsx +96 -0
  287. package/src/components/ChatSheets.tsx +565 -0
  288. package/src/components/ConnectorLogo.tsx +116 -0
  289. package/src/components/CustomDrawer.tsx +526 -0
  290. package/src/components/IdeasPane.tsx +318 -0
  291. package/src/components/ImessageSheet.tsx +280 -0
  292. package/src/components/KeyboardAvoider.tsx +45 -0
  293. package/src/components/Logo.tsx +97 -0
  294. package/src/components/LucyWorking.tsx +122 -0
  295. package/src/components/Markdown.tsx +219 -0
  296. package/src/components/Media.tsx +173 -0
  297. package/src/components/MessagesAppIcon.tsx +51 -0
  298. package/src/components/MicButton.tsx +92 -0
  299. package/src/components/ResultCards.tsx +1067 -0
  300. package/src/components/SignInPrompt.tsx +182 -0
  301. package/src/components/SignedOut.tsx +47 -0
  302. package/src/components/TalkToLucyHero.tsx +540 -0
  303. package/src/components/TalkToLucySheet.tsx +208 -0
  304. package/src/components/VoiceOrb.tsx +364 -0
  305. package/src/components/WhereLucyWorks.tsx +261 -0
  306. package/src/components/WorkspaceSection.tsx +307 -0
  307. package/src/components/YantraMark.tsx +30 -0
  308. package/src/components/drawerHeader.tsx +46 -0
  309. package/src/components/kit.tsx +309 -0
  310. package/src/components/lottieInstalled.ts +7 -0
  311. package/src/components/ui.tsx +700 -0
  312. package/src/components/useSignOut.ts +21 -0
  313. package/src/components/viewport.tsx +166 -0
  314. package/src/components/voiceDial.ts +45 -0
  315. package/src/compute.ts +168 -0
  316. package/src/config/env-config.ts +37 -0
  317. package/src/config/routes.ts +28 -0
  318. package/src/content.ts +217 -0
  319. package/src/hooks/keyboardCover.ts +70 -0
  320. package/src/hooks/useKeyboard.ts +135 -0
  321. package/src/hooks/useReducedMotion.ts +19 -0
  322. package/src/imessage/openMessages.ts +53 -0
  323. package/src/imessage/platform.ts +32 -0
  324. package/src/imessage/textLink.ts +307 -0
  325. package/src/index.ts +24 -0
  326. package/src/live/card.ts +62 -0
  327. package/src/live/liveActivity.ts +192 -0
  328. package/src/module.ts +8 -0
  329. package/src/offer/BlackFridayOffer.tsx +394 -0
  330. package/src/offer/blackFriday.ts +109 -0
  331. package/src/offer/parts.tsx +650 -0
  332. package/src/offer/state.ts +78 -0
  333. package/src/push/push.ts +171 -0
  334. package/src/push/usePushNotifications.ts +47 -0
  335. package/src/screens/Account/index.tsx +310 -0
  336. package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
  337. package/src/screens/Chat/index.tsx +891 -0
  338. package/src/screens/Chores/index.tsx +35 -0
  339. package/src/screens/Connectors/index.tsx +35 -0
  340. package/src/screens/History/index.tsx +346 -0
  341. package/src/screens/Home/index.tsx +2773 -0
  342. package/src/screens/Home/media.ts +31 -0
  343. package/src/screens/Welcome/index.tsx +1182 -0
  344. package/src/talk/talkToLucy.ts +187 -0
  345. package/src/theme/colors.ts +38 -0
  346. package/src/theme/fonts.ts +30 -0
  347. package/src/theme/muse.ts +86 -0
  348. package/src/utils/links.ts +84 -0
  349. package/src/utils/yantraLinks.ts +94 -0
  350. package/src/welcome/flow.ts +418 -0
  351. package/src/welcome/haptics.ts +179 -0
  352. package/src/welcome/parts.tsx +2160 -0
  353. package/src/welcome/powerOn.ts +84 -0
  354. package/src/welcome/seen.ts +68 -0
  355. package/src/welcome/sound.ts +173 -0
  356. package/tools/lottie/chat.motion +0 -0
  357. package/tools/lottie/cloud.motion +0 -0
  358. package/tools/lottie/generate.mjs +1209 -0
  359. package/tools/lottie/inter-glyphs.json +4416 -0
  360. package/tools/lottie/lucy-mark-calendar.motion +0 -0
  361. package/tools/lottie/lucy-mark-call.motion +0 -0
  362. package/tools/lottie/lucy-mark-connect.motion +0 -0
  363. package/tools/lottie/lucy-mark-details.motion +0 -0
  364. package/tools/lottie/lucy-mark-email.motion +0 -0
  365. package/tools/lottie/lucy-mark-message.motion +0 -0
  366. package/tools/lottie/lucy-mark-search.motion +0 -0
  367. package/tools/lottie/lucy-mark-think.motion +0 -0
  368. package/tools/lottie/lucy-mark-write.motion +0 -0
  369. package/tools/lottie/mark.json +1 -0
  370. package/tools/lottie/mine-none.motion +0 -0
  371. package/tools/lottie/mine-offline.motion +0 -0
  372. package/tools/lottie/mine-online.motion +0 -0
  373. package/tools/lottie/time-back.mjs +604 -0
  374. package/tools/sounds/render.mjs +730 -0
  375. package/tsconfig.json +17 -0
  376. package/README.md +0 -3
@@ -0,0 +1,1067 @@
1
+ /**
2
+ * Lucy's results as cards under her reply (chat/results.ts reads them out of it, as the web chat does): flights as
3
+ * itinerary rows, products (and stays, cars, trains) as picture tiles that swipe sideways. Book or Choose answers
4
+ * Lucy with the row's words, as if typed, so her rules still hold (she asks before she pays) and the pick stays in
5
+ * the thread. One pick per card, and a flights card folds to its pick. Every row also links out, to book it or look
6
+ * it up yourself. A card's foot, and the end of a swipe, hand over to the surface with more than she found: Travel
7
+ * or Shopping, opened over the chat. The look is the canvas's "Lucy's results" design, in the chat's colours
8
+ * (theme/muse.ts).
9
+ */
10
+ import React, { memo, useMemo, useState } from 'react';
11
+ import {
12
+ Image,
13
+ LayoutAnimation,
14
+ Pressable,
15
+ ScrollView,
16
+ StyleSheet,
17
+ Text,
18
+ View,
19
+ type DimensionValue,
20
+ type StyleProp,
21
+ type ViewStyle,
22
+ } from 'react-native';
23
+ import Svg, { Path } from 'react-native-svg';
24
+ import { MARK } from './Logo';
25
+ import { useReducedMotion } from '../hooks/useReducedMotion';
26
+ import { tap, tick } from '../welcome/haptics';
27
+ import { openInSheet, yantraAppUrl } from '../utils/links';
28
+ import {
29
+ actionWord,
30
+ BADGES,
31
+ beyondLabel,
32
+ cardPicks,
33
+ conditionOf,
34
+ describeFlight,
35
+ describeItem,
36
+ isFallbackFavicon,
37
+ legWhen,
38
+ moreSurface,
39
+ noteFor,
40
+ shownRows,
41
+ splitClock,
42
+ surfaceUrl,
43
+ type FlightLeg,
44
+ type FlightRow,
45
+ type FlightsCard,
46
+ type ListCard,
47
+ type ListRow,
48
+ type MoreSurface,
49
+ type ResultBadge,
50
+ type ResultCard,
51
+ type ResultLink,
52
+ } from '../chat/results';
53
+ import { lift, radius, ui } from '../theme/muse';
54
+
55
+ /* ------------------------------------------------------------------------------------------------ marks */
56
+
57
+ type GlyphName = 'plane' | 'bag' | 'bed' | 'car' | 'train' | 'bus' | 'luggage' | 'out' | 'check' | 'down' | 'warn';
58
+
59
+ const ring = (cx: number, cy: number, r: number) =>
60
+ `M${cx - r} ${cy}a${r} ${r} 0 1 0 ${2 * r} 0a${r} ${r} 0 1 0 ${-2 * r} 0`;
61
+
62
+ /** The design's line icons (Lucide), one path per stroke. */
63
+ const GLYPHS: Record<GlyphName, readonly string[]> = {
64
+ plane: [
65
+ 'M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z',
66
+ ],
67
+ bag: ['M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z', 'M3 6h18', 'M16 10a4 4 0 0 1-8 0'],
68
+ bed: [
69
+ 'M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8',
70
+ 'M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4',
71
+ 'M12 4v6',
72
+ 'M2 18h20',
73
+ ],
74
+ car: [
75
+ 'M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2',
76
+ ring(7, 17, 2),
77
+ 'M9 17h6',
78
+ ring(17, 17, 2),
79
+ ],
80
+ train: [
81
+ 'M8 3.1V7a4 4 0 0 0 8 0V3.1',
82
+ 'M9 15l-1-1',
83
+ 'M15 15l1-1',
84
+ 'M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z',
85
+ 'M8 19l-2 3',
86
+ 'M16 19l2 3',
87
+ ],
88
+ bus: [
89
+ 'M8 6v6',
90
+ 'M15 6v6',
91
+ 'M2 12h19.6',
92
+ 'M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3',
93
+ ring(7, 18, 2),
94
+ 'M9 18h5',
95
+ ring(16, 18, 2),
96
+ ],
97
+ luggage: [
98
+ 'M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2',
99
+ 'M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14',
100
+ 'M10 20h4',
101
+ ring(16, 20, 2),
102
+ ring(8, 20, 2),
103
+ ],
104
+ out: ['M7 7h10v10', 'M7 17 17 7'],
105
+ check: ['M20 6 9 17l-5-5'],
106
+ down: ['m6 9 6 6 6-6'],
107
+ warn: ['m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3', 'M12 9v4', 'M12 17h.01'],
108
+ };
109
+
110
+ function Glyph({
111
+ name,
112
+ size = 18,
113
+ color = ui.ink,
114
+ weight = 1.9,
115
+ style,
116
+ }: {
117
+ name: GlyphName;
118
+ size?: number;
119
+ color?: string;
120
+ weight?: number;
121
+ style?: StyleProp<ViewStyle>;
122
+ }) {
123
+ return (
124
+ <Svg
125
+ width={size}
126
+ height={size}
127
+ viewBox="0 0 24 24"
128
+ style={style}
129
+ accessibilityElementsHidden
130
+ importantForAccessibility="no"
131
+ >
132
+ {GLYPHS[name].map((d) => (
133
+ <Path
134
+ key={d}
135
+ d={d}
136
+ fill="none"
137
+ stroke={color}
138
+ strokeWidth={weight}
139
+ strokeLinecap="round"
140
+ strokeLinejoin="round"
141
+ />
142
+ ))}
143
+ </Svg>
144
+ );
145
+ }
146
+
147
+ const KIND_ICONS: Record<ResultCard['kind'], GlyphName> = {
148
+ flights: 'plane',
149
+ products: 'bag',
150
+ stays: 'bed',
151
+ cars: 'car',
152
+ trains: 'train',
153
+ buses: 'bus',
154
+ travel: 'luggage',
155
+ };
156
+
157
+ /* ------------------------------------------------------------------------------------------------ pieces */
158
+
159
+ /** Pictures that did not load (or came back as the favicon service's stand-in), for the app's life. */
160
+ const failedImages = new Set<string>();
161
+
162
+ /** An image that falls back for good once it fails, however often its row is drawn again. */
163
+ function useImage(src?: string) {
164
+ const [failed, setFailed] = useState(() => !src || failedImages.has(src));
165
+ const fail = () => {
166
+ if (src) failedImages.add(src);
167
+ setFailed(true);
168
+ };
169
+ return { show: Boolean(src) && !failed && !failedImages.has(src as string), fail };
170
+ }
171
+
172
+ const BADGE_TONES: Record<ResultBadge, { bg: string; fg: string }> = {
173
+ pick: { bg: ui.accentSoft, fg: ui.accentText },
174
+ cheapest: { bg: '#E2F3E9', fg: '#166B45' },
175
+ fastest: { bg: '#E6EEFB', fg: '#1F4F9A' },
176
+ };
177
+
178
+ function Badge({ badge }: { badge: ResultBadge }) {
179
+ const tone = BADGE_TONES[badge];
180
+ return (
181
+ <View style={[c.badge, { backgroundColor: tone.bg }]}>
182
+ {badge === 'pick' ? (
183
+ <Svg
184
+ width={9}
185
+ height={9}
186
+ viewBox="0 0 16 16"
187
+ accessibilityElementsHidden
188
+ importantForAccessibility="no"
189
+ >
190
+ <Path fill={ui.accent} d={MARK.FACE} />
191
+ </Svg>
192
+ ) : null}
193
+ <Text style={[c.badgeText, { color: tone.fg }]}>{BADGES[badge]}</Text>
194
+ </View>
195
+ );
196
+ }
197
+
198
+ /** The airline's mark: its site's icon, or two letters when it has none. */
199
+ function BrandMark({ logo, monogram }: { logo?: string; monogram: string }) {
200
+ const image = useImage(logo);
201
+ return (
202
+ <View style={c.mark}>
203
+ {image.show && logo ? (
204
+ <Image
205
+ source={{ uri: logo }}
206
+ style={c.markImage}
207
+ resizeMode="contain"
208
+ onError={image.fail}
209
+ onLoad={(e) => {
210
+ if (isFallbackFavicon({ src: logo, naturalWidth: e.nativeEvent?.source?.width ?? 0 })) {
211
+ image.fail();
212
+ }
213
+ }}
214
+ />
215
+ ) : (
216
+ <Text style={c.markText} allowFontScaling={false}>
217
+ {monogram}
218
+ </Text>
219
+ )}
220
+ </View>
221
+ );
222
+ }
223
+
224
+ /**
225
+ * A row's answer to Lucy: Book (or Choose), then Sent once it went. Held while she is on a turn, and for good once the
226
+ * card has its pick.
227
+ */
228
+ function ReplyButton({
229
+ label,
230
+ action,
231
+ sent,
232
+ locked,
233
+ waiting,
234
+ full,
235
+ onPress,
236
+ }: {
237
+ label: string;
238
+ action: string;
239
+ sent: boolean;
240
+ locked: boolean;
241
+ waiting: boolean;
242
+ full?: boolean;
243
+ onPress: () => void;
244
+ }) {
245
+ return (
246
+ <Pressable
247
+ accessibilityRole="button"
248
+ accessibilityLabel={sent ? `Sent: ${action}` : action}
249
+ accessibilityState={{ disabled: locked }}
250
+ disabled={locked}
251
+ onPress={onPress}
252
+ hitSlop={{ top: 4, bottom: 4, left: 2, right: 2 }}
253
+ style={({ pressed }) => [
254
+ c.reply,
255
+ full && c.replyFull,
256
+ sent && c.replySent,
257
+ waiting && c.replyWait,
258
+ pressed && c.replyPressed,
259
+ ]}
260
+ >
261
+ {sent ? (
262
+ <>
263
+ <Glyph name="check" size={15} color={OK_TEXT} weight={2.4} />
264
+ <Text style={[c.replyText, { color: OK_TEXT }]}>Sent</Text>
265
+ </>
266
+ ) : (
267
+ <Text style={c.replyText}>{label}</Text>
268
+ )}
269
+ </Pressable>
270
+ );
271
+ }
272
+
273
+ /** Somewhere to book it or see it yourself, opened over the chat. */
274
+ function OutLink({ link, small }: { link?: ResultLink; small?: boolean }) {
275
+ if (!link) return null;
276
+ return (
277
+ <Pressable
278
+ accessibilityRole="link"
279
+ accessibilityLabel={link.label}
280
+ accessibilityHint="Opens in the browser"
281
+ hitSlop={small ? 6 : 3}
282
+ onPress={() => openInSheet(link.href)}
283
+ style={({ pressed }) => [c.out, small && c.outSmall, pressed && { backgroundColor: ui.fill }]}
284
+ >
285
+ <Glyph name="out" size={small ? 14 : 16} weight={2} />
286
+ </Pressable>
287
+ );
288
+ }
289
+
290
+ /** The surface with more than Lucy found, on this environment's Yantra; null where it has no address. */
291
+ function useMore(kind: ResultCard['kind']): { more: MoreSurface; href: string } | null {
292
+ return useMemo(() => {
293
+ const more = moreSurface(kind);
294
+ const href = more ? surfaceUrl(more.host, yantraAppUrl()) : '';
295
+ return more && href ? { more, href } : null;
296
+ }, [kind]);
297
+ }
298
+
299
+ function openSurface(href: string) {
300
+ tap();
301
+ openInSheet(href);
302
+ }
303
+
304
+ /** "More flights in Travel": the card's way past what Lucy found. */
305
+ function SurfaceRow({ more, href, count, icon }: { more: MoreSurface; href: string; count: number; icon: GlyphName }) {
306
+ return (
307
+ <Pressable
308
+ accessibilityRole="link"
309
+ accessibilityLabel={`${more.label}. ${beyondLabel(count)}.`}
310
+ accessibilityHint={`Opens ${more.title}`}
311
+ onPress={() => openSurface(href)}
312
+ style={({ pressed }) => [c.surface, pressed && c.surfacePressed]}
313
+ >
314
+ <View style={c.surfaceIcon}>
315
+ <Glyph name={icon} size={18} color={ui.accentText} />
316
+ </View>
317
+ <View style={c.surfaceText}>
318
+ <Text style={c.surfaceTitle}>{more.label}</Text>
319
+ <Text style={c.surfaceSub}>{beyondLabel(count)}</Text>
320
+ </View>
321
+ <Glyph name="out" size={18} color={ui.ink2} />
322
+ </Pressable>
323
+ );
324
+ }
325
+
326
+ /** A card: its heading, its rows, Show more when it folds, and the foot with the note and the surface. */
327
+ function Frame({
328
+ card,
329
+ toggle,
330
+ open,
331
+ onToggle,
332
+ note,
333
+ surface,
334
+ children,
335
+ }: {
336
+ card: ResultCard;
337
+ toggle: string;
338
+ open: boolean;
339
+ onToggle: () => void;
340
+ note: string;
341
+ surface: { more: MoreSurface; href: string } | null;
342
+ children: React.ReactNode;
343
+ }) {
344
+ const icon = KIND_ICONS[card.kind];
345
+ return (
346
+ <View style={c.lift}>
347
+ <View style={c.card}>
348
+ <View style={c.head}>
349
+ <View style={c.headIcon}>
350
+ <Glyph name={icon} size={18} color={ui.accentText} />
351
+ </View>
352
+ <View style={c.headText}>
353
+ <Text style={c.title} accessibilityRole="header" numberOfLines={2}>
354
+ {card.title}
355
+ </Text>
356
+ {card.subtitle ? (
357
+ <Text style={c.sub} numberOfLines={2}>
358
+ {card.subtitle}
359
+ </Text>
360
+ ) : null}
361
+ </View>
362
+ </View>
363
+ {children}
364
+ {toggle ? (
365
+ <Pressable
366
+ accessibilityRole="button"
367
+ accessibilityState={{ expanded: open }}
368
+ onPress={onToggle}
369
+ style={({ pressed }) => [c.more, pressed && { backgroundColor: ui.bg }]}
370
+ >
371
+ <Text style={c.moreText}>{toggle}</Text>
372
+ <Glyph
373
+ name="down"
374
+ size={16}
375
+ color={ui.accentText}
376
+ weight={2.2}
377
+ style={open ? c.flip : undefined}
378
+ />
379
+ </Pressable>
380
+ ) : null}
381
+ <View style={c.foot}>
382
+ <Text style={c.note} accessibilityLiveRegion="polite">
383
+ {note}
384
+ </Text>
385
+ {surface ? (
386
+ <SurfaceRow more={surface.more} href={surface.href} count={card.rows.length} icon={icon} />
387
+ ) : null}
388
+ </View>
389
+ </View>
390
+ </View>
391
+ );
392
+ }
393
+
394
+ /* ------------------------------------------------------------------------------------------------ flights */
395
+
396
+ /** "10:10 PM" set large, "PM" small beside it, "+1" raised after a landing on a later day. */
397
+ function Clock({ clock, shift }: { clock?: string; shift?: string }) {
398
+ const { time, half } = splitClock(clock);
399
+ return (
400
+ <View style={c.clock}>
401
+ <Text style={c.time}>{time}</Text>
402
+ {half ? <Text style={c.half}>{half}</Text> : null}
403
+ {shift ? <Text style={c.shift}>{shift}</Text> : null}
404
+ </View>
405
+ );
406
+ }
407
+
408
+ /** One direction: leaves and lands on a route line (a plane when nonstop, a dot per stop), the airports, the stops. */
409
+ function Leg({ leg, when }: { leg: FlightLeg; when?: string }) {
410
+ const dots = Math.min(leg.stopCount ?? 0, 3);
411
+ return (
412
+ <View style={c.legWrap}>
413
+ {when ? <Text style={c.when}>{when}</Text> : null}
414
+ <View style={c.leg}>
415
+ <View>
416
+ <Clock clock={leg.departs} />
417
+ <Text style={c.code}>{leg.from ?? ''}</Text>
418
+ </View>
419
+ <View style={c.mid}>
420
+ <View style={c.route}>
421
+ <View style={c.line} />
422
+ <View style={[c.end, c.endL]} />
423
+ <View style={[c.end, c.endR]} />
424
+ {dots === 0 ? (
425
+ <View style={c.plane}>
426
+ <Glyph name="plane" size={14} color={ui.muted} weight={1.8} style={c.planeTurn} />
427
+ </View>
428
+ ) : (
429
+ Array.from({ length: dots }, (_, i) => (
430
+ <View
431
+ key={i}
432
+ style={[c.stop, { left: `${((i + 1) * 100) / (dots + 1)}%` as DimensionValue }]}
433
+ />
434
+ ))
435
+ )}
436
+ </View>
437
+ <Text style={c.span} numberOfLines={1}>
438
+ {[leg.duration, leg.stops].filter(Boolean).join(' · ')}
439
+ </Text>
440
+ {leg.via ? (
441
+ <Text style={c.via} numberOfLines={1}>
442
+ via {leg.via}
443
+ </Text>
444
+ ) : null}
445
+ </View>
446
+ <View style={c.right}>
447
+ <Clock clock={leg.arrives} shift={leg.dayShift} />
448
+ <Text style={c.code}>{leg.to ?? ''}</Text>
449
+ </View>
450
+ </View>
451
+ </View>
452
+ );
453
+ }
454
+
455
+ function FlightItem({
456
+ row,
457
+ datedRows,
458
+ sent,
459
+ dim,
460
+ locked,
461
+ waiting,
462
+ onBook,
463
+ }: {
464
+ row: FlightRow;
465
+ datedRows: boolean;
466
+ sent: boolean;
467
+ dim: boolean;
468
+ locked: boolean;
469
+ waiting: boolean;
470
+ onBook: () => void;
471
+ }) {
472
+ return (
473
+ <View style={[c.row, dim && c.dim]}>
474
+ <View accessible accessibilityLabel={describeFlight(row)}>
475
+ <View style={c.r1}>
476
+ <BrandMark logo={row.logo} monogram={row.monogram} />
477
+ <View style={c.name}>
478
+ <Text style={c.airline} numberOfLines={1}>
479
+ {row.airline}
480
+ </Text>
481
+ {row.flightNumber ? <Text style={c.number}>{row.flightNumber}</Text> : null}
482
+ {row.badges.map((badge) => (
483
+ <Badge key={badge} badge={badge} />
484
+ ))}
485
+ </View>
486
+ {row.price ? <Text style={c.price}>{row.price}</Text> : null}
487
+ </View>
488
+ {row.legs.map((leg, i) => (
489
+ <Leg key={i} leg={leg} when={legWhen(datedRows, row.legs.length, i, leg.date)} />
490
+ ))}
491
+ </View>
492
+ <View style={c.r4}>
493
+ <View style={c.fare}>
494
+ {row.fare ? (
495
+ <Text style={c.fareText} numberOfLines={2}>
496
+ {row.fare}
497
+ </Text>
498
+ ) : null}
499
+ {row.selfTransfer ? (
500
+ <View style={c.warn}>
501
+ <Glyph name="warn" size={12} color={ui.danger} weight={2.2} />
502
+ <Text style={c.warnText}>Separate tickets</Text>
503
+ </View>
504
+ ) : null}
505
+ </View>
506
+ <View style={c.acts}>
507
+ <ReplyButton
508
+ label="Book"
509
+ action={row.action}
510
+ sent={sent}
511
+ locked={locked}
512
+ waiting={waiting}
513
+ onPress={onBook}
514
+ />
515
+ <OutLink link={row.link} />
516
+ </View>
517
+ </View>
518
+ </View>
519
+ );
520
+ }
521
+
522
+ interface CardProps<C> {
523
+ card: C;
524
+ /** The card's pick so far: the words its tap sent. */
525
+ pick?: string;
526
+ /** Lucy is on a turn: a pick waits until she is done. */
527
+ busy: boolean;
528
+ onReply: (card: string, words: string) => void;
529
+ }
530
+
531
+ function FlightsResults({ card, pick, busy, onReply }: CardProps<FlightsCard>) {
532
+ const [open, setOpen] = useState(false);
533
+ const reduced = useReducedMotion();
534
+ const surface = useMore('flights');
535
+ const shown = shownRows(card.rows, open, pick);
536
+ const glide = () => {
537
+ if (!reduced) LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
538
+ };
539
+ return (
540
+ <Frame
541
+ card={card}
542
+ toggle={shown.toggle}
543
+ open={open}
544
+ onToggle={() => {
545
+ tick();
546
+ glide();
547
+ setOpen(!open);
548
+ }}
549
+ note={noteFor('flights', Boolean(pick), busy)}
550
+ surface={surface}
551
+ >
552
+ {shown.rows.map((row) => (
553
+ <FlightItem
554
+ key={row.key}
555
+ row={row}
556
+ datedRows={card.datedRows}
557
+ sent={row.reply === pick}
558
+ dim={Boolean(pick) && row.reply !== pick}
559
+ locked={Boolean(pick) || busy}
560
+ waiting={busy && !pick}
561
+ onBook={() => {
562
+ // The card folds to the booked flight as the words go to Lucy.
563
+ glide();
564
+ setOpen(false);
565
+ onReply(card.key, row.reply);
566
+ }}
567
+ />
568
+ ))}
569
+ </Frame>
570
+ );
571
+ }
572
+
573
+ /* ------------------------------------------------------------------------------------------------ tiles */
574
+
575
+ const TILE = 150;
576
+ const GAP = 10;
577
+
578
+ function Tile({
579
+ kind,
580
+ row,
581
+ label,
582
+ sent,
583
+ dim,
584
+ locked,
585
+ waiting,
586
+ onChoose,
587
+ }: {
588
+ kind: ListCard['kind'];
589
+ row: ListRow;
590
+ label: string;
591
+ sent: boolean;
592
+ dim: boolean;
593
+ locked: boolean;
594
+ waiting: boolean;
595
+ onChoose: () => void;
596
+ }) {
597
+ const image = useImage(row.imageUrl);
598
+ const condition = kind === 'products' ? conditionOf(row.title) : undefined;
599
+ const meta = [row.seller, row.rating ? `★ ${row.rating}${row.reviews ? ` (${row.reviews})` : ''}` : undefined]
600
+ .filter(Boolean)
601
+ .join(' · ');
602
+ return (
603
+ <View style={[c.tile, dim && c.dim]}>
604
+ <View accessible accessibilityLabel={describeItem(row, condition)}>
605
+ <View style={[c.photo, image.show && c.photoReal]}>
606
+ {image.show && row.imageUrl ? (
607
+ <Image
608
+ source={{ uri: row.imageUrl }}
609
+ style={c.photoImage}
610
+ resizeMode="contain"
611
+ onError={image.fail}
612
+ />
613
+ ) : (
614
+ <Glyph name={KIND_ICONS[kind]} size={30} color={PHOTO_INK} weight={1.6} style={c.photoGlyph} />
615
+ )}
616
+ {row.badges.length ? (
617
+ <View style={c.photoTags}>
618
+ {row.badges.map((badge) => (
619
+ <Badge key={badge} badge={badge} />
620
+ ))}
621
+ </View>
622
+ ) : null}
623
+ {condition ? (
624
+ <View style={c.cond}>
625
+ <Text style={c.condText}>{condition}</Text>
626
+ </View>
627
+ ) : null}
628
+ </View>
629
+ <View style={c.tileText}>
630
+ <View style={c.tilePriceRow}>
631
+ {row.price ? <Text style={c.tilePrice}>{row.price}</Text> : null}
632
+ {row.priceUnit ? <Text style={c.unit}>{row.priceUnit}</Text> : null}
633
+ {row.wasPrice ? <Text style={c.was}>{row.wasPrice}</Text> : null}
634
+ </View>
635
+ <Text style={c.tileTitle} numberOfLines={3}>
636
+ {row.title}
637
+ </Text>
638
+ {meta ? (
639
+ <Text style={c.tileMeta} numberOfLines={1}>
640
+ {meta}
641
+ </Text>
642
+ ) : null}
643
+ {row.detail ? (
644
+ <Text style={c.tileDetail} numberOfLines={2}>
645
+ {row.detail}
646
+ </Text>
647
+ ) : null}
648
+ </View>
649
+ </View>
650
+ <View style={c.tileFoot}>
651
+ <ReplyButton
652
+ full
653
+ label={label}
654
+ action={row.action}
655
+ sent={sent}
656
+ locked={locked}
657
+ waiting={waiting}
658
+ onPress={onChoose}
659
+ />
660
+ </View>
661
+ {row.link ? (
662
+ <View style={c.tileOut}>
663
+ <OutLink link={row.link} small />
664
+ </View>
665
+ ) : null}
666
+ </View>
667
+ );
668
+ }
669
+
670
+ /** Where the swipe ends: the surface, for more than the tiles before it. */
671
+ function EndTile({
672
+ surface,
673
+ count,
674
+ icon,
675
+ }: {
676
+ surface: { more: MoreSurface; href: string };
677
+ count: number;
678
+ icon: GlyphName;
679
+ }) {
680
+ return (
681
+ <Pressable
682
+ accessibilityRole="link"
683
+ accessibilityLabel={`${surface.more.label}. ${beyondLabel(count)}.`}
684
+ accessibilityHint={`Opens ${surface.more.title}`}
685
+ onPress={() => openSurface(surface.href)}
686
+ style={({ pressed }) => [c.tile, c.endTile, pressed && c.surfacePressed]}
687
+ >
688
+ <View style={c.endIcon}>
689
+ <Glyph name={icon} size={22} color={ui.accentText} />
690
+ </View>
691
+ <Text style={c.endTitle}>{surface.more.label}</Text>
692
+ <Text style={c.endSub}>{beyondLabel(count)}</Text>
693
+ <Glyph name="out" size={18} color={ui.ink2} style={c.endArrow} />
694
+ </Pressable>
695
+ );
696
+ }
697
+
698
+ function ListResults({ card, pick, busy, onReply }: CardProps<ListCard>) {
699
+ const surface = useMore(card.kind);
700
+ const label = actionWord(card.kind);
701
+ return (
702
+ <Frame
703
+ card={card}
704
+ toggle=""
705
+ open={false}
706
+ onToggle={() => undefined}
707
+ note={noteFor(card.kind, Boolean(pick), busy)}
708
+ surface={surface}
709
+ >
710
+ <ScrollView
711
+ horizontal
712
+ showsHorizontalScrollIndicator={false}
713
+ decelerationRate="fast"
714
+ snapToInterval={TILE + GAP}
715
+ contentContainerStyle={c.rail}
716
+ >
717
+ {card.rows.map((row) => (
718
+ <Tile
719
+ key={row.key}
720
+ kind={card.kind}
721
+ row={row}
722
+ label={label}
723
+ sent={row.reply === pick}
724
+ dim={Boolean(pick) && row.reply !== pick}
725
+ locked={Boolean(pick) || busy}
726
+ waiting={busy && !pick}
727
+ onChoose={() => onReply(card.key, row.reply)}
728
+ />
729
+ ))}
730
+ {surface ? <EndTile surface={surface} count={card.rows.length} icon={KIND_ICONS[card.kind]} /> : null}
731
+ </ScrollView>
732
+ </Frame>
733
+ );
734
+ }
735
+
736
+ /* ------------------------------------------------------------------------------------------------ the cards */
737
+
738
+ export interface ResultCardsProps {
739
+ cards: ResultCard[];
740
+ /** The person's messages after this reply, in the order sent: a card's pick is the first that is a row's words. */
741
+ later: readonly string[];
742
+ /** Lucy is on a turn: a pick waits until she is done. */
743
+ busy: boolean;
744
+ /** Answers Lucy with a row's words, as if typed. */
745
+ onReply: (words: string) => void;
746
+ }
747
+
748
+ /** The cards for one reply. A tap answers at once and locks its card, before the thread shows the message. */
749
+ export const ResultCards = memo(function ResultCards({ cards, later, busy, onReply }: ResultCardsProps) {
750
+ const sent = useMemo(() => cardPicks(cards, later), [cards, later]);
751
+ const [tapped, setTapped] = useState<Record<string, string>>({});
752
+ if (!cards.length) return null;
753
+ const reply = (card: string, words: string) => {
754
+ if (busy || sent[card] || tapped[card]) return;
755
+ tap();
756
+ setTapped((before) => ({ ...before, [card]: words }));
757
+ onReply(words);
758
+ };
759
+ return (
760
+ <View style={c.stack}>
761
+ {cards.map((card) => {
762
+ const pick = sent[card.key] ?? tapped[card.key];
763
+ return card.kind === 'flights' ? (
764
+ <FlightsResults key={card.key} card={card} pick={pick} busy={busy} onReply={reply} />
765
+ ) : (
766
+ <ListResults key={card.key} card={card} pick={pick} busy={busy} onReply={reply} />
767
+ );
768
+ })}
769
+ </View>
770
+ );
771
+ });
772
+
773
+ /* ------------------------------------------------------------------------------------------------ styles */
774
+
775
+ /** A badge's green and the Sent button's, dark enough for small text on its tint. */
776
+ const OK_TEXT = '#166B45';
777
+ const CREAM = '#FFF8F2';
778
+ const PHOTO_INK = '#8D837A';
779
+ const LINE = 'rgba(26,23,20,0.11)';
780
+
781
+ const c = StyleSheet.create({
782
+ stack: { gap: 12 },
783
+ lift: { borderRadius: 22, backgroundColor: ui.surface, ...lift },
784
+ card: {
785
+ borderRadius: 22,
786
+ overflow: 'hidden',
787
+ borderWidth: StyleSheet.hairlineWidth,
788
+ borderColor: 'rgba(26,23,20,0.08)',
789
+ backgroundColor: ui.surface,
790
+ },
791
+ head: {
792
+ flexDirection: 'row',
793
+ alignItems: 'center',
794
+ gap: 12,
795
+ paddingHorizontal: 16,
796
+ paddingTop: 14,
797
+ paddingBottom: 13,
798
+ },
799
+ headIcon: {
800
+ width: 34,
801
+ height: 34,
802
+ borderRadius: 11,
803
+ backgroundColor: ui.accentSoft,
804
+ alignItems: 'center',
805
+ justifyContent: 'center',
806
+ },
807
+ headText: { flex: 1, minWidth: 0 },
808
+ title: { fontSize: 16, lineHeight: 21, fontWeight: '600', letterSpacing: -0.2, color: ui.ink },
809
+ sub: { fontSize: 12.5, lineHeight: 17, color: ui.muted },
810
+
811
+ // a flight
812
+ row: {
813
+ paddingHorizontal: 16,
814
+ paddingVertical: 14,
815
+ borderTopWidth: StyleSheet.hairlineWidth,
816
+ borderTopColor: ui.hairline,
817
+ },
818
+ dim: { opacity: 0.42 },
819
+ r1: { flexDirection: 'row', alignItems: 'center', gap: 10 },
820
+ mark: {
821
+ width: 28,
822
+ height: 28,
823
+ borderRadius: 8,
824
+ backgroundColor: ui.fill,
825
+ alignItems: 'center',
826
+ justifyContent: 'center',
827
+ overflow: 'hidden',
828
+ },
829
+ markImage: { width: 20, height: 20 },
830
+ markText: { fontSize: 10.5, fontWeight: '700', letterSpacing: 0.2, color: ui.ink2 },
831
+ name: {
832
+ flex: 1,
833
+ minWidth: 0,
834
+ flexDirection: 'row',
835
+ flexWrap: 'wrap',
836
+ alignItems: 'center',
837
+ columnGap: 8,
838
+ rowGap: 4,
839
+ },
840
+ airline: { flexShrink: 1, fontSize: 15, lineHeight: 20, fontWeight: '600', letterSpacing: -0.15, color: ui.ink },
841
+ number: { fontSize: 12.5, lineHeight: 20, fontWeight: '500', color: ui.muted },
842
+ price: {
843
+ alignSelf: 'flex-start',
844
+ fontSize: 17,
845
+ lineHeight: 28,
846
+ fontWeight: '600',
847
+ letterSpacing: -0.3,
848
+ color: ui.ink,
849
+ fontVariant: ['tabular-nums'],
850
+ },
851
+ badge: { flexDirection: 'row', alignItems: 'center', gap: 4, height: 20, paddingHorizontal: 7, borderRadius: 6 },
852
+ badgeText: { fontSize: 11.5, fontWeight: '600' },
853
+
854
+ legWrap: { marginTop: 12 },
855
+ when: { marginBottom: 4, fontSize: 12, lineHeight: 16, fontWeight: '600', color: ui.muted },
856
+ leg: { flexDirection: 'row', alignItems: 'flex-start', gap: 12 },
857
+ clock: { flexDirection: 'row', alignItems: 'baseline' },
858
+ time: {
859
+ fontSize: 21,
860
+ lineHeight: 26,
861
+ fontWeight: '600',
862
+ letterSpacing: -0.5,
863
+ color: ui.ink,
864
+ fontVariant: ['tabular-nums'],
865
+ },
866
+ half: { marginLeft: 3, fontSize: 11.5, fontWeight: '600', letterSpacing: 0.2, color: ui.ink2 },
867
+ shift: {
868
+ alignSelf: 'flex-start',
869
+ marginLeft: 2,
870
+ marginTop: 1,
871
+ fontSize: 11,
872
+ lineHeight: 13,
873
+ fontWeight: '700',
874
+ color: ui.accentText,
875
+ },
876
+ code: { marginTop: 2, fontSize: 12, lineHeight: 16, fontWeight: '600', letterSpacing: 0.8, color: ui.ink2 },
877
+ right: { alignItems: 'flex-end' },
878
+ mid: { flex: 1, minWidth: 0, alignItems: 'center' },
879
+ route: { alignSelf: 'stretch', height: 26 },
880
+ line: {
881
+ position: 'absolute',
882
+ left: 3,
883
+ right: 3,
884
+ top: 12,
885
+ height: 2,
886
+ borderRadius: 1,
887
+ backgroundColor: 'rgba(26,23,20,0.14)',
888
+ },
889
+ end: { position: 'absolute', top: 10, width: 6, height: 6, borderRadius: 3, backgroundColor: 'rgba(26,23,20,0.3)' },
890
+ endL: { left: 0 },
891
+ endR: { right: 0 },
892
+ plane: {
893
+ position: 'absolute',
894
+ left: '50%',
895
+ top: 5,
896
+ width: 24,
897
+ height: 16,
898
+ marginLeft: -12,
899
+ alignItems: 'center',
900
+ justifyContent: 'center',
901
+ backgroundColor: ui.surface,
902
+ },
903
+ planeTurn: { transform: [{ rotate: '45deg' }] },
904
+ stop: {
905
+ position: 'absolute',
906
+ top: 8,
907
+ width: 10,
908
+ height: 10,
909
+ marginLeft: -5,
910
+ borderRadius: 5,
911
+ borderWidth: 2,
912
+ borderColor: ui.accent,
913
+ backgroundColor: ui.surface,
914
+ },
915
+ span: { marginTop: 2, fontSize: 12.5, lineHeight: 16, color: ui.muted },
916
+ via: { fontSize: 12, lineHeight: 16, color: ui.muted },
917
+
918
+ r4: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 10, marginTop: 12 },
919
+ fare: { flex: 1, minWidth: 0, gap: 3 },
920
+ fareText: { fontSize: 12.5, lineHeight: 17, color: ui.muted },
921
+ warn: { flexDirection: 'row', alignItems: 'center', gap: 4 },
922
+ warnText: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: ui.danger },
923
+ acts: { flexDirection: 'row', alignItems: 'center', gap: 8 },
924
+ reply: {
925
+ flexDirection: 'row',
926
+ alignItems: 'center',
927
+ justifyContent: 'center',
928
+ gap: 5,
929
+ height: 38,
930
+ paddingHorizontal: 18,
931
+ borderRadius: radius.pill,
932
+ backgroundColor: ui.ink,
933
+ },
934
+ replyFull: { alignSelf: 'stretch', height: 36, paddingHorizontal: 0 },
935
+ replySent: { backgroundColor: '#E2F3E9' },
936
+ replyWait: { opacity: 0.45 },
937
+ replyPressed: { backgroundColor: '#000000', transform: [{ scale: 0.96 }] },
938
+ replyText: { fontSize: 14.5, fontWeight: '600', letterSpacing: -0.1, color: '#FFFAF5' },
939
+ out: {
940
+ width: 38,
941
+ height: 38,
942
+ borderRadius: 19,
943
+ borderWidth: 1,
944
+ borderColor: LINE,
945
+ backgroundColor: ui.surface,
946
+ alignItems: 'center',
947
+ justifyContent: 'center',
948
+ },
949
+ outSmall: { width: 32, height: 32, borderRadius: 16, borderColor: 'rgba(26,23,20,0.06)', ...lift },
950
+
951
+ // the card's foot
952
+ more: {
953
+ flexDirection: 'row',
954
+ alignItems: 'center',
955
+ justifyContent: 'center',
956
+ gap: 6,
957
+ height: 46,
958
+ borderTopWidth: StyleSheet.hairlineWidth,
959
+ borderTopColor: ui.hairline,
960
+ },
961
+ moreText: { fontSize: 14, fontWeight: '600', color: ui.accentText },
962
+ flip: { transform: [{ rotate: '180deg' }] },
963
+ foot: {
964
+ paddingHorizontal: 14,
965
+ paddingTop: 12,
966
+ paddingBottom: 14,
967
+ backgroundColor: CREAM,
968
+ borderTopWidth: StyleSheet.hairlineWidth,
969
+ borderTopColor: ui.hairline,
970
+ },
971
+ note: { paddingHorizontal: 2, fontSize: 12.5, lineHeight: 17, color: ui.muted },
972
+ surface: {
973
+ flexDirection: 'row',
974
+ alignItems: 'center',
975
+ gap: 12,
976
+ minHeight: 56,
977
+ marginTop: 10,
978
+ paddingVertical: 9,
979
+ paddingLeft: 10,
980
+ paddingRight: 14,
981
+ borderRadius: 16,
982
+ borderWidth: 1,
983
+ borderColor: LINE,
984
+ backgroundColor: ui.surface,
985
+ },
986
+ surfacePressed: { transform: [{ scale: 0.985 }], backgroundColor: ui.bg },
987
+ surfaceIcon: {
988
+ width: 36,
989
+ height: 36,
990
+ borderRadius: 11,
991
+ backgroundColor: ui.accentSoft,
992
+ alignItems: 'center',
993
+ justifyContent: 'center',
994
+ },
995
+ surfaceText: { flex: 1, minWidth: 0 },
996
+ surfaceTitle: { fontSize: 14.5, lineHeight: 19, fontWeight: '600', color: ui.ink },
997
+ surfaceSub: { fontSize: 12.5, lineHeight: 17, color: ui.muted },
998
+
999
+ // tiles
1000
+ rail: { gap: GAP, paddingLeft: 14, paddingRight: 14, paddingTop: 2, paddingBottom: 16 },
1001
+ tile: {
1002
+ width: TILE,
1003
+ borderRadius: 16,
1004
+ borderWidth: 1,
1005
+ borderColor: LINE,
1006
+ backgroundColor: ui.surface,
1007
+ overflow: 'hidden',
1008
+ },
1009
+ photo: { height: 120, alignItems: 'center', justifyContent: 'center', backgroundColor: '#F4EEE8' },
1010
+ photoReal: {
1011
+ backgroundColor: '#FFFFFF',
1012
+ borderBottomWidth: StyleSheet.hairlineWidth,
1013
+ borderBottomColor: ui.hairline,
1014
+ },
1015
+ photoImage: { position: 'absolute', left: 10, right: 10, top: 10, bottom: 10 },
1016
+ // Below centre, between the badges stacked at the top and the condition at the bottom.
1017
+ photoGlyph: { marginTop: 16 },
1018
+ photoTags: { position: 'absolute', left: 8, top: 8, alignItems: 'flex-start', gap: 4 },
1019
+ cond: {
1020
+ position: 'absolute',
1021
+ left: 8,
1022
+ bottom: 8,
1023
+ height: 20,
1024
+ paddingHorizontal: 7,
1025
+ borderRadius: 6,
1026
+ justifyContent: 'center',
1027
+ backgroundColor: 'rgba(26,23,20,0.72)',
1028
+ },
1029
+ condText: { fontSize: 11, fontWeight: '600', color: '#FFFFFF' },
1030
+ tileOut: { position: 'absolute', top: 8, right: 8 },
1031
+ tileText: { paddingHorizontal: 12, paddingTop: 10 },
1032
+ tilePriceRow: { flexDirection: 'row', alignItems: 'baseline', flexWrap: 'wrap', columnGap: 5 },
1033
+ tilePrice: {
1034
+ fontSize: 17,
1035
+ lineHeight: 22,
1036
+ fontWeight: '600',
1037
+ letterSpacing: -0.3,
1038
+ color: ui.ink,
1039
+ fontVariant: ['tabular-nums'],
1040
+ },
1041
+ unit: { fontSize: 12, color: ui.muted },
1042
+ was: { fontSize: 12, color: ui.muted, textDecorationLine: 'line-through' },
1043
+ tileTitle: { marginTop: 3, minHeight: 54, fontSize: 13, lineHeight: 18, color: ui.ink2 },
1044
+ tileMeta: { marginTop: 6, fontSize: 12, lineHeight: 16, color: ui.muted },
1045
+ tileDetail: { marginTop: 2, fontSize: 12, lineHeight: 16, color: ui.muted },
1046
+ tileFoot: { marginTop: 'auto', paddingHorizontal: 12, paddingTop: 10, paddingBottom: 12 },
1047
+ endTile: {
1048
+ alignItems: 'center',
1049
+ justifyContent: 'center',
1050
+ paddingHorizontal: 12,
1051
+ paddingVertical: 16,
1052
+ borderColor: 'rgba(184,65,0,0.16)',
1053
+ backgroundColor: CREAM,
1054
+ },
1055
+ endIcon: {
1056
+ width: 52,
1057
+ height: 52,
1058
+ borderRadius: 26,
1059
+ marginBottom: 10,
1060
+ backgroundColor: ui.accentSoft,
1061
+ alignItems: 'center',
1062
+ justifyContent: 'center',
1063
+ },
1064
+ endTitle: { fontSize: 14.5, lineHeight: 19, fontWeight: '600', color: ui.ink, textAlign: 'center' },
1065
+ endSub: { marginTop: 4, fontSize: 12.5, lineHeight: 17, color: ui.muted, textAlign: 'center' },
1066
+ endArrow: { marginTop: 8 },
1067
+ });