@gkd-kit/inspect 0.0.1701618945540 → 0.0.1701761676275

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/404.html +7 -7
  2. package/dist/assets/ActionCard.vue_vue_type_script_setup_true_lang-d948deff.js +1388 -0
  3. package/dist/assets/DevicePage-fa8bcfbf.js +457 -0
  4. package/dist/assets/HomePage-e4a77c59.js +400 -0
  5. package/dist/assets/ImportPage-32019896.js +87 -0
  6. package/dist/assets/SnapshotPage-430959f6.js +3628 -0
  7. package/dist/assets/_404Page-e1f46b50.js +30 -0
  8. package/dist/assets/import-db3ec019.js +288 -0
  9. package/dist/assets/index-9eef18bb.css +360 -0
  10. package/dist/assets/index-b6ecc2e7.js +9780 -0
  11. package/dist/assets/index-df0b30b5.js +21365 -0
  12. package/dist/assets/jszip.min-9024b065.js +2651 -0
  13. package/dist/assets/node-8fda318c.js +7817 -0
  14. package/dist/assets/polyfills-82a76ef1.js +11381 -0
  15. package/dist/assets/storage-71d9086d.js +4479 -0
  16. package/dist/assets/table-9941a21f.js +8763 -0
  17. package/dist/index.html +7 -7
  18. package/package.json +25 -26
  19. package/dist/assets/ActionCard.vue_vue_type_script_setup_true_lang-e0e6453b.js +0 -10
  20. package/dist/assets/ActionCard.vue_vue_type_script_setup_true_lang-e0e6453b.js.map +0 -1
  21. package/dist/assets/DevicePage-6d350a54.js +0 -4
  22. package/dist/assets/DevicePage-6d350a54.js.map +0 -1
  23. package/dist/assets/HomePage-f6150882.js +0 -10
  24. package/dist/assets/HomePage-f6150882.js.map +0 -1
  25. package/dist/assets/ImportPage-e1fd5e19.js +0 -2
  26. package/dist/assets/ImportPage-e1fd5e19.js.map +0 -1
  27. package/dist/assets/SnapshotPage-49b5182f.css +0 -1
  28. package/dist/assets/SnapshotPage-57332573.js +0 -241
  29. package/dist/assets/SnapshotPage-57332573.js.map +0 -1
  30. package/dist/assets/_404Page-0de639dc.js +0 -2
  31. package/dist/assets/_404Page-0de639dc.js.map +0 -1
  32. package/dist/assets/_404Page-2ece9679.css +0 -1
  33. package/dist/assets/_plugin-vue_export-helper-c27b6911.js +0 -2
  34. package/dist/assets/_plugin-vue_export-helper-c27b6911.js.map +0 -1
  35. package/dist/assets/import-ad987535.js +0 -2
  36. package/dist/assets/import-ad987535.js.map +0 -1
  37. package/dist/assets/index-2cec9166.js +0 -17
  38. package/dist/assets/index-2cec9166.js.map +0 -1
  39. package/dist/assets/index-5093d345.css +0 -1
  40. package/dist/assets/index-d459a9d6.js +0 -558
  41. package/dist/assets/index-d459a9d6.js.map +0 -1
  42. package/dist/assets/jszip.min-3b5196b7.js +0 -13
  43. package/dist/assets/jszip.min-3b5196b7.js.map +0 -1
  44. package/dist/assets/node-f710d8d6.js +0 -731
  45. package/dist/assets/node-f710d8d6.js.map +0 -1
  46. package/dist/assets/polyfills-f223ca2c.js +0 -1
  47. package/dist/assets/storage-79dd328c.js +0 -330
  48. package/dist/assets/storage-79dd328c.js.map +0 -1
  49. package/dist/assets/table-a8d8181f.js +0 -958
  50. package/dist/assets/table-a8d8181f.js.map +0 -1
@@ -0,0 +1,3628 @@
1
+ import { _ as _sfc_main$6, e as exportSnapshotAsJpgUrl, f as exportSnapshotAsZipUrl } from "./ActionCard.vue_vue_type_script_setup_true_lang-d948deff.js";
2
+ import { f as fadeInHeightExpandTransition, c as copy, m as message, b as githubJpgStorage, g as githubUrlToSelfUrl, e as githubZipStorage, a as snapshotStorage, h as gmOk, i as screenshotStorage, j as delay } from "./storage-71d9086d.js";
3
+ import { d as defineComponent, n as h, p as commonLight, q as cB, v as cM, x as cE, y as c, z as useConfig, A as ref, c as computed, B as useTheme, C as provide, D as useRtl, E as useThemeClass, G as createInjectionKey, H as call, I as useFalseUntilTruthy, J as toRef, K as withDirectives, L as vShow, M as NFadeInExpandTransition, O as createId, P as useMemo, Q as inject, S as throwError, T as resolveSlotWithProps, U as NBaseIcon, V as resolveWrappedSlotWithProps, W as composite, X as createTheme, Y as scrollbarLight, Z as changeColor, _ as cNotM, $ as insideModal, a0 as insidePopover, a1 as createKey, a2 as NIconSwitchTransition, a3 as NBaseLoading, a4 as render, a5 as isBrowser, a6 as onMounted, a7 as repeat, a8 as pxfy, a9 as iconSwitchTransition, w as watchEffect, e as watch, aa as getMargin, ab as depx, ac as XScrollbar, ad as resolveSlot, ae as nextTick, a as shallowReactive, s as shallowRef, af as onUnmounted, ag as createBlock, h as createBaseVNode, ah as renderSlot, ai as normalizeStyle, aj as normalizeClass, ak as Teleport, o as openBlock, g as withCtx, b as createVNode, u as unref, f as createElementBlock, al as renderList, F as Fragment, l as toDisplayString, m as createCommentVNode, k as createTextVNode, i as withKeys, j as NButton, am as withModifiers, an as useRoute, ao as useRouter } from "./index-df0b30b5.js";
4
+ import { e as useMergedState, C as ChevronRightIcon, f as checkboxLight, g as emptyLight, h as NCheckbox, i as happensIn, V as VVirtualList, j as createTreeMate, k as flatten, l as createIndexGetter, m as NEmpty, n as NTooltip, d as NIcon, o as NEllipsis, p as findNodeByXy, c as NSpace, q as NRadio, r as NRadioGroup, N as NInput, a as NInputGroup, s as getNodeLabel, t as dayjs, v as getDevice, w as listToTree } from "./node-8fda318c.js";
5
+ import { e as errorTry, a as errorWrap, p as parseSelector, l as lib, u as useTitle } from "./index-b6ecc2e7.js";
6
+ import "./jszip.min-9024b065.js";
7
+ function createDataKey(key) {
8
+ return typeof key === "string" ? `s-${key}` : `n-${key}`;
9
+ }
10
+ const ChevronLeftIcon = defineComponent({
11
+ name: "ChevronLeft",
12
+ render() {
13
+ return h(
14
+ "svg",
15
+ { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
16
+ h("path", { d: "M10.3536 3.14645C10.5488 3.34171 10.5488 3.65829 10.3536 3.85355L6.20711 8L10.3536 12.1464C10.5488 12.3417 10.5488 12.6583 10.3536 12.8536C10.1583 13.0488 9.84171 13.0488 9.64645 12.8536L5.14645 8.35355C4.95118 8.15829 4.95118 7.84171 5.14645 7.64645L9.64645 3.14645C9.84171 2.95118 10.1583 2.95118 10.3536 3.14645Z", fill: "currentColor" })
17
+ );
18
+ }
19
+ });
20
+ const SwitcherIcon = defineComponent({
21
+ name: "Switcher",
22
+ render() {
23
+ return h(
24
+ "svg",
25
+ { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32" },
26
+ h("path", { d: "M12 8l10 8l-10 8z" })
27
+ );
28
+ }
29
+ });
30
+ const self$2 = (vars) => {
31
+ const { fontWeight, textColor1, textColor2, textColorDisabled, dividerColor, fontSize } = vars;
32
+ return {
33
+ titleFontSize: fontSize,
34
+ titleFontWeight: fontWeight,
35
+ dividerColor,
36
+ titleTextColor: textColor1,
37
+ titleTextColorDisabled: textColorDisabled,
38
+ fontSize,
39
+ textColor: textColor2,
40
+ arrowColor: textColor2,
41
+ arrowColorDisabled: textColorDisabled,
42
+ itemMargin: "16px 0 0 0",
43
+ titlePadding: "16px 0 0 0"
44
+ };
45
+ };
46
+ const collapseLight = {
47
+ name: "Collapse",
48
+ common: commonLight,
49
+ self: self$2
50
+ };
51
+ const collapseLight$1 = collapseLight;
52
+ const style$2 = cB("collapse", "width: 100%;", [cB("collapse-item", `
53
+ font-size: var(--n-font-size);
54
+ color: var(--n-text-color);
55
+ transition:
56
+ color .3s var(--n-bezier),
57
+ border-color .3s var(--n-bezier);
58
+ margin: var(--n-item-margin);
59
+ `, [cM("disabled", [cE("header", "cursor: not-allowed;", [cE("header-main", `
60
+ color: var(--n-title-text-color-disabled);
61
+ `), cB("collapse-item-arrow", `
62
+ color: var(--n-arrow-color-disabled);
63
+ `)])]), cB("collapse-item", "margin-left: 32px;"), c("&:first-child", "margin-top: 0;"), c("&:first-child >", [cE("header", "padding-top: 0;")]), cM("left-arrow-placement", [cE("header", [cB("collapse-item-arrow", "margin-right: 4px;")])]), cM("right-arrow-placement", [cE("header", [cB("collapse-item-arrow", "margin-left: 4px;")])]), cE("content-wrapper", [cE("content-inner", "padding-top: 16px;"), fadeInHeightExpandTransition({
64
+ duration: "0.15s"
65
+ })]), cM("active", [cE("header", [cM("active", [cB("collapse-item-arrow", "transform: rotate(90deg);")])])]), c("&:not(:first-child)", "border-top: 1px solid var(--n-divider-color);"), cE("header", `
66
+ font-size: var(--n-title-font-size);
67
+ display: flex;
68
+ flex-wrap: nowrap;
69
+ align-items: center;
70
+ transition: color .3s var(--n-bezier);
71
+ position: relative;
72
+ padding: var(--n-title-padding);
73
+ color: var(--n-title-text-color);
74
+ cursor: pointer;
75
+ `, [cE("header-main", `
76
+ display: flex;
77
+ flex-wrap: nowrap;
78
+ align-items: center;
79
+ font-weight: var(--n-title-font-weight);
80
+ transition: color .3s var(--n-bezier);
81
+ flex: 1;
82
+ color: var(--n-title-text-color);
83
+ `), cE("header-extra", `
84
+ display: flex;
85
+ align-items: center;
86
+ transition: color .3s var(--n-bezier);
87
+ color: var(--n-text-color);
88
+ `), cB("collapse-item-arrow", `
89
+ display: flex;
90
+ transition:
91
+ transform .15s var(--n-bezier),
92
+ color .3s var(--n-bezier);
93
+ font-size: 18px;
94
+ color: var(--n-arrow-color);
95
+ `)])])]);
96
+ const collapseProps = Object.assign(Object.assign({}, useTheme.props), {
97
+ defaultExpandedNames: {
98
+ type: [Array, String],
99
+ default: null
100
+ },
101
+ expandedNames: [Array, String],
102
+ arrowPlacement: {
103
+ type: String,
104
+ default: "left"
105
+ },
106
+ accordion: {
107
+ type: Boolean,
108
+ default: false
109
+ },
110
+ displayDirective: {
111
+ type: String,
112
+ default: "if"
113
+ },
114
+ onItemHeaderClick: [Function, Array],
115
+ "onUpdate:expandedNames": [Function, Array],
116
+ onUpdateExpandedNames: [Function, Array],
117
+ // deprecated
118
+ onExpandedNamesChange: {
119
+ type: [Function, Array],
120
+ validator: () => {
121
+ return true;
122
+ },
123
+ default: void 0
124
+ }
125
+ });
126
+ const collapseInjectionKey = createInjectionKey("n-collapse");
127
+ const NCollapse = defineComponent({
128
+ name: "Collapse",
129
+ props: collapseProps,
130
+ setup(props, { slots }) {
131
+ const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props);
132
+ const uncontrolledExpandedNamesRef = ref(props.defaultExpandedNames);
133
+ const controlledExpandedNamesRef = computed(() => props.expandedNames);
134
+ const mergedExpandedNamesRef = useMergedState(controlledExpandedNamesRef, uncontrolledExpandedNamesRef);
135
+ const themeRef = useTheme("Collapse", "-collapse", style$2, collapseLight$1, props, mergedClsPrefixRef);
136
+ function doUpdateExpandedNames(names) {
137
+ const { "onUpdate:expandedNames": _onUpdateExpandedNames, onUpdateExpandedNames, onExpandedNamesChange } = props;
138
+ if (onUpdateExpandedNames) {
139
+ call(onUpdateExpandedNames, names);
140
+ }
141
+ if (_onUpdateExpandedNames) {
142
+ call(_onUpdateExpandedNames, names);
143
+ }
144
+ if (onExpandedNamesChange) {
145
+ call(onExpandedNamesChange, names);
146
+ }
147
+ uncontrolledExpandedNamesRef.value = names;
148
+ }
149
+ function doItemHeaderClick(info) {
150
+ const { onItemHeaderClick } = props;
151
+ if (onItemHeaderClick) {
152
+ call(onItemHeaderClick, info);
153
+ }
154
+ }
155
+ function toggleItem(collapse, name, event) {
156
+ const { accordion } = props;
157
+ const { value: expandedNames } = mergedExpandedNamesRef;
158
+ if (accordion) {
159
+ if (collapse) {
160
+ doUpdateExpandedNames([name]);
161
+ doItemHeaderClick({ name, expanded: true, event });
162
+ } else {
163
+ doUpdateExpandedNames([]);
164
+ doItemHeaderClick({ name, expanded: false, event });
165
+ }
166
+ } else {
167
+ if (!Array.isArray(expandedNames)) {
168
+ doUpdateExpandedNames([name]);
169
+ doItemHeaderClick({ name, expanded: true, event });
170
+ } else {
171
+ const activeNames = expandedNames.slice();
172
+ const index = activeNames.findIndex((activeName) => name === activeName);
173
+ if (~index) {
174
+ activeNames.splice(index, 1);
175
+ doUpdateExpandedNames(activeNames);
176
+ doItemHeaderClick({ name, expanded: false, event });
177
+ } else {
178
+ activeNames.push(name);
179
+ doUpdateExpandedNames(activeNames);
180
+ doItemHeaderClick({ name, expanded: true, event });
181
+ }
182
+ }
183
+ }
184
+ }
185
+ provide(collapseInjectionKey, {
186
+ props,
187
+ mergedClsPrefixRef,
188
+ expandedNamesRef: mergedExpandedNamesRef,
189
+ slots,
190
+ toggleItem
191
+ });
192
+ const rtlEnabledRef = useRtl("Collapse", mergedRtlRef, mergedClsPrefixRef);
193
+ const cssVarsRef = computed(() => {
194
+ const { common: { cubicBezierEaseInOut }, self: { titleFontWeight, dividerColor, titlePadding, titleTextColor, titleTextColorDisabled, textColor, arrowColor, fontSize, titleFontSize, arrowColorDisabled, itemMargin } } = themeRef.value;
195
+ return {
196
+ "--n-font-size": fontSize,
197
+ "--n-bezier": cubicBezierEaseInOut,
198
+ "--n-text-color": textColor,
199
+ "--n-divider-color": dividerColor,
200
+ "--n-title-padding": titlePadding,
201
+ "--n-title-font-size": titleFontSize,
202
+ "--n-title-text-color": titleTextColor,
203
+ "--n-title-text-color-disabled": titleTextColorDisabled,
204
+ "--n-title-font-weight": titleFontWeight,
205
+ "--n-arrow-color": arrowColor,
206
+ "--n-arrow-color-disabled": arrowColorDisabled,
207
+ "--n-item-margin": itemMargin
208
+ };
209
+ });
210
+ const themeClassHandle = inlineThemeDisabled ? useThemeClass("collapse", void 0, cssVarsRef, props) : void 0;
211
+ return {
212
+ rtlEnabled: rtlEnabledRef,
213
+ mergedTheme: themeRef,
214
+ mergedClsPrefix: mergedClsPrefixRef,
215
+ cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
216
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
217
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
218
+ };
219
+ },
220
+ render() {
221
+ var _a;
222
+ (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
223
+ return h("div", { class: [
224
+ `${this.mergedClsPrefix}-collapse`,
225
+ this.rtlEnabled && `${this.mergedClsPrefix}-collapse--rtl`,
226
+ this.themeClass
227
+ ], style: this.cssVars }, this.$slots);
228
+ }
229
+ });
230
+ const NCollapseItemContent = defineComponent({
231
+ name: "CollapseItemContent",
232
+ props: {
233
+ displayDirective: {
234
+ type: String,
235
+ required: true
236
+ },
237
+ show: Boolean,
238
+ clsPrefix: {
239
+ type: String,
240
+ required: true
241
+ }
242
+ },
243
+ setup(props) {
244
+ const onceTrueRef = useFalseUntilTruthy(toRef(props, "show"));
245
+ return {
246
+ onceTrue: onceTrueRef
247
+ };
248
+ },
249
+ render() {
250
+ return h(NFadeInExpandTransition, null, {
251
+ default: () => {
252
+ const { show, displayDirective, onceTrue, clsPrefix } = this;
253
+ const useVShow = displayDirective === "show" && onceTrue;
254
+ const contentNode = h(
255
+ "div",
256
+ { class: `${clsPrefix}-collapse-item__content-wrapper` },
257
+ h("div", { class: `${clsPrefix}-collapse-item__content-inner` }, this.$slots)
258
+ );
259
+ return useVShow ? withDirectives(contentNode, [[vShow, show]]) : show ? contentNode : null;
260
+ }
261
+ });
262
+ }
263
+ });
264
+ const collapseItemProps = {
265
+ title: String,
266
+ name: [String, Number],
267
+ disabled: Boolean,
268
+ displayDirective: String
269
+ };
270
+ const NCollapseItem = defineComponent({
271
+ name: "CollapseItem",
272
+ props: collapseItemProps,
273
+ setup(props) {
274
+ const { mergedRtlRef } = useConfig(props);
275
+ const randomName = createId();
276
+ const mergedNameRef = useMemo(() => {
277
+ var _a;
278
+ return (_a = props.name) !== null && _a !== void 0 ? _a : randomName;
279
+ });
280
+ const NCollapse2 = inject(collapseInjectionKey);
281
+ if (!NCollapse2) {
282
+ throwError("collapse-item", "`n-collapse-item` must be placed inside `n-collapse`.");
283
+ }
284
+ const { expandedNamesRef, props: collapseProps2, mergedClsPrefixRef, slots: collapseSlots } = NCollapse2;
285
+ const collapsedRef = computed(() => {
286
+ const { value: expandedNames } = expandedNamesRef;
287
+ if (Array.isArray(expandedNames)) {
288
+ const { value: name } = mergedNameRef;
289
+ return !~expandedNames.findIndex((expandedName) => expandedName === name);
290
+ } else if (expandedNames) {
291
+ const { value: name } = mergedNameRef;
292
+ return name !== expandedNames;
293
+ }
294
+ return true;
295
+ });
296
+ const rtlEnabledRef = useRtl("Collapse", mergedRtlRef, mergedClsPrefixRef);
297
+ return {
298
+ rtlEnabled: rtlEnabledRef,
299
+ collapseSlots,
300
+ randomName,
301
+ mergedClsPrefix: mergedClsPrefixRef,
302
+ collapsed: collapsedRef,
303
+ mergedDisplayDirective: computed(() => {
304
+ const { displayDirective } = props;
305
+ if (displayDirective) {
306
+ return displayDirective;
307
+ } else {
308
+ return collapseProps2.displayDirective;
309
+ }
310
+ }),
311
+ arrowPlacement: computed(() => {
312
+ return collapseProps2.arrowPlacement;
313
+ }),
314
+ handleClick(e) {
315
+ if (NCollapse2 && !props.disabled) {
316
+ NCollapse2.toggleItem(collapsedRef.value, mergedNameRef.value, e);
317
+ }
318
+ }
319
+ };
320
+ },
321
+ render() {
322
+ const { collapseSlots, $slots, arrowPlacement, collapsed, mergedDisplayDirective, mergedClsPrefix, disabled } = this;
323
+ const headerNode = resolveSlotWithProps($slots.header, { collapsed }, () => [this.title]);
324
+ const headerExtraSlot = $slots["header-extra"] || collapseSlots["header-extra"];
325
+ const arrowSlot = $slots.arrow || collapseSlots.arrow;
326
+ return h(
327
+ "div",
328
+ { class: [
329
+ `${mergedClsPrefix}-collapse-item`,
330
+ `${mergedClsPrefix}-collapse-item--${arrowPlacement}-arrow-placement`,
331
+ disabled && `${mergedClsPrefix}-collapse-item--disabled`,
332
+ !collapsed && `${mergedClsPrefix}-collapse-item--active`
333
+ ] },
334
+ h(
335
+ "div",
336
+ { class: [
337
+ `${mergedClsPrefix}-collapse-item__header`,
338
+ !collapsed && `${mergedClsPrefix}-collapse-item__header--active`
339
+ ] },
340
+ h(
341
+ "div",
342
+ { class: `${mergedClsPrefix}-collapse-item__header-main`, onClick: this.handleClick },
343
+ arrowPlacement === "right" && headerNode,
344
+ h("div", { class: `${mergedClsPrefix}-collapse-item-arrow`, key: this.rtlEnabled ? 0 : 1 }, resolveSlotWithProps(arrowSlot, { collapsed }, () => {
345
+ var _a;
346
+ return [
347
+ h(NBaseIcon, { clsPrefix: mergedClsPrefix }, {
348
+ default: (_a = collapseSlots.expandIcon) !== null && _a !== void 0 ? _a : () => this.rtlEnabled ? h(ChevronLeftIcon, null) : h(ChevronRightIcon, null)
349
+ })
350
+ ];
351
+ })),
352
+ arrowPlacement === "left" && headerNode
353
+ ),
354
+ resolveWrappedSlotWithProps(headerExtraSlot, { collapsed }, (children) => h("div", { class: `${mergedClsPrefix}-collapse-item__header-extra`, onClick: this.handleClick }, children))
355
+ ),
356
+ h(NCollapseItemContent, { clsPrefix: mergedClsPrefix, displayDirective: mergedDisplayDirective, show: !collapsed }, $slots)
357
+ );
358
+ }
359
+ });
360
+ const sizeVariables = {
361
+ thPaddingSmall: "6px",
362
+ thPaddingMedium: "12px",
363
+ thPaddingLarge: "12px",
364
+ tdPaddingSmall: "6px",
365
+ tdPaddingMedium: "12px",
366
+ tdPaddingLarge: "12px"
367
+ };
368
+ const self$1 = (vars) => {
369
+ const { dividerColor, cardColor, modalColor, popoverColor, tableHeaderColor, tableColorStriped, textColor1, textColor2, borderRadius, fontWeightStrong, lineHeight, fontSizeSmall, fontSizeMedium, fontSizeLarge } = vars;
370
+ return Object.assign(Object.assign({}, sizeVariables), {
371
+ fontSizeSmall,
372
+ fontSizeMedium,
373
+ fontSizeLarge,
374
+ lineHeight,
375
+ borderRadius,
376
+ borderColor: composite(cardColor, dividerColor),
377
+ borderColorModal: composite(modalColor, dividerColor),
378
+ borderColorPopover: composite(popoverColor, dividerColor),
379
+ tdColor: cardColor,
380
+ tdColorModal: modalColor,
381
+ tdColorPopover: popoverColor,
382
+ tdColorStriped: composite(cardColor, tableColorStriped),
383
+ tdColorStripedModal: composite(modalColor, tableColorStriped),
384
+ tdColorStripedPopover: composite(popoverColor, tableColorStriped),
385
+ thColor: composite(cardColor, tableHeaderColor),
386
+ thColorModal: composite(modalColor, tableHeaderColor),
387
+ thColorPopover: composite(popoverColor, tableHeaderColor),
388
+ thTextColor: textColor1,
389
+ tdTextColor: textColor2,
390
+ thFontWeight: fontWeightStrong
391
+ });
392
+ };
393
+ const tableLight = {
394
+ name: "Table",
395
+ common: commonLight,
396
+ self: self$1
397
+ };
398
+ const tableLight$1 = tableLight;
399
+ const self = (vars) => {
400
+ const { borderRadiusSmall, hoverColor, pressedColor, primaryColor, textColor3, textColor2, textColorDisabled, fontSize } = vars;
401
+ return {
402
+ fontSize,
403
+ lineHeight: "1.5",
404
+ nodeHeight: "30px",
405
+ nodeWrapperPadding: "3px 0",
406
+ nodeBorderRadius: borderRadiusSmall,
407
+ nodeColorHover: hoverColor,
408
+ nodeColorPressed: pressedColor,
409
+ nodeColorActive: changeColor(primaryColor, { alpha: 0.1 }),
410
+ arrowColor: textColor3,
411
+ nodeTextColor: textColor2,
412
+ nodeTextColorDisabled: textColorDisabled,
413
+ loadingColor: primaryColor,
414
+ dropMarkColor: primaryColor
415
+ };
416
+ };
417
+ const treeLight = createTheme({
418
+ name: "Tree",
419
+ common: commonLight,
420
+ peers: {
421
+ Checkbox: checkboxLight,
422
+ Scrollbar: scrollbarLight,
423
+ Empty: emptyLight
424
+ },
425
+ self
426
+ });
427
+ const treeLight$1 = treeLight;
428
+ const style$1 = c([cB("table", `
429
+ font-size: var(--n-font-size);
430
+ font-variant-numeric: tabular-nums;
431
+ line-height: var(--n-line-height);
432
+ width: 100%;
433
+ border-radius: var(--n-border-radius) var(--n-border-radius) 0 0;
434
+ text-align: left;
435
+ border-collapse: separate;
436
+ border-spacing: 0;
437
+ overflow: hidden;
438
+ background-color: var(--n-td-color);
439
+ border-color: var(--n-merged-border-color);
440
+ transition:
441
+ background-color .3s var(--n-bezier),
442
+ border-color .3s var(--n-bezier),
443
+ color .3s var(--n-bezier);
444
+ --n-merged-border-color: var(--n-border-color);
445
+ `, [c("th", `
446
+ white-space: nowrap;
447
+ transition:
448
+ background-color .3s var(--n-bezier),
449
+ border-color .3s var(--n-bezier),
450
+ color .3s var(--n-bezier);
451
+ text-align: inherit;
452
+ padding: var(--n-th-padding);
453
+ vertical-align: inherit;
454
+ text-transform: none;
455
+ border: 0px solid var(--n-merged-border-color);
456
+ font-weight: var(--n-th-font-weight);
457
+ color: var(--n-th-text-color);
458
+ background-color: var(--n-th-color);
459
+ border-bottom: 1px solid var(--n-merged-border-color);
460
+ border-right: 1px solid var(--n-merged-border-color);
461
+ `, [c("&:last-child", `
462
+ border-right: 0px solid var(--n-merged-border-color);
463
+ `)]), c("td", `
464
+ transition:
465
+ background-color .3s var(--n-bezier),
466
+ border-color .3s var(--n-bezier),
467
+ color .3s var(--n-bezier);
468
+ padding: var(--n-td-padding);
469
+ color: var(--n-td-text-color);
470
+ background-color: var(--n-td-color);
471
+ border: 0px solid var(--n-merged-border-color);
472
+ border-right: 1px solid var(--n-merged-border-color);
473
+ border-bottom: 1px solid var(--n-merged-border-color);
474
+ `, [c("&:last-child", `
475
+ border-right: 0px solid var(--n-merged-border-color);
476
+ `)]), cM("bordered", `
477
+ border: 1px solid var(--n-merged-border-color);
478
+ border-radius: var(--n-border-radius);
479
+ `, [c("tr", [c("&:last-child", [c("td", `
480
+ border-bottom: 0 solid var(--n-merged-border-color);
481
+ `)])])]), cM("single-line", [c("th", `
482
+ border-right: 0px solid var(--n-merged-border-color);
483
+ `), c("td", `
484
+ border-right: 0px solid var(--n-merged-border-color);
485
+ `)]), cM("single-column", [c("tr", [c("&:not(:last-child)", [c("td", `
486
+ border-bottom: 0px solid var(--n-merged-border-color);
487
+ `)])])]), cM("striped", [c("tr:nth-of-type(even)", [c("td", "background-color: var(--n-td-color-striped)")])]), cNotM("bottom-bordered", [c("tr", [c("&:last-child", [c("td", `
488
+ border-bottom: 0px solid var(--n-merged-border-color);
489
+ `)])])])]), insideModal(cB("table", `
490
+ background-color: var(--n-td-color-modal);
491
+ --n-merged-border-color: var(--n-border-color-modal);
492
+ `, [c("th", `
493
+ background-color: var(--n-th-color-modal);
494
+ `), c("td", `
495
+ background-color: var(--n-td-color-modal);
496
+ `)])), insidePopover(cB("table", `
497
+ background-color: var(--n-td-color-popover);
498
+ --n-merged-border-color: var(--n-border-color-popover);
499
+ `, [c("th", `
500
+ background-color: var(--n-th-color-popover);
501
+ `), c("td", `
502
+ background-color: var(--n-td-color-popover);
503
+ `)]))]);
504
+ const tableProps = Object.assign(Object.assign({}, useTheme.props), { bordered: {
505
+ type: Boolean,
506
+ default: true
507
+ }, bottomBordered: {
508
+ type: Boolean,
509
+ default: true
510
+ }, singleLine: {
511
+ type: Boolean,
512
+ default: true
513
+ }, striped: Boolean, singleColumn: Boolean, size: {
514
+ type: String,
515
+ default: "medium"
516
+ } });
517
+ const NTable = defineComponent({
518
+ name: "Table",
519
+ props: tableProps,
520
+ setup(props) {
521
+ const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props);
522
+ const themeRef = useTheme("Table", "-table", style$1, tableLight$1, props, mergedClsPrefixRef);
523
+ const rtlEnabledRef = useRtl("Table", mergedRtlRef, mergedClsPrefixRef);
524
+ const cssVarsRef = computed(() => {
525
+ const { size } = props;
526
+ const { self: { borderColor, tdColor, tdColorModal, tdColorPopover, thColor, thColorModal, thColorPopover, thTextColor, tdTextColor, borderRadius, thFontWeight, lineHeight, borderColorModal, borderColorPopover, tdColorStriped, tdColorStripedModal, tdColorStripedPopover, [createKey("fontSize", size)]: fontSize, [createKey("tdPadding", size)]: tdPadding, [createKey("thPadding", size)]: thPadding }, common: { cubicBezierEaseInOut } } = themeRef.value;
527
+ return {
528
+ "--n-bezier": cubicBezierEaseInOut,
529
+ "--n-td-color": tdColor,
530
+ "--n-td-color-modal": tdColorModal,
531
+ "--n-td-color-popover": tdColorPopover,
532
+ "--n-td-text-color": tdTextColor,
533
+ "--n-border-color": borderColor,
534
+ "--n-border-color-modal": borderColorModal,
535
+ "--n-border-color-popover": borderColorPopover,
536
+ "--n-border-radius": borderRadius,
537
+ "--n-font-size": fontSize,
538
+ "--n-th-color": thColor,
539
+ "--n-th-color-modal": thColorModal,
540
+ "--n-th-color-popover": thColorPopover,
541
+ "--n-th-font-weight": thFontWeight,
542
+ "--n-th-text-color": thTextColor,
543
+ "--n-line-height": lineHeight,
544
+ "--n-td-padding": tdPadding,
545
+ "--n-th-padding": thPadding,
546
+ "--n-td-color-striped": tdColorStriped,
547
+ "--n-td-color-striped-modal": tdColorStripedModal,
548
+ "--n-td-color-striped-popover": tdColorStripedPopover
549
+ };
550
+ });
551
+ const themeClassHandle = inlineThemeDisabled ? useThemeClass("table", computed(() => {
552
+ return props.size[0];
553
+ }), cssVarsRef, props) : void 0;
554
+ return {
555
+ rtlEnabled: rtlEnabledRef,
556
+ mergedClsPrefix: mergedClsPrefixRef,
557
+ cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
558
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
559
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
560
+ };
561
+ },
562
+ render() {
563
+ var _a;
564
+ const { mergedClsPrefix } = this;
565
+ (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
566
+ return h("table", { class: [
567
+ `${mergedClsPrefix}-table`,
568
+ this.themeClass,
569
+ {
570
+ [`${mergedClsPrefix}-table--rtl`]: this.rtlEnabled,
571
+ [`${mergedClsPrefix}-table--bottom-bordered`]: this.bottomBordered,
572
+ [`${mergedClsPrefix}-table--bordered`]: this.bordered,
573
+ [`${mergedClsPrefix}-table--single-line`]: this.singleLine,
574
+ [`${mergedClsPrefix}-table--single-column`]: this.singleColumn,
575
+ [`${mergedClsPrefix}-table--striped`]: this.striped
576
+ }
577
+ ], style: this.cssVars }, this.$slots);
578
+ }
579
+ });
580
+ const NTh = defineComponent({
581
+ name: "Th",
582
+ render() {
583
+ return h("th", null, this.$slots);
584
+ }
585
+ });
586
+ const NTr = defineComponent({
587
+ name: "Tr",
588
+ render() {
589
+ return h("tr", null, this.$slots);
590
+ }
591
+ });
592
+ const NTd = defineComponent({
593
+ name: "Td",
594
+ render() {
595
+ return h("td", null, this.$slots);
596
+ }
597
+ });
598
+ const NThead = defineComponent({
599
+ name: "Thead",
600
+ render() {
601
+ return h("thead", null, this.$slots);
602
+ }
603
+ });
604
+ const NTbody = defineComponent({
605
+ name: "Tbody",
606
+ render() {
607
+ return h("tbody", null, this.$slots);
608
+ }
609
+ });
610
+ const treeSelectInjectionKey = createInjectionKey("n-tree-select");
611
+ const treeInjectionKey = createInjectionKey("n-tree");
612
+ const NTreeNodeSwitcher = defineComponent({
613
+ name: "NTreeSwitcher",
614
+ props: {
615
+ clsPrefix: {
616
+ type: String,
617
+ required: true
618
+ },
619
+ indent: { type: Number, required: true },
620
+ expanded: Boolean,
621
+ selected: Boolean,
622
+ hide: Boolean,
623
+ loading: Boolean,
624
+ onClick: Function,
625
+ tmNode: {
626
+ type: Object,
627
+ required: true
628
+ }
629
+ },
630
+ setup(props) {
631
+ const { renderSwitcherIconRef } = inject(treeInjectionKey, null);
632
+ return () => {
633
+ const { clsPrefix, expanded, hide, indent, onClick } = props;
634
+ return h(
635
+ "span",
636
+ { "data-switcher": true, class: [
637
+ `${clsPrefix}-tree-node-switcher`,
638
+ expanded && `${clsPrefix}-tree-node-switcher--expanded`,
639
+ hide && `${clsPrefix}-tree-node-switcher--hide`
640
+ ], style: { width: `${indent}px` }, onClick },
641
+ h(
642
+ "div",
643
+ { class: `${clsPrefix}-tree-node-switcher__icon` },
644
+ h(NIconSwitchTransition, null, {
645
+ default: () => {
646
+ if (props.loading) {
647
+ return h(NBaseLoading, { clsPrefix, key: "loading", radius: 85, strokeWidth: 20 });
648
+ }
649
+ const { value: renderSwitcherIcon } = renderSwitcherIconRef;
650
+ return renderSwitcherIcon ? renderSwitcherIcon({
651
+ expanded: props.expanded,
652
+ selected: props.selected,
653
+ option: props.tmNode.rawNode
654
+ }) : h(NBaseIcon, { clsPrefix, key: "switcher" }, { default: () => h(SwitcherIcon, null) });
655
+ }
656
+ })
657
+ )
658
+ );
659
+ };
660
+ }
661
+ });
662
+ const NTreeNodeCheckbox = defineComponent({
663
+ name: "NTreeNodeCheckbox",
664
+ props: {
665
+ clsPrefix: {
666
+ type: String,
667
+ required: true
668
+ },
669
+ indent: {
670
+ type: Number,
671
+ required: true
672
+ },
673
+ right: Boolean,
674
+ focusable: Boolean,
675
+ disabled: Boolean,
676
+ checked: Boolean,
677
+ indeterminate: Boolean,
678
+ onCheck: Function
679
+ },
680
+ setup(props) {
681
+ const NTree2 = inject(treeInjectionKey);
682
+ function doCheck(value) {
683
+ const { onCheck } = props;
684
+ if (onCheck) {
685
+ onCheck(value);
686
+ }
687
+ }
688
+ function handleUpdateValue(value) {
689
+ doCheck(value);
690
+ }
691
+ return {
692
+ handleUpdateValue,
693
+ mergedTheme: NTree2.mergedThemeRef
694
+ };
695
+ },
696
+ render() {
697
+ const { clsPrefix, mergedTheme, checked, indeterminate, disabled, focusable, indent, handleUpdateValue } = this;
698
+ return h(
699
+ "span",
700
+ { class: [
701
+ `${clsPrefix}-tree-node-checkbox`,
702
+ this.right && `${clsPrefix}-tree-node-checkbox--right`
703
+ ], style: {
704
+ width: `${indent}px`
705
+ }, "data-checkbox": true },
706
+ h(NCheckbox, { focusable, disabled, theme: mergedTheme.peers.Checkbox, themeOverrides: mergedTheme.peerOverrides.Checkbox, checked, indeterminate, onUpdateChecked: handleUpdateValue })
707
+ );
708
+ }
709
+ });
710
+ const NTreeNodeContent = defineComponent({
711
+ name: "TreeNodeContent",
712
+ props: {
713
+ clsPrefix: {
714
+ type: String,
715
+ required: true
716
+ },
717
+ disabled: Boolean,
718
+ checked: Boolean,
719
+ selected: Boolean,
720
+ onClick: Function,
721
+ onDragstart: Function,
722
+ tmNode: {
723
+ type: Object,
724
+ required: true
725
+ },
726
+ nodeProps: Object
727
+ },
728
+ setup(props) {
729
+ const { renderLabelRef, renderPrefixRef, renderSuffixRef, labelFieldRef } = (
730
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
731
+ inject(treeInjectionKey)
732
+ );
733
+ const selfRef = ref(null);
734
+ function doClick(e) {
735
+ const { onClick } = props;
736
+ if (onClick)
737
+ onClick(e);
738
+ }
739
+ function handleClick(e) {
740
+ doClick(e);
741
+ }
742
+ return {
743
+ selfRef,
744
+ renderLabel: renderLabelRef,
745
+ renderPrefix: renderPrefixRef,
746
+ renderSuffix: renderSuffixRef,
747
+ labelField: labelFieldRef,
748
+ handleClick
749
+ };
750
+ },
751
+ render() {
752
+ const { clsPrefix, labelField, nodeProps, checked = false, selected = false, renderLabel, renderPrefix, renderSuffix, handleClick, onDragstart, tmNode: { rawNode, rawNode: { prefix, suffix, [labelField]: label } } } = this;
753
+ return h(
754
+ "span",
755
+ Object.assign({}, nodeProps, { ref: "selfRef", class: [`${clsPrefix}-tree-node-content`, nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps.class], onClick: handleClick, draggable: onDragstart === void 0 ? void 0 : true, onDragstart }),
756
+ renderPrefix || prefix ? h("div", { class: `${clsPrefix}-tree-node-content__prefix` }, renderPrefix ? renderPrefix({
757
+ option: rawNode,
758
+ selected,
759
+ checked
760
+ }) : render(prefix)) : null,
761
+ h("div", { class: `${clsPrefix}-tree-node-content__text` }, renderLabel ? renderLabel({
762
+ option: rawNode,
763
+ selected,
764
+ checked
765
+ }) : render(label)),
766
+ renderSuffix || suffix ? h("div", { class: `${clsPrefix}-tree-node-content__suffix` }, renderSuffix ? renderSuffix({
767
+ option: rawNode,
768
+ selected,
769
+ checked
770
+ }) : render(suffix)) : null
771
+ );
772
+ }
773
+ });
774
+ function renderDropMark({ position, offsetLevel, indent, el }) {
775
+ const style2 = {
776
+ position: "absolute",
777
+ boxSizing: "border-box",
778
+ right: 0
779
+ };
780
+ if (position === "inside") {
781
+ style2.left = 0;
782
+ style2.top = 0;
783
+ style2.bottom = 0;
784
+ style2.borderRadius = "inherit";
785
+ style2.boxShadow = "inset 0 0 0 2px var(--n-drop-mark-color)";
786
+ } else {
787
+ const cssPosition = position === "before" ? "top" : "bottom";
788
+ style2[cssPosition] = 0;
789
+ style2.left = `${el.offsetLeft + 6 - offsetLevel * indent}px`;
790
+ style2.height = "2px";
791
+ style2.backgroundColor = "var(--n-drop-mark-color)";
792
+ style2.transformOrigin = cssPosition;
793
+ style2.borderRadius = "1px";
794
+ style2.transform = position === "before" ? "translateY(-4px)" : "translateY(4px)";
795
+ }
796
+ return h("div", { style: style2 });
797
+ }
798
+ function defaultAllowDrop({ dropPosition, node }) {
799
+ if (node.isLeaf === false)
800
+ return true;
801
+ if (node.children) {
802
+ return true;
803
+ }
804
+ return dropPosition !== "inside";
805
+ }
806
+ function useMergedCheckStrategy(props) {
807
+ return computed(() => props.leafOnly ? "child" : props.checkStrategy);
808
+ }
809
+ function isNodeDisabled(node, disabledField) {
810
+ return !!node.rawNode[disabledField];
811
+ }
812
+ function traverse(nodes, childrenField, callback, callbackAfter) {
813
+ nodes === null || nodes === void 0 ? void 0 : nodes.forEach((node) => {
814
+ callback(node);
815
+ traverse(node[childrenField], childrenField, callback, callbackAfter);
816
+ callbackAfter(node);
817
+ });
818
+ }
819
+ function keysWithFilter(nodes, pattern, keyField, childrenField, filter) {
820
+ const keys = /* @__PURE__ */ new Set();
821
+ const highlightKeySet = /* @__PURE__ */ new Set();
822
+ const path = [];
823
+ traverse(nodes, childrenField, (node) => {
824
+ path.push(node);
825
+ if (filter(pattern, node)) {
826
+ highlightKeySet.add(node[keyField]);
827
+ for (let i = path.length - 2; i >= 0; --i) {
828
+ if (!keys.has(path[i][keyField])) {
829
+ keys.add(path[i][keyField]);
830
+ } else {
831
+ return;
832
+ }
833
+ }
834
+ }
835
+ }, () => {
836
+ path.pop();
837
+ });
838
+ return {
839
+ expandedKeys: Array.from(keys),
840
+ highlightKeySet
841
+ };
842
+ }
843
+ if (isBrowser && Image) {
844
+ const emptyImage = new Image();
845
+ emptyImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
846
+ }
847
+ function filterTree(tree, filter, pattern, keyField, childrenField) {
848
+ const visitedTailKeys = /* @__PURE__ */ new Set();
849
+ const visitedNonTailKeys = /* @__PURE__ */ new Set();
850
+ const highlightKeySet = /* @__PURE__ */ new Set();
851
+ const expandedKeys = [];
852
+ const filteredTree = [];
853
+ const path = [];
854
+ function visit(t) {
855
+ t.forEach((n) => {
856
+ path.push(n);
857
+ if (filter(pattern, n)) {
858
+ visitedTailKeys.add(n[keyField]);
859
+ highlightKeySet.add(n[keyField]);
860
+ for (let i = path.length - 2; i >= 0; --i) {
861
+ const key = path[i][keyField];
862
+ if (!visitedNonTailKeys.has(key)) {
863
+ visitedNonTailKeys.add(key);
864
+ if (visitedTailKeys.has(key)) {
865
+ visitedTailKeys.delete(key);
866
+ }
867
+ } else {
868
+ break;
869
+ }
870
+ }
871
+ }
872
+ const children = n[childrenField];
873
+ if (children) {
874
+ visit(children);
875
+ }
876
+ path.pop();
877
+ });
878
+ }
879
+ visit(tree);
880
+ function build(t, sibs) {
881
+ t.forEach((n) => {
882
+ const key = n[keyField];
883
+ const isVisitedTail = visitedTailKeys.has(key);
884
+ const isVisitedNonTail = visitedNonTailKeys.has(key);
885
+ if (!isVisitedTail && !isVisitedNonTail)
886
+ return;
887
+ const children = n[childrenField];
888
+ if (children) {
889
+ if (isVisitedTail) {
890
+ sibs.push(n);
891
+ } else {
892
+ expandedKeys.push(key);
893
+ const clonedNode = Object.assign(Object.assign({}, n), { [childrenField]: [] });
894
+ sibs.push(clonedNode);
895
+ build(children, clonedNode[childrenField]);
896
+ }
897
+ } else {
898
+ sibs.push(n);
899
+ }
900
+ });
901
+ }
902
+ build(tree, filteredTree);
903
+ return {
904
+ filteredTree,
905
+ highlightKeySet,
906
+ expandedKeys
907
+ };
908
+ }
909
+ const TreeNode = defineComponent({
910
+ name: "TreeNode",
911
+ props: {
912
+ clsPrefix: {
913
+ type: String,
914
+ required: true
915
+ },
916
+ tmNode: {
917
+ type: Object,
918
+ required: true
919
+ }
920
+ },
921
+ setup(props) {
922
+ const NTree2 = inject(treeInjectionKey);
923
+ const { droppingNodeParentRef, droppingMouseNodeRef, draggingNodeRef, droppingPositionRef, droppingOffsetLevelRef, nodePropsRef, indentRef, blockLineRef, checkboxPlacementRef, checkOnClickRef, disabledFieldRef, showLineRef } = NTree2;
924
+ const checkboxDisabledRef = useMemo(() => !!props.tmNode.rawNode.checkboxDisabled);
925
+ const nodeIsDisabledRef = useMemo(() => {
926
+ return isNodeDisabled(props.tmNode, disabledFieldRef.value);
927
+ });
928
+ const disabledRef = useMemo(() => NTree2.disabledRef.value || nodeIsDisabledRef.value);
929
+ const resolvedNodePropsRef = computed(() => {
930
+ const { value: nodeProps } = nodePropsRef;
931
+ if (!nodeProps)
932
+ return void 0;
933
+ return nodeProps({ option: props.tmNode.rawNode });
934
+ });
935
+ const contentInstRef = ref(null);
936
+ const contentElRef = { value: null };
937
+ onMounted(() => {
938
+ contentElRef.value = contentInstRef.value.$el;
939
+ });
940
+ function handleSwitcherClick() {
941
+ const { tmNode } = props;
942
+ if (!tmNode.isLeaf && !tmNode.shallowLoaded) {
943
+ if (!NTree2.loadingKeysRef.value.has(tmNode.key)) {
944
+ NTree2.loadingKeysRef.value.add(tmNode.key);
945
+ } else {
946
+ return;
947
+ }
948
+ const { onLoadRef: { value: onLoad } } = NTree2;
949
+ if (onLoad) {
950
+ void onLoad(tmNode.rawNode).then((value) => {
951
+ if (value !== false) {
952
+ NTree2.handleSwitcherClick(tmNode);
953
+ }
954
+ }).finally(() => {
955
+ NTree2.loadingKeysRef.value.delete(tmNode.key);
956
+ });
957
+ }
958
+ } else {
959
+ NTree2.handleSwitcherClick(tmNode);
960
+ }
961
+ }
962
+ const selectableRef = useMemo(() => !nodeIsDisabledRef.value && NTree2.selectableRef.value && (NTree2.internalTreeSelect ? NTree2.mergedCheckStrategyRef.value !== "child" || NTree2.multipleRef.value && NTree2.cascadeRef.value || props.tmNode.isLeaf : true));
963
+ const checkableRef = useMemo(() => NTree2.checkableRef.value && (NTree2.cascadeRef.value || NTree2.mergedCheckStrategyRef.value !== "child" || props.tmNode.isLeaf));
964
+ const checkedRef = useMemo(() => NTree2.displayedCheckedKeysRef.value.includes(props.tmNode.key));
965
+ const mergedCheckOnClickRef = useMemo(() => {
966
+ const { value: checkable } = checkableRef;
967
+ if (!checkable)
968
+ return false;
969
+ const { value: checkOnClick } = checkOnClickRef;
970
+ const { tmNode } = props;
971
+ if (typeof checkOnClick === "boolean") {
972
+ return !tmNode.disabled && checkOnClick;
973
+ }
974
+ return checkOnClick(props.tmNode.rawNode);
975
+ });
976
+ function _handleClick(e) {
977
+ const { value: expandOnClick } = NTree2.expandOnClickRef;
978
+ const { value: selectable } = selectableRef;
979
+ const { value: mergedCheckOnClick } = mergedCheckOnClickRef;
980
+ if (!selectable && !expandOnClick && !mergedCheckOnClick)
981
+ return;
982
+ if (happensIn(e, "checkbox") || happensIn(e, "switcher"))
983
+ return;
984
+ const { tmNode } = props;
985
+ if (selectable) {
986
+ NTree2.handleSelect(tmNode);
987
+ }
988
+ if (expandOnClick && !tmNode.isLeaf) {
989
+ handleSwitcherClick();
990
+ }
991
+ if (mergedCheckOnClick) {
992
+ handleCheck(!checkedRef.value);
993
+ }
994
+ }
995
+ function handleContentClick(e) {
996
+ var _a, _b;
997
+ if (blockLineRef.value)
998
+ return;
999
+ if (!disabledRef.value)
1000
+ _handleClick(e);
1001
+ (_b = (_a = resolvedNodePropsRef.value) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
1002
+ }
1003
+ function handleLineClick(e) {
1004
+ var _a, _b;
1005
+ if (!blockLineRef.value)
1006
+ return;
1007
+ if (!disabledRef.value) {
1008
+ _handleClick(e);
1009
+ }
1010
+ (_b = (_a = resolvedNodePropsRef.value) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
1011
+ }
1012
+ function handleCheck(checked) {
1013
+ NTree2.handleCheck(props.tmNode, checked);
1014
+ }
1015
+ function handleDragStart(e) {
1016
+ NTree2.handleDragStart({
1017
+ event: e,
1018
+ node: props.tmNode
1019
+ });
1020
+ }
1021
+ function handleDragEnter(e) {
1022
+ if (e.currentTarget !== e.target) {
1023
+ return;
1024
+ }
1025
+ NTree2.handleDragEnter({
1026
+ event: e,
1027
+ node: props.tmNode
1028
+ });
1029
+ }
1030
+ function handleDragOver(e) {
1031
+ e.preventDefault();
1032
+ NTree2.handleDragOver({
1033
+ event: e,
1034
+ node: props.tmNode
1035
+ });
1036
+ }
1037
+ function handleDragEnd(e) {
1038
+ NTree2.handleDragEnd({
1039
+ event: e,
1040
+ node: props.tmNode
1041
+ });
1042
+ }
1043
+ function handleDragLeave(e) {
1044
+ if (e.currentTarget !== e.target) {
1045
+ return;
1046
+ }
1047
+ NTree2.handleDragLeave({
1048
+ event: e,
1049
+ node: props.tmNode
1050
+ });
1051
+ }
1052
+ function handleDrop(e) {
1053
+ e.preventDefault();
1054
+ if (droppingPositionRef.value !== null) {
1055
+ NTree2.handleDrop({
1056
+ event: e,
1057
+ node: props.tmNode,
1058
+ dropPosition: droppingPositionRef.value
1059
+ });
1060
+ }
1061
+ }
1062
+ const indentNodes = computed(() => {
1063
+ const { clsPrefix } = props;
1064
+ const { value: indent } = indentRef;
1065
+ if (showLineRef.value) {
1066
+ const indentNodes2 = [];
1067
+ let cursor = props.tmNode.parent;
1068
+ while (cursor) {
1069
+ if (cursor.isLastChild) {
1070
+ indentNodes2.push(h(
1071
+ "div",
1072
+ { class: `${clsPrefix}-tree-node-indent` },
1073
+ h("div", { style: { width: `${indent}px` } })
1074
+ ));
1075
+ } else {
1076
+ indentNodes2.push(h(
1077
+ "div",
1078
+ { class: [
1079
+ `${clsPrefix}-tree-node-indent`,
1080
+ `${clsPrefix}-tree-node-indent--show-line`
1081
+ ] },
1082
+ h("div", { style: { width: `${indent}px` } })
1083
+ ));
1084
+ }
1085
+ cursor = cursor.parent;
1086
+ }
1087
+ return indentNodes2.reverse();
1088
+ } else {
1089
+ return repeat(props.tmNode.level, h(
1090
+ "div",
1091
+ { class: `${props.clsPrefix}-tree-node-indent` },
1092
+ h("div", { style: { width: `${indent}px` } })
1093
+ ));
1094
+ }
1095
+ });
1096
+ return {
1097
+ showDropMark: useMemo(() => {
1098
+ const { value: draggingNode } = draggingNodeRef;
1099
+ if (!draggingNode)
1100
+ return;
1101
+ const { value: droppingPosition } = droppingPositionRef;
1102
+ if (!droppingPosition)
1103
+ return;
1104
+ const { value: droppingMouseNode } = droppingMouseNodeRef;
1105
+ if (!droppingMouseNode) {
1106
+ return;
1107
+ }
1108
+ const { tmNode } = props;
1109
+ if (tmNode.key === droppingMouseNode.key)
1110
+ return true;
1111
+ return false;
1112
+ }),
1113
+ showDropMarkAsParent: useMemo(() => {
1114
+ const { value: droppingNodeParent } = droppingNodeParentRef;
1115
+ if (!droppingNodeParent)
1116
+ return false;
1117
+ const { tmNode } = props;
1118
+ const { value: droppingPosition } = droppingPositionRef;
1119
+ if (droppingPosition === "before" || droppingPosition === "after") {
1120
+ return droppingNodeParent.key === tmNode.key;
1121
+ }
1122
+ return false;
1123
+ }),
1124
+ pending: useMemo(() => NTree2.pendingNodeKeyRef.value === props.tmNode.key),
1125
+ loading: useMemo(() => NTree2.loadingKeysRef.value.has(props.tmNode.key)),
1126
+ highlight: useMemo(() => {
1127
+ var _a;
1128
+ return (_a = NTree2.highlightKeySetRef.value) === null || _a === void 0 ? void 0 : _a.has(props.tmNode.key);
1129
+ }),
1130
+ checked: checkedRef,
1131
+ indeterminate: useMemo(() => NTree2.displayedIndeterminateKeysRef.value.includes(props.tmNode.key)),
1132
+ selected: useMemo(() => NTree2.mergedSelectedKeysRef.value.includes(props.tmNode.key)),
1133
+ expanded: useMemo(() => NTree2.mergedExpandedKeysRef.value.includes(props.tmNode.key)),
1134
+ disabled: disabledRef,
1135
+ checkable: checkableRef,
1136
+ mergedCheckOnClick: mergedCheckOnClickRef,
1137
+ checkboxDisabled: checkboxDisabledRef,
1138
+ selectable: selectableRef,
1139
+ expandOnClick: NTree2.expandOnClickRef,
1140
+ internalScrollable: NTree2.internalScrollableRef,
1141
+ draggable: NTree2.draggableRef,
1142
+ blockLine: blockLineRef,
1143
+ nodeProps: resolvedNodePropsRef,
1144
+ checkboxFocusable: NTree2.internalCheckboxFocusableRef,
1145
+ droppingPosition: droppingPositionRef,
1146
+ droppingOffsetLevel: droppingOffsetLevelRef,
1147
+ indent: indentRef,
1148
+ checkboxPlacement: checkboxPlacementRef,
1149
+ showLine: showLineRef,
1150
+ contentInstRef,
1151
+ contentElRef,
1152
+ indentNodes,
1153
+ handleCheck,
1154
+ handleDrop,
1155
+ handleDragStart,
1156
+ handleDragEnter,
1157
+ handleDragOver,
1158
+ handleDragEnd,
1159
+ handleDragLeave,
1160
+ handleLineClick,
1161
+ handleContentClick,
1162
+ handleSwitcherClick
1163
+ };
1164
+ },
1165
+ render() {
1166
+ const { tmNode, clsPrefix, checkable, expandOnClick, selectable, selected, checked, highlight, draggable, blockLine, indent, indentNodes, disabled, pending, internalScrollable, nodeProps, checkboxPlacement } = this;
1167
+ const dragEventHandlers = draggable && !disabled ? {
1168
+ onDragenter: this.handleDragEnter,
1169
+ onDragleave: this.handleDragLeave,
1170
+ onDragend: this.handleDragEnd,
1171
+ onDrop: this.handleDrop,
1172
+ onDragover: this.handleDragOver
1173
+ } : void 0;
1174
+ const dataKey = internalScrollable ? createDataKey(tmNode.key) : void 0;
1175
+ const checkboxOnRight = checkboxPlacement === "right";
1176
+ const checkboxNode = checkable ? h(NTreeNodeCheckbox, { indent, right: checkboxOnRight, focusable: this.checkboxFocusable, disabled: disabled || this.checkboxDisabled, clsPrefix, checked: this.checked, indeterminate: this.indeterminate, onCheck: this.handleCheck }) : null;
1177
+ return h(
1178
+ "div",
1179
+ Object.assign({ class: `${clsPrefix}-tree-node-wrapper` }, dragEventHandlers),
1180
+ h(
1181
+ "div",
1182
+ Object.assign({}, blockLine ? nodeProps : void 0, { class: [
1183
+ `${clsPrefix}-tree-node`,
1184
+ {
1185
+ [`${clsPrefix}-tree-node--selected`]: selected,
1186
+ [`${clsPrefix}-tree-node--checkable`]: checkable,
1187
+ [`${clsPrefix}-tree-node--highlight`]: highlight,
1188
+ [`${clsPrefix}-tree-node--pending`]: pending,
1189
+ [`${clsPrefix}-tree-node--disabled`]: disabled,
1190
+ [`${clsPrefix}-tree-node--selectable`]: selectable,
1191
+ [`${clsPrefix}-tree-node--clickable`]: selectable || expandOnClick || this.mergedCheckOnClick
1192
+ },
1193
+ nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps.class
1194
+ ], "data-key": dataKey, draggable: draggable && blockLine, onClick: this.handleLineClick, onDragstart: draggable && blockLine && !disabled ? this.handleDragStart : void 0 }),
1195
+ indentNodes,
1196
+ tmNode.isLeaf && this.showLine ? h(
1197
+ "div",
1198
+ { class: [
1199
+ `${clsPrefix}-tree-node-indent`,
1200
+ `${clsPrefix}-tree-node-indent--show-line`,
1201
+ tmNode.isLeaf && `${clsPrefix}-tree-node-indent--is-leaf`,
1202
+ tmNode.isLastChild && `${clsPrefix}-tree-node-indent--last-child`
1203
+ ] },
1204
+ h("div", { style: { width: `${indent}px` } })
1205
+ ) : h(NTreeNodeSwitcher, { clsPrefix, expanded: this.expanded, selected, loading: this.loading, hide: tmNode.isLeaf, tmNode: this.tmNode, indent, onClick: this.handleSwitcherClick }),
1206
+ !checkboxOnRight ? checkboxNode : null,
1207
+ h(NTreeNodeContent, { ref: "contentInstRef", clsPrefix, checked, selected, onClick: this.handleContentClick, nodeProps: blockLine ? void 0 : nodeProps, onDragstart: draggable && !blockLine && !disabled ? this.handleDragStart : void 0, tmNode }),
1208
+ draggable ? this.showDropMark ? renderDropMark({
1209
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1210
+ el: this.contentElRef.value,
1211
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1212
+ position: this.droppingPosition,
1213
+ offsetLevel: this.droppingOffsetLevel,
1214
+ indent
1215
+ }) : this.showDropMarkAsParent ? renderDropMark({
1216
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1217
+ el: this.contentElRef.value,
1218
+ position: "inside",
1219
+ offsetLevel: this.droppingOffsetLevel,
1220
+ indent
1221
+ }) : null : null,
1222
+ checkboxOnRight ? checkboxNode : null
1223
+ )
1224
+ );
1225
+ }
1226
+ });
1227
+ const NTreeNode = TreeNode;
1228
+ function useKeyboard({ props, fNodesRef, mergedExpandedKeysRef, mergedSelectedKeysRef, handleSelect, handleSwitcherClick }) {
1229
+ const { value: mergedSelectedKeys } = mergedSelectedKeysRef;
1230
+ const treeSelectInjection = inject(treeSelectInjectionKey, null);
1231
+ const pendingNodeKeyRef = treeSelectInjection ? treeSelectInjection.pendingNodeKeyRef : ref(mergedSelectedKeys.length ? mergedSelectedKeys[mergedSelectedKeys.length - 1] : null);
1232
+ function handleKeydown(e) {
1233
+ if (!props.keyboard)
1234
+ return;
1235
+ const { value: pendingNodeKey } = pendingNodeKeyRef;
1236
+ if (pendingNodeKey === null) {
1237
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1238
+ e.preventDefault();
1239
+ }
1240
+ if (["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) {
1241
+ if (pendingNodeKey === null) {
1242
+ const { value: fNodes } = fNodesRef;
1243
+ let fIndex = 0;
1244
+ while (fIndex < fNodes.length) {
1245
+ if (!fNodes[fIndex].disabled) {
1246
+ pendingNodeKeyRef.value = fNodes[fIndex].key;
1247
+ break;
1248
+ }
1249
+ fIndex += 1;
1250
+ }
1251
+ }
1252
+ }
1253
+ } else {
1254
+ const { value: fNodes } = fNodesRef;
1255
+ let fIndex = fNodes.findIndex((tmNode) => tmNode.key === pendingNodeKey);
1256
+ if (!~fIndex)
1257
+ return;
1258
+ if (e.key === "Enter") {
1259
+ handleSelect(fNodes[fIndex]);
1260
+ } else if (e.key === "ArrowDown") {
1261
+ e.preventDefault();
1262
+ fIndex += 1;
1263
+ while (fIndex < fNodes.length) {
1264
+ if (!fNodes[fIndex].disabled) {
1265
+ pendingNodeKeyRef.value = fNodes[fIndex].key;
1266
+ break;
1267
+ }
1268
+ fIndex += 1;
1269
+ }
1270
+ } else if (e.key === "ArrowUp") {
1271
+ e.preventDefault();
1272
+ fIndex -= 1;
1273
+ while (fIndex >= 0) {
1274
+ if (!fNodes[fIndex].disabled) {
1275
+ pendingNodeKeyRef.value = fNodes[fIndex].key;
1276
+ break;
1277
+ }
1278
+ fIndex -= 1;
1279
+ }
1280
+ } else if (e.key === "ArrowLeft") {
1281
+ const pendingNode = fNodes[fIndex];
1282
+ if (pendingNode.isLeaf || !mergedExpandedKeysRef.value.includes(pendingNodeKey)) {
1283
+ const parentTmNode = pendingNode.getParent();
1284
+ if (parentTmNode) {
1285
+ pendingNodeKeyRef.value = parentTmNode.key;
1286
+ }
1287
+ } else {
1288
+ handleSwitcherClick(pendingNode);
1289
+ }
1290
+ } else if (e.key === "ArrowRight") {
1291
+ const pendingNode = fNodes[fIndex];
1292
+ if (pendingNode.isLeaf)
1293
+ return;
1294
+ if (!mergedExpandedKeysRef.value.includes(pendingNodeKey)) {
1295
+ handleSwitcherClick(pendingNode);
1296
+ } else {
1297
+ fIndex += 1;
1298
+ while (fIndex < fNodes.length) {
1299
+ if (!fNodes[fIndex].disabled) {
1300
+ pendingNodeKeyRef.value = fNodes[fIndex].key;
1301
+ break;
1302
+ }
1303
+ fIndex += 1;
1304
+ }
1305
+ }
1306
+ }
1307
+ }
1308
+ }
1309
+ return {
1310
+ pendingNodeKeyRef,
1311
+ handleKeydown
1312
+ };
1313
+ }
1314
+ const MotionWrapper = defineComponent({
1315
+ name: "TreeMotionWrapper",
1316
+ props: {
1317
+ clsPrefix: {
1318
+ type: String,
1319
+ required: true
1320
+ },
1321
+ height: Number,
1322
+ nodes: {
1323
+ type: Array,
1324
+ required: true
1325
+ },
1326
+ mode: {
1327
+ type: String,
1328
+ required: true
1329
+ },
1330
+ onAfterEnter: {
1331
+ type: Function,
1332
+ required: true
1333
+ }
1334
+ },
1335
+ render() {
1336
+ const { clsPrefix } = this;
1337
+ return h(NFadeInExpandTransition, { onAfterEnter: this.onAfterEnter, appear: true, reverse: this.mode === "collapse" }, {
1338
+ default: () => h("div", { class: [
1339
+ `${clsPrefix}-tree-motion-wrapper`,
1340
+ `${clsPrefix}-tree-motion-wrapper--${this.mode}`
1341
+ ], style: {
1342
+ height: pxfy(this.height)
1343
+ } }, this.nodes.map((node) => h(NTreeNode, { clsPrefix, tmNode: node })))
1344
+ });
1345
+ }
1346
+ });
1347
+ const iconSwitchTransitionNode = iconSwitchTransition();
1348
+ const style = cB("tree", `
1349
+ font-size: var(--n-font-size);
1350
+ outline: none;
1351
+ `, [c("ul, li", `
1352
+ margin: 0;
1353
+ padding: 0;
1354
+ list-style: none;
1355
+ `), c(">", [cB("tree-node", [c("&:first-child", "margin-top: 0;")])]), cB("tree-motion-wrapper", [cM("expand", [fadeInHeightExpandTransition({
1356
+ duration: "0.2s"
1357
+ })]), cM("collapse", [fadeInHeightExpandTransition({
1358
+ duration: "0.2s",
1359
+ reverse: true
1360
+ })])]), cB("tree-node-wrapper", `
1361
+ box-sizing: border-box;
1362
+ padding: var(--n-node-wrapper-padding);
1363
+ `), cB("tree-node", `
1364
+ transform: translate3d(0,0,0);
1365
+ position: relative;
1366
+ display: flex;
1367
+ border-radius: var(--n-node-border-radius);
1368
+ transition: background-color .3s var(--n-bezier);
1369
+ `, [cM("highlight", [cB("tree-node-content", [cE("text", "border-bottom-color: var(--n-node-text-color-disabled);")])]), cM("disabled", [cB("tree-node-content", `
1370
+ color: var(--n-node-text-color-disabled);
1371
+ cursor: not-allowed;
1372
+ `)]), cNotM("disabled", [cM("clickable", [cB("tree-node-content", `
1373
+ cursor: pointer;
1374
+ `)])])]), cM("block-node", [cB("tree-node-content", `
1375
+ flex: 1;
1376
+ min-width: 0;
1377
+ `)]), cNotM("block-line", [cB("tree-node", [cNotM("disabled", [cB("tree-node-content", [c("&:hover", "background: var(--n-node-color-hover);")]), cM("selectable", [cB("tree-node-content", [c("&:active", "background: var(--n-node-color-pressed);")])]), cM("pending", [cB("tree-node-content", `
1378
+ background: var(--n-node-color-hover);
1379
+ `)]), cM("selected", [cB("tree-node-content", "background: var(--n-node-color-active);")])])])]), cM("block-line", [cB("tree-node", [cNotM("disabled", [c("&:hover", "background: var(--n-node-color-hover);"), cM("pending", `
1380
+ background: var(--n-node-color-hover);
1381
+ `), cM("selectable", [cNotM("selected", [c("&:active", "background: var(--n-node-color-pressed);")])]), cM("selected", "background: var(--n-node-color-active);")]), cM("disabled", `
1382
+ cursor: not-allowed;
1383
+ `)])]), cB("tree-node-indent", `
1384
+ flex-grow: 0;
1385
+ flex-shrink: 0;
1386
+ `, [cM("show-line", "position: relative", [c("&::before", `
1387
+ position: absolute;
1388
+ left: 50%;
1389
+ border-left: 1px solid var(--n-border-color);
1390
+ transition: border-color .3s var(--n-bezier);
1391
+ transform: translate(-50%);
1392
+ content: "";
1393
+ top: var(--n-line-offset-top);
1394
+ bottom: var(--n-line-offset-bottom);
1395
+ `), cM("last-child", [c("&::before", `
1396
+ bottom: 50%;
1397
+ `)]), cM("is-leaf", [c("&::after", `
1398
+ position: absolute;
1399
+ content: "";
1400
+ left: calc(50% + 0.5px);
1401
+ right: 0;
1402
+ bottom: 50%;
1403
+ transition: border-color .3s var(--n-bezier);
1404
+ border-bottom: 1px solid var(--n-border-color);
1405
+ `)])]), cNotM("show-line", "height: 0;")]), cB("tree-node-switcher", `
1406
+ cursor: pointer;
1407
+ display: inline-flex;
1408
+ flex-shrink: 0;
1409
+ height: var(--n-node-content-height);
1410
+ align-items: center;
1411
+ justify-content: center;
1412
+ transition: transform .15s var(--n-bezier);
1413
+ vertical-align: bottom;
1414
+ `, [cE("icon", `
1415
+ position: relative;
1416
+ height: 14px;
1417
+ width: 14px;
1418
+ display: flex;
1419
+ color: var(--n-arrow-color);
1420
+ transition: color .3s var(--n-bezier);
1421
+ font-size: 14px;
1422
+ `, [cB("icon", [iconSwitchTransitionNode]), cB("base-loading", `
1423
+ color: var(--n-loading-color);
1424
+ position: absolute;
1425
+ left: 0;
1426
+ top: 0;
1427
+ right: 0;
1428
+ bottom: 0;
1429
+ `, [iconSwitchTransitionNode]), cB("base-icon", [iconSwitchTransitionNode])]), cM("hide", "visibility: hidden;"), cM("expanded", "transform: rotate(90deg);")]), cB("tree-node-checkbox", `
1430
+ display: inline-flex;
1431
+ height: var(--n-node-content-height);
1432
+ vertical-align: bottom;
1433
+ align-items: center;
1434
+ justify-content: center;
1435
+ `), cB("tree-node-content", `
1436
+ user-select: none;
1437
+ position: relative;
1438
+ display: inline-flex;
1439
+ align-items: center;
1440
+ min-height: var(--n-node-content-height);
1441
+ box-sizing: border-box;
1442
+ line-height: var(--n-line-height);
1443
+ vertical-align: bottom;
1444
+ padding: 0 6px 0 4px;
1445
+ cursor: default;
1446
+ border-radius: var(--n-node-border-radius);
1447
+ color: var(--n-node-text-color);
1448
+ transition:
1449
+ color .3s var(--n-bezier),
1450
+ background-color .3s var(--n-bezier),
1451
+ border-color .3s var(--n-bezier);
1452
+ `, [c("&:last-child", "margin-bottom: 0;"), cE("prefix", `
1453
+ display: inline-flex;
1454
+ margin-right: 8px;
1455
+ `), cE("text", `
1456
+ border-bottom: 1px solid #0000;
1457
+ transition: border-color .3s var(--n-bezier);
1458
+ flex-grow: 1;
1459
+ max-width: 100%;
1460
+ `), cE("suffix", `
1461
+ display: inline-flex;
1462
+ `)]), cE("empty", "margin: auto;")]);
1463
+ var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
1464
+ function adopt(value) {
1465
+ return value instanceof P ? value : new P(function(resolve) {
1466
+ resolve(value);
1467
+ });
1468
+ }
1469
+ return new (P || (P = Promise))(function(resolve, reject) {
1470
+ function fulfilled(value) {
1471
+ try {
1472
+ step(generator.next(value));
1473
+ } catch (e) {
1474
+ reject(e);
1475
+ }
1476
+ }
1477
+ function rejected(value) {
1478
+ try {
1479
+ step(generator["throw"](value));
1480
+ } catch (e) {
1481
+ reject(e);
1482
+ }
1483
+ }
1484
+ function step(result) {
1485
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1486
+ }
1487
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1488
+ });
1489
+ };
1490
+ function createTreeMateOptions(keyField, childrenField, disabledField, getChildren) {
1491
+ const settledGetChildren = getChildren || ((node) => {
1492
+ return node[childrenField];
1493
+ });
1494
+ return {
1495
+ getIsGroup() {
1496
+ return false;
1497
+ },
1498
+ getKey(node) {
1499
+ return node[keyField];
1500
+ },
1501
+ getChildren: settledGetChildren,
1502
+ getDisabled(node) {
1503
+ return !!(node[disabledField] || node.checkboxDisabled);
1504
+ }
1505
+ };
1506
+ }
1507
+ const treeSharedProps = {
1508
+ allowCheckingNotLoaded: Boolean,
1509
+ filter: Function,
1510
+ defaultExpandAll: Boolean,
1511
+ expandedKeys: Array,
1512
+ keyField: {
1513
+ type: String,
1514
+ default: "key"
1515
+ },
1516
+ labelField: {
1517
+ type: String,
1518
+ default: "label"
1519
+ },
1520
+ childrenField: {
1521
+ type: String,
1522
+ default: "children"
1523
+ },
1524
+ disabledField: {
1525
+ type: String,
1526
+ default: "disabled"
1527
+ },
1528
+ defaultExpandedKeys: {
1529
+ type: Array,
1530
+ default: () => []
1531
+ },
1532
+ indeterminateKeys: Array,
1533
+ renderSwitcherIcon: Function,
1534
+ onUpdateIndeterminateKeys: [Function, Array],
1535
+ "onUpdate:indeterminateKeys": [Function, Array],
1536
+ onUpdateExpandedKeys: [Function, Array],
1537
+ "onUpdate:expandedKeys": [Function, Array]
1538
+ };
1539
+ const treeProps = Object.assign(Object.assign(Object.assign(Object.assign({}, useTheme.props), { accordion: Boolean, showIrrelevantNodes: { type: Boolean, default: true }, data: {
1540
+ type: Array,
1541
+ default: () => []
1542
+ }, expandOnDragenter: {
1543
+ type: Boolean,
1544
+ default: true
1545
+ }, expandOnClick: Boolean, checkOnClick: {
1546
+ type: [Boolean, Function],
1547
+ default: false
1548
+ }, cancelable: {
1549
+ type: Boolean,
1550
+ default: true
1551
+ }, checkable: Boolean, draggable: Boolean, blockNode: Boolean, blockLine: Boolean, showLine: Boolean, disabled: Boolean, checkedKeys: Array, defaultCheckedKeys: {
1552
+ type: Array,
1553
+ default: () => []
1554
+ }, selectedKeys: Array, defaultSelectedKeys: {
1555
+ type: Array,
1556
+ default: () => []
1557
+ }, multiple: Boolean, pattern: {
1558
+ type: String,
1559
+ default: ""
1560
+ }, onLoad: Function, cascade: Boolean, selectable: {
1561
+ type: Boolean,
1562
+ default: true
1563
+ }, scrollbarProps: Object, indent: {
1564
+ type: Number,
1565
+ default: 24
1566
+ }, allowDrop: {
1567
+ type: Function,
1568
+ default: defaultAllowDrop
1569
+ }, animated: {
1570
+ type: Boolean,
1571
+ default: true
1572
+ }, checkboxPlacement: {
1573
+ type: String,
1574
+ default: "left"
1575
+ }, virtualScroll: Boolean, watchProps: Array, renderLabel: Function, renderPrefix: Function, renderSuffix: Function, nodeProps: Function, keyboard: {
1576
+ type: Boolean,
1577
+ default: true
1578
+ }, getChildren: Function, onDragenter: [Function, Array], onDragleave: [Function, Array], onDragend: [Function, Array], onDragstart: [Function, Array], onDragover: [Function, Array], onDrop: [Function, Array], onUpdateCheckedKeys: [Function, Array], "onUpdate:checkedKeys": [Function, Array], onUpdateSelectedKeys: [Function, Array], "onUpdate:selectedKeys": [Function, Array] }), treeSharedProps), {
1579
+ // internal props for tree-select
1580
+ internalTreeSelect: Boolean,
1581
+ internalScrollable: Boolean,
1582
+ internalScrollablePadding: String,
1583
+ // use it to display
1584
+ internalRenderEmpty: Function,
1585
+ internalHighlightKeySet: Object,
1586
+ internalUnifySelectCheck: Boolean,
1587
+ internalCheckboxFocusable: {
1588
+ type: Boolean,
1589
+ default: true
1590
+ },
1591
+ internalFocusable: {
1592
+ // Make tree-select take over keyboard operations
1593
+ type: Boolean,
1594
+ default: true
1595
+ },
1596
+ checkStrategy: {
1597
+ type: String,
1598
+ default: "all"
1599
+ },
1600
+ /**
1601
+ * @deprecated
1602
+ */
1603
+ leafOnly: Boolean
1604
+ });
1605
+ const NTree = defineComponent({
1606
+ name: "Tree",
1607
+ props: treeProps,
1608
+ setup(props) {
1609
+ const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props);
1610
+ const rtlEnabledRef = useRtl("Tree", mergedRtlRef, mergedClsPrefixRef);
1611
+ const themeRef = useTheme("Tree", "-tree", style, treeLight$1, props, mergedClsPrefixRef);
1612
+ const selfElRef = ref(null);
1613
+ const scrollbarInstRef = ref(null);
1614
+ const virtualListInstRef = ref(null);
1615
+ function getScrollContainer() {
1616
+ var _a;
1617
+ return (_a = virtualListInstRef.value) === null || _a === void 0 ? void 0 : _a.listElRef;
1618
+ }
1619
+ function getScrollContent() {
1620
+ var _a;
1621
+ return (_a = virtualListInstRef.value) === null || _a === void 0 ? void 0 : _a.itemsElRef;
1622
+ }
1623
+ const mergedFilterRef = computed(() => {
1624
+ const { filter } = props;
1625
+ if (filter)
1626
+ return filter;
1627
+ const { labelField } = props;
1628
+ return (pattern, node) => {
1629
+ if (!pattern.length)
1630
+ return true;
1631
+ const label = node[labelField];
1632
+ if (typeof label === "string") {
1633
+ return label.toLowerCase().includes(pattern.toLowerCase());
1634
+ }
1635
+ return false;
1636
+ };
1637
+ });
1638
+ const filteredTreeInfoRef = computed(() => {
1639
+ const { pattern } = props;
1640
+ if (!pattern) {
1641
+ return {
1642
+ filteredTree: props.data,
1643
+ highlightKeySet: null,
1644
+ expandedKeys: void 0
1645
+ };
1646
+ }
1647
+ if (!pattern.length || !mergedFilterRef.value) {
1648
+ return {
1649
+ filteredTree: props.data,
1650
+ highlightKeySet: null,
1651
+ expandedKeys: void 0
1652
+ };
1653
+ }
1654
+ return filterTree(props.data, mergedFilterRef.value, pattern, props.keyField, props.childrenField);
1655
+ });
1656
+ const displayTreeMateRef = computed(() => createTreeMate(props.showIrrelevantNodes ? props.data : filteredTreeInfoRef.value.filteredTree, createTreeMateOptions(props.keyField, props.childrenField, props.disabledField, props.getChildren)));
1657
+ const treeSelectInjection = inject(treeSelectInjectionKey, null);
1658
+ const dataTreeMateRef = props.internalTreeSelect ? treeSelectInjection.dataTreeMate : displayTreeMateRef;
1659
+ const { watchProps } = props;
1660
+ const uncontrolledCheckedKeysRef = ref([]);
1661
+ if (watchProps === null || watchProps === void 0 ? void 0 : watchProps.includes("defaultCheckedKeys")) {
1662
+ watchEffect(() => {
1663
+ uncontrolledCheckedKeysRef.value = props.defaultCheckedKeys;
1664
+ });
1665
+ } else {
1666
+ uncontrolledCheckedKeysRef.value = props.defaultCheckedKeys;
1667
+ }
1668
+ const controlledCheckedKeysRef = toRef(props, "checkedKeys");
1669
+ const mergedCheckedKeysRef = useMergedState(controlledCheckedKeysRef, uncontrolledCheckedKeysRef);
1670
+ const checkedStatusRef = computed(() => {
1671
+ const value = dataTreeMateRef.value.getCheckedKeys(mergedCheckedKeysRef.value, {
1672
+ cascade: props.cascade,
1673
+ allowNotLoaded: props.allowCheckingNotLoaded
1674
+ });
1675
+ return value;
1676
+ });
1677
+ const mergedCheckStrategyRef = useMergedCheckStrategy(props);
1678
+ const displayedCheckedKeysRef = computed(() => {
1679
+ return checkedStatusRef.value.checkedKeys;
1680
+ });
1681
+ const displayedIndeterminateKeysRef = computed(() => {
1682
+ const { indeterminateKeys } = props;
1683
+ if (indeterminateKeys !== void 0)
1684
+ return indeterminateKeys;
1685
+ return checkedStatusRef.value.indeterminateKeys;
1686
+ });
1687
+ const uncontrolledSelectedKeysRef = ref([]);
1688
+ if (watchProps === null || watchProps === void 0 ? void 0 : watchProps.includes("defaultSelectedKeys")) {
1689
+ watchEffect(() => {
1690
+ uncontrolledSelectedKeysRef.value = props.defaultSelectedKeys;
1691
+ });
1692
+ } else {
1693
+ uncontrolledSelectedKeysRef.value = props.defaultSelectedKeys;
1694
+ }
1695
+ const controlledSelectedKeysRef = toRef(props, "selectedKeys");
1696
+ const mergedSelectedKeysRef = useMergedState(controlledSelectedKeysRef, uncontrolledSelectedKeysRef);
1697
+ const uncontrolledExpandedKeysRef = ref([]);
1698
+ const initUncontrolledExpandedKeys = (keys) => {
1699
+ uncontrolledExpandedKeysRef.value = props.defaultExpandAll ? dataTreeMateRef.value.getNonLeafKeys() : keys === void 0 ? props.defaultExpandedKeys : keys;
1700
+ };
1701
+ if (watchProps === null || watchProps === void 0 ? void 0 : watchProps.includes("defaultExpandedKeys")) {
1702
+ watchEffect(() => {
1703
+ initUncontrolledExpandedKeys(void 0);
1704
+ });
1705
+ } else {
1706
+ watchEffect(() => {
1707
+ initUncontrolledExpandedKeys(props.defaultExpandedKeys);
1708
+ });
1709
+ }
1710
+ const controlledExpandedKeysRef = toRef(props, "expandedKeys");
1711
+ const mergedExpandedKeysRef = useMergedState(controlledExpandedKeysRef, uncontrolledExpandedKeysRef);
1712
+ const fNodesRef = computed(() => displayTreeMateRef.value.getFlattenedNodes(mergedExpandedKeysRef.value));
1713
+ const { pendingNodeKeyRef, handleKeydown } = useKeyboard({
1714
+ props,
1715
+ mergedSelectedKeysRef,
1716
+ fNodesRef,
1717
+ mergedExpandedKeysRef,
1718
+ handleSelect,
1719
+ handleSwitcherClick
1720
+ });
1721
+ let expandTimerId = null;
1722
+ let nodeKeyToBeExpanded = null;
1723
+ const uncontrolledHighlightKeySetRef = ref(/* @__PURE__ */ new Set());
1724
+ const controlledHighlightKeySetRef = computed(() => {
1725
+ return props.internalHighlightKeySet || filteredTreeInfoRef.value.highlightKeySet;
1726
+ });
1727
+ const mergedHighlightKeySetRef = useMergedState(controlledHighlightKeySetRef, uncontrolledHighlightKeySetRef);
1728
+ const loadingKeysRef = ref(/* @__PURE__ */ new Set());
1729
+ const expandedNonLoadingKeysRef = computed(() => {
1730
+ return mergedExpandedKeysRef.value.filter((key) => !loadingKeysRef.value.has(key));
1731
+ });
1732
+ let dragStartX = 0;
1733
+ const draggingNodeRef = ref(null);
1734
+ const droppingNodeRef = ref(null);
1735
+ const droppingMouseNodeRef = ref(null);
1736
+ const droppingPositionRef = ref(null);
1737
+ const droppingOffsetLevelRef = ref(0);
1738
+ const droppingNodeParentRef = computed(() => {
1739
+ const { value: droppingNode } = droppingNodeRef;
1740
+ if (!droppingNode)
1741
+ return null;
1742
+ return droppingNode.parent;
1743
+ });
1744
+ watch(toRef(props, "data"), () => {
1745
+ loadingKeysRef.value.clear();
1746
+ pendingNodeKeyRef.value = null;
1747
+ resetDndState();
1748
+ }, {
1749
+ deep: false
1750
+ });
1751
+ let expandAnimationDisabled = false;
1752
+ const disableExpandAnimationForOneTick = () => {
1753
+ expandAnimationDisabled = true;
1754
+ void nextTick(() => {
1755
+ expandAnimationDisabled = false;
1756
+ });
1757
+ };
1758
+ let memoizedExpandedKeys;
1759
+ watch(toRef(props, "pattern"), (value, oldValue) => {
1760
+ if (props.showIrrelevantNodes) {
1761
+ memoizedExpandedKeys = void 0;
1762
+ if (value) {
1763
+ const { expandedKeys: expandedKeysAfterChange, highlightKeySet } = keysWithFilter(props.data, props.pattern, props.keyField, props.childrenField, mergedFilterRef.value);
1764
+ uncontrolledHighlightKeySetRef.value = highlightKeySet;
1765
+ disableExpandAnimationForOneTick();
1766
+ doUpdateExpandedKeys(expandedKeysAfterChange, getOptionsByKeys(expandedKeysAfterChange), { node: null, action: "filter" });
1767
+ } else {
1768
+ uncontrolledHighlightKeySetRef.value = /* @__PURE__ */ new Set();
1769
+ }
1770
+ } else {
1771
+ if (!value.length) {
1772
+ if (memoizedExpandedKeys !== void 0) {
1773
+ disableExpandAnimationForOneTick();
1774
+ doUpdateExpandedKeys(memoizedExpandedKeys, getOptionsByKeys(memoizedExpandedKeys), { node: null, action: "filter" });
1775
+ }
1776
+ } else {
1777
+ if (!oldValue.length) {
1778
+ memoizedExpandedKeys = mergedExpandedKeysRef.value;
1779
+ }
1780
+ const { expandedKeys } = filteredTreeInfoRef.value;
1781
+ if (expandedKeys !== void 0) {
1782
+ disableExpandAnimationForOneTick();
1783
+ doUpdateExpandedKeys(expandedKeys, getOptionsByKeys(expandedKeys), {
1784
+ node: null,
1785
+ action: "filter"
1786
+ });
1787
+ }
1788
+ }
1789
+ }
1790
+ });
1791
+ function triggerLoading(node) {
1792
+ return __awaiter(this, void 0, void 0, function* () {
1793
+ const { onLoad } = props;
1794
+ if (!onLoad) {
1795
+ yield Promise.resolve();
1796
+ return;
1797
+ }
1798
+ const { value: loadingKeys } = loadingKeysRef;
1799
+ if (!loadingKeys.has(node.key)) {
1800
+ loadingKeys.add(node.key);
1801
+ try {
1802
+ const loadResult = yield onLoad(node.rawNode);
1803
+ if (loadResult === false) {
1804
+ resetDragExpandState();
1805
+ }
1806
+ } catch (loadError) {
1807
+ console.error(loadError);
1808
+ resetDragExpandState();
1809
+ }
1810
+ loadingKeys.delete(node.key);
1811
+ }
1812
+ });
1813
+ }
1814
+ watchEffect(() => {
1815
+ var _a;
1816
+ const { value: displayTreeMate } = displayTreeMateRef;
1817
+ if (!displayTreeMate)
1818
+ return;
1819
+ const { getNode } = displayTreeMate;
1820
+ (_a = mergedExpandedKeysRef.value) === null || _a === void 0 ? void 0 : _a.forEach((key) => {
1821
+ const node = getNode(key);
1822
+ if (node && !node.shallowLoaded) {
1823
+ void triggerLoading(node);
1824
+ }
1825
+ });
1826
+ });
1827
+ const aipRef = ref(false);
1828
+ const afNodesRef = ref([]);
1829
+ watch(expandedNonLoadingKeysRef, (value, prevValue) => {
1830
+ if (!props.animated || expandAnimationDisabled) {
1831
+ void nextTick(syncScrollbar);
1832
+ return;
1833
+ }
1834
+ const nodeHeight = depx(themeRef.value.self.nodeHeight);
1835
+ const prevVSet = new Set(prevValue);
1836
+ let addedKey = null;
1837
+ let removedKey = null;
1838
+ for (const expandedKey of value) {
1839
+ if (!prevVSet.has(expandedKey)) {
1840
+ if (addedKey !== null)
1841
+ return;
1842
+ addedKey = expandedKey;
1843
+ }
1844
+ }
1845
+ const currentVSet = new Set(value);
1846
+ for (const expandedKey of prevValue) {
1847
+ if (!currentVSet.has(expandedKey)) {
1848
+ if (removedKey !== null)
1849
+ return;
1850
+ removedKey = expandedKey;
1851
+ }
1852
+ }
1853
+ if (addedKey === null && removedKey === null) {
1854
+ return;
1855
+ }
1856
+ const { virtualScroll } = props;
1857
+ const viewportHeight = (virtualScroll ? virtualListInstRef.value.listElRef : selfElRef.value).offsetHeight;
1858
+ const viewportItemCount = Math.ceil(viewportHeight / nodeHeight) + 1;
1859
+ let baseExpandedKeys;
1860
+ if (addedKey !== null) {
1861
+ baseExpandedKeys = prevValue;
1862
+ }
1863
+ if (removedKey !== null) {
1864
+ if (baseExpandedKeys === void 0) {
1865
+ baseExpandedKeys = value;
1866
+ } else {
1867
+ baseExpandedKeys = baseExpandedKeys.filter((key) => key !== removedKey);
1868
+ }
1869
+ }
1870
+ aipRef.value = true;
1871
+ afNodesRef.value = displayTreeMateRef.value.getFlattenedNodes(baseExpandedKeys);
1872
+ if (addedKey !== null) {
1873
+ const expandedNodeIndex = afNodesRef.value.findIndex((node) => node.key === addedKey);
1874
+ if (~expandedNodeIndex) {
1875
+ const children = (
1876
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1877
+ afNodesRef.value[expandedNodeIndex].children
1878
+ );
1879
+ if (children) {
1880
+ const expandedChildren = flatten(children, value);
1881
+ afNodesRef.value.splice(expandedNodeIndex + 1, 0, {
1882
+ __motion: true,
1883
+ mode: "expand",
1884
+ height: virtualScroll ? expandedChildren.length * nodeHeight : void 0,
1885
+ nodes: virtualScroll ? expandedChildren.slice(0, viewportItemCount) : expandedChildren
1886
+ });
1887
+ }
1888
+ }
1889
+ }
1890
+ if (removedKey !== null) {
1891
+ const collapsedNodeIndex = afNodesRef.value.findIndex((node) => node.key === removedKey);
1892
+ if (~collapsedNodeIndex) {
1893
+ const collapsedNodeChildren = afNodesRef.value[collapsedNodeIndex].children;
1894
+ if (!collapsedNodeChildren)
1895
+ return;
1896
+ aipRef.value = true;
1897
+ const collapsedChildren = flatten(collapsedNodeChildren, value);
1898
+ afNodesRef.value.splice(collapsedNodeIndex + 1, 0, {
1899
+ __motion: true,
1900
+ mode: "collapse",
1901
+ height: virtualScroll ? collapsedChildren.length * nodeHeight : void 0,
1902
+ nodes: virtualScroll ? collapsedChildren.slice(0, viewportItemCount) : collapsedChildren
1903
+ });
1904
+ }
1905
+ }
1906
+ });
1907
+ const getFIndexRef = computed(() => {
1908
+ return createIndexGetter(fNodesRef.value);
1909
+ });
1910
+ const mergedFNodesRef = computed(() => {
1911
+ if (aipRef.value)
1912
+ return afNodesRef.value;
1913
+ else
1914
+ return fNodesRef.value;
1915
+ });
1916
+ function syncScrollbar() {
1917
+ const { value: scrollbarInst } = scrollbarInstRef;
1918
+ if (scrollbarInst)
1919
+ scrollbarInst.sync();
1920
+ }
1921
+ function handleAfterEnter() {
1922
+ aipRef.value = false;
1923
+ if (props.virtualScroll) {
1924
+ void nextTick(syncScrollbar);
1925
+ }
1926
+ }
1927
+ function getOptionsByKeys(keys) {
1928
+ const { getNode } = dataTreeMateRef.value;
1929
+ return keys.map((key) => {
1930
+ var _a;
1931
+ return ((_a = getNode(key)) === null || _a === void 0 ? void 0 : _a.rawNode) || null;
1932
+ });
1933
+ }
1934
+ function doUpdateExpandedKeys(value, option, meta) {
1935
+ const { "onUpdate:expandedKeys": _onUpdateExpandedKeys, onUpdateExpandedKeys } = props;
1936
+ uncontrolledExpandedKeysRef.value = value;
1937
+ if (_onUpdateExpandedKeys) {
1938
+ call(_onUpdateExpandedKeys, value, option, meta);
1939
+ }
1940
+ if (onUpdateExpandedKeys) {
1941
+ call(onUpdateExpandedKeys, value, option, meta);
1942
+ }
1943
+ }
1944
+ function doUpdateCheckedKeys(value, option, meta) {
1945
+ const { "onUpdate:checkedKeys": _onUpdateCheckedKeys, onUpdateCheckedKeys } = props;
1946
+ uncontrolledCheckedKeysRef.value = value;
1947
+ if (onUpdateCheckedKeys) {
1948
+ call(onUpdateCheckedKeys, value, option, meta);
1949
+ }
1950
+ if (_onUpdateCheckedKeys) {
1951
+ call(_onUpdateCheckedKeys, value, option, meta);
1952
+ }
1953
+ }
1954
+ function doUpdateIndeterminateKeys(value, option) {
1955
+ const { "onUpdate:indeterminateKeys": _onUpdateIndeterminateKeys, onUpdateIndeterminateKeys } = props;
1956
+ if (_onUpdateIndeterminateKeys) {
1957
+ call(_onUpdateIndeterminateKeys, value, option);
1958
+ }
1959
+ if (onUpdateIndeterminateKeys) {
1960
+ call(onUpdateIndeterminateKeys, value, option);
1961
+ }
1962
+ }
1963
+ function doUpdateSelectedKeys(value, option, meta) {
1964
+ const { "onUpdate:selectedKeys": _onUpdateSelectedKeys, onUpdateSelectedKeys } = props;
1965
+ uncontrolledSelectedKeysRef.value = value;
1966
+ if (onUpdateSelectedKeys) {
1967
+ call(onUpdateSelectedKeys, value, option, meta);
1968
+ }
1969
+ if (_onUpdateSelectedKeys) {
1970
+ call(_onUpdateSelectedKeys, value, option, meta);
1971
+ }
1972
+ }
1973
+ function doDragEnter(info) {
1974
+ const { onDragenter } = props;
1975
+ if (onDragenter)
1976
+ call(onDragenter, info);
1977
+ }
1978
+ function doDragLeave(info) {
1979
+ const { onDragleave } = props;
1980
+ if (onDragleave)
1981
+ call(onDragleave, info);
1982
+ }
1983
+ function doDragEnd(info) {
1984
+ const { onDragend } = props;
1985
+ if (onDragend)
1986
+ call(onDragend, info);
1987
+ }
1988
+ function doDragStart(info) {
1989
+ const { onDragstart } = props;
1990
+ if (onDragstart)
1991
+ call(onDragstart, info);
1992
+ }
1993
+ function doDragOver(info) {
1994
+ const { onDragover } = props;
1995
+ if (onDragover)
1996
+ call(onDragover, info);
1997
+ }
1998
+ function doDrop(info) {
1999
+ const { onDrop } = props;
2000
+ if (onDrop)
2001
+ call(onDrop, info);
2002
+ }
2003
+ function resetDndState() {
2004
+ resetDragState();
2005
+ resetDropState();
2006
+ }
2007
+ function resetDragState() {
2008
+ draggingNodeRef.value = null;
2009
+ }
2010
+ function resetDropState() {
2011
+ droppingOffsetLevelRef.value = 0;
2012
+ droppingNodeRef.value = null;
2013
+ droppingMouseNodeRef.value = null;
2014
+ droppingPositionRef.value = null;
2015
+ resetDragExpandState();
2016
+ }
2017
+ function resetDragExpandState() {
2018
+ if (expandTimerId) {
2019
+ window.clearTimeout(expandTimerId);
2020
+ expandTimerId = null;
2021
+ }
2022
+ nodeKeyToBeExpanded = null;
2023
+ }
2024
+ function handleCheck(node, checked) {
2025
+ if (props.disabled || isNodeDisabled(node, props.disabledField)) {
2026
+ return;
2027
+ }
2028
+ if (props.internalUnifySelectCheck && !props.multiple) {
2029
+ handleSelect(node);
2030
+ return;
2031
+ }
2032
+ const checkedAction = checked ? "check" : "uncheck";
2033
+ const { checkedKeys, indeterminateKeys } = dataTreeMateRef.value[checkedAction](node.key, displayedCheckedKeysRef.value, {
2034
+ cascade: props.cascade,
2035
+ checkStrategy: mergedCheckStrategyRef.value,
2036
+ allowNotLoaded: props.allowCheckingNotLoaded
2037
+ });
2038
+ doUpdateCheckedKeys(checkedKeys, getOptionsByKeys(checkedKeys), {
2039
+ node: node.rawNode,
2040
+ action: checkedAction
2041
+ });
2042
+ doUpdateIndeterminateKeys(indeterminateKeys, getOptionsByKeys(indeterminateKeys));
2043
+ }
2044
+ function toggleExpand(node) {
2045
+ if (props.disabled)
2046
+ return;
2047
+ const { key } = node;
2048
+ const { value: mergedExpandedKeys } = mergedExpandedKeysRef;
2049
+ const index = mergedExpandedKeys.findIndex((expandNodeId) => expandNodeId === key);
2050
+ if (~index) {
2051
+ const expandedKeysAfterChange = Array.from(mergedExpandedKeys);
2052
+ expandedKeysAfterChange.splice(index, 1);
2053
+ doUpdateExpandedKeys(expandedKeysAfterChange, getOptionsByKeys(expandedKeysAfterChange), {
2054
+ node: node.rawNode,
2055
+ action: "collapse"
2056
+ });
2057
+ } else {
2058
+ const nodeToBeExpanded = displayTreeMateRef.value.getNode(key);
2059
+ if (!nodeToBeExpanded || nodeToBeExpanded.isLeaf) {
2060
+ return;
2061
+ }
2062
+ let nextKeys;
2063
+ if (props.accordion) {
2064
+ const siblingKeySet = new Set(node.siblings.map(({ key: key2 }) => key2));
2065
+ nextKeys = mergedExpandedKeys.filter((expandedKey) => {
2066
+ return !siblingKeySet.has(expandedKey);
2067
+ });
2068
+ nextKeys.push(key);
2069
+ } else {
2070
+ nextKeys = mergedExpandedKeys.concat(key);
2071
+ }
2072
+ doUpdateExpandedKeys(nextKeys, getOptionsByKeys(nextKeys), {
2073
+ node: node.rawNode,
2074
+ action: "expand"
2075
+ });
2076
+ }
2077
+ }
2078
+ function handleSwitcherClick(node) {
2079
+ if (props.disabled || aipRef.value)
2080
+ return;
2081
+ toggleExpand(node);
2082
+ }
2083
+ function handleSelect(node) {
2084
+ if (props.disabled || !props.selectable) {
2085
+ return;
2086
+ }
2087
+ pendingNodeKeyRef.value = node.key;
2088
+ if (props.internalUnifySelectCheck) {
2089
+ const { value: { checkedKeys, indeterminateKeys } } = checkedStatusRef;
2090
+ if (props.multiple) {
2091
+ handleCheck(node, !(checkedKeys.includes(node.key) || indeterminateKeys.includes(node.key)));
2092
+ } else {
2093
+ doUpdateCheckedKeys([node.key], getOptionsByKeys([node.key]), {
2094
+ node: node.rawNode,
2095
+ action: "check"
2096
+ });
2097
+ }
2098
+ }
2099
+ if (props.multiple) {
2100
+ const selectedKeys = Array.from(mergedSelectedKeysRef.value);
2101
+ const index = selectedKeys.findIndex((key) => key === node.key);
2102
+ if (~index) {
2103
+ if (props.cancelable) {
2104
+ selectedKeys.splice(index, 1);
2105
+ }
2106
+ } else if (!~index) {
2107
+ selectedKeys.push(node.key);
2108
+ }
2109
+ doUpdateSelectedKeys(selectedKeys, getOptionsByKeys(selectedKeys), {
2110
+ node: node.rawNode,
2111
+ action: ~index ? "unselect" : "select"
2112
+ });
2113
+ } else {
2114
+ const selectedKeys = mergedSelectedKeysRef.value;
2115
+ if (selectedKeys.includes(node.key)) {
2116
+ if (props.cancelable) {
2117
+ doUpdateSelectedKeys([], [], {
2118
+ node: node.rawNode,
2119
+ action: "unselect"
2120
+ });
2121
+ }
2122
+ } else {
2123
+ doUpdateSelectedKeys([node.key], getOptionsByKeys([node.key]), {
2124
+ node: node.rawNode,
2125
+ action: "select"
2126
+ });
2127
+ }
2128
+ }
2129
+ }
2130
+ function expandDragEnterNode(node) {
2131
+ if (expandTimerId) {
2132
+ window.clearTimeout(expandTimerId);
2133
+ expandTimerId = null;
2134
+ }
2135
+ if (node.isLeaf)
2136
+ return;
2137
+ nodeKeyToBeExpanded = node.key;
2138
+ const expand = () => {
2139
+ if (nodeKeyToBeExpanded !== node.key)
2140
+ return;
2141
+ const { value: droppingMouseNode } = droppingMouseNodeRef;
2142
+ if (droppingMouseNode && droppingMouseNode.key === node.key && !mergedExpandedKeysRef.value.includes(node.key)) {
2143
+ const nextKeys = mergedExpandedKeysRef.value.concat(node.key);
2144
+ doUpdateExpandedKeys(nextKeys, getOptionsByKeys(nextKeys), {
2145
+ node: node.rawNode,
2146
+ action: "expand"
2147
+ });
2148
+ }
2149
+ expandTimerId = null;
2150
+ nodeKeyToBeExpanded = null;
2151
+ };
2152
+ if (!node.shallowLoaded) {
2153
+ expandTimerId = window.setTimeout(() => {
2154
+ void triggerLoading(node).then(() => {
2155
+ expand();
2156
+ });
2157
+ }, 1e3);
2158
+ } else {
2159
+ expandTimerId = window.setTimeout(() => {
2160
+ expand();
2161
+ }, 1e3);
2162
+ }
2163
+ }
2164
+ function handleDragEnter({ event, node }) {
2165
+ if (!props.draggable || props.disabled || isNodeDisabled(node, props.disabledField)) {
2166
+ return;
2167
+ }
2168
+ handleDragOver({ event, node }, false);
2169
+ doDragEnter({ event, node: node.rawNode });
2170
+ }
2171
+ function handleDragLeave({ event, node }) {
2172
+ if (!props.draggable || props.disabled || isNodeDisabled(node, props.disabledField)) {
2173
+ return;
2174
+ }
2175
+ doDragLeave({ event, node: node.rawNode });
2176
+ }
2177
+ function handleDragLeaveTree(e) {
2178
+ if (e.target !== e.currentTarget)
2179
+ return;
2180
+ resetDropState();
2181
+ }
2182
+ function handleDragEnd({ event, node }) {
2183
+ resetDndState();
2184
+ if (!props.draggable || props.disabled || isNodeDisabled(node, props.disabledField)) {
2185
+ return;
2186
+ }
2187
+ doDragEnd({ event, node: node.rawNode });
2188
+ }
2189
+ function handleDragStart({ event, node }) {
2190
+ if (!props.draggable || props.disabled || isNodeDisabled(node, props.disabledField)) {
2191
+ return;
2192
+ }
2193
+ dragStartX = event.clientX;
2194
+ draggingNodeRef.value = node;
2195
+ doDragStart({ event, node: node.rawNode });
2196
+ }
2197
+ function handleDragOver({ event, node }, emit = true) {
2198
+ var _a;
2199
+ if (!props.draggable || props.disabled || isNodeDisabled(node, props.disabledField)) {
2200
+ return;
2201
+ }
2202
+ const { value: draggingNode } = draggingNodeRef;
2203
+ if (!draggingNode)
2204
+ return;
2205
+ const { allowDrop, indent } = props;
2206
+ if (emit)
2207
+ doDragOver({ event, node: node.rawNode });
2208
+ const el = event.currentTarget;
2209
+ const { height: elOffsetHeight, top: elClientTop } = el.getBoundingClientRect();
2210
+ const eventOffsetY = event.clientY - elClientTop;
2211
+ let mousePosition;
2212
+ const allowDropInside = allowDrop({
2213
+ node: node.rawNode,
2214
+ dropPosition: "inside",
2215
+ phase: "drag"
2216
+ });
2217
+ if (allowDropInside) {
2218
+ if (eventOffsetY <= 8) {
2219
+ mousePosition = "before";
2220
+ } else if (eventOffsetY >= elOffsetHeight - 8) {
2221
+ mousePosition = "after";
2222
+ } else {
2223
+ mousePosition = "inside";
2224
+ }
2225
+ } else {
2226
+ if (eventOffsetY <= elOffsetHeight / 2) {
2227
+ mousePosition = "before";
2228
+ } else {
2229
+ mousePosition = "after";
2230
+ }
2231
+ }
2232
+ const { value: getFindex } = getFIndexRef;
2233
+ let finalDropNode;
2234
+ let finalDropPosition;
2235
+ const hoverNodeFIndex = getFindex(node.key);
2236
+ if (hoverNodeFIndex === null) {
2237
+ resetDropState();
2238
+ return;
2239
+ }
2240
+ let mouseAtExpandedNonLeafNode = false;
2241
+ if (mousePosition === "inside") {
2242
+ finalDropNode = node;
2243
+ finalDropPosition = "inside";
2244
+ } else {
2245
+ if (mousePosition === "before") {
2246
+ if (node.isFirstChild) {
2247
+ finalDropNode = node;
2248
+ finalDropPosition = "before";
2249
+ } else {
2250
+ finalDropNode = fNodesRef.value[hoverNodeFIndex - 1];
2251
+ finalDropPosition = "after";
2252
+ }
2253
+ } else {
2254
+ finalDropNode = node;
2255
+ finalDropPosition = "after";
2256
+ }
2257
+ }
2258
+ if (!finalDropNode.isLeaf && mergedExpandedKeysRef.value.includes(finalDropNode.key)) {
2259
+ mouseAtExpandedNonLeafNode = true;
2260
+ if (finalDropPosition === "after") {
2261
+ finalDropNode = fNodesRef.value[hoverNodeFIndex + 1];
2262
+ if (!finalDropNode) {
2263
+ finalDropNode = node;
2264
+ finalDropPosition = "inside";
2265
+ } else {
2266
+ finalDropPosition = "before";
2267
+ }
2268
+ }
2269
+ }
2270
+ const droppingMouseNode = finalDropNode;
2271
+ droppingMouseNodeRef.value = droppingMouseNode;
2272
+ if (!mouseAtExpandedNonLeafNode && draggingNode.isLastChild && draggingNode.key === finalDropNode.key) {
2273
+ finalDropPosition = "after";
2274
+ }
2275
+ if (finalDropPosition === "after") {
2276
+ let offset = dragStartX - event.clientX;
2277
+ let offsetLevel = 0;
2278
+ while (offset >= indent / 2 && // divide by 2 to make it easier to trigger
2279
+ finalDropNode.parent !== null && finalDropNode.isLastChild && offsetLevel < 1) {
2280
+ offset -= indent;
2281
+ offsetLevel += 1;
2282
+ finalDropNode = finalDropNode.parent;
2283
+ }
2284
+ droppingOffsetLevelRef.value = offsetLevel;
2285
+ } else {
2286
+ droppingOffsetLevelRef.value = 0;
2287
+ }
2288
+ if (draggingNode.contains(finalDropNode) || finalDropPosition === "inside" && ((_a = draggingNode.parent) === null || _a === void 0 ? void 0 : _a.key) === finalDropNode.key) {
2289
+ if (draggingNode.key === droppingMouseNode.key && draggingNode.key === finalDropNode.key)
2290
+ ;
2291
+ else {
2292
+ resetDropState();
2293
+ return;
2294
+ }
2295
+ }
2296
+ if (!allowDrop({
2297
+ node: finalDropNode.rawNode,
2298
+ dropPosition: finalDropPosition,
2299
+ phase: "drag"
2300
+ })) {
2301
+ resetDropState();
2302
+ return;
2303
+ }
2304
+ if (draggingNode.key === finalDropNode.key) {
2305
+ resetDragExpandState();
2306
+ } else {
2307
+ if (nodeKeyToBeExpanded !== finalDropNode.key) {
2308
+ if (finalDropPosition === "inside") {
2309
+ if (props.expandOnDragenter) {
2310
+ expandDragEnterNode(finalDropNode);
2311
+ if (!finalDropNode.shallowLoaded && nodeKeyToBeExpanded !== finalDropNode.key) {
2312
+ resetDndState();
2313
+ return;
2314
+ }
2315
+ } else {
2316
+ if (!finalDropNode.shallowLoaded) {
2317
+ resetDndState();
2318
+ return;
2319
+ }
2320
+ }
2321
+ } else {
2322
+ resetDragExpandState();
2323
+ }
2324
+ } else {
2325
+ if (finalDropPosition !== "inside") {
2326
+ resetDragExpandState();
2327
+ }
2328
+ }
2329
+ }
2330
+ droppingPositionRef.value = finalDropPosition;
2331
+ droppingNodeRef.value = finalDropNode;
2332
+ }
2333
+ function handleDrop({ event, node, dropPosition }) {
2334
+ if (!props.draggable || props.disabled || isNodeDisabled(node, props.disabledField)) {
2335
+ return;
2336
+ }
2337
+ const { value: draggingNode } = draggingNodeRef;
2338
+ const { value: droppingNode } = droppingNodeRef;
2339
+ const { value: droppingPosition } = droppingPositionRef;
2340
+ if (!draggingNode || !droppingNode || !droppingPosition) {
2341
+ return;
2342
+ }
2343
+ if (!props.allowDrop({
2344
+ node: droppingNode.rawNode,
2345
+ dropPosition: droppingPosition,
2346
+ phase: "drag"
2347
+ })) {
2348
+ return;
2349
+ }
2350
+ if (draggingNode.key === droppingNode.key) {
2351
+ return;
2352
+ }
2353
+ if (droppingPosition === "before") {
2354
+ const nextNode = draggingNode.getNext({ includeDisabled: true });
2355
+ if (nextNode) {
2356
+ if (nextNode.key === droppingNode.key) {
2357
+ resetDropState();
2358
+ return;
2359
+ }
2360
+ }
2361
+ }
2362
+ if (droppingPosition === "after") {
2363
+ const prevNode = draggingNode.getPrev({ includeDisabled: true });
2364
+ if (prevNode) {
2365
+ if (prevNode.key === droppingNode.key) {
2366
+ resetDropState();
2367
+ return;
2368
+ }
2369
+ }
2370
+ }
2371
+ doDrop({
2372
+ event,
2373
+ node: droppingNode.rawNode,
2374
+ dragNode: draggingNode.rawNode,
2375
+ dropPosition
2376
+ });
2377
+ resetDndState();
2378
+ }
2379
+ function handleScroll() {
2380
+ syncScrollbar();
2381
+ }
2382
+ function handleResize() {
2383
+ syncScrollbar();
2384
+ }
2385
+ function handleFocusout(e) {
2386
+ var _a;
2387
+ if (props.virtualScroll || props.internalScrollable) {
2388
+ const { value: scrollbarInst } = scrollbarInstRef;
2389
+ if ((_a = scrollbarInst === null || scrollbarInst === void 0 ? void 0 : scrollbarInst.containerRef) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget)) {
2390
+ return;
2391
+ }
2392
+ pendingNodeKeyRef.value = null;
2393
+ } else {
2394
+ const { value: selfEl } = selfElRef;
2395
+ if (selfEl === null || selfEl === void 0 ? void 0 : selfEl.contains(e.relatedTarget))
2396
+ return;
2397
+ pendingNodeKeyRef.value = null;
2398
+ }
2399
+ }
2400
+ watch(pendingNodeKeyRef, (value) => {
2401
+ var _a, _b;
2402
+ if (value === null)
2403
+ return;
2404
+ if (props.virtualScroll) {
2405
+ (_a = virtualListInstRef.value) === null || _a === void 0 ? void 0 : _a.scrollTo({ key: value });
2406
+ } else if (props.internalScrollable) {
2407
+ const { value: scrollbarInst } = scrollbarInstRef;
2408
+ if (scrollbarInst === null)
2409
+ return;
2410
+ const targetEl = (_b = scrollbarInst.contentRef) === null || _b === void 0 ? void 0 : _b.querySelector(`[data-key="${createDataKey(value)}"]`);
2411
+ if (!targetEl)
2412
+ return;
2413
+ scrollbarInst.scrollTo({
2414
+ el: targetEl
2415
+ });
2416
+ }
2417
+ });
2418
+ provide(treeInjectionKey, {
2419
+ loadingKeysRef,
2420
+ highlightKeySetRef: mergedHighlightKeySetRef,
2421
+ displayedCheckedKeysRef,
2422
+ displayedIndeterminateKeysRef,
2423
+ mergedSelectedKeysRef,
2424
+ mergedExpandedKeysRef,
2425
+ mergedThemeRef: themeRef,
2426
+ mergedCheckStrategyRef,
2427
+ nodePropsRef: toRef(props, "nodeProps"),
2428
+ disabledRef: toRef(props, "disabled"),
2429
+ checkableRef: toRef(props, "checkable"),
2430
+ selectableRef: toRef(props, "selectable"),
2431
+ expandOnClickRef: toRef(props, "expandOnClick"),
2432
+ onLoadRef: toRef(props, "onLoad"),
2433
+ draggableRef: toRef(props, "draggable"),
2434
+ blockLineRef: toRef(props, "blockLine"),
2435
+ indentRef: toRef(props, "indent"),
2436
+ cascadeRef: toRef(props, "cascade"),
2437
+ checkOnClickRef: toRef(props, "checkOnClick"),
2438
+ checkboxPlacementRef: props.checkboxPlacement,
2439
+ droppingMouseNodeRef,
2440
+ droppingNodeParentRef,
2441
+ draggingNodeRef,
2442
+ droppingPositionRef,
2443
+ droppingOffsetLevelRef,
2444
+ fNodesRef,
2445
+ pendingNodeKeyRef,
2446
+ showLineRef: toRef(props, "showLine"),
2447
+ disabledFieldRef: toRef(props, "disabledField"),
2448
+ internalScrollableRef: toRef(props, "internalScrollable"),
2449
+ internalCheckboxFocusableRef: toRef(props, "internalCheckboxFocusable"),
2450
+ internalTreeSelect: props.internalTreeSelect,
2451
+ renderLabelRef: toRef(props, "renderLabel"),
2452
+ renderPrefixRef: toRef(props, "renderPrefix"),
2453
+ renderSuffixRef: toRef(props, "renderSuffix"),
2454
+ renderSwitcherIconRef: toRef(props, "renderSwitcherIcon"),
2455
+ labelFieldRef: toRef(props, "labelField"),
2456
+ multipleRef: toRef(props, "multiple"),
2457
+ handleSwitcherClick,
2458
+ handleDragEnd,
2459
+ handleDragEnter,
2460
+ handleDragLeave,
2461
+ handleDragStart,
2462
+ handleDrop,
2463
+ handleDragOver,
2464
+ handleSelect,
2465
+ handleCheck
2466
+ });
2467
+ function scrollTo(options) {
2468
+ var _a;
2469
+ (_a = virtualListInstRef.value) === null || _a === void 0 ? void 0 : _a.scrollTo(options);
2470
+ }
2471
+ const exposedMethods = {
2472
+ handleKeydown,
2473
+ scrollTo,
2474
+ getCheckedData: () => {
2475
+ if (!props.checkable)
2476
+ return { keys: [], options: [] };
2477
+ const { checkedKeys } = checkedStatusRef.value;
2478
+ return {
2479
+ keys: checkedKeys,
2480
+ options: getOptionsByKeys(checkedKeys)
2481
+ };
2482
+ },
2483
+ getIndeterminateData: () => {
2484
+ if (!props.checkable)
2485
+ return { keys: [], options: [] };
2486
+ const { indeterminateKeys } = checkedStatusRef.value;
2487
+ return {
2488
+ keys: indeterminateKeys,
2489
+ options: getOptionsByKeys(indeterminateKeys)
2490
+ };
2491
+ }
2492
+ };
2493
+ const cssVarsRef = computed(() => {
2494
+ const { common: { cubicBezierEaseInOut }, self: { fontSize, nodeBorderRadius, nodeColorHover, nodeColorPressed, nodeColorActive, arrowColor, loadingColor, nodeTextColor, nodeTextColorDisabled, dropMarkColor, nodeWrapperPadding, nodeHeight, lineHeight } } = themeRef.value;
2495
+ const lineOffsetTop = getMargin(nodeWrapperPadding, "top");
2496
+ const lineOffsetBottom = getMargin(nodeWrapperPadding, "bottom");
2497
+ const nodeContentHeight = pxfy(depx(nodeHeight) - depx(lineOffsetTop) - depx(lineOffsetBottom));
2498
+ return {
2499
+ "--n-arrow-color": arrowColor,
2500
+ "--n-loading-color": loadingColor,
2501
+ "--n-bezier": cubicBezierEaseInOut,
2502
+ "--n-font-size": fontSize,
2503
+ "--n-node-border-radius": nodeBorderRadius,
2504
+ "--n-node-color-active": nodeColorActive,
2505
+ "--n-node-color-hover": nodeColorHover,
2506
+ "--n-node-color-pressed": nodeColorPressed,
2507
+ "--n-node-text-color": nodeTextColor,
2508
+ "--n-node-text-color-disabled": nodeTextColorDisabled,
2509
+ "--n-drop-mark-color": dropMarkColor,
2510
+ "--n-node-wrapper-padding": nodeWrapperPadding,
2511
+ "--n-line-offset-top": `-${lineOffsetTop}`,
2512
+ "--n-line-offset-bottom": `-${lineOffsetBottom}`,
2513
+ "--n-node-content-height": nodeContentHeight,
2514
+ "--n-line-height": lineHeight
2515
+ };
2516
+ });
2517
+ const themeClassHandle = inlineThemeDisabled ? useThemeClass("tree", void 0, cssVarsRef, props) : void 0;
2518
+ return Object.assign(Object.assign({}, exposedMethods), {
2519
+ mergedClsPrefix: mergedClsPrefixRef,
2520
+ mergedTheme: themeRef,
2521
+ rtlEnabled: rtlEnabledRef,
2522
+ fNodes: mergedFNodesRef,
2523
+ aip: aipRef,
2524
+ selfElRef,
2525
+ virtualListInstRef,
2526
+ scrollbarInstRef,
2527
+ handleFocusout,
2528
+ handleDragLeaveTree,
2529
+ handleScroll,
2530
+ getScrollContainer,
2531
+ getScrollContent,
2532
+ handleAfterEnter,
2533
+ handleResize,
2534
+ cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
2535
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
2536
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
2537
+ });
2538
+ },
2539
+ render() {
2540
+ var _a;
2541
+ const { fNodes, internalRenderEmpty } = this;
2542
+ if (!fNodes.length && internalRenderEmpty) {
2543
+ return internalRenderEmpty();
2544
+ }
2545
+ const { mergedClsPrefix, blockNode, blockLine, draggable, disabled, internalFocusable, checkable, handleKeydown, rtlEnabled, handleFocusout, scrollbarProps } = this;
2546
+ const mergedFocusable = internalFocusable && !disabled;
2547
+ const tabindex = mergedFocusable ? "0" : void 0;
2548
+ const treeClass = [
2549
+ `${mergedClsPrefix}-tree`,
2550
+ rtlEnabled && `${mergedClsPrefix}-tree--rtl`,
2551
+ checkable && `${mergedClsPrefix}-tree--checkable`,
2552
+ (blockLine || blockNode) && `${mergedClsPrefix}-tree--block-node`,
2553
+ blockLine && `${mergedClsPrefix}-tree--block-line`
2554
+ ];
2555
+ const createNode = (tmNode) => {
2556
+ return "__motion" in tmNode ? h(MotionWrapper, { height: tmNode.height, nodes: tmNode.nodes, clsPrefix: mergedClsPrefix, mode: tmNode.mode, onAfterEnter: this.handleAfterEnter }) : h(NTreeNode, { key: tmNode.key, tmNode, clsPrefix: mergedClsPrefix });
2557
+ };
2558
+ if (this.virtualScroll) {
2559
+ const { mergedTheme, internalScrollablePadding } = this;
2560
+ const padding = getMargin(internalScrollablePadding || "0");
2561
+ return h(XScrollbar, Object.assign({}, scrollbarProps, { ref: "scrollbarInstRef", onDragleave: draggable ? this.handleDragLeaveTree : void 0, container: this.getScrollContainer, content: this.getScrollContent, class: treeClass, theme: mergedTheme.peers.Scrollbar, themeOverrides: mergedTheme.peerOverrides.Scrollbar, tabindex, onKeydown: mergedFocusable ? handleKeydown : void 0, onFocusout: mergedFocusable ? handleFocusout : void 0 }), {
2562
+ default: () => {
2563
+ var _a2;
2564
+ (_a2 = this.onRender) === null || _a2 === void 0 ? void 0 : _a2.call(this);
2565
+ return h(VVirtualList, { ref: "virtualListInstRef", items: this.fNodes, itemSize: depx(mergedTheme.self.nodeHeight), ignoreItemResize: this.aip, paddingTop: padding.top, paddingBottom: padding.bottom, class: this.themeClass, style: [
2566
+ this.cssVars,
2567
+ {
2568
+ paddingLeft: padding.left,
2569
+ paddingRight: padding.right
2570
+ }
2571
+ ], onScroll: this.handleScroll, onResize: this.handleResize, showScrollbar: false, itemResizable: true }, {
2572
+ default: ({ item }) => createNode(item)
2573
+ });
2574
+ }
2575
+ });
2576
+ }
2577
+ const { internalScrollable } = this;
2578
+ treeClass.push(this.themeClass);
2579
+ (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
2580
+ if (internalScrollable) {
2581
+ return h(XScrollbar, Object.assign({}, scrollbarProps, { class: treeClass, tabindex, onKeydown: mergedFocusable ? handleKeydown : void 0, onFocusout: mergedFocusable ? handleFocusout : void 0, style: this.cssVars, contentStyle: { padding: this.internalScrollablePadding } }), {
2582
+ default: () => h("div", { onDragleave: draggable ? this.handleDragLeaveTree : void 0, ref: "selfElRef" }, this.fNodes.map(createNode))
2583
+ });
2584
+ } else {
2585
+ return h("div", { class: treeClass, tabindex, ref: "selfElRef", style: this.cssVars, onKeydown: mergedFocusable ? handleKeydown : void 0, onFocusout: mergedFocusable ? handleFocusout : void 0, onDragleave: draggable ? this.handleDragLeaveTree : void 0 }, !fNodes.length ? resolveSlot(this.$slots.empty, () => [
2586
+ h(NEmpty, { class: `${mergedClsPrefix}-tree__empty`, theme: this.mergedTheme.peers.Empty, themeOverrides: this.mergedTheme.peerOverrides.Empty })
2587
+ ]) : fNodes.map(createNode));
2588
+ }
2589
+ }
2590
+ });
2591
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2592
+ __name: "DraggableCard",
2593
+ props: {
2594
+ initialValue: { default: () => ({}) }
2595
+ },
2596
+ setup(__props) {
2597
+ const props = __props;
2598
+ const isLeft = props.initialValue.left !== void 0;
2599
+ const isTop = props.initialValue.top !== void 0;
2600
+ const prevOffset = {
2601
+ x: (isLeft ? props.initialValue.left : props.initialValue.right) ?? 0,
2602
+ y: (isTop ? props.initialValue.top : props.initialValue.bottom) ?? 0
2603
+ };
2604
+ const offset = shallowReactive({ ...prevOffset });
2605
+ const currentStyle = computed(() => {
2606
+ const xStyle = isLeft ? `left:${offset.x}px;` : `right:${offset.x}px;`;
2607
+ const yStyle = isTop ? `top:${offset.y}px;` : `bottom:${offset.y}px;`;
2608
+ return xStyle + yStyle;
2609
+ });
2610
+ let prevEv = void 0;
2611
+ const startMove = (ev) => {
2612
+ prevEv = ev;
2613
+ prevOffset.x = offset.x;
2614
+ prevOffset.y = offset.y;
2615
+ };
2616
+ const move = (ev) => {
2617
+ if (!target.value || !prevEv)
2618
+ return;
2619
+ const dx = ev.clientX - prevEv.clientX;
2620
+ const dy = ev.clientY - prevEv.clientY;
2621
+ offset.x = prevOffset.x + (isLeft ? dx : -dx);
2622
+ offset.y = prevOffset.y + (isTop ? dy : -dy);
2623
+ };
2624
+ const endMove = () => {
2625
+ prevEv = void 0;
2626
+ };
2627
+ const box = shallowRef();
2628
+ const target = shallowRef();
2629
+ const preventSelection = (ev) => {
2630
+ if (prevEv) {
2631
+ ev.preventDefault();
2632
+ }
2633
+ };
2634
+ const transitions = [`transition-top,bottom,left,right-500`];
2635
+ const windowEndMove = () => {
2636
+ if (!target.value)
2637
+ return;
2638
+ const { top, bottom, left, right } = target.value.getBoundingClientRect();
2639
+ if (right < 0 || left > window.innerWidth || bottom < 0 || top > window.innerHeight) {
2640
+ offset.x = prevOffset.x;
2641
+ offset.y = prevOffset.y;
2642
+ endMove();
2643
+ const boxDiv = box.value;
2644
+ if (boxDiv) {
2645
+ boxDiv.classList.add(...transitions);
2646
+ setTimeout(() => {
2647
+ boxDiv.classList.remove(...transitions);
2648
+ }, 550);
2649
+ }
2650
+ }
2651
+ };
2652
+ window.addEventListener("pointermove", move);
2653
+ window.addEventListener("pointerup", windowEndMove);
2654
+ document.addEventListener("selectstart", preventSelection);
2655
+ onUnmounted(() => {
2656
+ window.removeEventListener("pointermove", move);
2657
+ window.removeEventListener("pointerup", windowEndMove);
2658
+ document.removeEventListener("selectstart", preventSelection);
2659
+ endMove();
2660
+ });
2661
+ watch(target, (newValue, oldvalue) => {
2662
+ if (newValue) {
2663
+ newValue.addEventListener("pointerdown", startMove);
2664
+ newValue.addEventListener("pointerup", endMove);
2665
+ }
2666
+ if (oldvalue) {
2667
+ oldvalue.removeEventListener("pointerdown", startMove);
2668
+ oldvalue.removeEventListener("pointerup", endMove);
2669
+ }
2670
+ });
2671
+ onUnmounted(() => {
2672
+ if (!target.value)
2673
+ return;
2674
+ target.value.removeEventListener("pointerdown", startMove);
2675
+ target.value.removeEventListener("pointerup", endMove);
2676
+ });
2677
+ const updateTarget = (arg) => {
2678
+ if (arg instanceof HTMLElement) {
2679
+ target.value = arg;
2680
+ } else {
2681
+ target.value = void 0;
2682
+ }
2683
+ };
2684
+ return (_ctx, _cache) => {
2685
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
2686
+ createBaseVNode("div", {
2687
+ fixed: "",
2688
+ ref_key: "box",
2689
+ ref: box,
2690
+ style: normalizeStyle([_ctx.$attrs.style, currentStyle.value]),
2691
+ class: normalizeClass(_ctx.$attrs.class)
2692
+ }, [
2693
+ renderSlot(_ctx.$slots, "default", { onRef: updateTarget })
2694
+ ], 6)
2695
+ ]);
2696
+ };
2697
+ }
2698
+ });
2699
+ const _hoisted_1$4 = /* @__PURE__ */ createBaseVNode("th", null, "Name", -1);
2700
+ const _hoisted_2$2 = /* @__PURE__ */ createBaseVNode("th", null, "Value", -1);
2701
+ const _hoisted_3$2 = [
2702
+ _hoisted_1$4,
2703
+ _hoisted_2$2
2704
+ ];
2705
+ const _hoisted_4$2 = {
2706
+ key: 0,
2707
+ flex: "",
2708
+ "flex-justify-between": "",
2709
+ "flex-items-center": ""
2710
+ };
2711
+ const _hoisted_5$2 = {
2712
+ key: 0,
2713
+ viewBox: "0 0 28 28"
2714
+ };
2715
+ const _hoisted_6$2 = /* @__PURE__ */ createBaseVNode("g", { fill: "none" }, [
2716
+ /* @__PURE__ */ createBaseVNode("path", {
2717
+ d: "M15 8a1 1 0 1 1-2 0a1 1 0 0 1 2 0zm-1.75 3.75v7.5a.75.75 0 0 0 1.5 0v-7.5a.75.75 0 0 0-1.5 0zM2 14C2 7.373 7.373 2 14 2s12 5.373 12 12s-5.373 12-12 12S2 20.627 2 14zM14 3.5C8.201 3.5 3.5 8.201 3.5 14S8.201 24.5 14 24.5S24.5 19.799 24.5 14S19.799 3.5 14 3.5z",
2718
+ fill: "currentColor"
2719
+ })
2720
+ ], -1);
2721
+ const _hoisted_7$2 = [
2722
+ _hoisted_6$2
2723
+ ];
2724
+ const _hoisted_8$2 = {
2725
+ key: 1,
2726
+ viewBox: "0 0 1024 1024"
2727
+ };
2728
+ const _hoisted_9$2 = /* @__PURE__ */ createBaseVNode("path", { d: "M722.500267 330.888533l-273.408 273.408-147.729067-147.729066a42.018133 42.018133 0 1 0-59.426133 59.426133l177.425066 177.493333a41.984 41.984 0 0 0 59.426134 0L781.9264 390.314667a42.001067 42.001067 0 0 0-59.392-59.426134h-0.034133zM78.506667 783.496533a508.279467 508.279467 0 0 0 319.0784 226.986667C530.773333 1041.066667 667.886933 1017.924267 783.701333 945.390933a508.279467 508.279467 0 0 0 226.986667-319.0784 508.279467 508.279467 0 0 0-65.058133-386.116266C848.554667 85.367467 681.710933 0.341333 511.214933 0.341333a508.6208 508.6208 0 0 0-270.813866 77.960534A36.864 36.864 0 0 0 279.552 140.629333C484.113067 12.288 755.029333 74.581333 883.268267 279.278933a434.9952 434.9952 0 0 1 55.739733 330.5472 435.029333 435.029333 0 0 1-194.3552 273.134934 435.746133 435.746133 0 0 1-330.581333 55.773866A435.165867 435.165867 0 0 1 140.936533 744.379733a436.770133 436.770133 0 0 1-5.666133-456.055466 36.829867 36.829867 0 0 0-63.317333-37.546667A510.1568 510.1568 0 0 0 78.506667 783.530667v-0.034134z" }, null, -1);
2729
+ const _hoisted_10 = [
2730
+ _hoisted_9$2
2731
+ ];
2732
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2733
+ __name: "AttrCard",
2734
+ props: {
2735
+ focusNode: {}
2736
+ },
2737
+ setup(__props) {
2738
+ const props = __props;
2739
+ const lenAttrNames = [`text`, `desc`];
2740
+ const attrs = computed(() => {
2741
+ return Object.entries(props.focusNode.attr).map(([name, value]) => {
2742
+ const attr = {
2743
+ name,
2744
+ value: JSON.stringify(value)
2745
+ };
2746
+ if (lenAttrNames.includes(name)) {
2747
+ return [
2748
+ attr,
2749
+ {
2750
+ name: name + `.length`,
2751
+ value: JSON.stringify((value == null ? void 0 : value.length) ?? null)
2752
+ }
2753
+ ];
2754
+ }
2755
+ return attr;
2756
+ }).flat();
2757
+ });
2758
+ const attrDesc = {
2759
+ _id: `虚拟属性:生成快照访问节点顺序`,
2760
+ _pid: `虚拟属性:父节点的 _id`,
2761
+ depth: `在某些应用上可能造成无限节点错误`,
2762
+ id: `可快速查找`,
2763
+ text: `可快速查找`
2764
+ };
2765
+ return (_ctx, _cache) => {
2766
+ return openBlock(), createBlock(_sfc_main$5, { initialValue: { top: 75, right: 10 } }, {
2767
+ default: withCtx(({ onRef }) => [
2768
+ createVNode(unref(NTable), {
2769
+ size: "small",
2770
+ striped: "",
2771
+ singleLine: false,
2772
+ class: "gkd_code",
2773
+ themeOverrides: {
2774
+ thPaddingSmall: "1px 3px",
2775
+ tdPaddingSmall: "1px 3px"
2776
+ }
2777
+ }, {
2778
+ default: withCtx(() => [
2779
+ createBaseVNode("thead", null, [
2780
+ createBaseVNode("tr", {
2781
+ ref: onRef,
2782
+ "cursor-move": ""
2783
+ }, _hoisted_3$2, 512)
2784
+ ]),
2785
+ createVNode(unref(NTbody), null, {
2786
+ default: withCtx(() => [
2787
+ (openBlock(true), createElementBlock(Fragment, null, renderList(attrs.value, (attrx) => {
2788
+ return openBlock(), createBlock(unref(NTr), {
2789
+ key: attrx.name
2790
+ }, {
2791
+ default: withCtx(() => [
2792
+ createVNode(unref(NTd), {
2793
+ onClick: ($event) => unref(copy)(`${attrx.name}=${attrx.value}`)
2794
+ }, {
2795
+ default: withCtx(() => [
2796
+ attrx.name in attrDesc ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
2797
+ createBaseVNode("div", null, toDisplayString(attrx.name), 1),
2798
+ createVNode(unref(NTooltip), null, {
2799
+ trigger: withCtx(() => [
2800
+ createVNode(unref(NIcon), { size: "16" }, {
2801
+ default: withCtx(() => [
2802
+ attrx.name != `id` && attrx.name != `text` ? (openBlock(), createElementBlock("svg", _hoisted_5$2, _hoisted_7$2)) : (_ctx.focusNode.quickFind || attrx.name == "id" && _ctx.focusNode.idQf || attrx.name == "text" && _ctx.focusNode.textQf) && JSON.parse(attrx.value) ? (openBlock(), createElementBlock("svg", _hoisted_8$2, _hoisted_10)) : createCommentVNode("", true)
2803
+ ]),
2804
+ _: 2
2805
+ }, 1024)
2806
+ ]),
2807
+ default: withCtx(() => [
2808
+ createTextVNode(" " + toDisplayString(attrDesc[attrx.name]), 1)
2809
+ ]),
2810
+ _: 2
2811
+ }, 1024)
2812
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2813
+ createTextVNode(toDisplayString(attrx.name), 1)
2814
+ ], 64))
2815
+ ]),
2816
+ _: 2
2817
+ }, 1032, ["onClick"]),
2818
+ createVNode(unref(NTd), null, {
2819
+ default: withCtx(() => [
2820
+ attrx.name == "id" ? (openBlock(), createBlock(unref(NEllipsis), {
2821
+ key: 0,
2822
+ style: { "width": "180px", "min-width": "max(12vw, 180px)", "direction": "rtl", "text-align": "left" }
2823
+ }, {
2824
+ default: withCtx(() => [
2825
+ createTextVNode(toDisplayString(attrx.value), 1)
2826
+ ]),
2827
+ _: 2
2828
+ }, 1024)) : (openBlock(), createBlock(unref(NEllipsis), {
2829
+ key: 1,
2830
+ style: { "width": "180px", "min-width": "max(12vw, 180px)" }
2831
+ }, {
2832
+ default: withCtx(() => [
2833
+ createTextVNode(toDisplayString(attrx.value), 1)
2834
+ ]),
2835
+ _: 2
2836
+ }, 1024))
2837
+ ]),
2838
+ _: 2
2839
+ }, 1024)
2840
+ ]),
2841
+ _: 2
2842
+ }, 1024);
2843
+ }), 128))
2844
+ ]),
2845
+ _: 1
2846
+ })
2847
+ ]),
2848
+ _: 2
2849
+ }, 1024)
2850
+ ]),
2851
+ _: 1
2852
+ });
2853
+ };
2854
+ }
2855
+ });
2856
+ const _hoisted_1$3 = {
2857
+ flex: "",
2858
+ "flex-col": "",
2859
+ relative: "",
2860
+ "h-full": ""
2861
+ };
2862
+ const _hoisted_2$1 = ["src"];
2863
+ const _hoisted_3$1 = /* @__PURE__ */ createBaseVNode("div", {
2864
+ absolute: "",
2865
+ "left-0": "",
2866
+ "top-0": "",
2867
+ "bottom-0": "",
2868
+ "right-0": "",
2869
+ "b-solid": "",
2870
+ "b-1px": "",
2871
+ "b-red": ""
2872
+ }, null, -1);
2873
+ const _hoisted_4$1 = [
2874
+ _hoisted_3$1
2875
+ ];
2876
+ const _hoisted_5$1 = {
2877
+ class: "left-[calc(100%+4px)]",
2878
+ absolute: "",
2879
+ "top-0": "",
2880
+ "overflow-hidden": "",
2881
+ "z-1": "",
2882
+ "bg-white": "",
2883
+ "h-200px": "",
2884
+ "w-200px": "",
2885
+ "border-1px": "",
2886
+ "border-indigo-600": "",
2887
+ "border-dashed": ""
2888
+ };
2889
+ const _hoisted_6$1 = ["src"];
2890
+ const _hoisted_7$1 = {
2891
+ absolute: "",
2892
+ "left-2px": "",
2893
+ "top-2px": "",
2894
+ class: "leading-[1]",
2895
+ style: { "background-color": "rgba(256, 256, 256, 0.7)" }
2896
+ };
2897
+ const _hoisted_8$1 = /* @__PURE__ */ createBaseVNode("div", {
2898
+ class: "top-[calc(50%-1px)]",
2899
+ absolute: "",
2900
+ "left-0": "",
2901
+ "right-0": "",
2902
+ "h-1px": "",
2903
+ "bg-repeat-x": "",
2904
+ "mix-blend-difference": "",
2905
+ style: { "background": "linear-gradient(\n to left,\n transparent 0%,\n transparent 50%,\n #fff 50%,\n #fff 100%\n )", "background-size": "10px 1px" }
2906
+ }, null, -1);
2907
+ const _hoisted_9$1 = /* @__PURE__ */ createBaseVNode("div", {
2908
+ class: "left-[calc(50%-1px)]",
2909
+ absolute: "",
2910
+ "top-0": "",
2911
+ "bottom-0": "",
2912
+ "w-1px": "",
2913
+ "bg-repeat-y": "",
2914
+ "mix-blend-difference": "",
2915
+ style: { "background": "linear-gradient(\n to top,\n transparent 0%,\n transparent 50%,\n #fff 50%,\n #fff 100%\n )", "background-size": "1px 10px" }
2916
+ }, null, -1);
2917
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2918
+ __name: "ScreenshotCard",
2919
+ props: {
2920
+ url: {},
2921
+ snapshot: {},
2922
+ rootNode: {},
2923
+ focusNode: {},
2924
+ onUpdateFocusNode: { type: Function, default: () => () => {
2925
+ } }
2926
+ },
2927
+ setup(__props) {
2928
+ const props = __props;
2929
+ const imgRef = shallowRef();
2930
+ const clickEvRef = shallowRef();
2931
+ watchEffect(() => {
2932
+ if (!props.rootNode)
2933
+ return;
2934
+ const ev = clickEvRef.value;
2935
+ const img = imgRef.value;
2936
+ if (!ev || !img) {
2937
+ return;
2938
+ }
2939
+ const imgRect = img.getBoundingClientRect();
2940
+ const innerHeight = imgRect.width / img.naturalWidth * img.naturalHeight;
2941
+ const offsetTop = (imgRect.height - innerHeight) / 2;
2942
+ const ox = (ev.clientX - imgRect.left) / imgRect.width * img.naturalWidth;
2943
+ const oy = (ev.clientY - imgRect.top - offsetTop) / innerHeight * img.naturalHeight;
2944
+ const childNode = findNodeByXy(props.snapshot.nodes, ox, oy);
2945
+ if (childNode) {
2946
+ props.onUpdateFocusNode(childNode);
2947
+ }
2948
+ });
2949
+ const percent = (n) => {
2950
+ return `${n * 100}%`;
2951
+ };
2952
+ const positionStyle = computed(() => {
2953
+ var _a;
2954
+ const img = imgRef.value;
2955
+ const attr = (_a = props.focusNode) == null ? void 0 : _a.attr;
2956
+ if (!props.focusNode || !img || !attr) {
2957
+ return ``;
2958
+ }
2959
+ const imgRect = img.getBoundingClientRect();
2960
+ const innerHeight = imgRect.width / img.naturalWidth * img.naturalHeight;
2961
+ return {
2962
+ left: `calc(${percent(attr.left / img.naturalWidth)} - 2px)`,
2963
+ width: `calc(${percent(
2964
+ (attr.right - attr.left) / img.naturalWidth
2965
+ )} + 2px)`,
2966
+ top: `calc(${percent(
2967
+ (attr.top / img.naturalHeight * innerHeight + (imgRect.height - innerHeight) / 2) / imgRect.height
2968
+ )} - 2px)`,
2969
+ height: `calc(${percent(
2970
+ (attr.bottom - attr.top) / img.naturalHeight * innerHeight / imgRect.height
2971
+ )} + 2px)`
2972
+ };
2973
+ });
2974
+ const imgHover = shallowRef(false);
2975
+ const hoverPosition = shallowRef({ ox: 0, oy: 0 });
2976
+ const imgMove = (ev) => {
2977
+ const img = imgRef.value;
2978
+ if (!img)
2979
+ return;
2980
+ const imgRect = img.getBoundingClientRect();
2981
+ const innerHeight = imgRect.width / img.naturalWidth * img.naturalHeight;
2982
+ const offsetTop = (imgRect.height - innerHeight) / 2;
2983
+ const ox = (ev.clientX - imgRect.left) / imgRect.width * img.naturalWidth;
2984
+ const oy = (ev.clientY - imgRect.top - offsetTop) / innerHeight * img.naturalHeight;
2985
+ hoverPosition.value = { ox, oy };
2986
+ hoverPositionStyle.value = {
2987
+ left: -(ox - 0.1 * img.naturalWidth) / img.naturalWidth * 1e3 + "px",
2988
+ top: -(oy - 0.1 * img.naturalWidth) / img.naturalWidth * 1e3 + "px"
2989
+ };
2990
+ };
2991
+ const hoverPositionStyle = shallowRef({ left: "0", top: "0" });
2992
+ return (_ctx, _cache) => {
2993
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
2994
+ createBaseVNode("img", {
2995
+ ref_key: "imgRef",
2996
+ ref: imgRef,
2997
+ src: _ctx.url,
2998
+ onClick: _cache[0] || (_cache[0] = ($event) => clickEvRef.value = $event),
2999
+ "cursor-crosshair": "",
3000
+ "h-full": "",
3001
+ "object-contain": "",
3002
+ style: { "max-width": "max(35vw, 400px)" },
3003
+ onMouseover: _cache[1] || (_cache[1] = ($event) => imgHover.value = true),
3004
+ onMouseleave: _cache[2] || (_cache[2] = ($event) => imgHover.value = false),
3005
+ onMousemove: imgMove
3006
+ }, null, 40, _hoisted_2$1),
3007
+ createBaseVNode("div", {
3008
+ style: normalizeStyle(positionStyle.value),
3009
+ absolute: "",
3010
+ "pointer-events-none": "",
3011
+ "transition-all-300": "",
3012
+ "b-1px": "",
3013
+ "b-blue": "",
3014
+ "b-solid": ""
3015
+ }, _hoisted_4$1, 4),
3016
+ withDirectives(createBaseVNode("div", _hoisted_5$1, [
3017
+ createBaseVNode("img", {
3018
+ src: _ctx.url,
3019
+ "object-contain": "",
3020
+ absolute: "",
3021
+ "left-0": "",
3022
+ "top-0": "",
3023
+ style: normalizeStyle(hoverPositionStyle.value),
3024
+ "w-1000px": ""
3025
+ }, null, 12, _hoisted_6$1),
3026
+ createBaseVNode("div", _hoisted_7$1, toDisplayString(`${hoverPosition.value.ox.toFixed(0)},${hoverPosition.value.oy.toFixed(0)}`), 1),
3027
+ _hoisted_8$1,
3028
+ _hoisted_9$1
3029
+ ], 512), [
3030
+ [vShow, imgHover.value]
3031
+ ])
3032
+ ]);
3033
+ };
3034
+ }
3035
+ });
3036
+ const _hoisted_1$2 = {
3037
+ "w-480px": "",
3038
+ "bg-white": "",
3039
+ "b-1px": "",
3040
+ "b-solid": "",
3041
+ "b-gray-200": "",
3042
+ "rounded-4px": "",
3043
+ "p-8px": "",
3044
+ style: { "min-width": "max(25vw, 480px)" }
3045
+ };
3046
+ const _hoisted_2 = {
3047
+ flex: "",
3048
+ "m-b-4px": ""
3049
+ };
3050
+ const _hoisted_3 = /* @__PURE__ */ createBaseVNode("svg", {
3051
+ xmlns: "http://www.w3.org/2000/svg",
3052
+ "xmlns:xlink": "http://www.w3.org/1999/xlink",
3053
+ viewBox: "0 0 32 32"
3054
+ }, [
3055
+ /* @__PURE__ */ createBaseVNode("path", {
3056
+ d: "M29 27.586l-7.552-7.552a11.018 11.018 0 1 0-1.414 1.414L27.586 29zM4 13a9 9 0 1 1 9 9a9.01 9.01 0 0 1-9-9z",
3057
+ fill: "currentColor"
3058
+ })
3059
+ ], -1);
3060
+ const _hoisted_4 = /* @__PURE__ */ createBaseVNode("div", { "p-5px": "" }, null, -1);
3061
+ const _hoisted_5 = {
3062
+ key: 0,
3063
+ underline: "",
3064
+ "decoration-1": "",
3065
+ "m-r-4px": "",
3066
+ title: "查询数量"
3067
+ };
3068
+ const _hoisted_6 = ["title"];
3069
+ const _hoisted_7 = /* @__PURE__ */ createBaseVNode("svg", { viewBox: "0 0 24 24" }, [
3070
+ /* @__PURE__ */ createBaseVNode("path", {
3071
+ d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",
3072
+ fill: "currentColor"
3073
+ })
3074
+ ], -1);
3075
+ const _hoisted_8 = /* @__PURE__ */ createBaseVNode("div", { "p-l-8px": "" }, null, -1);
3076
+ const _hoisted_9 = /* @__PURE__ */ createBaseVNode("svg", { viewBox: "0 0 24 24" }, [
3077
+ /* @__PURE__ */ createBaseVNode("g", { fill: "none" }, [
3078
+ /* @__PURE__ */ createBaseVNode("path", {
3079
+ d: "M12 1.75a3.25 3.25 0 0 1 3.245 3.066L15.25 5h5.25a.75.75 0 0 1 .102 1.493L20.5 6.5h-.796l-1.28 13.02a2.75 2.75 0 0 1-2.561 2.474l-.176.006H8.313a2.75 2.75 0 0 1-2.714-2.307l-.023-.174L4.295 6.5H3.5a.75.75 0 0 1-.743-.648L2.75 5.75a.75.75 0 0 1 .648-.743L3.5 5h5.25A3.25 3.25 0 0 1 12 1.75zm6.197 4.75H5.802l1.267 12.872a1.25 1.25 0 0 0 1.117 1.122l.127.006h7.374c.6 0 1.109-.425 1.225-1.002l.02-.126L18.196 6.5zM13.75 9.25a.75.75 0 0 1 .743.648L14.5 10v7a.75.75 0 0 1-1.493.102L13 17v-7a.75.75 0 0 1 .75-.75zm-3.5 0a.75.75 0 0 1 .743.648L11 10v7a.75.75 0 0 1-1.493.102L9.5 17v-7a.75.75 0 0 1 .75-.75zm1.75-6a1.75 1.75 0 0 0-1.744 1.606L10.25 5h3.5A1.75 1.75 0 0 0 12 3.25z",
3080
+ fill: "currentColor"
3081
+ })
3082
+ ])
3083
+ ], -1);
3084
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3085
+ __name: "SearchCard",
3086
+ props: {
3087
+ snapshot: {},
3088
+ rootNode: {},
3089
+ onUpdateFocusNode: { type: Function, default: () => () => {
3090
+ } }
3091
+ },
3092
+ setup(__props) {
3093
+ const props = __props;
3094
+ const selectorText = shallowRef(``);
3095
+ const selectorResults = shallowReactive([]);
3096
+ const searchBySelector = errorTry(() => {
3097
+ if (!props.rootNode) {
3098
+ message.error(`根节点不存在`);
3099
+ return;
3100
+ }
3101
+ const text = selectorText.value.trim();
3102
+ if (!text)
3103
+ return;
3104
+ if (enableSearchBySelector.value) {
3105
+ const selector = errorWrap(() => parseSelector(text), `选择器非法`);
3106
+ if (selectorResults.find(
3107
+ (s) => typeof s.selector == "object" && s.selector.toString() == selector.toString()
3108
+ )) {
3109
+ message.warning(`不可重复选择`);
3110
+ return;
3111
+ }
3112
+ const results = selector.querySelectorAll(props.rootNode);
3113
+ if (results.length == 0) {
3114
+ message.success(`没有选择到节点`);
3115
+ return;
3116
+ }
3117
+ message.success(`选择到 ${results.length} 个节点`);
3118
+ selectorResults.unshift({ selector, results });
3119
+ } else {
3120
+ if (selectorResults.find(
3121
+ (s) => typeof s.selector == "string" && s.selector.toString() == text
3122
+ )) {
3123
+ message.warning(`不可重复选择`);
3124
+ return;
3125
+ }
3126
+ const results = [];
3127
+ const stack = [props.rootNode];
3128
+ while (stack.length > 0) {
3129
+ const n = stack.pop();
3130
+ if (getNodeLabel(n).includes(text)) {
3131
+ results.push(n);
3132
+ }
3133
+ stack.push(...[...n.children].reverse());
3134
+ }
3135
+ if (results.length == 0) {
3136
+ message.success(`没有搜索到节点`);
3137
+ return;
3138
+ }
3139
+ message.success(`搜索到 ${results.length} 个节点`);
3140
+ selectorResults.unshift({ selector: text, results });
3141
+ }
3142
+ });
3143
+ const generateRules = errorTry(async (selector) => {
3144
+ let jpgUrl = githubJpgStorage[props.snapshot.id];
3145
+ if (jpgUrl) {
3146
+ jpgUrl = githubUrlToSelfUrl(jpgUrl);
3147
+ }
3148
+ let zipUrl = githubZipStorage[props.snapshot.id];
3149
+ if (zipUrl) {
3150
+ zipUrl = githubUrlToSelfUrl(zipUrl);
3151
+ }
3152
+ const rule = {
3153
+ id: props.snapshot.appId,
3154
+ name: props.snapshot.appName,
3155
+ groups: [
3156
+ {
3157
+ key: 1,
3158
+ name: `[ChangeMe]规则名称-${dayjs().format("YYYY-MM-DD HH:mm:ss")}`,
3159
+ desc: `[ChangeMe]本规则由GKD网页端审查工具生成`,
3160
+ rules: [
3161
+ {
3162
+ activityIds: props.snapshot.activityId,
3163
+ matches: selector.toString(),
3164
+ exampleUrls: jpgUrl,
3165
+ snapshotUrls: zipUrl
3166
+ }
3167
+ ]
3168
+ }
3169
+ ]
3170
+ };
3171
+ copy(lib.stringify(rule, void 0, 2));
3172
+ });
3173
+ const enableSearchBySelector = shallowRef(true);
3174
+ const _1vw = window.innerWidth / 100;
3175
+ return (_ctx, _cache) => {
3176
+ return openBlock(), createBlock(_sfc_main$5, {
3177
+ initialValue: { top: 75, right: Math.max(315, 12 * _1vw + 135) },
3178
+ class: "z-1"
3179
+ }, {
3180
+ default: withCtx(({ onRef }) => [
3181
+ createBaseVNode("div", _hoisted_1$2, [
3182
+ createBaseVNode("div", _hoisted_2, [
3183
+ createVNode(unref(NRadioGroup), {
3184
+ value: enableSearchBySelector.value,
3185
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => enableSearchBySelector.value = $event)
3186
+ }, {
3187
+ default: withCtx(() => [
3188
+ createVNode(unref(NSpace), null, {
3189
+ default: withCtx(() => [
3190
+ createVNode(unref(NRadio), { value: false }, {
3191
+ default: withCtx(() => [
3192
+ createTextVNode(" 字符搜索 ")
3193
+ ]),
3194
+ _: 1
3195
+ }),
3196
+ createVNode(unref(NRadio), { value: true }, {
3197
+ default: withCtx(() => [
3198
+ createTextVNode(" 选择器查询 ")
3199
+ ]),
3200
+ _: 1
3201
+ })
3202
+ ]),
3203
+ _: 1
3204
+ })
3205
+ ]),
3206
+ _: 1
3207
+ }, 8, ["value"]),
3208
+ createBaseVNode("div", {
3209
+ "flex-1": "",
3210
+ "cursor-move": "",
3211
+ ref: onRef
3212
+ }, null, 512)
3213
+ ]),
3214
+ createVNode(unref(NInputGroup), null, {
3215
+ default: withCtx(() => [
3216
+ createVNode(unref(NInput), {
3217
+ value: selectorText.value,
3218
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => selectorText.value = $event),
3219
+ placeholder: enableSearchBySelector.value ? `请输入选择器` : `请输入字符`,
3220
+ onKeyup: withKeys(unref(searchBySelector), ["enter"]),
3221
+ inputProps: { class: "gkd_code" }
3222
+ }, null, 8, ["value", "placeholder", "onKeyup"]),
3223
+ createVNode(unref(NButton), { onClick: unref(searchBySelector) }, {
3224
+ icon: withCtx(() => [
3225
+ createVNode(unref(NIcon), null, {
3226
+ default: withCtx(() => [
3227
+ _hoisted_3
3228
+ ]),
3229
+ _: 1
3230
+ })
3231
+ ]),
3232
+ _: 1
3233
+ }, 8, ["onClick"])
3234
+ ]),
3235
+ _: 1
3236
+ }),
3237
+ _hoisted_4,
3238
+ createVNode(unref(NCollapse), null, {
3239
+ default: withCtx(() => [
3240
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(selectorResults), (selectorResult, index) => {
3241
+ return openBlock(), createBlock(unref(NCollapseItem), {
3242
+ key: selectorResult.selector.toString()
3243
+ }, {
3244
+ header: withCtx(() => [
3245
+ selectorResult.results.length > 1 ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(selectorResult.results.length), 1)) : createCommentVNode("", true),
3246
+ createBaseVNode("span", {
3247
+ "break-all": "",
3248
+ title: typeof selectorResult.selector == "object" ? `选择器` : `搜索字符`
3249
+ }, toDisplayString(selectorResult.selector.toString()), 9, _hoisted_6)
3250
+ ]),
3251
+ "header-extra": withCtx(() => [
3252
+ typeof selectorResult.selector == "object" ? (openBlock(), createBlock(unref(NButton), {
3253
+ key: 0,
3254
+ size: "small",
3255
+ onClick: withModifiers(($event) => unref(generateRules)(selectorResult.selector), ["stop"]),
3256
+ title: "复制规则"
3257
+ }, {
3258
+ icon: withCtx(() => [
3259
+ createVNode(unref(NIcon), null, {
3260
+ default: withCtx(() => [
3261
+ _hoisted_7
3262
+ ]),
3263
+ _: 1
3264
+ })
3265
+ ]),
3266
+ _: 2
3267
+ }, 1032, ["onClick"])) : createCommentVNode("", true),
3268
+ _hoisted_8,
3269
+ createVNode(unref(NButton), {
3270
+ size: "small",
3271
+ onClick: withModifiers(($event) => unref(selectorResults).splice(index, 1), ["stop"]),
3272
+ title: "删除记录"
3273
+ }, {
3274
+ icon: withCtx(() => [
3275
+ createVNode(unref(NIcon), null, {
3276
+ default: withCtx(() => [
3277
+ _hoisted_9
3278
+ ]),
3279
+ _: 1
3280
+ })
3281
+ ]),
3282
+ _: 2
3283
+ }, 1032, ["onClick"])
3284
+ ]),
3285
+ default: withCtx(() => [
3286
+ createVNode(unref(NSpace), { style: { "max-height": "400px", "overflow-y": "scroll", "padding-bottom": "10px" } }, {
3287
+ default: withCtx(() => [
3288
+ (openBlock(true), createElementBlock(Fragment, null, renderList(selectorResult.results, (resultNode) => {
3289
+ return openBlock(), createBlock(unref(NButton), {
3290
+ key: resultNode.id,
3291
+ onClick: ($event) => _ctx.onUpdateFocusNode(resultNode),
3292
+ size: "small"
3293
+ }, {
3294
+ default: withCtx(() => [
3295
+ createTextVNode(toDisplayString(unref(getNodeLabel)(resultNode)), 1)
3296
+ ]),
3297
+ _: 2
3298
+ }, 1032, ["onClick"]);
3299
+ }), 128))
3300
+ ]),
3301
+ _: 2
3302
+ }, 1024)
3303
+ ]),
3304
+ _: 2
3305
+ }, 1024);
3306
+ }), 128))
3307
+ ]),
3308
+ _: 1
3309
+ })
3310
+ ])
3311
+ ]),
3312
+ _: 1
3313
+ }, 8, ["initialValue"]);
3314
+ };
3315
+ }
3316
+ });
3317
+ const _hoisted_1$1 = {
3318
+ flex: "",
3319
+ "flex-col": ""
3320
+ };
3321
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3322
+ __name: "WindowCard",
3323
+ props: {
3324
+ snapshot: {},
3325
+ rootNode: {},
3326
+ focusNode: {},
3327
+ onUpdateFocusNode: {
3328
+ type: Function,
3329
+ default: () => () => {
3330
+ }
3331
+ }
3332
+ },
3333
+ setup(__props) {
3334
+ const props = __props;
3335
+ const defaultExpandedKeys = shallowRef([]);
3336
+ watchEffect(async () => {
3337
+ var _a;
3338
+ if (!props.focusNode)
3339
+ return;
3340
+ const key = props.focusNode.id;
3341
+ let n = props.focusNode.parent;
3342
+ if (!n) {
3343
+ return;
3344
+ }
3345
+ const s = new Set(defaultExpandedKeys.value);
3346
+ while (n) {
3347
+ s.add(n.id);
3348
+ n = n.parent;
3349
+ }
3350
+ if (s.size == defaultExpandedKeys.value.length) {
3351
+ return;
3352
+ }
3353
+ defaultExpandedKeys.value = [...s];
3354
+ await nextTick();
3355
+ (_a = treeRef.value) == null ? void 0 : _a.scrollTo({
3356
+ key
3357
+ });
3358
+ });
3359
+ const treeRef = shallowRef();
3360
+ const updateCheckedKeys = (keys, options, meta) => {
3361
+ };
3362
+ const treeFilter = (pattern, node) => {
3363
+ var _a;
3364
+ return node.id === ((_a = props.focusNode) == null ? void 0 : _a.id);
3365
+ };
3366
+ const treeNodeProps = (info) => {
3367
+ var _a;
3368
+ return {
3369
+ onClick: () => {
3370
+ props.onUpdateFocusNode(info.option);
3371
+ },
3372
+ style: {
3373
+ color: info.option.id == ((_a = props.focusNode) == null ? void 0 : _a.id) ? `#00F` : void 0
3374
+ }
3375
+ };
3376
+ };
3377
+ const renderLabel = (info) => {
3378
+ return getNodeLabel(info.option);
3379
+ };
3380
+ return (_ctx, _cache) => {
3381
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [createVNode(unref(NTable), {
3382
+ size: "small",
3383
+ striped: "",
3384
+ singleLine: false,
3385
+ class: "table-fixed",
3386
+ themeOverrides: {
3387
+ thPaddingSmall: "2px 4px",
3388
+ tdPaddingSmall: "2px 4px"
3389
+ }
3390
+ }, {
3391
+ default: withCtx(() => [createVNode(unref(NThead), null, {
3392
+ default: withCtx(() => [createVNode(unref(NTr), null, {
3393
+ default: withCtx(() => [createVNode(unref(NTh), {
3394
+ class: "w-140px"
3395
+ }, {
3396
+ default: withCtx(() => [createTextVNode(" Device ")]),
3397
+ _: 1
3398
+ }), createVNode(unref(NTh), {
3399
+ class: "w-100px"
3400
+ }, {
3401
+ default: withCtx(() => [createTextVNode(" Name ")]),
3402
+ _: 1
3403
+ }), createVNode(unref(NTh), {
3404
+ class: "w-100px"
3405
+ }, {
3406
+ default: withCtx(() => [createTextVNode(" VersionName ")]),
3407
+ _: 1
3408
+ }), createVNode(unref(NTh), {
3409
+ class: "w-100px"
3410
+ }, {
3411
+ default: withCtx(() => [createTextVNode(" VersionCode ")]),
3412
+ _: 1
3413
+ }), createVNode(unref(NTh), {
3414
+ class: "w-150px"
3415
+ }, {
3416
+ default: withCtx(() => [createTextVNode(" AppId ")]),
3417
+ _: 1
3418
+ }), createVNode(unref(NTh), null, {
3419
+ default: withCtx(() => [createTextVNode(" ActivityId ")]),
3420
+ _: 1
3421
+ }), createVNode(unref(NTh), {
3422
+ class: "w-175px"
3423
+ }, {
3424
+ default: withCtx(() => [createTextVNode(" 操作 ")]),
3425
+ _: 1
3426
+ })]),
3427
+ _: 1
3428
+ })]),
3429
+ _: 1
3430
+ }), createVNode(unref(NTbody), null, {
3431
+ default: withCtx(() => [createVNode(unref(NTr), null, {
3432
+ default: withCtx(() => [createVNode(unref(NTd), {
3433
+ class: "whitespace-nowrap"
3434
+ }, {
3435
+ default: withCtx(() => [createTextVNode(toDisplayString(`${unref(getDevice)(_ctx.snapshot).manufacturer} Android ${unref(getDevice)(_ctx.snapshot).release || ``}`), 1)]),
3436
+ _: 1
3437
+ }), createVNode(unref(NTd), {
3438
+ class: "whitespace-nowrap",
3439
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(copy)(_ctx.snapshot.appName))
3440
+ }, {
3441
+ default: withCtx(() => [createVNode(unref(NEllipsis), null, {
3442
+ default: withCtx(() => [createTextVNode(toDisplayString(_ctx.snapshot.appName), 1)]),
3443
+ _: 1
3444
+ })]),
3445
+ _: 1
3446
+ }), createVNode(unref(NTd), {
3447
+ class: "whitespace-nowrap",
3448
+ onClick: _cache[1] || (_cache[1] = ($event) => unref(copy)(_ctx.snapshot.appVersionName))
3449
+ }, {
3450
+ default: withCtx(() => [createVNode(unref(NEllipsis), null, {
3451
+ default: withCtx(() => [createTextVNode(toDisplayString(_ctx.snapshot.appVersionName), 1)]),
3452
+ _: 1
3453
+ })]),
3454
+ _: 1
3455
+ }), createVNode(unref(NTd), {
3456
+ class: "whitespace-nowrap",
3457
+ onClick: _cache[2] || (_cache[2] = ($event) => unref(copy)(_ctx.snapshot.appVersionCode.toString()))
3458
+ }, {
3459
+ default: withCtx(() => [createVNode(unref(NEllipsis), null, {
3460
+ default: withCtx(() => [createTextVNode(toDisplayString(_ctx.snapshot.appVersionCode), 1)]),
3461
+ _: 1
3462
+ })]),
3463
+ _: 1
3464
+ }), createVNode(unref(NTd), {
3465
+ class: "whitespace-nowrap",
3466
+ onClick: _cache[3] || (_cache[3] = ($event) => unref(copy)(_ctx.snapshot.appId))
3467
+ }, {
3468
+ default: withCtx(() => [createVNode(unref(NEllipsis), null, {
3469
+ default: withCtx(() => [createTextVNode(toDisplayString(_ctx.snapshot.appId), 1)]),
3470
+ _: 1
3471
+ })]),
3472
+ _: 1
3473
+ }), createVNode(unref(NTd), {
3474
+ onClick: _cache[4] || (_cache[4] = ($event) => unref(copy)(_ctx.snapshot.activityId)),
3475
+ class: "break-words"
3476
+ }, {
3477
+ default: withCtx(() => [createVNode(unref(NEllipsis), null, {
3478
+ default: withCtx(() => [createTextVNode(toDisplayString(_ctx.snapshot.activityId), 1)]),
3479
+ _: 1
3480
+ })]),
3481
+ _: 1
3482
+ }), createVNode(unref(NTd), null, {
3483
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
3484
+ _: 3
3485
+ })]),
3486
+ _: 3
3487
+ })]),
3488
+ _: 3
3489
+ })]),
3490
+ _: 3
3491
+ }), createVNode(unref(NTree), {
3492
+ ref_key: "treeRef",
3493
+ ref: treeRef,
3494
+ virtualScroll: "",
3495
+ showLine: "",
3496
+ "onUpdate:checkedKeys": updateCheckedKeys,
3497
+ keyField: "id",
3498
+ defaultExpandedKeys: defaultExpandedKeys.value,
3499
+ data: [_ctx.rootNode],
3500
+ filter: treeFilter,
3501
+ nodeProps: treeNodeProps,
3502
+ renderLabel,
3503
+ style: {
3504
+ "--n-border-color": "rgb(239, 239, 245)"
3505
+ }
3506
+ }, null, 8, ["defaultExpandedKeys", "data", "filter", "nodeProps", "renderLabel"])]);
3507
+ };
3508
+ }
3509
+ });
3510
+ const _hoisted_1 = {
3511
+ "h-full": "",
3512
+ flex: "",
3513
+ "gap-5px": "",
3514
+ "p-5px": "",
3515
+ "box-border": ""
3516
+ };
3517
+ const _sfc_main = /* @__PURE__ */ defineComponent({
3518
+ __name: "SnapshotPage",
3519
+ setup(__props) {
3520
+ const route = useRoute();
3521
+ const router = useRouter();
3522
+ const title = useTitle();
3523
+ const snapshotId = computed(() => String(route.params.snapshotId || ``));
3524
+ const showSize = computed(() => {
3525
+ const n = Number(route.query.showSize || ``);
3526
+ if (!Number.isSafeInteger(n) || n <= 0) {
3527
+ return 2e3;
3528
+ }
3529
+ return n;
3530
+ });
3531
+ const screenshotUrl = shallowRef(``);
3532
+ const snapshot = shallowRef();
3533
+ watchEffect(async () => {
3534
+ const localSnapshot = await snapshotStorage.getItem(snapshotId.value);
3535
+ if (!localSnapshot) {
3536
+ message.error(`快照数据缺失`);
3537
+ return;
3538
+ }
3539
+ if (gmOk()) {
3540
+ setTimeout(async () => {
3541
+ exportSnapshotAsJpgUrl(localSnapshot);
3542
+ if (!githubZipStorage[localSnapshot.id]) {
3543
+ exportSnapshotAsZipUrl(
3544
+ await snapshotStorage.getItem(snapshotId.value)
3545
+ );
3546
+ }
3547
+ }, 1e3);
3548
+ }
3549
+ if (localSnapshot.nodes.length > showSize.value) {
3550
+ message.warning(
3551
+ `当前展示节点数量为${showSize.value}
3552
+ 之后的${localSnapshot.nodes.length - showSize.value}个节点将被丢弃
3553
+ 使用showSize查询参数可以修改展示数量`
3554
+ );
3555
+ localSnapshot.nodes = localSnapshot.nodes.slice(0, showSize.value);
3556
+ }
3557
+ const bf = await screenshotStorage.getItem(snapshotId.value);
3558
+ if (!bf) {
3559
+ message.create(`截屏数据缺失`);
3560
+ return;
3561
+ }
3562
+ screenshotUrl.value = URL.createObjectURL(
3563
+ new Blob([bf], {
3564
+ type: "image/png"
3565
+ })
3566
+ );
3567
+ snapshot.value = localSnapshot;
3568
+ rootNode.value = listToTree(localSnapshot.nodes);
3569
+ title.value = "快照-" + localSnapshot.appName || localSnapshot.appId;
3570
+ await delay(500);
3571
+ if (!focusNode.value) {
3572
+ focusNode.value = rootNode.value;
3573
+ }
3574
+ });
3575
+ const rootNode = shallowRef();
3576
+ const focusNode = shallowRef();
3577
+ const onDelete = async () => {
3578
+ message.success(`删除成功,即将回到首页`);
3579
+ await delay(2e3);
3580
+ router.replace({
3581
+ path: `/`
3582
+ });
3583
+ };
3584
+ return (_ctx, _cache) => {
3585
+ return openBlock(), createElementBlock("div", _hoisted_1, [
3586
+ screenshotUrl.value && snapshot.value ? (openBlock(), createBlock(_sfc_main$3, {
3587
+ key: 0,
3588
+ url: screenshotUrl.value,
3589
+ snapshot: snapshot.value,
3590
+ rootNode: rootNode.value,
3591
+ focusNode: focusNode.value,
3592
+ onUpdateFocusNode: _cache[0] || (_cache[0] = ($event) => focusNode.value = $event)
3593
+ }, null, 8, ["url", "snapshot", "rootNode", "focusNode"])) : createCommentVNode("", true),
3594
+ snapshot.value && rootNode.value ? (openBlock(), createBlock(_sfc_main$1, {
3595
+ key: 1,
3596
+ rootNode: rootNode.value,
3597
+ snapshot: snapshot.value,
3598
+ focusNode: focusNode.value,
3599
+ onUpdateFocusNode: _cache[1] || (_cache[1] = ($event) => focusNode.value = $event),
3600
+ class: "flex-1"
3601
+ }, {
3602
+ default: withCtx(() => [
3603
+ snapshot.value ? (openBlock(), createBlock(_sfc_main$6, {
3604
+ key: 0,
3605
+ snapshot: snapshot.value,
3606
+ onDelete,
3607
+ showPreview: false
3608
+ }, null, 8, ["snapshot"])) : createCommentVNode("", true)
3609
+ ]),
3610
+ _: 1
3611
+ }, 8, ["rootNode", "snapshot", "focusNode"])) : createCommentVNode("", true),
3612
+ focusNode.value ? (openBlock(), createBlock(_sfc_main$4, {
3613
+ key: 2,
3614
+ focusNode: focusNode.value
3615
+ }, null, 8, ["focusNode"])) : createCommentVNode("", true),
3616
+ rootNode.value && snapshot.value ? (openBlock(), createBlock(_sfc_main$2, {
3617
+ key: 3,
3618
+ snapshot: snapshot.value,
3619
+ rootNode: rootNode.value,
3620
+ onUpdateFocusNode: _cache[2] || (_cache[2] = ($event) => focusNode.value = $event)
3621
+ }, null, 8, ["snapshot", "rootNode"])) : createCommentVNode("", true)
3622
+ ]);
3623
+ };
3624
+ }
3625
+ });
3626
+ export {
3627
+ _sfc_main as default
3628
+ };