@powerhousedao/connect 6.2.3-dev.60 → 6.2.3-dev.62

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 (178) hide show
  1. package/README.md +101 -0
  2. package/dist/{AddDriveModal-C5odBO8y.js → AddDriveModal-D_3jDwjp.js} +6 -6
  3. package/dist/AddDriveModal-D_3jDwjp.js.map +1 -0
  4. package/dist/{ClearStorageModal-DE2TKUfn.js → ClearStorageModal-CXWhHez-.js} +9 -11
  5. package/dist/ClearStorageModal-CXWhHez-.js.map +1 -0
  6. package/dist/{ConfirmDocumentUpgradeModal-k79v2wM6.js → ConfirmDocumentUpgradeModal-CrU2Z1CL.js} +5 -5
  7. package/dist/{ConfirmDocumentUpgradeModal-k79v2wM6.js.map → ConfirmDocumentUpgradeModal-CrU2Z1CL.js.map} +1 -1
  8. package/dist/{CookiesPolicyModal-BLw4pnhn.js → CookiesPolicyModal-DQwsgDI9.js} +5 -5
  9. package/dist/{CookiesPolicyModal-BLw4pnhn.js.map → CookiesPolicyModal-DQwsgDI9.js.map} +1 -1
  10. package/dist/{CreateDocumentModal-Bmv0V-kY.js → CreateDocumentModal-Cf1APibL.js} +4 -4
  11. package/dist/{CreateDocumentModal-Bmv0V-kY.js.map → CreateDocumentModal-Cf1APibL.js.map} +1 -1
  12. package/dist/{DebugSettingsModal-BYrr41NU.js → DebugSettingsModal-C0j4mtkx.js} +8 -8
  13. package/dist/{DebugSettingsModal-BYrr41NU.js.map → DebugSettingsModal-C0j4mtkx.js.map} +1 -1
  14. package/dist/{DeleteDriveModal-CjGnG0ht.js → DeleteDriveModal-lE9eCBua.js} +5 -5
  15. package/dist/{DeleteDriveModal-CjGnG0ht.js.map → DeleteDriveModal-lE9eCBua.js.map} +1 -1
  16. package/dist/{DeleteItemModal-BbY_4_xT.js → DeleteItemModal-BFgcGsm3.js} +6 -6
  17. package/dist/{DeleteItemModal-BbY_4_xT.js.map → DeleteItemModal-BFgcGsm3.js.map} +1 -1
  18. package/dist/{DisclaimerModal-DuglmEwL.js → DisclaimerModal-CF6JkIIu.js} +6 -6
  19. package/dist/{DisclaimerModal-DuglmEwL.js.map → DisclaimerModal-CF6JkIIu.js.map} +1 -1
  20. package/dist/{DocumentVersionUnsupportedModal-C4fy7fZ6.js → DocumentVersionUnsupportedModal-Cm9Jb9W7.js} +5 -5
  21. package/dist/DocumentVersionUnsupportedModal-Cm9Jb9W7.js.map +1 -0
  22. package/dist/{DownloadDocumentWithErrorsModal-BsPQ5qgy.js → DownloadDocumentWithErrorsModal-CShKhfEQ.js} +5 -5
  23. package/dist/{DownloadDocumentWithErrorsModal-BsPQ5qgy.js.map → DownloadDocumentWithErrorsModal-CShKhfEQ.js.map} +1 -1
  24. package/dist/{DriveAuthRequiredModal-CtsB0kwH.js → DriveAuthRequiredModal-CMwPUyZf.js} +5 -5
  25. package/dist/{DriveAuthRequiredModal-CtsB0kwH.js.map → DriveAuthRequiredModal-CMwPUyZf.js.map} +1 -1
  26. package/dist/{DriveSettingsModal-d1L0eYof.js → DriveSettingsModal-BSImj4BH.js} +5 -5
  27. package/dist/{DriveSettingsModal-d1L0eYof.js.map → DriveSettingsModal-BSImj4BH.js.map} +1 -1
  28. package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js +2565 -0
  29. package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js.map +1 -0
  30. package/dist/{InspectorModal-CpqAS_PY.js → InspectorModal-CKuKR5g7.js} +9 -9
  31. package/dist/{InspectorModal-CpqAS_PY.js.map → InspectorModal-CKuKR5g7.js.map} +1 -1
  32. package/dist/{LoginModal-CI0ogC2-.js → LoginModal-DT_05uva.js} +6 -6
  33. package/dist/{LoginModal-CI0ogC2-.js.map → LoginModal-DT_05uva.js.map} +1 -1
  34. package/dist/{MissingPackageModal-DS3dgJ1K.js → MissingPackageModal-DtISKgub.js} +6 -6
  35. package/dist/{MissingPackageModal-DS3dgJ1K.js.map → MissingPackageModal-DtISKgub.js.map} +1 -1
  36. package/dist/{OpenFileDocumentsModal-C9vyTb6I.js → OpenFileDocumentsModal-X9GnX2Bk.js} +13 -12
  37. package/dist/OpenFileDocumentsModal-X9GnX2Bk.js.map +1 -0
  38. package/dist/{UpgradeDriveModal-CXX6D5Au.js → UpgradeDriveModal-DvM-PNWe.js} +6 -6
  39. package/dist/{UpgradeDriveModal-CXX6D5Au.js.map → UpgradeDriveModal-DvM-PNWe.js.map} +1 -1
  40. package/dist/app-layout-BIq-ZW-6.js +394 -0
  41. package/dist/app-layout-BIq-ZW-6.js.map +1 -0
  42. package/dist/app-loader-DqNf3gc0.js +1291 -0
  43. package/dist/app-loader-DqNf3gc0.js.map +1 -0
  44. package/dist/app-loader-gMCokq-Y.js +4 -0
  45. package/dist/{app-skeleton-CBN4tenZ.js → app-skeleton-DYLZ7npI.js} +3 -3
  46. package/dist/{app-skeleton--Me5zlSz.js → app-skeleton-gzg8cRzm.js} +7 -7
  47. package/dist/app-skeleton-gzg8cRzm.js.map +1 -0
  48. package/dist/{boot-CNW7ypcB.js → boot-CC_DgQKX.js} +32 -9
  49. package/dist/boot-CC_DgQKX.js.map +1 -0
  50. package/dist/{build-info-CRwnXFRI.js → build-info-BL03di3M.js} +5 -5
  51. package/dist/{build-info-CRwnXFRI.js.map → build-info-BL03di3M.js.map} +1 -1
  52. package/dist/components-D4yHqff7.js +120 -0
  53. package/dist/components-D4yHqff7.js.map +1 -0
  54. package/dist/connect-router-KmNBGS0G.js +434 -0
  55. package/dist/connect-router-KmNBGS0G.js.map +1 -0
  56. package/dist/{connect.config-CB78ZsFz.js → connect.config-uZF-gnvV.js} +7 -7
  57. package/dist/{connect.config-CB78ZsFz.js.map → connect.config-uZF-gnvV.js.map} +1 -1
  58. package/dist/{connection-state-BDikOGKo.js → connection-state-C_477Kr_.js} +6 -6
  59. package/dist/{connection-state-BDikOGKo.js.map → connection-state-C_477Kr_.js.map} +1 -1
  60. package/dist/context-De2EB1AA-Ni0d829Q.js +1759 -0
  61. package/dist/context-De2EB1AA-Ni0d829Q.js.map +1 -0
  62. package/dist/{cookie-banner-D05DZRqY.js → cookie-banner-HPgyuHM5.js} +6 -6
  63. package/dist/{cookie-banner-D05DZRqY.js.map → cookie-banner-HPgyuHM5.js.map} +1 -1
  64. package/dist/drive-icon-BiVP8yJc.js +38 -0
  65. package/dist/drive-icon-BiVP8yJc.js.map +1 -0
  66. package/dist/esm-BDACZntJ.js +148 -0
  67. package/dist/esm-BDACZntJ.js.map +1 -0
  68. package/dist/index-UrZFqSgm.d.ts +166 -0
  69. package/dist/index-UrZFqSgm.d.ts.map +1 -0
  70. package/dist/layout.d.ts +29 -0
  71. package/dist/layout.d.ts.map +1 -0
  72. package/dist/layout.js +6 -0
  73. package/dist/{load-BO0qVu72.js → load-CEuzCNRz.js} +48 -48
  74. package/dist/load-CEuzCNRz.js.map +1 -0
  75. package/dist/main.js +2 -2
  76. package/dist/{multi-reactor-BG-DqUcm.js → multi-reactor-fSKpLBjT.js} +10 -7
  77. package/dist/multi-reactor-fSKpLBjT.js.map +1 -0
  78. package/dist/open-file-uploads-BcyWmUZn.js +183 -0
  79. package/dist/open-file-uploads-BcyWmUZn.js.map +1 -0
  80. package/dist/{package-manager-BPVMRBoV.js → package-manager-BkFRzovd.js} +52 -45
  81. package/dist/package-manager-BkFRzovd.js.map +1 -0
  82. package/dist/{pglite-migrate-core-BcXcImng.js → pglite-migrate-core-DBlU6HIc.js} +4 -4
  83. package/dist/pglite-migrate-core-DBlU6HIc.js.map +1 -0
  84. package/dist/{pglite-seed-CQJ97bEt.js → pglite-seed-BsEPByVM.js} +4 -4
  85. package/dist/{pglite-seed-CQJ97bEt.js.map → pglite-seed-BsEPByVM.js.map} +1 -1
  86. package/dist/{preferences-store-Cm0BoiHA.js → preferences-store-DANUajdg.js} +4 -4
  87. package/dist/{preferences-store-Cm0BoiHA.js.map → preferences-store-DANUajdg.js.map} +1 -1
  88. package/dist/prerendered-shell-DxCUDEXL.js +45 -0
  89. package/dist/prerendered-shell-DxCUDEXL.js.map +1 -0
  90. package/dist/{reactor-B8Sh7Et8.js → reactor-DmBtssmg.js} +50 -46
  91. package/dist/reactor-DmBtssmg.js.map +1 -0
  92. package/dist/reactor-chat-LAB-9G3G.js +50 -0
  93. package/dist/reactor-chat-LAB-9G3G.js.map +1 -0
  94. package/dist/reactor.worker.js +85 -27
  95. package/dist/reactor.worker.js.map +1 -1
  96. package/dist/{registerServiceWorker-DT6t8wjg.js → registerServiceWorker-CkVxA2KC.js} +4 -4
  97. package/dist/{registerServiceWorker-DT6t8wjg.js.map → registerServiceWorker-CkVxA2KC.js.map} +1 -1
  98. package/dist/route-components-BkztQruF.js +148 -0
  99. package/dist/route-components-BkztQruF.js.map +1 -0
  100. package/dist/route-tree.d.ts +2229 -0
  101. package/dist/route-tree.d.ts.map +1 -0
  102. package/dist/route-tree.js +211 -0
  103. package/dist/route-tree.js.map +1 -0
  104. package/dist/router-B4Z1LV9b.js +4 -0
  105. package/dist/router-BlxJIE3W.js +604 -0
  106. package/dist/router-BlxJIE3W.js.map +1 -0
  107. package/dist/router.d.ts +4 -0
  108. package/dist/router.js +7 -0
  109. package/dist/{runtime-config-DI5OfIC6.js → runtime-config-DdN1Frg7.js} +6 -9
  110. package/dist/runtime-config-DdN1Frg7.js.map +1 -0
  111. package/dist/{sentry-jfDyrxdX.js → sentry-CJb7--mu.js} +7 -4
  112. package/dist/{sentry-jfDyrxdX.js.map → sentry-CJb7--mu.js.map} +1 -1
  113. package/dist/{SettingsModal-_hk8S-ey.js → settings-2Id1UgNY.js} +126 -83
  114. package/dist/settings-2Id1UgNY.js.map +1 -0
  115. package/dist/settings-CjvK8OKA.js +91 -0
  116. package/dist/settings-CjvK8OKA.js.map +1 -0
  117. package/dist/shell-head.html +1 -0
  118. package/dist/shell.html +1 -0
  119. package/dist/sidebar-BXf8OEwm.d.ts +34 -0
  120. package/dist/sidebar-BXf8OEwm.d.ts.map +1 -0
  121. package/dist/sidebar-lAVFRsni.js +31 -0
  122. package/dist/sidebar-lAVFRsni.js.map +1 -0
  123. package/dist/start-connect.d.ts +4 -1
  124. package/dist/start-connect.d.ts.map +1 -1
  125. package/dist/start-connect.js +9 -5
  126. package/dist/start-connect.js.map +1 -1
  127. package/dist/style.css +36 -18
  128. package/dist/{useRegistryPackages-3EcR3GOh.js → useRegistryPackages-BqIWwXV-.js} +5 -5
  129. package/dist/{useRegistryPackages-3EcR3GOh.js.map → useRegistryPackages-BqIWwXV-.js.map} +1 -1
  130. package/fonts.css +177 -0
  131. package/package.json +51 -22
  132. package/scripts/critical-css.ts +243 -0
  133. package/scripts/prerender-shell.ts +100 -0
  134. package/src/routeTree.gen.ts +293 -0
  135. package/src/router/connect-router.ts +170 -0
  136. package/src/router/drive-route-loader.ts +116 -0
  137. package/src/router/index.ts +51 -0
  138. package/src/router/navigation.ts +230 -0
  139. package/src/router/perf-marks.test.tsx +98 -0
  140. package/src/router/perf-marks.ts +97 -0
  141. package/src/router/register.ts +9 -0
  142. package/src/router/route-components.tsx +98 -0
  143. package/src/router/route-tree.ts +88 -0
  144. package/src/router/scroll.ts +69 -0
  145. package/src/router/search.ts +66 -0
  146. package/src/router/settings.ts +120 -0
  147. package/src/router/sidebar.ts +55 -0
  148. package/src/router/titles.test.ts +24 -0
  149. package/src/router/titles.ts +33 -0
  150. package/src/routes/__root.tsx +28 -0
  151. package/src/routes/core/_app/$.tsx +13 -0
  152. package/src/routes/core/_app/_content/d/$driveSlug/{-$nodeSlug}.tsx +52 -0
  153. package/src/routes/core/_app/_content/index.tsx +3 -0
  154. package/src/routes/core/_app/_content.tsx +9 -0
  155. package/src/routes/core/_app/settings/about.tsx +20 -0
  156. package/src/routes/core/_app/settings/ai-assistant.tsx +20 -0
  157. package/src/routes/core/_app/settings/danger-zone.tsx +21 -0
  158. package/src/routes/core/_app/settings/default-editors.tsx +20 -0
  159. package/src/routes/core/_app/settings/package-manager.tsx +20 -0
  160. package/src/routes/core/_app/settings.tsx +35 -0
  161. package/src/routes/core/_app.tsx +10 -0
  162. package/dist/AddDriveModal-C5odBO8y.js.map +0 -1
  163. package/dist/ClearStorageModal-DE2TKUfn.js.map +0 -1
  164. package/dist/DocumentVersionUnsupportedModal-C4fy7fZ6.js.map +0 -1
  165. package/dist/OpenFileDocumentsModal-C9vyTb6I.js.map +0 -1
  166. package/dist/SettingsModal-_hk8S-ey.js.map +0 -1
  167. package/dist/app-loader-C_y2O5-k.js +0 -2379
  168. package/dist/app-loader-C_y2O5-k.js.map +0 -1
  169. package/dist/app-loader-DthM3kLU.js +0 -4
  170. package/dist/app-skeleton--Me5zlSz.js.map +0 -1
  171. package/dist/boot-CNW7ypcB.js.map +0 -1
  172. package/dist/components-DVQlpeR0.js +0 -5
  173. package/dist/load-BO0qVu72.js.map +0 -1
  174. package/dist/multi-reactor-BG-DqUcm.js.map +0 -1
  175. package/dist/package-manager-BPVMRBoV.js.map +0 -1
  176. package/dist/pglite-migrate-core-BcXcImng.js.map +0 -1
  177. package/dist/reactor-B8Sh7Et8.js.map +0 -1
  178. package/dist/runtime-config-DI5OfIC6.js.map +0 -1
@@ -0,0 +1,1291 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fb571d15-627e-5160-8820-2247b7ba2dee")}catch(e){}}();
3
+ import { t as LoadingShell } from "./prerendered-shell-DxCUDEXL.js";
4
+ import { t as getRuntimeConfig } from "./runtime-config-DdN1Frg7.js";
5
+ import { n as drainOpenPanelBuffer, t as clearOpenPanelBuffer } from "./buffer-DNTcuap_.js";
6
+ import { n as setSentryModule } from "./sentry-CJb7--mu.js";
7
+ import { c as DetailedFallback, l as ErrorBoundary } from "./app-layout-BIq-ZW-6.js";
8
+ import { c as idbError, d as isStoredDocumentsRefused } from "./pglite-major-p4_YefAE.js";
9
+ import { n as cloneFileData, r as migrateIdb } from "./pglite-migrate-core-DBlU6HIc.js";
10
+ import "./i18n-CTgT1HG-.js";
11
+ import { n as setMigrationStatus, t as AppSkeleton } from "./app-skeleton-gzg8cRzm.js";
12
+ import { r as connectConfig } from "./connect.config-uZF-gnvV.js";
13
+ import { n as useAcceptedCookies } from "./preferences-store-DANUajdg.js";
14
+ import { t as ToastContainer } from "./toast-C6WW-_O-.js";
15
+ import { t as Router } from "./router-BlxJIE3W.js";
16
+ import { a as subscribeOpenFileUploads, c as initLaunchQueueFileHandling, n as getOpenFileUploads, r as removeOpenFileUpload, t as clearOpenFileUploads } from "./open-file-uploads-BcyWmUZn.js";
17
+ import { c as getCachedMigrationMajor, d as subscribeMigrationMajor, i as subscribeWorkerConnection, n as getWorkerConnectionStatus, p as PRIMARY_IDB_NAMES } from "./connection-state-C_477Kr_.js";
18
+ import { n as serviceWorkerManager, r as subscribeServiceWorkerUpdate, t as getServiceWorkerUpdateAvailable } from "./registerServiceWorker-CkVxA2KC.js";
19
+ import { StrictMode, Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
20
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
21
+ import { PHStoreProvider, RenownWalletProvider, bindPHStoreToWindow, createPHStore, getActivePHStore, setSelectedNode, showPHModal, useEditorPreloader, usePHModal, usePackageDiscoveryService, useReactorClientModule, useTheme, useUser } from "@powerhousedao/reactor-browser";
22
+ import { PackageInstallModal, UploadFileListContainer } from "@powerhousedao/design-system/connect";
23
+ import { Icon, Modal, PowerhouseButton } from "@powerhousedao/design-system";
24
+ import { childLogger } from "document-model";
25
+ import { z } from "zod";
26
+ import { twMerge } from "tailwind-merge";
27
+ import { mockAdapter } from "@renown/sdk/wallet/mock";
28
+ import { privyAdapter } from "@renown/sdk/wallet/privy";
29
+ import { rainbowAdapter } from "@renown/sdk/wallet/rainbow";
30
+ import { arbitrum, base, mainnet, optimism, polygon, sepolia } from "wagmi/chains";
31
+ //#region src/components/analytics.tsx
32
+ function gtag(...args) {
33
+ window.dataLayer?.push(...args);
34
+ }
35
+ const Analytics = () => {
36
+ const gaTrackingId = connectConfig.gaTrackingId;
37
+ const [{ analytics }] = useAcceptedCookies();
38
+ const useAnalytics = gaTrackingId && analytics;
39
+ useEffect(() => {
40
+ if (useAnalytics) {
41
+ const script = document.createElement("script");
42
+ script.src = `https://www.googletagmanager.com/gtag/js?id=${gaTrackingId}`;
43
+ script.async = true;
44
+ document.head.appendChild(script);
45
+ window.dataLayer = window.dataLayer || [];
46
+ gtag("js", /* @__PURE__ */ new Date());
47
+ gtag("config", gaTrackingId);
48
+ return () => {
49
+ document.head.removeChild(script);
50
+ };
51
+ }
52
+ }, [useAnalytics, gaTrackingId]);
53
+ return null;
54
+ };
55
+ //#endregion
56
+ //#region src/services/openpanel/client.ts
57
+ let client;
58
+ /**
59
+ * Returns the cached `OpenPanel` singleton, building it on first call.
60
+ *
61
+ * When `config.clientId` is empty it returns `undefined` without importing
62
+ * `@openpanel/web`, so the bundler can tree-shake the SDK out of production.
63
+ */
64
+ async function getOpenPanelClient(config) {
65
+ if (!config.clientId) return;
66
+ if (client) return client;
67
+ const { OpenPanel: OpenPanelClass } = await import("@openpanel/web");
68
+ client = new OpenPanelClass({
69
+ clientId: config.clientId,
70
+ ...config.apiUrl ? { apiUrl: config.apiUrl } : {},
71
+ trackScreenViews: true,
72
+ trackOutgoingLinks: true
73
+ });
74
+ client.setGlobalProperties({ app: "connect" });
75
+ drainOpenPanelBuffer(client);
76
+ return client;
77
+ }
78
+ /**
79
+ * Clears the cached singleton and the pre-init buffer. Call on consent
80
+ * revocation or during tests; buffered events are discarded, not replayed.
81
+ */
82
+ function resetOpenPanelClient() {
83
+ client = void 0;
84
+ clearOpenPanelBuffer();
85
+ }
86
+ //#endregion
87
+ //#region src/services/openpanel/events.json
88
+ var events_default = [
89
+ {
90
+ "documentType": "powerhouse/document-drive",
91
+ "actionTypes": [
92
+ "ADD_FOLDER",
93
+ "DELETE_NODE",
94
+ "ADD_FILE",
95
+ "UPDATE_FILE",
96
+ "COPY_NODE",
97
+ "MOVE_NODE",
98
+ "SET_DRIVE_NAME",
99
+ "SET_DRIVE_ICON"
100
+ ]
101
+ },
102
+ {
103
+ "documentType": "powerhouse/document-model",
104
+ "actionTypes": [
105
+ "SET_MODEL_NAME",
106
+ "SET_MODEL_ID",
107
+ "ADD_MODULE",
108
+ "DELETE_MODULE",
109
+ "ADD_OPERATION",
110
+ "DELETE_OPERATION"
111
+ ]
112
+ },
113
+ {
114
+ "documentType": "powerhouse/reactor-drive",
115
+ "actionTypes": [
116
+ "ADD_FOLDER",
117
+ "REMOVE_FOLDER",
118
+ "UPDATE_FOLDER"
119
+ ]
120
+ }
121
+ ];
122
+ //#endregion
123
+ //#region src/services/openpanel/events.ts
124
+ const EventMappingSchema = z.object({
125
+ documentType: z.string().min(1),
126
+ actionTypes: z.array(z.string().min(1)).min(1),
127
+ alias: z.string().optional()
128
+ }).strict();
129
+ const EventMappingsSchema = z.array(EventMappingSchema).readonly();
130
+ /**
131
+ * Parses and validates the event mapping table, returning the validated array
132
+ * and an O(1) lookup map. Accepts a `raw` override for tests. Throws on zod
133
+ * failures and on duplicate `(documentType, actionType)` pairs.
134
+ */
135
+ function loadEvents(raw = events_default) {
136
+ const result = EventMappingsSchema.safeParse(raw);
137
+ if (!result.success) throw new Error(`Invalid OpenPanel events.json: ${result.error.message}`);
138
+ const mappings = result.data;
139
+ const lookupMap = /* @__PURE__ */ new Map();
140
+ for (const mapping of mappings) {
141
+ let inner = lookupMap.get(mapping.documentType);
142
+ if (!inner) {
143
+ inner = /* @__PURE__ */ new Map();
144
+ lookupMap.set(mapping.documentType, inner);
145
+ }
146
+ for (const actionType of mapping.actionTypes) {
147
+ if (inner.has(actionType)) throw new Error(`Duplicate OpenPanel event mapping for ${mapping.documentType}/${actionType}`);
148
+ inner.set(actionType, mapping);
149
+ }
150
+ }
151
+ return {
152
+ mappings,
153
+ lookupMap
154
+ };
155
+ }
156
+ const { mappings: defaultMappings, lookupMap: defaultLookupMap } = loadEvents();
157
+ /** Validated mapping array from the bundled events.json. */
158
+ const eventMappings = defaultMappings;
159
+ /** O(1) lookup map: documentType → actionType → mapping. */
160
+ const eventLookupMap = defaultLookupMap;
161
+ /**
162
+ * Normalizes a document type into a safe event-name segment: lowercased, `/`
163
+ * replaced with `.`, and any character outside `[a-z0-9._-]` stripped.
164
+ * e.g. `powerhouse/document-drive` → `powerhouse.document-drive`.
165
+ */
166
+ function normalize(documentType) {
167
+ return documentType.toLowerCase().replace(/\//g, ".").replace(/[^a-z0-9._-]/g, "");
168
+ }
169
+ /**
170
+ * Derives the OpenPanel event name: `mapping.alias` when present, otherwise
171
+ * `${normalize(documentType)}.${actionType.toLowerCase()}`.
172
+ */
173
+ function deriveEventName(mapping, op) {
174
+ if (mapping.alias) return mapping.alias;
175
+ return `${normalize(op.context.documentType)}.${op.operation.action.type.toLowerCase()}`;
176
+ }
177
+ /**
178
+ * Builds the default properties attached to every OpenPanel event. The `app`
179
+ * property is stamped globally by the client, not here.
180
+ */
181
+ function buildDefaultProperties(op) {
182
+ return {
183
+ documentType: op.context.documentType,
184
+ actionType: op.operation.action.type,
185
+ documentId: op.context.documentId,
186
+ scope: op.context.scope,
187
+ branch: op.context.branch
188
+ };
189
+ }
190
+ //#endregion
191
+ //#region src/services/openpanel/processor.ts
192
+ /**
193
+ * Read-only reactor `IProcessor` that translates matching document operations
194
+ * into OpenPanel analytics events. Operations whose `(documentType, actionType)`
195
+ * pair is absent from the lookup map are skipped; per-operation errors are
196
+ * routed to `onError` and never thrown back to the manager.
197
+ */
198
+ var OpenPanelProcessor = class {
199
+ client;
200
+ lookupMap;
201
+ onError;
202
+ constructor(client, lookupMap, onError = (err) => console.warn("[OpenPanelProcessor] Error tracking event:", err)) {
203
+ this.client = client;
204
+ this.lookupMap = lookupMap;
205
+ this.onError = onError;
206
+ }
207
+ async onOperations(operations) {
208
+ for (const op of operations) {
209
+ const inner = this.lookupMap.get(op.context.documentType);
210
+ if (!inner) continue;
211
+ const mapping = inner.get(op.operation.action.type);
212
+ if (!mapping) continue;
213
+ const name = deriveEventName(mapping, op);
214
+ const payload = buildDefaultProperties(op);
215
+ try {
216
+ await this.client.track(name, payload);
217
+ } catch (err) {
218
+ this.onError(err, op);
219
+ }
220
+ }
221
+ }
222
+ onDisconnect() {
223
+ this.client.flush?.();
224
+ return Promise.resolve();
225
+ }
226
+ };
227
+ //#endregion
228
+ //#region src/services/openpanel/factory.ts
229
+ /**
230
+ * Returns a `ProcessorFactory` that, for each drive, creates a single
231
+ * `OpenPanelProcessor` record whose `filter.documentType` is the union of all
232
+ * document types present in the event mapping table.
233
+ */
234
+ function createOpenPanelProcessorFactory(config) {
235
+ return function openPanelProcessorFactory(_driveHeader) {
236
+ const documentType = Array.from(config.events.lookupMap.keys());
237
+ return [{
238
+ processor: new OpenPanelProcessor(config.client, config.events.lookupMap, config.onError),
239
+ filter: { documentType },
240
+ startFrom: config.startFrom ?? "current"
241
+ }];
242
+ };
243
+ }
244
+ //#endregion
245
+ //#region src/components/openpanel-traits.ts
246
+ /**
247
+ * Builds the OpenPanel identity traits from a renown User.
248
+ *
249
+ * Canonical trait schema (shared with Renown and Vetra — each app sends every
250
+ * field it has data for, under these names):
251
+ * - `address`, `did`, `networkId`, `chainId`, `caip2` — wallet/chain facts.
252
+ * - `ensName`, `ensAvatar` — raw ENS facts.
253
+ * - `username`, `userImage`, `profileDocumentId`, `profileCreatedAt` — raw
254
+ * Renown profile facts.
255
+ * - `accountType` — wallet-adapter concept; only Renown has it.
256
+ *
257
+ * Rules:
258
+ * - `credential` (contains a JWT) is **never** forwarded.
259
+ * - Traits carry raw facts only; resolved presentation values (avatar,
260
+ * display name) go in OpenPanel's native identify fields — see
261
+ * {@link buildIdentifyPayload}.
262
+ * - Optional fields (`ens`, `profile`) are only included when their value is
263
+ * non-nullish (guards against `null` from `RenownProfile` fields as well
264
+ * as plain `undefined`).
265
+ *
266
+ * Mirror the Sentry pattern in `store/user.ts`: destructure off `credential`
267
+ * first, then assemble the trait payload from the remainder.
268
+ */
269
+ function buildTraits(user) {
270
+ const { credential: _credential, ...rest } = user;
271
+ const traits = {
272
+ address: rest.address,
273
+ did: rest.did,
274
+ networkId: rest.networkId,
275
+ chainId: rest.chainId,
276
+ caip2: `${rest.networkId}:${rest.chainId}`
277
+ };
278
+ if (rest.ens?.name != null) traits.ensName = rest.ens.name;
279
+ if (rest.ens?.avatarUrl != null) traits.ensAvatar = rest.ens.avatarUrl;
280
+ if (rest.profile?.username != null) traits.username = rest.profile.username;
281
+ if (rest.profile?.userImage != null) traits.userImage = rest.profile.userImage;
282
+ if (rest.profile?.documentId != null) traits.profileDocumentId = rest.profile.documentId;
283
+ if (rest.profile?.createdAt != null) traits.profileCreatedAt = rest.profile.createdAt;
284
+ return traits;
285
+ }
286
+ /**
287
+ * Builds the full `identify()` payload:
288
+ * - `profileId` is the wallet address — the cross-app profile key shared with
289
+ * Renown and Vetra.
290
+ * - `avatar` / `firstName` are OpenPanel's native profile fields (they drive
291
+ * the picture and name in the dashboard UI), resolved as
292
+ * `userImage ?? ensAvatar` and `ensName ?? username`.
293
+ * - `properties` are the raw traits from {@link buildTraits}.
294
+ */
295
+ function buildIdentifyPayload(user) {
296
+ const avatar = user.profile?.userImage ?? user.ens?.avatarUrl;
297
+ const firstName = user.ens?.name ?? user.profile?.username;
298
+ return {
299
+ profileId: user.address,
300
+ ...avatar != null ? { avatar } : {},
301
+ ...firstName != null ? { firstName } : {},
302
+ properties: buildTraits(user)
303
+ };
304
+ }
305
+ //#endregion
306
+ //#region src/components/openpanel.tsx
307
+ /**
308
+ * `OpenPanel` is a `null`-rendering component that manages the full lifecycle
309
+ * of the OpenPanel analytics subsystem.
310
+ *
311
+ * Gates:
312
+ * - `useAcceptedCookies().analytics === true` — the existing analytics cookie.
313
+ * - `connectConfig.openPanel.clientId` non-empty — no client ID → no-op.
314
+ *
315
+ * Behaviour when both gates pass:
316
+ * 1. Lazy-imports `@openpanel/web` and builds the singleton via
317
+ * `getOpenPanelClient(connectConfig.openPanel)`.
318
+ * 2. Exposes the client on `window.openPanel` for the card-6
319
+ * `useOpenPanelAnalytics()` hook to consume.
320
+ * 3. If `connectConfig.openPanel.trackOperations`, registers the processor
321
+ * factory against `processorManager` so document operations are forwarded.
322
+ * 4. Calls `client.identify()` when the renown user transitions from
323
+ * `undefined` → defined (login). The profile ID is the wallet address —
324
+ * the cross-app key shared with Renown and Vetra.
325
+ * 5. Calls `client.clear()` when the user transitions from defined →
326
+ * `undefined` (logout).
327
+ *
328
+ * Teardown (unmount **or** consent revocation):
329
+ * - `unregisterFactory("openpanel")` to remove the processor.
330
+ * - `resetOpenPanelClient()` to clear the singleton.
331
+ * - `window.openPanel` is cleared.
332
+ *
333
+ * Mirrors the Sentry pattern in `store/user.ts` for login/logout detection.
334
+ * Analytics failures are caught and forwarded to `console.warn` — they must
335
+ * never throw into the application.
336
+ *
337
+ * Mounted next to `<Analytics />` in `app.tsx`.
338
+ */
339
+ function OpenPanel() {
340
+ const [{ analytics }] = useAcceptedCookies();
341
+ const user = useUser();
342
+ const module = useReactorClientModule();
343
+ const reactorClientModule = module?.kind === "browser" ? module : void 0;
344
+ const [client, setClient] = useState();
345
+ /**
346
+ * Tracks the previous `user` value so we can detect the two transitions:
347
+ * undefined → defined (login)
348
+ * defined → undefined (logout)
349
+ */
350
+ const prevUserRef = useRef(void 0);
351
+ const enabled = analytics && !!connectConfig.openPanel.clientId;
352
+ const processorManager = reactorClientModule?.reactorModule?.processorManager;
353
+ useEffect(() => {
354
+ if (!enabled) return;
355
+ let cancelled = false;
356
+ const isCancelled = () => cancelled;
357
+ const setup = async () => {
358
+ let builtClient;
359
+ try {
360
+ builtClient = await getOpenPanelClient(connectConfig.openPanel);
361
+ } catch (err) {
362
+ console.warn("[OpenPanel] Failed to build client:", err);
363
+ return;
364
+ }
365
+ if (isCancelled() || !builtClient) return;
366
+ setClient(builtClient);
367
+ window.openPanel = builtClient;
368
+ if (connectConfig.openPanel.trackOperations && processorManager) try {
369
+ await processorManager.registerFactory("openpanel", createOpenPanelProcessorFactory({
370
+ client: builtClient,
371
+ events: {
372
+ mappings: eventMappings,
373
+ lookupMap: eventLookupMap
374
+ },
375
+ startFrom: "current"
376
+ }));
377
+ if (isCancelled()) await processorManager.unregisterFactory("openpanel").catch((err) => console.warn("[OpenPanel] Failed to unregister factory after cancellation:", err));
378
+ } catch (err) {
379
+ console.warn("[OpenPanel] Failed to register processor factory:", err);
380
+ }
381
+ };
382
+ setup();
383
+ return () => {
384
+ cancelled = true;
385
+ prevUserRef.current = void 0;
386
+ if (connectConfig.openPanel.trackOperations && processorManager) processorManager.unregisterFactory("openpanel").catch((err) => console.warn("[OpenPanel] Failed to unregister processor factory:", err));
387
+ resetOpenPanelClient();
388
+ window.openPanel = void 0;
389
+ setClient(void 0);
390
+ };
391
+ }, [enabled, processorManager]);
392
+ useEffect(() => {
393
+ if (!enabled || !client) return;
394
+ const prev = prevUserRef.current;
395
+ prevUserRef.current = user;
396
+ if (!prev && user) try {
397
+ client.identify(buildIdentifyPayload(user));
398
+ } catch (err) {
399
+ console.warn("[OpenPanel] Failed to identify user:", err);
400
+ }
401
+ else if (prev && !user) try {
402
+ client.clear();
403
+ } catch (err) {
404
+ console.warn("[OpenPanel] Failed to clear user:", err);
405
+ }
406
+ }, [
407
+ client,
408
+ user,
409
+ enabled
410
+ ]);
411
+ return null;
412
+ }
413
+ //#endregion
414
+ //#region src/hooks/useInitSentry.ts
415
+ const logger$1 = childLogger(["sentry"]);
416
+ let clientStarted = false;
417
+ async function getSentry() {
418
+ return await import("@sentry/react");
419
+ }
420
+ async function initSentry() {
421
+ const Sentry = await getSentry();
422
+ const integrations = [
423
+ Sentry.httpClientIntegration(),
424
+ Sentry.extraErrorDataIntegration({ depth: 5 }),
425
+ Sentry.replayIntegration(),
426
+ Sentry.captureConsoleIntegration({ levels: ["error"] })
427
+ ];
428
+ if (connectConfig.sentry.tracing) {
429
+ const { getConnectRouter } = await import("./router-B4Z1LV9b.js");
430
+ integrations.push(Sentry.tanstackRouterBrowserTracingIntegration(getConnectRouter()));
431
+ }
432
+ Sentry.init({
433
+ release: connectConfig.sentry.release,
434
+ dsn: connectConfig.sentry.dsn ?? void 0,
435
+ environment: connectConfig.sentry.env,
436
+ integrations,
437
+ ignoreErrors: [
438
+ "User is not allowed to create files",
439
+ "User is not allowed to move documents",
440
+ "The user aborted a request."
441
+ ],
442
+ sendDefaultPii: true,
443
+ tracesSampleRate: 1,
444
+ replaysSessionSampleRate: .1,
445
+ replaysOnErrorSampleRate: 1,
446
+ beforeSend(event, hint) {
447
+ const error = hint.originalException;
448
+ if (error instanceof TypeError && error.message.includes("Failed to fetch") && !navigator.onLine) return null;
449
+ return event;
450
+ }
451
+ });
452
+ setSentryModule(Sentry);
453
+ clientStarted = true;
454
+ }
455
+ async function closeClient() {
456
+ if (!clientStarted) return;
457
+ const sentry = await getSentry();
458
+ setSentryModule(void 0);
459
+ return sentry.getClient()?.close();
460
+ }
461
+ function useInitSentry() {
462
+ const [acceptedCookies] = useAcceptedCookies();
463
+ const { analytics } = acceptedCookies;
464
+ useEffect(() => {
465
+ if (!analytics) {
466
+ closeClient().catch((error) => logger$1.error("@error", error));
467
+ return;
468
+ }
469
+ if (clientStarted || connectConfig.sentry.dsn === null || connectConfig.sentry.dsn === void 0 || connectConfig.sentry.dsn === "") return;
470
+ initSentry().catch((error) => logger$1.error("@error", error));
471
+ }, [analytics]);
472
+ }
473
+ //#endregion
474
+ //#region src/context/sentry-provider.tsx
475
+ const SentryProvider = ({ children }) => {
476
+ useInitSentry();
477
+ return children;
478
+ };
479
+ //#endregion
480
+ //#region src/utils/document-editor-debug-tools.ts
481
+ var DocumentEditorDebugTools = class {
482
+ document;
483
+ operations = [];
484
+ constructor(document) {
485
+ if (document) this.document = document;
486
+ }
487
+ operationsToTableObject(operations) {
488
+ return operations.map((op) => ({
489
+ ...op,
490
+ input: JSON.stringify(op.action.input)
491
+ }));
492
+ }
493
+ setDocument(document) {
494
+ this.document = document;
495
+ }
496
+ getDocument() {
497
+ return this.document;
498
+ }
499
+ getOperations() {
500
+ return this.operations;
501
+ }
502
+ pushOperation(operation) {
503
+ this.operations.push(operation);
504
+ }
505
+ operationsTable() {
506
+ if (!this.document) console.warn("No document");
507
+ const ops = Object.values(this.document?.operations || {}).filter((array) => array !== void 0).flatMap((array) => array).sort((a, b) => a.index - b.index);
508
+ console.table(this.operationsToTableObject(ops));
509
+ }
510
+ scopeOperationsTable(scope) {
511
+ if (!this.document) console.warn("No document");
512
+ const ops = this.document?.operations[scope] || [];
513
+ console.table(this.operationsToTableObject(ops));
514
+ }
515
+ operationsLog() {
516
+ console.log(this.operations);
517
+ }
518
+ operationsLogTable() {
519
+ console.table(this.operationsToTableObject(this.operations));
520
+ }
521
+ clear() {
522
+ this.operations = [];
523
+ this.document = void 0;
524
+ }
525
+ };
526
+ //#endregion
527
+ //#region src/utils/pglite-migration.ts
528
+ const BACKUP_PREFIX = "ph-pglite-backup::";
529
+ const BACKUP_INDEX_KEY = "ph:pglite-backups";
530
+ const BACKUP_RETENTION_MS = 2592e6;
531
+ function deleteIdb(name, timeoutMs = 15e3) {
532
+ return new Promise((resolve, reject) => {
533
+ const req = indexedDB.deleteDatabase(name);
534
+ let settled = false;
535
+ const done = (fn) => {
536
+ if (settled) return;
537
+ settled = true;
538
+ fn();
539
+ };
540
+ const timer = setTimeout(() => done(() => reject(/* @__PURE__ */ new Error(`IDB delete timed out for ${name} after ${timeoutMs}ms`))), timeoutMs);
541
+ req.onsuccess = () => done(() => {
542
+ clearTimeout(timer);
543
+ resolve();
544
+ });
545
+ req.onerror = () => done(() => {
546
+ clearTimeout(timer);
547
+ reject(idbError(req, `IDB delete failed for ${name}`));
548
+ });
549
+ });
550
+ }
551
+ function readBackupIndex() {
552
+ try {
553
+ const raw = localStorage.getItem(BACKUP_INDEX_KEY);
554
+ if (!raw) return [];
555
+ const parsed = JSON.parse(raw);
556
+ return Array.isArray(parsed) ? parsed : [];
557
+ } catch {
558
+ return [];
559
+ }
560
+ }
561
+ function writeBackupIndex(records) {
562
+ try {
563
+ localStorage.setItem(BACKUP_INDEX_KEY, JSON.stringify(records));
564
+ } catch {}
565
+ }
566
+ function registerBackup(rec) {
567
+ writeBackupIndex([...readBackupIndex(), rec]);
568
+ }
569
+ function forgetBackup(name) {
570
+ writeBackupIndex(readBackupIndex().filter((r) => r.name !== name));
571
+ }
572
+ async function janitor() {
573
+ const cutoff = Date.now() - BACKUP_RETENTION_MS;
574
+ const keep = [];
575
+ for (const rec of readBackupIndex()) {
576
+ if (rec.createdAt >= cutoff) {
577
+ keep.push(rec);
578
+ continue;
579
+ }
580
+ try {
581
+ await deleteIdb(rec.name);
582
+ } catch (err) {
583
+ console.warn(`Failed to delete expired pglite backup ${rec.name}`, err);
584
+ keep.push(rec);
585
+ }
586
+ }
587
+ writeBackupIndex(keep);
588
+ }
589
+ function createPersistentBackup() {
590
+ return {
591
+ snapshot: async (idbName) => {
592
+ const backupName = `${BACKUP_PREFIX}${idbName}::${(/* @__PURE__ */ new Date()).toISOString()}`;
593
+ await cloneFileData(idbName, backupName);
594
+ registerBackup({
595
+ name: backupName,
596
+ idbName,
597
+ createdAt: Date.now()
598
+ });
599
+ return backupName;
600
+ },
601
+ rollback: async (handle, idbName, cause) => {
602
+ const backupName = handle;
603
+ try {
604
+ await cloneFileData(backupName, idbName);
605
+ } catch (rollbackErr) {
606
+ console.error(`PGlite migration rollback failed for ${idbName}; backup ${backupName} retained. Primary migration error:`, cause, "Rollback error:", rollbackErr);
607
+ return;
608
+ }
609
+ await deleteIdb(backupName).catch(() => void 0);
610
+ forgetBackup(backupName);
611
+ },
612
+ discard: async (handle) => {
613
+ const backupName = handle;
614
+ await deleteIdb(backupName).catch(() => void 0);
615
+ forgetBackup(backupName);
616
+ },
617
+ commit: () => Promise.resolve()
618
+ };
619
+ }
620
+ async function migrateAllLocked() {
621
+ const backup = createPersistentBackup();
622
+ try {
623
+ for (const idbName of PRIMARY_IDB_NAMES) await migrateIdb(idbName, (phase) => setMigrationStatus({
624
+ idbName,
625
+ phase
626
+ }), backup);
627
+ } finally {
628
+ setMigrationStatus(null);
629
+ }
630
+ }
631
+ async function migrateAllIfNeeded() {
632
+ janitor().catch((err) => console.warn("PGlite backup janitor failed", err));
633
+ if (!(typeof navigator !== "undefined" && "locks" in navigator && typeof navigator.locks.request === "function")) {
634
+ await migrateAllLocked();
635
+ return;
636
+ }
637
+ await navigator.locks.request("ph-pglite-migration", { mode: "exclusive" }, async () => {
638
+ await migrateAllLocked();
639
+ });
640
+ }
641
+ //#endregion
642
+ //#region src/hooks/useFailedInstallations.ts
643
+ const emptyArray$1 = [];
644
+ function useFailedInstallations() {
645
+ const discoveryService = usePackageDiscoveryService();
646
+ return useSyncExternalStore((cb) => discoveryService?.subscribeFailed(cb) ?? (() => {}), () => discoveryService?.getFailedInstallations() ?? emptyArray$1);
647
+ }
648
+ //#endregion
649
+ //#region src/components/missing-model-banner.tsx
650
+ const reasonLabels = {
651
+ "no-registry": "No package registry is configured.",
652
+ "not-in-registry": "No matching package found in the registry.",
653
+ "registry-error": "Couldn't reach the package registry.",
654
+ "install-failed": "Package failed to install.",
655
+ dismissed: "Installation was dismissed.",
656
+ offline: "You're offline — this package can't be loaded until you reconnect."
657
+ };
658
+ function canRetry(reason) {
659
+ return reason !== "no-registry";
660
+ }
661
+ function MissingModelBanner() {
662
+ const failed = useFailedInstallations();
663
+ const discoveryService = usePackageDiscoveryService();
664
+ const [open, setOpen] = useState(false);
665
+ const [dismissed, setDismissed] = useState(false);
666
+ useEffect(() => {
667
+ return discoveryService?.subscribeEvents((event) => {
668
+ if (event.type === "load-failed") setDismissed(false);
669
+ });
670
+ }, [discoveryService]);
671
+ if (failed.length === 0) return null;
672
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [dismissed ? null : /* @__PURE__ */ jsx("div", {
673
+ className: "absolute inset-x-0 top-0 z-200 bg-background",
674
+ children: /* @__PURE__ */ jsxs("div", {
675
+ className: "flex items-center justify-between gap-3 bg-warning/10 px-4 py-2 text-sm text-warning",
676
+ children: [/* @__PURE__ */ jsx("span", { children: failed.length === 1 ? "1 document type couldn't load (missing model)." : `${failed.length} document types couldn't load (missing models).` }), /* @__PURE__ */ jsxs("div", {
677
+ className: "flex items-center gap-2",
678
+ children: [/* @__PURE__ */ jsx("button", {
679
+ type: "button",
680
+ onClick: () => setOpen(true),
681
+ className: "rounded-md border border-warning bg-background px-3 py-1 text-warning hover:hover-effect",
682
+ children: "View"
683
+ }), /* @__PURE__ */ jsx("button", {
684
+ type: "button",
685
+ onClick: () => setDismissed(true),
686
+ "aria-label": "Dismiss",
687
+ className: "flex items-center text-warning hover:hover-effect",
688
+ children: /* @__PURE__ */ jsx(Icon, {
689
+ name: "XmarkLight",
690
+ size: 16
691
+ })
692
+ })]
693
+ })]
694
+ })
695
+ }), /* @__PURE__ */ jsx(MissingModelDetailsModal, {
696
+ open,
697
+ failed,
698
+ onClose: () => setOpen(false)
699
+ })] });
700
+ }
701
+ function MissingModelDetailsModal(props) {
702
+ const { open, failed, onClose } = props;
703
+ const discoveryService = usePackageDiscoveryService();
704
+ const [retrying, setRetrying] = useState(() => /* @__PURE__ */ new Set());
705
+ async function handleRetry(documentType) {
706
+ if (!discoveryService) return;
707
+ setRetrying((prev) => new Set(prev).add(documentType));
708
+ try {
709
+ await discoveryService.retryInstallation(documentType);
710
+ } finally {
711
+ setRetrying((prev) => {
712
+ const next = new Set(prev);
713
+ next.delete(documentType);
714
+ return next;
715
+ });
716
+ }
717
+ }
718
+ return /* @__PURE__ */ jsx(Modal, {
719
+ open,
720
+ onOpenChange: (isOpen) => {
721
+ if (!isOpen) onClose();
722
+ },
723
+ contentProps: { className: "rounded-3xl" },
724
+ children: /* @__PURE__ */ jsxs("div", {
725
+ className: "w-[520px] max-w-[90vw] bg-background p-6",
726
+ children: [
727
+ /* @__PURE__ */ jsx("div", {
728
+ className: "border-b border-border pb-2 text-2xl font-bold text-foreground",
729
+ children: "Missing document models"
730
+ }),
731
+ /* @__PURE__ */ jsx("div", {
732
+ className: "my-4 text-sm text-foreground",
733
+ children: "The following document types couldn't be loaded. Documents using them won't display until the underlying package is installed."
734
+ }),
735
+ failed.length === 0 ? /* @__PURE__ */ jsx("div", {
736
+ className: "rounded-xl bg-background p-4 text-sm text-foreground",
737
+ children: "No outstanding failures."
738
+ }) : /* @__PURE__ */ jsx("div", {
739
+ className: "flex max-h-[60vh] flex-col gap-3 overflow-y-auto",
740
+ children: failed.map((entry) => {
741
+ const isRetrying = retrying.has(entry.documentType);
742
+ const retryDisabled = !canRetry(entry.reason) || isRetrying;
743
+ return /* @__PURE__ */ jsxs("div", {
744
+ className: "rounded-xl bg-background p-4",
745
+ children: [
746
+ /* @__PURE__ */ jsx("div", {
747
+ className: "mb-1 font-mono text-sm font-semibold text-foreground",
748
+ children: entry.documentType
749
+ }),
750
+ /* @__PURE__ */ jsx("div", {
751
+ className: "mb-2 text-xs text-foreground",
752
+ children: reasonLabels[entry.reason]
753
+ }),
754
+ entry.packageNames.length > 0 ? /* @__PURE__ */ jsxs("div", {
755
+ className: "mb-2 text-xs text-muted-foreground",
756
+ children: [
757
+ "Package",
758
+ entry.packageNames.length > 1 ? "s" : "",
759
+ ":",
760
+ " ",
761
+ entry.packageNames.join(", ")
762
+ ]
763
+ }) : null,
764
+ entry.error ? /* @__PURE__ */ jsx("div", {
765
+ className: "mb-2 font-mono text-xs wrap-break-word text-destructive",
766
+ children: entry.error.message
767
+ }) : null,
768
+ /* @__PURE__ */ jsx("div", {
769
+ className: "flex justify-end",
770
+ children: /* @__PURE__ */ jsx("button", {
771
+ type: "button",
772
+ onClick: () => void handleRetry(entry.documentType),
773
+ disabled: retryDisabled,
774
+ title: canRetry(entry.reason) ? void 0 : "No registry is configured; nothing to retry against.",
775
+ className: twMerge("min-h-[32px] rounded-xl px-3 py-1 text-sm font-semibold text-foreground transition-all hover:hover-effect", retryDisabled ? "cursor-not-allowed bg-secondary hover:hover-effect" : "bg-primary text-primary-foreground active:active-effect"),
776
+ children: isRetrying ? "Retrying..." : "Try install again"
777
+ })
778
+ })
779
+ ]
780
+ }, entry.documentType);
781
+ })
782
+ }),
783
+ /* @__PURE__ */ jsx("div", {
784
+ className: "mt-4 flex justify-end",
785
+ children: /* @__PURE__ */ jsx("button", {
786
+ type: "button",
787
+ onClick: onClose,
788
+ className: "min-h-[36px] rounded-xl border border-border bg-background px-4 py-2 text-sm font-semibold text-foreground hover:hover-effect",
789
+ children: "Close"
790
+ })
791
+ })
792
+ ]
793
+ })
794
+ });
795
+ }
796
+ //#endregion
797
+ //#region src/components/open-file-upload-list.tsx
798
+ function OpenFileUploadList() {
799
+ const uploads = useSyncExternalStore(subscribeOpenFileUploads, getOpenFileUploads);
800
+ return /* @__PURE__ */ jsx(UploadFileListContainer, {
801
+ uploadsArray: uploads,
802
+ uploadsCount: uploads.length,
803
+ removeUpload: removeOpenFileUpload,
804
+ clearAllUploads: clearOpenFileUploads,
805
+ setSelectedNode
806
+ });
807
+ }
808
+ //#endregion
809
+ //#region src/hooks/usePendingInstallations.ts
810
+ const emptyArray = [];
811
+ function usePendingInstallations() {
812
+ const discoveryService = usePackageDiscoveryService();
813
+ const cacheRef = useRef(emptyArray);
814
+ const getSnapshot = useCallback(() => {
815
+ if (!discoveryService) return emptyArray;
816
+ const next = discoveryService.getPendingInstallations() ?? emptyArray;
817
+ const prev = cacheRef.current;
818
+ if (next === prev || next.length === prev.length && next.every((p, i) => p === prev[i])) return prev;
819
+ cacheRef.current = next;
820
+ return next;
821
+ }, [discoveryService]);
822
+ return useSyncExternalStore((cb) => discoveryService?.subscribePending(cb) ?? (() => {}), getSnapshot);
823
+ }
824
+ //#endregion
825
+ //#region src/components/package-install-prompt.tsx
826
+ function PackageInstallPrompt() {
827
+ const pendingInstallations = usePendingInstallations();
828
+ const discoveryService = usePackageDiscoveryService();
829
+ if (!discoveryService || pendingInstallations.length === 0) return null;
830
+ const installations = pendingInstallations.flatMap((p) => p.packageNames.map((packageName) => ({
831
+ documentType: p.documentType,
832
+ packageName
833
+ })));
834
+ return /* @__PURE__ */ jsx(PackageInstallModal, {
835
+ pendingInstallations: installations,
836
+ onInstall: (packageName) => discoveryService.approveInstallation(packageName),
837
+ onDismiss: (packageName) => discoveryService.dismissInstallation(packageName)
838
+ });
839
+ }
840
+ //#endregion
841
+ //#region src/components/renown-adapter-descriptors.ts
842
+ function describe(id, build) {
843
+ try {
844
+ return [build()];
845
+ } catch (error) {
846
+ console.error(`[connect] Ignoring the "${id}" wallet adapter: connect.renown.adapters.${id} was rejected.`, error);
847
+ return [];
848
+ }
849
+ }
850
+ const CHAINS_BY_ID = new Map([
851
+ mainnet,
852
+ sepolia,
853
+ polygon,
854
+ optimism,
855
+ arbitrum,
856
+ base
857
+ ].map((chain) => [chain.id, chain]));
858
+ function chainsFor(chainId) {
859
+ if (chainId === void 0) return void 0;
860
+ const chain = CHAINS_BY_ID.get(chainId);
861
+ if (!chain) {
862
+ console.error(`[connect] connect.renown.chainId ${chainId} is not a chain Connect can offer, so in-page sign-in will be rejected. Supported: ${[...CHAINS_BY_ID.keys()].join(", ")}.`);
863
+ return;
864
+ }
865
+ return [chain];
866
+ }
867
+ /** Map Connect's declarative `connect.renown.adapters` config to the descriptors `RenownWalletProvider` takes. Array order sets the order of the login buttons. A rejected adapter config is dropped (logged), leaving the others working. `chainId` is `connect.renown.chainId`, the chain Renown issues credentials on. */
868
+ function configToDescriptors(config, chainId) {
869
+ if (!config) return [];
870
+ const { rainbow, privy, mock } = config;
871
+ const descriptors = [];
872
+ const chains = chainsFor(chainId);
873
+ if (rainbow) descriptors.push(...describe("rainbow", () => rainbowAdapter({
874
+ ...rainbow,
875
+ ...chains ? { chains } : {}
876
+ })));
877
+ if (privy) {
878
+ const { appId, clientId, methods } = privy;
879
+ if (appId) descriptors.push(...describe("privy", () => privyAdapter({
880
+ appId,
881
+ clientId,
882
+ methods,
883
+ chain: chains?.[0]
884
+ })));
885
+ }
886
+ if (mock) descriptors.push(...describe("mock", () => mockAdapter({
887
+ ...mock,
888
+ methods: mock.methods
889
+ })));
890
+ return descriptors;
891
+ }
892
+ //#endregion
893
+ //#region src/components/renown-wallet-providers.tsx
894
+ function resolveColor(expr, fallback) {
895
+ if (typeof document === "undefined") return fallback;
896
+ const probe = document.createElement("span");
897
+ probe.style.color = fallback;
898
+ probe.style.color = expr;
899
+ probe.style.display = "none";
900
+ document.body.appendChild(probe);
901
+ const resolved = getComputedStyle(probe).color;
902
+ probe.remove();
903
+ return resolved || fallback;
904
+ }
905
+ function RenownWalletProviders({ children }) {
906
+ const config = getRuntimeConfig().connect.renown?.adapters;
907
+ const chainId = getRuntimeConfig().connect.renown?.chainId;
908
+ const { theme } = useTheme();
909
+ const adapters = useMemo(() => configToDescriptors(config, chainId), [config, chainId]);
910
+ const walletTheme = useMemo(() => adapters.length > 0 ? {
911
+ mode: theme,
912
+ accentColor: resolveColor("var(--primary)", "#0084ff"),
913
+ accentColorForeground: resolveColor("var(--primary-foreground)", "#ffffff")
914
+ } : void 0, [theme, adapters]);
915
+ if (adapters.length === 0) return /* @__PURE__ */ jsx(Fragment$1, { children });
916
+ return /* @__PURE__ */ jsx(RenownWalletProvider, {
917
+ adapters,
918
+ theme: walletTheme,
919
+ children
920
+ });
921
+ }
922
+ //#endregion
923
+ //#region src/components/app.tsx
924
+ const ConnectReactorChatFab = lazy(() => import("./reactor-chat-LAB-9G3G.js").then((m) => ({ default: m.ConnectReactorChatFab })));
925
+ const App = () => {
926
+ useTheme();
927
+ useEditorPreloader();
928
+ useEffect(() => {
929
+ const handlePreloadError = (event) => {
930
+ const payload = event.payload;
931
+ const failedUrl = (payload instanceof Error ? payload.message : typeof payload === "string" ? payload : "").match(/https?:\/\/[^\s"']+/)?.[0];
932
+ if (failedUrl && !failedUrl.startsWith(window.location.origin)) {
933
+ console.debug(`[Connect] Skipping reload — vite:preloadError for off-origin URL: ${failedUrl}`);
934
+ return;
935
+ }
936
+ console.log("Outdated chunks detected, reloading page...");
937
+ window.location.reload();
938
+ };
939
+ window.addEventListener("vite:preloadError", handlePreloadError);
940
+ return () => {
941
+ window.removeEventListener("vite:preloadError", handlePreloadError);
942
+ };
943
+ }, []);
944
+ useEffect(() => {
945
+ if (import.meta.env.MODE === "development") window.documentEditorDebugTools = new DocumentEditorDebugTools();
946
+ else if (connectConfig.offline) serviceWorkerManager.registerServiceWorker(false);
947
+ else serviceWorkerManager.unregisterAll();
948
+ }, []);
949
+ useEffect(() => {
950
+ initLaunchQueueFileHandling();
951
+ }, []);
952
+ return /* @__PURE__ */ jsx(SentryProvider, { children: /* @__PURE__ */ jsxs(RenownWalletProviders, { children: [
953
+ /* @__PURE__ */ jsx(ToastContainer, { position: "bottom-right" }),
954
+ connectConfig.aiAssistantEnabled && /* @__PURE__ */ jsx(Suspense, {
955
+ name: "ReactorChat",
956
+ fallback: null,
957
+ children: /* @__PURE__ */ jsx(ConnectReactorChatFab, {})
958
+ }),
959
+ /* @__PURE__ */ jsx(MissingModelBanner, {}),
960
+ /* @__PURE__ */ jsx(Router, {}),
961
+ /* @__PURE__ */ jsx(OpenFileUploadList, {}),
962
+ /* @__PURE__ */ jsx(PackageInstallPrompt, {}),
963
+ /* @__PURE__ */ jsx(Analytics, {}),
964
+ /* @__PURE__ */ jsx(OpenPanel, {})
965
+ ] }) });
966
+ };
967
+ //#endregion
968
+ //#region src/components/connection-banner.tsx
969
+ const CONNECTED = "connected";
970
+ const BANNER_TEXT = {
971
+ failed: {
972
+ title: "Reactor worker failed to load",
973
+ detail: "The background worker script could not be loaded. Reload to retry."
974
+ },
975
+ lost: {
976
+ title: "Lost connection to the reactor",
977
+ detail: "The background worker stopped responding. Reload to reconnect."
978
+ },
979
+ "storage-held": {
980
+ title: "Waiting for another Connect tab",
981
+ detail: "Another Connect tab still holds local storage. Close or reload the other Connect tabs to continue."
982
+ },
983
+ "version-conflict": {
984
+ title: "Connect tabs are on different builds",
985
+ detail: "Open tabs keep restarting the reactor. Close the other Connect tabs, then reload."
986
+ },
987
+ "storage-unusable": {
988
+ title: "Local storage is unusable",
989
+ detail: "The local database stopped responding. Clear storage to start over, or reload to retry."
990
+ }
991
+ };
992
+ const ConnectionBanner = () => {
993
+ const status = useSyncExternalStore(subscribeWorkerConnection, getWorkerConnectionStatus, () => CONNECTED);
994
+ if (status === "connected") return null;
995
+ const { title, detail } = BANNER_TEXT[status];
996
+ return /* @__PURE__ */ jsx("div", {
997
+ className: "absolute inset-x-0 top-0 z-30 flex justify-center p-3",
998
+ children: /* @__PURE__ */ jsxs("div", {
999
+ className: "flex max-w-3xl items-center gap-3 rounded-lg border border-destructive bg-warning px-4 py-3 text-sm text-warning-foreground shadow-lg",
1000
+ children: [
1001
+ /* @__PURE__ */ jsxs("div", {
1002
+ className: "flex-1",
1003
+ children: [/* @__PURE__ */ jsx("div", {
1004
+ className: "font-semibold",
1005
+ children: title
1006
+ }), /* @__PURE__ */ jsx("div", {
1007
+ className: "text-foreground",
1008
+ children: detail
1009
+ })]
1010
+ }),
1011
+ status === "storage-unusable" && /* @__PURE__ */ jsx("button", {
1012
+ type: "button",
1013
+ onClick: () => showPHModal({ type: "clearStorage" }),
1014
+ className: "rounded-sm bg-primary px-3 py-1 text-sm font-medium text-primary-foreground hover:hover-effect",
1015
+ children: "Clear storage"
1016
+ }),
1017
+ /* @__PURE__ */ jsx("button", {
1018
+ type: "button",
1019
+ onClick: () => window.location.reload(),
1020
+ className: "rounded-sm bg-primary px-3 py-1 text-sm font-medium text-primary-foreground hover:hover-effect",
1021
+ children: "Reload"
1022
+ })
1023
+ ]
1024
+ })
1025
+ });
1026
+ };
1027
+ //#endregion
1028
+ //#region src/components/migration-banner.tsx
1029
+ function BannerShell({ title, body, error, children }) {
1030
+ return /* @__PURE__ */ jsx("div", {
1031
+ className: "absolute inset-x-0 top-0 z-30 flex justify-center p-3",
1032
+ children: /* @__PURE__ */ jsxs("div", {
1033
+ className: "flex max-w-3xl items-center gap-3 rounded-lg border border-warning bg-warning px-4 py-3 text-sm text-warning-foreground shadow-lg",
1034
+ children: [/* @__PURE__ */ jsxs("div", {
1035
+ className: "flex-1",
1036
+ children: [
1037
+ /* @__PURE__ */ jsx("div", {
1038
+ className: "font-semibold",
1039
+ children: title
1040
+ }),
1041
+ /* @__PURE__ */ jsx("div", {
1042
+ className: "text-foreground",
1043
+ children: body
1044
+ }),
1045
+ error && /* @__PURE__ */ jsxs("div", {
1046
+ className: "mt-2 font-medium text-destructive",
1047
+ children: ["Migration failed: ", error]
1048
+ })
1049
+ ]
1050
+ }), children]
1051
+ })
1052
+ });
1053
+ }
1054
+ const actionButton = "rounded-sm bg-primary px-3 py-1 text-sm font-medium text-primary-foreground hover:hover-effect disabled:disabled-effect";
1055
+ const dismissButton = "rounded-sm border border-foreground bg-transparent px-3 py-1 text-sm font-medium text-foreground hover:hover-effect disabled:disabled-effect";
1056
+ let browserDismissed = false;
1057
+ const browserListeners = /* @__PURE__ */ new Set();
1058
+ function WorkerMigrationBanner({ adminClient }) {
1059
+ const state = useSyncExternalStore((cb) => adminClient.subscribeMigration(cb), () => adminClient.getMigrationState());
1060
+ const [dismissed, setDismissed] = useState(false);
1061
+ const [error, setError] = useState(null);
1062
+ if (state.status === "idle") return null;
1063
+ if (state.status === "needed" && dismissed) return null;
1064
+ const migrating = state.status === "migrating";
1065
+ const handleMigrate = () => {
1066
+ setError(null);
1067
+ adminClient.migrate().catch((err) => {
1068
+ setError(err instanceof Error ? err.message : String(err));
1069
+ });
1070
+ };
1071
+ return /* @__PURE__ */ jsxs(BannerShell, {
1072
+ title: migrating ? `Migrating to Postgres 17…` : `Your local database uses Postgres ${state.legacyMajor ?? "?"}.`,
1073
+ body: migrating ? `Working (${state.phase ?? "starting"}). Your data is backed up first.` : `Migrate to Postgres 17 to pick up the latest features. Your data will be backed up first.`,
1074
+ error: error ?? (state.status === "failed" ? state.error : null),
1075
+ children: [!migrating && /* @__PURE__ */ jsx("button", {
1076
+ type: "button",
1077
+ onClick: handleMigrate,
1078
+ className: actionButton,
1079
+ children: state.status === "failed" ? "Retry" : "Migrate now"
1080
+ }), state.status === "needed" && /* @__PURE__ */ jsx("button", {
1081
+ type: "button",
1082
+ onClick: () => setDismissed(true),
1083
+ className: dismissButton,
1084
+ children: "Dismiss"
1085
+ })]
1086
+ });
1087
+ }
1088
+ function BrowserMigrationBanner() {
1089
+ const isDismissed = useSyncExternalStore((cb) => {
1090
+ browserListeners.add(cb);
1091
+ return () => browserListeners.delete(cb);
1092
+ }, () => browserDismissed, () => false);
1093
+ const major = useSyncExternalStore(subscribeMigrationMajor, getCachedMigrationMajor, () => void 0);
1094
+ const [migrating, setMigrating] = useState(false);
1095
+ const [error, setError] = useState(null);
1096
+ if (major === void 0 || major === null || major === 17) return null;
1097
+ if (isDismissed) return null;
1098
+ const handleMigrate = () => {
1099
+ setError(null);
1100
+ setMigrating(true);
1101
+ migrateAllIfNeeded().then(() => window.location.reload()).catch((err) => {
1102
+ setError(err instanceof Error ? err.message : String(err));
1103
+ setMigrating(false);
1104
+ });
1105
+ };
1106
+ return /* @__PURE__ */ jsxs(BannerShell, {
1107
+ title: `Your local database uses Postgres ${major}.`,
1108
+ body: `Migrate to Postgres 17 to pick up the latest features. Your data will be backed up first.`,
1109
+ error,
1110
+ children: [/* @__PURE__ */ jsx("button", {
1111
+ type: "button",
1112
+ disabled: migrating,
1113
+ onClick: handleMigrate,
1114
+ className: actionButton,
1115
+ children: migrating ? "Migrating…" : "Migrate now"
1116
+ }), /* @__PURE__ */ jsx("button", {
1117
+ type: "button",
1118
+ disabled: migrating,
1119
+ onClick: () => {
1120
+ browserDismissed = true;
1121
+ for (const l of browserListeners) l();
1122
+ },
1123
+ className: dismissButton,
1124
+ children: "Dismiss"
1125
+ })]
1126
+ });
1127
+ }
1128
+ const MigrationBanner = () => {
1129
+ const module = useReactorClientModule();
1130
+ if (module?.kind === "worker") return /* @__PURE__ */ jsx(WorkerMigrationBanner, { adminClient: module.adminClient });
1131
+ return /* @__PURE__ */ jsx(BrowserMigrationBanner, {});
1132
+ };
1133
+ //#endregion
1134
+ //#region src/components/modal/modals-container.tsx
1135
+ const AddDriveModal$1 = lazy(() => import("./AddDriveModal-D_3jDwjp.js").then((m) => ({ default: m.AddDriveModal })));
1136
+ const ClearStorageModal = lazy(() => import("./ClearStorageModal-CXWhHez-.js").then((m) => ({ default: m.ClearStorageModal })));
1137
+ const CookiesPolicyModal = lazy(() => import("./CookiesPolicyModal-DQwsgDI9.js").then((m) => ({ default: m.CookiesPolicyModal })));
1138
+ const CreateDocumentModal$1 = lazy(() => import("./CreateDocumentModal-Cf1APibL.js").then((m) => ({ default: m.CreateDocumentModal })));
1139
+ const DebugSettingsModal = lazy(() => import("./DebugSettingsModal-C0j4mtkx.js").then((m) => ({ default: m.DebugSettingsModal })));
1140
+ const DeleteDriveModal = lazy(() => import("./DeleteDriveModal-lE9eCBua.js").then((m) => ({ default: m.DeleteDriveModal })));
1141
+ const DeleteItemModal = lazy(() => import("./DeleteItemModal-BFgcGsm3.js").then((m) => ({ default: m.DeleteItemModal })));
1142
+ const DisclaimerModal = lazy(() => import("./DisclaimerModal-CF6JkIIu.js").then((m) => ({ default: m.DisclaimerModal })));
1143
+ const DriveSettingsModal$1 = lazy(() => import("./DriveSettingsModal-BSImj4BH.js").then((m) => ({ default: m.DriveSettingsModal })));
1144
+ const DownloadDocumentWithErrorsModal = lazy(() => import("./DownloadDocumentWithErrorsModal-CShKhfEQ.js").then((m) => ({ default: m.DownloadDocumentWithErrorsModal })));
1145
+ const DocumentVersionUnsupportedModal = lazy(() => import("./DocumentVersionUnsupportedModal-Cm9Jb9W7.js").then((m) => ({ default: m.DocumentVersionUnsupportedModal })));
1146
+ const ConfirmDocumentUpgradeModal = lazy(() => import("./ConfirmDocumentUpgradeModal-CrU2Z1CL.js").then((m) => ({ default: m.ConfirmDocumentUpgradeModal })));
1147
+ const UpgradeDriveModal = lazy(() => import("./UpgradeDriveModal-DvM-PNWe.js").then((m) => ({ default: m.UpgradeDriveModal })));
1148
+ const modalComponents = {
1149
+ addDrive: AddDriveModal$1,
1150
+ clearStorage: ClearStorageModal,
1151
+ cookiesPolicy: CookiesPolicyModal,
1152
+ createDocument: CreateDocumentModal$1,
1153
+ debugSettings: DebugSettingsModal,
1154
+ deleteDrive: DeleteDriveModal,
1155
+ deleteItem: DeleteItemModal,
1156
+ disclaimer: DisclaimerModal,
1157
+ driveSettings: DriveSettingsModal$1,
1158
+ downloadDocumentWithErrors: DownloadDocumentWithErrorsModal,
1159
+ documentVersionUnsupported: DocumentVersionUnsupportedModal,
1160
+ confirmDocumentUpgrade: ConfirmDocumentUpgradeModal,
1161
+ inspector: lazy(() => import("./InspectorModal-CKuKR5g7.js").then((m) => ({ default: m.InspectorModal }))),
1162
+ upgradeDrive: UpgradeDriveModal,
1163
+ missingPackage: lazy(() => import("./MissingPackageModal-DtISKgub.js").then((m) => ({ default: m.ConnectMissingPackageModal }))),
1164
+ driveAuthRequired: lazy(() => import("./DriveAuthRequiredModal-CMwPUyZf.js").then((m) => ({ default: m.DriveAuthRequiredModal }))),
1165
+ openFileDocuments: lazy(() => import("./OpenFileDocumentsModal-X9GnX2Bk.js").then((m) => ({ default: m.OpenFileDocumentsModal }))),
1166
+ login: lazy(() => import("./LoginModal-DT_05uva.js").then((m) => ({ default: m.LoginModal })))
1167
+ };
1168
+ const ModalsContainer = lazy(() => {
1169
+ return Promise.resolve({ default: () => {
1170
+ const phModal = usePHModal();
1171
+ if (!phModal?.type) return null;
1172
+ const ModalComponent = modalComponents[phModal.type];
1173
+ return ModalComponent ? /* @__PURE__ */ jsx(ErrorBoundary, {
1174
+ variant: "silent",
1175
+ loggerContext: ["Connect", "Modals"],
1176
+ children: /* @__PURE__ */ jsx(Suspense, {
1177
+ fallback: null,
1178
+ children: /* @__PURE__ */ jsx(ModalComponent, {})
1179
+ })
1180
+ }) : null;
1181
+ } });
1182
+ });
1183
+ //#endregion
1184
+ //#region src/components/service-worker-update-prompt.tsx
1185
+ const ServiceWorkerUpdatePrompt = () => {
1186
+ if (!useSyncExternalStore(subscribeServiceWorkerUpdate, getServiceWorkerUpdateAvailable, () => false)) return null;
1187
+ return /* @__PURE__ */ jsx("div", {
1188
+ className: "absolute inset-x-0 bottom-0 z-30 flex justify-center p-3",
1189
+ children: /* @__PURE__ */ jsxs("div", {
1190
+ className: "flex max-w-3xl items-center gap-3 rounded-lg border border-foreground bg-primary px-4 py-3 text-sm text-primary-foreground shadow-lg",
1191
+ children: [/* @__PURE__ */ jsx("div", {
1192
+ className: "flex-1 font-medium",
1193
+ children: "A new version of Connect is available."
1194
+ }), /* @__PURE__ */ jsx("button", {
1195
+ type: "button",
1196
+ onClick: () => serviceWorkerManager.applyUpdate(),
1197
+ className: "rounded-sm bg-primary-foreground px-3 py-1 text-sm font-medium text-primary hover:hover-effect",
1198
+ children: "Refresh"
1199
+ })]
1200
+ })
1201
+ });
1202
+ };
1203
+ //#endregion
1204
+ //#region src/components/stored-documents-refused.tsx
1205
+ /** Boot screen for a reactor that refused this browser's stored documents. */
1206
+ function StoredDocumentsRefusedFallback({ error }) {
1207
+ return /* @__PURE__ */ jsx("div", {
1208
+ className: "z-10 mx-auto flex max-w-[80%] flex-1 items-center justify-center p-6",
1209
+ children: /* @__PURE__ */ jsxs("div", {
1210
+ role: "alert",
1211
+ className: "w-full max-w-lg rounded-lg border border-border bg-card p-6 text-foreground shadow-sm",
1212
+ children: [
1213
+ /* @__PURE__ */ jsxs("div", {
1214
+ className: "mb-3 flex items-center gap-2",
1215
+ children: [/* @__PURE__ */ jsx(Icon, {
1216
+ name: "Error",
1217
+ className: "size-5 shrink-0 text-destructive"
1218
+ }), /* @__PURE__ */ jsx("h1", {
1219
+ className: "text-lg font-semibold text-foreground",
1220
+ children: "Connect cannot open this browser's documents"
1221
+ })]
1222
+ }),
1223
+ /* @__PURE__ */ jsx("p", {
1224
+ className: "mb-4 text-sm wrap-break-word text-foreground",
1225
+ children: error.message
1226
+ }),
1227
+ /* @__PURE__ */ jsx(PowerhouseButton, {
1228
+ type: "button",
1229
+ onClick: () => {
1230
+ window.location.reload();
1231
+ },
1232
+ className: "px-3 py-1.5 text-base font-medium",
1233
+ children: "Reload"
1234
+ })
1235
+ ]
1236
+ })
1237
+ });
1238
+ }
1239
+ //#endregion
1240
+ //#region src/components/app-loader.tsx
1241
+ const CookieBanner$1 = lazy(() => import("./cookie-banner-HPgyuHM5.js").then((m) => ({ default: m.CookieBanner })));
1242
+ function connectPHStore() {
1243
+ const active = getActivePHStore();
1244
+ if (active) return active;
1245
+ const store = createPHStore();
1246
+ bindPHStoreToWindow(store);
1247
+ return store;
1248
+ }
1249
+ const AppLoader = (props) => {
1250
+ const phStore = connectPHStore();
1251
+ const Load = lazy(() => import("./load-CEuzCNRz.js").then((m) => m.loadComponent(props.localPackage, phStore)));
1252
+ return /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(PHStoreProvider, {
1253
+ store: phStore,
1254
+ children: /* @__PURE__ */ jsxs(ErrorBoundary, {
1255
+ fallbackRender: (props) => /* @__PURE__ */ jsx(AppSkeleton, { children: isStoredDocumentsRefused(props.error) ? /* @__PURE__ */ jsx(StoredDocumentsRefusedFallback, { error: props.error }) : /* @__PURE__ */ jsx(DetailedFallback, { ...props }) }),
1256
+ resetKeys: [props.localPackage],
1257
+ loggerContext: ["Connect"],
1258
+ children: [
1259
+ /* @__PURE__ */ jsx(Suspense, {
1260
+ fallback: /* @__PURE__ */ jsx(LoadingShell, { Fallback: AppSkeleton }),
1261
+ name: "AppLoader",
1262
+ children: /* @__PURE__ */ jsx(Load, {
1263
+ ...props,
1264
+ children: /* @__PURE__ */ jsx(App, {})
1265
+ })
1266
+ }),
1267
+ /* @__PURE__ */ jsx(ErrorBoundary, {
1268
+ variant: "silent",
1269
+ loggerContext: ["Connect", "CookieBanner"],
1270
+ children: /* @__PURE__ */ jsx(Suspense, {
1271
+ fallback: null,
1272
+ name: "CookieBanner",
1273
+ children: /* @__PURE__ */ jsx(CookieBanner$1, {})
1274
+ })
1275
+ }),
1276
+ /* @__PURE__ */ jsx(Suspense, {
1277
+ name: "ModalsContainer",
1278
+ children: /* @__PURE__ */ jsx(ModalsContainer, {})
1279
+ }),
1280
+ /* @__PURE__ */ jsx(MigrationBanner, {}),
1281
+ /* @__PURE__ */ jsx(ServiceWorkerUpdatePrompt, {}),
1282
+ /* @__PURE__ */ jsx(ConnectionBanner, {})
1283
+ ]
1284
+ })
1285
+ }) });
1286
+ };
1287
+ //#endregion
1288
+ export { Analytics as i, App as n, OpenPanel as r, AppLoader as t };
1289
+
1290
+ //# sourceMappingURL=app-loader-DqNf3gc0.js.map
1291
+ //# debugId=fb571d15-627e-5160-8820-2247b7ba2dee