@onairosofficial/onairos-capacitor 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/LICENSE +194 -10
  2. package/README.md +182 -25
  3. package/dist/onairos.capacitor.esm.js +1 -0
  4. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  5. package/onairos.d.ts +656 -0
  6. package/package.json +186 -38
  7. package/src/OnairosReconnectButton.jsx +272 -0
  8. package/src/RSA.jsx +57 -0
  9. package/src/assets/NewLogo.png +0 -0
  10. package/src/assets/OnairosNewLogo.png +0 -0
  11. package/src/assets/chatgpt-icon.png +0 -0
  12. package/src/assets/fire-horse.png +0 -0
  13. package/src/assets/fire-horse.transparent.png +0 -0
  14. package/src/assets/latest-firehorse.png +0 -0
  15. package/src/assets/perplexity.png +0 -0
  16. package/src/assets/persona.png +0 -0
  17. package/src/assets/persona1.png +0 -0
  18. package/src/assets/persona2.png +0 -0
  19. package/src/assets/persona3.png +0 -0
  20. package/src/assets/persona4.png +0 -0
  21. package/src/assets/persona5.png +0 -0
  22. package/src/capacitorConnectorCatalog.js +38 -0
  23. package/src/capacitorOAuthConfig.js +52 -0
  24. package/src/chatgptHostedImport/index.js +303 -0
  25. package/src/components/AuthButtons.jsx +48 -0
  26. package/src/components/ConnectChatGPTModal.jsx +666 -0
  27. package/src/components/ConnectClaudeModal.jsx +610 -0
  28. package/src/components/ConnectGeminiModal.jsx +639 -0
  29. package/src/components/ConnectGrokModal.jsx +701 -0
  30. package/src/components/ConnectPerplexityModal.jsx +726 -0
  31. package/src/components/DataExplainerScreen.jsx +349 -0
  32. package/src/components/DataRequest.js +885 -0
  33. package/src/components/DataRequest.jsx +1055 -0
  34. package/src/components/EmailAuth.js +1871 -0
  35. package/src/components/EmailAuth.jsx +2062 -0
  36. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  37. package/src/components/GoogleButton.js +133 -0
  38. package/src/components/LLMConnectorManager.jsx +201 -0
  39. package/src/components/LoadingPage.jsx +19 -0
  40. package/src/components/LoadingScreen.jsx +81 -0
  41. package/src/components/LunarBirthdate.jsx +96 -0
  42. package/src/components/LunarLoadingPage.jsx +251 -0
  43. package/src/components/Notification.jsx +21 -0
  44. package/src/components/OnairosAppButton.jsx +85 -0
  45. package/src/components/OnairosSSO.jsx +645 -0
  46. package/src/components/OnairosTrigger.jsx +61 -0
  47. package/src/components/PerplexityLogo.jsx +43 -0
  48. package/src/components/PinSetup.js +200 -0
  49. package/src/components/PinSetup.jsx +228 -0
  50. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  51. package/src/components/SdkErrorBoundary.jsx +36 -0
  52. package/src/components/SecuritySetup.js +81 -0
  53. package/src/components/SessionUserBar.jsx +83 -0
  54. package/src/components/SignUp.js +123 -0
  55. package/src/components/TestTelegramButton.js +53 -0
  56. package/src/components/TrainingComponent.jsx +200 -0
  57. package/src/components/TrainingScreen.jsx +897 -0
  58. package/src/components/UniversalOnboarding.js +306 -0
  59. package/src/components/UniversalOnboarding.jsx +4837 -0
  60. package/src/components/ValentineLoadingPage.jsx +502 -0
  61. package/src/components/ValentineModeSelector.jsx +162 -0
  62. package/src/components/WelcomeScreen.jsx +435 -0
  63. package/src/components/WrappedLoadingPage.jsx +205 -0
  64. package/src/components/connectors/ChatGPTConnector.js +348 -0
  65. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  66. package/src/components/connectors/ClaudeConnector.js +44 -0
  67. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  68. package/src/components/connectors/GeminiConnector.js +170 -0
  69. package/src/components/connectors/GeminiConnector.jsx +170 -0
  70. package/src/components/connectors/GmailConnector.js +148 -0
  71. package/src/components/connectors/GmailConnector.jsx +148 -0
  72. package/src/components/connectors/GrokConnector.js +16 -0
  73. package/src/components/connectors/GrokConnector.jsx +16 -0
  74. package/src/components/connectors/HingeConnector.js +419 -0
  75. package/src/components/connectors/HingeConnector.jsx +419 -0
  76. package/src/components/connectors/InstagramDataConnector.js +726 -0
  77. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  78. package/src/components/connectors/LinkedInConnector.js +4 -0
  79. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  80. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  81. package/src/components/connectors/PinterestConnector.js +208 -0
  82. package/src/components/connectors/PinterestConnector.jsx +208 -0
  83. package/src/components/connectors/README.md +292 -0
  84. package/src/components/connectors/RedditConnector.js +229 -0
  85. package/src/components/connectors/RedditConnector.jsx +229 -0
  86. package/src/components/connectors/SephoraConnector.js +482 -0
  87. package/src/components/connectors/SephoraConnector.jsx +482 -0
  88. package/src/components/connectors/TikTokConnector.jsx +430 -0
  89. package/src/components/connectors/YoutubeConnector.js +361 -0
  90. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  91. package/src/components/connectors/index.js +50 -0
  92. package/src/components/icons.jsx +46 -0
  93. package/src/components/icons.tsx +21 -0
  94. package/src/components/ui/PageLayout.jsx +1255 -0
  95. package/src/components/ui/PrimaryButton.jsx +162 -0
  96. package/src/components/ui/button.jsx +49 -0
  97. package/src/components/ui/card.jsx +61 -0
  98. package/src/components/ui/checkbox.jsx +33 -0
  99. package/src/components/ui/label.jsx +29 -0
  100. package/src/components/utils/UpdateConnections.js +45 -0
  101. package/src/components/utils/oauthHelper.js +97 -0
  102. package/src/config/api-config.js +138 -0
  103. package/src/deepLink.jsx +38 -0
  104. package/src/getPin.js +26 -0
  105. package/src/icons/Avatar.png +0 -0
  106. package/src/icons/Sentiment.png +0 -0
  107. package/src/icons/Trait.png +0 -0
  108. package/src/iframe/DataRequestPage.jsx +285 -0
  109. package/src/iframe/OnairosButtonIntegration.md +148 -0
  110. package/src/iframe/components/Box.jsx +56 -0
  111. package/src/iframe/components/IndividualConnection.jsx +88 -0
  112. package/src/iframe/dataRequestHandler.js +714 -0
  113. package/src/iframe/data_request_iframe.html +27 -0
  114. package/src/iframe/data_request_page.js +47 -0
  115. package/src/iframe/icons/Avatar.png +1 -0
  116. package/src/iframe/icons/Avatar2.png +1 -0
  117. package/src/iframe/icons/Sentiment.png +1 -0
  118. package/src/iframe/icons/Trait.png +1 -0
  119. package/src/iframe/icons/onairos_logo.png +0 -0
  120. package/src/iframe/utils/api.js +57 -0
  121. package/src/index.js +274 -0
  122. package/src/laravel/OnairosVue.vue +410 -0
  123. package/src/laravel/blade-helpers.js +320 -0
  124. package/src/laravel/vite-plugin.js +179 -0
  125. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  126. package/src/mobile/components/MobileBox.jsx +71 -0
  127. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  128. package/src/mobile/shims/browser-apis.js +78 -0
  129. package/src/mobile/shims/lucide-shim.js +85 -0
  130. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  131. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  132. package/src/newUI/PrimaryButton.tsx +213 -0
  133. package/src/newUI/SignInStep.tsx +194 -0
  134. package/src/newUI/VerificationStep.tsx +133 -0
  135. package/src/newUI/WelcomeScreen.tsx +311 -0
  136. package/src/newUI/services/connectedAccountsService.js +129 -0
  137. package/src/onairos.capacitor.jsx +16 -0
  138. package/src/onairos.core.jsx +133 -0
  139. package/src/onairos.jsx +14 -0
  140. package/src/onairos.native.jsx +15 -0
  141. package/src/onairosButton.jsx +9000 -0
  142. package/src/overlay/CheckBox.jsx +114 -0
  143. package/src/overlay/IndividualConnection copy.js +86 -0
  144. package/src/overlay/IndividualConnection.js +191 -0
  145. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  146. package/src/overlay/box.js +84 -0
  147. package/src/overlay/overlay.js +437 -0
  148. package/src/styles/onairos-scoped-preflight.css +97 -0
  149. package/src/styles/sdkCssRegistry.js +20 -0
  150. package/src/styles/styleLoaderInsertShadow.js +69 -0
  151. package/src/styles/tailwind.capacitor.css +395 -0
  152. package/src/styles/tailwind.css +395 -0
  153. package/src/theme/colors.js +40 -0
  154. package/src/utils/apiKeyValidation.js +341 -0
  155. package/src/utils/apiResponseLogger.js +316 -0
  156. package/src/utils/authHeaders.js +275 -0
  157. package/src/utils/biometrics.js +26 -0
  158. package/src/utils/bookmarkletUtils.js +28 -0
  159. package/src/utils/capacitorDetection.js +278 -0
  160. package/src/utils/capacitorLLMHelper.js +352 -0
  161. package/src/utils/capacitorPlugins.js +366 -0
  162. package/src/utils/crossDomainSSO.js +587 -0
  163. package/src/utils/deepLinking.js +27 -0
  164. package/src/utils/devLogger.js +46 -0
  165. package/src/utils/extensionDetection.js +418 -0
  166. package/src/utils/extractMemory.js +277 -0
  167. package/src/utils/framerBrandingOverrides.js +40 -0
  168. package/src/utils/googleWebClientId.js +55 -0
  169. package/src/utils/overlayHandler.js +224 -0
  170. package/src/utils/platformDisconnect.js +309 -0
  171. package/src/utils/pollTrainingStatus.js +200 -0
  172. package/src/utils/rawMemoriesAccess.js +211 -0
  173. package/src/utils/resolveBackendAppId.js +47 -0
  174. package/src/utils/responseFormatter.js +140 -0
  175. package/src/utils/sdkDebugStorage.js +113 -0
  176. package/src/utils/sdkInitialization.js +645 -0
  177. package/src/utils/sessionManager.js +1258 -0
  178. package/src/utils/startBackgroundTraining.js +100 -0
  179. package/src/utils/userDataFormatter.js +222 -0
  180. package/index.d.ts +0 -1
  181. package/index.js +0 -1
@@ -0,0 +1,885 @@
1
+ import React, { useState, useEffect, useMemo } from "react";
2
+ import { API_CONFIG } from '../config/api-config';
3
+ import SessionUserBar from './SessionUserBar.jsx';
4
+ // import personaImg from "../assets/persona.png";
5
+ // Use remote URL to avoid 403 Forbidden on local asset during dev/prod mismatch
6
+ const personaImg = "https://anushkasirv.sirv.com/persona.jpg";
7
+
8
+ /** Sources that can back “Raw Memories” (LLMs + retail/media raw pipelines). */
9
+ const RAW_MEMORY_SOURCE_KEYS = new Set([
10
+ 'chatgpt',
11
+ 'claude',
12
+ 'gemini',
13
+ 'grok',
14
+ 'netflix',
15
+ 'spotify',
16
+ 'sephora',
17
+ ]);
18
+
19
+ const LLM_RAW_MEMORY_SOURCE_KEYS = new Set([
20
+ 'chatgpt',
21
+ 'claude',
22
+ 'gemini',
23
+ 'grok',
24
+ ]);
25
+
26
+ const X_LOGO_SVG =
27
+ 'data:image/svg+xml,%3Csvg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath fill="%23000000" d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/%3E%3C/svg%3E';
28
+
29
+ const DATA_REQUEST_PLATFORM_LOGOS = {
30
+ Instagram: 'https://upload.wikimedia.org/wikipedia/commons/a/a5/Instagram_icon.png',
31
+ YouTube: 'https://upload.wikimedia.org/wikipedia/commons/0/09/YouTube_full-color_icon_%282017%29.svg',
32
+ LinkedIn: 'https://upload.wikimedia.org/wikipedia/commons/c/ca/LinkedIn_logo_initials.png',
33
+ Reddit: 'https://upload.wikimedia.org/wikipedia/en/b/bd/Reddit_Logo_Icon.svg',
34
+ Pinterest: 'https://upload.wikimedia.org/wikipedia/commons/0/08/Pinterest-logo.png',
35
+ Sephora: 'https://www.sephora.com/favicon.ico',
36
+ GitHub: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png',
37
+ Facebook: 'https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg',
38
+ Gmail: 'https://upload.wikimedia.org/wikipedia/commons/7/7e/Gmail_icon_%282020%29.svg',
39
+ X: X_LOGO_SVG,
40
+ Twitter: X_LOGO_SVG,
41
+ ChatGPT: 'https://anushkasirv.sirv.com/openai.png',
42
+ Claude: 'https://anushkasirv.sirv.com/claude-color.png',
43
+ Gemini: 'https://anushkasirv.sirv.com/gemini-color.png',
44
+ Grok: 'https://anushkasirv.sirv.com/grok.png',
45
+ TikTok:
46
+ 'data:image/svg+xml,%3Csvg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath fill="%23010101" d="M14.5 3.5v10.34a3.84 3.84 0 1 1-3.84-3.84c.29 0 .57.03.84.09v2.18a1.7 1.7 0 1 0 .8 1.44V3.5h2.2a3.86 3.86 0 0 0 3.12 3.78v2.13a6.12 6.12 0 0 1-3.12-1.02V3.5z"/%3E%3Cpath fill="%2325F4EE" d="M13.8 2.9v10.34a3.84 3.84 0 1 1-3.84-3.84c.29 0 .57.03.84.09v1.4a2.35 2.35 0 1 0 1.74 2.27V2.9h1.26z" opacity="0.95"/%3E%3C/svg%3E',
47
+ Netflix: 'https://upload.wikimedia.org/wikipedia/commons/0/08/Netflix_2015_logo.svg',
48
+ Spotify: 'https://upload.wikimedia.org/wikipedia/commons/8/84/Spotify_icon.svg',
49
+ };
50
+
51
+ /* -------------------------
52
+ ICON COMPONENTS
53
+ -------------------------- */
54
+ const Icon = ({ type, isGlass }) => {
55
+ const base = `w-4 h-4 ${isGlass ? 'text-white/70' : 'text-gray-700'}`;
56
+
57
+ switch (type) {
58
+ case "User":
59
+ return (
60
+ <svg className={base} viewBox="0 0 24 24" fill="currentColor">
61
+ <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
62
+ </svg>
63
+ );
64
+ case "Memory":
65
+ return (
66
+ <svg className={base} viewBox="0 0 24 24" fill="currentColor">
67
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
68
+ </svg>
69
+ );
70
+ case "Grid3X3":
71
+ return (
72
+ <svg className={base} viewBox="0 0 24 24" fill="currentColor">
73
+ <path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"/>
74
+ </svg>
75
+ );
76
+ case "Brain":
77
+ return (
78
+ <svg className={base} viewBox="0 0 24 24" fill="currentColor">
79
+ <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"/>
80
+ </svg>
81
+ );
82
+ default:
83
+ return null;
84
+ }
85
+ };
86
+
87
+ /* -------------------------
88
+ TOGGLE (soft apple style)
89
+ -------------------------- */
90
+ const DataTypeToggle = ({ dataType, enabled, onToggle, isNative, isGlass }) => {
91
+ const isDisabled = dataType.required || dataType.disabled;
92
+
93
+ const handle = () => {
94
+ if (isDisabled) return;
95
+ onToggle(dataType.id, !enabled);
96
+ };
97
+
98
+ const getTitle = () => {
99
+ if (dataType.required) return 'Required - cannot be disabled';
100
+ if (dataType.disabled && dataType.disabledReason) return dataType.disabledReason;
101
+ return '';
102
+ };
103
+
104
+ const checkboxVisualStyle = {
105
+ width: 20,
106
+ height: 20,
107
+ borderRadius: 6,
108
+ borderWidth: 2,
109
+ borderStyle: 'solid',
110
+ borderColor: dataType.disabled
111
+ ? (isGlass ? 'rgba(255,255,255,0.28)' : '#D1D5DB')
112
+ : enabled
113
+ ? (isGlass ? 'rgba(255,255,255,0.55)' : '#111827')
114
+ : (isGlass ? 'rgba(255,255,255,0.75)' : '#4B5563'),
115
+ backgroundColor: dataType.disabled
116
+ ? (isGlass ? 'rgba(255,255,255,0.06)' : '#F3F4F6')
117
+ : enabled
118
+ ? (isGlass ? 'rgba(255,255,255,0.22)' : '#111827')
119
+ : '#FFFFFF',
120
+ boxShadow: enabled || dataType.disabled
121
+ ? '0 1px 2px rgba(17,24,39,0.12)'
122
+ : `0 0 0 1px ${isGlass ? 'rgba(255,255,255,0.28)' : 'rgba(17,24,39,0.16)'}, inset 0 0 0 1px rgba(255,255,255,0.85)`,
123
+ outline: 'none',
124
+ opacity: 1,
125
+ WebkitAppearance: 'none',
126
+ appearance: 'none',
127
+ WebkitTextFillColor: 'currentColor',
128
+ };
129
+
130
+ return (
131
+ <button
132
+ onClick={handle}
133
+ className={`
134
+ w-full flex items-center justify-between
135
+ py-2.5 px-3
136
+ ${isGlass ? 'bg-white/10' : 'bg-white/40 backdrop-blur-sm'}
137
+ ${isDisabled ? 'cursor-not-allowed opacity-50' : isGlass ? 'hover:bg-white/20 cursor-pointer' : 'hover:bg-white/70 cursor-pointer'}
138
+ transition rounded-xl shadow-sm
139
+ `}
140
+ style={{ maxWidth: '100%', minWidth: 0, boxSizing: 'border-box' }}
141
+ title={getTitle()}
142
+ disabled={dataType.disabled}
143
+ >
144
+ <div className="flex items-center gap-2.5 flex-1 min-w-0">
145
+ <div className={`w-7 h-7 flex items-center justify-center rounded-full flex-shrink-0 ${dataType.disabled ? (isGlass ? 'bg-white/5' : 'bg-gray-200') : (isGlass ? 'bg-white/10' : 'bg-gray-100')}`}>
146
+ <Icon type={dataType.icon} isGlass={isGlass} />
147
+ </div>
148
+ <div className="flex flex-col items-start min-w-0">
149
+ <span className={`${isNative ? 'text-[14px]' : 'text-[13px]'} font-medium ${dataType.disabled ? (isGlass ? 'text-white/40' : 'text-gray-400') : (isGlass ? 'text-white' : 'text-gray-900')}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
150
+ {dataType.name}
151
+ {dataType.required && <span className={`ml-1.5 text-[11px] ${isGlass ? 'text-white/50' : 'text-gray-500'}`}>(Required)</span>}
152
+ </span>
153
+ {dataType.description && (
154
+ <span className={`text-[11px] leading-tight ${dataType.disabled ? (isGlass ? 'text-white/30' : 'text-gray-400') : (isGlass ? 'text-white/50' : 'text-gray-500')}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
155
+ {dataType.description}
156
+ </span>
157
+ )}
158
+ </div>
159
+ </div>
160
+
161
+ <div
162
+ className={`w-5 h-5 rounded-md border-2 flex items-center justify-center shadow-sm flex-shrink-0 ml-2
163
+ transition
164
+ ${dataType.disabled
165
+ ? isGlass ? "bg-white/5 border-white/20" : "bg-gray-100 border-gray-300"
166
+ : enabled
167
+ ? isGlass ? "bg-white/20 border-white/30" : "bg-gray-900 border-gray-900"
168
+ : isGlass ? "bg-transparent border-white/60" : "bg-white border-gray-500"
169
+ }`}
170
+ style={checkboxVisualStyle}
171
+ >
172
+ {enabled && !dataType.disabled && (
173
+ <svg className="w-3 h-3 text-white" style={{ color: '#FFFFFF', WebkitTextFillColor: '#FFFFFF' }} viewBox="0 0 20 20" fill="currentColor">
174
+ <path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"/>
175
+ </svg>
176
+ )}
177
+ </div>
178
+ </button>
179
+ );
180
+ };
181
+
182
+ /* -------------------------
183
+ MAIN COMPONENT
184
+ -------------------------- */
185
+
186
+ const getOptions = (appName, hasRawMemorySources) => [
187
+ { id: "basic", name: "Basic Profile", icon: "User", required: true, description: "Your basic profile information" },
188
+ { id: "preferences", name: "Preferences", icon: "Grid3X3", description: `Your preferences towards ${appName}` },
189
+ { id: "personality", name: "Interests", icon: "Brain", description: "Overview of your personality" },
190
+ {
191
+ id: "rawMemories",
192
+ name: "Raw Memories",
193
+ icon: "Memory",
194
+ description: hasRawMemorySources
195
+ ? "Secure raw app data from your connected sources"
196
+ : "Connect a supported source (LLM, Netflix, Spotify, Sephora, …) to enable",
197
+ disabled: !hasRawMemorySources,
198
+ disabledReason: !hasRawMemorySources ? "Connect a raw data source first" : null,
199
+ },
200
+ ];
201
+
202
+ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connectedPlatforms = [], showTime = false, userEmail = null, onLogout = null, appIcon = null, customTitle = null, theme = 'default', rawMemoriesOnly = false, rawMemoriesConfig = null, requestData = null, allowedPlatforms = null, rawMemoriesOffered = null, demoMode = false }) => {
203
+ const isGlass = theme === 'glass';
204
+ const [selected, setSelected] = useState({
205
+ basic: true,
206
+ rawMemories: false,
207
+ preferences: false,
208
+ personality: false,
209
+ });
210
+
211
+ const normalizedRequestData = Array.isArray(requestData) ? requestData.map((s) => String(s).toLowerCase()) : null;
212
+
213
+ const [freq, setFreq] = useState("weekly");
214
+ const [platformIconFailed, setPlatformIconFailed] = useState({});
215
+ const [platforms, setPlatforms] = useState(() => getConnected());
216
+ const [isSubmitting, setIsSubmitting] = useState(false);
217
+
218
+ const isWrappedApp = typeof appName === 'string' && appName.toLowerCase().includes('wrapped');
219
+
220
+ // Debug: Log props on mount
221
+ useEffect(() => {
222
+ console.log('🔍 [DATAREQUEST-MOUNT] Props received:', {
223
+ userEmail,
224
+ connectedPlatforms,
225
+ appName,
226
+ hasUserEmail: !!userEmail,
227
+ connectedPlatformsType: typeof connectedPlatforms,
228
+ connectedPlatformsIsArray: Array.isArray(connectedPlatforms),
229
+ connectedPlatformsLength: Array.isArray(connectedPlatforms) ? connectedPlatforms.length : 'N/A'
230
+ });
231
+
232
+ // Also check localStorage
233
+ try {
234
+ const u = JSON.parse(localStorage.getItem("onairosUser") || "{}");
235
+ console.log('🔍 [DATAREQUEST-MOUNT] localStorage onairosUser:', {
236
+ email: u.email,
237
+ connectedAccounts: u.connectedAccounts,
238
+ hasConnectedAccounts: !!u.connectedAccounts,
239
+ connectedAccountsLength: Array.isArray(u.connectedAccounts) ? u.connectedAccounts.length : 'N/A'
240
+ });
241
+ } catch (e) {
242
+ console.error('❌ Failed to read localStorage:', e);
243
+ }
244
+ }, []); // Run only once on mount
245
+
246
+ // Normalize platform ids/names coming from different sources (SDK, backend, localStorage)
247
+ // so logos always render (e.g. "linkedin" -> "LinkedIn").
248
+ function normalizePlatformName(p) {
249
+ const key = String(p || '').trim();
250
+ // Reject pure-numeric strings (leaked array indices)
251
+ if (/^\d+$/.test(key)) return '';
252
+ const lower = key.toLowerCase();
253
+ const map = {
254
+ instagram: 'Instagram',
255
+ youtube: 'YouTube',
256
+ linkedin: 'LinkedIn',
257
+ reddit: 'Reddit',
258
+ pinterest: 'Pinterest',
259
+ sephora: 'Sephora',
260
+ github: 'GitHub',
261
+ facebook: 'Facebook',
262
+ gmail: 'Gmail',
263
+ twitter: 'X',
264
+ x: 'X',
265
+ chatgpt: 'ChatGPT',
266
+ claude: 'Claude',
267
+ gemini: 'Gemini',
268
+ grok: 'Grok',
269
+ tiktok: 'TikTok',
270
+ netflix: 'Netflix',
271
+ spotify: 'Spotify',
272
+ };
273
+ return map[lower] || (key ? key.charAt(0).toUpperCase() + key.slice(1) : '');
274
+ }
275
+
276
+ function platformKeyForFilter(displayName) {
277
+ return String(normalizePlatformName(displayName) || '').trim().toLowerCase();
278
+ }
279
+
280
+ function allowlistIncludesAnyRawSource(allowedSet) {
281
+ if (!allowedSet || allowedSet.size === 0) return true;
282
+ for (const k of allowedSet) {
283
+ if (RAW_MEMORY_SOURCE_KEYS.has(k)) return true;
284
+ }
285
+ return false;
286
+ }
287
+
288
+ function userHasConnectedRawSourceInAllowlist(connectedList, allowedSet) {
289
+ const list = Array.isArray(connectedList) ? connectedList : [];
290
+ if (!allowedSet || allowedSet.size === 0) {
291
+ return list.some((p) => RAW_MEMORY_SOURCE_KEYS.has(platformKeyForFilter(p)));
292
+ }
293
+ return list.some((p) => {
294
+ const k = platformKeyForFilter(p);
295
+ return RAW_MEMORY_SOURCE_KEYS.has(k) && allowedSet.has(k);
296
+ });
297
+ }
298
+
299
+ function userHasConnectedLlmRawSourceInAllowlist(connectedList, allowedSet) {
300
+ const list = Array.isArray(connectedList) ? connectedList : [];
301
+ if (!allowedSet || allowedSet.size === 0) {
302
+ return list.some((p) => LLM_RAW_MEMORY_SOURCE_KEYS.has(platformKeyForFilter(p)));
303
+ }
304
+ return list.some((p) => {
305
+ const k = platformKeyForFilter(p);
306
+ return LLM_RAW_MEMORY_SOURCE_KEYS.has(k) && allowedSet.has(k);
307
+ });
308
+ }
309
+
310
+ function developerExplicitlyWantsRawMemoriesInUI() {
311
+ if (rawMemoriesOffered === false) return false;
312
+ if (rawMemoriesOnly || rawMemoriesConfig != null) return true;
313
+ if (requestData == null) return false;
314
+ if (!Array.isArray(requestData) || requestData.length === 0) return false;
315
+ return !!(normalizedRequestData && normalizedRequestData.includes('rawmemories'));
316
+ }
317
+
318
+ function normalizePlatformList(items) {
319
+ const normalized = (Array.isArray(items) ? items : [])
320
+ .map(normalizePlatformName)
321
+ .filter(Boolean);
322
+ return [...new Set(normalized)];
323
+ }
324
+
325
+ function extractPlatformCandidates(source) {
326
+ if (!source || typeof source !== 'object') return [];
327
+ return [
328
+ source.connectedAccounts,
329
+ source.connectedPlatforms,
330
+ source.connected_platforms,
331
+ source.accountStatus?.connectedPlatforms,
332
+ source.accountStatus?.connected_platforms,
333
+ source.AccountStatus?.connectedPlatforms,
334
+ source.AccountStatus?.connected_platforms,
335
+ source.accountInfo?.connectedPlatforms,
336
+ source.accountInfo?.connected_platforms,
337
+ source.AccountInfo?.connectedPlatforms,
338
+ source.AccountInfo?.connected_platforms,
339
+ source.body?.connectedPlatforms,
340
+ source.body?.connected_platforms,
341
+ source.body?.accountStatus?.connectedPlatforms,
342
+ source.body?.accountStatus?.connected_platforms,
343
+ source.body?.AccountStatus?.connectedPlatforms,
344
+ source.body?.AccountStatus?.connected_platforms,
345
+ source.body?.AccountInfo?.connectedPlatforms,
346
+ source.body?.AccountInfo?.connected_platforms,
347
+ source.accountDetails?.existingUserData?.connections,
348
+ source.accountInfo?.existingUserData?.connections,
349
+ source.AccountInfo?.existingUserData?.connections,
350
+ source.body?.accountDetails?.existingUserData?.connections,
351
+ source.body?.accountInfo?.existingUserData?.connections,
352
+ source.body?.AccountInfo?.existingUserData?.connections,
353
+ ];
354
+ }
355
+
356
+ function normalizePlatformCandidate(candidate) {
357
+ if (Array.isArray(candidate)) {
358
+ const objectConnections = candidate
359
+ .map((item) => {
360
+ if (!item || typeof item !== 'object') return item;
361
+ if (item.hasData === false || item.connected === false || item.enabled === false) return '';
362
+ return item.platform || item.displayName || item.name || item.connector || item.id || '';
363
+ })
364
+ .filter(Boolean);
365
+ return normalizePlatformList(objectConnections);
366
+ }
367
+
368
+ if (candidate && typeof candidate === 'object') {
369
+ const mappedRaw = Object.entries(candidate)
370
+ .filter(([_, v]) => Boolean(v))
371
+ .map(([k]) => k);
372
+ return normalizePlatformList(mappedRaw);
373
+ }
374
+
375
+ return [];
376
+ }
377
+
378
+ function readLocalConnectedSnapshot() {
379
+ try {
380
+ const u = JSON.parse(localStorage.getItem("onairosUser") || "{}");
381
+ if (!u || typeof u !== 'object') {
382
+ return { hasField: false, platforms: [] };
383
+ }
384
+
385
+ let sawField = false;
386
+ for (const candidate of extractPlatformCandidates(u)) {
387
+ if (candidate !== undefined && candidate !== null) sawField = true;
388
+ const platforms = normalizePlatformCandidate(candidate);
389
+ if (platforms.length > 0) {
390
+ return { hasField: true, platforms };
391
+ }
392
+ }
393
+
394
+ return { hasField: sawField, platforms: [] };
395
+ } catch (e) {
396
+ console.error('❌ Failed to read localStorage:', e);
397
+ return { hasField: false, platforms: [] };
398
+ }
399
+ }
400
+
401
+ const toggle = (id, val) => {
402
+ // Ensure "basic" is always true (required) and disabled options can't be toggled
403
+ const option = availableOptions.find(opt => opt.id === id);
404
+ if (option?.required || option?.disabled) {
405
+ return; // Don't allow toggling required or disabled options
406
+ }
407
+ setSelected((p) => ({ ...p, [id]: val }));
408
+ };
409
+
410
+ const selectedCount = Object.values(selected).filter(Boolean).length;
411
+
412
+ // Ensure we actually show connected platforms even if prop isn't passed
413
+ function getConnected() {
414
+ console.log('📊 DataRequest getConnected:', {
415
+ connectedPlatforms,
416
+ isArray: Array.isArray(connectedPlatforms),
417
+ type: typeof connectedPlatforms
418
+ });
419
+
420
+ // Prefer non-empty localStorage snapshots: UniversalOnboarding updates them on OAuth return.
421
+ // If localStorage only has an empty/stale field, keep falling through to props/backend.
422
+ const localSnapshot = readLocalConnectedSnapshot();
423
+ if (localSnapshot.platforms.length > 0) {
424
+ console.log('✅ Using localStorage connectedAccounts:', localSnapshot.platforms);
425
+ return localSnapshot.platforms;
426
+ }
427
+
428
+ // Fall back to prop if localStorage isn't available / doesn't have the field.
429
+ // If array provided, use it
430
+ if (Array.isArray(connectedPlatforms) && connectedPlatforms.length > 0) {
431
+ const unique = normalizePlatformList(connectedPlatforms);
432
+ console.log('✅ Using connectedPlatforms prop (array):', connectedPlatforms, '→', unique);
433
+ return unique;
434
+ }
435
+
436
+ // If object provided, map truthy keys
437
+ if (connectedPlatforms && typeof connectedPlatforms === "object" && !Array.isArray(connectedPlatforms)) {
438
+ for (const candidate of [connectedPlatforms, ...extractPlatformCandidates(connectedPlatforms)]) {
439
+ const unique = normalizePlatformCandidate(candidate);
440
+ if (unique.length > 0) {
441
+ console.log('✅ Using connectedPlatforms prop (object):', candidate, '→', unique);
442
+ return unique;
443
+ }
444
+ }
445
+ }
446
+
447
+ console.log('⚠️ No connected platforms found');
448
+ return [];
449
+ }
450
+
451
+ // Refresh platforms list on mount and when connectedPlatforms changes
452
+ useEffect(() => {
453
+ const refreshPlatforms = () => {
454
+ const newPlatforms = getConnected();
455
+ console.log('🔄 DataRequest refreshing platforms:', newPlatforms);
456
+ setPlatforms(newPlatforms);
457
+ };
458
+
459
+ // Initial load
460
+ refreshPlatforms();
461
+
462
+ // If no platforms found and user is authenticated, fetch from backend
463
+ // This helps existing users who don't have connectedAccounts in localStorage yet
464
+ const fetchFromBackendIfNeeded = async () => {
465
+ const currentPlatforms = getConnected();
466
+ console.log('🔍 [FETCH-CHECK] currentPlatforms:', currentPlatforms);
467
+ console.log('🔍 [FETCH-CHECK] userEmail:', userEmail);
468
+ console.log('🔍 [FETCH-CHECK] Should fetch?', currentPlatforms.length === 0 && userEmail);
469
+
470
+ if (currentPlatforms.length === 0 && userEmail) {
471
+ console.log('⚠️ No connected platforms found in localStorage for authenticated user, fetching from backend...');
472
+ try {
473
+ const baseUrl = API_CONFIG.getBaseUrl();
474
+
475
+ console.log('📡 Fetching from:', `${baseUrl}/getAccountInfo/email`);
476
+ console.log('📡 Request body:', { Info: { identifier: userEmail } });
477
+
478
+ const resp = await fetch(`${baseUrl}/getAccountInfo/email`, {
479
+ method: 'POST',
480
+ headers: { 'Content-Type': 'application/json' },
481
+ body: JSON.stringify({ Info: { identifier: userEmail } })
482
+ });
483
+
484
+ console.log('📡 Response status:', resp.status);
485
+ console.log('📡 Response ok:', resp.ok);
486
+
487
+ if (resp.ok) {
488
+ const data = await resp.json();
489
+ console.log('📡 Full response data:', data);
490
+ console.log('📡 accountStatus:', data?.accountStatus);
491
+ console.log('📡 accountStatus.connectedPlatforms:', data?.accountStatus?.connectedPlatforms);
492
+
493
+ const connectedRaw = extractPlatformCandidates(data).find((candidate) => {
494
+ return normalizePlatformCandidate(candidate).length > 0;
495
+ }) || [];
496
+
497
+ console.log('📡 connectedRaw:', connectedRaw);
498
+
499
+ {
500
+ const unique = normalizePlatformCandidate(connectedRaw);
501
+ if (unique.length === 0) {
502
+ console.log('⚠️ No connected platforms found in backend response');
503
+ return;
504
+ }
505
+ console.log('✅ Fetched connected platforms from backend:', unique);
506
+
507
+ // Save to localStorage so it persists
508
+ try {
509
+ const u = JSON.parse(localStorage.getItem("onairosUser") || "{}");
510
+ u.connectedAccounts = unique;
511
+ localStorage.setItem("onairosUser", JSON.stringify(u));
512
+ console.log('💾 Saved connectedAccounts to localStorage');
513
+ } catch (e) {
514
+ console.error('❌ Failed to save to localStorage:', e);
515
+ }
516
+
517
+ // Update platforms display
518
+ setPlatforms(unique);
519
+ // Dispatch event so other components know about the update
520
+ try { window.dispatchEvent(new Event('onairos-connected-accounts-update')); } catch {}
521
+ }
522
+ } else {
523
+ const errorText = await resp.text();
524
+ console.error('❌ Backend request failed:', resp.status, errorText);
525
+ }
526
+ } catch (error) {
527
+ console.error('❌ Failed to fetch connected platforms from backend:', error);
528
+ }
529
+ }
530
+ };
531
+
532
+ fetchFromBackendIfNeeded();
533
+
534
+ // Listen for custom event from UniversalOnboarding
535
+ const handleConnectedAccountsUpdate = () => {
536
+ console.log('📡 DataRequest received connectedAccountsUpdate event');
537
+ refreshPlatforms();
538
+ };
539
+
540
+ // Listen for storage events (cross-tab/window updates)
541
+ const handleStorageChange = (e) => {
542
+ if (e.key === 'onairosUser') {
543
+ console.log('💾 DataRequest detected storage change');
544
+ refreshPlatforms();
545
+ }
546
+ };
547
+
548
+ window.addEventListener('onairos-connected-accounts-update', handleConnectedAccountsUpdate);
549
+ window.addEventListener('storage', handleStorageChange);
550
+
551
+ return () => {
552
+ if (typeof handleConnectedAccountsUpdate === 'function') {
553
+ window.removeEventListener('onairos-connected-accounts-update', handleConnectedAccountsUpdate);
554
+ }
555
+ if (typeof handleStorageChange === 'function') {
556
+ window.removeEventListener('storage', handleStorageChange);
557
+ }
558
+ };
559
+ }, [connectedPlatforms, userEmail]); // Re-run if connectedPlatforms prop or userEmail changes
560
+
561
+ console.log('🎯 Final platforms to display:', platforms);
562
+
563
+ // SDK parity: Capacitor should look like mobile web.
564
+ // Avoid “native-only” sizing differences here.
565
+
566
+ const allowedNormalizedSet = useMemo(() => {
567
+ if (!Array.isArray(allowedPlatforms) || allowedPlatforms.length === 0) return null;
568
+ return new Set(allowedPlatforms.map((p) => platformKeyForFilter(p)).filter(Boolean));
569
+ }, [allowedPlatforms]);
570
+
571
+ const visibleConnectedPlatforms = useMemo(() => {
572
+ if (!allowedNormalizedSet) return platforms;
573
+ return platforms.filter((p) => allowedNormalizedSet.has(platformKeyForFilter(p)));
574
+ }, [platforms, allowedNormalizedSet]);
575
+ const hasVisibleConnectedPlatforms = visibleConnectedPlatforms.length > 0;
576
+
577
+ const hasRawMemorySources = userHasConnectedRawSourceInAllowlist(platforms, allowedNormalizedSet);
578
+ const hasLlmRawMemorySources = userHasConnectedLlmRawSourceInAllowlist(platforms, allowedNormalizedSet);
579
+ const showRawMemoriesOption =
580
+ rawMemoriesOffered !== false &&
581
+ (developerExplicitlyWantsRawMemoriesInUI() || hasLlmRawMemorySources) &&
582
+ hasRawMemorySources &&
583
+ allowlistIncludesAnyRawSource(allowedNormalizedSet);
584
+
585
+ const availableOptions = getOptions(appName, hasRawMemorySources).filter((opt) => {
586
+ if (opt.required) return true;
587
+ if (opt.id === 'rawMemories') return showRawMemoriesOption;
588
+ if (!normalizedRequestData || normalizedRequestData.length === 0) return true;
589
+ return normalizedRequestData.includes(opt.id.toLowerCase());
590
+ });
591
+
592
+ const freqToPercent = (f) => (f === "once" ? 0 : f === "weekly" ? 50 : 100);
593
+
594
+ const showConnectPlatformsCard = visibleConnectedPlatforms.length > 0;
595
+
596
+ const renderConnectPlatformChip = (platform, index) => {
597
+ const src = DATA_REQUEST_PLATFORM_LOGOS[platform] || '';
598
+ const key = `conn-${platform}-${index}`;
599
+ const failed = !!platformIconFailed[key];
600
+ const fallbackText = (() => {
601
+ if (platform === 'LinkedIn') return 'in';
602
+ if (platform === 'YouTube') return 'YT';
603
+ if (platform === 'ChatGPT') return 'AI';
604
+ return String(platform || '?').slice(0, 2).toUpperCase();
605
+ })();
606
+ const face = failed || !src ? (
607
+ <div
608
+ title={platform}
609
+ className="w-6 h-6 rounded-md shadow-sm flex-shrink-0 bg-gray-100 text-gray-700 flex items-center justify-center text-[10px] font-semibold"
610
+ >
611
+ {fallbackText}
612
+ </div>
613
+ ) : (
614
+ <img
615
+ src={src}
616
+ alt={platform}
617
+ title={platform}
618
+ className="w-6 h-6 rounded-md shadow-sm flex-shrink-0"
619
+ onError={() => setPlatformIconFailed((p) => ({ ...p, [key]: true }))}
620
+ />
621
+ );
622
+ return (
623
+ <span key={key} className="inline-flex flex-shrink-0">
624
+ {face}
625
+ </span>
626
+ );
627
+ };
628
+
629
+ const handleRailClick = (e) => {
630
+ const rect = e.currentTarget.getBoundingClientRect();
631
+ const x = Math.max(0, Math.min(rect.width, e.clientX - rect.left));
632
+ const ratio = x / rect.width;
633
+ if (ratio < 1 / 3) setFreq("once");
634
+ else if (ratio < 2 / 3) setFreq("weekly");
635
+ else setFreq("daily");
636
+ };
637
+
638
+ const handleAcceptContinue = async () => {
639
+ if (selectedCount === 0 || isSubmitting || !hasVisibleConnectedPlatforms) return;
640
+ setIsSubmitting(true);
641
+ try {
642
+ await new Promise((resolve) => requestAnimationFrame(resolve));
643
+ await onComplete?.({
644
+ approved: Object.keys(selected).filter(id => selected[id]),
645
+ freq,
646
+ demoMode: !!demoMode,
647
+ });
648
+ } finally {
649
+ setIsSubmitting(false);
650
+ }
651
+ };
652
+
653
+ return (
654
+ <div className={`flex flex-col h-full max-h-full md:max-h-[90vh] rounded-3xl overflow-hidden ${isGlass ? 'bg-transparent' : 'bg-white/70 backdrop-blur-2xl'}`}>
655
+
656
+ {userEmail && (
657
+ <SessionUserBar userEmail={userEmail} onLogout={onLogout} theme={theme} />
658
+ )}
659
+
660
+ {/* CONTENT */}
661
+ <div className="flex-1 overflow-y-auto px-6 pt-3 md:pt-6 pb-2">
662
+
663
+ {/* DEBUG: Manual refresh button (remove in production) */}
664
+ {process.env.NODE_ENV === 'development' && (
665
+ <div className="mb-2 p-2 bg-yellow-100 border border-yellow-300 rounded text-xs">
666
+ <div className="font-bold mb-1">Debug Info:</div>
667
+ <div>Platforms: {platforms.length} connected</div>
668
+ <div>UserEmail: {userEmail || 'Not set'}</div>
669
+ <button
670
+ onClick={async () => {
671
+ console.log('🔄 Manual refresh triggered');
672
+ try {
673
+ const baseUrl = API_CONFIG.getBaseUrl();
674
+
675
+ const resp = await fetch(`${baseUrl}/getAccountInfo/email`, {
676
+ method: 'POST',
677
+ headers: { 'Content-Type': 'application/json' },
678
+ body: JSON.stringify({ Info: { identifier: userEmail } })
679
+ });
680
+
681
+ const data = await resp.json();
682
+ console.log('📡 Manual fetch response:', data);
683
+ alert(`Response received! Check console for details.\nConnected: ${data?.accountStatus?.connectedPlatforms?.length || 0} platforms`);
684
+ } catch (e) {
685
+ console.error('❌ Manual fetch error:', e);
686
+ alert('Error: ' + e.message);
687
+ }
688
+ }}
689
+ className="mt-1 px-2 py-1 bg-blue-500 text-white rounded text-xs"
690
+ >
691
+ Manually Fetch Platforms
692
+ </button>
693
+ </div>
694
+ )}
695
+
696
+ {/* ICONS */}
697
+ <div className="flex justify-center items-center gap-3 mb-3 md:mb-4">
698
+ {/* Wrapped: Onairos -> Persona. Non-wrapped: Onairos -> app placeholder */}
699
+ <div className={`w-10 h-10 rounded-2xl shadow flex items-center justify-center overflow-hidden ${isGlass ? 'bg-white/10' : 'bg-white'}`}>
700
+ <img
701
+ src="https://blasianhokage.sirv.com/Images/Logo%20V1.png"
702
+ alt="Onairos"
703
+ className="w-full h-full object-cover"
704
+ />
705
+ </div>
706
+ <svg className={`w-5 h-5 ${isGlass ? 'text-white/40' : 'text-gray-400'}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
707
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M14 5l7 7m0 0l-7 7m7-7H3" />
708
+ </svg>
709
+ <div className={`w-10 h-10 rounded-2xl shadow flex items-center justify-center overflow-hidden ${isGlass ? 'bg-white/10' : 'bg-white'}`}>
710
+ {appIcon ? (
711
+ <img
712
+ src={appIcon}
713
+ alt={appName}
714
+ className="w-full h-full object-cover"
715
+ onError={(e) => {
716
+ e.currentTarget.style.display = 'none';
717
+ e.currentTarget.parentElement.innerHTML = `<span class="text-lg font-serif font-bold" style="font-family: IBM Plex Sans, system-ui, sans-serif">${(appName || 'A').charAt(0).toUpperCase()}</span>`;
718
+ }}
719
+ />
720
+ ) : isWrappedApp ? (
721
+ <img
722
+ src={personaImg}
723
+ alt="Persona"
724
+ className="w-6 h-6 object-contain rounded-xl"
725
+ onError={(e) => {
726
+ e.currentTarget.style.display = 'none';
727
+ e.currentTarget.parentElement.innerHTML = '<span class="text-xl">🎁</span>';
728
+ }}
729
+ />
730
+ ) : (
731
+ <span className="text-lg font-serif font-bold" style={{ fontFamily: 'IBM Plex Sans, system-ui, sans-serif' }}>{(appName || 'A').charAt(0).toUpperCase()}</span>
732
+ )}
733
+ </div>
734
+ </div>
735
+
736
+ {/* TITLE */}
737
+ <div className="text-center mb-4 md:mb-5">
738
+ <h1 className={`text-[20px] md:text-[22px] font-semibold leading-tight tracking-tight ${isGlass ? 'text-white' : 'text-gray-900'}`} style={{ fontFamily: 'IBM Plex Sans, system-ui, sans-serif' }}>
739
+ {customTitle || `${appName} wants to personalize your experience`}
740
+ </h1>
741
+ <p className={`text-[12px] mt-1 ${isGlass ? 'text-white/50' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>choose what to share</p>
742
+ {demoMode && (
743
+ <p className={`mx-auto mt-2 max-w-[320px] text-[11px] leading-snug ${isGlass ? 'text-white/55' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
744
+ Proof-of-concept mode: this screen shows the consent flow only. The SDK will not process your account data.
745
+ </p>
746
+ )}
747
+ </div>
748
+
749
+ {/* TOGGLES - Always vertical layout */}
750
+ <div className="flex flex-col gap-2 mb-4 md:mb-6">
751
+ {availableOptions.map((opt) => (
752
+ <DataTypeToggle
753
+ key={opt.id}
754
+ dataType={opt}
755
+ enabled={selected[opt.id]}
756
+ onToggle={toggle}
757
+ isNative={false}
758
+ isGlass={isGlass}
759
+ />
760
+ ))}
761
+ </div>
762
+
763
+ {/* FREQUENCY PANEL - Only shown if showTime is true */}
764
+ {showTime && (
765
+ <div className="p-5 rounded-3xl bg-white/50 backdrop-blur-md border border-black/5 shadow-sm">
766
+ <div className="flex justify-between items-center mb-3">
767
+ <span className="text-sm font-medium text-gray-900" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
768
+ How often can {appName} receive updates?
769
+ </span>
770
+ <span className="text-[11px] text-gray-500" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
771
+ {freq === "once"
772
+ ? "one-time only"
773
+ : freq === "weekly"
774
+ ? "once per week"
775
+ : "once per day"}
776
+ </span>
777
+ </div>
778
+
779
+ {/* SLIDER: subtle rail, monochrome progress, click-to-set */}
780
+ <div
781
+ className="relative h-2.5 rounded-full bg-gray-200/90 overflow-hidden mb-4 border border-black/5 shadow-inner cursor-pointer"
782
+ onClick={handleRailClick}
783
+ >
784
+ <div
785
+ className="absolute h-full transition-all rounded-full"
786
+ style={{
787
+ width: `${freqToPercent(freq)}%`,
788
+ background: "linear-gradient(90deg, rgba(31,41,55,0.95) 0%, rgba(107,114,128,0.9) 60%, rgba(209,213,219,0.85) 100%)",
789
+ }}
790
+ />
791
+ {/* Tick marks for 3 stops */}
792
+ <span className="absolute left-0 top-1/2 -translate-y-1/2 w-[2px] h-3 bg-black/10" />
793
+ <span className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[2px] h-3 bg-black/10" />
794
+ <span className="absolute right-0 top-1/2 -translate-y-1/2 w-[2px] h-3 bg-black/10" />
795
+ {/* Thumb indicator (sleek) */}
796
+ <span
797
+ className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-4.5 h-4.5 rounded-full bg-white border border-black/20 shadow-md"
798
+ style={{
799
+ left: `${freqToPercent(freq)}%`,
800
+ }}
801
+ />
802
+ </div>
803
+
804
+ <div className="grid grid-cols-3 text-center text-[12px] font-medium" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
805
+ <button onClick={() => setFreq("once")} className="text-gray-700">1× only</button>
806
+ <button onClick={() => setFreq("weekly")} className="text-gray-900 font-semibold">1× weekly</button>
807
+ <button onClick={() => setFreq("daily")} className="text-gray-700">1× daily</button>
808
+ </div>
809
+
810
+ <p className="text-[11px] text-gray-500 mt-3 leading-snug" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
811
+ This only controls update frequency; It does not grant more access.
812
+ </p>
813
+ </div>
814
+ )}
815
+
816
+ </div>
817
+
818
+ {/* FOOTER */}
819
+ <div className={`px-6 py-3 md:py-4 border-t ${isGlass ? 'bg-transparent border-white/10' : 'bg-white/80 backdrop-blur border-black/5'}`}>
820
+ {showConnectPlatformsCard && (
821
+ <div className={`mb-3 rounded-2xl backdrop-blur border px-3 py-2.5 ${isGlass ? 'bg-white/5 border-white/10' : 'bg-white/60 border-black/5'}`}>
822
+ <div className="text-center mb-1">
823
+ <div className={`text-[13px] font-semibold ${isGlass ? 'text-white' : 'text-gray-900'}`} style={{ fontFamily: 'IBM Plex Sans, system-ui, sans-serif' }}>Connect Platforms</div>
824
+ <div className={`text-[11px] ${isGlass ? 'text-white/50' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>more connections, smarter personalization</div>
825
+ </div>
826
+ <div className="flex items-center justify-center gap-2 overflow-x-auto whitespace-nowrap pb-1" style={{ WebkitOverflowScrolling: 'touch' }}>
827
+ {visibleConnectedPlatforms.map((platform, index) => renderConnectPlatformChip(platform, index))}
828
+ </div>
829
+ {typeof onConnectMoreApps === 'function' && (
830
+ <div className="mt-1 flex justify-center">
831
+ <button
832
+ type="button"
833
+ onClick={onConnectMoreApps}
834
+ className={`text-[11px] font-medium inline-flex items-center gap-1.5 ${isGlass ? 'text-white/60 hover:text-white/90' : 'text-gray-700 hover:text-gray-900'}`}
835
+ style={{ WebkitTextFillColor: isGlass ? undefined : '#111827', fontFamily: 'Inter, system-ui, sans-serif' }}
836
+ >
837
+ <span style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>Connect more</span>
838
+ <span
839
+ aria-hidden="true"
840
+ className={`inline-flex items-center justify-center w-4 h-4 rounded-full border leading-none ${isGlass ? 'border-white/30 text-white/60' : 'border-gray-400 text-gray-800'}`}
841
+ style={{ WebkitTextFillColor: isGlass ? undefined : '#111827' }}
842
+ >
843
+ +
844
+ </span>
845
+ </button>
846
+ </div>
847
+ )}
848
+ </div>
849
+ )}
850
+
851
+ {(!platforms || platforms.length === 0) &&
852
+ visibleConnectedPlatforms.length === 0 &&
853
+ typeof onConnectMoreApps === 'function' && (
854
+ <div className={`mb-3 rounded-2xl backdrop-blur border px-3 py-2 text-center ${isGlass ? 'bg-white/5 border-white/10' : 'bg-white/60 border-black/5'}`}>
855
+ <div className={`text-[11px] mb-1 ${isGlass ? 'text-white/50' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>No apps connected yet</div>
856
+ <button
857
+ type="button"
858
+ onClick={onConnectMoreApps}
859
+ className="text-[12px] font-medium underline underline-offset-2 text-gray-700 hover:text-gray-900"
860
+ style={{ WebkitTextFillColor: '#111827', fontFamily: 'Inter, system-ui, sans-serif' }}
861
+ >
862
+ Connect apps?
863
+ </button>
864
+ </div>
865
+ )}
866
+ <button
867
+ className={`w-full rounded-full py-3 text-sm font-medium shadow-sm flex items-center justify-center gap-2 transition ${selectedCount === 0 || isSubmitting || !hasVisibleConnectedPlatforms ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'} ${isGlass ? 'bg-white/15 border border-white/20' : 'bg-gray-900'}`}
868
+ style={{ color: '#ffffff', fontFamily: 'Inter, system-ui, sans-serif' }}
869
+ disabled={selectedCount === 0 || isSubmitting || !hasVisibleConnectedPlatforms}
870
+ onClick={handleAcceptContinue}
871
+ >
872
+ {isSubmitting ? (
873
+ <svg className="w-4 h-4 animate-spin" viewBox="0 0 24 24" fill="none" aria-hidden="true">
874
+ <circle className="opacity-25" cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="3" />
875
+ <path className="opacity-90" d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" strokeWidth="3" strokeLinecap="round" />
876
+ </svg>
877
+ ) : null}
878
+ {hasVisibleConnectedPlatforms ? 'Accept & Continue' : 'Connect apps to continue'}
879
+ </button>
880
+ </div>
881
+ </div>
882
+ );
883
+ };
884
+
885
+ export default DataRequest;