@powerhousedao/connect 1.1.2 → 2.5.0-test.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/.env +2 -1
  2. package/dist/assets/{app-D1OgCILX.css → app-Djvyy0EQ.css} +145 -2
  3. package/dist/assets/{app-DJhQA-n0.js → app-DnlszXoG.js} +49870 -42678
  4. package/dist/assets/app-DnlszXoG.js.map +1 -0
  5. package/dist/assets/{app-loader-4GyeoNTc.css → app-loader-CDW9U8zV.css} +179 -7
  6. package/dist/assets/{app-loader-_ujGNJEV.js → app-loader-LF_aPRFS.js} +3441 -3977
  7. package/dist/assets/app-loader-LF_aPRFS.js.map +1 -0
  8. package/dist/assets/browser-Bl-r87ld.js +27234 -0
  9. package/dist/assets/browser-Bl-r87ld.js.map +1 -0
  10. package/dist/assets/{ccip-CCI6GbPl.js → ccip-5fOGBE-2.js} +4 -3
  11. package/dist/assets/ccip-5fOGBE-2.js.map +1 -0
  12. package/dist/assets/{content-9ycjllj5.js → content-ChtzAUHq.js} +1762 -1049
  13. package/dist/assets/content-ChtzAUHq.js.map +1 -0
  14. package/dist/assets/{index-3G4_JsnT.js → index-B8Ch0VYb.js} +4 -3
  15. package/dist/assets/index-B8Ch0VYb.js.map +1 -0
  16. package/dist/assets/{index-C2x6Y6L5.js → index-C9SvsNTs.js} +23 -171
  17. package/dist/assets/index-C9SvsNTs.js.map +1 -0
  18. package/dist/assets/index-ttu2Jrkl.js +208 -0
  19. package/dist/assets/index-ttu2Jrkl.js.map +1 -0
  20. package/dist/assets/{index-8c1XCqhj.js → index-wgNrNkzN.js} +466 -309
  21. package/dist/assets/index-wgNrNkzN.js.map +1 -0
  22. package/dist/assets/{main.DXf9Xuwr.js → main.B-rBx6n2.js} +2 -1
  23. package/dist/assets/main.B-rBx6n2.js.map +1 -0
  24. package/dist/assets/reactor-analytics-C42Sftjd.js +42 -0
  25. package/dist/assets/reactor-analytics-C42Sftjd.js.map +1 -0
  26. package/dist/assets/router-DocwpreM.js +1791 -0
  27. package/dist/assets/router-DocwpreM.js.map +1 -0
  28. package/dist/assets/{style-U7Kx3_hE.css → style-C0GVbPTL.css} +6 -3
  29. package/dist/external-packages.js +1 -0
  30. package/dist/external-packages.js.map +1 -0
  31. package/dist/hmr.js +1 -0
  32. package/dist/hmr.js.map +1 -0
  33. package/dist/index.html +2 -1
  34. package/dist/service-worker.js +1 -0
  35. package/dist/service-worker.js.map +1 -0
  36. package/dist/swEnv.js +1 -0
  37. package/dist/vite-envs.sh +10 -1
  38. package/package.json +21 -16
@@ -0,0 +1,1791 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/content-ChtzAUHq.js","assets/app-DnlszXoG.js","assets/main.B-rBx6n2.js","assets/app-loader-LF_aPRFS.js","assets/app-loader-CDW9U8zV.css","assets/app-Djvyy0EQ.css"])))=>i.map(i=>d[i]);
2
+ import { _ as __vitePreload } from "./main.B-rBx6n2.js";
3
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
4
+ import { aN as generateDocumentStateQueryFields, a3 as PUBLIC, a1 as LOCAL, aM as t, _ as logger, aO as gql, aP as request, af as connectConfig } from "./app-loader-LF_aPRFS.js";
5
+ import * as React from "react";
6
+ import React__default, { useRef, useState, useEffect, useCallback, useContext, useSyncExternalStore, useMemo, Component, createElement, createContext, Suspense } from "react";
7
+ import * as ReactDOM from "react-dom";
8
+ import { P as Popover, a as PopoverTrigger, b as PopoverContent, t as twMerge, I as Icon, B as Button, g as getEnsAvatar$1, c as getEnsName$1, d as BaseError$1, W as WagmiContext, u as useQuery$1, e as useDocumentDriveServer, m as makeNodeSlugFromNodeName, D as DRIVE, F as FILE, S as SUCCESS, f as useModal, h as useUiNodesContext, i as useApps, j as toast$1, k as useUnwrappedReactor, l as createRouter$1, n as createBrowserHistory, o as logV6DeprecationWarnings, p as DataRouterContext, q as DataRouterStateContext, R as Router, E as ErrorResponseImpl, r as useRoutesImpl, s as mapRouteProperties, v as useLocation, w as useNavigate, x as useTranslation, y as useDocumentDrives, z as useReadModeContext, A as useAsyncReactor, C as useConnectConfig, G as CONFLICT, H as ERROR, J as isLatestVersion, K as useParams, L as useLogin, M as ModalManager, N as isElectron, O as isMac, Q as Outlet, T as useGetAppNameForEditorId, U as createMemoryRouter } from "./app-DnlszXoG.js";
9
+ const AccountPopover = ({ children, content }) => {
10
+ return jsxs(Popover, { children: [jsx(PopoverTrigger, { asChild: true, children: jsx("div", { className: "cursor-pointer", children }) }), jsx(PopoverContent, { className: "w-52 p-0", align: "start", children: content })] });
11
+ };
12
+ function SidebarHeader({ className, ...props }) {
13
+ return jsx("div", { className: twMerge("shrink-0", className), ...props });
14
+ }
15
+ function SidebarFooter({ className, ...props }) {
16
+ return jsx("div", { className: twMerge("shrink-0", className), ...props });
17
+ }
18
+ const Sidebar$1 = ({ maxWidth = "304px", minWidth = "80px", className, children, ...props }) => {
19
+ const ref = useRef(null);
20
+ return jsx("div", { ...props, className: twMerge(`group flex h-full flex-col bg-slate-50`, className), ref, style: {
21
+ width: minWidth
22
+ }, children });
23
+ };
24
+ function SidebarPanel({ className, children, ...props }) {
25
+ const [hasScroll, setHasScroll] = useState(false);
26
+ function checkContentScroll(target) {
27
+ setHasScroll(target.scrollHeight - target.scrollTop - target.clientHeight > 1);
28
+ }
29
+ const containerRef = useRef(null);
30
+ useEffect(() => {
31
+ if (!containerRef.current) {
32
+ return;
33
+ }
34
+ const observer = new ResizeObserver((entries) => {
35
+ const entry = entries.pop();
36
+ if (!entry) {
37
+ return;
38
+ }
39
+ const { target } = entry;
40
+ checkContentScroll(target);
41
+ });
42
+ observer.observe(containerRef.current);
43
+ return () => {
44
+ observer.disconnect();
45
+ };
46
+ }, [containerRef.current]);
47
+ return jsxs(Fragment, { children: [jsx("div", { className: twMerge("no-scrollbar flex-1 overflow-auto text-gray-900 transition-shadow", className), onScroll: (e) => checkContentScroll(e.currentTarget), ref: containerRef, ...props, children }), hasScroll ? jsx("div", { className: "pointer-events-none z-10 -mt-12 h-12 w-full", style: {
48
+ boxShadow: "inset 0px -33px 32px -16px rgba(0,0,0,0.1)"
49
+ } }) : null] });
50
+ }
51
+ const AccountPopoverLogin = ({ onLogin }) => {
52
+ const [loading, setLoading] = useState(false);
53
+ const content = loading ? jsx(Icon, { name: "Reload", size: 14, className: "animate-spin" }) : jsx("span", { children: "Connect" });
54
+ const handleLogin = () => {
55
+ setLoading(true);
56
+ onLogin();
57
+ };
58
+ return jsxs("div", { className: "p-4", children: [jsx("div", { className: "mb-4 flex justify-center", children: jsx("div", { className: "flex h-[22px] w-[83px] items-center justify-center overflow-hidden", children: jsx(Icon, { name: "RenownLight", size: 83 }) }) }), jsx("button", { onClick: handleLogin, className: "mt-4 flex h-7 w-full cursor-pointer items-center justify-center rounded-lg border border-gray-300 bg-transparent text-sm active:opacity-70", type: "button", children: content })] });
59
+ };
60
+ const shortAddress = (address) => `${address.slice(0, 7)}...${address.slice(-5)}`;
61
+ const AccountPopoverUser = ({ address, onDisconnect, etherscanUrl, username = "" }) => {
62
+ const [isCopied, setIsCopied] = useState(false);
63
+ const copyToClipboard = useCallback(async (text) => {
64
+ try {
65
+ await navigator.clipboard.writeText(text);
66
+ setIsCopied(true);
67
+ setTimeout(() => setIsCopied(false), 2e3);
68
+ } catch (err) {
69
+ console.error("Failed to copy address:", err);
70
+ }
71
+ }, []);
72
+ return jsxs("div", { className: "flex flex-col divide-y divide-gray-200 text-gray-900", children: [jsxs("div", { className: "px-3 py-2", children: [username && jsx("div", { className: "text-sm font-medium", children: username }), jsx("div", { className: "mt-1 flex items-center gap-2", children: jsx(Button, { size: "small", color: "light", onClick: copyToClipboard.bind(null, address), className: "w-full cursor-pointer bg-transparent p-0 active:opacity-70", type: "button", children: jsxs("div", { className: "relative flex w-full items-center gap-1", children: [jsxs("div", { className: `flex items-center gap-1 transition-opacity duration-150 ${isCopied ? "opacity-0" : "opacity-100"}`, children: [jsx("span", { className: "text-xs", children: shortAddress(address) }), jsx(Icon, { name: "FilesEarmark", color: "#9EA0A1", size: 14 })] }), jsx("div", { className: `absolute left-0 text-xs transition-opacity duration-150 ${isCopied ? "opacity-100" : "opacity-0"}`, children: "Copied to clipboard!" })] }) }) })] }), etherscanUrl && jsx("div", { className: "px-3 py-2", children: jsxs("a", { href: etherscanUrl, target: "_blank", rel: "noopener noreferrer", className: "flex items-center gap-2 text-sm text-gray-900 hover:text-gray-600", children: [jsx(Icon, { name: "Ethscan", size: 14 }), "View on Etherscan"] }) }), jsx("div", { className: "px-3 py-2", children: jsxs("button", { onClick: onDisconnect, className: "flex w-full cursor-pointer items-center gap-2 text-sm text-red-900 hover:text-red-700", type: "button", children: [jsx(Icon, { name: "Disconnect", size: 14, color: "#EA4335" }), "Disconnect"] }) })] });
73
+ };
74
+ function useSwitchboard(reactor) {
75
+ return {
76
+ getDriveIdBySlug: async (driveUrl, slug) => {
77
+ if (!driveUrl) {
78
+ return;
79
+ }
80
+ const urlParts = driveUrl.split("/");
81
+ urlParts.pop();
82
+ urlParts.pop();
83
+ urlParts.push("drives");
84
+ const drivesUrl = urlParts.join("/");
85
+ const result = await fetch(drivesUrl, {
86
+ method: "POST",
87
+ headers: {
88
+ "Content-Type": "application/json"
89
+ },
90
+ body: JSON.stringify({
91
+ query: `
92
+ query getDriveIdBySlug($slug: String!) {
93
+ driveIdBySlug(slug: $slug)
94
+ }
95
+ `,
96
+ variables: {
97
+ slug
98
+ }
99
+ })
100
+ });
101
+ const data = await result.json();
102
+ return data.data.driveIdBySlug;
103
+ },
104
+ getSwitchboardGatewayUrl: (driveUrl) => {
105
+ const urlParts = driveUrl.split("/");
106
+ urlParts.pop();
107
+ urlParts.pop();
108
+ urlParts.push("graphql");
109
+ return urlParts.join("/");
110
+ },
111
+ getDocumentGraphqlQuery: async (driveId, documentId) => {
112
+ const doc = await reactor.getDocument(driveId, documentId);
113
+ const docModel = reactor.getDocumentModelModules().find((m) => m.documentModel.id === doc.documentType);
114
+ if (!docModel) {
115
+ throw new Error("Document model not found");
116
+ }
117
+ const stateFields = generateDocumentStateQueryFields(docModel.documentModel, "document");
118
+ return `
119
+ query getDocument($documentId: String!) {
120
+ ${docModel.documentModel.name} {
121
+ getDocument(id: $documentId) {
122
+ ${stateFields}
123
+ }
124
+ }
125
+ }
126
+ `;
127
+ }
128
+ };
129
+ }
130
+ const ImgPowerhouse = "/assets/powerhouse-rounded-CeKGGUG4.png";
131
+ function getAction(client, actionFn, name) {
132
+ const action_implicit = client[actionFn.name];
133
+ if (typeof action_implicit === "function")
134
+ return action_implicit;
135
+ const action_explicit = client[name];
136
+ if (typeof action_explicit === "function")
137
+ return action_explicit;
138
+ return (params) => actionFn(client, params);
139
+ }
140
+ function getChainId(config) {
141
+ return config.state.chainId;
142
+ }
143
+ function getEnsAvatar(config, parameters) {
144
+ const { chainId, ...rest } = parameters;
145
+ const client = config.getClient({ chainId });
146
+ const action = getAction(client, getEnsAvatar$1, "getEnsAvatar");
147
+ return action(rest);
148
+ }
149
+ function getEnsName(config, parameters) {
150
+ const { chainId, ...rest } = parameters;
151
+ const client = config.getClient({ chainId });
152
+ const action = getAction(client, getEnsName$1, "getEnsName");
153
+ return action(rest);
154
+ }
155
+ function watchChainId(config, parameters) {
156
+ const { onChange } = parameters;
157
+ return config.subscribe((state) => state.chainId, onChange);
158
+ }
159
+ const version = "2.15.4";
160
+ const getVersion = () => `wagmi@${version}`;
161
+ class BaseError extends BaseError$1 {
162
+ constructor() {
163
+ super(...arguments);
164
+ Object.defineProperty(this, "name", {
165
+ enumerable: true,
166
+ configurable: true,
167
+ writable: true,
168
+ value: "WagmiError"
169
+ });
170
+ }
171
+ get docsBaseUrl() {
172
+ return "https://wagmi.sh/react";
173
+ }
174
+ get version() {
175
+ return getVersion();
176
+ }
177
+ }
178
+ class WagmiProviderNotFoundError extends BaseError {
179
+ constructor() {
180
+ super("`useConfig` must be used within `WagmiProvider`.", {
181
+ docsPath: "/api/WagmiProvider"
182
+ });
183
+ Object.defineProperty(this, "name", {
184
+ enumerable: true,
185
+ configurable: true,
186
+ writable: true,
187
+ value: "WagmiProviderNotFoundError"
188
+ });
189
+ }
190
+ }
191
+ function useConfig(parameters = {}) {
192
+ const config = parameters.config ?? useContext(WagmiContext);
193
+ if (!config)
194
+ throw new WagmiProviderNotFoundError();
195
+ return config;
196
+ }
197
+ function hashFn(queryKey) {
198
+ return JSON.stringify(queryKey, (_, value) => {
199
+ if (isPlainObject(value))
200
+ return Object.keys(value).sort().reduce((result, key) => {
201
+ result[key] = value[key];
202
+ return result;
203
+ }, {});
204
+ if (typeof value === "bigint")
205
+ return value.toString();
206
+ return value;
207
+ });
208
+ }
209
+ function isPlainObject(value) {
210
+ if (!hasObjectPrototype(value)) {
211
+ return false;
212
+ }
213
+ const ctor = value.constructor;
214
+ if (typeof ctor === "undefined")
215
+ return true;
216
+ const prot = ctor.prototype;
217
+ if (!hasObjectPrototype(prot))
218
+ return false;
219
+ if (!prot.hasOwnProperty("isPrototypeOf"))
220
+ return false;
221
+ return true;
222
+ }
223
+ function hasObjectPrototype(o) {
224
+ return Object.prototype.toString.call(o) === "[object Object]";
225
+ }
226
+ function filterQueryOptions(options) {
227
+ const {
228
+ // import('@tanstack/query-core').QueryOptions
229
+ _defaulted,
230
+ behavior,
231
+ gcTime,
232
+ initialData,
233
+ initialDataUpdatedAt,
234
+ maxPages,
235
+ meta,
236
+ networkMode,
237
+ queryFn,
238
+ queryHash,
239
+ queryKey,
240
+ queryKeyHashFn,
241
+ retry,
242
+ retryDelay,
243
+ structuralSharing,
244
+ // import('@tanstack/query-core').InfiniteQueryObserverOptions
245
+ getPreviousPageParam,
246
+ getNextPageParam,
247
+ initialPageParam,
248
+ // import('@tanstack/react-query').UseQueryOptions
249
+ _optimisticResults,
250
+ enabled,
251
+ notifyOnChangeProps,
252
+ placeholderData,
253
+ refetchInterval,
254
+ refetchIntervalInBackground,
255
+ refetchOnMount,
256
+ refetchOnReconnect,
257
+ refetchOnWindowFocus,
258
+ retryOnMount,
259
+ select,
260
+ staleTime,
261
+ suspense,
262
+ throwOnError,
263
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
264
+ // wagmi
265
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
266
+ config,
267
+ connector,
268
+ query,
269
+ ...rest
270
+ } = options;
271
+ return rest;
272
+ }
273
+ function getEnsAvatarQueryOptions(config, options = {}) {
274
+ return {
275
+ async queryFn({ queryKey }) {
276
+ const { name, scopeKey: _, ...parameters } = queryKey[1];
277
+ if (!name)
278
+ throw new Error("name is required");
279
+ return getEnsAvatar(config, { ...parameters, name });
280
+ },
281
+ queryKey: getEnsAvatarQueryKey(options)
282
+ };
283
+ }
284
+ function getEnsAvatarQueryKey(options = {}) {
285
+ return ["ensAvatar", filterQueryOptions(options)];
286
+ }
287
+ function getEnsNameQueryOptions(config, options = {}) {
288
+ return {
289
+ async queryFn({ queryKey }) {
290
+ const { address, scopeKey: _, ...parameters } = queryKey[1];
291
+ if (!address)
292
+ throw new Error("address is required");
293
+ return getEnsName(config, { ...parameters, address });
294
+ },
295
+ queryKey: getEnsNameQueryKey(options)
296
+ };
297
+ }
298
+ function getEnsNameQueryKey(options = {}) {
299
+ return ["ensName", filterQueryOptions(options)];
300
+ }
301
+ function useQuery(parameters) {
302
+ const result = useQuery$1({
303
+ ...parameters,
304
+ queryKeyHashFn: hashFn
305
+ // for bigint support
306
+ });
307
+ result.queryKey = parameters.queryKey;
308
+ return result;
309
+ }
310
+ function useChainId(parameters = {}) {
311
+ const config = useConfig(parameters);
312
+ return useSyncExternalStore((onChange) => watchChainId(config, { onChange }), () => getChainId(config), () => getChainId(config));
313
+ }
314
+ function useEnsAvatar(parameters = {}) {
315
+ const { name, query = {} } = parameters;
316
+ const config = useConfig(parameters);
317
+ const chainId = useChainId({ config });
318
+ const options = getEnsAvatarQueryOptions(config, {
319
+ ...parameters,
320
+ chainId: parameters.chainId ?? chainId
321
+ });
322
+ const enabled = Boolean(name && (query.enabled ?? true));
323
+ return useQuery({ ...query, ...options, enabled });
324
+ }
325
+ function useEnsName(parameters = {}) {
326
+ const { address, query = {} } = parameters;
327
+ const config = useConfig(parameters);
328
+ const chainId = useChainId({ config });
329
+ const options = getEnsNameQueryOptions(config, {
330
+ ...parameters,
331
+ chainId: parameters.chainId ?? chainId
332
+ });
333
+ const enabled = Boolean(address && (query.enabled ?? true));
334
+ return useQuery({ ...query, ...options, enabled });
335
+ }
336
+ function ENSAvatar(props) {
337
+ const { address, chainId = 1, size = "14px" } = props;
338
+ const style = {
339
+ width: size,
340
+ height: size
341
+ };
342
+ const ensNameResult = useEnsName({ address, chainId });
343
+ const name = ensNameResult.data ?? void 0;
344
+ const ensAvatarResult = useEnsAvatar({ name });
345
+ const avatarUrl = ensAvatarResult.data ?? ImgPowerhouse;
346
+ const isLoading = ensNameResult.isLoading || ensAvatarResult.isLoading;
347
+ if (isLoading)
348
+ return jsx("div", { className: "fade-out flex-none animate-pulse rounded-full bg-gray-400", style });
349
+ return jsx("img", { alt: "ENS Avatar", className: "flex-none rounded-full object-contain", src: avatarUrl, style });
350
+ }
351
+ const HomeBg = "/assets/home-bg-BEhF9NuW.png";
352
+ const HomeScreen = function HomeScreen2(props) {
353
+ const { children, containerClassName } = props;
354
+ return jsx("div", { className: twMerge("container relative mx-auto flex h-full flex-col", containerClassName), children: jsxs("div", { className: "m-8 flex flex-wrap justify-center gap-4 pt-12", children: [jsx("img", { src: HomeBg, alt: "background", className: "pointer-events-none absolute inset-8 z-0 size-[calc(100%-32px)] object-contain" }), children] }) });
355
+ };
356
+ const HomeScreenItem = function HomeScreenItem2(props) {
357
+ const { icon, title, description, containerClassName, shareable, onClick } = props;
358
+ return jsxs("div", { className: twMerge("relative flex h-24 cursor-pointer flex-col items-center justify-center text-center text-sm text-black", containerClassName, onClick && "cursor-pointer"), onClick, children: [jsx("div", { className: "mx-auto pb-2", children: icon || jsx("div", { className: "size-8 items-center justify-center rounded-lg bg-black pt-1", children: jsx("span", { className: "text-6 w-6 text-white", children: title.slice(0, 1).toUpperCase() }) }) }), jsxs("div", { children: [jsx("h3", { children: title }), description && jsx("p", { className: "text-gray-500", children: description })] }), shareable && jsx("div", { className: "absolute left-2 top-0 mb-2", children: jsx(Icon, { name: "PeopleFill", width: 12, height: 12 }) })] });
359
+ };
360
+ const HomeScreenAddDriveItem = function HomeScreenAddDriveItem2(props) {
361
+ const { containerClassName, onClick } = props;
362
+ return jsx(HomeScreenItem, { title: "Create New Drive", icon: jsx(Icon, { name: "PlusSquare", size: 32 }), onClick, containerClassName });
363
+ };
364
+ const renownShortHover = "/assets/renown-short-hover-BiSLBV7L.png";
365
+ const renownShort = "data:image/png;base64,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";
366
+ const SidebarLogin = ({ onLogin }) => {
367
+ const content = jsx(AccountPopoverLogin, { onLogin });
368
+ return jsx(AccountPopover, { content, children: jsxs("div", { className: "group/sidebar-footer flex w-full cursor-pointer items-baseline justify-start text-sm font-semibold leading-10 text-gray-600", children: [jsx("img", { className: "group-hover/sidebar-footer:hidden", src: renownShort }), jsx("img", { className: "hidden group-hover/sidebar-footer:block", src: renownShortHover })] }) });
369
+ };
370
+ const SidebarUser = ({ address, etherscanUrl, onDisconnect }) => {
371
+ const { data } = useEnsName({ address });
372
+ const ensName = data;
373
+ const content = jsx(AccountPopoverUser, { address, username: ensName, onDisconnect, etherscanUrl });
374
+ return jsx(AccountPopover, { content, children: jsx("div", { className: "flex items-center justify-center rounded-sm", children: jsx(ENSAvatar, { address, size: "40px" }) }) });
375
+ };
376
+ const ConnectSidebarFooter = ({ address, className, onLogin, onClickSettings, onDisconnect, etherscanUrl = "", ...props }) => {
377
+ return jsxs(SidebarFooter, { ...props, className: twMerge("flex flex-col gap-2 border-t border-gray-300 px-2 py-4", className), children: [jsx("div", { className: "", children: address ? jsx(SidebarUser, { address, onDisconnect, etherscanUrl }) : jsx(SidebarLogin, { onLogin }) }), jsxs("button", { type: "button", className: "mt-3 flex w-full cursor-pointer items-center justify-center outline-none", onClick: onClickSettings, children: [jsx(Icon, { className: "text-gray-600", name: "Settings" }), jsx("span", { className: "hidden text-sm font-semibold leading-6 text-gray-800", children: "Settings" })] })] });
378
+ };
379
+ const ConnectSidebarHeader = ({ onClick, className, children, ...props }) => {
380
+ return jsx(SidebarHeader, { ...props, className: twMerge("flex justify-center gap-4 border-b border-gray-300 py-4", className), children: jsx("button", { className: "", onClick, type: "button", children: jsx(Icon, { className: "text-gray-600", name: "ConnectSmall", size: 24 }) }) });
381
+ };
382
+ const ConnectSidebar = ({ onClick, address, headerContent, onClickSettings, maxWidth = "304px", minWidth = "58px", onLogin, onDisconnect, etherscanUrl, ...props }) => {
383
+ return jsxs(Sidebar$1, { ...props, maxWidth, minWidth, children: [jsxs(SidebarPanel, { children: [jsx(ConnectSidebarHeader, { onClick, children: headerContent }), jsx("div", { className: "flex flex-col", children: props.children })] }), jsx(ConnectSidebarFooter, { address, onClickSettings, onLogin, onDisconnect, etherscanUrl })] });
384
+ };
385
+ const SidebarItem = function SidebarItem2(props) {
386
+ const { icon, title, description, containerClassName, active, onClick } = props;
387
+ return jsx("div", { className: twMerge("relative flex cursor-pointer flex-col items-center justify-center text-center text-sm text-black", containerClassName, active && "bg-white", onClick && "cursor-pointer"), onClick, children: jsx("div", { className: "mx-auto py-4", children: icon || jsx("div", { className: "size-8 items-center justify-center rounded-lg bg-black pt-1", children: jsx("span", { className: "text-6 w-6 text-white", children: title.slice(0, 1).toUpperCase() }) }) }) });
388
+ };
389
+ const SidebarAddDriveItem = function SidebarAddDriveItem2(props) {
390
+ const { containerClassName, onClick } = props;
391
+ return jsx(SidebarItem, { title: "Create New Drive", icon: jsx(Icon, { name: "PlusSquare", size: 32 }), onClick, containerClassName });
392
+ };
393
+ function useMakeUiDriveNode() {
394
+ const { getSyncStatus } = useDocumentDriveServer();
395
+ const makeUiDriveNode = useCallback(
396
+ async (drive) => {
397
+ const isReadDrive = "readContext" in drive;
398
+ const id = drive.id;
399
+ const { name, icon } = drive.state.global;
400
+ const { slug } = drive;
401
+ const { sharingType: _sharingType, availableOffline } = !isReadDrive ? drive.state.local : { sharingType: PUBLIC, availableOffline: false };
402
+ const __sharingType = _sharingType == null ? void 0 : _sharingType.toUpperCase();
403
+ const sharingType = __sharingType === "PRIVATE" ? LOCAL : __sharingType;
404
+ const driveSyncStatus = !isReadDrive ? await getSyncStatus(id, sharingType) : void 0;
405
+ const normalizedDriveSyncStatus = driveSyncStatus === "INITIAL_SYNC" ? "SYNCING" : driveSyncStatus;
406
+ const driveNode = {
407
+ id,
408
+ name,
409
+ slug: slug || null,
410
+ kind: DRIVE,
411
+ children: [],
412
+ nodeMap: {},
413
+ sharingType,
414
+ syncStatus: normalizedDriveSyncStatus,
415
+ availableOffline,
416
+ icon,
417
+ parentFolder: null,
418
+ driveId: id
419
+ };
420
+ const nodes = drive.state.global.nodes.map((n) => {
421
+ const node = {
422
+ ...n,
423
+ slug: makeNodeSlugFromNodeName(n.name),
424
+ driveId: id,
425
+ parentFolder: n.parentFolder || id,
426
+ kind: n.kind.toUpperCase(),
427
+ syncStatus: normalizedDriveSyncStatus,
428
+ sharingType
429
+ };
430
+ if (node.kind === DRIVE) {
431
+ throw new Error("Drive nodes should not be nested");
432
+ }
433
+ if (node.kind === FILE) {
434
+ return node;
435
+ }
436
+ return {
437
+ ...node,
438
+ children: []
439
+ };
440
+ });
441
+ for (const node of nodes) {
442
+ driveNode.nodeMap[node.id] = node;
443
+ }
444
+ for await (const node of nodes) {
445
+ if (node.kind === FILE) {
446
+ const fileSyncStatus = !isReadDrive ? await getSyncStatus(
447
+ node.synchronizationUnits[0].syncId,
448
+ sharingType
449
+ ) : void 0;
450
+ const normalizedFileSyncStatus = fileSyncStatus === "INITIAL_SYNC" ? "SYNCING" : fileSyncStatus;
451
+ node.syncStatus = normalizedFileSyncStatus;
452
+ }
453
+ if (node.parentFolder === id) {
454
+ driveNode.children.push(node);
455
+ continue;
456
+ }
457
+ const parent = driveNode.nodeMap[node.parentFolder];
458
+ if (parent.kind === FILE) {
459
+ throw new Error(
460
+ `Parent node ${node.parentFolder} is a file, not a folder`
461
+ );
462
+ }
463
+ parent.children.push(node);
464
+ if (node.syncStatus !== SUCCESS) {
465
+ parent.syncStatus = node.syncStatus;
466
+ }
467
+ }
468
+ return driveNode;
469
+ },
470
+ [getSyncStatus]
471
+ );
472
+ return makeUiDriveNode;
473
+ }
474
+ function useShowAddDriveModal() {
475
+ const { showModal } = useModal();
476
+ const { addDrive, addRemoteDrive } = useDocumentDriveServer();
477
+ const { setSelectedNode } = useUiNodesContext();
478
+ const apps = useApps();
479
+ const makeUiDriveNode = useMakeUiDriveNode();
480
+ const onAddLocalDrive = useCallback(
481
+ async (data) => {
482
+ try {
483
+ const app = apps.find((a) => a.id === data.appId);
484
+ const newDrive = await addDrive(
485
+ {
486
+ id: "",
487
+ slug: "",
488
+ global: {
489
+ name: data.name,
490
+ icon: null
491
+ },
492
+ local: {
493
+ availableOffline: data.availableOffline,
494
+ sharingType: data.sharingType.toLowerCase(),
495
+ listeners: [],
496
+ triggers: []
497
+ }
498
+ },
499
+ app == null ? void 0 : app.driveEditor
500
+ );
501
+ toast$1(t("notifications.addDriveSuccess"), {
502
+ type: "connect-success"
503
+ });
504
+ const newDriveNode = await makeUiDriveNode(newDrive);
505
+ setSelectedNode(newDriveNode);
506
+ } catch (e) {
507
+ console.error(e);
508
+ }
509
+ },
510
+ [addDrive, makeUiDriveNode, setSelectedNode, t]
511
+ );
512
+ const onAddRemoteDrive = useCallback(
513
+ async (data) => {
514
+ try {
515
+ const newDrive = await addRemoteDrive(data.url, {
516
+ sharingType: data.sharingType,
517
+ availableOffline: data.availableOffline,
518
+ listeners: [
519
+ {
520
+ block: true,
521
+ callInfo: {
522
+ data: data.url,
523
+ name: "switchboard-push",
524
+ transmitterType: "SwitchboardPush"
525
+ },
526
+ filter: {
527
+ branch: ["main"],
528
+ documentId: ["*"],
529
+ documentType: ["*"],
530
+ scope: ["global"]
531
+ },
532
+ label: "Switchboard Sync",
533
+ listenerId: "1",
534
+ system: true
535
+ }
536
+ ],
537
+ triggers: []
538
+ });
539
+ toast$1(t("notifications.addDriveSuccess"), {
540
+ type: "connect-success"
541
+ });
542
+ const newDriveNode = await makeUiDriveNode(newDrive);
543
+ setSelectedNode(newDriveNode);
544
+ } catch (e) {
545
+ console.error(e);
546
+ }
547
+ },
548
+ [addRemoteDrive, makeUiDriveNode, setSelectedNode, t]
549
+ );
550
+ const showAddDriveModal = useCallback(
551
+ () => showModal("addDriveModal", {
552
+ onAddLocalDrive,
553
+ onAddRemoteDrive
554
+ }),
555
+ [onAddLocalDrive, onAddRemoteDrive, showModal]
556
+ );
557
+ return showAddDriveModal;
558
+ }
559
+ const DELAY_LIMIT = 1e5;
560
+ const isListenerIdNotFound = (errorMessage, listenerId) => {
561
+ if (!listenerId) return false;
562
+ return errorMessage.toLocaleLowerCase().includes(`transmitter ${listenerId} not found`);
563
+ };
564
+ const useClientErrorHandler = () => {
565
+ const [handlingInProgress, setHandlingInProgress] = useState([]);
566
+ const [pullResponderTriggerMap, setPullResponderTriggerMap] = useState(/* @__PURE__ */ new Map());
567
+ const {
568
+ addTrigger,
569
+ removeTrigger,
570
+ registerNewPullResponderTrigger,
571
+ renameDrive,
572
+ addRemoteDrive,
573
+ documentDrives,
574
+ setDriveSharingType
575
+ } = useDocumentDriveServer();
576
+ const reactor = useUnwrappedReactor();
577
+ const { getDriveIdBySlug } = useSwitchboard(reactor);
578
+ const pullResponderRegisterDelay = useRef(/* @__PURE__ */ new Map());
579
+ const handleStrands400 = useCallback(
580
+ async (driveId, trigger, handlerCode) => {
581
+ setHandlingInProgress((state) => [...state, handlerCode]);
582
+ const triggerData = trigger.data;
583
+ try {
584
+ let pullResponderTrigger = pullResponderTriggerMap.get(handlerCode);
585
+ if (!pullResponderTrigger) {
586
+ pullResponderTrigger = await registerNewPullResponderTrigger(
587
+ driveId,
588
+ triggerData.url,
589
+ {
590
+ pullInterval: Number(triggerData.interval) || 3e3
591
+ }
592
+ );
593
+ pullResponderTriggerMap.set(
594
+ handlerCode,
595
+ pullResponderTrigger
596
+ );
597
+ setPullResponderTriggerMap(pullResponderTriggerMap);
598
+ }
599
+ await removeTrigger(driveId, trigger.id);
600
+ await addTrigger(driveId, pullResponderTrigger);
601
+ pullResponderRegisterDelay.current.delete(handlerCode);
602
+ } catch (error) {
603
+ const delay = pullResponderRegisterDelay.current.get(handlerCode) || 1;
604
+ pullResponderRegisterDelay.current.set(
605
+ handlerCode,
606
+ delay === DELAY_LIMIT ? delay : delay * 10
607
+ );
608
+ logger.error(error);
609
+ } finally {
610
+ setHandlingInProgress(
611
+ (state) => state.filter((code) => code !== handlerCode)
612
+ );
613
+ }
614
+ },
615
+ [
616
+ pullResponderTriggerMap,
617
+ removeTrigger,
618
+ addTrigger,
619
+ pullResponderRegisterDelay,
620
+ registerNewPullResponderTrigger
621
+ ]
622
+ );
623
+ const handleDriveNotFound = useCallback(
624
+ async (driveId, trigger, handlerCode) => {
625
+ var _a;
626
+ setHandlingInProgress((state) => [...state, handlerCode]);
627
+ try {
628
+ const drive = documentDrives.find(
629
+ (drive2) => drive2.id === driveId
630
+ );
631
+ if (!drive) return;
632
+ await removeTrigger(driveId, trigger.id);
633
+ await renameDrive(
634
+ driveId,
635
+ drive.state.global.name + ` (${drive.id})`
636
+ );
637
+ await setDriveSharingType(driveId, LOCAL);
638
+ if (((_a = trigger.data) == null ? void 0 : _a.url) && drive.slug) {
639
+ const newId = await getDriveIdBySlug(
640
+ trigger.data.url,
641
+ drive.slug
642
+ );
643
+ if (newId) {
644
+ const urlParts = trigger.data.url.split("/");
645
+ urlParts[urlParts.length - 1] = newId;
646
+ const newUrl = urlParts.join("/");
647
+ await addRemoteDrive(newUrl, {
648
+ availableOffline: true,
649
+ sharingType: "PUBLIC",
650
+ listeners: [],
651
+ triggers: []
652
+ });
653
+ }
654
+ }
655
+ } catch (e) {
656
+ logger.error(e);
657
+ } finally {
658
+ setHandlingInProgress(
659
+ (state) => state.filter((code) => code !== handlerCode)
660
+ );
661
+ }
662
+ },
663
+ [
664
+ documentDrives,
665
+ removeTrigger,
666
+ renameDrive,
667
+ setDriveSharingType,
668
+ getDriveIdBySlug,
669
+ addRemoteDrive
670
+ ]
671
+ );
672
+ const strandsErrorHandler = useCallback(
673
+ async (driveId, trigger, status, errorMessage) => {
674
+ var _a;
675
+ switch (status) {
676
+ case 400: {
677
+ if (isListenerIdNotFound(
678
+ errorMessage,
679
+ (_a = trigger.data) == null ? void 0 : _a.listenerId
680
+ )) {
681
+ const autoRegisterPullResponder = localStorage.getItem(
682
+ "AUTO_REGISTER_PULL_RESPONDER"
683
+ ) !== "false";
684
+ if (!autoRegisterPullResponder) return;
685
+ const handlerCode = `strands:${driveId}:${status}`;
686
+ if (handlingInProgress.includes(handlerCode))
687
+ return;
688
+ if (!trigger.data) return;
689
+ const delay = pullResponderRegisterDelay.current.get(
690
+ handlerCode
691
+ ) || 0;
692
+ setTimeout(
693
+ () => handleStrands400(
694
+ driveId,
695
+ trigger,
696
+ handlerCode
697
+ ),
698
+ delay
699
+ );
700
+ }
701
+ break;
702
+ }
703
+ case 404: {
704
+ const handlerCode = `strands:${driveId}:${status}`;
705
+ if (handlingInProgress.includes(handlerCode)) return;
706
+ setTimeout(
707
+ () => handleDriveNotFound(
708
+ driveId,
709
+ trigger,
710
+ handlerCode
711
+ ),
712
+ 0
713
+ );
714
+ break;
715
+ }
716
+ }
717
+ },
718
+ [handleDriveNotFound, handleStrands400, handlingInProgress]
719
+ );
720
+ return useMemo(() => ({ strandsErrorHandler }), [strandsErrorHandler]);
721
+ };
722
+ /**
723
+ * React Router DOM v6.30.1
724
+ *
725
+ * Copyright (c) Remix Software Inc.
726
+ *
727
+ * This source code is licensed under the MIT license found in the
728
+ * LICENSE.md file in the root directory of this source tree.
729
+ *
730
+ * @license MIT
731
+ */
732
+ function _extends() {
733
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
734
+ for (var i = 1; i < arguments.length; i++) {
735
+ var source = arguments[i];
736
+ for (var key in source) {
737
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
738
+ target[key] = source[key];
739
+ }
740
+ }
741
+ }
742
+ return target;
743
+ };
744
+ return _extends.apply(this, arguments);
745
+ }
746
+ function createSearchParams(init) {
747
+ if (init === void 0) {
748
+ init = "";
749
+ }
750
+ return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
751
+ let value = init[key];
752
+ return memo.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
753
+ }, []));
754
+ }
755
+ function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
756
+ let searchParams = createSearchParams(locationSearch);
757
+ if (defaultSearchParams) {
758
+ defaultSearchParams.forEach((_, key) => {
759
+ if (!searchParams.has(key)) {
760
+ defaultSearchParams.getAll(key).forEach((value) => {
761
+ searchParams.append(key, value);
762
+ });
763
+ }
764
+ });
765
+ }
766
+ return searchParams;
767
+ }
768
+ const REACT_ROUTER_VERSION = "6";
769
+ try {
770
+ window.__reactRouterVersion = REACT_ROUTER_VERSION;
771
+ } catch (e) {
772
+ }
773
+ function createBrowserRouter(routes2, opts) {
774
+ return createRouter$1({
775
+ basename: opts == null ? void 0 : opts.basename,
776
+ future: _extends({}, opts == null ? void 0 : opts.future, {
777
+ v7_prependBasename: true
778
+ }),
779
+ history: createBrowserHistory({
780
+ window: opts == null ? void 0 : opts.window
781
+ }),
782
+ hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
783
+ routes: routes2,
784
+ mapRouteProperties,
785
+ dataStrategy: opts == null ? void 0 : opts.dataStrategy,
786
+ patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
787
+ window: opts == null ? void 0 : opts.window
788
+ }).initialize();
789
+ }
790
+ function parseHydrationData() {
791
+ var _window;
792
+ let state = (_window = window) == null ? void 0 : _window.__staticRouterHydrationData;
793
+ if (state && state.errors) {
794
+ state = _extends({}, state, {
795
+ errors: deserializeErrors(state.errors)
796
+ });
797
+ }
798
+ return state;
799
+ }
800
+ function deserializeErrors(errors) {
801
+ if (!errors) return null;
802
+ let entries = Object.entries(errors);
803
+ let serialized = {};
804
+ for (let [key, val] of entries) {
805
+ if (val && val.__type === "RouteErrorResponse") {
806
+ serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
807
+ } else if (val && val.__type === "Error") {
808
+ if (val.__subType) {
809
+ let ErrorConstructor = window[val.__subType];
810
+ if (typeof ErrorConstructor === "function") {
811
+ try {
812
+ let error = new ErrorConstructor(val.message);
813
+ error.stack = "";
814
+ serialized[key] = error;
815
+ } catch (e) {
816
+ }
817
+ }
818
+ }
819
+ if (serialized[key] == null) {
820
+ let error = new Error(val.message);
821
+ error.stack = "";
822
+ serialized[key] = error;
823
+ }
824
+ } else {
825
+ serialized[key] = val;
826
+ }
827
+ }
828
+ return serialized;
829
+ }
830
+ const ViewTransitionContext = /* @__PURE__ */ React.createContext({
831
+ isTransitioning: false
832
+ });
833
+ const FetchersContext = /* @__PURE__ */ React.createContext(/* @__PURE__ */ new Map());
834
+ const START_TRANSITION = "startTransition";
835
+ const startTransitionImpl = React[START_TRANSITION];
836
+ const FLUSH_SYNC = "flushSync";
837
+ const flushSyncImpl = ReactDOM[FLUSH_SYNC];
838
+ function startTransitionSafe(cb) {
839
+ if (startTransitionImpl) {
840
+ startTransitionImpl(cb);
841
+ } else {
842
+ cb();
843
+ }
844
+ }
845
+ function flushSyncSafe(cb) {
846
+ if (flushSyncImpl) {
847
+ flushSyncImpl(cb);
848
+ } else {
849
+ cb();
850
+ }
851
+ }
852
+ class Deferred {
853
+ constructor() {
854
+ this.status = "pending";
855
+ this.promise = new Promise((resolve, reject) => {
856
+ this.resolve = (value) => {
857
+ if (this.status === "pending") {
858
+ this.status = "resolved";
859
+ resolve(value);
860
+ }
861
+ };
862
+ this.reject = (reason) => {
863
+ if (this.status === "pending") {
864
+ this.status = "rejected";
865
+ reject(reason);
866
+ }
867
+ };
868
+ });
869
+ }
870
+ }
871
+ function RouterProvider(_ref) {
872
+ let {
873
+ fallbackElement,
874
+ router: router2,
875
+ future
876
+ } = _ref;
877
+ let [state, setStateImpl] = React.useState(router2.state);
878
+ let [pendingState, setPendingState] = React.useState();
879
+ let [vtContext, setVtContext] = React.useState({
880
+ isTransitioning: false
881
+ });
882
+ let [renderDfd, setRenderDfd] = React.useState();
883
+ let [transition, setTransition] = React.useState();
884
+ let [interruption, setInterruption] = React.useState();
885
+ let fetcherData = React.useRef(/* @__PURE__ */ new Map());
886
+ let {
887
+ v7_startTransition
888
+ } = future || {};
889
+ let optInStartTransition = React.useCallback((cb) => {
890
+ if (v7_startTransition) {
891
+ startTransitionSafe(cb);
892
+ } else {
893
+ cb();
894
+ }
895
+ }, [v7_startTransition]);
896
+ let setState = React.useCallback((newState, _ref2) => {
897
+ let {
898
+ deletedFetchers,
899
+ flushSync,
900
+ viewTransitionOpts
901
+ } = _ref2;
902
+ newState.fetchers.forEach((fetcher, key) => {
903
+ if (fetcher.data !== void 0) {
904
+ fetcherData.current.set(key, fetcher.data);
905
+ }
906
+ });
907
+ deletedFetchers.forEach((key) => fetcherData.current.delete(key));
908
+ let isViewTransitionUnavailable = router2.window == null || router2.window.document == null || typeof router2.window.document.startViewTransition !== "function";
909
+ if (!viewTransitionOpts || isViewTransitionUnavailable) {
910
+ if (flushSync) {
911
+ flushSyncSafe(() => setStateImpl(newState));
912
+ } else {
913
+ optInStartTransition(() => setStateImpl(newState));
914
+ }
915
+ return;
916
+ }
917
+ if (flushSync) {
918
+ flushSyncSafe(() => {
919
+ if (transition) {
920
+ renderDfd && renderDfd.resolve();
921
+ transition.skipTransition();
922
+ }
923
+ setVtContext({
924
+ isTransitioning: true,
925
+ flushSync: true,
926
+ currentLocation: viewTransitionOpts.currentLocation,
927
+ nextLocation: viewTransitionOpts.nextLocation
928
+ });
929
+ });
930
+ let t2 = router2.window.document.startViewTransition(() => {
931
+ flushSyncSafe(() => setStateImpl(newState));
932
+ });
933
+ t2.finished.finally(() => {
934
+ flushSyncSafe(() => {
935
+ setRenderDfd(void 0);
936
+ setTransition(void 0);
937
+ setPendingState(void 0);
938
+ setVtContext({
939
+ isTransitioning: false
940
+ });
941
+ });
942
+ });
943
+ flushSyncSafe(() => setTransition(t2));
944
+ return;
945
+ }
946
+ if (transition) {
947
+ renderDfd && renderDfd.resolve();
948
+ transition.skipTransition();
949
+ setInterruption({
950
+ state: newState,
951
+ currentLocation: viewTransitionOpts.currentLocation,
952
+ nextLocation: viewTransitionOpts.nextLocation
953
+ });
954
+ } else {
955
+ setPendingState(newState);
956
+ setVtContext({
957
+ isTransitioning: true,
958
+ flushSync: false,
959
+ currentLocation: viewTransitionOpts.currentLocation,
960
+ nextLocation: viewTransitionOpts.nextLocation
961
+ });
962
+ }
963
+ }, [router2.window, transition, renderDfd, fetcherData, optInStartTransition]);
964
+ React.useLayoutEffect(() => router2.subscribe(setState), [router2, setState]);
965
+ React.useEffect(() => {
966
+ if (vtContext.isTransitioning && !vtContext.flushSync) {
967
+ setRenderDfd(new Deferred());
968
+ }
969
+ }, [vtContext]);
970
+ React.useEffect(() => {
971
+ if (renderDfd && pendingState && router2.window) {
972
+ let newState = pendingState;
973
+ let renderPromise = renderDfd.promise;
974
+ let transition2 = router2.window.document.startViewTransition(async () => {
975
+ optInStartTransition(() => setStateImpl(newState));
976
+ await renderPromise;
977
+ });
978
+ transition2.finished.finally(() => {
979
+ setRenderDfd(void 0);
980
+ setTransition(void 0);
981
+ setPendingState(void 0);
982
+ setVtContext({
983
+ isTransitioning: false
984
+ });
985
+ });
986
+ setTransition(transition2);
987
+ }
988
+ }, [optInStartTransition, pendingState, renderDfd, router2.window]);
989
+ React.useEffect(() => {
990
+ if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
991
+ renderDfd.resolve();
992
+ }
993
+ }, [renderDfd, transition, state.location, pendingState]);
994
+ React.useEffect(() => {
995
+ if (!vtContext.isTransitioning && interruption) {
996
+ setPendingState(interruption.state);
997
+ setVtContext({
998
+ isTransitioning: true,
999
+ flushSync: false,
1000
+ currentLocation: interruption.currentLocation,
1001
+ nextLocation: interruption.nextLocation
1002
+ });
1003
+ setInterruption(void 0);
1004
+ }
1005
+ }, [vtContext.isTransitioning, interruption]);
1006
+ React.useEffect(() => {
1007
+ }, []);
1008
+ let navigator2 = React.useMemo(() => {
1009
+ return {
1010
+ createHref: router2.createHref,
1011
+ encodeLocation: router2.encodeLocation,
1012
+ go: (n) => router2.navigate(n),
1013
+ push: (to, state2, opts) => router2.navigate(to, {
1014
+ state: state2,
1015
+ preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
1016
+ }),
1017
+ replace: (to, state2, opts) => router2.navigate(to, {
1018
+ replace: true,
1019
+ state: state2,
1020
+ preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
1021
+ })
1022
+ };
1023
+ }, [router2]);
1024
+ let basename = router2.basename || "/";
1025
+ let dataRouterContext = React.useMemo(() => ({
1026
+ router: router2,
1027
+ navigator: navigator2,
1028
+ static: false,
1029
+ basename
1030
+ }), [router2, navigator2, basename]);
1031
+ let routerFuture = React.useMemo(() => ({
1032
+ v7_relativeSplatPath: router2.future.v7_relativeSplatPath
1033
+ }), [router2.future.v7_relativeSplatPath]);
1034
+ React.useEffect(() => logV6DeprecationWarnings(future, router2.future), [future, router2.future]);
1035
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DataRouterContext.Provider, {
1036
+ value: dataRouterContext
1037
+ }, /* @__PURE__ */ React.createElement(DataRouterStateContext.Provider, {
1038
+ value: state
1039
+ }, /* @__PURE__ */ React.createElement(FetchersContext.Provider, {
1040
+ value: fetcherData.current
1041
+ }, /* @__PURE__ */ React.createElement(ViewTransitionContext.Provider, {
1042
+ value: vtContext
1043
+ }, /* @__PURE__ */ React.createElement(Router, {
1044
+ basename,
1045
+ location: state.location,
1046
+ navigationType: state.historyAction,
1047
+ navigator: navigator2,
1048
+ future: routerFuture
1049
+ }, state.initialized || router2.future.v7_partialHydration ? /* @__PURE__ */ React.createElement(MemoizedDataRoutes, {
1050
+ routes: router2.routes,
1051
+ future: router2.future,
1052
+ state
1053
+ }) : fallbackElement))))), null);
1054
+ }
1055
+ const MemoizedDataRoutes = /* @__PURE__ */ React.memo(DataRoutes);
1056
+ function DataRoutes(_ref3) {
1057
+ let {
1058
+ routes: routes2,
1059
+ future,
1060
+ state
1061
+ } = _ref3;
1062
+ return useRoutesImpl(routes2, void 0, state, future);
1063
+ }
1064
+ var DataRouterHook;
1065
+ (function(DataRouterHook2) {
1066
+ DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
1067
+ DataRouterHook2["UseSubmit"] = "useSubmit";
1068
+ DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
1069
+ DataRouterHook2["UseFetcher"] = "useFetcher";
1070
+ DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
1071
+ })(DataRouterHook || (DataRouterHook = {}));
1072
+ var DataRouterStateHook;
1073
+ (function(DataRouterStateHook2) {
1074
+ DataRouterStateHook2["UseFetcher"] = "useFetcher";
1075
+ DataRouterStateHook2["UseFetchers"] = "useFetchers";
1076
+ DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
1077
+ })(DataRouterStateHook || (DataRouterStateHook = {}));
1078
+ function useSearchParams(defaultInit) {
1079
+ let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
1080
+ let hasSetSearchParamsRef = React.useRef(false);
1081
+ let location2 = useLocation();
1082
+ let searchParams = React.useMemo(() => (
1083
+ // Only merge in the defaults if we haven't yet called setSearchParams.
1084
+ // Once we call that we want those to take precedence, otherwise you can't
1085
+ // remove a param with setSearchParams({}) if it has an initial value
1086
+ getSearchParamsForLocation(location2.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
1087
+ ), [location2.search]);
1088
+ let navigate = useNavigate();
1089
+ let setSearchParams = React.useCallback((nextInit, navigateOptions) => {
1090
+ const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
1091
+ hasSetSearchParamsRef.current = true;
1092
+ navigate("?" + newSearchParams, navigateOptions);
1093
+ }, [navigate, searchParams]);
1094
+ return [searchParams, setSearchParams];
1095
+ }
1096
+ const CONNECT_TOAST_CONTAINER_ID = "connect";
1097
+ function toast(content, options) {
1098
+ const {
1099
+ type = "default",
1100
+ containerId = CONNECT_TOAST_CONTAINER_ID,
1101
+ ...restOptions
1102
+ } = options || {};
1103
+ return toast$1(content, { type, containerId, ...restOptions });
1104
+ }
1105
+ const useLoadInitialData = () => {
1106
+ const { t: t2 } = useTranslation();
1107
+ const { documentDrives, onSyncStatus } = useDocumentDriveServer();
1108
+ const { driveNodes, setDriveNodes } = useUiNodesContext();
1109
+ const prevDrivesState = useRef([...driveNodes]);
1110
+ const drivesWithError = useRef([]);
1111
+ const [, , serverSubscribeUpdates] = useDocumentDrives();
1112
+ const { readDrives } = useReadModeContext();
1113
+ const clientErrorHandler = useClientErrorHandler();
1114
+ const reactor = useAsyncReactor();
1115
+ const [connectConfig2] = useConnectConfig();
1116
+ async function checkLatestVersion() {
1117
+ const result = await isLatestVersion();
1118
+ if (result === null) return;
1119
+ if (result.isLatest) {
1120
+ return true;
1121
+ }
1122
+ if (window.__VITE_ENVS.MODE === "development" || connectConfig2.studioMode || !connectConfig2.warnOutdatedApp) {
1123
+ logger.warn(
1124
+ `Connect is outdated:
1125
+ Current: ${result.currentVersion}
1126
+ Latest: ${result.latestVersion}`
1127
+ );
1128
+ } else {
1129
+ toast(/* @__PURE__ */ jsx(ReloadConnectToast, {}), {
1130
+ type: "connect-warning",
1131
+ toastId: "outdated-app",
1132
+ autoClose: false
1133
+ });
1134
+ }
1135
+ }
1136
+ useEffect(() => {
1137
+ checkLatestVersion().catch(console.error);
1138
+ }, []);
1139
+ useEffect(() => {
1140
+ const unsubscribe = serverSubscribeUpdates(clientErrorHandler);
1141
+ return unsubscribe;
1142
+ }, [serverSubscribeUpdates, documentDrives, clientErrorHandler]);
1143
+ const checkDrivesErrors = useCallback(
1144
+ async (driveNodes2, t22) => {
1145
+ driveNodes2.forEach((drive) => {
1146
+ const prevDrive = prevDrivesState.current.find(
1147
+ (prevDrive2) => prevDrive2.id === drive.id
1148
+ );
1149
+ if (!prevDrive) return;
1150
+ if (drive.sharingType !== LOCAL && drive.syncStatus === SUCCESS && drivesWithError.current.includes(drive)) {
1151
+ drivesWithError.current = drivesWithError.current.filter(
1152
+ (d) => d.id !== drive.id
1153
+ );
1154
+ return toast(t22("notifications.driveSyncSuccess"), {
1155
+ type: "connect-success"
1156
+ });
1157
+ }
1158
+ if ((drive.syncStatus === CONFLICT || drive.syncStatus === ERROR) && drive.syncStatus !== prevDrive.syncStatus) {
1159
+ drivesWithError.current.push(drive);
1160
+ }
1161
+ });
1162
+ prevDrivesState.current = [...driveNodes2];
1163
+ if (drivesWithError.current.length > 0) {
1164
+ const isCurrent = await checkLatestVersion();
1165
+ if (isCurrent) {
1166
+ drivesWithError.current.forEach((drive) => {
1167
+ toast(
1168
+ t22(
1169
+ `notifications.${drive.syncStatus === CONFLICT ? "driveSyncConflict" : "driveSyncError"}`,
1170
+ { drive: drive.name }
1171
+ ),
1172
+ {
1173
+ type: "connect-warning",
1174
+ toastId: `${drive.syncStatus === CONFLICT ? "driveSyncConflict" : "driveSyncError"}-${drive.id}`
1175
+ }
1176
+ );
1177
+ });
1178
+ }
1179
+ }
1180
+ },
1181
+ []
1182
+ );
1183
+ useEffect(() => {
1184
+ checkDrivesErrors(driveNodes, t2).catch(console.error);
1185
+ }, [driveNodes, t2, checkDrivesErrors]);
1186
+ const makeUiDriveNode = useMakeUiDriveNode();
1187
+ const makeUiDriveNodes = useCallback(
1188
+ async (documentDrives2) => {
1189
+ return Promise.all(documentDrives2.map(makeUiDriveNode));
1190
+ },
1191
+ [makeUiDriveNode]
1192
+ );
1193
+ const updateUiDriveNodes = useCallback(
1194
+ async (documentDrives2) => {
1195
+ const uiDriveNodes = await makeUiDriveNodes(documentDrives2);
1196
+ setDriveNodes(uiDriveNodes);
1197
+ },
1198
+ [makeUiDriveNodes, setDriveNodes]
1199
+ );
1200
+ useEffect(() => {
1201
+ const drives = [
1202
+ ...readDrives,
1203
+ ...documentDrives
1204
+ ];
1205
+ updateUiDriveNodes(drives).catch(console.error);
1206
+ }, [documentDrives, readDrives, updateUiDriveNodes]);
1207
+ useEffect(() => {
1208
+ if (!reactor) {
1209
+ return;
1210
+ }
1211
+ const unsub = onSyncStatus(() => updateUiDriveNodes(documentDrives));
1212
+ return unsub;
1213
+ }, [reactor, documentDrives, onSyncStatus, updateUiDriveNodes]);
1214
+ };
1215
+ function buildPathname(selectedNodePath) {
1216
+ const driveNode = selectedNodePath[0];
1217
+ if (!driveNode) {
1218
+ return;
1219
+ }
1220
+ if (driveNode.kind !== DRIVE) {
1221
+ throw new Error(
1222
+ "Node path is invalid, first node is not a drive node."
1223
+ );
1224
+ }
1225
+ const driveNodeComponent = makeDriveNodeUrlComponent(driveNode);
1226
+ const nodePathComponents = selectedNodePath.slice(1).map((node) => encodeURIComponent(node.slug || node.name));
1227
+ const pathname = [driveNodeComponent, ...nodePathComponents].join("/");
1228
+ return pathname;
1229
+ }
1230
+ function makeDriveNodeUrlComponent(driveNode) {
1231
+ const component = driveNode.slug || driveNode.name || driveNode.id;
1232
+ return `/d/${encodeURIComponent(component)}`;
1233
+ }
1234
+ function getSelectedNodeFromPathname(driveNodes, driveIdFromPathname, nodeNamesFromPathname) {
1235
+ if (!driveIdFromPathname) {
1236
+ return null;
1237
+ }
1238
+ const driveId = decodeURIComponent(driveIdFromPathname);
1239
+ const driveNode = driveNodes.find(
1240
+ (node) => (node == null ? void 0 : node.id) === driveId || (node == null ? void 0 : node.slug) === driveId || (node == null ? void 0 : node.name) === driveId
1241
+ );
1242
+ if (!driveNode) return null;
1243
+ if (!nodeNamesFromPathname) return driveNode;
1244
+ const nodeNames = nodeNamesFromPathname.split("/").filter(Boolean).map(decodeURIComponent);
1245
+ let selectedNode = driveNode;
1246
+ for (const nodeName of nodeNames) {
1247
+ if (selectedNode.kind === FILE) break;
1248
+ const nextNode = selectedNode.children.find(
1249
+ (node) => node.slug === nodeName || node.name === nodeName
1250
+ );
1251
+ if (!nextNode) {
1252
+ console.error("Node not found:", nodeName);
1253
+ break;
1254
+ }
1255
+ selectedNode = nextNode;
1256
+ }
1257
+ return selectedNode;
1258
+ }
1259
+ const useNodeNavigation = () => {
1260
+ const navigate = useNavigate();
1261
+ const location2 = useLocation();
1262
+ const { search, pathname } = location2;
1263
+ const params = useParams();
1264
+ const { driveNodes, selectedNode, selectedNodePath, setSelectedNode } = useUiNodesContext();
1265
+ const driveIdFromPathname = params.driveId;
1266
+ const nodeNamesFromPathname = params["*"];
1267
+ const selectedNodeFromPathname = getSelectedNodeFromPathname(
1268
+ driveNodes,
1269
+ driveIdFromPathname,
1270
+ nodeNamesFromPathname
1271
+ );
1272
+ const selectedNodePathname = buildPathname(selectedNodePath);
1273
+ useEffect(() => {
1274
+ if (!selectedNodePathname || selectedNodePathname === pathname) return;
1275
+ navigate({ pathname: selectedNodePathname, search });
1276
+ }, [search, navigate, selectedNodePathname]);
1277
+ useEffect(() => {
1278
+ if (selectedNode || !selectedNodeFromPathname) return;
1279
+ setSelectedNode(selectedNodeFromPathname);
1280
+ }, [selectedNode, selectedNodeFromPathname, setSelectedNode]);
1281
+ useEffect(() => {
1282
+ const selectedNodeFromPathname2 = getSelectedNodeFromPathname(
1283
+ driveNodes,
1284
+ driveIdFromPathname,
1285
+ nodeNamesFromPathname
1286
+ );
1287
+ if (!selectedNodeFromPathname2) return;
1288
+ setSelectedNode(selectedNodeFromPathname2);
1289
+ }, [
1290
+ driveNodes,
1291
+ driveIdFromPathname,
1292
+ nodeNamesFromPathname,
1293
+ setSelectedNode
1294
+ ]);
1295
+ };
1296
+ const SvgAtlasLogomark = (props) => /* @__PURE__ */ React.createElement("svg", { width: 28, height: 32, viewBox: "0 0 28 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M0.05092 23.7286L0.000163347 23.9993L0 23.9995L0.207853 24.067L27.6823 24.067L27.9995 23.9995L27.9161 23.6913L14.2182 0.209032L13.9998 0L13.749 0.246353L0.05092 23.7286ZM20.9994 11.9999L7.0003 11.9999L13.9998 23.999L20.9994 11.9999Z", fill: "url(#paint0_radial_319_20865)" }), /* @__PURE__ */ React.createElement("path", { d: "M14 0L0 23.9998V7.99993L14 0Z", fill: "url(#paint1_linear_319_20865)" }), /* @__PURE__ */ React.createElement("path", { d: "M28 24L7.82013e-05 24L14 31.9999L28 24Z", fill: "url(#paint2_linear_319_20865)" }), /* @__PURE__ */ React.createElement("path", { d: "M14 0L28 23.9998V7.99993L14 0Z", fill: "url(#paint3_linear_319_20865)" }), /* @__PURE__ */ React.createElement("defs", null, /* @__PURE__ */ React.createElement("radialGradient", { id: "paint0_radial_319_20865", cx: 0, cy: 0, r: 1, gradientUnits: "userSpaceOnUse", gradientTransform: "translate(13.9994 16.0344) rotate(-89.9988) scale(16.0344 16.201)" }, /* @__PURE__ */ React.createElement("stop", { offset: 0.181008, stopColor: "#FFCD6B" }), /* @__PURE__ */ React.createElement("stop", { offset: 1, stopColor: "#EB5EDF" })), /* @__PURE__ */ React.createElement("linearGradient", { id: "paint1_linear_319_20865", x1: -0.031454, y1: 24.041, x2: 13.801, y2: -0.142908, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ React.createElement("stop", { stopColor: "#4331E9" }), /* @__PURE__ */ React.createElement("stop", { offset: 1, stopColor: "#A273FF" })), /* @__PURE__ */ React.createElement("linearGradient", { id: "paint2_linear_319_20865", x1: -0.0310093, y1: 24, x2: 28.0444, y2: 24, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ React.createElement("stop", { stopColor: "#A273FF" }), /* @__PURE__ */ React.createElement("stop", { offset: 1, stopColor: "#4331E9" })), /* @__PURE__ */ React.createElement("linearGradient", { id: "paint3_linear_319_20865", x1: 28.0315, y1: 24.041, x2: 14.199, y2: -0.142908, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ React.createElement("stop", { stopColor: "#A273FF" }), /* @__PURE__ */ React.createElement("stop", { offset: 1, stopColor: "#4331E9" }))));
1297
+ const SvgRefresh = (props) => /* @__PURE__ */ React.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M15.6867 8.03333C15.4933 7.83999 15.1733 7.83999 14.98 8.03333L14.6733 8.34001V8C14.6733 4.32 11.68 1.32666 7.99999 1.32666C5.96666 1.32666 4.06666 2.23999 2.79333 3.82666C2.61999 4.03999 2.65332 4.35999 2.87332 4.52665C3.08666 4.69999 3.40666 4.66666 3.57332 4.44666C4.65999 3.09332 6.27332 2.31999 7.99999 2.31999C11.1267 2.31999 13.6733 4.86666 13.6733 7.99333V8.32666L13.3667 8.02002C13.1733 7.82669 12.8533 7.82669 12.66 8.02002C12.4667 8.21335 12.4667 8.53335 12.66 8.72668L13.82 9.88668C13.8667 9.93334 13.92 9.96666 13.98 9.99333C14.04 10.02 14.1067 10.0333 14.1733 10.0333C14.24 10.0333 14.3 10.02 14.3667 9.99333C14.4267 9.96666 14.48 9.93334 14.5267 9.88668L15.6867 8.72668C15.88 8.54668 15.88 8.22666 15.6867 8.03333Z", fill: "#6C7275" }), /* @__PURE__ */ React.createElement("path", { d: "M13.1267 11.4666C12.9133 11.2933 12.5933 11.3266 12.4267 11.5466C11.34 12.9 9.72665 13.6733 7.99998 13.6733C4.87332 13.6733 2.32665 11.1266 2.32665 7.99996V7.66663L2.63332 7.97331C2.73332 8.07331 2.85999 8.11996 2.98665 8.11996C3.11332 8.11996 3.23999 8.07331 3.33999 7.97331C3.53332 7.77998 3.53332 7.45998 3.33999 7.26664L2.17998 6.10661C2.13332 6.05994 2.07998 6.02663 2.01998 5.99996C1.89998 5.94663 1.75998 5.94663 1.63998 5.99996C1.57998 6.02663 1.52665 6.05994 1.47999 6.10661L0.319988 7.26664C0.126654 7.45998 0.126654 7.77998 0.319988 7.97331C0.513321 8.16664 0.833319 8.16664 1.02665 7.97331L1.33332 7.66663V7.99996C1.33332 11.68 4.32665 14.6733 8.00665 14.6733C10.04 14.6733 11.94 13.76 13.2133 12.1733C13.38 11.96 13.3467 11.64 13.1267 11.4666Z", fill: "#6C7275" }));
1298
+ const REACTOR_URL = "https://apps.powerhouse.io/sky-atlas/staging/switchboard";
1299
+ const MIN_LOADING_TIME = 2e3;
1300
+ function useReactorUrl() {
1301
+ const { search } = useLocation();
1302
+ return useMemo(() => {
1303
+ const params = new URLSearchParams(search);
1304
+ const url = params.get("reactorUrl") ?? REACTOR_URL;
1305
+ return url.endsWith("/") ? url : `${url}/`;
1306
+ }, [search]);
1307
+ }
1308
+ async function forkAtlas(docId, reactorUrl) {
1309
+ const document = gql`
1310
+ mutation ForkAtlas($docId: PHID) {
1311
+ ForkAtlas(docId: $docId)
1312
+ }
1313
+ `;
1314
+ return await request(`${reactorUrl}graphql`, document, { docId });
1315
+ }
1316
+ function AtlasImport() {
1317
+ const status = useRef("initial");
1318
+ const reactor = useUnwrappedReactor();
1319
+ const { documentId } = useParams();
1320
+ const reactorUrl = useReactorUrl();
1321
+ const navigate = useNavigate();
1322
+ const { addRemoteDrive } = useDocumentDriveServer();
1323
+ const [driveId, setDriveId] = useState(void 0);
1324
+ const [error, setError] = useState(void 0);
1325
+ const [loading, setLoading] = useState(true);
1326
+ const hasError = status.current === "error";
1327
+ useEffect(() => {
1328
+ if (error) {
1329
+ console.error("Error forking Atlas:", error);
1330
+ toast("Error forking Atlas", { type: "error" });
1331
+ }
1332
+ }, [error]);
1333
+ async function forkAtlasDocument(documentId2) {
1334
+ const result = await forkAtlas(documentId2, reactorUrl);
1335
+ const driveId2 = result.ForkAtlas;
1336
+ status.current = "forked";
1337
+ setDriveId(driveId2);
1338
+ }
1339
+ const redirectToDrive = useCallback(() => {
1340
+ if (driveId && !loading) {
1341
+ navigate(`/d/${driveId}`, { replace: true });
1342
+ }
1343
+ }, [driveId, navigate, loading]);
1344
+ const addForkDrive = useCallback(
1345
+ async (driveId2) => {
1346
+ console.log("Adding remote drive:", driveId2);
1347
+ const driveUrl = `${reactorUrl}d/${driveId2}`;
1348
+ try {
1349
+ const addedDrive = await addRemoteDrive(driveUrl, {
1350
+ sharingType: "PUBLIC",
1351
+ availableOffline: true,
1352
+ listeners: [
1353
+ {
1354
+ block: true,
1355
+ callInfo: {
1356
+ data: driveUrl,
1357
+ name: "switchboard-push",
1358
+ transmitterType: "SwitchboardPush"
1359
+ },
1360
+ filter: {
1361
+ branch: ["main"],
1362
+ documentId: ["*"],
1363
+ documentType: ["*"],
1364
+ scope: ["global"]
1365
+ },
1366
+ label: "Switchboard Sync",
1367
+ listenerId: "1",
1368
+ system: true
1369
+ }
1370
+ ],
1371
+ triggers: []
1372
+ });
1373
+ status.current = "done";
1374
+ console.log("Added remote drive:", addedDrive);
1375
+ setTimeout(() => {
1376
+ setLoading(false);
1377
+ }, MIN_LOADING_TIME);
1378
+ } catch (error2) {
1379
+ status.current = "error";
1380
+ setLoading(false);
1381
+ setError(error2);
1382
+ }
1383
+ },
1384
+ [addRemoteDrive, navigate, reactorUrl]
1385
+ );
1386
+ useEffect(() => {
1387
+ if (!documentId || status.current !== "initial") return;
1388
+ status.current = "forking";
1389
+ forkAtlasDocument(documentId).catch((error2) => {
1390
+ status.current = "error";
1391
+ setError(error2);
1392
+ });
1393
+ }, [documentId, status]);
1394
+ useEffect(() => {
1395
+ if (!driveId || !reactor || status.current !== "forked") return;
1396
+ status.current = "addingDrive";
1397
+ new Promise((resolve) => {
1398
+ setTimeout(resolve, 500);
1399
+ }).then(() => addForkDrive(driveId)).catch((error2) => {
1400
+ status.current = "error";
1401
+ setError(error2);
1402
+ });
1403
+ }, [driveId, reactor, status]);
1404
+ return /* @__PURE__ */ jsx("div", { className: "bg-gray-50 size-full flex justify-center gap-x-4", children: /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-2xl w-full max-w-[850px] drop-shadow-sm p-6", children: [
1405
+ /* @__PURE__ */ jsx("h1", { className: "text-lg text-gray-900 font-medium", children: "Welcome to the Atlas Explorer" }),
1406
+ /* @__PURE__ */ jsx("div", { className: "mt-4 bg-gray-50 border border-gray-200 rounded-xl p-6", children: /* @__PURE__ */ jsxs("div", { className: "bg-slate-50 rounded-2xl min-h-80 flex flex-col justify-center items-center", children: [
1407
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(SvgAtlasLogomark, {}) }),
1408
+ hasError ? /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-800 mt-3", children: "Error forking Atlas scope. Please try again." }) : /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500 mt-3", children: "Forking Atlas scope..." }),
1409
+ /* @__PURE__ */ jsx(
1410
+ Button,
1411
+ {
1412
+ onClick: hasError ? window.location.reload.bind(
1413
+ window.location
1414
+ ) : redirectToDrive,
1415
+ size: "small",
1416
+ color: "light",
1417
+ className: "bg-white border border-gray-200 h-9 px-3 mt-4 text-gray-600",
1418
+ children: hasError ? "Retry" : loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
1419
+ /* @__PURE__ */ jsx(SvgRefresh, { className: "animate-spin" }),
1420
+ "Loading"
1421
+ ] }) : "Continue"
1422
+ }
1423
+ )
1424
+ ] }) })
1425
+ ] }) });
1426
+ }
1427
+ const ErrorBoundaryContext = createContext(null);
1428
+ const initialState = {
1429
+ didCatch: false,
1430
+ error: null
1431
+ };
1432
+ class ErrorBoundary extends Component {
1433
+ constructor(props) {
1434
+ super(props);
1435
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
1436
+ this.state = initialState;
1437
+ }
1438
+ static getDerivedStateFromError(error) {
1439
+ return {
1440
+ didCatch: true,
1441
+ error
1442
+ };
1443
+ }
1444
+ resetErrorBoundary() {
1445
+ const {
1446
+ error
1447
+ } = this.state;
1448
+ if (error !== null) {
1449
+ var _this$props$onReset, _this$props;
1450
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1451
+ args[_key] = arguments[_key];
1452
+ }
1453
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
1454
+ args,
1455
+ reason: "imperative-api"
1456
+ });
1457
+ this.setState(initialState);
1458
+ }
1459
+ }
1460
+ componentDidCatch(error, info) {
1461
+ var _this$props$onError, _this$props2;
1462
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
1463
+ }
1464
+ componentDidUpdate(prevProps, prevState) {
1465
+ const {
1466
+ didCatch
1467
+ } = this.state;
1468
+ const {
1469
+ resetKeys
1470
+ } = this.props;
1471
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
1472
+ var _this$props$onReset2, _this$props3;
1473
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
1474
+ next: resetKeys,
1475
+ prev: prevProps.resetKeys,
1476
+ reason: "keys"
1477
+ });
1478
+ this.setState(initialState);
1479
+ }
1480
+ }
1481
+ render() {
1482
+ const {
1483
+ children,
1484
+ fallbackRender,
1485
+ FallbackComponent,
1486
+ fallback
1487
+ } = this.props;
1488
+ const {
1489
+ didCatch,
1490
+ error
1491
+ } = this.state;
1492
+ let childToRender = children;
1493
+ if (didCatch) {
1494
+ const props = {
1495
+ error,
1496
+ resetErrorBoundary: this.resetErrorBoundary
1497
+ };
1498
+ if (typeof fallbackRender === "function") {
1499
+ childToRender = fallbackRender(props);
1500
+ } else if (FallbackComponent) {
1501
+ childToRender = createElement(FallbackComponent, props);
1502
+ } else if (fallback !== void 0) {
1503
+ childToRender = fallback;
1504
+ } else {
1505
+ throw error;
1506
+ }
1507
+ }
1508
+ return createElement(ErrorBoundaryContext.Provider, {
1509
+ value: {
1510
+ didCatch,
1511
+ error,
1512
+ resetErrorBoundary: this.resetErrorBoundary
1513
+ }
1514
+ }, childToRender);
1515
+ }
1516
+ }
1517
+ function hasArrayChanged() {
1518
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
1519
+ let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
1520
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
1521
+ }
1522
+ const SvgConnect = (props) => /* @__PURE__ */ React.createElement("svg", { width: 107, height: 20, viewBox: "0 0 107 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M0.666504 10.1087C0.666504 8.30419 1.056 6.69918 1.83499 5.29371C2.61398 3.8709 3.6959 2.76908 5.08077 1.98827C6.48295 1.1901 8.0669 0.791016 9.83261 0.791016C11.9965 0.791016 13.8487 1.36361 15.3894 2.50881C16.9301 3.654 17.9601 5.21563 18.4794 7.1937H13.5977C13.2342 6.43023 12.7149 5.84896 12.0397 5.44988C11.3819 5.05079 10.6289 4.85125 9.78067 4.85125C8.41311 4.85125 7.30522 5.32842 6.45699 6.28275C5.60876 7.23708 5.18464 8.51241 5.18464 10.1087C5.18464 11.7051 5.60876 12.9804 6.45699 13.9347C7.30522 14.8891 8.41311 15.3662 9.78067 15.3662C10.6289 15.3662 11.3819 15.1667 12.0397 14.7676C12.7149 14.3685 13.2342 13.7872 13.5977 13.0238H18.4794C17.9601 15.0018 16.9301 16.5635 15.3894 17.7087C13.8487 18.8365 11.9965 19.4004 9.83261 19.4004C8.0669 19.4004 6.48295 19.01 5.08077 18.2292C3.6959 17.431 2.61398 16.3292 1.83499 14.9238C1.056 13.5183 0.666504 11.9133 0.666504 10.1087Z" }), /* @__PURE__ */ React.createElement("path", { d: "M26.7553 19.4785C25.3358 19.4785 24.0548 19.1749 22.9123 18.5676C21.7871 17.9603 20.8956 17.0927 20.2378 15.9648C19.5973 14.837 19.277 13.5183 19.277 12.0087C19.277 10.5165 19.6059 9.20646 20.2638 8.07862C20.9216 6.93343 21.8217 6.05718 22.9642 5.44988C24.1068 4.84258 25.3878 4.53893 26.8073 4.53893C28.2267 4.53893 29.5078 4.84258 30.6503 5.44988C31.7928 6.05718 32.693 6.93343 33.3508 8.07862C34.0086 9.20646 34.3375 10.5165 34.3375 12.0087C34.3375 13.5009 33.9999 14.8197 33.3248 15.9648C32.667 17.0927 31.7582 17.9603 30.5983 18.5676C29.4558 19.1749 28.1748 19.4785 26.7553 19.4785ZM26.7553 15.6265C27.6036 15.6265 28.322 15.3142 28.9105 14.6895C29.5164 14.0649 29.8193 13.1713 29.8193 12.0087C29.8193 10.8462 29.5251 9.95257 28.9365 9.32792C28.3652 8.70327 27.6555 8.39095 26.8073 8.39095C25.9417 8.39095 25.2233 8.70327 24.6521 9.32792C24.0808 9.93522 23.7952 10.8288 23.7952 12.0087C23.7952 13.1713 24.0721 14.0649 24.6261 14.6895C25.1973 15.3142 25.9071 15.6265 26.7553 15.6265Z" }), /* @__PURE__ */ React.createElement("path", { d: "M44.483 4.59098C46.1795 4.59098 47.5297 5.14623 48.5337 6.25672C49.5551 7.34986 50.0658 8.85944 50.0658 10.7854V19.2703H45.6515V11.3841C45.6515 10.4124 45.4005 9.6576 44.8985 9.11971C44.3964 8.58181 43.7213 8.31286 42.8731 8.31286C42.0249 8.31286 41.3497 8.58181 40.8477 9.11971C40.3457 9.6576 40.0947 10.4124 40.0947 11.3841V19.2703H35.6545V4.74714H40.0947V6.67315C40.5448 6.03115 41.1507 5.52796 41.9123 5.16358C42.674 4.78185 43.5309 4.59098 44.483 4.59098Z" }), /* @__PURE__ */ React.createElement("path", { d: "M60.9412 4.59098C62.6376 4.59098 63.9879 5.14623 64.9919 6.25672C66.0133 7.34986 66.5239 8.85944 66.5239 10.7854V19.2703H62.1096V11.3841C62.1096 10.4124 61.8586 9.6576 61.3566 9.11971C60.8546 8.58181 60.1795 8.31286 59.3313 8.31286C58.483 8.31286 57.8079 8.58181 57.3059 9.11971C56.8039 9.6576 56.5529 10.4124 56.5529 11.3841V19.2703H52.1126V4.74714H56.5529V6.67315C57.0029 6.03115 57.6088 5.52796 58.3705 5.16358C59.1322 4.78185 59.9891 4.59098 60.9412 4.59098Z" }), /* @__PURE__ */ React.createElement("path", { d: "M82.2291 11.7745C82.2291 12.1909 82.2031 12.6247 82.1512 13.0758H72.1022C72.1715 13.9781 72.4571 14.6722 72.9591 15.158C73.4784 15.6265 74.1103 15.8607 74.8546 15.8607C75.9625 15.8607 76.7329 15.3923 77.1656 14.4553H81.8915C81.6491 15.4096 81.2077 16.2685 80.5672 17.032C79.944 17.7954 79.1564 18.3941 78.2043 18.8278C77.2522 19.2616 76.1876 19.4785 75.0104 19.4785C73.5909 19.4785 72.3272 19.1749 71.2194 18.5676C70.1115 17.9603 69.2459 17.0927 68.6227 15.9648C67.9995 14.837 67.6879 13.5183 67.6879 12.0087C67.6879 10.4991 67.9909 9.18044 68.5968 8.05259C69.2199 6.92475 70.0855 6.05718 71.1934 5.44988C72.3013 4.84258 73.5736 4.53893 75.0104 4.53893C76.4126 4.53893 77.659 4.8339 78.7496 5.42385C79.8402 6.0138 80.6884 6.85534 81.2943 7.94848C81.9175 9.04163 82.2291 10.317 82.2291 11.7745ZM77.685 10.6033C77.685 9.83979 77.4253 9.23249 76.906 8.78135C76.3866 8.33022 75.7375 8.10465 74.9585 8.10465C74.2141 8.10465 73.5823 8.32154 73.063 8.75533C72.561 9.18911 72.2494 9.80509 72.1282 10.6033H77.685Z" }), /* @__PURE__ */ React.createElement("path", { d: "M82.65 12.0087C82.65 10.4991 82.9529 9.18044 83.5588 8.05259C84.182 6.92475 85.0389 6.05718 86.1295 5.44988C87.2374 4.84258 88.5011 4.53893 89.9206 4.53893C91.7382 4.53893 93.2529 5.01609 94.4647 5.97042C95.6937 6.92475 96.4987 8.26949 96.8795 10.0046H92.1537C91.7555 8.89414 90.9852 8.33889 89.8427 8.33889C89.0291 8.33889 88.3799 8.65989 87.8952 9.3019C87.4105 9.92655 87.1681 10.8288 87.1681 12.0087C87.1681 13.1886 87.4105 14.0996 87.8952 14.7416C88.3799 15.3662 89.0291 15.6786 89.8427 15.6786C90.9852 15.6786 91.7555 15.1233 92.1537 14.0128H96.8795C96.4987 15.7133 95.6937 17.0493 94.4647 18.021C93.2356 18.9927 91.7209 19.4785 89.9206 19.4785C88.5011 19.4785 87.2374 19.1749 86.1295 18.5676C85.0389 17.9603 84.182 17.0927 83.5588 15.9648C82.9529 14.837 82.65 13.5183 82.65 12.0087Z" }), /* @__PURE__ */ React.createElement("path", { d: "M106.291 15.4964V19.2703H104.032C102.423 19.2703 101.167 18.8799 100.267 18.0991C99.3672 17.3009 98.9171 16.0082 98.9171 14.221V8.443H97.1514V4.74714H98.9171V1.20745H103.357V4.74714H106.266V8.443H103.357V14.2731C103.357 14.7069 103.461 15.0192 103.669 15.2101C103.877 15.4009 104.223 15.4964 104.708 15.4964H106.291Z" }));
1523
+ const SvgLogo = (props) => /* @__PURE__ */ React.createElement("svg", { width: 26, height: 26, viewBox: "0 0 26 26", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M20.105 7.37978C19.9097 7.18452 19.9097 6.86795 20.105 6.67269L22.5725 4.20504C24.9229 6.75889 26.0649 10.0248 25.9972 13.2723L20.105 7.37978ZM16.1222 10.6556C15.927 10.8509 15.927 11.1674 16.1222 11.3627L24.2614 19.5023C25.125 18.0079 25.667 16.378 25.8875 14.7149L19.3289 8.15595C19.1336 7.96068 18.817 7.96068 18.6218 8.15595L16.1222 10.6556ZM0.00284613 12.729C-0.0649083 15.9752 1.07706 19.2411 3.42753 21.7962L5.89504 19.3285C6.09029 19.1333 6.09029 18.8167 5.89504 18.6214L0.00284613 12.729ZM4.20485 22.5723C6.75858 24.9229 10.0256 26.0649 13.2716 25.9972L7.37946 20.1047C7.1842 19.9094 6.8676 19.9094 6.67234 20.1047L4.20485 22.5723ZM13.0519 18.5174C13.2472 18.3222 13.2472 18.0056 13.0519 17.8103L1.73982 6.49772C0.87626 7.99209 0.334223 9.62072 0.113713 11.2851L9.84523 21.0171C10.0405 21.2124 10.3571 21.2124 10.5524 21.0171L13.0519 18.5174ZM9.60276 7.08454C9.78969 6.88798 9.7858 6.57823 9.594 6.38642L5.55009 2.34233C4.93783 2.77105 4.35391 3.25889 3.80695 3.80588C3.25998 4.35287 2.77216 4.93684 2.34346 5.54912L6.3864 9.59111C6.57859 9.78325 6.88907 9.7867 7.08548 9.59887L8.47817 8.26702L9.60276 7.08454ZM11.2072 21.6733C11.012 21.8685 11.012 22.1851 11.2072 22.3804L14.7142 25.8875C16.3785 25.667 18.0071 25.1249 19.5013 24.2613L14.4139 19.1736C14.2186 18.9783 13.902 18.9783 13.7067 19.1736L11.2072 21.6733ZM23.6565 20.4496L11.0843 7.87683C10.8891 7.68156 10.5725 7.68156 10.3772 7.87683L7.87766 10.3765C7.68241 10.5718 7.68241 10.8883 7.87766 11.0836L20.4499 23.6564C21.0622 23.2277 21.6461 22.7398 22.193 22.1929C22.74 21.6459 23.2278 21.0619 23.6565 20.4496ZM17.8445 7.37855C18.0397 7.18329 18.0397 6.86672 17.8445 6.67146L11.2858 0.112477C9.62151 0.332998 7.99294 0.875053 6.49865 1.73866L14.6378 9.87821C14.8331 10.0735 15.1497 10.0735 15.3449 9.87821L17.8445 7.37855ZM21.7951 3.42769C19.2414 1.07712 15.9744 -0.0649114 12.7284 0.00284625L18.6205 5.89529C18.8158 6.09056 19.1324 6.09056 19.3277 5.89529L21.7951 3.42769Z", fill: "url(#paint0_linear_526_12008)" }), /* @__PURE__ */ React.createElement("defs", null, /* @__PURE__ */ React.createElement("linearGradient", { id: "paint0_linear_526_12008", x1: 13, y1: 0, x2: 13, y2: 26, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ React.createElement("stop", { stopColor: "currentColor" }), /* @__PURE__ */ React.createElement("stop", { offset: 1, stopColor: "currentColor" }))));
1524
+ function Sidebar() {
1525
+ const { showModal } = useModal();
1526
+ const navigate = useNavigate();
1527
+ const { user, openRenown, logout } = useLogin();
1528
+ const { driveNodes, setSelectedNode, selectedNode } = useUiNodesContext();
1529
+ const [config] = useConnectConfig();
1530
+ const showAddDriveModal = useShowAddDriveModal();
1531
+ const connectDebug = localStorage.getItem("CONNECT_DEBUG") === "true";
1532
+ const onClickSettings = () => {
1533
+ showModal("settingsModal", { onRefresh: () => navigate(0) });
1534
+ };
1535
+ const onRootClick = useCallback(() => {
1536
+ setSelectedNode(null);
1537
+ navigate("/");
1538
+ }, [navigate, setSelectedNode]);
1539
+ const onAddDriveClick = useCallback(() => {
1540
+ showAddDriveModal();
1541
+ }, [showAddDriveModal]);
1542
+ const headerContent = /* @__PURE__ */ jsxs("div", { className: "flex h-full items-center", children: [
1543
+ /* @__PURE__ */ jsx(
1544
+ Icon,
1545
+ {
1546
+ name: "Connect",
1547
+ className: "!h-[30px] !w-[100px] cursor-pointer",
1548
+ onClick: onRootClick
1549
+ }
1550
+ ),
1551
+ connectDebug && /* @__PURE__ */ jsx(
1552
+ "button",
1553
+ {
1554
+ id: "connect-debug-button",
1555
+ className: "ml-6",
1556
+ onClick: () => showModal("debugSettingsModal", {}),
1557
+ children: /* @__PURE__ */ jsx("img", { src: "settings.png", className: "h-5 text-gray-600" })
1558
+ }
1559
+ )
1560
+ ] });
1561
+ const handleDriveClick = useCallback(
1562
+ (driveNode) => {
1563
+ setSelectedNode(driveNode);
1564
+ },
1565
+ [setSelectedNode]
1566
+ );
1567
+ const etherscanUrl = (user == null ? void 0 : user.address) ? `https://etherscan.io/address/${user.address}` : "";
1568
+ return /* @__PURE__ */ jsx(
1569
+ ConnectSidebar,
1570
+ {
1571
+ id: "sidebar",
1572
+ onClick: () => onRootClick(),
1573
+ onClickSettings,
1574
+ headerContent,
1575
+ address: user == null ? void 0 : user.address,
1576
+ onLogin: openRenown,
1577
+ onDisconnect: logout,
1578
+ etherscanUrl,
1579
+ children: /* @__PURE__ */ jsxs(
1580
+ ErrorBoundary,
1581
+ {
1582
+ fallback: /* @__PURE__ */ jsx("div", { className: "text-center", children: "There was an error loading drives" }),
1583
+ onError: logger.error,
1584
+ children: [
1585
+ driveNodes.map((node, index) => /* @__PURE__ */ jsx(
1586
+ SidebarItem,
1587
+ {
1588
+ title: node.name,
1589
+ onClick: () => handleDriveClick(node),
1590
+ active: (selectedNode == null ? void 0 : selectedNode.id) === node.id,
1591
+ icon: node.icon ? /* @__PURE__ */ jsx(
1592
+ "img",
1593
+ {
1594
+ src: node.icon,
1595
+ alt: node.name,
1596
+ width: 32,
1597
+ height: 32
1598
+ }
1599
+ ) : void 0
1600
+ },
1601
+ index
1602
+ )),
1603
+ config.drives.addDriveEnabled && /* @__PURE__ */ jsx(SidebarAddDriveItem, { onClick: onAddDriveClick })
1604
+ ]
1605
+ }
1606
+ )
1607
+ }
1608
+ );
1609
+ }
1610
+ function Root() {
1611
+ useLoadInitialData();
1612
+ useNodeNavigation();
1613
+ const navigate = useNavigate();
1614
+ const { login } = useLogin();
1615
+ useEffect(() => {
1616
+ var _a;
1617
+ (_a = window.electronAPI) == null ? void 0 : _a.ready();
1618
+ }, []);
1619
+ const [searchParams, setSearchParams] = useSearchParams();
1620
+ useEffect(() => {
1621
+ const userStr = searchParams.get("user");
1622
+ if (userStr && login) {
1623
+ const userDid = decodeURIComponent(userStr);
1624
+ searchParams.delete("user");
1625
+ setSearchParams(searchParams);
1626
+ login(userDid).catch(logger.error);
1627
+ }
1628
+ }, [login, searchParams, setSearchParams]);
1629
+ useEffect(() => {
1630
+ var _a;
1631
+ const unsubscribe = (_a = window.electronAPI) == null ? void 0 : _a.handleURL((_e, url) => {
1632
+ navigate(`/${url}`);
1633
+ });
1634
+ return unsubscribe;
1635
+ }, [navigate]);
1636
+ return /* @__PURE__ */ jsx(ModalManager, { children: /* @__PURE__ */ jsxs("div", { className: "h-screen", children: [
1637
+ isElectron && /* @__PURE__ */ jsxs(
1638
+ "div",
1639
+ {
1640
+ className: `h-8 w-full
1641
+ ${isMac && "justify-center"}
1642
+ flex items-center bg-gray-50`,
1643
+ children: [
1644
+ /* @__PURE__ */ jsx(SvgLogo, { className: "ml-1 mr-0.5 p-1.5" }),
1645
+ /* @__PURE__ */ jsx(SvgConnect, { className: "h-3 w-fit" })
1646
+ ]
1647
+ }
1648
+ ),
1649
+ /* @__PURE__ */ jsx(
1650
+ "div",
1651
+ {
1652
+ className: `flex items-stretch overflow-auto
1653
+ ${isElectron ? "h-app-height" : "h-screen"}
1654
+ `,
1655
+ role: "presentation",
1656
+ tabIndex: 0,
1657
+ children: /* @__PURE__ */ jsxs(Suspense, { children: [
1658
+ /* @__PURE__ */ jsx(Sidebar, {}),
1659
+ /* @__PURE__ */ jsx("div", { className: "relative flex-1 overflow-auto", children: /* @__PURE__ */ jsx(Outlet, {}) })
1660
+ ] })
1661
+ }
1662
+ )
1663
+ ] }) });
1664
+ }
1665
+ const ReloadConnectToast = () => {
1666
+ const { t: t2 } = useTranslation();
1667
+ return /* @__PURE__ */ jsxs("div", { children: [
1668
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: t2("notifications.reloadApp") }),
1669
+ /* @__PURE__ */ jsxs(
1670
+ "button",
1671
+ {
1672
+ onClick: () => location.reload(),
1673
+ className: "underline decoration-solid underline-offset-2",
1674
+ children: [
1675
+ t2("common.reloadConnect"),
1676
+ " 🔄"
1677
+ ]
1678
+ }
1679
+ )
1680
+ ] });
1681
+ };
1682
+ function getDriveIcon(driveNode) {
1683
+ if (driveNode.icon) {
1684
+ return /* @__PURE__ */ jsx(
1685
+ "img",
1686
+ {
1687
+ src: driveNode.icon,
1688
+ alt: driveNode.name,
1689
+ height: 32,
1690
+ width: 32
1691
+ }
1692
+ );
1693
+ }
1694
+ if (driveNode.sharingType === "LOCAL") {
1695
+ return /* @__PURE__ */ jsx(Icon, { name: "Hdd", size: 32 });
1696
+ } else {
1697
+ return /* @__PURE__ */ jsx(Icon, { name: "Server", size: 32 });
1698
+ }
1699
+ }
1700
+ function Home() {
1701
+ const getAppDescriptionForEditorId = useGetAppNameForEditorId();
1702
+ const showAddDriveModal = useShowAddDriveModal();
1703
+ const { documentDrives } = useDocumentDriveServer();
1704
+ const { driveNodes, setSelectedNode } = useUiNodesContext();
1705
+ const [config] = useConnectConfig();
1706
+ const handleDriveClick = useCallback(
1707
+ (driveNode) => {
1708
+ setSelectedNode(driveNode);
1709
+ },
1710
+ [setSelectedNode]
1711
+ );
1712
+ const onAddDriveClick = useCallback(() => {
1713
+ showAddDriveModal();
1714
+ }, [showAddDriveModal]);
1715
+ return /* @__PURE__ */ jsxs(HomeScreen, { children: [
1716
+ driveNodes.map((driveNode) => {
1717
+ var _a;
1718
+ const drive = documentDrives.find((d) => d.id === driveNode.id);
1719
+ const editorId = (_a = drive == null ? void 0 : drive.meta) == null ? void 0 : _a.preferredEditor;
1720
+ const appName = editorId ? getAppDescriptionForEditorId(editorId) : void 0;
1721
+ return /* @__PURE__ */ jsx(
1722
+ HomeScreenItem,
1723
+ {
1724
+ title: driveNode.name,
1725
+ description: appName || "Drive Explorer App",
1726
+ icon: getDriveIcon(driveNode),
1727
+ onClick: () => handleDriveClick(driveNode)
1728
+ },
1729
+ driveNode.id
1730
+ );
1731
+ }),
1732
+ config.drives.addDriveEnabled && /* @__PURE__ */ jsx(HomeScreenAddDriveItem, { onClick: onAddDriveClick })
1733
+ ] });
1734
+ }
1735
+ const Content = React__default.lazy(() => __vitePreload(() => import("./content-ChtzAUHq.js"), true ? __vite__mapDeps([0,1,2,3,4,5]) : void 0));
1736
+ async function createRouter(routes2) {
1737
+ var _a;
1738
+ const isPackaged = await ((_a = window.electronAPI) == null ? void 0 : _a.isPackaged());
1739
+ const createRouter2 = isPackaged ? createMemoryRouter : createBrowserRouter;
1740
+ return createRouter2(routes2, {
1741
+ basename: connectConfig.routerBasename,
1742
+ future: {
1743
+ v7_fetcherPersist: true,
1744
+ v7_relativeSplatPath: true
1745
+ }
1746
+ });
1747
+ }
1748
+ function createRoutes() {
1749
+ const routes2 = [
1750
+ {
1751
+ path: "/",
1752
+ element: /* @__PURE__ */ jsx(Home, {})
1753
+ },
1754
+ {
1755
+ path: "d?/:driveId?/*?",
1756
+ element: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Content, {}) })
1757
+ },
1758
+ {
1759
+ path: "import/:documentId",
1760
+ element: /* @__PURE__ */ jsx(AtlasImport, {})
1761
+ }
1762
+ ];
1763
+ return [
1764
+ {
1765
+ path: "/",
1766
+ element: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Root, {}) }),
1767
+ children: routes2
1768
+ },
1769
+ {
1770
+ element: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Root, {}) })
1771
+ }
1772
+ ];
1773
+ }
1774
+ const routes = createRoutes();
1775
+ const RouterAsync = async () => {
1776
+ const router2 = await createRouter(routes);
1777
+ const Router2 = () => /* @__PURE__ */ jsx(RouterProvider, { router: router2 });
1778
+ return Router2;
1779
+ };
1780
+ const router = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1781
+ __proto__: null,
1782
+ default: RouterAsync
1783
+ }, Symbol.toStringTag, { value: "Module" }));
1784
+ export {
1785
+ ENSAvatar as E,
1786
+ ErrorBoundary as a,
1787
+ router as r,
1788
+ toast as t,
1789
+ useSwitchboard as u
1790
+ };
1791
+ //# sourceMappingURL=router-DocwpreM.js.map