@univerjs/sheets-filter 0.10.9 → 0.10.10-experimental.20251016-33b0941

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,60 +1,60 @@
1
1
  var be = Object.defineProperty;
2
- var $e = (i, t, e) => t in i ? be(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var C = (i, t, e) => $e(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { isNumeric as Le, Disposable as U, Rectangle as te, mergeSets as K, Tools as ie, extractPureTextFromCell as Ue, CellValueType as k, ColorKit as se, UniverInstanceType as D, fromCallback as Pe, CommandType as O, IResourceManagerService as De, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as J, sequenceExecute as j, ErrorService as Be, LocaleService as ze, Inject as A, Optional as He, DisposableCollection as me, moveMatrixArray as oe, IConfigService as ge, Plugin as Ve, merge as We, touchDependencies as je, Injector as ke } from "@univerjs/core";
5
- import { getSheetCommandTarget as H, SheetsSelectionsService as qe, isSingleCellSelection as Ge, expandToContinuousRange as _e, SheetInterceptorService as Qe, RefRangeService as Je, ZebraCrossingCacheController as Ze, SetWorksheetActiveOperation as Ke, CopySheetCommand as Ye, RemoveSheetCommand as Xe, INTERCEPTOR_POINT as et, RemoveRowMutation as tt, InsertRowMutation as rt, SetRangeValuesMutation as nt, MoveRowsCommand as it, MoveRangeCommand as st, EffectRefRangId as le, RemoveRowCommand as ot, RemoveColCommand as lt, InsertColCommand as at, InsertRowCommand as ct, InsertColMutation as Ce, RemoveColMutation as Re, MoveColsMutation as pe } from "@univerjs/sheets";
2
+ var $e = (i, r, e) => r in i ? be(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
+ var C = (i, r, e) => $e(i, typeof r != "symbol" ? r + "" : r, e);
4
+ import { createREGEXFromWildChar as me, isNumeric as Le, Disposable as U, Rectangle as te, mergeSets as K, Tools as ie, extractPureTextFromCell as Ue, CellValueType as k, ColorKit as se, UniverInstanceType as D, fromCallback as Pe, CommandType as O, IResourceManagerService as De, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as J, sequenceExecute as j, ErrorService as Be, LocaleService as ze, Inject as A, Optional as He, DisposableCollection as ge, moveMatrixArray as oe, IConfigService as _e, Plugin as Ve, merge as We, touchDependencies as je, Injector as ke } from "@univerjs/core";
5
+ import { getSheetCommandTarget as H, SheetsSelectionsService as qe, isSingleCellSelection as Ge, expandToContinuousRange as Ce, SheetInterceptorService as Qe, RefRangeService as Je, ZebraCrossingCacheController as Ze, SetWorksheetActiveOperation as Ke, CopySheetCommand as Ye, RemoveSheetCommand as Xe, INTERCEPTOR_POINT as et, RemoveRowMutation as tt, InsertRowMutation as rt, SetRangeValuesMutation as nt, MoveRowsCommand as it, MoveRangeCommand as st, EffectRefRangId as le, RemoveRowCommand as ot, RemoveColCommand as lt, InsertColCommand as at, InsertRowCommand as ct, InsertColMutation as Re, RemoveColMutation as pe, MoveColsMutation as Se } from "@univerjs/sheets";
6
6
  import { BehaviorSubject as $, merge as dt, filter as ut, switchMap as ht, of as ft } from "rxjs";
7
7
  import { COLOR_BLACK_RGB as mt } from "@univerjs/engine-render";
8
8
  import { DataSyncPrimaryController as gt } from "@univerjs/rpc";
9
9
  import { IActiveDirtyManagerService as _t, ISheetRowFilteredService as Ct } from "@univerjs/engine-formula";
10
- const Se = "sheet.mutation.set-filter-range", Fe = "sheet.mutation.set-filter-criteria", we = "sheet.mutation.remove-filter", ve = "sheet.mutation.re-calc-filter", Me = /* @__PURE__ */ new Set([
11
- Se,
10
+ const Fe = "sheet.mutation.set-filter-range", we = "sheet.mutation.set-filter-criteria", ve = "sheet.mutation.remove-filter", Me = "sheet.mutation.re-calc-filter", Ee = /* @__PURE__ */ new Set([
12
11
  Fe,
13
12
  we,
14
- ve
13
+ ve,
14
+ Me
15
15
  ]);
16
- var b = /* @__PURE__ */ ((i) => (i[i.VALUES = 0] = "VALUES", i[i.COLORS = 1] = "COLORS", i[i.CONDITIONS = 2] = "CONDITIONS", i))(b || {}), x = /* @__PURE__ */ ((i) => (i.EQUAL = "equal", i.GREATER_THAN = "greaterThan", i.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", i.LESS_THAN = "lessThan", i.LESS_THAN_OR_EQUAL = "lessThanOrEqual", i.NOT_EQUALS = "notEqual", i))(x || {});
16
+ var b = /* @__PURE__ */ ((i) => (i[i.VALUES = 0] = "VALUES", i[i.COLORS = 1] = "COLORS", i[i.CONDITIONS = 2] = "CONDITIONS", i))(b || {}), I = /* @__PURE__ */ ((i) => (i.EQUAL = "equal", i.GREATER_THAN = "greaterThan", i.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", i.LESS_THAN = "lessThan", i.LESS_THAN_OR_EQUAL = "lessThanOrEqual", i.NOT_EQUALS = "notEqual", i))(I || {});
17
17
  const Rt = {
18
- operator: x.GREATER_THAN,
19
- fn: (i, t) => P(i) ? i > t : !1
18
+ operator: I.GREATER_THAN,
19
+ fn: (i, r) => P(i) ? i > r : !1
20
20
  }, pt = {
21
- operator: x.GREATER_THAN_OR_EQUAL,
22
- fn: (i, t) => P(i) ? i >= t : !1
21
+ operator: I.GREATER_THAN_OR_EQUAL,
22
+ fn: (i, r) => P(i) ? i >= r : !1
23
23
  }, St = {
24
- operator: x.LESS_THAN,
25
- fn: (i, t) => P(i) ? i < t : !1
24
+ operator: I.LESS_THAN,
25
+ fn: (i, r) => P(i) ? i < r : !1
26
26
  }, Ft = {
27
- operator: x.LESS_THAN_OR_EQUAL,
28
- fn: (i, t) => P(i) ? i <= t : !1
27
+ operator: I.LESS_THAN_OR_EQUAL,
28
+ fn: (i, r) => P(i) ? i <= r : !1
29
29
  }, wt = {
30
- operator: x.EQUAL,
31
- fn: (i, t) => P(i) ? i === t : !1
32
- }, Ee = {
33
- operator: x.NOT_EQUALS,
34
- fn: (i, t) => {
35
- if (typeof t == "string") {
36
- if (t === " ")
30
+ operator: I.EQUAL,
31
+ fn: (i, r) => P(i) ? i === r : !1
32
+ }, Oe = {
33
+ operator: I.NOT_EQUALS,
34
+ fn: (i, r) => {
35
+ if (typeof r == "string") {
36
+ if (r === " ")
37
37
  return i != null;
38
- const e = ye(i);
39
- return e && Ot(t) ? !Ae(t).test(e) : e !== t;
38
+ const e = Ae(i);
39
+ return e && Ot(r) ? !me(r).test(e) : e !== r;
40
40
  }
41
- return P(i) ? i !== t : !0;
41
+ return P(i) ? i !== r : !0;
42
42
  }
43
- }, Oe = /* @__PURE__ */ new Map([]), vt = [Rt, pt, St, Ft, wt, Ee];
43
+ }, ye = /* @__PURE__ */ new Map([]), vt = [Rt, pt, St, Ft, wt, Oe];
44
44
  vt.forEach((i) => {
45
- Oe.set(i.operator, i);
45
+ ye.set(i.operator, i);
46
46
  });
47
47
  function Mt(i) {
48
48
  return !!i;
49
49
  }
50
50
  const Et = {
51
- fn: (i, t) => {
52
- const e = ye(i);
53
- return e === null ? t === "" : Ae(t).test(e);
51
+ fn: (i, r) => {
52
+ const e = Ae(i);
53
+ return e === null ? r === "" : me(r).test(e);
54
54
  }
55
55
  };
56
56
  function ae(i) {
57
- return i ? Oe.get(i) : Et;
57
+ return i ? ye.get(i) : Et;
58
58
  }
59
59
  function P(i) {
60
60
  return typeof i == "number";
@@ -62,19 +62,15 @@ function P(i) {
62
62
  function ce(i) {
63
63
  return !!(typeof i == "number" || typeof i == "string" && Le(i));
64
64
  }
65
- function ye(i) {
65
+ function Ae(i) {
66
66
  return typeof i == "boolean" || i == null ? null : typeof i == "string" ? i : i.toString();
67
67
  }
68
68
  function Ot(i) {
69
69
  return typeof i == "number" ? !1 : i.indexOf("*") !== -1 || i.indexOf("?") !== -1;
70
70
  }
71
- function Ae(i) {
72
- const t = i.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".").replace(/[*]/g, ".$&");
73
- return new RegExp(`^${t}$`);
74
- }
75
71
  const Y = () => /* @__PURE__ */ new Set();
76
72
  class q extends U {
77
- constructor(e, r, n) {
73
+ constructor(e, t, n) {
78
74
  super();
79
75
  C(this, "_filteredOutRows$", new $(Y()));
80
76
  /** An observable value. A set of filtered out rows. */
@@ -85,7 +81,7 @@ class q extends U {
85
81
  C(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
86
82
  C(this, "_alreadyFilteredOutRows", Y());
87
83
  C(this, "_range");
88
- this.unitId = e, this.subUnitId = r, this._worksheet = n;
84
+ this.unitId = e, this.subUnitId = t, this._worksheet = n;
89
85
  }
90
86
  get filteredOutRows() {
91
87
  return this._filteredOutRows$.getValue();
@@ -102,7 +98,7 @@ class q extends U {
102
98
  serialize() {
103
99
  const e = {
104
100
  ref: te.clone(this._range),
105
- filterColumns: this._getAllFilterColumns(!0).sort(([r], [n]) => r - n).map(([r, n]) => n.serialize())
101
+ filterColumns: this._getAllFilterColumns(!0).sort(([t], [n]) => t - n).map(([t, n]) => n.serialize())
106
102
  };
107
103
  return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
108
104
  }
@@ -113,13 +109,13 @@ class q extends U {
113
109
  * @param worksheet the Worksheet object
114
110
  * @param autoFilter auto filter data
115
111
  */
116
- static deserialize(e, r, n, s) {
117
- const o = new q(e, r, n);
112
+ static deserialize(e, t, n, s) {
113
+ const o = new q(e, t, n);
118
114
  return o._dump(s), o;
119
115
  }
120
116
  _dump(e) {
121
- var r;
122
- this.setRange(e.ref), (r = e.filterColumns) == null || r.forEach((n) => this._setCriteriaWithoutReCalc(n.colId, n)), e.cachedFilteredOut && (this._alreadyFilteredOutRows = new Set(e.cachedFilteredOut), this._emit()), this._emitHasCriteria();
117
+ var t;
118
+ this.setRange(e.ref), (t = e.filterColumns) == null || t.forEach((n) => this._setCriteriaWithoutReCalc(n.colId, n)), e.cachedFilteredOut && (this._alreadyFilteredOutRows = new Set(e.cachedFilteredOut), this._emit()), this._emitHasCriteria();
123
119
  }
124
120
  isRowFiltered(e) {
125
121
  return this._alreadyFilteredOutRows.has(e);
@@ -135,9 +131,9 @@ class q extends U {
135
131
  * @param col
136
132
  */
137
133
  getFilteredOutRowsExceptCol(e) {
138
- return this._getAllFilterColumns(!0).filter(([r]) => r !== e).reduce((r, [, n]) => {
139
- const s = n.calc({ getAlreadyFilteredOutRows: () => r });
140
- return s ? K(r, s) : r;
134
+ return this._getAllFilterColumns(!0).filter(([t]) => t !== e).reduce((t, [, n]) => {
135
+ const s = n.calc({ getAlreadyFilteredOutRows: () => t });
136
+ return s ? K(t, s) : t;
141
137
  }, /* @__PURE__ */ new Set());
142
138
  }
143
139
  /**
@@ -145,45 +141,45 @@ class q extends U {
145
141
  * if the new range not overlaps the old range.
146
142
  */
147
143
  setRange(e) {
148
- this._range = e, this._getAllFilterColumns(!0).forEach(([r, n]) => {
144
+ this._range = e, this._getAllFilterColumns(!0).forEach(([t, n]) => {
149
145
  n.setRangeAndColumn({
150
146
  startRow: e.startRow,
151
147
  endRow: e.endRow,
152
- startColumn: r,
153
- endColumn: r
154
- }, r);
148
+ startColumn: t,
149
+ endColumn: t
150
+ }, t);
155
151
  });
156
152
  }
157
153
  /**
158
154
  * Set or remove filter criteria on a specific row.
159
155
  */
160
- setCriteria(e, r, n = !1) {
156
+ setCriteria(e, t, n = !1) {
161
157
  if (!this._range)
162
158
  throw new Error("[FilterModel] could not set criteria before a range is set!");
163
- if (!r) {
159
+ if (!t) {
164
160
  this._removeCriteria(e), this._rebuildAlreadyFilteredOutRowsWithCache(), n && this._reCalcAllColumns(), this._emit(), this._emitHasCriteria();
165
161
  return;
166
162
  }
167
- this._setCriteriaWithoutReCalc(e, r), n && (this._rebuildAlreadyFilteredOutRowsWithCache(), this._reCalcWithNoCacheColumns(), this._emit(), this._emitHasCriteria());
163
+ this._setCriteriaWithoutReCalc(e, t), n && (this._rebuildAlreadyFilteredOutRowsWithCache(), this._reCalcWithNoCacheColumns(), this._emit(), this._emitHasCriteria());
168
164
  }
169
165
  getAllFilterColumns() {
170
166
  return this._getAllFilterColumns(!0);
171
167
  }
172
168
  getFilterColumn(e) {
173
- var r;
174
- return (r = this._filterColumnByIndex.get(e)) != null ? r : null;
169
+ var t;
170
+ return (t = this._filterColumnByIndex.get(e)) != null ? t : null;
175
171
  }
176
172
  reCalc() {
177
173
  this._reCalcAllColumns(), this._emit();
178
174
  }
179
175
  _getAllFilterColumns(e = !1) {
180
- const r = Array.from(this._filterColumnByIndex.entries());
181
- return e ? r : r.map(([n, s]) => s);
176
+ const t = Array.from(this._filterColumnByIndex.entries());
177
+ return e ? t : t.map(([n, s]) => s);
182
178
  }
183
179
  _reCalcAllColumns() {
184
180
  this._alreadyFilteredOutRows = Y(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
185
181
  }
186
- _setCriteriaWithoutReCalc(e, r) {
182
+ _setCriteriaWithoutReCalc(e, t) {
187
183
  const n = this._range;
188
184
  if (!n)
189
185
  throw new Error("[FilterModel] could not set criteria before a range is set!");
@@ -195,13 +191,13 @@ class q extends U {
195
191
  this.unitId,
196
192
  this.subUnitId,
197
193
  this._worksheet,
198
- r,
194
+ t,
199
195
  { getAlreadyFilteredOutRows: () => this._alreadyFilteredOutRows }
200
- ), l.setRangeAndColumn(n, e), this._filterColumnByIndex.set(e, l)), l.setCriteria(r);
196
+ ), l.setRangeAndColumn(n, e), this._filterColumnByIndex.set(e, l)), l.setCriteria(t);
201
197
  }
202
198
  _removeCriteria(e) {
203
- const r = this._filterColumnByIndex.get(e);
204
- r && (r.dispose(), this._filterColumnByIndex.delete(e));
199
+ const t = this._filterColumnByIndex.get(e);
200
+ t && (t.dispose(), this._filterColumnByIndex.delete(e));
205
201
  }
206
202
  _emit() {
207
203
  this._filteredOutRows$.next(this._alreadyFilteredOutRows);
@@ -210,19 +206,19 @@ class q extends U {
210
206
  this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
211
207
  }
212
208
  _rebuildAlreadyFilteredOutRowsWithCache() {
213
- const e = this._getAllFilterColumns().filter((r) => r.hasCache()).reduce((r, n) => K(r, n.filteredOutRows), /* @__PURE__ */ new Set());
209
+ const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => K(t, n.filteredOutRows), /* @__PURE__ */ new Set());
214
210
  this._alreadyFilteredOutRows = e;
215
211
  }
216
212
  _reCalcWithNoCacheColumns() {
217
- const e = this._getAllFilterColumns().filter((r) => !r.hasCache());
218
- for (const r of e) {
219
- const n = r.reCalc();
213
+ const e = this._getAllFilterColumns().filter((t) => !t.hasCache());
214
+ for (const t of e) {
215
+ const n = t.reCalc();
220
216
  n && (this._alreadyFilteredOutRows = K(this._alreadyFilteredOutRows, n));
221
217
  }
222
218
  }
223
219
  }
224
220
  class yt extends U {
225
- constructor(e, r, n, s, o) {
221
+ constructor(e, t, n, s, o) {
226
222
  super();
227
223
  C(this, "_filteredOutRows", null);
228
224
  /** Cache the filter function. */
@@ -230,7 +226,7 @@ class yt extends U {
230
226
  C(this, "_range", null);
231
227
  C(this, "_column", 0);
232
228
  C(this, "_filterBy", b.VALUES);
233
- this.unitId = e, this.subUnitId = r, this._worksheet = n, this._criteria = s, this._filterColumnContext = o;
229
+ this.unitId = e, this.subUnitId = t, this._worksheet = n, this._criteria = s, this._filterColumnContext = o;
234
230
  }
235
231
  get filteredOutRows() {
236
232
  return this._filteredOutRows;
@@ -259,8 +255,8 @@ class yt extends U {
259
255
  return this._filteredOutRows !== null;
260
256
  }
261
257
  // The first row should be omitted!
262
- setRangeAndColumn(e, r) {
263
- this._range = e, this._column = r;
258
+ setRangeAndColumn(e, t) {
259
+ this._range = e, this._column = t;
264
260
  }
265
261
  setCriteria(e) {
266
262
  this._criteria = e, this._generateFilterFn(), this._filteredOutRows = null;
@@ -284,7 +280,7 @@ class yt extends U {
284
280
  throw new Error("[FilterColumn] cannot calculate without a range!");
285
281
  if (typeof this._column != "number")
286
282
  throw new TypeError("[FilterColumn] cannot calculate without a column offset!");
287
- const r = this._column, n = { startColumn: r, endColumn: r, startRow: this._range.startRow + 1, endRow: this._range.endRow }, s = /* @__PURE__ */ new Set(), o = e.getAlreadyFilteredOutRows();
283
+ const t = this._column, n = { startColumn: t, endColumn: t, startRow: this._range.startRow + 1, endRow: this._range.endRow }, s = /* @__PURE__ */ new Set(), o = e.getAlreadyFilteredOutRows();
288
284
  for (const l of this._worksheet.iterateByColumn(n, !1, !1)) {
289
285
  const { row: a, rowSpan: c, col: u } = l;
290
286
  if (o.has(a) && (!c || c === 1))
@@ -305,84 +301,84 @@ function At(i) {
305
301
  if (i.colorFilters)
306
302
  return Tt(i.colorFilters);
307
303
  if (i.customFilters)
308
- return xt(i.customFilters);
304
+ return It(i.customFilters);
309
305
  throw new Error("[FilterModel]: other types of filters are not supported yet.");
310
306
  }
311
307
  function Nt(i) {
312
- const t = !!i.blank, e = new Set(i.filters);
313
- return (r) => r === void 0 || r === "" ? t : e.has(typeof r == "string" ? r : `${r}`);
308
+ const r = !!i.blank, e = new Set(i.filters);
309
+ return (t) => t === void 0 || t === "" ? r : e.has(typeof t == "string" ? t : `${t}`);
314
310
  }
315
311
  function Tt(i) {
316
312
  if (i.cellFillColors) {
317
- const t = new Set(i.cellFillColors);
313
+ const r = new Set(i.cellFillColors);
318
314
  return (e) => {
319
315
  var n;
320
316
  if (!e || !((n = e.bg) != null && n.rgb))
321
- return !!t.has(null);
322
- const r = new se(e.bg.rgb).toRgbString();
323
- return t.has(r);
317
+ return !!r.has(null);
318
+ const t = new se(e.bg.rgb).toRgbString();
319
+ return r.has(t);
324
320
  };
325
321
  }
326
322
  if (i.cellTextColors) {
327
- const t = new Set(i.cellTextColors);
323
+ const r = new Set(i.cellTextColors);
328
324
  return (e) => {
329
325
  var n;
330
326
  if (!e || !((n = e.cl) != null && n.rgb))
331
- return !!t.has(mt);
332
- const r = new se(e.cl.rgb).toRgbString();
333
- return t.has(r);
327
+ return !!r.has(mt);
328
+ const t = new se(e.cl.rgb).toRgbString();
329
+ return r.has(t);
334
330
  };
335
331
  }
336
332
  throw new Error("[FilterModel]: color filters are not supported yet.");
337
333
  }
338
- function xt(i) {
339
- const t = i.customFilters.map((e) => Lt(e));
340
- return $t(t) ? i.and ? It(t) : bt(t) : t[0];
341
- }
342
334
  function It(i) {
343
- const [t, e] = i;
344
- return (r) => t(r) && e(r);
335
+ const r = i.customFilters.map((e) => Lt(e));
336
+ return $t(r) ? i.and ? xt(r) : bt(r) : r[0];
337
+ }
338
+ function xt(i) {
339
+ const [r, e] = i;
340
+ return (t) => r(t) && e(t);
345
341
  }
346
342
  function bt(i) {
347
- const [t, e] = i;
348
- return (r) => t(r) || e(r);
343
+ const [r, e] = i;
344
+ return (t) => r(t) || e(t);
349
345
  }
350
346
  function $t(i) {
351
347
  return i.length === 2;
352
348
  }
353
349
  function Lt(i) {
354
- const t = i.val;
355
- if (i.operator === x.NOT_EQUALS && !ce(t))
356
- return (n) => Ee.fn(n, t);
350
+ const r = i.val;
351
+ if (i.operator === I.NOT_EQUALS && !ce(r))
352
+ return (n) => Oe.fn(n, r);
357
353
  if (Mt(i.operator)) {
358
- if (!ce(t)) return () => !1;
359
- const n = ae(i.operator), s = Number(t);
354
+ if (!ce(r)) return () => !1;
355
+ const n = ae(i.operator), s = Number(r);
360
356
  return (o) => n.fn(o, s);
361
357
  }
362
358
  const e = ae(i.operator);
363
- return (r) => e.fn(r, t);
359
+ return (t) => e.fn(t, r);
364
360
  }
365
- function Ut(i, t, e) {
366
- const r = i.getCell(t, e);
367
- if (!r) return null;
368
- const n = i.getCellRaw(t, e);
369
- return r && !n ? de(r) : n ? r.t === k.NUMBER && typeof r.v == "string" ? n.v : r.t === k.NUMBER ? Number(n.v) : de(n) : null;
361
+ function Ut(i, r, e) {
362
+ const t = i.getCell(r, e);
363
+ if (!t) return null;
364
+ const n = i.getCellRaw(r, e);
365
+ return t && !n ? de(t) : n ? t.t === k.NUMBER && typeof t.v == "string" ? n.v : t.t === k.NUMBER ? Number(n.v) : de(n) : null;
370
366
  }
371
367
  function de(i) {
372
- var r, n;
373
- const t = (n = (r = i.p) == null ? void 0 : r.body) == null ? void 0 : n.dataStream;
374
- if (t) return t.trimEnd();
368
+ var t, n;
369
+ const r = (n = (t = i.p) == null ? void 0 : t.body) == null ? void 0 : n.dataStream;
370
+ if (r) return r.trimEnd();
375
371
  const e = i.v;
376
372
  return typeof e == "string" ? i.t === k.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === k.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
377
373
  }
378
- var Pt = Object.getOwnPropertyDescriptor, Dt = (i, t, e, r) => {
379
- for (var n = r > 1 ? void 0 : r ? Pt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
374
+ var Pt = Object.getOwnPropertyDescriptor, Dt = (i, r, e, t) => {
375
+ for (var n = t > 1 ? void 0 : t ? Pt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
380
376
  (o = i[s]) && (n = o(n) || n);
381
377
  return n;
382
- }, X = (i, t) => (e, r) => t(e, r, i);
378
+ }, X = (i, r) => (e, t) => r(e, t, i);
383
379
  const Ne = "SHEET_FILTER_PLUGIN";
384
380
  let M = class extends U {
385
- constructor(t, e, r) {
381
+ constructor(r, e, t) {
386
382
  super();
387
383
  C(this, "_filterModels", /* @__PURE__ */ new Map());
388
384
  C(this, "_loadedUnitId$", new $(null));
@@ -392,7 +388,7 @@ let M = class extends U {
392
388
  C(this, "_activeFilterModel$", new $(null));
393
389
  /** An observable value emitting the current Workbook's active Worksheet's filter model (if there is one). */
394
390
  C(this, "activeFilterModel$", this._activeFilterModel$.asObservable());
395
- this._resourcesManagerService = t, this._univerInstanceService = e, this._commandService = r, this._initModel(), this._initActiveFilterModel();
391
+ this._resourcesManagerService = r, this._univerInstanceService = e, this._commandService = t, this._initModel(), this._initActiveFilterModel();
396
392
  }
397
393
  /** The current Workbook's active Worksheet's filter model (if there is one). */
398
394
  get activeFilterModel() {
@@ -403,34 +399,34 @@ let M = class extends U {
403
399
  * @param unitId
404
400
  * @param subUnitId
405
401
  */
406
- ensureFilterModel(t, e) {
407
- const r = this.getFilterModel(t, e);
408
- if (r)
409
- return r;
410
- const n = this._univerInstanceService.getUniverSheetInstance(t);
402
+ ensureFilterModel(r, e) {
403
+ const t = this.getFilterModel(r, e);
404
+ if (t)
405
+ return t;
406
+ const n = this._univerInstanceService.getUniverSheetInstance(r);
411
407
  if (!n)
412
- throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${t}!`);
408
+ throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${r}!`);
413
409
  const s = n.getSheetBySheetId(e);
414
410
  if (!s)
415
411
  throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
416
- const o = new q(t, e, s);
417
- return this._cacheFilterModel(t, e, o), o;
412
+ const o = new q(r, e, s);
413
+ return this._cacheFilterModel(r, e, o), o;
418
414
  }
419
- getFilterModel(t, e) {
420
- var r, n;
421
- return (n = (r = this._filterModels.get(t)) == null ? void 0 : r.get(e)) != null ? n : null;
415
+ getFilterModel(r, e) {
416
+ var t, n;
417
+ return (n = (t = this._filterModels.get(r)) == null ? void 0 : t.get(e)) != null ? n : null;
422
418
  }
423
- removeFilterModel(t, e) {
424
- const r = this.getFilterModel(t, e);
425
- return r ? (r.dispose(), this._filterModels.get(t).delete(e), !0) : !1;
419
+ removeFilterModel(r, e) {
420
+ const t = this.getFilterModel(r, e);
421
+ return t ? (t.dispose(), this._filterModels.get(r).delete(e), !0) : !1;
426
422
  }
427
- setFilterErrorMsg(t) {
428
- this._errorMsg$.next(t);
423
+ setFilterErrorMsg(r) {
424
+ this._errorMsg$.next(r);
429
425
  }
430
426
  _updateActiveFilterModel() {
431
- let t;
427
+ let r;
432
428
  try {
433
- if (t = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !t) {
429
+ if (r = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !r) {
434
430
  this._activeFilterModel$.next(null);
435
431
  return;
436
432
  }
@@ -438,60 +434,60 @@ let M = class extends U {
438
434
  console.error("[SheetsFilterService]: could not get active workbook!", o);
439
435
  return;
440
436
  }
441
- const e = t.getActiveSheet(!0);
437
+ const e = r.getActiveSheet(!0);
442
438
  if (!e) {
443
439
  this._activeFilterModel$.next(null);
444
440
  return;
445
441
  }
446
- const r = e.getUnitId(), n = e.getSheetId(), s = this.getFilterModel(r, n);
442
+ const t = e.getUnitId(), n = e.getSheetId(), s = this.getFilterModel(t, n);
447
443
  this._activeFilterModel$.next(s);
448
444
  }
449
445
  _initActiveFilterModel() {
450
446
  this.disposeWithMe(
451
447
  dt(
452
448
  // source1: executing filter related mutations
453
- Pe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ut(([t]) => t.type === O.MUTATION && Me.has(t.id))),
449
+ Pe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ut(([r]) => r.type === O.MUTATION && Ee.has(r.id))),
454
450
  // source2: activate sheet changes
455
- this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(ht((t) => {
451
+ this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(ht((r) => {
456
452
  var e;
457
- return (e = t == null ? void 0 : t.activeSheet$) != null ? e : ft(null);
453
+ return (e = r == null ? void 0 : r.activeSheet$) != null ? e : ft(null);
458
454
  }))
459
455
  ).subscribe(() => this._updateActiveFilterModel())
460
456
  );
461
457
  }
462
- _serializeAutoFiltersForUnit(t) {
463
- const e = this._filterModels.get(t);
458
+ _serializeAutoFiltersForUnit(r) {
459
+ const e = this._filterModels.get(r);
464
460
  if (!e)
465
461
  return "{}";
466
- const r = {};
462
+ const t = {};
467
463
  return e.forEach((n, s) => {
468
- r[s] = n.serialize();
469
- }), JSON.stringify(r);
464
+ t[s] = n.serialize();
465
+ }), JSON.stringify(t);
470
466
  }
471
- _deserializeAutoFiltersForUnit(t, e) {
472
- const r = this._univerInstanceService.getUniverSheetInstance(t);
467
+ _deserializeAutoFiltersForUnit(r, e) {
468
+ const t = this._univerInstanceService.getUniverSheetInstance(r);
473
469
  Object.keys(e).forEach((n) => {
474
- const s = e[n], o = q.deserialize(t, n, r.getSheetBySheetId(n), s);
475
- this._cacheFilterModel(t, n, o);
470
+ const s = e[n], o = q.deserialize(r, n, t.getSheetBySheetId(n), s);
471
+ this._cacheFilterModel(r, n, o);
476
472
  });
477
473
  }
478
474
  _initModel() {
479
475
  this._resourcesManagerService.registerPluginResource({
480
476
  pluginName: Ne,
481
477
  businesses: [D.UNIVER_SHEET],
482
- toJson: (t) => this._serializeAutoFiltersForUnit(t),
483
- parseJson: (t) => JSON.parse(t),
484
- onLoad: (t, e) => {
485
- this._deserializeAutoFiltersForUnit(t, e), this._loadedUnitId$.next(t), this._updateActiveFilterModel();
478
+ toJson: (r) => this._serializeAutoFiltersForUnit(r),
479
+ parseJson: (r) => JSON.parse(r),
480
+ onLoad: (r, e) => {
481
+ this._deserializeAutoFiltersForUnit(r, e), this._loadedUnitId$.next(r), this._updateActiveFilterModel();
486
482
  },
487
- onUnLoad: (t) => {
488
- const e = this._filterModels.get(t);
489
- e && (e.forEach((r) => r.dispose()), this._filterModels.delete(t));
483
+ onUnLoad: (r) => {
484
+ const e = this._filterModels.get(r);
485
+ e && (e.forEach((t) => t.dispose()), this._filterModels.delete(r));
490
486
  }
491
487
  });
492
488
  }
493
- _cacheFilterModel(t, e, r) {
494
- this._filterModels.has(t) || this._filterModels.set(t, /* @__PURE__ */ new Map()), this._filterModels.get(t).set(e, r);
489
+ _cacheFilterModel(r, e, t) {
490
+ this._filterModels.has(r) || this._filterModels.set(r, /* @__PURE__ */ new Map()), this._filterModels.get(r).set(e, t);
495
491
  }
496
492
  };
497
493
  M = Dt([
@@ -500,44 +496,44 @@ M = Dt([
500
496
  X(2, N)
501
497
  ], M);
502
498
  const R = {
503
- id: Se,
499
+ id: Fe,
504
500
  type: O.MUTATION,
505
- handler: (i, t) => {
506
- const { subUnitId: e, unitId: r, range: n } = t;
507
- return i.get(M).ensureFilterModel(r, e).setRange(n), !0;
501
+ handler: (i, r) => {
502
+ const { subUnitId: e, unitId: t, range: n } = r;
503
+ return i.get(M).ensureFilterModel(t, e).setRange(n), !0;
508
504
  }
509
505
  }, p = {
510
- id: Fe,
506
+ id: we,
511
507
  type: O.MUTATION,
512
- handler: (i, t) => {
513
- const { subUnitId: e, unitId: r, criteria: n, col: s, reCalc: o = !0 } = t, a = i.get(M).getFilterModel(r, e);
508
+ handler: (i, r) => {
509
+ const { subUnitId: e, unitId: t, criteria: n, col: s, reCalc: o = !0 } = r, a = i.get(M).getFilterModel(t, e);
514
510
  return a ? (a.setCriteria(s, n, o), !0) : !1;
515
511
  }
516
512
  }, y = {
517
- id: we,
513
+ id: ve,
518
514
  type: O.MUTATION,
519
- handler: (i, t) => {
520
- const { unitId: e, subUnitId: r } = t;
521
- return i.get(M).removeFilterModel(e, r);
515
+ handler: (i, r) => {
516
+ const { unitId: e, subUnitId: t } = r;
517
+ return i.get(M).removeFilterModel(e, t);
522
518
  }
523
519
  }, B = {
524
- id: ve,
520
+ id: Me,
525
521
  type: O.MUTATION,
526
- handler: (i, t) => {
527
- const { unitId: e, subUnitId: r } = t, s = i.get(M).getFilterModel(e, r);
522
+ handler: (i, r) => {
523
+ const { unitId: e, subUnitId: t } = r, s = i.get(M).getFilterModel(e, t);
528
524
  return s ? (s.reCalc(), !0) : !1;
529
525
  }
530
526
  }, Bt = {
531
527
  id: "sheet.command.set-filter-range",
532
528
  type: O.COMMAND,
533
- handler: (i, t) => {
534
- const e = i.get(M), r = i.get(N), n = i.get(J), s = i.get(T), { unitId: o, subUnitId: l, range: a } = t;
535
- if (!H(s, t) || e.getFilterModel(o, l)) return !1;
529
+ handler: (i, r) => {
530
+ const e = i.get(M), t = i.get(N), n = i.get(J), s = i.get(T), { unitId: o, subUnitId: l, range: a } = r;
531
+ if (!H(s, r) || e.getFilterModel(o, l)) return !1;
536
532
  if (a.endRow === a.startRow) {
537
533
  const g = i.get(Be), _ = i.get(ze);
538
534
  return g.emit(_.t("sheets-filter.command.not-valid-filter-range")), !1;
539
535
  }
540
- const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, h = r.syncExecuteCommand(d.id, d.params);
536
+ const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, h = t.syncExecuteCommand(d.id, d.params);
541
537
  return h && n.pushUndoRedo({
542
538
  unitID: o,
543
539
  undoMutations: [{ id: y.id, params: { unitId: o, subUnitId: l } }],
@@ -547,10 +543,10 @@ const R = {
547
543
  }, zt = {
548
544
  id: "sheet.command.remove-sheet-filter",
549
545
  type: O.COMMAND,
550
- handler: (i, t) => {
551
- const e = i.get(T), r = i.get(M), n = i.get(N), s = i.get(J), o = H(e, t);
546
+ handler: (i, r) => {
547
+ const e = i.get(T), t = i.get(M), n = i.get(N), s = i.get(J), o = H(e, r);
552
548
  if (!o) return !1;
553
- const { unitId: l, subUnitId: a } = o, c = r.getFilterModel(l, a);
549
+ const { unitId: l, subUnitId: a } = o, c = t.getFilterModel(l, a);
554
550
  if (!c) return !1;
555
551
  const u = c == null ? void 0 : c.serialize(), d = Ht(l, a, u), h = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
556
552
  return h && s.pushUndoRedo({
@@ -563,15 +559,15 @@ const R = {
563
559
  id: "sheet.command.smart-toggle-filter",
564
560
  type: O.COMMAND,
565
561
  handler: async (i) => {
566
- const t = i.get(T), e = i.get(M), r = i.get(N), n = t.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
562
+ const r = i.get(T), e = i.get(M), t = i.get(N), n = r.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
567
563
  if (!s || !n) return !1;
568
564
  const o = n.getUnitId(), l = s.getSheetId();
569
565
  if (e.getFilterModel(o, l))
570
- return r.executeCommand(zt.id, { unitId: o, subUnitId: l });
566
+ return t.executeCommand(zt.id, { unitId: o, subUnitId: l });
571
567
  const u = i.get(qe).getCurrentLastSelection();
572
568
  if (!u) return !1;
573
- const d = u.range, h = Ge(u) ? _e(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
574
- return r.executeCommand(Bt.id, {
569
+ const d = u.range, h = Ge(u) ? Ce(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
570
+ return t.executeCommand(Bt.id, {
575
571
  unitId: o,
576
572
  subUnitId: l,
577
573
  range: h
@@ -580,8 +576,8 @@ const R = {
580
576
  }, cr = {
581
577
  id: "sheet.command.set-filter-criteria",
582
578
  type: O.COMMAND,
583
- handler: (i, t) => {
584
- const e = i.get(M), r = i.get(N), n = i.get(J), { unitId: s, subUnitId: o, col: l, criteria: a } = t, c = e.getFilterModel(s, o);
579
+ handler: (i, r) => {
580
+ const e = i.get(M), t = i.get(N), n = i.get(J), { unitId: s, subUnitId: o, col: l, criteria: a } = r, c = e.getFilterModel(s, o);
585
581
  if (!c) return !1;
586
582
  const u = c.getRange();
587
583
  if (!u || l < u.startColumn || l > u.endColumn) return !1;
@@ -593,7 +589,7 @@ const R = {
593
589
  col: l,
594
590
  criteria: a
595
591
  }
596
- }, _ = r.syncExecuteCommand(g.id, g.params);
592
+ }, _ = t.syncExecuteCommand(g.id, g.params);
597
593
  return _ && n.pushUndoRedo({
598
594
  unitID: s,
599
595
  undoMutations: [h],
@@ -603,13 +599,13 @@ const R = {
603
599
  }, dr = {
604
600
  id: "sheet.command.clear-filter-criteria",
605
601
  type: O.COMMAND,
606
- handler: (i, t) => {
607
- const e = i.get(M), r = i.get(J), n = i.get(N), s = i.get(T), o = H(s, t);
602
+ handler: (i, r) => {
603
+ const e = i.get(M), t = i.get(J), n = i.get(N), s = i.get(T), o = H(s, r);
608
604
  if (!o) return !1;
609
605
  const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
610
606
  if (!c) return !1;
611
607
  const u = c.serialize(), d = Te(l, a, u), h = Vt(l, a, u);
612
- return j(h, n).result ? (r.pushUndoRedo({
608
+ return j(h, n).result ? (t.pushUndoRedo({
613
609
  unitID: l,
614
610
  undoMutations: d,
615
611
  redoMutations: h
@@ -618,108 +614,108 @@ const R = {
618
614
  }, ur = {
619
615
  id: "sheet.command.re-calc-filter",
620
616
  type: O.COMMAND,
621
- handler: (i, t) => {
622
- const e = i.get(M), r = i.get(N), n = i.get(T), s = H(n, t);
617
+ handler: (i, r) => {
618
+ const e = i.get(M), t = i.get(N), n = i.get(T), s = H(n, r);
623
619
  if (!s) return !1;
624
620
  const { unitId: o, subUnitId: l } = s;
625
- return e.getFilterModel(s.unitId, s.subUnitId) ? r.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
621
+ return e.getFilterModel(s.unitId, s.subUnitId) ? t.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
626
622
  }
627
623
  };
628
- function Ht(i, t, e) {
629
- const r = [], n = {
624
+ function Ht(i, r, e) {
625
+ const t = [], n = {
630
626
  id: R.id,
631
627
  params: {
632
628
  unitId: i,
633
- subUnitId: t,
629
+ subUnitId: r,
634
630
  range: e.ref
635
631
  }
636
632
  };
637
- return r.push(n), Te(i, t, e).forEach((o) => r.push(o)), r;
633
+ return t.push(n), Te(i, r, e).forEach((o) => t.push(o)), t;
638
634
  }
639
- function Te(i, t, e) {
635
+ function Te(i, r, e) {
640
636
  var n;
641
- const r = [];
637
+ const t = [];
642
638
  return (n = e.filterColumns) == null || n.forEach((s) => {
643
639
  const o = {
644
640
  id: p.id,
645
641
  params: {
646
642
  unitId: i,
647
- subUnitId: t,
643
+ subUnitId: r,
648
644
  col: s.colId,
649
645
  criteria: s
650
646
  }
651
647
  };
652
- r.push(o);
653
- }), r;
648
+ t.push(o);
649
+ }), t;
654
650
  }
655
- function Vt(i, t, e) {
651
+ function Vt(i, r, e) {
656
652
  var n;
657
- const r = [];
653
+ const t = [];
658
654
  return (n = e.filterColumns) == null || n.forEach((s) => {
659
655
  const o = {
660
656
  id: p.id,
661
657
  params: {
662
658
  unitId: i,
663
- subUnitId: t,
659
+ subUnitId: r,
664
660
  col: s.colId,
665
661
  criteria: null
666
662
  }
667
663
  };
668
- r.push(o);
669
- }), r;
664
+ t.push(o);
665
+ }), t;
670
666
  }
671
- function Wt(i, t, e, r) {
672
- if (!r)
667
+ function Wt(i, r, e, t) {
668
+ if (!t)
673
669
  return {
674
670
  id: p.id,
675
671
  params: {
676
672
  unitId: i,
677
- subUnitId: t,
673
+ subUnitId: r,
678
674
  col: e,
679
675
  criteria: null
680
676
  }
681
677
  };
682
- const n = r.serialize();
678
+ const n = t.serialize();
683
679
  return {
684
680
  id: p.id,
685
681
  params: {
686
682
  unitId: i,
687
- subUnitId: t,
683
+ subUnitId: r,
688
684
  col: e,
689
685
  criteria: n
690
686
  }
691
687
  };
692
688
  }
693
- const xe = "sheets-filter.config", ue = {};
694
- function jt(i, t) {
689
+ const Ie = "sheets-filter.config", ue = {};
690
+ function jt(i, r) {
695
691
  for (let e = 0; e < i.length; e++) {
696
- let r = e;
692
+ let t = e;
697
693
  if (i[e])
698
694
  for (let n = e + 1; n < i.length; n++)
699
- i[r] && i[n] && t(i[r], i[n]) && (i[r] = null, r = n);
695
+ i[t] && i[n] && r(i[t], i[n]) && (i[t] = null, t = n);
700
696
  }
701
697
  return i.filter((e) => e !== null);
702
698
  }
703
699
  function L(i) {
704
- return jt(i, (t, e) => t.id === p.id && e.id === p.id && t.params.unitId === e.params.unitId && t.params.subUnitId === e.params.subUnitId && t.params.col === e.params.col);
700
+ return jt(i, (r, e) => r.id === p.id && e.id === p.id && r.params.unitId === e.params.unitId && r.params.subUnitId === e.params.subUnitId && r.params.col === e.params.col);
705
701
  }
706
- var kt = Object.getOwnPropertyDescriptor, qt = (i, t, e, r) => {
707
- for (var n = r > 1 ? void 0 : r ? kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
702
+ var kt = Object.getOwnPropertyDescriptor, qt = (i, r, e, t) => {
703
+ for (var n = t > 1 ? void 0 : t ? kt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
708
704
  (o = i[s]) && (n = o(n) || n);
709
705
  return n;
710
- }, I = (i, t) => (e, r) => t(e, r, i);
706
+ }, x = (i, r) => (e, t) => r(e, t, i);
711
707
  let z = class extends U {
712
- constructor(t, e, r, n, s, o, l) {
708
+ constructor(r, e, t, n, s, o, l) {
713
709
  super();
714
- C(this, "_disposableCollection", new me());
715
- this._commandService = t, this._sheetInterceptorService = e, this._sheetsFilterService = r, this._univerInstanceService = n, this._refRangeService = s, this._dataSyncPrimaryController = o, this._zebraCrossingCacheController = l, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling(), this._initZebraCrossingCacheListener();
710
+ C(this, "_disposableCollection", new ge());
711
+ this._commandService = r, this._sheetInterceptorService = e, this._sheetsFilterService = t, this._univerInstanceService = n, this._refRangeService = s, this._dataSyncPrimaryController = o, this._zebraCrossingCacheController = l, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling(), this._initZebraCrossingCacheListener();
716
712
  }
717
713
  _initZebraCrossingCacheListener() {
718
714
  this.disposeWithMe(
719
- this._sheetsFilterService.activeFilterModel$.subscribe((t) => {
720
- t && this.disposeWithMe(
721
- t.filteredOutRows$.subscribe(() => {
722
- this._zebraCrossingCacheController.updateZebraCrossingCache(t.unitId, t.subUnitId);
715
+ this._sheetsFilterService.activeFilterModel$.subscribe((r) => {
716
+ r && this.disposeWithMe(
717
+ r.filteredOutRows$.subscribe(() => {
718
+ this._zebraCrossingCacheController.updateZebraCrossingCache(r.unitId, r.subUnitId);
723
719
  })
724
720
  );
725
721
  })
@@ -731,86 +727,86 @@ let z = class extends U {
731
727
  R,
732
728
  B,
733
729
  y
734
- ].forEach((t) => {
730
+ ].forEach((r) => {
735
731
  var e;
736
- this.disposeWithMe(this._commandService.registerCommand(t)), (e = this._dataSyncPrimaryController) == null || e.registerSyncingMutations(t);
732
+ this.disposeWithMe(this._commandService.registerCommand(r)), (e = this._dataSyncPrimaryController) == null || e.registerSyncingMutations(r);
737
733
  });
738
734
  }
739
735
  _initInterceptors() {
740
736
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
741
- getMutations: (t) => this._getUpdateFilter(t)
742
- })), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
743
- if (t.id === Ke.id) {
744
- const e = t.params, r = e.subUnitId, n = e.unitId;
745
- if (!r || !n)
737
+ getMutations: (r) => this._getUpdateFilter(r)
738
+ })), this.disposeWithMe(this._commandService.onCommandExecuted((r) => {
739
+ if (r.id === Ke.id) {
740
+ const e = r.params, t = e.subUnitId, n = e.unitId;
741
+ if (!t || !n)
746
742
  return;
747
- this._registerRefRange(n, r);
743
+ this._registerRefRange(n, t);
748
744
  }
749
- if (t.id === R.id) {
750
- const e = t.params, r = e.subUnitId, n = e.unitId;
751
- if (!r || !n)
745
+ if (r.id === R.id) {
746
+ const e = r.params, t = e.subUnitId, n = e.unitId;
747
+ if (!t || !n)
752
748
  return;
753
749
  this._registerRefRange(e.unitId, e.subUnitId);
754
750
  }
755
- })), this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe((t) => {
756
- if (t) {
757
- const e = this._univerInstanceService.getUniverSheetInstance(t), r = e == null ? void 0 : e.getActiveSheet();
758
- r && this._registerRefRange(t, r.getSheetId());
751
+ })), this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe((r) => {
752
+ if (r) {
753
+ const e = this._univerInstanceService.getUniverSheetInstance(r), t = e == null ? void 0 : e.getActiveSheet();
754
+ t && this._registerRefRange(r, t.getSheetId());
759
755
  }
760
756
  }));
761
757
  }
762
- _registerRefRange(t, e) {
758
+ _registerRefRange(r, e) {
763
759
  var l;
764
760
  this._disposableCollection.dispose();
765
- const r = this._univerInstanceService.getUniverSheetInstance(t), n = r == null ? void 0 : r.getSheetBySheetId(e);
766
- if (!r || !n) return;
767
- const s = (l = this._sheetsFilterService.getFilterModel(t, e)) == null ? void 0 : l.getRange(), o = (a) => {
761
+ const t = this._univerInstanceService.getUniverSheetInstance(r), n = t == null ? void 0 : t.getSheetBySheetId(e);
762
+ if (!t || !n) return;
763
+ const s = (l = this._sheetsFilterService.getFilterModel(r, e)) == null ? void 0 : l.getRange(), o = (a) => {
768
764
  switch (a.id) {
769
765
  case ct.id: {
770
- const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
766
+ const c = a.params, u = c.unitId || r, d = c.subUnitId || e;
771
767
  return this._handleInsertRowCommand(c, u, d);
772
768
  }
773
769
  case at.id: {
774
- const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
770
+ const c = a.params, u = c.unitId || r, d = c.subUnitId || e;
775
771
  return this.handleInsertColCommand(c.range, u, d);
776
772
  }
777
773
  case lt.id: {
778
774
  const c = a.params;
779
- return this.handleRemoveColCommand(c.range, t, e);
775
+ return this.handleRemoveColCommand(c.range, r, e);
780
776
  }
781
777
  case ot.id: {
782
778
  const c = a.params;
783
- return this._handleRemoveRowCommand(c, t, e);
779
+ return this._handleRemoveRowCommand(c, r, e);
784
780
  }
785
781
  case le.MoveColsCommandId: {
786
782
  const c = a.params;
787
783
  return this.handleMoveColsCommand({
788
784
  fromRange: c.fromRange,
789
785
  toRange: c.toRange
790
- }, t, e);
786
+ }, r, e);
791
787
  }
792
788
  case le.MoveRowsCommandId: {
793
789
  const c = a.params;
794
- return this._handleMoveRowsCommand(c, t, e);
790
+ return this._handleMoveRowsCommand(c, r, e);
795
791
  }
796
792
  case st.id: {
797
793
  const c = a.params;
798
- return this._handleMoveRangeCommand(c, t, e);
794
+ return this._handleMoveRangeCommand(c, r, e);
799
795
  }
800
796
  }
801
797
  return { redos: [], undos: [] };
802
798
  };
803
- s && this._disposableCollection.add(this._refRangeService.registerRefRange(s, o, t, e));
799
+ s && this._disposableCollection.add(this._refRangeService.registerRefRange(s, o, r, e));
804
800
  }
805
- _getUpdateFilter(t) {
806
- const { id: e } = t;
801
+ _getUpdateFilter(r) {
802
+ const { id: e } = r;
807
803
  switch (e) {
808
804
  case Xe.id: {
809
- const r = t.params;
810
- return this._handleRemoveSheetCommand(r, r.unitId, r.subUnitId);
805
+ const t = r.params;
806
+ return this._handleRemoveSheetCommand(t, t.unitId, t.subUnitId);
811
807
  }
812
808
  case Ye.id: {
813
- const r = t.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = r;
809
+ const t = r.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = t;
814
810
  return !s || !o || !n ? this._handleNull() : this._handleCopySheetCommand(s, o, n);
815
811
  }
816
812
  }
@@ -819,17 +815,17 @@ let z = class extends U {
819
815
  undos: []
820
816
  };
821
817
  }
822
- handleInsertColCommand(t, e, r) {
818
+ handleInsertColCommand(r, e, t) {
823
819
  var f;
824
- const n = this._sheetsFilterService.getFilterModel(e, r), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
820
+ const n = this._sheetsFilterService.getFilterModel(e, t), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
825
821
  if (!n || !s)
826
822
  return this._handleNull();
827
- const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = t, u = c - a + 1;
823
+ const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = r, u = c - a + 1;
828
824
  if (c > l)
829
825
  return this._handleNull();
830
826
  const d = [], h = [], g = a, _ = {
831
827
  unitId: e,
832
- subUnitId: r,
828
+ subUnitId: t,
833
829
  range: {
834
830
  ...s,
835
831
  startColumn: a <= o ? o + u : o,
@@ -837,28 +833,28 @@ let z = class extends U {
837
833
  }
838
834
  }, S = {
839
835
  unitId: e,
840
- subUnitId: r,
836
+ subUnitId: t,
841
837
  range: s
842
838
  };
843
839
  d.push({ id: R.id, params: _ }), h.push({ id: R.id, params: S });
844
840
  const F = n.getAllFilterColumns().filter((m) => m[0] >= g);
845
841
  if (F.length !== 0) {
846
- const { newRange: m, oldRange: v } = this._moveCriteria(e, r, F, u);
842
+ const { newRange: m, oldRange: v } = this._moveCriteria(e, t, F, u);
847
843
  d.push(...v.redos, ...m.redos), h.push(...m.undos, ...v.undos);
848
844
  }
849
845
  return { redos: L(d), undos: L(h) };
850
846
  }
851
- _handleInsertRowCommand(t, e, r) {
847
+ _handleInsertRowCommand(r, e, t) {
852
848
  var S;
853
- const n = this._sheetsFilterService.getFilterModel(e, r), s = (S = n == null ? void 0 : n.getRange()) != null ? S : null;
849
+ const n = this._sheetsFilterService.getFilterModel(e, t), s = (S = n == null ? void 0 : n.getRange()) != null ? S : null;
854
850
  if (!n || !s)
855
851
  return this._handleNull();
856
- const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = t.range, u = c - a + 1;
852
+ const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = r.range, u = c - a + 1;
857
853
  if (c > l)
858
854
  return this._handleNull();
859
855
  const d = [], h = [], g = {
860
856
  unitId: e,
861
- subUnitId: r,
857
+ subUnitId: t,
862
858
  range: {
863
859
  ...s,
864
860
  startRow: a <= o ? o + u : o,
@@ -866,7 +862,7 @@ let z = class extends U {
866
862
  }
867
863
  }, _ = {
868
864
  unitId: e,
869
- subUnitId: r,
865
+ subUnitId: t,
870
866
  range: s
871
867
  };
872
868
  return d.push({ id: R.id, params: g }), h.push({ id: R.id, params: _ }), {
@@ -874,18 +870,18 @@ let z = class extends U {
874
870
  undos: L(h)
875
871
  };
876
872
  }
877
- handleRemoveColCommand(t, e, r) {
873
+ handleRemoveColCommand(r, e, t) {
878
874
  var F;
879
- const n = this._sheetsFilterService.getFilterModel(e, r), s = (F = n == null ? void 0 : n.getRange()) != null ? F : null;
875
+ const n = this._sheetsFilterService.getFilterModel(e, t), s = (F = n == null ? void 0 : n.getRange()) != null ? F : null;
880
876
  if (!n || !s)
881
877
  return this._handleNull();
882
- const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = t;
878
+ const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = r;
883
879
  if (a > l)
884
880
  return this._handleNull();
885
881
  const u = [], d = [], h = c < o ? 0 : Math.min(c, l) - Math.max(a, o) + 1, g = c - a + 1, _ = n.getAllFilterColumns();
886
882
  _.forEach((f) => {
887
883
  const [m, v] = f;
888
- m <= c && m >= a && (u.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: null } }), d.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
884
+ m <= c && m >= a && (u.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: null } }), d.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: { ...v.serialize(), colId: m } } }));
889
885
  });
890
886
  const S = _.filter((f) => {
891
887
  const [m, v] = f;
@@ -893,39 +889,39 @@ let z = class extends U {
893
889
  });
894
890
  let w = { undos: [], redos: [] };
895
891
  if (S.length > 0) {
896
- const { oldRange: f, newRange: m } = this._moveCriteria(e, r, S, -g);
892
+ const { oldRange: f, newRange: m } = this._moveCriteria(e, t, S, -g);
897
893
  w = m, u.push(...f.redos), d.unshift(...f.undos);
898
894
  }
899
895
  if (h === l - o + 1) {
900
896
  const f = {
901
897
  unitId: e,
902
- subUnitId: r
898
+ subUnitId: t
903
899
  };
904
- u.push({ id: y.id, params: f }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } });
900
+ u.push({ id: y.id, params: f }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
905
901
  } else {
906
902
  const f = o <= a ? o : h === 0 ? o - g : a, m = o <= a ? l - h : l - g, v = {
907
903
  unitId: e,
908
- subUnitId: r,
904
+ subUnitId: t,
909
905
  range: { ...s, startColumn: f, endColumn: m }
910
906
  };
911
- u.push({ id: R.id, params: v }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }), u.push(...w.redos), d.unshift(...w.undos);
907
+ u.push({ id: R.id, params: v }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), u.push(...w.redos), d.unshift(...w.undos);
912
908
  }
913
909
  return {
914
910
  undos: d,
915
911
  redos: u
916
912
  };
917
913
  }
918
- _handleRemoveRowCommand(t, e, r) {
914
+ _handleRemoveRowCommand(r, e, t) {
919
915
  var S;
920
- const n = this._sheetsFilterService.getFilterModel(e, r);
916
+ const n = this._sheetsFilterService.getFilterModel(e, t);
921
917
  if (!n)
922
918
  return this._handleNull();
923
- const s = n.getRange(), { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = t.range;
919
+ const s = n.getRange(), { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = r.range;
924
920
  if (a > l)
925
921
  return this._handleNull();
926
922
  if (c < o)
927
923
  return {
928
- undos: [{ id: R.id, params: { range: s, unitId: e, subUnitId: r } }],
924
+ undos: [{ id: R.id, params: { range: s, unitId: e, subUnitId: t } }],
929
925
  redos: [{
930
926
  id: R.id,
931
927
  params: {
@@ -935,29 +931,29 @@ let z = class extends U {
935
931
  endRow: l - (c - a + 1)
936
932
  },
937
933
  unitId: e,
938
- subUnitId: r
934
+ subUnitId: t
939
935
  }
940
936
  }]
941
937
  };
942
938
  const u = [], d = [], h = n.getAllFilterColumns(), g = o <= c && o >= a;
943
- d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } });
939
+ d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
944
940
  const _ = Math.min(c, l) - Math.max(a, o) + 1;
945
941
  if (_ === l - o + 1 || g) {
946
942
  const w = {
947
943
  unitId: e,
948
- subUnitId: r
944
+ subUnitId: t
949
945
  };
950
946
  u.push({ id: y.id, params: w }), h.forEach((F) => {
951
947
  const [f, m] = F, v = {
952
948
  unitId: e,
953
- subUnitId: r,
949
+ subUnitId: t,
954
950
  col: f,
955
951
  criteria: { ...m.serialize(), colId: f }
956
952
  };
957
953
  d.push({ id: p.id, params: v });
958
954
  });
959
955
  } else {
960
- const w = (S = this._univerInstanceService.getUniverSheetInstance(e)) == null ? void 0 : S.getSheetBySheetId(r);
956
+ const w = (S = this._univerInstanceService.getUniverSheetInstance(e)) == null ? void 0 : S.getSheetBySheetId(t);
961
957
  if (!w)
962
958
  return this._handleNull();
963
959
  const F = [];
@@ -965,7 +961,7 @@ let z = class extends U {
965
961
  w.getRowFiltered(E) && F.push(E);
966
962
  const f = Math.min(o, a), m = f + (l - o) - _ + F.length, v = {
967
963
  unitId: e,
968
- subUnitId: r,
964
+ subUnitId: t,
969
965
  range: {
970
966
  ...s,
971
967
  startRow: f,
@@ -980,13 +976,13 @@ let z = class extends U {
980
976
  };
981
977
  }
982
978
  // eslint-disable-next-line max-lines-per-function
983
- handleMoveColsCommand({ fromRange: t, toRange: e }, r, n) {
979
+ handleMoveColsCommand({ fromRange: r, toRange: e }, t, n) {
984
980
  var F;
985
- const s = this._sheetsFilterService.getFilterModel(r, n), o = (F = s == null ? void 0 : s.getRange()) != null ? F : null;
981
+ const s = this._sheetsFilterService.getFilterModel(t, n), o = (F = s == null ? void 0 : s.getRange()) != null ? F : null;
986
982
  if (!s || !o)
987
983
  return this._handleNull();
988
984
  const { startColumn: l, endColumn: a } = o;
989
- if (t.endColumn < l && e.startColumn <= l || t.startColumn > a && e.endColumn > a)
985
+ if (r.endColumn < l && e.startColumn <= l || r.startColumn > a && e.endColumn > a)
990
986
  return this._handleNull();
991
987
  const c = [], u = [], d = {};
992
988
  for (let f = l; f <= a; f++)
@@ -994,9 +990,9 @@ let z = class extends U {
994
990
  colIndex: f,
995
991
  filter: s.getFilterColumn(f)
996
992
  };
997
- oe(t.startColumn, t.endColumn - t.startColumn + 1, e.startColumn, d);
993
+ oe(r.startColumn, r.endColumn - r.startColumn + 1, e.startColumn, d);
998
994
  let h = o.startColumn, g = o.endColumn;
999
- l >= t.startColumn && l <= t.endColumn && e.startColumn > t.startColumn && t.endColumn < a && (h = t.endColumn + 1), a >= t.startColumn && a <= t.endColumn && e.startColumn < t.startColumn && t.startColumn > l && (g = t.startColumn - 1);
995
+ l >= r.startColumn && l <= r.endColumn && e.startColumn > r.startColumn && r.endColumn < a && (h = r.endColumn + 1), a >= r.startColumn && a <= r.endColumn && e.startColumn < r.startColumn && r.startColumn > l && (g = r.startColumn - 1);
1000
996
  const _ = Object.keys(d).map((f) => Number(f)), S = _.find((f) => d[f].colIndex === g), w = _.find((f) => d[f].colIndex === h);
1001
997
  if (_.forEach((f) => {
1002
998
  var re, ne;
@@ -1004,31 +1000,31 @@ let z = class extends U {
1004
1000
  if (v) {
1005
1001
  if (E >= w && E <= S) {
1006
1002
  const Z = {
1007
- unitId: r,
1003
+ unitId: t,
1008
1004
  subUnitId: n,
1009
1005
  col: E,
1010
1006
  criteria: { ...v.serialize(), colId: E }
1011
- }, Ie = {
1012
- unitId: r,
1007
+ }, xe = {
1008
+ unitId: t,
1013
1009
  subUnitId: n,
1014
1010
  col: E,
1015
1011
  criteria: s.getFilterColumn(E) ? { ...(re = s.getFilterColumn(E)) == null ? void 0 : re.serialize(), colId: E } : null
1016
1012
  };
1017
- c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: Ie });
1013
+ c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: xe });
1018
1014
  }
1019
1015
  if (!((ne = d[m]) != null && ne.filter)) {
1020
1016
  const Z = {
1021
- unitId: r,
1017
+ unitId: t,
1022
1018
  subUnitId: n,
1023
1019
  col: m,
1024
1020
  criteria: null
1025
1021
  };
1026
- c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: { unitId: r, subUnitId: n, col: m, criteria: { ...v.serialize(), colId: m } } });
1022
+ c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: { unitId: t, subUnitId: n, col: m, criteria: { ...v.serialize(), colId: m } } });
1027
1023
  }
1028
1024
  }
1029
1025
  }), l !== w || a !== S) {
1030
1026
  const f = {
1031
- unitId: r,
1027
+ unitId: t,
1032
1028
  subUnitId: n,
1033
1029
  range: {
1034
1030
  ...o,
@@ -1036,19 +1032,19 @@ let z = class extends U {
1036
1032
  endColumn: S
1037
1033
  }
1038
1034
  };
1039
- c.unshift({ id: R.id, params: f }), u.unshift({ id: R.id, params: { range: o, unitId: r, subUnitId: n } });
1035
+ c.unshift({ id: R.id, params: f }), u.unshift({ id: R.id, params: { range: o, unitId: t, subUnitId: n } });
1040
1036
  }
1041
1037
  return {
1042
1038
  undos: u,
1043
1039
  redos: c
1044
1040
  };
1045
1041
  }
1046
- _handleMoveRowsCommand(t, e, r) {
1042
+ _handleMoveRowsCommand(r, e, t) {
1047
1043
  var f;
1048
- const n = this._sheetsFilterService.getFilterModel(e, r), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
1044
+ const n = this._sheetsFilterService.getFilterModel(e, t), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
1049
1045
  if (!n || !s)
1050
1046
  return this._handleNull();
1051
- const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } = t;
1047
+ const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } = r;
1052
1048
  if (a.endRow < o && c.startRow <= o || a.startRow > l && c.endRow > l)
1053
1049
  return this._handleNull();
1054
1050
  const u = [], d = [], h = {};
@@ -1063,22 +1059,22 @@ let z = class extends U {
1063
1059
  if (o !== F || l !== w) {
1064
1060
  const m = {
1065
1061
  unitId: e,
1066
- subUnitId: r,
1062
+ subUnitId: t,
1067
1063
  range: {
1068
1064
  ...s,
1069
1065
  startRow: F,
1070
1066
  endRow: w
1071
1067
  }
1072
1068
  };
1073
- u.push({ id: R.id, params: m }, { id: B.id, params: { unitId: e, subUnitId: r } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }, { id: B.id, params: { unitId: e, subUnitId: r } });
1069
+ u.push({ id: R.id, params: m }, { id: B.id, params: { unitId: e, subUnitId: t } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }, { id: B.id, params: { unitId: e, subUnitId: t } });
1074
1070
  }
1075
1071
  return {
1076
1072
  redos: u,
1077
1073
  undos: d
1078
1074
  };
1079
1075
  }
1080
- _handleMoveRangeCommand(t, e, r) {
1081
- const { fromRange: n, toRange: s } = t, o = this._sheetsFilterService.getFilterModel(e, r);
1076
+ _handleMoveRangeCommand(r, e, t) {
1077
+ const { fromRange: n, toRange: s } = r, o = this._sheetsFilterService.getFilterModel(e, t);
1082
1078
  if (!o)
1083
1079
  return this._handleNull();
1084
1080
  const l = o.getRange();
@@ -1095,29 +1091,29 @@ let z = class extends U {
1095
1091
  id: y.id,
1096
1092
  params: {
1097
1093
  unitId: e,
1098
- subUnitId: r
1094
+ subUnitId: t
1099
1095
  }
1100
- }, _ = { id: R.id, params: { unitId: e, subUnitId: r, range: h } }, S = { id: R.id, params: { unitId: e, subUnitId: r, range: l } };
1096
+ }, _ = { id: R.id, params: { unitId: e, subUnitId: t, range: h } }, S = { id: R.id, params: { unitId: e, subUnitId: t, range: l } };
1101
1097
  a.push(g, _), c.push(g, S);
1102
1098
  const w = o.getAllFilterColumns(), F = s.startColumn - n.startColumn;
1103
1099
  w.forEach((f) => {
1104
1100
  const [m, v] = f;
1105
- v && (a.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m + F, criteria: { ...v.serialize(), colId: m + F } } }), c.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
1101
+ v && (a.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m + F, criteria: { ...v.serialize(), colId: m + F } } }), c.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: { ...v.serialize(), colId: m } } }));
1106
1102
  });
1107
1103
  } else if (te.intersects(s, l)) {
1108
1104
  const u = {
1109
1105
  ...l,
1110
1106
  endRow: Math.max(l.endRow, s.endRow)
1111
1107
  };
1112
- a.push({ id: R.id, params: { unitId: e, subUnitId: r, range: u } }), c.push({ id: R.id, params: { unitId: e, subUnitId: r, range: l } });
1108
+ a.push({ id: R.id, params: { unitId: e, subUnitId: t, range: u } }), c.push({ id: R.id, params: { unitId: e, subUnitId: t, range: l } });
1113
1109
  }
1114
1110
  return {
1115
1111
  redos: a,
1116
1112
  undos: c
1117
1113
  };
1118
1114
  }
1119
- _handleRemoveSheetCommand(t, e, r) {
1120
- const n = this._sheetsFilterService.getFilterModel(e, r);
1115
+ _handleRemoveSheetCommand(r, e, t) {
1116
+ const n = this._sheetsFilterService.getFilterModel(e, t);
1121
1117
  if (!n)
1122
1118
  return this._handleNull();
1123
1119
  const s = n.getRange();
@@ -1125,14 +1121,14 @@ let z = class extends U {
1125
1121
  return this._handleNull();
1126
1122
  const o = [], l = [];
1127
1123
  return n.getAllFilterColumns().forEach(([c, u]) => {
1128
- l.push({ id: p.id, params: { unitId: e, subUnitId: r, col: c, criteria: { ...u.serialize(), colId: c } } });
1129
- }), o.push({ id: y.id, params: { unitId: e, subUnitId: r, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }), {
1124
+ l.push({ id: p.id, params: { unitId: e, subUnitId: t, col: c, criteria: { ...u.serialize(), colId: c } } });
1125
+ }), o.push({ id: y.id, params: { unitId: e, subUnitId: t, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), {
1130
1126
  undos: l,
1131
1127
  redos: o
1132
1128
  };
1133
1129
  }
1134
- _handleCopySheetCommand(t, e, r) {
1135
- const n = this._sheetsFilterService.getFilterModel(t, e);
1130
+ _handleCopySheetCommand(r, e, t) {
1131
+ const n = this._sheetsFilterService.getFilterModel(r, e);
1136
1132
  if (!n)
1137
1133
  return this._handleNull();
1138
1134
  const s = n.getRange();
@@ -1140,8 +1136,8 @@ let z = class extends U {
1140
1136
  return this._handleNull();
1141
1137
  const o = [], l = [], a = [], c = [];
1142
1138
  return n.getAllFilterColumns().forEach(([d, h]) => {
1143
- o.push({ id: p.id, params: { unitId: t, subUnitId: r, col: d, criteria: { ...h.serialize(), colId: d } } }), a.push({ id: p.id, params: { unitId: t, subUnitId: r, col: d, criteria: null } });
1144
- }), a.push({ id: y.id, params: { unitId: t, subUnitId: r, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: t, subUnitId: r } }), {
1139
+ o.push({ id: p.id, params: { unitId: r, subUnitId: t, col: d, criteria: { ...h.serialize(), colId: d } } }), a.push({ id: p.id, params: { unitId: r, subUnitId: t, col: d, criteria: null } });
1140
+ }), a.push({ id: y.id, params: { unitId: r, subUnitId: t, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: r, subUnitId: t } }), {
1145
1141
  undos: l,
1146
1142
  redos: o,
1147
1143
  preUndos: a,
@@ -1154,23 +1150,23 @@ let z = class extends U {
1154
1150
  _initRowFilteredInterceptor() {
1155
1151
  this.disposeWithMe(this._sheetInterceptorService.intercept(et.ROW_FILTERED, {
1156
1152
  // sheet-interceptor.service.ts
1157
- handler: (t, e) => {
1158
- var r, n;
1159
- return t ? !0 : (n = (r = this._sheetsFilterService.getFilterModel(
1153
+ handler: (r, e) => {
1154
+ var t, n;
1155
+ return r ? !0 : (n = (t = this._sheetsFilterService.getFilterModel(
1160
1156
  e.unitId,
1161
1157
  e.subUnitId
1162
- )) == null ? void 0 : r.isRowFiltered(e.row)) != null ? n : !1;
1158
+ )) == null ? void 0 : t.isRowFiltered(e.row)) != null ? n : !1;
1163
1159
  }
1164
1160
  }));
1165
1161
  }
1166
- _moveCriteria(t, e, r, n) {
1162
+ _moveCriteria(r, e, t, n) {
1167
1163
  const s = {
1168
- unitId: t,
1164
+ unitId: r,
1169
1165
  subUnitId: e,
1170
1166
  criteria: null,
1171
1167
  col: -1
1172
1168
  }, o = [], l = [], a = [], c = [];
1173
- return r.forEach((u) => {
1169
+ return t.forEach((u) => {
1174
1170
  const [d, h] = u;
1175
1171
  l.push({
1176
1172
  id: p.id,
@@ -1186,7 +1182,7 @@ let z = class extends U {
1186
1182
  criteria: { ...h.serialize(), colId: d }
1187
1183
  }
1188
1184
  });
1189
- }), r.forEach((u) => {
1185
+ }), t.forEach((u) => {
1190
1186
  const [d, h] = u;
1191
1187
  c.push({
1192
1188
  id: p.id,
@@ -1215,14 +1211,14 @@ let z = class extends U {
1215
1211
  };
1216
1212
  }
1217
1213
  _commandExecutedListener() {
1218
- this.disposeWithMe(this._commandService.onCommandExecuted((t, e) => {
1214
+ this.disposeWithMe(this._commandService.onCommandExecuted((r, e) => {
1219
1215
  var c, u;
1220
- const { unitId: r, subUnitId: n } = t.params || {}, s = this._sheetsFilterService.getFilterModel(r, n);
1216
+ const { unitId: t, subUnitId: n } = r.params || {}, s = this._sheetsFilterService.getFilterModel(t, n);
1221
1217
  if (!s) return;
1222
1218
  const o = Array.from(s.filteredOutRows).sort((d, h) => d - h), l = [];
1223
1219
  let a = !1;
1224
- if (t.id === tt.id) {
1225
- const { startRow: d, endRow: h } = t.params.range, g = o.filter((_) => _ >= d && _ <= h);
1220
+ if (r.id === tt.id) {
1221
+ const { startRow: d, endRow: h } = r.params.range, g = o.filter((_) => _ >= d && _ <= h);
1226
1222
  o.forEach((_) => {
1227
1223
  if (_ < d)
1228
1224
  l.push(_);
@@ -1233,27 +1229,27 @@ let z = class extends U {
1233
1229
  l.push(_ - (h - d + 1 - g.length));
1234
1230
  });
1235
1231
  }
1236
- if (t.id === rt.id) {
1237
- const { startRow: d, endRow: h } = t.params.range;
1232
+ if (r.id === rt.id) {
1233
+ const { startRow: d, endRow: h } = r.params.range;
1238
1234
  o.forEach((g) => {
1239
1235
  g >= d ? (a = !0, l.push(g + (h - d + 1))) : l.push(g);
1240
1236
  });
1241
1237
  }
1242
- if (a && (s.filteredOutRows = new Set(l)), t.id === nt.id && !(e != null && e.onlyLocal)) {
1243
- const d = this._getExtendRegion(r, n);
1238
+ if (a && (s.filteredOutRows = new Set(l)), r.id === nt.id && !(e != null && e.onlyLocal)) {
1239
+ const d = this._getExtendRegion(t, n);
1244
1240
  if (d) {
1245
- const h = t.params.cellValue;
1241
+ const h = r.params.cellValue;
1246
1242
  if (h)
1247
1243
  for (let g = d.startColumn; g <= d.endColumn; g++) {
1248
1244
  const _ = (c = h == null ? void 0 : h[d.startRow]) == null ? void 0 : c[g];
1249
1245
  if (_ && this._cellHasValue(_)) {
1250
- const S = (u = this._univerInstanceService.getUnit(r)) == null ? void 0 : u.getSheetBySheetId(n);
1246
+ const S = (u = this._univerInstanceService.getUnit(t)) == null ? void 0 : u.getSheetBySheetId(n);
1251
1247
  if (S) {
1252
- const w = _e(d, { down: !0 }, S), F = this._sheetsFilterService.getFilterModel(r, n), f = F.getRange();
1248
+ const w = Ce(d, { down: !0 }, S), F = this._sheetsFilterService.getFilterModel(t, n), f = F.getRange();
1253
1249
  F.setRange({
1254
1250
  ...f,
1255
1251
  endRow: w.endRow
1256
- }), this._registerRefRange(r, n);
1252
+ }), this._registerRefRange(t, n);
1257
1253
  }
1258
1254
  }
1259
1255
  }
@@ -1261,15 +1257,15 @@ let z = class extends U {
1261
1257
  }
1262
1258
  }));
1263
1259
  }
1264
- _getExtendRegion(t, e) {
1260
+ _getExtendRegion(r, e) {
1265
1261
  var a;
1266
- const r = this._sheetsFilterService.getFilterModel(t, e);
1267
- if (!r)
1262
+ const t = this._sheetsFilterService.getFilterModel(r, e);
1263
+ if (!t)
1268
1264
  return null;
1269
- const n = (a = this._univerInstanceService.getUnit(t)) == null ? void 0 : a.getSheetBySheetId(e);
1265
+ const n = (a = this._univerInstanceService.getUnit(r)) == null ? void 0 : a.getSheetBySheetId(e);
1270
1266
  if (!n)
1271
1267
  return null;
1272
- const s = r.getRange();
1268
+ const s = t.getRange();
1273
1269
  if (!s)
1274
1270
  return null;
1275
1271
  const o = n.getRowCount() - 1, l = n.getRowManager();
@@ -1284,53 +1280,53 @@ let z = class extends U {
1284
1280
  return null;
1285
1281
  }
1286
1282
  _initErrorHandling() {
1287
- this.disposeWithMe(this._commandService.beforeCommandExecuted((t) => {
1288
- const e = t.params, r = H(this._univerInstanceService);
1289
- if (!r) return;
1290
- const { subUnitId: n, unitId: s } = r, o = this._sheetsFilterService.getFilterModel(s, n);
1283
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((r) => {
1284
+ const e = r.params, t = H(this._univerInstanceService);
1285
+ if (!t) return;
1286
+ const { subUnitId: n, unitId: s } = t, o = this._sheetsFilterService.getFilterModel(s, n);
1291
1287
  if (!o) return;
1292
1288
  const l = o.getRange();
1293
- if (t.id === it.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1289
+ if (r.id === it.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1294
1290
  throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
1295
1291
  }));
1296
1292
  }
1297
- _cellHasValue(t) {
1298
- const e = Object.values(t);
1299
- return !(e.length === 0 || e.every((r) => r == null));
1293
+ _cellHasValue(r) {
1294
+ const e = Object.values(r);
1295
+ return !(e.length === 0 || e.every((t) => t == null));
1300
1296
  }
1301
1297
  };
1302
1298
  z = qt([
1303
- I(0, N),
1304
- I(1, A(Qe)),
1305
- I(2, A(M)),
1306
- I(3, T),
1307
- I(4, A(Je)),
1308
- I(5, He(gt)),
1309
- I(6, A(Ze))
1299
+ x(0, N),
1300
+ x(1, A(Qe)),
1301
+ x(2, A(M)),
1302
+ x(3, T),
1303
+ x(4, A(Je)),
1304
+ x(5, He(gt)),
1305
+ x(6, A(Ze))
1310
1306
  ], z);
1311
- var Gt = Object.getOwnPropertyDescriptor, Qt = (i, t, e, r) => {
1312
- for (var n = r > 1 ? void 0 : r ? Gt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1307
+ var Gt = Object.getOwnPropertyDescriptor, Qt = (i, r, e, t) => {
1308
+ for (var n = t > 1 ? void 0 : t ? Gt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1313
1309
  (o = i[s]) && (n = o(n) || n);
1314
1310
  return n;
1315
- }, ee = (i, t) => (e, r) => t(e, r, i);
1311
+ }, ee = (i, r) => (e, t) => r(e, t, i);
1316
1312
  const Jt = [
1317
1313
  p.id,
1318
1314
  B.id
1319
1315
  ], Zt = [
1320
- Ce.id,
1321
1316
  Re.id,
1322
- pe.id
1317
+ pe.id,
1318
+ Se.id
1323
1319
  ];
1324
1320
  let G = class extends U {
1325
- constructor(t, e, r) {
1321
+ constructor(r, e, t) {
1326
1322
  super();
1327
- C(this, "_d", new me());
1323
+ C(this, "_d", new ge());
1328
1324
  C(this, "_visible$", new $(!1));
1329
1325
  C(this, "visible$", this._visible$.asObservable());
1330
1326
  C(this, "_enabled$", new $(!0));
1331
1327
  C(this, "enabled$", this._enabled$.asObservable());
1332
- this._sheetsFilterController = t, this._commandService = e, this._configService = r;
1333
- const n = this._configService.getConfig(xe);
1328
+ this._sheetsFilterController = r, this._commandService = e, this._configService = t;
1329
+ const n = this._configService.getConfig(Ie);
1334
1330
  n != null && n.enableSyncSwitch && this._visible$.next(!0);
1335
1331
  }
1336
1332
  get visible() {
@@ -1339,25 +1335,25 @@ let G = class extends U {
1339
1335
  get enabled() {
1340
1336
  return this._enabled$.getValue();
1341
1337
  }
1342
- setEnabled(t) {
1343
- this._enabled$.next(t), t ? this._d.dispose() : this._initOnlyLocalListener();
1338
+ setEnabled(r) {
1339
+ this._enabled$.next(r), r ? this._d.dispose() : this._initOnlyLocalListener();
1344
1340
  }
1345
1341
  _initOnlyLocalListener() {
1346
1342
  this._d.add(
1347
- this._commandService.beforeCommandExecuted((t, e) => {
1348
- Jt.includes(t.id) && (e || (e = {}), e.onlyLocal = !0);
1343
+ this._commandService.beforeCommandExecuted((r, e) => {
1344
+ Jt.includes(r.id) && (e || (e = {}), e.onlyLocal = !0);
1349
1345
  })
1350
1346
  ), this._d.add(
1351
- this._commandService.onCommandExecuted((t, e) => {
1352
- if (Zt.includes(t.id) && (e != null && e.fromCollab)) {
1353
- if (t.id === Ce.id) {
1354
- const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleInsertColCommand(r, n, s);
1347
+ this._commandService.onCommandExecuted((r, e) => {
1348
+ if (Zt.includes(r.id) && (e != null && e.fromCollab)) {
1349
+ if (r.id === Re.id) {
1350
+ const { range: t, unitId: n, subUnitId: s } = r.params, { redos: o } = this._sheetsFilterController.handleInsertColCommand(t, n, s);
1355
1351
  j(o, this._commandService, e);
1356
- } else if (t.id === Re.id) {
1357
- const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleRemoveColCommand(r, n, s);
1352
+ } else if (r.id === pe.id) {
1353
+ const { range: t, unitId: n, subUnitId: s } = r.params, { redos: o } = this._sheetsFilterController.handleRemoveColCommand(t, n, s);
1358
1354
  j(o, this._commandService, e);
1359
- } else if (t.id === pe.id) {
1360
- const { sourceRange: r, targetRange: n, unitId: s, subUnitId: o } = t.params, { redos: l } = this._sheetsFilterController.handleMoveColsCommand({ fromRange: r, toRange: n }, s, o);
1355
+ } else if (r.id === Se.id) {
1356
+ const { sourceRange: t, targetRange: n, unitId: s, subUnitId: o } = r.params, { redos: l } = this._sheetsFilterController.handleMoveColsCommand({ fromRange: t, toRange: n }, s, o);
1361
1357
  j(l, this._commandService, e);
1362
1358
  }
1363
1359
  }
@@ -1368,29 +1364,29 @@ let G = class extends U {
1368
1364
  G = Qt([
1369
1365
  ee(0, A(z)),
1370
1366
  ee(1, N),
1371
- ee(2, ge)
1367
+ ee(2, _e)
1372
1368
  ], G);
1373
- var Kt = Object.getOwnPropertyDescriptor, Yt = (i, t, e, r) => {
1374
- for (var n = r > 1 ? void 0 : r ? Kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1369
+ var Kt = Object.getOwnPropertyDescriptor, Yt = (i, r, e, t) => {
1370
+ for (var n = t > 1 ? void 0 : t ? Kt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1375
1371
  (o = i[s]) && (n = o(n) || n);
1376
1372
  return n;
1377
- }, V = (i, t) => (e, r) => t(e, r, i);
1373
+ }, V = (i, r) => (e, t) => r(e, t, i);
1378
1374
  let Q = class extends U {
1379
- constructor(i, t, e, r) {
1380
- super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = t, this._sheetsFilterService = e, this._univerInstanceService = r, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
1375
+ constructor(i, r, e, t) {
1376
+ super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = r, this._sheetsFilterService = e, this._univerInstanceService = t, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
1381
1377
  }
1382
1378
  _initFormulaDirtyRange() {
1383
- Me.forEach((i) => {
1379
+ Ee.forEach((i) => {
1384
1380
  this._activeDirtyManagerService.register(
1385
1381
  i,
1386
1382
  {
1387
1383
  commandId: i,
1388
- getDirtyData: (t) => {
1389
- const e = t.params, { unitId: r, subUnitId: n } = e;
1384
+ getDirtyData: (r) => {
1385
+ const e = r.params, { unitId: t, subUnitId: n } = e;
1390
1386
  return {
1391
- dirtyRanges: this._getHideRowMutation(r, n),
1387
+ dirtyRanges: this._getHideRowMutation(t, n),
1392
1388
  clearDependencyTreeCache: {
1393
- [r]: {
1389
+ [t]: {
1394
1390
  [n]: "1"
1395
1391
  }
1396
1392
  }
@@ -1400,27 +1396,27 @@ let Q = class extends U {
1400
1396
  );
1401
1397
  });
1402
1398
  }
1403
- _getHideRowMutation(i, t) {
1399
+ _getHideRowMutation(i, r) {
1404
1400
  var l, a;
1405
- const e = (l = this._sheetsFilterService.getFilterModel(i, t)) == null ? void 0 : l.getRange(), r = (a = this._univerInstanceService.getUnit(i)) == null ? void 0 : a.getSheetBySheetId(t);
1406
- if (e == null || r == null)
1401
+ const e = (l = this._sheetsFilterService.getFilterModel(i, r)) == null ? void 0 : l.getRange(), t = (a = this._univerInstanceService.getUnit(i)) == null ? void 0 : a.getSheetBySheetId(r);
1402
+ if (e == null || t == null)
1407
1403
  return [];
1408
1404
  const { startRow: n, endRow: s } = e;
1409
1405
  return [{
1410
1406
  unitId: i,
1411
- sheetId: t,
1407
+ sheetId: r,
1412
1408
  range: {
1413
1409
  startRow: n,
1414
1410
  startColumn: 0,
1415
1411
  endRow: s,
1416
- endColumn: r.getColumnCount() - 1
1412
+ endColumn: t.getColumnCount() - 1
1417
1413
  }
1418
1414
  }];
1419
1415
  }
1420
1416
  _registerSheetRowFiltered() {
1421
- this._sheetRowFilteredService.register((i, t, e) => {
1422
- var r, n;
1423
- return (n = (r = this._sheetsFilterService.getFilterModel(i, t)) == null ? void 0 : r.isRowFiltered(e)) != null ? n : !1;
1417
+ this._sheetRowFilteredService.register((i, r, e) => {
1418
+ var t, n;
1419
+ return (n = (t = this._sheetsFilterService.getFilterModel(i, r)) == null ? void 0 : t.isRowFiltered(e)) != null ? n : !1;
1424
1420
  });
1425
1421
  }
1426
1422
  };
@@ -1430,20 +1426,20 @@ Q = Yt([
1430
1426
  V(2, A(M)),
1431
1427
  V(3, T)
1432
1428
  ], Q);
1433
- var Xt = Object.getOwnPropertyDescriptor, er = (i, t, e, r) => {
1434
- for (var n = r > 1 ? void 0 : r ? Xt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1429
+ var Xt = Object.getOwnPropertyDescriptor, er = (i, r, e, t) => {
1430
+ for (var n = t > 1 ? void 0 : t ? Xt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1435
1431
  (o = i[s]) && (n = o(n) || n);
1436
1432
  return n;
1437
- }, he = (i, t) => (e, r) => t(e, r, i), W;
1433
+ }, he = (i, r) => (e, t) => r(e, t, i), W;
1438
1434
  let fe = (W = class extends Ve {
1439
- constructor(i = ue, t, e) {
1440
- super(), this._config = i, this._injector = t, this._configService = e;
1441
- const { ...r } = We(
1435
+ constructor(i = ue, r, e) {
1436
+ super(), this._config = i, this._injector = r, this._configService = e;
1437
+ const { ...t } = We(
1442
1438
  {},
1443
1439
  ue,
1444
1440
  this._config
1445
1441
  );
1446
- this._configService.setConfig(xe, r);
1442
+ this._configService.setConfig(Ie, t);
1447
1443
  }
1448
1444
  onStarting() {
1449
1445
  [
@@ -1463,12 +1459,12 @@ let fe = (W = class extends Ve {
1463
1459
  }, C(W, "type", D.UNIVER_SHEET), C(W, "pluginName", Ne), W);
1464
1460
  fe = er([
1465
1461
  he(1, A(ke)),
1466
- he(2, ge)
1462
+ he(2, _e)
1467
1463
  ], fe);
1468
1464
  export {
1469
1465
  dr as ClearSheetsFilterCriteriaCommand,
1470
- x as CustomFilterOperator,
1471
- Me as FILTER_MUTATIONS,
1466
+ I as CustomFilterOperator,
1467
+ Ee as FILTER_MUTATIONS,
1472
1468
  b as FilterBy,
1473
1469
  yt as FilterColumn,
1474
1470
  q as FilterModel,
@@ -1491,5 +1487,5 @@ export {
1491
1487
  pt as greaterThanOrEqualTo,
1492
1488
  St as lessThan,
1493
1489
  Ft as lessThanOrEqualTo,
1494
- Ee as notEquals
1490
+ Oe as notEquals
1495
1491
  };