@onairosofficial/onairos-capacitor 0.1.0 → 0.1.2

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 (202) hide show
  1. package/CAPACITOR_QUICK_START.md +379 -0
  2. package/CONNECTORS.md +122 -0
  3. package/LICENSE +194 -10
  4. package/OnairosofficialOnairosCapacitor.podspec +13 -0
  5. package/Package.swift +26 -0
  6. package/README.md +176 -25
  7. package/dist/onairos.capacitor.esm.js +1 -0
  8. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  9. package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
  10. package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
  11. package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
  12. package/docs/CROSS_SDK_PARITY.md +239 -0
  13. package/docs/DATA_FREQUENCY.md +57 -0
  14. package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
  15. package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
  16. package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
  17. package/docs/PLATFORM_APIS.md +559 -0
  18. package/docs/RAW_MEMORIES_API.md +305 -0
  19. package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
  20. package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
  21. package/docs/oldFixes.md +216 -0
  22. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
  23. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
  24. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
  25. package/onairos.d.ts +656 -0
  26. package/package.json +188 -37
  27. package/src/OnairosReconnectButton.jsx +272 -0
  28. package/src/RSA.jsx +57 -0
  29. package/src/assets/NewLogo.png +0 -0
  30. package/src/assets/OnairosNewLogo.png +0 -0
  31. package/src/assets/chatgpt-icon.png +0 -0
  32. package/src/assets/fire-horse.png +0 -0
  33. package/src/assets/fire-horse.transparent.png +0 -0
  34. package/src/assets/latest-firehorse.png +0 -0
  35. package/src/assets/perplexity.png +0 -0
  36. package/src/assets/persona.png +0 -0
  37. package/src/assets/persona1.png +0 -0
  38. package/src/assets/persona2.png +0 -0
  39. package/src/assets/persona3.png +0 -0
  40. package/src/assets/persona4.png +0 -0
  41. package/src/assets/persona5.png +0 -0
  42. package/src/capacitorConnectorCatalog.js +38 -0
  43. package/src/capacitorOAuthConfig.js +52 -0
  44. package/src/chatgptHostedImport/index.js +303 -0
  45. package/src/components/AuthButtons.jsx +48 -0
  46. package/src/components/ConnectChatGPTModal.jsx +666 -0
  47. package/src/components/ConnectClaudeModal.jsx +610 -0
  48. package/src/components/ConnectGeminiModal.jsx +639 -0
  49. package/src/components/ConnectGrokModal.jsx +701 -0
  50. package/src/components/ConnectPerplexityModal.jsx +726 -0
  51. package/src/components/DataExplainerScreen.jsx +349 -0
  52. package/src/components/DataRequest.js +885 -0
  53. package/src/components/DataRequest.jsx +1055 -0
  54. package/src/components/EmailAuth.js +1871 -0
  55. package/src/components/EmailAuth.jsx +2062 -0
  56. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  57. package/src/components/GoogleButton.js +133 -0
  58. package/src/components/LLMConnectorManager.jsx +201 -0
  59. package/src/components/LoadingPage.jsx +19 -0
  60. package/src/components/LoadingScreen.jsx +81 -0
  61. package/src/components/LunarBirthdate.jsx +96 -0
  62. package/src/components/LunarLoadingPage.jsx +251 -0
  63. package/src/components/Notification.jsx +21 -0
  64. package/src/components/OnairosAppButton.jsx +85 -0
  65. package/src/components/OnairosSSO.jsx +645 -0
  66. package/src/components/OnairosTrigger.jsx +61 -0
  67. package/src/components/PerplexityLogo.jsx +43 -0
  68. package/src/components/PinSetup.js +200 -0
  69. package/src/components/PinSetup.jsx +228 -0
  70. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  71. package/src/components/SdkErrorBoundary.jsx +36 -0
  72. package/src/components/SecuritySetup.js +81 -0
  73. package/src/components/SessionUserBar.jsx +83 -0
  74. package/src/components/SignUp.js +123 -0
  75. package/src/components/TestTelegramButton.js +53 -0
  76. package/src/components/TrainingComponent.jsx +200 -0
  77. package/src/components/TrainingScreen.jsx +897 -0
  78. package/src/components/UniversalOnboarding.js +306 -0
  79. package/src/components/UniversalOnboarding.jsx +4837 -0
  80. package/src/components/ValentineLoadingPage.jsx +502 -0
  81. package/src/components/ValentineModeSelector.jsx +162 -0
  82. package/src/components/WelcomeScreen.jsx +435 -0
  83. package/src/components/WrappedLoadingPage.jsx +205 -0
  84. package/src/components/connectors/ChatGPTConnector.js +348 -0
  85. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  86. package/src/components/connectors/ClaudeConnector.js +44 -0
  87. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  88. package/src/components/connectors/GeminiConnector.js +170 -0
  89. package/src/components/connectors/GeminiConnector.jsx +170 -0
  90. package/src/components/connectors/GmailConnector.js +148 -0
  91. package/src/components/connectors/GmailConnector.jsx +148 -0
  92. package/src/components/connectors/GrokConnector.js +16 -0
  93. package/src/components/connectors/GrokConnector.jsx +16 -0
  94. package/src/components/connectors/HingeConnector.js +419 -0
  95. package/src/components/connectors/HingeConnector.jsx +419 -0
  96. package/src/components/connectors/InstagramDataConnector.js +726 -0
  97. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  98. package/src/components/connectors/LinkedInConnector.js +4 -0
  99. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  100. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  101. package/src/components/connectors/PinterestConnector.js +208 -0
  102. package/src/components/connectors/PinterestConnector.jsx +208 -0
  103. package/src/components/connectors/README.md +292 -0
  104. package/src/components/connectors/RedditConnector.js +229 -0
  105. package/src/components/connectors/RedditConnector.jsx +229 -0
  106. package/src/components/connectors/SephoraConnector.js +482 -0
  107. package/src/components/connectors/SephoraConnector.jsx +482 -0
  108. package/src/components/connectors/TikTokConnector.jsx +430 -0
  109. package/src/components/connectors/YoutubeConnector.js +361 -0
  110. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  111. package/src/components/connectors/index.js +50 -0
  112. package/src/components/icons.jsx +46 -0
  113. package/src/components/icons.tsx +21 -0
  114. package/src/components/ui/PageLayout.jsx +1255 -0
  115. package/src/components/ui/PrimaryButton.jsx +162 -0
  116. package/src/components/ui/button.jsx +49 -0
  117. package/src/components/ui/card.jsx +61 -0
  118. package/src/components/ui/checkbox.jsx +33 -0
  119. package/src/components/ui/label.jsx +29 -0
  120. package/src/components/utils/UpdateConnections.js +45 -0
  121. package/src/components/utils/oauthHelper.js +97 -0
  122. package/src/config/api-config.js +138 -0
  123. package/src/deepLink.jsx +38 -0
  124. package/src/getPin.js +26 -0
  125. package/src/icons/Avatar.png +0 -0
  126. package/src/icons/Sentiment.png +0 -0
  127. package/src/icons/Trait.png +0 -0
  128. package/src/iframe/DataRequestPage.jsx +285 -0
  129. package/src/iframe/OnairosButtonIntegration.md +148 -0
  130. package/src/iframe/components/Box.jsx +56 -0
  131. package/src/iframe/components/IndividualConnection.jsx +88 -0
  132. package/src/iframe/dataRequestHandler.js +714 -0
  133. package/src/iframe/data_request_iframe.html +27 -0
  134. package/src/iframe/data_request_page.js +47 -0
  135. package/src/iframe/icons/Avatar.png +1 -0
  136. package/src/iframe/icons/Avatar2.png +1 -0
  137. package/src/iframe/icons/Sentiment.png +1 -0
  138. package/src/iframe/icons/Trait.png +1 -0
  139. package/src/iframe/icons/onairos_logo.png +0 -0
  140. package/src/iframe/utils/api.js +57 -0
  141. package/src/index.js +274 -0
  142. package/src/laravel/OnairosVue.vue +410 -0
  143. package/src/laravel/blade-helpers.js +320 -0
  144. package/src/laravel/vite-plugin.js +179 -0
  145. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  146. package/src/mobile/components/MobileBox.jsx +71 -0
  147. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  148. package/src/mobile/shims/browser-apis.js +78 -0
  149. package/src/mobile/shims/lucide-shim.js +85 -0
  150. package/src/nativeConnectors.js +5 -0
  151. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  152. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  153. package/src/newUI/PrimaryButton.tsx +213 -0
  154. package/src/newUI/SignInStep.tsx +194 -0
  155. package/src/newUI/VerificationStep.tsx +133 -0
  156. package/src/newUI/WelcomeScreen.tsx +311 -0
  157. package/src/newUI/services/connectedAccountsService.js +129 -0
  158. package/src/onairos.capacitor.jsx +15 -0
  159. package/src/onairos.core.jsx +133 -0
  160. package/src/onairos.jsx +14 -0
  161. package/src/onairos.native.jsx +15 -0
  162. package/src/onairosButton.jsx +9000 -0
  163. package/src/overlay/CheckBox.jsx +114 -0
  164. package/src/overlay/IndividualConnection copy.js +86 -0
  165. package/src/overlay/IndividualConnection.js +191 -0
  166. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  167. package/src/overlay/box.js +84 -0
  168. package/src/overlay/overlay.js +437 -0
  169. package/src/styles/onairos-scoped-preflight.css +97 -0
  170. package/src/styles/sdkCssRegistry.js +20 -0
  171. package/src/styles/styleLoaderInsertShadow.js +69 -0
  172. package/src/styles/tailwind.capacitor.css +395 -0
  173. package/src/styles/tailwind.css +395 -0
  174. package/src/theme/colors.js +40 -0
  175. package/src/utils/apiKeyValidation.js +341 -0
  176. package/src/utils/apiResponseLogger.js +316 -0
  177. package/src/utils/authHeaders.js +275 -0
  178. package/src/utils/biometrics.js +26 -0
  179. package/src/utils/bookmarkletUtils.js +28 -0
  180. package/src/utils/capacitorDetection.js +278 -0
  181. package/src/utils/capacitorLLMHelper.js +352 -0
  182. package/src/utils/capacitorPlugins.js +366 -0
  183. package/src/utils/crossDomainSSO.js +587 -0
  184. package/src/utils/deepLinking.js +27 -0
  185. package/src/utils/devLogger.js +46 -0
  186. package/src/utils/extensionDetection.js +418 -0
  187. package/src/utils/extractMemory.js +277 -0
  188. package/src/utils/framerBrandingOverrides.js +40 -0
  189. package/src/utils/googleWebClientId.js +55 -0
  190. package/src/utils/overlayHandler.js +224 -0
  191. package/src/utils/platformDisconnect.js +309 -0
  192. package/src/utils/pollTrainingStatus.js +200 -0
  193. package/src/utils/rawMemoriesAccess.js +211 -0
  194. package/src/utils/resolveBackendAppId.js +47 -0
  195. package/src/utils/responseFormatter.js +140 -0
  196. package/src/utils/sdkDebugStorage.js +113 -0
  197. package/src/utils/sdkInitialization.js +645 -0
  198. package/src/utils/sessionManager.js +1258 -0
  199. package/src/utils/startBackgroundTraining.js +100 -0
  200. package/src/utils/userDataFormatter.js +222 -0
  201. package/index.d.ts +0 -1
  202. package/index.js +0 -1
@@ -0,0 +1,502 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Lottie from 'lottie-react';
3
+ import { PERPLEXITY_LOGO_DATA_URI } from './PerplexityLogo.jsx';
4
+
5
+ // Pixel Heart Component
6
+ const PixelHeart = ({ className = "", color = "#ff006e", style }) => (
7
+ <svg width="24" height="24" viewBox="0 0 13 11" fill="none" className={className} style={style} xmlns="http://www.w3.org/2000/svg">
8
+ {/* Outline */}
9
+ <path d="M3 0h2v1H3V0zm5 0h2v1H8V0zM2 1h1v1H2V1zm3 0h1v1H5V1zm2 0h1v1H7V1zm3 0h1v1h-1V1zM1 2h1v3H1V2zm10 0h1v3h-1V2zM2 5h1v1H2V5zm8 0h1v1h-1V5zM3 6h1v1H3V6zm6 0h1v1h-1V6zM4 7h1v1H4V7zm4 0h1v1H8V7zM5 8h1v1H5V8zm2 0h1v1H7V8zM6 9h1v1H6V9z" fill="black" />
10
+ {/* Fill */}
11
+ <path d="M3 1h2v1H3V1zm5 0h2v1H8V1zM2 2h9v3H2V2zM3 5h7v1H3V5zM4 6h5v1H4V6zM5 7h3v1H5V7zM6 8h1v1H6V8z" fill={color} />
12
+ {/* Highlight */}
13
+ <rect x="3" y="2" width="1" height="1" fill="white" fillOpacity="0.5" />
14
+ <rect x="4" y="2" width="1" height="1" fill="white" fillOpacity="0.5" />
15
+ </svg>
16
+ );
17
+
18
+ // Animated ellipsis component that cycles through . .. ...
19
+ const AnimatedEllipsis = () => {
20
+ const [dots, setDots] = useState(1);
21
+
22
+ useEffect(() => {
23
+ const interval = setInterval(() => {
24
+ setDots(prev => (prev % 3) + 1);
25
+ }, 500); // Change every 500ms
26
+
27
+ return () => clearInterval(interval);
28
+ }, []);
29
+
30
+ return <span>{'.'.repeat(dots)}</span>;
31
+ };
32
+
33
+ export default function ValentineLoadingPage({
34
+ appName,
35
+ isComplete = false,
36
+ onTransitionComplete,
37
+ mode = 'single',
38
+ connectedPlatforms = [],
39
+ errorTitle = null,
40
+ errorMessage = null,
41
+ errorStatus = null,
42
+ onBack,
43
+ onRetry,
44
+ }) {
45
+ console.log('[ValentineLoadingPage] rendered with props:', { appName, isComplete, mode });
46
+
47
+ const [animationData, setAnimationData] = useState(null);
48
+ const [progress, setProgress] = useState(0);
49
+ const [messageIndex, setMessageIndex] = useState(0);
50
+ const [isAnimatingToComplete, setIsAnimatingToComplete] = useState(false);
51
+ const hasError = Boolean(errorMessage);
52
+ const [timeoutError, setTimeoutError] = useState(null);
53
+ // Prevent brief backend/SDK transient states (422/428) from flashing the "error screen"
54
+ // while a valid dashboard is still being generated and will arrive moments later.
55
+ const [errorGateReady, setErrorGateReady] = useState(false);
56
+ useEffect(() => {
57
+ const id = setTimeout(() => setErrorGateReady(true), 12000);
58
+ return () => clearTimeout(id);
59
+ }, []);
60
+ const showError = errorGateReady && (hasError || Boolean(timeoutError));
61
+ const derivedError = timeoutError || (hasError ? { title: errorTitle, message: errorMessage, status: errorStatus } : null);
62
+ const derivedStatus = derivedError?.status ?? null;
63
+ const isReconnectRequired = derivedStatus === 428 || derivedStatus === 'reconnect_required';
64
+ const connectedList = Array.isArray(connectedPlatforms)
65
+ ? connectedPlatforms.map((x) => String(x || '').trim()).filter(Boolean)
66
+ : [];
67
+ const connectedLabel = connectedList.length ? connectedList.join(', ') : 'None';
68
+ const [platformIconFailed, setPlatformIconFailed] = useState({});
69
+
70
+ const xLogo =
71
+ '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';
72
+ const logoMap = {
73
+ Instagram: 'https://upload.wikimedia.org/wikipedia/commons/a/a5/Instagram_icon.png',
74
+ YouTube: 'https://upload.wikimedia.org/wikipedia/commons/0/09/YouTube_full-color_icon_%282017%29.svg',
75
+ LinkedIn: 'https://upload.wikimedia.org/wikipedia/commons/c/ca/LinkedIn_logo_initials.png',
76
+ Reddit: 'https://upload.wikimedia.org/wikipedia/en/b/bd/Reddit_Logo_Icon.svg',
77
+ Pinterest: 'https://upload.wikimedia.org/wikipedia/commons/0/08/Pinterest-logo.png',
78
+ Sephora: 'https://www.sephora.com/favicon.ico',
79
+ GitHub: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png',
80
+ Facebook: 'https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg',
81
+ Gmail: 'https://upload.wikimedia.org/wikipedia/commons/7/7e/Gmail_icon_%282020%29.svg',
82
+ X: xLogo,
83
+ Twitter: xLogo,
84
+ ChatGPT: 'https://anushkasirv.sirv.com/openai.png',
85
+ Claude: 'https://anushkasirv.sirv.com/claude-color.png',
86
+ Gemini: 'https://anushkasirv.sirv.com/gemini-color.png',
87
+ Grok: 'https://anushkasirv.sirv.com/grok.png',
88
+ Perplexity: PERPLEXITY_LOGO_DATA_URI,
89
+ };
90
+ const getFallbackText = (platform) => {
91
+ if (platform === 'LinkedIn') return 'in';
92
+ if (platform === 'YouTube') return 'YT';
93
+ if (platform === 'ChatGPT') return 'AI';
94
+ return String(platform || '?').slice(0, 2).toUpperCase();
95
+ };
96
+
97
+ // Safety: if backend never resolves, stop infinite loading.
98
+ // After 100 seconds, show a lightweight inline error message.
99
+ useEffect(() => {
100
+ if (isComplete) {
101
+ setTimeoutError(null);
102
+ return;
103
+ }
104
+ if (hasError) return;
105
+ const id = setTimeout(() => {
106
+ setTimeoutError({
107
+ title: 'Still working…',
108
+ message: 'This can take a couple minutes. If it looks stuck, try reconnecting a platform or refreshing.',
109
+ status: null,
110
+ });
111
+ }, 100000); // 100 seconds
112
+ return () => clearTimeout(id);
113
+ }, [hasError, isComplete]);
114
+
115
+ // Valentine-themed messages - different for single vs couple mode
116
+ const singleMessages = [
117
+ "Consulting Cupid's algorithm...",
118
+ "Analyzing your romantic vibe...",
119
+ "Calculating main character energy...",
120
+ "Decoding your love language...",
121
+ "Scanning for red flags (spoiler: you're green)...",
122
+ "Measuring butterflies in stomach...",
123
+ "Preparing your love report...",
124
+ "Simulating your perfect first date...",
125
+ "Detecting crush patterns...",
126
+ "Manifesting your soulmate...",
127
+ "Teaching AI what makes you simp...",
128
+ "Brewing a love potion (legally)...",
129
+ "Reading your digital palm...",
130
+ "Stalking your vibe (respectfully)...",
131
+ "Swiping right on your behalf...",
132
+ "Calculating rizz levels...",
133
+ "Summoning romantic algorithms...",
134
+ "Loading your hot girl/guy era..."
135
+ ];
136
+
137
+ const coupleMessages = [
138
+ "Consulting Cupid's compatibility matrix...",
139
+ "Analyzing relationship resonance...",
140
+ "Calculating couple synergy levels...",
141
+ "Decoding your shared love language...",
142
+ "Scanning for red flags (and green lights)...",
143
+ "Measuring chemistry levels...",
144
+ "Preparing your compatibility report...",
145
+ "Simulating your next date night...",
146
+ "Detecting power couple patterns...",
147
+ "Manifesting couple goals...",
148
+ "Teaching AI what 'us' means...",
149
+ "Brewing a love potion for two...",
150
+ "Stalking both your vibes (consensually)...",
151
+ "Matching your energies...",
152
+ "Measuring combined rizz levels...",
153
+ "Summoning relationship wisdom...",
154
+ "Loading your power couple era...",
155
+ ];
156
+
157
+ const messages = mode === 'couple' ? coupleMessages : singleMessages;
158
+
159
+ useEffect(() => {
160
+ // Use the same rain-anim.json as wrapped loading screen
161
+ console.log('[ValentineLoadingPage] Attempting to load rain animation...');
162
+ fetch('/rain-anim.json')
163
+ .then(res => {
164
+ console.log('[ValentineLoadingPage] Rain animation response:', res.status);
165
+ if (!res.ok) throw new Error('Failed to fetch local animation');
166
+ return res.json();
167
+ })
168
+ .then(data => {
169
+ console.log('[ValentineLoadingPage] Rain animation loaded successfully');
170
+ setAnimationData(data);
171
+ })
172
+ .catch(err => {
173
+ console.error('[ValentineLoadingPage] Failed to load rain animation from local:', err);
174
+ // Fallback: try from the npm package public folder
175
+ console.log('[ValentineLoadingPage] Trying fallback CDN...');
176
+ fetch('https://onairos.sirv.com/rain-anim.json')
177
+ .then(res => {
178
+ console.log('[ValentineLoadingPage] Fallback CDN response:', res.status);
179
+ if (!res.ok) throw new Error('Failed to fetch from CDN');
180
+ return res.json();
181
+ })
182
+ .then(data => {
183
+ console.log('[ValentineLoadingPage] Rain animation loaded from CDN');
184
+ setAnimationData(data);
185
+ })
186
+ .catch(err2 => {
187
+ console.error('[ValentineLoadingPage] Failed to load rain animation from CDN:', err2);
188
+ console.log('[ValentineLoadingPage] Using CSS spinner fallback');
189
+ });
190
+ });
191
+ }, []);
192
+
193
+ // Animate progress bar over ~2 minutes (API can take 1-3 minutes)
194
+ useEffect(() => {
195
+ if (isAnimatingToComplete || showError) return;
196
+
197
+ const duration = 120000; // 2 minutes in ms
198
+ const interval = 100; // Update every 100ms
199
+ const increment = (interval / duration) * 100;
200
+
201
+ const timer = setInterval(() => {
202
+ setProgress(prev => {
203
+ const next = prev + increment;
204
+ return next >= 95 ? 95 : next;
205
+ });
206
+ }, interval);
207
+
208
+ return () => clearInterval(timer);
209
+ }, [isAnimatingToComplete, showError]);
210
+
211
+ // When isComplete becomes true, animate progress to 100%
212
+ useEffect(() => {
213
+ if (!isComplete || isAnimatingToComplete) return;
214
+
215
+ console.log('[ValentineLoadingPage] Valentine data ready - animating progress to 100%');
216
+ setIsAnimatingToComplete(true);
217
+
218
+ const startProgress = progress;
219
+ const duration = 500;
220
+ const startTime = Date.now();
221
+
222
+ const animateToComplete = () => {
223
+ const elapsed = Date.now() - startTime;
224
+ const t = Math.min(elapsed / duration, 1);
225
+
226
+ const eased = 1 - Math.pow(1 - t, 3);
227
+ const currentProgress = startProgress + (100 - startProgress) * eased;
228
+
229
+ setProgress(currentProgress);
230
+
231
+ if (t < 1) {
232
+ requestAnimationFrame(animateToComplete);
233
+ } else {
234
+ setTimeout(() => {
235
+ if (onTransitionComplete) {
236
+ onTransitionComplete();
237
+ }
238
+ }, 200);
239
+ }
240
+ };
241
+
242
+ requestAnimationFrame(animateToComplete);
243
+ }, [isComplete, isAnimatingToComplete, progress, onTransitionComplete]);
244
+
245
+ // Rotate messages
246
+ useEffect(() => {
247
+ if (showError) return;
248
+ const messageTimer = setInterval(() => {
249
+ setMessageIndex(prev => (prev + 1) % messages.length);
250
+ }, 4000);
251
+ return () => clearInterval(messageTimer);
252
+ }, [showError, messages.length]);
253
+
254
+ const effectiveErrorTitle = timeoutError?.title || errorTitle;
255
+ const effectiveErrorMessage = timeoutError?.message || errorMessage;
256
+ const effectiveErrorStatus = timeoutError?.status || errorStatus;
257
+
258
+ return (
259
+ <div
260
+ className={[
261
+ 'flex flex-col items-center h-full px-4 py-4 md:px-6 overflow-hidden',
262
+ showError ? 'justify-start pt-8' : 'justify-center',
263
+ ].join(' ')}
264
+ style={{ backgroundColor: '#ffffff' }}
265
+ >
266
+ <div className="flex flex-col items-center justify-center w-full max-w-2xl space-y-3 md:space-y-5 h-full max-h-[600px]">
267
+
268
+ {/* Title (loading only; hide on error) */}
269
+ {!showError ? (
270
+ <div className="text-center flex-shrink-0 mt-0">
271
+ <h2
272
+ className="text-lg md:text-2xl font-bold mb-1"
273
+ style={{
274
+ fontFamily: "'Press Start 2P', 'Courier New', monospace",
275
+ color: '#ff006e',
276
+ textShadow: '2px 2px 0 #000',
277
+ letterSpacing: '0.05em',
278
+ }}
279
+ >
280
+ PREPARING YOUR VALENTINE
281
+ </h2>
282
+ <p
283
+ className="text-xs md:text-sm px-4 font-medium"
284
+ style={{
285
+ fontFamily: "'Press Start 2P', 'Courier New', monospace",
286
+ color: '#ff006e',
287
+ letterSpacing: '0.05em',
288
+ }}
289
+ >
290
+ RUNNING COMPATIBILITY DIAGNOSTICS
291
+ </p>
292
+ </div>
293
+ ) : null}
294
+
295
+ {/* Warning (shown above the heart) */}
296
+ {showError ? (
297
+ <div className="w-full max-w-xl px-2 flex-shrink-0">
298
+ <div className="flex flex-col items-center text-center">
299
+ <div
300
+ className="flex items-center justify-center"
301
+ style={{ fontSize: 56, lineHeight: 1 }}
302
+ aria-hidden="true"
303
+ >
304
+ ⚠️
305
+ </div>
306
+ <div
307
+ className="mt-3 text-base md:text-lg font-semibold text-gray-900"
308
+ style={{ fontFamily: 'Inter, system-ui, sans-serif', lineHeight: 1.25 }}
309
+ >
310
+ {derivedError?.message
311
+ ? derivedError.message
312
+ : isReconnectRequired
313
+ ? 'Reconnect a platform to continue.'
314
+ : 'Not enough data. Connect more apps to continue.'}
315
+ </div>
316
+
317
+ {typeof onBack === 'function' ? (
318
+ <button
319
+ onClick={onBack}
320
+ className="mt-4 rounded-full bg-gray-900 hover:bg-gray-800 text-white px-6 py-3 text-sm md:text-base font-semibold transition-colors"
321
+ style={{ fontFamily: 'Inter, system-ui, sans-serif' }}
322
+ >
323
+ {isReconnectRequired ? 'Reconnect' : 'Connect more apps'}
324
+ </button>
325
+ ) : null}
326
+ </div>
327
+ </div>
328
+ ) : null}
329
+
330
+ {/* Beautiful Enhanced Spinner */}
331
+ {animationData ? (
332
+ <div
333
+ className="w-full max-w-[200px] md:max-w-[260px] mx-auto flex-shrink-1 min-h-0 aspect-square flex items-center justify-center relative"
334
+ style={showError ? { opacity: 0.35, filter: 'grayscale(1)' } : undefined}
335
+ >
336
+ {console.log('[ValentineLoadingPage] Rendering Lottie animation')}
337
+ <div style={{ filter: 'hue-rotate(300deg) saturate(1.5)', width: '100%', height: '100%' }}>
338
+ <Lottie
339
+ animationData={animationData}
340
+ loop={true}
341
+ autoplay={true}
342
+ style={{ width: '100%', height: '100%' }}
343
+ />
344
+ </div>
345
+ </div>
346
+ ) : (
347
+ <div
348
+ className="w-full max-w-sm h-32 md:h-48 flex items-center justify-center flex-shrink-0 relative"
349
+ style={showError ? { opacity: 0.35, filter: 'grayscale(1)' } : undefined}
350
+ >
351
+ {console.log('[ValentineLoadingPage] Showing enhanced CSS spinner')}
352
+ {/* Multi-layered spinning hearts */}
353
+ <div className="relative w-32 h-32 md:w-40 md:h-40">
354
+ {/* Outer ring */}
355
+ <div className="absolute inset-0 rounded-full border-4 border-transparent border-t-pink-500 animate-spin" style={{ animationDuration: '1.5s' }}></div>
356
+ {/* Middle ring */}
357
+ <div className="absolute inset-2 rounded-full border-4 border-transparent border-r-pink-400 animate-spin" style={{ animationDuration: '2s', animationDirection: 'reverse' }}></div>
358
+ {/* Inner ring */}
359
+ <div className="absolute inset-4 rounded-full border-4 border-transparent border-b-pink-300 animate-spin" style={{ animationDuration: '1s' }}></div>
360
+ {/* Center pulsing pixel heart */}
361
+ <div className="absolute inset-0 flex items-center justify-center">
362
+ <PixelHeart
363
+ className="w-16 h-16 animate-pulse"
364
+ color="#ff006e"
365
+ style={{ animation: 'pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite' }}
366
+ />
367
+ </div>
368
+ </div>
369
+ </div>
370
+ )}
371
+
372
+ {/* Connected platforms (under the heart) */}
373
+ {showError ? (
374
+ <div className="w-full max-w-xl px-2 flex-shrink-0 -mt-2">
375
+ <div className="text-center" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
376
+ <div className="text-base md:text-lg font-semibold text-gray-900">Connected apps</div>
377
+ <div className="mt-2 flex items-center justify-center gap-2 flex-wrap">
378
+ {connectedList.map((platform, index) => {
379
+ const src = logoMap[platform] || '';
380
+ const key = `${platform}-${index}`;
381
+ const failed = !!platformIconFailed[key];
382
+ return failed || !src ? (
383
+ <div
384
+ key={key}
385
+ title={platform}
386
+ className="w-8 h-8 rounded-md shadow-sm flex-shrink-0 bg-gray-100 text-gray-700 flex items-center justify-center text-[11px] font-semibold"
387
+ >
388
+ {getFallbackText(platform)}
389
+ </div>
390
+ ) : (
391
+ <img
392
+ key={key}
393
+ src={src}
394
+ alt={platform}
395
+ title={platform}
396
+ className="w-8 h-8 rounded-md shadow-sm flex-shrink-0"
397
+ onError={() => setPlatformIconFailed((p) => ({ ...p, [key]: true }))}
398
+ />
399
+ );
400
+ })}
401
+ </div>
402
+ <div className="mt-2 text-sm md:text-base text-gray-600">
403
+ {connectedLabel}
404
+ </div>
405
+ </div>
406
+ </div>
407
+ ) : null}
408
+
409
+ {/* Loading progress + captions (loading only; hide on error) */}
410
+ {!showError ? (
411
+ <div className="w-full max-w-xl px-2 flex-shrink-0">
412
+ <div
413
+ className="flex justify-between text-xs font-bold mb-2 px-1"
414
+ style={{
415
+ fontFamily: "'Press Start 2P', 'Courier New', monospace",
416
+ color: '#ff006e',
417
+ }}
418
+ >
419
+ <span>CUPID IS WORKING<AnimatedEllipsis /></span>
420
+ <span>{Math.round(progress)}%</span>
421
+ </div>
422
+
423
+ <div
424
+ className="relative w-full h-4 overflow-hidden border-2 border-black"
425
+ style={{ backgroundColor: '#fecdd3', boxShadow: '4px 4px 0 #000' }}
426
+ >
427
+ <div
428
+ className="absolute top-0 left-0 h-full transition-all duration-300 ease-out"
429
+ style={{ width: `${progress}%`, backgroundColor: '#ff006e' }}
430
+ >
431
+ <div className="w-full h-full absolute inset-0 bg-white/20 animate-pulse"></div>
432
+ </div>
433
+ </div>
434
+
435
+ {/* Rotating message */}
436
+ <div className="h-8 mt-4 flex items-center justify-center">
437
+ <p
438
+ key={messageIndex}
439
+ className="text-center text-sm font-bold animate-fadeIn"
440
+ style={{
441
+ animation: 'fadeIn 0.5s ease-in-out',
442
+ fontFamily: "'Press Start 2P', 'Courier New', monospace",
443
+ color: '#ff006e',
444
+ fontSize: '10px',
445
+ lineHeight: '1.5',
446
+ }}
447
+ >
448
+ {messages[messageIndex].replace(/\.\.\.$/, '')}<AnimatedEllipsis />
449
+ </p>
450
+ </div>
451
+
452
+ {/* Wait message */}
453
+ <div className="mt-5 flex flex-col items-center gap-1.5 max-w-sm mx-auto">
454
+ <div className="h-1 w-12 mb-1.5" style={{ backgroundColor: '#ff006e' }}></div>
455
+ <p
456
+ className="text-xs text-center leading-relaxed font-medium"
457
+ style={{
458
+ fontFamily: "'Press Start 2P', 'Courier New', monospace",
459
+ color: '#ff006e',
460
+ fontSize: '8px',
461
+ lineHeight: '1.6',
462
+ }}
463
+ >
464
+ THIS TAKES ABOUT 1-3 MINUTES TO GENERATE YOUR LOVE PROFILE.
465
+ </p>
466
+ <p
467
+ className="text-xs text-center font-medium"
468
+ style={{
469
+ fontFamily: "'Press Start 2P', 'Courier New', monospace",
470
+ color: '#ff006e',
471
+ fontSize: '8px',
472
+ }}
473
+ >
474
+ DON'T CLOSE THIS WINDOW!
475
+ </p>
476
+ </div>
477
+ </div>
478
+ ) : null}
479
+
480
+ <style>{`
481
+ @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
482
+
483
+ @keyframes fadeIn {
484
+ 0% { opacity: 0; transform: translateY(-4px); }
485
+ 100% { opacity: 1; transform: translateY(0); }
486
+ }
487
+
488
+ @keyframes pulse {
489
+ 0%, 100% {
490
+ transform: scale(1);
491
+ opacity: 1;
492
+ }
493
+ 50% {
494
+ transform: scale(1.15);
495
+ opacity: 0.9;
496
+ }
497
+ }
498
+ `}</style>
499
+ </div>
500
+ </div>
501
+ );
502
+ }
@@ -0,0 +1,162 @@
1
+ import React, { useState } from 'react';
2
+
3
+ export default function ValentineModeSelector({ onSelectMode, currentUserIdentifier, initialMode }) {
4
+ const [mode, setMode] = useState(initialMode || null); // 'single' | 'couple'
5
+ const [partnerId, setPartnerId] = useState('');
6
+ const [copied, setCopied] = useState(false);
7
+
8
+ // If initialMode is provided, we can maybe skip selection if it's 'single',
9
+ // but if it's 'couple', we still need Partner ID.
10
+ // Actually, the parent component handles bypassing if mode is fully set.
11
+ // This component is for when user INPUT is needed.
12
+
13
+ const handleCopyId = () => {
14
+ if (currentUserIdentifier) {
15
+ navigator.clipboard.writeText(currentUserIdentifier);
16
+ setCopied(true);
17
+ setTimeout(() => setCopied(false), 2000);
18
+ }
19
+ };
20
+
21
+ const handleContinue = () => {
22
+ if (mode === 'single') {
23
+ onSelectMode('single');
24
+ } else if (mode === 'couple' && partnerId.trim()) {
25
+ onSelectMode('couple', partnerId.trim());
26
+ }
27
+ };
28
+
29
+ return (
30
+ <div className="flex flex-col items-center justify-center h-full px-6 py-8 bg-pink-50 text-gray-900">
31
+ <div className="max-w-md w-full flex flex-col items-center space-y-6">
32
+
33
+ {/* Header */}
34
+ <div className="text-center space-y-2">
35
+ <h1 className="text-3xl font-bold text-pink-600" style={{ fontFamily: 'Comic Sans MS, cursive, sans-serif' }}>
36
+ Onairos Valentine 💘
37
+ </h1>
38
+ <p className="text-pink-500 font-medium">
39
+ Discover your romantic digital DNA.
40
+ </p>
41
+ </div>
42
+
43
+ {/* Display Current User ID */}
44
+ {currentUserIdentifier && (
45
+ <div className="w-full bg-white rounded-xl border border-pink-200 p-4 shadow-sm flex flex-col items-center gap-2">
46
+ <p className="text-xs font-bold text-pink-400 uppercase tracking-widest">Your Valentine ID</p>
47
+ <div className="flex items-center gap-2 w-full justify-center">
48
+ <code className="bg-pink-50 px-3 py-1.5 rounded-lg text-pink-700 font-mono text-sm border border-pink-100">
49
+ {currentUserIdentifier}
50
+ </code>
51
+ <button
52
+ onClick={handleCopyId}
53
+ className="p-1.5 text-pink-400 hover:text-pink-600 hover:bg-pink-50 rounded-md transition-colors"
54
+ title="Copy ID"
55
+ >
56
+ {copied ? (
57
+ <svg className="w-5 h-5 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" /></svg>
58
+ ) : (
59
+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>
60
+ )}
61
+ </button>
62
+ </div>
63
+ <p className="text-[10px] text-gray-400 text-center">
64
+ Share this ID with your partner for Couple Mode!
65
+ </p>
66
+ </div>
67
+ )}
68
+
69
+ {/* Mode Selection Cards - Hide if initialMode forces a view, or show as toggle */}
70
+ {!initialMode && (
71
+ <div className="grid grid-cols-2 gap-4 w-full">
72
+ <button
73
+ type="button"
74
+ onClick={() => setMode('single')}
75
+ className={`
76
+ relative p-4 rounded-2xl border-2 transition-all duration-200 flex flex-col items-center gap-3
77
+ ${mode === 'single'
78
+ ? 'border-pink-500 bg-pink-100 shadow-md transform scale-105'
79
+ : 'border-pink-200 bg-white hover:border-pink-300 hover:bg-pink-50'}
80
+ `}
81
+ >
82
+ <div className="text-4xl">🧘‍♀️</div>
83
+ <div className="font-bold text-pink-700">Single</div>
84
+ <p className="text-xs text-center text-gray-500">Focus on self-love & individual insights</p>
85
+
86
+ {mode === 'single' && (
87
+ <div className="absolute top-2 right-2 text-pink-600">
88
+ <svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"><path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd"/></svg>
89
+ </div>
90
+ )}
91
+ </button>
92
+
93
+ <button
94
+ type="button"
95
+ onClick={() => setMode('couple')}
96
+ className={`
97
+ relative p-4 rounded-2xl border-2 transition-all duration-200 flex flex-col items-center gap-3
98
+ ${mode === 'couple'
99
+ ? 'border-pink-500 bg-pink-100 shadow-md transform scale-105'
100
+ : 'border-pink-200 bg-white hover:border-pink-300 hover:bg-pink-50'}
101
+ `}
102
+ >
103
+ <div className="text-4xl">💑</div>
104
+ <div className="font-bold text-pink-700">Couple</div>
105
+ <p className="text-xs text-center text-gray-500">Compare stats & compatibility</p>
106
+
107
+ {mode === 'couple' && (
108
+ <div className="absolute top-2 right-2 text-pink-600">
109
+ <svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"><path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd"/></svg>
110
+ </div>
111
+ )}
112
+ </button>
113
+ </div>
114
+ )}
115
+
116
+ {/* Couple Mode Input - Show if mode is couple (either selected or initial) */}
117
+ {mode === 'couple' && (
118
+ <div className="w-full animate-fadeIn">
119
+ <label className="block text-sm font-medium text-pink-700 mb-1">
120
+ Enter Partner's ID
121
+ </label>
122
+ <input
123
+ type="text"
124
+ value={partnerId}
125
+ onChange={(e) => setPartnerId(e.target.value)}
126
+ placeholder="e.g. user123"
127
+ className="w-full px-4 py-3 rounded-xl border border-pink-300 focus:ring-2 focus:ring-pink-500 focus:border-pink-500 outline-none transition-all"
128
+ />
129
+ <p className="mt-2 text-xs text-pink-500">
130
+ Make sure your partner enters your ID too!
131
+ </p>
132
+ </div>
133
+ )}
134
+
135
+ {/* Continue Button */}
136
+ <button
137
+ onClick={handleContinue}
138
+ disabled={!mode || (mode === 'couple' && !partnerId.trim())}
139
+ className={`
140
+ w-full py-3.5 rounded-full font-bold text-white text-lg transition-all shadow-lg
141
+ ${(!mode || (mode === 'couple' && !partnerId.trim()))
142
+ ? 'bg-pink-300 cursor-not-allowed opacity-70'
143
+ : 'bg-pink-500 hover:bg-pink-600 hover:shadow-xl transform hover:-translate-y-0.5'}
144
+ `}
145
+ >
146
+ Start Journey 💖
147
+ </button>
148
+
149
+ </div>
150
+ <style>{`
151
+ @keyframes fadeIn {
152
+ from { opacity: 0; transform: translateY(-10px); }
153
+ to { opacity: 1; transform: translateY(0); }
154
+ }
155
+ .animate-fadeIn {
156
+ animation: fadeIn 0.3s ease-out forwards;
157
+ }
158
+ `}</style>
159
+ </div>
160
+ );
161
+ }
162
+