@univerjs/sheets-data-validation 0.17.0 → 0.18.0
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/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -1628
- package/lib/es/index.js +1 -2640
- package/lib/facade.js +1 -1628
- package/lib/index.js +1 -2640
- package/lib/types/commands/commands/data-validation.command.d.ts +19 -4
- package/lib/types/common/date-text-map.d.ts +15 -0
- package/lib/types/controllers/dv-formula-ref-range.controller.d.ts +17 -1
- package/lib/types/controllers/dv-formula.controller.d.ts +15 -0
- package/lib/types/controllers/dv-ref-range.controller.d.ts +17 -1
- package/lib/types/controllers/dv-sheet.controller.d.ts +15 -0
- package/lib/types/controllers/dv.controller.d.ts +15 -0
- package/lib/types/facade/f-data-validation-builder.d.ts +18 -2
- package/lib/types/facade/f-data-validation.d.ts +16 -1
- package/lib/types/facade/f-event.d.ts +20 -5
- package/lib/types/facade/f-range.d.ts +18 -2
- package/lib/types/facade/f-univer.d.ts +16 -1
- package/lib/types/facade/f-workbook.d.ts +20 -3
- package/lib/types/facade/f-worksheet.d.ts +18 -2
- package/lib/types/models/rule-matrix.d.ts +17 -2
- package/lib/types/models/sheet-data-validation-model.d.ts +24 -7
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/dv-cache.service.d.ts +18 -2
- package/lib/types/services/dv-custom-formula.service.d.ts +21 -5
- package/lib/types/services/dv-formula.service.d.ts +19 -2
- package/lib/types/services/dv-list-cache.service.d.ts +18 -2
- package/lib/types/services/dv-validator-service.d.ts +17 -1
- package/lib/types/types/const/operator-text-map.d.ts +15 -0
- package/lib/types/types/const/two-formula-operators.d.ts +15 -0
- package/lib/types/utils/create.d.ts +18 -2
- package/lib/types/utils/formula.d.ts +18 -3
- package/lib/types/utils/get-cell-data-origin.d.ts +17 -2
- package/lib/types/validators/any-validator.d.ts +18 -2
- package/lib/types/validators/checkbox-validator.d.ts +19 -2
- package/lib/types/validators/custom-validator.d.ts +18 -2
- package/lib/types/validators/date-validator.d.ts +20 -3
- package/lib/types/validators/decimal-validator.d.ts +23 -6
- package/lib/types/validators/list-multiple-validator.d.ts +15 -0
- package/lib/types/validators/list-validator.d.ts +18 -2
- package/lib/types/validators/text-length-validator.d.ts +23 -6
- package/lib/types/validators/util.d.ts +18 -3
- package/lib/types/validators/whole-validator.d.ts +23 -6
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +11 -10
package/lib/es/index.js
CHANGED
|
@@ -1,2640 +1 @@
|
|
|
1
|
-
var Vt = Object.defineProperty;
|
|
2
|
-
var yt = (s, a, e) => a in s ? Vt(s, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[a] = e;
|
|
3
|
-
var m = (s, a, e) => yt(s, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
-
import { Inject as v, ICommandService as U, IUniverInstanceService as D, Disposable as B, ObjectMatrix as Ve, getIntersectRange as nt, UniverInstanceType as N, Range as H, Rectangle as w, isFormulaString as S, getOriginCellValue as Tt, Injector as be, numfmt as L, DataValidationType as T, RBush as Ct, debounce as Ft, Tools as M, DataValidationStatus as A, WrapStrategy as Ee, DataValidationOperator as h, dayjs as lt, DataValidationRenderMode as $e, CommandType as z, IUndoRedoService as Z, sequenceExecute as Le, isRangesEqual as ut, IPermissionService as Nt, generateRandomId as Ke, toDisposable as ze, CellValueType as Ot, RxDisposable as wt, LifecycleService as At, LifecycleStages as tt, bufferDebounceTime as It, DependentOn as Dt, IConfigService as bt, Plugin as Lt, merge as Ut } from "@univerjs/core";
|
|
5
|
-
import { DataValidationModel as he, DataValidatorRegistryService as q, UpdateRuleType as V, BaseDataValidator as Y, TextLengthErrorTitleMap as Bt, AddDataValidationMutation as b, RemoveDataValidationMutation as I, UpdateDataValidationMutation as y, getRuleSetting as xt, getRuleOptions as Pt, UniverDataValidationPlugin as Ht } from "@univerjs/data-validation";
|
|
6
|
-
import { ERROR_TYPE_SET as Wt, RegisterOtherFormulaService as ct, OtherFormulaBizType as dt, LexerTreeBuilder as X, isReferenceString as ht, sequenceNodeType as $t, deserializeRangeWithSheet as kt, deserializeRangeWithSheetWithCache as jt, operatorToken as Qt } from "@univerjs/engine-formula";
|
|
7
|
-
import { SetRangeValuesMutation as le, RemoveSheetMutation as mt, getSheetCommandTarget as Ze, SetRangeValuesUndoMutationFactory as gt, WorksheetViewPermission as Gt, RefRangeService as qt, handleCommonDefaultRangeChangeWithEffectRefCommands as Yt, SheetInterceptorService as pt, RemoveSheetCommand as Xt, CopySheetCommand as Kt, SheetsSelectionsService as ft, ClearSelectionAllCommand as zt } from "@univerjs/sheets";
|
|
8
|
-
import { Subject as Xe, bufferWhen as Zt, filter as at } from "rxjs";
|
|
9
|
-
import { FormulaRefRangeService as _t, UniverSheetsFormulaPlugin as Jt } from "@univerjs/sheets-formula";
|
|
10
|
-
var ea = Object.getOwnPropertyDescriptor, ta = (s, a, e, t) => {
|
|
11
|
-
for (var r = t > 1 ? void 0 : t ? ea(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
12
|
-
(o = s[i]) && (r = o(r) || r);
|
|
13
|
-
return r;
|
|
14
|
-
}, ke = (s, a) => (e, t) => a(e, t, s);
|
|
15
|
-
let Q = class extends B {
|
|
16
|
-
constructor(a, e, t) {
|
|
17
|
-
super();
|
|
18
|
-
m(this, "_cacheMatrix", /* @__PURE__ */ new Map());
|
|
19
|
-
m(this, "_dirtyRanges$", new Xe());
|
|
20
|
-
m(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
|
|
21
|
-
this._commandService = a, this._univerInstanceService = e, this._sheetDataValidationModel = t, this._initDirtyRanges(), this._initSheetRemove();
|
|
22
|
-
}
|
|
23
|
-
_initDirtyRanges() {
|
|
24
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((a, e) => {
|
|
25
|
-
if (a.id === le.id && !(e != null && e.onlyLocal)) {
|
|
26
|
-
const { cellValue: t, unitId: r, subUnitId: i } = a.params;
|
|
27
|
-
if (t) {
|
|
28
|
-
const o = new Ve(t).getDataRange();
|
|
29
|
-
if (o.endRow === -1) return;
|
|
30
|
-
const u = this._sheetDataValidationModel.getRules(r, i).map((c) => c.ranges).flat().map((c) => nt(c, o)).filter(Boolean);
|
|
31
|
-
u.length && this.markRangeDirty(r, i, u, !0);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
_initSheetRemove() {
|
|
37
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((a) => {
|
|
38
|
-
var e;
|
|
39
|
-
if (a.id === mt.id) {
|
|
40
|
-
const { unitId: t, subUnitId: r } = a.params;
|
|
41
|
-
(e = this._cacheMatrix.get(t)) == null || e.delete(r);
|
|
42
|
-
}
|
|
43
|
-
})), this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe((a) => {
|
|
44
|
-
a.type === N.UNIVER_SHEET && this._cacheMatrix.delete(a.getUnitId());
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
_ensureCache(a, e) {
|
|
48
|
-
let t = this._cacheMatrix.get(a);
|
|
49
|
-
t || (t = /* @__PURE__ */ new Map(), this._cacheMatrix.set(a, t));
|
|
50
|
-
let r = t.get(e);
|
|
51
|
-
return r || (r = new Ve(), t.set(e, r)), r;
|
|
52
|
-
}
|
|
53
|
-
ensureCache(a, e) {
|
|
54
|
-
return this._ensureCache(a, e);
|
|
55
|
-
}
|
|
56
|
-
addRule(a, e, t) {
|
|
57
|
-
this.markRangeDirty(a, e, t.ranges);
|
|
58
|
-
}
|
|
59
|
-
removeRule(a, e, t) {
|
|
60
|
-
this._deleteRange(a, e, t.ranges);
|
|
61
|
-
}
|
|
62
|
-
markRangeDirty(a, e, t, r) {
|
|
63
|
-
const i = this._ensureCache(a, e);
|
|
64
|
-
t.forEach((o) => {
|
|
65
|
-
H.foreach(o, (n, l) => {
|
|
66
|
-
i.getValue(n, l) !== void 0 && i.setValue(n, l, void 0);
|
|
67
|
-
});
|
|
68
|
-
}), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t, isSetRange: r });
|
|
69
|
-
}
|
|
70
|
-
_deleteRange(a, e, t) {
|
|
71
|
-
const r = this._ensureCache(a, e);
|
|
72
|
-
t.forEach((i) => {
|
|
73
|
-
H.foreach(i, (o, n) => {
|
|
74
|
-
r.realDeleteValue(o, n);
|
|
75
|
-
});
|
|
76
|
-
}), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t });
|
|
77
|
-
}
|
|
78
|
-
getValue(a, e, t, r) {
|
|
79
|
-
return this._ensureCache(a, e).getValue(t, r);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
Q = ta([
|
|
83
|
-
ke(0, v(U)),
|
|
84
|
-
ke(1, v(D)),
|
|
85
|
-
ke(2, v(he))
|
|
86
|
-
], Q);
|
|
87
|
-
function ne(s) {
|
|
88
|
-
var a, e;
|
|
89
|
-
return (e = (a = s == null ? void 0 : s[0]) == null ? void 0 : a[0]) == null ? void 0 : e.v;
|
|
90
|
-
}
|
|
91
|
-
function ve(s) {
|
|
92
|
-
var a;
|
|
93
|
-
return (a = s == null ? void 0 : s[0]) == null ? void 0 : a[0];
|
|
94
|
-
}
|
|
95
|
-
function C(s) {
|
|
96
|
-
return !Wt.has(s);
|
|
97
|
-
}
|
|
98
|
-
function me(s, a) {
|
|
99
|
-
var t;
|
|
100
|
-
const e = a.getValidatorItem(s);
|
|
101
|
-
return (t = e == null ? void 0 : e.offsetFormulaByRange) != null ? t : !1;
|
|
102
|
-
}
|
|
103
|
-
var aa = Object.getOwnPropertyDescriptor, ra = (s, a, e, t) => {
|
|
104
|
-
for (var r = t > 1 ? void 0 : t ? aa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
105
|
-
(o = s[i]) && (r = o(r) || r);
|
|
106
|
-
return r;
|
|
107
|
-
}, oe = (s, a) => (e, t) => a(e, t, s);
|
|
108
|
-
let W = class extends B {
|
|
109
|
-
constructor(a, e, t, r, i) {
|
|
110
|
-
super();
|
|
111
|
-
/**
|
|
112
|
-
* Map of origin formula of rule
|
|
113
|
-
*/
|
|
114
|
-
m(this, "_ruleFormulaMap", /* @__PURE__ */ new Map());
|
|
115
|
-
m(this, "_ruleFormulaMap2", /* @__PURE__ */ new Map());
|
|
116
|
-
this._instanceSrv = a, this._registerOtherFormulaService = e, this._dataValidationModel = t, this._dataValidationCacheService = r, this._validatorRegistryService = i, this._initFormulaResultHandler(), this._initDirtyRanges();
|
|
117
|
-
}
|
|
118
|
-
dispose() {
|
|
119
|
-
super.dispose(), this._ruleFormulaMap.clear(), this._ruleFormulaMap2.clear();
|
|
120
|
-
}
|
|
121
|
-
_initFormulaResultHandler() {
|
|
122
|
-
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((a) => {
|
|
123
|
-
for (const e in a) {
|
|
124
|
-
const t = a[e];
|
|
125
|
-
if (this._instanceSrv.getUnitType(e) === N.UNIVER_SHEET)
|
|
126
|
-
for (const i in t) {
|
|
127
|
-
const o = t[i], { ruleFormulaMap: n } = this._ensureMaps(e, i);
|
|
128
|
-
o.forEach((l) => {
|
|
129
|
-
var d, g;
|
|
130
|
-
const u = n.get((d = l.extra) == null ? void 0 : d.ruleId), c = this._dataValidationModel.getRuleById(e, i, (g = l.extra) == null ? void 0 : g.ruleId);
|
|
131
|
-
c && u && this._dataValidationCacheService.markRangeDirty(e, i, c.ranges);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
_ensureMaps(a, e) {
|
|
138
|
-
let t = this._ruleFormulaMap.get(a), r = this._ruleFormulaMap2.get(a);
|
|
139
|
-
t || (t = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(a, t)), r || (r = /* @__PURE__ */ new Map(), this._ruleFormulaMap2.set(a, r));
|
|
140
|
-
let i = t.get(e);
|
|
141
|
-
i || (i = /* @__PURE__ */ new Map(), t.set(e, i));
|
|
142
|
-
let o = r.get(e);
|
|
143
|
-
return o || (o = /* @__PURE__ */ new Map(), r.set(e, o)), { ruleFormulaMap: i, ruleFormulaMap2: o };
|
|
144
|
-
}
|
|
145
|
-
_registerFormula(a, e, t, r, i) {
|
|
146
|
-
return this._registerOtherFormulaService.registerFormulaWithRange(a, e, r, i, { ruleId: t }, dt.DATA_VALIDATION_CUSTOM, t);
|
|
147
|
-
}
|
|
148
|
-
_handleDirtyRanges(a, e, t) {
|
|
149
|
-
this._dataValidationModel.getRules(a, e).forEach((i) => {
|
|
150
|
-
const o = i.ranges;
|
|
151
|
-
w.doAnyRangesIntersect(o, t) && this.makeRuleDirty(a, e, i.uid);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
_initDirtyRanges() {
|
|
155
|
-
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.subscribe((a) => {
|
|
156
|
-
a.isSetRange && this._handleDirtyRanges(a.unitId, a.subUnitId, a.ranges);
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
deleteByRuleId(a, e, t) {
|
|
160
|
-
const { ruleFormulaMap: r, ruleFormulaMap2: i } = this._ensureMaps(a, e), o = this._dataValidationModel.getRuleById(a, e, t), n = r.get(t);
|
|
161
|
-
if (!o || !n)
|
|
162
|
-
return;
|
|
163
|
-
const l = r.get(t);
|
|
164
|
-
l && (r.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [l.formulaId]));
|
|
165
|
-
const u = i.get(t);
|
|
166
|
-
u && (i.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [u.formulaId]));
|
|
167
|
-
}
|
|
168
|
-
_addFormulaByRange(a, e, t, r, i, o) {
|
|
169
|
-
const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(a, e), u = o[0].startRow, c = o[0].startColumn;
|
|
170
|
-
if (r && S(r)) {
|
|
171
|
-
const d = this._registerFormula(a, e, t, r, o);
|
|
172
|
-
n.set(t, {
|
|
173
|
-
formula: r,
|
|
174
|
-
originCol: c,
|
|
175
|
-
originRow: u,
|
|
176
|
-
formulaId: d
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
if (i && S(i)) {
|
|
180
|
-
const d = this._registerFormula(a, e, t, i, o);
|
|
181
|
-
l.set(t, {
|
|
182
|
-
formula: i,
|
|
183
|
-
originCol: c,
|
|
184
|
-
originRow: u,
|
|
185
|
-
formulaId: d
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
addRule(a, e, t) {
|
|
190
|
-
if (me(t.type, this._validatorRegistryService)) {
|
|
191
|
-
const { ranges: r, formula1: i, formula2: o, uid: n } = t;
|
|
192
|
-
this._addFormulaByRange(a, e, n, i, o, r);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async getCellFormulaValue(a, e, t, r, i) {
|
|
196
|
-
var f, p;
|
|
197
|
-
const { ruleFormulaMap: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
198
|
-
if (!n)
|
|
199
|
-
return Promise.resolve(void 0);
|
|
200
|
-
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
201
|
-
return ve((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
202
|
-
}
|
|
203
|
-
async getCellFormula2Value(a, e, t, r, i) {
|
|
204
|
-
var f, p;
|
|
205
|
-
const { ruleFormulaMap2: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
206
|
-
if (!n)
|
|
207
|
-
return Promise.resolve(void 0);
|
|
208
|
-
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
209
|
-
return ve((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
210
|
-
}
|
|
211
|
-
getCellFormulaValueSync(a, e, t, r, i) {
|
|
212
|
-
var f, p;
|
|
213
|
-
const { ruleFormulaMap: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
214
|
-
if (!n)
|
|
215
|
-
return;
|
|
216
|
-
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
217
|
-
return ve((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
218
|
-
}
|
|
219
|
-
getCellFormula2ValueSync(a, e, t, r, i) {
|
|
220
|
-
var f, p;
|
|
221
|
-
const { ruleFormulaMap2: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
222
|
-
if (!n)
|
|
223
|
-
return;
|
|
224
|
-
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
225
|
-
return ve((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
226
|
-
}
|
|
227
|
-
getRuleFormulaInfo(a, e, t) {
|
|
228
|
-
const { ruleFormulaMap: r } = this._ensureMaps(a, e);
|
|
229
|
-
return r.get(t);
|
|
230
|
-
}
|
|
231
|
-
makeRuleDirty(a, e, t) {
|
|
232
|
-
var o, n, l, u;
|
|
233
|
-
const r = (n = (o = this._ruleFormulaMap.get(a)) == null ? void 0 : o.get(e)) == null ? void 0 : n.get(t), i = (u = (l = this._ruleFormulaMap2.get(a)) == null ? void 0 : l.get(e)) == null ? void 0 : u.get(t);
|
|
234
|
-
r && this._registerOtherFormulaService.markFormulaDirty(a, e, r.formulaId), i && this._registerOtherFormulaService.markFormulaDirty(a, e, i.formulaId);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
W = ra([
|
|
238
|
-
oe(0, D),
|
|
239
|
-
oe(1, v(ct)),
|
|
240
|
-
oe(2, v(he)),
|
|
241
|
-
oe(3, v(Q)),
|
|
242
|
-
oe(4, v(q))
|
|
243
|
-
], W);
|
|
244
|
-
function re(s) {
|
|
245
|
-
return Tt(s);
|
|
246
|
-
}
|
|
247
|
-
function vt(s) {
|
|
248
|
-
var a;
|
|
249
|
-
return String((a = re(s)) != null ? a : "");
|
|
250
|
-
}
|
|
251
|
-
function sr(s) {
|
|
252
|
-
return s.filter(Boolean).join(",");
|
|
253
|
-
}
|
|
254
|
-
function Me(s) {
|
|
255
|
-
return s.split(",").filter(Boolean);
|
|
256
|
-
}
|
|
257
|
-
function or(s) {
|
|
258
|
-
const a = re(s);
|
|
259
|
-
return a == null ? "" : a.toString();
|
|
260
|
-
}
|
|
261
|
-
function Ue(s, a, e) {
|
|
262
|
-
const { formula1: t, formula2: r } = a, i = a.ranges[0].startRow, o = a.ranges[0].startColumn, n = e.row - i, l = e.col - o, u = S(t) ? s.moveFormulaRefOffset(t, l, n, !0) : t, c = S(r) ? s.moveFormulaRefOffset(r, l, n, !0) : r;
|
|
263
|
-
return {
|
|
264
|
-
transformedFormula1: u,
|
|
265
|
-
transformedFormula2: c
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
var ia = Object.getOwnPropertyDescriptor, sa = (s, a, e, t) => {
|
|
269
|
-
for (var r = t > 1 ? void 0 : t ? ia(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
270
|
-
(o = s[i]) && (r = o(r) || r);
|
|
271
|
-
return r;
|
|
272
|
-
}, rt = (s, a) => (e, t) => a(e, t, s);
|
|
273
|
-
let ue = class extends B {
|
|
274
|
-
constructor(a, e) {
|
|
275
|
-
super();
|
|
276
|
-
// Cache structure: unitId -> subUnitId -> ruleId -> cache item
|
|
277
|
-
m(this, "_cache", /* @__PURE__ */ new Map());
|
|
278
|
-
this._injector = a, this._dataValidationModel = e, this._initRuleChangeListener();
|
|
279
|
-
}
|
|
280
|
-
_initRuleChangeListener() {
|
|
281
|
-
this.disposeWithMe(
|
|
282
|
-
this._dataValidationModel.ruleChange$.subscribe((a) => {
|
|
283
|
-
(a.type === "remove" || a.type === "update") && this.markRuleDirty(a.unitId, a.subUnitId, a.rule.uid);
|
|
284
|
-
})
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Get cached list data or compute and cache it if not exists.
|
|
289
|
-
*/
|
|
290
|
-
getOrCompute(a, e, t) {
|
|
291
|
-
const r = this.getCache(a, e, t.uid);
|
|
292
|
-
if (r)
|
|
293
|
-
return r;
|
|
294
|
-
const o = this._injector.get(G).getRuleFormulaResultSync(a, e, t.uid);
|
|
295
|
-
return this.computeAndCache(a, e, t, o);
|
|
296
|
-
}
|
|
297
|
-
_ensureCache(a, e) {
|
|
298
|
-
let t = this._cache.get(a);
|
|
299
|
-
t || (t = /* @__PURE__ */ new Map(), this._cache.set(a, t));
|
|
300
|
-
let r = t.get(e);
|
|
301
|
-
return r || (r = /* @__PURE__ */ new Map(), t.set(e, r)), r;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Get cached list data for a rule. Returns undefined if not cached.
|
|
305
|
-
*/
|
|
306
|
-
getCache(a, e, t) {
|
|
307
|
-
var r, i;
|
|
308
|
-
return (i = (r = this._cache.get(a)) == null ? void 0 : r.get(e)) == null ? void 0 : i.get(t);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Set cache for a rule.
|
|
312
|
-
*/
|
|
313
|
-
setCache(a, e, t, r) {
|
|
314
|
-
this._ensureCache(a, e).set(t, r);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Mark a rule's cache as dirty (invalidate it).
|
|
318
|
-
* Called when formula results change.
|
|
319
|
-
*/
|
|
320
|
-
markRuleDirty(a, e, t) {
|
|
321
|
-
var r, i;
|
|
322
|
-
(i = (r = this._cache.get(a)) == null ? void 0 : r.get(e)) == null || i.delete(t);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Clear all caches.
|
|
326
|
-
*/
|
|
327
|
-
clear() {
|
|
328
|
-
this._cache.clear();
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Compute list data from formula result and cache it.
|
|
332
|
-
*/
|
|
333
|
-
computeAndCache(a, e, t, r) {
|
|
334
|
-
var f, p, R;
|
|
335
|
-
const { formula1: i = "", formula2: o = "" } = t, n = S(i) ? this._getRuleFormulaResultSet((R = (p = (f = r == null ? void 0 : r[0]) == null ? void 0 : f.result) == null ? void 0 : p[0]) == null ? void 0 : R[0]) : Me(i), l = o.split(","), u = n.map((E, _) => ({ label: E, color: l[_] || "" })), c = {};
|
|
336
|
-
for (const E of u)
|
|
337
|
-
E.color && (c[E.label] = E.color);
|
|
338
|
-
const d = new Set(n), g = { list: n, listWithColor: u, colorMap: c, set: d };
|
|
339
|
-
return this.setCache(a, e, t.uid, g), g;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Extract string list from formula result cells.
|
|
343
|
-
*/
|
|
344
|
-
_getRuleFormulaResultSet(a) {
|
|
345
|
-
var t, r;
|
|
346
|
-
if (!a)
|
|
347
|
-
return [];
|
|
348
|
-
const e = /* @__PURE__ */ new Set();
|
|
349
|
-
for (let i = 0, o = a.length; i < o; i++) {
|
|
350
|
-
const n = a[i];
|
|
351
|
-
if (n)
|
|
352
|
-
for (let l = 0, u = n.length; l < u; l++) {
|
|
353
|
-
const c = n[l], d = re(c);
|
|
354
|
-
if (d != null) {
|
|
355
|
-
if (typeof d != "string" && typeof (c == null ? void 0 : c.s) == "object" && ((r = (t = c.s) == null ? void 0 : t.n) != null && r.pattern)) {
|
|
356
|
-
e.add(L.format(c.s.n.pattern, d, { throws: !1 }));
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
const g = typeof d == "string" ? d : String(d);
|
|
360
|
-
C(g) && e.add(g);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return [...e];
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
ue = sa([
|
|
368
|
-
rt(0, v(be)),
|
|
369
|
-
rt(1, v(he))
|
|
370
|
-
], ue);
|
|
371
|
-
var oa = Object.getOwnPropertyDescriptor, na = (s, a, e, t) => {
|
|
372
|
-
for (var r = t > 1 ? void 0 : t ? oa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
373
|
-
(o = s[i]) && (r = o(r) || r);
|
|
374
|
-
return r;
|
|
375
|
-
}, ee = (s, a) => (e, t) => a(e, t, s);
|
|
376
|
-
let G = class extends B {
|
|
377
|
-
constructor(a, e, t, r, i, o) {
|
|
378
|
-
super();
|
|
379
|
-
m(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
380
|
-
this._instanceService = a, this._registerOtherFormulaService = e, this._dataValidationCacheService = t, this._dataValidationModel = r, this._validatorRegistryService = i, this._listCacheService = o, this._initFormulaResultHandler();
|
|
381
|
-
}
|
|
382
|
-
_initFormulaResultHandler() {
|
|
383
|
-
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((a) => {
|
|
384
|
-
for (const e in a) {
|
|
385
|
-
const t = a[e];
|
|
386
|
-
if (this._instanceService.getUnitType(e) === N.UNIVER_SHEET)
|
|
387
|
-
for (const i in t) {
|
|
388
|
-
const o = t[i], n = this._ensureRuleFormulaMap(e, i);
|
|
389
|
-
o.forEach((l) => {
|
|
390
|
-
var c;
|
|
391
|
-
const u = (c = l.extra) == null ? void 0 : c.ruleId;
|
|
392
|
-
if (u && n.get(u)) {
|
|
393
|
-
const d = this._dataValidationModel.getRuleById(e, i, u);
|
|
394
|
-
d && (this._listCacheService.markRuleDirty(e, i, u), this._dataValidationCacheService.markRangeDirty(e, i, d.ranges));
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}));
|
|
400
|
-
}
|
|
401
|
-
_ensureRuleFormulaMap(a, e) {
|
|
402
|
-
let t = this._formulaRuleMap.get(a);
|
|
403
|
-
t || (t = /* @__PURE__ */ new Map(), this._formulaRuleMap.set(a, t));
|
|
404
|
-
let r = t.get(e);
|
|
405
|
-
return r || (r = /* @__PURE__ */ new Map(), t.set(e, r)), r;
|
|
406
|
-
}
|
|
407
|
-
_registerSingleFormula(a, e, t, r) {
|
|
408
|
-
const i = [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }];
|
|
409
|
-
return this._registerOtherFormulaService.registerFormulaWithRange(a, e, t, i, { ruleId: r }, dt.DATA_VALIDATION, r);
|
|
410
|
-
}
|
|
411
|
-
addRule(a, e, t) {
|
|
412
|
-
if (!me(t.type, this._validatorRegistryService) && t.type !== T.CHECKBOX) {
|
|
413
|
-
const { formula1: r, formula2: i, uid: o } = t, n = S(r), l = S(i);
|
|
414
|
-
if (!n && !l)
|
|
415
|
-
return;
|
|
416
|
-
const u = this._ensureRuleFormulaMap(a, e), c = [void 0, void 0];
|
|
417
|
-
if (n) {
|
|
418
|
-
const d = this._registerSingleFormula(a, e, r, o);
|
|
419
|
-
c[0] = { id: d, text: r };
|
|
420
|
-
}
|
|
421
|
-
if (l) {
|
|
422
|
-
const d = this._registerSingleFormula(a, e, i, o);
|
|
423
|
-
c[1] = { id: d, text: i };
|
|
424
|
-
}
|
|
425
|
-
u.set(o, c);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
removeRule(a, e, t) {
|
|
429
|
-
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
430
|
-
if (!i)
|
|
431
|
-
return;
|
|
432
|
-
const [o, n] = i, l = [o == null ? void 0 : o.id, n == null ? void 0 : n.id].filter(Boolean);
|
|
433
|
-
l.length && this._registerOtherFormulaService.deleteFormula(a, e, l);
|
|
434
|
-
}
|
|
435
|
-
getRuleFormulaResult(a, e, t) {
|
|
436
|
-
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
437
|
-
if (!i)
|
|
438
|
-
return Promise.resolve(null);
|
|
439
|
-
const o = async (n) => n && this._registerOtherFormulaService.getFormulaValue(a, e, n.id);
|
|
440
|
-
return Promise.all([
|
|
441
|
-
o(i[0]),
|
|
442
|
-
o(i[1])
|
|
443
|
-
]);
|
|
444
|
-
}
|
|
445
|
-
getRuleFormulaResultSync(a, e, t) {
|
|
446
|
-
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
447
|
-
if (i)
|
|
448
|
-
return i.map((o) => {
|
|
449
|
-
if (o)
|
|
450
|
-
return this._registerOtherFormulaService.getFormulaValueSync(a, e, o.id);
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
getRuleFormulaInfo(a, e, t) {
|
|
454
|
-
return this._ensureRuleFormulaMap(a, e).get(t);
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
G = na([
|
|
458
|
-
ee(0, D),
|
|
459
|
-
ee(1, v(ct)),
|
|
460
|
-
ee(2, v(Q)),
|
|
461
|
-
ee(3, v(he)),
|
|
462
|
-
ee(4, v(q)),
|
|
463
|
-
ee(5, v(ue))
|
|
464
|
-
], G);
|
|
465
|
-
class Je {
|
|
466
|
-
constructor(a, e, t, r, i = !1) {
|
|
467
|
-
m(this, "_map");
|
|
468
|
-
m(this, "_tree", new Ct());
|
|
469
|
-
m(this, "_dirty", !0);
|
|
470
|
-
m(this, "_buildTree", () => {
|
|
471
|
-
if (!this._dirty || this._disableTree)
|
|
472
|
-
return;
|
|
473
|
-
this._tree.clear();
|
|
474
|
-
const a = [];
|
|
475
|
-
this._map.forEach((e, t) => {
|
|
476
|
-
e.forEach((r) => {
|
|
477
|
-
a.push({
|
|
478
|
-
minX: r.startRow,
|
|
479
|
-
maxX: r.endRow,
|
|
480
|
-
minY: r.startColumn,
|
|
481
|
-
maxY: r.endColumn,
|
|
482
|
-
ruleId: t
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
}), this._tree.load(a), this._dirty = !1;
|
|
486
|
-
});
|
|
487
|
-
m(this, "_debonceBuildTree", Ft(this._buildTree, 0));
|
|
488
|
-
this._unitId = e, this._subUnitId = t, this._univerInstanceService = r, this._disableTree = i, this._map = a, this._buildTree();
|
|
489
|
-
}
|
|
490
|
-
get _worksheet() {
|
|
491
|
-
var a;
|
|
492
|
-
return (a = this._univerInstanceService.getUnit(this._unitId, N.UNIVER_SHEET)) == null ? void 0 : a.getSheetBySheetId(this._subUnitId);
|
|
493
|
-
}
|
|
494
|
-
_addRule(a, e) {
|
|
495
|
-
if (!this._worksheet)
|
|
496
|
-
return;
|
|
497
|
-
const t = w.mergeRanges(e.map((r) => H.transformRange(r, this._worksheet)));
|
|
498
|
-
this._map.forEach((r, i) => {
|
|
499
|
-
const o = w.subtractMulti(r, t);
|
|
500
|
-
o.length === 0 ? this._map.delete(i) : this._map.set(i, o);
|
|
501
|
-
}), this._dirty = !0, this._map.set(a, t), this._debonceBuildTree();
|
|
502
|
-
}
|
|
503
|
-
addRule(a) {
|
|
504
|
-
this._addRule(a.uid, a.ranges);
|
|
505
|
-
}
|
|
506
|
-
removeRange(a) {
|
|
507
|
-
if (!this._worksheet)
|
|
508
|
-
return;
|
|
509
|
-
const e = a.map((t) => H.transformRange(t, this._worksheet));
|
|
510
|
-
this._map.forEach((t, r) => {
|
|
511
|
-
const i = w.subtractMulti(t, e);
|
|
512
|
-
i.length === 0 ? this._map.delete(r) : this._map.set(r, i);
|
|
513
|
-
}), this._dirty = !0, this._debonceBuildTree();
|
|
514
|
-
}
|
|
515
|
-
_removeRule(a) {
|
|
516
|
-
this._map.delete(a), this._dirty = !0, this._debonceBuildTree();
|
|
517
|
-
}
|
|
518
|
-
removeRule(a) {
|
|
519
|
-
this._removeRule(a.uid);
|
|
520
|
-
}
|
|
521
|
-
updateRange(a, e) {
|
|
522
|
-
this._removeRule(a), this._addRule(a, e);
|
|
523
|
-
}
|
|
524
|
-
addRangeRules(a) {
|
|
525
|
-
a.forEach(({ id: e, ranges: t }) => {
|
|
526
|
-
if (!t.length)
|
|
527
|
-
return;
|
|
528
|
-
let r = this._map.get(e);
|
|
529
|
-
r ? (this._map.set(e, w.mergeRanges([...r, ...t])), r = this._map.get(e)) : (r = t, this._map.set(e, r)), this._map.forEach((i, o) => {
|
|
530
|
-
if (o === e)
|
|
531
|
-
return;
|
|
532
|
-
const n = w.subtractMulti(i, t);
|
|
533
|
-
n.length === 0 ? this._map.delete(o) : this._map.set(o, n);
|
|
534
|
-
});
|
|
535
|
-
}), this._dirty = !0, this._debonceBuildTree();
|
|
536
|
-
}
|
|
537
|
-
diff(a) {
|
|
538
|
-
const e = [];
|
|
539
|
-
let t = 0;
|
|
540
|
-
return a.forEach((r, i) => {
|
|
541
|
-
var l;
|
|
542
|
-
const o = (l = this._map.get(r.uid)) != null ? l : [], n = r.ranges;
|
|
543
|
-
o.length !== 0 && (o.length !== n.length || o.some((u, c) => !w.equals(u, n[c]))) && e.push({
|
|
544
|
-
type: "update",
|
|
545
|
-
ruleId: r.uid,
|
|
546
|
-
oldRanges: n,
|
|
547
|
-
newRanges: w.sort(o),
|
|
548
|
-
rule: r
|
|
549
|
-
}), o.length === 0 && (e.push({
|
|
550
|
-
type: "delete",
|
|
551
|
-
rule: r,
|
|
552
|
-
index: i - t
|
|
553
|
-
}), t++);
|
|
554
|
-
}), e;
|
|
555
|
-
}
|
|
556
|
-
diffWithAddition(a, e) {
|
|
557
|
-
const t = [];
|
|
558
|
-
let r = 0;
|
|
559
|
-
return a.forEach((i, o) => {
|
|
560
|
-
var u;
|
|
561
|
-
const n = (u = this._map.get(i.uid)) != null ? u : [], l = i.ranges;
|
|
562
|
-
n.length !== 0 && (n.length !== l.length || n.some((c, d) => !w.equals(c, l[d]))) && t.push({
|
|
563
|
-
type: "update",
|
|
564
|
-
ruleId: i.uid,
|
|
565
|
-
oldRanges: l,
|
|
566
|
-
newRanges: w.sort(n),
|
|
567
|
-
rule: i
|
|
568
|
-
}), n.length === 0 && (t.push({
|
|
569
|
-
type: "delete",
|
|
570
|
-
rule: i,
|
|
571
|
-
index: o - r
|
|
572
|
-
}), r++);
|
|
573
|
-
}), Array.from(e).forEach((i) => {
|
|
574
|
-
var n;
|
|
575
|
-
const o = (n = this._map.get(i.uid)) != null ? n : [];
|
|
576
|
-
t.push({
|
|
577
|
-
type: "add",
|
|
578
|
-
rule: {
|
|
579
|
-
...i,
|
|
580
|
-
ranges: w.sort(o)
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
}), t;
|
|
584
|
-
}
|
|
585
|
-
clone() {
|
|
586
|
-
return new Je(
|
|
587
|
-
new Map(M.deepClone(Array.from(this._map.entries()))),
|
|
588
|
-
this._unitId,
|
|
589
|
-
this._subUnitId,
|
|
590
|
-
this._univerInstanceService,
|
|
591
|
-
// disable tree on cloned matrix, cause there is no need to search
|
|
592
|
-
!0
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
getValue(a, e) {
|
|
596
|
-
this._dirty && this._buildTree();
|
|
597
|
-
const t = this._tree.search({
|
|
598
|
-
minX: a,
|
|
599
|
-
maxX: a,
|
|
600
|
-
minY: e,
|
|
601
|
-
maxY: e
|
|
602
|
-
});
|
|
603
|
-
return t.length > 0 ? t[0].ruleId : void 0;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
var la = Object.getOwnPropertyDescriptor, ua = (s, a, e, t) => {
|
|
607
|
-
for (var r = t > 1 ? void 0 : t ? la(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
608
|
-
(o = s[i]) && (r = o(r) || r);
|
|
609
|
-
return r;
|
|
610
|
-
}, K = (s, a) => (e, t) => a(e, t, s);
|
|
611
|
-
let F = class extends B {
|
|
612
|
-
constructor(a, e, t, r, i, o, n) {
|
|
613
|
-
super();
|
|
614
|
-
m(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
|
|
615
|
-
m(this, "_validStatusChange$", new Xe());
|
|
616
|
-
m(this, "_ruleChange$", new Xe());
|
|
617
|
-
m(this, "ruleChange$", this._ruleChange$.asObservable());
|
|
618
|
-
m(this, "validStatusChange$", this._validStatusChange$.asObservable());
|
|
619
|
-
this._dataValidationModel = a, this._univerInstanceService = e, this._dataValidatorRegistryService = t, this._dataValidationCacheService = r, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService = o, this._commandService = n, this._initRuleUpdateListener(), this.disposeWithMe(() => {
|
|
620
|
-
this._ruleChange$.complete(), this._validStatusChange$.complete();
|
|
621
|
-
}), this._initUniverInstanceListener();
|
|
622
|
-
}
|
|
623
|
-
_initUniverInstanceListener() {
|
|
624
|
-
this.disposeWithMe(
|
|
625
|
-
this._univerInstanceService.unitDisposed$.subscribe((a) => {
|
|
626
|
-
this._ruleMatrixMap.delete(a.getUnitId());
|
|
627
|
-
})
|
|
628
|
-
), this.disposeWithMe(
|
|
629
|
-
this._commandService.onCommandExecuted((a) => {
|
|
630
|
-
if (a.id === mt.id) {
|
|
631
|
-
const { unitId: e, subUnitId: t } = a.params, r = this._ruleMatrixMap.get(e);
|
|
632
|
-
r && r.delete(t);
|
|
633
|
-
}
|
|
634
|
-
})
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
_initRuleUpdateListener() {
|
|
638
|
-
const a = this._dataValidationModel.getAll();
|
|
639
|
-
for (const [e, t] of a)
|
|
640
|
-
for (const [r, i] of t)
|
|
641
|
-
for (const o of i)
|
|
642
|
-
this._addRule(e, r, o), this._ruleChange$.next({
|
|
643
|
-
type: "add",
|
|
644
|
-
unitId: e,
|
|
645
|
-
subUnitId: r,
|
|
646
|
-
rule: o,
|
|
647
|
-
source: "patched"
|
|
648
|
-
});
|
|
649
|
-
this.disposeWithMe(
|
|
650
|
-
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
651
|
-
switch (e.type) {
|
|
652
|
-
case "add":
|
|
653
|
-
this._addRule(e.unitId, e.subUnitId, e.rule);
|
|
654
|
-
break;
|
|
655
|
-
case "update":
|
|
656
|
-
this._updateRule(e.unitId, e.subUnitId, e.rule.uid, e.oldRule, e.updatePayload);
|
|
657
|
-
break;
|
|
658
|
-
case "remove":
|
|
659
|
-
this._removeRule(e.unitId, e.subUnitId, e.rule);
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
this._ruleChange$.next(e);
|
|
663
|
-
})
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
_ensureRuleMatrix(a, e) {
|
|
667
|
-
let t = this._ruleMatrixMap.get(a);
|
|
668
|
-
t || (t = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(a, t));
|
|
669
|
-
let r = t.get(e);
|
|
670
|
-
return r || (r = new Je(/* @__PURE__ */ new Map(), a, e, this._univerInstanceService), t.set(e, r)), r;
|
|
671
|
-
}
|
|
672
|
-
_addRuleSideEffect(a, e, t) {
|
|
673
|
-
this._ensureRuleMatrix(a, e).addRule(t), this._dataValidationCacheService.addRule(a, e, t), this._dataValidationFormulaService.addRule(a, e, t), this._dataValidationCustomFormulaService.addRule(a, e, t);
|
|
674
|
-
}
|
|
675
|
-
_addRule(a, e, t) {
|
|
676
|
-
(Array.isArray(t) ? t : [t]).forEach((i) => {
|
|
677
|
-
this._addRuleSideEffect(a, e, i);
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
_updateRule(a, e, t, r, i) {
|
|
681
|
-
const o = this._ensureRuleMatrix(a, e), n = {
|
|
682
|
-
...r,
|
|
683
|
-
...i.payload
|
|
684
|
-
};
|
|
685
|
-
i.type === V.RANGE ? o.updateRange(t, i.payload) : i.type === V.ALL && o.updateRange(t, i.payload.ranges), this._dataValidationCacheService.removeRule(a, e, r), this._dataValidationCacheService.addRule(a, e, n), this._dataValidationFormulaService.removeRule(a, e, r.uid), this._dataValidationFormulaService.addRule(a, e, n), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t), this._dataValidationCustomFormulaService.addRule(a, e, n);
|
|
686
|
-
}
|
|
687
|
-
_removeRule(a, e, t) {
|
|
688
|
-
this._ensureRuleMatrix(a, e).removeRule(t), this._dataValidationCacheService.removeRule(a, e, t), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t.uid);
|
|
689
|
-
}
|
|
690
|
-
getValidator(a) {
|
|
691
|
-
return this._dataValidatorRegistryService.getValidatorItem(a);
|
|
692
|
-
}
|
|
693
|
-
getRuleIdByLocation(a, e, t, r) {
|
|
694
|
-
return this._ensureRuleMatrix(a, e).getValue(t, r);
|
|
695
|
-
}
|
|
696
|
-
getRuleByLocation(a, e, t, r) {
|
|
697
|
-
const i = this.getRuleIdByLocation(a, e, t, r);
|
|
698
|
-
if (i)
|
|
699
|
-
return this._dataValidationModel.getRuleById(a, e, i);
|
|
700
|
-
}
|
|
701
|
-
validator(a, e, t) {
|
|
702
|
-
const { col: r, row: i, unitId: o, subUnitId: n, worksheet: l } = e, u = (p, R) => {
|
|
703
|
-
t && t(p, R), R && this._validStatusChange$.next({
|
|
704
|
-
unitId: o,
|
|
705
|
-
subUnitId: n,
|
|
706
|
-
ruleId: a.uid,
|
|
707
|
-
status: p,
|
|
708
|
-
row: i,
|
|
709
|
-
col: r
|
|
710
|
-
});
|
|
711
|
-
}, c = l.getCellValueOnly(i, r), d = this.getValidator(a.type), g = l.getCellRaw(i, r), f = re(g);
|
|
712
|
-
if (d) {
|
|
713
|
-
const p = this._dataValidationCacheService.ensureCache(o, n), R = p.getValue(i, r);
|
|
714
|
-
return R == null ? (p.setValue(i, r, A.VALIDATING), d.validator(
|
|
715
|
-
{
|
|
716
|
-
value: f,
|
|
717
|
-
unitId: o,
|
|
718
|
-
subUnitId: n,
|
|
719
|
-
row: i,
|
|
720
|
-
column: r,
|
|
721
|
-
worksheet: e.worksheet,
|
|
722
|
-
workbook: e.workbook,
|
|
723
|
-
interceptValue: re(c),
|
|
724
|
-
t: g == null ? void 0 : g.t
|
|
725
|
-
},
|
|
726
|
-
a
|
|
727
|
-
).then((E) => {
|
|
728
|
-
const _ = E ? A.VALID : A.INVALID, O = p.getValue(i, r);
|
|
729
|
-
_ === A.VALID ? p.realDeleteValue(i, r) : p.setValue(i, r, _), u(_, R !== O);
|
|
730
|
-
}), A.VALIDATING) : (u(R != null ? R : A.VALID, !1), R != null ? R : A.VALID);
|
|
731
|
-
} else
|
|
732
|
-
return u(A.VALID, !1), A.VALID;
|
|
733
|
-
}
|
|
734
|
-
getRuleObjectMatrix(a, e) {
|
|
735
|
-
return this._ensureRuleMatrix(a, e);
|
|
736
|
-
}
|
|
737
|
-
getRuleById(a, e, t) {
|
|
738
|
-
return this._dataValidationModel.getRuleById(a, e, t);
|
|
739
|
-
}
|
|
740
|
-
getRuleIndex(a, e, t) {
|
|
741
|
-
return this._dataValidationModel.getRuleIndex(a, e, t);
|
|
742
|
-
}
|
|
743
|
-
getRules(a, e) {
|
|
744
|
-
return [...this._dataValidationModel.getRules(a, e)];
|
|
745
|
-
}
|
|
746
|
-
getUnitRules(a) {
|
|
747
|
-
return this._dataValidationModel.getUnitRules(a);
|
|
748
|
-
}
|
|
749
|
-
deleteUnitRules(a) {
|
|
750
|
-
return this._dataValidationModel.deleteUnitRules(a);
|
|
751
|
-
}
|
|
752
|
-
getSubUnitIds(a) {
|
|
753
|
-
return this._dataValidationModel.getSubUnitIds(a);
|
|
754
|
-
}
|
|
755
|
-
getAll() {
|
|
756
|
-
return this._dataValidationModel.getAll();
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
F = ua([
|
|
760
|
-
K(0, v(he)),
|
|
761
|
-
K(1, D),
|
|
762
|
-
K(2, v(q)),
|
|
763
|
-
K(3, v(Q)),
|
|
764
|
-
K(4, v(G)),
|
|
765
|
-
K(5, v(W)),
|
|
766
|
-
K(6, U)
|
|
767
|
-
], F);
|
|
768
|
-
const ye = 1, Te = 0;
|
|
769
|
-
function it(s, a) {
|
|
770
|
-
return M.isBlank(s) ? a.t("dataValidation.validFail.value") : S(s) ? a.t("dataValidation.validFail.primitive") : "";
|
|
771
|
-
}
|
|
772
|
-
const Re = (s) => M.isDefine(s) && String(s).toLowerCase() === "true" ? "1" : String(s).toLowerCase() === "false" ? "0" : s;
|
|
773
|
-
class ca extends Y {
|
|
774
|
-
constructor() {
|
|
775
|
-
super(...arguments);
|
|
776
|
-
m(this, "id", T.CHECKBOX);
|
|
777
|
-
m(this, "title", "dataValidation.checkbox.title");
|
|
778
|
-
m(this, "operators", []);
|
|
779
|
-
m(this, "scopes", ["sheet"]);
|
|
780
|
-
m(this, "order", 41);
|
|
781
|
-
m(this, "offsetFormulaByRange", !1);
|
|
782
|
-
m(this, "_formulaService", this.injector.get(G));
|
|
783
|
-
m(this, "skipDefaultFontRender", (e, t, r) => {
|
|
784
|
-
const { unitId: i, subUnitId: o } = r, { formula1: n, formula2: l } = this.parseFormulaSync(e, i, o), u = `${t != null ? t : ""}`;
|
|
785
|
-
return !u || u === `${n}` || u === `${l}`;
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
validatorFormula(e, t, r) {
|
|
789
|
-
const { formula1: i, formula2: o } = e, n = i === o;
|
|
790
|
-
if (M.isBlank(i) && M.isBlank(o))
|
|
791
|
-
return {
|
|
792
|
-
success: !0
|
|
793
|
-
};
|
|
794
|
-
if (n)
|
|
795
|
-
return {
|
|
796
|
-
success: !1,
|
|
797
|
-
formula1: this.localeService.t("dataValidation.validFail.checkboxEqual"),
|
|
798
|
-
formula2: this.localeService.t("dataValidation.validFail.checkboxEqual")
|
|
799
|
-
};
|
|
800
|
-
const l = it(i, this.localeService), u = it(o, this.localeService);
|
|
801
|
-
return {
|
|
802
|
-
success: !l && !u,
|
|
803
|
-
formula1: l,
|
|
804
|
-
formula2: u
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
async parseFormula(e, t, r) {
|
|
808
|
-
var d, g, f, p;
|
|
809
|
-
const { formula1: i = ye, formula2: o = Te } = e, n = await this._formulaService.getRuleFormulaResult(t, r, e.uid), l = S(i) ? ne((g = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : g[0][0]) : i, u = S(o) ? ne((p = (f = n == null ? void 0 : n[1]) == null ? void 0 : f.result) == null ? void 0 : p[0][0]) : o, c = C(String(l)) && C(String(u));
|
|
810
|
-
return {
|
|
811
|
-
formula1: Re(l),
|
|
812
|
-
formula2: Re(u),
|
|
813
|
-
originFormula1: l,
|
|
814
|
-
originFormula2: u,
|
|
815
|
-
isFormulaValid: c
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
getExtraStyle(e, t) {
|
|
819
|
-
return {
|
|
820
|
-
tb: Ee.CLIP
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
parseFormulaSync(e, t, r) {
|
|
824
|
-
var d, g, f, p;
|
|
825
|
-
const { formula1: i = ye, formula2: o = Te } = e, n = this._formulaService.getRuleFormulaResultSync(t, r, e.uid), l = S(i) ? ne((g = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : g[0][0]) : i, u = S(o) ? ne((p = (f = n == null ? void 0 : n[1]) == null ? void 0 : f.result) == null ? void 0 : p[0][0]) : o, c = C(String(l)) && C(String(u));
|
|
826
|
-
return {
|
|
827
|
-
formula1: Re(l),
|
|
828
|
-
formula2: Re(u),
|
|
829
|
-
originFormula1: l,
|
|
830
|
-
originFormula2: u,
|
|
831
|
-
isFormulaValid: c
|
|
832
|
-
};
|
|
833
|
-
}
|
|
834
|
-
async isValidType(e, t, r) {
|
|
835
|
-
const { value: i, unitId: o, subUnitId: n } = e, { formula1: l, formula2: u, originFormula1: c, originFormula2: d } = await this.parseFormula(r, o, n);
|
|
836
|
-
return !M.isDefine(l) || !M.isDefine(u) ? !0 : M.isDefine(i) && (String(i) === String(l) || String(i) === String(u) || String(i) === String(c != null ? c : "") || String(i) === String(d != null ? d : ""));
|
|
837
|
-
}
|
|
838
|
-
generateRuleErrorMessage(e) {
|
|
839
|
-
return this.localeService.t("dataValidation.checkbox.error");
|
|
840
|
-
}
|
|
841
|
-
generateRuleName(e) {
|
|
842
|
-
return this.titleStr;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
const da = {
|
|
846
|
-
[h.BETWEEN]: "dataValidation.date.operators.between",
|
|
847
|
-
[h.EQUAL]: "dataValidation.date.operators.equal",
|
|
848
|
-
[h.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
|
|
849
|
-
[h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.operators.greaterThanOrEqual",
|
|
850
|
-
[h.LESS_THAN]: "dataValidation.date.operators.lessThan",
|
|
851
|
-
[h.LESS_THAN_OR_EQUAL]: "dataValidation.date.operators.lessThanOrEqual",
|
|
852
|
-
[h.NOT_BETWEEN]: "dataValidation.date.operators.notBetween",
|
|
853
|
-
[h.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
|
|
854
|
-
};
|
|
855
|
-
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 + "";
|
|
856
|
-
const st = {
|
|
857
|
-
[h.BETWEEN]: "dataValidation.date.ruleName.between",
|
|
858
|
-
[h.EQUAL]: "dataValidation.date.ruleName.equal",
|
|
859
|
-
[h.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
|
|
860
|
-
[h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.ruleName.greaterThanOrEqual",
|
|
861
|
-
[h.LESS_THAN]: "dataValidation.date.ruleName.lessThan",
|
|
862
|
-
[h.LESS_THAN_OR_EQUAL]: "dataValidation.date.ruleName.lessThanOrEqual",
|
|
863
|
-
[h.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
|
|
864
|
-
[h.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual",
|
|
865
|
-
NONE: "dataValidation.date.ruleName.legal"
|
|
866
|
-
}, ha = {
|
|
867
|
-
[h.BETWEEN]: "dataValidation.date.errorMsg.between",
|
|
868
|
-
[h.EQUAL]: "dataValidation.date.errorMsg.equal",
|
|
869
|
-
[h.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
|
|
870
|
-
[h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.greaterThanOrEqual",
|
|
871
|
-
[h.LESS_THAN]: "dataValidation.date.errorMsg.lessThan",
|
|
872
|
-
[h.LESS_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.lessThanOrEqual",
|
|
873
|
-
[h.NOT_BETWEEN]: "dataValidation.date.errorMsg.notBetween",
|
|
874
|
-
[h.NOT_EQUAL]: "dataValidation.date.errorMsg.notEqual",
|
|
875
|
-
NONE: "dataValidation.date.errorMsg.legal"
|
|
876
|
-
}, Be = [
|
|
877
|
-
h.BETWEEN,
|
|
878
|
-
h.NOT_BETWEEN
|
|
879
|
-
], ce = "{FORMULA1}", de = "{FORMULA2}", je = (s) => {
|
|
880
|
-
var e, t;
|
|
881
|
-
if (s == null || typeof s == "boolean")
|
|
882
|
-
return;
|
|
883
|
-
if (typeof s == "number" || !Number.isNaN(+s))
|
|
884
|
-
return +s;
|
|
885
|
-
const a = (e = L.parseDate(s)) == null ? void 0 : e.v;
|
|
886
|
-
return M.isDefine(a) ? a : (t = L.parseDate(lt(s).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : t.v;
|
|
887
|
-
};
|
|
888
|
-
class ma extends Y {
|
|
889
|
-
constructor() {
|
|
890
|
-
super(...arguments);
|
|
891
|
-
m(this, "id", T.DATE);
|
|
892
|
-
m(this, "title", "dataValidation.date.title");
|
|
893
|
-
m(this, "order", 40);
|
|
894
|
-
m(this, "operators", [
|
|
895
|
-
h.BETWEEN,
|
|
896
|
-
h.EQUAL,
|
|
897
|
-
h.GREATER_THAN,
|
|
898
|
-
h.GREATER_THAN_OR_EQUAL,
|
|
899
|
-
h.LESS_THAN,
|
|
900
|
-
h.LESS_THAN_OR_EQUAL,
|
|
901
|
-
h.NOT_BETWEEN,
|
|
902
|
-
h.NOT_EQUAL
|
|
903
|
-
]);
|
|
904
|
-
m(this, "scopes", ["sheet"]);
|
|
905
|
-
m(this, "_customFormulaService", this.injector.get(W));
|
|
906
|
-
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
907
|
-
}
|
|
908
|
-
async parseFormula(e, t, r, i, o) {
|
|
909
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
|
|
910
|
-
return {
|
|
911
|
-
formula1: je(S(u) ? n == null ? void 0 : n.v : u),
|
|
912
|
-
formula2: je(S(c) ? l == null ? void 0 : l.v : c),
|
|
913
|
-
isFormulaValid: d
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
async isValidType(e) {
|
|
917
|
-
const { interceptValue: t, value: r } = e;
|
|
918
|
-
return typeof r == "number" && typeof t == "string" ? !!L.parseDate(t) : typeof t == "string" ? !!L.parseDate(t) : !1;
|
|
919
|
-
}
|
|
920
|
-
_validatorSingleFormula(e) {
|
|
921
|
-
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e) || !!(e && L.parseDate(e)));
|
|
922
|
-
}
|
|
923
|
-
validatorFormula(e, t, r) {
|
|
924
|
-
const i = e.operator;
|
|
925
|
-
if (!i)
|
|
926
|
-
return {
|
|
927
|
-
success: !0
|
|
928
|
-
};
|
|
929
|
-
const o = this._validatorSingleFormula(e.formula1), n = this.localeService.t("dataValidation.validFail.date");
|
|
930
|
-
if (Be.includes(i)) {
|
|
931
|
-
const u = this._validatorSingleFormula(e.formula2);
|
|
932
|
-
return {
|
|
933
|
-
success: o && u,
|
|
934
|
-
formula1: o ? void 0 : n,
|
|
935
|
-
formula2: u ? void 0 : n
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
return {
|
|
939
|
-
success: o,
|
|
940
|
-
formula1: o ? void 0 : n
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
normalizeFormula(e, t, r) {
|
|
944
|
-
const { formula1: i, formula2: o, bizInfo: n } = e, l = (u) => {
|
|
945
|
-
var d;
|
|
946
|
-
if (!u)
|
|
947
|
-
return u;
|
|
948
|
-
let c;
|
|
949
|
-
if (!Number.isNaN(+u))
|
|
950
|
-
c = L.dateFromSerial(+u);
|
|
951
|
-
else {
|
|
952
|
-
const g = (d = L.parseDate(u)) == null ? void 0 : d.v;
|
|
953
|
-
if (g == null)
|
|
954
|
-
return "";
|
|
955
|
-
c = L.dateFromSerial(g);
|
|
956
|
-
}
|
|
957
|
-
return lt(`${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");
|
|
958
|
-
};
|
|
959
|
-
return {
|
|
960
|
-
formula1: S(i) ? i : l(`${i}`),
|
|
961
|
-
formula2: S(o) ? o : l(`${o}`)
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
transform(e, t, r) {
|
|
965
|
-
const { value: i } = e;
|
|
966
|
-
return {
|
|
967
|
-
...e,
|
|
968
|
-
value: je(i)
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
get operatorNames() {
|
|
972
|
-
return this.operators.map((e) => this.localeService.t(da[e]));
|
|
973
|
-
}
|
|
974
|
-
generateRuleName(e) {
|
|
975
|
-
var r, i;
|
|
976
|
-
if (!e.operator)
|
|
977
|
-
return this.localeService.t(st.NONE);
|
|
978
|
-
const t = this.localeService.t(st[e.operator]).replace(ce, (r = e.formula1) != null ? r : "").replace(de, (i = e.formula2) != null ? i : "");
|
|
979
|
-
return `${this.titleStr} ${t}`;
|
|
980
|
-
}
|
|
981
|
-
generateRuleErrorMessage(e, t) {
|
|
982
|
-
if (!e.operator)
|
|
983
|
-
return this.titleStr;
|
|
984
|
-
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
985
|
-
return `${this.localeService.t(ha[e.operator]).replace(ce, r != null ? r : "").replace(de, i != null ? i : "")}`;
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
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 + "";
|
|
989
|
-
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 + "";
|
|
990
|
-
const Ce = {
|
|
991
|
-
[h.BETWEEN]: "dataValidation.errorMsg.between",
|
|
992
|
-
[h.EQUAL]: "dataValidation.errorMsg.equal",
|
|
993
|
-
[h.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
994
|
-
[h.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
|
|
995
|
-
[h.LESS_THAN]: "dataValidation.errorMsg.lessThan",
|
|
996
|
-
[h.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
|
|
997
|
-
[h.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
998
|
-
[h.NOT_EQUAL]: "dataValidation.errorMsg.notEqual",
|
|
999
|
-
NONE: "dataValidation.errorMsg.legal"
|
|
1000
|
-
};
|
|
1001
|
-
function Fe(s) {
|
|
1002
|
-
return +s;
|
|
1003
|
-
}
|
|
1004
|
-
class ga extends Y {
|
|
1005
|
-
constructor() {
|
|
1006
|
-
super(...arguments);
|
|
1007
|
-
m(this, "_customFormulaService", this.injector.get(W));
|
|
1008
|
-
m(this, "id", T.DECIMAL);
|
|
1009
|
-
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
1010
|
-
m(this, "title", "dataValidation.decimal.title");
|
|
1011
|
-
m(this, "order", 20);
|
|
1012
|
-
m(this, "operators", [
|
|
1013
|
-
h.BETWEEN,
|
|
1014
|
-
h.EQUAL,
|
|
1015
|
-
h.GREATER_THAN,
|
|
1016
|
-
h.GREATER_THAN_OR_EQUAL,
|
|
1017
|
-
h.LESS_THAN,
|
|
1018
|
-
h.LESS_THAN_OR_EQUAL,
|
|
1019
|
-
h.NOT_BETWEEN,
|
|
1020
|
-
h.NOT_EQUAL
|
|
1021
|
-
]);
|
|
1022
|
-
m(this, "scopes", ["sheet"]);
|
|
1023
|
-
}
|
|
1024
|
-
_isFormulaOrNumber(e) {
|
|
1025
|
-
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e));
|
|
1026
|
-
}
|
|
1027
|
-
async isValidType(e, t, r) {
|
|
1028
|
-
const { value: i } = e;
|
|
1029
|
-
return !Number.isNaN(Fe(i));
|
|
1030
|
-
}
|
|
1031
|
-
transform(e, t, r) {
|
|
1032
|
-
const { value: i } = e;
|
|
1033
|
-
return {
|
|
1034
|
-
...e,
|
|
1035
|
-
value: Fe(i)
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
_parseNumber(e) {
|
|
1039
|
-
return e == null ? Number.NaN : +e;
|
|
1040
|
-
}
|
|
1041
|
-
async parseFormula(e, t, r, i, o) {
|
|
1042
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
|
|
1043
|
-
return {
|
|
1044
|
-
formula1: this._parseNumber(S(u) ? n == null ? void 0 : n.v : u),
|
|
1045
|
-
formula2: this._parseNumber(S(c) ? l == null ? void 0 : l.v : c),
|
|
1046
|
-
isFormulaValid: d
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
validatorFormula(e, t, r) {
|
|
1050
|
-
const i = e.operator;
|
|
1051
|
-
if (!i)
|
|
1052
|
-
return {
|
|
1053
|
-
success: !0
|
|
1054
|
-
};
|
|
1055
|
-
const o = M.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), n = M.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = Be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
1056
|
-
return l ? {
|
|
1057
|
-
success: o && n,
|
|
1058
|
-
formula1: o ? void 0 : u,
|
|
1059
|
-
formula2: n ? void 0 : u
|
|
1060
|
-
} : {
|
|
1061
|
-
success: o,
|
|
1062
|
-
formula1: o ? "" : u
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
generateRuleErrorMessage(e, t) {
|
|
1066
|
-
if (!e.operator)
|
|
1067
|
-
return this.localeService.t(Ce.NONE).replace("{TYPE}", this.titleStr);
|
|
1068
|
-
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
1069
|
-
return `${this.localeService.t(Ce[e.operator]).replace(ce, r != null ? r : "").replace(de, i != null ? i : "")}`;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
function pa(s) {
|
|
1073
|
-
var e, t;
|
|
1074
|
-
if (!s)
|
|
1075
|
-
return [];
|
|
1076
|
-
const a = /* @__PURE__ */ new Set();
|
|
1077
|
-
for (let r = 0, i = s.length; r < i; r++) {
|
|
1078
|
-
const o = s[r];
|
|
1079
|
-
if (o)
|
|
1080
|
-
for (let n = 0, l = o.length; n < l; n++) {
|
|
1081
|
-
const u = o[n], c = re(u);
|
|
1082
|
-
if (c != null) {
|
|
1083
|
-
if (typeof c != "string" && typeof (u == null ? void 0 : u.s) == "object" && ((t = (e = u.s) == null ? void 0 : e.n) != null && t.pattern)) {
|
|
1084
|
-
a.add(L.format(u.s.n.pattern, c, { throws: !1 }));
|
|
1085
|
-
continue;
|
|
1086
|
-
}
|
|
1087
|
-
const d = typeof c == "string" ? c : String(c);
|
|
1088
|
-
C(d) && a.add(d);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
return [...a];
|
|
1093
|
-
}
|
|
1094
|
-
const fa = [
|
|
1095
|
-
"if",
|
|
1096
|
-
"indirect",
|
|
1097
|
-
"choose",
|
|
1098
|
-
"offset"
|
|
1099
|
-
];
|
|
1100
|
-
function _a(s, a) {
|
|
1101
|
-
if (!S(s) || ht(s.slice(1)))
|
|
1102
|
-
return !0;
|
|
1103
|
-
const t = a.sequenceNodesBuilder(s);
|
|
1104
|
-
return t && t.some((r) => typeof r == "object" && r.nodeType === $t.FUNCTION && fa.indexOf(r.token.toLowerCase()) > -1);
|
|
1105
|
-
}
|
|
1106
|
-
function va(s, a) {
|
|
1107
|
-
const { formula1: e = "", ranges: t } = s;
|
|
1108
|
-
if (ht(e.slice(1))) {
|
|
1109
|
-
const i = kt(e.slice(1));
|
|
1110
|
-
if ((!i.sheetName || i.sheetName === a) && t.some((o) => w.intersects(o, i.range)))
|
|
1111
|
-
return !0;
|
|
1112
|
-
}
|
|
1113
|
-
return !1;
|
|
1114
|
-
}
|
|
1115
|
-
class Rt extends Y {
|
|
1116
|
-
constructor() {
|
|
1117
|
-
super(...arguments);
|
|
1118
|
-
m(this, "formulaService", this.injector.get(G));
|
|
1119
|
-
m(this, "_lexer", this.injector.get(X));
|
|
1120
|
-
m(this, "_univerInstanceService", this.injector.get(D));
|
|
1121
|
-
m(this, "_listCacheService", this.injector.get(ue));
|
|
1122
|
-
m(this, "order", 50);
|
|
1123
|
-
m(this, "offsetFormulaByRange", !1);
|
|
1124
|
-
m(this, "id", T.LIST);
|
|
1125
|
-
m(this, "title", "dataValidation.list.title");
|
|
1126
|
-
m(this, "operators", []);
|
|
1127
|
-
m(this, "scopes", ["sheet"]);
|
|
1128
|
-
m(this, "skipDefaultFontRender", (e) => e.renderMode !== $e.TEXT);
|
|
1129
|
-
}
|
|
1130
|
-
validatorFormula(e, t, r) {
|
|
1131
|
-
var u, c, d;
|
|
1132
|
-
const i = !M.isBlank(e.formula1), o = _a((u = e.formula1) != null ? u : "", this._lexer), n = (d = (c = this._univerInstanceService.getUnit(t, N.UNIVER_SHEET)) == null ? void 0 : c.getSheetBySheetId(r)) == null ? void 0 : d.getName(), l = va(e, n != null ? n : "");
|
|
1133
|
-
return {
|
|
1134
|
-
success: !!(i && o && !l),
|
|
1135
|
-
formula1: i ? o ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
|
-
getExtraStyle(e, t, { style: r }) {
|
|
1139
|
-
var o;
|
|
1140
|
-
const i = (o = r.tb !== Ee.OVERFLOW ? r.tb : Ee.CLIP) != null ? o : Ee.WRAP;
|
|
1141
|
-
if (e.type === T.LIST && (e.renderMode === $e.ARROW || e.renderMode === $e.TEXT)) {
|
|
1142
|
-
const n = this.getListWithColorMap(e), l = `${t != null ? t : ""}`, u = n[l];
|
|
1143
|
-
if (u)
|
|
1144
|
-
return {
|
|
1145
|
-
bg: {
|
|
1146
|
-
rgb: u
|
|
1147
|
-
},
|
|
1148
|
-
tb: i
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
return {
|
|
1152
|
-
tb: i
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
|
-
parseCellValue(e) {
|
|
1156
|
-
const t = e.toString();
|
|
1157
|
-
return Me(t);
|
|
1158
|
-
}
|
|
1159
|
-
async parseFormula(e, t, r) {
|
|
1160
|
-
var l, u;
|
|
1161
|
-
const i = await this.formulaService.getRuleFormulaResult(t, r, e.uid), o = ne((u = (l = i == null ? void 0 : i[0]) == null ? void 0 : l.result) == null ? void 0 : u[0][0]);
|
|
1162
|
-
return {
|
|
1163
|
-
formula1: void 0,
|
|
1164
|
-
formula2: void 0,
|
|
1165
|
-
isFormulaValid: C(String(o))
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
async isValidType(e, t, r) {
|
|
1169
|
-
const { value: i, unitId: o, subUnitId: n } = e, { formula1: l = "" } = r, u = S(l) ? this._listCacheService.getOrCompute(
|
|
1170
|
-
o,
|
|
1171
|
-
n,
|
|
1172
|
-
r
|
|
1173
|
-
).list : Me(l);
|
|
1174
|
-
return this.parseCellValue(i).every((d) => u.includes(d));
|
|
1175
|
-
}
|
|
1176
|
-
generateRuleName() {
|
|
1177
|
-
return this.localeService.t("dataValidation.list.name");
|
|
1178
|
-
}
|
|
1179
|
-
generateRuleErrorMessage() {
|
|
1180
|
-
return this.localeService.t("dataValidation.list.error");
|
|
1181
|
-
}
|
|
1182
|
-
_getUnitAndSubUnit(e, t) {
|
|
1183
|
-
var o, n;
|
|
1184
|
-
const r = (o = e ? this._univerInstanceService.getUniverSheetInstance(e) : void 0) != null ? o : this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1185
|
-
if (!r) return null;
|
|
1186
|
-
const i = (n = t ? r.getSheetBySheetId(t) : void 0) != null ? n : r.getActiveSheet();
|
|
1187
|
-
return i ? {
|
|
1188
|
-
unitId: r.getUnitId(),
|
|
1189
|
-
subUnitId: i.getSheetId()
|
|
1190
|
-
} : null;
|
|
1191
|
-
}
|
|
1192
|
-
getList(e, t, r) {
|
|
1193
|
-
const i = this._getUnitAndSubUnit(t, r);
|
|
1194
|
-
if (!i) return [];
|
|
1195
|
-
const { unitId: o, subUnitId: n } = i;
|
|
1196
|
-
return this._listCacheService.getOrCompute(
|
|
1197
|
-
o,
|
|
1198
|
-
n,
|
|
1199
|
-
e
|
|
1200
|
-
).list;
|
|
1201
|
-
}
|
|
1202
|
-
async getListAsync(e, t, r) {
|
|
1203
|
-
var c, d;
|
|
1204
|
-
const { formula1: i = "" } = e, o = this._getUnitAndSubUnit(t, r);
|
|
1205
|
-
if (!o) return [];
|
|
1206
|
-
const { unitId: n, subUnitId: l } = o, u = await this.formulaService.getRuleFormulaResult(n, l, e.uid);
|
|
1207
|
-
return S(i) ? pa((d = (c = u == null ? void 0 : u[0]) == null ? void 0 : c.result) == null ? void 0 : d[0][0]) : Me(i);
|
|
1208
|
-
}
|
|
1209
|
-
getListWithColor(e, t, r) {
|
|
1210
|
-
const i = this._getUnitAndSubUnit(t, r);
|
|
1211
|
-
if (!i) return [];
|
|
1212
|
-
const { unitId: o, subUnitId: n } = i;
|
|
1213
|
-
return this._listCacheService.getOrCompute(
|
|
1214
|
-
o,
|
|
1215
|
-
n,
|
|
1216
|
-
e
|
|
1217
|
-
).listWithColor;
|
|
1218
|
-
}
|
|
1219
|
-
getListWithColorMap(e, t, r) {
|
|
1220
|
-
const i = this._getUnitAndSubUnit(t, r);
|
|
1221
|
-
if (!i) return {};
|
|
1222
|
-
const { unitId: o, subUnitId: n } = i;
|
|
1223
|
-
return this._listCacheService.getOrCompute(
|
|
1224
|
-
o,
|
|
1225
|
-
n,
|
|
1226
|
-
e
|
|
1227
|
-
).colorMap;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
class Ra extends Y {
|
|
1231
|
-
constructor() {
|
|
1232
|
-
super(...arguments);
|
|
1233
|
-
m(this, "id", T.TEXT_LENGTH);
|
|
1234
|
-
m(this, "title", "dataValidation.textLength.title");
|
|
1235
|
-
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
1236
|
-
m(this, "order", 30);
|
|
1237
|
-
m(this, "operators", [
|
|
1238
|
-
h.BETWEEN,
|
|
1239
|
-
h.EQUAL,
|
|
1240
|
-
h.GREATER_THAN,
|
|
1241
|
-
h.GREATER_THAN_OR_EQUAL,
|
|
1242
|
-
h.LESS_THAN,
|
|
1243
|
-
h.LESS_THAN_OR_EQUAL,
|
|
1244
|
-
h.NOT_BETWEEN,
|
|
1245
|
-
h.NOT_EQUAL
|
|
1246
|
-
]);
|
|
1247
|
-
m(this, "scopes", ["sheet"]);
|
|
1248
|
-
m(this, "_customFormulaService", this.injector.get(W));
|
|
1249
|
-
}
|
|
1250
|
-
_isFormulaOrInt(e) {
|
|
1251
|
-
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
1252
|
-
}
|
|
1253
|
-
validatorFormula(e, t, r) {
|
|
1254
|
-
const i = e.operator;
|
|
1255
|
-
if (!i)
|
|
1256
|
-
return {
|
|
1257
|
-
success: !1
|
|
1258
|
-
};
|
|
1259
|
-
const o = M.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = M.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
1260
|
-
return l ? {
|
|
1261
|
-
success: o && n,
|
|
1262
|
-
formula1: o ? void 0 : u,
|
|
1263
|
-
formula2: n ? void 0 : u
|
|
1264
|
-
} : {
|
|
1265
|
-
success: o,
|
|
1266
|
-
formula1: u
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
_parseNumber(e) {
|
|
1270
|
-
return e == null ? Number.NaN : +e;
|
|
1271
|
-
}
|
|
1272
|
-
async parseFormula(e, t, r, i, o) {
|
|
1273
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
|
|
1274
|
-
return {
|
|
1275
|
-
formula1: this._parseNumber(S(u) ? n == null ? void 0 : n.v : u),
|
|
1276
|
-
formula2: this._parseNumber(S(c) ? l == null ? void 0 : l.v : c),
|
|
1277
|
-
isFormulaValid: d
|
|
1278
|
-
};
|
|
1279
|
-
}
|
|
1280
|
-
transform(e, t, r) {
|
|
1281
|
-
return {
|
|
1282
|
-
...e,
|
|
1283
|
-
value: e.value.toString().length
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
async isValidType(e, t, r) {
|
|
1287
|
-
const { value: i } = e;
|
|
1288
|
-
return typeof i == "string" || typeof i == "number";
|
|
1289
|
-
}
|
|
1290
|
-
generateRuleErrorMessage(e, t) {
|
|
1291
|
-
if (!e.operator)
|
|
1292
|
-
return this.titleStr;
|
|
1293
|
-
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
1294
|
-
return `${this.localeService.t(Bt[e.operator]).replace(ce, r != null ? r : "").replace(de, i != null ? i : "")}`;
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
function St(s) {
|
|
1298
|
-
var e, t;
|
|
1299
|
-
return s ? s.p ? !((t = (e = s.p.body) == null ? void 0 : e.dataStream) != null ? t : "").slice(0, -2).trim() : M.isBlank(s.v) : !0;
|
|
1300
|
-
}
|
|
1301
|
-
function xe(s, a, e, t, r = "command", i = !0) {
|
|
1302
|
-
const o = t.get(X), n = t.get(q), l = [], u = [], c = t.get(F), d = t.get(D), g = Ze(d, { unitId: s, subUnitId: a });
|
|
1303
|
-
if (!g)
|
|
1304
|
-
return {
|
|
1305
|
-
redoMutations: l,
|
|
1306
|
-
undoMutations: u
|
|
1307
|
-
};
|
|
1308
|
-
const { worksheet: f } = g, p = new Ve();
|
|
1309
|
-
let R = !1;
|
|
1310
|
-
function E(_, O) {
|
|
1311
|
-
i && _.forEach(($) => {
|
|
1312
|
-
H.foreach($, (x, k) => {
|
|
1313
|
-
const P = f.getCellRaw(x, k), J = vt(P);
|
|
1314
|
-
(St(P) || J === O) && !(P != null && P.p) && (R = !0, p.setValue(x, k, {
|
|
1315
|
-
v: O,
|
|
1316
|
-
p: null
|
|
1317
|
-
}));
|
|
1318
|
-
});
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
if (e.forEach((_) => {
|
|
1322
|
-
switch (_.type) {
|
|
1323
|
-
case "delete":
|
|
1324
|
-
l.push({
|
|
1325
|
-
id: I.id,
|
|
1326
|
-
params: {
|
|
1327
|
-
unitId: s,
|
|
1328
|
-
subUnitId: a,
|
|
1329
|
-
ruleId: _.rule.uid,
|
|
1330
|
-
source: r
|
|
1331
|
-
}
|
|
1332
|
-
}), u.unshift({
|
|
1333
|
-
id: b.id,
|
|
1334
|
-
params: {
|
|
1335
|
-
unitId: s,
|
|
1336
|
-
subUnitId: a,
|
|
1337
|
-
rule: _.rule,
|
|
1338
|
-
index: _.index,
|
|
1339
|
-
source: r
|
|
1340
|
-
}
|
|
1341
|
-
});
|
|
1342
|
-
break;
|
|
1343
|
-
case "update": {
|
|
1344
|
-
if (me(_.rule.type, n)) {
|
|
1345
|
-
const $ = _.oldRanges[0].startRow, x = _.oldRanges[0].startColumn, k = _.newRanges[0].startRow, P = _.newRanges[0].startColumn, J = k - $, ge = P - x, pe = S(_.rule.formula1) ? o.moveFormulaRefOffset(_.rule.formula1, ge, J) : _.rule.formula1, fe = S(_.rule.formula2) ? o.moveFormulaRefOffset(_.rule.formula2, ge, J) : _.rule.formula2;
|
|
1346
|
-
pe !== _.rule.formula1 || fe !== _.rule.formula2 || !ut(_.newRanges, _.oldRanges) ? (l.push({
|
|
1347
|
-
id: y.id,
|
|
1348
|
-
params: {
|
|
1349
|
-
unitId: s,
|
|
1350
|
-
subUnitId: a,
|
|
1351
|
-
ruleId: _.ruleId,
|
|
1352
|
-
payload: {
|
|
1353
|
-
type: V.ALL,
|
|
1354
|
-
payload: {
|
|
1355
|
-
formula1: pe,
|
|
1356
|
-
formula2: fe,
|
|
1357
|
-
ranges: _.newRanges
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
}), u.unshift({
|
|
1362
|
-
id: y.id,
|
|
1363
|
-
params: {
|
|
1364
|
-
unitId: s,
|
|
1365
|
-
subUnitId: a,
|
|
1366
|
-
ruleId: _.ruleId,
|
|
1367
|
-
payload: {
|
|
1368
|
-
type: V.ALL,
|
|
1369
|
-
payload: {
|
|
1370
|
-
formula1: _.rule.formula1,
|
|
1371
|
-
formula2: _.rule.formula2,
|
|
1372
|
-
ranges: _.oldRanges
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
})) : (l.push({
|
|
1377
|
-
id: y.id,
|
|
1378
|
-
params: {
|
|
1379
|
-
unitId: s,
|
|
1380
|
-
subUnitId: a,
|
|
1381
|
-
ruleId: _.ruleId,
|
|
1382
|
-
payload: {
|
|
1383
|
-
type: V.RANGE,
|
|
1384
|
-
payload: _.newRanges
|
|
1385
|
-
},
|
|
1386
|
-
source: r
|
|
1387
|
-
}
|
|
1388
|
-
}), u.unshift({
|
|
1389
|
-
id: y.id,
|
|
1390
|
-
params: {
|
|
1391
|
-
unitId: s,
|
|
1392
|
-
subUnitId: a,
|
|
1393
|
-
ruleId: _.ruleId,
|
|
1394
|
-
payload: {
|
|
1395
|
-
type: V.RANGE,
|
|
1396
|
-
payload: _.oldRanges
|
|
1397
|
-
},
|
|
1398
|
-
source: r
|
|
1399
|
-
}
|
|
1400
|
-
}));
|
|
1401
|
-
} else
|
|
1402
|
-
l.push({
|
|
1403
|
-
id: y.id,
|
|
1404
|
-
params: {
|
|
1405
|
-
unitId: s,
|
|
1406
|
-
subUnitId: a,
|
|
1407
|
-
ruleId: _.ruleId,
|
|
1408
|
-
payload: {
|
|
1409
|
-
type: V.RANGE,
|
|
1410
|
-
payload: _.newRanges
|
|
1411
|
-
},
|
|
1412
|
-
source: r
|
|
1413
|
-
}
|
|
1414
|
-
}), u.unshift({
|
|
1415
|
-
id: y.id,
|
|
1416
|
-
params: {
|
|
1417
|
-
unitId: s,
|
|
1418
|
-
subUnitId: a,
|
|
1419
|
-
ruleId: _.ruleId,
|
|
1420
|
-
payload: {
|
|
1421
|
-
type: V.RANGE,
|
|
1422
|
-
payload: _.oldRanges
|
|
1423
|
-
},
|
|
1424
|
-
source: r
|
|
1425
|
-
}
|
|
1426
|
-
});
|
|
1427
|
-
const O = c.getRuleById(s, a, _.ruleId);
|
|
1428
|
-
if (O && O.type === T.CHECKBOX) {
|
|
1429
|
-
const x = c.getValidator(T.CHECKBOX).parseFormulaSync(O, s, a);
|
|
1430
|
-
E(_.newRanges, x.formula2);
|
|
1431
|
-
}
|
|
1432
|
-
break;
|
|
1433
|
-
}
|
|
1434
|
-
case "add": {
|
|
1435
|
-
if (l.push({
|
|
1436
|
-
id: b.id,
|
|
1437
|
-
params: {
|
|
1438
|
-
unitId: s,
|
|
1439
|
-
subUnitId: a,
|
|
1440
|
-
rule: _.rule,
|
|
1441
|
-
source: r
|
|
1442
|
-
}
|
|
1443
|
-
}), u.unshift({
|
|
1444
|
-
id: I.id,
|
|
1445
|
-
params: {
|
|
1446
|
-
unitId: s,
|
|
1447
|
-
subUnitId: a,
|
|
1448
|
-
ruleId: _.rule.uid,
|
|
1449
|
-
source: r
|
|
1450
|
-
}
|
|
1451
|
-
}), _.rule.type === T.CHECKBOX) {
|
|
1452
|
-
const $ = c.getValidator(T.CHECKBOX).parseFormulaSync(_.rule, s, a);
|
|
1453
|
-
E(_.rule.ranges, $.originFormula2);
|
|
1454
|
-
}
|
|
1455
|
-
break;
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
}), R) {
|
|
1459
|
-
const _ = {
|
|
1460
|
-
id: le.id,
|
|
1461
|
-
params: {
|
|
1462
|
-
unitId: s,
|
|
1463
|
-
subUnitId: a,
|
|
1464
|
-
cellValue: p.getData()
|
|
1465
|
-
}
|
|
1466
|
-
}, O = {
|
|
1467
|
-
id: le.id,
|
|
1468
|
-
params: gt(t, _.params)
|
|
1469
|
-
};
|
|
1470
|
-
l.push(_), u.push(O);
|
|
1471
|
-
}
|
|
1472
|
-
return {
|
|
1473
|
-
redoMutations: l,
|
|
1474
|
-
undoMutations: u
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
const Sa = {
|
|
1478
|
-
type: z.COMMAND,
|
|
1479
|
-
id: "sheet.command.updateDataValidationRuleRange",
|
|
1480
|
-
handler(s, a) {
|
|
1481
|
-
if (!a)
|
|
1482
|
-
return !1;
|
|
1483
|
-
const { unitId: e, subUnitId: t, ranges: r, ruleId: i } = a, o = s.get(F), n = s.get(U), l = s.get(Z);
|
|
1484
|
-
if (!o.getRuleById(e, t, i))
|
|
1485
|
-
return !1;
|
|
1486
|
-
const c = o.getRuleObjectMatrix(e, t).clone();
|
|
1487
|
-
c.updateRange(i, r);
|
|
1488
|
-
const d = c.diff(o.getRules(e, t)), { redoMutations: g, undoMutations: f } = xe(e, t, d, s);
|
|
1489
|
-
return l.pushUndoRedo({
|
|
1490
|
-
undoMutations: f,
|
|
1491
|
-
redoMutations: g,
|
|
1492
|
-
unitID: e
|
|
1493
|
-
}), Le(g, n), !0;
|
|
1494
|
-
}
|
|
1495
|
-
}, Ea = {
|
|
1496
|
-
type: z.COMMAND,
|
|
1497
|
-
id: "sheet.command.addDataValidation",
|
|
1498
|
-
handler(s, a) {
|
|
1499
|
-
if (!a)
|
|
1500
|
-
return !1;
|
|
1501
|
-
const { unitId: e, subUnitId: t, rule: r } = a, i = s.get(F), o = s.get(U), n = s.get(Z), l = i.getRuleObjectMatrix(e, t).clone();
|
|
1502
|
-
l.addRule(r);
|
|
1503
|
-
const u = l.diff(i.getRules(e, t)), c = i.getValidator(r.type), d = {
|
|
1504
|
-
unitId: e,
|
|
1505
|
-
subUnitId: t,
|
|
1506
|
-
rule: {
|
|
1507
|
-
...r,
|
|
1508
|
-
...c == null ? void 0 : c.normalizeFormula(r, e, t)
|
|
1509
|
-
}
|
|
1510
|
-
}, { redoMutations: g, undoMutations: f } = xe(e, t, u, s);
|
|
1511
|
-
return g.push({
|
|
1512
|
-
id: b.id,
|
|
1513
|
-
params: d
|
|
1514
|
-
}), f.unshift({
|
|
1515
|
-
id: I.id,
|
|
1516
|
-
params: {
|
|
1517
|
-
unitId: e,
|
|
1518
|
-
subUnitId: t,
|
|
1519
|
-
ruleId: r.uid
|
|
1520
|
-
}
|
|
1521
|
-
}), n.pushUndoRedo({
|
|
1522
|
-
unitID: e,
|
|
1523
|
-
redoMutations: g,
|
|
1524
|
-
undoMutations: f
|
|
1525
|
-
}), Le(g, o), !0;
|
|
1526
|
-
}
|
|
1527
|
-
}, Ma = {
|
|
1528
|
-
type: z.COMMAND,
|
|
1529
|
-
id: "sheets.command.update-data-validation-setting",
|
|
1530
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1531
|
-
handler(s, a) {
|
|
1532
|
-
if (!a)
|
|
1533
|
-
return !1;
|
|
1534
|
-
const e = s.get(U), t = s.get(Z), r = s.get(F), i = s.get(q), { unitId: o, subUnitId: n, ruleId: l, setting: u } = a, c = i.getValidatorItem(u.type);
|
|
1535
|
-
if (!c)
|
|
1536
|
-
return !1;
|
|
1537
|
-
const d = r.getRuleById(o, n, l);
|
|
1538
|
-
if (!d)
|
|
1539
|
-
return !1;
|
|
1540
|
-
const g = { ...d, ...u };
|
|
1541
|
-
if (!c.validatorFormula(g, o, n).success)
|
|
1542
|
-
return !1;
|
|
1543
|
-
const f = {
|
|
1544
|
-
unitId: o,
|
|
1545
|
-
subUnitId: n,
|
|
1546
|
-
ruleId: l,
|
|
1547
|
-
payload: {
|
|
1548
|
-
type: V.SETTING,
|
|
1549
|
-
payload: {
|
|
1550
|
-
...u,
|
|
1551
|
-
...c.normalizeFormula(g, o, n)
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
}, p = [{
|
|
1555
|
-
id: y.id,
|
|
1556
|
-
params: f
|
|
1557
|
-
}], R = {
|
|
1558
|
-
unitId: o,
|
|
1559
|
-
subUnitId: n,
|
|
1560
|
-
ruleId: l,
|
|
1561
|
-
payload: {
|
|
1562
|
-
type: V.SETTING,
|
|
1563
|
-
payload: xt(d)
|
|
1564
|
-
}
|
|
1565
|
-
}, E = [{
|
|
1566
|
-
id: y.id,
|
|
1567
|
-
params: R
|
|
1568
|
-
}];
|
|
1569
|
-
if (u.type === T.CHECKBOX) {
|
|
1570
|
-
const O = d.ranges, $ = s.get(D), x = Ze($, { unitId: o, subUnitId: n });
|
|
1571
|
-
if (x) {
|
|
1572
|
-
const k = new Ve(), { worksheet: P } = x, { formula2: J = Te, formula1: ge = ye } = d, { formula2: pe = Te, formula1: fe = ye } = u;
|
|
1573
|
-
let He = !1;
|
|
1574
|
-
if (O.forEach((_e) => {
|
|
1575
|
-
H.foreach(_e, (se, We) => {
|
|
1576
|
-
const j = P.getCellRaw(se, We), et = vt(j);
|
|
1577
|
-
(St(j) || et === String(J)) && !(j != null && j.p) ? (k.setValue(se, We, {
|
|
1578
|
-
v: pe,
|
|
1579
|
-
p: null
|
|
1580
|
-
}), He = !0) : et === String(ge) && !(j != null && j.p) && (k.setValue(se, We, {
|
|
1581
|
-
v: fe,
|
|
1582
|
-
p: null
|
|
1583
|
-
}), He = !0);
|
|
1584
|
-
});
|
|
1585
|
-
}), He) {
|
|
1586
|
-
const _e = {
|
|
1587
|
-
id: le.id,
|
|
1588
|
-
params: {
|
|
1589
|
-
unitId: o,
|
|
1590
|
-
subUnitId: n,
|
|
1591
|
-
cellValue: k.getData()
|
|
1592
|
-
}
|
|
1593
|
-
}, se = {
|
|
1594
|
-
id: le.id,
|
|
1595
|
-
params: gt(s, _e.params)
|
|
1596
|
-
};
|
|
1597
|
-
p.push(_e), E.push(se);
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
return Le(p, e).result ? (t.pushUndoRedo({
|
|
1602
|
-
unitID: o,
|
|
1603
|
-
redoMutations: p,
|
|
1604
|
-
undoMutations: E
|
|
1605
|
-
}), !0) : !1;
|
|
1606
|
-
}
|
|
1607
|
-
}, Va = {
|
|
1608
|
-
type: z.COMMAND,
|
|
1609
|
-
id: "sheets.command.update-data-validation-options",
|
|
1610
|
-
handler(s, a) {
|
|
1611
|
-
if (!a)
|
|
1612
|
-
return !1;
|
|
1613
|
-
const e = s.get(U), t = s.get(Z), r = s.get(F), { unitId: i, subUnitId: o, ruleId: n, options: l } = a, u = r.getRuleById(i, o, n);
|
|
1614
|
-
if (!u)
|
|
1615
|
-
return !1;
|
|
1616
|
-
const c = {
|
|
1617
|
-
unitId: i,
|
|
1618
|
-
subUnitId: o,
|
|
1619
|
-
ruleId: n,
|
|
1620
|
-
payload: {
|
|
1621
|
-
type: V.OPTIONS,
|
|
1622
|
-
payload: l
|
|
1623
|
-
}
|
|
1624
|
-
}, d = [{
|
|
1625
|
-
id: y.id,
|
|
1626
|
-
params: c
|
|
1627
|
-
}], g = {
|
|
1628
|
-
unitId: i,
|
|
1629
|
-
subUnitId: o,
|
|
1630
|
-
ruleId: n,
|
|
1631
|
-
payload: {
|
|
1632
|
-
type: V.OPTIONS,
|
|
1633
|
-
payload: Pt(u)
|
|
1634
|
-
}
|
|
1635
|
-
}, f = [{
|
|
1636
|
-
id: y.id,
|
|
1637
|
-
params: g
|
|
1638
|
-
}];
|
|
1639
|
-
return t.pushUndoRedo({
|
|
1640
|
-
unitID: i,
|
|
1641
|
-
redoMutations: d,
|
|
1642
|
-
undoMutations: f
|
|
1643
|
-
}), e.executeCommand(y.id, c), !0;
|
|
1644
|
-
}
|
|
1645
|
-
}, ya = {
|
|
1646
|
-
type: z.COMMAND,
|
|
1647
|
-
id: "sheets.command.clear-range-data-validation",
|
|
1648
|
-
handler(s, a) {
|
|
1649
|
-
if (!a)
|
|
1650
|
-
return !1;
|
|
1651
|
-
const { unitId: e, subUnitId: t, ranges: r } = a, i = s.get(U), o = s.get(D), n = Ze(o, { unitId: e, subUnitId: t }), l = s.get(F);
|
|
1652
|
-
if (!n) return !1;
|
|
1653
|
-
const u = s.get(Z), c = l.getRuleObjectMatrix(e, t).clone();
|
|
1654
|
-
c.removeRange(r);
|
|
1655
|
-
const d = c.diff(l.getRules(e, t)), { redoMutations: g, undoMutations: f } = xe(e, t, d, s);
|
|
1656
|
-
return u.pushUndoRedo({
|
|
1657
|
-
unitID: e,
|
|
1658
|
-
redoMutations: g,
|
|
1659
|
-
undoMutations: f
|
|
1660
|
-
}), Le(g, i).result;
|
|
1661
|
-
}
|
|
1662
|
-
}, Ta = {
|
|
1663
|
-
type: z.COMMAND,
|
|
1664
|
-
id: "sheet.command.remove-all-data-validation",
|
|
1665
|
-
handler(s, a) {
|
|
1666
|
-
if (!a)
|
|
1667
|
-
return !1;
|
|
1668
|
-
const { unitId: e, subUnitId: t } = a, r = s.get(U), i = s.get(F), o = s.get(Z), n = [...i.getRules(e, t)], l = {
|
|
1669
|
-
unitId: e,
|
|
1670
|
-
subUnitId: t,
|
|
1671
|
-
ruleId: n.map((d) => d.uid)
|
|
1672
|
-
}, u = [{
|
|
1673
|
-
id: I.id,
|
|
1674
|
-
params: l
|
|
1675
|
-
}], c = [{
|
|
1676
|
-
id: b.id,
|
|
1677
|
-
params: {
|
|
1678
|
-
unitId: e,
|
|
1679
|
-
subUnitId: t,
|
|
1680
|
-
rule: n
|
|
1681
|
-
}
|
|
1682
|
-
}];
|
|
1683
|
-
return o.pushUndoRedo({
|
|
1684
|
-
redoMutations: u,
|
|
1685
|
-
undoMutations: c,
|
|
1686
|
-
unitID: e
|
|
1687
|
-
}), r.executeCommand(I.id, l), !0;
|
|
1688
|
-
}
|
|
1689
|
-
}, Ca = (s, a) => {
|
|
1690
|
-
const e = s.get(F), { unitId: t, subUnitId: r, ruleId: i, source: o } = a;
|
|
1691
|
-
if (Array.isArray(i)) {
|
|
1692
|
-
const l = i.map((u) => e.getRuleById(t, r, u)).filter(Boolean);
|
|
1693
|
-
return [{
|
|
1694
|
-
id: b.id,
|
|
1695
|
-
params: {
|
|
1696
|
-
unitId: t,
|
|
1697
|
-
subUnitId: r,
|
|
1698
|
-
rule: l,
|
|
1699
|
-
source: o
|
|
1700
|
-
}
|
|
1701
|
-
}];
|
|
1702
|
-
}
|
|
1703
|
-
return [{
|
|
1704
|
-
id: b.id,
|
|
1705
|
-
params: {
|
|
1706
|
-
unitId: t,
|
|
1707
|
-
subUnitId: r,
|
|
1708
|
-
rule: {
|
|
1709
|
-
...e.getRuleById(t, r, i)
|
|
1710
|
-
},
|
|
1711
|
-
index: e.getRuleIndex(t, r, i)
|
|
1712
|
-
}
|
|
1713
|
-
}];
|
|
1714
|
-
}, Fa = {
|
|
1715
|
-
type: z.COMMAND,
|
|
1716
|
-
id: "sheet.command.remove-data-validation-rule",
|
|
1717
|
-
handler(s, a) {
|
|
1718
|
-
if (!a)
|
|
1719
|
-
return !1;
|
|
1720
|
-
const { unitId: e, subUnitId: t, ruleId: r } = a, i = s.get(U), o = s.get(Z), n = s.get(F), l = [{
|
|
1721
|
-
id: I.id,
|
|
1722
|
-
params: a
|
|
1723
|
-
}], u = [{
|
|
1724
|
-
id: b.id,
|
|
1725
|
-
params: {
|
|
1726
|
-
unitId: e,
|
|
1727
|
-
subUnitId: t,
|
|
1728
|
-
rule: {
|
|
1729
|
-
...n.getRuleById(e, t, r)
|
|
1730
|
-
},
|
|
1731
|
-
index: n.getRuleIndex(e, t, r)
|
|
1732
|
-
}
|
|
1733
|
-
}];
|
|
1734
|
-
return o.pushUndoRedo({
|
|
1735
|
-
undoMutations: u,
|
|
1736
|
-
redoMutations: l,
|
|
1737
|
-
unitID: a.unitId
|
|
1738
|
-
}), i.executeCommand(I.id, a), !0;
|
|
1739
|
-
}
|
|
1740
|
-
}, Na = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
1741
|
-
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 || {}), Oa = Object.getOwnPropertyDescriptor, wa = (s, a, e, t) => {
|
|
1742
|
-
for (var r = t > 1 ? void 0 : t ? Oa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
1743
|
-
(o = s[i]) && (r = o(r) || r);
|
|
1744
|
-
return r;
|
|
1745
|
-
}, Qe = (s, a) => (e, t) => a(e, t, s);
|
|
1746
|
-
let Ne = class extends B {
|
|
1747
|
-
constructor(s, a, e) {
|
|
1748
|
-
super(), this._univerInstanceService = s, this._permissionService = a, this._lexerTreeBuilder = e;
|
|
1749
|
-
}
|
|
1750
|
-
getFormulaRefCheck(s) {
|
|
1751
|
-
var e, t;
|
|
1752
|
-
const a = this._lexerTreeBuilder.sequenceNodesBuilder(s);
|
|
1753
|
-
if (!a)
|
|
1754
|
-
return !0;
|
|
1755
|
-
for (let r = 0; r < a.length; r++) {
|
|
1756
|
-
const i = a[r];
|
|
1757
|
-
if (typeof i == "string")
|
|
1758
|
-
continue;
|
|
1759
|
-
const { token: o } = i, n = jt(o), l = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1760
|
-
let u = l.getActiveSheet();
|
|
1761
|
-
const c = l.getUnitId();
|
|
1762
|
-
if (n.sheetName) {
|
|
1763
|
-
if (u = l.getSheetBySheetName(n.sheetName), !u)
|
|
1764
|
-
return !1;
|
|
1765
|
-
const R = u == null ? void 0 : u.getSheetId();
|
|
1766
|
-
if (!this._permissionService.getPermissionPoint(new Gt(c, R).id)) return !1;
|
|
1767
|
-
}
|
|
1768
|
-
if (!u)
|
|
1769
|
-
return !1;
|
|
1770
|
-
const { startRow: d, endRow: g, startColumn: f, endColumn: p } = n.range;
|
|
1771
|
-
for (let R = d; R <= g; R++)
|
|
1772
|
-
for (let E = f; E <= p; E++) {
|
|
1773
|
-
const _ = (t = (e = u.getCell(R, E)) == null ? void 0 : e.selectionProtection) == null ? void 0 : t[0];
|
|
1774
|
-
if ((_ == null ? void 0 : _[Et.View]) === !1)
|
|
1775
|
-
return !1;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
return !0;
|
|
1779
|
-
}
|
|
1780
|
-
};
|
|
1781
|
-
Ne = wa([
|
|
1782
|
-
Qe(0, D),
|
|
1783
|
-
Qe(1, Nt),
|
|
1784
|
-
Qe(2, v(X))
|
|
1785
|
-
], Ne);
|
|
1786
|
-
const Aa = "@univerjs/sheets-data-validation", Ia = "0.17.0", Mt = {
|
|
1787
|
-
name: Aa,
|
|
1788
|
-
version: Ia
|
|
1789
|
-
}, Da = "sheets-data-validation.config", ot = {};
|
|
1790
|
-
var ba = Object.getOwnPropertyDescriptor, La = (s, a, e, t) => {
|
|
1791
|
-
for (var r = t > 1 ? void 0 : t ? ba(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
1792
|
-
(o = s[i]) && (r = o(r) || r);
|
|
1793
|
-
return r;
|
|
1794
|
-
}, Ge = (s, a) => (e, t) => a(e, t, s);
|
|
1795
|
-
let Oe = class extends B {
|
|
1796
|
-
constructor(a, e, t) {
|
|
1797
|
-
super();
|
|
1798
|
-
m(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
1799
|
-
m(this, "registerRule", (a, e, t) => {
|
|
1800
|
-
me(t.type, this._validatorRegistryService) && this.register(a, e, t);
|
|
1801
|
-
});
|
|
1802
|
-
this._dataValidationModel = a, this._formulaRefRangeService = e, this._validatorRegistryService = t, this._initRefRange();
|
|
1803
|
-
}
|
|
1804
|
-
_getIdWithUnitId(a, e, t) {
|
|
1805
|
-
return `${a}_${e}_${t}`;
|
|
1806
|
-
}
|
|
1807
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1808
|
-
register(a, e, t) {
|
|
1809
|
-
const r = t.ranges, i = t.formula1, o = t.formula2, n = this._formulaRefRangeService.registerRangeFormula(a, e, r, [i != null ? i : "", o != null ? o : ""], (u) => {
|
|
1810
|
-
if (u.length === 0)
|
|
1811
|
-
return {
|
|
1812
|
-
undos: [{
|
|
1813
|
-
id: b.id,
|
|
1814
|
-
params: {
|
|
1815
|
-
unitId: a,
|
|
1816
|
-
subUnitId: e,
|
|
1817
|
-
rule: t,
|
|
1818
|
-
source: "patched"
|
|
1819
|
-
}
|
|
1820
|
-
}],
|
|
1821
|
-
redos: [{
|
|
1822
|
-
id: I.id,
|
|
1823
|
-
params: {
|
|
1824
|
-
unitId: a,
|
|
1825
|
-
subUnitId: e,
|
|
1826
|
-
ruleId: t.uid,
|
|
1827
|
-
source: "patched"
|
|
1828
|
-
}
|
|
1829
|
-
}]
|
|
1830
|
-
};
|
|
1831
|
-
const c = [], d = [], g = u[0];
|
|
1832
|
-
c.push({
|
|
1833
|
-
id: y.id,
|
|
1834
|
-
params: {
|
|
1835
|
-
unitId: a,
|
|
1836
|
-
subUnitId: e,
|
|
1837
|
-
ruleId: t.uid,
|
|
1838
|
-
payload: {
|
|
1839
|
-
type: V.ALL,
|
|
1840
|
-
payload: {
|
|
1841
|
-
ranges: g.ranges,
|
|
1842
|
-
formula1: g.formulas[0],
|
|
1843
|
-
formula2: g.formulas[1]
|
|
1844
|
-
}
|
|
1845
|
-
},
|
|
1846
|
-
source: "patched"
|
|
1847
|
-
}
|
|
1848
|
-
}), d.push({
|
|
1849
|
-
id: y.id,
|
|
1850
|
-
params: {
|
|
1851
|
-
unitId: a,
|
|
1852
|
-
subUnitId: e,
|
|
1853
|
-
ruleId: t.uid,
|
|
1854
|
-
payload: {
|
|
1855
|
-
type: V.ALL,
|
|
1856
|
-
payload: {
|
|
1857
|
-
ranges: r,
|
|
1858
|
-
formula1: i,
|
|
1859
|
-
formula2: o
|
|
1860
|
-
}
|
|
1861
|
-
},
|
|
1862
|
-
source: "patched"
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
for (let f = 1; f < u.length; f++) {
|
|
1866
|
-
const p = u[f], R = Ke();
|
|
1867
|
-
c.push({
|
|
1868
|
-
id: b.id,
|
|
1869
|
-
params: {
|
|
1870
|
-
unitId: a,
|
|
1871
|
-
subUnitId: e,
|
|
1872
|
-
rule: {
|
|
1873
|
-
...t,
|
|
1874
|
-
uid: R,
|
|
1875
|
-
formula1: p.formulas[0],
|
|
1876
|
-
formula2: p.formulas[1],
|
|
1877
|
-
ranges: p.ranges
|
|
1878
|
-
},
|
|
1879
|
-
source: "patched"
|
|
1880
|
-
}
|
|
1881
|
-
}), d.push({
|
|
1882
|
-
id: I.id,
|
|
1883
|
-
params: {
|
|
1884
|
-
unitId: a,
|
|
1885
|
-
subUnitId: e,
|
|
1886
|
-
ruleId: R,
|
|
1887
|
-
source: "patched"
|
|
1888
|
-
}
|
|
1889
|
-
});
|
|
1890
|
-
}
|
|
1891
|
-
return {
|
|
1892
|
-
undos: d,
|
|
1893
|
-
redos: c
|
|
1894
|
-
};
|
|
1895
|
-
}), l = this._getIdWithUnitId(a, e, t.uid);
|
|
1896
|
-
this._disposableMap.set(l, n);
|
|
1897
|
-
}
|
|
1898
|
-
_initRefRange() {
|
|
1899
|
-
const a = this._dataValidationModel.getAll();
|
|
1900
|
-
for (const [e, t] of a)
|
|
1901
|
-
for (const [r, i] of t)
|
|
1902
|
-
for (const o of i)
|
|
1903
|
-
this.registerRule(e, r, o);
|
|
1904
|
-
this.disposeWithMe(
|
|
1905
|
-
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
1906
|
-
const { unitId: t, subUnitId: r, rule: i } = e;
|
|
1907
|
-
switch (e.type) {
|
|
1908
|
-
case "add": {
|
|
1909
|
-
const o = e.rule;
|
|
1910
|
-
this.registerRule(e.unitId, e.subUnitId, o);
|
|
1911
|
-
break;
|
|
1912
|
-
}
|
|
1913
|
-
case "remove": {
|
|
1914
|
-
const o = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
|
|
1915
|
-
o && o.dispose();
|
|
1916
|
-
break;
|
|
1917
|
-
}
|
|
1918
|
-
case "update": {
|
|
1919
|
-
const o = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, o.uid));
|
|
1920
|
-
n && n.dispose(), this.registerRule(e.unitId, e.subUnitId, o);
|
|
1921
|
-
break;
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
})
|
|
1925
|
-
), this.disposeWithMe(ze(() => {
|
|
1926
|
-
this._disposableMap.forEach((e) => {
|
|
1927
|
-
e.dispose();
|
|
1928
|
-
}), this._disposableMap.clear();
|
|
1929
|
-
}));
|
|
1930
|
-
}
|
|
1931
|
-
};
|
|
1932
|
-
Oe = La([
|
|
1933
|
-
Ge(0, v(F)),
|
|
1934
|
-
Ge(1, v(_t)),
|
|
1935
|
-
Ge(2, v(q))
|
|
1936
|
-
], Oe);
|
|
1937
|
-
var Ua = Object.getOwnPropertyDescriptor, Ba = (s, a, e, t) => {
|
|
1938
|
-
for (var r = t > 1 ? void 0 : t ? Ua(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
1939
|
-
(o = s[i]) && (r = o(r) || r);
|
|
1940
|
-
return r;
|
|
1941
|
-
}, te = (s, a) => (e, t) => a(e, t, s);
|
|
1942
|
-
let we = class extends B {
|
|
1943
|
-
constructor(a, e, t, r, i, o) {
|
|
1944
|
-
super();
|
|
1945
|
-
m(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
1946
|
-
m(this, "registerRule", (a, e, t) => {
|
|
1947
|
-
me(t.type, this._validatorRegistryService) || (this.register(a, e, t), this.registerFormula(a, e, t));
|
|
1948
|
-
});
|
|
1949
|
-
this._dataValidationModel = a, this._injector = e, this._refRangeService = t, this._dataValidationFormulaService = r, this._formulaRefRangeService = i, this._validatorRegistryService = o, this._initRefRange();
|
|
1950
|
-
}
|
|
1951
|
-
_getIdWithUnitId(a, e, t) {
|
|
1952
|
-
return `${a}_${e}_${t}`;
|
|
1953
|
-
}
|
|
1954
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1955
|
-
registerFormula(a, e, t) {
|
|
1956
|
-
var u;
|
|
1957
|
-
const r = t.uid, i = this._getIdWithUnitId(a, e, r), o = (u = this._disposableMap.get(i)) != null ? u : /* @__PURE__ */ new Set(), n = (c, d) => {
|
|
1958
|
-
const g = this._dataValidationModel.getRuleById(a, e, r);
|
|
1959
|
-
if (!g)
|
|
1960
|
-
return { redos: [], undos: [] };
|
|
1961
|
-
const f = g[c];
|
|
1962
|
-
if (!f || f === d)
|
|
1963
|
-
return { redos: [], undos: [] };
|
|
1964
|
-
const p = {
|
|
1965
|
-
unitId: a,
|
|
1966
|
-
subUnitId: e,
|
|
1967
|
-
ruleId: t.uid,
|
|
1968
|
-
payload: {
|
|
1969
|
-
type: V.SETTING,
|
|
1970
|
-
payload: {
|
|
1971
|
-
type: g.type,
|
|
1972
|
-
formula1: g.formula1,
|
|
1973
|
-
formula2: g.formula2,
|
|
1974
|
-
[c]: d
|
|
1975
|
-
}
|
|
1976
|
-
},
|
|
1977
|
-
source: "patched"
|
|
1978
|
-
}, R = {
|
|
1979
|
-
unitId: a,
|
|
1980
|
-
subUnitId: e,
|
|
1981
|
-
ruleId: t.uid,
|
|
1982
|
-
payload: {
|
|
1983
|
-
type: V.SETTING,
|
|
1984
|
-
payload: {
|
|
1985
|
-
type: g.type,
|
|
1986
|
-
formula1: g.formula1,
|
|
1987
|
-
formula2: g.formula2
|
|
1988
|
-
}
|
|
1989
|
-
},
|
|
1990
|
-
source: "patched"
|
|
1991
|
-
}, E = [
|
|
1992
|
-
{
|
|
1993
|
-
id: y.id,
|
|
1994
|
-
params: p
|
|
1995
|
-
}
|
|
1996
|
-
], _ = [
|
|
1997
|
-
{
|
|
1998
|
-
id: y.id,
|
|
1999
|
-
params: R
|
|
2000
|
-
}
|
|
2001
|
-
];
|
|
2002
|
-
return { redos: E, undos: _ };
|
|
2003
|
-
}, l = this._dataValidationFormulaService.getRuleFormulaInfo(a, e, r);
|
|
2004
|
-
if (l) {
|
|
2005
|
-
const [c, d] = l;
|
|
2006
|
-
if (c) {
|
|
2007
|
-
const g = this._formulaRefRangeService.registerFormula(
|
|
2008
|
-
a,
|
|
2009
|
-
e,
|
|
2010
|
-
c.text,
|
|
2011
|
-
(f) => n("formula1", f)
|
|
2012
|
-
);
|
|
2013
|
-
o.add(() => g.dispose());
|
|
2014
|
-
}
|
|
2015
|
-
if (d) {
|
|
2016
|
-
const g = this._formulaRefRangeService.registerFormula(
|
|
2017
|
-
a,
|
|
2018
|
-
e,
|
|
2019
|
-
d.text,
|
|
2020
|
-
(f) => n("formula2", f)
|
|
2021
|
-
);
|
|
2022
|
-
o.add(() => g.dispose());
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
register(a, e, t) {
|
|
2027
|
-
var l;
|
|
2028
|
-
const r = (u) => {
|
|
2029
|
-
const c = [...t.ranges], g = c.map((p) => Yt(p, u)).filter((p) => !!p).flat();
|
|
2030
|
-
if (ut(g, c))
|
|
2031
|
-
return { redos: [], undos: [] };
|
|
2032
|
-
if (g.length) {
|
|
2033
|
-
const p = {
|
|
2034
|
-
unitId: a,
|
|
2035
|
-
subUnitId: e,
|
|
2036
|
-
ruleId: t.uid,
|
|
2037
|
-
payload: {
|
|
2038
|
-
type: V.RANGE,
|
|
2039
|
-
payload: g
|
|
2040
|
-
},
|
|
2041
|
-
source: "patched"
|
|
2042
|
-
}, R = [{ id: y.id, params: p }], E = [{
|
|
2043
|
-
id: y.id,
|
|
2044
|
-
params: {
|
|
2045
|
-
unitId: a,
|
|
2046
|
-
subUnitId: e,
|
|
2047
|
-
ruleId: t.uid,
|
|
2048
|
-
payload: {
|
|
2049
|
-
type: V.RANGE,
|
|
2050
|
-
payload: c
|
|
2051
|
-
},
|
|
2052
|
-
source: "patched"
|
|
2053
|
-
}
|
|
2054
|
-
}];
|
|
2055
|
-
return { redos: R, undos: E };
|
|
2056
|
-
} else {
|
|
2057
|
-
const p = { unitId: a, subUnitId: e, ruleId: t.uid }, R = [{ id: I.id, params: p }], E = Ca(this._injector, p);
|
|
2058
|
-
return { redos: R, undos: E };
|
|
2059
|
-
}
|
|
2060
|
-
}, i = [];
|
|
2061
|
-
t.ranges.forEach((u) => {
|
|
2062
|
-
const c = this._refRangeService.registerRefRange(u, r, a, e);
|
|
2063
|
-
i.push(() => c.dispose());
|
|
2064
|
-
});
|
|
2065
|
-
const o = this._getIdWithUnitId(a, e, t.uid), n = (l = this._disposableMap.get(o)) != null ? l : /* @__PURE__ */ new Set();
|
|
2066
|
-
n.add(() => i.forEach((u) => u())), this._disposableMap.set(o, n);
|
|
2067
|
-
}
|
|
2068
|
-
_initRefRange() {
|
|
2069
|
-
const a = this._dataValidationModel.getAll();
|
|
2070
|
-
for (const [e, t] of a)
|
|
2071
|
-
for (const [r, i] of t)
|
|
2072
|
-
for (const o of i)
|
|
2073
|
-
this.registerRule(e, r, o);
|
|
2074
|
-
this.disposeWithMe(
|
|
2075
|
-
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
2076
|
-
const { unitId: t, subUnitId: r, rule: i } = e;
|
|
2077
|
-
switch (e.type) {
|
|
2078
|
-
case "add": {
|
|
2079
|
-
const o = e.rule;
|
|
2080
|
-
this.registerRule(e.unitId, e.subUnitId, o);
|
|
2081
|
-
break;
|
|
2082
|
-
}
|
|
2083
|
-
case "remove": {
|
|
2084
|
-
const o = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
|
|
2085
|
-
o && o.forEach((n) => n());
|
|
2086
|
-
break;
|
|
2087
|
-
}
|
|
2088
|
-
case "update": {
|
|
2089
|
-
const o = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, o.uid));
|
|
2090
|
-
n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId, o);
|
|
2091
|
-
break;
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
})
|
|
2095
|
-
), this.disposeWithMe(ze(() => {
|
|
2096
|
-
this._disposableMap.forEach((e) => {
|
|
2097
|
-
e.forEach((t) => t());
|
|
2098
|
-
}), this._disposableMap.clear();
|
|
2099
|
-
}));
|
|
2100
|
-
}
|
|
2101
|
-
};
|
|
2102
|
-
we = Ba([
|
|
2103
|
-
te(0, v(F)),
|
|
2104
|
-
te(1, v(be)),
|
|
2105
|
-
te(2, v(qt)),
|
|
2106
|
-
te(3, v(G)),
|
|
2107
|
-
te(4, v(_t)),
|
|
2108
|
-
te(5, v(q))
|
|
2109
|
-
], we);
|
|
2110
|
-
var xa = Object.getOwnPropertyDescriptor, Pa = (s, a, e, t) => {
|
|
2111
|
-
for (var r = t > 1 ? void 0 : t ? xa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2112
|
-
(o = s[i]) && (r = o(r) || r);
|
|
2113
|
-
return r;
|
|
2114
|
-
}, qe = (s, a) => (e, t) => a(e, t, s);
|
|
2115
|
-
let Ae = class extends B {
|
|
2116
|
-
constructor(s, a, e) {
|
|
2117
|
-
super(), this._sheetInterceptorService = s, this._univerInstanceService = a, this._sheetDataValidationModel = e, this._initSheetChange();
|
|
2118
|
-
}
|
|
2119
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2120
|
-
_initSheetChange() {
|
|
2121
|
-
this.disposeWithMe(
|
|
2122
|
-
this._sheetInterceptorService.interceptCommand({
|
|
2123
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2124
|
-
getMutations: (s) => {
|
|
2125
|
-
var a;
|
|
2126
|
-
if (s.id === Xt.id) {
|
|
2127
|
-
const e = s.params, t = e.unitId || this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET).getUnitId(), r = this._univerInstanceService.getUniverSheetInstance(t);
|
|
2128
|
-
if (!r)
|
|
2129
|
-
return { redos: [], undos: [] };
|
|
2130
|
-
const i = e.subUnitId || ((a = r.getActiveSheet()) == null ? void 0 : a.getSheetId());
|
|
2131
|
-
if (!i)
|
|
2132
|
-
return { redos: [], undos: [] };
|
|
2133
|
-
const o = this._sheetDataValidationModel.getRules(t, i);
|
|
2134
|
-
if (o.length === 0)
|
|
2135
|
-
return { redos: [], undos: [] };
|
|
2136
|
-
const n = o.map((c) => c.uid), l = {
|
|
2137
|
-
unitId: t,
|
|
2138
|
-
subUnitId: i,
|
|
2139
|
-
ruleId: n,
|
|
2140
|
-
source: "patched"
|
|
2141
|
-
}, u = {
|
|
2142
|
-
unitId: t,
|
|
2143
|
-
subUnitId: i,
|
|
2144
|
-
rule: [...o],
|
|
2145
|
-
source: "patched"
|
|
2146
|
-
};
|
|
2147
|
-
return {
|
|
2148
|
-
redos: [{
|
|
2149
|
-
id: I.id,
|
|
2150
|
-
params: l
|
|
2151
|
-
}],
|
|
2152
|
-
undos: [{
|
|
2153
|
-
id: b.id,
|
|
2154
|
-
params: u
|
|
2155
|
-
}]
|
|
2156
|
-
};
|
|
2157
|
-
} else if (s.id === Kt.id) {
|
|
2158
|
-
const e = s.params, { unitId: t, subUnitId: r, targetSubUnitId: i } = e;
|
|
2159
|
-
if (!t || !r || !i)
|
|
2160
|
-
return { redos: [], undos: [] };
|
|
2161
|
-
const o = this._sheetDataValidationModel.getRules(t, r);
|
|
2162
|
-
if (o.length === 0)
|
|
2163
|
-
return { redos: [], undos: [] };
|
|
2164
|
-
const n = o.map((l) => ({ ...l, uid: Ke(6) }));
|
|
2165
|
-
return {
|
|
2166
|
-
redos: [
|
|
2167
|
-
{
|
|
2168
|
-
id: b.id,
|
|
2169
|
-
params: {
|
|
2170
|
-
unitId: t,
|
|
2171
|
-
subUnitId: i,
|
|
2172
|
-
rule: n,
|
|
2173
|
-
source: "patched"
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
],
|
|
2177
|
-
undos: [
|
|
2178
|
-
{
|
|
2179
|
-
id: I.id,
|
|
2180
|
-
params: {
|
|
2181
|
-
unitId: t,
|
|
2182
|
-
subUnitId: i,
|
|
2183
|
-
ruleId: n.map((l) => l.uid),
|
|
2184
|
-
source: "patched"
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
]
|
|
2188
|
-
};
|
|
2189
|
-
}
|
|
2190
|
-
return { redos: [], undos: [] };
|
|
2191
|
-
}
|
|
2192
|
-
})
|
|
2193
|
-
);
|
|
2194
|
-
}
|
|
2195
|
-
};
|
|
2196
|
-
Ae = Pa([
|
|
2197
|
-
qe(0, v(pt)),
|
|
2198
|
-
qe(1, v(D)),
|
|
2199
|
-
qe(2, v(F))
|
|
2200
|
-
], Ae);
|
|
2201
|
-
class Ha extends Y {
|
|
2202
|
-
constructor() {
|
|
2203
|
-
super(...arguments);
|
|
2204
|
-
m(this, "id", T.ANY);
|
|
2205
|
-
m(this, "title", "dataValidation.any.title");
|
|
2206
|
-
m(this, "operators", []);
|
|
2207
|
-
m(this, "scopes", ["sheet"]);
|
|
2208
|
-
m(this, "order", 0);
|
|
2209
|
-
m(this, "offsetFormulaByRange", !1);
|
|
2210
|
-
}
|
|
2211
|
-
async parseFormula(e, t, r) {
|
|
2212
|
-
return {
|
|
2213
|
-
formula1: e.formula1,
|
|
2214
|
-
formula2: e.formula2,
|
|
2215
|
-
isFormulaValid: !0
|
|
2216
|
-
};
|
|
2217
|
-
}
|
|
2218
|
-
validatorFormula(e, t, r) {
|
|
2219
|
-
return {
|
|
2220
|
-
success: !0
|
|
2221
|
-
};
|
|
2222
|
-
}
|
|
2223
|
-
async isValidType(e, t, r) {
|
|
2224
|
-
return !0;
|
|
2225
|
-
}
|
|
2226
|
-
generateRuleErrorMessage(e) {
|
|
2227
|
-
return this.localeService.t("dataValidation.any.error");
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
class Wa extends Y {
|
|
2231
|
-
constructor() {
|
|
2232
|
-
super(...arguments);
|
|
2233
|
-
m(this, "id", T.CUSTOM);
|
|
2234
|
-
m(this, "title", "dataValidation.custom.title");
|
|
2235
|
-
m(this, "operators", []);
|
|
2236
|
-
m(this, "scopes", ["sheet"]);
|
|
2237
|
-
m(this, "order", 60);
|
|
2238
|
-
m(this, "_customFormulaService", this.injector.get(W));
|
|
2239
|
-
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
2240
|
-
}
|
|
2241
|
-
validatorFormula(e, t, r) {
|
|
2242
|
-
var u;
|
|
2243
|
-
const i = S(e.formula1), o = (u = e.formula1) != null ? u : "", l = this._lexerTreeBuilder.checkIfAddBracket(o) === 0 && o.startsWith(Qt.EQUALS);
|
|
2244
|
-
return {
|
|
2245
|
-
success: i && l,
|
|
2246
|
-
formula1: i && l ? "" : this.localeService.t("dataValidation.validFail.formula")
|
|
2247
|
-
};
|
|
2248
|
-
}
|
|
2249
|
-
async parseFormula(e, t, r) {
|
|
2250
|
-
return {
|
|
2251
|
-
formula1: void 0,
|
|
2252
|
-
formula2: void 0,
|
|
2253
|
-
isFormulaValid: !0
|
|
2254
|
-
};
|
|
2255
|
-
}
|
|
2256
|
-
async isValidType(e, t, r) {
|
|
2257
|
-
const { column: i, row: o, unitId: n, subUnitId: l } = e, u = await this._customFormulaService.getCellFormulaValue(n, l, r.uid, o, i), c = u == null ? void 0 : u.v;
|
|
2258
|
-
return C(String(c)) && M.isDefine(c) && c !== "" ? u.t === Ot.BOOLEAN ? !!c : typeof c == "boolean" ? c : typeof c == "number" ? !!c : typeof c == "string" ? C(c) : !!c : !1;
|
|
2259
|
-
}
|
|
2260
|
-
generateRuleErrorMessage(e) {
|
|
2261
|
-
return this.localeService.t("dataValidation.custom.error");
|
|
2262
|
-
}
|
|
2263
|
-
generateRuleName(e) {
|
|
2264
|
-
var t;
|
|
2265
|
-
return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (t = e.formula1) != null ? t : "");
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
class $a extends Rt {
|
|
2269
|
-
constructor() {
|
|
2270
|
-
super(...arguments);
|
|
2271
|
-
m(this, "id", T.LIST_MULTIPLE);
|
|
2272
|
-
m(this, "title", "dataValidation.listMultiple.title");
|
|
2273
|
-
m(this, "offsetFormulaByRange", !1);
|
|
2274
|
-
m(this, "skipDefaultFontRender", () => !0);
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
class ka extends Y {
|
|
2278
|
-
constructor() {
|
|
2279
|
-
super(...arguments);
|
|
2280
|
-
m(this, "_customFormulaService", this.injector.get(W));
|
|
2281
|
-
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
2282
|
-
m(this, "id", T.WHOLE);
|
|
2283
|
-
m(this, "title", "dataValidation.whole.title");
|
|
2284
|
-
m(this, "order", 10);
|
|
2285
|
-
m(this, "operators", [
|
|
2286
|
-
h.BETWEEN,
|
|
2287
|
-
h.EQUAL,
|
|
2288
|
-
h.GREATER_THAN,
|
|
2289
|
-
h.GREATER_THAN_OR_EQUAL,
|
|
2290
|
-
h.LESS_THAN,
|
|
2291
|
-
h.LESS_THAN_OR_EQUAL,
|
|
2292
|
-
h.NOT_BETWEEN,
|
|
2293
|
-
h.NOT_EQUAL
|
|
2294
|
-
]);
|
|
2295
|
-
m(this, "scopes", ["sheet"]);
|
|
2296
|
-
}
|
|
2297
|
-
_isFormulaOrInt(e) {
|
|
2298
|
-
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
2299
|
-
}
|
|
2300
|
-
async isValidType(e, t, r) {
|
|
2301
|
-
const { value: i } = e, o = Fe(i);
|
|
2302
|
-
return !Number.isNaN(o) && Number.isInteger(o);
|
|
2303
|
-
}
|
|
2304
|
-
transform(e, t, r) {
|
|
2305
|
-
const { value: i } = e;
|
|
2306
|
-
return {
|
|
2307
|
-
...e,
|
|
2308
|
-
value: Fe(i)
|
|
2309
|
-
};
|
|
2310
|
-
}
|
|
2311
|
-
_parseNumber(e) {
|
|
2312
|
-
return e == null ? Number.NaN : +e;
|
|
2313
|
-
}
|
|
2314
|
-
async parseFormula(e, t, r, i, o) {
|
|
2315
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = S(u) ? n == null ? void 0 : n.v : u, g = S(c) ? l == null ? void 0 : l.v : c, f = C(`${d}`) && C(`${g}`);
|
|
2316
|
-
return {
|
|
2317
|
-
formula1: this._parseNumber(d),
|
|
2318
|
-
formula2: this._parseNumber(g),
|
|
2319
|
-
isFormulaValid: f
|
|
2320
|
-
};
|
|
2321
|
-
}
|
|
2322
|
-
validatorFormula(e, t, r) {
|
|
2323
|
-
const i = e.operator;
|
|
2324
|
-
if (!i)
|
|
2325
|
-
return {
|
|
2326
|
-
success: !0
|
|
2327
|
-
};
|
|
2328
|
-
const o = M.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = M.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
2329
|
-
return l ? {
|
|
2330
|
-
success: o && n,
|
|
2331
|
-
formula1: o ? void 0 : u,
|
|
2332
|
-
formula2: n ? void 0 : u
|
|
2333
|
-
} : {
|
|
2334
|
-
success: o,
|
|
2335
|
-
formula1: u
|
|
2336
|
-
};
|
|
2337
|
-
}
|
|
2338
|
-
generateRuleErrorMessage(e, t) {
|
|
2339
|
-
if (!e.operator)
|
|
2340
|
-
return this.localeService.t(Ce.NONE).replace("{TYPE}", this.titleStr);
|
|
2341
|
-
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
2342
|
-
return `${this.localeService.t(Ce[e.operator]).replace(ce, r != null ? r : "").replace(de, i != null ? i : "")}`;
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
var ja = Object.getOwnPropertyDescriptor, Qa = (s, a, e, t) => {
|
|
2346
|
-
for (var r = t > 1 ? void 0 : t ? ja(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2347
|
-
(o = s[i]) && (r = o(r) || r);
|
|
2348
|
-
return r;
|
|
2349
|
-
}, ae = (s, a) => (e, t) => a(e, t, s);
|
|
2350
|
-
let Ie = class extends wt {
|
|
2351
|
-
constructor(s, a, e, t, r, i) {
|
|
2352
|
-
super(), this._univerInstanceService = s, this._dataValidatorRegistryService = a, this._injector = e, this._selectionManagerService = t, this._sheetInterceptorService = r, this._sheetDataValidationModel = i, this._init();
|
|
2353
|
-
}
|
|
2354
|
-
_init() {
|
|
2355
|
-
this._registerValidators(), this._initCommandInterceptor();
|
|
2356
|
-
}
|
|
2357
|
-
_registerValidators() {
|
|
2358
|
-
[
|
|
2359
|
-
Ha,
|
|
2360
|
-
ga,
|
|
2361
|
-
ka,
|
|
2362
|
-
Ra,
|
|
2363
|
-
ma,
|
|
2364
|
-
ca,
|
|
2365
|
-
Rt,
|
|
2366
|
-
$a,
|
|
2367
|
-
Wa
|
|
2368
|
-
].forEach((s) => {
|
|
2369
|
-
const a = this._injector.createInstance(s);
|
|
2370
|
-
this.disposeWithMe(this._dataValidatorRegistryService.register(a)), this.disposeWithMe(ze(() => this._injector.delete(s)));
|
|
2371
|
-
});
|
|
2372
|
-
}
|
|
2373
|
-
_initCommandInterceptor() {
|
|
2374
|
-
this._sheetInterceptorService.interceptCommand({
|
|
2375
|
-
getMutations: (s) => {
|
|
2376
|
-
var a;
|
|
2377
|
-
if (s.id === zt.id) {
|
|
2378
|
-
const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e.getUnitId(), r = e.getActiveSheet();
|
|
2379
|
-
if (!r)
|
|
2380
|
-
throw new Error("No active sheet found");
|
|
2381
|
-
const i = r.getSheetId(), o = (a = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : a.map((d) => d.range), n = this._sheetDataValidationModel.getRuleObjectMatrix(t, i).clone();
|
|
2382
|
-
o && n.removeRange(o);
|
|
2383
|
-
const l = n.diff(this._sheetDataValidationModel.getRules(t, i)), { redoMutations: u, undoMutations: c } = xe(t, i, l, this._injector, "patched");
|
|
2384
|
-
return {
|
|
2385
|
-
undos: c,
|
|
2386
|
-
redos: u
|
|
2387
|
-
};
|
|
2388
|
-
}
|
|
2389
|
-
return {
|
|
2390
|
-
undos: [],
|
|
2391
|
-
redos: []
|
|
2392
|
-
};
|
|
2393
|
-
}
|
|
2394
|
-
});
|
|
2395
|
-
}
|
|
2396
|
-
};
|
|
2397
|
-
Ie = Qa([
|
|
2398
|
-
ae(0, D),
|
|
2399
|
-
ae(1, v(q)),
|
|
2400
|
-
ae(2, v(be)),
|
|
2401
|
-
ae(3, v(ft)),
|
|
2402
|
-
ae(4, v(pt)),
|
|
2403
|
-
ae(5, v(F))
|
|
2404
|
-
], Ie);
|
|
2405
|
-
var Ga = Object.getOwnPropertyDescriptor, qa = (s, a, e, t) => {
|
|
2406
|
-
for (var r = t > 1 ? void 0 : t ? Ga(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2407
|
-
(o = s[i]) && (r = o(r) || r);
|
|
2408
|
-
return r;
|
|
2409
|
-
}, Se = (s, a) => (e, t) => a(e, t, s);
|
|
2410
|
-
let De = class extends B {
|
|
2411
|
-
constructor(s, a, e, t) {
|
|
2412
|
-
super(), this._univerInstanceService = s, this._sheetDataValidationModel = a, this._dataValidationCacheService = e, this._lifecycleService = t, this._initRecalculate();
|
|
2413
|
-
}
|
|
2414
|
-
_initRecalculate() {
|
|
2415
|
-
const s = (a) => {
|
|
2416
|
-
if (a.length === 0)
|
|
2417
|
-
return;
|
|
2418
|
-
const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet(), r = {};
|
|
2419
|
-
a.flat().forEach((i) => {
|
|
2420
|
-
r[i.unitId] || (r[i.unitId] = {}), r[i.unitId][i.subUnitId] || (r[i.unitId][i.subUnitId] = []);
|
|
2421
|
-
const o = this._univerInstanceService.getUnit(i.unitId, N.UNIVER_SHEET), n = o == null ? void 0 : o.getSheetBySheetId(i.subUnitId);
|
|
2422
|
-
n && r[i.unitId][i.subUnitId].push(...i.ranges.map((l) => H.transformRange(l, n)));
|
|
2423
|
-
}), Object.entries(r).forEach(([i, o]) => {
|
|
2424
|
-
Object.entries(o).forEach(([n, l]) => {
|
|
2425
|
-
(e == null ? void 0 : e.getUnitId()) === i && (t == null ? void 0 : t.getSheetId()) === n ? this.validatorRanges(i, n, l) : requestIdleCallback(() => {
|
|
2426
|
-
this.validatorRanges(i, n, l);
|
|
2427
|
-
});
|
|
2428
|
-
});
|
|
2429
|
-
});
|
|
2430
|
-
};
|
|
2431
|
-
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Zt(() => this._lifecycleService.lifecycle$.pipe(at((a) => a === tt.Rendered)))).subscribe(s)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(at(() => this._lifecycleService.stage >= tt.Rendered), It(20)).subscribe(s));
|
|
2432
|
-
}
|
|
2433
|
-
async _validatorByCell(s, a, e, t) {
|
|
2434
|
-
const r = s.getUnitId(), i = a.getSheetId();
|
|
2435
|
-
if (!M.isDefine(e) || !M.isDefine(t))
|
|
2436
|
-
throw new Error(`row or col is not defined, row: ${e}, col: ${t}`);
|
|
2437
|
-
let o = e, n = t;
|
|
2438
|
-
const l = a.getMergedCell(e, t);
|
|
2439
|
-
l && (o = l.startRow, n = l.startColumn);
|
|
2440
|
-
const u = this._sheetDataValidationModel.getRuleByLocation(r, i, o, n);
|
|
2441
|
-
return u ? new Promise((c) => {
|
|
2442
|
-
this._sheetDataValidationModel.validator(u, { unitId: r, subUnitId: i, row: o, col: n, worksheet: a, workbook: s }, (d) => {
|
|
2443
|
-
c(d);
|
|
2444
|
-
});
|
|
2445
|
-
}) : A.VALID;
|
|
2446
|
-
}
|
|
2447
|
-
async validatorCell(s, a, e, t) {
|
|
2448
|
-
const r = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
|
|
2449
|
-
if (!r)
|
|
2450
|
-
throw new Error(`cannot find current workbook, unitId: ${s}`);
|
|
2451
|
-
const i = r.getSheetBySheetId(a);
|
|
2452
|
-
if (!i)
|
|
2453
|
-
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2454
|
-
return this._validatorByCell(r, i, e, t);
|
|
2455
|
-
}
|
|
2456
|
-
async validatorRanges(s, a, e) {
|
|
2457
|
-
if (!e.length)
|
|
2458
|
-
return Promise.resolve([]);
|
|
2459
|
-
const t = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
|
|
2460
|
-
if (!t)
|
|
2461
|
-
throw new Error(`cannot find current workbook, unitId: ${s}`);
|
|
2462
|
-
const r = t.getSheetBySheetId(a);
|
|
2463
|
-
if (!r)
|
|
2464
|
-
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2465
|
-
const o = this._sheetDataValidationModel.getRules(s, a).map((c) => c.ranges).flat(), n = e.map((c) => o.map((d) => nt(c, d))).flat().filter(Boolean), l = [], u = await Promise.all(
|
|
2466
|
-
n.map((c, d) => {
|
|
2467
|
-
const g = [];
|
|
2468
|
-
for (let f = c.startRow; f <= c.endRow; f++)
|
|
2469
|
-
for (let p = c.startColumn; p <= c.endColumn; p++) {
|
|
2470
|
-
g.push(this._validatorByCell(t, r, f, p));
|
|
2471
|
-
const R = r.getMergedCell(f, p);
|
|
2472
|
-
R && l.push({
|
|
2473
|
-
resultRowIndex: d,
|
|
2474
|
-
resultColIndex: g.length - 1,
|
|
2475
|
-
row: R.startRow,
|
|
2476
|
-
col: R.startColumn
|
|
2477
|
-
});
|
|
2478
|
-
}
|
|
2479
|
-
return Promise.all(g);
|
|
2480
|
-
})
|
|
2481
|
-
);
|
|
2482
|
-
return l.length && l.forEach(({ resultRowIndex: c, resultColIndex: d, row: g, col: f }) => {
|
|
2483
|
-
var p;
|
|
2484
|
-
u[c][d] === A.VALIDATING && (u[c][d] = (p = this._dataValidationCacheService.getValue(s, a, g, f)) != null ? p : A.VALID);
|
|
2485
|
-
}), u;
|
|
2486
|
-
}
|
|
2487
|
-
async validatorWorksheet(s, a) {
|
|
2488
|
-
const e = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
|
|
2489
|
-
if (!e)
|
|
2490
|
-
throw new Error(`cannot find current workbook, unitId: ${s}`);
|
|
2491
|
-
const t = e.getSheetBySheetId(a);
|
|
2492
|
-
if (!t)
|
|
2493
|
-
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2494
|
-
const r = this._sheetDataValidationModel.getRules(s, a);
|
|
2495
|
-
return await Promise.all(
|
|
2496
|
-
r.map((i) => Promise.all(
|
|
2497
|
-
i.ranges.map((o) => {
|
|
2498
|
-
const n = [];
|
|
2499
|
-
return H.foreach(o, (l, u) => {
|
|
2500
|
-
n.push(this._validatorByCell(e, t, l, u));
|
|
2501
|
-
}), Promise.all(n);
|
|
2502
|
-
})
|
|
2503
|
-
))
|
|
2504
|
-
), this._dataValidationCacheService.ensureCache(s, a);
|
|
2505
|
-
}
|
|
2506
|
-
async validatorWorkbook(s) {
|
|
2507
|
-
const a = this._sheetDataValidationModel.getSubUnitIds(s), e = await Promise.all(a.map((r) => this.validatorWorksheet(s, r))), t = {};
|
|
2508
|
-
return e.forEach((r, i) => {
|
|
2509
|
-
t[a[i]] = r;
|
|
2510
|
-
}), t;
|
|
2511
|
-
}
|
|
2512
|
-
getDataValidations(s, a, e) {
|
|
2513
|
-
const t = this._sheetDataValidationModel.getRuleObjectMatrix(s, a), r = /* @__PURE__ */ new Set();
|
|
2514
|
-
return e.forEach((o) => {
|
|
2515
|
-
H.foreach(o, (n, l) => {
|
|
2516
|
-
const u = t.getValue(n, l);
|
|
2517
|
-
u && r.add(u);
|
|
2518
|
-
});
|
|
2519
|
-
}), Array.from(r).map((o) => this._sheetDataValidationModel.getRuleById(s, a, o)).filter(Boolean);
|
|
2520
|
-
}
|
|
2521
|
-
getDataValidation(s, a, e) {
|
|
2522
|
-
return this.getDataValidations(s, a, e)[0];
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
De = qa([
|
|
2526
|
-
Se(0, D),
|
|
2527
|
-
Se(1, v(F)),
|
|
2528
|
-
Se(2, v(Q)),
|
|
2529
|
-
Se(3, v(At))
|
|
2530
|
-
], De);
|
|
2531
|
-
var Ya = Object.defineProperty, Xa = Object.getOwnPropertyDescriptor, Ka = (s, a, e) => a in s ? Ya(s, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[a] = e, za = (s, a, e, t) => {
|
|
2532
|
-
for (var r = t > 1 ? void 0 : t ? Xa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2533
|
-
(o = s[i]) && (r = o(r) || r);
|
|
2534
|
-
return r;
|
|
2535
|
-
}, Ye = (s, a) => (e, t) => a(e, t, s), Pe = (s, a, e) => Ka(s, typeof a != "symbol" ? a + "" : a, e);
|
|
2536
|
-
let ie = class extends Lt {
|
|
2537
|
-
constructor(s = ot, a, e, t) {
|
|
2538
|
-
super(), this._config = s, this._injector = a, this._commandService = e, this._configService = t;
|
|
2539
|
-
const { ...r } = Ut(
|
|
2540
|
-
{},
|
|
2541
|
-
ot,
|
|
2542
|
-
this._config
|
|
2543
|
-
);
|
|
2544
|
-
this._configService.setConfig(Da, r);
|
|
2545
|
-
}
|
|
2546
|
-
onStarting() {
|
|
2547
|
-
[
|
|
2548
|
-
[Q],
|
|
2549
|
-
[ue],
|
|
2550
|
-
[G],
|
|
2551
|
-
[W],
|
|
2552
|
-
[De],
|
|
2553
|
-
[F],
|
|
2554
|
-
[Ie],
|
|
2555
|
-
[Ne],
|
|
2556
|
-
[Ae],
|
|
2557
|
-
[we],
|
|
2558
|
-
[Oe]
|
|
2559
|
-
].forEach((s) => {
|
|
2560
|
-
this._injector.add(s);
|
|
2561
|
-
}), [
|
|
2562
|
-
Ea,
|
|
2563
|
-
Sa,
|
|
2564
|
-
Ma,
|
|
2565
|
-
Va,
|
|
2566
|
-
Fa,
|
|
2567
|
-
Ta,
|
|
2568
|
-
ya
|
|
2569
|
-
].forEach((s) => {
|
|
2570
|
-
this._commandService.registerCommand(s);
|
|
2571
|
-
}), this._injector.get(Q), this._injector.get(De), this._injector.get(Ie), this._injector.get(Oe), this._injector.get(we);
|
|
2572
|
-
}
|
|
2573
|
-
onReady() {
|
|
2574
|
-
this._injector.get(Ae);
|
|
2575
|
-
}
|
|
2576
|
-
onRendered() {
|
|
2577
|
-
this._injector.get(Ne);
|
|
2578
|
-
}
|
|
2579
|
-
};
|
|
2580
|
-
Pe(ie, "pluginName", Na);
|
|
2581
|
-
Pe(ie, "packageName", Mt.name);
|
|
2582
|
-
Pe(ie, "version", Mt.version);
|
|
2583
|
-
Pe(ie, "type", N.UNIVER_SHEET);
|
|
2584
|
-
ie = za([
|
|
2585
|
-
Dt(Jt, Ht),
|
|
2586
|
-
Ye(1, v(be)),
|
|
2587
|
-
Ye(2, U),
|
|
2588
|
-
Ye(3, bt)
|
|
2589
|
-
], ie);
|
|
2590
|
-
function nr(s) {
|
|
2591
|
-
const e = s.get(ft).getCurrentSelections().map((i) => i.range);
|
|
2592
|
-
return {
|
|
2593
|
-
uid: Ke(6),
|
|
2594
|
-
type: T.DECIMAL,
|
|
2595
|
-
operator: h.EQUAL,
|
|
2596
|
-
formula1: "100",
|
|
2597
|
-
ranges: e != null ? e : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
|
|
2598
|
-
};
|
|
2599
|
-
}
|
|
2600
|
-
const lr = "data-validation.custom-formula-input", ur = "data-validation.formula-input", cr = "data-validation.list-formula-input", dr = "data-validation.checkbox-formula-input";
|
|
2601
|
-
export {
|
|
2602
|
-
Ea as AddSheetDataValidationCommand,
|
|
2603
|
-
ur as BASE_FORMULA_INPUT_NAME,
|
|
2604
|
-
ye as CHECKBOX_FORMULA_1,
|
|
2605
|
-
Te as CHECKBOX_FORMULA_2,
|
|
2606
|
-
dr as CHECKBOX_FORMULA_INPUT_NAME,
|
|
2607
|
-
lr as CUSTOM_FORMULA_INPUT_NAME,
|
|
2608
|
-
ca as CheckboxValidator,
|
|
2609
|
-
ya as ClearRangeDataValidationCommand,
|
|
2610
|
-
Na as DATA_VALIDATION_PLUGIN_NAME,
|
|
2611
|
-
Q as DataValidationCacheService,
|
|
2612
|
-
W as DataValidationCustomFormulaService,
|
|
2613
|
-
Ne as DataValidationFormulaController,
|
|
2614
|
-
G as DataValidationFormulaService,
|
|
2615
|
-
ue as DataValidationListCacheService,
|
|
2616
|
-
ma as DateValidator,
|
|
2617
|
-
cr as LIST_FORMULA_INPUT_NAME,
|
|
2618
|
-
$a as ListMultipleValidator,
|
|
2619
|
-
Rt as ListValidator,
|
|
2620
|
-
Ta as RemoveSheetAllDataValidationCommand,
|
|
2621
|
-
Fa as RemoveSheetDataValidationCommand,
|
|
2622
|
-
F as SheetDataValidationModel,
|
|
2623
|
-
De as SheetsDataValidationValidatorService,
|
|
2624
|
-
ie as UniverSheetsDataValidationPlugin,
|
|
2625
|
-
Va as UpdateSheetDataValidationOptionsCommand,
|
|
2626
|
-
Sa as UpdateSheetDataValidationRangeCommand,
|
|
2627
|
-
Ma as UpdateSheetDataValidationSettingCommand,
|
|
2628
|
-
nr as createDefaultNewRule,
|
|
2629
|
-
Me as deserializeListOptions,
|
|
2630
|
-
Fe as getCellValueNumber,
|
|
2631
|
-
re as getCellValueOrigin,
|
|
2632
|
-
or as getDataValidationCellValue,
|
|
2633
|
-
xe as getDataValidationDiffMutations,
|
|
2634
|
-
ve as getFormulaCellData,
|
|
2635
|
-
ne as getFormulaResult,
|
|
2636
|
-
Ue as getTransformedFormula,
|
|
2637
|
-
C as isLegalFormulaResult,
|
|
2638
|
-
sr as serializeListOptions,
|
|
2639
|
-
Re as transformCheckboxValue
|
|
2640
|
-
};
|
|
1
|
+
import{CellValueType as e,CommandType as t,DataValidationOperator as n,DataValidationRenderMode as r,DataValidationStatus as i,DataValidationType as a,DependentOn as o,Disposable as s,ICommandService as c,IConfigService as l,IPermissionService as u,IUndoRedoService as d,IUniverInstanceService as f,Inject as p,Injector as m,LifecycleService as h,LifecycleStages as g,ObjectMatrix as ee,Plugin as te,RBush as ne,Range as _,Rectangle as v,RxDisposable as re,Tools as y,UniverInstanceType as b,WrapStrategy as ie,bufferDebounceTime as ae,dayjs as oe,debounce as se,generateRandomId as ce,getIntersectRange as le,getOriginCellValue as ue,isFormulaString as x,isRangesEqual as de,merge as fe,numfmt as S,sequenceExecute as pe,toDisposable as me}from"@univerjs/core";import{AddDataValidationMutation as C,BaseDataValidator as w,DataValidationModel as T,DataValidatorRegistryService as E,RemoveDataValidationMutation as D,TextLengthErrorTitleMap as he,UniverDataValidationPlugin as ge,UpdateDataValidationMutation as O,UpdateRuleType as k,getRuleOptions as _e,getRuleSetting as ve}from"@univerjs/data-validation";import{ERROR_TYPE_SET as ye,LexerTreeBuilder as A,OtherFormulaBizType as be,RegisterOtherFormulaService as xe,deserializeRangeWithSheet as Se,deserializeRangeWithSheetWithCache as Ce,isReferenceString as we,operatorToken as Te,sequenceNodeType as Ee}from"@univerjs/engine-formula";import{ClearSelectionAllCommand as De,CopySheetCommand as Oe,RefRangeService as ke,RemoveSheetCommand as Ae,RemoveSheetMutation as je,SetRangeValuesMutation as j,SetRangeValuesUndoMutationFactory as Me,SheetInterceptorService as Ne,SheetsSelectionsService as Pe,WorksheetViewPermission as Fe,getSheetCommandTarget as Ie,handleCommonDefaultRangeChangeWithEffectRefCommands as Le}from"@univerjs/sheets";import{Subject as Re,bufferWhen as ze,filter as Be}from"rxjs";import{UnitAction as Ve}from"@univerjs/protocol";import{FormulaRefRangeService as He,UniverSheetsFormulaPlugin as Ue}from"@univerjs/sheets-formula";function M(e){"@babel/helpers - typeof";return M=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},M(e)}function We(e,t){if(M(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(M(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ge(e){var t=We(e,`string`);return M(t)==`symbol`?t:t+``}function N(e,t,n){return(t=Ge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(e,t){return function(n,r){t(n,r,e)}}function F(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let I=class extends s{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._sheetDataValidationModel=n,N(this,`_cacheMatrix`,new Map),N(this,`_dirtyRanges$`,new Re),N(this,`dirtyRanges$`,this._dirtyRanges$.asObservable()),this._initDirtyRanges(),this._initSheetRemove()}_initDirtyRanges(){this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{if(e.id===j.id&&!(t!=null&&t.onlyLocal)){let{cellValue:t,unitId:n,subUnitId:r}=e.params;if(t){let e=new ee(t).getDataRange();if(e.endRow===-1)return;let i=this._sheetDataValidationModel.getRules(n,r).map(e=>e.ranges).flat().map(t=>le(t,e)).filter(Boolean);i.length&&this.markRangeDirty(n,r,i,!0)}}}))}_initSheetRemove(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===je.id){var t;let{unitId:n,subUnitId:r}=e.params;(t=this._cacheMatrix.get(n))==null||t.delete(r)}})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{e.type===b.UNIVER_SHEET&&this._cacheMatrix.delete(e.getUnitId())}))}_ensureCache(e,t){let n=this._cacheMatrix.get(e);n||(n=new Map,this._cacheMatrix.set(e,n));let r=n.get(t);return r||(r=new ee,n.set(t,r)),r}ensureCache(e,t){return this._ensureCache(e,t)}addRule(e,t,n){this.markRangeDirty(e,t,n.ranges)}removeRule(e,t,n){this._deleteRange(e,t,n.ranges)}markRangeDirty(e,t,n,r){let i=this._ensureCache(e,t);n.forEach(e=>{_.foreach(e,(e,t)=>{i.getValue(e,t)!==void 0&&i.setValue(e,t,void 0)})}),this._dirtyRanges$.next({unitId:e,subUnitId:t,ranges:n,isSetRange:r})}_deleteRange(e,t,n){let r=this._ensureCache(e,t);n.forEach(e=>{_.foreach(e,(e,t)=>{r.realDeleteValue(e,t)})}),this._dirtyRanges$.next({unitId:e,subUnitId:t,ranges:n})}getValue(e,t,n,r){return this._ensureCache(e,t).getValue(n,r)}};I=F([P(0,p(c)),P(1,p(f)),P(2,p(T))],I);function L(e){var t;return e==null||(t=e[0])==null||(t=t[0])==null?void 0:t.v}function R(e){var t;return e==null||(t=e[0])==null?void 0:t[0]}function z(e){return!ye.has(e)}function B(e,t){var n;let r=t.getValidatorItem(e);return(n=r==null?void 0:r.offsetFormulaByRange)==null?!1:n}let V=class extends s{constructor(e,t,n,r,i){super(),this._instanceSrv=e,this._registerOtherFormulaService=t,this._dataValidationModel=n,this._dataValidationCacheService=r,this._validatorRegistryService=i,N(this,`_ruleFormulaMap`,new Map),N(this,`_ruleFormulaMap2`,new Map),this._initFormulaResultHandler(),this._initDirtyRanges()}dispose(){super.dispose(),this._ruleFormulaMap.clear(),this._ruleFormulaMap2.clear()}_initFormulaResultHandler(){this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe(e=>{for(let t in e){let n=e[t];if(this._instanceSrv.getUnitType(t)===b.UNIVER_SHEET)for(let e in n){let r=n[e],{ruleFormulaMap:i}=this._ensureMaps(t,e);r.forEach(n=>{var r,a;let o=i.get((r=n.extra)==null?void 0:r.ruleId),s=this._dataValidationModel.getRuleById(t,e,(a=n.extra)==null?void 0:a.ruleId);s&&o&&this._dataValidationCacheService.markRangeDirty(t,e,s.ranges)})}}}))}_ensureMaps(e,t){let n=this._ruleFormulaMap.get(e),r=this._ruleFormulaMap2.get(e);n||(n=new Map,this._ruleFormulaMap.set(e,n)),r||(r=new Map,this._ruleFormulaMap2.set(e,r));let i=n.get(t);i||(i=new Map,n.set(t,i));let a=r.get(t);return a||(a=new Map,r.set(t,a)),{ruleFormulaMap:i,ruleFormulaMap2:a}}_registerFormula(e,t,n,r,i){return this._registerOtherFormulaService.registerFormulaWithRange(e,t,r,i,{ruleId:n},be.DATA_VALIDATION_CUSTOM,n)}_handleDirtyRanges(e,t,n){this._dataValidationModel.getRules(e,t).forEach(r=>{let i=r.ranges;v.doAnyRangesIntersect(i,n)&&this.makeRuleDirty(e,t,r.uid)})}_initDirtyRanges(){this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.subscribe(e=>{e.isSetRange&&this._handleDirtyRanges(e.unitId,e.subUnitId,e.ranges)}))}deleteByRuleId(e,t,n){let{ruleFormulaMap:r,ruleFormulaMap2:i}=this._ensureMaps(e,t),a=this._dataValidationModel.getRuleById(e,t,n),o=r.get(n);if(!a||!o)return;let s=r.get(n);s&&(r.delete(n),this._registerOtherFormulaService.deleteFormula(e,t,[s.formulaId]));let c=i.get(n);c&&(i.delete(n),this._registerOtherFormulaService.deleteFormula(e,t,[c.formulaId]))}_addFormulaByRange(e,t,n,r,i,a){let{ruleFormulaMap:o,ruleFormulaMap2:s}=this._ensureMaps(e,t),c=a[0].startRow,l=a[0].startColumn;if(r&&x(r)){let i=this._registerFormula(e,t,n,r,a);o.set(n,{formula:r,originCol:l,originRow:c,formulaId:i})}if(i&&x(i)){let r=this._registerFormula(e,t,n,i,a);s.set(n,{formula:i,originCol:l,originRow:c,formulaId:r})}}addRule(e,t,n){if(B(n.type,this._validatorRegistryService)){let{ranges:r,formula1:i,formula2:a,uid:o}=n;this._addFormulaByRange(e,t,o,i,a,r)}}async getCellFormulaValue(e,t,n,r,i){var a;let{ruleFormulaMap:o}=this._ensureMaps(e,t),s=o.get(n);if(!s)return Promise.resolve(void 0);let c=await this._registerOtherFormulaService.getFormulaValue(e,t,s.formulaId),{originRow:l,originCol:u}=s,d=r-l,f=i-u;return R(c==null||(a=c.result)==null||(a=a[d])==null?void 0:a[f])}async getCellFormula2Value(e,t,n,r,i){var a;let{ruleFormulaMap2:o}=this._ensureMaps(e,t),s=o.get(n);if(!s)return Promise.resolve(void 0);let c=await this._registerOtherFormulaService.getFormulaValue(e,t,s.formulaId),{originRow:l,originCol:u}=s,d=r-l,f=i-u;return R(c==null||(a=c.result)==null||(a=a[d])==null?void 0:a[f])}getCellFormulaValueSync(e,t,n,r,i){var a;let{ruleFormulaMap:o}=this._ensureMaps(e,t),s=o.get(n);if(!s)return;let c=this._registerOtherFormulaService.getFormulaValueSync(e,t,s.formulaId),{originRow:l,originCol:u}=s,d=r-l,f=i-u;return R(c==null||(a=c.result)==null||(a=a[d])==null?void 0:a[f])}getCellFormula2ValueSync(e,t,n,r,i){var a;let{ruleFormulaMap2:o}=this._ensureMaps(e,t),s=o.get(n);if(!s)return;let c=this._registerOtherFormulaService.getFormulaValueSync(e,t,s.formulaId),{originRow:l,originCol:u}=s,d=r-l,f=i-u;return R(c==null||(a=c.result)==null||(a=a[d])==null?void 0:a[f])}getRuleFormulaInfo(e,t,n){let{ruleFormulaMap:r}=this._ensureMaps(e,t);return r.get(n)}makeRuleDirty(e,t,n){var r,i;let a=(r=this._ruleFormulaMap.get(e))==null||(r=r.get(t))==null?void 0:r.get(n),o=(i=this._ruleFormulaMap2.get(e))==null||(i=i.get(t))==null?void 0:i.get(n);a&&this._registerOtherFormulaService.markFormulaDirty(e,t,a.formulaId),o&&this._registerOtherFormulaService.markFormulaDirty(e,t,o.formulaId)}};V=F([P(0,f),P(1,p(xe)),P(2,p(T)),P(3,p(I)),P(4,p(E))],V);function H(e){return ue(e)}function Ke(e){var t;return String((t=H(e))==null?``:t)}function qe(e){return e.filter(Boolean).join(`,`)}function U(e){return e.split(`,`).filter(Boolean)}function Je(e){let t=H(e);return t==null?``:t.toString()}function W(e,t,n){let{formula1:r,formula2:i}=t,a=t.ranges[0].startRow,o=t.ranges[0].startColumn,s=n.row-a,c=n.col-o;return{transformedFormula1:x(r)?e.moveFormulaRefOffset(r,c,s,!0):r,transformedFormula2:x(i)?e.moveFormulaRefOffset(i,c,s,!0):i}}let G=class extends s{constructor(e,t){super(),this._injector=e,this._dataValidationModel=t,N(this,`_cache`,new Map),this._initRuleChangeListener()}_initRuleChangeListener(){this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe(e=>{(e.type===`remove`||e.type===`update`)&&this.markRuleDirty(e.unitId,e.subUnitId,e.rule.uid)}))}getOrCompute(e,t,n){let r=this.getCache(e,t,n.uid);if(r)return r;let i=this._injector.get(K).getRuleFormulaResultSync(e,t,n.uid);return this.computeAndCache(e,t,n,i)}_ensureCache(e,t){let n=this._cache.get(e);n||(n=new Map,this._cache.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}getCache(e,t,n){var r;return(r=this._cache.get(e))==null||(r=r.get(t))==null?void 0:r.get(n)}setCache(e,t,n,r){this._ensureCache(e,t).set(n,r)}markRuleDirty(e,t,n){var r;(r=this._cache.get(e))==null||(r=r.get(t))==null||r.delete(n)}clear(){this._cache.clear()}computeAndCache(e,t,n,r){var i;let{formula1:a=``,formula2:o=``}=n,s=x(a)?this._getRuleFormulaResultSet(r==null||(i=r[0])==null||(i=i.result)==null||(i=i[0])==null?void 0:i[0]):U(a),c=o.split(`,`),l=s.map((e,t)=>({label:e,color:c[t]||``})),u={};for(let e of l)e.color&&(u[e.label]=e.color);let d={list:s,listWithColor:l,colorMap:u,set:new Set(s)};return this.setCache(e,t,n.uid,d),d}_getRuleFormulaResultSet(e){if(!e)return[];let t=new Set;for(let r=0,i=e.length;r<i;r++){let i=e[r];if(i)for(let e=0,r=i.length;e<r;e++){let r=i[e],a=H(r);if(a!=null){var n;if(typeof a!=`string`&&typeof(r==null?void 0:r.s)==`object`&&!((n=r.s)==null||(n=n.n)==null)&&n.pattern){t.add(S.format(r.s.n.pattern,a,{throws:!1}));continue}let e=typeof a==`string`?a:String(a);z(e)&&t.add(e)}}}return[...t]}};G=F([P(0,p(m)),P(1,p(T))],G);let K=class extends s{constructor(e,t,n,r,i,a){super(),this._instanceService=e,this._registerOtherFormulaService=t,this._dataValidationCacheService=n,this._dataValidationModel=r,this._validatorRegistryService=i,this._listCacheService=a,N(this,`_formulaRuleMap`,new Map),this._initFormulaResultHandler()}_initFormulaResultHandler(){this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe(e=>{for(let t in e){let n=e[t];if(this._instanceService.getUnitType(t)===b.UNIVER_SHEET)for(let e in n){let r=n[e],i=this._ensureRuleFormulaMap(t,e);r.forEach(n=>{var r;let a=(r=n.extra)==null?void 0:r.ruleId;if(a&&i.get(a)){let n=this._dataValidationModel.getRuleById(t,e,a);n&&(this._listCacheService.markRuleDirty(t,e,a),this._dataValidationCacheService.markRangeDirty(t,e,n.ranges))}})}}}))}_ensureRuleFormulaMap(e,t){let n=this._formulaRuleMap.get(e);n||(n=new Map,this._formulaRuleMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_registerSingleFormula(e,t,n,r){return this._registerOtherFormulaService.registerFormulaWithRange(e,t,n,[{startColumn:0,endColumn:0,startRow:0,endRow:0}],{ruleId:r},be.DATA_VALIDATION,r)}addRule(e,t,n){if(!B(n.type,this._validatorRegistryService)&&n.type!==a.CHECKBOX){let{formula1:r,formula2:i,uid:a}=n,o=x(r),s=x(i);if(!o&&!s)return;let c=this._ensureRuleFormulaMap(e,t),l=[void 0,void 0];o&&(l[0]={id:this._registerSingleFormula(e,t,r,a),text:r}),s&&(l[1]={id:this._registerSingleFormula(e,t,i,a),text:i}),c.set(a,l)}}removeRule(e,t,n){let r=this._ensureRuleFormulaMap(e,t).get(n);if(!r)return;let[i,a]=r,o=[i==null?void 0:i.id,a==null?void 0:a.id].filter(Boolean);o.length&&this._registerOtherFormulaService.deleteFormula(e,t,o)}getRuleFormulaResult(e,t,n){let r=this._ensureRuleFormulaMap(e,t).get(n);if(!r)return Promise.resolve(null);let i=async n=>n&&this._registerOtherFormulaService.getFormulaValue(e,t,n.id);return Promise.all([i(r[0]),i(r[1])])}getRuleFormulaResultSync(e,t,n){let r=this._ensureRuleFormulaMap(e,t).get(n);if(r)return r.map(n=>{if(n)return this._registerOtherFormulaService.getFormulaValueSync(e,t,n.id)})}getRuleFormulaInfo(e,t,n){return this._ensureRuleFormulaMap(e,t).get(n)}};K=F([P(0,f),P(1,p(xe)),P(2,p(I)),P(3,p(T)),P(4,p(E)),P(5,p(G))],K);var Ye=class e{constructor(e,t,n,r,i=!1){this._unitId=t,this._subUnitId=n,this._univerInstanceService=r,this._disableTree=i,N(this,`_map`,void 0),N(this,`_tree`,new ne),N(this,`_dirty`,!0),N(this,`_buildTree`,()=>{if(!this._dirty||this._disableTree)return;this._tree.clear();let e=[];this._map.forEach((t,n)=>{t.forEach(t=>{e.push({minX:t.startRow,maxX:t.endRow,minY:t.startColumn,maxY:t.endColumn,ruleId:n})})}),this._tree.load(e),this._dirty=!1}),N(this,`_debonceBuildTree`,se(this._buildTree,0)),this._map=e,this._buildTree()}get _worksheet(){var e;return(e=this._univerInstanceService.getUnit(this._unitId,b.UNIVER_SHEET))==null?void 0:e.getSheetBySheetId(this._subUnitId)}_addRule(e,t){if(!this._worksheet)return;let n=v.mergeRanges(t.map(e=>_.transformRange(e,this._worksheet)));this._map.forEach((e,t)=>{let r=v.subtractMulti(e,n);r.length===0?this._map.delete(t):this._map.set(t,r)}),this._dirty=!0,this._map.set(e,n),this._debonceBuildTree()}addRule(e){this._addRule(e.uid,e.ranges)}removeRange(e){if(!this._worksheet)return;let t=e.map(e=>_.transformRange(e,this._worksheet));this._map.forEach((e,n)=>{let r=v.subtractMulti(e,t);r.length===0?this._map.delete(n):this._map.set(n,r)}),this._dirty=!0,this._debonceBuildTree()}_removeRule(e){this._map.delete(e),this._dirty=!0,this._debonceBuildTree()}removeRule(e){this._removeRule(e.uid)}updateRange(e,t){this._removeRule(e),this._addRule(e,t)}addRangeRules(e){e.forEach(({id:e,ranges:t})=>{if(!t.length)return;let n=this._map.get(e);n?(this._map.set(e,v.mergeRanges([...n,...t])),n=this._map.get(e)):(n=t,this._map.set(e,n)),this._map.forEach((n,r)=>{if(r===e)return;let i=v.subtractMulti(n,t);i.length===0?this._map.delete(r):this._map.set(r,i)})}),this._dirty=!0,this._debonceBuildTree()}diff(e){let t=[],n=0;return e.forEach((e,r)=>{var i;let a=(i=this._map.get(e.uid))==null?[]:i,o=e.ranges;a.length!==0&&(a.length!==o.length||a.some((e,t)=>!v.equals(e,o[t])))&&t.push({type:`update`,ruleId:e.uid,oldRanges:o,newRanges:v.sort(a),rule:e}),a.length===0&&(t.push({type:`delete`,rule:e,index:r-n}),n++)}),t}diffWithAddition(e,t){let n=[],r=0;return e.forEach((e,t)=>{var i;let a=(i=this._map.get(e.uid))==null?[]:i,o=e.ranges;a.length!==0&&(a.length!==o.length||a.some((e,t)=>!v.equals(e,o[t])))&&n.push({type:`update`,ruleId:e.uid,oldRanges:o,newRanges:v.sort(a),rule:e}),a.length===0&&(n.push({type:`delete`,rule:e,index:t-r}),r++)}),Array.from(t).forEach(e=>{var t;let r=(t=this._map.get(e.uid))==null?[]:t;n.push({type:`add`,rule:{...e,ranges:v.sort(r)}})}),n}clone(){return new e(new Map(y.deepClone(Array.from(this._map.entries()))),this._unitId,this._subUnitId,this._univerInstanceService,!0)}getValue(e,t){this._dirty&&this._buildTree();let n=this._tree.search({minX:e,maxX:e,minY:t,maxY:t});return n.length>0?n[0].ruleId:void 0}};let q=class extends s{constructor(e,t,n,r,i,a,o){super(),this._dataValidationModel=e,this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._dataValidationCacheService=r,this._dataValidationFormulaService=i,this._dataValidationCustomFormulaService=a,this._commandService=o,N(this,`_ruleMatrixMap`,new Map),N(this,`_validStatusChange$`,new Re),N(this,`_ruleChange$`,new Re),N(this,`ruleChange$`,this._ruleChange$.asObservable()),N(this,`validStatusChange$`,this._validStatusChange$.asObservable()),this._initRuleUpdateListener(),this.disposeWithMe(()=>{this._ruleChange$.complete(),this._validStatusChange$.complete()}),this._initUniverInstanceListener()}_initUniverInstanceListener(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{this._ruleMatrixMap.delete(e.getUnitId())})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===je.id){let{unitId:t,subUnitId:n}=e.params,r=this._ruleMatrixMap.get(t);r&&r.delete(n)}}))}_initRuleUpdateListener(){let e=this._dataValidationModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this._addRule(t,e,n),this._ruleChange$.next({type:`add`,unitId:t,subUnitId:e,rule:n,source:`patched`});this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe(e=>{switch(e.type){case`add`:this._addRule(e.unitId,e.subUnitId,e.rule);break;case`update`:this._updateRule(e.unitId,e.subUnitId,e.rule.uid,e.oldRule,e.updatePayload);break;case`remove`:this._removeRule(e.unitId,e.subUnitId,e.rule);break}this._ruleChange$.next(e)}))}_ensureRuleMatrix(e,t){let n=this._ruleMatrixMap.get(e);n||(n=new Map,this._ruleMatrixMap.set(e,n));let r=n.get(t);return r||(r=new Ye(new Map,e,t,this._univerInstanceService),n.set(t,r)),r}_addRuleSideEffect(e,t,n){this._ensureRuleMatrix(e,t).addRule(n),this._dataValidationCacheService.addRule(e,t,n),this._dataValidationFormulaService.addRule(e,t,n),this._dataValidationCustomFormulaService.addRule(e,t,n)}_addRule(e,t,n){(Array.isArray(n)?n:[n]).forEach(n=>{this._addRuleSideEffect(e,t,n)})}_updateRule(e,t,n,r,i){let a=this._ensureRuleMatrix(e,t),o={...r,...i.payload};i.type===k.RANGE?a.updateRange(n,i.payload):i.type===k.ALL&&a.updateRange(n,i.payload.ranges),this._dataValidationCacheService.removeRule(e,t,r),this._dataValidationCacheService.addRule(e,t,o),this._dataValidationFormulaService.removeRule(e,t,r.uid),this._dataValidationFormulaService.addRule(e,t,o),this._dataValidationCustomFormulaService.deleteByRuleId(e,t,n),this._dataValidationCustomFormulaService.addRule(e,t,o)}_removeRule(e,t,n){this._ensureRuleMatrix(e,t).removeRule(n),this._dataValidationCacheService.removeRule(e,t,n),this._dataValidationCustomFormulaService.deleteByRuleId(e,t,n.uid)}getValidator(e){return this._dataValidatorRegistryService.getValidatorItem(e)}getRuleIdByLocation(e,t,n,r){return this._ensureRuleMatrix(e,t).getValue(n,r)}getRuleByLocation(e,t,n,r){let i=this.getRuleIdByLocation(e,t,n,r);if(i)return this._dataValidationModel.getRuleById(e,t,i)}validator(e,t,n){let{col:r,row:a,unitId:o,subUnitId:s,worksheet:c}=t,l=(t,i)=>{n&&n(t,i),i&&this._validStatusChange$.next({unitId:o,subUnitId:s,ruleId:e.uid,status:t,row:a,col:r})},u=c.getCellValueOnly(a,r),d=this.getValidator(e.type),f=c.getCellRaw(a,r),p=H(f);if(d){let n=this._dataValidationCacheService.ensureCache(o,s),c=n.getValue(a,r);return c==null?(n.setValue(a,r,i.VALIDATING),d.validator({value:p,unitId:o,subUnitId:s,row:a,column:r,worksheet:t.worksheet,workbook:t.workbook,interceptValue:H(u),t:f==null?void 0:f.t},e).then(e=>{let t=e?i.VALID:i.INVALID,o=n.getValue(a,r);t===i.VALID?n.realDeleteValue(a,r):n.setValue(a,r,t),l(t,c!==o)}),i.VALIDATING):(l(c==null?i.VALID:c,!1),c==null?i.VALID:c)}else return l(i.VALID,!1),i.VALID}getRuleObjectMatrix(e,t){return this._ensureRuleMatrix(e,t)}getRuleById(e,t,n){return this._dataValidationModel.getRuleById(e,t,n)}getRuleIndex(e,t,n){return this._dataValidationModel.getRuleIndex(e,t,n)}getRules(e,t){return[...this._dataValidationModel.getRules(e,t)]}getUnitRules(e){return this._dataValidationModel.getUnitRules(e)}deleteUnitRules(e){return this._dataValidationModel.deleteUnitRules(e)}getSubUnitIds(e){return this._dataValidationModel.getSubUnitIds(e)}getAll(){return this._dataValidationModel.getAll()}};q=F([P(0,p(T)),P(1,f),P(2,p(E)),P(3,p(I)),P(4,p(K)),P(5,p(V)),P(6,c)],q);const Xe=1,Ze=0;function Qe(e,t){return y.isBlank(e)?t.t(`dataValidation.validFail.value`):x(e)?t.t(`dataValidation.validFail.primitive`):``}const J=e=>y.isDefine(e)&&String(e).toLowerCase()===`true`?`1`:String(e).toLowerCase()===`false`?`0`:e;var $e=class extends w{constructor(...e){super(...e),N(this,`id`,a.CHECKBOX),N(this,`title`,`dataValidation.checkbox.title`),N(this,`operators`,[]),N(this,`scopes`,[`sheet`]),N(this,`order`,41),N(this,`offsetFormulaByRange`,!1),N(this,`_formulaService`,this.injector.get(K)),N(this,`skipDefaultFontRender`,(e,t,n)=>{let{unitId:r,subUnitId:i}=n,{formula1:a,formula2:o}=this.parseFormulaSync(e,r,i),s=`${t==null?``:t}`;return!s||s===`${a}`||s===`${o}`})}validatorFormula(e,t,n){let{formula1:r,formula2:i}=e,a=r===i;if(y.isBlank(r)&&y.isBlank(i))return{success:!0};if(a)return{success:!1,formula1:this.localeService.t(`dataValidation.validFail.checkboxEqual`),formula2:this.localeService.t(`dataValidation.validFail.checkboxEqual`)};let o=Qe(r,this.localeService),s=Qe(i,this.localeService);return{success:!o&&!s,formula1:o,formula2:s}}async parseFormula(e,t,n){var r,i;let{formula1:a=1,formula2:o=0}=e,s=await this._formulaService.getRuleFormulaResult(t,n,e.uid),c=x(a)?L(s==null||(r=s[0])==null||(r=r.result)==null?void 0:r[0][0]):a,l=x(o)?L(s==null||(i=s[1])==null||(i=i.result)==null?void 0:i[0][0]):o,u=z(String(c))&&z(String(l));return{formula1:J(c),formula2:J(l),originFormula1:c,originFormula2:l,isFormulaValid:u}}getExtraStyle(e,t){return{tb:ie.CLIP}}parseFormulaSync(e,t,n){var r,i;let{formula1:a=1,formula2:o=0}=e,s=this._formulaService.getRuleFormulaResultSync(t,n,e.uid),c=x(a)?L(s==null||(r=s[0])==null||(r=r.result)==null?void 0:r[0][0]):a,l=x(o)?L(s==null||(i=s[1])==null||(i=i.result)==null?void 0:i[0][0]):o,u=z(String(c))&&z(String(l));return{formula1:J(c),formula2:J(l),originFormula1:c,originFormula2:l,isFormulaValid:u}}async isValidType(e,t,n){let{value:r,unitId:i,subUnitId:a}=e,{formula1:o,formula2:s,originFormula1:c,originFormula2:l}=await this.parseFormula(n,i,a);return!y.isDefine(o)||!y.isDefine(s)?!0:y.isDefine(r)&&(String(r)===String(o)||String(r)===String(s)||String(r)===String(c==null?``:c)||String(r)===String(l==null?``:l))}generateRuleErrorMessage(e){return this.localeService.t(`dataValidation.checkbox.error`)}generateRuleName(e){return this.titleStr}};const et={[n.BETWEEN]:`dataValidation.date.operators.between`,[n.EQUAL]:`dataValidation.date.operators.equal`,[n.GREATER_THAN]:`dataValidation.date.operators.greaterThan`,[n.GREATER_THAN_OR_EQUAL]:`dataValidation.date.operators.greaterThanOrEqual`,[n.LESS_THAN]:`dataValidation.date.operators.lessThan`,[n.LESS_THAN_OR_EQUAL]:`dataValidation.date.operators.lessThanOrEqual`,[n.NOT_BETWEEN]:`dataValidation.date.operators.notBetween`,[n.NOT_EQUAL]:`dataValidation.date.operators.notEqual`};n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL;const tt={[n.BETWEEN]:`dataValidation.date.ruleName.between`,[n.EQUAL]:`dataValidation.date.ruleName.equal`,[n.GREATER_THAN]:`dataValidation.date.ruleName.greaterThan`,[n.GREATER_THAN_OR_EQUAL]:`dataValidation.date.ruleName.greaterThanOrEqual`,[n.LESS_THAN]:`dataValidation.date.ruleName.lessThan`,[n.LESS_THAN_OR_EQUAL]:`dataValidation.date.ruleName.lessThanOrEqual`,[n.NOT_BETWEEN]:`dataValidation.date.ruleName.notBetween`,[n.NOT_EQUAL]:`dataValidation.date.ruleName.notEqual`,NONE:`dataValidation.date.ruleName.legal`},nt={[n.BETWEEN]:`dataValidation.date.errorMsg.between`,[n.EQUAL]:`dataValidation.date.errorMsg.equal`,[n.GREATER_THAN]:`dataValidation.date.errorMsg.greaterThan`,[n.GREATER_THAN_OR_EQUAL]:`dataValidation.date.errorMsg.greaterThanOrEqual`,[n.LESS_THAN]:`dataValidation.date.errorMsg.lessThan`,[n.LESS_THAN_OR_EQUAL]:`dataValidation.date.errorMsg.lessThanOrEqual`,[n.NOT_BETWEEN]:`dataValidation.date.errorMsg.notBetween`,[n.NOT_EQUAL]:`dataValidation.date.errorMsg.notEqual`,NONE:`dataValidation.date.errorMsg.legal`},rt=[n.BETWEEN,n.NOT_BETWEEN],Y=`{FORMULA1}`,X=`{FORMULA2}`,it=e=>{var t,n;if(e==null||typeof e==`boolean`)return;if(typeof e==`number`||!Number.isNaN(+e))return+e;let r=(t=S.parseDate(e))==null?void 0:t.v;return y.isDefine(r)?r:(n=S.parseDate(oe(e).format(`YYYY-MM-DD HH:mm:ss`)))==null?void 0:n.v};var at=class extends w{constructor(...e){super(...e),N(this,`id`,a.DATE),N(this,`title`,`dataValidation.date.title`),N(this,`order`,40),N(this,`operators`,[n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL]),N(this,`scopes`,[`sheet`]),N(this,`_customFormulaService`,this.injector.get(V)),N(this,`_lexerTreeBuilder`,this.injector.get(A))}async parseFormula(e,t,n,r,i){let a=await this._customFormulaService.getCellFormulaValue(t,n,e.uid,r,i),o=await this._customFormulaService.getCellFormula2Value(t,n,e.uid,r,i),{formula1:s,formula2:c}=e,l=z(String(a==null?void 0:a.v))&&z(String(o==null?void 0:o.v));return{formula1:it(x(s)?a==null?void 0:a.v:s),formula2:it(x(c)?o==null?void 0:o.v:c),isFormulaValid:l}}async isValidType(e){let{interceptValue:t,value:n}=e;return typeof n==`number`&&typeof t==`string`||typeof t==`string`?!!S.parseDate(t):!1}_validatorSingleFormula(e){return!y.isBlank(e)&&(x(e)||!Number.isNaN(+e)||!!(e&&S.parseDate(e)))}validatorFormula(e,t,n){let r=e.operator;if(!r)return{success:!0};let i=this._validatorSingleFormula(e.formula1),a=this.localeService.t(`dataValidation.validFail.date`);if(rt.includes(r)){let t=this._validatorSingleFormula(e.formula2);return{success:i&&t,formula1:i?void 0:a,formula2:t?void 0:a}}return{success:i,formula1:i?void 0:a}}normalizeFormula(e,t,n){let{formula1:r,formula2:i,bizInfo:a}=e,o=e=>{if(!e)return e;let t;if(!Number.isNaN(+e))t=S.dateFromSerial(+e);else{var n;let r=(n=S.parseDate(e))==null?void 0:n.v;if(r==null)return``;t=S.dateFromSerial(r)}return oe(`${t[0]}/${t[1]}/${t[2]} ${t[3]}:${t[4]}:${t[5]}`).format(a!=null&&a.showTime?`YYYY-MM-DD HH:mm:ss`:`YYYY-MM-DD`)};return{formula1:x(r)?r:o(`${r}`),formula2:x(i)?i:o(`${i}`)}}transform(e,t,n){let{value:r}=e;return{...e,value:it(r)}}get operatorNames(){return this.operators.map(e=>this.localeService.t(et[e]))}generateRuleName(e){var t,n;if(!e.operator)return this.localeService.t(tt.NONE);let r=this.localeService.t(tt[e.operator]).replace(Y,(t=e.formula1)==null?``:t).replace(X,(n=e.formula2)==null?``:n);return`${this.titleStr} ${r}`}generateRuleErrorMessage(e,t){if(!e.operator)return this.titleStr;let{transformedFormula1:n,transformedFormula2:r}=W(this._lexerTreeBuilder,e,t);return`${this.localeService.t(nt[e.operator]).replace(Y,n==null?``:n).replace(X,r==null?``:r)}`}};n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL,n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL;const ot={[n.BETWEEN]:`dataValidation.errorMsg.between`,[n.EQUAL]:`dataValidation.errorMsg.equal`,[n.GREATER_THAN]:`dataValidation.errorMsg.greaterThan`,[n.GREATER_THAN_OR_EQUAL]:`dataValidation.errorMsg.greaterThanOrEqual`,[n.LESS_THAN]:`dataValidation.errorMsg.lessThan`,[n.LESS_THAN_OR_EQUAL]:`dataValidation.errorMsg.lessThanOrEqual`,[n.NOT_BETWEEN]:`dataValidation.errorMsg.notBetween`,[n.NOT_EQUAL]:`dataValidation.errorMsg.notEqual`,NONE:`dataValidation.errorMsg.legal`};function Z(e){return+e}var st=class extends w{constructor(...e){super(...e),N(this,`_customFormulaService`,this.injector.get(V)),N(this,`id`,a.DECIMAL),N(this,`_lexerTreeBuilder`,this.injector.get(A)),N(this,`title`,`dataValidation.decimal.title`),N(this,`order`,20),N(this,`operators`,[n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL]),N(this,`scopes`,[`sheet`])}_isFormulaOrNumber(e){return!y.isBlank(e)&&(x(e)||!Number.isNaN(+e))}async isValidType(e,t,n){let{value:r}=e;return!Number.isNaN(Z(r))}transform(e,t,n){let{value:r}=e;return{...e,value:Z(r)}}_parseNumber(e){return e==null?NaN:+e}async parseFormula(e,t,n,r,i){let a=await this._customFormulaService.getCellFormulaValue(t,n,e.uid,r,i),o=await this._customFormulaService.getCellFormula2Value(t,n,e.uid,r,i),{formula1:s,formula2:c}=e,l=z(String(a==null?void 0:a.v))&&z(String(o==null?void 0:o.v));return{formula1:this._parseNumber(x(s)?a==null?void 0:a.v:s),formula2:this._parseNumber(x(c)?o==null?void 0:o.v:c),isFormulaValid:l}}validatorFormula(e,t,n){let r=e.operator;if(!r)return{success:!0};let i=y.isDefine(e.formula1)&&this._isFormulaOrNumber(e.formula1),a=y.isDefine(e.formula2)&&this._isFormulaOrNumber(e.formula2),o=rt.includes(r),s=this.localeService.t(`dataValidation.validFail.number`);return o?{success:i&&a,formula1:i?void 0:s,formula2:a?void 0:s}:{success:i,formula1:i?``:s}}generateRuleErrorMessage(e,t){if(!e.operator)return this.localeService.t(ot.NONE).replace(`{TYPE}`,this.titleStr);let{transformedFormula1:n,transformedFormula2:r}=W(this._lexerTreeBuilder,e,t);return`${this.localeService.t(ot[e.operator]).replace(Y,n==null?``:n).replace(X,r==null?``:r)}`}};function ct(e){if(!e)return[];let t=new Set;for(let r=0,i=e.length;r<i;r++){let i=e[r];if(i)for(let e=0,r=i.length;e<r;e++){let r=i[e],a=H(r);if(a!=null){var n;if(typeof a!=`string`&&typeof(r==null?void 0:r.s)==`object`&&!((n=r.s)==null||(n=n.n)==null)&&n.pattern){t.add(S.format(r.s.n.pattern,a,{throws:!1}));continue}let e=typeof a==`string`?a:String(a);z(e)&&t.add(e)}}}return[...t]}const lt=[`if`,`indirect`,`choose`,`offset`];function ut(e,t){if(!x(e)||we(e.slice(1)))return!0;let n=t.sequenceNodesBuilder(e);return n&&n.some(e=>typeof e==`object`&&e.nodeType===Ee.FUNCTION&<.indexOf(e.token.toLowerCase())>-1)}function dt(e,t){let{formula1:n=``,ranges:r}=e;if(we(n.slice(1))){let e=Se(n.slice(1));if((!e.sheetName||e.sheetName===t)&&r.some(t=>v.intersects(t,e.range)))return!0}return!1}var ft=class extends w{constructor(...e){super(...e),N(this,`formulaService`,this.injector.get(K)),N(this,`_lexer`,this.injector.get(A)),N(this,`_univerInstanceService`,this.injector.get(f)),N(this,`_listCacheService`,this.injector.get(G)),N(this,`order`,50),N(this,`offsetFormulaByRange`,!1),N(this,`id`,a.LIST),N(this,`title`,`dataValidation.list.title`),N(this,`operators`,[]),N(this,`scopes`,[`sheet`]),N(this,`skipDefaultFontRender`,e=>e.renderMode!==r.TEXT)}validatorFormula(e,t,n){var r,i;let a=!y.isBlank(e.formula1),o=ut((r=e.formula1)==null?``:r,this._lexer),s=(i=this._univerInstanceService.getUnit(t,b.UNIVER_SHEET))==null||(i=i.getSheetBySheetId(n))==null?void 0:i.getName(),c=dt(e,s==null?``:s);return{success:!!(a&&o&&!c),formula1:a?o?c?this.localeService.t(`dataValidation.validFail.listIntersects`):void 0:this.localeService.t(`dataValidation.validFail.listInvalid`):this.localeService.t(`dataValidation.validFail.list`)}}getExtraStyle(e,t,{style:n}){var i;let o=(i=n.tb===ie.OVERFLOW?ie.CLIP:n.tb)==null?ie.WRAP:i;if(e.type===a.LIST&&(e.renderMode===r.ARROW||e.renderMode===r.TEXT)){let n=this.getListWithColorMap(e)[`${t==null?``:t}`];if(n)return{bg:{rgb:n},tb:o}}return{tb:o}}parseCellValue(e){return U(e.toString())}async parseFormula(e,t,n){var r;let i=await this.formulaService.getRuleFormulaResult(t,n,e.uid),a=L(i==null||(r=i[0])==null||(r=r.result)==null?void 0:r[0][0]);return{formula1:void 0,formula2:void 0,isFormulaValid:z(String(a))}}async isValidType(e,t,n){let{value:r,unitId:i,subUnitId:a}=e,{formula1:o=``}=n,s=x(o)?this._listCacheService.getOrCompute(i,a,n).list:U(o);return this.parseCellValue(r).every(e=>s.includes(e))}generateRuleName(){return this.localeService.t(`dataValidation.list.name`)}generateRuleErrorMessage(){return this.localeService.t(`dataValidation.list.error`)}_getUnitAndSubUnit(e,t){var n,r;let i=(n=e?this._univerInstanceService.getUniverSheetInstance(e):void 0)==null?this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET):n;if(!i)return null;let a=(r=t?i.getSheetBySheetId(t):void 0)==null?i.getActiveSheet():r;return a?{unitId:i.getUnitId(),subUnitId:a.getSheetId()}:null}getList(e,t,n){let r=this._getUnitAndSubUnit(t,n);if(!r)return[];let{unitId:i,subUnitId:a}=r;return this._listCacheService.getOrCompute(i,a,e).list}async getListAsync(e,t,n){var r;let{formula1:i=``}=e,a=this._getUnitAndSubUnit(t,n);if(!a)return[];let{unitId:o,subUnitId:s}=a,c=await this.formulaService.getRuleFormulaResult(o,s,e.uid);return x(i)?ct(c==null||(r=c[0])==null||(r=r.result)==null?void 0:r[0][0]):U(i)}getListWithColor(e,t,n){let r=this._getUnitAndSubUnit(t,n);if(!r)return[];let{unitId:i,subUnitId:a}=r;return this._listCacheService.getOrCompute(i,a,e).listWithColor}getListWithColorMap(e,t,n){let r=this._getUnitAndSubUnit(t,n);if(!r)return{};let{unitId:i,subUnitId:a}=r;return this._listCacheService.getOrCompute(i,a,e).colorMap}},pt=class extends w{constructor(...e){super(...e),N(this,`id`,a.TEXT_LENGTH),N(this,`title`,`dataValidation.textLength.title`),N(this,`_lexerTreeBuilder`,this.injector.get(A)),N(this,`order`,30),N(this,`operators`,[n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL]),N(this,`scopes`,[`sheet`]),N(this,`_customFormulaService`,this.injector.get(V))}_isFormulaOrInt(e){return!y.isBlank(e)&&(x(e)||!Number.isNaN(+e)&&Number.isInteger(+e))}validatorFormula(e,t,n){let r=e.operator;if(!r)return{success:!1};let i=y.isDefine(e.formula1)&&this._isFormulaOrInt(e.formula1),a=y.isDefine(e.formula2)&&this._isFormulaOrInt(e.formula2),o=rt.includes(r),s=this.localeService.t(`dataValidation.validFail.number`);return o?{success:i&&a,formula1:i?void 0:s,formula2:a?void 0:s}:{success:i,formula1:s}}_parseNumber(e){return e==null?NaN:+e}async parseFormula(e,t,n,r,i){let a=await this._customFormulaService.getCellFormulaValue(t,n,e.uid,r,i),o=await this._customFormulaService.getCellFormula2Value(t,n,e.uid,r,i),{formula1:s,formula2:c}=e,l=z(String(a==null?void 0:a.v))&&z(String(o==null?void 0:o.v));return{formula1:this._parseNumber(x(s)?a==null?void 0:a.v:s),formula2:this._parseNumber(x(c)?o==null?void 0:o.v:c),isFormulaValid:l}}transform(e,t,n){return{...e,value:e.value.toString().length}}async isValidType(e,t,n){let{value:r}=e;return typeof r==`string`||typeof r==`number`}generateRuleErrorMessage(e,t){if(!e.operator)return this.titleStr;let{transformedFormula1:n,transformedFormula2:r}=W(this._lexerTreeBuilder,e,t);return`${this.localeService.t(he[e.operator]).replace(Y,n==null?``:n).replace(X,r==null?``:r)}`}};function mt(e){var t,n;return e?e.p?!((t=(n=e.p.body)==null?void 0:n.dataStream)==null?``:t).slice(0,-2).trim():y.isBlank(e.v):!0}function ht(e,t,n,r,i=`command`,o=!0){let s=r.get(A),c=r.get(E),l=[],u=[],d=r.get(q),p=Ie(r.get(f),{unitId:e,subUnitId:t});if(!p)return{redoMutations:l,undoMutations:u};let{worksheet:m}=p,h=new ee,g=!1;function te(e,t){o&&e.forEach(e=>{_.foreach(e,(e,n)=>{let r=m.getCellRaw(e,n),i=Ke(r);(mt(r)||i===t)&&!(r!=null&&r.p)&&(g=!0,h.setValue(e,n,{v:t,p:null}))})})}if(n.forEach(n=>{switch(n.type){case`delete`:l.push({id:D.id,params:{unitId:e,subUnitId:t,ruleId:n.rule.uid,source:i}}),u.unshift({id:C.id,params:{unitId:e,subUnitId:t,rule:n.rule,index:n.index,source:i}});break;case`update`:{if(B(n.rule.type,c)){let r=n.oldRanges[0].startRow,a=n.oldRanges[0].startColumn,o=n.newRanges[0].startRow,c=n.newRanges[0].startColumn,d=o-r,f=c-a,p=x(n.rule.formula1)?s.moveFormulaRefOffset(n.rule.formula1,f,d):n.rule.formula1,m=x(n.rule.formula2)?s.moveFormulaRefOffset(n.rule.formula2,f,d):n.rule.formula2;p!==n.rule.formula1||m!==n.rule.formula2||!de(n.newRanges,n.oldRanges)?(l.push({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.ruleId,payload:{type:k.ALL,payload:{formula1:p,formula2:m,ranges:n.newRanges}}}}),u.unshift({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.ruleId,payload:{type:k.ALL,payload:{formula1:n.rule.formula1,formula2:n.rule.formula2,ranges:n.oldRanges}}}})):(l.push({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.ruleId,payload:{type:k.RANGE,payload:n.newRanges},source:i}}),u.unshift({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.ruleId,payload:{type:k.RANGE,payload:n.oldRanges},source:i}}))}else l.push({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.ruleId,payload:{type:k.RANGE,payload:n.newRanges},source:i}}),u.unshift({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.ruleId,payload:{type:k.RANGE,payload:n.oldRanges},source:i}});let r=d.getRuleById(e,t,n.ruleId);if(r&&r.type===a.CHECKBOX){let i=d.getValidator(a.CHECKBOX).parseFormulaSync(r,e,t);te(n.newRanges,i.formula2)}break}case`add`:if(l.push({id:C.id,params:{unitId:e,subUnitId:t,rule:n.rule,source:i}}),u.unshift({id:D.id,params:{unitId:e,subUnitId:t,ruleId:n.rule.uid,source:i}}),n.rule.type===a.CHECKBOX){let r=d.getValidator(a.CHECKBOX).parseFormulaSync(n.rule,e,t);te(n.rule.ranges,r.originFormula2)}break;default:break}}),g){let n={id:j.id,params:{unitId:e,subUnitId:t,cellValue:h.getData()}},i={id:j.id,params:Me(r,n.params)};l.push(n),u.push(i)}return{redoMutations:l,undoMutations:u}}const gt={type:t.COMMAND,id:`sheet.command.updateDataValidationRuleRange`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ranges:i,ruleId:a}=t,o=e.get(q),s=e.get(c),l=e.get(d);if(!o.getRuleById(n,r,a))return!1;let u=o.getRuleObjectMatrix(n,r).clone();u.updateRange(a,i);let{redoMutations:f,undoMutations:p}=ht(n,r,u.diff(o.getRules(n,r)),e);return l.pushUndoRedo({undoMutations:p,redoMutations:f,unitID:n}),pe(f,s),!0}},_t={type:t.COMMAND,id:`sheet.command.addDataValidation`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,rule:i}=t,a=e.get(q),o=e.get(c),s=e.get(d),l=a.getRuleObjectMatrix(n,r).clone();l.addRule(i);let u=l.diff(a.getRules(n,r)),f=a.getValidator(i.type),p={unitId:n,subUnitId:r,rule:{...i,...f==null?void 0:f.normalizeFormula(i,n,r)}},{redoMutations:m,undoMutations:h}=ht(n,r,u,e);return m.push({id:C.id,params:p}),h.unshift({id:D.id,params:{unitId:n,subUnitId:r,ruleId:i.uid}}),s.pushUndoRedo({unitID:n,redoMutations:m,undoMutations:h}),pe(m,o),!0}},vt={type:t.COMMAND,id:`sheets.command.update-data-validation-setting`,handler(e,t){if(!t)return!1;let n=e.get(c),r=e.get(d),i=e.get(q),o=e.get(E),{unitId:s,subUnitId:l,ruleId:u,setting:p}=t,m=o.getValidatorItem(p.type);if(!m)return!1;let h=i.getRuleById(s,l,u);if(!h)return!1;let g={...h,...p};if(!m.validatorFormula(g,s,l).success)return!1;let te={unitId:s,subUnitId:l,ruleId:u,payload:{type:k.SETTING,payload:{...p,...m.normalizeFormula(g,s,l)}}},ne=[{id:O.id,params:te}],v={unitId:s,subUnitId:l,ruleId:u,payload:{type:k.SETTING,payload:ve(h)}},re=[{id:O.id,params:v}];if(p.type===a.CHECKBOX){let t=h.ranges,n=Ie(e.get(f),{unitId:s,subUnitId:l});if(n){let r=new ee,{worksheet:i}=n,{formula2:a=0,formula1:o=1}=h,{formula2:c=0,formula1:u=1}=p,d=!1;if(t.forEach(e=>{_.foreach(e,(e,t)=>{let n=i.getCellRaw(e,t),s=Ke(n);(mt(n)||s===String(a))&&!(n!=null&&n.p)?(r.setValue(e,t,{v:c,p:null}),d=!0):s===String(o)&&!(n!=null&&n.p)&&(r.setValue(e,t,{v:u,p:null}),d=!0)})}),d){let t={id:j.id,params:{unitId:s,subUnitId:l,cellValue:r.getData()}},n={id:j.id,params:Me(e,t.params)};ne.push(t),re.push(n)}}}return pe(ne,n).result?(r.pushUndoRedo({unitID:s,redoMutations:ne,undoMutations:re}),!0):!1}},yt={type:t.COMMAND,id:`sheets.command.update-data-validation-options`,handler(e,t){if(!t)return!1;let n=e.get(c),r=e.get(d),i=e.get(q),{unitId:a,subUnitId:o,ruleId:s,options:l}=t,u=i.getRuleById(a,o,s);if(!u)return!1;let f={unitId:a,subUnitId:o,ruleId:s,payload:{type:k.OPTIONS,payload:l}},p=[{id:O.id,params:f}],m={unitId:a,subUnitId:o,ruleId:s,payload:{type:k.OPTIONS,payload:_e(u)}},h=[{id:O.id,params:m}];return r.pushUndoRedo({unitID:a,redoMutations:p,undoMutations:h}),n.executeCommand(O.id,f),!0}},bt={type:t.COMMAND,id:`sheets.command.clear-range-data-validation`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ranges:i}=t,a=e.get(c),o=Ie(e.get(f),{unitId:n,subUnitId:r}),s=e.get(q);if(!o)return!1;let l=e.get(d),u=s.getRuleObjectMatrix(n,r).clone();u.removeRange(i);let{redoMutations:p,undoMutations:m}=ht(n,r,u.diff(s.getRules(n,r)),e);return l.pushUndoRedo({unitID:n,redoMutations:p,undoMutations:m}),pe(p,a).result}},xt={type:t.COMMAND,id:`sheet.command.remove-all-data-validation`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r}=t,i=e.get(c),a=e.get(q),o=e.get(d),s=[...a.getRules(n,r)],l={unitId:n,subUnitId:r,ruleId:s.map(e=>e.uid)},u=[{id:D.id,params:l}],f=[{id:C.id,params:{unitId:n,subUnitId:r,rule:s}}];return o.pushUndoRedo({redoMutations:u,undoMutations:f,unitID:n}),i.executeCommand(D.id,l),!0}},St=(e,t)=>{let n=e.get(q),{unitId:r,subUnitId:i,ruleId:a,source:o}=t;if(Array.isArray(a)){let e=a.map(e=>n.getRuleById(r,i,e)).filter(Boolean);return[{id:C.id,params:{unitId:r,subUnitId:i,rule:e,source:o}}]}return[{id:C.id,params:{unitId:r,subUnitId:i,rule:{...n.getRuleById(r,i,a)},index:n.getRuleIndex(r,i,a)}}]},Ct={type:t.COMMAND,id:`sheet.command.remove-data-validation-rule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ruleId:i}=t,a=e.get(c),o=e.get(d),s=e.get(q),l=[{id:D.id,params:t}],u=[{id:C.id,params:{unitId:n,subUnitId:r,rule:{...s.getRuleById(n,r,i)},index:s.getRuleIndex(n,r,i)}}];return o.pushUndoRedo({undoMutations:u,redoMutations:l,unitID:t.unitId}),a.executeCommand(D.id,t),!0}},wt=`SHEET_DATA_VALIDATION_PLUGIN`;let Tt=class extends s{constructor(e,t,n){super(),this._univerInstanceService=e,this._permissionService=t,this._lexerTreeBuilder=n}getFormulaRefCheck(e){let t=this._lexerTreeBuilder.sequenceNodesBuilder(e);if(!t)return!0;for(let e=0;e<t.length;e++){let r=t[e];if(typeof r==`string`)continue;let{token:i}=r,a=Ce(i),o=this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET),s=o.getActiveSheet(),c=o.getUnitId();if(a.sheetName){if(s=o.getSheetBySheetName(a.sheetName),!s)return!1;let e=s==null?void 0:s.getSheetId();if(!this._permissionService.getPermissionPoint(new Fe(c,e).id))return!1}if(!s)return!1;let{startRow:l,endRow:u,startColumn:d,endColumn:f}=a.range;for(let e=l;e<=u;e++)for(let t=d;t<=f;t++){var n;let r=(n=s.getCell(e,t))==null||(n=n.selectionProtection)==null?void 0:n[0];if((r==null?void 0:r[Ve.View])===!1)return!1}}return!0}};Tt=F([P(0,f),P(1,u),P(2,p(A))],Tt);var Et=`@univerjs/sheets-data-validation`,Dt=`0.18.0`;const Ot=`sheets-data-validation.config`;Symbol(Ot);const kt={};let At=class extends s{constructor(e,t,n){super(),this._dataValidationModel=e,this._formulaRefRangeService=t,this._validatorRegistryService=n,N(this,`_disposableMap`,new Map),N(this,`registerRule`,(e,t,n)=>{B(n.type,this._validatorRegistryService)&&this.register(e,t,n)}),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}register(e,t,n){let r=n.ranges,i=n.formula1,a=n.formula2,o=this._formulaRefRangeService.registerRangeFormula(e,t,r,[i==null?``:i,a==null?``:a],o=>{if(o.length===0)return{undos:[{id:C.id,params:{unitId:e,subUnitId:t,rule:n,source:`patched`}}],redos:[{id:D.id,params:{unitId:e,subUnitId:t,ruleId:n.uid,source:`patched`}}]};let s=[],c=[],l=o[0];s.push({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.uid,payload:{type:k.ALL,payload:{ranges:l.ranges,formula1:l.formulas[0],formula2:l.formulas[1]}},source:`patched`}}),c.push({id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.uid,payload:{type:k.ALL,payload:{ranges:r,formula1:i,formula2:a}},source:`patched`}});for(let r=1;r<o.length;r++){let i=o[r],a=ce();s.push({id:C.id,params:{unitId:e,subUnitId:t,rule:{...n,uid:a,formula1:i.formulas[0],formula2:i.formulas[1],ranges:i.ranges},source:`patched`}}),c.push({id:D.id,params:{unitId:e,subUnitId:t,ruleId:a,source:`patched`}})}return{undos:c,redos:s}}),s=this._getIdWithUnitId(e,t,n.uid);this._disposableMap.set(s,o)}_initRefRange(){let e=this._dataValidationModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this.registerRule(t,e,n);this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r}=e;switch(e.type){case`add`:{let t=e.rule;this.registerRule(e.unitId,e.subUnitId,t);break}case`remove`:{let e=this._disposableMap.get(this._getIdWithUnitId(t,n,r.uid));e&&e.dispose();break}case`update`:{let r=e.rule,i=this._disposableMap.get(this._getIdWithUnitId(t,n,r.uid));i&&i.dispose(),this.registerRule(e.unitId,e.subUnitId,r);break}}})),this.disposeWithMe(me(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};At=F([P(0,p(q)),P(1,p(He)),P(2,p(E))],At);let jt=class extends s{constructor(e,t,n,r,i,a){super(),this._dataValidationModel=e,this._injector=t,this._refRangeService=n,this._dataValidationFormulaService=r,this._formulaRefRangeService=i,this._validatorRegistryService=a,N(this,`_disposableMap`,new Map),N(this,`registerRule`,(e,t,n)=>{B(n.type,this._validatorRegistryService)||(this.register(e,t,n),this.registerFormula(e,t,n))}),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}registerFormula(e,t,n){var r;let i=n.uid,a=this._getIdWithUnitId(e,t,i),o=(r=this._disposableMap.get(a))==null?new Set:r,s=(r,a)=>{let o=this._dataValidationModel.getRuleById(e,t,i);if(!o)return{redos:[],undos:[]};let s=o[r];if(!s||s===a)return{redos:[],undos:[]};let c={unitId:e,subUnitId:t,ruleId:n.uid,payload:{type:k.SETTING,payload:{type:o.type,formula1:o.formula1,formula2:o.formula2,[r]:a}},source:`patched`},l={unitId:e,subUnitId:t,ruleId:n.uid,payload:{type:k.SETTING,payload:{type:o.type,formula1:o.formula1,formula2:o.formula2}},source:`patched`};return{redos:[{id:O.id,params:c}],undos:[{id:O.id,params:l}]}},c=this._dataValidationFormulaService.getRuleFormulaInfo(e,t,i);if(c){let[n,r]=c;if(n){let r=this._formulaRefRangeService.registerFormula(e,t,n.text,e=>s(`formula1`,e));o.add(()=>r.dispose())}if(r){let n=this._formulaRefRangeService.registerFormula(e,t,r.text,e=>s(`formula2`,e));o.add(()=>n.dispose())}}}register(e,t,n){var r;let i=r=>{let i=[...n.ranges],a=i.map(e=>Le(e,r)).filter(e=>!!e).flat();if(de(a,i))return{redos:[],undos:[]};if(a.length){let r={unitId:e,subUnitId:t,ruleId:n.uid,payload:{type:k.RANGE,payload:a},source:`patched`};return{redos:[{id:O.id,params:r}],undos:[{id:O.id,params:{unitId:e,subUnitId:t,ruleId:n.uid,payload:{type:k.RANGE,payload:i},source:`patched`}}]}}else{let r={unitId:e,subUnitId:t,ruleId:n.uid};return{redos:[{id:D.id,params:r}],undos:St(this._injector,r)}}},a=[];n.ranges.forEach(n=>{let r=this._refRangeService.registerRefRange(n,i,e,t);a.push(()=>r.dispose())});let o=this._getIdWithUnitId(e,t,n.uid),s=(r=this._disposableMap.get(o))==null?new Set:r;s.add(()=>a.forEach(e=>e())),this._disposableMap.set(o,s)}_initRefRange(){let e=this._dataValidationModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this.registerRule(t,e,n);this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r}=e;switch(e.type){case`add`:{let t=e.rule;this.registerRule(e.unitId,e.subUnitId,t);break}case`remove`:{let e=this._disposableMap.get(this._getIdWithUnitId(t,n,r.uid));e&&e.forEach(e=>e());break}case`update`:{let r=e.rule,i=this._disposableMap.get(this._getIdWithUnitId(t,n,r.uid));i&&i.forEach(e=>e()),this.registerRule(e.unitId,e.subUnitId,r);break}}})),this.disposeWithMe(me(()=>{this._disposableMap.forEach(e=>{e.forEach(e=>e())}),this._disposableMap.clear()}))}};jt=F([P(0,p(q)),P(1,p(m)),P(2,p(ke)),P(3,p(K)),P(4,p(He)),P(5,p(E))],jt);let Mt=class extends s{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._sheetDataValidationModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===Ae.id){var t;let n=e.params,r=n.unitId||this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET).getUnitId(),i=this._univerInstanceService.getUniverSheetInstance(r);if(!i)return{redos:[],undos:[]};let a=n.subUnitId||((t=i.getActiveSheet())==null?void 0:t.getSheetId());if(!a)return{redos:[],undos:[]};let o=this._sheetDataValidationModel.getRules(r,a);if(o.length===0)return{redos:[],undos:[]};let s={unitId:r,subUnitId:a,ruleId:o.map(e=>e.uid),source:`patched`},c={unitId:r,subUnitId:a,rule:[...o],source:`patched`};return{redos:[{id:D.id,params:s}],undos:[{id:C.id,params:c}]}}else if(e.id===Oe.id){let{unitId:t,subUnitId:n,targetSubUnitId:r}=e.params;if(!t||!n||!r)return{redos:[],undos:[]};let i=this._sheetDataValidationModel.getRules(t,n);if(i.length===0)return{redos:[],undos:[]};let a=i.map(e=>({...e,uid:ce(6)}));return{redos:[{id:C.id,params:{unitId:t,subUnitId:r,rule:a,source:`patched`}}],undos:[{id:D.id,params:{unitId:t,subUnitId:r,ruleId:a.map(e=>e.uid),source:`patched`}}]}}return{redos:[],undos:[]}}}))}};Mt=F([P(0,p(Ne)),P(1,p(f)),P(2,p(q))],Mt);var Nt=class extends w{constructor(...e){super(...e),N(this,`id`,a.ANY),N(this,`title`,`dataValidation.any.title`),N(this,`operators`,[]),N(this,`scopes`,[`sheet`]),N(this,`order`,0),N(this,`offsetFormulaByRange`,!1)}async parseFormula(e,t,n){return{formula1:e.formula1,formula2:e.formula2,isFormulaValid:!0}}validatorFormula(e,t,n){return{success:!0}}async isValidType(e,t,n){return!0}generateRuleErrorMessage(e){return this.localeService.t(`dataValidation.any.error`)}},Pt=class extends w{constructor(...e){super(...e),N(this,`id`,a.CUSTOM),N(this,`title`,`dataValidation.custom.title`),N(this,`operators`,[]),N(this,`scopes`,[`sheet`]),N(this,`order`,60),N(this,`_customFormulaService`,this.injector.get(V)),N(this,`_lexerTreeBuilder`,this.injector.get(A))}validatorFormula(e,t,n){var r;let i=x(e.formula1),a=(r=e.formula1)==null?``:r,o=this._lexerTreeBuilder.checkIfAddBracket(a)===0&&a.startsWith(Te.EQUALS);return{success:i&&o,formula1:i&&o?``:this.localeService.t(`dataValidation.validFail.formula`)}}async parseFormula(e,t,n){return{formula1:void 0,formula2:void 0,isFormulaValid:!0}}async isValidType(t,n,r){let{column:i,row:a,unitId:o,subUnitId:s}=t,c=await this._customFormulaService.getCellFormulaValue(o,s,r.uid,a,i),l=c==null?void 0:c.v;return z(String(l))&&y.isDefine(l)&&l!==``?c.t===e.BOOLEAN?!!l:typeof l==`boolean`?l:typeof l==`number`?!!l:typeof l==`string`?z(l):!!l:!1}generateRuleErrorMessage(e){return this.localeService.t(`dataValidation.custom.error`)}generateRuleName(e){var t;return this.localeService.t(`dataValidation.custom.ruleName`).replace(`{FORMULA1}`,(t=e.formula1)==null?``:t)}},Ft=class extends ft{constructor(...e){super(...e),N(this,`id`,a.LIST_MULTIPLE),N(this,`title`,`dataValidation.listMultiple.title`),N(this,`offsetFormulaByRange`,!1),N(this,`skipDefaultFontRender`,()=>!0)}},It=class extends w{constructor(...e){super(...e),N(this,`_customFormulaService`,this.injector.get(V)),N(this,`_lexerTreeBuilder`,this.injector.get(A)),N(this,`id`,a.WHOLE),N(this,`title`,`dataValidation.whole.title`),N(this,`order`,10),N(this,`operators`,[n.BETWEEN,n.EQUAL,n.GREATER_THAN,n.GREATER_THAN_OR_EQUAL,n.LESS_THAN,n.LESS_THAN_OR_EQUAL,n.NOT_BETWEEN,n.NOT_EQUAL]),N(this,`scopes`,[`sheet`])}_isFormulaOrInt(e){return!y.isBlank(e)&&(x(e)||!Number.isNaN(+e)&&Number.isInteger(+e))}async isValidType(e,t,n){let{value:r}=e,i=Z(r);return!Number.isNaN(i)&&Number.isInteger(i)}transform(e,t,n){let{value:r}=e;return{...e,value:Z(r)}}_parseNumber(e){return e==null?NaN:+e}async parseFormula(e,t,n,r,i){let a=await this._customFormulaService.getCellFormulaValue(t,n,e.uid,r,i),o=await this._customFormulaService.getCellFormula2Value(t,n,e.uid,r,i),{formula1:s,formula2:c}=e,l=x(s)?a==null?void 0:a.v:s,u=x(c)?o==null?void 0:o.v:c,d=z(`${l}`)&&z(`${u}`);return{formula1:this._parseNumber(l),formula2:this._parseNumber(u),isFormulaValid:d}}validatorFormula(e,t,n){let r=e.operator;if(!r)return{success:!0};let i=y.isDefine(e.formula1)&&this._isFormulaOrInt(e.formula1),a=y.isDefine(e.formula2)&&this._isFormulaOrInt(e.formula2),o=rt.includes(r),s=this.localeService.t(`dataValidation.validFail.number`);return o?{success:i&&a,formula1:i?void 0:s,formula2:a?void 0:s}:{success:i,formula1:s}}generateRuleErrorMessage(e,t){if(!e.operator)return this.localeService.t(ot.NONE).replace(`{TYPE}`,this.titleStr);let{transformedFormula1:n,transformedFormula2:r}=W(this._lexerTreeBuilder,e,t);return`${this.localeService.t(ot[e.operator]).replace(Y,n==null?``:n).replace(X,r==null?``:r)}`}};let Lt=class extends re{constructor(e,t,n,r,i,a){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._injector=n,this._selectionManagerService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._init()}_init(){this._registerValidators(),this._initCommandInterceptor()}_registerValidators(){[Nt,st,It,pt,at,$e,ft,Ft,Pt].forEach(e=>{let t=this._injector.createInstance(e);this.disposeWithMe(this._dataValidatorRegistryService.register(t)),this.disposeWithMe(me(()=>this._injector.delete(e)))})}_initCommandInterceptor(){this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===De.id){var t;let e=this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET),n=e.getUnitId(),r=e.getActiveSheet();if(!r)throw Error(`No active sheet found`);let i=r.getSheetId(),a=(t=this._selectionManagerService.getCurrentSelections())==null?void 0:t.map(e=>e.range),o=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone();a&&o.removeRange(a);let{redoMutations:s,undoMutations:c}=ht(n,i,o.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,`patched`);return{undos:c,redos:s}}return{undos:[],redos:[]}}})}};Lt=F([P(0,f),P(1,p(E)),P(2,p(m)),P(3,p(Pe)),P(4,p(Ne)),P(5,p(q))],Lt);let Q=class extends s{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._sheetDataValidationModel=t,this._dataValidationCacheService=n,this._lifecycleService=r,this._initRecalculate()}_initRecalculate(){let e=e=>{if(e.length===0)return;let t=this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET),n=t==null?void 0:t.getActiveSheet(),r={};e.flat().forEach(e=>{r[e.unitId]||(r[e.unitId]={}),r[e.unitId][e.subUnitId]||(r[e.unitId][e.subUnitId]=[]);let t=this._univerInstanceService.getUnit(e.unitId,b.UNIVER_SHEET),n=t==null?void 0:t.getSheetBySheetId(e.subUnitId);n&&r[e.unitId][e.subUnitId].push(...e.ranges.map(e=>_.transformRange(e,n)))}),Object.entries(r).forEach(([e,r])=>{Object.entries(r).forEach(([r,i])=>{(t==null?void 0:t.getUnitId())===e&&(n==null?void 0:n.getSheetId())===r?this.validatorRanges(e,r,i):requestIdleCallback(()=>{this.validatorRanges(e,r,i)})})})};this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(ze(()=>this._lifecycleService.lifecycle$.pipe(Be(e=>e===g.Rendered)))).subscribe(e)),this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Be(()=>this._lifecycleService.stage>=g.Rendered),ae(20)).subscribe(e))}async _validatorByCell(e,t,n,r){let a=e.getUnitId(),o=t.getSheetId();if(!y.isDefine(n)||!y.isDefine(r))throw Error(`row or col is not defined, row: ${n}, col: ${r}`);let s=n,c=r,l=t.getMergedCell(n,r);l&&(s=l.startRow,c=l.startColumn);let u=this._sheetDataValidationModel.getRuleByLocation(a,o,s,c);return u?new Promise(n=>{this._sheetDataValidationModel.validator(u,{unitId:a,subUnitId:o,row:s,col:c,worksheet:t,workbook:e},e=>{n(e)})}):i.VALID}async validatorCell(e,t,n,r){let i=this._univerInstanceService.getUnit(e,b.UNIVER_SHEET);if(!i)throw Error(`cannot find current workbook, unitId: ${e}`);let a=i.getSheetBySheetId(t);if(!a)throw Error(`cannot find current worksheet, sheetId: ${t}`);return this._validatorByCell(i,a,n,r)}async validatorRanges(e,t,n){if(!n.length)return Promise.resolve([]);let r=this._univerInstanceService.getUnit(e,b.UNIVER_SHEET);if(!r)throw Error(`cannot find current workbook, unitId: ${e}`);let a=r.getSheetBySheetId(t);if(!a)throw Error(`cannot find current worksheet, sheetId: ${t}`);let o=this._sheetDataValidationModel.getRules(e,t).map(e=>e.ranges).flat(),s=n.map(e=>o.map(t=>le(e,t))).flat().filter(Boolean),c=[],l=await Promise.all(s.map((e,t)=>{let n=[];for(let i=e.startRow;i<=e.endRow;i++)for(let o=e.startColumn;o<=e.endColumn;o++){n.push(this._validatorByCell(r,a,i,o));let e=a.getMergedCell(i,o);e&&c.push({resultRowIndex:t,resultColIndex:n.length-1,row:e.startRow,col:e.startColumn})}return Promise.all(n)}));return c.length&&c.forEach(({resultRowIndex:n,resultColIndex:r,row:a,col:o})=>{if(l[n][r]===i.VALIDATING){var s;l[n][r]=(s=this._dataValidationCacheService.getValue(e,t,a,o))==null?i.VALID:s}}),l}async validatorWorksheet(e,t){let n=this._univerInstanceService.getUnit(e,b.UNIVER_SHEET);if(!n)throw Error(`cannot find current workbook, unitId: ${e}`);let r=n.getSheetBySheetId(t);if(!r)throw Error(`cannot find current worksheet, sheetId: ${t}`);let i=this._sheetDataValidationModel.getRules(e,t);return await Promise.all(i.map(e=>Promise.all(e.ranges.map(e=>{let t=[];return _.foreach(e,(e,i)=>{t.push(this._validatorByCell(n,r,e,i))}),Promise.all(t)})))),this._dataValidationCacheService.ensureCache(e,t)}async validatorWorkbook(e){let t=this._sheetDataValidationModel.getSubUnitIds(e),n=await Promise.all(t.map(t=>this.validatorWorksheet(e,t))),r={};return n.forEach((e,n)=>{r[t[n]]=e}),r}getDataValidations(e,t,n){let r=this._sheetDataValidationModel.getRuleObjectMatrix(e,t),i=new Set;return n.forEach(e=>{_.foreach(e,(e,t)=>{let n=r.getValue(e,t);n&&i.add(n)})}),Array.from(i).map(n=>this._sheetDataValidationModel.getRuleById(e,t,n)).filter(Boolean)}getDataValidation(e,t,n){return this.getDataValidations(e,t,n)[0]}};Q=F([P(0,f),P(1,p(q)),P(2,p(I)),P(3,p(h))],Q);let $=class extends te{constructor(e=kt,t,n,r){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=r;let{...i}=fe({},kt,this._config);this._configService.setConfig(Ot,i)}onStarting(){[[I],[G],[K],[V],[Q],[q],[Lt],[Tt],[Mt],[jt],[At]].forEach(e=>{this._injector.add(e)}),[_t,gt,vt,yt,Ct,xt,bt].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(I),this._injector.get(Q),this._injector.get(Lt),this._injector.get(At),this._injector.get(jt)}onReady(){this._injector.get(Mt)}onRendered(){this._injector.get(Tt)}};N($,`pluginName`,wt),N($,`packageName`,Et),N($,`version`,Dt),N($,`type`,b.UNIVER_SHEET),$=F([o(Ue,ge),P(1,p(m)),P(2,c),P(3,l)],$);function Rt(e){let t=e.get(Pe).getCurrentSelections().map(e=>e.range);return{uid:ce(6),type:a.DECIMAL,operator:n.EQUAL,formula1:`100`,ranges:t==null?[{startColumn:0,endColumn:0,startRow:0,endRow:0}]:t}}const zt=`data-validation.custom-formula-input`,Bt=`data-validation.formula-input`,Vt=`data-validation.list-formula-input`,Ht=`data-validation.checkbox-formula-input`;export{_t as AddSheetDataValidationCommand,Bt as BASE_FORMULA_INPUT_NAME,Xe as CHECKBOX_FORMULA_1,Ze as CHECKBOX_FORMULA_2,Ht as CHECKBOX_FORMULA_INPUT_NAME,zt as CUSTOM_FORMULA_INPUT_NAME,$e as CheckboxValidator,bt as ClearRangeDataValidationCommand,wt as DATA_VALIDATION_PLUGIN_NAME,I as DataValidationCacheService,V as DataValidationCustomFormulaService,Tt as DataValidationFormulaController,K as DataValidationFormulaService,G as DataValidationListCacheService,at as DateValidator,Vt as LIST_FORMULA_INPUT_NAME,Ft as ListMultipleValidator,ft as ListValidator,xt as RemoveSheetAllDataValidationCommand,Ct as RemoveSheetDataValidationCommand,q as SheetDataValidationModel,Q as SheetsDataValidationValidatorService,$ as UniverSheetsDataValidationPlugin,yt as UpdateSheetDataValidationOptionsCommand,gt as UpdateSheetDataValidationRangeCommand,vt as UpdateSheetDataValidationSettingCommand,Rt as createDefaultNewRule,U as deserializeListOptions,Z as getCellValueNumber,H as getCellValueOrigin,Je as getDataValidationCellValue,ht as getDataValidationDiffMutations,R as getFormulaCellData,L as getFormulaResult,W as getTransformedFormula,z as isLegalFormulaResult,qe as serializeListOptions,J as transformCheckboxValue};
|