@epam/ai-dial-chat-hooks 1.1.0-dev.422 → 1.1.0-dev.426
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.
- package/{api-error-DuLNy43N.js → api-error/api-error.js} +1 -1
- package/api-transport/create-csrf-middleware.js +21 -0
- package/api-transport/create-unauthorized-middleware.js +41 -0
- package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
- package/attachments.js +3 -2
- package/catalog/catalog-derivations.js +10 -0
- package/catalog/catalog-primary-action.js +21 -0
- package/catalog/create-publish-api.js +27 -0
- package/catalog/deployment-endpoint-url.js +34 -0
- package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
- package/catalog/entity-details.js +6 -0
- package/catalog/map-deployment-limits-to-catalog.js +73 -0
- package/catalog/map-deployment-limits-to-input.js +14 -0
- package/catalog/map-deployment-to-catalog-item.js +92 -0
- package/catalog/map-entity-details-to-catalog.js +350 -0
- package/catalog/map-prompt-to-catalog-item.js +49 -0
- package/catalog/map-skill-to-catalog-item.js +123 -0
- package/catalog/mcp-endpoint-url.js +26 -0
- package/catalog/publish.js +18 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
- package/catalog/useCatalogItemDetails.js +101 -0
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
- package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
- package/catalog/usePublishFolders/usePublishFolders.js +72 -0
- package/catalog.js +22 -3
- package/conversation/announcement-message.js +42 -0
- package/conversation/conversation-transfer/async.js +18 -0
- package/conversation/conversation-transfer/attachment-refs.js +11 -0
- package/conversation/conversation-transfer/build-upload-path.js +27 -0
- package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
- package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
- package/conversation/conversation-transfer/export-conversation.js +32 -0
- package/conversation/conversation-transfer/import-conversation.js +93 -0
- package/conversation/conversation-transfer/progress.js +39 -0
- package/conversation/conversation-transfer/queue.js +84 -0
- package/conversation/conversation-transfer/types.js +9 -0
- package/conversation/conversation-transfer/zip-export.js +19 -0
- package/conversation/conversation-transfer/zip-import.js +29 -0
- package/conversation/create-chat-stream-api.js +96 -0
- package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
- package/conversation/display-name-watch.js +5 -0
- package/conversation/footer-message.js +23 -0
- package/conversation/get-model-id-from-conversation-id.js +14 -0
- package/conversation/greeting.js +7 -0
- package/conversation/message-factory.js +19 -0
- package/conversation/message-utils.js +13 -0
- package/conversation/overlay-messages.js +8 -0
- package/conversation/quick-app-conversation-starters.js +29 -0
- package/conversation/starter-option.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
- package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
- package/conversation/useConversationExport/useConversationExport.js +285 -0
- package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
- package/conversation/useConversationHandlers/message-factory.js +21 -0
- package/conversation/useConversationHandlers/message-utils.js +8 -0
- package/conversation/useConversationHandlers/starter-option.js +11 -0
- package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
- package/conversation/useConversationImport/useConversationImport.js +239 -0
- package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
- package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
- package/conversation/useConversationStream/apply-chunk.js +78 -0
- package/conversation/useConversationStream/buffered-generation.js +18 -0
- package/conversation/useConversationStream/conversation-path.js +8 -0
- package/conversation/useConversationStream/generation-resume.js +126 -0
- package/conversation/useConversationStream/useConversationStream.js +148 -0
- package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
- package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
- package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
- package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
- package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
- package/conversation-sources.js +1 -1
- package/conversation-transfer.js +7 -3
- package/conversation.d.ts +66 -0
- package/conversation.js +31 -2
- package/file-manager.d.ts +3 -4
- package/file-manager.js +28 -3
- package/files/annotation.js +15 -0
- package/files/attachment-canvas.js +218 -0
- package/files/attachment-dto-to-display.js +15 -0
- package/files/attachment-types.js +16 -0
- package/files/create-files-api.js +40 -0
- package/files/create-upload-file-with-progress.js +42 -0
- package/files/dial-file-manager-copy-move.util.js +55 -0
- package/files/dial-file-manager-mapping.util.js +140 -0
- package/files/dial-file-manager-path.util.js +72 -0
- package/files/dial-file-manager.model.js +25 -0
- package/files/dial-file-manager.types.js +10 -0
- package/files/dial-file-to-attachment.js +37 -0
- package/files/dial-file.js +30 -0
- package/files/dial-files-api.js +6 -0
- package/files/download-destination.js +6 -0
- package/files/file-manager-variant.js +11 -0
- package/files/file-name.js +19 -0
- package/files/prepare-download-destination.js +24 -0
- package/files/resolve-dial-file-api-path.js +33 -0
- package/files/source-content.js +37 -0
- package/files/useDialFileListing/useDialFileListing.js +295 -0
- package/files/useDialFileManager/useDialFileManager.js +146 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
- package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
- package/files/useDialFileMutations/useDialFileMutations.js +359 -0
- package/files/useDialFileSharing/useDialFileSharing.js +70 -0
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
- package/index.d.ts +69 -4
- package/index.js +134 -28
- package/mcp-apps/mcp-apps-api-client.js +48 -0
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
- package/mcp-apps.js +6 -2
- package/oauth/authorize-url.js +12 -0
- package/oauth/handshake.js +65 -0
- package/oauth/popup.js +29 -0
- package/oauth/toolset-id.js +10 -0
- package/oauth/types.js +24 -0
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
- package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
- package/oauth.js +9 -3
- package/package.json +35 -23
- package/prompt/export-prompt.js +28 -0
- package/prompt/prompt-resource.js +15 -0
- package/prompt/prompt.js +12 -0
- package/prompt/usePromptsState/usePromptsState.js +42 -0
- package/scheduled-task/scheduled-task-mapping.js +6 -0
- package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
- package/scheduled-tasks.js +3 -2
- package/scroll-anchoring.js +1 -1
- package/shared/application-schema.js +4 -0
- package/shared/browser-timezone.js +10 -0
- package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
- package/shared/custom-apps.js +30 -0
- package/shared/external-services.js +18 -0
- package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
- package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
- package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
- package/shared/toolset-login-events.js +13 -0
- package/sharing.js +3 -3
- package/skill/skill-file-batch-validation.js +48 -0
- package/skill/skill-file-preview.js +15 -0
- package/skill/skill-manifest.js +70 -0
- package/skill/skill-types.js +15 -0
- package/skill/skill.js +48 -0
- package/skill/useSkillEditorLoad.js +103 -0
- package/skill/useSkillEditorSubmit.js +135 -0
- package/skill/useSkillFileActions.js +99 -0
- package/skill/useSkillFilePreview.js +29 -0
- package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
- package/skill-editor.js +8 -3
- package/skills-state.js +1 -1
- package/source-content.d.ts +29 -0
- package/source-content.js +2 -0
- package/usage/useUsageData/useUsageData.js +32 -0
- package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
- package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
- package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
- package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
- package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
- package/useToolsMenu/useToolsMenu.js +50 -0
- package/useViewportWidth/useViewportWidth.js +12 -0
- package/utils.js +17 -7
- package/viewport-layout.js +4 -2
- package/attachment-types-AAoN9E95.js +0 -7760
- package/browser-Btsa0Lmr.js +0 -607
- package/skill-manifest-CeG6-WSK.js +0 -4056
- package/useAttachmentValidation-CkMTd5lA.js +0 -102
- package/useConversationImport-CDRs7JF1.js +0 -826
- package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
- package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
- package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
- package/useSkillFileActions-B-VaGD20.js +0 -373
- package/useSkillFilePreview-B5o1n_0F.js +0 -1244
- package/useToolsMenu-zURpMEn1.js +0 -1882
- package/useToolsetLogin-B05m134e.js +0 -195
- package/useUsageData-D7BxloKZ.js +0 -201
|
@@ -1,2291 +0,0 @@
|
|
|
1
|
-
import { a as e } from "./attachment-types-AAoN9E95.js";
|
|
2
|
-
import { r as t } from "./api-error-DuLNy43N.js";
|
|
3
|
-
import { n } from "./string-utils-iBi2Y55C.js";
|
|
4
|
-
import { AttachmentContentType as r, AttachmentErrorType as i, getOoxmlMimeType as a, isHtmlPreviewable as o, isOoxmlPreviewable as s, isTextPreviewable as c } from "@epam/ai-dial-attachment-canvas";
|
|
5
|
-
import { AttachmentType as l, DialFileManagerActionProfile as u, DialFileManagerVariant as d, FileExtension as f, FileUploadStatus as p, HIDDEN_FILE as m, MIMEType as h, RequestStatus as g, base64ToBlob as _, getParentFolderPath as v, getUtf8ByteLength as y, messageAttachmentToDisplayAttachment as b, stripUrlQueryAndFragment as x, triggerAnchorDownload as S, truncateToUtf8Bytes as C, tryBase64ToBytes as w } from "@epam/ai-dial-chat-shared";
|
|
6
|
-
import { annotationHighlightId as T, annotationsToPdfHighlights as E, getAnnotationPdfPage as D, parsePdfPageReference as O } from "@epam/ai-dial-quotations";
|
|
7
|
-
import { useCallback as k, useEffect as A, useMemo as j, useRef as M, useState as N } from "react";
|
|
8
|
-
import { ArchiveItemDtoNodeTypeEnum as P, CopyItemDtoNodeTypeEnum as F, DeleteItemDtoNodeTypeEnum as I, ListFilesItemDtoNodeTypeEnum as ee, MoveItemDtoNodeTypeEnum as L, RenameItemDtoNodeTypeEnum as R } from "@epam/ai-dial-chat-api-client";
|
|
9
|
-
import { DialFileNodeType as te, NOT_ALLOWED_SYMBOLS as ne, NOT_ALLOWED_SYMBOLS_REGEXP as z, NotificationVariant as B } from "@epam/ai-dial-ui-kit";
|
|
10
|
-
import { DialFileManagerActions as V, DialFileManagerTabs as H, DialFileNodeType as U, DialFilePermission as W, FileManagerColumnKey as G } from "@epam/ai-dial-react-file-manager";
|
|
11
|
-
//#region src/files/dial-files-api.ts
|
|
12
|
-
var re = /* @__PURE__ */ function(e) {
|
|
13
|
-
return e.Overwrite = "overwrite", e.CreateOnly = "create-only", e;
|
|
14
|
-
}({}), K = /* @__PURE__ */ function(e) {
|
|
15
|
-
return e.FolderLoadFailed = "folderLoadFailed", e.MetadataLoadFailed = "metadataLoadFailed", e.FolderCreateFailed = "folderCreateFailed", e.DownloadFileFailed = "downloadFileFailed", e.DownloadFilesFailed = "downloadFilesFailed", e.FilesDeleted = "filesDeleted", e.FilesDeletePartiallyFailed = "filesDeletePartiallyFailed", e.DeleteFailed = "deleteFailed", e.RenameFailed = "renameFailed", e.RenamePartiallyFailed = "renamePartiallyFailed", e.MoveFailed = "moveFailed", e.MovePartiallyFailed = "movePartiallyFailed", e.CopyFailed = "copyFailed", e.CopyPartiallyFailed = "copyPartiallyFailed", e.UnshareFailed = "unshareFailed", e.RemoveAccessFailed = "removeAccessFailed", e.UploadFailed = "uploadFailed", e.UploadCompleted = "uploadCompleted", e.UploadArchiveFailed = "uploadArchiveFailed", e.UploadArchivePartiallyFailed = "uploadArchivePartiallyFailed", e.UploadArchiveRequestFailed = "uploadArchiveRequestFailed", e;
|
|
16
|
-
}({}), q = /* @__PURE__ */ function(e) {
|
|
17
|
-
return e.Empty = "empty", e.ForbiddenSymbols = "forbiddenSymbols", e.ReservedName = "reservedName", e.TooLong = "tooLong", e.DuplicateName = "duplicateName", e.LeadingDot = "leadingDot", e;
|
|
18
|
-
}({}), J = /* @__PURE__ */ function(e) {
|
|
19
|
-
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e;
|
|
20
|
-
}({}), ie = 3, ae = m, oe = /[/\\]/, se = {
|
|
21
|
-
year: "numeric",
|
|
22
|
-
month: "short",
|
|
23
|
-
day: "2-digit"
|
|
24
|
-
}, ce = [
|
|
25
|
-
G.Name,
|
|
26
|
-
G.UpdatedAt,
|
|
27
|
-
G.Size,
|
|
28
|
-
G.Actions
|
|
29
|
-
], le = [
|
|
30
|
-
G.Name,
|
|
31
|
-
G.UpdatedAt,
|
|
32
|
-
G.Size,
|
|
33
|
-
G.Author,
|
|
34
|
-
G.Actions
|
|
35
|
-
], ue = {
|
|
36
|
-
READ: W.READ,
|
|
37
|
-
WRITE: W.WRITE,
|
|
38
|
-
SHARE: W.SHARE
|
|
39
|
-
}, de = (e) => {
|
|
40
|
-
switch (e) {
|
|
41
|
-
case d.Attach: return u.Attach;
|
|
42
|
-
case d.Standalone: return u.Browse;
|
|
43
|
-
case d.FolderPicker: return u.Full;
|
|
44
|
-
}
|
|
45
|
-
}, Y = (e, t) => {
|
|
46
|
-
if (oe.test(e)) return !0;
|
|
47
|
-
if (t == null) return !1;
|
|
48
|
-
t.lastIndex = 0;
|
|
49
|
-
let n = t.test(e);
|
|
50
|
-
return t.lastIndex = 0, n;
|
|
51
|
-
}, fe = (e) => e.replace(/\/+$/, "") || "/", X = (e, t) => {
|
|
52
|
-
let n = e.split("/").filter(Boolean);
|
|
53
|
-
return n[n.length - 1] ?? t;
|
|
54
|
-
}, pe = (e, t) => fe(e || `/${t}`).replace(/^\/+/, "") || t, me = (e, t) => {
|
|
55
|
-
let n = fe(t);
|
|
56
|
-
for (let r of e) {
|
|
57
|
-
if (r.nodeType !== U.FOLDER) continue;
|
|
58
|
-
if (fe(r.path) === n) return r;
|
|
59
|
-
let e = me(r.items ?? [], t);
|
|
60
|
-
if (e) return e;
|
|
61
|
-
}
|
|
62
|
-
}, he = (e) => e?.permissions?.includes(W.WRITE) ?? !1, ge = (e, t) => {
|
|
63
|
-
for (let n of e) {
|
|
64
|
-
if (n.path === t || n.id === t) return n;
|
|
65
|
-
let e = ge(n.items ?? [], t);
|
|
66
|
-
if (e) return e;
|
|
67
|
-
}
|
|
68
|
-
}, _e = (e) => {
|
|
69
|
-
switch (e) {
|
|
70
|
-
case u.Attach: return !1;
|
|
71
|
-
case u.Browse:
|
|
72
|
-
case u.Full: return !0;
|
|
73
|
-
default: throw Error(`Unhandled actionProfile: ${String(e)}`);
|
|
74
|
-
}
|
|
75
|
-
}, ve = (e) => e === u.Full, ye = (e, t) => {
|
|
76
|
-
let n = e.replace(/\/$/, ""), r = n.lastIndexOf("/");
|
|
77
|
-
if (r <= 0) {
|
|
78
|
-
let e = r === 0 ? n.slice(1) : n;
|
|
79
|
-
return {
|
|
80
|
-
parentVirtualPath: `/${t}`,
|
|
81
|
-
name: e
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
parentVirtualPath: n.slice(0, r),
|
|
86
|
-
name: n.slice(r + 1)
|
|
87
|
-
};
|
|
88
|
-
}, Z = (e, t) => {
|
|
89
|
-
let n = `files/${t}/`;
|
|
90
|
-
return e.startsWith(n) ? e.slice(n.length) : e;
|
|
91
|
-
}, be = (e, t, r) => {
|
|
92
|
-
let i = e.replace(/\/+$/, "").split("/").filter(Boolean).map(n).join("/"), a = i ? `/${t}/${i}` : `/${t}`;
|
|
93
|
-
return r ? `${a}/` : a;
|
|
94
|
-
}, xe = (e, t, n) => {
|
|
95
|
-
if (!e) return {
|
|
96
|
-
bucket: n,
|
|
97
|
-
path: e
|
|
98
|
-
};
|
|
99
|
-
let r = e.indexOf("/"), i = r === -1 ? e : e.slice(0, r), a = t.get(i);
|
|
100
|
-
if (!a) return {
|
|
101
|
-
bucket: n,
|
|
102
|
-
path: e
|
|
103
|
-
};
|
|
104
|
-
let o = Z(a.dialCorePath, a.bucket), s = r === -1 ? "" : e.slice(r + 1);
|
|
105
|
-
return {
|
|
106
|
-
bucket: a.bucket,
|
|
107
|
-
path: o + s
|
|
108
|
-
};
|
|
109
|
-
}, Se = (e) => e.startsWith("files/"), Ce = (e, t) => {
|
|
110
|
-
let r = `files/${t}/`;
|
|
111
|
-
if (e.startsWith(r)) return n(e.slice(r.length));
|
|
112
|
-
if (Se(e)) {
|
|
113
|
-
let r = e.slice(6), i = r.indexOf("/");
|
|
114
|
-
if (i >= 0) {
|
|
115
|
-
let e = r.slice(0, i), a = r.slice(i + 1);
|
|
116
|
-
if (e === t) return n(a);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return e;
|
|
120
|
-
}, Q = (e, t) => {
|
|
121
|
-
let n = `/${t}`, r = `/${t}/`, i = `${t}/`;
|
|
122
|
-
if (e === n || e === `${t}` || e === r || e === i) return "";
|
|
123
|
-
let a;
|
|
124
|
-
if (e.startsWith(r)) a = e.slice(r.length);
|
|
125
|
-
else if (e.startsWith(i)) a = e.slice(i.length);
|
|
126
|
-
else {
|
|
127
|
-
let t = e.replace(/^\//, "");
|
|
128
|
-
a = t.startsWith(i) ? t.slice(i.length) : t;
|
|
129
|
-
}
|
|
130
|
-
let o = a.replace(/\/{2,}/g, "/");
|
|
131
|
-
return o && !o.endsWith("/") ? `${o}/` : o;
|
|
132
|
-
}, we = (e, t) => e.startsWith("/") || e === t || e.startsWith(`${t}/`), Te = (e, t, n) => {
|
|
133
|
-
let r = e.nodeType === U.FOLDER, i = e.id ? Ce(e.id, t) : null, a = i != null && !we(i, n) ? i : Q(e.path, n);
|
|
134
|
-
return r ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, "");
|
|
135
|
-
}, Ee = (e, t, n) => e.map((e) => {
|
|
136
|
-
let r = e.nodeType === U.FOLDER, i = Q(e.sourceUrl, n), a = Q(e.destinationUrl, n), o = X(e.sourceUrl, i);
|
|
137
|
-
return {
|
|
138
|
-
destinationName: X(e.destinationUrl, a),
|
|
139
|
-
dto: {
|
|
140
|
-
bucket: t,
|
|
141
|
-
sourcePath: r ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, ""),
|
|
142
|
-
destinationPath: r ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, ""),
|
|
143
|
-
overwrite: e.overwrite === !0,
|
|
144
|
-
nodeType: r ? F.Folder : F.Item,
|
|
145
|
-
name: o
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}), De = (e, t, n) => {
|
|
149
|
-
let r = e.map((e) => {
|
|
150
|
-
let t = e.nodeType === U.FOLDER, r = Q(e.sourceUrl, n), i = Q(e.destinationUrl, n), a = X(e.sourceUrl, r), o = X(e.destinationUrl, i), s = t ? r.endsWith("/") ? r : `${r}/` : r.replace(/\/$/, ""), c = t ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, "");
|
|
151
|
-
return {
|
|
152
|
-
isFolder: t,
|
|
153
|
-
name: a,
|
|
154
|
-
destinationName: o,
|
|
155
|
-
overwrite: e.overwrite === !0,
|
|
156
|
-
sourcePath: s,
|
|
157
|
-
destinationPath: c,
|
|
158
|
-
sourceParent: v(s),
|
|
159
|
-
destinationParent: v(c)
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
return {
|
|
163
|
-
renameDtos: r.filter((e) => e.sourceParent === e.destinationParent).map((e) => ({
|
|
164
|
-
bucket: t,
|
|
165
|
-
sourcePath: e.sourcePath,
|
|
166
|
-
destinationPath: e.destinationPath,
|
|
167
|
-
nodeType: e.isFolder ? R.Folder : R.Item,
|
|
168
|
-
name: e.name
|
|
169
|
-
})),
|
|
170
|
-
preparedMoveItems: r.filter((e) => e.sourceParent !== e.destinationParent).map((e) => ({
|
|
171
|
-
destinationName: e.destinationName,
|
|
172
|
-
dto: {
|
|
173
|
-
bucket: t,
|
|
174
|
-
sourcePath: e.sourcePath,
|
|
175
|
-
destinationPath: e.destinationPath,
|
|
176
|
-
overwrite: e.overwrite,
|
|
177
|
-
nodeType: e.isFolder ? L.Folder : L.Item,
|
|
178
|
-
name: e.name
|
|
179
|
-
}
|
|
180
|
-
}))
|
|
181
|
-
};
|
|
182
|
-
}, Oe = (e) => {
|
|
183
|
-
if (!e?.length) return;
|
|
184
|
-
let t = e.map((e) => ue[e.toUpperCase()]).filter((e) => e != null);
|
|
185
|
-
return t.length > 0 ? t : void 0;
|
|
186
|
-
}, ke = (e, t) => {
|
|
187
|
-
let n = t.find((e) => e.success);
|
|
188
|
-
if (n != null) return e.find(({ dto: e }) => e.sourcePath === n.sourcePath && e.destinationPath === n.destinationPath) ?? e.find(({ dto: e }) => e.destinationPath === n.destinationPath) ?? e[0];
|
|
189
|
-
}, Ae = (e, t, n, r, i) => {
|
|
190
|
-
let a = e.get(n);
|
|
191
|
-
if (a == null) return [];
|
|
192
|
-
let o = r.replace(/\/$/, "");
|
|
193
|
-
return a.map((a) => {
|
|
194
|
-
let s = a.nodeType === ee.Folder, c = a.name, l = s ? `${o}/${c}/` : `${o}/${c}`, u = {
|
|
195
|
-
id: a.path,
|
|
196
|
-
name: c,
|
|
197
|
-
path: l,
|
|
198
|
-
url: a.url,
|
|
199
|
-
parentPath: r,
|
|
200
|
-
nodeType: s ? U.FOLDER : U.ITEM,
|
|
201
|
-
folderId: i,
|
|
202
|
-
bucket: a.bucket,
|
|
203
|
-
author: a.author,
|
|
204
|
-
resourceType: a.resourceType,
|
|
205
|
-
contentLength: a.contentLength,
|
|
206
|
-
contentType: a.contentType,
|
|
207
|
-
updatedAt: a.updatedAt ? new Date(a.updatedAt).toISOString() : void 0
|
|
208
|
-
};
|
|
209
|
-
if (s) {
|
|
210
|
-
let r = `${n}${c}/`;
|
|
211
|
-
u.permissions = Oe(a.permissions) ?? Oe(t.get(r)), u.items = Ae(e, t, r, l, a.path);
|
|
212
|
-
}
|
|
213
|
-
return u;
|
|
214
|
-
});
|
|
215
|
-
}, je = (e, t, n, r) => {
|
|
216
|
-
let i = new Map(e), a = [...i.get(t) ?? []], o = {
|
|
217
|
-
name: n.name,
|
|
218
|
-
path: n.path,
|
|
219
|
-
folderId: n.folderId,
|
|
220
|
-
nodeType: ee.Folder,
|
|
221
|
-
bucket: n.bucket,
|
|
222
|
-
parentPath: n.parentPath || void 0,
|
|
223
|
-
url: n.path,
|
|
224
|
-
permissions: r
|
|
225
|
-
};
|
|
226
|
-
return a.some((e) => e.name.toLowerCase() === n.name.toLowerCase()) || a.push(o), i.set(t, a), i;
|
|
227
|
-
}, Me = (e, t, n) => {
|
|
228
|
-
if (!e) return e;
|
|
229
|
-
let r = typeof n == "string" ? { status: n } : n, i = e.files.map((e, n) => n === t ? {
|
|
230
|
-
...e,
|
|
231
|
-
...r
|
|
232
|
-
} : e);
|
|
233
|
-
return {
|
|
234
|
-
...e,
|
|
235
|
-
files: i
|
|
236
|
-
};
|
|
237
|
-
}, Ne = (e, t, n, r, i) => {
|
|
238
|
-
if (t === H.Shared) {
|
|
239
|
-
if (r === "") return e.listSharedFiles({ path: void 0 }).then((e) => ({ items: e.items }));
|
|
240
|
-
let t = r.indexOf("/"), n = t === -1 ? r : r.slice(0, t), a = i.get(n);
|
|
241
|
-
if (a) {
|
|
242
|
-
let n = Z(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1));
|
|
243
|
-
return e.listFiles({
|
|
244
|
-
bucket: a.bucket,
|
|
245
|
-
path: n,
|
|
246
|
-
permissions: !0
|
|
247
|
-
}).then((e) => ({
|
|
248
|
-
items: e.items,
|
|
249
|
-
permissions: e.permissions
|
|
250
|
-
}));
|
|
251
|
-
}
|
|
252
|
-
return Promise.resolve({ items: [] });
|
|
253
|
-
}
|
|
254
|
-
return t === H.Organization ? e.listPublicFiles({ path: r || void 0 }).then((e) => ({ items: e.items })) : e.listFiles({
|
|
255
|
-
bucket: n,
|
|
256
|
-
path: r,
|
|
257
|
-
permissions: !0
|
|
258
|
-
}).then((e) => ({
|
|
259
|
-
items: e.items,
|
|
260
|
-
permissions: e.permissions
|
|
261
|
-
}));
|
|
262
|
-
}, Pe = async (e, t, n, r, i) => {
|
|
263
|
-
if (t === H.Shared) {
|
|
264
|
-
let t = r.indexOf("/"), n = t === -1 ? r : r.slice(0, t), a = i.get(n);
|
|
265
|
-
if (!a) return { items: [] };
|
|
266
|
-
let o = Z(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1)), { items: s } = await e.listFiles({
|
|
267
|
-
bucket: a.bucket,
|
|
268
|
-
path: o,
|
|
269
|
-
permissions: !0,
|
|
270
|
-
recursive: !0
|
|
271
|
-
});
|
|
272
|
-
return { items: s };
|
|
273
|
-
}
|
|
274
|
-
if (t === H.Organization) {
|
|
275
|
-
let { items: t } = await e.listPublicFiles({
|
|
276
|
-
path: r || void 0,
|
|
277
|
-
recursive: !0
|
|
278
|
-
});
|
|
279
|
-
return { items: t };
|
|
280
|
-
}
|
|
281
|
-
let { items: a } = await e.listFiles({
|
|
282
|
-
bucket: n,
|
|
283
|
-
path: r,
|
|
284
|
-
permissions: !0,
|
|
285
|
-
recursive: !0
|
|
286
|
-
});
|
|
287
|
-
return { items: a };
|
|
288
|
-
}, Fe = (e, t, n) => {
|
|
289
|
-
let r = e.nodeType === ee.Folder, i = e.name, a = e.bucket ?? t, o = Z(e.url ?? e.path ?? "", a).replace(/\/$/, ""), s = o.lastIndexOf("/"), c = be(s > 0 ? o.slice(0, s) : "", n, !1), l = r ? `${c}/${i}/` : `${c}/${i}`;
|
|
290
|
-
return {
|
|
291
|
-
id: e.path,
|
|
292
|
-
name: i,
|
|
293
|
-
path: l,
|
|
294
|
-
url: e.url,
|
|
295
|
-
parentPath: c,
|
|
296
|
-
nodeType: r ? U.FOLDER : U.ITEM,
|
|
297
|
-
folderId: e.folderId,
|
|
298
|
-
bucket: a,
|
|
299
|
-
author: e.author,
|
|
300
|
-
contentLength: e.contentLength,
|
|
301
|
-
contentType: e.contentType,
|
|
302
|
-
updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : void 0
|
|
303
|
-
};
|
|
304
|
-
}, Ie = (e, t) => ({
|
|
305
|
-
...t,
|
|
306
|
-
bucket: e.bucket ?? t.bucket,
|
|
307
|
-
author: e.author,
|
|
308
|
-
contentLength: e.contentLength,
|
|
309
|
-
contentType: e.contentType,
|
|
310
|
-
resourceType: e.resourceType ?? t.resourceType,
|
|
311
|
-
permissions: Oe(e.permissions) ?? t.permissions,
|
|
312
|
-
updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : t.updatedAt,
|
|
313
|
-
createdAt: e.createdAt ? new Date(e.createdAt).toISOString() : t.createdAt
|
|
314
|
-
}), Le = (e) => e instanceof AbortSignal ? { signal: e } : e ?? {}, Re = (e, t) => ({
|
|
315
|
-
listPublicFiles: (t) => e.listPublicFiles(t),
|
|
316
|
-
listSharedFiles: (t) => e.listSharedFiles(t),
|
|
317
|
-
listFiles: (t, n) => e.listFiles(t, n ? { signal: n } : void 0),
|
|
318
|
-
uploadFile: (n, r, i, a) => {
|
|
319
|
-
let { signal: o, onProgress: s, uploadMode: c } = Le(a);
|
|
320
|
-
return s == null ? e.uploadFile({
|
|
321
|
-
bucket: n,
|
|
322
|
-
path: r,
|
|
323
|
-
file: i,
|
|
324
|
-
uploadMode: c
|
|
325
|
-
}, o ? { signal: o } : void 0) : t(n, r, i, {
|
|
326
|
-
signal: o,
|
|
327
|
-
onProgress: s,
|
|
328
|
-
uploadMode: c
|
|
329
|
-
});
|
|
330
|
-
},
|
|
331
|
-
uploadArchive: (t, n, r) => e.uploadArchive({
|
|
332
|
-
file: t,
|
|
333
|
-
bucket: n,
|
|
334
|
-
destinationPath: r
|
|
335
|
-
}),
|
|
336
|
-
getFileMetadata: (t) => e.getFileMetadata(t),
|
|
337
|
-
downloadFile: async (t, n, r) => (await e.downloadFileRaw({
|
|
338
|
-
bucket: t,
|
|
339
|
-
path: n
|
|
340
|
-
}, ...r ? [{ signal: r }] : [])).raw,
|
|
341
|
-
createFolder: (t) => e.createFolder({ createFolderDto: t }),
|
|
342
|
-
deleteFiles: (t) => e.deleteFiles({ deleteFilesDto: { items: t } }),
|
|
343
|
-
renameFiles: (t) => e.renameFiles({ renameFilesDto: { items: t } }),
|
|
344
|
-
copyFiles: (t, n) => e.copyFiles({ copyFilesDto: { items: t } }, n ? { signal: n } : void 0),
|
|
345
|
-
moveFiles: (t, n) => e.moveFiles({ moveFilesDto: { items: t } }, n ? { signal: n } : void 0),
|
|
346
|
-
downloadArchive: async (t) => (await e.downloadArchiveRaw({ downloadArchiveDto: { items: t } })).raw,
|
|
347
|
-
revokeAccess: (t) => e.revokeAccess({ revokeAccessDto: { items: t } }),
|
|
348
|
-
discardShared: (t) => e.discardShared({ discardSharedDto: { items: t } }),
|
|
349
|
-
listSharedByMe: (t) => e.listSharedByMe({ bucket: t })
|
|
350
|
-
}), ze = (e) => {
|
|
351
|
-
let { uploadUrl: t, xhrFactory: n = () => new XMLHttpRequest() } = e;
|
|
352
|
-
return (r, i, a, { signal: o, onProgress: s, uploadMode: c } = {}) => new Promise((l, u) => {
|
|
353
|
-
let d = n();
|
|
354
|
-
d.open("POST", t), d.withCredentials = !0;
|
|
355
|
-
let f = e.getCsrfToken();
|
|
356
|
-
f != null && d.setRequestHeader("X-CSRF-Token", f);
|
|
357
|
-
let p = new FormData();
|
|
358
|
-
if (p.append("file", a), p.append("bucket", r), p.append("path", i), c != null && p.append("uploadMode", c), d.upload.addEventListener("progress", (e) => {
|
|
359
|
-
!s || !e.lengthComputable || e.total <= 0 || s(Math.min(100, Math.round(e.loaded / e.total * 100)));
|
|
360
|
-
}), d.addEventListener("load", () => {
|
|
361
|
-
let n = d.getResponseHeader("x-csrf-token");
|
|
362
|
-
if (n && e.setCsrfToken(n), d.status >= 200 && d.status < 300) {
|
|
363
|
-
try {
|
|
364
|
-
l(JSON.parse(d.responseText));
|
|
365
|
-
} catch {
|
|
366
|
-
u(/* @__PURE__ */ Error("Upload response was not valid JSON"));
|
|
367
|
-
}
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (d.status === 401) {
|
|
371
|
-
e.notifyUnauthorized(t), u(e.createUnauthorizedError(t));
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
u(/* @__PURE__ */ Error(`Upload failed with status ${d.status}`));
|
|
375
|
-
}), d.addEventListener("error", () => {
|
|
376
|
-
u(/* @__PURE__ */ Error("Upload failed"));
|
|
377
|
-
}), d.addEventListener("abort", () => {
|
|
378
|
-
u(new DOMException("Upload aborted", "AbortError"));
|
|
379
|
-
}), o != null) {
|
|
380
|
-
if (o.aborted) {
|
|
381
|
-
d.abort();
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
o.addEventListener("abort", () => d.abort(), { once: !0 });
|
|
385
|
-
}
|
|
386
|
-
d.send(p);
|
|
387
|
-
});
|
|
388
|
-
}, Be = (t, n) => {
|
|
389
|
-
let { url: r } = t;
|
|
390
|
-
if (r == null) return;
|
|
391
|
-
let i = r.split("#")[0];
|
|
392
|
-
if (e(i)) {
|
|
393
|
-
let e = n(i);
|
|
394
|
-
if (e == null) return;
|
|
395
|
-
S(e, t.title ?? i.split("/").pop() ?? "");
|
|
396
|
-
} else window.open(r, "_blank", "noopener,noreferrer");
|
|
397
|
-
}, Ve = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, He = /* @__PURE__ */ new Set(), Ue = typeof process == "object" && process ? process : {}, We = (e, t, n, r) => {
|
|
398
|
-
typeof Ue.emitWarning == "function" ? Ue.emitWarning(e, t, n, r) : console.error(`[${n}] ${t}: ${e}`);
|
|
399
|
-
}, Ge = globalThis.AbortController, Ke = globalThis.AbortSignal;
|
|
400
|
-
/* c8 ignore start */
|
|
401
|
-
if (Ge === void 0) {
|
|
402
|
-
Ke = class {
|
|
403
|
-
onabort;
|
|
404
|
-
_onabort = [];
|
|
405
|
-
reason;
|
|
406
|
-
aborted = !1;
|
|
407
|
-
addEventListener(e, t) {
|
|
408
|
-
this._onabort.push(t);
|
|
409
|
-
}
|
|
410
|
-
}, Ge = class {
|
|
411
|
-
constructor() {
|
|
412
|
-
t();
|
|
413
|
-
}
|
|
414
|
-
signal = new Ke();
|
|
415
|
-
abort(e) {
|
|
416
|
-
if (!this.signal.aborted) {
|
|
417
|
-
this.signal.reason = e, this.signal.aborted = !0;
|
|
418
|
-
for (let t of this.signal._onabort) t(e);
|
|
419
|
-
this.signal.onabort?.(e);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
let e = Ue.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
|
|
424
|
-
e && (e = !1, We("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
/* c8 ignore stop */
|
|
428
|
-
var qe = (e) => !He.has(e), $ = (e) => e && e === Math.floor(e) && e > 0 && isFinite(e), Je = (e) => $(e) ? e <= 2 ** 8 ? Uint8Array : e <= 2 ** 16 ? Uint16Array : e <= 2 ** 32 ? Uint32Array : e <= 2 ** 53 - 1 ? Ye : null : null, Ye = class extends Array {
|
|
429
|
-
constructor(e) {
|
|
430
|
-
super(e), this.fill(0);
|
|
431
|
-
}
|
|
432
|
-
}, Xe = class e {
|
|
433
|
-
heap;
|
|
434
|
-
length;
|
|
435
|
-
static #e = !1;
|
|
436
|
-
static create(t) {
|
|
437
|
-
let n = Je(t);
|
|
438
|
-
if (!n) return [];
|
|
439
|
-
e.#e = !0;
|
|
440
|
-
let r = new e(t, n);
|
|
441
|
-
return e.#e = !1, r;
|
|
442
|
-
}
|
|
443
|
-
constructor(t, n) {
|
|
444
|
-
/* c8 ignore start */
|
|
445
|
-
if (!e.#e) throw TypeError("instantiate Stack using Stack.create(n)");
|
|
446
|
-
this.heap = new n(t), this.length = 0;
|
|
447
|
-
}
|
|
448
|
-
push(e) {
|
|
449
|
-
this.heap[this.length++] = e;
|
|
450
|
-
}
|
|
451
|
-
pop() {
|
|
452
|
-
return this.heap[--this.length];
|
|
453
|
-
}
|
|
454
|
-
}, Ze = class e {
|
|
455
|
-
#e;
|
|
456
|
-
#t;
|
|
457
|
-
#n;
|
|
458
|
-
#r;
|
|
459
|
-
#i;
|
|
460
|
-
#a;
|
|
461
|
-
ttl;
|
|
462
|
-
ttlResolution;
|
|
463
|
-
ttlAutopurge;
|
|
464
|
-
updateAgeOnGet;
|
|
465
|
-
updateAgeOnHas;
|
|
466
|
-
allowStale;
|
|
467
|
-
noDisposeOnSet;
|
|
468
|
-
noUpdateTTL;
|
|
469
|
-
maxEntrySize;
|
|
470
|
-
sizeCalculation;
|
|
471
|
-
noDeleteOnFetchRejection;
|
|
472
|
-
noDeleteOnStaleGet;
|
|
473
|
-
allowStaleOnFetchAbort;
|
|
474
|
-
allowStaleOnFetchRejection;
|
|
475
|
-
ignoreFetchAbort;
|
|
476
|
-
#o;
|
|
477
|
-
#s;
|
|
478
|
-
#c;
|
|
479
|
-
#l;
|
|
480
|
-
#u;
|
|
481
|
-
#d;
|
|
482
|
-
#f;
|
|
483
|
-
#p;
|
|
484
|
-
#m;
|
|
485
|
-
#h;
|
|
486
|
-
#g;
|
|
487
|
-
#_;
|
|
488
|
-
#v;
|
|
489
|
-
#y;
|
|
490
|
-
#b;
|
|
491
|
-
#x;
|
|
492
|
-
#S;
|
|
493
|
-
static unsafeExposeInternals(e) {
|
|
494
|
-
return {
|
|
495
|
-
starts: e.#v,
|
|
496
|
-
ttls: e.#y,
|
|
497
|
-
sizes: e.#_,
|
|
498
|
-
keyMap: e.#c,
|
|
499
|
-
keyList: e.#l,
|
|
500
|
-
valList: e.#u,
|
|
501
|
-
next: e.#d,
|
|
502
|
-
prev: e.#f,
|
|
503
|
-
get head() {
|
|
504
|
-
return e.#p;
|
|
505
|
-
},
|
|
506
|
-
get tail() {
|
|
507
|
-
return e.#m;
|
|
508
|
-
},
|
|
509
|
-
free: e.#h,
|
|
510
|
-
isBackgroundFetch: (t) => e.#L(t),
|
|
511
|
-
backgroundFetch: (t, n, r, i) => e.#I(t, n, r, i),
|
|
512
|
-
moveToTail: (t) => e.#z(t),
|
|
513
|
-
indexes: (t) => e.#M(t),
|
|
514
|
-
rindexes: (t) => e.#N(t),
|
|
515
|
-
isStale: (t) => e.#D(t)
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
get max() {
|
|
519
|
-
return this.#e;
|
|
520
|
-
}
|
|
521
|
-
get maxSize() {
|
|
522
|
-
return this.#t;
|
|
523
|
-
}
|
|
524
|
-
get calculatedSize() {
|
|
525
|
-
return this.#s;
|
|
526
|
-
}
|
|
527
|
-
get size() {
|
|
528
|
-
return this.#o;
|
|
529
|
-
}
|
|
530
|
-
get fetchMethod() {
|
|
531
|
-
return this.#i;
|
|
532
|
-
}
|
|
533
|
-
get memoMethod() {
|
|
534
|
-
return this.#a;
|
|
535
|
-
}
|
|
536
|
-
get dispose() {
|
|
537
|
-
return this.#n;
|
|
538
|
-
}
|
|
539
|
-
get disposeAfter() {
|
|
540
|
-
return this.#r;
|
|
541
|
-
}
|
|
542
|
-
constructor(t) {
|
|
543
|
-
let { max: n = 0, ttl: r, ttlResolution: i = 1, ttlAutopurge: a, updateAgeOnGet: o, updateAgeOnHas: s, allowStale: c, dispose: l, disposeAfter: u, noDisposeOnSet: d, noUpdateTTL: f, maxSize: p = 0, maxEntrySize: m = 0, sizeCalculation: h, fetchMethod: g, memoMethod: _, noDeleteOnFetchRejection: v, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: x, ignoreFetchAbort: S } = t;
|
|
544
|
-
if (n !== 0 && !$(n)) throw TypeError("max option must be a nonnegative integer");
|
|
545
|
-
let C = n ? Je(n) : Array;
|
|
546
|
-
if (!C) throw Error("invalid max value: " + n);
|
|
547
|
-
if (this.#e = n, this.#t = p, this.maxEntrySize = m || this.#t, this.sizeCalculation = h, this.sizeCalculation) {
|
|
548
|
-
if (!this.#t && !this.maxEntrySize) throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
549
|
-
if (typeof this.sizeCalculation != "function") throw TypeError("sizeCalculation set to non-function");
|
|
550
|
-
}
|
|
551
|
-
if (_ !== void 0 && typeof _ != "function") throw TypeError("memoMethod must be a function if defined");
|
|
552
|
-
if (this.#a = _, g !== void 0 && typeof g != "function") throw TypeError("fetchMethod must be a function if specified");
|
|
553
|
-
if (this.#i = g, this.#x = !!g, this.#c = /* @__PURE__ */ new Map(), this.#l = Array(n).fill(void 0), this.#u = Array(n).fill(void 0), this.#d = new C(n), this.#f = new C(n), this.#p = 0, this.#m = 0, this.#h = Xe.create(n), this.#o = 0, this.#s = 0, typeof l == "function" && (this.#n = l), typeof u == "function" ? (this.#r = u, this.#g = []) : (this.#r = void 0, this.#g = void 0), this.#b = !!this.#n, this.#S = !!this.#r, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!v, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!x, this.ignoreFetchAbort = !!S, this.maxEntrySize !== 0) {
|
|
554
|
-
if (this.#t !== 0 && !$(this.#t)) throw TypeError("maxSize must be a positive integer if specified");
|
|
555
|
-
if (!$(this.maxEntrySize)) throw TypeError("maxEntrySize must be a positive integer if specified");
|
|
556
|
-
this.#O();
|
|
557
|
-
}
|
|
558
|
-
if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!s, this.ttlResolution = $(i) || i === 0 ? i : 1, this.ttlAutopurge = !!a, this.ttl = r || 0, this.ttl) {
|
|
559
|
-
if (!$(this.ttl)) throw TypeError("ttl must be a positive integer if specified");
|
|
560
|
-
this.#C();
|
|
561
|
-
}
|
|
562
|
-
if (this.#e === 0 && this.ttl === 0 && this.#t === 0) throw TypeError("At least one of max, maxSize, or ttl is required");
|
|
563
|
-
if (!this.ttlAutopurge && !this.#e && !this.#t) {
|
|
564
|
-
let t = "LRU_CACHE_UNBOUNDED";
|
|
565
|
-
qe(t) && (He.add(t), We("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", t, e));
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
getRemainingTTL(e) {
|
|
569
|
-
return this.#c.has(e) ? Infinity : 0;
|
|
570
|
-
}
|
|
571
|
-
#C() {
|
|
572
|
-
let e = new Ye(this.#e), t = new Ye(this.#e);
|
|
573
|
-
this.#y = e, this.#v = t, this.#E = (n, r, i = Ve.now()) => {
|
|
574
|
-
if (t[n] = r === 0 ? 0 : i, e[n] = r, r !== 0 && this.ttlAutopurge) {
|
|
575
|
-
let e = setTimeout(() => {
|
|
576
|
-
this.#D(n) && this.#B(this.#l[n], "expire");
|
|
577
|
-
}, r + 1);
|
|
578
|
-
/* c8 ignore start */
|
|
579
|
-
e.unref && e.unref();
|
|
580
|
-
}
|
|
581
|
-
}, this.#w = (n) => {
|
|
582
|
-
t[n] = e[n] === 0 ? 0 : Ve.now();
|
|
583
|
-
}, this.#T = (i, a) => {
|
|
584
|
-
if (e[a]) {
|
|
585
|
-
let o = e[a], s = t[a];
|
|
586
|
-
/* c8 ignore next */
|
|
587
|
-
if (!o || !s) return;
|
|
588
|
-
i.ttl = o, i.start = s, i.now = n || r(), i.remainingTTL = o - (i.now - s);
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
let n = 0, r = () => {
|
|
592
|
-
let e = Ve.now();
|
|
593
|
-
if (this.ttlResolution > 0) {
|
|
594
|
-
n = e;
|
|
595
|
-
let t = setTimeout(() => n = 0, this.ttlResolution);
|
|
596
|
-
/* c8 ignore start */
|
|
597
|
-
t.unref && t.unref();
|
|
598
|
-
}
|
|
599
|
-
return e;
|
|
600
|
-
};
|
|
601
|
-
this.getRemainingTTL = (i) => {
|
|
602
|
-
let a = this.#c.get(i);
|
|
603
|
-
if (a === void 0) return 0;
|
|
604
|
-
let o = e[a], s = t[a];
|
|
605
|
-
return !o || !s ? Infinity : o - ((n || r()) - s);
|
|
606
|
-
}, this.#D = (i) => {
|
|
607
|
-
let a = t[i], o = e[i];
|
|
608
|
-
return !!o && !!a && (n || r()) - a > o;
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
#w = () => {};
|
|
612
|
-
#T = () => {};
|
|
613
|
-
#E = () => {};
|
|
614
|
-
/* c8 ignore stop */
|
|
615
|
-
#D = () => !1;
|
|
616
|
-
#O() {
|
|
617
|
-
let e = new Ye(this.#e);
|
|
618
|
-
this.#s = 0, this.#_ = e, this.#k = (t) => {
|
|
619
|
-
this.#s -= e[t], e[t] = 0;
|
|
620
|
-
}, this.#j = (e, t, n, r) => {
|
|
621
|
-
if (this.#L(t)) return 0;
|
|
622
|
-
if (!$(n)) if (r) {
|
|
623
|
-
if (typeof r != "function") throw TypeError("sizeCalculation must be a function");
|
|
624
|
-
if (n = r(t, e), !$(n)) throw TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
625
|
-
} else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
626
|
-
return n;
|
|
627
|
-
}, this.#A = (t, n, r) => {
|
|
628
|
-
if (e[t] = n, this.#t) {
|
|
629
|
-
let n = this.#t - e[t];
|
|
630
|
-
for (; this.#s > n;) this.#F(!0);
|
|
631
|
-
}
|
|
632
|
-
this.#s += e[t], r && (r.entrySize = n, r.totalCalculatedSize = this.#s);
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
#k = (e) => {};
|
|
636
|
-
#A = (e, t, n) => {};
|
|
637
|
-
#j = (e, t, n, r) => {
|
|
638
|
-
if (n || r) throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
639
|
-
return 0;
|
|
640
|
-
};
|
|
641
|
-
*#M({ allowStale: e = this.allowStale } = {}) {
|
|
642
|
-
if (this.#o) for (let t = this.#m; !(!this.#P(t) || ((e || !this.#D(t)) && (yield t), t === this.#p));) t = this.#f[t];
|
|
643
|
-
}
|
|
644
|
-
*#N({ allowStale: e = this.allowStale } = {}) {
|
|
645
|
-
if (this.#o) for (let t = this.#p; !(!this.#P(t) || ((e || !this.#D(t)) && (yield t), t === this.#m));) t = this.#d[t];
|
|
646
|
-
}
|
|
647
|
-
#P(e) {
|
|
648
|
-
return e !== void 0 && this.#c.get(this.#l[e]) === e;
|
|
649
|
-
}
|
|
650
|
-
*entries() {
|
|
651
|
-
for (let e of this.#M()) this.#u[e] !== void 0 && this.#l[e] !== void 0 && !this.#L(this.#u[e]) && (yield [this.#l[e], this.#u[e]]);
|
|
652
|
-
}
|
|
653
|
-
*rentries() {
|
|
654
|
-
for (let e of this.#N()) this.#u[e] !== void 0 && this.#l[e] !== void 0 && !this.#L(this.#u[e]) && (yield [this.#l[e], this.#u[e]]);
|
|
655
|
-
}
|
|
656
|
-
*keys() {
|
|
657
|
-
for (let e of this.#M()) {
|
|
658
|
-
let t = this.#l[e];
|
|
659
|
-
t !== void 0 && !this.#L(this.#u[e]) && (yield t);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
*rkeys() {
|
|
663
|
-
for (let e of this.#N()) {
|
|
664
|
-
let t = this.#l[e];
|
|
665
|
-
t !== void 0 && !this.#L(this.#u[e]) && (yield t);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
*values() {
|
|
669
|
-
for (let e of this.#M()) this.#u[e] !== void 0 && !this.#L(this.#u[e]) && (yield this.#u[e]);
|
|
670
|
-
}
|
|
671
|
-
*rvalues() {
|
|
672
|
-
for (let e of this.#N()) this.#u[e] !== void 0 && !this.#L(this.#u[e]) && (yield this.#u[e]);
|
|
673
|
-
}
|
|
674
|
-
[Symbol.iterator]() {
|
|
675
|
-
return this.entries();
|
|
676
|
-
}
|
|
677
|
-
[Symbol.toStringTag] = "LRUCache";
|
|
678
|
-
find(e, t = {}) {
|
|
679
|
-
for (let n of this.#M()) {
|
|
680
|
-
let r = this.#u[n], i = this.#L(r) ? r.__staleWhileFetching : r;
|
|
681
|
-
if (i !== void 0 && e(i, this.#l[n], this)) return this.get(this.#l[n], t);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
forEach(e, t = this) {
|
|
685
|
-
for (let n of this.#M()) {
|
|
686
|
-
let r = this.#u[n], i = this.#L(r) ? r.__staleWhileFetching : r;
|
|
687
|
-
i !== void 0 && e.call(t, i, this.#l[n], this);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
rforEach(e, t = this) {
|
|
691
|
-
for (let n of this.#N()) {
|
|
692
|
-
let r = this.#u[n], i = this.#L(r) ? r.__staleWhileFetching : r;
|
|
693
|
-
i !== void 0 && e.call(t, i, this.#l[n], this);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
purgeStale() {
|
|
697
|
-
let e = !1;
|
|
698
|
-
for (let t of this.#N({ allowStale: !0 })) this.#D(t) && (this.#B(this.#l[t], "expire"), e = !0);
|
|
699
|
-
return e;
|
|
700
|
-
}
|
|
701
|
-
info(e) {
|
|
702
|
-
let t = this.#c.get(e);
|
|
703
|
-
if (t === void 0) return;
|
|
704
|
-
let n = this.#u[t], r = this.#L(n) ? n.__staleWhileFetching : n;
|
|
705
|
-
if (r === void 0) return;
|
|
706
|
-
let i = { value: r };
|
|
707
|
-
if (this.#y && this.#v) {
|
|
708
|
-
let e = this.#y[t], n = this.#v[t];
|
|
709
|
-
e && n && (i.ttl = e - (Ve.now() - n), i.start = Date.now());
|
|
710
|
-
}
|
|
711
|
-
return this.#_ && (i.size = this.#_[t]), i;
|
|
712
|
-
}
|
|
713
|
-
dump() {
|
|
714
|
-
let e = [];
|
|
715
|
-
for (let t of this.#M({ allowStale: !0 })) {
|
|
716
|
-
let n = this.#l[t], r = this.#u[t], i = this.#L(r) ? r.__staleWhileFetching : r;
|
|
717
|
-
if (i === void 0 || n === void 0) continue;
|
|
718
|
-
let a = { value: i };
|
|
719
|
-
if (this.#y && this.#v) {
|
|
720
|
-
a.ttl = this.#y[t];
|
|
721
|
-
let e = Ve.now() - this.#v[t];
|
|
722
|
-
a.start = Math.floor(Date.now() - e);
|
|
723
|
-
}
|
|
724
|
-
this.#_ && (a.size = this.#_[t]), e.unshift([n, a]);
|
|
725
|
-
}
|
|
726
|
-
return e;
|
|
727
|
-
}
|
|
728
|
-
load(e) {
|
|
729
|
-
this.clear();
|
|
730
|
-
for (let [t, n] of e) {
|
|
731
|
-
if (n.start) {
|
|
732
|
-
let e = Date.now() - n.start;
|
|
733
|
-
n.start = Ve.now() - e;
|
|
734
|
-
}
|
|
735
|
-
this.set(t, n.value, n);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
set(e, t, n = {}) {
|
|
739
|
-
if (t === void 0) return this.delete(e), this;
|
|
740
|
-
let { ttl: r = this.ttl, start: i, noDisposeOnSet: a = this.noDisposeOnSet, sizeCalculation: o = this.sizeCalculation, status: s } = n, { noUpdateTTL: c = this.noUpdateTTL } = n, l = this.#j(e, t, n.size || 0, o);
|
|
741
|
-
if (this.maxEntrySize && l > this.maxEntrySize) return s && (s.set = "miss", s.maxEntrySizeExceeded = !0), this.#B(e, "set"), this;
|
|
742
|
-
let u = this.#o === 0 ? void 0 : this.#c.get(e);
|
|
743
|
-
if (u === void 0) u = this.#o === 0 ? this.#m : this.#h.length === 0 ? this.#o === this.#e ? this.#F(!1) : this.#o : this.#h.pop(), this.#l[u] = e, this.#u[u] = t, this.#c.set(e, u), this.#d[this.#m] = u, this.#f[u] = this.#m, this.#m = u, this.#o++, this.#A(u, l, s), s && (s.set = "add"), c = !1;
|
|
744
|
-
else {
|
|
745
|
-
this.#z(u);
|
|
746
|
-
let n = this.#u[u];
|
|
747
|
-
if (t !== n) {
|
|
748
|
-
if (this.#x && this.#L(n)) {
|
|
749
|
-
n.__abortController.abort(/* @__PURE__ */ Error("replaced"));
|
|
750
|
-
let { __staleWhileFetching: t } = n;
|
|
751
|
-
t !== void 0 && !a && (this.#b && this.#n?.(t, e, "set"), this.#S && this.#g?.push([
|
|
752
|
-
t,
|
|
753
|
-
e,
|
|
754
|
-
"set"
|
|
755
|
-
]));
|
|
756
|
-
} else a || (this.#b && this.#n?.(n, e, "set"), this.#S && this.#g?.push([
|
|
757
|
-
n,
|
|
758
|
-
e,
|
|
759
|
-
"set"
|
|
760
|
-
]));
|
|
761
|
-
if (this.#k(u), this.#A(u, l, s), this.#u[u] = t, s) {
|
|
762
|
-
s.set = "replace";
|
|
763
|
-
let e = n && this.#L(n) ? n.__staleWhileFetching : n;
|
|
764
|
-
e !== void 0 && (s.oldValue = e);
|
|
765
|
-
}
|
|
766
|
-
} else s && (s.set = "update");
|
|
767
|
-
}
|
|
768
|
-
if (r !== 0 && !this.#y && this.#C(), this.#y && (c || this.#E(u, r, i), s && this.#T(s, u)), !a && this.#S && this.#g) {
|
|
769
|
-
let e = this.#g, t;
|
|
770
|
-
for (; t = e?.shift();) this.#r?.(...t);
|
|
771
|
-
}
|
|
772
|
-
return this;
|
|
773
|
-
}
|
|
774
|
-
pop() {
|
|
775
|
-
try {
|
|
776
|
-
for (; this.#o;) {
|
|
777
|
-
let e = this.#u[this.#p];
|
|
778
|
-
if (this.#F(!0), this.#L(e)) {
|
|
779
|
-
if (e.__staleWhileFetching) return e.__staleWhileFetching;
|
|
780
|
-
} else if (e !== void 0) return e;
|
|
781
|
-
}
|
|
782
|
-
} finally {
|
|
783
|
-
if (this.#S && this.#g) {
|
|
784
|
-
let e = this.#g, t;
|
|
785
|
-
for (; t = e?.shift();) this.#r?.(...t);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
#F(e) {
|
|
790
|
-
let t = this.#p, n = this.#l[t], r = this.#u[t];
|
|
791
|
-
return this.#x && this.#L(r) ? r.__abortController.abort(/* @__PURE__ */ Error("evicted")) : (this.#b || this.#S) && (this.#b && this.#n?.(r, n, "evict"), this.#S && this.#g?.push([
|
|
792
|
-
r,
|
|
793
|
-
n,
|
|
794
|
-
"evict"
|
|
795
|
-
])), this.#k(t), e && (this.#l[t] = void 0, this.#u[t] = void 0, this.#h.push(t)), this.#o === 1 ? (this.#p = this.#m = 0, this.#h.length = 0) : this.#p = this.#d[t], this.#c.delete(n), this.#o--, t;
|
|
796
|
-
}
|
|
797
|
-
has(e, t = {}) {
|
|
798
|
-
let { updateAgeOnHas: n = this.updateAgeOnHas, status: r } = t, i = this.#c.get(e);
|
|
799
|
-
if (i !== void 0) {
|
|
800
|
-
let e = this.#u[i];
|
|
801
|
-
if (this.#L(e) && e.__staleWhileFetching === void 0) return !1;
|
|
802
|
-
if (this.#D(i)) r && (r.has = "stale", this.#T(r, i));
|
|
803
|
-
else return n && this.#w(i), r && (r.has = "hit", this.#T(r, i)), !0;
|
|
804
|
-
} else r && (r.has = "miss");
|
|
805
|
-
return !1;
|
|
806
|
-
}
|
|
807
|
-
peek(e, t = {}) {
|
|
808
|
-
let { allowStale: n = this.allowStale } = t, r = this.#c.get(e);
|
|
809
|
-
if (r === void 0 || !n && this.#D(r)) return;
|
|
810
|
-
let i = this.#u[r];
|
|
811
|
-
return this.#L(i) ? i.__staleWhileFetching : i;
|
|
812
|
-
}
|
|
813
|
-
#I(e, t, n, r) {
|
|
814
|
-
let i = t === void 0 ? void 0 : this.#u[t];
|
|
815
|
-
if (this.#L(i)) return i;
|
|
816
|
-
let a = new Ge(), { signal: o } = n;
|
|
817
|
-
o?.addEventListener("abort", () => a.abort(o.reason), { signal: a.signal });
|
|
818
|
-
let s = {
|
|
819
|
-
signal: a.signal,
|
|
820
|
-
options: n,
|
|
821
|
-
context: r
|
|
822
|
-
}, c = (r, i = !1) => {
|
|
823
|
-
let { aborted: o } = a.signal, c = n.ignoreFetchAbort && r !== void 0;
|
|
824
|
-
if (n.status && (o && !i ? (n.status.fetchAborted = !0, n.status.fetchError = a.signal.reason, c && (n.status.fetchAbortIgnored = !0)) : n.status.fetchResolved = !0), o && !c && !i) return u(a.signal.reason);
|
|
825
|
-
let l = f;
|
|
826
|
-
return this.#u[t] === f && (r === void 0 ? l.__staleWhileFetching ? this.#u[t] = l.__staleWhileFetching : this.#B(e, "fetch") : (n.status && (n.status.fetchUpdated = !0), this.set(e, r, s.options))), r;
|
|
827
|
-
}, l = (e) => (n.status && (n.status.fetchRejected = !0, n.status.fetchError = e), u(e)), u = (r) => {
|
|
828
|
-
let { aborted: i } = a.signal, o = i && n.allowStaleOnFetchAbort, s = o || n.allowStaleOnFetchRejection, c = s || n.noDeleteOnFetchRejection, l = f;
|
|
829
|
-
if (this.#u[t] === f && (!c || l.__staleWhileFetching === void 0 ? this.#B(e, "fetch") : o || (this.#u[t] = l.__staleWhileFetching)), s) return n.status && l.__staleWhileFetching !== void 0 && (n.status.returnedStale = !0), l.__staleWhileFetching;
|
|
830
|
-
if (l.__returned === l) throw r;
|
|
831
|
-
}, d = (t, r) => {
|
|
832
|
-
let o = this.#i?.(e, i, s);
|
|
833
|
-
o && o instanceof Promise && o.then((e) => t(e === void 0 ? void 0 : e), r), a.signal.addEventListener("abort", () => {
|
|
834
|
-
(!n.ignoreFetchAbort || n.allowStaleOnFetchAbort) && (t(void 0), n.allowStaleOnFetchAbort && (t = (e) => c(e, !0)));
|
|
835
|
-
});
|
|
836
|
-
};
|
|
837
|
-
n.status && (n.status.fetchDispatched = !0);
|
|
838
|
-
let f = new Promise(d).then(c, l), p = Object.assign(f, {
|
|
839
|
-
__abortController: a,
|
|
840
|
-
__staleWhileFetching: i,
|
|
841
|
-
__returned: void 0
|
|
842
|
-
});
|
|
843
|
-
return t === void 0 ? (this.set(e, p, {
|
|
844
|
-
...s.options,
|
|
845
|
-
status: void 0
|
|
846
|
-
}), t = this.#c.get(e)) : this.#u[t] = p, p;
|
|
847
|
-
}
|
|
848
|
-
#L(e) {
|
|
849
|
-
if (!this.#x) return !1;
|
|
850
|
-
let t = e;
|
|
851
|
-
return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof Ge;
|
|
852
|
-
}
|
|
853
|
-
async fetch(e, t = {}) {
|
|
854
|
-
let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, ttl: a = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: s = 0, sizeCalculation: c = this.sizeCalculation, noUpdateTTL: l = this.noUpdateTTL, noDeleteOnFetchRejection: u = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: m, forceRefresh: h = !1, status: g, signal: _ } = t;
|
|
855
|
-
if (!this.#x) return g && (g.fetch = "get"), this.get(e, {
|
|
856
|
-
allowStale: n,
|
|
857
|
-
updateAgeOnGet: r,
|
|
858
|
-
noDeleteOnStaleGet: i,
|
|
859
|
-
status: g
|
|
860
|
-
});
|
|
861
|
-
let v = {
|
|
862
|
-
allowStale: n,
|
|
863
|
-
updateAgeOnGet: r,
|
|
864
|
-
noDeleteOnStaleGet: i,
|
|
865
|
-
ttl: a,
|
|
866
|
-
noDisposeOnSet: o,
|
|
867
|
-
size: s,
|
|
868
|
-
sizeCalculation: c,
|
|
869
|
-
noUpdateTTL: l,
|
|
870
|
-
noDeleteOnFetchRejection: u,
|
|
871
|
-
allowStaleOnFetchRejection: d,
|
|
872
|
-
allowStaleOnFetchAbort: p,
|
|
873
|
-
ignoreFetchAbort: f,
|
|
874
|
-
status: g,
|
|
875
|
-
signal: _
|
|
876
|
-
}, y = this.#c.get(e);
|
|
877
|
-
if (y === void 0) {
|
|
878
|
-
g && (g.fetch = "miss");
|
|
879
|
-
let t = this.#I(e, y, v, m);
|
|
880
|
-
return t.__returned = t;
|
|
881
|
-
} else {
|
|
882
|
-
let t = this.#u[y];
|
|
883
|
-
if (this.#L(t)) {
|
|
884
|
-
let e = n && t.__staleWhileFetching !== void 0;
|
|
885
|
-
return g && (g.fetch = "inflight", e && (g.returnedStale = !0)), e ? t.__staleWhileFetching : t.__returned = t;
|
|
886
|
-
}
|
|
887
|
-
let i = this.#D(y);
|
|
888
|
-
if (!h && !i) return g && (g.fetch = "hit"), this.#z(y), r && this.#w(y), g && this.#T(g, y), t;
|
|
889
|
-
let a = this.#I(e, y, v, m), o = a.__staleWhileFetching !== void 0 && n;
|
|
890
|
-
return g && (g.fetch = i ? "stale" : "refresh", o && i && (g.returnedStale = !0)), o ? a.__staleWhileFetching : a.__returned = a;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
async forceFetch(e, t = {}) {
|
|
894
|
-
let n = await this.fetch(e, t);
|
|
895
|
-
if (n === void 0) throw Error("fetch() returned undefined");
|
|
896
|
-
return n;
|
|
897
|
-
}
|
|
898
|
-
memo(e, t = {}) {
|
|
899
|
-
let n = this.#a;
|
|
900
|
-
if (!n) throw Error("no memoMethod provided to constructor");
|
|
901
|
-
let { context: r, forceRefresh: i, ...a } = t, o = this.get(e, a);
|
|
902
|
-
if (!i && o !== void 0) return o;
|
|
903
|
-
let s = n(e, o, {
|
|
904
|
-
options: a,
|
|
905
|
-
context: r
|
|
906
|
-
});
|
|
907
|
-
return this.set(e, s, a), s;
|
|
908
|
-
}
|
|
909
|
-
get(e, t = {}) {
|
|
910
|
-
let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, status: a } = t, o = this.#c.get(e);
|
|
911
|
-
if (o !== void 0) {
|
|
912
|
-
let t = this.#u[o], s = this.#L(t);
|
|
913
|
-
return a && this.#T(a, o), this.#D(o) ? (a && (a.get = "stale"), s ? (a && n && t.__staleWhileFetching !== void 0 && (a.returnedStale = !0), n ? t.__staleWhileFetching : void 0) : (i || this.#B(e, "expire"), a && n && (a.returnedStale = !0), n ? t : void 0)) : (a && (a.get = "hit"), s ? t.__staleWhileFetching : (this.#z(o), r && this.#w(o), t));
|
|
914
|
-
} else a && (a.get = "miss");
|
|
915
|
-
}
|
|
916
|
-
#R(e, t) {
|
|
917
|
-
this.#f[t] = e, this.#d[e] = t;
|
|
918
|
-
}
|
|
919
|
-
#z(e) {
|
|
920
|
-
e !== this.#m && (e === this.#p ? this.#p = this.#d[e] : this.#R(this.#f[e], this.#d[e]), this.#R(this.#m, e), this.#m = e);
|
|
921
|
-
}
|
|
922
|
-
delete(e) {
|
|
923
|
-
return this.#B(e, "delete");
|
|
924
|
-
}
|
|
925
|
-
#B(e, t) {
|
|
926
|
-
let n = !1;
|
|
927
|
-
if (this.#o !== 0) {
|
|
928
|
-
let r = this.#c.get(e);
|
|
929
|
-
if (r !== void 0) if (n = !0, this.#o === 1) this.#V(t);
|
|
930
|
-
else {
|
|
931
|
-
this.#k(r);
|
|
932
|
-
let n = this.#u[r];
|
|
933
|
-
if (this.#L(n) ? n.__abortController.abort(/* @__PURE__ */ Error("deleted")) : (this.#b || this.#S) && (this.#b && this.#n?.(n, e, t), this.#S && this.#g?.push([
|
|
934
|
-
n,
|
|
935
|
-
e,
|
|
936
|
-
t
|
|
937
|
-
])), this.#c.delete(e), this.#l[r] = void 0, this.#u[r] = void 0, r === this.#m) this.#m = this.#f[r];
|
|
938
|
-
else if (r === this.#p) this.#p = this.#d[r];
|
|
939
|
-
else {
|
|
940
|
-
let e = this.#f[r];
|
|
941
|
-
this.#d[e] = this.#d[r];
|
|
942
|
-
let t = this.#d[r];
|
|
943
|
-
this.#f[t] = this.#f[r];
|
|
944
|
-
}
|
|
945
|
-
this.#o--, this.#h.push(r);
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
if (this.#S && this.#g?.length) {
|
|
949
|
-
let e = this.#g, t;
|
|
950
|
-
for (; t = e?.shift();) this.#r?.(...t);
|
|
951
|
-
}
|
|
952
|
-
return n;
|
|
953
|
-
}
|
|
954
|
-
clear() {
|
|
955
|
-
return this.#V("delete");
|
|
956
|
-
}
|
|
957
|
-
#V(e) {
|
|
958
|
-
for (let t of this.#N({ allowStale: !0 })) {
|
|
959
|
-
let n = this.#u[t];
|
|
960
|
-
if (this.#L(n)) n.__abortController.abort(/* @__PURE__ */ Error("deleted"));
|
|
961
|
-
else {
|
|
962
|
-
let r = this.#l[t];
|
|
963
|
-
this.#b && this.#n?.(n, r, e), this.#S && this.#g?.push([
|
|
964
|
-
n,
|
|
965
|
-
r,
|
|
966
|
-
e
|
|
967
|
-
]);
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
if (this.#c.clear(), this.#u.fill(void 0), this.#l.fill(void 0), this.#y && this.#v && (this.#y.fill(0), this.#v.fill(0)), this.#_ && this.#_.fill(0), this.#p = 0, this.#m = 0, this.#h.length = 0, this.#s = 0, this.#o = 0, this.#S && this.#g) {
|
|
971
|
-
let e = this.#g, t;
|
|
972
|
-
for (; t = e?.shift();) this.#r?.(...t);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}, Qe = (e, t) => URL.createObjectURL(_(e, t)), $e = (e) => {
|
|
976
|
-
let t = w(e);
|
|
977
|
-
return t == null ? e : new TextDecoder().decode(t);
|
|
978
|
-
}, et = (e, t) => ({
|
|
979
|
-
type: r.Error,
|
|
980
|
-
errorType: e === 403 ? i.Forbidden : i.LoadFailed,
|
|
981
|
-
url: t
|
|
982
|
-
}), tt = (e) => ({
|
|
983
|
-
type: r.Error,
|
|
984
|
-
errorType: i.LoadFailed,
|
|
985
|
-
url: e
|
|
986
|
-
}), nt = (e) => {
|
|
987
|
-
let t;
|
|
988
|
-
try {
|
|
989
|
-
t = new URL(e).pathname;
|
|
990
|
-
} catch {
|
|
991
|
-
t = x(e);
|
|
992
|
-
}
|
|
993
|
-
let n = t.split("/").filter(Boolean).pop() ?? "";
|
|
994
|
-
try {
|
|
995
|
-
return decodeURIComponent(n);
|
|
996
|
-
} catch {
|
|
997
|
-
return n;
|
|
998
|
-
}
|
|
999
|
-
}, rt = (e) => e.startsWith("image/") || e.startsWith("audio/") || e === h.PDF || s("", e), it = (e, t) => {
|
|
1000
|
-
if (rt(e)) return e;
|
|
1001
|
-
let n = nt(t), r = n.lastIndexOf(".");
|
|
1002
|
-
return (r === -1 ? "" : n.slice(r + 1).toLowerCase()) === f.PDF ? h.PDF : a(n) ?? e;
|
|
1003
|
-
}, at = (e, t) => {
|
|
1004
|
-
if (rt(it(e, t))) return !0;
|
|
1005
|
-
let n = nt(t);
|
|
1006
|
-
return c(n) || o(n);
|
|
1007
|
-
}, ot = new Ze({ max: 10 }), st = new Ze({ max: 50 }), ct = () => {
|
|
1008
|
-
ot.clear(), st.clear();
|
|
1009
|
-
}, lt = (e) => {
|
|
1010
|
-
let t = ot.get(e);
|
|
1011
|
-
return t ?? (t = fetch(e).then((e) => {
|
|
1012
|
-
if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
|
|
1013
|
-
return e.blob();
|
|
1014
|
-
}).catch((t) => {
|
|
1015
|
-
throw ot.delete(e), t;
|
|
1016
|
-
}), ot.set(e, t)), t;
|
|
1017
|
-
}, ut = (e) => {
|
|
1018
|
-
let t = st.get(e);
|
|
1019
|
-
return t ?? (t = fetch(e).then((e) => {
|
|
1020
|
-
if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
|
|
1021
|
-
return e.text();
|
|
1022
|
-
}).catch((t) => {
|
|
1023
|
-
throw st.delete(e), t;
|
|
1024
|
-
}), st.set(e, t)), t;
|
|
1025
|
-
}, dt = async (e, t) => {
|
|
1026
|
-
if ("file" in e) return URL.createObjectURL(e.file);
|
|
1027
|
-
let n = t.resolveDialUrl(e);
|
|
1028
|
-
if (n != null) try {
|
|
1029
|
-
let e = await lt(n);
|
|
1030
|
-
return URL.createObjectURL(e);
|
|
1031
|
-
} catch (e) {
|
|
1032
|
-
let t = e.status;
|
|
1033
|
-
return t == null ? tt(n) : et(t, n);
|
|
1034
|
-
}
|
|
1035
|
-
if (e.previewUrl != null) return e.previewUrl;
|
|
1036
|
-
if (e.data != null) return Qe(e.data, e.contentType);
|
|
1037
|
-
}, ft = async (e, t) => {
|
|
1038
|
-
if (e.data != null) return $e(e.data);
|
|
1039
|
-
let n = t.resolveDialUrl(e);
|
|
1040
|
-
if (n != null) try {
|
|
1041
|
-
return await ut(n);
|
|
1042
|
-
} catch (e) {
|
|
1043
|
-
let t = e.status;
|
|
1044
|
-
return t == null ? tt(n) : et(t, n);
|
|
1045
|
-
}
|
|
1046
|
-
if ("file" in e) return e.file.text();
|
|
1047
|
-
}, pt = (e, t) => e.data != null || t.resolveDialUrl(e) != null || "file" in e, mt = (e, t) => {
|
|
1048
|
-
if ("file" in e) return {
|
|
1049
|
-
type: r.Image,
|
|
1050
|
-
url: URL.createObjectURL(e.file)
|
|
1051
|
-
};
|
|
1052
|
-
let n = t.resolveDialUrl(e);
|
|
1053
|
-
return n == null ? e.previewUrl == null ? e.data == null ? null : {
|
|
1054
|
-
type: r.Image,
|
|
1055
|
-
url: Qe(e.data, e.contentType)
|
|
1056
|
-
} : {
|
|
1057
|
-
type: r.Image,
|
|
1058
|
-
url: e.previewUrl
|
|
1059
|
-
} : {
|
|
1060
|
-
type: r.Image,
|
|
1061
|
-
url: n
|
|
1062
|
-
};
|
|
1063
|
-
}, ht = async (e, t) => {
|
|
1064
|
-
let n = await ft(e, t);
|
|
1065
|
-
return n == null ? null : typeof n == "string" ? {
|
|
1066
|
-
type: r.PlainText,
|
|
1067
|
-
text: n
|
|
1068
|
-
} : n;
|
|
1069
|
-
}, gt = async (e, t) => {
|
|
1070
|
-
let n = await ft(e, t);
|
|
1071
|
-
return n == null ? null : typeof n == "string" ? {
|
|
1072
|
-
type: r.Markdown,
|
|
1073
|
-
text: n
|
|
1074
|
-
} : n;
|
|
1075
|
-
}, _t = 1048576, vt = async (e, t, n) => {
|
|
1076
|
-
let i = await ft(e, t);
|
|
1077
|
-
return i == null ? null : typeof i == "string" ? {
|
|
1078
|
-
type: r.Code,
|
|
1079
|
-
text: i,
|
|
1080
|
-
language: n
|
|
1081
|
-
} : i;
|
|
1082
|
-
}, yt = async (e, t) => {
|
|
1083
|
-
let n = await ft(e, t);
|
|
1084
|
-
if (n == null) return null;
|
|
1085
|
-
if (typeof n != "string") return n;
|
|
1086
|
-
if (n.length > _t) return null;
|
|
1087
|
-
let i = t.resolveDialUrl(e) ?? void 0;
|
|
1088
|
-
return {
|
|
1089
|
-
type: r.Html,
|
|
1090
|
-
srcdoc: n,
|
|
1091
|
-
url: i
|
|
1092
|
-
};
|
|
1093
|
-
}, bt = (t, n, i) => {
|
|
1094
|
-
let a = t.body?.source?.attachment;
|
|
1095
|
-
if (a?.type !== h.PDF) return null;
|
|
1096
|
-
let o = e(a.url) ? i.resolveDialFileDownloadUrl(a.url) : a.url;
|
|
1097
|
-
if (o == null) return null;
|
|
1098
|
-
let s = (n.find((e) => e.annotations.includes(t))?.annotations ?? [t]).filter((e) => e.body?.source?.attachment?.url === a.url), c = s.indexOf(t), l = E(s), u = T(t, c);
|
|
1099
|
-
return {
|
|
1100
|
-
type: r.Pdf,
|
|
1101
|
-
url: o,
|
|
1102
|
-
highlights: l,
|
|
1103
|
-
selectedHighlightId: l.some((e) => e.id === u) ? u : void 0,
|
|
1104
|
-
page: D(t)
|
|
1105
|
-
};
|
|
1106
|
-
}, xt = (t, n) => {
|
|
1107
|
-
let i = O(t.url);
|
|
1108
|
-
if (i == null) return null;
|
|
1109
|
-
let a = e(i.baseUrl) ? n.resolveDialFileDownloadUrl(i.baseUrl) : i.baseUrl;
|
|
1110
|
-
if (a == null) return null;
|
|
1111
|
-
if (i.page == null) return {
|
|
1112
|
-
type: r.Pdf,
|
|
1113
|
-
url: a
|
|
1114
|
-
};
|
|
1115
|
-
let o = `reference-page-${i.page}`;
|
|
1116
|
-
return {
|
|
1117
|
-
type: r.Pdf,
|
|
1118
|
-
url: a,
|
|
1119
|
-
highlights: [{
|
|
1120
|
-
id: o,
|
|
1121
|
-
bboxes: [{
|
|
1122
|
-
page: i.page,
|
|
1123
|
-
x1: 0,
|
|
1124
|
-
y1: 0,
|
|
1125
|
-
x2: 0,
|
|
1126
|
-
y2: 0
|
|
1127
|
-
}],
|
|
1128
|
-
style: {
|
|
1129
|
-
backgroundColor: "transparent",
|
|
1130
|
-
opacity: 0
|
|
1131
|
-
}
|
|
1132
|
-
}],
|
|
1133
|
-
selectedHighlightId: o,
|
|
1134
|
-
page: i.page
|
|
1135
|
-
};
|
|
1136
|
-
}, St = (e) => {
|
|
1137
|
-
try {
|
|
1138
|
-
let t = new URL(e).protocol;
|
|
1139
|
-
return t === "http:" || t === "https:" || t === "blob:";
|
|
1140
|
-
} catch {
|
|
1141
|
-
return !1;
|
|
1142
|
-
}
|
|
1143
|
-
}, Ct = (t) => t.url != null && !e(t.url) && St(t.url) ? t.url : void 0, wt = async (e, t) => {
|
|
1144
|
-
let n = await dt(e, t);
|
|
1145
|
-
if (n != null) return typeof n == "string" ? {
|
|
1146
|
-
type: r.Pdf,
|
|
1147
|
-
url: n
|
|
1148
|
-
} : n;
|
|
1149
|
-
let i = Ct(e);
|
|
1150
|
-
return i == null ? null : {
|
|
1151
|
-
type: r.Pdf,
|
|
1152
|
-
url: i
|
|
1153
|
-
};
|
|
1154
|
-
}, Tt = async (e, t, n) => {
|
|
1155
|
-
let i = await dt(e, t);
|
|
1156
|
-
if (i != null) return typeof i == "string" ? {
|
|
1157
|
-
type: r.Ooxml,
|
|
1158
|
-
url: i,
|
|
1159
|
-
format: n
|
|
1160
|
-
} : i;
|
|
1161
|
-
let a = Ct(e);
|
|
1162
|
-
return a == null ? null : {
|
|
1163
|
-
type: r.Ooxml,
|
|
1164
|
-
url: a,
|
|
1165
|
-
format: n
|
|
1166
|
-
};
|
|
1167
|
-
}, Et = async (e, t) => {
|
|
1168
|
-
let n = await ft(e, t);
|
|
1169
|
-
if (n == null) return null;
|
|
1170
|
-
if (typeof n != "string") return n;
|
|
1171
|
-
try {
|
|
1172
|
-
let e = JSON.parse(n);
|
|
1173
|
-
return {
|
|
1174
|
-
type: r.Json,
|
|
1175
|
-
value: e
|
|
1176
|
-
};
|
|
1177
|
-
} catch {
|
|
1178
|
-
return {
|
|
1179
|
-
type: r.PlainText,
|
|
1180
|
-
text: n
|
|
1181
|
-
};
|
|
1182
|
-
}
|
|
1183
|
-
}, Dt = async (e, t, n, i) => {
|
|
1184
|
-
let a = await ft(e, t);
|
|
1185
|
-
if (a == null || typeof a != "string") return null;
|
|
1186
|
-
let o = {};
|
|
1187
|
-
try {
|
|
1188
|
-
let e = JSON.parse(a);
|
|
1189
|
-
typeof e == "object" && e && (o = e);
|
|
1190
|
-
} catch {}
|
|
1191
|
-
return {
|
|
1192
|
-
type: r.Visualizer,
|
|
1193
|
-
url: n.url,
|
|
1194
|
-
mimeType: e.contentType,
|
|
1195
|
-
data: o,
|
|
1196
|
-
layout: {
|
|
1197
|
-
width: n.width,
|
|
1198
|
-
height: n.height,
|
|
1199
|
-
mobileHeight: n.mobileHeight,
|
|
1200
|
-
themeId: i
|
|
1201
|
-
},
|
|
1202
|
-
visualizerName: n.title,
|
|
1203
|
-
requestTimeout: n.requestTimeout
|
|
1204
|
-
};
|
|
1205
|
-
}, Ot = (e, t) => b(e, t), kt = (e) => {
|
|
1206
|
-
let t = e.body?.source?.attachment;
|
|
1207
|
-
return t == null ? null : {
|
|
1208
|
-
id: t.url,
|
|
1209
|
-
name: t.url.split("/").pop() ?? t.url,
|
|
1210
|
-
contentType: t.type,
|
|
1211
|
-
type: t.type.startsWith("image/") ? l.Image : l.File,
|
|
1212
|
-
status: g.Idle,
|
|
1213
|
-
url: t.url
|
|
1214
|
-
};
|
|
1215
|
-
}, At = (e, t) => e?.map((e) => Ot(e, t)) ?? [], jt = (t, n) => {
|
|
1216
|
-
let r = t.url ?? t.id;
|
|
1217
|
-
if (r) return e(r) || r.startsWith("http://") || r.startsWith("https://") ? r : `files/${n}/${r.replace(/^\/+/, "")}`;
|
|
1218
|
-
}, Mt = (e, t, n) => {
|
|
1219
|
-
if (e.nodeType !== te.ITEM) return null;
|
|
1220
|
-
let r = jt(e, t);
|
|
1221
|
-
if (!r) return null;
|
|
1222
|
-
let i = e.contentType ?? "application/octet-stream", a = i.startsWith("image/"), o = a ? n?.resolvePreviewUrl?.(r) : void 0;
|
|
1223
|
-
return {
|
|
1224
|
-
id: r,
|
|
1225
|
-
name: e.name,
|
|
1226
|
-
contentType: i,
|
|
1227
|
-
type: a ? l.Image : l.File,
|
|
1228
|
-
status: g.Idle,
|
|
1229
|
-
url: r,
|
|
1230
|
-
file: new File([], e.name, { type: i }),
|
|
1231
|
-
...o == null ? {} : { previewUrl: o }
|
|
1232
|
-
};
|
|
1233
|
-
}, Nt = (e, t, n) => e.map((e) => Mt(e, t, n)).filter((e) => e != null), Pt = (e) => {
|
|
1234
|
-
let t = n(e.replace(/\/$/, "").split("/").filter(Boolean).pop() ?? "");
|
|
1235
|
-
return {
|
|
1236
|
-
id: e,
|
|
1237
|
-
name: t,
|
|
1238
|
-
contentType: "application/octet-stream",
|
|
1239
|
-
type: l.File,
|
|
1240
|
-
status: g.Idle,
|
|
1241
|
-
url: e,
|
|
1242
|
-
file: new File([], t)
|
|
1243
|
-
};
|
|
1244
|
-
}, Ft = /* @__PURE__ */ function(e) {
|
|
1245
|
-
return e.Blob = "blob", e.Stream = "stream", e.Cancelled = "cancelled", e;
|
|
1246
|
-
}({}), It = async (e, t = "application/octet-stream") => {
|
|
1247
|
-
let n = window.showSaveFilePicker;
|
|
1248
|
-
if (n == null) return { type: Ft.Blob };
|
|
1249
|
-
try {
|
|
1250
|
-
let r = e.lastIndexOf("."), i = r >= 0 ? e.slice(r) : void 0, a = await n.call(window, {
|
|
1251
|
-
suggestedName: e,
|
|
1252
|
-
types: [{
|
|
1253
|
-
description: t,
|
|
1254
|
-
accept: { [t]: i == null ? [] : [i] }
|
|
1255
|
-
}]
|
|
1256
|
-
});
|
|
1257
|
-
return {
|
|
1258
|
-
type: Ft.Stream,
|
|
1259
|
-
writable: await a.createWritable()
|
|
1260
|
-
};
|
|
1261
|
-
} catch (e) {
|
|
1262
|
-
if (e instanceof DOMException && e.name === "AbortError") return { type: Ft.Cancelled };
|
|
1263
|
-
throw e;
|
|
1264
|
-
}
|
|
1265
|
-
}, Lt = (e) => {
|
|
1266
|
-
let t = e.lastIndexOf("."), n = t > 0;
|
|
1267
|
-
return {
|
|
1268
|
-
base: n ? e.slice(0, t) : e,
|
|
1269
|
-
extension: n ? e.slice(t) : ""
|
|
1270
|
-
};
|
|
1271
|
-
}, Rt = (e, t = 255) => {
|
|
1272
|
-
if (y(e) <= t) return e;
|
|
1273
|
-
let { base: n, extension: r } = Lt(e), i = t - y(r);
|
|
1274
|
-
return i <= 0 ? C(e, t) : `${C(n, i)}${r}`;
|
|
1275
|
-
}, zt = (e) => {
|
|
1276
|
-
let { base: t, extension: n } = Lt(e), r = t.replace(new RegExp(z.source, "g"), "_").replace(/[.\s]+$/, "");
|
|
1277
|
-
return r === "" ? e : Rt(`${r}${n}`);
|
|
1278
|
-
}, Bt = ({ filesApi: e, bucket: n, rootLabel: r, activeTab: i, onNotification: a }) => {
|
|
1279
|
-
let [o, s] = N(""), [c, l] = N(() => /* @__PURE__ */ new Map()), u = M(c);
|
|
1280
|
-
A(() => {
|
|
1281
|
-
u.current = c;
|
|
1282
|
-
}, [c]);
|
|
1283
|
-
let [d, f] = N(() => /* @__PURE__ */ new Map()), [p, m] = N(!0), [h, g] = N(null), [_, y] = N(0), [b, x] = N(void 0), [S, C] = N(() => /* @__PURE__ */ new Set()), w = M(/* @__PURE__ */ new Map()), [T, E] = N(!1), [D, O] = N(null), P = M(null), F = M(null), I = M(/* @__PURE__ */ new Set()), L = M(/* @__PURE__ */ new Set()), [R, te] = N(() => /* @__PURE__ */ new Set()), [ne, z] = N(() => /* @__PURE__ */ new Set()), [V, W] = N(() => /* @__PURE__ */ new Set()), G = M(i);
|
|
1284
|
-
A(() => {
|
|
1285
|
-
G.current !== i && (G.current = i, l(/* @__PURE__ */ new Map()), f(/* @__PURE__ */ new Map()), s(""), x(void 0), w.current = /* @__PURE__ */ new Map(), I.current = /* @__PURE__ */ new Set(), L.current = /* @__PURE__ */ new Set(), z(/* @__PURE__ */ new Set()), W(/* @__PURE__ */ new Set()), P.current != null && (clearTimeout(P.current), P.current = null), F.current?.(), F.current = null, O(null), E(!1), te(/* @__PURE__ */ new Set()));
|
|
1286
|
-
}, [i]), A(() => () => {
|
|
1287
|
-
P.current != null && clearTimeout(P.current), F.current?.();
|
|
1288
|
-
}, []), A(() => {
|
|
1289
|
-
let a = !1;
|
|
1290
|
-
return m(!0), g(null), Ne(e, i, n, o, w.current).then(({ items: e, permissions: t }) => {
|
|
1291
|
-
a || (l((t) => {
|
|
1292
|
-
let n = new Map(t);
|
|
1293
|
-
return n.set(o, e), n;
|
|
1294
|
-
}), f((e) => new Map(e).set(o, t)), i === H.Shared && o === "" && (x(e.map((e) => be(Z(e.path, e.bucket ?? ""), r, e.nodeType === ee.Folder))), w.current = new Map(e.map((e) => [e.name, {
|
|
1295
|
-
bucket: e.bucket ?? "",
|
|
1296
|
-
dialCorePath: e.path
|
|
1297
|
-
}]))));
|
|
1298
|
-
}).catch((e) => {
|
|
1299
|
-
if (!a) {
|
|
1300
|
-
if (o !== "" && t(e) === 404) {
|
|
1301
|
-
s(v(o));
|
|
1302
|
-
return;
|
|
1303
|
-
}
|
|
1304
|
-
g("dialFileManager.error");
|
|
1305
|
-
}
|
|
1306
|
-
}).finally(() => {
|
|
1307
|
-
a || m(!1);
|
|
1308
|
-
}), () => {
|
|
1309
|
-
a = !0;
|
|
1310
|
-
};
|
|
1311
|
-
}, [
|
|
1312
|
-
i,
|
|
1313
|
-
n,
|
|
1314
|
-
e,
|
|
1315
|
-
o,
|
|
1316
|
-
_,
|
|
1317
|
-
r
|
|
1318
|
-
]), A(() => {
|
|
1319
|
-
if (i !== H.MyFiles) {
|
|
1320
|
-
C(/* @__PURE__ */ new Set());
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
let t = !1;
|
|
1324
|
-
return e.listSharedByMe(n).then((e) => {
|
|
1325
|
-
t || C(new Set(e.items.map((e) => be(Z(e.path, n), r, e.nodeType === ee.Folder))));
|
|
1326
|
-
}).catch(() => {
|
|
1327
|
-
t || C(/* @__PURE__ */ new Set());
|
|
1328
|
-
}), () => {
|
|
1329
|
-
t = !0;
|
|
1330
|
-
};
|
|
1331
|
-
}, [
|
|
1332
|
-
i,
|
|
1333
|
-
n,
|
|
1334
|
-
e,
|
|
1335
|
-
_,
|
|
1336
|
-
r
|
|
1337
|
-
]);
|
|
1338
|
-
let re = j(() => [{
|
|
1339
|
-
id: n,
|
|
1340
|
-
name: r,
|
|
1341
|
-
path: `/${r}`,
|
|
1342
|
-
parentPath: "",
|
|
1343
|
-
nodeType: U.FOLDER,
|
|
1344
|
-
folderId: n,
|
|
1345
|
-
permissions: Oe(d.get("")),
|
|
1346
|
-
items: Ae(c, d, "", `/${r}`, n)
|
|
1347
|
-
}], [
|
|
1348
|
-
c,
|
|
1349
|
-
d,
|
|
1350
|
-
r,
|
|
1351
|
-
n
|
|
1352
|
-
]), q = k((e) => {
|
|
1353
|
-
if (e == null) {
|
|
1354
|
-
s("");
|
|
1355
|
-
return;
|
|
1356
|
-
}
|
|
1357
|
-
let t = `/${r}/`, n = `${r}/`;
|
|
1358
|
-
if (e === `/${r}` || e === t || e === r || e === n) {
|
|
1359
|
-
s("");
|
|
1360
|
-
return;
|
|
1361
|
-
}
|
|
1362
|
-
let i;
|
|
1363
|
-
if (e.startsWith(t)) i = e.slice(t.length);
|
|
1364
|
-
else if (e.startsWith(n)) i = e.slice(n.length);
|
|
1365
|
-
else {
|
|
1366
|
-
let t = e.replace(/^\//, "");
|
|
1367
|
-
i = t.startsWith(n) ? t.slice(n.length) : t;
|
|
1368
|
-
}
|
|
1369
|
-
s(i && !i.endsWith("/") ? `${i}/` : i);
|
|
1370
|
-
}, [r]), J = k(() => {
|
|
1371
|
-
y((e) => e + 1);
|
|
1372
|
-
}, []), ie = J, ae = k((t) => {
|
|
1373
|
-
if (t.length === 0) return;
|
|
1374
|
-
let s = new Set([...R].map((e) => Q(e, r))), c = (e) => e === o || o.startsWith(e) || s.has(e), u = t.filter((e) => !c(e)), d = t.filter((e) => c(e) && e !== o);
|
|
1375
|
-
u.length > 0 && (l((e) => {
|
|
1376
|
-
let t = new Map(e);
|
|
1377
|
-
return u.forEach((e) => t.delete(e)), t;
|
|
1378
|
-
}), f((e) => {
|
|
1379
|
-
let t = new Map(e);
|
|
1380
|
-
return u.forEach((e) => t.delete(e)), t;
|
|
1381
|
-
})), d.forEach((t) => {
|
|
1382
|
-
(async () => {
|
|
1383
|
-
try {
|
|
1384
|
-
let { items: r, permissions: a } = await Ne(e, i, n, t, w.current);
|
|
1385
|
-
l((e) => new Map(e).set(t, r)), a != null && f((e) => new Map(e).set(t, a));
|
|
1386
|
-
} catch {
|
|
1387
|
-
a?.({
|
|
1388
|
-
variant: B.Error,
|
|
1389
|
-
reason: K.FolderLoadFailed
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
})();
|
|
1393
|
-
});
|
|
1394
|
-
}, [
|
|
1395
|
-
i,
|
|
1396
|
-
n,
|
|
1397
|
-
e,
|
|
1398
|
-
o,
|
|
1399
|
-
R,
|
|
1400
|
-
r,
|
|
1401
|
-
a
|
|
1402
|
-
]), oe = k((e, t, n) => {
|
|
1403
|
-
l((r) => je(r, e, t, n));
|
|
1404
|
-
}, []), se = k((t) => {
|
|
1405
|
-
let o = t == null ? "" : Q(t, r), s = t ?? `/${r}`;
|
|
1406
|
-
if (W((e) => {
|
|
1407
|
-
if (e.has(s)) return e;
|
|
1408
|
-
let t = new Set(e);
|
|
1409
|
-
return t.add(s), t;
|
|
1410
|
-
}), !u.current.has(o)) {
|
|
1411
|
-
if (I.current.has(o)) {
|
|
1412
|
-
z((e) => {
|
|
1413
|
-
let t = new Set(e);
|
|
1414
|
-
return t.add(s), t;
|
|
1415
|
-
});
|
|
1416
|
-
return;
|
|
1417
|
-
}
|
|
1418
|
-
I.current.add(o), z((e) => {
|
|
1419
|
-
let t = new Set(e);
|
|
1420
|
-
return t.add(s), t;
|
|
1421
|
-
}), (async () => {
|
|
1422
|
-
try {
|
|
1423
|
-
let { items: t, permissions: r } = await Ne(e, i, n, o, w.current);
|
|
1424
|
-
l((e) => new Map(e).set(o, t)), r != null && f((e) => new Map(e).set(o, r)), L.current.delete(o);
|
|
1425
|
-
} catch {
|
|
1426
|
-
a?.({
|
|
1427
|
-
variant: B.Error,
|
|
1428
|
-
reason: K.FolderLoadFailed
|
|
1429
|
-
});
|
|
1430
|
-
} finally {
|
|
1431
|
-
I.current.delete(o), z((e) => {
|
|
1432
|
-
let t = new Set(e);
|
|
1433
|
-
return t.delete(s), t;
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
})();
|
|
1437
|
-
}
|
|
1438
|
-
}, [
|
|
1439
|
-
i,
|
|
1440
|
-
n,
|
|
1441
|
-
e,
|
|
1442
|
-
a,
|
|
1443
|
-
r
|
|
1444
|
-
]), ce = j(() => {
|
|
1445
|
-
let e = /* @__PURE__ */ new Set(), t = new Set([...R, ...V]);
|
|
1446
|
-
for (let n of t) {
|
|
1447
|
-
let t = Q(n, r);
|
|
1448
|
-
c.has(t) && e.add(n);
|
|
1449
|
-
}
|
|
1450
|
-
return e;
|
|
1451
|
-
}, [
|
|
1452
|
-
R,
|
|
1453
|
-
V,
|
|
1454
|
-
c,
|
|
1455
|
-
r
|
|
1456
|
-
]), le = k((t) => {
|
|
1457
|
-
R.forEach((e) => {
|
|
1458
|
-
t.has(e) || L.current.delete(Q(e, r));
|
|
1459
|
-
}), te(t), [...t].filter((e) => {
|
|
1460
|
-
let t = Q(e, r);
|
|
1461
|
-
return !u.current.has(t) && !I.current.has(t) && !L.current.has(t);
|
|
1462
|
-
}).forEach((t) => {
|
|
1463
|
-
let o = Q(t, r);
|
|
1464
|
-
I.current.add(o), (async () => {
|
|
1465
|
-
try {
|
|
1466
|
-
let { items: t, permissions: r } = await Ne(e, i, n, o, w.current);
|
|
1467
|
-
l((e) => new Map(e).set(o, t)), r != null && f((e) => new Map(e).set(o, r));
|
|
1468
|
-
} catch {
|
|
1469
|
-
L.current.add(o), a?.({
|
|
1470
|
-
variant: B.Error,
|
|
1471
|
-
reason: K.FolderLoadFailed
|
|
1472
|
-
});
|
|
1473
|
-
} finally {
|
|
1474
|
-
I.current.delete(o), z((e) => {
|
|
1475
|
-
let n = new Set(e);
|
|
1476
|
-
return n.delete(t), n;
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
})();
|
|
1480
|
-
});
|
|
1481
|
-
}, [
|
|
1482
|
-
i,
|
|
1483
|
-
n,
|
|
1484
|
-
e,
|
|
1485
|
-
R,
|
|
1486
|
-
a,
|
|
1487
|
-
r
|
|
1488
|
-
]), ue = k(() => {
|
|
1489
|
-
P.current != null && (clearTimeout(P.current), P.current = null), F.current?.(), F.current = null, O(null), E(!1);
|
|
1490
|
-
}, []), de = k((t, a) => {
|
|
1491
|
-
if (P.current != null && (clearTimeout(P.current), P.current = null), F.current?.(), F.current = null, !a.trim()) {
|
|
1492
|
-
O(null), E(!1);
|
|
1493
|
-
return;
|
|
1494
|
-
}
|
|
1495
|
-
P.current = setTimeout(() => {
|
|
1496
|
-
P.current = null;
|
|
1497
|
-
let t = a.toLowerCase();
|
|
1498
|
-
if (i === H.Shared && o === "") {
|
|
1499
|
-
F.current?.(), F.current = null, E(!0), O((c.get("") ?? []).filter((e) => e.name.toLowerCase().includes(t)).map((e) => Fe(e, e.bucket ?? n, r))), E(!1);
|
|
1500
|
-
return;
|
|
1501
|
-
}
|
|
1502
|
-
let s = !1;
|
|
1503
|
-
F.current = () => {
|
|
1504
|
-
s = !0;
|
|
1505
|
-
}, E(!0), (async () => {
|
|
1506
|
-
try {
|
|
1507
|
-
let { items: a } = await Pe(e, i, n, o, w.current);
|
|
1508
|
-
if (s) return;
|
|
1509
|
-
O(a.filter((e) => e.name.toLowerCase().includes(t)).map((e) => Fe(e, e.bucket ?? n, r)));
|
|
1510
|
-
} catch {
|
|
1511
|
-
s || O([]);
|
|
1512
|
-
} finally {
|
|
1513
|
-
s || E(!1);
|
|
1514
|
-
}
|
|
1515
|
-
})();
|
|
1516
|
-
}, 300);
|
|
1517
|
-
}, [
|
|
1518
|
-
i,
|
|
1519
|
-
n,
|
|
1520
|
-
c,
|
|
1521
|
-
e,
|
|
1522
|
-
o,
|
|
1523
|
-
r
|
|
1524
|
-
]), Y = o ? `/${r}/${o}` : `/${r}`, X = j(() => {
|
|
1525
|
-
let e = re[0];
|
|
1526
|
-
if (e) return fe(Y) === fe(`/${r}`) ? e : me(e.items ?? [], Y);
|
|
1527
|
-
}, [
|
|
1528
|
-
re,
|
|
1529
|
-
Y,
|
|
1530
|
-
r
|
|
1531
|
-
]);
|
|
1532
|
-
return {
|
|
1533
|
-
items: re,
|
|
1534
|
-
isLoading: p,
|
|
1535
|
-
error: h,
|
|
1536
|
-
path: Y,
|
|
1537
|
-
folderPath: o,
|
|
1538
|
-
onPathChange: q,
|
|
1539
|
-
retry: J,
|
|
1540
|
-
onSearchFiles: de,
|
|
1541
|
-
isSearching: T,
|
|
1542
|
-
searchResults: D,
|
|
1543
|
-
clearSearchResults: ue,
|
|
1544
|
-
expandedPaths: R,
|
|
1545
|
-
loadedPaths: ce,
|
|
1546
|
-
onExpandedPathsChange: le,
|
|
1547
|
-
onFolderPopupPathChange: se,
|
|
1548
|
-
folderPopupLoadingPaths: ne,
|
|
1549
|
-
sharedWithMeIds: j(() => i === H.Shared ? b : void 0, [i, b]),
|
|
1550
|
-
sharedByMePaths: S,
|
|
1551
|
-
currentFolder: X,
|
|
1552
|
-
cache: c,
|
|
1553
|
-
listingPermissionsCache: d,
|
|
1554
|
-
sharedRootMetaRef: w,
|
|
1555
|
-
setFolderPath: s,
|
|
1556
|
-
invalidateFolders: ae,
|
|
1557
|
-
mergeCreatedFolder: oe,
|
|
1558
|
-
bumpRetry: ie
|
|
1559
|
-
};
|
|
1560
|
-
}, Vt = ({ filesApi: e, bucket: t, rootLabel: n, onNotification: r }) => {
|
|
1561
|
-
let [i, a] = N(void 0), [o, s] = N(!1);
|
|
1562
|
-
return {
|
|
1563
|
-
fileMetadata: i,
|
|
1564
|
-
isFileMetadataLoading: o,
|
|
1565
|
-
onGetInfo: k((i) => {
|
|
1566
|
-
(async () => {
|
|
1567
|
-
s(!0);
|
|
1568
|
-
try {
|
|
1569
|
-
let r = i.bucket ?? t, o = Te(i, r, n);
|
|
1570
|
-
a(Ie(await e.getFileMetadata({
|
|
1571
|
-
bucket: r,
|
|
1572
|
-
path: o
|
|
1573
|
-
}), i));
|
|
1574
|
-
} catch {
|
|
1575
|
-
r?.({
|
|
1576
|
-
variant: B.Error,
|
|
1577
|
-
reason: K.MetadataLoadFailed
|
|
1578
|
-
});
|
|
1579
|
-
} finally {
|
|
1580
|
-
s(!1);
|
|
1581
|
-
}
|
|
1582
|
-
})();
|
|
1583
|
-
}, [
|
|
1584
|
-
t,
|
|
1585
|
-
e,
|
|
1586
|
-
n,
|
|
1587
|
-
r
|
|
1588
|
-
]),
|
|
1589
|
-
clearMetadata: k(() => {
|
|
1590
|
-
a(void 0), s(!1);
|
|
1591
|
-
}, [])
|
|
1592
|
-
};
|
|
1593
|
-
}, Ht = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, folderPath: i, currentFolder: a, sharedRootMetaRef: o, listingPermissionsCache: s, invalidateFolders: c, bumpRetry: l, mergeCreatedFolder: u, setFolderPath: d, onNotification: f, onOperationSuccess: p, downloadDestination: m, forbiddenSymbolsRegExp: h }) => {
|
|
1594
|
-
let [g, _] = N(!1), [y, b] = N(!1), [x, S] = N(!1), [C, w] = N(!1), [T, E] = N(!1), [D, O] = N(!1), A = M(null), j = M(null), F = k((e, t) => {
|
|
1595
|
-
let n = null;
|
|
1596
|
-
if (!e || e.trim() === "") n = { reason: q.Empty };
|
|
1597
|
-
else if (Y(e, h)) n = {
|
|
1598
|
-
reason: q.ForbiddenSymbols,
|
|
1599
|
-
symbols: ne
|
|
1600
|
-
};
|
|
1601
|
-
else if (e.startsWith(".")) n = { reason: q.LeadingDot };
|
|
1602
|
-
else if (e === ae) n = { reason: q.ReservedName };
|
|
1603
|
-
else if (e.length > 255) n = {
|
|
1604
|
-
reason: q.TooLong,
|
|
1605
|
-
maxLength: 255
|
|
1606
|
-
};
|
|
1607
|
-
else {
|
|
1608
|
-
let r = t.items ?? [], i = e.toLowerCase(), a = r.find((e) => e.name.toLowerCase() === i);
|
|
1609
|
-
a && (n = {
|
|
1610
|
-
reason: q.DuplicateName,
|
|
1611
|
-
existingName: a.name
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
return j.current = n, n;
|
|
1615
|
-
}, [h]), ee = k(async (c, d, m) => {
|
|
1616
|
-
let { parentVirtualPath: h, name: g } = ye(d, n), v = Q(h, n), y = a && i === v ? a : {
|
|
1617
|
-
id: v,
|
|
1618
|
-
path: v,
|
|
1619
|
-
name: h.split("/").filter(Boolean).pop() ?? "",
|
|
1620
|
-
folderId: v,
|
|
1621
|
-
nodeType: U.FOLDER,
|
|
1622
|
-
items: []
|
|
1623
|
-
}, b = j.current;
|
|
1624
|
-
if (j.current = null, F(g, y) || b) return;
|
|
1625
|
-
_(!0);
|
|
1626
|
-
let { bucket: x, path: S } = r === H.Shared ? xe(v, o.current, t) : {
|
|
1627
|
-
bucket: t,
|
|
1628
|
-
path: v
|
|
1629
|
-
};
|
|
1630
|
-
try {
|
|
1631
|
-
u(v, await e.createFolder({
|
|
1632
|
-
bucket: x,
|
|
1633
|
-
parentPath: S,
|
|
1634
|
-
name: g
|
|
1635
|
-
}), s.get(v)), l(), p?.({
|
|
1636
|
-
kind: J.FolderCreated,
|
|
1637
|
-
name: g
|
|
1638
|
-
});
|
|
1639
|
-
} catch {
|
|
1640
|
-
f?.({
|
|
1641
|
-
variant: B.Error,
|
|
1642
|
-
reason: K.FolderCreateFailed
|
|
1643
|
-
});
|
|
1644
|
-
} finally {
|
|
1645
|
-
_(!1);
|
|
1646
|
-
}
|
|
1647
|
-
}, [
|
|
1648
|
-
r,
|
|
1649
|
-
t,
|
|
1650
|
-
a,
|
|
1651
|
-
e,
|
|
1652
|
-
i,
|
|
1653
|
-
F,
|
|
1654
|
-
n,
|
|
1655
|
-
s,
|
|
1656
|
-
u,
|
|
1657
|
-
l,
|
|
1658
|
-
p,
|
|
1659
|
-
o,
|
|
1660
|
-
f
|
|
1661
|
-
]), L = k((r) => {
|
|
1662
|
-
(async () => {
|
|
1663
|
-
b(!0);
|
|
1664
|
-
try {
|
|
1665
|
-
let i = r.length === 1 ? r[0].nodeType === U.ITEM ? r[0].name : `${r[0].name}.zip` : "files.zip", a = await m.resolveDestination(i, r.length === 1 && r[0].nodeType === U.ITEM ? r[0].contentType ?? "application/octet-stream" : "application/zip");
|
|
1666
|
-
if (a.type === Ft.Cancelled) return;
|
|
1667
|
-
if (r.length === 1 && r[0].nodeType === U.ITEM) {
|
|
1668
|
-
let t = r[0];
|
|
1669
|
-
if (!t.bucket) throw Error("File is missing bucket");
|
|
1670
|
-
let i = Te(t, t.bucket, n), o = await e.downloadFile(t.bucket, i);
|
|
1671
|
-
if (!o.ok) throw Error(`Download failed with status ${o.status}`);
|
|
1672
|
-
let s = await m.triggerDownload(o, t.name, a);
|
|
1673
|
-
p?.({
|
|
1674
|
-
kind: J.FileDownloaded,
|
|
1675
|
-
name: s,
|
|
1676
|
-
count: 1
|
|
1677
|
-
});
|
|
1678
|
-
} else {
|
|
1679
|
-
let o = r.map((e) => ({
|
|
1680
|
-
bucket: e.bucket ?? t,
|
|
1681
|
-
path: Te(e, e.bucket ?? t, n),
|
|
1682
|
-
name: e.name,
|
|
1683
|
-
nodeType: e.nodeType === U.FOLDER ? P.Folder : P.Item
|
|
1684
|
-
})), s = await e.downloadArchive(o);
|
|
1685
|
-
if (!s.ok) throw Error(`Download failed with status ${s.status}`);
|
|
1686
|
-
let c = await m.triggerDownload(s, i, a);
|
|
1687
|
-
r.length === 1 ? p?.({
|
|
1688
|
-
kind: J.FileDownloaded,
|
|
1689
|
-
name: c
|
|
1690
|
-
}) : p?.({
|
|
1691
|
-
kind: J.FilesDownloaded,
|
|
1692
|
-
count: r.length
|
|
1693
|
-
});
|
|
1694
|
-
}
|
|
1695
|
-
} catch {
|
|
1696
|
-
f?.({
|
|
1697
|
-
variant: B.Error,
|
|
1698
|
-
reason: r.length === 1 ? K.DownloadFileFailed : K.DownloadFilesFailed
|
|
1699
|
-
});
|
|
1700
|
-
} finally {
|
|
1701
|
-
b(!1);
|
|
1702
|
-
}
|
|
1703
|
-
})();
|
|
1704
|
-
}, [
|
|
1705
|
-
t,
|
|
1706
|
-
n,
|
|
1707
|
-
p,
|
|
1708
|
-
f,
|
|
1709
|
-
e,
|
|
1710
|
-
m
|
|
1711
|
-
]), te = k((a, s) => {
|
|
1712
|
-
a.length !== 0 && (async () => {
|
|
1713
|
-
S(!0);
|
|
1714
|
-
let u = a.map((e) => {
|
|
1715
|
-
let i = e.nodeType === U.FOLDER, a = Q(e.sourceUrl, n), s = i ? a : a.replace(/\/$/, ""), c = X(e.sourceUrl, s), { bucket: l, path: u } = r === H.Shared ? xe(s, o.current, t) : {
|
|
1716
|
-
bucket: t,
|
|
1717
|
-
path: s
|
|
1718
|
-
};
|
|
1719
|
-
return {
|
|
1720
|
-
bucket: l,
|
|
1721
|
-
path: u,
|
|
1722
|
-
name: c,
|
|
1723
|
-
nodeType: i ? I.Folder : I.Item
|
|
1724
|
-
};
|
|
1725
|
-
});
|
|
1726
|
-
try {
|
|
1727
|
-
let { results: t } = await e.deleteFiles(u), r = t.filter((e) => !e.success), i = r.length, a = t.length - i, o = t.find((e) => e.success), c = u.find((e) => e.path === o?.path) ?? u[0];
|
|
1728
|
-
if (a > 0 && f?.({
|
|
1729
|
-
variant: B.Success,
|
|
1730
|
-
reason: K.FilesDeleted,
|
|
1731
|
-
count: a,
|
|
1732
|
-
name: c?.name,
|
|
1733
|
-
folder: s || n
|
|
1734
|
-
}), i > 0) {
|
|
1735
|
-
let e = r.slice(0, 3).map((e) => u.find((t) => t.path === e.path)?.name ?? e.path), t = i - e.length;
|
|
1736
|
-
f?.({
|
|
1737
|
-
variant: B.Error,
|
|
1738
|
-
reason: K.FilesDeletePartiallyFailed,
|
|
1739
|
-
names: e,
|
|
1740
|
-
restCount: t
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1743
|
-
} catch {
|
|
1744
|
-
f?.({
|
|
1745
|
-
variant: B.Error,
|
|
1746
|
-
reason: K.DeleteFailed
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1749
|
-
let p = u.filter((e) => e.nodeType === I.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
|
|
1750
|
-
c([...new Set(u.map((e) => {
|
|
1751
|
-
if (e.nodeType === I.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
|
|
1752
|
-
let t = e.path.lastIndexOf("/");
|
|
1753
|
-
return t > 0 ? e.path.slice(0, t + 1) : "";
|
|
1754
|
-
}))]), p.some((e) => i === e || i.startsWith(e)) && d((e) => e.replace(/[^/]+\/$/, "")), l(), S(!1);
|
|
1755
|
-
})();
|
|
1756
|
-
}, [
|
|
1757
|
-
r,
|
|
1758
|
-
t,
|
|
1759
|
-
n,
|
|
1760
|
-
i,
|
|
1761
|
-
f,
|
|
1762
|
-
e,
|
|
1763
|
-
o,
|
|
1764
|
-
c,
|
|
1765
|
-
l,
|
|
1766
|
-
d
|
|
1767
|
-
]), z = k((e, t) => {
|
|
1768
|
-
if (!e || e.trim() === "") return { reason: q.Empty };
|
|
1769
|
-
if (e === ae) return { reason: q.ReservedName };
|
|
1770
|
-
if (Y(e, h)) return {
|
|
1771
|
-
reason: q.ForbiddenSymbols,
|
|
1772
|
-
symbols: ne
|
|
1773
|
-
};
|
|
1774
|
-
if (e.length > 255) return {
|
|
1775
|
-
reason: q.TooLong,
|
|
1776
|
-
maxLength: 255
|
|
1777
|
-
};
|
|
1778
|
-
let n = a?.items ?? [], r = e.toLowerCase(), i = n.find((e) => e.path !== t.path && e.name.toLowerCase() === r);
|
|
1779
|
-
return i ? {
|
|
1780
|
-
reason: q.DuplicateName,
|
|
1781
|
-
existingName: i.name
|
|
1782
|
-
} : null;
|
|
1783
|
-
}, [h, a]), V = k((r, i) => {
|
|
1784
|
-
if (r.length === 0 || T || D) return;
|
|
1785
|
-
let a = new AbortController();
|
|
1786
|
-
A.current = a, (async () => {
|
|
1787
|
-
E(!0);
|
|
1788
|
-
let o = Ee(r, t, n), s = o.map(({ dto: e }) => e);
|
|
1789
|
-
try {
|
|
1790
|
-
let { results: t } = await e.copyFiles(s, a.signal), r = t.filter((e) => !e.success).length, c = t.length - r;
|
|
1791
|
-
if (c > 0) {
|
|
1792
|
-
let e = ke(o, t);
|
|
1793
|
-
p?.({
|
|
1794
|
-
kind: c === 1 ? J.FileCopied : J.FilesCopied,
|
|
1795
|
-
name: e?.destinationName,
|
|
1796
|
-
count: c,
|
|
1797
|
-
destinationFolderName: pe(i, n)
|
|
1798
|
-
});
|
|
1799
|
-
}
|
|
1800
|
-
r > 0 && r < t.length ? f?.({
|
|
1801
|
-
variant: B.Error,
|
|
1802
|
-
reason: K.CopyPartiallyFailed,
|
|
1803
|
-
count: r
|
|
1804
|
-
}) : r === t.length && f?.({
|
|
1805
|
-
variant: B.Error,
|
|
1806
|
-
reason: K.CopyFailed
|
|
1807
|
-
});
|
|
1808
|
-
} catch {
|
|
1809
|
-
a.signal.aborted || f?.({
|
|
1810
|
-
variant: B.Error,
|
|
1811
|
-
reason: K.CopyFailed
|
|
1812
|
-
});
|
|
1813
|
-
} finally {
|
|
1814
|
-
c([...new Set(s.flatMap((e) => [v(e.sourcePath), v(e.destinationPath)]))]), l(), E(!1), A.current = null;
|
|
1815
|
-
}
|
|
1816
|
-
})();
|
|
1817
|
-
}, [
|
|
1818
|
-
t,
|
|
1819
|
-
n,
|
|
1820
|
-
f,
|
|
1821
|
-
p,
|
|
1822
|
-
e,
|
|
1823
|
-
T,
|
|
1824
|
-
D,
|
|
1825
|
-
c,
|
|
1826
|
-
l
|
|
1827
|
-
]), W = k(() => {
|
|
1828
|
-
A.current?.abort();
|
|
1829
|
-
}, []);
|
|
1830
|
-
return {
|
|
1831
|
-
isCreatingFolder: g,
|
|
1832
|
-
isDownloading: y,
|
|
1833
|
-
isDeleting: x,
|
|
1834
|
-
isRenaming: C,
|
|
1835
|
-
isCopying: T,
|
|
1836
|
-
isMoving: D,
|
|
1837
|
-
onCreateFolder: ee,
|
|
1838
|
-
onCreateFolderValidate: F,
|
|
1839
|
-
onDownloadFiles: L,
|
|
1840
|
-
onDeleteFiles: te,
|
|
1841
|
-
onRenameValidate: z,
|
|
1842
|
-
onMoveToFiles: k((r, a, o) => {
|
|
1843
|
-
if (r.length === 0 || T || D || C) return;
|
|
1844
|
-
let { renameDtos: s, preparedMoveItems: u } = De(r, t, n), m = u.map(({ dto: e }) => e), h = new AbortController();
|
|
1845
|
-
m.length > 0 && (A.current = h), (async () => {
|
|
1846
|
-
s.length > 0 && w(!0), m.length > 0 && O(!0);
|
|
1847
|
-
let [t, r] = await Promise.all([(async () => {
|
|
1848
|
-
if (s.length === 0) return {
|
|
1849
|
-
results: [],
|
|
1850
|
-
threw: !1
|
|
1851
|
-
};
|
|
1852
|
-
try {
|
|
1853
|
-
let { results: t } = await e.renameFiles(s);
|
|
1854
|
-
return {
|
|
1855
|
-
results: t,
|
|
1856
|
-
threw: !1
|
|
1857
|
-
};
|
|
1858
|
-
} catch {
|
|
1859
|
-
return {
|
|
1860
|
-
results: [],
|
|
1861
|
-
threw: !0
|
|
1862
|
-
};
|
|
1863
|
-
}
|
|
1864
|
-
})(), (async () => {
|
|
1865
|
-
if (m.length === 0) return {
|
|
1866
|
-
results: [],
|
|
1867
|
-
threw: !1,
|
|
1868
|
-
aborted: !1
|
|
1869
|
-
};
|
|
1870
|
-
try {
|
|
1871
|
-
let { results: t } = await e.moveFiles(m, h.signal);
|
|
1872
|
-
return {
|
|
1873
|
-
results: t,
|
|
1874
|
-
threw: !1,
|
|
1875
|
-
aborted: !1
|
|
1876
|
-
};
|
|
1877
|
-
} catch {
|
|
1878
|
-
return {
|
|
1879
|
-
results: [],
|
|
1880
|
-
threw: !0,
|
|
1881
|
-
aborted: h.signal.aborted
|
|
1882
|
-
};
|
|
1883
|
-
}
|
|
1884
|
-
})()]), a = t.threw ? s.length : t.results.filter((e) => !e.success).length, g = r.threw && r.aborted, _ = g ? 0 : m.length, y = g ? 0 : r.threw ? m.length : r.results.filter((e) => !e.success).length, b = r.threw ? 0 : r.results.filter((e) => e.success).length, x = s.length + _, S = a + y, C = y > 0;
|
|
1885
|
-
if (b > 0) {
|
|
1886
|
-
let e = ke(u, r.results);
|
|
1887
|
-
p?.({
|
|
1888
|
-
kind: b === 1 ? J.FileMoved : J.FilesMoved,
|
|
1889
|
-
name: e?.destinationName,
|
|
1890
|
-
count: b,
|
|
1891
|
-
destinationFolderName: pe(o, n)
|
|
1892
|
-
});
|
|
1893
|
-
}
|
|
1894
|
-
if (s.length === 1 && a === 0) {
|
|
1895
|
-
let [e] = s;
|
|
1896
|
-
p?.({
|
|
1897
|
-
kind: J.FileRenamed,
|
|
1898
|
-
name: X(e.destinationPath, e.destinationPath),
|
|
1899
|
-
isFolder: e.nodeType === R.Folder
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
S > 0 && (S === x ? f?.({
|
|
1903
|
-
variant: B.Error,
|
|
1904
|
-
reason: C ? K.MoveFailed : K.RenameFailed
|
|
1905
|
-
}) : f?.({
|
|
1906
|
-
variant: B.Error,
|
|
1907
|
-
reason: C ? K.MovePartiallyFailed : K.RenamePartiallyFailed,
|
|
1908
|
-
count: S
|
|
1909
|
-
}));
|
|
1910
|
-
let T = s.find((e) => e.nodeType === R.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
|
|
1911
|
-
if (T != null) {
|
|
1912
|
-
let e = T.sourcePath.endsWith("/") ? T.sourcePath : `${T.sourcePath}/`;
|
|
1913
|
-
if (i === e || i.startsWith(e)) {
|
|
1914
|
-
let t = T.destinationPath.endsWith("/") ? T.destinationPath : `${T.destinationPath}/`;
|
|
1915
|
-
d(i.replace(e, t));
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
c([...new Set([...s, ...m].flatMap((e) => [v(e.sourcePath), v(e.destinationPath)]))]), l(), w(!1), O(!1), m.length > 0 && (A.current = null);
|
|
1919
|
-
})();
|
|
1920
|
-
}, [
|
|
1921
|
-
t,
|
|
1922
|
-
n,
|
|
1923
|
-
i,
|
|
1924
|
-
p,
|
|
1925
|
-
f,
|
|
1926
|
-
e,
|
|
1927
|
-
T,
|
|
1928
|
-
D,
|
|
1929
|
-
C,
|
|
1930
|
-
c,
|
|
1931
|
-
l,
|
|
1932
|
-
d
|
|
1933
|
-
]),
|
|
1934
|
-
onCopyFiles: V,
|
|
1935
|
-
cancelCopyMove: W
|
|
1936
|
-
};
|
|
1937
|
-
}, Ut = ({ filesApi: e, bucket: t, rootLabel: n, bumpRetry: r, onNotification: i }) => {
|
|
1938
|
-
let [a, o] = N(!1), [s, c] = N(!1);
|
|
1939
|
-
return {
|
|
1940
|
-
isUnsharing: a,
|
|
1941
|
-
isRemovingAccess: s,
|
|
1942
|
-
onUnshareFiles: k((a) => {
|
|
1943
|
-
a.length !== 0 && (async () => {
|
|
1944
|
-
o(!0);
|
|
1945
|
-
let s = a.map((e) => {
|
|
1946
|
-
let r = e.bucket ?? t;
|
|
1947
|
-
return {
|
|
1948
|
-
bucket: r,
|
|
1949
|
-
path: Te(e, r, n)
|
|
1950
|
-
};
|
|
1951
|
-
});
|
|
1952
|
-
try {
|
|
1953
|
-
await e.discardShared(s), r();
|
|
1954
|
-
} catch {
|
|
1955
|
-
i?.({
|
|
1956
|
-
variant: B.Error,
|
|
1957
|
-
reason: K.UnshareFailed
|
|
1958
|
-
});
|
|
1959
|
-
} finally {
|
|
1960
|
-
o(!1);
|
|
1961
|
-
}
|
|
1962
|
-
})();
|
|
1963
|
-
}, [
|
|
1964
|
-
t,
|
|
1965
|
-
n,
|
|
1966
|
-
i,
|
|
1967
|
-
e,
|
|
1968
|
-
r
|
|
1969
|
-
]),
|
|
1970
|
-
onRemoveFilesAccess: k((a) => {
|
|
1971
|
-
a.length !== 0 && (async () => {
|
|
1972
|
-
c(!0);
|
|
1973
|
-
let o = a.map((e) => {
|
|
1974
|
-
let r = e.bucket ?? t;
|
|
1975
|
-
return {
|
|
1976
|
-
bucket: r,
|
|
1977
|
-
path: Te(e, r, n)
|
|
1978
|
-
};
|
|
1979
|
-
});
|
|
1980
|
-
try {
|
|
1981
|
-
await e.revokeAccess(o), r();
|
|
1982
|
-
} catch {
|
|
1983
|
-
i?.({
|
|
1984
|
-
variant: B.Error,
|
|
1985
|
-
reason: K.RemoveAccessFailed
|
|
1986
|
-
});
|
|
1987
|
-
} finally {
|
|
1988
|
-
c(!1);
|
|
1989
|
-
}
|
|
1990
|
-
})();
|
|
1991
|
-
}, [
|
|
1992
|
-
t,
|
|
1993
|
-
n,
|
|
1994
|
-
i,
|
|
1995
|
-
e,
|
|
1996
|
-
r
|
|
1997
|
-
])
|
|
1998
|
-
};
|
|
1999
|
-
}, Wt = 5, Gt = (e) => e.error ? `${e.path} (${e.error})` : e.path, Kt = (e) => {
|
|
2000
|
-
let t = e.slice(0, Wt);
|
|
2001
|
-
return {
|
|
2002
|
-
names: t.map(Gt),
|
|
2003
|
-
restCount: e.length - t.length
|
|
2004
|
-
};
|
|
2005
|
-
}, qt = (e, t) => `${e}${t}/`, Jt = (e) => /\.zip$/i.test(e), Yt = (e) => {
|
|
2006
|
-
let [t] = e;
|
|
2007
|
-
if (!(e.length !== 1 || t == null)) return Jt(t.fileContent.name) && !Jt(t.name) ? t : void 0;
|
|
2008
|
-
}, Xt = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, cache: i, sharedRootMetaRef: a, invalidateFolders: o, bumpRetry: s, onNotification: c }) => {
|
|
2009
|
-
let [l, u] = N(null), d = M(null), f = k((r, i, a) => {
|
|
2010
|
-
let l = Q(a, n);
|
|
2011
|
-
u({
|
|
2012
|
-
files: [{
|
|
2013
|
-
id: `${Date.now()}-archive`,
|
|
2014
|
-
name: i,
|
|
2015
|
-
status: p.Uploading
|
|
2016
|
-
}],
|
|
2017
|
-
isOpen: !0
|
|
2018
|
-
}), (async () => {
|
|
2019
|
-
try {
|
|
2020
|
-
let { results: n } = await e.uploadArchive(r, t, qt(l, i)), a = n.filter((e) => e.success).length, o = n.filter((e) => !e.success), s = o.length, { names: u, restCount: d } = Kt(o);
|
|
2021
|
-
n.length > 0 && a === 0 ? c?.({
|
|
2022
|
-
variant: B.Error,
|
|
2023
|
-
reason: K.UploadArchiveFailed,
|
|
2024
|
-
names: u,
|
|
2025
|
-
restCount: d
|
|
2026
|
-
}) : s > 0 && c?.({
|
|
2027
|
-
variant: B.Error,
|
|
2028
|
-
reason: K.UploadArchivePartiallyFailed,
|
|
2029
|
-
count: s,
|
|
2030
|
-
names: u,
|
|
2031
|
-
restCount: d
|
|
2032
|
-
});
|
|
2033
|
-
} catch {
|
|
2034
|
-
c?.({
|
|
2035
|
-
variant: B.Error,
|
|
2036
|
-
reason: K.UploadArchiveRequestFailed
|
|
2037
|
-
});
|
|
2038
|
-
} finally {
|
|
2039
|
-
o([l]), s(), u(null);
|
|
2040
|
-
}
|
|
2041
|
-
})();
|
|
2042
|
-
}, [
|
|
2043
|
-
t,
|
|
2044
|
-
n,
|
|
2045
|
-
c,
|
|
2046
|
-
e,
|
|
2047
|
-
o,
|
|
2048
|
-
s
|
|
2049
|
-
]);
|
|
2050
|
-
return {
|
|
2051
|
-
onUploadFiles: k((l, m) => {
|
|
2052
|
-
if (l.length === 0) return;
|
|
2053
|
-
let h = Yt(l);
|
|
2054
|
-
if (h != null) {
|
|
2055
|
-
f(h.fileContent, h.name, m);
|
|
2056
|
-
return;
|
|
2057
|
-
}
|
|
2058
|
-
let g = new AbortController();
|
|
2059
|
-
d.current = g, u({
|
|
2060
|
-
files: l.map((e, t) => ({
|
|
2061
|
-
id: `${Date.now()}-${t}`,
|
|
2062
|
-
name: e.name,
|
|
2063
|
-
status: p.Queued
|
|
2064
|
-
})),
|
|
2065
|
-
isOpen: !0
|
|
2066
|
-
});
|
|
2067
|
-
let _ = Q(m, n), { bucket: v, path: y } = r === H.Shared ? xe(_, a.current, t) : {
|
|
2068
|
-
bucket: t,
|
|
2069
|
-
path: _
|
|
2070
|
-
}, b = new Set((i.get(_) ?? []).map((e) => e.name.toLowerCase()));
|
|
2071
|
-
(async () => {
|
|
2072
|
-
let t = 0, r = 0, i = 0, a = async () => {
|
|
2073
|
-
for (; t < l.length;) {
|
|
2074
|
-
let n = t++, a = l[n];
|
|
2075
|
-
if (g.signal.aborted) {
|
|
2076
|
-
u((e) => Me(e, n, p.Cancelled));
|
|
2077
|
-
continue;
|
|
2078
|
-
}
|
|
2079
|
-
u((e) => Me(e, n, {
|
|
2080
|
-
status: p.Uploading,
|
|
2081
|
-
percent: 0
|
|
2082
|
-
}));
|
|
2083
|
-
let o = b.has(a.name.toLowerCase()) ? re.Overwrite : re.CreateOnly;
|
|
2084
|
-
try {
|
|
2085
|
-
await e.uploadFile(v, `${y}${a.name}`, a.fileContent, {
|
|
2086
|
-
signal: g.signal,
|
|
2087
|
-
uploadMode: o,
|
|
2088
|
-
onProgress: (e) => {
|
|
2089
|
-
u((t) => Me(t, n, {
|
|
2090
|
-
status: p.Uploading,
|
|
2091
|
-
percent: e
|
|
2092
|
-
}));
|
|
2093
|
-
}
|
|
2094
|
-
}), u((e) => Me(e, n, {
|
|
2095
|
-
status: p.Completed,
|
|
2096
|
-
percent: 100
|
|
2097
|
-
})), r += 1;
|
|
2098
|
-
} catch {
|
|
2099
|
-
let e = g.signal.aborted ? p.Cancelled : p.Failed;
|
|
2100
|
-
e === p.Failed && (i += 1), u((t) => Me(t, n, e));
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
};
|
|
2104
|
-
await Promise.all(Array.from({ length: 3 }, () => a())), g.signal.aborted || (r === 0 && i > 0 ? c?.({
|
|
2105
|
-
variant: B.Error,
|
|
2106
|
-
reason: K.UploadFailed
|
|
2107
|
-
}) : c?.({
|
|
2108
|
-
variant: B.Success,
|
|
2109
|
-
reason: K.UploadCompleted,
|
|
2110
|
-
folder: y || n
|
|
2111
|
-
})), o([_]), s(), d.current = null, u(null);
|
|
2112
|
-
})();
|
|
2113
|
-
}, [
|
|
2114
|
-
r,
|
|
2115
|
-
t,
|
|
2116
|
-
i,
|
|
2117
|
-
n,
|
|
2118
|
-
c,
|
|
2119
|
-
e,
|
|
2120
|
-
a,
|
|
2121
|
-
o,
|
|
2122
|
-
s,
|
|
2123
|
-
f
|
|
2124
|
-
]),
|
|
2125
|
-
onUploadArchive: k((e, t, n) => {
|
|
2126
|
-
f(e, t, n);
|
|
2127
|
-
}, [f]),
|
|
2128
|
-
onValidateUpload: k(async (e, t, n) => {
|
|
2129
|
-
for (let t of e) t.name = zt(t.name);
|
|
2130
|
-
return { valid: !0 };
|
|
2131
|
-
}, []),
|
|
2132
|
-
uploadBatchState: l,
|
|
2133
|
-
cancelUpload: k(() => {
|
|
2134
|
-
d.current?.abort();
|
|
2135
|
-
}, []),
|
|
2136
|
-
clearUploadBatch: k(() => {
|
|
2137
|
-
u(null);
|
|
2138
|
-
}, [])
|
|
2139
|
-
};
|
|
2140
|
-
}, Zt = ({ filesApi: e, bucket: t, rootLabel: n = "My files", activeTab: r = H.MyFiles, onNotification: i, onOperationSuccess: a, forbiddenSymbolsRegExp: o, variant: s = d.Attach, actionProfile: c, labels: l, locale: f, disabledNewButtonTooltip: p, downloadDestination: m, buildValidationErrorMessage: h }) => {
|
|
2141
|
-
let g = c ?? de(s), _ = Bt({
|
|
2142
|
-
filesApi: e,
|
|
2143
|
-
bucket: t,
|
|
2144
|
-
rootLabel: n,
|
|
2145
|
-
activeTab: r,
|
|
2146
|
-
onNotification: i
|
|
2147
|
-
}), v = Xt({
|
|
2148
|
-
filesApi: e,
|
|
2149
|
-
bucket: t,
|
|
2150
|
-
rootLabel: n,
|
|
2151
|
-
activeTab: r,
|
|
2152
|
-
cache: _.cache,
|
|
2153
|
-
sharedRootMetaRef: _.sharedRootMetaRef,
|
|
2154
|
-
invalidateFolders: _.invalidateFolders,
|
|
2155
|
-
bumpRetry: _.bumpRetry,
|
|
2156
|
-
onNotification: i
|
|
2157
|
-
}), y = Ht({
|
|
2158
|
-
filesApi: e,
|
|
2159
|
-
bucket: t,
|
|
2160
|
-
rootLabel: n,
|
|
2161
|
-
activeTab: r,
|
|
2162
|
-
folderPath: _.folderPath,
|
|
2163
|
-
currentFolder: _.currentFolder,
|
|
2164
|
-
sharedRootMetaRef: _.sharedRootMetaRef,
|
|
2165
|
-
listingPermissionsCache: _.listingPermissionsCache,
|
|
2166
|
-
invalidateFolders: _.invalidateFolders,
|
|
2167
|
-
bumpRetry: _.bumpRetry,
|
|
2168
|
-
mergeCreatedFolder: _.mergeCreatedFolder,
|
|
2169
|
-
setFolderPath: _.setFolderPath,
|
|
2170
|
-
onNotification: i,
|
|
2171
|
-
onOperationSuccess: a,
|
|
2172
|
-
downloadDestination: m,
|
|
2173
|
-
forbiddenSymbolsRegExp: o
|
|
2174
|
-
}), b = Ut({
|
|
2175
|
-
filesApi: e,
|
|
2176
|
-
bucket: t,
|
|
2177
|
-
rootLabel: n,
|
|
2178
|
-
bumpRetry: _.bumpRetry,
|
|
2179
|
-
onNotification: i
|
|
2180
|
-
}), x = Vt({
|
|
2181
|
-
filesApi: e,
|
|
2182
|
-
bucket: t,
|
|
2183
|
-
rootLabel: n,
|
|
2184
|
-
onNotification: i
|
|
2185
|
-
}), S = he(_.currentFolder), C = j(() => r === H.Organization || r === H.Shared && _.folderPath === "" ? !1 : S, [
|
|
2186
|
-
r,
|
|
2187
|
-
_.folderPath,
|
|
2188
|
-
S
|
|
2189
|
-
]), w = j(() => r === H.Shared ? le : ce, [r]), T = j(() => {
|
|
2190
|
-
let e = {}, t = (t) => {
|
|
2191
|
-
let n = l[t];
|
|
2192
|
-
n != null && (e[t] = n);
|
|
2193
|
-
};
|
|
2194
|
-
return t(V.Download), r === H.MyFiles ? (t(V.Delete), C && (t(V.Rename), _e(g) && (t(V.Copy), t(V.Move), t(V.Duplicate))), ve(g) && t(V.RemoveAccess)) : r === H.Shared && ve(g) && t(V.Unshare), g === u.Full && t(V.Info), e;
|
|
2195
|
-
}, [
|
|
2196
|
-
r,
|
|
2197
|
-
C,
|
|
2198
|
-
g,
|
|
2199
|
-
l
|
|
2200
|
-
]), E = j(() => y.isCreatingFolder || y.isDownloading || y.isDeleting || y.isRenaming || y.isCopying || y.isMoving || b.isUnsharing || b.isRemovingAccess || v.uploadBatchState != null, [
|
|
2201
|
-
y.isCreatingFolder,
|
|
2202
|
-
y.isDownloading,
|
|
2203
|
-
y.isDeleting,
|
|
2204
|
-
y.isRenaming,
|
|
2205
|
-
y.isCopying,
|
|
2206
|
-
y.isMoving,
|
|
2207
|
-
b.isUnsharing,
|
|
2208
|
-
b.isRemovingAccess,
|
|
2209
|
-
v.uploadBatchState
|
|
2210
|
-
]), D = k((e, t) => {
|
|
2211
|
-
let n = y.onCreateFolderValidate(e, t);
|
|
2212
|
-
return n ? h(n) : null;
|
|
2213
|
-
}, [y, h]), O = k((e, t) => {
|
|
2214
|
-
let n = y.onRenameValidate(e, t);
|
|
2215
|
-
return n ? h(n, t) : null;
|
|
2216
|
-
}, [y, h]);
|
|
2217
|
-
return {
|
|
2218
|
-
items: _.items,
|
|
2219
|
-
isLoading: _.isLoading,
|
|
2220
|
-
error: _.error,
|
|
2221
|
-
path: _.path,
|
|
2222
|
-
onPathChange: _.onPathChange,
|
|
2223
|
-
retry: _.retry,
|
|
2224
|
-
onSearchFiles: _.onSearchFiles,
|
|
2225
|
-
isSearching: _.isSearching,
|
|
2226
|
-
searchResults: _.searchResults,
|
|
2227
|
-
clearSearchResults: _.clearSearchResults,
|
|
2228
|
-
expandedPaths: _.expandedPaths,
|
|
2229
|
-
loadedPaths: _.loadedPaths,
|
|
2230
|
-
onExpandedPathsChange: _.onExpandedPathsChange,
|
|
2231
|
-
onFolderPopupPathChange: _.onFolderPopupPathChange,
|
|
2232
|
-
folderPopupLoadingPaths: _.folderPopupLoadingPaths,
|
|
2233
|
-
onUploadFiles: v.onUploadFiles,
|
|
2234
|
-
onUploadArchive: v.onUploadArchive,
|
|
2235
|
-
onValidateUpload: v.onValidateUpload,
|
|
2236
|
-
uploadBatchState: v.uploadBatchState,
|
|
2237
|
-
cancelUpload: v.cancelUpload,
|
|
2238
|
-
clearUploadBatch: v.clearUploadBatch,
|
|
2239
|
-
onCreateFolder: y.onCreateFolder,
|
|
2240
|
-
onCreateFolderValidate: D,
|
|
2241
|
-
isCreatingFolder: y.isCreatingFolder,
|
|
2242
|
-
onDownloadFiles: y.onDownloadFiles,
|
|
2243
|
-
isDownloading: y.isDownloading,
|
|
2244
|
-
onDeleteFiles: y.onDeleteFiles,
|
|
2245
|
-
isDeleting: y.isDeleting,
|
|
2246
|
-
onRenameValidate: O,
|
|
2247
|
-
onMoveToFiles: y.onMoveToFiles,
|
|
2248
|
-
isRenaming: y.isRenaming,
|
|
2249
|
-
onCopyFiles: y.onCopyFiles,
|
|
2250
|
-
isCopying: y.isCopying,
|
|
2251
|
-
isMoving: y.isMoving,
|
|
2252
|
-
cancelCopyMove: y.cancelCopyMove,
|
|
2253
|
-
uploadEnabled: C,
|
|
2254
|
-
isNewButtonDisabled: !C,
|
|
2255
|
-
disabledNewButtonTooltip: p,
|
|
2256
|
-
visibleColumns: w,
|
|
2257
|
-
dateLocale: f,
|
|
2258
|
-
dateOptions: se,
|
|
2259
|
-
actionLabels: T,
|
|
2260
|
-
sharedWithMeIds: _.sharedWithMeIds,
|
|
2261
|
-
sharedByMePaths: _.sharedByMePaths,
|
|
2262
|
-
onUnshareFiles: b.onUnshareFiles,
|
|
2263
|
-
isUnsharing: b.isUnsharing,
|
|
2264
|
-
onRemoveFilesAccess: b.onRemoveFilesAccess,
|
|
2265
|
-
isRemovingAccess: b.isRemovingAccess,
|
|
2266
|
-
fileMetadata: x.fileMetadata,
|
|
2267
|
-
isFileMetadataLoading: x.isFileMetadataLoading,
|
|
2268
|
-
onGetInfo: x.onGetInfo,
|
|
2269
|
-
clearMetadata: x.clearMetadata,
|
|
2270
|
-
isAnyOperationInProgress: E
|
|
2271
|
-
};
|
|
2272
|
-
}, Qt = [
|
|
2273
|
-
H.MyFiles,
|
|
2274
|
-
H.Shared,
|
|
2275
|
-
H.Organization
|
|
2276
|
-
], $t = (e, t, n, r) => {
|
|
2277
|
-
let i = k((e) => r == null || r.includes(e), [r]), a = j(() => n?.filter((e) => i(e.id)).flatMap(({ id: e, label: t, disabled: n }) => typeof t == "string" ? [{
|
|
2278
|
-
id: e,
|
|
2279
|
-
label: t,
|
|
2280
|
-
disabled: n
|
|
2281
|
-
}] : []), [n, i]);
|
|
2282
|
-
return A(() => {
|
|
2283
|
-
i(e) || t(Qt.find((e) => i(e)) ?? H.MyFiles);
|
|
2284
|
-
}, [
|
|
2285
|
-
i,
|
|
2286
|
-
e,
|
|
2287
|
-
t
|
|
2288
|
-
]), { tabs: a };
|
|
2289
|
-
};
|
|
2290
|
-
//#endregion
|
|
2291
|
-
export { Z as $, gt as A, Pe as B, at as C, J as Ct, yt as D, it as E, Be as F, je as G, Oe as H, ze as I, De as J, Me as K, Re as L, wt as M, ht as N, mt as O, Dt as P, be as Q, Ae as R, pt as S, q as St, vt as T, Ie as U, ke as V, Fe as W, Te as X, v as Y, Q as Z, Ot as _, se as _t, Ht as a, Y as at, ct as b, ie as bt, zt as c, fe as ct, It as d, u as dt, ge as et, Ft as f, d as ft, kt as g, ue as gt, Pt as h, le as ht, Ut as i, he as it, Tt as j, Et as k, Lt as l, ye as lt, Nt as m, ce as mt, Zt as n, pe as nt, Vt as o, _e as ot, Mt as p, de as pt, Ee as q, Xt as r, X as rt, Bt as s, ve as st, $t as t, me as tt, Rt as u, xe as ut, At as v, oe as vt, xt as w, re as wt, nt as x, K as xt, bt as y, ae as yt, Ne as z };
|