@univerjs/sheets-filter 0.1.11 → 0.1.13

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/es/index.js CHANGED
@@ -1,82 +1,82 @@
1
- var ce = Object.defineProperty;
2
- var ue = (s, r, e) => r in s ? ce(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
3
- var _ = (s, r, e) => (ue(s, typeof r != "symbol" ? r + "" : r, e), e);
4
- import { isNumeric as de, Disposable as B, Rectangle as Y, mergeSets as U, Tools as V, extractPureTextFromCell as he, CellValueType as W, CommandType as N, UniverInstanceType as H, fromCallback as fe, OnLifecycle as K, LifecycleStages as Z, IResourceManagerService as me, IUniverInstanceService as k, ICommandService as ee, DisposableCollection as _e, moveMatrixArray as D, Plugin as ge } from "@univerjs/core";
5
- import { Inject as $, Injector as Ce } from "@wendellhu/redi";
6
- import { BehaviorSubject as I, merge as Re, filter as pe, switchMap as Fe, of as we } from "rxjs";
7
- import { SheetInterceptorService as Se, RefRangeService as ve, SetWorksheetActivateCommand as Me, RemoveSheetCommand as Ee, INTERCEPTOR_POINT as Oe, RemoveRowMutation as ye, InsertRowMutation as Ae, MoveRangeCommand as Te, EffectRefRangId as Q, RemoveRowCommand as Ne, RemoveColCommand as xe, InsertColCommand as $e, InsertRowCommand as Pe } from "@univerjs/sheets";
8
- var E = /* @__PURE__ */ ((s) => (s.EQUAL = "equal", s.GREATER_THAN = "greaterThan", s.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", s.LESS_THAN = "lessThan", s.LESS_THAN_OR_EQUAL = "lessThanOrEqual", s.NOT_EQUALS = "notEqual", s))(E || {});
9
- const Ie = {
10
- operator: E.GREATER_THAN,
11
- fn: (s, r) => A(s) ? s > r : !1
12
- }, Le = {
13
- operator: E.GREATER_THAN_OR_EQUAL,
14
- fn: (s, r) => A(s) ? s >= r : !1
15
- }, Be = {
16
- operator: E.LESS_THAN,
17
- fn: (s, r) => A(s) ? s < r : !1
1
+ var ue = Object.defineProperty;
2
+ var de = (s, r, e) => r in s ? ue(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
3
+ var g = (s, r, e) => (de(s, typeof r != "symbol" ? r + "" : r, e), e);
4
+ import { isNumeric as he, Disposable as b, Rectangle as k, mergeSets as z, Tools as q, extractPureTextFromCell as fe, CellValueType as j, CommandType as $, UniverInstanceType as V, fromCallback as me, OnLifecycle as ee, LifecycleStages as te, IResourceManagerService as _e, IUniverInstanceService as re, ICommandService as se, DisposableCollection as ge, moveMatrixArray as G, Plugin as Ce } from "@univerjs/core";
5
+ import { Inject as P, Injector as Re } from "@wendellhu/redi";
6
+ import { BehaviorSubject as x, merge as pe, filter as we, switchMap as Fe, of as ve } from "rxjs";
7
+ import { SheetInterceptorService as Se, RefRangeService as Me, SetWorksheetActivateCommand as Ee, RemoveSheetCommand as Oe, INTERCEPTOR_POINT as ye, RemoveRowMutation as Ae, InsertRowMutation as Te, getSheetCommandTarget as Ne, MoveRowsCommand as xe, MoveRangeCommand as $e, EffectRefRangId as J, RemoveRowCommand as Ie, RemoveColCommand as Pe, InsertColCommand as Le, InsertRowCommand as Be } from "@univerjs/sheets";
8
+ var O = /* @__PURE__ */ ((s) => (s.EQUAL = "equal", s.GREATER_THAN = "greaterThan", s.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", s.LESS_THAN = "lessThan", s.LESS_THAN_OR_EQUAL = "lessThanOrEqual", s.NOT_EQUALS = "notEqual", s))(O || {});
9
+ const be = {
10
+ operator: O.GREATER_THAN,
11
+ fn: (s, r) => T(s) ? s > r : !1
18
12
  }, Ue = {
19
- operator: E.LESS_THAN_OR_EQUAL,
20
- fn: (s, r) => A(s) ? s <= r : !1
13
+ operator: O.GREATER_THAN_OR_EQUAL,
14
+ fn: (s, r) => T(s) ? s >= r : !1
21
15
  }, ze = {
22
- operator: E.EQUAL,
23
- fn: (s, r) => A(s) ? s === r : !1
24
- }, te = {
25
- operator: E.NOT_EQUALS,
16
+ operator: O.LESS_THAN,
17
+ fn: (s, r) => T(s) ? s < r : !1
18
+ }, He = {
19
+ operator: O.LESS_THAN_OR_EQUAL,
20
+ fn: (s, r) => T(s) ? s <= r : !1
21
+ }, We = {
22
+ operator: O.EQUAL,
23
+ fn: (s, r) => T(s) ? s === r : !1
24
+ }, ne = {
25
+ operator: O.NOT_EQUALS,
26
26
  fn: (s, r) => {
27
27
  if (typeof r == "string") {
28
28
  if (r === " ")
29
29
  return s != null;
30
- const e = se(s);
31
- return e && je(r) ? !ne(r).test(e) : e !== r;
30
+ const e = oe(s);
31
+ return e && Qe(r) ? !le(r).test(e) : e !== r;
32
32
  }
33
- return A(s) ? s !== r : !0;
33
+ return T(s) ? s !== r : !0;
34
34
  }
35
- }, re = /* @__PURE__ */ new Map([]), be = [Ie, Le, Be, Ue, ze, te];
36
- be.forEach((s) => {
37
- re.set(s.operator, s);
35
+ }, ie = /* @__PURE__ */ new Map([]), je = [be, Ue, ze, He, We, ne];
36
+ je.forEach((s) => {
37
+ ie.set(s.operator, s);
38
38
  });
39
- function We(s) {
39
+ function Ve(s) {
40
40
  return !!s;
41
41
  }
42
- const He = {
42
+ const De = {
43
43
  fn: (s, r) => {
44
- const e = se(s);
45
- return e === null ? r === "" : ne(r).test(e);
44
+ const e = oe(s);
45
+ return e === null ? r === "" : le(r).test(e);
46
46
  }
47
47
  };
48
- function q(s) {
49
- return s ? re.get(s) : He;
48
+ function X(s) {
49
+ return s ? ie.get(s) : De;
50
50
  }
51
- function A(s) {
51
+ function T(s) {
52
52
  return typeof s == "number";
53
53
  }
54
- function G(s) {
55
- return !!(typeof s == "number" || typeof s == "string" && de(s));
54
+ function Y(s) {
55
+ return !!(typeof s == "number" || typeof s == "string" && he(s));
56
56
  }
57
- function se(s) {
57
+ function oe(s) {
58
58
  return typeof s == "boolean" || s == null ? null : typeof s == "string" ? s : s.toString();
59
59
  }
60
- function je(s) {
60
+ function Qe(s) {
61
61
  return typeof s == "number" ? !1 : s.indexOf("*") !== -1 || s.indexOf("?") !== -1;
62
62
  }
63
- function ne(s) {
63
+ function le(s) {
64
64
  const r = s.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".").replace(/[*]/g, ".$&");
65
65
  return new RegExp(`^${r}$`);
66
66
  }
67
- const z = () => /* @__PURE__ */ new Set();
68
- class L extends B {
67
+ const H = () => /* @__PURE__ */ new Set();
68
+ class B extends b {
69
69
  constructor(e, t, n) {
70
70
  super();
71
- _(this, "_filteredOutRows$", new I(z()));
71
+ g(this, "_filteredOutRows$", new x(H()));
72
72
  /** An observable value. A set of filtered out rows. */
73
- _(this, "filteredOutRows$", this._filteredOutRows$.asObservable());
73
+ g(this, "filteredOutRows$", this._filteredOutRows$.asObservable());
74
74
  // TODO: we may need to update which cols have criteria rather than simple boolean
75
- _(this, "_hasCriteria$", new I(!1));
76
- _(this, "hasCriteria$", this._hasCriteria$.asObservable());
77
- _(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
78
- _(this, "_alreadyFilteredOutRows", z());
79
- _(this, "_range");
75
+ g(this, "_hasCriteria$", new x(!1));
76
+ g(this, "hasCriteria$", this._hasCriteria$.asObservable());
77
+ g(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
78
+ g(this, "_alreadyFilteredOutRows", H());
79
+ g(this, "_range");
80
80
  this.unitId = e, this.subUnitId = t, this._worksheet = n;
81
81
  }
82
82
  get filteredOutRows() {
@@ -93,7 +93,7 @@ class L extends B {
93
93
  */
94
94
  serialize() {
95
95
  const e = {
96
- ref: Y.clone(this._range),
96
+ ref: k.clone(this._range),
97
97
  filterColumns: this._getAllFilterColumns(!0).sort(([t], [n]) => t - n).map(([t, n]) => n.serialize())
98
98
  };
99
99
  return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
@@ -106,7 +106,7 @@ class L extends B {
106
106
  * @param autoFilter auto filter data
107
107
  */
108
108
  static deserialize(e, t, n, i) {
109
- const o = new L(e, t, n);
109
+ const o = new B(e, t, n);
110
110
  return o._dump(i), o;
111
111
  }
112
112
  _dump(e) {
@@ -129,7 +129,7 @@ class L extends B {
129
129
  getFilteredOutRowsExceptCol(e) {
130
130
  return this._getAllFilterColumns(!0).filter(([t]) => t !== e).reduce((t, [, n]) => {
131
131
  const i = n.calc({ getAlreadyFilteredOutRows: () => t });
132
- return i ? U(t, i) : t;
132
+ return i ? z(t, i) : t;
133
133
  }, /* @__PURE__ */ new Set());
134
134
  }
135
135
  /**
@@ -173,7 +173,7 @@ class L extends B {
173
173
  return e ? t : t.map(([n, i]) => i);
174
174
  }
175
175
  _reCalcAllColumns() {
176
- this._alreadyFilteredOutRows = z(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
176
+ this._alreadyFilteredOutRows = H(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
177
177
  }
178
178
  _setCriteriaWithoutReCalc(e, t) {
179
179
  const n = this._range;
@@ -183,7 +183,7 @@ class L extends B {
183
183
  if (e > o || e < i)
184
184
  throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);
185
185
  let l;
186
- this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new Ve(
186
+ this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new qe(
187
187
  this.unitId,
188
188
  this.subUnitId,
189
189
  this._worksheet,
@@ -202,26 +202,26 @@ class L extends B {
202
202
  this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
203
203
  }
204
204
  _rebuildAlreadyFilteredOutRowsWithCache() {
205
- const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => U(t, n.filteredOutRows), /* @__PURE__ */ new Set());
205
+ const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => z(t, n.filteredOutRows), /* @__PURE__ */ new Set());
206
206
  this._alreadyFilteredOutRows = e;
207
207
  }
208
208
  _reCalcWithNoCacheColumns() {
209
209
  const e = this._getAllFilterColumns().filter((t) => !t.hasCache());
210
210
  for (const t of e) {
211
211
  const n = t.reCalc();
212
- n && (this._alreadyFilteredOutRows = U(this._alreadyFilteredOutRows, n));
212
+ n && (this._alreadyFilteredOutRows = z(this._alreadyFilteredOutRows, n));
213
213
  }
214
214
  }
215
215
  }
216
- class Ve extends B {
216
+ class qe extends b {
217
217
  constructor(e, t, n, i, o) {
218
218
  super();
219
- _(this, "_filteredOutRows", null);
219
+ g(this, "_filteredOutRows", null);
220
220
  /** Cache the filter function. */
221
- _(this, "_filterFn", null);
222
- _(this, "_range", null);
223
- _(this, "_column", 0);
224
- _(this, "_filterByValues", !1);
221
+ g(this, "_filterFn", null);
222
+ g(this, "_range", null);
223
+ g(this, "_column", 0);
224
+ g(this, "_filterByValues", !1);
225
225
  this.unitId = e, this.subUnitId = t, this._worksheet = n, this._criteria = i, this._filterColumnContext = o;
226
226
  }
227
227
  get filteredOutRows() {
@@ -239,7 +239,7 @@ class Ve extends B {
239
239
  serialize() {
240
240
  if (!this._criteria)
241
241
  throw new Error("[FilterColumn]: could not serialize without a filter column!");
242
- return V.deepClone({
242
+ return q.deepClone({
243
243
  ...this._criteria,
244
244
  colId: this._column
245
245
  });
@@ -255,7 +255,7 @@ class Ve extends B {
255
255
  this._criteria = e, this._generateFilterFn(), this._filteredOutRows = null;
256
256
  }
257
257
  getColumnData() {
258
- return V.deepClone(this._criteria);
258
+ return q.deepClone(this._criteria);
259
259
  }
260
260
  /**
261
261
  * Trigger new calculation on this `FilterModel` instance.
@@ -278,120 +278,122 @@ class Ve extends B {
278
278
  const { row: a, rowSpan: u, col: c } = l;
279
279
  if (o.has(a) && (!u || u === 1))
280
280
  continue;
281
- const h = this._filterByValues ? he(this._worksheet.getCell(a, c)) : Ke(this._worksheet, a, c);
281
+ const h = this._filterByValues ? fe(this._worksheet.getCell(a, c)) : et(this._worksheet, a, c);
282
282
  if (!this._filterFn(h) && (i.add(a), u))
283
- for (let m = 1; m < u; m++)
284
- i.add(a + m);
283
+ for (let _ = 1; _ < u; _++)
284
+ i.add(a + _);
285
285
  }
286
286
  return i;
287
287
  }
288
288
  _generateFilterFn() {
289
- this._criteria && (this._filterFn = De(this._criteria), this._filterByValues = !!this._criteria.filters);
289
+ this._criteria && (this._filterFn = Ge(this._criteria), this._filterByValues = !!this._criteria.filters);
290
290
  }
291
291
  }
292
- function De(s) {
292
+ function Ge(s) {
293
293
  if (s.filters)
294
- return Qe(s.filters);
294
+ return Je(s.filters);
295
295
  if (s.customFilters)
296
- return qe(s.customFilters);
296
+ return Xe(s.customFilters);
297
297
  throw new Error("[FilterModel]: other types of filters are not supported yet.");
298
298
  }
299
- function Qe(s) {
299
+ function Je(s) {
300
300
  const r = !!s.blank, e = new Set(s.filters);
301
301
  return (t) => t === void 0 || t === "" ? r : e.has(typeof t == "string" ? t : `${t}`);
302
302
  }
303
- function qe(s) {
304
- const r = s.customFilters.map((e) => Ye(e));
305
- return Xe(r) ? s.and ? Ge(r) : Je(r) : r[0];
303
+ function Xe(s) {
304
+ const r = s.customFilters.map((e) => ke(e));
305
+ return Ze(r) ? s.and ? Ye(r) : Ke(r) : r[0];
306
306
  }
307
- function Ge(s) {
307
+ function Ye(s) {
308
308
  const [r, e] = s;
309
309
  return (t) => r(t) && e(t);
310
310
  }
311
- function Je(s) {
311
+ function Ke(s) {
312
312
  const [r, e] = s;
313
313
  return (t) => r(t) || e(t);
314
314
  }
315
- function Xe(s) {
315
+ function Ze(s) {
316
316
  return s.length === 2;
317
317
  }
318
- function Ye(s) {
318
+ function ke(s) {
319
319
  const r = s.val;
320
- if (s.operator === E.NOT_EQUALS && !G(r))
321
- return (n) => te.fn(n, r);
322
- if (We(s.operator)) {
323
- if (!G(r))
320
+ if (s.operator === O.NOT_EQUALS && !Y(r))
321
+ return (n) => ne.fn(n, r);
322
+ if (Ve(s.operator)) {
323
+ if (!Y(r))
324
324
  return () => !1;
325
- const n = q(s.operator), i = Number(r);
325
+ const n = X(s.operator), i = Number(r);
326
326
  return (o) => n.fn(o, i);
327
327
  }
328
- const e = q(s.operator);
328
+ const e = X(s.operator);
329
329
  return (t) => e.fn(t, r);
330
330
  }
331
- function Ke(s, r, e) {
331
+ function et(s, r, e) {
332
332
  const t = s.getCell(r, e);
333
333
  if (!t)
334
334
  return null;
335
335
  const n = s.getCellRaw(r, e);
336
- return t && !n ? J(t) : n ? t.t === W.NUMBER && typeof t.v == "string" ? n.v : J(n) : null;
336
+ return t && !n ? K(t) : n ? t.t === j.NUMBER && typeof t.v == "string" ? n.v : K(n) : null;
337
337
  }
338
- function J(s) {
338
+ function K(s) {
339
339
  var t, n;
340
340
  const r = (n = (t = s.p) == null ? void 0 : t.body) == null ? void 0 : n.dataStream;
341
341
  if (r)
342
342
  return r.trimEnd();
343
343
  const e = s.v;
344
- return typeof e == "string" ? s.t === W.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? s.t === W.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
344
+ return typeof e == "string" ? s.t === j.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? s.t === j.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
345
345
  }
346
- const C = {
346
+ const R = {
347
347
  id: "sheet.mutation.set-filter-range",
348
- type: N.MUTATION,
348
+ type: $.MUTATION,
349
349
  handler: (s, r) => {
350
350
  const { subUnitId: e, unitId: t, range: n } = r;
351
- return s.get(v).ensureFilterModel(t, e).setRange(n), !0;
351
+ return s.get(S).ensureFilterModel(t, e).setRange(n), !0;
352
352
  }
353
353
  }, F = {
354
354
  id: "sheet.mutation.set-filter-criteria",
355
- type: N.MUTATION,
355
+ type: $.MUTATION,
356
356
  handler: (s, r) => {
357
- const { subUnitId: e, unitId: t, criteria: n, col: i, reCalc: o = !0 } = r, a = s.get(v).getFilterModel(t, e);
357
+ const { subUnitId: e, unitId: t, criteria: n, col: i, reCalc: o = !0 } = r, a = s.get(S).getFilterModel(t, e);
358
358
  return a ? (a.setCriteria(i, n, o), !0) : !1;
359
359
  }
360
- }, y = {
360
+ }, A = {
361
361
  id: "sheet.mutation.remove-filter",
362
- type: N.MUTATION,
362
+ type: $.MUTATION,
363
363
  handler: (s, r) => {
364
364
  const { unitId: e, subUnitId: t } = r;
365
- return s.get(v).removeFilterModel(e, t);
365
+ return s.get(S).removeFilterModel(e, t);
366
366
  }
367
- }, ie = {
367
+ }, ae = {
368
368
  id: "sheet.mutation.re-calc-filter",
369
- type: N.MUTATION,
369
+ type: $.MUTATION,
370
370
  handler: (s, r) => {
371
- const { unitId: e, subUnitId: t } = r, i = s.get(v).getFilterModel(e, t);
371
+ const { unitId: e, subUnitId: t } = r, i = s.get(S).getFilterModel(e, t);
372
372
  return i ? (i.reCalc(), !0) : !1;
373
373
  }
374
374
  };
375
- var Ze = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, et = (s, r, e, t) => {
376
- for (var n = t > 1 ? void 0 : t ? ke(r, e) : r, i = s.length - 1, o; i >= 0; i--)
375
+ var tt = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, st = (s, r, e, t) => {
376
+ for (var n = t > 1 ? void 0 : t ? rt(r, e) : r, i = s.length - 1, o; i >= 0; i--)
377
377
  (o = s[i]) && (n = (t ? o(r, e, n) : o(n)) || n);
378
- return t && n && Ze(r, e, n), n;
379
- }, b = (s, r) => (e, t) => r(e, t, s);
380
- const tt = /* @__PURE__ */ new Set([
381
- C.id,
378
+ return t && n && tt(r, e, n), n;
379
+ }, W = (s, r) => (e, t) => r(e, t, s);
380
+ const nt = /* @__PURE__ */ new Set([
381
+ R.id,
382
382
  F.id,
383
- y.id,
384
- ie.id
385
- ]), oe = "SHEET_FILTER_PLUGIN";
386
- let v = class extends B {
383
+ A.id,
384
+ ae.id
385
+ ]), ce = "SHEET_FILTER_PLUGIN";
386
+ let S = class extends b {
387
387
  constructor(r, e, t) {
388
388
  super();
389
- _(this, "_filterModels", /* @__PURE__ */ new Map());
390
- _(this, "_loadedUnitId$", new I(null));
391
- _(this, "loadedUnitId$", this._loadedUnitId$.asObservable());
392
- _(this, "_activeFilterModel$", new I(null));
389
+ g(this, "_filterModels", /* @__PURE__ */ new Map());
390
+ g(this, "_loadedUnitId$", new x(null));
391
+ g(this, "loadedUnitId$", this._loadedUnitId$.asObservable());
392
+ g(this, "_errorMsg$", new x(null));
393
+ g(this, "errorMsg$", this._errorMsg$.asObservable());
394
+ g(this, "_activeFilterModel$", new x(null));
393
395
  /** An observable value emitting the current Workbook's active Worksheet's filter model (if there is one). */
394
- _(this, "activeFilterModel$", this._activeFilterModel$.asObservable());
396
+ g(this, "activeFilterModel$", this._activeFilterModel$.asObservable());
395
397
  this._resourcesManagerService = r, this._univerInstanceService = e, this._commandService = t, this._initModel(), this._initActiveFilterModel();
396
398
  }
397
399
  /** The current Workbook's active Worksheet's filter model (if there is one). */
@@ -413,7 +415,7 @@ let v = class extends B {
413
415
  const i = n.getSheetBySheetId(e);
414
416
  if (!i)
415
417
  throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
416
- const o = new L(r, e, i);
418
+ const o = new B(r, e, i);
417
419
  return this._cacheFilterModel(r, e, o), o;
418
420
  }
419
421
  getFilterModel(r, e) {
@@ -424,17 +426,20 @@ let v = class extends B {
424
426
  const t = this.getFilterModel(r, e);
425
427
  return t ? (t.dispose(), this._filterModels.get(r).delete(e), !0) : !1;
426
428
  }
429
+ setFilterErrorMsg(r) {
430
+ this._errorMsg$.next(r);
431
+ }
427
432
  _updateActiveFilterModel() {
428
433
  let r;
429
434
  try {
430
- if (r = this._univerInstanceService.getCurrentUnitForType(H.UNIVER_SHEET), !r) {
435
+ if (r = this._univerInstanceService.getCurrentUnitForType(V.UNIVER_SHEET), !r) {
431
436
  this._activeFilterModel$.next(null);
432
437
  return;
433
438
  }
434
439
  } catch {
435
440
  return;
436
441
  }
437
- const e = r.getActiveSheet();
442
+ const e = r.getRawActiveSheet();
438
443
  if (!e) {
439
444
  this._activeFilterModel$.next(null);
440
445
  return;
@@ -444,13 +449,13 @@ let v = class extends B {
444
449
  }
445
450
  _initActiveFilterModel() {
446
451
  this.disposeWithMe(
447
- Re(
452
+ pe(
448
453
  // source1: executing filter related mutations
449
- fe(this._commandService.onCommandExecuted).pipe(pe(([r]) => r.type === N.MUTATION && tt.has(r.id))),
454
+ me(this._commandService.onCommandExecuted).pipe(we(([r]) => r.type === $.MUTATION && nt.has(r.id))),
450
455
  // source2: activate sheet changes
451
- this._univerInstanceService.getCurrentTypeOfUnit$(H.UNIVER_SHEET).pipe(Fe((r) => {
456
+ this._univerInstanceService.getCurrentTypeOfUnit$(V.UNIVER_SHEET).pipe(Fe((r) => {
452
457
  var e;
453
- return (e = r == null ? void 0 : r.activeSheet$) != null ? e : we(null);
458
+ return (e = r == null ? void 0 : r.activeSheet$) != null ? e : ve(null);
454
459
  }))
455
460
  ).subscribe(() => this._updateActiveFilterModel())
456
461
  );
@@ -467,13 +472,13 @@ let v = class extends B {
467
472
  _deserializeAutoFiltersForUnit(r, e) {
468
473
  const t = this._univerInstanceService.getUniverSheetInstance(r);
469
474
  Object.keys(e).forEach((n) => {
470
- const i = e[n], o = L.deserialize(r, n, t.getSheetBySheetId(n), i);
475
+ const i = e[n], o = B.deserialize(r, n, t.getSheetBySheetId(n), i);
471
476
  this._cacheFilterModel(r, n, o);
472
477
  });
473
478
  }
474
479
  _initModel() {
475
480
  this._resourcesManagerService.registerPluginResource({
476
- pluginName: oe,
481
+ pluginName: ce,
477
482
  businesses: [2],
478
483
  toJson: (r) => this._serializeAutoFiltersForUnit(r),
479
484
  parseJson: (r) => JSON.parse(r),
@@ -490,13 +495,13 @@ let v = class extends B {
490
495
  this._filterModels.has(r) || this._filterModels.set(r, /* @__PURE__ */ new Map()), this._filterModels.get(r).set(e, t);
491
496
  }
492
497
  };
493
- v = et([
494
- K(Z.Ready, v),
495
- b(0, me),
496
- b(1, k),
497
- b(2, ee)
498
- ], v);
499
- function rt(s, r) {
498
+ S = st([
499
+ ee(te.Ready, S),
500
+ W(0, _e),
501
+ W(1, re),
502
+ W(2, se)
503
+ ], S);
504
+ function it(s, r) {
500
505
  for (let e = 0; e < s.length; e++) {
501
506
  let t = e;
502
507
  if (s[e])
@@ -505,31 +510,31 @@ function rt(s, r) {
505
510
  }
506
511
  return s.filter((e) => e !== null);
507
512
  }
508
- function M(s) {
509
- return rt(s, (r, e) => r.id === F.id && e.id === F.id && r.params.unitId === e.params.unitId && r.params.subUnitId === e.params.subUnitId && r.params.col === e.params.col);
513
+ function E(s) {
514
+ return it(s, (r, e) => r.id === F.id && e.id === F.id && r.params.unitId === e.params.unitId && r.params.subUnitId === e.params.subUnitId && r.params.col === e.params.col);
510
515
  }
511
- var st = Object.defineProperty, nt = Object.getOwnPropertyDescriptor, it = (s, r, e, t) => {
512
- for (var n = t > 1 ? void 0 : t ? nt(r, e) : r, i = s.length - 1, o; i >= 0; i--)
516
+ var ot = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, at = (s, r, e, t) => {
517
+ for (var n = t > 1 ? void 0 : t ? lt(r, e) : r, i = s.length - 1, o; i >= 0; i--)
513
518
  (o = s[i]) && (n = (t ? o(r, e, n) : o(n)) || n);
514
- return t && n && st(r, e, n), n;
515
- }, T = (s, r) => (e, t) => r(e, t, s);
516
- let P = class extends B {
519
+ return t && n && ot(r, e, n), n;
520
+ }, N = (s, r) => (e, t) => r(e, t, s);
521
+ let L = class extends b {
517
522
  constructor(s, r, e, t, n) {
518
- super(), this._commandService = s, this._sheetInterceptorService = r, this._sheetsFilterService = e, this._univerInstanceService = t, this._refRangeService = n, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener();
523
+ super(), this._commandService = s, this._sheetInterceptorService = r, this._sheetsFilterService = e, this._univerInstanceService = t, this._refRangeService = n, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling();
519
524
  }
520
525
  _initCommands() {
521
526
  [
522
527
  F,
523
- C,
524
- ie,
525
- y
528
+ R,
529
+ ae,
530
+ A
526
531
  ].forEach((s) => this.disposeWithMe(this._commandService.registerCommand(s)));
527
532
  }
528
533
  _initInterceptors() {
529
534
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
530
535
  getMutations: (e) => this._getUpdateFilter(e)
531
536
  }));
532
- const s = new _e(), r = (e, t) => {
537
+ const s = new ge(), r = (e, t) => {
533
538
  var a;
534
539
  const n = this._univerInstanceService.getUniverSheetInstance(e);
535
540
  if (!n || !(n == null ? void 0 : n.getSheetBySheetId(t)))
@@ -537,31 +542,31 @@ let P = class extends B {
537
542
  s.dispose();
538
543
  const o = (a = this._sheetsFilterService.getFilterModel(e, t)) == null ? void 0 : a.getRange(), l = (u) => {
539
544
  switch (u.id) {
540
- case Pe.id: {
541
- const c = u.params, h = c.unitId || e, m = c.subUnitId || t;
542
- return this._handleInsertRowCommand(c, h, m);
545
+ case Be.id: {
546
+ const c = u.params, h = c.unitId || e, _ = c.subUnitId || t;
547
+ return this._handleInsertRowCommand(c, h, _);
543
548
  }
544
- case $e.id: {
545
- const c = u.params, h = c.unitId || e, m = c.subUnitId || t;
546
- return this._handleInsertColCommand(c, h, m);
549
+ case Le.id: {
550
+ const c = u.params, h = c.unitId || e, _ = c.subUnitId || t;
551
+ return this._handleInsertColCommand(c, h, _);
547
552
  }
548
- case xe.id: {
553
+ case Pe.id: {
549
554
  const c = u.params;
550
555
  return this._handleRemoveColCommand(c, e, t);
551
556
  }
552
- case Ne.id: {
557
+ case Ie.id: {
553
558
  const c = u.params;
554
559
  return this._handleRemoveRowCommand(c, e, t);
555
560
  }
556
- case Q.MoveColsCommandId: {
561
+ case J.MoveColsCommandId: {
557
562
  const c = u.params;
558
563
  return this._handleMoveColsCommand(c, e, t);
559
564
  }
560
- case Q.MoveRowsCommandId: {
565
+ case J.MoveRowsCommandId: {
561
566
  const c = u.params;
562
567
  return this._handleMoveRowsCommand(c, e, t);
563
568
  }
564
- case Te.id: {
569
+ case $e.id: {
565
570
  const c = u.params;
566
571
  return this._handleMoveRangeCommand(c, e, t);
567
572
  }
@@ -571,13 +576,13 @@ let P = class extends B {
571
576
  o && s.add(this._refRangeService.registerRefRange(o, l, e, t));
572
577
  };
573
578
  this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
574
- if (e.id === Me.id) {
579
+ if (e.id === Ee.id) {
575
580
  const t = e.params, n = t.subUnitId, i = t.unitId;
576
581
  if (!n || !i)
577
582
  return;
578
583
  r(i, n);
579
584
  }
580
- if (e.id === C.id) {
585
+ if (e.id === R.id) {
581
586
  const t = e.params, n = t.subUnitId, i = t.unitId;
582
587
  if (!n || !i)
583
588
  return;
@@ -593,7 +598,7 @@ let P = class extends B {
593
598
  _getUpdateFilter(s) {
594
599
  const { id: r } = s;
595
600
  switch (r) {
596
- case Ee.id: {
601
+ case Oe.id: {
597
602
  const e = s.params;
598
603
  return this._handleRemoveSheetCommand(e, e.unitId, e.subUnitId);
599
604
  }
@@ -604,14 +609,14 @@ let P = class extends B {
604
609
  };
605
610
  }
606
611
  _handleInsertColCommand(s, r, e) {
607
- var f;
608
- const t = this._sheetsFilterService.getFilterModel(r, e), n = (f = t == null ? void 0 : t.getRange()) != null ? f : null;
612
+ var m;
613
+ const t = this._sheetsFilterService.getFilterModel(r, e), n = (m = t == null ? void 0 : t.getRange()) != null ? m : null;
609
614
  if (!t || !n)
610
615
  return this._handleNull();
611
616
  const { startColumn: i, endColumn: o } = n, { startColumn: l, endColumn: a } = s.range, u = a - l + 1;
612
617
  if (a > o)
613
618
  return this._handleNull();
614
- const c = [], h = [], m = l, p = {
619
+ const c = [], h = [], _ = l, p = {
615
620
  unitId: r,
616
621
  subUnitId: e,
617
622
  range: {
@@ -619,28 +624,28 @@ let P = class extends B {
619
624
  startColumn: l <= i ? i + u : i,
620
625
  endColumn: o + u
621
626
  }
622
- }, R = {
627
+ }, C = {
623
628
  unitId: r,
624
629
  subUnitId: e,
625
630
  range: n
626
631
  };
627
- c.push({ id: C.id, params: p }), h.push({ id: C.id, params: R });
628
- const d = t.getAllFilterColumns().filter((g) => g[0] >= m);
629
- if (d.length !== 0) {
630
- const { undos: g, redos: S } = this.moveCriteria(r, e, d, u);
631
- c.push(...S), h.push(...g);
632
+ c.push({ id: R.id, params: p }), h.push({ id: R.id, params: C });
633
+ const f = t.getAllFilterColumns().filter((d) => d[0] >= _);
634
+ if (f.length !== 0) {
635
+ const { undos: d, redos: v } = this.moveCriteria(r, e, f, u);
636
+ c.push(...v), h.push(...d);
632
637
  }
633
- return { redos: M(c), undos: M(h) };
638
+ return { redos: E(c), undos: E(h) };
634
639
  }
635
640
  _handleInsertRowCommand(s, r, e) {
636
- var R;
637
- const t = this._sheetsFilterService.getFilterModel(r, e), n = (R = t == null ? void 0 : t.getRange()) != null ? R : null;
641
+ var C;
642
+ const t = this._sheetsFilterService.getFilterModel(r, e), n = (C = t == null ? void 0 : t.getRange()) != null ? C : null;
638
643
  if (!t || !n)
639
644
  return this._handleNull();
640
645
  const { startRow: i, endRow: o } = n, { startRow: l, endRow: a } = s.range, u = a - l + 1;
641
646
  if (a > o)
642
647
  return this._handleNull();
643
- const c = [], h = [], m = {
648
+ const c = [], h = [], _ = {
644
649
  unitId: r,
645
650
  subUnitId: e,
646
651
  range: {
@@ -653,9 +658,9 @@ let P = class extends B {
653
658
  subUnitId: e,
654
659
  range: n
655
660
  };
656
- return c.push({ id: C.id, params: m }), h.push({ id: C.id, params: p }), {
657
- redos: M(c),
658
- undos: M(h)
661
+ return c.push({ id: R.id, params: _ }), h.push({ id: R.id, params: p }), {
662
+ redos: E(c),
663
+ undos: E(h)
659
664
  };
660
665
  }
661
666
  _handleRemoveColCommand(s, r, e) {
@@ -666,37 +671,37 @@ let P = class extends B {
666
671
  const { startColumn: i, endColumn: o } = n, { startColumn: l, endColumn: a } = s.range;
667
672
  if (l > o)
668
673
  return this._handleNull();
669
- const u = [], c = [], h = a < i ? 0 : Math.min(a, o) - Math.max(l, i) + 1, m = a - l + 1, p = t.getAllFilterColumns();
670
- p.forEach((d) => {
671
- const [f, g] = d;
672
- f <= a && f >= l && (u.push({ id: F.id, params: { unitId: r, subUnitId: e, col: f, criteria: null } }), c.push({ id: F.id, params: { unitId: r, subUnitId: e, col: f, criteria: { ...g.serialize(), colId: f } } }));
674
+ const u = [], c = [], h = a < i ? 0 : Math.min(a, o) - Math.max(l, i) + 1, _ = a - l + 1, p = t.getAllFilterColumns();
675
+ p.forEach((f) => {
676
+ const [m, d] = f;
677
+ m <= a && m >= l && (u.push({ id: F.id, params: { unitId: r, subUnitId: e, col: m, criteria: null } }), c.push({ id: F.id, params: { unitId: r, subUnitId: e, col: m, criteria: { ...d.serialize(), colId: m } } }));
673
678
  });
674
- const R = p.filter((d) => {
675
- const [f, g] = d;
676
- return f > a;
679
+ const C = p.filter((f) => {
680
+ const [m, d] = f;
681
+ return m > a;
677
682
  });
678
- if (R.length > 0) {
679
- const { undos: d, redos: f } = this.moveCriteria(r, e, R, -m);
680
- u.push(...f), c.push(...d);
683
+ if (C.length > 0) {
684
+ const { undos: f, redos: m } = this.moveCriteria(r, e, C, -_);
685
+ u.push(...m), c.push(...f);
681
686
  }
682
687
  if (h === o - i + 1) {
683
- const d = {
688
+ const f = {
684
689
  unitId: r,
685
690
  subUnitId: e
686
691
  };
687
- u.push({ id: y.id, params: d });
692
+ u.push({ id: A.id, params: f });
688
693
  } else if (i <= l) {
689
- const d = o - h, f = {
694
+ const f = o - h, m = {
690
695
  unitId: r,
691
696
  subUnitId: e,
692
697
  range: {
693
698
  ...n,
694
- endColumn: d
699
+ endColumn: f
695
700
  }
696
701
  };
697
- u.push({ id: C.id, params: f });
702
+ u.push({ id: R.id, params: m });
698
703
  } else {
699
- const d = {
704
+ const f = {
700
705
  unitId: r,
701
706
  subUnitId: e,
702
707
  range: {
@@ -705,64 +710,65 @@ let P = class extends B {
705
710
  endColumn: o - (a - l + 1)
706
711
  }
707
712
  };
708
- u.push({ id: C.id, params: d });
713
+ u.push({ id: R.id, params: f });
709
714
  }
710
- return c.push({ id: C.id, params: { range: n, unitId: r, subUnitId: e } }), {
711
- undos: M(c),
712
- redos: M(u)
715
+ return c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } }), {
716
+ undos: E(c),
717
+ redos: E(u)
713
718
  };
714
719
  }
715
720
  _handleRemoveRowCommand(s, r, e) {
716
- var R;
721
+ var C;
717
722
  const t = this._sheetsFilterService.getFilterModel(r, e);
718
723
  if (!t)
719
724
  return this._handleNull();
720
725
  const n = t.getRange(), { startRow: i, endRow: o } = n, { startRow: l, endRow: a } = s.range;
721
726
  if (l > o)
722
727
  return this._handleNull();
723
- const u = [], c = [], h = t.getAllFilterColumns(), m = i <= a && i >= l;
724
- c.push({ id: C.id, params: { range: n, unitId: r, subUnitId: e } });
728
+ const u = [], c = [], h = t.getAllFilterColumns(), _ = i <= a && i >= l;
729
+ c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } });
725
730
  const p = Math.min(a, o) - Math.max(l, i) + 1;
726
- if (p === o - i + 1 || m) {
731
+ if (p === o - i + 1 || _) {
727
732
  const w = {
728
733
  unitId: r,
729
734
  subUnitId: e
730
735
  };
731
- u.push({ id: y.id, params: w }), h.forEach((d) => {
732
- const [f, g] = d, S = {
736
+ u.push({ id: A.id, params: w }), h.forEach((f) => {
737
+ const [m, d] = f, v = {
733
738
  unitId: r,
734
739
  subUnitId: e,
735
- col: f,
736
- criteria: { ...g.serialize(), colId: f }
740
+ col: m,
741
+ criteria: { ...d.serialize(), colId: m }
737
742
  };
738
- c.push({ id: F.id, params: S });
743
+ c.push({ id: F.id, params: v });
739
744
  });
740
745
  } else {
741
- const w = (R = this._univerInstanceService.getUniverSheetInstance(r)) == null ? void 0 : R.getSheetBySheetId(e);
746
+ const w = (C = this._univerInstanceService.getUniverSheetInstance(r)) == null ? void 0 : C.getSheetBySheetId(e);
742
747
  if (!w)
743
748
  return this._handleNull();
744
- const d = [];
745
- for (let O = l; O <= a; O++)
746
- w.getRowFiltered(O) && d.push(O);
747
- const f = Math.min(i, l), g = f + (o - i) - p + d.length, S = {
749
+ const f = [];
750
+ for (let M = l; M <= a; M++)
751
+ w.getRowFiltered(M) && f.push(M);
752
+ const m = Math.min(i, l), d = m + (o - i) - p + f.length, v = {
748
753
  unitId: r,
749
754
  subUnitId: e,
750
755
  range: {
751
756
  ...n,
752
- startRow: f,
753
- endRow: g
757
+ startRow: m,
758
+ endRow: d
754
759
  }
755
760
  };
756
- u.push({ id: C.id, params: S });
761
+ u.push({ id: R.id, params: v });
757
762
  }
758
763
  return {
759
- undos: M(c),
760
- redos: M(u)
764
+ undos: E(c),
765
+ redos: E(u)
761
766
  };
762
767
  }
768
+ // eslint-disable-next-line max-lines-per-function
763
769
  _handleMoveColsCommand(s, r, e) {
764
- var w;
765
- const t = this._sheetsFilterService.getFilterModel(r, e), n = (w = t == null ? void 0 : t.getRange()) != null ? w : null;
770
+ var m;
771
+ const t = this._sheetsFilterService.getFilterModel(r, e), n = (m = t == null ? void 0 : t.getRange()) != null ? m : null;
766
772
  if (!t || !n)
767
773
  return this._handleNull();
768
774
  const { startColumn: i, endColumn: o } = n, { fromRange: l, toRange: a } = s;
@@ -774,39 +780,44 @@ let P = class extends B {
774
780
  colIndex: d,
775
781
  filter: t.getFilterColumn(d)
776
782
  };
777
- D(l.startColumn, l.endColumn - l.startColumn + 1, a.startColumn, h);
778
- const m = Object.keys(h).map((d) => Number(d)), p = Math.max(...m), R = Math.min(...m);
779
- if (m.forEach((d) => {
780
- var O, j;
781
- const { colIndex: f, filter: g } = h[d], S = d;
782
- if (g) {
783
- const le = {
784
- unitId: r,
785
- subUnitId: e,
786
- col: S,
787
- criteria: { ...g.serialize(), colId: S }
788
- };
789
- if (u.push({ id: F.id, params: le }), c.push({ id: y.id, params: { unitId: r, subUnitId: e, col: S, criteria: { ...(O = t.getFilterColumn(S)) == null ? void 0 : O.serialize(), colId: S } } }), !((j = h[f]) != null && j.filter)) {
790
- const ae = {
783
+ G(l.startColumn, l.endColumn - l.startColumn + 1, a.startColumn, h);
784
+ let _ = n.startColumn, p = n.endColumn;
785
+ i >= l.startColumn && i <= l.endColumn && a.startColumn > l.startColumn && l.endColumn < o && (_ = l.endColumn + 1), o >= l.startColumn && o <= l.endColumn && a.startColumn < l.startColumn && l.startColumn > i && (p = l.startColumn - 1);
786
+ const C = Object.keys(h).map((d) => Number(d)), w = C.find((d) => h[d].colIndex === p), f = C.find((d) => h[d].colIndex === _);
787
+ if (C.forEach((d) => {
788
+ var D, Q;
789
+ const { colIndex: v, filter: M } = h[d], y = d;
790
+ if (M) {
791
+ if (y >= f && y <= w) {
792
+ const U = {
791
793
  unitId: r,
792
794
  subUnitId: e,
793
- col: f,
795
+ col: y,
796
+ criteria: { ...M.serialize(), colId: y }
797
+ };
798
+ u.push({ id: F.id, params: U }), c.push({ id: A.id, params: { unitId: r, subUnitId: e, col: y, criteria: { ...(D = t.getFilterColumn(y)) == null ? void 0 : D.serialize(), colId: y } } });
799
+ }
800
+ if (!((Q = h[v]) != null && Q.filter)) {
801
+ const U = {
802
+ unitId: r,
803
+ subUnitId: e,
804
+ col: v,
794
805
  criteria: null
795
806
  };
796
- u.push({ id: F.id, params: ae }), c.push({ id: F.id, params: { unitId: r, subUnitId: e, col: f, criteria: { ...g.serialize(), colId: f } } });
807
+ u.push({ id: F.id, params: U }), c.push({ id: F.id, params: { unitId: r, subUnitId: e, col: v, criteria: { ...M.serialize(), colId: v } } });
797
808
  }
798
809
  }
799
- }), i !== R || o !== p) {
810
+ }), i !== f || o !== w) {
800
811
  const d = {
801
812
  unitId: r,
802
813
  subUnitId: e,
803
814
  range: {
804
815
  ...n,
805
- startColumn: R,
806
- endColumn: p
816
+ startColumn: f,
817
+ endColumn: w
807
818
  }
808
819
  };
809
- u.unshift({ id: C.id, params: d }), c.push({ id: C.id, params: { range: n, unitId: r, subUnitId: e } });
820
+ u.unshift({ id: R.id, params: d }), c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } });
810
821
  }
811
822
  return {
812
823
  undos: c,
@@ -814,8 +825,8 @@ let P = class extends B {
814
825
  };
815
826
  }
816
827
  _handleMoveRowsCommand(s, r, e) {
817
- var w;
818
- const t = this._sheetsFilterService.getFilterModel(r, e), n = (w = t == null ? void 0 : t.getRange()) != null ? w : null;
828
+ var m;
829
+ const t = this._sheetsFilterService.getFilterModel(r, e), n = (m = t == null ? void 0 : t.getRange()) != null ? m : null;
819
830
  if (!t || !n)
820
831
  return this._handleNull();
821
832
  const { startRow: i, endRow: o } = n, { fromRange: l, toRange: a } = s;
@@ -824,21 +835,23 @@ let P = class extends B {
824
835
  const u = [], c = [], h = {};
825
836
  for (let d = i; d <= o; d++)
826
837
  h[d] = {
827
- offset: d - i
838
+ oldIndex: d
828
839
  };
829
- D(l.startRow, l.endRow - l.startRow + 1, a.startRow, h);
830
- const m = Object.keys(h).map((d) => Number(d)), p = Math.max(...m), R = Math.min(...m);
831
- if (i !== R || o !== p) {
840
+ const _ = i;
841
+ let p = o;
842
+ o >= l.startRow && o <= l.endRow && a.startRow < l.startRow && l.startRow > i && (p = l.startRow - 1), G(l.startRow, l.endRow - l.startRow + 1, a.startRow, h);
843
+ const C = Object.keys(h).map((d) => Number(d)), w = C.find((d) => h[d].oldIndex === p), f = C.find((d) => h[d].oldIndex === _);
844
+ if (i !== f || o !== w) {
832
845
  const d = {
833
846
  unitId: r,
834
847
  subUnitId: e,
835
848
  range: {
836
849
  ...n,
837
- startRow: R,
838
- endRow: p
850
+ startRow: f,
851
+ endRow: w
839
852
  }
840
853
  };
841
- u.unshift({ id: C.id, params: d }), c.push({ id: C.id, params: { range: n, unitId: r, subUnitId: e } });
854
+ u.unshift({ id: R.id, params: d }), c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } });
842
855
  }
843
856
  return {
844
857
  redos: u,
@@ -853,24 +866,24 @@ let P = class extends B {
853
866
  if (!o)
854
867
  return this._handleNull();
855
868
  const l = [], a = [];
856
- if (Y.contains(t, o)) {
869
+ if (k.contains(t, o)) {
857
870
  const u = o.startRow - t.startRow, c = o.startColumn - t.startColumn, h = {
858
871
  startRow: n.startRow + u,
859
872
  startColumn: n.startColumn + c,
860
873
  endRow: n.startRow + u + (o.endRow - o.startRow),
861
874
  endColumn: n.startColumn + c + (o.endColumn - o.startColumn)
862
- }, m = {
863
- id: y.id,
875
+ }, _ = {
876
+ id: A.id,
864
877
  params: {
865
878
  unitId: r,
866
879
  subUnitId: e
867
880
  }
868
- }, p = { id: C.id, params: { unitId: r, subUnitId: e, range: h } }, R = { id: C.id, params: { unitId: r, subUnitId: e, range: o } };
869
- l.push(m, p), a.push(m, R);
870
- const w = i.getAllFilterColumns(), d = n.startColumn - t.startColumn;
871
- w.forEach((f) => {
872
- const [g, S] = f;
873
- S && (l.push({ id: F.id, params: { unitId: r, subUnitId: e, col: g + d, criteria: { ...S.serialize(), colId: g + d } } }), a.push({ id: F.id, params: { unitId: r, subUnitId: e, col: g, criteria: { ...S.serialize(), colId: g } } }));
881
+ }, p = { id: R.id, params: { unitId: r, subUnitId: e, range: h } }, C = { id: R.id, params: { unitId: r, subUnitId: e, range: o } };
882
+ l.push(_, p), a.push(_, C);
883
+ const w = i.getAllFilterColumns(), f = n.startColumn - t.startColumn;
884
+ w.forEach((m) => {
885
+ const [d, v] = m;
886
+ v && (l.push({ id: F.id, params: { unitId: r, subUnitId: e, col: d + f, criteria: { ...v.serialize(), colId: d + f } } }), a.push({ id: F.id, params: { unitId: r, subUnitId: e, col: d, criteria: { ...v.serialize(), colId: d } } }));
874
887
  });
875
888
  }
876
889
  return {
@@ -889,7 +902,7 @@ let P = class extends B {
889
902
  return t.getAllFilterColumns().forEach((a) => {
890
903
  const [u, c] = a;
891
904
  o.push({ id: F.id, params: { unitId: r, subUnitId: e, col: a, criteria: { ...c.serialize(), colId: a } } });
892
- }), i.push({ id: y.id, params: { unitId: r, subUnitId: e, range: n } }), o.unshift({ id: C.id, params: { range: n, unitId: r, subUnitId: e } }), {
905
+ }), i.push({ id: A.id, params: { unitId: r, subUnitId: e, range: n } }), o.unshift({ id: R.id, params: { range: n, unitId: r, subUnitId: e } }), {
893
906
  undos: o,
894
907
  redos: i
895
908
  };
@@ -898,7 +911,7 @@ let P = class extends B {
898
911
  return { redos: [], undos: [] };
899
912
  }
900
913
  _initRowFilteredInterceptor() {
901
- this.disposeWithMe(this._sheetInterceptorService.intercept(Oe.ROW_FILTERED, {
914
+ this.disposeWithMe(this._sheetInterceptorService.intercept(ye.ROW_FILTERED, {
902
915
  handler: (s, r) => {
903
916
  var e, t;
904
917
  return s ? !0 : (t = (e = this._sheetsFilterService.getFilterModel(
@@ -960,7 +973,7 @@ let P = class extends B {
960
973
  return;
961
974
  const n = Array.from(t.filteredOutRows).sort((l, a) => l - a), i = [];
962
975
  let o = !1;
963
- if (s.id === ye.id) {
976
+ if (s.id === Ae.id) {
964
977
  const { startRow: l, endRow: a } = s.params.range, u = n.filter((c) => c >= l && c <= a);
965
978
  n.forEach((c) => {
966
979
  if (c < l)
@@ -972,7 +985,7 @@ let P = class extends B {
972
985
  i.push(c - (a - l + 1 - u.length));
973
986
  });
974
987
  }
975
- if (s.id === Ae.id) {
988
+ if (s.id === Te.id) {
976
989
  const { startRow: l, endRow: a } = s.params.range;
977
990
  n.forEach((u) => {
978
991
  u >= l ? (o = !0, i.push(u + (a - l + 1))) : i.push(u);
@@ -981,51 +994,64 @@ let P = class extends B {
981
994
  o && (t.filteredOutRows = new Set(i));
982
995
  }));
983
996
  }
997
+ _initErrorHandling() {
998
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((s) => {
999
+ const r = s.params, e = Ne(this._univerInstanceService);
1000
+ if (!e)
1001
+ return;
1002
+ const { subUnitId: t, unitId: n } = e, i = this._sheetsFilterService.getFilterModel(n, t);
1003
+ if (!i)
1004
+ return;
1005
+ const o = i.getRange();
1006
+ if (s.id === xe.id && r.fromRange.startRow <= o.startRow && r.fromRange.endRow >= o.startRow)
1007
+ throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
1008
+ }));
1009
+ }
984
1010
  };
985
- P = it([
986
- K(Z.Ready, P),
987
- T(0, ee),
988
- T(1, $(Se)),
989
- T(2, $(v)),
990
- T(3, k),
991
- T(4, $(ve))
992
- ], P);
993
- var ot = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, at = (s, r, e, t) => {
994
- for (var n = t > 1 ? void 0 : t ? lt(r, e) : r, i = s.length - 1, o; i >= 0; i--)
1011
+ L = at([
1012
+ ee(te.Ready, L),
1013
+ N(0, se),
1014
+ N(1, P(Se)),
1015
+ N(2, P(S)),
1016
+ N(3, re),
1017
+ N(4, P(Me))
1018
+ ], L);
1019
+ var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, dt = (s, r, e, t) => {
1020
+ for (var n = t > 1 ? void 0 : t ? ut(r, e) : r, i = s.length - 1, o; i >= 0; i--)
995
1021
  (o = s[i]) && (n = (t ? o(r, e, n) : o(n)) || n);
996
- return t && n && ot(r, e, n), n;
997
- }, ct = (s, r) => (e, t) => r(e, t, s), x;
998
- let X = (x = class extends ge {
1022
+ return t && n && ct(r, e, n), n;
1023
+ }, ht = (s, r) => (e, t) => r(e, t, s), I;
1024
+ let Z = (I = class extends Ce {
999
1025
  constructor(s, r) {
1000
1026
  super(), this._injector = r;
1001
1027
  }
1002
1028
  onStarting(s) {
1003
1029
  [
1004
- [v],
1005
- [P]
1030
+ [S],
1031
+ [L]
1006
1032
  ].forEach((r) => s.add(r));
1007
1033
  }
1008
- }, _(x, "type", H.UNIVER_SHEET), _(x, "pluginName", oe), x);
1009
- X = at([
1010
- ct(1, $(Ce))
1011
- ], X);
1034
+ }, g(I, "type", V.UNIVER_SHEET), g(I, "pluginName", ce), I);
1035
+ Z = dt([
1036
+ ht(1, P(Re))
1037
+ ], Z);
1012
1038
  export {
1013
- E as CustomFilterOperator,
1014
- tt as FILTER_MUTATIONS,
1015
- Ve as FilterColumn,
1016
- L as FilterModel,
1017
- ie as ReCalcSheetsFilterMutation,
1018
- y as RemoveSheetsFilterMutation,
1019
- oe as SHEET_FILTER_SNAPSHOT_ID,
1039
+ O as CustomFilterOperator,
1040
+ nt as FILTER_MUTATIONS,
1041
+ qe as FilterColumn,
1042
+ B as FilterModel,
1043
+ ae as ReCalcSheetsFilterMutation,
1044
+ A as RemoveSheetsFilterMutation,
1045
+ ce as SHEET_FILTER_SNAPSHOT_ID,
1020
1046
  F as SetSheetsFilterCriteriaMutation,
1021
- C as SetSheetsFilterRangeMutation,
1022
- v as SheetsFilterService,
1023
- X as UniverSheetsFilterPlugin,
1024
- ze as equals,
1025
- q as getCustomFilterFn,
1026
- Ie as greaterThan,
1027
- Le as greaterThanOrEqualTo,
1028
- Be as lessThan,
1029
- Ue as lessThanOrEqualTo,
1030
- te as notEquals
1047
+ R as SetSheetsFilterRangeMutation,
1048
+ S as SheetsFilterService,
1049
+ Z as UniverSheetsFilterPlugin,
1050
+ We as equals,
1051
+ X as getCustomFilterFn,
1052
+ be as greaterThan,
1053
+ Ue as greaterThanOrEqualTo,
1054
+ ze as lessThan,
1055
+ He as lessThanOrEqualTo,
1056
+ ne as notEquals
1031
1057
  };