@powerhousedao/connect 1.0.19-staging.0 → 1.0.20-dev.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 (34) hide show
  1. package/dist/.env +1 -1
  2. package/dist/assets/{app-B0t4z_0j.js → app-DULISSV9.js} +8719 -3619
  3. package/dist/assets/app-DULISSV9.js.map +1 -0
  4. package/dist/assets/{app-CDOWlDp2.css → app-b1jkE5Vo.css} +115 -0
  5. package/dist/assets/{app-loader-DiF8OhX3.css → app-loader-B74nopv_.css} +130 -0
  6. package/dist/assets/{app-loader-C-1MIlBU.js → app-loader-CS6aHo9m.js} +508 -247
  7. package/dist/assets/app-loader-CS6aHo9m.js.map +1 -0
  8. package/dist/assets/browser-ClaMQmoS.js +27234 -0
  9. package/dist/assets/browser-ClaMQmoS.js.map +1 -0
  10. package/dist/assets/{ccip-CiyFdT-G.js → ccip-HqktEv5j.js} +4 -3
  11. package/dist/assets/ccip-HqktEv5j.js.map +1 -0
  12. package/dist/assets/{content-DhAAoiTj.js → content-CwQswwKt.js} +1040 -373
  13. package/dist/assets/content-CwQswwKt.js.map +1 -0
  14. package/dist/assets/{index-D-cXDDE0.js → index-4Y8IZCoL.js} +4 -3
  15. package/dist/assets/index-4Y8IZCoL.js.map +1 -0
  16. package/dist/assets/{index-DMkr0pEM.js → index-DzXmrci3.js} +4 -3
  17. package/dist/assets/index-DzXmrci3.js.map +1 -0
  18. package/dist/assets/{index-BYJBV0RH.js → index-q1LnGFn2.js} +23 -17
  19. package/dist/assets/index-q1LnGFn2.js.map +1 -0
  20. package/dist/assets/{main.DTarSVWp.js → main.uPY9aYSk.js} +2 -1
  21. package/dist/assets/main.uPY9aYSk.js.map +1 -0
  22. package/dist/assets/reactor-analytics-C3XNgGME.js +15 -0
  23. package/dist/assets/reactor-analytics-C3XNgGME.js.map +1 -0
  24. package/dist/assets/router-CvCplkfB.js +2178 -0
  25. package/dist/assets/router-CvCplkfB.js.map +1 -0
  26. package/dist/external-packages.js +1 -0
  27. package/dist/external-packages.js.map +1 -0
  28. package/dist/hmr.js +1 -0
  29. package/dist/hmr.js.map +1 -0
  30. package/dist/index.html +1 -1
  31. package/dist/service-worker.js +1 -0
  32. package/dist/service-worker.js.map +1 -0
  33. package/dist/vite-envs.sh +1 -1
  34. package/package.json +10 -9
@@ -0,0 +1,2178 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/content-CwQswwKt.js","assets/app-DULISSV9.js","assets/main.uPY9aYSk.js","assets/app-loader-CS6aHo9m.js","assets/app-loader-B74nopv_.css","assets/app-b1jkE5Vo.css"])))=>i.map(i=>d[i]);
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
9
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
+ var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a;
11
+ import { _ as __vitePreload } from "./main.uPY9aYSk.js";
12
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
13
+ import { $ as Icon, _ as logger, a1 as LOCAL, aB as FILE, aR as DRIVE, aY as gql, aZ as request, ah as connectConfig } from "./app-loader-CS6aHo9m.js";
14
+ import * as React from "react";
15
+ import React__default, { useRef, useState, useEffect, useCallback, useContext, useSyncExternalStore, useMemo, Component, createElement, createContext, Suspense } from "react";
16
+ import * as ReactDOM from "react-dom";
17
+ import { P as Popover, a as PopoverTrigger, b as PopoverContent, t as twMerge, B as Button, g as getEnsAvatar$1, c as getEnsName$1, d as BaseError$1, W as WagmiContext, S as Subscribable, p as pendingThenable, r as resolveEnabled, s as shallowEqualObjects, e as resolveStaleTime, n as noop$1, i as isServer, f as isValidTimeout, h as timeUntilStale, j as focusManager, k as fetchState, l as replaceData, m as notifyManager, u as useQueryClient, o as useDocumentDriveServer, q as createRouter$1, v as createBrowserHistory, w as logV6DeprecationWarnings, D as DataRouterContext, x as DataRouterStateContext, R as Router, E as ErrorResponseImpl, y as useRoutesImpl, z as mapRouteProperties, A as useLocation, C as useNavigate, F as useTranslation, G as useUiNodes, H as useDocumentDrives, I as useReadModeContext, J as useAsyncReactor, K as useConnectConfig, L as SUCCESS, M as toast, N as CONFLICT, O as ERROR, Q as isLatestVersion, T as useParams, U as useUiNodesContext, V as useUnwrappedReactor, X as useModal, Y as useLogin, Z as ModalManager, _ as isElectron, $ as isMac, a0 as Outlet, a1 as useGetAppNameForEditorId, a2 as createMemoryRouter } from "./app-DULISSV9.js";
18
+ const AccountPopover = ({ children, content }) => {
19
+ 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 })] });
20
+ };
21
+ function SidebarHeader({ className, ...props }) {
22
+ return jsx("div", { className: twMerge("shrink-0", className), ...props });
23
+ }
24
+ function SidebarFooter({ className, ...props }) {
25
+ return jsx("div", { className: twMerge("shrink-0", className), ...props });
26
+ }
27
+ const Sidebar$1 = ({ maxWidth = "304px", minWidth = "80px", className, children, ...props }) => {
28
+ const ref = useRef(null);
29
+ return jsx("div", { ...props, className: twMerge(`group flex h-full flex-col bg-slate-50`, className), ref, style: {
30
+ width: minWidth
31
+ }, children });
32
+ };
33
+ function SidebarPanel({ className, children, ...props }) {
34
+ const [hasScroll, setHasScroll] = useState(false);
35
+ function checkContentScroll(target) {
36
+ setHasScroll(target.scrollHeight - target.scrollTop - target.clientHeight > 1);
37
+ }
38
+ const containerRef = useRef(null);
39
+ useEffect(() => {
40
+ if (!containerRef.current) {
41
+ return;
42
+ }
43
+ const observer = new ResizeObserver((entries) => {
44
+ const entry = entries.pop();
45
+ if (!entry) {
46
+ return;
47
+ }
48
+ const { target } = entry;
49
+ checkContentScroll(target);
50
+ });
51
+ observer.observe(containerRef.current);
52
+ return () => {
53
+ observer.disconnect();
54
+ };
55
+ }, [containerRef.current]);
56
+ 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: {
57
+ boxShadow: "inset 0px -33px 32px -16px rgba(0,0,0,0.1)"
58
+ } }) : null] });
59
+ }
60
+ const AccountPopoverLogin = ({ onLogin }) => {
61
+ const [loading, setLoading] = useState(false);
62
+ const content = loading ? jsx(Icon, { name: "Reload", size: 14, className: "animate-spin" }) : jsx("span", { children: "Connect" });
63
+ const handleLogin = () => {
64
+ setLoading(true);
65
+ onLogin();
66
+ };
67
+ 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 })] });
68
+ };
69
+ const shortAddress = (address) => `${address.slice(0, 7)}...${address.slice(-5)}`;
70
+ const AccountPopoverUser = ({ address, onDisconnect, etherscanUrl, username = "" }) => {
71
+ const [isCopied, setIsCopied] = useState(false);
72
+ const copyToClipboard = useCallback(async (text) => {
73
+ try {
74
+ await navigator.clipboard.writeText(text);
75
+ setIsCopied(true);
76
+ setTimeout(() => setIsCopied(false), 2e3);
77
+ } catch (err) {
78
+ console.error("Failed to copy address:", err);
79
+ }
80
+ }, []);
81
+ 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"] }) })] });
82
+ };
83
+ const ImgPowerhouse = "/assets/powerhouse-rounded-CeKGGUG4.png";
84
+ function getAction(client, actionFn, name) {
85
+ const action_implicit = client[actionFn.name];
86
+ if (typeof action_implicit === "function")
87
+ return action_implicit;
88
+ const action_explicit = client[name];
89
+ if (typeof action_explicit === "function")
90
+ return action_explicit;
91
+ return (params) => actionFn(client, params);
92
+ }
93
+ function getChainId(config) {
94
+ return config.state.chainId;
95
+ }
96
+ function getEnsAvatar(config, parameters) {
97
+ const { chainId, ...rest } = parameters;
98
+ const client = config.getClient({ chainId });
99
+ const action = getAction(client, getEnsAvatar$1, "getEnsAvatar");
100
+ return action(rest);
101
+ }
102
+ function getEnsName(config, parameters) {
103
+ const { chainId, ...rest } = parameters;
104
+ const client = config.getClient({ chainId });
105
+ const action = getAction(client, getEnsName$1, "getEnsName");
106
+ return action(rest);
107
+ }
108
+ function watchChainId(config, parameters) {
109
+ const { onChange } = parameters;
110
+ return config.subscribe((state) => state.chainId, onChange);
111
+ }
112
+ const version = "2.14.15";
113
+ const getVersion = () => `wagmi@${version}`;
114
+ class BaseError extends BaseError$1 {
115
+ constructor() {
116
+ super(...arguments);
117
+ Object.defineProperty(this, "name", {
118
+ enumerable: true,
119
+ configurable: true,
120
+ writable: true,
121
+ value: "WagmiError"
122
+ });
123
+ }
124
+ get docsBaseUrl() {
125
+ return "https://wagmi.sh/react";
126
+ }
127
+ get version() {
128
+ return getVersion();
129
+ }
130
+ }
131
+ class WagmiProviderNotFoundError extends BaseError {
132
+ constructor() {
133
+ super("`useConfig` must be used within `WagmiProvider`.", {
134
+ docsPath: "/api/WagmiProvider"
135
+ });
136
+ Object.defineProperty(this, "name", {
137
+ enumerable: true,
138
+ configurable: true,
139
+ writable: true,
140
+ value: "WagmiProviderNotFoundError"
141
+ });
142
+ }
143
+ }
144
+ function useConfig(parameters = {}) {
145
+ const config = parameters.config ?? useContext(WagmiContext);
146
+ if (!config)
147
+ throw new WagmiProviderNotFoundError();
148
+ return config;
149
+ }
150
+ var QueryObserver = (_a = class extends Subscribable {
151
+ constructor(client, options) {
152
+ super();
153
+ __privateAdd(this, _QueryObserver_instances);
154
+ __privateAdd(this, _client);
155
+ __privateAdd(this, _currentQuery);
156
+ __privateAdd(this, _currentQueryInitialState);
157
+ __privateAdd(this, _currentResult);
158
+ __privateAdd(this, _currentResultState);
159
+ __privateAdd(this, _currentResultOptions);
160
+ __privateAdd(this, _currentThenable);
161
+ __privateAdd(this, _selectError);
162
+ __privateAdd(this, _selectFn);
163
+ __privateAdd(this, _selectResult);
164
+ // This property keeps track of the last query with defined data.
165
+ // It will be used to pass the previous data and query to the placeholder function between renders.
166
+ __privateAdd(this, _lastQueryWithDefinedData);
167
+ __privateAdd(this, _staleTimeoutId);
168
+ __privateAdd(this, _refetchIntervalId);
169
+ __privateAdd(this, _currentRefetchInterval);
170
+ __privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
171
+ this.options = options;
172
+ __privateSet(this, _client, client);
173
+ __privateSet(this, _selectError, null);
174
+ __privateSet(this, _currentThenable, pendingThenable());
175
+ if (!this.options.experimental_prefetchInRender) {
176
+ __privateGet(this, _currentThenable).reject(
177
+ new Error("experimental_prefetchInRender feature flag is not enabled")
178
+ );
179
+ }
180
+ this.bindMethods();
181
+ this.setOptions(options);
182
+ }
183
+ bindMethods() {
184
+ this.refetch = this.refetch.bind(this);
185
+ }
186
+ onSubscribe() {
187
+ if (this.listeners.size === 1) {
188
+ __privateGet(this, _currentQuery).addObserver(this);
189
+ if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
190
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
191
+ } else {
192
+ this.updateResult();
193
+ }
194
+ __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
195
+ }
196
+ }
197
+ onUnsubscribe() {
198
+ if (!this.hasListeners()) {
199
+ this.destroy();
200
+ }
201
+ }
202
+ shouldFetchOnReconnect() {
203
+ return shouldFetchOn(
204
+ __privateGet(this, _currentQuery),
205
+ this.options,
206
+ this.options.refetchOnReconnect
207
+ );
208
+ }
209
+ shouldFetchOnWindowFocus() {
210
+ return shouldFetchOn(
211
+ __privateGet(this, _currentQuery),
212
+ this.options,
213
+ this.options.refetchOnWindowFocus
214
+ );
215
+ }
216
+ destroy() {
217
+ this.listeners = /* @__PURE__ */ new Set();
218
+ __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
219
+ __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
220
+ __privateGet(this, _currentQuery).removeObserver(this);
221
+ }
222
+ setOptions(options) {
223
+ const prevOptions = this.options;
224
+ const prevQuery = __privateGet(this, _currentQuery);
225
+ this.options = __privateGet(this, _client).defaultQueryOptions(options);
226
+ if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
227
+ throw new Error(
228
+ "Expected enabled to be a boolean or a callback that returns a boolean"
229
+ );
230
+ }
231
+ __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
232
+ __privateGet(this, _currentQuery).setOptions(this.options);
233
+ if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
234
+ __privateGet(this, _client).getQueryCache().notify({
235
+ type: "observerOptionsUpdated",
236
+ query: __privateGet(this, _currentQuery),
237
+ observer: this
238
+ });
239
+ }
240
+ const mounted = this.hasListeners();
241
+ if (mounted && shouldFetchOptionally(
242
+ __privateGet(this, _currentQuery),
243
+ prevQuery,
244
+ this.options,
245
+ prevOptions
246
+ )) {
247
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
248
+ }
249
+ this.updateResult();
250
+ if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
251
+ __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
252
+ }
253
+ const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
254
+ if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
255
+ __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
256
+ }
257
+ }
258
+ getOptimisticResult(options) {
259
+ const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options);
260
+ const result = this.createResult(query, options);
261
+ if (shouldAssignObserverCurrentProperties(this, result)) {
262
+ __privateSet(this, _currentResult, result);
263
+ __privateSet(this, _currentResultOptions, this.options);
264
+ __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
265
+ }
266
+ return result;
267
+ }
268
+ getCurrentResult() {
269
+ return __privateGet(this, _currentResult);
270
+ }
271
+ trackResult(result, onPropTracked) {
272
+ const trackedResult = {};
273
+ Object.keys(result).forEach((key) => {
274
+ Object.defineProperty(trackedResult, key, {
275
+ configurable: false,
276
+ enumerable: true,
277
+ get: () => {
278
+ this.trackProp(key);
279
+ onPropTracked == null ? void 0 : onPropTracked(key);
280
+ return result[key];
281
+ }
282
+ });
283
+ });
284
+ return trackedResult;
285
+ }
286
+ trackProp(key) {
287
+ __privateGet(this, _trackedProps).add(key);
288
+ }
289
+ getCurrentQuery() {
290
+ return __privateGet(this, _currentQuery);
291
+ }
292
+ refetch({ ...options } = {}) {
293
+ return this.fetch({
294
+ ...options
295
+ });
296
+ }
297
+ fetchOptimistic(options) {
298
+ const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
299
+ const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
300
+ return query.fetch().then(() => this.createResult(query, defaultedOptions));
301
+ }
302
+ fetch(fetchOptions) {
303
+ return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
304
+ ...fetchOptions,
305
+ cancelRefetch: fetchOptions.cancelRefetch ?? true
306
+ }).then(() => {
307
+ this.updateResult();
308
+ return __privateGet(this, _currentResult);
309
+ });
310
+ }
311
+ createResult(query, options) {
312
+ var _a2;
313
+ const prevQuery = __privateGet(this, _currentQuery);
314
+ const prevOptions = this.options;
315
+ const prevResult = __privateGet(this, _currentResult);
316
+ const prevResultState = __privateGet(this, _currentResultState);
317
+ const prevResultOptions = __privateGet(this, _currentResultOptions);
318
+ const queryChange = query !== prevQuery;
319
+ const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
320
+ const { state } = query;
321
+ let newState = { ...state };
322
+ let isPlaceholderData = false;
323
+ let data;
324
+ if (options._optimisticResults) {
325
+ const mounted = this.hasListeners();
326
+ const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
327
+ const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
328
+ if (fetchOnMount || fetchOptionally) {
329
+ newState = {
330
+ ...newState,
331
+ ...fetchState(state.data, query.options)
332
+ };
333
+ }
334
+ if (options._optimisticResults === "isRestoring") {
335
+ newState.fetchStatus = "idle";
336
+ }
337
+ }
338
+ let { error, errorUpdatedAt, status } = newState;
339
+ if (options.select && newState.data !== void 0) {
340
+ if (prevResult && newState.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === __privateGet(this, _selectFn)) {
341
+ data = __privateGet(this, _selectResult);
342
+ } else {
343
+ try {
344
+ __privateSet(this, _selectFn, options.select);
345
+ data = options.select(newState.data);
346
+ data = replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
347
+ __privateSet(this, _selectResult, data);
348
+ __privateSet(this, _selectError, null);
349
+ } catch (selectError) {
350
+ __privateSet(this, _selectError, selectError);
351
+ }
352
+ }
353
+ } else {
354
+ data = newState.data;
355
+ }
356
+ if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
357
+ let placeholderData;
358
+ if ((prevResult == null ? void 0 : prevResult.isPlaceholderData) && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
359
+ placeholderData = prevResult.data;
360
+ } else {
361
+ placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
362
+ (_a2 = __privateGet(this, _lastQueryWithDefinedData)) == null ? void 0 : _a2.state.data,
363
+ __privateGet(this, _lastQueryWithDefinedData)
364
+ ) : options.placeholderData;
365
+ if (options.select && placeholderData !== void 0) {
366
+ try {
367
+ placeholderData = options.select(placeholderData);
368
+ __privateSet(this, _selectError, null);
369
+ } catch (selectError) {
370
+ __privateSet(this, _selectError, selectError);
371
+ }
372
+ }
373
+ }
374
+ if (placeholderData !== void 0) {
375
+ status = "success";
376
+ data = replaceData(
377
+ prevResult == null ? void 0 : prevResult.data,
378
+ placeholderData,
379
+ options
380
+ );
381
+ isPlaceholderData = true;
382
+ }
383
+ }
384
+ if (__privateGet(this, _selectError)) {
385
+ error = __privateGet(this, _selectError);
386
+ data = __privateGet(this, _selectResult);
387
+ errorUpdatedAt = Date.now();
388
+ status = "error";
389
+ }
390
+ const isFetching = newState.fetchStatus === "fetching";
391
+ const isPending = status === "pending";
392
+ const isError = status === "error";
393
+ const isLoading = isPending && isFetching;
394
+ const hasData = data !== void 0;
395
+ const result = {
396
+ status,
397
+ fetchStatus: newState.fetchStatus,
398
+ isPending,
399
+ isSuccess: status === "success",
400
+ isError,
401
+ isInitialLoading: isLoading,
402
+ isLoading,
403
+ data,
404
+ dataUpdatedAt: newState.dataUpdatedAt,
405
+ error,
406
+ errorUpdatedAt,
407
+ failureCount: newState.fetchFailureCount,
408
+ failureReason: newState.fetchFailureReason,
409
+ errorUpdateCount: newState.errorUpdateCount,
410
+ isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
411
+ isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
412
+ isFetching,
413
+ isRefetching: isFetching && !isPending,
414
+ isLoadingError: isError && !hasData,
415
+ isPaused: newState.fetchStatus === "paused",
416
+ isPlaceholderData,
417
+ isRefetchError: isError && hasData,
418
+ isStale: isStale(query, options),
419
+ refetch: this.refetch,
420
+ promise: __privateGet(this, _currentThenable)
421
+ };
422
+ const nextResult = result;
423
+ if (this.options.experimental_prefetchInRender) {
424
+ const finalizeThenableIfPossible = (thenable) => {
425
+ if (nextResult.status === "error") {
426
+ thenable.reject(nextResult.error);
427
+ } else if (nextResult.data !== void 0) {
428
+ thenable.resolve(nextResult.data);
429
+ }
430
+ };
431
+ const recreateThenable = () => {
432
+ const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
433
+ finalizeThenableIfPossible(pending);
434
+ };
435
+ const prevThenable = __privateGet(this, _currentThenable);
436
+ switch (prevThenable.status) {
437
+ case "pending":
438
+ if (query.queryHash === prevQuery.queryHash) {
439
+ finalizeThenableIfPossible(prevThenable);
440
+ }
441
+ break;
442
+ case "fulfilled":
443
+ if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
444
+ recreateThenable();
445
+ }
446
+ break;
447
+ case "rejected":
448
+ if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
449
+ recreateThenable();
450
+ }
451
+ break;
452
+ }
453
+ }
454
+ return nextResult;
455
+ }
456
+ updateResult() {
457
+ const prevResult = __privateGet(this, _currentResult);
458
+ const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
459
+ __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
460
+ __privateSet(this, _currentResultOptions, this.options);
461
+ if (__privateGet(this, _currentResultState).data !== void 0) {
462
+ __privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
463
+ }
464
+ if (shallowEqualObjects(nextResult, prevResult)) {
465
+ return;
466
+ }
467
+ __privateSet(this, _currentResult, nextResult);
468
+ const shouldNotifyListeners = () => {
469
+ if (!prevResult) {
470
+ return true;
471
+ }
472
+ const { notifyOnChangeProps } = this.options;
473
+ const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
474
+ if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
475
+ return true;
476
+ }
477
+ const includedProps = new Set(
478
+ notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
479
+ );
480
+ if (this.options.throwOnError) {
481
+ includedProps.add("error");
482
+ }
483
+ return Object.keys(__privateGet(this, _currentResult)).some((key) => {
484
+ const typedKey = key;
485
+ const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
486
+ return changed && includedProps.has(typedKey);
487
+ });
488
+ };
489
+ __privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
490
+ }
491
+ onQueryUpdate() {
492
+ this.updateResult();
493
+ if (this.hasListeners()) {
494
+ __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
495
+ }
496
+ }
497
+ }, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
498
+ __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
499
+ let promise = __privateGet(this, _currentQuery).fetch(
500
+ this.options,
501
+ fetchOptions
502
+ );
503
+ if (!(fetchOptions == null ? void 0 : fetchOptions.throwOnError)) {
504
+ promise = promise.catch(noop$1);
505
+ }
506
+ return promise;
507
+ }, updateStaleTimeout_fn = function() {
508
+ __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
509
+ const staleTime = resolveStaleTime(
510
+ this.options.staleTime,
511
+ __privateGet(this, _currentQuery)
512
+ );
513
+ if (isServer || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
514
+ return;
515
+ }
516
+ const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
517
+ const timeout = time + 1;
518
+ __privateSet(this, _staleTimeoutId, setTimeout(() => {
519
+ if (!__privateGet(this, _currentResult).isStale) {
520
+ this.updateResult();
521
+ }
522
+ }, timeout));
523
+ }, computeRefetchInterval_fn = function() {
524
+ return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
525
+ }, updateRefetchInterval_fn = function(nextInterval) {
526
+ __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
527
+ __privateSet(this, _currentRefetchInterval, nextInterval);
528
+ if (isServer || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
529
+ return;
530
+ }
531
+ __privateSet(this, _refetchIntervalId, setInterval(() => {
532
+ if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
533
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
534
+ }
535
+ }, __privateGet(this, _currentRefetchInterval)));
536
+ }, updateTimers_fn = function() {
537
+ __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
538
+ __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
539
+ }, clearStaleTimeout_fn = function() {
540
+ if (__privateGet(this, _staleTimeoutId)) {
541
+ clearTimeout(__privateGet(this, _staleTimeoutId));
542
+ __privateSet(this, _staleTimeoutId, void 0);
543
+ }
544
+ }, clearRefetchInterval_fn = function() {
545
+ if (__privateGet(this, _refetchIntervalId)) {
546
+ clearInterval(__privateGet(this, _refetchIntervalId));
547
+ __privateSet(this, _refetchIntervalId, void 0);
548
+ }
549
+ }, updateQuery_fn = function() {
550
+ const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
551
+ if (query === __privateGet(this, _currentQuery)) {
552
+ return;
553
+ }
554
+ const prevQuery = __privateGet(this, _currentQuery);
555
+ __privateSet(this, _currentQuery, query);
556
+ __privateSet(this, _currentQueryInitialState, query.state);
557
+ if (this.hasListeners()) {
558
+ prevQuery == null ? void 0 : prevQuery.removeObserver(this);
559
+ query.addObserver(this);
560
+ }
561
+ }, notify_fn = function(notifyOptions) {
562
+ notifyManager.batch(() => {
563
+ if (notifyOptions.listeners) {
564
+ this.listeners.forEach((listener) => {
565
+ listener(__privateGet(this, _currentResult));
566
+ });
567
+ }
568
+ __privateGet(this, _client).getQueryCache().notify({
569
+ query: __privateGet(this, _currentQuery),
570
+ type: "observerResultsUpdated"
571
+ });
572
+ });
573
+ }, _a);
574
+ function shouldLoadOnMount(query, options) {
575
+ return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
576
+ }
577
+ function shouldFetchOnMount(query, options) {
578
+ return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
579
+ }
580
+ function shouldFetchOn(query, options, field) {
581
+ if (resolveEnabled(options.enabled, query) !== false) {
582
+ const value = typeof field === "function" ? field(query) : field;
583
+ return value === "always" || value !== false && isStale(query, options);
584
+ }
585
+ return false;
586
+ }
587
+ function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
588
+ return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
589
+ }
590
+ function isStale(query, options) {
591
+ return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
592
+ }
593
+ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
594
+ if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
595
+ return true;
596
+ }
597
+ return false;
598
+ }
599
+ function hashFn(queryKey) {
600
+ return JSON.stringify(queryKey, (_, value) => {
601
+ if (isPlainObject(value))
602
+ return Object.keys(value).sort().reduce((result, key) => {
603
+ result[key] = value[key];
604
+ return result;
605
+ }, {});
606
+ if (typeof value === "bigint")
607
+ return value.toString();
608
+ return value;
609
+ });
610
+ }
611
+ function isPlainObject(value) {
612
+ if (!hasObjectPrototype(value)) {
613
+ return false;
614
+ }
615
+ const ctor = value.constructor;
616
+ if (typeof ctor === "undefined")
617
+ return true;
618
+ const prot = ctor.prototype;
619
+ if (!hasObjectPrototype(prot))
620
+ return false;
621
+ if (!prot.hasOwnProperty("isPrototypeOf"))
622
+ return false;
623
+ return true;
624
+ }
625
+ function hasObjectPrototype(o) {
626
+ return Object.prototype.toString.call(o) === "[object Object]";
627
+ }
628
+ function filterQueryOptions(options) {
629
+ const {
630
+ // import('@tanstack/query-core').QueryOptions
631
+ _defaulted,
632
+ behavior,
633
+ gcTime,
634
+ initialData,
635
+ initialDataUpdatedAt,
636
+ maxPages,
637
+ meta,
638
+ networkMode,
639
+ queryFn,
640
+ queryHash,
641
+ queryKey,
642
+ queryKeyHashFn,
643
+ retry,
644
+ retryDelay,
645
+ structuralSharing,
646
+ // import('@tanstack/query-core').InfiniteQueryObserverOptions
647
+ getPreviousPageParam,
648
+ getNextPageParam,
649
+ initialPageParam,
650
+ // import('@tanstack/react-query').UseQueryOptions
651
+ _optimisticResults,
652
+ enabled,
653
+ notifyOnChangeProps,
654
+ placeholderData,
655
+ refetchInterval,
656
+ refetchIntervalInBackground,
657
+ refetchOnMount,
658
+ refetchOnReconnect,
659
+ refetchOnWindowFocus,
660
+ retryOnMount,
661
+ select,
662
+ staleTime,
663
+ suspense,
664
+ throwOnError,
665
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
666
+ // wagmi
667
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
668
+ config,
669
+ connector,
670
+ query,
671
+ ...rest
672
+ } = options;
673
+ return rest;
674
+ }
675
+ function getEnsAvatarQueryOptions(config, options = {}) {
676
+ return {
677
+ async queryFn({ queryKey }) {
678
+ const { name, scopeKey: _, ...parameters } = queryKey[1];
679
+ if (!name)
680
+ throw new Error("name is required");
681
+ return getEnsAvatar(config, { ...parameters, name });
682
+ },
683
+ queryKey: getEnsAvatarQueryKey(options)
684
+ };
685
+ }
686
+ function getEnsAvatarQueryKey(options = {}) {
687
+ return ["ensAvatar", filterQueryOptions(options)];
688
+ }
689
+ function getEnsNameQueryOptions(config, options = {}) {
690
+ return {
691
+ async queryFn({ queryKey }) {
692
+ const { address, scopeKey: _, ...parameters } = queryKey[1];
693
+ if (!address)
694
+ throw new Error("address is required");
695
+ return getEnsName(config, { ...parameters, address });
696
+ },
697
+ queryKey: getEnsNameQueryKey(options)
698
+ };
699
+ }
700
+ function getEnsNameQueryKey(options = {}) {
701
+ return ["ensName", filterQueryOptions(options)];
702
+ }
703
+ var IsRestoringContext = React.createContext(false);
704
+ var useIsRestoring = () => React.useContext(IsRestoringContext);
705
+ IsRestoringContext.Provider;
706
+ function createValue() {
707
+ let isReset = false;
708
+ return {
709
+ clearReset: () => {
710
+ isReset = false;
711
+ },
712
+ reset: () => {
713
+ isReset = true;
714
+ },
715
+ isReset: () => {
716
+ return isReset;
717
+ }
718
+ };
719
+ }
720
+ var QueryErrorResetBoundaryContext = React.createContext(createValue());
721
+ var useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
722
+ function shouldThrowError(throwError, params) {
723
+ if (typeof throwError === "function") {
724
+ return throwError(...params);
725
+ }
726
+ return !!throwError;
727
+ }
728
+ function noop() {
729
+ }
730
+ var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
731
+ if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
732
+ if (!errorResetBoundary.isReset()) {
733
+ options.retryOnMount = false;
734
+ }
735
+ }
736
+ };
737
+ var useClearResetErrorBoundary = (errorResetBoundary) => {
738
+ React.useEffect(() => {
739
+ errorResetBoundary.clearReset();
740
+ }, [errorResetBoundary]);
741
+ };
742
+ var getHasError = ({
743
+ result,
744
+ errorResetBoundary,
745
+ throwOnError,
746
+ query,
747
+ suspense
748
+ }) => {
749
+ return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
750
+ };
751
+ var ensureSuspenseTimers = (defaultedOptions) => {
752
+ const originalStaleTime = defaultedOptions.staleTime;
753
+ if (defaultedOptions.suspense) {
754
+ defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => Math.max(originalStaleTime(...args), 1e3) : Math.max(originalStaleTime ?? 1e3, 1e3);
755
+ if (typeof defaultedOptions.gcTime === "number") {
756
+ defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, 1e3);
757
+ }
758
+ }
759
+ };
760
+ var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
761
+ var shouldSuspend = (defaultedOptions, result) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && result.isPending;
762
+ var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
763
+ errorResetBoundary.clearReset();
764
+ });
765
+ function useBaseQuery(options, Observer, queryClient) {
766
+ var _a2, _b, _c, _d, _e;
767
+ const client = useQueryClient();
768
+ const isRestoring = useIsRestoring();
769
+ const errorResetBoundary = useQueryErrorResetBoundary();
770
+ const defaultedOptions = client.defaultQueryOptions(options);
771
+ (_b = (_a2 = client.getDefaultOptions().queries) == null ? void 0 : _a2._experimental_beforeQuery) == null ? void 0 : _b.call(
772
+ _a2,
773
+ defaultedOptions
774
+ );
775
+ defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
776
+ ensureSuspenseTimers(defaultedOptions);
777
+ ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
778
+ useClearResetErrorBoundary(errorResetBoundary);
779
+ const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
780
+ const [observer] = React.useState(
781
+ () => new Observer(
782
+ client,
783
+ defaultedOptions
784
+ )
785
+ );
786
+ const result = observer.getOptimisticResult(defaultedOptions);
787
+ const shouldSubscribe = !isRestoring && options.subscribed !== false;
788
+ React.useSyncExternalStore(
789
+ React.useCallback(
790
+ (onStoreChange) => {
791
+ const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
792
+ observer.updateResult();
793
+ return unsubscribe;
794
+ },
795
+ [observer, shouldSubscribe]
796
+ ),
797
+ () => observer.getCurrentResult(),
798
+ () => observer.getCurrentResult()
799
+ );
800
+ React.useEffect(() => {
801
+ observer.setOptions(defaultedOptions);
802
+ }, [defaultedOptions, observer]);
803
+ if (shouldSuspend(defaultedOptions, result)) {
804
+ throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
805
+ }
806
+ if (getHasError({
807
+ result,
808
+ errorResetBoundary,
809
+ throwOnError: defaultedOptions.throwOnError,
810
+ query: client.getQueryCache().get(defaultedOptions.queryHash),
811
+ suspense: defaultedOptions.suspense
812
+ })) {
813
+ throw result.error;
814
+ }
815
+ (_d = (_c = client.getDefaultOptions().queries) == null ? void 0 : _c._experimental_afterQuery) == null ? void 0 : _d.call(
816
+ _c,
817
+ defaultedOptions,
818
+ result
819
+ );
820
+ if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
821
+ const promise = isNewCacheEntry ? (
822
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
823
+ fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
824
+ ) : (
825
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
826
+ (_e = client.getQueryCache().get(defaultedOptions.queryHash)) == null ? void 0 : _e.promise
827
+ );
828
+ promise == null ? void 0 : promise.catch(noop).finally(() => {
829
+ observer.updateResult();
830
+ });
831
+ }
832
+ return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
833
+ }
834
+ function useQuery$1(options, queryClient) {
835
+ return useBaseQuery(options, QueryObserver);
836
+ }
837
+ function useQuery(parameters) {
838
+ const result = useQuery$1({
839
+ ...parameters,
840
+ queryKeyHashFn: hashFn
841
+ // for bigint support
842
+ });
843
+ result.queryKey = parameters.queryKey;
844
+ return result;
845
+ }
846
+ function useChainId(parameters = {}) {
847
+ const config = useConfig(parameters);
848
+ return useSyncExternalStore((onChange) => watchChainId(config, { onChange }), () => getChainId(config), () => getChainId(config));
849
+ }
850
+ function useEnsAvatar(parameters = {}) {
851
+ const { name, query = {} } = parameters;
852
+ const config = useConfig(parameters);
853
+ const chainId = useChainId({ config });
854
+ const options = getEnsAvatarQueryOptions(config, {
855
+ ...parameters,
856
+ chainId: parameters.chainId ?? chainId
857
+ });
858
+ const enabled = Boolean(name && (query.enabled ?? true));
859
+ return useQuery({ ...query, ...options, enabled });
860
+ }
861
+ function useEnsName(parameters = {}) {
862
+ const { address, query = {} } = parameters;
863
+ const config = useConfig(parameters);
864
+ const chainId = useChainId({ config });
865
+ const options = getEnsNameQueryOptions(config, {
866
+ ...parameters,
867
+ chainId: parameters.chainId ?? chainId
868
+ });
869
+ const enabled = Boolean(address && (query.enabled ?? true));
870
+ return useQuery({ ...query, ...options, enabled });
871
+ }
872
+ function ENSAvatar(props) {
873
+ const { address, chainId = 1, size = "14px" } = props;
874
+ const style = {
875
+ width: size,
876
+ height: size
877
+ };
878
+ const ensNameResult = useEnsName({ address, chainId });
879
+ const name = ensNameResult.data ?? void 0;
880
+ const ensAvatarResult = useEnsAvatar({ name });
881
+ const avatarUrl = ensAvatarResult.data ?? ImgPowerhouse;
882
+ const isLoading = ensNameResult.isLoading || ensAvatarResult.isLoading;
883
+ if (isLoading)
884
+ return jsx("div", { className: "fade-out flex-none animate-pulse rounded-full bg-gray-400", style });
885
+ return jsx("img", { alt: "ENS Avatar", className: "flex-none rounded-full object-contain", src: avatarUrl, style });
886
+ }
887
+ const HomeBg = "/assets/home-bg-BEhF9NuW.png";
888
+ const HomeScreen = function HomeScreen2(props) {
889
+ const { children, containerClassName } = props;
890
+ 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] }) });
891
+ };
892
+ const HomeScreenItem = function HomeScreenItem2(props) {
893
+ const { icon, title, description, containerClassName, shareable, onClick } = props;
894
+ 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 }) })] });
895
+ };
896
+ const HomeScreenAddDriveItem = function HomeScreenAddDriveItem2(props) {
897
+ const { containerClassName, onClick } = props;
898
+ return jsx(HomeScreenItem, { title: "Create New Drive", icon: jsx(Icon, { name: "PlusSquare", size: 32 }), onClick, containerClassName });
899
+ };
900
+ const renownShortHover = "/assets/renown-short-hover-BiSLBV7L.png";
901
+ const renownShort = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAtmSURBVHgB7Z3dbtvmGcefl5LsqHYCq0C6tEUCZ0kDzAFqd0NTYAmweAfr0YD0CrpeQboriH0H6RUsu4ChAYodtCdJD3LQBGttILEBJ4tdJ2uzBoi0yIpsi+S790+ZDkmREilSHySfX6FKpkgliH5+nuf9pKAEkFLO1Bu7VzRNzEuiWfXzglDHSIgZYsYC9b1sCaEeJFZMU66WCnS7XC5vUUwE9Qmk2dndvar+ZpetB5NCxIr6Hr+II1NkgQ7FMeTnHGGygxLhRkGj5agiRRKo3mxeY3EyjkZLR8vl5bCnhxKo2WzOGqb4UpJcCDpH1T+E/wpKY+3gU4XoO0MyCaKyhvVsqifTNNWzVM8y8Hz1rW2pr3ExTDTq+Q3vNPc/lYZ+3S/qwI+iVlDSCJYlZcgDiVqGQdLXJVGTJD47NjV5s9vndP3W6429a8rZpY6LIE6hoB4aMenHMMxgkXqktECBguSBNHhwxMkWiEgt3SRDpbgOukjka8HLxt4VQeaX3uOlIkedrKPr7WjkRWiFv0yXJ/7ecdx7AAWzbsgfnDUPgs1EsWgVykz2QTTaa+melCZqRU1+4C2sO8KJSoe3vAXzZInlyRMoTxAw3MgZXbXEvee6BELdg6EI5zGkLa538gcCRkk1lNzIhXqjseQ8cmiGlbpM2nS+WdA0migViMkvKKx1V00kavr+5OlKRdTw02EEUqnrmvNCBJ1SkQvmvFMsauROQHKmOPHqc/sn6y2/6MMtLsams2X2OgpZhrQM92h6u6OQ5WHadItCliWqSL7quqDAdQ/jpqB5nBDaH6wnv/R1ZKLILS/GBbqEdvdarmP6/pGK5k1f1qg6y8N4gBHevsBSafeKOuSeoqGxPEwAXjcwvUfVQGLedZLGxTPjj9cNKWhWw/9cJ3EAYgLwuqHaZvM4Nus+zAYxAXSkMDGj9TiHYQ7pVEP1BxEzFL6+9T3tvGrS4u/fpzcrRykrcMU8BLb/85yePa/STmOX1h49oSzBAg2BJ0qgw9dPn1OWYIEGzH5LtyKQ8+dnv1QpK7BAA2ZbRRxI42T1wSZlBRZowKw/2u44hnpov9WiLMACDRCI8qK64/ve2sZTygIs0ABZvf848L31je1MRCEWaEA82vxZRaBa4Puoi1bvp78WYoEGxOra457nrD18kvoWGQs0AFYfPLY6DcOdm+4oxAIlzE6jSSsRpEChvbaR3t5pFihBUBR/fft7isq9lY3UpjIWKEHufLceOnV1XHtvzYpeaYMFSgjUPds/9T/OBfEQvdLWtGeBEgDyrCRQDFsS3UqXRCxQTJKSx+ZFbSdVErFAMbi38jBReWwg0Vff3E1FTcQC9YHV2lJRYm1jmwaFXRONu0Si3mi69qEqT5aICQb9NnfurvXd2uqHhfO/pvnzp2kcaHpWp7JAIUHUWX2wNdCo0403Z6Zp8eL7ND1VplHCAvXBuuopXlHFsndi2Cg4O/u2FY1GJRILFBJEnEebz2j94fZQ01UYpqeO0InjlZGIxAL1ADUOJsFjOsY4RJxenHr3OJ05/Tadeuc4DQMWKAC0dtqtnvGKNmGZKBXp4oU5S6hB4hWIm/EHoO8lrfIAa/XHT8NfMsQCHXDirYqqK9J7FytEoLmzp2jYcArzgCiEqRWYUTjuEQnSWPWPSlsoqocB10ARwIJATH7vNrd5FECc35w7SXPnTlmvhwkL1AdokY1DRBqlODYsUAzQmTiqOcwnVTP90kdzIxPHhgWKSXuQ819Di0YQ5sMPzlk90OMAC5QQd1c2rCGOQYIe548v/856Hhe8AvEGU31yYeGcFR0GldLQpbB4aX7kKasXLFAMMM0CJC3RGZWuLqle5TQwcoGGUUsMMgUkLVGa5AEjF+gf/7xDwwQyTb9RpomJIlVmpg96oON1wiUlEeb8pEkekLsUhohnRz10FNpfOiRCr26/rR1IhPGofgtriL14cZ7SBtdAB2AaBx5YZXF29p2+ppBCov/+UlMDs3WKyri1tsLCg6keEJ3QYYjU+mjr50jXosWEaadRW04fLryXSnkACxQARMLk+ah1DUSYP6iJwoDmOoYm0goL1ANEI4gUhTk1XhV2asjFC+cpzbBAIUAqiypRmCiEc9KaumxYoJBAoij7+PSaoAZxxmV8Kw4sUASwj8+LavgWVrcodEa19NIefQALFBGshw9LtyiUhegDWKCIWP1FEXYT84tCGK7IQvQBqe1IxBdwJuRvcbW6Qy/+V09s3A1Ne0SXMODWTugXcq4xO3s6G9EHpFcgNZ61EKG/BSQ1NRU9zVi5OlHqPXfKnvhuD3HYq0qzQq5SGH7z//ynj2LXH+077oSfaO9cNfqrDMkDclcD2Ss4464BQy0UFqS7k+8et0bbo0bNcSe3g6noAf7qm+/6Xv8eNQ3+UY2RZZHctsKsIjxGMVvtY8Q9i+S6GR9nR4s0r6NPklwLlKW7J4+KXAs07ise0gD3RDOxyLVAadiBbNzJtUAvYrSksjKWFZdcC/TvzWhznp1gKIXJsUDYEzFKb7KXSmWamBwLtP7waay+nCwNiMYhlwJh7VfcHedPvJXe/RSTJFcdIdbCwfubsVIXwDykMFM58kBqBdp51bSW3IShgY0zlTRJDT9kaUJYXNIrkJJhFNvNofbh+uc13BMdkYsp2z1j0LBAEcjCQsCkYYFCghmMC2Ny07dxggUKgXWzt0vp27tnGPB8hh6My/7M4wr/qwQAYbDJVJq3XhkGLJAPuJ0AVk9w1OkN10A+oJeZ5QkHC+QD7tCDladMb1L7a4be4I8Xfxv4fpwbo2Cm4trGU262hyCzESjuLZE4CoUjswLZ99bqFzsKMd3JdA3EUWjwZFogjkKDJ/OtMI5CgyXzAtkbPPULR6Hu5KIfaO69eMMRHIWCyYVA7W3l+p8Ez1EomNz0RM/H3BmMo5A/uRGo187xveAo5E+uxsI4CiVPrgTiKJQ8uRuN5yiULLkTiKNQsuRyPhDulBMHjkKvyaVAWJocZ30XR6HX5HZG4pmYtzvgKNQmtwLFHWTlKNQmtwLFneoBOArlfFI9R6H4iHqjKZ0HypO8cRITTHPPHXFVBJKuG19JSQzji58amiRR630awygzTLcbgmhLE0KsOA+a7A8TgFcNKZRAZJo/Og8apkkM44fpdcOUq0hhrggkuQhiAjA9bsAdzWjt3nSdpHIYO8R4QWAxPfWNUaDbWqVSqSmVbjvf0E2DGMaJ2VFAy5VKubzV7kiU9K3zTUPnOohx0zLcTphSfIFnSyBd373u7A+Ca7rBUYhpYyh5vLUx0heeLYGsNGa2jbLRdZNrIcYSxxt9BGk3kL7arw+oVqszxYnJTXXocLpesahRqVAgJr/s64YVgZzoGp22BTocTA2KQpzK8ouuxPHKo6qfZVseILwX1Ru7P6jAteA8NqlGrDVNEJMfkLp29933lBWq53n6jbJr27aO6Ry6Jj/xDrBi2gJ3MOYHQzXZ91rezCNrLUGL3nM7BEJ4klL81XWpesBGTmfZB2nLL2BIKnzmTF02vhPKjk2Xb5BJy97jLVUToajiaJQ9rNaW+m7x6MRcPjY1edPvuq6FTb3eXFKKXeu4SCXDYkGzHkz6QdTRffp62pjLR6emloKu7VkZv3zZuCIK4m/O5v3hxQciFVSBjddMeoAsuolWlgwQR9aEKmWmkY26EOpbrzabsyVJt9SfMxt0DlppmmiLhNf4YJZqPLAFQXGMEXW/gVEnmCPWEvITv5qn41yKQFBKY7KCtPoCjx4tL4W9InKIQDQqGOaSENqnxGSEtjj69JHrFeGd4tydvnNMWyS6rMLdVW/HI5MShBoQNejbfsR5/REJcCiTJZKYl4Jm1QfPEjMmyBoWT2AOj+rQ+REzCY2pIzf7lcbJ/wH9VD8KK3ri6QAAAABJRU5ErkJggg==";
902
+ const SidebarLogin = ({ onLogin }) => {
903
+ const content = jsx(AccountPopoverLogin, { onLogin });
904
+ 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 })] }) });
905
+ };
906
+ const SidebarUser = ({ address, etherscanUrl, onDisconnect }) => {
907
+ const { data } = useEnsName({ address });
908
+ const ensName = data;
909
+ const content = jsx(AccountPopoverUser, { address, username: ensName, onDisconnect, etherscanUrl });
910
+ return jsx(AccountPopover, { content, children: jsx("div", { className: "flex items-center justify-center rounded-sm", children: jsx(ENSAvatar, { address, size: "40px" }) }) });
911
+ };
912
+ const ConnectSidebarFooter = ({ address, className, onLogin, onClickSettings, onDisconnect, etherscanUrl = "", ...props }) => {
913
+ 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" })] })] });
914
+ };
915
+ const ConnectSidebarHeader = ({ onClick, className, children, ...props }) => {
916
+ 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 }) }) });
917
+ };
918
+ const ConnectSidebar = ({ onClick, address, headerContent, onClickSettings, maxWidth = "304px", minWidth = "58px", onLogin, onDisconnect, etherscanUrl, ...props }) => {
919
+ 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 })] });
920
+ };
921
+ const SidebarItem = function SidebarItem2(props) {
922
+ const { icon, title, description, containerClassName, active, onClick } = props;
923
+ 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() }) }) }) });
924
+ };
925
+ const SidebarAddDriveItem = function SidebarAddDriveItem2(props) {
926
+ const { containerClassName, onClick } = props;
927
+ return jsx(SidebarItem, { title: "Create New Drive", icon: jsx(Icon, { name: "PlusSquare", size: 32 }), onClick, containerClassName });
928
+ };
929
+ function useSwitchboard() {
930
+ return {
931
+ getDriveIdBySlug: async (driveUrl, slug) => {
932
+ if (!driveUrl) {
933
+ return;
934
+ }
935
+ const urlParts = driveUrl.split("/");
936
+ urlParts.pop();
937
+ urlParts.pop();
938
+ urlParts.push("drives");
939
+ const drivesUrl = urlParts.join("/");
940
+ const result = await fetch(drivesUrl, {
941
+ method: "POST",
942
+ headers: {
943
+ "Content-Type": "application/json"
944
+ },
945
+ body: JSON.stringify({
946
+ query: `
947
+ query getDriveIdBySlug($slug: String!) {
948
+ driveIdBySlug(slug: $slug)
949
+ }
950
+ `,
951
+ variables: {
952
+ slug
953
+ }
954
+ })
955
+ });
956
+ const data = await result.json();
957
+ return data.data.driveIdBySlug;
958
+ }
959
+ };
960
+ }
961
+ const DELAY_LIMIT = 1e5;
962
+ const isListenerIdNotFound = (errorMessage, listenerId) => {
963
+ if (!listenerId) return false;
964
+ return errorMessage.toLocaleLowerCase().includes(`transmitter ${listenerId} not found`);
965
+ };
966
+ const useClientErrorHandler = () => {
967
+ const [handlingInProgress, setHandlingInProgress] = useState([]);
968
+ const [pullResponderTriggerMap, setPullResponderTriggerMap] = useState(/* @__PURE__ */ new Map());
969
+ const {
970
+ addTrigger,
971
+ removeTrigger,
972
+ registerNewPullResponderTrigger,
973
+ renameDrive,
974
+ addRemoteDrive,
975
+ documentDrives,
976
+ setDriveSharingType
977
+ } = useDocumentDriveServer();
978
+ const { getDriveIdBySlug } = useSwitchboard();
979
+ const pullResponderRegisterDelay = useRef(/* @__PURE__ */ new Map());
980
+ const handleStrands400 = useCallback(
981
+ async (driveId, trigger, handlerCode) => {
982
+ setHandlingInProgress((state) => [...state, handlerCode]);
983
+ const triggerData = trigger.data;
984
+ try {
985
+ let pullResponderTrigger = pullResponderTriggerMap.get(handlerCode);
986
+ if (!pullResponderTrigger) {
987
+ pullResponderTrigger = await registerNewPullResponderTrigger(
988
+ driveId,
989
+ triggerData.url,
990
+ {
991
+ pullInterval: Number(triggerData.interval) || 3e3
992
+ }
993
+ );
994
+ pullResponderTriggerMap.set(
995
+ handlerCode,
996
+ pullResponderTrigger
997
+ );
998
+ setPullResponderTriggerMap(pullResponderTriggerMap);
999
+ }
1000
+ await removeTrigger(driveId, trigger.id);
1001
+ await addTrigger(driveId, pullResponderTrigger);
1002
+ pullResponderRegisterDelay.current.delete(handlerCode);
1003
+ } catch (error) {
1004
+ const delay = pullResponderRegisterDelay.current.get(handlerCode) || 1;
1005
+ pullResponderRegisterDelay.current.set(
1006
+ handlerCode,
1007
+ delay === DELAY_LIMIT ? delay : delay * 10
1008
+ );
1009
+ logger.error(error);
1010
+ } finally {
1011
+ setHandlingInProgress(
1012
+ (state) => state.filter((code) => code !== handlerCode)
1013
+ );
1014
+ }
1015
+ },
1016
+ [
1017
+ pullResponderTriggerMap,
1018
+ removeTrigger,
1019
+ addTrigger,
1020
+ pullResponderRegisterDelay,
1021
+ registerNewPullResponderTrigger
1022
+ ]
1023
+ );
1024
+ const handleDriveNotFound = useCallback(
1025
+ async (driveId, trigger, handlerCode) => {
1026
+ var _a2;
1027
+ setHandlingInProgress((state) => [...state, handlerCode]);
1028
+ try {
1029
+ const drive = documentDrives.find(
1030
+ (drive2) => drive2.state.global.id === driveId
1031
+ );
1032
+ if (!drive) return;
1033
+ await removeTrigger(driveId, trigger.id);
1034
+ await renameDrive(
1035
+ driveId,
1036
+ drive.state.global.name + ` (${drive.state.global.id})`
1037
+ );
1038
+ await setDriveSharingType(driveId, LOCAL);
1039
+ if (((_a2 = trigger.data) == null ? void 0 : _a2.url) && drive.state.global.slug) {
1040
+ const newId = await getDriveIdBySlug(
1041
+ trigger.data.url,
1042
+ drive.state.global.slug
1043
+ );
1044
+ if (newId) {
1045
+ const urlParts = trigger.data.url.split("/");
1046
+ urlParts[urlParts.length - 1] = newId;
1047
+ const newUrl = urlParts.join("/");
1048
+ await addRemoteDrive(newUrl, {
1049
+ availableOffline: true,
1050
+ sharingType: "PUBLIC",
1051
+ listeners: [],
1052
+ triggers: []
1053
+ });
1054
+ }
1055
+ }
1056
+ } catch (e) {
1057
+ logger.error(e);
1058
+ } finally {
1059
+ setHandlingInProgress(
1060
+ (state) => state.filter((code) => code !== handlerCode)
1061
+ );
1062
+ }
1063
+ },
1064
+ [
1065
+ documentDrives,
1066
+ removeTrigger,
1067
+ renameDrive,
1068
+ setDriveSharingType,
1069
+ getDriveIdBySlug,
1070
+ addRemoteDrive
1071
+ ]
1072
+ );
1073
+ const strandsErrorHandler = useCallback(
1074
+ async (driveId, trigger, status, errorMessage) => {
1075
+ var _a2;
1076
+ switch (status) {
1077
+ case 400: {
1078
+ if (isListenerIdNotFound(
1079
+ errorMessage,
1080
+ (_a2 = trigger.data) == null ? void 0 : _a2.listenerId
1081
+ )) {
1082
+ const autoRegisterPullResponder = localStorage.getItem(
1083
+ "AUTO_REGISTER_PULL_RESPONDER"
1084
+ ) !== "false";
1085
+ if (!autoRegisterPullResponder) return;
1086
+ const handlerCode = `strands:${driveId}:${status}`;
1087
+ if (handlingInProgress.includes(handlerCode))
1088
+ return;
1089
+ if (!trigger.data) return;
1090
+ const delay = pullResponderRegisterDelay.current.get(
1091
+ handlerCode
1092
+ ) || 0;
1093
+ setTimeout(
1094
+ () => handleStrands400(
1095
+ driveId,
1096
+ trigger,
1097
+ handlerCode
1098
+ ),
1099
+ delay
1100
+ );
1101
+ }
1102
+ break;
1103
+ }
1104
+ case 404: {
1105
+ const handlerCode = `strands:${driveId}:${status}`;
1106
+ if (handlingInProgress.includes(handlerCode)) return;
1107
+ setTimeout(
1108
+ () => handleDriveNotFound(
1109
+ driveId,
1110
+ trigger,
1111
+ handlerCode
1112
+ ),
1113
+ 0
1114
+ );
1115
+ break;
1116
+ }
1117
+ }
1118
+ },
1119
+ [handleDriveNotFound, handleStrands400, handlingInProgress]
1120
+ );
1121
+ return useMemo(() => ({ strandsErrorHandler }), [strandsErrorHandler]);
1122
+ };
1123
+ /**
1124
+ * React Router DOM v6.30.0
1125
+ *
1126
+ * Copyright (c) Remix Software Inc.
1127
+ *
1128
+ * This source code is licensed under the MIT license found in the
1129
+ * LICENSE.md file in the root directory of this source tree.
1130
+ *
1131
+ * @license MIT
1132
+ */
1133
+ function _extends() {
1134
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
1135
+ for (var i = 1; i < arguments.length; i++) {
1136
+ var source = arguments[i];
1137
+ for (var key in source) {
1138
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1139
+ target[key] = source[key];
1140
+ }
1141
+ }
1142
+ }
1143
+ return target;
1144
+ };
1145
+ return _extends.apply(this, arguments);
1146
+ }
1147
+ function createSearchParams(init) {
1148
+ if (init === void 0) {
1149
+ init = "";
1150
+ }
1151
+ return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
1152
+ let value = init[key];
1153
+ return memo.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
1154
+ }, []));
1155
+ }
1156
+ function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
1157
+ let searchParams = createSearchParams(locationSearch);
1158
+ if (defaultSearchParams) {
1159
+ defaultSearchParams.forEach((_, key) => {
1160
+ if (!searchParams.has(key)) {
1161
+ defaultSearchParams.getAll(key).forEach((value) => {
1162
+ searchParams.append(key, value);
1163
+ });
1164
+ }
1165
+ });
1166
+ }
1167
+ return searchParams;
1168
+ }
1169
+ const REACT_ROUTER_VERSION = "6";
1170
+ try {
1171
+ window.__reactRouterVersion = REACT_ROUTER_VERSION;
1172
+ } catch (e) {
1173
+ }
1174
+ function createBrowserRouter(routes2, opts) {
1175
+ return createRouter$1({
1176
+ basename: opts == null ? void 0 : opts.basename,
1177
+ future: _extends({}, opts == null ? void 0 : opts.future, {
1178
+ v7_prependBasename: true
1179
+ }),
1180
+ history: createBrowserHistory({
1181
+ window: opts == null ? void 0 : opts.window
1182
+ }),
1183
+ hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
1184
+ routes: routes2,
1185
+ mapRouteProperties,
1186
+ dataStrategy: opts == null ? void 0 : opts.dataStrategy,
1187
+ patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
1188
+ window: opts == null ? void 0 : opts.window
1189
+ }).initialize();
1190
+ }
1191
+ function parseHydrationData() {
1192
+ var _window;
1193
+ let state = (_window = window) == null ? void 0 : _window.__staticRouterHydrationData;
1194
+ if (state && state.errors) {
1195
+ state = _extends({}, state, {
1196
+ errors: deserializeErrors(state.errors)
1197
+ });
1198
+ }
1199
+ return state;
1200
+ }
1201
+ function deserializeErrors(errors) {
1202
+ if (!errors) return null;
1203
+ let entries = Object.entries(errors);
1204
+ let serialized = {};
1205
+ for (let [key, val] of entries) {
1206
+ if (val && val.__type === "RouteErrorResponse") {
1207
+ serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
1208
+ } else if (val && val.__type === "Error") {
1209
+ if (val.__subType) {
1210
+ let ErrorConstructor = window[val.__subType];
1211
+ if (typeof ErrorConstructor === "function") {
1212
+ try {
1213
+ let error = new ErrorConstructor(val.message);
1214
+ error.stack = "";
1215
+ serialized[key] = error;
1216
+ } catch (e) {
1217
+ }
1218
+ }
1219
+ }
1220
+ if (serialized[key] == null) {
1221
+ let error = new Error(val.message);
1222
+ error.stack = "";
1223
+ serialized[key] = error;
1224
+ }
1225
+ } else {
1226
+ serialized[key] = val;
1227
+ }
1228
+ }
1229
+ return serialized;
1230
+ }
1231
+ const ViewTransitionContext = /* @__PURE__ */ React.createContext({
1232
+ isTransitioning: false
1233
+ });
1234
+ const FetchersContext = /* @__PURE__ */ React.createContext(/* @__PURE__ */ new Map());
1235
+ const START_TRANSITION = "startTransition";
1236
+ const startTransitionImpl = React[START_TRANSITION];
1237
+ const FLUSH_SYNC = "flushSync";
1238
+ const flushSyncImpl = ReactDOM[FLUSH_SYNC];
1239
+ function startTransitionSafe(cb) {
1240
+ if (startTransitionImpl) {
1241
+ startTransitionImpl(cb);
1242
+ } else {
1243
+ cb();
1244
+ }
1245
+ }
1246
+ function flushSyncSafe(cb) {
1247
+ if (flushSyncImpl) {
1248
+ flushSyncImpl(cb);
1249
+ } else {
1250
+ cb();
1251
+ }
1252
+ }
1253
+ class Deferred {
1254
+ constructor() {
1255
+ this.status = "pending";
1256
+ this.promise = new Promise((resolve, reject) => {
1257
+ this.resolve = (value) => {
1258
+ if (this.status === "pending") {
1259
+ this.status = "resolved";
1260
+ resolve(value);
1261
+ }
1262
+ };
1263
+ this.reject = (reason) => {
1264
+ if (this.status === "pending") {
1265
+ this.status = "rejected";
1266
+ reject(reason);
1267
+ }
1268
+ };
1269
+ });
1270
+ }
1271
+ }
1272
+ function RouterProvider(_ref) {
1273
+ let {
1274
+ fallbackElement,
1275
+ router: router2,
1276
+ future
1277
+ } = _ref;
1278
+ let [state, setStateImpl] = React.useState(router2.state);
1279
+ let [pendingState, setPendingState] = React.useState();
1280
+ let [vtContext, setVtContext] = React.useState({
1281
+ isTransitioning: false
1282
+ });
1283
+ let [renderDfd, setRenderDfd] = React.useState();
1284
+ let [transition, setTransition] = React.useState();
1285
+ let [interruption, setInterruption] = React.useState();
1286
+ let fetcherData = React.useRef(/* @__PURE__ */ new Map());
1287
+ let {
1288
+ v7_startTransition
1289
+ } = future || {};
1290
+ let optInStartTransition = React.useCallback((cb) => {
1291
+ if (v7_startTransition) {
1292
+ startTransitionSafe(cb);
1293
+ } else {
1294
+ cb();
1295
+ }
1296
+ }, [v7_startTransition]);
1297
+ let setState = React.useCallback((newState, _ref2) => {
1298
+ let {
1299
+ deletedFetchers,
1300
+ flushSync,
1301
+ viewTransitionOpts
1302
+ } = _ref2;
1303
+ newState.fetchers.forEach((fetcher, key) => {
1304
+ if (fetcher.data !== void 0) {
1305
+ fetcherData.current.set(key, fetcher.data);
1306
+ }
1307
+ });
1308
+ deletedFetchers.forEach((key) => fetcherData.current.delete(key));
1309
+ let isViewTransitionUnavailable = router2.window == null || router2.window.document == null || typeof router2.window.document.startViewTransition !== "function";
1310
+ if (!viewTransitionOpts || isViewTransitionUnavailable) {
1311
+ if (flushSync) {
1312
+ flushSyncSafe(() => setStateImpl(newState));
1313
+ } else {
1314
+ optInStartTransition(() => setStateImpl(newState));
1315
+ }
1316
+ return;
1317
+ }
1318
+ if (flushSync) {
1319
+ flushSyncSafe(() => {
1320
+ if (transition) {
1321
+ renderDfd && renderDfd.resolve();
1322
+ transition.skipTransition();
1323
+ }
1324
+ setVtContext({
1325
+ isTransitioning: true,
1326
+ flushSync: true,
1327
+ currentLocation: viewTransitionOpts.currentLocation,
1328
+ nextLocation: viewTransitionOpts.nextLocation
1329
+ });
1330
+ });
1331
+ let t = router2.window.document.startViewTransition(() => {
1332
+ flushSyncSafe(() => setStateImpl(newState));
1333
+ });
1334
+ t.finished.finally(() => {
1335
+ flushSyncSafe(() => {
1336
+ setRenderDfd(void 0);
1337
+ setTransition(void 0);
1338
+ setPendingState(void 0);
1339
+ setVtContext({
1340
+ isTransitioning: false
1341
+ });
1342
+ });
1343
+ });
1344
+ flushSyncSafe(() => setTransition(t));
1345
+ return;
1346
+ }
1347
+ if (transition) {
1348
+ renderDfd && renderDfd.resolve();
1349
+ transition.skipTransition();
1350
+ setInterruption({
1351
+ state: newState,
1352
+ currentLocation: viewTransitionOpts.currentLocation,
1353
+ nextLocation: viewTransitionOpts.nextLocation
1354
+ });
1355
+ } else {
1356
+ setPendingState(newState);
1357
+ setVtContext({
1358
+ isTransitioning: true,
1359
+ flushSync: false,
1360
+ currentLocation: viewTransitionOpts.currentLocation,
1361
+ nextLocation: viewTransitionOpts.nextLocation
1362
+ });
1363
+ }
1364
+ }, [router2.window, transition, renderDfd, fetcherData, optInStartTransition]);
1365
+ React.useLayoutEffect(() => router2.subscribe(setState), [router2, setState]);
1366
+ React.useEffect(() => {
1367
+ if (vtContext.isTransitioning && !vtContext.flushSync) {
1368
+ setRenderDfd(new Deferred());
1369
+ }
1370
+ }, [vtContext]);
1371
+ React.useEffect(() => {
1372
+ if (renderDfd && pendingState && router2.window) {
1373
+ let newState = pendingState;
1374
+ let renderPromise = renderDfd.promise;
1375
+ let transition2 = router2.window.document.startViewTransition(async () => {
1376
+ optInStartTransition(() => setStateImpl(newState));
1377
+ await renderPromise;
1378
+ });
1379
+ transition2.finished.finally(() => {
1380
+ setRenderDfd(void 0);
1381
+ setTransition(void 0);
1382
+ setPendingState(void 0);
1383
+ setVtContext({
1384
+ isTransitioning: false
1385
+ });
1386
+ });
1387
+ setTransition(transition2);
1388
+ }
1389
+ }, [optInStartTransition, pendingState, renderDfd, router2.window]);
1390
+ React.useEffect(() => {
1391
+ if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
1392
+ renderDfd.resolve();
1393
+ }
1394
+ }, [renderDfd, transition, state.location, pendingState]);
1395
+ React.useEffect(() => {
1396
+ if (!vtContext.isTransitioning && interruption) {
1397
+ setPendingState(interruption.state);
1398
+ setVtContext({
1399
+ isTransitioning: true,
1400
+ flushSync: false,
1401
+ currentLocation: interruption.currentLocation,
1402
+ nextLocation: interruption.nextLocation
1403
+ });
1404
+ setInterruption(void 0);
1405
+ }
1406
+ }, [vtContext.isTransitioning, interruption]);
1407
+ React.useEffect(() => {
1408
+ }, []);
1409
+ let navigator2 = React.useMemo(() => {
1410
+ return {
1411
+ createHref: router2.createHref,
1412
+ encodeLocation: router2.encodeLocation,
1413
+ go: (n) => router2.navigate(n),
1414
+ push: (to, state2, opts) => router2.navigate(to, {
1415
+ state: state2,
1416
+ preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
1417
+ }),
1418
+ replace: (to, state2, opts) => router2.navigate(to, {
1419
+ replace: true,
1420
+ state: state2,
1421
+ preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
1422
+ })
1423
+ };
1424
+ }, [router2]);
1425
+ let basename = router2.basename || "/";
1426
+ let dataRouterContext = React.useMemo(() => ({
1427
+ router: router2,
1428
+ navigator: navigator2,
1429
+ static: false,
1430
+ basename
1431
+ }), [router2, navigator2, basename]);
1432
+ let routerFuture = React.useMemo(() => ({
1433
+ v7_relativeSplatPath: router2.future.v7_relativeSplatPath
1434
+ }), [router2.future.v7_relativeSplatPath]);
1435
+ React.useEffect(() => logV6DeprecationWarnings(future, router2.future), [future, router2.future]);
1436
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DataRouterContext.Provider, {
1437
+ value: dataRouterContext
1438
+ }, /* @__PURE__ */ React.createElement(DataRouterStateContext.Provider, {
1439
+ value: state
1440
+ }, /* @__PURE__ */ React.createElement(FetchersContext.Provider, {
1441
+ value: fetcherData.current
1442
+ }, /* @__PURE__ */ React.createElement(ViewTransitionContext.Provider, {
1443
+ value: vtContext
1444
+ }, /* @__PURE__ */ React.createElement(Router, {
1445
+ basename,
1446
+ location: state.location,
1447
+ navigationType: state.historyAction,
1448
+ navigator: navigator2,
1449
+ future: routerFuture
1450
+ }, state.initialized || router2.future.v7_partialHydration ? /* @__PURE__ */ React.createElement(MemoizedDataRoutes, {
1451
+ routes: router2.routes,
1452
+ future: router2.future,
1453
+ state
1454
+ }) : fallbackElement))))), null);
1455
+ }
1456
+ const MemoizedDataRoutes = /* @__PURE__ */ React.memo(DataRoutes);
1457
+ function DataRoutes(_ref3) {
1458
+ let {
1459
+ routes: routes2,
1460
+ future,
1461
+ state
1462
+ } = _ref3;
1463
+ return useRoutesImpl(routes2, void 0, state, future);
1464
+ }
1465
+ var DataRouterHook;
1466
+ (function(DataRouterHook2) {
1467
+ DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
1468
+ DataRouterHook2["UseSubmit"] = "useSubmit";
1469
+ DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
1470
+ DataRouterHook2["UseFetcher"] = "useFetcher";
1471
+ DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
1472
+ })(DataRouterHook || (DataRouterHook = {}));
1473
+ var DataRouterStateHook;
1474
+ (function(DataRouterStateHook2) {
1475
+ DataRouterStateHook2["UseFetcher"] = "useFetcher";
1476
+ DataRouterStateHook2["UseFetchers"] = "useFetchers";
1477
+ DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
1478
+ })(DataRouterStateHook || (DataRouterStateHook = {}));
1479
+ function useSearchParams(defaultInit) {
1480
+ let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
1481
+ let hasSetSearchParamsRef = React.useRef(false);
1482
+ let location2 = useLocation();
1483
+ let searchParams = React.useMemo(() => (
1484
+ // Only merge in the defaults if we haven't yet called setSearchParams.
1485
+ // Once we call that we want those to take precedence, otherwise you can't
1486
+ // remove a param with setSearchParams({}) if it has an initial value
1487
+ getSearchParamsForLocation(location2.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
1488
+ ), [location2.search]);
1489
+ let navigate = useNavigate();
1490
+ let setSearchParams = React.useCallback((nextInit, navigateOptions) => {
1491
+ const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
1492
+ hasSetSearchParamsRef.current = true;
1493
+ navigate("?" + newSearchParams, navigateOptions);
1494
+ }, [navigate, searchParams]);
1495
+ return [searchParams, setSearchParams];
1496
+ }
1497
+ const useLoadInitialData = () => {
1498
+ const { t } = useTranslation();
1499
+ const {
1500
+ documentDrives,
1501
+ driveNodes,
1502
+ setDriveNodes,
1503
+ makeUiDriveNodes,
1504
+ onSyncStatus
1505
+ } = useUiNodes();
1506
+ const prevDrivesState = useRef([...driveNodes]);
1507
+ const drivesWithError = useRef([]);
1508
+ const [, , serverSubscribeUpdates] = useDocumentDrives();
1509
+ const { readDrives } = useReadModeContext();
1510
+ const clientErrorHandler = useClientErrorHandler();
1511
+ const reactor = useAsyncReactor();
1512
+ const [connectConfig2] = useConnectConfig();
1513
+ async function checkLatestVersion() {
1514
+ const result = await isLatestVersion();
1515
+ if (result === null) return;
1516
+ if (result.isLatest) {
1517
+ return true;
1518
+ }
1519
+ if (window.__VITE_ENVS.MODE === "development" || connectConfig2.studioMode || !connectConfig2.warnOutdatedApp) {
1520
+ console.warn(
1521
+ `Connect is outdated:
1522
+ Current: ${result.currentVersion}
1523
+ Latest: ${result.latestVersion}`
1524
+ );
1525
+ } else {
1526
+ toast(/* @__PURE__ */ jsx(ReloadConnectToast, {}), {
1527
+ type: "connect-warning",
1528
+ toastId: "outdated-app",
1529
+ autoClose: false
1530
+ });
1531
+ }
1532
+ }
1533
+ useEffect(() => {
1534
+ checkLatestVersion().catch(console.error);
1535
+ }, []);
1536
+ useEffect(() => {
1537
+ const unsubscribe = serverSubscribeUpdates(clientErrorHandler);
1538
+ return unsubscribe;
1539
+ }, [serverSubscribeUpdates, documentDrives, clientErrorHandler]);
1540
+ const checkDrivesErrors = useCallback(
1541
+ async (driveNodes2, t2) => {
1542
+ driveNodes2.forEach((drive) => {
1543
+ const prevDrive = prevDrivesState.current.find(
1544
+ (prevDrive2) => prevDrive2.id === drive.id
1545
+ );
1546
+ if (!prevDrive) return;
1547
+ if (drive.sharingType !== LOCAL && drive.syncStatus === SUCCESS && drivesWithError.current.includes(drive)) {
1548
+ drivesWithError.current = drivesWithError.current.filter(
1549
+ (d) => d.id !== drive.id
1550
+ );
1551
+ return toast(t2("notifications.driveSyncSuccess"), {
1552
+ type: "connect-success"
1553
+ });
1554
+ }
1555
+ if ((drive.syncStatus === CONFLICT || drive.syncStatus === ERROR) && drive.syncStatus !== prevDrive.syncStatus) {
1556
+ drivesWithError.current.push(drive);
1557
+ }
1558
+ });
1559
+ prevDrivesState.current = [...driveNodes2];
1560
+ if (drivesWithError.current.length > 0) {
1561
+ const isCurrent = await checkLatestVersion();
1562
+ if (isCurrent) {
1563
+ drivesWithError.current.forEach((drive) => {
1564
+ toast(
1565
+ t2(
1566
+ `notifications.${drive.syncStatus === CONFLICT ? "driveSyncConflict" : "driveSyncError"}`,
1567
+ { drive: drive.name }
1568
+ ),
1569
+ {
1570
+ type: "connect-warning",
1571
+ toastId: `${drive.syncStatus === CONFLICT ? "driveSyncConflict" : "driveSyncError"}-${drive.id}`
1572
+ }
1573
+ );
1574
+ });
1575
+ }
1576
+ }
1577
+ },
1578
+ []
1579
+ );
1580
+ useEffect(() => {
1581
+ checkDrivesErrors(driveNodes, t).catch(console.error);
1582
+ }, [driveNodes, t, checkDrivesErrors]);
1583
+ const updateUiDriveNodes = useCallback(
1584
+ async (documentDrives2) => {
1585
+ const uiDriveNodes = await makeUiDriveNodes(documentDrives2);
1586
+ setDriveNodes(uiDriveNodes);
1587
+ },
1588
+ [makeUiDriveNodes, setDriveNodes]
1589
+ );
1590
+ useEffect(() => {
1591
+ const drives = [
1592
+ ...readDrives,
1593
+ ...documentDrives
1594
+ ];
1595
+ updateUiDriveNodes(drives).catch(console.error);
1596
+ }, [documentDrives, readDrives, updateUiDriveNodes]);
1597
+ useEffect(() => {
1598
+ if (!reactor) {
1599
+ return;
1600
+ }
1601
+ const unsub = onSyncStatus(() => updateUiDriveNodes(documentDrives));
1602
+ return unsub;
1603
+ }, [reactor, documentDrives, onSyncStatus, updateUiDriveNodes]);
1604
+ };
1605
+ function buildPathname(selectedNodePath) {
1606
+ const driveNode = selectedNodePath[0];
1607
+ if (!driveNode) {
1608
+ return;
1609
+ }
1610
+ if (driveNode.kind !== DRIVE) {
1611
+ throw new Error(
1612
+ "Node path is invalid, first node is not a drive node."
1613
+ );
1614
+ }
1615
+ const driveNodeComponent = makeDriveNodeUrlComponent(driveNode);
1616
+ const nodePathComponents = selectedNodePath.slice(1).map((node) => encodeURIComponent(node.slug || node.name));
1617
+ const pathname = [driveNodeComponent, ...nodePathComponents].join("/");
1618
+ return pathname;
1619
+ }
1620
+ function makeDriveNodeUrlComponent(driveNode) {
1621
+ const component = driveNode.slug || driveNode.name || driveNode.id;
1622
+ return `/d/${encodeURIComponent(component)}`;
1623
+ }
1624
+ function getSelectedNodeFromPathname(driveNodes, driveIdFromPathname, nodeNamesFromPathname) {
1625
+ if (!driveIdFromPathname) {
1626
+ return null;
1627
+ }
1628
+ const driveId = decodeURIComponent(driveIdFromPathname);
1629
+ const driveNode = driveNodes.find(
1630
+ (node) => (node == null ? void 0 : node.id) === driveId || (node == null ? void 0 : node.slug) === driveId || (node == null ? void 0 : node.name) === driveId
1631
+ );
1632
+ if (!driveNode) return null;
1633
+ if (!nodeNamesFromPathname) return driveNode;
1634
+ const nodeNames = nodeNamesFromPathname.split("/").filter(Boolean).map(decodeURIComponent);
1635
+ let selectedNode = driveNode;
1636
+ for (const nodeName of nodeNames) {
1637
+ if (selectedNode.kind === FILE) break;
1638
+ const nextNode = selectedNode.children.find(
1639
+ (node) => node.slug === nodeName || node.name === nodeName
1640
+ );
1641
+ if (!nextNode) {
1642
+ console.error("Node not found:", nodeName);
1643
+ break;
1644
+ }
1645
+ selectedNode = nextNode;
1646
+ }
1647
+ return selectedNode;
1648
+ }
1649
+ const useNodeNavigation = () => {
1650
+ const navigate = useNavigate();
1651
+ const location2 = useLocation();
1652
+ const { search, pathname } = location2;
1653
+ const params = useParams();
1654
+ const { driveNodes, selectedNode, selectedNodePath, setSelectedNode } = useUiNodesContext();
1655
+ const driveIdFromPathname = params.driveId;
1656
+ const nodeNamesFromPathname = params["*"];
1657
+ const selectedNodeFromPathname = getSelectedNodeFromPathname(
1658
+ driveNodes,
1659
+ driveIdFromPathname,
1660
+ nodeNamesFromPathname
1661
+ );
1662
+ const selectedNodePathname = buildPathname(selectedNodePath);
1663
+ useEffect(() => {
1664
+ if (!selectedNodePathname || selectedNodePathname === pathname) return;
1665
+ navigate({ pathname: selectedNodePathname, search });
1666
+ }, [search, navigate, selectedNodePathname]);
1667
+ useEffect(() => {
1668
+ if (selectedNode || !selectedNodeFromPathname) return;
1669
+ setSelectedNode(selectedNodeFromPathname);
1670
+ }, [selectedNode, selectedNodeFromPathname, setSelectedNode]);
1671
+ useEffect(() => {
1672
+ const selectedNodeFromPathname2 = getSelectedNodeFromPathname(
1673
+ driveNodes,
1674
+ driveIdFromPathname,
1675
+ nodeNamesFromPathname
1676
+ );
1677
+ if (!selectedNodeFromPathname2) return;
1678
+ setSelectedNode(selectedNodeFromPathname2);
1679
+ }, [
1680
+ driveNodes,
1681
+ driveIdFromPathname,
1682
+ nodeNamesFromPathname,
1683
+ setSelectedNode
1684
+ ]);
1685
+ };
1686
+ 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" }))));
1687
+ 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" }));
1688
+ const REACTOR_URL = "https://apps.powerhouse.io/sky-atlas/staging/switchboard";
1689
+ const MIN_LOADING_TIME = 2e3;
1690
+ function useReactorUrl() {
1691
+ const { search } = useLocation();
1692
+ return useMemo(() => {
1693
+ const params = new URLSearchParams(search);
1694
+ const url = params.get("reactorUrl") ?? REACTOR_URL;
1695
+ return url.endsWith("/") ? url : `${url}/`;
1696
+ }, [search]);
1697
+ }
1698
+ async function forkAtlas(docId, reactorUrl) {
1699
+ const document = gql`
1700
+ mutation ForkAtlas($docId: PHID) {
1701
+ ForkAtlas(docId: $docId)
1702
+ }
1703
+ `;
1704
+ return await request(`${reactorUrl}graphql`, document, { docId });
1705
+ }
1706
+ function AtlasImport() {
1707
+ const status = useRef("initial");
1708
+ const reactor = useUnwrappedReactor();
1709
+ const { documentId } = useParams();
1710
+ const reactorUrl = useReactorUrl();
1711
+ const navigate = useNavigate();
1712
+ const { addRemoteDrive } = useDocumentDriveServer();
1713
+ const [driveId, setDriveId] = useState(void 0);
1714
+ const [error, setError] = useState(void 0);
1715
+ const [loading, setLoading] = useState(true);
1716
+ const hasError = status.current === "error";
1717
+ useEffect(() => {
1718
+ if (error) {
1719
+ console.error("Error forking Atlas:", error);
1720
+ toast("Error forking Atlas", { type: "error" });
1721
+ }
1722
+ }, [error]);
1723
+ async function forkAtlasDocument(documentId2) {
1724
+ const result = await forkAtlas(documentId2, reactorUrl);
1725
+ const driveId2 = result.ForkAtlas;
1726
+ status.current = "forked";
1727
+ setDriveId(driveId2);
1728
+ }
1729
+ const redirectToDrive = useCallback(() => {
1730
+ if (driveId && !loading) {
1731
+ navigate(`/d/${driveId}`, { replace: true });
1732
+ }
1733
+ }, [driveId, navigate, loading]);
1734
+ const addForkDrive = useCallback(
1735
+ async (driveId2) => {
1736
+ console.log("Adding remote drive:", driveId2);
1737
+ const driveUrl = `${reactorUrl}d/${driveId2}`;
1738
+ try {
1739
+ const addedDrive = await addRemoteDrive(driveUrl, {
1740
+ sharingType: "PUBLIC",
1741
+ availableOffline: true,
1742
+ listeners: [
1743
+ {
1744
+ block: true,
1745
+ callInfo: {
1746
+ data: driveUrl,
1747
+ name: "switchboard-push",
1748
+ transmitterType: "SwitchboardPush"
1749
+ },
1750
+ filter: {
1751
+ branch: ["main"],
1752
+ documentId: ["*"],
1753
+ documentType: ["*"],
1754
+ scope: ["global"]
1755
+ },
1756
+ label: "Switchboard Sync",
1757
+ listenerId: "1",
1758
+ system: true
1759
+ }
1760
+ ],
1761
+ triggers: []
1762
+ });
1763
+ status.current = "done";
1764
+ console.log("Added remote drive:", addedDrive);
1765
+ setTimeout(() => {
1766
+ setLoading(false);
1767
+ }, MIN_LOADING_TIME);
1768
+ } catch (error2) {
1769
+ status.current = "error";
1770
+ setLoading(false);
1771
+ setError(error2);
1772
+ }
1773
+ },
1774
+ [addRemoteDrive, navigate, reactorUrl]
1775
+ );
1776
+ useEffect(() => {
1777
+ if (!documentId || status.current !== "initial") return;
1778
+ status.current = "forking";
1779
+ forkAtlasDocument(documentId).catch((error2) => {
1780
+ status.current = "error";
1781
+ setError(error2);
1782
+ });
1783
+ }, [documentId, status]);
1784
+ useEffect(() => {
1785
+ if (!driveId || !reactor || status.current !== "forked") return;
1786
+ status.current = "addingDrive";
1787
+ new Promise((resolve) => {
1788
+ setTimeout(resolve, 500);
1789
+ }).then(() => addForkDrive(driveId)).catch((error2) => {
1790
+ status.current = "error";
1791
+ setError(error2);
1792
+ });
1793
+ }, [driveId, reactor, status]);
1794
+ 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: [
1795
+ /* @__PURE__ */ jsx("h1", { className: "text-lg text-gray-900 font-medium", children: "Welcome to the Atlas Explorer" }),
1796
+ /* @__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: [
1797
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(SvgAtlasLogomark, {}) }),
1798
+ 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..." }),
1799
+ /* @__PURE__ */ jsx(
1800
+ Button,
1801
+ {
1802
+ onClick: hasError ? window.location.reload.bind(
1803
+ window.location
1804
+ ) : redirectToDrive,
1805
+ size: "small",
1806
+ color: "light",
1807
+ className: "bg-white border border-gray-200 h-9 px-3 mt-4 text-gray-600",
1808
+ children: hasError ? "Retry" : loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
1809
+ /* @__PURE__ */ jsx(SvgRefresh, { className: "animate-spin" }),
1810
+ "Loading"
1811
+ ] }) : "Continue"
1812
+ }
1813
+ )
1814
+ ] }) })
1815
+ ] }) });
1816
+ }
1817
+ const ErrorBoundaryContext = createContext(null);
1818
+ const initialState = {
1819
+ didCatch: false,
1820
+ error: null
1821
+ };
1822
+ class ErrorBoundary extends Component {
1823
+ constructor(props) {
1824
+ super(props);
1825
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
1826
+ this.state = initialState;
1827
+ }
1828
+ static getDerivedStateFromError(error) {
1829
+ return {
1830
+ didCatch: true,
1831
+ error
1832
+ };
1833
+ }
1834
+ resetErrorBoundary() {
1835
+ const {
1836
+ error
1837
+ } = this.state;
1838
+ if (error !== null) {
1839
+ var _this$props$onReset, _this$props;
1840
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1841
+ args[_key] = arguments[_key];
1842
+ }
1843
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
1844
+ args,
1845
+ reason: "imperative-api"
1846
+ });
1847
+ this.setState(initialState);
1848
+ }
1849
+ }
1850
+ componentDidCatch(error, info) {
1851
+ var _this$props$onError, _this$props2;
1852
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
1853
+ }
1854
+ componentDidUpdate(prevProps, prevState) {
1855
+ const {
1856
+ didCatch
1857
+ } = this.state;
1858
+ const {
1859
+ resetKeys
1860
+ } = this.props;
1861
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
1862
+ var _this$props$onReset2, _this$props3;
1863
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
1864
+ next: resetKeys,
1865
+ prev: prevProps.resetKeys,
1866
+ reason: "keys"
1867
+ });
1868
+ this.setState(initialState);
1869
+ }
1870
+ }
1871
+ render() {
1872
+ const {
1873
+ children,
1874
+ fallbackRender,
1875
+ FallbackComponent,
1876
+ fallback
1877
+ } = this.props;
1878
+ const {
1879
+ didCatch,
1880
+ error
1881
+ } = this.state;
1882
+ let childToRender = children;
1883
+ if (didCatch) {
1884
+ const props = {
1885
+ error,
1886
+ resetErrorBoundary: this.resetErrorBoundary
1887
+ };
1888
+ if (typeof fallbackRender === "function") {
1889
+ childToRender = fallbackRender(props);
1890
+ } else if (FallbackComponent) {
1891
+ childToRender = createElement(FallbackComponent, props);
1892
+ } else if (fallback !== void 0) {
1893
+ childToRender = fallback;
1894
+ } else {
1895
+ throw error;
1896
+ }
1897
+ }
1898
+ return createElement(ErrorBoundaryContext.Provider, {
1899
+ value: {
1900
+ didCatch,
1901
+ error,
1902
+ resetErrorBoundary: this.resetErrorBoundary
1903
+ }
1904
+ }, childToRender);
1905
+ }
1906
+ }
1907
+ function hasArrayChanged() {
1908
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
1909
+ let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
1910
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
1911
+ }
1912
+ 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" }));
1913
+ 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" }))));
1914
+ function Sidebar() {
1915
+ const { showModal } = useModal();
1916
+ const navigate = useNavigate();
1917
+ const { user, openRenown, logout } = useLogin();
1918
+ const { driveNodes, setSelectedNode, selectedNode, showAddDriveModal } = useUiNodes();
1919
+ const connectDebug = localStorage.getItem("CONNECT_DEBUG") === "true";
1920
+ const onClickSettings = () => {
1921
+ showModal("settingsModal", { onRefresh: () => navigate(0) });
1922
+ };
1923
+ const onRootClick = useCallback(() => {
1924
+ setSelectedNode(null);
1925
+ navigate("/");
1926
+ }, [navigate, setSelectedNode]);
1927
+ const onAddDriveClick = useCallback(() => {
1928
+ showAddDriveModal();
1929
+ }, [showAddDriveModal]);
1930
+ const headerContent = /* @__PURE__ */ jsxs("div", { className: "flex h-full items-center", children: [
1931
+ /* @__PURE__ */ jsx(
1932
+ Icon,
1933
+ {
1934
+ name: "Connect",
1935
+ className: "!h-[30px] !w-[100px] cursor-pointer",
1936
+ onClick: onRootClick
1937
+ }
1938
+ ),
1939
+ connectDebug && /* @__PURE__ */ jsx(
1940
+ "button",
1941
+ {
1942
+ id: "connect-debug-button",
1943
+ className: "ml-6",
1944
+ onClick: () => showModal("debugSettingsModal", {}),
1945
+ children: /* @__PURE__ */ jsx("img", { src: "settings.png", className: "h-5 text-gray-600" })
1946
+ }
1947
+ )
1948
+ ] });
1949
+ const handleDriveClick = useCallback(
1950
+ (driveNode) => {
1951
+ setSelectedNode(driveNode);
1952
+ },
1953
+ [setSelectedNode]
1954
+ );
1955
+ const etherscanUrl = (user == null ? void 0 : user.address) ? `https://etherscan.io/address/${user.address}` : "";
1956
+ return /* @__PURE__ */ jsx(
1957
+ ConnectSidebar,
1958
+ {
1959
+ id: "sidebar",
1960
+ onClick: () => onRootClick(),
1961
+ onClickSettings,
1962
+ headerContent,
1963
+ address: user == null ? void 0 : user.address,
1964
+ onLogin: openRenown,
1965
+ onDisconnect: logout,
1966
+ etherscanUrl,
1967
+ children: /* @__PURE__ */ jsxs(
1968
+ ErrorBoundary,
1969
+ {
1970
+ fallback: /* @__PURE__ */ jsx("div", { className: "text-center", children: "There was an error loading drives" }),
1971
+ onError: logger.error,
1972
+ children: [
1973
+ driveNodes.map((node, index) => /* @__PURE__ */ jsx(
1974
+ SidebarItem,
1975
+ {
1976
+ title: node.name,
1977
+ onClick: () => handleDriveClick(node),
1978
+ active: (selectedNode == null ? void 0 : selectedNode.id) === node.id,
1979
+ icon: node.icon ? /* @__PURE__ */ jsx(
1980
+ "img",
1981
+ {
1982
+ src: node.icon,
1983
+ alt: node.name,
1984
+ width: 32,
1985
+ height: 32
1986
+ }
1987
+ ) : void 0
1988
+ },
1989
+ index
1990
+ )),
1991
+ /* @__PURE__ */ jsx(SidebarAddDriveItem, { onClick: onAddDriveClick })
1992
+ ]
1993
+ }
1994
+ )
1995
+ }
1996
+ );
1997
+ }
1998
+ function Root() {
1999
+ useLoadInitialData();
2000
+ useNodeNavigation();
2001
+ const navigate = useNavigate();
2002
+ const { login } = useLogin();
2003
+ useEffect(() => {
2004
+ var _a2;
2005
+ (_a2 = window.electronAPI) == null ? void 0 : _a2.ready();
2006
+ }, []);
2007
+ const [searchParams, setSearchParams] = useSearchParams();
2008
+ useEffect(() => {
2009
+ const userStr = searchParams.get("user");
2010
+ if (userStr && login) {
2011
+ const userDid = decodeURIComponent(userStr);
2012
+ searchParams.delete("user");
2013
+ setSearchParams(searchParams);
2014
+ login(userDid).catch(logger.error);
2015
+ }
2016
+ }, [login, searchParams, setSearchParams]);
2017
+ useEffect(() => {
2018
+ var _a2;
2019
+ const unsubscribe = (_a2 = window.electronAPI) == null ? void 0 : _a2.handleURL((_e, url) => {
2020
+ navigate(`/${url}`);
2021
+ });
2022
+ return unsubscribe;
2023
+ }, [navigate]);
2024
+ return /* @__PURE__ */ jsx(ModalManager, { children: /* @__PURE__ */ jsxs("div", { className: "h-screen", children: [
2025
+ isElectron && /* @__PURE__ */ jsxs(
2026
+ "div",
2027
+ {
2028
+ className: `h-8 w-full
2029
+ ${isMac && "justify-center"}
2030
+ flex items-center bg-gray-50`,
2031
+ children: [
2032
+ /* @__PURE__ */ jsx(SvgLogo, { className: "ml-1 mr-0.5 p-1.5" }),
2033
+ /* @__PURE__ */ jsx(SvgConnect, { className: "h-3 w-fit" })
2034
+ ]
2035
+ }
2036
+ ),
2037
+ /* @__PURE__ */ jsx(
2038
+ "div",
2039
+ {
2040
+ className: `flex items-stretch overflow-auto
2041
+ ${isElectron ? "h-app-height" : "h-screen"}
2042
+ `,
2043
+ role: "presentation",
2044
+ tabIndex: 0,
2045
+ children: /* @__PURE__ */ jsxs(Suspense, { children: [
2046
+ /* @__PURE__ */ jsx(Sidebar, {}),
2047
+ /* @__PURE__ */ jsx("div", { className: "relative flex-1 overflow-auto", children: /* @__PURE__ */ jsx(Outlet, {}) })
2048
+ ] })
2049
+ }
2050
+ )
2051
+ ] }) });
2052
+ }
2053
+ const ReloadConnectToast = () => {
2054
+ const { t } = useTranslation();
2055
+ return /* @__PURE__ */ jsxs("div", { children: [
2056
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: t("notifications.reloadApp") }),
2057
+ /* @__PURE__ */ jsxs(
2058
+ "button",
2059
+ {
2060
+ onClick: () => location.reload(),
2061
+ className: "underline decoration-solid underline-offset-2",
2062
+ children: [
2063
+ t("common.reloadConnect"),
2064
+ " 🔄"
2065
+ ]
2066
+ }
2067
+ )
2068
+ ] });
2069
+ };
2070
+ function getDriveIcon(driveNode) {
2071
+ if (driveNode.icon) {
2072
+ return /* @__PURE__ */ jsx(
2073
+ "img",
2074
+ {
2075
+ src: driveNode.icon,
2076
+ alt: driveNode.name,
2077
+ height: 32,
2078
+ width: 32
2079
+ }
2080
+ );
2081
+ }
2082
+ if (driveNode.sharingType === "LOCAL") {
2083
+ return /* @__PURE__ */ jsx(Icon, { name: "Hdd", size: 32 });
2084
+ } else {
2085
+ return /* @__PURE__ */ jsx(Icon, { name: "Server", size: 32 });
2086
+ }
2087
+ }
2088
+ function Home() {
2089
+ const getAppDescriptionForEditorId = useGetAppNameForEditorId();
2090
+ const { showAddDriveModal, driveNodes, setSelectedNode } = useUiNodes();
2091
+ const { documentDrives } = useDocumentDriveServer();
2092
+ const handleDriveClick = useCallback(
2093
+ (driveNode) => {
2094
+ setSelectedNode(driveNode);
2095
+ },
2096
+ [setSelectedNode]
2097
+ );
2098
+ const onAddDriveClick = useCallback(() => {
2099
+ showAddDriveModal();
2100
+ }, [showAddDriveModal]);
2101
+ return /* @__PURE__ */ jsxs(HomeScreen, { children: [
2102
+ driveNodes.map((driveNode) => {
2103
+ var _a2;
2104
+ const drive = documentDrives.find(
2105
+ (d) => d.state.global.id === driveNode.id
2106
+ );
2107
+ const editorId = (_a2 = drive == null ? void 0 : drive.meta) == null ? void 0 : _a2.preferredEditor;
2108
+ const appName = editorId ? getAppDescriptionForEditorId(editorId) : void 0;
2109
+ return /* @__PURE__ */ jsx(
2110
+ HomeScreenItem,
2111
+ {
2112
+ title: driveNode.name,
2113
+ description: appName || "Drive Explorer App",
2114
+ icon: getDriveIcon(driveNode),
2115
+ onClick: () => handleDriveClick(driveNode)
2116
+ },
2117
+ driveNode.id
2118
+ );
2119
+ }),
2120
+ /* @__PURE__ */ jsx(HomeScreenAddDriveItem, { onClick: onAddDriveClick })
2121
+ ] });
2122
+ }
2123
+ const Content = React__default.lazy(() => __vitePreload(() => import("./content-CwQswwKt.js"), true ? __vite__mapDeps([0,1,2,3,4,5]) : void 0));
2124
+ async function createRouter(routes2) {
2125
+ var _a2;
2126
+ const isPackaged = await ((_a2 = window.electronAPI) == null ? void 0 : _a2.isPackaged());
2127
+ const createRouter2 = isPackaged ? createMemoryRouter : createBrowserRouter;
2128
+ return createRouter2(routes2, {
2129
+ basename: connectConfig.routerBasename,
2130
+ future: {
2131
+ v7_fetcherPersist: true,
2132
+ v7_relativeSplatPath: true
2133
+ }
2134
+ });
2135
+ }
2136
+ function createRoutes() {
2137
+ const routes2 = [
2138
+ {
2139
+ path: "/",
2140
+ element: /* @__PURE__ */ jsx(Home, {})
2141
+ },
2142
+ {
2143
+ path: "d?/:driveId?/*?",
2144
+ element: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Content, {}) })
2145
+ },
2146
+ {
2147
+ path: "import/:documentId",
2148
+ element: /* @__PURE__ */ jsx(AtlasImport, {})
2149
+ }
2150
+ ];
2151
+ return [
2152
+ {
2153
+ path: "/",
2154
+ element: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Root, {}) }),
2155
+ children: routes2
2156
+ },
2157
+ {
2158
+ element: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Root, {}) })
2159
+ }
2160
+ ];
2161
+ }
2162
+ const routes = createRoutes();
2163
+ const RouterAsync = async () => {
2164
+ const router2 = await createRouter(routes);
2165
+ const Router2 = () => /* @__PURE__ */ jsx(RouterProvider, { router: router2 });
2166
+ return Router2;
2167
+ };
2168
+ const router = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2169
+ __proto__: null,
2170
+ default: RouterAsync
2171
+ }, Symbol.toStringTag, { value: "Module" }));
2172
+ export {
2173
+ ENSAvatar as E,
2174
+ ErrorBoundary as a,
2175
+ router as r,
2176
+ useQuery$1 as u
2177
+ };
2178
+ //# sourceMappingURL=router-CvCplkfB.js.map