@univerjs/sheets-data-validation 0.5.0-alpha.0 → 0.5.0-beta.1

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,37 +1,37 @@
1
- var bt = Object.defineProperty;
2
- var Dt = (s, t, e) => t in s ? bt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var g = (s, t, e) => Dt(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { Inject as E, ICommandService as re, Disposable as ce, ObjectMatrix as Ue, Range as Q, UniverInstanceType as K, DataValidationType as $, isFormulaString as F, IUniverInstanceService as Z, getOriginCellValue as It, debounce as $t, Rectangle as ee, Tools as b, DataValidationStatus as ge, WrapStrategy as Le, DataValidationOperator as _, numfmt as oe, DataValidationRenderMode as Ke, CommandType as ve, IUndoRedoService as Se, sequenceExecute as Ye, CellValueType as xt, Injector as st, RxDisposable as At, toDisposable as gt, IPermissionService as Lt, isRangesEqual as Ut, LifecycleService as Bt, LifecycleStages as ht, bufferDebounceTime as Pt, DependentOn as Ht, Plugin as kt, IConfigService as Wt } from "@univerjs/core";
5
- import { DataValidationModel as nt, DataValidatorRegistryService as ot, UpdateRuleType as Y, BaseDataValidator as de, TextLengthErrorTitleMap as jt, AddDataValidationMutation as le, RemoveDataValidationMutation as ie, UpdateDataValidationMutation as X, getRuleSetting as rt, getRuleOptions as qt, UniverDataValidationPlugin as Gt } from "@univerjs/data-validation";
6
- import { SetRangeValuesMutation as Ce, RemoveSheetMutation as Qt, getSheetCommandTarget as lt, SetRangeValuesUndoMutationFactory as vt, SheetsSelectionsService as St, SheetInterceptorService as Rt, ClearSelectionAllCommand as Yt, WorksheetViewPermission as Xt, RefRangeService as zt, handleCommonDefaultRangeChangeWithEffectRefCommands as Kt, RemoveSheetCommand as Zt } from "@univerjs/sheets";
7
- import { Subject as at, bufferWhen as Jt, filter as mt } from "rxjs";
8
- import { RegisterOtherFormulaService as yt, FormulaRefRangeService as er } from "@univerjs/sheets-formula";
9
- import { ERROR_TYPE_SET as tr, LexerTreeBuilder as ut, isReferenceString as Mt, sequenceNodeType as rr, deserializeRangeWithSheet as ar, deserializeRangeWithSheetWithCache as ir } from "@univerjs/engine-formula";
10
- const sr = "SHEET_DATA_VALIDATION_PLUGIN";
11
- var nr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, lr = (s, t, e, r) => {
12
- for (var i = r > 1 ? void 0 : r ? or(t, e) : t, a = s.length - 1, n; a >= 0; a--)
13
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
14
- return r && i && nr(t, e, i), i;
15
- }, ur = (s, t) => (e, r) => t(e, r, s);
16
- let ue = class extends ce {
1
+ var St = Object.defineProperty;
2
+ var Vt = (o, t, e) => t in o ? St(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var f = (o, t, e) => Vt(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { Inject as v, ICommandService as H, Disposable as W, ObjectMatrix as Re, Range as I, DataValidationType as M, UniverInstanceType as A, isFormulaString as R, IUniverInstanceService as D, getOriginCellValue as Nt, debounce as Mt, Rectangle as B, Tools as N, DataValidationStatus as Y, WrapStrategy as ve, DataValidationOperator as h, numfmt as k, dayjs as it, DataValidationRenderMode as Le, CommandType as K, IUndoRedoService as z, sequenceExecute as Oe, CellValueType as yt, Injector as je, RxDisposable as Et, toDisposable as qe, IPermissionService as Tt, generateRandomId as wt, isRangesEqual as Ft, LifecycleService as Ct, LifecycleStages as et, bufferDebounceTime as Ot, DependentOn as bt, Plugin as It, IConfigService as At } from "@univerjs/core";
5
+ import { DataValidationModel as Ge, DataValidatorRegistryService as Qe, UpdateRuleType as w, BaseDataValidator as q, TextLengthErrorTitleMap as Dt, AddDataValidationMutation as U, RemoveDataValidationMutation as P, UpdateDataValidationMutation as b, getRuleSetting as xt, getRuleOptions as Lt, UniverDataValidationPlugin as Bt } from "@univerjs/data-validation";
6
+ import { SetRangeValuesMutation as se, RemoveSheetMutation as Pt, getSheetCommandTarget as Ye, SetRangeValuesUndoMutationFactory as st, SheetsSelectionsService as ot, SheetInterceptorService as nt, ClearSelectionAllCommand as Ut, WorksheetViewPermission as $t, RefRangeService as Ht, handleCommonDefaultRangeChangeWithEffectRefCommands as Wt, RemoveSheetCommand as kt } from "@univerjs/sheets";
7
+ import { Subject as We, bufferWhen as jt, filter as tt } from "rxjs";
8
+ import { RegisterOtherFormulaService as lt, FormulaRefRangeService as ut } from "@univerjs/sheets-formula";
9
+ import { ERROR_TYPE_SET as qt, LexerTreeBuilder as Z, isReferenceString as ct, sequenceNodeType as Gt, deserializeRangeWithSheet as Qt, deserializeRangeWithSheetWithCache as Yt } from "@univerjs/engine-formula";
10
+ const Xt = "SHEET_DATA_VALIDATION_PLUGIN";
11
+ var Kt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Zt = (o, t, e, r) => {
12
+ for (var a = r > 1 ? void 0 : r ? zt(t, e) : t, i = o.length - 1, s; i >= 0; i--)
13
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
14
+ return r && a && Kt(t, e, a), a;
15
+ }, Jt = (o, t) => (e, r) => t(e, r, o);
16
+ let j = class extends W {
17
17
  constructor(t) {
18
18
  super();
19
- g(this, "_cacheMatrix", /* @__PURE__ */ new Map());
20
- g(this, "_dirtyRanges$", new at());
21
- g(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
19
+ f(this, "_cacheMatrix", /* @__PURE__ */ new Map());
20
+ f(this, "_dirtyRanges$", new We());
21
+ f(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
22
22
  this._commandService = t, this._initDirtyRanges();
23
23
  }
24
24
  _initDirtyRanges() {
25
25
  this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
26
- if (t.id === Ce.id) {
27
- const { cellValue: e, unitId: r, subUnitId: i } = t.params;
26
+ if (t.id === se.id) {
27
+ const { cellValue: e, unitId: r, subUnitId: a } = t.params;
28
28
  if (e) {
29
- const a = new Ue(e).getDataRange();
30
- if (a.endRow === -1) return;
29
+ const i = new Re(e).getDataRange();
30
+ if (i.endRow === -1) return;
31
31
  this._dirtyRanges$.next({
32
32
  unitId: r,
33
- subUnitId: i,
34
- ranges: [a]
33
+ subUnitId: a,
34
+ ranges: [i]
35
35
  });
36
36
  }
37
37
  }
@@ -40,8 +40,8 @@ let ue = class extends ce {
40
40
  _ensureCache(t, e) {
41
41
  let r = this._cacheMatrix.get(t);
42
42
  r || (r = /* @__PURE__ */ new Map(), this._cacheMatrix.set(t, r));
43
- let i = r.get(e);
44
- return i || (i = new Ue(), r.set(e, i)), i;
43
+ let a = r.get(e);
44
+ return a || (a = new Re(), r.set(e, a)), a;
45
45
  }
46
46
  ensureCache(t, e) {
47
47
  return this._ensureCache(t, e);
@@ -52,170 +52,212 @@ let ue = class extends ce {
52
52
  removeRule(t, e, r) {
53
53
  this._deleteRange(t, e, r.ranges);
54
54
  }
55
- updateRuleRanges(t, e, r, i, a) {
56
- const n = this._ensureCache(t, e);
57
- a.forEach((o) => {
58
- Q.foreach(o, (l, u) => {
59
- const c = n.getValue(l, u);
55
+ updateRuleRanges(t, e, r, a, i) {
56
+ const s = this._ensureCache(t, e);
57
+ i.forEach((n) => {
58
+ I.foreach(n, (l, u) => {
59
+ const c = s.getValue(l, u);
60
60
  c && (c.temp = !0);
61
61
  });
62
- }), i.forEach((o) => {
63
- Q.foreach(o, (l, u) => {
64
- const c = n.getValue(l, u);
65
- c && c.ruleId === r ? c.temp = !1 : n.setValue(l, u, void 0);
62
+ }), a.forEach((n) => {
63
+ I.foreach(n, (l, u) => {
64
+ const c = s.getValue(l, u);
65
+ c && c.ruleId === r ? c.temp = !1 : s.setValue(l, u, void 0);
66
66
  });
67
- }), a.forEach((o) => {
68
- Q.foreach(o, (l, u) => {
69
- const c = n.getValue(l, u);
70
- c && c.temp === !0 && n.realDeleteValue(l, u);
67
+ }), i.forEach((n) => {
68
+ I.foreach(n, (l, u) => {
69
+ const c = s.getValue(l, u);
70
+ c && c.temp === !0 && s.realDeleteValue(l, u);
71
71
  });
72
- }), this._dirtyRanges$.next({ unitId: t, subUnitId: e, ranges: [...a, ...i] });
72
+ }), this._dirtyRanges$.next({ unitId: t, subUnitId: e, ranges: [...i, ...a] });
73
73
  }
74
74
  markRangeDirty(t, e, r) {
75
- const i = this._ensureCache(t, e);
76
- r.forEach((a) => {
77
- Q.foreach(a, (n, o) => {
78
- i.setValue(n, o, void 0);
75
+ const a = this._ensureCache(t, e);
76
+ r.forEach((i) => {
77
+ I.foreach(i, (s, n) => {
78
+ a.setValue(s, n, void 0);
79
79
  });
80
80
  }), this._dirtyRanges$.next({ unitId: t, subUnitId: e, ranges: r });
81
81
  }
82
- markCellDirty(t, e, r, i) {
83
- this._ensureCache(t, e).setValue(r, i, void 0), this._dirtyRanges$.next({ unitId: t, subUnitId: e, ranges: [{ startRow: r, startColumn: i, endRow: r, endColumn: i }] });
82
+ markCellDirty(t, e, r, a) {
83
+ this._ensureCache(t, e).setValue(r, a, void 0), this._dirtyRanges$.next({ unitId: t, subUnitId: e, ranges: [{ startRow: r, startColumn: a, endRow: r, endColumn: a }] });
84
84
  }
85
85
  _deleteRange(t, e, r) {
86
- const i = this._ensureCache(t, e);
87
- r.forEach((a) => {
88
- Q.foreach(a, (n, o) => {
89
- i.realDeleteValue(n, o);
86
+ const a = this._ensureCache(t, e);
87
+ r.forEach((i) => {
88
+ I.foreach(i, (s, n) => {
89
+ a.realDeleteValue(s, n);
90
90
  });
91
91
  }), this._dirtyRanges$.next({ unitId: t, subUnitId: e, ranges: r });
92
92
  }
93
- getValue(t, e, r, i) {
94
- return this._ensureCache(t, e).getValue(r, i);
93
+ getValue(t, e, r, a) {
94
+ return this._ensureCache(t, e).getValue(r, a);
95
95
  }
96
- setValue(t, e, r, i, a) {
97
- return this._ensureCache(t, e).setValue(r, i, a);
96
+ setValue(t, e, r, a, i) {
97
+ return this._ensureCache(t, e).setValue(r, a, i);
98
98
  }
99
99
  };
100
- ue = lr([
101
- ur(0, E(re))
102
- ], ue);
103
- function z(s) {
100
+ j = Zt([
101
+ Jt(0, v(H))
102
+ ], j);
103
+ function ie(o) {
104
104
  var t, e;
105
- return (e = (t = s == null ? void 0 : s[0]) == null ? void 0 : t[0]) == null ? void 0 : e.v;
105
+ return (e = (t = o == null ? void 0 : o[0]) == null ? void 0 : t[0]) == null ? void 0 : e.v;
106
106
  }
107
- function cr(s) {
107
+ function he(o) {
108
108
  var t;
109
- return (t = s == null ? void 0 : s[0]) == null ? void 0 : t[0];
109
+ return (t = o == null ? void 0 : o[0]) == null ? void 0 : t[0];
110
110
  }
111
- function W(s) {
112
- return !tr.has(s);
111
+ function O(o) {
112
+ return !qt.has(o);
113
113
  }
114
- var dr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, mr = (s, t, e, r) => {
115
- for (var i = r > 1 ? void 0 : r ? hr(t, e) : t, a = s.length - 1, n; a >= 0; a--)
116
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
117
- return r && i && dr(t, e, i), i;
118
- }, De = (s, t) => (e, r) => t(e, r, s);
119
- let we = class extends ce {
120
- constructor(t, e, r, i) {
114
+ function le(o) {
115
+ return o !== M.LIST && o !== M.LIST_MULTIPLE && o !== M.CHECKBOX && o !== M.ANY;
116
+ }
117
+ var er = Object.defineProperty, tr = Object.getOwnPropertyDescriptor, rr = (o, t, e, r) => {
118
+ for (var a = r > 1 ? void 0 : r ? tr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
119
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
120
+ return r && a && er(t, e, a), a;
121
+ }, me = (o, t) => (e, r) => t(e, r, o);
122
+ let $ = class extends W {
123
+ constructor(t, e, r, a) {
121
124
  super();
122
125
  /**
123
126
  * Map of origin formula of rule
124
127
  */
125
- g(this, "_ruleFormulaMap", /* @__PURE__ */ new Map());
126
- this._instanceSrv = t, this._registerOtherFormulaService = e, this._dataValidationModel = r, this._dataValidationCacheService = i, this._initFormulaResultHandler();
128
+ f(this, "_ruleFormulaMap", /* @__PURE__ */ new Map());
129
+ f(this, "_ruleFormulaMap2", /* @__PURE__ */ new Map());
130
+ this._instanceSrv = t, this._registerOtherFormulaService = e, this._dataValidationModel = r, this._dataValidationCacheService = a, this._initFormulaResultHandler();
127
131
  }
128
132
  _initFormulaResultHandler() {
129
133
  this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((t) => {
130
134
  for (const e in t) {
131
135
  const r = t[e];
132
- if (this._instanceSrv.getUnitType(e) === K.UNIVER_SHEET)
133
- for (const a in r) {
134
- const n = r[a], { ruleFormulaMap: o } = this._ensureMaps(e, a);
135
- n.forEach((l) => {
136
+ if (this._instanceSrv.getUnitType(e) === A.UNIVER_SHEET)
137
+ for (const i in r) {
138
+ const s = r[i], { ruleFormulaMap: n } = this._ensureMaps(e, i);
139
+ s.forEach((l) => {
136
140
  var d, m;
137
- const u = o.get((d = l.extra) == null ? void 0 : d.ruleId), c = this._dataValidationModel.getRuleById(e, a, (m = l.extra) == null ? void 0 : m.ruleId);
138
- c && u && !u.isTransformable && this._dataValidationCacheService.markRangeDirty(e, a, c.ranges);
141
+ const u = n.get((d = l.extra) == null ? void 0 : d.ruleId), c = this._dataValidationModel.getRuleById(e, i, (m = l.extra) == null ? void 0 : m.ruleId);
142
+ c && u && this._dataValidationCacheService.markRangeDirty(e, i, c.ranges);
139
143
  });
140
144
  }
141
145
  }
142
146
  }));
143
147
  }
144
148
  _ensureMaps(t, e) {
145
- let r = this._ruleFormulaMap.get(t);
146
- r || (r = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(t, r));
149
+ let r = this._ruleFormulaMap.get(t), a = this._ruleFormulaMap2.get(t);
150
+ r || (r = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(t, r)), a || (a = /* @__PURE__ */ new Map(), this._ruleFormulaMap2.set(t, a));
147
151
  let i = r.get(e);
148
- return i || (i = /* @__PURE__ */ new Map(), r.set(e, i)), { ruleFormulaMap: i };
152
+ i || (i = /* @__PURE__ */ new Map(), r.set(e, i));
153
+ let s = a.get(e);
154
+ return s || (s = /* @__PURE__ */ new Map(), a.set(e, s)), { ruleFormulaMap: i, ruleFormulaMap2: s };
149
155
  }
150
- _registerFormula(t, e, r, i, a) {
151
- return this._registerOtherFormulaService.registerFormulaWithRange(t, e, i, a, { ruleId: r });
156
+ _registerFormula(t, e, r, a, i) {
157
+ return this._registerOtherFormulaService.registerFormulaWithRange(t, e, a, i, { ruleId: r });
152
158
  }
153
159
  deleteByRuleId(t, e, r) {
154
- const { ruleFormulaMap: i } = this._ensureMaps(t, e), a = this._dataValidationModel.getRuleById(t, e, r), n = i.get(r);
155
- if (!a || !n)
156
- return;
157
- const o = i.get(r);
158
- o && (i.delete(r), this._registerOtherFormulaService.deleteFormula(t, e, [o.formulaId]));
159
- }
160
- _addFormulaByRange(t, e, r, i, a) {
161
- const { ruleFormulaMap: n } = this._ensureMaps(t, e);
162
- if (!i)
160
+ const { ruleFormulaMap: a, ruleFormulaMap2: i } = this._ensureMaps(t, e), s = this._dataValidationModel.getRuleById(t, e, r), n = a.get(r);
161
+ if (!s || !n)
163
162
  return;
164
- const o = a[0].startRow, l = a[0].startColumn, u = this._registerFormula(t, e, r, i, a);
165
- n.set(r, {
166
- formula: i,
167
- originCol: l,
168
- originRow: o,
169
- formulaId: u,
170
- isTransformable: !0
171
- });
163
+ const l = a.get(r);
164
+ l && (a.delete(r), this._registerOtherFormulaService.deleteFormula(t, e, [l.formulaId]));
165
+ const u = i.get(r);
166
+ u && (i.delete(r), this._registerOtherFormulaService.deleteFormula(t, e, [u.formulaId]));
167
+ }
168
+ _addFormulaByRange(t, e, r, a, i, s) {
169
+ const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(t, e), u = s[0].startRow, c = s[0].startColumn;
170
+ if (a && R(a)) {
171
+ const d = this._registerFormula(t, e, r, a, s);
172
+ n.set(r, {
173
+ formula: a,
174
+ originCol: c,
175
+ originRow: u,
176
+ formulaId: d
177
+ });
178
+ }
179
+ if (i && R(i)) {
180
+ const d = this._registerFormula(t, e, r, i, s);
181
+ l.set(r, {
182
+ formula: i,
183
+ originCol: c,
184
+ originRow: u,
185
+ formulaId: d
186
+ });
187
+ }
172
188
  }
173
189
  addRule(t, e, r) {
174
- const { ranges: i, formula1: a, uid: n, type: o } = r;
175
- o !== $.CUSTOM || !a || !F(a) || this._addFormulaByRange(t, e, n, a, i);
190
+ if (le(r.type)) {
191
+ const { ranges: a, formula1: i, formula2: s, uid: n } = r;
192
+ this._addFormulaByRange(t, e, n, i, s, a);
193
+ }
176
194
  }
177
- async getCellFormulaValue(t, e, r, i, a) {
178
- var v, S;
179
- const { ruleFormulaMap: n } = this._ensureMaps(t, e), o = n.get(r);
180
- if (!o)
195
+ async getCellFormulaValue(t, e, r, a, i) {
196
+ var _, p;
197
+ const { ruleFormulaMap: s } = this._ensureMaps(t, e), n = s.get(r);
198
+ if (!n)
181
199
  return Promise.resolve(void 0);
182
- const l = await this._registerOtherFormulaService.getFormulaValue(t, e, o.formulaId), { originRow: u, originCol: c } = o, d = i - u, m = a - c;
183
- return cr((S = (v = l == null ? void 0 : l.result) == null ? void 0 : v[d]) == null ? void 0 : S[m]);
200
+ const l = await this._registerOtherFormulaService.getFormulaValue(t, e, n.formulaId), { originRow: u, originCol: c } = n, d = a - u, m = i - c;
201
+ return he((p = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[d]) == null ? void 0 : p[m]);
202
+ }
203
+ async getCellFormula2Value(t, e, r, a, i) {
204
+ var _, p;
205
+ const { ruleFormulaMap2: s } = this._ensureMaps(t, e), n = s.get(r);
206
+ if (!n)
207
+ return Promise.resolve(void 0);
208
+ const l = await this._registerOtherFormulaService.getFormulaValue(t, e, n.formulaId), { originRow: u, originCol: c } = n, d = a - u, m = i - c;
209
+ return he((p = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[d]) == null ? void 0 : p[m]);
210
+ }
211
+ getCellFormulaValueSync(t, e, r, a, i) {
212
+ var _, p;
213
+ const { ruleFormulaMap: s } = this._ensureMaps(t, e), n = s.get(r);
214
+ if (!n)
215
+ return;
216
+ const l = this._registerOtherFormulaService.getFormulaValueSync(t, e, n.formulaId), { originRow: u, originCol: c } = n, d = a - u, m = i - c;
217
+ return he((p = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[d]) == null ? void 0 : p[m]);
218
+ }
219
+ getCellFormula2ValueSync(t, e, r, a, i) {
220
+ var _, p;
221
+ const { ruleFormulaMap2: s } = this._ensureMaps(t, e), n = s.get(r);
222
+ if (!n)
223
+ return;
224
+ const l = this._registerOtherFormulaService.getFormulaValueSync(t, e, n.formulaId), { originRow: u, originCol: c } = n, d = a - u, m = i - c;
225
+ return he((p = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[d]) == null ? void 0 : p[m]);
184
226
  }
185
227
  getRuleFormulaInfo(t, e, r) {
186
- const { ruleFormulaMap: i } = this._ensureMaps(t, e);
187
- return i.get(r);
228
+ const { ruleFormulaMap: a } = this._ensureMaps(t, e);
229
+ return a.get(r);
188
230
  }
189
231
  };
190
- we = mr([
191
- De(0, Z),
192
- De(1, E(yt)),
193
- De(2, E(nt)),
194
- De(3, E(ue))
195
- ], we);
196
- var fr = Object.defineProperty, _r = Object.getOwnPropertyDescriptor, pr = (s, t, e, r) => {
197
- for (var i = r > 1 ? void 0 : r ? _r(t, e) : t, a = s.length - 1, n; a >= 0; a--)
198
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
199
- return r && i && fr(t, e, i), i;
200
- }, Ie = (s, t) => (e, r) => t(e, r, s);
201
- let te = class extends ce {
202
- constructor(t, e, r, i) {
232
+ $ = rr([
233
+ me(0, D),
234
+ me(1, v(lt)),
235
+ me(2, v(Ge)),
236
+ me(3, v(j))
237
+ ], $);
238
+ var ar = Object.defineProperty, ir = Object.getOwnPropertyDescriptor, sr = (o, t, e, r) => {
239
+ for (var a = r > 1 ? void 0 : r ? ir(t, e) : t, i = o.length - 1, s; i >= 0; i--)
240
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
241
+ return r && a && ar(t, e, a), a;
242
+ }, fe = (o, t) => (e, r) => t(e, r, o);
243
+ let X = class extends W {
244
+ constructor(t, e, r, a) {
203
245
  super();
204
- g(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
205
- this._instanceService = t, this._registerOtherFormulaService = e, this._dataValidationCacheService = r, this._dataValidationModel = i, this._initFormulaResultHandler();
246
+ f(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
247
+ this._instanceService = t, this._registerOtherFormulaService = e, this._dataValidationCacheService = r, this._dataValidationModel = a, this._initFormulaResultHandler();
206
248
  }
207
249
  _initFormulaResultHandler() {
208
250
  this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((t) => {
209
251
  for (const e in t) {
210
252
  const r = t[e];
211
- if (this._instanceService.getUnitType(e) === K.UNIVER_SHEET)
212
- for (const a in r) {
213
- const n = r[a], o = this._ensureRuleFormulaMap(e, a);
214
- n.forEach((l) => {
253
+ if (this._instanceService.getUnitType(e) === A.UNIVER_SHEET)
254
+ for (const i in r) {
255
+ const s = r[i], n = this._ensureRuleFormulaMap(e, i);
256
+ s.forEach((l) => {
215
257
  var u, c;
216
- if (o.get((u = l.extra) == null ? void 0 : u.ruleId)) {
217
- const d = this._dataValidationModel.getRuleById(e, a, (c = l.extra) == null ? void 0 : c.ruleId);
218
- d && this._dataValidationCacheService.markRangeDirty(e, a, d.ranges);
258
+ if (n.get((u = l.extra) == null ? void 0 : u.ruleId)) {
259
+ const d = this._dataValidationModel.getRuleById(e, i, (c = l.extra) == null ? void 0 : c.ruleId);
260
+ d && this._dataValidationCacheService.markRangeDirty(e, i, d.ranges);
219
261
  }
220
262
  });
221
263
  }
@@ -225,97 +267,73 @@ let te = class extends ce {
225
267
  _ensureRuleFormulaMap(t, e) {
226
268
  let r = this._formulaRuleMap.get(t);
227
269
  r || (r = /* @__PURE__ */ new Map(), this._formulaRuleMap.set(t, r));
228
- let i = r.get(e);
229
- return i || (i = /* @__PURE__ */ new Map(), r.set(e, i)), i;
270
+ let a = r.get(e);
271
+ return a || (a = /* @__PURE__ */ new Map(), r.set(e, a)), a;
230
272
  }
231
- _registerSingleFormula(t, e, r, i) {
232
- const a = [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }];
233
- return this._registerOtherFormulaService.registerFormulaWithRange(t, e, r, a, { ruleId: i });
273
+ _registerSingleFormula(t, e, r, a) {
274
+ const i = [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }];
275
+ return this._registerOtherFormulaService.registerFormulaWithRange(t, e, r, i, { ruleId: a });
234
276
  }
235
- addRule(t, e, r, i, a, n) {
236
- const o = F(i), l = F(a);
237
- if (!o && !l)
238
- return;
239
- const u = this._ensureRuleFormulaMap(t, e), c = [void 0, void 0];
240
- if (o) {
241
- const d = this._registerSingleFormula(t, e, i, r);
242
- c[0] = { id: d, text: i };
243
- }
244
- if (l) {
245
- const d = this._registerSingleFormula(t, e, a, r);
246
- c[1] = { id: d, text: a };
277
+ addRule(t, e, r) {
278
+ if (!le(r.type) && r.type !== M.CHECKBOX) {
279
+ const { formula1: a, formula2: i, uid: s } = r, n = R(a), l = R(i);
280
+ if (!n && !l)
281
+ return;
282
+ const u = this._ensureRuleFormulaMap(t, e), c = [void 0, void 0];
283
+ if (n) {
284
+ const d = this._registerSingleFormula(t, e, a, s);
285
+ c[0] = { id: d, text: a };
286
+ }
287
+ if (l) {
288
+ const d = this._registerSingleFormula(t, e, i, s);
289
+ c[1] = { id: d, text: i };
290
+ }
291
+ u.set(s, c);
247
292
  }
248
- u.set(r, c);
249
293
  }
250
294
  removeRule(t, e, r) {
251
- const a = this._ensureRuleFormulaMap(t, e).get(r);
252
- if (!a)
295
+ const i = this._ensureRuleFormulaMap(t, e).get(r);
296
+ if (!i)
253
297
  return;
254
- const [n, o] = a, l = [n == null ? void 0 : n.id, o == null ? void 0 : o.id].filter(Boolean);
298
+ const [s, n] = i, l = [s == null ? void 0 : s.id, n == null ? void 0 : n.id].filter(Boolean);
255
299
  l.length && this._registerOtherFormulaService.deleteFormula(t, e, l);
256
300
  }
257
- updateRuleFormulaText(t, e, r, i, a, n) {
258
- const l = this._ensureRuleFormulaMap(t, e).get(r);
259
- if (!l) {
260
- this.addRule(t, e, r, i, a, n);
261
- return;
262
- }
263
- const [u, c] = l;
264
- if ((u == null ? void 0 : u.text) !== i)
265
- if (u && this._registerOtherFormulaService.deleteFormula(t, e, [u.id]), F(i)) {
266
- const d = this._registerSingleFormula(t, e, i, r);
267
- l[0] = {
268
- text: i,
269
- id: d
270
- };
271
- } else
272
- l[0] = void 0;
273
- if ((c == null ? void 0 : c.text) !== a)
274
- if (c && this._registerOtherFormulaService.deleteFormula(t, e, [c.id]), F(a)) {
275
- const d = this._registerSingleFormula(t, e, a, r);
276
- l[1] = {
277
- text: a,
278
- id: d
279
- };
280
- } else
281
- l[1] = void 0;
282
- }
283
301
  getRuleFormulaResult(t, e, r) {
284
- const a = this._ensureRuleFormulaMap(t, e).get(r);
285
- if (!a)
302
+ const i = this._ensureRuleFormulaMap(t, e).get(r);
303
+ if (!i)
286
304
  return Promise.resolve(null);
287
- const n = async (o) => o && this._registerOtherFormulaService.getFormulaValue(t, e, o.id);
305
+ const s = async (n) => n && this._registerOtherFormulaService.getFormulaValue(t, e, n.id);
288
306
  return Promise.all([
289
- n(a[0]),
290
- n(a[1])
307
+ s(i[0]),
308
+ s(i[1])
291
309
  ]);
292
310
  }
293
311
  getRuleFormulaResultSync(t, e, r) {
294
- const a = this._ensureRuleFormulaMap(t, e).get(r);
295
- if (a)
296
- return a.map((n) => {
297
- if (n)
298
- return this._registerOtherFormulaService.getFormulaValueSync(t, e, n.id);
312
+ const i = this._ensureRuleFormulaMap(t, e).get(r);
313
+ if (i)
314
+ return i.map((s) => {
315
+ if (s)
316
+ return this._registerOtherFormulaService.getFormulaValueSync(t, e, s.id);
299
317
  });
300
318
  }
301
319
  getRuleFormulaInfo(t, e, r) {
302
320
  return this._ensureRuleFormulaMap(t, e).get(r);
303
321
  }
304
322
  };
305
- te = pr([
306
- Ie(0, Z),
307
- Ie(1, E(yt)),
308
- Ie(2, E(ue)),
309
- Ie(3, E(nt))
310
- ], te);
311
- function Ve(s) {
312
- return It(s);
323
+ X = sr([
324
+ fe(0, D),
325
+ fe(1, v(lt)),
326
+ fe(2, v(j)),
327
+ fe(3, v(Ge))
328
+ ], X);
329
+ function ae(o) {
330
+ return Nt(o);
313
331
  }
314
- function Nt(s) {
332
+ function dt(o) {
315
333
  var t;
316
- return String((t = Ve(s)) != null ? t : "");
334
+ return String((t = ae(o)) != null ? t : "");
317
335
  }
318
- const gr = class it {
336
+ const or = class ke {
319
337
  /**
320
338
  * Accept two comparable values and creates new instance of interval
321
339
  * Predicate Interval.comparable_less(low, high) supposed to return true on these values
@@ -330,7 +348,7 @@ const gr = class it {
330
348
  * @returns {Interval}
331
349
  */
332
350
  clone() {
333
- return new it(this.low, this.high);
351
+ return new ke(this.low, this.high);
334
352
  }
335
353
  /**
336
354
  * Propery max returns clone of this interval
@@ -377,7 +395,7 @@ const gr = class it {
377
395
  * @returns {Interval}
378
396
  */
379
397
  merge(t) {
380
- return new it(
398
+ return new ke(
381
399
  this.low === void 0 ? t.low : this.low < t.low ? this.low : t.low,
382
400
  this.high === void 0 ? t.high : this.high > t.high ? this.high : t.high
383
401
  );
@@ -406,17 +424,17 @@ const gr = class it {
406
424
  static comparable_less_than(t, e) {
407
425
  return t < e;
408
426
  }
409
- }, P = 0, C = 1;
410
- class _e {
411
- constructor(t = void 0, e = void 0, r = null, i = null, a = null, n = C) {
412
- if (this.left = r, this.right = i, this.parent = a, this.color = n, this.item = { key: t, value: e }, t && t instanceof Array && t.length === 2 && !Number.isNaN(t[0]) && !Number.isNaN(t[1])) {
413
- let [o, l] = t;
414
- o > l && ([o, l] = [l, o]), this.item.key = new gr(o, l);
427
+ }, T = 0, V = 1;
428
+ class G {
429
+ constructor(t = void 0, e = void 0, r = null, a = null, i = null, s = V) {
430
+ if (this.left = r, this.right = a, this.parent = i, this.color = s, this.item = { key: t, value: e }, t && t instanceof Array && t.length === 2 && !Number.isNaN(t[0]) && !Number.isNaN(t[1])) {
431
+ let [n, l] = t;
432
+ n > l && ([n, l] = [l, n]), this.item.key = new or(n, l);
415
433
  }
416
434
  this.max = this.item.key ? this.item.key.max : void 0;
417
435
  }
418
436
  isNil() {
419
- return this.item.key === void 0 && this.item.value === void 0 && this.left === null && this.right === null && this.color === C;
437
+ return this.item.key === void 0 && this.item.value === void 0 && this.left === null && this.right === null && this.color === V;
420
438
  }
421
439
  _value_less_than(t) {
422
440
  return this.item.value && t.item.value && this.item.value.less_than ? this.item.value.less_than(t.item.value) : this.item.value < t.item.value;
@@ -459,12 +477,12 @@ class _e {
459
477
  return e(t.item.key.high, r);
460
478
  }
461
479
  }
462
- class ct {
480
+ class Xe {
463
481
  /**
464
482
  * Construct new empty instance of IntervalTree
465
483
  */
466
484
  constructor() {
467
- this.root = null, this.nil_node = new _e();
485
+ this.root = null, this.nil_node = new G();
468
486
  }
469
487
  /**
470
488
  * Returns number of items stored in the interval tree
@@ -524,7 +542,7 @@ class ct {
524
542
  */
525
543
  insert(t, e = t) {
526
544
  if (t === void 0) return;
527
- let r = new _e(t, e, this.nil_node, this.nil_node, null, P);
545
+ let r = new G(t, e, this.nil_node, this.nil_node, null, T);
528
546
  return this.tree_insert(r), this.recalc_max(r), r;
529
547
  }
530
548
  /**
@@ -534,7 +552,7 @@ class ct {
534
552
  * @returns {boolean} true if item {key, value} exist in the tree, false otherwise
535
553
  */
536
554
  exist(t, e = t) {
537
- let r = new _e(t, e);
555
+ let r = new G(t, e);
538
556
  return !!this.tree_search(this.root, r);
539
557
  }
540
558
  /**
@@ -544,8 +562,8 @@ class ct {
544
562
  * @returns {boolean} true if item {key, value} deleted, false if not found
545
563
  */
546
564
  remove(t, e = t) {
547
- let r = new _e(t, e), i = this.tree_search(this.root, r);
548
- return i && this.tree_delete(i), i;
565
+ let r = new G(t, e), a = this.tree_search(this.root, r);
566
+ return a && this.tree_delete(a), a;
549
567
  }
550
568
  /**
551
569
  * Returns array of entry values which keys intersect with given interval <br/>
@@ -554,9 +572,9 @@ class ct {
554
572
  * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
555
573
  * @returns {Array}
556
574
  */
557
- search(t, e = (r, i) => r === i ? i.output() : r) {
558
- let r = new _e(t), i = [];
559
- return this.tree_search_interval(this.root, r, i), i.map((a) => e(a.item.value, a.item.key));
575
+ search(t, e = (r, a) => r === a ? a.output() : r) {
576
+ let r = new G(t), a = [];
577
+ return this.tree_search_interval(this.root, r, a), a.map((i) => e(i.item.value, i.item.key));
560
578
  }
561
579
  /**
562
580
  * Returns true if intersection between given and any interval stored in the tree found
@@ -564,7 +582,7 @@ class ct {
564
582
  * @returns {boolean}
565
583
  */
566
584
  intersect_any(t) {
567
- let e = new _e(t);
585
+ let e = new G(t);
568
586
  return this.tree_find_any_interval(this.root, e);
569
587
  }
570
588
  /**
@@ -580,7 +598,7 @@ class ct {
580
598
  * @param callback(value,key) - function to be called for each tree item
581
599
  */
582
600
  map(t) {
583
- const e = new ct();
601
+ const e = new Xe();
584
602
  return this.tree_walk(this.root, (r) => e.insert(r.item.key, t(r.item.value, r.item.key))), e;
585
603
  }
586
604
  /**
@@ -588,9 +606,9 @@ class ct {
588
606
  * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
589
607
  * @returns {Iterator}
590
608
  */
591
- *iterate(t, e = (r, i) => r === i ? i.output() : r) {
609
+ *iterate(t, e = (r, a) => r === a ? a.output() : r) {
592
610
  let r;
593
- for (t ? r = this.tree_search_nearest_forward(this.root, new _e(t)) : this.root && (r = this.local_minimum(this.root)); r; )
611
+ for (t ? r = this.tree_search_nearest_forward(this.root, new G(t)) : this.root && (r = this.local_minimum(this.root)); r; )
594
612
  yield e(r.item.value, r.item.key), r = this.tree_successor(r);
595
613
  }
596
614
  recalc_max(t) {
@@ -613,29 +631,29 @@ class ct {
613
631
  // Go upwords to the root and re-color until violation will be resolved
614
632
  insert_fixup(t) {
615
633
  let e, r;
616
- for (e = t; e !== this.root && e.parent.color === P; )
617
- e.parent === e.parent.parent.left ? (r = e.parent.parent.right, r.color === P ? (e.parent.color = C, r.color = C, e.parent.parent.color = P, e = e.parent.parent) : (e === e.parent.right && (e = e.parent, this.rotate_left(e)), e.parent.color = C, e.parent.parent.color = P, this.rotate_right(e.parent.parent))) : (r = e.parent.parent.left, r.color === P ? (e.parent.color = C, r.color = C, e.parent.parent.color = P, e = e.parent.parent) : (e === e.parent.left && (e = e.parent, this.rotate_right(e)), e.parent.color = C, e.parent.parent.color = P, this.rotate_left(e.parent.parent)));
618
- this.root.color = C;
634
+ for (e = t; e !== this.root && e.parent.color === T; )
635
+ e.parent === e.parent.parent.left ? (r = e.parent.parent.right, r.color === T ? (e.parent.color = V, r.color = V, e.parent.parent.color = T, e = e.parent.parent) : (e === e.parent.right && (e = e.parent, this.rotate_left(e)), e.parent.color = V, e.parent.parent.color = T, this.rotate_right(e.parent.parent))) : (r = e.parent.parent.left, r.color === T ? (e.parent.color = V, r.color = V, e.parent.parent.color = T, e = e.parent.parent) : (e === e.parent.left && (e = e.parent, this.rotate_right(e)), e.parent.color = V, e.parent.parent.color = T, this.rotate_left(e.parent.parent)));
636
+ this.root.color = V;
619
637
  }
620
638
  tree_delete(t) {
621
639
  let e, r;
622
640
  t.left === this.nil_node || t.right === this.nil_node ? e = t : e = this.tree_successor(t), e.left !== this.nil_node ? r = e.left : r = e.right, r.parent = e.parent, e === this.root ? this.root = r : (e === e.parent.left ? e.parent.left = r : e.parent.right = r, e.parent.update_max()), this.recalc_max(r), e !== t && (t.copy_data(e), t.update_max(), this.recalc_max(t)), /*fix_node != this.nil_node && */
623
- e.color === C && this.delete_fixup(r);
641
+ e.color === V && this.delete_fixup(r);
624
642
  }
625
643
  delete_fixup(t) {
626
644
  let e = t, r;
627
- for (; e !== this.root && e.parent != null && e.color === C; )
628
- e === e.parent.left ? (r = e.parent.right, r.color === P && (r.color = C, e.parent.color = P, this.rotate_left(e.parent), r = e.parent.right), r.left.color === C && r.right.color === C ? (r.color = P, e = e.parent) : (r.right.color === C && (r.color = P, r.left.color = C, this.rotate_right(r), r = e.parent.right), r.color = e.parent.color, e.parent.color = C, r.right.color = C, this.rotate_left(e.parent), e = this.root)) : (r = e.parent.left, r.color === P && (r.color = C, e.parent.color = P, this.rotate_right(e.parent), r = e.parent.left), r.left.color === C && r.right.color === C ? (r.color = P, e = e.parent) : (r.left.color === C && (r.color = P, r.right.color = C, this.rotate_left(r), r = e.parent.left), r.color = e.parent.color, e.parent.color = C, r.left.color = C, this.rotate_right(e.parent), e = this.root));
629
- e.color = C;
645
+ for (; e !== this.root && e.parent != null && e.color === V; )
646
+ e === e.parent.left ? (r = e.parent.right, r.color === T && (r.color = V, e.parent.color = T, this.rotate_left(e.parent), r = e.parent.right), r.left.color === V && r.right.color === V ? (r.color = T, e = e.parent) : (r.right.color === V && (r.color = T, r.left.color = V, this.rotate_right(r), r = e.parent.right), r.color = e.parent.color, e.parent.color = V, r.right.color = V, this.rotate_left(e.parent), e = this.root)) : (r = e.parent.left, r.color === T && (r.color = V, e.parent.color = T, this.rotate_right(e.parent), r = e.parent.left), r.left.color === V && r.right.color === V ? (r.color = T, e = e.parent) : (r.left.color === V && (r.color = T, r.right.color = V, this.rotate_left(r), r = e.parent.left), r.color = e.parent.color, e.parent.color = V, r.left.color = V, this.rotate_right(e.parent), e = this.root));
647
+ e.color = V;
630
648
  }
631
649
  tree_search(t, e) {
632
650
  if (!(t == null || t === this.nil_node))
633
651
  return e.equal_to(t) ? t : e.less_than(t) ? this.tree_search(t.left, e) : this.tree_search(t.right, e);
634
652
  }
635
653
  tree_search_nearest_forward(t, e) {
636
- let r, i = t;
637
- for (; i && i !== this.nil_node; )
638
- i.less_than(e) ? i.intersect(e) ? (r = i, i = i.left) : i = i.right : ((!r || i.less_than(r)) && (r = i), i = i.left);
654
+ let r, a = t;
655
+ for (; a && a !== this.nil_node; )
656
+ a.less_than(e) ? a.intersect(e) ? (r = a, a = a.left) : a = a.right : ((!r || a.less_than(r)) && (r = a), a = a.left);
639
657
  return r || null;
640
658
  }
641
659
  // Original search_interval method; container res support push() insertion
@@ -661,13 +679,13 @@ class ct {
661
679
  return e;
662
680
  }
663
681
  tree_successor(t) {
664
- let e, r, i;
682
+ let e, r, a;
665
683
  if (t.right !== this.nil_node)
666
684
  e = this.local_minimum(t.right);
667
685
  else {
668
- for (r = t, i = t.parent; i != null && i.right === r; )
669
- r = i, i = i.parent;
670
- e = i;
686
+ for (r = t, a = t.parent; a != null && a.right === r; )
687
+ r = a, a = a.parent;
688
+ e = a;
671
689
  }
672
690
  return e;
673
691
  }
@@ -692,69 +710,69 @@ class ct {
692
710
  testRedBlackProperty() {
693
711
  let t = !0;
694
712
  return this.tree_walk(this.root, function(e) {
695
- e.color === P && (e.left.color === C && e.right.color === C || (t = !1));
713
+ e.color === T && (e.left.color === V && e.right.color === V || (t = !1));
696
714
  }), t;
697
715
  }
698
716
  /* Throw error if not every path from root to bottom has same black height */
699
717
  testBlackHeightProperty(t) {
700
- let e = 0, r = 0, i = 0;
701
- if (t.color === C && e++, t.left !== this.nil_node ? r = this.testBlackHeightProperty(t.left) : r = 1, t.right !== this.nil_node ? i = this.testBlackHeightProperty(t.right) : i = 1, r !== i)
718
+ let e = 0, r = 0, a = 0;
719
+ if (t.color === V && e++, t.left !== this.nil_node ? r = this.testBlackHeightProperty(t.left) : r = 1, t.right !== this.nil_node ? a = this.testBlackHeightProperty(t.right) : a = 1, r !== a)
702
720
  throw new Error("Red-black height property violated");
703
721
  return e += r, e;
704
722
  }
705
723
  }
706
- class dt {
707
- constructor(t, e, r, i, a = !1) {
708
- g(this, "_map");
709
- g(this, "_tree", /* @__PURE__ */ new Map());
710
- g(this, "_dirty", !0);
711
- g(this, "_buildTree", () => {
724
+ class Ke {
725
+ constructor(t, e, r, a, i = !1) {
726
+ f(this, "_map");
727
+ f(this, "_tree", /* @__PURE__ */ new Map());
728
+ f(this, "_dirty", !0);
729
+ f(this, "_buildTree", () => {
712
730
  if (!this._dirty || this._disableTree)
713
731
  return;
714
732
  const t = /* @__PURE__ */ new Map();
715
- this._map.forEach((r, i) => {
716
- r.forEach((a) => {
717
- for (let n = a.startColumn; n <= a.endColumn; n++) {
718
- let o = t.get(n);
719
- o || (o = [], t.set(n, o)), o.push({
720
- startRow: a.startRow,
721
- endRow: a.endRow,
722
- ruleId: i
733
+ this._map.forEach((r, a) => {
734
+ r.forEach((i) => {
735
+ for (let s = i.startColumn; s <= i.endColumn; s++) {
736
+ let n = t.get(s);
737
+ n || (n = [], t.set(s, n)), n.push({
738
+ startRow: i.startRow,
739
+ endRow: i.endRow,
740
+ ruleId: a
723
741
  });
724
742
  }
725
743
  });
726
744
  });
727
745
  const e = /* @__PURE__ */ new Map();
728
- t.forEach((r, i) => {
729
- const a = new ct();
730
- r.forEach((n) => {
731
- a.insert([n.startRow, n.endRow], n.ruleId);
732
- }), e.set(i, a);
746
+ t.forEach((r, a) => {
747
+ const i = new Xe();
748
+ r.forEach((s) => {
749
+ i.insert([s.startRow, s.endRow], s.ruleId);
750
+ }), e.set(a, i);
733
751
  }), this._tree = e, this._dirty = !1;
734
752
  });
735
- g(this, "_debonceBuildTree", $t(this._buildTree, 0));
736
- this._unitId = e, this._subUnitId = r, this._univerInstanceService = i, this._disableTree = a, this._map = t, this._buildTree();
753
+ f(this, "_debonceBuildTree", Mt(this._buildTree, 0));
754
+ this._unitId = e, this._subUnitId = r, this._univerInstanceService = a, this._disableTree = i, this._map = t, this._buildTree();
737
755
  }
738
756
  get _worksheet() {
739
757
  var t;
740
- return (t = this._univerInstanceService.getUnit(this._unitId, K.UNIVER_SHEET)) == null ? void 0 : t.getSheetBySheetId(this._subUnitId);
758
+ return (t = this._univerInstanceService.getUnit(this._unitId, A.UNIVER_SHEET)) == null ? void 0 : t.getSheetBySheetId(this._subUnitId);
741
759
  }
742
760
  addRule(t) {
743
761
  if (!this._worksheet)
744
762
  return;
745
- const e = t.uid, r = t.ranges.map((i) => Q.transformRange(i, this._worksheet));
746
- this._map.forEach((i, a) => {
747
- const n = ee.subtractMulti(i, r);
748
- n.length === 0 ? this._map.delete(a) : this._map.set(a, n);
763
+ const e = t.uid, r = t.ranges.map((a) => I.transformRange(a, this._worksheet));
764
+ this._map.forEach((a, i) => {
765
+ const s = B.subtractMulti(a, r);
766
+ s.length === 0 ? this._map.delete(i) : this._map.set(i, s);
749
767
  }), this._dirty = !0, this._map.set(e, r), this._debonceBuildTree();
750
768
  }
751
769
  removeRange(t) {
752
770
  if (!this._worksheet)
753
771
  return;
754
- const e = t.map((r) => Q.transformRange(r, this._worksheet));
755
- this._map.forEach((r, i) => {
756
- const a = ee.subtractMulti(r, e);
757
- a.length === 0 ? this._map.delete(i) : this._map.set(i, a);
772
+ const e = t.map((r) => I.transformRange(r, this._worksheet));
773
+ this._map.forEach((r, a) => {
774
+ const i = B.subtractMulti(r, e);
775
+ i.length === 0 ? this._map.delete(a) : this._map.set(a, i);
758
776
  }), this._dirty = !0, this._debonceBuildTree();
759
777
  }
760
778
  removeRule(t) {
@@ -764,76 +782,76 @@ class dt {
764
782
  if (!this._worksheet)
765
783
  return;
766
784
  this._map.delete(t);
767
- const r = e.map((i) => Q.transformRange(i, this._worksheet));
768
- this._map.forEach((i, a) => {
769
- const n = ee.subtractMulti(i, r);
770
- n.length === 0 ? this._map.delete(a) : this._map.set(a, n);
785
+ const r = e.map((a) => I.transformRange(a, this._worksheet));
786
+ this._map.forEach((a, i) => {
787
+ const s = B.subtractMulti(a, r);
788
+ s.length === 0 ? this._map.delete(i) : this._map.set(i, s);
771
789
  }), this._map.set(t, r), this._dirty = !0, this._debonceBuildTree();
772
790
  }
773
791
  addRangeRules(t) {
774
792
  t.forEach(({ id: e, ranges: r }) => {
775
793
  if (!r.length)
776
794
  return;
777
- let i = this._map.get(e);
778
- i ? (this._map.set(e, ee.mergeRanges([...i, ...r])), i = this._map.get(e)) : (i = r, this._map.set(e, i)), this._map.forEach((a, n) => {
779
- if (n === e)
795
+ let a = this._map.get(e);
796
+ a ? (this._map.set(e, B.mergeRanges([...a, ...r])), a = this._map.get(e)) : (a = r, this._map.set(e, a)), this._map.forEach((i, s) => {
797
+ if (s === e)
780
798
  return;
781
- const o = ee.subtractMulti(a, r);
782
- o.length === 0 ? this._map.delete(n) : this._map.set(n, o);
799
+ const n = B.subtractMulti(i, r);
800
+ n.length === 0 ? this._map.delete(s) : this._map.set(s, n);
783
801
  });
784
802
  }), this._dirty = !0, this._debonceBuildTree();
785
803
  }
786
804
  diff(t) {
787
805
  const e = [];
788
806
  let r = 0;
789
- return t.forEach((i, a) => {
807
+ return t.forEach((a, i) => {
790
808
  var l;
791
- const n = (l = this._map.get(i.uid)) != null ? l : [], o = i.ranges;
792
- n.length !== 0 && (n.length !== o.length || n.some((u, c) => !ee.equals(u, o[c]))) && e.push({
809
+ const s = (l = this._map.get(a.uid)) != null ? l : [], n = a.ranges;
810
+ s.length !== 0 && (s.length !== n.length || s.some((u, c) => !B.equals(u, n[c]))) && e.push({
793
811
  type: "update",
794
- ruleId: i.uid,
795
- oldRanges: o,
796
- newRanges: ee.sort(n),
797
- rule: i
798
- }), n.length === 0 && (e.push({
812
+ ruleId: a.uid,
813
+ oldRanges: n,
814
+ newRanges: B.sort(s),
815
+ rule: a
816
+ }), s.length === 0 && (e.push({
799
817
  type: "delete",
800
- rule: i,
801
- index: a - r
818
+ rule: a,
819
+ index: i - r
802
820
  }), r++);
803
821
  }), e;
804
822
  }
805
823
  diffWithAddition(t, e) {
806
824
  const r = [];
807
- let i = 0;
808
- return t.forEach((a, n) => {
825
+ let a = 0;
826
+ return t.forEach((i, s) => {
809
827
  var u;
810
- const o = (u = this._map.get(a.uid)) != null ? u : [], l = a.ranges;
811
- o.length !== 0 && (o.length !== l.length || o.some((c, d) => !ee.equals(c, l[d]))) && r.push({
828
+ const n = (u = this._map.get(i.uid)) != null ? u : [], l = i.ranges;
829
+ n.length !== 0 && (n.length !== l.length || n.some((c, d) => !B.equals(c, l[d]))) && r.push({
812
830
  type: "update",
813
- ruleId: a.uid,
831
+ ruleId: i.uid,
814
832
  oldRanges: l,
815
- newRanges: ee.sort(o),
816
- rule: a
817
- }), o.length === 0 && (r.push({
833
+ newRanges: B.sort(n),
834
+ rule: i
835
+ }), n.length === 0 && (r.push({
818
836
  type: "delete",
819
- rule: a,
820
- index: n - i
821
- }), i++);
822
- }), Array.from(e).forEach((a) => {
823
- var o;
824
- const n = (o = this._map.get(a.uid)) != null ? o : [];
837
+ rule: i,
838
+ index: s - a
839
+ }), a++);
840
+ }), Array.from(e).forEach((i) => {
841
+ var n;
842
+ const s = (n = this._map.get(i.uid)) != null ? n : [];
825
843
  r.push({
826
844
  type: "add",
827
845
  rule: {
828
- ...a,
829
- ranges: ee.sort(n)
846
+ ...i,
847
+ ranges: B.sort(s)
830
848
  }
831
849
  });
832
850
  }), r;
833
851
  }
834
852
  clone() {
835
- return new dt(
836
- new Map(b.deepClone(Array.from(this._map.entries()))),
853
+ return new Ke(
854
+ new Map(N.deepClone(Array.from(this._map.entries()))),
837
855
  this._unitId,
838
856
  this._subUnitId,
839
857
  this._univerInstanceService,
@@ -846,24 +864,24 @@ class dt {
846
864
  const r = this._tree.get(e);
847
865
  if (!r)
848
866
  return;
849
- const i = r.search([t, t]);
850
- return i.length > 0 ? i[0] : void 0;
867
+ const a = r.search([t, t]);
868
+ return a.length > 0 ? a[0] : void 0;
851
869
  }
852
870
  }
853
- var vr = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, Rr = (s, t, e, r) => {
854
- for (var i = r > 1 ? void 0 : r ? Sr(t, e) : t, a = s.length - 1, n; a >= 0; a--)
855
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
856
- return r && i && vr(t, e, i), i;
857
- }, pe = (s, t) => (e, r) => t(e, r, s);
858
- let j = class extends ce {
859
- constructor(t, e, r, i, a, n, o) {
871
+ var nr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ur = (o, t, e, r) => {
872
+ for (var a = r > 1 ? void 0 : r ? lr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
873
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
874
+ return r && a && nr(t, e, a), a;
875
+ }, Q = (o, t) => (e, r) => t(e, r, o);
876
+ let F = class extends W {
877
+ constructor(t, e, r, a, i, s, n) {
860
878
  super();
861
- g(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
862
- g(this, "_validStatusChange$", new at());
863
- g(this, "_ruleChange$", new at());
864
- g(this, "ruleChange$", this._ruleChange$.asObservable());
865
- g(this, "validStatusChange$", this._validStatusChange$.asObservable());
866
- this._dataValidationModel = t, this._univerInstanceService = e, this._dataValidatorRegistryService = r, this._dataValidationCacheService = i, this._dataValidationFormulaService = a, this._dataValidationCustomFormulaService = n, this._commandService = o, this._initRuleUpdateListener(), this.disposeWithMe(() => {
879
+ f(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
880
+ f(this, "_validStatusChange$", new We());
881
+ f(this, "_ruleChange$", new We());
882
+ f(this, "ruleChange$", this._ruleChange$.asObservable());
883
+ f(this, "validStatusChange$", this._validStatusChange$.asObservable());
884
+ this._dataValidationModel = t, this._univerInstanceService = e, this._dataValidatorRegistryService = r, this._dataValidationCacheService = a, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService = s, this._commandService = n, this._initRuleUpdateListener(), this.disposeWithMe(() => {
867
885
  this._ruleChange$.complete(), this._validStatusChange$.complete();
868
886
  }), this._initUniverInstanceListener();
869
887
  }
@@ -874,9 +892,9 @@ let j = class extends ce {
874
892
  })
875
893
  ), this.disposeWithMe(
876
894
  this._commandService.onCommandExecuted((t) => {
877
- if (t.id === Qt.id) {
878
- const { unitId: e, subUnitId: r } = t.params, i = this._ruleMatrixMap.get(e);
879
- i && i.delete(r);
895
+ if (t.id === Pt.id) {
896
+ const { unitId: e, subUnitId: r } = t.params, a = this._ruleMatrixMap.get(e);
897
+ a && a.delete(r);
880
898
  }
881
899
  })
882
900
  );
@@ -884,13 +902,13 @@ let j = class extends ce {
884
902
  _initRuleUpdateListener() {
885
903
  const t = this._dataValidationModel.getAll();
886
904
  for (const [e, r] of t)
887
- for (const [i, a] of r)
888
- for (const n of a)
889
- this._addRule(e, i, n), this._ruleChange$.next({
905
+ for (const [a, i] of r)
906
+ for (const s of i)
907
+ this._addRule(e, a, s), this._ruleChange$.next({
890
908
  type: "add",
891
909
  unitId: e,
892
- subUnitId: i,
893
- rule: n,
910
+ subUnitId: a,
911
+ rule: s,
894
912
  source: "patched"
895
913
  });
896
914
  this.disposeWithMe(
@@ -913,97 +931,84 @@ let j = class extends ce {
913
931
  _ensureRuleMatrix(t, e) {
914
932
  let r = this._ruleMatrixMap.get(t);
915
933
  r || (r = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(t, r));
916
- let i = r.get(e);
917
- return i || (i = new dt(/* @__PURE__ */ new Map(), t, e, this._univerInstanceService), r.set(e, i)), i;
934
+ let a = r.get(e);
935
+ return a || (a = new Ke(/* @__PURE__ */ new Map(), t, e, this._univerInstanceService), r.set(e, a)), a;
918
936
  }
919
937
  _addRuleSideEffect(t, e, r) {
920
- this._ensureRuleMatrix(t, e).addRule(r), this._dataValidationCacheService.addRule(t, e, r), this._dataValidationFormulaService.addRule(t, e, r.uid, r.formula1, r.formula2, r.ranges), r.type === $.CUSTOM && this._dataValidationCustomFormulaService.addRule(t, e, r);
938
+ this._ensureRuleMatrix(t, e).addRule(r), this._dataValidationCacheService.addRule(t, e, r), this._dataValidationFormulaService.addRule(t, e, r), this._dataValidationCustomFormulaService.addRule(t, e, r);
921
939
  }
922
940
  _addRule(t, e, r) {
923
- (Array.isArray(r) ? r : [r]).forEach((a) => {
924
- this._addRuleSideEffect(t, e, a);
941
+ (Array.isArray(r) ? r : [r]).forEach((i) => {
942
+ this._addRuleSideEffect(t, e, i);
925
943
  });
926
944
  }
927
- _updateRule(t, e, r, i, a) {
928
- const n = this._ensureRuleMatrix(t, e);
929
- a.type === Y.RANGE ? (n.updateRange(r, a.payload), this._dataValidationCacheService.updateRuleRanges(t, e, r, a.payload, i.ranges), i.type === $.CUSTOM && (this._dataValidationCustomFormulaService.deleteByRuleId(t, e, r), this._dataValidationCustomFormulaService.addRule(t, e, {
930
- ...i,
931
- ranges: a.payload
932
- }))) : a.type === Y.SETTING && (this._dataValidationCacheService.markRangeDirty(t, e, i.ranges), this._dataValidationFormulaService.updateRuleFormulaText(t, e, r, a.payload.formula1, a.payload.formula2, i.ranges), i.type === $.CUSTOM ? (this._dataValidationCustomFormulaService.deleteByRuleId(t, e, r), this._dataValidationCustomFormulaService.addRule(t, e, {
933
- ...i,
934
- ...a.payload
935
- })) : a.payload.type === $.CUSTOM && this._dataValidationCustomFormulaService.addRule(t, e, {
936
- ...i,
937
- ...a.payload
938
- }));
945
+ _updateRule(t, e, r, a, i) {
946
+ const s = this._ensureRuleMatrix(t, e), n = {
947
+ ...a,
948
+ ...i.payload
949
+ };
950
+ i.type === w.RANGE ? (s.updateRange(r, i.payload), this._dataValidationCacheService.updateRuleRanges(t, e, r, i.payload, a.ranges)) : i.type === w.SETTING ? this._dataValidationCacheService.markRangeDirty(t, e, a.ranges) : i.type === w.ALL && (s.updateRange(r, i.payload.ranges), this._dataValidationCacheService.updateRuleRanges(t, e, r, i.payload.ranges, a.ranges), this._dataValidationCacheService.markRangeDirty(t, e, a.ranges)), this._dataValidationFormulaService.removeRule(t, e, a.uid), this._dataValidationFormulaService.addRule(t, e, n), this._dataValidationCustomFormulaService.deleteByRuleId(t, e, r), this._dataValidationCustomFormulaService.addRule(t, e, n);
939
951
  }
940
952
  _removeRule(t, e, r) {
941
- this._ensureRuleMatrix(t, e).removeRule(r), this._dataValidationCacheService.removeRule(t, e, r), r.type === $.CUSTOM && this._dataValidationCustomFormulaService.deleteByRuleId(t, e, r.uid);
953
+ this._ensureRuleMatrix(t, e).removeRule(r), this._dataValidationCacheService.removeRule(t, e, r), this._dataValidationCustomFormulaService.deleteByRuleId(t, e, r.uid);
942
954
  }
943
955
  getValidator(t) {
944
956
  return this._dataValidatorRegistryService.getValidatorItem(t);
945
957
  }
946
- getRuleIdByLocation(t, e, r, i) {
947
- return this._ensureRuleMatrix(t, e).getValue(r, i);
958
+ getRuleIdByLocation(t, e, r, a) {
959
+ return this._ensureRuleMatrix(t, e).getValue(r, a);
948
960
  }
949
- getRuleByLocation(t, e, r, i) {
950
- const a = this.getRuleIdByLocation(t, e, r, i);
951
- if (a)
952
- return this._dataValidationModel.getRuleById(t, e, a);
961
+ getRuleByLocation(t, e, r, a) {
962
+ const i = this.getRuleIdByLocation(t, e, r, a);
963
+ if (i)
964
+ return this._dataValidationModel.getRuleById(t, e, i);
953
965
  }
954
966
  validator(t, e, r) {
955
- const { col: i, row: a, unitId: n, subUnitId: o, worksheet: l } = e, u = t.uid, c = t.formula1, d = t.formula2, m = (x, O) => {
956
- r && r(x, O), O && this._validStatusChange$.next({
957
- unitId: n,
958
- subUnitId: o,
967
+ const { col: a, row: i, unitId: s, subUnitId: n, worksheet: l } = e, u = t.uid, c = t.formula1, d = t.formula2, m = (C, E) => {
968
+ r && r(C, E), E && this._validStatusChange$.next({
969
+ unitId: s,
970
+ subUnitId: n,
959
971
  ruleId: t.uid,
960
- status: x,
961
- row: a,
962
- col: i
972
+ status: C,
973
+ row: i,
974
+ col: a
963
975
  });
964
- }, v = l.getCellValueOnly(a, i), S = this.getValidator(t.type), w = l.getCellRaw(a, i), I = Ve(w), M = Ve(v);
965
- if (S) {
966
- const x = this._dataValidationCacheService.ensureCache(n, o), O = x.getValue(a, i);
967
- return !O || O.value !== I || O.interceptValue !== M || O.ruleId !== u || O.formula1 !== c || O.formula2 !== d ? (x.setValue(a, i, {
968
- value: I,
969
- interceptValue: M,
970
- status: ge.VALIDATING,
976
+ }, _ = l.getCellValueOnly(i, a), p = this.getValidator(t.type), S = l.getCellRaw(i, a), y = ae(S), g = ae(_);
977
+ if (p) {
978
+ const C = this._dataValidationCacheService.ensureCache(s, n), E = C.getValue(i, a);
979
+ return !E || E.value !== y || E.interceptValue !== g || E.ruleId !== u || E.formula1 !== c || E.formula2 !== d ? (C.setValue(i, a, {
980
+ value: y,
981
+ interceptValue: g,
982
+ status: Y.VALIDATING,
971
983
  ruleId: u,
972
984
  formula1: c || "",
973
985
  formula2: d || ""
974
- }), S.validator(
986
+ }), p.validator(
975
987
  {
976
- value: I,
977
- unitId: n,
978
- subUnitId: o,
979
- row: a,
980
- column: i,
988
+ value: y,
989
+ unitId: s,
990
+ subUnitId: n,
991
+ row: i,
992
+ column: a,
981
993
  worksheet: e.worksheet,
982
994
  workbook: e.workbook,
983
- interceptValue: Ve(v),
984
- t: w == null ? void 0 : w.t
995
+ interceptValue: ae(_),
996
+ t: S == null ? void 0 : S.t
985
997
  },
986
998
  t
987
- ).then((H) => {
988
- const L = H ? ge.VALID : ge.INVALID;
989
- x.setValue(a, i, {
990
- value: I,
999
+ ).then((x) => {
1000
+ const L = x ? Y.VALID : Y.INVALID;
1001
+ C.setValue(i, a, {
1002
+ value: y,
991
1003
  status: L,
992
1004
  ruleId: u,
993
- interceptValue: M,
1005
+ interceptValue: g,
994
1006
  formula1: c || "",
995
1007
  formula2: d || ""
996
1008
  }), m(L, !0);
997
- }), ge.VALIDATING) : (m(O.status, !1), O.status);
1009
+ }), Y.VALIDATING) : (m(E.status, !1), E.status);
998
1010
  } else
999
- return m(ge.VALID, !1), ge.VALID;
1000
- }
1001
- getRuleErrorMsg(t, e, r) {
1002
- const i = this._dataValidationModel.getRuleById(t, e, r);
1003
- if (!i)
1004
- return "";
1005
- const a = this._dataValidatorRegistryService.getValidatorItem(i.type);
1006
- return i.error ? i.error : a ? a.getRuleFinalError(i) : "";
1011
+ return m(Y.VALID, !1), Y.VALID;
1007
1012
  }
1008
1013
  getRuleObjectMatrix(t, e) {
1009
1014
  return this._ensureRuleMatrix(t, e);
@@ -1030,58 +1035,58 @@ let j = class extends ce {
1030
1035
  return this._dataValidationModel.getAll();
1031
1036
  }
1032
1037
  };
1033
- j = Rr([
1034
- pe(0, E(nt)),
1035
- pe(1, Z),
1036
- pe(2, E(ot)),
1037
- pe(3, E(ue)),
1038
- pe(4, E(te)),
1039
- pe(5, E(we)),
1040
- pe(6, re)
1041
- ], j);
1042
- const Be = 1, Pe = 0;
1043
- function ft(s, t) {
1044
- return b.isBlank(s) ? t.t("dataValidation.validFail.value") : F(s) ? t.t("dataValidation.validFail.primitive") : "";
1038
+ F = ur([
1039
+ Q(0, v(Ge)),
1040
+ Q(1, D),
1041
+ Q(2, v(Qe)),
1042
+ Q(3, v(j)),
1043
+ Q(4, v(X)),
1044
+ Q(5, v($)),
1045
+ Q(6, H)
1046
+ ], F);
1047
+ const Se = 1, Ve = 0;
1048
+ function rt(o, t) {
1049
+ return N.isBlank(o) ? t.t("dataValidation.validFail.value") : R(o) ? t.t("dataValidation.validFail.primitive") : "";
1045
1050
  }
1046
- const $e = (s) => b.isDefine(s) && String(s).toLowerCase() === "true" ? "1" : String(s).toLowerCase() === "false" ? "0" : s;
1047
- class yr extends de {
1051
+ const _e = (o) => N.isDefine(o) && String(o).toLowerCase() === "true" ? "1" : String(o).toLowerCase() === "false" ? "0" : o;
1052
+ class cr extends q {
1048
1053
  constructor() {
1049
1054
  super(...arguments);
1050
- g(this, "id", $.CHECKBOX);
1051
- g(this, "title", "dataValidation.checkbox.title");
1052
- g(this, "operators", []);
1053
- g(this, "scopes", ["sheet"]);
1054
- g(this, "_formulaService", this.injector.get(te));
1055
- g(this, "skipDefaultFontRender", (e, r, i) => {
1056
- const { unitId: a, subUnitId: n } = i, { formula1: o, formula2: l } = this.parseFormulaSync(e, a, n), u = `${r != null ? r : ""}`;
1057
- return !u || u === `${o}` || u === `${l}`;
1055
+ f(this, "id", M.CHECKBOX);
1056
+ f(this, "title", "dataValidation.checkbox.title");
1057
+ f(this, "operators", []);
1058
+ f(this, "scopes", ["sheet"]);
1059
+ f(this, "_formulaService", this.injector.get(X));
1060
+ f(this, "skipDefaultFontRender", (e, r, a) => {
1061
+ const { unitId: i, subUnitId: s } = a, { formula1: n, formula2: l } = this.parseFormulaSync(e, i, s), u = `${r != null ? r : ""}`;
1062
+ return !u || u === `${n}` || u === `${l}`;
1058
1063
  });
1059
1064
  }
1060
- validatorFormula(e, r, i) {
1061
- const { formula1: a, formula2: n } = e, o = a === n;
1062
- if (b.isBlank(a) && b.isBlank(n))
1065
+ validatorFormula(e, r, a) {
1066
+ const { formula1: i, formula2: s } = e, n = i === s;
1067
+ if (N.isBlank(i) && N.isBlank(s))
1063
1068
  return {
1064
1069
  success: !0
1065
1070
  };
1066
- if (o)
1071
+ if (n)
1067
1072
  return {
1068
1073
  success: !1,
1069
1074
  formula1: this.localeService.t("dataValidation.validFail.checkboxEqual"),
1070
1075
  formula2: this.localeService.t("dataValidation.validFail.checkboxEqual")
1071
1076
  };
1072
- const l = ft(a, this.localeService), u = ft(n, this.localeService);
1077
+ const l = rt(i, this.localeService), u = rt(s, this.localeService);
1073
1078
  return {
1074
1079
  success: !l && !u,
1075
1080
  formula1: l,
1076
1081
  formula2: u
1077
1082
  };
1078
1083
  }
1079
- async parseFormula(e, r, i) {
1080
- var d, m, v, S;
1081
- const { formula1: a = Be, formula2: n = Pe } = e, o = await this._formulaService.getRuleFormulaResult(r, i, e.uid), l = F(a) ? z((m = (d = o == null ? void 0 : o[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]) : a, u = F(n) ? z((S = (v = o == null ? void 0 : o[1]) == null ? void 0 : v.result) == null ? void 0 : S[0][0]) : n, c = W(String(l)) && W(String(u));
1084
+ async parseFormula(e, r, a) {
1085
+ var d, m, _, p;
1086
+ const { formula1: i = Se, formula2: s = Ve } = e, n = await this._formulaService.getRuleFormulaResult(r, a, e.uid), l = R(i) ? ie((m = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]) : i, u = R(s) ? ie((p = (_ = n == null ? void 0 : n[1]) == null ? void 0 : _.result) == null ? void 0 : p[0][0]) : s, c = O(String(l)) && O(String(u));
1082
1087
  return {
1083
- formula1: $e(l),
1084
- formula2: $e(u),
1088
+ formula1: _e(l),
1089
+ formula2: _e(u),
1085
1090
  originFormula1: l,
1086
1091
  originFormula2: u,
1087
1092
  isFormulaValid: c
@@ -1089,700 +1094,439 @@ class yr extends de {
1089
1094
  }
1090
1095
  getExtraStyle(e, r) {
1091
1096
  return {
1092
- tb: Le.CLIP
1097
+ tb: ve.CLIP
1093
1098
  };
1094
1099
  }
1095
- parseFormulaSync(e, r, i) {
1096
- var d, m, v, S;
1097
- const { formula1: a = Be, formula2: n = Pe } = e, o = this._formulaService.getRuleFormulaResultSync(r, i, e.uid), l = F(a) ? z((m = (d = o == null ? void 0 : o[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]) : a, u = F(n) ? z((S = (v = o == null ? void 0 : o[1]) == null ? void 0 : v.result) == null ? void 0 : S[0][0]) : n, c = W(String(l)) && W(String(u));
1100
+ parseFormulaSync(e, r, a) {
1101
+ var d, m, _, p;
1102
+ const { formula1: i = Se, formula2: s = Ve } = e, n = this._formulaService.getRuleFormulaResultSync(r, a, e.uid), l = R(i) ? ie((m = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]) : i, u = R(s) ? ie((p = (_ = n == null ? void 0 : n[1]) == null ? void 0 : _.result) == null ? void 0 : p[0][0]) : s, c = O(String(l)) && O(String(u));
1098
1103
  return {
1099
- formula1: $e(l),
1100
- formula2: $e(u),
1104
+ formula1: _e(l),
1105
+ formula2: _e(u),
1101
1106
  originFormula1: l,
1102
1107
  originFormula2: u,
1103
1108
  isFormulaValid: c
1104
1109
  };
1105
1110
  }
1106
- async isValidType(e, r, i) {
1107
- const { value: a, unitId: n, subUnitId: o } = e, { formula1: l, formula2: u, originFormula1: c, originFormula2: d } = await this.parseFormula(i, n, o);
1108
- return !b.isDefine(l) || !b.isDefine(u) ? !0 : b.isDefine(a) && (String(a) === String(l) || String(a) === String(u) || String(a) === String(c != null ? c : "") || String(a) === String(d != null ? d : ""));
1111
+ async isValidType(e, r, a) {
1112
+ const { value: i, unitId: s, subUnitId: n } = e, { formula1: l, formula2: u, originFormula1: c, originFormula2: d } = await this.parseFormula(a, s, n);
1113
+ return !N.isDefine(l) || !N.isDefine(u) ? !0 : N.isDefine(i) && (String(i) === String(l) || String(i) === String(u) || String(i) === String(c != null ? c : "") || String(i) === String(d != null ? d : ""));
1109
1114
  }
1110
1115
  generateRuleErrorMessage(e) {
1111
1116
  return this.localeService.t("dataValidation.checkbox.error");
1112
1117
  }
1113
1118
  }
1114
- var Mr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
1115
- function Nr(s) {
1116
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
1117
- }
1118
- var Vt = { exports: {} };
1119
- (function(s, t) {
1120
- (function(e, r) {
1121
- s.exports = r();
1122
- })(Mr, function() {
1123
- var e = 1e3, r = 6e4, i = 36e5, a = "millisecond", n = "second", o = "minute", l = "hour", u = "day", c = "week", d = "month", m = "quarter", v = "year", S = "date", w = "Invalid Date", I = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, M = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, x = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(y) {
1124
- var f = ["th", "st", "nd", "rd"], h = y % 100;
1125
- return "[" + y + (f[(h - 20) % 10] || f[h] || f[0]) + "]";
1126
- } }, O = function(y, f, h) {
1127
- var R = String(y);
1128
- return !R || R.length >= f ? y : "" + Array(f + 1 - R.length).join(h) + y;
1129
- }, H = { s: O, z: function(y) {
1130
- var f = -y.utcOffset(), h = Math.abs(f), R = Math.floor(h / 60), p = h % 60;
1131
- return (f <= 0 ? "+" : "-") + O(R, 2, "0") + ":" + O(p, 2, "0");
1132
- }, m: function y(f, h) {
1133
- if (f.date() < h.date()) return -y(h, f);
1134
- var R = 12 * (h.year() - f.year()) + (h.month() - f.month()), p = f.clone().add(R, d), N = h - p < 0, V = f.clone().add(R + (N ? -1 : 1), d);
1135
- return +(-(R + (h - p) / (N ? p - V : V - p)) || 0);
1136
- }, a: function(y) {
1137
- return y < 0 ? Math.ceil(y) || 0 : Math.floor(y);
1138
- }, p: function(y) {
1139
- return { M: d, y: v, w: c, d: u, D: S, h: l, m: o, s: n, ms: a, Q: m }[y] || String(y || "").toLowerCase().replace(/s$/, "");
1140
- }, u: function(y) {
1141
- return y === void 0;
1142
- } }, L = "en", q = {};
1143
- q[L] = x;
1144
- var se = "$isDayjsObject", he = function(y) {
1145
- return y instanceof Re || !(!y || !y[se]);
1146
- }, ae = function y(f, h, R) {
1147
- var p;
1148
- if (!f) return L;
1149
- if (typeof f == "string") {
1150
- var N = f.toLowerCase();
1151
- q[N] && (p = N), h && (q[N] = h, p = N);
1152
- var V = f.split("-");
1153
- if (!p && V.length > 1) return y(V[0]);
1154
- } else {
1155
- var D = f.name;
1156
- q[D] = f, p = D;
1157
- }
1158
- return !R && p && (L = p), p || !R && L;
1159
- }, U = function(y, f) {
1160
- if (he(y)) return y.clone();
1161
- var h = typeof f == "object" ? f : {};
1162
- return h.date = y, h.args = arguments, new Re(h);
1163
- }, T = H;
1164
- T.l = ae, T.i = he, T.w = function(y, f) {
1165
- return U(y, { locale: f.$L, utc: f.$u, x: f.$x, $offset: f.$offset });
1166
- };
1167
- var Re = function() {
1168
- function y(h) {
1169
- this.$L = ae(h.locale, null, !0), this.parse(h), this.$x = this.$x || h.x || {}, this[se] = !0;
1170
- }
1171
- var f = y.prototype;
1172
- return f.parse = function(h) {
1173
- this.$d = function(R) {
1174
- var p = R.date, N = R.utc;
1175
- if (p === null) return /* @__PURE__ */ new Date(NaN);
1176
- if (T.u(p)) return /* @__PURE__ */ new Date();
1177
- if (p instanceof Date) return new Date(p);
1178
- if (typeof p == "string" && !/Z$/i.test(p)) {
1179
- var V = p.match(I);
1180
- if (V) {
1181
- var D = V[2] - 1 || 0, A = (V[7] || "0").substring(0, 3);
1182
- return N ? new Date(Date.UTC(V[1], D, V[3] || 1, V[4] || 0, V[5] || 0, V[6] || 0, A)) : new Date(V[1], D, V[3] || 1, V[4] || 0, V[5] || 0, V[6] || 0, A);
1183
- }
1184
- }
1185
- return new Date(p);
1186
- }(h), this.init();
1187
- }, f.init = function() {
1188
- var h = this.$d;
1189
- this.$y = h.getFullYear(), this.$M = h.getMonth(), this.$D = h.getDate(), this.$W = h.getDay(), this.$H = h.getHours(), this.$m = h.getMinutes(), this.$s = h.getSeconds(), this.$ms = h.getMilliseconds();
1190
- }, f.$utils = function() {
1191
- return T;
1192
- }, f.isValid = function() {
1193
- return this.$d.toString() !== w;
1194
- }, f.isSame = function(h, R) {
1195
- var p = U(h);
1196
- return this.startOf(R) <= p && p <= this.endOf(R);
1197
- }, f.isAfter = function(h, R) {
1198
- return U(h) < this.startOf(R);
1199
- }, f.isBefore = function(h, R) {
1200
- return this.endOf(R) < U(h);
1201
- }, f.$g = function(h, R, p) {
1202
- return T.u(h) ? this[R] : this.set(p, h);
1203
- }, f.unix = function() {
1204
- return Math.floor(this.valueOf() / 1e3);
1205
- }, f.valueOf = function() {
1206
- return this.$d.getTime();
1207
- }, f.startOf = function(h, R) {
1208
- var p = this, N = !!T.u(R) || R, V = T.p(h), D = function(fe, G) {
1209
- var ne = T.w(p.$u ? Date.UTC(p.$y, G, fe) : new Date(p.$y, G, fe), p);
1210
- return N ? ne : ne.endOf(u);
1211
- }, A = function(fe, G) {
1212
- return T.w(p.toDate()[fe].apply(p.toDate("s"), (N ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(G)), p);
1213
- }, B = this.$W, k = this.$M, J = this.$D, ye = "set" + (this.$u ? "UTC" : "");
1214
- switch (V) {
1215
- case v:
1216
- return N ? D(1, 0) : D(31, 11);
1217
- case d:
1218
- return N ? D(1, k) : D(0, k + 1);
1219
- case c:
1220
- var me = this.$locale().weekStart || 0, Te = (B < me ? B + 7 : B) - me;
1221
- return D(N ? J - Te : J + (6 - Te), k);
1222
- case u:
1223
- case S:
1224
- return A(ye + "Hours", 0);
1225
- case l:
1226
- return A(ye + "Minutes", 1);
1227
- case o:
1228
- return A(ye + "Seconds", 2);
1229
- case n:
1230
- return A(ye + "Milliseconds", 3);
1231
- default:
1232
- return this.clone();
1233
- }
1234
- }, f.endOf = function(h) {
1235
- return this.startOf(h, !1);
1236
- }, f.$set = function(h, R) {
1237
- var p, N = T.p(h), V = "set" + (this.$u ? "UTC" : ""), D = (p = {}, p[u] = V + "Date", p[S] = V + "Date", p[d] = V + "Month", p[v] = V + "FullYear", p[l] = V + "Hours", p[o] = V + "Minutes", p[n] = V + "Seconds", p[a] = V + "Milliseconds", p)[N], A = N === u ? this.$D + (R - this.$W) : R;
1238
- if (N === d || N === v) {
1239
- var B = this.clone().set(S, 1);
1240
- B.$d[D](A), B.init(), this.$d = B.set(S, Math.min(this.$D, B.daysInMonth())).$d;
1241
- } else D && this.$d[D](A);
1242
- return this.init(), this;
1243
- }, f.set = function(h, R) {
1244
- return this.clone().$set(h, R);
1245
- }, f.get = function(h) {
1246
- return this[T.p(h)]();
1247
- }, f.add = function(h, R) {
1248
- var p, N = this;
1249
- h = Number(h);
1250
- var V = T.p(R), D = function(k) {
1251
- var J = U(N);
1252
- return T.w(J.date(J.date() + Math.round(k * h)), N);
1253
- };
1254
- if (V === d) return this.set(d, this.$M + h);
1255
- if (V === v) return this.set(v, this.$y + h);
1256
- if (V === u) return D(1);
1257
- if (V === c) return D(7);
1258
- var A = (p = {}, p[o] = r, p[l] = i, p[n] = e, p)[V] || 1, B = this.$d.getTime() + h * A;
1259
- return T.w(B, this);
1260
- }, f.subtract = function(h, R) {
1261
- return this.add(-1 * h, R);
1262
- }, f.format = function(h) {
1263
- var R = this, p = this.$locale();
1264
- if (!this.isValid()) return p.invalidDate || w;
1265
- var N = h || "YYYY-MM-DDTHH:mm:ssZ", V = T.z(this), D = this.$H, A = this.$m, B = this.$M, k = p.weekdays, J = p.months, ye = p.meridiem, me = function(G, ne, Fe, be) {
1266
- return G && (G[ne] || G(R, N)) || Fe[ne].slice(0, be);
1267
- }, Te = function(G) {
1268
- return T.s(D % 12 || 12, G, "0");
1269
- }, fe = ye || function(G, ne, Fe) {
1270
- var be = G < 12 ? "AM" : "PM";
1271
- return Fe ? be.toLowerCase() : be;
1272
- };
1273
- return N.replace(M, function(G, ne) {
1274
- return ne || function(Fe) {
1275
- switch (Fe) {
1276
- case "YY":
1277
- return String(R.$y).slice(-2);
1278
- case "YYYY":
1279
- return T.s(R.$y, 4, "0");
1280
- case "M":
1281
- return B + 1;
1282
- case "MM":
1283
- return T.s(B + 1, 2, "0");
1284
- case "MMM":
1285
- return me(p.monthsShort, B, J, 3);
1286
- case "MMMM":
1287
- return me(J, B);
1288
- case "D":
1289
- return R.$D;
1290
- case "DD":
1291
- return T.s(R.$D, 2, "0");
1292
- case "d":
1293
- return String(R.$W);
1294
- case "dd":
1295
- return me(p.weekdaysMin, R.$W, k, 2);
1296
- case "ddd":
1297
- return me(p.weekdaysShort, R.$W, k, 3);
1298
- case "dddd":
1299
- return k[R.$W];
1300
- case "H":
1301
- return String(D);
1302
- case "HH":
1303
- return T.s(D, 2, "0");
1304
- case "h":
1305
- return Te(1);
1306
- case "hh":
1307
- return Te(2);
1308
- case "a":
1309
- return fe(D, A, !0);
1310
- case "A":
1311
- return fe(D, A, !1);
1312
- case "m":
1313
- return String(A);
1314
- case "mm":
1315
- return T.s(A, 2, "0");
1316
- case "s":
1317
- return String(R.$s);
1318
- case "ss":
1319
- return T.s(R.$s, 2, "0");
1320
- case "SSS":
1321
- return T.s(R.$ms, 3, "0");
1322
- case "Z":
1323
- return V;
1324
- }
1325
- return null;
1326
- }(G) || V.replace(":", "");
1327
- });
1328
- }, f.utcOffset = function() {
1329
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
1330
- }, f.diff = function(h, R, p) {
1331
- var N, V = this, D = T.p(R), A = U(h), B = (A.utcOffset() - this.utcOffset()) * r, k = this - A, J = function() {
1332
- return T.m(V, A);
1333
- };
1334
- switch (D) {
1335
- case v:
1336
- N = J() / 12;
1337
- break;
1338
- case d:
1339
- N = J();
1340
- break;
1341
- case m:
1342
- N = J() / 3;
1343
- break;
1344
- case c:
1345
- N = (k - B) / 6048e5;
1346
- break;
1347
- case u:
1348
- N = (k - B) / 864e5;
1349
- break;
1350
- case l:
1351
- N = k / i;
1352
- break;
1353
- case o:
1354
- N = k / r;
1355
- break;
1356
- case n:
1357
- N = k / e;
1358
- break;
1359
- default:
1360
- N = k;
1361
- }
1362
- return p ? N : T.a(N);
1363
- }, f.daysInMonth = function() {
1364
- return this.endOf(d).$D;
1365
- }, f.$locale = function() {
1366
- return q[this.$L];
1367
- }, f.locale = function(h, R) {
1368
- if (!h) return this.$L;
1369
- var p = this.clone(), N = ae(h, R, !0);
1370
- return N && (p.$L = N), p;
1371
- }, f.clone = function() {
1372
- return T.w(this.$d, this);
1373
- }, f.toDate = function() {
1374
- return new Date(this.valueOf());
1375
- }, f.toJSON = function() {
1376
- return this.isValid() ? this.toISOString() : null;
1377
- }, f.toISOString = function() {
1378
- return this.$d.toISOString();
1379
- }, f.toString = function() {
1380
- return this.$d.toUTCString();
1381
- }, y;
1382
- }(), Oe = Re.prototype;
1383
- return U.prototype = Oe, [["$ms", a], ["$s", n], ["$m", o], ["$H", l], ["$W", u], ["$M", d], ["$y", v], ["$D", S]].forEach(function(y) {
1384
- Oe[y[1]] = function(f) {
1385
- return this.$g(f, y[0], y[1]);
1386
- };
1387
- }), U.extend = function(y, f) {
1388
- return y.$i || (y(f, Re, U), y.$i = !0), U;
1389
- }, U.locale = ae, U.isDayjs = he, U.unix = function(y) {
1390
- return U(1e3 * y);
1391
- }, U.en = q[L], U.Ls = q, U.p = {}, U;
1392
- });
1393
- })(Vt);
1394
- var Vr = Vt.exports;
1395
- const wt = /* @__PURE__ */ Nr(Vr), wr = {
1396
- [_.BETWEEN]: "dataValidation.date.operators.between",
1397
- [_.EQUAL]: "dataValidation.date.operators.equal",
1398
- [_.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
1399
- [_.GREATER_THAN_OR_EQUAL]: "dataValidation.date.operators.greaterThanOrEqual",
1400
- [_.LESS_THAN]: "dataValidation.date.operators.lessThan",
1401
- [_.LESS_THAN_OR_EQUAL]: "dataValidation.date.operators.lessThanOrEqual",
1402
- [_.NOT_BETWEEN]: "dataValidation.date.operators.notBetween",
1403
- [_.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
1119
+ const dr = {
1120
+ [h.BETWEEN]: "dataValidation.date.operators.between",
1121
+ [h.EQUAL]: "dataValidation.date.operators.equal",
1122
+ [h.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
1123
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.operators.greaterThanOrEqual",
1124
+ [h.LESS_THAN]: "dataValidation.date.operators.lessThan",
1125
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.date.operators.lessThanOrEqual",
1126
+ [h.NOT_BETWEEN]: "dataValidation.date.operators.notBetween",
1127
+ [h.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
1404
1128
  };
1405
- _.BETWEEN + "", _.EQUAL + "", _.GREATER_THAN + "", _.GREATER_THAN_OR_EQUAL + "", _.LESS_THAN + "", _.LESS_THAN_OR_EQUAL + "", _.NOT_BETWEEN + "", _.NOT_EQUAL + "";
1406
- const Tr = {
1407
- [_.BETWEEN]: "dataValidation.date.ruleName.between",
1408
- [_.EQUAL]: "dataValidation.date.ruleName.equal",
1409
- [_.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
1410
- [_.GREATER_THAN_OR_EQUAL]: "dataValidation.date.ruleName.greaterThanOrEqual",
1411
- [_.LESS_THAN]: "dataValidation.date.ruleName.lessThan",
1412
- [_.LESS_THAN_OR_EQUAL]: "dataValidation.date.ruleName.lessThanOrEqual",
1413
- [_.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
1414
- [_.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual"
1415
- }, Fr = {
1416
- [_.BETWEEN]: "dataValidation.date.errorMsg.between",
1417
- [_.EQUAL]: "dataValidation.date.errorMsg.equal",
1418
- [_.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
1419
- [_.GREATER_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.greaterThanOrEqual",
1420
- [_.LESS_THAN]: "dataValidation.date.errorMsg.lessThan",
1421
- [_.LESS_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.lessThanOrEqual",
1422
- [_.NOT_BETWEEN]: "dataValidation.date.errorMsg.notBetween",
1423
- [_.NOT_EQUAL]: "dataValidation.date.errorMsg.notEqual"
1424
- }, Xe = [
1425
- _.BETWEEN,
1426
- _.NOT_BETWEEN
1427
- ], _t = "{FORMULA1}", pt = "{FORMULA2}", Ee = (s) => {
1129
+ h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
1130
+ const hr = {
1131
+ [h.BETWEEN]: "dataValidation.date.ruleName.between",
1132
+ [h.EQUAL]: "dataValidation.date.ruleName.equal",
1133
+ [h.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
1134
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.ruleName.greaterThanOrEqual",
1135
+ [h.LESS_THAN]: "dataValidation.date.ruleName.lessThan",
1136
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.date.ruleName.lessThanOrEqual",
1137
+ [h.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
1138
+ [h.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual"
1139
+ }, mr = {
1140
+ [h.BETWEEN]: "dataValidation.date.errorMsg.between",
1141
+ [h.EQUAL]: "dataValidation.date.errorMsg.equal",
1142
+ [h.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
1143
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.greaterThanOrEqual",
1144
+ [h.LESS_THAN]: "dataValidation.date.errorMsg.lessThan",
1145
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.lessThanOrEqual",
1146
+ [h.NOT_BETWEEN]: "dataValidation.date.errorMsg.notBetween",
1147
+ [h.NOT_EQUAL]: "dataValidation.date.errorMsg.notEqual"
1148
+ }, be = [
1149
+ h.BETWEEN,
1150
+ h.NOT_BETWEEN
1151
+ ], oe = "{FORMULA1}", ne = "{FORMULA2}";
1152
+ function la(o) {
1153
+ return o.filter(Boolean).join(",");
1154
+ }
1155
+ function pe(o) {
1156
+ return o.split(",").filter(Boolean);
1157
+ }
1158
+ function ua(o) {
1159
+ const t = ae(o);
1160
+ return t == null ? "" : t.toString();
1161
+ }
1162
+ function Ie(o, t, e) {
1163
+ const { formula1: r, formula2: a } = t, i = t.ranges[0].startRow, s = t.ranges[0].startColumn, n = e.row - i, l = e.col - s, u = R(r) ? o.moveFormulaRefOffset(r, l, n, !0) : r, c = R(a) ? o.moveFormulaRefOffset(a, l, n, !0) : a;
1164
+ return {
1165
+ transformedFormula1: u,
1166
+ transformedFormula2: c
1167
+ };
1168
+ }
1169
+ const Be = (o) => {
1428
1170
  var e, r;
1429
- if (s == null || typeof s == "boolean")
1171
+ if (o == null || typeof o == "boolean")
1430
1172
  return;
1431
- if (typeof s == "number" || !Number.isNaN(+s))
1432
- return +s;
1433
- const t = (e = oe.parseDate(s)) == null ? void 0 : e.v;
1434
- return b.isDefine(t) ? t : (r = oe.parseDate(wt(s).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : r.v;
1173
+ if (typeof o == "number" || !Number.isNaN(+o))
1174
+ return +o;
1175
+ const t = (e = k.parseDate(o)) == null ? void 0 : e.v;
1176
+ return N.isDefine(t) ? t : (r = k.parseDate(it(o).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : r.v;
1435
1177
  };
1436
- class Er extends de {
1178
+ class fr extends q {
1437
1179
  constructor() {
1438
1180
  super(...arguments);
1439
- g(this, "id", $.DATE);
1440
- g(this, "title", "dataValidation.date.title");
1441
- g(this, "operators", [
1442
- _.BETWEEN,
1443
- _.EQUAL,
1444
- _.GREATER_THAN,
1445
- _.GREATER_THAN_OR_EQUAL,
1446
- _.LESS_THAN,
1447
- _.LESS_THAN_OR_EQUAL,
1448
- _.NOT_BETWEEN,
1449
- _.NOT_EQUAL
1181
+ f(this, "id", M.DATE);
1182
+ f(this, "title", "dataValidation.date.title");
1183
+ f(this, "operators", [
1184
+ h.BETWEEN,
1185
+ h.EQUAL,
1186
+ h.GREATER_THAN,
1187
+ h.GREATER_THAN_OR_EQUAL,
1188
+ h.LESS_THAN,
1189
+ h.LESS_THAN_OR_EQUAL,
1190
+ h.NOT_BETWEEN,
1191
+ h.NOT_EQUAL
1450
1192
  ]);
1451
- g(this, "scopes", ["sheet"]);
1452
- g(this, "_formulaService", this.injector.get(te));
1453
- }
1454
- async parseFormula(e, r, i) {
1455
- var d, m, v, S;
1456
- const a = await this._formulaService.getRuleFormulaResult(r, i, e.uid), { formula1: n, formula2: o } = e, l = z((m = (d = a == null ? void 0 : a[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]), u = z((S = (v = a == null ? void 0 : a[1]) == null ? void 0 : v.result) == null ? void 0 : S[0][0]), c = W(String(l)) && W(String(u));
1457
- return {
1458
- formula1: Ee(F(n) ? l : n),
1459
- formula2: Ee(F(o) ? u : o),
1460
- isFormulaValid: c
1461
- };
1193
+ f(this, "scopes", ["sheet"]);
1194
+ f(this, "_customFormulaService", this.injector.get($));
1195
+ f(this, "_lexerTreeBuilder", this.injector.get(Z));
1462
1196
  }
1463
- parseFormulaSync(e, r, i) {
1464
- var l, u, c, d;
1465
- const a = this._formulaService.getRuleFormulaResultSync(r, i, e.uid), { formula1: n, formula2: o } = e;
1197
+ async parseFormula(e, r, a, i, s) {
1198
+ const n = await this._customFormulaService.getCellFormulaValue(r, a, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(r, a, e.uid, i, s), { formula1: u, formula2: c } = e, d = O(String(n == null ? void 0 : n.v)) && O(String(l == null ? void 0 : l.v));
1466
1199
  return {
1467
- formula1: Ee(F(n) ? z((u = (l = a == null ? void 0 : a[0]) == null ? void 0 : l.result) == null ? void 0 : u[0][0]) : n),
1468
- formula2: Ee(F(o) ? z((d = (c = a == null ? void 0 : a[1]) == null ? void 0 : c.result) == null ? void 0 : d[0][0]) : o)
1200
+ formula1: Be(R(u) ? n == null ? void 0 : n.v : u),
1201
+ formula2: Be(R(c) ? l == null ? void 0 : l.v : c),
1202
+ isFormulaValid: d
1469
1203
  };
1470
1204
  }
1471
1205
  async isValidType(e) {
1472
- const { interceptValue: r, value: i } = e;
1473
- return typeof i == "number" && typeof r == "string" ? !0 : typeof r == "string" ? !!oe.parseDate(r) : !1;
1206
+ const { interceptValue: r, value: a } = e;
1207
+ return typeof a == "number" && typeof r == "string" ? !0 : typeof r == "string" ? !!k.parseDate(r) : !1;
1474
1208
  }
1475
1209
  _validatorSingleFormula(e) {
1476
- return !b.isBlank(e) && (F(e) || !Number.isNaN(+e) || !!(e && oe.parseDate(e)));
1210
+ return !N.isBlank(e) && (R(e) || !Number.isNaN(+e) || !!(e && k.parseDate(e)));
1477
1211
  }
1478
- validatorFormula(e, r, i) {
1479
- const a = e.operator;
1480
- if (!a)
1212
+ validatorFormula(e, r, a) {
1213
+ const i = e.operator;
1214
+ if (!i)
1481
1215
  return {
1482
1216
  success: !1
1483
1217
  };
1484
- const n = this._validatorSingleFormula(e.formula1), o = this.localeService.t("dataValidation.validFail.date");
1485
- if (Xe.includes(a)) {
1218
+ const s = this._validatorSingleFormula(e.formula1), n = this.localeService.t("dataValidation.validFail.date");
1219
+ if (be.includes(i)) {
1486
1220
  const u = this._validatorSingleFormula(e.formula2);
1487
1221
  return {
1488
- success: n && u,
1489
- formula1: n ? void 0 : o,
1490
- formula2: u ? void 0 : o
1222
+ success: s && u,
1223
+ formula1: s ? void 0 : n,
1224
+ formula2: u ? void 0 : n
1491
1225
  };
1492
1226
  }
1493
1227
  return {
1494
- success: n,
1495
- formula1: n ? void 0 : o
1228
+ success: s,
1229
+ formula1: s ? void 0 : n
1496
1230
  };
1497
1231
  }
1498
- normalizeFormula(e, r, i) {
1499
- const { formula1: a, formula2: n, bizInfo: o } = e, l = (u) => {
1232
+ normalizeFormula(e, r, a) {
1233
+ const { formula1: i, formula2: s, bizInfo: n } = e, l = (u) => {
1500
1234
  var d;
1501
1235
  if (!u)
1502
1236
  return u;
1503
1237
  let c;
1504
1238
  if (!Number.isNaN(+u))
1505
- c = oe.dateFromSerial(+u);
1239
+ c = k.dateFromSerial(+u);
1506
1240
  else {
1507
- const m = (d = oe.parseDate(u)) == null ? void 0 : d.v;
1241
+ const m = (d = k.parseDate(u)) == null ? void 0 : d.v;
1508
1242
  if (m == null)
1509
1243
  return "";
1510
- c = oe.dateFromSerial(m);
1244
+ c = k.dateFromSerial(m);
1511
1245
  }
1512
- return wt(`${c[0]}/${c[1]}/${c[2]} ${c[3]}:${c[4]}:${c[5]}`).format(o != null && o.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
1246
+ return it(`${c[0]}/${c[1]}/${c[2]} ${c[3]}:${c[4]}:${c[5]}`).format(n != null && n.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
1513
1247
  };
1514
1248
  return {
1515
- formula1: F(a) ? a : l(`${a}`),
1516
- formula2: F(n) ? n : l(`${n}`)
1249
+ formula1: R(i) ? i : l(`${i}`),
1250
+ formula2: R(s) ? s : l(`${s}`)
1517
1251
  };
1518
1252
  }
1519
- transform(e, r, i) {
1520
- const { value: a } = e;
1253
+ transform(e, r, a) {
1254
+ const { value: i } = e;
1521
1255
  return {
1522
1256
  ...e,
1523
- value: Ee(a)
1257
+ value: Be(i)
1524
1258
  };
1525
1259
  }
1526
- async validatorIsEqual(e, r, i) {
1527
- const { formula1: a } = r, { value: n } = e;
1528
- return Number.isNaN(a) ? !0 : n === a;
1260
+ async validatorIsEqual(e, r, a) {
1261
+ const { formula1: i } = r, { value: s } = e;
1262
+ return Number.isNaN(i) ? !0 : s === i;
1529
1263
  }
1530
- async validatorIsNotEqual(e, r, i) {
1531
- const { formula1: a } = r;
1532
- return Number.isNaN(a) ? !0 : e.value !== a;
1264
+ async validatorIsNotEqual(e, r, a) {
1265
+ const { formula1: i } = r;
1266
+ return Number.isNaN(i) ? !0 : e.value !== i;
1533
1267
  }
1534
- async validatorIsBetween(e, r, i) {
1535
- const { formula1: a, formula2: n } = r;
1536
- if (Number.isNaN(a) || Number.isNaN(n))
1268
+ async validatorIsBetween(e, r, a) {
1269
+ const { formula1: i, formula2: s } = r;
1270
+ if (Number.isNaN(i) || Number.isNaN(s))
1537
1271
  return !0;
1538
- const o = Math.min(a, n), l = Math.max(a, n);
1539
- return e.value >= o && e.value <= l;
1272
+ const n = Math.min(i, s), l = Math.max(i, s);
1273
+ return e.value >= n && e.value <= l;
1540
1274
  }
1541
- async validatorIsNotBetween(e, r, i) {
1542
- const { formula1: a, formula2: n } = r;
1543
- if (Number.isNaN(a) || Number.isNaN(n))
1275
+ async validatorIsNotBetween(e, r, a) {
1276
+ const { formula1: i, formula2: s } = r;
1277
+ if (Number.isNaN(i) || Number.isNaN(s))
1544
1278
  return !0;
1545
- const o = Math.min(a, n), l = Math.max(a, n);
1546
- return e.value < o || e.value > l;
1279
+ const n = Math.min(i, s), l = Math.max(i, s);
1280
+ return e.value < n || e.value > l;
1547
1281
  }
1548
- async validatorIsGreaterThan(e, r, i) {
1549
- const { formula1: a } = r;
1550
- return Number.isNaN(a) ? !0 : e.value > a;
1282
+ async validatorIsGreaterThan(e, r, a) {
1283
+ const { formula1: i } = r;
1284
+ return Number.isNaN(i) ? !0 : e.value > i;
1551
1285
  }
1552
- async validatorIsGreaterThanOrEqual(e, r, i) {
1553
- const { formula1: a } = r;
1554
- return Number.isNaN(a) ? !0 : e.value >= a;
1286
+ async validatorIsGreaterThanOrEqual(e, r, a) {
1287
+ const { formula1: i } = r;
1288
+ return Number.isNaN(i) ? !0 : e.value >= i;
1555
1289
  }
1556
- async validatorIsLessThan(e, r, i) {
1557
- const { formula1: a } = r;
1558
- return Number.isNaN(a) ? !0 : e.value < a;
1290
+ async validatorIsLessThan(e, r, a) {
1291
+ const { formula1: i } = r;
1292
+ return Number.isNaN(i) ? !0 : e.value < i;
1559
1293
  }
1560
- async validatorIsLessThanOrEqual(e, r, i) {
1561
- const { formula1: a } = r;
1562
- return Number.isNaN(a) ? !0 : e.value <= a;
1294
+ async validatorIsLessThanOrEqual(e, r, a) {
1295
+ const { formula1: i } = r;
1296
+ return Number.isNaN(i) ? !0 : e.value <= i;
1563
1297
  }
1564
1298
  get operatorNames() {
1565
- return this.operators.map((e) => this.localeService.t(wr[e]));
1299
+ return this.operators.map((e) => this.localeService.t(dr[e]));
1566
1300
  }
1567
1301
  generateRuleName(e) {
1568
- var i, a;
1302
+ var a, i;
1569
1303
  if (!e.operator)
1570
1304
  return this.titleStr;
1571
- const r = this.localeService.t(Tr[e.operator]).replace(_t, (i = e.formula1) != null ? i : "").replace(pt, (a = e.formula2) != null ? a : "");
1305
+ const r = this.localeService.t(hr[e.operator]).replace(oe, (a = e.formula1) != null ? a : "").replace(ne, (i = e.formula2) != null ? i : "");
1572
1306
  return `${this.titleStr} ${r}`;
1573
1307
  }
1574
- generateRuleErrorMessage(e) {
1575
- var i, a;
1576
- return e.operator ? `${this.localeService.t(Fr[e.operator]).replace(_t, (i = e.formula1) != null ? i : "").replace(pt, (a = e.formula2) != null ? a : "")}` : this.titleStr;
1308
+ generateRuleErrorMessage(e, r) {
1309
+ if (!e.operator)
1310
+ return this.titleStr;
1311
+ const { transformedFormula1: a, transformedFormula2: i } = Ie(this._lexerTreeBuilder, e, r);
1312
+ return `${this.localeService.t(mr[e.operator]).replace(oe, a != null ? a : "").replace(ne, i != null ? i : "")}`;
1577
1313
  }
1578
1314
  }
1579
- function He(s) {
1580
- let t = s;
1581
- return typeof s == "string" ? ((s.startsWith("¥") || s.startsWith("$")) && (t = s.slice(1)), +t) : +s;
1315
+ h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
1316
+ h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
1317
+ const ht = {
1318
+ [h.BETWEEN]: "dataValidation.errorMsg.between",
1319
+ [h.EQUAL]: "dataValidation.errorMsg.equal",
1320
+ [h.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
1321
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
1322
+ [h.LESS_THAN]: "dataValidation.errorMsg.lessThan",
1323
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
1324
+ [h.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
1325
+ [h.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
1326
+ };
1327
+ function Ne(o) {
1328
+ let t = o;
1329
+ return typeof o == "string" ? ((o.startsWith("¥") || o.startsWith("$")) && (t = o.slice(1)), +t) : +o;
1582
1330
  }
1583
- class Cr extends de {
1331
+ class _r extends q {
1584
1332
  constructor() {
1585
1333
  super(...arguments);
1586
- g(this, "_formulaService", this.injector.get(te));
1587
- g(this, "id", $.DECIMAL);
1588
- g(this, "title", "dataValidation.decimal.title");
1589
- g(this, "operators", [
1590
- _.BETWEEN,
1591
- _.EQUAL,
1592
- _.GREATER_THAN,
1593
- _.GREATER_THAN_OR_EQUAL,
1594
- _.LESS_THAN,
1595
- _.LESS_THAN_OR_EQUAL,
1596
- _.NOT_BETWEEN,
1597
- _.NOT_EQUAL
1334
+ f(this, "_customFormulaService", this.injector.get($));
1335
+ f(this, "id", M.DECIMAL);
1336
+ f(this, "_lexerTreeBuilder", this.injector.get(Z));
1337
+ f(this, "title", "dataValidation.decimal.title");
1338
+ f(this, "operators", [
1339
+ h.BETWEEN,
1340
+ h.EQUAL,
1341
+ h.GREATER_THAN,
1342
+ h.GREATER_THAN_OR_EQUAL,
1343
+ h.LESS_THAN,
1344
+ h.LESS_THAN_OR_EQUAL,
1345
+ h.NOT_BETWEEN,
1346
+ h.NOT_EQUAL
1598
1347
  ]);
1599
- g(this, "scopes", ["sheet"]);
1348
+ f(this, "scopes", ["sheet"]);
1600
1349
  }
1601
1350
  _isFormulaOrNumber(e) {
1602
- return !b.isBlank(e) && (F(e) || !Number.isNaN(+e));
1351
+ return !N.isBlank(e) && (R(e) || !Number.isNaN(+e));
1603
1352
  }
1604
- async isValidType(e, r, i) {
1605
- const { value: a } = e;
1606
- return !Number.isNaN(He(a));
1353
+ async isValidType(e, r, a) {
1354
+ const { value: i } = e;
1355
+ return !Number.isNaN(Ne(i));
1607
1356
  }
1608
- transform(e, r, i) {
1609
- const { value: a } = e;
1357
+ transform(e, r, a) {
1358
+ const { value: i } = e;
1610
1359
  return {
1611
1360
  ...e,
1612
- value: He(a)
1361
+ value: Ne(i)
1613
1362
  };
1614
1363
  }
1615
1364
  _parseNumber(e) {
1616
1365
  return e == null ? Number.NaN : +e;
1617
1366
  }
1618
- async parseFormula(e, r, i) {
1619
- var m, v, S, w;
1620
- const a = await this._formulaService.getRuleFormulaResult(r, i, e.uid), { formula1: n, formula2: o } = e, l = z((v = (m = a == null ? void 0 : a[0]) == null ? void 0 : m.result) == null ? void 0 : v[0][0]), u = z((w = (S = a == null ? void 0 : a[1]) == null ? void 0 : S.result) == null ? void 0 : w[0][0]), c = W(String(l)) && W(String(u));
1367
+ async parseFormula(e, r, a, i, s) {
1368
+ const n = await this._customFormulaService.getCellFormulaValue(r, a, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(r, a, e.uid, i, s), { formula1: u, formula2: c } = e, d = O(String(n == null ? void 0 : n.v)) && O(String(l == null ? void 0 : l.v));
1621
1369
  return {
1622
- formula1: this._parseNumber(F(n) ? l : n),
1623
- formula2: this._parseNumber(F(o) ? u : o),
1624
- isFormulaValid: c
1370
+ formula1: this._parseNumber(R(u) ? n == null ? void 0 : n.v : u),
1371
+ formula2: this._parseNumber(R(c) ? l == null ? void 0 : l.v : c),
1372
+ isFormulaValid: d
1625
1373
  };
1626
1374
  }
1627
- validatorFormula(e, r, i) {
1628
- const a = e.operator;
1629
- if (!a)
1375
+ validatorFormula(e, r, a) {
1376
+ const i = e.operator;
1377
+ if (!i)
1630
1378
  return {
1631
1379
  success: !1
1632
1380
  };
1633
- const n = b.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), o = b.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = Xe.includes(a), u = this.localeService.t("dataValidation.validFail.number");
1381
+ const s = N.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), n = N.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
1634
1382
  return l ? {
1635
- success: n && o,
1636
- formula1: n ? void 0 : u,
1637
- formula2: o ? void 0 : u
1383
+ success: s && n,
1384
+ formula1: s ? void 0 : u,
1385
+ formula2: n ? void 0 : u
1638
1386
  } : {
1639
- success: n,
1640
- formula1: n ? "" : u
1387
+ success: s,
1388
+ formula1: s ? "" : u
1641
1389
  };
1642
1390
  }
1643
- async validatorIsEqual(e, r, i) {
1644
- const { formula1: a } = r, { value: n } = e;
1645
- return Number.isNaN(a) ? !0 : n === a;
1391
+ async validatorIsEqual(e, r, a) {
1392
+ const { formula1: i } = r, { value: s } = e;
1393
+ return Number.isNaN(i) ? !0 : s === i;
1646
1394
  }
1647
- async validatorIsNotEqual(e, r, i) {
1648
- const { formula1: a } = r;
1649
- return Number.isNaN(a) ? !0 : e.value !== a;
1395
+ async validatorIsNotEqual(e, r, a) {
1396
+ const { formula1: i } = r;
1397
+ return Number.isNaN(i) ? !0 : e.value !== i;
1650
1398
  }
1651
- async validatorIsBetween(e, r, i) {
1652
- const { formula1: a, formula2: n } = r;
1653
- if (Number.isNaN(a) || Number.isNaN(n))
1399
+ async validatorIsBetween(e, r, a) {
1400
+ const { formula1: i, formula2: s } = r;
1401
+ if (Number.isNaN(i) || Number.isNaN(s))
1654
1402
  return !0;
1655
- const o = Math.min(a, n), l = Math.max(a, n);
1656
- return e.value >= o && e.value <= l;
1403
+ const n = Math.min(i, s), l = Math.max(i, s);
1404
+ return e.value >= n && e.value <= l;
1657
1405
  }
1658
- async validatorIsNotBetween(e, r, i) {
1659
- const { formula1: a, formula2: n } = r;
1660
- if (Number.isNaN(a) || Number.isNaN(n))
1406
+ async validatorIsNotBetween(e, r, a) {
1407
+ const { formula1: i, formula2: s } = r;
1408
+ if (Number.isNaN(i) || Number.isNaN(s))
1661
1409
  return !0;
1662
- const o = Math.min(a, n), l = Math.max(a, n);
1663
- return e.value < o || e.value > l;
1410
+ const n = Math.min(i, s), l = Math.max(i, s);
1411
+ return e.value < n || e.value > l;
1664
1412
  }
1665
- async validatorIsGreaterThan(e, r, i) {
1666
- const { formula1: a } = r;
1667
- return Number.isNaN(a) ? !0 : e.value > a;
1413
+ async validatorIsGreaterThan(e, r, a) {
1414
+ const { formula1: i } = r;
1415
+ return Number.isNaN(i) ? !0 : e.value > i;
1668
1416
  }
1669
- async validatorIsGreaterThanOrEqual(e, r, i) {
1670
- const { formula1: a } = r;
1671
- return Number.isNaN(a) ? !0 : e.value >= a;
1417
+ async validatorIsGreaterThanOrEqual(e, r, a) {
1418
+ const { formula1: i } = r;
1419
+ return Number.isNaN(i) ? !0 : e.value >= i;
1672
1420
  }
1673
- async validatorIsLessThan(e, r, i) {
1674
- const { formula1: a } = r;
1675
- return Number.isNaN(a) ? !0 : e.value < a;
1421
+ async validatorIsLessThan(e, r, a) {
1422
+ const { formula1: i } = r;
1423
+ return Number.isNaN(i) ? !0 : e.value < i;
1676
1424
  }
1677
- async validatorIsLessThanOrEqual(e, r, i) {
1678
- const { formula1: a } = r;
1679
- return Number.isNaN(a) ? !0 : e.value <= a;
1425
+ async validatorIsLessThanOrEqual(e, r, a) {
1426
+ const { formula1: i } = r;
1427
+ return Number.isNaN(i) ? !0 : e.value <= i;
1428
+ }
1429
+ generateRuleErrorMessage(e, r) {
1430
+ if (!e.operator)
1431
+ return this.titleStr;
1432
+ const { transformedFormula1: a, transformedFormula2: i } = Ie(this._lexerTreeBuilder, e, r);
1433
+ return `${this.localeService.t(ht[e.operator]).replace(oe, a != null ? a : "").replace(ne, i != null ? i : "")}`;
1680
1434
  }
1681
1435
  }
1682
- function ya(s) {
1683
- return s.filter(Boolean).join(",");
1684
- }
1685
- function xe(s) {
1686
- return s.split(",").filter(Boolean);
1687
- }
1688
- function Ma(s) {
1689
- const t = Ve(s);
1690
- return t == null ? "" : t.toString();
1691
- }
1692
- function Ze(s) {
1693
- if (!s)
1436
+ function Pe(o) {
1437
+ if (!o)
1694
1438
  return [];
1695
1439
  const t = /* @__PURE__ */ new Set();
1696
- return s.forEach(
1440
+ return o.forEach(
1697
1441
  (e) => {
1698
1442
  e.forEach((r) => {
1699
- var a, n;
1700
- const i = Ve(r);
1701
- if (i != null) {
1702
- if (typeof i != "string" && typeof (r == null ? void 0 : r.s) == "object" && ((n = (a = r.s) == null ? void 0 : a.n) != null && n.pattern)) {
1703
- t.add(oe.format(r.s.n.pattern, i, { throws: !1 }));
1443
+ var i, s;
1444
+ const a = ae(r);
1445
+ if (a != null) {
1446
+ if (typeof a != "string" && typeof (r == null ? void 0 : r.s) == "object" && ((s = (i = r.s) == null ? void 0 : i.n) != null && s.pattern)) {
1447
+ t.add(k.format(r.s.n.pattern, a, { throws: !1 }));
1704
1448
  return;
1705
1449
  }
1706
- W(i.toString()) && t.add(i.toString());
1450
+ O(a.toString()) && t.add(a.toString());
1707
1451
  }
1708
1452
  });
1709
1453
  }
1710
1454
  ), [...t];
1711
1455
  }
1712
- const Or = [
1456
+ const pr = [
1713
1457
  "if",
1714
1458
  "indirect",
1715
1459
  "choose",
1716
1460
  "offset"
1717
1461
  ];
1718
- function br(s, t) {
1719
- if (!F(s) || Mt(s.slice(1)))
1462
+ function gr(o, t) {
1463
+ if (!R(o) || ct(o.slice(1)))
1720
1464
  return !0;
1721
- const r = t.sequenceNodesBuilder(s);
1722
- return r && r.some((i) => typeof i == "object" && i.nodeType === rr.FUNCTION && Or.indexOf(i.token.toLowerCase()) > -1);
1465
+ const r = t.sequenceNodesBuilder(o);
1466
+ return r && r.some((a) => typeof a == "object" && a.nodeType === Gt.FUNCTION && pr.indexOf(a.token.toLowerCase()) > -1);
1723
1467
  }
1724
- function Dr(s, t) {
1725
- const { formula1: e = "", ranges: r } = s;
1726
- if (Mt(e.slice(1))) {
1727
- const a = ar(e.slice(1));
1728
- if ((!a.sheetName || a.sheetName === t) && r.some((n) => ee.intersects(n, a.range)))
1468
+ function vr(o, t) {
1469
+ const { formula1: e = "", ranges: r } = o;
1470
+ if (ct(e.slice(1))) {
1471
+ const i = Qt(e.slice(1));
1472
+ if ((!i.sheetName || i.sheetName === t) && r.some((s) => B.intersects(s, i.range)))
1729
1473
  return !0;
1730
1474
  }
1731
1475
  return !1;
1732
1476
  }
1733
- class Tt extends de {
1477
+ class mt extends q {
1734
1478
  constructor() {
1735
1479
  super(...arguments);
1736
- g(this, "formulaService", this.injector.get(te));
1737
- g(this, "_lexer", this.injector.get(ut));
1738
- g(this, "_univerInstanceService", this.injector.get(Z));
1739
- g(this, "id", $.LIST);
1740
- g(this, "title", "dataValidation.list.title");
1741
- g(this, "operators", []);
1742
- g(this, "scopes", ["sheet"]);
1743
- g(this, "skipDefaultFontRender", (e) => e.renderMode !== Ke.TEXT);
1744
- }
1745
- validatorFormula(e, r, i) {
1480
+ f(this, "formulaService", this.injector.get(X));
1481
+ f(this, "_lexer", this.injector.get(Z));
1482
+ f(this, "_univerInstanceService", this.injector.get(D));
1483
+ f(this, "id", M.LIST);
1484
+ f(this, "title", "dataValidation.list.title");
1485
+ f(this, "operators", []);
1486
+ f(this, "scopes", ["sheet"]);
1487
+ f(this, "skipDefaultFontRender", (e) => e.renderMode !== Le.TEXT);
1488
+ }
1489
+ validatorFormula(e, r, a) {
1746
1490
  var u, c, d;
1747
- const a = !b.isBlank(e.formula1), n = br((u = e.formula1) != null ? u : "", this._lexer), o = (d = (c = this._univerInstanceService.getUnit(r, K.UNIVER_SHEET)) == null ? void 0 : c.getSheetBySheetId(i)) == null ? void 0 : d.getName(), l = Dr(e, o != null ? o : "");
1491
+ const i = !N.isBlank(e.formula1), s = gr((u = e.formula1) != null ? u : "", this._lexer), n = (d = (c = this._univerInstanceService.getUnit(r, A.UNIVER_SHEET)) == null ? void 0 : c.getSheetBySheetId(a)) == null ? void 0 : d.getName(), l = vr(e, n != null ? n : "");
1748
1492
  return {
1749
- success: !!(a && n && !l),
1750
- formula1: a ? n ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
1493
+ success: !!(i && s && !l),
1494
+ formula1: i ? s ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
1751
1495
  };
1752
1496
  }
1753
- getExtraStyle(e, r, { style: i }) {
1754
- var n;
1755
- const a = (n = i.tb !== Le.OVERFLOW ? i.tb : Le.CLIP) != null ? n : Le.WRAP;
1756
- if (e.type === $.LIST && (e.renderMode === Ke.ARROW || e.renderMode === Ke.TEXT)) {
1757
- const o = this.getListWithColorMap(e), l = `${r != null ? r : ""}`, u = o[l];
1497
+ getExtraStyle(e, r, { style: a }) {
1498
+ var s;
1499
+ const i = (s = a.tb !== ve.OVERFLOW ? a.tb : ve.CLIP) != null ? s : ve.WRAP;
1500
+ if (e.type === M.LIST && (e.renderMode === Le.ARROW || e.renderMode === Le.TEXT)) {
1501
+ const n = this.getListWithColorMap(e), l = `${r != null ? r : ""}`, u = n[l];
1758
1502
  if (u)
1759
1503
  return {
1760
1504
  bg: {
1761
1505
  rgb: u
1762
1506
  },
1763
- tb: a
1507
+ tb: i
1764
1508
  };
1765
1509
  }
1766
1510
  return {
1767
- tb: a
1511
+ tb: i
1768
1512
  };
1769
1513
  }
1770
1514
  parseCellValue(e) {
1771
1515
  const r = e.toString();
1772
- return xe(r);
1516
+ return pe(r);
1773
1517
  }
1774
- async parseFormula(e, r, i) {
1518
+ async parseFormula(e, r, a) {
1775
1519
  var u, c, d, m;
1776
- const { formula1: a = "" } = e, n = await this.formulaService.getRuleFormulaResult(r, i, e.uid), o = z((c = (u = n == null ? void 0 : n[0]) == null ? void 0 : u.result) == null ? void 0 : c[0][0]), l = W(String(o));
1520
+ const { formula1: i = "" } = e, s = await this.formulaService.getRuleFormulaResult(r, a, e.uid), n = ie((c = (u = s == null ? void 0 : s[0]) == null ? void 0 : u.result) == null ? void 0 : c[0][0]), l = O(String(n));
1777
1521
  return {
1778
- formula1: F(a) ? Ze((m = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]) : xe(a),
1522
+ formula1: R(i) ? Pe((m = (d = s == null ? void 0 : s[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]) : pe(i),
1779
1523
  formula2: void 0,
1780
1524
  isFormulaValid: l
1781
1525
  };
1782
1526
  }
1783
- async isValidType(e, r, i) {
1784
- const { value: a } = e, { formula1: n = [] } = r;
1785
- return this.parseCellValue(a).every((l) => n.includes(l));
1527
+ async isValidType(e, r, a) {
1528
+ const { value: i } = e, { formula1: s = [] } = r;
1529
+ return this.parseCellValue(i).every((l) => s.includes(l));
1786
1530
  }
1787
1531
  generateRuleName() {
1788
1532
  return this.localeService.t("dataValidation.list.name");
@@ -1790,70 +1534,70 @@ class Tt extends de {
1790
1534
  generateRuleErrorMessage() {
1791
1535
  return this.localeService.t("dataValidation.list.error");
1792
1536
  }
1793
- getList(e, r, i) {
1794
- var m, v, S, w;
1795
- const { formula1: a = "" } = e, n = this.injector.get(Z), o = (m = r ? n.getUniverSheetInstance(r) : void 0) != null ? m : n.getCurrentUnitForType(K.UNIVER_SHEET);
1796
- if (!o) return [];
1797
- const l = (v = i ? o.getSheetBySheetId(i) : void 0) != null ? v : o.getActiveSheet();
1537
+ getList(e, r, a) {
1538
+ var m, _, p, S;
1539
+ const { formula1: i = "" } = e, s = this.injector.get(D), n = (m = r ? s.getUniverSheetInstance(r) : void 0) != null ? m : s.getCurrentUnitForType(A.UNIVER_SHEET);
1540
+ if (!n) return [];
1541
+ const l = (_ = a ? n.getSheetBySheetId(a) : void 0) != null ? _ : n.getActiveSheet();
1798
1542
  if (!l) return [];
1799
- const u = o.getUnitId(), c = l.getSheetId(), d = this.formulaService.getRuleFormulaResultSync(u, c, e.uid);
1800
- return F(a) ? Ze((w = (S = d == null ? void 0 : d[0]) == null ? void 0 : S.result) == null ? void 0 : w[0][0]) : xe(a);
1801
- }
1802
- async getListAsync(e, r, i) {
1803
- var m, v, S, w;
1804
- const { formula1: a = "" } = e, n = this.injector.get(Z), o = (m = r ? n.getUniverSheetInstance(r) : void 0) != null ? m : n.getCurrentUnitForType(K.UNIVER_SHEET);
1805
- if (!o) return [];
1806
- const l = (v = i ? o.getSheetBySheetId(i) : void 0) != null ? v : o.getActiveSheet();
1543
+ const u = n.getUnitId(), c = l.getSheetId(), d = this.formulaService.getRuleFormulaResultSync(u, c, e.uid);
1544
+ return R(i) ? Pe((S = (p = d == null ? void 0 : d[0]) == null ? void 0 : p.result) == null ? void 0 : S[0][0]) : pe(i);
1545
+ }
1546
+ async getListAsync(e, r, a) {
1547
+ var m, _, p, S;
1548
+ const { formula1: i = "" } = e, s = this.injector.get(D), n = (m = r ? s.getUniverSheetInstance(r) : void 0) != null ? m : s.getCurrentUnitForType(A.UNIVER_SHEET);
1549
+ if (!n) return [];
1550
+ const l = (_ = a ? n.getSheetBySheetId(a) : void 0) != null ? _ : n.getActiveSheet();
1807
1551
  if (!l) return [];
1808
- const u = o.getUnitId(), c = l.getSheetId(), d = await this.formulaService.getRuleFormulaResult(u, c, e.uid);
1809
- return F(a) ? Ze((w = (S = d == null ? void 0 : d[0]) == null ? void 0 : S.result) == null ? void 0 : w[0][0]) : xe(a);
1552
+ const u = n.getUnitId(), c = l.getSheetId(), d = await this.formulaService.getRuleFormulaResult(u, c, e.uid);
1553
+ return R(i) ? Pe((S = (p = d == null ? void 0 : d[0]) == null ? void 0 : p.result) == null ? void 0 : S[0][0]) : pe(i);
1810
1554
  }
1811
- getListWithColor(e, r, i) {
1812
- const a = this.getList(e, r, i), n = (e.formula2 || "").split(",");
1813
- return a.map((o, l) => ({ label: o, color: n[l] }));
1555
+ getListWithColor(e, r, a) {
1556
+ const i = this.getList(e, r, a), s = (e.formula2 || "").split(",");
1557
+ return i.map((n, l) => ({ label: n, color: s[l] }));
1814
1558
  }
1815
- getListWithColorMap(e, r, i) {
1816
- const a = this.getListWithColor(e, r, i), n = {};
1817
- return a.forEach((o) => {
1818
- o.color && (n[o.label] = o.color);
1819
- }), n;
1559
+ getListWithColorMap(e, r, a) {
1560
+ const i = this.getListWithColor(e, r, a), s = {};
1561
+ return i.forEach((n) => {
1562
+ n.color && (s[n.label] = n.color);
1563
+ }), s;
1820
1564
  }
1821
1565
  }
1822
- const Ir = "{FORMULA1}", $r = "{FORMULA2}";
1823
- class xr extends de {
1566
+ class Rr extends q {
1824
1567
  constructor() {
1825
1568
  super(...arguments);
1826
- g(this, "id", $.TEXT_LENGTH);
1827
- g(this, "title", "dataValidation.textLength.title");
1828
- g(this, "operators", [
1829
- _.BETWEEN,
1830
- _.EQUAL,
1831
- _.GREATER_THAN,
1832
- _.GREATER_THAN_OR_EQUAL,
1833
- _.LESS_THAN,
1834
- _.LESS_THAN_OR_EQUAL,
1835
- _.NOT_BETWEEN,
1836
- _.NOT_EQUAL
1569
+ f(this, "id", M.TEXT_LENGTH);
1570
+ f(this, "title", "dataValidation.textLength.title");
1571
+ f(this, "_lexerTreeBuilder", this.injector.get(Z));
1572
+ f(this, "operators", [
1573
+ h.BETWEEN,
1574
+ h.EQUAL,
1575
+ h.GREATER_THAN,
1576
+ h.GREATER_THAN_OR_EQUAL,
1577
+ h.LESS_THAN,
1578
+ h.LESS_THAN_OR_EQUAL,
1579
+ h.NOT_BETWEEN,
1580
+ h.NOT_EQUAL
1837
1581
  ]);
1838
- g(this, "scopes", ["sheet"]);
1839
- g(this, "_formulaService", this.injector.get(te));
1582
+ f(this, "scopes", ["sheet"]);
1583
+ f(this, "_customFormulaService", this.injector.get($));
1840
1584
  }
1841
1585
  _isFormulaOrInt(e) {
1842
- return !b.isBlank(e) && (F(e) || !Number.isNaN(+e) && Number.isInteger(+e));
1586
+ return !N.isBlank(e) && (R(e) || !Number.isNaN(+e) && Number.isInteger(+e));
1843
1587
  }
1844
- validatorFormula(e, r, i) {
1845
- const a = e.operator;
1846
- if (!a)
1588
+ validatorFormula(e, r, a) {
1589
+ const i = e.operator;
1590
+ if (!i)
1847
1591
  return {
1848
1592
  success: !1
1849
1593
  };
1850
- const n = b.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), o = b.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Xe.includes(a), u = this.localeService.t("dataValidation.validFail.number");
1594
+ const s = N.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = N.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
1851
1595
  return l ? {
1852
- success: n && o,
1853
- formula1: n ? void 0 : u,
1854
- formula2: o ? void 0 : u
1596
+ success: s && n,
1597
+ formula1: s ? void 0 : u,
1598
+ formula2: n ? void 0 : u
1855
1599
  } : {
1856
- success: n,
1600
+ success: s,
1857
1601
  formula1: u
1858
1602
  };
1859
1603
  }
@@ -1863,527 +1607,537 @@ class xr extends de {
1863
1607
  _isValidFormula(e) {
1864
1608
  return !Number.isNaN(e);
1865
1609
  }
1866
- async parseFormula(e, r, i) {
1867
- var d, m, v, S;
1868
- const a = await this._formulaService.getRuleFormulaResult(r, i, e.uid), { formula1: n, formula2: o } = e, l = z((m = (d = a == null ? void 0 : a[0]) == null ? void 0 : d.result) == null ? void 0 : m[0][0]), u = z((S = (v = a == null ? void 0 : a[1]) == null ? void 0 : v.result) == null ? void 0 : S[0][0]), c = W(String(l)) && W(String(u));
1610
+ async parseFormula(e, r, a, i, s) {
1611
+ const n = await this._customFormulaService.getCellFormulaValue(r, a, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(r, a, e.uid, i, s), { formula1: u, formula2: c } = e, d = O(String(n == null ? void 0 : n.v)) && O(String(l == null ? void 0 : l.v));
1869
1612
  return {
1870
- formula1: this._parseNumber(F(n) ? l : n),
1871
- formula2: this._parseNumber(F(o) ? u : o),
1872
- isFormulaValid: c
1613
+ formula1: this._parseNumber(R(u) ? n == null ? void 0 : n.v : u),
1614
+ formula2: this._parseNumber(R(c) ? l == null ? void 0 : l.v : c),
1615
+ isFormulaValid: d
1873
1616
  };
1874
1617
  }
1875
- transform(e, r, i) {
1618
+ transform(e, r, a) {
1876
1619
  return {
1877
1620
  ...e,
1878
1621
  value: e.value.toString().length
1879
1622
  };
1880
1623
  }
1881
- async isValidType(e, r, i) {
1882
- const { value: a } = e;
1883
- return typeof a == "string" || typeof a == "number";
1624
+ async isValidType(e, r, a) {
1625
+ const { value: i } = e;
1626
+ return typeof i == "string" || typeof i == "number";
1884
1627
  }
1885
- async validatorIsEqual(e, r, i) {
1886
- const { formula1: a } = r;
1887
- return b.isDefine(a) ? e.value === a : !1;
1628
+ async validatorIsEqual(e, r, a) {
1629
+ const { formula1: i } = r;
1630
+ return N.isDefine(i) ? e.value === i : !1;
1888
1631
  }
1889
- async validatorIsNotEqual(e, r, i) {
1890
- const { formula1: a } = r;
1891
- return b.isDefine(a) ? e.value !== a : !1;
1632
+ async validatorIsNotEqual(e, r, a) {
1633
+ const { formula1: i } = r;
1634
+ return N.isDefine(i) ? e.value !== i : !1;
1892
1635
  }
1893
- async validatorIsBetween(e, r, i) {
1894
- const { formula1: a, formula2: n } = r, { value: o } = e;
1895
- if (!this._isValidFormula(a) || !this._isValidFormula(n))
1636
+ async validatorIsBetween(e, r, a) {
1637
+ const { formula1: i, formula2: s } = r, { value: n } = e;
1638
+ if (!this._isValidFormula(i) || !this._isValidFormula(s))
1896
1639
  return !1;
1897
- const l = Math.max(a, n), u = Math.min(a, n);
1898
- return o >= u && o <= l;
1640
+ const l = Math.max(i, s), u = Math.min(i, s);
1641
+ return n >= u && n <= l;
1899
1642
  }
1900
- async validatorIsNotBetween(e, r, i) {
1901
- const { formula1: a, formula2: n } = r, { value: o } = e;
1902
- if (!this._isValidFormula(a) || !this._isValidFormula(n))
1643
+ async validatorIsNotBetween(e, r, a) {
1644
+ const { formula1: i, formula2: s } = r, { value: n } = e;
1645
+ if (!this._isValidFormula(i) || !this._isValidFormula(s))
1903
1646
  return !1;
1904
- const l = Math.max(a, n), u = Math.min(a, n);
1905
- return o < u || o > l;
1647
+ const l = Math.max(i, s), u = Math.min(i, s);
1648
+ return n < u || n > l;
1906
1649
  }
1907
- async validatorIsGreaterThan(e, r, i) {
1908
- const { formula1: a } = r, { value: n } = e;
1909
- return this._isValidFormula(a) ? n > a : !1;
1650
+ async validatorIsGreaterThan(e, r, a) {
1651
+ const { formula1: i } = r, { value: s } = e;
1652
+ return this._isValidFormula(i) ? s > i : !1;
1910
1653
  }
1911
- async validatorIsGreaterThanOrEqual(e, r, i) {
1912
- const { formula1: a } = r, { value: n } = e;
1913
- return this._isValidFormula(a) ? n >= a : !1;
1654
+ async validatorIsGreaterThanOrEqual(e, r, a) {
1655
+ const { formula1: i } = r, { value: s } = e;
1656
+ return this._isValidFormula(i) ? s >= i : !1;
1914
1657
  }
1915
- async validatorIsLessThan(e, r, i) {
1916
- const { formula1: a } = r, { value: n } = e;
1917
- return this._isValidFormula(a) ? n < a : !1;
1658
+ async validatorIsLessThan(e, r, a) {
1659
+ const { formula1: i } = r, { value: s } = e;
1660
+ return this._isValidFormula(i) ? s < i : !1;
1918
1661
  }
1919
- async validatorIsLessThanOrEqual(e, r, i) {
1920
- const { formula1: a } = r, { value: n } = e;
1921
- return this._isValidFormula(a) ? n <= a : !1;
1662
+ async validatorIsLessThanOrEqual(e, r, a) {
1663
+ const { formula1: i } = r, { value: s } = e;
1664
+ return this._isValidFormula(i) ? s <= i : !1;
1922
1665
  }
1923
- generateRuleErrorMessage(e) {
1924
- var i, a;
1925
- return e.operator ? `${this.localeService.t(jt[e.operator]).replace(Ir, (i = e.formula1) != null ? i : "").replace($r, (a = e.formula2) != null ? a : "")}` : this.titleStr;
1666
+ generateRuleErrorMessage(e, r) {
1667
+ if (!e.operator)
1668
+ return this.titleStr;
1669
+ const { transformedFormula1: a, transformedFormula2: i } = Ie(this._lexerTreeBuilder, e, r);
1670
+ return `${this.localeService.t(Dt[e.operator]).replace(oe, a != null ? a : "").replace(ne, i != null ? i : "")}`;
1926
1671
  }
1927
1672
  }
1928
- function Ft(s) {
1673
+ function ft(o) {
1929
1674
  var e, r;
1930
- return s ? s.p ? !((r = (e = s.p.body) == null ? void 0 : e.dataStream) != null ? r : "").slice(0, -2).trim() : b.isBlank(s.v) : !0;
1675
+ return o ? o.p ? !((r = (e = o.p.body) == null ? void 0 : e.dataStream) != null ? r : "").slice(0, -2).trim() : N.isBlank(o.v) : !0;
1931
1676
  }
1932
- function ze(s, t, e, r, i = "command", a = !0) {
1933
- const n = r.get(ut), o = [], l = [], u = r.get(j), c = r.get(Z), d = lt(c, { unitId: s, subUnitId: t });
1677
+ function Ae(o, t, e, r, a = "command", i = !0) {
1678
+ const s = r.get(Z), n = [], l = [], u = r.get(F), c = r.get(D), d = Ye(c, { unitId: o, subUnitId: t });
1934
1679
  if (!d)
1935
1680
  return {
1936
- redoMutations: o,
1681
+ redoMutations: n,
1937
1682
  undoMutations: l
1938
1683
  };
1939
- const { worksheet: m } = d, v = new Ue();
1940
- function S(M, x) {
1941
- a && M.forEach((O) => {
1942
- Q.foreach(O, (H, L) => {
1943
- const q = m.getCellRaw(H, L), se = Nt(q);
1944
- (Ft(q) || se === x) && v.setValue(H, L, {
1945
- v: x,
1684
+ const { worksheet: m } = d, _ = new Re();
1685
+ function p(g, C) {
1686
+ i && g.forEach((E) => {
1687
+ I.foreach(E, (x, L) => {
1688
+ const J = m.getCellRaw(x, L), ee = dt(J);
1689
+ (ft(J) || ee === C) && _.setValue(x, L, {
1690
+ v: C,
1946
1691
  p: null
1947
1692
  });
1948
1693
  });
1949
1694
  });
1950
1695
  }
1951
- e.forEach((M) => {
1952
- switch (M.type) {
1696
+ e.forEach((g) => {
1697
+ switch (g.type) {
1953
1698
  case "delete":
1954
- o.push({
1955
- id: ie.id,
1699
+ n.push({
1700
+ id: P.id,
1956
1701
  params: {
1957
- unitId: s,
1702
+ unitId: o,
1958
1703
  subUnitId: t,
1959
- ruleId: M.rule.uid,
1960
- source: i
1704
+ ruleId: g.rule.uid,
1705
+ source: a
1961
1706
  }
1962
1707
  }), l.unshift({
1963
- id: le.id,
1708
+ id: U.id,
1964
1709
  params: {
1965
- unitId: s,
1710
+ unitId: o,
1966
1711
  subUnitId: t,
1967
- rule: M.rule,
1968
- index: M.index,
1969
- source: i
1712
+ rule: g.rule,
1713
+ index: g.index,
1714
+ source: a
1970
1715
  }
1971
1716
  });
1972
1717
  break;
1973
1718
  case "update": {
1974
- if (o.push({
1975
- id: X.id,
1976
- params: {
1977
- unitId: s,
1978
- subUnitId: t,
1979
- ruleId: M.ruleId,
1980
- payload: {
1981
- type: Y.RANGE,
1982
- payload: M.newRanges
1983
- },
1984
- source: i
1985
- }
1986
- }), l.unshift({
1987
- id: X.id,
1988
- params: {
1989
- unitId: s,
1990
- subUnitId: t,
1991
- ruleId: M.ruleId,
1992
- payload: {
1993
- type: Y.RANGE,
1994
- payload: M.oldRanges
1995
- },
1996
- source: i
1997
- }
1998
- }), M.rule.type === $.CUSTOM) {
1999
- const O = M.oldRanges[0].startRow, H = M.oldRanges[0].startColumn, L = M.newRanges[0].startRow, q = M.newRanges[0].startColumn, se = L - O, he = q - H, ae = n.moveFormulaRefOffset(M.rule.formula1, he, se);
2000
- ae !== M.rule.formula1 && (o.push({
2001
- id: X.id,
1719
+ if (le(g.rule.type)) {
1720
+ const E = g.oldRanges[0].startRow, x = g.oldRanges[0].startColumn, L = g.newRanges[0].startRow, J = g.newRanges[0].startColumn, ee = L - E, ue = J - x, ce = R(g.rule.formula1) ? s.moveFormulaRefOffset(g.rule.formula1, ue, ee) : g.rule.formula1, de = R(g.rule.formula2) ? s.moveFormulaRefOffset(g.rule.formula2, ue, ee) : g.rule.formula2;
1721
+ (ce !== g.rule.formula1 || de !== g.rule.formula2) && (n.push({
1722
+ id: b.id,
2002
1723
  params: {
2003
- unitId: s,
1724
+ unitId: o,
2004
1725
  subUnitId: t,
2005
- ruleId: M.ruleId,
1726
+ ruleId: g.ruleId,
2006
1727
  payload: {
2007
- type: Y.SETTING,
1728
+ type: w.ALL,
2008
1729
  payload: {
2009
- ...rt(M.rule),
2010
- formula1: ae
1730
+ formula1: ce,
1731
+ formula2: de,
1732
+ ranges: g.newRanges
2011
1733
  }
2012
1734
  }
2013
1735
  }
2014
1736
  }), l.unshift({
2015
- id: X.id,
1737
+ id: b.id,
2016
1738
  params: {
2017
- unitId: s,
1739
+ unitId: o,
2018
1740
  subUnitId: t,
2019
- ruleId: M.ruleId,
1741
+ ruleId: g.ruleId,
2020
1742
  payload: {
2021
- type: Y.SETTING,
2022
- payload: rt(M.rule)
1743
+ type: w.ALL,
1744
+ payload: {
1745
+ formula1: g.rule.formula1,
1746
+ formula2: g.rule.formula2,
1747
+ ranges: g.oldRanges
1748
+ }
2023
1749
  }
2024
1750
  }
2025
1751
  }));
2026
- }
2027
- const x = u.getRuleById(s, t, M.ruleId);
2028
- if (x && x.type === $.CHECKBOX) {
2029
- const H = u.getValidator($.CHECKBOX).parseFormulaSync(x, s, t);
2030
- S(M.newRanges, H.formula2);
1752
+ } else
1753
+ n.push({
1754
+ id: b.id,
1755
+ params: {
1756
+ unitId: o,
1757
+ subUnitId: t,
1758
+ ruleId: g.ruleId,
1759
+ payload: {
1760
+ type: w.RANGE,
1761
+ payload: g.newRanges
1762
+ },
1763
+ source: a
1764
+ }
1765
+ }), l.unshift({
1766
+ id: b.id,
1767
+ params: {
1768
+ unitId: o,
1769
+ subUnitId: t,
1770
+ ruleId: g.ruleId,
1771
+ payload: {
1772
+ type: w.RANGE,
1773
+ payload: g.oldRanges
1774
+ },
1775
+ source: a
1776
+ }
1777
+ });
1778
+ const C = u.getRuleById(o, t, g.ruleId);
1779
+ if (C && C.type === M.CHECKBOX) {
1780
+ const x = u.getValidator(M.CHECKBOX).parseFormulaSync(C, o, t);
1781
+ p(g.newRanges, x.formula2);
2031
1782
  }
2032
1783
  break;
2033
1784
  }
2034
1785
  case "add": {
2035
- if (o.push({
2036
- id: le.id,
1786
+ if (n.push({
1787
+ id: U.id,
2037
1788
  params: {
2038
- unitId: s,
1789
+ unitId: o,
2039
1790
  subUnitId: t,
2040
- rule: M.rule,
2041
- source: i
1791
+ rule: g.rule,
1792
+ source: a
2042
1793
  }
2043
1794
  }), l.unshift({
2044
- id: ie.id,
1795
+ id: P.id,
2045
1796
  params: {
2046
- unitId: s,
1797
+ unitId: o,
2047
1798
  subUnitId: t,
2048
- ruleId: M.rule.uid,
2049
- source: i
1799
+ ruleId: g.rule.uid,
1800
+ source: a
2050
1801
  }
2051
- }), M.rule.type === $.CHECKBOX) {
2052
- const O = u.getValidator($.CHECKBOX).parseFormulaSync(M.rule, s, t);
2053
- S(M.rule.ranges, O.originFormula2);
1802
+ }), g.rule.type === M.CHECKBOX) {
1803
+ const E = u.getValidator(M.CHECKBOX).parseFormulaSync(g.rule, o, t);
1804
+ p(g.rule.ranges, E.originFormula2);
2054
1805
  }
2055
1806
  break;
2056
1807
  }
2057
1808
  }
2058
1809
  });
2059
- const w = {
2060
- id: Ce.id,
1810
+ const S = {
1811
+ id: se.id,
2061
1812
  params: {
2062
- unitId: s,
1813
+ unitId: o,
2063
1814
  subUnitId: t,
2064
- cellValue: v.getData()
1815
+ cellValue: _.getData()
2065
1816
  }
2066
- }, I = {
2067
- id: Ce.id,
2068
- params: vt(r, w.params)
1817
+ }, y = {
1818
+ id: se.id,
1819
+ params: st(r, S.params)
2069
1820
  };
2070
- return o.push(w), l.push(I), {
2071
- redoMutations: o,
1821
+ return n.push(S), l.push(y), {
1822
+ redoMutations: n,
2072
1823
  undoMutations: l
2073
1824
  };
2074
1825
  }
2075
- const Ar = {
2076
- type: ve.COMMAND,
1826
+ const Sr = {
1827
+ type: K.COMMAND,
2077
1828
  id: "sheet.command.updateDataValidationRuleRange",
2078
- handler(s, t) {
1829
+ handler(o, t) {
2079
1830
  if (!t)
2080
1831
  return !1;
2081
- const { unitId: e, subUnitId: r, ranges: i, ruleId: a } = t, n = s.get(j), o = s.get(re), l = s.get(Se);
2082
- if (!n.getRuleById(e, r, a))
1832
+ const { unitId: e, subUnitId: r, ranges: a, ruleId: i } = t, s = o.get(F), n = o.get(H), l = o.get(z);
1833
+ if (!s.getRuleById(e, r, i))
2083
1834
  return !1;
2084
- const c = n.getRuleObjectMatrix(e, r).clone();
2085
- c.updateRange(a, i);
2086
- const d = c.diff(n.getRules(e, r)), { redoMutations: m, undoMutations: v } = ze(e, r, d, s);
1835
+ const c = s.getRuleObjectMatrix(e, r).clone();
1836
+ c.updateRange(i, a);
1837
+ const d = c.diff(s.getRules(e, r)), { redoMutations: m, undoMutations: _ } = Ae(e, r, d, o);
2087
1838
  return l.pushUndoRedo({
2088
- undoMutations: v,
1839
+ undoMutations: _,
2089
1840
  redoMutations: m,
2090
1841
  unitID: e
2091
- }), Ye(m, o), !0;
1842
+ }), Oe(m, n), !0;
2092
1843
  }
2093
- }, Lr = {
2094
- type: ve.COMMAND,
1844
+ }, Vr = {
1845
+ type: K.COMMAND,
2095
1846
  id: "sheet.command.addDataValidation",
2096
- handler(s, t) {
1847
+ handler(o, t) {
2097
1848
  if (!t)
2098
1849
  return !1;
2099
- const { unitId: e, subUnitId: r, rule: i } = t, a = s.get(j), n = s.get(re), o = s.get(Se), l = a.getRuleObjectMatrix(e, r).clone();
2100
- l.addRule(i);
2101
- const u = l.diff(a.getRules(e, r)), c = {
1850
+ const { unitId: e, subUnitId: r, rule: a } = t, i = o.get(F), s = o.get(H), n = o.get(z), l = i.getRuleObjectMatrix(e, r).clone();
1851
+ l.addRule(a);
1852
+ const u = l.diff(i.getRules(e, r)), c = i.getValidator(a.type), d = {
2102
1853
  unitId: e,
2103
1854
  subUnitId: r,
2104
- rule: i
2105
- }, { redoMutations: d, undoMutations: m } = ze(e, r, u, s);
2106
- return d.push({
2107
- id: le.id,
2108
- params: c
2109
- }), m.unshift({
2110
- id: ie.id,
1855
+ rule: {
1856
+ ...a,
1857
+ ...c == null ? void 0 : c.normalizeFormula(a, e, r)
1858
+ }
1859
+ }, { redoMutations: m, undoMutations: _ } = Ae(e, r, u, o);
1860
+ return m.push({
1861
+ id: U.id,
1862
+ params: d
1863
+ }), _.unshift({
1864
+ id: P.id,
2111
1865
  params: {
2112
1866
  unitId: e,
2113
1867
  subUnitId: r,
2114
- ruleId: i.uid
1868
+ ruleId: a.uid
2115
1869
  }
2116
- }), o.pushUndoRedo({
1870
+ }), n.pushUndoRedo({
2117
1871
  unitID: e,
2118
- redoMutations: d,
2119
- undoMutations: m
2120
- }), Ye(d, n), !0;
1872
+ redoMutations: m,
1873
+ undoMutations: _
1874
+ }), Oe(m, s), !0;
2121
1875
  }
2122
- }, Ur = {
2123
- type: ve.COMMAND,
1876
+ }, Nr = {
1877
+ type: K.COMMAND,
2124
1878
  id: "sheets.command.update-data-validation-setting",
2125
1879
  // eslint-disable-next-line max-lines-per-function
2126
- handler(s, t) {
1880
+ handler(o, t) {
2127
1881
  if (!t)
2128
1882
  return !1;
2129
- const e = s.get(re), r = s.get(Se), i = s.get(j), a = s.get(ot), { unitId: n, subUnitId: o, ruleId: l, setting: u } = t, c = a.getValidatorItem(u.type);
1883
+ const e = o.get(H), r = o.get(z), a = o.get(F), i = o.get(Qe), { unitId: s, subUnitId: n, ruleId: l, setting: u } = t, c = i.getValidatorItem(u.type);
2130
1884
  if (!c)
2131
1885
  return !1;
2132
- const d = i.getRuleById(n, o, l);
1886
+ const d = a.getRuleById(s, n, l);
2133
1887
  if (!d)
2134
1888
  return !1;
2135
1889
  const m = { ...d, ...u };
2136
- if (!c.validatorFormula(m, n, o).success)
1890
+ if (!c.validatorFormula(m, s, n).success)
2137
1891
  return !1;
2138
- const v = {
2139
- unitId: n,
2140
- subUnitId: o,
1892
+ const _ = {
1893
+ unitId: s,
1894
+ subUnitId: n,
2141
1895
  ruleId: l,
2142
1896
  payload: {
2143
- type: Y.SETTING,
1897
+ type: w.SETTING,
2144
1898
  payload: {
2145
1899
  ...u,
2146
- ...c.normalizeFormula(m, n, o)
1900
+ ...c.normalizeFormula(m, s, n)
2147
1901
  }
2148
1902
  }
2149
- }, S = [{
2150
- id: X.id,
2151
- params: v
2152
- }], w = {
2153
- unitId: n,
2154
- subUnitId: o,
1903
+ }, p = [{
1904
+ id: b.id,
1905
+ params: _
1906
+ }], S = {
1907
+ unitId: s,
1908
+ subUnitId: n,
2155
1909
  ruleId: l,
2156
1910
  payload: {
2157
- type: Y.SETTING,
2158
- payload: rt(d)
1911
+ type: w.SETTING,
1912
+ payload: xt(d)
2159
1913
  }
2160
- }, I = [{
2161
- id: X.id,
2162
- params: w
1914
+ }, y = [{
1915
+ id: b.id,
1916
+ params: S
2163
1917
  }];
2164
- if (u.type === $.CHECKBOX) {
2165
- const x = d.ranges, O = s.get(Z), H = lt(O, { unitId: n, subUnitId: o });
2166
- if (H) {
2167
- const L = new Ue(), { worksheet: q } = H, { formula2: se = Pe, formula1: he = Be } = d, { formula2: ae = Pe, formula1: U = Be } = u;
2168
- x.forEach((Oe) => {
2169
- Q.foreach(Oe, (y, f) => {
2170
- const h = q.getCellRaw(y, f), R = Nt(h);
2171
- Ft(h) || R === String(se) ? L.setValue(y, f, {
2172
- v: ae,
1918
+ if (u.type === M.CHECKBOX) {
1919
+ const C = d.ranges, E = o.get(D), x = Ye(E, { unitId: s, subUnitId: n });
1920
+ if (x) {
1921
+ const L = new Re(), { worksheet: J } = x, { formula2: ee = Ve, formula1: ue = Se } = d, { formula2: ce = Ve, formula1: de = Se } = u;
1922
+ C.forEach((Rt) => {
1923
+ I.foreach(Rt, (De, xe) => {
1924
+ const Ze = J.getCellRaw(De, xe), Je = dt(Ze);
1925
+ ft(Ze) || Je === String(ee) ? L.setValue(De, xe, {
1926
+ v: ce,
2173
1927
  p: null
2174
- }) : R === String(he) && L.setValue(y, f, {
2175
- v: U,
1928
+ }) : Je === String(ue) && L.setValue(De, xe, {
1929
+ v: de,
2176
1930
  p: null
2177
1931
  });
2178
1932
  });
2179
1933
  });
2180
- const T = {
2181
- id: Ce.id,
1934
+ const ze = {
1935
+ id: se.id,
2182
1936
  params: {
2183
- unitId: n,
2184
- subUnitId: o,
1937
+ unitId: s,
1938
+ subUnitId: n,
2185
1939
  cellValue: L.getData()
2186
1940
  }
2187
- }, Re = {
2188
- id: Ce.id,
2189
- params: vt(s, T.params)
1941
+ }, vt = {
1942
+ id: se.id,
1943
+ params: st(o, ze.params)
2190
1944
  };
2191
- S.push(T), I.push(Re);
1945
+ p.push(ze), y.push(vt);
2192
1946
  }
2193
1947
  }
2194
- return Ye(S, e).result ? (r.pushUndoRedo({
2195
- unitID: n,
2196
- redoMutations: S,
2197
- undoMutations: I
1948
+ return Oe(p, e).result ? (r.pushUndoRedo({
1949
+ unitID: s,
1950
+ redoMutations: p,
1951
+ undoMutations: y
2198
1952
  }), !0) : !1;
2199
1953
  }
2200
- }, Br = {
2201
- type: ve.COMMAND,
1954
+ }, Mr = {
1955
+ type: K.COMMAND,
2202
1956
  id: "sheets.command.update-data-validation-options",
2203
- handler(s, t) {
1957
+ handler(o, t) {
2204
1958
  if (!t)
2205
1959
  return !1;
2206
- const e = s.get(re), r = s.get(Se), i = s.get(j), { unitId: a, subUnitId: n, ruleId: o, options: l } = t, u = i.getRuleById(a, n, o);
1960
+ const e = o.get(H), r = o.get(z), a = o.get(F), { unitId: i, subUnitId: s, ruleId: n, options: l } = t, u = a.getRuleById(i, s, n);
2207
1961
  if (!u)
2208
1962
  return !1;
2209
1963
  const c = {
2210
- unitId: a,
2211
- subUnitId: n,
2212
- ruleId: o,
1964
+ unitId: i,
1965
+ subUnitId: s,
1966
+ ruleId: n,
2213
1967
  payload: {
2214
- type: Y.OPTIONS,
1968
+ type: w.OPTIONS,
2215
1969
  payload: l
2216
1970
  }
2217
1971
  }, d = [{
2218
- id: X.id,
1972
+ id: b.id,
2219
1973
  params: c
2220
1974
  }], m = {
2221
- unitId: a,
2222
- subUnitId: n,
2223
- ruleId: o,
1975
+ unitId: i,
1976
+ subUnitId: s,
1977
+ ruleId: n,
2224
1978
  payload: {
2225
- type: Y.OPTIONS,
2226
- payload: qt(u)
1979
+ type: w.OPTIONS,
1980
+ payload: Lt(u)
2227
1981
  }
2228
- }, v = [{
2229
- id: X.id,
1982
+ }, _ = [{
1983
+ id: b.id,
2230
1984
  params: m
2231
1985
  }];
2232
1986
  return r.pushUndoRedo({
2233
- unitID: a,
1987
+ unitID: i,
2234
1988
  redoMutations: d,
2235
- undoMutations: v
2236
- }), e.executeCommand(X.id, c), !0;
1989
+ undoMutations: _
1990
+ }), e.executeCommand(b.id, c), !0;
2237
1991
  }
2238
- }, Pr = {
2239
- type: ve.COMMAND,
1992
+ }, yr = {
1993
+ type: K.COMMAND,
2240
1994
  id: "sheets.command.clear-range-data-validation",
2241
- handler(s, t) {
1995
+ handler(o, t) {
2242
1996
  if (!t)
2243
1997
  return !1;
2244
- const { unitId: e, subUnitId: r, ranges: i } = t, a = s.get(re), n = s.get(Z), o = lt(n, { unitId: e, subUnitId: r }), l = s.get(j);
2245
- if (!o) return !1;
2246
- const u = s.get(Se), c = l.getRuleObjectMatrix(e, r).clone();
2247
- c.removeRange(i);
2248
- const d = c.diff(l.getRules(e, r)), { redoMutations: m, undoMutations: v } = ze(e, r, d, s);
1998
+ const { unitId: e, subUnitId: r, ranges: a } = t, i = o.get(H), s = o.get(D), n = Ye(s, { unitId: e, subUnitId: r }), l = o.get(F);
1999
+ if (!n) return !1;
2000
+ const u = o.get(z), c = l.getRuleObjectMatrix(e, r).clone();
2001
+ c.removeRange(a);
2002
+ const d = c.diff(l.getRules(e, r)), { redoMutations: m, undoMutations: _ } = Ae(e, r, d, o);
2249
2003
  return u.pushUndoRedo({
2250
2004
  unitID: e,
2251
2005
  redoMutations: m,
2252
- undoMutations: v
2253
- }), Ye(m, a).result;
2006
+ undoMutations: _
2007
+ }), Oe(m, i).result;
2254
2008
  }
2255
- }, Hr = {
2256
- type: ve.COMMAND,
2009
+ }, Er = {
2010
+ type: K.COMMAND,
2257
2011
  id: "sheet.command.remove-all-data-validation",
2258
- handler(s, t) {
2012
+ handler(o, t) {
2259
2013
  if (!t)
2260
2014
  return !1;
2261
- const { unitId: e, subUnitId: r } = t, i = s.get(re), a = s.get(j), n = s.get(Se), o = [...a.getRules(e, r)], l = {
2015
+ const { unitId: e, subUnitId: r } = t, a = o.get(H), i = o.get(F), s = o.get(z), n = [...i.getRules(e, r)], l = {
2262
2016
  unitId: e,
2263
2017
  subUnitId: r,
2264
- ruleId: o.map((d) => d.uid)
2018
+ ruleId: n.map((d) => d.uid)
2265
2019
  }, u = [{
2266
- id: ie.id,
2020
+ id: P.id,
2267
2021
  params: l
2268
2022
  }], c = [{
2269
- id: le.id,
2023
+ id: U.id,
2270
2024
  params: {
2271
2025
  unitId: e,
2272
2026
  subUnitId: r,
2273
- rule: o
2027
+ rule: n
2274
2028
  }
2275
2029
  }];
2276
- return n.pushUndoRedo({
2030
+ return s.pushUndoRedo({
2277
2031
  redoMutations: u,
2278
2032
  undoMutations: c,
2279
2033
  unitID: e
2280
- }), i.executeCommand(ie.id, l), !0;
2034
+ }), a.executeCommand(P.id, l), !0;
2281
2035
  }
2282
- }, kr = (s, t) => {
2283
- const e = s.get(j), { unitId: r, subUnitId: i, ruleId: a, source: n } = t;
2284
- if (Array.isArray(a)) {
2285
- const l = a.map((u) => e.getRuleById(r, i, u)).filter(Boolean);
2036
+ }, Tr = (o, t) => {
2037
+ const e = o.get(F), { unitId: r, subUnitId: a, ruleId: i, source: s } = t;
2038
+ if (Array.isArray(i)) {
2039
+ const l = i.map((u) => e.getRuleById(r, a, u)).filter(Boolean);
2286
2040
  return [{
2287
- id: le.id,
2041
+ id: U.id,
2288
2042
  params: {
2289
2043
  unitId: r,
2290
- subUnitId: i,
2044
+ subUnitId: a,
2291
2045
  rule: l,
2292
- source: n
2046
+ source: s
2293
2047
  }
2294
2048
  }];
2295
2049
  }
2296
2050
  return [{
2297
- id: le.id,
2051
+ id: U.id,
2298
2052
  params: {
2299
2053
  unitId: r,
2300
- subUnitId: i,
2054
+ subUnitId: a,
2301
2055
  rule: {
2302
- ...e.getRuleById(r, i, a)
2056
+ ...e.getRuleById(r, a, i)
2303
2057
  },
2304
- index: e.getRuleIndex(r, i, a)
2058
+ index: e.getRuleIndex(r, a, i)
2305
2059
  }
2306
2060
  }];
2307
- }, Wr = {
2308
- type: ve.COMMAND,
2061
+ }, wr = {
2062
+ type: K.COMMAND,
2309
2063
  id: "sheet.command.remove-data-validation-rule",
2310
- handler(s, t) {
2064
+ handler(o, t) {
2311
2065
  if (!t)
2312
2066
  return !1;
2313
- const { unitId: e, subUnitId: r, ruleId: i } = t, a = s.get(re), n = s.get(Se), o = s.get(j), l = [{
2314
- id: ie.id,
2067
+ const { unitId: e, subUnitId: r, ruleId: a } = t, i = o.get(H), s = o.get(z), n = o.get(F), l = [{
2068
+ id: P.id,
2315
2069
  params: t
2316
2070
  }], u = [{
2317
- id: le.id,
2071
+ id: U.id,
2318
2072
  params: {
2319
2073
  unitId: e,
2320
2074
  subUnitId: r,
2321
2075
  rule: {
2322
- ...o.getRuleById(e, r, i)
2076
+ ...n.getRuleById(e, r, a)
2323
2077
  },
2324
- index: o.getRuleIndex(e, r, i)
2078
+ index: n.getRuleIndex(e, r, a)
2325
2079
  }
2326
2080
  }];
2327
- return n.pushUndoRedo({
2081
+ return s.pushUndoRedo({
2328
2082
  undoMutations: u,
2329
2083
  redoMutations: l,
2330
2084
  unitID: t.unitId
2331
- }), a.executeCommand(ie.id, t), !0;
2085
+ }), i.executeCommand(P.id, t), !0;
2332
2086
  }
2333
- }, jr = "sheets-data-validation.config", qr = {};
2334
- class Gr extends de {
2087
+ }, Fr = "sheets-data-validation.config", Cr = {};
2088
+ class Or extends q {
2335
2089
  constructor() {
2336
2090
  super(...arguments);
2337
- g(this, "id", $.ANY);
2338
- g(this, "title", "dataValidation.any.title");
2339
- g(this, "operators", []);
2340
- g(this, "scopes", ["sheet"]);
2091
+ f(this, "id", M.ANY);
2092
+ f(this, "title", "dataValidation.any.title");
2093
+ f(this, "operators", []);
2094
+ f(this, "scopes", ["sheet"]);
2341
2095
  }
2342
- async parseFormula(e, r, i) {
2096
+ async parseFormula(e, r, a) {
2343
2097
  return {
2344
2098
  formula1: e.formula1,
2345
2099
  formula2: e.formula2,
2346
2100
  isFormulaValid: !0
2347
2101
  };
2348
2102
  }
2349
- validatorFormula(e, r, i) {
2103
+ validatorFormula(e, r, a) {
2350
2104
  return {
2351
2105
  success: !0
2352
2106
  };
2353
2107
  }
2354
- async isValidType(e, r, i) {
2108
+ async isValidType(e, r, a) {
2355
2109
  return !0;
2356
2110
  }
2357
2111
  generateRuleErrorMessage(e) {
2358
2112
  return this.localeService.t("dataValidation.any.error");
2359
2113
  }
2360
2114
  }
2361
- class Qr extends de {
2115
+ class br extends q {
2362
2116
  constructor() {
2363
2117
  super(...arguments);
2364
- g(this, "id", $.CUSTOM);
2365
- g(this, "title", "dataValidation.custom.title");
2366
- g(this, "operators", []);
2367
- g(this, "scopes", ["sheet"]);
2368
- g(this, "_customFormulaService", this.injector.get(we));
2369
- }
2370
- validatorFormula(e, r, i) {
2371
- const a = F(e.formula1);
2118
+ f(this, "id", M.CUSTOM);
2119
+ f(this, "title", "dataValidation.custom.title");
2120
+ f(this, "operators", []);
2121
+ f(this, "scopes", ["sheet"]);
2122
+ f(this, "_customFormulaService", this.injector.get($));
2123
+ }
2124
+ validatorFormula(e, r, a) {
2125
+ const i = R(e.formula1);
2372
2126
  return {
2373
- success: a,
2374
- formula1: a ? "" : this.localeService.t("dataValidation.validFail.formula")
2127
+ success: i,
2128
+ formula1: i ? "" : this.localeService.t("dataValidation.validFail.formula")
2375
2129
  };
2376
2130
  }
2377
- async parseFormula(e, r, i) {
2131
+ async parseFormula(e, r, a) {
2378
2132
  return {
2379
2133
  formula1: void 0,
2380
2134
  formula2: void 0,
2381
2135
  isFormulaValid: !0
2382
2136
  };
2383
2137
  }
2384
- async isValidType(e, r, i) {
2385
- const { column: a, row: n, unitId: o, subUnitId: l } = e, u = await this._customFormulaService.getCellFormulaValue(o, l, i.uid, n, a), c = u == null ? void 0 : u.v;
2386
- return W(String(c)) && b.isDefine(c) && c !== "" ? u.t === xt.BOOLEAN ? !!c : typeof c == "boolean" ? c : typeof c == "number" ? !!c : typeof c == "string" ? W(c) : !!c : !1;
2138
+ async isValidType(e, r, a) {
2139
+ const { column: i, row: s, unitId: n, subUnitId: l } = e, u = await this._customFormulaService.getCellFormulaValue(n, l, a.uid, s, i), c = u == null ? void 0 : u.v;
2140
+ return O(String(c)) && N.isDefine(c) && c !== "" ? u.t === yt.BOOLEAN ? !!c : typeof c == "boolean" ? c : typeof c == "number" ? !!c : typeof c == "string" ? O(c) : !!c : !1;
2387
2141
  }
2388
2142
  generateRuleErrorMessage(e) {
2389
2143
  return this.localeService.t("dataValidation.custom.error");
@@ -2393,152 +2147,158 @@ class Qr extends de {
2393
2147
  return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (r = e.formula1) != null ? r : "");
2394
2148
  }
2395
2149
  }
2396
- class Yr extends Tt {
2150
+ class Ir extends mt {
2397
2151
  constructor() {
2398
2152
  super(...arguments);
2399
- g(this, "id", $.LIST_MULTIPLE);
2400
- g(this, "title", "dataValidation.listMultiple.title");
2401
- g(this, "skipDefaultFontRender", () => !0);
2153
+ f(this, "id", M.LIST_MULTIPLE);
2154
+ f(this, "title", "dataValidation.listMultiple.title");
2155
+ f(this, "skipDefaultFontRender", () => !0);
2402
2156
  }
2403
2157
  }
2404
- class Xr extends de {
2158
+ class Ar extends q {
2405
2159
  constructor() {
2406
2160
  super(...arguments);
2407
- g(this, "_formulaService", this.injector.get(te));
2408
- g(this, "id", $.WHOLE);
2409
- g(this, "title", "dataValidation.whole.title");
2410
- g(this, "operators", [
2411
- _.BETWEEN,
2412
- _.EQUAL,
2413
- _.GREATER_THAN,
2414
- _.GREATER_THAN_OR_EQUAL,
2415
- _.LESS_THAN,
2416
- _.LESS_THAN_OR_EQUAL,
2417
- _.NOT_BETWEEN,
2418
- _.NOT_EQUAL
2161
+ f(this, "_customFormulaService", this.injector.get($));
2162
+ f(this, "_lexerTreeBuilder", this.injector.get(Z));
2163
+ f(this, "id", M.WHOLE);
2164
+ f(this, "title", "dataValidation.whole.title");
2165
+ f(this, "operators", [
2166
+ h.BETWEEN,
2167
+ h.EQUAL,
2168
+ h.GREATER_THAN,
2169
+ h.GREATER_THAN_OR_EQUAL,
2170
+ h.LESS_THAN,
2171
+ h.LESS_THAN_OR_EQUAL,
2172
+ h.NOT_BETWEEN,
2173
+ h.NOT_EQUAL
2419
2174
  ]);
2420
- g(this, "scopes", ["sheet"]);
2175
+ f(this, "scopes", ["sheet"]);
2421
2176
  }
2422
2177
  _isFormulaOrInt(e) {
2423
- return !b.isBlank(e) && (F(e) || !Number.isNaN(+e) && Number.isInteger(+e));
2178
+ return !N.isBlank(e) && (R(e) || !Number.isNaN(+e) && Number.isInteger(+e));
2424
2179
  }
2425
- async isValidType(e, r, i) {
2426
- const { value: a } = e, n = He(a);
2427
- return !Number.isNaN(n) && Number.isInteger(n);
2180
+ async isValidType(e, r, a) {
2181
+ const { value: i } = e, s = Ne(i);
2182
+ return !Number.isNaN(s) && Number.isInteger(s);
2428
2183
  }
2429
- transform(e, r, i) {
2430
- const { value: a } = e;
2184
+ transform(e, r, a) {
2185
+ const { value: i } = e;
2431
2186
  return {
2432
2187
  ...e,
2433
- value: He(a)
2188
+ value: Ne(i)
2434
2189
  };
2435
2190
  }
2436
2191
  _parseNumber(e) {
2437
2192
  return e == null ? Number.NaN : +e;
2438
2193
  }
2439
- async parseFormula(e, r, i) {
2440
- var m, v, S, w, I, M, x, O, H, L;
2441
- const a = await this._formulaService.getRuleFormulaResult(r, i, e.uid), { formula1: n, formula2: o } = e, l = F(n) ? (I = (w = (S = (v = (m = a == null ? void 0 : a[0]) == null ? void 0 : m.result) == null ? void 0 : v[0]) == null ? void 0 : S[0]) == null ? void 0 : w[0][0]) == null ? void 0 : I.v : n, u = F(o) ? (L = (H = (O = (x = (M = a == null ? void 0 : a[1]) == null ? void 0 : M.result) == null ? void 0 : x[0]) == null ? void 0 : O[0]) == null ? void 0 : H[0][0]) == null ? void 0 : L.v : o, c = W(`${l}`) && W(`${u}`);
2194
+ async parseFormula(e, r, a, i, s) {
2195
+ const n = await this._customFormulaService.getCellFormulaValue(r, a, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(r, a, e.uid, i, s), { formula1: u, formula2: c } = e, d = R(u) ? n == null ? void 0 : n.v : u, m = R(c) ? l == null ? void 0 : l.v : c, _ = O(`${d}`) && O(`${m}`);
2442
2196
  return {
2443
- formula1: this._parseNumber(l),
2444
- formula2: this._parseNumber(u),
2445
- isFormulaValid: c
2197
+ formula1: this._parseNumber(d),
2198
+ formula2: this._parseNumber(m),
2199
+ isFormulaValid: _
2446
2200
  };
2447
2201
  }
2448
- validatorFormula(e, r, i) {
2449
- const a = e.operator;
2450
- if (!a)
2202
+ validatorFormula(e, r, a) {
2203
+ const i = e.operator;
2204
+ if (!i)
2451
2205
  return {
2452
2206
  success: !1
2453
2207
  };
2454
- const n = b.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), o = b.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Xe.includes(a), u = this.localeService.t("dataValidation.validFail.number");
2208
+ const s = N.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = N.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
2455
2209
  return l ? {
2456
- success: n && o,
2457
- formula1: n ? void 0 : u,
2458
- formula2: o ? void 0 : u
2210
+ success: s && n,
2211
+ formula1: s ? void 0 : u,
2212
+ formula2: n ? void 0 : u
2459
2213
  } : {
2460
- success: n,
2214
+ success: s,
2461
2215
  formula1: u
2462
2216
  };
2463
2217
  }
2464
- async validatorIsEqual(e, r, i) {
2465
- const { formula1: a } = r, { value: n } = e;
2466
- return Number.isNaN(a) ? !0 : n === a;
2218
+ async validatorIsEqual(e, r, a) {
2219
+ const { formula1: i } = r, { value: s } = e;
2220
+ return Number.isNaN(i) ? !0 : s === i;
2467
2221
  }
2468
- async validatorIsNotEqual(e, r, i) {
2469
- const { formula1: a } = r;
2470
- return Number.isNaN(a) ? !0 : e.value !== a;
2222
+ async validatorIsNotEqual(e, r, a) {
2223
+ const { formula1: i } = r;
2224
+ return Number.isNaN(i) ? !0 : e.value !== i;
2471
2225
  }
2472
- async validatorIsBetween(e, r, i) {
2473
- const { formula1: a, formula2: n } = r;
2474
- if (Number.isNaN(a) || Number.isNaN(n))
2226
+ async validatorIsBetween(e, r, a) {
2227
+ const { formula1: i, formula2: s } = r;
2228
+ if (Number.isNaN(i) || Number.isNaN(s))
2475
2229
  return !0;
2476
- const o = Math.min(a, n), l = Math.max(a, n);
2477
- return e.value >= o && e.value <= l;
2230
+ const n = Math.min(i, s), l = Math.max(i, s);
2231
+ return e.value >= n && e.value <= l;
2478
2232
  }
2479
- async validatorIsNotBetween(e, r, i) {
2480
- const { formula1: a, formula2: n } = r;
2481
- if (Number.isNaN(a) || Number.isNaN(n))
2233
+ async validatorIsNotBetween(e, r, a) {
2234
+ const { formula1: i, formula2: s } = r;
2235
+ if (Number.isNaN(i) || Number.isNaN(s))
2482
2236
  return !0;
2483
- const o = Math.min(a, n), l = Math.max(a, n);
2484
- return e.value < o || e.value > l;
2237
+ const n = Math.min(i, s), l = Math.max(i, s);
2238
+ return e.value < n || e.value > l;
2239
+ }
2240
+ async validatorIsGreaterThan(e, r, a) {
2241
+ const { formula1: i } = r;
2242
+ return Number.isNaN(i) ? !0 : e.value > i;
2485
2243
  }
2486
- async validatorIsGreaterThan(e, r, i) {
2487
- const { formula1: a } = r;
2488
- return Number.isNaN(a) ? !0 : e.value > a;
2244
+ async validatorIsGreaterThanOrEqual(e, r, a) {
2245
+ const { formula1: i } = r;
2246
+ return Number.isNaN(i) ? !0 : e.value >= i;
2489
2247
  }
2490
- async validatorIsGreaterThanOrEqual(e, r, i) {
2491
- const { formula1: a } = r;
2492
- return Number.isNaN(a) ? !0 : e.value >= a;
2248
+ async validatorIsLessThan(e, r, a) {
2249
+ const { formula1: i } = r;
2250
+ return Number.isNaN(i) ? !0 : e.value < i;
2493
2251
  }
2494
- async validatorIsLessThan(e, r, i) {
2495
- const { formula1: a } = r;
2496
- return Number.isNaN(a) ? !0 : e.value < a;
2252
+ async validatorIsLessThanOrEqual(e, r, a) {
2253
+ const { formula1: i } = r;
2254
+ return Number.isNaN(i) ? !0 : e.value <= i;
2497
2255
  }
2498
- async validatorIsLessThanOrEqual(e, r, i) {
2499
- const { formula1: a } = r;
2500
- return Number.isNaN(a) ? !0 : e.value <= a;
2256
+ generateRuleErrorMessage(e, r) {
2257
+ if (!e.operator)
2258
+ return this.titleStr;
2259
+ const { transformedFormula1: a, transformedFormula2: i } = Ie(this._lexerTreeBuilder, e, r);
2260
+ return `${this.localeService.t(ht[e.operator]).replace(oe, a != null ? a : "").replace(ne, i != null ? i : "")}`;
2501
2261
  }
2502
2262
  }
2503
- var zr = Object.defineProperty, Kr = Object.getOwnPropertyDescriptor, Zr = (s, t, e, r) => {
2504
- for (var i = r > 1 ? void 0 : r ? Kr(t, e) : t, a = s.length - 1, n; a >= 0; a--)
2505
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
2506
- return r && i && zr(t, e, i), i;
2507
- }, Me = (s, t) => (e, r) => t(e, r, s);
2508
- let ke = class extends At {
2509
- constructor(s, t, e, r, i, a) {
2510
- super(), this._univerInstanceService = s, this._dataValidatorRegistryService = t, this._injector = e, this._selectionManagerService = r, this._sheetInterceptorService = i, this._sheetDataValidationModel = a, this._init();
2263
+ var Dr = Object.defineProperty, xr = Object.getOwnPropertyDescriptor, Lr = (o, t, e, r) => {
2264
+ for (var a = r > 1 ? void 0 : r ? xr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2265
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2266
+ return r && a && Dr(t, e, a), a;
2267
+ }, te = (o, t) => (e, r) => t(e, r, o);
2268
+ let Me = class extends Et {
2269
+ constructor(o, t, e, r, a, i) {
2270
+ super(), this._univerInstanceService = o, this._dataValidatorRegistryService = t, this._injector = e, this._selectionManagerService = r, this._sheetInterceptorService = a, this._sheetDataValidationModel = i, this._init();
2511
2271
  }
2512
2272
  _init() {
2513
2273
  this._registerValidators(), this._initCommandInterceptor();
2514
2274
  }
2515
2275
  _registerValidators() {
2516
2276
  [
2517
- Gr,
2518
- Cr,
2519
- Xr,
2520
- xr,
2521
- Er,
2522
- yr,
2523
- Tt,
2524
- Yr,
2525
- Qr
2526
- ].forEach((s) => {
2527
- const t = this._injector.createInstance(s);
2528
- this.disposeWithMe(this._dataValidatorRegistryService.register(t)), this.disposeWithMe(gt(() => this._injector.delete(s)));
2277
+ Or,
2278
+ _r,
2279
+ Ar,
2280
+ Rr,
2281
+ fr,
2282
+ cr,
2283
+ mt,
2284
+ Ir,
2285
+ br
2286
+ ].forEach((o) => {
2287
+ const t = this._injector.createInstance(o);
2288
+ this.disposeWithMe(this._dataValidatorRegistryService.register(t)), this.disposeWithMe(qe(() => this._injector.delete(o)));
2529
2289
  });
2530
2290
  }
2531
2291
  _initCommandInterceptor() {
2532
2292
  this._sheetInterceptorService.interceptCommand({
2533
- getMutations: (s) => {
2293
+ getMutations: (o) => {
2534
2294
  var t;
2535
- if (s.id === Yt.id) {
2536
- const e = this._univerInstanceService.getCurrentUnitForType(K.UNIVER_SHEET), r = e.getUnitId(), i = e.getActiveSheet();
2537
- if (!i)
2295
+ if (o.id === Ut.id) {
2296
+ const e = this._univerInstanceService.getCurrentUnitForType(A.UNIVER_SHEET), r = e.getUnitId(), a = e.getActiveSheet();
2297
+ if (!a)
2538
2298
  throw new Error("No active sheet found");
2539
- const a = i.getSheetId(), n = (t = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : t.map((d) => d.range), o = this._sheetDataValidationModel.getRuleObjectMatrix(r, a).clone();
2540
- n && o.removeRange(n);
2541
- const l = o.diff(this._sheetDataValidationModel.getRules(r, a)), { redoMutations: u, undoMutations: c } = ze(r, a, l, this._injector, "patched");
2299
+ const i = a.getSheetId(), s = (t = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : t.map((d) => d.range), n = this._sheetDataValidationModel.getRuleObjectMatrix(r, i).clone();
2300
+ s && n.removeRange(s);
2301
+ const l = n.diff(this._sheetDataValidationModel.getRules(r, i)), { redoMutations: u, undoMutations: c } = Ae(r, i, l, this._injector, "patched");
2542
2302
  return {
2543
2303
  undos: c,
2544
2304
  redos: u
@@ -2552,97 +2312,236 @@ let ke = class extends At {
2552
2312
  });
2553
2313
  }
2554
2314
  };
2555
- ke = Zr([
2556
- Me(0, Z),
2557
- Me(1, E(ot)),
2558
- Me(2, E(st)),
2559
- Me(3, E(St)),
2560
- Me(4, E(Rt)),
2561
- Me(5, E(j))
2562
- ], ke);
2563
- var Et = /* @__PURE__ */ ((s) => (s[s.View = 0] = "View", s[s.Edit = 1] = "Edit", s[s.ManageCollaborator = 2] = "ManageCollaborator", s[s.Print = 3] = "Print", s[s.Duplicate = 4] = "Duplicate", s[s.Comment = 5] = "Comment", s[s.Copy = 6] = "Copy", s[s.Share = 7] = "Share", s[s.Export = 8] = "Export", s[s.MoveWorksheet = 9] = "MoveWorksheet", s[s.DeleteWorksheet = 10] = "DeleteWorksheet", s[s.HideWorksheet = 11] = "HideWorksheet", s[s.RenameWorksheet = 12] = "RenameWorksheet", s[s.CreateWorksheet = 13] = "CreateWorksheet", s[s.SetWorksheetStyle = 14] = "SetWorksheetStyle", s[s.EditWorksheetCell = 15] = "EditWorksheetCell", s[s.InsertHyperlink = 16] = "InsertHyperlink", s[s.Sort = 17] = "Sort", s[s.Filter = 18] = "Filter", s[s.PivotTable = 19] = "PivotTable", s[s.FloatImg = 20] = "FloatImg", s[s.History = 21] = "History", s[s.RwHgtClWdt = 22] = "RwHgtClWdt", s[s.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", s[s.ViewFilter = 24] = "ViewFilter", s[s.MoveSheet = 25] = "MoveSheet", s[s.DeleteSheet = 26] = "DeleteSheet", s[s.HideSheet = 27] = "HideSheet", s[s.CopySheet = 28] = "CopySheet", s[s.RenameSheet = 29] = "RenameSheet", s[s.CreateSheet = 30] = "CreateSheet", s[s.SelectProtectedCells = 31] = "SelectProtectedCells", s[s.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", s[s.SetCellStyle = 33] = "SetCellStyle", s[s.SetCellValue = 34] = "SetCellValue", s[s.SetRowStyle = 35] = "SetRowStyle", s[s.SetColumnStyle = 36] = "SetColumnStyle", s[s.InsertRow = 37] = "InsertRow", s[s.InsertColumn = 38] = "InsertColumn", s[s.DeleteRow = 39] = "DeleteRow", s[s.DeleteColumn = 40] = "DeleteColumn", s[s.EditExtraObject = 41] = "EditExtraObject", s[s.Delete = 42] = "Delete", s[s.RecoverHistory = 43] = "RecoverHistory", s[s.ViewHistory = 44] = "ViewHistory", s[s.CreatePermissionObject = 45] = "CreatePermissionObject", s[s.UNRECOGNIZED = -1] = "UNRECOGNIZED", s))(Et || {}), Jr = Object.defineProperty, ea = Object.getOwnPropertyDescriptor, ta = (s, t, e, r) => {
2564
- for (var i = r > 1 ? void 0 : r ? ea(t, e) : t, a = s.length - 1, n; a >= 0; a--)
2565
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
2566
- return r && i && Jr(t, e, i), i;
2567
- }, Je = (s, t) => (e, r) => t(e, r, s);
2568
- let We = class extends ce {
2569
- constructor(s, t, e) {
2570
- super(), this._univerInstanceService = s, this._permissionService = t, this._lexerTreeBuilder = e;
2571
- }
2572
- getFormulaRefCheck(s) {
2315
+ Me = Lr([
2316
+ te(0, D),
2317
+ te(1, v(Qe)),
2318
+ te(2, v(je)),
2319
+ te(3, v(ot)),
2320
+ te(4, v(nt)),
2321
+ te(5, v(F))
2322
+ ], Me);
2323
+ var _t = /* @__PURE__ */ ((o) => (o[o.View = 0] = "View", o[o.Edit = 1] = "Edit", o[o.ManageCollaborator = 2] = "ManageCollaborator", o[o.Print = 3] = "Print", o[o.Duplicate = 4] = "Duplicate", o[o.Comment = 5] = "Comment", o[o.Copy = 6] = "Copy", o[o.Share = 7] = "Share", o[o.Export = 8] = "Export", o[o.MoveWorksheet = 9] = "MoveWorksheet", o[o.DeleteWorksheet = 10] = "DeleteWorksheet", o[o.HideWorksheet = 11] = "HideWorksheet", o[o.RenameWorksheet = 12] = "RenameWorksheet", o[o.CreateWorksheet = 13] = "CreateWorksheet", o[o.SetWorksheetStyle = 14] = "SetWorksheetStyle", o[o.EditWorksheetCell = 15] = "EditWorksheetCell", o[o.InsertHyperlink = 16] = "InsertHyperlink", o[o.Sort = 17] = "Sort", o[o.Filter = 18] = "Filter", o[o.PivotTable = 19] = "PivotTable", o[o.FloatImg = 20] = "FloatImg", o[o.History = 21] = "History", o[o.RwHgtClWdt = 22] = "RwHgtClWdt", o[o.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", o[o.ViewFilter = 24] = "ViewFilter", o[o.MoveSheet = 25] = "MoveSheet", o[o.DeleteSheet = 26] = "DeleteSheet", o[o.HideSheet = 27] = "HideSheet", o[o.CopySheet = 28] = "CopySheet", o[o.RenameSheet = 29] = "RenameSheet", o[o.CreateSheet = 30] = "CreateSheet", o[o.SelectProtectedCells = 31] = "SelectProtectedCells", o[o.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", o[o.SetCellStyle = 33] = "SetCellStyle", o[o.SetCellValue = 34] = "SetCellValue", o[o.SetRowStyle = 35] = "SetRowStyle", o[o.SetColumnStyle = 36] = "SetColumnStyle", o[o.InsertRow = 37] = "InsertRow", o[o.InsertColumn = 38] = "InsertColumn", o[o.DeleteRow = 39] = "DeleteRow", o[o.DeleteColumn = 40] = "DeleteColumn", o[o.EditExtraObject = 41] = "EditExtraObject", o[o.Delete = 42] = "Delete", o[o.RecoverHistory = 43] = "RecoverHistory", o[o.ViewHistory = 44] = "ViewHistory", o[o.CreatePermissionObject = 45] = "CreatePermissionObject", o[o.UNRECOGNIZED = -1] = "UNRECOGNIZED", o))(_t || {}), Br = Object.defineProperty, Pr = Object.getOwnPropertyDescriptor, Ur = (o, t, e, r) => {
2324
+ for (var a = r > 1 ? void 0 : r ? Pr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2325
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2326
+ return r && a && Br(t, e, a), a;
2327
+ }, Ue = (o, t) => (e, r) => t(e, r, o);
2328
+ let ye = class extends W {
2329
+ constructor(o, t, e) {
2330
+ super(), this._univerInstanceService = o, this._permissionService = t, this._lexerTreeBuilder = e;
2331
+ }
2332
+ getFormulaRefCheck(o) {
2573
2333
  var e, r;
2574
- const t = this._lexerTreeBuilder.sequenceNodesBuilder(s);
2334
+ const t = this._lexerTreeBuilder.sequenceNodesBuilder(o);
2575
2335
  if (!t)
2576
2336
  return !0;
2577
- for (let i = 0; i < t.length; i++) {
2578
- const a = t[i];
2579
- if (typeof a == "string")
2337
+ for (let a = 0; a < t.length; a++) {
2338
+ const i = t[a];
2339
+ if (typeof i == "string")
2580
2340
  continue;
2581
- const { token: n } = a, o = ir(n), l = this._univerInstanceService.getCurrentUnitForType(K.UNIVER_SHEET);
2341
+ const { token: s } = i, n = Yt(s), l = this._univerInstanceService.getCurrentUnitForType(A.UNIVER_SHEET);
2582
2342
  let u = l.getActiveSheet();
2583
2343
  const c = l.getUnitId();
2584
- if (o.sheetName) {
2585
- if (u = l.getSheetBySheetName(o.sheetName), !u)
2344
+ if (n.sheetName) {
2345
+ if (u = l.getSheetBySheetName(n.sheetName), !u)
2586
2346
  return !1;
2587
- const w = u == null ? void 0 : u.getSheetId();
2588
- if (!this._permissionService.getPermissionPoint(new Xt(c, w).id)) return !1;
2347
+ const S = u == null ? void 0 : u.getSheetId();
2348
+ if (!this._permissionService.getPermissionPoint(new $t(c, S).id)) return !1;
2589
2349
  }
2590
2350
  if (!u)
2591
2351
  return !1;
2592
- const { startRow: d, endRow: m, startColumn: v, endColumn: S } = o.range;
2593
- for (let w = d; w <= m; w++)
2594
- for (let I = v; I <= S; I++) {
2595
- const M = (r = (e = u.getCell(w, I)) == null ? void 0 : e.selectionProtection) == null ? void 0 : r[0];
2596
- if ((M == null ? void 0 : M[Et.View]) === !1)
2352
+ const { startRow: d, endRow: m, startColumn: _, endColumn: p } = n.range;
2353
+ for (let S = d; S <= m; S++)
2354
+ for (let y = _; y <= p; y++) {
2355
+ const g = (r = (e = u.getCell(S, y)) == null ? void 0 : e.selectionProtection) == null ? void 0 : r[0];
2356
+ if ((g == null ? void 0 : g[_t.View]) === !1)
2597
2357
  return !1;
2598
2358
  }
2599
2359
  }
2600
2360
  return !0;
2601
2361
  }
2602
2362
  };
2603
- We = ta([
2604
- Je(0, Z),
2605
- Je(1, Lt),
2606
- Je(2, E(ut))
2607
- ], We);
2608
- var ra = Object.defineProperty, aa = Object.getOwnPropertyDescriptor, ia = (s, t, e, r) => {
2609
- for (var i = r > 1 ? void 0 : r ? aa(t, e) : t, a = s.length - 1, n; a >= 0; a--)
2610
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
2611
- return r && i && ra(t, e, i), i;
2612
- }, Ne = (s, t) => (e, r) => t(e, r, s);
2613
- let je = class extends ce {
2614
- constructor(t, e, r, i, a, n) {
2363
+ ye = Ur([
2364
+ Ue(0, D),
2365
+ Ue(1, Tt),
2366
+ Ue(2, v(Z))
2367
+ ], ye);
2368
+ var $r = Object.defineProperty, Hr = Object.getOwnPropertyDescriptor, Wr = (o, t, e, r) => {
2369
+ for (var a = r > 1 ? void 0 : r ? Hr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2370
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2371
+ return r && a && $r(t, e, a), a;
2372
+ }, at = (o, t) => (e, r) => t(e, r, o);
2373
+ let Ee = class extends W {
2374
+ constructor(t, e) {
2615
2375
  super();
2616
- g(this, "_disposableMap", /* @__PURE__ */ new Map());
2617
- g(this, "registerRule", (t, e, r) => {
2618
- this.register(t, e, r), this.registerFormula(t, e, r);
2376
+ f(this, "_disposableMap", /* @__PURE__ */ new Map());
2377
+ f(this, "registerRule", (t, e, r) => {
2378
+ le(r.type) && this.register(t, e, r);
2619
2379
  });
2620
- this._dataValidationModel = t, this._injector = e, this._refRangeService = r, this._dataValidationCustomFormulaService = i, this._dataValidationFormulaService = a, this._formulaRefRangeService = n, this._initRefRange();
2380
+ this._dataValidationModel = t, this._formulaRefRangeService = e, this._initRefRange();
2621
2381
  }
2622
2382
  _getIdWithUnitId(t, e, r) {
2623
2383
  return `${t}_${e}_${r}`;
2624
2384
  }
2625
2385
  // eslint-disable-next-line max-lines-per-function
2386
+ register(t, e, r) {
2387
+ const a = r.ranges, i = r.formula1, s = r.formula2, n = this._formulaRefRangeService.registerRangeFormula(t, e, a, [i != null ? i : "", s != null ? s : ""], (u) => {
2388
+ if (u.length === 0)
2389
+ return {
2390
+ undos: [{
2391
+ id: U.id,
2392
+ params: {
2393
+ unitId: t,
2394
+ subUnitId: e,
2395
+ rule: r
2396
+ }
2397
+ }],
2398
+ redos: [{
2399
+ id: P.id,
2400
+ params: {
2401
+ unitId: t,
2402
+ subUnitId: e,
2403
+ ruleId: r.uid
2404
+ }
2405
+ }]
2406
+ };
2407
+ const c = [], d = [], m = u[0];
2408
+ c.push({
2409
+ id: b.id,
2410
+ params: {
2411
+ unitId: t,
2412
+ subUnitId: e,
2413
+ ruleId: r.uid,
2414
+ payload: {
2415
+ type: w.ALL,
2416
+ payload: {
2417
+ ranges: m.ranges,
2418
+ formula1: m.formulas[0],
2419
+ formula2: m.formulas[1]
2420
+ }
2421
+ }
2422
+ }
2423
+ }), d.push({
2424
+ id: b.id,
2425
+ params: {
2426
+ unitId: t,
2427
+ subUnitId: e,
2428
+ ruleId: r.uid,
2429
+ payload: {
2430
+ type: w.ALL,
2431
+ payload: {
2432
+ ranges: a,
2433
+ formula1: i,
2434
+ formula2: s
2435
+ }
2436
+ }
2437
+ }
2438
+ });
2439
+ for (let _ = 1; _ < u.length; _++) {
2440
+ const p = u[_], S = wt();
2441
+ c.push({
2442
+ id: U.id,
2443
+ params: {
2444
+ unitId: t,
2445
+ subUnitId: e,
2446
+ rule: {
2447
+ ...r,
2448
+ uid: S,
2449
+ formula1: p.formulas[0],
2450
+ formula2: p.formulas[1],
2451
+ ranges: p.ranges
2452
+ }
2453
+ }
2454
+ }), d.push({
2455
+ id: P.id,
2456
+ params: {
2457
+ unitId: t,
2458
+ subUnitId: e,
2459
+ ruleId: S
2460
+ }
2461
+ });
2462
+ }
2463
+ return {
2464
+ undos: d,
2465
+ redos: c
2466
+ };
2467
+ }), l = this._getIdWithUnitId(t, e, r.uid);
2468
+ this._disposableMap.set(l, n);
2469
+ }
2470
+ _initRefRange() {
2471
+ const t = this._dataValidationModel.getAll();
2472
+ for (const [e, r] of t)
2473
+ for (const [a, i] of r)
2474
+ for (const s of i)
2475
+ this.registerRule(e, a, s);
2476
+ this.disposeWithMe(
2477
+ this._dataValidationModel.ruleChange$.subscribe((e) => {
2478
+ const { unitId: r, subUnitId: a, rule: i } = e;
2479
+ switch (e.type) {
2480
+ case "add": {
2481
+ const s = e.rule;
2482
+ this.registerRule(e.unitId, e.subUnitId, s);
2483
+ break;
2484
+ }
2485
+ case "remove": {
2486
+ const s = this._disposableMap.get(this._getIdWithUnitId(r, a, i.uid));
2487
+ s && s.dispose();
2488
+ break;
2489
+ }
2490
+ case "update": {
2491
+ const s = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(r, a, s.uid));
2492
+ n && n.dispose(), this.registerRule(e.unitId, e.subUnitId, s);
2493
+ break;
2494
+ }
2495
+ }
2496
+ })
2497
+ ), this.disposeWithMe(qe(() => {
2498
+ this._disposableMap.forEach((e) => {
2499
+ e.dispose();
2500
+ }), this._disposableMap.clear();
2501
+ }));
2502
+ }
2503
+ };
2504
+ Ee = Wr([
2505
+ at(0, v(F)),
2506
+ at(1, v(ut))
2507
+ ], Ee);
2508
+ var kr = Object.defineProperty, jr = Object.getOwnPropertyDescriptor, qr = (o, t, e, r) => {
2509
+ for (var a = r > 1 ? void 0 : r ? jr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2510
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2511
+ return r && a && kr(t, e, a), a;
2512
+ }, re = (o, t) => (e, r) => t(e, r, o);
2513
+ let Te = class extends W {
2514
+ constructor(t, e, r, a, i, s) {
2515
+ super();
2516
+ f(this, "_disposableMap", /* @__PURE__ */ new Map());
2517
+ f(this, "registerRule", (t, e, r) => {
2518
+ le(r.type) || (this.register(t, e, r), this.registerFormula(t, e, r));
2519
+ });
2520
+ this._dataValidationModel = t, this._injector = e, this._refRangeService = r, this._dataValidationCustomFormulaService = a, this._dataValidationFormulaService = i, this._formulaRefRangeService = s, this._initRefRange();
2521
+ }
2522
+ _getIdWithUnitId(t, e, r) {
2523
+ return `${t}_${e}_${r}`;
2524
+ }
2626
2525
  registerFormula(t, e, r) {
2627
- var l;
2628
- const i = r.uid, a = this._getIdWithUnitId(t, e, i), n = (l = this._disposableMap.get(a)) != null ? l : /* @__PURE__ */ new Set(), o = (u, c) => {
2629
- const d = this._dataValidationModel.getRuleById(t, e, i);
2630
- if (!d)
2526
+ var u;
2527
+ const a = r.uid, i = this._getIdWithUnitId(t, e, a), s = (u = this._disposableMap.get(i)) != null ? u : /* @__PURE__ */ new Set(), n = (c, d) => {
2528
+ const m = this._dataValidationModel.getRuleById(t, e, a);
2529
+ if (!m)
2631
2530
  return { redos: [], undos: [] };
2632
- const m = d[u];
2633
- if (!m || m === c)
2531
+ const _ = m[c];
2532
+ if (!_ || _ === d)
2634
2533
  return { redos: [], undos: [] };
2635
- const v = {
2534
+ const p = {
2636
2535
  unitId: t,
2637
2536
  subUnitId: e,
2638
2537
  ruleId: r.uid,
2639
2538
  payload: {
2640
- type: Y.SETTING,
2539
+ type: w.SETTING,
2641
2540
  payload: {
2642
- type: d.type,
2643
- formula1: d.formula1,
2644
- formula2: d.formula2,
2645
- [u]: c
2541
+ type: m.type,
2542
+ formula1: m.formula1,
2543
+ formula2: m.formula2,
2544
+ [c]: d
2646
2545
  }
2647
2546
  }
2648
2547
  }, S = {
@@ -2650,188 +2549,174 @@ let je = class extends ce {
2650
2549
  subUnitId: e,
2651
2550
  ruleId: r.uid,
2652
2551
  payload: {
2653
- type: Y.SETTING,
2552
+ type: w.SETTING,
2654
2553
  payload: {
2655
- type: d.type,
2656
- formula1: d.formula1,
2657
- formula2: d.formula2
2554
+ type: m.type,
2555
+ formula1: m.formula1,
2556
+ formula2: m.formula2
2658
2557
  }
2659
2558
  }
2660
- }, w = [
2559
+ }, y = [
2661
2560
  {
2662
- id: X.id,
2663
- params: v
2561
+ id: b.id,
2562
+ params: p
2664
2563
  }
2665
- ], I = [
2564
+ ], g = [
2666
2565
  {
2667
- id: X.id,
2566
+ id: b.id,
2668
2567
  params: S
2669
2568
  }
2670
2569
  ];
2671
- return { redos: w, undos: I };
2672
- };
2673
- if (r.type === $.CUSTOM) {
2674
- const u = this._dataValidationCustomFormulaService.getRuleFormulaInfo(t, e, i);
2675
- if (u) {
2676
- const c = this._formulaRefRangeService.registerFormula(
2570
+ return { redos: y, undos: g };
2571
+ }, l = this._dataValidationFormulaService.getRuleFormulaInfo(t, e, a);
2572
+ if (l) {
2573
+ const [c, d] = l;
2574
+ if (c) {
2575
+ const m = this._formulaRefRangeService.registerFormula(
2677
2576
  t,
2678
2577
  e,
2679
- u.formula,
2680
- (d) => o("formula1", d)
2578
+ c.text,
2579
+ (_) => n("formula1", _)
2681
2580
  );
2682
- n.add(() => c.dispose());
2581
+ s.add(() => m.dispose());
2683
2582
  }
2684
- } else {
2685
- const u = this._dataValidationFormulaService.getRuleFormulaInfo(t, e, i);
2686
- if (u) {
2687
- const [c, d] = u;
2688
- if (c) {
2689
- const m = this._formulaRefRangeService.registerFormula(
2690
- t,
2691
- e,
2692
- c.text,
2693
- (v) => o("formula1", v)
2694
- );
2695
- n.add(() => m.dispose());
2696
- }
2697
- if (d) {
2698
- const m = this._formulaRefRangeService.registerFormula(
2699
- t,
2700
- e,
2701
- d.text,
2702
- (v) => o("formula2", v)
2703
- );
2704
- n.add(() => m.dispose());
2705
- }
2583
+ if (d) {
2584
+ const m = this._formulaRefRangeService.registerFormula(
2585
+ t,
2586
+ e,
2587
+ d.text,
2588
+ (_) => n("formula2", _)
2589
+ );
2590
+ s.add(() => m.dispose());
2706
2591
  }
2707
2592
  }
2708
2593
  }
2709
2594
  register(t, e, r) {
2710
2595
  var l;
2711
- const i = (u) => {
2712
- const c = [...r.ranges], m = c.map((S) => Kt(S, u)).filter((S) => !!S).flat();
2713
- if (Ut(m, c))
2596
+ const a = (u) => {
2597
+ const c = [...r.ranges], m = c.map((p) => Wt(p, u)).filter((p) => !!p).flat();
2598
+ if (Ft(m, c))
2714
2599
  return { redos: [], undos: [] };
2715
2600
  if (m.length) {
2716
- const S = {
2601
+ const p = {
2717
2602
  unitId: t,
2718
2603
  subUnitId: e,
2719
2604
  ruleId: r.uid,
2720
2605
  payload: {
2721
- type: Y.RANGE,
2606
+ type: w.RANGE,
2722
2607
  payload: m
2723
2608
  },
2724
2609
  source: "patched"
2725
- }, w = [{ id: X.id, params: S }], I = [{
2726
- id: X.id,
2610
+ }, S = [{ id: b.id, params: p }], y = [{
2611
+ id: b.id,
2727
2612
  params: {
2728
2613
  unitId: t,
2729
2614
  subUnitId: e,
2730
2615
  ruleId: r.uid,
2731
2616
  payload: {
2732
- type: Y.RANGE,
2617
+ type: w.RANGE,
2733
2618
  payload: c
2734
2619
  },
2735
2620
  source: "patched"
2736
2621
  }
2737
2622
  }];
2738
- return { redos: w, undos: I };
2623
+ return { redos: S, undos: y };
2739
2624
  } else {
2740
- const S = { unitId: t, subUnitId: e, ruleId: r.uid }, w = [{ id: ie.id, params: S }], I = kr(this._injector, S);
2741
- return { redos: w, undos: I };
2625
+ const p = { unitId: t, subUnitId: e, ruleId: r.uid }, S = [{ id: P.id, params: p }], y = Tr(this._injector, p);
2626
+ return { redos: S, undos: y };
2742
2627
  }
2743
- }, a = [];
2628
+ }, i = [];
2744
2629
  r.ranges.forEach((u) => {
2745
- const c = this._refRangeService.registerRefRange(u, i, t, e);
2746
- a.push(() => c.dispose());
2630
+ const c = this._refRangeService.registerRefRange(u, a, t, e);
2631
+ i.push(() => c.dispose());
2747
2632
  });
2748
- const n = this._getIdWithUnitId(t, e, r.uid), o = (l = this._disposableMap.get(n)) != null ? l : /* @__PURE__ */ new Set();
2749
- o.add(() => a.forEach((u) => u())), this._disposableMap.set(n, o);
2633
+ const s = this._getIdWithUnitId(t, e, r.uid), n = (l = this._disposableMap.get(s)) != null ? l : /* @__PURE__ */ new Set();
2634
+ n.add(() => i.forEach((u) => u())), this._disposableMap.set(s, n);
2750
2635
  }
2751
2636
  _initRefRange() {
2752
2637
  const t = this._dataValidationModel.getAll();
2753
2638
  for (const [e, r] of t)
2754
- for (const [i, a] of r)
2755
- for (const n of a)
2756
- this.registerRule(e, i, n);
2639
+ for (const [a, i] of r)
2640
+ for (const s of i)
2641
+ this.registerRule(e, a, s);
2757
2642
  this.disposeWithMe(
2758
2643
  this._dataValidationModel.ruleChange$.subscribe((e) => {
2759
- const { unitId: r, subUnitId: i, rule: a } = e;
2644
+ const { unitId: r, subUnitId: a, rule: i } = e;
2760
2645
  switch (e.type) {
2761
2646
  case "add": {
2762
- const n = e.rule;
2763
- this.registerRule(e.unitId, e.subUnitId, n);
2647
+ const s = e.rule;
2648
+ this.registerRule(e.unitId, e.subUnitId, s);
2764
2649
  break;
2765
2650
  }
2766
2651
  case "remove": {
2767
- const n = this._disposableMap.get(this._getIdWithUnitId(r, i, a.uid));
2768
- n && n.forEach((o) => o());
2652
+ const s = this._disposableMap.get(this._getIdWithUnitId(r, a, i.uid));
2653
+ s && s.forEach((n) => n());
2769
2654
  break;
2770
2655
  }
2771
2656
  case "update": {
2772
- const n = e.rule, o = this._disposableMap.get(this._getIdWithUnitId(r, i, n.uid));
2773
- o && o.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId, n);
2657
+ const s = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(r, a, s.uid));
2658
+ n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId, s);
2774
2659
  break;
2775
2660
  }
2776
2661
  }
2777
2662
  })
2778
- ), this.disposeWithMe(gt(() => {
2663
+ ), this.disposeWithMe(qe(() => {
2779
2664
  this._disposableMap.forEach((e) => {
2780
2665
  e.forEach((r) => r());
2781
2666
  }), this._disposableMap.clear();
2782
2667
  }));
2783
2668
  }
2784
2669
  };
2785
- je = ia([
2786
- Ne(0, E(j)),
2787
- Ne(1, E(st)),
2788
- Ne(2, E(zt)),
2789
- Ne(3, E(we)),
2790
- Ne(4, E(te)),
2791
- Ne(5, E(er))
2792
- ], je);
2793
- var sa = Object.defineProperty, na = Object.getOwnPropertyDescriptor, oa = (s, t, e, r) => {
2794
- for (var i = r > 1 ? void 0 : r ? na(t, e) : t, a = s.length - 1, n; a >= 0; a--)
2795
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
2796
- return r && i && sa(t, e, i), i;
2797
- }, et = (s, t) => (e, r) => t(e, r, s);
2798
- let qe = class extends ce {
2799
- constructor(s, t, e) {
2800
- super(), this._sheetInterceptorService = s, this._univerInstanceService = t, this._sheetDataValidationModel = e, this._initSheetChange();
2670
+ Te = qr([
2671
+ re(0, v(F)),
2672
+ re(1, v(je)),
2673
+ re(2, v(Ht)),
2674
+ re(3, v($)),
2675
+ re(4, v(X)),
2676
+ re(5, v(ut))
2677
+ ], Te);
2678
+ var Gr = Object.defineProperty, Qr = Object.getOwnPropertyDescriptor, Yr = (o, t, e, r) => {
2679
+ for (var a = r > 1 ? void 0 : r ? Qr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2680
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2681
+ return r && a && Gr(t, e, a), a;
2682
+ }, $e = (o, t) => (e, r) => t(e, r, o);
2683
+ let we = class extends W {
2684
+ constructor(o, t, e) {
2685
+ super(), this._sheetInterceptorService = o, this._univerInstanceService = t, this._sheetDataValidationModel = e, this._initSheetChange();
2801
2686
  }
2802
2687
  _initSheetChange() {
2803
2688
  this.disposeWithMe(
2804
2689
  this._sheetInterceptorService.interceptCommand({
2805
- getMutations: (s) => {
2690
+ getMutations: (o) => {
2806
2691
  var t;
2807
- if (s.id === Zt.id) {
2808
- const e = s.params, r = e.unitId || this._univerInstanceService.getCurrentUnitForType(K.UNIVER_SHEET).getUnitId(), i = this._univerInstanceService.getUniverSheetInstance(r);
2809
- if (!i)
2810
- return { redos: [], undos: [] };
2811
- const a = e.subUnitId || ((t = i.getActiveSheet()) == null ? void 0 : t.getSheetId());
2692
+ if (o.id === kt.id) {
2693
+ const e = o.params, r = e.unitId || this._univerInstanceService.getCurrentUnitForType(A.UNIVER_SHEET).getUnitId(), a = this._univerInstanceService.getUniverSheetInstance(r);
2812
2694
  if (!a)
2813
2695
  return { redos: [], undos: [] };
2814
- const n = this._sheetDataValidationModel.getRules(r, a);
2815
- if (n.length === 0)
2696
+ const i = e.subUnitId || ((t = a.getActiveSheet()) == null ? void 0 : t.getSheetId());
2697
+ if (!i)
2698
+ return { redos: [], undos: [] };
2699
+ const s = this._sheetDataValidationModel.getRules(r, i);
2700
+ if (s.length === 0)
2816
2701
  return { redos: [], undos: [] };
2817
- const o = n.map((c) => c.uid), l = {
2702
+ const n = s.map((c) => c.uid), l = {
2818
2703
  unitId: r,
2819
- subUnitId: a,
2820
- ruleId: o,
2704
+ subUnitId: i,
2705
+ ruleId: n,
2821
2706
  source: "patched"
2822
2707
  }, u = {
2823
2708
  unitId: r,
2824
- subUnitId: a,
2825
- rule: [...n],
2709
+ subUnitId: i,
2710
+ rule: [...s],
2826
2711
  source: "patched"
2827
2712
  };
2828
2713
  return {
2829
2714
  redos: [{
2830
- id: ie.id,
2715
+ id: P.id,
2831
2716
  params: l
2832
2717
  }],
2833
2718
  undos: [{
2834
- id: le.id,
2719
+ id: U.id,
2835
2720
  params: u
2836
2721
  }]
2837
2722
  };
@@ -2842,188 +2727,189 @@ let qe = class extends ce {
2842
2727
  );
2843
2728
  }
2844
2729
  };
2845
- qe = oa([
2846
- et(0, E(Rt)),
2847
- et(1, E(Z)),
2848
- et(2, E(j))
2849
- ], qe);
2850
- var la = Object.defineProperty, ua = Object.getOwnPropertyDescriptor, ca = (s, t, e, r) => {
2851
- for (var i = r > 1 ? void 0 : r ? ua(t, e) : t, a = s.length - 1, n; a >= 0; a--)
2852
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
2853
- return r && i && la(t, e, i), i;
2854
- }, Ae = (s, t) => (e, r) => t(e, r, s);
2855
- let Ge = class extends ce {
2856
- constructor(s, t, e, r) {
2857
- super(), this._univerInstanceService = s, this._sheetDataValidationModel = t, this._dataValidationCacheService = e, this._lifecycleService = r, this._initRecalculate();
2730
+ we = Yr([
2731
+ $e(0, v(nt)),
2732
+ $e(1, v(D)),
2733
+ $e(2, v(F))
2734
+ ], we);
2735
+ var Xr = Object.defineProperty, Kr = Object.getOwnPropertyDescriptor, zr = (o, t, e, r) => {
2736
+ for (var a = r > 1 ? void 0 : r ? Kr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2737
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2738
+ return r && a && Xr(t, e, a), a;
2739
+ }, ge = (o, t) => (e, r) => t(e, r, o);
2740
+ let Fe = class extends W {
2741
+ constructor(o, t, e, r) {
2742
+ super(), this._univerInstanceService = o, this._sheetDataValidationModel = t, this._dataValidationCacheService = e, this._lifecycleService = r, this._initRecalculate();
2858
2743
  }
2859
2744
  _initRecalculate() {
2860
- const s = (t) => {
2745
+ const o = (t) => {
2861
2746
  if (t.length === 0)
2862
2747
  return;
2863
- const e = this._univerInstanceService.getCurrentUnitForType(K.UNIVER_SHEET), r = e == null ? void 0 : e.getActiveSheet(), i = {};
2864
- t.flat().forEach((a) => {
2865
- i[a.unitId] || (i[a.unitId] = {}), i[a.unitId][a.subUnitId] || (i[a.unitId][a.subUnitId] = []);
2866
- const n = this._univerInstanceService.getUnit(a.unitId, K.UNIVER_SHEET), o = n == null ? void 0 : n.getSheetBySheetId(a.subUnitId);
2867
- o && i[a.unitId][a.subUnitId].push(...a.ranges.map((l) => Q.transformRange(l, o)));
2868
- }), Object.entries(i).forEach(([a, n]) => {
2869
- Object.entries(n).forEach(([o, l]) => {
2870
- (e == null ? void 0 : e.getUnitId()) === a && (r == null ? void 0 : r.getSheetId()) === o ? this.validatorRanges(a, o, l) : requestIdleCallback(() => {
2871
- this.validatorRanges(a, o, l);
2748
+ const e = this._univerInstanceService.getCurrentUnitForType(A.UNIVER_SHEET), r = e == null ? void 0 : e.getActiveSheet(), a = {};
2749
+ t.flat().forEach((i) => {
2750
+ a[i.unitId] || (a[i.unitId] = {}), a[i.unitId][i.subUnitId] || (a[i.unitId][i.subUnitId] = []);
2751
+ const s = this._univerInstanceService.getUnit(i.unitId, A.UNIVER_SHEET), n = s == null ? void 0 : s.getSheetBySheetId(i.subUnitId);
2752
+ n && a[i.unitId][i.subUnitId].push(...i.ranges.map((l) => I.transformRange(l, n)));
2753
+ }), Object.entries(a).forEach(([i, s]) => {
2754
+ Object.entries(s).forEach(([n, l]) => {
2755
+ (e == null ? void 0 : e.getUnitId()) === i && (r == null ? void 0 : r.getSheetId()) === n ? this.validatorRanges(i, n, l) : requestIdleCallback(() => {
2756
+ this.validatorRanges(i, n, l);
2872
2757
  });
2873
2758
  });
2874
2759
  });
2875
2760
  };
2876
- this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Jt(() => this._lifecycleService.lifecycle$.pipe(mt((t) => t === ht.Rendered)))).subscribe(s)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(mt(() => this._lifecycleService.stage >= ht.Rendered), Pt(20)).subscribe(s));
2761
+ this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(jt(() => this._lifecycleService.lifecycle$.pipe(tt((t) => t === et.Rendered)))).subscribe(o)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(tt(() => this._lifecycleService.stage >= et.Rendered), Ot(20)).subscribe(o));
2877
2762
  }
2878
- async validatorCell(s, t, e, r) {
2879
- const i = this._univerInstanceService.getUnit(s, K.UNIVER_SHEET);
2880
- if (!i)
2881
- throw new Error(`cannot find current workbook, unitId: ${s}`);
2882
- const a = i.getSheetBySheetId(t);
2763
+ async validatorCell(o, t, e, r) {
2764
+ const a = this._univerInstanceService.getUnit(o, A.UNIVER_SHEET);
2883
2765
  if (!a)
2766
+ throw new Error(`cannot find current workbook, unitId: ${o}`);
2767
+ const i = a.getSheetBySheetId(t);
2768
+ if (!i)
2884
2769
  throw new Error(`cannot find current worksheet, sheetId: ${t}`);
2885
- if (!b.isDefine(e) || !b.isDefine(r))
2770
+ if (!N.isDefine(e) || !N.isDefine(r))
2886
2771
  throw new Error(`row or col is not defined, row: ${e}, col: ${r}`);
2887
- const n = this._sheetDataValidationModel.getRuleByLocation(s, t, e, r);
2888
- return n ? new Promise((o) => {
2889
- this._sheetDataValidationModel.validator(n, { unitId: s, subUnitId: t, row: e, col: r, worksheet: a, workbook: i }, (l) => {
2890
- o(l);
2772
+ const s = this._sheetDataValidationModel.getRuleByLocation(o, t, e, r);
2773
+ return s ? new Promise((n) => {
2774
+ this._sheetDataValidationModel.validator(s, { unitId: o, subUnitId: t, row: e, col: r, worksheet: i, workbook: a }, (l) => {
2775
+ n(l);
2891
2776
  });
2892
- }) : ge.VALID;
2777
+ }) : Y.VALID;
2893
2778
  }
2894
- validatorRanges(s, t, e) {
2779
+ validatorRanges(o, t, e) {
2895
2780
  return Promise.all(e.map((r) => {
2896
- const i = [];
2897
- return Q.foreach(r, (a, n) => {
2898
- i.push(this.validatorCell(s, t, a, n));
2899
- }), i;
2900
- }));
2901
- }
2902
- async validatorWorksheet(s, t) {
2903
- const e = this._sheetDataValidationModel.getRules(s, t);
2904
- return await Promise.all(e.map((r) => Promise.all(r.ranges.map((i) => {
2905
2781
  const a = [];
2906
- return Q.foreach(i, (n, o) => {
2907
- a.push(this.validatorCell(s, t, n, o));
2782
+ return I.foreach(r, (i, s) => {
2783
+ a.push(this.validatorCell(o, t, i, s));
2908
2784
  }), a;
2909
- })))), this._dataValidationCacheService.ensureCache(s, t);
2785
+ }));
2786
+ }
2787
+ async validatorWorksheet(o, t) {
2788
+ const e = this._sheetDataValidationModel.getRules(o, t);
2789
+ return await Promise.all(e.map((r) => Promise.all(r.ranges.map((a) => {
2790
+ const i = [];
2791
+ return I.foreach(a, (s, n) => {
2792
+ i.push(this.validatorCell(o, t, s, n));
2793
+ }), i;
2794
+ })))), this._dataValidationCacheService.ensureCache(o, t);
2910
2795
  }
2911
- async validatorWorkbook(s) {
2912
- const t = this._sheetDataValidationModel.getSubUnitIds(s), e = await Promise.all(t.map((i) => this.validatorWorksheet(s, i))), r = {};
2913
- return e.forEach((i, a) => {
2914
- r[t[a]] = i;
2796
+ async validatorWorkbook(o) {
2797
+ const t = this._sheetDataValidationModel.getSubUnitIds(o), e = await Promise.all(t.map((a) => this.validatorWorksheet(o, a))), r = {};
2798
+ return e.forEach((a, i) => {
2799
+ r[t[i]] = a;
2915
2800
  }), r;
2916
2801
  }
2917
- getDataValidations(s, t, e) {
2918
- const r = this._sheetDataValidationModel.getRuleObjectMatrix(s, t), i = /* @__PURE__ */ new Set();
2919
- return e.forEach((n) => {
2920
- Q.foreach(n, (o, l) => {
2921
- const u = r.getValue(o, l);
2922
- u && i.add(u);
2802
+ getDataValidations(o, t, e) {
2803
+ const r = this._sheetDataValidationModel.getRuleObjectMatrix(o, t), a = /* @__PURE__ */ new Set();
2804
+ return e.forEach((s) => {
2805
+ I.foreach(s, (n, l) => {
2806
+ const u = r.getValue(n, l);
2807
+ u && a.add(u);
2923
2808
  });
2924
- }), Array.from(i).map((n) => this._sheetDataValidationModel.getRuleById(s, t, n)).filter(Boolean);
2809
+ }), Array.from(a).map((s) => this._sheetDataValidationModel.getRuleById(o, t, s)).filter(Boolean);
2925
2810
  }
2926
- getDataValidation(s, t, e) {
2927
- return this.getDataValidations(s, t, e)[0];
2811
+ getDataValidation(o, t, e) {
2812
+ return this.getDataValidations(o, t, e)[0];
2928
2813
  }
2929
2814
  };
2930
- Ge = ca([
2931
- Ae(0, Z),
2932
- Ae(1, E(j)),
2933
- Ae(2, E(ue)),
2934
- Ae(3, E(Bt))
2935
- ], Ge);
2936
- var Ct = Object.defineProperty, da = Object.getOwnPropertyDescriptor, ha = (s, t, e) => t in s ? Ct(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, ma = (s, t, e, r) => {
2937
- for (var i = r > 1 ? void 0 : r ? da(t, e) : t, a = s.length - 1, n; a >= 0; a--)
2938
- (n = s[a]) && (i = (r ? n(t, e, i) : n(i)) || i);
2939
- return r && i && Ct(t, e, i), i;
2940
- }, tt = (s, t) => (e, r) => t(e, r, s), Ot = (s, t, e) => ha(s, typeof t != "symbol" ? t + "" : t, e);
2941
- let Qe = class extends kt {
2942
- constructor(s = qr, t, e, r) {
2943
- super(), this._config = s, this._injector = t, this._commandService = e, this._configService = r;
2944
- const { ...i } = this._config;
2945
- this._configService.setConfig(jr, i);
2815
+ Fe = zr([
2816
+ ge(0, D),
2817
+ ge(1, v(F)),
2818
+ ge(2, v(j)),
2819
+ ge(3, v(Ct))
2820
+ ], Fe);
2821
+ var pt = Object.defineProperty, Zr = Object.getOwnPropertyDescriptor, Jr = (o, t, e) => t in o ? pt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, ea = (o, t, e, r) => {
2822
+ for (var a = r > 1 ? void 0 : r ? Zr(t, e) : t, i = o.length - 1, s; i >= 0; i--)
2823
+ (s = o[i]) && (a = (r ? s(t, e, a) : s(a)) || a);
2824
+ return r && a && pt(t, e, a), a;
2825
+ }, He = (o, t) => (e, r) => t(e, r, o), gt = (o, t, e) => Jr(o, typeof t != "symbol" ? t + "" : t, e);
2826
+ let Ce = class extends It {
2827
+ constructor(o = Cr, t, e, r) {
2828
+ super(), this._config = o, this._injector = t, this._commandService = e, this._configService = r;
2829
+ const { ...a } = this._config;
2830
+ this._configService.setConfig(Fr, a);
2946
2831
  }
2947
2832
  onStarting() {
2948
2833
  [
2949
- [ue],
2950
- [te],
2951
- [we],
2952
- [Ge],
2953
2834
  [j],
2954
- [ke],
2955
- [je],
2956
- [We],
2957
- [qe]
2958
- ].forEach((s) => {
2959
- this._injector.add(s);
2835
+ [X],
2836
+ [$],
2837
+ [Fe],
2838
+ [F],
2839
+ [Me],
2840
+ [ye],
2841
+ [we],
2842
+ [Te],
2843
+ [Ee]
2844
+ ].forEach((o) => {
2845
+ this._injector.add(o);
2960
2846
  }), [
2961
- Lr,
2962
- Ar,
2963
- Ur,
2964
- Br,
2965
- Wr,
2966
- Hr,
2967
- Pr
2968
- ].forEach((s) => {
2969
- this._commandService.registerCommand(s);
2970
- }), this._injector.get(ue), this._injector.get(Ge), this._injector.get(je);
2847
+ Vr,
2848
+ Sr,
2849
+ Nr,
2850
+ Mr,
2851
+ wr,
2852
+ Er,
2853
+ yr
2854
+ ].forEach((o) => {
2855
+ this._commandService.registerCommand(o);
2856
+ }), this._injector.get(j), this._injector.get(Fe), this._injector.get(Ee), this._injector.get(Te);
2971
2857
  }
2972
2858
  onReady() {
2973
- this._injector.get(qe);
2859
+ this._injector.get(we);
2974
2860
  }
2975
2861
  onRendered() {
2976
- this._injector.get(ke), this._injector.get(We);
2862
+ this._injector.get(Me), this._injector.get(ye);
2977
2863
  }
2978
2864
  };
2979
- Ot(Qe, "pluginName", sr);
2980
- Ot(Qe, "type", K.UNIVER_SHEET);
2981
- Qe = ma([
2982
- Ht(Gt),
2983
- tt(1, E(st)),
2984
- tt(2, re),
2985
- tt(3, Wt)
2986
- ], Qe);
2987
- function Na(s) {
2988
- const e = s.get(St).getCurrentSelections().map((a) => a.range);
2865
+ gt(Ce, "pluginName", Xt);
2866
+ gt(Ce, "type", A.UNIVER_SHEET);
2867
+ Ce = ea([
2868
+ bt(Bt),
2869
+ He(1, v(je)),
2870
+ He(2, H),
2871
+ He(3, At)
2872
+ ], Ce);
2873
+ function ca(o) {
2874
+ const e = o.get(ot).getCurrentSelections().map((i) => i.range);
2989
2875
  return {
2990
- uid: b.generateRandomId(6),
2991
- type: $.DECIMAL,
2992
- operator: _.EQUAL,
2876
+ uid: N.generateRandomId(6),
2877
+ type: M.DECIMAL,
2878
+ operator: h.EQUAL,
2993
2879
  formula1: "100",
2994
2880
  ranges: e != null ? e : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
2995
2881
  };
2996
2882
  }
2997
2883
  export {
2998
- Lr as AddSheetDataValidationCommand,
2999
- Be as CHECKBOX_FORMULA_1,
3000
- Pe as CHECKBOX_FORMULA_2,
3001
- yr as CheckboxValidator,
3002
- Pr as ClearRangeDataValidationCommand,
3003
- sr as DATA_VALIDATION_PLUGIN_NAME,
3004
- ue as DataValidationCacheService,
3005
- we as DataValidationCustomFormulaService,
3006
- We as DataValidationFormulaController,
3007
- te as DataValidationFormulaService,
3008
- Er as DateValidator,
3009
- Yr as ListMultipleValidator,
3010
- Tt as ListValidator,
3011
- Hr as RemoveSheetAllDataValidationCommand,
3012
- Wr as RemoveSheetDataValidationCommand,
3013
- j as SheetDataValidationModel,
3014
- Ge as SheetsDataValidationValidatorService,
3015
- Qe as UniverSheetsDataValidationPlugin,
3016
- Br as UpdateSheetDataValidationOptionsCommand,
3017
- Ar as UpdateSheetDataValidationRangeCommand,
3018
- Ur as UpdateSheetDataValidationSettingCommand,
3019
- Na as createDefaultNewRule,
3020
- xe as deserializeListOptions,
3021
- Ve as getCellValueOrigin,
3022
- Ma as getDataValidationCellValue,
3023
- ze as getDataValidationDiffMutations,
3024
- cr as getFormulaCellData,
3025
- z as getFormulaResult,
3026
- W as isLegalFormulaResult,
3027
- ya as serializeListOptions,
3028
- $e as transformCheckboxValue
2884
+ Vr as AddSheetDataValidationCommand,
2885
+ Se as CHECKBOX_FORMULA_1,
2886
+ Ve as CHECKBOX_FORMULA_2,
2887
+ cr as CheckboxValidator,
2888
+ yr as ClearRangeDataValidationCommand,
2889
+ Xt as DATA_VALIDATION_PLUGIN_NAME,
2890
+ j as DataValidationCacheService,
2891
+ $ as DataValidationCustomFormulaService,
2892
+ ye as DataValidationFormulaController,
2893
+ X as DataValidationFormulaService,
2894
+ fr as DateValidator,
2895
+ Ir as ListMultipleValidator,
2896
+ mt as ListValidator,
2897
+ Er as RemoveSheetAllDataValidationCommand,
2898
+ wr as RemoveSheetDataValidationCommand,
2899
+ F as SheetDataValidationModel,
2900
+ Fe as SheetsDataValidationValidatorService,
2901
+ Ce as UniverSheetsDataValidationPlugin,
2902
+ Mr as UpdateSheetDataValidationOptionsCommand,
2903
+ Sr as UpdateSheetDataValidationRangeCommand,
2904
+ Nr as UpdateSheetDataValidationSettingCommand,
2905
+ ca as createDefaultNewRule,
2906
+ pe as deserializeListOptions,
2907
+ ae as getCellValueOrigin,
2908
+ ua as getDataValidationCellValue,
2909
+ Ae as getDataValidationDiffMutations,
2910
+ he as getFormulaCellData,
2911
+ ie as getFormulaResult,
2912
+ O as isLegalFormulaResult,
2913
+ la as serializeListOptions,
2914
+ _e as transformCheckboxValue
3029
2915
  };