@univerjs/sheets-table 0.16.1 → 0.17.0-insiders.20260318-d69dc16

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 (47) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/es/facade.js +1 -165
  4. package/lib/es/index.js +1 -2919
  5. package/lib/facade.js +1 -165
  6. package/lib/index.js +1 -2919
  7. package/lib/types/commands/commands/add-sheet-table.command.d.ts +17 -2
  8. package/lib/types/commands/commands/add-table-theme.command.d.ts +17 -2
  9. package/lib/types/commands/commands/delete-sheet-table.command.d.ts +17 -2
  10. package/lib/types/commands/commands/remove-table-theme.command.d.ts +16 -1
  11. package/lib/types/commands/commands/set-sheet-table.command.d.ts +17 -2
  12. package/lib/types/commands/commands/set-table-filter.command.d.ts +17 -2
  13. package/lib/types/commands/commands/sheet-table-row-col.command.d.ts +16 -1
  14. package/lib/types/commands/mutations/add-sheet-table.mutation.d.ts +17 -2
  15. package/lib/types/commands/mutations/delete-sheet-table.mutation.d.ts +16 -1
  16. package/lib/types/commands/mutations/set-sheet-table.mutation.d.ts +17 -2
  17. package/lib/types/commands/mutations/set-table-filter.mutation.d.ts +17 -2
  18. package/lib/types/config/config.d.ts +34 -0
  19. package/lib/types/controllers/sheet-table-formula.controller.d.ts +15 -0
  20. package/lib/types/controllers/sheet-table-range.controller.d.ts +15 -0
  21. package/lib/types/controllers/sheet-table-ref-range.controller.d.ts +15 -0
  22. package/lib/types/controllers/sheet-table-theme.controller.d.ts +15 -0
  23. package/lib/types/controllers/sheets-table.controller.d.ts +18 -2
  24. package/lib/types/controllers/table-filter.controller.d.ts +16 -1
  25. package/lib/types/controllers/table-theme.factory.d.ts +45 -30
  26. package/lib/types/facade/f-enum.d.ts +15 -0
  27. package/lib/types/facade/f-workbook.d.ts +16 -1
  28. package/lib/types/facade/f-worksheet.d.ts +17 -2
  29. package/lib/types/index.d.ts +14 -14
  30. package/lib/types/model/filter-util/condition.d.ts +19 -3
  31. package/lib/types/model/filter-util/date-filter-util.d.ts +16 -1
  32. package/lib/types/model/filter-util/manual.d.ts +16 -1
  33. package/lib/types/model/filter-util/number-filter-util.d.ts +16 -1
  34. package/lib/types/model/filter-util/text-filter-util.d.ts +16 -1
  35. package/lib/types/model/table-column.d.ts +17 -2
  36. package/lib/types/model/table-filter.d.ts +19 -3
  37. package/lib/types/model/table-manager.d.ts +25 -9
  38. package/lib/types/model/table.d.ts +17 -2
  39. package/lib/types/plugin.d.ts +18 -1
  40. package/lib/types/services/table-service.d.ts +18 -2
  41. package/lib/types/types/type.d.ts +17 -2
  42. package/lib/types/util.d.ts +19 -4
  43. package/lib/umd/facade.js +1 -1
  44. package/lib/umd/index.js +1 -1
  45. package/package.json +9 -8
  46. package/LICENSE +0 -176
  47. package/lib/types/controllers/config.schema.d.ts +0 -19
package/lib/es/index.js CHANGED
@@ -1,2919 +1 @@
1
- var ot = Object.defineProperty;
2
- var it = (t, e, n) => e in t ? ot(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var b = (t, e, n) => it(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { CellValueType as J, UniverInstanceType as j, BorderStyleTypes as lt, createREGEXFromWildChar as Z, generateRandomId as B, IUniverInstanceService as A, Inject as C, LocaleService as be, Disposable as H, CommandType as y, IUndoRedoService as L, ICommandService as D, customNameCharacterCheck as Be, sequenceExecute as E, ILogService as We, IResourceManagerService as ut, Rectangle as _e, RTree as ct, InterceptorEffectEnum as dt, Injector as He, IConfigService as Ve, Plugin as ht, merge as gt, registerDependencies as mt, touchDependencies as Me } from "@univerjs/core";
5
- import { IDefinedNamesService as Pe, RemoveSuperTableMutation as ve, SetSuperTableMutation as bt } from "@univerjs/engine-formula";
6
- import { getSheetCommandTarget as $, SheetInterceptorService as Re, INTERCEPTOR_POINT as qe, RemoveSheetCommand as wt, CopySheetCommand as ft, AddRangeThemeMutation as Je, RemoveRangeThemeMutation as ke, SheetRangeThemeModel as Qe, SheetsSelectionsService as we, InsertRowMutation as Ye, RemoveRowMutation as Ge, getMoveRangeUndoRedoMutations as fe, InsertColMutation as je, RemoveColMutation as ze, IExclusiveRangeService as pt, RefRangeService as St, RemoveColCommand as _t, RemoveRowCommand as Ct, InsertColCommand as Rt, InsertRowCommand as Tt, SheetRangeThemeService as It, RangeThemeStyle as Mt, ZebraCrossingCacheController as vt } from "@univerjs/sheets";
7
- import { Subject as Y, BehaviorSubject as Ke, filter as pe, switchMap as Fe } from "rxjs";
8
- var M = /* @__PURE__ */ ((t) => (t.Insert = "insert", t.Delete = "delete", t))(M || {}), N = /* @__PURE__ */ ((t) => (t.Row = "row", t.Col = "column", t))(N || {}), Xe = /* @__PURE__ */ ((t) => (t.None = "none", t.String = "string", t.Number = "number", t.Date = "date", t.Bool = "bool", t.Checkbox = "checkbox", t.List = "list", t))(Xe || {}), ne = /* @__PURE__ */ ((t) => (t.manual = "manual", t.condition = "condition", t))(ne || {}), U = /* @__PURE__ */ ((t) => (t.Date = "date", t.Number = "number", t.String = "string", t.Logic = "logic", t))(U || {}), F = /* @__PURE__ */ ((t) => (t.Equal = "equal", t.NotEqual = "notEqual", t.GreaterThan = "greaterThan", t.GreaterThanOrEqual = "greaterThanOrEqual", t.LessThan = "lessThan", t.LessThanOrEqual = "lessThanOrEqual", t.Between = "between", t.NotBetween = "notBetween", t.Above = "above", t.Below = "below", t.TopN = "topN", t))(F || {}), P = /* @__PURE__ */ ((t) => (t.Equal = "equal", t.NotEqual = "notEqual", t.Contains = "contains", t.NotContains = "notContains", t.StartsWith = "startsWith", t.EndsWith = "endsWith", t))(P || {}), m = /* @__PURE__ */ ((t) => (t.Equal = "equal", t.NotEqual = "notEqual", t.After = "after", t.AfterOrEqual = "afterOrEqual", t.Before = "before", t.BeforeOrEqual = "beforeOrEqual", t.Between = "between", t.NotBetween = "notBetween", t.Today = "today", t.Yesterday = "yesterday", t.Tomorrow = "tomorrow", t.ThisWeek = "thisWeek", t.LastWeek = "lastWeek", t.NextWeek = "nextWeek", t.ThisMonth = "thisMonth", t.LastMonth = "lastMonth", t.NextMonth = "nextMonth", t.ThisQuarter = "thisQuarter", t.LastQuarter = "lastQuarter", t.NextQuarter = "nextQuarter", t.ThisYear = "thisYear", t.LastYear = "lastYear", t.NextYear = "nextYear", t.YearToDate = "yearToDate", t.Quarter = "quarter", t.Month = "month", t.M1 = "m1", t.M2 = "m2", t.M3 = "m3", t.M4 = "m4", t.M5 = "m5", t.M6 = "m6", t.M7 = "m7", t.M8 = "m8", t.M9 = "m9", t.M10 = "m10", t.M11 = "m11", t.M12 = "m12", t.Q1 = "q1", t.Q2 = "q2", t.Q3 = "q3", t.Q4 = "q4", t))(m || {}), q = /* @__PURE__ */ ((t) => (t[t.FilteredSortNone = 1] = "FilteredSortNone", t[t.FilteredSortAsc = 2] = "FilteredSortAsc", t[t.FilteredSortDesc = 3] = "FilteredSortDesc", t[t.FilterNoneSortNone = 4] = "FilterNoneSortNone", t[t.FilterNoneSortAsc = 5] = "FilterNoneSortAsc", t[t.FilterNoneSortDesc = 6] = "FilterNoneSortDesc", t))(q || {}), G = /* @__PURE__ */ ((t) => (t.Asc = "asc", t.Desc = "desc", t.None = "none", t))(G || {});
9
- function te(t, e) {
10
- return `${e} ${t}`;
11
- }
12
- const Ne = "TRUE", ye = "FALSE", Ft = (t) => {
13
- var n;
14
- return ((n = t.body) == null ? void 0 : n.dataStream.replace(/\r\n$/, "")) || "";
15
- };
16
- function Ze(t) {
17
- if (t) {
18
- const { v: e, t: n, p: s } = t;
19
- return s ? Ft(s) : (n === J.FORCE_STRING || n === J.STRING) && e !== void 0 && e !== null ? String(e) : n === J.BOOLEAN ? e ? Ne : ye : n === J.NUMBER ? String(e) : typeof e === "boolean" ? e ? Ne : ye : e == null ? "" : String(e);
20
- }
21
- return "";
22
- }
23
- function Nt(t, e) {
24
- if (t != null)
25
- switch (e) {
26
- case G.Asc:
27
- return q.FilteredSortAsc;
28
- case G.Desc:
29
- return q.FilteredSortDesc;
30
- default:
31
- return q.FilteredSortNone;
32
- }
33
- else
34
- switch (e) {
35
- case G.Asc:
36
- return q.FilterNoneSortAsc;
37
- case G.Desc:
38
- return q.FilterNoneSortDesc;
39
- default:
40
- return q.FilterNoneSortNone;
41
- }
42
- }
43
- function yt(t) {
44
- return t ? t.filterType === ne.condition : !1;
45
- }
46
- function gs(t) {
47
- return t ? t.filterType === ne.manual : !1;
48
- }
49
- function et(t, e) {
50
- const { univerInstanceService: n, tableManager: s, definedNamesService: r } = e, a = /* @__PURE__ */ new Set(), o = n == null ? void 0 : n.getUnit(t, j.UNIVER_SHEET);
51
- o && o.getSheets().forEach((i) => {
52
- a.add(i.getName().toLowerCase());
53
- });
54
- const u = s == null ? void 0 : s.getTableList(t);
55
- u && u.length > 0 && u.forEach((i) => {
56
- a.add(i.name.toLowerCase());
57
- });
58
- const l = r == null ? void 0 : r.getDefinedNameMap(t);
59
- return l && Object.values(l).forEach((i) => {
60
- a.add(i.name.toLowerCase());
61
- }), a;
62
- }
63
- const x = {
64
- s: lt.THIN,
65
- cl: {
66
- rgb: "rgb(95, 101, 116)"
67
- }
68
- }, tt = "sheets-table.config", De = {}, ms = {
69
- headerRowStyle: {
70
- bd: {
71
- t: x
72
- }
73
- },
74
- headerColumnStyle: {
75
- bd: {
76
- l: x
77
- }
78
- },
79
- lastColumnStyle: {
80
- bd: {
81
- r: x
82
- }
83
- },
84
- lastRowStyle: {
85
- bd: {
86
- b: x
87
- }
88
- }
89
- }, bs = (t, e) => {
90
- if (t === "headerRowStyle") {
91
- if (!e.bd)
92
- return {
93
- ...e,
94
- bd: {
95
- t: x
96
- }
97
- };
98
- } else if (t === "lastRowStyle") {
99
- if (!e.bd)
100
- return {
101
- ...e,
102
- bd: {
103
- b: x
104
- }
105
- };
106
- } else if (t === "lastColumnStyle") {
107
- if (!e.bd)
108
- return {
109
- ...e,
110
- bd: {
111
- r: x
112
- }
113
- };
114
- } else if (t === "headerColumnStyle" && !e.bd)
115
- return {
116
- ...e,
117
- bd: {
118
- l: x
119
- }
120
- };
121
- return e;
122
- }, Dt = [
123
- [["#6280F9", "#FFFFFF", "#BAC6F8", "#D2DAFA"], ["#fff"]],
124
- [["#16BDCA", "#FFFFFF", "#EDFAFA", "#AFECEF"], ["#000"]],
125
- [["#31C48D", "#FFFFFF", "#F3FAF7", "#BCF0DA"], ["#fff"]],
126
- [["#AC94FA", "#FFFFFF", "#F6F5FF", "#EDEBFE"], ["#fff"]],
127
- [["#F17EBB", "#FFFFFF", "#FDF2F8", "#FCE8F3"], ["#fff"]],
128
- [["#F98080", "#FFFFFF", "#FDF2F2", "#FDE8E8"], ["#fff"]]
129
- ], nt = Dt.map((t, e) => {
130
- const [n, s] = t, [r, a, o, u] = n, [l] = s;
131
- return {
132
- name: `table-default-${e}`,
133
- style: {
134
- headerRowStyle: {
135
- bg: {
136
- rgb: r
137
- },
138
- cl: {
139
- rgb: l
140
- },
141
- bd: {
142
- t: x
143
- }
144
- },
145
- headerColumnStyle: {
146
- bd: {
147
- l: x
148
- }
149
- },
150
- firstRowStyle: {
151
- bg: {
152
- rgb: a
153
- }
154
- },
155
- secondRowStyle: {
156
- bg: {
157
- rgb: o
158
- }
159
- },
160
- lastRowStyle: {
161
- bg: {
162
- rgb: u
163
- },
164
- bd: {
165
- b: x
166
- }
167
- },
168
- lastColumnStyle: {
169
- bd: {
170
- r: x
171
- }
172
- }
173
- }
174
- };
175
- });
176
- class z {
177
- constructor(e, n) {
178
- b(this, "dataType");
179
- b(this, "id");
180
- b(this, "displayName");
181
- b(this, "formula");
182
- b(this, "meta");
183
- b(this, "style");
184
- this.id = e, this.displayName = n, this.dataType = Xe.String, this.formula = "", this.meta = {}, this.style = {};
185
- }
186
- getMeta() {
187
- return this.meta;
188
- }
189
- setMeta(e) {
190
- this.meta = e;
191
- }
192
- getDisplayName() {
193
- return this.displayName;
194
- }
195
- toJSON() {
196
- return {
197
- id: this.id,
198
- displayName: this.displayName,
199
- dataType: this.dataType,
200
- formula: this.formula,
201
- meta: this.meta,
202
- style: this.style
203
- };
204
- }
205
- fromJSON(e) {
206
- this.id = e.id, this.displayName = e.displayName, this.dataType = e.dataType, this.formula = e.formula, this.meta = e.meta, this.style = e.style;
207
- }
208
- }
209
- const xt = (t) => t.getMonth() <= 2, Ot = (t) => {
210
- const e = t.getMonth();
211
- return e > 2 && e <= 5;
212
- }, Ut = (t) => {
213
- const e = t.getMonth();
214
- return e > 5 && e <= 8;
215
- }, $t = (t) => {
216
- const e = t.getMonth();
217
- return e > 8 && e <= 11;
218
- }, At = (t) => t.getMonth() === 0, Lt = (t) => t.getMonth() === 1, Et = (t) => t.getMonth() === 2, Bt = (t) => t.getMonth() === 3, Wt = (t) => t.getMonth() === 4, Ht = (t) => t.getMonth() === 5, Vt = (t) => t.getMonth() === 6, Pt = (t) => t.getMonth() === 7, qt = (t) => t.getMonth() === 8, Jt = (t) => t.getMonth() === 9, kt = (t) => t.getMonth() === 10, Qt = (t) => t.getMonth() === 11, Yt = (t, e = /* @__PURE__ */ new Date()) => t.toDateString() === e.toDateString(), Gt = (t, e = /* @__PURE__ */ new Date()) => {
219
- const n = new Date(e);
220
- return n.setDate(n.getDate() + 1), t.toDateString() === n.toDateString();
221
- }, jt = (t, e = /* @__PURE__ */ new Date()) => {
222
- const n = new Date(e);
223
- return n.setDate(n.getDate() - 1), t.toDateString() === n.toDateString();
224
- }, K = (t) => {
225
- const e = t.getDay(), n = t.getDate() - e + (e === 0 ? -6 : 1), s = new Date(t);
226
- return s.setDate(n), s;
227
- }, st = 10080 * 60 * 1e3, zt = (t, e = /* @__PURE__ */ new Date()) => {
228
- const n = K(t), s = K(e);
229
- return n.toDateString() === s.toDateString();
230
- }, Kt = (t, e = /* @__PURE__ */ new Date()) => {
231
- const n = K(t), s = new Date(K(e).getTime() + st);
232
- return n.toDateString() === s.toDateString();
233
- }, Xt = (t, e = /* @__PURE__ */ new Date()) => {
234
- const n = K(t), s = new Date(K(e).getTime() - st);
235
- return n.toDateString() === s.toDateString();
236
- }, Zt = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth(), en = (t) => {
237
- const e = new Date(t);
238
- return e.setHours(0, 0, 0, 0), e.setDate(1), e;
239
- }, tn = (t, e = /* @__PURE__ */ new Date()) => {
240
- const n = new Date(e);
241
- n.setHours(0, 0, 0, 0), n.setMonth(n.getMonth() + 1, 1);
242
- const s = new Date(n);
243
- s.setMonth(s.getMonth() + 1, 0);
244
- const r = t.getTime();
245
- return r >= n.getTime() && r < s.getTime();
246
- }, nn = (t, e = /* @__PURE__ */ new Date()) => {
247
- const n = en(e), s = new Date(n);
248
- s.setMonth(s.getMonth() + 1, 0);
249
- const r = t.getTime();
250
- return r >= n.getTime() && r < s.getTime();
251
- }, Te = (t) => {
252
- const e = new Date(t);
253
- e.setHours(0, 0, 0, 0), e.setDate(1);
254
- const n = e.getMonth();
255
- return e.setMonth(n - n % 3), e;
256
- }, sn = (t, e = /* @__PURE__ */ new Date()) => {
257
- const n = Te(e), s = new Date(n);
258
- s.setMonth(s.getMonth() + 3);
259
- const r = t.getTime();
260
- return r >= n.getTime() && r < s.getTime();
261
- }, rn = (t, e = /* @__PURE__ */ new Date()) => {
262
- const n = Te(e), s = new Date(n);
263
- s.setMonth(s.getMonth() + 3);
264
- const r = new Date(s);
265
- r.setMonth(r.getMonth() + 3, 0);
266
- const a = t.getTime();
267
- return a >= s.getTime() && a < r.getTime();
268
- }, an = (t, e = /* @__PURE__ */ new Date()) => {
269
- const n = Te(e), s = new Date(n);
270
- s.setMonth(s.getMonth() - 3);
271
- const r = new Date(n);
272
- r.setDate(0);
273
- const a = t.getTime();
274
- return a >= s.getTime() && a < r.getTime();
275
- }, on = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear(), ln = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear() + 1, un = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear() - 1, cn = (t, e = /* @__PURE__ */ new Date()) => {
276
- const n = new Date(e);
277
- n.setHours(0, 0, 0, 0), n.setMonth(0, 1);
278
- const s = t.getTime();
279
- return s >= n.getTime() && s < e.getTime();
280
- };
281
- function dn(t) {
282
- switch (t.compareType) {
283
- case m.Equal: {
284
- const e = new Date(t.expectedValue);
285
- return (n) => n.getTime() === e.getTime();
286
- }
287
- case m.NotEqual: {
288
- const e = new Date(t.expectedValue);
289
- return (n) => n.getTime() !== e.getTime();
290
- }
291
- case m.After: {
292
- const e = new Date(t.expectedValue);
293
- return (n) => n.getTime() > e.getTime();
294
- }
295
- case m.Before: {
296
- const e = new Date(t.expectedValue);
297
- return (n) => n.getTime() < e.getTime();
298
- }
299
- case m.AfterOrEqual: {
300
- const e = new Date(t.expectedValue);
301
- return (n) => n.getTime() >= e.getTime();
302
- }
303
- case m.BeforeOrEqual: {
304
- const e = new Date(t.expectedValue);
305
- return (n) => n.getTime() <= e.getTime();
306
- }
307
- case m.Between:
308
- return (e) => {
309
- const [n, s] = t.expectedValue;
310
- return e.getTime() >= new Date(n).getTime() && e.getTime() <= new Date(s).getTime();
311
- };
312
- case m.NotBetween:
313
- return (e) => {
314
- const [n, s] = t.expectedValue;
315
- return e.getTime() < new Date(n).getTime() || e.getTime() > new Date(s).getTime();
316
- };
317
- case m.Today: {
318
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
319
- return (n) => Yt(n, e);
320
- }
321
- case m.Yesterday: {
322
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
323
- return (n) => jt(n, e);
324
- }
325
- case m.Tomorrow: {
326
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
327
- return (n) => Gt(n, e);
328
- }
329
- case m.ThisWeek: {
330
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
331
- return (n) => zt(n, e);
332
- }
333
- case m.LastWeek: {
334
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
335
- return (n) => Xt(n, e);
336
- }
337
- case m.NextWeek: {
338
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
339
- return (n) => Kt(n, e);
340
- }
341
- case m.ThisMonth: {
342
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
343
- return (n) => Zt(n, e);
344
- }
345
- case m.LastMonth: {
346
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
347
- return (n) => nn(n, e);
348
- }
349
- case m.NextMonth: {
350
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
351
- return (n) => tn(n, e);
352
- }
353
- case m.ThisQuarter: {
354
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
355
- return (n) => sn(n, e);
356
- }
357
- case m.LastQuarter: {
358
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
359
- return (n) => an(n, e);
360
- }
361
- case m.NextQuarter: {
362
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
363
- return (n) => rn(n, e);
364
- }
365
- case m.ThisYear: {
366
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
367
- return (n) => on(n, e);
368
- }
369
- case m.LastYear: {
370
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
371
- return (n) => un(n, e);
372
- }
373
- case m.NextYear: {
374
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
375
- return (n) => ln(n, e);
376
- }
377
- case m.YearToDate: {
378
- const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
379
- return (n) => cn(n, e);
380
- }
381
- case m.M1:
382
- return At;
383
- case m.M2:
384
- return Lt;
385
- case m.M3:
386
- return Et;
387
- case m.M4:
388
- return Bt;
389
- case m.M5:
390
- return Wt;
391
- case m.M6:
392
- return Ht;
393
- case m.M7:
394
- return Vt;
395
- case m.M8:
396
- return Pt;
397
- case m.M9:
398
- return qt;
399
- case m.M10:
400
- return Jt;
401
- case m.M11:
402
- return kt;
403
- case m.M12:
404
- return Qt;
405
- case m.Q1:
406
- return xt;
407
- case m.Q2:
408
- return Ot;
409
- case m.Q3:
410
- return Ut;
411
- case m.Q4:
412
- return $t;
413
- default:
414
- throw new Error("Unsupported compare type");
415
- }
416
- }
417
- class hn {
418
- /**
419
- * Initializes a new instance of the Heap class.
420
- */
421
- constructor() {
422
- b(this, "heap");
423
- this.heap = [];
424
- }
425
- /**
426
- * Swaps the elements at the given indices in the heap.
427
- * @param index1 The index of the first element.
428
- * @param index2 The index of the second element.
429
- */
430
- swap(e, n) {
431
- const s = this.heap[e];
432
- this.heap[e] = this.heap[n], this.heap[n] = s;
433
- }
434
- /**
435
- * Returns the index of the parent node for the given index.
436
- * @param index The index of the node.
437
- * @returns The index of the parent node.
438
- */
439
- getParentIndex(e) {
440
- return Math.floor((e - 1) / 2);
441
- }
442
- /**
443
- * Returns the index of the left child node for the given index.
444
- * @param index The index of the node.
445
- * @returns The index of the left child node.
446
- */
447
- getLeftIndex(e) {
448
- return e * 2 + 1;
449
- }
450
- /**
451
- * Returns the index of the right child node for the given index.
452
- * @param index The index of the node.
453
- * @returns The index of the right child node.
454
- */
455
- getRightIndex(e) {
456
- return e * 2 + 2;
457
- }
458
- /**
459
- * Returns the number of elements in the heap.
460
- * @returns The number of elements in the heap.
461
- */
462
- size() {
463
- return this.heap.length;
464
- }
465
- /**
466
- * Returns the minimum value in the heap without removing it.
467
- * @returns The minimum value in the heap.
468
- */
469
- peek() {
470
- return this.heap[0];
471
- }
472
- /**
473
- * @description Returns whether the heap includes the given value.
474
- * @param {number} value The value to be checked.
475
- * @returns {boolean} return true if the heap includes the given value
476
- */
477
- include(e) {
478
- return this.heap.includes(e);
479
- }
480
- }
481
- class gn extends hn {
482
- /**
483
- * Initializes a new instance of the MinHeap class.
484
- */
485
- constructor() {
486
- super();
487
- }
488
- /**
489
- * Moves the element at the given index up the heap until it satisfies the min heap property.
490
- * @param index The index of the element to be shifted up.
491
- */
492
- shiftUp(e) {
493
- if (e === 0)
494
- return;
495
- const n = this.getParentIndex(e);
496
- this.heap[n] > this.heap[e] && (this.swap(n, e), this.shiftUp(n));
497
- }
498
- /**
499
- * Moves the element at the given index down the heap until it satisfies the min heap property.
500
- * @param index The index of the element to be shifted down.
501
- */
502
- shiftDown(e) {
503
- const n = this.getLeftIndex(e), s = this.getRightIndex(e);
504
- this.heap[n] < this.heap[e] && (this.swap(n, e), this.shiftDown(n)), this.heap[s] < this.heap[e] && (this.swap(s, e), this.shiftDown(s));
505
- }
506
- /**
507
- * Inserts a new value into the min heap.
508
- * @param value The value to be inserted.
509
- */
510
- insert(e) {
511
- this.heap.push(e), this.shiftUp(this.heap.length - 1);
512
- }
513
- /**
514
- * Removes and returns the minimum value from the min heap.
515
- */
516
- pop() {
517
- this.heap[0] = this.heap.pop(), this.shiftDown(0);
518
- }
519
- }
520
- const mn = (t, e) => {
521
- const n = new gn();
522
- for (const s of t)
523
- n.insert(s), n.size() > e && n.pop();
524
- return n.heap;
525
- }, bn = (t, e) => t > e, wn = (t, e) => t < e, fn = (t, e, n) => mn(t, e).includes(n);
526
- function pn(t, e) {
527
- switch (t.compareType) {
528
- case F.Equal: {
529
- const n = Number(t.expectedValue);
530
- return (s) => s === n;
531
- }
532
- case F.NotEqual: {
533
- const n = Number(t.expectedValue);
534
- return (s) => s !== n;
535
- }
536
- case F.GreaterThan: {
537
- const n = Number(t.expectedValue);
538
- return (s) => s > n;
539
- }
540
- case F.GreaterThanOrEqual: {
541
- const n = Number(t.expectedValue);
542
- return (s) => s >= n;
543
- }
544
- case F.LessThan: {
545
- const n = Number(t.expectedValue);
546
- return (s) => s < n;
547
- }
548
- case F.LessThanOrEqual: {
549
- const n = Number(t.expectedValue);
550
- return (s) => s <= n;
551
- }
552
- case F.Between: {
553
- const [n, s] = t.expectedValue, r = Number(n), a = Number(s);
554
- return r > a ? (o) => o >= a && o <= r : (o) => o >= r && o <= a;
555
- }
556
- case F.NotBetween: {
557
- const [n, s] = t.expectedValue, r = Number(n), a = Number(s);
558
- return r > a ? (o) => o < a || o > r : (o) => o < r || o > a;
559
- }
560
- case F.Above: {
561
- const n = e.average;
562
- return (s) => bn(s, n);
563
- }
564
- case F.Below: {
565
- const n = e.average;
566
- return (s) => wn(s, n);
567
- }
568
- case F.TopN: {
569
- const n = e.list, s = Number(t.expectedValue);
570
- return (r) => fn(n, s, r);
571
- }
572
- }
573
- }
574
- const Sn = (t, e) => Z(e).test(t), _n = (t, e) => !Z(e).test(t), Cn = (t, e) => Z(`*${e}*`).test(t), Rn = (t, e) => !Z(`*${e}*`).test(t), Tn = (t, e) => Z(`${e}*`).test(t), In = (t, e) => Z(`*${e}`).test(t);
575
- function Mn(t) {
576
- switch (t.compareType) {
577
- case P.Equal:
578
- return (e) => Sn(e, t.expectedValue);
579
- case P.NotEqual:
580
- return (e) => _n(e, t.expectedValue);
581
- case P.Contains:
582
- return (e) => Cn(e, t.expectedValue);
583
- case P.NotContains:
584
- return (e) => Rn(e, t.expectedValue);
585
- case P.StartsWith:
586
- return (e) => Tn(e, t.expectedValue);
587
- case P.EndsWith:
588
- return (e) => In(e, t.expectedValue);
589
- default:
590
- return console.error(`Unknown filter operator: ${t.compareType}`), (e) => !0;
591
- }
592
- }
593
- const vn = /* @__PURE__ */ new Set([
594
- F.Above,
595
- F.Below,
596
- F.TopN
597
- ]);
598
- m.Today, m.Yesterday, m.Tomorrow, m.ThisWeek, m.LastWeek, m.NextWeek, m.ThisMonth, m.LastMonth, m.NextMonth, m.ThisQuarter, m.LastQuarter, m.NextQuarter, m.NextYear, m.ThisYear, m.LastYear, m.YearToDate;
599
- function rt(t) {
600
- return vn.has(t);
601
- }
602
- function Fn(t, e) {
603
- if (rt(t.filterInfo.compareType))
604
- return (n) => !0;
605
- switch (t.filterInfo.conditionType) {
606
- case U.Date:
607
- return dn(t.filterInfo);
608
- case U.Number:
609
- return pn(t.filterInfo, e);
610
- case U.String:
611
- return Mn(t.filterInfo);
612
- case U.Logic:
613
- default:
614
- return (n) => !0;
615
- }
616
- }
617
- function ue(t, e, n, s) {
618
- switch (s) {
619
- case U.Date: {
620
- const r = xe(t, e, n);
621
- return r ? Dn(r) : null;
622
- }
623
- case U.Number:
624
- return xe(t, e, n);
625
- case U.String:
626
- default:
627
- return yn(t, e, n);
628
- }
629
- }
630
- const Nn = (t) => {
631
- var n;
632
- return ((n = t.body) == null ? void 0 : n.dataStream.replace(/\r\n$/, "")) || "";
633
- };
634
- function yn(t, e, n) {
635
- const s = t.getCell(e, n);
636
- if (!s) return null;
637
- const { v: r, t: a, p: o } = s;
638
- if (o)
639
- return Nn(o);
640
- if (typeof r == "string")
641
- return a === J.BOOLEAN ? r.toUpperCase() : r;
642
- if (typeof r == "number")
643
- return a === J.BOOLEAN ? r ? "TRUE" : "FALSE" : r;
644
- if (typeof r == "boolean") return r ? "TRUE" : "FALSE";
645
- if (r !== void 0)
646
- return String(r);
647
- }
648
- function xe(t, e, n) {
649
- const s = t.getCell(e, n);
650
- if (!s) return null;
651
- const { v: r, t: a, p: o } = s;
652
- return o ? null : typeof r == "string" && a === J.NUMBER ? Number(t.getCellRaw(e, n).v) : Number(r);
653
- }
654
- function Dn(t) {
655
- const e = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), n = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
656
- let s = t - 1;
657
- return s > (n.getTime() - e.getTime()) / (1e3 * 3600 * 24) && (s -= 1), s < 0 && (s = t), new Date(e.getTime() + s * (1e3 * 3600 * 24));
658
- }
659
- class Oe {
660
- constructor() {
661
- b(this, "_tableColumnFilterList");
662
- b(this, "_tableSortInfo");
663
- b(this, "_filterOutRows");
664
- this._tableColumnFilterList = [];
665
- }
666
- setColumnFilter(e, n) {
667
- n ? this._tableColumnFilterList[e] = n : this._tableColumnFilterList[e] = void 0;
668
- }
669
- setSortState(e, n) {
670
- this._tableSortInfo = { columnIndex: e, sortState: n };
671
- }
672
- getColumnFilter(e) {
673
- return this._tableColumnFilterList[e];
674
- }
675
- getFilterState(e) {
676
- var s;
677
- const n = ((s = this._tableSortInfo) == null ? void 0 : s.columnIndex) === e ? this._tableSortInfo.sortState : G.None;
678
- return Nt(this._tableColumnFilterList[e], n);
679
- }
680
- getSortState() {
681
- var e;
682
- return (e = this._tableSortInfo) != null ? e : {};
683
- }
684
- getFilterStates(e) {
685
- const n = [], { startColumn: s, endColumn: r } = e;
686
- for (let a = s; a <= r; a++)
687
- n.push(this.getFilterState(a - s));
688
- return n;
689
- }
690
- getFilterOutRows() {
691
- return this._filterOutRows;
692
- }
693
- doFilter(e, n) {
694
- const s = /* @__PURE__ */ new Set(), r = this._tableColumnFilterList;
695
- for (let a = 0; a < r.length; a++)
696
- r[a] && this.doColumnFilter(e, n, a, s);
697
- return this._filterOutRows = s, s;
698
- }
699
- doColumnFilter(e, n, s, r) {
700
- const a = this._tableColumnFilterList[s];
701
- if (a && e) {
702
- const { startRow: o, endRow: u, startColumn: l } = n, i = l + s, h = this.getExecuteFunc(e, n, s, a);
703
- for (let d = o; d <= u; d++) {
704
- const c = yt(a) ? a.filterInfo.conditionType : U.String;
705
- ue(e, d, i, c) === null ? r.add(d) : h(ue(e, d, i, c)) || r.add(d);
706
- }
707
- }
708
- }
709
- _getNumberCalculatedOptions(e, n, s) {
710
- const { startRow: r, endRow: a, startColumn: o } = n, u = o + s, l = [];
711
- let i = 0, h = 0;
712
- for (let d = r; d <= a; d++) {
713
- const c = ue(e, d, u, U.Number);
714
- c !== null && (l.push(c), i++, h += c);
715
- }
716
- return {
717
- list: l,
718
- average: i > 0 ? h / i : 0
719
- };
720
- }
721
- getExecuteFunc(e, n, s, r) {
722
- if (r.filterType === ne.manual) {
723
- const a = new Set(r.values);
724
- return (o) => a.has(o);
725
- } else if (r.filterType === ne.condition) {
726
- const o = rt(r.filterInfo.compareType) ? this._getNumberCalculatedOptions(e, n, s) : void 0;
727
- return Fn(r, o);
728
- } else
729
- return (a) => !0;
730
- }
731
- toJSON() {
732
- return {
733
- tableColumnFilterList: this._tableColumnFilterList,
734
- tableSortInfo: this._tableSortInfo
735
- };
736
- }
737
- fromJSON(e) {
738
- var n;
739
- this._tableColumnFilterList = (n = e.tableColumnFilterList) != null ? n : [], e.tableSortInfo && (this._tableSortInfo = e.tableSortInfo);
740
- }
741
- dispose() {
742
- this._tableColumnFilterList = [];
743
- }
744
- }
745
- class Ue {
746
- constructor(e, n, s, r, a = {}) {
747
- b(this, "_id");
748
- b(this, "_name");
749
- /**
750
- * @property {string} tableStyleId The table style id. If the property is empty, the default style will be used.
751
- */
752
- b(this, "_tableStyleId");
753
- b(this, "_showHeader");
754
- b(this, "_showFooter");
755
- b(this, "_range");
756
- b(this, "_columns", /* @__PURE__ */ new Map());
757
- b(this, "_columnOrder", []);
758
- b(this, "tableMeta");
759
- b(this, "_tableFilters");
760
- b(this, "_subUnitId");
761
- this._id = e, this._range = s, this._name = n, this._tableFilters = new Oe(), this._init(r, a);
762
- }
763
- _init(e, n) {
764
- var o, u;
765
- this._tableStyleId = n == null ? void 0 : n.tableStyleId, this._showHeader = (o = n == null ? void 0 : n.showHeader) != null ? o : !0, this._showFooter = !1;
766
- const s = this.getRange(), r = s.startColumn, a = s.endColumn;
767
- for (let l = r; l <= a; l++) {
768
- const i = l - r;
769
- let h, d;
770
- (u = n.columns) != null && u[i] ? (h = n.columns[i].id, d = n.columns[i].displayName) : (h = B(), d = e[l - r]);
771
- const c = new z(h, d);
772
- this._columns.set(h, c), this._columnOrder.push(h);
773
- }
774
- n.filters && n.filters.forEach((i, h) => {
775
- i && this._tableFilters.setColumnFilter(h, i);
776
- });
777
- }
778
- setTableFilterColumn(e, n) {
779
- this._tableFilters.setColumnFilter(e, n);
780
- }
781
- getTableFilterColumn(e) {
782
- return this._tableFilters.getColumnFilter(e);
783
- }
784
- getTableFilters() {
785
- return this._tableFilters;
786
- }
787
- getTableFilterRange() {
788
- const e = this.getRange(), n = this.isShowHeader(), s = this.isShowFooter(), { startRow: r, startColumn: a, endRow: o, endColumn: u } = e, l = n ? r + 1 : r, i = s ? o - 1 : o;
789
- return {
790
- startRow: l,
791
- startColumn: a,
792
- endRow: i,
793
- endColumn: u
794
- };
795
- }
796
- setColumns(e) {
797
- this._columns.clear(), this._columnOrder = [], e.forEach((n) => {
798
- const s = new z(n.id, n.displayName);
799
- s.fromJSON(n), this._columns.set(n.id, s), this._columnOrder.push(n.id);
800
- });
801
- }
802
- getColumnsCount() {
803
- return this._columnOrder.length;
804
- }
805
- insertColumn(e, n) {
806
- const s = n.id;
807
- this._columns.set(s, n), this._columnOrder.splice(e, 0, s);
808
- }
809
- removeColumn(e) {
810
- const n = this._columnOrder[e];
811
- this._columns.delete(n), this._columnOrder.splice(e, 1);
812
- }
813
- setTableMeta(e) {
814
- this.tableMeta = e;
815
- }
816
- getTableMeta() {
817
- return this.tableMeta;
818
- }
819
- getColumn(e) {
820
- return this._columns.get(e);
821
- }
822
- getTableColumnByIndex(e) {
823
- const n = this._columnOrder[e];
824
- return this.getColumn(n);
825
- }
826
- getColumnNameByIndex(e) {
827
- var s;
828
- const n = this._columnOrder[e];
829
- return ((s = this.getColumn(n)) == null ? void 0 : s.getDisplayName()) || "";
830
- }
831
- getId() {
832
- return this._id;
833
- }
834
- getRangeInfo() {
835
- return {
836
- ...this._range
837
- };
838
- }
839
- getRange() {
840
- return { ...this._range };
841
- }
842
- setRange(e) {
843
- this._range = e;
844
- }
845
- setDisplayName(e) {
846
- this._name = e;
847
- }
848
- getDisplayName() {
849
- return this._name;
850
- }
851
- getSubunitId() {
852
- return this._subUnitId;
853
- }
854
- setSubunitId(e) {
855
- this._subUnitId = e;
856
- }
857
- getTableStyleId() {
858
- var e;
859
- return (e = this._tableStyleId) != null ? e : nt[0].name;
860
- }
861
- setTableStyleId(e) {
862
- this._tableStyleId = e;
863
- }
864
- isShowHeader() {
865
- var e;
866
- return (e = this._showHeader) != null ? e : !0;
867
- }
868
- setShowHeader(e) {
869
- this._showHeader = e;
870
- }
871
- isShowFooter() {
872
- var e;
873
- return (e = this._showFooter) != null ? e : !1;
874
- }
875
- getTableInfo() {
876
- return {
877
- id: this._id,
878
- subUnitId: this._subUnitId,
879
- name: this._name,
880
- range: this.getRangeInfo(),
881
- meta: this.tableMeta,
882
- showHeader: this._showHeader,
883
- columns: this._columnOrder.map((e) => this._columns.get(e).toJSON())
884
- };
885
- }
886
- getTableConfig() {
887
- return {
888
- name: this.getDisplayName(),
889
- range: this.getRangeInfo(),
890
- options: {
891
- showHeader: this._showHeader,
892
- showFooter: this._showFooter
893
- },
894
- tableStyleId: this._tableStyleId
895
- };
896
- }
897
- getFilterStates(e) {
898
- return this._tableFilters.getFilterStates(e);
899
- }
900
- toJSON() {
901
- const e = [];
902
- return this._columns.forEach((n) => {
903
- e.push(n.toJSON());
904
- }), {
905
- id: this._id,
906
- name: this._name,
907
- range: this.getRangeInfo(),
908
- options: {
909
- showHeader: this._showHeader,
910
- showFooter: this._showFooter,
911
- tableStyleId: this._tableStyleId
912
- },
913
- // TODO: support filter
914
- filters: this._tableFilters.toJSON(),
915
- columns: e,
916
- meta: this.tableMeta
917
- };
918
- }
919
- fromJSON(e) {
920
- var s, r;
921
- this._id = e.id, this._name = e.name, this._range = e.range, this.tableMeta = e.meta, this._tableStyleId = e.options.tableStyleId || "", this._showHeader = (s = e.options.showHeader) != null ? s : !0, this._showFooter = (r = e.options.showFooter) != null ? r : !0, e.columns.forEach((a) => {
922
- const o = new z(a.id, a.displayName);
923
- o.fromJSON(a), this._columns.set(a.id, o), this._columnOrder.push(a.id);
924
- }), this._tableFilters = new Oe(), this._tableFilters.fromJSON(e.filters);
925
- }
926
- dispose() {
927
- this._id = "", this._name = "", this._tableStyleId = "", this._showHeader = !0, this._showFooter = !0, delete this._range, this._columns.clear(), this._columnOrder = [];
928
- }
929
- }
930
- var xn = Object.getOwnPropertyDescriptor, On = (t, e, n, s) => {
931
- for (var r = s > 1 ? void 0 : s ? xn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
932
- (o = t[a]) && (r = o(r) || r);
933
- return r;
934
- }, $e = (t, e) => (n, s) => e(n, s, t);
935
- let T = class extends H {
936
- constructor(e, n) {
937
- super();
938
- b(this, "_tableMap");
939
- b(this, "_tableAdd$", new Y());
940
- b(this, "tableAdd$", this._tableAdd$.asObservable());
941
- b(this, "_tableDelete$", new Y());
942
- b(this, "tableDelete$", this._tableDelete$.asObservable());
943
- b(this, "_tableNameChanged$", new Y());
944
- b(this, "tableNameChanged$", this._tableNameChanged$.asObservable());
945
- b(this, "_tableRangeChanged$", new Y());
946
- b(this, "tableRangeChanged$", this._tableRangeChanged$.asObservable());
947
- b(this, "_tableThemeChanged$", new Y());
948
- b(this, "tableThemeChanged$", this._tableThemeChanged$.asObservable());
949
- b(this, "_tableFilterChanged$", new Y());
950
- b(this, "tableFilterChanged$", this._tableFilterChanged$.asObservable());
951
- b(this, "_tableInitStatus", new Ke(!1));
952
- b(this, "tableInitStatus$", this._tableInitStatus.asObservable());
953
- this._univerInstanceService = e, this._localeService = n, this._tableMap = /* @__PURE__ */ new Map();
954
- }
955
- _ensureUnit(e) {
956
- return this._tableMap.has(e) || this._tableMap.set(e, /* @__PURE__ */ new Map()), this._tableMap.get(e);
957
- }
958
- getColumnHeader(e, n, s, r) {
959
- var d;
960
- const a = (d = this._univerInstanceService.getUnit(e)) == null ? void 0 : d.getSheetBySheetId(n), { startRow: o, startColumn: u, endColumn: l } = s, i = [], h = r != null ? r : "Column";
961
- for (let c = u; c <= l; c++)
962
- i.push(Ze(a == null ? void 0 : a.getCell(o, c)) || te(c - u + 1, h));
963
- return i;
964
- }
965
- /**
966
- * Add a table to univer.
967
- * @param {string} unitId The unit id of the table.
968
- * @param {string} subUnitId The subunit id of the table.
969
- * @param {string} name The table name, it should be unique in the unit or it will be appended with a number.
970
- * @param {ITableRange} range The range of the table, it contains the unit id and subunit id.
971
- * @param {string[]} [header] The header of the table, if not provided, it will be generated based on the range.
972
- * @param {string} [initId] The initial id of the table, if not provided, a random id will be generated.
973
- * @param {ITableOptions} [options] Other options of the table.
974
- * @returns {string} The table id.
975
- */
976
- addTable(e, n, s, r, a, o, u) {
977
- var c;
978
- const l = o != null ? o : B(), i = a || this.getColumnHeader(e, n, r), h = new Ue(l, s, r, i, u);
979
- if (h.setSubunitId(n), this._ensureUnit(e).set(l, h), this._tableAdd$.next({
980
- unitId: e,
981
- subUnitId: n,
982
- range: r,
983
- tableName: s,
984
- tableId: l,
985
- tableStyleId: u == null ? void 0 : u.tableStyleId
986
- }), u != null && u.filters) {
987
- const g = (c = this._univerInstanceService.getUnit(e)) == null ? void 0 : c.getSheetBySheetId(n);
988
- h.getTableFilters().doFilter(g, r), this._tableFilterChanged$.next({
989
- unitId: e,
990
- subUnitId: n,
991
- tableId: l
992
- });
993
- }
994
- return l;
995
- }
996
- addFilter(e, n, s, r) {
997
- const a = this.getTable(e, n);
998
- if (a) {
999
- a.getTableFilters().setColumnFilter(s, r);
1000
- const u = a.getSubunitId();
1001
- this._tableFilterChanged$.next({
1002
- unitId: e,
1003
- subUnitId: u,
1004
- tableId: n
1005
- });
1006
- }
1007
- }
1008
- getFilterRanges(e, n) {
1009
- const s = this._tableMap.get(e);
1010
- if (!s)
1011
- return [];
1012
- const r = [];
1013
- return s.forEach((a) => {
1014
- a.getSubunitId() === n && a.isShowHeader() && r.push(a.getRange());
1015
- }), r;
1016
- }
1017
- getSheetFilterRangeWithState(e, n) {
1018
- const s = this._tableMap.get(e);
1019
- if (!s)
1020
- return [];
1021
- const r = [];
1022
- return s.forEach((a) => {
1023
- a.getSubunitId() === n && a.isShowHeader() && r.push({
1024
- tableId: a.getId(),
1025
- range: a.getRange(),
1026
- states: a.getFilterStates(a.getRange())
1027
- });
1028
- }), r;
1029
- }
1030
- getTable(e, n) {
1031
- const s = this._tableMap.get(e);
1032
- if (s)
1033
- return s.get(n);
1034
- }
1035
- /**
1036
- * Get the unique table name, in excel, the table name should be unique because it is used as a reference.
1037
- * @param {string} unitId The unit id of the table.
1038
- * @param {string} baseName The base name of the table.
1039
- * @returns {string} The unique table name
1040
- */
1041
- getUniqueTableName(e, n) {
1042
- const s = this._tableMap.get(e);
1043
- if (!s)
1044
- return n;
1045
- const r = new Set(Array.from(s.values()).map((u) => u.getDisplayName()));
1046
- let a = n, o = 1;
1047
- for (; r.has(a); )
1048
- a = `${n}-${o}`, o++;
1049
- return a;
1050
- }
1051
- /**
1052
- * Get table by unit id and table id.
1053
- * @param {string} unitId The unit id of the table.
1054
- * @param {string} tableId The table id.
1055
- * @returns {Table} The table.
1056
- */
1057
- getTableById(e, n) {
1058
- return this.getTable(e, n);
1059
- }
1060
- getTableList(e) {
1061
- const n = this._tableMap.get(e);
1062
- return n ? Array.from(n.values()).map((s) => ({ ...s.getTableInfo(), unitId: e })) : [];
1063
- }
1064
- /**
1065
- * Get the table list by unit id and subunit id.
1066
- * @param {string} unitId The unit id of the table.
1067
- * @param {string} subUnitId The subunit id of the table.
1068
- * @returns {Table[]} The table list.
1069
- */
1070
- getTablesBySubunitId(e, n) {
1071
- const s = this._tableMap.get(e);
1072
- return s ? Array.from(s.values()).filter((r) => r.getSubunitId() === n) : [];
1073
- }
1074
- getTablesInfoBySubunitId(e, n) {
1075
- return this.getTablesBySubunitId(e, n).map((s) => ({
1076
- id: s.getId(),
1077
- name: s.getDisplayName(),
1078
- range: s.getRange()
1079
- }));
1080
- }
1081
- deleteTable(e, n) {
1082
- const s = this._tableMap.get(e), r = s == null ? void 0 : s.get(n);
1083
- if (r) {
1084
- const a = r.getTableInfo(), o = r.getTableStyleId();
1085
- s == null || s.delete(n);
1086
- const { subUnitId: u, range: l, name: i } = a;
1087
- this._tableDelete$.next({
1088
- unitId: e,
1089
- subUnitId: u,
1090
- tableId: n,
1091
- range: l,
1092
- tableName: i,
1093
- tableStyleId: o
1094
- });
1095
- }
1096
- }
1097
- operationTableRowCol(e, n, s) {
1098
- const r = this.getTableById(e, n);
1099
- if (!r) return;
1100
- const { operationType: a, rowColType: o, index: u, count: l, columnsJson: i } = s, h = r.getRange(), d = { ...h };
1101
- if (a === M.Insert) {
1102
- if (o === "row")
1103
- d.endRow += l;
1104
- else if (o === "column") {
1105
- d.endColumn += l;
1106
- for (let c = 0; c < l; c++) {
1107
- const g = this._localeService.t("sheets-table.columnPrefix"), _ = new z(B(), te(r.getColumnsCount() + 1 + c, g));
1108
- i != null && i[c] && _.fromJSON(i[c]);
1109
- const f = u + c - h.startColumn;
1110
- r.insertColumn(f, _);
1111
- }
1112
- }
1113
- } else if (o === "row")
1114
- d.endRow -= l;
1115
- else if (o === "column") {
1116
- d.endColumn -= l;
1117
- for (let c = l - 1; c >= 0; c--) {
1118
- const g = u + c - h.startColumn;
1119
- r.removeColumn(g);
1120
- }
1121
- }
1122
- r.setRange(d), this._tableRangeChanged$.next({
1123
- unitId: e,
1124
- subUnitId: r.getSubunitId(),
1125
- tableId: n,
1126
- range: d,
1127
- oldRange: h
1128
- });
1129
- }
1130
- updateTableRange(e, n, s) {
1131
- const r = this.getTableById(e, n);
1132
- if (!r) return;
1133
- const a = r.getRange(), o = s.newRange;
1134
- if (o.startColumn < a.startColumn) {
1135
- const u = a.startColumn - o.startColumn, l = this._localeService.t("sheets-table.columnPrefix");
1136
- for (let i = 0; i < u; i++)
1137
- r.insertColumn(a.startColumn, new z(B(), te(r.getColumnsCount() + 1, l)));
1138
- } else if (o.startColumn > a.startColumn) {
1139
- const u = o.startColumn - a.startColumn;
1140
- for (let l = u - 1; l >= 0; l--) {
1141
- const i = o.startColumn + l - a.startColumn;
1142
- r.removeColumn(i);
1143
- }
1144
- }
1145
- if (o.endColumn < a.endColumn) {
1146
- const u = a.endColumn - o.endColumn;
1147
- for (let l = u - 1; l >= 0; l--) {
1148
- const i = o.endColumn + l - a.startColumn;
1149
- r.removeColumn(i);
1150
- }
1151
- } else if (o.endColumn > a.endColumn) {
1152
- const u = o.endColumn - a.endColumn;
1153
- for (let l = 0; l < u; l++)
1154
- r.insertColumn(a.endColumn, new z(B(), te(r.getColumnsCount() + 1, "Column")));
1155
- }
1156
- r.setRange(o), this._tableRangeChanged$.next({
1157
- unitId: e,
1158
- subUnitId: r.getSubunitId(),
1159
- tableId: n,
1160
- range: o,
1161
- oldRange: a
1162
- });
1163
- }
1164
- setTableByConfig(e, n, s) {
1165
- var c;
1166
- const r = this._tableMap.get(e), a = r == null ? void 0 : r.get(n);
1167
- if (!a) return;
1168
- const o = a.getSubunitId(), { name: u, updateRange: l, rowColOperation: i, theme: h, options: d } = s;
1169
- if (u) {
1170
- const g = a.getDisplayName();
1171
- a.setDisplayName(u), this._tableNameChanged$.next({
1172
- unitId: e,
1173
- subUnitId: o,
1174
- tableId: n,
1175
- tableName: u,
1176
- oldTableName: g
1177
- });
1178
- }
1179
- if (i && this.operationTableRowCol(e, n, i), l && this.updateTableRange(e, n, l), h) {
1180
- const g = (c = a.getTableStyleId()) != null ? c : "default";
1181
- a.setTableStyleId(h), this._tableThemeChanged$.next({
1182
- unitId: e,
1183
- subUnitId: o,
1184
- tableId: n,
1185
- theme: h,
1186
- oldTheme: g
1187
- });
1188
- }
1189
- d && d.showHeader !== void 0 && a.setShowHeader(d.showHeader);
1190
- }
1191
- toJSON(e) {
1192
- const n = {}, s = this._tableMap.get(e);
1193
- return s && s.forEach((r) => {
1194
- const a = r.getSubunitId();
1195
- if (!n[a]) {
1196
- const o = /* @__PURE__ */ new Set();
1197
- this.getTablesBySubunitId(e, a).forEach((l) => {
1198
- const i = l.getTableFilters().getFilterOutRows();
1199
- if (i)
1200
- for (const h of i)
1201
- o.add(h);
1202
- }), n[a] = {
1203
- tables: [],
1204
- tableFilteredOutRows: Array.from(o)
1205
- };
1206
- }
1207
- n[a].tables.push(r.toJSON());
1208
- }), n;
1209
- }
1210
- fromJSON(e, n) {
1211
- const s = this._ensureUnit(e);
1212
- Object.keys(n).forEach((a) => {
1213
- const o = $(this._univerInstanceService, { unitId: e, subUnitId: a });
1214
- if (!o)
1215
- return;
1216
- const u = o.worksheet;
1217
- let l;
1218
- n[a].tables ? l = n[a].tables : Array.isArray(n[a]) && (l = n[a]), l && l.forEach((i) => {
1219
- const h = this.getColumnHeader(e, a, i.range), d = new Ue(i.id, i.name, i.range, h, i.options);
1220
- if (d.setTableMeta(i.meta), i.columns.length && d.setColumns(i.columns), i.filters) {
1221
- const c = d.getTableFilters();
1222
- c.fromJSON(i.filters), c.doFilter(u, d.getTableFilterRange());
1223
- }
1224
- d.setSubunitId(a), s.set(i.id, d), this._tableAdd$.next({
1225
- unitId: e,
1226
- subUnitId: a,
1227
- range: i.range,
1228
- tableName: i.name,
1229
- tableId: i.id
1230
- });
1231
- });
1232
- }), this._tableInitStatus.next(!0);
1233
- }
1234
- deleteUnitId(e) {
1235
- const n = this._tableMap.get(e);
1236
- n && n.forEach((s) => s.dispose()), this._tableMap.delete(e);
1237
- }
1238
- dispose() {
1239
- super.dispose(), this._tableAdd$.complete(), this._tableDelete$.complete(), this._tableNameChanged$.complete(), this._tableRangeChanged$.complete(), this._tableThemeChanged$.complete(), this._tableFilterChanged$.complete(), this._tableInitStatus.complete(), this._tableMap.forEach((e) => {
1240
- e.forEach((n) => n.dispose()), e.clear();
1241
- }), this._tableMap.clear();
1242
- }
1243
- };
1244
- T = On([
1245
- $e(0, A),
1246
- $e(1, C(be))
1247
- ], T);
1248
- var Un = Object.getOwnPropertyDescriptor, $n = (t, e, n, s) => {
1249
- for (var r = s > 1 ? void 0 : s ? Un(e, n) : e, a = t.length - 1, o; a >= 0; a--)
1250
- (o = t[a]) && (r = o(r) || r);
1251
- return r;
1252
- }, An = (t, e) => (n, s) => e(n, s, t);
1253
- let X = class extends H {
1254
- constructor(t) {
1255
- super(), this._tableManager = t;
1256
- }
1257
- getTableInfo(t, e) {
1258
- const n = this._tableManager.getTable(t, e);
1259
- if (n)
1260
- return {
1261
- unitId: t,
1262
- ...n.getTableInfo()
1263
- };
1264
- }
1265
- getTableList(t) {
1266
- return this._tableManager.getTableList(t);
1267
- }
1268
- addTable(t, e, n, s, r, a, o) {
1269
- return this._tableManager.addTable(t, e, n, s, r, a, o);
1270
- }
1271
- deleteTable(t, e, n) {
1272
- this._tableManager.deleteTable(t, n);
1273
- }
1274
- getTableMeta(t, e) {
1275
- var n;
1276
- return (n = this._tableManager.getTable(t, e)) == null ? void 0 : n.getTableMeta();
1277
- }
1278
- setTableMeta(t, e, n) {
1279
- var s;
1280
- (s = this._tableManager.getTable(t, e)) == null || s.setTableMeta(n);
1281
- }
1282
- getTableColumnMeta(t, e, n) {
1283
- var s, r;
1284
- return (r = (s = this._tableManager.getTable(t, e)) == null ? void 0 : s.getTableColumnByIndex(n)) == null ? void 0 : r.getMeta();
1285
- }
1286
- selTableColumnMeta(t, e, n, s) {
1287
- var r, a;
1288
- (a = (r = this._tableManager.getTable(t, e)) == null ? void 0 : r.getTableColumnByIndex(n)) == null || a.setMeta(s);
1289
- }
1290
- addFilter(t, e, n, s) {
1291
- this._tableManager.addFilter(t, e, n, s);
1292
- }
1293
- getCellValueWithConditionType(t, e, n, s = U.String) {
1294
- return ue(t, e, n, s);
1295
- }
1296
- };
1297
- X = $n([
1298
- An(0, C(T))
1299
- ], X);
1300
- const k = {
1301
- id: "sheet.mutation.add-table",
1302
- type: y.MUTATION,
1303
- handler: (t, e) => {
1304
- const { tableId: n, unitId: s, subUnitId: r, name: a, range: o, header: u, options: l } = e;
1305
- return t.get(X).addTable(s, r, a, o, u, n, l), !0;
1306
- }
1307
- }, Q = {
1308
- id: "sheet.mutation.delete-table",
1309
- type: y.MUTATION,
1310
- handler: (t, e) => {
1311
- const { unitId: n, subUnitId: s, tableId: r } = e;
1312
- return t.get(X).deleteTable(n, s, r), !0;
1313
- }
1314
- }, Ln = {
1315
- id: "sheet.command.add-table",
1316
- type: y.COMMAND,
1317
- handler: (t, e) => {
1318
- var p;
1319
- if (!e)
1320
- return !1;
1321
- const n = t.get(L), s = t.get(D), r = t.get(be), a = t.get(T), o = (p = e.id) != null ? p : B(), u = et(e.unitId, {
1322
- univerInstanceService: t.get(A),
1323
- tableManager: a,
1324
- definedNamesService: t.get(Pe)
1325
- });
1326
- let l = e.name;
1327
- if (!l || !Be(l.toLowerCase(), u)) {
1328
- const w = r.t("sheets-table.tablePrefix");
1329
- let R = a.getTableList(e.unitId).length + 1;
1330
- for (const O of u)
1331
- if (O.startsWith(w.toLowerCase())) {
1332
- const I = Number(O.slice(w.length));
1333
- Number.isInteger(I) && I >= R && (R = I + 1);
1334
- }
1335
- l = `${w}${R}`;
1336
- }
1337
- const i = [], h = [], { unitId: d, subUnitId: c, range: g } = e, _ = a.getColumnHeader(d, c, g, r.t("sheets-table.columnPrefix"));
1338
- return i.push({ id: k.id, params: { ...e, tableId: o, name: l, header: _ } }), h.push({ id: Q.id, params: { tableId: o, unitId: e.unitId } }), E(i, s) && n.pushUndoRedo({
1339
- unitID: e.unitId,
1340
- undoMutations: h,
1341
- redoMutations: i
1342
- }), !0;
1343
- }
1344
- }, En = {
1345
- id: "sheet.command.delete-table",
1346
- type: y.COMMAND,
1347
- handler: (t, e) => {
1348
- if (!e)
1349
- return !1;
1350
- const n = t.get(L), s = t.get(D), r = t.get(T), a = t.get(We), o = [], u = [], l = r.getTable(e.unitId, e.tableId), i = l == null ? void 0 : l.toJSON();
1351
- return i ? (o.push({ id: Q.id, params: { ...e } }), u.push({
1352
- id: k.id,
1353
- params: {
1354
- unitId: e.unitId,
1355
- subUnitId: e.subUnitId,
1356
- tableId: e.tableId,
1357
- name: i.name,
1358
- range: i.range,
1359
- options: i.options
1360
- }
1361
- }), E(o, s) && n.pushUndoRedo({
1362
- unitID: e.unitId,
1363
- undoMutations: u,
1364
- redoMutations: o
1365
- }), !0) : (a.error("[TableManager]: Table not found"), !1);
1366
- }
1367
- }, Ce = {
1368
- id: "sheet.mutation.set-table-filter",
1369
- type: y.MUTATION,
1370
- handler: (t, e) => {
1371
- const { tableId: n, unitId: s, column: r, tableFilter: a } = e;
1372
- return t.get(T).addFilter(s, n, r, a), !0;
1373
- }
1374
- }, Bn = {
1375
- id: "sheet.command.set-table-filter",
1376
- type: y.COMMAND,
1377
- handler: (t, e) => {
1378
- if (!e)
1379
- return !1;
1380
- const n = t.get(L), s = t.get(D), r = e.tableId || B(), a = [], o = [];
1381
- return a.push({ id: Ce.id, params: { ...e, tableId: r } }), o.push({ id: Ce.id, params: { ...e, tableId: r, tableFilter: void 0 } }), E(a, s) && n.pushUndoRedo({
1382
- unitID: e.unitId,
1383
- undoMutations: o,
1384
- redoMutations: a
1385
- }), !0;
1386
- }
1387
- }, at = "SHEET_TABLE_PLUGIN", re = "SHEET_TABLE", Wn = "table-custom";
1388
- var Hn = Object.getOwnPropertyDescriptor, Vn = (t, e, n, s) => {
1389
- for (var r = s > 1 ? void 0 : s ? Hn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
1390
- (o = t[a]) && (r = o(r) || r);
1391
- return r;
1392
- }, ae = (t, e) => (n, s) => e(n, s, t);
1393
- let W = class extends H {
1394
- constructor(e, n, s, r) {
1395
- super();
1396
- b(this, "_tableRangeRTree", /* @__PURE__ */ new Map());
1397
- this._univerInstanceService = e, this._sheetInterceptorService = n, this._tableManager = s, this._resourceManagerService = r, this._initSnapshot(), this._initSheetChange(), this.registerTableChangeEvent(), this.registerTableHeaderInterceptor();
1398
- }
1399
- getContainerTableWithRange(e, n, s) {
1400
- const r = this._ensureTableRangeRTree(e), o = Array.from(r.bulkSearch([{ unitId: e, sheetId: n, range: s }])).find((u) => {
1401
- const l = this._tableManager.getTable(e, String(u));
1402
- return l ? _e.contains(l.getRange(), s) : !1;
1403
- });
1404
- if (o)
1405
- return this._tableManager.getTable(e, String(o));
1406
- }
1407
- _ensureTableRangeRTree(e) {
1408
- return this._tableRangeRTree.has(e) || this._tableRangeRTree.set(e, new ct()), this._tableRangeRTree.get(e);
1409
- }
1410
- registerTableChangeEvent() {
1411
- this.disposeWithMe(
1412
- this._tableManager.tableAdd$.subscribe((e) => {
1413
- const { range: n, tableId: s, unitId: r, subUnitId: a } = e;
1414
- this._ensureTableRangeRTree(r).insert({
1415
- unitId: r,
1416
- sheetId: a,
1417
- id: s,
1418
- range: { ...n }
1419
- });
1420
- })
1421
- ), this.disposeWithMe(
1422
- this._tableManager.tableRangeChanged$.subscribe((e) => {
1423
- const { range: n, tableId: s, unitId: r, subUnitId: a, oldRange: o } = e, u = this._ensureTableRangeRTree(r);
1424
- u.remove({
1425
- unitId: r,
1426
- sheetId: a,
1427
- id: s,
1428
- range: { ...o }
1429
- }), u.insert({
1430
- unitId: r,
1431
- sheetId: a,
1432
- id: s,
1433
- range: { ...n }
1434
- });
1435
- })
1436
- ), this.disposeWithMe(
1437
- this._tableManager.tableDelete$.subscribe((e) => {
1438
- const { tableId: n, unitId: s, subUnitId: r, range: a } = e;
1439
- this._ensureTableRangeRTree(s).remove({
1440
- unitId: s,
1441
- sheetId: r,
1442
- id: n,
1443
- range: { ...a }
1444
- });
1445
- })
1446
- );
1447
- }
1448
- registerTableHeaderInterceptor() {
1449
- this.disposeWithMe(
1450
- this._sheetInterceptorService.intercept(qe.CELL_CONTENT, {
1451
- effect: dt.Value,
1452
- handler: (e, n, s) => {
1453
- const { row: r, col: a, unitId: o, subUnitId: u } = n, l = this._ensureTableRangeRTree(o);
1454
- if ((e == null ? void 0 : e.v) === void 0 && l) {
1455
- const h = Array.from(l.bulkSearch([{ unitId: o, sheetId: u, range: { startColumn: a, endColumn: a, startRow: r, endRow: r } }]));
1456
- if (h.length > 0) {
1457
- const d = this._tableManager.getTable(o, h[0]);
1458
- if (d) {
1459
- const c = d.getRange(), g = a - c.startColumn;
1460
- if (c.startRow === r) {
1461
- const f = d.getColumnNameByIndex(g);
1462
- return (!e || e === n.rawData) && (e = { ...n.rawData }), e.v = f, s(e);
1463
- }
1464
- }
1465
- }
1466
- }
1467
- return s(e);
1468
- }
1469
- })
1470
- );
1471
- }
1472
- _toJson(e) {
1473
- return this._tableManager.toJSON(e);
1474
- }
1475
- _fromJSON(e, n) {
1476
- return this._tableManager.fromJSON(e, n);
1477
- }
1478
- _deleteUnitId(e) {
1479
- this._tableManager.deleteUnitId(e);
1480
- }
1481
- _initSnapshot() {
1482
- this.disposeWithMe(this._resourceManagerService.registerPluginResource({
1483
- toJson: (e) => JSON.stringify(this._toJson(e)),
1484
- parseJson: (e) => {
1485
- if (!e)
1486
- return {};
1487
- try {
1488
- return JSON.parse(e);
1489
- } catch {
1490
- return {};
1491
- }
1492
- },
1493
- businesses: [j.UNIVER_SHEET],
1494
- pluginName: at,
1495
- onLoad: (e, n) => {
1496
- this._fromJSON(e, n);
1497
- },
1498
- onUnLoad: (e) => {
1499
- this._deleteUnitId(e);
1500
- }
1501
- }));
1502
- }
1503
- // eslint-disable-next-line max-lines-per-function
1504
- _initSheetChange() {
1505
- this.disposeWithMe(
1506
- this._sheetInterceptorService.interceptCommand({
1507
- // eslint-disable-next-line max-lines-per-function
1508
- getMutations: (e) => {
1509
- var n;
1510
- if (e.id === wt.id) {
1511
- const s = e.params, r = s.unitId || this._univerInstanceService.getCurrentUnitOfType(j.UNIVER_SHEET).getUnitId(), a = s.subUnitId || ((n = this._univerInstanceService.getCurrentUnitOfType(j.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : n.getSheetId());
1512
- if (!r || !a)
1513
- return { redos: [], undos: [] };
1514
- const o = this._tableManager.getTablesBySubunitId(r, a);
1515
- if (o.length === 0)
1516
- return { redos: [], undos: [] };
1517
- const u = [], l = [];
1518
- return o.forEach((i) => {
1519
- const h = i.toJSON();
1520
- u.push({
1521
- id: Q.id,
1522
- params: {
1523
- unitId: r,
1524
- subUnitId: a,
1525
- tableId: h.id
1526
- }
1527
- }), l.push({
1528
- id: k.id,
1529
- params: {
1530
- unitId: r,
1531
- subUnitId: a,
1532
- name: h.name,
1533
- range: h.range,
1534
- tableId: h.id,
1535
- options: {
1536
- ...h.options,
1537
- columns: h.columns,
1538
- filters: h.filters.tableColumnFilterList
1539
- }
1540
- }
1541
- });
1542
- }), { redos: u, undos: l };
1543
- } else if (e.id === ft.id) {
1544
- const s = e.params, { unitId: r, subUnitId: a, targetSubUnitId: o } = s;
1545
- if (!r || !a || !o)
1546
- return { redos: [], undos: [] };
1547
- const u = this._tableManager.getTablesBySubunitId(r, a);
1548
- if (u.length === 0)
1549
- return { redos: [], undos: [] };
1550
- const l = [], i = [];
1551
- return u.forEach((h) => {
1552
- const d = h.toJSON(), c = B();
1553
- l.push({
1554
- id: k.id,
1555
- params: {
1556
- unitId: r,
1557
- subUnitId: o,
1558
- name: d.name,
1559
- range: {
1560
- ...d.range,
1561
- sheetId: o
1562
- },
1563
- tableId: c,
1564
- options: {
1565
- ...d.options,
1566
- columns: d.columns,
1567
- filters: d.filters.tableColumnFilterList
1568
- }
1569
- }
1570
- }), i.push({
1571
- id: Q.id,
1572
- params: {
1573
- unitId: r,
1574
- subUnitId: o,
1575
- tableId: c
1576
- }
1577
- });
1578
- }), { redos: l, undos: i };
1579
- }
1580
- return { redos: [], undos: [] };
1581
- }
1582
- })
1583
- );
1584
- }
1585
- dispose() {
1586
- super.dispose(), this._tableRangeRTree.clear();
1587
- }
1588
- };
1589
- W = Vn([
1590
- ae(0, C(A)),
1591
- ae(1, C(Re)),
1592
- ae(2, C(T)),
1593
- ae(3, C(ut))
1594
- ], W);
1595
- const S = {
1596
- id: "sheet.mutation.set-sheet-table",
1597
- type: y.MUTATION,
1598
- handler: (t, e) => {
1599
- if (!e)
1600
- return !1;
1601
- const { unitId: n, tableId: s, config: r } = e;
1602
- return t.get(T).setTableByConfig(n, s, r), !0;
1603
- }
1604
- }, Pn = {
1605
- id: "sheet.command.add-table-theme",
1606
- type: y.COMMAND,
1607
- handler: (t, e) => {
1608
- if (!e)
1609
- return !1;
1610
- const n = t.get(T), { unitId: s, tableId: r, themeStyle: a } = e, o = [], u = [], l = n.getTableById(s, r);
1611
- if (!l) return !1;
1612
- const i = l.getSubunitId();
1613
- o.push({
1614
- id: Je.id,
1615
- params: {
1616
- unitId: s,
1617
- subUnitId: i,
1618
- styleJSON: a.toJson()
1619
- }
1620
- }), o.push({
1621
- id: S.id,
1622
- params: {
1623
- unitId: s,
1624
- subUnitId: i,
1625
- tableId: r,
1626
- config: {
1627
- theme: a.getName()
1628
- }
1629
- }
1630
- }), u.push({
1631
- id: S.id,
1632
- params: {
1633
- unitId: s,
1634
- subUnitId: i,
1635
- tableId: r,
1636
- config: {
1637
- themeStyle: l.getTableStyleId()
1638
- }
1639
- }
1640
- }), u.push({
1641
- id: ke.id,
1642
- params: {
1643
- unitId: s,
1644
- subUnitId: i,
1645
- styleName: a.getName()
1646
- }
1647
- });
1648
- const h = t.get(D);
1649
- return E(o, h) && t.get(L).pushUndoRedo({
1650
- unitID: s,
1651
- undoMutations: u,
1652
- redoMutations: o
1653
- }), !0;
1654
- }
1655
- }, qn = {
1656
- id: "sheet.command.remove-table-theme",
1657
- type: y.COMMAND,
1658
- handler: (t, e) => {
1659
- if (!e)
1660
- return !1;
1661
- const { unitId: n, tableId: s, themeName: r } = e, a = t.get(T), o = t.get(Qe), u = a.getTableById(n, s);
1662
- if (!u) return !1;
1663
- const l = u.getSubunitId(), i = [], h = [], d = o.getRegisteredRangeThemes().filter((w) => w == null ? void 0 : w.startsWith("table-default"));
1664
- let g = o.getRegisteredRangeThemes().filter((w) => w == null ? void 0 : w.startsWith(Wn)).find((w) => w !== r);
1665
- g || (g = d[0]), i.push({ id: S.id, params: { unitId: n, subUnitId: l, tableId: s, config: { theme: g } } }), i.push({ id: ke.id, params: { unitId: n, subUnitId: l, styleName: r } });
1666
- const _ = o.getDefaultRangeThemeStyle(r);
1667
- _ && (h.push({ id: Je.id, params: { unitId: n, subUnitId: l, styleJSON: _.toJson() } }), h.push({ id: S.id, params: { unitId: n, subUnitId: l, tableId: s, config: { theme: r } } }));
1668
- const f = t.get(D);
1669
- return E(i, f) && t.get(L).pushUndoRedo({
1670
- unitID: n,
1671
- redoMutations: i,
1672
- undoMutations: h
1673
- }), !0;
1674
- }
1675
- }, Jn = {
1676
- id: "sheet.command.set-table-config",
1677
- type: y.COMMAND,
1678
- // eslint-disable-next-line max-lines-per-function
1679
- handler: (t, e) => {
1680
- if (!e)
1681
- return !1;
1682
- const { unitId: n, tableId: s, name: r, updateRange: a, rowColOperation: o, theme: u } = e, l = t.get(T), i = l.getTableById(n, s);
1683
- if (!i) return !1;
1684
- const h = {}, d = {}, c = t.get(be), g = et(n, {
1685
- univerInstanceService: t.get(A),
1686
- tableManager: l,
1687
- definedNamesService: t.get(Pe)
1688
- });
1689
- if (r) {
1690
- if (!Be(r.toLowerCase(), g))
1691
- return t.get(We).warn(c.t("sheets-table.tableNameError")), !1;
1692
- h.name = i.getDisplayName(), d.name = r;
1693
- }
1694
- o && (h.rowColOperation = {
1695
- operationType: o.operationType === M.Insert ? M.Delete : M.Insert,
1696
- rowColType: o.rowColType,
1697
- index: o.index,
1698
- count: o.count
1699
- }, d.rowColOperation = o), a && (h.updateRange = {
1700
- newRange: i.getRange()
1701
- }, d.updateRange = a), u && (h.theme = i.getTableStyleId(), d.theme = u);
1702
- const _ = {
1703
- unitId: n,
1704
- subUnitId: i.getSubunitId(),
1705
- tableId: s,
1706
- config: d
1707
- };
1708
- return t.get(D).executeCommand(S.id, _), t.get(L).pushUndoRedo({
1709
- unitID: n,
1710
- undoMutations: [
1711
- {
1712
- id: S.id,
1713
- params: {
1714
- unitId: n,
1715
- subUnitId: i.getSubunitId(),
1716
- tableId: s,
1717
- config: h
1718
- }
1719
- }
1720
- ],
1721
- redoMutations: [
1722
- {
1723
- id: S.id,
1724
- params: _
1725
- }
1726
- ]
1727
- }), !0;
1728
- }
1729
- }, kn = {
1730
- id: "sheet.command.table-insert-row",
1731
- type: y.COMMAND,
1732
- handler: (t) => {
1733
- const e = t.get(A), n = $(e);
1734
- if (!n)
1735
- return !1;
1736
- const { workbook: s, worksheet: r, unitId: a, subUnitId: o } = n, l = t.get(we).getCurrentSelections();
1737
- if (!l.length || l.length > 1)
1738
- return !1;
1739
- t.get(T);
1740
- const h = l[0].range, c = t.get(W).getContainerTableWithRange(a, o, h);
1741
- if (!c) return !1;
1742
- const g = h.endRow - h.startRow + 1, f = r.getRowCount() - 1, p = r.getCellMatrix().getDataRange().endRow, w = [], R = [];
1743
- if (f - p < g)
1744
- w.push({
1745
- id: Ye.id,
1746
- params: {
1747
- unitId: a,
1748
- subUnitId: o,
1749
- range: { ...h }
1750
- }
1751
- }), w.push({
1752
- id: S.id,
1753
- params: {
1754
- unitId: a,
1755
- subUnitId: o,
1756
- tableId: c.getId(),
1757
- config: {
1758
- updateRange: {
1759
- newRange: {
1760
- ...c.getRange(),
1761
- endRow: c.getRange().endRow + g
1762
- }
1763
- }
1764
- }
1765
- }
1766
- }), R.push({
1767
- id: S.id,
1768
- params: {
1769
- unitId: a,
1770
- subUnitId: o,
1771
- tableId: c.getId(),
1772
- config: {
1773
- updateRange: {
1774
- newRange: c.getRange()
1775
- }
1776
- }
1777
- }
1778
- }), R.push({
1779
- id: Ge.id,
1780
- params: {
1781
- unitId: a,
1782
- subUnitId: o,
1783
- range: { ...h }
1784
- }
1785
- });
1786
- else {
1787
- const v = { ...c.getRange() };
1788
- w.push({
1789
- id: S.id,
1790
- params: {
1791
- unitId: a,
1792
- subUnitId: o,
1793
- tableId: c.getId(),
1794
- config: {
1795
- updateRange: {
1796
- newRange: {
1797
- ...v,
1798
- endRow: v.endRow + g
1799
- }
1800
- }
1801
- }
1802
- }
1803
- }), R.push({
1804
- id: S.id,
1805
- params: {
1806
- unitId: a,
1807
- subUnitId: o,
1808
- tableId: c.getId(),
1809
- config: {
1810
- updateRange: {
1811
- newRange: { ...v }
1812
- }
1813
- }
1814
- }
1815
- });
1816
- const ee = fe(
1817
- t,
1818
- {
1819
- unitId: a,
1820
- subUnitId: o,
1821
- range: {
1822
- startRow: h.startRow,
1823
- endRow: p,
1824
- startColumn: v.startColumn,
1825
- endColumn: v.endColumn
1826
- }
1827
- },
1828
- {
1829
- unitId: a,
1830
- subUnitId: o,
1831
- range: {
1832
- startRow: h.startRow + g,
1833
- endRow: p + g,
1834
- startColumn: v.startColumn,
1835
- endColumn: v.endColumn
1836
- }
1837
- }
1838
- );
1839
- ee && (w.push(...ee.redos), R.push(...ee.undos));
1840
- }
1841
- const O = t.get(D);
1842
- return E(w, O) && t.get(L).pushUndoRedo({
1843
- unitID: a,
1844
- undoMutations: R,
1845
- redoMutations: w
1846
- }), !0;
1847
- }
1848
- }, Qn = {
1849
- id: "sheet.command.table-insert-col",
1850
- type: y.COMMAND,
1851
- handler: (t) => {
1852
- const e = t.get(A), n = $(e);
1853
- if (!n)
1854
- return !1;
1855
- const { worksheet: s, unitId: r, subUnitId: a } = n, u = t.get(we).getCurrentSelections();
1856
- if (!u.length || u.length > 1)
1857
- return !1;
1858
- const i = u[0].range, d = t.get(W).getContainerTableWithRange(r, a, i);
1859
- if (!d) return !1;
1860
- const c = i.endColumn - i.startColumn + 1, _ = s.getColumnCount() - 1, f = s.getCellMatrix().getDataRange().endColumn, p = [], w = [];
1861
- if (_ - f < c)
1862
- p.push({
1863
- id: je.id,
1864
- params: {
1865
- unitId: r,
1866
- subUnitId: a,
1867
- range: { ...i }
1868
- }
1869
- }), p.push({
1870
- id: S.id,
1871
- params: {
1872
- unitId: r,
1873
- subUnitId: a,
1874
- tableId: d.getId(),
1875
- config: {
1876
- rowColOperation: {
1877
- operationType: M.Insert,
1878
- rowColType: N.Col,
1879
- index: i.startColumn,
1880
- count: c
1881
- }
1882
- }
1883
- }
1884
- }), w.push({
1885
- id: S.id,
1886
- params: {
1887
- unitId: r,
1888
- subUnitId: a,
1889
- tableId: d.getId(),
1890
- config: {
1891
- rowColOperation: {
1892
- operationType: M.Delete,
1893
- rowColType: N.Col,
1894
- index: i.startColumn,
1895
- count: c
1896
- }
1897
- }
1898
- }
1899
- }), w.push({
1900
- id: ze.id,
1901
- params: {
1902
- unitId: r,
1903
- subUnitId: a,
1904
- range: { ...i }
1905
- }
1906
- });
1907
- else {
1908
- const I = d.getRange();
1909
- p.push({
1910
- id: S.id,
1911
- params: {
1912
- unitId: r,
1913
- subUnitId: a,
1914
- tableId: d.getId(),
1915
- config: {
1916
- rowColOperation: {
1917
- operationType: M.Insert,
1918
- rowColType: N.Col,
1919
- index: i.startColumn,
1920
- count: c
1921
- }
1922
- }
1923
- }
1924
- }), w.push({
1925
- id: S.id,
1926
- params: {
1927
- unitId: r,
1928
- subUnitId: a,
1929
- tableId: d.getId(),
1930
- config: {
1931
- rowColOperation: {
1932
- operationType: M.Delete,
1933
- rowColType: N.Col,
1934
- index: i.startColumn,
1935
- count: c
1936
- }
1937
- }
1938
- }
1939
- });
1940
- const v = fe(
1941
- t,
1942
- {
1943
- unitId: r,
1944
- subUnitId: a,
1945
- range: {
1946
- startRow: I.startRow,
1947
- endRow: I.endRow,
1948
- startColumn: i.startColumn,
1949
- endColumn: f
1950
- }
1951
- },
1952
- {
1953
- unitId: r,
1954
- subUnitId: a,
1955
- range: {
1956
- startRow: I.startRow,
1957
- endRow: I.endRow,
1958
- startColumn: i.startColumn + c,
1959
- endColumn: f + c
1960
- }
1961
- }
1962
- );
1963
- v && (p.push(...v.redos), w.push(...v.undos));
1964
- }
1965
- const R = t.get(D);
1966
- return E(p, R) && t.get(L).pushUndoRedo({
1967
- unitID: r,
1968
- undoMutations: w,
1969
- redoMutations: p
1970
- }), !0;
1971
- }
1972
- }, Yn = {
1973
- id: "sheet.command.table-remove-row",
1974
- type: y.COMMAND,
1975
- handler: (t, e) => {
1976
- if (!e)
1977
- return !1;
1978
- const n = t.get(A), s = $(n, e);
1979
- if (!s)
1980
- return !1;
1981
- const { unitId: r, subUnitId: a } = s, u = t.get(we).getCurrentSelections();
1982
- if (!u.length || u.length > 1)
1983
- return !1;
1984
- const i = u[0].range, d = t.get(W).getContainerTableWithRange(r, a, i);
1985
- if (!d) return !1;
1986
- const c = i.endRow - i.startRow + 1, g = [], _ = [], f = d.getRange();
1987
- g.push({
1988
- id: S.id,
1989
- params: {
1990
- unitId: r,
1991
- subUnitId: a,
1992
- tableId: d.getId(),
1993
- config: {
1994
- updateRange: {
1995
- newRange: {
1996
- ...f,
1997
- endRow: f.endRow - c
1998
- }
1999
- }
2000
- }
2001
- }
2002
- }), _.push({
2003
- id: S.id,
2004
- params: {
2005
- unitId: r,
2006
- subUnitId: a,
2007
- tableId: d.getId(),
2008
- config: {
2009
- updateRange: {
2010
- newRange: { ...f }
2011
- }
2012
- }
2013
- }
2014
- });
2015
- const w = s.worksheet.getCellMatrix().getDataRange().endRow, R = fe(
2016
- t,
2017
- {
2018
- unitId: r,
2019
- subUnitId: a,
2020
- range: {
2021
- startRow: i.endRow + 1,
2022
- endRow: w,
2023
- startColumn: f.startColumn,
2024
- endColumn: f.endColumn
2025
- }
2026
- },
2027
- {
2028
- unitId: r,
2029
- subUnitId: a,
2030
- range: {
2031
- startRow: i.startRow,
2032
- endRow: w - c,
2033
- startColumn: f.startColumn,
2034
- endColumn: f.endColumn
2035
- }
2036
- }
2037
- );
2038
- R && (g.push(...R.redos), _.push(...R.undos));
2039
- const O = t.get(D);
2040
- return E(g, O) && t.get(L).pushUndoRedo({
2041
- unitID: r,
2042
- undoMutations: _,
2043
- redoMutations: g
2044
- }), !0;
2045
- }
2046
- }, Gn = {
2047
- id: "sheet.command.table-remove-col",
2048
- type: y.COMMAND,
2049
- handler: (t, e) => {
2050
- if (!e)
2051
- return !1;
2052
- const n = t.get(A), s = $(n, e);
2053
- if (!s)
2054
- return !1;
2055
- const { workbook: r, unitId: a, subUnitId: o } = s;
2056
- t.get(T);
2057
- const l = t.get(we).getCurrentSelections();
2058
- if (!l.length || l.length > 1)
2059
- return !1;
2060
- const h = l[0].range, c = t.get(W).getContainerTableWithRange(a, o, h);
2061
- if (!c) return !1;
2062
- const g = h.endColumn - h.startColumn + 1, _ = [], f = [], p = c.getRange();
2063
- _.push({
2064
- id: S.id,
2065
- params: {
2066
- unitId: a,
2067
- subUnitId: o,
2068
- tableId: c.getId(),
2069
- config: {
2070
- rowColOperation: {
2071
- operationType: M.Delete,
2072
- rowColType: N.Col,
2073
- index: h.startColumn,
2074
- count: g
2075
- }
2076
- }
2077
- }
2078
- });
2079
- const w = [], R = h.startColumn - p.startColumn;
2080
- for (let se = 0; se < g; se++) {
2081
- const Ie = c.getTableInfo().columns[R + se];
2082
- Ie && w.push(Ie);
2083
- }
2084
- f.push({
2085
- id: S.id,
2086
- params: {
2087
- unitId: a,
2088
- subUnitId: o,
2089
- tableId: c.getId(),
2090
- config: {
2091
- rowColOperation: {
2092
- operationType: M.Insert,
2093
- rowColType: N.Col,
2094
- index: h.startColumn,
2095
- count: g,
2096
- columnsJson: w
2097
- }
2098
- }
2099
- }
2100
- });
2101
- const I = s.worksheet.getCellMatrix().getDataRange().endColumn, v = fe(
2102
- t,
2103
- {
2104
- unitId: a,
2105
- subUnitId: o,
2106
- range: {
2107
- startRow: p.startRow,
2108
- endRow: p.endRow,
2109
- startColumn: h.endColumn + 1,
2110
- endColumn: I
2111
- }
2112
- },
2113
- {
2114
- unitId: a,
2115
- subUnitId: o,
2116
- range: {
2117
- startRow: p.startRow,
2118
- endRow: p.endRow,
2119
- startColumn: h.startColumn,
2120
- endColumn: I - g
2121
- }
2122
- }
2123
- );
2124
- v && (_.push(...v.redos), f.push(...v.undos));
2125
- const ee = t.get(D);
2126
- return E(_, ee) && t.get(L).pushUndoRedo({
2127
- unitID: a,
2128
- undoMutations: f,
2129
- redoMutations: _
2130
- }), !0;
2131
- }
2132
- };
2133
- var jn = Object.getOwnPropertyDescriptor, zn = (t, e, n, s) => {
2134
- for (var r = s > 1 ? void 0 : s ? jn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
2135
- (o = t[a]) && (r = o(r) || r);
2136
- return r;
2137
- }, Ae = (t, e) => (n, s) => e(n, s, t);
2138
- let ce = class extends H {
2139
- constructor(t, e) {
2140
- super(), this._tableManager = t, this._commandService = e, this._initRangeListener();
2141
- }
2142
- _initRangeListener() {
2143
- this.disposeWithMe(
2144
- this._tableManager.tableRangeChanged$.subscribe((t) => {
2145
- const { tableId: e, unitId: n } = t, s = this._tableManager.getTableById(n, e);
2146
- s && this._updateSuperTable(n, s);
2147
- })
2148
- ), this.disposeWithMe(
2149
- this._tableManager.tableAdd$.subscribe((t) => {
2150
- const { tableId: e, unitId: n } = t, s = this._tableManager.getTableById(n, e);
2151
- s && this._updateSuperTable(n, s);
2152
- })
2153
- ), this.disposeWithMe(
2154
- this._tableManager.tableDelete$.subscribe((t) => {
2155
- const { unitId: e, tableName: n } = t;
2156
- this._commandService.executeCommand(ve.id, {
2157
- unitId: e,
2158
- tableName: n
2159
- });
2160
- })
2161
- ), this.disposeWithMe(
2162
- this._tableManager.tableNameChanged$.subscribe((t) => {
2163
- const { tableId: e, unitId: n, oldTableName: s } = t;
2164
- this._commandService.executeCommand(ve.id, {
2165
- unitId: n,
2166
- tableName: s
2167
- });
2168
- const r = this._tableManager.getTableById(n, e);
2169
- r && this._updateSuperTable(n, r);
2170
- })
2171
- );
2172
- }
2173
- _updateSuperTable(t, e) {
2174
- const n = e.getTableInfo(), s = n.name, r = n.columns, a = /* @__PURE__ */ new Map();
2175
- r.forEach((o, u) => {
2176
- a.set(o.displayName, u);
2177
- }), this._commandService.executeCommand(bt.id, {
2178
- unitId: t,
2179
- tableName: s,
2180
- reference: {
2181
- range: n.range,
2182
- sheetId: n.subUnitId,
2183
- titleMap: a
2184
- }
2185
- });
2186
- }
2187
- };
2188
- ce = zn([
2189
- Ae(0, C(T)),
2190
- Ae(1, D)
2191
- ], ce);
2192
- var Kn = Object.getOwnPropertyDescriptor, Xn = (t, e, n, s) => {
2193
- for (var r = s > 1 ? void 0 : s ? Kn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
2194
- (o = t[a]) && (r = o(r) || r);
2195
- return r;
2196
- }, Le = (t, e) => (n, s) => e(n, s, t);
2197
- let de = class extends H {
2198
- constructor(t, e) {
2199
- super(), this._tableManager = t, this._exclusiveRangeService = e, this._initRangeListener();
2200
- }
2201
- _initRangeListener() {
2202
- this.disposeWithMe(
2203
- this._tableManager.tableRangeChanged$.subscribe((t) => {
2204
- const { range: e, tableId: n, unitId: s, subUnitId: r } = t;
2205
- this._exclusiveRangeService.clearExclusiveRangesByGroupId(s, r, re, n), this._exclusiveRangeService.addExclusiveRange(s, r, re, [{
2206
- range: { ...e },
2207
- groupId: n
2208
- }]);
2209
- })
2210
- ), this.disposeWithMe(
2211
- this._tableManager.tableAdd$.subscribe((t) => {
2212
- const { tableId: e, unitId: n, subUnitId: s, range: r } = t;
2213
- this._exclusiveRangeService.addExclusiveRange(n, s, re, [{
2214
- range: { ...r },
2215
- groupId: e
2216
- }]);
2217
- })
2218
- ), this.disposeWithMe(
2219
- this._tableManager.tableDelete$.subscribe((t) => {
2220
- const { tableId: e, unitId: n, subUnitId: s } = t;
2221
- this._exclusiveRangeService.clearExclusiveRangesByGroupId(n, s, re, e);
2222
- })
2223
- );
2224
- }
2225
- };
2226
- de = Xn([
2227
- Le(0, C(T)),
2228
- Le(1, C(pt))
2229
- ], de);
2230
- var Zn = Object.getOwnPropertyDescriptor, es = (t, e, n, s) => {
2231
- for (var r = s > 1 ? void 0 : s ? Zn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
2232
- (o = t[a]) && (r = o(r) || r);
2233
- return r;
2234
- }, V = (t, e) => (n, s) => e(n, s, t);
2235
- let he = class extends H {
2236
- constructor(t, e, n, s, r, a, o) {
2237
- super(), this._commandService = t, this._refRangeService = e, this._univerInstanceService = n, this._injector = s, this._sheetInterceptorService = r, this._tableManager = a, this._localeService = o, this._initCommandInterceptor(), this._initCommandListener();
2238
- }
2239
- _initCommandInterceptor() {
2240
- const t = this;
2241
- this._sheetInterceptorService.interceptCommand({
2242
- getMutations(e) {
2243
- const n = { redos: [], undos: [] }, { id: s, params: r } = e;
2244
- switch (s) {
2245
- case Tt.id:
2246
- return t._generateTableMutationWithInsertRow(r);
2247
- case Rt.id:
2248
- return t._generateTableMutationWithInsertCol(r);
2249
- case Ct.id:
2250
- return t._generateTableMutationWithRemoveRow(r);
2251
- case _t.id:
2252
- return t._generateTableMutationWithRemoveCol(r);
2253
- }
2254
- return n;
2255
- }
2256
- });
2257
- }
2258
- _generateTableMutationWithInsertRow(t) {
2259
- const e = [], n = [], s = $(this._univerInstanceService, t);
2260
- if (!s)
2261
- return { undos: e, redos: n };
2262
- const { unitId: r, subUnitId: a } = s, o = this._tableManager.getTablesBySubunitId(r, a);
2263
- if (!o.length)
2264
- return { undos: e, redos: n };
2265
- const { range: u } = t;
2266
- return o.forEach((l) => {
2267
- const i = l.getRange();
2268
- if (u.startRow > i.startRow && u.startRow <= i.endRow) {
2269
- const h = u.endRow - u.startRow + 1;
2270
- n.push({
2271
- id: S.id,
2272
- params: {
2273
- unitId: r,
2274
- subUnitId: a,
2275
- tableId: l.getId(),
2276
- config: {
2277
- updateRange: {
2278
- newRange: {
2279
- ...i,
2280
- endRow: i.endRow + h
2281
- }
2282
- }
2283
- }
2284
- }
2285
- }), e.push({
2286
- id: S.id,
2287
- params: {
2288
- unitId: r,
2289
- subUnitId: a,
2290
- tableId: l.getId(),
2291
- config: {
2292
- updateRange: {
2293
- newRange: {
2294
- ...i
2295
- }
2296
- }
2297
- }
2298
- }
2299
- });
2300
- }
2301
- }), { undos: e, redos: n };
2302
- }
2303
- _generateTableMutationWithInsertCol(t) {
2304
- const e = [], n = [], s = $(this._univerInstanceService, t);
2305
- if (!s)
2306
- return { undos: e, redos: n };
2307
- const { unitId: r, subUnitId: a } = s, o = this._tableManager.getTablesBySubunitId(r, a);
2308
- if (!o.length)
2309
- return { undos: e, redos: n };
2310
- const { range: u } = t;
2311
- return o.forEach((l) => {
2312
- const i = l.getRange();
2313
- if (u.startColumn > i.startColumn && u.startColumn <= i.endColumn) {
2314
- const h = u.endColumn - u.startColumn + 1;
2315
- n.push({
2316
- id: S.id,
2317
- params: {
2318
- unitId: r,
2319
- subUnitId: a,
2320
- tableId: l.getId(),
2321
- config: {
2322
- rowColOperation: {
2323
- operationType: M.Insert,
2324
- rowColType: N.Col,
2325
- index: u.startColumn,
2326
- count: h
2327
- }
2328
- }
2329
- }
2330
- }), e.push({
2331
- id: S.id,
2332
- params: {
2333
- unitId: r,
2334
- subUnitId: a,
2335
- tableId: l.getId(),
2336
- config: {
2337
- rowColOperation: {
2338
- operationType: M.Delete,
2339
- rowColType: N.Col,
2340
- index: u.startColumn,
2341
- count: h
2342
- }
2343
- }
2344
- }
2345
- });
2346
- }
2347
- }), { undos: e, redos: n };
2348
- }
2349
- _generateTableMutationWithRemoveRow(t) {
2350
- const e = [], n = [], s = [], r = [], a = $(this._univerInstanceService);
2351
- if (!a)
2352
- return { undos: e, redos: n, preRedos: s, preUndos: r };
2353
- const { unitId: o, subUnitId: u } = a, l = this._tableManager.getTablesBySubunitId(o, u);
2354
- if (!l.length)
2355
- return { undos: e, redos: n, preRedos: s, preUndos: r };
2356
- const { range: i } = t, h = i.endRow - i.startRow + 1;
2357
- return l.forEach((d) => {
2358
- const c = d.getRange();
2359
- if (_e.intersects(c, i))
2360
- if (i.startRow <= c.startRow && i.endRow >= c.startRow) {
2361
- s.push({
2362
- id: Q.id,
2363
- params: {
2364
- unitId: o,
2365
- subUnitId: u,
2366
- tableId: d.getId()
2367
- }
2368
- });
2369
- const g = d.toJSON();
2370
- e.push({
2371
- id: k.id,
2372
- params: {
2373
- unitId: o,
2374
- subUnitId: u,
2375
- tableId: g.id,
2376
- name: g.name,
2377
- range: g.range,
2378
- options: g.options
2379
- }
2380
- });
2381
- } else i.startRow > c.startRow && i.startRow <= c.endRow ? (n.push({
2382
- id: S.id,
2383
- params: {
2384
- unitId: o,
2385
- subUnitId: u,
2386
- tableId: d.getId(),
2387
- config: {
2388
- updateRange: {
2389
- newRange: {
2390
- ...c,
2391
- endRow: c.endRow - h
2392
- }
2393
- }
2394
- }
2395
- }
2396
- }), e.push({
2397
- id: S.id,
2398
- params: {
2399
- unitId: o,
2400
- subUnitId: u,
2401
- tableId: d.getId(),
2402
- config: {
2403
- updateRange: {
2404
- newRange: {
2405
- ...c
2406
- }
2407
- }
2408
- }
2409
- }
2410
- })) : i.startRow < c.endRow && i.endRow >= c.endRow && (n.push({
2411
- id: S.id,
2412
- params: {
2413
- unitId: o,
2414
- subUnitId: u,
2415
- tableId: d.getId(),
2416
- config: {
2417
- updateRange: {
2418
- newRange: {
2419
- ...c,
2420
- endRow: i.startRow - 1
2421
- }
2422
- }
2423
- }
2424
- }
2425
- }), e.push({
2426
- id: S.id,
2427
- params: {
2428
- unitId: o,
2429
- subUnitId: u,
2430
- tableId: d.getId(),
2431
- config: {
2432
- updateRange: {
2433
- newRange: {
2434
- ...c
2435
- }
2436
- }
2437
- }
2438
- }
2439
- }));
2440
- }), { undos: e, redos: n, preRedos: s, preUndos: r };
2441
- }
2442
- _generateTableMutationWithRemoveCol(t) {
2443
- const e = [], n = [], s = [], r = [], a = $(this._univerInstanceService);
2444
- if (!a)
2445
- return { undos: e, redos: n, preRedos: s, preUndos: r };
2446
- const { unitId: o, subUnitId: u } = a, l = this._tableManager.getTablesBySubunitId(o, u);
2447
- if (!l.length)
2448
- return { undos: e, redos: n, preRedos: s, preUndos: r };
2449
- const { range: i } = t, h = i.endColumn - i.startColumn + 1;
2450
- return l.forEach((d) => {
2451
- const c = d.getRange();
2452
- if (_e.intersects(c, i)) {
2453
- if (i.startColumn <= c.startColumn && i.endColumn >= c.endColumn) {
2454
- s.push({
2455
- id: Q.id,
2456
- params: {
2457
- unitId: o,
2458
- subUnitId: u,
2459
- tableId: d.getId()
2460
- }
2461
- });
2462
- const g = d.toJSON(), { startRow: _, startColumn: f, endColumn: p } = g.range, w = this._univerInstanceService.getUnit(o), R = w == null ? void 0 : w.getSheetBySheetId(u);
2463
- if (!R)
2464
- return { undos: e, redos: n, preRedos: s, preUndos: r };
2465
- const O = [];
2466
- for (let I = f; I <= p; I++)
2467
- O.push(Ze(R == null ? void 0 : R.getCell(_, I)) || te(I - f + 1, this._localeService.t("sheets-table.columnPrefix")));
2468
- e.push({
2469
- id: k.id,
2470
- params: {
2471
- unitId: o,
2472
- subUnitId: u,
2473
- tableId: g.id,
2474
- name: g.name,
2475
- header: O,
2476
- range: g.range,
2477
- options: g.options
2478
- }
2479
- });
2480
- } else if (i.startColumn <= c.startColumn && i.endColumn >= c.startColumn) {
2481
- const g = i.endColumn - c.startColumn + 1;
2482
- n.push({
2483
- id: S.id,
2484
- params: {
2485
- unitId: o,
2486
- subUnitId: u,
2487
- tableId: d.getId(),
2488
- config: {
2489
- rowColOperation: {
2490
- operationType: M.Delete,
2491
- rowColType: N.Col,
2492
- index: c.startColumn,
2493
- count: g
2494
- }
2495
- }
2496
- }
2497
- });
2498
- const _ = [];
2499
- for (let f = 0; f < g; f++) {
2500
- const p = d.getTableColumnByIndex(f);
2501
- p && _.push(p.toJSON());
2502
- }
2503
- e.push({
2504
- id: S.id,
2505
- params: {
2506
- unitId: o,
2507
- subUnitId: u,
2508
- tableId: d.getId(),
2509
- config: {
2510
- rowColOperation: {
2511
- operationType: M.Insert,
2512
- rowColType: N.Col,
2513
- index: c.startColumn,
2514
- count: g,
2515
- columnsJson: _
2516
- }
2517
- }
2518
- }
2519
- });
2520
- } else if (i.startColumn > c.startColumn && i.endColumn > c.endColumn) {
2521
- const g = c.endColumn - i.startColumn + 1;
2522
- n.push({
2523
- id: S.id,
2524
- params: {
2525
- unitId: o,
2526
- subUnitId: u,
2527
- tableId: d.getId(),
2528
- config: {
2529
- rowColOperation: {
2530
- operationType: M.Delete,
2531
- rowColType: N.Col,
2532
- index: i.startColumn,
2533
- count: g
2534
- }
2535
- }
2536
- }
2537
- });
2538
- const _ = [], f = i.startColumn - c.startColumn;
2539
- for (let p = 0; p < g; p++) {
2540
- const w = d.getTableColumnByIndex(p + f);
2541
- w && _.push(w.toJSON());
2542
- }
2543
- e.push({
2544
- id: S.id,
2545
- params: {
2546
- unitId: o,
2547
- subUnitId: u,
2548
- tableId: d.getId(),
2549
- config: {
2550
- rowColOperation: {
2551
- operationType: M.Insert,
2552
- rowColType: N.Col,
2553
- index: i.startColumn,
2554
- count: h,
2555
- columnsJson: _
2556
- }
2557
- }
2558
- }
2559
- });
2560
- } else if (i.startColumn > c.startColumn && i.endColumn <= c.endColumn) {
2561
- n.push({
2562
- id: S.id,
2563
- params: {
2564
- unitId: o,
2565
- subUnitId: u,
2566
- tableId: d.getId(),
2567
- config: {
2568
- rowColOperation: {
2569
- operationType: M.Delete,
2570
- rowColType: N.Col,
2571
- index: i.startColumn,
2572
- count: h
2573
- }
2574
- }
2575
- }
2576
- });
2577
- const g = [], _ = i.startColumn - c.startColumn;
2578
- for (let f = 0; f < h; f++) {
2579
- const p = d.getTableColumnByIndex(f + _);
2580
- p && g.push(p.toJSON());
2581
- }
2582
- e.push({
2583
- id: S.id,
2584
- params: {
2585
- unitId: o,
2586
- subUnitId: u,
2587
- tableId: d.getId(),
2588
- config: {
2589
- rowColOperation: {
2590
- operationType: M.Insert,
2591
- rowColType: N.Col,
2592
- index: i.startColumn,
2593
- count: h,
2594
- columnsJson: g
2595
- }
2596
- }
2597
- }
2598
- });
2599
- }
2600
- }
2601
- }), { undos: e, redos: n, preRedos: s, preUndos: r };
2602
- }
2603
- _initCommandListener() {
2604
- this._commandService.onCommandExecuted((t) => {
2605
- if (t.id === Ye.id) {
2606
- const e = t.params, { unitId: n, subUnitId: s, range: r } = e, a = r.endRow - r.startRow + 1;
2607
- this._tableManager.getTablesBySubunitId(n, s).forEach((u) => {
2608
- const l = u.getRange();
2609
- r.startRow <= l.startRow && this._tableManager.updateTableRange(n, u.getId(), {
2610
- newRange: {
2611
- ...l,
2612
- startRow: l.startRow + a,
2613
- endRow: l.endRow + a
2614
- }
2615
- });
2616
- });
2617
- } else if (t.id === je.id) {
2618
- const e = t.params, { unitId: n, subUnitId: s, range: r } = e, a = r.endColumn - r.startColumn + 1;
2619
- this._tableManager.getTablesBySubunitId(n, s).forEach((u) => {
2620
- const l = u.getRange();
2621
- r.startColumn <= l.startColumn && this._tableManager.updateTableRange(n, u.getId(), {
2622
- newRange: {
2623
- ...l,
2624
- startColumn: l.startColumn + a,
2625
- endColumn: l.endColumn + a
2626
- }
2627
- });
2628
- });
2629
- } else if (t.id === Ge.id) {
2630
- const e = t.params, { unitId: n, subUnitId: s, range: r } = e, a = r.endRow - r.startRow + 1;
2631
- this._tableManager.getTablesBySubunitId(n, s).forEach((u) => {
2632
- const l = u.getRange();
2633
- r.startRow < l.startRow && this._tableManager.updateTableRange(n, u.getId(), {
2634
- newRange: {
2635
- ...l,
2636
- startRow: l.startRow - a,
2637
- endRow: l.endRow - a
2638
- }
2639
- });
2640
- });
2641
- } else if (t.id === ze.id) {
2642
- const e = t.params, { unitId: n, subUnitId: s, range: r } = e, a = r.endColumn - r.startColumn + 1;
2643
- this._tableManager.getTablesBySubunitId(n, s).forEach((u) => {
2644
- const l = u.getRange();
2645
- r.startColumn < l.startColumn && this._tableManager.updateTableRange(n, u.getId(), {
2646
- newRange: {
2647
- ...l,
2648
- startColumn: l.startColumn - a,
2649
- endColumn: l.endColumn - a
2650
- }
2651
- });
2652
- });
2653
- }
2654
- });
2655
- }
2656
- };
2657
- he = es([
2658
- V(0, C(D)),
2659
- V(1, C(St)),
2660
- V(2, C(A)),
2661
- V(3, C(He)),
2662
- V(4, C(Re)),
2663
- V(5, C(T)),
2664
- V(6, C(be))
2665
- ], he);
2666
- var ts = Object.getOwnPropertyDescriptor, ns = (t, e, n, s) => {
2667
- for (var r = s > 1 ? void 0 : s ? ts(e, n) : e, a = t.length - 1, o; a >= 0; a--)
2668
- (o = t[a]) && (r = o(r) || r);
2669
- return r;
2670
- }, oe = (t, e) => (n, s) => e(n, s, t);
2671
- let ge = class extends H {
2672
- constructor(e, n, s, r) {
2673
- super();
2674
- b(this, "_defaultThemeIndex", 0);
2675
- b(this, "_allThemes", []);
2676
- this._tableManager = e, this._sheetRangeThemeService = n, this._sheetRangeThemeModel = s, this._configService = r, this._initUserTableTheme(), this.registerTableChangeEvent(), this._initDefaultTableTheme();
2677
- }
2678
- registerTableChangeEvent() {
2679
- this.disposeWithMe(
2680
- this._tableManager.tableAdd$.subscribe((e) => {
2681
- const { range: n, tableId: s, unitId: r, subUnitId: a, tableStyleId: o } = e, u = this._tableManager.getTable(r, s), l = o || this._allThemes[this._defaultThemeIndex].name;
2682
- u.setTableStyleId(l), this._sheetRangeThemeService.registerRangeThemeStyle(l, {
2683
- unitId: r,
2684
- subUnitId: a,
2685
- range: { ...n }
2686
- });
2687
- })
2688
- ), this.disposeWithMe(
2689
- this._tableManager.tableRangeChanged$.subscribe((e) => {
2690
- const { range: n, oldRange: s, tableId: r, unitId: a, subUnitId: o } = e, u = this._tableManager.getTable(a, r);
2691
- let l = u.getTableStyleId();
2692
- l || (l = this._allThemes[this._defaultThemeIndex].name, u.setTableStyleId(l)), this._sheetRangeThemeService.removeRangeThemeRule(l, {
2693
- unitId: a,
2694
- subUnitId: o,
2695
- range: { ...s }
2696
- }), this._sheetRangeThemeService.registerRangeThemeStyle(l, {
2697
- unitId: a,
2698
- subUnitId: o,
2699
- range: { ...n }
2700
- });
2701
- })
2702
- ), this.disposeWithMe(
2703
- this._tableManager.tableThemeChanged$.subscribe((e) => {
2704
- const { theme: n, oldTheme: s, tableId: r, unitId: a, subUnitId: o } = e, l = this._tableManager.getTable(a, r).getRange();
2705
- this._sheetRangeThemeService.removeRangeThemeRule(s, {
2706
- unitId: a,
2707
- subUnitId: o,
2708
- range: { ...l }
2709
- }), this._sheetRangeThemeService.registerRangeThemeStyle(n, {
2710
- unitId: a,
2711
- subUnitId: o,
2712
- range: { ...l }
2713
- });
2714
- })
2715
- ), this.disposeWithMe(
2716
- this._tableManager.tableDelete$.subscribe((e) => {
2717
- const { range: n, unitId: s, subUnitId: r, tableStyleId: a = this._allThemes[this._defaultThemeIndex].name } = e;
2718
- this._sheetRangeThemeService.removeRangeThemeRule(a, {
2719
- unitId: s,
2720
- subUnitId: r,
2721
- range: { ...n }
2722
- });
2723
- })
2724
- );
2725
- }
2726
- _initUserTableTheme() {
2727
- const e = this._configService.getConfig(tt) || {}, n = e.defaultThemeIndex || 0, s = e.userThemes || [];
2728
- this._defaultThemeIndex = n, this._allThemes = s.concat(nt);
2729
- }
2730
- _initDefaultTableTheme() {
2731
- for (let e = 0; e < this._allThemes.length; e++) {
2732
- const { name: n, style: s } = this._allThemes[e], r = new Mt(n, s);
2733
- this._sheetRangeThemeModel.registerDefaultRangeTheme(r);
2734
- }
2735
- }
2736
- dispose() {
2737
- super.dispose(), this._allThemes = [], this._defaultThemeIndex = 0;
2738
- }
2739
- };
2740
- ge = ns([
2741
- oe(0, C(T)),
2742
- oe(1, C(It)),
2743
- oe(2, C(Qe)),
2744
- oe(3, Ve)
2745
- ], ge);
2746
- var ss = Object.getOwnPropertyDescriptor, rs = (t, e, n, s) => {
2747
- for (var r = s > 1 ? void 0 : s ? ss(e, n) : e, a = t.length - 1, o; a >= 0; a--)
2748
- (o = t[a]) && (r = o(r) || r);
2749
- return r;
2750
- }, ie = (t, e) => (n, s) => e(n, s, t);
2751
- let me = class extends H {
2752
- constructor(e, n, s, r) {
2753
- super();
2754
- b(this, "_tableFilteredOutRows$", new Ke(/* @__PURE__ */ new Set()));
2755
- b(this, "tableFilteredOutRows$", this._tableFilteredOutRows$.asObservable());
2756
- b(this, "_subscription", null);
2757
- this._tableManager = e, this._sheetInterceptorService = n, this._univerInstanceService = s, this._zebraCrossingCacheController = r, this.registerFilterChangeEvent(), this.initTableHiddenRowIntercept(), this._initFilteredOutRows();
2758
- }
2759
- get tableFilteredOutRows() {
2760
- return this._tableFilteredOutRows$.value;
2761
- }
2762
- set tableFilteredOutRows(e) {
2763
- this._tableFilteredOutRows$.next(e);
2764
- }
2765
- initTableHiddenRowIntercept() {
2766
- this.disposeWithMe(this._sheetInterceptorService.intercept(qe.ROW_FILTERED, {
2767
- // 这里需要保证优先级高于sheet的筛选,因为筛选没有next,低于筛选的不会触发interceptor
2768
- priority: 100,
2769
- handler: (e, n, s) => {
2770
- if (e) return !0;
2771
- const r = this.tableFilteredOutRows.has(n.row);
2772
- return r ? !0 : s(r);
2773
- }
2774
- }));
2775
- }
2776
- _initFilteredOutRows() {
2777
- this._tableManager.tableInitStatus$.pipe(
2778
- pe((e) => e),
2779
- Fe(() => this._univerInstanceService.getCurrentTypeOfUnit$(j.UNIVER_SHEET)),
2780
- pe((e) => e != null),
2781
- Fe((e) => e.activeSheet$),
2782
- pe((e) => e != null)
2783
- ).subscribe(() => {
2784
- const e = $(this._univerInstanceService);
2785
- if (!e)
2786
- return;
2787
- const { unitId: n, subUnitId: s } = e;
2788
- this.tableFilteredOutRows.clear(), this._tableManager.getTablesBySubunitId(n, s).forEach((a) => {
2789
- const o = a.getTableFilters().getFilterOutRows();
2790
- if (o)
2791
- for (const u of o)
2792
- this.tableFilteredOutRows.add(u);
2793
- });
2794
- });
2795
- }
2796
- registerFilterChangeEvent() {
2797
- this.disposeWithMe(
2798
- this._tableManager.tableFilterChanged$.subscribe((e) => {
2799
- var i;
2800
- const { unitId: n, subUnitId: s, tableId: r } = e, a = (i = this._univerInstanceService.getUnit(n)) == null ? void 0 : i.getSheetBySheetId(s), o = this._tableManager.getTable(n, r);
2801
- if (!a || !o)
2802
- return;
2803
- this.tableFilteredOutRows.clear(), o.getTableFilters().doFilter(a, o.getTableFilterRange()), this._tableManager.getTablesBySubunitId(n, s).forEach((h) => {
2804
- const d = h.getTableFilters().getFilterOutRows();
2805
- if (d)
2806
- for (const c of d)
2807
- this.tableFilteredOutRows.add(c);
2808
- }), this._zebraCrossingCacheController.updateZebraCrossingCache(n, s);
2809
- })
2810
- );
2811
- }
2812
- dispose() {
2813
- var e;
2814
- super.dispose(), (e = this._subscription) == null || e.unsubscribe();
2815
- }
2816
- };
2817
- me = rs([
2818
- ie(0, C(T)),
2819
- ie(1, C(Re)),
2820
- ie(2, C(A)),
2821
- ie(3, C(vt))
2822
- ], me);
2823
- var as = Object.getOwnPropertyDescriptor, os = (t, e, n, s) => {
2824
- for (var r = s > 1 ? void 0 : s ? as(e, n) : e, a = t.length - 1, o; a >= 0; a--)
2825
- (o = t[a]) && (r = o(r) || r);
2826
- return r;
2827
- }, Se = (t, e) => (n, s) => e(n, s, t), le;
2828
- let Ee = (le = class extends ht {
2829
- constructor(t = De, e, n, s) {
2830
- super(), this._config = t, this._injector = e, this._configService = n, this._commandService = s;
2831
- const { ...r } = gt(
2832
- {},
2833
- De,
2834
- this._config
2835
- );
2836
- this._configService.setConfig(tt, r), this._initRegisterCommand();
2837
- }
2838
- onStarting() {
2839
- mt(this._injector, [
2840
- [T],
2841
- [ge],
2842
- [W],
2843
- [X],
2844
- [me],
2845
- [de],
2846
- [he],
2847
- [ce]
2848
- ]);
2849
- }
2850
- onReady() {
2851
- Me(this._injector, [
2852
- [ce],
2853
- [de],
2854
- [he],
2855
- [ge],
2856
- [W],
2857
- [X],
2858
- [me]
2859
- ]), Me(this._injector, [
2860
- [T]
2861
- ]);
2862
- }
2863
- _initRegisterCommand() {
2864
- [
2865
- Ln,
2866
- k,
2867
- En,
2868
- Q,
2869
- Ce,
2870
- Bn,
2871
- Jn,
2872
- S,
2873
- Pn,
2874
- qn,
2875
- kn,
2876
- Qn,
2877
- Yn,
2878
- Gn
2879
- ].forEach((t) => this._commandService.registerCommand(t));
2880
- }
2881
- }, b(le, "pluginName", at), b(le, "type", j.UNIVER_SHEET), le);
2882
- Ee = os([
2883
- Se(1, C(He)),
2884
- Se(2, Ve),
2885
- Se(3, C(D))
2886
- ], Ee);
2887
- export {
2888
- Ln as AddSheetTableCommand,
2889
- k as AddSheetTableMutation,
2890
- Pn as AddTableThemeCommand,
2891
- En as DeleteSheetTableCommand,
2892
- Q as DeleteSheetTableMutation,
2893
- qn as RemoveTableThemeCommand,
2894
- Wn as SHEET_TABLE_CUSTOM_THEME_PREFIX,
2895
- Jn as SetSheetTableCommand,
2896
- Bn as SetSheetTableFilterCommand,
2897
- Ce as SetSheetTableFilterMutation,
2898
- S as SetSheetTableMutation,
2899
- Qn as SheetTableInsertColCommand,
2900
- kn as SheetTableInsertRowCommand,
2901
- Gn as SheetTableRemoveColCommand,
2902
- Yn as SheetTableRemoveRowCommand,
2903
- X as SheetTableService,
2904
- q as SheetsTableButtonStateEnum,
2905
- W as SheetsTableController,
2906
- G as SheetsTableSortStateEnum,
2907
- Xe as TableColumnDataTypeEnum,
2908
- ne as TableColumnFilterTypeEnum,
2909
- U as TableConditionTypeEnum,
2910
- m as TableDateCompareTypeEnum,
2911
- T as TableManager,
2912
- F as TableNumberCompareTypeEnum,
2913
- P as TableStringCompareTypeEnum,
2914
- Ee as UniverSheetsTablePlugin,
2915
- ms as customEmptyThemeWithBorderStyle,
2916
- yt as isConditionFilter,
2917
- gs as isManualTableFilter,
2918
- bs as processStyleWithBorderStyle
2919
- };
1
+ import{BorderStyleTypes as e,CellValueType as t,CommandType as n,Disposable as r,ICommandService as i,IConfigService as a,ILogService as o,IResourceManagerService as s,IUndoRedoService as c,IUniverInstanceService as l,Inject as u,Injector as d,InterceptorEffectEnum as f,LocaleService as p,Plugin as m,RTree as h,Rectangle as g,UniverInstanceType as _,createREGEXFromWildChar as v,customNameCharacterCheck as y,generateRandomId as b,merge as ee,registerDependencies as te,sequenceExecute as x,touchDependencies as ne}from"@univerjs/core";import{IDefinedNamesService as re,RemoveSuperTableMutation as ie,SetSuperTableMutation as ae}from"@univerjs/engine-formula";import{AddRangeThemeMutation as oe,CopySheetCommand as se,IExclusiveRangeService as ce,INTERCEPTOR_POINT as le,InsertColCommand as ue,InsertColMutation as de,InsertRowCommand as fe,InsertRowMutation as pe,RangeThemeStyle as me,RefRangeService as he,RemoveColCommand as ge,RemoveColMutation as _e,RemoveRangeThemeMutation as ve,RemoveRowCommand as ye,RemoveRowMutation as be,RemoveSheetCommand as xe,SheetInterceptorService as Se,SheetRangeThemeModel as Ce,SheetRangeThemeService as we,SheetsSelectionsService as S,ZebraCrossingCacheController as Te,getMoveRangeUndoRedoMutations as C,getSheetCommandTarget as w}from"@univerjs/sheets";import{BehaviorSubject as Ee,Subject as T,filter as De,switchMap as Oe}from"rxjs";let E=function(e){return e.Insert=`insert`,e.Delete=`delete`,e}({}),D=function(e){return e.Row=`row`,e.Col=`column`,e}({}),ke=function(e){return e.None=`none`,e.String=`string`,e.Number=`number`,e.Date=`date`,e.Bool=`bool`,e.Checkbox=`checkbox`,e.List=`list`,e}({}),O=function(e){return e.manual=`manual`,e.condition=`condition`,e}({}),k=function(e){return e.Date=`date`,e.Number=`number`,e.String=`string`,e.Logic=`logic`,e}({}),A=function(e){return e.Equal=`equal`,e.NotEqual=`notEqual`,e.GreaterThan=`greaterThan`,e.GreaterThanOrEqual=`greaterThanOrEqual`,e.LessThan=`lessThan`,e.LessThanOrEqual=`lessThanOrEqual`,e.Between=`between`,e.NotBetween=`notBetween`,e.Above=`above`,e.Below=`below`,e.TopN=`topN`,e}({}),j=function(e){return e.Equal=`equal`,e.NotEqual=`notEqual`,e.Contains=`contains`,e.NotContains=`notContains`,e.StartsWith=`startsWith`,e.EndsWith=`endsWith`,e}({}),M=function(e){return e.Equal=`equal`,e.NotEqual=`notEqual`,e.After=`after`,e.AfterOrEqual=`afterOrEqual`,e.Before=`before`,e.BeforeOrEqual=`beforeOrEqual`,e.Between=`between`,e.NotBetween=`notBetween`,e.Today=`today`,e.Yesterday=`yesterday`,e.Tomorrow=`tomorrow`,e.ThisWeek=`thisWeek`,e.LastWeek=`lastWeek`,e.NextWeek=`nextWeek`,e.ThisMonth=`thisMonth`,e.LastMonth=`lastMonth`,e.NextMonth=`nextMonth`,e.ThisQuarter=`thisQuarter`,e.LastQuarter=`lastQuarter`,e.NextQuarter=`nextQuarter`,e.ThisYear=`thisYear`,e.LastYear=`lastYear`,e.NextYear=`nextYear`,e.YearToDate=`yearToDate`,e.Quarter=`quarter`,e.Month=`month`,e.M1=`m1`,e.M2=`m2`,e.M3=`m3`,e.M4=`m4`,e.M5=`m5`,e.M6=`m6`,e.M7=`m7`,e.M8=`m8`,e.M9=`m9`,e.M10=`m10`,e.M11=`m11`,e.M12=`m12`,e.Q1=`q1`,e.Q2=`q2`,e.Q3=`q3`,e.Q4=`q4`,e}({}),N=function(e){return e[e.FilteredSortNone=1]=`FilteredSortNone`,e[e.FilteredSortAsc=2]=`FilteredSortAsc`,e[e.FilteredSortDesc=3]=`FilteredSortDesc`,e[e.FilterNoneSortNone=4]=`FilterNoneSortNone`,e[e.FilterNoneSortAsc=5]=`FilterNoneSortAsc`,e[e.FilterNoneSortDesc=6]=`FilterNoneSortDesc`,e}({}),P=function(e){return e.Asc=`asc`,e.Desc=`desc`,e.None=`none`,e}({});function F(e,t){return`${t} ${e}`}const Ae=`TRUE`,je=`FALSE`,Me=e=>{var t;return((t=e.body)==null?void 0:t.dataStream.replace(/\r\n$/,``))||``};function Ne(e){if(e){let{v:n,t:r,p:i}=e;return i?Me(i):(r===t.FORCE_STRING||r===t.STRING)&&n!=null?String(n):r===t.BOOLEAN?n?Ae:je:r===t.NUMBER?String(n):typeof n==`boolean`?n?Ae:je:n==null?``:String(n)}return``}function Pe(e,t){if(e!=null)switch(t){case P.Asc:return N.FilteredSortAsc;case P.Desc:return N.FilteredSortDesc;default:return N.FilteredSortNone}else switch(t){case P.Asc:return N.FilterNoneSortAsc;case P.Desc:return N.FilterNoneSortDesc;default:return N.FilterNoneSortNone}}function Fe(e){return e?e.filterType===O.condition:!1}function Ie(e){return e?e.filterType===O.manual:!1}function Le(e,t){let{univerInstanceService:n,tableManager:r,definedNamesService:i}=t,a=new Set,o=n==null?void 0:n.getUnit(e,_.UNIVER_SHEET);o&&o.getSheets().forEach(e=>{a.add(e.getName().toLowerCase())});let s=r==null?void 0:r.getTableList(e);s&&s.length>0&&s.forEach(e=>{a.add(e.name.toLowerCase())});let c=i==null?void 0:i.getDefinedNameMap(e);return c&&Object.values(c).forEach(e=>{a.add(e.name.toLowerCase())}),a}const I={s:e.THIN,cl:{rgb:`rgb(95, 101, 116)`}},Re=`sheets-table.config`;Symbol(Re);const ze={},Be={headerRowStyle:{bd:{t:I}},headerColumnStyle:{bd:{l:I}},lastColumnStyle:{bd:{r:I}},lastRowStyle:{bd:{b:I}}},Ve=(e,t)=>{if(e===`headerRowStyle`){if(!t.bd)return{...t,bd:{t:I}}}else if(e===`lastRowStyle`){if(!t.bd)return{...t,bd:{b:I}}}else if(e===`lastColumnStyle`){if(!t.bd)return{...t,bd:{r:I}}}else if(e===`headerColumnStyle`&&!t.bd)return{...t,bd:{l:I}};return t},He=[[[`#6280F9`,`#FFFFFF`,`#BAC6F8`,`#D2DAFA`],[`#fff`]],[[`#16BDCA`,`#FFFFFF`,`#EDFAFA`,`#AFECEF`],[`#000`]],[[`#31C48D`,`#FFFFFF`,`#F3FAF7`,`#BCF0DA`],[`#fff`]],[[`#AC94FA`,`#FFFFFF`,`#F6F5FF`,`#EDEBFE`],[`#fff`]],[[`#F17EBB`,`#FFFFFF`,`#FDF2F8`,`#FCE8F3`],[`#fff`]],[[`#F98080`,`#FFFFFF`,`#FDF2F2`,`#FDE8E8`],[`#fff`]]].map((e,t)=>{let[n,r]=e,[i,a,o,s]=n,[c]=r;return{name:`table-default-${t}`,style:{headerRowStyle:{bg:{rgb:i},cl:{rgb:c},bd:{t:I}},headerColumnStyle:{bd:{l:I}},firstRowStyle:{bg:{rgb:a}},secondRowStyle:{bg:{rgb:o}},lastRowStyle:{bg:{rgb:s},bd:{b:I}},lastColumnStyle:{bd:{r:I}}}}});function L(e){"@babel/helpers - typeof";return L=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},L(e)}function Ue(e,t){if(L(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(L(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function We(e){var t=Ue(e,`string`);return L(t)==`symbol`?t:t+``}function R(e,t,n){return(t=We(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var z=class{constructor(e,t){R(this,`dataType`,void 0),R(this,`id`,void 0),R(this,`displayName`,void 0),R(this,`formula`,void 0),R(this,`meta`,void 0),R(this,`style`,void 0),this.id=e,this.displayName=t,this.dataType=ke.String,this.formula=``,this.meta={},this.style={}}getMeta(){return this.meta}setMeta(e){this.meta=e}getDisplayName(){return this.displayName}toJSON(){return{id:this.id,displayName:this.displayName,dataType:this.dataType,formula:this.formula,meta:this.meta,style:this.style}}fromJSON(e){this.id=e.id,this.displayName=e.displayName,this.dataType=e.dataType,this.formula=e.formula,this.meta=e.meta,this.style=e.style}};const Ge=e=>e.getMonth()<=2,Ke=e=>{let t=e.getMonth();return t>2&&t<=5},qe=e=>{let t=e.getMonth();return t>5&&t<=8},Je=e=>{let t=e.getMonth();return t>8&&t<=11},Ye=e=>e.getMonth()===0,Xe=e=>e.getMonth()===1,Ze=e=>e.getMonth()===2,Qe=e=>e.getMonth()===3,$e=e=>e.getMonth()===4,et=e=>e.getMonth()===5,tt=e=>e.getMonth()===6,nt=e=>e.getMonth()===7,rt=e=>e.getMonth()===8,it=e=>e.getMonth()===9,at=e=>e.getMonth()===10,ot=e=>e.getMonth()===11,st=(e,t=new Date)=>e.toDateString()===t.toDateString(),ct=(e,t=new Date)=>{let n=new Date(t);return n.setDate(n.getDate()+1),e.toDateString()===n.toDateString()},lt=(e,t=new Date)=>{let n=new Date(t);return n.setDate(n.getDate()-1),e.toDateString()===n.toDateString()},B=e=>{let t=e.getDay(),n=e.getDate()-t+(t===0?-6:1),r=new Date(e);return r.setDate(n),r},ut=10080*60*1e3,dt=(e,t=new Date)=>{let n=B(e),r=B(t);return n.toDateString()===r.toDateString()},ft=(e,t=new Date)=>{let n=B(e),r=new Date(B(t).getTime()+ut);return n.toDateString()===r.toDateString()},pt=(e,t=new Date)=>{let n=B(e),r=new Date(B(t).getTime()-ut);return n.toDateString()===r.toDateString()},mt=(e,t=new Date)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth(),ht=e=>{let t=new Date(e);return t.setHours(0,0,0,0),t.setDate(1),t},gt=(e,t=new Date)=>{let n=new Date(t);n.setHours(0,0,0,0),n.setMonth(n.getMonth()+1,1);let r=new Date(n);r.setMonth(r.getMonth()+1,0);let i=e.getTime();return i>=n.getTime()&&i<r.getTime()},_t=(e,t=new Date)=>{let n=ht(t),r=new Date(n);r.setMonth(r.getMonth()+1,0);let i=e.getTime();return i>=n.getTime()&&i<r.getTime()},vt=e=>{let t=new Date(e);t.setHours(0,0,0,0),t.setDate(1);let n=t.getMonth();return t.setMonth(n-n%3),t},yt=(e,t=new Date)=>{let n=vt(t),r=new Date(n);r.setMonth(r.getMonth()+3);let i=e.getTime();return i>=n.getTime()&&i<r.getTime()},bt=(e,t=new Date)=>{let n=vt(t),r=new Date(n);r.setMonth(r.getMonth()+3);let i=new Date(r);i.setMonth(i.getMonth()+3,0);let a=e.getTime();return a>=r.getTime()&&a<i.getTime()},xt=(e,t=new Date)=>{let n=vt(t),r=new Date(n);r.setMonth(r.getMonth()-3);let i=new Date(n);i.setDate(0);let a=e.getTime();return a>=r.getTime()&&a<i.getTime()},St=(e,t=new Date)=>e.getFullYear()===t.getFullYear(),Ct=(e,t=new Date)=>e.getFullYear()===t.getFullYear()+1,wt=(e,t=new Date)=>e.getFullYear()===t.getFullYear()-1,Tt=(e,t=new Date)=>{let n=new Date(t);n.setHours(0,0,0,0),n.setMonth(0,1);let r=e.getTime();return r>=n.getTime()&&r<t.getTime()};function Et(e){switch(e.compareType){case M.Equal:{let t=new Date(e.expectedValue);return e=>e.getTime()===t.getTime()}case M.NotEqual:{let t=new Date(e.expectedValue);return e=>e.getTime()!==t.getTime()}case M.After:{let t=new Date(e.expectedValue);return e=>e.getTime()>t.getTime()}case M.Before:{let t=new Date(e.expectedValue);return e=>e.getTime()<t.getTime()}case M.AfterOrEqual:{let t=new Date(e.expectedValue);return e=>e.getTime()>=t.getTime()}case M.BeforeOrEqual:{let t=new Date(e.expectedValue);return e=>e.getTime()<=t.getTime()}case M.Between:return t=>{let[n,r]=e.expectedValue;return t.getTime()>=new Date(n).getTime()&&t.getTime()<=new Date(r).getTime()};case M.NotBetween:return t=>{let[n,r]=e.expectedValue;return t.getTime()<new Date(n).getTime()||t.getTime()>new Date(r).getTime()};case M.Today:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>st(e,t)}case M.Yesterday:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>lt(e,t)}case M.Tomorrow:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>ct(e,t)}case M.ThisWeek:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>dt(e,t)}case M.LastWeek:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>pt(e,t)}case M.NextWeek:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>ft(e,t)}case M.ThisMonth:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>mt(e,t)}case M.LastMonth:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>_t(e,t)}case M.NextMonth:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>gt(e,t)}case M.ThisQuarter:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>yt(e,t)}case M.LastQuarter:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>xt(e,t)}case M.NextQuarter:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>bt(e,t)}case M.ThisYear:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>St(e,t)}case M.LastYear:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>wt(e,t)}case M.NextYear:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>Ct(e,t)}case M.YearToDate:{let t=e.anchorTime?new Date(e.anchorTime):new Date;return e=>Tt(e,t)}case M.M1:return Ye;case M.M2:return Xe;case M.M3:return Ze;case M.M4:return Qe;case M.M5:return $e;case M.M6:return et;case M.M7:return tt;case M.M8:return nt;case M.M9:return rt;case M.M10:return it;case M.M11:return at;case M.M12:return ot;case M.Q1:return Ge;case M.Q2:return Ke;case M.Q3:return qe;case M.Q4:return Je;default:throw Error(`Unsupported compare type`)}}var Dt=class{constructor(){R(this,`heap`,void 0),this.heap=[]}swap(e,t){let n=this.heap[e];this.heap[e]=this.heap[t],this.heap[t]=n}getParentIndex(e){return Math.floor((e-1)/2)}getLeftIndex(e){return e*2+1}getRightIndex(e){return e*2+2}size(){return this.heap.length}peek(){return this.heap[0]}include(e){return this.heap.includes(e)}},Ot=class extends Dt{constructor(){super()}shiftUp(e){if(e===0)return;let t=this.getParentIndex(e);this.heap[t]>this.heap[e]&&(this.swap(t,e),this.shiftUp(t))}shiftDown(e){let t=this.getLeftIndex(e),n=this.getRightIndex(e);this.heap[t]<this.heap[e]&&(this.swap(t,e),this.shiftDown(t)),this.heap[n]<this.heap[e]&&(this.swap(n,e),this.shiftDown(n))}insert(e){this.heap.push(e),this.shiftUp(this.heap.length-1)}pop(){this.heap[0]=this.heap.pop(),this.shiftDown(0)}};const kt=(e,t)=>{let n=new Ot;for(let r of e)n.insert(r),n.size()>t&&n.pop();return n.heap},At=(e,t)=>e>t,jt=(e,t)=>e<t,Mt=(e,t,n)=>kt(e,t).includes(n);function Nt(e,t){switch(e.compareType){case A.Equal:{let t=Number(e.expectedValue);return e=>e===t}case A.NotEqual:{let t=Number(e.expectedValue);return e=>e!==t}case A.GreaterThan:{let t=Number(e.expectedValue);return e=>e>t}case A.GreaterThanOrEqual:{let t=Number(e.expectedValue);return e=>e>=t}case A.LessThan:{let t=Number(e.expectedValue);return e=>e<t}case A.LessThanOrEqual:{let t=Number(e.expectedValue);return e=>e<=t}case A.Between:{let[t,n]=e.expectedValue,r=Number(t),i=Number(n);return r>i?e=>e>=i&&e<=r:e=>e>=r&&e<=i}case A.NotBetween:{let[t,n]=e.expectedValue,r=Number(t),i=Number(n);return r>i?e=>e<i||e>r:e=>e<r||e>i}case A.Above:{let e=t.average;return t=>At(t,e)}case A.Below:{let e=t.average;return t=>jt(t,e)}case A.TopN:{let n=t.list,r=Number(e.expectedValue);return e=>Mt(n,r,e)}}}const Pt=(e,t)=>v(t).test(e),Ft=(e,t)=>!v(t).test(e),It=(e,t)=>v(`*${t}*`).test(e),Lt=(e,t)=>!v(`*${t}*`).test(e),Rt=(e,t)=>v(`${t}*`).test(e),zt=(e,t)=>v(`*${t}`).test(e);function Bt(e){switch(e.compareType){case j.Equal:return t=>Pt(t,e.expectedValue);case j.NotEqual:return t=>Ft(t,e.expectedValue);case j.Contains:return t=>It(t,e.expectedValue);case j.NotContains:return t=>Lt(t,e.expectedValue);case j.StartsWith:return t=>Rt(t,e.expectedValue);case j.EndsWith:return t=>zt(t,e.expectedValue);default:return console.error(`Unknown filter operator: ${e.compareType}`),e=>!0}}const Vt=new Set([A.Above,A.Below,A.TopN]);new Set([M.Today,M.Yesterday,M.Tomorrow,M.ThisWeek,M.LastWeek,M.NextWeek,M.ThisMonth,M.LastMonth,M.NextMonth,M.ThisQuarter,M.LastQuarter,M.NextQuarter,M.NextYear,M.ThisYear,M.LastYear,M.YearToDate]);function Ht(e){return Vt.has(e)}function Ut(e,t){if(Ht(e.filterInfo.compareType))return e=>!0;switch(e.filterInfo.conditionType){case k.Date:return Et(e.filterInfo);case k.Number:return Nt(e.filterInfo,t);case k.String:return Bt(e.filterInfo);case k.Logic:default:return e=>!0}}function V(e,t,n,r){switch(r){case k.Date:{let r=Kt(e,t,n);return r?qt(r):null}case k.Number:return Kt(e,t,n);case k.String:default:return Gt(e,t,n)}}const Wt=e=>{var t;return((t=e.body)==null?void 0:t.dataStream.replace(/\r\n$/,``))||``};function Gt(e,n,r){let i=e.getCell(n,r);if(!i)return null;let{v:a,t:o,p:s}=i;if(s)return Wt(s);if(typeof a==`string`)return o===t.BOOLEAN?a.toUpperCase():a;if(typeof a==`number`)return o===t.BOOLEAN?a?`TRUE`:`FALSE`:a;if(typeof a==`boolean`)return a?`TRUE`:`FALSE`;if(a!==void 0)return String(a)}function Kt(e,n,r){let i=e.getCell(n,r);if(!i)return null;let{v:a,t:o,p:s}=i;return s?null:typeof a==`string`&&o===t.NUMBER?Number(e.getCellRaw(n,r).v):Number(a)}function qt(e){let t=new Date(Date.UTC(1900,0,1,0,0,0)),n=new Date(Date.UTC(1900,1,28,0,0,0)),r=e-1;return r>(n.getTime()-t.getTime())/(1e3*3600*24)&&--r,r<0&&(r=e),new Date(t.getTime()+1e3*3600*24*r)}var Jt=class{constructor(){R(this,`_tableColumnFilterList`,void 0),R(this,`_tableSortInfo`,void 0),R(this,`_filterOutRows`,void 0),this._tableColumnFilterList=[]}setColumnFilter(e,t){t?this._tableColumnFilterList[e]=t:this._tableColumnFilterList[e]=void 0}setSortState(e,t){this._tableSortInfo={columnIndex:e,sortState:t}}getColumnFilter(e){return this._tableColumnFilterList[e]}getFilterState(e){var t;let n=((t=this._tableSortInfo)==null?void 0:t.columnIndex)===e?this._tableSortInfo.sortState:P.None;return Pe(this._tableColumnFilterList[e],n)}getSortState(){var e;return(e=this._tableSortInfo)==null?{}:e}getFilterStates(e){let t=[],{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)t.push(this.getFilterState(e-n));return t}getFilterOutRows(){return this._filterOutRows}doFilter(e,t){let n=new Set,r=this._tableColumnFilterList;for(let i=0;i<r.length;i++)r[i]&&this.doColumnFilter(e,t,i,n);return this._filterOutRows=n,n}doColumnFilter(e,t,n,r){let i=this._tableColumnFilterList[n];if(i&&e){let{startRow:a,endRow:o,startColumn:s}=t,c=s+n,l=this.getExecuteFunc(e,t,n,i);for(let t=a;t<=o;t++){let n=Fe(i)?i.filterInfo.conditionType:k.String;V(e,t,c,n)===null?r.add(t):l(V(e,t,c,n))||r.add(t)}}}_getNumberCalculatedOptions(e,t,n){let{startRow:r,endRow:i,startColumn:a}=t,o=a+n,s=[],c=0,l=0;for(let t=r;t<=i;t++){let n=V(e,t,o,k.Number);n!==null&&(s.push(n),c++,l+=n)}return{list:s,average:c>0?l/c:0}}getExecuteFunc(e,t,n,r){if(r.filterType===O.manual){let e=new Set(r.values);return t=>e.has(t)}else if(r.filterType===O.condition)return Ut(r,Ht(r.filterInfo.compareType)?this._getNumberCalculatedOptions(e,t,n):void 0);else return e=>!0}toJSON(){return{tableColumnFilterList:this._tableColumnFilterList,tableSortInfo:this._tableSortInfo}}fromJSON(e){var t;this._tableColumnFilterList=(t=e.tableColumnFilterList)==null?[]:t,e.tableSortInfo&&(this._tableSortInfo=e.tableSortInfo)}dispose(){this._tableColumnFilterList=[]}},Yt=class{constructor(e,t,n,r,i={}){R(this,`_id`,void 0),R(this,`_name`,void 0),R(this,`_tableStyleId`,void 0),R(this,`_showHeader`,void 0),R(this,`_showFooter`,void 0),R(this,`_range`,void 0),R(this,`_columns`,new Map),R(this,`_columnOrder`,[]),R(this,`tableMeta`,void 0),R(this,`_tableFilters`,void 0),R(this,`_subUnitId`,void 0),this._id=e,this._range=n,this._name=t,this._tableFilters=new Jt,this._init(r,i)}_init(e,t){var n;this._tableStyleId=t==null?void 0:t.tableStyleId,this._showHeader=(n=t==null?void 0:t.showHeader)==null?!0:n,this._showFooter=!1;let r=this.getRange(),i=r.startColumn,a=r.endColumn;for(let n=i;n<=a;n++){var o;let r=n-i,a,s;(o=t.columns)!=null&&o[r]?(a=t.columns[r].id,s=t.columns[r].displayName):(a=b(),s=e[n-i]);let c=new z(a,s);this._columns.set(a,c),this._columnOrder.push(a)}t.filters&&t.filters.forEach((e,t)=>{e&&this._tableFilters.setColumnFilter(t,e)})}setTableFilterColumn(e,t){this._tableFilters.setColumnFilter(e,t)}getTableFilterColumn(e){return this._tableFilters.getColumnFilter(e)}getTableFilters(){return this._tableFilters}getTableFilterRange(){let e=this.getRange(),t=this.isShowHeader(),n=this.isShowFooter(),{startRow:r,startColumn:i,endRow:a,endColumn:o}=e;return{startRow:t?r+1:r,startColumn:i,endRow:n?a-1:a,endColumn:o}}setColumns(e){this._columns.clear(),this._columnOrder=[],e.forEach(e=>{let t=new z(e.id,e.displayName);t.fromJSON(e),this._columns.set(e.id,t),this._columnOrder.push(e.id)})}getColumnsCount(){return this._columnOrder.length}insertColumn(e,t){let n=t.id;this._columns.set(n,t),this._columnOrder.splice(e,0,n)}removeColumn(e){let t=this._columnOrder[e];this._columns.delete(t),this._columnOrder.splice(e,1)}setTableMeta(e){this.tableMeta=e}getTableMeta(){return this.tableMeta}getColumn(e){return this._columns.get(e)}getTableColumnByIndex(e){let t=this._columnOrder[e];return this.getColumn(t)}getColumnNameByIndex(e){var t;let n=this._columnOrder[e];return((t=this.getColumn(n))==null?void 0:t.getDisplayName())||``}getId(){return this._id}getRangeInfo(){return{...this._range}}getRange(){return{...this._range}}setRange(e){this._range=e}setDisplayName(e){this._name=e}getDisplayName(){return this._name}getSubunitId(){return this._subUnitId}setSubunitId(e){this._subUnitId=e}getTableStyleId(){var e;return(e=this._tableStyleId)==null?He[0].name:e}setTableStyleId(e){this._tableStyleId=e}isShowHeader(){var e;return(e=this._showHeader)==null?!0:e}setShowHeader(e){this._showHeader=e}isShowFooter(){var e;return(e=this._showFooter)==null?!1:e}getTableInfo(){return{id:this._id,subUnitId:this._subUnitId,name:this._name,range:this.getRangeInfo(),meta:this.tableMeta,showHeader:this._showHeader,columns:this._columnOrder.map(e=>this._columns.get(e).toJSON())}}getTableConfig(){return{name:this.getDisplayName(),range:this.getRangeInfo(),options:{showHeader:this._showHeader,showFooter:this._showFooter},tableStyleId:this._tableStyleId}}getFilterStates(e){return this._tableFilters.getFilterStates(e)}toJSON(){let e=[];return this._columns.forEach(t=>{e.push(t.toJSON())}),{id:this._id,name:this._name,range:this.getRangeInfo(),options:{showHeader:this._showHeader,showFooter:this._showFooter,tableStyleId:this._tableStyleId},filters:this._tableFilters.toJSON(),columns:e,meta:this.tableMeta}}fromJSON(e){var t,n;this._id=e.id,this._name=e.name,this._range=e.range,this.tableMeta=e.meta,this._tableStyleId=e.options.tableStyleId||``,this._showHeader=(t=e.options.showHeader)==null?!0:t,this._showFooter=(n=e.options.showFooter)==null?!0:n,e.columns.forEach(e=>{let t=new z(e.id,e.displayName);t.fromJSON(e),this._columns.set(e.id,t),this._columnOrder.push(e.id)}),this._tableFilters=new Jt,this._tableFilters.fromJSON(e.filters)}dispose(){this._id=``,this._name=``,this._tableStyleId=``,this._showHeader=!0,this._showFooter=!0,delete this._range,this._columns.clear(),this._columnOrder=[]}};function H(e,t){return function(n,r){t(n,r,e)}}function U(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let W=class extends r{constructor(e,t){super(),this._univerInstanceService=e,this._localeService=t,R(this,`_tableMap`,void 0),R(this,`_tableAdd$`,new T),R(this,`tableAdd$`,this._tableAdd$.asObservable()),R(this,`_tableDelete$`,new T),R(this,`tableDelete$`,this._tableDelete$.asObservable()),R(this,`_tableNameChanged$`,new T),R(this,`tableNameChanged$`,this._tableNameChanged$.asObservable()),R(this,`_tableRangeChanged$`,new T),R(this,`tableRangeChanged$`,this._tableRangeChanged$.asObservable()),R(this,`_tableThemeChanged$`,new T),R(this,`tableThemeChanged$`,this._tableThemeChanged$.asObservable()),R(this,`_tableFilterChanged$`,new T),R(this,`tableFilterChanged$`,this._tableFilterChanged$.asObservable()),R(this,`_tableInitStatus`,new Ee(!1)),R(this,`tableInitStatus$`,this._tableInitStatus.asObservable()),this._tableMap=new Map}_ensureUnit(e){return this._tableMap.has(e)||this._tableMap.set(e,new Map),this._tableMap.get(e)}getColumnHeader(e,t,n,r){var i;let a=(i=this._univerInstanceService.getUnit(e))==null?void 0:i.getSheetBySheetId(t),{startRow:o,startColumn:s,endColumn:c}=n,l=[],u=r==null?`Column`:r;for(let e=s;e<=c;e++)l.push(Ne(a==null?void 0:a.getCell(o,e))||F(e-s+1,u));return l}addTable(e,t,n,r,i,a,o){let s=a==null?b():a,c=new Yt(s,n,r,i||this.getColumnHeader(e,t,r),o);if(c.setSubunitId(t),this._ensureUnit(e).set(s,c),this._tableAdd$.next({unitId:e,subUnitId:t,range:r,tableName:n,tableId:s,tableStyleId:o==null?void 0:o.tableStyleId}),o!=null&&o.filters){var l;let n=(l=this._univerInstanceService.getUnit(e))==null?void 0:l.getSheetBySheetId(t);c.getTableFilters().doFilter(n,r),this._tableFilterChanged$.next({unitId:e,subUnitId:t,tableId:s})}return s}addFilter(e,t,n,r){let i=this.getTable(e,t);if(i){i.getTableFilters().setColumnFilter(n,r);let a=i.getSubunitId();this._tableFilterChanged$.next({unitId:e,subUnitId:a,tableId:t})}}getFilterRanges(e,t){let n=this._tableMap.get(e);if(!n)return[];let r=[];return n.forEach(e=>{e.getSubunitId()===t&&e.isShowHeader()&&r.push(e.getRange())}),r}getSheetFilterRangeWithState(e,t){let n=this._tableMap.get(e);if(!n)return[];let r=[];return n.forEach(e=>{e.getSubunitId()===t&&e.isShowHeader()&&r.push({tableId:e.getId(),range:e.getRange(),states:e.getFilterStates(e.getRange())})}),r}getTable(e,t){let n=this._tableMap.get(e);if(n)return n.get(t)}getUniqueTableName(e,t){let n=this._tableMap.get(e);if(!n)return t;let r=new Set(Array.from(n.values()).map(e=>e.getDisplayName())),i=t,a=1;for(;r.has(i);)i=`${t}-${a}`,a++;return i}getTableById(e,t){return this.getTable(e,t)}getTableList(e){let t=this._tableMap.get(e);return t?Array.from(t.values()).map(t=>({...t.getTableInfo(),unitId:e})):[]}getTablesBySubunitId(e,t){let n=this._tableMap.get(e);return n?Array.from(n.values()).filter(e=>e.getSubunitId()===t):[]}getTablesInfoBySubunitId(e,t){return this.getTablesBySubunitId(e,t).map(e=>({id:e.getId(),name:e.getDisplayName(),range:e.getRange()}))}deleteTable(e,t){let n=this._tableMap.get(e),r=n==null?void 0:n.get(t);if(r){let i=r.getTableInfo(),a=r.getTableStyleId();n==null||n.delete(t);let{subUnitId:o,range:s,name:c}=i;this._tableDelete$.next({unitId:e,subUnitId:o,tableId:t,range:s,tableName:c,tableStyleId:a})}}operationTableRowCol(e,t,n){let r=this.getTableById(e,t);if(!r)return;let{operationType:i,rowColType:a,index:o,count:s,columnsJson:c}=n,l=r.getRange(),u={...l};if(i===E.Insert){if(a===`row`)u.endRow+=s;else if(a===`column`){u.endColumn+=s;for(let e=0;e<s;e++){let t=this._localeService.t(`sheets-table.columnPrefix`),n=new z(b(),F(r.getColumnsCount()+1+e,t));c!=null&&c[e]&&n.fromJSON(c[e]);let i=o+e-l.startColumn;r.insertColumn(i,n)}}}else if(a===`row`)u.endRow-=s;else if(a===`column`){u.endColumn-=s;for(let e=s-1;e>=0;e--){let t=o+e-l.startColumn;r.removeColumn(t)}}r.setRange(u),this._tableRangeChanged$.next({unitId:e,subUnitId:r.getSubunitId(),tableId:t,range:u,oldRange:l})}updateTableRange(e,t,n){let r=this.getTableById(e,t);if(!r)return;let i=r.getRange(),a=n.newRange;if(a.startColumn<i.startColumn){let e=i.startColumn-a.startColumn,t=this._localeService.t(`sheets-table.columnPrefix`);for(let n=0;n<e;n++)r.insertColumn(i.startColumn,new z(b(),F(r.getColumnsCount()+1,t)))}else if(a.startColumn>i.startColumn){let e=a.startColumn-i.startColumn;for(let t=e-1;t>=0;t--){let e=a.startColumn+t-i.startColumn;r.removeColumn(e)}}if(a.endColumn<i.endColumn){let e=i.endColumn-a.endColumn;for(let t=e-1;t>=0;t--){let e=a.endColumn+t-i.startColumn;r.removeColumn(e)}}else if(a.endColumn>i.endColumn){let e=a.endColumn-i.endColumn;for(let t=0;t<e;t++)r.insertColumn(i.endColumn,new z(b(),F(r.getColumnsCount()+1,`Column`)))}r.setRange(a),this._tableRangeChanged$.next({unitId:e,subUnitId:r.getSubunitId(),tableId:t,range:a,oldRange:i})}setTableByConfig(e,t,n){let r=this._tableMap.get(e),i=r==null?void 0:r.get(t);if(!i)return;let a=i.getSubunitId(),{name:o,updateRange:s,rowColOperation:c,theme:l,options:u}=n;if(o){let n=i.getDisplayName();i.setDisplayName(o),this._tableNameChanged$.next({unitId:e,subUnitId:a,tableId:t,tableName:o,oldTableName:n})}if(c&&this.operationTableRowCol(e,t,c),s&&this.updateTableRange(e,t,s),l){var d;let n=(d=i.getTableStyleId())==null?`default`:d;i.setTableStyleId(l),this._tableThemeChanged$.next({unitId:e,subUnitId:a,tableId:t,theme:l,oldTheme:n})}u&&u.showHeader!==void 0&&i.setShowHeader(u.showHeader)}toJSON(e){let t={},n=this._tableMap.get(e);return n&&n.forEach(n=>{let r=n.getSubunitId();if(!t[r]){let n=new Set;this.getTablesBySubunitId(e,r).forEach(e=>{let t=e.getTableFilters().getFilterOutRows();if(t)for(let e of t)n.add(e)}),t[r]={tables:[],tableFilteredOutRows:Array.from(n)}}t[r].tables.push(n.toJSON())}),t}fromJSON(e,t){let n=this._ensureUnit(e);Object.keys(t).forEach(r=>{let i=w(this._univerInstanceService,{unitId:e,subUnitId:r});if(!i)return;let a=i.worksheet,o;t[r].tables?o=t[r].tables:Array.isArray(t[r])&&(o=t[r]),o&&o.forEach(t=>{let i=this.getColumnHeader(e,r,t.range),o=new Yt(t.id,t.name,t.range,i,t.options);if(o.setTableMeta(t.meta),t.columns.length&&o.setColumns(t.columns),t.filters){let e=o.getTableFilters();e.fromJSON(t.filters),e.doFilter(a,o.getTableFilterRange())}o.setSubunitId(r),n.set(t.id,o),this._tableAdd$.next({unitId:e,subUnitId:r,range:t.range,tableName:t.name,tableId:t.id})})}),this._tableInitStatus.next(!0)}deleteUnitId(e){let t=this._tableMap.get(e);t&&t.forEach(e=>e.dispose()),this._tableMap.delete(e)}dispose(){super.dispose(),this._tableAdd$.complete(),this._tableDelete$.complete(),this._tableNameChanged$.complete(),this._tableRangeChanged$.complete(),this._tableThemeChanged$.complete(),this._tableFilterChanged$.complete(),this._tableInitStatus.complete(),this._tableMap.forEach(e=>{e.forEach(e=>e.dispose()),e.clear()}),this._tableMap.clear()}};W=U([H(0,l),H(1,u(p))],W);let G=class extends r{constructor(e){super(),this._tableManager=e}getTableInfo(e,t){let n=this._tableManager.getTable(e,t);if(n)return{unitId:e,...n.getTableInfo()}}getTableList(e){return this._tableManager.getTableList(e)}addTable(e,t,n,r,i,a,o){return this._tableManager.addTable(e,t,n,r,i,a,o)}deleteTable(e,t,n){this._tableManager.deleteTable(e,n)}getTableMeta(e,t){var n;return(n=this._tableManager.getTable(e,t))==null?void 0:n.getTableMeta()}setTableMeta(e,t,n){var r;(r=this._tableManager.getTable(e,t))==null||r.setTableMeta(n)}getTableColumnMeta(e,t,n){var r;return(r=this._tableManager.getTable(e,t))==null||(r=r.getTableColumnByIndex(n))==null?void 0:r.getMeta()}selTableColumnMeta(e,t,n,r){var i;(i=this._tableManager.getTable(e,t))==null||(i=i.getTableColumnByIndex(n))==null||i.setMeta(r)}addFilter(e,t,n,r){this._tableManager.addFilter(e,t,n,r)}getCellValueWithConditionType(e,t,n,r=k.String){return V(e,t,n,r)}};G=U([H(0,u(W))],G);const K={id:`sheet.mutation.add-table`,type:n.MUTATION,handler:(e,t)=>{let{tableId:n,unitId:r,subUnitId:i,name:a,range:o,header:s,options:c}=t;return e.get(G).addTable(r,i,a,o,s,n,c),!0}},q={id:`sheet.mutation.delete-table`,type:n.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,tableId:i}=t;return e.get(G).deleteTable(n,r,i),!0}},Xt={id:`sheet.command.add-table`,type:n.COMMAND,handler:(e,t)=>{var n;if(!t)return!1;let r=e.get(c),a=e.get(i),o=e.get(p),s=e.get(W),u=(n=t.id)==null?b():n,d=Le(t.unitId,{univerInstanceService:e.get(l),tableManager:s,definedNamesService:e.get(re)}),f=t.name;if(!f||!y(f.toLowerCase(),d)){let e=o.t(`sheets-table.tablePrefix`),n=s.getTableList(t.unitId).length+1;for(let t of d)if(t.startsWith(e.toLowerCase())){let r=Number(t.slice(e.length));Number.isInteger(r)&&r>=n&&(n=r+1)}f=`${e}${n}`}let m=[],h=[],{unitId:g,subUnitId:_,range:v}=t,ee=s.getColumnHeader(g,_,v,o.t(`sheets-table.columnPrefix`));return m.push({id:K.id,params:{...t,tableId:u,name:f,header:ee}}),h.push({id:q.id,params:{tableId:u,unitId:t.unitId}}),x(m,a)&&r.pushUndoRedo({unitID:t.unitId,undoMutations:h,redoMutations:m}),!0}},J={id:`sheet.mutation.set-sheet-table`,type:n.MUTATION,handler:(e,t)=>{if(!t)return!1;let{unitId:n,tableId:r,config:i}=t;return e.get(W).setTableByConfig(n,r,i),!0}},Zt={id:`sheet.command.add-table-theme`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let n=e.get(W),{unitId:r,tableId:a,themeStyle:o}=t,s=[],l=[],u=n.getTableById(r,a);if(!u)return!1;let d=u.getSubunitId();return s.push({id:oe.id,params:{unitId:r,subUnitId:d,styleJSON:o.toJson()}}),s.push({id:J.id,params:{unitId:r,subUnitId:d,tableId:a,config:{theme:o.getName()}}}),l.push({id:J.id,params:{unitId:r,subUnitId:d,tableId:a,config:{themeStyle:u.getTableStyleId()}}}),l.push({id:ve.id,params:{unitId:r,subUnitId:d,styleName:o.getName()}}),x(s,e.get(i))&&e.get(c).pushUndoRedo({unitID:r,undoMutations:l,redoMutations:s}),!0}},Qt={id:`sheet.command.delete-table`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let n=e.get(c),r=e.get(i),a=e.get(W),s=e.get(o),l=[],u=[],d=a.getTable(t.unitId,t.tableId),f=d==null?void 0:d.toJSON();return f?(l.push({id:q.id,params:{...t}}),u.push({id:K.id,params:{unitId:t.unitId,subUnitId:t.subUnitId,tableId:t.tableId,name:f.name,range:f.range,options:f.options}}),x(l,r)&&n.pushUndoRedo({unitID:t.unitId,undoMutations:u,redoMutations:l}),!0):(s.error(`[TableManager]: Table not found`),!1)}},$t=`SHEET_TABLE_PLUGIN`,Y=`SHEET_TABLE`,en=`table-custom`,tn={id:`sheet.command.remove-table-theme`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let{unitId:n,tableId:r,themeName:a}=t,o=e.get(W),s=e.get(Ce),l=o.getTableById(n,r);if(!l)return!1;let u=l.getSubunitId(),d=[],f=[],p=s.getRegisteredRangeThemes().filter(e=>e==null?void 0:e.startsWith(`table-default`)),m=s.getRegisteredRangeThemes().filter(e=>e==null?void 0:e.startsWith(en)).find(e=>e!==a);m||(m=p[0]),d.push({id:J.id,params:{unitId:n,subUnitId:u,tableId:r,config:{theme:m}}}),d.push({id:ve.id,params:{unitId:n,subUnitId:u,styleName:a}});let h=s.getDefaultRangeThemeStyle(a);return h&&(f.push({id:oe.id,params:{unitId:n,subUnitId:u,styleJSON:h.toJson()}}),f.push({id:J.id,params:{unitId:n,subUnitId:u,tableId:r,config:{theme:a}}})),x(d,e.get(i))&&e.get(c).pushUndoRedo({unitID:n,redoMutations:d,undoMutations:f}),!0}},nn={id:`sheet.command.set-table-config`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let{unitId:n,tableId:r,name:a,updateRange:s,rowColOperation:u,theme:d}=t,f=e.get(W),m=f.getTableById(n,r);if(!m)return!1;let h={},g={},_=e.get(p),v=Le(n,{univerInstanceService:e.get(l),tableManager:f,definedNamesService:e.get(re)});if(a){if(!y(a.toLowerCase(),v))return e.get(o).warn(_.t(`sheets-table.tableNameError`)),!1;h.name=m.getDisplayName(),g.name=a}u&&(h.rowColOperation={operationType:u.operationType===E.Insert?E.Delete:E.Insert,rowColType:u.rowColType,index:u.index,count:u.count},g.rowColOperation=u),s&&(h.updateRange={newRange:m.getRange()},g.updateRange=s),d&&(h.theme=m.getTableStyleId(),g.theme=d);let b={unitId:n,subUnitId:m.getSubunitId(),tableId:r,config:g};return e.get(i).executeCommand(J.id,b),e.get(c).pushUndoRedo({unitID:n,undoMutations:[{id:J.id,params:{unitId:n,subUnitId:m.getSubunitId(),tableId:r,config:h}}],redoMutations:[{id:J.id,params:b}]}),!0}},X={id:`sheet.mutation.set-table-filter`,type:n.MUTATION,handler:(e,t)=>{let{tableId:n,unitId:r,column:i,tableFilter:a}=t;return e.get(W).addFilter(r,n,i,a),!0}},rn={id:`sheet.command.set-table-filter`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let n=e.get(c),r=e.get(i),a=t.tableId||b(),o=[],s=[];return o.push({id:X.id,params:{...t,tableId:a}}),s.push({id:X.id,params:{...t,tableId:a,tableFilter:void 0}}),x(o,r)&&n.pushUndoRedo({unitID:t.unitId,undoMutations:s,redoMutations:o}),!0}};let Z=class extends r{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._sheetInterceptorService=t,this._tableManager=n,this._resourceManagerService=r,R(this,`_tableRangeRTree`,new Map),this._initSnapshot(),this._initSheetChange(),this.registerTableChangeEvent(),this.registerTableHeaderInterceptor()}getContainerTableWithRange(e,t,n){let r=this._ensureTableRangeRTree(e),i=Array.from(r.bulkSearch([{unitId:e,sheetId:t,range:n}])).find(t=>{let r=this._tableManager.getTable(e,String(t));return r?g.contains(r.getRange(),n):!1});if(i)return this._tableManager.getTable(e,String(i))}_ensureTableRangeRTree(e){return this._tableRangeRTree.has(e)||this._tableRangeRTree.set(e,new h),this._tableRangeRTree.get(e)}registerTableChangeEvent(){this.disposeWithMe(this._tableManager.tableAdd$.subscribe(e=>{let{range:t,tableId:n,unitId:r,subUnitId:i}=e;this._ensureTableRangeRTree(r).insert({unitId:r,sheetId:i,id:n,range:{...t}})})),this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe(e=>{let{range:t,tableId:n,unitId:r,subUnitId:i,oldRange:a}=e,o=this._ensureTableRangeRTree(r);o.remove({unitId:r,sheetId:i,id:n,range:{...a}}),o.insert({unitId:r,sheetId:i,id:n,range:{...t}})})),this.disposeWithMe(this._tableManager.tableDelete$.subscribe(e=>{let{tableId:t,unitId:n,subUnitId:r,range:i}=e;this._ensureTableRangeRTree(n).remove({unitId:n,sheetId:r,id:t,range:{...i}})}))}registerTableHeaderInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(le.CELL_CONTENT,{effect:f.Value,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t,s=this._ensureTableRangeRTree(a);if((e==null?void 0:e.v)===void 0&&s){let c=Array.from(s.bulkSearch([{unitId:a,sheetId:o,range:{startColumn:i,endColumn:i,startRow:r,endRow:r}}]));if(c.length>0){let o=this._tableManager.getTable(a,c[0]);if(o){let a=o.getRange(),s=i-a.startColumn;if(a.startRow===r){let r=o.getColumnNameByIndex(s);return(!e||e===t.rawData)&&(e={...t.rawData}),e.v=r,n(e)}}}}return n(e)}}))}_toJson(e){return this._tableManager.toJSON(e)}_fromJSON(e,t){return this._tableManager.fromJSON(e,t)}_deleteUnitId(e){this._tableManager.deleteUnitId(e)}_initSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource({toJson:e=>JSON.stringify(this._toJson(e)),parseJson:e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}},businesses:[_.UNIVER_SHEET],pluginName:$t,onLoad:(e,t)=>{this._fromJSON(e,t)},onUnLoad:e=>{this._deleteUnitId(e)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===xe.id){var t;let n=e.params,r=n.unitId||this._univerInstanceService.getCurrentUnitOfType(_.UNIVER_SHEET).getUnitId(),i=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(_.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!r||!i)return{redos:[],undos:[]};let a=this._tableManager.getTablesBySubunitId(r,i);if(a.length===0)return{redos:[],undos:[]};let o=[],s=[];return a.forEach(e=>{let t=e.toJSON();o.push({id:q.id,params:{unitId:r,subUnitId:i,tableId:t.id}}),s.push({id:K.id,params:{unitId:r,subUnitId:i,name:t.name,range:t.range,tableId:t.id,options:{...t.options,columns:t.columns,filters:t.filters.tableColumnFilterList}}})}),{redos:o,undos:s}}else if(e.id===se.id){let{unitId:t,subUnitId:n,targetSubUnitId:r}=e.params;if(!t||!n||!r)return{redos:[],undos:[]};let i=this._tableManager.getTablesBySubunitId(t,n);if(i.length===0)return{redos:[],undos:[]};let a=[],o=[];return i.forEach(e=>{let n=e.toJSON(),i=b();a.push({id:K.id,params:{unitId:t,subUnitId:r,name:n.name,range:{...n.range,sheetId:r},tableId:i,options:{...n.options,columns:n.columns,filters:n.filters.tableColumnFilterList}}}),o.push({id:q.id,params:{unitId:t,subUnitId:r,tableId:i}})}),{redos:a,undos:o}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._tableRangeRTree.clear()}};Z=U([H(0,u(l)),H(1,u(Se)),H(2,u(W)),H(3,u(s))],Z);const an={id:`sheet.command.table-insert-row`,type:n.COMMAND,handler:e=>{let t=w(e.get(l));if(!t)return!1;let{workbook:n,worksheet:r,unitId:a,subUnitId:o}=t,s=e.get(S).getCurrentSelections();if(!s.length||s.length>1)return!1;e.get(W);let u=s[0].range,d=e.get(Z).getContainerTableWithRange(a,o,u);if(!d)return!1;let f=u.endRow-u.startRow+1,p=r.getRowCount()-1,m=r.getCellMatrix().getDataRange().endRow,h=[],g=[];if(p-m<f)h.push({id:pe.id,params:{unitId:a,subUnitId:o,range:{...u}}}),h.push({id:J.id,params:{unitId:a,subUnitId:o,tableId:d.getId(),config:{updateRange:{newRange:{...d.getRange(),endRow:d.getRange().endRow+f}}}}}),g.push({id:J.id,params:{unitId:a,subUnitId:o,tableId:d.getId(),config:{updateRange:{newRange:d.getRange()}}}}),g.push({id:be.id,params:{unitId:a,subUnitId:o,range:{...u}}});else{let t={...d.getRange()};h.push({id:J.id,params:{unitId:a,subUnitId:o,tableId:d.getId(),config:{updateRange:{newRange:{...t,endRow:t.endRow+f}}}}}),g.push({id:J.id,params:{unitId:a,subUnitId:o,tableId:d.getId(),config:{updateRange:{newRange:{...t}}}}});let n=C(e,{unitId:a,subUnitId:o,range:{startRow:u.startRow,endRow:m,startColumn:t.startColumn,endColumn:t.endColumn}},{unitId:a,subUnitId:o,range:{startRow:u.startRow+f,endRow:m+f,startColumn:t.startColumn,endColumn:t.endColumn}});n&&(h.push(...n.redos),g.push(...n.undos))}return x(h,e.get(i))&&e.get(c).pushUndoRedo({unitID:a,undoMutations:g,redoMutations:h}),!0}},on={id:`sheet.command.table-insert-col`,type:n.COMMAND,handler:e=>{let t=w(e.get(l));if(!t)return!1;let{worksheet:n,unitId:r,subUnitId:a}=t,o=e.get(S).getCurrentSelections();if(!o.length||o.length>1)return!1;let s=o[0].range,u=e.get(Z).getContainerTableWithRange(r,a,s);if(!u)return!1;let d=s.endColumn-s.startColumn+1,f=n.getColumnCount()-1,p=n.getCellMatrix().getDataRange().endColumn,m=[],h=[];if(f-p<d)m.push({id:de.id,params:{unitId:r,subUnitId:a,range:{...s}}}),m.push({id:J.id,params:{unitId:r,subUnitId:a,tableId:u.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:s.startColumn,count:d}}}}),h.push({id:J.id,params:{unitId:r,subUnitId:a,tableId:u.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:s.startColumn,count:d}}}}),h.push({id:_e.id,params:{unitId:r,subUnitId:a,range:{...s}}});else{let t=u.getRange();m.push({id:J.id,params:{unitId:r,subUnitId:a,tableId:u.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:s.startColumn,count:d}}}}),h.push({id:J.id,params:{unitId:r,subUnitId:a,tableId:u.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:s.startColumn,count:d}}}});let n=C(e,{unitId:r,subUnitId:a,range:{startRow:t.startRow,endRow:t.endRow,startColumn:s.startColumn,endColumn:p}},{unitId:r,subUnitId:a,range:{startRow:t.startRow,endRow:t.endRow,startColumn:s.startColumn+d,endColumn:p+d}});n&&(m.push(...n.redos),h.push(...n.undos))}return x(m,e.get(i))&&e.get(c).pushUndoRedo({unitID:r,undoMutations:h,redoMutations:m}),!0}},sn={id:`sheet.command.table-remove-row`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let n=w(e.get(l),t);if(!n)return!1;let{unitId:r,subUnitId:a}=n,o=e.get(S).getCurrentSelections();if(!o.length||o.length>1)return!1;let s=o[0].range,u=e.get(Z).getContainerTableWithRange(r,a,s);if(!u)return!1;let d=s.endRow-s.startRow+1,f=[],p=[],m=u.getRange();f.push({id:J.id,params:{unitId:r,subUnitId:a,tableId:u.getId(),config:{updateRange:{newRange:{...m,endRow:m.endRow-d}}}}}),p.push({id:J.id,params:{unitId:r,subUnitId:a,tableId:u.getId(),config:{updateRange:{newRange:{...m}}}}});let h=n.worksheet.getCellMatrix().getDataRange().endRow,g=C(e,{unitId:r,subUnitId:a,range:{startRow:s.endRow+1,endRow:h,startColumn:m.startColumn,endColumn:m.endColumn}},{unitId:r,subUnitId:a,range:{startRow:s.startRow,endRow:h-d,startColumn:m.startColumn,endColumn:m.endColumn}});return g&&(f.push(...g.redos),p.push(...g.undos)),x(f,e.get(i))&&e.get(c).pushUndoRedo({unitID:r,undoMutations:p,redoMutations:f}),!0}},cn={id:`sheet.command.table-remove-col`,type:n.COMMAND,handler:(e,t)=>{if(!t)return!1;let n=w(e.get(l),t);if(!n)return!1;let{workbook:r,unitId:a,subUnitId:o}=n;e.get(W);let s=e.get(S).getCurrentSelections();if(!s.length||s.length>1)return!1;let u=s[0].range,d=e.get(Z).getContainerTableWithRange(a,o,u);if(!d)return!1;let f=u.endColumn-u.startColumn+1,p=[],m=[],h=d.getRange();p.push({id:J.id,params:{unitId:a,subUnitId:o,tableId:d.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:u.startColumn,count:f}}}});let g=[],_=u.startColumn-h.startColumn;for(let e=0;e<f;e++){let t=d.getTableInfo().columns[_+e];t&&g.push(t)}m.push({id:J.id,params:{unitId:a,subUnitId:o,tableId:d.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:u.startColumn,count:f,columnsJson:g}}}});let v=n.worksheet.getCellMatrix().getDataRange().endColumn,y=C(e,{unitId:a,subUnitId:o,range:{startRow:h.startRow,endRow:h.endRow,startColumn:u.endColumn+1,endColumn:v}},{unitId:a,subUnitId:o,range:{startRow:h.startRow,endRow:h.endRow,startColumn:u.startColumn,endColumn:v-f}});return y&&(p.push(...y.redos),m.push(...y.undos)),x(p,e.get(i))&&e.get(c).pushUndoRedo({unitID:a,undoMutations:m,redoMutations:p}),!0}};var ln=`@univerjs/sheets-table`,un=`0.17.0-insiders.20260318-d69dc16`;let Q=class extends r{constructor(e,t){super(),this._tableManager=e,this._commandService=t,this._initRangeListener()}_initRangeListener(){this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe(e=>{let{tableId:t,unitId:n}=e,r=this._tableManager.getTableById(n,t);r&&this._updateSuperTable(n,r)})),this.disposeWithMe(this._tableManager.tableAdd$.subscribe(e=>{let{tableId:t,unitId:n}=e,r=this._tableManager.getTableById(n,t);r&&this._updateSuperTable(n,r)})),this.disposeWithMe(this._tableManager.tableDelete$.subscribe(e=>{let{unitId:t,tableName:n}=e;this._commandService.executeCommand(ie.id,{unitId:t,tableName:n})})),this.disposeWithMe(this._tableManager.tableNameChanged$.subscribe(e=>{let{tableId:t,unitId:n,oldTableName:r}=e;this._commandService.executeCommand(ie.id,{unitId:n,tableName:r});let i=this._tableManager.getTableById(n,t);i&&this._updateSuperTable(n,i)}))}_updateSuperTable(e,t){let n=t.getTableInfo(),r=n.name,i=n.columns,a=new Map;i.forEach((e,t)=>{a.set(e.displayName,t)}),this._commandService.executeCommand(ae.id,{unitId:e,tableName:r,reference:{range:n.range,sheetId:n.subUnitId,titleMap:a}})}};Q=U([H(0,u(W)),H(1,i)],Q);let dn=class extends r{constructor(e,t){super(),this._tableManager=e,this._exclusiveRangeService=t,this._initRangeListener()}_initRangeListener(){this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe(e=>{let{range:t,tableId:n,unitId:r,subUnitId:i}=e;this._exclusiveRangeService.clearExclusiveRangesByGroupId(r,i,Y,n),this._exclusiveRangeService.addExclusiveRange(r,i,Y,[{range:{...t},groupId:n}])})),this.disposeWithMe(this._tableManager.tableAdd$.subscribe(e=>{let{tableId:t,unitId:n,subUnitId:r,range:i}=e;this._exclusiveRangeService.addExclusiveRange(n,r,Y,[{range:{...i},groupId:t}])})),this.disposeWithMe(this._tableManager.tableDelete$.subscribe(e=>{let{tableId:t,unitId:n,subUnitId:r}=e;this._exclusiveRangeService.clearExclusiveRangesByGroupId(n,r,Y,t)}))}};dn=U([H(0,u(W)),H(1,u(ce))],dn);let fn=class extends r{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._refRangeService=t,this._univerInstanceService=n,this._injector=r,this._sheetInterceptorService=i,this._tableManager=a,this._localeService=o,this._initCommandInterceptor(),this._initCommandListener()}_initCommandInterceptor(){let e=this;this._sheetInterceptorService.interceptCommand({getMutations(t){let n={redos:[],undos:[]},{id:r,params:i}=t;switch(r){case fe.id:return e._generateTableMutationWithInsertRow(i);case ue.id:return e._generateTableMutationWithInsertCol(i);case ye.id:return e._generateTableMutationWithRemoveRow(i);case ge.id:return e._generateTableMutationWithRemoveCol(i)}return n}})}_generateTableMutationWithInsertRow(e){let t=[],n=[],r=w(this._univerInstanceService,e);if(!r)return{undos:t,redos:n};let{unitId:i,subUnitId:a}=r,o=this._tableManager.getTablesBySubunitId(i,a);if(!o.length)return{undos:t,redos:n};let{range:s}=e;return o.forEach(e=>{let r=e.getRange();if(s.startRow>r.startRow&&s.startRow<=r.endRow){let o=s.endRow-s.startRow+1;n.push({id:J.id,params:{unitId:i,subUnitId:a,tableId:e.getId(),config:{updateRange:{newRange:{...r,endRow:r.endRow+o}}}}}),t.push({id:J.id,params:{unitId:i,subUnitId:a,tableId:e.getId(),config:{updateRange:{newRange:{...r}}}}})}}),{undos:t,redos:n}}_generateTableMutationWithInsertCol(e){let t=[],n=[],r=w(this._univerInstanceService,e);if(!r)return{undos:t,redos:n};let{unitId:i,subUnitId:a}=r,o=this._tableManager.getTablesBySubunitId(i,a);if(!o.length)return{undos:t,redos:n};let{range:s}=e;return o.forEach(e=>{let r=e.getRange();if(s.startColumn>r.startColumn&&s.startColumn<=r.endColumn){let r=s.endColumn-s.startColumn+1;n.push({id:J.id,params:{unitId:i,subUnitId:a,tableId:e.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:s.startColumn,count:r}}}}),t.push({id:J.id,params:{unitId:i,subUnitId:a,tableId:e.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:s.startColumn,count:r}}}})}}),{undos:t,redos:n}}_generateTableMutationWithRemoveRow(e){let t=[],n=[],r=[],i=[],a=w(this._univerInstanceService);if(!a)return{undos:t,redos:n,preRedos:r,preUndos:i};let{unitId:o,subUnitId:s}=a,c=this._tableManager.getTablesBySubunitId(o,s);if(!c.length)return{undos:t,redos:n,preRedos:r,preUndos:i};let{range:l}=e,u=l.endRow-l.startRow+1;return c.forEach(e=>{let i=e.getRange();if(g.intersects(i,l))if(l.startRow<=i.startRow&&l.endRow>=i.startRow){r.push({id:q.id,params:{unitId:o,subUnitId:s,tableId:e.getId()}});let n=e.toJSON();t.push({id:K.id,params:{unitId:o,subUnitId:s,tableId:n.id,name:n.name,range:n.range,options:n.options}})}else l.startRow>i.startRow&&l.startRow<=i.endRow?(n.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{updateRange:{newRange:{...i,endRow:i.endRow-u}}}}}),t.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{updateRange:{newRange:{...i}}}}})):l.startRow<i.endRow&&l.endRow>=i.endRow&&(n.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{updateRange:{newRange:{...i,endRow:l.startRow-1}}}}}),t.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{updateRange:{newRange:{...i}}}}}))}),{undos:t,redos:n,preRedos:r,preUndos:i}}_generateTableMutationWithRemoveCol(e){let t=[],n=[],r=[],i=[],a=w(this._univerInstanceService);if(!a)return{undos:t,redos:n,preRedos:r,preUndos:i};let{unitId:o,subUnitId:s}=a,c=this._tableManager.getTablesBySubunitId(o,s);if(!c.length)return{undos:t,redos:n,preRedos:r,preUndos:i};let{range:l}=e,u=l.endColumn-l.startColumn+1;return c.forEach(e=>{let a=e.getRange();if(g.intersects(a,l)){if(l.startColumn<=a.startColumn&&l.endColumn>=a.endColumn){r.push({id:q.id,params:{unitId:o,subUnitId:s,tableId:e.getId()}});let a=e.toJSON(),{startRow:c,startColumn:l,endColumn:u}=a.range,d=this._univerInstanceService.getUnit(o),f=d==null?void 0:d.getSheetBySheetId(s);if(!f)return{undos:t,redos:n,preRedos:r,preUndos:i};let p=[];for(let e=l;e<=u;e++)p.push(Ne(f==null?void 0:f.getCell(c,e))||F(e-l+1,this._localeService.t(`sheets-table.columnPrefix`)));t.push({id:K.id,params:{unitId:o,subUnitId:s,tableId:a.id,name:a.name,header:p,range:a.range,options:a.options}})}else if(l.startColumn<=a.startColumn&&l.endColumn>=a.startColumn){let r=l.endColumn-a.startColumn+1;n.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:a.startColumn,count:r}}}});let i=[];for(let t=0;t<r;t++){let n=e.getTableColumnByIndex(t);n&&i.push(n.toJSON())}t.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:a.startColumn,count:r,columnsJson:i}}}})}else if(l.startColumn>a.startColumn&&l.endColumn>a.endColumn){let r=a.endColumn-l.startColumn+1;n.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:l.startColumn,count:r}}}});let i=[],c=l.startColumn-a.startColumn;for(let t=0;t<r;t++){let n=e.getTableColumnByIndex(t+c);n&&i.push(n.toJSON())}t.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:l.startColumn,count:u,columnsJson:i}}}})}else if(l.startColumn>a.startColumn&&l.endColumn<=a.endColumn){n.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{rowColOperation:{operationType:E.Delete,rowColType:D.Col,index:l.startColumn,count:u}}}});let r=[],i=l.startColumn-a.startColumn;for(let t=0;t<u;t++){let n=e.getTableColumnByIndex(t+i);n&&r.push(n.toJSON())}t.push({id:J.id,params:{unitId:o,subUnitId:s,tableId:e.getId(),config:{rowColOperation:{operationType:E.Insert,rowColType:D.Col,index:l.startColumn,count:u,columnsJson:r}}}})}}}),{undos:t,redos:n,preRedos:r,preUndos:i}}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===pe.id){let{unitId:t,subUnitId:n,range:r}=e.params,i=r.endRow-r.startRow+1;this._tableManager.getTablesBySubunitId(t,n).forEach(e=>{let n=e.getRange();r.startRow<=n.startRow&&this._tableManager.updateTableRange(t,e.getId(),{newRange:{...n,startRow:n.startRow+i,endRow:n.endRow+i}})})}else if(e.id===de.id){let{unitId:t,subUnitId:n,range:r}=e.params,i=r.endColumn-r.startColumn+1;this._tableManager.getTablesBySubunitId(t,n).forEach(e=>{let n=e.getRange();r.startColumn<=n.startColumn&&this._tableManager.updateTableRange(t,e.getId(),{newRange:{...n,startColumn:n.startColumn+i,endColumn:n.endColumn+i}})})}else if(e.id===be.id){let{unitId:t,subUnitId:n,range:r}=e.params,i=r.endRow-r.startRow+1;this._tableManager.getTablesBySubunitId(t,n).forEach(e=>{let n=e.getRange();r.startRow<n.startRow&&this._tableManager.updateTableRange(t,e.getId(),{newRange:{...n,startRow:n.startRow-i,endRow:n.endRow-i}})})}else if(e.id===_e.id){let{unitId:t,subUnitId:n,range:r}=e.params,i=r.endColumn-r.startColumn+1;this._tableManager.getTablesBySubunitId(t,n).forEach(e=>{let n=e.getRange();r.startColumn<n.startColumn&&this._tableManager.updateTableRange(t,e.getId(),{newRange:{...n,startColumn:n.startColumn-i,endColumn:n.endColumn-i}})})}})}};fn=U([H(0,u(i)),H(1,u(he)),H(2,u(l)),H(3,u(d)),H(4,u(Se)),H(5,u(W)),H(6,u(p))],fn);let pn=class extends r{constructor(e,t,n,r){super(),this._tableManager=e,this._sheetRangeThemeService=t,this._sheetRangeThemeModel=n,this._configService=r,R(this,`_defaultThemeIndex`,0),R(this,`_allThemes`,[]),this._initUserTableTheme(),this.registerTableChangeEvent(),this._initDefaultTableTheme()}registerTableChangeEvent(){this.disposeWithMe(this._tableManager.tableAdd$.subscribe(e=>{let{range:t,tableId:n,unitId:r,subUnitId:i,tableStyleId:a}=e,o=this._tableManager.getTable(r,n),s=a||this._allThemes[this._defaultThemeIndex].name;o.setTableStyleId(s),this._sheetRangeThemeService.registerRangeThemeStyle(s,{unitId:r,subUnitId:i,range:{...t}})})),this.disposeWithMe(this._tableManager.tableRangeChanged$.subscribe(e=>{let{range:t,oldRange:n,tableId:r,unitId:i,subUnitId:a}=e,o=this._tableManager.getTable(i,r),s=o.getTableStyleId();s||(s=this._allThemes[this._defaultThemeIndex].name,o.setTableStyleId(s)),this._sheetRangeThemeService.removeRangeThemeRule(s,{unitId:i,subUnitId:a,range:{...n}}),this._sheetRangeThemeService.registerRangeThemeStyle(s,{unitId:i,subUnitId:a,range:{...t}})})),this.disposeWithMe(this._tableManager.tableThemeChanged$.subscribe(e=>{let{theme:t,oldTheme:n,tableId:r,unitId:i,subUnitId:a}=e,o=this._tableManager.getTable(i,r).getRange();this._sheetRangeThemeService.removeRangeThemeRule(n,{unitId:i,subUnitId:a,range:{...o}}),this._sheetRangeThemeService.registerRangeThemeStyle(t,{unitId:i,subUnitId:a,range:{...o}})})),this.disposeWithMe(this._tableManager.tableDelete$.subscribe(e=>{let{range:t,unitId:n,subUnitId:r,tableStyleId:i=this._allThemes[this._defaultThemeIndex].name}=e;this._sheetRangeThemeService.removeRangeThemeRule(i,{unitId:n,subUnitId:r,range:{...t}})}))}_initUserTableTheme(){let e=this._configService.getConfig(`sheets-table.config`)||{},t=e.defaultThemeIndex||0,n=e.userThemes||[];this._defaultThemeIndex=t,this._allThemes=n.concat(He)}_initDefaultTableTheme(){for(let e=0;e<this._allThemes.length;e++){let{name:t,style:n}=this._allThemes[e],r=new me(t,n);this._sheetRangeThemeModel.registerDefaultRangeTheme(r)}}dispose(){super.dispose(),this._allThemes=[],this._defaultThemeIndex=0}};pn=U([H(0,u(W)),H(1,u(we)),H(2,u(Ce)),H(3,a)],pn);let mn=class extends r{constructor(e,t,n,r){super(),this._tableManager=e,this._sheetInterceptorService=t,this._univerInstanceService=n,this._zebraCrossingCacheController=r,R(this,`_tableFilteredOutRows$`,new Ee(new Set)),R(this,`tableFilteredOutRows$`,this._tableFilteredOutRows$.asObservable()),R(this,`_subscription`,null),this.registerFilterChangeEvent(),this.initTableHiddenRowIntercept(),this._initFilteredOutRows()}get tableFilteredOutRows(){return this._tableFilteredOutRows$.value}set tableFilteredOutRows(e){this._tableFilteredOutRows$.next(e)}initTableHiddenRowIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(le.ROW_FILTERED,{priority:100,handler:(e,t,n)=>{if(e)return!0;let r=this.tableFilteredOutRows.has(t.row);return r?!0:n(r)}}))}_initFilteredOutRows(){this._tableManager.tableInitStatus$.pipe(De(e=>e),Oe(()=>this._univerInstanceService.getCurrentTypeOfUnit$(_.UNIVER_SHEET)),De(e=>e!=null),Oe(e=>e.activeSheet$),De(e=>e!=null)).subscribe(()=>{let e=w(this._univerInstanceService);if(!e)return;let{unitId:t,subUnitId:n}=e;this.tableFilteredOutRows.clear(),this._tableManager.getTablesBySubunitId(t,n).forEach(e=>{let t=e.getTableFilters().getFilterOutRows();if(t)for(let e of t)this.tableFilteredOutRows.add(e)})})}registerFilterChangeEvent(){this.disposeWithMe(this._tableManager.tableFilterChanged$.subscribe(e=>{var t;let{unitId:n,subUnitId:r,tableId:i}=e,a=(t=this._univerInstanceService.getUnit(n))==null?void 0:t.getSheetBySheetId(r),o=this._tableManager.getTable(n,i);!a||!o||(this.tableFilteredOutRows.clear(),o.getTableFilters().doFilter(a,o.getTableFilterRange()),this._tableManager.getTablesBySubunitId(n,r).forEach(e=>{let t=e.getTableFilters().getFilterOutRows();if(t)for(let e of t)this.tableFilteredOutRows.add(e)}),this._zebraCrossingCacheController.updateZebraCrossingCache(n,r))}))}dispose(){var e;super.dispose(),(e=this._subscription)==null||e.unsubscribe()}};mn=U([H(0,u(W)),H(1,u(Se)),H(2,u(l)),H(3,u(Te))],mn);let $=class extends m{constructor(e=ze,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._commandService=r;let{...i}=ee({},ze,this._config);this._configService.setConfig(Re,i),this._initRegisterCommand()}onStarting(){te(this._injector,[[W],[pn],[Z],[G],[mn],[dn],[fn],[Q]])}onReady(){ne(this._injector,[[Q],[dn],[fn],[pn],[Z],[G],[mn]]),ne(this._injector,[[W]])}_initRegisterCommand(){[Xt,K,Qt,q,X,rn,nn,J,Zt,tn,an,on,sn,cn].forEach(e=>this._commandService.registerCommand(e))}};R($,`pluginName`,$t),R($,`packageName`,ln),R($,`version`,un),R($,`type`,_.UNIVER_SHEET),$=U([H(1,u(d)),H(2,a),H(3,u(i))],$);export{Xt as AddSheetTableCommand,K as AddSheetTableMutation,Zt as AddTableThemeCommand,Qt as DeleteSheetTableCommand,q as DeleteSheetTableMutation,tn as RemoveTableThemeCommand,en as SHEET_TABLE_CUSTOM_THEME_PREFIX,nn as SetSheetTableCommand,rn as SetSheetTableFilterCommand,X as SetSheetTableFilterMutation,J as SetSheetTableMutation,on as SheetTableInsertColCommand,an as SheetTableInsertRowCommand,cn as SheetTableRemoveColCommand,sn as SheetTableRemoveRowCommand,G as SheetTableService,N as SheetsTableButtonStateEnum,Z as SheetsTableController,P as SheetsTableSortStateEnum,ke as TableColumnDataTypeEnum,O as TableColumnFilterTypeEnum,k as TableConditionTypeEnum,M as TableDateCompareTypeEnum,W as TableManager,A as TableNumberCompareTypeEnum,j as TableStringCompareTypeEnum,$ as UniverSheetsTablePlugin,Be as customEmptyThemeWithBorderStyle,Fe as isConditionFilter,Ie as isManualTableFilter,Ve as processStyleWithBorderStyle};